@c4a/context-cli 0.6.0-beta.7 → 0.6.1-beta.1

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 (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +130 -132
  3. package/README.zh-CN.md +158 -0
  4. package/cli.js +14978 -15477
  5. package/package.json +18 -3
  6. package/plugins/README.md +8 -0
  7. package/plugins/README_CN.md +6 -0
  8. package/plugins/VERSION +1 -1
  9. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  10. package/plugins/claude/skills/skill-continue-workflow/SKILL.md +39 -3
  11. package/plugins/claude/skills/skill-package-output/SKILL.md +16 -3
  12. package/plugins/claude/skills/skill-prose-align/SKILL.md +26 -31
  13. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  14. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  15. package/plugins/claude/skills/skill-prose-compile/SKILL.md +26 -27
  16. package/plugins/claude/skills/skill-review-gate/SKILL.md +17 -6
  17. package/plugins/claude/skills/skill-source-scope/SKILL.md +10 -9
  18. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  19. package/plugins/codex/skills/continue/references/internal-procedures/skill-continue-workflow.md +39 -3
  20. package/plugins/codex/skills/continue/references/internal-procedures/skill-package-output.md +16 -3
  21. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  22. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  23. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align.md +26 -31
  24. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile.md +26 -27
  25. package/plugins/codex/skills/continue/references/internal-procedures/skill-review-gate.md +17 -6
  26. package/plugins/codex/skills/continue/references/internal-procedures/skill-source-scope.md +10 -9
  27. package/plugins/codex/skills/init/references/internal-procedures/skill-continue-workflow.md +39 -3
  28. package/plugins/codex/skills/init/references/internal-procedures/skill-package-output.md +16 -3
  29. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  30. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  31. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align.md +26 -31
  32. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile.md +26 -27
  33. package/plugins/codex/skills/init/references/internal-procedures/skill-review-gate.md +17 -6
  34. package/plugins/codex/skills/init/references/internal-procedures/skill-source-scope.md +10 -9
  35. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  36. package/plugins/cursor/skills/skill-continue-workflow/SKILL.md +39 -3
  37. package/plugins/cursor/skills/skill-package-output/SKILL.md +16 -3
  38. package/plugins/cursor/skills/skill-prose-align/SKILL.md +26 -31
  39. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  40. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  41. package/plugins/cursor/skills/skill-prose-compile/SKILL.md +26 -27
  42. package/plugins/cursor/skills/skill-review-gate/SKILL.md +17 -6
  43. package/plugins/cursor/skills/skill-source-scope/SKILL.md +10 -9
  44. package/plugins/skills/context-continue/references/internal-procedures/skill-continue-workflow.md +39 -3
  45. package/plugins/skills/context-continue/references/internal-procedures/skill-package-output.md +16 -3
  46. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  47. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  48. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align.md +26 -31
  49. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile.md +26 -27
  50. package/plugins/skills/context-continue/references/internal-procedures/skill-review-gate.md +17 -6
  51. package/plugins/skills/context-continue/references/internal-procedures/skill-source-scope.md +10 -9
  52. package/plugins/skills/context-init/references/internal-procedures/skill-continue-workflow.md +39 -3
  53. package/plugins/skills/context-init/references/internal-procedures/skill-package-output.md +16 -3
  54. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  55. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  56. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align.md +26 -31
  57. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile.md +26 -27
  58. package/plugins/skills/context-init/references/internal-procedures/skill-review-gate.md +17 -6
  59. package/plugins/skills/context-init/references/internal-procedures/skill-source-scope.md +10 -9
  60. package/plugin/.claude-plugin/plugin.json.template +0 -16
  61. package/plugin/.codex-plugin/plugin.json.template +0 -38
  62. package/plugin/.cursor-plugin/plugin.json.template +0 -29
  63. package/plugin/README.md +0 -150
  64. package/plugin/README_CN.md +0 -136
  65. package/plugin/assets/icon.svg +0 -3
  66. package/plugin/assets/logo.svg +0 -3
  67. package/plugin/assets/workflow-en.png +0 -0
  68. package/plugin/assets/workflow.png +0 -0
  69. package/plugin/commands/continue.md +0 -34
  70. package/plugin/commands/init.md +0 -21
  71. package/plugin/skills/skill-continue-workflow/SKILL.md +0 -199
  72. package/plugin/skills/skill-init-workspace/SKILL.md +0 -74
  73. package/plugin/skills/skill-package-output/SKILL.md +0 -167
  74. package/plugin/skills/skill-prose-align/SKILL.md +0 -327
  75. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning/references/candidate-resolution.md +0 -91
  76. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning/references/density-profile.md +0 -30
  77. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +0 -269
  78. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning.md +0 -276
  79. package/plugin/skills/skill-prose-compile/SKILL.md +0 -288
  80. package/plugin/skills/skill-prose-compile/references/internal-procedures/close-gate.md +0 -132
  81. package/plugin/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/action-domain-gates.md +0 -52
  82. package/plugin/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/notes.md +0 -48
  83. package/plugin/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/refresh-and-update.md +0 -85
  84. package/plugin/skills/skill-prose-compile/references/internal-procedures/compile-actions/references/structural-challenges.md +0 -73
  85. package/plugin/skills/skill-prose-compile/references/internal-procedures/compile-actions.md +0 -413
  86. package/plugin/skills/skill-prose-compile/references/internal-procedures/compile-judgment.md +0 -123
  87. package/plugin/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/disposition-semantics.md +0 -81
  88. package/plugin/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/leakage-and-ownership.md +0 -55
  89. package/plugin/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/scope-review-and-omit.md +0 -93
  90. package/plugin/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/temporal-and-evidence.md +0 -79
  91. package/plugin/skills/skill-prose-compile/references/internal-procedures/semantic-judgment/references/user-confirmation.md +0 -111
  92. package/plugin/skills/skill-prose-compile/references/internal-procedures/semantic-judgment.md +0 -194
  93. package/plugin/skills/skill-review-gate/SKILL.md +0 -127
  94. package/plugin/skills/skill-source-scope/SKILL.md +0 -524
  95. package/plugin/skills/skill-source-scope/references/capture-source.md +0 -201
  96. package/plugins/assets/icon.svg +0 -3
  97. package/plugins/assets/workflow-en.png +0 -0
  98. package/plugins/assets/workflow.png +0 -0
  99. package/plugins/codex/assets/workflow-en.png +0 -0
  100. package/plugins/codex/assets/workflow.png +0 -0
  101. package/plugins/cursor/assets/icon.svg +0 -3
  102. package/plugins/cursor/assets/workflow-en.png +0 -0
  103. package/plugins/cursor/assets/workflow.png +0 -0
  104. package/scripts/build-plugin.ts +0 -658
@@ -1,127 +0,0 @@
1
- ---
2
- name: skill-review-gate
3
- description: >
4
- Internal procedure invoked by the public Context continuation entry; not a user slash command.
5
- Opens the review UI, waits for user decisions, applies copied review decision Payloads,
6
- and prevents agent-authored approval/rejection decisions unless the user
7
- explicitly requests the scoped quick-decision path.
8
- tools:
9
- - Bash
10
- ---
11
-
12
- # skill-review-gate
13
-
14
- Run the human review gate. The user decides approval or rejection.
15
-
16
- ## TL;DR
17
-
18
- - The agent never approves or rejects candidates on the user's behalf.
19
- - Enter this skill only when the preceding command returns
20
- `next_action.human_gate=true`. A no-delta codegraph run returns false and does
21
- not need Review.
22
- - For prose, enter only after every View in the confirmed compile batch is
23
- prepared. For codegraph, enter only after all pending extract phases in the
24
- confirmed module round are complete. The CLI blocks partial-batch Review.
25
- - Use `context review html <collection> --open --format json` for visual review.
26
- - `<collection>` is an internal production collection such as `architecture`,
27
- `sop`, `decision`, or `standards`; it is not an OKF package root such as
28
- `wikis`, `guides`, or `rules`.
29
- - Always surface the CLI-printed `file_url`. If browser opening fails or the
30
- host cannot make a path clickable, also provide `absolute_path`.
31
- - Apply only the review decision Payload copied by the user from the review UI.
32
- - Do not parse `unapproved/entities.jsonl`, `.tmp`, or HTML internals with
33
- scripts to synthesize decisions.
34
- - If the user explicitly asks for quick or automated approval/rejection, use
35
- `context review approve <candidate-id> --collection <collection>` /
36
- `context review reject <candidate-id> --collection <collection>` or `--all`;
37
- these commands still enforce the current scoped candidate-id gate.
38
- - `context run <extract-phase-id> --auto-promote` is a separate, explicit
39
- codegraph-only CI/CD policy. It may apply code add/update/remove deltas and
40
- refresh deterministic close, and verify them without this gate; it never
41
- applies to semantic knowledge. Package build remains an explicit later step.
42
- - `approved-source-ref-ambiguous` on beta.5 approved codegraph pages is an
43
- evidence migration, not a new review decision. Rerun the declared codegraph
44
- extraction, then run `context review migrate-codegraph-refs` and verify.
45
-
46
- <procedures>
47
-
48
- ### Step 1 — Open Review
49
-
50
- For the internal collection reported by status, run:
51
-
52
- ```bash
53
- context review html <collection> --open --format json
54
- ```
55
-
56
- Inspect the returned `opened` field. When it is `true`, tell the user the page
57
- was opened. When it is `false`, do not claim it opened; report `open_error` and
58
- provide `file_url` as the primary clickable link plus `absolute_path` as a
59
- copyable fallback. Do not drop `--open`, and do not assume a fixed review
60
- filename; review scope is collection or `--all`.
61
- Do not substitute OKF package roots (`wikis`, `guides`, `rules`) for this
62
- argument; review scope is the internal collection namespace.
63
-
64
- Explain that this page is the human gate between draft candidates and approved
65
- knowledge. Approved entries become Markdown under `knowledge/`; rejected entries
66
- stay in the committed ledger and are not written as knowledge pages. The agent
67
- must not choose these states.
68
-
69
- ### Step 2 — Wait For Payload
70
-
71
- Ask the user to review candidates in the HTML page, open Payload, copy the
72
- compact review decision Payload, and paste it into the agent chat. Uniform
73
- decisions produce one JSON line; exceptions add JSONL lines. The Payload records the
74
- user's decisions, usually as a default decision plus exceptions, so it should
75
- not be expanded into pretty JSON unless the user asks.
76
-
77
- The user should not need to create a payload file manually. Do not continue
78
- until the user supplies that payload.
79
-
80
- If the user instead explicitly asks the agent to use the quick approval or
81
- rejection path, do not synthesize a decision Payload. Run the scoped quick command with the
82
- candidate id shown by review/list/status and either `--collection <collection>`
83
- or `--all`.
84
-
85
- ### Step 3 — Apply Payload
86
-
87
- After the user pastes the payload into chat, the agent writes it to a normal
88
- temporary file under the current workspace `.tmp/` directory and runs:
89
-
90
- ```bash
91
- context review apply <payload-file>
92
- ```
93
-
94
- Do not accept or emit alternate `{ "decisions": [...] }` JSON. Use only
95
- `context.review.decisions.v1` JSONL.
96
- Do not use unsupported scratch, workflow, compile, or `.context/config.yaml`
97
- commands to store this payload.
98
-
99
- ### Step 4 — Return To Status
100
-
101
- Run `context status` after apply. If it reports package output choice, return to
102
- `${CLAUDE_PLUGIN_ROOT}/skills/skill-continue-workflow/SKILL.md`.
103
-
104
- If status instead reports `approved-source-ref-ambiguous` for a pre-file-aware
105
- codegraph ref, explain that the user's decisions remain approved. Rerun its
106
- declared extraction phase to refresh the symbol index, then run:
107
-
108
- ```bash
109
- context review migrate-codegraph-refs
110
- context verify
111
- ```
112
-
113
- Do not reopen Review, synthesize another payload, delete approved pages, or
114
- filter conflicting symbols. If the ref is already file-aware, report a
115
- duplicate extract-index defect rather than running the metadata migration.
116
-
117
- ### Step 5 — Self-verify Checklist
118
-
119
- - [ ] Every decision came from the user's copied payload. If not, stop and
120
- discard the agent-authored decision, unless the user explicitly requested a
121
- scoped quick command and that command used `--collection` or `--all`.
122
- - [ ] Payload was applied through `context review apply`. If not, return to
123
- **Step 3**.
124
- - [ ] No direct edits were made to `knowledge/` or `unapproved/`. If not, report
125
- the protocol error.
126
-
127
- </procedures>
@@ -1,524 +0,0 @@
1
- ---
2
- name: skill-source-scope
3
- description: >
4
- Internal procedure invoked by the public Context continuation entry; not a user slash command.
5
- Handles source registration, monorepo source boundaries, extract phase
6
- declaration, no-write scope preview, and the pre-extraction confirmation gate.
7
- tools:
8
- - Bash
9
- ---
10
-
11
- # skill-source-scope
12
-
13
- Choose and validate what may become draft knowledge.
14
-
15
- ## TL;DR
16
-
17
- - Missing source means the next product action is "add a knowledge source".
18
- Explain that in user-facing language before showing any CLI command.
19
- - Ask what source the user wants to add: local code repo/package, remote Git
20
- repo/package, local Markdown/MDX document/folder, article/documentation repo as a
21
- file source, or Lark/Feishu document. Current CLI can execute repo sources,
22
- local file sources, and Lark document capture through the declared flow.
23
- - Treat source registration as a knowledge-boundary decision, not a parameter
24
- prompt. Repo, file, and Lark sources use today's date as a batch. Multiple
25
- modules or documents share that date; never auto-append `-A/-B/-C` or ask for
26
- a second flat date name. File/Lark modules may be supplied with `--module`;
27
- otherwise the CLI derives a safe module from the local path or opaque
28
- document identity.
29
- - When the user supplies multiple sources together, register them with one
30
- `context source add batch [YYYYMMDD] --input <yaml|json|->` command. Never run
31
- multiple mutating `context source add` commands in parallel. Single-source
32
- commands use the same project write lock and must be retried serially when
33
- the CLI reports that the lock is held.
34
- - Do not infer a source from cwd, parent directories, package names, monorepo
35
- layout, or git remote.
36
- - In monorepos, inspect the package tree, then register each selected
37
- package/subdirectory as a module under the same date. Do not extract an
38
- ambiguous parent module.
39
- - `extractTs.include` filters files inside the selected source; it is not a
40
- package/module selector.
41
- - Do not ask users to add `exports`, `main`, `bin`, or a new entry file to the
42
- source repository solely for extraction. Standard package entries are
43
- auto-detected; non-standard API roots belong in Context-owned
44
- `extractTs.entries`. When the confirmed scope is all declarations in matched
45
- files, use `mode: "scan"` instead of inventing an entry.
46
- - Empty or undetected entries must return `NO_ENTRY_DETECTED`; never treat an
47
- empty extraction as success. Configure `entries`, or choose scan mode only
48
- when every matched file is the intended scope.
49
- - TypeScript extraction follows tsconfig/jsconfig `extends`, `baseUrl`, and
50
- `paths`. Aliases such as `@/` do not require changes to the source repository.
51
- - Use `context source inspect <date>/<module> --format json` for module choices.
52
- - Before first real extraction, generate a no-write preview and show module
53
- counts plus `knowledgeTree` / `knowledgePathExamples` to the user. Use
54
- `--dry-run` only in the command you execute, not as the user-facing label.
55
- - During a declared multi-module extraction round, treat
56
- `next_action.human_gate=false` as mechanical continuation: finish every
57
- pending extract phase before opening one combined Review page.
58
- - When captured file/Lark sources coexist with an unprocessed repo source,
59
- process code first while document structure is still untouched. Follow the
60
- `ready-to-extract` route and explain that document align resumes after the
61
- code extraction/review round. Do not interrupt a document structure or
62
- compile gate that has already started.
63
- - Human-facing explanations must describe the extraction impact first: what code
64
- files are read, what symbols become draft knowledge, what is skipped, and what
65
- review gate follows. Do not lead with `extractTs`, `include`, `exportedOnly`,
66
- or `reviewValidity`.
67
- - Document capture has its own gate. After a file or Lark source is registered,
68
- ask for permission before reading the source body, then show the capture
69
- summary before handing off to material investigation and structure drafting.
70
- If the user explicitly asked to capture, ingest, fetch, read, or include the
71
- exact path/URL, that request already grants read permission; do not ask again
72
- after registration. Mere mention, source discussion, and register-only
73
- requests do not grant permission, and an explicit refusal always wins.
74
- When the user requested several documents together, that confirmation covers
75
- those explicit modules: declare them all, then execute every capture command
76
- returned by `context status` before asking another source question.
77
- Do not default to one page per document, and do not create final draft pages
78
- directly from capture.
79
- - For capture routing, output handling, missing dependency recovery, and final
80
- reporting discipline, read the source capture procedure at
81
- [references/capture-source.md](references/capture-source.md). Its judgment
82
- rules use only the declared source/capture phase flow in this skill.
83
- - Do not use unsupported source lifecycle shortcuts. There is no direct
84
- source deletion or purge command in this workflow, and agents must not delete
85
- `sources/`, `knowledge/`, `unapproved/`, `dist/`, or `.tmp` to simulate one.
86
- If the user asks to retract, remove, or purge a source, stop and explain that
87
- the current plugin exposes no approved gate for that operation.
88
-
89
- <reference>
90
-
91
- ## Source Type Guide
92
-
93
- When the workspace has no source, do not ask with a raw placeholder command.
94
- Ask for a knowledge source in plain language and map it to the supported path:
95
-
96
- | User source | What to ask for | Current handling |
97
- |---|---|---|
98
- | Local code repo | date batch, concrete module name, and local repo/package path | Register with `context source add repo [YYYYMMDD] --module <module> --local <path>`. CLI records git root + optional `subpath`; when the Context workspace and source share a Git root, an absolute input is stored relative to the workspace. `sources/repo/YYYYMMDD/<module>` becomes an ignored relative symlink to that module view. |
99
- | Local monorepo package/module | which concrete packages/subdirs belong to this batch | Register every confirmed boundary as a module under the same date. Do not create `YYYYMMDD-A/B/C`, and do not use `extractTs.include` as a package selector. |
100
- | Remote Git repo | knowledge boundary, remote URL, pinned commit/ref, desired package/subdir, and permission to clone | CLI does not clone automatically. After explicit user approval, the agent may clone/checkout to an ignored local path, then register that local checkout. Cloned source content must not be committed. |
101
- | Local Markdown / document file or folder | date batch, document module boundary, local path, include glob or include-list if needed, and permission to read the source body | Register with `context source add file [YYYYMMDD] --module <module> --local <path>`; `--module` may be omitted when the path-derived name is sufficient. Documents from the same date are written as sibling files under `sources/file/YYYYMMDD/` and share that date's `manifest.json`. |
102
- | Lark / Feishu document | date batch, document module, URL/token, intended collection, and permission to read remotely | Register each document with `context source add lark [YYYYMMDD] --module <module>` plus exactly one identity flag. Documents from the same date are written as sibling files under `sources/lark/YYYYMMDD/` and share that date's `manifest.json`. Omit `--module` when the CLI-derived opaque identity is acceptable. |
103
-
104
- When asking for a document mainline collection, do not ask only "which
105
- collection?". Explain every available option in product language:
106
-
107
- | Collection | Use when the source is mainly about |
108
- |---|---|
109
- | `business` | 业务域、业务对象、行业/组织概念、非技术的领域知识 |
110
- | `product` | PRD、用户故事、产品行为、需求说明、验收口径 |
111
- | `architecture` | 系统架构、组件/模块设计、技术方案、工具链、平台能力 |
112
- | `sop` | SOP、操作流程、排障步骤、oncall/runbook、巡检维护 |
113
- | `faq` | 问答集合、常见问题、按问题检索的解释和处理建议 |
114
- | `standards` | 规范、标准、约束、检查清单、合规/质量规则 |
115
- | `decision` | 明确的方案选择、取舍理由、ADR、决策记录 |
116
- | `incident` | 事故复盘、故障时间线、影响面、根因、处置和预防措施 |
117
- | `test` | 测试计划、测试场景、验证矩阵、验收用例 |
118
-
119
- Do not offer `codegraph` or `feats` for prose document alignment. `codegraph`
120
- comes from code extraction, and `feats` is a later feature namespace.
121
-
122
- </reference>
123
-
124
- <procedures>
125
-
126
- ### Step 1 — Register Only User-Chosen Sources
127
-
128
- If no source is registered, tell the user that the next step is adding a
129
- knowledge source. Use the user's language and explain that this is a boundary
130
- choice:
131
-
132
- ```text
133
- You are choosing which code modules belong to one dated source batch.
134
- The date is the source directory/batch; each concrete module has its own
135
- extraction, source ref, phase id, and stable codegraph subtree. The date is not
136
- part of the knowledge path.
137
-
138
- If the source is one package:
139
- knowledge/codegraph/<module>/...
140
- repo:YYYYMMDD/<module>#symbol:...
141
-
142
- If the source is one document source:
143
- knowledge/architecture/entity/example.md
144
- file:YYYYMMDD/getting-started/index.md#span:...
145
- align:file:YYYYMMDD/getting-started:architecture
146
- dist/<name>-kb/
147
-
148
- If the date batch contains several repo modules, outputs are shaped like:
149
- knowledge/codegraph/module-a/...
150
- knowledge/codegraph/module-b/...
151
- ```
152
-
153
- Every repo source has both levels, even when the batch contains only one module.
154
- The date groups capture work; the module is the extraction boundary and
155
- project-wide codegraph identity. Do not register the same repo module name under
156
- another date; refresh it through its existing date/module selector.
157
-
158
- When the user has already provided a path, describe the current interpretation
159
- and use the CLI date default:
160
-
161
- ```text
162
- I am treating this path as the source boundary:
163
- <path>
164
-
165
- If this path is one package/module, it will be registered under today's date
166
- and use refs such as repo:YYYYMMDD/<module>#...
167
-
168
- If this path contains multiple modules, I will show the detected tree and
169
- register each selected module under the same date. Knowledge paths stay stable:
170
- knowledge/codegraph/<module-name>/...
171
-
172
- Extraction will still run separately for each module.
173
- ```
174
-
175
- Then ask for one of:
176
-
177
- - local code repo or package path;
178
- - remote Git repo URL plus pinned commit/ref and target package/subdir;
179
- - local document path;
180
- - Lark/Feishu document URL.
181
-
182
- Do not ask "what is the source name?" as the first or only question. Ask what
183
- they want the knowledge source to cover, then use the date default. For repo
184
- sources, ask which concrete module/package is being registered.
185
-
186
- Good user-facing wording:
187
-
188
- ```text
189
- Next we need to add a knowledge source.
190
-
191
- If you only want a manual for the component package, choose that package
192
- directory as the source boundary, for example:
193
- batch: YYYYMMDD
194
- module: component-lib
195
- path: /repo/packages/component-lib
196
-
197
- The date is one batch, not one module. The concrete selector appears in refs
198
- and phases such as repo:YYYYMMDD/component-lib#... and
199
- extract:YYYYMMDD/component-lib:codegraph.
200
-
201
- One date can group multiple registered modules while knowledge omits the date:
202
- knowledge/codegraph/module-a/...
203
- knowledge/codegraph/module-b/...
204
-
205
- Extraction still runs per concrete module. If a path contains several packages,
206
- I will show the module tree first and register each chosen package under this
207
- same date before reading code.
208
- ```
209
-
210
- Mention the CLI command only as an implementation detail after the user chooses
211
- a supported repo source.
212
-
213
- For a local repo source, ask for:
214
-
215
- - source boundary;
216
- - local repo or package/subdirectory path;
217
- - remote/ref only when not inferable or when the user wants an explicit pin.
218
-
219
- After the user provides the choice, run:
220
-
221
- ```bash
222
- context source add repo [YYYYMMDD] --module <module> --local <repo-or-subdir>
223
- context source ensure [YYYYMMDD|YYYYMMDD/module]
224
- ```
225
-
226
- For several repo/file/Lark modules confirmed in one request, prefer one batch
227
- payload instead of parallel commands:
228
-
229
- ```yaml
230
- sources:
231
- - type: repo
232
- module: module-a
233
- local: ../monorepo/packages/module-a
234
- - type: repo
235
- module: module-b
236
- local: ../monorepo/packages/module-b
237
- - type: lark
238
- url: https://example.larksuite.com/wiki/example
239
- ```
240
-
241
- ```bash
242
- context source add batch [YYYYMMDD] --input <sources.yaml|json|-> --format json
243
- ```
244
-
245
- The CLI validates batch identities, holds one project write lock, and writes
246
- registries atomically. It processes items in payload order. If a runtime item
247
- fails, the error reports completed items; fix it and rerun the same payload,
248
- because source registration is idempotent. Do not patch registry YAML manually.
249
- Repo items require `module`. File and Lark items may omit it; the CLI returns a
250
- derived lowercase path-safe module. If derived identities collide, provide
251
- explicit distinct modules and rerun the unchanged batch boundary.
252
-
253
- The repo batch must be a valid calendar date. The CLI rejects suffixes such as
254
- `YYYYMMDD-A`. A date-only `source ensure` or `source inspect` selector operates
255
- on every repo module registered in that batch; append `/module` to target one.
256
- If `--local` is absolute but the selected module and Context workspace belong
257
- to the same Git repository, expect the registry to store the Git root relative
258
- to the workspace plus `subpath`. The materialized source symlink also uses a
259
- relative target, so moving the repository as a unit keeps it valid. A source in
260
- a different Git repository may retain its absolute checkout root.
261
-
262
- Add `--remote` / `--ref` only when the user gave explicit values.
263
-
264
- For a remote Git repo source, ask for permission before clone/checkout. If the
265
- user approves, clone to an ignored local path, checkout the requested commit,
266
- then register that local checkout with `context source add repo`. Do not commit
267
- cloned source content.
268
-
269
- For local Markdown/MDX document sources, after the user confirms the boundary, run:
270
-
271
- ```bash
272
- context source add file [YYYYMMDD] --module <module> --local <file-or-folder>
273
- ```
274
-
275
- The date is the batch and the module is the concrete document boundary. Multiple
276
- file modules may share one date. `--module` may be omitted when the CLI-derived
277
- path slug is adequate; do not stop merely because another document already uses
278
- today's date.
279
-
280
- Default file capture handles Markdown. If `context source add file`,
281
- `context source inspect`, `context status`, or capture output reports that the
282
- source looks like an MDX documentation site, stop at the source boundary gate
283
- and ask the user to confirm that interpretation before changing `src/index.ts`.
284
- For MDX documentation sites that use `_meta.json` route metadata, declare
285
- `captureFile({ source: source("<date>", "<module>", { type: "file" }), processor: mdxJsonDocs() })` in
286
- `src/index.ts`; included `_meta.json` files are route metadata, and the CLI
287
- generates `__context_route_metadata.md` as mechanical route evidence. Use
288
- `--include` only when the approved boundary is narrower than the folder. For a
289
- long fixed batch, prefer `--include-list <file>` with one include per line;
290
- blank lines and `#` comments are ignored. Then explain that the next operation
291
- reads the approved document files and writes sibling files in one date batch.
292
- The CLI manages their shared capture metadata. After the user confirms read permission, summarize the
293
- `src/index.ts` change or show an equivalent diff summary, and run the capture
294
- phase.
295
- Apply [references/capture-source.md](references/capture-source.md) for route
296
- selection, dependency recovery, output handling, and final reporting, using the
297
- current capture phase command returned by `context status`.
298
-
299
- For Lark/Feishu document sources, register every requested document under the
300
- same date batch but do not fetch content
301
- with ad hoc scripts. Explain which remote document or wiki token will be read,
302
- that each document is written under `sources/lark/YYYYMMDD/` beside the other documents in that date batch, that one shared `manifest.json` tracks them, that committed
303
- snapshots enable offline verify and fresh-clone reproduction, that whether to
304
- add extra ignore rules is a business repository decision, and that access
305
- credentials are not written to the workspace. Use the declared capture/align
306
- flow only after the user confirms remote reading. After declaring
307
- `captureLark({ source: source("<date>", "<module>", { type: "lark" }) })`, summarize the `src/index.ts`
308
- change or show an equivalent diff summary.
309
- When the user adds more documents to an already confirmed batch and says they
310
- belong together, inherit the confirmed mainline collection and read permission
311
- for those explicitly supplied URLs. Register and declare all modules before
312
- capture; do not ask for another date name or repeat the same collection gate.
313
- If `context status --format json` returns multiple items in
314
- `routing.command_plan` while state is `needs-capture`, run every
315
- `after-human-confirmation` item in order after the current conversation contains
316
- permission. After one module completes, status should retain only the
317
- uncaptured modules; do not reopen the batch boundary gate between them.
318
- Apply [references/capture-source.md](references/capture-source.md) for route
319
- selection, dependency recovery, output handling, and final reporting, using the
320
- current capture phase command returned by `context status`.
321
-
322
- ### Step 2 — Handle Monorepos
323
-
324
- If a registered source may contain multiple packages, run:
325
-
326
- ```bash
327
- context source inspect <date>/<module> --format json
328
- ```
329
-
330
- Present the detected module/package paths from that CLI output as a tree. Explain
331
- the choices without exposing internal API names first:
332
-
333
- - register each chosen package/subdirectory as a module in the current date
334
- batch;
335
- - extraction, Review, and verification remain independent per concrete module.
336
-
337
- Wait for the user to choose. If the user chooses `packages/button`, register it
338
- as another module in the same date batch:
339
-
340
- ```bash
341
- context source add repo <date> --module button --local <repo>/packages/button
342
- ```
343
-
344
- Do not model a monorepo package choice as `include: ["packages/button/src/**"]`
345
- on the parent source.
346
-
347
- ### Step 3 — Review Captured Document Summary
348
-
349
- When status is `captured-ready-to-investigate`, or after a capture phase
350
- completes, do not immediately create draft pages or compile actions. Present
351
- the capture summary first:
352
-
353
- - document count;
354
- - title tree, heading tree, or source span distribution from the CLI output;
355
- - available reading budget and evidence views;
356
- - flat document path under `sources/file|lark/YYYYMMDD/` and the date-level `manifest.json`;
357
- - the fact that approved pages are planned through
358
- `unapproved/structure.yaml` before compile;
359
- - whether the source is local file/folder evidence or Lark/Feishu evidence.
360
-
361
- Then explain the next semantic gate in user-facing terms:
362
-
363
- ```text
364
- The source body has been captured into a committed snapshot.
365
-
366
- Next we investigate the material and propose a structure draft:
367
- - which knowledge pages should exist;
368
- - which source spans support each section;
369
- - which relationships are supported by evidence;
370
- - what remains unresolved or weak.
371
-
372
- No approved Markdown is written at this point. Compile can start only after the
373
- structure is validated and you confirm it.
374
- ```
375
-
376
- If the user wants to influence the shape before the Agent drafts it, ask a
377
- small semantic question with host-native multi-choice support when available:
378
-
379
- - Continue material investigation and propose a structure draft.
380
- - First add a reference structure or preference, such as expected domains,
381
- page naming, or relationship focus.
382
- - Narrow or correct the captured source before planning.
383
-
384
- Do not use SDK factory names as user-facing option labels. If the user asks for
385
- one page per source document, represent that as a degenerate structure draft
386
- and still route through structure confirmation plus compile. Then follow
387
- `${CLAUDE_PLUGIN_ROOT}/skills/skill-prose-align/SKILL.md`.
388
-
389
- ### Step 4 — Declare Extract And Review
390
-
391
- Read the SDK guide before editing:
392
-
393
- ```text
394
- node_modules/@c4a/context/docs/guides/agent-dialogue.md
395
- node_modules/@c4a/context/docs/guides/agent-guide.md
396
- node_modules/@c4a/context/docs/reference/project-api.md
397
- ```
398
-
399
- Before editing, explain the proposed extraction in product terms. Use wording
400
- like:
401
-
402
- ```text
403
- The source is ready and resolves to one package/module.
404
-
405
- Proposed extraction:
406
- - read TypeScript/TSX files under `src/`;
407
- - include exported symbols such as components, functions, types, and props;
408
- - create draft candidates for human review;
409
- - write no approved Markdown until the review payload is applied.
410
-
411
- This skips files outside `src/` and non-exported/internal helpers. If you want
412
- docs, tests, examples, or internal APIs included, say that before extraction.
413
-
414
- I will first generate a preview without writing candidates. The preview will
415
- show counts plus the planned `knowledge/` tree.
416
- ```
417
-
418
- Only after the user confirms this product-level scope, declare the chosen repo
419
- module with `source("YYYYMMDD", "<module>")`, add the TypeScript extraction phase, and add
420
- the human review phase. Use `include` only for a file-level filter within the
421
- chosen source boundary. If the package has no standard detected entry, keep the
422
- source repository unchanged and ask whether its intended knowledge surface is:
423
-
424
- - a public API graph rooted at specific files — configure source-relative
425
- `entries` that are also matched by `include`; or
426
- - all declarations in the matched files — configure `mode: "scan"`, which uses
427
- no entries and includes internal symbols by default.
428
-
429
- Mention the internal API names only in code-change summaries, or when the user
430
- asks for implementation details.
431
-
432
- When the user confirms several modules as one extraction round, declare all of
433
- their source-specific extract phases before writing candidates. Preview every
434
- phase first, summarize the combined scope once, and ask for one scope
435
- confirmation for that round.
436
-
437
- ### Step 5 — Show The Pre-extraction Preview
438
-
439
- Before real extraction, run the CLI no-write preview:
440
-
441
- ```bash
442
- context run <extract-phase-id> --dry-run --format json
443
- ```
444
-
445
- Show the user:
446
-
447
- - resolved source and module/package list;
448
- - discovered, AST-analyzed, skipped, symbol, relation, and candidate estimate
449
- counts, including each skipped reason;
450
- - `knowledgeTree`;
451
- - several `knowledgePathExamples`.
452
-
453
- Explain that approved pages will land under paths derived from collection,
454
- containment, and slug; NodeRef/ViewRef are identity fields, not path strings:
455
-
456
- ```text
457
- knowledge/<collection>/<containment>/<slug>.md
458
- ```
459
-
460
- If date batch, module name, module list, candidate estimate, or path shape is
461
- not what the user expects, stop and repair the source boundary or module registration
462
- before extraction.
463
-
464
- For code sources, `knowledge/codegraph/<module>/...` is the expected shape;
465
- the date remains in source refs and phase ids. An additional repeated package segment below `<module>` may indicate an
466
- over-broad boundary; stop if the preview shows that unexpectedly.
467
-
468
- Do not present this as a CLI option or as "Context default options" to the
469
- user. Present it as the actual proposed knowledge impact: code area read,
470
- exported-symbol policy, candidate count, and final path shape. The user-facing
471
- phrase is "preview without writing".
472
-
473
- ### Step 6 — Run Extraction Only After Scope Is Clear
474
-
475
- If the user already confirmed the exact source/scope and the no-write preview
476
- matches it, run:
477
-
478
- ```bash
479
- context run <extract-phase-id>
480
- ```
481
-
482
- Read the structured result before routing. A codegraph phase that produces
483
- candidates returns `continue-codegraph-batch` with `human_gate=false`; run the
484
- returned status command and continue any remaining confirmed extract phases.
485
- Only when status has no `pendingExtractPhases` and returns `needs-review` should
486
- the Agent open one collection-level Codegraph Review. The first round includes
487
- all candidates across the confirmed modules; later rounds include only
488
- added/updated/removed symbols, while unchanged approved symbols stay approved.
489
- Do not open Review after each module.
490
-
491
- Only when the user explicitly requests a non-interactive CI/CD codegraph sync,
492
- run:
493
-
494
- ```bash
495
- context run <extract-phase-id> --auto-promote --format json
496
- ```
497
-
498
- This applies deterministic codegraph deltas, refreshes deterministic close when
499
- needed, and verifies the result. Read `autoPromotion.close` and
500
- `autoPromotion.verify`; a nonzero exit or close/verification issue is a pipeline
501
- failure. Run `context build` separately when the pipeline publishes packages.
502
- Never use `--auto-promote` for prose or semantic collections.
503
-
504
- If an upgraded workspace reports `approved-source-ref-ambiguous` for pre-file-aware
505
- beta.5 codegraph refs, preserve the existing approval decisions. Rerun the
506
- declared codegraph extraction phase to produce the current file-aware symbol
507
- index, then run `context review migrate-codegraph-refs` and `context verify`.
508
- Tell the user this is evidence metadata migration and does not reopen Review.
509
-
510
- If the preview reports modules outside the confirmed source boundary, do not
511
- run extraction. Ask the user to choose the corrected source boundary.
512
-
513
- ### Step 7 — Self-verify Checklist
514
-
515
- - [ ] Source choice came from the user, not inference. If not, return to
516
- **Step 1**.
517
- - [ ] Monorepo package selection is represented as source boundary. If not,
518
- return to **Step 2**.
519
- - [ ] Captured document summary was shown before structure/compile. If not, return to
520
- **Step 3**.
521
- - [ ] No-write tree/path preview was shown before first real extraction. If not,
522
- return to **Step 5**.
523
-
524
- </procedures>