@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
@@ -1,6 +1,6 @@
1
1
  schema: agent-graph.provider.v1
2
2
  id: c4a/context
3
- version: 0.6.17
3
+ version: 0.6.19
4
4
  name: Context workflow
5
5
  description: Internal work contract for Context knowledge workspaces.
6
6
  graphs:
@@ -55,6 +55,12 @@ Treat those fields as structural scope evidence, not a semantic ranking. Stop
55
55
  when the preview crosses the confirmed module boundary or the module
56
56
  identity/path shape is wrong.
57
57
 
58
+ Also report the unit inventory: eligible/analyzed file and LOC counts,
59
+ discovered/read Markdown, target/exported symbols, stable entry and boundary
60
+ targets, exclusions and parser gaps. After extraction, read every independent
61
+ audit dimension and the exact uncovered identities. Use the CLI-selected
62
+ repair actions and matching templates; do not invent a total score.
63
+
58
64
  Apply the per-index-unit policy exactly: up to 100 pages proceeds; 101–300 pages
59
65
  warns and proceeds; more than 300 pages stops even in fully managed mode. Group
60
66
  all oversized or capability-gap units into one explanation and one plan-revision
@@ -69,6 +75,12 @@ or mirrored areas, enable `exportedOnly`, change to an aggregate
69
75
  `extractTs()` source into overlapping index units. Report a batch-total page
70
76
  advisory as a cost signal, not a new Gate.
71
77
 
78
+ In fully managed mode, revise absolute failures automatically and aim for each
79
+ recommended target. After three attempts with the same unit/problem fingerprint,
80
+ stop at the single aggregated guidance Gate and report all failed modules,
81
+ dimensions, attempted actions, and likely missing material together. Ordinary
82
+ mode also makes one batch decision; it does not create one user Gate per module.
83
+
72
84
  For a multi-module round, finish every pending extraction target before opening
73
85
  one Review. For an unchanged repeat run, explain that no added, changed, or
74
86
  removed symbols need a decision. Mention `extractTs`, `include`, `entries`,
@@ -23,7 +23,7 @@ recommendation, and describe its package root:
23
23
  | `incident` | incident timelines, impact, causes, response, and prevention | `guides/` |
24
24
  | `test` | test plans, validation scenarios, matrices, and acceptance cases | `rules/` |
25
25
 
26
- `codegraph` comes from code extraction and `feats` is not a document mainline
26
+ `codeindex` comes from code extraction and `feats` is not a document mainline
27
27
  collection. Filenames, URLs, titles, and example collection names are
28
28
  insufficient evidence.
29
29
 
@@ -18,8 +18,23 @@ The user does not need to create a payload file; the Agent may write the pasted
18
18
  payload to ignored scratch storage for the CLI command. Never derive a payload
19
19
  from HTML, candidate ids, snapshots, or a default decision.
20
20
 
21
+ When the user completes a decision from the report, retain the exact report URL
22
+ or local report path and reviewed scope in the current conversation for the
23
+ final completion summary. Do not persist a separate workspace ledger or count a
24
+ report as user-reviewed when it was inaccessible, fully managed, or bypassed by
25
+ force approval.
26
+
27
+ Do not mention force approval when first presenting Review. If the user replies
28
+ without a Payload that they approve or want to continue, explain that the
29
+ report Payload remains the normal path. Only at that point, when the report is
30
+ unavailable to them, tell them they may explicitly reply with the exact phrase
31
+ `强制批准` to approve the complete current scope without per-candidate choices.
32
+ Execute the Route's `after-human-confirmation` force-approval command only after
33
+ that exact phrase appears in the current conversation. Phrases such as `我批准`,
34
+ `继续`, or `全部通过` do not invoke this escape path.
35
+
21
36
  Do not open Review for one page or module while another confirmed item in the
22
- same round is still being generated. If a repeat codegraph run has no delta,
37
+ same round is still being generated. If a repeat codeindex run has no delta,
23
38
  state that existing approvals were preserved and no Review gate remains.
24
39
 
