@c4a/context-cli 0.6.17 → 0.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +6 -2
  2. package/README.zh-CN.md +5 -2
  3. package/cli.js +11452 -7269
  4. package/docs/document-optimization.md +35 -11
  5. package/docs/document-optimization.zh-CN.md +29 -9
  6. package/package.json +2 -2
  7. package/plugins/VERSION +1 -1
  8. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  9. package/plugins/claude/commands/context.md +44 -6
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +44 -6
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +44 -6
  14. package/plugins/skills/c4a-context/SKILL.md +44 -6
  15. package/providers/context/actions/apply-code-index-guidance.yaml +5 -0
  16. package/providers/context/actions/apply-forced-review.yaml +5 -0
  17. package/providers/context/actions/maintain-evidence.yaml +1 -1
  18. package/providers/context/actions/migrate-codeindex.yaml +5 -0
  19. package/providers/context/actions/register-source-batch.yaml +1 -1
  20. package/providers/context/actions/restore-repository-sources.yaml +1 -1
  21. package/providers/context/actions/revise-code-index-audit.yaml +5 -0
  22. package/providers/context/actions/submit-code-index-audit.yaml +6 -0
  23. package/providers/context/codes.yaml +5 -0
  24. package/providers/context/graphs/workspace.yaml +82 -2
  25. package/providers/context/manifest.json +128 -56
  26. package/providers/context/provider.yaml +1 -1
  27. package/providers/context/resources/dialogue/code-extraction.md +12 -0
  28. package/providers/context/resources/dialogue/document-classification.md +1 -1
  29. package/providers/context/resources/dialogue/knowledge-review.md +16 -1
  30. package/providers/context/resources/dialogue/source-boundary.md +9 -1
  31. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +11 -8
  32. package/providers/context/resources/dialogue/workflow-mode-after-creation.md +6 -4
  33. package/providers/context/resources/manuals/guides/lark-resources.md +7 -0
  34. package/providers/context/resources/manuals/guides/package-outputs.md +3 -3
  35. package/providers/context/resources/manuals/reference/code-extractors.md +5 -4
  36. package/providers/context/resources/manuals/reference/package-templates.md +18 -10
  37. package/providers/context/resources/manuals/reference/project-api.md +56 -24
  38. package/providers/context/resources/procedures/close-and-build.md +26 -3
  39. package/providers/context/resources/procedures/code-extraction.md +45 -7
  40. package/providers/context/resources/procedures/code-index-audit.md +83 -0
  41. package/providers/context/resources/procedures/document-capture.md +9 -0
  42. package/providers/context/resources/procedures/document-optimization.md +69 -21
  43. package/providers/context/resources/procedures/document-revision.md +11 -6
  44. package/providers/context/resources/procedures/knowledge-review.md +10 -1
  45. package/providers/context/resources/procedures/source-boundary.md +20 -8
  46. package/providers/context/resources/semantic/align/structure-planning.md +4 -4
  47. package/providers/context/resources/semantic/code-index/classification.md +8 -5
  48. package/providers/context/resources/views/code-index-audit.yaml +6 -0
  49. package/providers/context/schemas/code-index-audit-decision.schema.json +94 -0
  50. package/providers/context/schemas/document-optimization-decisions.schema.json +29 -6
  51. package/providers/context/schemas/source-batch-input.schema.json +18 -3
@@ -27,6 +27,10 @@ selected package's public SDK/README before editing `src/index.ts`; never infer
27
27
  its API from bundled output. `moduleTypeEvidence` must identify the inspected
28
28
  paths that support the classification. An `unknown` unit or a unit with no
29
29
  classification evidence is an incomplete index plan.
30
+ Record exact source-relative Markdown paths read during classification in
31
+ `indexUnits[].documents`. Context inventories module Markdown independently:
32
+ root README or documentation entry files require complete reading, while other
33
+ related Markdown uses the reported Floor and Target coverage.
30
34
 
31
35
  For every custom extraction preview, Context probes source paths for known
32
36
  community structural capabilities: TypeScript symbols, React Router routes, Go
@@ -49,6 +53,15 @@ public-contract plan. Scan mode, repository collections, and custom extraction
49
53
  must declare their index units explicitly; an inferred plan is diagnostic only
50
54
  and cannot write candidates.
51
55
 
56
+ Every index unit must expose one inventory contract. Built-in parsers produce
57
+ it from AST and source traversal; a project adapter returns the same generic
58
+ shape. The inventory separates eligible/analyzed files and non-empty LOC,
59
+ discovered/read Markdown, discovered/analyzed/target/exported symbols, stable
60
+ entries and profile-selected boundaries, plus excluded files and reasons. JSON,
61
+ YAML, lockfiles and assets may be evidence but do not inflate source LOC.
62
+ Evidence-only adapter output is explicitly `unscorable` and cannot pass the
63
+ mechanical quality Gate as a complete module index.
64
+
52
65
  Extractor output shape must match the semantic plan. `extractTs()` projects one
