use super::super::{CliCommandSpec, CommandEffect, arg, command_syntax, opt};
pub(in crate::interfaces::cli::spec) fn repo_query() -> CliCommandSpec {
command!(
&["repo", "query"],
"relay-knowledge repo query <alias> --query <text> [--kind <kind>] [--ref <ref>] [--path <filter>] [--language <id>] [--freshness <policy>] [--exclude-generated] [--limit <n>]",
"Retrieve code symbols, references, and chunks from a repository index.",
"code.repo.query",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--query",
Some("text"),
true,
false,
"Code search text; multiple unflagged words after --query are joined.",
None,
&[],
),
opt(
"--kind",
Some("kind"),
false,
false,
"Code retrieval mode.",
Some("hybrid"),
&[
"hybrid",
"symbol",
"definition",
"references",
"callers",
"callees",
"imports",
"sbom",
],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--path",
Some("filter"),
false,
true,
"Restricts query to indexed path prefix.",
None,
&[],
),
opt(
"--language",
Some("id"),
false,
true,
"Restricts query to language id.",
None,
&[],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls index freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum result count requested from the API.",
Some("10"),
&[],
),
opt(
"--exclude-generated",
None,
false,
false,
"Exclude generated files from query results.",
None,
&[],
),
],
&["relay-knowledge repo query core --query retry_policy --kind definition --format json"],
&[
"The meaning of --kind is command-local; do not reuse index or worker kind values here.",
"Generated files remain indexed for freshness and statistics; --exclude-generated only filters retrieval results.",
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_graph() -> CliCommandSpec {
command!(
&["repo", "graph"],
"relay-knowledge repo graph <alias> --focus <path> --path <root> [--ref <ref>] [--depth <1|2>] [--node-limit <n>] [--edge-limit <n>]",
"Read a bounded OKF concept/source neighborhood from one fresh indexed snapshot.",
"code.repo.graph",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--focus",
Some("path"),
true,
false,
"Indexed OKF concept Markdown path.",
None,
&[],
),
opt(
"--path",
Some("root"),
true,
true,
"Explicit OKF bundle root containing the focus concept.",
None,
&[],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Fresh indexed Git ref.",
Some("HEAD"),
&[],
),
opt(
"--depth",
Some("1|2"),
false,
false,
"Concept-link traversal depth.",
Some("1"),
&["1", "2"],
),
opt(
"--node-limit",
Some("n"),
false,
false,
"Maximum returned nodes, capped at 100.",
Some("100"),
&[],
),
opt(
"--edge-limit",
Some("n"),
false,
false,
"Maximum returned edges, capped at 200.",
Some("200"),
&[],
),
],
&[
"relay-knowledge repo graph stone-star --focus knowledge/investment-research/rates.md --path knowledge/investment-research --ref HEAD --format json"
],
&[
"The graph is derived only from indexed Markdown at the resolved commit; it never reads the live worktree.",
"The selected snapshot must be fresh, and the focus must stay inside an explicit path root.",
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_context() -> CliCommandSpec {
command!(
&["repo", "context"],
"relay-knowledge repo context <alias> --query <text> [--ref <ref>] [--path <filter>] [--language <id>] [--freshness <policy>] [--limit <n>] [--max-context-bytes <n>] [--no-code] [--exclude-generated]",
"Build a one-call codegraph context pack for coding agents.",
"code.repo.context",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--query",
Some("text"),
true,
false,
"Context request text; multiple unflagged words after --query are joined.",
None,
&[],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--path",
Some("filter"),
false,
true,
"Restricts context to indexed path prefix.",
None,
&[],
),
opt(
"--language",
Some("id"),
false,
true,
"Restricts context to language id.",
None,
&[],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls index freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum entry, related-symbol, and graph-path count per group.",
Some("8"),
&[],
),
opt(
"--max-context-bytes",
Some("n"),
false,
false,
"Maximum serialized context pack size.",
Some("65536"),
&[],
),
opt(
"--no-code",
None,
false,
false,
"Omit code excerpts while keeping provenance and graph evidence.",
None,
&[],
),
opt(
"--exclude-generated",
None,
false,
false,
"Exclude generated files from context evidence.",
None,
&[],
),
],
&[
"relay-knowledge repo context core --query \"retry_policy callers imports\" --format json",
],
&[
"The command orchestrates existing code graph queries and does not trigger repository indexing or refresh.",
"JSON includes entry_points, related_symbols, graph_paths, impact_hints, code_excerpts, freshness, budget, and truncation diagnostics.",
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_feature_flags() -> CliCommandSpec {
command!(
&["repo", "feature-flags"],
"relay-knowledge repo feature-flags <alias> [--query <text>] [--ref <ref>] [--path <filter>] [--language <id>] [--freshness <policy>] [--limit <n>]",
"List configuration-driven feature flags and code relationships from a repository index.",
"code.repo.feature_flags",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--query",
Some("text"),
false,
false,
"Optional filter over feature flag name, config key, path, or excerpt.",
None,
&[],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--path",
Some("filter"),
false,
true,
"Restricts query to indexed path prefix.",
None,
&[],
),
opt(
"--language",
Some("id"),
false,
true,
"Restricts query to language id.",
None,
&[],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls index freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum feature flag groups requested from the API.",
Some("50"),
&[],
),
],
&["relay-knowledge repo feature-flags core --query checkout --format json"],
&[
"Feature flags are indexed facts; this command does not scan the repository at query time."
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_framework() -> CliCommandSpec {
command!(
&["repo", "framework"],
"relay-knowledge repo framework <alias> [--query <text>] [--framework <angular|vue>] [--kind <kind>] [--ref <ref>] [--path <filter>] [--freshness <policy>] [--limit <n>]",
"Read the bounded Angular/Vue component and template graph from a repository index.",
"code.repo.framework_graph",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--query",
Some("text"),
false,
false,
"Optional filter over names, targets, details, and paths.",
None,
&[],
),
opt(
"--framework",
Some("framework"),
false,
true,
"Restricts results to a framework family.",
None,
&["angular", "vue"],
),
opt(
"--kind",
Some("kind"),
false,
true,
"Restricts node results to a framework construct kind.",
None,
&[
"component",
"directive",
"pipe",
"template",
"input",
"output",
"prop",
"emit",
"model",
"slot",
"template-variable",
"control-flow",
],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--path",
Some("filter"),
false,
true,
"Restricts query to an indexed path prefix.",
None,
&[],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls index freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum nodes and maximum edges requested from the API.",
Some("50"),
&[],
),
],
&["relay-knowledge repo framework frontend --framework vue --kind component --format json"],
&[
"Framework facts are extracted during durable indexing; this command does not scan source files at query time."
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_impact() -> CliCommandSpec {
command!(
&["repo", "impact"],
"relay-knowledge repo impact <alias> --base <ref> --head <ref> [--limit <n>]",
"Analyze code impact between two refs.",
"code.repo.impact",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--base",
Some("ref"),
true,
false,
"Base ref for diff analysis.",
None,
&[],
),
opt(
"--head",
Some("ref"),
true,
false,
"Head ref for diff analysis.",
None,
&[],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum impact result count.",
Some("100"),
&[],
),
],
&["relay-knowledge repo impact core --base main --head HEAD --format json"],
&[],
)
}
pub(in crate::interfaces::cli::spec) fn repo_view() -> CliCommandSpec {
command!(
&["repo", "view"],
"relay-knowledge repo view <alias> [--kind architecture-layers|business-domains|dependency-tour|process-flow|affected-scope] [--ref <ref>] [--path <filter>] [--language <id>] [--freshness <policy>] [--limit <n>] [--changed-path <path>]",
"Read an evidence-backed codebase understanding view derived from indexed graph facts.",
"code.repo.view",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--kind",
Some("kind"),
false,
false,
"View family to derive.",
Some("architecture-layers"),
&[
"architecture-layers",
"business-domains",
"dependency-tour",
"process-flow",
"affected-scope",
],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--path",
Some("filter"),
false,
true,
"Restricts the selected repository scope by path prefix.",
None,
&[],
),
opt(
"--language",
Some("id"),
false,
true,
"Restricts the selected repository scope by language id.",
None,
&[],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls code graph freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum node, edge, and section count requested from the API.",
Some("20"),
&[],
),
opt(
"--changed-path",
Some("path"),
false,
true,
"Changed path used by affected-scope deterministic v1.",
None,
&[],
),
],
&[
"relay-knowledge repo view core --kind dependency-tour --freshness wait-until-fresh --format json",
"relay-knowledge repo view core --kind affected-scope --changed-path src/lib.rs --format json",
],
&[
"Views are derived read models from committed code graph facts; narrative sections are not persisted as graph facts.",
"`affected-scope` requires one or more `--changed-path` values in deterministic v1.",
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_software() -> CliCommandSpec {
command!(
&["repo", "software"],
"relay-knowledge repo software <alias> [--ref <ref>] [--kind dependencies|sdks|files|topics|relationships|build|iac|design|systems|apis|resources|tests|deployments|releases|statements|conflicts|all] [--freshness <policy>] [--limit <n>]",
"Read compatible software projections and provenance-bearing ontology entities, statements, and conflicts.",
"code.repo.software",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--kind",
Some("kind"),
false,
false,
"Software global projection slice.",
Some("all"),
&[
"dependencies",
"sdks",
"files",
"topics",
"relationships",
"build",
"iac",
"design",
"systems",
"apis",
"resources",
"tests",
"deployments",
"releases",
"statements",
"conflicts",
"all",
],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls projection freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Result bound; kind=all shares one strict total across slices using deterministic round-robin.",
Some("100"),
&[],
),
],
&["relay-knowledge repo software core --kind all --format json"],
&[
"The projection is built from authorized repository index facts and retains ontology version, source coverage, evidence, freshness, completeness, and conflict diagnostics."
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_software_export() -> CliCommandSpec {
command!(
&["repo", "software", "export"],
"relay-knowledge repo software export <alias> --profile spdx-3|cyclonedx-1.7|prov-o [--ref <ref>] [--freshness <policy>] [--limit <n>]",
"Export the snapshot-bound software ontology through a standard interoperability profile.",
"code.repo.software_export",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[],
)],
&[
opt(
"--profile",
Some("profile"),
true,
false,
"Standard mapping profile.",
None,
&["spdx-3", "cyclonedx-1.7", "prov-o"],
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed Git ref or worktree selector.",
Some("HEAD"),
&[],
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls projection freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"],
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum ontology rows used by the bounded export.",
Some("500"),
&[],
),
],
&["relay-knowledge repo software export core --profile cyclonedx-1.7 --format json"],
&[
"SPDX uses the 3.0.1 JSON-LD context; CycloneDX uses the 1.7 JSON schema; PROV-O emits JSON-LD Entity, Activity, Agent, and provenance relations."
],
)
}
pub(in crate::interfaces::cli::spec) fn repo_business() -> CliCommandSpec {
command!(
&["repo", "business"],
"relay-knowledge repo business <alias> [--kind terms|mappings|all] [--query <text>] [--domain <id>] [--ref <ref>] [--freshness <policy>] [--limit <n>]",
"Read authored business terms and their declared technical mappings from an indexed repository scope.",
"code.repo.business",
CommandEffect::ReadOnly,
&[arg(
"alias",
true,
false,
"Registered repository alias.",
None,
&[]
)],
&[
opt(
"--kind",
Some("kind"),
false,
false,
"Business projection slice.",
Some("all"),
&["terms", "mappings", "all"]
),
opt(
"--query",
Some("text"),
false,
false,
"Canonical name, alias, definition, or mapping hint.",
None,
&[]
),
opt(
"--domain",
Some("id"),
false,
false,
"Domain id or declared domain name used for disambiguation.",
None,
&[]
),
opt(
"--ref",
Some("ref"),
false,
false,
"Indexed immutable Git ref.",
Some("HEAD"),
&[]
),
opt(
"--freshness",
Some("policy"),
false,
false,
"Controls projection freshness.",
Some("allow-stale"),
&["allow-stale", "wait-until-fresh", "graph-only"]
),
opt(
"--limit",
Some("n"),
false,
false,
"Maximum returned terms.",
Some("100"),
&[]
),
],
&["relay-knowledge repo business core --kind all --query MRR --format json"],
&[
"The command reads the fenced business projection; it never scans glossary YAML at query time."
],
)
}
#[cfg(test)]
#[path = "mod_tests.rs"]
mod tests;