@c4a/context-cli 0.6.2 → 0.6.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 (50) hide show
  1. package/README.md +51 -3
  2. package/README.zh-CN.md +43 -3
  3. package/cli.js +32849 -28177
  4. package/docs/context-debug-event-v1.schema.json +31 -0
  5. package/docs/context-debug-replay-v1.schema.json +33 -0
  6. package/docs/debug-tracing.md +94 -0
  7. package/docs/quickstart.md +1 -1
  8. package/package.json +6 -3
  9. package/plugins/VERSION +1 -1
  10. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  11. package/plugins/claude/commands/continue.md +19 -14
  12. package/plugins/claude/commands/init.md +3 -1
  13. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  14. package/plugins/codex/skills/continue/SKILL.md +19 -14
  15. package/plugins/codex/skills/init/SKILL.md +2 -0
  16. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  17. package/plugins/cursor/commands/context-continue.md +19 -14
  18. package/plugins/cursor/commands/context-init.md +3 -1
  19. package/plugins/skills/context-continue/SKILL.md +19 -14
  20. package/plugins/skills/context-init/SKILL.md +2 -0
  21. package/providers/context/actions/inspect-code-extraction.yaml +5 -0
  22. package/providers/context/actions/inspect-repository-recovery.yaml +6 -0
  23. package/providers/context/actions/reconcile-review-identities.yaml +5 -0
  24. package/providers/context/actions/repair-verification.yaml +3 -3
  25. package/providers/context/actions/restore-repository-sources.yaml +7 -0
  26. package/providers/context/codes.yaml +2 -1
  27. package/providers/context/graphs/workspace.yaml +51 -8
  28. package/providers/context/manifest.json +126 -45
  29. package/providers/context/provider.yaml +1 -1
  30. package/providers/context/resources/dialogue/code-extraction.md +11 -0
  31. package/providers/context/resources/dialogue/package-output.md +9 -0
  32. package/providers/context/resources/dialogue/repository-source-recovery.md +23 -0
  33. package/providers/context/resources/manuals/guides/lark-resources.md +121 -0
  34. package/providers/context/resources/manuals/guides/package-outputs.md +22 -0
  35. package/providers/context/resources/manuals/reference/code-extractors.md +94 -0
  36. package/providers/context/resources/manuals/reference/package-templates.md +52 -0
  37. package/providers/context/resources/manuals/reference/project-api.md +78 -7
  38. package/providers/context/resources/procedures/close-and-build.md +5 -3
  39. package/providers/context/resources/procedures/code-extraction.md +23 -0
  40. package/providers/context/resources/procedures/document-capture.md +5 -1
  41. package/providers/context/resources/procedures/knowledge-review.md +10 -0
  42. package/providers/context/resources/procedures/package-output.md +21 -0
  43. package/providers/context/resources/procedures/repository-source-recovery.md +43 -0
  44. package/providers/context/resources/procedures/source-capture-detailed.md +13 -0
  45. package/providers/context/resources/procedures/verify-and-repair.md +12 -0
  46. package/providers/context/resources/semantic/align/gates.md +2 -2
  47. package/providers/context/resources/semantic/align/structure-planning.md +8 -3
  48. package/providers/context/resources/views/source-boundary.yaml +6 -0
  49. package/providers/context/schemas/repository-source-recovery.schema.json +40 -0
  50. package/providers/context/actions/ensure-repository-sources.yaml +0 -5
package/README.md CHANGED
@@ -37,6 +37,11 @@ The public Agent entries are:
37
37
  For the shortest installed-package walkthrough, read
38
38
  [CLI Quickstart](./docs/quickstart.md).
39
39
 
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
+
40
45
  ## CLI And Agent Responsibilities
41
46
 
42
47
  | Responsibility | Owner |
@@ -83,7 +88,8 @@ The workspace state is split across:
83
88
  confirmed structure snapshots during an open lifecycle round.
84
89
  - `knowledge/` for approved Markdown, the closed `structure.yaml` projection,
85
90
  and the minimal `decisions.json` rejected-candidate fingerprint map when one
86
- exists.
91
+ exists. Resources referenced by approved pages live in content-addressed
92
+ `knowledge/assets/` paths.
87
93
  - `dist/` for generated package output.
88
94
  - `.tmp/context-runtime/` for other ignored logs, previews, reports, locks, and caches.
89
95
 