53
66
  candidate page per selected symbol and assigns each source to one index unit;
54
67
  it is suitable for a deliberately granular public reference. Aggregated module
@@ -82,13 +95,17 @@ rerun the batch preview, then process exactly one pending extraction target and
82
95
  evaluate again. Do not add a second classification Gate after the page-count
83
96
  Gate; a plan revision returns through the same configuration step.
84
97
 
85
- A batch-total page warning and quality risks such as a thin aggregate are
86
- advisory only. They remain visible for cost and content-shape review but do not
87
- become a new Gate. Legal scale recovery includes narrowing `include`, excluding
88
- generated or mirrored directories, enabling `exportedOnly`, moving from a
89
- symbol catalog to an aggregated `extractCustom()` plan, or registering real
90
- child sources. Splitting one `extractTs()` source into overlapping units is not
91
- a valid workaround.
98
+ A batch-total page warning remains advisory. After extraction, independent
99
+ mechanical dimensions enforce source analysis, target-boundary coverage,
100
+ facts/explanation, evidence scope, implementation ratio, and page shape.
101
+ Aggregate custom candidates are rendered only from evidence-scoped `sections`;
102
+ free Markdown, empty optional sections, template instructions, and placeholders
103
+ cannot become reader-facing knowledge. A required Section without evidence is a
104
+ material/capability gap instead of an empty heading. Legal scale recovery
105
+ includes narrowing `include`, excluding generated or mirrored directories,
106
+ enabling `exportedOnly`, moving from a symbol catalog to an aggregated
107
+ `extractCustom()` plan, or registering real child sources. Splitting one
108
+ `extractTs()` source into overlapping units is not a valid workaround.
92
109
 
93
110
  Current previews are cached below `.tmp/context-runtime/extract/previews/` and
94
111
  formal extraction reuses their validated structural result. Cache identity is
@@ -97,6 +114,12 @@ locks, and the preview protocol. Deleting
97
114
  `.tmp` only causes a fresh preview. Existing approved knowledge is not
98
115
  retroactively rejected solely because it is large.
99
116
 
117
+ New workspaces write `knowledge/codeindex/**`. If an old workspace contains
118
+ legacy `knowledge/codegraph/**`, follow the Route-returned
119
+ `context migrate codeindex --format json` action. It rewrites formal collection
120
+ identities and invalidates derived extraction/audit state without requiring
121
+ `.tmp`. Never create a permanent dual-write or move the directory by hand.
122
+
100
123
  Do not open Review while another extraction target in the same batch remains.
101
124
  Unchanged approved or rejected symbols do not need another decision; new or
102
125
  changed candidates remain subject to the current Review policy.
@@ -144,3 +167,18 @@ extractor, keep the lifecycle in `extractCustom()` and implement only the
144
167
  missing project adapter. If reliable syntax facts cannot be produced, stop at
145
168
  configuration and report the generic capability gap rather than emitting an
146
169
  empty or guessed graph.
