codecartographer-pi 0.6.0 → 0.6.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.
package/README.md
CHANGED
|
@@ -77,26 +77,36 @@ If you install the whole repository as a Pi package, Pi may still run package in
|
|
|
77
77
|
What the Pi extension adds:
|
|
78
78
|
|
|
79
79
|
- `/codecarto-init` to copy `.codecarto/` into the current repository
|
|
80
|
-
- `/codecarto-next` to
|
|
80
|
+
- `/codecarto-next [--llm-steer | --no-llm-steer]` to spawn the next eligible phase as a sub-agent (the optional flag opts into the LLM-rewriter for the seed prompt; see *Phase orchestration* below)
|
|
81
81
|
- `/codecarto-status` to show current phase progress
|
|
82
82
|
- `/codecarto-validate` and `/codecarto-complete` for validation-gated status updates
|
|
83
|
-
- a
|
|
83
|
+
- `/codecarto-phase <id>` to force a specific phase even out of pipeline order
|
|
84
|
+
- `/codecarto-skill <name>` to run a post-pipeline skill once all phases are complete
|
|
85
|
+
- `/codecarto-usage` to show cumulative + per-phase token usage from local phase runs (0.6.0+)
|
|
86
|
+
- a footer/widget showing the active CodeCartographer phase, plus a live **Agents** widget above the editor while a phase sub-agent is running
|
|
84
87
|
- tool interception that blocks `edit` and `write` outside `.codecarto/`
|
|
85
88
|
- direct phase prompts that tell Pi exactly which `.codecarto/findings/<phase>/SKILL.md` file to read, without registering those internal files as global Pi skills
|
|
86
89
|
|
|
87
|
-
### Phase
|
|
90
|
+
### Phase orchestration (0.2.0 – 0.6.0)
|
|
88
91
|
|
|
89
|
-
`/codecarto-next` runs each phase as an isolated
|
|
92
|
+
`/codecarto-next` runs each phase as an isolated `AgentSession` while your TUI stays on the orchestrator session. The phase's tool calls, file reads, and reasoning live in the child's own context window — they never accumulate in the orchestrator. A persistent **Agents** widget appears above the editor while a phase is running, showing live tool count, token usage, elapsed time, and the current activity. The widget auto-clears once the phase finishes (and lingers a few seconds after for visibility).
|
|
90
93
|
|
|
91
94
|
```
|
|
92
95
|
● CodeCartographer
|
|
93
|
-
└─ ⠹ architecture phase ⟳3 · 5 tool uses · 12.3k tokens · 1m32s
|
|
96
|
+
└─ ⠹ architecture phase ⟳ 3 · 5 tool uses · 12.3k tokens · 1m32s
|
|
94
97
|
⎿ reading…
|
|
95
98
|
```
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
Capabilities layered on top of the parallel-widget runner:
|
|
98
101
|
|
|
99
|
-
|
|
102
|
+
- **0.3.0 — file-backed sessions.** Phase sub-agents persist their transcripts to the same `~/.pi/agent/sessions/<encoded-cwd>/` directory the orchestrator uses, so Pi's `/resume`, `/tree`, and `/export` browse them as first-class sessions. The picker shows them with an explicit `CodeCartographer phase: <id>` name and lineage back to the orchestrator's own session.
|
|
103
|
+
- **0.4.0 — phase-completion summary.** When a phase finishes (completed, aborted, or errored), a Markdown closeout block is appended to the orchestrator's transcript via `pi.sendMessage(...)`. You see it in the TUI scrollback; the orchestrator's LLM picks it up as context on your next message. No auto-trigger — control of the next step stays with you.
|
|
104
|
+
- **0.5.0 — opt-in LLM-steered seed prompt.** Set `orchestrator.llm_steer_next_phase: true` in `.codecarto/workflow/config.yaml`, or pass `--llm-steer` per invocation, and the orchestrator's model will run a one-shot rewriter that reads the previous phase's closeout and customizes the next phase's seed prompt to highlight relevant prior findings. Off by default — extra orchestrator-side tokens, opt-in.
|
|
105
|
+
- **0.6.0 — local usage log.** Each phase run is appended to `.codecarto/workflow/.usage.local.yaml` (gitignored). `/codecarto-usage` reports cumulative + per-phase totals. Best-effort logging — write failures don't surface as phase errors.
|
|
106
|
+
|
|
107
|
+
Versions 0.1.3 – 0.1.4 used a different design — a session-switching pattern via `ctx.newSession()` that flipped the TUI to the child. That delivered context isolation but the switch was visually invisible during normal flow, so 0.2.0 replaced it with the parallel-widget approach. 0.1.x workspaces don't need migration; existing `.codecarto/` directories work with 0.6.0 unchanged.
|
|
108
|
+
|
|
109
|
+
The MCP-server path is unaffected — it has no session concept; the host (Claude Desktop / Claude Code / etc.) is always the orchestrator. `/codecarto-usage` is Pi-only; the MCP path doesn't run sub-agents itself, so there's no per-phase usage to track on that side.
|
|
100
110
|
|
|
101
111
|
## MCP Server
|
|
102
112
|
|
|
@@ -10,6 +10,8 @@ export interface RewritePhasePromptResult {
|
|
|
10
10
|
prompt: string;
|
|
11
11
|
used: boolean;
|
|
12
12
|
skipReason?: string;
|
|
13
|
+
/** ID of the previous phase whose closeout the rewriter read, when used. */
|
|
14
|
+
prevPhaseId?: string;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* Run the rewriter and return the customized seed prompt. On any failure
|
|
@@ -18,3 +20,14 @@ export interface RewritePhasePromptResult {
|
|
|
18
20
|
* throws. The caller decides what to surface to the user.
|
|
19
21
|
*/
|
|
20
22
|
export declare function rewritePhasePrompt(input: RewritePhasePromptInput): Promise<RewritePhasePromptResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Build the markdown block injected into the orchestrator's session
|
|
25
|
+
* (via pi.sendMessage with customType "codecarto-steering") whenever the
|
|
26
|
+
* rewriter produces a customized seed. Lets the user audit what the
|
|
27
|
+
* rewriter chose to emphasize before the phase sub-agent starts.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildSteeringMessage(input: {
|
|
30
|
+
nextPhaseId: string;
|
|
31
|
+
prevPhaseId?: string;
|
|
32
|
+
rewrittenPrompt: string;
|
|
33
|
+
}): string;
|
|
@@ -48,7 +48,27 @@ export async function rewritePhasePrompt(input) {
|
|
|
48
48
|
if (!trimmed) {
|
|
49
49
|
return { prompt: originalPrompt, used: false, skipReason: "rewriter returned empty output" };
|
|
50
50
|
}
|
|
51
|
-
return { prompt: trimmed, used: true };
|
|
51
|
+
return { prompt: trimmed, used: true, prevPhaseId };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build the markdown block injected into the orchestrator's session
|
|
55
|
+
* (via pi.sendMessage with customType "codecarto-steering") whenever the
|
|
56
|
+
* rewriter produces a customized seed. Lets the user audit what the
|
|
57
|
+
* rewriter chose to emphasize before the phase sub-agent starts.
|
|
58
|
+
*/
|
|
59
|
+
export function buildSteeringMessage(input) {
|
|
60
|
+
const provenance = input.prevPhaseId
|
|
61
|
+
? `customized by the orchestrator's LLM from \`${input.prevPhaseId}\`'s closeout`
|
|
62
|
+
: "customized by the orchestrator's LLM";
|
|
63
|
+
return [
|
|
64
|
+
`**Steering: \`${input.nextPhaseId}\` seed prompt**`,
|
|
65
|
+
"",
|
|
66
|
+
`_${provenance}. The phase sub-agent will receive the prompt below as its first user message._`,
|
|
67
|
+
"",
|
|
68
|
+
"---",
|
|
69
|
+
"",
|
|
70
|
+
input.rewrittenPrompt,
|
|
71
|
+
].join("\n");
|
|
52
72
|
}
|
|
53
73
|
function findPreviousPhaseId(state, nextPhaseId) {
|
|
54
74
|
const order = state.pipeline.phase_order;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import { basename, join, resolve } from "node:path";
|
|
3
3
|
import { runPhase } from "./agent-runner.js";
|
|
4
|
-
import { rewritePhasePrompt } from "./agent-rewriter.js";
|
|
4
|
+
import { buildSteeringMessage, rewritePhasePrompt } from "./agent-rewriter.js";
|
|
5
5
|
import { clearPhase, finishPhase, getPhaseActivity, startPhase } from "./agent-state.js";
|
|
6
6
|
import { buildPhaseSummary } from "./agent-summary.js";
|
|
7
7
|
import { disposeAgentsWidget, getAgentsWidget } from "./agent-widget.js";
|
|
@@ -258,6 +258,20 @@ export default function codeCartographerExtension(pi) {
|
|
|
258
258
|
if (rewrite.used) {
|
|
259
259
|
prompt = rewrite.prompt;
|
|
260
260
|
ctx.ui.notify(`LLM rewriter customized ${phase.id} seed prompt.`, "info");
|
|
261
|
+
// Inject the full rewritten prompt into the orchestrator's session
|
|
262
|
+
// so the user can audit what the rewriter chose to emphasize before
|
|
263
|
+
// the phase sub-agent starts. Same pattern as the phase-completion
|
|
264
|
+
// summary: display:true renders in the TUI; no triggerTurn so the
|
|
265
|
+
// orchestrator doesn't auto-respond.
|
|
266
|
+
pi.sendMessage({
|
|
267
|
+
customType: "codecarto-steering",
|
|
268
|
+
content: buildSteeringMessage({
|
|
269
|
+
nextPhaseId: phase.id,
|
|
270
|
+
prevPhaseId: rewrite.prevPhaseId,
|
|
271
|
+
rewrittenPrompt: rewrite.prompt,
|
|
272
|
+
}),
|
|
273
|
+
display: true,
|
|
274
|
+
});
|
|
261
275
|
}
|
|
262
276
|
else {
|
|
263
277
|
ctx.ui.notify(`LLM rewriter skipped (${rewrite.skipReason}); using stock prompt.`, "warning");
|