@c4a/context-cli 0.6.1-beta.2 → 0.6.1-beta.4

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 (57) hide show
  1. package/README.md +20 -9
  2. package/README.zh-CN.md +10 -8
  3. package/cli.js +66051 -62866
  4. package/docs/quickstart.md +13 -0
  5. package/package.json +3 -3
  6. package/plugins/README.md +18 -2
  7. package/plugins/README_CN.md +16 -2
  8. package/plugins/VERSION +1 -1
  9. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  10. package/plugins/claude/commands/continue.md +33 -4
  11. package/plugins/claude/commands/init.md +21 -17
  12. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  13. package/plugins/codex/skills/continue/SKILL.md +33 -4
  14. package/plugins/codex/skills/init/SKILL.md +23 -19
  15. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  16. package/plugins/cursor/commands/context-continue.md +33 -4
  17. package/plugins/cursor/commands/context-init.md +24 -20
  18. package/plugins/skills/context-continue/SKILL.md +33 -4
  19. package/plugins/skills/context-init/SKILL.md +23 -19
  20. package/providers/context/actions/accept-package-templates.yaml +5 -0
  21. package/providers/context/actions/align-next.yaml +1 -1
  22. package/providers/context/actions/apply-managed-review.yaml +0 -1
  23. package/providers/context/actions/apply-structure-confirmation.yaml +0 -1
  24. package/providers/context/actions/capture-next.yaml +0 -1
  25. package/providers/context/actions/compile-next.yaml +0 -1
  26. package/providers/context/actions/configure-code-extraction.yaml +0 -1
  27. package/providers/context/actions/configure-document-capture.yaml +0 -1
  28. package/providers/context/actions/configure-package-output.yaml +0 -1
  29. package/providers/context/actions/configure-prose-lifecycle.yaml +0 -1
  30. package/providers/context/actions/ensure-repository-sources.yaml +1 -1
  31. package/providers/context/actions/extract-next.yaml +0 -1
  32. package/providers/context/actions/repair-project-entry.yaml +0 -1
  33. package/providers/context/actions/repair-workspace-state.yaml +0 -1
  34. package/providers/context/codes.yaml +2 -0
  35. package/providers/context/graphs/workspace.yaml +26 -1
  36. package/providers/context/manifest.json +95 -68
  37. package/providers/context/provider.yaml +1 -1
  38. package/providers/context/resources/diagnostics/projection-stale.md +13 -0
  39. package/providers/context/resources/dialogue/document-classification.md +2 -1
  40. package/providers/context/resources/dialogue/package-output.md +5 -7
  41. package/providers/context/resources/manuals/guides/package-outputs.md +40 -37
  42. package/providers/context/resources/manuals/reference/package-templates.md +36 -48
  43. package/providers/context/resources/manuals/reference/project-api.md +95 -12
  44. package/providers/context/resources/manuals/reference/template-variables.md +12 -11
  45. package/providers/context/resources/procedures/close-and-build.md +3 -2
  46. package/providers/context/resources/procedures/code-extraction.md +16 -2
  47. package/providers/context/resources/procedures/document-capture.md +14 -0
  48. package/providers/context/resources/procedures/document-classification.md +3 -1
  49. package/providers/context/resources/procedures/evidence-maintenance.md +0 -1
  50. package/providers/context/resources/procedures/knowledge-review.md +0 -1
  51. package/providers/context/resources/procedures/package-output.md +17 -11
  52. package/providers/context/resources/procedures/project-configuration.md +0 -1
  53. package/providers/context/resources/procedures/prose-align.md +45 -0
  54. package/providers/context/resources/procedures/verify-and-repair.md +0 -1
  55. package/providers/context/resources/semantic/align/candidate-resolution.md +4 -2
  56. package/providers/context/resources/semantic/align/structure-planning.md +24 -8
  57. package/providers/context/schemas/prose-structure-batch.schema.json +35 -0
@@ -13,8 +13,10 @@ example, or a fixed content-specific prompt.
13
13
  Read the current collection-neutral evidence view, explain a short
14
14
  evidence-backed recommendation and its output implications, then obtain the
15
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.
16
19
 
17
20
  After the decision, declare the complete align, compile, and review lifecycle
18
21
  for the same canonical source and collection. Re-evaluate instead of assuming
19
22
  the declaration closed every document target.
20
-
@@ -18,4 +18,3 @@ the resulting evidence state must stay explicit.
18
18
 
19
19
  Use the affected `view_ref` values from the current diagnostic resource. Do not
20
20
  target maintenance by guessed paths or node names.
21
-
@@ -22,4 +22,3 @@ conversation. It does not bypass source permission, validation, close, or
22
22
  verify.
23
23
 
24
24
  After apply, re-evaluate. Do not infer that close or package output is current.