170
+ # Agent audit after extraction
171
+
172
+ After every complete code-extraction batch, the Route produces one batch-level
173
+ code-index audit. Mechanical signals cover content depth, evidence scope,
174
+ declared-source coverage, and structured handoffs. A dimension outside its
175
+ absolute bounds is a mechanical rejection and cannot be accepted. Advisory or
176
+ elevated signals inside those bounds remain review evidence: the Agent must
177
+ inspect the affected pages and submit one `accept`, `revise`, or
178
+ `request-input` decision for all index units together.
179
+
180
+ Do not split this into one confirmation per module. In fully managed operation,
181
+ real issues select `revise` and the Route returns through project configuration,
182
+ batch Preview, extraction, and a new audit until the index is acceptable. A
183
+ false positive may be accepted only with a concrete inspected reason. Ask the
184
+ user only when reliable correction needs unavailable material or access.
@@ -0,0 +1,83 @@
1
+ ---
2
+ id: procedure.code-index-audit
3
+ kind: procedure
4
+ mediaType: text/markdown
5
+ ---
6
+
7
+ # Code-index Agent audit
8
+
9
+ This Route is a required semantic review of the complete proposed code index.
10
+ The CLI reports mechanical signals; the Agent reads the affected candidate
11
+ content and evidence, compares registered sources with the user-confirmed
12
+ scope, and decides whether the index is fit for its declared output profiles.
13
+ Reader metrics exclude Context lifecycle comments and evidence annotations.
14
+ Improve the source-backed knowledge itself; do not change Markdown syntax,
15
+ sentence count, or pagination solely to influence a mechanical counter.
16
+
17
+ The report contains no aggregate score. Every dimension is computed
18
+ independently with its observed value, floor, recommended target, ceiling,
19
+ mechanical score, uncovered identities, and legal repair actions. A dimension
20
+ outside its absolute bounds cannot be accepted or offset by another strong
21
+ dimension. Every elevated signal must receive an assessment tied to inspected
22
+ content. Submit one `context.code-index-audit-decision.v1` payload for the
23
+ complete batch.
24
+
25
+ Read the complete inventory before deciding. It separates eligible and
26
+ analyzed files/LOC, read documents, target and exported symbols, stable entries,
27
+ protocol boundaries, exclusions, and parser gaps. For each failed or
28
+ below-target dimension, use the returned uncovered identities, affected pages,
29
+ recommended template resources, and action vocabulary. Do not replace those
30
+ facts with an inferred file list.
31
+
32
+ For custom adapters, file and symbol identity arrays are complete denominators,
33
+ not samples: their lengths must match the declared counts, analyzed identities
34
+ must belong to eligible identities, and exported identities must belong to the
35
+ target-symbol set. For a single-source unit, the CLI independently enumerates
36
+ the represented language families plus Markdown/MDX after declared exclusions;
37
+ an adapter cannot make its ratio pass by reporting only hand-picked evidence
38
+ files. Conventional sibling page entries, Go route-register calls, and exported
39
+ operations from a declared Go handler source of truth are also independently
40
+ enumerated; include every discovered identity in the target-symbol and boundary
41
+ denominators even when one aggregate page explains them. Section evidence may
42
+ contain multiple files and may overlap
43
+ another Section when one fact crosses a boundary. It must not be reduced to one
44
+ arbitrary primary file, and every Section must not repeat the complete page
45
+ evidence set merely to satisfy coverage. Distinct structured relationships must
46
+ cite the concrete evidence for their own handoff instead of repeating one whole
47
+ page evidence set across every destination.
48
+
49
+ ## Decisions
50
+
51
+ - `accept`: the requested scope is represented, every dimension is within its
52
+ absolute bounds, and every real content-depth, evidence-scope, template, and
53
+ relationship issue is resolved. A below-target dimension remains visible
54
+ and needs a concrete reason in ordinary operation.
55
+ - `revise`: one or more real problems remain. Identify the affected units and
56
+ describe changes to scope, aggregation, sections, evidence, or structured
57
+ handoffs. The Route returns to `src/index.ts`, Preview, extraction, and a new
58
+ audit revision.
59
+ - `request-input`: reliable revision requires material unavailable in the
60
+ registered sources, such as an external protocol or missing source boundary.
61
+ Ask only for that material, then submit a new decision.
62
+
63
+ ## Fully managed operation
64
+
65
+ Fully managed authority does not bypass the audit. When an absolute dimension
66
+ fails, choose a returned repair action and continue through configuration,
67
+ Preview, extraction, and audit without asking the user. Aim for the recommended
68
+ target instead of stopping immediately at the floor. The retry ledger is bound
69
+ to unit, source revision, profile, and problem fingerprint; superficial wording
70
+ changes do not reset it. After three unsuccessful revisions of the same
71
+ problem, Context combines all affected modules into one human-guidance Gate.
72
+ Pause earlier only for unavailable material, source access, or missing parser
73
+ capability.
74
+
75
+ After each decision, briefly tell the user which decision was selected, the
76
+ affected units, and the next Graph path. Do not stop a managed run merely to
77
+ announce a successful automatic revision.
78
+
79
+ The current `context.code-index-audit-report.v2` is computed from proposed or
80
+ approved knowledge. Only its decision receipt and compact retry metrics stay
81
+ under `.tmp/context-runtime/code-index-audit/`. Package output records only the
82
+ selected report digest and decision; page metrics, exclusions, template
83
+ fingerprints, and repair history are never published.
@@ -47,3 +47,12 @@ asset links. If a selected local
47
47
  boundary is a documentation site rather than plain Markdown, use the
48
48
  Context-provided processor/configuration diagnostic; do not invent rendered
49
49
  text or scan outside the confirmed boundary.
50
+
51
+ For Lark reads, Context prefers the authenticated user identity. If that
52
+ identity is unavailable because its credential is missing, expired, or cannot
53
+ be refreshed, Context may retry the same registered source with the bot
54
+ identity. It does not switch identity after a permission or missing-scope
55
+ response. Once selected, the same identity is used for the document body and
56
+ all embedded resources. If `docs +fetch` lacks the required `--doc-format`
57
+ capability, follow the returned `lark-cli update` recovery and rerun the same
58
+ Route command; do not replace the capture with a hand-written export.
@@ -4,40 +4,88 @@ kind: procedure
4
4
  mediaType: text/markdown