25
40
  When the user explicitly requested fully managed operation, use only the
@@ -17,11 +17,19 @@ Explain the observable impact:
17
17
  - every confirmed source is a module inside that batch;
18
18
  - several code and document modules may share the date;
19
19
  - `date/module` appears in source refs and phase ids; and
20
- - stable codegraph knowledge paths use the module name without the date.
20
+ - stable codeindex knowledge paths use the module name without the date.
21
21
 
22
22
  Do not invent `-A`, `-B`, or sequence suffixes. If today's batch exists, append
23
23
  the newly confirmed module to it.
24
24
 
25
+ When the current request already lists exact local modules or documents, do not
26
+ repeat the source-boundary question in either ordinary or fully managed mode.
27
+ Resolve each named module to one unique existing local path inside the
28
+ user-scoped root, then pass that path in the batch payload. Repository paths are
29
+ relative to the Context project root; the CLI may mechanically read their Git
30
+ root, `origin`, and current commit. Ask only when a name is ambiguous, no
31
+ matching path exists, or selecting one match would broaden the requested scope.
32
+
25
33
  When inspection finds several package boundaries, show their paths and ask
26
34
  which concrete boundaries should become sources. Explain that `include`
27
35
  filters files inside a source and cannot select a monorepo package. Only after
@@ -6,17 +6,20 @@ mediaType: text/markdown
6
6
 
7
7
  # Workflow mode after source capture
8
8
 
9
- When source capture has completed and the conversation is still using ordinary
10
- review mode, remind the user in their current conversation language that the
11
- remaining workflow will pause at review decisions and provide HTML reports for
12
- inspection. The current product estimate is that ordinary review makes the
13
- overall workflow about 40% slower, with the exact difference depending on scope
14
- and user response time.
9
+ When source capture has completed, ask about execution mode only if the
10
+ conversation still has no explicit choice and no earlier mode question was
11
+ asked. If ordinary review or fully managed operation was already selected,
12
+ continue without a reminder or another confirmation. When a choice is still
13
+ needed, explain in the user's current conversation language that ordinary
14
+ review pauses at review decisions and provides HTML reports for inspection.
15
+ The current product estimate is that ordinary review makes the overall workflow
16
+ about 40% slower, with the exact difference depending on scope and response
17
+ time.
15
18
 
16
19
  Offer fully managed operation for the rest of the current conversation. Explain
17
20
  that it skips delegatable content-review surfaces and is faster, but reduces the
18
21
  user's ability to control or adjust intermediate content. It does not bypass
19
22
  source boundaries, external permissions, hard validation, evidence checks,
20
23
  verification failures, or other non-delegatable safety boundaries. Do not ask
21
- again when fully managed authority is already active, and never persist the
22
- choice in project files.
24
+ again after this one-time conversation choice, and never persist it in project
25
+ files.
@@ -6,9 +6,10 @@ mediaType: text/markdown
6
6
 
7
7
  # Workflow mode after workspace creation
8
8
 
9
- After the workspace is created, briefly explain the two execution modes in the
10
- user's current conversation language unless they already selected fully managed
11
- operation in this conversation.
9
+ After the workspace is created, explain the two execution modes only when the
10
+ conversation has not already selected a mode and no earlier mode question was
11
+ asked. If the entry plan or initialization confirmation already resolved this
12
+ choice, continue without asking again.
12
13
 
13
14
  - Ordinary review mode is the default. Context pauses at review decisions and
14
15
  provides HTML reports for the user to inspect. The current product estimate is
@@ -22,4 +23,5 @@ Make clear that fully managed mode does not bypass source boundaries, external
22
23
  permissions, hard validation, evidence checks, verification failures, or other
23
24
  non-delegatable safety boundaries. Ask whether the user wants to keep the
24
25
  default ordinary review mode or authorize fully managed operation for the
25
- current conversation. Do not persist the choice in project files.
26
+ current conversation. This is a one-time conversation choice: do not repeat it
27
+ after capture or resume, and do not persist it in project files.
@@ -39,6 +39,13 @@ resources remain explicit in the capture report. Unknown non-empty XML blocks
39
39
  stay auditable in the raw XML and receive a warning; the CLI does not infer
