agentv 0.17.0 → 0.19.0
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/{chunk-KL3Y2C6J.js → chunk-EJTXU5JO.js} +421 -308
- package/dist/chunk-EJTXU5JO.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/.claude/skills/agentv-prompt-optimizer/SKILL.md +35 -27
- package/package.json +2 -2
- package/dist/chunk-KL3Y2C6J.js.map +0 -1
|
@@ -145,13 +145,13 @@ import { readFileSync as readFileSync2 } from "node:fs";
|
|
|
145
145
|
import { Command } from "commander";
|
|
146
146
|
|
|
147
147
|
// src/commands/eval/index.ts
|
|
148
|
-
import { stat as
|
|
148
|
+
import { stat as stat4 } from "node:fs/promises";
|
|
149
149
|
import path19 from "node:path";
|
|
150
150
|
import fg from "fast-glob";
|
|
151
151
|
|
|
152
152
|
// src/commands/eval/run-eval.ts
|
|
153
153
|
import { constants as constants6 } from "node:fs";
|
|
154
|
-
import { access as access6, mkdir as
|
|
154
|
+
import { access as access6, mkdir as mkdir7 } from "node:fs/promises";
|
|
155
155
|
import path18 from "node:path";
|
|
156
156
|
import { pathToFileURL } from "node:url";
|
|
157
157
|
|
|
@@ -4874,18 +4874,18 @@ function isAgentProvider(provider) {
|
|
|
4874
4874
|
import { readFile as readFile5 } from "node:fs/promises";
|
|
4875
4875
|
import path62 from "node:path";
|
|
4876
4876
|
import { parse as parse22 } from "yaml";
|
|
4877
|
-
import { readFile as
|
|
4877
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
4878
4878
|
import path22 from "node:path";
|
|
4879
4879
|
import micromatch from "micromatch";
|
|
4880
4880
|
import { parse as parse5 } from "yaml";
|
|
4881
4881
|
import { constants as constants3 } from "node:fs";
|
|
4882
4882
|
import { access as access3 } from "node:fs/promises";
|
|
4883
|
-
import
|
|
4883
|
+
import path12 from "node:path";
|
|
4884
4884
|
import path32 from "node:path";
|
|
4885
4885
|
import { readFile as readFile22 } from "node:fs/promises";
|
|
4886
4886
|
import { readFile as readFile32 } from "node:fs/promises";
|
|
4887
4887
|
import path42 from "node:path";
|
|
4888
|
-
import { readFile as
|
|
4888
|
+
import { readFile as readFile42 } from "node:fs/promises";
|
|
4889
4889
|
import path52 from "node:path";
|
|
4890
4890
|
|
|
4891
4891
|
// ../../node_modules/.bun/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
@@ -32481,34 +32481,21 @@ import { promisify as promisify2 } from "node:util";
|
|
|
32481
32481
|
import { exec as execCallback, spawn as spawn2 } from "node:child_process";
|
|
32482
32482
|
import { randomUUID } from "node:crypto";
|
|
32483
32483
|
import { constants as constants22, createWriteStream } from "node:fs";
|
|
32484
|
-
import { access as access22, mkdir as
|
|
32484
|
+
import { access as access22, mkdir as mkdir4, mkdtemp, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
|
|
32485
32485
|
import { tmpdir } from "node:os";
|
|
32486
|
-
import
|
|
32486
|
+
import path92 from "node:path";
|
|
32487
32487
|
import { promisify as promisify22 } from "node:util";
|
|
32488
32488
|
import path82 from "node:path";
|
|
32489
|
-
import
|
|
32489
|
+
import path102 from "node:path";
|
|
32490
32490
|
|
|
32491
|
-
// ../../node_modules/.bun/subagent@0.
|
|
32492
|
-
import {
|
|
32493
|
-
import
|
|
32494
|
-
import path6 from "path";
|
|
32495
|
-
import { promisify } from "util";
|
|
32491
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/agentDispatch.js
|
|
32492
|
+
import { stat as stat3, writeFile as writeFile3 } from "fs/promises";
|
|
32493
|
+
import path10 from "path";
|
|
32496
32494
|
|
|
32497
|
-
// ../../node_modules/.bun/subagent@0.
|
|
32498
|
-
import os from "os";
|
|
32499
|
-
import path2 from "path";
|
|
32500
|
-
var DEFAULT_LOCK_NAME = "subagent.lock";
|
|
32501
|
-
var DEFAULT_ALIVE_FILENAME = ".alive";
|
|
32502
|
-
function getDefaultSubagentRoot(vscodeCmd = "code") {
|
|
32503
|
-
const folder = vscodeCmd === "code-insiders" ? "vscode-insiders-agents" : "vscode-agents";
|
|
32504
|
-
return path2.join(os.homedir(), ".subagent", folder);
|
|
32505
|
-
}
|
|
32506
|
-
var DEFAULT_SUBAGENT_ROOT = getDefaultSubagentRoot();
|
|
32507
|
-
|
|
32508
|
-
// ../../node_modules/.bun/subagent@0.4.7/node_modules/subagent/dist/utils/fs.js
|
|
32495
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/utils/fs.js
|
|
32509
32496
|
import { constants as constants2 } from "fs";
|
|
32510
32497
|
import { access as access2, mkdir, readdir, rm, stat } from "fs/promises";
|
|
32511
|
-
import
|
|
32498
|
+
import path2 from "path";
|
|
32512
32499
|
async function pathExists(target) {
|
|
32513
32500
|
try {
|
|
32514
32501
|
await access2(target, constants2.F_OK);
|
|
@@ -32524,7 +32511,7 @@ async function readDirEntries(target) {
|
|
|
32524
32511
|
const entries = await readdir(target, { withFileTypes: true });
|
|
32525
32512
|
return entries.map((entry) => ({
|
|
32526
32513
|
name: entry.name,
|
|
32527
|
-
absolutePath:
|
|
32514
|
+
absolutePath: path2.join(target, entry.name),
|
|
32528
32515
|
isDirectory: entry.isDirectory()
|
|
32529
32516
|
}));
|
|
32530
32517
|
}
|
|
@@ -32538,10 +32525,10 @@ async function removeIfExists(target) {
|
|
|
32538
32525
|
}
|
|
32539
32526
|
}
|
|
32540
32527
|
|
|
32541
|
-
// ../../node_modules/.bun/subagent@0.
|
|
32542
|
-
import
|
|
32528
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/utils/path.js
|
|
32529
|
+
import path3 from "path";
|
|
32543
32530
|
function pathToFileUri(filePath) {
|
|
32544
|
-
const absolutePath =
|
|
32531
|
+
const absolutePath = path3.isAbsolute(filePath) ? filePath : path3.resolve(filePath);
|
|
32545
32532
|
const normalizedPath = absolutePath.replace(/\\/g, "/");
|
|
32546
32533
|
if (/^[a-zA-Z]:\//.test(normalizedPath)) {
|
|
32547
32534
|
return `file:///${normalizedPath}`;
|
|
@@ -32549,14 +32536,22 @@ function pathToFileUri(filePath) {
|
|
|
32549
32536
|
return `file://${normalizedPath}`;
|
|
32550
32537
|
}
|
|
32551
32538
|
|
|
32552
|
-
// ../../node_modules/.bun/subagent@0.
|
|
32553
|
-
|
|
32554
|
-
|
|
32555
|
-
|
|
32556
|
-
|
|
32539
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/workspaceManager.js
|
|
32540
|
+
import { copyFile, mkdir as mkdir2, readdir as readdir2, readFile as readFile2, stat as stat2, writeFile } from "fs/promises";
|
|
32541
|
+
import path6 from "path";
|
|
32542
|
+
|
|
32543
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/constants.js
|
|
32544
|
+
import os from "os";
|
|
32545
|
+
import path4 from "path";
|
|
32546
|
+
var DEFAULT_LOCK_NAME = "subagent.lock";
|
|
32547
|
+
var DEFAULT_ALIVE_FILENAME = ".alive";
|
|
32548
|
+
function getDefaultSubagentRoot(vscodeCmd = "code") {
|
|
32549
|
+
const folder = vscodeCmd === "code-insiders" ? "vscode-insiders-agents" : "vscode-agents";
|
|
32550
|
+
return path4.join(os.homedir(), ".subagent", folder);
|
|
32557
32551
|
}
|
|
32552
|
+
var DEFAULT_SUBAGENT_ROOT = getDefaultSubagentRoot();
|
|
32558
32553
|
|
|
32559
|
-
// ../../node_modules/.bun/subagent@0.
|
|
32554
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/utils/workspace.js
|
|
32560
32555
|
import path5 from "path";
|
|
32561
32556
|
|
|
32562
32557
|
// ../../node_modules/.bun/json5@2.2.3/node_modules/json5/dist/index.mjs
|
|
@@ -33644,7 +33639,7 @@ var JSON5 = {
|
|
|
33644
33639
|
var lib = JSON5;
|
|
33645
33640
|
var dist_default = lib;
|
|
33646
33641
|
|
|
33647
|
-
// ../../node_modules/.bun/subagent@0.
|
|
33642
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/utils/workspace.js
|
|
33648
33643
|
function transformWorkspacePaths(workspaceContent, templateDir) {
|
|
33649
33644
|
let workspace;
|
|
33650
33645
|
try {
|
|
@@ -33717,11 +33712,7 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
|
|
|
33717
33712
|
return JSON.stringify(transformedWorkspace, null, 2);
|
|
33718
33713
|
}
|
|
33719
33714
|
|
|
33720
|
-
// ../../node_modules/.bun/subagent@0.
|
|
33721
|
-
var execAsync = promisify(exec);
|
|
33722
|
-
function generateTimestamp() {
|
|
33723
|
-
return (/* @__PURE__ */ new Date()).toISOString().replace(/[-:TZ.]/g, "").slice(0, 14);
|
|
33724
|
-
}
|
|
33715
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/workspaceManager.js
|
|
33725
33716
|
var DEFAULT_WORKSPACE_TEMPLATE = {
|
|
33726
33717
|
folders: [
|
|
33727
33718
|
{
|
|
@@ -33729,27 +33720,9 @@ var DEFAULT_WORKSPACE_TEMPLATE = {
|
|
|
33729
33720
|
}
|
|
33730
33721
|
]
|
|
33731
33722
|
};
|
|
33732
|
-
var DEFAULT_WAKEUP_CONTENT = `---
|
|
33733
|
-
description: 'Wake-up Signal'
|
|
33734
|
-
model: Grok Code Fast 1 (copilot)
|
|
33735
|
-
---`;
|
|
33736
33723
|
function getSubagentRoot(vscodeCmd = "code") {
|
|
33737
33724
|
return getDefaultSubagentRoot(vscodeCmd);
|
|
33738
33725
|
}
|
|
33739
|
-
async function resolvePromptFile(promptFile) {
|
|
33740
|
-
if (!promptFile) {
|
|
33741
|
-
return void 0;
|
|
33742
|
-
}
|
|
33743
|
-
const resolvedPrompt = path6.resolve(promptFile);
|
|
33744
|
-
if (!await pathExists(resolvedPrompt)) {
|
|
33745
|
-
throw new Error(`Prompt file not found: ${resolvedPrompt}`);
|
|
33746
|
-
}
|
|
33747
|
-
const promptStats = await stat2(resolvedPrompt);
|
|
33748
|
-
if (!promptStats.isFile()) {
|
|
33749
|
-
throw new Error(`Prompt file must be a file, not a directory: ${resolvedPrompt}`);
|
|
33750
|
-
}
|
|
33751
|
-
return resolvedPrompt;
|
|
33752
|
-
}
|
|
33753
33726
|
async function findUnlockedSubagent(subagentRoot) {
|
|
33754
33727
|
if (!await pathExists(subagentRoot)) {
|
|
33755
33728
|
return null;
|
|
@@ -33767,42 +33740,6 @@ async function findUnlockedSubagent(subagentRoot) {
|
|
|
33767
33740
|
}
|
|
33768
33741
|
return null;
|
|
33769
33742
|
}
|
|
33770
|
-
async function checkWorkspaceOpened(workspaceName, vscodeCmd) {
|
|
33771
|
-
try {
|
|
33772
|
-
const { stdout } = await execAsync(`${vscodeCmd} --status`, { timeout: 1e4, windowsHide: true });
|
|
33773
|
-
return stdout.includes(workspaceName);
|
|
33774
|
-
} catch {
|
|
33775
|
-
return false;
|
|
33776
|
-
}
|
|
33777
|
-
}
|
|
33778
|
-
async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir, vscodeCmd, pollInterval = 1, timeout = 60) {
|
|
33779
|
-
const alreadyOpen = await checkWorkspaceOpened(workspaceName, vscodeCmd);
|
|
33780
|
-
if (alreadyOpen) {
|
|
33781
|
-
spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
|
|
33782
|
-
return true;
|
|
33783
|
-
}
|
|
33784
|
-
const aliveFile = path6.join(subagentDir, DEFAULT_ALIVE_FILENAME);
|
|
33785
|
-
await removeIfExists(aliveFile);
|
|
33786
|
-
const githubAgentsDir = path6.join(subagentDir, ".github", "agents");
|
|
33787
|
-
await mkdir2(githubAgentsDir, { recursive: true });
|
|
33788
|
-
const wakeupDst = path6.join(githubAgentsDir, "wakeup.md");
|
|
33789
|
-
const subagentDst = path6.join(githubAgentsDir, "subagent.md");
|
|
33790
|
-
await writeFile(wakeupDst, DEFAULT_WAKEUP_CONTENT, "utf8");
|
|
33791
|
-
spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
|
|
33792
|
-
await sleep(100);
|
|
33793
|
-
const wakeupChatId = "wakeup";
|
|
33794
|
-
const chatArgs = ["-r", "chat", "-m", wakeupChatId, `create a file named .alive in the ${path6.basename(subagentDir)} folder`];
|
|
33795
|
-
spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
|
|
33796
|
-
const start = Date.now();
|
|
33797
|
-
while (!await pathExists(aliveFile)) {
|
|
33798
|
-
if (Date.now() - start > timeout * 1e3) {
|
|
33799
|
-
console.error(`warning: Workspace readiness timeout after ${timeout}s`);
|
|
33800
|
-
return false;
|
|
33801
|
-
}
|
|
33802
|
-
await sleep(pollInterval * 1e3);
|
|
33803
|
-
}
|
|
33804
|
-
return true;
|
|
33805
|
-
}
|
|
33806
33743
|
async function copyAgentConfig(subagentDir, workspaceTemplate) {
|
|
33807
33744
|
let workspaceContent;
|
|
33808
33745
|
if (workspaceTemplate) {
|
|
@@ -33852,6 +33789,263 @@ async function removeSubagentLock(subagentDir) {
|
|
|
33852
33789
|
const lockFile = path6.join(subagentDir, DEFAULT_LOCK_NAME);
|
|
33853
33790
|
await removeIfExists(lockFile);
|
|
33854
33791
|
}
|
|
33792
|
+
async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspaceTemplate, dryRun) {
|
|
33793
|
+
if (dryRun) {
|
|
33794
|
+
return 0;
|
|
33795
|
+
}
|
|
33796
|
+
try {
|
|
33797
|
+
await copyAgentConfig(subagentDir, workspaceTemplate);
|
|
33798
|
+
} catch (error40) {
|
|
33799
|
+
console.error(`error: ${error40.message}`);
|
|
33800
|
+
return 1;
|
|
33801
|
+
}
|
|
33802
|
+
try {
|
|
33803
|
+
await createSubagentLock(subagentDir);
|
|
33804
|
+
} catch (error40) {
|
|
33805
|
+
console.error(`error: Failed to create subagent lock: ${error40.message}`);
|
|
33806
|
+
return 1;
|
|
33807
|
+
}
|
|
33808
|
+
if (promptFile) {
|
|
33809
|
+
const githubAgentsDir = path6.join(subagentDir, ".github", "agents");
|
|
33810
|
+
await mkdir2(githubAgentsDir, { recursive: true });
|
|
33811
|
+
const agentFile = path6.join(githubAgentsDir, `${chatId}.md`);
|
|
33812
|
+
try {
|
|
33813
|
+
await copyFile(promptFile, agentFile);
|
|
33814
|
+
} catch (error40) {
|
|
33815
|
+
console.error(`error: Failed to copy prompt file to agent mode: ${error40.message}`);
|
|
33816
|
+
return 1;
|
|
33817
|
+
}
|
|
33818
|
+
}
|
|
33819
|
+
return 0;
|
|
33820
|
+
}
|
|
33821
|
+
|
|
33822
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/vscodeProcess.js
|
|
33823
|
+
import { exec, spawn } from "child_process";
|
|
33824
|
+
import { mkdir as mkdir3, writeFile as writeFile2 } from "fs/promises";
|
|
33825
|
+
import path7 from "path";
|
|
33826
|
+
import { promisify } from "util";
|
|
33827
|
+
|
|
33828
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/utils/time.js
|
|
33829
|
+
function sleep(ms) {
|
|
33830
|
+
return new Promise((resolve2) => {
|
|
33831
|
+
setTimeout(resolve2, ms);
|
|
33832
|
+
});
|
|
33833
|
+
}
|
|
33834
|
+
|
|
33835
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/vscodeProcess.js
|
|
33836
|
+
var execAsync = promisify(exec);
|
|
33837
|
+
var DEFAULT_WAKEUP_CONTENT = `---
|
|
33838
|
+
description: 'Wake-up Signal'
|
|
33839
|
+
model: Grok Code Fast 1 (copilot)
|
|
33840
|
+
---`;
|
|
33841
|
+
async function checkWorkspaceOpened(workspaceName, vscodeCmd) {
|
|
33842
|
+
try {
|
|
33843
|
+
const { stdout } = await execAsync(`${vscodeCmd} --status`, { timeout: 1e4, windowsHide: true });
|
|
33844
|
+
return stdout.includes(workspaceName);
|
|
33845
|
+
} catch {
|
|
33846
|
+
return false;
|
|
33847
|
+
}
|
|
33848
|
+
}
|
|
33849
|
+
async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir, vscodeCmd, pollInterval = 1, timeout = 60) {
|
|
33850
|
+
const alreadyOpen = await checkWorkspaceOpened(workspaceName, vscodeCmd);
|
|
33851
|
+
if (alreadyOpen) {
|
|
33852
|
+
spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
|
|
33853
|
+
return true;
|
|
33854
|
+
}
|
|
33855
|
+
const aliveFile = path7.join(subagentDir, DEFAULT_ALIVE_FILENAME);
|
|
33856
|
+
await removeIfExists(aliveFile);
|
|
33857
|
+
const githubAgentsDir = path7.join(subagentDir, ".github", "agents");
|
|
33858
|
+
await mkdir3(githubAgentsDir, { recursive: true });
|
|
33859
|
+
const wakeupDst = path7.join(githubAgentsDir, "wakeup.md");
|
|
33860
|
+
await writeFile2(wakeupDst, DEFAULT_WAKEUP_CONTENT, "utf8");
|
|
33861
|
+
spawn(vscodeCmd, [workspacePath], { windowsHide: true, shell: true, detached: false });
|
|
33862
|
+
await sleep(100);
|
|
33863
|
+
const wakeupChatId = "wakeup";
|
|
33864
|
+
const chatArgs = [
|
|
33865
|
+
"-r",
|
|
33866
|
+
"chat",
|
|
33867
|
+
"-m",
|
|
33868
|
+
wakeupChatId,
|
|
33869
|
+
`create a file named .alive in the ${path7.basename(subagentDir)} folder`
|
|
33870
|
+
];
|
|
33871
|
+
spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
|
|
33872
|
+
const start = Date.now();
|
|
33873
|
+
while (!await pathExists(aliveFile)) {
|
|
33874
|
+
if (Date.now() - start > timeout * 1e3) {
|
|
33875
|
+
console.error(`warning: Workspace readiness timeout after ${timeout}s`);
|
|
33876
|
+
return false;
|
|
33877
|
+
}
|
|
33878
|
+
await sleep(pollInterval * 1e3);
|
|
33879
|
+
}
|
|
33880
|
+
return true;
|
|
33881
|
+
}
|
|
33882
|
+
async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, requestInstructions, timestamp, vscodeCmd) {
|
|
33883
|
+
try {
|
|
33884
|
+
const workspacePath = path7.join(subagentDir, `${path7.basename(subagentDir)}.code-workspace`);
|
|
33885
|
+
const messagesDir = path7.join(subagentDir, "messages");
|
|
33886
|
+
await mkdir3(messagesDir, { recursive: true });
|
|
33887
|
+
const reqFile = path7.join(messagesDir, `${timestamp}_req.md`);
|
|
33888
|
+
await writeFile2(reqFile, requestInstructions, { encoding: "utf8" });
|
|
33889
|
+
const reqUri = pathToFileUri(reqFile);
|
|
33890
|
+
const chatArgs = ["-r", "chat", "-m", chatId];
|
|
33891
|
+
for (const attachment of attachmentPaths) {
|
|
33892
|
+
chatArgs.push("-a", attachment);
|
|
33893
|
+
}
|
|
33894
|
+
chatArgs.push("-a", reqFile);
|
|
33895
|
+
chatArgs.push(`Follow instructions in [${path7.basename(reqFile)}](${reqUri})`);
|
|
33896
|
+
const workspaceReady = await ensureWorkspaceFocused(workspacePath, path7.basename(subagentDir), subagentDir, vscodeCmd);
|
|
33897
|
+
if (!workspaceReady) {
|
|
33898
|
+
console.error("warning: Workspace may not be fully ready");
|
|
33899
|
+
}
|
|
33900
|
+
await sleep(500);
|
|
33901
|
+
spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
|
|
33902
|
+
return true;
|
|
33903
|
+
} catch (error40) {
|
|
33904
|
+
console.error(`warning: Failed to launch VS Code: ${error40.message}`);
|
|
33905
|
+
return false;
|
|
33906
|
+
}
|
|
33907
|
+
}
|
|
33908
|
+
async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, chatInstruction, vscodeCmd) {
|
|
33909
|
+
try {
|
|
33910
|
+
const workspacePath = path7.join(subagentDir, `${path7.basename(subagentDir)}.code-workspace`);
|
|
33911
|
+
const messagesDir = path7.join(subagentDir, "messages");
|
|
33912
|
+
await mkdir3(messagesDir, { recursive: true });
|
|
33913
|
+
const chatArgs = ["-r", "chat", "-m", chatId];
|
|
33914
|
+
for (const attachment of attachmentPaths) {
|
|
33915
|
+
chatArgs.push("-a", attachment);
|
|
33916
|
+
}
|
|
33917
|
+
chatArgs.push(chatInstruction);
|
|
33918
|
+
const workspaceReady = await ensureWorkspaceFocused(workspacePath, path7.basename(subagentDir), subagentDir, vscodeCmd);
|
|
33919
|
+
if (!workspaceReady) {
|
|
33920
|
+
console.error("warning: Workspace may not be fully ready");
|
|
33921
|
+
}
|
|
33922
|
+
await sleep(500);
|
|
33923
|
+
spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
|
|
33924
|
+
return true;
|
|
33925
|
+
} catch (error40) {
|
|
33926
|
+
console.error(`warning: Failed to launch VS Code: ${error40.message}`);
|
|
33927
|
+
return false;
|
|
33928
|
+
}
|
|
33929
|
+
}
|
|
33930
|
+
|
|
33931
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/promptBuilder.js
|
|
33932
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
33933
|
+
import path8 from "path";
|
|
33934
|
+
|
|
33935
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/utils/template.js
|
|
33936
|
+
function renderTemplate(content, variables) {
|
|
33937
|
+
if (!content) {
|
|
33938
|
+
return content;
|
|
33939
|
+
}
|
|
33940
|
+
const variableLookup = /* @__PURE__ */ new Map();
|
|
33941
|
+
for (const [key2, value] of Object.entries(variables)) {
|
|
33942
|
+
variableLookup.set(key2.toLowerCase(), value);
|
|
33943
|
+
}
|
|
33944
|
+
const referencedVariables = /* @__PURE__ */ new Set();
|
|
33945
|
+
const result = content.replace(/\{\{([a-zA-Z_]+)\}\}/gi, (match, variableName) => {
|
|
33946
|
+
const lowerCaseKey = variableName.toLowerCase();
|
|
33947
|
+
referencedVariables.add(lowerCaseKey);
|
|
33948
|
+
if (!variableLookup.has(lowerCaseKey)) {
|
|
33949
|
+
throw new Error(`Template variable '${variableName}' is not provided in the variables object`);
|
|
33950
|
+
}
|
|
33951
|
+
return variableLookup.get(lowerCaseKey);
|
|
33952
|
+
});
|
|
33953
|
+
return result;
|
|
33954
|
+
}
|
|
33955
|
+
|
|
33956
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/templates.js
|
|
33957
|
+
var DEFAULT_REQUEST_TEMPLATE = `[[ ## system_instructions ## ]]
|
|
33958
|
+
|
|
33959
|
+
**IMPORTANT**: Follow these exact steps:
|
|
33960
|
+
1. Do NOT create any additional output files in the workspace.
|
|
33961
|
+
2. Create and write your complete response to: {{responseFileTmp}}
|
|
33962
|
+
3. All intended file outputs/changes MUST be returned INLINE in your response using \`<file path="..."> ... </file>\` tags. For each file, include either:
|
|
33963
|
+
- the full final file content, OR
|
|
33964
|
+
- a unified git diff (preferred when editing an existing file).
|
|
33965
|
+
4. When completely finished, run these PowerShell commands to signal completion:
|
|
33966
|
+
\`\`\`
|
|
33967
|
+
Move-Item -LiteralPath '{{responseFileTmp}}' -Destination '{{responseFileFinal}}'
|
|
33968
|
+
if (Test-Path subagent.lock) { del subagent.lock }
|
|
33969
|
+
\`\`\`
|
|
33970
|
+
|
|
33971
|
+
Do not proceed to step 2 until your response is completely written to the temporary file.
|
|
33972
|
+
|
|
33973
|
+
[[ ## task ## ]]
|
|
33974
|
+
|
|
33975
|
+
{{userQuery}}
|
|
33976
|
+
`;
|
|
33977
|
+
var DEFAULT_BATCH_REQUEST_TEMPLATE = `[[ ## system_instructions ## ]]
|
|
33978
|
+
|
|
33979
|
+
**IMPORTANT**: Follow these exact steps:
|
|
33980
|
+
1. Do NOT create any additional output files in the workspace.
|
|
33981
|
+
2. Create and write your complete response to: {{responseFileTmp}}
|
|
33982
|
+
3. All intended file outputs/changes MUST be returned INLINE in your response using \`<file path="..."> ... </file>\` tags. For each file, include either:
|
|
33983
|
+
- the full final file content, OR
|
|
33984
|
+
- a unified git diff (preferred when editing an existing file).
|
|
33985
|
+
4. When completely finished and the response is stable, rename it to: {{responseFileFinal}}
|
|
33986
|
+
5. Do not unlock the workspace from this request; batch orchestration will handle unlocking after all responses are ready.
|
|
33987
|
+
|
|
33988
|
+
[[ ## task ## ]]
|
|
33989
|
+
|
|
33990
|
+
{{userQuery}}
|
|
33991
|
+
`;
|
|
33992
|
+
var DEFAULT_BATCH_ORCHESTRATOR_TEMPLATE = `MANDATORY: Run #runSubagent tool in your Available Actions for each request file to process them in isolated contexts.
|
|
33993
|
+
DO NOT read the request files yourself - only pass the file paths to each subagent:
|
|
33994
|
+
|
|
33995
|
+
{{requestFiles}}
|
|
33996
|
+
|
|
33997
|
+
After ALL queries complete, verify all responses exist and unlock:
|
|
33998
|
+
|
|
33999
|
+
\`\`\`powershell
|
|
34000
|
+
$responses = @({{responseList}})
|
|
34001
|
+
$missing = $responses | Where-Object { -not (Test-Path "messages/$_") }
|
|
34002
|
+
if ($missing.Count -eq 0) { del subagent.lock }
|
|
34003
|
+
\`\`\`
|
|
34004
|
+
`;
|
|
34005
|
+
|
|
34006
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/promptBuilder.js
|
|
34007
|
+
async function loadTemplateFile(filePath) {
|
|
34008
|
+
try {
|
|
34009
|
+
return await readFile3(filePath, "utf8");
|
|
34010
|
+
} catch (error40) {
|
|
34011
|
+
throw new Error(`Failed to load template file '${filePath}': ${error40.message}`);
|
|
34012
|
+
}
|
|
34013
|
+
}
|
|
34014
|
+
function loadDefaultRequestTemplate() {
|
|
34015
|
+
return DEFAULT_REQUEST_TEMPLATE;
|
|
34016
|
+
}
|
|
34017
|
+
function loadDefaultBatchRequestTemplate() {
|
|
34018
|
+
return DEFAULT_BATCH_REQUEST_TEMPLATE;
|
|
34019
|
+
}
|
|
34020
|
+
function loadDefaultBatchOrchestratorTemplate() {
|
|
34021
|
+
return DEFAULT_BATCH_ORCHESTRATOR_TEMPLATE;
|
|
34022
|
+
}
|
|
34023
|
+
function createRequestPrompt(userQuery, responseFileTmp, responseFileFinal, templateContent) {
|
|
34024
|
+
return renderTemplate(templateContent, {
|
|
34025
|
+
userQuery,
|
|
34026
|
+
responseFileTmp,
|
|
34027
|
+
responseFileFinal
|
|
34028
|
+
});
|
|
34029
|
+
}
|
|
34030
|
+
function createBatchRequestPrompt(userQuery, responseFileTmp, responseFileFinal, templateContent) {
|
|
34031
|
+
return renderTemplate(templateContent, {
|
|
34032
|
+
userQuery,
|
|
34033
|
+
responseFileTmp,
|
|
34034
|
+
responseFileFinal
|
|
34035
|
+
});
|
|
34036
|
+
}
|
|
34037
|
+
function createBatchOrchestratorPrompt(requestFiles, responseFiles, templateContent) {
|
|
34038
|
+
const requestLines = requestFiles.map((file2, index) => `${index + 1}. messages/${path8.basename(file2)}`).join("\n");
|
|
34039
|
+
const responseList = responseFiles.map((file2) => `"${path8.basename(file2)}"`).join(", ");
|
|
34040
|
+
return renderTemplate(templateContent, {
|
|
34041
|
+
requestFiles: requestLines,
|
|
34042
|
+
responseList
|
|
34043
|
+
});
|
|
34044
|
+
}
|
|
34045
|
+
|
|
34046
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/responseWaiter.js
|
|
34047
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
34048
|
+
import path9 from "path";
|
|
33855
34049
|
async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, silent = false) {
|
|
33856
34050
|
if (!silent) {
|
|
33857
34051
|
console.error(`waiting for agent to finish: ${responseFileFinal}`);
|
|
@@ -33870,7 +34064,7 @@ async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, sile
|
|
|
33870
34064
|
const maxAttempts = 10;
|
|
33871
34065
|
while (attempts < maxAttempts) {
|
|
33872
34066
|
try {
|
|
33873
|
-
const content = await
|
|
34067
|
+
const content = await readFile4(responseFileFinal, { encoding: "utf8" });
|
|
33874
34068
|
if (!silent) {
|
|
33875
34069
|
process.stdout.write(`${content}
|
|
33876
34070
|
`);
|
|
@@ -33891,7 +34085,7 @@ async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, sile
|
|
|
33891
34085
|
}
|
|
33892
34086
|
async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, silent = false) {
|
|
33893
34087
|
if (!silent) {
|
|
33894
|
-
const fileList = responseFilesFinal.map((file2) =>
|
|
34088
|
+
const fileList = responseFilesFinal.map((file2) => path9.basename(file2)).join(", ");
|
|
33895
34089
|
console.error(`waiting for ${responseFilesFinal.length} batch response(s): ${fileList}`);
|
|
33896
34090
|
}
|
|
33897
34091
|
try {
|
|
@@ -33917,7 +34111,7 @@ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, sil
|
|
|
33917
34111
|
const maxAttempts = 10;
|
|
33918
34112
|
while (attempts < maxAttempts) {
|
|
33919
34113
|
try {
|
|
33920
|
-
const content = await
|
|
34114
|
+
const content = await readFile4(file2, { encoding: "utf8" });
|
|
33921
34115
|
if (!silent) {
|
|
33922
34116
|
process.stdout.write(`${content}
|
|
33923
34117
|
`);
|
|
@@ -33937,79 +34131,24 @@ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, sil
|
|
|
33937
34131
|
}
|
|
33938
34132
|
return true;
|
|
33939
34133
|
}
|
|
33940
|
-
|
|
33941
|
-
|
|
33942
|
-
|
|
33943
|
-
|
|
33944
|
-
|
|
33945
|
-
|
|
33946
|
-
|
|
33947
|
-
|
|
33948
|
-
return 1;
|
|
34134
|
+
|
|
34135
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/agentDispatch.js
|
|
34136
|
+
function generateTimestamp() {
|
|
34137
|
+
return (/* @__PURE__ */ new Date()).toISOString().replace(/[-:TZ.]/g, "").slice(0, 14);
|
|
34138
|
+
}
|
|
34139
|
+
async function resolvePromptFile(promptFile) {
|
|
34140
|
+
if (!promptFile) {
|
|
34141
|
+
return void 0;
|
|
33949
34142
|
}
|
|
33950
|
-
|
|
33951
|
-
|
|
33952
|
-
|
|
33953
|
-
console.error(`error: Failed to create subagent lock: ${error40.message}`);
|
|
33954
|
-
return 1;
|
|
34143
|
+
const resolvedPrompt = path10.resolve(promptFile);
|
|
34144
|
+
if (!await pathExists(resolvedPrompt)) {
|
|
34145
|
+
throw new Error(`Prompt file not found: ${resolvedPrompt}`);
|
|
33955
34146
|
}
|
|
33956
|
-
|
|
33957
|
-
|
|
33958
|
-
|
|
33959
|
-
const agentFile = path6.join(githubAgentsDir, `${chatId}.md`);
|
|
33960
|
-
try {
|
|
33961
|
-
await copyFile(promptFile, agentFile);
|
|
33962
|
-
} catch (error40) {
|
|
33963
|
-
console.error(`error: Failed to copy prompt file to agent mode: ${error40.message}`);
|
|
33964
|
-
return 1;
|
|
33965
|
-
}
|
|
34147
|
+
const promptStats = await stat3(resolvedPrompt);
|
|
34148
|
+
if (!promptStats.isFile()) {
|
|
34149
|
+
throw new Error(`Prompt file must be a file, not a directory: ${resolvedPrompt}`);
|
|
33966
34150
|
}
|
|
33967
|
-
return
|
|
33968
|
-
}
|
|
33969
|
-
function createRequestPrompt(userQuery, responseFileTmp, responseFileFinal) {
|
|
33970
|
-
return `[[ ## task ## ]]
|
|
33971
|
-
|
|
33972
|
-
${userQuery}
|
|
33973
|
-
|
|
33974
|
-
[[ ## system_instructions ## ]]
|
|
33975
|
-
|
|
33976
|
-
**IMPORTANT**: Follow these exact steps:
|
|
33977
|
-
1. Create and write your complete response to: ${responseFileTmp}
|
|
33978
|
-
2. When completely finished, run these PowerShell commands to signal completion:
|
|
33979
|
-
\`\`\`
|
|
33980
|
-
Move-Item -LiteralPath '${responseFileTmp}' -Destination '${responseFileFinal}'
|
|
33981
|
-
if (Test-Path subagent.lock) { del subagent.lock }
|
|
33982
|
-
\`\`\`
|
|
33983
|
-
|
|
33984
|
-
Do not proceed to step 2 until your response is completely written to the temporary file.`;
|
|
33985
|
-
}
|
|
33986
|
-
function createBatchRequestPrompt(userQuery, responseFileTmp, responseFileFinal) {
|
|
33987
|
-
return `[[ ## task ## ]]
|
|
33988
|
-
|
|
33989
|
-
${userQuery}
|
|
33990
|
-
|
|
33991
|
-
[[ ## system_instructions ## ]]
|
|
33992
|
-
|
|
33993
|
-
Write your complete response to: ${responseFileTmp}
|
|
33994
|
-
When completely finished and the response is stable, rename it to: ${responseFileFinal}
|
|
33995
|
-
Do not unlock the workspace from this request; batch orchestration will handle unlocking after all responses are ready.`;
|
|
33996
|
-
}
|
|
33997
|
-
function createBatchOrchestratorPrompt(requestFiles, responseFiles) {
|
|
33998
|
-
const requestLines = requestFiles.map((file2, index) => `${index + 1}. messages/${path6.basename(file2)}`).join("\n");
|
|
33999
|
-
const responseList = responseFiles.map((file2) => `"${path6.basename(file2)}"`).join(", ");
|
|
34000
|
-
return `MANDATORY: Run #runSubagent tool in your Available Actions for each request file to process them in isolated contexts.
|
|
34001
|
-
DO NOT read the request files yourself - only pass the file paths to each subagent:
|
|
34002
|
-
|
|
34003
|
-
${requestLines}
|
|
34004
|
-
|
|
34005
|
-
After ALL queries complete, verify all responses exist and unlock:
|
|
34006
|
-
|
|
34007
|
-
\`\`\`powershell
|
|
34008
|
-
$responses = @(${responseList})
|
|
34009
|
-
$missing = $responses | Where-Object { -not (Test-Path "messages/$_") }
|
|
34010
|
-
if ($missing.Count -eq 0) { del subagent.lock }
|
|
34011
|
-
\`\`\`
|
|
34012
|
-
`;
|
|
34151
|
+
return resolvedPrompt;
|
|
34013
34152
|
}
|
|
34014
34153
|
async function resolveAttachments(extraAttachments) {
|
|
34015
34154
|
if (!extraAttachments) {
|
|
@@ -34017,7 +34156,7 @@ async function resolveAttachments(extraAttachments) {
|
|
|
34017
34156
|
}
|
|
34018
34157
|
const resolved = [];
|
|
34019
34158
|
for (const attachment of extraAttachments) {
|
|
34020
|
-
const resolvedPath =
|
|
34159
|
+
const resolvedPath = path10.resolve(attachment);
|
|
34021
34160
|
if (!await pathExists(resolvedPath)) {
|
|
34022
34161
|
throw new Error(`Attachment not found: ${resolvedPath}`);
|
|
34023
34162
|
}
|
|
@@ -34025,55 +34164,8 @@ async function resolveAttachments(extraAttachments) {
|
|
|
34025
34164
|
}
|
|
34026
34165
|
return resolved;
|
|
34027
34166
|
}
|
|
34028
|
-
async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, requestInstructions, timestamp, vscodeCmd) {
|
|
34029
|
-
try {
|
|
34030
|
-
const workspacePath = path6.join(subagentDir, `${path6.basename(subagentDir)}.code-workspace`);
|
|
34031
|
-
const messagesDir = path6.join(subagentDir, "messages");
|
|
34032
|
-
await mkdir2(messagesDir, { recursive: true });
|
|
34033
|
-
const reqFile = path6.join(messagesDir, `${timestamp}_req.md`);
|
|
34034
|
-
await writeFile(reqFile, requestInstructions, { encoding: "utf8" });
|
|
34035
|
-
const chatArgs = ["-r", "chat", "-m", chatId];
|
|
34036
|
-
for (const attachment of attachmentPaths) {
|
|
34037
|
-
chatArgs.push("-a", attachment);
|
|
34038
|
-
}
|
|
34039
|
-
chatArgs.push("-a", reqFile);
|
|
34040
|
-
chatArgs.push(`Follow instructions in ${path6.basename(reqFile)}`);
|
|
34041
|
-
const workspaceReady = await ensureWorkspaceFocused(workspacePath, path6.basename(subagentDir), subagentDir, vscodeCmd);
|
|
34042
|
-
if (!workspaceReady) {
|
|
34043
|
-
console.error("warning: Workspace may not be fully ready");
|
|
34044
|
-
}
|
|
34045
|
-
await sleep(500);
|
|
34046
|
-
spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
|
|
34047
|
-
return true;
|
|
34048
|
-
} catch (error40) {
|
|
34049
|
-
console.error(`warning: Failed to launch VS Code: ${error40.message}`);
|
|
34050
|
-
return false;
|
|
34051
|
-
}
|
|
34052
|
-
}
|
|
34053
|
-
async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, chatInstruction, vscodeCmd) {
|
|
34054
|
-
try {
|
|
34055
|
-
const workspacePath = path6.join(subagentDir, `${path6.basename(subagentDir)}.code-workspace`);
|
|
34056
|
-
const messagesDir = path6.join(subagentDir, "messages");
|
|
34057
|
-
await mkdir2(messagesDir, { recursive: true });
|
|
34058
|
-
const chatArgs = ["-r", "chat", "-m", chatId];
|
|
34059
|
-
for (const attachment of attachmentPaths) {
|
|
34060
|
-
chatArgs.push("-a", attachment);
|
|
34061
|
-
}
|
|
34062
|
-
chatArgs.push(chatInstruction);
|
|
34063
|
-
const workspaceReady = await ensureWorkspaceFocused(workspacePath, path6.basename(subagentDir), subagentDir, vscodeCmd);
|
|
34064
|
-
if (!workspaceReady) {
|
|
34065
|
-
console.error("warning: Workspace may not be fully ready");
|
|
34066
|
-
}
|
|
34067
|
-
await sleep(500);
|
|
34068
|
-
spawn(vscodeCmd, chatArgs, { windowsHide: true, shell: true, detached: false });
|
|
34069
|
-
return true;
|
|
34070
|
-
} catch (error40) {
|
|
34071
|
-
console.error(`warning: Failed to launch VS Code: ${error40.message}`);
|
|
34072
|
-
return false;
|
|
34073
|
-
}
|
|
34074
|
-
}
|
|
34075
34167
|
async function dispatchAgentSession(options) {
|
|
34076
|
-
const { userQuery, promptFile, extraAttachments, workspaceTemplate, dryRun = false, wait = true, vscodeCmd = "code", subagentRoot, silent = false } = options;
|
|
34168
|
+
const { userQuery, promptFile, requestTemplate, extraAttachments, workspaceTemplate, dryRun = false, wait = true, vscodeCmd = "code", subagentRoot, silent = false } = options;
|
|
34077
34169
|
try {
|
|
34078
34170
|
let resolvedPrompt;
|
|
34079
34171
|
try {
|
|
@@ -34084,6 +34176,15 @@ async function dispatchAgentSession(options) {
|
|
|
34084
34176
|
error: error40.message
|
|
34085
34177
|
};
|
|
34086
34178
|
}
|
|
34179
|
+
let templateContent;
|
|
34180
|
+
try {
|
|
34181
|
+
templateContent = requestTemplate ? await loadTemplateFile(path10.resolve(requestTemplate)) : loadDefaultRequestTemplate();
|
|
34182
|
+
} catch (error40) {
|
|
34183
|
+
return {
|
|
34184
|
+
exitCode: 1,
|
|
34185
|
+
error: error40.message
|
|
34186
|
+
};
|
|
34187
|
+
}
|
|
34087
34188
|
const subagentRootPath = subagentRoot ?? getSubagentRoot(vscodeCmd);
|
|
34088
34189
|
const subagentDir = await findUnlockedSubagent(subagentRootPath);
|
|
34089
34190
|
if (!subagentDir) {
|
|
@@ -34092,7 +34193,7 @@ async function dispatchAgentSession(options) {
|
|
|
34092
34193
|
error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
|
|
34093
34194
|
};
|
|
34094
34195
|
}
|
|
34095
|
-
const subagentName =
|
|
34196
|
+
const subagentName = path10.basename(subagentDir);
|
|
34096
34197
|
const chatId = Math.random().toString(16).slice(2, 10);
|
|
34097
34198
|
const preparationResult = await prepareSubagentDirectory(subagentDir, resolvedPrompt, chatId, workspaceTemplate, dryRun);
|
|
34098
34199
|
if (preparationResult !== 0) {
|
|
@@ -34113,10 +34214,10 @@ async function dispatchAgentSession(options) {
|
|
|
34113
34214
|
};
|
|
34114
34215
|
}
|
|
34115
34216
|
const timestamp = generateTimestamp();
|
|
34116
|
-
const messagesDir =
|
|
34117
|
-
const responseFileTmp =
|
|
34118
|
-
const responseFileFinal =
|
|
34119
|
-
const requestInstructions = createRequestPrompt(userQuery, responseFileTmp, responseFileFinal);
|
|
34217
|
+
const messagesDir = path10.join(subagentDir, "messages");
|
|
34218
|
+
const responseFileTmp = path10.join(messagesDir, `${timestamp}_res.tmp.md`);
|
|
34219
|
+
const responseFileFinal = path10.join(messagesDir, `${timestamp}_res.md`);
|
|
34220
|
+
const requestInstructions = createRequestPrompt(userQuery, responseFileTmp, responseFileFinal, templateContent);
|
|
34120
34221
|
if (dryRun) {
|
|
34121
34222
|
return {
|
|
34122
34223
|
exitCode: 0,
|
|
@@ -34168,7 +34269,7 @@ async function dispatchAgentSession(options) {
|
|
|
34168
34269
|
}
|
|
34169
34270
|
}
|
|
34170
34271
|
async function dispatchBatchAgent(options) {
|
|
34171
|
-
const { userQueries, promptFile, extraAttachments, workspaceTemplate, dryRun = false, wait = false, vscodeCmd = "code", subagentRoot, silent = false } = options;
|
|
34272
|
+
const { userQueries, promptFile, requestTemplate, extraAttachments, workspaceTemplate, dryRun = false, wait = false, vscodeCmd = "code", subagentRoot, silent = false } = options;
|
|
34172
34273
|
if (!userQueries || userQueries.length === 0) {
|
|
34173
34274
|
return {
|
|
34174
34275
|
exitCode: 1,
|
|
@@ -34193,6 +34294,18 @@ async function dispatchBatchAgent(options) {
|
|
|
34193
34294
|
error: error40.message
|
|
34194
34295
|
};
|
|
34195
34296
|
}
|
|
34297
|
+
let batchRequestTemplateContent;
|
|
34298
|
+
try {
|
|
34299
|
+
batchRequestTemplateContent = requestTemplate ? await loadTemplateFile(path10.resolve(requestTemplate)) : loadDefaultBatchRequestTemplate();
|
|
34300
|
+
} catch (error40) {
|
|
34301
|
+
return {
|
|
34302
|
+
exitCode: 1,
|
|
34303
|
+
requestFiles,
|
|
34304
|
+
queryCount,
|
|
34305
|
+
error: error40.message
|
|
34306
|
+
};
|
|
34307
|
+
}
|
|
34308
|
+
const orchestratorTemplateContent = loadDefaultBatchOrchestratorTemplate();
|
|
34196
34309
|
const subagentRootPath = subagentRoot ?? getSubagentRoot(vscodeCmd);
|
|
34197
34310
|
const subagentDir = await findUnlockedSubagent(subagentRootPath);
|
|
34198
34311
|
if (!subagentDir) {
|
|
@@ -34203,7 +34316,7 @@ async function dispatchBatchAgent(options) {
|
|
|
34203
34316
|
error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
|
|
34204
34317
|
};
|
|
34205
34318
|
}
|
|
34206
|
-
subagentName =
|
|
34319
|
+
subagentName = path10.basename(subagentDir);
|
|
34207
34320
|
const chatId = Math.random().toString(16).slice(2, 10);
|
|
34208
34321
|
const preparationResult = await prepareSubagentDirectory(subagentDir, resolvedPrompt, chatId, workspaceTemplate, dryRun);
|
|
34209
34322
|
if (preparationResult !== 0) {
|
|
@@ -34228,15 +34341,15 @@ async function dispatchBatchAgent(options) {
|
|
|
34228
34341
|
};
|
|
34229
34342
|
}
|
|
34230
34343
|
const timestamp = generateTimestamp();
|
|
34231
|
-
const messagesDir =
|
|
34232
|
-
requestFiles = userQueries.map((_, index) =>
|
|
34233
|
-
const responseTmpFiles = userQueries.map((_, index) =>
|
|
34234
|
-
responseFilesFinal = userQueries.map((_, index) =>
|
|
34235
|
-
const orchestratorFile =
|
|
34344
|
+
const messagesDir = path10.join(subagentDir, "messages");
|
|
34345
|
+
requestFiles = userQueries.map((_, index) => path10.join(messagesDir, `${timestamp}_${index}_req.md`));
|
|
34346
|
+
const responseTmpFiles = userQueries.map((_, index) => path10.join(messagesDir, `${timestamp}_${index}_res.tmp.md`));
|
|
34347
|
+
responseFilesFinal = userQueries.map((_, index) => path10.join(messagesDir, `${timestamp}_${index}_res.md`));
|
|
34348
|
+
const orchestratorFile = path10.join(messagesDir, `${timestamp}_orchestrator.md`);
|
|
34236
34349
|
if (!dryRun) {
|
|
34237
|
-
await Promise.all(userQueries.map((query, index) =>
|
|
34238
|
-
const orchestratorContent = createBatchOrchestratorPrompt(requestFiles, responseFilesFinal);
|
|
34239
|
-
await
|
|
34350
|
+
await Promise.all(userQueries.map((query, index) => writeFile3(requestFiles[index], createBatchRequestPrompt(query, responseTmpFiles[index], responseFilesFinal[index], batchRequestTemplateContent), { encoding: "utf8" })));
|
|
34351
|
+
const orchestratorContent = createBatchOrchestratorPrompt(requestFiles, responseFilesFinal, orchestratorTemplateContent);
|
|
34352
|
+
await writeFile3(orchestratorFile, orchestratorContent, { encoding: "utf8" });
|
|
34240
34353
|
}
|
|
34241
34354
|
const chatAttachments = [orchestratorFile, ...attachments];
|
|
34242
34355
|
const orchestratorUri = pathToFileUri(orchestratorFile);
|
|
@@ -34299,9 +34412,9 @@ async function dispatchBatchAgent(options) {
|
|
|
34299
34412
|
}
|
|
34300
34413
|
}
|
|
34301
34414
|
|
|
34302
|
-
// ../../node_modules/.bun/subagent@0.
|
|
34303
|
-
import { writeFile as
|
|
34304
|
-
import
|
|
34415
|
+
// ../../node_modules/.bun/subagent@0.5.3/node_modules/subagent/dist/vscode/provision.js
|
|
34416
|
+
import { writeFile as writeFile4 } from "fs/promises";
|
|
34417
|
+
import path11 from "path";
|
|
34305
34418
|
var DEFAULT_WORKSPACE_TEMPLATE2 = {
|
|
34306
34419
|
folders: [
|
|
34307
34420
|
{
|
|
@@ -34324,7 +34437,7 @@ async function provisionSubagents(options) {
|
|
|
34324
34437
|
if (!Number.isInteger(subagents) || subagents < 1) {
|
|
34325
34438
|
throw new Error("subagents must be a positive integer");
|
|
34326
34439
|
}
|
|
34327
|
-
const targetPath =
|
|
34440
|
+
const targetPath = path11.resolve(targetRoot);
|
|
34328
34441
|
if (!dryRun) {
|
|
34329
34442
|
await ensureDir(targetPath);
|
|
34330
34443
|
}
|
|
@@ -34343,7 +34456,7 @@ async function provisionSubagents(options) {
|
|
|
34343
34456
|
continue;
|
|
34344
34457
|
}
|
|
34345
34458
|
highestNumber = Math.max(highestNumber, parsed);
|
|
34346
|
-
const lockFile =
|
|
34459
|
+
const lockFile = path11.join(entry.absolutePath, lockName);
|
|
34347
34460
|
const locked = await pathExists(lockFile);
|
|
34348
34461
|
if (locked) {
|
|
34349
34462
|
lockedSubagents.add(entry.absolutePath);
|
|
@@ -34360,11 +34473,11 @@ async function provisionSubagents(options) {
|
|
|
34360
34473
|
break;
|
|
34361
34474
|
}
|
|
34362
34475
|
const subagentDir = subagent.absolutePath;
|
|
34363
|
-
const githubAgentsDir =
|
|
34364
|
-
const lockFile =
|
|
34365
|
-
const workspaceDst =
|
|
34366
|
-
const wakeupDst =
|
|
34367
|
-
const subagentDst =
|
|
34476
|
+
const githubAgentsDir = path11.join(subagentDir, ".github", "agents");
|
|
34477
|
+
const lockFile = path11.join(subagentDir, lockName);
|
|
34478
|
+
const workspaceDst = path11.join(subagentDir, `${path11.basename(subagentDir)}.code-workspace`);
|
|
34479
|
+
const wakeupDst = path11.join(githubAgentsDir, "wakeup.md");
|
|
34480
|
+
const subagentDst = path11.join(githubAgentsDir, "subagent.md");
|
|
34368
34481
|
const isLocked = await pathExists(lockFile);
|
|
34369
34482
|
if (isLocked && !force) {
|
|
34370
34483
|
continue;
|
|
@@ -34373,8 +34486,8 @@ async function provisionSubagents(options) {
|
|
|
34373
34486
|
if (!dryRun) {
|
|
34374
34487
|
await removeIfExists(lockFile);
|
|
34375
34488
|
await ensureDir(githubAgentsDir);
|
|
34376
|
-
await
|
|
34377
|
-
await
|
|
34489
|
+
await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
|
|
34490
|
+
await writeFile4(wakeupDst, wakeupContent, "utf8");
|
|
34378
34491
|
}
|
|
34379
34492
|
created.push(subagentDir);
|
|
34380
34493
|
lockedSubagents.delete(subagentDir);
|
|
@@ -34384,8 +34497,8 @@ async function provisionSubagents(options) {
|
|
|
34384
34497
|
if (!isLocked && force) {
|
|
34385
34498
|
if (!dryRun) {
|
|
34386
34499
|
await ensureDir(githubAgentsDir);
|
|
34387
|
-
await
|
|
34388
|
-
await
|
|
34500
|
+
await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
|
|
34501
|
+
await writeFile4(wakeupDst, wakeupContent, "utf8");
|
|
34389
34502
|
}
|
|
34390
34503
|
created.push(subagentDir);
|
|
34391
34504
|
subagentsProvisioned += 1;
|
|
@@ -34393,8 +34506,8 @@ async function provisionSubagents(options) {
|
|
|
34393
34506
|
}
|
|
34394
34507
|
if (!dryRun && !await pathExists(workspaceDst)) {
|
|
34395
34508
|
await ensureDir(githubAgentsDir);
|
|
34396
|
-
await
|
|
34397
|
-
await
|
|
34509
|
+
await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
|
|
34510
|
+
await writeFile4(wakeupDst, wakeupContent, "utf8");
|
|
34398
34511
|
}
|
|
34399
34512
|
skippedExisting.push(subagentDir);
|
|
34400
34513
|
subagentsProvisioned += 1;
|
|
@@ -34402,16 +34515,16 @@ async function provisionSubagents(options) {
|
|
|
34402
34515
|
let nextIndex = highestNumber;
|
|
34403
34516
|
while (subagentsProvisioned < subagents) {
|
|
34404
34517
|
nextIndex += 1;
|
|
34405
|
-
const subagentDir =
|
|
34406
|
-
const githubAgentsDir =
|
|
34407
|
-
const workspaceDst =
|
|
34408
|
-
const wakeupDst =
|
|
34409
|
-
const subagentDst =
|
|
34518
|
+
const subagentDir = path11.join(targetPath, `subagent-${nextIndex}`);
|
|
34519
|
+
const githubAgentsDir = path11.join(subagentDir, ".github", "agents");
|
|
34520
|
+
const workspaceDst = path11.join(subagentDir, `${path11.basename(subagentDir)}.code-workspace`);
|
|
34521
|
+
const wakeupDst = path11.join(githubAgentsDir, "wakeup.md");
|
|
34522
|
+
const subagentDst = path11.join(githubAgentsDir, "subagent.md");
|
|
34410
34523
|
if (!dryRun) {
|
|
34411
34524
|
await ensureDir(subagentDir);
|
|
34412
34525
|
await ensureDir(githubAgentsDir);
|
|
34413
|
-
await
|
|
34414
|
-
await
|
|
34526
|
+
await writeFile4(workspaceDst, JSON.stringify(workspaceTemplate, null, 2), "utf8");
|
|
34527
|
+
await writeFile4(wakeupDst, wakeupContent, "utf8");
|
|
34415
34528
|
}
|
|
34416
34529
|
created.push(subagentDir);
|
|
34417
34530
|
subagentsProvisioned += 1;
|
|
@@ -34425,12 +34538,12 @@ async function provisionSubagents(options) {
|
|
|
34425
34538
|
|
|
34426
34539
|
// ../../packages/core/dist/index.js
|
|
34427
34540
|
import { constants as constants32 } from "node:fs";
|
|
34428
|
-
import { access as access32, readFile as
|
|
34429
|
-
import
|
|
34541
|
+
import { access as access32, readFile as readFile62 } from "node:fs/promises";
|
|
34542
|
+
import path112 from "node:path";
|
|
34430
34543
|
import { parse as parse32 } from "yaml";
|
|
34431
34544
|
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
34432
34545
|
import { mkdir as mkdir22, writeFile as writeFile22 } from "node:fs/promises";
|
|
34433
|
-
import
|
|
34546
|
+
import path122 from "node:path";
|
|
34434
34547
|
var TEST_MESSAGE_ROLE_VALUES = ["system", "user", "assistant", "tool"];
|
|
34435
34548
|
var TEST_MESSAGE_ROLE_SET = new Set(TEST_MESSAGE_ROLE_VALUES);
|
|
34436
34549
|
function isTestMessageRole(value) {
|
|
@@ -34568,15 +34681,15 @@ function resolveToAbsolutePath(candidate) {
|
|
|
34568
34681
|
if (candidate.startsWith("file://")) {
|
|
34569
34682
|
return new URL(candidate).pathname;
|
|
34570
34683
|
}
|
|
34571
|
-
return
|
|
34684
|
+
return path12.resolve(candidate);
|
|
34572
34685
|
}
|
|
34573
34686
|
throw new TypeError("Unsupported repoRoot value. Expected string or URL.");
|
|
34574
34687
|
}
|
|
34575
34688
|
function buildDirectoryChain2(filePath, repoRoot) {
|
|
34576
34689
|
const directories = [];
|
|
34577
34690
|
const seen = /* @__PURE__ */ new Set();
|
|
34578
|
-
const boundary =
|
|
34579
|
-
let current =
|
|
34691
|
+
const boundary = path12.resolve(repoRoot);
|
|
34692
|
+
let current = path12.resolve(path12.dirname(filePath));
|
|
34580
34693
|
while (current !== void 0) {
|
|
34581
34694
|
if (!seen.has(current)) {
|
|
34582
34695
|
directories.push(current);
|
|
@@ -34585,7 +34698,7 @@ function buildDirectoryChain2(filePath, repoRoot) {
|
|
|
34585
34698
|
if (current === boundary) {
|
|
34586
34699
|
break;
|
|
34587
34700
|
}
|
|
34588
|
-
const parent =
|
|
34701
|
+
const parent = path12.dirname(current);
|
|
34589
34702
|
if (parent === current) {
|
|
34590
34703
|
break;
|
|
34591
34704
|
}
|
|
@@ -34599,16 +34712,16 @@ function buildDirectoryChain2(filePath, repoRoot) {
|
|
|
34599
34712
|
function buildSearchRoots2(evalPath, repoRoot) {
|
|
34600
34713
|
const uniqueRoots = [];
|
|
34601
34714
|
const addRoot = (root2) => {
|
|
34602
|
-
const normalized =
|
|
34715
|
+
const normalized = path12.resolve(root2);
|
|
34603
34716
|
if (!uniqueRoots.includes(normalized)) {
|
|
34604
34717
|
uniqueRoots.push(normalized);
|
|
34605
34718
|
}
|
|
34606
34719
|
};
|
|
34607
|
-
let currentDir =
|
|
34720
|
+
let currentDir = path12.dirname(evalPath);
|
|
34608
34721
|
let reachedBoundary = false;
|
|
34609
34722
|
while (!reachedBoundary) {
|
|
34610
34723
|
addRoot(currentDir);
|
|
34611
|
-
const parentDir =
|
|
34724
|
+
const parentDir = path12.dirname(currentDir);
|
|
34612
34725
|
if (currentDir === repoRoot || parentDir === currentDir) {
|
|
34613
34726
|
reachedBoundary = true;
|
|
34614
34727
|
} else {
|
|
@@ -34626,16 +34739,16 @@ function trimLeadingSeparators2(value) {
|
|
|
34626
34739
|
async function resolveFileReference2(rawValue, searchRoots) {
|
|
34627
34740
|
const displayPath = trimLeadingSeparators2(rawValue);
|
|
34628
34741
|
const potentialPaths = [];
|
|
34629
|
-
if (
|
|
34630
|
-
potentialPaths.push(
|
|
34742
|
+
if (path12.isAbsolute(rawValue)) {
|
|
34743
|
+
potentialPaths.push(path12.normalize(rawValue));
|
|
34631
34744
|
}
|
|
34632
34745
|
for (const base of searchRoots) {
|
|
34633
|
-
potentialPaths.push(
|
|
34746
|
+
potentialPaths.push(path12.resolve(base, displayPath));
|
|
34634
34747
|
}
|
|
34635
34748
|
const attempted = [];
|
|
34636
34749
|
const seen = /* @__PURE__ */ new Set();
|
|
34637
34750
|
for (const candidate of potentialPaths) {
|
|
34638
|
-
const absoluteCandidate =
|
|
34751
|
+
const absoluteCandidate = path12.resolve(candidate);
|
|
34639
34752
|
if (seen.has(absoluteCandidate)) {
|
|
34640
34753
|
continue;
|
|
34641
34754
|
}
|
|
@@ -34658,7 +34771,7 @@ async function loadConfig(evalFilePath, repoRoot) {
|
|
|
34658
34771
|
continue;
|
|
34659
34772
|
}
|
|
34660
34773
|
try {
|
|
34661
|
-
const rawConfig = await
|
|
34774
|
+
const rawConfig = await readFile6(configPath, "utf8");
|
|
34662
34775
|
const parsed = parse5(rawConfig);
|
|
34663
34776
|
if (!isJsonObject(parsed)) {
|
|
34664
34777
|
logWarning(`Invalid .agentv/config.yaml format at ${configPath}`);
|
|
@@ -35053,7 +35166,7 @@ async function buildPromptInputs(testCase, mode = "lm") {
|
|
|
35053
35166
|
continue;
|
|
35054
35167
|
}
|
|
35055
35168
|
try {
|
|
35056
|
-
const content = (await
|
|
35169
|
+
const content = (await readFile42(absolutePath, "utf8")).replace(/\r\n/g, "\n").trim();
|
|
35057
35170
|
guidelineParts.push({
|
|
35058
35171
|
content,
|
|
35059
35172
|
isFile: true,
|
|
@@ -35799,7 +35912,7 @@ var CliProvider = class {
|
|
|
35799
35912
|
await this.ensureHealthy(request.signal);
|
|
35800
35913
|
const outputFilePath = generateOutputFilePath(request.evalCaseId);
|
|
35801
35914
|
const templateValues = buildTemplateValues(request, this.config, outputFilePath);
|
|
35802
|
-
const renderedCommand =
|
|
35915
|
+
const renderedCommand = renderTemplate2(this.config.commandTemplate, templateValues);
|
|
35803
35916
|
const result = await this.runCommand(renderedCommand, {
|
|
35804
35917
|
cwd: this.config.cwd,
|
|
35805
35918
|
env: process.env,
|
|
@@ -35877,7 +35990,7 @@ var CliProvider = class {
|
|
|
35877
35990
|
}
|
|
35878
35991
|
return;
|
|
35879
35992
|
}
|
|
35880
|
-
const renderedCommand =
|
|
35993
|
+
const renderedCommand = renderTemplate2(
|
|
35881
35994
|
healthcheck.commandTemplate,
|
|
35882
35995
|
buildTemplateValues(
|
|
35883
35996
|
{
|
|
@@ -35945,7 +36058,7 @@ function formatFileList(files, template) {
|
|
|
35945
36058
|
return formatter.replaceAll("{path}", escapedPath).replaceAll("{basename}", escapedName);
|
|
35946
36059
|
}).join(" ");
|
|
35947
36060
|
}
|
|
35948
|
-
function
|
|
36061
|
+
function renderTemplate2(template, values) {
|
|
35949
36062
|
return template.replace(/\{([A-Z_]+)\}/g, (match, key2) => {
|
|
35950
36063
|
const replacement = values[key2];
|
|
35951
36064
|
return replacement !== void 0 ? replacement : match;
|
|
@@ -36143,8 +36256,8 @@ var CodexProvider = class {
|
|
|
36143
36256
|
const logger = await this.createStreamLogger(request).catch(() => void 0);
|
|
36144
36257
|
try {
|
|
36145
36258
|
const promptContent = buildPromptDocument(request, inputFiles);
|
|
36146
|
-
const promptFile =
|
|
36147
|
-
await
|
|
36259
|
+
const promptFile = path92.join(workspaceRoot, PROMPT_FILENAME);
|
|
36260
|
+
await writeFile5(promptFile, promptContent, "utf8");
|
|
36148
36261
|
const args = this.buildCodexArgs();
|
|
36149
36262
|
const cwd = this.resolveCwd(workspaceRoot);
|
|
36150
36263
|
const result = await this.executeCodex(args, cwd, promptContent, request.signal, logger);
|
|
@@ -36193,7 +36306,7 @@ var CodexProvider = class {
|
|
|
36193
36306
|
if (!this.config.cwd) {
|
|
36194
36307
|
return workspaceRoot;
|
|
36195
36308
|
}
|
|
36196
|
-
return
|
|
36309
|
+
return path92.resolve(this.config.cwd);
|
|
36197
36310
|
}
|
|
36198
36311
|
buildCodexArgs() {
|
|
36199
36312
|
const args = [
|
|
@@ -36235,7 +36348,7 @@ var CodexProvider = class {
|
|
|
36235
36348
|
}
|
|
36236
36349
|
}
|
|
36237
36350
|
async createWorkspace() {
|
|
36238
|
-
return await mkdtemp(
|
|
36351
|
+
return await mkdtemp(path92.join(tmpdir(), WORKSPACE_PREFIX));
|
|
36239
36352
|
}
|
|
36240
36353
|
async cleanupWorkspace(workspaceRoot) {
|
|
36241
36354
|
try {
|
|
@@ -36249,9 +36362,9 @@ var CodexProvider = class {
|
|
|
36249
36362
|
return void 0;
|
|
36250
36363
|
}
|
|
36251
36364
|
if (this.config.logDir) {
|
|
36252
|
-
return
|
|
36365
|
+
return path92.resolve(this.config.logDir);
|
|
36253
36366
|
}
|
|
36254
|
-
return
|
|
36367
|
+
return path92.join(process.cwd(), ".agentv", "logs", "codex");
|
|
36255
36368
|
}
|
|
36256
36369
|
async createStreamLogger(request) {
|
|
36257
36370
|
const logDir = this.resolveLogDirectory();
|
|
@@ -36259,13 +36372,13 @@ var CodexProvider = class {
|
|
|
36259
36372
|
return void 0;
|
|
36260
36373
|
}
|
|
36261
36374
|
try {
|
|
36262
|
-
await
|
|
36375
|
+
await mkdir4(logDir, { recursive: true });
|
|
36263
36376
|
} catch (error40) {
|
|
36264
36377
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
36265
36378
|
console.warn(`Skipping Codex stream logging (could not create ${logDir}): ${message}`);
|
|
36266
36379
|
return void 0;
|
|
36267
36380
|
}
|
|
36268
|
-
const filePath =
|
|
36381
|
+
const filePath = path92.join(logDir, buildLogFilename(request, this.targetName));
|
|
36269
36382
|
try {
|
|
36270
36383
|
const logger = await CodexStreamLogger.create({
|
|
36271
36384
|
filePath,
|
|
@@ -36480,7 +36593,7 @@ function tryParseJsonValue(rawLine) {
|
|
|
36480
36593
|
async function locateExecutable(candidate) {
|
|
36481
36594
|
const includesPathSeparator = candidate.includes("/") || candidate.includes("\\");
|
|
36482
36595
|
if (includesPathSeparator) {
|
|
36483
|
-
const resolved =
|
|
36596
|
+
const resolved = path92.isAbsolute(candidate) ? candidate : path92.resolve(candidate);
|
|
36484
36597
|
const executablePath = await ensureWindowsExecutableVariant(resolved);
|
|
36485
36598
|
await access22(executablePath, constants22.F_OK);
|
|
36486
36599
|
return executablePath;
|
|
@@ -36952,7 +37065,7 @@ function buildMandatoryPrereadBlock2(guidelineFiles, attachmentFiles) {
|
|
|
36952
37065
|
return "";
|
|
36953
37066
|
}
|
|
36954
37067
|
const buildList = (files) => files.map((absolutePath) => {
|
|
36955
|
-
const fileName =
|
|
37068
|
+
const fileName = path102.basename(absolutePath);
|
|
36956
37069
|
const fileUri = pathToFileUri22(absolutePath);
|
|
36957
37070
|
return `* [${fileName}](${fileUri})`;
|
|
36958
37071
|
});
|
|
@@ -36977,8 +37090,8 @@ function collectGuidelineFiles2(attachments, guidelinePatterns) {
|
|
|
36977
37090
|
}
|
|
36978
37091
|
const unique = /* @__PURE__ */ new Map();
|
|
36979
37092
|
for (const attachment of attachments) {
|
|
36980
|
-
const absolutePath =
|
|
36981
|
-
const normalized = absolutePath.split(
|
|
37093
|
+
const absolutePath = path102.resolve(attachment);
|
|
37094
|
+
const normalized = absolutePath.split(path102.sep).join("/");
|
|
36982
37095
|
if (isGuidelineFile(normalized, guidelinePatterns)) {
|
|
36983
37096
|
if (!unique.has(absolutePath)) {
|
|
36984
37097
|
unique.set(absolutePath, absolutePath);
|
|
@@ -36993,7 +37106,7 @@ function collectAttachmentFiles(attachments) {
|
|
|
36993
37106
|
}
|
|
36994
37107
|
const unique = /* @__PURE__ */ new Map();
|
|
36995
37108
|
for (const attachment of attachments) {
|
|
36996
|
-
const absolutePath =
|
|
37109
|
+
const absolutePath = path102.resolve(attachment);
|
|
36997
37110
|
if (!unique.has(absolutePath)) {
|
|
36998
37111
|
unique.set(absolutePath, absolutePath);
|
|
36999
37112
|
}
|
|
@@ -37001,7 +37114,7 @@ function collectAttachmentFiles(attachments) {
|
|
|
37001
37114
|
return Array.from(unique.values());
|
|
37002
37115
|
}
|
|
37003
37116
|
function pathToFileUri22(filePath) {
|
|
37004
|
-
const absolutePath =
|
|
37117
|
+
const absolutePath = path102.isAbsolute(filePath) ? filePath : path102.resolve(filePath);
|
|
37005
37118
|
const normalizedPath = absolutePath.replace(/\\/g, "/");
|
|
37006
37119
|
if (/^[a-zA-Z]:\//.test(normalizedPath)) {
|
|
37007
37120
|
return `file:///${normalizedPath}`;
|
|
@@ -37014,7 +37127,7 @@ function normalizeAttachments(attachments) {
|
|
|
37014
37127
|
}
|
|
37015
37128
|
const deduped = /* @__PURE__ */ new Set();
|
|
37016
37129
|
for (const attachment of attachments) {
|
|
37017
|
-
deduped.add(
|
|
37130
|
+
deduped.add(path102.resolve(attachment));
|
|
37018
37131
|
}
|
|
37019
37132
|
return Array.from(deduped);
|
|
37020
37133
|
}
|
|
@@ -37023,7 +37136,7 @@ function mergeAttachments(all) {
|
|
|
37023
37136
|
for (const list of all) {
|
|
37024
37137
|
if (!list) continue;
|
|
37025
37138
|
for (const inputFile of list) {
|
|
37026
|
-
deduped.add(
|
|
37139
|
+
deduped.add(path102.resolve(inputFile));
|
|
37027
37140
|
}
|
|
37028
37141
|
}
|
|
37029
37142
|
return deduped.size > 0 ? Array.from(deduped) : void 0;
|
|
@@ -37103,11 +37216,11 @@ async function fileExists3(filePath) {
|
|
|
37103
37216
|
}
|
|
37104
37217
|
}
|
|
37105
37218
|
async function readTargetDefinitions(filePath) {
|
|
37106
|
-
const absolutePath =
|
|
37219
|
+
const absolutePath = path112.resolve(filePath);
|
|
37107
37220
|
if (!await fileExists3(absolutePath)) {
|
|
37108
37221
|
throw new Error(`targets.yaml not found at ${absolutePath}`);
|
|
37109
37222
|
}
|
|
37110
|
-
const raw = await
|
|
37223
|
+
const raw = await readFile62(absolutePath, "utf8");
|
|
37111
37224
|
const parsed = parse32(raw);
|
|
37112
37225
|
if (!isRecord(parsed)) {
|
|
37113
37226
|
throw new Error(`targets.yaml at ${absolutePath} must be a YAML object with a 'targets' field`);
|
|
@@ -38238,8 +38351,8 @@ function buildEvaluatorRegistry(overrides, resolveJudgeProvider) {
|
|
|
38238
38351
|
async function dumpPrompt(directory, evalCase, promptInputs) {
|
|
38239
38352
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
38240
38353
|
const filename = `${timestamp}_${sanitizeFilename(evalCase.id)}.json`;
|
|
38241
|
-
const filePath =
|
|
38242
|
-
await mkdir22(
|
|
38354
|
+
const filePath = path122.resolve(directory, filename);
|
|
38355
|
+
await mkdir22(path122.dirname(filePath), { recursive: true });
|
|
38243
38356
|
const payload = {
|
|
38244
38357
|
eval_id: evalCase.id,
|
|
38245
38358
|
question: promptInputs.question,
|
|
@@ -38422,7 +38535,7 @@ async function loadEnvFromHierarchy(options) {
|
|
|
38422
38535
|
|
|
38423
38536
|
// src/commands/eval/jsonl-writer.ts
|
|
38424
38537
|
import { createWriteStream as createWriteStream2 } from "node:fs";
|
|
38425
|
-
import { mkdir as
|
|
38538
|
+
import { mkdir as mkdir5 } from "node:fs/promises";
|
|
38426
38539
|
import path14 from "node:path";
|
|
38427
38540
|
import { finished } from "node:stream/promises";
|
|
38428
38541
|
|
|
@@ -38641,7 +38754,7 @@ var JsonlWriter = class _JsonlWriter {
|
|
|
38641
38754
|
this.stream = stream;
|
|
38642
38755
|
}
|
|
38643
38756
|
static async open(filePath) {
|
|
38644
|
-
await
|
|
38757
|
+
await mkdir5(path14.dirname(filePath), { recursive: true });
|
|
38645
38758
|
const stream = createWriteStream2(filePath, { flags: "w", encoding: "utf8" });
|
|
38646
38759
|
return new _JsonlWriter(stream);
|
|
38647
38760
|
}
|
|
@@ -38672,7 +38785,7 @@ var JsonlWriter = class _JsonlWriter {
|
|
|
38672
38785
|
|
|
38673
38786
|
// src/commands/eval/yaml-writer.ts
|
|
38674
38787
|
import { createWriteStream as createWriteStream3 } from "node:fs";
|
|
38675
|
-
import { mkdir as
|
|
38788
|
+
import { mkdir as mkdir6 } from "node:fs/promises";
|
|
38676
38789
|
import path15 from "node:path";
|
|
38677
38790
|
import { finished as finished2 } from "node:stream/promises";
|
|
38678
38791
|
import { stringify as stringifyYaml } from "yaml";
|
|
@@ -38685,7 +38798,7 @@ var YamlWriter = class _YamlWriter {
|
|
|
38685
38798
|
this.stream = stream;
|
|
38686
38799
|
}
|
|
38687
38800
|
static async open(filePath) {
|
|
38688
|
-
await
|
|
38801
|
+
await mkdir6(path15.dirname(filePath), { recursive: true });
|
|
38689
38802
|
const stream = createWriteStream3(filePath, { flags: "w", encoding: "utf8" });
|
|
38690
38803
|
return new _YamlWriter(stream);
|
|
38691
38804
|
}
|
|
@@ -39099,7 +39212,7 @@ import { parse as parse23 } from "yaml";
|
|
|
39099
39212
|
import { readFile as readFile33 } from "node:fs/promises";
|
|
39100
39213
|
import path23 from "node:path";
|
|
39101
39214
|
import { parse as parse33 } from "yaml";
|
|
39102
|
-
import { readFile as
|
|
39215
|
+
import { readFile as readFile43 } from "node:fs/promises";
|
|
39103
39216
|
import { parse as parse42 } from "yaml";
|
|
39104
39217
|
import { readFile as readFile52 } from "node:fs/promises";
|
|
39105
39218
|
import path33 from "node:path";
|
|
@@ -39754,7 +39867,7 @@ var SCHEMA_CONFIG_V222 = "agentv-config-v2";
|
|
|
39754
39867
|
async function validateConfigFile(filePath) {
|
|
39755
39868
|
const errors = [];
|
|
39756
39869
|
try {
|
|
39757
|
-
const content = await
|
|
39870
|
+
const content = await readFile43(filePath, "utf8");
|
|
39758
39871
|
const parsed = parse42(content);
|
|
39759
39872
|
if (typeof parsed !== "object" || parsed === null) {
|
|
39760
39873
|
errors.push({
|
|
@@ -40297,7 +40410,7 @@ async function runSingleEvalFile(params) {
|
|
|
40297
40410
|
}
|
|
40298
40411
|
const promptDumpDir = resolvePromptDirectory(options.dumpPrompts, cwd);
|
|
40299
40412
|
if (promptDumpDir) {
|
|
40300
|
-
await
|
|
40413
|
+
await mkdir7(promptDumpDir, { recursive: true });
|
|
40301
40414
|
if (options.verbose) {
|
|
40302
40415
|
console.log(`Prompt dumps enabled at: ${promptDumpDir}`);
|
|
40303
40416
|
}
|
|
@@ -40550,7 +40663,7 @@ async function resolveEvalPaths(evalPaths, cwd) {
|
|
|
40550
40663
|
for (const pattern of normalizedInputs) {
|
|
40551
40664
|
const candidatePath = path19.isAbsolute(pattern) ? path19.normalize(pattern) : path19.resolve(cwd, pattern);
|
|
40552
40665
|
try {
|
|
40553
|
-
const stats = await
|
|
40666
|
+
const stats = await stat4(candidatePath);
|
|
40554
40667
|
if (stats.isFile() && /\.ya?ml$/i.test(candidatePath)) {
|
|
40555
40668
|
results.add(candidatePath);
|
|
40556
40669
|
continue;
|
|
@@ -40620,9 +40733,9 @@ function readTemplatesRecursively(dir, relativePath) {
|
|
|
40620
40733
|
const entries = readdirSync(dir);
|
|
40621
40734
|
for (const entry of entries) {
|
|
40622
40735
|
const fullPath = path20.join(dir, entry);
|
|
40623
|
-
const
|
|
40736
|
+
const stat6 = statSync(fullPath);
|
|
40624
40737
|
const entryRelativePath = relativePath ? path20.join(relativePath, entry) : entry;
|
|
40625
|
-
if (
|
|
40738
|
+
if (stat6.isDirectory()) {
|
|
40626
40739
|
templates.push(...readTemplatesRecursively(fullPath, entryRelativePath));
|
|
40627
40740
|
} else {
|
|
40628
40741
|
const content = readFileSync(fullPath, "utf-8");
|
|
@@ -40861,7 +40974,7 @@ function isTTY2() {
|
|
|
40861
40974
|
|
|
40862
40975
|
// src/commands/validate/validate-files.ts
|
|
40863
40976
|
import { constants as constants7 } from "node:fs";
|
|
40864
|
-
import { access as access7, readdir as readdir3, stat as
|
|
40977
|
+
import { access as access7, readdir as readdir3, stat as stat5 } from "node:fs/promises";
|
|
40865
40978
|
import path24 from "node:path";
|
|
40866
40979
|
async function validateFiles(paths) {
|
|
40867
40980
|
const filePaths = await expandPaths(paths);
|
|
@@ -40926,7 +41039,7 @@ async function expandPaths(paths) {
|
|
|
40926
41039
|
console.warn(`Warning: Path not found: ${inputPath}`);
|
|
40927
41040
|
continue;
|
|
40928
41041
|
}
|
|
40929
|
-
const stats = await
|
|
41042
|
+
const stats = await stat5(absolutePath);
|
|
40930
41043
|
if (stats.isFile()) {
|
|
40931
41044
|
if (isYamlFile(absolutePath)) {
|
|
40932
41045
|
expanded.push(absolutePath);
|
|
@@ -41019,4 +41132,4 @@ export {
|
|
|
41019
41132
|
createProgram,
|
|
41020
41133
|
runCli
|
|
41021
41134
|
};
|
|
41022
|
-
//# sourceMappingURL=chunk-
|
|
41135
|
+
//# sourceMappingURL=chunk-EJTXU5JO.js.map
|