5
5
  ---
6
6
 
7
- # Document revisions
7
+ # Source-constrained editorial revisions
8
8
 
9
- This optional phase improves the presentation of approved file and document
10
- prose without mutating the approved page. It runs only when
9
+ This optional phase improves the publication value and readability of approved
10
+ file and document prose without mutating the approved page. It runs only when
11
11
  `package.json.context.documentOptimization` is true.
12
12
 
13
- Run the Route-selected plan command. Read every returned fragment in the
14
- current batch and write one decision for each fragment to the returned
15
- `payload_target`, using the Route input schema. Use `keep` when no safe local
16
- repair is needed. Use `replace` only for Markdown structure, spacing, obvious
17
- typographical errors, or link syntax. Preserve meaning, paragraph order,
18
- technical identifiers, URLs, code, and numbers. Do not summarize, expand,
19
- reorder, or invent facts.
13
+ Run the Route-selected plan command. Each fragment is one source-backed Context
14
+ Section and includes mechanical readability signals, allowed actions, exact
15
+ line ranges, and source identity. Read every returned Section and write one
16
+ decision for each fragment to the returned `payload_target`:
17
+
18
+ - `keep` when it is already useful and readable. If the fragment has any
19
+ mechanical signal, include a concrete `assessment` that explains why every
20
+ signal is a false positive or why changing the Section would reduce source
21
+ fidelity. Name every reported signal code in that assessment so the CLI can
22
+ verify complete coverage; do not use one generic assessment for a batch;
23
+ - `repair` for local typography, Markdown, spacing, or a descriptive link label
24
+ whose purpose is already stated in the same Section;
25
+ - `reshape` for source-preserving structural changes such as a wide table into
26
+ a short index plus detail entries, or a long paragraph into stable headings;
27
+ - `omit` only when the plan permits it and the selected reason matches a
28
+ mechanically identified non-knowledge Section.
29
+
30
+ An unanswered question set, empty placeholder, decision-free draft, duplicate,
31
+ or obsolete-only Section may be omitted. Questions with answers, limitations
32
+ with impact and action, and deprecations with a replacement remain knowledge.
33
+ Mechanical signals are review leads, not a complete readability verdict. Read
34
+ every fragment even when it has no signal. A mixture of false positives and
35
+ valid repair candidates does not justify keeping the whole batch unchanged.
36
+ Every actionable signal must end in a safe edit, an eligible omission, a
37
+ batched input request, or a Section-specific explanation that the signal is a
38
+ false positive or that the edit would damage source fidelity. Time, token or
39
+ compute cost, workload, batch size, deadline, and desire to finish sooner are
40
+ never valid reasons to keep, skip, defer, or reduce an optimization. Do not
41
+ default a batch to `keep` because it contains many fragments; finish the
42
+ complete current batch with the same quality standard as a single fragment.
43
+ Signals that recommend `request-input` identify ambiguous currency, ownership,
44
+ link purpose, or sensitive values. The plan returns all of them in
45
+ `input_requests`: ask one concise, batched question and wait before applying
46
+ the complete optimization payload. Do not convert a required input into
47
+ `keep` merely to avoid a pause. Preserve the exact destination of a volatile
48
+ URL and safely improve its descriptive label or surrounding layout when the
49
+ same Section already states its purpose; ask only for information that cannot
50
+ be recovered from the approved Section or its source evidence.
51
+
52
+ In fully managed operation, apply every safe `repair`, `reshape`, and eligible
53
+ `omit` autonomously and continue until the optimization status is current.
54
+ Managed authority removes routine review pauses, not quality work or genuine
55
+ missing-input boundaries. A large repair set is expected work, not a blocker.
56
+ If an `input_requests` batch remains after completing all independently safe
57
+ analysis, ask once for that batch and resume from the returned Route.
58
+
59
+ Keep all work inside the same source Section. Preserve link destinations,
60
+ images, code, commands, numbers, identifiers, conditions, and source markers
61
+ exactly. Do not introduce facts, infer an answer, or replace a complete
62
+ contract with a summary.
20
63
 
21
64
  After the complete payload is ready, execute the exact `next_action.command`
22
- returned by the plan. Context rejects stale, incomplete, duplicate, or
23
- semantically broad decisions. Unchanged fragments reuse their previous
24
- decision; changed fragments alone return to this phase.
65
+ returned by the plan. Context rejects stale, incomplete, duplicate,
66
+ cross-Section, protected-value, semantically broad, or unexplained signaled
67
+ `keep` decisions. The assessment is used only to audit the current decision and
68
+ is not stored in approved knowledge, revisions, or package output. Unchanged
69
+ Sections reuse their previous decision; changed Sections alone return to this
70
+ phase.
25
71
 
