@subimpact/e 0.99.2 → 0.99.5
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 +7 -17
- package/dist/bundle/chunks/{chunk-75XIWY7P.js → chunk-34ZJK2EZ.js} +1 -1
- package/dist/bundle/chunks/{chunk-5ZENNE67.js → chunk-YGYY5CGE.js} +6 -6
- package/dist/bundle/chunks/{pi-logo-animation-MA3YLQTM.js → pi-logo-animation-5NR3P2W2.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-VX2P5PB3.js → virtual-modules-GWKJPH7F.js} +1 -1
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/modes/interactive/components/pi-logo-animation.js +2 -2
- package/dist/modes/interactive/components/pi-logo-animation.js.map +1 -1
- package/dist/modes/interactive/components/pi-logo.d.ts +7 -6
- package/dist/modes/interactive/components/pi-logo.d.ts.map +1 -1
- package/dist/modes/interactive/components/pi-logo.js +12 -11
- package/dist/modes/interactive/components/pi-logo.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.js +1 -1
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/docs/cli.md +3 -62
- package/docs/configuration.md +0 -2
- package/docs/docs.json +0 -4
- package/docs/extensions.md +5 -25
- package/docs/llama-cpp.md +1 -1
- package/docs/models.md +4 -21
- package/docs/sdk.md +1 -6
- package/docs/security.md +0 -2
- package/docs/settings.md +4 -6
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/overlay-qa-tests.ts +1 -1
- package/package.json +1 -1
- package/docs/mcp.md +0 -248
- package/examples/extensions/subagent/README.md +0 -177
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -157
- package/examples/extensions/subagent/index.ts +0 -1038
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent discovery and configuration
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import { CONFIG_DIR_NAME, getAgentDir, parseFrontmatter } from "@earendil-works/pi-coding-agent";
|
|
8
|
-
|
|
9
|
-
export type AgentScope = "user" | "project" | "both";
|
|
10
|
-
|
|
11
|
-
export interface AgentConfig {
|
|
12
|
-
name: string;
|
|
13
|
-
description: string;
|
|
14
|
-
tools?: string[];
|
|
15
|
-
model?: string;
|
|
16
|
-
systemPrompt: string;
|
|
17
|
-
source: "user" | "project";
|
|
18
|
-
filePath: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface AgentDiscoveryResult {
|
|
22
|
-
agents: AgentConfig[];
|
|
23
|
-
projectAgentsDir: string | null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Raw agent frontmatter. Values are `unknown` because `parseFrontmatter` runs a
|
|
28
|
-
* real YAML parser, so any scalar or collection can appear here.
|
|
29
|
-
*
|
|
30
|
-
* A type alias rather than an interface: `parseFrontmatter` constrains its
|
|
31
|
-
* parameter to `Record<string, unknown>`, and only an alias picks up the
|
|
32
|
-
* implicit index signature that satisfies it.
|
|
33
|
-
*/
|
|
34
|
-
type AgentFrontmatter = {
|
|
35
|
-
name?: unknown;
|
|
36
|
-
description?: unknown;
|
|
37
|
-
tools?: unknown;
|
|
38
|
-
model?: unknown;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Normalize a frontmatter `tools` value to a list of tool names.
|
|
43
|
-
*
|
|
44
|
-
* Both spellings are valid YAML and both are in use:
|
|
45
|
-
*
|
|
46
|
-
* tools: read, bash # string
|
|
47
|
-
* tools: [read, bash] # array
|
|
48
|
-
*
|
|
49
|
-
* so accept either. Anything else (a number, a map, a nested list) yields no
|
|
50
|
-
* tools rather than throwing: this runs inside agent discovery, where a single
|
|
51
|
-
* bad file must not take down every other agent in the same directory.
|
|
52
|
-
*/
|
|
53
|
-
function parseToolList(value: unknown): string[] | undefined {
|
|
54
|
-
const raw = Array.isArray(value) ? value : typeof value === "string" ? value.split(",") : [];
|
|
55
|
-
const tools = raw
|
|
56
|
-
.filter((t): t is string => typeof t === "string")
|
|
57
|
-
.map((t) => t.trim())
|
|
58
|
-
.filter(Boolean);
|
|
59
|
-
return tools.length > 0 ? tools : undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
|
|
63
|
-
const agents: AgentConfig[] = [];
|
|
64
|
-
|
|
65
|
-
if (!fs.existsSync(dir)) {
|
|
66
|
-
return agents;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let entries: fs.Dirent[];
|
|
70
|
-
try {
|
|
71
|
-
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
72
|
-
} catch {
|
|
73
|
-
return agents;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
for (const entry of entries) {
|
|
77
|
-
if (!entry.name.endsWith(".md")) continue;
|
|
78
|
-
if (!entry.isFile() && !entry.isSymbolicLink()) continue;
|
|
79
|
-
|
|
80
|
-
const filePath = path.join(dir, entry.name);
|
|
81
|
-
let content: string;
|
|
82
|
-
try {
|
|
83
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
84
|
-
} catch {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const { frontmatter, body } = parseFrontmatter<AgentFrontmatter>(content);
|
|
89
|
-
|
|
90
|
-
if (typeof frontmatter.name !== "string" || typeof frontmatter.description !== "string") {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
agents.push({
|
|
95
|
-
name: frontmatter.name,
|
|
96
|
-
description: frontmatter.description,
|
|
97
|
-
tools: parseToolList(frontmatter.tools),
|
|
98
|
-
model: typeof frontmatter.model === "string" ? frontmatter.model : undefined,
|
|
99
|
-
systemPrompt: body,
|
|
100
|
-
source,
|
|
101
|
-
filePath,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return agents;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function isDirectory(p: string): boolean {
|
|
109
|
-
try {
|
|
110
|
-
return fs.statSync(p).isDirectory();
|
|
111
|
-
} catch {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function findNearestProjectAgentsDir(cwd: string): string | null {
|
|
117
|
-
let currentDir = cwd;
|
|
118
|
-
while (true) {
|
|
119
|
-
const candidate = path.join(currentDir, CONFIG_DIR_NAME, "agents");
|
|
120
|
-
if (isDirectory(candidate)) return candidate;
|
|
121
|
-
|
|
122
|
-
const parentDir = path.dirname(currentDir);
|
|
123
|
-
if (parentDir === currentDir) return null;
|
|
124
|
-
currentDir = parentDir;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
|
|
129
|
-
const userDir = path.join(getAgentDir(), "agents");
|
|
130
|
-
const projectAgentsDir = findNearestProjectAgentsDir(cwd);
|
|
131
|
-
|
|
132
|
-
const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
|
|
133
|
-
const projectAgents = scope === "user" || !projectAgentsDir ? [] : loadAgentsFromDir(projectAgentsDir, "project");
|
|
134
|
-
|
|
135
|
-
const agentMap = new Map<string, AgentConfig>();
|
|
136
|
-
|
|
137
|
-
if (scope === "both") {
|
|
138
|
-
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
|
139
|
-
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
|
140
|
-
} else if (scope === "user") {
|
|
141
|
-
for (const agent of userAgents) agentMap.set(agent.name, agent);
|
|
142
|
-
} else {
|
|
143
|
-
for (const agent of projectAgents) agentMap.set(agent.name, agent);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return { agents: Array.from(agentMap.values()), projectAgentsDir };
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function formatAgentList(agents: AgentConfig[], maxItems: number): { text: string; remaining: number } {
|
|
150
|
-
if (agents.length === 0) return { text: "none", remaining: 0 };
|
|
151
|
-
const listed = agents.slice(0, maxItems);
|
|
152
|
-
const remaining = agents.length - listed.length;
|
|
153
|
-
return {
|
|
154
|
-
text: listed.map((a) => `${a.name} (${a.source}): ${a.description}`).join("; "),
|
|
155
|
-
remaining,
|
|
156
|
-
};
|
|
157
|
-
}
|