@gotgenes/pi-subagents 6.16.3 → 6.17.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/CHANGELOG.md +27 -0
- package/docs/architecture/architecture.md +588 -535
- package/docs/architecture/history/phase-1-api-boundary.md +8 -0
- package/docs/architecture/history/phase-2-remove-scheduling.md +9 -0
- package/docs/architecture/history/phase-3-remove-rpc-groupjoin.md +11 -0
- package/docs/architecture/history/phase-4-implement-service.md +8 -0
- package/docs/architecture/history/phase-5-decompose-index.md +42 -0
- package/docs/architecture/history/phase-7-encapsulation.md +173 -0
- package/docs/architecture/history/phase-8-testability.md +103 -0
- package/docs/architecture/history/phase-9-observation-ctx.md +122 -0
- package/docs/plans/0147-inject-wrap-text-into-conversation-viewer.md +166 -0
- package/docs/retro/0147-inject-wrap-text-into-conversation-viewer.md +90 -0
- package/package.json +1 -1
- package/src/agent-manager.ts +11 -11
- package/src/agent-record.ts +6 -6
- package/src/agent-runner.ts +6 -6
- package/src/agent-types.ts +2 -2
- package/src/custom-agents.ts +3 -3
- package/src/default-agents.ts +1 -1
- package/src/env.ts +2 -2
- package/src/handlers/index.ts +2 -2
- package/src/index.ts +26 -26
- package/src/invocation-config.ts +1 -1
- package/src/memory.ts +2 -2
- package/src/notification.ts +4 -4
- package/src/parent-snapshot.ts +1 -1
- package/src/prompts.ts +2 -2
- package/src/record-observer.ts +2 -2
- package/src/renderer.ts +2 -2
- package/src/runtime.ts +2 -2
- package/src/service-adapter.ts +5 -5
- package/src/service.ts +1 -1
- package/src/session-config.ts +5 -5
- package/src/skill-loader.ts +2 -2
- package/src/tools/agent-tool.ts +11 -11
- package/src/tools/background-spawner.ts +8 -8
- package/src/tools/foreground-runner.ts +9 -9
- package/src/tools/get-result-tool.ts +5 -5
- package/src/tools/helpers.ts +4 -4
- package/src/tools/spawn-config.ts +6 -6
- package/src/tools/steer-tool.ts +3 -3
- package/src/types.ts +1 -1
- package/src/ui/agent-activity-tracker.ts +1 -1
- package/src/ui/agent-config-editor.ts +4 -4
- package/src/ui/agent-creation-wizard.ts +5 -5
- package/src/ui/agent-menu.ts +12 -10
- package/src/ui/agent-widget.ts +5 -5
- package/src/ui/conversation-viewer.ts +33 -21
- package/src/ui/display.ts +2 -2
- package/src/ui/ui-observer.ts +1 -1
- package/src/ui/widget-renderer.ts +5 -5
- package/src/worktree-state.ts +1 -1
- package/src/worktree.ts +1 -1
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
issue: 147
|
|
3
|
+
issue_title: "Inject text wrapping into ConversationViewer (Phase 9, Step O)"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Retro: #147 — Inject text wrapping into ConversationViewer (Phase 9, Step O)
|
|
7
|
+
|
|
8
|
+
## Stage: Planning (2026-05-23T00:00:00Z)
|
|
9
|
+
|
|
10
|
+
### Session summary
|
|
11
|
+
|
|
12
|
+
Read the issue, loaded package-pi-subagents, code-design, testing, and markdown-conventions skills.
|
|
13
|
+
Explored `src/ui/conversation-viewer.ts`, `src/ui/agent-menu.ts`, `test/conversation-viewer.test.ts`, and the Phase 9 architecture roadmap.
|
|
14
|
+
Wrote and committed the plan at `packages/pi-subagents/docs/plans/0147-inject-wrap-text-into-conversation-viewer.md`.
|
|
15
|
+
|
|
16
|
+
### Observations
|
|
17
|
+
|
|
18
|
+
- The change is tightly scoped: two source files (`conversation-viewer.ts`, `agent-menu.ts`) and one test file.
|
|
19
|
+
- `wrapTextWithAnsi` is called in exactly four places inside `buildContentLines` — all in the same private method, making the replacement straightforward.
|
|
20
|
+
- The only production call site for `new ConversationViewer({…})` is `viewAgentConversation` in `agent-menu.ts`.
|
|
21
|
+
`wrapTextWithAnsi` is added as a static import there and passed as `wrapText` — no threading through `AgentMenuDeps` needed.
|
|
22
|
+
- All `new ConversationViewer({…})` calls in the test file are inline (no shared factory helper), so every call site needs the new `wrapText` field added.
|
|
23
|
+
Grep confirms the count: 11+ calls, all in `test/conversation-viewer.test.ts`.
|
|
24
|
+
- The plan uses 2 TDD cycles: Cycle 1 adds the field and updates all call sites (with the `vi.mock` still present for safety); Cycle 2 removes the mock and converts dynamic `await import()` to static imports.
|
|
25
|
+
This ordering avoids a large simultaneous change and gives the suite a stable intermediate state.
|
|
26
|
+
- The "mock is intercepting wrapTextWithAnsi" test is deleted in Cycle 1 (it verified the mock mechanism, not production behavior).
|
|
27
|
+
- No exported API symbols are removed; `wrapText` is a new required field on `ConversationViewerOptions`, which is a breaking change only for external constructors of `ConversationViewer` — confirmed none exist outside this package.
|
|
28
|
+
|
|
29
|
+
## Stage: Implementation — TDD (2026-05-23T11:36:00Z)
|
|
30
|
+
|
|
31
|
+
### Session summary
|
|
32
|
+
|
|
33
|
+
Completed both TDD cycles from the plan.
|
|
34
|
+
Cycle 1 added `wrapText` to `ConversationViewerOptions`, destructured options in the constructor, replaced all four `wrapTextWithAnsi` calls with `this.wrapText`, updated `agent-menu.ts` to import and pass `wrapTextWithAnsi`, and updated all 16 test constructor call sites (11 render-width-safety + 5 safety-net) while keeping the `vi.mock` shim in place.
|
|
35
|
+
Cycle 2 removed the `vi.mock` block, `wrapOverride`, and `beforeEach` reset, then converted the dynamic `await import()` calls to ordinary static imports.
|
|
36
|
+
Test count: 806 → 805 (deleted the mock-mechanism sentinel test).
|
|
37
|
+
Full suite 50 files, 805 tests, all green.
|
|
38
|
+
|
|
39
|
+
### Observations
|
|
40
|
+
|
|
41
|
+
- The plan said the render-width-safety constructor calls numbered "11+" — the actual count was 16 total (11 render-width-safety + 5 safety-net), all in `test/conversation-viewer.test.ts`.
|
|
42
|
+
No external call sites existed.
|
|
43
|
+
- `wrapTextWithAnsi` needed to be added to the dynamic import in Cycle 1 (`const { visibleWidth, wrapTextWithAnsi } = await import(...)`) because the render-width-safety tests reference it by name.
|
|
44
|
+
The plan didn't call this out explicitly — minor omission.
|
|
45
|
+
- Used a Python script (inline via bash) to make the 17 constructor-call edits rather than 17 separate Edit-tool calls.
|
|
46
|
+
The safety-net tests each had a different stub character (`X`, `Y`, `Z`, `B`, `W`) which required a regex capture group to preserve.
|
|
47
|
+
The script worked on the first attempt.
|
|
48
|
+
- Cycle 2 was a single Edit call replacing the entire mock block + the two dynamic imports + `beforeEach`.
|
|
49
|
+
The autoformatter then cleaned up import ordering automatically.
|
|
50
|
+
- Architecture doc updated: smells table row struck-through and Step O marked ✓.
|
|
51
|
+
|
|
52
|
+
## Stage: Final Retrospective (2026-05-23T11:45:00Z)
|
|
53
|
+
|
|
54
|
+
### Session summary
|
|
55
|
+
|
|
56
|
+
Planned, implemented, shipped, and released issue #147 across a single session chain.
|
|
57
|
+
Two TDD cycles completed cleanly; CI passed; issue closed; `pi-subagents-v6.17.0` released.
|
|
58
|
+
Test count: 806 → 805 (deleted mock-mechanism sentinel test).
|
|
59
|
+
|
|
60
|
+
### Observations
|
|
61
|
+
|
|
62
|
+
#### What went well
|
|
63
|
+
|
|
64
|
+
- Python script for bulk constructor edits worked first-try on 17 call sites with per-test regex capture groups.
|
|
65
|
+
This is now a proven pattern — #116 and #147 both used it successfully for `ConversationViewer` constructor changes.
|
|
66
|
+
- Two-cycle TDD approach (Cycle 1: add DI with mock still present; Cycle 2: remove mock) gave a stable intermediate state and caught the missing `wrapTextWithAnsi` import before proceeding.
|
|
67
|
+
- Scope was tight: 3 files changed, 2 commits of substance, no rework on the production code.
|
|
68
|
+
|
|
69
|
+
#### What caused friction (agent side)
|
|
70
|
+
|
|
71
|
+
1. `instruction-violation` — Failed to load the `colgrep` skill during planning.
|
|
72
|
+
Constructed the path by pattern (`.pi/skills/colgrep/SKILL.md`) instead of using the `<location>` listed in the `<available_skills>` block (`packages/pi-colgrep/skills/colgrep/SKILL.md`).
|
|
73
|
+
Got ENOENT and silently moved on.
|
|
74
|
+
Impact: user-caught; required a follow-up exchange to load the skill and re-review the plan.
|
|
75
|
+
No rework needed — the plan was already correct.
|
|
76
|
+
2. `wrong-abstraction` — Cycle 2 Edit replaced the entire `vi.mock` block + dynamic imports as one chunk, leaving the `ConversationViewer` static import stranded after `const testRegistry` instead of at the top with other imports.
|
|
77
|
+
Impact: user-caught ("Wait, we have a dynamic import?"); required a follow-up edit and amend into the retro commit.
|
|
78
|
+
3. `missing-context` — Plan stated "11+" constructor call sites; actual count was 16 (11 render-width-safety + 5 safety-net).
|
|
79
|
+
The grep output during planning showed all 16 but the count wasn't verified.
|
|
80
|
+
Impact: no rework — the Python script handled all 17 (16 test + 1 production) regardless.
|
|
81
|
+
|
|
82
|
+
#### What caused friction (user side)
|
|
83
|
+
|
|
84
|
+
- No friction identified — user interventions were timely and precise.
|
|
85
|
+
|
|
86
|
+
### Changes made
|
|
87
|
+
|
|
88
|
+
1. Appended this final retrospective entry to `packages/pi-subagents/docs/retro/0147-inject-wrap-text-into-conversation-viewer.md`.
|
|
89
|
+
2. Separated `colgrep` skill loading into its own bullet in `.pi/prompts/plan-issue.md` to reduce pattern-matching shortcuts.
|
|
90
|
+
3. Replaced deterministic step in `.pi/prompts/retro.md` with a "Sync with remote" section matching the other prompts.
|
package/package.json
CHANGED
package/src/agent-manager.ts
CHANGED
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import type { Model } from "@earendil-works/pi-ai";
|
|
11
11
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
12
|
-
import { AgentRecord } from "./agent-record
|
|
13
|
-
import type { AgentRunner } from "./agent-runner
|
|
14
|
-
import { AgentTypeRegistry } from "./agent-types
|
|
15
|
-
import { debugLog } from "./debug
|
|
16
|
-
import { NotificationState } from "./notification-state
|
|
17
|
-
import type { ParentSnapshot } from "./parent-snapshot
|
|
18
|
-
import { subscribeRecordObserver } from "./record-observer
|
|
19
|
-
import type { RunConfig } from "./runtime
|
|
20
|
-
import type { AgentInvocation, IsolationMode, ShellExec, SubagentType, ThinkingLevel } from "./types
|
|
21
|
-
import type { WorktreeManager } from "./worktree
|
|
22
|
-
import { WorktreeState } from "./worktree-state
|
|
12
|
+
import { AgentRecord } from "./agent-record";
|
|
13
|
+
import type { AgentRunner } from "./agent-runner";
|
|
14
|
+
import { AgentTypeRegistry } from "./agent-types";
|
|
15
|
+
import { debugLog } from "./debug";
|
|
16
|
+
import { NotificationState } from "./notification-state";
|
|
17
|
+
import type { ParentSnapshot } from "./parent-snapshot";
|
|
18
|
+
import { subscribeRecordObserver } from "./record-observer";
|
|
19
|
+
import type { RunConfig } from "./runtime";
|
|
20
|
+
import type { AgentInvocation, IsolationMode, ShellExec, SubagentType, ThinkingLevel } from "./types";
|
|
21
|
+
import type { WorktreeManager } from "./worktree";
|
|
22
|
+
import { WorktreeState } from "./worktree-state";
|
|
23
23
|
|
|
24
24
|
export type CompactionInfo = { reason: "manual" | "threshold" | "overflow"; tokensBefore: number };
|
|
25
25
|
|
package/src/agent-record.ts
CHANGED
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
16
|
-
import type { ExecutionState } from "./execution-state
|
|
17
|
-
import type { NotificationState } from "./notification-state
|
|
18
|
-
import type { AgentInvocation, SubagentType } from "./types
|
|
19
|
-
import type { LifetimeUsage } from "./usage
|
|
20
|
-
import { addUsage } from "./usage
|
|
21
|
-
import type { WorktreeState } from "./worktree-state
|
|
16
|
+
import type { ExecutionState } from "./execution-state";
|
|
17
|
+
import type { NotificationState } from "./notification-state";
|
|
18
|
+
import type { AgentInvocation, SubagentType } from "./types";
|
|
19
|
+
import type { LifetimeUsage } from "./usage";
|
|
20
|
+
import { addUsage } from "./usage";
|
|
21
|
+
import type { WorktreeState } from "./worktree-state";
|
|
22
22
|
|
|
23
23
|
export type AgentRecordStatus =
|
|
24
24
|
| "queued"
|
package/src/agent-runner.ts
CHANGED
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
type AgentSessionEvent,
|
|
9
9
|
type SettingsManager,
|
|
10
10
|
} from "@earendil-works/pi-coding-agent";
|
|
11
|
-
import type { AgentConfigLookup } from "./agent-types
|
|
12
|
-
import { extractText } from "./context
|
|
13
|
-
import type { EnvInfo } from "./env
|
|
14
|
-
import type { ParentSnapshot } from "./parent-snapshot
|
|
15
|
-
import { type AssemblerIO, assembleSessionConfig } from "./session-config
|
|
16
|
-
import type { ShellExec, SubagentType, ThinkingLevel } from "./types
|
|
11
|
+
import type { AgentConfigLookup } from "./agent-types";
|
|
12
|
+
import { extractText } from "./context";
|
|
13
|
+
import type { EnvInfo } from "./env";
|
|
14
|
+
import type { ParentSnapshot } from "./parent-snapshot";
|
|
15
|
+
import { type AssemblerIO, assembleSessionConfig } from "./session-config";
|
|
16
|
+
import type { ShellExec, SubagentType, ThinkingLevel } from "./types";
|
|
17
17
|
|
|
18
18
|
/** Names of tools registered by this extension that subagents must NOT inherit. */
|
|
19
19
|
const EXCLUDED_TOOL_NAMES = ["Agent", "get_subagent_result", "steer_subagent"];
|
package/src/agent-types.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* User agents override defaults with the same name. Disabled agents are kept but excluded from spawning.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { DEFAULT_AGENTS } from "./default-agents
|
|
9
|
-
import type { AgentConfig } from "./types
|
|
8
|
+
import { DEFAULT_AGENTS } from "./default-agents";
|
|
9
|
+
import type { AgentConfig } from "./types";
|
|
10
10
|
|
|
11
11
|
// ── AgentConfigLookup interface ──────────────────────────────────────────────
|
|
12
12
|
|
package/src/custom-agents.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
6
6
|
import { basename, join } from "node:path";
|
|
7
7
|
import { getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
8
|
-
import { BUILTIN_TOOL_NAMES } from "./agent-types
|
|
9
|
-
import { debugLog } from "./debug
|
|
10
|
-
import type { AgentConfig, MemoryScope, ThinkingLevel } from "./types
|
|
8
|
+
import { BUILTIN_TOOL_NAMES } from "./agent-types";
|
|
9
|
+
import { debugLog } from "./debug";
|
|
10
|
+
import type { AgentConfig, MemoryScope, ThinkingLevel } from "./types";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Scan for custom agent .md files from multiple locations.
|
package/src/default-agents.ts
CHANGED
package/src/env.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* env.ts — Detect environment info (git, platform) for subagent system prompts.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { debugLog } from "./debug
|
|
6
|
-
import type { ShellExec } from "./types
|
|
5
|
+
import { debugLog } from "./debug";
|
|
6
|
+
import type { ShellExec } from "./types";
|
|
7
7
|
|
|
8
8
|
export interface EnvInfo {
|
|
9
9
|
isGitRepo: boolean;
|
package/src/handlers/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { SessionLifecycleHandler } from "./lifecycle
|
|
2
|
-
export { ToolStartHandler } from "./tool-start
|
|
1
|
+
export { SessionLifecycleHandler } from "./lifecycle";
|
|
2
|
+
export { ToolStartHandler } from "./tool-start";
|
package/src/index.ts
CHANGED
|
@@ -20,35 +20,35 @@ import {
|
|
|
20
20
|
SettingsManager as SdkSettingsManager,
|
|
21
21
|
SessionManager,
|
|
22
22
|
} from "@earendil-works/pi-coding-agent";
|
|
23
|
-
import { AgentManager, type AgentManagerObserver } from "./agent-manager
|
|
24
|
-
import { createAgentRunner, getAgentConversation, type RunnerIO, steerAgent } from "./agent-runner
|
|
25
|
-
import { AgentTypeRegistry } from "./agent-types
|
|
26
|
-
import { loadCustomAgents } from "./custom-agents
|
|
27
|
-
import { detectEnv } from "./env
|
|
28
|
-
import { SessionLifecycleHandler, ToolStartHandler } from "./handlers/index
|
|
29
|
-
import { buildMemoryBlock, buildReadOnlyMemoryBlock } from "./memory
|
|
30
|
-
import { type ModelRegistry, resolveModel } from "./model-resolver
|
|
31
|
-
import { buildEventData, type NotificationDetails, NotificationManager } from "./notification
|
|
32
|
-
import { buildParentSnapshot } from "./parent-snapshot
|
|
33
|
-
import { buildAgentPrompt } from "./prompts
|
|
34
|
-
import { createNotificationRenderer } from "./renderer
|
|
35
|
-
import { createSubagentRuntime } from "./runtime
|
|
36
|
-
import { publishSubagentsService, unpublishSubagentsService } from "./service
|
|
37
|
-
import { createSubagentsService } from "./service-adapter
|
|
38
|
-
import { deriveSubagentSessionDir } from "./session-dir
|
|
39
|
-
import { SettingsManager } from "./settings
|
|
40
|
-
import { preloadSkills } from "./skill-loader
|
|
41
|
-
import { createAgentTool } from "./tools/agent-tool
|
|
42
|
-
import { createGetResultTool } from "./tools/get-result-tool
|
|
43
|
-
import { getModelLabelFromConfig } from "./tools/helpers
|
|
44
|
-
import { createSteerTool } from "./tools/steer-tool
|
|
45
|
-
import { FsAgentFileOps } from "./ui/agent-file-ops
|
|
46
|
-
import { createAgentsMenuHandler } from "./ui/agent-menu
|
|
23
|
+
import { AgentManager, type AgentManagerObserver } from "./agent-manager";
|
|
24
|
+
import { createAgentRunner, getAgentConversation, type RunnerIO, steerAgent } from "./agent-runner";
|
|
25
|
+
import { AgentTypeRegistry } from "./agent-types";
|
|
26
|
+
import { loadCustomAgents } from "./custom-agents";
|
|
27
|
+
import { detectEnv } from "./env";
|
|
28
|
+
import { SessionLifecycleHandler, ToolStartHandler } from "./handlers/index";
|
|
29
|
+
import { buildMemoryBlock, buildReadOnlyMemoryBlock } from "./memory";
|
|
30
|
+
import { type ModelRegistry, resolveModel } from "./model-resolver";
|
|
31
|
+
import { buildEventData, type NotificationDetails, NotificationManager } from "./notification";
|
|
32
|
+
import { buildParentSnapshot } from "./parent-snapshot";
|
|
33
|
+
import { buildAgentPrompt } from "./prompts";
|
|
34
|
+
import { createNotificationRenderer } from "./renderer";
|
|
35
|
+
import { createSubagentRuntime } from "./runtime";
|
|
36
|
+
import { publishSubagentsService, unpublishSubagentsService } from "./service";
|
|
37
|
+
import { createSubagentsService } from "./service-adapter";
|
|
38
|
+
import { deriveSubagentSessionDir } from "./session-dir";
|
|
39
|
+
import { SettingsManager } from "./settings";
|
|
40
|
+
import { preloadSkills } from "./skill-loader";
|
|
41
|
+
import { createAgentTool } from "./tools/agent-tool";
|
|
42
|
+
import { createGetResultTool } from "./tools/get-result-tool";
|
|
43
|
+
import { getModelLabelFromConfig } from "./tools/helpers";
|
|
44
|
+
import { createSteerTool } from "./tools/steer-tool";
|
|
45
|
+
import { FsAgentFileOps } from "./ui/agent-file-ops";
|
|
46
|
+
import { createAgentsMenuHandler } from "./ui/agent-menu";
|
|
47
47
|
import {
|
|
48
48
|
AgentWidget,
|
|
49
49
|
type UICtx,
|
|
50
|
-
} from "./ui/agent-widget
|
|
51
|
-
import { GitWorktreeManager } from "./worktree
|
|
50
|
+
} from "./ui/agent-widget";
|
|
51
|
+
import { GitWorktreeManager } from "./worktree";
|
|
52
52
|
|
|
53
53
|
export default function (pi: ExtensionAPI) {
|
|
54
54
|
// ---- Register custom notification renderer ----
|
package/src/invocation-config.ts
CHANGED
package/src/memory.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
import { existsSync, lstatSync, mkdirSync, readFileSync } from "node:fs";
|
|
11
11
|
import { homedir } from "node:os";
|
|
12
12
|
import { join, } from "node:path";
|
|
13
|
-
import { debugLog } from "./debug
|
|
14
|
-
import type { MemoryScope } from "./types
|
|
13
|
+
import { debugLog } from "./debug";
|
|
14
|
+
import type { MemoryScope } from "./types";
|
|
15
15
|
|
|
16
16
|
/** Maximum lines to read from MEMORY.md */
|
|
17
17
|
const MAX_MEMORY_LINES = 200;
|
package/src/notification.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { debugLog } from "./debug
|
|
2
|
-
import type { AgentRecord } from "./types
|
|
3
|
-
import type { AgentActivityTracker } from "./ui/agent-activity-tracker
|
|
4
|
-
import { getLifetimeTotal, getSessionContextPercent } from "./usage
|
|
1
|
+
import { debugLog } from "./debug";
|
|
2
|
+
import type { AgentRecord } from "./types";
|
|
3
|
+
import type { AgentActivityTracker } from "./ui/agent-activity-tracker";
|
|
4
|
+
import { getLifetimeTotal, getSessionContextPercent } from "./usage";
|
|
5
5
|
|
|
6
6
|
/** Details attached to custom notification messages for visual rendering. */
|
|
7
7
|
export interface NotificationDetails {
|
package/src/parent-snapshot.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
|
-
import { buildParentContext } from "./context
|
|
6
|
+
import { buildParentContext } from "./context";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Plain data snapshot of the parent session state captured at spawn time.
|
package/src/prompts.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* prompts.ts — System prompt builder for agents.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { EnvInfo } from "./env
|
|
6
|
-
import type { AgentPromptConfig } from "./types
|
|
5
|
+
import type { EnvInfo } from "./env";
|
|
6
|
+
import type { AgentPromptConfig } from "./types";
|
|
7
7
|
|
|
8
8
|
/** Extra sections to inject into the system prompt (memory, skills, etc.). */
|
|
9
9
|
export interface PromptExtras {
|
package/src/record-observer.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and resume() with a single direct subscription.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { CompactionInfo } from "./agent-manager
|
|
9
|
-
import type { AgentRecord } from "./agent-record
|
|
8
|
+
import type { CompactionInfo } from "./agent-manager";
|
|
9
|
+
import type { AgentRecord } from "./agent-record";
|
|
10
10
|
|
|
11
11
|
/** Narrow session interface — only the subscribe method needed by the observer. */
|
|
12
12
|
interface SubscribableSession {
|
package/src/renderer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Text } from "@earendil-works/pi-tui";
|
|
2
|
-
import type { NotificationDetails } from "./notification
|
|
3
|
-
import { formatMs, formatTokens, formatTurns } from "./ui/display
|
|
2
|
+
import type { NotificationDetails } from "./notification";
|
|
3
|
+
import { formatMs, formatTokens, formatTurns } from "./ui/display";
|
|
4
4
|
|
|
5
5
|
/** Narrow theme interface — only the methods the renderer actually calls. */
|
|
6
6
|
interface RendererTheme {
|
package/src/runtime.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Follows the same pattern as pi-permission-system's ExtensionRuntime.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { AgentActivityTracker } from "./ui/agent-activity-tracker
|
|
10
|
-
import type { UICtx } from "./ui/agent-widget
|
|
9
|
+
import type { AgentActivityTracker } from "./ui/agent-activity-tracker";
|
|
10
|
+
import type { UICtx } from "./ui/agent-widget";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Narrow widget interface consumed by SubagentRuntime delegation methods.
|
package/src/service-adapter.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
import type { ModelRegistry } from "./model-resolver
|
|
10
|
-
import type { ParentSnapshot } from "./parent-snapshot
|
|
11
|
-
import { buildParentSnapshot } from "./parent-snapshot
|
|
12
|
-
import type { SubagentRecord, SubagentsService } from "./service
|
|
13
|
-
import type { AgentRecord } from "./types
|
|
9
|
+
import type { ModelRegistry } from "./model-resolver";
|
|
10
|
+
import type { ParentSnapshot } from "./parent-snapshot";
|
|
11
|
+
import { buildParentSnapshot } from "./parent-snapshot";
|
|
12
|
+
import type { SubagentRecord, SubagentsService } from "./service";
|
|
13
|
+
import type { AgentRecord } from "./types";
|
|
14
14
|
|
|
15
15
|
/** Narrow interface for the AgentManager — avoids coupling to the concrete class. */
|
|
16
16
|
export interface AgentManagerLike {
|
package/src/service.ts
CHANGED
package/src/session-config.ts
CHANGED
|
@@ -14,16 +14,16 @@ import {
|
|
|
14
14
|
type AgentConfigLookup,
|
|
15
15
|
getMemoryToolNames,
|
|
16
16
|
getReadOnlyMemoryToolNames,
|
|
17
|
-
} from "./agent-types
|
|
18
|
-
import type { EnvInfo } from "./env
|
|
19
|
-
import type { PromptExtras } from "./prompts
|
|
20
|
-
import type { PreloadedSkill } from "./skill-loader
|
|
17
|
+
} from "./agent-types";
|
|
18
|
+
import type { EnvInfo } from "./env";
|
|
19
|
+
import type { PromptExtras } from "./prompts";
|
|
20
|
+
import type { PreloadedSkill } from "./skill-loader";
|
|
21
21
|
import type {
|
|
22
22
|
AgentPromptConfig,
|
|
23
23
|
MemoryScope,
|
|
24
24
|
SubagentType,
|
|
25
25
|
ThinkingLevel,
|
|
26
|
-
} from "./types
|
|
26
|
+
} from "./types";
|
|
27
27
|
|
|
28
28
|
// ── Public interfaces ────────────────────────────────────────────────────────
|
|
29
29
|
|
package/src/skill-loader.ts
CHANGED
|
@@ -23,8 +23,8 @@ import { existsSync, readdirSync } from "node:fs";
|
|
|
23
23
|
import { homedir } from "node:os";
|
|
24
24
|
import { join } from "node:path";
|
|
25
25
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
26
|
-
import { debugLog } from "./debug
|
|
27
|
-
import { isSymlink, isUnsafeName, safeReadFile } from "./memory
|
|
26
|
+
import { debugLog } from "./debug";
|
|
27
|
+
import { isSymlink, isUnsafeName, safeReadFile } from "./memory";
|
|
28
28
|
|
|
29
29
|
export interface PreloadedSkill {
|
|
30
30
|
name: string;
|
package/src/tools/agent-tool.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Text } from "@earendil-works/pi-tui";
|
|
3
3
|
import { Type } from "@sinclair/typebox";
|
|
4
|
-
import type { AgentSpawnConfig } from "../agent-manager
|
|
5
|
-
import { AgentTypeRegistry } from "../agent-types
|
|
6
|
-
import type { ParentSnapshot } from "../parent-snapshot
|
|
4
|
+
import type { AgentSpawnConfig } from "../agent-manager";
|
|
5
|
+
import { AgentTypeRegistry } from "../agent-types";
|
|
6
|
+
import type { ParentSnapshot } from "../parent-snapshot";
|
|
7
7
|
|
|
8
|
-
import type { AgentRecord } from "../types
|
|
9
|
-
import { AgentActivityTracker } from "../ui/agent-activity-tracker
|
|
10
|
-
import { type UICtx } from "../ui/agent-widget
|
|
8
|
+
import type { AgentRecord } from "../types";
|
|
9
|
+
import { AgentActivityTracker } from "../ui/agent-activity-tracker";
|
|
10
|
+
import { type UICtx } from "../ui/agent-widget";
|
|
11
11
|
import {
|
|
12
12
|
type AgentDetails,
|
|
13
13
|
formatMs,
|
|
14
14
|
formatTurns,
|
|
15
15
|
getDisplayName,
|
|
16
16
|
SPINNER,
|
|
17
|
-
} from "../ui/display
|
|
18
|
-
import { spawnBackground } from "./background-spawner
|
|
19
|
-
import { runForeground } from "./foreground-runner
|
|
20
|
-
import { buildDetails, buildTypeListText, textResult } from "./helpers
|
|
21
|
-
import { type ModelInfo, resolveSpawnConfig } from "./spawn-config
|
|
17
|
+
} from "../ui/display";
|
|
18
|
+
import { spawnBackground } from "./background-spawner";
|
|
19
|
+
import { runForeground } from "./foreground-runner";
|
|
20
|
+
import { buildDetails, buildTypeListText, textResult } from "./helpers";
|
|
21
|
+
import { type ModelInfo, resolveSpawnConfig } from "./spawn-config";
|
|
22
22
|
|
|
23
23
|
// ---- Deps interface ----
|
|
24
24
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { AgentSpawnConfig } from "../agent-manager
|
|
2
|
-
import type { ParentSnapshot } from "../parent-snapshot
|
|
3
|
-
import type { AgentRecord } from "../types
|
|
4
|
-
import { AgentActivityTracker } from "../ui/agent-activity-tracker
|
|
5
|
-
import { subscribeUIObserver } from "../ui/ui-observer
|
|
6
|
-
import type { AgentActivityAccess } from "./agent-tool
|
|
7
|
-
import { textResult } from "./helpers
|
|
8
|
-
import type { ResolvedSpawnConfig } from "./spawn-config
|
|
1
|
+
import type { AgentSpawnConfig } from "../agent-manager";
|
|
2
|
+
import type { ParentSnapshot } from "../parent-snapshot";
|
|
3
|
+
import type { AgentRecord } from "../types";
|
|
4
|
+
import { AgentActivityTracker } from "../ui/agent-activity-tracker";
|
|
5
|
+
import { subscribeUIObserver } from "../ui/ui-observer";
|
|
6
|
+
import type { AgentActivityAccess } from "./agent-tool";
|
|
7
|
+
import { textResult } from "./helpers";
|
|
8
|
+
import type { ResolvedSpawnConfig } from "./spawn-config";
|
|
9
9
|
|
|
10
10
|
/** Narrow manager interface for the background spawner. */
|
|
11
11
|
export interface BackgroundManagerDeps {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { AgentSpawnConfig } from "../agent-manager
|
|
3
|
-
import type { ParentSnapshot } from "../parent-snapshot
|
|
4
|
-
import type { AgentRecord } from "../types
|
|
5
|
-
import { AgentActivityTracker } from "../ui/agent-activity-tracker
|
|
2
|
+
import type { AgentSpawnConfig } from "../agent-manager";
|
|
3
|
+
import type { ParentSnapshot } from "../parent-snapshot";
|
|
4
|
+
import type { AgentRecord } from "../types";
|
|
5
|
+
import { AgentActivityTracker } from "../ui/agent-activity-tracker";
|
|
6
6
|
import {
|
|
7
7
|
type AgentDetails,
|
|
8
8
|
describeActivity,
|
|
9
9
|
formatMs,
|
|
10
10
|
SPINNER,
|
|
11
|
-
} from "../ui/display
|
|
12
|
-
import { subscribeUIObserver } from "../ui/ui-observer
|
|
13
|
-
import type { AgentActivityAccess } from "./agent-tool
|
|
11
|
+
} from "../ui/display";
|
|
12
|
+
import { subscribeUIObserver } from "../ui/ui-observer";
|
|
13
|
+
import type { AgentActivityAccess } from "./agent-tool";
|
|
14
14
|
import {
|
|
15
15
|
buildDetails,
|
|
16
16
|
formatLifetimeTokens,
|
|
17
17
|
getStatusNote,
|
|
18
18
|
textResult,
|
|
19
|
-
} from "./helpers
|
|
20
|
-
import type { ResolvedSpawnConfig } from "./spawn-config
|
|
19
|
+
} from "./helpers";
|
|
20
|
+
import type { ResolvedSpawnConfig } from "./spawn-config";
|
|
21
21
|
|
|
22
22
|
/** Narrow manager interface for the foreground runner. */
|
|
23
23
|
export interface ForegroundManagerDeps {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import type { AgentConfigLookup } from "../agent-types
|
|
4
|
-
import type { AgentRecord } from "../types
|
|
5
|
-
import { formatDuration, getDisplayName } from "../ui/display
|
|
6
|
-
import { getSessionContextPercent } from "../usage
|
|
7
|
-
import { formatLifetimeTokens, textResult } from "./helpers
|
|
3
|
+
import type { AgentConfigLookup } from "../agent-types";
|
|
4
|
+
import type { AgentRecord } from "../types";
|
|
5
|
+
import { formatDuration, getDisplayName } from "../ui/display";
|
|
6
|
+
import { getSessionContextPercent } from "../usage";
|
|
7
|
+
import { formatLifetimeTokens, textResult } from "./helpers";
|
|
8
8
|
|
|
9
9
|
/** Create the get_subagent_result tool definition (without Pi SDK wrapper). */
|
|
10
10
|
export function createGetResultTool(
|
package/src/tools/helpers.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AgentConfigLookup } from "../agent-types
|
|
2
|
-
import { AgentActivityTracker } from "../ui/agent-activity-tracker
|
|
3
|
-
import { type AgentDetails, formatTokens } from "../ui/display
|
|
4
|
-
import { getLifetimeTotal, type LifetimeUsage } from "../usage
|
|
1
|
+
import type { AgentConfigLookup } from "../agent-types";
|
|
2
|
+
import { AgentActivityTracker } from "../ui/agent-activity-tracker";
|
|
3
|
+
import { type AgentDetails, formatTokens } from "../ui/display";
|
|
4
|
+
import { getLifetimeTotal, type LifetimeUsage } from "../usage";
|
|
5
5
|
|
|
6
6
|
/** Parenthetical status note for completed agent result text. */
|
|
7
7
|
export function getStatusNote(status: string): string {
|
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Model } from "@earendil-works/pi-ai";
|
|
10
|
-
import { normalizeMaxTurns } from "../agent-runner
|
|
11
|
-
import type { AgentTypeRegistry } from "../agent-types
|
|
12
|
-
import { resolveAgentInvocationConfig } from "../invocation-config
|
|
13
|
-
import { resolveInvocationModel } from "../model-resolver
|
|
14
|
-
import type { AgentInvocation, IsolationMode, SubagentType, ThinkingLevel } from "../types
|
|
10
|
+
import { normalizeMaxTurns } from "../agent-runner";
|
|
11
|
+
import type { AgentTypeRegistry } from "../agent-types";
|
|
12
|
+
import { resolveAgentInvocationConfig } from "../invocation-config";
|
|
13
|
+
import { resolveInvocationModel } from "../model-resolver";
|
|
14
|
+
import type { AgentInvocation, IsolationMode, SubagentType, ThinkingLevel } from "../types";
|
|
15
15
|
import {
|
|
16
16
|
type AgentDetails,
|
|
17
17
|
buildInvocationTags,
|
|
18
18
|
getDisplayName,
|
|
19
19
|
getPromptModeLabel,
|
|
20
|
-
} from "../ui/display
|
|
20
|
+
} from "../ui/display";
|
|
21
21
|
|
|
22
22
|
/** Model info extracted from the parent session context. */
|
|
23
23
|
export interface ModelInfo {
|
package/src/tools/steer-tool.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import type { AgentRecord } from "../types
|
|
4
|
-
import { getSessionContextPercent } from "../usage
|
|
5
|
-
import { formatLifetimeTokens, textResult } from "./helpers
|
|
3
|
+
import type { AgentRecord } from "../types";
|
|
4
|
+
import { getSessionContextPercent } from "../usage";
|
|
5
|
+
import { formatLifetimeTokens, textResult } from "./helpers";
|
|
6
6
|
|
|
7
7
|
/** Create the steer_subagent tool definition (without Pi SDK wrapper). */
|
|
8
8
|
export function createSteerTool(
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { ThinkingLevel } from "@earendil-works/pi-ai";
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
export { AgentRecord } from "./agent-record
|
|
8
|
+
export { AgentRecord } from "./agent-record";
|
|
9
9
|
export type { ThinkingLevel };
|
|
10
10
|
|
|
11
11
|
/** Agent type: any string name (built-in defaults or user-defined). */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* in `ui-observer.ts`. Callers use named transition methods; readers use read-only accessors.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { SessionLike } from "../usage
|
|
8
|
+
import type { SessionLike } from "../usage";
|
|
9
9
|
|
|
10
10
|
/** Per-agent live activity state with explicit transition methods and read-only accessors. */
|
|
11
11
|
export class AgentActivityTracker {
|