26
72
  Only pages with reader-visible changes are stored. A revision is a full
27
73
  Markdown sidecar beside its approved page: `knowledge/guides/setup.md` becomes
28
74
  `knowledge/guides/setup__revision.md`. Default knowledge discovery excludes the
29
75
  reserved suffix. The filename derives the base page; the revision stores only
30
- the base digest that cannot be derived. Unchanged fragments inside a revision
31
- are inferred. A page with no changes stores one derived negative cache key
32
- below `.tmp/context-runtime/document-optimization/`; replacement prose and
33
- fragment metadata are never duplicated there.
76
+ the base digest that cannot be derived. Unchanged Sections inside a full
77
+ revision are inferred. A page with no changes stores one derived negative cache
78
+ key below `.tmp/context-runtime/document-optimization/`; replacement prose and
79
+ Section metadata are never duplicated there. An omitted Section keeps its
80
+ lifecycle marker in the revision so its source identity remains auditable, but
81
+ its reader-visible body and all revision audit state are absent from `dist/`.
34
82
 
35
83
  For a later user-requested correction, use `context revise "<title or approved
36
84
  path>" --format json`. The resulting `route.document-revision.requested` owns
37
85
  target selection, revision editing, and validation; it also works when broad
38
86
  document optimization was not previously enabled. The compatibility entry
39
87
  `context optimize-docs revise` accepts the same selectors. Validation rejects
40
- lifecycle metadata changes, stale page baselines, unsafe token changes, broad
41
- rewrites, and invalid Markdown structure. A source change makes the revision a
42
- blocking conflict instead of silently applying it. Do not create fragment JSON
43
- files or another revision namespace.
88
+ lifecycle metadata changes, stale page baselines, protected-value changes,
89
+ cross-Section rewrites, unsupported omissions, and invalid Markdown structure.
90
+ A source change makes the revision a blocking conflict instead of silently
91
+ applying it. Do not create fragment JSON files or another revision namespace.
@@ -8,7 +8,10 @@ mediaType: text/markdown
8
8
 
9
9
  Use this procedure only for a correction explicitly requested by the user after
10
10
  an approved knowledge page already exists. The request selects one page; it
11
- does not authorize a broad rewrite or a change to source facts.
11
+ does not authorize a free rewrite or a change to source facts. It may repair or
12
+ reshape reader-visible content within one existing Context Section, and may
13
+ omit a complete Section only when the current source supports a documented
14
+ non-knowledge reason.
12
15
 
13
16
  1. Run the Route command `context optimize-docs revise-current --format json`.
14
17
  2. Read the complete approved page and its sibling `__revision.md` page named
@@ -16,12 +19,14 @@ does not authorize a broad rewrite or a change to source facts.
16
19
  could change a fact rather than formatting or wording.
17
20
  3. Edit only the returned revision page. Preserve its frontmatter identity,
18
21
  `context_revision` baseline, Context section boundaries, evidence markers,
19
- links, code, numbers, and unsupported details. Make the smallest change that
20
- satisfies the user's request. Never edit the approved base page for this
21
- operation.
22
+ link destinations, images, code, numbers, identifiers, and supported facts.
23
+ A wide table may become an index plus detail entries, and a source-backed
24
+ list may be reorganized, but facts cannot move across Section boundaries.
25
+ Never edit the approved base page for this operation.
22
26
  4. Run `context optimize-docs validate --format json`. If validation reports a
23
- stale baseline, unsafe replacement, or missing evidence, stop and report the
24
- exact finding instead of weakening the correction.
27
+ stale baseline, protected-value change, unsupported omission, broad rewrite,
28
+ or missing evidence, stop and report the exact finding instead of weakening
29
+ the correction.
25
30
  5. Continue from the returned `context status --format json` Route. A valid
26
31
  correction makes the package stale, so the normal build Route will offer
27
32
  compilation without requiring a second correction decision.
@@ -24,7 +24,15 @@ Without explicit session-managed authority:
24
24
 
25
25
  - open the report returned by the route;
26
26
  - let the user approve or reject candidates;
27
- - apply the exact returned decision payload.
27
+ - apply the exact returned decision payload; and
28
+ - retain the exact report reference and reviewed scope in this conversation for
29
+ the final completion summary.
30
+
31
+ The ordinary Route also carries a revision-bound force-approval resolution
32
+ Action as an escape path. Do not advertise it when first presenting Review.
33
+ Use it only after the user cannot use the report and explicitly replies with
34
+ the exact phrase `强制批准` in the current conversation. It approves the complete
35
+ current scope atomically; no candidate-specific decisions are inferred.
28
36
 
