@c4a/context-cli 0.6.8 → 0.6.10

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 (35) hide show
  1. package/README.md +156 -220
  2. package/README.zh-CN.md +120 -160
  3. package/cli.js +265 -58
  4. package/docs/quickstart.md +57 -70
  5. package/docs/quickstart.zh-CN.md +79 -0
  6. package/package.json +4 -4
  7. package/plugins/.agents/plugins/marketplace.json +1 -1
  8. package/plugins/.claude-plugin/marketplace.json +2 -2
  9. package/plugins/.cursor-plugin/marketplace.json +2 -2
  10. package/plugins/README.md +79 -66
  11. package/plugins/README_CN.md +62 -57
  12. package/plugins/VERSION +1 -1
  13. package/plugins/claude/.claude-plugin/plugin.json +3 -3
  14. package/plugins/claude/commands/context.md +121 -0
  15. package/plugins/codex/.codex-plugin/plugin.json +4 -4
  16. package/plugins/codex/skills/context/SKILL.md +133 -0
  17. package/plugins/cursor/.cursor-plugin/plugin.json +3 -3
  18. package/plugins/cursor/README.md +2 -2
  19. package/plugins/cursor/commands/c4a-context.md +125 -0
  20. package/plugins/skills/c4a-context/SKILL.md +133 -0
  21. package/providers/context/graphs/workspace.yaml +40 -1
  22. package/providers/context/manifest.json +27 -9
  23. package/providers/context/provider.yaml +2 -2
  24. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +22 -0
  25. package/providers/context/resources/dialogue/workflow-mode-after-creation.md +25 -0
  26. package/providers/context/resources/manuals/guides/package-outputs.md +1 -1
  27. package/providers/context/resources/manuals/reference/package-templates.md +1 -1
  28. package/plugins/claude/commands/continue.md +0 -109
  29. package/plugins/claude/commands/init.md +0 -36
  30. package/plugins/codex/skills/continue/SKILL.md +0 -121
  31. package/plugins/codex/skills/init/SKILL.md +0 -48
  32. package/plugins/cursor/commands/context-continue.md +0 -113
  33. package/plugins/cursor/commands/context-init.md +0 -40
  34. package/plugins/skills/context-continue/SKILL.md +0 -121
  35. package/plugins/skills/context-init/SKILL.md +0 -48
package/README.md CHANGED
@@ -1,268 +1,204 @@
1
- # Context CLI
1
+ # Context Agent Runtime
2
2
 
3
3
  [简体中文](./README.zh-CN.md)
4
4
 
5
- `@c4a/context-cli` provides the **Context CLI** and the global Agent plugin
6
- installer. The CLI manages project-local workspace state; the Agent plugin
7
- explains that state, asks for user decisions, and edits project configuration.
5
+ `@c4a/context-cli` ships the local runtime and Agent integration for the
6
+ Context knowledge production workflow. Despite the package name, its primary
7
+ user experience is not a terminal command catalog: users invoke one Agent
8
+ entry, describe the knowledge they want, and follow the decisions explained in
9
+ conversation.
8
10
 
9
- The CLI is Node/Bun compatible and does not call an LLM. Mechanical work belongs
10
- to the CLI, semantic judgment belongs to the Agent, and important decisions
11
- belong to the user.
11
+ The runtime performs deterministic work—workspace observation, source capture,
12
+ code indexing, evidence validation, candidate staging, review application,
13
+ verification, and package builds. The Agent performs semantic work, while the
14
+ user owns permissions and important content decisions. The runtime never calls
15
+ an LLM itself.
12
16
 
13
- Markdown parsing is structural only: source headings remain inside citeable
14
- evidence spans, while their meaning, grouping, and knowledge type are never
15
- inferred by the CLI.
16
-
17
- ## Install
17
+ ## Install the Agent integration
18
18
 
19
19
  ```bash
20
- npm install -g @c4a/context-cli
20
+ npm install -g @c4a/context-cli@latest
21
21
  context plugin install
22
22
  ```
23
23
 
24
- Global package installation also attempts a best-effort plugin refresh. Run
25
- `context plugin install` again after installing or upgrading Claude or Codex,
26
- then restart the Agent.
24
+ Restart or refresh the Agent host after installation. The bundled installer
25
+ projects the same source entry into supported Claude, Codex, Cursor, and
26
+ Skill-compatible layouts.
27
27
 
28
- The public Agent entries are:
28
+ The public community entry is `/c4a:context`. It creates a requested workspace,
29
+ locates an existing workspace, or resumes the current workflow. Users should
30
+ start with intent, not internal commands:
29
31
 