40
40
  their meaning.
41
41
 
42
+ Document and resource reads share one access identity. Context first uses the
43
+ user identity; it falls back to the bot identity only when user credentials
44
+ are unavailable, never when the source denies permission or reports missing
45
+ scopes. This prevents a capture from mixing document text read by one identity
46
+ with attachments read by another. A bot fallback is reported in the capture
47
+ result and remains subject to the bot's own access boundary.
48
+
42
49
  ## Storage lifecycle
43
50
 
44
51
  Resources have three distinct locations:
@@ -111,8 +111,8 @@ capture reports are never distributed as reader assets. See
111
111
  [Lark Resource Materialization](./lark-resources.md).
112
112
 
113
113
  The same inventory exposes `structure.relationship_coverage`. It records
114
- whether selected codegraph pages have current source-backed AST relationship
115
- metadata, how many codegraph views were selected, and how many package-visible
114
+ whether selected codeindex pages have current source-backed AST relationship
115
+ metadata, how many codeindex views were selected, and how many package-visible
116
116
  edges were emitted. An empty edge list is therefore explicit evidence of a
117
117
  coverage state, not permission to invent a dependency.
118
118
 
@@ -136,7 +136,7 @@ Current collection mapping:
136
136
 
137
137
  | Internal collection | Package path | Role |
138
138
  |---|---|---|
139
- | `codegraph` | `wikis/codegraph/` | Structured code entities and relationships. |
139
+ | `codeindex` | `wikis/codeindex/` | Source-backed code indexes with optional structured relationships. |
140
140
  | `business` | `wikis/business/` | Structured business entities and relationships. |
141
141
  | `product` | `wikis/product/` | Structured product entities, behavior, and relationships. |
142
142
  | `architecture` | `guides/architecture/` | Architecture explanations and design narratives. |
@@ -104,7 +104,7 @@ configuration problem, not a Review decision.
104
104
 
105
105
  If no current capability can parse the source reliably, stop at configuration
106
106
  and report the missing generic capability. Do not silently emit an empty
107
- codegraph or reuse an unrelated parser.
107
+ codeindex or reuse an unrelated parser.
108
108
 
109
109
  ## Plan Before Parsing
110
110
 
@@ -114,7 +114,7 @@ application, adapter, CLI/tool, monorepo container, derived source,
114
114
  authoritative contract source, or unknown.
115
115
  A hybrid module may declare several `moduleTypes` and several behavior `facets`;
116
116
  keep one primary `moduleType` for concise reports. Record inspected paths in
117
- `moduleTypeEvidence`, then read all matching Route-recommended files below
117
+ `moduleTypeEvidence`, record every Markdown file actually read in `documents`, then read all matching Route-recommended files below
118
118
  `resources/semantic/code-index/templates/` and combine them into one plan.
119
119
  After that, choose exactly one closed output profile: `module-map`,
120
120
  `application-map`, `protocol-index`, `service-boundary`, `runtime-map`,
@@ -136,8 +136,9 @@ selected symbol and permits one owning index unit per source. Use it for an
136
136
  intentional granular public reference. Use `extractCustom()` for module-level
137
137
  aggregation, registries, protocol indexes, cross-module flows, or multiple
138
138
  candidate owners over one source; each candidate declares its `module` and
139
- evidence-scoped `sections`. Each section's typed coverage and exact evidence is
140
- checked against the output profile during preview. Resolve repositories from
139
+ at least one evidence-scoped `section`; there is no page-level Markdown
140
+ fallback. Each section's typed coverage and exact evidence is checked against
141
+ the output profile during preview. Resolve repositories from
141
142
  the extractor context's `sources[].absolutePath`, never from a
142
143
  machine-specific checkout path. Cross-module flow output must also emit
143
144
  source-backed structured edges. Generated clients/models, mirrored sources, legacy