25
-
@@ -11,21 +11,27 @@ agents or text consumers. Explain the available Context package kinds and their
11
11
  directory shape before asking the user to choose.
12
12
 
13
13
  After confirmation, declare the package in `src/index.ts` using the SDK schema
14
- resource. Templates may customize presentation, but they must not overwrite
14
+ resource. The current Route's `configuration.contract` lists the supported
15
+ output choices, required fields, mechanical defaults, and follow-up status
16
+ command; do not infer another factory or hidden default. Templates may customize presentation, but they must not overwrite
15
17
  approved knowledge paths or remove required indexes.
16
18
 
17
- An Agent knowledge-base package uses its package name as a stable single-level
18
- knowledge namespace by default. Explain that default after the package name is
19
- confirmed. Ask for a custom namespace only when the user needs another value;
20
- it may contain several concise lowercase path segments, such as
21
- `group/package` or `personal-user.123/package`, with letters and numbers joined
22
- by hyphens or dots. Declare an override as
23
- `kbPackage({ distribution: { knowledgeNamespace } })`; do not derive it from
24
- an unstated downstream identity or rewrite template prose.
19
+ Generated generic templates carry a mechanical digest marker. Before the first
20
+ build, replace or edit the declared template source, or explicitly accept the
21
+ unchanged generic default through the current Route. Editing the template
22
+ changes its digest and resolves the review without a separate command.
23
+ Acceptance records only that decision; Context does not judge template prose
24
+ or infer audience, scope, or navigation semantics.
25
25
 
26
- Ask separately whether the author wants a short optional Skill prefix. If so,
26
+ An Agent knowledge-base package writes flat package-relative roots such as
27
+ `wikis/`, `guides/`, `rules/`, and `feats/`. The package name already provides
28
+ the surrounding `dist/<package-name>/` boundary. Do not ask the user for a
29
+ distribution namespace or add `distribution.knowledgeNamespace` to a new
30
+ declaration.
31
+
32
+ Ask whether the author wants a short optional Skill prefix. If so,
27
33
  maintain the complete final Skill directory name in the template, such as
28
- `skills/android-query/`. Knowledge namespaces never rename Skills.
34
+ `skills/android-query/`. Package-root layout never renames Skills.
29
35
 
30
36
  Package output is incremental: a built package is current only for the approved
31
37
  knowledge and template digests recorded by its receipt.
@@ -19,4 +19,3 @@ declaration requested by the route in `src/index.ts`.
19
19
 
20
20
  The Context SDK API reference is a discoverable resource. Do not guess an API
21
21
  shape from older prompts or cached plugin text.
22
-
@@ -14,10 +14,55 @@ and block boundaries when they preserve coherent reading units; fixed line
14
14
  windows are only a fallback for unstructured text. A page may contain multiple
15
15
  sections, each with its own continuous evidence span.
16
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
+
17
42
  Stage all required source/collection slots before batch Review. Structure
18
43
  confirmation is an explicit gate. A confirmation applies only to the staged
19
44
  slot digest shown by the route; if the digest changes, confirm again.
20
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
+
21
66
  Independent read-only evidence views may run in parallel. Structure stage,
22
67
  confirmation, compile writes, and Review application are serial lifecycle
23
68
  mutations; execute them in the order selected by `workflow.current`.
@@ -17,4 +17,3 @@ then run verification again.
17
17
  Do not delete candidates, approved pages, snapshots, or structure slots to make
18
18
  verification pass. Derived diagnostics should not be handled as independent
19
19
  root failures.
20
-
@@ -45,8 +45,10 @@ Known anomaly kinds:
45
45
  Use stable `node_ref`, `view_ref`, and `section_ref` values from the current
46
46
  `context.structure.v1` payload for in-payload references. A NodeRef should be
47
47
  safe, lower-case, and path-shaped, such as `entity/rspack` or
48
- `domain/build-tooling`. `slug` and `path` are derived fields in the current
49
- flow; do not invent alternate reference aliases.
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.
50
52
 
51
53
  When an edge or section points at knowledge:
52
54
 