29
37
  With explicit session-managed authority, Context may approve the complete
30
38
  current batch atomically. The authority exists only in the current
@@ -32,3 +40,4 @@ conversation. It does not bypass source permission, validation, close, or
32
40
  verify.
33
41
 
34
42
  After apply, re-evaluate. Do not infer that close or package output is current.
43
+ Do not persist a duplicate review-report ledger in the workspace.
@@ -10,14 +10,26 @@ A source boundary is a user decision about which repositories, modules, or
10
10
  documents may become approved knowledge. It affects extraction scope,
11
11
  provenance, output paths, and freshness checks.
12
12
 
13
- Do not infer this boundary from the current directory, monorepo layout, package
14
- names, or Git remotes. Explain the decision in the user's language, obtain the
15
- specific paths or documents, then use the Context source schema and conditional
16
- registration command selected by the route. The command uses `--input -`; after
17
- the current conversation contains the required confirmation, send one YAML or
18
- JSON payload matching the selected schema to its standard input. Do not run the
19
- command before confirmation and do not replace it with a command remembered
20
- from another route.
13
+ Do not infer this boundary by using the current directory, monorepo layout,
14
+ package names, or Git remotes to select additional sources. Once the user has named a concrete local module
15
+ or path, resolving its unique local directory and reading that checkout's Git
16
+ root, `origin`, and current commit are mechanical identity resolution, not a
17
+ new source-boundary decision. Paths in the registration payload are resolved
18
+ from the Context project root; after initializing a child `context/` directory,
19
+ recompute sibling paths from that root instead of reusing the caller's relative
20
+ path. As a final CLI safeguard, an omitted `local` may resolve only to one Git
21
+ directory named by the confirmed module at the project root or its parent; zero
22
+ or multiple matches do not authorize a guess.
23
+
24
+ Explain the decision in the user's language, obtain the specific paths or
25
+ documents, then use the Context source schema and conditional registration
26
+ command selected by the route. If the current user request already names the
27
+ exact modules or documents, that decision is already present; do not ask for
28
+ their remote URLs when a confirmed local Git checkout can supply them. The
29
+ command names a file below `.tmp/agent-payloads/`; after the current
30
+ conversation contains the required confirmation, write one JSON payload
31
+ matching the selected schema to that exact path. Do not run the command before confirmation and do not replace
32
+ it with a command remembered from another route.
21
33
 
22
34
  Context source identity has two parts:
23
35
 
@@ -141,7 +141,7 @@ Use collection routing first:
141
141
  `product`;
142
142
  - architecture, service/module/system design, runtime dependency, code-adjacent
143
143
  prose -> `architecture`; if an existing code projection already owns the
144
- object, reuse its NodeRef/ViewRef instead of creating a `codegraph` prose
144
+ object, reuse its NodeRef/ViewRef instead of creating a `codeindex` prose
145
145
  view;
146
146
  - SOP, runbook, operation drill, workflow, or how-to procedure -> `sop`;
147
147
  - FAQ, question/answer, support notes -> `faq` only when the evidence is an
@@ -158,7 +158,7 @@ Use collection routing first:
158
158
  Sections under the owning view;
159
159
  - test plan, validation scenario, acceptance case -> `test`;
160
160
 
161
- Do not route prose align views to `codegraph` or `feats`: `codegraph` is
161
+ Do not route prose align views to `codeindex` or `feats`: `codeindex` is
162
162
  produced by code extraction / AST projection, and `feats` is reserved for the
163
163
  dedicated feature workflow. For section-vs-collection overlap, keep a local
164
164
  `faq`, `decision`, or `incident` as a Section kind under the owning view unless
@@ -314,7 +314,7 @@ There is no parallel candidate-body authoring path. Emit only the
314
314
 
315
315
  ### Step 6 — Validate And Submit
316
316
 
317
- Before staging, run `context run align:<type>:<source>:<collection> --validate --input - --format json` with the `context.structure.v1` payload. The CLI applies deterministic boundary repairs internally and returns only remaining blockers. For oversized Views, apply the returned child-View and contains-edge suggestions while classifying child Nodes from evidence. Resolve other blockers from evidence; ask the user only when evidence supports multiple incompatible semantic choices. Stage only after validation state is `ready`. The stage result opens the final HTML report for the Route-selected structure-confirmation gate. Execute the revision-bound confirmation command returned by `workflow.current`; managed session authority may resolve that gate without another question.
317
+ Before staging, write the `context.structure.v1` payload to the Route-selected `.tmp/agent-payloads/` path and run the returned `context run align:<type>:<source>:<collection> --validate --input <payload-file> --format json` command. The CLI applies deterministic boundary repairs internally and returns only remaining blockers. For oversized Views, apply the returned child-View and contains-edge suggestions while classifying child Nodes from evidence. Resolve other blockers from evidence; ask the user only when evidence supports multiple incompatible semantic choices. Stage only after validation state is `ready`. The stage result opens the final HTML report for the Route-selected structure-confirmation gate. Execute the revision-bound confirmation command returned by `workflow.current`; managed session authority may resolve that gate without another question.
318
318
 