@@ -47,7 +47,7 @@ kbPackage({
47
47
  llmsPackage({
48
48
  name: "component-lib-llms",
49
49
  template: "src/package-templates/llms",
50
- select: { include: ["codegraph/component-lib/**"] },
50
+ select: { include: ["codeindex/component-lib/**"] },
51
51
  });
52
52
  ```
53
53
 
@@ -265,7 +265,7 @@ its pages instead of producing one index per path segment.
265
265
  The generated
266
266
  `dist/<package-name>/wikis/` tree is the required default
267
267
  KB entry surface. Internal collections are mapped into OKF roots during build:
268
- `codegraph`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
268
+ `codeindex`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
269
269
  `faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
270
270
  `rules/`; and `feats` goes to `feats/`. Treat `wikis/` as the structured
271
271
  entity-and-relationship layer. Guides and rules may explain, operationalize,
@@ -313,17 +313,25 @@ wants project-specific behavior beyond knowledge lookup.
313
313
 
314
314
  ## Context OKF Profiles
315
315
 
316
- Approved Markdown under `knowledge/` is the production source of truth:
316
+ Approved Markdown under `knowledge/` and its deterministic
317
+ `knowledge/structure.yaml` projection form the authoring source of truth:
317
318
 
318
319
  - top-level YAML frontmatter uses OKF fields such as `type`, `title`,
319
320
  `description`, `tags`, `timestamp`, and `resource`;
320
- - Context production metadata such as `sources`, `node_type`, `visibility`,
321
- `code_symbols`, relationship records, and `candidate_fingerprint` also lives
322
- at the top level;
321
+ - each Markdown page keeps reader fields, stable page identity, `sources`, and a
322
+ small recovery capsule (`resource`, `node_type`, containment fields, and
323
+ relationship mode);
324
+ - large or repeated machine state such as complete `code_symbols`, code
325
+ evidence, relationship records, candidate fingerprints, and optimization
326
+ decisions lives once in the corresponding `structure.yaml` view record;
327
+ - Context readers hydrate that machine state in memory before verify, audit,
328
+ revision, or build. Do not copy a compact page as a new page without using a
329
+ Context authoring command;
323
330
  - do not nest Context production metadata under `context`; fields such as
324
331
  `context.sources` and `context.code_symbols` are not part of the 0.6 profile;
325
332
  - section provenance lives in `<!-- context:section ... source_ref="..." -->`
326
- comments;
333
+ comments. When a Section needs more than one citation, the CLI preserves the
334
+ complete set in its adjacent `context:source_refs` block;
327
335
  - do not add frontmatter `source_refs`; page-level provenance is derived from
328
336
  section source refs when needed;
329
337
  - do not add `context` or `schema` fields.
@@ -346,7 +354,7 @@ src-N#span:<heading-hint> L<start>-<end>@<span-hash>
346
354
 
347
355
  The code symbol form includes the source-relative file so same-name symbols in
348
356
  different files resolve to one exact symbol-index row. Consumers should still
349
- treat the complete `source_ref` as opaque. Production codegraph pages keep
357
+ treat the complete `source_ref` as opaque. Production codeindex pages keep
350
358
  `candidate_fingerprint` at the top level and do not duplicate this evidence in
351
359
  `code_origin`.
352
360
 
@@ -398,8 +406,8 @@ current closed state.
398
406
 
399
407
  Before writing output, `context build` validates that rendered template paths
400
408
  are safe, unique, and do not collide with copied knowledge paths. For example,
401
- a template file that renders to `wikis/codegraph/foo.md` is rejected if
402
- selected knowledge such as `knowledge/codegraph/foo.md` maps to that same OKF
409
+ a template file that renders to `wikis/codeindex/foo.md` is rejected if
410
+ selected knowledge such as `knowledge/codeindex/foo.md` maps to that same OKF
403
411
  output path. Rename the template file or use `select.exclude` when the
404
412
  collision is intentional.
405
413
 
@@ -35,7 +35,7 @@ the date:
35
35
  ```text
36
36
  knowledge/<collection>/<slug>.md
37
37
  knowledge/<collection>/<containment>/<slug>.md # only for an intentional hierarchy
38
- knowledge/codegraph/<module>/symbol/<slug>.md
38
+ knowledge/codeindex/<module>/symbol/<slug>.md
39
39
  repo:<date>/<module>#symbol:...
40
40
  file:<date>/<module>/<document>#span:...
41
41
  lark:<date>/<module>/<document>#span:...
@@ -47,12 +47,12 @@ dist/<source-name>-kb/...
47
47
  Choose the module boundary before extraction. In a monorepo, register each
48
48
  confirmed package/subdirectory under the same date batch. A repo root that
49
49
  resolves to multiple modules is for inspection; it is not an extraction unit.
50
- Approved codegraph paths use the stable module name; the date remains only in
50
+ Approved codeindex paths use the stable module name; the date remains only in
51
51
  source selectors, phase ids, and evidence refs:
52
52
 
53
53
  ```text
54
- knowledge/codegraph/module-a/...
55
- knowledge/codegraph/module-b/...
54
+ knowledge/codeindex/module-a/...
55
+ knowledge/codeindex/module-b/...
56
56
  ```
57
57
 
58
58
  For prose Views, provide a stable filename `slug` and omit `path`; the CLI
@@ -63,7 +63,7 @@ it is not a required source/module wrapper.
63
63
 
64
64
  The registry stores this as one date entry containing several `modules` entries,
65
65
  and materializes each module at `sources/repo/<date>/<module>`.
66
- Repo module names are project-wide codegraph identities and therefore cannot be
66
+ Repo module names are project-wide codeindex identities and therefore cannot be
67
67
  reused under another date batch. Refresh an existing module through its original
68
68
  date/module selector.
69
69
  When a repo module and the Context workspace share the same Git root, the CLI
@@ -408,7 +408,7 @@ alignProse({
408
408
  ```
409
409
 
410
410
  `collection` is an internal knowledge classification, not a package directory.
411
- Package build maps `codegraph`/`business`/`product` to `wikis/`,
411
+ Package build maps `codeindex`/`business`/`product` to `wikis/`,
412
412
  `architecture`/`sop`/`faq`/`decision`/`incident` to `guides/`,
413
413
  `standards`/`test` to `rules/`, and `feats` to `feats/`. The complete output
414
414
  contract is documented in [Package Outputs](../guides/package-outputs.md).
@@ -598,7 +598,7 @@ Extract exported TypeScript / TSX symbols into draft candidates:
598
598
  ```ts
599
599
  extractTs({
600
600
  source: componentLib,
601
- collection: "codegraph",
601
+ collection: "codeindex",
602
602
  });
603
603
  ```
604
604
 
@@ -607,7 +607,7 @@ Options:
607
607
  | Field | Meaning |
608
608
  |---|---|
609
609
  | `source` | `source("date", "module")` for one repo module |
610
- | `collection` | Code extraction uses `"codegraph"` |
610
+ | `collection` | Code extraction uses `"codeindex"` |
611
611
  | `include` | Optional glob list inside the selected source; default is `["src/**/*.{ts,tsx}"]` |
612
612
  | `mode` | `"exports"` (default) traces public exports from automatic or configured entries; `"scan"` uses every file matched by `include` as an entry root |
613
613
  | `entries` | Optional source-relative entry files for `"exports"` mode. They override `package.json` entry detection and live only in the Context project configuration |
@@ -620,7 +620,7 @@ An explicit index unit records production intent rather than parser settings:
620
620
  ```ts
621
621
  extractTs({
622
622
  source: componentLib,
623
- collection: "codegraph",
623
+ collection: "codeindex",
624
624
  indexUnits: [{
625
625
  id: "component-public-api",
626
626
  inputSources: ["20260712/component-lib"],
@@ -629,6 +629,7 @@ extractTs({
629
629
  moduleTypes: ["sdk-library"],
630
630
  facets: ["public-api", "plugin-extension"],
631
631
  moduleTypeEvidence: ["package.json exports and src/index.ts public entry"],
632
+ documents: ["README.md", "docs/public-api.md"],
632
633
  outputProfile: "public-api-reference",
633
634
  responsibility: "Document stable exported component contracts.",
634
635
  entries: ["src/index.ts"],
@@ -655,6 +656,9 @@ behaviors such as routing, protocol consumption, events, persistence, plugins,
655
656
  release, or cross-module chains. `moduleTypeEvidence` records the inspected
656
657
  paths that support the classification. Classify first, then read the matching
657
658
  Route-provided code-index templates, and only then finish the extraction plan.
659
+ `documents` contains exact source-relative Markdown paths read for that plan;
660
+ Context compares it with discovered module documents instead of treating a
661
+ source-code comment as documentation coverage.
658
662
  `lifecycle` is `"authoritative"`, `"generated"`, `"mirrored"`, `"legacy"`,
659
663
  or `"vendored"`; derived sources normally use `"provenance-only"` rather
660
664
  than duplicating reader-facing pages. These are generic project facts, not
@@ -680,7 +684,7 @@ editing the source repository:
680
684
  ```ts
681
685
  extractTs({
682
686
  source: componentLib,
683
- collection: "codegraph",
687
+ collection: "codeindex",
684
688
  include: ["src/**/*.ts"],
685
689
  entries: ["src/api.ts"],
686
690
  });
@@ -740,7 +744,7 @@ remain report signals and do not create another Gate.
740
744
  Phase id shape:
741
745
 
742
746
  ```text
743
- extract:<source-name-or-repo>:codegraph
747
+ extract:<source-name-or-repo>:codeindex
744
748
  ```
745
749
 
746
750
  Codegraph extraction has two execution policies:
@@ -751,7 +755,7 @@ Codegraph extraction has two execution policies:
751
755
  the Agent re-evaluates `context status --format json`; only
752
756
  `workflow.current` decides whether Review is now required.
753
757
  - `context run <phase-id> --auto-promote` is the explicit CI/CD path. It is valid
754
- only for `phase.extract.ts` codegraph phases, applies deterministic code deltas
758
+ only for `phase.extract.ts` codeindex phases, applies deterministic code deltas
755
759
  without Review, refreshes deterministic close when approved knowledge changed,
756
760
  then runs project verification. Close or verification errors make the command
757
761
  fail; JSON output reports applied/materialized/removed counts plus a `close`
@@ -763,7 +767,7 @@ other semantic knowledge. Agents must not infer a human gate from a phase-local
763
767
  result. Human gates and their inspection/resolution Actions are exposed only by
764
768
  `workflow.current`.
765
769
 
766
- Approved codegraph sections use the local evidence form
770
+ Approved codeindex sections use the local evidence form
767
771
  `src-N#symbol:<file>:<symbol>:<kind>@<digest>`. The file segment makes reverse
768
772
  lookup exact when multiple files contain the same symbol name, kind, and digest;
769
773
  the complete ref remains opaque to agents. New pages keep only top-level
@@ -779,7 +783,7 @@ aggregated repository protocol:
779
783
  extractCustom({
780
784
  id: "extract:service:protocol",
781
785
  sources: [service],
782
- collection: "codegraph",
786
+ collection: "codeindex",
783
787
  indexUnits: [{
784
788
  id: "service-protocol",
785
789
  inputSources: ["20260811/service"],
@@ -850,6 +854,12 @@ least one source-backed structured edge. `context status` therefore treats this
850
854
  pending code extraction target, and Review can verify snapshot freshness
851
855
  without a placeholder `extractTs` phase.
852
856
 
857
+ Each `sections[].markdown` value is Section body content only; do not copy the
858
+ template heading into it. Context renders `sections[].title` and rejects nested
859
+ reader headings at the SDK boundary so empty template chapters cannot leak into
860
+ knowledge. Evidence `symbol` and `kind` are canonical-ref tokens and cannot
861
+ contain `:` or `@`; exact qualified signatures remain reader-facing prose.
862
+
853
863
  `indexUnits` is also the batch scale and ownership contract. Candidate
854
864
  `module` must match one declared unit id or output owner. Older callbacks that
855
865
  omit `indexUnits` remain compatible: Context groups candidates by `module` and
@@ -879,6 +889,21 @@ output profile. Coverage is based on source-backed evidence paths, not Markdown
879
889
  page count, so one aggregate page can pass while an entry-only static module
880
890
  card cannot.
881
891
 
892
+ For a single-source index unit, Context also scans every represented language
893
+ family and Markdown/MDX file after the unit's declared exclusions. The adapter's
894
+ `eligibleFileTargets` and `eligibleLoc` must cover that independent baseline.
895
+ Configuration files may be evidence, but a hand-picked evidence list cannot be
896
+ reused as the source or LOC denominator. Cross-module-flow units remain scored
897
+ against their declared entry, protocol, operation, and handoff boundaries rather
898
+ than treating several repositories as one source-code page.
899
+
900
+ The same baseline discovers conventional sibling page entries, route-register
901
+ calls in Go router files, and exported receiver operations when a Go handler is
902
+ the declared service source of truth. Every discovered identity must appear in
903
+ the target-symbol and boundary denominators. An aggregate page may summarize
904
+ these identities, but an adapter cannot list one representative sibling and
905
+ silently omit the rest.
906
+
882
907
  The extractor returns knowledge semantics (`nodeRef`, rendered Markdown,
883
908
  Review summary and source-backed evidence). It must not write `knowledge/`,
884
909
  `.tmp/context-runtime/lifecycle/candidates.jsonl`, extraction fingerprints or
@@ -899,9 +924,9 @@ import { indexGoRepository } from "@c4a/extract-go";
899
924
  import { extractCustom } from "@c4a/context";
900
925
 
901
926
  extractCustom({
902
- id: "extract:service:codegraph",
927
+ id: "extract:service:codeindex",
903
928
  sources: [service],
904
- collection: "codegraph",
929
+ collection: "codeindex",
905
930
  extract: async ({ projectRoot }) => {
906
931
  const facts = await indexGoRepository(resolveServiceCheckout(projectRoot));
907
932
  return { candidates: buildServiceCandidates(facts) };
@@ -927,7 +952,7 @@ and its evidence coverage auditable before candidate writes.
927
952
  Declare the review step for a collection:
928
953
 
929
954
  ```ts
930
- reviewValidity({ collection: "codegraph" });
955
+ reviewValidity({ collection: "codeindex" });
931
956
  ```
932
957
 
933
958
  Declare one review gate for all current draft collections:
@@ -939,7 +964,7 @@ reviewValidity({ scope: "all" });
939
964
  Phase id:
940
965
 
941
966
  ```text
942
- review:codegraph:validity
967
+ review:codeindex:validity
943
968
  review:all:validity
944
969
  ```
945
970
 
@@ -951,14 +976,21 @@ review html --all --open --format json`, confirm the returned `opened` field,
951
976
  and wait for the user-copied payload. They should not run the phase as an
952
977
  automatic approval step or synthesize a payload themselves.
953
978
 
954
- The only batch-wide exception is explicit current-conversation fully managed
955
- authority. In that mode, follow the `context status --managed` route to
979
+ One batch-wide path is explicit current-conversation fully managed authority.
980
+ In that mode, follow the `context status --managed` route to
956
981
  `context review approve-all ... --managed`; the CLI validates the exact current
957
982
  scope before applying one default-approved decision.
958
983
 
984
+ Ordinary mode has a separate user-confirmed escape path for environments where
985
+ the Review report cannot be opened. Do not advertise it in the initial Review
986
+ prompt. After the user reports that limitation, the exact conversation phrase
987
+ `强制批准` authorizes only the current Route's revision-bound
988
+ `context review approve-all ... --force` command. Other generic approval or
989
+ continue wording does not invoke it.
990
+
959
991
  The gate is batch-scoped: prose waits for every planned View across all active
960
992
  structure slots and every declared `pendingStructureTargets` item in the round;
961
- codegraph waits for every pending extract phase in the confirmed module round.
993
+ codeindex waits for every pending extract phase in the confirmed module round.
962
994
  Candidate count/hash therefore describes the complete current batch rather than
963
995
  one page, source slot, or module. Deterministic close later merges all active
964
996
  slots into `knowledge/structure.yaml`, retains only their source, collection,
@@ -988,13 +1020,13 @@ const sample = source("20260712", "sample");
988
1020
 
989
1021
  customPhase("custom:20260712/sample:review", async (ctx) => {
990
1022
  await ctx.ensureSources({ source: sample });
991
- await ctx.extract.ts(extractTs({ source: sample, collection: "codegraph" }));
992
- await ctx.review.html(reviewValidity({ collection: "codegraph" }));
1023
+ await ctx.extract.ts(extractTs({ source: sample, collection: "codeindex" }));
1024
+ await ctx.review.html(reviewValidity({ collection: "codeindex" }));
993
1025
  });
994
1026
  ```
995
1027
 
996
1028
  Custom phases are an orchestration escape hatch. Use `extractCustom()` instead
997
- when project code needs to publish codegraph candidates. The supported runtime
1029
+ when project code needs to publish codeindex candidates. The supported runtime
998
1030
  helpers are:
999
1031
 
1000
1032
  - `ctx.ensureSources(...)` for repo source readiness.
@@ -6,14 +6,20 @@ mediaType: text/markdown
6
6
 
7
7
  # Close and build
8
8
 
9
- Close deterministically derives `knowledge/structure.yaml` from approved
10
- Markdown and the confirmed structure snapshots. It validates the rebuilt
11
- projection. When an approved page still points at a captured source asset,
9
+ Close deterministically reconciles approved Markdown, existing durable machine
10
+ metadata, and confirmed structure snapshots into `knowledge/structure.yaml`.
11
+ It then compacts repeated machine fields out of each Markdown page and validates
12
+ the hydrated result. When an approved page still points at a captured source asset,
12
13
  close may mechanically replace that target with its content-addressed
13
14
  `knowledge/assets` path; it does not rewrite reader-visible prose. Before
14
15
  removing the transient snapshots, it retains only each closed prose target's
15
16
  source, collection, and consumed snapshot hash under `source_inputs`.
16
17
 
18
+ Do not hand-edit, duplicate, or move fields between Markdown and
19
+ `structure.yaml`. The CLI owns compaction and hydration. A compact Markdown page
20
+ remains readable and keeps enough identity for projection diagnostics; complete
21
+ code and optimization metadata is intentionally not duplicated.
22
+
17
23
  Build runs only after close and verification are current. It writes declared
18
24
  packages under `dist/` and records an inventory receipt with added, updated,
19
25
  removed, and index changes.
@@ -26,3 +32,20 @@ package inventory. Revision sidecars are never emitted as separate knowledge.
26
32
  Run only the current route command, then evaluate again. A successful build
27
33
  means the currently declared scope is current; newly captured or newly declared
28
34
  targets can reopen earlier graph nodes.
35
+
36
+ The final completion summary must cover the built outputs, validation status,
37
+ knowledge scale, and unresolved issues. Add a compact `Review reports` section with every
38
+ exact HTML report URL or local report path that the user actually used for a
39
+ review decision in this conversation, together with its reviewed scope. Omit
40
+ the section when no report was user-reviewed. Do not reconstruct it by scanning
41
+ `.tmp`, invent a shareable URL, or classify fully managed or force approval as
42
+ user review.
43
+ # Code-index audit record
44
+
45
+ When a package selects approved `codeindex` pages, build requires the current
46
+ batch-level Agent audit to be accepted. The complete report and decision state
47
+ are runtime data below `.tmp/context-runtime/code-index-audit/`; deleting
48
+ `.tmp/` causes Context to recompute and re-audit them. They are not copied into
49
+ `dist/`, uploaded with the package, or committed as knowledge. The package
50
+ inventory stores only the report digest, decision, and compact summary needed
51
+ to identify the audited build.