30
- - `/context:init` creates a project-local Context workspace.
31
- - `/context:continue` reads the current workspace state and continues from the
32
- next action.
32
+ ```text
33
+ /c4a:context Turn these product documents and this repository into a reviewed
34
+ Agent knowledge package. Keep every code claim traceable.
35
+ ```
33
36
 
34
- `/context:continue` is Agent guidance, not a CLI subcommand. There is no
35
- `context continue` command.
37
+ If the Agent entry is present but the `context` executable is missing, the
38
+ entry reports the exact installation recovery and stops. It does not run an
39
+ installation preflight on every request and does not confuse a normal workflow
40
+ `not found` diagnostic with a missing executable.
36
41
 
37
- For the shortest installed-package walkthrough, read
38
- [CLI Quickstart](./docs/quickstart.md).
42
+ ## How one Agent entry drives the workflow
39
43
 
40
- Workspace tracing is off by default. Use `context init context --debug` or
41
- `context debug enable` only when command and Agent Graph route observability is
42
- needed; logs stay under ignored `.tmp/context-runtime/debug/`. See
43
- [Workspace debug tracing](./docs/debug-tracing.md).
44
+ ```text
45
+ User knowledge goal
46
+
47
+ single Agent entry
48
+
49
+ context entry ── observes workspace location and state
50
+
51
+ workflow.current ── current Route, resources, Gate, exact commands
52
+
53
+ Agent reads / decides / executes one selected action
54
+
55
+ workspace facts change ── evaluate again
56
+ ```
44
57
 
45
- ## CLI And Agent Responsibilities
58
+ `context entry --format json` is the read-only bootstrap resolver. It can
59
+ return an initialization action, a workspace relocation action, or the current
60
+ workflow evaluation. There is no `context continue` primitive and no separate
61
+ public entry for source, review, build, or status.
46
62
 
47
- | Responsibility | Owner |
48
- |---|---|
49
- | Source registries, capture, extraction, review application, verify, and build | CLI |
50
- | Explaining choices, editing `src/index.ts`, proposing structure, and generating candidates from evidence | Agent |
51
- | Source permission, classification, review decisions, and package-output choice | User |
63
+ Once a workspace is ready, `workflow.current` is the current-step authority:
52
64
 
53
- The Agent treats `context status --format json` `workflow.current` as the
54
- current-step authority rather than guessing the next command. The default JSON
55
- view is compact: it contains the route, required resource locations, progress,
56
- counts, and aggregated diagnostics. Use `--view full` only for debugging. Long
57
- procedures and semantic rules remain complete Markdown resources selected by
58
- the route; progressive loading does not shorten or discard them.
65
+ - required resources marked `read-required` are read completely before acting;
66
+ - only Route-returned commands are executed, with their revision and authority
67
+ arguments preserved;
68
+ - human Gates explain the decision and its impact before collecting a choice;
69
+ - project configuration changes are limited to the file named by the Route;
70
+ - every action is followed by a fresh observation, so stale commands cannot
71
+ advance a changed workspace.
59
72
 
60
- ## Create Or Continue A Workspace
73
+ Long procedures, schemas, diagnostics, and source views remain addressable
74
+ files in the bundled workflow. The Agent loads only what the current Route
75
+ selects instead of carrying the entire lifecycle in its prompt.
61
76
 
62
- ```bash
63
- # Create a standalone workspace.
64
- context init context
65
- # Use --language zh-CN when generated workspace and starter templates should be Chinese.
66
- cd context
67
- bun install
68
-
69
- # Ask the Agent to continue from the current state.
70
- /context:continue
71
- ```
77
+ ## The knowledge production lifecycle
72
78
 
73
- The generated `AGENTS.md` is the Agent's project-local operating guide. After
74
- dependency installation, SDK manuals are available at:
79
+ | Phase | What the user experiences | What the runtime protects |
80
+ |---|---|---|
81
+ | Goal and sources | Confirm what knowledge is needed and which materials are in scope | Source identity, permission boundary, pinned repository or document inputs |
82
+ | Capture and extraction | The Agent reads documents or inspects a confirmed code boundary | Complete bodies, resources, symbols, relations, fingerprints, and freshness |
83
+ | Structure and compile | Review the proposed knowledge organization and content | Source-bound Nodes and Sections, coverage, continuity, and stable identities |
84
+ | Review and close | Approve, reject, or adjust the candidate set | Atomic review application, durable decisions, and closed structure projection |
85
+ | Verify and build | Choose an output and receive a reusable package | Validation, package templates, asset policy, and build inventory |
75
86
 
