@esso0428/pi-subagents 0.15.0 → 0.15.2
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 +10 -0
- package/README.md +2 -2
- package/dist/agent-manager.d.ts +8 -0
- package/dist/agent-manager.js +87 -19
- package/dist/agent-runner.js +85 -66
- package/dist/agent-types.js +45 -27
- package/dist/context.js +6 -2
- package/dist/cross-extension-rpc.js +9 -5
- package/dist/custom-agents.js +18 -15
- package/dist/default-agents.js +4 -1
- package/dist/enabled-models.js +16 -11
- package/dist/env.js +4 -1
- package/dist/group-join.js +5 -1
- package/dist/index.js +280 -221
- package/dist/invocation-config.js +6 -2
- package/dist/memory.js +34 -24
- package/dist/model-resolver.js +4 -1
- package/dist/nico-overrides.js +20 -14
- package/dist/output-file.js +21 -15
- package/dist/prompts.js +4 -1
- package/dist/schedule-store.js +21 -16
- package/dist/schedule.js +12 -8
- package/dist/settings.js +23 -15
- package/dist/skill-loader.js +23 -20
- package/dist/status-note.js +4 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js +4 -1
- package/dist/ui/agent-widget.js +37 -23
- package/dist/ui/conversation-viewer.js +43 -39
- package/dist/ui/fleet-list.js +30 -24
- package/dist/ui/markdown-result.d.ts +3 -0
- package/dist/ui/markdown-result.js +53 -0
- package/dist/ui/schedule-menu.js +4 -1
- package/dist/ui/viewer-keys.js +10 -7
- package/dist/usage.js +10 -4
- package/dist/worktree.js +31 -26
- package/package.json +1 -1
- package/src/agent-manager.ts +72 -0
- package/src/agent-runner.ts +11 -3
- package/src/index.ts +39 -16
- package/src/types.ts +1 -0
- package/src/ui/markdown-result.ts +56 -0
- package/test/agent-manager-history.test.ts +84 -0
- package/test/ui/markdown-result.test.ts +45 -0
package/dist/agent-types.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* agent-types.ts — Unified agent type registry.
|
|
3
4
|
*
|
|
4
5
|
* Merges embedded default agents with user-defined agents from .pi/agents/*.md, .agents/agents/*.md, and global agents.
|
|
5
6
|
* User agents override defaults with the same name. Disabled agents are kept but excluded from spawning.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.BUILTIN_TOOL_NAMES = void 0;
|
|
10
|
+
exports.isDefaultsDisabled = isDefaultsDisabled;
|
|
11
|
+
exports.setDefaultsDisabled = setDefaultsDisabled;
|
|
12
|
+
exports.registerAgents = registerAgents;
|
|
13
|
+
exports.applyNicoOverrides = applyNicoOverrides;
|
|
14
|
+
exports.resolveType = resolveType;
|
|
15
|
+
exports.getAgentConfig = getAgentConfig;
|
|
16
|
+
exports.getAvailableTypes = getAvailableTypes;
|
|
17
|
+
exports.getAllTypes = getAllTypes;
|
|
18
|
+
exports.getDefaultAgentNames = getDefaultAgentNames;
|
|
19
|
+
exports.getUserAgentNames = getUserAgentNames;
|
|
20
|
+
exports.isValidType = isValidType;
|
|
21
|
+
exports.getMemoryToolNames = getMemoryToolNames;
|
|
22
|
+
exports.getReadOnlyMemoryToolNames = getReadOnlyMemoryToolNames;
|
|
23
|
+
exports.getToolNamesForType = getToolNamesForType;
|
|
24
|
+
exports.getConfig = getConfig;
|
|
25
|
+
const pi_coding_agent_1 = require("@earendil-works/pi-coding-agent");
|
|
26
|
+
const default_agents_js_1 = require("./default-agents.js");
|
|
27
|
+
const nico_overrides_js_1 = require("./nico-overrides.js");
|
|
10
28
|
/**
|
|
11
29
|
* All known built-in tool names, derived from pi's own tool factories rather
|
|
12
30
|
* than hardcoded so the set tracks pi-mono if it adds/renames a built-in.
|
|
@@ -15,27 +33,27 @@ import { applyNicoOverridesToMap, readNicoAgentOverrides } from "./nico-override
|
|
|
15
33
|
* (read, bash, edit, write, grep, find, ls). The `cwd` only binds tool
|
|
16
34
|
* operations we never invoke here — we read each tool's `.name` and discard it.
|
|
17
35
|
*/
|
|
18
|
-
|
|
19
|
-
...new Set([...createCodingTools("."), ...createReadOnlyTools(".")].map((t) => t.name)),
|
|
36
|
+
exports.BUILTIN_TOOL_NAMES = [
|
|
37
|
+
...new Set([...(0, pi_coding_agent_1.createCodingTools)("."), ...(0, pi_coding_agent_1.createReadOnlyTools)(".")].map((t) => t.name)),
|
|
20
38
|
];
|
|
21
39
|
/** Unified runtime registry of all agents (defaults + user-defined). */
|
|
22
40
|
const agents = new Map();
|
|
23
41
|
/** When true, DEFAULT_AGENTS are skipped during registration. */
|
|
24
42
|
let disableDefaults = false;
|
|
25
43
|
/** Check whether default agents are disabled. */
|
|
26
|
-
|
|
44
|
+
function isDefaultsDisabled() { return disableDefaults; }
|
|
27
45
|
/** Set whether default agents are disabled. */
|
|
28
|
-
|
|
46
|
+
function setDefaultsDisabled(b) { disableDefaults = b; }
|
|
29
47
|
/**
|
|
30
48
|
* Register agents into the unified registry.
|
|
31
49
|
* Starts with DEFAULT_AGENTS, then overlays user agents (overrides defaults with same name).
|
|
32
50
|
* Disabled agents (enabled === false) are kept in the registry but excluded from spawning.
|
|
33
51
|
*/
|
|
34
|
-
|
|
52
|
+
function registerAgents(userAgents) {
|
|
35
53
|
agents.clear();
|
|
36
54
|
// Start with defaults (unless disabled via settings)
|
|
37
55
|
if (!disableDefaults) {
|
|
38
|
-
for (const [name, config] of DEFAULT_AGENTS) {
|
|
56
|
+
for (const [name, config] of default_agents_js_1.DEFAULT_AGENTS) {
|
|
39
57
|
agents.set(name, config);
|
|
40
58
|
}
|
|
41
59
|
}
|
|
@@ -50,9 +68,9 @@ export function registerAgents(userAgents) {
|
|
|
50
68
|
* them as the highest-priority layer. Auto-registers agents that don't
|
|
51
69
|
* exist in the registry yet.
|
|
52
70
|
*/
|
|
53
|
-
|
|
54
|
-
const { overrides, defaultModel } = readNicoAgentOverrides(process.cwd());
|
|
55
|
-
applyNicoOverridesToMap(agents, overrides, defaultModel);
|
|
71
|
+
function applyNicoOverrides() {
|
|
72
|
+
const { overrides, defaultModel } = (0, nico_overrides_js_1.readNicoAgentOverrides)(process.cwd());
|
|
73
|
+
(0, nico_overrides_js_1.applyNicoOverridesToMap)(agents, overrides, defaultModel);
|
|
56
74
|
}
|
|
57
75
|
/** Case-insensitive key resolution. */
|
|
58
76
|
function resolveKey(name) {
|
|
@@ -66,38 +84,38 @@ function resolveKey(name) {
|
|
|
66
84
|
return undefined;
|
|
67
85
|
}
|
|
68
86
|
/** Resolve a type name case-insensitively. Returns the canonical key or undefined. */
|
|
69
|
-
|
|
87
|
+
function resolveType(name) {
|
|
70
88
|
return resolveKey(name);
|
|
71
89
|
}
|
|
72
90
|
/** Get the agent config for a type (case-insensitive). */
|
|
73
|
-
|
|
91
|
+
function getAgentConfig(name) {
|
|
74
92
|
const key = resolveKey(name);
|
|
75
93
|
return key ? agents.get(key) : undefined;
|
|
76
94
|
}
|
|
77
95
|
/** Get all enabled type names (for spawning and tool descriptions). */
|
|
78
|
-
|
|
96
|
+
function getAvailableTypes() {
|
|
79
97
|
return [...agents.entries()]
|
|
80
98
|
.filter(([_, config]) => config.enabled !== false)
|
|
81
99
|
.map(([name]) => name);
|
|
82
100
|
}
|
|
83
101
|
/** Get all type names including disabled (for UI listing). */
|
|
84
|
-
|
|
102
|
+
function getAllTypes() {
|
|
85
103
|
return [...agents.keys()];
|
|
86
104
|
}
|
|
87
105
|
/** Get names of default agents currently in the registry. */
|
|
88
|
-
|
|
106
|
+
function getDefaultAgentNames() {
|
|
89
107
|
return [...agents.entries()]
|
|
90
108
|
.filter(([_, config]) => config.isDefault === true)
|
|
91
109
|
.map(([name]) => name);
|
|
92
110
|
}
|
|
93
111
|
/** Get names of user-defined agents (non-defaults) currently in the registry. */
|
|
94
|
-
|
|
112
|
+
function getUserAgentNames() {
|
|
95
113
|
return [...agents.entries()]
|
|
96
114
|
.filter(([_, config]) => config.isDefault !== true)
|
|
97
115
|
.map(([name]) => name);
|
|
98
116
|
}
|
|
99
117
|
/** Check if a type is valid and enabled (case-insensitive). */
|
|
100
|
-
|
|
118
|
+
function isValidType(type) {
|
|
101
119
|
const key = resolveKey(type);
|
|
102
120
|
if (!key)
|
|
103
121
|
return false;
|
|
@@ -108,7 +126,7 @@ const MEMORY_TOOL_NAMES = ["read", "write", "edit"];
|
|
|
108
126
|
/**
|
|
109
127
|
* Get memory tool names (read/write/edit) not already in the provided set.
|
|
110
128
|
*/
|
|
111
|
-
|
|
129
|
+
function getMemoryToolNames(existingToolNames) {
|
|
112
130
|
return MEMORY_TOOL_NAMES.filter(n => !existingToolNames.has(n));
|
|
113
131
|
}
|
|
114
132
|
/** Tool names needed for read-only memory access. */
|
|
@@ -116,27 +134,27 @@ const READONLY_MEMORY_TOOL_NAMES = ["read"];
|
|
|
116
134
|
/**
|
|
117
135
|
* Get read-only memory tool names not already in the provided set.
|
|
118
136
|
*/
|
|
119
|
-
|
|
137
|
+
function getReadOnlyMemoryToolNames(existingToolNames) {
|
|
120
138
|
return READONLY_MEMORY_TOOL_NAMES.filter(n => !existingToolNames.has(n));
|
|
121
139
|
}
|
|
122
140
|
/** Get built-in tool names for a type (case-insensitive). */
|
|
123
|
-
|
|
141
|
+
function getToolNamesForType(type) {
|
|
124
142
|
const key = resolveKey(type);
|
|
125
143
|
const raw = key ? agents.get(key) : undefined;
|
|
126
144
|
const config = raw?.enabled !== false ? raw : undefined;
|
|
127
145
|
// `undefined` (definition omitted the field) → all built-ins; an explicit `[]`
|
|
128
146
|
// (`tools: none` or a `tools:` with only `ext:` entries) → zero built-ins.
|
|
129
|
-
return config?.builtinToolNames ?? [...BUILTIN_TOOL_NAMES];
|
|
147
|
+
return config?.builtinToolNames ?? [...exports.BUILTIN_TOOL_NAMES];
|
|
130
148
|
}
|
|
131
149
|
/** Get config for a type (case-insensitive, returns a SubagentTypeConfig-compatible object). Falls back to general-purpose. */
|
|
132
|
-
|
|
150
|
+
function getConfig(type) {
|
|
133
151
|
const key = resolveKey(type);
|
|
134
152
|
const config = key ? agents.get(key) : undefined;
|
|
135
153
|
if (config && config.enabled !== false) {
|
|
136
154
|
return {
|
|
137
155
|
displayName: config.displayName ?? config.name,
|
|
138
156
|
description: config.description,
|
|
139
|
-
builtinToolNames: config.builtinToolNames ?? BUILTIN_TOOL_NAMES,
|
|
157
|
+
builtinToolNames: config.builtinToolNames ?? exports.BUILTIN_TOOL_NAMES,
|
|
140
158
|
extensions: config.extensions,
|
|
141
159
|
excludeExtensions: config.excludeExtensions,
|
|
142
160
|
skills: config.skills,
|
|
@@ -149,7 +167,7 @@ export function getConfig(type) {
|
|
|
149
167
|
return {
|
|
150
168
|
displayName: gp.displayName ?? gp.name,
|
|
151
169
|
description: gp.description,
|
|
152
|
-
builtinToolNames: gp.builtinToolNames ?? BUILTIN_TOOL_NAMES,
|
|
170
|
+
builtinToolNames: gp.builtinToolNames ?? exports.BUILTIN_TOOL_NAMES,
|
|
153
171
|
extensions: gp.extensions,
|
|
154
172
|
excludeExtensions: gp.excludeExtensions,
|
|
155
173
|
skills: gp.skills,
|
|
@@ -160,7 +178,7 @@ export function getConfig(type) {
|
|
|
160
178
|
return {
|
|
161
179
|
displayName: "Agent",
|
|
162
180
|
description: "General-purpose agent for complex, multi-step tasks",
|
|
163
|
-
builtinToolNames: BUILTIN_TOOL_NAMES,
|
|
181
|
+
builtinToolNames: exports.BUILTIN_TOOL_NAMES,
|
|
164
182
|
extensions: true,
|
|
165
183
|
skills: true,
|
|
166
184
|
promptMode: "append",
|
package/dist/context.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* context.ts — Extract parent conversation context for subagent inheritance.
|
|
3
4
|
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractText = extractText;
|
|
7
|
+
exports.buildParentContext = buildParentContext;
|
|
4
8
|
/** Extract text from a message content block array. */
|
|
5
|
-
|
|
9
|
+
function extractText(content) {
|
|
6
10
|
return content
|
|
7
11
|
.filter((c) => c.type === "text")
|
|
8
12
|
.map((c) => c.text ?? "")
|
|
@@ -13,7 +17,7 @@ export function extractText(content) {
|
|
|
13
17
|
* Used when inherit_context is true to give the subagent visibility
|
|
14
18
|
* into what has been discussed/done so far.
|
|
15
19
|
*/
|
|
16
|
-
|
|
20
|
+
function buildParentContext(ctx) {
|
|
17
21
|
const entries = ctx.sessionManager.getBranch();
|
|
18
22
|
if (!entries || entries.length === 0)
|
|
19
23
|
return "";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Cross-extension RPC handlers for the subagents extension.
|
|
3
4
|
*
|
|
@@ -8,9 +9,12 @@
|
|
|
8
9
|
* success → { success: true, data?: T }
|
|
9
10
|
* error → { success: false, error: string }
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.PROTOCOL_VERSION = void 0;
|
|
14
|
+
exports.registerRpcHandlers = registerRpcHandlers;
|
|
15
|
+
const model_resolver_js_1 = require("./model-resolver.js");
|
|
12
16
|
/** RPC protocol version — bumped when the envelope or method contracts change. */
|
|
13
|
-
|
|
17
|
+
exports.PROTOCOL_VERSION = 2;
|
|
14
18
|
/**
|
|
15
19
|
* Wire a single RPC handler: listen on `channel`, run `fn(params)`,
|
|
16
20
|
* emit the reply envelope on `channel:reply:${requestId}`.
|
|
@@ -36,10 +40,10 @@ function handleRpc(events, channel, fn) {
|
|
|
36
40
|
* Register ping, spawn, and stop RPC handlers on the event bus.
|
|
37
41
|
* Returns unsub functions for cleanup.
|
|
38
42
|
*/
|
|
39
|
-
|
|
43
|
+
function registerRpcHandlers(deps) {
|
|
40
44
|
const { events, pi, getCtx, manager } = deps;
|
|
41
45
|
const unsubPing = handleRpc(events, "subagents:rpc:ping", () => {
|
|
42
|
-
return { version: PROTOCOL_VERSION };
|
|
46
|
+
return { version: exports.PROTOCOL_VERSION };
|
|
43
47
|
});
|
|
44
48
|
const unsubSpawn = handleRpc(events, "subagents:rpc:spawn", ({ type, prompt, options }) => {
|
|
45
49
|
const ctx = getCtx();
|
|
@@ -57,7 +61,7 @@ export function registerRpcHandlers(deps) {
|
|
|
57
61
|
if (!registry) {
|
|
58
62
|
throw new Error(`Model override "${normalizedOptions.model}" provided but ctx.modelRegistry is unavailable`);
|
|
59
63
|
}
|
|
60
|
-
const resolved = resolveModel(normalizedOptions.model, registry);
|
|
64
|
+
const resolved = (0, model_resolver_js_1.resolveModel)(normalizedOptions.model, registry);
|
|
61
65
|
if (typeof resolved === "string") {
|
|
62
66
|
// resolveModel returns a human-readable error string when the
|
|
63
67
|
// input doesn't match any available model. Surface it instead of
|
package/dist/custom-agents.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* custom-agents.ts — Load user-defined agents from project (.pi/agents/, plus the shared .agents/agents/ workspace) and global ($PI_CODING_AGENT_DIR/agents/, default ~/.pi/agent/agents/) locations.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadCustomAgents = loadCustomAgents;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
const pi_coding_agent_1 = require("@earendil-works/pi-coding-agent");
|
|
10
|
+
const agent_types_js_1 = require("./agent-types.js");
|
|
8
11
|
/**
|
|
9
12
|
* Scan for custom agent .md files from multiple locations.
|
|
10
13
|
* Discovery hierarchy (higher priority wins):
|
|
@@ -17,10 +20,10 @@ import { BUILTIN_TOOL_NAMES } from "./agent-types.js";
|
|
|
17
20
|
* authority; .agents/agents is an additional read location.
|
|
18
21
|
* Any name is allowed — names matching defaults (e.g. "Explore") override them.
|
|
19
22
|
*/
|
|
20
|
-
|
|
21
|
-
const globalDir = join(getAgentDir(), "agents");
|
|
22
|
-
const workspaceProjectDir = join(cwd, ".agents", "agents");
|
|
23
|
-
const projectDir = join(cwd, ".pi", "agents");
|
|
23
|
+
function loadCustomAgents(cwd) {
|
|
24
|
+
const globalDir = (0, node_path_1.join)((0, pi_coding_agent_1.getAgentDir)(), "agents");
|
|
25
|
+
const workspaceProjectDir = (0, node_path_1.join)(cwd, ".agents", "agents");
|
|
26
|
+
const projectDir = (0, node_path_1.join)(cwd, ".pi", "agents");
|
|
24
27
|
const agents = new Map();
|
|
25
28
|
loadFromDir(globalDir, agents, "global"); // lowest priority
|
|
26
29
|
loadFromDir(workspaceProjectDir, agents, "project"); // shared workspace
|
|
@@ -29,25 +32,25 @@ export function loadCustomAgents(cwd) {
|
|
|
29
32
|
}
|
|
30
33
|
/** Load agent configs from a directory into the map. */
|
|
31
34
|
function loadFromDir(dir, agents, source) {
|
|
32
|
-
if (!existsSync(dir))
|
|
35
|
+
if (!(0, node_fs_1.existsSync)(dir))
|
|
33
36
|
return;
|
|
34
37
|
let files;
|
|
35
38
|
try {
|
|
36
|
-
files = readdirSync(dir).filter(f => f.endsWith(".md"));
|
|
39
|
+
files = (0, node_fs_1.readdirSync)(dir).filter(f => f.endsWith(".md"));
|
|
37
40
|
}
|
|
38
41
|
catch {
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
41
44
|
for (const file of files) {
|
|
42
|
-
const name = basename(file, ".md");
|
|
45
|
+
const name = (0, node_path_1.basename)(file, ".md");
|
|
43
46
|
let content;
|
|
44
47
|
try {
|
|
45
|
-
content = readFileSync(join(dir, file), "utf-8");
|
|
48
|
+
content = (0, node_fs_1.readFileSync)((0, node_path_1.join)(dir, file), "utf-8");
|
|
46
49
|
}
|
|
47
50
|
catch {
|
|
48
51
|
continue;
|
|
49
52
|
}
|
|
50
|
-
const { frontmatter: fm, body } = parseFrontmatter(content);
|
|
53
|
+
const { frontmatter: fm, body } = (0, pi_coding_agent_1.parseFrontmatter)(content);
|
|
51
54
|
const { builtinToolNames, extSelectors } = parseToolsField(fm.tools);
|
|
52
55
|
agents.set(name, {
|
|
53
56
|
name,
|
|
@@ -116,13 +119,13 @@ function csvList(val, defaults) {
|
|
|
116
119
|
* `tools:` present with only `ext:` entries → zero built-ins (use `*`).
|
|
117
120
|
*/
|
|
118
121
|
function parseToolsField(val) {
|
|
119
|
-
const entries = csvList(val, BUILTIN_TOOL_NAMES);
|
|
122
|
+
const entries = csvList(val, agent_types_js_1.BUILTIN_TOOL_NAMES);
|
|
120
123
|
const isWildcard = (e) => e === "*" || e.toLowerCase() === "all";
|
|
121
124
|
const hasWildcard = entries.some(isWildcard);
|
|
122
125
|
const plain = entries.filter(e => !isWildcard(e) && !e.startsWith("ext:"));
|
|
123
126
|
const extEntries = entries.filter(e => e.startsWith("ext:"));
|
|
124
127
|
return {
|
|
125
|
-
builtinToolNames: hasWildcard ? [...new Set([...BUILTIN_TOOL_NAMES, ...plain])] : plain,
|
|
128
|
+
builtinToolNames: hasWildcard ? [...new Set([...agent_types_js_1.BUILTIN_TOOL_NAMES, ...plain])] : plain,
|
|
126
129
|
extSelectors: extEntries.length > 0 ? extEntries : undefined,
|
|
127
130
|
};
|
|
128
131
|
}
|
package/dist/default-agents.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* default-agents.ts — Embedded default agent configurations.
|
|
3
4
|
*
|
|
4
5
|
* These are always available but can be overridden by user .md files with the same name.
|
|
5
6
|
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DEFAULT_AGENTS = void 0;
|
|
6
9
|
const READ_ONLY_TOOLS = ["read", "bash", "grep", "find", "ls"];
|
|
7
|
-
|
|
10
|
+
exports.DEFAULT_AGENTS = new Map([
|
|
8
11
|
[
|
|
9
12
|
"general-purpose",
|
|
10
13
|
{
|
package/dist/enabled-models.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Reads `enabledModels` from pi's settings (global `<agentDir>/settings.json`
|
|
3
4
|
* + project-local `<cwd>/.pi/settings.json`, project wins) and resolves
|
|
@@ -25,22 +26,26 @@
|
|
|
25
26
|
* enabledModels = ["anthropic/claude-sonnet-4-6", "anthropic/claude-opus-4-6"]
|
|
26
27
|
* → resolves to { "anthropic/claude-sonnet-4-6", "anthropic/claude-opus-4-6" }
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.readEnabledModels = readEnabledModels;
|
|
31
|
+
exports.resolveEnabledModels = resolveEnabledModels;
|
|
32
|
+
exports.isModelInScope = isModelInScope;
|
|
33
|
+
const node_fs_1 = require("node:fs");
|
|
34
|
+
const node_path_1 = require("node:path");
|
|
35
|
+
const pi_coding_agent_1 = require("@earendil-works/pi-coding-agent");
|
|
31
36
|
/** Paths to pi's settings.json files: [project, global] (project takes precedence). */
|
|
32
37
|
function settingsPaths(cwd) {
|
|
33
38
|
return [
|
|
34
|
-
join(cwd, ".pi", "settings.json"),
|
|
35
|
-
join(getAgentDir(), "settings.json"),
|
|
39
|
+
(0, node_path_1.join)(cwd, ".pi", "settings.json"),
|
|
40
|
+
(0, node_path_1.join)((0, pi_coding_agent_1.getAgentDir)(), "settings.json"),
|
|
36
41
|
];
|
|
37
42
|
}
|
|
38
43
|
/** Read `enabledModels` from a single settings.json file. Undefined when missing or absent. */
|
|
39
44
|
function readField(path) {
|
|
40
|
-
if (!existsSync(path))
|
|
45
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
41
46
|
return undefined;
|
|
42
47
|
try {
|
|
43
|
-
const raw = JSON.parse(readFileSync(path, "utf-8"));
|
|
48
|
+
const raw = JSON.parse((0, node_fs_1.readFileSync)(path, "utf-8"));
|
|
44
49
|
if (Array.isArray(raw?.enabledModels))
|
|
45
50
|
return raw.enabledModels;
|
|
46
51
|
}
|
|
@@ -55,7 +60,7 @@ function readField(path) {
|
|
|
55
60
|
* (and matches our own loadSettings precedence in src/settings.ts).
|
|
56
61
|
* Returns undefined when neither file has the field.
|
|
57
62
|
*/
|
|
58
|
-
|
|
63
|
+
function readEnabledModels(cwd) {
|
|
59
64
|
const [project, global] = settingsPaths(cwd);
|
|
60
65
|
return readField(project) ?? readField(global);
|
|
61
66
|
}
|
|
@@ -80,14 +85,14 @@ let cachedPatternsKey = "";
|
|
|
80
85
|
/** mtime+size hash of one file, or "missing" if absent. */
|
|
81
86
|
function hashOf(path) {
|
|
82
87
|
try {
|
|
83
|
-
const s = statSync(path);
|
|
88
|
+
const s = (0, node_fs_1.statSync)(path);
|
|
84
89
|
return `${s.mtimeMs}-${s.size}`;
|
|
85
90
|
}
|
|
86
91
|
catch {
|
|
87
92
|
return "missing";
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
|
-
|
|
95
|
+
function resolveEnabledModels(patterns, registry, cwd = process.cwd()) {
|
|
91
96
|
// Fast path: check cache (stat both project and global settings.json files)
|
|
92
97
|
const patternsKey = JSON.stringify(patterns);
|
|
93
98
|
const [project, global] = settingsPaths(cwd);
|
|
@@ -121,7 +126,7 @@ export function resolveEnabledModels(patterns, registry, cwd = process.cwd()) {
|
|
|
121
126
|
* (`provider/id` lowercase) so callers don't have to reproduce it —
|
|
122
127
|
* both set-building (resolveExact) and lookup go through `modelKey`.
|
|
123
128
|
*/
|
|
124
|
-
|
|
129
|
+
function isModelInScope(model, allowed) {
|
|
125
130
|
return allowed.has(modelKey(model));
|
|
126
131
|
}
|
|
127
132
|
/** Canonical lowercase `provider/id` key for the allowed set. */
|
package/dist/env.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* env.ts — Detect environment info (git, platform) for subagent system prompts.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.detectEnv = detectEnv;
|
|
7
|
+
async function detectEnv(pi, cwd) {
|
|
5
8
|
let isGitRepo = false;
|
|
6
9
|
let branch = "";
|
|
7
10
|
try {
|
package/dist/group-join.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* group-join.ts — Manages grouped background agent completion notifications.
|
|
3
4
|
*
|
|
@@ -5,11 +6,13 @@
|
|
|
5
6
|
* agents in a group are held until all complete (or a timeout fires),
|
|
6
7
|
* then a single consolidated notification is sent.
|
|
7
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GroupJoinManager = void 0;
|
|
8
11
|
/** Default timeout: 30s after first completion in a group. */
|
|
9
12
|
const DEFAULT_TIMEOUT = 30_000;
|
|
10
13
|
/** Straggler re-batch timeout: 15s. */
|
|
11
14
|
const STRAGGLER_TIMEOUT = 15_000;
|
|
12
|
-
|
|
15
|
+
class GroupJoinManager {
|
|
13
16
|
deliverCb;
|
|
14
17
|
groupTimeout;
|
|
15
18
|
groups = new Map();
|
|
@@ -114,3 +117,4 @@ export class GroupJoinManager {
|
|
|
114
117
|
this.agentToGroup.clear();
|
|
115
118
|
}
|
|
116
119
|
}
|
|
120
|
+
exports.GroupJoinManager = GroupJoinManager;
|