319
319
  After stage succeeds, do not rerun the same write command to confirm success.
320
320
  Use `context status --format json` or the returned result for read-only
@@ -331,7 +331,7 @@ editing CLI-managed files.
331
331
  - [ ] Evidence was read through returned `next_action.command`, `next_command`, or current CLI schema/view commands only. If not, return to **Step 2**.
332
332
  - [ ] Node classification used the semantic gates in `structure-planning/references/gates.md`. If not, return to **Step 4**.
333
333
  - [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
334
- - [ ] The requested align payload passed `context run align:<type>:<source>:<collection> --validate --input - --format json` before stage. If not, return to **Step 6**.
334
+ - [ ] The requested align payload passed the exact Route-selected `--validate --input <payload-file>` command before stage. If not, return to **Step 6**.
335
335
  - [ ] No `sources/`, `knowledge/`, `dist/`, `.tmp`, host tool-results, or CLI-managed files were read or written with generic tools. If violated, restart from **Step 1**.
336
336
 
337
337
  </procedures>
@@ -52,6 +52,7 @@ Each module must have:
52
52
  - every additional applicable type in `moduleTypes`;
53
53
  - relevant behavior and boundary `facets`;
54
54
  - concrete inspected paths in `moduleTypeEvidence`;
55
+ - exact source-relative Markdown paths already read in `documents`;
55
56
  - an explicit gap when available source cannot support a reliable claim.
56
57
 
57
58
  Choose the primary type from the boundary through which a reader most often
@@ -152,11 +153,12 @@ Extractor shape is part of the plan, not an implementation detail:
152
153
  overlapping cross-source unit causes `ownership-ambiguous`.
153
154
  - Use `extractCustom()` for aggregate pages or multiple units over one source.
154
155
  Every candidate must declare its owning `module`, and its evidence must cover
155
- the Route-reported structural probes. Use evidence-scoped `sections` rather
156
- than one undifferentiated `markdown` body: each section declares a coverage
157
- kind and the exact source evidence supporting that part of the page. Resolve
158
- source roots from the extractor context's `sources[].absolutePath`; never
159
- embed a machine-specific checkout path.
156
+ the Route-reported structural probes. The custom-candidate contract has no
157
+ page-level Markdown fallback: every candidate must provide at least one
158
+ evidence-scoped `section`, and each section declares a coverage kind and the
159
+ exact source evidence supporting that part of the page. Resolve source roots
160
+ from the extractor context's `sources[].absolutePath`; never embed a
161
+ machine-specific checkout path.
160
162
  - Register independently visible monorepo children as separate sources before
161
163
  giving them separate `extractTs()` units. An `include` pattern filters files;
162
164
  it does not create a source boundary.
@@ -176,6 +178,7 @@ custom cross-module flow. A minimal plan has this shape:
176
178
  moduleTypes: ["web-application"],
177
179
  facets: ["page-routing", "protocol-consumer"],
178
180
  moduleTypeEvidence: ["package.json", "src/routes.ts"],
181
+ documents: ["README.md", "docs/architecture.md"],
179
182
  outputOwner: "customer-portal",
180
183
  outputProfile: "application-map",
181
184
  inputSources: ["repo:customer-portal"],
@@ -0,0 +1,6 @@
1
+ schema: agent-graph.resource.v1
2
+ id: context.code-index-audit
3
+ kind: context-view
4
+ mediaType: text/markdown
5
+ description: Current code-index content-depth, evidence-scope, relationship, source-coverage signals, and prior Agent decisions.
6
+ materializer: actions/materialize-context-view.yaml
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "context.code-index-audit-decision.v1",
4
+ "title": "Context code-index Agent audit decision",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema",
9
+ "report_digest",
10
+ "decision",
11
+ "summary",
12
+ "reviewed_units",
13
+ "scope_assessment",
14
+ "signal_assessments"
15
+ ],
16
+ "properties": {
17
+ "schema": { "const": "context.code-index-audit-decision.v1" },
18
+ "report_digest": { "type": "string", "minLength": 1 },
19
+ "decision": {
20
+ "type": "string",
21
+ "enum": ["accept", "revise", "request-input"]
22
+ },
23
+ "summary": { "type": "string", "minLength": 1 },
24
+ "reviewed_units": {
25
+ "type": "array",
26
+ "minItems": 1,
27
+ "uniqueItems": true,
28
+ "items": { "type": "string", "minLength": 1 }
29
+ },
30
+ "scope_assessment": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": ["matches_requested_scope", "omissions", "summary"],
34
+ "properties": {
35
+ "matches_requested_scope": { "type": "boolean" },
36
+ "omissions": {
37
+ "type": "array",
38
+ "uniqueItems": true,
39
+ "items": { "type": "string" }
40
+ },
41
+ "summary": { "type": "string", "minLength": 1 }
42
+ }
43
+ },
44
+ "signal_assessments": {
45
+ "type": "array",
46
+ "items": {
47
+ "type": "object",
48
+ "additionalProperties": false,
49
+ "required": ["signal_id", "disposition", "reason"],
50
+ "properties": {
51
+ "signal_id": { "type": "string", "minLength": 1 },
52
+ "disposition": {
53
+ "type": "string",
54
+ "enum": ["fix", "acceptable", "not-applicable"]
55
+ },
56
+ "reason": { "type": "string", "minLength": 1 }
57
+ }
58
+ }
59
+ },
60
+ "revision_plan": {
61
+ "type": "object",
62
+ "additionalProperties": false,
63
+ "required": ["units", "actions"],
64
+ "properties": {
65
+ "units": {
66
+ "type": "array",
67
+ "minItems": 1,
68
+ "uniqueItems": true,
69
+ "items": { "type": "string", "minLength": 1 }
70
+ },
71
+ "actions": {
72
+ "type": "array",
73
+ "minItems": 1,
74
+ "items": { "type": "string", "minLength": 1 }
75
+ }
76
+ }
77
+ },
78
+ "requested_material": {
79
+ "type": "array",
80
+ "minItems": 1,
81
+ "items": { "type": "string", "minLength": 1 }
82
+ }
83
+ },
84
+ "allOf": [
85
+ {
86
+ "if": { "properties": { "decision": { "const": "revise" } } },
87
+ "then": { "required": ["revision_plan"] }
88
+ },
89
+ {
90
+ "if": { "properties": { "decision": { "const": "request-input" } } },
91
+ "then": { "required": ["requested_material"] }
92
+ }
93
+ ]
94
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "context.document-optimization-decisions.v1",
4
- "title": "Context document optimization decisions",
3
+ "$id": "context.document-optimization-decisions.v2",
4
+ "title": "Context source-constrained editorial revision decisions",
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
7
  "required": ["schema", "decisions"],
