@c4a/context 0.6.1-beta.1 → 0.6.1-beta.2
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 +9 -2
- package/README.zh-CN.md +5 -1
- package/contracts.d.ts +5 -0
- package/docs/README.md +5 -3
- package/docs/getting-started.md +45 -21
- package/docs/guides/agent-dialogue.md +38 -350
- package/docs/guides/agent-guide.md +118 -87
- package/docs/guides/package-outputs.md +69 -16
- package/docs/reference/package-templates.md +103 -20
- package/docs/reference/project-api.md +70 -74
- package/docs/reference/template-variables.md +27 -11
- package/index.d.ts +10 -3
- package/index.js +58 -4
- package/package.json +1 -1
- package/templates/package-templates/kb/AGENTS.md +10 -10
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +16 -15
- package/templates/package-templates/kb/wikis/index.md +7 -7
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
|
|
48
|
-
|
|
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
|
|
|
@@ -116,6 +117,12 @@ include `{{packageName}}`, `{{displayName}}`, `{{knowledgeCount}}`,
|
|
|
116
117
|
`{{knowledgeGroups}}`, `{{knowledgeItems}}`, `{{knowledgeTree}}`, and
|
|
117
118
|
`{{buildInventory}}`.
|
|
118
119
|
|
|
120
|
+
Every KB package defaults `distribution.knowledgeNamespace` to its package
|
|
121
|
+
`name`, producing a short single-level knowledge directory. Set the field
|
|
122
|
+
explicitly when a multi-segment namespace such as
|
|
123
|
+
`personal-user.123/package` is required. Context isolates OKF roots under the
|
|
124
|
+
complete value; Skill names remain author-maintained and independent.
|
|
125
|
+
|
|
119
126
|
For advanced routing and retrieval, a template may carry a local script such as
|
|
120
127
|
`query.ts`, with a Skill describing when and how an Agent should call it. The
|
|
121
128
|
Skill can also route the Agent to MCP servers, CLI commands, or other tools to
|
package/README.zh-CN.md
CHANGED
|
@@ -38,7 +38,7 @@ export default defineProject({
|
|
|
38
38
|
});
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
`src/index.ts` 有点像知识项目的 Webpack 配置:它定义哪些内容进入项目、经过哪些转换和门禁,以及最终构建什么产物。安装好的 Agent
|
|
41
|
+
`src/index.ts` 有点像知识项目的 Webpack 配置:它定义哪些内容进入项目、经过哪些转换和门禁,以及最终构建什么产物。安装好的 Agent 插件只提供薄入口,当前工作流路由会按需选择维护这份配置所需的流程资源和 SDK 文档。
|
|
42
42
|
|
|
43
43
|
## 主要 API
|
|
44
44
|
|
|
@@ -97,6 +97,10 @@ kb/
|
|
|
97
97
|
|
|
98
98
|
模板使用 Handlebars 变量,可以作用于文件内容和路径。常用变量包括 `{{packageName}}`、`{{displayName}}`、`{{knowledgeCount}}`、`{{knowledgeGroups}}`、`{{knowledgeItems}}`、`{{knowledgeTree}}` 和 `{{buildInventory}}`。
|
|
99
99
|
|
|
100
|
+
每个 KB 包默认使用包 `name` 作为 `distribution.knowledgeNamespace`,生成简短的
|
|
101
|
+
单级知识目录。需要 `personal-user.123/package` 这类多段目录时可以显式配置该字段。
|
|
102
|
+
Context 会按照完整 namespace 隔离各个 OKF 根目录;Skill 名称仍由作者独立维护。
|
|
103
|
+
|
|
100
104
|
如果需要更强的路由和检索能力,模板可以携带 `query.ts` 一类本地脚本,再由 Skill 约定 Agent 何时、如何调用。Skill 也可以把 Agent 路由到 MCP、CLI 或其他工具,组成适合当前知识包的 Agentic Search 流程。
|
|
101
105
|
|
|
102
106
|
## 状态边界
|
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,14 +6,16 @@ These docs ship inside the installed SDK package at:
|
|
|
6
6
|
node_modules/@c4a/context/docs/
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
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) —
|
|
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.
|
|
18
20
|
- [Project API](./reference/project-api.md) — `defineProject`, sources, phases, review, and packages.
|
|
19
21
|
- [Package Templates](./reference/package-templates.md) — `kbPackage`, `llmsPackage`, template variables, and examples.
|
package/docs/getting-started.md
CHANGED
|
@@ -10,14 +10,18 @@ source boundary, then declare the matching phases in `src/index.ts`.
|
|
|
10
10
|
context init context --dev
|
|
11
11
|
cd context
|
|
12
12
|
bun install
|
|
13
|
-
context status
|
|
13
|
+
context status --format json
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Use `--dev` when testing a local link or prepared pack before the matching SDK
|
|
17
17
|
version is published. It writes a `file:` dependency to the SDK resolved beside
|
|
18
18
|
the active CLI. Published users can omit it and install the versioned SDK from
|
|
19
19
|
the registry.
|
|
20
|
-
When operating through an Agent plugin, use the installed Context continuation
|
|
20
|
+
When operating through an Agent plugin, use the installed Context continuation
|
|
21
|
+
entry from the project root after initialization. It consumes
|
|
22
|
+
`workflow.current`, loads only the selected resources, and calls lower-level
|
|
23
|
+
CLI primitives as needed. The exact slash command or skill name is
|
|
24
|
+
host-specific.
|
|
21
25
|
|
|
22
26
|
## 2. Choose And Register A Source Boundary
|
|
23
27
|
|
|
@@ -30,7 +34,8 @@ suffixes from prose or content. ViewRef/NodeRef are identity fields, not path
|
|
|
30
34
|
strings:
|
|
31
35
|
|
|
32
36
|
```text
|
|
33
|
-
knowledge/<collection>/<
|
|
37
|
+
knowledge/<collection>/<slug>.md
|
|
38
|
+
knowledge/<collection>/<containment>/<slug>.md # intentional hierarchy only
|
|
34
39
|
repo:<date>/<module>#symbol:...
|
|
35
40
|
file:<source-name>/<document>#span:...
|
|
36
41
|
lark:<source-name>/<document>#span:...
|
|
@@ -98,21 +103,27 @@ module first. An explicit request to capture/read those exact paths or URLs is
|
|
|
98
103
|
the read confirmation for that requested batch; do not ask again after
|
|
99
104
|
registration. Merely mentioning a possible source is not permission.
|
|
100
105
|
`context status --format json` returns all remaining capture phases in
|
|
101
|
-
`
|
|
102
|
-
|
|
103
|
-
pausing for another date name or
|
|
104
|
-
|
|
105
|
-
`
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
`workflow.current.commands`. Every item requiring the confirmed read scope is
|
|
107
|
+
marked `after-human-confirmation`, so one explicit confirmation can authorize
|
|
108
|
+
the complete requested batch without pausing for another date name or
|
|
109
|
+
collection choice between modules. If any module lacks a declaration,
|
|
110
|
+
`workflow.current.configuration` identifies the precise project change instead
|
|
111
|
+
of returning an unexecutable command. Read every
|
|
112
|
+
`workflow.current.resources.required` item before acting; long procedures and
|
|
113
|
+
semantic rules remain available as files and are loaded only for the route that
|
|
114
|
+
needs them.
|
|
115
|
+
|
|
116
|
+
After capture, status selects `route.document.classification-required` for
|
|
117
|
+
document modules without an align declaration. Run the Gate's returned
|
|
118
|
+
collection-neutral inspection commands first; only then propose a mainline
|
|
119
|
+
collection and ask for confirmation. Batch read permission does not choose a
|
|
120
|
+
collection.
|
|
111
121
|
|
|
112
122
|
When the workspace also contains repo sources, Context prioritizes untouched
|
|
113
|
-
code after all document captures finish:
|
|
114
|
-
until the code extraction round is current,
|
|
115
|
-
investigation. An existing document
|
|
123
|
+
code after all document captures finish: the current reason is
|
|
124
|
+
`route.extract.pending-target` until the code extraction round is current,
|
|
125
|
+
then routing returns to document investigation. An existing document
|
|
126
|
+
structure/compile gate is never interrupted.
|
|
116
127
|
|
|
117
128
|
For a single component package, use the package directory as the repo source
|
|
118
129
|
boundary:
|
|
@@ -173,8 +184,8 @@ the wrong ref, ask the user before running repo operations outside the CLI.
|
|
|
173
184
|
### Document Source Flow
|
|
174
185
|
|
|
175
186
|
For source documents, keep the project declaration small and let the CLI guide
|
|
176
|
-
the evidence views, structure confirmation, compile
|
|
177
|
-
close steps:
|
|
187
|
+
the evidence views, structure confirmation, deterministic compile projection,
|
|
188
|
+
review, and close steps:
|
|
178
189
|
|
|
179
190
|
```ts
|
|
180
191
|
import {
|
|
@@ -200,7 +211,8 @@ export default defineProject({
|
|
|
200
211
|
});
|
|
201
212
|
```
|
|
202
213
|
|
|
203
|
-
Then start from `context status` or the installed Context
|
|
214
|
+
Then start from `context status` or the installed host-specific Context
|
|
215
|
+
continuation entry. The
|
|
204
216
|
normal sequence is:
|
|
205
217
|
|
|
206
218
|
1. capture the source into committed snapshots;
|
|
@@ -242,8 +254,11 @@ context run extract:20260712/component-lib:codegraph
|
|
|
242
254
|
When operating through an Agent, use `--dry-run --format json` as the CLI
|
|
243
255
|
implementation for a no-write preview. For extract phases it returns a
|
|
244
256
|
`preview` block with resolved sources, modules, file counts, symbol counts,
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
resolved entry files, exported/internal counts, symbol-kind counts, candidate
|
|
258
|
+
estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level hints.
|
|
259
|
+
Treat that preview as a structural scope check before producing draft
|
|
260
|
+
candidates; the CLI does not decide which symbols are important to a business
|
|
261
|
+
or audience.
|
|
247
262
|
|
|
248
263
|
The codegraph path keeps the stable module identity. The date stays in the repo
|
|
249
264
|
source ref and phase id, not in the knowledge path:
|
|
@@ -311,6 +326,15 @@ Choose an agent knowledge-base package when agents should consume the reviewed
|
|
|
311
326
|
knowledge as a reusable package. After the user chooses this output shape,
|
|
312
327
|
declare it with `kbPackage()`.
|
|
313
328
|
|
|
329
|
+
The package name becomes its stable single-level knowledge namespace by
|
|
330
|
+
default. Ask for a custom namespace only when the user needs another value. An
|
|
331
|
+
explicit namespace may contain several concise lowercase path segments, such
|
|
332
|
+
as `group/package` or `personal-user.123/package`; each segment may use letters
|
|
333
|
+
and numbers joined by hyphens or dots. Do not infer custom values from
|
|
334
|
+
downstream platform identifiers. Ask separately whether the author wants a
|
|
335
|
+
short Skill prefix, then maintain the complete final Skill directory name in
|
|
336
|
+
the template.
|
|
337
|
+
|
|
314
338
|
The default `knowledge-query` skill teaches agents how to query copied OKF root
|
|
315
339
|
directories structure-first, starting with `wikis/`, cite
|
|
316
340
|
page/section evidence, inspect structure/build metadata when present, and report
|
|
@@ -1,365 +1,53 @@
|
|
|
1
1
|
# Agent Dialogue
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Context human gates should be explained as product decisions, not exposed as
|
|
4
|
+
SDK or CLI implementation details.
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Current Authority
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Run:
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- what decision is being made;
|
|
14
|
-
- what will happen after they approve;
|
|
15
|
-
- what files or knowledge shape will be affected;
|
|
16
|
-
- what alternatives they can choose.
|
|
17
|
-
|
|
18
|
-
CLI commands, source names, phase ids, status values, payload keys, and
|
|
19
|
-
`source_ref` values are protocol text. Keep those exact when needed, but do not
|
|
20
|
-
make them the main explanation.
|
|
21
|
-
|
|
22
|
-
## Fully Managed Conversation
|
|
23
|
-
|
|
24
|
-
If the user explicitly says the current conversation is fully managed, briefly
|
|
25
|
-
confirm that eligible workflow decisions will proceed automatically, then use
|
|
26
|
-
the CLI's `--managed` status loop. Do not ask the ordinary classification,
|
|
27
|
-
extraction-scope, structure-confirmation, Review, or package-output questions.
|
|
28
|
-
Continue to surface source/read permission, external operation requests, and
|
|
29
|
-
validation or verification failures because managed mode does not authorize or
|
|
30
|
-
hide them. The authorization ends with the conversation and must not be written
|
|
31
|
-
to project configuration.
|
|
32
|
-
|
|
33
|
-
## Human Gate Question Form
|
|
34
|
-
|
|
35
|
-
When the decision has a small fixed option set, use the host's native
|
|
36
|
-
multi-choice tool when available:
|
|
37
|
-
|
|
38
|
-
- Claude Code: `AskUserQuestion`
|
|
39
|
-
- Codex: use the available native user-input tool, for example
|
|
40
|
-
`request_user_input` when it is exposed
|
|
41
|
-
- Cursor Plan Mode: `AskQuestion`
|
|
42
|
-
|
|
43
|
-
If no native question tool is available, fall back to Markdown `A/B/C` choices.
|
|
44
|
-
Each option must include a short impact statement. Do not ask an open-ended
|
|
45
|
-
free-text question when the actual workflow has two or three known branches.
|
|
46
|
-
The option labels must be semantic user choices, not API or factory names. Use
|
|
47
|
-
implementation names such as `alignProse`, `compileProse`, `kbPackage`, or
|
|
48
|
-
`llmsPackage` only in a technical follow-up, command, or `src/index.ts` change
|
|
49
|
-
summary.
|
|
50
|
-
|
|
51
|
-
Examples:
|
|
52
|
-
|
|
53
|
-
- document structure gate: continue material investigation vs add user
|
|
54
|
-
structure guidance vs narrow the captured source;
|
|
55
|
-
- package output: agent knowledge-base package vs LLM text bundle vs skip for
|
|
56
|
-
now;
|
|
57
|
-
- stale approved page: create a replacement review candidate vs confirm the
|
|
58
|
-
existing content is still valid;
|
|
59
|
-
- orphaned approved page: mark the page deprecated vs keep it as unverifiable
|
|
60
|
-
knowledge.
|
|
61
|
-
|
|
62
|
-
## Source Boundary Gate
|
|
63
|
-
|
|
64
|
-
Bad:
|
|
65
|
-
|
|
66
|
-
```text
|
|
67
|
-
Please provide source name:
|
|
68
|
-
context source add repo <date> --module <module> --local <repo-or-subdir>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Good:
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
Next we need to choose the knowledge source.
|
|
75
|
-
|
|
76
|
-
If you want one manual for only this package, choose the package directory as
|
|
77
|
-
the source boundary. If you want one manual for the whole subspace, choose the
|
|
78
|
-
subspace root.
|
|
79
|
-
|
|
80
|
-
The CLI uses today's local date (`YYYYMMDD`) as the repo batch. Each confirmed
|
|
81
|
-
package is registered as a module under that date, so the same batch can contain
|
|
82
|
-
web, Lynx, and shared modules without `-A/-B/-C` suffixes. The concrete selector
|
|
83
|
-
`YYYYMMDD/module` becomes part of source refs and phase ids, while approved
|
|
84
|
-
knowledge uses the stable module name without the date:
|
|
85
|
-
knowledge/codegraph/<module>/...
|
|
86
|
-
repo:YYYYMMDD/<module>#...
|
|
87
|
-
|
|
88
|
-
If today's batch already exists, add the next confirmed code or document module
|
|
89
|
-
to it; do not add a sequence number automatically. File/Lark registration
|
|
90
|
-
returns a `YYYYMMDD/module` identity and never requires a second flat date name.
|
|
91
|
-
|
|
92
|
-
For the current first extraction, I will still ask you to confirm the concrete
|
|
93
|
-
package/subdirectory boundary before reading code.
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Only after that explanation should the agent show the concrete command it will
|
|
97
|
-
run.
|
|
98
|
-
|
|
99
|
-
## Document Read Permission Gate
|
|
100
|
-
|
|
101
|
-
Bad:
|
|
102
|
-
|
|
103
|
-
```text
|
|
104
|
-
Running capture:file:docs now.
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Good:
|
|
108
|
-
|
|
109
|
-
```text
|
|
110
|
-
The source is registered, but registration did not read the document body.
|
|
111
|
-
|
|
112
|
-
The next operation will read this local Markdown file or folder and write a
|
|
113
|
-
committed sibling file under `sources/file/<date>/`, tracked by that date's single `manifest.json`. The concrete
|
|
114
|
-
`YYYYMMDD/module` identity is returned by `context source add file`. That snapshot is used
|
|
115
|
-
later for review, verify, and fresh-clone reproduction.
|
|
116
|
-
|
|
117
|
-
Please confirm that I may read this document source now. After you confirm, I
|
|
118
|
-
will declare the capture phase in `src/index.ts`, summarize that change, and
|
|
119
|
-
run the capture command.
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
For Lark / Feishu:
|
|
123
|
-
|
|
124
|
-
```text
|
|
125
|
-
The source is registered, but registration did not fetch the remote document.
|
|
126
|
-
|
|
127
|
-
The next operation will read the Lark/Feishu document you provided and write a
|
|
128
|
-
normalized sibling file under `sources/lark/<date>/`, tracked by that date's single `manifest.json`. Several requested
|
|
129
|
-
documents may share the date; each has its own module and snapshot. The snapshot is
|
|
130
|
-
committed by default so verify can work offline and after a fresh clone. Access
|
|
131
|
-
credentials stay in the Lark CLI; they are not written to this workspace. If
|
|
132
|
-
your business repository wants to ignore this snapshot, that is a repository
|
|
133
|
-
policy decision and verify will report degraded offline evidence later.
|
|
134
|
-
|
|
135
|
-
Please confirm that I may read this remote document now.
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Do not run capture preview, capture, or refresh before this permission is clear.
|
|
139
|
-
|
|
140
|
-
## Document Investigation Gate
|
|
141
|
-
|
|
142
|
-
Bad:
|
|
143
|
-
|
|
144
|
-
```text
|
|
145
|
-
Run align:file:docs:architecture or compile:file:docs:architecture?
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Good:
|
|
149
|
-
|
|
150
|
-
```text
|
|
151
|
-
The document source has been captured into a committed snapshot.
|
|
152
|
-
|
|
153
|
-
Capture summary:
|
|
154
|
-
- documents: <count>
|
|
155
|
-
- title tree: <top-level titles or heading groups>
|
|
156
|
-
- evidence views: read-plan, source-index --compact, span-detail, span-text
|
|
157
|
-
|
|
158
|
-
Next I will investigate the material and propose a structure draft. That draft
|
|
159
|
-
decides:
|
|
160
|
-
|
|
161
|
-
- which knowledge pages should exist;
|
|
162
|
-
- which sections belong to each page;
|
|
163
|
-
- which relationships have source-backed evidence;
|
|
164
|
-
- which questions remain unresolved.
|
|
165
|
-
|
|
166
|
-
Confirming the structure will freeze paths, section ownership, relationships,
|
|
167
|
-
and compile order for this round. No approved Markdown is written before review.
|
|
168
|
-
|
|
169
|
-
You can choose:
|
|
170
|
-
A. Continue material investigation and let me propose the structure draft.
|
|
171
|
-
B. First give structure preferences, such as expected domains or naming.
|
|
172
|
-
C. Go back and narrow or correct the captured source.
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
After the user chooses, update `src/index.ts` if the matching align/compile
|
|
176
|
-
phases are not declared yet, then summarize the change. For example:
|
|
177
|
-
|
|
178
|
-
```text
|
|
179
|
-
I updated the project flow to add document structure planning and source-bound
|
|
180
|
-
compile for source `20260704`. No approved Markdown is written yet. The next gate
|
|
181
|
-
is a structure draft for your confirmation.
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
If the user asks for one page per source document, explain that it is modeled as
|
|
185
|
-
a simple structure draft. It still goes through structure confirmation and
|
|
186
|
-
source-bound compile; there is no separate shortcut that writes final page body
|
|
187
|
-
directly from capture.
|
|
188
|
-
|
|
189
|
-
Validator-required page splits and continuous-source Section splits are not a
|
|
190
|
-
new approval round. Apply the returned repair route, validate until
|
|
191
|
-
`confirmation_ready=true`, then stage and present the automatically opened HTML
|
|
192
|
-
report for one final structure confirmation. If evidence leaves multiple
|
|
193
|
-
incompatible semantic structures, ask only that design question and explicitly
|
|
194
|
-
say it is not the final report-based review.
|
|
195
|
-
|
|
196
|
-
## Extraction Scope Gate
|
|
197
|
-
|
|
198
|
-
Bad:
|
|
199
|
-
|
|
200
|
-
```text
|
|
201
|
-
是否按 Context 默认范围继续?
|
|
202
|
-
extractTs({
|
|
203
|
-
source: source("20260712", "component-lib"),
|
|
204
|
-
collection: "codegraph",
|
|
205
|
-
// include defaults to ["src/**/*.{ts,tsx}"]
|
|
206
|
-
// exportedOnly defaults to true
|
|
207
|
-
})
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
Good:
|
|
211
|
-
|
|
212
|
-
```text
|
|
213
|
-
The source is ready and resolves to one package.
|
|
214
|
-
|
|
215
|
-
Proposed extraction:
|
|
216
|
-
- read TypeScript/TSX files under `src/`;
|
|
217
|
-
- only include exported symbols such as components, functions, types, and props;
|
|
218
|
-
- create draft candidates for human review;
|
|
219
|
-
- no approved Markdown is written until you review the candidates.
|
|
220
|
-
|
|
221
|
-
This means files outside `src/` and non-exported/internal helpers are skipped.
|
|
222
|
-
If you want docs, tests, examples, or internal APIs included, say that before
|
|
223
|
-
extraction.
|
|
224
|
-
|
|
225
|
-
If the selected package has no standard package entry, do not ask the user to
|
|
226
|
-
change its source or `package.json`. Explain two Context-owned choices: provide
|
|
227
|
-
the source-relative API roots as configured entries, or scan every file matched
|
|
228
|
-
by the confirmed file scope. Entry-based extraction preserves public API
|
|
229
|
-
reachability; scan mode includes internal declarations by default.
|
|
230
|
-
|
|
231
|
-
I will first generate a preview without writing candidates. The preview will
|
|
232
|
-
show the file count, symbol count, candidate count, and planned `knowledge/`
|
|
233
|
-
tree. I will only run extraction after that preview matches your expectation.
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Mention `extractTs`, `include`, `entries`, `mode`, `exportedOnly`, or
|
|
237
|
-
`reviewValidity` only if the
|
|
238
|
-
user asks for implementation details, or when editing `src/index.ts` in a code
|
|
239
|
-
summary.
|
|
240
|
-
|
|
241
|
-
## Review Gate
|
|
242
|
-
|
|
243
|
-
Bad:
|
|
244
|
-
|
|
245
|
-
```text
|
|
246
|
-
Run reviewValidity and apply payload.
|
|
10
|
+
```bash
|
|
11
|
+
context status --format json
|
|
247
12
|
```
|
|
248
13
|
|
|
249
|
-
|
|
14
|
+
For a gate, `workflow.current.resources.required` includes the exact dialogue
|
|
15
|
+
resource for that decision together with its operating procedure and current
|
|
16
|
+
workspace view. Read those selected resources before asking the question. The
|
|
17
|
+
gate-specific source-boundary, read-permission, classification, extraction,
|
|
18
|
+
structure, Review, package, and evidence-maintenance guidance is intentionally
|
|
19
|
+
not duplicated in this SDK manual.
|
|
250
20
|
|
|
251
|
-
|
|
252
|
-
|
|
21
|
+
This keeps a new Agent from loading every possible conversation script before
|
|
22
|
+
it knows which decision is current.
|
|
253
23
|
|
|
254
|
-
|
|
255
|
-
into chat. I will only apply the payload you provide; I will not approve or
|
|
256
|
-
reject candidates on your behalf. Review decides which draft entries become
|
|
257
|
-
approved Markdown under `knowledge/`, and which entries stay rejected in the
|
|
258
|
-
ledger.
|
|
24
|
+
## Stable Principles
|
|
259
25
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
26
|
+
- Use the user's conversation language for explanations and questions.
|
|
27
|
+
- Keep commands, paths, ids, payload fields, status values, and `source_ref`
|
|
28
|
+
tokens exact.
|
|
29
|
+
- Explain what is being decided, what changes after confirmation, and which
|
|
30
|
+
alternatives exist before showing implementation detail.
|
|
31
|
+
- Prefer the host's native choice UI for a small fixed option set. Otherwise
|
|
32
|
+
use concise A/B/C choices with one impact sentence each.
|
|
33
|
+
- Use semantic labels such as “Agent knowledge-base package” rather than SDK
|
|
34
|
+
factory names such as `kbPackage`.
|
|
35
|
+
- Do not infer a decision from a filename, URL, repository layout, example, or
|
|
36
|
+
previous conversation.
|
|
37
|
+
- Keep transition reports short: what changed, the current state, and the next
|
|
38
|
+
decision or action.
|
|
263
39
|
|
|
264
|
-
|
|
265
|
-
after the CLI reports that the complete batch is prepared. Do not ask the user
|
|
266
|
-
to review one page or module while other confirmed items in the same round are
|
|
267
|
-
still being generated.
|
|
40
|
+
## Fully Managed Conversations
|
|
268
41
|
|
|
269
|
-
|
|
42
|
+
Only when the user explicitly requests fully managed operation in the current
|
|
43
|
+
conversation, use:
|
|
270
44
|
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
decision. Existing approved symbols were preserved, so there is no human gate
|
|
274
|
-
for this run and I can continue.
|
|
45
|
+
```bash
|
|
46
|
+
context status --managed --format json
|
|
275
47
|
```
|
|
276
48
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
needed, run verification, and fail the pipeline if close or verification fails.
|
|
283
|
-
Package build remains a separate publishing step. Semantic knowledge still
|
|
284
|
-
requires Review.
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
## Package Gate
|
|
288
|
-
|
|
289
|
-
Bad:
|
|
290
|
-
|
|
291
|
-
```text
|
|
292
|
-
Choose one: skills, llms, both, none.
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
Good:
|
|
296
|
-
|
|
297
|
-
```text
|
|
298
|
-
Approved knowledge is ready. Now choose how it should be packaged.
|
|
299
|
-
|
|
300
|
-
Recommended first output is an agent knowledge-base package:
|
|
301
|
-
dist/<name>-kb/
|
|
302
|
-
├── AGENTS.md
|
|
303
|
-
├── skills/knowledge-query/SKILL.md
|
|
304
|
-
└── wikis/
|
|
305
|
-
├── index.md
|
|
306
|
-
├── <group>/index.md
|
|
307
|
-
└── <group>/...
|
|
308
|
-
|
|
309
|
-
This gives agents a reusable knowledge-query skill plus copied approved
|
|
310
|
-
knowledge pages. The
|
|
311
|
-
default query skill starts from OKF indexes, cites page/section evidence, uses
|
|
312
|
-
structure/build metadata when present, and reports gaps rather than inventing
|
|
313
|
-
unsupported answers. The template under `src/package-templates/kb/` is editable
|
|
314
|
-
before build, including `wikis/index.md` for bundle scope and query guidance.
|
|
315
|
-
The root index should stay shallow by default: it lists next-level directories,
|
|
316
|
-
and `context build` generates child directory indexes so users can browse from
|
|
317
|
-
bundle to group to page.
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
Offer the alternatives as user-facing choices:
|
|
321
|
-
|
|
322
|
-
- Agent knowledge-base package: creates `dist/<name>-kb/` for agents to query
|
|
323
|
-
and cite approved knowledge pages.
|
|
324
|
-
- LLM text bundle: creates `dist/<name>-llms/` for one text/RAG import bundle.
|
|
325
|
-
- Skip for now: leaves approved Markdown in `knowledge/` without a `dist/`
|
|
326
|
-
package.
|
|
327
|
-
|
|
328
|
-
Do not offer `both` as a shortcut. If the user wants multiple outputs, declare
|
|
329
|
-
one package first, build and inspect it, then ask before adding another. Use
|
|
330
|
-
`kbPackage` / `llmsPackage` only after the user has chosen the semantic output
|
|
331
|
-
shape.
|
|
332
|
-
|
|
333
|
-
## Evidence Maintenance Gates
|
|
334
|
-
|
|
335
|
-
When approved knowledge still exists but the source evidence changed, explain
|
|
336
|
-
that the approved page remains usable but is no longer fully current against
|
|
337
|
-
the latest snapshot.
|
|
338
|
-
|
|
339
|
-
Use semantic choices:
|
|
340
|
-
|
|
341
|
-
- Create an updated draft for review: best when the source change may require
|
|
342
|
-
wording, scope, or facts to change. This creates a replacement candidate and
|
|
343
|
-
still requires review.
|
|
344
|
-
- Confirm the current page is still valid: best when the source change is only
|
|
345
|
-
formatting, typo cleanup, or otherwise does not affect the approved content.
|
|
346
|
-
This re-binds the page to the current evidence without changing its body.
|
|
347
|
-
|
|
348
|
-
When an approved page points to a source document that no longer exists in the
|
|
349
|
-
current snapshot, do not offer replacement or re-binding. Use semantic choices:
|
|
350
|
-
|
|
351
|
-
- Mark the page as deprecated: removes it from later package output while
|
|
352
|
-
preserving audit history.
|
|
353
|
-
- Keep it as source-orphaned knowledge: leaves it approved, but verify/status
|
|
354
|
-
will keep reporting an evidence warning.
|
|
355
|
-
|
|
356
|
-
## Reporting
|
|
357
|
-
|
|
358
|
-
Keep reports short and state transitions oriented:
|
|
359
|
-
|
|
360
|
-
- commands run;
|
|
361
|
-
- current state;
|
|
362
|
-
- what changed;
|
|
363
|
-
- the next human decision, if any.
|
|
364
|
-
|
|
365
|
-
Do not paste long raw CLI transcripts unless the user asks for exact output.
|
|
49
|
+
The returned route decides which delegatable gates may proceed without another
|
|
50
|
+
question. This authority is not project configuration and must not be persisted
|
|
51
|
+
or reused in another conversation. It cannot choose source boundaries,
|
|
52
|
+
authorize unread external sources or external operations, or bypass validation
|
|
53
|
+
and verification.
|