poe-code 3.0.192 → 3.0.194
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/index.js +718 -559
- package/dist/index.js.map +4 -4
- package/dist/providers/poe-agent.js +162 -71
- package/dist/providers/poe-agent.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -785,11 +785,11 @@ var init_parse = __esm({
|
|
|
785
785
|
function mergeLayers(layers) {
|
|
786
786
|
return mergeObjectLayers(layers, []);
|
|
787
787
|
}
|
|
788
|
-
function mergeObjectLayers(layers,
|
|
788
|
+
function mergeObjectLayers(layers, path94) {
|
|
789
789
|
const data = {};
|
|
790
790
|
const sources = {};
|
|
791
791
|
for (const key2 of collectKeys(layers)) {
|
|
792
|
-
const resolved = resolveKey(layers, key2,
|
|
792
|
+
const resolved = resolveKey(layers, key2, path94);
|
|
793
793
|
if (resolved === void 0) {
|
|
794
794
|
continue;
|
|
795
795
|
}
|
|
@@ -807,7 +807,7 @@ function collectKeys(layers) {
|
|
|
807
807
|
}
|
|
808
808
|
return [...keys];
|
|
809
809
|
}
|
|
810
|
-
function resolveKey(layers, key2,
|
|
810
|
+
function resolveKey(layers, key2, path94) {
|
|
811
811
|
let winningSource;
|
|
812
812
|
let winningValue;
|
|
813
813
|
const objectLayers = [];
|
|
@@ -837,9 +837,9 @@ function resolveKey(layers, key2, path93) {
|
|
|
837
837
|
if (winningSource === void 0) {
|
|
838
838
|
return void 0;
|
|
839
839
|
}
|
|
840
|
-
const fullPath = buildPath(
|
|
840
|
+
const fullPath = buildPath(path94, key2);
|
|
841
841
|
if (isPlainObject(winningValue)) {
|
|
842
|
-
const merged = mergeObjectLayers(objectLayers, [...
|
|
842
|
+
const merged = mergeObjectLayers(objectLayers, [...path94, key2]);
|
|
843
843
|
return {
|
|
844
844
|
value: merged.data,
|
|
845
845
|
sources: {
|
|
@@ -864,8 +864,8 @@ function isWinningCandidate(key2, value) {
|
|
|
864
864
|
}
|
|
865
865
|
return true;
|
|
866
866
|
}
|
|
867
|
-
function buildPath(
|
|
868
|
-
return [...
|
|
867
|
+
function buildPath(path94, key2) {
|
|
868
|
+
return [...path94, key2].join(".");
|
|
869
869
|
}
|
|
870
870
|
function isPlainObject(value) {
|
|
871
871
|
if (value === null || Array.isArray(value) || typeof value !== "object") {
|
|
@@ -1543,16 +1543,16 @@ function getConfigFormat(pathOrFormat) {
|
|
|
1543
1543
|
}
|
|
1544
1544
|
return formatRegistry[formatName];
|
|
1545
1545
|
}
|
|
1546
|
-
function detectFormat2(
|
|
1547
|
-
const ext = getExtension(
|
|
1546
|
+
function detectFormat2(path94) {
|
|
1547
|
+
const ext = getExtension(path94);
|
|
1548
1548
|
return extensionMap[ext];
|
|
1549
1549
|
}
|
|
1550
|
-
function getExtension(
|
|
1551
|
-
const lastDot =
|
|
1550
|
+
function getExtension(path94) {
|
|
1551
|
+
const lastDot = path94.lastIndexOf(".");
|
|
1552
1552
|
if (lastDot === -1) {
|
|
1553
1553
|
return "";
|
|
1554
1554
|
}
|
|
1555
|
-
return
|
|
1555
|
+
return path94.slice(lastDot).toLowerCase();
|
|
1556
1556
|
}
|
|
1557
1557
|
var formatRegistry, extensionMap;
|
|
1558
1558
|
var init_formats = __esm({
|
|
@@ -2764,50 +2764,50 @@ import { createTwoFilesPatch } from "diff";
|
|
|
2764
2764
|
import chalk from "chalk";
|
|
2765
2765
|
function createDryRunFileSystem(base, recorder) {
|
|
2766
2766
|
const proxy = {
|
|
2767
|
-
async readFile(
|
|
2767
|
+
async readFile(path94, encoding) {
|
|
2768
2768
|
if (encoding) {
|
|
2769
|
-
return base.readFile(
|
|
2769
|
+
return base.readFile(path94, encoding);
|
|
2770
2770
|
}
|
|
2771
|
-
return base.readFile(
|
|
2771
|
+
return base.readFile(path94);
|
|
2772
2772
|
},
|
|
2773
|
-
async writeFile(
|
|
2774
|
-
const previousContent = await tryReadText(base,
|
|
2773
|
+
async writeFile(path94, data, options) {
|
|
2774
|
+
const previousContent = await tryReadText(base, path94);
|
|
2775
2775
|
const nextContent = formatData(data, options?.encoding);
|
|
2776
2776
|
recorder.record({
|
|
2777
2777
|
type: "writeFile",
|
|
2778
|
-
path:
|
|
2778
|
+
path: path94,
|
|
2779
2779
|
nextContent,
|
|
2780
2780
|
previousContent
|
|
2781
2781
|
});
|
|
2782
2782
|
},
|
|
2783
|
-
async symlink(target,
|
|
2784
|
-
recorder.record({ type: "symlink", target, path:
|
|
2783
|
+
async symlink(target, path94) {
|
|
2784
|
+
recorder.record({ type: "symlink", target, path: path94 });
|
|
2785
2785
|
},
|
|
2786
|
-
async readlink(
|
|
2787
|
-
return base.readlink(
|
|
2786
|
+
async readlink(path94) {
|
|
2787
|
+
return base.readlink(path94);
|
|
2788
2788
|
},
|
|
2789
|
-
async mkdir(
|
|
2790
|
-
recorder.record({ type: "mkdir", path:
|
|
2789
|
+
async mkdir(path94, options) {
|
|
2790
|
+
recorder.record({ type: "mkdir", path: path94, options });
|
|
2791
2791
|
},
|
|
2792
|
-
async stat(
|
|
2793
|
-
return base.stat(
|
|
2792
|
+
async stat(path94) {
|
|
2793
|
+
return base.stat(path94);
|
|
2794
2794
|
},
|
|
2795
|
-
async lstat(
|
|
2796
|
-
return base.lstat(
|
|
2795
|
+
async lstat(path94) {
|
|
2796
|
+
return base.lstat(path94);
|
|
2797
2797
|
},
|
|
2798
2798
|
async rename(from, to) {
|
|
2799
2799
|
recorder.record({ type: "rename", from, to });
|
|
2800
2800
|
},
|
|
2801
|
-
async unlink(
|
|
2802
|
-
recorder.record({ type: "unlink", path:
|
|
2801
|
+
async unlink(path94) {
|
|
2802
|
+
recorder.record({ type: "unlink", path: path94 });
|
|
2803
2803
|
},
|
|
2804
|
-
async readdir(
|
|
2805
|
-
return base.readdir(
|
|
2804
|
+
async readdir(path94) {
|
|
2805
|
+
return base.readdir(path94);
|
|
2806
2806
|
}
|
|
2807
2807
|
};
|
|
2808
2808
|
if (typeof base.rm === "function") {
|
|
2809
|
-
proxy.rm = async (
|
|
2810
|
-
recorder.record({ type: "rm", path:
|
|
2809
|
+
proxy.rm = async (path94, options) => {
|
|
2810
|
+
recorder.record({ type: "rm", path: path94, options });
|
|
2811
2811
|
};
|
|
2812
2812
|
}
|
|
2813
2813
|
if (typeof base.copyFile === "function") {
|
|
@@ -2909,8 +2909,8 @@ function describeWriteChange(previous, next) {
|
|
|
2909
2909
|
}
|
|
2910
2910
|
return "update";
|
|
2911
2911
|
}
|
|
2912
|
-
function renderWriteCommand(
|
|
2913
|
-
const command = `cat > ${
|
|
2912
|
+
function renderWriteCommand(path94, change) {
|
|
2913
|
+
const command = `cat > ${path94}`;
|
|
2914
2914
|
if (change === "create") {
|
|
2915
2915
|
return renderOperationCommand(command, chalk.green, "# create");
|
|
2916
2916
|
}
|
|
@@ -3072,9 +3072,9 @@ function redactTomlLine(line) {
|
|
|
3072
3072
|
}
|
|
3073
3073
|
return line;
|
|
3074
3074
|
}
|
|
3075
|
-
async function tryReadText(base,
|
|
3075
|
+
async function tryReadText(base, path94) {
|
|
3076
3076
|
try {
|
|
3077
|
-
return await base.readFile(
|
|
3077
|
+
return await base.readFile(path94, "utf8");
|
|
3078
3078
|
} catch (error2) {
|
|
3079
3079
|
if (isNotFound(error2)) {
|
|
3080
3080
|
return null;
|
|
@@ -11892,8 +11892,8 @@ function resourceNotFound(resource) {
|
|
|
11892
11892
|
`Resource not found: ${resource}`
|
|
11893
11893
|
);
|
|
11894
11894
|
}
|
|
11895
|
-
function assertAbsolutePath(
|
|
11896
|
-
if (!isAbsolute(
|
|
11895
|
+
function assertAbsolutePath(path94) {
|
|
11896
|
+
if (!isAbsolute(path94)) {
|
|
11897
11897
|
throw invalidParams('"path" must be an absolute path');
|
|
11898
11898
|
}
|
|
11899
11899
|
}
|
|
@@ -12768,21 +12768,21 @@ async function* adaptClaude(lines) {
|
|
|
12768
12768
|
if (blockType !== "tool_result") continue;
|
|
12769
12769
|
const kind = toolKindsById.get(item.tool_use_id);
|
|
12770
12770
|
toolKindsById.delete(item.tool_use_id);
|
|
12771
|
-
let
|
|
12771
|
+
let path94;
|
|
12772
12772
|
if (typeof item.content === "string") {
|
|
12773
|
-
|
|
12773
|
+
path94 = item.content;
|
|
12774
12774
|
} else {
|
|
12775
12775
|
try {
|
|
12776
|
-
|
|
12776
|
+
path94 = JSON.stringify(item.content);
|
|
12777
12777
|
} catch {
|
|
12778
|
-
|
|
12778
|
+
path94 = String(item.content);
|
|
12779
12779
|
}
|
|
12780
12780
|
}
|
|
12781
12781
|
yield {
|
|
12782
12782
|
event: "tool_complete",
|
|
12783
12783
|
id: item.tool_use_id,
|
|
12784
12784
|
kind,
|
|
12785
|
-
path:
|
|
12785
|
+
path: path94
|
|
12786
12786
|
};
|
|
12787
12787
|
}
|
|
12788
12788
|
}
|
|
@@ -12905,10 +12905,10 @@ async function* adaptCodex(lines) {
|
|
|
12905
12905
|
const kindFromStart = toolKindById.get(item.id);
|
|
12906
12906
|
const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
|
|
12907
12907
|
const titleFromEvent = isNonEmptyString(item.path) ? item.path : itemType === "mcp_tool_call" ? `${isNonEmptyString(item.server) ? item.server : "unknown"}.${isNonEmptyString(item.tool) ? item.tool : "unknown"}` : void 0;
|
|
12908
|
-
const
|
|
12908
|
+
const path94 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
|
|
12909
12909
|
toolTitleById.delete(item.id);
|
|
12910
12910
|
toolKindById.delete(item.id);
|
|
12911
|
-
yield { event: "tool_complete", id: item.id, kind, path:
|
|
12911
|
+
yield { event: "tool_complete", id: item.id, kind, path: path94 };
|
|
12912
12912
|
}
|
|
12913
12913
|
}
|
|
12914
12914
|
}
|
|
@@ -13592,7 +13592,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
|
|
|
13592
13592
|
}
|
|
13593
13593
|
const id = readString2(event.id);
|
|
13594
13594
|
const kind = readString2(event.kind);
|
|
13595
|
-
const
|
|
13595
|
+
const path94 = readString2(event.path);
|
|
13596
13596
|
let toolCall = id ? toolCallsById.get(id) : void 0;
|
|
13597
13597
|
if (!toolCall) {
|
|
13598
13598
|
toolCall = {};
|
|
@@ -13607,8 +13607,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
|
|
|
13607
13607
|
if (kind) {
|
|
13608
13608
|
toolCall.kind = kind;
|
|
13609
13609
|
}
|
|
13610
|
-
if (
|
|
13611
|
-
toolCall.path =
|
|
13610
|
+
if (path94) {
|
|
13611
|
+
toolCall.path = path94;
|
|
13612
13612
|
}
|
|
13613
13613
|
}
|
|
13614
13614
|
var sessionCapture;
|
|
@@ -23348,6 +23348,17 @@ function parseSuperintendentDoc(filePath, content) {
|
|
|
23348
23348
|
frontmatter: parseFrontmatter(resolvedFilePath, parsedFrontmatter)
|
|
23349
23349
|
};
|
|
23350
23350
|
}
|
|
23351
|
+
function readExplicitBuilderAgent(filePath, content) {
|
|
23352
|
+
const resolvedFilePath = path18.resolve(filePath);
|
|
23353
|
+
const { frontmatterText } = splitFrontmatter(resolvedFilePath, content);
|
|
23354
|
+
const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
|
|
23355
|
+
const frontmatter = expectRecord(parsedFrontmatter, "frontmatter", resolvedFilePath);
|
|
23356
|
+
if (frontmatter.builder === void 0) {
|
|
23357
|
+
return void 0;
|
|
23358
|
+
}
|
|
23359
|
+
const builder = expectRecord(frontmatter.builder, "builder", resolvedFilePath);
|
|
23360
|
+
return builder.agent === void 0 ? void 0 : expectString(builder.agent, "builder.agent", resolvedFilePath);
|
|
23361
|
+
}
|
|
23351
23362
|
function splitFrontmatter(filePath, content) {
|
|
23352
23363
|
const normalizedContent = content.startsWith("\uFEFF") ? content.slice(1) : content;
|
|
23353
23364
|
const openingLineBreak = readOpeningLineBreak(normalizedContent);
|
|
@@ -24133,21 +24144,82 @@ function backoff(attempt, minTimeout, maxTimeout) {
|
|
|
24133
24144
|
function hasErrorCode(error2, code) {
|
|
24134
24145
|
return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
24135
24146
|
}
|
|
24147
|
+
function hasAnyErrorCode(error2, codes) {
|
|
24148
|
+
return codes.some((code) => hasErrorCode(error2, code));
|
|
24149
|
+
}
|
|
24150
|
+
function isPidRunning(pid) {
|
|
24151
|
+
try {
|
|
24152
|
+
process.kill(pid, 0);
|
|
24153
|
+
return true;
|
|
24154
|
+
} catch (error2) {
|
|
24155
|
+
return !hasErrorCode(error2, "ESRCH");
|
|
24156
|
+
}
|
|
24157
|
+
}
|
|
24136
24158
|
function createDefaultFs() {
|
|
24137
24159
|
return {
|
|
24138
|
-
open: (
|
|
24160
|
+
open: (path94, flags) => fsPromises5.open(path94, flags),
|
|
24161
|
+
readFile: (path94, encoding) => fsPromises5.readFile(path94, encoding),
|
|
24139
24162
|
stat: fsPromises5.stat,
|
|
24140
24163
|
unlink: fsPromises5.unlink
|
|
24141
24164
|
};
|
|
24142
24165
|
}
|
|
24143
|
-
async function removeLockFile(fs19, lockPath) {
|
|
24166
|
+
async function removeLockFile(fs19, lockPath, signal) {
|
|
24167
|
+
for (let attempt = 0; attempt <= 4; attempt += 1) {
|
|
24168
|
+
throwIfAborted(signal);
|
|
24169
|
+
try {
|
|
24170
|
+
await fs19.unlink(lockPath);
|
|
24171
|
+
return;
|
|
24172
|
+
} catch (error2) {
|
|
24173
|
+
if (hasErrorCode(error2, "ENOENT")) {
|
|
24174
|
+
return;
|
|
24175
|
+
}
|
|
24176
|
+
if (!hasAnyErrorCode(error2, ["EPERM", "EBUSY"]) || attempt === 4) {
|
|
24177
|
+
throw error2;
|
|
24178
|
+
}
|
|
24179
|
+
}
|
|
24180
|
+
await sleep(25 * 2 ** attempt, signal);
|
|
24181
|
+
}
|
|
24182
|
+
}
|
|
24183
|
+
function parseLockMetadata(content) {
|
|
24144
24184
|
try {
|
|
24145
|
-
|
|
24185
|
+
const parsed = JSON.parse(content);
|
|
24186
|
+
if (!parsed || typeof parsed !== "object" || !("host" in parsed) || !("pid" in parsed)) {
|
|
24187
|
+
return void 0;
|
|
24188
|
+
}
|
|
24189
|
+
const { host, pid } = parsed;
|
|
24190
|
+
if (typeof host === "string" && typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0) {
|
|
24191
|
+
return {
|
|
24192
|
+
host,
|
|
24193
|
+
pid
|
|
24194
|
+
};
|
|
24195
|
+
}
|
|
24196
|
+
} catch (ignoredError) {
|
|
24197
|
+
void ignoredError;
|
|
24198
|
+
}
|
|
24199
|
+
return void 0;
|
|
24200
|
+
}
|
|
24201
|
+
async function readLockMetadata(fs19, lockPath) {
|
|
24202
|
+
if (!fs19.readFile) {
|
|
24203
|
+
return void 0;
|
|
24204
|
+
}
|
|
24205
|
+
try {
|
|
24206
|
+
return parseLockMetadata(await fs19.readFile(lockPath, "utf8"));
|
|
24146
24207
|
} catch (error2) {
|
|
24147
|
-
if (
|
|
24148
|
-
|
|
24208
|
+
if (hasErrorCode(error2, "ENOENT")) {
|
|
24209
|
+
return null;
|
|
24149
24210
|
}
|
|
24211
|
+
return void 0;
|
|
24212
|
+
}
|
|
24213
|
+
}
|
|
24214
|
+
async function shouldReclaimLock(options) {
|
|
24215
|
+
const metadata = await readLockMetadata(options.fs, options.lockPath);
|
|
24216
|
+
if (metadata === null) {
|
|
24217
|
+
return "missing";
|
|
24218
|
+
}
|
|
24219
|
+
if (metadata?.host === os2.hostname()) {
|
|
24220
|
+
return !options.isPidRunning(metadata.pid);
|
|
24150
24221
|
}
|
|
24222
|
+
return Date.now() - options.stat.mtimeMs > options.staleMs;
|
|
24151
24223
|
}
|
|
24152
24224
|
async function writeLockMetadata(handle) {
|
|
24153
24225
|
try {
|
|
@@ -24169,7 +24241,8 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
24169
24241
|
const retries = options.retries ?? 20;
|
|
24170
24242
|
const minTimeout = options.minTimeout ?? 25;
|
|
24171
24243
|
const maxTimeout = options.maxTimeout ?? 250;
|
|
24172
|
-
const staleMs = options.staleMs ??
|
|
24244
|
+
const staleMs = options.staleMs ?? 1e3;
|
|
24245
|
+
const pidIsRunning = options.isPidRunning ?? isPidRunning;
|
|
24173
24246
|
const lockPath = `${filePath}.lock`;
|
|
24174
24247
|
let attempt = 0;
|
|
24175
24248
|
while (attempt <= retries) {
|
|
@@ -24183,7 +24256,7 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
24183
24256
|
return;
|
|
24184
24257
|
}
|
|
24185
24258
|
released = true;
|
|
24186
|
-
await removeLockFile(fs19, lockPath);
|
|
24259
|
+
await removeLockFile(fs19, lockPath, options.signal);
|
|
24187
24260
|
};
|
|
24188
24261
|
} catch (error2) {
|
|
24189
24262
|
if (!hasErrorCode(error2, "EEXIST")) {
|
|
@@ -24199,8 +24272,18 @@ async function acquireFileLock(filePath, options = {}) {
|
|
|
24199
24272
|
}
|
|
24200
24273
|
throw statError;
|
|
24201
24274
|
}
|
|
24202
|
-
|
|
24203
|
-
|
|
24275
|
+
const reclaimLock = await shouldReclaimLock({
|
|
24276
|
+
fs: fs19,
|
|
24277
|
+
isPidRunning: pidIsRunning,
|
|
24278
|
+
lockPath,
|
|
24279
|
+
staleMs,
|
|
24280
|
+
stat: stat24
|
|
24281
|
+
});
|
|
24282
|
+
if (reclaimLock === "missing") {
|
|
24283
|
+
continue;
|
|
24284
|
+
}
|
|
24285
|
+
if (reclaimLock) {
|
|
24286
|
+
await removeLockFile(fs19, lockPath, options.signal);
|
|
24204
24287
|
continue;
|
|
24205
24288
|
}
|
|
24206
24289
|
if (attempt >= retries) {
|
|
@@ -26279,8 +26362,69 @@ var init_src14 = __esm({
|
|
|
26279
26362
|
}
|
|
26280
26363
|
});
|
|
26281
26364
|
|
|
26282
|
-
// packages/toolcraft/src/
|
|
26365
|
+
// packages/toolcraft/src/package-metadata.ts
|
|
26366
|
+
import { existsSync, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
26367
|
+
import path24 from "node:path";
|
|
26283
26368
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
26369
|
+
function pathFromInput(from) {
|
|
26370
|
+
if (from instanceof URL) {
|
|
26371
|
+
return fileURLToPath2(from);
|
|
26372
|
+
}
|
|
26373
|
+
if (from.startsWith("file:")) {
|
|
26374
|
+
return fileURLToPath2(from);
|
|
26375
|
+
}
|
|
26376
|
+
return path24.resolve(from);
|
|
26377
|
+
}
|
|
26378
|
+
function getSearchDirectory(from) {
|
|
26379
|
+
const resolved = pathFromInput(from);
|
|
26380
|
+
try {
|
|
26381
|
+
return statSync(resolved).isDirectory() ? resolved : path24.dirname(resolved);
|
|
26382
|
+
} catch {
|
|
26383
|
+
return path24.dirname(resolved);
|
|
26384
|
+
}
|
|
26385
|
+
}
|
|
26386
|
+
function readPackageMetadata(packageJsonPath) {
|
|
26387
|
+
const parsed = JSON.parse(readFileSync2(packageJsonPath, "utf8"));
|
|
26388
|
+
const metadata = { path: packageJsonPath };
|
|
26389
|
+
if (typeof parsed.name === "string") {
|
|
26390
|
+
metadata.name = parsed.name;
|
|
26391
|
+
}
|
|
26392
|
+
if (typeof parsed.version === "string") {
|
|
26393
|
+
metadata.version = parsed.version;
|
|
26394
|
+
}
|
|
26395
|
+
return metadata;
|
|
26396
|
+
}
|
|
26397
|
+
function findPackageMetadata(from) {
|
|
26398
|
+
let current = getSearchDirectory(from);
|
|
26399
|
+
while (true) {
|
|
26400
|
+
const packageJsonPath = path24.join(current, "package.json");
|
|
26401
|
+
if (existsSync(packageJsonPath)) {
|
|
26402
|
+
return readPackageMetadata(packageJsonPath);
|
|
26403
|
+
}
|
|
26404
|
+
const parent = path24.dirname(current);
|
|
26405
|
+
if (parent === current) {
|
|
26406
|
+
return void 0;
|
|
26407
|
+
}
|
|
26408
|
+
current = parent;
|
|
26409
|
+
}
|
|
26410
|
+
}
|
|
26411
|
+
function findEntrypointPackageMetadata(entrypoint) {
|
|
26412
|
+
if (entrypoint === void 0 || entrypoint.length === 0) {
|
|
26413
|
+
return void 0;
|
|
26414
|
+
}
|
|
26415
|
+
if (!path24.isAbsolute(entrypoint) && !entrypoint.startsWith("file:")) {
|
|
26416
|
+
return void 0;
|
|
26417
|
+
}
|
|
26418
|
+
return findPackageMetadata(entrypoint);
|
|
26419
|
+
}
|
|
26420
|
+
var init_package_metadata = __esm({
|
|
26421
|
+
"packages/toolcraft/src/package-metadata.ts"() {
|
|
26422
|
+
"use strict";
|
|
26423
|
+
}
|
|
26424
|
+
});
|
|
26425
|
+
|
|
26426
|
+
// packages/toolcraft/src/index.ts
|
|
26427
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
26284
26428
|
function cloneScope(scope) {
|
|
26285
26429
|
return scope === void 0 ? void 0 : [...scope];
|
|
26286
26430
|
}
|
|
@@ -26362,7 +26506,7 @@ function validateRenameMap(rename8) {
|
|
|
26362
26506
|
function parseStackPath(candidate) {
|
|
26363
26507
|
if (candidate.startsWith("file://")) {
|
|
26364
26508
|
try {
|
|
26365
|
-
return
|
|
26509
|
+
return fileURLToPath3(candidate);
|
|
26366
26510
|
} catch {
|
|
26367
26511
|
return void 0;
|
|
26368
26512
|
}
|
|
@@ -26720,6 +26864,7 @@ var init_src15 = __esm({
|
|
|
26720
26864
|
init_config3();
|
|
26721
26865
|
init_user_error();
|
|
26722
26866
|
init_src14();
|
|
26867
|
+
init_package_metadata();
|
|
26723
26868
|
commandConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.command.config");
|
|
26724
26869
|
groupConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.group.config");
|
|
26725
26870
|
commandSourcePathSymbol = /* @__PURE__ */ Symbol("toolcraft.command.sourcePath");
|
|
@@ -26808,7 +26953,7 @@ var init_builder_group = __esm({
|
|
|
26808
26953
|
|
|
26809
26954
|
// packages/agent-skill-config/src/configs.ts
|
|
26810
26955
|
import os3 from "node:os";
|
|
26811
|
-
import
|
|
26956
|
+
import path25 from "node:path";
|
|
26812
26957
|
function resolveAgentSupport(input, registry = agentSkillConfigs) {
|
|
26813
26958
|
const resolvedId = resolveAgentId(input);
|
|
26814
26959
|
if (!resolvedId) {
|
|
@@ -26848,9 +26993,9 @@ var init_configs2 = __esm({
|
|
|
26848
26993
|
});
|
|
26849
26994
|
|
|
26850
26995
|
// packages/agent-skill-config/src/templates.ts
|
|
26851
|
-
import { readFile as
|
|
26852
|
-
import
|
|
26853
|
-
import { fileURLToPath as
|
|
26996
|
+
import { readFile as readFile4, stat as stat3 } from "node:fs/promises";
|
|
26997
|
+
import path26 from "node:path";
|
|
26998
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
26854
26999
|
async function pathExists2(target) {
|
|
26855
27000
|
try {
|
|
26856
27001
|
await stat3(target);
|
|
@@ -26863,12 +27008,12 @@ async function pathExists2(target) {
|
|
|
26863
27008
|
}
|
|
26864
27009
|
}
|
|
26865
27010
|
async function findPackageRoot(entryFilePath) {
|
|
26866
|
-
let current =
|
|
27011
|
+
let current = path26.dirname(entryFilePath);
|
|
26867
27012
|
while (true) {
|
|
26868
|
-
if (await pathExists2(
|
|
27013
|
+
if (await pathExists2(path26.join(current, "package.json"))) {
|
|
26869
27014
|
return current;
|
|
26870
27015
|
}
|
|
26871
|
-
const parent =
|
|
27016
|
+
const parent = path26.dirname(current);
|
|
26872
27017
|
if (parent === current) {
|
|
26873
27018
|
throw new Error("Unable to locate package root for agent-skill-config templates.");
|
|
26874
27019
|
}
|
|
@@ -26876,11 +27021,11 @@ async function findPackageRoot(entryFilePath) {
|
|
|
26876
27021
|
}
|
|
26877
27022
|
}
|
|
26878
27023
|
async function resolveTemplatePath(templateId) {
|
|
26879
|
-
const packageRoot = await findPackageRoot(
|
|
27024
|
+
const packageRoot = await findPackageRoot(fileURLToPath4(import.meta.url));
|
|
26880
27025
|
const candidates = [
|
|
26881
|
-
|
|
26882
|
-
|
|
26883
|
-
|
|
27026
|
+
path26.join(packageRoot, "src", "templates", templateId),
|
|
27027
|
+
path26.join(packageRoot, "dist", "templates", templateId),
|
|
27028
|
+
path26.join(packageRoot, "dist", "templates", "skill", templateId)
|
|
26884
27029
|
];
|
|
26885
27030
|
for (const candidate of candidates) {
|
|
26886
27031
|
if (await pathExists2(candidate)) {
|
|
@@ -26901,7 +27046,7 @@ async function loadTemplate(templateId) {
|
|
|
26901
27046
|
return cached2;
|
|
26902
27047
|
}
|
|
26903
27048
|
const resolved = await resolveTemplatePath(templateId);
|
|
26904
|
-
const content = await
|
|
27049
|
+
const content = await readFile4(resolved, "utf8");
|
|
26905
27050
|
cache.set(templateId, content);
|
|
26906
27051
|
return content;
|
|
26907
27052
|
}
|
|
@@ -27048,9 +27193,9 @@ var init_src16 = __esm({
|
|
|
27048
27193
|
});
|
|
27049
27194
|
|
|
27050
27195
|
// packages/superintendent/src/commands/install.ts
|
|
27051
|
-
import
|
|
27052
|
-
import { readFile as
|
|
27053
|
-
import { fileURLToPath as
|
|
27196
|
+
import path27 from "node:path";
|
|
27197
|
+
import { readFile as readFile5, stat as stat4, mkdir as mkdir4, writeFile as writeFile2, unlink as unlink3, readdir as readdir3, chmod as chmod2 } from "node:fs/promises";
|
|
27198
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
27054
27199
|
async function resolvePlanDirectory(cwd, homeDir, env) {
|
|
27055
27200
|
const configPath = resolveConfigPath(homeDir);
|
|
27056
27201
|
const projectConfigPath = resolveProjectConfigPath(cwd);
|
|
@@ -27059,9 +27204,9 @@ async function resolvePlanDirectory(cwd, homeDir, env) {
|
|
|
27059
27204
|
}
|
|
27060
27205
|
function resolveAbsoluteDirectory(dir, cwd, homeDir) {
|
|
27061
27206
|
if (dir.startsWith("~/")) {
|
|
27062
|
-
return
|
|
27207
|
+
return path27.join(homeDir, dir.slice(2));
|
|
27063
27208
|
}
|
|
27064
|
-
return
|
|
27209
|
+
return path27.isAbsolute(dir) ? dir : path27.resolve(cwd, dir);
|
|
27065
27210
|
}
|
|
27066
27211
|
async function pathExists3(targetPath) {
|
|
27067
27212
|
try {
|
|
@@ -27078,17 +27223,17 @@ async function loadSkillTemplate() {
|
|
|
27078
27223
|
if (skillTemplateCache) {
|
|
27079
27224
|
return skillTemplateCache;
|
|
27080
27225
|
}
|
|
27081
|
-
const packageRoot = await findPackageRoot2(
|
|
27226
|
+
const packageRoot = await findPackageRoot2(fileURLToPath5(import.meta.url));
|
|
27082
27227
|
const templateRoots = [
|
|
27083
|
-
|
|
27084
|
-
|
|
27228
|
+
path27.join(packageRoot, "src", "templates"),
|
|
27229
|
+
path27.join(packageRoot, "dist", "templates")
|
|
27085
27230
|
];
|
|
27086
27231
|
for (const templateRoot of templateRoots) {
|
|
27087
27232
|
if (!await pathExists3(templateRoot)) {
|
|
27088
27233
|
continue;
|
|
27089
27234
|
}
|
|
27090
|
-
skillTemplateCache = await
|
|
27091
|
-
|
|
27235
|
+
skillTemplateCache = await readFile5(
|
|
27236
|
+
path27.join(templateRoot, "SKILL_superintendent.md"),
|
|
27092
27237
|
"utf8"
|
|
27093
27238
|
);
|
|
27094
27239
|
return skillTemplateCache;
|
|
@@ -27096,12 +27241,12 @@ async function loadSkillTemplate() {
|
|
|
27096
27241
|
throw new Error("Unable to locate Superintendent skill template.");
|
|
27097
27242
|
}
|
|
27098
27243
|
async function findPackageRoot2(entryFilePath) {
|
|
27099
|
-
let currentPath =
|
|
27244
|
+
let currentPath = path27.dirname(entryFilePath);
|
|
27100
27245
|
while (true) {
|
|
27101
|
-
if (await pathExists3(
|
|
27246
|
+
if (await pathExists3(path27.join(currentPath, "package.json"))) {
|
|
27102
27247
|
return currentPath;
|
|
27103
27248
|
}
|
|
27104
|
-
const parentPath =
|
|
27249
|
+
const parentPath = path27.dirname(currentPath);
|
|
27105
27250
|
if (parentPath === currentPath) {
|
|
27106
27251
|
throw new Error("Unable to locate package root for Superintendent templates.");
|
|
27107
27252
|
}
|
|
@@ -27117,7 +27262,7 @@ var init_install = __esm({
|
|
|
27117
27262
|
init_src16();
|
|
27118
27263
|
init_src13();
|
|
27119
27264
|
fs2 = {
|
|
27120
|
-
readFile: (p, encoding) =>
|
|
27265
|
+
readFile: (p, encoding) => readFile5(p, encoding),
|
|
27121
27266
|
writeFile: (p, content) => writeFile2(p, content),
|
|
27122
27267
|
mkdir: (p, options) => mkdir4(p, options).then(() => void 0),
|
|
27123
27268
|
unlink: (p) => unlink3(p),
|
|
@@ -27412,13 +27557,13 @@ var init_complete = __esm({
|
|
|
27412
27557
|
});
|
|
27413
27558
|
|
|
27414
27559
|
// packages/superintendent/src/commands/plan-path.ts
|
|
27415
|
-
import
|
|
27416
|
-
import { readFile as
|
|
27560
|
+
import path28 from "node:path";
|
|
27561
|
+
import { readFile as readFile6, writeFile as writeFile3, mkdir as mkdir5, unlink as unlink4, stat as stat5, readdir as readdir4 } from "node:fs/promises";
|
|
27417
27562
|
function resolveAbsoluteDirectory2(dir, cwd, homeDir) {
|
|
27418
27563
|
if (dir.startsWith("~/")) {
|
|
27419
|
-
return
|
|
27564
|
+
return path28.join(homeDir, dir.slice(2));
|
|
27420
27565
|
}
|
|
27421
|
-
return
|
|
27566
|
+
return path28.isAbsolute(dir) ? dir : path28.resolve(cwd, dir);
|
|
27422
27567
|
}
|
|
27423
27568
|
var fs3, planPathCommand;
|
|
27424
27569
|
var init_plan_path = __esm({
|
|
@@ -27427,7 +27572,7 @@ var init_plan_path = __esm({
|
|
|
27427
27572
|
init_src15();
|
|
27428
27573
|
init_src5();
|
|
27429
27574
|
fs3 = {
|
|
27430
|
-
readFile: (p, encoding) =>
|
|
27575
|
+
readFile: (p, encoding) => readFile6(p, encoding),
|
|
27431
27576
|
writeFile: (p, content) => writeFile3(p, content),
|
|
27432
27577
|
mkdir: (p, options) => mkdir5(p, options).then(() => void 0),
|
|
27433
27578
|
unlink: (p) => unlink4(p),
|
|
@@ -27501,7 +27646,7 @@ var init_config_scope = __esm({
|
|
|
27501
27646
|
});
|
|
27502
27647
|
|
|
27503
27648
|
// packages/superintendent/src/commands/run.ts
|
|
27504
|
-
import
|
|
27649
|
+
import path29 from "node:path";
|
|
27505
27650
|
import * as fsPromises7 from "node:fs/promises";
|
|
27506
27651
|
import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
|
|
27507
27652
|
function createRunMcpCommand(runners) {
|
|
@@ -27612,10 +27757,13 @@ async function runSuperintendentCommand(options) {
|
|
|
27612
27757
|
runner: "superintendent",
|
|
27613
27758
|
homeDir: options.homeDir
|
|
27614
27759
|
});
|
|
27615
|
-
const
|
|
27760
|
+
const documentContent = await fs19.readFile(selectedDocPath, "utf8");
|
|
27761
|
+
const document = parseSuperintendentDoc(selectedDocPath, documentContent);
|
|
27616
27762
|
const selectedBuilder = await resolveLoopAgent({
|
|
27617
27763
|
providedAgent: normalizeAgentSelection(options.builderAgent),
|
|
27618
|
-
frontmatterAgent: normalizeAgentSelection(
|
|
27764
|
+
frontmatterAgent: normalizeAgentSelection(
|
|
27765
|
+
readExplicitBuilderAgent(selectedDocPath, documentContent)
|
|
27766
|
+
),
|
|
27619
27767
|
configuredDefaultAgent: normalizeAgentSelection(options.configuredDefaultAgent) ?? null,
|
|
27620
27768
|
assumeYes,
|
|
27621
27769
|
fallbackAgent: "claude-code",
|
|
@@ -27891,7 +28039,7 @@ async function runSuperintendentCommand(options) {
|
|
|
27891
28039
|
session.pauseRequested = true;
|
|
27892
28040
|
}
|
|
27893
28041
|
editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
|
|
27894
|
-
appendEvent("info", `Log opened: ${
|
|
28042
|
+
appendEvent("info", `Log opened: ${path29.basename(session.latestLogFile)}`);
|
|
27895
28043
|
syncStats();
|
|
27896
28044
|
}
|
|
27897
28045
|
};
|
|
@@ -28040,13 +28188,13 @@ async function listPlanDirectoryDocs(fs19, planDirectory, cwd, homeDir) {
|
|
|
28040
28188
|
}
|
|
28041
28189
|
throw error2;
|
|
28042
28190
|
}
|
|
28043
|
-
return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) =>
|
|
28191
|
+
return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) => path29.join(absoluteDir, entry)).sort((left, right) => left.localeCompare(right));
|
|
28044
28192
|
}
|
|
28045
28193
|
function resolveAbsolutePlanDirectory(dir, cwd, homeDir) {
|
|
28046
28194
|
if (dir.startsWith("~/")) {
|
|
28047
|
-
return
|
|
28195
|
+
return path29.join(homeDir, dir.slice(2));
|
|
28048
28196
|
}
|
|
28049
|
-
return
|
|
28197
|
+
return path29.isAbsolute(dir) ? dir : path29.resolve(cwd, dir);
|
|
28050
28198
|
}
|
|
28051
28199
|
function normalizeAgentSelection(value) {
|
|
28052
28200
|
if (typeof value !== "string") {
|
|
@@ -28282,7 +28430,7 @@ function resolveEditor(env) {
|
|
|
28282
28430
|
const parts = raw.split(/\s+/);
|
|
28283
28431
|
const command = parts[0] ?? "vi";
|
|
28284
28432
|
const args = parts.slice(1);
|
|
28285
|
-
const binary =
|
|
28433
|
+
const binary = path29.basename(command);
|
|
28286
28434
|
const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
|
|
28287
28435
|
return { command, args, mode };
|
|
28288
28436
|
}
|
|
@@ -28309,11 +28457,11 @@ function stripStopReason(result) {
|
|
|
28309
28457
|
};
|
|
28310
28458
|
}
|
|
28311
28459
|
function displayPath(filePath, cwd, homeDir) {
|
|
28312
|
-
if (filePath.startsWith(`${cwd}${
|
|
28313
|
-
return
|
|
28460
|
+
if (filePath.startsWith(`${cwd}${path29.sep}`)) {
|
|
28461
|
+
return path29.relative(cwd, filePath);
|
|
28314
28462
|
}
|
|
28315
|
-
if (filePath.startsWith(`${homeDir}${
|
|
28316
|
-
return `~/${
|
|
28463
|
+
if (filePath.startsWith(`${homeDir}${path29.sep}`)) {
|
|
28464
|
+
return `~/${path29.relative(homeDir, filePath)}`;
|
|
28317
28465
|
}
|
|
28318
28466
|
return filePath;
|
|
28319
28467
|
}
|
|
@@ -28717,7 +28865,7 @@ var init_src17 = __esm({
|
|
|
28717
28865
|
});
|
|
28718
28866
|
|
|
28719
28867
|
// src/services/config.ts
|
|
28720
|
-
import
|
|
28868
|
+
import path30 from "node:path";
|
|
28721
28869
|
async function deleteConfig(options) {
|
|
28722
28870
|
const { fs: fs19, filePath } = options;
|
|
28723
28871
|
try {
|
|
@@ -28820,7 +28968,7 @@ async function migrateLegacyCredentialsIfNeeded(fs19, filePath) {
|
|
|
28820
28968
|
await migrateLegacyCredentialsFile(fs19, filePath);
|
|
28821
28969
|
}
|
|
28822
28970
|
async function migrateLegacyCredentialsFile(fs19, configPath) {
|
|
28823
|
-
const legacyPath =
|
|
28971
|
+
const legacyPath = path30.join(path30.dirname(configPath), "credentials.json");
|
|
28824
28972
|
const raw = await readFileIfExists(fs19, legacyPath);
|
|
28825
28973
|
if (raw === null) {
|
|
28826
28974
|
return;
|
|
@@ -28889,9 +29037,9 @@ async function recoverInvalidConfig(fs19, filePath, content) {
|
|
|
28889
29037
|
await fs19.writeFile(filePath, EMPTY_DOCUMENT3, { encoding: "utf8" });
|
|
28890
29038
|
}
|
|
28891
29039
|
function createInvalidBackupPath2(filePath) {
|
|
28892
|
-
const directory =
|
|
28893
|
-
const baseName =
|
|
28894
|
-
return
|
|
29040
|
+
const directory = path30.dirname(filePath);
|
|
29041
|
+
const baseName = path30.basename(filePath);
|
|
29042
|
+
return path30.join(directory, `${baseName}.invalid-${createTimestamp()}.json`);
|
|
28895
29043
|
}
|
|
28896
29044
|
function isRecord10(value) {
|
|
28897
29045
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -29048,7 +29196,7 @@ var init_errors2 = __esm({
|
|
|
29048
29196
|
});
|
|
29049
29197
|
|
|
29050
29198
|
// src/cli/commands/shared.ts
|
|
29051
|
-
import
|
|
29199
|
+
import path31 from "node:path";
|
|
29052
29200
|
function buildActiveProvider(id, baseUrl, credential) {
|
|
29053
29201
|
return { id, baseUrl, credential, extraEnv: {} };
|
|
29054
29202
|
}
|
|
@@ -29183,7 +29331,7 @@ function buildResumeCommand(canonicalService, threadId, cwd) {
|
|
|
29183
29331
|
if (!binaryName) {
|
|
29184
29332
|
return void 0;
|
|
29185
29333
|
}
|
|
29186
|
-
const resumeCwd =
|
|
29334
|
+
const resumeCwd = path31.resolve(cwd);
|
|
29187
29335
|
const args = spawnConfig.resumeCommand(threadId, resumeCwd);
|
|
29188
29336
|
const agentCommand = [binaryName, ...args.map(shlexQuote)].join(" ");
|
|
29189
29337
|
const needsCdPrefix = !args.includes(resumeCwd);
|
|
@@ -29383,14 +29531,14 @@ function parseDockerLocator(input) {
|
|
|
29383
29531
|
throw new Error(`Invalid docker workspace locator "${input}".`);
|
|
29384
29532
|
}
|
|
29385
29533
|
const container = input.slice(0, slashIndex);
|
|
29386
|
-
const
|
|
29387
|
-
if (container.length === 0 ||
|
|
29534
|
+
const path94 = input.slice(slashIndex);
|
|
29535
|
+
if (container.length === 0 || path94.length === 0) {
|
|
29388
29536
|
throw new Error(`Invalid docker workspace locator "${input}".`);
|
|
29389
29537
|
}
|
|
29390
29538
|
return {
|
|
29391
29539
|
scheme: "docker",
|
|
29392
29540
|
container,
|
|
29393
|
-
path:
|
|
29541
|
+
path: path94
|
|
29394
29542
|
};
|
|
29395
29543
|
}
|
|
29396
29544
|
function splitOnce(input, separator) {
|
|
@@ -29451,9 +29599,9 @@ var init_parse3 = __esm({
|
|
|
29451
29599
|
});
|
|
29452
29600
|
|
|
29453
29601
|
// packages/workspace-resolver/src/github/clone.ts
|
|
29454
|
-
import
|
|
29602
|
+
import path32 from "node:path";
|
|
29455
29603
|
function buildCachePath(homeDir, locator) {
|
|
29456
|
-
return
|
|
29604
|
+
return path32.join(
|
|
29457
29605
|
homeDir,
|
|
29458
29606
|
".poe-code",
|
|
29459
29607
|
"workspaces",
|
|
@@ -29468,7 +29616,7 @@ async function cloneOrUpdate(locator, options) {
|
|
|
29468
29616
|
const cacheDir = buildCachePath(options.homeDir, locator);
|
|
29469
29617
|
const exists = await pathExists4(options.fs, cacheDir);
|
|
29470
29618
|
if (!exists) {
|
|
29471
|
-
await options.fs.mkdir(
|
|
29619
|
+
await options.fs.mkdir(path32.dirname(cacheDir), { recursive: true });
|
|
29472
29620
|
await assertExecSuccess(
|
|
29473
29621
|
await options.exec("git", ["clone", "--depth", "1", buildCloneUrl(locator), cacheDir]),
|
|
29474
29622
|
"git clone failed"
|
|
@@ -29514,9 +29662,9 @@ var init_clone = __esm({
|
|
|
29514
29662
|
});
|
|
29515
29663
|
|
|
29516
29664
|
// packages/workspace-resolver/src/github/isolation.ts
|
|
29517
|
-
import
|
|
29665
|
+
import path33 from "node:path";
|
|
29518
29666
|
async function createWritableCheckout(locator, sourceCwd, options) {
|
|
29519
|
-
const cwd =
|
|
29667
|
+
const cwd = path33.join(
|
|
29520
29668
|
options.homeDir,
|
|
29521
29669
|
".poe-code",
|
|
29522
29670
|
"workspaces",
|
|
@@ -29525,7 +29673,7 @@ async function createWritableCheckout(locator, sourceCwd, options) {
|
|
|
29525
29673
|
createCheckoutId()
|
|
29526
29674
|
);
|
|
29527
29675
|
const revision = locator.ref ?? "HEAD";
|
|
29528
|
-
await options.fs.mkdir(
|
|
29676
|
+
await options.fs.mkdir(path33.dirname(cwd), { recursive: true });
|
|
29529
29677
|
await assertExecSuccess2(
|
|
29530
29678
|
await options.exec("git", ["worktree", "add", "--detach", cwd, revision], {
|
|
29531
29679
|
cwd: sourceCwd
|
|
@@ -29565,12 +29713,12 @@ var init_isolation = __esm({
|
|
|
29565
29713
|
});
|
|
29566
29714
|
|
|
29567
29715
|
// packages/workspace-resolver/src/resolve.ts
|
|
29568
|
-
import
|
|
29716
|
+
import path34 from "node:path";
|
|
29569
29717
|
async function resolveWorkspace(input, options) {
|
|
29570
29718
|
const locator = parseLocator(input);
|
|
29571
29719
|
if (locator.scheme === "local") {
|
|
29572
29720
|
return {
|
|
29573
|
-
cwd:
|
|
29721
|
+
cwd: path34.isAbsolute(locator.path) ? locator.path : path34.resolve(options.baseDir, locator.path),
|
|
29574
29722
|
locator
|
|
29575
29723
|
};
|
|
29576
29724
|
}
|
|
@@ -29583,7 +29731,7 @@ async function resolveWorkspace(input, options) {
|
|
|
29583
29731
|
try {
|
|
29584
29732
|
writable = mode === "read" ? void 0 : await createWritableCheckout(locator, cacheDir, options);
|
|
29585
29733
|
const workspaceRoot = writable?.cwd ?? cacheDir;
|
|
29586
|
-
const cwd = locator.subdir ?
|
|
29734
|
+
const cwd = locator.subdir ? path34.join(workspaceRoot, locator.subdir) : workspaceRoot;
|
|
29587
29735
|
await assertPathExists(options.fs, cwd, locator);
|
|
29588
29736
|
return {
|
|
29589
29737
|
cwd,
|
|
@@ -29796,7 +29944,7 @@ var init_spawn_core = __esm({
|
|
|
29796
29944
|
});
|
|
29797
29945
|
|
|
29798
29946
|
// src/cli/environment.ts
|
|
29799
|
-
import
|
|
29947
|
+
import path35 from "node:path";
|
|
29800
29948
|
function createCliEnvironment(init) {
|
|
29801
29949
|
const platform = init.platform ?? process.platform;
|
|
29802
29950
|
const variables = init.variables ?? process.env;
|
|
@@ -29804,7 +29952,7 @@ function createCliEnvironment(init) {
|
|
|
29804
29952
|
const projectConfigPath = resolveProjectConfigPath(init.cwd);
|
|
29805
29953
|
const logDir = resolveLogDir(init.homeDir);
|
|
29806
29954
|
const { poeApiBaseUrl, poeBaseUrl } = resolvePoeBaseUrls(variables);
|
|
29807
|
-
const resolveHomePath = (...segments) =>
|
|
29955
|
+
const resolveHomePath = (...segments) => path35.join(init.homeDir, ...segments);
|
|
29808
29956
|
const getVariable = (name) => variables[name];
|
|
29809
29957
|
return {
|
|
29810
29958
|
cwd: init.cwd,
|
|
@@ -29821,7 +29969,7 @@ function createCliEnvironment(init) {
|
|
|
29821
29969
|
};
|
|
29822
29970
|
}
|
|
29823
29971
|
function resolveLogDir(homeDir) {
|
|
29824
|
-
return
|
|
29972
|
+
return path35.join(homeDir, ".poe-code", "logs");
|
|
29825
29973
|
}
|
|
29826
29974
|
function resolvePoeBaseUrls(variables) {
|
|
29827
29975
|
const raw = variables.POE_BASE_URL;
|
|
@@ -30569,7 +30717,7 @@ var init_logger2 = __esm({
|
|
|
30569
30717
|
});
|
|
30570
30718
|
|
|
30571
30719
|
// src/cli/error-logger.ts
|
|
30572
|
-
import
|
|
30720
|
+
import path36 from "node:path";
|
|
30573
30721
|
var DEFAULT_MAX_SIZE, DEFAULT_MAX_BACKUPS, ErrorLogger;
|
|
30574
30722
|
var init_error_logger = __esm({
|
|
30575
30723
|
"src/cli/error-logger.ts"() {
|
|
@@ -30586,7 +30734,7 @@ var init_error_logger = __esm({
|
|
|
30586
30734
|
fileLoggingAvailable;
|
|
30587
30735
|
constructor(options) {
|
|
30588
30736
|
this.fs = options.fs;
|
|
30589
|
-
this.logFilePath =
|
|
30737
|
+
this.logFilePath = path36.join(options.logDir, "errors.log");
|
|
30590
30738
|
this.logToStderr = options.logToStderr ?? true;
|
|
30591
30739
|
this.maxSize = options.maxSize ?? DEFAULT_MAX_SIZE;
|
|
30592
30740
|
this.maxBackups = options.maxBackups ?? DEFAULT_MAX_BACKUPS;
|
|
@@ -30707,7 +30855,7 @@ ${entry.stack}`);
|
|
|
30707
30855
|
return `${this.logFilePath}.${index}`;
|
|
30708
30856
|
}
|
|
30709
30857
|
ensureLogDirectory() {
|
|
30710
|
-
const directory =
|
|
30858
|
+
const directory = path36.dirname(this.logFilePath);
|
|
30711
30859
|
try {
|
|
30712
30860
|
if (!this.fs.existsSync(directory)) {
|
|
30713
30861
|
this.fs.mkdirSync(directory, { recursive: true });
|
|
@@ -30725,9 +30873,9 @@ ${entry.stack}`);
|
|
|
30725
30873
|
});
|
|
30726
30874
|
|
|
30727
30875
|
// src/providers/index.ts
|
|
30728
|
-
import
|
|
30876
|
+
import path37 from "node:path";
|
|
30729
30877
|
import { readdir as readdir6 } from "node:fs/promises";
|
|
30730
|
-
import { fileURLToPath as
|
|
30878
|
+
import { fileURLToPath as fileURLToPath6, pathToFileURL } from "node:url";
|
|
30731
30879
|
function isProviderModule(filename) {
|
|
30732
30880
|
if (filename.endsWith(".d.ts") || filename.endsWith(".d.ts.map")) {
|
|
30733
30881
|
return false;
|
|
@@ -30752,7 +30900,7 @@ async function loadProviders() {
|
|
|
30752
30900
|
for (const entry of entries) {
|
|
30753
30901
|
if (!entry.isFile()) continue;
|
|
30754
30902
|
if (!isProviderModule(entry.name)) continue;
|
|
30755
|
-
const moduleUrl = pathToFileURL(
|
|
30903
|
+
const moduleUrl = pathToFileURL(path37.join(currentDir, entry.name)).href;
|
|
30756
30904
|
const moduleExports = await import(moduleUrl);
|
|
30757
30905
|
if (!moduleExports.provider) {
|
|
30758
30906
|
throw new Error(`Provider module "${entry.name}" must export "provider".`);
|
|
@@ -30768,8 +30916,8 @@ var moduleDir, currentDir, defaultProviders;
|
|
|
30768
30916
|
var init_providers = __esm({
|
|
30769
30917
|
async "src/providers/index.ts"() {
|
|
30770
30918
|
"use strict";
|
|
30771
|
-
moduleDir =
|
|
30772
|
-
currentDir =
|
|
30919
|
+
moduleDir = path37.dirname(fileURLToPath6(import.meta.url));
|
|
30920
|
+
currentDir = path37.basename(moduleDir) === "providers" ? moduleDir : path37.join(moduleDir, "providers");
|
|
30773
30921
|
defaultProviders = await loadProviders();
|
|
30774
30922
|
}
|
|
30775
30923
|
});
|
|
@@ -31346,25 +31494,25 @@ function createSdkContainer(options) {
|
|
|
31346
31494
|
});
|
|
31347
31495
|
loggerFactory.setErrorLogger(errorLogger);
|
|
31348
31496
|
const asyncFs = {
|
|
31349
|
-
readFile: ((
|
|
31497
|
+
readFile: ((path94, encoding) => {
|
|
31350
31498
|
if (encoding) {
|
|
31351
|
-
return fs4.readFile(
|
|
31499
|
+
return fs4.readFile(path94, encoding);
|
|
31352
31500
|
}
|
|
31353
|
-
return fs4.readFile(
|
|
31501
|
+
return fs4.readFile(path94);
|
|
31354
31502
|
}),
|
|
31355
|
-
symlink: (target,
|
|
31356
|
-
readlink: (
|
|
31357
|
-
writeFile: (
|
|
31358
|
-
mkdir: (
|
|
31503
|
+
symlink: (target, path94) => fs4.symlink(target, path94),
|
|
31504
|
+
readlink: (path94) => fs4.readlink(path94, { encoding: "utf8" }),
|
|
31505
|
+
writeFile: (path94, data, opts) => fs4.writeFile(path94, data, opts),
|
|
31506
|
+
mkdir: (path94, opts) => fs4.mkdir(path94, opts).then(() => {
|
|
31359
31507
|
}),
|
|
31360
|
-
stat: (
|
|
31361
|
-
lstat: (
|
|
31508
|
+
stat: (path94) => fs4.stat(path94),
|
|
31509
|
+
lstat: (path94) => fs4.lstat(path94),
|
|
31362
31510
|
rename: (oldPath, newPath) => fs4.rename(oldPath, newPath),
|
|
31363
|
-
rm: (
|
|
31364
|
-
unlink: (
|
|
31365
|
-
readdir: (
|
|
31511
|
+
rm: (path94, opts) => fs4.rm(path94, opts),
|
|
31512
|
+
unlink: (path94) => fs4.unlink(path94),
|
|
31513
|
+
readdir: (path94) => fs4.readdir(path94),
|
|
31366
31514
|
copyFile: (src, dest) => fs4.copyFile(src, dest),
|
|
31367
|
-
chmod: (
|
|
31515
|
+
chmod: (path94, mode) => fs4.chmod(path94, mode)
|
|
31368
31516
|
};
|
|
31369
31517
|
const contextFactory = createCommandContextFactory({ fs: asyncFs });
|
|
31370
31518
|
const authFs = {
|
|
@@ -31750,7 +31898,7 @@ var init_utils2 = __esm({
|
|
|
31750
31898
|
});
|
|
31751
31899
|
|
|
31752
31900
|
// packages/pipeline/src/config/loader.ts
|
|
31753
|
-
import
|
|
31901
|
+
import path38 from "node:path";
|
|
31754
31902
|
import { parse as parse6 } from "yaml";
|
|
31755
31903
|
function asStepMode(value) {
|
|
31756
31904
|
if (value === void 0 || value === null) {
|
|
@@ -31858,22 +32006,22 @@ async function directoryExists(fs19, targetPath) {
|
|
|
31858
32006
|
}
|
|
31859
32007
|
}
|
|
31860
32008
|
async function resolveStepsFile(options) {
|
|
31861
|
-
const projectFile =
|
|
32009
|
+
const projectFile = path38.join(options.cwd, ".poe-code", "pipeline", "steps.yaml");
|
|
31862
32010
|
if (await fileExists2(options.fs, projectFile)) {
|
|
31863
32011
|
return projectFile;
|
|
31864
32012
|
}
|
|
31865
|
-
const globalFile =
|
|
32013
|
+
const globalFile = path38.join(options.homeDir, ".poe-code", "pipeline", "steps.yaml");
|
|
31866
32014
|
if (await fileExists2(options.fs, globalFile)) {
|
|
31867
32015
|
return globalFile;
|
|
31868
32016
|
}
|
|
31869
32017
|
return null;
|
|
31870
32018
|
}
|
|
31871
32019
|
async function resolveStepsDirectory(options) {
|
|
31872
|
-
const projectDir =
|
|
32020
|
+
const projectDir = path38.join(options.cwd, ".poe-code", "pipeline", "steps");
|
|
31873
32021
|
if (await directoryExists(options.fs, projectDir)) {
|
|
31874
32022
|
return projectDir;
|
|
31875
32023
|
}
|
|
31876
|
-
const globalDir =
|
|
32024
|
+
const globalDir = path38.join(options.homeDir, ".poe-code", "pipeline", "steps");
|
|
31877
32025
|
if (await directoryExists(options.fs, globalDir)) {
|
|
31878
32026
|
return globalDir;
|
|
31879
32027
|
}
|
|
@@ -31897,9 +32045,9 @@ function parseConfigData(filePath, document) {
|
|
|
31897
32045
|
return config;
|
|
31898
32046
|
}
|
|
31899
32047
|
async function loadPipelineConfig(options) {
|
|
31900
|
-
const globalDir =
|
|
31901
|
-
const globalPath =
|
|
31902
|
-
const projectPath =
|
|
32048
|
+
const globalDir = path38.join(options.homeDir, ".poe-code", "pipeline");
|
|
32049
|
+
const globalPath = path38.join(globalDir, "config.yaml");
|
|
32050
|
+
const projectPath = path38.join(options.cwd, ".poe-code", "pipeline", "config.yaml");
|
|
31903
32051
|
const [globalContent, projectContent] = await Promise.all([
|
|
31904
32052
|
readOptionalFile2(options.fs, globalPath),
|
|
31905
32053
|
readOptionalFile2(options.fs, projectPath)
|
|
@@ -31936,7 +32084,7 @@ async function loadResolvedSteps(options) {
|
|
|
31936
32084
|
}
|
|
31937
32085
|
return applyStepOverrides({ steps: {} }, options.stepOverrides);
|
|
31938
32086
|
}
|
|
31939
|
-
const filePath =
|
|
32087
|
+
const filePath = path38.join(stepsDir, `${name}.yaml`);
|
|
31940
32088
|
const content = await readOptionalFile2(options.fs, filePath);
|
|
31941
32089
|
if (content == null) {
|
|
31942
32090
|
throw new Error(`Unknown pipeline step config "${name}" in "${stepsDir}".`);
|
|
@@ -32180,7 +32328,7 @@ var init_parser2 = __esm({
|
|
|
32180
32328
|
});
|
|
32181
32329
|
|
|
32182
32330
|
// packages/pipeline/src/plan/discovery.ts
|
|
32183
|
-
import
|
|
32331
|
+
import path39 from "node:path";
|
|
32184
32332
|
import * as fsPromises8 from "node:fs/promises";
|
|
32185
32333
|
import { parse as parseYaml3 } from "yaml";
|
|
32186
32334
|
function createDefaultFs4() {
|
|
@@ -32225,7 +32373,7 @@ function countCompletedTasks(planPath, content) {
|
|
|
32225
32373
|
};
|
|
32226
32374
|
}
|
|
32227
32375
|
async function ensurePlanExists(fs19, cwd, planPath) {
|
|
32228
|
-
const absolutePath =
|
|
32376
|
+
const absolutePath = path39.isAbsolute(planPath) ? planPath : path39.resolve(cwd, planPath);
|
|
32229
32377
|
try {
|
|
32230
32378
|
const stat24 = await fs19.stat(absolutePath);
|
|
32231
32379
|
if (!stat24.isFile()) {
|
|
@@ -32253,12 +32401,12 @@ async function scanPlansDir(fs19, plansDir, displayPrefix) {
|
|
|
32253
32401
|
if (!isMarkdownFile(entry)) {
|
|
32254
32402
|
continue;
|
|
32255
32403
|
}
|
|
32256
|
-
const absolutePath =
|
|
32404
|
+
const absolutePath = path39.join(plansDir, entry);
|
|
32257
32405
|
const stat24 = await fs19.stat(absolutePath);
|
|
32258
32406
|
if (!stat24.isFile()) {
|
|
32259
32407
|
continue;
|
|
32260
32408
|
}
|
|
32261
|
-
const displayPath2 =
|
|
32409
|
+
const displayPath2 = path39.join(displayPrefix, entry);
|
|
32262
32410
|
const content = await fs19.readFile(absolutePath, "utf8");
|
|
32263
32411
|
if (!isPipelinePlan(content)) {
|
|
32264
32412
|
continue;
|
|
@@ -32279,9 +32427,9 @@ async function scanCustomPlanDir(fs19, planDirectory, cwd, homeDir) {
|
|
|
32279
32427
|
}
|
|
32280
32428
|
function resolveAbsoluteDirectory3(dir, cwd, homeDir) {
|
|
32281
32429
|
if (dir.startsWith("~/")) {
|
|
32282
|
-
return
|
|
32430
|
+
return path39.join(homeDir, dir.slice(2));
|
|
32283
32431
|
}
|
|
32284
|
-
return
|
|
32432
|
+
return path39.isAbsolute(dir) ? dir : path39.resolve(cwd, dir);
|
|
32285
32433
|
}
|
|
32286
32434
|
function describeDiscoveryDirectory(planDirectory) {
|
|
32287
32435
|
const configured = planDirectory?.trim();
|
|
@@ -32293,9 +32441,9 @@ function resolvePlanDirectory2(options) {
|
|
|
32293
32441
|
}
|
|
32294
32442
|
function resolveAbsolutePlanPath(planPath, cwd, homeDir) {
|
|
32295
32443
|
if (planPath.startsWith("~/")) {
|
|
32296
|
-
return
|
|
32444
|
+
return path39.join(homeDir, planPath.slice(2));
|
|
32297
32445
|
}
|
|
32298
|
-
return
|
|
32446
|
+
return path39.isAbsolute(planPath) ? planPath : path39.resolve(cwd, planPath);
|
|
32299
32447
|
}
|
|
32300
32448
|
async function resolvePlanPath(options) {
|
|
32301
32449
|
const fs19 = options.fs ?? createDefaultFs4();
|
|
@@ -32357,7 +32505,7 @@ async function resolvePlanPaths(options) {
|
|
|
32357
32505
|
}
|
|
32358
32506
|
const selectedPath = await options.promptForPath({
|
|
32359
32507
|
message: "Enter the pipeline plan path",
|
|
32360
|
-
placeholder:
|
|
32508
|
+
placeholder: path39.join(describeDiscoveryDirectory(options.planDirectory), "plan.md")
|
|
32361
32509
|
});
|
|
32362
32510
|
return selectedPath ? [selectedPath] : null;
|
|
32363
32511
|
}
|
|
@@ -32549,7 +32697,7 @@ var init_interpolate = __esm({
|
|
|
32549
32697
|
});
|
|
32550
32698
|
|
|
32551
32699
|
// packages/pipeline/src/run/runner.ts
|
|
32552
|
-
import
|
|
32700
|
+
import path40 from "node:path";
|
|
32553
32701
|
function selectFromTask(task) {
|
|
32554
32702
|
if (typeof task.status === "string") {
|
|
32555
32703
|
return task.status === "done" ? { kind: "completed" } : { kind: "run", task };
|
|
@@ -32573,15 +32721,15 @@ function selectNextExecution(plan, taskId) {
|
|
|
32573
32721
|
function describeExecutionContext(selection) {
|
|
32574
32722
|
return selection.stepName ? `task "${selection.task.id}" step "${selection.stepName}"` : `task "${selection.task.id}"`;
|
|
32575
32723
|
}
|
|
32576
|
-
async function resolveFileIncludes(template, cwd,
|
|
32724
|
+
async function resolveFileIncludes(template, cwd, readFile38) {
|
|
32577
32725
|
const matches2 = [...template.matchAll(FILE_INCLUDE_PATTERN)];
|
|
32578
32726
|
if (matches2.length === 0) {
|
|
32579
32727
|
return template;
|
|
32580
32728
|
}
|
|
32581
32729
|
let result = template;
|
|
32582
32730
|
for (const match of matches2) {
|
|
32583
|
-
const absolutePath =
|
|
32584
|
-
const content = await
|
|
32731
|
+
const absolutePath = path40.resolve(cwd, match[1]);
|
|
32732
|
+
const content = await readFile38(absolutePath, "utf8");
|
|
32585
32733
|
result = result.replace(match[0], content);
|
|
32586
32734
|
}
|
|
32587
32735
|
return result;
|
|
@@ -32622,7 +32770,7 @@ var init_runner2 = __esm({
|
|
|
32622
32770
|
});
|
|
32623
32771
|
|
|
32624
32772
|
// packages/pipeline/src/vars/resolve.ts
|
|
32625
|
-
import
|
|
32773
|
+
import path41 from "node:path";
|
|
32626
32774
|
function looksLikeDocPath(value) {
|
|
32627
32775
|
const trimmed = value.trim();
|
|
32628
32776
|
if (trimmed.length === 0) return false;
|
|
@@ -32639,7 +32787,7 @@ function looksLikeDocPath(value) {
|
|
|
32639
32787
|
}
|
|
32640
32788
|
async function resolveDocVarFromPath(options) {
|
|
32641
32789
|
const trimmed = options.value.trim();
|
|
32642
|
-
const absolutePath =
|
|
32790
|
+
const absolutePath = path41.isAbsolute(trimmed) ? trimmed : path41.join(options.cwd, trimmed);
|
|
32643
32791
|
try {
|
|
32644
32792
|
return await options.readFile(absolutePath, "utf8");
|
|
32645
32793
|
} catch (error2) {
|
|
@@ -32649,15 +32797,15 @@ async function resolveDocVarFromPath(options) {
|
|
|
32649
32797
|
);
|
|
32650
32798
|
}
|
|
32651
32799
|
}
|
|
32652
|
-
async function resolvePipelineVars(vars, cwd,
|
|
32800
|
+
async function resolvePipelineVars(vars, cwd, readFile38) {
|
|
32653
32801
|
const resolved = {};
|
|
32654
32802
|
for (const [key2, value] of Object.entries(vars)) {
|
|
32655
32803
|
if (key2.endsWith("_doc") && looksLikeDocPath(value)) {
|
|
32656
|
-
const docContent = await resolveDocVarFromPath({ key: key2, value, cwd, readFile:
|
|
32657
|
-
resolved[key2] = await resolveFileIncludes(docContent, cwd,
|
|
32804
|
+
const docContent = await resolveDocVarFromPath({ key: key2, value, cwd, readFile: readFile38 });
|
|
32805
|
+
resolved[key2] = await resolveFileIncludes(docContent, cwd, readFile38);
|
|
32658
32806
|
continue;
|
|
32659
32807
|
}
|
|
32660
|
-
resolved[key2] = await resolveFileIncludes(value, cwd,
|
|
32808
|
+
resolved[key2] = await resolveFileIncludes(value, cwd, readFile38);
|
|
32661
32809
|
}
|
|
32662
32810
|
return resolved;
|
|
32663
32811
|
}
|
|
@@ -32708,7 +32856,7 @@ var init_validate = __esm({
|
|
|
32708
32856
|
});
|
|
32709
32857
|
|
|
32710
32858
|
// packages/pipeline/src/run/pipeline.ts
|
|
32711
|
-
import
|
|
32859
|
+
import path42 from "node:path";
|
|
32712
32860
|
import * as fsPromises9 from "node:fs/promises";
|
|
32713
32861
|
function createDefaultFs5() {
|
|
32714
32862
|
const fs19 = {
|
|
@@ -32793,9 +32941,9 @@ function resolveMode2(stepName, steps) {
|
|
|
32793
32941
|
return step.mode;
|
|
32794
32942
|
}
|
|
32795
32943
|
async function archivePlan(fs19, absolutePlanPath) {
|
|
32796
|
-
const dir =
|
|
32797
|
-
const archiveDir =
|
|
32798
|
-
const archivePath =
|
|
32944
|
+
const dir = path42.dirname(absolutePlanPath);
|
|
32945
|
+
const archiveDir = path42.join(dir, "archive");
|
|
32946
|
+
const archivePath = path42.join(archiveDir, path42.basename(absolutePlanPath));
|
|
32799
32947
|
await fs19.mkdir(archiveDir, { recursive: true });
|
|
32800
32948
|
await fs19.rename(absolutePlanPath, archivePath);
|
|
32801
32949
|
}
|
|
@@ -33498,9 +33646,9 @@ var init_git = __esm({
|
|
|
33498
33646
|
});
|
|
33499
33647
|
|
|
33500
33648
|
// packages/experiment-loop/src/config/loader.ts
|
|
33501
|
-
import
|
|
33502
|
-
import { readFile as
|
|
33503
|
-
import { fileURLToPath as
|
|
33649
|
+
import path43 from "node:path";
|
|
33650
|
+
import { readFile as readFile11 } from "node:fs/promises";
|
|
33651
|
+
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
33504
33652
|
import { parse as parse8 } from "yaml";
|
|
33505
33653
|
function isRecord13(value) {
|
|
33506
33654
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -33543,8 +33691,8 @@ function parseRunConfigDocument(filePath, content) {
|
|
|
33543
33691
|
return parseRunConfigData(filePath, parseRunConfigYaml(filePath, content));
|
|
33544
33692
|
}
|
|
33545
33693
|
async function readBundledFile(name) {
|
|
33546
|
-
const filePath =
|
|
33547
|
-
return
|
|
33694
|
+
const filePath = fileURLToPath7(new URL(`./${name}`, import.meta.url));
|
|
33695
|
+
return readFile11(filePath, "utf8");
|
|
33548
33696
|
}
|
|
33549
33697
|
async function readDefaultRunConfig() {
|
|
33550
33698
|
const content = await readBundledFile("default-run.yaml");
|
|
@@ -33555,7 +33703,7 @@ async function readDefaultRunConfig() {
|
|
|
33555
33703
|
return config;
|
|
33556
33704
|
}
|
|
33557
33705
|
function createRunConfigResolveFs(fs19) {
|
|
33558
|
-
const bundledRunPath =
|
|
33706
|
+
const bundledRunPath = fileURLToPath7(new URL("./run.yaml", import.meta.url));
|
|
33559
33707
|
return {
|
|
33560
33708
|
async readFile(filePath, encoding) {
|
|
33561
33709
|
if (filePath === bundledRunPath) {
|
|
@@ -33569,7 +33717,7 @@ async function loadInstructions() {
|
|
|
33569
33717
|
return readBundledFile("default-instructions.md");
|
|
33570
33718
|
}
|
|
33571
33719
|
async function loadRunConfig(options) {
|
|
33572
|
-
const projectPath =
|
|
33720
|
+
const projectPath = path43.join(options.cwd, ".poe-code", "experiments", "run.yaml");
|
|
33573
33721
|
const projectContent = await readOptionalFile3(options.fs, projectPath);
|
|
33574
33722
|
if (projectContent == null) {
|
|
33575
33723
|
return readDefaultRunConfig();
|
|
@@ -33578,8 +33726,8 @@ async function loadRunConfig(options) {
|
|
|
33578
33726
|
if (projectDocument === null || projectDocument === void 0) {
|
|
33579
33727
|
return readDefaultRunConfig();
|
|
33580
33728
|
}
|
|
33581
|
-
const bundledConfigDir =
|
|
33582
|
-
const globalConfigDir =
|
|
33729
|
+
const bundledConfigDir = path43.resolve(fileURLToPath7(new URL(".", import.meta.url)));
|
|
33730
|
+
const globalConfigDir = path43.resolve(path43.join(options.homeDir, ".poe-code", "experiments"));
|
|
33583
33731
|
const resolved = await resolve(
|
|
33584
33732
|
[
|
|
33585
33733
|
{ source: "document", filePath: projectPath, content: projectContent },
|
|
@@ -33602,7 +33750,7 @@ var init_loader2 = __esm({
|
|
|
33602
33750
|
});
|
|
33603
33751
|
|
|
33604
33752
|
// packages/experiment-loop/src/discovery/discovery.ts
|
|
33605
|
-
import
|
|
33753
|
+
import path44 from "node:path";
|
|
33606
33754
|
import * as fsPromises10 from "node:fs/promises";
|
|
33607
33755
|
function createDefaultFs6() {
|
|
33608
33756
|
return {
|
|
@@ -33636,12 +33784,12 @@ async function scanDir(fs19, absoluteDir, displayDir) {
|
|
|
33636
33784
|
if (!isMarkdownFile2(entry)) {
|
|
33637
33785
|
continue;
|
|
33638
33786
|
}
|
|
33639
|
-
const absolutePath =
|
|
33787
|
+
const absolutePath = path44.join(absoluteDir, entry);
|
|
33640
33788
|
const stat24 = await fs19.stat(absolutePath);
|
|
33641
33789
|
if (!stat24.isFile()) {
|
|
33642
33790
|
continue;
|
|
33643
33791
|
}
|
|
33644
|
-
const displayPath2 =
|
|
33792
|
+
const displayPath2 = path44.join(displayDir, entry);
|
|
33645
33793
|
docs.push({
|
|
33646
33794
|
path: displayPath2,
|
|
33647
33795
|
displayPath: displayPath2
|
|
@@ -33650,18 +33798,18 @@ async function scanDir(fs19, absoluteDir, displayDir) {
|
|
|
33650
33798
|
return docs;
|
|
33651
33799
|
}
|
|
33652
33800
|
function toDisplayPath(options) {
|
|
33653
|
-
const localDir =
|
|
33654
|
-
const globalDir =
|
|
33655
|
-
if (options.absolutePath.startsWith(`${localDir}${
|
|
33656
|
-
return
|
|
33801
|
+
const localDir = path44.join(options.cwd, ".poe-code", "experiments");
|
|
33802
|
+
const globalDir = path44.join(options.homeDir, ".poe-code", "experiments");
|
|
33803
|
+
if (options.absolutePath.startsWith(`${localDir}${path44.sep}`)) {
|
|
33804
|
+
return path44.join(
|
|
33657
33805
|
".poe-code/experiments",
|
|
33658
|
-
|
|
33806
|
+
path44.relative(localDir, options.absolutePath)
|
|
33659
33807
|
);
|
|
33660
33808
|
}
|
|
33661
|
-
if (options.absolutePath.startsWith(`${globalDir}${
|
|
33662
|
-
return
|
|
33809
|
+
if (options.absolutePath.startsWith(`${globalDir}${path44.sep}`)) {
|
|
33810
|
+
return path44.join(
|
|
33663
33811
|
"~/.poe-code/experiments",
|
|
33664
|
-
|
|
33812
|
+
path44.relative(globalDir, options.absolutePath)
|
|
33665
33813
|
);
|
|
33666
33814
|
}
|
|
33667
33815
|
return options.absolutePath;
|
|
@@ -33694,8 +33842,8 @@ async function discoverExperimentDocs(options) {
|
|
|
33694
33842
|
const customDir = options.planDirectory?.trim();
|
|
33695
33843
|
const docs = customDir ? await scanCustomDir(fs19, customDir, options.cwd, options.homeDir) : await scanDefaultDirs(fs19, options.cwd, options.homeDir);
|
|
33696
33844
|
return docs.sort((left, right) => {
|
|
33697
|
-
const leftName =
|
|
33698
|
-
const rightName =
|
|
33845
|
+
const leftName = path44.basename(left.displayPath).toLowerCase();
|
|
33846
|
+
const rightName = path44.basename(right.displayPath).toLowerCase();
|
|
33699
33847
|
return leftName === rightName ? left.displayPath.localeCompare(right.displayPath) : leftName.localeCompare(rightName);
|
|
33700
33848
|
});
|
|
33701
33849
|
}
|
|
@@ -33709,7 +33857,7 @@ var init_discovery2 = __esm({
|
|
|
33709
33857
|
// packages/experiment-loop/src/run/loop.ts
|
|
33710
33858
|
import { exec as execCallback } from "node:child_process";
|
|
33711
33859
|
import * as fsPromises11 from "node:fs/promises";
|
|
33712
|
-
import
|
|
33860
|
+
import path45 from "node:path";
|
|
33713
33861
|
function createDefaultFs7() {
|
|
33714
33862
|
const fs19 = {
|
|
33715
33863
|
readFile: fsPromises11.readFile,
|
|
@@ -33761,9 +33909,9 @@ function createDefaultExec() {
|
|
|
33761
33909
|
});
|
|
33762
33910
|
}
|
|
33763
33911
|
function resolveJournalPath(docPath) {
|
|
33764
|
-
return
|
|
33765
|
-
|
|
33766
|
-
`${
|
|
33912
|
+
return path45.join(
|
|
33913
|
+
path45.dirname(docPath),
|
|
33914
|
+
`${path45.basename(docPath, path45.extname(docPath))}.journal.jsonl`
|
|
33767
33915
|
);
|
|
33768
33916
|
}
|
|
33769
33917
|
function normalizeMetrics(metric) {
|
|
@@ -33897,8 +34045,8 @@ async function runExperimentLoop(options) {
|
|
|
33897
34045
|
[
|
|
33898
34046
|
{ source: "cli", data: { agent: options.agent } },
|
|
33899
34047
|
{ source: "document", filePath: absoluteDocPath, content: rawContent },
|
|
33900
|
-
{ source: "base", path:
|
|
33901
|
-
{ source: "base", path:
|
|
34048
|
+
{ source: "base", path: path45.join(options.cwd, ".poe-code/experiments/bases") },
|
|
34049
|
+
{ source: "base", path: path45.join(options.homeDir, ".poe-code/experiments/bases") },
|
|
33902
34050
|
{ source: "defaults", data: { agent: "claude-code" } }
|
|
33903
34051
|
],
|
|
33904
34052
|
{ fs: fs19 }
|
|
@@ -33980,7 +34128,7 @@ async function runExperimentLoop(options) {
|
|
|
33980
34128
|
experimentIndex,
|
|
33981
34129
|
baseline,
|
|
33982
34130
|
docPath: options.docPath,
|
|
33983
|
-
docName:
|
|
34131
|
+
docName: path45.basename(absoluteDocPath, path45.extname(absoluteDocPath))
|
|
33984
34132
|
});
|
|
33985
34133
|
const currentSpecifier = agents[(experimentIndex - 1) % agents.length];
|
|
33986
34134
|
const model = currentSpecifier.model;
|
|
@@ -34213,7 +34361,7 @@ var init_frontmatter3 = __esm({
|
|
|
34213
34361
|
});
|
|
34214
34362
|
|
|
34215
34363
|
// packages/ralph/src/discovery/discovery.ts
|
|
34216
|
-
import
|
|
34364
|
+
import path46 from "node:path";
|
|
34217
34365
|
import * as fsPromises12 from "node:fs/promises";
|
|
34218
34366
|
function createDefaultFs8() {
|
|
34219
34367
|
return {
|
|
@@ -34249,12 +34397,12 @@ async function scanDir2(fs19, absoluteDir, displayDir) {
|
|
|
34249
34397
|
if (!isMarkdownFile3(entry)) {
|
|
34250
34398
|
continue;
|
|
34251
34399
|
}
|
|
34252
|
-
const absolutePath =
|
|
34400
|
+
const absolutePath = path46.join(absoluteDir, entry);
|
|
34253
34401
|
const stat24 = await fs19.stat(absolutePath);
|
|
34254
34402
|
if (!stat24.isFile()) {
|
|
34255
34403
|
continue;
|
|
34256
34404
|
}
|
|
34257
|
-
const displayPath2 =
|
|
34405
|
+
const displayPath2 = path46.join(displayDir, entry);
|
|
34258
34406
|
docs.push({
|
|
34259
34407
|
path: displayPath2,
|
|
34260
34408
|
displayPath: displayPath2
|
|
@@ -34263,18 +34411,18 @@ async function scanDir2(fs19, absoluteDir, displayDir) {
|
|
|
34263
34411
|
return docs;
|
|
34264
34412
|
}
|
|
34265
34413
|
function toDisplayPath2(options) {
|
|
34266
|
-
const localDir =
|
|
34267
|
-
const globalDir =
|
|
34268
|
-
if (options.absolutePath.startsWith(`${localDir}${
|
|
34269
|
-
return
|
|
34414
|
+
const localDir = path46.join(options.cwd, ".poe-code", "ralph", "plans");
|
|
34415
|
+
const globalDir = path46.join(options.homeDir, ".poe-code", "ralph", "plans");
|
|
34416
|
+
if (options.absolutePath.startsWith(`${localDir}${path46.sep}`)) {
|
|
34417
|
+
return path46.join(
|
|
34270
34418
|
".poe-code/ralph/plans",
|
|
34271
|
-
|
|
34419
|
+
path46.relative(localDir, options.absolutePath)
|
|
34272
34420
|
);
|
|
34273
34421
|
}
|
|
34274
|
-
if (options.absolutePath.startsWith(`${globalDir}${
|
|
34275
|
-
return
|
|
34422
|
+
if (options.absolutePath.startsWith(`${globalDir}${path46.sep}`)) {
|
|
34423
|
+
return path46.join(
|
|
34276
34424
|
"~/.poe-code/ralph/plans",
|
|
34277
|
-
|
|
34425
|
+
path46.relative(globalDir, options.absolutePath)
|
|
34278
34426
|
);
|
|
34279
34427
|
}
|
|
34280
34428
|
return options.absolutePath;
|
|
@@ -34307,8 +34455,8 @@ async function discoverDocs(options) {
|
|
|
34307
34455
|
const customDir = options.planDirectory?.trim();
|
|
34308
34456
|
const docs = customDir ? await scanCustomDir2(fs19, customDir, options.cwd, options.homeDir) : await scanDefaultDirs2(fs19, options.cwd, options.homeDir);
|
|
34309
34457
|
return docs.sort((left, right) => {
|
|
34310
|
-
const leftName =
|
|
34311
|
-
const rightName =
|
|
34458
|
+
const leftName = path46.basename(left.displayPath).toLowerCase();
|
|
34459
|
+
const rightName = path46.basename(right.displayPath).toLowerCase();
|
|
34312
34460
|
return leftName === rightName ? left.displayPath.localeCompare(right.displayPath) : leftName.localeCompare(rightName);
|
|
34313
34461
|
});
|
|
34314
34462
|
}
|
|
@@ -34332,7 +34480,7 @@ var init_variables = __esm({
|
|
|
34332
34480
|
});
|
|
34333
34481
|
|
|
34334
34482
|
// packages/ralph/src/run/ralph.ts
|
|
34335
|
-
import
|
|
34483
|
+
import path47 from "node:path";
|
|
34336
34484
|
import * as fsPromises13 from "node:fs/promises";
|
|
34337
34485
|
async function runRalph(options) {
|
|
34338
34486
|
const fs19 = options.fs ?? createDefaultFs9();
|
|
@@ -34536,11 +34684,11 @@ async function resolveDocumentConfigFromContent(options, fs19, absoluteDocPath,
|
|
|
34536
34684
|
},
|
|
34537
34685
|
{
|
|
34538
34686
|
source: "base",
|
|
34539
|
-
path:
|
|
34687
|
+
path: path47.join(options.cwd, ".poe-code/ralph/bases")
|
|
34540
34688
|
},
|
|
34541
34689
|
{
|
|
34542
34690
|
source: "base",
|
|
34543
|
-
path:
|
|
34691
|
+
path: path47.join(options.homeDir, ".poe-code/ralph/bases")
|
|
34544
34692
|
},
|
|
34545
34693
|
{
|
|
34546
34694
|
source: "defaults",
|
|
@@ -34680,9 +34828,9 @@ async function updateFrontmatter2(fs19, absoluteDocPath, state, iteration) {
|
|
|
34680
34828
|
await fs19.writeFile(absoluteDocPath, content);
|
|
34681
34829
|
}
|
|
34682
34830
|
async function archivePlan2(fs19, absoluteDocPath) {
|
|
34683
|
-
const dir =
|
|
34684
|
-
const archiveDir =
|
|
34685
|
-
const archivePath =
|
|
34831
|
+
const dir = path47.dirname(absoluteDocPath);
|
|
34832
|
+
const archiveDir = path47.join(dir, "archive");
|
|
34833
|
+
const archivePath = path47.join(archiveDir, path47.basename(absoluteDocPath));
|
|
34686
34834
|
await fs19.mkdir(archiveDir, { recursive: true });
|
|
34687
34835
|
await fs19.rename(absoluteDocPath, archivePath);
|
|
34688
34836
|
}
|
|
@@ -34717,7 +34865,7 @@ var init_src23 = __esm({
|
|
|
34717
34865
|
});
|
|
34718
34866
|
|
|
34719
34867
|
// packages/plan-browser/src/format.ts
|
|
34720
|
-
import
|
|
34868
|
+
import path48 from "node:path";
|
|
34721
34869
|
import { parseDocument as parseDocument5 } from "yaml";
|
|
34722
34870
|
function isPipelineTaskDone(task) {
|
|
34723
34871
|
if (typeof task.status === "string") {
|
|
@@ -34888,9 +35036,9 @@ function formatPipelinePlanMarkdown(options) {
|
|
|
34888
35036
|
return lines.join("\n").trimEnd();
|
|
34889
35037
|
}
|
|
34890
35038
|
function resolveExperimentJournalPath(absolutePath) {
|
|
34891
|
-
return
|
|
34892
|
-
|
|
34893
|
-
`${
|
|
35039
|
+
return path48.join(
|
|
35040
|
+
path48.dirname(absolutePath),
|
|
35041
|
+
`${path48.basename(absolutePath, path48.extname(absolutePath))}.journal.jsonl`
|
|
34894
35042
|
);
|
|
34895
35043
|
}
|
|
34896
35044
|
async function readExperimentState(fs19, absolutePath) {
|
|
@@ -34920,7 +35068,7 @@ function resolveFormatFromPath(filePath) {
|
|
|
34920
35068
|
}
|
|
34921
35069
|
async function readPlanMetadata(options) {
|
|
34922
35070
|
const content = await options.fs.readFile(options.absolutePath, "utf8");
|
|
34923
|
-
const fallbackName =
|
|
35071
|
+
const fallbackName = path48.basename(options.path);
|
|
34924
35072
|
if (options.kind === "pipeline") {
|
|
34925
35073
|
return {
|
|
34926
35074
|
title: fallbackName,
|
|
@@ -34981,7 +35129,7 @@ var init_format = __esm({
|
|
|
34981
35129
|
});
|
|
34982
35130
|
|
|
34983
35131
|
// packages/plan-browser/src/discovery.ts
|
|
34984
|
-
import
|
|
35132
|
+
import path49 from "node:path";
|
|
34985
35133
|
import * as fsPromises14 from "node:fs/promises";
|
|
34986
35134
|
function createDefaultFs10() {
|
|
34987
35135
|
return {
|
|
@@ -35008,9 +35156,9 @@ function isNotFound5(error2) {
|
|
|
35008
35156
|
}
|
|
35009
35157
|
function resolveAbsoluteDirectory4(dir, cwd, homeDir) {
|
|
35010
35158
|
if (dir.startsWith("~/")) {
|
|
35011
|
-
return
|
|
35159
|
+
return path49.join(homeDir, dir.slice(2));
|
|
35012
35160
|
}
|
|
35013
|
-
return
|
|
35161
|
+
return path49.isAbsolute(dir) ? dir : path49.resolve(cwd, dir);
|
|
35014
35162
|
}
|
|
35015
35163
|
function isMarkdownFile4(name) {
|
|
35016
35164
|
return name.toLowerCase().endsWith(".md");
|
|
@@ -35087,12 +35235,12 @@ async function discoverSharedPlans(options) {
|
|
|
35087
35235
|
if (!isMarkdownFile4(name)) {
|
|
35088
35236
|
continue;
|
|
35089
35237
|
}
|
|
35090
|
-
const absolutePath =
|
|
35238
|
+
const absolutePath = path49.join(absoluteDir, name);
|
|
35091
35239
|
const stat24 = await options.fs.stat(absolutePath);
|
|
35092
35240
|
if (!stat24.isFile()) {
|
|
35093
35241
|
continue;
|
|
35094
35242
|
}
|
|
35095
|
-
const displayPath2 =
|
|
35243
|
+
const displayPath2 = path49.join(displayDir, name);
|
|
35096
35244
|
const content = await options.fs.readFile(absolutePath, "utf8");
|
|
35097
35245
|
const kind = classifyPlanKind(content, displayPath2);
|
|
35098
35246
|
if (options.kind && kind !== options.kind) {
|
|
@@ -35137,7 +35285,7 @@ var init_discovery4 = __esm({
|
|
|
35137
35285
|
});
|
|
35138
35286
|
|
|
35139
35287
|
// packages/plan-browser/src/actions.ts
|
|
35140
|
-
import
|
|
35288
|
+
import path50 from "node:path";
|
|
35141
35289
|
import { spawnSync as nodeSpawnSync2 } from "node:child_process";
|
|
35142
35290
|
function resolveEditor2(env = process.env) {
|
|
35143
35291
|
const editor = env.EDITOR?.trim() || env.VISUAL?.trim() || "vi";
|
|
@@ -35149,8 +35297,8 @@ function editPlan2(absolutePath, options = {}) {
|
|
|
35149
35297
|
spawnSync3(editor, [absolutePath], { stdio: "inherit" });
|
|
35150
35298
|
}
|
|
35151
35299
|
async function archivePlan3(entry, fs19) {
|
|
35152
|
-
const archiveDir =
|
|
35153
|
-
const archivedPath =
|
|
35300
|
+
const archiveDir = path50.join(path50.dirname(entry.absolutePath), "archive");
|
|
35301
|
+
const archivedPath = path50.join(archiveDir, path50.basename(entry.absolutePath));
|
|
35154
35302
|
await fs19.mkdir(archiveDir, { recursive: true });
|
|
35155
35303
|
await fs19.rename(entry.absolutePath, archivedPath);
|
|
35156
35304
|
return archivedPath;
|
|
@@ -35165,7 +35313,7 @@ var init_actions = __esm({
|
|
|
35165
35313
|
});
|
|
35166
35314
|
|
|
35167
35315
|
// packages/plan-browser/src/browser.ts
|
|
35168
|
-
import
|
|
35316
|
+
import path51 from "node:path";
|
|
35169
35317
|
async function runPlanBrowser(options) {
|
|
35170
35318
|
const renderPlanPreview = async (entry) => {
|
|
35171
35319
|
const markdown = await loadPlanPreviewMarkdown(entry, options.fs);
|
|
@@ -35194,7 +35342,7 @@ async function runPlanBrowser(options) {
|
|
|
35194
35342
|
const selectedPath = await select2({
|
|
35195
35343
|
message: "Select a plan",
|
|
35196
35344
|
options: plans.map((plan) => ({
|
|
35197
|
-
label: text.selectLabel(
|
|
35345
|
+
label: text.selectLabel(path51.basename(plan.path), plan.detail),
|
|
35198
35346
|
hint: plan.typeLabel,
|
|
35199
35347
|
value: plan.absolutePath
|
|
35200
35348
|
}))
|
|
@@ -35230,7 +35378,7 @@ async function runPlanBrowser(options) {
|
|
|
35230
35378
|
if (action === "archive") {
|
|
35231
35379
|
try {
|
|
35232
35380
|
const confirmed = options.assumeYes || await confirmOrCancel({
|
|
35233
|
-
message: `Archive ${
|
|
35381
|
+
message: `Archive ${path51.basename(selectedPlan.path)}?`,
|
|
35234
35382
|
initialValue: true
|
|
35235
35383
|
});
|
|
35236
35384
|
if (confirmed) {
|
|
@@ -35245,7 +35393,7 @@ async function runPlanBrowser(options) {
|
|
|
35245
35393
|
}
|
|
35246
35394
|
try {
|
|
35247
35395
|
const confirmed = options.assumeYes || await confirmOrCancel({
|
|
35248
|
-
message: `Permanently delete ${
|
|
35396
|
+
message: `Permanently delete ${path51.basename(selectedPlan.path)}?`,
|
|
35249
35397
|
initialValue: true
|
|
35250
35398
|
});
|
|
35251
35399
|
if (confirmed) {
|
|
@@ -35390,7 +35538,7 @@ var init_scan = __esm({
|
|
|
35390
35538
|
|
|
35391
35539
|
// packages/markdown-reader/src/core/document.ts
|
|
35392
35540
|
import nodeFs2 from "node:fs/promises";
|
|
35393
|
-
import
|
|
35541
|
+
import path52 from "node:path";
|
|
35394
35542
|
import { parseDocument as parseDocument6 } from "yaml";
|
|
35395
35543
|
async function loadMarkdownDocument(file, dependencies = {}) {
|
|
35396
35544
|
const resolvedFile = resolveMarkdownPath(file, dependencies.cwd);
|
|
@@ -35405,7 +35553,7 @@ async function loadMarkdownDocument(file, dependencies = {}) {
|
|
|
35405
35553
|
};
|
|
35406
35554
|
}
|
|
35407
35555
|
function resolveMarkdownPath(file, cwd = process.cwd()) {
|
|
35408
|
-
return
|
|
35556
|
+
return path52.isAbsolute(file) ? file : path52.resolve(cwd, file);
|
|
35409
35557
|
}
|
|
35410
35558
|
function sliceMarkdownBytes(source, start, end) {
|
|
35411
35559
|
return Buffer.from(source, "utf8").subarray(start, end).toString("utf8");
|
|
@@ -36580,7 +36728,7 @@ var init_state = __esm({
|
|
|
36580
36728
|
});
|
|
36581
36729
|
|
|
36582
36730
|
// packages/task-list/src/backends/utils.ts
|
|
36583
|
-
import
|
|
36731
|
+
import path53 from "node:path";
|
|
36584
36732
|
function hasErrorCode2(error2, code) {
|
|
36585
36733
|
return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
36586
36734
|
}
|
|
@@ -36612,7 +36760,7 @@ async function statIfExists(fs19, filePath) {
|
|
|
36612
36760
|
async function writeAtomically(fs19, filePath, content) {
|
|
36613
36761
|
const tempPath = `${filePath}.tmp-${process.pid}-${tmpFileCounter}`;
|
|
36614
36762
|
tmpFileCounter += 1;
|
|
36615
|
-
await fs19.mkdir(
|
|
36763
|
+
await fs19.mkdir(path53.dirname(filePath), { recursive: true });
|
|
36616
36764
|
try {
|
|
36617
36765
|
await fs19.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
|
|
36618
36766
|
await fs19.rename(tempPath, filePath);
|
|
@@ -36636,7 +36784,7 @@ var init_utils3 = __esm({
|
|
|
36636
36784
|
});
|
|
36637
36785
|
|
|
36638
36786
|
// packages/task-list/src/backends/markdown-dir.ts
|
|
36639
|
-
import
|
|
36787
|
+
import path54 from "node:path";
|
|
36640
36788
|
import { parseDocument as parseDocument7, stringify as stringify3 } from "yaml";
|
|
36641
36789
|
function validateListName(name) {
|
|
36642
36790
|
if (name.length === 0 || name === ARCHIVE_DIRECTORY_NAME || name.startsWith(".") || name.includes("/") || name.includes("\\") || name.includes("..")) {
|
|
@@ -36655,16 +36803,16 @@ function parseQualifiedId(qualifiedId) {
|
|
|
36655
36803
|
};
|
|
36656
36804
|
}
|
|
36657
36805
|
function listPath(rootPath, list) {
|
|
36658
|
-
return
|
|
36806
|
+
return path54.join(rootPath, list);
|
|
36659
36807
|
}
|
|
36660
36808
|
function archiveDirectoryPath(rootPath, list) {
|
|
36661
|
-
return
|
|
36809
|
+
return path54.join(listPath(rootPath, list), ARCHIVE_DIRECTORY_NAME);
|
|
36662
36810
|
}
|
|
36663
36811
|
function activeTaskPath(rootPath, list, id) {
|
|
36664
|
-
return
|
|
36812
|
+
return path54.join(listPath(rootPath, list), `${id}${MARKDOWN_EXTENSION}`);
|
|
36665
36813
|
}
|
|
36666
36814
|
function archivedTaskPath(rootPath, list, id) {
|
|
36667
|
-
return
|
|
36815
|
+
return path54.join(archiveDirectoryPath(rootPath, list), `${id}${MARKDOWN_EXTENSION}`);
|
|
36668
36816
|
}
|
|
36669
36817
|
function isMarkdownFile5(entryName) {
|
|
36670
36818
|
return entryName.endsWith(MARKDOWN_EXTENSION);
|
|
@@ -36896,7 +37044,7 @@ function createTasksView(deps, list) {
|
|
|
36896
37044
|
if (isHiddenEntry(entryName) || isLockFile(entryName) || !isMarkdownFile5(entryName)) {
|
|
36897
37045
|
continue;
|
|
36898
37046
|
}
|
|
36899
|
-
const entryPath =
|
|
37047
|
+
const entryPath = path54.join(directoryPath, entryName);
|
|
36900
37048
|
const entryStat = await statIfExists(deps.fs, entryPath);
|
|
36901
37049
|
if (!entryStat?.isFile()) {
|
|
36902
37050
|
continue;
|
|
@@ -37051,7 +37199,7 @@ async function markdownDirBackend(deps) {
|
|
|
37051
37199
|
if (entryName === ARCHIVE_DIRECTORY_NAME || isHiddenEntry(entryName) || isLockFile(entryName)) {
|
|
37052
37200
|
continue;
|
|
37053
37201
|
}
|
|
37054
|
-
const entryPath =
|
|
37202
|
+
const entryPath = path54.join(deps.path, entryName);
|
|
37055
37203
|
const entryStat = await statIfExists(deps.fs, entryPath);
|
|
37056
37204
|
if (entryStat?.isDirectory()) {
|
|
37057
37205
|
result.push(entryName);
|
|
@@ -38058,7 +38206,7 @@ var init_gate = __esm({
|
|
|
38058
38206
|
});
|
|
38059
38207
|
|
|
38060
38208
|
// packages/toolcraft/src/human-in-loop/runner.ts
|
|
38061
|
-
import { access, readFile as
|
|
38209
|
+
import { access, readFile as readFile15, writeFile as writeFile10 } from "node:fs/promises";
|
|
38062
38210
|
async function runApproval(approvalId, runtimeOptions, root) {
|
|
38063
38211
|
const { tasks } = await ensureApprovalList(runtimeOptions);
|
|
38064
38212
|
const task = await tasks.get(approvalId);
|
|
@@ -38178,13 +38326,13 @@ function createHandlerContext(command, params) {
|
|
|
38178
38326
|
}
|
|
38179
38327
|
function createFs() {
|
|
38180
38328
|
return {
|
|
38181
|
-
readFile: async (
|
|
38182
|
-
writeFile: async (
|
|
38183
|
-
await writeFile10(
|
|
38329
|
+
readFile: async (path94, encoding = "utf8") => readFile15(path94, { encoding }),
|
|
38330
|
+
writeFile: async (path94, contents) => {
|
|
38331
|
+
await writeFile10(path94, contents);
|
|
38184
38332
|
},
|
|
38185
|
-
exists: async (
|
|
38333
|
+
exists: async (path94) => {
|
|
38186
38334
|
try {
|
|
38187
|
-
await access(
|
|
38335
|
+
await access(path94);
|
|
38188
38336
|
return true;
|
|
38189
38337
|
} catch {
|
|
38190
38338
|
return false;
|
|
@@ -38790,9 +38938,9 @@ function mergeJsonSchemas(base, overlay) {
|
|
|
38790
38938
|
...mergedRequired === void 0 ? {} : { required: mergedRequired }
|
|
38791
38939
|
};
|
|
38792
38940
|
}
|
|
38793
|
-
function hasSelfReferencingRef(schema, root,
|
|
38941
|
+
function hasSelfReferencingRef(schema, root, path94 = "#", activePaths = /* @__PURE__ */ new Set()) {
|
|
38794
38942
|
const nextActivePaths = new Set(activePaths);
|
|
38795
|
-
nextActivePaths.add(
|
|
38943
|
+
nextActivePaths.add(path94);
|
|
38796
38944
|
const localRefPath = getLocalRefPath(schema.$ref);
|
|
38797
38945
|
if (localRefPath !== void 0) {
|
|
38798
38946
|
if (nextActivePaths.has(localRefPath)) {
|
|
@@ -38803,13 +38951,13 @@ function hasSelfReferencingRef(schema, root, path93 = "#", activePaths = /* @__P
|
|
|
38803
38951
|
return true;
|
|
38804
38952
|
}
|
|
38805
38953
|
}
|
|
38806
|
-
if (schema.items !== void 0 && hasSelfReferencingRef(schema.items, root, `${
|
|
38954
|
+
if (schema.items !== void 0 && hasSelfReferencingRef(schema.items, root, `${path94}/items`, nextActivePaths)) {
|
|
38807
38955
|
return true;
|
|
38808
38956
|
}
|
|
38809
38957
|
if (typeof schema.additionalProperties === "object" && schema.additionalProperties !== null && hasSelfReferencingRef(
|
|
38810
38958
|
schema.additionalProperties,
|
|
38811
38959
|
root,
|
|
38812
|
-
`${
|
|
38960
|
+
`${path94}/additionalProperties`,
|
|
38813
38961
|
nextActivePaths
|
|
38814
38962
|
)) {
|
|
38815
38963
|
return true;
|
|
@@ -38818,7 +38966,7 @@ function hasSelfReferencingRef(schema, root, path93 = "#", activePaths = /* @__P
|
|
|
38818
38966
|
if (hasSelfReferencingRef(
|
|
38819
38967
|
childSchema,
|
|
38820
38968
|
root,
|
|
38821
|
-
`${
|
|
38969
|
+
`${path94}/properties/${escapeJsonPointerSegment(key2)}`,
|
|
38822
38970
|
nextActivePaths
|
|
38823
38971
|
)) {
|
|
38824
38972
|
return true;
|
|
@@ -38828,19 +38976,19 @@ function hasSelfReferencingRef(schema, root, path93 = "#", activePaths = /* @__P
|
|
|
38828
38976
|
if (hasSelfReferencingRef(
|
|
38829
38977
|
childSchema,
|
|
38830
38978
|
root,
|
|
38831
|
-
`${
|
|
38979
|
+
`${path94}/$defs/${escapeJsonPointerSegment(key2)}`,
|
|
38832
38980
|
nextActivePaths
|
|
38833
38981
|
)) {
|
|
38834
38982
|
return true;
|
|
38835
38983
|
}
|
|
38836
38984
|
}
|
|
38837
38985
|
for (const [index, childSchema] of (schema.oneOf ?? []).entries()) {
|
|
38838
|
-
if (hasSelfReferencingRef(childSchema, root, `${
|
|
38986
|
+
if (hasSelfReferencingRef(childSchema, root, `${path94}/oneOf/${index}`, nextActivePaths)) {
|
|
38839
38987
|
return true;
|
|
38840
38988
|
}
|
|
38841
38989
|
}
|
|
38842
38990
|
for (const [index, childSchema] of (schema.anyOf ?? []).entries()) {
|
|
38843
|
-
if (hasSelfReferencingRef(childSchema, root, `${
|
|
38991
|
+
if (hasSelfReferencingRef(childSchema, root, `${path94}/anyOf/${index}`, nextActivePaths)) {
|
|
38844
38992
|
return true;
|
|
38845
38993
|
}
|
|
38846
38994
|
}
|
|
@@ -38856,14 +39004,14 @@ function getLocalRefPath(ref) {
|
|
|
38856
39004
|
return ref.startsWith("#/") ? ref : void 0;
|
|
38857
39005
|
}
|
|
38858
39006
|
function resolveLocalRef(root, ref) {
|
|
38859
|
-
const
|
|
38860
|
-
if (
|
|
39007
|
+
const path94 = getLocalRefPath(ref);
|
|
39008
|
+
if (path94 === void 0) {
|
|
38861
39009
|
return void 0;
|
|
38862
39010
|
}
|
|
38863
|
-
if (
|
|
39011
|
+
if (path94 === "#") {
|
|
38864
39012
|
return root;
|
|
38865
39013
|
}
|
|
38866
|
-
const segments =
|
|
39014
|
+
const segments = path94.slice(2).split("/").map(unescapeJsonPointerSegment);
|
|
38867
39015
|
let current = root;
|
|
38868
39016
|
for (const segment of segments) {
|
|
38869
39017
|
if (Array.isArray(current)) {
|
|
@@ -38957,9 +39105,9 @@ var init_json_schema_converter = __esm({
|
|
|
38957
39105
|
});
|
|
38958
39106
|
|
|
38959
39107
|
// packages/toolcraft/src/mcp-proxy.ts
|
|
38960
|
-
import { existsSync } from "node:fs";
|
|
38961
|
-
import { mkdir as mkdir13, readFile as
|
|
38962
|
-
import
|
|
39108
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
39109
|
+
import { mkdir as mkdir13, readFile as readFile16, rename as rename7, unlink as unlink11, writeFile as writeFile11 } from "node:fs/promises";
|
|
39110
|
+
import path55 from "node:path";
|
|
38963
39111
|
function getInternalGroupConfig2(group) {
|
|
38964
39112
|
const symbol = Object.getOwnPropertySymbols(group).find(
|
|
38965
39113
|
(candidate) => candidate.description === GROUP_CONFIG_SYMBOL_DESCRIPTION
|
|
@@ -39101,7 +39249,7 @@ async function ensureConnected(connection) {
|
|
|
39101
39249
|
}
|
|
39102
39250
|
async function readCache(cachePath) {
|
|
39103
39251
|
try {
|
|
39104
|
-
const raw = await
|
|
39252
|
+
const raw = await readFile16(cachePath, "utf8");
|
|
39105
39253
|
const parsed = JSON.parse(raw);
|
|
39106
39254
|
if (parsed === null || typeof parsed !== "object" || !Array.isArray(parsed.tools) || parsed.upstream === void 0 || typeof parsed.upstream.name !== "string" || typeof parsed.upstream.version !== "string") {
|
|
39107
39255
|
return void 0;
|
|
@@ -39122,7 +39270,7 @@ async function readCache(cachePath) {
|
|
|
39122
39270
|
}
|
|
39123
39271
|
}
|
|
39124
39272
|
async function writeCache(cachePath, cache2) {
|
|
39125
|
-
const directory =
|
|
39273
|
+
const directory = path55.dirname(cachePath);
|
|
39126
39274
|
const tempPath = `${cachePath}.tmp`;
|
|
39127
39275
|
await mkdir13(directory, { recursive: true });
|
|
39128
39276
|
await writeFile11(tempPath, `${JSON.stringify(cache2, null, 2)}
|
|
@@ -39265,14 +39413,14 @@ function collectProxyGroups(root) {
|
|
|
39265
39413
|
}
|
|
39266
39414
|
function resolveCachePath(name, projectRoot) {
|
|
39267
39415
|
if (projectRoot !== void 0) {
|
|
39268
|
-
return
|
|
39416
|
+
return path55.join(projectRoot, ".toolcraft", "mcp", `${name}.json`);
|
|
39269
39417
|
}
|
|
39270
39418
|
let current = process.cwd();
|
|
39271
39419
|
while (true) {
|
|
39272
|
-
if (
|
|
39273
|
-
return
|
|
39420
|
+
if (existsSync2(path55.join(current, "package.json"))) {
|
|
39421
|
+
return path55.join(current, ".toolcraft", "mcp", `${name}.json`);
|
|
39274
39422
|
}
|
|
39275
|
-
const parent =
|
|
39423
|
+
const parent = path55.dirname(current);
|
|
39276
39424
|
if (parent === current) {
|
|
39277
39425
|
throw new Error(
|
|
39278
39426
|
`Could not find package.json above "${process.cwd()}" while resolving MCP cache path.`
|
|
@@ -39390,7 +39538,7 @@ var init_schema_scope = __esm({
|
|
|
39390
39538
|
});
|
|
39391
39539
|
|
|
39392
39540
|
// packages/toolcraft/src/mcp.ts
|
|
39393
|
-
import { access as access2, readFile as
|
|
39541
|
+
import { access as access2, readFile as readFile17, writeFile as writeFile12 } from "node:fs/promises";
|
|
39394
39542
|
function normalizeRoots(roots) {
|
|
39395
39543
|
if (!Array.isArray(roots)) {
|
|
39396
39544
|
return roots;
|
|
@@ -39458,13 +39606,13 @@ function isPlainObject4(value) {
|
|
|
39458
39606
|
}
|
|
39459
39607
|
function createFs2() {
|
|
39460
39608
|
return {
|
|
39461
|
-
readFile: async (
|
|
39462
|
-
writeFile: async (
|
|
39463
|
-
await writeFile12(
|
|
39609
|
+
readFile: async (path94, encoding = "utf8") => readFile17(path94, { encoding }),
|
|
39610
|
+
writeFile: async (path94, contents) => {
|
|
39611
|
+
await writeFile12(path94, contents);
|
|
39464
39612
|
},
|
|
39465
|
-
exists: async (
|
|
39613
|
+
exists: async (path94) => {
|
|
39466
39614
|
try {
|
|
39467
|
-
await access2(
|
|
39615
|
+
await access2(path94);
|
|
39468
39616
|
return true;
|
|
39469
39617
|
} catch {
|
|
39470
39618
|
return false;
|
|
@@ -39509,11 +39657,11 @@ function applySchemaCasing(schema, casing) {
|
|
|
39509
39657
|
...required === void 0 ? {} : { required }
|
|
39510
39658
|
};
|
|
39511
39659
|
}
|
|
39512
|
-
function collectParamSummaries(schema, casing,
|
|
39660
|
+
function collectParamSummaries(schema, casing, path94 = [], inheritedOptional = false) {
|
|
39513
39661
|
const summaries = [];
|
|
39514
39662
|
for (const [key2, rawChildSchema] of Object.entries(schema.shape)) {
|
|
39515
39663
|
const childSchema = unwrapOptional2(rawChildSchema);
|
|
39516
|
-
const nextPath = [...
|
|
39664
|
+
const nextPath = [...path94, formatSegment(key2, casing)];
|
|
39517
39665
|
const optional = inheritedOptional || isOptional(rawChildSchema);
|
|
39518
39666
|
if (childSchema.kind === "object") {
|
|
39519
39667
|
summaries.push(...collectParamSummaries(childSchema, casing, nextPath, optional));
|
|
@@ -39542,8 +39690,8 @@ function matchesAllowlist(toolName, allowlist) {
|
|
|
39542
39690
|
const candidates = segments.map((_segment, index) => segments.slice(0, index + 1).join("__"));
|
|
39543
39691
|
return candidates.some((candidate) => allowlist.includes(candidate));
|
|
39544
39692
|
}
|
|
39545
|
-
function formatToolName(
|
|
39546
|
-
return
|
|
39693
|
+
function formatToolName(path94) {
|
|
39694
|
+
return path94.map((segment) => formatSegment(segment, "snake")).join("__");
|
|
39547
39695
|
}
|
|
39548
39696
|
function enumerateTools(root, casing, allowlist) {
|
|
39549
39697
|
const tools = [];
|
|
@@ -39745,7 +39893,8 @@ function createResolvedMCPServer(root, options) {
|
|
|
39745
39893
|
};
|
|
39746
39894
|
validateServices(services);
|
|
39747
39895
|
const tools = enumerateTools(root, casing, options.tools);
|
|
39748
|
-
const
|
|
39896
|
+
const version = resolveMCPVersion(options.version);
|
|
39897
|
+
const server = createServer({ name: options.name, version });
|
|
39749
39898
|
for (const tool of tools) {
|
|
39750
39899
|
server.tool(
|
|
39751
39900
|
tool.name,
|
|
@@ -39795,6 +39944,13 @@ function createResolvedMCPServer(root, options) {
|
|
|
39795
39944
|
}
|
|
39796
39945
|
};
|
|
39797
39946
|
}
|
|
39947
|
+
function resolveMCPVersion(version) {
|
|
39948
|
+
const resolvedVersion = version ?? findEntrypointPackageMetadata(process.argv[1])?.version;
|
|
39949
|
+
if (resolvedVersion === void 0) {
|
|
39950
|
+
throw new Error("MCP version is required when no package.json version can be inferred from the entrypoint.");
|
|
39951
|
+
}
|
|
39952
|
+
return resolvedVersion;
|
|
39953
|
+
}
|
|
39798
39954
|
async function runMCP(roots, options) {
|
|
39799
39955
|
const root = mergeApprovalsGroup(normalizeRoots(roots));
|
|
39800
39956
|
await resolveMcpProxies(root);
|
|
@@ -39812,6 +39968,7 @@ var init_mcp2 = __esm({
|
|
|
39812
39968
|
init_human_in_loop();
|
|
39813
39969
|
init_mcp_proxy();
|
|
39814
39970
|
init_number_schema();
|
|
39971
|
+
init_package_metadata();
|
|
39815
39972
|
init_schema_scope();
|
|
39816
39973
|
RESERVED_SERVICE_NAMES = /* @__PURE__ */ new Set(["params", "secrets", "fetch", "fs", "env", "progress"]);
|
|
39817
39974
|
}
|
|
@@ -39887,7 +40044,7 @@ var init_SKILL_plan = __esm({
|
|
|
39887
40044
|
});
|
|
39888
40045
|
|
|
39889
40046
|
// src/cli/commands/plan.ts
|
|
39890
|
-
import
|
|
40047
|
+
import path56 from "node:path";
|
|
39891
40048
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
39892
40049
|
function buildPlanPrompt(options) {
|
|
39893
40050
|
const trimmedQuestion = options.question.trim();
|
|
@@ -40039,7 +40196,7 @@ async function discoverPlans(container, kind) {
|
|
|
40039
40196
|
async function resolveSelectedPlan(options) {
|
|
40040
40197
|
const providedPath = options.providedPath?.trim();
|
|
40041
40198
|
if (providedPath) {
|
|
40042
|
-
const resolvedAbsolute = providedPath.startsWith("~/") ?
|
|
40199
|
+
const resolvedAbsolute = providedPath.startsWith("~/") ? path56.join(options.container.env.homeDir, providedPath.slice(2)) : path56.isAbsolute(providedPath) ? providedPath : path56.resolve(options.container.env.cwd, providedPath);
|
|
40043
40200
|
const matched2 = options.plans.find(
|
|
40044
40201
|
(plan) => plan.path === providedPath || plan.absolutePath === providedPath || plan.absolutePath === resolvedAbsolute
|
|
40045
40202
|
);
|
|
@@ -40057,7 +40214,7 @@ async function resolveSelectedPlan(options) {
|
|
|
40057
40214
|
const selected = await select2({
|
|
40058
40215
|
message: options.promptMessage,
|
|
40059
40216
|
options: options.plans.map((plan) => ({
|
|
40060
|
-
label: text.selectLabel(
|
|
40217
|
+
label: text.selectLabel(path56.basename(plan.path), plan.detail),
|
|
40061
40218
|
hint: plan.typeLabel,
|
|
40062
40219
|
value: plan.absolutePath
|
|
40063
40220
|
}))
|
|
@@ -40095,7 +40252,7 @@ async function renderPlanList(container, options) {
|
|
|
40095
40252
|
kind: plan.kind,
|
|
40096
40253
|
type: plan.typeLabel,
|
|
40097
40254
|
runner: plan.runner,
|
|
40098
|
-
name:
|
|
40255
|
+
name: path56.basename(plan.path),
|
|
40099
40256
|
path: plan.path,
|
|
40100
40257
|
detail: plan.detail,
|
|
40101
40258
|
updated: formatDate(plan.updatedAt)
|
|
@@ -40120,7 +40277,7 @@ async function renderPlanList(container, options) {
|
|
|
40120
40277
|
rows: plans.map((plan) => ({
|
|
40121
40278
|
kind: plan.kind,
|
|
40122
40279
|
type: plan.typeLabel,
|
|
40123
|
-
name:
|
|
40280
|
+
name: path56.basename(plan.path),
|
|
40124
40281
|
detail: plan.detail,
|
|
40125
40282
|
updated: formatDate(plan.updatedAt)
|
|
40126
40283
|
}))
|
|
@@ -40154,7 +40311,7 @@ async function executePlanAction(options) {
|
|
|
40154
40311
|
}
|
|
40155
40312
|
if (!flags.assumeYes) {
|
|
40156
40313
|
const confirmed = await confirmOrCancel({
|
|
40157
|
-
message: options.action === "archive" ? `Archive ${
|
|
40314
|
+
message: options.action === "archive" ? `Archive ${path56.basename(plan.path)}?` : `Permanently delete ${path56.basename(plan.path)}?`,
|
|
40158
40315
|
initialValue: true
|
|
40159
40316
|
});
|
|
40160
40317
|
if (!confirmed) {
|
|
@@ -40504,7 +40661,7 @@ var init_plan = __esm({
|
|
|
40504
40661
|
});
|
|
40505
40662
|
|
|
40506
40663
|
// src/cli/commands/pipeline-init.ts
|
|
40507
|
-
import
|
|
40664
|
+
import path57 from "node:path";
|
|
40508
40665
|
import { parse as parseYaml4 } from "yaml";
|
|
40509
40666
|
function buildPipelineInitPrompt(options) {
|
|
40510
40667
|
const trimmedQuestion = options.question?.trim() ?? "";
|
|
@@ -40591,8 +40748,8 @@ async function discoverMarkdownFiles(fs19, absoluteDirectory, parentRelativePath
|
|
|
40591
40748
|
}
|
|
40592
40749
|
const markdownFiles = [];
|
|
40593
40750
|
for (const entry of [...entries].sort((left, right) => left.localeCompare(right))) {
|
|
40594
|
-
const absolutePath =
|
|
40595
|
-
const relativePath = parentRelativePath.length > 0 ?
|
|
40751
|
+
const absolutePath = path57.join(absoluteDirectory, entry);
|
|
40752
|
+
const relativePath = parentRelativePath.length > 0 ? path57.join(parentRelativePath, entry) : entry;
|
|
40596
40753
|
const stat24 = await fs19.stat(absolutePath);
|
|
40597
40754
|
if (stat24.isDirectory()) {
|
|
40598
40755
|
if (entry === "archive") {
|
|
@@ -40622,7 +40779,7 @@ function extractTitle2(filePath, content) {
|
|
|
40622
40779
|
return title;
|
|
40623
40780
|
}
|
|
40624
40781
|
}
|
|
40625
|
-
return
|
|
40782
|
+
return path57.basename(filePath, path57.extname(filePath));
|
|
40626
40783
|
}
|
|
40627
40784
|
function createMarkdownFence(content) {
|
|
40628
40785
|
return "`".repeat(Math.max(3, longestBacktickRun(content) + 1));
|
|
@@ -40667,7 +40824,7 @@ var init_SKILL_plan2 = __esm({
|
|
|
40667
40824
|
|
|
40668
40825
|
// src/sdk/pipeline.ts
|
|
40669
40826
|
import * as fsPromises16 from "node:fs/promises";
|
|
40670
|
-
import
|
|
40827
|
+
import path58 from "node:path";
|
|
40671
40828
|
import { parse as parseYaml5 } from "yaml";
|
|
40672
40829
|
function isActivityTimeoutError2(error2) {
|
|
40673
40830
|
return error2 instanceof Error && error2.name === "ActivityTimeoutError";
|
|
@@ -40713,7 +40870,7 @@ async function runPipeline2(options) {
|
|
|
40713
40870
|
});
|
|
40714
40871
|
});
|
|
40715
40872
|
if (options.plan) {
|
|
40716
|
-
const planAbsolutePath =
|
|
40873
|
+
const planAbsolutePath = path58.resolve(options.cwd, options.plan);
|
|
40717
40874
|
if (await planNeedsInit(planAbsolutePath)) {
|
|
40718
40875
|
const sourceDocContent = await fsPromises16.readFile(planAbsolutePath, "utf8");
|
|
40719
40876
|
const prompt = buildPipelineInitPrompt({
|
|
@@ -40831,7 +40988,7 @@ var init_pipeline2 = __esm({
|
|
|
40831
40988
|
});
|
|
40832
40989
|
|
|
40833
40990
|
// packages/process-launcher/src/state/state-store.ts
|
|
40834
|
-
import
|
|
40991
|
+
import path59 from "node:path";
|
|
40835
40992
|
import * as nodeFs3 from "node:fs/promises";
|
|
40836
40993
|
function isNotFoundError2(error2) {
|
|
40837
40994
|
return error2 instanceof Error && "code" in error2 && error2.code === "ENOENT";
|
|
@@ -40847,7 +41004,7 @@ async function removeDirectory2(fs19, directoryPath) {
|
|
|
40847
41004
|
throw error2;
|
|
40848
41005
|
}
|
|
40849
41006
|
for (const entry of entries) {
|
|
40850
|
-
const entryPath =
|
|
41007
|
+
const entryPath = path59.join(directoryPath, entry);
|
|
40851
41008
|
const stat24 = await fs19.stat(entryPath);
|
|
40852
41009
|
if (stat24.isFile()) {
|
|
40853
41010
|
await fs19.rm(entryPath, { force: true });
|
|
@@ -40864,7 +41021,7 @@ async function removeDirectory2(fs19, directoryPath) {
|
|
|
40864
41021
|
}
|
|
40865
41022
|
function createStateStore(stateDir, fs19 = nodeFs3) {
|
|
40866
41023
|
async function read(id) {
|
|
40867
|
-
const statePath =
|
|
41024
|
+
const statePath = path59.join(stateDir, id, "state.json");
|
|
40868
41025
|
try {
|
|
40869
41026
|
const content = await fs19.readFile(statePath, "utf8");
|
|
40870
41027
|
return JSON.parse(content);
|
|
@@ -40876,9 +41033,9 @@ function createStateStore(stateDir, fs19 = nodeFs3) {
|
|
|
40876
41033
|
}
|
|
40877
41034
|
}
|
|
40878
41035
|
async function write2(id, state) {
|
|
40879
|
-
const processDir =
|
|
41036
|
+
const processDir = path59.join(stateDir, id);
|
|
40880
41037
|
await fs19.mkdir(processDir, { recursive: true });
|
|
40881
|
-
await fs19.writeFile(
|
|
41038
|
+
await fs19.writeFile(path59.join(processDir, "state.json"), `${JSON.stringify(state, null, 2)}
|
|
40882
41039
|
`);
|
|
40883
41040
|
}
|
|
40884
41041
|
async function list() {
|
|
@@ -40893,7 +41050,7 @@ function createStateStore(stateDir, fs19 = nodeFs3) {
|
|
|
40893
41050
|
}
|
|
40894
41051
|
const states = [];
|
|
40895
41052
|
for (const entry of [...entries].sort()) {
|
|
40896
|
-
const entryPath =
|
|
41053
|
+
const entryPath = path59.join(stateDir, entry);
|
|
40897
41054
|
try {
|
|
40898
41055
|
const stat24 = await fs19.stat(entryPath);
|
|
40899
41056
|
if (stat24.isFile()) {
|
|
@@ -40913,7 +41070,7 @@ function createStateStore(stateDir, fs19 = nodeFs3) {
|
|
|
40913
41070
|
return states;
|
|
40914
41071
|
}
|
|
40915
41072
|
async function remove2(id) {
|
|
40916
|
-
await removeDirectory2(fs19,
|
|
41073
|
+
await removeDirectory2(fs19, path59.join(stateDir, id));
|
|
40917
41074
|
}
|
|
40918
41075
|
return { read, write: write2, list, remove: remove2 };
|
|
40919
41076
|
}
|
|
@@ -40924,16 +41081,16 @@ var init_state_store = __esm({
|
|
|
40924
41081
|
});
|
|
40925
41082
|
|
|
40926
41083
|
// packages/process-launcher/src/logs/log-writer.ts
|
|
40927
|
-
import
|
|
41084
|
+
import path60 from "node:path";
|
|
40928
41085
|
import * as nodeFs4 from "node:fs/promises";
|
|
40929
41086
|
function isNotFoundError3(error2) {
|
|
40930
41087
|
return error2 instanceof Error && "code" in error2 && error2.code === "ENOENT";
|
|
40931
41088
|
}
|
|
40932
41089
|
function getCurrentLogPath(logDir, stream) {
|
|
40933
|
-
return
|
|
41090
|
+
return path60.join(logDir, `${stream}.log`);
|
|
40934
41091
|
}
|
|
40935
41092
|
function getRotatedLogPath(logDir, stream, index) {
|
|
40936
|
-
return
|
|
41093
|
+
return path60.join(logDir, `${stream}.${index}.log`);
|
|
40937
41094
|
}
|
|
40938
41095
|
async function isFile(fs19, filePath) {
|
|
40939
41096
|
try {
|
|
@@ -40980,7 +41137,7 @@ async function removeAllStreamLogs(fs19, logDir, stream) {
|
|
|
40980
41137
|
if (getRotatedLogIndex(fileName, stream) === null) {
|
|
40981
41138
|
continue;
|
|
40982
41139
|
}
|
|
40983
|
-
await fs19.rm(
|
|
41140
|
+
await fs19.rm(path60.join(logDir, fileName), { force: true });
|
|
40984
41141
|
}
|
|
40985
41142
|
} catch (error2) {
|
|
40986
41143
|
if (isNotFoundError3(error2)) {
|
|
@@ -41240,7 +41397,7 @@ var init_engine = __esm({
|
|
|
41240
41397
|
});
|
|
41241
41398
|
|
|
41242
41399
|
// packages/process-runner/src/docker/args.ts
|
|
41243
|
-
import
|
|
41400
|
+
import path61 from "node:path";
|
|
41244
41401
|
function buildDockerRunArgs(input) {
|
|
41245
41402
|
const args = [input.engine];
|
|
41246
41403
|
if (input.engine === "docker" && input.context) {
|
|
@@ -41267,7 +41424,7 @@ function buildDockerRunArgs(input) {
|
|
|
41267
41424
|
args.push("-e", `${key2}=${value}`);
|
|
41268
41425
|
}
|
|
41269
41426
|
for (const mount of input.mounts) {
|
|
41270
|
-
const volume = `${
|
|
41427
|
+
const volume = `${path61.resolve(mount.source)}:${mount.target}${mount.readonly ? ":ro" : ""}`;
|
|
41271
41428
|
args.push("-v", volume);
|
|
41272
41429
|
}
|
|
41273
41430
|
for (const port of input.ports) {
|
|
@@ -41524,13 +41681,13 @@ var init_src29 = __esm({
|
|
|
41524
41681
|
import { spawnSync } from "node:child_process";
|
|
41525
41682
|
import * as nodeFs5 from "node:fs/promises";
|
|
41526
41683
|
import os6 from "node:os";
|
|
41527
|
-
import
|
|
41684
|
+
import path62 from "node:path";
|
|
41528
41685
|
function createSupervisor(options) {
|
|
41529
41686
|
const { spec: spec10 } = options;
|
|
41530
41687
|
const runner = resolveRunner(options);
|
|
41531
41688
|
const stateStore = createStateStore(options.stateDir, options.fs);
|
|
41532
41689
|
const logWriter = createLogWriter(
|
|
41533
|
-
|
|
41690
|
+
path62.join(options.stateDir, spec10.id, "logs"),
|
|
41534
41691
|
spec10.logRetainCount ?? 5,
|
|
41535
41692
|
options.fs
|
|
41536
41693
|
);
|
|
@@ -41898,8 +42055,8 @@ async function resolveProcessWorkspace(cwd, stateDir) {
|
|
|
41898
42055
|
};
|
|
41899
42056
|
}
|
|
41900
42057
|
function resolveWorkspaceHomeDir(stateDir) {
|
|
41901
|
-
if (
|
|
41902
|
-
return
|
|
42058
|
+
if (path62.basename(stateDir) === "launch" && path62.basename(path62.dirname(stateDir)) === ".poe-code") {
|
|
42059
|
+
return path62.dirname(path62.dirname(stateDir));
|
|
41903
42060
|
}
|
|
41904
42061
|
return os6.homedir();
|
|
41905
42062
|
}
|
|
@@ -41951,7 +42108,7 @@ var init_supervisor = __esm({
|
|
|
41951
42108
|
});
|
|
41952
42109
|
|
|
41953
42110
|
// packages/process-launcher/src/launcher.ts
|
|
41954
|
-
import
|
|
42111
|
+
import path63 from "node:path";
|
|
41955
42112
|
import * as nodeFs6 from "node:fs/promises";
|
|
41956
42113
|
async function startManagedProcess(options) {
|
|
41957
42114
|
const fs19 = options.fs ?? defaultFs2();
|
|
@@ -42300,7 +42457,7 @@ async function listIds(fs19, baseDir) {
|
|
|
42300
42457
|
const entries = await fs19.readdir(baseDir);
|
|
42301
42458
|
const ids = [];
|
|
42302
42459
|
for (const entry of entries) {
|
|
42303
|
-
const entryPath =
|
|
42460
|
+
const entryPath = path63.join(baseDir, entry);
|
|
42304
42461
|
try {
|
|
42305
42462
|
const stat24 = await fs19.stat(entryPath);
|
|
42306
42463
|
if (!stat24.isFile()) {
|
|
@@ -42350,24 +42507,24 @@ async function readJsonFile(fs19, filePath) {
|
|
|
42350
42507
|
}
|
|
42351
42508
|
}
|
|
42352
42509
|
async function writeJsonFile(fs19, filePath, value) {
|
|
42353
|
-
await fs19.mkdir(
|
|
42510
|
+
await fs19.mkdir(path63.dirname(filePath), { recursive: true });
|
|
42354
42511
|
await fs19.writeFile(filePath, `${JSON.stringify(value, null, 2)}
|
|
42355
42512
|
`);
|
|
42356
42513
|
}
|
|
42357
42514
|
function resolveProcessDir(baseDir, id) {
|
|
42358
|
-
return
|
|
42515
|
+
return path63.join(baseDir, id);
|
|
42359
42516
|
}
|
|
42360
42517
|
function resolveSpecPath(baseDir, id) {
|
|
42361
|
-
return
|
|
42518
|
+
return path63.join(resolveProcessDir(baseDir, id), "spec.json");
|
|
42362
42519
|
}
|
|
42363
42520
|
function resolveStatePath(baseDir, id) {
|
|
42364
|
-
return
|
|
42521
|
+
return path63.join(resolveProcessDir(baseDir, id), "state.json");
|
|
42365
42522
|
}
|
|
42366
42523
|
function resolveMetaPath(baseDir, id) {
|
|
42367
|
-
return
|
|
42524
|
+
return path63.join(resolveProcessDir(baseDir, id), "meta.json");
|
|
42368
42525
|
}
|
|
42369
42526
|
function resolveLogDir2(baseDir, id) {
|
|
42370
|
-
return
|
|
42527
|
+
return path63.join(resolveProcessDir(baseDir, id), "logs");
|
|
42371
42528
|
}
|
|
42372
42529
|
function isNotFoundError4(error2) {
|
|
42373
42530
|
return error2 instanceof Error && "code" in error2 && error2.code === "ENOENT";
|
|
@@ -42448,7 +42605,7 @@ var init_ralph2 = __esm({
|
|
|
42448
42605
|
|
|
42449
42606
|
// src/sdk/experiment.ts
|
|
42450
42607
|
import * as fsPromises17 from "node:fs/promises";
|
|
42451
|
-
import
|
|
42608
|
+
import path64 from "node:path";
|
|
42452
42609
|
function createDefaultFs12() {
|
|
42453
42610
|
return {
|
|
42454
42611
|
readFile: fsPromises17.readFile,
|
|
@@ -42476,9 +42633,9 @@ function createDefaultFs12() {
|
|
|
42476
42633
|
};
|
|
42477
42634
|
}
|
|
42478
42635
|
function resolveJournalPath2(docPath) {
|
|
42479
|
-
return
|
|
42480
|
-
|
|
42481
|
-
`${
|
|
42636
|
+
return path64.join(
|
|
42637
|
+
path64.dirname(docPath),
|
|
42638
|
+
`${path64.basename(docPath, path64.extname(docPath))}.journal.jsonl`
|
|
42482
42639
|
);
|
|
42483
42640
|
}
|
|
42484
42641
|
async function runExperiment(options) {
|
|
@@ -42685,7 +42842,7 @@ var init_frontmatter4 = __esm({
|
|
|
42685
42842
|
});
|
|
42686
42843
|
|
|
42687
42844
|
// packages/github-workflows/src/discover.ts
|
|
42688
|
-
import { readdir as readdir16, readFile as
|
|
42845
|
+
import { readdir as readdir16, readFile as readFile20 } from "node:fs/promises";
|
|
42689
42846
|
import { join as join2 } from "node:path";
|
|
42690
42847
|
async function discoverAutomations(builtInDir, ...projectDirs) {
|
|
42691
42848
|
const directories = [builtInDir, ...projectDirs];
|
|
@@ -42729,7 +42886,7 @@ async function listMarkdownFiles(dir) {
|
|
|
42729
42886
|
}
|
|
42730
42887
|
async function readAutomation(dir, fileName, baseName, baseDirs) {
|
|
42731
42888
|
const filePath = join2(dir, fileName);
|
|
42732
|
-
const content = await
|
|
42889
|
+
const content = await readFile20(filePath, "utf8");
|
|
42733
42890
|
const resolved = await resolve(
|
|
42734
42891
|
[
|
|
42735
42892
|
{
|
|
@@ -42750,7 +42907,7 @@ async function readAutomation(dir, fileName, baseName, baseDirs) {
|
|
|
42750
42907
|
}
|
|
42751
42908
|
],
|
|
42752
42909
|
{
|
|
42753
|
-
fs: { readFile:
|
|
42910
|
+
fs: { readFile: readFile20 }
|
|
42754
42911
|
}
|
|
42755
42912
|
);
|
|
42756
42913
|
const name = stripPrefix(fileName.slice(0, -3));
|
|
@@ -43038,8 +43195,8 @@ var init_setup_agent = __esm({
|
|
|
43038
43195
|
});
|
|
43039
43196
|
|
|
43040
43197
|
// packages/github-workflows/src/variables.ts
|
|
43041
|
-
import
|
|
43042
|
-
import { readFile as
|
|
43198
|
+
import path65 from "node:path";
|
|
43199
|
+
import { readFile as readFile21 } from "node:fs/promises";
|
|
43043
43200
|
import { isMap as isMap3, parseDocument as parseDocument9, stringify as stringify4 } from "yaml";
|
|
43044
43201
|
function isRecord20(value) {
|
|
43045
43202
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -43130,7 +43287,7 @@ function extractUserOverrideBlocks(filePath, content) {
|
|
|
43130
43287
|
}
|
|
43131
43288
|
async function readOptionalVariablesContent(filePath) {
|
|
43132
43289
|
try {
|
|
43133
|
-
return await
|
|
43290
|
+
return await readFile21(filePath, "utf8");
|
|
43134
43291
|
} catch (error2) {
|
|
43135
43292
|
if (error2 instanceof Error && error2.code === "ENOENT") {
|
|
43136
43293
|
return void 0;
|
|
@@ -43158,9 +43315,9 @@ function formatCommentedBlock(name, value) {
|
|
|
43158
43315
|
return formatVariableBlock(name, value).split("\n").map((line) => `# ${line}`).join("\n");
|
|
43159
43316
|
}
|
|
43160
43317
|
async function loadVariableSources(builtInDir, projectDir) {
|
|
43161
|
-
const builtInPath =
|
|
43162
|
-
const builtInVariables = parseVariables(builtInPath, await
|
|
43163
|
-
const projectVariablesPath = projectDir === void 0 ? void 0 :
|
|
43318
|
+
const builtInPath = path65.join(builtInDir, VARIABLES_FILE_NAME);
|
|
43319
|
+
const builtInVariables = parseVariables(builtInPath, await readFile21(builtInPath, "utf8"));
|
|
43320
|
+
const projectVariablesPath = projectDir === void 0 ? void 0 : path65.join(projectDir, VARIABLES_FILE_NAME);
|
|
43164
43321
|
const projectVariablesContent = projectVariablesPath === void 0 ? void 0 : await readOptionalVariablesContent(projectVariablesPath);
|
|
43165
43322
|
if (projectVariablesPath === void 0 || projectVariablesContent === void 0) {
|
|
43166
43323
|
return { builtInVariables, extendsBuiltIns: true, projectVariables: {} };
|
|
@@ -43172,13 +43329,13 @@ async function loadVariableSources(builtInDir, projectDir) {
|
|
|
43172
43329
|
return { builtInVariables, extendsBuiltIns, projectVariables };
|
|
43173
43330
|
}
|
|
43174
43331
|
async function loadVariables(builtInDir, projectDir) {
|
|
43175
|
-
const builtInPath =
|
|
43176
|
-
const builtInContent = await
|
|
43332
|
+
const builtInPath = path65.join(builtInDir, VARIABLES_FILE_NAME);
|
|
43333
|
+
const builtInContent = await readFile21(builtInPath, "utf8");
|
|
43177
43334
|
const builtInVariables = parseVariables(builtInPath, builtInContent);
|
|
43178
43335
|
if (projectDir === void 0) {
|
|
43179
43336
|
return filterDisabledVariables(builtInVariables);
|
|
43180
43337
|
}
|
|
43181
|
-
const projectVariablesPath =
|
|
43338
|
+
const projectVariablesPath = path65.join(projectDir, VARIABLES_FILE_NAME);
|
|
43182
43339
|
const projectVariablesContent = await readOptionalVariablesContent(projectVariablesPath);
|
|
43183
43340
|
if (projectVariablesContent === void 0) {
|
|
43184
43341
|
return filterDisabledVariables(builtInVariables);
|
|
@@ -43197,7 +43354,7 @@ async function loadVariables(builtInDir, projectDir) {
|
|
|
43197
43354
|
}
|
|
43198
43355
|
],
|
|
43199
43356
|
{
|
|
43200
|
-
fs: { readFile:
|
|
43357
|
+
fs: { readFile: readFile21 },
|
|
43201
43358
|
autoExtend: true
|
|
43202
43359
|
}
|
|
43203
43360
|
);
|
|
@@ -43211,7 +43368,7 @@ async function loadVariableStatuses(builtInDir, projectDir) {
|
|
|
43211
43368
|
(key2) => !extendsBuiltIns || !Object.prototype.hasOwnProperty.call(builtInVariables, key2)
|
|
43212
43369
|
)
|
|
43213
43370
|
];
|
|
43214
|
-
const projectVariablesPath = projectDir === void 0 ? void 0 :
|
|
43371
|
+
const projectVariablesPath = projectDir === void 0 ? void 0 : path65.join(projectDir, VARIABLES_FILE_NAME);
|
|
43215
43372
|
return orderedNames.map((name) => {
|
|
43216
43373
|
if (!Object.prototype.hasOwnProperty.call(projectVariables, name)) {
|
|
43217
43374
|
return {
|
|
@@ -43272,9 +43429,9 @@ var init_variables2 = __esm({
|
|
|
43272
43429
|
});
|
|
43273
43430
|
|
|
43274
43431
|
// packages/github-workflows/src/commands.ts
|
|
43275
|
-
import { access as access3, mkdir as mkdir16, readFile as
|
|
43276
|
-
import
|
|
43277
|
-
import { fileURLToPath as
|
|
43432
|
+
import { access as access3, mkdir as mkdir16, readFile as readFile22, unlink as unlink12, writeFile as writeFile14 } from "node:fs/promises";
|
|
43433
|
+
import path66 from "node:path";
|
|
43434
|
+
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
43278
43435
|
import Mustache3 from "mustache";
|
|
43279
43436
|
function formatLabel(name) {
|
|
43280
43437
|
const capitalize2 = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -43296,7 +43453,7 @@ async function loadNamedAutomation(name, cwd) {
|
|
|
43296
43453
|
}
|
|
43297
43454
|
async function readBuiltInPromptFile(name) {
|
|
43298
43455
|
try {
|
|
43299
|
-
return await
|
|
43456
|
+
return await readFile22(path66.join(await resolveBuiltInPromptsDir(), `${name}.md`), "utf8");
|
|
43300
43457
|
} catch (error2) {
|
|
43301
43458
|
if (isMissingPathError2(error2)) {
|
|
43302
43459
|
throw new UserError(`Automation "${name}" was not found.`);
|
|
@@ -43305,11 +43462,11 @@ async function readBuiltInPromptFile(name) {
|
|
|
43305
43462
|
}
|
|
43306
43463
|
}
|
|
43307
43464
|
async function readBuiltInWorkflowTemplate(name, variant, automationName = name, promptPath) {
|
|
43308
|
-
const templatePath =
|
|
43465
|
+
const templatePath = path66.join(await resolveBuiltInWorkflowTemplatesDir(), `${name}.${variant}.yml`);
|
|
43309
43466
|
try {
|
|
43310
|
-
const content = await
|
|
43467
|
+
const content = await readFile22(templatePath, "utf8");
|
|
43311
43468
|
const header = promptPath !== void 0 ? `# Auto-generated by: poe-code github-workflows install ${name}
|
|
43312
|
-
# Edit ${
|
|
43469
|
+
# Edit ${path66.relative(process.cwd(), promptPath)} to customize the prompt.
|
|
43313
43470
|
` : `# Auto-generated by: poe-code github-workflows install ${name}
|
|
43314
43471
|
`;
|
|
43315
43472
|
const processedContent = content.replaceAll(` ${name}`, ` ${automationName}`).replaceAll("__UPSTREAM_REPO__", UPSTREAM_REPO);
|
|
@@ -43338,7 +43495,7 @@ function projectPromptDirs(cwd) {
|
|
|
43338
43495
|
return [projectWorkflowDir(cwd)];
|
|
43339
43496
|
}
|
|
43340
43497
|
function projectWorkflowDir(cwd) {
|
|
43341
|
-
return
|
|
43498
|
+
return path66.join(cwd, ".github", "workflows");
|
|
43342
43499
|
}
|
|
43343
43500
|
function projectGitHubWorkflowsDir(cwd) {
|
|
43344
43501
|
return projectWorkflowDir(cwd);
|
|
@@ -43357,7 +43514,7 @@ async function resolveBuiltInPromptsDir() {
|
|
|
43357
43514
|
return builtInPromptsDirCandidates[0];
|
|
43358
43515
|
}
|
|
43359
43516
|
async function resolveBuiltInAssetsDir() {
|
|
43360
|
-
return
|
|
43517
|
+
return path66.dirname(await resolveBuiltInPromptsDir());
|
|
43361
43518
|
}
|
|
43362
43519
|
function resolveCwd(cwd) {
|
|
43363
43520
|
return cwd ?? process.cwd();
|
|
@@ -43511,16 +43668,16 @@ function addPromptHeader(content, name) {
|
|
|
43511
43668
|
async function installAutomation(name, cwd, isEject) {
|
|
43512
43669
|
const variant = isEject ? "ejected" : "caller";
|
|
43513
43670
|
const localAutomationName = isEject ? `poe-code-${name}` : name;
|
|
43514
|
-
const promptPath = isEject ?
|
|
43671
|
+
const promptPath = isEject ? path66.join(projectWorkflowDir(cwd), `${localAutomationName}.md`) : void 0;
|
|
43515
43672
|
const [workflowTemplate, rawPrompt] = await Promise.all([
|
|
43516
43673
|
readBuiltInWorkflowTemplate(name, variant, localAutomationName, promptPath),
|
|
43517
43674
|
readBuiltInPromptFile(name)
|
|
43518
43675
|
]);
|
|
43519
|
-
const workflowPath =
|
|
43520
|
-
await mkdir16(
|
|
43676
|
+
const workflowPath = path66.join(cwd, ".github", "workflows", `poe-code-${name}.yml`);
|
|
43677
|
+
await mkdir16(path66.dirname(workflowPath), { recursive: true });
|
|
43521
43678
|
await writeFile14(workflowPath, workflowTemplate, "utf8");
|
|
43522
43679
|
if (promptPath !== void 0) {
|
|
43523
|
-
await mkdir16(
|
|
43680
|
+
await mkdir16(path66.dirname(promptPath), { recursive: true });
|
|
43524
43681
|
await writeFile14(promptPath, addPromptHeader(rawPrompt, name), "utf8");
|
|
43525
43682
|
}
|
|
43526
43683
|
return {
|
|
@@ -43533,8 +43690,8 @@ async function installAutomation(name, cwd, isEject) {
|
|
|
43533
43690
|
}
|
|
43534
43691
|
async function ensureProjectSupportFiles(cwd, builtInVariables) {
|
|
43535
43692
|
const projectDir = projectGitHubWorkflowsDir(cwd);
|
|
43536
|
-
const variablesPath =
|
|
43537
|
-
const readmePath =
|
|
43693
|
+
const variablesPath = path66.join(projectDir, "variables.yaml");
|
|
43694
|
+
const readmePath = path66.join(projectDir, "README.md");
|
|
43538
43695
|
await mkdir16(projectDir, { recursive: true });
|
|
43539
43696
|
await writeFile14(
|
|
43540
43697
|
variablesPath,
|
|
@@ -43546,7 +43703,7 @@ async function ensureProjectSupportFiles(cwd, builtInVariables) {
|
|
|
43546
43703
|
}
|
|
43547
43704
|
async function readOptionalFile4(filePath) {
|
|
43548
43705
|
try {
|
|
43549
|
-
return await
|
|
43706
|
+
return await readFile22(filePath, "utf8");
|
|
43550
43707
|
} catch (error2) {
|
|
43551
43708
|
if (isMissingPathError2(error2)) {
|
|
43552
43709
|
return void 0;
|
|
@@ -43609,12 +43766,12 @@ var init_commands2 = __esm({
|
|
|
43609
43766
|
init_variables2();
|
|
43610
43767
|
UPSTREAM_REPO = "poe-platform/poe-code";
|
|
43611
43768
|
builtInPromptsDirCandidates = [
|
|
43612
|
-
|
|
43613
|
-
|
|
43769
|
+
fileURLToPath8(new URL("./prompts", import.meta.url)),
|
|
43770
|
+
fileURLToPath8(new URL("../src/prompts", import.meta.url))
|
|
43614
43771
|
];
|
|
43615
43772
|
builtInWorkflowTemplatesDirCandidates = [
|
|
43616
|
-
|
|
43617
|
-
|
|
43773
|
+
fileURLToPath8(new URL("./workflow-templates", import.meta.url)),
|
|
43774
|
+
fileURLToPath8(new URL("../src/workflow-templates", import.meta.url))
|
|
43618
43775
|
];
|
|
43619
43776
|
Mustache3.escape = (value) => value;
|
|
43620
43777
|
installableAutomations = [
|
|
@@ -43816,7 +43973,7 @@ var init_commands2 = __esm({
|
|
|
43816
43973
|
scope: ["cli"],
|
|
43817
43974
|
handler: async ({ params }) => {
|
|
43818
43975
|
const name = params.name;
|
|
43819
|
-
const workflowPath =
|
|
43976
|
+
const workflowPath = path66.join(resolveCwd(), ".github", "workflows", `poe-code-${name}.yml`);
|
|
43820
43977
|
try {
|
|
43821
43978
|
await unlink12(workflowPath);
|
|
43822
43979
|
} catch (error2) {
|
|
@@ -43919,7 +44076,7 @@ var init_commands2 = __esm({
|
|
|
43919
44076
|
return (await loadVariableStatuses(await resolveBuiltInAssetsDir(), projectGitHubWorkflowsDir(cwd))).map(
|
|
43920
44077
|
(status) => ({
|
|
43921
44078
|
...status,
|
|
43922
|
-
source: status.source === "built-in" ? status.source :
|
|
44079
|
+
source: status.source === "built-in" ? status.source : path66.relative(cwd, status.source)
|
|
43923
44080
|
})
|
|
43924
44081
|
);
|
|
43925
44082
|
},
|
|
@@ -43974,7 +44131,7 @@ var init_src31 = __esm({
|
|
|
43974
44131
|
|
|
43975
44132
|
// src/utils/execution-context.ts
|
|
43976
44133
|
import { basename as basename2, dirname as dirname3 } from "node:path";
|
|
43977
|
-
import { fileURLToPath as
|
|
44134
|
+
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
43978
44135
|
function detectExecutionContext(input) {
|
|
43979
44136
|
const { argv, env, moduleUrl } = input;
|
|
43980
44137
|
if (isDevelopmentMode(argv, env)) {
|
|
@@ -44033,7 +44190,7 @@ function detectNpxVersion(env) {
|
|
|
44033
44190
|
return "default";
|
|
44034
44191
|
}
|
|
44035
44192
|
function createDevelopmentContext(moduleUrl) {
|
|
44036
|
-
const modulePath =
|
|
44193
|
+
const modulePath = fileURLToPath9(moduleUrl);
|
|
44037
44194
|
const srcIndex = modulePath.lastIndexOf("/src/");
|
|
44038
44195
|
const projectRoot = srcIndex !== -1 ? modulePath.substring(0, srcIndex) : dirname3(dirname3(modulePath));
|
|
44039
44196
|
return {
|
|
@@ -44097,7 +44254,7 @@ var init_execution_context = __esm({
|
|
|
44097
44254
|
});
|
|
44098
44255
|
|
|
44099
44256
|
// src/sdk/launch.ts
|
|
44100
|
-
import
|
|
44257
|
+
import path67 from "node:path";
|
|
44101
44258
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
44102
44259
|
async function startLaunch(options) {
|
|
44103
44260
|
const homeDir = resolveHomeDir(options.homeDir);
|
|
@@ -44203,7 +44360,7 @@ async function runLaunchDaemon(options) {
|
|
|
44203
44360
|
});
|
|
44204
44361
|
}
|
|
44205
44362
|
function resolveLaunchBaseDir(homeDir) {
|
|
44206
|
-
return
|
|
44363
|
+
return path67.join(homeDir, ".poe-code", "launch");
|
|
44207
44364
|
}
|
|
44208
44365
|
function resolveHomeDir(homeDir) {
|
|
44209
44366
|
if (homeDir) {
|
|
@@ -44219,7 +44376,7 @@ function normalizeLaunchSpec(spec10, baseDir) {
|
|
|
44219
44376
|
if (locator.scheme !== "local") {
|
|
44220
44377
|
return spec10;
|
|
44221
44378
|
}
|
|
44222
|
-
const cwd =
|
|
44379
|
+
const cwd = path67.isAbsolute(locator.path) ? locator.path : path67.resolve(baseDir, locator.path);
|
|
44223
44380
|
return {
|
|
44224
44381
|
...spec10,
|
|
44225
44382
|
cwd
|
|
@@ -45213,15 +45370,15 @@ var init_renderer3 = __esm({
|
|
|
45213
45370
|
});
|
|
45214
45371
|
|
|
45215
45372
|
// packages/toolcraft/src/cli.ts
|
|
45216
|
-
import { access as access4, readFile as
|
|
45217
|
-
import
|
|
45373
|
+
import { access as access4, readFile as readFile23, writeFile as writeFile15 } from "node:fs/promises";
|
|
45374
|
+
import path69 from "node:path";
|
|
45218
45375
|
import { Command as CommanderCommand, CommanderError, InvalidArgumentError, Option } from "commander";
|
|
45219
45376
|
function inferProgramName(argv) {
|
|
45220
45377
|
const entrypoint = argv[1];
|
|
45221
45378
|
if (typeof entrypoint !== "string" || entrypoint.length === 0) {
|
|
45222
45379
|
return "toolcraft";
|
|
45223
45380
|
}
|
|
45224
|
-
const parsed =
|
|
45381
|
+
const parsed = path69.parse(entrypoint);
|
|
45225
45382
|
return parsed.name.length > 0 ? parsed.name : "toolcraft";
|
|
45226
45383
|
}
|
|
45227
45384
|
function normalizeRoots2(roots, argv) {
|
|
@@ -45278,11 +45435,11 @@ function formatSegment2(segment, casing) {
|
|
|
45278
45435
|
const separator = casing === "snake" ? "_" : "-";
|
|
45279
45436
|
return splitWords2(segment).join(separator);
|
|
45280
45437
|
}
|
|
45281
|
-
function toOptionFlag(
|
|
45282
|
-
return `--${
|
|
45438
|
+
function toOptionFlag(path94, casing) {
|
|
45439
|
+
return `--${path94.map((segment) => formatSegment2(segment, casing)).join(".")}`;
|
|
45283
45440
|
}
|
|
45284
|
-
function toOptionAttribute(
|
|
45285
|
-
return
|
|
45441
|
+
function toOptionAttribute(path94, casing) {
|
|
45442
|
+
return path94.map((segment) => {
|
|
45286
45443
|
const formatted = formatSegment2(segment, casing);
|
|
45287
45444
|
if (casing === "snake") {
|
|
45288
45445
|
return formatted;
|
|
@@ -45293,23 +45450,23 @@ function toOptionAttribute(path93, casing) {
|
|
|
45293
45450
|
).join("");
|
|
45294
45451
|
}).join(".");
|
|
45295
45452
|
}
|
|
45296
|
-
function toDisplayPath3(
|
|
45297
|
-
return
|
|
45453
|
+
function toDisplayPath3(path94) {
|
|
45454
|
+
return path94.join(".");
|
|
45298
45455
|
}
|
|
45299
|
-
function toUnionKindControlPath(
|
|
45300
|
-
if (
|
|
45456
|
+
function toUnionKindControlPath(path94) {
|
|
45457
|
+
if (path94.length === 0) {
|
|
45301
45458
|
return ["kind"];
|
|
45302
45459
|
}
|
|
45303
|
-
const head =
|
|
45304
|
-
const tail =
|
|
45460
|
+
const head = path94.slice(0, -1);
|
|
45461
|
+
const tail = path94[path94.length - 1] ?? "";
|
|
45305
45462
|
return [...head, `${tail}Kind`];
|
|
45306
45463
|
}
|
|
45307
|
-
function toUnionKindDisplayPath(
|
|
45308
|
-
if (
|
|
45464
|
+
function toUnionKindDisplayPath(path94) {
|
|
45465
|
+
if (path94.length === 0) {
|
|
45309
45466
|
return "kind";
|
|
45310
45467
|
}
|
|
45311
|
-
const head =
|
|
45312
|
-
const tail =
|
|
45468
|
+
const head = path94.slice(0, -1);
|
|
45469
|
+
const tail = path94[path94.length - 1] ?? "";
|
|
45313
45470
|
return [...head, `${tail}-kind`].join(".");
|
|
45314
45471
|
}
|
|
45315
45472
|
function createSyntheticEnumSchema(values) {
|
|
@@ -45325,14 +45482,14 @@ function getRequiredBranchFingerprint(branch, casing) {
|
|
|
45325
45482
|
const requiredKeys = Object.entries(branch.shape).filter(([, schema]) => schema.kind !== "optional").map(([key2]) => formatSegment2(key2, casing)).sort();
|
|
45326
45483
|
return requiredKeys.join("+");
|
|
45327
45484
|
}
|
|
45328
|
-
function collectFields(schema, casing,
|
|
45485
|
+
function collectFields(schema, casing, path94 = [], inheritedOptional = false, variantContext) {
|
|
45329
45486
|
const collected = {
|
|
45330
45487
|
dynamicFields: [],
|
|
45331
45488
|
fields: [],
|
|
45332
45489
|
variants: []
|
|
45333
45490
|
};
|
|
45334
45491
|
for (const [key2, rawChildSchema] of Object.entries(schema.shape)) {
|
|
45335
|
-
const nextPath = [...
|
|
45492
|
+
const nextPath = [...path94, key2];
|
|
45336
45493
|
const runtimeOptional = inheritedOptional || rawChildSchema.kind === "optional";
|
|
45337
45494
|
const childSchema = unwrapOptional3(rawChildSchema);
|
|
45338
45495
|
const requiredWhenActive = rawChildSchema.kind !== "optional" && childSchema.default === void 0;
|
|
@@ -45495,9 +45652,9 @@ function collectFields(schema, casing, path93 = [], inheritedOptional = false, v
|
|
|
45495
45652
|
}
|
|
45496
45653
|
return collected;
|
|
45497
45654
|
}
|
|
45498
|
-
function toCommanderOptionAttribute(
|
|
45499
|
-
const optionAttribute = toOptionAttribute(
|
|
45500
|
-
const optionFlag = toOptionFlag(
|
|
45655
|
+
function toCommanderOptionAttribute(path94, casing) {
|
|
45656
|
+
const optionAttribute = toOptionAttribute(path94, casing);
|
|
45657
|
+
const optionFlag = toOptionFlag(path94, casing);
|
|
45501
45658
|
if (!GLOBAL_LONG_OPTION_FLAGS.has(optionFlag)) {
|
|
45502
45659
|
return optionAttribute;
|
|
45503
45660
|
}
|
|
@@ -46125,10 +46282,10 @@ function addGlobalOptions(command) {
|
|
|
46125
46282
|
throw new InvalidArgumentError('Invalid value for "--output". Expected one of: rich, md, markdown, json.');
|
|
46126
46283
|
}).option("--verbose", "Print stack traces for unexpected errors.");
|
|
46127
46284
|
}
|
|
46128
|
-
function setNestedValue(target,
|
|
46285
|
+
function setNestedValue(target, path94, value) {
|
|
46129
46286
|
let cursor = target;
|
|
46130
|
-
for (let index = 0; index <
|
|
46131
|
-
const segment =
|
|
46287
|
+
for (let index = 0; index < path94.length - 1; index += 1) {
|
|
46288
|
+
const segment = path94[index] ?? "";
|
|
46132
46289
|
const existing = cursor[segment];
|
|
46133
46290
|
if (typeof existing === "object" && existing !== null) {
|
|
46134
46291
|
cursor = existing;
|
|
@@ -46138,7 +46295,7 @@ function setNestedValue(target, path93, value) {
|
|
|
46138
46295
|
cursor[segment] = next;
|
|
46139
46296
|
cursor = next;
|
|
46140
46297
|
}
|
|
46141
|
-
const leaf =
|
|
46298
|
+
const leaf = path94[path94.length - 1];
|
|
46142
46299
|
if (leaf !== void 0) {
|
|
46143
46300
|
cursor[leaf] = value;
|
|
46144
46301
|
}
|
|
@@ -46235,13 +46392,13 @@ async function withOutputFormat2(output, fn) {
|
|
|
46235
46392
|
}
|
|
46236
46393
|
function createFs3() {
|
|
46237
46394
|
return {
|
|
46238
|
-
readFile: async (
|
|
46239
|
-
writeFile: async (
|
|
46240
|
-
await writeFile15(
|
|
46395
|
+
readFile: async (path94, encoding = "utf8") => readFile23(path94, { encoding }),
|
|
46396
|
+
writeFile: async (path94, contents) => {
|
|
46397
|
+
await writeFile15(path94, contents);
|
|
46241
46398
|
},
|
|
46242
|
-
exists: async (
|
|
46399
|
+
exists: async (path94) => {
|
|
46243
46400
|
try {
|
|
46244
|
-
await access4(
|
|
46401
|
+
await access4(path94);
|
|
46245
46402
|
return true;
|
|
46246
46403
|
} catch {
|
|
46247
46404
|
return false;
|
|
@@ -46262,9 +46419,9 @@ function isPlainObject5(value) {
|
|
|
46262
46419
|
function hasFieldValue(value) {
|
|
46263
46420
|
return value !== void 0;
|
|
46264
46421
|
}
|
|
46265
|
-
function hasNestedField(fields,
|
|
46422
|
+
function hasNestedField(fields, path94) {
|
|
46266
46423
|
return fields.some(
|
|
46267
|
-
(field) =>
|
|
46424
|
+
(field) => path94.length < field.path.length && path94.every((segment, index) => field.path[index] === segment)
|
|
46268
46425
|
);
|
|
46269
46426
|
}
|
|
46270
46427
|
function describeExpectedPresetValue(schema) {
|
|
@@ -46339,7 +46496,7 @@ function validatePresetFieldValue(value, field, presetPath) {
|
|
|
46339
46496
|
async function loadPresetValues(fields, presetPath) {
|
|
46340
46497
|
let rawPreset;
|
|
46341
46498
|
try {
|
|
46342
|
-
rawPreset = await
|
|
46499
|
+
rawPreset = await readFile23(presetPath, {
|
|
46343
46500
|
encoding: "utf8"
|
|
46344
46501
|
});
|
|
46345
46502
|
} catch (error2) {
|
|
@@ -46360,9 +46517,9 @@ async function loadPresetValues(fields, presetPath) {
|
|
|
46360
46517
|
}
|
|
46361
46518
|
const fieldByPath = new Map(fields.map((field) => [field.displayPath, field]));
|
|
46362
46519
|
const presetValues = {};
|
|
46363
|
-
function visitObject(current,
|
|
46520
|
+
function visitObject(current, path94) {
|
|
46364
46521
|
for (const [key2, value] of Object.entries(current)) {
|
|
46365
|
-
const nextPath = [...
|
|
46522
|
+
const nextPath = [...path94, key2];
|
|
46366
46523
|
const displayPath2 = toDisplayPath3(nextPath);
|
|
46367
46524
|
const field = fieldByPath.get(displayPath2);
|
|
46368
46525
|
if (field !== void 0) {
|
|
@@ -46560,8 +46717,8 @@ function createFixtureService(definition) {
|
|
|
46560
46717
|
);
|
|
46561
46718
|
}
|
|
46562
46719
|
function resolveFixturePath(commandPath) {
|
|
46563
|
-
const parsed =
|
|
46564
|
-
return
|
|
46720
|
+
const parsed = path69.parse(commandPath);
|
|
46721
|
+
return path69.join(parsed.dir, `${parsed.name}.fixture.json`);
|
|
46565
46722
|
}
|
|
46566
46723
|
function selectFixtureScenario(scenarios, selector) {
|
|
46567
46724
|
if (isNumericFixtureSelector(selector)) {
|
|
@@ -46588,7 +46745,7 @@ async function loadFixtureScenario(command, selector) {
|
|
|
46588
46745
|
const fixturePath = resolveFixturePath(commandPath);
|
|
46589
46746
|
let rawFixture;
|
|
46590
46747
|
try {
|
|
46591
|
-
rawFixture = await
|
|
46748
|
+
rawFixture = await readFile23(fixturePath, {
|
|
46592
46749
|
encoding: "utf8"
|
|
46593
46750
|
});
|
|
46594
46751
|
} catch {
|
|
@@ -46684,8 +46841,8 @@ function validateServices2(services) {
|
|
|
46684
46841
|
}
|
|
46685
46842
|
}
|
|
46686
46843
|
}
|
|
46687
|
-
function getNestedValue(target,
|
|
46688
|
-
return
|
|
46844
|
+
function getNestedValue(target, path94) {
|
|
46845
|
+
return path94.reduce(
|
|
46689
46846
|
(current, segment) => current !== null && typeof current === "object" ? current[segment] : void 0,
|
|
46690
46847
|
target
|
|
46691
46848
|
);
|
|
@@ -47219,6 +47376,7 @@ async function runCLI(roots, options = {}) {
|
|
|
47219
47376
|
const casing = options.casing ?? "kebab";
|
|
47220
47377
|
const services = options.services ?? {};
|
|
47221
47378
|
const runtimeOptions = options.humanInLoop ?? {};
|
|
47379
|
+
const version = options.version ?? findEntrypointPackageMetadata(process.argv[1])?.version;
|
|
47222
47380
|
const servicesWithBuiltIns = {
|
|
47223
47381
|
...services,
|
|
47224
47382
|
runtimeOptions,
|
|
@@ -47229,7 +47387,7 @@ async function runCLI(roots, options = {}) {
|
|
|
47229
47387
|
};
|
|
47230
47388
|
validateServices2(services);
|
|
47231
47389
|
if (hasHelpFlag(process.argv)) {
|
|
47232
|
-
await renderGeneratedHelp(root, process.argv, options);
|
|
47390
|
+
await renderGeneratedHelp(root, process.argv, { ...options, version });
|
|
47233
47391
|
return;
|
|
47234
47392
|
}
|
|
47235
47393
|
const program = new CommanderCommand();
|
|
@@ -47238,8 +47396,8 @@ async function runCLI(roots, options = {}) {
|
|
|
47238
47396
|
program.showHelpAfterError();
|
|
47239
47397
|
program.addHelpCommand(false);
|
|
47240
47398
|
addGlobalOptions(program);
|
|
47241
|
-
if (
|
|
47242
|
-
program.version(
|
|
47399
|
+
if (version !== void 0) {
|
|
47400
|
+
program.version(version, "--version");
|
|
47243
47401
|
}
|
|
47244
47402
|
let lastActionCommand;
|
|
47245
47403
|
const execute2 = async (state) => {
|
|
@@ -47277,6 +47435,7 @@ var init_cli = __esm({
|
|
|
47277
47435
|
init_human_in_loop();
|
|
47278
47436
|
init_mcp_proxy();
|
|
47279
47437
|
init_number_schema();
|
|
47438
|
+
init_package_metadata();
|
|
47280
47439
|
init_renderer3();
|
|
47281
47440
|
RESERVED_SERVICE_NAMES2 = /* @__PURE__ */ new Set(["params", "secrets", "fetch", "fs", "env", "progress"]);
|
|
47282
47441
|
NULL_OPTION_VALUE = /* @__PURE__ */ Symbol("toolcraft.cli.null");
|
|
@@ -47801,7 +47960,7 @@ var init_agent2 = __esm({
|
|
|
47801
47960
|
});
|
|
47802
47961
|
|
|
47803
47962
|
// src/cli/commands/spawn.ts
|
|
47804
|
-
import
|
|
47963
|
+
import path70 from "node:path";
|
|
47805
47964
|
import { Option as Option2 } from "commander";
|
|
47806
47965
|
function registerSpawnCommand(program, container, options = {}) {
|
|
47807
47966
|
const spawnServices = container.registry.list().filter((service) => typeof service.spawn === "function" || getSpawnConfig(service.name));
|
|
@@ -48082,7 +48241,7 @@ async function resolvePromptInput(input, fs19, baseDir) {
|
|
|
48082
48241
|
if (rawPath.length === 0) {
|
|
48083
48242
|
throw new ValidationError("prompt @<path> requires a file path after '@'");
|
|
48084
48243
|
}
|
|
48085
|
-
const filePath =
|
|
48244
|
+
const filePath = path70.isAbsolute(rawPath) ? rawPath : path70.join(baseDir, rawPath);
|
|
48086
48245
|
try {
|
|
48087
48246
|
const contents = await fs19.readFile(filePath, "utf8");
|
|
48088
48247
|
return contents.trim();
|
|
@@ -48103,7 +48262,7 @@ async function resolveMcpSpawnInput(input, fs19, baseDir) {
|
|
|
48103
48262
|
if (rawPath.length === 0) {
|
|
48104
48263
|
throw new ValidationError("--mcp-servers @<path> requires a file path after '@'");
|
|
48105
48264
|
}
|
|
48106
|
-
const filePath =
|
|
48265
|
+
const filePath = path70.isAbsolute(rawPath) ? rawPath : path70.join(baseDir, rawPath);
|
|
48107
48266
|
try {
|
|
48108
48267
|
return await fs19.readFile(filePath, "utf8");
|
|
48109
48268
|
} catch (error2) {
|
|
@@ -48991,9 +49150,9 @@ var init_command_not_found = __esm({
|
|
|
48991
49150
|
|
|
48992
49151
|
// src/cli/commands/utils-symlink-ops.ts
|
|
48993
49152
|
import { dirname as dirname4 } from "node:path";
|
|
48994
|
-
async function tryLstat(fs19,
|
|
49153
|
+
async function tryLstat(fs19, path94) {
|
|
48995
49154
|
try {
|
|
48996
|
-
return await fs19.lstat(
|
|
49155
|
+
return await fs19.lstat(path94);
|
|
48997
49156
|
} catch (error2) {
|
|
48998
49157
|
if (isNotFound(error2)) {
|
|
48999
49158
|
return null;
|
|
@@ -49044,13 +49203,13 @@ async function applySymlinkOps(fs19, ops, opts) {
|
|
|
49044
49203
|
}
|
|
49045
49204
|
return { conflicts };
|
|
49046
49205
|
}
|
|
49047
|
-
async function isSymlinkPointingTo(fs19,
|
|
49206
|
+
async function isSymlinkPointingTo(fs19, path94, expectedTarget) {
|
|
49048
49207
|
try {
|
|
49049
|
-
const stats = await fs19.lstat(
|
|
49208
|
+
const stats = await fs19.lstat(path94);
|
|
49050
49209
|
if (!stats.isSymbolicLink()) {
|
|
49051
49210
|
return false;
|
|
49052
49211
|
}
|
|
49053
|
-
return await fs19.readlink(
|
|
49212
|
+
return await fs19.readlink(path94) === expectedTarget;
|
|
49054
49213
|
} catch (error2) {
|
|
49055
49214
|
if (isNotFound(error2)) {
|
|
49056
49215
|
return false;
|
|
@@ -49528,7 +49687,7 @@ var init_media_download = __esm({
|
|
|
49528
49687
|
});
|
|
49529
49688
|
|
|
49530
49689
|
// src/cli/commands/generate.ts
|
|
49531
|
-
import
|
|
49690
|
+
import path71 from "node:path";
|
|
49532
49691
|
function registerGenerateCommand(program, container) {
|
|
49533
49692
|
const generate2 = program.command("generate").alias("g").description("Generate content via Poe API.").option("--model <model>", `Model identifier (default: ${DEFAULT_TEXT_MODEL})`).option(
|
|
49534
49693
|
"--param <key=value>",
|
|
@@ -49801,11 +49960,11 @@ function getDefaultMimeType(type) {
|
|
|
49801
49960
|
return defaults[type];
|
|
49802
49961
|
}
|
|
49803
49962
|
function resolveOutputPath(filename, cwd) {
|
|
49804
|
-
if (
|
|
49963
|
+
if (path71.isAbsolute(filename)) {
|
|
49805
49964
|
return { path: filename, label: filename };
|
|
49806
49965
|
}
|
|
49807
49966
|
return {
|
|
49808
|
-
path:
|
|
49967
|
+
path: path71.join(cwd, filename),
|
|
49809
49968
|
label: `./${filename}`
|
|
49810
49969
|
};
|
|
49811
49970
|
}
|
|
@@ -50406,10 +50565,10 @@ var init_shapes = __esm({
|
|
|
50406
50565
|
});
|
|
50407
50566
|
|
|
50408
50567
|
// packages/agent-mcp-config/src/apply.ts
|
|
50409
|
-
import
|
|
50568
|
+
import path72 from "node:path";
|
|
50410
50569
|
import { parse as parseYaml6, stringify as stringifyYaml3 } from "yaml";
|
|
50411
50570
|
function getConfigDirectory(configPath) {
|
|
50412
|
-
return
|
|
50571
|
+
return path72.dirname(configPath);
|
|
50413
50572
|
}
|
|
50414
50573
|
function isConfigObject6(value) {
|
|
50415
50574
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -50429,9 +50588,9 @@ function expandHomePath(configPath, homeDir) {
|
|
|
50429
50588
|
return homeDir;
|
|
50430
50589
|
}
|
|
50431
50590
|
if (configPath.startsWith("~/")) {
|
|
50432
|
-
return
|
|
50591
|
+
return path72.join(homeDir, configPath.slice(2));
|
|
50433
50592
|
}
|
|
50434
|
-
return
|
|
50593
|
+
return path72.join(homeDir, configPath.slice(1));
|
|
50435
50594
|
}
|
|
50436
50595
|
function parseYamlDocument2(content) {
|
|
50437
50596
|
if (content.trim() === "") {
|
|
@@ -50464,7 +50623,7 @@ async function writeYamlConfig(configPath, document, options) {
|
|
|
50464
50623
|
return;
|
|
50465
50624
|
}
|
|
50466
50625
|
const absolutePath = expandHomePath(configPath, options.homeDir);
|
|
50467
|
-
const configDir =
|
|
50626
|
+
const configDir = path72.dirname(absolutePath);
|
|
50468
50627
|
await options.fs.mkdir(configDir, { recursive: true });
|
|
50469
50628
|
await options.fs.writeFile(absolutePath, serializeYamlDocument(document), {
|
|
50470
50629
|
encoding: "utf8"
|
|
@@ -51743,9 +51902,9 @@ var init_dashboard_loop_shared = __esm({
|
|
|
51743
51902
|
});
|
|
51744
51903
|
|
|
51745
51904
|
// src/cli/commands/pipeline.ts
|
|
51746
|
-
import
|
|
51747
|
-
import { readFile as
|
|
51748
|
-
import { fileURLToPath as
|
|
51905
|
+
import path73 from "node:path";
|
|
51906
|
+
import { readFile as readFile24, stat as stat18 } from "node:fs/promises";
|
|
51907
|
+
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
51749
51908
|
async function resolvePipelineCommandConfig(container) {
|
|
51750
51909
|
const [configDoc, pipelineYamlConfig] = await Promise.all([
|
|
51751
51910
|
readMergedDocument(
|
|
@@ -51802,11 +51961,11 @@ function resolveMaxRuns(value) {
|
|
|
51802
51961
|
return parsed;
|
|
51803
51962
|
}
|
|
51804
51963
|
function resolvePipelineInitSourcePath(container, sourcePath) {
|
|
51805
|
-
const absolutePath = sourcePath.startsWith("~/") ?
|
|
51964
|
+
const absolutePath = sourcePath.startsWith("~/") ? path73.join(container.env.homeDir, sourcePath.slice(2)) : path73.isAbsolute(sourcePath) ? sourcePath : path73.resolve(container.env.cwd, sourcePath);
|
|
51806
51965
|
return {
|
|
51807
51966
|
absolutePath,
|
|
51808
51967
|
relativePath: sourcePath,
|
|
51809
|
-
title:
|
|
51968
|
+
title: path73.basename(sourcePath, path73.extname(sourcePath))
|
|
51810
51969
|
};
|
|
51811
51970
|
}
|
|
51812
51971
|
function isActivityTimeoutError3(error2) {
|
|
@@ -52148,12 +52307,12 @@ async function runPipelineWithDashboard(options) {
|
|
|
52148
52307
|
}
|
|
52149
52308
|
}
|
|
52150
52309
|
function resolvePipelinePaths(scope, cwd, homeDir) {
|
|
52151
|
-
const rootPath = scope === "global" ?
|
|
52310
|
+
const rootPath = scope === "global" ? path73.join(homeDir, ".poe-code", "pipeline") : path73.join(cwd, ".poe-code", "pipeline");
|
|
52152
52311
|
const displayRoot = scope === "global" ? "~/.poe-code/pipeline" : ".poe-code/pipeline";
|
|
52153
52312
|
return {
|
|
52154
|
-
plansPath:
|
|
52155
|
-
stepsPath:
|
|
52156
|
-
legacyDefaultStepsPath:
|
|
52313
|
+
plansPath: path73.join(rootPath, "plans"),
|
|
52314
|
+
stepsPath: path73.join(rootPath, "steps.yaml"),
|
|
52315
|
+
legacyDefaultStepsPath: path73.join(rootPath, "steps", "default.yaml"),
|
|
52157
52316
|
displayPlansPath: `${displayRoot}/plans`,
|
|
52158
52317
|
displayStepsPath: `${displayRoot}/steps.yaml`
|
|
52159
52318
|
};
|
|
@@ -52162,18 +52321,18 @@ async function loadPipelineTemplates() {
|
|
|
52162
52321
|
if (pipelineTemplatesCache) {
|
|
52163
52322
|
return pipelineTemplatesCache;
|
|
52164
52323
|
}
|
|
52165
|
-
const packageRoot = await findPackageRoot3(
|
|
52324
|
+
const packageRoot = await findPackageRoot3(fileURLToPath10(import.meta.url));
|
|
52166
52325
|
const templateRoots = [
|
|
52167
|
-
|
|
52168
|
-
|
|
52326
|
+
path73.join(packageRoot, "src", "templates", "pipeline"),
|
|
52327
|
+
path73.join(packageRoot, "dist", "templates", "pipeline")
|
|
52169
52328
|
];
|
|
52170
52329
|
for (const templateRoot of templateRoots) {
|
|
52171
52330
|
if (!await pathExistsOnDisk(templateRoot)) {
|
|
52172
52331
|
continue;
|
|
52173
52332
|
}
|
|
52174
52333
|
const [skillPlan, steps] = await Promise.all([
|
|
52175
|
-
|
|
52176
|
-
|
|
52334
|
+
readFile24(path73.join(templateRoot, "SKILL_plan.md"), "utf8"),
|
|
52335
|
+
readFile24(path73.join(templateRoot, "steps.yaml.mustache"), "utf8")
|
|
52177
52336
|
]);
|
|
52178
52337
|
pipelineTemplatesCache = { skillPlan, steps };
|
|
52179
52338
|
return pipelineTemplatesCache;
|
|
@@ -52192,12 +52351,12 @@ async function pathExistsOnDisk(targetPath) {
|
|
|
52192
52351
|
}
|
|
52193
52352
|
}
|
|
52194
52353
|
async function findPackageRoot3(entryFilePath) {
|
|
52195
|
-
let currentPath =
|
|
52354
|
+
let currentPath = path73.dirname(entryFilePath);
|
|
52196
52355
|
while (true) {
|
|
52197
|
-
if (await pathExistsOnDisk(
|
|
52356
|
+
if (await pathExistsOnDisk(path73.join(currentPath, "package.json"))) {
|
|
52198
52357
|
return currentPath;
|
|
52199
52358
|
}
|
|
52200
|
-
const parentPath =
|
|
52359
|
+
const parentPath = path73.dirname(currentPath);
|
|
52201
52360
|
if (parentPath === currentPath) {
|
|
52202
52361
|
throw new Error("Unable to locate package root for Pipeline templates.");
|
|
52203
52362
|
}
|
|
@@ -52485,11 +52644,11 @@ function registerPipelineCommand(program, container) {
|
|
|
52485
52644
|
if (typeof t.status === "string") return t.status === "done";
|
|
52486
52645
|
return Object.values(t.status).every((s) => s === "done");
|
|
52487
52646
|
}).length;
|
|
52488
|
-
const
|
|
52647
|
+
const readFile38 = container.fs.readFile.bind(container.fs);
|
|
52489
52648
|
const resolvedVars = await resolvePipelineVars(
|
|
52490
52649
|
plan.vars ?? {},
|
|
52491
52650
|
container.env.cwd,
|
|
52492
|
-
|
|
52651
|
+
readFile38
|
|
52493
52652
|
);
|
|
52494
52653
|
const resolvedSetup = plan.setup === null ? void 0 : plan.setup ?? steps.setup;
|
|
52495
52654
|
const resolvedTeardown = plan.teardown === null ? void 0 : plan.teardown ?? steps.teardown;
|
|
@@ -52511,7 +52670,7 @@ function registerPipelineCommand(program, container) {
|
|
|
52511
52670
|
if (opts.preview) {
|
|
52512
52671
|
if (resolvedSetup) {
|
|
52513
52672
|
const raw = interpolatePipelineVars(resolvedSetup.prompt, resolvedVars, "setup");
|
|
52514
|
-
const expanded = await resolveFileIncludes(raw, container.env.cwd,
|
|
52673
|
+
const expanded = await resolveFileIncludes(raw, container.env.cwd, readFile38);
|
|
52515
52674
|
resources.logger.resolved("setup", expanded);
|
|
52516
52675
|
}
|
|
52517
52676
|
for (const task of plan.tasks) {
|
|
@@ -52524,7 +52683,7 @@ function registerPipelineCommand(program, container) {
|
|
|
52524
52683
|
vars: resolvedVars
|
|
52525
52684
|
}),
|
|
52526
52685
|
container.env.cwd,
|
|
52527
|
-
|
|
52686
|
+
readFile38
|
|
52528
52687
|
);
|
|
52529
52688
|
resources.logger.resolved(`task: ${task.id} \u2014 ${task.title}`, expanded);
|
|
52530
52689
|
} else {
|
|
@@ -52537,7 +52696,7 @@ function registerPipelineCommand(program, container) {
|
|
|
52537
52696
|
vars: resolvedVars
|
|
52538
52697
|
}),
|
|
52539
52698
|
container.env.cwd,
|
|
52540
|
-
|
|
52699
|
+
readFile38
|
|
52541
52700
|
);
|
|
52542
52701
|
resources.logger.resolved(`task: ${task.id} / ${stepName}`, expanded);
|
|
52543
52702
|
}
|
|
@@ -52545,7 +52704,7 @@ function registerPipelineCommand(program, container) {
|
|
|
52545
52704
|
}
|
|
52546
52705
|
if (resolvedTeardown) {
|
|
52547
52706
|
const raw = interpolatePipelineVars(resolvedTeardown.prompt, resolvedVars, "teardown");
|
|
52548
|
-
const expanded = await resolveFileIncludes(raw, container.env.cwd,
|
|
52707
|
+
const expanded = await resolveFileIncludes(raw, container.env.cwd, readFile38);
|
|
52549
52708
|
resources.logger.resolved("teardown", expanded);
|
|
52550
52709
|
}
|
|
52551
52710
|
}
|
|
@@ -52662,7 +52821,7 @@ function registerPipelineCommand(program, container) {
|
|
|
52662
52821
|
`Would ${stepsExists ? "overwrite" : "create"}: ${pipelinePaths.displayStepsPath}`
|
|
52663
52822
|
);
|
|
52664
52823
|
} else {
|
|
52665
|
-
await container.fs.mkdir(
|
|
52824
|
+
await container.fs.mkdir(path73.dirname(pipelinePaths.stepsPath), {
|
|
52666
52825
|
recursive: true
|
|
52667
52826
|
});
|
|
52668
52827
|
await container.fs.writeFile(pipelinePaths.stepsPath, templates.steps, {
|
|
@@ -52708,7 +52867,7 @@ var init_pipeline3 = __esm({
|
|
|
52708
52867
|
});
|
|
52709
52868
|
|
|
52710
52869
|
// src/cli/commands/ralph.ts
|
|
52711
|
-
import
|
|
52870
|
+
import path74 from "node:path";
|
|
52712
52871
|
function formatRalphAgentSummary(agent2) {
|
|
52713
52872
|
return Array.isArray(agent2) ? agent2.join(", ") : agent2;
|
|
52714
52873
|
}
|
|
@@ -52889,9 +53048,9 @@ function normalizeConfiguredIterations(value) {
|
|
|
52889
53048
|
}
|
|
52890
53049
|
function resolveAbsoluteDocPath(container, docPath) {
|
|
52891
53050
|
if (docPath.startsWith("~/")) {
|
|
52892
|
-
return
|
|
53051
|
+
return path74.join(container.env.homeDir, docPath.slice(2));
|
|
52893
53052
|
}
|
|
52894
|
-
return
|
|
53053
|
+
return path74.isAbsolute(docPath) ? docPath : path74.resolve(container.env.cwd, docPath);
|
|
52895
53054
|
}
|
|
52896
53055
|
async function resolveRalphCommandConfig(container) {
|
|
52897
53056
|
const configDoc = await readMergedDocument(
|
|
@@ -53286,11 +53445,11 @@ var init_ralph3 = __esm({
|
|
|
53286
53445
|
});
|
|
53287
53446
|
|
|
53288
53447
|
// src/cli/commands/experiment.ts
|
|
53289
|
-
import
|
|
53290
|
-
import { readFile as
|
|
53291
|
-
import { fileURLToPath as
|
|
53448
|
+
import path75 from "node:path";
|
|
53449
|
+
import { readFile as readFile25, stat as stat19 } from "node:fs/promises";
|
|
53450
|
+
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
53292
53451
|
function resolveExperimentPaths(scope, cwd, homeDir) {
|
|
53293
|
-
const rootPath = scope === "global" ?
|
|
53452
|
+
const rootPath = scope === "global" ? path75.join(homeDir, ".poe-code", "experiments") : path75.join(cwd, ".poe-code", "experiments");
|
|
53294
53453
|
const displayRoot = scope === "global" ? "~/.poe-code/experiments" : ".poe-code/experiments";
|
|
53295
53454
|
return {
|
|
53296
53455
|
experimentsPath: rootPath,
|
|
@@ -53309,12 +53468,12 @@ async function pathExistsOnDisk2(targetPath) {
|
|
|
53309
53468
|
}
|
|
53310
53469
|
}
|
|
53311
53470
|
async function findPackageRoot4(entryFilePath) {
|
|
53312
|
-
let currentPath =
|
|
53471
|
+
let currentPath = path75.dirname(entryFilePath);
|
|
53313
53472
|
while (true) {
|
|
53314
|
-
if (await pathExistsOnDisk2(
|
|
53473
|
+
if (await pathExistsOnDisk2(path75.join(currentPath, "package.json"))) {
|
|
53315
53474
|
return currentPath;
|
|
53316
53475
|
}
|
|
53317
|
-
const parentPath =
|
|
53476
|
+
const parentPath = path75.dirname(currentPath);
|
|
53318
53477
|
if (parentPath === currentPath) {
|
|
53319
53478
|
throw new Error("Unable to locate package root for Experiment templates.");
|
|
53320
53479
|
}
|
|
@@ -53325,18 +53484,18 @@ async function loadExperimentTemplates() {
|
|
|
53325
53484
|
if (experimentTemplatesCache) {
|
|
53326
53485
|
return experimentTemplatesCache;
|
|
53327
53486
|
}
|
|
53328
|
-
const packageRoot = await findPackageRoot4(
|
|
53487
|
+
const packageRoot = await findPackageRoot4(fileURLToPath11(import.meta.url));
|
|
53329
53488
|
const templateRoots = [
|
|
53330
|
-
|
|
53331
|
-
|
|
53489
|
+
path75.join(packageRoot, "src", "templates", "experiment"),
|
|
53490
|
+
path75.join(packageRoot, "dist", "templates", "experiment")
|
|
53332
53491
|
];
|
|
53333
53492
|
for (const templateRoot of templateRoots) {
|
|
53334
53493
|
if (!await pathExistsOnDisk2(templateRoot)) {
|
|
53335
53494
|
continue;
|
|
53336
53495
|
}
|
|
53337
53496
|
const [skillPlan, runYaml] = await Promise.all([
|
|
53338
|
-
|
|
53339
|
-
|
|
53497
|
+
readFile25(path75.join(templateRoot, "SKILL_experiment.md"), "utf8"),
|
|
53498
|
+
readFile25(path75.join(templateRoot, "run.yaml.mustache"), "utf8")
|
|
53340
53499
|
]);
|
|
53341
53500
|
experimentTemplatesCache = { skillPlan, runYaml };
|
|
53342
53501
|
return experimentTemplatesCache;
|
|
@@ -54030,8 +54189,8 @@ function registerExperimentCommand(program, container) {
|
|
|
54030
54189
|
resources.logger.info(`Create: ${experimentPaths.displayExperimentsPath}`);
|
|
54031
54190
|
}
|
|
54032
54191
|
}
|
|
54033
|
-
const runYamlPath =
|
|
54034
|
-
const runYamlDisplayPath =
|
|
54192
|
+
const runYamlPath = path75.join(experimentPaths.experimentsPath, "run.yaml");
|
|
54193
|
+
const runYamlDisplayPath = path75.join(experimentPaths.displayExperimentsPath, "run.yaml");
|
|
54035
54194
|
if (!await pathExists6(container.fs, runYamlPath)) {
|
|
54036
54195
|
if (flags.dryRun) {
|
|
54037
54196
|
resources.logger.dryRun(`Would create: ${runYamlDisplayPath}`);
|
|
@@ -54494,9 +54653,9 @@ var init_launch2 = __esm({
|
|
|
54494
54653
|
});
|
|
54495
54654
|
|
|
54496
54655
|
// packages/memory/src/paths.ts
|
|
54497
|
-
import
|
|
54656
|
+
import path76 from "node:path";
|
|
54498
54657
|
function resolveMemoryRoot(cwd) {
|
|
54499
|
-
return
|
|
54658
|
+
return path76.resolve(cwd, ".poe-code", "memory");
|
|
54500
54659
|
}
|
|
54501
54660
|
function assertSafeRelPath(input) {
|
|
54502
54661
|
const trimmed = input.trim();
|
|
@@ -54504,10 +54663,10 @@ function assertSafeRelPath(input) {
|
|
|
54504
54663
|
throw new MemoryPathError("Expected a non-empty relative path.");
|
|
54505
54664
|
}
|
|
54506
54665
|
const slashNormalized = trimmed.replaceAll("\\", "/");
|
|
54507
|
-
if (
|
|
54666
|
+
if (path76.posix.isAbsolute(slashNormalized) || path76.win32.isAbsolute(slashNormalized)) {
|
|
54508
54667
|
throw new MemoryPathError(`Expected a relative path, received absolute path "${input}".`);
|
|
54509
54668
|
}
|
|
54510
|
-
const normalized =
|
|
54669
|
+
const normalized = path76.posix.normalize(slashNormalized);
|
|
54511
54670
|
if (normalized === "." || normalized.length === 0) {
|
|
54512
54671
|
throw new MemoryPathError("Expected a relative path to a file or directory.");
|
|
54513
54672
|
}
|
|
@@ -54536,7 +54695,7 @@ var init_paths2 = __esm({
|
|
|
54536
54695
|
});
|
|
54537
54696
|
|
|
54538
54697
|
// packages/memory/src/resolve-root.ts
|
|
54539
|
-
import
|
|
54698
|
+
import path77 from "node:path";
|
|
54540
54699
|
async function resolveConfiguredMemoryRoot(options) {
|
|
54541
54700
|
const envOverride = options.env[MEMORY_ROOT_ENV_VAR]?.trim();
|
|
54542
54701
|
if (envOverride && envOverride.length > 0) {
|
|
@@ -54553,7 +54712,7 @@ async function resolveConfiguredMemoryRoot(options) {
|
|
|
54553
54712
|
return resolveMemoryRoot(options.cwd);
|
|
54554
54713
|
}
|
|
54555
54714
|
function resolveAgainstCwd(cwd, value) {
|
|
54556
|
-
return
|
|
54715
|
+
return path77.isAbsolute(value) ? value : path77.resolve(cwd, value);
|
|
54557
54716
|
}
|
|
54558
54717
|
var MEMORY_ROOT_ENV_VAR;
|
|
54559
54718
|
var init_resolve_root = __esm({
|
|
@@ -54567,11 +54726,11 @@ var init_resolve_root = __esm({
|
|
|
54567
54726
|
|
|
54568
54727
|
// packages/memory/src/init.ts
|
|
54569
54728
|
import * as fs5 from "node:fs/promises";
|
|
54570
|
-
import
|
|
54729
|
+
import path78 from "node:path";
|
|
54571
54730
|
async function initMemory(root) {
|
|
54572
|
-
await fs5.mkdir(
|
|
54573
|
-
await writeFileIfMissing(
|
|
54574
|
-
await writeFileIfMissing(
|
|
54731
|
+
await fs5.mkdir(path78.join(root, MEMORY_PAGES_DIR_RELPATH), { recursive: true });
|
|
54732
|
+
await writeFileIfMissing(path78.join(root, MEMORY_INDEX_RELPATH), "# Memory index\n");
|
|
54733
|
+
await writeFileIfMissing(path78.join(root, MEMORY_LOG_RELPATH), "");
|
|
54575
54734
|
}
|
|
54576
54735
|
async function writeFileIfMissing(filePath, content) {
|
|
54577
54736
|
try {
|
|
@@ -54770,10 +54929,10 @@ function parseSources(value) {
|
|
|
54770
54929
|
if (!isRecord22(item)) {
|
|
54771
54930
|
throw new Error('Invalid "sources" frontmatter. Expected each source to be a string or object.');
|
|
54772
54931
|
}
|
|
54773
|
-
const
|
|
54932
|
+
const path94 = readRequiredString(item.path, "sources[].path");
|
|
54774
54933
|
const startLine = readOptionalPositiveInteger(item.startLine, "sources[].startLine");
|
|
54775
54934
|
const endLine = readOptionalPositiveInteger(item.endLine, "sources[].endLine");
|
|
54776
|
-
return parseSourceRef(serializeSourceRef({ path:
|
|
54935
|
+
return parseSourceRef(serializeSourceRef({ path: path94, ...startLine === void 0 ? {} : { startLine }, ...endLine === void 0 ? {} : { endLine } }));
|
|
54777
54936
|
});
|
|
54778
54937
|
}
|
|
54779
54938
|
function readOptionalString3(value, field) {
|
|
@@ -54817,7 +54976,7 @@ var init_frontmatter5 = __esm({
|
|
|
54817
54976
|
|
|
54818
54977
|
// packages/memory/src/pages.ts
|
|
54819
54978
|
import * as fs6 from "node:fs/promises";
|
|
54820
|
-
import
|
|
54979
|
+
import path79 from "node:path";
|
|
54821
54980
|
async function listPages(root) {
|
|
54822
54981
|
const relPaths = await collectMarkdownRelPaths(root, MEMORY_PAGES_DIR_RELPATH);
|
|
54823
54982
|
const pages = await Promise.all(relPaths.map(async (relPath) => readPage(root, relPath)));
|
|
@@ -54825,7 +54984,7 @@ async function listPages(root) {
|
|
|
54825
54984
|
}
|
|
54826
54985
|
async function readPage(root, relPath) {
|
|
54827
54986
|
const normalizedRelPath = assertMarkdownRelPath(relPath);
|
|
54828
|
-
const absPath =
|
|
54987
|
+
const absPath = path79.join(root, normalizedRelPath);
|
|
54829
54988
|
const [content, stat24] = await Promise.all([fs6.readFile(absPath, "utf8"), fs6.stat(absPath)]);
|
|
54830
54989
|
try {
|
|
54831
54990
|
const parsed = parseFrontmatter4(content);
|
|
@@ -54854,7 +55013,7 @@ async function collectMarkdownRelPaths(root, startRelPath = "") {
|
|
|
54854
55013
|
return relPaths.sort((left, right) => left.localeCompare(right));
|
|
54855
55014
|
}
|
|
54856
55015
|
async function collectMarkdownRelPathsInto(root, currentRelPath, relPaths) {
|
|
54857
|
-
const absPath =
|
|
55016
|
+
const absPath = path79.join(root, currentRelPath);
|
|
54858
55017
|
let entryNames;
|
|
54859
55018
|
try {
|
|
54860
55019
|
entryNames = await fs6.readdir(absPath);
|
|
@@ -54865,8 +55024,8 @@ async function collectMarkdownRelPathsInto(root, currentRelPath, relPaths) {
|
|
|
54865
55024
|
throw error2;
|
|
54866
55025
|
}
|
|
54867
55026
|
for (const entryName of entryNames.sort((left, right) => left.localeCompare(right))) {
|
|
54868
|
-
const entryRelPath = currentRelPath.length === 0 ? entryName :
|
|
54869
|
-
const entryAbsPath =
|
|
55027
|
+
const entryRelPath = currentRelPath.length === 0 ? entryName : path79.posix.join(currentRelPath, entryName);
|
|
55028
|
+
const entryAbsPath = path79.join(root, entryRelPath);
|
|
54870
55029
|
const entryStat = await fs6.stat(entryAbsPath);
|
|
54871
55030
|
if (entryStat.isDirectory()) {
|
|
54872
55031
|
if (entryName === MEMORY_CACHE_DIR_RELPATH) {
|
|
@@ -54896,7 +55055,7 @@ function assertMarkdownRelPath(relPath) {
|
|
|
54896
55055
|
return normalizedRelPath;
|
|
54897
55056
|
}
|
|
54898
55057
|
function isMarkdownPath(relPath) {
|
|
54899
|
-
return
|
|
55058
|
+
return path79.posix.extname(relPath).toLowerCase() === ".md";
|
|
54900
55059
|
}
|
|
54901
55060
|
function isMissing(error2) {
|
|
54902
55061
|
return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
|
|
@@ -54911,7 +55070,7 @@ var init_pages = __esm({
|
|
|
54911
55070
|
|
|
54912
55071
|
// packages/memory/src/search.ts
|
|
54913
55072
|
import * as fs7 from "node:fs/promises";
|
|
54914
|
-
import
|
|
55073
|
+
import path80 from "node:path";
|
|
54915
55074
|
async function searchMemory(root, query) {
|
|
54916
55075
|
const normalizedQuery = query.trim();
|
|
54917
55076
|
if (normalizedQuery.length === 0) {
|
|
@@ -54920,7 +55079,7 @@ async function searchMemory(root, query) {
|
|
|
54920
55079
|
const relPaths = await collectMarkdownRelPaths(root);
|
|
54921
55080
|
const hits = [];
|
|
54922
55081
|
for (const relPath of relPaths) {
|
|
54923
|
-
const content = await fs7.readFile(
|
|
55082
|
+
const content = await fs7.readFile(path80.join(root, relPath), "utf8");
|
|
54924
55083
|
if (content.length === 0) {
|
|
54925
55084
|
continue;
|
|
54926
55085
|
}
|
|
@@ -54947,7 +55106,7 @@ var init_search = __esm({
|
|
|
54947
55106
|
|
|
54948
55107
|
// packages/memory/src/status.ts
|
|
54949
55108
|
import * as fs8 from "node:fs/promises";
|
|
54950
|
-
import
|
|
55109
|
+
import path81 from "node:path";
|
|
54951
55110
|
async function statusOf(root) {
|
|
54952
55111
|
if (!await pathExists7(root)) {
|
|
54953
55112
|
return {
|
|
@@ -54964,7 +55123,7 @@ async function statusOf(root) {
|
|
|
54964
55123
|
let totalBytes = 0;
|
|
54965
55124
|
let lastWriteAtMs = Number.NEGATIVE_INFINITY;
|
|
54966
55125
|
for (const relPath of markdownRelPaths) {
|
|
54967
|
-
const stat24 = await fs8.stat(
|
|
55126
|
+
const stat24 = await fs8.stat(path81.join(root, relPath));
|
|
54968
55127
|
totalBytes += stat24.size;
|
|
54969
55128
|
lastWriteAtMs = Math.max(lastWriteAtMs, stat24.mtimeMs);
|
|
54970
55129
|
}
|
|
@@ -54996,7 +55155,7 @@ var init_status = __esm({
|
|
|
54996
55155
|
|
|
54997
55156
|
// packages/memory/src/lock.ts
|
|
54998
55157
|
import * as fsPromises20 from "node:fs/promises";
|
|
54999
|
-
import
|
|
55158
|
+
import path82 from "node:path";
|
|
55000
55159
|
function createDefaultFs13() {
|
|
55001
55160
|
return {
|
|
55002
55161
|
readFile: (filePath, encoding) => fsPromises20.readFile(filePath, encoding),
|
|
@@ -55026,7 +55185,7 @@ function parsePid(input) {
|
|
|
55026
55185
|
const pid = Number.parseInt(value, 10);
|
|
55027
55186
|
return Number.isSafeInteger(pid) && pid > 0 ? pid : void 0;
|
|
55028
55187
|
}
|
|
55029
|
-
function
|
|
55188
|
+
function isPidRunning2(pid) {
|
|
55030
55189
|
try {
|
|
55031
55190
|
process.kill(pid, 0);
|
|
55032
55191
|
return true;
|
|
@@ -55055,12 +55214,12 @@ async function readLockPid(fs19, lockPath) {
|
|
|
55055
55214
|
}
|
|
55056
55215
|
async function withLock(root, run, options = {}) {
|
|
55057
55216
|
const fs19 = options.fs ?? createDefaultFs13();
|
|
55058
|
-
const lockPath =
|
|
55217
|
+
const lockPath = path82.join(root, MEMORY_LOCK_RELPATH);
|
|
55059
55218
|
const pid = options.pid ?? process.pid;
|
|
55060
55219
|
const retries = options.retries ?? 20;
|
|
55061
55220
|
const minTimeoutMs = options.minTimeoutMs ?? 25;
|
|
55062
55221
|
const maxTimeoutMs = options.maxTimeoutMs ?? 250;
|
|
55063
|
-
const pidIsRunning = options.isPidRunning ??
|
|
55222
|
+
const pidIsRunning = options.isPidRunning ?? isPidRunning2;
|
|
55064
55223
|
for (let attempt = 0; attempt <= retries; attempt += 1) {
|
|
55065
55224
|
try {
|
|
55066
55225
|
await fs19.writeFile(lockPath, `${pid}
|
|
@@ -55278,13 +55437,13 @@ var init_confidence = __esm({
|
|
|
55278
55437
|
// packages/memory/src/reconcile.ts
|
|
55279
55438
|
import { createHash } from "node:crypto";
|
|
55280
55439
|
import * as fs9 from "node:fs/promises";
|
|
55281
|
-
import
|
|
55440
|
+
import path83 from "node:path";
|
|
55282
55441
|
async function snapshot(root) {
|
|
55283
55442
|
const pages = Object.fromEntries(
|
|
55284
55443
|
await Promise.all(
|
|
55285
55444
|
(await collectMarkdownRelPaths(root, MEMORY_PAGES_DIR_RELPATH)).map(async (relPath) => [
|
|
55286
55445
|
relPath,
|
|
55287
|
-
hashContent(await fs9.readFile(
|
|
55446
|
+
hashContent(await fs9.readFile(path83.join(root, relPath), "utf8"))
|
|
55288
55447
|
])
|
|
55289
55448
|
)
|
|
55290
55449
|
);
|
|
@@ -55295,7 +55454,7 @@ async function reconcile(root, before, _verb, detail) {
|
|
|
55295
55454
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
55296
55455
|
const currentPages = await Promise.all(
|
|
55297
55456
|
(await collectMarkdownRelPaths(root, MEMORY_PAGES_DIR_RELPATH)).map(async (relPath) => {
|
|
55298
|
-
const absPath =
|
|
55457
|
+
const absPath = path83.join(root, relPath);
|
|
55299
55458
|
const markdown = await fs9.readFile(absPath, "utf8");
|
|
55300
55459
|
const parsed = parsePageMarkdown(relPath, markdown);
|
|
55301
55460
|
const normalizedFrontmatter = withDenormalizedSources(parsed.frontmatter, parsed.body);
|
|
@@ -55317,7 +55476,7 @@ async function reconcile(root, before, _verb, detail) {
|
|
|
55317
55476
|
})
|
|
55318
55477
|
);
|
|
55319
55478
|
await Promise.all(
|
|
55320
|
-
currentPages.filter((page) => page.currentMarkdown !== page.nextMarkdown).map((page) => fs9.writeFile(
|
|
55479
|
+
currentPages.filter((page) => page.currentMarkdown !== page.nextMarkdown).map((page) => fs9.writeFile(path83.join(root, page.relPath), page.nextMarkdown, "utf8"))
|
|
55321
55480
|
);
|
|
55322
55481
|
const diff2 = diffSnapshots(before, await snapshot(root));
|
|
55323
55482
|
await writeIndex(root);
|
|
@@ -55347,7 +55506,7 @@ async function appendLogEntries(root, diff2, detail, timestamp = (/* @__PURE__ *
|
|
|
55347
55506
|
if (entries.length === 0) {
|
|
55348
55507
|
return;
|
|
55349
55508
|
}
|
|
55350
|
-
const logPath =
|
|
55509
|
+
const logPath = path83.join(root, MEMORY_LOG_RELPATH);
|
|
55351
55510
|
const existing = await fs9.readFile(logPath, "utf8");
|
|
55352
55511
|
const separator = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
55353
55512
|
await fs9.writeFile(logPath, `${existing}${separator}${entries.join("\n")}
|
|
@@ -55371,7 +55530,7 @@ async function writeIndex(root) {
|
|
|
55371
55530
|
description: page.frontmatter.description ?? ""
|
|
55372
55531
|
}))
|
|
55373
55532
|
);
|
|
55374
|
-
await fs9.writeFile(
|
|
55533
|
+
await fs9.writeFile(path83.join(root, MEMORY_INDEX_RELPATH), index, "utf8");
|
|
55375
55534
|
}
|
|
55376
55535
|
function parsePageMarkdown(relPath, markdown) {
|
|
55377
55536
|
try {
|
|
@@ -55423,14 +55582,14 @@ var init_reconcile = __esm({
|
|
|
55423
55582
|
|
|
55424
55583
|
// packages/memory/src/write.ts
|
|
55425
55584
|
import * as fs10 from "node:fs/promises";
|
|
55426
|
-
import
|
|
55585
|
+
import path84 from "node:path";
|
|
55427
55586
|
async function writePage(root, relPath, body, opts) {
|
|
55428
55587
|
const pageRelPath = assertPageRelPath(relPath);
|
|
55429
55588
|
return withLock(root, async () => {
|
|
55430
55589
|
const before = await snapshot(root);
|
|
55431
|
-
await fs10.mkdir(
|
|
55590
|
+
await fs10.mkdir(path84.dirname(path84.join(root, pageRelPath)), { recursive: true });
|
|
55432
55591
|
await fs10.writeFile(
|
|
55433
|
-
|
|
55592
|
+
path84.join(root, pageRelPath),
|
|
55434
55593
|
serializeFrontmatter(opts.frontmatter ?? {}, body),
|
|
55435
55594
|
"utf8"
|
|
55436
55595
|
);
|
|
@@ -55441,8 +55600,8 @@ async function appendToPage(root, relPath, content, opts) {
|
|
|
55441
55600
|
const pageRelPath = assertPageRelPath(relPath);
|
|
55442
55601
|
return withLock(root, async () => {
|
|
55443
55602
|
const before = await snapshot(root);
|
|
55444
|
-
const pagePath =
|
|
55445
|
-
await fs10.mkdir(
|
|
55603
|
+
const pagePath = path84.join(root, pageRelPath);
|
|
55604
|
+
await fs10.mkdir(path84.dirname(pagePath), { recursive: true });
|
|
55446
55605
|
const existing = await readMarkdownIfPresent(pagePath);
|
|
55447
55606
|
const parsed = existing === void 0 ? { frontmatter: {}, body: "" } : parseFrontmatter4(existing);
|
|
55448
55607
|
await fs10.writeFile(
|
|
@@ -55464,7 +55623,7 @@ async function removeChildren(directoryPath) {
|
|
|
55464
55623
|
if (entryName === MEMORY_LOCK_RELPATH) {
|
|
55465
55624
|
continue;
|
|
55466
55625
|
}
|
|
55467
|
-
const entryPath =
|
|
55626
|
+
const entryPath = path84.join(directoryPath, entryName);
|
|
55468
55627
|
const stat24 = await fs10.stat(entryPath);
|
|
55469
55628
|
if (stat24.isDirectory()) {
|
|
55470
55629
|
await removeDirectory3(entryPath);
|
|
@@ -55481,7 +55640,7 @@ async function removeDirectory3(directoryPath) {
|
|
|
55481
55640
|
}
|
|
55482
55641
|
function assertPageRelPath(relPath) {
|
|
55483
55642
|
const normalizedRelPath = assertSafeRelPath(relPath);
|
|
55484
|
-
if (!normalizedRelPath.startsWith(`${MEMORY_PAGES_DIR_RELPATH}/`) ||
|
|
55643
|
+
if (!normalizedRelPath.startsWith(`${MEMORY_PAGES_DIR_RELPATH}/`) || path84.posix.extname(normalizedRelPath).toLowerCase() !== ".md") {
|
|
55485
55644
|
throw new Error(`Expected a markdown page path under "${MEMORY_PAGES_DIR_RELPATH}/".`);
|
|
55486
55645
|
}
|
|
55487
55646
|
return normalizedRelPath;
|
|
@@ -55509,7 +55668,7 @@ var init_write2 = __esm({
|
|
|
55509
55668
|
|
|
55510
55669
|
// packages/memory/src/edit.ts
|
|
55511
55670
|
import * as fs11 from "node:fs/promises";
|
|
55512
|
-
import
|
|
55671
|
+
import path85 from "node:path";
|
|
55513
55672
|
var init_edit = __esm({
|
|
55514
55673
|
"packages/memory/src/edit.ts"() {
|
|
55515
55674
|
"use strict";
|
|
@@ -55520,7 +55679,7 @@ var init_edit = __esm({
|
|
|
55520
55679
|
|
|
55521
55680
|
// packages/memory/src/audit.ts
|
|
55522
55681
|
import * as fs12 from "node:fs/promises";
|
|
55523
|
-
import
|
|
55682
|
+
import path86 from "node:path";
|
|
55524
55683
|
async function auditClaims(root, repoRoot, options = {}) {
|
|
55525
55684
|
const minInferredConfidence = options.minInferredConfidence ?? DEFAULT_MIN_INFERRED_CONFIDENCE;
|
|
55526
55685
|
const rejectUntagged = options.rejectUntagged ?? DEFAULT_REJECT_UNTAGGED;
|
|
@@ -55572,10 +55731,10 @@ async function auditSourceRef(source, claimLineNumber, repoRoot, sourceCache) {
|
|
|
55572
55731
|
if (isUrlLike(source.path)) {
|
|
55573
55732
|
return void 0;
|
|
55574
55733
|
}
|
|
55575
|
-
if (
|
|
55734
|
+
if (path86.isAbsolute(source.path)) {
|
|
55576
55735
|
return `Claim on line ${claimLineNumber} cites "${serializeSourceRef(source)}", but source paths must be repo-relative or URLs.`;
|
|
55577
55736
|
}
|
|
55578
|
-
const absPath =
|
|
55737
|
+
const absPath = path86.resolve(repoRoot, source.path);
|
|
55579
55738
|
if (!isWithinRoot(repoRoot, absPath)) {
|
|
55580
55739
|
return `Claim on line ${claimLineNumber} cites "${serializeSourceRef(source)}", which resolves outside the repo root.`;
|
|
55581
55740
|
}
|
|
@@ -55641,8 +55800,8 @@ function isUrlLike(value) {
|
|
|
55641
55800
|
return /^[a-z][a-z\d+.-]*:\/\//i.test(value);
|
|
55642
55801
|
}
|
|
55643
55802
|
function isWithinRoot(root, absPath) {
|
|
55644
|
-
const relative =
|
|
55645
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
55803
|
+
const relative = path86.relative(root, absPath);
|
|
55804
|
+
return relative === "" || !relative.startsWith("..") && !path86.isAbsolute(relative);
|
|
55646
55805
|
}
|
|
55647
55806
|
var DEFAULT_MIN_INFERRED_CONFIDENCE, DEFAULT_REJECT_UNTAGGED, DEFAULT_UNTAGGED_BODY_THRESHOLD_CHARS;
|
|
55648
55807
|
var init_audit = __esm({
|
|
@@ -55660,7 +55819,7 @@ var init_audit = __esm({
|
|
|
55660
55819
|
// packages/memory/src/cache.ts
|
|
55661
55820
|
import { createHash as createHash2 } from "node:crypto";
|
|
55662
55821
|
import * as fs13 from "node:fs/promises";
|
|
55663
|
-
import
|
|
55822
|
+
import path87 from "node:path";
|
|
55664
55823
|
function computeIngestKey(input) {
|
|
55665
55824
|
const hash = createHash2("sha256");
|
|
55666
55825
|
hash.update(input.sourceBytes);
|
|
@@ -55673,7 +55832,7 @@ function computeIngestKey(input) {
|
|
|
55673
55832
|
return hash.digest("hex");
|
|
55674
55833
|
}
|
|
55675
55834
|
async function readCacheEntry(root, key2) {
|
|
55676
|
-
const cachePath =
|
|
55835
|
+
const cachePath = path87.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH, `${key2}.json`);
|
|
55677
55836
|
let raw;
|
|
55678
55837
|
try {
|
|
55679
55838
|
raw = await fs13.readFile(cachePath, "utf8");
|
|
@@ -55692,9 +55851,9 @@ async function readCacheEntry(root, key2) {
|
|
|
55692
55851
|
}
|
|
55693
55852
|
}
|
|
55694
55853
|
async function writeCacheEntry(root, entry) {
|
|
55695
|
-
await fs13.mkdir(
|
|
55854
|
+
await fs13.mkdir(path87.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH), { recursive: true });
|
|
55696
55855
|
await fs13.writeFile(
|
|
55697
|
-
|
|
55856
|
+
path87.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH, `${entry.key}.json`),
|
|
55698
55857
|
`${JSON.stringify(entry)}
|
|
55699
55858
|
`,
|
|
55700
55859
|
"utf8"
|
|
@@ -55810,9 +55969,9 @@ var init_tokenizer = __esm({
|
|
|
55810
55969
|
});
|
|
55811
55970
|
|
|
55812
55971
|
// packages/tokenfill/src/corpus.ts
|
|
55813
|
-
import { readdirSync, readFileSync as
|
|
55972
|
+
import { readdirSync, readFileSync as readFileSync3 } from "node:fs";
|
|
55814
55973
|
import { dirname as dirname5, join as join5 } from "node:path";
|
|
55815
|
-
import { fileURLToPath as
|
|
55974
|
+
import { fileURLToPath as fileURLToPath12 } from "node:url";
|
|
55816
55975
|
function getCorpusFileNames() {
|
|
55817
55976
|
return readdirSync(corpusDirectoryPath, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => entry.name).sort((left, right) => left.localeCompare(right));
|
|
55818
55977
|
}
|
|
@@ -55821,14 +55980,14 @@ function loadBuiltInCorpusArticles() {
|
|
|
55821
55980
|
if (corpusFileNames.length === 0) {
|
|
55822
55981
|
throw new Error(`No built-in corpus markdown files found in ${corpusDirectoryPath}`);
|
|
55823
55982
|
}
|
|
55824
|
-
return corpusFileNames.map((fileName) =>
|
|
55983
|
+
return corpusFileNames.map((fileName) => readFileSync3(join5(corpusDirectoryPath, fileName), "utf8").trim());
|
|
55825
55984
|
}
|
|
55826
55985
|
var CORPUS_ARTICLE_SEPARATOR, corpusDirectoryPath, BUILT_IN_CORPUS_ARTICLES;
|
|
55827
55986
|
var init_corpus = __esm({
|
|
55828
55987
|
"packages/tokenfill/src/corpus.ts"() {
|
|
55829
55988
|
"use strict";
|
|
55830
55989
|
CORPUS_ARTICLE_SEPARATOR = "\n\n";
|
|
55831
|
-
corpusDirectoryPath = join5(dirname5(
|
|
55990
|
+
corpusDirectoryPath = join5(dirname5(fileURLToPath12(import.meta.url)), "corpus");
|
|
55832
55991
|
BUILT_IN_CORPUS_ARTICLES = loadBuiltInCorpusArticles();
|
|
55833
55992
|
}
|
|
55834
55993
|
});
|
|
@@ -55856,7 +56015,7 @@ var init_src33 = __esm({
|
|
|
55856
56015
|
|
|
55857
56016
|
// packages/memory/src/tokens.ts
|
|
55858
56017
|
import * as fs14 from "node:fs/promises";
|
|
55859
|
-
import
|
|
56018
|
+
import path88 from "node:path";
|
|
55860
56019
|
async function computeTokenStats(root) {
|
|
55861
56020
|
if (!await pathExists8(root)) {
|
|
55862
56021
|
return {
|
|
@@ -55878,11 +56037,11 @@ async function computeTokenStats(root) {
|
|
|
55878
56037
|
}
|
|
55879
56038
|
}
|
|
55880
56039
|
}
|
|
55881
|
-
const repoRoot =
|
|
56040
|
+
const repoRoot = path88.resolve(root, "..", "..");
|
|
55882
56041
|
let sourceTokens = 0;
|
|
55883
56042
|
const missingSources = [];
|
|
55884
56043
|
for (const sourcePath of sourcePaths) {
|
|
55885
|
-
const absPath =
|
|
56044
|
+
const absPath = path88.isAbsolute(sourcePath) ? sourcePath : path88.resolve(repoRoot, sourcePath);
|
|
55886
56045
|
try {
|
|
55887
56046
|
const content = await fs14.readFile(absPath, "utf8");
|
|
55888
56047
|
sourceTokens += countTokens(content);
|
|
@@ -55927,7 +56086,7 @@ var init_tokens2 = __esm({
|
|
|
55927
56086
|
|
|
55928
56087
|
// packages/memory/src/ingest.ts
|
|
55929
56088
|
import * as fs15 from "node:fs/promises";
|
|
55930
|
-
import
|
|
56089
|
+
import path89 from "node:path";
|
|
55931
56090
|
function resolveRunners2(overrides) {
|
|
55932
56091
|
return {
|
|
55933
56092
|
computeIngestKey: overrides?.computeIngestKey ?? computeIngestKey,
|
|
@@ -55941,10 +56100,10 @@ function resolveRunners2(overrides) {
|
|
|
55941
56100
|
async function ingest(root, opts, runners) {
|
|
55942
56101
|
const resolved = resolveRunners2(runners);
|
|
55943
56102
|
const source = await materializeSource(opts.source);
|
|
55944
|
-
const indexMdBytes = await fs15.readFile(
|
|
56103
|
+
const indexMdBytes = await fs15.readFile(path89.join(root, MEMORY_INDEX_RELPATH));
|
|
55945
56104
|
const configOptions = {
|
|
55946
56105
|
fs: fs15,
|
|
55947
|
-
filePath:
|
|
56106
|
+
filePath: path89.join(inferRepoRoot(root), "poe-code.json")
|
|
55948
56107
|
};
|
|
55949
56108
|
const agentId = await resolveAgent(configOptions, opts.agent ?? null) ?? opts.agent ?? "claude-code";
|
|
55950
56109
|
const key2 = resolved.computeIngestKey({
|
|
@@ -56034,7 +56193,7 @@ async function materializeSource(source) {
|
|
|
56034
56193
|
throw new Error("URL ingest not implemented yet.");
|
|
56035
56194
|
}
|
|
56036
56195
|
function inferRepoRoot(root) {
|
|
56037
|
-
return
|
|
56196
|
+
return path89.resolve(root, "..", "..");
|
|
56038
56197
|
}
|
|
56039
56198
|
async function runWithTimeout(promise, timeoutMs) {
|
|
56040
56199
|
return await new Promise((resolve2, reject) => {
|
|
@@ -56086,7 +56245,7 @@ var init_install3 = __esm({
|
|
|
56086
56245
|
|
|
56087
56246
|
// packages/memory/src/query.ts
|
|
56088
56247
|
import * as fs16 from "node:fs/promises";
|
|
56089
|
-
import
|
|
56248
|
+
import path90 from "node:path";
|
|
56090
56249
|
async function queryMemory(root, options) {
|
|
56091
56250
|
const pages = await listPages(root);
|
|
56092
56251
|
if (pages.length === 0) {
|
|
@@ -56100,7 +56259,7 @@ async function queryMemory(root, options) {
|
|
|
56100
56259
|
}
|
|
56101
56260
|
const configOptions = {
|
|
56102
56261
|
fs: fs16,
|
|
56103
|
-
filePath:
|
|
56262
|
+
filePath: path90.join(inferRepoRoot2(root), "poe-code.json")
|
|
56104
56263
|
};
|
|
56105
56264
|
const agentId = await resolveAgent(configOptions, options.agent ?? null) ?? options.agent ?? "claude-code";
|
|
56106
56265
|
const context = await selectQueryContext(root, options.question, options.budget);
|
|
@@ -56115,7 +56274,7 @@ async function queryMemory(root, options) {
|
|
|
56115
56274
|
}
|
|
56116
56275
|
async function selectQueryContext(root, question, budget) {
|
|
56117
56276
|
const [indexText, pages] = await Promise.all([
|
|
56118
|
-
fs16.readFile(
|
|
56277
|
+
fs16.readFile(path90.join(root, MEMORY_INDEX_RELPATH), "utf8"),
|
|
56119
56278
|
listPages(root)
|
|
56120
56279
|
]);
|
|
56121
56280
|
const indexTokens = countTokens(indexText);
|
|
@@ -56194,7 +56353,7 @@ function tokenize2(text4) {
|
|
|
56194
56353
|
return text4.toLowerCase().split(/[^a-z0-9]+/).filter((token) => token.length > 0);
|
|
56195
56354
|
}
|
|
56196
56355
|
function inferRepoRoot2(root) {
|
|
56197
|
-
return
|
|
56356
|
+
return path90.resolve(root, "..", "..");
|
|
56198
56357
|
}
|
|
56199
56358
|
var init_query = __esm({
|
|
56200
56359
|
"packages/memory/src/query.ts"() {
|
|
@@ -56209,7 +56368,7 @@ var init_query = __esm({
|
|
|
56209
56368
|
|
|
56210
56369
|
// packages/memory/src/explain.ts
|
|
56211
56370
|
import * as fs17 from "node:fs/promises";
|
|
56212
|
-
import
|
|
56371
|
+
import path91 from "node:path";
|
|
56213
56372
|
async function explainPage(root, options) {
|
|
56214
56373
|
const targetPage = await readPageIfPresent(root, options.relPath);
|
|
56215
56374
|
if (targetPage === void 0) {
|
|
@@ -56232,7 +56391,7 @@ async function explainPage(root, options) {
|
|
|
56232
56391
|
}
|
|
56233
56392
|
const configOptions = {
|
|
56234
56393
|
fs: fs17,
|
|
56235
|
-
filePath:
|
|
56394
|
+
filePath: path91.join(inferRepoRoot3(root), "poe-code.json")
|
|
56236
56395
|
};
|
|
56237
56396
|
const agentId = await resolveAgent(configOptions, options.agent ?? null) ?? options.agent ?? "claude-code";
|
|
56238
56397
|
const response = await spawn3(agentId, { prompt });
|
|
@@ -56281,7 +56440,7 @@ async function readPageIfPresent(root, relPath) {
|
|
|
56281
56440
|
}
|
|
56282
56441
|
}
|
|
56283
56442
|
function inferRepoRoot3(root) {
|
|
56284
|
-
return
|
|
56443
|
+
return path91.resolve(root, "..", "..");
|
|
56285
56444
|
}
|
|
56286
56445
|
var init_explain = __esm({
|
|
56287
56446
|
"packages/memory/src/explain.ts"() {
|
|
@@ -56303,9 +56462,9 @@ var init_explain_cli = __esm({
|
|
|
56303
56462
|
});
|
|
56304
56463
|
|
|
56305
56464
|
// packages/memory/src/handle.ts
|
|
56306
|
-
import
|
|
56465
|
+
import path92 from "node:path";
|
|
56307
56466
|
function openMemory(opts) {
|
|
56308
|
-
if (!
|
|
56467
|
+
if (!path92.isAbsolute(opts.root)) {
|
|
56309
56468
|
throw new Error(`openMemory: root must be absolute, got ${opts.root}`);
|
|
56310
56469
|
}
|
|
56311
56470
|
const root = opts.root;
|
|
@@ -56379,7 +56538,7 @@ var init_src34 = __esm({
|
|
|
56379
56538
|
});
|
|
56380
56539
|
|
|
56381
56540
|
// src/cli/commands/memory.ts
|
|
56382
|
-
import
|
|
56541
|
+
import path93 from "node:path";
|
|
56383
56542
|
import * as fs18 from "node:fs/promises";
|
|
56384
56543
|
async function resolveRoot(container) {
|
|
56385
56544
|
return resolveConfiguredMemoryRoot({
|
|
@@ -56396,7 +56555,7 @@ function resolvePageRelPath(input) {
|
|
|
56396
56555
|
throw new ValidationError("Missing page path.");
|
|
56397
56556
|
}
|
|
56398
56557
|
const normalized = trimmed.replaceAll("\\", "/");
|
|
56399
|
-
const withExt =
|
|
56558
|
+
const withExt = path93.posix.extname(normalized).length === 0 ? `${normalized}.md` : normalized;
|
|
56400
56559
|
return withExt.startsWith("pages/") ? withExt : `pages/${withExt}`;
|
|
56401
56560
|
}
|
|
56402
56561
|
function displayPageRelPath(relPath) {
|
|
@@ -56434,8 +56593,8 @@ function registerMemoryCommand(program, container) {
|
|
|
56434
56593
|
}
|
|
56435
56594
|
await initMemory(root);
|
|
56436
56595
|
resources.context.complete({
|
|
56437
|
-
success: `Initialized memory at ${
|
|
56438
|
-
dry: `Would initialize memory at ${
|
|
56596
|
+
success: `Initialized memory at ${path93.relative(container.env.cwd, root)}`,
|
|
56597
|
+
dry: `Would initialize memory at ${path93.relative(container.env.cwd, root)}`
|
|
56439
56598
|
});
|
|
56440
56599
|
resources.context.finalize();
|
|
56441
56600
|
});
|
|
@@ -56467,7 +56626,7 @@ function registerMemoryCommand(program, container) {
|
|
|
56467
56626
|
resources.logger.intro("memory show");
|
|
56468
56627
|
await assertInitialized(mem);
|
|
56469
56628
|
const relPath = resolvePageRelPath(pagePath);
|
|
56470
|
-
const absPath =
|
|
56629
|
+
const absPath = path93.join(mem.root, relPath);
|
|
56471
56630
|
try {
|
|
56472
56631
|
const content = await fs18.readFile(absPath, "utf8");
|
|
56473
56632
|
process.stdout.write(content.endsWith("\n") ? content : `${content}
|
|
@@ -56649,7 +56808,7 @@ var init_package2 = __esm({
|
|
|
56649
56808
|
"package.json"() {
|
|
56650
56809
|
package_default2 = {
|
|
56651
56810
|
name: "poe-code",
|
|
56652
|
-
version: "3.0.
|
|
56811
|
+
version: "3.0.194",
|
|
56653
56812
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
56654
56813
|
type: "module",
|
|
56655
56814
|
main: "./dist/index.js",
|
|
@@ -56866,22 +57025,22 @@ function formatCommandHeader(cmd) {
|
|
|
56866
57025
|
}
|
|
56867
57026
|
return `Poe - ${parts.reverse().join(" ")}`;
|
|
56868
57027
|
}
|
|
56869
|
-
function findCommandByPath(root,
|
|
57028
|
+
function findCommandByPath(root, path94) {
|
|
56870
57029
|
let current = root;
|
|
56871
|
-
for (const segment of
|
|
57030
|
+
for (const segment of path94) {
|
|
56872
57031
|
const next = current.commands.find(
|
|
56873
57032
|
(command) => Reflect.get(command, "_hidden") !== true && command.name() === segment
|
|
56874
57033
|
);
|
|
56875
57034
|
if (!next) {
|
|
56876
|
-
throw new Error(`Root help command is missing: ${
|
|
57035
|
+
throw new Error(`Root help command is missing: ${path94.join(" ")}`);
|
|
56877
57036
|
}
|
|
56878
57037
|
current = next;
|
|
56879
57038
|
}
|
|
56880
57039
|
return current;
|
|
56881
57040
|
}
|
|
56882
|
-
function formatRootHelpCommandName(
|
|
57041
|
+
function formatRootHelpCommandName(path94, command) {
|
|
56883
57042
|
const leaf = [command.name(), ...command.aliases()].join(", ");
|
|
56884
|
-
return
|
|
57043
|
+
return path94.length > 1 ? [...path94.slice(0, -1), leaf].join(" ") : leaf;
|
|
56885
57044
|
}
|
|
56886
57045
|
function splitUsageParts(usage) {
|
|
56887
57046
|
return usage.split(" ").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
@@ -57592,7 +57751,7 @@ init_config4();
|
|
|
57592
57751
|
init_constants();
|
|
57593
57752
|
init_errors2();
|
|
57594
57753
|
import os8 from "node:os";
|
|
57595
|
-
import
|
|
57754
|
+
import path68 from "node:path";
|
|
57596
57755
|
import fsPromises19 from "node:fs/promises";
|
|
57597
57756
|
import { Command } from "commander";
|
|
57598
57757
|
function parseMcpSpawnConfig(input) {
|
|
@@ -57664,10 +57823,10 @@ function resolveWorkingDirectory(baseDir, candidate) {
|
|
|
57664
57823
|
if (!candidate || candidate.trim().length === 0) {
|
|
57665
57824
|
return void 0;
|
|
57666
57825
|
}
|
|
57667
|
-
if (
|
|
57826
|
+
if (path68.isAbsolute(candidate)) {
|
|
57668
57827
|
return candidate;
|
|
57669
57828
|
}
|
|
57670
|
-
return
|
|
57829
|
+
return path68.resolve(baseDir, candidate);
|
|
57671
57830
|
}
|
|
57672
57831
|
function configurePoeAgentRunOptions(command) {
|
|
57673
57832
|
return command.option("-y, --yes", "Accept configured defaults without prompting").option("--model <model>", "Model identifier override").option("--prompt <text>", "Prompt text to send").option("-C, --cwd <path>", "Working directory for the agent").option("--stdin", "Read the prompt from stdin").option(
|