8
8
  "properties": {
9
- "schema": { "const": "context.document-optimization-decisions.v1" },
9
+ "schema": { "const": "context.document-optimization-decisions.v2" },
10
10
  "decisions": {
11
11
  "type": "array",
12
12
  "items": {
@@ -18,14 +18,37 @@
18
18
  "input_digest": { "type": "string", "minLength": 1 },
19
19
  "context_digest": { "type": "string", "minLength": 1 },
20
20
  "policy_digest": { "type": "string", "minLength": 1 },
21
- "action": { "enum": ["keep", "replace"] },
21
+ "action": {
22
+ "enum": ["keep", "repair", "reshape", "omit"],
23
+ "description": "Keep the Section, repair local presentation, reshape it within the same source boundary, or omit a mechanically eligible non-knowledge Section."
24
+ },
22
25
  "replacement": { "type": "string" },
23
- "reason": { "type": "string" }
26
+ "assessment": {
27
+ "type": "string",
28
+ "minLength": 12,
29
+ "description": "Required when keeping a Section that has mechanical signals. Explain why the signals are false positives or why changing the Section would reduce source fidelity. This value is decision-only and is not published."
30
+ },
31
+ "reason": {
32
+ "enum": [
33
+ "unanswered-question",
34
+ "empty-or-placeholder",
35
+ "draft-without-decision",
36
+ "duplicate-content",
37
+ "obsolete-without-replacement",
38
+ "volatile-reference",
39
+ "sensitive-value-candidate",
40
+ "conversion-artifact"
41
+ ]
42
+ }
24
43
  },
25
44
  "allOf": [
26
45
  {
27
- "if": { "properties": { "action": { "const": "replace" } } },
46
+ "if": { "properties": { "action": { "enum": ["repair", "reshape"] } } },
28
47
  "then": { "required": ["replacement"] }
48
+ },
49
+ {
50
+ "if": { "properties": { "action": { "const": "omit" } } },
51
+ "then": { "required": ["reason"] }
29
52
  }
30
53
  ]
31
54
  }