@cleocode/cleo 2026.5.77 → 2026.5.78
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/cli/index.js +1222 -347
- package/dist/cli/index.js.map +3 -3
- package/package.json +11 -10
package/dist/cli/index.js
CHANGED
|
@@ -103,8 +103,8 @@ function formatLineColumns(lines, linePrefix = "") {
|
|
|
103
103
|
for (const line of lines) for (const [i, element] of line.entries()) maxLength[i] = Math.max(maxLength[i] || 0, element.length);
|
|
104
104
|
return lines.map((l) => l.map((c, i) => linePrefix + c[i === 0 ? "padStart" : "padEnd"](maxLength[i])).join(" ")).join("\n");
|
|
105
105
|
}
|
|
106
|
-
function resolveValue(
|
|
107
|
-
return typeof
|
|
106
|
+
function resolveValue(input2) {
|
|
107
|
+
return typeof input2 === "function" ? input2() : input2;
|
|
108
108
|
}
|
|
109
109
|
function parseRawArgs(args = [], opts = {}) {
|
|
110
110
|
const booleans = new Set(opts.boolean || []);
|
|
@@ -403,12 +403,12 @@ function getFieldContext() {
|
|
|
403
403
|
return currentContext;
|
|
404
404
|
}
|
|
405
405
|
function resolveFieldContext(opts) {
|
|
406
|
-
const
|
|
406
|
+
const input2 = {
|
|
407
407
|
fieldFlag: typeof opts["field"] === "string" ? opts["field"] : void 0,
|
|
408
408
|
fieldsFlag: typeof opts["fields"] === "string" ? opts["fields"] : void 0,
|
|
409
409
|
mviFlag: typeof opts["mvi"] === "string" ? opts["mvi"] : void 0
|
|
410
410
|
};
|
|
411
|
-
return resolveFieldExtraction(
|
|
411
|
+
return resolveFieldExtraction(input2);
|
|
412
412
|
}
|
|
413
413
|
var currentContext;
|
|
414
414
|
var init_field_context = __esm({
|
|
@@ -429,6 +429,9 @@ function setFormatContext(resolution) {
|
|
|
429
429
|
function getFormatContext() {
|
|
430
430
|
return currentResolution;
|
|
431
431
|
}
|
|
432
|
+
function isJsonFormat() {
|
|
433
|
+
return currentResolution.format === "json";
|
|
434
|
+
}
|
|
432
435
|
var currentResolution;
|
|
433
436
|
var init_format_context = __esm({
|
|
434
437
|
"packages/cleo/src/cli/format-context.ts"() {
|
|
@@ -442,11 +445,11 @@ var init_format_context = __esm({
|
|
|
442
445
|
});
|
|
443
446
|
|
|
444
447
|
// packages/animations/src/animate-context.ts
|
|
445
|
-
function createAnimateContext(
|
|
446
|
-
const format =
|
|
447
|
-
const quiet =
|
|
448
|
-
const isTTY =
|
|
449
|
-
const noColor3 =
|
|
448
|
+
function createAnimateContext(input2) {
|
|
449
|
+
const format = input2.flagResolution.format;
|
|
450
|
+
const quiet = input2.flagResolution.quiet;
|
|
451
|
+
const isTTY = input2.isTTY ?? Boolean(process.stdout.isTTY);
|
|
452
|
+
const noColor3 = input2.noColor ?? process.env.NO_COLOR != null;
|
|
450
453
|
const inputs = { format, quiet, isTTY, noColor: noColor3 };
|
|
451
454
|
if (format !== "human") {
|
|
452
455
|
return { enabled: false, reason: "format-json", inputs };
|
|
@@ -2896,10 +2899,10 @@ var init_colors = __esm({
|
|
|
2896
2899
|
});
|
|
2897
2900
|
|
|
2898
2901
|
// packages/cleo/src/cli/renderers/format-helpers.ts
|
|
2899
|
-
function pagerFooter(
|
|
2900
|
-
const { shown, page } =
|
|
2901
|
-
const total = page?.total ??
|
|
2902
|
-
const filtered =
|
|
2902
|
+
function pagerFooter(input2) {
|
|
2903
|
+
const { shown, page } = input2;
|
|
2904
|
+
const total = page?.total ?? input2.total ?? shown;
|
|
2905
|
+
const filtered = input2.filtered;
|
|
2903
2906
|
const hasMore = page?.hasMore === true || shown < total;
|
|
2904
2907
|
const filterActive = typeof filtered === "number" && filtered !== total;
|
|
2905
2908
|
if (!hasMore && !filterActive) return "";
|
|
@@ -20296,10 +20299,10 @@ function rowToApproval(row) {
|
|
|
20296
20299
|
if (reason !== void 0) approval.reason = reason;
|
|
20297
20300
|
return approval;
|
|
20298
20301
|
}
|
|
20299
|
-
function createApprovalGate(db,
|
|
20300
|
-
const token = generateResumeToken(
|
|
20302
|
+
function createApprovalGate(db, input2) {
|
|
20303
|
+
const token = generateResumeToken(input2.runId, input2.nodeId, input2.bindings, input2.secret);
|
|
20301
20304
|
const approvalId = randomUUID3();
|
|
20302
|
-
const autoPassed =
|
|
20305
|
+
const autoPassed = input2.autoPassed ?? false;
|
|
20303
20306
|
const status = autoPassed ? "approved" : "pending";
|
|
20304
20307
|
const stmt = db.prepare(`
|
|
20305
20308
|
INSERT INTO playbook_approvals
|
|
@@ -20308,13 +20311,13 @@ function createApprovalGate(db, input) {
|
|
|
20308
20311
|
`);
|
|
20309
20312
|
stmt.run(
|
|
20310
20313
|
approvalId,
|
|
20311
|
-
|
|
20312
|
-
|
|
20314
|
+
input2.runId,
|
|
20315
|
+
input2.nodeId,
|
|
20313
20316
|
token,
|
|
20314
20317
|
status,
|
|
20315
20318
|
autoPassed ? 1 : 0,
|
|
20316
|
-
|
|
20317
|
-
|
|
20319
|
+
input2.approver ?? null,
|
|
20320
|
+
input2.reason ?? null
|
|
20318
20321
|
);
|
|
20319
20322
|
const row = db.prepare("SELECT * FROM playbook_approvals WHERE approval_id = ?").get(approvalId);
|
|
20320
20323
|
if (row === void 0) {
|
|
@@ -20803,14 +20806,14 @@ function resolveYamlBinary(data) {
|
|
|
20803
20806
|
return bitlen % 8 === 0;
|
|
20804
20807
|
}
|
|
20805
20808
|
function constructYamlBinary(data) {
|
|
20806
|
-
var idx, tailbits,
|
|
20809
|
+
var idx, tailbits, input2 = data.replace(/[\r\n=]/g, ""), max = input2.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
20807
20810
|
for (idx = 0; idx < max; idx++) {
|
|
20808
20811
|
if (idx % 4 === 0 && idx) {
|
|
20809
20812
|
result.push(bits >> 16 & 255);
|
|
20810
20813
|
result.push(bits >> 8 & 255);
|
|
20811
20814
|
result.push(bits & 255);
|
|
20812
20815
|
}
|
|
20813
|
-
bits = bits << 6 | map2.indexOf(
|
|
20816
|
+
bits = bits << 6 | map2.indexOf(input2.charAt(idx));
|
|
20814
20817
|
}
|
|
20815
20818
|
tailbits = max % 4 * 6;
|
|
20816
20819
|
if (tailbits === 0) {
|
|
@@ -20985,8 +20988,8 @@ function setProperty(object, key, value) {
|
|
|
20985
20988
|
object[key] = value;
|
|
20986
20989
|
}
|
|
20987
20990
|
}
|
|
20988
|
-
function State$1(
|
|
20989
|
-
this.input =
|
|
20991
|
+
function State$1(input2, options) {
|
|
20992
|
+
this.input = input2;
|
|
20990
20993
|
this.filename = options["filename"] || null;
|
|
20991
20994
|
this.schema = options["schema"] || _default;
|
|
20992
20995
|
this.onWarning = options["onWarning"] || null;
|
|
@@ -20995,7 +20998,7 @@ function State$1(input, options) {
|
|
|
20995
20998
|
this.listener = options["listener"] || null;
|
|
20996
20999
|
this.implicitTypes = this.schema.compiledImplicit;
|
|
20997
21000
|
this.typeMap = this.schema.compiledTypeMap;
|
|
20998
|
-
this.length =
|
|
21001
|
+
this.length = input2.length;
|
|
20999
21002
|
this.position = 0;
|
|
21000
21003
|
this.line = 0;
|
|
21001
21004
|
this.lineStart = 0;
|
|
@@ -21951,19 +21954,19 @@ function readDocument(state) {
|
|
|
21951
21954
|
return;
|
|
21952
21955
|
}
|
|
21953
21956
|
}
|
|
21954
|
-
function loadDocuments(
|
|
21955
|
-
|
|
21957
|
+
function loadDocuments(input2, options) {
|
|
21958
|
+
input2 = String(input2);
|
|
21956
21959
|
options = options || {};
|
|
21957
|
-
if (
|
|
21958
|
-
if (
|
|
21959
|
-
|
|
21960
|
+
if (input2.length !== 0) {
|
|
21961
|
+
if (input2.charCodeAt(input2.length - 1) !== 10 && input2.charCodeAt(input2.length - 1) !== 13) {
|
|
21962
|
+
input2 += "\n";
|
|
21960
21963
|
}
|
|
21961
|
-
if (
|
|
21962
|
-
|
|
21964
|
+
if (input2.charCodeAt(0) === 65279) {
|
|
21965
|
+
input2 = input2.slice(1);
|
|
21963
21966
|
}
|
|
21964
21967
|
}
|
|
21965
|
-
var state = new State$1(
|
|
21966
|
-
var nullpos =
|
|
21968
|
+
var state = new State$1(input2, options);
|
|
21969
|
+
var nullpos = input2.indexOf("\0");
|
|
21967
21970
|
if (nullpos !== -1) {
|
|
21968
21971
|
state.position = nullpos;
|
|
21969
21972
|
throwError(state, "null byte is not allowed in input");
|
|
@@ -21978,12 +21981,12 @@ function loadDocuments(input, options) {
|
|
|
21978
21981
|
}
|
|
21979
21982
|
return state.documents;
|
|
21980
21983
|
}
|
|
21981
|
-
function loadAll$1(
|
|
21984
|
+
function loadAll$1(input2, iterator, options) {
|
|
21982
21985
|
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
21983
21986
|
options = iterator;
|
|
21984
21987
|
iterator = null;
|
|
21985
21988
|
}
|
|
21986
|
-
var documents = loadDocuments(
|
|
21989
|
+
var documents = loadDocuments(input2, options);
|
|
21987
21990
|
if (typeof iterator !== "function") {
|
|
21988
21991
|
return documents;
|
|
21989
21992
|
}
|
|
@@ -21991,8 +21994,8 @@ function loadAll$1(input, iterator, options) {
|
|
|
21991
21994
|
iterator(documents[index]);
|
|
21992
21995
|
}
|
|
21993
21996
|
}
|
|
21994
|
-
function load$1(
|
|
21995
|
-
var documents = loadDocuments(
|
|
21997
|
+
function load$1(input2, options) {
|
|
21998
|
+
var documents = loadDocuments(input2, options);
|
|
21996
21999
|
if (documents.length === 0) {
|
|
21997
22000
|
return void 0;
|
|
21998
22001
|
} else if (documents.length === 1) {
|
|
@@ -22538,11 +22541,11 @@ function inspectNode(object, objects, duplicatesIndexes) {
|
|
|
22538
22541
|
}
|
|
22539
22542
|
}
|
|
22540
22543
|
}
|
|
22541
|
-
function dump$1(
|
|
22544
|
+
function dump$1(input2, options) {
|
|
22542
22545
|
options = options || {};
|
|
22543
22546
|
var state = new State(options);
|
|
22544
|
-
if (!state.noRefs) getDuplicateReferences(
|
|
22545
|
-
var value =
|
|
22547
|
+
if (!state.noRefs) getDuplicateReferences(input2, state);
|
|
22548
|
+
var value = input2;
|
|
22546
22549
|
if (state.replacer) {
|
|
22547
22550
|
value = state.replacer.call({ "": value }, "", value);
|
|
22548
22551
|
}
|
|
@@ -23298,11 +23301,11 @@ function parseInputs(raw) {
|
|
|
23298
23301
|
required = r.required;
|
|
23299
23302
|
}
|
|
23300
23303
|
const description = typeof r.description === "string" ? r.description : void 0;
|
|
23301
|
-
const
|
|
23302
|
-
if (required !== void 0)
|
|
23303
|
-
if (Object.hasOwn(r, "default"))
|
|
23304
|
-
if (description !== void 0)
|
|
23305
|
-
return
|
|
23304
|
+
const input2 = { name: r.name };
|
|
23305
|
+
if (required !== void 0) input2.required = required;
|
|
23306
|
+
if (Object.hasOwn(r, "default")) input2.default = r.default;
|
|
23307
|
+
if (description !== void 0) input2.description = description;
|
|
23308
|
+
return input2;
|
|
23306
23309
|
});
|
|
23307
23310
|
}
|
|
23308
23311
|
function parseErrorHandlers(raw) {
|
|
@@ -23705,9 +23708,9 @@ function rowToPlaybookApproval(row) {
|
|
|
23705
23708
|
autoPassed: row.auto_passed === 1
|
|
23706
23709
|
};
|
|
23707
23710
|
}
|
|
23708
|
-
function createPlaybookRun(db,
|
|
23711
|
+
function createPlaybookRun(db, input2) {
|
|
23709
23712
|
const runId = randomUUID4();
|
|
23710
|
-
const bindingsJson = JSON.stringify(
|
|
23713
|
+
const bindingsJson = JSON.stringify(input2.initialBindings ?? {});
|
|
23711
23714
|
const insert = db.prepare(
|
|
23712
23715
|
`INSERT INTO playbook_runs (
|
|
23713
23716
|
run_id, playbook_name, playbook_hash, bindings, status,
|
|
@@ -23716,11 +23719,11 @@ function createPlaybookRun(db, input) {
|
|
|
23716
23719
|
);
|
|
23717
23720
|
insert.run(
|
|
23718
23721
|
runId,
|
|
23719
|
-
|
|
23720
|
-
|
|
23722
|
+
input2.playbookName,
|
|
23723
|
+
input2.playbookHash,
|
|
23721
23724
|
bindingsJson,
|
|
23722
|
-
|
|
23723
|
-
|
|
23725
|
+
input2.epicId ?? null,
|
|
23726
|
+
input2.sessionId ?? null
|
|
23724
23727
|
);
|
|
23725
23728
|
const row = db.prepare("SELECT * FROM playbook_runs WHERE run_id = ?").get(runId);
|
|
23726
23729
|
if (!row) {
|
|
@@ -23823,14 +23826,14 @@ function deletePlaybookRun(db, runId) {
|
|
|
23823
23826
|
const result = db.prepare("DELETE FROM playbook_runs WHERE run_id = ?").run(runId);
|
|
23824
23827
|
return Number(result.changes) > 0;
|
|
23825
23828
|
}
|
|
23826
|
-
function createPlaybookApproval(db,
|
|
23829
|
+
function createPlaybookApproval(db, input2) {
|
|
23827
23830
|
const approvalId = randomUUID4();
|
|
23828
|
-
const autoPassed =
|
|
23831
|
+
const autoPassed = input2.autoPassed ? 1 : 0;
|
|
23829
23832
|
db.prepare(
|
|
23830
23833
|
`INSERT INTO playbook_approvals (
|
|
23831
23834
|
approval_id, run_id, node_id, token, status, auto_passed
|
|
23832
23835
|
) VALUES (?, ?, ?, ?, 'pending', ?)`
|
|
23833
|
-
).run(approvalId,
|
|
23836
|
+
).run(approvalId, input2.runId, input2.nodeId, input2.token, autoPassed);
|
|
23834
23837
|
const row = db.prepare("SELECT * FROM playbook_approvals WHERE approval_id = ?").get(approvalId);
|
|
23835
23838
|
if (!row) {
|
|
23836
23839
|
throw new Error(`playbook state: failed to read back approval ${approvalId} after insert`);
|
|
@@ -24007,7 +24010,7 @@ async function executeAgenticNode(node, runId, context, iteration, dispatcher) {
|
|
|
24007
24010
|
async function executeDeterministicNode(node, runId, context, iteration, dispatcher, runner) {
|
|
24008
24011
|
try {
|
|
24009
24012
|
if (runner !== void 0) {
|
|
24010
|
-
const
|
|
24013
|
+
const input2 = {
|
|
24011
24014
|
runId,
|
|
24012
24015
|
nodeId: node.id,
|
|
24013
24016
|
command: node.command,
|
|
@@ -24015,10 +24018,10 @@ async function executeDeterministicNode(node, runId, context, iteration, dispatc
|
|
|
24015
24018
|
context: { ...context },
|
|
24016
24019
|
iteration
|
|
24017
24020
|
};
|
|
24018
|
-
if (node.cwd !== void 0)
|
|
24019
|
-
if (node.env !== void 0)
|
|
24020
|
-
if (node.timeout_ms !== void 0)
|
|
24021
|
-
const result2 = await runner.run(
|
|
24021
|
+
if (node.cwd !== void 0) input2.cwd = node.cwd;
|
|
24022
|
+
if (node.env !== void 0) input2.env = node.env;
|
|
24023
|
+
if (node.timeout_ms !== void 0) input2.timeout_ms = node.timeout_ms;
|
|
24024
|
+
const result2 = await runner.run(input2);
|
|
24022
24025
|
if (result2.status === "success") {
|
|
24023
24026
|
return { kind: "success", output: result2.output };
|
|
24024
24027
|
}
|
|
@@ -24639,10 +24642,10 @@ async function buildDefaultDispatcher() {
|
|
|
24639
24642
|
const { getProjectRoot: getProjectRoot34 } = await import("@cleocode/core/internal");
|
|
24640
24643
|
const projectRoot = getProjectRoot34();
|
|
24641
24644
|
return {
|
|
24642
|
-
async dispatch(
|
|
24645
|
+
async dispatch(input2) {
|
|
24643
24646
|
try {
|
|
24644
24647
|
const result = await orchestrateSpawnExecute2(
|
|
24645
|
-
|
|
24648
|
+
input2.taskId,
|
|
24646
24649
|
/* adapterId */
|
|
24647
24650
|
void 0,
|
|
24648
24651
|
/* protocolType */
|
|
@@ -24655,9 +24658,9 @@ async function buildDefaultDispatcher() {
|
|
|
24655
24658
|
return {
|
|
24656
24659
|
status: "success",
|
|
24657
24660
|
output: {
|
|
24658
|
-
[`${
|
|
24659
|
-
nodeId:
|
|
24660
|
-
agentId:
|
|
24661
|
+
[`${input2.nodeId}_spawn`]: true,
|
|
24662
|
+
nodeId: input2.nodeId,
|
|
24663
|
+
agentId: input2.agentId,
|
|
24661
24664
|
dispatchData: result.data ?? null
|
|
24662
24665
|
}
|
|
24663
24666
|
};
|
|
@@ -24665,7 +24668,7 @@ async function buildDefaultDispatcher() {
|
|
|
24665
24668
|
return {
|
|
24666
24669
|
status: "failure",
|
|
24667
24670
|
output: {},
|
|
24668
|
-
error: result.error?.message ?? `spawn failed for ${
|
|
24671
|
+
error: result.error?.message ?? `spawn failed for ${input2.agentId}`
|
|
24669
24672
|
};
|
|
24670
24673
|
} catch (err) {
|
|
24671
24674
|
return {
|
|
@@ -25261,16 +25264,16 @@ async function orchestrateRejectOp(params) {
|
|
|
25261
25264
|
async function orchestrateClassify(request, context, projectRoot) {
|
|
25262
25265
|
try {
|
|
25263
25266
|
const { getCleoCantWorkflowsDir } = await import("@cleocode/core/internal");
|
|
25264
|
-
const { readFileSync:
|
|
25265
|
-
const { join:
|
|
25267
|
+
const { readFileSync: readFileSync18, readdirSync: readdirSync4, existsSync: existsSync16 } = await import("node:fs");
|
|
25268
|
+
const { join: join28 } = await import("node:path");
|
|
25266
25269
|
const workflowsDir = getCleoCantWorkflowsDir();
|
|
25267
25270
|
const combined = `${request} ${context ?? ""}`.toLowerCase();
|
|
25268
25271
|
const matches = [];
|
|
25269
|
-
if (
|
|
25272
|
+
if (existsSync16(workflowsDir)) {
|
|
25270
25273
|
const files = readdirSync4(workflowsDir).filter((f) => f.endsWith(".cant"));
|
|
25271
25274
|
for (const file of files) {
|
|
25272
25275
|
try {
|
|
25273
|
-
const src =
|
|
25276
|
+
const src = readFileSync18(join28(workflowsDir, file), "utf-8");
|
|
25274
25277
|
const teamMatch = /^team\s+(\S+):/m.exec(src);
|
|
25275
25278
|
if (!teamMatch) continue;
|
|
25276
25279
|
const teamName = teamMatch[1];
|
|
@@ -25285,12 +25288,12 @@ async function orchestrateClassify(request, context, projectRoot) {
|
|
|
25285
25288
|
}
|
|
25286
25289
|
}
|
|
25287
25290
|
}
|
|
25288
|
-
const localCantDir =
|
|
25289
|
-
if (
|
|
25291
|
+
const localCantDir = join28(projectRoot, CLEO_DIR_NAME, WORKFLOWS_SUBDIR);
|
|
25292
|
+
if (existsSync16(localCantDir)) {
|
|
25290
25293
|
const files = readdirSync4(localCantDir).filter((f) => f.endsWith(".cant"));
|
|
25291
25294
|
for (const file of files) {
|
|
25292
25295
|
try {
|
|
25293
|
-
const src =
|
|
25296
|
+
const src = readFileSync18(join28(localCantDir, file), "utf-8");
|
|
25294
25297
|
const teamMatch = /^team\s+(\S+):/m.exec(src);
|
|
25295
25298
|
if (!teamMatch) continue;
|
|
25296
25299
|
const teamName = teamMatch[1];
|
|
@@ -30672,7 +30675,7 @@ var init_add_batch = __esm({
|
|
|
30672
30675
|
});
|
|
30673
30676
|
}
|
|
30674
30677
|
}
|
|
30675
|
-
const
|
|
30678
|
+
const output2 = {
|
|
30676
30679
|
total: tasks.length,
|
|
30677
30680
|
created: tasks.length - failed,
|
|
30678
30681
|
failed,
|
|
@@ -30680,14 +30683,14 @@ var init_add_batch = __esm({
|
|
|
30680
30683
|
results
|
|
30681
30684
|
};
|
|
30682
30685
|
if (failed > 0) {
|
|
30683
|
-
cliOutput(
|
|
30686
|
+
cliOutput(output2, {
|
|
30684
30687
|
command: "add-batch",
|
|
30685
30688
|
message: `${failed} of ${tasks.length} tasks failed`,
|
|
30686
30689
|
operation: "tasks.add-batch"
|
|
30687
30690
|
});
|
|
30688
30691
|
process.exit(1);
|
|
30689
30692
|
} else {
|
|
30690
|
-
cliOutput(
|
|
30693
|
+
cliOutput(output2, {
|
|
30691
30694
|
command: "add-batch",
|
|
30692
30695
|
operation: "tasks.add-batch"
|
|
30693
30696
|
});
|
|
@@ -31964,12 +31967,12 @@ var init_agent = __esm({
|
|
|
31964
31967
|
transportConfig: {},
|
|
31965
31968
|
isActive: true
|
|
31966
31969
|
});
|
|
31967
|
-
const { existsSync:
|
|
31968
|
-
const { join:
|
|
31969
|
-
const cantDir =
|
|
31970
|
-
const cantPath =
|
|
31970
|
+
const { existsSync: existsSync16, mkdirSync: mkdirSync7, writeFileSync: writeFileSync7 } = await import("node:fs");
|
|
31971
|
+
const { join: join28 } = await import("node:path");
|
|
31972
|
+
const cantDir = join28(CLEO_DIR_NAME, AGENTS_SUBDIR);
|
|
31973
|
+
const cantPath = join28(cantDir, `${agentId}.cant`);
|
|
31971
31974
|
let cantScaffolded = false;
|
|
31972
|
-
if (!
|
|
31975
|
+
if (!existsSync16(cantPath)) {
|
|
31973
31976
|
mkdirSync7(cantDir, { recursive: true });
|
|
31974
31977
|
const role = classification ?? "specialist";
|
|
31975
31978
|
const cantContent = `---
|
|
@@ -32020,7 +32023,7 @@ agent ${agentId}:
|
|
|
32020
32023
|
enforcement:
|
|
32021
32024
|
1: TODO \u2014 what does this agent push back on?
|
|
32022
32025
|
`;
|
|
32023
|
-
|
|
32026
|
+
writeFileSync7(cantPath, cantContent, "utf-8");
|
|
32024
32027
|
cantScaffolded = true;
|
|
32025
32028
|
}
|
|
32026
32029
|
cliOutput(
|
|
@@ -32029,7 +32032,7 @@ agent ${agentId}:
|
|
|
32029
32032
|
data: {
|
|
32030
32033
|
agentId: credential.agentId,
|
|
32031
32034
|
displayName: credential.displayName,
|
|
32032
|
-
cantFile: cantScaffolded ? cantPath :
|
|
32035
|
+
cantFile: cantScaffolded ? cantPath : existsSync16(cantPath) ? cantPath : null,
|
|
32033
32036
|
cantScaffolded
|
|
32034
32037
|
}
|
|
32035
32038
|
},
|
|
@@ -32148,8 +32151,8 @@ agent ${agentId}:
|
|
|
32148
32151
|
try {
|
|
32149
32152
|
const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
|
|
32150
32153
|
const { createRuntime } = await import("@cleocode/runtime");
|
|
32151
|
-
const { existsSync:
|
|
32152
|
-
const { join:
|
|
32154
|
+
const { existsSync: existsSync16, readFileSync: readFileSync18 } = await import("node:fs");
|
|
32155
|
+
const { join: join28 } = await import("node:path");
|
|
32153
32156
|
await getDb3();
|
|
32154
32157
|
const registry = new AgentRegistryAccessor(process.cwd());
|
|
32155
32158
|
const credential = await registry.get(args.agentId);
|
|
@@ -32169,9 +32172,9 @@ agent ${agentId}:
|
|
|
32169
32172
|
}
|
|
32170
32173
|
let profile = null;
|
|
32171
32174
|
let cantValidation = null;
|
|
32172
|
-
const cantPath = args.cant ??
|
|
32173
|
-
if (
|
|
32174
|
-
profile =
|
|
32175
|
+
const cantPath = args.cant ?? join28(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
|
|
32176
|
+
if (existsSync16(cantPath)) {
|
|
32177
|
+
profile = readFileSync18(cantPath, "utf-8");
|
|
32175
32178
|
try {
|
|
32176
32179
|
const cantModule = await import("@cleocode/cant");
|
|
32177
32180
|
const validate = "validate" in cantModule ? cantModule.validate : null;
|
|
@@ -32694,8 +32697,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
32694
32697
|
try {
|
|
32695
32698
|
const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
|
|
32696
32699
|
const { createRuntime } = await import("@cleocode/runtime");
|
|
32697
|
-
const { existsSync:
|
|
32698
|
-
const { join:
|
|
32700
|
+
const { existsSync: existsSync16 } = await import("node:fs");
|
|
32701
|
+
const { join: join28 } = await import("node:path");
|
|
32699
32702
|
const { execFile: execFile2 } = await import("node:child_process");
|
|
32700
32703
|
const { promisify: promisify2 } = await import("node:util");
|
|
32701
32704
|
const execFileAsync = promisify2(execFile2);
|
|
@@ -32715,8 +32718,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
32715
32718
|
}
|
|
32716
32719
|
await registry.update(args.agentId, { isActive: true });
|
|
32717
32720
|
await registry.markUsed(args.agentId);
|
|
32718
|
-
const cantPath =
|
|
32719
|
-
const hasProfile =
|
|
32721
|
+
const cantPath = join28(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
|
|
32722
|
+
const hasProfile = existsSync16(cantPath);
|
|
32720
32723
|
const runtime = await createRuntime(registry, {
|
|
32721
32724
|
agentId: args.agentId,
|
|
32722
32725
|
pollIntervalMs: 5e3,
|
|
@@ -33564,11 +33567,11 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33564
33567
|
async run({ args }) {
|
|
33565
33568
|
let tempDir = null;
|
|
33566
33569
|
try {
|
|
33567
|
-
const { existsSync:
|
|
33568
|
-
const { join:
|
|
33570
|
+
const { existsSync: existsSync16, mkdirSync: mkdirSync7, statSync, readdirSync: readdirSync4, copyFileSync } = await import("node:fs");
|
|
33571
|
+
const { join: join28, basename, resolve: resolve5, extname } = await import("node:path");
|
|
33569
33572
|
const { tmpdir: tmpdir2 } = await import("node:os");
|
|
33570
33573
|
const resolvedPath = resolve5(args.path);
|
|
33571
|
-
if (!
|
|
33574
|
+
if (!existsSync16(resolvedPath)) {
|
|
33572
33575
|
cliOutput(
|
|
33573
33576
|
{
|
|
33574
33577
|
success: false,
|
|
@@ -33589,7 +33592,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33589
33592
|
cantPath = resolvedPath;
|
|
33590
33593
|
} else if (stat2.isFile() && ext === ".cantz") {
|
|
33591
33594
|
const { execFileSync: execFileSync5 } = await import("node:child_process");
|
|
33592
|
-
tempDir =
|
|
33595
|
+
tempDir = join28(tmpdir2(), `cleo-agent-install-${Date.now()}`);
|
|
33593
33596
|
mkdirSync7(tempDir, { recursive: true });
|
|
33594
33597
|
try {
|
|
33595
33598
|
execFileSync5("unzip", ["-o", "-q", resolvedPath, "-d", tempDir], {
|
|
@@ -33611,7 +33614,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33611
33614
|
return;
|
|
33612
33615
|
}
|
|
33613
33616
|
const topLevel = readdirSync4(tempDir).filter(
|
|
33614
|
-
(entry) => statSync(
|
|
33617
|
+
(entry) => statSync(join28(tempDir, entry)).isDirectory()
|
|
33615
33618
|
);
|
|
33616
33619
|
if (topLevel.length !== 1) {
|
|
33617
33620
|
cliOutput(
|
|
@@ -33628,8 +33631,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33628
33631
|
return;
|
|
33629
33632
|
}
|
|
33630
33633
|
const agentName = topLevel[0];
|
|
33631
|
-
const personaPath =
|
|
33632
|
-
if (!
|
|
33634
|
+
const personaPath = join28(tempDir, agentName, "persona.cant");
|
|
33635
|
+
if (!existsSync16(personaPath)) {
|
|
33633
33636
|
cliOutput(
|
|
33634
33637
|
{
|
|
33635
33638
|
success: false,
|
|
@@ -33643,12 +33646,12 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33643
33646
|
process.exitCode = 6;
|
|
33644
33647
|
return;
|
|
33645
33648
|
}
|
|
33646
|
-
cantPath =
|
|
33649
|
+
cantPath = join28(tempDir, `${agentName}.cant`);
|
|
33647
33650
|
copyFileSync(personaPath, cantPath);
|
|
33648
33651
|
} else if (stat2.isDirectory()) {
|
|
33649
33652
|
const agentName = basename(resolvedPath);
|
|
33650
|
-
const personaPath =
|
|
33651
|
-
if (!
|
|
33653
|
+
const personaPath = join28(resolvedPath, "persona.cant");
|
|
33654
|
+
if (!existsSync16(personaPath)) {
|
|
33652
33655
|
cliOutput(
|
|
33653
33656
|
{
|
|
33654
33657
|
success: false,
|
|
@@ -33662,9 +33665,9 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33662
33665
|
process.exitCode = 6;
|
|
33663
33666
|
return;
|
|
33664
33667
|
}
|
|
33665
|
-
tempDir =
|
|
33668
|
+
tempDir = join28(tmpdir2(), `cleo-agent-install-${Date.now()}`);
|
|
33666
33669
|
mkdirSync7(tempDir, { recursive: true });
|
|
33667
|
-
cantPath =
|
|
33670
|
+
cantPath = join28(tempDir, `${agentName}.cant`);
|
|
33668
33671
|
copyFileSync(personaPath, cantPath);
|
|
33669
33672
|
} else {
|
|
33670
33673
|
cliOutput(
|
|
@@ -33783,11 +33786,11 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33783
33786
|
},
|
|
33784
33787
|
async run({ args }) {
|
|
33785
33788
|
try {
|
|
33786
|
-
const { existsSync:
|
|
33789
|
+
const { existsSync: existsSync16, statSync } = await import("node:fs");
|
|
33787
33790
|
const { resolve: resolve5, basename, dirname: dirname9 } = await import("node:path");
|
|
33788
33791
|
const { execFileSync: execFileSync5 } = await import("node:child_process");
|
|
33789
33792
|
const resolvedDir = resolve5(args.dir);
|
|
33790
|
-
if (!
|
|
33793
|
+
if (!existsSync16(resolvedDir) || !statSync(resolvedDir).isDirectory()) {
|
|
33791
33794
|
cliOutput(
|
|
33792
33795
|
{
|
|
33793
33796
|
success: false,
|
|
@@ -33801,9 +33804,9 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33801
33804
|
process.exitCode = 4;
|
|
33802
33805
|
return;
|
|
33803
33806
|
}
|
|
33804
|
-
const { join:
|
|
33805
|
-
const personaPath =
|
|
33806
|
-
if (!
|
|
33807
|
+
const { join: join28 } = await import("node:path");
|
|
33808
|
+
const personaPath = join28(resolvedDir, "persona.cant");
|
|
33809
|
+
if (!existsSync16(personaPath)) {
|
|
33807
33810
|
cliOutput(
|
|
33808
33811
|
{
|
|
33809
33812
|
success: false,
|
|
@@ -33850,7 +33853,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33850
33853
|
if (entry.isFile()) {
|
|
33851
33854
|
fileCount++;
|
|
33852
33855
|
} else if (entry.isDirectory()) {
|
|
33853
|
-
countFiles(
|
|
33856
|
+
countFiles(join28(dirPath, entry.name));
|
|
33854
33857
|
}
|
|
33855
33858
|
}
|
|
33856
33859
|
};
|
|
@@ -33919,8 +33922,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33919
33922
|
},
|
|
33920
33923
|
async run({ args }) {
|
|
33921
33924
|
try {
|
|
33922
|
-
const { existsSync:
|
|
33923
|
-
const { join:
|
|
33925
|
+
const { existsSync: existsSync16, mkdirSync: mkdirSync7, writeFileSync: writeFileSync7 } = await import("node:fs");
|
|
33926
|
+
const { join: join28 } = await import("node:path");
|
|
33924
33927
|
const { homedir: homedir9 } = await import("node:os");
|
|
33925
33928
|
const name = args.name;
|
|
33926
33929
|
const role = args.role;
|
|
@@ -33980,13 +33983,13 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
33980
33983
|
let targetRoot;
|
|
33981
33984
|
if (isGlobal) {
|
|
33982
33985
|
const home = homedir9();
|
|
33983
|
-
const xdgData = process.env["XDG_DATA_HOME"] ??
|
|
33984
|
-
targetRoot =
|
|
33986
|
+
const xdgData = process.env["XDG_DATA_HOME"] ?? join28(home, ".local", "share");
|
|
33987
|
+
targetRoot = join28(xdgData, "cleo", "cant", "agents");
|
|
33985
33988
|
} else {
|
|
33986
|
-
targetRoot =
|
|
33989
|
+
targetRoot = join28(process.cwd(), CLEO_DIR_NAME, CANT_AGENTS_SUBDIR);
|
|
33987
33990
|
}
|
|
33988
|
-
const agentDir =
|
|
33989
|
-
if (
|
|
33991
|
+
const agentDir = join28(targetRoot, name);
|
|
33992
|
+
if (existsSync16(agentDir)) {
|
|
33990
33993
|
cliOutput(
|
|
33991
33994
|
{
|
|
33992
33995
|
success: false,
|
|
@@ -34010,29 +34013,29 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
34010
34013
|
domain,
|
|
34011
34014
|
parent
|
|
34012
34015
|
});
|
|
34013
|
-
|
|
34016
|
+
writeFileSync7(join28(agentDir, "persona.cant"), personaContent, "utf-8");
|
|
34014
34017
|
const manifest = generateManifest({ name, role, tier, domain });
|
|
34015
|
-
|
|
34016
|
-
|
|
34018
|
+
writeFileSync7(
|
|
34019
|
+
join28(agentDir, "manifest.json"),
|
|
34017
34020
|
`${JSON.stringify(manifest, null, 2)}
|
|
34018
34021
|
`,
|
|
34019
34022
|
"utf-8"
|
|
34020
34023
|
);
|
|
34021
34024
|
const createdFiles = [
|
|
34022
|
-
|
|
34023
|
-
|
|
34025
|
+
join28(agentDir, "persona.cant"),
|
|
34026
|
+
join28(agentDir, "manifest.json")
|
|
34024
34027
|
];
|
|
34025
34028
|
if (team) {
|
|
34026
34029
|
const teamConfigContent = generateTeamConfig(name, role, team);
|
|
34027
|
-
|
|
34028
|
-
createdFiles.push(
|
|
34030
|
+
writeFileSync7(join28(agentDir, "team-config.cant"), teamConfigContent, "utf-8");
|
|
34031
|
+
createdFiles.push(join28(agentDir, "team-config.cant"));
|
|
34029
34032
|
}
|
|
34030
34033
|
if (seedBrain) {
|
|
34031
|
-
const expertiseDir =
|
|
34034
|
+
const expertiseDir = join28(agentDir, "expertise");
|
|
34032
34035
|
mkdirSync7(expertiseDir, { recursive: true });
|
|
34033
34036
|
const seedContent = generateMentalModelSeed(name, role, domain);
|
|
34034
|
-
|
|
34035
|
-
createdFiles.push(
|
|
34037
|
+
writeFileSync7(join28(expertiseDir, "mental-model-seed.md"), seedContent, "utf-8");
|
|
34038
|
+
createdFiles.push(join28(expertiseDir, "mental-model-seed.md"));
|
|
34036
34039
|
try {
|
|
34037
34040
|
const { execFile: execFile2 } = await import("node:child_process");
|
|
34038
34041
|
const { promisify: promisify2 } = await import("node:util");
|
|
@@ -34130,17 +34133,17 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
|
|
|
34130
34133
|
},
|
|
34131
34134
|
async run({ args }) {
|
|
34132
34135
|
try {
|
|
34133
|
-
const { existsSync:
|
|
34134
|
-
const { resolve: resolve5, join:
|
|
34136
|
+
const { existsSync: existsSync16, readFileSync: readFileSync18, mkdirSync: mkdirSync7 } = await import("node:fs");
|
|
34137
|
+
const { resolve: resolve5, join: join28 } = await import("node:path");
|
|
34135
34138
|
const specPath = resolve5(args.spec);
|
|
34136
|
-
if (!
|
|
34139
|
+
if (!existsSync16(specPath)) {
|
|
34137
34140
|
cliError(`spec file not found: ${specPath}`, 4, { name: "E_NOT_FOUND" });
|
|
34138
34141
|
process.exitCode = 4;
|
|
34139
34142
|
return;
|
|
34140
34143
|
}
|
|
34141
|
-
const specContent =
|
|
34144
|
+
const specContent = readFileSync18(specPath, "utf-8");
|
|
34142
34145
|
const projectRoot = process.cwd();
|
|
34143
|
-
const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) :
|
|
34146
|
+
const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join28(projectRoot, ".cleo", "cant", "agents");
|
|
34144
34147
|
mkdirSync7(outputDir, { recursive: true });
|
|
34145
34148
|
if (args["dry-run"]) {
|
|
34146
34149
|
cliOutput(
|
|
@@ -34610,6 +34613,441 @@ var init_audit2 = __esm({
|
|
|
34610
34613
|
}
|
|
34611
34614
|
});
|
|
34612
34615
|
|
|
34616
|
+
// packages/cleo/src/cli/commands/auth/list.ts
|
|
34617
|
+
function formatExpiry(expiresAt) {
|
|
34618
|
+
if (expiresAt == null) return "never";
|
|
34619
|
+
const remaining = expiresAt - Date.now();
|
|
34620
|
+
if (remaining <= 0) return "expired";
|
|
34621
|
+
const minutes = Math.floor(remaining / 6e4);
|
|
34622
|
+
if (minutes <= 90) return `expires in ${minutes}m`;
|
|
34623
|
+
const hours = Math.floor(minutes / 60);
|
|
34624
|
+
if (hours <= 36) return `expires in ${hours}h`;
|
|
34625
|
+
const days = Math.floor(hours / 24);
|
|
34626
|
+
return `expires in ${days}d`;
|
|
34627
|
+
}
|
|
34628
|
+
var authListCommand;
|
|
34629
|
+
var init_list = __esm({
|
|
34630
|
+
"packages/cleo/src/cli/commands/auth/list.ts"() {
|
|
34631
|
+
"use strict";
|
|
34632
|
+
init_dist();
|
|
34633
|
+
init_renderers();
|
|
34634
|
+
authListCommand = defineCommand({
|
|
34635
|
+
meta: {
|
|
34636
|
+
name: "list",
|
|
34637
|
+
description: "List ALL pool entries from ALL sources (env, claude-code, cleo-pkce, codex-cli, gemini-cli, gh-cli, manual). Tokens are never surfaced \u2014 use `cleo llm list` for the LLM-scoped view that mirrors the manual store only."
|
|
34638
|
+
},
|
|
34639
|
+
args: {
|
|
34640
|
+
provider: {
|
|
34641
|
+
type: "string",
|
|
34642
|
+
description: "Filter to a single provider id (e.g. anthropic)"
|
|
34643
|
+
},
|
|
34644
|
+
json: {
|
|
34645
|
+
type: "boolean",
|
|
34646
|
+
description: "Output as JSON envelope"
|
|
34647
|
+
}
|
|
34648
|
+
},
|
|
34649
|
+
async run({ args }) {
|
|
34650
|
+
const a = args;
|
|
34651
|
+
const providerFilter = typeof a["provider"] === "string" && a["provider"] !== "" ? a["provider"] : null;
|
|
34652
|
+
const { getCredentialPool } = await import(
|
|
34653
|
+
/* webpackIgnore: true */
|
|
34654
|
+
"@cleocode/core/llm/credential-pool.js"
|
|
34655
|
+
);
|
|
34656
|
+
const pool = getCredentialPool();
|
|
34657
|
+
await pool.seed();
|
|
34658
|
+
const stored = await pool.list();
|
|
34659
|
+
const entries = stored.filter((c) => providerFilter ? c.provider === providerFilter : true).map((c) => ({
|
|
34660
|
+
provider: c.provider,
|
|
34661
|
+
label: c.label,
|
|
34662
|
+
source: c.source ?? "manual",
|
|
34663
|
+
authType: c.authType,
|
|
34664
|
+
expiryStatus: formatExpiry(c.expiresAt),
|
|
34665
|
+
// `current` is "is this entry not in active cooldown AND not disabled"
|
|
34666
|
+
// — i.e. could it be served right now. A richer notion of "default
|
|
34667
|
+
// credential per provider" would require resolver introspection,
|
|
34668
|
+
// which lands in a follow-up task.
|
|
34669
|
+
current: !c.disabled && (c.lastErrorResetAt == null || c.lastErrorResetAt <= Date.now())
|
|
34670
|
+
})).sort((a2, b) => {
|
|
34671
|
+
const p = a2.provider.localeCompare(b.provider);
|
|
34672
|
+
return p !== 0 ? p : a2.label.localeCompare(b.label);
|
|
34673
|
+
});
|
|
34674
|
+
cliOutput(
|
|
34675
|
+
{ entries },
|
|
34676
|
+
{
|
|
34677
|
+
command: "auth-list",
|
|
34678
|
+
operation: "auth.list"
|
|
34679
|
+
}
|
|
34680
|
+
);
|
|
34681
|
+
}
|
|
34682
|
+
});
|
|
34683
|
+
}
|
|
34684
|
+
});
|
|
34685
|
+
|
|
34686
|
+
// packages/cleo/src/cli/commands/auth/migrate-project-secrets.ts
|
|
34687
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "node:fs";
|
|
34688
|
+
import { join as join7 } from "node:path";
|
|
34689
|
+
import { createInterface } from "node:readline";
|
|
34690
|
+
function resolveProjectRootArg(arg) {
|
|
34691
|
+
if (typeof arg === "string" && arg.length > 0) return arg;
|
|
34692
|
+
return process.cwd();
|
|
34693
|
+
}
|
|
34694
|
+
function projectConfigPath(projectRoot) {
|
|
34695
|
+
const cleoDir = process.env["CLEO_DIR"] ?? ".cleo";
|
|
34696
|
+
return join7(projectRoot, cleoDir, "config.json");
|
|
34697
|
+
}
|
|
34698
|
+
function extractApiKeyEntries(config) {
|
|
34699
|
+
if (!config || typeof config !== "object") return [];
|
|
34700
|
+
const llm = config["llm"];
|
|
34701
|
+
if (!llm || typeof llm !== "object") return [];
|
|
34702
|
+
const providers = llm["providers"];
|
|
34703
|
+
if (!providers || typeof providers !== "object") return [];
|
|
34704
|
+
const out = [];
|
|
34705
|
+
for (const [provider, raw] of Object.entries(providers)) {
|
|
34706
|
+
if (!raw || typeof raw !== "object") continue;
|
|
34707
|
+
const apiKey = raw["apiKey"];
|
|
34708
|
+
if (typeof apiKey === "string" && apiKey.trim().length > 0) {
|
|
34709
|
+
out.push({ provider, apiKey: apiKey.trim() });
|
|
34710
|
+
}
|
|
34711
|
+
}
|
|
34712
|
+
return out;
|
|
34713
|
+
}
|
|
34714
|
+
function stripApiKeysFromConfig(config) {
|
|
34715
|
+
const clone = structuredClone(config);
|
|
34716
|
+
const llm = clone["llm"];
|
|
34717
|
+
if (!llm || typeof llm !== "object") return clone;
|
|
34718
|
+
const providers = llm["providers"];
|
|
34719
|
+
if (!providers || typeof providers !== "object") return clone;
|
|
34720
|
+
const cleanedProviders = {};
|
|
34721
|
+
for (const [provider, raw] of Object.entries(providers)) {
|
|
34722
|
+
if (!raw || typeof raw !== "object") {
|
|
34723
|
+
cleanedProviders[provider] = raw;
|
|
34724
|
+
continue;
|
|
34725
|
+
}
|
|
34726
|
+
const entry = { ...raw };
|
|
34727
|
+
delete entry["apiKey"];
|
|
34728
|
+
if (Object.keys(entry).length > 0) {
|
|
34729
|
+
cleanedProviders[provider] = entry;
|
|
34730
|
+
}
|
|
34731
|
+
}
|
|
34732
|
+
llm["providers"] = cleanedProviders;
|
|
34733
|
+
return clone;
|
|
34734
|
+
}
|
|
34735
|
+
function detectAuthType(provider, token) {
|
|
34736
|
+
if (provider !== "anthropic") return "api_key";
|
|
34737
|
+
if (token.startsWith("sk-ant-oat-") || token.startsWith("sk-ant-ort-")) return "oauth";
|
|
34738
|
+
return "api_key";
|
|
34739
|
+
}
|
|
34740
|
+
async function promptYesNo(question) {
|
|
34741
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
34742
|
+
try {
|
|
34743
|
+
const answer = await new Promise((resolve5) => {
|
|
34744
|
+
rl.question(question, (a) => resolve5(a));
|
|
34745
|
+
});
|
|
34746
|
+
const clean = answer.trim().toLowerCase();
|
|
34747
|
+
return clean === "y" || clean === "yes";
|
|
34748
|
+
} finally {
|
|
34749
|
+
rl.close();
|
|
34750
|
+
}
|
|
34751
|
+
}
|
|
34752
|
+
async function runMigrateProjectSecrets(opts) {
|
|
34753
|
+
const configPath = projectConfigPath(opts.projectRoot);
|
|
34754
|
+
if (!existsSync6(configPath)) {
|
|
34755
|
+
return {
|
|
34756
|
+
configPath,
|
|
34757
|
+
backupPath: null,
|
|
34758
|
+
migrated: [],
|
|
34759
|
+
cancelled: false,
|
|
34760
|
+
dryRun: opts.dryRun
|
|
34761
|
+
};
|
|
34762
|
+
}
|
|
34763
|
+
const raw = readFileSync7(configPath, "utf-8");
|
|
34764
|
+
let parsed;
|
|
34765
|
+
try {
|
|
34766
|
+
parsed = JSON.parse(raw);
|
|
34767
|
+
} catch (err) {
|
|
34768
|
+
throw new Error(
|
|
34769
|
+
`Failed to parse ${configPath}: ${err instanceof Error ? err.message : String(err)}. Fix the JSON syntax error before running migrate-project-secrets.`
|
|
34770
|
+
);
|
|
34771
|
+
}
|
|
34772
|
+
const entries = extractApiKeyEntries(parsed);
|
|
34773
|
+
if (entries.length === 0) {
|
|
34774
|
+
return {
|
|
34775
|
+
configPath,
|
|
34776
|
+
backupPath: null,
|
|
34777
|
+
migrated: [],
|
|
34778
|
+
cancelled: false,
|
|
34779
|
+
dryRun: opts.dryRun
|
|
34780
|
+
};
|
|
34781
|
+
}
|
|
34782
|
+
if (!opts.yes) {
|
|
34783
|
+
process.stderr.write(
|
|
34784
|
+
`Found ${entries.length} project-config secret(s) to migrate:
|
|
34785
|
+
` + entries.map((e) => ` - ${e.provider}
|
|
34786
|
+
`).join("") + `
|
|
34787
|
+
This will:
|
|
34788
|
+
1. Back up ${configPath} -> ${configPath}.pre-migration-bak
|
|
34789
|
+
2. Move each apiKey into the unified credential pool with label 'migrated-from-project-config'
|
|
34790
|
+
3. Remove the apiKey fields from the project config
|
|
34791
|
+
|
|
34792
|
+
`
|
|
34793
|
+
);
|
|
34794
|
+
const confirmed = await promptYesNo("Proceed? [y/N] ");
|
|
34795
|
+
if (!confirmed) {
|
|
34796
|
+
return {
|
|
34797
|
+
configPath,
|
|
34798
|
+
backupPath: null,
|
|
34799
|
+
migrated: [],
|
|
34800
|
+
cancelled: true,
|
|
34801
|
+
dryRun: opts.dryRun
|
|
34802
|
+
};
|
|
34803
|
+
}
|
|
34804
|
+
}
|
|
34805
|
+
if (opts.dryRun) {
|
|
34806
|
+
return {
|
|
34807
|
+
configPath,
|
|
34808
|
+
backupPath: null,
|
|
34809
|
+
migrated: entries.map((e) => ({
|
|
34810
|
+
provider: e.provider,
|
|
34811
|
+
label: "migrated-from-project-config",
|
|
34812
|
+
moved: false
|
|
34813
|
+
})),
|
|
34814
|
+
cancelled: false,
|
|
34815
|
+
dryRun: true
|
|
34816
|
+
};
|
|
34817
|
+
}
|
|
34818
|
+
const backupPath = `${configPath}.pre-migration-bak`;
|
|
34819
|
+
writeFileSync2(backupPath, raw, { mode: 384 });
|
|
34820
|
+
const { addCredential: addCredential2 } = await import(
|
|
34821
|
+
/* webpackIgnore: true */
|
|
34822
|
+
"@cleocode/core/llm/credentials-store.js"
|
|
34823
|
+
);
|
|
34824
|
+
const migrated = [];
|
|
34825
|
+
for (const { provider, apiKey } of entries) {
|
|
34826
|
+
await addCredential2({
|
|
34827
|
+
provider,
|
|
34828
|
+
label: "migrated-from-project-config",
|
|
34829
|
+
authType: detectAuthType(provider, apiKey),
|
|
34830
|
+
accessToken: apiKey,
|
|
34831
|
+
source: "manual"
|
|
34832
|
+
});
|
|
34833
|
+
migrated.push({ provider, label: "migrated-from-project-config", moved: true });
|
|
34834
|
+
}
|
|
34835
|
+
const stripped = stripApiKeysFromConfig(parsed);
|
|
34836
|
+
writeFileSync2(configPath, `${JSON.stringify(stripped, null, 2)}
|
|
34837
|
+
`, "utf-8");
|
|
34838
|
+
return {
|
|
34839
|
+
configPath,
|
|
34840
|
+
backupPath,
|
|
34841
|
+
migrated,
|
|
34842
|
+
cancelled: false,
|
|
34843
|
+
dryRun: false
|
|
34844
|
+
};
|
|
34845
|
+
}
|
|
34846
|
+
var authMigrateProjectSecretsCommand;
|
|
34847
|
+
var init_migrate_project_secrets = __esm({
|
|
34848
|
+
"packages/cleo/src/cli/commands/auth/migrate-project-secrets.ts"() {
|
|
34849
|
+
"use strict";
|
|
34850
|
+
init_dist();
|
|
34851
|
+
init_renderers();
|
|
34852
|
+
authMigrateProjectSecretsCommand = defineCommand({
|
|
34853
|
+
meta: {
|
|
34854
|
+
name: "migrate-project-secrets",
|
|
34855
|
+
description: "Move every llm.providers.*.apiKey out of .cleo/config.json (project-scoped, often committed to git) and into the unified credential pool. Atomic: backs up the original config to .cleo/config.json.pre-migration-bak first."
|
|
34856
|
+
},
|
|
34857
|
+
args: {
|
|
34858
|
+
"project-root": {
|
|
34859
|
+
type: "string",
|
|
34860
|
+
description: "Override the project root (default: cwd)"
|
|
34861
|
+
},
|
|
34862
|
+
yes: {
|
|
34863
|
+
type: "boolean",
|
|
34864
|
+
description: "Skip the interactive confirmation prompt",
|
|
34865
|
+
default: false
|
|
34866
|
+
},
|
|
34867
|
+
"dry-run": {
|
|
34868
|
+
type: "boolean",
|
|
34869
|
+
description: "Show what would be migrated without writing anything",
|
|
34870
|
+
default: false
|
|
34871
|
+
},
|
|
34872
|
+
json: {
|
|
34873
|
+
type: "boolean",
|
|
34874
|
+
description: "Output as JSON envelope"
|
|
34875
|
+
}
|
|
34876
|
+
},
|
|
34877
|
+
async run({ args }) {
|
|
34878
|
+
const a = args;
|
|
34879
|
+
const projectRoot = resolveProjectRootArg(a["project-root"]);
|
|
34880
|
+
const yes = Boolean(a["yes"]);
|
|
34881
|
+
const dryRun = Boolean(a["dry-run"]);
|
|
34882
|
+
let result;
|
|
34883
|
+
try {
|
|
34884
|
+
result = await runMigrateProjectSecrets({ projectRoot, yes, dryRun });
|
|
34885
|
+
} catch (err) {
|
|
34886
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
34887
|
+
cliError(message, 6, { name: "E_VALIDATION" });
|
|
34888
|
+
process.exit(6);
|
|
34889
|
+
}
|
|
34890
|
+
cliOutput(result, {
|
|
34891
|
+
command: "auth-migrate-project-secrets",
|
|
34892
|
+
operation: "auth.migrate-project-secrets"
|
|
34893
|
+
});
|
|
34894
|
+
}
|
|
34895
|
+
});
|
|
34896
|
+
}
|
|
34897
|
+
});
|
|
34898
|
+
|
|
34899
|
+
// packages/cleo/src/cli/commands/auth/remove.ts
|
|
34900
|
+
var authRemoveCommand;
|
|
34901
|
+
var init_remove = __esm({
|
|
34902
|
+
"packages/cleo/src/cli/commands/auth/remove.ts"() {
|
|
34903
|
+
"use strict";
|
|
34904
|
+
init_dist();
|
|
34905
|
+
init_renderers();
|
|
34906
|
+
authRemoveCommand = defineCommand({
|
|
34907
|
+
meta: {
|
|
34908
|
+
name: "remove",
|
|
34909
|
+
description: "Remove a credential by (provider, label) and suppress its source from future re-seeding. Dispatches to the per-source RemovalStep so claude-code (et al.) entries are handled correctly without deleting external files."
|
|
34910
|
+
},
|
|
34911
|
+
args: {
|
|
34912
|
+
provider: {
|
|
34913
|
+
type: "positional",
|
|
34914
|
+
description: "Provider id (e.g. anthropic, openai, gemini)",
|
|
34915
|
+
required: true
|
|
34916
|
+
},
|
|
34917
|
+
label: {
|
|
34918
|
+
type: "positional",
|
|
34919
|
+
description: "Label of the credential to remove (unique within provider)",
|
|
34920
|
+
required: true
|
|
34921
|
+
},
|
|
34922
|
+
json: {
|
|
34923
|
+
type: "boolean",
|
|
34924
|
+
description: "Output as JSON envelope"
|
|
34925
|
+
}
|
|
34926
|
+
},
|
|
34927
|
+
async run({ args }) {
|
|
34928
|
+
const a = args;
|
|
34929
|
+
const provider = String(a["provider"] ?? "");
|
|
34930
|
+
const label = String(a["label"] ?? "");
|
|
34931
|
+
if (!provider) {
|
|
34932
|
+
cliError("provider is required", 6, { name: "E_INVALID_INPUT" });
|
|
34933
|
+
process.exit(6);
|
|
34934
|
+
}
|
|
34935
|
+
if (!label) {
|
|
34936
|
+
cliError("label is required", 6, { name: "E_INVALID_INPUT" });
|
|
34937
|
+
process.exit(6);
|
|
34938
|
+
}
|
|
34939
|
+
const { getCredentialPool } = await import(
|
|
34940
|
+
/* webpackIgnore: true */
|
|
34941
|
+
"@cleocode/core/llm/credential-pool.js"
|
|
34942
|
+
);
|
|
34943
|
+
const { REMOVAL_REGISTRY, addSuppression } = await import(
|
|
34944
|
+
/* webpackIgnore: true */
|
|
34945
|
+
"@cleocode/core/llm/credential-removal.js"
|
|
34946
|
+
);
|
|
34947
|
+
const { removeCredential } = await import(
|
|
34948
|
+
/* webpackIgnore: true */
|
|
34949
|
+
"@cleocode/core/llm/credentials-store.js"
|
|
34950
|
+
);
|
|
34951
|
+
const pool = getCredentialPool();
|
|
34952
|
+
const entries = await pool.list();
|
|
34953
|
+
const entry = entries.find((c) => c.provider === provider && c.label === label);
|
|
34954
|
+
if (!entry) {
|
|
34955
|
+
cliError(`No credential found for provider='${provider}' label='${label}'`, 4, {
|
|
34956
|
+
name: "E_NOT_FOUND",
|
|
34957
|
+
fix: `Run 'cleo auth list' to see active credentials.`
|
|
34958
|
+
});
|
|
34959
|
+
process.exit(4);
|
|
34960
|
+
}
|
|
34961
|
+
const sourceId = entry.source ?? "manual";
|
|
34962
|
+
const step = REMOVAL_REGISTRY.find(sourceId);
|
|
34963
|
+
if (!step) {
|
|
34964
|
+
cliError(
|
|
34965
|
+
`No RemovalStep registered for source='${sourceId}' \u2014 cannot safely remove '${provider}/${label}'.`,
|
|
34966
|
+
2,
|
|
34967
|
+
{
|
|
34968
|
+
name: "E_REMOVAL_NOT_REGISTERED",
|
|
34969
|
+
fix: `Open an issue: a credential was seeded from an unknown source.`
|
|
34970
|
+
}
|
|
34971
|
+
);
|
|
34972
|
+
process.exit(2);
|
|
34973
|
+
}
|
|
34974
|
+
const stepResult = await step.remove({ provider, label });
|
|
34975
|
+
for (const path6 of stepResult.cleaned) {
|
|
34976
|
+
process.stderr.write(`cleaned: ${path6}
|
|
34977
|
+
`);
|
|
34978
|
+
}
|
|
34979
|
+
for (const hint of stepResult.hints) {
|
|
34980
|
+
process.stderr.write(`hint: ${hint}
|
|
34981
|
+
`);
|
|
34982
|
+
}
|
|
34983
|
+
let suppressed = false;
|
|
34984
|
+
if (stepResult.suppress) {
|
|
34985
|
+
addSuppression(provider, sourceId);
|
|
34986
|
+
suppressed = true;
|
|
34987
|
+
}
|
|
34988
|
+
const removed = await removeCredential(
|
|
34989
|
+
entry.provider,
|
|
34990
|
+
// ModelTransport
|
|
34991
|
+
label
|
|
34992
|
+
);
|
|
34993
|
+
const result = {
|
|
34994
|
+
provider,
|
|
34995
|
+
label,
|
|
34996
|
+
source: sourceId,
|
|
34997
|
+
removed,
|
|
34998
|
+
cleaned: stepResult.cleaned,
|
|
34999
|
+
hints: stepResult.hints,
|
|
35000
|
+
suppressed
|
|
35001
|
+
};
|
|
35002
|
+
cliOutput(result, {
|
|
35003
|
+
command: "auth-remove",
|
|
35004
|
+
operation: "auth.remove"
|
|
35005
|
+
});
|
|
35006
|
+
}
|
|
35007
|
+
});
|
|
35008
|
+
}
|
|
35009
|
+
});
|
|
35010
|
+
|
|
35011
|
+
// packages/cleo/src/cli/commands/auth/index.ts
|
|
35012
|
+
var init_auth = __esm({
|
|
35013
|
+
"packages/cleo/src/cli/commands/auth/index.ts"() {
|
|
35014
|
+
"use strict";
|
|
35015
|
+
init_list();
|
|
35016
|
+
init_migrate_project_secrets();
|
|
35017
|
+
init_remove();
|
|
35018
|
+
}
|
|
35019
|
+
});
|
|
35020
|
+
|
|
35021
|
+
// packages/cleo/src/cli/commands/auth.ts
|
|
35022
|
+
var auth_exports = {};
|
|
35023
|
+
__export(auth_exports, {
|
|
35024
|
+
authCommand: () => authCommand
|
|
35025
|
+
});
|
|
35026
|
+
var authCommand;
|
|
35027
|
+
var init_auth2 = __esm({
|
|
35028
|
+
"packages/cleo/src/cli/commands/auth.ts"() {
|
|
35029
|
+
"use strict";
|
|
35030
|
+
init_dist();
|
|
35031
|
+
init_auth();
|
|
35032
|
+
authCommand = defineCommand({
|
|
35033
|
+
meta: {
|
|
35034
|
+
name: "auth",
|
|
35035
|
+
description: "Unified credential view across all seeded sources (cleo llm list is the LLM-scoped sister command)."
|
|
35036
|
+
},
|
|
35037
|
+
subCommands: {
|
|
35038
|
+
list: authListCommand,
|
|
35039
|
+
remove: authRemoveCommand,
|
|
35040
|
+
"migrate-project-secrets": authMigrateProjectSecretsCommand
|
|
35041
|
+
},
|
|
35042
|
+
async run({ cmd, rawArgs }) {
|
|
35043
|
+
const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
|
|
35044
|
+
if (firstArg && cmd.subCommands && firstArg in cmd.subCommands) return;
|
|
35045
|
+
await showUsage(cmd);
|
|
35046
|
+
}
|
|
35047
|
+
});
|
|
35048
|
+
}
|
|
35049
|
+
});
|
|
35050
|
+
|
|
34613
35051
|
// packages/cleo/src/cli/commands/backfill.ts
|
|
34614
35052
|
var backfill_exports = {};
|
|
34615
35053
|
__export(backfill_exports, {
|
|
@@ -34713,7 +35151,7 @@ var init_backfill = __esm({
|
|
|
34713
35151
|
}
|
|
34714
35152
|
try {
|
|
34715
35153
|
const result = await backfillTasks(root, { dryRun, rollback, taskIds });
|
|
34716
|
-
const
|
|
35154
|
+
const output2 = {
|
|
34717
35155
|
dryRun,
|
|
34718
35156
|
rollback,
|
|
34719
35157
|
tasksScanned: result.tasksScanned,
|
|
@@ -34721,12 +35159,12 @@ var init_backfill = __esm({
|
|
|
34721
35159
|
changes: result.changes
|
|
34722
35160
|
};
|
|
34723
35161
|
if (!rollback) {
|
|
34724
|
-
|
|
34725
|
-
|
|
35162
|
+
output2["acAdded"] = result.acAdded;
|
|
35163
|
+
output2["verificationAdded"] = result.verificationAdded;
|
|
34726
35164
|
}
|
|
34727
35165
|
const messagePrefix = dryRun ? "[dry run] " : rollback ? "[rollback] " : "";
|
|
34728
35166
|
const messageSuffix = result.changes.length === 0 ? "Nothing to do \u2014 all tasks already have AC and verification metadata." : `Scanned ${result.tasksScanned}, changed ${result.tasksChanged} task(s).`;
|
|
34729
|
-
cliOutput(
|
|
35167
|
+
cliOutput(output2, {
|
|
34730
35168
|
command: "backfill",
|
|
34731
35169
|
operation: "admin.backfill",
|
|
34732
35170
|
message: `${messagePrefix}${messageSuffix}`
|
|
@@ -35845,12 +36283,12 @@ var briefing_exports = {};
|
|
|
35845
36283
|
__export(briefing_exports, {
|
|
35846
36284
|
briefingCommand: () => briefingCommand
|
|
35847
36285
|
});
|
|
35848
|
-
import { existsSync as
|
|
36286
|
+
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
35849
36287
|
import { homedir as homedir2 } from "node:os";
|
|
35850
|
-
import { join as
|
|
36288
|
+
import { join as join8 } from "node:path";
|
|
35851
36289
|
function resolveInjectionTemplatePath() {
|
|
35852
|
-
const xdgConfig = process.env["XDG_CONFIG_HOME"] ??
|
|
35853
|
-
return
|
|
36290
|
+
const xdgConfig = process.env["XDG_CONFIG_HOME"] ?? join8(homedir2(), ".cleo");
|
|
36291
|
+
return join8(xdgConfig, "templates", "CLEO-INJECTION.md");
|
|
35854
36292
|
}
|
|
35855
36293
|
function extractSection(content, sectionName) {
|
|
35856
36294
|
const openTag = `<!-- CLEO-INJECTION:section=${sectionName} -->`;
|
|
@@ -35877,13 +36315,13 @@ function renderForAdapter(sectionName, content, format) {
|
|
|
35877
36315
|
}
|
|
35878
36316
|
async function runBriefingInject(sectionName, formatStr) {
|
|
35879
36317
|
const templatePath = resolveInjectionTemplatePath();
|
|
35880
|
-
if (!
|
|
36318
|
+
if (!existsSync7(templatePath)) {
|
|
35881
36319
|
process.stderr.write(`[briefing inject] CLEO-INJECTION.md not found at ${templatePath}
|
|
35882
36320
|
`);
|
|
35883
36321
|
process.exitCode = 1;
|
|
35884
36322
|
return;
|
|
35885
36323
|
}
|
|
35886
|
-
const content =
|
|
36324
|
+
const content = readFileSync8(templatePath, "utf-8");
|
|
35887
36325
|
const section = extractSection(content, sectionName);
|
|
35888
36326
|
if (section === null) {
|
|
35889
36327
|
const available = INJECTION_SECTION_NAMES.join(", ");
|
|
@@ -35895,7 +36333,7 @@ Available sections: ${available}
|
|
|
35895
36333
|
process.exitCode = 1;
|
|
35896
36334
|
return;
|
|
35897
36335
|
}
|
|
35898
|
-
let
|
|
36336
|
+
let output2 = section;
|
|
35899
36337
|
if (formatStr.startsWith("adapter:")) {
|
|
35900
36338
|
const adapterName = formatStr.slice("adapter:".length);
|
|
35901
36339
|
if (!ADAPTER_FORMATS.includes(adapterName)) {
|
|
@@ -35906,9 +36344,9 @@ Available sections: ${available}
|
|
|
35906
36344
|
process.exitCode = 1;
|
|
35907
36345
|
return;
|
|
35908
36346
|
}
|
|
35909
|
-
|
|
36347
|
+
output2 = renderForAdapter(sectionName, section, adapterName);
|
|
35910
36348
|
}
|
|
35911
|
-
process.stdout.write(
|
|
36349
|
+
process.stdout.write(output2 + "\n");
|
|
35912
36350
|
}
|
|
35913
36351
|
var INJECTION_SECTION_NAMES, ADAPTER_FORMATS, briefingCommand;
|
|
35914
36352
|
var init_briefing = __esm({
|
|
@@ -36026,7 +36464,7 @@ __export(caamp_exports, {
|
|
|
36026
36464
|
caampCommand: () => caampCommand
|
|
36027
36465
|
});
|
|
36028
36466
|
import { homedir as homedir3 } from "node:os";
|
|
36029
|
-
import { join as
|
|
36467
|
+
import { join as join9 } from "node:path";
|
|
36030
36468
|
var dedupeCommand, caampCommand;
|
|
36031
36469
|
var init_caamp = __esm({
|
|
36032
36470
|
"packages/cleo/src/cli/commands/caamp.ts"() {
|
|
@@ -36063,18 +36501,18 @@ var init_caamp = __esm({
|
|
|
36063
36501
|
} else {
|
|
36064
36502
|
const home = homedir3();
|
|
36065
36503
|
filePaths = [
|
|
36066
|
-
|
|
36504
|
+
join9(home, ".agents", "AGENTS.md"),
|
|
36067
36505
|
// project-level AGENTS.md in cwd
|
|
36068
|
-
|
|
36506
|
+
join9(process.cwd(), "AGENTS.md")
|
|
36069
36507
|
];
|
|
36070
36508
|
}
|
|
36071
36509
|
if (args["dry-run"]) {
|
|
36072
36510
|
const { parseCaampBlocks } = await import("@cleocode/caamp");
|
|
36073
|
-
const { existsSync:
|
|
36511
|
+
const { existsSync: existsSync16 } = await import("node:fs");
|
|
36074
36512
|
const { readFile: readFile6 } = await import("node:fs/promises");
|
|
36075
36513
|
const dryResults = [];
|
|
36076
36514
|
for (const filePath of filePaths) {
|
|
36077
|
-
if (!
|
|
36515
|
+
if (!existsSync16(filePath)) {
|
|
36078
36516
|
dryResults.push({ filePath, exists: false, blockCount: 0, wouldRemove: 0 });
|
|
36079
36517
|
continue;
|
|
36080
36518
|
}
|
|
@@ -36172,13 +36610,13 @@ var cant_exports = {};
|
|
|
36172
36610
|
__export(cant_exports, {
|
|
36173
36611
|
cantCommand: () => cantCommand
|
|
36174
36612
|
});
|
|
36175
|
-
import { existsSync as
|
|
36176
|
-
import { dirname as dirname4, isAbsolute, join as
|
|
36613
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync3 } from "node:fs";
|
|
36614
|
+
import { dirname as dirname4, isAbsolute, join as join10, resolve as resolve3 } from "node:path";
|
|
36177
36615
|
function resolveFilePath(file) {
|
|
36178
36616
|
return isAbsolute(file) ? file : resolve3(process.cwd(), file);
|
|
36179
36617
|
}
|
|
36180
36618
|
function ensureExists(filePath, operation) {
|
|
36181
|
-
if (
|
|
36619
|
+
if (existsSync8(filePath)) return true;
|
|
36182
36620
|
cliError(`File not found: ${filePath}`, "E_FILE_READ");
|
|
36183
36621
|
process.exitCode = 3;
|
|
36184
36622
|
if (process.env["CLEO_DEBUG"]) humanWarn(`(operation: ${operation})`);
|
|
@@ -36328,7 +36766,7 @@ var init_cant = __esm({
|
|
|
36328
36766
|
if (!ensureExists(filePath, "cant.migrate")) return;
|
|
36329
36767
|
try {
|
|
36330
36768
|
const mod = await loadMigrateEngine();
|
|
36331
|
-
const content =
|
|
36769
|
+
const content = readFileSync9(filePath, "utf-8");
|
|
36332
36770
|
const result = mod.migrateMarkdown(content, filePath, {
|
|
36333
36771
|
write: isWrite,
|
|
36334
36772
|
verbose: isVerbose,
|
|
@@ -36338,9 +36776,9 @@ var init_cant = __esm({
|
|
|
36338
36776
|
const projectRoot = process.cwd();
|
|
36339
36777
|
let written = 0;
|
|
36340
36778
|
for (const outputFile of result.outputFiles) {
|
|
36341
|
-
const outputPath = isAbsolute(outputFile.path) ? outputFile.path :
|
|
36779
|
+
const outputPath = isAbsolute(outputFile.path) ? outputFile.path : join10(projectRoot, outputFile.path);
|
|
36342
36780
|
mkdirSync2(dirname4(outputPath), { recursive: true });
|
|
36343
|
-
|
|
36781
|
+
writeFileSync3(outputPath, outputFile.content, "utf-8");
|
|
36344
36782
|
written++;
|
|
36345
36783
|
}
|
|
36346
36784
|
cliOutput(
|
|
@@ -36394,7 +36832,7 @@ var chain_exports = {};
|
|
|
36394
36832
|
__export(chain_exports, {
|
|
36395
36833
|
chainCommand: () => chainCommand
|
|
36396
36834
|
});
|
|
36397
|
-
import { readFileSync as
|
|
36835
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
36398
36836
|
var showCommand3, listCommand5, addCommand3, instantiateCommand, advanceCommand, chainCommand;
|
|
36399
36837
|
var init_chain = __esm({
|
|
36400
36838
|
"packages/cleo/src/cli/commands/chain.ts"() {
|
|
@@ -36436,7 +36874,7 @@ var init_chain = __esm({
|
|
|
36436
36874
|
}
|
|
36437
36875
|
},
|
|
36438
36876
|
async run({ args }) {
|
|
36439
|
-
const chainJson = JSON.parse(
|
|
36877
|
+
const chainJson = JSON.parse(readFileSync10(args.file, "utf-8"));
|
|
36440
36878
|
await dispatchFromCli(
|
|
36441
36879
|
"mutate",
|
|
36442
36880
|
"pipeline",
|
|
@@ -36621,10 +37059,10 @@ var init_check2 = __esm({
|
|
|
36621
37059
|
}
|
|
36622
37060
|
},
|
|
36623
37061
|
async run({ args }) {
|
|
36624
|
-
const { readFileSync:
|
|
37062
|
+
const { readFileSync: readFileSync18 } = await import("node:fs");
|
|
36625
37063
|
let chain;
|
|
36626
37064
|
try {
|
|
36627
|
-
chain = JSON.parse(
|
|
37065
|
+
chain = JSON.parse(readFileSync18(args.file, "utf8"));
|
|
36628
37066
|
} catch (err) {
|
|
36629
37067
|
const message = err instanceof Error ? err.message : String(err);
|
|
36630
37068
|
cliError(`Failed to read or parse chain file: ${message}`, 2, {
|
|
@@ -37096,9 +37534,9 @@ var init_code = __esm({
|
|
|
37096
37534
|
async run({ args }) {
|
|
37097
37535
|
await requireTreeSitter();
|
|
37098
37536
|
const { smartOutline } = await import("@cleocode/core/internal");
|
|
37099
|
-
const { join:
|
|
37537
|
+
const { join: join28 } = await import("node:path");
|
|
37100
37538
|
const root = process.cwd();
|
|
37101
|
-
const absPath = args.file.startsWith("/") ? args.file :
|
|
37539
|
+
const absPath = args.file.startsWith("/") ? args.file : join28(root, args.file);
|
|
37102
37540
|
const result = smartOutline(absPath, root);
|
|
37103
37541
|
if (result.errors.length > 0 && result.symbols.length === 0) {
|
|
37104
37542
|
cliError(result.errors.join(", "), 1, { name: "E_OUTLINE_FAILED" });
|
|
@@ -37189,9 +37627,9 @@ var init_code = __esm({
|
|
|
37189
37627
|
async run({ args }) {
|
|
37190
37628
|
await requireTreeSitter();
|
|
37191
37629
|
const { smartUnfold } = await import("@cleocode/core/internal");
|
|
37192
|
-
const { join:
|
|
37630
|
+
const { join: join28 } = await import("node:path");
|
|
37193
37631
|
const root = process.cwd();
|
|
37194
|
-
const absPath = args.file.startsWith("/") ? args.file :
|
|
37632
|
+
const absPath = args.file.startsWith("/") ? args.file : join28(root, args.file);
|
|
37195
37633
|
const result = smartUnfold(absPath, args.symbol, root);
|
|
37196
37634
|
if (!result.found) {
|
|
37197
37635
|
const errs = result.errors.length > 0 ? `: ${result.errors.join(", ")}` : "";
|
|
@@ -37270,16 +37708,16 @@ var init_complete = __esm({
|
|
|
37270
37708
|
}
|
|
37271
37709
|
const data = response.data;
|
|
37272
37710
|
const task = data?.task ?? data;
|
|
37273
|
-
const
|
|
37711
|
+
const output2 = { task };
|
|
37274
37712
|
const autoCompleted = data?.autoCompleted;
|
|
37275
37713
|
if (Array.isArray(autoCompleted) && autoCompleted.length > 0) {
|
|
37276
|
-
|
|
37714
|
+
output2["autoCompleted"] = autoCompleted;
|
|
37277
37715
|
}
|
|
37278
37716
|
const unblockedTasks = data?.unblockedTasks;
|
|
37279
37717
|
if (Array.isArray(unblockedTasks) && unblockedTasks.length > 0) {
|
|
37280
|
-
|
|
37718
|
+
output2["unblockedTasks"] = unblockedTasks;
|
|
37281
37719
|
}
|
|
37282
|
-
cliOutput(
|
|
37720
|
+
cliOutput(output2, { command: "complete", operation: "tasks.complete" });
|
|
37283
37721
|
}
|
|
37284
37722
|
});
|
|
37285
37723
|
}
|
|
@@ -38333,9 +38771,9 @@ var daemon_exports = {};
|
|
|
38333
38771
|
__export(daemon_exports, {
|
|
38334
38772
|
daemonCommand: () => daemonCommand
|
|
38335
38773
|
});
|
|
38336
|
-
import { existsSync as
|
|
38774
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
38337
38775
|
import { homedir as homedir4 } from "node:os";
|
|
38338
|
-
import { join as
|
|
38776
|
+
import { join as join11 } from "node:path";
|
|
38339
38777
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
38340
38778
|
import { getGCDaemonStatus, spawnGCDaemon, stopGCDaemon } from "@cleocode/core/gc/daemon.js";
|
|
38341
38779
|
import {
|
|
@@ -38400,9 +38838,9 @@ async function showDaemonStatus(cleoDir, projectRoot) {
|
|
|
38400
38838
|
}
|
|
38401
38839
|
function resolveDaemonInstallerScript() {
|
|
38402
38840
|
const filePath = fileURLToPath3(import.meta.url);
|
|
38403
|
-
const candidate1 =
|
|
38404
|
-
if (
|
|
38405
|
-
const candidate2 =
|
|
38841
|
+
const candidate1 = join11(filePath, "..", "..", "..", "scripts", "install-daemon-service.mjs");
|
|
38842
|
+
if (existsSync9(candidate1)) return candidate1;
|
|
38843
|
+
const candidate2 = join11(
|
|
38406
38844
|
filePath,
|
|
38407
38845
|
"..",
|
|
38408
38846
|
"..",
|
|
@@ -38437,7 +38875,7 @@ var init_daemon = __esm({
|
|
|
38437
38875
|
}
|
|
38438
38876
|
},
|
|
38439
38877
|
async run({ args }) {
|
|
38440
|
-
const cleoDir = args["cleo-dir"] ??
|
|
38878
|
+
const cleoDir = args["cleo-dir"] ?? join11(homedir4(), ".cleo");
|
|
38441
38879
|
const foreground = args.foreground ?? false;
|
|
38442
38880
|
if (foreground) {
|
|
38443
38881
|
const projectRoot = process.cwd();
|
|
@@ -38474,13 +38912,13 @@ var init_daemon = __esm({
|
|
|
38474
38912
|
{
|
|
38475
38913
|
pid,
|
|
38476
38914
|
cleoDir,
|
|
38477
|
-
logs:
|
|
38915
|
+
logs: join11(cleoDir, "logs", "gc.log"),
|
|
38478
38916
|
message: `GC daemon started (PID ${pid})`
|
|
38479
38917
|
},
|
|
38480
38918
|
{
|
|
38481
38919
|
command: "daemon",
|
|
38482
38920
|
operation: "daemon.start",
|
|
38483
|
-
message: `GC daemon started (PID ${pid}) \u2014 Logs: ${
|
|
38921
|
+
message: `GC daemon started (PID ${pid}) \u2014 Logs: ${join11(cleoDir, "logs", "gc.log")}`
|
|
38484
38922
|
}
|
|
38485
38923
|
);
|
|
38486
38924
|
} catch (err) {
|
|
@@ -38510,7 +38948,7 @@ var init_daemon = __esm({
|
|
|
38510
38948
|
}
|
|
38511
38949
|
},
|
|
38512
38950
|
async run({ args }) {
|
|
38513
|
-
const cleoDir = args["cleo-dir"] ??
|
|
38951
|
+
const cleoDir = args["cleo-dir"] ?? join11(homedir4(), ".cleo");
|
|
38514
38952
|
try {
|
|
38515
38953
|
const stopResult = await stopGCDaemon(cleoDir);
|
|
38516
38954
|
cliOutput(stopResult, {
|
|
@@ -38548,7 +38986,7 @@ var init_daemon = __esm({
|
|
|
38548
38986
|
}
|
|
38549
38987
|
},
|
|
38550
38988
|
async run({ args }) {
|
|
38551
|
-
const cleoDir = args["cleo-dir"] ??
|
|
38989
|
+
const cleoDir = args["cleo-dir"] ?? join11(homedir4(), ".cleo");
|
|
38552
38990
|
await showDaemonStatus(cleoDir, process.cwd());
|
|
38553
38991
|
}
|
|
38554
38992
|
});
|
|
@@ -38646,7 +39084,7 @@ var init_daemon = __esm({
|
|
|
38646
39084
|
},
|
|
38647
39085
|
async run({ args, cmd, rawArgs }) {
|
|
38648
39086
|
if (isSubCommandDispatch(rawArgs, cmd.subCommands)) return;
|
|
38649
|
-
const cleoDir = args["cleo-dir"] ??
|
|
39087
|
+
const cleoDir = args["cleo-dir"] ?? join11(homedir4(), ".cleo");
|
|
38650
39088
|
await showDaemonStatus(cleoDir, process.cwd());
|
|
38651
39089
|
}
|
|
38652
39090
|
});
|
|
@@ -38843,12 +39281,12 @@ var init_delete = __esm({
|
|
|
38843
39281
|
handleRawError(response, { command: "delete", operation: "tasks.delete" });
|
|
38844
39282
|
}
|
|
38845
39283
|
const data = response.data;
|
|
38846
|
-
const
|
|
39284
|
+
const output2 = { deletedTask: data?.deletedTask };
|
|
38847
39285
|
const cascadeDeleted = data?.cascadeDeleted;
|
|
38848
39286
|
if (Array.isArray(cascadeDeleted) && cascadeDeleted.length > 0) {
|
|
38849
|
-
|
|
39287
|
+
output2["cascadeDeleted"] = cascadeDeleted;
|
|
38850
39288
|
}
|
|
38851
|
-
cliOutput(
|
|
39289
|
+
cliOutput(output2, { command: "delete", operation: "tasks.delete" });
|
|
38852
39290
|
}
|
|
38853
39291
|
});
|
|
38854
39292
|
}
|
|
@@ -39109,12 +39547,12 @@ var detect_drift_exports = {};
|
|
|
39109
39547
|
__export(detect_drift_exports, {
|
|
39110
39548
|
detectDriftCommand: () => detectDriftCommand
|
|
39111
39549
|
});
|
|
39112
|
-
import { existsSync as
|
|
39113
|
-
import { dirname as dirname5, join as
|
|
39550
|
+
import { existsSync as existsSync10, readdirSync, readFileSync as readFileSync11 } from "node:fs";
|
|
39551
|
+
import { dirname as dirname5, join as join12 } from "node:path";
|
|
39114
39552
|
function findProjectRoot() {
|
|
39115
39553
|
let currentDir = process.cwd();
|
|
39116
39554
|
while (currentDir !== "/") {
|
|
39117
|
-
if (
|
|
39555
|
+
if (existsSync10(join12(currentDir, "package.json"))) {
|
|
39118
39556
|
return currentDir;
|
|
39119
39557
|
}
|
|
39120
39558
|
const parent = dirname5(currentDir);
|
|
@@ -39138,11 +39576,11 @@ var init_detect_drift = __esm({
|
|
|
39138
39576
|
},
|
|
39139
39577
|
async run() {
|
|
39140
39578
|
const projectRoot = findProjectRoot();
|
|
39141
|
-
const isCleoRepo =
|
|
39142
|
-
const cleoSrcRoot = isCleoRepo ?
|
|
39579
|
+
const isCleoRepo = existsSync10(join12(projectRoot, "packages", "cleo", "src"));
|
|
39580
|
+
const cleoSrcRoot = isCleoRepo ? join12(projectRoot, "packages", "cleo", "src") : join12(projectRoot, "src");
|
|
39143
39581
|
const safeRead = (filePath) => {
|
|
39144
39582
|
try {
|
|
39145
|
-
return
|
|
39583
|
+
return readFileSync11(filePath, "utf-8");
|
|
39146
39584
|
} catch {
|
|
39147
39585
|
return "";
|
|
39148
39586
|
}
|
|
@@ -39153,8 +39591,8 @@ var init_detect_drift = __esm({
|
|
|
39153
39591
|
checks: [],
|
|
39154
39592
|
recommendations: []
|
|
39155
39593
|
};
|
|
39156
|
-
const injPath =
|
|
39157
|
-
if (
|
|
39594
|
+
const injPath = join12(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
|
|
39595
|
+
if (existsSync10(injPath)) {
|
|
39158
39596
|
const content = safeRead(injPath);
|
|
39159
39597
|
userResult.checks.push({
|
|
39160
39598
|
name: "Agent injection",
|
|
@@ -39205,10 +39643,10 @@ var init_detect_drift = __esm({
|
|
|
39205
39643
|
}
|
|
39206
39644
|
};
|
|
39207
39645
|
try {
|
|
39208
|
-
const specPath =
|
|
39209
|
-
const registryPath =
|
|
39210
|
-
const dispatchDomainsDir =
|
|
39211
|
-
if (!
|
|
39646
|
+
const specPath = join12(projectRoot, "docs", "specs", "CLEO-OPERATION-CONSTITUTION.md");
|
|
39647
|
+
const registryPath = join12(cleoSrcRoot, "dispatch", "registry.ts");
|
|
39648
|
+
const dispatchDomainsDir = join12(cleoSrcRoot, "dispatch", "domains");
|
|
39649
|
+
if (!existsSync10(specPath)) {
|
|
39212
39650
|
addCheck("Gateway-to-spec sync", "fail", "CLEO-OPERATION-CONSTITUTION.md missing", [
|
|
39213
39651
|
{
|
|
39214
39652
|
severity: "error",
|
|
@@ -39218,7 +39656,7 @@ var init_detect_drift = __esm({
|
|
|
39218
39656
|
recommendation: "Create docs/specs/CLEO-OPERATION-CONSTITUTION.md with canonical operation definitions"
|
|
39219
39657
|
}
|
|
39220
39658
|
]);
|
|
39221
|
-
} else if (!
|
|
39659
|
+
} else if (!existsSync10(registryPath) || !existsSync10(dispatchDomainsDir)) {
|
|
39222
39660
|
addCheck("Gateway-to-spec sync", "fail", "Dispatch registry or domains missing", [
|
|
39223
39661
|
{
|
|
39224
39662
|
severity: "error",
|
|
@@ -39276,9 +39714,9 @@ var init_detect_drift = __esm({
|
|
|
39276
39714
|
]);
|
|
39277
39715
|
}
|
|
39278
39716
|
try {
|
|
39279
|
-
const cliDir =
|
|
39280
|
-
const coreDir = isCleoRepo ?
|
|
39281
|
-
if (!
|
|
39717
|
+
const cliDir = join12(cleoSrcRoot, "cli", "commands");
|
|
39718
|
+
const coreDir = isCleoRepo ? join12(projectRoot, "packages", "core", "src") : join12(projectRoot, "src", "core");
|
|
39719
|
+
if (!existsSync10(cliDir)) {
|
|
39282
39720
|
addCheck("CLI-to-core sync", "fail", "CLI commands directory missing", [
|
|
39283
39721
|
{
|
|
39284
39722
|
severity: "error",
|
|
@@ -39287,7 +39725,7 @@ var init_detect_drift = __esm({
|
|
|
39287
39725
|
recommendation: "Verify TypeScript source structure is intact"
|
|
39288
39726
|
}
|
|
39289
39727
|
]);
|
|
39290
|
-
} else if (!
|
|
39728
|
+
} else if (!existsSync10(coreDir)) {
|
|
39291
39729
|
addCheck("CLI-to-core sync", "fail", "Core directory missing", [
|
|
39292
39730
|
{
|
|
39293
39731
|
severity: "error",
|
|
@@ -39304,8 +39742,8 @@ var init_detect_drift = __esm({
|
|
|
39304
39742
|
addCheck("CLI-to-core sync", "fail", `Error: ${getErrorMessage(e)}`);
|
|
39305
39743
|
}
|
|
39306
39744
|
try {
|
|
39307
|
-
const domainsDir =
|
|
39308
|
-
if (!
|
|
39745
|
+
const domainsDir = join12(cleoSrcRoot, "dispatch", "domains");
|
|
39746
|
+
if (!existsSync10(domainsDir)) {
|
|
39309
39747
|
addCheck("Domain handler coverage", "fail", "Dispatch domains directory missing", [
|
|
39310
39748
|
{
|
|
39311
39749
|
severity: "error",
|
|
@@ -39322,8 +39760,8 @@ var init_detect_drift = __esm({
|
|
|
39322
39760
|
addCheck("Domain handler coverage", "fail", `Error: ${getErrorMessage(e)}`);
|
|
39323
39761
|
}
|
|
39324
39762
|
try {
|
|
39325
|
-
const matrixPath =
|
|
39326
|
-
if (!
|
|
39763
|
+
const matrixPath = join12(cleoSrcRoot, "dispatch", "lib", "capability-matrix.ts");
|
|
39764
|
+
if (!existsSync10(matrixPath)) {
|
|
39327
39765
|
addCheck("Capability matrix", "fail", "Capability matrix missing", [
|
|
39328
39766
|
{
|
|
39329
39767
|
severity: "error",
|
|
@@ -39339,8 +39777,8 @@ var init_detect_drift = __esm({
|
|
|
39339
39777
|
addCheck("Capability matrix", "fail", `Error: ${getErrorMessage(e)}`);
|
|
39340
39778
|
}
|
|
39341
39779
|
try {
|
|
39342
|
-
const schemaPath =
|
|
39343
|
-
if (!
|
|
39780
|
+
const schemaPath = join12(projectRoot, "src", "store", "schema.ts");
|
|
39781
|
+
if (!existsSync10(schemaPath)) {
|
|
39344
39782
|
addCheck("Schema validation", "fail", "Schema definition missing", [
|
|
39345
39783
|
{
|
|
39346
39784
|
severity: "error",
|
|
@@ -39374,10 +39812,10 @@ var init_detect_drift = __esm({
|
|
|
39374
39812
|
addCheck("Schema validation", "fail", `Error: ${getErrorMessage(e)}`);
|
|
39375
39813
|
}
|
|
39376
39814
|
try {
|
|
39377
|
-
const visionPath =
|
|
39378
|
-
const specPath =
|
|
39815
|
+
const visionPath = join12(projectRoot, "docs", "concepts", "CLEO-VISION.md");
|
|
39816
|
+
const specPath = join12(projectRoot, "docs", "specs", "CLEO-PORTABLE-PROJECT-BRAIN-SPEC.md");
|
|
39379
39817
|
const issues = [];
|
|
39380
|
-
if (!
|
|
39818
|
+
if (!existsSync10(visionPath)) {
|
|
39381
39819
|
issues.push({
|
|
39382
39820
|
severity: "error",
|
|
39383
39821
|
category: "vision",
|
|
@@ -39386,7 +39824,7 @@ var init_detect_drift = __esm({
|
|
|
39386
39824
|
recommendation: "Create docs/concepts/CLEO-VISION.md with project vision"
|
|
39387
39825
|
});
|
|
39388
39826
|
}
|
|
39389
|
-
if (!
|
|
39827
|
+
if (!existsSync10(specPath)) {
|
|
39390
39828
|
issues.push({
|
|
39391
39829
|
severity: "error",
|
|
39392
39830
|
category: "spec",
|
|
@@ -39430,8 +39868,8 @@ var init_detect_drift = __esm({
|
|
|
39430
39868
|
addCheck("Canonical identity", "fail", `Error: ${getErrorMessage(e)}`);
|
|
39431
39869
|
}
|
|
39432
39870
|
try {
|
|
39433
|
-
const injectionPath =
|
|
39434
|
-
if (!
|
|
39871
|
+
const injectionPath = join12(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
|
|
39872
|
+
if (!existsSync10(injectionPath)) {
|
|
39435
39873
|
addCheck("Agent injection", "fail", "Agent injection template missing", [
|
|
39436
39874
|
{
|
|
39437
39875
|
severity: "error",
|
|
@@ -39460,8 +39898,8 @@ var init_detect_drift = __esm({
|
|
|
39460
39898
|
addCheck("Agent injection", "fail", `Error: ${getErrorMessage(e)}`);
|
|
39461
39899
|
}
|
|
39462
39900
|
try {
|
|
39463
|
-
const exitCodesPath =
|
|
39464
|
-
if (!
|
|
39901
|
+
const exitCodesPath = join12(cleoSrcRoot, "dispatch", "lib", "exit-codes.ts");
|
|
39902
|
+
if (!existsSync10(exitCodesPath)) {
|
|
39465
39903
|
addCheck("Exit codes", "fail", "Exit codes definition missing", [
|
|
39466
39904
|
{
|
|
39467
39905
|
severity: "error",
|
|
@@ -39635,7 +40073,7 @@ __export(docs_exports, {
|
|
|
39635
40073
|
docsCommand: () => docsCommand
|
|
39636
40074
|
});
|
|
39637
40075
|
import { mkdir, readdir, readFile as readFile2, writeFile } from "node:fs/promises";
|
|
39638
|
-
import { dirname as dirname6, isAbsolute as isAbsolute2, join as
|
|
40076
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join13, resolve as resolve4 } from "node:path";
|
|
39639
40077
|
import {
|
|
39640
40078
|
buildDocsGraph,
|
|
39641
40079
|
CleoError as CleoError3,
|
|
@@ -39651,7 +40089,7 @@ import {
|
|
|
39651
40089
|
searchDocs as searchDocs2
|
|
39652
40090
|
} from "@cleocode/core/internal";
|
|
39653
40091
|
async function getScriptNames(projectRoot) {
|
|
39654
|
-
const scriptsDir =
|
|
40092
|
+
const scriptsDir = join13(projectRoot, "scripts");
|
|
39655
40093
|
try {
|
|
39656
40094
|
const files = await readdir(scriptsDir);
|
|
39657
40095
|
return files.filter((f) => f.endsWith(".sh")).map((f) => f.replace(".sh", "")).sort();
|
|
@@ -39660,7 +40098,7 @@ async function getScriptNames(projectRoot) {
|
|
|
39660
40098
|
}
|
|
39661
40099
|
}
|
|
39662
40100
|
async function getIndexedCommands(projectRoot) {
|
|
39663
|
-
const indexPath =
|
|
40101
|
+
const indexPath = join13(projectRoot, "docs", "commands", "COMMANDS-INDEX.json");
|
|
39664
40102
|
const index = await readJson(indexPath);
|
|
39665
40103
|
if (!index) return [];
|
|
39666
40104
|
return index.commands.map((c) => c.name).sort();
|
|
@@ -39693,7 +40131,7 @@ async function runGapCheck(_projectRoot, filterId) {
|
|
|
39693
40131
|
const reviewFiles = files.filter((f) => f.endsWith(".md"));
|
|
39694
40132
|
for (const file of reviewFiles) {
|
|
39695
40133
|
if (filterId && !file.includes(filterId)) continue;
|
|
39696
|
-
const filePath =
|
|
40134
|
+
const filePath = join13(reviewDir, file);
|
|
39697
40135
|
const content = await readFile2(filePath, "utf-8");
|
|
39698
40136
|
const taskMatch = file.match(/^(T\d+)/);
|
|
39699
40137
|
const taskId = taskMatch ? taskMatch[1] : "UNKNOWN";
|
|
@@ -40107,7 +40545,7 @@ var init_docs3 = __esm({
|
|
|
40107
40545
|
const fmt = args.format ?? "mermaid";
|
|
40108
40546
|
try {
|
|
40109
40547
|
const result = await buildDocsGraph({ ownerId: String(args.for), projectRoot });
|
|
40110
|
-
let
|
|
40548
|
+
let output2;
|
|
40111
40549
|
if (fmt === "dot") {
|
|
40112
40550
|
const dotLines = ["digraph docs {"];
|
|
40113
40551
|
for (const node of result.nodes) {
|
|
@@ -40117,9 +40555,9 @@ var init_docs3 = __esm({
|
|
|
40117
40555
|
dotLines.push(` "${edge.source}" -> "${edge.target}" [label="${edge.relation}"];`);
|
|
40118
40556
|
}
|
|
40119
40557
|
dotLines.push("}");
|
|
40120
|
-
|
|
40558
|
+
output2 = dotLines.join("\n");
|
|
40121
40559
|
} else if (fmt === "json") {
|
|
40122
|
-
|
|
40560
|
+
output2 = JSON.stringify(result, null, 2);
|
|
40123
40561
|
} else {
|
|
40124
40562
|
const lines = ["graph LR"];
|
|
40125
40563
|
for (const edge of result.edges) {
|
|
@@ -40130,16 +40568,16 @@ var init_docs3 = __esm({
|
|
|
40130
40568
|
lines.push(` ${node.id}["${node.label}"]`);
|
|
40131
40569
|
}
|
|
40132
40570
|
}
|
|
40133
|
-
|
|
40571
|
+
output2 = lines.join("\n");
|
|
40134
40572
|
}
|
|
40135
40573
|
if (typeof args.out === "string" && args.out.length > 0) {
|
|
40136
40574
|
const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
|
|
40137
40575
|
await mkdir(dirname6(outPath), { recursive: true });
|
|
40138
|
-
await writeFile(outPath,
|
|
40576
|
+
await writeFile(outPath, output2, "utf8");
|
|
40139
40577
|
humanInfo(`Wrote graph to ${outPath}`);
|
|
40140
40578
|
}
|
|
40141
40579
|
cliOutput(
|
|
40142
|
-
{ format: fmt, nodeCount: result.nodes.length, edgeCount: result.edges.length, output },
|
|
40580
|
+
{ format: fmt, nodeCount: result.nodes.length, edgeCount: result.edges.length, output: output2 },
|
|
40143
40581
|
{ command: "docs graph", operation: "docs.graph" }
|
|
40144
40582
|
);
|
|
40145
40583
|
} catch (err) {
|
|
@@ -40659,8 +41097,8 @@ __export(migrate_agents_v2_exports, {
|
|
|
40659
41097
|
walkAgentsDir: () => walkAgentsDir
|
|
40660
41098
|
});
|
|
40661
41099
|
import { createHash as createHash2 } from "node:crypto";
|
|
40662
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
40663
|
-
import { join as
|
|
41100
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync11, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync12 } from "node:fs";
|
|
41101
|
+
import { join as join14 } from "node:path";
|
|
40664
41102
|
import { getProjectRoot as getProjectRoot23, installAgentFromCant } from "@cleocode/core/internal";
|
|
40665
41103
|
import { openCleoDb } from "@cleocode/core/store/open-cleo-db";
|
|
40666
41104
|
function sha256Hex(bytes) {
|
|
@@ -40680,15 +41118,15 @@ function extractAgentName(source) {
|
|
|
40680
41118
|
return headerMatch[1] ?? null;
|
|
40681
41119
|
}
|
|
40682
41120
|
function appendAuditLog(projectRoot, entry) {
|
|
40683
|
-
const auditPath =
|
|
40684
|
-
const auditDir =
|
|
40685
|
-
if (!
|
|
41121
|
+
const auditPath = join14(projectRoot, AUDIT_LOG_RELATIVE);
|
|
41122
|
+
const auditDir = join14(auditPath, "..");
|
|
41123
|
+
if (!existsSync11(auditDir)) {
|
|
40686
41124
|
mkdirSync3(auditDir, { recursive: true });
|
|
40687
41125
|
}
|
|
40688
41126
|
appendFileSync2(auditPath, JSON.stringify(entry) + "\n", "utf8");
|
|
40689
41127
|
}
|
|
40690
41128
|
function walkAgentsDir(db, scanDir, projectRoot, summary, verbose) {
|
|
40691
|
-
if (!
|
|
41129
|
+
if (!existsSync11(scanDir)) return;
|
|
40692
41130
|
let files;
|
|
40693
41131
|
try {
|
|
40694
41132
|
files = readdirSync2(scanDir).filter((f) => f.endsWith(".cant"));
|
|
@@ -40699,12 +41137,12 @@ function walkAgentsDir(db, scanDir, projectRoot, summary, verbose) {
|
|
|
40699
41137
|
return;
|
|
40700
41138
|
}
|
|
40701
41139
|
for (const filename of files) {
|
|
40702
|
-
const cantPath =
|
|
41140
|
+
const cantPath = join14(scanDir, filename);
|
|
40703
41141
|
const relPath = cantPath.replace(`${projectRoot}/`, "");
|
|
40704
41142
|
let sourceBytes;
|
|
40705
41143
|
let sourceText;
|
|
40706
41144
|
try {
|
|
40707
|
-
sourceBytes =
|
|
41145
|
+
sourceBytes = readFileSync12(cantPath);
|
|
40708
41146
|
sourceText = sourceBytes.toString("utf8");
|
|
40709
41147
|
} catch (err) {
|
|
40710
41148
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -40796,9 +41234,9 @@ async function runMigrateAgentsV2(projectRoot, verbose = true) {
|
|
|
40796
41234
|
const { db: _sdDb } = await openCleoDb("signaldock");
|
|
40797
41235
|
const db = _sdDb;
|
|
40798
41236
|
try {
|
|
40799
|
-
const canonicalDir =
|
|
41237
|
+
const canonicalDir = join14(projectRoot, ".cleo", "cant", "agents");
|
|
40800
41238
|
walkAgentsDir(db, canonicalDir, projectRoot, summary, verbose);
|
|
40801
|
-
const legacyDir =
|
|
41239
|
+
const legacyDir = join14(projectRoot, ".cleo", "agents");
|
|
40802
41240
|
walkAgentsDir(db, legacyDir, projectRoot, summary, verbose);
|
|
40803
41241
|
} finally {
|
|
40804
41242
|
db.close();
|
|
@@ -40806,11 +41244,11 @@ async function runMigrateAgentsV2(projectRoot, verbose = true) {
|
|
|
40806
41244
|
return summary;
|
|
40807
41245
|
}
|
|
40808
41246
|
function readMigrationConflicts(projectRoot) {
|
|
40809
|
-
const auditPath =
|
|
40810
|
-
if (!
|
|
41247
|
+
const auditPath = join14(projectRoot, AUDIT_LOG_RELATIVE);
|
|
41248
|
+
if (!existsSync11(auditPath)) return [];
|
|
40811
41249
|
let raw;
|
|
40812
41250
|
try {
|
|
40813
|
-
raw =
|
|
41251
|
+
raw = readFileSync12(auditPath, "utf8");
|
|
40814
41252
|
} catch {
|
|
40815
41253
|
return [];
|
|
40816
41254
|
}
|
|
@@ -40890,8 +41328,8 @@ var doctor_exports = {};
|
|
|
40890
41328
|
__export(doctor_exports, {
|
|
40891
41329
|
doctorCommand: () => doctorCommand2
|
|
40892
41330
|
});
|
|
40893
|
-
import { mkdirSync as mkdirSync4, writeFileSync as
|
|
40894
|
-
import { join as
|
|
41331
|
+
import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
41332
|
+
import { join as join15 } from "node:path";
|
|
40895
41333
|
import { getProjectRoot as getProjectRoot24, quarantineRogueCleoDir, scanRogueCleoDirs } from "@cleocode/core/internal";
|
|
40896
41334
|
async function scanTestFixturesInProd(projectRoot) {
|
|
40897
41335
|
const { getDb: getDb3, getNativeDb } = await import("@cleocode/core/internal");
|
|
@@ -40926,16 +41364,16 @@ async function scanTestFixturesInProd(projectRoot) {
|
|
|
40926
41364
|
}
|
|
40927
41365
|
async function quarantineTestFixtures(projectRoot, matches) {
|
|
40928
41366
|
if (matches.length === 0) return 0;
|
|
40929
|
-
const cleoDir =
|
|
40930
|
-
const quarantineDir =
|
|
41367
|
+
const cleoDir = join15(projectRoot, ".cleo");
|
|
41368
|
+
const quarantineDir = join15(
|
|
40931
41369
|
cleoDir,
|
|
40932
41370
|
"quarantine",
|
|
40933
41371
|
`fixture-scan-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`
|
|
40934
41372
|
);
|
|
40935
41373
|
mkdirSync4(quarantineDir, { recursive: true });
|
|
40936
41374
|
const manifest = matches.map((m) => ({ ...m, quarantinedAt: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
40937
|
-
|
|
40938
|
-
|
|
41375
|
+
writeFileSync4(
|
|
41376
|
+
join15(quarantineDir, "manifest.jsonl"),
|
|
40939
41377
|
manifest.map((m) => JSON.stringify(m)).join("\n") + "\n"
|
|
40940
41378
|
);
|
|
40941
41379
|
const { getNativeDb } = await import("@cleocode/core/internal");
|
|
@@ -41388,7 +41826,7 @@ __export(event_exports, {
|
|
|
41388
41826
|
orchestratorCommand: () => orchestratorCommand
|
|
41389
41827
|
});
|
|
41390
41828
|
import { readdir as readdir2 } from "node:fs/promises";
|
|
41391
|
-
import { join as
|
|
41829
|
+
import { join as join16 } from "node:path";
|
|
41392
41830
|
import { cwd as processCwd } from "node:process";
|
|
41393
41831
|
import { appendEvent } from "@cleocode/core/events/event-bus.js";
|
|
41394
41832
|
function resolveProjectRoot3(arg) {
|
|
@@ -41511,7 +41949,7 @@ var init_event = __esm({
|
|
|
41511
41949
|
const agentIdFilter = args.agent;
|
|
41512
41950
|
const showAll = args.all === true;
|
|
41513
41951
|
const lines = parseInt(args.lines ?? "20", 10);
|
|
41514
|
-
const eventsDir =
|
|
41952
|
+
const eventsDir = join16(projectRoot, ".cleo", "agent-events");
|
|
41515
41953
|
try {
|
|
41516
41954
|
let files = [];
|
|
41517
41955
|
try {
|
|
@@ -41548,8 +41986,8 @@ var init_event = __esm({
|
|
|
41548
41986
|
}
|
|
41549
41987
|
for (const file of filesToTail) {
|
|
41550
41988
|
const agentId = file.replace(".jsonl", "");
|
|
41551
|
-
const { readFileSync:
|
|
41552
|
-
const content =
|
|
41989
|
+
const { readFileSync: readFileSync18 } = await import("node:fs");
|
|
41990
|
+
const content = readFileSync18(join16(eventsDir, file), "utf-8");
|
|
41553
41991
|
const eventLines = content.trim().split("\n").filter(Boolean);
|
|
41554
41992
|
const tail = eventLines.slice(-lines);
|
|
41555
41993
|
if (jsonMode) {
|
|
@@ -41619,7 +42057,7 @@ var init_event = __esm({
|
|
|
41619
42057
|
const epicFilter = args.epic;
|
|
41620
42058
|
const follow = args.follow === true;
|
|
41621
42059
|
const lines = parseInt(args.lines ?? "50", 10);
|
|
41622
|
-
const eventsDir =
|
|
42060
|
+
const eventsDir = join16(projectRoot, ".cleo", "agent-events");
|
|
41623
42061
|
let files = [];
|
|
41624
42062
|
try {
|
|
41625
42063
|
const entries = await readdir2(eventsDir);
|
|
@@ -41644,8 +42082,8 @@ var init_event = __esm({
|
|
|
41644
42082
|
const printAgentLog = async (file) => {
|
|
41645
42083
|
const agentId = file.replace(".jsonl", "");
|
|
41646
42084
|
try {
|
|
41647
|
-
const { readFileSync:
|
|
41648
|
-
const content =
|
|
42085
|
+
const { readFileSync: readFileSync18 } = await import("node:fs");
|
|
42086
|
+
const content = readFileSync18(join16(eventsDir, file), "utf-8");
|
|
41649
42087
|
const eventLines = content.trim().split("\n").filter(Boolean);
|
|
41650
42088
|
const tail = eventLines.slice(-lines);
|
|
41651
42089
|
if (jsonMode) {
|
|
@@ -42020,7 +42458,7 @@ __export(gc_exports, {
|
|
|
42020
42458
|
gcCommand: () => gcCommand
|
|
42021
42459
|
});
|
|
42022
42460
|
import { homedir as homedir5, tmpdir } from "node:os";
|
|
42023
|
-
import { join as
|
|
42461
|
+
import { join as join17 } from "node:path";
|
|
42024
42462
|
import { pruneOrphanTempDirs, pruneOrphanWorktrees } from "@cleocode/core/gc/cleanup.js";
|
|
42025
42463
|
import { runGC } from "@cleocode/core/gc/runner.js";
|
|
42026
42464
|
import { readGCState } from "@cleocode/core/gc/state.js";
|
|
@@ -42059,7 +42497,7 @@ var init_gc = __esm({
|
|
|
42059
42497
|
}
|
|
42060
42498
|
},
|
|
42061
42499
|
async run({ args }) {
|
|
42062
|
-
const cleoDir = args["cleo-dir"] ??
|
|
42500
|
+
const cleoDir = args["cleo-dir"] ?? join17(homedir5(), ".cleo");
|
|
42063
42501
|
const dryRun = args["dry-run"];
|
|
42064
42502
|
try {
|
|
42065
42503
|
const gcResult = await runGC({ cleoDir, dryRun });
|
|
@@ -42101,8 +42539,8 @@ var init_gc = __esm({
|
|
|
42101
42539
|
}
|
|
42102
42540
|
},
|
|
42103
42541
|
async run({ args }) {
|
|
42104
|
-
const cleoDir = args["cleo-dir"] ??
|
|
42105
|
-
const statePath =
|
|
42542
|
+
const cleoDir = args["cleo-dir"] ?? join17(homedir5(), ".cleo");
|
|
42543
|
+
const statePath = join17(cleoDir, "gc-state.json");
|
|
42106
42544
|
try {
|
|
42107
42545
|
const state = await readGCState(statePath);
|
|
42108
42546
|
const diskStr = state.lastDiskUsedPct !== null ? `${state.lastDiskUsedPct.toFixed(1)}%` : "unknown";
|
|
@@ -42155,8 +42593,8 @@ var init_gc = __esm({
|
|
|
42155
42593
|
}
|
|
42156
42594
|
},
|
|
42157
42595
|
async run({ args }) {
|
|
42158
|
-
const xdgData = process.env["XDG_DATA_HOME"] ??
|
|
42159
|
-
const worktreesRoot = args["worktrees-root"] ??
|
|
42596
|
+
const xdgData = process.env["XDG_DATA_HOME"] ?? join17(homedir5(), ".local", "share");
|
|
42597
|
+
const worktreesRoot = args["worktrees-root"] ?? join17(xdgData, "cleo", "worktrees");
|
|
42160
42598
|
const projectHash = args["project-hash"];
|
|
42161
42599
|
const dryRun = args["dry-run"];
|
|
42162
42600
|
const preserveRaw = args["preserve-tasks"];
|
|
@@ -42266,13 +42704,13 @@ __export(generate_changelog_exports, {
|
|
|
42266
42704
|
generateChangelogCommand: () => generateChangelogCommand
|
|
42267
42705
|
});
|
|
42268
42706
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
42269
|
-
import { existsSync as
|
|
42270
|
-
import { dirname as dirname7, join as
|
|
42707
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync5, readFileSync as readFileSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
42708
|
+
import { dirname as dirname7, join as join18 } from "node:path";
|
|
42271
42709
|
import { CleoError as CleoError4, formatError as formatError6, getConfigPath, getProjectRoot as getProjectRoot25 } from "@cleocode/core";
|
|
42272
42710
|
function getChangelogSource(cwd) {
|
|
42273
42711
|
const configPath = getConfigPath(cwd);
|
|
42274
42712
|
try {
|
|
42275
|
-
const config = JSON.parse(
|
|
42713
|
+
const config = JSON.parse(readFileSync13(configPath, "utf-8"));
|
|
42276
42714
|
return config?.release?.changelog?.source ?? "CHANGELOG.md";
|
|
42277
42715
|
} catch {
|
|
42278
42716
|
return "CHANGELOG.md";
|
|
@@ -42281,7 +42719,7 @@ function getChangelogSource(cwd) {
|
|
|
42281
42719
|
function getEnabledPlatforms(cwd) {
|
|
42282
42720
|
const configPath = getConfigPath(cwd);
|
|
42283
42721
|
try {
|
|
42284
|
-
const config = JSON.parse(
|
|
42722
|
+
const config = JSON.parse(readFileSync13(configPath, "utf-8"));
|
|
42285
42723
|
const outputs = config?.release?.changelog?.outputs ?? [];
|
|
42286
42724
|
return outputs.filter((o) => o.enabled);
|
|
42287
42725
|
} catch {
|
|
@@ -42432,11 +42870,11 @@ var init_generate_changelog = __esm({
|
|
|
42432
42870
|
const targetPlatform = args.platform;
|
|
42433
42871
|
const dryRun = args["dry-run"] === true;
|
|
42434
42872
|
const sourceFile = getChangelogSource();
|
|
42435
|
-
const sourcePath =
|
|
42436
|
-
if (!
|
|
42873
|
+
const sourcePath = join18(getProjectRoot25(), sourceFile);
|
|
42874
|
+
if (!existsSync12(sourcePath)) {
|
|
42437
42875
|
throw new CleoError4(4 /* NOT_FOUND */, `Changelog source not found: ${sourcePath}`);
|
|
42438
42876
|
}
|
|
42439
|
-
const sourceContent =
|
|
42877
|
+
const sourceContent = readFileSync13(sourcePath, "utf-8");
|
|
42440
42878
|
const repoSlug = getGitHubRepoSlug();
|
|
42441
42879
|
const results = [];
|
|
42442
42880
|
if (targetPlatform) {
|
|
@@ -42445,9 +42883,9 @@ var init_generate_changelog = __esm({
|
|
|
42445
42883
|
const outputPath = platformConfig?.path ?? getDefaultOutputPath(targetPlatform);
|
|
42446
42884
|
const content = generateForPlatform(targetPlatform, sourceContent, repoSlug, limit);
|
|
42447
42885
|
if (!dryRun) {
|
|
42448
|
-
const fullPath =
|
|
42886
|
+
const fullPath = join18(getProjectRoot25(), outputPath);
|
|
42449
42887
|
mkdirSync5(dirname7(fullPath), { recursive: true });
|
|
42450
|
-
|
|
42888
|
+
writeFileSync5(fullPath, content, "utf-8");
|
|
42451
42889
|
}
|
|
42452
42890
|
results.push({ platform: targetPlatform, path: outputPath, written: !dryRun });
|
|
42453
42891
|
} else {
|
|
@@ -42466,9 +42904,9 @@ var init_generate_changelog = __esm({
|
|
|
42466
42904
|
limit
|
|
42467
42905
|
);
|
|
42468
42906
|
if (!dryRun) {
|
|
42469
|
-
const fullPath =
|
|
42907
|
+
const fullPath = join18(getProjectRoot25(), platformConfig.path);
|
|
42470
42908
|
mkdirSync5(dirname7(fullPath), { recursive: true });
|
|
42471
|
-
|
|
42909
|
+
writeFileSync5(fullPath, content, "utf-8");
|
|
42472
42910
|
}
|
|
42473
42911
|
results.push({
|
|
42474
42912
|
platform: platformConfig.platform,
|
|
@@ -43605,19 +44043,19 @@ __export(init_exports, {
|
|
|
43605
44043
|
getGitignoreTemplate: () => getGitignoreTemplate,
|
|
43606
44044
|
initCommand: () => initCommand2
|
|
43607
44045
|
});
|
|
43608
|
-
import { existsSync as
|
|
43609
|
-
import { join as
|
|
44046
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14 } from "node:fs";
|
|
44047
|
+
import { join as join19 } from "node:path";
|
|
43610
44048
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
43611
44049
|
import { CleoError as CleoError5, formatError as formatError7, initProject as initProject2 } from "@cleocode/core";
|
|
43612
44050
|
function getGitignoreTemplate() {
|
|
43613
44051
|
try {
|
|
43614
44052
|
const thisFile = fileURLToPath4(import.meta.url);
|
|
43615
|
-
const packageRoot =
|
|
43616
|
-
const localTemplatePath =
|
|
43617
|
-
const monorepoTemplatePath =
|
|
43618
|
-
const templatePath =
|
|
43619
|
-
if (
|
|
43620
|
-
return
|
|
44053
|
+
const packageRoot = join19(thisFile, "..", "..", "..", "..");
|
|
44054
|
+
const localTemplatePath = join19(packageRoot, "templates", "cleo-gitignore");
|
|
44055
|
+
const monorepoTemplatePath = join19(packageRoot, "..", "..", "templates", "cleo-gitignore");
|
|
44056
|
+
const templatePath = existsSync13(localTemplatePath) ? localTemplatePath : monorepoTemplatePath;
|
|
44057
|
+
if (existsSync13(templatePath)) {
|
|
44058
|
+
return readFileSync14(templatePath, "utf-8");
|
|
43621
44059
|
}
|
|
43622
44060
|
} catch {
|
|
43623
44061
|
}
|
|
@@ -44446,7 +44884,7 @@ __export(list_exports, {
|
|
|
44446
44884
|
});
|
|
44447
44885
|
import { createPage as createPage2 } from "@cleocode/core";
|
|
44448
44886
|
var listArgs, listCommand9;
|
|
44449
|
-
var
|
|
44887
|
+
var init_list2 = __esm({
|
|
44450
44888
|
"packages/cleo/src/cli/commands/list.ts"() {
|
|
44451
44889
|
"use strict";
|
|
44452
44890
|
init_src2();
|
|
@@ -46080,9 +46518,9 @@ __export(memory_exports, {
|
|
|
46080
46518
|
memoryCommand: () => memoryCommand
|
|
46081
46519
|
});
|
|
46082
46520
|
import { createHash as createHash3 } from "node:crypto";
|
|
46083
|
-
import { existsSync as
|
|
46521
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync6, readdirSync as readdirSync3, readFileSync as readFileSync15, writeFileSync as writeFileSync6 } from "node:fs";
|
|
46084
46522
|
import { homedir as homedir6 } from "node:os";
|
|
46085
|
-
import { join as
|
|
46523
|
+
import { join as join20 } from "node:path";
|
|
46086
46524
|
import {
|
|
46087
46525
|
getBrainDb as getBrainDb2,
|
|
46088
46526
|
getBrainNativeDb as getBrainNativeDb3,
|
|
@@ -46123,8 +46561,8 @@ ${body}`).digest("hex").slice(0, 16);
|
|
|
46123
46561
|
}
|
|
46124
46562
|
function loadImportHashes(stateFile) {
|
|
46125
46563
|
try {
|
|
46126
|
-
if (!
|
|
46127
|
-
const raw =
|
|
46564
|
+
if (!existsSync14(stateFile)) return /* @__PURE__ */ new Set();
|
|
46565
|
+
const raw = readFileSync15(stateFile, "utf-8");
|
|
46128
46566
|
const parsed = JSON.parse(raw);
|
|
46129
46567
|
return new Set(parsed.hashes);
|
|
46130
46568
|
} catch {
|
|
@@ -46133,8 +46571,8 @@ function loadImportHashes(stateFile) {
|
|
|
46133
46571
|
}
|
|
46134
46572
|
function saveImportHashes(stateFile, hashes) {
|
|
46135
46573
|
const dir = stateFile.slice(0, stateFile.lastIndexOf("/"));
|
|
46136
|
-
if (!
|
|
46137
|
-
|
|
46574
|
+
if (!existsSync14(dir)) mkdirSync6(dir, { recursive: true });
|
|
46575
|
+
writeFileSync6(stateFile, JSON.stringify({ hashes: [...hashes] }, null, 2), "utf-8");
|
|
46138
46576
|
}
|
|
46139
46577
|
function makeMemorySubcommand(opts) {
|
|
46140
46578
|
const mergedArgs = {
|
|
@@ -47245,16 +47683,16 @@ var init_memory3 = __esm({
|
|
|
47245
47683
|
}
|
|
47246
47684
|
},
|
|
47247
47685
|
async run({ args }) {
|
|
47248
|
-
const sourceDir = args.from ??
|
|
47686
|
+
const sourceDir = args.from ?? join20(homedir6(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
|
|
47249
47687
|
const isDryRun = !!args["dry-run"];
|
|
47250
47688
|
const projectRoot = getProjectRoot27();
|
|
47251
|
-
const stateFile =
|
|
47252
|
-
if (!
|
|
47689
|
+
const stateFile = join20(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
|
|
47690
|
+
if (!existsSync14(sourceDir)) {
|
|
47253
47691
|
cliError(`Source directory not found: ${sourceDir}`, "E_NOT_FOUND", { name: "E_NOT_FOUND" });
|
|
47254
47692
|
process.exit(1);
|
|
47255
47693
|
return;
|
|
47256
47694
|
}
|
|
47257
|
-
const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) =>
|
|
47695
|
+
const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) => join20(sourceDir, f));
|
|
47258
47696
|
const importedHashes = isDryRun ? /* @__PURE__ */ new Set() : loadImportHashes(stateFile);
|
|
47259
47697
|
const stats = { total: files.length, imported: 0, skipped: 0, errors: 0 };
|
|
47260
47698
|
const importedEntries = [];
|
|
@@ -47263,7 +47701,7 @@ var init_memory3 = __esm({
|
|
|
47263
47701
|
for (const filePath of files) {
|
|
47264
47702
|
const fileName = filePath.split("/").pop() ?? filePath;
|
|
47265
47703
|
try {
|
|
47266
|
-
const raw =
|
|
47704
|
+
const raw = readFileSync15(filePath, "utf-8");
|
|
47267
47705
|
if (!raw.trim()) {
|
|
47268
47706
|
stats.skipped++;
|
|
47269
47707
|
skippedEntries.push({ file: fileName, reason: "empty file" });
|
|
@@ -49649,8 +50087,8 @@ var init_nexus4 = __esm({
|
|
|
49649
50087
|
return;
|
|
49650
50088
|
}
|
|
49651
50089
|
if (!skipPrompt) {
|
|
49652
|
-
const { createInterface:
|
|
49653
|
-
const rl =
|
|
50090
|
+
const { createInterface: createInterface4 } = await import("node:readline");
|
|
50091
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
49654
50092
|
const confirmed = await new Promise((resolve5) => {
|
|
49655
50093
|
rl.question(
|
|
49656
50094
|
`
|
|
@@ -49813,9 +50251,9 @@ var init_nexus4 = __esm({
|
|
|
49813
50251
|
}
|
|
49814
50252
|
const nodes = projectFilter ? allNodes.filter((n) => n["projectId"] === projectFilter) : allNodes;
|
|
49815
50253
|
const relations = projectFilter ? allRelations.filter((r) => r["projectId"] === projectFilter) : allRelations;
|
|
49816
|
-
let
|
|
50254
|
+
let output2 = "";
|
|
49817
50255
|
if (format === "json") {
|
|
49818
|
-
|
|
50256
|
+
output2 = JSON.stringify(
|
|
49819
50257
|
{
|
|
49820
50258
|
nodes: nodes.map((n) => ({
|
|
49821
50259
|
id: n["id"],
|
|
@@ -49842,7 +50280,7 @@ var init_nexus4 = __esm({
|
|
|
49842
50280
|
2
|
|
49843
50281
|
);
|
|
49844
50282
|
} else if (format === "gexf") {
|
|
49845
|
-
|
|
50283
|
+
output2 = generateGexf(nodes, relations);
|
|
49846
50284
|
} else {
|
|
49847
50285
|
cliError(
|
|
49848
50286
|
`Unknown format '${format}'. Supported: gexf, json`,
|
|
@@ -49854,8 +50292,8 @@ var init_nexus4 = __esm({
|
|
|
49854
50292
|
return;
|
|
49855
50293
|
}
|
|
49856
50294
|
if (outputFile) {
|
|
49857
|
-
const { writeFileSync:
|
|
49858
|
-
|
|
50295
|
+
const { writeFileSync: writeFileSync7 } = await import("node:fs");
|
|
50296
|
+
writeFileSync7(outputFile, output2, "utf-8");
|
|
49859
50297
|
const durationMs = Date.now() - startTime;
|
|
49860
50298
|
cliOutput(
|
|
49861
50299
|
{ outputFile, nodeCount: nodes.length, edgeCount: relations.length },
|
|
@@ -49867,8 +50305,8 @@ var init_nexus4 = __esm({
|
|
|
49867
50305
|
);
|
|
49868
50306
|
humanInfo(`[nexus] Export completed in ${durationMs}ms`);
|
|
49869
50307
|
} else {
|
|
49870
|
-
process.stdout.write(
|
|
49871
|
-
if (!
|
|
50308
|
+
process.stdout.write(output2);
|
|
50309
|
+
if (!output2.endsWith("\n")) process.stdout.write("\n");
|
|
49872
50310
|
}
|
|
49873
50311
|
} catch (err) {
|
|
49874
50312
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -54771,7 +55209,7 @@ __export(revert_exports, {
|
|
|
54771
55209
|
revertCommand: () => revertCommand
|
|
54772
55210
|
});
|
|
54773
55211
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
54774
|
-
import { join as
|
|
55212
|
+
import { join as join21 } from "node:path";
|
|
54775
55213
|
import { cwd as processCwd2 } from "node:process";
|
|
54776
55214
|
import { E_RECEIPT_NOT_FOUND } from "@cleocode/core/sentient/chain-walker.js";
|
|
54777
55215
|
import { SENTIENT_STATE_FILE } from "@cleocode/core/sentient/daemon.js";
|
|
@@ -54824,7 +55262,7 @@ async function loadOwnerAttestation(attestationFilePath) {
|
|
|
54824
55262
|
return obj;
|
|
54825
55263
|
}
|
|
54826
55264
|
async function loadOwnerPubkeys(projectRoot) {
|
|
54827
|
-
const path6 =
|
|
55265
|
+
const path6 = join21(projectRoot, OWNER_PUBKEYS_FILE);
|
|
54828
55266
|
try {
|
|
54829
55267
|
const raw = await readFile3(path6, "utf-8");
|
|
54830
55268
|
const parsed = JSON.parse(raw);
|
|
@@ -54908,7 +55346,7 @@ var init_revert = __esm({
|
|
|
54908
55346
|
if (attestation && allowedPubkeys.size > 0 && !allowedPubkeys.has(attestation.ownerPubkey)) {
|
|
54909
55347
|
emitFailure2(
|
|
54910
55348
|
E_OWNER_ATTESTATION_REQUIRED,
|
|
54911
|
-
`Attestation pubkey "${attestation.ownerPubkey}" is not in the owner allowlist at ${
|
|
55349
|
+
`Attestation pubkey "${attestation.ownerPubkey}" is not in the owner allowlist at ${join21(projectRoot, OWNER_PUBKEYS_FILE)}`,
|
|
54912
55350
|
jsonMode
|
|
54913
55351
|
);
|
|
54914
55352
|
}
|
|
@@ -54961,7 +55399,7 @@ ${lines}`
|
|
|
54961
55399
|
identity,
|
|
54962
55400
|
includeHuman
|
|
54963
55401
|
});
|
|
54964
|
-
const statePath =
|
|
55402
|
+
const statePath = join21(projectRoot, SENTIENT_STATE_FILE);
|
|
54965
55403
|
const state = await readSentientState(statePath);
|
|
54966
55404
|
emitSuccess(
|
|
54967
55405
|
{
|
|
@@ -55343,7 +55781,7 @@ __export(self_update_exports, {
|
|
|
55343
55781
|
});
|
|
55344
55782
|
import { execFile } from "node:child_process";
|
|
55345
55783
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
55346
|
-
import { join as
|
|
55784
|
+
import { join as join22 } from "node:path";
|
|
55347
55785
|
import * as readline2 from "node:readline";
|
|
55348
55786
|
import { promisify } from "node:util";
|
|
55349
55787
|
import {
|
|
@@ -55358,7 +55796,7 @@ import {
|
|
|
55358
55796
|
async function getCurrentVersion() {
|
|
55359
55797
|
const cleoHome = getCleoHome();
|
|
55360
55798
|
try {
|
|
55361
|
-
const content = await readFile4(
|
|
55799
|
+
const content = await readFile4(join22(cleoHome, "VERSION"), "utf-8");
|
|
55362
55800
|
return (content.split("\n")[0] ?? "unknown").trim();
|
|
55363
55801
|
} catch {
|
|
55364
55802
|
return "unknown";
|
|
@@ -55412,7 +55850,7 @@ async function writeRuntimeVersionMetadata(mode, source, version) {
|
|
|
55412
55850
|
];
|
|
55413
55851
|
await import("node:fs/promises").then(
|
|
55414
55852
|
({ writeFile: writeFile3, mkdir: mkdir4 }) => mkdir4(cleoHome, { recursive: true }).then(
|
|
55415
|
-
() => writeFile3(
|
|
55853
|
+
() => writeFile3(join22(cleoHome, "VERSION"), `${lines.join("\n")}
|
|
55416
55854
|
`, "utf-8")
|
|
55417
55855
|
)
|
|
55418
55856
|
);
|
|
@@ -55823,7 +56261,7 @@ var sentient_exports = {};
|
|
|
55823
56261
|
__export(sentient_exports, {
|
|
55824
56262
|
sentientCommand: () => sentientCommand
|
|
55825
56263
|
});
|
|
55826
|
-
import { join as
|
|
56264
|
+
import { join as join23 } from "node:path";
|
|
55827
56265
|
import { cwd as processCwd3 } from "node:process";
|
|
55828
56266
|
import {
|
|
55829
56267
|
getSentientDaemonStatus as getSentientDaemonStatus2,
|
|
@@ -55892,7 +56330,7 @@ var init_sentient3 = __esm({
|
|
|
55892
56330
|
return;
|
|
55893
56331
|
}
|
|
55894
56332
|
if (dryRun) {
|
|
55895
|
-
const statePath2 =
|
|
56333
|
+
const statePath2 = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
55896
56334
|
const outcome = await safeRunTick({ projectRoot, statePath: statePath2, dryRun: true });
|
|
55897
56335
|
emitSuccess2(
|
|
55898
56336
|
{ dryRun: true, outcome },
|
|
@@ -56008,7 +56446,7 @@ Logs: ${logPath}`
|
|
|
56008
56446
|
const jsonMode = args.json === true;
|
|
56009
56447
|
const dryRun = args["dry-run"] === true;
|
|
56010
56448
|
try {
|
|
56011
|
-
const statePath =
|
|
56449
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56012
56450
|
const outcome = await safeRunTick({ projectRoot, statePath, dryRun });
|
|
56013
56451
|
emitSuccess2(
|
|
56014
56452
|
{ outcome, dryRun },
|
|
@@ -56077,7 +56515,7 @@ Logs: ${logPath}`
|
|
|
56077
56515
|
return;
|
|
56078
56516
|
}
|
|
56079
56517
|
await db.update(tasks).set({ status: "pending", updatedAt: now }).where(eq2(tasks.id, id)).run();
|
|
56080
|
-
const statePath =
|
|
56518
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56081
56519
|
const state = await readSentientState2(statePath);
|
|
56082
56520
|
await patchSentientState(statePath, {
|
|
56083
56521
|
tier2Stats: {
|
|
@@ -56129,7 +56567,7 @@ Logs: ${logPath}`
|
|
|
56129
56567
|
return;
|
|
56130
56568
|
}
|
|
56131
56569
|
await db.update(tasks).set({ status: "cancelled", cancellationReason: reason, cancelledAt: now, updatedAt: now }).where(eq2(tasks.id, id)).run();
|
|
56132
|
-
const statePath =
|
|
56570
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56133
56571
|
const state = await readSentientState2(statePath);
|
|
56134
56572
|
await patchSentientState(statePath, {
|
|
56135
56573
|
tier2Stats: {
|
|
@@ -56174,7 +56612,7 @@ Logs: ${logPath}`
|
|
|
56174
56612
|
const projectRoot = resolveProjectRoot6(args.project);
|
|
56175
56613
|
const jsonMode = args.json === true;
|
|
56176
56614
|
try {
|
|
56177
|
-
const statePath =
|
|
56615
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56178
56616
|
const outcome = await safeRunProposeTick({ projectRoot, statePath });
|
|
56179
56617
|
emitSuccess2(
|
|
56180
56618
|
{ outcome },
|
|
@@ -56194,7 +56632,7 @@ Logs: ${logPath}`
|
|
|
56194
56632
|
const projectRoot = resolveProjectRoot6(args.project);
|
|
56195
56633
|
const jsonMode = args.json === true;
|
|
56196
56634
|
try {
|
|
56197
|
-
const statePath =
|
|
56635
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56198
56636
|
const updated = await patchSentientState(statePath, { tier2Enabled: true });
|
|
56199
56637
|
emitSuccess2({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals enabled");
|
|
56200
56638
|
} catch (err) {
|
|
@@ -56213,7 +56651,7 @@ Logs: ${logPath}`
|
|
|
56213
56651
|
const projectRoot = resolveProjectRoot6(args.project);
|
|
56214
56652
|
const jsonMode = args.json === true;
|
|
56215
56653
|
try {
|
|
56216
|
-
const statePath =
|
|
56654
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56217
56655
|
const updated = await patchSentientState(statePath, { tier2Enabled: false });
|
|
56218
56656
|
emitSuccess2({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals disabled");
|
|
56219
56657
|
} catch (err) {
|
|
@@ -56244,7 +56682,7 @@ Logs: ${logPath}`
|
|
|
56244
56682
|
const projectRoot = resolveProjectRoot6(args.project);
|
|
56245
56683
|
const jsonMode = args.json === true;
|
|
56246
56684
|
try {
|
|
56247
|
-
const statePath =
|
|
56685
|
+
const statePath = join23(projectRoot, SENTIENT_STATE_FILE2);
|
|
56248
56686
|
const state = await readSentientState2(statePath);
|
|
56249
56687
|
emitSuccess2(
|
|
56250
56688
|
{
|
|
@@ -56609,9 +57047,9 @@ async function promptOwnerAuthPassword(sessionName) {
|
|
|
56609
57047
|
);
|
|
56610
57048
|
return null;
|
|
56611
57049
|
}
|
|
56612
|
-
const { createInterface:
|
|
57050
|
+
const { createInterface: createInterface4 } = await import("node:readline");
|
|
56613
57051
|
const { deriveOwnerAuthToken } = await import("@cleocode/core/internal");
|
|
56614
|
-
const rl =
|
|
57052
|
+
const rl = createInterface4({
|
|
56615
57053
|
input: process.stdin,
|
|
56616
57054
|
output: process.stderr,
|
|
56617
57055
|
terminal: true
|
|
@@ -57202,6 +57640,231 @@ var init_session4 = __esm({
|
|
|
57202
57640
|
}
|
|
57203
57641
|
});
|
|
57204
57642
|
|
|
57643
|
+
// packages/cleo/src/cli/lib/readline-wizard-io.ts
|
|
57644
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
57645
|
+
import * as readline3 from "node:readline/promises";
|
|
57646
|
+
var ReadlineWizardIO;
|
|
57647
|
+
var init_readline_wizard_io = __esm({
|
|
57648
|
+
"packages/cleo/src/cli/lib/readline-wizard-io.ts"() {
|
|
57649
|
+
"use strict";
|
|
57650
|
+
ReadlineWizardIO = class {
|
|
57651
|
+
rl;
|
|
57652
|
+
/**
|
|
57653
|
+
* Construct a readline interface bound to the supplied streams.
|
|
57654
|
+
*
|
|
57655
|
+
* The defaults (`process.stdin` / `process.stdout`) are correct for
|
|
57656
|
+
* production use; tests inject in-memory streams.
|
|
57657
|
+
*
|
|
57658
|
+
* @param inStream - Input stream; defaults to `process.stdin`.
|
|
57659
|
+
* @param outStream - Output stream; defaults to `process.stdout`.
|
|
57660
|
+
*/
|
|
57661
|
+
constructor(inStream = input, outStream = output) {
|
|
57662
|
+
this.rl = readline3.createInterface({ input: inStream, output: outStream });
|
|
57663
|
+
}
|
|
57664
|
+
/**
|
|
57665
|
+
* Release the underlying readline interface.
|
|
57666
|
+
*
|
|
57667
|
+
* Safe to call multiple times — `readline.Interface.close()` is
|
|
57668
|
+
* idempotent.
|
|
57669
|
+
*/
|
|
57670
|
+
close() {
|
|
57671
|
+
this.rl.close();
|
|
57672
|
+
}
|
|
57673
|
+
async prompt(question) {
|
|
57674
|
+
const answer = await this.rl.question(`${question} `);
|
|
57675
|
+
return answer.trim();
|
|
57676
|
+
}
|
|
57677
|
+
async confirm(question, defaultValue) {
|
|
57678
|
+
const hint = defaultValue === void 0 ? "[y/n]" : defaultValue ? "[Y/n]" : "[y/N]";
|
|
57679
|
+
const raw = (await this.rl.question(`${question} ${hint} `)).trim().toLowerCase();
|
|
57680
|
+
if (raw === "") {
|
|
57681
|
+
if (defaultValue === void 0) {
|
|
57682
|
+
return this.confirm(question, defaultValue);
|
|
57683
|
+
}
|
|
57684
|
+
return defaultValue;
|
|
57685
|
+
}
|
|
57686
|
+
if (raw === "y" || raw === "yes") return true;
|
|
57687
|
+
if (raw === "n" || raw === "no") return false;
|
|
57688
|
+
return this.confirm(question, defaultValue);
|
|
57689
|
+
}
|
|
57690
|
+
async select(question, options) {
|
|
57691
|
+
if (options.length === 0) {
|
|
57692
|
+
throw new Error(`ReadlineWizardIO.select: option list is empty for '${question}'`);
|
|
57693
|
+
}
|
|
57694
|
+
process.stdout.write(`${question}
|
|
57695
|
+
`);
|
|
57696
|
+
options.forEach((opt, idx) => {
|
|
57697
|
+
process.stdout.write(` ${idx + 1}) ${opt}
|
|
57698
|
+
`);
|
|
57699
|
+
});
|
|
57700
|
+
const MAX_RETRIES = 10;
|
|
57701
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
57702
|
+
const raw = (await this.rl.question(`Choose [1-${options.length}]: `)).trim();
|
|
57703
|
+
if (/^\d+$/.test(raw)) {
|
|
57704
|
+
const idx = Number.parseInt(raw, 10) - 1;
|
|
57705
|
+
if (idx >= 0 && idx < options.length) return options[idx];
|
|
57706
|
+
}
|
|
57707
|
+
if (options.includes(raw)) return raw;
|
|
57708
|
+
process.stdout.write(`Invalid choice '${raw}'. Try again.
|
|
57709
|
+
`);
|
|
57710
|
+
}
|
|
57711
|
+
throw new Error(
|
|
57712
|
+
`ReadlineWizardIO.select: gave up after ${MAX_RETRIES} invalid responses for '${question}'`
|
|
57713
|
+
);
|
|
57714
|
+
}
|
|
57715
|
+
info(message) {
|
|
57716
|
+
process.stdout.write(`${message}
|
|
57717
|
+
`);
|
|
57718
|
+
}
|
|
57719
|
+
warn(message) {
|
|
57720
|
+
process.stderr.write(`${message}
|
|
57721
|
+
`);
|
|
57722
|
+
}
|
|
57723
|
+
error(message) {
|
|
57724
|
+
process.stderr.write(`${message}
|
|
57725
|
+
`);
|
|
57726
|
+
}
|
|
57727
|
+
};
|
|
57728
|
+
}
|
|
57729
|
+
});
|
|
57730
|
+
|
|
57731
|
+
// packages/cleo/src/cli/commands/setup.ts
|
|
57732
|
+
var setup_exports = {};
|
|
57733
|
+
__export(setup_exports, {
|
|
57734
|
+
buildWizardOptions: () => buildWizardOptions,
|
|
57735
|
+
runSetup: () => runSetup,
|
|
57736
|
+
setupCommand: () => setupCommand2
|
|
57737
|
+
});
|
|
57738
|
+
import { createDefaultWizardRunner } from "@cleocode/core/setup";
|
|
57739
|
+
function buildWizardOptions(args) {
|
|
57740
|
+
const out = {};
|
|
57741
|
+
if (args["non-interactive"] === true || args["nonInteractive"] === true) {
|
|
57742
|
+
out.nonInteractive = true;
|
|
57743
|
+
}
|
|
57744
|
+
if (typeof args["provider"] === "string" && args["provider"] !== "") {
|
|
57745
|
+
out.provider = args["provider"];
|
|
57746
|
+
}
|
|
57747
|
+
if (typeof args["api-key"] === "string" && args["api-key"] !== "") {
|
|
57748
|
+
out.apiKey = args["api-key"];
|
|
57749
|
+
} else if (typeof args["apiKey"] === "string" && args["apiKey"] !== "") {
|
|
57750
|
+
out.apiKey = args["apiKey"];
|
|
57751
|
+
}
|
|
57752
|
+
if (typeof args["label"] === "string" && args["label"] !== "") {
|
|
57753
|
+
out.label = args["label"];
|
|
57754
|
+
}
|
|
57755
|
+
if (typeof args["agent-name"] === "string" && args["agent-name"] !== "") {
|
|
57756
|
+
out.agentName = args["agent-name"];
|
|
57757
|
+
} else if (typeof args["agentName"] === "string" && args["agentName"] !== "") {
|
|
57758
|
+
out.agentName = args["agentName"];
|
|
57759
|
+
}
|
|
57760
|
+
if (typeof args["strictness"] === "string" && args["strictness"] !== "") {
|
|
57761
|
+
const s = args["strictness"];
|
|
57762
|
+
if (s === "strict" || s === "standard" || s === "minimal") {
|
|
57763
|
+
out.strictness = s;
|
|
57764
|
+
}
|
|
57765
|
+
}
|
|
57766
|
+
if (typeof args["project-root"] === "string" && args["project-root"] !== "") {
|
|
57767
|
+
out.projectRoot = args["project-root"];
|
|
57768
|
+
}
|
|
57769
|
+
return out;
|
|
57770
|
+
}
|
|
57771
|
+
function wrapSingleSection(name, result) {
|
|
57772
|
+
return {
|
|
57773
|
+
sectionsRun: [name],
|
|
57774
|
+
summary: [`${name}: ${result.summary}`]
|
|
57775
|
+
};
|
|
57776
|
+
}
|
|
57777
|
+
function isOk(result) {
|
|
57778
|
+
return !result.summary.some((line) => /:\s*failed:/i.test(line));
|
|
57779
|
+
}
|
|
57780
|
+
async function runSetup(args, io) {
|
|
57781
|
+
const options = buildWizardOptions(args);
|
|
57782
|
+
const runner = createDefaultWizardRunner();
|
|
57783
|
+
const sectionArg = typeof args["section"] === "string" ? args["section"] : null;
|
|
57784
|
+
let runResult;
|
|
57785
|
+
if (sectionArg) {
|
|
57786
|
+
const known = runner.list().map((r) => r.section);
|
|
57787
|
+
if (!known.includes(sectionArg)) {
|
|
57788
|
+
throw new Error(`cleo setup: unknown section '${sectionArg}'. Known: ${known.join(", ")}`);
|
|
57789
|
+
}
|
|
57790
|
+
const single = await runner.runSection(sectionArg, io, options);
|
|
57791
|
+
runResult = wrapSingleSection(sectionArg, single);
|
|
57792
|
+
} else {
|
|
57793
|
+
runResult = await runner.run(io, options);
|
|
57794
|
+
}
|
|
57795
|
+
return {
|
|
57796
|
+
sectionsRun: runResult.sectionsRun,
|
|
57797
|
+
summary: runResult.summary,
|
|
57798
|
+
ok: isOk(runResult)
|
|
57799
|
+
};
|
|
57800
|
+
}
|
|
57801
|
+
var setupCommand2;
|
|
57802
|
+
var init_setup = __esm({
|
|
57803
|
+
"packages/cleo/src/cli/commands/setup.ts"() {
|
|
57804
|
+
"use strict";
|
|
57805
|
+
init_dist();
|
|
57806
|
+
init_readline_wizard_io();
|
|
57807
|
+
init_renderers();
|
|
57808
|
+
setupCommand2 = defineCommand({
|
|
57809
|
+
meta: {
|
|
57810
|
+
name: "setup",
|
|
57811
|
+
description: "Interactive setup wizard \u2014 runs all sections (llm, identity, sentient, project-conventions) in canonical order. Use --section <name> for a single section or --non-interactive with --provider/--api-key to configure LLM without prompts."
|
|
57812
|
+
},
|
|
57813
|
+
args: {
|
|
57814
|
+
section: {
|
|
57815
|
+
type: "string",
|
|
57816
|
+
description: "Run only one named section. Valid: llm | identity | sentient | project-conventions"
|
|
57817
|
+
},
|
|
57818
|
+
"non-interactive": {
|
|
57819
|
+
type: "boolean",
|
|
57820
|
+
description: "Skip prompts. Sections that need extra data short-circuit silently. Pair with --provider and --api-key to configure LLM."
|
|
57821
|
+
},
|
|
57822
|
+
provider: {
|
|
57823
|
+
type: "string",
|
|
57824
|
+
description: "LLM provider id when --non-interactive (anthropic, openai, gemini, openrouter, \u2026)."
|
|
57825
|
+
},
|
|
57826
|
+
"api-key": {
|
|
57827
|
+
type: "string",
|
|
57828
|
+
description: "API key used when --non-interactive --provider is set."
|
|
57829
|
+
},
|
|
57830
|
+
label: {
|
|
57831
|
+
type: "string",
|
|
57832
|
+
description: "Optional credential label override (defaults to 'cli-input')."
|
|
57833
|
+
},
|
|
57834
|
+
"agent-name": {
|
|
57835
|
+
type: "string",
|
|
57836
|
+
description: "Override agent display name for the identity section."
|
|
57837
|
+
},
|
|
57838
|
+
strictness: {
|
|
57839
|
+
type: "string",
|
|
57840
|
+
description: "Project-conventions strictness preset: 'strict' | 'standard' | 'minimal'."
|
|
57841
|
+
},
|
|
57842
|
+
"project-root": {
|
|
57843
|
+
type: "string",
|
|
57844
|
+
description: "Override project root path (defaults to process.cwd())."
|
|
57845
|
+
}
|
|
57846
|
+
},
|
|
57847
|
+
async run({ args }) {
|
|
57848
|
+
const io = new ReadlineWizardIO();
|
|
57849
|
+
let result;
|
|
57850
|
+
try {
|
|
57851
|
+
result = await runSetup(args, io);
|
|
57852
|
+
} finally {
|
|
57853
|
+
io.close();
|
|
57854
|
+
}
|
|
57855
|
+
cliOutput(result, {
|
|
57856
|
+
command: "setup",
|
|
57857
|
+
operation: "setup.run",
|
|
57858
|
+
message: result.ok ? `Setup completed (${result.sectionsRun.length} section(s)).` : `Setup finished with errors (${result.sectionsRun.length} section(s)).`
|
|
57859
|
+
});
|
|
57860
|
+
if (!result.ok) {
|
|
57861
|
+
process.exit(1);
|
|
57862
|
+
}
|
|
57863
|
+
}
|
|
57864
|
+
});
|
|
57865
|
+
}
|
|
57866
|
+
});
|
|
57867
|
+
|
|
57205
57868
|
// packages/cleo/src/cli/commands/show.ts
|
|
57206
57869
|
var show_exports = {};
|
|
57207
57870
|
__export(show_exports, {
|
|
@@ -57802,6 +58465,134 @@ var init_stats = __esm({
|
|
|
57802
58465
|
}
|
|
57803
58466
|
});
|
|
57804
58467
|
|
|
58468
|
+
// packages/cleo/src/cli/commands/status.ts
|
|
58469
|
+
var status_exports = {};
|
|
58470
|
+
__export(status_exports, {
|
|
58471
|
+
statusCommand: () => statusCommand13
|
|
58472
|
+
});
|
|
58473
|
+
import { getCleoStatus } from "@cleocode/core/status";
|
|
58474
|
+
function formatEpoch(epoch) {
|
|
58475
|
+
if (epoch == null) return "";
|
|
58476
|
+
const d = new Date(epoch);
|
|
58477
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
58478
|
+
return d.toISOString().replace("T", " ").slice(0, 19) + "Z";
|
|
58479
|
+
}
|
|
58480
|
+
function renderCredentialLine(c) {
|
|
58481
|
+
const badges = [];
|
|
58482
|
+
if (c.lastStatus === "invalid") badges.push(`${RED}${BOLD}[INVALID]${NC}`);
|
|
58483
|
+
if (c.isExpired === true) badges.push(`${YELLOW}${BOLD}[EXPIRED]${NC}`);
|
|
58484
|
+
const label = c.label ?? "(no label)";
|
|
58485
|
+
const head = `${BOLD}${c.provider}${NC} ${DIM}${label}${NC}`;
|
|
58486
|
+
const meta = [];
|
|
58487
|
+
meta.push(`source=${c.source}`);
|
|
58488
|
+
if (c.authType !== void 0) meta.push(`authType=${c.authType}`);
|
|
58489
|
+
if (c.lastStatus !== void 0) meta.push(`lastStatus=${c.lastStatus}`);
|
|
58490
|
+
if (c.expiresAt != null) meta.push(`expiresAt=${formatEpoch(c.expiresAt)}`);
|
|
58491
|
+
const metaLine = `${DIM}${meta.join(" \xB7 ")}${NC}`;
|
|
58492
|
+
const badgeStr = badges.length > 0 ? ` ${badges.join(" ")}` : "";
|
|
58493
|
+
return ` ${head}${badgeStr}
|
|
58494
|
+
${metaLine}`;
|
|
58495
|
+
}
|
|
58496
|
+
function renderStatusHuman(status) {
|
|
58497
|
+
const lines = [];
|
|
58498
|
+
if (status.config.hasSecretsInProjectConfig) {
|
|
58499
|
+
lines.push(`${RED}${BOLD}WARNING: Secrets detected in project config${NC}`);
|
|
58500
|
+
for (const w of status.config.secretsWarnings) {
|
|
58501
|
+
lines.push(` ${RED}${w}${NC}`);
|
|
58502
|
+
}
|
|
58503
|
+
lines.push("");
|
|
58504
|
+
}
|
|
58505
|
+
lines.push(`${BOLD}Identity${NC}`);
|
|
58506
|
+
lines.push(` ${DIM}agentId:${NC} ${status.identity.agentId ?? "(none)"}`);
|
|
58507
|
+
lines.push(` ${DIM}identityFile:${NC} ${status.identity.identityFile ?? "(none)"}`);
|
|
58508
|
+
const loggedInBadge = status.identity.loggedIn ? `${GREEN}yes${NC}` : `${YELLOW}no \u2014 run \`cleo setup\`${NC}`;
|
|
58509
|
+
lines.push(` ${DIM}loggedIn:${NC} ${loggedInBadge}`);
|
|
58510
|
+
lines.push("");
|
|
58511
|
+
lines.push(`${BOLD}Credentials${NC} ${DIM}(${status.credentials.length} entries)${NC}`);
|
|
58512
|
+
if (status.credentials.length === 0) {
|
|
58513
|
+
lines.push(` ${DIM}(no credentials \u2014 run \`cleo auth list\` after \`cleo setup\`)${NC}`);
|
|
58514
|
+
} else {
|
|
58515
|
+
for (const c of status.credentials) {
|
|
58516
|
+
lines.push(renderCredentialLine(c));
|
|
58517
|
+
}
|
|
58518
|
+
}
|
|
58519
|
+
lines.push("");
|
|
58520
|
+
lines.push(`${BOLD}Config${NC}`);
|
|
58521
|
+
lines.push(` ${DIM}globalConfigPath:${NC} ${status.config.globalConfigPath}`);
|
|
58522
|
+
lines.push(` ${DIM}projectConfigPath:${NC} ${status.config.projectConfigPath ?? "(none)"}`);
|
|
58523
|
+
lines.push(` ${DIM}activeConfigPath:${NC} ${status.config.activeConfigPath}`);
|
|
58524
|
+
lines.push("");
|
|
58525
|
+
lines.push(`${BOLD}Session${NC}`);
|
|
58526
|
+
const sessionState = status.session.active ? `${GREEN}active${NC}` : `${DIM}inactive${NC}`;
|
|
58527
|
+
lines.push(` ${DIM}state:${NC} ${sessionState}`);
|
|
58528
|
+
lines.push(` ${DIM}sessionId:${NC} ${status.session.sessionId ?? "(none)"}`);
|
|
58529
|
+
lines.push(` ${DIM}focusedTask:${NC} ${status.session.focusedTask ?? "(none)"}`);
|
|
58530
|
+
lines.push("");
|
|
58531
|
+
lines.push(`${BOLD}Harness${NC}`);
|
|
58532
|
+
lines.push(` ${DIM}active:${NC} ${CYAN}${status.harness.active}${NC}`);
|
|
58533
|
+
lines.push(
|
|
58534
|
+
` ${DIM}healthy:${NC} ${status.harness.healthy ? `${GREEN}yes${NC}` : `${RED}no${NC}`}`
|
|
58535
|
+
);
|
|
58536
|
+
if (status.harness.issues.length > 0) {
|
|
58537
|
+
for (const issue of status.harness.issues) {
|
|
58538
|
+
lines.push(` ${YELLOW}- ${issue}${NC}`);
|
|
58539
|
+
}
|
|
58540
|
+
}
|
|
58541
|
+
lines.push("");
|
|
58542
|
+
lines.push(`${BOLD}Daemon${NC}`);
|
|
58543
|
+
const daemonState = status.daemon.running ? `${GREEN}running${NC}` : `${DIM}stopped${NC}`;
|
|
58544
|
+
lines.push(` ${DIM}state:${NC} ${daemonState}`);
|
|
58545
|
+
lines.push(` ${DIM}pid:${NC} ${status.daemon.pid ?? "(none)"}`);
|
|
58546
|
+
lines.push(
|
|
58547
|
+
` ${DIM}lastTickAt:${NC} ${status.daemon.lastTickAt != null ? formatEpoch(status.daemon.lastTickAt) : "(never)"}`
|
|
58548
|
+
);
|
|
58549
|
+
const killSwitchBadge = status.daemon.killSwitchActive ? `${RED}${BOLD}ACTIVE${NC}` : `${DIM}inactive${NC}`;
|
|
58550
|
+
lines.push(` ${DIM}killSwitchActive:${NC} ${killSwitchBadge}`);
|
|
58551
|
+
return lines.join("\n");
|
|
58552
|
+
}
|
|
58553
|
+
function computeExitCode(status) {
|
|
58554
|
+
const hasInvalid = status.credentials.some((c) => c.lastStatus === "invalid");
|
|
58555
|
+
return hasInvalid ? 1 : 0;
|
|
58556
|
+
}
|
|
58557
|
+
var statusCommand13;
|
|
58558
|
+
var init_status = __esm({
|
|
58559
|
+
"packages/cleo/src/cli/commands/status.ts"() {
|
|
58560
|
+
"use strict";
|
|
58561
|
+
init_dist();
|
|
58562
|
+
init_format_context();
|
|
58563
|
+
init_colors();
|
|
58564
|
+
init_renderers();
|
|
58565
|
+
statusCommand13 = defineCommand({
|
|
58566
|
+
meta: {
|
|
58567
|
+
name: "status",
|
|
58568
|
+
description: "Unified config + credential + session + harness + daemon snapshot. Use --json for the full LAFS envelope (CleoStatus interface). Exits non-zero when any credential is in invalid state."
|
|
58569
|
+
},
|
|
58570
|
+
args: {
|
|
58571
|
+
json: {
|
|
58572
|
+
type: "boolean",
|
|
58573
|
+
description: "Output as JSON envelope (CleoStatus interface)"
|
|
58574
|
+
}
|
|
58575
|
+
},
|
|
58576
|
+
async run({ args }) {
|
|
58577
|
+
const a = args;
|
|
58578
|
+
const forceJson = a["json"] === true;
|
|
58579
|
+
const status = await getCleoStatus();
|
|
58580
|
+
if (forceJson || isJsonFormat()) {
|
|
58581
|
+
cliOutput(status, {
|
|
58582
|
+
command: "status",
|
|
58583
|
+
operation: "status.show"
|
|
58584
|
+
});
|
|
58585
|
+
} else {
|
|
58586
|
+
process.stdout.write(`${renderStatusHuman(status)}
|
|
58587
|
+
`);
|
|
58588
|
+
}
|
|
58589
|
+
const exitCode = computeExitCode(status);
|
|
58590
|
+
if (exitCode !== 0) process.exit(exitCode);
|
|
58591
|
+
}
|
|
58592
|
+
});
|
|
58593
|
+
}
|
|
58594
|
+
});
|
|
58595
|
+
|
|
57805
58596
|
// packages/cleo/src/cli/commands/sticky.ts
|
|
57806
58597
|
var sticky_exports = {};
|
|
57807
58598
|
__export(sticky_exports, {
|
|
@@ -58229,10 +59020,10 @@ var init_sync = __esm({
|
|
|
58229
59020
|
}
|
|
58230
59021
|
},
|
|
58231
59022
|
async run({ args }) {
|
|
58232
|
-
const { readFileSync:
|
|
59023
|
+
const { readFileSync: readFileSync18 } = await import("node:fs");
|
|
58233
59024
|
let externalTasks;
|
|
58234
59025
|
try {
|
|
58235
|
-
externalTasks = JSON.parse(
|
|
59026
|
+
externalTasks = JSON.parse(readFileSync18(args.file, "utf8"));
|
|
58236
59027
|
} catch (err) {
|
|
58237
59028
|
const message = err instanceof Error ? err.message : String(err);
|
|
58238
59029
|
cliError(`Failed to read or parse external tasks file: ${message}`, 2, {
|
|
@@ -58388,7 +59179,7 @@ var testing_exports = {};
|
|
|
58388
59179
|
__export(testing_exports, {
|
|
58389
59180
|
testingCommand: () => testingCommand
|
|
58390
59181
|
});
|
|
58391
|
-
var validateCommand9, checkCommand7,
|
|
59182
|
+
var validateCommand9, checkCommand7, statusCommand14, coverageCommand, runCommand4, testingCommand;
|
|
58392
59183
|
var init_testing = __esm({
|
|
58393
59184
|
"packages/cleo/src/cli/commands/testing.ts"() {
|
|
58394
59185
|
"use strict";
|
|
@@ -58449,7 +59240,7 @@ var init_testing = __esm({
|
|
|
58449
59240
|
);
|
|
58450
59241
|
}
|
|
58451
59242
|
});
|
|
58452
|
-
|
|
59243
|
+
statusCommand14 = defineCommand({
|
|
58453
59244
|
meta: { name: "status", description: "Show test suite status" },
|
|
58454
59245
|
async run() {
|
|
58455
59246
|
await dispatchFromCli(
|
|
@@ -58496,7 +59287,7 @@ var init_testing = __esm({
|
|
|
58496
59287
|
subCommands: {
|
|
58497
59288
|
validate: validateCommand9,
|
|
58498
59289
|
check: checkCommand7,
|
|
58499
|
-
status:
|
|
59290
|
+
status: statusCommand14,
|
|
58500
59291
|
coverage: coverageCommand,
|
|
58501
59292
|
run: runCommand4
|
|
58502
59293
|
},
|
|
@@ -58514,12 +59305,12 @@ var token_exports = {};
|
|
|
58514
59305
|
__export(token_exports, {
|
|
58515
59306
|
tokenCommand: () => tokenCommand
|
|
58516
59307
|
});
|
|
58517
|
-
import { readFileSync as
|
|
59308
|
+
import { readFileSync as readFileSync16 } from "node:fs";
|
|
58518
59309
|
import { getProjectRoot as getProjectRoot32, measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
|
|
58519
59310
|
function readPayload(args, textKey, fileKey) {
|
|
58520
59311
|
const text = args[textKey];
|
|
58521
59312
|
const file = args[fileKey];
|
|
58522
|
-
if (file) return
|
|
59313
|
+
if (file) return readFileSync16(file, "utf-8");
|
|
58523
59314
|
return text;
|
|
58524
59315
|
}
|
|
58525
59316
|
var filterArgs, summaryCommand3, listCommand24, showCommand16, deleteCommand3, clearCommand2, estimateCommand, tokenCommand;
|
|
@@ -58669,7 +59460,7 @@ var init_token = __esm({
|
|
|
58669
59460
|
async run({ args }) {
|
|
58670
59461
|
const requestPayload = readPayload(args, "request-text", "request-file");
|
|
58671
59462
|
const responsePayload = readPayload(args, "response-text", "response-file");
|
|
58672
|
-
const
|
|
59463
|
+
const input2 = {
|
|
58673
59464
|
requestPayload,
|
|
58674
59465
|
responsePayload,
|
|
58675
59466
|
provider: args.provider,
|
|
@@ -58679,7 +59470,7 @@ var init_token = __esm({
|
|
|
58679
59470
|
domain: args.domain,
|
|
58680
59471
|
operation: args.operation
|
|
58681
59472
|
};
|
|
58682
|
-
const result = args.record ? await recordTokenExchange2(getProjectRoot32(),
|
|
59473
|
+
const result = args.record ? await recordTokenExchange2(getProjectRoot32(), input2) : await measureTokenExchange(input2);
|
|
58683
59474
|
cliOutput(result, {
|
|
58684
59475
|
command: "token",
|
|
58685
59476
|
operation: args.record ? "admin.token.record" : "token.estimate"
|
|
@@ -58714,7 +59505,7 @@ __export(transcript_exports, {
|
|
|
58714
59505
|
transcriptCommand: () => transcriptCommand
|
|
58715
59506
|
});
|
|
58716
59507
|
import { homedir as homedir8 } from "node:os";
|
|
58717
|
-
import { join as
|
|
59508
|
+
import { join as join24 } from "node:path";
|
|
58718
59509
|
import { getProjectRoot as getProjectRoot33 } from "@cleocode/core";
|
|
58719
59510
|
import {
|
|
58720
59511
|
parseDurationMs,
|
|
@@ -58768,7 +59559,7 @@ var init_transcript = __esm({
|
|
|
58768
59559
|
}
|
|
58769
59560
|
return;
|
|
58770
59561
|
}
|
|
58771
|
-
const projectsDir = args["projects-dir"] ??
|
|
59562
|
+
const projectsDir = args["projects-dir"] ?? join24(homedir8(), ".claude", "projects");
|
|
58772
59563
|
try {
|
|
58773
59564
|
const result = await scanTranscripts(projectsDir);
|
|
58774
59565
|
cliOutput(
|
|
@@ -59074,7 +59865,7 @@ var init_transcript = __esm({
|
|
|
59074
59865
|
process.exit(2);
|
|
59075
59866
|
return;
|
|
59076
59867
|
}
|
|
59077
|
-
const projectsDir = args["projects-dir"] ??
|
|
59868
|
+
const projectsDir = args["projects-dir"] ?? join24(homedir8(), ".claude", "projects");
|
|
59078
59869
|
try {
|
|
59079
59870
|
const pruneResult = await pruneTranscripts({
|
|
59080
59871
|
olderThanMs,
|
|
@@ -59666,15 +60457,15 @@ __export(web_exports, {
|
|
|
59666
60457
|
});
|
|
59667
60458
|
import { execFileSync as execFileSync4, spawn as spawn2 } from "node:child_process";
|
|
59668
60459
|
import { mkdir as mkdir3, open, readFile as readFile5, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
59669
|
-
import { join as
|
|
60460
|
+
import { join as join25 } from "node:path";
|
|
59670
60461
|
import { CleoError as CleoError12, formatError as formatError9, getCleoHome as getCleoHome2 } from "@cleocode/core";
|
|
59671
60462
|
function getWebPaths() {
|
|
59672
60463
|
const cleoHome = getCleoHome2();
|
|
59673
60464
|
return {
|
|
59674
|
-
pidFile:
|
|
59675
|
-
configFile:
|
|
59676
|
-
logDir:
|
|
59677
|
-
logFile:
|
|
60465
|
+
pidFile: join25(cleoHome, "web-server.pid"),
|
|
60466
|
+
configFile: join25(cleoHome, "web-server.json"),
|
|
60467
|
+
logDir: join25(cleoHome, "logs"),
|
|
60468
|
+
logFile: join25(cleoHome, "logs", "web-server.log")
|
|
59678
60469
|
};
|
|
59679
60470
|
}
|
|
59680
60471
|
function isProcessRunning(pid) {
|
|
@@ -59713,7 +60504,7 @@ async function startWebServer(port, host) {
|
|
|
59713
60504
|
throw new CleoError12(1 /* GENERAL_ERROR */, `Server already running (PID: ${status.pid})`);
|
|
59714
60505
|
}
|
|
59715
60506
|
const projectRoot = process.env["CLEO_ROOT"] ?? process.cwd();
|
|
59716
|
-
const studioDir = process.env["CLEO_STUDIO_DIR"] ??
|
|
60507
|
+
const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join25(projectRoot, "packages", "studio", "build");
|
|
59717
60508
|
await mkdir3(logDir, { recursive: true });
|
|
59718
60509
|
await writeFile2(
|
|
59719
60510
|
configFile,
|
|
@@ -59723,7 +60514,7 @@ async function startWebServer(port, host) {
|
|
|
59723
60514
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
59724
60515
|
})
|
|
59725
60516
|
);
|
|
59726
|
-
const webIndexPath =
|
|
60517
|
+
const webIndexPath = join25(studioDir, "index.js");
|
|
59727
60518
|
try {
|
|
59728
60519
|
await stat(webIndexPath);
|
|
59729
60520
|
} catch {
|
|
@@ -59792,7 +60583,7 @@ Logs: ${logFile}`
|
|
|
59792
60583
|
{ command: "web", message: `CLEO Web UI running on port ${port}` }
|
|
59793
60584
|
);
|
|
59794
60585
|
}
|
|
59795
|
-
var DEFAULT_PORT, DEFAULT_HOST, startCommand10, stopCommand5, restartCommand,
|
|
60586
|
+
var DEFAULT_PORT, DEFAULT_HOST, startCommand10, stopCommand5, restartCommand, statusCommand15, openCommand, webCommand;
|
|
59796
60587
|
var init_web = __esm({
|
|
59797
60588
|
"packages/cleo/src/cli/commands/web.ts"() {
|
|
59798
60589
|
"use strict";
|
|
@@ -59924,7 +60715,7 @@ var init_web = __esm({
|
|
|
59924
60715
|
}
|
|
59925
60716
|
}
|
|
59926
60717
|
});
|
|
59927
|
-
|
|
60718
|
+
statusCommand15 = defineCommand({
|
|
59928
60719
|
meta: { name: "status", description: "Check server status" },
|
|
59929
60720
|
async run() {
|
|
59930
60721
|
try {
|
|
@@ -59978,7 +60769,7 @@ var init_web = __esm({
|
|
|
59978
60769
|
start: startCommand10,
|
|
59979
60770
|
stop: stopCommand5,
|
|
59980
60771
|
restart: restartCommand,
|
|
59981
|
-
status:
|
|
60772
|
+
status: statusCommand15,
|
|
59982
60773
|
open: openCommand
|
|
59983
60774
|
},
|
|
59984
60775
|
async run({ cmd, rawArgs }) {
|
|
@@ -59994,8 +60785,8 @@ var init_web = __esm({
|
|
|
59994
60785
|
init_dist();
|
|
59995
60786
|
init_field_context();
|
|
59996
60787
|
init_format_context();
|
|
59997
|
-
import { readFileSync as
|
|
59998
|
-
import { dirname as dirname8, join as
|
|
60788
|
+
import { readFileSync as readFileSync17 } from "node:fs";
|
|
60789
|
+
import { dirname as dirname8, join as join27 } from "node:path";
|
|
59999
60790
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
60000
60791
|
|
|
60001
60792
|
// packages/cleo/src/cli/generated/command-manifest.ts
|
|
@@ -60066,6 +60857,12 @@ var COMMAND_MANIFEST = [
|
|
|
60066
60857
|
description: "Git-backed audit tooling (lineage reconstruction, integrity checks). ",
|
|
60067
60858
|
load: async () => (await Promise.resolve().then(() => (init_audit2(), audit_exports))).auditCommand
|
|
60068
60859
|
},
|
|
60860
|
+
{
|
|
60861
|
+
exportName: "authCommand",
|
|
60862
|
+
name: "auth",
|
|
60863
|
+
description: "Unified credential view across all seeded sources (cleo llm list is the LLM-scoped sister command).",
|
|
60864
|
+
load: async () => (await Promise.resolve().then(() => (init_auth2(), auth_exports))).authCommand
|
|
60865
|
+
},
|
|
60069
60866
|
{
|
|
60070
60867
|
exportName: "backfillCommand",
|
|
60071
60868
|
name: "backfill",
|
|
@@ -60412,7 +61209,7 @@ var COMMAND_MANIFEST = [
|
|
|
60412
61209
|
exportName: "listCommand",
|
|
60413
61210
|
name: "list",
|
|
60414
61211
|
description: "List tasks with optional filters",
|
|
60415
|
-
load: async () => (await Promise.resolve().then(() => (
|
|
61212
|
+
load: async () => (await Promise.resolve().then(() => (init_list2(), list_exports))).listCommand
|
|
60416
61213
|
},
|
|
60417
61214
|
{
|
|
60418
61215
|
exportName: "costCommand",
|
|
@@ -60666,6 +61463,12 @@ var COMMAND_MANIFEST = [
|
|
|
60666
61463
|
description: "Manage work sessions",
|
|
60667
61464
|
load: async () => (await Promise.resolve().then(() => (init_session4(), session_exports))).sessionCommand
|
|
60668
61465
|
},
|
|
61466
|
+
{
|
|
61467
|
+
exportName: "setupCommand",
|
|
61468
|
+
name: "setup",
|
|
61469
|
+
description: "Interactive setup wizard \u2014 runs all sections (llm, identity, sentient, project-conventions) in canonical order. Use --section <name> for a single section or --non-interactive with --provider/--api-key to configure LLM without prompts.",
|
|
61470
|
+
load: async () => (await Promise.resolve().then(() => (init_setup(), setup_exports))).setupCommand
|
|
61471
|
+
},
|
|
60669
61472
|
{
|
|
60670
61473
|
exportName: "showCommand",
|
|
60671
61474
|
name: "show",
|
|
@@ -60696,6 +61499,12 @@ var COMMAND_MANIFEST = [
|
|
|
60696
61499
|
description: "Project statistics (counts, completion rates, velocity)",
|
|
60697
61500
|
load: async () => (await Promise.resolve().then(() => (init_stats(), stats_exports))).statsCommand
|
|
60698
61501
|
},
|
|
61502
|
+
{
|
|
61503
|
+
exportName: "statusCommand",
|
|
61504
|
+
name: "status",
|
|
61505
|
+
description: "Unified config + credential + session + harness + daemon snapshot. ",
|
|
61506
|
+
load: async () => (await Promise.resolve().then(() => (init_status(), status_exports))).statusCommand
|
|
61507
|
+
},
|
|
60699
61508
|
{
|
|
60700
61509
|
exportName: "stickyCommand",
|
|
60701
61510
|
name: "sticky",
|
|
@@ -61030,8 +61839,8 @@ function lazyCommand(meta, loader2) {
|
|
|
61030
61839
|
}
|
|
61031
61840
|
|
|
61032
61841
|
// packages/cleo/src/cli/lib/did-you-mean.ts
|
|
61033
|
-
function levenshteinDistance(
|
|
61034
|
-
const inputLen =
|
|
61842
|
+
function levenshteinDistance(input2, candidate) {
|
|
61843
|
+
const inputLen = input2.length;
|
|
61035
61844
|
const candidateLen = candidate.length;
|
|
61036
61845
|
const matrix = Array.from({ length: inputLen + 1 }, (_, i) => [i]);
|
|
61037
61846
|
for (let j = 1; j <= candidateLen; j++) {
|
|
@@ -61039,7 +61848,7 @@ function levenshteinDistance(input, candidate) {
|
|
|
61039
61848
|
}
|
|
61040
61849
|
for (let i = 1; i <= inputLen; i++) {
|
|
61041
61850
|
for (let j = 1; j <= candidateLen; j++) {
|
|
61042
|
-
const cost =
|
|
61851
|
+
const cost = input2[i - 1] === candidate[j - 1] ? 0 : 1;
|
|
61043
61852
|
matrix[i][j] = Math.min(
|
|
61044
61853
|
matrix[i - 1][j] + 1,
|
|
61045
61854
|
// deletion
|
|
@@ -61052,10 +61861,10 @@ function levenshteinDistance(input, candidate) {
|
|
|
61052
61861
|
}
|
|
61053
61862
|
return matrix[inputLen][candidateLen];
|
|
61054
61863
|
}
|
|
61055
|
-
function didYouMean(
|
|
61864
|
+
function didYouMean(input2, candidates, maxDistance = 2) {
|
|
61056
61865
|
const suggestions = candidates.map((candidate) => ({
|
|
61057
61866
|
command: candidate,
|
|
61058
|
-
distance: levenshteinDistance(
|
|
61867
|
+
distance: levenshteinDistance(input2, candidate)
|
|
61059
61868
|
})).filter((item) => item.distance <= maxDistance).sort((a, b) => {
|
|
61060
61869
|
if (a.distance !== b.distance) {
|
|
61061
61870
|
return a.distance - b.distance;
|
|
@@ -61065,17 +61874,77 @@ function didYouMean(input, candidates, maxDistance = 2) {
|
|
|
61065
61874
|
return suggestions;
|
|
61066
61875
|
}
|
|
61067
61876
|
|
|
61877
|
+
// packages/cleo/src/cli/lib/first-run-detection.ts
|
|
61878
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
61879
|
+
import { join as join26 } from "node:path";
|
|
61880
|
+
async function detectFirstRun() {
|
|
61881
|
+
const envKey = process.env["ANTHROPIC_API_KEY"];
|
|
61882
|
+
if (typeof envKey === "string" && envKey.length > 0) return false;
|
|
61883
|
+
const { getCleoPlatformPaths } = await import("@cleocode/paths");
|
|
61884
|
+
const configPath = join26(getCleoPlatformPaths().config, "config.json");
|
|
61885
|
+
if (existsSync15(configPath)) return false;
|
|
61886
|
+
try {
|
|
61887
|
+
const { getCredentialPool } = await import("@cleocode/core/llm/credential-pool.js");
|
|
61888
|
+
const pool = getCredentialPool();
|
|
61889
|
+
const entries = await pool.list();
|
|
61890
|
+
if (entries.length > 0) return false;
|
|
61891
|
+
} catch {
|
|
61892
|
+
}
|
|
61893
|
+
return true;
|
|
61894
|
+
}
|
|
61895
|
+
function waitForEnterOrTimeout(timeoutMs) {
|
|
61896
|
+
return new Promise((resolve5) => {
|
|
61897
|
+
let resolved = false;
|
|
61898
|
+
const finish = () => {
|
|
61899
|
+
if (resolved) return;
|
|
61900
|
+
resolved = true;
|
|
61901
|
+
clearTimeout(timer);
|
|
61902
|
+
process.stdin.removeListener("data", onData);
|
|
61903
|
+
process.stdin.removeListener("end", onEnd);
|
|
61904
|
+
try {
|
|
61905
|
+
process.stdin.pause();
|
|
61906
|
+
} catch {
|
|
61907
|
+
}
|
|
61908
|
+
resolve5();
|
|
61909
|
+
};
|
|
61910
|
+
const onData = (chunk) => {
|
|
61911
|
+
const s = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
61912
|
+
if (s.includes("\n") || s.includes("\r")) finish();
|
|
61913
|
+
};
|
|
61914
|
+
const onEnd = () => finish();
|
|
61915
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
61916
|
+
process.stdin.on("data", onData);
|
|
61917
|
+
process.stdin.on("end", onEnd);
|
|
61918
|
+
try {
|
|
61919
|
+
process.stdin.resume();
|
|
61920
|
+
} catch {
|
|
61921
|
+
}
|
|
61922
|
+
});
|
|
61923
|
+
}
|
|
61924
|
+
async function maybePromptFirstRun() {
|
|
61925
|
+
try {
|
|
61926
|
+
const isFirstRun = await detectFirstRun();
|
|
61927
|
+
if (!isFirstRun) return;
|
|
61928
|
+
if (process.stdin.isTTY !== true) return;
|
|
61929
|
+
process.stderr.write(
|
|
61930
|
+
"CLEO is not configured. Run 'cleo setup' to get started. (Press Enter to skip, or wait 10s)\n"
|
|
61931
|
+
);
|
|
61932
|
+
await waitForEnterOrTimeout(1e4);
|
|
61933
|
+
} catch {
|
|
61934
|
+
}
|
|
61935
|
+
}
|
|
61936
|
+
|
|
61068
61937
|
// packages/cleo/src/cli/middleware/output-format.ts
|
|
61069
61938
|
import { resolveOutputFormat } from "@cleocode/lafs";
|
|
61070
61939
|
function resolveFormat(opts, defaults) {
|
|
61071
|
-
const
|
|
61940
|
+
const input2 = {
|
|
61072
61941
|
jsonFlag: opts["json"] === true,
|
|
61073
61942
|
humanFlag: opts["human"] === true,
|
|
61074
61943
|
quiet: opts["quiet"] === true,
|
|
61075
61944
|
projectDefault: defaults?.projectDefault,
|
|
61076
61945
|
userDefault: defaults?.userDefault
|
|
61077
61946
|
};
|
|
61078
|
-
return resolveOutputFormat(
|
|
61947
|
+
return resolveOutputFormat(input2);
|
|
61079
61948
|
}
|
|
61080
61949
|
|
|
61081
61950
|
// packages/cleo/src/cli/index.ts
|
|
@@ -61101,8 +61970,8 @@ Or via NodeSource: https://github.com/nodesource/distributions
|
|
|
61101
61970
|
}
|
|
61102
61971
|
}
|
|
61103
61972
|
function getPackageVersion() {
|
|
61104
|
-
const pkgPath =
|
|
61105
|
-
const pkg = JSON.parse(
|
|
61973
|
+
const pkgPath = join27(dirname8(fileURLToPath5(import.meta.url)), "../../package.json");
|
|
61974
|
+
const pkg = JSON.parse(readFileSync17(pkgPath, "utf-8"));
|
|
61106
61975
|
return pkg.version;
|
|
61107
61976
|
}
|
|
61108
61977
|
var CLI_VERSION = getPackageVersion();
|
|
@@ -61162,6 +62031,12 @@ async function startCli() {
|
|
|
61162
62031
|
if (!isHelpOrVersion) {
|
|
61163
62032
|
await runStartupMaintenance();
|
|
61164
62033
|
}
|
|
62034
|
+
if (!isHelpOrVersion) {
|
|
62035
|
+
try {
|
|
62036
|
+
await maybePromptFirstRun();
|
|
62037
|
+
} catch {
|
|
62038
|
+
}
|
|
62039
|
+
}
|
|
61165
62040
|
const main = defineCommand({
|
|
61166
62041
|
meta: {
|
|
61167
62042
|
name: "cleo",
|