@c4a/context 0.6.1 → 0.6.3

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.
package/README.md CHANGED
@@ -44,8 +44,9 @@ export default defineProject({
44
44
 
45
45
  `src/index.ts` is similar to a Webpack configuration for knowledge. It defines
46
46
  what enters the project, which transformations and gates run, and what is built
47
- at the end. The installed Agent plugin includes the skills and SDK manuals
48
- needed to maintain this configuration from a user's requirements.
47
+ at the end. The installed Agent plugin provides thin entries; the current
48
+ workflow route selects the procedures and manuals needed to maintain this
49
+ configuration from a user's requirements.
49
50
 
50
51
  ## Public Surface
51
52
 
@@ -54,15 +55,17 @@ needed to maintain this configuration from a user's requirements.
54
55
  | `defineProject()` | Declares the complete project graph. |
55
56
  | `source()` and `allSources()` | References registered repo, file, or Lark source boundaries. |
56
57
  | `extractTs()` | Extracts TypeScript/TSX symbols and relationships into `codegraph` candidates. |
58
+ | `extractCustom()` | Runs a project-owned code extractor while Context owns candidate, evidence, freshness, and Review state. |
57
59
  | `alignProse()` and `compileProse()` | Structures document evidence and compiles source-bound knowledge candidates. |
58
60
  | `reviewValidity()` | Declares the review gate for one collection or the project. |
59
61
  | `customPhase()` | Adds project-specific orchestration when built-in phase factories are not enough. |
60
62
  | `kbPackage()` | Builds an Agent knowledge-base package from approved knowledge and templates. |
61
63
  | `llmsPackage()` | Builds a single text bundle for model context or RAG import. |
62
64
 
63
- Use the built-in phase factories first. `customPhase()` is an escape hatch for
64
- project-specific orchestration, not a replacement for source, extraction,
65
- review, and package lifecycle rules.
65
+ Use `extractCustom()` when a repository needs a non-TypeScript or aggregated
66
+ code extractor. Use `customPhase()` only for orchestration that does not publish
67
+ knowledge candidates; it is not a replacement for source, extraction, Review,
68
+ and package lifecycle rules.
66
69
 
67
70
  ## Knowledge Collections
68
71
 
@@ -116,18 +119,33 @@ include `{{packageName}}`, `{{displayName}}`, `{{knowledgeCount}}`,
116
119
  `{{knowledgeGroups}}`, `{{knowledgeItems}}`, `{{knowledgeTree}}`, and
117
120
  `{{buildInventory}}`.
118
121
 
122
+ Every KB package emits flat roots such as `wikis/`, `guides/`, `rules/`, and
123
+ `feats/`. The package `name` defines only the `dist/<package-name>/` boundary;
124
+ it is not repeated inside knowledge paths. Context still accepts
125
+ `distribution.knowledgeNamespace` from older workspaces, but the legacy value
126
+ no longer changes build output and new declarations do not need it. Skill names
127
+ remain author-maintained and independent.
128
+
119
129
  For advanced routing and retrieval, a template may carry a local script such as
120
130
  `query.ts`, with a Skill describing when and how an Agent should call it. The
121
131
  Skill can also route the Agent to MCP servers, CLI commands, or other tools to
122
132
  form a package-specific Agentic Search workflow.
123
133
 
134
+ Long-lived, multi-source production workspaces can copy
135
+ `templates/project-skills/maintain-project-knowledge/SKILL.md` into their
136
+ `.agents/skills/` directory and customize it with project ownership, source
137
+ impact mappings, and readiness criteria. This project adapter is not included
138
+ in knowledge packages; lifecycle authority remains with the installed Context
139
+ Skill and current Route.
140
+
124
141
  ## State Boundary
125
142
 
126
143
  The SDK stays declarative. It may describe reads, writes, phases, review, and
127
144
  package selection, but the CLI owns source materialization, capture, extraction,
128
145
  review application, approved Markdown materialization, verification, and build.
129
146
  Do not replace CLI lifecycle operations with direct edits to `sources/`,
130
- `unapproved/`, `knowledge/`, or `dist/`.
147
+ `knowledge/`, `dist/`, or the ignored `.tmp/context-runtime/lifecycle/` runtime
148
+ state. The CLI owns that runtime state and removes it after a successful close.
131
149
 
132
150
  ## Documentation
133
151
 
@@ -136,5 +154,6 @@ Do not replace CLI lifecycle operations with direct edits to `sources/`,
136
154
  - [Agent Guide](./docs/guides/agent-guide.md)
137
155
  - [Project API](./docs/reference/project-api.md)
138
156
  - [Package Outputs](./docs/guides/package-outputs.md)
157
+ - [Lark Resource Materialization](./docs/guides/lark-resources.md)
139
158
  - [Package Templates](./docs/reference/package-templates.md)
140
159
  - [Template Variables](./docs/reference/template-variables.md)
@@ -0,0 +1,128 @@
1
+ # Context SDK
2
+
3
+ [English](./README.md)
4
+
5
+ `@c4a/context` 是 Context workspace 使用的声明式 SDK。它为 `src/index.ts` 提供类型化 API,用来描述知识来源、处理阶段、审核门禁和知识包输出。SDK 本身不写入工作区,也不执行流程;这些操作由 [Context CLI](../context-cli/README.zh-CN.md) 负责。
6
+
7
+ ## 项目模型
8
+
9
+ Context 项目使用“来源 → 阶段 → 知识包”的声明模型:
10
+
11
+ ```ts
12
+ import {
13
+ defineProject,
14
+ extractTs,
15
+ kbPackage,
16
+ reviewValidity,
17
+ source,
18
+ } from "@c4a/context";
19
+
20
+ const sampleLib = source("20260712", "sample-lib");
21
+
22
+ export default defineProject({
23
+ sources: [sampleLib],
24
+ phases: [
25
+ extractTs({ source: sampleLib, collection: "codegraph" }),
26
+ reviewValidity({ collection: "codegraph" }),
27
+ ],
28
+ packages: [
29
+ kbPackage({
30
+ name: "sample-lib-kb",
31
+ template: {
32
+ path: "src/package-templates/kb",
33
+ vars: { displayName: "Sample Library KB" },
34
+ },
35
+ select: { collections: ["codegraph"], okfRoots: ["wikis"] },
36
+ }),
37
+ ],
38
+ });
39
+ ```
40
+
41
+ `src/index.ts` 有点像知识项目的 Webpack 配置:它定义哪些内容进入项目、经过哪些转换和门禁,以及最终构建什么产物。安装好的 Agent 插件只提供薄入口,当前工作流路由会按需选择维护这份配置所需的流程资源和 SDK 文档。
42
+
43
+ ## 主要 API
44
+
45
+ | API | 用途 |
46
+ |---|---|
47
+ | `defineProject()` | 声明完整的项目处理图。 |
48
+ | `source()` 和 `allSources()` | 引用已经登记的代码仓库、本地文件或飞书来源边界。 |
49
+ | `extractTs()` | 从 TypeScript/TSX 中提取符号和关系,生成 `codegraph` 候选。 |
50
+ | `extractCustom()` | 运行项目自有代码提取器,同时由 Context 维护候选、证据、新鲜度和审核状态。 |
51
+ | `alignProse()` 和 `compileProse()` | 整理文档证据,并生成与来源绑定的知识候选。 |
52
+ | `reviewValidity()` | 声明单个知识类型或整个项目的审核门禁。 |
53
+ | `customPhase()` | 在内置阶段无法覆盖时增加项目专用编排。 |
54
+ | `kbPackage()` | 使用审核通过的知识和模板构建 Agent 知识库。 |
55
+ | `llmsPackage()` | 构建供模型上下文或 RAG 导入使用的单文件文本包。 |
56
+
57
+ 非 TypeScript 或需要聚合代码事实时使用 `extractCustom()`。`customPhase()`
58
+ 只用于不发布知识候选的项目专用编排,不能绕开来源、提取、审核和打包生命周期。
59
+
60
+ ## 知识分类
61
+
62
+ 审核通过的 Markdown 会存放在 `knowledge/<collection>/`:
63
+
64
+ | 知识类型 | 主要内容 | 常见来源 |
65
+ |---|---|---|
66
+ | `codegraph` | 代码符号、模块和调用关系 | 代码仓库 |
67
+ | `business` | 业务概念、角色和业务关系 | 业务文档、飞书文档 |
68
+ | `product` | 产品能力、功能行为和产品关系 | 产品文档、需求文档 |
69
+ | `architecture` | 系统结构、模块职责和设计说明 | 架构文档、设计文档 |
70
+ | `sop` | 操作流程、运行手册和处理步骤 | 操作手册、值班文档 |
71
+ | `faq` | 常见问题、解释和排障方法 | FAQ、支持文档、经验记录 |
72
+ | `decision` | 方案选择、取舍和决策背景 | 设计评审、决策记录 |
73
+ | `incident` | 故障过程、处置方式和后续行动 | 故障复盘、事故报告 |
74
+ | `standards` | 必须遵守的规范和约束 | 研发规范、业务规则 |
75
+ | `test` | 验证规则、测试场景和验收标准 | 测试文档、验收说明 |
76
+ | `feats` | 面向具体场景整理的能力记录 | 项目自定义处理和已确认知识 |
77
+
78
+ 知识类型是语义分类,不是最终知识包目录。构建时会把选中的类型映射到 `wikis/`、`guides/`、`rules/`、`feats/` 等 OKF 目录。同一份来源可能贡献多种知识,分类应该依据证据和用户确认,而不是文件名。
79
+
80
+ ## 知识包模板
81
+
82
+ 知识包声明会引用 `src/package-templates/` 下的可编辑模板。安装后的示例位于:
83
+
84
+ ```text
85
+ node_modules/@c4a/context/templates/package-templates/
86
+ ```
87
+
88
+ 默认 KB 模板包含:
89
+
90
+ ```text
91
+ kb/
92
+ |-- AGENTS.md
93
+ |-- skills/
94
+ | `-- knowledge-query/SKILL.md
95
+ `-- wikis/index.md
96
+ ```
97
+
98
+ `knowledge-query` Skill 会告诉消费知识包的 Agent 如何浏览索引、读取审核通过的知识并引用证据。项目还可以增加更多 Skills,或者在 `wikis/`、`guides/`、`rules/` 等目录中加入模板文件。
99
+
100
+ 模板使用 Handlebars 变量,可以作用于文件内容和路径。常用变量包括 `{{packageName}}`、`{{displayName}}`、`{{knowledgeCount}}`、`{{knowledgeGroups}}`、`{{knowledgeItems}}`、`{{knowledgeTree}}` 和 `{{buildInventory}}`。
101
+
102
+ 每个 KB 包直接输出扁平的 `wikis/`、`guides/`、`rules/`、`feats/` 等根目录;包 `name`
103
+ 只用于确定 `dist/<package-name>/` 边界,不会再次写入知识路径。旧工作区中的
104
+ `distribution.knowledgeNamespace` 仍可被读取,但不再改变构建结果;新声明无需配置它。
105
+ Skill 名称继续由作者独立维护。
106
+
107
+ 如果需要更强的路由和检索能力,模板可以携带 `query.ts` 一类本地脚本,再由 Skill 约定 Agent 何时、如何调用。Skill 也可以把 Agent 路由到 MCP、CLI 或其他工具,组成适合当前知识包的 Agentic Search 流程。
108
+
109
+ 长期维护、多来源的知识生产工作区可以从
110
+ `templates/project-skills.zh-CN/maintain-project-knowledge/SKILL.md` 复制一份
111
+ 项目维护 Skill 到 `.agents/skills/`。它不进入知识包,而是补充项目专属的来源
112
+ 归属、仓库变化影响范围和准出标准;Context 生命周期仍由已安装的 Context Skill
113
+ 和当前 Route 负责。
114
+
115
+ ## 状态边界
116
+
117
+ SDK 只负责声明。它可以描述读取、写入、阶段、审核和知识包选择,但来源物化、内容读取、代码提取、审核应用、正式知识写入、质量验证和构建都由 CLI 负责。不要通过直接编辑 `sources/`、`knowledge/`、`dist/` 或被忽略的 `.tmp/context-runtime/lifecycle/` 运行态来替代 CLI 生命周期操作;成功 close 后 CLI 会清理该运行态。
118
+
119
+ ## 参考文档
120
+
121
+ - [文档索引](./docs/README.md)
122
+ - [快速开始](./docs/getting-started.md)
123
+ - [Agent 指南](./docs/guides/agent-guide.md)
124
+ - [项目 API](./docs/reference/project-api.md)
125
+ - [知识包输出](./docs/guides/package-outputs.md)
126
+ - [飞书资源物化](./docs/guides/lark-resources.md)
127
+ - [知识包模板](./docs/reference/package-templates.md)
128
+ - [模板变量](./docs/reference/template-variables.md)
package/contracts.d.ts CHANGED
@@ -19,6 +19,11 @@ export type PackageSelectDefinition = {
19
19
  include?: readonly string[];
20
20
  exclude?: readonly string[];
21
21
  };
22
+ export type PackageNavigationDefinition = {
23
+ foldDirectoryIndexes: boolean;
24
+ maxInlineEntries: number;
25
+ };
26
+ export declare const DEFAULT_PACKAGE_NAVIGATION: Readonly<PackageNavigationDefinition>;
22
27
  export declare const DOC_MAINLINE_COLLECTIONS: readonly DocumentMainlineCollection[];
23
28
  export declare const MAINLINE_COLLECTIONS: readonly MainlineCollection[];
24
29
  export declare const TOP_LEVEL_NAMESPACES: readonly TopLevelNamespace[];
package/docs/README.md CHANGED
@@ -6,24 +6,28 @@ These docs ship inside the installed SDK package at:
6
6
  node_modules/@c4a/context/docs/
7
7
  ```
8
8
 
9
- Agents should read these files before editing a Context workspace, especially
10
- before changing `src/index.ts` or package templates.
9
+ For lifecycle work, Agents should first consume the resources selected by
10
+ `context status --format json` `workflow.current`. Read these SDK manuals when
11
+ the selected route requires project configuration, package templates, or
12
+ general reference; do not preload the whole manual set.
11
13
 
12
14
  ## Read First
13
15
 
14
16
  - [Getting Started](./getting-started.md) — end-to-end component-library flow.
15
17
  - [Agent Guide](./guides/agent-guide.md) — what an agent should do, and what it should not inspect manually.
16
- - [Agent Dialogue](./guides/agent-dialogue.md) — how agents should explain human gates without exposing internal API details first.
18
+ - [Agent Dialogue](./guides/agent-dialogue.md) — stable dialogue principles and how route-selected gate resources are discovered.
17
19
  - [Package Outputs](./guides/package-outputs.md) — how to choose between an agent knowledge-base package, LLM text, or no package output.
20
+ - [Lark Resource Materialization](./guides/lark-resources.md) — how embedded resources move from source evidence to approved knowledge and package assets.
18
21
  - [Project API](./reference/project-api.md) — `defineProject`, sources, phases, review, and packages.
19
22
  - [Package Templates](./reference/package-templates.md) — `kbPackage`, `llmsPackage`, template variables, and examples.
20
23
  - [Template Variables](./reference/template-variables.md) — Handlebars variables, loops, comments, and default knowledge inventories.
21
24
 
22
- Approved Markdown and kb package OKF output follow the C4A OKF Profile:
23
- OKF fields and C4A extension fields live at the top level. Do not nest
24
- `sources`, `visibility`, or `code_symbols` under `context`, and do not add
25
- frontmatter `source_refs`. Section provenance lives in `context:section`
26
- source_ref span comments. The kb package root may contain agent files; the
25
+ Approved Markdown follows the complete Context production profile. Package
26
+ knowledge pages use a smaller consumer projection containing only reader-facing
27
+ metadata and content. Node identity, provenance, section evidence, review
28
+ fingerprints, symbol lists, generated-child records, and relationships remain in
29
+ the production workspace or `context-build-inventory.json`. The inventory maps
30
+ each distributed path back to its approved knowledge path. The kb package root may contain agent files; the
27
31
  OKF-compatible surface is its selected `wikis/`, `guides/`, `rules/`, and
28
32
  `feats/` subtrees.
29
33
 
@@ -37,3 +41,15 @@ node_modules/@c4a/context/templates/package-templates/
37
41
 
38
42
  Copy or mirror these into a workspace under `src/package-templates/` when the
39
43
  project needs package outputs.
44
+
45
+ Long-lived multi-source production workspaces may also start from the optional
46
+ project-maintenance Skill template at:
47
+
48
+ ```text
49
+ node_modules/@c4a/context/templates/project-skills/maintain-project-knowledge/SKILL.md
50
+ ```
51
+
52
+ Copy it into the project's `.agents/skills/`, rename it for the project, and
53
+ replace its project-fact and impact-map sections. It is a project adapter; it is
54
+ not included in a built knowledge package and does not replace the installed
55
+ Context Skill.
@@ -7,17 +7,32 @@ source boundary, then declare the matching phases in `src/index.ts`.
7
7
  ## 1. Initialize
8
8
 
9
9
  ```bash
10
- context init context --dev
10
+ context init context
11
11
  cd context
12
12
  bun install
13
- context status
13
+ context status --format json
14
14
  ```
15
15
 
16
- Use `--dev` when testing a local link or prepared pack before the matching SDK
17
- version is published. It writes a `file:` dependency to the SDK resolved beside
18
- the active CLI. Published users can omit it and install the versioned SDK from
19
- the registry.
20
- When operating through an Agent plugin, use the installed Context continuation entry from the project root after initialization; it reads `context status` and then calls the lower-level CLI primitives as needed. The exact slash command or skill name is host-specific.
16
+ Use `--language zh-CN` (or `--language en`) during initialization when the
17
+ generated README, AGENTS contract, and package starter templates should use a
18
+ specific language. Context stores this choice in `package.json`; it does not
19
+ guess from the shell locale or Agent conversation.
20
+
21
+ Use `--dev` only when testing a locally linked CLI or a prepared package before
22
+ the matching SDK version is published. It writes a `file:` dependency to the SDK
23
+ resolved beside the active CLI. Registry installs should use the default command
24
+ above so the workspace receives the matching versioned SDK dependency.
25
+
26
+ Without `project-dir`, init uses the dedicated `context/` directory. Initializing
27
+ inside a non-empty directory that is not already a Context workspace is blocked
28
+ before any files are written; use the returned `--allow-nonempty` command only
29
+ after confirming that the existing files should share the workspace root.
30
+
31
+ When operating through an Agent plugin, use the installed Context continuation
32
+ entry from the project root after initialization. It consumes
33
+ `workflow.current`, loads only the selected resources, and calls lower-level
34
+ CLI primitives as needed. The exact slash command or skill name is
35
+ host-specific.
21
36
 
22
37
  ## 2. Choose And Register A Source Boundary
23
38
 
@@ -30,7 +45,8 @@ suffixes from prose or content. ViewRef/NodeRef are identity fields, not path
30
45
  strings:
31
46
 
32
47
  ```text
33
- knowledge/<collection>/<containment>/<slug>.md
48
+ knowledge/<collection>/<slug>.md
49
+ knowledge/<collection>/<containment>/<slug>.md # intentional hierarchy only
34
50
  repo:<date>/<module>#symbol:...
35
51
  file:<source-name>/<document>#span:...
36
52
  lark:<source-name>/<document>#span:...
@@ -98,21 +114,27 @@ module first. An explicit request to capture/read those exact paths or URLs is
98
114
  the read confirmation for that requested batch; do not ask again after
99
115
  registration. Merely mentioning a possible source is not permission.
100
116
  `context status --format json` returns all remaining capture phases in
101
- `routing.command_plan`. Every item is marked `after-human-confirmation`, so one
102
- explicit confirmation can authorize the complete requested batch without
103
- pausing for another date name or collection choice between modules. If any
104
- module lacks a declaration, status returns `needs-capture-phase` and a precise
105
- `routing.configuration` action instead of an unexecutable command.
106
-
107
- After capture, status returns `captured-ready-to-classify` for document modules
108
- without an align declaration. Run the returned collection-neutral evidence
109
- views first; only then propose a mainline collection and ask for confirmation.
110
- The batch read permission does not itself choose a collection.
117
+ `workflow.current.commands`. Every item requiring the confirmed read scope is
118
+ marked `after-human-confirmation`, so one explicit confirmation can authorize
119
+ the complete requested batch without pausing for another date name or
120
+ collection choice between modules. If any module lacks a declaration,
121
+ `workflow.current.configuration` identifies the precise project change instead
122
+ of returning an unexecutable command. Read every
123
+ `workflow.current.resources.required` item before acting; long procedures and
124
+ semantic rules remain available as files and are loaded only for the route that
125
+ needs them.
126
+
127
+ After capture, status selects `route.document.classification-required` for
128
+ document modules without an align declaration. Run the Gate's returned
129
+ collection-neutral inspection commands first; only then propose a mainline
130
+ collection and ask for confirmation. Batch read permission does not choose a
131
+ collection.
111
132
 
112
133
  When the workspace also contains repo sources, Context prioritizes untouched
113
- code after all document captures finish: status returns `ready-to-extract`
114
- until the code extraction round is current, then returns to document
115
- investigation. An existing document structure/compile gate is never interrupted.
134
+ code after all document captures finish: the current reason is
135
+ `route.extract.pending-target` until the code extraction round is current,
136
+ then routing returns to document investigation. An existing document
137
+ structure/compile gate is never interrupted.
116
138
 
117
139
  For a single component package, use the package directory as the repo source
118
140
  boundary:
@@ -165,16 +187,27 @@ and suggested `context source add` commands.
165
187
 
166
188
  Remote Git sources need the same boundary decision. Ask for the remote URL, the
167
189
  pinned commit/ref, and whether the user approves cloning. The CLI does not
168
- clone, checkout, reset, or fetch silently. If source material is missing or at
169
- the wrong ref, ask the user before running repo operations outside the CLI.
190
+ clone, checkout, reset, or fetch silently. If registered source material is
191
+ missing, the current Route exposes a repository recovery plan. The user chooses
192
+ an existing checkout, a bounded local scan, or an explicit shallow/partial clone
193
+ of the registered pinned commit. Context validates the remote, commit, and
194
+ subpaths, restores local aliases, and materializes module links. Advancing to a
195
+ new upstream commit remains a separate source-update decision.
196
+
197
+ For a long-lived production workspace with project-specific source ownership or
198
+ impact rules, copy the optional maintenance Skill template from
199
+ `templates/project-skills/maintain-project-knowledge/SKILL.md` into the
200
+ project's `.agents/skills/`, rename it for the project, and edit its project
201
+ facts. Keep Context lifecycle commands in the installed Context Skill and
202
+ current Route rather than duplicating them in the project Skill.
170
203
 
171
204
  ## 3. Declare The Flow
172
205
 
173
206
  ### Document Source Flow
174
207
 
175
208
  For source documents, keep the project declaration small and let the CLI guide
176
- the evidence views, structure confirmation, compile action schema, review, and
177
- close steps:
209
+ the evidence views, structure confirmation, deterministic compile projection,
210
+ review, and close steps:
178
211
 
179
212
  ```ts
180
213
  import {
@@ -200,11 +233,12 @@ export default defineProject({
200
233
  });
201
234
  ```
202
235
 
203
- Then start from `context status` or the installed Context continue Skill. The
236
+ Then start from `context status` or the installed host-specific Context
237
+ continuation entry. The
204
238
  normal sequence is:
205
239
 
206
240
  1. capture the source into committed snapshots;
207
- 2. investigate evidence and confirm `unapproved/structure.yaml`;
241
+ 2. investigate evidence and confirm the CLI-managed lifecycle structure;
208
242
  3. compile every source-bound View from confirmed structure;
209
243
  4. review/apply the complete candidate batch once;
210
244
  5. run close once, then verify and build when packages are declared.
@@ -242,8 +276,11 @@ context run extract:20260712/component-lib:codegraph
242
276
  When operating through an Agent, use `--dry-run --format json` as the CLI
243
277
  implementation for a no-write preview. For extract phases it returns a
244
278
  `preview` block with resolved sources, modules, file counts, symbol counts,
245
- candidate estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level
246
- hints. Treat that preview as the scope check before producing draft candidates.
279
+ resolved entry files, exported/internal counts, symbol-kind counts, candidate
280
+ estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level hints.
281
+ Treat that preview as a structural scope check before producing draft
282
+ candidates; the CLI does not decide which symbols are important to a business
283
+ or audience.
247
284
 
248
285
  The codegraph path keeps the stable module identity. The date stays in the repo
249
286
  source ref and phase id, not in the knowledge path:
@@ -272,18 +309,21 @@ context review html architecture --open
272
309
  Use the generated HTML page to approve or reject candidates. If the browser does
273
310
  not open automatically, use the emitted `file://` URL. When
274
311
  finished, open `Payload` and copy the review decision Payload into the agent chat.
275
- Uniform decisions use one JSON line; exceptions add JSONL lines. The
276
- agent writes that pasted payload to a normal temporary file under the workspace
277
- `.tmp/` directory and runs:
312
+ Uniform decisions use one JSON line; exceptions add JSONL lines. The agent
313
+ writes that pasted payload to the recommended workspace scratch area,
314
+ `.tmp/agent-payloads/`, and runs:
278
315
 
279
316
  ```bash
280
317
  context review apply <payload-file>
281
318
  ```
282
319
 
283
320
  Do not hand-write approved Markdown. `context review apply` owns materialization
284
- from `unapproved/entities.jsonl` into `knowledge/`.
285
- Do not store review payloads through scratch files outside `.tmp/` or by
286
- editing workspace config.
321
+ from the CLI-managed lifecycle candidate ledger into `knowledge/`. The runtime
322
+ ledger is ignored and is removed after a successful close; durable rejected
323
+ candidate fingerprints, when any, are kept in `knowledge/decisions.json`.
324
+ The location is a recommendation rather than a CLI restriction. Do not create a
325
+ top-level scratch directory or edit workspace config merely to retain a review
326
+ payload.
287
327
 
288
328
  ## 5. Build Packages
289
329
 
@@ -311,6 +351,12 @@ Choose an agent knowledge-base package when agents should consume the reviewed
311
351
  knowledge as a reusable package. After the user chooses this output shape,
312
352
  declare it with `kbPackage()`.
313
353
 
354
+ The package name already identifies the surrounding `dist/` directory. The OKF
355
+ roots inside it stay flat (`wikis/`, `guides/`, `rules/`, and `feats/`), so do
356
+ not ask for a second distribution namespace. Ask separately whether the author
357
+ wants a short Skill prefix, then maintain the complete final Skill directory
358
+ name in the template.
359
+
314
360
  The default `knowledge-query` skill teaches agents how to query copied OKF root
315
361
  directories structure-first, starting with `wikis/`, cite
316
362
  page/section evidence, inspect structure/build metadata when present, and report