@@ -34,9 +34,9 @@ Run `context run align:<type>:<source>:<collection> --view read-plan --format js
34
34
  - Schema names and enum values come from
35
35
  `context run align:<type>:<source>:<collection> --view schema --format json`. Use
36
36
  that schema as the authoring contract for `context.structure.v1`.
37
- - Existing approved knowledge and `knowledge/structure.yaml` are the lookup
38
- registry exposed through current CLI/status/query views. Do not read
39
- `knowledge/**` or create a separate registry file.
37
+ - Existing approved knowledge is the lookup registry exposed by the current
38
+ align `existing-knowledge` View. Do not read `knowledge/**`, guess a top-level
39
+ query command, or create a separate registry file.
40
40
  - Code projection Nodes are reusable knowledge handles. When document evidence belongs on a code symbol, reuse the code slug instead of creating a parallel document Node.
41
41
  - Validation diagnostics are the mechanical structure ownership source of
42
42
  truth. Non-content spans such as navigation references, placeholders, front
@@ -55,7 +55,10 @@ Run `context run align:<type>:<source>:<collection> --view read-plan --format js
55
55
  placeholder/relation source is skipped entirely, leave its relation clues in
56
56
  `unresolved[]` only when they still matter; otherwise omit them.
57
57
  - `views[]` and diagnostics distinguish citable evidence from supporting context. Do not promote supporting/context-only material into cited Sections unless a later ownership correction makes it citation-eligible.
58
- - Keep cache-friendly prompt order: fixed protocol/schema first, existing knowledge lookup second, source evidence views third, current semantic payload last. Preserve CLI JSON order and do not add timestamps, random ids, scratch paths, or host paths to generated payloads.
58
+ - Keep cache-friendly prompt order: fixed protocol/schema first, source evidence
59
+ views second, targeted existing-knowledge results third, and the current
60
+ semantic payload last. Preserve CLI JSON order and do not add timestamps,
61
+ random ids, scratch paths, or host paths to generated payloads.
59
62
  - Structure digests and snapshot hashes are stale guards. Follow returned
60
63
  `next_action.command` and do not invent digest values.
61
64
  - Node type, tag, fake-Entity, `domain`, and `action` gates are in `structure-planning/references/gates.md`.
@@ -91,8 +94,9 @@ or `next_command`.
91
94
 
92
95
  `read-plan` is the navigation surface. It chooses whether the next evidence read
93
96
  is `source-index`, `span-detail`, `span-text`, or another current evidence view.
94
- Read those views and then author the requested
95
- `context.structure.v1` payload yourself. Never pipe evidence text into validate.
97
+ Read those views and then author the requested `context.structure.v1` payload
98
+ yourself after completing the targeted lookup in Step 3. Never pipe evidence
99
+ text into validate.
96
100
 
97
101
  If an evidence view is truncated, `page.has_more: true`, or the CLI returns a
98
102
  `next_command`, run that command before authoring.
@@ -107,7 +111,19 @@ is explicitly needed, otherwise return to the CLI-designated navigation view.
107
111
 
108
112
  ### Step 3 — Reuse Existing Knowledge
109
113
 
110
- Query existing knowledge for reusable names before proposing new term/service/system/action Nodes. Exact title/slug/alias hits should usually become references to the existing Node, not duplicate candidates.
114
+ After source evidence identifies a candidate title or stable ref, run:
115
+
116
+ ```bash
117
+ context run align:<type>:<source>:<collection> --view existing-knowledge --query <title-or-stable-ref> --format json
118
+ ```
119
+
120
+ Use the returned pagination command when present. Exact title, NodeRef, or
121
+ ViewRef hits should usually reuse the existing Node instead of creating a
122
+ duplicate candidate. The lookup returns only the best title/NodeRef/ViewRef
123
+ identity tier. Shared tag matches are summarized separately and never require
124
+ walking the related subgraph merely to determine whether a root identity
125
+ exists. The lookup is deterministic identity discovery; the Agent still
126
+ decides whether the source evidence describes the same concept.
111
127
 
112
128
  When a code projection Node already represents the object, reuse its slug for prose evidence and plan only prose-owned Sections for the current source evidence.
113
129
 
@@ -311,6 +327,6 @@ editing CLI-managed files.
311
327
  - [ ] Node classification used the semantic gates in `structure-planning/references/gates.md`. If not, return to **Step 4**.
312
328
  - [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
313
329
  - [ ] The requested align payload passed `context run align:<type>:<source>:<collection> --validate --input - --format json` before stage. If not, return to **Step 6**.
314
- - [ ] No `sources/`, `unapproved/`, `knowledge/`, `dist/`, `.tmp`, host tool-results, or CLI-managed files were read or written with generic tools. If violated, restart from **Step 1**.
330
+ - [ ] 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**.
315
331
 
316
332
  </procedures>
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "context.prose.structure-batch.v1",
4
+ "title": "Context prose structure batch",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema", "items"],
8
+ "properties": {
9
+ "schema": {
10
+ "const": "context.prose.structure-batch.v1"
11
+ },
12
+ "items": {
13
+ "type": "array",
14
+ "minItems": 1,
15
+ "maxItems": 100,
16
+ "items": {
17
+ "type": "object",
18
+ "additionalProperties": false,
19
+ "required": ["phase_id", "input"],
20
+ "properties": {
21
+ "phase_id": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "description": "One declared phase.align.prose id from the current pending structure targets."
25
+ },
26
+ "input": {
27
+ "type": "string",
28
+ "minLength": 1,
29
+ "description": "Project-relative or absolute YAML/JSON context.structure.v1 payload path for this target."
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }