@getpochi/cli 0.5.34 → 0.5.35
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/dist/cli.js +86 -37
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -346497,6 +346497,24 @@ var WebsiteTaskCreateEvent = exports_external2.object({
|
|
|
346497
346497
|
githubTemplateUrl: exports_external2.string().optional()
|
|
346498
346498
|
})
|
|
346499
346499
|
});
|
|
346500
|
+
// ../common/src/base/error.ts
|
|
346501
|
+
function toErrorMessage(error40) {
|
|
346502
|
+
if (error40 == null) {
|
|
346503
|
+
return "unknown error";
|
|
346504
|
+
}
|
|
346505
|
+
if (typeof error40 === "string") {
|
|
346506
|
+
return error40;
|
|
346507
|
+
}
|
|
346508
|
+
if (error40 instanceof Error) {
|
|
346509
|
+
return error40.message;
|
|
346510
|
+
}
|
|
346511
|
+
return JSON.stringify(error40);
|
|
346512
|
+
}
|
|
346513
|
+
// ../common/src/vscode-webui-bridge/types/custom-agent.ts
|
|
346514
|
+
var isValidCustomAgentFile = (agent) => {
|
|
346515
|
+
return agent.name !== undefined && agent.description !== undefined && agent.systemPrompt !== undefined && !agent.error;
|
|
346516
|
+
};
|
|
346517
|
+
|
|
346500
346518
|
// ../common/src/vscode-webui-bridge/index.ts
|
|
346501
346519
|
var isPochiDev = process.env.POCHI_LOCAL_SERVER === "true";
|
|
346502
346520
|
var isSyncDev = process.env.POCHI_LOCAL_SYNC_SERVER === "true";
|
|
@@ -355562,7 +355580,7 @@ var {
|
|
|
355562
355580
|
// package.json
|
|
355563
355581
|
var package_default = {
|
|
355564
355582
|
name: "@getpochi/cli",
|
|
355565
|
-
version: "0.5.
|
|
355583
|
+
version: "0.5.35",
|
|
355566
355584
|
type: "module",
|
|
355567
355585
|
bin: {
|
|
355568
355586
|
pochi: "src/cli.ts"
|
|
@@ -367108,34 +367126,72 @@ function matter2(file2, options) {
|
|
|
367108
367126
|
}
|
|
367109
367127
|
}
|
|
367110
367128
|
// ../common/src/tool-utils/agent-parser.ts
|
|
367111
|
-
|
|
367112
|
-
|
|
367113
|
-
|
|
367129
|
+
var CustomAgentFrontmatter = v4_default.object({
|
|
367130
|
+
name: v4_default.string().optional(),
|
|
367131
|
+
description: v4_default.string(),
|
|
367132
|
+
tools: v4_default.union([v4_default.string(), v4_default.array(v4_default.string())]).optional()
|
|
367133
|
+
});
|
|
367134
|
+
async function parseAgentFile(filePath, readFileContent) {
|
|
367135
|
+
const defaultName = path8.basename(filePath, path8.extname(filePath));
|
|
367136
|
+
let content3;
|
|
367137
|
+
try {
|
|
367138
|
+
content3 = await readFileContent(filePath);
|
|
367139
|
+
} catch (error40) {
|
|
367140
|
+
return {
|
|
367141
|
+
name: defaultName,
|
|
367142
|
+
filePath,
|
|
367143
|
+
error: "readError",
|
|
367144
|
+
message: toErrorMessage(error40)
|
|
367145
|
+
};
|
|
367146
|
+
}
|
|
367147
|
+
let vfile2;
|
|
367148
|
+
try {
|
|
367149
|
+
vfile2 = await remark().use(remarkFrontmatter, [{ type: "yaml", marker: "-" }]).use(() => (_tree, file2) => matter2(file2)).process(content3);
|
|
367150
|
+
} catch (error40) {
|
|
367151
|
+
return {
|
|
367152
|
+
name: defaultName,
|
|
367153
|
+
filePath,
|
|
367154
|
+
error: "parseError",
|
|
367155
|
+
message: toErrorMessage(error40)
|
|
367156
|
+
};
|
|
367157
|
+
}
|
|
367158
|
+
const systemPrompt = vfile2.value.toString().trim();
|
|
367159
|
+
if (!vfile2.data.matter || Object.keys(vfile2.data.matter).length === 0) {
|
|
367160
|
+
return {
|
|
367161
|
+
name: defaultName,
|
|
367162
|
+
filePath,
|
|
367163
|
+
error: "parseError",
|
|
367164
|
+
message: "No agent definition found in the frontmatter of the file.",
|
|
367165
|
+
systemPrompt
|
|
367166
|
+
};
|
|
367167
|
+
}
|
|
367168
|
+
const parseResult = CustomAgentFrontmatter.safeParse(vfile2.data.matter);
|
|
367114
367169
|
if (!parseResult.success) {
|
|
367115
|
-
return
|
|
367170
|
+
return {
|
|
367171
|
+
name: defaultName,
|
|
367172
|
+
filePath,
|
|
367173
|
+
error: "validationError",
|
|
367174
|
+
message: parseResult.error.issues.map((i3) => `Field \`${i3.path}\` parse error, ${i3.message}`).join("; "),
|
|
367175
|
+
systemPrompt
|
|
367176
|
+
};
|
|
367116
367177
|
}
|
|
367117
367178
|
const frontmatterData = parseResult.data;
|
|
367118
|
-
const systemPrompt = file2.value.toString().trim();
|
|
367119
|
-
const defaultName = path8.basename(filePath, path8.extname(filePath));
|
|
367120
367179
|
const toolsRaw = frontmatterData.tools;
|
|
367121
367180
|
let tools;
|
|
367122
367181
|
if (typeof toolsRaw === "string") {
|
|
367123
|
-
|
|
367182
|
+
const toolsRawStr = toolsRaw.trim();
|
|
367183
|
+
tools = toolsRawStr.length > 0 ? toolsRawStr.split(",").map((tool3) => tool3.trim()) : [];
|
|
367124
367184
|
} else if (Array.isArray(toolsRaw)) {
|
|
367125
|
-
tools = toolsRaw;
|
|
367185
|
+
tools = toolsRaw.map((tool3) => tool3.trim()).filter((tool3) => tool3.length > 0);
|
|
367126
367186
|
}
|
|
367127
367187
|
return {
|
|
367188
|
+
filePath,
|
|
367128
367189
|
name: frontmatterData.name || defaultName,
|
|
367129
367190
|
tools,
|
|
367130
367191
|
description: frontmatterData.description,
|
|
367131
367192
|
systemPrompt
|
|
367132
367193
|
};
|
|
367133
367194
|
}
|
|
367134
|
-
var CustomAgentFrontmatter = v4_default.object({
|
|
367135
|
-
name: v4_default.string().optional(),
|
|
367136
|
-
description: v4_default.string(),
|
|
367137
|
-
tools: v4_default.union([v4_default.string(), v4_default.array(v4_default.string())]).optional()
|
|
367138
|
-
});
|
|
367139
367195
|
// src/lib/load-agents.ts
|
|
367140
367196
|
var logger13 = getLogger("CustomAgentManager");
|
|
367141
367197
|
async function readAgentsFromDir(dir) {
|
|
@@ -367148,15 +367204,9 @@ async function readAgentsFromDir(dir) {
|
|
|
367148
367204
|
for (const fileName of files) {
|
|
367149
367205
|
if (fileName.endsWith(".md")) {
|
|
367150
367206
|
const filePath = path9.join(dir, fileName);
|
|
367151
|
-
|
|
367152
|
-
|
|
367153
|
-
|
|
367154
|
-
if (agent) {
|
|
367155
|
-
agents.push({ ...agent, filePath });
|
|
367156
|
-
}
|
|
367157
|
-
} catch (error40) {
|
|
367158
|
-
logger13.debug(`Could not read agent file ${filePath}:`, error40);
|
|
367159
|
-
}
|
|
367207
|
+
const readFileContent = async (filePath2) => await fs5.readFile(filePath2, "utf-8");
|
|
367208
|
+
const agent = await parseAgentFile(filePath, readFileContent);
|
|
367209
|
+
agents.push({ ...agent, filePath });
|
|
367160
367210
|
}
|
|
367161
367211
|
}
|
|
367162
367212
|
} catch (error40) {
|
|
@@ -367173,8 +367223,15 @@ async function loadAgents(workingDirectory) {
|
|
|
367173
367223
|
}
|
|
367174
367224
|
const systemAgentsDir = path9.join(os6.homedir(), ".pochi", "agents");
|
|
367175
367225
|
allAgents.push(...await readAgentsFromDir(systemAgentsDir));
|
|
367176
|
-
|
|
367177
|
-
|
|
367226
|
+
const validAgents = allAgents.filter((agent) => {
|
|
367227
|
+
if (isValidCustomAgentFile(agent)) {
|
|
367228
|
+
return true;
|
|
367229
|
+
}
|
|
367230
|
+
logger13.warn(`Ignoring invalid custom agent file ${agent.filePath}: [${agent.error}] ${agent.message}`);
|
|
367231
|
+
return false;
|
|
367232
|
+
});
|
|
367233
|
+
logger13.debug(`Loaded ${allAgents.length} custom agents (${validAgents.length} valid, ${allAgents.length - validAgents.length} invalid)`);
|
|
367234
|
+
return validAgents;
|
|
367178
367235
|
} catch (error40) {
|
|
367179
367236
|
logger13.error("Failed to load custom agents", error40);
|
|
367180
367237
|
return [];
|
|
@@ -372750,6 +372807,7 @@ class McpConnection {
|
|
|
372750
372807
|
command: this.config.command,
|
|
372751
372808
|
args: this.config.args,
|
|
372752
372809
|
cwd: this.config.cwd,
|
|
372810
|
+
stderr: "ignore",
|
|
372753
372811
|
env: {
|
|
372754
372812
|
...getDefaultEnvironment(),
|
|
372755
372813
|
...this.config.env
|
|
@@ -398788,7 +398846,7 @@ async function executeToolCall(tool3, options4, abortSignal) {
|
|
|
398788
398846
|
});
|
|
398789
398847
|
} catch (e11) {
|
|
398790
398848
|
return {
|
|
398791
|
-
error:
|
|
398849
|
+
error: toErrorMessage(e11)
|
|
398792
398850
|
};
|
|
398793
398851
|
}
|
|
398794
398852
|
}
|
|
@@ -398805,7 +398863,7 @@ async function executeToolCall(tool3, options4, abortSignal) {
|
|
|
398805
398863
|
return result2;
|
|
398806
398864
|
} catch (e11) {
|
|
398807
398865
|
return {
|
|
398808
|
-
error:
|
|
398866
|
+
error: toErrorMessage(e11)
|
|
398809
398867
|
};
|
|
398810
398868
|
}
|
|
398811
398869
|
}
|
|
@@ -398814,15 +398872,6 @@ async function executeToolCall(tool3, options4, abortSignal) {
|
|
|
398814
398872
|
error: `Tool ${toolName} not found.`
|
|
398815
398873
|
};
|
|
398816
398874
|
}
|
|
398817
|
-
function toErrorString(e11) {
|
|
398818
|
-
if (e11 instanceof Error) {
|
|
398819
|
-
return e11.message;
|
|
398820
|
-
}
|
|
398821
|
-
if (typeof e11 === "string") {
|
|
398822
|
-
return e11;
|
|
398823
|
-
}
|
|
398824
|
-
return JSON.stringify(e11);
|
|
398825
|
-
}
|
|
398826
398875
|
|
|
398827
398876
|
// src/task-runner.ts
|
|
398828
398877
|
var logger28 = getLogger("TaskRunner");
|
|
@@ -399226,7 +399275,7 @@ async function downloadAndInstall(program5, release2) {
|
|
|
399226
399275
|
// package.json
|
|
399227
399276
|
var package_default2 = {
|
|
399228
399277
|
name: "@getpochi/cli",
|
|
399229
|
-
version: "0.5.
|
|
399278
|
+
version: "0.5.35",
|
|
399230
399279
|
type: "module",
|
|
399231
399280
|
bin: {
|
|
399232
399281
|
pochi: "src/cli.ts"
|