@@ -106,6 +112,14 @@ KB packages use flat, package-relative OKF roots: `wikis/`, `guides/`,
106
112
  `dist/<package-name>/` directory and is not repeated inside those roots. Older
107
113
  workspaces that still declare `distribution.knowledgeNamespace` remain
108
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.
109
123
 
110
124
  See the SDK manuals for the complete configuration and template contract:
111
125
 
@@ -133,6 +147,21 @@ implementation detail; Context users and plugins consume only
133
147
  Building a package completes the currently active approved state; it does not
134
148
  freeze the workspace. New sources can be added and processed later.
135
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
+
136
165
  ## Command Groups
137
166
 
138
167
  ```bash
@@ -140,9 +169,14 @@ freeze the workspace. New sources can be added and processed later.
140
169
  context plugin install
141
170
  context plugin status
142
171
 
143
- # Workspace state
172
+ # Workspace creation and state
144
173
  context init [project-dir]
145
174
  context status
175
+ context run --managed --until blocked-or-complete --format json
176
+
177
+ # Route-selected resources
178
+ context resource materialize --help
179
+ context resource acknowledge-current --help
146
180
 
147
181
  # Sources
148
182
  context source add repo [YYYYMMDD] --module <module> --local <repo-or-subdir>
@@ -161,15 +195,28 @@ context run <phase-id>
161
195
  context review html [collection] --open
162
196
  context review apply <payload-file>
163
197
 
198
+ # Package template decisions
199
+ context package template accept --help
200
+
164
201
  # Final quality and output
165
202
  context close
166
203
  context verify
167
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
168
213
  ```
169
214
 
170
215
  Run `context <command> --help` for current flags. Commands that require a
171
216
  workspace search upward for a `package.json` with `context.project=true` and a
172
- configured `context.entry`.
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.
173
220
 
174
221
  ## Human Gates And Evidence
175
222
 
@@ -195,6 +242,7 @@ citation: copy it exactly and do not parse it as a filesystem path.
195
242
  - [Getting Started](../context/docs/getting-started.md)
196
243
  - [Agent Guide](../context/docs/guides/agent-guide.md)
197
244
  - [Agent Dialogue](../context/docs/guides/agent-dialogue.md)
245
+ - [Lark Resource Materialization](../context/docs/guides/lark-resources.md)
198
246
  - [Project API](../context/docs/reference/project-api.md)
199
247
  - [Package Templates](../context/docs/reference/package-templates.md)
200
248
 
package/README.zh-CN.md CHANGED
@@ -26,6 +26,11 @@ context plugin install
26
26
 
27
27
  最简安装后流程参见 [CLI 快速开始](./docs/quickstart.md)。
28
28
 
29
+ 工作区调试追踪默认关闭。仅在需要观察命令调用与 Agent Graph 路由时,使用
30
+ `context init context --debug` 或 `context debug enable` 开启;日志只写入已忽略的
31
+ `.tmp/context-runtime/debug/`。协议与回放说明见
32
+ [工作区调试追踪](./docs/debug-tracing.md)。
33
+
29
34
  ## CLI、Agent 和用户的分工
30
35
 
31
36
  | 职责 | 负责方 |
@@ -62,7 +67,7 @@ node_modules/@c4a/context/docs/reference/package-templates.md
62
67
  - `src/`:项目声明和知识包模板。
63
68
  - `sources/`:来源登记和已经读取的证据。
64
69
  - `.tmp/context-runtime/lifecycle/`:一个开放生命周期轮次中的、被忽略且仅由 CLI 管理的草稿候选和已确认结构快照。
65
- - `knowledge/`:已批准的 Markdown、close 后的 `structure.yaml` 结构投影,以及存在时用于记录被拒候选 fingerprint 的精简 `decisions.json`。
70
+ - `knowledge/`:已批准的 Markdown、close 后的 `structure.yaml` 结构投影,以及存在时用于记录被拒候选 fingerprint 的精简 `decisions.json`。已批准页面引用的资源位于内容寻址的 `knowledge/assets/`。
66
71
  - `dist/`:构建生成的知识包。
67
72
  - `.tmp/context-runtime/`:其他被忽略的日志、预览、报告、锁和缓存。
68
73
 
@@ -76,6 +81,11 @@ node_modules/@c4a/context/docs/reference/package-templates.md
76
81
  `wikis/`、`guides/`、`rules/` 和 `feats/` 作为包内 OKF 根目录,不再在这些目录下重复包名。
