@c4a/context-cli 0.5.29-alpha.1 → 0.5.29-beta.16
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 +71 -34
- package/cli.js +39951 -15792
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json.template +1 -1
- package/plugin/.codex-plugin/plugin.json.template +8 -5
- package/plugin/.cursor-plugin/plugin.json.template +29 -0
- package/plugin/README.md +99 -0
- package/plugin/README_CN.md +97 -0
- package/plugin/assets/icon.svg +3 -0
- package/plugin/assets/logo.svg +3 -0
- package/plugin/commands/align.md +44 -44
- package/plugin/commands/capture.md +28 -12
- package/plugin/commands/compile.md +97 -34
- package/plugin/commands/context.md +7 -4
- package/plugin/commands/drop.md +14 -6
- package/plugin/commands/extract.md +4 -4
- package/plugin/commands/init.md +49 -10
- package/plugin/commands/purge.md +8 -4
- package/plugin/commands/query.md +11 -3
- package/plugin/commands/status.md +4 -2
- package/plugin/skills/skill-align-workflow/SKILL.md +55 -0
- package/plugin/skills/skill-align-workflow/references/candidate-resolution.md +60 -0
- package/plugin/skills/skill-align-workflow/references/density-profile.md +23 -0
- package/plugin/skills/skill-align-workflow/references/gates.md +95 -0
- package/plugin/skills/skill-compile-close/SKILL.md +127 -0
- package/plugin/skills/skill-compile-draft/SKILL.md +409 -0
- package/plugin/skills/skill-context-query/SKILL.md +184 -0
- package/plugin/skills/skill-drop/SKILL.md +190 -0
- package/plugin/skills/skill-semantic-reconcile/SKILL.md +249 -0
- package/scripts/build-plugin.ts +674 -45
- package/templates/aspects/code/aspect.yaml +21 -0
- package/templates/aspects/code/prompt.md +33 -18
- package/templates/aspects/design-system/prompt.md +2 -3
- package/templates/aspects/graphql/prompt.md +2 -2
- package/templates/aspects/openapi/prompt.md +2 -2
- package/plugin/.claude-plugin/plugin.json +0 -16
- package/plugin/.codex-plugin/plugin.json +0 -35
- package/plugin/commands/capture-aspect.md +0 -17
- package/plugin/commands/capture-code.md +0 -25
- package/plugin/skills/align-finalize/SKILL.md +0 -137
- package/plugin/skills/align-propose/SKILL.md +0 -142
- package/plugin/skills/align-scan/SKILL.md +0 -161
- package/plugin/skills/align-scan/references/data-model.md +0 -343
- package/plugin/skills/align-scan/references/user-question-contract.md +0 -155
- package/plugin/skills/compile-close/SKILL.md +0 -122
- package/plugin/skills/compile-draft/SKILL.md +0 -246
- package/plugin/skills/context-query/SKILL.md +0 -166
- package/plugin/skills/drop/SKILL.md +0 -163
- package/plugin/skills/semantic-reconcile/SKILL.md +0 -106
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: drop
|
|
3
|
-
description: >
|
|
4
|
-
Source retraction through CLI-owned planning and application. The agent
|
|
5
|
-
calls `context drop --plan` for a structured impact plan, presents the
|
|
6
|
-
user-facing summary for confirmation, runs semantic reconciliation, then
|
|
7
|
-
calls `context drop --apply-plan --decisions` so the CLI archives raw and
|
|
8
|
-
removed knowledge, cleans active knowledge, applies source alias reindexing,
|
|
9
|
-
source stamp, changelog append, semantic ledger write, and verify.
|
|
10
|
-
Activates when `/context:drop` is invoked with a source-id, raw snapshot
|
|
11
|
-
path, or URL.
|
|
12
|
-
tools:
|
|
13
|
-
- Bash
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# drop — retract a source without losing the audit trail
|
|
17
|
-
|
|
18
|
-
Ask the CLI for a structured cleanup plan, confirm the user-visible impact,
|
|
19
|
-
run semantic reconciliation on affected knowledge items, then ask the CLI to
|
|
20
|
-
apply the plan with the confirmed decision document. Do not inspect or mutate
|
|
21
|
-
workspace files directly.
|
|
22
|
-
|
|
23
|
-
`WORKSPACE_DIR` is provided by the caller from `context workspace locate --format json` (`ctxDir`). It is `.context/` in embedded layout and the repository root in root layout.
|
|
24
|
-
|
|
25
|
-
## TL;DR — Non-negotiables
|
|
26
|
-
|
|
27
|
-
- Plan + semantic prepare/review + apply are CLI-owned. The agent only presents the plan, asks semantic questions when required, and waits for confirmation.
|
|
28
|
-
- Drop removes affected raw / unsupported knowledge from the active workspace and stores them under `archive/` for restore/audit.
|
|
29
|
-
- Do not Read / Glob / Grep / Write anything under `WORKSPACE_DIR`; all impact analysis and mutation must go through `context drop --plan`, `context reconcile prepare --mode drop`, `context reconcile review`, and `context drop --apply-plan --decisions`.
|
|
30
|
-
- `context drop --plan <source-id|raw-path|url> --format json` resolves source-id, computes affected topics / knowledge items, and reports alias reindex impact.
|
|
31
|
-
- `context drop --apply-plan <plan-file> --decisions <decisions-file> --reason "<text>" --yes` archives affected active content, consumes semantic decisions, removes unsupported Sections / empty Nodes from active knowledge, applies source alias reindexing, writes the semantic ledger, source stamp, changelog append, and verify.
|
|
32
|
-
- User confirmation required unless `--yes` was passed; abort on any non-`y` answer without writing. `--yes` does not skip semantic `ask_user` questions.
|
|
33
|
-
- Confirmation prose follows `${CLAUDE_PLUGIN_ROOT}/skills/align-scan/references/user-question-contract.md`: describe affected topics and claims, not source-ref mechanics.
|
|
34
|
-
- Source evidence, section, and verify rule meanings stay anchored to `${CLAUDE_PLUGIN_ROOT}/skills/align-scan/references/data-model.md`.
|
|
35
|
-
- Output language: impact plan + report match the user's language; CLI commands, flag names, source-ids, comment attributes stay English.
|
|
36
|
-
|
|
37
|
-
<reference>
|
|
38
|
-
|
|
39
|
-
## Plan fields
|
|
40
|
-
|
|
41
|
-
The JSON plan has:
|
|
42
|
-
|
|
43
|
-
| Field | Meaning |
|
|
44
|
-
|---|---|
|
|
45
|
-
| `source_id` | Canonical source id resolved from user input |
|
|
46
|
-
| `resolved_from.kind` | `source-id`, `snapshot-path`, or `url` |
|
|
47
|
-
| `affected_nodes[]` | Topics whose source list contains the dropped source |
|
|
48
|
-
| `affected_nodes[].sections[]` | Knowledge items that require semantic reconciliation before the source is dropped |
|
|
49
|
-
| `affected_nodes[].reindex_sections[]` | Knowledge items whose internal source alias will be renumbered after the source is removed |
|
|
50
|
-
| `affected_nodes[].will_be_sourceless` | Topic may be archived if it has no remaining active content after cleanup |
|
|
51
|
-
| `affected_graph_edges[]` | Explicit graph edges that will be removed because one endpoint leaves active knowledge |
|
|
52
|
-
| `unaffected_references[]` | Topic relationships that mention affected topics but are not source evidence |
|
|
53
|
-
| `summary` | Counts for confirmation and changelog |
|
|
54
|
-
|
|
55
|
-
## User-facing impact summary shape
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
Affected: N topics · M knowledge items
|
|
59
|
-
|
|
60
|
-
<topic title>
|
|
61
|
-
"short claim preview" → remove from active knowledge and archive
|
|
62
|
-
"short claim preview" → keep, supported by another source document
|
|
63
|
-
<topic title>
|
|
64
|
-
"short claim preview" → remove from active knowledge and archive
|
|
65
|
-
|
|
66
|
-
Proceed? [y/N]
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Keep the internal node slug, Section id, and source-ref patch data in your
|
|
70
|
-
working notes for Step 4; show them only if the user asks for implementation
|
|
71
|
-
details.
|
|
72
|
-
|
|
73
|
-
## CLI shapes
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
context drop --plan <source-id|raw-path|url> --format json
|
|
77
|
-
context reconcile prepare --mode drop --drop-plan <plan-file> --format json
|
|
78
|
-
context reconcile review --context <context-file> --decisions <decisions-file> --format json
|
|
79
|
-
context drop --apply-plan <plan-file> --decisions <decisions-file> --reason "<text>" --yes
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
The apply command writes a source-specific archive under `archive/sources/`,
|
|
83
|
-
moves affected raw out of active `raw/`, consumes semantic decisions for
|
|
84
|
-
reanchor / remove_unsupported / split_then_reanchor, removes unsupported
|
|
85
|
-
Sections / empty Nodes from active `knowledge/`, flips the source registry entry to
|
|
86
|
-
`status: dropped`, stamps `drop_reason` + `dropped_at` + `archive_path`,
|
|
87
|
-
appends a `[drop]` line to `knowledge/changelog.md`, records
|
|
88
|
-
`decisions/semantic.yaml`, and runs verify. It exits
|
|
89
|
-
non-zero if the source-id is unknown, already dropped, plan shape is invalid,
|
|
90
|
-
the plan is stale, semantic decisions are unresolved/invalid, or verify reports errors.
|
|
91
|
-
|
|
92
|
-
</reference>
|
|
93
|
-
|
|
94
|
-
<procedures>
|
|
95
|
-
|
|
96
|
-
### Step 1 — Parse arguments
|
|
97
|
-
|
|
98
|
-
From `$ARGUMENTS`: `<source-id|raw-path|url>` (required), `--reason <text>` (optional), `--yes` (optional). If the target is missing, stop and ask for the source id or raw snapshot path. If the reason is missing but the user's wording gives a clear reason, infer a concise reason such as `用户主动撤回`; otherwise collect it before Step 4.
|
|
99
|
-
|
|
100
|
-
### Step 2 — Ask CLI for a plan
|
|
101
|
-
|
|
102
|
-
Run `context drop --plan <source-id|raw-path|url> --format json`. Do not inspect
|
|
103
|
-
workspace files yourself. If the CLI reports source-not-found or
|
|
104
|
-
source-already-dropped, relay the error and stop.
|
|
105
|
-
|
|
106
|
-
### Step 3 — Present the impact plan
|
|
107
|
-
|
|
108
|
-
Render the [User-facing impact summary shape](#user-facing-impact-summary-shape)
|
|
109
|
-
from the plan JSON in the user's language. Make clear that dropping a source
|
|
110
|
-
removes listed content from active knowledge but keeps it restorable under
|
|
111
|
-
`archive/` until `context purge`. Mention graph edge cleanup when
|
|
112
|
-
`affected_graph_edges[]` is non-empty. Include the reason that will be stamped; if
|
|
113
|
-
it is still unknown, ask for the reason before continuing. If `--yes`, log
|
|
114
|
-
"auto-confirmed per --yes" and continue. Otherwise wait for `y`; abort on
|
|
115
|
-
anything else without writing.
|
|
116
|
-
|
|
117
|
-
### Step 4 — Reconcile affected knowledge
|
|
118
|
-
|
|
119
|
-
Write the exact plan JSON to a temporary file outside `WORKSPACE_DIR`, then run:
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
context reconcile prepare --mode drop --drop-plan <plan-file> --format json
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Invoke `${CLAUDE_PLUGIN_ROOT}/skills/semantic-reconcile/SKILL.md` with that
|
|
126
|
-
prepare payload. Save its decision document outside `WORKSPACE_DIR`, then run
|
|
127
|
-
`context reconcile review --context <context-file> --decisions <decisions-file> --format json`.
|
|
128
|
-
If review returns any `questions[]`, ask the user and rewrite those decisions
|
|
129
|
-
from `ask_user` into one of `reanchor`, `remove_unsupported`, or
|
|
130
|
-
`split_then_reanchor` before continuing. Do not let `--yes` bypass this step.
|
|
131
|
-
|
|
132
|
-
### Step 5 — Apply the plan
|
|
133
|
-
|
|
134
|
-
Write the exact plan JSON and confirmed semantic decision document to temporary
|
|
135
|
-
files outside `WORKSPACE_DIR`, then call:
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
context drop --apply-plan <plan-file> --decisions <decisions-file> --reason "<text>" --yes
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Do not call `context mdrive section ...` or `context mdrive node ...` for the
|
|
142
|
-
standard drop flow; `drop --apply-plan --decisions` owns cleanup, ledger write,
|
|
143
|
-
and verify.
|
|
144
|
-
|
|
145
|
-
### Step 6 — Report
|
|
146
|
-
|
|
147
|
-
The apply command already verifies. Run `context source get <source-id>` and
|
|
148
|
-
report in the user's language: topics affected, knowledge items marked
|
|
149
|
-
archived/removed from active knowledge, source alias reindex count, archive
|
|
150
|
-
path, changelog timestamp.
|
|
151
|
-
|
|
152
|
-
### Step 7 — Self-verify
|
|
153
|
-
|
|
154
|
-
- [ ] No Read / Glob / Grep / Write was used against `WORKSPACE_DIR` — if any was used, restart from **Step 2** with CLI-only flow.
|
|
155
|
-
- [ ] `context drop --plan` succeeded before asking the user — if not, **Step 2**.
|
|
156
|
-
- [ ] `context reconcile prepare --mode drop` was run from the exact drop plan — if not, **Step 2**.
|
|
157
|
-
- [ ] `context reconcile review` returned zero `questions[]` before apply; if any question remains, ask the user and regenerate the decisions document.
|
|
158
|
-
- [ ] User confirmed unless `--yes` was passed — if not, abort without writing.
|
|
159
|
-
- [ ] `context drop --apply-plan` exited 0 — if not, surface the CLI error and stop.
|
|
160
|
-
- [ ] `context source get <source-id>` shows the source as dropped — if not, surface the mismatch.
|
|
161
|
-
- [ ] The reported source entry includes `archive_path` — if missing, surface the mismatch.
|
|
162
|
-
|
|
163
|
-
</procedures>
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: semantic-reconcile
|
|
3
|
-
description: >
|
|
4
|
-
Internal skill for `/context:compile` and `/context:drop`. Consumes only
|
|
5
|
-
`context reconcile prepare` output, judges semantic relation/action for each
|
|
6
|
-
item, and emits a schema_version 1.0 semantic decision document for
|
|
7
|
-
`context reconcile review` / `context reconcile apply`.
|
|
8
|
-
tools:
|
|
9
|
-
- Bash
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# semantic-reconcile — decide Section reconciliation
|
|
13
|
-
|
|
14
|
-
Judge duplicate, merge, conflict, reanchor, and unsupported cases from the
|
|
15
|
-
CLI-prepared context. Emit decisions only; the CLI performs every write.
|
|
16
|
-
|
|
17
|
-
## TL;DR — Non-negotiables
|
|
18
|
-
|
|
19
|
-
- Input is only the `context reconcile prepare` payload. Do not Read, Glob, Grep, or Write workspace `raw/`, `knowledge/`, `archive/`, or `decisions/`.
|
|
20
|
-
- Output exactly one YAML or JSON document with `schema_version: "1.0"` and `decisions[]`.
|
|
21
|
-
- Use canonical relations: `exact_duplicate`, `strong_equivalent`, `near_duplicate`, `complement`, `supersedes`, `conflicts`, `reanchor`, `unsupported`, `keep_separate`, `ask_user`.
|
|
22
|
-
- Use canonical actions: `duplicate_skip`, `merge_update`, `supersede`, `reanchor`, `remove_unsupported`, `keep_separate`, `split_then_reanchor`, `ask_user`.
|
|
23
|
-
- `no-op` is not a decision action. For unchanged refresh items, emit no decision or `duplicate_skip`.
|
|
24
|
-
- Never expose `src-N`, Section ids, or source refs as the user-facing choice. They may appear only in the structured payload.
|
|
25
|
-
- `merge_update` is legal only when the final Section content is supported by one valid `source_ref`; otherwise use `keep_separate`, `split_then_reanchor`, or `ask_user`.
|
|
26
|
-
- Unresolved conflicts and low-confidence support questions must be `action: ask_user`.
|
|
27
|
-
|
|
28
|
-
<reference>
|
|
29
|
-
|
|
30
|
-
## Decision Shape
|
|
31
|
-
|
|
32
|
-
```yaml
|
|
33
|
-
schema_version: "1.0"
|
|
34
|
-
decisions:
|
|
35
|
-
- item_id: claim-001
|
|
36
|
-
relation: near_duplicate
|
|
37
|
-
action: merge_update
|
|
38
|
-
target:
|
|
39
|
-
node: payment-runtime
|
|
40
|
-
section_id: section-3
|
|
41
|
-
proposed:
|
|
42
|
-
content: "Runtime isolation uses sandboxing to avoid state pollution."
|
|
43
|
-
confidence: confirmed
|
|
44
|
-
source_ref: "src-2#runtime L12-14"
|
|
45
|
-
source_ref_text: "sandboxing to avoid state pollution"
|
|
46
|
-
rationale: "The new evidence refines the same claim."
|
|
47
|
-
user_confirmation:
|
|
48
|
-
required: true
|
|
49
|
-
question_type: merge_confirmation
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Action Rules
|
|
53
|
-
|
|
54
|
-
| action | Required fields |
|
|
55
|
-
|---|---|
|
|
56
|
-
| `duplicate_skip` | `target` |
|
|
57
|
-
| `merge_update` | `target`, `proposed.content`, `proposed.source_ref` |
|
|
58
|
-
| `supersede` | `target`, `proposed.kind`, `proposed.content`, `proposed.source_ref` |
|
|
59
|
-
| `reanchor` | `target`, `proposed.source_ref`, `proposed.confidence` |
|
|
60
|
-
| `remove_unsupported` | `target` |
|
|
61
|
-
| `keep_separate` | `target`, `proposed.kind`, `proposed.content`, `proposed.source_ref` |
|
|
62
|
-
| `split_then_reanchor` | `target`, `proposed.sections[]` |
|
|
63
|
-
| `ask_user` | `user_confirmation.required: true` |
|
|
64
|
-
|
|
65
|
-
</reference>
|
|
66
|
-
|
|
67
|
-
<procedures>
|
|
68
|
-
|
|
69
|
-
### Step 1 — Read Prepared Context
|
|
70
|
-
|
|
71
|
-
Use the caller-provided `context reconcile prepare` output. For each item,
|
|
72
|
-
compare `proposed`, `candidates`, `previous_decisions`, and `evidence`.
|
|
73
|
-
|
|
74
|
-
### Step 2 — Reuse Stable Priors
|
|
75
|
-
|
|
76
|
-
If `previous_decisions[]` shows the same boundary and the prepared item still
|
|
77
|
-
matches, emit the same final action. If the target changed, treat the previous
|
|
78
|
-
decision as a prior only and continue judging.
|
|
79
|
-
|
|
80
|
-
### Step 3 — Decide Relation And Action
|
|
81
|
-
|
|
82
|
-
Classify each item:
|
|
83
|
-
|
|
84
|
-
- Exact same claim already active -> `exact_duplicate` + `duplicate_skip`.
|
|
85
|
-
- Same claim with safer wording and one supporting source -> `strong_equivalent` or `near_duplicate` + `merge_update`.
|
|
86
|
-
- Additional but separate boundary -> `complement` + `keep_separate`.
|
|
87
|
-
- New material replaces old rule -> `supersedes` + `supersede`.
|
|
88
|
-
- Direct contradiction -> `conflicts` + `ask_user`.
|
|
89
|
-
- Drop item still fully supported elsewhere -> `reanchor` + `reanchor`.
|
|
90
|
-
- Drop item partly supported -> `reanchor` + `split_then_reanchor`.
|
|
91
|
-
- No surviving support -> `unsupported` + `remove_unsupported`.
|
|
92
|
-
- Evidence is close but not enough -> `ask_user`.
|
|
93
|
-
|
|
94
|
-
### Step 4 — Emit Decisions
|
|
95
|
-
|
|
96
|
-
Emit only executable final decisions plus unresolved `ask_user` questions.
|
|
97
|
-
Do not include prose outside the document.
|
|
98
|
-
|
|
99
|
-
### Step 5 — Self-verify
|
|
100
|
-
|
|
101
|
-
- [ ] Every decision uses canonical relation/action values. If not, **Step 3**.
|
|
102
|
-
- [ ] No `no-op` action appears. If not, **Step 3**.
|
|
103
|
-
- [ ] Every write action has the required fields from [Action Rules](#action-rules). If not, **Step 4**.
|
|
104
|
-
- [ ] No workspace files were read or written directly. If violated, restart from **Step 1**.
|
|
105
|
-
|
|
106
|
-
</procedures>
|