@c4a/context-cli 0.5.29-beta.29 → 0.5.33-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +5492 -4159
- package/package.json +1 -1
- package/plugin/commands/capture.md +10 -14
- package/plugin/commands/compile.md +5 -3
- package/plugin/skills/skill-compile-judge/SKILL.md +1 -0
package/package.json
CHANGED
|
@@ -14,17 +14,11 @@ length exemption for self-contained slash commands.
|
|
|
14
14
|
|
|
15
15
|
Capture is entirely CLI-driven — your role is to route the right `context capture` invocation and relay its output. Never hand-write captured source snapshots: the CLI owns normalisation (NFC, BOM strip, line endings) and the `content_hash` contract, so any manual edit breaks idempotency.
|
|
16
16
|
|
|
17
|
-
### Code capture dependency
|
|
17
|
+
### Code capture dependency handling
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Do not run ad-hoc Node.js package-resolution preflights before `context capture --code`. The CLI owns dependency discovery and returns structured `agent_hints[]` when `@c4a/extract-ts` or another code-capture dependency is unavailable. Run the requested `context capture --code ...` or `context capture --code ... --plan --format json` command directly, then follow the CLI's `agent_hints[]` if it fails.
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
sh -c 'CTX_BIN="$(command -v context)" && node -e "const { createRequire } = require(\"node:module\"); createRequire(process.argv[1]).resolve(\"@c4a/extract-ts\");" "$CTX_BIN"'
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
If the check fails, stop the capture task and surface the CLI's `agent_hints[]` install command (the CLI picks `npm install -g` or `bun install -g` based on how `context` itself was installed). Ask the user once whether to run that command on their behalf; global installs touch shared state, so explicit confirmation is required before invoking `Bash`. If approved, run the exact command from `agent_hints[0].command`, then retry the original `context capture --code ...` invocation. If declined, leave the command visible so the user can run it manually. Do not inline `@c4a/extract-ts`, do not hand-write code snapshots, and do not continue with partial capture.
|
|
26
|
-
|
|
27
|
-
Invocation note: code capture does not run through `npx`. `context capture --code` resolves `@c4a/extract` and `@c4a/extract-ts` from the installed `@c4a/context-cli` package using Node package resolution, prepares a user-cache aspect runner wrapper, and executes that wrapper directly. The plugin must therefore be available to the same global install that provides `context`.
|
|
21
|
+
Invocation note: code capture does not run through `npx`. `context capture --code` resolves `@c4a/extract` and `@c4a/extract-ts` from the installed `@c4a/context-cli` package using its own runtime package resolution, prepares a user-cache aspect runner wrapper, and executes that wrapper directly. Do not substitute a hand-written resolver check for the CLI.
|
|
28
22
|
|
|
29
23
|
### Route by argument
|
|
30
24
|
|
|
@@ -35,9 +29,11 @@ Invocation note: code capture does not run through `npx`. `context capture --cod
|
|
|
35
29
|
- `$ARGUMENTS` contains `--refresh` → `context capture --refresh`. This refreshes active Feishu URL sources and local Markdown sources whose stored origin file still exists; code sources use `context capture --code`.
|
|
36
30
|
- User asks for code capture with explicit `--module` flags → run `context capture --code $ARGUMENTS`, preserving code flags such as `--module`, `--version`, `--version-from`, and `--no-runner-cache`.
|
|
37
31
|
- User asks to refresh/re-capture an already configured code source → run `context capture --code` unless the user explicitly wants to change package selection or version flags. The CLI reuses stored `capture_config`, appends a new snapshot only when code/version content changes, and never overwrites prior snapshots.
|
|
32
|
+
- User provides multiple code target paths → run the code-capture flow once per target path. `context capture --code` accepts only one target path per invocation.
|
|
38
33
|
- User asks for code capture without explicit `--module` flags → first run `context capture --code $ARGUMENTS --plan --format json`.
|
|
39
34
|
- Present only candidate package name, module path, and version. Do not show file counts or the derived path filter.
|
|
40
|
-
-
|
|
35
|
+
- If the plan returns exactly one candidate package, run `context capture --code <original-target-if-present> --module <candidate.path> --format json` immediately.
|
|
36
|
+
- If the plan returns multiple candidate packages, ask the user which package paths to capture. If the host interaction supports multi-select, allow multi-select; otherwise ask the user to reply with one or more package paths/names.
|
|
41
37
|
- Then run `context capture --code` with one repeated `--module <path>` for every selected package. The CLI derives and stores path filtering silently from that selection.
|
|
42
38
|
- User asks to record conversation material, a decision, a revision intent, or a temporary observation → use note capture:
|
|
43
39
|
- Classify once as `revision`, `decision`, or `brainstorm`; temporary observations are `brainstorm`. If unclear, ask one clarification.
|
|
@@ -45,7 +41,7 @@ Invocation note: code capture does not run through `npx`. `context capture --cod
|
|
|
45
41
|
- Write the body to `context capture --note --intent <intent> --anchor <node-slug>[#<section-id>] --input -` for anchored notes, or omit `--anchor` for brainstorm.
|
|
46
42
|
- For `revision`, organize the stdin Markdown with headings: `旧上下文`, `修改意图`, `新内容`, `验证条件`.
|
|
47
43
|
- For `decision`, organize the stdin Markdown with headings: `议题`, `选项`, `决议`, `理由`.
|
|
48
|
-
- After capture, run `context status --format json` and base the user-facing next step on `next_step.command` / `workflow.next_step`.
|
|
44
|
+
- After capture, run `context status --view summary --format json` and base the user-facing next step on `next_step.command` / `workflow.next_step`.
|
|
49
45
|
|
|
50
46
|
For stdin batches, use this shape:
|
|
51
47
|
|
|
@@ -62,12 +58,12 @@ Do not pipe the heredoc through another command, and do not discover files with
|
|
|
62
58
|
|
|
63
59
|
Report the CLI output verbatim. If the CLI reports `N sources changed`, suggest the right next step:
|
|
64
60
|
|
|
65
|
-
- Run `context status --format json` and use its `next_step.command` / `workflow.next_step`.
|
|
61
|
+
- Run `context status --view summary --format json` and use its `next_step.command` / `workflow.next_step`.
|
|
66
62
|
- If status says aligned knowledge is missing or alignment is required → suggest `/context:align`.
|
|
67
63
|
- If status says compile work is pending for Markdown / evidence-backed knowledge → suggest `/context:compile`. Mention `/context:align` only if the user wants to revise the structure.
|
|
68
|
-
- If the capture was code-only and status
|
|
64
|
+
- If the capture was code-only and status suggests `context compile --code <slug>`, surface that exact command. Do not suggest bare `/context:compile` for code-only sources.
|
|
69
65
|
|
|
70
|
-
Never suggest `/context:compile` when no align plan exists or when the only active source is `aspect:code` raw snapshot data
|
|
66
|
+
Never suggest bare `/context:compile` when no align plan exists or when the only active source is `aspect:code` raw snapshot data. Use `context compile --code <slug>` for deterministic code projection, or `context source get <source-id>` when the user only wants to inspect the captured raw code source.
|
|
71
67
|
|
|
72
68
|
If capture is rejected with `agent_hints[].code = "workflow-cross-family-rejected"`, do **not** run `context workflow abandon ...` automatically. First run or ask the user to run `context workflow status --format json` and explain that another workflow is active in this workspace. Continue that workflow when it is the intended task; ask the user before abandoning it when the user wants to discard that in-progress work. If the user expected a different repository/workspace, change to the confirmed workspace root before retrying capture.
|
|
73
69
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: "Compile the confirmed align plan into knowledge articles: draft, semantic reconciliation, apply, then close."
|
|
3
|
-
argument-hint: "[--plan]"
|
|
3
|
+
argument-hint: "[--plan | --code [slug]]"
|
|
4
4
|
allowed-tools: Bash(context:*)
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -27,10 +27,12 @@ Modes:
|
|
|
27
27
|
- **`--plan`** (opt-in when `$ARGUMENTS` contains `--plan`) — per Node, run `context compile --draft <slug> --input - --plan` so the CLI validates stdin draft content without writing active knowledge; surface a user-facing change list (new knowledge, replaced knowledge, unchanged knowledge, and why) while keeping internal Section ids / source refs in details only when needed, then **stop at the end of the per-Node loop — do NOT run close**. The user re-runs `/context:compile` without `--plan` to apply; that run does the real writes + close.
|
|
28
28
|
- **`--code [slug]`** — run the CLI-owned code projection route directly with `context compile --code [slug]`; it does not enter draft/reconcile and uses the same deterministic implementation as `context align --code`.
|
|
29
29
|
|
|
30
|
+
Code mode short-circuit: if `$ARGUMENTS` contains `--code`, run `context compile --code [slug]` immediately, relay the CLI output, and stop. Do not run the default compile doctor/draft/reconcile preflight for code projection.
|
|
31
|
+
|
|
30
32
|
Delegated workflow mode:
|
|
31
33
|
|
|
32
34
|
- If the user explicitly authorized托管/全自动/delegated mode at the start of this conversation, add `--delegated` to the first compile workflow-creating command, preferably `context compile --scan-changes --delegated --format json`. Do not add it for vague "continue" / "继续" permission.
|
|
33
|
-
- `--delegated` is a workflow-level authorization, not a per-review override. It only lets the CLI auto-accept low-risk weak support when
|
|
35
|
+
- `--delegated` is a workflow-level authorization, not a per-review override. It only lets the CLI auto-accept low-risk weak lexical support when `source_support.missing_hard_terms` is empty; missing hard facts, type drift, schema errors, ownership/structure challenges, and destructive gates still block.
|
|
34
36
|
- Never hand-author `decided_by: delegated_agent`; the CLI injects it only inside a delegated compile workflow.
|
|
35
37
|
|
|
36
38
|
Language policy: your explanatory prose and final reports follow the user's conversation language. Node titles, summaries, and user-facing draft explanations follow `NodeContext.generation_policy.language` when the CLI provides it. Source-bound compile draft `content` should stay close to the cited source language when it differs from the workspace language; do not translate cited English facts into Chinese just to match the workspace. Section `summary` is a compact reader/query aid derived from `content`; source_support hard-term matching checks `content`, not `summary`. Preserve product names, code identifiers, CLI flags, slugs, `block_id` / `source_ref` tokens, and exact quoted evidence as printed. CLI stdout/stderr, the canonical `processing <slug>` lines, paths, slugs, block ids, source refs, issue codes, flags, and command names stay as printed.
|
|
@@ -40,7 +42,7 @@ Stable prompt/output policy: keep fixed protocol, schema, mount matrix, and work
|
|
|
40
42
|
Preflight:
|
|
41
43
|
|
|
42
44
|
1. Run `context doctor`; output-align group must be green. If it reports missing aligned knowledge, tell the user to run `/context:align` and stop. Incremental cache group warnings are informational here; only output-align errors block compile.
|
|
43
|
-
2. Run `context mdrive workspace stats --format json`, `context source list --format json`, and `context status --format json`; record the before counts and `STATUS.semantic.refreshed_source_pending_compile.source_ids[]`. This status means newer raw snapshots exist; it does not mean finalized ownership or `node.sources[]` are already refreshed.
|
|
45
|
+
2. Run `context mdrive workspace stats --format json`, `context source list --format json`, and `context status --view summary --format json`; record the before counts and `STATUS.semantic.refreshed_source_pending_compile.source_ids[]`. This status means newer raw snapshots exist; it does not mean finalized ownership or `node.sources[]` are already refreshed.
|
|
44
46
|
3. Run `context compile --scan-changes --format json` and parse the JSON as `COMPILE_WORKSET`. If delegated workflow mode is explicitly authorized, run `context compile --scan-changes --delegated --format json` for this first scan instead. `--scan-changes` is the only workset scan flag; `--plan` is reserved for draft validation.
|
|
45
47
|
- If `context workflow status --format json` has `current: null` but `last_published` is present, continue with `context compile --scan-changes`; the published finalized ownership is still the workspace structure truth. Use `context workflow list --format json` only when you need lineage/history diagnostics.
|
|
46
48
|
- Compile JSON may include `source_finalize`; use it as lineage for the finalized ownership that produced the current Node set and citation ownership.
|
|
@@ -27,6 +27,7 @@ decisions only; the CLI reviews, applies, and writes every workspace change.
|
|
|
27
27
|
- Escape hatch: when an item has no candidates, `relation_verdict: new` with `compared_section_ids: []` and `compared_count: 0` is valid and expected.
|
|
28
28
|
- For `duplicate`, `supersede`, `conflict`, or `merge_into`, set `target_section_id` to the matched candidate Section id.
|
|
29
29
|
- Same `source_ref` can support different Section kinds only when the semantic role differs. Detect and explain same-source-ref multi-kind cases instead of treating them as automatic duplicates.
|
|
30
|
+
- A supported judge verdict may override low lexical `source_support` only when the cited raw evidence covers the hard facts. If `source_support.missing_hard_terms[]` names real missing facts, do not mark support as supported.
|
|
30
31
|
- Weak support is a warning-level verdict, not permission to invent missing facts. Unsupported support should normally pair with `conflict` or a later user question rather than a write decision.
|
|
31
32
|
|
|
32
33
|
<reference>
|