@gotgenes/pi-subagents 6.17.0 → 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 +12 -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/retro/0147-inject-wrap-text-into-conversation-viewer.md +40 -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 +10 -10
- package/src/ui/agent-widget.ts +5 -5
- package/src/ui/conversation-viewer.ts +6 -6
- 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
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 {
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
|
|
10
|
-
import type { AgentTypeRegistry } from "../agent-types
|
|
11
|
-
import type { AgentConfig } from "../types
|
|
12
|
-
import type { AgentFileOps } from "./agent-file-ops
|
|
13
|
-
import type { MenuUI } from "./agent-menu
|
|
10
|
+
import type { AgentTypeRegistry } from "../agent-types";
|
|
11
|
+
import type { AgentConfig } from "../types";
|
|
12
|
+
import type { AgentFileOps } from "./agent-file-ops";
|
|
13
|
+
import type { MenuUI } from "./agent-menu";
|
|
14
14
|
|
|
15
15
|
// ---- Factory ----
|
|
16
16
|
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import { join } from "node:path";
|
|
9
9
|
|
|
10
|
-
import { BUILTIN_TOOL_NAMES } from "../agent-types
|
|
11
|
-
import type { ParentSnapshot } from "../parent-snapshot
|
|
12
|
-
import type { AgentRecord } from "../types
|
|
13
|
-
import type { AgentFileOps } from "./agent-file-ops
|
|
14
|
-
import type { MenuUI } from "./agent-menu
|
|
10
|
+
import { BUILTIN_TOOL_NAMES } from "../agent-types";
|
|
11
|
+
import type { ParentSnapshot } from "../parent-snapshot";
|
|
12
|
+
import type { AgentRecord } from "../types";
|
|
13
|
+
import type { AgentFileOps } from "./agent-file-ops";
|
|
14
|
+
import type { MenuUI } from "./agent-menu";
|
|
15
15
|
|
|
16
16
|
// ---- Deps interface ----
|
|
17
17
|
|
package/src/ui/agent-menu.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
2
|
-
import { AgentTypeRegistry } from "../agent-types
|
|
3
|
-
import type { ModelRegistry } from "../model-resolver
|
|
4
|
-
import type { ParentSnapshot } from "../parent-snapshot
|
|
5
|
-
import type { AgentConfig, AgentRecord } from "../types
|
|
6
|
-
import type { AgentActivityTracker } from "./agent-activity-tracker
|
|
7
|
-
import { createAgentConfigEditor } from "./agent-config-editor
|
|
8
|
-
import { createAgentCreationWizard } from "./agent-creation-wizard
|
|
9
|
-
import type { AgentFileOps } from "./agent-file-ops
|
|
10
|
-
import { formatDuration, getDisplayName } from "./display
|
|
2
|
+
import { AgentTypeRegistry } from "../agent-types";
|
|
3
|
+
import type { ModelRegistry } from "../model-resolver";
|
|
4
|
+
import type { ParentSnapshot } from "../parent-snapshot";
|
|
5
|
+
import type { AgentConfig, AgentRecord } from "../types";
|
|
6
|
+
import type { AgentActivityTracker } from "./agent-activity-tracker";
|
|
7
|
+
import { createAgentConfigEditor } from "./agent-config-editor";
|
|
8
|
+
import { createAgentCreationWizard } from "./agent-creation-wizard";
|
|
9
|
+
import type { AgentFileOps } from "./agent-file-ops";
|
|
10
|
+
import { formatDuration, getDisplayName } from "./display";
|
|
11
11
|
|
|
12
12
|
// ---- Deps interface ----
|
|
13
13
|
|
|
@@ -247,7 +247,7 @@ export function createAgentsMenuHandler({
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
const { ConversationViewer, VIEWPORT_HEIGHT_PCT } = await import(
|
|
250
|
-
"./conversation-viewer
|
|
250
|
+
"./conversation-viewer"
|
|
251
251
|
);
|
|
252
252
|
const activity = agentActivity.get(record.id);
|
|
253
253
|
|
package/src/ui/agent-widget.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Uses the callback form of setWidget for themed rendering.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { AgentManager } from "../agent-manager
|
|
9
|
-
import { AgentTypeRegistry } from "../agent-types
|
|
10
|
-
import type { AgentActivityTracker } from "./agent-activity-tracker
|
|
11
|
-
import { ERROR_STATUSES, type Theme } from "./display
|
|
12
|
-
import { renderWidgetLines } from "./widget-renderer
|
|
8
|
+
import type { AgentManager } from "../agent-manager";
|
|
9
|
+
import { AgentTypeRegistry } from "../agent-types";
|
|
10
|
+
import type { AgentActivityTracker } from "./agent-activity-tracker";
|
|
11
|
+
import { ERROR_STATUSES, type Theme } from "./display";
|
|
12
|
+
import { renderWidgetLines } from "./widget-renderer";
|
|
13
13
|
|
|
14
14
|
// ---- Types ----
|
|
15
15
|
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import type { AgentSession } from "@earendil-works/pi-coding-agent";
|
|
9
9
|
import { type Component, matchesKey, type TUI, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
10
|
-
import type { AgentConfigLookup } from "../agent-types
|
|
11
|
-
import { extractText } from "../context
|
|
12
|
-
import type { AgentRecord } from "../types
|
|
13
|
-
import { getLifetimeTotal, getSessionContextPercent } from "../usage
|
|
14
|
-
import type { AgentActivityTracker } from "./agent-activity-tracker
|
|
15
|
-
import { buildInvocationTags, describeActivity, formatDuration, formatSessionTokens, getDisplayName, getPromptModeLabel, type Theme } from "./display
|
|
10
|
+
import type { AgentConfigLookup } from "../agent-types";
|
|
11
|
+
import { extractText } from "../context";
|
|
12
|
+
import type { AgentRecord } from "../types";
|
|
13
|
+
import { getLifetimeTotal, getSessionContextPercent } from "../usage";
|
|
14
|
+
import type { AgentActivityTracker } from "./agent-activity-tracker";
|
|
15
|
+
import { buildInvocationTags, describeActivity, formatDuration, formatSessionTokens, getDisplayName, getPromptModeLabel, type Theme } from "./display";
|
|
16
16
|
|
|
17
17
|
// ── Local message-shape types ───────────────────────────────────────────────
|
|
18
18
|
// The Pi SDK does not export narrow types for all message content variants.
|
package/src/ui/display.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Consumed by the widget, the menu, tool modules, and the notification renderer.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { AgentConfigLookup } from "../agent-types
|
|
9
|
-
import type { AgentInvocation, SubagentType } from "../types
|
|
8
|
+
import type { AgentConfigLookup } from "../agent-types";
|
|
9
|
+
import type { AgentInvocation, SubagentType } from "../types";
|
|
10
10
|
|
|
11
11
|
// ---- Types ----
|
|
12
12
|
|
package/src/ui/ui-observer.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* turn count, lifetime usage).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { AgentActivityTracker } from "./agent-activity-tracker
|
|
9
|
+
import type { AgentActivityTracker } from "./agent-activity-tracker";
|
|
10
10
|
|
|
11
11
|
/** Narrow session interface — only the subscribe method needed by the observer. */
|
|
12
12
|
interface SubscribableSession {
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
9
|
-
import type { AgentConfigLookup } from "../agent-types
|
|
10
|
-
import type { SubagentType } from "../types
|
|
11
|
-
import type { LifetimeUsage, SessionLike } from "../usage
|
|
12
|
-
import { getLifetimeTotal, getSessionContextPercent } from "../usage
|
|
9
|
+
import type { AgentConfigLookup } from "../agent-types";
|
|
10
|
+
import type { SubagentType } from "../types";
|
|
11
|
+
import type { LifetimeUsage, SessionLike } from "../usage";
|
|
12
|
+
import { getLifetimeTotal, getSessionContextPercent } from "../usage";
|
|
13
13
|
import {
|
|
14
14
|
describeActivity,
|
|
15
15
|
formatMs,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getPromptModeLabel,
|
|
20
20
|
SPINNER,
|
|
21
21
|
type Theme,
|
|
22
|
-
} from "./display
|
|
22
|
+
} from "./display";
|
|
23
23
|
|
|
24
24
|
// ── Data interfaces ──────────────────────────────────────────────────────────
|
|
25
25
|
|
package/src/worktree-state.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* cleanupResult is recorded once at completion or error — it is not set at construction.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { WorktreeCleanupResult, WorktreeInfo } from "./worktree
|
|
9
|
+
import type { WorktreeCleanupResult, WorktreeInfo } from "./worktree";
|
|
10
10
|
|
|
11
11
|
export type { WorktreeCleanupResult, WorktreeInfo };
|
|
12
12
|
|
package/src/worktree.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { randomUUID } from "node:crypto";
|
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
12
|
import { tmpdir } from "node:os";
|
|
13
13
|
import { join } from "node:path";
|
|
14
|
-
import { debugLog } from "./debug
|
|
14
|
+
import { debugLog } from "./debug";
|
|
15
15
|
|
|
16
16
|
export interface WorktreeInfo {
|
|
17
17
|
/** Absolute path to the worktree directory. */
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: {
|
|
6
|
+
alias: {
|
|
7
|
+
"#src": path.resolve(import.meta.dirname, "src"),
|
|
8
|
+
"#test": path.resolve(import.meta.dirname, "test"),
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
test: {
|
|
12
|
+
include: ["test/**/*.test.ts"],
|
|
13
|
+
},
|
|
14
|
+
});
|