76
- ```text
77
- node_modules/@c4a/context/docs/README.md
78
- node_modules/@c4a/context/docs/guides/agent-guide.md
79
- node_modules/@c4a/context/docs/reference/project-api.md
80
- node_modules/@c4a/context/docs/reference/package-templates.md
81
- ```
87
+ Building completes the currently approved state; it does not freeze the
88
+ workspace. New or changed sources can open another production round later.
82
89
 
83
- The workspace state is split across:
84
-
85
- - `src/` for project declarations and package templates.
86
- - `sources/` for source registries and captured evidence.
87
- - `.tmp/context-runtime/lifecycle/` for ignored, CLI-managed draft candidates and
88
- confirmed structure snapshots during an open lifecycle round.
89
- - `knowledge/` for approved Markdown, the closed `structure.yaml` projection,
90
- and the minimal `decisions.json` rejected-candidate fingerprint map when one
91
- exists. Resources referenced by approved pages live in content-addressed
92
- `knowledge/assets/` paths.
93
- - `dist/` for generated package output.
94
- - `.tmp/context-runtime/` for other ignored logs, previews, reports, locks, and caches.
95
-
96
- The lifecycle and review runtime state is not user-editable and is removed by a
97
- successful `context close`. `knowledge/structure.yaml` is the durable approved
98
- structure projection. Its minimal `source_inputs` entries record only the
99
- source, collection, and source snapshot consumed by a closed prose target, so a
100
- clean workspace can distinguish completed and changed inputs after transient
101
- snapshots are removed. `knowledge/decisions.json` only preserves rejected
102
- candidate IDs and their fingerprints so unchanged candidates are not offered again.
103
-
104
- Do not repair lifecycle state by manually deleting or rewriting these
105
- directories. Use the command or next action returned by the CLI.
106
-
107
- ## Package Output
108
-
109
- `context build` writes each declared package under `dist/<package-name>/`.
110
- KB packages use flat, package-relative OKF roots: `wikis/`, `guides/`,
111
- `rules/`, and `feats/`. The package name already identifies the surrounding
112
- `dist/<package-name>/` directory and is not repeated inside those roots. Older
113
- workspaces that still declare `distribution.knowledgeNamespace` remain
114
- loadable, but the legacy value no longer changes package paths.
115
- New KB setup should offer Git raw resource delivery first. Build rewrites links
116
- to repository raw URLs; committing and publishing the resources remains the
117
- package author's responsibility. An explicit `urlPrefix` also works when the
118
- Context workspace itself is outside Git. Without Git or an explicit prefix,
119
- authors can bundle resources under `others/assets/` or explicitly omit them and
120
- retain unresolved references.
121
- Bundled delivery may configure `kbPackage().assets.optimize`; Context itself
122
- does not depend on an image processor.
123
-
124
- See the SDK manuals for the complete configuration and template contract:
125
-
126
- - [Package outputs](../context/docs/guides/package-outputs.md)
127
- - [Package templates](../context/docs/reference/package-templates.md)
128
-
129
- ## Status-Driven Workflow
130
-
131
- The project workflow is declared in `src/index.ts` and routed by the bundled
132
- Context workflow graph behind `context status`. This graph is an internal CLI
133
- implementation detail; Context users and plugins consume only
134
- `workflow.current`, Context commands, and the selected resources:
135
-
136
- | Stage | CLI surface |
137
- |---|---|
138
- | Source setup | `context source add repo/file/lark`, `context source add batch`, and `context source ensure` |
139
- | Document capture | Declared capture phases through `context run <phase-id>` |
140
- | Code extraction | Declared `extractTs` phases through `context run <phase-id>` |
141
- | Prose structure | `context run align:<type>:<source>:<collection> ...` evidence and validation views |
142
- | Prose compile | `context run compile:<type>:<source>:<collection> ...` evidence and validation views |
143
- | Review | `context review html`, scoped decisions, and `context review apply` |
144
- | Close and quality | `context close` and `context verify` |
145
- | Package output | `context build` |
146
-
147
- Building a package completes the currently active approved state; it does not
148
- freeze the workspace. New sources can be added and processed later.
149
-
150
- With explicit current-conversation managed authority,
151
- `context run --managed --until blocked-or-complete` keeps one workspace-bound
152
- runtime for consecutive deterministic actions. Each action remains bound to
153
- the Route revision that selected it; after the action, Context reloads the
154
- project from disk and evaluates the graph again. Known local actions run in the
155
- same process, while source tools and other external effects remain isolated in
156
- child processes.
157
-
158
- The runtime scope owns only short-lived resources such as output capture,
159
- timers, child processes, and write locks, and releases them in reverse order.
160
- Knowledge, snapshots, decisions, and package output are durable state: they
161
- retain their existing revision checks, project write lock, atomic write, close,
162
- and verify contracts. No execution scope rolls back or substitutes those
163
- contracts, and the workspace file protocol is unchanged.
164
-
165
- ## Command Groups
90
+ ## Ordinary and fully managed conversations
166
91
 