77
82
  旧工作区即使仍声明 `distribution.knowledgeNamespace` 也可以继续加载,但该兼容字段不再改变
78
83
  知识包输出路径。
84
+ 新建 KB 时优先选择 Git raw 资源分发:构建器将链接改写到仓库 raw 地址;资源的
85
+ 提交和发布由知识包作者负责。非 Git 工作区可以配置另一个资源仓库的显式 Raw
86
+ 前缀;没有可用 Git 或显式前缀时,可以选择随包复制到 `others/assets/`,或显式
87
+ 不输出资源并保留失效引用。随包模式可以安装 `sharp` 并通过
88
+ `kbPackage().assets.optimize` 仅优化生成文件;Context 本身不依赖图片处理器。
79
89
 
80
90
  完整配置和模板约定参见 SDK 手册:
81
91
 
@@ -99,6 +109,16 @@ node_modules/@c4a/context/docs/reference/package-templates.md
99
109
 
100
110
  一次构建只完成当前已经确认的知识状态,并不会冻结工作区。后续还可以继续添加和处理新的来源。
101
111
 
112
+ 当前对话明确授予全托管权限后,
113
+ `context run --managed --until blocked-or-complete` 会在同一个工作区运行时中连续执行
114
+ 确定性动作。每个动作仍绑定到选择它的 Route revision;动作完成后,Context 会重新从磁盘
115
+ 加载项目并再次求值工作图。已知的本地动作在同一进程中执行,来源工具和其他外部副作用仍
116
+ 隔离在子进程中。
117
+
118
+ 执行作用域只管理输出捕获、定时器、子进程和写锁等短生命周期资源,并按注册顺序的逆序释放。
119
+ 知识、快照、审核决定和知识包产物属于持久状态,继续使用原有的 revision 校验、项目写锁、
120
+ 原子写入、close 和 verify 契约。执行作用域不会回滚或替代这些契约,工作区文件协议也不改变。
121
+
102
122
  ## 命令分组
103
123
 
104
124
  ```bash
@@ -106,9 +126,14 @@ node_modules/@c4a/context/docs/reference/package-templates.md
106
126
  context plugin install
107
127
  context plugin status
108
128
 
109
- # 工作区状态
129
+ # 工作区创建与状态
110
130
  context init [project-dir]
111
131
  context status
132
+ context run --managed --until blocked-or-complete --format json
133
+
134
+ # 当前路由选择的资源
135
+ context resource materialize --help
136
+ context resource acknowledge-current --help
112
137
 
113
138
  # 知识来源
114
139
  context source add repo [YYYYMMDD] --module <module> --local <repo-or-subdir>
@@ -127,13 +152,27 @@ context run <phase-id>
127
152
  context review html [collection] --open
128
153
  context review apply <payload-file>
129
154
 
155
+ # 知识包模板决策
156
+ context package template accept --help
157
+
130
158
  # 最终质量与输出
131
159
  context close
132
160
  context verify
133
161
  context build
162
+
163
+ # 可选的工作区调试追踪
164
+ context debug enable
165
+ context debug status
166
+ context debug export
167
+
168
+ # 开发与缓存维护
169
+ context clean-cache --dry-run
134
170
  ```
135
171
 
136
- 当前参数以 `context <command> --help` 为准。需要工作区的命令会向上查找带有 `context.project=true` 和 `context.entry` 配置的 `package.json`。
172
+ 当前参数以 `context <command> --help` 为准。需要工作区的命令会向上查找带有
173
+ `context.project=true` 和 `context.entry` 配置的 `package.json`。带 revision
174
+ 约束的资源和知识包命令通常应直接复制 `workflow.current` 返回的命令;上面的例子只用于
175
+ 发现命令入口,不能替代当前路由。
137
176
 
138
177
  ## 人工门禁与证据
139
178
 
@@ -152,6 +191,7 @@ CLI 返回的来源名称、阶段 ID、候选 ID、诊断和 `source_ref` 都
152
191
  - [快速开始](../context/docs/getting-started.md)
153
192
  - [Agent 指南](../context/docs/guides/agent-guide.md)
154
193
  - [Agent 对话指南](../context/docs/guides/agent-dialogue.md)
194
+ - [飞书资源物化](../context/docs/guides/lark-resources.md)
155
195
  - [项目 API](../context/docs/reference/project-api.md)
156
196
  - [知识包模板](../context/docs/reference/package-templates.md)
157
197