@c4a/context-cli 0.7.0 → 0.7.1

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 (88) hide show
  1. package/cli.js +32779 -32620
  2. package/indexers/capability-manifest.json +4 -9
  3. package/indexers/release-manifest.json +1 -1
  4. package/package.json +3 -3
  5. package/plugins/VERSION +1 -1
  6. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  7. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  8. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  9. package/providers/context/actions/run-indexer-lifecycle.yaml +7 -0
  10. package/providers/context/codes.yaml +3 -27
  11. package/providers/context/graphs/indexer.yaml +2 -28
  12. package/providers/context/graphs/workspace.yaml +37 -473
  13. package/providers/context/manifest.json +58 -558
  14. package/providers/context/provider.yaml +2 -2
  15. package/providers/context/resources/diagnostics/projection-stale.md +0 -1
  16. package/providers/context/resources/manuals/reference/project-api.md +39 -38
  17. package/providers/context/resources/views/document-optimization-current.yaml +1 -1
  18. package/providers/context/resources/views/package-current.yaml +1 -1
  19. package/providers/context/resources/views/resolved-indexer-instructions.yaml +1 -1
  20. package/providers/context/resources/views/review-current.yaml +1 -1
  21. package/providers/context/resources/views/source-boundary.yaml +1 -1
  22. package/providers/context/resources/views/source-current.yaml +1 -1
  23. package/providers/context/resources/views/verification-current.yaml +1 -1
  24. package/providers/context/resources/views/workspace-current.yaml +1 -1
  25. package/providers/context/schemas/indexer-contract-overlay-validation-input.schema.json +0 -42
  26. package/providers/context/schemas/indexer-contract-overlay-validation-result.schema.json +27 -122
  27. package/providers/context/schemas/indexer-lifecycle-continuation.schema.json +15 -0
  28. package/providers/context/schemas/indexer-overlay-question-proposal-input.schema.json +4 -4
  29. package/providers/context/schemas/indexer-overlay-question-rebind-input.schema.json +4 -4
  30. package/providers/context/skills/run-indexer-lifecycle/SKILL.md +36 -0
  31. package/providers/context/actions/align-next.yaml +0 -6
  32. package/providers/context/actions/apply-code-index-guidance.yaml +0 -5
  33. package/providers/context/actions/apply-document-optimization-guidance.yaml +0 -5
  34. package/providers/context/actions/apply-structure-confirmation.yaml +0 -5
  35. package/providers/context/actions/authorize-indexer-contract-overlay.yaml +0 -7
  36. package/providers/context/actions/compile-next.yaml +0 -5
  37. package/providers/context/actions/configure-code-extraction.yaml +0 -5
  38. package/providers/context/actions/configure-prose-lifecycle.yaml +0 -5
  39. package/providers/context/actions/extract-next.yaml +0 -5
  40. package/providers/context/actions/inspect-code-extraction.yaml +0 -5
  41. package/providers/context/actions/inspect-document-classification.yaml +0 -5
  42. package/providers/context/actions/inspect-structure.yaml +0 -5
  43. package/providers/context/actions/migrate-codeindex.yaml +0 -5
  44. package/providers/context/actions/optimize-documents.yaml +0 -6
  45. package/providers/context/actions/preview-extraction-batch.yaml +0 -5
  46. package/providers/context/actions/revise-code-index-audit.yaml +0 -5
  47. package/providers/context/actions/submit-code-index-audit.yaml +0 -6
  48. package/providers/context/resources/dialogue/code-extraction.md +0 -87
  49. package/providers/context/resources/dialogue/document-classification.md +0 -33
  50. package/providers/context/resources/dialogue/structure-confirmation.md +0 -44
  51. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +0 -25
  52. package/providers/context/resources/manuals/reference/code-extractors.md +0 -152
  53. package/providers/context/resources/procedures/code-extraction.md +0 -188
  54. package/providers/context/resources/procedures/code-index-audit.md +0 -113
  55. package/providers/context/resources/procedures/document-classification.md +0 -22
  56. package/providers/context/resources/procedures/document-optimization.md +0 -110
  57. package/providers/context/resources/procedures/prose-align.md +0 -68
  58. package/providers/context/resources/procedures/prose-compile.md +0 -23
  59. package/providers/context/resources/semantic/align/candidate-resolution.md +0 -106
  60. package/providers/context/resources/semantic/align/density-profile.md +0 -41
  61. package/providers/context/resources/semantic/align/gates.md +0 -276
  62. package/providers/context/resources/semantic/align/structure-planning.md +0 -337
  63. package/providers/context/resources/semantic/code-index/classification.md +0 -270
  64. package/providers/context/resources/semantic/code-index/templates/adapter.md +0 -118
  65. package/providers/context/resources/semantic/code-index/templates/api-service.md +0 -116
  66. package/providers/context/resources/semantic/code-index/templates/background-runtime.md +0 -109
  67. package/providers/context/resources/semantic/code-index/templates/cli-tool.md +0 -129
  68. package/providers/context/resources/semantic/code-index/templates/contract-source.md +0 -73
  69. package/providers/context/resources/semantic/code-index/templates/contracts-and-chains.md +0 -81
  70. package/providers/context/resources/semantic/code-index/templates/cross-module-chain.md +0 -78
  71. package/providers/context/resources/semantic/code-index/templates/derived-source.md +0 -116
  72. package/providers/context/resources/semantic/code-index/templates/domain-service.md +0 -109
  73. package/providers/context/resources/semantic/code-index/templates/event-flow.md +0 -62
  74. package/providers/context/resources/semantic/code-index/templates/monorepo-container.md +0 -124
  75. package/providers/context/resources/semantic/code-index/templates/persistence-boundary.md +0 -56
  76. package/providers/context/resources/semantic/code-index/templates/plugin-extension.md +0 -52
  77. package/providers/context/resources/semantic/code-index/templates/protocol-boundary.md +0 -88
  78. package/providers/context/resources/semantic/code-index/templates/sdk-library.md +0 -132
  79. package/providers/context/resources/semantic/code-index/templates/web-application.md +0 -145
  80. package/providers/context/resources/semantic/compile/index.md +0 -31
  81. package/providers/context/resources/views/code-index-audit.yaml +0 -6
  82. package/providers/context/resources/views/extraction-preview.yaml +0 -6
  83. package/providers/context/resources/views/structure-current.yaml +0 -6
  84. package/providers/context/schemas/code-index-audit-decision.schema.json +0 -94
  85. package/providers/context/schemas/document-optimization-decisions.schema.json +0 -57
  86. package/providers/context/schemas/indexer-contract-overlay-authorization-input.schema.json +0 -32
  87. package/providers/context/schemas/indexer-contract-overlay-authorization-result.schema.json +0 -121
  88. package/providers/context/schemas/prose-structure-batch.schema.json +0 -35
