archondev 2.19.54 → 2.19.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TZNB4BPI.js → chunk-DDAOREZF.js} +1 -1
- package/dist/{chunk-TG3ELXS3.js → chunk-ICPOD7FC.js} +73 -12
- package/dist/{chunk-L3FRKAIO.js → chunk-K6A6CWUG.js} +1 -1
- package/dist/{chunk-SAM5CXO4.js → chunk-LM5UBTSS.js} +38 -1
- package/dist/{chunk-R4A2C42M.js → chunk-QKHRSVUO.js} +76 -12
- package/dist/chunk-R664NEAA.js +66 -0
- package/dist/{chunk-XHIVKDU5.js → chunk-TNS5OLCD.js} +1 -1
- package/dist/{execute-HQ5XANCR.js → execute-4KDY6MOO.js} +3 -2
- package/dist/index.js +89 -33
- package/dist/{list-QKB55FIY.js → list-D4THOSHG.js} +3 -2
- package/dist/{parallel-WCUTC4FM.js → parallel-HUAAE6PS.js} +3 -2
- package/dist/{plan-V57SS7O6.js → plan-7YU2U4RY.js} +2 -1
- package/dist/{preferences-MTGN2VZK.js → preferences-QTPQLCXN.js} +2 -1
- package/dist/{show-QDTDTY4P.js → show-VLTLYZDI.js} +3 -2
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
UsageRecorder,
|
|
8
8
|
handleInsufficientCreditsRecovery,
|
|
9
9
|
loadAtom
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-QKHRSVUO.js";
|
|
11
11
|
import {
|
|
12
12
|
transitionAtom
|
|
13
13
|
} from "./chunk-WGLVDEZC.js";
|
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
AnthropicClient,
|
|
16
16
|
getDefaultModel
|
|
17
17
|
} from "./chunk-F7R3QKHP.js";
|
|
18
|
+
import {
|
|
19
|
+
debugLog,
|
|
20
|
+
getDebugLogPath
|
|
21
|
+
} from "./chunk-R664NEAA.js";
|
|
18
22
|
import {
|
|
19
23
|
createAuthedSupabaseClient
|
|
20
24
|
} from "./chunk-Q3GIFHIQ.js";
|
|
@@ -4208,11 +4212,12 @@ var ExecutorAgent = class {
|
|
|
4208
4212
|
rollbackPerformed: false
|
|
4209
4213
|
};
|
|
4210
4214
|
}
|
|
4211
|
-
const
|
|
4215
|
+
const reconciledDiffs = this.reconcileOutOfScopeDiffs(diffs, plan);
|
|
4216
|
+
const violations = this.checkArchitectureViolations(reconciledDiffs, plan, architecture);
|
|
4212
4217
|
if (violations.length > 0) {
|
|
4213
4218
|
return {
|
|
4214
4219
|
success: false,
|
|
4215
|
-
diffs,
|
|
4220
|
+
diffs: reconciledDiffs,
|
|
4216
4221
|
usage: response.usage,
|
|
4217
4222
|
qualityChecksPassed: false,
|
|
4218
4223
|
errorMessage: `Architecture violations: ${violations.join(", ")}`,
|
|
@@ -4221,7 +4226,7 @@ var ExecutorAgent = class {
|
|
|
4221
4226
|
}
|
|
4222
4227
|
const originalContents = /* @__PURE__ */ new Map();
|
|
4223
4228
|
try {
|
|
4224
|
-
for (const diff of
|
|
4229
|
+
for (const diff of reconciledDiffs) {
|
|
4225
4230
|
const fullPath = `${cwd}/${diff.path}`;
|
|
4226
4231
|
if (existsSync6(fullPath)) {
|
|
4227
4232
|
originalContents.set(diff.path, await readFile5(fullPath, "utf-8"));
|
|
@@ -4229,7 +4234,7 @@ var ExecutorAgent = class {
|
|
|
4229
4234
|
originalContents.set(diff.path, null);
|
|
4230
4235
|
}
|
|
4231
4236
|
}
|
|
4232
|
-
for (const diff of
|
|
4237
|
+
for (const diff of reconciledDiffs) {
|
|
4233
4238
|
const fullPath = `${cwd}/${diff.path}`;
|
|
4234
4239
|
if (diff.operation === "DELETE") {
|
|
4235
4240
|
continue;
|
|
@@ -4242,10 +4247,10 @@ var ExecutorAgent = class {
|
|
|
4242
4247
|
}
|
|
4243
4248
|
const qualityChecksPassed = await this.runQualityChecks(cwd);
|
|
4244
4249
|
if (!qualityChecksPassed) {
|
|
4245
|
-
await this.rollback(cwd, originalContents,
|
|
4250
|
+
await this.rollback(cwd, originalContents, reconciledDiffs);
|
|
4246
4251
|
return {
|
|
4247
4252
|
success: false,
|
|
4248
|
-
diffs,
|
|
4253
|
+
diffs: reconciledDiffs,
|
|
4249
4254
|
usage: response.usage,
|
|
4250
4255
|
qualityChecksPassed: false,
|
|
4251
4256
|
errorMessage: "Quality checks failed - changes rolled back",
|
|
@@ -4254,16 +4259,16 @@ var ExecutorAgent = class {
|
|
|
4254
4259
|
}
|
|
4255
4260
|
return {
|
|
4256
4261
|
success: true,
|
|
4257
|
-
diffs,
|
|
4262
|
+
diffs: reconciledDiffs,
|
|
4258
4263
|
usage: response.usage,
|
|
4259
4264
|
qualityChecksPassed: true,
|
|
4260
4265
|
rollbackPerformed: false
|
|
4261
4266
|
};
|
|
4262
4267
|
} catch (error) {
|
|
4263
|
-
await this.rollback(cwd, originalContents,
|
|
4268
|
+
await this.rollback(cwd, originalContents, reconciledDiffs);
|
|
4264
4269
|
return {
|
|
4265
4270
|
success: false,
|
|
4266
|
-
diffs,
|
|
4271
|
+
diffs: reconciledDiffs,
|
|
4267
4272
|
usage: response.usage,
|
|
4268
4273
|
qualityChecksPassed: false,
|
|
4269
4274
|
errorMessage: error instanceof Error ? error.message : "Unknown error",
|
|
@@ -4436,6 +4441,33 @@ var ExecutorAgent = class {
|
|
|
4436
4441
|
const regexPattern = pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\//g, "\\/");
|
|
4437
4442
|
return new RegExp(`^${regexPattern}$`).test(path);
|
|
4438
4443
|
}
|
|
4444
|
+
reconcileOutOfScopeDiffs(diffs, plan) {
|
|
4445
|
+
const allowedFiles = plan.files_to_modify;
|
|
4446
|
+
if (allowedFiles.length !== 1 || diffs.length !== 1) {
|
|
4447
|
+
return diffs;
|
|
4448
|
+
}
|
|
4449
|
+
const onlyAllowed = this.normalizePath(allowedFiles[0]);
|
|
4450
|
+
const candidate = diffs[0];
|
|
4451
|
+
if (!onlyAllowed || !candidate) {
|
|
4452
|
+
return diffs;
|
|
4453
|
+
}
|
|
4454
|
+
const normalizedDiffPath = this.normalizePath(candidate.path);
|
|
4455
|
+
if (normalizedDiffPath === onlyAllowed) {
|
|
4456
|
+
return diffs;
|
|
4457
|
+
}
|
|
4458
|
+
const contentLike = /\.(md|markdown|txt)$/i.test(onlyAllowed) && /\.(md|markdown|txt)$/i.test(normalizedDiffPath);
|
|
4459
|
+
const sameDir = dirname2(normalizedDiffPath) === dirname2(onlyAllowed);
|
|
4460
|
+
if (!contentLike || !sameDir) {
|
|
4461
|
+
return diffs;
|
|
4462
|
+
}
|
|
4463
|
+
return [{
|
|
4464
|
+
...candidate,
|
|
4465
|
+
path: onlyAllowed
|
|
4466
|
+
}];
|
|
4467
|
+
}
|
|
4468
|
+
normalizePath(path) {
|
|
4469
|
+
return path.replace(/\\/g, "/").replace(/^\.?\//, "");
|
|
4470
|
+
}
|
|
4439
4471
|
/**
|
|
4440
4472
|
* Run quality checks (typecheck, lint)
|
|
4441
4473
|
*/
|
|
@@ -4835,7 +4867,7 @@ async function attemptPathScopeAutoRecovery(atom, cwd, parseSchema, options) {
|
|
|
4835
4867
|
if (allowedPaths.length === 0) {
|
|
4836
4868
|
return false;
|
|
4837
4869
|
}
|
|
4838
|
-
const { listLocalAtoms, plan } = await import("./plan-
|
|
4870
|
+
const { listLocalAtoms, plan } = await import("./plan-7YU2U4RY.js");
|
|
4839
4871
|
const before = await listLocalAtoms();
|
|
4840
4872
|
const recoveryStartedAt = Date.now();
|
|
4841
4873
|
const recoverySource = atom.description ?? atom.title;
|
|
@@ -4903,13 +4935,18 @@ async function execute(atomId, options) {
|
|
|
4903
4935
|
process.exit(1);
|
|
4904
4936
|
};
|
|
4905
4937
|
if (options.parallel && options.parallel.length > 0) {
|
|
4906
|
-
const { parallelExecute } = await import("./parallel-
|
|
4938
|
+
const { parallelExecute } = await import("./parallel-HUAAE6PS.js");
|
|
4907
4939
|
const allAtomIds = [atomId, ...options.parallel];
|
|
4908
4940
|
await parallelExecute(allAtomIds, { skipGates: options.skipGates === true });
|
|
4909
4941
|
return;
|
|
4910
4942
|
}
|
|
4911
4943
|
const prompt = createPrompt();
|
|
4912
4944
|
const cwd = process.cwd();
|
|
4945
|
+
const debugPath = getDebugLogPath();
|
|
4946
|
+
if (debugPath) {
|
|
4947
|
+
console.log(chalk2.dim(`Debug logging enabled: ${debugPath}`));
|
|
4948
|
+
}
|
|
4949
|
+
debugLog("execute", "start", "Execute command started", { atomId, options });
|
|
4913
4950
|
try {
|
|
4914
4951
|
if (options.cloud) {
|
|
4915
4952
|
const config2 = await loadConfig();
|
|
@@ -5121,9 +5158,23 @@ ${conflictReport.blockerCount} blocking conflict(s) found.`));
|
|
|
5121
5158
|
}
|
|
5122
5159
|
}
|
|
5123
5160
|
const executionResult = await executor.executeAtom(atom, atom.plan, parseResult.schema, cwd);
|
|
5161
|
+
debugLog("execute", "result.received", "Executor returned execution result", {
|
|
5162
|
+
success: executionResult.success,
|
|
5163
|
+
rollbackPerformed: executionResult.rollbackPerformed,
|
|
5164
|
+
diffPaths: executionResult.diffs.map((d) => d.path),
|
|
5165
|
+
errorMessage: executionResult.errorMessage ?? null,
|
|
5166
|
+
plannedFiles: atom.plan.files_to_modify
|
|
5167
|
+
});
|
|
5124
5168
|
const filesChanged = executionResult.diffs.map((d) => d.path);
|
|
5125
5169
|
if (!executionResult.success) {
|
|
5126
5170
|
if (isGovernanceViolation(executionResult.errorMessage)) {
|
|
5171
|
+
debugLog("execute", "result.governance_violation", "Execution blocked by governance", {
|
|
5172
|
+
atomId: atom.externalId,
|
|
5173
|
+
errorMessage: executionResult.errorMessage ?? null,
|
|
5174
|
+
diffPaths: executionResult.diffs.map((d) => d.path),
|
|
5175
|
+
plannedFiles: atom.plan.files_to_modify,
|
|
5176
|
+
violations: extractGovernanceViolations(executionResult.errorMessage)
|
|
5177
|
+
});
|
|
5127
5178
|
console.log(chalk2.yellow("\n\u26A0\uFE0F Execution paused by governance guidance"));
|
|
5128
5179
|
console.log(chalk2.dim("No changes were committed. Update the plan/path scope, then continue."));
|
|
5129
5180
|
const violations = extractGovernanceViolations(executionResult.errorMessage);
|
|
@@ -5164,6 +5215,10 @@ ${conflictReport.blockerCount} blocking conflict(s) found.`));
|
|
|
5164
5215
|
if (isGovernanceViolation(executionResult.errorMessage)) {
|
|
5165
5216
|
const pathScopeViolation = isPathScopeGovernanceViolation(executionResult.errorMessage);
|
|
5166
5217
|
if (pathScopeViolation && options.pathScopeAutoRecover !== false) {
|
|
5218
|
+
debugLog("execute", "auto_recover.attempt", "Attempting path-scope auto recovery", {
|
|
5219
|
+
atomId: atom.externalId,
|
|
5220
|
+
autoRecoverDepth: options.autoRecoverDepth ?? 0
|
|
5221
|
+
});
|
|
5167
5222
|
const recovered = await attemptPathScopeAutoRecovery(
|
|
5168
5223
|
atom,
|
|
5169
5224
|
cwd,
|
|
@@ -5171,8 +5226,14 @@ ${conflictReport.blockerCount} blocking conflict(s) found.`));
|
|
|
5171
5226
|
options
|
|
5172
5227
|
);
|
|
5173
5228
|
if (recovered) {
|
|
5229
|
+
debugLog("execute", "auto_recover.success", "Path-scope auto recovery succeeded", {
|
|
5230
|
+
atomId: atom.externalId
|
|
5231
|
+
});
|
|
5174
5232
|
return;
|
|
5175
5233
|
}
|
|
5234
|
+
debugLog("execute", "auto_recover.failed", "Path-scope auto recovery did not produce a replacement atom", {
|
|
5235
|
+
atomId: atom.externalId
|
|
5236
|
+
});
|
|
5176
5237
|
}
|
|
5177
5238
|
printExecuteNextActions(
|
|
5178
5239
|
atom.externalId,
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
debugLog,
|
|
3
|
+
getDebugLogPath
|
|
4
|
+
} from "./chunk-R664NEAA.js";
|
|
1
5
|
import {
|
|
2
6
|
createAuthedSupabaseClient
|
|
3
7
|
} from "./chunk-Q3GIFHIQ.js";
|
|
@@ -1312,12 +1316,26 @@ function aggregateUsageRows(rows, start, end) {
|
|
|
1312
1316
|
return { totalInputTokens, totalOutputTokens, totalCost, byModel };
|
|
1313
1317
|
}
|
|
1314
1318
|
async function showUsageDetails(options = {}) {
|
|
1315
|
-
const { pauseForInput = false } = options;
|
|
1319
|
+
const { pauseForInput = false, debug = false } = options;
|
|
1316
1320
|
console.log(chalk.bold("\n-- Usage Details --\n"));
|
|
1321
|
+
if (debug) {
|
|
1322
|
+
const debugPath = getDebugLogPath();
|
|
1323
|
+
if (debugPath) {
|
|
1324
|
+
console.log(chalk.dim(`Debug logging enabled: ${debugPath}`));
|
|
1325
|
+
} else {
|
|
1326
|
+
console.log(chalk.dim("Tip: set ARCHON_DEBUG=1 to persist diagnostics to .archon/debug/*.log"));
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1317
1329
|
const spinner = ora("Loading usage data...").start();
|
|
1318
1330
|
const config = await loadConfig();
|
|
1319
1331
|
const authToken = getAuthToken(config);
|
|
1320
1332
|
const authId = config.userId;
|
|
1333
|
+
if (debug) {
|
|
1334
|
+
debugLog("usage", "start", "Usage command started", {
|
|
1335
|
+
authId: authId ?? null,
|
|
1336
|
+
hasToken: !!authToken
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1321
1339
|
if (!authToken) {
|
|
1322
1340
|
spinner.fail("Not logged in");
|
|
1323
1341
|
return;
|
|
@@ -1327,6 +1345,11 @@ async function showUsageDetails(options = {}) {
|
|
|
1327
1345
|
const response = await fetch(`${apiUrl}/api/usage`, {
|
|
1328
1346
|
headers: { "Authorization": `Bearer ${authToken}` }
|
|
1329
1347
|
});
|
|
1348
|
+
if (debug) {
|
|
1349
|
+
debugLog("usage", "api.response", "Received /api/usage response", {
|
|
1350
|
+
status: response.status
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1330
1353
|
spinner.stop();
|
|
1331
1354
|
if (!response.ok) {
|
|
1332
1355
|
console.log(chalk.yellow("Unable to fetch usage data."));
|
|
@@ -1335,6 +1358,9 @@ async function showUsageDetails(options = {}) {
|
|
|
1335
1358
|
const data = await response.json();
|
|
1336
1359
|
if (data.tier === "BYOK") {
|
|
1337
1360
|
const ids = await resolveAuthAndProfileIds(authToken, authId);
|
|
1361
|
+
if (debug) {
|
|
1362
|
+
debugLog("usage", "byok.identity", "Resolved auth/profile IDs for BYOK usage command", ids);
|
|
1363
|
+
}
|
|
1338
1364
|
if (!ids.authId || !ids.profileId) {
|
|
1339
1365
|
console.log(chalk.yellow("Unable to resolve user ID for usage details."));
|
|
1340
1366
|
return;
|
|
@@ -1342,6 +1368,14 @@ async function showUsageDetails(options = {}) {
|
|
|
1342
1368
|
const now = /* @__PURE__ */ new Date();
|
|
1343
1369
|
const yearStart = new Date(now.getFullYear(), 0, 1);
|
|
1344
1370
|
const usageRows = await fetchUsageRows(authToken, ids.profileId, yearStart.toISOString(), now.toISOString());
|
|
1371
|
+
if (debug) {
|
|
1372
|
+
debugLog("usage", "byok.rows", "Fetched BYOK token usage rows", {
|
|
1373
|
+
profileId: ids.profileId,
|
|
1374
|
+
rowCount: usageRows?.length ?? 0,
|
|
1375
|
+
start: yearStart.toISOString(),
|
|
1376
|
+
end: now.toISOString()
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1345
1379
|
if (!usageRows) {
|
|
1346
1380
|
console.log(chalk.yellow("Unable to fetch BYOK usage data."));
|
|
1347
1381
|
return;
|
|
@@ -1412,6 +1446,9 @@ async function showUsageDetails(options = {}) {
|
|
|
1412
1446
|
}
|
|
1413
1447
|
}
|
|
1414
1448
|
} catch {
|
|
1449
|
+
if (debug) {
|
|
1450
|
+
debugLog("usage", "error", "Usage command threw exception");
|
|
1451
|
+
}
|
|
1415
1452
|
spinner.stop();
|
|
1416
1453
|
console.log(chalk.yellow("Error fetching usage data."));
|
|
1417
1454
|
}
|
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
AnthropicClient,
|
|
10
10
|
getDefaultModel
|
|
11
11
|
} from "./chunk-F7R3QKHP.js";
|
|
12
|
+
import {
|
|
13
|
+
debugLog
|
|
14
|
+
} from "./chunk-R664NEAA.js";
|
|
12
15
|
import {
|
|
13
16
|
createAuthedSupabaseClient
|
|
14
17
|
} from "./chunk-Q3GIFHIQ.js";
|
|
@@ -38,7 +41,7 @@ import {
|
|
|
38
41
|
import chalk2 from "chalk";
|
|
39
42
|
import { existsSync } from "fs";
|
|
40
43
|
import { readFile, writeFile, mkdir, stat } from "fs/promises";
|
|
41
|
-
import { join, dirname, basename, extname } from "path";
|
|
44
|
+
import { join, dirname, basename, extname, isAbsolute, resolve, relative } from "path";
|
|
42
45
|
import { createInterface } from "readline";
|
|
43
46
|
|
|
44
47
|
// src/agents/sentinel.ts
|
|
@@ -851,14 +854,14 @@ function isUuid(value) {
|
|
|
851
854
|
import chalk from "chalk";
|
|
852
855
|
import readline from "readline";
|
|
853
856
|
function prompt(question) {
|
|
854
|
-
return new Promise((
|
|
857
|
+
return new Promise((resolve2) => {
|
|
855
858
|
const rl = readline.createInterface({
|
|
856
859
|
input: process.stdin,
|
|
857
860
|
output: process.stdout
|
|
858
861
|
});
|
|
859
862
|
rl.question(`${chalk.cyan("?")} ${question}: `, (answer) => {
|
|
860
863
|
rl.close();
|
|
861
|
-
|
|
864
|
+
resolve2(answer.trim());
|
|
862
865
|
});
|
|
863
866
|
});
|
|
864
867
|
}
|
|
@@ -899,8 +902,8 @@ function createPrompt() {
|
|
|
899
902
|
output: process.stdout
|
|
900
903
|
});
|
|
901
904
|
return {
|
|
902
|
-
ask: (question) => new Promise((
|
|
903
|
-
rl.question(question,
|
|
905
|
+
ask: (question) => new Promise((resolve2) => {
|
|
906
|
+
rl.question(question, resolve2);
|
|
904
907
|
}),
|
|
905
908
|
close: () => rl.close()
|
|
906
909
|
};
|
|
@@ -930,7 +933,15 @@ async function plan(description, options) {
|
|
|
930
933
|
}
|
|
931
934
|
const requirements = extractNumberedRequirements(description);
|
|
932
935
|
const references = extractReferencedFiles(description);
|
|
936
|
+
debugLog("plan", "references.extracted", "Referenced files extracted from prompt", {
|
|
937
|
+
references
|
|
938
|
+
});
|
|
933
939
|
const { foundFiles, missingFiles, fileSummaries } = await loadReferencedFileSummaries(references);
|
|
940
|
+
debugLog("plan", "references.resolved", "Referenced files resolved on disk", {
|
|
941
|
+
foundFiles,
|
|
942
|
+
missingFiles,
|
|
943
|
+
summaryCount: fileSummaries.length
|
|
944
|
+
});
|
|
934
945
|
if (references.length > 0) {
|
|
935
946
|
console.log(chalk2.dim("\nReferenced inputs detected:"));
|
|
936
947
|
for (const ref of references) {
|
|
@@ -1595,9 +1606,8 @@ function resolveContentOutputTargets(description, referencedFiles, deliverableTa
|
|
|
1595
1606
|
}
|
|
1596
1607
|
function deriveDefaultContentOutputPath(description, referencedFiles) {
|
|
1597
1608
|
const sampleSuffix = /\b(sample|first lesson)\b/i.test(description) ? ".sample-capsule" : ".capsule";
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1600
|
-
);
|
|
1609
|
+
const desiredDay = inferRequestedDay(description);
|
|
1610
|
+
const preferredRef = pickPreferredReference(referencedFiles, desiredDay);
|
|
1601
1611
|
const primaryRef = preferredRef ?? referencedFiles.find((ref) => /\.(md|txt|markdown)$/i.test(ref));
|
|
1602
1612
|
if (!primaryRef) {
|
|
1603
1613
|
return `daily-exercises/capsule-output${sampleSuffix}.md`;
|
|
@@ -1606,12 +1616,19 @@ function deriveDefaultContentOutputPath(description, referencedFiles) {
|
|
|
1606
1616
|
const fileBase = basename(primaryRef, extname(primaryRef));
|
|
1607
1617
|
const outName = `${fileBase}${sampleSuffix}.md`;
|
|
1608
1618
|
const output = baseDir === "." ? `daily-exercises/${outName}` : join(baseDir, outName);
|
|
1609
|
-
|
|
1619
|
+
const normalizedOutput = output.replace(/\\/g, "/");
|
|
1620
|
+
debugLog("plan", "outputs.derived", "Derived default content output path", {
|
|
1621
|
+
desiredDay,
|
|
1622
|
+
primaryRef,
|
|
1623
|
+
output: normalizedOutput
|
|
1624
|
+
});
|
|
1625
|
+
return normalizedOutput;
|
|
1610
1626
|
}
|
|
1611
1627
|
function extractReferencedFiles(description) {
|
|
1612
1628
|
const references = /* @__PURE__ */ new Set();
|
|
1613
1629
|
const barePattern = /\b[\w./-]+\.(md|txt|json|yaml|yml|png|jpg|jpeg|gif|svg|pdf)\b/gi;
|
|
1614
|
-
const
|
|
1630
|
+
const absolutePattern = /(?:^|[\s("'`])((?:\/[^"'`\s]+)+\.(?:md|txt|json|yaml|yml|png|jpg|jpeg|gif|svg|pdf))/gi;
|
|
1631
|
+
const quotedPattern = /["']([^"']+\.(?:md|txt|json|yaml|yml|png|jpg|jpeg|gif|svg|pdf))["']/gi;
|
|
1615
1632
|
let match;
|
|
1616
1633
|
while ((match = quotedPattern.exec(description)) !== null) {
|
|
1617
1634
|
if (match[1]) {
|
|
@@ -1623,6 +1640,11 @@ function extractReferencedFiles(description) {
|
|
|
1623
1640
|
references.add(match[0].replace(/["'`,]/g, "").trim());
|
|
1624
1641
|
}
|
|
1625
1642
|
}
|
|
1643
|
+
while ((match = absolutePattern.exec(description)) !== null) {
|
|
1644
|
+
if (match[1]) {
|
|
1645
|
+
references.add(match[1].replace(/["'`,]/g, "").trim());
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1626
1648
|
return Array.from(references).filter((ref) => ref.length > 0);
|
|
1627
1649
|
}
|
|
1628
1650
|
async function loadReferencedFileSummaries(references) {
|
|
@@ -1630,13 +1652,21 @@ async function loadReferencedFileSummaries(references) {
|
|
|
1630
1652
|
const missingFiles = [];
|
|
1631
1653
|
const fileSummaries = [];
|
|
1632
1654
|
for (const ref of references) {
|
|
1633
|
-
const
|
|
1634
|
-
const absolute = join(process.cwd(), normalized);
|
|
1655
|
+
const absolute = resolveReferencePath(process.cwd(), ref);
|
|
1635
1656
|
if (!existsSync(absolute)) {
|
|
1636
1657
|
missingFiles.push(ref);
|
|
1658
|
+
debugLog("plan", "references.missing", "Referenced file missing on disk", {
|
|
1659
|
+
ref,
|
|
1660
|
+
absolute
|
|
1661
|
+
});
|
|
1637
1662
|
continue;
|
|
1638
1663
|
}
|
|
1639
1664
|
foundFiles.push(ref);
|
|
1665
|
+
debugLog("plan", "references.found", "Referenced file found on disk", {
|
|
1666
|
+
ref,
|
|
1667
|
+
absolute,
|
|
1668
|
+
relative: relative(process.cwd(), absolute).replace(/\\/g, "/")
|
|
1669
|
+
});
|
|
1640
1670
|
const isImage = /\.(png|jpg|jpeg|gif|svg)$/i.test(ref);
|
|
1641
1671
|
if (isImage) {
|
|
1642
1672
|
try {
|
|
@@ -1669,6 +1699,40 @@ async function loadReferencedFileSummaries(references) {
|
|
|
1669
1699
|
}
|
|
1670
1700
|
return { foundFiles, missingFiles, fileSummaries };
|
|
1671
1701
|
}
|
|
1702
|
+
function resolveReferencePath(cwd, ref) {
|
|
1703
|
+
const cleaned = ref.trim().replace(/^["']|["']$/g, "");
|
|
1704
|
+
if (isAbsolute(cleaned)) {
|
|
1705
|
+
return resolve(cleaned);
|
|
1706
|
+
}
|
|
1707
|
+
return resolve(cwd, cleaned.replace(/^\.?\//, ""));
|
|
1708
|
+
}
|
|
1709
|
+
function inferRequestedDay(description) {
|
|
1710
|
+
if (/\bfirst lesson\b/i.test(description)) return 1;
|
|
1711
|
+
const dayMatch = description.match(/\bday[\s_-]*0?(\d{1,2})\b/i);
|
|
1712
|
+
if (!dayMatch?.[1]) return null;
|
|
1713
|
+
const parsed = Number.parseInt(dayMatch[1], 10);
|
|
1714
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
1715
|
+
}
|
|
1716
|
+
function pickPreferredReference(referencedFiles, desiredDay) {
|
|
1717
|
+
const markdownRefs = referencedFiles.filter((ref) => /\.(md|txt|markdown)$/i.test(ref));
|
|
1718
|
+
if (markdownRefs.length === 0) return void 0;
|
|
1719
|
+
const prioritized = markdownRefs.slice().sort((a, b) => {
|
|
1720
|
+
const aOld = /(^|\/)oldies(\/|$)/i.test(a) ? 1 : 0;
|
|
1721
|
+
const bOld = /(^|\/)oldies(\/|$)/i.test(b) ? 1 : 0;
|
|
1722
|
+
if (aOld !== bOld) return aOld - bOld;
|
|
1723
|
+
const aCore = /^(daily-exercises|curriculum|research)\//i.test(a) ? 0 : 1;
|
|
1724
|
+
const bCore = /^(daily-exercises|curriculum|research)\//i.test(b) ? 0 : 1;
|
|
1725
|
+
return aCore - bCore;
|
|
1726
|
+
});
|
|
1727
|
+
if (desiredDay !== null) {
|
|
1728
|
+
const matchByDay = prioritized.find((ref) => {
|
|
1729
|
+
const dayPattern = new RegExp(`\\b(day|lesson|email[-_ ]day)[-_ ]?0*${desiredDay}\\b`, "i");
|
|
1730
|
+
return dayPattern.test(ref);
|
|
1731
|
+
});
|
|
1732
|
+
if (matchByDay) return matchByDay;
|
|
1733
|
+
}
|
|
1734
|
+
return prioritized[0];
|
|
1735
|
+
}
|
|
1672
1736
|
async function promptForDeliverableTarget(prompt2, requirements, references) {
|
|
1673
1737
|
const mentionsResearch = requirements.some((req) => req.toLowerCase().includes("research"));
|
|
1674
1738
|
const defaultTarget = references.find((ref) => ref.toLowerCase().endsWith(".md"));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/cli/debug.ts
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
function isDebugEnabled() {
|
|
5
|
+
const value = process.env["ARCHON_DEBUG"]?.trim().toLowerCase();
|
|
6
|
+
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
7
|
+
}
|
|
8
|
+
function createRunId() {
|
|
9
|
+
const now = /* @__PURE__ */ new Date();
|
|
10
|
+
const yyyy = String(now.getFullYear());
|
|
11
|
+
const mm = String(now.getMonth() + 1).padStart(2, "0");
|
|
12
|
+
const dd = String(now.getDate()).padStart(2, "0");
|
|
13
|
+
const hh = String(now.getHours()).padStart(2, "0");
|
|
14
|
+
const mi = String(now.getMinutes()).padStart(2, "0");
|
|
15
|
+
const ss = String(now.getSeconds()).padStart(2, "0");
|
|
16
|
+
return `${yyyy}${mm}${dd}-${hh}${mi}${ss}-${process.pid}`;
|
|
17
|
+
}
|
|
18
|
+
var RUN_ID = createRunId();
|
|
19
|
+
var LOG_PATH = join(process.cwd(), ".archon", "debug", `${RUN_ID}.log`);
|
|
20
|
+
function redactValue(value) {
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
if (value.length > 3e3) {
|
|
23
|
+
return `${value.slice(0, 3e3)}... [truncated]`;
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
return value.map(redactValue);
|
|
29
|
+
}
|
|
30
|
+
if (value && typeof value === "object") {
|
|
31
|
+
const out = {};
|
|
32
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
33
|
+
if (/(token|secret|key|password|authorization|auth)/i.test(key)) {
|
|
34
|
+
out[key] = "[redacted]";
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
out[key] = redactValue(nested);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
function getDebugLogPath() {
|
|
44
|
+
return isDebugEnabled() ? LOG_PATH : null;
|
|
45
|
+
}
|
|
46
|
+
function debugLog(scope, stage, message, data) {
|
|
47
|
+
if (!isDebugEnabled()) return;
|
|
48
|
+
const payload = {
|
|
49
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
50
|
+
scope,
|
|
51
|
+
stage,
|
|
52
|
+
message,
|
|
53
|
+
data: redactValue(data)
|
|
54
|
+
};
|
|
55
|
+
const dir = join(process.cwd(), ".archon", "debug");
|
|
56
|
+
if (!existsSync(dir)) {
|
|
57
|
+
mkdirSync(dir, { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
appendFileSync(LOG_PATH, `${JSON.stringify(payload)}
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
getDebugLogPath,
|
|
65
|
+
debugLog
|
|
66
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
execute
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ICPOD7FC.js";
|
|
4
4
|
import "./chunk-EBHHIUCB.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-QKHRSVUO.js";
|
|
6
6
|
import "./chunk-WGLVDEZC.js";
|
|
7
7
|
import "./chunk-3MZOEZUH.js";
|
|
8
8
|
import "./chunk-F7R3QKHP.js";
|
|
9
|
+
import "./chunk-R664NEAA.js";
|
|
9
10
|
import "./chunk-Q3GIFHIQ.js";
|
|
10
11
|
import "./chunk-5EVHUDQX.js";
|
|
11
12
|
import "./chunk-7C6JELBL.js";
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./chunk-6URKZ7NB.js";
|
|
14
14
|
import {
|
|
15
15
|
show
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-DDAOREZF.js";
|
|
17
17
|
import {
|
|
18
18
|
bugReport
|
|
19
19
|
} from "./chunk-AHK2ITJX.js";
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
showExecutionPreferences,
|
|
39
39
|
showPreferences,
|
|
40
40
|
showUsageDetails
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-LM5UBTSS.js";
|
|
42
42
|
import {
|
|
43
43
|
init,
|
|
44
44
|
isInitialized
|
|
@@ -50,13 +50,13 @@ import {
|
|
|
50
50
|
parallelRunWaves,
|
|
51
51
|
parallelSchedule,
|
|
52
52
|
parallelStatus
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-K6A6CWUG.js";
|
|
54
54
|
import {
|
|
55
55
|
DependencyParser,
|
|
56
56
|
EnvironmentConfigLoader,
|
|
57
57
|
EnvironmentValidator,
|
|
58
58
|
execute
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-ICPOD7FC.js";
|
|
60
60
|
import {
|
|
61
61
|
cloudCancel,
|
|
62
62
|
cloudLogs,
|
|
@@ -64,12 +64,12 @@ import {
|
|
|
64
64
|
} from "./chunk-EBHHIUCB.js";
|
|
65
65
|
import {
|
|
66
66
|
list
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-TNS5OLCD.js";
|
|
68
68
|
import {
|
|
69
69
|
listLocalAtoms,
|
|
70
70
|
loadAtom,
|
|
71
71
|
plan
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-QKHRSVUO.js";
|
|
73
73
|
import "./chunk-WGLVDEZC.js";
|
|
74
74
|
import "./chunk-3MZOEZUH.js";
|
|
75
75
|
import {
|
|
@@ -77,6 +77,10 @@ import {
|
|
|
77
77
|
ok,
|
|
78
78
|
sleep
|
|
79
79
|
} from "./chunk-F7R3QKHP.js";
|
|
80
|
+
import {
|
|
81
|
+
debugLog,
|
|
82
|
+
getDebugLogPath
|
|
83
|
+
} from "./chunk-R664NEAA.js";
|
|
80
84
|
import {
|
|
81
85
|
createAuthedSupabaseClient
|
|
82
86
|
} from "./chunk-Q3GIFHIQ.js";
|
|
@@ -2714,6 +2718,11 @@ function uiSeparator() {
|
|
|
2714
2718
|
}
|
|
2715
2719
|
async function start(options = {}) {
|
|
2716
2720
|
const cwd = process.cwd();
|
|
2721
|
+
const debugPath = getDebugLogPath();
|
|
2722
|
+
if (debugPath) {
|
|
2723
|
+
console.log(chalk6.dim(`Debug logging enabled: ${debugPath}`));
|
|
2724
|
+
}
|
|
2725
|
+
debugLog("start", "session.begin", "Starting archon session", { cwd });
|
|
2717
2726
|
displayBrandedHeader();
|
|
2718
2727
|
const updateCheckPromise = startBackgroundUpdateCheck();
|
|
2719
2728
|
let config = await loadConfig();
|
|
@@ -2844,13 +2853,40 @@ async function start(options = {}) {
|
|
|
2844
2853
|
if (currentTier === "BYOK" && config.accessToken) {
|
|
2845
2854
|
try {
|
|
2846
2855
|
const resolvedAuthId = await resolveAuthIdFromToken(config.accessToken, config.userId);
|
|
2856
|
+
debugLog("start", "byok_usage.identity", "Resolved auth/profile identity for BYOK startup usage", {
|
|
2857
|
+
configUserId: config.userId ?? null,
|
|
2858
|
+
resolvedAuthId
|
|
2859
|
+
});
|
|
2847
2860
|
let usageStats = await fetchByokUsageStats(config.accessToken);
|
|
2848
2861
|
const apiLooksEmpty = !!usageStats && usageStats.totalInputTokens === 0 && usageStats.totalOutputTokens === 0 && usageStats.totalBaseCost === 0 && usageStats.byModel.length === 0;
|
|
2862
|
+
debugLog("start", "byok_usage.api", "Fetched BYOK usage from /api/usage", {
|
|
2863
|
+
usageStatsPresent: !!usageStats,
|
|
2864
|
+
apiLooksEmpty,
|
|
2865
|
+
totals: usageStats ? {
|
|
2866
|
+
totalInputTokens: usageStats.totalInputTokens,
|
|
2867
|
+
totalOutputTokens: usageStats.totalOutputTokens,
|
|
2868
|
+
totalBaseCost: usageStats.totalBaseCost,
|
|
2869
|
+
byModelCount: usageStats.byModel.length
|
|
2870
|
+
} : null
|
|
2871
|
+
});
|
|
2849
2872
|
if (!usageStats || apiLooksEmpty && resolvedAuthId) {
|
|
2850
2873
|
const supabaseStats = resolvedAuthId ? await fetchByokUsageStatsFromSupabase(config.accessToken, resolvedAuthId) : null;
|
|
2851
2874
|
if (supabaseStats) {
|
|
2852
2875
|
usageStats = supabaseStats;
|
|
2853
2876
|
}
|
|
2877
|
+
debugLog("start", "byok_usage.supabase_fallback", "Fetched BYOK usage from Supabase fallback", {
|
|
2878
|
+
fallbackAttempted: !!resolvedAuthId,
|
|
2879
|
+
fallbackReturned: !!supabaseStats,
|
|
2880
|
+
totals: supabaseStats ? {
|
|
2881
|
+
totalInputTokens: supabaseStats.totalInputTokens,
|
|
2882
|
+
totalOutputTokens: supabaseStats.totalOutputTokens,
|
|
2883
|
+
totalBaseCost: supabaseStats.totalBaseCost,
|
|
2884
|
+
byModelCount: supabaseStats.byModel.length,
|
|
2885
|
+
periodStart: supabaseStats.periodStart,
|
|
2886
|
+
periodEnd: supabaseStats.periodEnd,
|
|
2887
|
+
periodSource: supabaseStats.periodSource
|
|
2888
|
+
} : null
|
|
2889
|
+
});
|
|
2854
2890
|
}
|
|
2855
2891
|
const usageStatsUnavailable = !usageStats;
|
|
2856
2892
|
if (!usageStats) {
|
|
@@ -2892,7 +2928,7 @@ async function start(options = {}) {
|
|
|
2892
2928
|
}
|
|
2893
2929
|
console.log(chalk6.dim(uiSeparator()));
|
|
2894
2930
|
if (usageStatsUnavailable) {
|
|
2895
|
-
console.log(chalk6.dim("Usage details may be delayed. Run `archon usage` to
|
|
2931
|
+
console.log(chalk6.dim("Usage details may be delayed. Run `archon usage --debug` to inspect identity/source windows."));
|
|
2896
2932
|
}
|
|
2897
2933
|
console.log(chalk6.dim("View details: archon usage | Models: archon preferences | Switch tier: archon upgrade"));
|
|
2898
2934
|
} catch {
|
|
@@ -3078,6 +3114,9 @@ async function fetchByokUsageStats(accessToken) {
|
|
|
3078
3114
|
}
|
|
3079
3115
|
});
|
|
3080
3116
|
if (!response.ok) {
|
|
3117
|
+
debugLog("start", "byok_usage.api_error", "BYOK /api/usage returned non-OK status", {
|
|
3118
|
+
status: response.status
|
|
3119
|
+
});
|
|
3081
3120
|
return null;
|
|
3082
3121
|
}
|
|
3083
3122
|
const data = await response.json();
|
|
@@ -3098,6 +3137,7 @@ async function fetchByokUsageStats(accessToken) {
|
|
|
3098
3137
|
periodSource: data.periodSource
|
|
3099
3138
|
};
|
|
3100
3139
|
} catch {
|
|
3140
|
+
debugLog("start", "byok_usage.api_exception", "BYOK /api/usage request threw exception");
|
|
3101
3141
|
return null;
|
|
3102
3142
|
}
|
|
3103
3143
|
}
|
|
@@ -3108,12 +3148,21 @@ async function fetchByokUsageStatsFromSupabase(accessToken, authId) {
|
|
|
3108
3148
|
const supabase = createAuthedSupabaseClient2(SUPABASE_URL2, SUPABASE_ANON_KEY2, accessToken);
|
|
3109
3149
|
const profileId = await resolveProfileIdForUsage(supabase, authId);
|
|
3110
3150
|
if (!profileId) {
|
|
3151
|
+
debugLog("start", "byok_usage.profile_missing", "Could not resolve profile ID for BYOK Supabase fallback", {
|
|
3152
|
+
authId
|
|
3153
|
+
});
|
|
3111
3154
|
return null;
|
|
3112
3155
|
}
|
|
3113
3156
|
const now = /* @__PURE__ */ new Date();
|
|
3114
3157
|
const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
3115
3158
|
const monthStats = await fetchByokUsageWindow(supabase, profileId, monthStart, now);
|
|
3116
3159
|
if (hasAnyByokUsage(monthStats)) {
|
|
3160
|
+
debugLog("start", "byok_usage.window", "Using month-to-date BYOK fallback window", {
|
|
3161
|
+
profileId,
|
|
3162
|
+
start: monthStart.toISOString(),
|
|
3163
|
+
end: now.toISOString(),
|
|
3164
|
+
totals: monthStats
|
|
3165
|
+
});
|
|
3117
3166
|
return {
|
|
3118
3167
|
...monthStats,
|
|
3119
3168
|
periodStart: monthStart.toISOString(),
|
|
@@ -3123,6 +3172,12 @@ async function fetchByokUsageStatsFromSupabase(accessToken, authId) {
|
|
|
3123
3172
|
}
|
|
3124
3173
|
const trailingStart = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
3125
3174
|
const trailingStats = await fetchByokUsageWindow(supabase, profileId, trailingStart, now);
|
|
3175
|
+
debugLog("start", "byok_usage.window", "Using trailing 30-day BYOK fallback window", {
|
|
3176
|
+
profileId,
|
|
3177
|
+
start: trailingStart.toISOString(),
|
|
3178
|
+
end: now.toISOString(),
|
|
3179
|
+
totals: trailingStats
|
|
3180
|
+
});
|
|
3126
3181
|
return {
|
|
3127
3182
|
...trailingStats,
|
|
3128
3183
|
periodStart: trailingStart.toISOString(),
|
|
@@ -3130,6 +3185,7 @@ async function fetchByokUsageStatsFromSupabase(accessToken, authId) {
|
|
|
3130
3185
|
periodSource: "profile_period"
|
|
3131
3186
|
};
|
|
3132
3187
|
} catch {
|
|
3188
|
+
debugLog("start", "byok_usage.supabase_exception", "BYOK Supabase fallback threw exception");
|
|
3133
3189
|
return null;
|
|
3134
3190
|
}
|
|
3135
3191
|
}
|
|
@@ -3419,7 +3475,7 @@ async function runExploreFlow(cwd, followUpInput, options = {}) {
|
|
|
3419
3475
|
case "1": {
|
|
3420
3476
|
const description = await promptWithCommands("Describe what you want to do", { allowMultiline: true });
|
|
3421
3477
|
if (description.trim()) {
|
|
3422
|
-
const { plan: plan2 } = await import("./plan-
|
|
3478
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
3423
3479
|
await plan2(description, { conversational: true });
|
|
3424
3480
|
}
|
|
3425
3481
|
await showMainMenu();
|
|
@@ -3664,7 +3720,7 @@ ${state.forbiddenPatterns?.length ? `- **Forbidden patterns:** ${state.forbidden
|
|
|
3664
3720
|
const hintedTask = initialTaskHint?.trim() ?? "";
|
|
3665
3721
|
if (hintedTask) {
|
|
3666
3722
|
console.log(chalk6.dim("Using your request above as the first task.\n"));
|
|
3667
|
-
const { plan: plan2 } = await import("./plan-
|
|
3723
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
3668
3724
|
await plan2(hintedTask, { conversational: true });
|
|
3669
3725
|
return;
|
|
3670
3726
|
}
|
|
@@ -3689,7 +3745,7 @@ ${state.forbiddenPatterns?.length ? `- **Forbidden patterns:** ${state.forbidden
|
|
|
3689
3745
|
description = continueAnswer.trim();
|
|
3690
3746
|
}
|
|
3691
3747
|
if (description.trim()) {
|
|
3692
|
-
const { plan: plan2 } = await import("./plan-
|
|
3748
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
3693
3749
|
await plan2(description, { conversational: true });
|
|
3694
3750
|
}
|
|
3695
3751
|
}
|
|
@@ -3918,7 +3974,7 @@ async function handleAgentConversationInput(cwd, input) {
|
|
|
3918
3974
|
return true;
|
|
3919
3975
|
}
|
|
3920
3976
|
console.log(chalk6.dim("\n> Got it! Creating a task for this...\n"));
|
|
3921
|
-
const { plan: plan2 } = await import("./plan-
|
|
3977
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
3922
3978
|
await plan2(await withAllowedPathScope(cwd, input), { conversational: true });
|
|
3923
3979
|
if (shouldAutoExecuteAfterPlanning(input)) {
|
|
3924
3980
|
await continueWithCurrentTask(cwd, { runAllReady: true });
|
|
@@ -3965,7 +4021,7 @@ async function showProposalForApproval(input) {
|
|
|
3965
4021
|
}
|
|
3966
4022
|
}
|
|
3967
4023
|
async function showLatestPlannedAtom(cwd) {
|
|
3968
|
-
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-
|
|
4024
|
+
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-7YU2U4RY.js");
|
|
3969
4025
|
const atoms = await listLocalAtoms2();
|
|
3970
4026
|
if (atoms.length === 0) {
|
|
3971
4027
|
console.log(chalk6.yellow("No atoms found yet. Tell me what to plan."));
|
|
@@ -3983,7 +4039,7 @@ async function showLatestPlannedAtom(cwd) {
|
|
|
3983
4039
|
console.log(chalk6.dim(`
|
|
3984
4040
|
Showing latest planned atom (${latest.externalId})...
|
|
3985
4041
|
`));
|
|
3986
|
-
const { show: show2 } = await import("./show-
|
|
4042
|
+
const { show: show2 } = await import("./show-VLTLYZDI.js");
|
|
3987
4043
|
await show2(latest.externalId);
|
|
3988
4044
|
}
|
|
3989
4045
|
function isContinuationDirective(input) {
|
|
@@ -4116,7 +4172,7 @@ async function applyApprovedProposal(cwd) {
|
|
|
4116
4172
|
console.log(chalk6.dim('\nReply "continue" when you want execution to start.'));
|
|
4117
4173
|
}
|
|
4118
4174
|
async function createTaskFromRequest(cwd, request) {
|
|
4119
|
-
const { plan: plan2, listLocalAtoms: listLocalAtoms2 } = await import("./plan-
|
|
4175
|
+
const { plan: plan2, listLocalAtoms: listLocalAtoms2 } = await import("./plan-7YU2U4RY.js");
|
|
4120
4176
|
const before = await listLocalAtoms2();
|
|
4121
4177
|
const beforeIds = new Set(before.map((atom) => atom.externalId));
|
|
4122
4178
|
await plan2(await withAllowedPathScope(cwd, request), { conversational: true });
|
|
@@ -4292,13 +4348,13 @@ function buildSampleCapsuleDraft(cwd, files, capsuleCount) {
|
|
|
4292
4348
|
].join("\n");
|
|
4293
4349
|
}
|
|
4294
4350
|
async function continueWithCurrentTask(cwd, options = {}) {
|
|
4295
|
-
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-
|
|
4351
|
+
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-7YU2U4RY.js");
|
|
4296
4352
|
const byMostRecent = (a, b) => {
|
|
4297
4353
|
const aTime = new Date(String(a.updatedAt ?? a.createdAt ?? "")).getTime() || 0;
|
|
4298
4354
|
const bTime = new Date(String(b.updatedAt ?? b.createdAt ?? "")).getTime() || 0;
|
|
4299
4355
|
return bTime - aTime;
|
|
4300
4356
|
};
|
|
4301
|
-
const { execute: execute2 } = await import("./execute-
|
|
4357
|
+
const { execute: execute2 } = await import("./execute-4KDY6MOO.js");
|
|
4302
4358
|
const runAllReady = options.runAllReady === true;
|
|
4303
4359
|
const scopeIds = options.onlyAtomIds ? new Set(options.onlyAtomIds) : null;
|
|
4304
4360
|
const attempted = /* @__PURE__ */ new Set();
|
|
@@ -4358,7 +4414,7 @@ Continuing with ${nextAtom.externalId}...
|
|
|
4358
4414
|
}
|
|
4359
4415
|
await execute2(nextAtom.externalId, {
|
|
4360
4416
|
nonTerminating: true,
|
|
4361
|
-
pathScopeAutoRecover:
|
|
4417
|
+
pathScopeAutoRecover: true
|
|
4362
4418
|
});
|
|
4363
4419
|
if (!runAllReady) {
|
|
4364
4420
|
return;
|
|
@@ -4374,7 +4430,7 @@ Continuing with ${nextAtom.externalId}...
|
|
|
4374
4430
|
}
|
|
4375
4431
|
}
|
|
4376
4432
|
async function replanLatestBlockedAtom(cwd) {
|
|
4377
|
-
const { listLocalAtoms: listLocalAtoms2, plan: plan2 } = await import("./plan-
|
|
4433
|
+
const { listLocalAtoms: listLocalAtoms2, plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
4378
4434
|
const atoms = await listLocalAtoms2();
|
|
4379
4435
|
const blocked = atoms.filter((a) => a.status === "BLOCKED" && (a.errorMessage ?? "").toLowerCase().includes("outside the allowed paths")).sort((a, b) => {
|
|
4380
4436
|
const aTime = new Date(String(a.updatedAt ?? a.createdAt ?? "")).getTime() || 0;
|
|
@@ -4488,7 +4544,7 @@ async function handleFreeformJourneyInput(cwd, input) {
|
|
|
4488
4544
|
const state = detectProjectState(cwd);
|
|
4489
4545
|
if (state.hasArchitecture) {
|
|
4490
4546
|
console.log(chalk6.dim("\n> Got it! Creating a task for this...\n"));
|
|
4491
|
-
const { plan: plan3 } = await import("./plan-
|
|
4547
|
+
const { plan: plan3 } = await import("./plan-7YU2U4RY.js");
|
|
4492
4548
|
await plan3(await withAllowedPathScope(cwd, freeform), { conversational: true });
|
|
4493
4549
|
return true;
|
|
4494
4550
|
}
|
|
@@ -4497,7 +4553,7 @@ async function handleFreeformJourneyInput(cwd, input) {
|
|
|
4497
4553
|
return true;
|
|
4498
4554
|
}
|
|
4499
4555
|
console.log(chalk6.dim("\n> Got it! Creating a task for this...\n"));
|
|
4500
|
-
const { plan: plan2 } = await import("./plan-
|
|
4556
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
4501
4557
|
await plan2(await withAllowedPathScope(cwd, freeform), { conversational: true });
|
|
4502
4558
|
return true;
|
|
4503
4559
|
}
|
|
@@ -4546,7 +4602,7 @@ function isFileLocationQuestion(input) {
|
|
|
4546
4602
|
return true;
|
|
4547
4603
|
}
|
|
4548
4604
|
async function answerLatestOutputLocation(cwd) {
|
|
4549
|
-
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-
|
|
4605
|
+
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-7YU2U4RY.js");
|
|
4550
4606
|
const atoms = await listLocalAtoms2();
|
|
4551
4607
|
const latestDone = atoms.filter((atom) => atom.status === "DONE").sort((a, b) => {
|
|
4552
4608
|
const aTime = new Date(String(a.updatedAt ?? a.createdAt ?? "")).getTime() || 0;
|
|
@@ -4595,7 +4651,7 @@ async function handlePostExploreAction(cwd, request, options = {}) {
|
|
|
4595
4651
|
} else {
|
|
4596
4652
|
console.log(chalk6.dim("> Got it! Creating a task for this...\n"));
|
|
4597
4653
|
}
|
|
4598
|
-
const { plan: plan2 } = await import("./plan-
|
|
4654
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
4599
4655
|
await plan2(await withAllowedPathScope(cwd, request), { conversational: true });
|
|
4600
4656
|
if (options.agentMode) {
|
|
4601
4657
|
if (shouldAutoExecuteAfterPlanning(sourceInput)) {
|
|
@@ -4619,20 +4675,20 @@ Constraints:
|
|
|
4619
4675
|
- If required files are outside this scope, propose the minimum architecture path update first.`;
|
|
4620
4676
|
}
|
|
4621
4677
|
async function planTask() {
|
|
4622
|
-
const { plan: plan2 } = await import("./plan-
|
|
4678
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
4623
4679
|
const description = await promptWithCommands("Describe what you want to build", { allowMultiline: true });
|
|
4624
4680
|
if (description.trim()) {
|
|
4625
4681
|
await plan2(description, { conversational: true });
|
|
4626
4682
|
}
|
|
4627
4683
|
}
|
|
4628
4684
|
async function listAtoms() {
|
|
4629
|
-
const { list: list2 } = await import("./list-
|
|
4685
|
+
const { list: list2 } = await import("./list-D4THOSHG.js");
|
|
4630
4686
|
await list2({});
|
|
4631
4687
|
}
|
|
4632
4688
|
async function executeNext() {
|
|
4633
|
-
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-
|
|
4689
|
+
const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-7YU2U4RY.js");
|
|
4634
4690
|
const { analyzeProject, getComplexityDescription, getModeDescription } = await import("./orchestration-HIF3KP25.js");
|
|
4635
|
-
const { loadExecutionPreferences } = await import("./preferences-
|
|
4691
|
+
const { loadExecutionPreferences } = await import("./preferences-QTPQLCXN.js");
|
|
4636
4692
|
const cwd = process.cwd();
|
|
4637
4693
|
const atoms = await listLocalAtoms2();
|
|
4638
4694
|
const pendingAtoms = atoms.filter((a) => a.status === "READY" || a.status === "IN_PROGRESS");
|
|
@@ -4701,11 +4757,11 @@ async function executeNext() {
|
|
|
4701
4757
|
}
|
|
4702
4758
|
}
|
|
4703
4759
|
if (selectedMode === "parallel-cloud") {
|
|
4704
|
-
const { parallelExecuteCloud: parallelExecuteCloud2 } = await import("./parallel-
|
|
4760
|
+
const { parallelExecuteCloud: parallelExecuteCloud2 } = await import("./parallel-HUAAE6PS.js");
|
|
4705
4761
|
await parallelExecuteCloud2(runIds);
|
|
4706
4762
|
return;
|
|
4707
4763
|
}
|
|
4708
|
-
const { parallelExecute } = await import("./parallel-
|
|
4764
|
+
const { parallelExecute } = await import("./parallel-HUAAE6PS.js");
|
|
4709
4765
|
await parallelExecute(runIds);
|
|
4710
4766
|
return;
|
|
4711
4767
|
}
|
|
@@ -4713,7 +4769,7 @@ async function executeNext() {
|
|
|
4713
4769
|
const atomId = await prompt("Enter atom ID to execute (or press Enter for first pending)");
|
|
4714
4770
|
const targetId = atomId.trim() || pendingAtoms[0]?.id;
|
|
4715
4771
|
if (targetId) {
|
|
4716
|
-
const { execute: execute2 } = await import("./execute-
|
|
4772
|
+
const { execute: execute2 } = await import("./execute-4KDY6MOO.js");
|
|
4717
4773
|
await execute2(targetId, {});
|
|
4718
4774
|
} else {
|
|
4719
4775
|
console.log(chalk6.yellow("No atom to execute."));
|
|
@@ -4731,7 +4787,7 @@ async function viewStatus() {
|
|
|
4731
4787
|
await status2();
|
|
4732
4788
|
}
|
|
4733
4789
|
async function settingsMenu() {
|
|
4734
|
-
const { interactiveSettings } = await import("./preferences-
|
|
4790
|
+
const { interactiveSettings } = await import("./preferences-QTPQLCXN.js");
|
|
4735
4791
|
await interactiveSettings();
|
|
4736
4792
|
}
|
|
4737
4793
|
async function reviewCode() {
|
|
@@ -4862,7 +4918,7 @@ async function handleSlashCommand(input) {
|
|
|
4862
4918
|
const arg = parts.slice(1).join(" ").trim();
|
|
4863
4919
|
switch (command) {
|
|
4864
4920
|
case "/plan": {
|
|
4865
|
-
const { plan: plan2 } = await import("./plan-
|
|
4921
|
+
const { plan: plan2 } = await import("./plan-7YU2U4RY.js");
|
|
4866
4922
|
if (arg) {
|
|
4867
4923
|
await plan2(arg, { conversational: true });
|
|
4868
4924
|
} else {
|
|
@@ -9249,8 +9305,8 @@ creditsCommand.command("audit").description("Show billing audit log (immutable r
|
|
|
9249
9305
|
creditsCommand.action(async () => {
|
|
9250
9306
|
await showCredits();
|
|
9251
9307
|
});
|
|
9252
|
-
program.command("usage").description("Show usage by period and model").action(async () => {
|
|
9253
|
-
await showUsageDetails();
|
|
9308
|
+
program.command("usage").description("Show usage by period and model").option("--debug", "Show usage diagnostics (identity/window/source details)").action(async (options) => {
|
|
9309
|
+
await showUsageDetails({ debug: options.debug === true });
|
|
9254
9310
|
});
|
|
9255
9311
|
var preferencesCommand = program.command("preferences").description("Manage default model preferences");
|
|
9256
9312
|
preferencesCommand.command("set <key> <model>").description("Set a model preference (fast-model, thinking-model, primary-adversarial, secondary-adversarial)").action(async (key, model) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
list
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-TNS5OLCD.js";
|
|
4
|
+
import "./chunk-QKHRSVUO.js";
|
|
5
5
|
import "./chunk-WGLVDEZC.js";
|
|
6
6
|
import "./chunk-3MZOEZUH.js";
|
|
7
7
|
import "./chunk-F7R3QKHP.js";
|
|
8
|
+
import "./chunk-R664NEAA.js";
|
|
8
9
|
import "./chunk-Q3GIFHIQ.js";
|
|
9
10
|
import "./chunk-5EVHUDQX.js";
|
|
10
11
|
import "./chunk-7C6JELBL.js";
|
|
@@ -6,12 +6,13 @@ import {
|
|
|
6
6
|
parallelRunWaves,
|
|
7
7
|
parallelSchedule,
|
|
8
8
|
parallelStatus
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-K6A6CWUG.js";
|
|
10
10
|
import "./chunk-EBHHIUCB.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-QKHRSVUO.js";
|
|
12
12
|
import "./chunk-WGLVDEZC.js";
|
|
13
13
|
import "./chunk-3MZOEZUH.js";
|
|
14
14
|
import "./chunk-F7R3QKHP.js";
|
|
15
|
+
import "./chunk-R664NEAA.js";
|
|
15
16
|
import "./chunk-Q3GIFHIQ.js";
|
|
16
17
|
import "./chunk-5EVHUDQX.js";
|
|
17
18
|
import "./chunk-7C6JELBL.js";
|
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
loadAtom,
|
|
4
4
|
parseAtomDescription,
|
|
5
5
|
plan
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QKHRSVUO.js";
|
|
7
7
|
import "./chunk-WGLVDEZC.js";
|
|
8
8
|
import "./chunk-3MZOEZUH.js";
|
|
9
9
|
import "./chunk-F7R3QKHP.js";
|
|
10
|
+
import "./chunk-R664NEAA.js";
|
|
10
11
|
import "./chunk-Q3GIFHIQ.js";
|
|
11
12
|
import "./chunk-5EVHUDQX.js";
|
|
12
13
|
import "./chunk-7C6JELBL.js";
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
showExecutionPreferences,
|
|
10
10
|
showPreferences,
|
|
11
11
|
showUsageDetails
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LM5UBTSS.js";
|
|
13
|
+
import "./chunk-R664NEAA.js";
|
|
13
14
|
import "./chunk-Q3GIFHIQ.js";
|
|
14
15
|
import "./chunk-7C6JELBL.js";
|
|
15
16
|
import "./chunk-TFSHS7EN.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
show
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-DDAOREZF.js";
|
|
4
|
+
import "./chunk-QKHRSVUO.js";
|
|
5
5
|
import "./chunk-WGLVDEZC.js";
|
|
6
6
|
import "./chunk-3MZOEZUH.js";
|
|
7
7
|
import "./chunk-F7R3QKHP.js";
|
|
8
|
+
import "./chunk-R664NEAA.js";
|
|
8
9
|
import "./chunk-Q3GIFHIQ.js";
|
|
9
10
|
import "./chunk-5EVHUDQX.js";
|
|
10
11
|
import "./chunk-7C6JELBL.js";
|