poe-code 3.0.201 → 3.0.202
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 +1851 -1124
- package/dist/index.js.map +4 -4
- package/dist/providers/poe-agent.js +671 -410
- package/dist/providers/poe-agent.js.map +4 -4
- package/package.json +1 -1
- package/packages/memory/dist/index.js +399 -134
- package/packages/memory/dist/index.js.map +4 -4
|
@@ -609,8 +609,8 @@ function resourceNotFound(resource) {
|
|
|
609
609
|
`Resource not found: ${resource}`
|
|
610
610
|
);
|
|
611
611
|
}
|
|
612
|
-
function assertAbsolutePath(
|
|
613
|
-
if (!isAbsolute(
|
|
612
|
+
function assertAbsolutePath(path33) {
|
|
613
|
+
if (!isAbsolute(path33)) {
|
|
614
614
|
throw invalidParams('"path" must be an absolute path');
|
|
615
615
|
}
|
|
616
616
|
}
|
|
@@ -2917,7 +2917,7 @@ var init_acp_core = __esm({
|
|
|
2917
2917
|
});
|
|
2918
2918
|
|
|
2919
2919
|
// packages/poe-agent/src/plugins/plugin-args.ts
|
|
2920
|
-
import
|
|
2920
|
+
import path10 from "node:path";
|
|
2921
2921
|
function isObjectRecord4(value) {
|
|
2922
2922
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2923
2923
|
}
|
|
@@ -2987,13 +2987,13 @@ function getOptionalNonNegativeInteger(args, key2) {
|
|
|
2987
2987
|
return value;
|
|
2988
2988
|
}
|
|
2989
2989
|
function resolveAllowedPath(cwd, allowedPaths, inputPath) {
|
|
2990
|
-
const resolvedPath =
|
|
2990
|
+
const resolvedPath = path10.resolve(cwd, inputPath);
|
|
2991
2991
|
const isAllowed = allowedPaths.some((allowedPath) => {
|
|
2992
2992
|
if (allowedPath === resolvedPath) {
|
|
2993
2993
|
return true;
|
|
2994
2994
|
}
|
|
2995
|
-
const rel =
|
|
2996
|
-
return rel.length > 0 && !rel.startsWith("..") && !
|
|
2995
|
+
const rel = path10.relative(allowedPath, resolvedPath);
|
|
2996
|
+
return rel.length > 0 && !rel.startsWith("..") && !path10.isAbsolute(rel);
|
|
2997
2997
|
});
|
|
2998
2998
|
if (!isAllowed) {
|
|
2999
2999
|
throw new Error(`Path is outside allowed paths: ${inputPath}`);
|
|
@@ -3008,8 +3008,8 @@ var init_plugin_args = __esm({
|
|
|
3008
3008
|
|
|
3009
3009
|
// packages/poe-agent/src/plugins/poe-agent-plugin-files.ts
|
|
3010
3010
|
import { execFile as execFileCallback } from "node:child_process";
|
|
3011
|
-
import
|
|
3012
|
-
import
|
|
3011
|
+
import fsPromises3 from "node:fs/promises";
|
|
3012
|
+
import path11 from "node:path";
|
|
3013
3013
|
import { promisify } from "node:util";
|
|
3014
3014
|
import fastGlob from "fast-glob";
|
|
3015
3015
|
async function fileExists(fs4, filePath) {
|
|
@@ -3050,7 +3050,7 @@ function getOptionalGrepOutputMode(args, key2) {
|
|
|
3050
3050
|
);
|
|
3051
3051
|
}
|
|
3052
3052
|
function formatDisplayPath(cwd, filePath) {
|
|
3053
|
-
return
|
|
3053
|
+
return path11.relative(cwd, filePath) || path11.basename(filePath);
|
|
3054
3054
|
}
|
|
3055
3055
|
async function sortPathsByModifiedTime(matches2, fs4) {
|
|
3056
3056
|
const entries = await Promise.all(
|
|
@@ -3069,8 +3069,8 @@ async function sortPathsByModifiedTime(matches2, fs4) {
|
|
|
3069
3069
|
}
|
|
3070
3070
|
async function defaultSearchContent(options, fs4) {
|
|
3071
3071
|
const targetStat = await fs4.stat(options.path);
|
|
3072
|
-
const searchCwd = targetStat.isDirectory() ? options.path :
|
|
3073
|
-
const searchTarget = targetStat.isDirectory() ? "." :
|
|
3072
|
+
const searchCwd = targetStat.isDirectory() ? options.path : path11.dirname(options.path);
|
|
3073
|
+
const searchTarget = targetStat.isDirectory() ? "." : path11.basename(options.path);
|
|
3074
3074
|
const args = ["--color", "never"];
|
|
3075
3075
|
if (options.outputMode === "content") {
|
|
3076
3076
|
args.push("--with-filename");
|
|
@@ -3166,7 +3166,7 @@ function sliceLines(content, offset, limit) {
|
|
|
3166
3166
|
return content.slice(lineStart, lineEnd);
|
|
3167
3167
|
}
|
|
3168
3168
|
function detectImageMimeType(filePath) {
|
|
3169
|
-
const extension =
|
|
3169
|
+
const extension = path11.extname(filePath).toLowerCase();
|
|
3170
3170
|
if (extension === ".png") {
|
|
3171
3171
|
return "image/png";
|
|
3172
3172
|
}
|
|
@@ -3195,11 +3195,11 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
3195
3195
|
init_plugin_args();
|
|
3196
3196
|
execFile = promisify(execFileCallback);
|
|
3197
3197
|
filesPlugin = (options = {}) => {
|
|
3198
|
-
const cwd =
|
|
3198
|
+
const cwd = path11.resolve(options.cwd ?? process.cwd());
|
|
3199
3199
|
const allowedPaths = (options.allowedPaths ?? [cwd]).map(
|
|
3200
|
-
(allowedPath) =>
|
|
3200
|
+
(allowedPath) => path11.resolve(cwd, allowedPath)
|
|
3201
3201
|
);
|
|
3202
|
-
const fs4 = options.fs ??
|
|
3202
|
+
const fs4 = options.fs ?? fsPromises3;
|
|
3203
3203
|
const searchContent = options.searchContent ?? ((searchOptions) => defaultSearchContent(searchOptions, fs4));
|
|
3204
3204
|
const globFiles = options.globFiles ?? defaultGlobFiles;
|
|
3205
3205
|
const readFileTool = {
|
|
@@ -3317,13 +3317,13 @@ var init_poe_agent_plugin_files = __esm({
|
|
|
3317
3317
|
if (await fileExists(fs4, filePath)) {
|
|
3318
3318
|
throw new Error("File already exists \u2014 use str_replace to edit");
|
|
3319
3319
|
}
|
|
3320
|
-
await fs4.mkdir(
|
|
3320
|
+
await fs4.mkdir(path11.dirname(filePath), { recursive: true });
|
|
3321
3321
|
await fs4.writeFile(filePath, fileText, "utf8");
|
|
3322
3322
|
return `Created file: ${displayedPath}`;
|
|
3323
3323
|
}
|
|
3324
3324
|
if (command === "overwrite") {
|
|
3325
3325
|
const fileText = getRequiredString(args, "file_text", true);
|
|
3326
|
-
await fs4.mkdir(
|
|
3326
|
+
await fs4.mkdir(path11.dirname(filePath), { recursive: true });
|
|
3327
3327
|
await fs4.writeFile(filePath, fileText, "utf8");
|
|
3328
3328
|
return `Overwrote file: ${displayedPath}`;
|
|
3329
3329
|
}
|
|
@@ -3507,11 +3507,11 @@ var init_provider_metadata = __esm({
|
|
|
3507
3507
|
// packages/auth-store/src/encrypted-file-store.ts
|
|
3508
3508
|
import { createCipheriv, createDecipheriv, randomBytes, scrypt } from "node:crypto";
|
|
3509
3509
|
import { promises as fs } from "node:fs";
|
|
3510
|
-
import { homedir as homedir2, hostname, userInfo } from "node:os";
|
|
3511
|
-
import
|
|
3510
|
+
import { homedir as homedir2, hostname as hostname2, userInfo } from "node:os";
|
|
3511
|
+
import path12 from "node:path";
|
|
3512
3512
|
function defaultMachineIdentity() {
|
|
3513
3513
|
return {
|
|
3514
|
-
hostname:
|
|
3514
|
+
hostname: hostname2(),
|
|
3515
3515
|
username: userInfo().username
|
|
3516
3516
|
};
|
|
3517
3517
|
}
|
|
@@ -3560,7 +3560,7 @@ function parseEncryptedDocument(raw) {
|
|
|
3560
3560
|
function isRecord2(value) {
|
|
3561
3561
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
3562
3562
|
}
|
|
3563
|
-
function
|
|
3563
|
+
function isNotFoundError2(error2) {
|
|
3564
3564
|
return Boolean(
|
|
3565
3565
|
error2 && typeof error2 === "object" && "code" in error2 && error2.code === "ENOENT"
|
|
3566
3566
|
);
|
|
@@ -3586,7 +3586,7 @@ var init_encrypted_file_store = __esm({
|
|
|
3586
3586
|
constructor(input) {
|
|
3587
3587
|
this.fs = input.fs ?? fs;
|
|
3588
3588
|
this.salt = input.salt;
|
|
3589
|
-
this.filePath = input.filePath ??
|
|
3589
|
+
this.filePath = input.filePath ?? path12.join(
|
|
3590
3590
|
(input.getHomeDirectory ?? homedir2)(),
|
|
3591
3591
|
input.defaultDirectory ?? ".auth-store",
|
|
3592
3592
|
input.defaultFileName ?? "credentials.enc"
|
|
@@ -3599,7 +3599,7 @@ var init_encrypted_file_store = __esm({
|
|
|
3599
3599
|
try {
|
|
3600
3600
|
rawDocument = await this.fs.readFile(this.filePath, "utf8");
|
|
3601
3601
|
} catch (error2) {
|
|
3602
|
-
if (
|
|
3602
|
+
if (isNotFoundError2(error2)) {
|
|
3603
3603
|
return null;
|
|
3604
3604
|
}
|
|
3605
3605
|
throw error2;
|
|
@@ -3639,7 +3639,7 @@ var init_encrypted_file_store = __esm({
|
|
|
3639
3639
|
authTag: authTag.toString("base64"),
|
|
3640
3640
|
ciphertext: ciphertext.toString("base64")
|
|
3641
3641
|
};
|
|
3642
|
-
await this.fs.mkdir(
|
|
3642
|
+
await this.fs.mkdir(path12.dirname(this.filePath), { recursive: true });
|
|
3643
3643
|
await this.fs.writeFile(this.filePath, JSON.stringify(document), {
|
|
3644
3644
|
encoding: "utf8"
|
|
3645
3645
|
});
|
|
@@ -3649,7 +3649,7 @@ var init_encrypted_file_store = __esm({
|
|
|
3649
3649
|
try {
|
|
3650
3650
|
await this.fs.unlink(this.filePath);
|
|
3651
3651
|
} catch (error2) {
|
|
3652
|
-
if (!
|
|
3652
|
+
if (!isNotFoundError2(error2)) {
|
|
3653
3653
|
throw error2;
|
|
3654
3654
|
}
|
|
3655
3655
|
}
|
|
@@ -4858,7 +4858,7 @@ var init_poe_agent_plugin_openai_responses = __esm({
|
|
|
4858
4858
|
|
|
4859
4859
|
// packages/poe-agent/src/plugins/poe-agent-plugin-shell.ts
|
|
4860
4860
|
import { spawn as spawn2 } from "node:child_process";
|
|
4861
|
-
import
|
|
4861
|
+
import path13 from "node:path";
|
|
4862
4862
|
import { parse as parseShellCommand } from "shell-quote";
|
|
4863
4863
|
function parseTimeoutMs(args) {
|
|
4864
4864
|
const timeoutSeconds = getOptionalNumber(args, "timeout") ?? defaultTimeoutSeconds;
|
|
@@ -5425,9 +5425,9 @@ var init_poe_agent_plugin_shell = __esm({
|
|
|
5425
5425
|
maxTimeoutSeconds = 600;
|
|
5426
5426
|
terminateGracePeriodMs = 1e3;
|
|
5427
5427
|
shellPlugin = (options = {}) => {
|
|
5428
|
-
const cwd =
|
|
5428
|
+
const cwd = path13.resolve(options.cwd ?? process.cwd());
|
|
5429
5429
|
const allowedPaths = (options.allowedPaths ?? [cwd]).map(
|
|
5430
|
-
(allowedPath) =>
|
|
5430
|
+
(allowedPath) => path13.resolve(cwd, allowedPath)
|
|
5431
5431
|
);
|
|
5432
5432
|
const runCommand3 = options.runCommand ?? defaultRunCommand;
|
|
5433
5433
|
const backgroundCommands = /* @__PURE__ */ new Map();
|
|
@@ -5579,7 +5579,7 @@ var init_poe_agent_plugin_shell = __esm({
|
|
|
5579
5579
|
|
|
5580
5580
|
// packages/poe-agent/src/system-prompt.ts
|
|
5581
5581
|
import { readFileSync } from "node:fs";
|
|
5582
|
-
import { readFile } from "node:fs/promises";
|
|
5582
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
5583
5583
|
import { fileURLToPath } from "node:url";
|
|
5584
5584
|
function loadSystemPromptSync() {
|
|
5585
5585
|
return readFileSync(SYSTEM_PROMPT_PATH, "utf8");
|
|
@@ -5973,9 +5973,9 @@ var init_poe_agent_plugin_compaction = __esm({
|
|
|
5973
5973
|
});
|
|
5974
5974
|
|
|
5975
5975
|
// packages/poe-agent/src/plugins/poe-agent-plugin-memory.ts
|
|
5976
|
-
import
|
|
5977
|
-
import
|
|
5978
|
-
import
|
|
5976
|
+
import fsPromises4 from "node:fs/promises";
|
|
5977
|
+
import os3 from "node:os";
|
|
5978
|
+
import path14 from "node:path";
|
|
5979
5979
|
async function loadMemory(options) {
|
|
5980
5980
|
const sections = [];
|
|
5981
5981
|
const projectMemoryPath = await findNearestAgentsFile(options.cwd, options.fs);
|
|
@@ -5986,7 +5986,7 @@ async function loadMemory(options) {
|
|
|
5986
5986
|
}
|
|
5987
5987
|
}
|
|
5988
5988
|
const userMemory = await loadOptionalMemoryFile(
|
|
5989
|
-
|
|
5989
|
+
path14.join(options.homeDir, USER_MEMORY_DIRECTORY, AGENTS_FILE),
|
|
5990
5990
|
options.fs
|
|
5991
5991
|
);
|
|
5992
5992
|
if (userMemory) {
|
|
@@ -6000,11 +6000,11 @@ async function loadMemory(options) {
|
|
|
6000
6000
|
async function findNearestAgentsFile(cwd, fs4) {
|
|
6001
6001
|
let currentDirectory = cwd;
|
|
6002
6002
|
while (true) {
|
|
6003
|
-
const filePath =
|
|
6003
|
+
const filePath = path14.join(currentDirectory, AGENTS_FILE);
|
|
6004
6004
|
if (await readOptionalFile(filePath, fs4) !== void 0) {
|
|
6005
6005
|
return filePath;
|
|
6006
6006
|
}
|
|
6007
|
-
const parentDirectory =
|
|
6007
|
+
const parentDirectory = path14.dirname(currentDirectory);
|
|
6008
6008
|
if (parentDirectory === currentDirectory) {
|
|
6009
6009
|
return void 0;
|
|
6010
6010
|
}
|
|
@@ -6024,7 +6024,7 @@ async function loadOptionalMemoryFile(filePath, fs4) {
|
|
|
6024
6024
|
});
|
|
6025
6025
|
}
|
|
6026
6026
|
async function expandImports(options) {
|
|
6027
|
-
const normalizedPath =
|
|
6027
|
+
const normalizedPath = path14.resolve(options.filePath);
|
|
6028
6028
|
if (options.loading.has(normalizedPath)) {
|
|
6029
6029
|
throw new Error(`Circular AGENTS.md import detected: ${normalizedPath}`);
|
|
6030
6030
|
}
|
|
@@ -6037,7 +6037,7 @@ async function expandImports(options) {
|
|
|
6037
6037
|
expandedLines.push(line);
|
|
6038
6038
|
continue;
|
|
6039
6039
|
}
|
|
6040
|
-
const importedFilePath =
|
|
6040
|
+
const importedFilePath = path14.resolve(path14.dirname(normalizedPath), importPath);
|
|
6041
6041
|
const importedContent = await readRequiredFile(importedFilePath, options.fs);
|
|
6042
6042
|
const expandedImport = await expandImports({
|
|
6043
6043
|
filePath: importedFilePath,
|
|
@@ -6099,11 +6099,11 @@ var init_poe_agent_plugin_memory = __esm({
|
|
|
6099
6099
|
"use strict";
|
|
6100
6100
|
init_parse_options();
|
|
6101
6101
|
AGENTS_FILE = "AGENTS.md";
|
|
6102
|
-
USER_MEMORY_DIRECTORY =
|
|
6102
|
+
USER_MEMORY_DIRECTORY = path14.join(".config", "poe-code");
|
|
6103
6103
|
memoryPlugin = (options = {}) => {
|
|
6104
|
-
const cwd =
|
|
6105
|
-
const homeDir =
|
|
6106
|
-
const fs4 = options.fs ??
|
|
6104
|
+
const cwd = path14.resolve(options.cwd ?? process.cwd());
|
|
6105
|
+
const homeDir = path14.resolve(options.homeDir ?? os3.homedir());
|
|
6106
|
+
const fs4 = options.fs ?? fsPromises4;
|
|
6107
6107
|
let memoryPromise;
|
|
6108
6108
|
return {
|
|
6109
6109
|
name: "poe-agent-plugin-memory",
|
|
@@ -7267,7 +7267,7 @@ var init_resource_indicator = __esm({
|
|
|
7267
7267
|
|
|
7268
7268
|
// packages/mcp-oauth/dist/client/auth-store-session-store.js
|
|
7269
7269
|
import crypto from "node:crypto";
|
|
7270
|
-
import
|
|
7270
|
+
import path15 from "node:path";
|
|
7271
7271
|
var init_auth_store_session_store = __esm({
|
|
7272
7272
|
"packages/mcp-oauth/dist/client/auth-store-session-store.js"() {
|
|
7273
7273
|
"use strict";
|
|
@@ -8595,7 +8595,7 @@ var init_resolve_provider = __esm({
|
|
|
8595
8595
|
});
|
|
8596
8596
|
|
|
8597
8597
|
// packages/poe-agent/src/runtime/transcript.ts
|
|
8598
|
-
import
|
|
8598
|
+
import path16 from "node:path";
|
|
8599
8599
|
function mapAcpEventToSessionUpdates(event) {
|
|
8600
8600
|
if (event.type === "message.delta") {
|
|
8601
8601
|
if (event.content.length === 0) return [];
|
|
@@ -8656,11 +8656,11 @@ function mapAcpEventToSessionUpdates(event) {
|
|
|
8656
8656
|
return [];
|
|
8657
8657
|
}
|
|
8658
8658
|
function createTranscriptWriter(options) {
|
|
8659
|
-
const join2 = options.pathJoin ??
|
|
8659
|
+
const join2 = options.pathJoin ?? path16.join;
|
|
8660
8660
|
const filePath = resolveTranscriptFilePath(options, join2);
|
|
8661
8661
|
let dirEnsured;
|
|
8662
8662
|
let disabled = false;
|
|
8663
|
-
const logDir =
|
|
8663
|
+
const logDir = path16.dirname(filePath);
|
|
8664
8664
|
const ensureDir = () => {
|
|
8665
8665
|
if (!dirEnsured) {
|
|
8666
8666
|
dirEnsured = options.fs.mkdir(logDir, { recursive: true });
|
|
@@ -8702,7 +8702,7 @@ var init_transcript = __esm({
|
|
|
8702
8702
|
});
|
|
8703
8703
|
|
|
8704
8704
|
// packages/poe-agent/src/agent.ts
|
|
8705
|
-
import * as
|
|
8705
|
+
import * as fsPromises5 from "node:fs/promises";
|
|
8706
8706
|
function agent() {
|
|
8707
8707
|
return new ImmutableAgentBuilder();
|
|
8708
8708
|
}
|
|
@@ -9101,8 +9101,8 @@ var init_agent = __esm({
|
|
|
9101
9101
|
}
|
|
9102
9102
|
};
|
|
9103
9103
|
defaultTranscriptFs = {
|
|
9104
|
-
mkdir: (dir, options) =>
|
|
9105
|
-
appendFile: (filePath, contents) =>
|
|
9104
|
+
mkdir: (dir, options) => fsPromises5.mkdir(dir, options).then(() => void 0),
|
|
9105
|
+
appendFile: (filePath, contents) => fsPromises5.appendFile(filePath, contents, "utf8")
|
|
9106
9106
|
};
|
|
9107
9107
|
CallerAcpHost = class {
|
|
9108
9108
|
#runContext;
|
|
@@ -9903,8 +9903,8 @@ var init_model_utils = __esm({
|
|
|
9903
9903
|
// packages/agent-spawn/src/spawn.ts
|
|
9904
9904
|
import { spawn as spawnChildProcess2 } from "node:child_process";
|
|
9905
9905
|
import { mkdirSync, openSync, writeSync, closeSync } from "node:fs";
|
|
9906
|
-
import
|
|
9907
|
-
function
|
|
9906
|
+
import path17 from "node:path";
|
|
9907
|
+
function createAbortError2() {
|
|
9908
9908
|
const error2 = new Error("Agent spawn aborted");
|
|
9909
9909
|
error2.name = "AbortError";
|
|
9910
9910
|
return error2;
|
|
@@ -9985,7 +9985,7 @@ function buildCliArgs(config, options, stdinMode) {
|
|
|
9985
9985
|
}
|
|
9986
9986
|
async function spawn5(agentId, options, context) {
|
|
9987
9987
|
if (options.signal?.aborted) {
|
|
9988
|
-
throw
|
|
9988
|
+
throw createAbortError2();
|
|
9989
9989
|
}
|
|
9990
9990
|
const { agentId: resolvedId, binaryName, spawnConfig } = resolveCliConfig(agentId);
|
|
9991
9991
|
const stdinMode = options.useStdin && spawnConfig.stdinMode ? spawnConfig.stdinMode : void 0;
|
|
@@ -10056,7 +10056,7 @@ async function spawn5(agentId, options, context) {
|
|
|
10056
10056
|
cleanup();
|
|
10057
10057
|
closeSpawnLog(logFd);
|
|
10058
10058
|
if (aborted) {
|
|
10059
|
-
reject(
|
|
10059
|
+
reject(createAbortError2());
|
|
10060
10060
|
return;
|
|
10061
10061
|
}
|
|
10062
10062
|
reject(error2);
|
|
@@ -10065,7 +10065,7 @@ async function spawn5(agentId, options, context) {
|
|
|
10065
10065
|
cleanup();
|
|
10066
10066
|
closeSpawnLog(logFd);
|
|
10067
10067
|
if (aborted) {
|
|
10068
|
-
reject(
|
|
10068
|
+
reject(createAbortError2());
|
|
10069
10069
|
return;
|
|
10070
10070
|
}
|
|
10071
10071
|
if (timedOut) {
|
|
@@ -10088,11 +10088,11 @@ function resolveSpawnLogPath(options) {
|
|
|
10088
10088
|
if (!options.logDir || !options.logFileName) {
|
|
10089
10089
|
return void 0;
|
|
10090
10090
|
}
|
|
10091
|
-
return
|
|
10091
|
+
return path17.join(options.logDir, options.logFileName);
|
|
10092
10092
|
}
|
|
10093
10093
|
function openSpawnLog(filePath) {
|
|
10094
10094
|
try {
|
|
10095
|
-
mkdirSync(
|
|
10095
|
+
mkdirSync(path17.dirname(filePath), { recursive: true });
|
|
10096
10096
|
return openSync(filePath, "a");
|
|
10097
10097
|
} catch {
|
|
10098
10098
|
return void 0;
|
|
@@ -16706,9 +16706,9 @@ var init_autonomous = __esm({
|
|
|
16706
16706
|
});
|
|
16707
16707
|
|
|
16708
16708
|
// packages/agent-spawn/src/acp/replay.ts
|
|
16709
|
-
import
|
|
16709
|
+
import path18 from "node:path";
|
|
16710
16710
|
import { homedir as homedir3 } from "node:os";
|
|
16711
|
-
import { open, readdir } from "node:fs/promises";
|
|
16711
|
+
import { open as open2, readdir } from "node:fs/promises";
|
|
16712
16712
|
import { createInterface } from "node:readline";
|
|
16713
16713
|
var init_replay = __esm({
|
|
16714
16714
|
"packages/agent-spawn/src/acp/replay.ts"() {
|
|
@@ -16826,21 +16826,21 @@ async function* adaptClaude(lines) {
|
|
|
16826
16826
|
if (blockType !== "tool_result") continue;
|
|
16827
16827
|
const kind = toolKindsById.get(item.tool_use_id);
|
|
16828
16828
|
toolKindsById.delete(item.tool_use_id);
|
|
16829
|
-
let
|
|
16829
|
+
let path33;
|
|
16830
16830
|
if (typeof item.content === "string") {
|
|
16831
|
-
|
|
16831
|
+
path33 = item.content;
|
|
16832
16832
|
} else {
|
|
16833
16833
|
try {
|
|
16834
|
-
|
|
16834
|
+
path33 = JSON.stringify(item.content);
|
|
16835
16835
|
} catch {
|
|
16836
|
-
|
|
16836
|
+
path33 = String(item.content);
|
|
16837
16837
|
}
|
|
16838
16838
|
}
|
|
16839
16839
|
yield {
|
|
16840
16840
|
event: "tool_complete",
|
|
16841
16841
|
id: item.tool_use_id,
|
|
16842
16842
|
kind,
|
|
16843
|
-
path:
|
|
16843
|
+
path: path33
|
|
16844
16844
|
};
|
|
16845
16845
|
}
|
|
16846
16846
|
}
|
|
@@ -16963,10 +16963,10 @@ async function* adaptCodex(lines) {
|
|
|
16963
16963
|
const kindFromStart = toolKindById.get(item.id);
|
|
16964
16964
|
const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
|
|
16965
16965
|
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;
|
|
16966
|
-
const
|
|
16966
|
+
const path33 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
|
|
16967
16967
|
toolTitleById.delete(item.id);
|
|
16968
16968
|
toolKindById.delete(item.id);
|
|
16969
|
-
yield { event: "tool_complete", id: item.id, kind, path:
|
|
16969
|
+
yield { event: "tool_complete", id: item.id, kind, path: path33 };
|
|
16970
16970
|
}
|
|
16971
16971
|
}
|
|
16972
16972
|
}
|
|
@@ -17241,7 +17241,7 @@ var init_line_reader = __esm({
|
|
|
17241
17241
|
|
|
17242
17242
|
// packages/agent-spawn/src/acp/spawn.ts
|
|
17243
17243
|
import { spawn as spawnChildProcess4 } from "node:child_process";
|
|
17244
|
-
function
|
|
17244
|
+
function createAbortError3() {
|
|
17245
17245
|
const error2 = new Error("Agent spawn aborted");
|
|
17246
17246
|
error2.name = "AbortError";
|
|
17247
17247
|
return error2;
|
|
@@ -17267,7 +17267,7 @@ function getMcpArgsPosition2(config) {
|
|
|
17267
17267
|
}
|
|
17268
17268
|
function spawnStreaming(options) {
|
|
17269
17269
|
if (options.signal?.aborted) {
|
|
17270
|
-
throw
|
|
17270
|
+
throw createAbortError3();
|
|
17271
17271
|
}
|
|
17272
17272
|
const { agentId, binaryName, spawnConfig } = resolveConfig(options.agentId);
|
|
17273
17273
|
if (spawnConfig === void 0) {
|
|
@@ -17363,7 +17363,7 @@ function spawnStreaming(options) {
|
|
|
17363
17363
|
options.signal?.removeEventListener("abort", onAbort);
|
|
17364
17364
|
if (activityTimer) clearTimeout(activityTimer);
|
|
17365
17365
|
if (aborted) {
|
|
17366
|
-
reject(
|
|
17366
|
+
reject(createAbortError3());
|
|
17367
17367
|
return;
|
|
17368
17368
|
}
|
|
17369
17369
|
reject(error2);
|
|
@@ -17372,7 +17372,7 @@ function spawnStreaming(options) {
|
|
|
17372
17372
|
options.signal?.removeEventListener("abort", onAbort);
|
|
17373
17373
|
if (activityTimer) clearTimeout(activityTimer);
|
|
17374
17374
|
if (aborted) {
|
|
17375
|
-
reject(
|
|
17375
|
+
reject(createAbortError3());
|
|
17376
17376
|
return;
|
|
17377
17377
|
}
|
|
17378
17378
|
if (timedOut) {
|
|
@@ -17490,7 +17490,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
|
|
|
17490
17490
|
}
|
|
17491
17491
|
const id = readString(event.id);
|
|
17492
17492
|
const kind = readString(event.kind);
|
|
17493
|
-
const
|
|
17493
|
+
const path33 = readString(event.path);
|
|
17494
17494
|
let toolCall = id ? toolCallsById.get(id) : void 0;
|
|
17495
17495
|
if (!toolCall) {
|
|
17496
17496
|
toolCall = {};
|
|
@@ -17505,8 +17505,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
|
|
|
17505
17505
|
if (kind) {
|
|
17506
17506
|
toolCall.kind = kind;
|
|
17507
17507
|
}
|
|
17508
|
-
if (
|
|
17509
|
-
toolCall.path =
|
|
17508
|
+
if (path33) {
|
|
17509
|
+
toolCall.path = path33;
|
|
17510
17510
|
}
|
|
17511
17511
|
}
|
|
17512
17512
|
var sessionCapture;
|
|
@@ -17592,9 +17592,9 @@ var init_usage_capture = __esm({
|
|
|
17592
17592
|
});
|
|
17593
17593
|
|
|
17594
17594
|
// packages/agent-spawn/src/acp/middlewares/spawn-log.ts
|
|
17595
|
-
import
|
|
17595
|
+
import path19 from "node:path";
|
|
17596
17596
|
import { homedir as homedir4 } from "node:os";
|
|
17597
|
-
import { mkdir as mkdir2, open as
|
|
17597
|
+
import { mkdir as mkdir2, open as open3 } from "node:fs/promises";
|
|
17598
17598
|
function pad(value, width) {
|
|
17599
17599
|
return String(value).padStart(width, "0");
|
|
17600
17600
|
}
|
|
@@ -17629,14 +17629,14 @@ function resolveLogFilePath(ctx) {
|
|
|
17629
17629
|
if (ctx.logPath) {
|
|
17630
17630
|
return ctx.logPath;
|
|
17631
17631
|
}
|
|
17632
|
-
const baseDir = ctx.logDir ??
|
|
17632
|
+
const baseDir = ctx.logDir ?? path19.join(homedir4(), ".poe-code", "spawn-logs");
|
|
17633
17633
|
if (ctx.logFileName) {
|
|
17634
|
-
return
|
|
17634
|
+
return path19.join(baseDir, ctx.logFileName);
|
|
17635
17635
|
}
|
|
17636
17636
|
const startedAt = resolveStartedAt(ctx.startedAt);
|
|
17637
17637
|
const { day, time, milliseconds } = formatTimestamp(startedAt);
|
|
17638
17638
|
const fileName = `${day}-${time}-${milliseconds}-${normalizeAgent(ctx.agent)}.jsonl`;
|
|
17639
|
-
return
|
|
17639
|
+
return path19.join(baseDir, fileName);
|
|
17640
17640
|
}
|
|
17641
17641
|
async function writePreloadedEvents(writer, events) {
|
|
17642
17642
|
for (const event of events) {
|
|
@@ -17654,7 +17654,7 @@ var init_spawn_log = __esm({
|
|
|
17654
17654
|
logDirPath;
|
|
17655
17655
|
constructor(ctx) {
|
|
17656
17656
|
this.filePath = resolveLogFilePath(ctx);
|
|
17657
|
-
this.logDirPath =
|
|
17657
|
+
this.logDirPath = path19.dirname(this.filePath);
|
|
17658
17658
|
}
|
|
17659
17659
|
async writeEvent(event) {
|
|
17660
17660
|
if (this.isDisabled) {
|
|
@@ -17691,7 +17691,7 @@ var init_spawn_log = __esm({
|
|
|
17691
17691
|
}
|
|
17692
17692
|
try {
|
|
17693
17693
|
await mkdir2(this.logDirPath, { recursive: true });
|
|
17694
|
-
this.fileHandle = await
|
|
17694
|
+
this.fileHandle = await open3(this.filePath, "a");
|
|
17695
17695
|
} catch {
|
|
17696
17696
|
this.isDisabled = true;
|
|
17697
17697
|
}
|
|
@@ -18022,7 +18022,7 @@ var init_src7 = __esm({
|
|
|
18022
18022
|
|
|
18023
18023
|
// src/providers/poe-agent.ts
|
|
18024
18024
|
import fsPromises8 from "node:fs/promises";
|
|
18025
|
-
import
|
|
18025
|
+
import os5 from "node:os";
|
|
18026
18026
|
|
|
18027
18027
|
// src/cli/constants.ts
|
|
18028
18028
|
var DEFAULT_FRONTIER_MODEL = "anthropic/claude-opus-4.7";
|
|
@@ -18055,6 +18055,255 @@ var DEFAULT_KIMI_MODEL = KIMI_MODELS[0];
|
|
|
18055
18055
|
// src/providers/poe-agent.ts
|
|
18056
18056
|
init_src();
|
|
18057
18057
|
|
|
18058
|
+
// packages/poe-code-config/src/runtime.ts
|
|
18059
|
+
import { existsSync } from "node:fs";
|
|
18060
|
+
import path from "node:path";
|
|
18061
|
+
var defaultWorkspaceExclude = [
|
|
18062
|
+
".git",
|
|
18063
|
+
"node_modules",
|
|
18064
|
+
"dist",
|
|
18065
|
+
".turbo",
|
|
18066
|
+
".next",
|
|
18067
|
+
".poe-code/state.json"
|
|
18068
|
+
];
|
|
18069
|
+
var runtimeConfigScope = {
|
|
18070
|
+
scope: "runtime",
|
|
18071
|
+
schema: {
|
|
18072
|
+
type: {
|
|
18073
|
+
type: "string",
|
|
18074
|
+
default: "host",
|
|
18075
|
+
doc: "Runtime backend: host, docker, or e2b"
|
|
18076
|
+
},
|
|
18077
|
+
build_args: {
|
|
18078
|
+
type: "json",
|
|
18079
|
+
default: {},
|
|
18080
|
+
parse: parseBuildArgs,
|
|
18081
|
+
doc: "Build arguments passed to the runtime image build"
|
|
18082
|
+
},
|
|
18083
|
+
mounts: {
|
|
18084
|
+
type: "json",
|
|
18085
|
+
default: [],
|
|
18086
|
+
parse: parseMounts,
|
|
18087
|
+
doc: "Additional runtime mounts"
|
|
18088
|
+
},
|
|
18089
|
+
runner: {
|
|
18090
|
+
type: "json",
|
|
18091
|
+
default: createDefaultRunnerScope(),
|
|
18092
|
+
parse: parseRunner,
|
|
18093
|
+
doc: "Runner process and workspace transfer settings"
|
|
18094
|
+
},
|
|
18095
|
+
link: {
|
|
18096
|
+
type: "string",
|
|
18097
|
+
default: "",
|
|
18098
|
+
doc: "Informational link for the runtime definition"
|
|
18099
|
+
},
|
|
18100
|
+
image: {
|
|
18101
|
+
type: "string",
|
|
18102
|
+
default: "",
|
|
18103
|
+
doc: "Prebuilt Docker image"
|
|
18104
|
+
},
|
|
18105
|
+
dockerfile: {
|
|
18106
|
+
type: "string",
|
|
18107
|
+
default: "",
|
|
18108
|
+
doc: "Path to the Dockerfile used for docker or e2b builds"
|
|
18109
|
+
},
|
|
18110
|
+
build_context: {
|
|
18111
|
+
type: "string",
|
|
18112
|
+
default: "",
|
|
18113
|
+
doc: "Path to the Docker build context"
|
|
18114
|
+
},
|
|
18115
|
+
engine: {
|
|
18116
|
+
type: "string",
|
|
18117
|
+
default: "",
|
|
18118
|
+
doc: "Container engine for Docker runtime"
|
|
18119
|
+
},
|
|
18120
|
+
network: {
|
|
18121
|
+
type: "string",
|
|
18122
|
+
default: "",
|
|
18123
|
+
doc: "Docker network"
|
|
18124
|
+
},
|
|
18125
|
+
extra_args: {
|
|
18126
|
+
type: "json",
|
|
18127
|
+
default: void 0,
|
|
18128
|
+
parse: parseOptionalStringArray,
|
|
18129
|
+
doc: "Extra Docker runtime arguments"
|
|
18130
|
+
},
|
|
18131
|
+
template_id: {
|
|
18132
|
+
type: "string",
|
|
18133
|
+
default: "",
|
|
18134
|
+
doc: "Prebuilt E2B template id"
|
|
18135
|
+
},
|
|
18136
|
+
cpu: {
|
|
18137
|
+
type: "json",
|
|
18138
|
+
default: void 0,
|
|
18139
|
+
parse: parseOptionalNumber,
|
|
18140
|
+
doc: "E2B CPU count"
|
|
18141
|
+
},
|
|
18142
|
+
memory_mb: {
|
|
18143
|
+
type: "json",
|
|
18144
|
+
default: void 0,
|
|
18145
|
+
parse: parseOptionalNumber,
|
|
18146
|
+
doc: "E2B memory in megabytes"
|
|
18147
|
+
},
|
|
18148
|
+
timeout_minutes: {
|
|
18149
|
+
type: "json",
|
|
18150
|
+
default: void 0,
|
|
18151
|
+
parse: parseOptionalNumber,
|
|
18152
|
+
doc: "E2B timeout in minutes"
|
|
18153
|
+
},
|
|
18154
|
+
preserve_after_exit_hours: {
|
|
18155
|
+
type: "json",
|
|
18156
|
+
default: void 0,
|
|
18157
|
+
parse: parseOptionalNumber,
|
|
18158
|
+
doc: "Hours to keep an E2B sandbox alive after job exit"
|
|
18159
|
+
},
|
|
18160
|
+
api_key_env: {
|
|
18161
|
+
type: "string",
|
|
18162
|
+
default: "",
|
|
18163
|
+
doc: "Environment variable name containing the E2B API key"
|
|
18164
|
+
}
|
|
18165
|
+
}
|
|
18166
|
+
};
|
|
18167
|
+
function parseRunner(raw) {
|
|
18168
|
+
if (raw === void 0) {
|
|
18169
|
+
return createDefaultRunnerScope();
|
|
18170
|
+
}
|
|
18171
|
+
const record = asRecord(raw);
|
|
18172
|
+
if (record === void 0) {
|
|
18173
|
+
throw new Error("runner: expected an object.");
|
|
18174
|
+
}
|
|
18175
|
+
const uploadMaxFileMb = parseOptionalNumber(record.upload_max_file_mb, "runner.upload_max_file_mb") ?? 100;
|
|
18176
|
+
if (uploadMaxFileMb <= 0) {
|
|
18177
|
+
throw new Error("runner.upload_max_file_mb: expected a positive finite number.");
|
|
18178
|
+
}
|
|
18179
|
+
return omitUndefined({
|
|
18180
|
+
detach: parseOptionalBoolean(record.detach, "runner.detach") ?? false,
|
|
18181
|
+
upload_max_file_mb: uploadMaxFileMb,
|
|
18182
|
+
download_conflict: parseDownloadConflict(record.download_conflict),
|
|
18183
|
+
workspace: parseRunnerWorkspace(record.workspace)
|
|
18184
|
+
});
|
|
18185
|
+
}
|
|
18186
|
+
function createDefaultRunnerScope() {
|
|
18187
|
+
return {
|
|
18188
|
+
detach: false,
|
|
18189
|
+
upload_max_file_mb: 100,
|
|
18190
|
+
download_conflict: "refuse",
|
|
18191
|
+
workspace: {
|
|
18192
|
+
exclude: [...defaultWorkspaceExclude]
|
|
18193
|
+
}
|
|
18194
|
+
};
|
|
18195
|
+
}
|
|
18196
|
+
function parseRunnerWorkspace(value) {
|
|
18197
|
+
if (value === void 0) {
|
|
18198
|
+
return {
|
|
18199
|
+
exclude: [...defaultWorkspaceExclude]
|
|
18200
|
+
};
|
|
18201
|
+
}
|
|
18202
|
+
const record = asRecord(value);
|
|
18203
|
+
if (record === void 0) {
|
|
18204
|
+
throw new Error("runner.workspace: expected an object.");
|
|
18205
|
+
}
|
|
18206
|
+
return {
|
|
18207
|
+
exclude: parseOptionalStringArray(record.exclude, "runner.workspace.exclude") ?? [
|
|
18208
|
+
...defaultWorkspaceExclude
|
|
18209
|
+
]
|
|
18210
|
+
};
|
|
18211
|
+
}
|
|
18212
|
+
function parseDownloadConflict(value) {
|
|
18213
|
+
if (value === void 0) {
|
|
18214
|
+
return "refuse";
|
|
18215
|
+
}
|
|
18216
|
+
if (value === "refuse" || value === "overwrite") {
|
|
18217
|
+
return value;
|
|
18218
|
+
}
|
|
18219
|
+
throw new Error('runner.download_conflict: expected "refuse" or "overwrite".');
|
|
18220
|
+
}
|
|
18221
|
+
function parseBuildArgs(value) {
|
|
18222
|
+
if (value === void 0) {
|
|
18223
|
+
return {};
|
|
18224
|
+
}
|
|
18225
|
+
const record = asRecord(value);
|
|
18226
|
+
if (record === void 0) {
|
|
18227
|
+
throw new Error("build_args: expected an object.");
|
|
18228
|
+
}
|
|
18229
|
+
const parsed = {};
|
|
18230
|
+
for (const [key2, entry] of Object.entries(record)) {
|
|
18231
|
+
if (typeof entry !== "string") {
|
|
18232
|
+
throw new Error(`build_args.${key2}: expected a string.`);
|
|
18233
|
+
}
|
|
18234
|
+
parsed[key2] = entry;
|
|
18235
|
+
}
|
|
18236
|
+
return parsed;
|
|
18237
|
+
}
|
|
18238
|
+
function parseMounts(value) {
|
|
18239
|
+
if (value === void 0) {
|
|
18240
|
+
return [];
|
|
18241
|
+
}
|
|
18242
|
+
if (!Array.isArray(value)) {
|
|
18243
|
+
throw new Error("mounts: expected an array.");
|
|
18244
|
+
}
|
|
18245
|
+
return value.map((entry, index) => {
|
|
18246
|
+
const record = asRecord(entry);
|
|
18247
|
+
if (record === void 0) {
|
|
18248
|
+
throw new Error(`mounts[${index}]: expected an object.`);
|
|
18249
|
+
}
|
|
18250
|
+
const source = record.source;
|
|
18251
|
+
const target = record.target;
|
|
18252
|
+
if (typeof source !== "string") {
|
|
18253
|
+
throw new Error(`mounts[${index}].source: expected a string.`);
|
|
18254
|
+
}
|
|
18255
|
+
if (typeof target !== "string") {
|
|
18256
|
+
throw new Error(`mounts[${index}].target: expected a string.`);
|
|
18257
|
+
}
|
|
18258
|
+
return omitUndefined({
|
|
18259
|
+
source,
|
|
18260
|
+
target,
|
|
18261
|
+
readonly: parseOptionalBoolean(record.readonly, `mounts[${index}].readonly`)
|
|
18262
|
+
});
|
|
18263
|
+
});
|
|
18264
|
+
}
|
|
18265
|
+
function parseOptionalStringArray(value, key2 = "") {
|
|
18266
|
+
if (value === void 0) {
|
|
18267
|
+
return void 0;
|
|
18268
|
+
}
|
|
18269
|
+
if (!Array.isArray(value)) {
|
|
18270
|
+
throw new Error(`${key2 ? `${key2}: ` : ""}expected an array.`);
|
|
18271
|
+
}
|
|
18272
|
+
return value.map((entry, index) => {
|
|
18273
|
+
if (typeof entry !== "string") {
|
|
18274
|
+
throw new Error(`${key2}[${index}]: expected a string.`);
|
|
18275
|
+
}
|
|
18276
|
+
return entry;
|
|
18277
|
+
});
|
|
18278
|
+
}
|
|
18279
|
+
function parseOptionalNumber(value, key2 = "") {
|
|
18280
|
+
if (value === void 0) {
|
|
18281
|
+
return void 0;
|
|
18282
|
+
}
|
|
18283
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
18284
|
+
throw new Error(`${key2 ? `${key2}: ` : ""}expected a finite number.`);
|
|
18285
|
+
}
|
|
18286
|
+
return value;
|
|
18287
|
+
}
|
|
18288
|
+
function parseOptionalBoolean(value, key2) {
|
|
18289
|
+
if (value === void 0) {
|
|
18290
|
+
return void 0;
|
|
18291
|
+
}
|
|
18292
|
+
if (typeof value !== "boolean") {
|
|
18293
|
+
throw new Error(`${key2}: expected a boolean.`);
|
|
18294
|
+
}
|
|
18295
|
+
return value;
|
|
18296
|
+
}
|
|
18297
|
+
function asRecord(value) {
|
|
18298
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
18299
|
+
return void 0;
|
|
18300
|
+
}
|
|
18301
|
+
return value;
|
|
18302
|
+
}
|
|
18303
|
+
function omitUndefined(value) {
|
|
18304
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
18305
|
+
}
|
|
18306
|
+
|
|
18058
18307
|
// packages/poe-code-config/src/schema.ts
|
|
18059
18308
|
function defineScope(scope, schema) {
|
|
18060
18309
|
return {
|
|
@@ -18074,15 +18323,15 @@ var planConfigScope = defineScope("plan", {
|
|
|
18074
18323
|
});
|
|
18075
18324
|
|
|
18076
18325
|
// packages/poe-code-config/src/store.ts
|
|
18077
|
-
import
|
|
18326
|
+
import path6 from "node:path";
|
|
18078
18327
|
|
|
18079
18328
|
// packages/config-extends/src/discover.ts
|
|
18080
|
-
import
|
|
18329
|
+
import path2 from "node:path";
|
|
18081
18330
|
async function findBase(name, bases, fs4) {
|
|
18082
18331
|
const checkedPaths = [];
|
|
18083
18332
|
for (const basePath of bases) {
|
|
18084
18333
|
for (const extension of [".md", ".yaml", ".yml", ".json"]) {
|
|
18085
|
-
const filePath =
|
|
18334
|
+
const filePath = path2.join(basePath, `${name}${extension}`);
|
|
18086
18335
|
checkedPaths.push(filePath);
|
|
18087
18336
|
try {
|
|
18088
18337
|
return {
|
|
@@ -18106,7 +18355,7 @@ function hasCode(error2, code) {
|
|
|
18106
18355
|
}
|
|
18107
18356
|
|
|
18108
18357
|
// packages/config-extends/src/parse.ts
|
|
18109
|
-
import
|
|
18358
|
+
import path3 from "node:path";
|
|
18110
18359
|
import matter from "gray-matter";
|
|
18111
18360
|
import { parse as parseYaml } from "yaml";
|
|
18112
18361
|
function parseDocument(content, filePath) {
|
|
@@ -18124,7 +18373,7 @@ function parseDocument(content, filePath) {
|
|
|
18124
18373
|
};
|
|
18125
18374
|
}
|
|
18126
18375
|
function detectFormat(content, filePath) {
|
|
18127
|
-
const extension =
|
|
18376
|
+
const extension = path3.extname(filePath).toLowerCase();
|
|
18128
18377
|
if (extension === ".md") {
|
|
18129
18378
|
return "markdown";
|
|
18130
18379
|
}
|
|
@@ -18166,11 +18415,11 @@ function stripBom(content) {
|
|
|
18166
18415
|
function mergeLayers(layers) {
|
|
18167
18416
|
return mergeObjectLayers(layers, []);
|
|
18168
18417
|
}
|
|
18169
|
-
function mergeObjectLayers(layers,
|
|
18418
|
+
function mergeObjectLayers(layers, path33) {
|
|
18170
18419
|
const data = {};
|
|
18171
18420
|
const sources = {};
|
|
18172
18421
|
for (const key2 of collectKeys(layers)) {
|
|
18173
|
-
const resolved = resolveKey(layers, key2,
|
|
18422
|
+
const resolved = resolveKey(layers, key2, path33);
|
|
18174
18423
|
if (resolved === void 0) {
|
|
18175
18424
|
continue;
|
|
18176
18425
|
}
|
|
@@ -18188,7 +18437,7 @@ function collectKeys(layers) {
|
|
|
18188
18437
|
}
|
|
18189
18438
|
return [...keys];
|
|
18190
18439
|
}
|
|
18191
|
-
function resolveKey(layers, key2,
|
|
18440
|
+
function resolveKey(layers, key2, path33) {
|
|
18192
18441
|
let winningSource;
|
|
18193
18442
|
let winningValue;
|
|
18194
18443
|
const objectLayers = [];
|
|
@@ -18218,9 +18467,9 @@ function resolveKey(layers, key2, path30) {
|
|
|
18218
18467
|
if (winningSource === void 0) {
|
|
18219
18468
|
return void 0;
|
|
18220
18469
|
}
|
|
18221
|
-
const fullPath = buildPath(
|
|
18470
|
+
const fullPath = buildPath(path33, key2);
|
|
18222
18471
|
if (isPlainObject(winningValue)) {
|
|
18223
|
-
const merged = mergeObjectLayers(objectLayers, [...
|
|
18472
|
+
const merged = mergeObjectLayers(objectLayers, [...path33, key2]);
|
|
18224
18473
|
return {
|
|
18225
18474
|
value: merged.data,
|
|
18226
18475
|
sources: {
|
|
@@ -18245,8 +18494,8 @@ function isWinningCandidate(key2, value) {
|
|
|
18245
18494
|
}
|
|
18246
18495
|
return true;
|
|
18247
18496
|
}
|
|
18248
|
-
function buildPath(
|
|
18249
|
-
return [...
|
|
18497
|
+
function buildPath(path33, key2) {
|
|
18498
|
+
return [...path33, key2].join(".");
|
|
18250
18499
|
}
|
|
18251
18500
|
function isPlainObject(value) {
|
|
18252
18501
|
if (value === null || Array.isArray(value) || typeof value !== "object") {
|
|
@@ -18270,7 +18519,7 @@ function cloneValue(value) {
|
|
|
18270
18519
|
}
|
|
18271
18520
|
|
|
18272
18521
|
// packages/config-extends/src/resolve.ts
|
|
18273
|
-
import
|
|
18522
|
+
import path4 from "node:path";
|
|
18274
18523
|
var MAX_EXTENDS_DEPTH = 5;
|
|
18275
18524
|
var YIELD_TOKEN = "{{yield}}";
|
|
18276
18525
|
async function resolve(chain, options) {
|
|
@@ -18368,7 +18617,7 @@ Visited files:
|
|
|
18368
18617
|
);
|
|
18369
18618
|
}
|
|
18370
18619
|
const matchedBaseIndex = baseLayers.findIndex(
|
|
18371
|
-
(layer) => layer.path ===
|
|
18620
|
+
(layer) => layer.path === path4.dirname(discoveredBase.filePath)
|
|
18372
18621
|
);
|
|
18373
18622
|
if (matchedBaseIndex === -1) {
|
|
18374
18623
|
throw new Error(`Resolved base is outside configured base paths: ${discoveredBase.filePath}`);
|
|
@@ -18482,7 +18731,7 @@ function stripResolvedBasePrompts(layers, consumedBaseIndexes) {
|
|
|
18482
18731
|
});
|
|
18483
18732
|
}
|
|
18484
18733
|
function getBaseName(filePath) {
|
|
18485
|
-
return
|
|
18734
|
+
return path4.basename(filePath, path4.extname(filePath));
|
|
18486
18735
|
}
|
|
18487
18736
|
function shouldResolveBase(parsedDocument, autoExtend) {
|
|
18488
18737
|
return parsedDocument.extends || autoExtend === true && !parsedDocument.hasExtendsField;
|
|
@@ -18844,20 +19093,20 @@ function getConfigFormat(pathOrFormat) {
|
|
|
18844
19093
|
}
|
|
18845
19094
|
return formatRegistry[formatName];
|
|
18846
19095
|
}
|
|
18847
|
-
function detectFormat2(
|
|
18848
|
-
const ext = getExtension(
|
|
19096
|
+
function detectFormat2(path33) {
|
|
19097
|
+
const ext = getExtension(path33);
|
|
18849
19098
|
return extensionMap[ext];
|
|
18850
19099
|
}
|
|
18851
|
-
function getExtension(
|
|
18852
|
-
const lastDot =
|
|
19100
|
+
function getExtension(path33) {
|
|
19101
|
+
const lastDot = path33.lastIndexOf(".");
|
|
18853
19102
|
if (lastDot === -1) {
|
|
18854
19103
|
return "";
|
|
18855
19104
|
}
|
|
18856
|
-
return
|
|
19105
|
+
return path33.slice(lastDot).toLowerCase();
|
|
18857
19106
|
}
|
|
18858
19107
|
|
|
18859
19108
|
// packages/config-mutations/src/execution/path-utils.ts
|
|
18860
|
-
import
|
|
19109
|
+
import path5 from "node:path";
|
|
18861
19110
|
function expandHome(targetPath, homeDir) {
|
|
18862
19111
|
if (!targetPath?.startsWith("~")) {
|
|
18863
19112
|
return targetPath;
|
|
@@ -18874,7 +19123,7 @@ function expandHome(targetPath, homeDir) {
|
|
|
18874
19123
|
remainder = remainder.slice(1);
|
|
18875
19124
|
}
|
|
18876
19125
|
}
|
|
18877
|
-
return remainder.length === 0 ? homeDir :
|
|
19126
|
+
return remainder.length === 0 ? homeDir : path5.join(homeDir, remainder);
|
|
18878
19127
|
}
|
|
18879
19128
|
function validateHomePath(targetPath) {
|
|
18880
19129
|
if (typeof targetPath !== "string" || targetPath.length === 0) {
|
|
@@ -18892,12 +19141,12 @@ function resolvePath(rawPath, homeDir, pathMapper) {
|
|
|
18892
19141
|
if (!pathMapper) {
|
|
18893
19142
|
return expanded;
|
|
18894
19143
|
}
|
|
18895
|
-
const rawDirectory =
|
|
19144
|
+
const rawDirectory = path5.dirname(expanded);
|
|
18896
19145
|
const mappedDirectory = pathMapper.mapTargetDirectory({
|
|
18897
19146
|
targetDirectory: rawDirectory
|
|
18898
19147
|
});
|
|
18899
|
-
const filename =
|
|
18900
|
-
return filename.length === 0 ? mappedDirectory :
|
|
19148
|
+
const filename = path5.basename(expanded);
|
|
19149
|
+
return filename.length === 0 ? mappedDirectory : path5.join(mappedDirectory, filename);
|
|
18901
19150
|
}
|
|
18902
19151
|
|
|
18903
19152
|
// packages/config-mutations/src/fs-utils.ts
|
|
@@ -19533,7 +19782,7 @@ async function readMergedDocument(fs4, globalPath, projectPath) {
|
|
|
19533
19782
|
},
|
|
19534
19783
|
{
|
|
19535
19784
|
source: "base",
|
|
19536
|
-
path:
|
|
19785
|
+
path: path6.dirname(globalPath)
|
|
19537
19786
|
}
|
|
19538
19787
|
],
|
|
19539
19788
|
{
|
|
@@ -19610,31 +19859,31 @@ function createResolvedConfigFs(fs4, globalPath, globalContent) {
|
|
|
19610
19859
|
};
|
|
19611
19860
|
}
|
|
19612
19861
|
async function writeDocument(fs4, filePath, document) {
|
|
19613
|
-
await fs4.mkdir(
|
|
19862
|
+
await fs4.mkdir(path6.dirname(filePath), { recursive: true });
|
|
19614
19863
|
await fs4.writeFile(filePath, `${JSON.stringify(document, null, 2)}
|
|
19615
19864
|
`, {
|
|
19616
19865
|
encoding: "utf8"
|
|
19617
19866
|
});
|
|
19618
19867
|
}
|
|
19619
19868
|
async function recoverInvalidDocument(fs4, filePath, content) {
|
|
19620
|
-
await fs4.mkdir(
|
|
19869
|
+
await fs4.mkdir(path6.dirname(filePath), { recursive: true });
|
|
19621
19870
|
const backupPath = createInvalidBackupPath(filePath);
|
|
19622
19871
|
await fs4.writeFile(backupPath, content, { encoding: "utf8" });
|
|
19623
19872
|
await fs4.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
|
|
19624
19873
|
}
|
|
19625
19874
|
function createInvalidBackupPath(filePath) {
|
|
19626
|
-
const directory =
|
|
19627
|
-
const baseName =
|
|
19628
|
-
return
|
|
19875
|
+
const directory = path6.dirname(filePath);
|
|
19876
|
+
const baseName = path6.basename(filePath);
|
|
19877
|
+
return path6.join(directory, `${baseName}.invalid-${createTimestamp()}.json`);
|
|
19629
19878
|
}
|
|
19630
19879
|
function isRecord(value) {
|
|
19631
19880
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
19632
19881
|
}
|
|
19633
19882
|
function resolveConfigPath(homeDir) {
|
|
19634
|
-
return
|
|
19883
|
+
return path6.join(homeDir, ".poe-code", "config.json");
|
|
19635
19884
|
}
|
|
19636
19885
|
function resolveProjectConfigPath(cwd) {
|
|
19637
|
-
return
|
|
19886
|
+
return path6.join(cwd, ".poe-code", "config.json");
|
|
19638
19887
|
}
|
|
19639
19888
|
var EMPTY_DOCUMENT = `${JSON.stringify({}, null, 2)}
|
|
19640
19889
|
`;
|
|
@@ -19751,75 +20000,284 @@ async function resolveScopedValues(options, definition, env) {
|
|
|
19751
20000
|
}
|
|
19752
20001
|
|
|
19753
20002
|
// packages/poe-code-config/src/inspect.ts
|
|
19754
|
-
import
|
|
20003
|
+
import path7 from "node:path";
|
|
19755
20004
|
var EMPTY_DOCUMENT2 = `${JSON.stringify({}, null, 2)}
|
|
19756
20005
|
`;
|
|
19757
20006
|
|
|
19758
|
-
// src/
|
|
19759
|
-
|
|
19760
|
-
|
|
19761
|
-
|
|
19762
|
-
|
|
19763
|
-
|
|
19764
|
-
|
|
19765
|
-
|
|
19766
|
-
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
|
|
19770
|
-
|
|
19771
|
-
needsInstall = true;
|
|
19772
|
-
}
|
|
19773
|
-
if (!needsInstall) {
|
|
19774
|
-
return false;
|
|
20007
|
+
// packages/poe-code-config/src/state/index.ts
|
|
20008
|
+
import os2 from "node:os";
|
|
20009
|
+
|
|
20010
|
+
// packages/poe-code-config/src/state/jobs.ts
|
|
20011
|
+
import path8 from "node:path";
|
|
20012
|
+
|
|
20013
|
+
// packages/file-lock/src/lock.ts
|
|
20014
|
+
import * as fsPromises2 from "node:fs/promises";
|
|
20015
|
+
import * as os from "node:os";
|
|
20016
|
+
var LockTimeoutError = class extends Error {
|
|
20017
|
+
constructor(message2) {
|
|
20018
|
+
super(message2);
|
|
20019
|
+
this.name = "LockTimeoutError";
|
|
19775
20020
|
}
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
20021
|
+
};
|
|
20022
|
+
function createAbortError() {
|
|
20023
|
+
const error2 = new Error("The operation was aborted.");
|
|
20024
|
+
error2.name = "AbortError";
|
|
20025
|
+
return error2;
|
|
20026
|
+
}
|
|
20027
|
+
function throwIfAborted(signal) {
|
|
20028
|
+
if (signal?.aborted) {
|
|
20029
|
+
throw createAbortError();
|
|
19779
20030
|
}
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
20031
|
+
}
|
|
20032
|
+
function sleep(ms, signal) {
|
|
20033
|
+
if (!signal) {
|
|
20034
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
19783
20035
|
}
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
for (const postCheck of definition.postChecks) {
|
|
19787
|
-
await postCheck.run(checkContext);
|
|
19788
|
-
}
|
|
20036
|
+
if (signal.aborted) {
|
|
20037
|
+
return Promise.reject(createAbortError());
|
|
19789
20038
|
}
|
|
19790
|
-
|
|
19791
|
-
|
|
19792
|
-
|
|
19793
|
-
|
|
19794
|
-
}
|
|
19795
|
-
|
|
19796
|
-
|
|
20039
|
+
return new Promise((resolve2, reject) => {
|
|
20040
|
+
const timeoutId = setTimeout(() => {
|
|
20041
|
+
signal.removeEventListener("abort", onAbort);
|
|
20042
|
+
resolve2();
|
|
20043
|
+
}, ms);
|
|
20044
|
+
const onAbort = () => {
|
|
20045
|
+
clearTimeout(timeoutId);
|
|
20046
|
+
signal.removeEventListener("abort", onAbort);
|
|
20047
|
+
reject(createAbortError());
|
|
20048
|
+
};
|
|
20049
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
20050
|
+
});
|
|
19797
20051
|
}
|
|
19798
|
-
function
|
|
19799
|
-
|
|
20052
|
+
function backoff(attempt, minTimeout, maxTimeout) {
|
|
20053
|
+
const delay = Math.min(maxTimeout, minTimeout * 2 ** attempt);
|
|
20054
|
+
return delay + Math.random() * delay * 0.1;
|
|
19800
20055
|
}
|
|
19801
|
-
function
|
|
19802
|
-
|
|
19803
|
-
return '""';
|
|
19804
|
-
}
|
|
19805
|
-
if (value.includes(" ") || value.includes(" ") || value.includes("\n")) {
|
|
19806
|
-
return `"${value.replaceAll('"', '\\"')}"`;
|
|
19807
|
-
}
|
|
19808
|
-
return value;
|
|
20056
|
+
function hasErrorCode(error2, code) {
|
|
20057
|
+
return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
19809
20058
|
}
|
|
19810
|
-
function
|
|
19811
|
-
return
|
|
19812
|
-
(step) => !step.platforms || step.platforms.includes(platform)
|
|
19813
|
-
);
|
|
20059
|
+
function hasAnyErrorCode(error2, codes) {
|
|
20060
|
+
return codes.some((code) => hasErrorCode(error2, code));
|
|
19814
20061
|
}
|
|
19815
|
-
function
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
20062
|
+
function isPidRunning(pid) {
|
|
20063
|
+
try {
|
|
20064
|
+
process.kill(pid, 0);
|
|
20065
|
+
return true;
|
|
20066
|
+
} catch (error2) {
|
|
20067
|
+
return !hasErrorCode(error2, "ESRCH");
|
|
19820
20068
|
}
|
|
19821
20069
|
}
|
|
19822
|
-
|
|
20070
|
+
function createDefaultFs() {
|
|
20071
|
+
return {
|
|
20072
|
+
open: (path33, flags) => fsPromises2.open(path33, flags),
|
|
20073
|
+
readFile: (path33, encoding) => fsPromises2.readFile(path33, encoding),
|
|
20074
|
+
stat: fsPromises2.stat,
|
|
20075
|
+
unlink: fsPromises2.unlink
|
|
20076
|
+
};
|
|
20077
|
+
}
|
|
20078
|
+
async function removeLockFile(fs4, lockPath, signal) {
|
|
20079
|
+
for (let attempt = 0; attempt <= 4; attempt += 1) {
|
|
20080
|
+
throwIfAborted(signal);
|
|
20081
|
+
try {
|
|
20082
|
+
await fs4.unlink(lockPath);
|
|
20083
|
+
return;
|
|
20084
|
+
} catch (error2) {
|
|
20085
|
+
if (hasErrorCode(error2, "ENOENT")) {
|
|
20086
|
+
return;
|
|
20087
|
+
}
|
|
20088
|
+
if (!hasAnyErrorCode(error2, ["EPERM", "EBUSY"]) || attempt === 4) {
|
|
20089
|
+
throw error2;
|
|
20090
|
+
}
|
|
20091
|
+
}
|
|
20092
|
+
await sleep(25 * 2 ** attempt, signal);
|
|
20093
|
+
}
|
|
20094
|
+
}
|
|
20095
|
+
function parseLockMetadata(content) {
|
|
20096
|
+
try {
|
|
20097
|
+
const parsed = JSON.parse(content);
|
|
20098
|
+
if (!parsed || typeof parsed !== "object" || !("host" in parsed) || !("pid" in parsed)) {
|
|
20099
|
+
return void 0;
|
|
20100
|
+
}
|
|
20101
|
+
const { host, pid } = parsed;
|
|
20102
|
+
if (typeof host === "string" && typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0) {
|
|
20103
|
+
return {
|
|
20104
|
+
host,
|
|
20105
|
+
pid
|
|
20106
|
+
};
|
|
20107
|
+
}
|
|
20108
|
+
} catch (ignoredError) {
|
|
20109
|
+
void ignoredError;
|
|
20110
|
+
}
|
|
20111
|
+
return void 0;
|
|
20112
|
+
}
|
|
20113
|
+
async function readLockMetadata(fs4, lockPath) {
|
|
20114
|
+
if (!fs4.readFile) {
|
|
20115
|
+
return void 0;
|
|
20116
|
+
}
|
|
20117
|
+
try {
|
|
20118
|
+
return parseLockMetadata(await fs4.readFile(lockPath, "utf8"));
|
|
20119
|
+
} catch (error2) {
|
|
20120
|
+
if (hasErrorCode(error2, "ENOENT")) {
|
|
20121
|
+
return null;
|
|
20122
|
+
}
|
|
20123
|
+
return void 0;
|
|
20124
|
+
}
|
|
20125
|
+
}
|
|
20126
|
+
async function shouldReclaimLock(options) {
|
|
20127
|
+
const metadata = await readLockMetadata(options.fs, options.lockPath);
|
|
20128
|
+
if (metadata === null) {
|
|
20129
|
+
return "missing";
|
|
20130
|
+
}
|
|
20131
|
+
if (metadata?.host === os.hostname()) {
|
|
20132
|
+
return !options.isPidRunning(metadata.pid);
|
|
20133
|
+
}
|
|
20134
|
+
return Date.now() - options.stat.mtimeMs > options.staleMs;
|
|
20135
|
+
}
|
|
20136
|
+
async function writeLockMetadata(handle) {
|
|
20137
|
+
try {
|
|
20138
|
+
await handle.writeFile(
|
|
20139
|
+
JSON.stringify({ pid: process.pid, host: os.hostname(), acquiredAt: (/* @__PURE__ */ new Date()).toISOString() }),
|
|
20140
|
+
{ encoding: "utf8" }
|
|
20141
|
+
);
|
|
20142
|
+
} catch (ignoredError) {
|
|
20143
|
+
void ignoredError;
|
|
20144
|
+
}
|
|
20145
|
+
try {
|
|
20146
|
+
await handle.close();
|
|
20147
|
+
} catch (ignoredError) {
|
|
20148
|
+
void ignoredError;
|
|
20149
|
+
}
|
|
20150
|
+
}
|
|
20151
|
+
async function acquireFileLock(filePath, options = {}) {
|
|
20152
|
+
const fs4 = options.fs ?? createDefaultFs();
|
|
20153
|
+
const retries = options.retries ?? 20;
|
|
20154
|
+
const minTimeout = options.minTimeout ?? 25;
|
|
20155
|
+
const maxTimeout = options.maxTimeout ?? 250;
|
|
20156
|
+
const staleMs = options.staleMs ?? 1e3;
|
|
20157
|
+
const pidIsRunning = options.isPidRunning ?? isPidRunning;
|
|
20158
|
+
const lockPath = `${filePath}.lock`;
|
|
20159
|
+
let attempt = 0;
|
|
20160
|
+
while (attempt <= retries) {
|
|
20161
|
+
throwIfAborted(options.signal);
|
|
20162
|
+
try {
|
|
20163
|
+
const handle = await fs4.open(lockPath, "wx");
|
|
20164
|
+
await writeLockMetadata(handle);
|
|
20165
|
+
let released = false;
|
|
20166
|
+
return async () => {
|
|
20167
|
+
if (released) {
|
|
20168
|
+
return;
|
|
20169
|
+
}
|
|
20170
|
+
released = true;
|
|
20171
|
+
await removeLockFile(fs4, lockPath, options.signal);
|
|
20172
|
+
};
|
|
20173
|
+
} catch (error2) {
|
|
20174
|
+
if (!hasErrorCode(error2, "EEXIST")) {
|
|
20175
|
+
throw error2;
|
|
20176
|
+
}
|
|
20177
|
+
}
|
|
20178
|
+
let stat7;
|
|
20179
|
+
try {
|
|
20180
|
+
stat7 = await fs4.stat(lockPath);
|
|
20181
|
+
} catch (statError) {
|
|
20182
|
+
if (hasErrorCode(statError, "ENOENT")) {
|
|
20183
|
+
continue;
|
|
20184
|
+
}
|
|
20185
|
+
throw statError;
|
|
20186
|
+
}
|
|
20187
|
+
const reclaimLock = await shouldReclaimLock({
|
|
20188
|
+
fs: fs4,
|
|
20189
|
+
isPidRunning: pidIsRunning,
|
|
20190
|
+
lockPath,
|
|
20191
|
+
staleMs,
|
|
20192
|
+
stat: stat7
|
|
20193
|
+
});
|
|
20194
|
+
if (reclaimLock === "missing") {
|
|
20195
|
+
continue;
|
|
20196
|
+
}
|
|
20197
|
+
if (reclaimLock) {
|
|
20198
|
+
await removeLockFile(fs4, lockPath, options.signal);
|
|
20199
|
+
continue;
|
|
20200
|
+
}
|
|
20201
|
+
if (attempt >= retries) {
|
|
20202
|
+
break;
|
|
20203
|
+
}
|
|
20204
|
+
await sleep(backoff(attempt, minTimeout, maxTimeout), options.signal);
|
|
20205
|
+
attempt += 1;
|
|
20206
|
+
}
|
|
20207
|
+
throw new LockTimeoutError(`Failed to acquire lock on "${filePath}".`);
|
|
20208
|
+
}
|
|
20209
|
+
|
|
20210
|
+
// packages/poe-code-config/src/state/fs.ts
|
|
20211
|
+
import * as nodeFs from "node:fs/promises";
|
|
20212
|
+
|
|
20213
|
+
// packages/poe-code-config/src/state/templates.ts
|
|
20214
|
+
import path9 from "node:path";
|
|
20215
|
+
|
|
20216
|
+
// src/services/service-install.ts
|
|
20217
|
+
async function runServiceInstall(definition, context) {
|
|
20218
|
+
const checkContext = {
|
|
20219
|
+
isDryRun: context.isDryRun,
|
|
20220
|
+
runCommand: context.runCommand
|
|
20221
|
+
};
|
|
20222
|
+
let needsInstall = false;
|
|
20223
|
+
try {
|
|
20224
|
+
await definition.check.run(checkContext);
|
|
20225
|
+
context.logger(`${definition.summary} already installed.`);
|
|
20226
|
+
} catch (error2) {
|
|
20227
|
+
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
20228
|
+
context.logger(`${definition.summary} not detected: ${detail}`);
|
|
20229
|
+
needsInstall = true;
|
|
20230
|
+
}
|
|
20231
|
+
if (!needsInstall) {
|
|
20232
|
+
return false;
|
|
20233
|
+
}
|
|
20234
|
+
if (context.isDryRun) {
|
|
20235
|
+
logInstallDryRun(definition, context);
|
|
20236
|
+
return true;
|
|
20237
|
+
}
|
|
20238
|
+
const platformSteps = filterStepsByPlatform(definition.steps, context.platform);
|
|
20239
|
+
for (const step of platformSteps) {
|
|
20240
|
+
await runInstallStep(step, context);
|
|
20241
|
+
}
|
|
20242
|
+
await definition.check.run(checkContext);
|
|
20243
|
+
if (definition.postChecks) {
|
|
20244
|
+
for (const postCheck of definition.postChecks) {
|
|
20245
|
+
await postCheck.run(checkContext);
|
|
20246
|
+
}
|
|
20247
|
+
}
|
|
20248
|
+
context.logger(
|
|
20249
|
+
definition.successMessage ?? `${definition.summary} installed.`
|
|
20250
|
+
);
|
|
20251
|
+
return true;
|
|
20252
|
+
}
|
|
20253
|
+
function describeInstallCommand(step) {
|
|
20254
|
+
return `[${step.id}] ${formatCommand(step.command, step.args)}`;
|
|
20255
|
+
}
|
|
20256
|
+
function formatCommand(command, args) {
|
|
20257
|
+
return [command, ...args.map(quoteIfNeeded)].join(" ");
|
|
20258
|
+
}
|
|
20259
|
+
function quoteIfNeeded(value) {
|
|
20260
|
+
if (value.length === 0) {
|
|
20261
|
+
return '""';
|
|
20262
|
+
}
|
|
20263
|
+
if (value.includes(" ") || value.includes(" ") || value.includes("\n")) {
|
|
20264
|
+
return `"${value.replaceAll('"', '\\"')}"`;
|
|
20265
|
+
}
|
|
20266
|
+
return value;
|
|
20267
|
+
}
|
|
20268
|
+
function filterStepsByPlatform(steps, platform) {
|
|
20269
|
+
return steps.filter(
|
|
20270
|
+
(step) => !step.platforms || step.platforms.includes(platform)
|
|
20271
|
+
);
|
|
20272
|
+
}
|
|
20273
|
+
function logInstallDryRun(definition, context) {
|
|
20274
|
+
context.logger(`Dry run: would install ${definition.summary}.`);
|
|
20275
|
+
const platformSteps = filterStepsByPlatform(definition.steps, context.platform);
|
|
20276
|
+
for (const step of platformSteps) {
|
|
20277
|
+
context.logger(`Dry run: ${describeInstallCommand(step)}`);
|
|
20278
|
+
}
|
|
20279
|
+
}
|
|
20280
|
+
async function runInstallStep(step, context) {
|
|
19823
20281
|
context.logger(`Running ${describeInstallCommand(step)}`);
|
|
19824
20282
|
const result = await context.runCommand(step.command, step.args);
|
|
19825
20283
|
if (result.exitCode !== 0) {
|
|
@@ -19910,16 +20368,16 @@ function createInstallRunner(definition) {
|
|
|
19910
20368
|
}
|
|
19911
20369
|
|
|
19912
20370
|
// src/services/config.ts
|
|
19913
|
-
import
|
|
20371
|
+
import path32 from "node:path";
|
|
19914
20372
|
init_src7();
|
|
19915
20373
|
|
|
19916
20374
|
// packages/superintendent/src/document/parse.ts
|
|
19917
|
-
import
|
|
20375
|
+
import path20 from "node:path";
|
|
19918
20376
|
import { parseDocument as parseDocument2 } from "yaml";
|
|
19919
20377
|
var superintendentDocumentSchemaId = "https://poe-platform.github.io/poe-code/schemas/plans/superintendent.schema.json";
|
|
19920
20378
|
var validStatusStates = /* @__PURE__ */ new Set(["in_progress", "review", "completed"]);
|
|
19921
20379
|
function parseSuperintendentDoc(filePath, content) {
|
|
19922
|
-
const resolvedFilePath =
|
|
20380
|
+
const resolvedFilePath = path20.resolve(filePath);
|
|
19923
20381
|
const { frontmatterText, body } = splitFrontmatter(resolvedFilePath, content);
|
|
19924
20382
|
const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
|
|
19925
20383
|
return {
|
|
@@ -19929,7 +20387,7 @@ function parseSuperintendentDoc(filePath, content) {
|
|
|
19929
20387
|
};
|
|
19930
20388
|
}
|
|
19931
20389
|
function readExplicitBuilderAgent(filePath, content) {
|
|
19932
|
-
const resolvedFilePath =
|
|
20390
|
+
const resolvedFilePath = path20.resolve(filePath);
|
|
19933
20391
|
const { frontmatterText } = splitFrontmatter(resolvedFilePath, content);
|
|
19934
20392
|
const parsedFrontmatter = parseYamlFrontmatter(resolvedFilePath, frontmatterText);
|
|
19935
20393
|
const frontmatter = expectRecord(parsedFrontmatter, "frontmatter", resolvedFilePath);
|
|
@@ -20120,7 +20578,7 @@ function isRecord3(value) {
|
|
|
20120
20578
|
}
|
|
20121
20579
|
|
|
20122
20580
|
// packages/superintendent/src/document/write.ts
|
|
20123
|
-
import
|
|
20581
|
+
import path21 from "node:path";
|
|
20124
20582
|
import { isMap, parseDocument as parseDocument3 } from "yaml";
|
|
20125
20583
|
function updateStatus(filePath, content, status) {
|
|
20126
20584
|
return updateFrontmatter(filePath, content, (frontmatterDocument) => {
|
|
@@ -20141,7 +20599,7 @@ function setStatusReason(filePath, content, reason) {
|
|
|
20141
20599
|
});
|
|
20142
20600
|
}
|
|
20143
20601
|
function updateFrontmatter(filePath, content, mutate) {
|
|
20144
|
-
const resolvedFilePath =
|
|
20602
|
+
const resolvedFilePath = path21.resolve(filePath);
|
|
20145
20603
|
const parts = splitDocument(resolvedFilePath, content);
|
|
20146
20604
|
const frontmatterDocument = parseDocument3(parts.frontmatterText);
|
|
20147
20605
|
if (frontmatterDocument.errors.length > 0) {
|
|
@@ -20366,19 +20824,19 @@ function extractText(node) {
|
|
|
20366
20824
|
}
|
|
20367
20825
|
|
|
20368
20826
|
// packages/superintendent/src/runtime/loop.ts
|
|
20369
|
-
import
|
|
20827
|
+
import path25 from "node:path";
|
|
20370
20828
|
import * as fsPromises6 from "node:fs/promises";
|
|
20371
20829
|
|
|
20372
20830
|
// packages/agent-harness-tools/src/paths.ts
|
|
20373
|
-
import
|
|
20831
|
+
import path22 from "node:path";
|
|
20374
20832
|
function resolveWorkflowPath(inputPath, cwd, homeDir) {
|
|
20375
20833
|
if (inputPath.startsWith("~/")) {
|
|
20376
|
-
return
|
|
20834
|
+
return path22.join(homeDir, inputPath.slice(2));
|
|
20377
20835
|
}
|
|
20378
20836
|
if (inputPath === "~") {
|
|
20379
20837
|
return homeDir;
|
|
20380
20838
|
}
|
|
20381
|
-
return
|
|
20839
|
+
return path22.isAbsolute(inputPath) ? inputPath : path22.resolve(cwd, inputPath);
|
|
20382
20840
|
}
|
|
20383
20841
|
|
|
20384
20842
|
// packages/agent-harness-tools/src/participant.ts
|
|
@@ -20430,211 +20888,14 @@ async function resolveLoopAgent(input) {
|
|
|
20430
20888
|
return resolveSelectedAgent(selectedAgent);
|
|
20431
20889
|
}
|
|
20432
20890
|
|
|
20433
|
-
// packages/file-lock/src/lock.ts
|
|
20434
|
-
import * as fsPromises5 from "node:fs/promises";
|
|
20435
|
-
import * as os2 from "node:os";
|
|
20436
|
-
var LockTimeoutError = class extends Error {
|
|
20437
|
-
constructor(message2) {
|
|
20438
|
-
super(message2);
|
|
20439
|
-
this.name = "LockTimeoutError";
|
|
20440
|
-
}
|
|
20441
|
-
};
|
|
20442
|
-
function createAbortError3() {
|
|
20443
|
-
const error2 = new Error("The operation was aborted.");
|
|
20444
|
-
error2.name = "AbortError";
|
|
20445
|
-
return error2;
|
|
20446
|
-
}
|
|
20447
|
-
function throwIfAborted(signal) {
|
|
20448
|
-
if (signal?.aborted) {
|
|
20449
|
-
throw createAbortError3();
|
|
20450
|
-
}
|
|
20451
|
-
}
|
|
20452
|
-
function sleep(ms, signal) {
|
|
20453
|
-
if (!signal) {
|
|
20454
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
20455
|
-
}
|
|
20456
|
-
if (signal.aborted) {
|
|
20457
|
-
return Promise.reject(createAbortError3());
|
|
20458
|
-
}
|
|
20459
|
-
return new Promise((resolve2, reject) => {
|
|
20460
|
-
const timeoutId = setTimeout(() => {
|
|
20461
|
-
signal.removeEventListener("abort", onAbort);
|
|
20462
|
-
resolve2();
|
|
20463
|
-
}, ms);
|
|
20464
|
-
const onAbort = () => {
|
|
20465
|
-
clearTimeout(timeoutId);
|
|
20466
|
-
signal.removeEventListener("abort", onAbort);
|
|
20467
|
-
reject(createAbortError3());
|
|
20468
|
-
};
|
|
20469
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
20470
|
-
});
|
|
20471
|
-
}
|
|
20472
|
-
function backoff(attempt, minTimeout, maxTimeout) {
|
|
20473
|
-
const delay = Math.min(maxTimeout, minTimeout * 2 ** attempt);
|
|
20474
|
-
return delay + Math.random() * delay * 0.1;
|
|
20475
|
-
}
|
|
20476
|
-
function hasErrorCode(error2, code) {
|
|
20477
|
-
return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
20478
|
-
}
|
|
20479
|
-
function hasAnyErrorCode(error2, codes) {
|
|
20480
|
-
return codes.some((code) => hasErrorCode(error2, code));
|
|
20481
|
-
}
|
|
20482
|
-
function isPidRunning(pid) {
|
|
20483
|
-
try {
|
|
20484
|
-
process.kill(pid, 0);
|
|
20485
|
-
return true;
|
|
20486
|
-
} catch (error2) {
|
|
20487
|
-
return !hasErrorCode(error2, "ESRCH");
|
|
20488
|
-
}
|
|
20489
|
-
}
|
|
20490
|
-
function createDefaultFs() {
|
|
20491
|
-
return {
|
|
20492
|
-
open: (path30, flags) => fsPromises5.open(path30, flags),
|
|
20493
|
-
readFile: (path30, encoding) => fsPromises5.readFile(path30, encoding),
|
|
20494
|
-
stat: fsPromises5.stat,
|
|
20495
|
-
unlink: fsPromises5.unlink
|
|
20496
|
-
};
|
|
20497
|
-
}
|
|
20498
|
-
async function removeLockFile(fs4, lockPath, signal) {
|
|
20499
|
-
for (let attempt = 0; attempt <= 4; attempt += 1) {
|
|
20500
|
-
throwIfAborted(signal);
|
|
20501
|
-
try {
|
|
20502
|
-
await fs4.unlink(lockPath);
|
|
20503
|
-
return;
|
|
20504
|
-
} catch (error2) {
|
|
20505
|
-
if (hasErrorCode(error2, "ENOENT")) {
|
|
20506
|
-
return;
|
|
20507
|
-
}
|
|
20508
|
-
if (!hasAnyErrorCode(error2, ["EPERM", "EBUSY"]) || attempt === 4) {
|
|
20509
|
-
throw error2;
|
|
20510
|
-
}
|
|
20511
|
-
}
|
|
20512
|
-
await sleep(25 * 2 ** attempt, signal);
|
|
20513
|
-
}
|
|
20514
|
-
}
|
|
20515
|
-
function parseLockMetadata(content) {
|
|
20516
|
-
try {
|
|
20517
|
-
const parsed = JSON.parse(content);
|
|
20518
|
-
if (!parsed || typeof parsed !== "object" || !("host" in parsed) || !("pid" in parsed)) {
|
|
20519
|
-
return void 0;
|
|
20520
|
-
}
|
|
20521
|
-
const { host, pid } = parsed;
|
|
20522
|
-
if (typeof host === "string" && typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0) {
|
|
20523
|
-
return {
|
|
20524
|
-
host,
|
|
20525
|
-
pid
|
|
20526
|
-
};
|
|
20527
|
-
}
|
|
20528
|
-
} catch (ignoredError) {
|
|
20529
|
-
void ignoredError;
|
|
20530
|
-
}
|
|
20531
|
-
return void 0;
|
|
20532
|
-
}
|
|
20533
|
-
async function readLockMetadata(fs4, lockPath) {
|
|
20534
|
-
if (!fs4.readFile) {
|
|
20535
|
-
return void 0;
|
|
20536
|
-
}
|
|
20537
|
-
try {
|
|
20538
|
-
return parseLockMetadata(await fs4.readFile(lockPath, "utf8"));
|
|
20539
|
-
} catch (error2) {
|
|
20540
|
-
if (hasErrorCode(error2, "ENOENT")) {
|
|
20541
|
-
return null;
|
|
20542
|
-
}
|
|
20543
|
-
return void 0;
|
|
20544
|
-
}
|
|
20545
|
-
}
|
|
20546
|
-
async function shouldReclaimLock(options) {
|
|
20547
|
-
const metadata = await readLockMetadata(options.fs, options.lockPath);
|
|
20548
|
-
if (metadata === null) {
|
|
20549
|
-
return "missing";
|
|
20550
|
-
}
|
|
20551
|
-
if (metadata?.host === os2.hostname()) {
|
|
20552
|
-
return !options.isPidRunning(metadata.pid);
|
|
20553
|
-
}
|
|
20554
|
-
return Date.now() - options.stat.mtimeMs > options.staleMs;
|
|
20555
|
-
}
|
|
20556
|
-
async function writeLockMetadata(handle) {
|
|
20557
|
-
try {
|
|
20558
|
-
await handle.writeFile(
|
|
20559
|
-
JSON.stringify({ pid: process.pid, host: os2.hostname(), acquiredAt: (/* @__PURE__ */ new Date()).toISOString() }),
|
|
20560
|
-
{ encoding: "utf8" }
|
|
20561
|
-
);
|
|
20562
|
-
} catch (ignoredError) {
|
|
20563
|
-
void ignoredError;
|
|
20564
|
-
}
|
|
20565
|
-
try {
|
|
20566
|
-
await handle.close();
|
|
20567
|
-
} catch (ignoredError) {
|
|
20568
|
-
void ignoredError;
|
|
20569
|
-
}
|
|
20570
|
-
}
|
|
20571
|
-
async function acquireFileLock(filePath, options = {}) {
|
|
20572
|
-
const fs4 = options.fs ?? createDefaultFs();
|
|
20573
|
-
const retries = options.retries ?? 20;
|
|
20574
|
-
const minTimeout = options.minTimeout ?? 25;
|
|
20575
|
-
const maxTimeout = options.maxTimeout ?? 250;
|
|
20576
|
-
const staleMs = options.staleMs ?? 1e3;
|
|
20577
|
-
const pidIsRunning = options.isPidRunning ?? isPidRunning;
|
|
20578
|
-
const lockPath = `${filePath}.lock`;
|
|
20579
|
-
let attempt = 0;
|
|
20580
|
-
while (attempt <= retries) {
|
|
20581
|
-
throwIfAborted(options.signal);
|
|
20582
|
-
try {
|
|
20583
|
-
const handle = await fs4.open(lockPath, "wx");
|
|
20584
|
-
await writeLockMetadata(handle);
|
|
20585
|
-
let released = false;
|
|
20586
|
-
return async () => {
|
|
20587
|
-
if (released) {
|
|
20588
|
-
return;
|
|
20589
|
-
}
|
|
20590
|
-
released = true;
|
|
20591
|
-
await removeLockFile(fs4, lockPath, options.signal);
|
|
20592
|
-
};
|
|
20593
|
-
} catch (error2) {
|
|
20594
|
-
if (!hasErrorCode(error2, "EEXIST")) {
|
|
20595
|
-
throw error2;
|
|
20596
|
-
}
|
|
20597
|
-
}
|
|
20598
|
-
let stat7;
|
|
20599
|
-
try {
|
|
20600
|
-
stat7 = await fs4.stat(lockPath);
|
|
20601
|
-
} catch (statError) {
|
|
20602
|
-
if (hasErrorCode(statError, "ENOENT")) {
|
|
20603
|
-
continue;
|
|
20604
|
-
}
|
|
20605
|
-
throw statError;
|
|
20606
|
-
}
|
|
20607
|
-
const reclaimLock = await shouldReclaimLock({
|
|
20608
|
-
fs: fs4,
|
|
20609
|
-
isPidRunning: pidIsRunning,
|
|
20610
|
-
lockPath,
|
|
20611
|
-
staleMs,
|
|
20612
|
-
stat: stat7
|
|
20613
|
-
});
|
|
20614
|
-
if (reclaimLock === "missing") {
|
|
20615
|
-
continue;
|
|
20616
|
-
}
|
|
20617
|
-
if (reclaimLock) {
|
|
20618
|
-
await removeLockFile(fs4, lockPath, options.signal);
|
|
20619
|
-
continue;
|
|
20620
|
-
}
|
|
20621
|
-
if (attempt >= retries) {
|
|
20622
|
-
break;
|
|
20623
|
-
}
|
|
20624
|
-
await sleep(backoff(attempt, minTimeout, maxTimeout), options.signal);
|
|
20625
|
-
attempt += 1;
|
|
20626
|
-
}
|
|
20627
|
-
throw new LockTimeoutError(`Failed to acquire lock on "${filePath}".`);
|
|
20628
|
-
}
|
|
20629
|
-
|
|
20630
20891
|
// packages/agent-harness-tools/src/run-logs.ts
|
|
20631
|
-
import
|
|
20892
|
+
import path23 from "node:path";
|
|
20632
20893
|
function resolveRunLogDir(options) {
|
|
20633
20894
|
const slug = slugifyPlanPath(options.planPath);
|
|
20634
|
-
return
|
|
20895
|
+
return path23.join(options.homeDir, ".poe-code", "logs", options.runner, slug);
|
|
20635
20896
|
}
|
|
20636
20897
|
function slugifyPlanPath(planPath) {
|
|
20637
|
-
const base =
|
|
20898
|
+
const base = path23.basename(planPath);
|
|
20638
20899
|
const dot = base.lastIndexOf(".");
|
|
20639
20900
|
const stem = dot > 0 ? base.slice(0, dot) : base;
|
|
20640
20901
|
return slugifyLabel(stem);
|
|
@@ -20714,15 +20975,15 @@ function createLoopState(doc) {
|
|
|
20714
20975
|
init_src6();
|
|
20715
20976
|
|
|
20716
20977
|
// packages/superintendent/src/runtime/resolve-cwd.ts
|
|
20717
|
-
import
|
|
20978
|
+
import path24 from "node:path";
|
|
20718
20979
|
function resolveRoleCwd(role, docPath, defaultCwd) {
|
|
20719
20980
|
if (role.cwd === void 0) {
|
|
20720
20981
|
return defaultCwd;
|
|
20721
20982
|
}
|
|
20722
|
-
if (
|
|
20983
|
+
if (path24.isAbsolute(role.cwd)) {
|
|
20723
20984
|
return role.cwd;
|
|
20724
20985
|
}
|
|
20725
|
-
return
|
|
20986
|
+
return path24.resolve(path24.dirname(docPath), role.cwd);
|
|
20726
20987
|
}
|
|
20727
20988
|
|
|
20728
20989
|
// packages/superintendent/src/runtime/templates.ts
|
|
@@ -21869,7 +22130,7 @@ async function executeSuperintendent(options, context) {
|
|
|
21869
22130
|
function buildRoleOptions(options, role) {
|
|
21870
22131
|
return {
|
|
21871
22132
|
defaultCwd: options.cwd,
|
|
21872
|
-
...options.logDir ? { logPath:
|
|
22133
|
+
...options.logDir ? { logPath: path25.join(options.logDir, makeRunLogFileName(role)) } : {}
|
|
21873
22134
|
};
|
|
21874
22135
|
}
|
|
21875
22136
|
function shouldContinueReview(doc) {
|
|
@@ -22122,8 +22383,8 @@ var S = {
|
|
|
22122
22383
|
};
|
|
22123
22384
|
|
|
22124
22385
|
// packages/toolcraft/src/package-metadata.ts
|
|
22125
|
-
import { existsSync, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
22126
|
-
import
|
|
22386
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
22387
|
+
import path26 from "node:path";
|
|
22127
22388
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
22128
22389
|
|
|
22129
22390
|
// packages/toolcraft/src/index.ts
|
|
@@ -22540,14 +22801,14 @@ function hasCode2(error2, code) {
|
|
|
22540
22801
|
}
|
|
22541
22802
|
|
|
22542
22803
|
// packages/superintendent/src/commands/install.ts
|
|
22543
|
-
import
|
|
22804
|
+
import path29 from "node:path";
|
|
22544
22805
|
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";
|
|
22545
22806
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
22546
22807
|
|
|
22547
22808
|
// packages/agent-skill-config/src/configs.ts
|
|
22548
22809
|
init_src4();
|
|
22549
|
-
import
|
|
22550
|
-
import
|
|
22810
|
+
import os4 from "node:os";
|
|
22811
|
+
import path27 from "node:path";
|
|
22551
22812
|
var agentSkillConfigs = {
|
|
22552
22813
|
"claude-code": {
|
|
22553
22814
|
globalSkillDir: "~/.claude/skills",
|
|
@@ -22581,7 +22842,7 @@ function resolveAgentSupport(input, registry = agentSkillConfigs) {
|
|
|
22581
22842
|
|
|
22582
22843
|
// packages/agent-skill-config/src/templates.ts
|
|
22583
22844
|
import { readFile as readFile4, stat as stat3 } from "node:fs/promises";
|
|
22584
|
-
import
|
|
22845
|
+
import path28 from "node:path";
|
|
22585
22846
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
22586
22847
|
|
|
22587
22848
|
// packages/agent-skill-config/src/apply.ts
|
|
@@ -22735,9 +22996,9 @@ async function resolvePlanDirectory(cwd, homeDir, env) {
|
|
|
22735
22996
|
}
|
|
22736
22997
|
function resolveAbsoluteDirectory(dir, cwd, homeDir) {
|
|
22737
22998
|
if (dir.startsWith("~/")) {
|
|
22738
|
-
return
|
|
22999
|
+
return path29.join(homeDir, dir.slice(2));
|
|
22739
23000
|
}
|
|
22740
|
-
return
|
|
23001
|
+
return path29.isAbsolute(dir) ? dir : path29.resolve(cwd, dir);
|
|
22741
23002
|
}
|
|
22742
23003
|
async function pathExists2(targetPath) {
|
|
22743
23004
|
try {
|
|
@@ -22757,15 +23018,15 @@ async function loadSkillTemplate() {
|
|
|
22757
23018
|
}
|
|
22758
23019
|
const packageRoot = await findPackageRoot(fileURLToPath5(import.meta.url));
|
|
22759
23020
|
const templateRoots = [
|
|
22760
|
-
|
|
22761
|
-
|
|
23021
|
+
path29.join(packageRoot, "src", "templates"),
|
|
23022
|
+
path29.join(packageRoot, "dist", "templates")
|
|
22762
23023
|
];
|
|
22763
23024
|
for (const templateRoot of templateRoots) {
|
|
22764
23025
|
if (!await pathExists2(templateRoot)) {
|
|
22765
23026
|
continue;
|
|
22766
23027
|
}
|
|
22767
23028
|
skillTemplateCache = await readFile5(
|
|
22768
|
-
|
|
23029
|
+
path29.join(templateRoot, "SKILL_superintendent.md"),
|
|
22769
23030
|
"utf8"
|
|
22770
23031
|
);
|
|
22771
23032
|
return skillTemplateCache;
|
|
@@ -22773,12 +23034,12 @@ async function loadSkillTemplate() {
|
|
|
22773
23034
|
throw new Error("Unable to locate Superintendent skill template.");
|
|
22774
23035
|
}
|
|
22775
23036
|
async function findPackageRoot(entryFilePath) {
|
|
22776
|
-
let currentPath =
|
|
23037
|
+
let currentPath = path29.dirname(entryFilePath);
|
|
22777
23038
|
while (true) {
|
|
22778
|
-
if (await pathExists2(
|
|
23039
|
+
if (await pathExists2(path29.join(currentPath, "package.json"))) {
|
|
22779
23040
|
return currentPath;
|
|
22780
23041
|
}
|
|
22781
|
-
const parentPath =
|
|
23042
|
+
const parentPath = path29.dirname(currentPath);
|
|
22782
23043
|
if (parentPath === currentPath) {
|
|
22783
23044
|
throw new Error("Unable to locate package root for Superintendent templates.");
|
|
22784
23045
|
}
|
|
@@ -22976,7 +23237,7 @@ function hasCode4(error2, code) {
|
|
|
22976
23237
|
}
|
|
22977
23238
|
|
|
22978
23239
|
// packages/superintendent/src/commands/plan-path.ts
|
|
22979
|
-
import
|
|
23240
|
+
import path30 from "node:path";
|
|
22980
23241
|
import { readFile as readFile6, writeFile as writeFile3, mkdir as mkdir5, unlink as unlink4, stat as stat5, readdir as readdir4 } from "node:fs/promises";
|
|
22981
23242
|
var fs3 = {
|
|
22982
23243
|
readFile: (p, encoding) => readFile6(p, encoding),
|
|
@@ -23011,13 +23272,13 @@ var planPathCommand = defineCommand({
|
|
|
23011
23272
|
});
|
|
23012
23273
|
function resolveAbsoluteDirectory2(dir, cwd, homeDir) {
|
|
23013
23274
|
if (dir.startsWith("~/")) {
|
|
23014
|
-
return
|
|
23275
|
+
return path30.join(homeDir, dir.slice(2));
|
|
23015
23276
|
}
|
|
23016
|
-
return
|
|
23277
|
+
return path30.isAbsolute(dir) ? dir : path30.resolve(cwd, dir);
|
|
23017
23278
|
}
|
|
23018
23279
|
|
|
23019
23280
|
// packages/superintendent/src/commands/run.ts
|
|
23020
|
-
import
|
|
23281
|
+
import path31 from "node:path";
|
|
23021
23282
|
import * as fsPromises7 from "node:fs/promises";
|
|
23022
23283
|
import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
|
|
23023
23284
|
init_src6();
|
|
@@ -23528,7 +23789,7 @@ async function runSuperintendentCommand(options) {
|
|
|
23528
23789
|
session.pauseRequested = true;
|
|
23529
23790
|
}
|
|
23530
23791
|
editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
|
|
23531
|
-
appendEvent("info", `Log opened: ${
|
|
23792
|
+
appendEvent("info", `Log opened: ${path31.basename(session.latestLogFile)}`);
|
|
23532
23793
|
syncStats();
|
|
23533
23794
|
}
|
|
23534
23795
|
};
|
|
@@ -23677,13 +23938,13 @@ async function listPlanDirectoryDocs(fs4, planDirectory, cwd, homeDir) {
|
|
|
23677
23938
|
}
|
|
23678
23939
|
throw error2;
|
|
23679
23940
|
}
|
|
23680
|
-
return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) =>
|
|
23941
|
+
return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) => path31.join(absoluteDir, entry)).sort((left, right) => left.localeCompare(right));
|
|
23681
23942
|
}
|
|
23682
23943
|
function resolveAbsolutePlanDirectory(dir, cwd, homeDir) {
|
|
23683
23944
|
if (dir.startsWith("~/")) {
|
|
23684
|
-
return
|
|
23945
|
+
return path31.join(homeDir, dir.slice(2));
|
|
23685
23946
|
}
|
|
23686
|
-
return
|
|
23947
|
+
return path31.isAbsolute(dir) ? dir : path31.resolve(cwd, dir);
|
|
23687
23948
|
}
|
|
23688
23949
|
function normalizeAgentSelection(value) {
|
|
23689
23950
|
if (typeof value !== "string") {
|
|
@@ -23920,7 +24181,7 @@ function resolveEditor(env) {
|
|
|
23920
24181
|
const parts = raw.split(/\s+/);
|
|
23921
24182
|
const command = parts[0] ?? "vi";
|
|
23922
24183
|
const args = parts.slice(1);
|
|
23923
|
-
const binary =
|
|
24184
|
+
const binary = path31.basename(command);
|
|
23924
24185
|
const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
|
|
23925
24186
|
return { command, args, mode };
|
|
23926
24187
|
}
|
|
@@ -23947,11 +24208,11 @@ function stripStopReason(result) {
|
|
|
23947
24208
|
};
|
|
23948
24209
|
}
|
|
23949
24210
|
function displayPath(filePath, cwd, homeDir) {
|
|
23950
|
-
if (filePath.startsWith(`${cwd}${
|
|
23951
|
-
return
|
|
24211
|
+
if (filePath.startsWith(`${cwd}${path31.sep}`)) {
|
|
24212
|
+
return path31.relative(cwd, filePath);
|
|
23952
24213
|
}
|
|
23953
|
-
if (filePath.startsWith(`${homeDir}${
|
|
23954
|
-
return `~/${
|
|
24214
|
+
if (filePath.startsWith(`${homeDir}${path31.sep}`)) {
|
|
24215
|
+
return `~/${path31.relative(homeDir, filePath)}`;
|
|
23955
24216
|
}
|
|
23956
24217
|
return filePath;
|
|
23957
24218
|
}
|
|
@@ -24574,7 +24835,7 @@ function emitEvent(callback, event) {
|
|
|
24574
24835
|
}
|
|
24575
24836
|
async function loadConfiguredPlugins(options) {
|
|
24576
24837
|
const fs4 = createConfigFileSystem(options.fs);
|
|
24577
|
-
const homeDir = options.homeDir ??
|
|
24838
|
+
const homeDir = options.homeDir ?? os5.homedir();
|
|
24578
24839
|
const store = createConfigStore({
|
|
24579
24840
|
fs: fs4,
|
|
24580
24841
|
filePath: options.configPath ?? resolveConfigPath(homeDir),
|