@@ -1,22 +0,0 @@
1
- ---
2
- id: procedure.document-classification
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Document classification
8
-
9
- Classification chooses the main knowledge collection for a captured document.
10
- The choice must follow evidence investigation, not the URL, file name, a user
11
- example, or a fixed content-specific prompt.
12
-
13
- Read the current collection-neutral evidence view, explain a short
14
- evidence-backed recommendation and its output implications, then obtain the
15
- user decision unless the current session explicitly delegates this gate.
16
- Read every Route-selected `context.source-body/*` resource in full. Index and
17
- heading metadata support navigation but are not evidence that the document
18
- body was read.
19
-
20
- After the decision, declare the complete align, compile, and review lifecycle
21
- for the same canonical source and collection. Re-evaluate instead of assuming
22
- the declaration closed every document target.
@@ -1,110 +0,0 @@
1
- ---
2
- id: procedure.document-optimization
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Source-constrained editorial revisions
8
-
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
- `package.json.context.documentOptimization` is true.
12
-
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. `high` signals cannot be kept unchanged. Name every remaining
22
- `review` signal code in that assessment so the CLI can verify complete
23
- coverage; do not use one generic assessment for a batch;
24
- - `repair` for local typography, Markdown, spacing, or a descriptive link label
25
- whose purpose is already stated in the same Section;
26
- - `reshape` for source-preserving structural changes such as a wide table into
27
- a short index plus detail entries, or a long paragraph into stable headings;
28
- - `omit` only when the plan permits it and the selected reason matches a
29
- mechanically identified non-knowledge Section.
30
-
31
- An unanswered question set, empty placeholder, decision-free draft, duplicate,
32
- or obsolete-only Section may be omitted. Questions with answers, limitations
33
- with impact and action, and deprecations with a replacement remain knowledge.
34
- Mechanical signals are review leads, not a complete readability verdict. Read
35
- every fragment even when it has no signal. A mixture of false positives and
36
- valid repair candidates does not justify keeping the whole batch unchanged.
37
- Signals marked `high` are deterministic presentation obligations. A repair or
38
- reshape is rescanned against the effective replacement and cannot complete
39
- while one of those signals remains. Signals marked `review` require semantic
40
- inspection and may be kept only with the signal-specific assessment below.
41
- Every actionable signal must end in a safe edit, an eligible omission, a
42
- batched input request, or a Section-specific explanation that the signal is a
43
- false positive or that the edit would damage source fidelity. Time, token or
44
- compute cost, workload, batch size, deadline, and desire to finish sooner are
45
- never valid reasons to keep, skip, defer, or reduce an optimization. Do not
46
- default a batch to `keep` because it contains many fragments; finish the
47
- complete current batch with the same quality standard as a single fragment.
48
- Signals that recommend `request-input` identify ambiguous currency, ownership,
49
- link purpose, or sensitive values. The plan returns all of them in
50
- `input_requests`: ask one concise, batched question and wait before applying
51
- the complete optimization payload. Do not convert a required input into
52
- `keep` merely to avoid a pause. Preserve the exact destination of a volatile
53
- URL and safely improve its descriptive label or surrounding layout when the
54
- same Section already states its purpose; ask only for information that cannot
55
- be recovered from the approved Section or its source evidence.
56
-
57
- In fully managed operation, apply every safe `repair`, `reshape`, and eligible
58
- `omit` autonomously and continue until the optimization status is current.
59
- Managed authority removes routine review pauses, not quality work or genuine
60
- missing-input boundaries. A large repair set is expected work, not a blocker.
61
- If an `input_requests` batch remains after completing all independently safe
62
- analysis, ask once for that batch and resume from the returned Route.
63
-
64
- If the same current-batch quality problem fails three consecutive apply
65
- attempts, stop the automatic revision loop and follow
66
- `route.document-optimization.guidance-required`. Present one aggregated report
67
- for all affected Sections and ask for content-organization, source-fidelity, or
68
- missing-material direction. Do not restart Sections that already pass. A
69
- successful complete-batch apply clears the temporary retry record; retry
70
- history is never knowledge or package content.
71
-
72
- Keep all work inside the same source Section. Preserve link destinations,
73
- images, code, commands, numbers, identifiers, conditions, and source markers
74
- exactly. Do not introduce facts, infer an answer, or replace a complete
75
- contract with a summary.
76
-
77
- After the complete payload is ready, execute the exact `next_action.command`
78
- returned by the plan. Context rejects stale, incomplete, duplicate,
79
- cross-Section, protected-value, semantically broad, or unexplained signaled
80
- `keep` decisions. It also rescans every repair and reshape against the same
81
- mechanical analyzer before writing the revision; submitting a decision is not
82
- proof that the effective Markdown is clean. A repair or reshape that retains a
83
- review-confidence signal must include a Section-specific assessment naming
84
- that signal. The apply result reports each signal as `resolved` or `justified`
85
- with its source and post-revision range. The assessment and rescan detail are
86
- used only to audit the current decision and are not stored in approved
87
- knowledge, revisions, or package output. Unchanged
88
- Sections reuse their previous decision; changed Sections alone return to this
89
- phase.
90
-
91
- Only pages with reader-visible changes are stored. A revision is a full
92
- Markdown sidecar beside its approved page: `knowledge/guides/setup.md` becomes
93
- `knowledge/guides/setup__revision.md`. Default knowledge discovery excludes the
94
- reserved suffix. The filename derives the base page; the revision stores only
95
- the base digest that cannot be derived. Unchanged Sections inside a full
96
- revision are inferred. A page with no changes stores one derived negative cache
97
- key below `.tmp/context-runtime/document-optimization/`; replacement prose and
98
- Section metadata are never duplicated there. An omitted Section keeps its
99
- lifecycle marker in the revision so its source identity remains auditable, but
100
- its reader-visible body and all revision audit state are absent from `dist/`.
101
-
102
- For a later user-requested correction, use `context revise "<title or approved
103
- path>" --format json`. The resulting `route.document-revision.requested` owns
104
- target selection, revision editing, and validation; it also works when broad
105
- document optimization was not previously enabled. The compatibility entry
106
- `context optimize-docs revise` accepts the same selectors. Validation rejects
107
- lifecycle metadata changes, stale page baselines, protected-value changes,
108
- cross-Section rewrites, unsupported omissions, and invalid Markdown structure.
109
- A source change makes the revision a blocking conflict instead of silently
110
- applying it. Do not create fragment JSON files or another revision namespace.
@@ -1,68 +0,0 @@
1
- ---
2
- id: procedure.prose-align
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Prose structure alignment
8
-
9
- Alignment proposes source-bound knowledge structure. It does not write approved
10
- knowledge.
11
-
12
- Follow the current route's evidence view and input schema. Prefer source heading
13
- and block boundaries when they preserve coherent reading units; fixed line
14
- windows are only a fallback for unstructured text. A page may contain multiple
15
- sections, each with its own continuous evidence span.
16
-
17
- The default `read-plan` is the authoring packet for ordinary documents. It
18
- includes the payload contract, a compact canonical source-ref map, exact source
19
- body resources, the recommended scratch path, and the direct stage command.
20
- Do not separately request `schema`, `source-index`, or `existing-knowledge`
21
- unless the packet reports truncation or the task specifically needs an existing
22
- approved identity. Those views are diagnostics and large-source fallbacks, not
23
- mandatory workflow steps.
24
-
25
- Every `context.source-body/*` item selected in `workflow.current.resources`
26
- is source evidence, not supporting metadata. Read the complete Markdown file
27
- when its `read_state` is `read-required`. A source index, heading tree, token
28
- count, or successful capture never substitutes for body reading. A matching
29
- content digest receipt may be reused only while that text remains available in
30
- the current conversation. After reading every selected direct path, execute the
31
- single `resources.after_read.command`. For a generated Context View, execute
32
- its materialization command, read its complete file, then execute its exact
33
- `next_action.command`. Context carries the merged receipt file forward. A Route
34
- revision change does not invalidate unchanged bytes, but every lifecycle
35
- command remains revision-bound.
36
-
37
- When the route returns `payload_target`, write the Agent-authored structure input
38
- to its recommended `.tmp/agent-payloads/` path. This scratch area is separate
39
- from CLI-owned `.tmp/context-runtime/` and can be discarded after a successful
40
- stage. The recommendation does not restrict an explicit user-selected path.
41
-
42
- Stage all required source/collection slots before batch Review. Structure
43
- confirmation is an explicit gate. A confirmation applies only to the staged
44
- slot digest shown by the route; if the digest changes, confirm again.
45
-
46
- When the current Route exposes `batch`, author every listed target payload in
47
- one Agent planning pass, then write the small batch manifest to `batch.input`.
48
- Use `batch.validate.command` for a read-only all-target check or
49
- `batch.stage.command` to validate every target before any stage begins and then
50
- write the ready slots serially. The manifest contains only each `phase_id` and
51
- its structure payload `input` path; it does not merge document semantics or let
52
- the CLI choose page structure. A failed preflight writes no slot. If a later
53
- filesystem write fails, the result identifies completed slots and the Route
54
- remains recoverable.
55
-
56
- `--stage` performs the same validation and deterministic self-repair as
57
- `--validate`; use the separate validation command only for a diagnostics-only
58
- pass. In a managed conversation, a valid stage also records structure
59
- confirmation in the same write. Validation states are literal: `ready` may
60
- stage, `repair-required` may not, and `invalid` contains errors. `valid` is true
61
- only for `ready`; `error_free` distinguishes a blocker-only result from one
62
- containing errors. `self_healed` reports the input and output Section counts,
63
- how many original Sections were split, and the structural reason codes used by
64
- the repair.
65
-
66
- Independent read-only evidence views may run in parallel. Structure stage,
67
- confirmation, compile writes, and Review application are serial lifecycle
68
- mutations; execute them in the order selected by `workflow.current`.
@@ -1,23 +0,0 @@
1
- ---
2
- id: procedure.prose-compile
3
- kind: procedure
4
- mediaType: text/markdown
5
- ---
6
-
7
- # Source-bound prose compilation
8
-
9
- Compile materializes review candidates from confirmed structure and source
10
- evidence. It never writes directly to approved knowledge.
11
-
12
- The CLI derives this projection mechanically from the confirmed section ids,
13
- kinds, and source spans. Run only the revision-bound compile command returned
14
- by the current Route. Do not create compile-action payloads or rewrite source
15
- content.
16
-
17
- One compile command validates every owned view first, then atomically
18
- materializes the source/collection candidate batch. In an explicitly managed
19
- conversation, the host loop may continue across the remaining deterministic
20
- compile slots after this procedure has been read; it re-evaluates revision and
21
- validation state after every write. The current structure view is optional
22
- inspection context because the CLI consumes the confirmed structure directly.
23
- Do not open a partial Review while planned views remain.
@@ -1,106 +0,0 @@
1
- ---
2
- id: context.semantic.align.candidate-resolution
3
- kind: procedure
4
- media-type: text/markdown
5
- applies-to:
6
- - duplicate
7
- - conflict
8
- - stable_id
9
- - path
10
- - unresolved
11
- ---
12
-
13
- # Candidate Resolution Rules
14
- <!-- Context workflow semantic resource. -->
15
-
16
- Use these rules after reading the current align evidence views and before
17
- authoring `context.structure.v1`. They define how current anomaly diagnostics
18
- map to supported structure outcomes.
19
-
20
- ## Anomaly Signals
21
-
22
- Anomaly diagnostics are mechanical warnings. Do not ignore them and do not treat
23
- them as recommendations.
24
-
25
- For each anomaly, choose one current outcome and record the reasoning in the
26
- structure payload or user-facing explanation:
27
-
28
- | Outcome | Use When |
29
- |---|---|
30
- | Accept the correction | The anomaly points to a real structure fix. Apply a concrete node, section, edge, or ownership correction supported by source refs. |
31
- | Dismiss with rationale | The warning is mechanically true but semantically harmless. Keep the structure and state why in the confirmation summary. |
32
- | Keep unresolved | The warning changes structure but source evidence is insufficient. Add an `unresolved[]` item instead of guessing. |
33
-
34
- Known anomaly kinds:
35
-
36
- | Kind | Meaning | Required handling |
37
- |---|---|---|
38
- | Missing evidence | A proposed node, section, or edge has no source-backed evidence. | Add source refs, remove it, or keep the issue unresolved. |
39
- | Structure churn | A node was renamed, split, merged, replaced, or rejected during investigation. | Confirm the final id/title/target with the user or keep the ambiguity unresolved. |
40
- | Duplicate evidence | The same source ref appears more than once for the same semantic role. | Deduplicate it or explain why the repeated ref supports different roles. |
41
- | Broad review needed | The CLI collapsed many anomalies or reports aggregate risk. | Review the affected structure broadly; do not finalize solely from ordering. |
42
-
43
- ## Stable References
44
-
45
- Use stable `node_ref`, `view_ref`, and `section_ref` values from the current
46
- `context.structure.v1` payload for in-payload references. A NodeRef should be
47
- safe, lower-case, and path-shaped, such as `entity/rspack` or
48
- `domain/build-tooling`. `slug` is the required stable filename choice for a
49
- View. `path` is derived from collection, optional containment, and slug; omit
50
- it or use the exact CLI-derived value. Do not invent alternate reference
51
- aliases.
52
-
53
- When an edge or section points at knowledge:
54
-
55
- - use the schema ref that matches the target layer:
56
- `node_ref` for a conceptual Node, `view_ref` for a collection view, and
57
- `section_ref` for a planned section;
58
- - ensure the target NodeRef, ViewRef, or SectionRef exists in the current
59
- structure or approved knowledge;
60
- - keep relation hints unresolved when the target does not exist;
61
- - follow CLI diagnostics if a ref is unknown or stale.
62
-
63
- Do not create alternate alias fields or non-schema candidate ledger fields.
64
- They are not part of the current structure contract.
65
-
66
- ## Visible Labels And Audit Rationale
67
-
68
- Humans need to understand merge, reject, rename, and replacement choices
69
- without decoding temporary ids. Keep that discipline in the current structure
70
- flow through current fields:
71
-
72
- - use `title` and `summary` to name the final node in user-facing language;
73
- - explain renamed/split/merged candidates in the confirmation summary, not by
74
- adding non-schema label fields;
75
- - when a relation or rename cannot be settled from evidence, put the visible
76
- title/target clue in `unresolved[]`;
77
- - when asking the user, phrase the choice with business labels ("Rspack build
78
- tool page" vs "Webpack page"), not with source refs or internal section ids.
79
-
80
- NodeRef is the stable conceptual identity. ViewRef is the collection-specific
81
- view identity and is the durable approved-page identity. SectionRef is the
82
- stable planned-section identity under a ViewRef. Package paths are derived from
83
- the approved ViewRef plus containment/slug; do not treat paths as an alternate
84
- identity contract. Visible labels help humans review the choice, but they do
85
- not authorize a different NodeRef, ViewRef, edge, or section ownership without
86
- source-backed evidence and user confirmation.
87
-
88
- ## Duplicate And Conflict Handling
89
-
90
- - Exact duplicate structure -> keep one node/section/edge and explain the
91
- duplicate in the confirmation summary.
92
- - Same topic but different evidence boundary -> keep separate sections only
93
- when each section has a distinct source-backed role.
94
- - Conflicting facts -> ask the user or keep an `unresolved[]` item. Do not
95
- pick a winner from title order or source order.
96
- - Replacement or rename -> ask the user when it changes NodeRef, ViewRef,
97
- containment, slug, or the derived approved path. These are durable user-facing
98
- identities, not disposable labels.
99
-
100
- ## Self-verify
101
-
102
- - [ ] Every accepted node, section, and edge has source-backed support.
103
- - [ ] Every unresolved relation or conflict is explicit in `unresolved[]`.
104
- - [ ] No non-schema candidate ledger fields or alias fields appear in the payload.
105
- - [ ] NodeRef, ViewRef, and SectionRef values, not temporary labels or paths,
106
- are used for current references.
@@ -1,41 +0,0 @@
1
- ---
2
- id: context.semantic.align.density-profile
3
- kind: procedure
4
- media-type: text/markdown
5
- applies-to:
6
- - coverage
7
- - reading_density
8
- - structure
9
- ---
10
-
11
- # Evidence Density Selection
12
- <!-- Context workflow semantic resource. -->
13
-
14
- Use density as a private reading and section-planning strategy. It is not a
15
- separate payload, not a quality score, and not a workflow stage. Persist only
16
- current `context.structure.v1` fields such as `nodes[]`, `sections[]`,
17
- `source_refs[]`, `edges[]`, and `unresolved[]`.
18
-
19
- Apply this reference when a captured source is long, dense, fragmented, or hard
20
- to split into stable planned sections. Use the current CLI evidence views
21
- (`read-plan`, `source-index`, `span-detail`, `span-text`) to inspect material;
22
- do not invent a separate coarse-read artifact.
23
-
24
- | Profile | Use When | Agent Behavior |
25
- |---|---|---|
26
- | `macro` | A long source has many headings, sections, or broad topic shifts. | Create section proposals around major headings and preserve document-level anchors so later passes do not flatten scope. |
27
- | `meso` | Default for normal product, design, or operational documents with several related sections. | Produce section proposals for meaningful local units and preserve evidence anchors. |
28
- | `micro` | The source is fragmented, note-like, or dense with short independent claims. | Keep section proposals narrow and avoid bundling unrelated blocks into one candidate. |
29
- | `single_pass` | The source is short enough that one read can safely discover all relevant structure. | Keep anchors minimal and avoid over-segmentation, but still validate the resulting structure. |
30
-
31
- Treat Markdown heading changes as section-planning hints, not hard boundaries.
32
- Sibling sub-headings under a shared parent can remain in one planned section
33
- when they form one coherent semantic topic for that parent. Headings with no
34
- shared parent should usually split unless you intentionally want one section to
35
- span them. When a dense source has many headings, split by heading first, then
36
- merge adjacent or sibling groups only when the merged section is still one
37
- coherent fact group.
38
-
39
- Do not let density alone choose `node_type`, `tags`, `section.kind`, or body
40
- content. Action/domain gates are decided from source evidence and the current
41
- schema, not from density metadata.
@@ -1,276 +0,0 @@
1
- ---
2
- id: context.semantic.align.align-gates
3
- kind: procedure
4
- media-type: text/markdown
5
- applies-to:
6
- - node_type
7
- - domain
8
- - action
9
- - edges
10
- - tags
11
- ---
12
-
13
- # Node Classification Gates
14
- <!-- Context workflow semantic resource. -->
15
-
16
- Use these gates before every structure draft and before authoring the align
17
- payload described by the current schema view.
18
- Align owns Node type, tag, graph, planned Section, and ownership classification. It does **not** write Section prose.
19
-
20
- Current schema mapping:
21
-
22
- - Treat the action checklist, domain checklist, and inference tables as private
23
- working notes unless the current schema view explicitly exposes matching
24
- fields.
25
- - In `context.structure.v1`, persist the outcome through `node_type`, `tags`,
26
- `summary`, `ownership`, `sections[].source_refs`, `edges[]`, and
27
- `unresolved[]`.
28
- - Do not add unknown gate fields to the payload just because this procedure uses
29
- them for reasoning.
30
-
31
- ## Node Type Order
32
-
33
- Answer in this order and stop at the first match:
34
-
35
- 1. **Action?** A large executable event / process with both:
36
- - scale: can support `planned_sections` with at least two distinct Section kinds, or contains at least one child Action;
37
- - process evidence: explicit steps, phases, trigger -> handling -> result, role collaboration, or repeatable plan. Parallel lists such as "three API modes" are not process evidence.
38
- Single-section user-story / scenario / incident records may be meaningful to
39
- a human reader, but the CLI does not infer that exception from source prose.
40
- If the structure cannot express at least two distinct Section kinds or a
41
- child Action, keep the material as a Section under the owning Node.
42
- 2. **Entity?** A concrete independent subject with retrieval value: deployable code, product/application/system, library/module/CLI/symbol, or an atomic term/pattern.
43
- 3. **Domain?** A container/scope that groups at least one child Node.
44
- 4. Otherwise do not create a Node; leave the material for compile as a Section under the owning Node.
45
-
46
- Good examples:
47
-
48
- | Type | Examples |
49
- |---|---|
50
- | `domain` | "X business domain", "Y technical area", "Z research topic" |
51
- | `entity` concrete | `@acme/api-server`, `@acme/ui-kit` `Button`, "X sub-application" |
52
- | `entity` term | "X identifier", "Y business metric", idempotency |
53
- | `action` | "user submits X request end-to-end flow", "operator executes Y change flow", "team Z release flow" |
54
-
55
- ## Title and Source Heading Rules
56
-
57
- Classify the Node by the evidence referent, not by the source file title, heading, or local section title. A source title is ordinary evidence just like body prose. It has no automatic right to become `node.title`, `aliases[]`, or `slug`.
58
-
59
- After choosing `node_type`, choose the title to fit that type:
60
-
61
- | Final type | Title shape |
62
- |---|---|
63
- | `entity` concrete | The concrete product, service, library, module, CLI, symbol, application, or system name. |
64
- | `entity` term | The atomic concept or pattern name, without extra scope/process suffixes. |
65
- | `domain` | The grouping scope that owns child Nodes. |
66
- | `action` | The executable process / runbook / flow name that passed the Action Gate. |
67
-
68
- Scope/process words in a source title are warning signals when proposed as an Entity title, not hard classification rules. Re-check the type/title when a proposed Entity title contains words such as "方案", "架构", "体系", "演练", "流程", "策略", "能力", "机制", "framework", "architecture", "system", "strategy", "process", or "drill". Keep the wording only when evidence shows it is the formal name of a concrete object or an atomic term.
69
-
70
- Do not promote broad architecture/system/方案 content to `domain` just because it sounds like a scope. When the source has writable Sections but no resolvable current/existing child Nodes, use an Entity such as `[system]` or `[application]` and put the architecture facts in Sections. Use `domain` only when it groups child Nodes through supported `edges[]`.
71
-
72
- Relation-only sources should not force title copying or dangling graph edges. Decide placeholder handling in this order:
73
-
74
- 1. If resolved current/existing child Nodes make the page a real grouping scope, keep the relation evidence as supported `edges[]` only when the Domain also has at least one source-backed planned Section.
75
- 2. If an explicit user-facing retrieval need or graph need makes the source/page identity valuable, and the title names an atomic concept or concrete object, keep that identity in `unresolved[]` until it has source-backed section evidence, a valid generated `parent_index` view with source-backed `contains` edges to child views, or a compile-time `skip` decision. Do not submit root-level `planned_sections: []` or ordinary source-bound `sections: []`.
76
- 3. Otherwise, skip navigation-only / placeholder-only material; keep a short
77
- `unresolved[]` note only when the deferred relation remains useful.
78
-
79
- Do not create a hidden domain-gate object. A kept placeholder needs support:
80
- source refs, approved graph support, or explicit user-confirmed retrieval value.
81
- For Domain placeholders, write only resolved current/existing children as typed
82
- `edges[]`; if all children are unresolved/deferred relation clues, keep those
83
- target hints in `unresolved[]`. If the source names only an atomic concept and
84
- that term is useful on its own, prefer a concise term Entity title without
85
- scope/process suffixes.
86
-
87
- For no-write placeholder summaries, describe only the preserved page identity and unresolved navigation clues. Do not say the Node "provides navigation/links/relations to X" unless those targets are resolved graph children or rendered links; say the source contains deferred navigation clues instead.
88
-
89
- ## Section Promotion Gate
90
-
91
- Classify local evidence as a Section before creating a child Node/View. A
92
- heading, table row, FAQ label, or short sub-topic does not by itself establish a
93
- standalone page.
94
-
95
- Promote a Section to a child View only when at least one condition is supported
96
- by source evidence:
97
-
98
- 1. The title is a concrete product/code object/system/module/library, not just a
99
- local heading.
100
- 2. The item is an atomic term or pattern that answers standalone lookup
101
- questions outside the parent page.
102
- 3. The item clears the Action Gate or Domain Gate.
103
- 4. The source gives it independent article identity: owner/date, lifecycle,
104
- timeline, tracking record, or cross-cutting support scope.
105
-
106
- Use one content-neutral test for every proposed child View: does cited evidence
107
- support an independent subject identity, enough context to stand alone, and a
108
- separate retrieval need? A heading, section kind, collection name, or contains
109
- edge is not sufficient by itself. The CLI warns when many same-source,
110
- single-section child Entities look mechanically fragmented, but it does not
111
- reject a page merely because of its content type.
112
-
113
- ## Entity Tag Rules
114
-
115
- Use `tags` to state what the Entity is. Legal combinations:
116
-
117
- | Case | Tags |
118
- |---|---|
119
- | Runtime/code object | one A tag: `app`, `service`, `lib`, `cli`, `module`, or `symbol` |
120
- | Product-analysis object | one B tag: `application` or `system` |
121
- | Code + product object | one A tag plus one B tag |
122
- | Pure term / pattern | only `term` |
123
-
124
- `term` is mutually exclusive with A/B tags. React is `[lib]`, not `[lib, term]`; if a separate term entry is useful, create another Entity tagged `[term]` and let the structure plan express the relation as a typed edge or unresolved relation with `source_refs[]`.
125
-
126
- Do not inherit scope tags mechanically. If a parent Entity is tagged `system` or
127
- `application`, a child Entity should repeat that tag only when it is itself an
128
- independent system/application. Local aspects under that parent should either
129
- use their own shape tag or remain Sections.
130
-
131
- ## Action Gate
132
-
133
- Use `node_type: action` only after the Node Type Order says action. Fill the
134
- action reasoning checklist in your working notes; persist only fields accepted by
135
- the current structure schema.
136
-
137
- The action probe uses five booleans as a reasoning checklist, but the semantic
138
- bar is:
139
-
140
- | Field | Meaning | Evidence rule |
141
- |---|---|---|
142
- | `has_steps_or_phases` | Process evidence exists: steps, phases, trigger -> handling -> result, role collaboration, or repeatable plan. | Hard requirement; support it from span evidence. |
143
- | `has_actor_or_role` | A user, system, operator, service, or role performs the work. | May be inferred; record the source. |
144
- | `has_outcome_or_goal` | The process has a target result, acceptance condition, or operational goal. | May be inferred; record the source. |
145
- | `is_repeatable_or_planned` | The work is repeatable, scheduled, policy-like, or intentionally planned. | May be inferred; record the source. |
146
- | `queries_answerable_with_refs` | The Node can answer how/when/who/what-to-do questions from cited spans. | May be inferred; record the source. |
147
-
148
- Do not emit an Action for a single sentence, a one-off conclusion, a short operation, or a parallel enumeration. Those become Sections under the owning Entity or Domain. The CLI does not infer single-Section Action exceptions from source prose; represent the material with enough structure or keep it as a Section.
149
-
150
- Action anti-examples:
151
-
152
- | Candidate | Correct routing |
153
- |---|---|
154
- | "migrate to X tool" as one conclusion | `decision` Section under the owning Entity |
155
- | "component X usage" as one sentence | `description` + maybe `example` under X |
156
- | "submit -> validate -> generate" as one unexpanded sentence | `spec` Section under X/Y |
157
- | "three API call modes" | `comparison`, `spec`, or `description` Section; not Action |
158
-
159
- ## Fake Entity Gate
160
-
161
- A relationship-style title is only suspicious by itself. Downgrade or change type when at least **two** signals are true:
162
-
163
- 1. Title contains relationship language such as "X impact on Y", "Y under X", "Y side of X", "X migration", or "X collection".
164
- 2. No legal Entity tag fits.
165
- 3. The Node does not stand alone away from its upstream Node.
166
-
167
- Repairs:
168
-
169
- | Pattern | Repair |
170
- |---|---|
171
- | "X impact on Y" | Section under X plus a typed edge or unresolved relation to Y when the evidence supports it |
172
- | "Y under X condition" | Section under Y; X is a condition in the Section body |
173
- | "X subsystem migration" | Action only if it clears the Action Gate; otherwise `decision` Section under X |
174
- | "X error collection" / "X FAQ collection" | `faq` / `incident` Sections under X |
175
-
176
- ## Domain Gate
177
-
178
- Use `node_type: domain` only for a scope that groups child Nodes. Keep this
179
- domain reasoning checklist in working notes and persist supported relations through current
180
- `edges[]` or `unresolved[]`:
181
-
182
- | Field | Meaning |
183
- |---|---|
184
- | `scope_refs[]` | Source refs that describe the scope boundary or grouping. |
185
- | `child_refs[]` | Working-note candidate ids, local refs, or final slugs for children in the scope; persist valid ones as `edges[]`. |
186
- | `grouping_reason` | Why these children belong together under this domain. |
187
-
188
- If a domain has no resolvable child refs, no clear grouping reason, or only one same-file child without a broader scope, do not emit a Domain. For navigation-only / placeholder-only sources with only deferred children, skip the Node after ruling out standalone retrieval or graph value for an atomic-term or concrete Entity; keep only useful unresolved relation notes. Emit an Entity only when evidence names an atomic term or concrete object and choose its Entity tag yourself. The CLI rejects invalid Domain gates; it does not auto-downgrade a Domain or choose fallback tags.
189
-
190
- Scope-name titles such as "X 业务域", "Y 领域", "business domain", or "technical area" are a warning sign when proposed as Entity. Keep them as Entity only when the subject is an atomic term or concrete object; otherwise use Domain with supported child edges or unresolved relation hints.
191
-
192
- ## Edge Gate
193
-
194
- Use a typed edge only when all four checks pass:
195
-
196
- 1. Both `from` and `to` nodes exist in the current structure or approved
197
- knowledge.
198
- 2. The relation type is in the current closed set (`is_a`, `contains`,
199
- `depends_on`, `corresponds_to`, `causes`, `triggers`, `prerequisite`,
200
- `applies_to`, `verified_by`, `supersedes`).
201
- 3. `source_refs[]` cite evidence for the relation itself, not just for one
202
- endpoint.
203
- 4. The relation is stronger than a vague "related" hint.
204
-
205
- If any check fails, write an `unresolved[]` item instead of an edge.
206
-
207
- If the source sentence states the relation with uncertainty, keep the edge only
208
- when the uncertainty is source-authored and preserved through
209
- `confidence: possible` or `confidence: hypothesis`. Do not use `confidence` for
210
- Agent uncertainty. If you are uncertain whether the evidence supports the
211
- relation, write `unresolved[]` instead.
212
-
213
- ## Inference Sources
214
-
215
- Inference sources are working notes for the action reasoning checklist; do not
216
- persist this object unless the current schema explicitly exposes it:
217
-
218
- ```yaml
219
- inference_sources:
220
- actor:
221
- source_type: explicit-span
222
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
223
- rationale: "The span names the operator role."
224
- outcome_or_goal:
225
- source_type: inferred-from-span
226
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
227
- rationale: "The span describes recovery as the expected result."
228
- repeatability_or_plan:
229
- source_type: heading-and-span
230
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
231
- rationale: "The runbook heading and ordered list indicate planned reuse."
232
- answerability:
233
- source_type: explicit-span
234
- source_refs: ["file:docs/runbook.md#span:steps L10-18@<span-hash>"]
235
- rationale: "The steps answer how the operation is performed."
236
- ```
237
-
238
- Allowed `source_type` values:
239
-
240
- | Value | Use when |
241
- |---|---|
242
- | `explicit-span` | The evidence span directly states the signal. |
243
- | `heading-and-span` | The heading plus span text together support the signal. |
244
- | `ref-node` | An existing or same-decision Node reference supplies the signal. Include `ref_nodes`. |
245
- | `inferred-from-span` | The signal is inferred from span content. Keep the rationale short and concrete. |
246
-
247
- Each source must include `rationale` when inferred and at least one of `source_refs[]` or `ref_nodes[]`.
248
-
249
- ## Final Reflection
250
-
251
- - Entity cannot pick a legal tag, or depends on its upstream title to make sense -> write it as a Section under the upstream Node or change type before submit.
252
- - Action only supports one Section -> confirm its standalone retrieval value, write it as a Section under its owner, or add another source-backed Section / child Action. Multiple source-backed Sections may use the same kind; the CLI does not manufacture semantic variety to validate an Action.
253
- - Action "steps" are parallel options/configs -> route to Entity `comparison` / `spec` / `description`.
254
- - Domain has no children -> delete it or merge it into a larger Domain.
255
-
256
- ## Current CLI Quality Diagnostics
257
-
258
- Current `context.structure.v1` validation preserves the old Node quality
259
- checks as deterministic diagnostics:
260
-
261
- | Diagnostic | Meaning | Required response |
262
- |---|---|---|
263
- | `schema.section_kind_invalid` | A planned Section uses a kind outside the current prose kind set. | Replace it with a kind from the schema view; do not invent local kind names. |
264
- | `schema.section_kind_mount_invalid` | A planned Section kind cannot be mounted on the chosen `node_type`. | Choose a kind allowed by the mount matrix, or reclassify the Node before confirming structure. |
265
- | `tags.term_conflict` | An Entity uses `term` together with concrete runtime/product tags such as `lib`, `service`, `application`, or `system`. | Split the term from the concrete object, or remove the conflicting tag before staging. |
266
- | `node.description_dominates` | A non-Action Node has at least half of its planned Sections as `description`. | Re-run kind precision. Keep it only when source evidence is genuinely narrative; otherwise split into `example`, `spec`, `comparison`, `faq`, `incident`, `decision`, `warning`, or `principle`. |
267
- | `node.thin_concrete_entity` | A concrete Entity has one Section and no child Nodes. | Keep it only when it has stable standalone retrieval value; otherwise merge it into the owning Node. |
268
- | `node.children_should_be_sections` | One parent contains many same-source, single-section child Entities with no stable shape tag. | Merge those children into parent Sections unless the user confirms each child has standalone lookup value. |
269
- | `node.term_expanded_beyond_definition` | A `term` Entity has grown past a compact definition or owns children. | Move rules, procedures, designs, and examples to the owning Node; keep the term entry narrow. |
270
- | `node.action_too_thin` | An Action has one planned Section and no child Action. | Confirm its standalone retrieval value, keep it as a Section under the owning Node, add another source-backed Section, or add a child Action. This warning does not require artificial Section-kind diversity. |
271
- | `node.domain_without_children` | A Domain has no source-backed `contains` child edge. | Add supported children, keep an explicitly confirmed no-write placeholder, or reclassify the Node. |
272
- | `tags.child_inherits_system` | A child Entity repeats its parent `system` / `application` scope tag. | Retag by the child’s own shape/scope, or keep the child as a Section if it is only a local aspect. |
273
- | `edge.confidence_invalid` | An edge declares a confidence value outside the current schema. | Use only `possible` or `hypothesis`, or omit the field for source-certain relations. |
274
-
275
- Warnings are not automatic blockers, but they are not suggestions to ignore.
276
- Resolve them or include the user-confirmed rationale when confirming structure.