@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.
@@ -1,365 +1,53 @@
1
1
  # Agent Dialogue
2
2
 
3
- This guide defines how agents should talk to users while operating a Context
4
- workspace.
3
+ Context human gates should be explained as product decisions, not exposed as
4
+ SDK or CLI implementation details.
5
5
 
6
- ## Principle
6
+ ## Current Authority
7
7
 
8
- Talk about the user decision first, then the implementation detail.
8
+ Run:
9
9
 
10
- Do not start a human gate by exposing internal API names, default option names,
11
- or placeholder commands. The user needs to understand:
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
- Good:
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
- ```text
252
- Draft candidates are ready. The next step is human review.
21
+ This keeps a new Agent from loading every possible conversation script before
22
+ it knows which decision is current.
253
23
 
254
- Open the review HTML, approve or reject candidates, then copy the Payload back
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
- You do not need to save a payload file; I will write a temporary file and run
261
- the apply command.
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
- For a multi-View document or multi-module code round, use this wording only
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
- For a repeated codegraph run with no Review delta, say instead:
42
+ Only when the user explicitly requests fully managed operation in the current
43
+ conversation, use:
270
44
 
271
- ```text
272
- The source was checked and no added, changed, or removed code symbols need a
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
- For an explicitly requested CI/CD path, say:
278
-
279
- ```text
280
- I will run the codegraph phase with --auto-promote. It will apply only
281
- deterministic code add/update/remove deltas, refresh deterministic close when
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.