167
- ```bash
168
- # Plugin installation and diagnostics
169
- context plugin install
170
- context plugin status
92
+ Ordinary mode is the default. It preserves explicit source, scope, structure,
93
+ review, and package decisions and can provide HTML inspection reports at
94
+ content-review Gates.
171
95
 
172
- # Workspace creation and state
173
- context init [project-dir]
174
- context status
175
- context run --managed --until blocked-or-complete --format json
96
+ When the user explicitly authorizes fully managed operation for the current
97
+ conversation, the Agent uses:
176
98
 
177
- # Route-selected resources
178
- context resource materialize --help
179
- context resource acknowledge-current --help
180
-
181
- # Sources
182
- context source add repo [YYYYMMDD] --module <module> --local <repo-or-subdir>
183
- context source add file [YYYYMMDD] --module <module> --local <file-or-folder>
184
- context source add lark [YYYYMMDD] --module <module> --url <lark-url>
185
- context source add batch [YYYYMMDD] --input <yaml-or-json>
186
- context source remove <source-id> --format json # preview
187
- context source remove <source-id> --yes --plan-digest <preview-digest> --format json
188
- context source ensure [source]
189
- context source inspect [source]
190
-
191
- # Declared phases and review
192
- context run --list
193
- context run <phase-id> --dry-run
194
- context run <phase-id>
195
- context review html [collection] --open
196
- context review apply <payload-file>
197
-
198
- # Package template decisions
199
- context package template accept --help
200
-
201
- # Final quality and output
202
- context close
203
- context verify
204
- context build
205
-
206
- # Optional workspace tracing
207
- context debug enable
208
- context debug status
209
- context debug export
210
-
211
- # Development/cache maintenance
212
- context clean-cache --dry-run
99
+ ```bash
100
+ context run --managed --until blocked-or-complete --format json
213
101
  ```
214
102
 
215
- Run `context <command> --help` for current flags. Commands that require a
216
- workspace search upward for a `package.json` with `context.project=true` and a
217
- configured `context.entry`. Revision-bound resource and package commands should
218
- normally be copied from `workflow.current`; the examples above show their
219
- discovery surface rather than a replacement for the current route.
220
-
221
- ## Human Gates And Evidence
103
+ This collapses consecutive deterministic actions and delegated Gates, then
104
+ stops when Agent reading, project configuration, additional permission,
105
+ diagnostic repair, or a non-unique plan needs attention. It reuses the same
106
+ workflow Graph and does not remove ordinary-mode review capability. The
107
+ authority is conversation-scoped; it does not persist and cannot authorize new
108
+ source boundaries, unread external content, repository operations, failed
109
+ validation, or failed verification.
222
110
 
223
- - The CLI never silently clones, checks out, resets, fetches, installs, builds,
224
- or runs scripts in a source repository.
225
- - Source registration and source-body reading are separate permissions.
226
- - Extraction scope and document classification are confirmed before candidate
227
- writes.
228
- - In ordinary mode, Review decisions come from the user and the Agent must not
229
- invent payloads. Explicit current-conversation fully managed mode uses only
230
- the atomic approval command returned by `workflow.current`.
231
- - Package output is chosen after approved knowledge exists; package templates
232
- are project configuration, not a second factual source.
111
+ ## Workspace state
233
112
 
234
- CLI-returned source names, phase IDs, candidate IDs, diagnostics, and
235
- `source_ref` values are workflow tokens. A `source_ref` is an opaque evidence
236
- citation: copy it exactly and do not parse it as a filesystem path.
237
-
238
- ## Further Reading
113
+ ```text
114
+ context/
115
+ ├── src/ # declarative project and package templates
116
+ ├── sources/ # source registry and captured evidence
117
+ ├── knowledge/ # approved Markdown and durable decisions
118
+ ├── dist/ # built packages
119
+ └── .tmp/context-runtime/
120
+ ├── lifecycle/ # open-round candidates and structure
121
+ ├── debug/ # optional traces
122
+ └── logs/ # optional runtime-event outbox
123
+ ```
239
124
 
240
- - [CLI Quickstart](./docs/quickstart.md)
125
+ These directories have different durability contracts. `sources/` and
126
+ `knowledge/` are project state; `dist/` is reproducible output; lifecycle and
127
+ debug directories are ignored runtime state. A successful close removes the
128
+ completed lifecycle staging area. Do not repair a workflow by manually editing
129
+ or deleting CLI-owned state—use the recovery action returned by the current
130
+ Route.
131
+
132
+ ## Evidence and safety boundaries
133
+
134
+ - Source registration does not grant permission to read source bodies.
135
+ - The runtime does not silently clone, checkout, reset, fetch, install, build,
136
+ test, or run scripts in a source repository.
137
+ - Markdown parsing preserves structural evidence but does not infer product
138
+ meaning or choose a knowledge collection.
139
+ - Code extraction emits structural facts; the Agent and user decide their
140
+ knowledge meaning and scope.
141
+ - `source_ref` values are opaque, verified evidence identities. Copy them
142
+ exactly rather than treating them as filesystem paths.
143
+ - Review decisions become approved Markdown only through atomic review apply;
144
+ Agents do not hand-write lifecycle output.
145
+ - Package templates shape distribution but never replace approved knowledge as
146
+ the source of truth.
147
+
148
+ ## Package output
149
+
150
+ Declared packages are built under `dist/<package-name>/`. Agent knowledge
151
+ packages may contain `wikis/`, `guides/`, `rules/`, `feats/`, Skills, indexes,
152
+ and package-specific retrieval helpers. LLM packages consolidate selected
153
+ knowledge into a text artifact.
154
+
155
+ Each build inventory maps the distributed paths back to approved workspace
156
+ knowledge. Asset delivery can use repository raw URLs, an explicit URL prefix,
157
+ or bundled assets; the project chooses the policy before build.
158
+
159
+ See [Package Outputs](../context/docs/guides/package-outputs.md) and
160
+ [Package Templates](../context/docs/reference/package-templates.md).
161
+
162
+ ## Diagnostics and direct CLI use
163
+
164
+ Normal users should follow the Agent entry. Direct commands remain available
165
+ for maintainers, automation, and diagnostics:
166
+
167
+ - `context status --format json` inspects the current Route;
168
+ - `context <command> --help` is the authority for current flags;
169
+ - `context plugin status` checks installed Agent projections;
170
+ - `context debug enable` records optional traces below
171
+ `.tmp/context-runtime/debug/`;
172
+ - `context clean-cache --dry-run` previews cleanup of Context-owned stale
173
+ plugin caches.
174
+
175
+ Revision-bound commands should be copied from `workflow.current`; examples in
176
+ documentation are orientation, not a substitute for the current Route. See the
177
+ [installed quickstart](./docs/quickstart.md) and
178
+ [debug tracing guide](./docs/debug-tracing.md).
179
+
180
+ ## Documentation and development
181
+
182
+ - [Plugin contract](./plugin/README.md)
183
+ - [Workflow Provider internals](./context-workflow/README.md)
241
184
  - [SDK documentation index](../context/docs/README.md)
242
- - [Getting Started](../context/docs/getting-started.md)
185
+ - [Knowledge-project walkthrough](../context/docs/getting-started.md)
243
186
  - [Agent Guide](../context/docs/guides/agent-guide.md)
244
- - [Agent Dialogue](../context/docs/guides/agent-dialogue.md)
245
- - [Lark Resource Materialization](../context/docs/guides/lark-resources.md)
246
187
  - [Project API](../context/docs/reference/project-api.md)
247
- - [Package Templates](../context/docs/reference/package-templates.md)
248
-
249
- ## Development
250
188
 
251
- For the complete source, link, plugin, and npm-mode workflow, see
189
+ For source, link, packaged-install, and release workflows, see
252
190
  [`DEVELOPMENT.md`](../../DEVELOPMENT.md) and this package's
253
191
  [`DEVELOPMENT.md`](./DEVELOPMENT.md).
254
192
 
255
193
  ```bash
256
- ./start.sh link
257
194
  bun run --filter @c4a/context-cli build
258
195
  bun run --filter @c4a/context-cli typecheck
259
196
  bun run --filter @c4a/context-cli lint
260
197
  bun run --filter @c4a/context-cli test
261
198
  ```
262
199
 
263
- Build writes the installable Claude, Codex, Cursor, and skill-only trees to
264
- `dist/plugins`. `context plugin install` installs from that package-bundled
265
- output. Do not edit generated plugin trees directly.
200
+ Build generates the installable host projections under `dist/plugins`; edit
201
+ only `plugin/` and the bundled workflow source, never generated output.
266
202
 
267
203
  ## License
268
204