poe-code 3.0.200 → 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 +1856 -1128
- 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
|
@@ -35,7 +35,256 @@ function assertSafeRelPath(input) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// packages/memory/src/resolve-root.ts
|
|
38
|
-
import
|
|
38
|
+
import path11 from "node:path";
|
|
39
|
+
|
|
40
|
+
// packages/poe-code-config/src/runtime.ts
|
|
41
|
+
import { existsSync } from "node:fs";
|
|
42
|
+
import path2 from "node:path";
|
|
43
|
+
var defaultWorkspaceExclude = [
|
|
44
|
+
".git",
|
|
45
|
+
"node_modules",
|
|
46
|
+
"dist",
|
|
47
|
+
".turbo",
|
|
48
|
+
".next",
|
|
49
|
+
".poe-code/state.json"
|
|
50
|
+
];
|
|
51
|
+
var runtimeConfigScope = {
|
|
52
|
+
scope: "runtime",
|
|
53
|
+
schema: {
|
|
54
|
+
type: {
|
|
55
|
+
type: "string",
|
|
56
|
+
default: "host",
|
|
57
|
+
doc: "Runtime backend: host, docker, or e2b"
|
|
58
|
+
},
|
|
59
|
+
build_args: {
|
|
60
|
+
type: "json",
|
|
61
|
+
default: {},
|
|
62
|
+
parse: parseBuildArgs,
|
|
63
|
+
doc: "Build arguments passed to the runtime image build"
|
|
64
|
+
},
|
|
65
|
+
mounts: {
|
|
66
|
+
type: "json",
|
|
67
|
+
default: [],
|
|
68
|
+
parse: parseMounts,
|
|
69
|
+
doc: "Additional runtime mounts"
|
|
70
|
+
},
|
|
71
|
+
runner: {
|
|
72
|
+
type: "json",
|
|
73
|
+
default: createDefaultRunnerScope(),
|
|
74
|
+
parse: parseRunner,
|
|
75
|
+
doc: "Runner process and workspace transfer settings"
|
|
76
|
+
},
|
|
77
|
+
link: {
|
|
78
|
+
type: "string",
|
|
79
|
+
default: "",
|
|
80
|
+
doc: "Informational link for the runtime definition"
|
|
81
|
+
},
|
|
82
|
+
image: {
|
|
83
|
+
type: "string",
|
|
84
|
+
default: "",
|
|
85
|
+
doc: "Prebuilt Docker image"
|
|
86
|
+
},
|
|
87
|
+
dockerfile: {
|
|
88
|
+
type: "string",
|
|
89
|
+
default: "",
|
|
90
|
+
doc: "Path to the Dockerfile used for docker or e2b builds"
|
|
91
|
+
},
|
|
92
|
+
build_context: {
|
|
93
|
+
type: "string",
|
|
94
|
+
default: "",
|
|
95
|
+
doc: "Path to the Docker build context"
|
|
96
|
+
},
|
|
97
|
+
engine: {
|
|
98
|
+
type: "string",
|
|
99
|
+
default: "",
|
|
100
|
+
doc: "Container engine for Docker runtime"
|
|
101
|
+
},
|
|
102
|
+
network: {
|
|
103
|
+
type: "string",
|
|
104
|
+
default: "",
|
|
105
|
+
doc: "Docker network"
|
|
106
|
+
},
|
|
107
|
+
extra_args: {
|
|
108
|
+
type: "json",
|
|
109
|
+
default: void 0,
|
|
110
|
+
parse: parseOptionalStringArray,
|
|
111
|
+
doc: "Extra Docker runtime arguments"
|
|
112
|
+
},
|
|
113
|
+
template_id: {
|
|
114
|
+
type: "string",
|
|
115
|
+
default: "",
|
|
116
|
+
doc: "Prebuilt E2B template id"
|
|
117
|
+
},
|
|
118
|
+
cpu: {
|
|
119
|
+
type: "json",
|
|
120
|
+
default: void 0,
|
|
121
|
+
parse: parseOptionalNumber,
|
|
122
|
+
doc: "E2B CPU count"
|
|
123
|
+
},
|
|
124
|
+
memory_mb: {
|
|
125
|
+
type: "json",
|
|
126
|
+
default: void 0,
|
|
127
|
+
parse: parseOptionalNumber,
|
|
128
|
+
doc: "E2B memory in megabytes"
|
|
129
|
+
},
|
|
130
|
+
timeout_minutes: {
|
|
131
|
+
type: "json",
|
|
132
|
+
default: void 0,
|
|
133
|
+
parse: parseOptionalNumber,
|
|
134
|
+
doc: "E2B timeout in minutes"
|
|
135
|
+
},
|
|
136
|
+
preserve_after_exit_hours: {
|
|
137
|
+
type: "json",
|
|
138
|
+
default: void 0,
|
|
139
|
+
parse: parseOptionalNumber,
|
|
140
|
+
doc: "Hours to keep an E2B sandbox alive after job exit"
|
|
141
|
+
},
|
|
142
|
+
api_key_env: {
|
|
143
|
+
type: "string",
|
|
144
|
+
default: "",
|
|
145
|
+
doc: "Environment variable name containing the E2B API key"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
function parseRunner(raw) {
|
|
150
|
+
if (raw === void 0) {
|
|
151
|
+
return createDefaultRunnerScope();
|
|
152
|
+
}
|
|
153
|
+
const record = asRecord(raw);
|
|
154
|
+
if (record === void 0) {
|
|
155
|
+
throw new Error("runner: expected an object.");
|
|
156
|
+
}
|
|
157
|
+
const uploadMaxFileMb = parseOptionalNumber(record.upload_max_file_mb, "runner.upload_max_file_mb") ?? 100;
|
|
158
|
+
if (uploadMaxFileMb <= 0) {
|
|
159
|
+
throw new Error("runner.upload_max_file_mb: expected a positive finite number.");
|
|
160
|
+
}
|
|
161
|
+
return omitUndefined({
|
|
162
|
+
detach: parseOptionalBoolean(record.detach, "runner.detach") ?? false,
|
|
163
|
+
upload_max_file_mb: uploadMaxFileMb,
|
|
164
|
+
download_conflict: parseDownloadConflict(record.download_conflict),
|
|
165
|
+
workspace: parseRunnerWorkspace(record.workspace)
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function createDefaultRunnerScope() {
|
|
169
|
+
return {
|
|
170
|
+
detach: false,
|
|
171
|
+
upload_max_file_mb: 100,
|
|
172
|
+
download_conflict: "refuse",
|
|
173
|
+
workspace: {
|
|
174
|
+
exclude: [...defaultWorkspaceExclude]
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function parseRunnerWorkspace(value) {
|
|
179
|
+
if (value === void 0) {
|
|
180
|
+
return {
|
|
181
|
+
exclude: [...defaultWorkspaceExclude]
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const record = asRecord(value);
|
|
185
|
+
if (record === void 0) {
|
|
186
|
+
throw new Error("runner.workspace: expected an object.");
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
exclude: parseOptionalStringArray(record.exclude, "runner.workspace.exclude") ?? [
|
|
190
|
+
...defaultWorkspaceExclude
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function parseDownloadConflict(value) {
|
|
195
|
+
if (value === void 0) {
|
|
196
|
+
return "refuse";
|
|
197
|
+
}
|
|
198
|
+
if (value === "refuse" || value === "overwrite") {
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
throw new Error('runner.download_conflict: expected "refuse" or "overwrite".');
|
|
202
|
+
}
|
|
203
|
+
function parseBuildArgs(value) {
|
|
204
|
+
if (value === void 0) {
|
|
205
|
+
return {};
|
|
206
|
+
}
|
|
207
|
+
const record = asRecord(value);
|
|
208
|
+
if (record === void 0) {
|
|
209
|
+
throw new Error("build_args: expected an object.");
|
|
210
|
+
}
|
|
211
|
+
const parsed = {};
|
|
212
|
+
for (const [key, entry] of Object.entries(record)) {
|
|
213
|
+
if (typeof entry !== "string") {
|
|
214
|
+
throw new Error(`build_args.${key}: expected a string.`);
|
|
215
|
+
}
|
|
216
|
+
parsed[key] = entry;
|
|
217
|
+
}
|
|
218
|
+
return parsed;
|
|
219
|
+
}
|
|
220
|
+
function parseMounts(value) {
|
|
221
|
+
if (value === void 0) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
if (!Array.isArray(value)) {
|
|
225
|
+
throw new Error("mounts: expected an array.");
|
|
226
|
+
}
|
|
227
|
+
return value.map((entry, index) => {
|
|
228
|
+
const record = asRecord(entry);
|
|
229
|
+
if (record === void 0) {
|
|
230
|
+
throw new Error(`mounts[${index}]: expected an object.`);
|
|
231
|
+
}
|
|
232
|
+
const source = record.source;
|
|
233
|
+
const target = record.target;
|
|
234
|
+
if (typeof source !== "string") {
|
|
235
|
+
throw new Error(`mounts[${index}].source: expected a string.`);
|
|
236
|
+
}
|
|
237
|
+
if (typeof target !== "string") {
|
|
238
|
+
throw new Error(`mounts[${index}].target: expected a string.`);
|
|
239
|
+
}
|
|
240
|
+
return omitUndefined({
|
|
241
|
+
source,
|
|
242
|
+
target,
|
|
243
|
+
readonly: parseOptionalBoolean(record.readonly, `mounts[${index}].readonly`)
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function parseOptionalStringArray(value, key = "") {
|
|
248
|
+
if (value === void 0) {
|
|
249
|
+
return void 0;
|
|
250
|
+
}
|
|
251
|
+
if (!Array.isArray(value)) {
|
|
252
|
+
throw new Error(`${key ? `${key}: ` : ""}expected an array.`);
|
|
253
|
+
}
|
|
254
|
+
return value.map((entry, index) => {
|
|
255
|
+
if (typeof entry !== "string") {
|
|
256
|
+
throw new Error(`${key}[${index}]: expected a string.`);
|
|
257
|
+
}
|
|
258
|
+
return entry;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function parseOptionalNumber(value, key = "") {
|
|
262
|
+
if (value === void 0) {
|
|
263
|
+
return void 0;
|
|
264
|
+
}
|
|
265
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
266
|
+
throw new Error(`${key ? `${key}: ` : ""}expected a finite number.`);
|
|
267
|
+
}
|
|
268
|
+
return value;
|
|
269
|
+
}
|
|
270
|
+
function parseOptionalBoolean(value, key) {
|
|
271
|
+
if (value === void 0) {
|
|
272
|
+
return void 0;
|
|
273
|
+
}
|
|
274
|
+
if (typeof value !== "boolean") {
|
|
275
|
+
throw new Error(`${key}: expected a boolean.`);
|
|
276
|
+
}
|
|
277
|
+
return value;
|
|
278
|
+
}
|
|
279
|
+
function asRecord(value) {
|
|
280
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
281
|
+
return void 0;
|
|
282
|
+
}
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
function omitUndefined(value) {
|
|
286
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
|
|
287
|
+
}
|
|
39
288
|
|
|
40
289
|
// packages/poe-code-config/src/schema.ts
|
|
41
290
|
function defineScope(scope, schema) {
|
|
@@ -56,15 +305,15 @@ var planConfigScope = defineScope("plan", {
|
|
|
56
305
|
});
|
|
57
306
|
|
|
58
307
|
// packages/poe-code-config/src/store.ts
|
|
59
|
-
import
|
|
308
|
+
import path7 from "node:path";
|
|
60
309
|
|
|
61
310
|
// packages/config-extends/src/discover.ts
|
|
62
|
-
import
|
|
311
|
+
import path3 from "node:path";
|
|
63
312
|
async function findBase(name, bases, fs14) {
|
|
64
313
|
const checkedPaths = [];
|
|
65
314
|
for (const basePath of bases) {
|
|
66
315
|
for (const extension of [".md", ".yaml", ".yml", ".json"]) {
|
|
67
|
-
const filePath =
|
|
316
|
+
const filePath = path3.join(basePath, `${name}${extension}`);
|
|
68
317
|
checkedPaths.push(filePath);
|
|
69
318
|
try {
|
|
70
319
|
return {
|
|
@@ -88,7 +337,7 @@ function hasCode(error2, code) {
|
|
|
88
337
|
}
|
|
89
338
|
|
|
90
339
|
// packages/config-extends/src/parse.ts
|
|
91
|
-
import
|
|
340
|
+
import path4 from "node:path";
|
|
92
341
|
import matter from "gray-matter";
|
|
93
342
|
import { parse as parseYaml } from "yaml";
|
|
94
343
|
function parseDocument(content, filePath) {
|
|
@@ -106,7 +355,7 @@ function parseDocument(content, filePath) {
|
|
|
106
355
|
};
|
|
107
356
|
}
|
|
108
357
|
function detectFormat(content, filePath) {
|
|
109
|
-
const extension =
|
|
358
|
+
const extension = path4.extname(filePath).toLowerCase();
|
|
110
359
|
if (extension === ".md") {
|
|
111
360
|
return "markdown";
|
|
112
361
|
}
|
|
@@ -148,11 +397,11 @@ function stripBom(content) {
|
|
|
148
397
|
function mergeLayers(layers) {
|
|
149
398
|
return mergeObjectLayers(layers, []);
|
|
150
399
|
}
|
|
151
|
-
function mergeObjectLayers(layers,
|
|
400
|
+
function mergeObjectLayers(layers, path33) {
|
|
152
401
|
const data = {};
|
|
153
402
|
const sources = {};
|
|
154
403
|
for (const key of collectKeys(layers)) {
|
|
155
|
-
const resolved = resolveKey(layers, key,
|
|
404
|
+
const resolved = resolveKey(layers, key, path33);
|
|
156
405
|
if (resolved === void 0) {
|
|
157
406
|
continue;
|
|
158
407
|
}
|
|
@@ -170,7 +419,7 @@ function collectKeys(layers) {
|
|
|
170
419
|
}
|
|
171
420
|
return [...keys];
|
|
172
421
|
}
|
|
173
|
-
function resolveKey(layers, key,
|
|
422
|
+
function resolveKey(layers, key, path33) {
|
|
174
423
|
let winningSource;
|
|
175
424
|
let winningValue;
|
|
176
425
|
const objectLayers = [];
|
|
@@ -200,9 +449,9 @@ function resolveKey(layers, key, path30) {
|
|
|
200
449
|
if (winningSource === void 0) {
|
|
201
450
|
return void 0;
|
|
202
451
|
}
|
|
203
|
-
const fullPath = buildPath(
|
|
452
|
+
const fullPath = buildPath(path33, key);
|
|
204
453
|
if (isPlainObject(winningValue)) {
|
|
205
|
-
const merged = mergeObjectLayers(objectLayers, [...
|
|
454
|
+
const merged = mergeObjectLayers(objectLayers, [...path33, key]);
|
|
206
455
|
return {
|
|
207
456
|
value: merged.data,
|
|
208
457
|
sources: {
|
|
@@ -227,8 +476,8 @@ function isWinningCandidate(key, value) {
|
|
|
227
476
|
}
|
|
228
477
|
return true;
|
|
229
478
|
}
|
|
230
|
-
function buildPath(
|
|
231
|
-
return [...
|
|
479
|
+
function buildPath(path33, key) {
|
|
480
|
+
return [...path33, key].join(".");
|
|
232
481
|
}
|
|
233
482
|
function isPlainObject(value) {
|
|
234
483
|
if (value === null || Array.isArray(value) || typeof value !== "object") {
|
|
@@ -252,7 +501,7 @@ function cloneValue(value) {
|
|
|
252
501
|
}
|
|
253
502
|
|
|
254
503
|
// packages/config-extends/src/resolve.ts
|
|
255
|
-
import
|
|
504
|
+
import path5 from "node:path";
|
|
256
505
|
var MAX_EXTENDS_DEPTH = 5;
|
|
257
506
|
var YIELD_TOKEN = "{{yield}}";
|
|
258
507
|
async function resolve(chain, options) {
|
|
@@ -350,7 +599,7 @@ Visited files:
|
|
|
350
599
|
);
|
|
351
600
|
}
|
|
352
601
|
const matchedBaseIndex = baseLayers.findIndex(
|
|
353
|
-
(layer) => layer.path ===
|
|
602
|
+
(layer) => layer.path === path5.dirname(discoveredBase.filePath)
|
|
354
603
|
);
|
|
355
604
|
if (matchedBaseIndex === -1) {
|
|
356
605
|
throw new Error(`Resolved base is outside configured base paths: ${discoveredBase.filePath}`);
|
|
@@ -464,7 +713,7 @@ function stripResolvedBasePrompts(layers, consumedBaseIndexes) {
|
|
|
464
713
|
});
|
|
465
714
|
}
|
|
466
715
|
function getBaseName(filePath) {
|
|
467
|
-
return
|
|
716
|
+
return path5.basename(filePath, path5.extname(filePath));
|
|
468
717
|
}
|
|
469
718
|
function shouldResolveBase(parsedDocument, autoExtend) {
|
|
470
719
|
return parsedDocument.extends || autoExtend === true && !parsedDocument.hasExtendsField;
|
|
@@ -862,20 +1111,20 @@ function getConfigFormat(pathOrFormat) {
|
|
|
862
1111
|
}
|
|
863
1112
|
return formatRegistry[formatName];
|
|
864
1113
|
}
|
|
865
|
-
function detectFormat2(
|
|
866
|
-
const ext = getExtension(
|
|
1114
|
+
function detectFormat2(path33) {
|
|
1115
|
+
const ext = getExtension(path33);
|
|
867
1116
|
return extensionMap[ext];
|
|
868
1117
|
}
|
|
869
|
-
function getExtension(
|
|
870
|
-
const lastDot =
|
|
1118
|
+
function getExtension(path33) {
|
|
1119
|
+
const lastDot = path33.lastIndexOf(".");
|
|
871
1120
|
if (lastDot === -1) {
|
|
872
1121
|
return "";
|
|
873
1122
|
}
|
|
874
|
-
return
|
|
1123
|
+
return path33.slice(lastDot).toLowerCase();
|
|
875
1124
|
}
|
|
876
1125
|
|
|
877
1126
|
// packages/config-mutations/src/execution/path-utils.ts
|
|
878
|
-
import
|
|
1127
|
+
import path6 from "node:path";
|
|
879
1128
|
function expandHome(targetPath, homeDir) {
|
|
880
1129
|
if (!targetPath?.startsWith("~")) {
|
|
881
1130
|
return targetPath;
|
|
@@ -892,7 +1141,7 @@ function expandHome(targetPath, homeDir) {
|
|
|
892
1141
|
remainder = remainder.slice(1);
|
|
893
1142
|
}
|
|
894
1143
|
}
|
|
895
|
-
return remainder.length === 0 ? homeDir :
|
|
1144
|
+
return remainder.length === 0 ? homeDir : path6.join(homeDir, remainder);
|
|
896
1145
|
}
|
|
897
1146
|
function validateHomePath(targetPath) {
|
|
898
1147
|
if (typeof targetPath !== "string" || targetPath.length === 0) {
|
|
@@ -910,12 +1159,12 @@ function resolvePath(rawPath, homeDir, pathMapper) {
|
|
|
910
1159
|
if (!pathMapper) {
|
|
911
1160
|
return expanded;
|
|
912
1161
|
}
|
|
913
|
-
const rawDirectory =
|
|
1162
|
+
const rawDirectory = path6.dirname(expanded);
|
|
914
1163
|
const mappedDirectory = pathMapper.mapTargetDirectory({
|
|
915
1164
|
targetDirectory: rawDirectory
|
|
916
1165
|
});
|
|
917
|
-
const filename =
|
|
918
|
-
return filename.length === 0 ? mappedDirectory :
|
|
1166
|
+
const filename = path6.basename(expanded);
|
|
1167
|
+
return filename.length === 0 ? mappedDirectory : path6.join(mappedDirectory, filename);
|
|
919
1168
|
}
|
|
920
1169
|
|
|
921
1170
|
// packages/config-mutations/src/fs-utils.ts
|
|
@@ -1173,8 +1422,8 @@ async function applyChmod(mutation, context, options) {
|
|
|
1173
1422
|
};
|
|
1174
1423
|
}
|
|
1175
1424
|
try {
|
|
1176
|
-
const
|
|
1177
|
-
const currentMode = typeof
|
|
1425
|
+
const stat7 = await context.fs.stat(targetPath);
|
|
1426
|
+
const currentMode = typeof stat7.mode === "number" ? stat7.mode & 511 : null;
|
|
1178
1427
|
if (currentMode === mutation.mode) {
|
|
1179
1428
|
return {
|
|
1180
1429
|
outcome: { changed: false, effect: "none", detail: "noop" },
|
|
@@ -1537,7 +1786,7 @@ async function readMergedDocument(fs14, globalPath, projectPath) {
|
|
|
1537
1786
|
},
|
|
1538
1787
|
{
|
|
1539
1788
|
source: "base",
|
|
1540
|
-
path:
|
|
1789
|
+
path: path7.dirname(globalPath)
|
|
1541
1790
|
}
|
|
1542
1791
|
],
|
|
1543
1792
|
{
|
|
@@ -1614,15 +1863,15 @@ function createResolvedConfigFs(fs14, globalPath, globalContent) {
|
|
|
1614
1863
|
};
|
|
1615
1864
|
}
|
|
1616
1865
|
async function recoverInvalidDocument(fs14, filePath, content) {
|
|
1617
|
-
await fs14.mkdir(
|
|
1866
|
+
await fs14.mkdir(path7.dirname(filePath), { recursive: true });
|
|
1618
1867
|
const backupPath = createInvalidBackupPath(filePath);
|
|
1619
1868
|
await fs14.writeFile(backupPath, content, { encoding: "utf8" });
|
|
1620
1869
|
await fs14.writeFile(filePath, EMPTY_DOCUMENT, { encoding: "utf8" });
|
|
1621
1870
|
}
|
|
1622
1871
|
function createInvalidBackupPath(filePath) {
|
|
1623
|
-
const directory =
|
|
1624
|
-
const baseName =
|
|
1625
|
-
return
|
|
1872
|
+
const directory = path7.dirname(filePath);
|
|
1873
|
+
const baseName = path7.basename(filePath);
|
|
1874
|
+
return path7.join(directory, `${baseName}.invalid-${createTimestamp()}.json`);
|
|
1626
1875
|
}
|
|
1627
1876
|
function isRecord(value) {
|
|
1628
1877
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -1646,10 +1895,10 @@ async function cacheEnabled(options) {
|
|
|
1646
1895
|
}
|
|
1647
1896
|
async function resolveMemoryConfig(options) {
|
|
1648
1897
|
const document = await readMergedDocument(options.fs, options.filePath, options.projectFilePath);
|
|
1649
|
-
const memory =
|
|
1650
|
-
const cache =
|
|
1651
|
-
const mcp =
|
|
1652
|
-
const query =
|
|
1898
|
+
const memory = asRecord2(document.memory);
|
|
1899
|
+
const cache = asRecord2(memory?.cache);
|
|
1900
|
+
const mcp = asRecord2(memory?.mcp);
|
|
1901
|
+
const query = asRecord2(memory?.query);
|
|
1653
1902
|
return {
|
|
1654
1903
|
root: readString(memory?.root),
|
|
1655
1904
|
ingestAgent: readString(memory?.ingestAgent),
|
|
@@ -1659,7 +1908,7 @@ async function resolveMemoryConfig(options) {
|
|
|
1659
1908
|
defaultQueryBudget: readNumber(query?.defaultBudgetTokens) ?? 4096
|
|
1660
1909
|
};
|
|
1661
1910
|
}
|
|
1662
|
-
function
|
|
1911
|
+
function asRecord2(value) {
|
|
1663
1912
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1664
1913
|
return void 0;
|
|
1665
1914
|
}
|
|
@@ -1676,10 +1925,26 @@ function readBoolean(value) {
|
|
|
1676
1925
|
}
|
|
1677
1926
|
|
|
1678
1927
|
// packages/poe-code-config/src/inspect.ts
|
|
1679
|
-
import
|
|
1928
|
+
import path8 from "node:path";
|
|
1680
1929
|
var EMPTY_DOCUMENT2 = `${JSON.stringify({}, null, 2)}
|
|
1681
1930
|
`;
|
|
1682
1931
|
|
|
1932
|
+
// packages/poe-code-config/src/state/index.ts
|
|
1933
|
+
import os2 from "node:os";
|
|
1934
|
+
|
|
1935
|
+
// packages/poe-code-config/src/state/jobs.ts
|
|
1936
|
+
import path9 from "node:path";
|
|
1937
|
+
|
|
1938
|
+
// packages/file-lock/src/lock.ts
|
|
1939
|
+
import * as fsPromises from "node:fs/promises";
|
|
1940
|
+
import * as os from "node:os";
|
|
1941
|
+
|
|
1942
|
+
// packages/poe-code-config/src/state/fs.ts
|
|
1943
|
+
import * as nodeFs from "node:fs/promises";
|
|
1944
|
+
|
|
1945
|
+
// packages/poe-code-config/src/state/templates.ts
|
|
1946
|
+
import path10 from "node:path";
|
|
1947
|
+
|
|
1683
1948
|
// packages/memory/src/resolve-root.ts
|
|
1684
1949
|
var MEMORY_ROOT_ENV_VAR = "POE_CODE_MEMORY_ROOT";
|
|
1685
1950
|
async function resolveConfiguredMemoryRoot(options) {
|
|
@@ -1698,16 +1963,16 @@ async function resolveConfiguredMemoryRoot(options) {
|
|
|
1698
1963
|
return resolveMemoryRoot(options.cwd);
|
|
1699
1964
|
}
|
|
1700
1965
|
function resolveAgainstCwd(cwd, value) {
|
|
1701
|
-
return
|
|
1966
|
+
return path11.isAbsolute(value) ? value : path11.resolve(cwd, value);
|
|
1702
1967
|
}
|
|
1703
1968
|
|
|
1704
1969
|
// packages/memory/src/init.ts
|
|
1705
1970
|
import * as fs from "node:fs/promises";
|
|
1706
|
-
import
|
|
1971
|
+
import path12 from "node:path";
|
|
1707
1972
|
async function initMemory(root) {
|
|
1708
|
-
await fs.mkdir(
|
|
1709
|
-
await writeFileIfMissing(
|
|
1710
|
-
await writeFileIfMissing(
|
|
1973
|
+
await fs.mkdir(path12.join(root, MEMORY_PAGES_DIR_RELPATH), { recursive: true });
|
|
1974
|
+
await writeFileIfMissing(path12.join(root, MEMORY_INDEX_RELPATH), "# Memory index\n");
|
|
1975
|
+
await writeFileIfMissing(path12.join(root, MEMORY_LOG_RELPATH), "");
|
|
1711
1976
|
}
|
|
1712
1977
|
async function writeFileIfMissing(filePath, content) {
|
|
1713
1978
|
try {
|
|
@@ -1724,7 +1989,7 @@ function hasErrorCode(error2, code) {
|
|
|
1724
1989
|
|
|
1725
1990
|
// packages/memory/src/pages.ts
|
|
1726
1991
|
import * as fs2 from "node:fs/promises";
|
|
1727
|
-
import
|
|
1992
|
+
import path13 from "node:path";
|
|
1728
1993
|
|
|
1729
1994
|
// packages/memory/src/frontmatter.ts
|
|
1730
1995
|
import { parse as parse5, stringify } from "yaml";
|
|
@@ -1904,10 +2169,10 @@ function parseSources(value) {
|
|
|
1904
2169
|
if (!isRecord2(item)) {
|
|
1905
2170
|
throw new Error('Invalid "sources" frontmatter. Expected each source to be a string or object.');
|
|
1906
2171
|
}
|
|
1907
|
-
const
|
|
2172
|
+
const path33 = readRequiredString(item.path, "sources[].path");
|
|
1908
2173
|
const startLine = readOptionalPositiveInteger(item.startLine, "sources[].startLine");
|
|
1909
2174
|
const endLine = readOptionalPositiveInteger(item.endLine, "sources[].endLine");
|
|
1910
|
-
return parseSourceRef(serializeSourceRef({ path:
|
|
2175
|
+
return parseSourceRef(serializeSourceRef({ path: path33, ...startLine === void 0 ? {} : { startLine }, ...endLine === void 0 ? {} : { endLine } }));
|
|
1911
2176
|
});
|
|
1912
2177
|
}
|
|
1913
2178
|
function readOptionalString(value, field) {
|
|
@@ -1952,8 +2217,8 @@ async function listPages(root) {
|
|
|
1952
2217
|
}
|
|
1953
2218
|
async function readPage(root, relPath) {
|
|
1954
2219
|
const normalizedRelPath = assertMarkdownRelPath(relPath);
|
|
1955
|
-
const absPath =
|
|
1956
|
-
const [content,
|
|
2220
|
+
const absPath = path13.join(root, normalizedRelPath);
|
|
2221
|
+
const [content, stat7] = await Promise.all([fs2.readFile(absPath, "utf8"), fs2.stat(absPath)]);
|
|
1957
2222
|
try {
|
|
1958
2223
|
const parsed = parseFrontmatter(content);
|
|
1959
2224
|
return {
|
|
@@ -1961,7 +2226,7 @@ async function readPage(root, relPath) {
|
|
|
1961
2226
|
frontmatter: parsed.frontmatter,
|
|
1962
2227
|
body: parsed.body,
|
|
1963
2228
|
bytes: Buffer.byteLength(content),
|
|
1964
|
-
mtimeMs:
|
|
2229
|
+
mtimeMs: stat7.mtimeMs
|
|
1965
2230
|
};
|
|
1966
2231
|
} catch (error2) {
|
|
1967
2232
|
const message2 = error2 instanceof Error ? error2.message : String(error2);
|
|
@@ -1971,7 +2236,7 @@ async function readPage(root, relPath) {
|
|
|
1971
2236
|
frontmatter: {},
|
|
1972
2237
|
body: content,
|
|
1973
2238
|
bytes: Buffer.byteLength(content),
|
|
1974
|
-
mtimeMs:
|
|
2239
|
+
mtimeMs: stat7.mtimeMs
|
|
1975
2240
|
};
|
|
1976
2241
|
}
|
|
1977
2242
|
}
|
|
@@ -1981,7 +2246,7 @@ async function collectMarkdownRelPaths(root, startRelPath = "") {
|
|
|
1981
2246
|
return relPaths.sort((left, right) => left.localeCompare(right));
|
|
1982
2247
|
}
|
|
1983
2248
|
async function collectMarkdownRelPathsInto(root, currentRelPath, relPaths) {
|
|
1984
|
-
const absPath =
|
|
2249
|
+
const absPath = path13.join(root, currentRelPath);
|
|
1985
2250
|
let entryNames;
|
|
1986
2251
|
try {
|
|
1987
2252
|
entryNames = await fs2.readdir(absPath);
|
|
@@ -1992,8 +2257,8 @@ async function collectMarkdownRelPathsInto(root, currentRelPath, relPaths) {
|
|
|
1992
2257
|
throw error2;
|
|
1993
2258
|
}
|
|
1994
2259
|
for (const entryName of entryNames.sort((left, right) => left.localeCompare(right))) {
|
|
1995
|
-
const entryRelPath = currentRelPath.length === 0 ? entryName :
|
|
1996
|
-
const entryAbsPath =
|
|
2260
|
+
const entryRelPath = currentRelPath.length === 0 ? entryName : path13.posix.join(currentRelPath, entryName);
|
|
2261
|
+
const entryAbsPath = path13.join(root, entryRelPath);
|
|
1997
2262
|
const entryStat = await fs2.stat(entryAbsPath);
|
|
1998
2263
|
if (entryStat.isDirectory()) {
|
|
1999
2264
|
if (entryName === MEMORY_CACHE_DIR_RELPATH) {
|
|
@@ -2023,7 +2288,7 @@ function assertMarkdownRelPath(relPath) {
|
|
|
2023
2288
|
return normalizedRelPath;
|
|
2024
2289
|
}
|
|
2025
2290
|
function isMarkdownPath(relPath) {
|
|
2026
|
-
return
|
|
2291
|
+
return path13.posix.extname(relPath).toLowerCase() === ".md";
|
|
2027
2292
|
}
|
|
2028
2293
|
function isMissing(error2) {
|
|
2029
2294
|
return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
|
|
@@ -2031,7 +2296,7 @@ function isMissing(error2) {
|
|
|
2031
2296
|
|
|
2032
2297
|
// packages/memory/src/search.ts
|
|
2033
2298
|
import * as fs3 from "node:fs/promises";
|
|
2034
|
-
import
|
|
2299
|
+
import path14 from "node:path";
|
|
2035
2300
|
async function searchMemory(root, query) {
|
|
2036
2301
|
const normalizedQuery = query.trim();
|
|
2037
2302
|
if (normalizedQuery.length === 0) {
|
|
@@ -2040,7 +2305,7 @@ async function searchMemory(root, query) {
|
|
|
2040
2305
|
const relPaths = await collectMarkdownRelPaths(root);
|
|
2041
2306
|
const hits = [];
|
|
2042
2307
|
for (const relPath of relPaths) {
|
|
2043
|
-
const content = await fs3.readFile(
|
|
2308
|
+
const content = await fs3.readFile(path14.join(root, relPath), "utf8");
|
|
2044
2309
|
if (content.length === 0) {
|
|
2045
2310
|
continue;
|
|
2046
2311
|
}
|
|
@@ -2061,7 +2326,7 @@ async function searchMemory(root, query) {
|
|
|
2061
2326
|
|
|
2062
2327
|
// packages/memory/src/status.ts
|
|
2063
2328
|
import * as fs4 from "node:fs/promises";
|
|
2064
|
-
import
|
|
2329
|
+
import path15 from "node:path";
|
|
2065
2330
|
async function statusOf(root) {
|
|
2066
2331
|
if (!await pathExists2(root)) {
|
|
2067
2332
|
return {
|
|
@@ -2078,9 +2343,9 @@ async function statusOf(root) {
|
|
|
2078
2343
|
let totalBytes = 0;
|
|
2079
2344
|
let lastWriteAtMs = Number.NEGATIVE_INFINITY;
|
|
2080
2345
|
for (const relPath of markdownRelPaths) {
|
|
2081
|
-
const
|
|
2082
|
-
totalBytes +=
|
|
2083
|
-
lastWriteAtMs = Math.max(lastWriteAtMs,
|
|
2346
|
+
const stat7 = await fs4.stat(path15.join(root, relPath));
|
|
2347
|
+
totalBytes += stat7.size;
|
|
2348
|
+
lastWriteAtMs = Math.max(lastWriteAtMs, stat7.mtimeMs);
|
|
2084
2349
|
}
|
|
2085
2350
|
return {
|
|
2086
2351
|
pageCount: pageRelPaths.length,
|
|
@@ -2103,20 +2368,20 @@ async function pathExists2(targetPath) {
|
|
|
2103
2368
|
|
|
2104
2369
|
// packages/memory/src/edit.ts
|
|
2105
2370
|
import * as fs7 from "node:fs/promises";
|
|
2106
|
-
import
|
|
2371
|
+
import path19 from "node:path";
|
|
2107
2372
|
|
|
2108
2373
|
// packages/memory/src/write.ts
|
|
2109
2374
|
import * as fs6 from "node:fs/promises";
|
|
2110
|
-
import
|
|
2375
|
+
import path18 from "node:path";
|
|
2111
2376
|
|
|
2112
2377
|
// packages/memory/src/lock.ts
|
|
2113
|
-
import * as
|
|
2114
|
-
import
|
|
2378
|
+
import * as fsPromises2 from "node:fs/promises";
|
|
2379
|
+
import path16 from "node:path";
|
|
2115
2380
|
function createDefaultFs() {
|
|
2116
2381
|
return {
|
|
2117
|
-
readFile: (filePath, encoding) =>
|
|
2118
|
-
unlink:
|
|
2119
|
-
writeFile: (filePath, data, options) =>
|
|
2382
|
+
readFile: (filePath, encoding) => fsPromises2.readFile(filePath, encoding),
|
|
2383
|
+
unlink: fsPromises2.unlink,
|
|
2384
|
+
writeFile: (filePath, data, options) => fsPromises2.writeFile(filePath, data, options)
|
|
2120
2385
|
};
|
|
2121
2386
|
}
|
|
2122
2387
|
function sleep(ms) {
|
|
@@ -2170,7 +2435,7 @@ async function readLockPid(fs14, lockPath) {
|
|
|
2170
2435
|
}
|
|
2171
2436
|
async function withLock(root, run, options = {}) {
|
|
2172
2437
|
const fs14 = options.fs ?? createDefaultFs();
|
|
2173
|
-
const lockPath =
|
|
2438
|
+
const lockPath = path16.join(root, MEMORY_LOCK_RELPATH);
|
|
2174
2439
|
const pid = options.pid ?? process.pid;
|
|
2175
2440
|
const retries = options.retries ?? 20;
|
|
2176
2441
|
const minTimeoutMs = options.minTimeoutMs ?? 25;
|
|
@@ -2208,7 +2473,7 @@ async function withLock(root, run, options = {}) {
|
|
|
2208
2473
|
// packages/memory/src/reconcile.ts
|
|
2209
2474
|
import { createHash } from "node:crypto";
|
|
2210
2475
|
import * as fs5 from "node:fs/promises";
|
|
2211
|
-
import
|
|
2476
|
+
import path17 from "node:path";
|
|
2212
2477
|
|
|
2213
2478
|
// packages/memory/src/confidence.ts
|
|
2214
2479
|
var TAG_RE = /^<!--\s*memory:(?<verb>extracted|inferred|ambiguous)(?<rest>[^>]*?)-->\s*$/;
|
|
@@ -2420,7 +2685,7 @@ async function snapshot(root) {
|
|
|
2420
2685
|
await Promise.all(
|
|
2421
2686
|
(await collectMarkdownRelPaths(root, MEMORY_PAGES_DIR_RELPATH)).map(async (relPath) => [
|
|
2422
2687
|
relPath,
|
|
2423
|
-
hashContent(await fs5.readFile(
|
|
2688
|
+
hashContent(await fs5.readFile(path17.join(root, relPath), "utf8"))
|
|
2424
2689
|
])
|
|
2425
2690
|
)
|
|
2426
2691
|
);
|
|
@@ -2431,7 +2696,7 @@ async function reconcile(root, before, _verb, detail) {
|
|
|
2431
2696
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2432
2697
|
const currentPages = await Promise.all(
|
|
2433
2698
|
(await collectMarkdownRelPaths(root, MEMORY_PAGES_DIR_RELPATH)).map(async (relPath) => {
|
|
2434
|
-
const absPath =
|
|
2699
|
+
const absPath = path17.join(root, relPath);
|
|
2435
2700
|
const markdown = await fs5.readFile(absPath, "utf8");
|
|
2436
2701
|
const parsed = parsePageMarkdown(relPath, markdown);
|
|
2437
2702
|
const normalizedFrontmatter = withDenormalizedSources(parsed.frontmatter, parsed.body);
|
|
@@ -2453,7 +2718,7 @@ async function reconcile(root, before, _verb, detail) {
|
|
|
2453
2718
|
})
|
|
2454
2719
|
);
|
|
2455
2720
|
await Promise.all(
|
|
2456
|
-
currentPages.filter((page) => page.currentMarkdown !== page.nextMarkdown).map((page) => fs5.writeFile(
|
|
2721
|
+
currentPages.filter((page) => page.currentMarkdown !== page.nextMarkdown).map((page) => fs5.writeFile(path17.join(root, page.relPath), page.nextMarkdown, "utf8"))
|
|
2457
2722
|
);
|
|
2458
2723
|
const diff2 = diffSnapshots(before, await snapshot(root));
|
|
2459
2724
|
await writeIndex(root);
|
|
@@ -2483,7 +2748,7 @@ async function appendLogEntries(root, diff2, detail, timestamp = (/* @__PURE__ *
|
|
|
2483
2748
|
if (entries.length === 0) {
|
|
2484
2749
|
return;
|
|
2485
2750
|
}
|
|
2486
|
-
const logPath =
|
|
2751
|
+
const logPath = path17.join(root, MEMORY_LOG_RELPATH);
|
|
2487
2752
|
const existing = await fs5.readFile(logPath, "utf8");
|
|
2488
2753
|
const separator = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
2489
2754
|
await fs5.writeFile(logPath, `${existing}${separator}${entries.join("\n")}
|
|
@@ -2507,7 +2772,7 @@ async function writeIndex(root) {
|
|
|
2507
2772
|
description: page.frontmatter.description ?? ""
|
|
2508
2773
|
}))
|
|
2509
2774
|
);
|
|
2510
|
-
await fs5.writeFile(
|
|
2775
|
+
await fs5.writeFile(path17.join(root, MEMORY_INDEX_RELPATH), index, "utf8");
|
|
2511
2776
|
}
|
|
2512
2777
|
function parsePageMarkdown(relPath, markdown) {
|
|
2513
2778
|
try {
|
|
@@ -2552,9 +2817,9 @@ async function writePage(root, relPath, body, opts) {
|
|
|
2552
2817
|
const pageRelPath = assertPageRelPath(relPath);
|
|
2553
2818
|
return withLock(root, async () => {
|
|
2554
2819
|
const before = await snapshot(root);
|
|
2555
|
-
await fs6.mkdir(
|
|
2820
|
+
await fs6.mkdir(path18.dirname(path18.join(root, pageRelPath)), { recursive: true });
|
|
2556
2821
|
await fs6.writeFile(
|
|
2557
|
-
|
|
2822
|
+
path18.join(root, pageRelPath),
|
|
2558
2823
|
serializeFrontmatter(opts.frontmatter ?? {}, body),
|
|
2559
2824
|
"utf8"
|
|
2560
2825
|
);
|
|
@@ -2565,8 +2830,8 @@ async function appendToPage(root, relPath, content, opts) {
|
|
|
2565
2830
|
const pageRelPath = assertPageRelPath(relPath);
|
|
2566
2831
|
return withLock(root, async () => {
|
|
2567
2832
|
const before = await snapshot(root);
|
|
2568
|
-
const pagePath =
|
|
2569
|
-
await fs6.mkdir(
|
|
2833
|
+
const pagePath = path18.join(root, pageRelPath);
|
|
2834
|
+
await fs6.mkdir(path18.dirname(pagePath), { recursive: true });
|
|
2570
2835
|
const existing = await readMarkdownIfPresent(pagePath);
|
|
2571
2836
|
const parsed = existing === void 0 ? { frontmatter: {}, body: "" } : parseFrontmatter(existing);
|
|
2572
2837
|
await fs6.writeFile(
|
|
@@ -2588,13 +2853,13 @@ async function removeChildren(directoryPath) {
|
|
|
2588
2853
|
if (entryName === MEMORY_LOCK_RELPATH) {
|
|
2589
2854
|
continue;
|
|
2590
2855
|
}
|
|
2591
|
-
const entryPath =
|
|
2592
|
-
const
|
|
2593
|
-
if (
|
|
2856
|
+
const entryPath = path18.join(directoryPath, entryName);
|
|
2857
|
+
const stat7 = await fs6.stat(entryPath);
|
|
2858
|
+
if (stat7.isDirectory()) {
|
|
2594
2859
|
await removeDirectory2(entryPath);
|
|
2595
2860
|
continue;
|
|
2596
2861
|
}
|
|
2597
|
-
if (
|
|
2862
|
+
if (stat7.isFile()) {
|
|
2598
2863
|
await fs6.unlink(entryPath);
|
|
2599
2864
|
}
|
|
2600
2865
|
}
|
|
@@ -2605,7 +2870,7 @@ async function removeDirectory2(directoryPath) {
|
|
|
2605
2870
|
}
|
|
2606
2871
|
function assertPageRelPath(relPath) {
|
|
2607
2872
|
const normalizedRelPath = assertSafeRelPath(relPath);
|
|
2608
|
-
if (!normalizedRelPath.startsWith(`${MEMORY_PAGES_DIR_RELPATH}/`) ||
|
|
2873
|
+
if (!normalizedRelPath.startsWith(`${MEMORY_PAGES_DIR_RELPATH}/`) || path18.posix.extname(normalizedRelPath).toLowerCase() !== ".md") {
|
|
2609
2874
|
throw new Error(`Expected a markdown page path under "${MEMORY_PAGES_DIR_RELPATH}/".`);
|
|
2610
2875
|
}
|
|
2611
2876
|
return normalizedRelPath;
|
|
@@ -2623,12 +2888,12 @@ async function readMarkdownIfPresent(filePath) {
|
|
|
2623
2888
|
|
|
2624
2889
|
// packages/memory/src/edit.ts
|
|
2625
2890
|
async function editPage(root, relPath, opts) {
|
|
2626
|
-
const pagePath =
|
|
2891
|
+
const pagePath = path19.join(root, relPath);
|
|
2627
2892
|
const original = await readIfPresent(pagePath);
|
|
2628
|
-
const tempRoot =
|
|
2893
|
+
const tempRoot = path19.join(root, ".tmp");
|
|
2629
2894
|
await fs7.mkdir(tempRoot, { recursive: true });
|
|
2630
|
-
const tempDir = await fs7.mkdtemp(
|
|
2631
|
-
const tempPath =
|
|
2895
|
+
const tempDir = await fs7.mkdtemp(path19.join(tempRoot, "poe-code-memory-edit-"));
|
|
2896
|
+
const tempPath = path19.join(tempDir, path19.basename(relPath));
|
|
2632
2897
|
try {
|
|
2633
2898
|
await fs7.writeFile(tempPath, original ?? "", "utf8");
|
|
2634
2899
|
await opts.launchEditor(tempPath);
|
|
@@ -2662,7 +2927,7 @@ async function readIfPresent(filePath) {
|
|
|
2662
2927
|
|
|
2663
2928
|
// packages/memory/src/audit.ts
|
|
2664
2929
|
import * as fs8 from "node:fs/promises";
|
|
2665
|
-
import
|
|
2930
|
+
import path20 from "node:path";
|
|
2666
2931
|
var DEFAULT_MIN_INFERRED_CONFIDENCE = 0.3;
|
|
2667
2932
|
var DEFAULT_REJECT_UNTAGGED = false;
|
|
2668
2933
|
var DEFAULT_UNTAGGED_BODY_THRESHOLD_CHARS = 200;
|
|
@@ -2717,10 +2982,10 @@ async function auditSourceRef(source, claimLineNumber, repoRoot, sourceCache) {
|
|
|
2717
2982
|
if (isUrlLike(source.path)) {
|
|
2718
2983
|
return void 0;
|
|
2719
2984
|
}
|
|
2720
|
-
if (
|
|
2985
|
+
if (path20.isAbsolute(source.path)) {
|
|
2721
2986
|
return `Claim on line ${claimLineNumber} cites "${serializeSourceRef(source)}", but source paths must be repo-relative or URLs.`;
|
|
2722
2987
|
}
|
|
2723
|
-
const absPath =
|
|
2988
|
+
const absPath = path20.resolve(repoRoot, source.path);
|
|
2724
2989
|
if (!isWithinRoot(repoRoot, absPath)) {
|
|
2725
2990
|
return `Claim on line ${claimLineNumber} cites "${serializeSourceRef(source)}", which resolves outside the repo root.`;
|
|
2726
2991
|
}
|
|
@@ -2786,14 +3051,14 @@ function isUrlLike(value) {
|
|
|
2786
3051
|
return /^[a-z][a-z\d+.-]*:\/\//i.test(value);
|
|
2787
3052
|
}
|
|
2788
3053
|
function isWithinRoot(root, absPath) {
|
|
2789
|
-
const relative =
|
|
2790
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
3054
|
+
const relative = path20.relative(root, absPath);
|
|
3055
|
+
return relative === "" || !relative.startsWith("..") && !path20.isAbsolute(relative);
|
|
2791
3056
|
}
|
|
2792
3057
|
|
|
2793
3058
|
// packages/memory/src/cache.ts
|
|
2794
3059
|
import { createHash as createHash2 } from "node:crypto";
|
|
2795
3060
|
import * as fs9 from "node:fs/promises";
|
|
2796
|
-
import
|
|
3061
|
+
import path21 from "node:path";
|
|
2797
3062
|
function computeIngestKey(input) {
|
|
2798
3063
|
const hash = createHash2("sha256");
|
|
2799
3064
|
hash.update(input.sourceBytes);
|
|
@@ -2806,7 +3071,7 @@ function computeIngestKey(input) {
|
|
|
2806
3071
|
return hash.digest("hex");
|
|
2807
3072
|
}
|
|
2808
3073
|
async function readCacheEntry(root, key) {
|
|
2809
|
-
const cachePath =
|
|
3074
|
+
const cachePath = path21.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH, `${key}.json`);
|
|
2810
3075
|
let raw;
|
|
2811
3076
|
try {
|
|
2812
3077
|
raw = await fs9.readFile(cachePath, "utf8");
|
|
@@ -2825,17 +3090,17 @@ async function readCacheEntry(root, key) {
|
|
|
2825
3090
|
}
|
|
2826
3091
|
}
|
|
2827
3092
|
async function writeCacheEntry(root, entry) {
|
|
2828
|
-
await fs9.mkdir(
|
|
3093
|
+
await fs9.mkdir(path21.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH), { recursive: true });
|
|
2829
3094
|
await fs9.writeFile(
|
|
2830
|
-
|
|
3095
|
+
path21.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH, `${entry.key}.json`),
|
|
2831
3096
|
`${JSON.stringify(entry)}
|
|
2832
3097
|
`,
|
|
2833
3098
|
"utf8"
|
|
2834
3099
|
);
|
|
2835
3100
|
}
|
|
2836
3101
|
async function clearCache(root, opts = {}) {
|
|
2837
|
-
const ingestDir =
|
|
2838
|
-
const cacheDir =
|
|
3102
|
+
const ingestDir = path21.join(root, MEMORY_INGEST_CACHE_DIR_RELPATH);
|
|
3103
|
+
const cacheDir = path21.join(root, MEMORY_CACHE_DIR_RELPATH);
|
|
2839
3104
|
const fileNames = await readCacheFileNames(ingestDir);
|
|
2840
3105
|
if (fileNames.length === 0) {
|
|
2841
3106
|
if (opts.olderThanMs === void 0) {
|
|
@@ -2855,7 +3120,7 @@ async function clearCache(root, opts = {}) {
|
|
|
2855
3120
|
if (entry === null || Date.parse(entry.ingestedAt) > cutoff) {
|
|
2856
3121
|
continue;
|
|
2857
3122
|
}
|
|
2858
|
-
await fs9.rm(
|
|
3123
|
+
await fs9.rm(path21.join(ingestDir, fileName), { force: true });
|
|
2859
3124
|
removed += 1;
|
|
2860
3125
|
}
|
|
2861
3126
|
await removeEmptyDirectory(ingestDir);
|
|
@@ -2911,7 +3176,7 @@ function expectStringArray(value, field) {
|
|
|
2911
3176
|
}
|
|
2912
3177
|
async function readCacheFileNames(ingestDir) {
|
|
2913
3178
|
try {
|
|
2914
|
-
return (await fs9.readdir(ingestDir)).filter((fileName) =>
|
|
3179
|
+
return (await fs9.readdir(ingestDir)).filter((fileName) => path21.posix.extname(fileName).toLowerCase() === ".json").sort((left, right) => left.localeCompare(right));
|
|
2915
3180
|
} catch (error2) {
|
|
2916
3181
|
if (isMissing3(error2)) {
|
|
2917
3182
|
return [];
|
|
@@ -2963,7 +3228,7 @@ function parseOlderThan(value) {
|
|
|
2963
3228
|
|
|
2964
3229
|
// packages/memory/src/ingest.ts
|
|
2965
3230
|
import * as fs11 from "node:fs/promises";
|
|
2966
|
-
import
|
|
3231
|
+
import path26 from "node:path";
|
|
2967
3232
|
|
|
2968
3233
|
// packages/agent-spawn/src/run-command.ts
|
|
2969
3234
|
import { spawn } from "node:child_process";
|
|
@@ -3387,7 +3652,7 @@ function listMcpSupportedAgents() {
|
|
|
3387
3652
|
// packages/agent-spawn/src/spawn.ts
|
|
3388
3653
|
import { spawn as spawnChildProcess } from "node:child_process";
|
|
3389
3654
|
import { mkdirSync, openSync, writeSync, closeSync } from "node:fs";
|
|
3390
|
-
import
|
|
3655
|
+
import path22 from "node:path";
|
|
3391
3656
|
|
|
3392
3657
|
// packages/agent-spawn/src/configs/resolve-config.ts
|
|
3393
3658
|
function resolveConfig(agentId) {
|
|
@@ -3621,11 +3886,11 @@ function resolveSpawnLogPath(options) {
|
|
|
3621
3886
|
if (!options.logDir || !options.logFileName) {
|
|
3622
3887
|
return void 0;
|
|
3623
3888
|
}
|
|
3624
|
-
return
|
|
3889
|
+
return path22.join(options.logDir, options.logFileName);
|
|
3625
3890
|
}
|
|
3626
3891
|
function openSpawnLog(filePath) {
|
|
3627
3892
|
try {
|
|
3628
|
-
mkdirSync(
|
|
3893
|
+
mkdirSync(path22.dirname(filePath), { recursive: true });
|
|
3629
3894
|
return openSync(filePath, "a");
|
|
3630
3895
|
} catch {
|
|
3631
3896
|
return void 0;
|
|
@@ -4056,9 +4321,9 @@ import chalk16 from "chalk";
|
|
|
4056
4321
|
var DEFAULT_ACTIVITY_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
4057
4322
|
|
|
4058
4323
|
// packages/agent-spawn/src/acp/replay.ts
|
|
4059
|
-
import
|
|
4324
|
+
import path23 from "node:path";
|
|
4060
4325
|
import { homedir as homedir2 } from "node:os";
|
|
4061
|
-
import { open, readdir as readdir4 } from "node:fs/promises";
|
|
4326
|
+
import { open as open2, readdir as readdir4 } from "node:fs/promises";
|
|
4062
4327
|
import { createInterface } from "node:readline";
|
|
4063
4328
|
|
|
4064
4329
|
// packages/poe-acp-client/src/acp-client.ts
|
|
@@ -4070,7 +4335,7 @@ import {
|
|
|
4070
4335
|
} from "node:child_process";
|
|
4071
4336
|
|
|
4072
4337
|
// packages/poe-acp-client/src/run-report.ts
|
|
4073
|
-
import * as
|
|
4338
|
+
import * as fsPromises3 from "node:fs/promises";
|
|
4074
4339
|
import { homedir } from "node:os";
|
|
4075
4340
|
import { join } from "node:path";
|
|
4076
4341
|
|
|
@@ -4078,13 +4343,13 @@ import { join } from "node:path";
|
|
|
4078
4343
|
import { spawn as spawnChildProcess4 } from "node:child_process";
|
|
4079
4344
|
|
|
4080
4345
|
// packages/agent-spawn/src/acp/middlewares/spawn-log.ts
|
|
4081
|
-
import
|
|
4346
|
+
import path24 from "node:path";
|
|
4082
4347
|
import { homedir as homedir3 } from "node:os";
|
|
4083
|
-
import { mkdir as mkdir5, open as
|
|
4348
|
+
import { mkdir as mkdir5, open as open3 } from "node:fs/promises";
|
|
4084
4349
|
|
|
4085
4350
|
// packages/memory/src/tokens.ts
|
|
4086
4351
|
import * as fs10 from "node:fs/promises";
|
|
4087
|
-
import
|
|
4352
|
+
import path25 from "node:path";
|
|
4088
4353
|
|
|
4089
4354
|
// packages/tokenfill/dist/tokenizer.js
|
|
4090
4355
|
import { get_encoding } from "tiktoken";
|
|
@@ -4168,11 +4433,11 @@ async function computeTokenStats(root) {
|
|
|
4168
4433
|
}
|
|
4169
4434
|
}
|
|
4170
4435
|
}
|
|
4171
|
-
const repoRoot =
|
|
4436
|
+
const repoRoot = path25.resolve(root, "..", "..");
|
|
4172
4437
|
let sourceTokens = 0;
|
|
4173
4438
|
const missingSources = [];
|
|
4174
4439
|
for (const sourcePath of sourcePaths) {
|
|
4175
|
-
const absPath =
|
|
4440
|
+
const absPath = path25.isAbsolute(sourcePath) ? sourcePath : path25.resolve(repoRoot, sourcePath);
|
|
4176
4441
|
try {
|
|
4177
4442
|
const content = await fs10.readFile(absPath, "utf8");
|
|
4178
4443
|
sourceTokens += countTokens(content);
|
|
@@ -4223,10 +4488,10 @@ function resolveRunners(overrides) {
|
|
|
4223
4488
|
async function ingest(root, opts, runners) {
|
|
4224
4489
|
const resolved = resolveRunners(runners);
|
|
4225
4490
|
const source = await materializeSource(opts.source);
|
|
4226
|
-
const indexMdBytes = await fs11.readFile(
|
|
4491
|
+
const indexMdBytes = await fs11.readFile(path26.join(root, MEMORY_INDEX_RELPATH));
|
|
4227
4492
|
const configOptions = {
|
|
4228
4493
|
fs: fs11,
|
|
4229
|
-
filePath:
|
|
4494
|
+
filePath: path26.join(inferRepoRoot(root), "poe-code.json")
|
|
4230
4495
|
};
|
|
4231
4496
|
const agentId = await resolveAgent(configOptions, opts.agent ?? null) ?? opts.agent ?? "claude-code";
|
|
4232
4497
|
const key = resolved.computeIngestKey({
|
|
@@ -4316,7 +4581,7 @@ async function materializeSource(source) {
|
|
|
4316
4581
|
throw new Error("URL ingest not implemented yet.");
|
|
4317
4582
|
}
|
|
4318
4583
|
function inferRepoRoot(root) {
|
|
4319
|
-
return
|
|
4584
|
+
return path26.resolve(root, "..", "..");
|
|
4320
4585
|
}
|
|
4321
4586
|
async function runWithTimeout(promise, timeoutMs) {
|
|
4322
4587
|
return await new Promise((resolve2, reject) => {
|
|
@@ -5074,8 +5339,8 @@ function printMcpConfig() {
|
|
|
5074
5339
|
}
|
|
5075
5340
|
|
|
5076
5341
|
// packages/agent-skill-config/src/configs.ts
|
|
5077
|
-
import
|
|
5078
|
-
import
|
|
5342
|
+
import os3 from "node:os";
|
|
5343
|
+
import path27 from "node:path";
|
|
5079
5344
|
var agentSkillConfigs = {
|
|
5080
5345
|
"claude-code": {
|
|
5081
5346
|
globalSkillDir: "~/.claude/skills",
|
|
@@ -5108,8 +5373,8 @@ function resolveAgentSupport(input, registry = agentSkillConfigs) {
|
|
|
5108
5373
|
}
|
|
5109
5374
|
|
|
5110
5375
|
// packages/agent-skill-config/src/templates.ts
|
|
5111
|
-
import { readFile as
|
|
5112
|
-
import
|
|
5376
|
+
import { readFile as readFile12, stat as stat6 } from "node:fs/promises";
|
|
5377
|
+
import path28 from "node:path";
|
|
5113
5378
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
5114
5379
|
|
|
5115
5380
|
// packages/agent-skill-config/src/apply.ts
|
|
@@ -5242,7 +5507,7 @@ function resolveConfigPath2(config, platform) {
|
|
|
5242
5507
|
}
|
|
5243
5508
|
|
|
5244
5509
|
// packages/agent-mcp-config/src/apply.ts
|
|
5245
|
-
import
|
|
5510
|
+
import path29 from "node:path";
|
|
5246
5511
|
import { parse as parseYaml3, stringify as stringifyYaml2 } from "yaml";
|
|
5247
5512
|
|
|
5248
5513
|
// packages/agent-mcp-config/src/shapes.ts
|
|
@@ -5334,7 +5599,7 @@ function getShapeTransformer(shape) {
|
|
|
5334
5599
|
|
|
5335
5600
|
// packages/agent-mcp-config/src/apply.ts
|
|
5336
5601
|
function getConfigDirectory(configPath) {
|
|
5337
|
-
return
|
|
5602
|
+
return path29.dirname(configPath);
|
|
5338
5603
|
}
|
|
5339
5604
|
var UnsupportedAgentError2 = class extends Error {
|
|
5340
5605
|
constructor(agentId) {
|
|
@@ -5360,9 +5625,9 @@ function expandHomePath(configPath, homeDir) {
|
|
|
5360
5625
|
return homeDir;
|
|
5361
5626
|
}
|
|
5362
5627
|
if (configPath.startsWith("~/")) {
|
|
5363
|
-
return
|
|
5628
|
+
return path29.join(homeDir, configPath.slice(2));
|
|
5364
5629
|
}
|
|
5365
|
-
return
|
|
5630
|
+
return path29.join(homeDir, configPath.slice(1));
|
|
5366
5631
|
}
|
|
5367
5632
|
function parseYamlDocument(content) {
|
|
5368
5633
|
if (content.trim() === "") {
|
|
@@ -5395,7 +5660,7 @@ async function writeYamlConfig(configPath, document, options) {
|
|
|
5395
5660
|
return;
|
|
5396
5661
|
}
|
|
5397
5662
|
const absolutePath = expandHomePath(configPath, options.homeDir);
|
|
5398
|
-
const configDir =
|
|
5663
|
+
const configDir = path29.dirname(absolutePath);
|
|
5399
5664
|
await options.fs.mkdir(configDir, { recursive: true });
|
|
5400
5665
|
await options.fs.writeFile(absolutePath, serializeYamlDocument(document), {
|
|
5401
5666
|
encoding: "utf8"
|
|
@@ -5573,7 +5838,7 @@ async function installMemory(options) {
|
|
|
5573
5838
|
|
|
5574
5839
|
// packages/memory/src/query.ts
|
|
5575
5840
|
import * as fs12 from "node:fs/promises";
|
|
5576
|
-
import
|
|
5841
|
+
import path30 from "node:path";
|
|
5577
5842
|
async function queryMemory(root, options) {
|
|
5578
5843
|
const pages = await listPages(root);
|
|
5579
5844
|
if (pages.length === 0) {
|
|
@@ -5587,7 +5852,7 @@ async function queryMemory(root, options) {
|
|
|
5587
5852
|
}
|
|
5588
5853
|
const configOptions = {
|
|
5589
5854
|
fs: fs12,
|
|
5590
|
-
filePath:
|
|
5855
|
+
filePath: path30.join(inferRepoRoot2(root), "poe-code.json")
|
|
5591
5856
|
};
|
|
5592
5857
|
const agentId = await resolveAgent(configOptions, options.agent ?? null) ?? options.agent ?? "claude-code";
|
|
5593
5858
|
const context = await selectQueryContext(root, options.question, options.budget);
|
|
@@ -5602,7 +5867,7 @@ async function queryMemory(root, options) {
|
|
|
5602
5867
|
}
|
|
5603
5868
|
async function selectQueryContext(root, question, budget) {
|
|
5604
5869
|
const [indexText, pages] = await Promise.all([
|
|
5605
|
-
fs12.readFile(
|
|
5870
|
+
fs12.readFile(path30.join(root, MEMORY_INDEX_RELPATH), "utf8"),
|
|
5606
5871
|
listPages(root)
|
|
5607
5872
|
]);
|
|
5608
5873
|
const indexTokens = countTokens(indexText);
|
|
@@ -5681,12 +5946,12 @@ function tokenize(text4) {
|
|
|
5681
5946
|
return text4.toLowerCase().split(/[^a-z0-9]+/).filter((token) => token.length > 0);
|
|
5682
5947
|
}
|
|
5683
5948
|
function inferRepoRoot2(root) {
|
|
5684
|
-
return
|
|
5949
|
+
return path30.resolve(root, "..", "..");
|
|
5685
5950
|
}
|
|
5686
5951
|
|
|
5687
5952
|
// packages/memory/src/explain.ts
|
|
5688
5953
|
import * as fs13 from "node:fs/promises";
|
|
5689
|
-
import
|
|
5954
|
+
import path31 from "node:path";
|
|
5690
5955
|
async function explainPage(root, options) {
|
|
5691
5956
|
const targetPage = await readPageIfPresent(root, options.relPath);
|
|
5692
5957
|
if (targetPage === void 0) {
|
|
@@ -5709,7 +5974,7 @@ async function explainPage(root, options) {
|
|
|
5709
5974
|
}
|
|
5710
5975
|
const configOptions = {
|
|
5711
5976
|
fs: fs13,
|
|
5712
|
-
filePath:
|
|
5977
|
+
filePath: path31.join(inferRepoRoot3(root), "poe-code.json")
|
|
5713
5978
|
};
|
|
5714
5979
|
const agentId = await resolveAgent(configOptions, options.agent ?? null) ?? options.agent ?? "claude-code";
|
|
5715
5980
|
const response = await spawn2(agentId, { prompt });
|
|
@@ -5758,7 +6023,7 @@ async function readPageIfPresent(root, relPath) {
|
|
|
5758
6023
|
}
|
|
5759
6024
|
}
|
|
5760
6025
|
function inferRepoRoot3(root) {
|
|
5761
|
-
return
|
|
6026
|
+
return path31.resolve(root, "..", "..");
|
|
5762
6027
|
}
|
|
5763
6028
|
|
|
5764
6029
|
// packages/memory/src/explain.cli.ts
|
|
@@ -5771,9 +6036,9 @@ async function runMemoryExplain(input) {
|
|
|
5771
6036
|
}
|
|
5772
6037
|
|
|
5773
6038
|
// packages/memory/src/handle.ts
|
|
5774
|
-
import
|
|
6039
|
+
import path32 from "node:path";
|
|
5775
6040
|
function openMemory(opts) {
|
|
5776
|
-
if (!
|
|
6041
|
+
if (!path32.isAbsolute(opts.root)) {
|
|
5777
6042
|
throw new Error(`openMemory: root must be absolute, got ${opts.root}`);
|
|
5778
6043
|
}
|
|
5779
6044
|
const root = opts.root;
|