@cleocode/cleo 2026.4.129 → 2026.4.131
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 +753 -206
- package/dist/cli/index.js.map +4 -4
- package/package.json +9 -9
package/dist/cli/index.js
CHANGED
|
@@ -363,13 +363,72 @@ var init_attachment_schema = __esm({
|
|
|
363
363
|
});
|
|
364
364
|
|
|
365
365
|
// packages/contracts/src/branch-lock.ts
|
|
366
|
+
var BRANCH_LOCK_ERROR_CODES;
|
|
366
367
|
var init_branch_lock = __esm({
|
|
367
368
|
"packages/contracts/src/branch-lock.ts"() {
|
|
368
369
|
"use strict";
|
|
370
|
+
BRANCH_LOCK_ERROR_CODES = {
|
|
371
|
+
/** L2: git shim blocked a branch-mutating operation. */
|
|
372
|
+
E_GIT_OP_BLOCKED: "E_GIT_OP_BLOCKED",
|
|
373
|
+
/** L1: spawn attempted without a worktree handle. */
|
|
374
|
+
E_WORKTREE_REQUIRED: "E_WORKTREE_REQUIRED",
|
|
375
|
+
/** L1: worktree path does not exist or is not a valid git worktree. */
|
|
376
|
+
E_WORKTREE_INVALID: "E_WORKTREE_INVALID",
|
|
377
|
+
/** L1: cherry-pick failed during worktree.complete. */
|
|
378
|
+
E_CHERRY_PICK_FAILED: "E_CHERRY_PICK_FAILED",
|
|
379
|
+
/** L3: filesystem harden failed. */
|
|
380
|
+
E_FS_HARDEN_FAILED: "E_FS_HARDEN_FAILED",
|
|
381
|
+
/** L4a: HMAC token invalid or missing. */
|
|
382
|
+
E_OVERRIDE_TOKEN_INVALID: "E_OVERRIDE_TOKEN_INVALID",
|
|
383
|
+
/** L4b: caller has CLEO_AGENT_ROLE=worker|lead|subagent — override forbidden. */
|
|
384
|
+
E_OVERRIDE_FORBIDDEN_AGENT_ROLE: "E_OVERRIDE_FORBIDDEN_AGENT_ROLE",
|
|
385
|
+
/** L4c: override requires TTY but stdin/stderr is not a TTY. */
|
|
386
|
+
E_OVERRIDE_NEEDS_TTY: "E_OVERRIDE_NEEDS_TTY",
|
|
387
|
+
/** L4d: session override limit exceeded. */
|
|
388
|
+
E_OVERRIDE_RATE_LIMIT: "E_OVERRIDE_RATE_LIMIT"
|
|
389
|
+
};
|
|
369
390
|
}
|
|
370
391
|
});
|
|
371
392
|
|
|
372
393
|
// packages/contracts/src/exit-codes.ts
|
|
394
|
+
function isErrorCode(code) {
|
|
395
|
+
return code >= 1 && code < 100;
|
|
396
|
+
}
|
|
397
|
+
function isSuccessCode(code) {
|
|
398
|
+
return code === 0 || code >= 100;
|
|
399
|
+
}
|
|
400
|
+
function isNoChangeCode(code) {
|
|
401
|
+
return code === 102 /* NO_CHANGE */;
|
|
402
|
+
}
|
|
403
|
+
function isRecoverableCode(code) {
|
|
404
|
+
const nonRecoverable = /* @__PURE__ */ new Set([
|
|
405
|
+
3 /* FILE_ERROR */,
|
|
406
|
+
5 /* DEPENDENCY_ERROR */,
|
|
407
|
+
14 /* CIRCULAR_REFERENCE */,
|
|
408
|
+
18 /* CASCADE_FAILED */,
|
|
409
|
+
37 /* SESSION_CLOSE_BLOCKED */,
|
|
410
|
+
46 /* VERIFICATION_LOCKED */,
|
|
411
|
+
50 /* CONTEXT_WARNING */,
|
|
412
|
+
51 /* CONTEXT_CAUTION */,
|
|
413
|
+
52 /* CONTEXT_CRITICAL */,
|
|
414
|
+
53 /* CONTEXT_EMERGENCY */,
|
|
415
|
+
54 /* CONTEXT_STALE */,
|
|
416
|
+
64 /* AUTONOMOUS_BOUNDARY */,
|
|
417
|
+
65 /* HANDOFF_REQUIRED */,
|
|
418
|
+
72 /* NEXUS_PERMISSION_DENIED */,
|
|
419
|
+
75 /* NEXUS_REGISTRY_CORRUPT */,
|
|
420
|
+
82 /* CIRCULAR_VALIDATION */,
|
|
421
|
+
83 /* LIFECYCLE_TRANSITION_INVALID */,
|
|
422
|
+
85 /* ARTIFACT_TYPE_UNKNOWN */,
|
|
423
|
+
89 /* ARTIFACT_ROLLBACK_FAILED */,
|
|
424
|
+
93 /* DIGEST_MISMATCH */
|
|
425
|
+
]);
|
|
426
|
+
if (!isErrorCode(code)) return false;
|
|
427
|
+
return !nonRecoverable.has(code);
|
|
428
|
+
}
|
|
429
|
+
function getExitCodeName(code) {
|
|
430
|
+
return ExitCode[code] ?? "UNKNOWN";
|
|
431
|
+
}
|
|
373
432
|
var ExitCode;
|
|
374
433
|
var init_exit_codes = __esm({
|
|
375
434
|
"packages/contracts/src/exit-codes.ts"() {
|
|
@@ -471,6 +530,18 @@ var init_exit_codes = __esm({
|
|
|
471
530
|
});
|
|
472
531
|
|
|
473
532
|
// packages/contracts/src/errors.ts
|
|
533
|
+
function normalizeError(error, fallbackMessage = "An unexpected error occurred") {
|
|
534
|
+
if (error instanceof Error) {
|
|
535
|
+
return error;
|
|
536
|
+
}
|
|
537
|
+
if (typeof error === "string") {
|
|
538
|
+
return new Error(error);
|
|
539
|
+
}
|
|
540
|
+
if (error !== null && typeof error === "object" && "message" in error && typeof error.message === "string") {
|
|
541
|
+
return new Error(error.message);
|
|
542
|
+
}
|
|
543
|
+
return new Error(fallbackMessage);
|
|
544
|
+
}
|
|
474
545
|
function getErrorMessage(error, fallback = "Unknown error") {
|
|
475
546
|
if (error instanceof Error) {
|
|
476
547
|
return error.message;
|
|
@@ -483,10 +554,87 @@ function getErrorMessage(error, fallback = "Unknown error") {
|
|
|
483
554
|
}
|
|
484
555
|
return fallback;
|
|
485
556
|
}
|
|
557
|
+
function formatError(error, context, includeStack = false) {
|
|
558
|
+
const message = getErrorMessage(error);
|
|
559
|
+
const prefix = context ? `[${context}] ` : "";
|
|
560
|
+
let result = `${prefix}${message}`;
|
|
561
|
+
if (includeStack && error instanceof Error && error.stack) {
|
|
562
|
+
result += `
|
|
563
|
+
${error.stack}`;
|
|
564
|
+
}
|
|
565
|
+
return result;
|
|
566
|
+
}
|
|
567
|
+
function isErrorType(error, codeOrName) {
|
|
568
|
+
if (error instanceof Error) {
|
|
569
|
+
if (error.name === codeOrName) {
|
|
570
|
+
return true;
|
|
571
|
+
}
|
|
572
|
+
if ("code" in error && error.code === codeOrName) {
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
function createErrorResult(error) {
|
|
579
|
+
return {
|
|
580
|
+
success: false,
|
|
581
|
+
error: getErrorMessage(error)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function createSuccessResult() {
|
|
585
|
+
return { success: true };
|
|
586
|
+
}
|
|
587
|
+
function isErrorResult(result) {
|
|
588
|
+
return !result.success;
|
|
589
|
+
}
|
|
590
|
+
var ThinAgentViolationError, LifecycleScopeDeniedError;
|
|
486
591
|
var init_errors = __esm({
|
|
487
592
|
"packages/contracts/src/errors.ts"() {
|
|
488
593
|
"use strict";
|
|
489
594
|
init_exit_codes();
|
|
595
|
+
ThinAgentViolationError = class extends Error {
|
|
596
|
+
/**
|
|
597
|
+
* @param agentId - The offending agent's unique identifier.
|
|
598
|
+
* @param role - The offending agent's declared role (lead, worker, etc.).
|
|
599
|
+
* @param attemptedAction - The spawn action that was blocked.
|
|
600
|
+
*/
|
|
601
|
+
constructor(agentId, role, attemptedAction) {
|
|
602
|
+
super(
|
|
603
|
+
`E_THIN_AGENT_VIOLATION: agent '${agentId}' (role=${role}) attempted '${attemptedAction}'. Only orchestrators may spawn. Escalate via playbook approval gate.`
|
|
604
|
+
);
|
|
605
|
+
this.agentId = agentId;
|
|
606
|
+
this.role = role;
|
|
607
|
+
this.attemptedAction = attemptedAction;
|
|
608
|
+
this.name = "ThinAgentViolationError";
|
|
609
|
+
}
|
|
610
|
+
agentId;
|
|
611
|
+
role;
|
|
612
|
+
attemptedAction;
|
|
613
|
+
/** Stable LAFS error code string for envelope emission. */
|
|
614
|
+
code = "E_THIN_AGENT_VIOLATION";
|
|
615
|
+
/** Numeric exit code aligned with {@link ExitCode.THIN_AGENT_VIOLATION}. */
|
|
616
|
+
exitCode = 68 /* THIN_AGENT_VIOLATION */;
|
|
617
|
+
};
|
|
618
|
+
LifecycleScopeDeniedError = class extends Error {
|
|
619
|
+
/**
|
|
620
|
+
* @param epicId - The epic whose lifecycle mutation was blocked.
|
|
621
|
+
* @param sessionScope - Human-readable description of the current session scope.
|
|
622
|
+
*/
|
|
623
|
+
constructor(epicId, sessionScope) {
|
|
624
|
+
super(
|
|
625
|
+
`E_LIFECYCLE_SCOPE_DENIED: lifecycle stage advancement for epic '${epicId}' requires a session scoped to that epic or an owner override. Current session scope: ${sessionScope}. Use CLEO_OWNER_OVERRIDE=1 if this is an authorized operation.`
|
|
626
|
+
);
|
|
627
|
+
this.epicId = epicId;
|
|
628
|
+
this.sessionScope = sessionScope;
|
|
629
|
+
this.name = "LifecycleScopeDeniedError";
|
|
630
|
+
}
|
|
631
|
+
epicId;
|
|
632
|
+
sessionScope;
|
|
633
|
+
/** Stable LAFS error code string for envelope emission. */
|
|
634
|
+
code = "E_LIFECYCLE_SCOPE_DENIED";
|
|
635
|
+
/** Numeric exit code aligned with {@link ExitCode.TASK_NOT_IN_SCOPE} (34). */
|
|
636
|
+
exitCode = 34 /* TASK_NOT_IN_SCOPE */;
|
|
637
|
+
};
|
|
490
638
|
}
|
|
491
639
|
});
|
|
492
640
|
|
|
@@ -553,13 +701,49 @@ var init_evidence_record_schema = __esm({
|
|
|
553
701
|
});
|
|
554
702
|
|
|
555
703
|
// packages/contracts/src/facade.ts
|
|
704
|
+
var BRAIN_OBSERVATION_TYPES, AGENT_INSTANCE_STATUSES, AGENT_TYPES;
|
|
556
705
|
var init_facade = __esm({
|
|
557
706
|
"packages/contracts/src/facade.ts"() {
|
|
558
707
|
"use strict";
|
|
708
|
+
BRAIN_OBSERVATION_TYPES = [
|
|
709
|
+
"discovery",
|
|
710
|
+
"change",
|
|
711
|
+
"feature",
|
|
712
|
+
"bugfix",
|
|
713
|
+
"decision",
|
|
714
|
+
"refactor",
|
|
715
|
+
"diary"
|
|
716
|
+
];
|
|
717
|
+
AGENT_INSTANCE_STATUSES = [
|
|
718
|
+
"starting",
|
|
719
|
+
"active",
|
|
720
|
+
"idle",
|
|
721
|
+
"error",
|
|
722
|
+
"crashed",
|
|
723
|
+
"stopped"
|
|
724
|
+
];
|
|
725
|
+
AGENT_TYPES = [
|
|
726
|
+
"orchestrator",
|
|
727
|
+
"executor",
|
|
728
|
+
"researcher",
|
|
729
|
+
"architect",
|
|
730
|
+
"validator",
|
|
731
|
+
"documentor",
|
|
732
|
+
"custom"
|
|
733
|
+
];
|
|
559
734
|
}
|
|
560
735
|
});
|
|
561
736
|
|
|
562
737
|
// packages/contracts/src/lafs.ts
|
|
738
|
+
function isLafsSuccess(envelope) {
|
|
739
|
+
return envelope.success === true;
|
|
740
|
+
}
|
|
741
|
+
function isLafsError(envelope) {
|
|
742
|
+
return envelope.success === false;
|
|
743
|
+
}
|
|
744
|
+
function isGatewayEnvelope(envelope) {
|
|
745
|
+
return "_meta" in envelope && envelope._meta !== void 0;
|
|
746
|
+
}
|
|
563
747
|
var init_lafs = __esm({
|
|
564
748
|
"packages/contracts/src/lafs.ts"() {
|
|
565
749
|
"use strict";
|
|
@@ -720,6 +904,10 @@ var init_worktree = __esm({
|
|
|
720
904
|
});
|
|
721
905
|
|
|
722
906
|
// packages/contracts/src/operations/index.ts
|
|
907
|
+
var operations_exports = {};
|
|
908
|
+
__export(operations_exports, {
|
|
909
|
+
paramsToCittyArgs: () => paramsToCittyArgs
|
|
910
|
+
});
|
|
723
911
|
var init_operations = __esm({
|
|
724
912
|
"packages/contracts/src/operations/index.ts"() {
|
|
725
913
|
"use strict";
|
|
@@ -745,6 +933,21 @@ var init_operations = __esm({
|
|
|
745
933
|
});
|
|
746
934
|
|
|
747
935
|
// packages/contracts/src/peer.ts
|
|
936
|
+
function isPeerIdentity(value) {
|
|
937
|
+
if (typeof value !== "object" || value === null) return false;
|
|
938
|
+
const v = value;
|
|
939
|
+
return typeof v["peerId"] === "string" && v["peerId"].length > 0 && typeof v["peerKind"] === "string" && ["orchestrator", "lead", "worker", "subagent"].includes(v["peerKind"]) && typeof v["cantFile"] === "string" && v["cantFile"].length > 0 && typeof v["displayName"] === "string" && typeof v["description"] === "string";
|
|
940
|
+
}
|
|
941
|
+
function assertPeerIdentity(value) {
|
|
942
|
+
if (!isPeerIdentity(value)) {
|
|
943
|
+
throw new TypeError(
|
|
944
|
+
`Expected PeerIdentity { peerId, peerKind, cantFile, displayName, description } \u2014 got: ${JSON.stringify(value)}`
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
function filterPeerIdentities(values) {
|
|
949
|
+
return values.filter(isPeerIdentity);
|
|
950
|
+
}
|
|
748
951
|
var init_peer = __esm({
|
|
749
952
|
"packages/contracts/src/peer.ts"() {
|
|
750
953
|
"use strict";
|
|
@@ -752,17 +955,222 @@ var init_peer = __esm({
|
|
|
752
955
|
});
|
|
753
956
|
|
|
754
957
|
// packages/contracts/src/session.ts
|
|
958
|
+
var SessionView;
|
|
755
959
|
var init_session2 = __esm({
|
|
756
960
|
"packages/contracts/src/session.ts"() {
|
|
757
961
|
"use strict";
|
|
962
|
+
SessionView = class _SessionView {
|
|
963
|
+
_sessions;
|
|
964
|
+
constructor(sessions2) {
|
|
965
|
+
this._sessions = sessions2;
|
|
966
|
+
}
|
|
967
|
+
/** Create a SessionView from a Session array. */
|
|
968
|
+
static from(sessions2) {
|
|
969
|
+
return new _SessionView(sessions2);
|
|
970
|
+
}
|
|
971
|
+
/** All sessions in the view (readonly). */
|
|
972
|
+
get all() {
|
|
973
|
+
return this._sessions;
|
|
974
|
+
}
|
|
975
|
+
/** Number of sessions. */
|
|
976
|
+
get length() {
|
|
977
|
+
return this._sessions.length;
|
|
978
|
+
}
|
|
979
|
+
/** Find the currently active session (if any). */
|
|
980
|
+
findActive() {
|
|
981
|
+
return this._sessions.find((s) => s.status === "active");
|
|
982
|
+
}
|
|
983
|
+
/** Find a session by ID. */
|
|
984
|
+
findById(id) {
|
|
985
|
+
return this._sessions.find((s) => s.id === id);
|
|
986
|
+
}
|
|
987
|
+
/** Filter sessions by one or more statuses. */
|
|
988
|
+
filterByStatus(...statuses) {
|
|
989
|
+
return this._sessions.filter((s) => statuses.includes(s.status));
|
|
990
|
+
}
|
|
991
|
+
/** Find sessions matching a scope type and optional rootTaskId. */
|
|
992
|
+
findByScope(type2, rootTaskId) {
|
|
993
|
+
return this._sessions.filter((s) => {
|
|
994
|
+
if (s.scope?.type !== type2) return false;
|
|
995
|
+
if (rootTaskId && s.scope?.rootTaskId !== rootTaskId) return false;
|
|
996
|
+
return true;
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
/** Sort sessions by a date field. Returns a new array (does not mutate). */
|
|
1000
|
+
sortByDate(field, descending = true) {
|
|
1001
|
+
return [...this._sessions].sort((a, b) => {
|
|
1002
|
+
const aDate = new Date(a[field] || "").getTime();
|
|
1003
|
+
const bDate = new Date(b[field] || "").getTime();
|
|
1004
|
+
return descending ? bDate - aDate : aDate - bDate;
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
/** Get the most recently started session. */
|
|
1008
|
+
mostRecent() {
|
|
1009
|
+
if (this._sessions.length === 0) return void 0;
|
|
1010
|
+
return this.sortByDate("startedAt", true)[0];
|
|
1011
|
+
}
|
|
1012
|
+
/** Convert back to a plain Session array (shallow copy). */
|
|
1013
|
+
toArray() {
|
|
1014
|
+
return [...this._sessions];
|
|
1015
|
+
}
|
|
1016
|
+
/** Support for-of iteration. */
|
|
1017
|
+
[Symbol.iterator]() {
|
|
1018
|
+
return this._sessions[Symbol.iterator]();
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
// packages/contracts/src/session-journal.ts
|
|
1025
|
+
import { z as z4 } from "zod";
|
|
1026
|
+
var SESSION_JOURNAL_SCHEMA_VERSION, sessionJournalDoctorSummarySchema, sessionJournalDebriefSummarySchema, sessionJournalEntrySchema;
|
|
1027
|
+
var init_session_journal = __esm({
|
|
1028
|
+
"packages/contracts/src/session-journal.ts"() {
|
|
1029
|
+
"use strict";
|
|
1030
|
+
SESSION_JOURNAL_SCHEMA_VERSION = "1.0";
|
|
1031
|
+
sessionJournalDoctorSummarySchema = z4.object({
|
|
1032
|
+
/** `true` when zero noise patterns were detected. */
|
|
1033
|
+
isClean: z4.boolean(),
|
|
1034
|
+
/** Total number of noise findings across all patterns. */
|
|
1035
|
+
findingsCount: z4.number().int().nonnegative(),
|
|
1036
|
+
/** Pattern names that were detected (empty when isClean). */
|
|
1037
|
+
patterns: z4.array(z4.string()),
|
|
1038
|
+
/** Total brain entries scanned. `0` = empty or unavailable. */
|
|
1039
|
+
totalScanned: z4.number().int().nonnegative()
|
|
1040
|
+
});
|
|
1041
|
+
sessionJournalDebriefSummarySchema = z4.object({
|
|
1042
|
+
/** First 200 characters of the session end note (if provided). */
|
|
1043
|
+
noteExcerpt: z4.string().max(200).optional(),
|
|
1044
|
+
/** Number of tasks completed during the session. */
|
|
1045
|
+
tasksCompletedCount: z4.number().int().nonnegative(),
|
|
1046
|
+
/** Up to 5 task IDs (not titles) that were the focus of the session. */
|
|
1047
|
+
tasksFocused: z4.array(z4.string()).max(5).optional()
|
|
1048
|
+
});
|
|
1049
|
+
sessionJournalEntrySchema = z4.object({
|
|
1050
|
+
// Identity
|
|
1051
|
+
/** Schema version for forward-compatibility. Always `'1.0'` in this release. */
|
|
1052
|
+
schemaVersion: z4.literal(SESSION_JOURNAL_SCHEMA_VERSION),
|
|
1053
|
+
/** ISO 8601 timestamp when the entry was written. */
|
|
1054
|
+
timestamp: z4.string(),
|
|
1055
|
+
/** CLEO session ID (e.g. `ses_20260424055456_ede571`). */
|
|
1056
|
+
sessionId: z4.string(),
|
|
1057
|
+
/** Event type that triggered this journal entry. */
|
|
1058
|
+
eventType: z4.enum(["session_start", "session_end", "observation", "decision", "error"]),
|
|
1059
|
+
// Session metadata (set on session_start / session_end)
|
|
1060
|
+
/** Agent identifier (e.g. `cleo-prime`, `claude-code`). */
|
|
1061
|
+
agentIdentifier: z4.string().optional(),
|
|
1062
|
+
/** Provider adapter ID active for this session. */
|
|
1063
|
+
providerId: z4.string().optional(),
|
|
1064
|
+
/** Session scope string (e.g. `'global'` or `'epic:T1263'`). */
|
|
1065
|
+
scope: z4.string().optional(),
|
|
1066
|
+
// Session-end fields
|
|
1067
|
+
/** Duration of the session in seconds (session_end only). */
|
|
1068
|
+
duration: z4.number().int().nonnegative().optional(),
|
|
1069
|
+
/** Task IDs (not titles) completed during the session. */
|
|
1070
|
+
tasksCompleted: z4.array(z4.string()).optional(),
|
|
1071
|
+
// Doctor summary (T1262 absorbed)
|
|
1072
|
+
/** Compact result of `scanBrainNoise` run at session-end. */
|
|
1073
|
+
doctorSummary: sessionJournalDoctorSummarySchema.optional(),
|
|
1074
|
+
// Debrief summary
|
|
1075
|
+
/** Compact excerpt from session debrief data. */
|
|
1076
|
+
debriefSummary: sessionJournalDebriefSummarySchema.optional(),
|
|
1077
|
+
// Optional hash chain
|
|
1078
|
+
/** SHA-256 hex of the previous entry's raw JSON string (for integrity chain). */
|
|
1079
|
+
prevEntryHash: z4.string().optional()
|
|
1080
|
+
});
|
|
758
1081
|
}
|
|
759
1082
|
});
|
|
760
1083
|
|
|
761
1084
|
// packages/contracts/src/status-registry.ts
|
|
762
|
-
|
|
1085
|
+
function isValidStatus(entityType, value) {
|
|
1086
|
+
return STATUS_REGISTRY[entityType].includes(value);
|
|
1087
|
+
}
|
|
1088
|
+
var TASK_STATUSES, SESSION_STATUSES, LIFECYCLE_PIPELINE_STATUSES, LIFECYCLE_STAGE_STATUSES, ADR_STATUSES, GATE_STATUSES, MANIFEST_STATUSES, TERMINAL_TASK_STATUSES, TERMINAL_PIPELINE_STATUSES, TERMINAL_STAGE_STATUSES, STATUS_REGISTRY, PIPELINE_STATUS_ICONS, STAGE_STATUS_ICONS, TASK_STATUS_SYMBOLS_UNICODE, TASK_STATUS_SYMBOLS_ASCII;
|
|
763
1089
|
var init_status_registry = __esm({
|
|
764
1090
|
"packages/contracts/src/status-registry.ts"() {
|
|
765
1091
|
"use strict";
|
|
1092
|
+
TASK_STATUSES = [
|
|
1093
|
+
"pending",
|
|
1094
|
+
"active",
|
|
1095
|
+
"blocked",
|
|
1096
|
+
"done",
|
|
1097
|
+
"cancelled",
|
|
1098
|
+
"archived",
|
|
1099
|
+
"proposed"
|
|
1100
|
+
];
|
|
1101
|
+
SESSION_STATUSES = ["active", "ended", "orphaned", "suspended"];
|
|
1102
|
+
LIFECYCLE_PIPELINE_STATUSES = [
|
|
1103
|
+
"active",
|
|
1104
|
+
"completed",
|
|
1105
|
+
"blocked",
|
|
1106
|
+
"failed",
|
|
1107
|
+
"cancelled",
|
|
1108
|
+
"aborted"
|
|
1109
|
+
];
|
|
1110
|
+
LIFECYCLE_STAGE_STATUSES = [
|
|
1111
|
+
"not_started",
|
|
1112
|
+
"in_progress",
|
|
1113
|
+
"blocked",
|
|
1114
|
+
"completed",
|
|
1115
|
+
"skipped",
|
|
1116
|
+
"failed"
|
|
1117
|
+
];
|
|
1118
|
+
ADR_STATUSES = ["proposed", "accepted", "superseded", "deprecated"];
|
|
1119
|
+
GATE_STATUSES = ["pending", "passed", "failed", "waived"];
|
|
1120
|
+
MANIFEST_STATUSES = ["completed", "partial", "blocked", "archived"];
|
|
1121
|
+
TERMINAL_TASK_STATUSES = /* @__PURE__ */ new Set([
|
|
1122
|
+
"done",
|
|
1123
|
+
"cancelled",
|
|
1124
|
+
"archived"
|
|
1125
|
+
]);
|
|
1126
|
+
TERMINAL_PIPELINE_STATUSES = /* @__PURE__ */ new Set([
|
|
1127
|
+
"completed",
|
|
1128
|
+
"failed",
|
|
1129
|
+
"cancelled",
|
|
1130
|
+
"aborted"
|
|
1131
|
+
]);
|
|
1132
|
+
TERMINAL_STAGE_STATUSES = /* @__PURE__ */ new Set([
|
|
1133
|
+
"completed",
|
|
1134
|
+
"skipped",
|
|
1135
|
+
"failed"
|
|
1136
|
+
]);
|
|
1137
|
+
STATUS_REGISTRY = {
|
|
1138
|
+
task: TASK_STATUSES,
|
|
1139
|
+
session: SESSION_STATUSES,
|
|
1140
|
+
lifecycle_pipeline: LIFECYCLE_PIPELINE_STATUSES,
|
|
1141
|
+
lifecycle_stage: LIFECYCLE_STAGE_STATUSES,
|
|
1142
|
+
adr: ADR_STATUSES,
|
|
1143
|
+
gate: GATE_STATUSES,
|
|
1144
|
+
manifest: MANIFEST_STATUSES
|
|
1145
|
+
};
|
|
1146
|
+
PIPELINE_STATUS_ICONS = {
|
|
1147
|
+
active: "\u25B6",
|
|
1148
|
+
// pipeline is running
|
|
1149
|
+
completed: "\u2713",
|
|
1150
|
+
// all stages done successfully
|
|
1151
|
+
blocked: "\u23F8",
|
|
1152
|
+
// cannot advance; waiting
|
|
1153
|
+
failed: "\u2717",
|
|
1154
|
+
// terminal failure
|
|
1155
|
+
cancelled: "\u2298",
|
|
1156
|
+
// user-initiated abandonment
|
|
1157
|
+
aborted: "\u23F9"
|
|
1158
|
+
// system-forced termination
|
|
1159
|
+
};
|
|
1160
|
+
STAGE_STATUS_ICONS = {
|
|
1161
|
+
not_started: "\u23F9",
|
|
1162
|
+
// not yet entered
|
|
1163
|
+
in_progress: "\u25B6",
|
|
1164
|
+
// actively running
|
|
1165
|
+
blocked: "\u23F8",
|
|
1166
|
+
// paused / waiting
|
|
1167
|
+
completed: "\u2713",
|
|
1168
|
+
// finished successfully
|
|
1169
|
+
skipped: "\u23ED",
|
|
1170
|
+
// intentionally bypassed
|
|
1171
|
+
failed: "\u2717"
|
|
1172
|
+
// terminal failure
|
|
1173
|
+
};
|
|
766
1174
|
TASK_STATUS_SYMBOLS_UNICODE = {
|
|
767
1175
|
pending: "\u25CB",
|
|
768
1176
|
// ○ not yet started
|
|
@@ -792,52 +1200,52 @@ var init_status_registry = __esm({
|
|
|
792
1200
|
});
|
|
793
1201
|
|
|
794
1202
|
// packages/contracts/src/task-evidence.ts
|
|
795
|
-
import { z as
|
|
1203
|
+
import { z as z5 } from "zod";
|
|
796
1204
|
var fileEvidenceSchema, logEvidenceSchema, screenshotEvidenceSchema, testOutputEvidenceSchema, commandOutputEvidenceSchema, taskEvidenceSchema;
|
|
797
1205
|
var init_task_evidence = __esm({
|
|
798
1206
|
"packages/contracts/src/task-evidence.ts"() {
|
|
799
1207
|
"use strict";
|
|
800
|
-
fileEvidenceSchema =
|
|
801
|
-
kind:
|
|
802
|
-
sha256:
|
|
803
|
-
timestamp:
|
|
804
|
-
path:
|
|
805
|
-
mime:
|
|
806
|
-
description:
|
|
1208
|
+
fileEvidenceSchema = z5.object({
|
|
1209
|
+
kind: z5.literal("file"),
|
|
1210
|
+
sha256: z5.string().length(64),
|
|
1211
|
+
timestamp: z5.string().datetime(),
|
|
1212
|
+
path: z5.string().min(1),
|
|
1213
|
+
mime: z5.string().optional(),
|
|
1214
|
+
description: z5.string().optional()
|
|
807
1215
|
});
|
|
808
|
-
logEvidenceSchema =
|
|
809
|
-
kind:
|
|
810
|
-
sha256:
|
|
811
|
-
timestamp:
|
|
812
|
-
source:
|
|
813
|
-
description:
|
|
1216
|
+
logEvidenceSchema = z5.object({
|
|
1217
|
+
kind: z5.literal("log"),
|
|
1218
|
+
sha256: z5.string().length(64),
|
|
1219
|
+
timestamp: z5.string().datetime(),
|
|
1220
|
+
source: z5.string().min(1),
|
|
1221
|
+
description: z5.string().optional()
|
|
814
1222
|
});
|
|
815
|
-
screenshotEvidenceSchema =
|
|
816
|
-
kind:
|
|
817
|
-
sha256:
|
|
818
|
-
timestamp:
|
|
819
|
-
mime:
|
|
820
|
-
description:
|
|
1223
|
+
screenshotEvidenceSchema = z5.object({
|
|
1224
|
+
kind: z5.literal("screenshot"),
|
|
1225
|
+
sha256: z5.string().length(64),
|
|
1226
|
+
timestamp: z5.string().datetime(),
|
|
1227
|
+
mime: z5.enum(["image/png", "image/jpeg", "image/webp"]).optional(),
|
|
1228
|
+
description: z5.string().optional()
|
|
821
1229
|
});
|
|
822
|
-
testOutputEvidenceSchema =
|
|
823
|
-
kind:
|
|
824
|
-
sha256:
|
|
825
|
-
timestamp:
|
|
826
|
-
passed:
|
|
827
|
-
failed:
|
|
828
|
-
skipped:
|
|
829
|
-
exitCode:
|
|
830
|
-
description:
|
|
1230
|
+
testOutputEvidenceSchema = z5.object({
|
|
1231
|
+
kind: z5.literal("test-output"),
|
|
1232
|
+
sha256: z5.string().length(64),
|
|
1233
|
+
timestamp: z5.string().datetime(),
|
|
1234
|
+
passed: z5.number().int().nonnegative(),
|
|
1235
|
+
failed: z5.number().int().nonnegative(),
|
|
1236
|
+
skipped: z5.number().int().nonnegative(),
|
|
1237
|
+
exitCode: z5.number().int(),
|
|
1238
|
+
description: z5.string().optional()
|
|
831
1239
|
});
|
|
832
|
-
commandOutputEvidenceSchema =
|
|
833
|
-
kind:
|
|
834
|
-
sha256:
|
|
835
|
-
timestamp:
|
|
836
|
-
cmd:
|
|
837
|
-
exitCode:
|
|
838
|
-
description:
|
|
1240
|
+
commandOutputEvidenceSchema = z5.object({
|
|
1241
|
+
kind: z5.literal("command-output"),
|
|
1242
|
+
sha256: z5.string().length(64),
|
|
1243
|
+
timestamp: z5.string().datetime(),
|
|
1244
|
+
cmd: z5.string().min(1),
|
|
1245
|
+
exitCode: z5.number().int(),
|
|
1246
|
+
description: z5.string().optional()
|
|
839
1247
|
});
|
|
840
|
-
taskEvidenceSchema =
|
|
1248
|
+
taskEvidenceSchema = z5.discriminatedUnion("kind", [
|
|
841
1249
|
fileEvidenceSchema,
|
|
842
1250
|
logEvidenceSchema,
|
|
843
1251
|
screenshotEvidenceSchema,
|
|
@@ -848,6 +1256,90 @@ var init_task_evidence = __esm({
|
|
|
848
1256
|
});
|
|
849
1257
|
|
|
850
1258
|
// packages/contracts/src/index.ts
|
|
1259
|
+
var src_exports = {};
|
|
1260
|
+
__export(src_exports, {
|
|
1261
|
+
ADR_STATUSES: () => ADR_STATUSES,
|
|
1262
|
+
AGENT_INSTANCE_STATUSES: () => AGENT_INSTANCE_STATUSES,
|
|
1263
|
+
AGENT_TYPES: () => AGENT_TYPES,
|
|
1264
|
+
BRAIN_OBSERVATION_TYPES: () => BRAIN_OBSERVATION_TYPES,
|
|
1265
|
+
BRANCH_LOCK_ERROR_CODES: () => BRANCH_LOCK_ERROR_CODES,
|
|
1266
|
+
ExitCode: () => ExitCode,
|
|
1267
|
+
GATE_STATUSES: () => GATE_STATUSES,
|
|
1268
|
+
LIFECYCLE_PIPELINE_STATUSES: () => LIFECYCLE_PIPELINE_STATUSES,
|
|
1269
|
+
LIFECYCLE_STAGE_STATUSES: () => LIFECYCLE_STAGE_STATUSES,
|
|
1270
|
+
LifecycleScopeDeniedError: () => LifecycleScopeDeniedError,
|
|
1271
|
+
MANIFEST_STATUSES: () => MANIFEST_STATUSES,
|
|
1272
|
+
PIPELINE_STATUS_ICONS: () => PIPELINE_STATUS_ICONS,
|
|
1273
|
+
SESSION_JOURNAL_SCHEMA_VERSION: () => SESSION_JOURNAL_SCHEMA_VERSION,
|
|
1274
|
+
SESSION_STATUSES: () => SESSION_STATUSES,
|
|
1275
|
+
STAGE_STATUS_ICONS: () => STAGE_STATUS_ICONS,
|
|
1276
|
+
STATUS_REGISTRY: () => STATUS_REGISTRY,
|
|
1277
|
+
SessionView: () => SessionView,
|
|
1278
|
+
TASK_STATUSES: () => TASK_STATUSES,
|
|
1279
|
+
TASK_STATUS_SYMBOLS_ASCII: () => TASK_STATUS_SYMBOLS_ASCII,
|
|
1280
|
+
TASK_STATUS_SYMBOLS_UNICODE: () => TASK_STATUS_SYMBOLS_UNICODE,
|
|
1281
|
+
TERMINAL_PIPELINE_STATUSES: () => TERMINAL_PIPELINE_STATUSES,
|
|
1282
|
+
TERMINAL_STAGE_STATUSES: () => TERMINAL_STAGE_STATUSES,
|
|
1283
|
+
TERMINAL_TASK_STATUSES: () => TERMINAL_TASK_STATUSES,
|
|
1284
|
+
ThinAgentViolationError: () => ThinAgentViolationError,
|
|
1285
|
+
acceptanceArraySchema: () => acceptanceArraySchema,
|
|
1286
|
+
acceptanceGateResultSchema: () => acceptanceGateResultSchema,
|
|
1287
|
+
acceptanceGateSchema: () => acceptanceGateSchema,
|
|
1288
|
+
acceptanceItemSchema: () => acceptanceItemSchema,
|
|
1289
|
+
assertPeerIdentity: () => assertPeerIdentity,
|
|
1290
|
+
attachmentMetadataSchema: () => attachmentMetadataSchema,
|
|
1291
|
+
attachmentRefSchema: () => attachmentRefSchema,
|
|
1292
|
+
attachmentSchema: () => attachmentSchema,
|
|
1293
|
+
blobAttachmentSchema: () => blobAttachmentSchema,
|
|
1294
|
+
commandGateSchema: () => commandGateSchema,
|
|
1295
|
+
commandOutputEvidenceSchema: () => commandOutputEvidenceSchema,
|
|
1296
|
+
commandOutputRecordSchema: () => commandOutputRecordSchema,
|
|
1297
|
+
createErrorResult: () => createErrorResult,
|
|
1298
|
+
createSuccessResult: () => createSuccessResult,
|
|
1299
|
+
evidenceRecordSchema: () => evidenceRecordSchema,
|
|
1300
|
+
fileAssertionSchema: () => fileAssertionSchema,
|
|
1301
|
+
fileEvidenceSchema: () => fileEvidenceSchema,
|
|
1302
|
+
fileGateSchema: () => fileGateSchema,
|
|
1303
|
+
filterPeerIdentities: () => filterPeerIdentities,
|
|
1304
|
+
formatError: () => formatError,
|
|
1305
|
+
gateBaseSchema: () => gateBaseSchema,
|
|
1306
|
+
gateResultDetailsSchema: () => gateResultDetailsSchema,
|
|
1307
|
+
getErrorMessage: () => getErrorMessage,
|
|
1308
|
+
getExitCodeName: () => getExitCodeName,
|
|
1309
|
+
httpGateSchema: () => httpGateSchema,
|
|
1310
|
+
implDiffRecordSchema: () => implDiffRecordSchema,
|
|
1311
|
+
isErrorCode: () => isErrorCode,
|
|
1312
|
+
isErrorResult: () => isErrorResult,
|
|
1313
|
+
isErrorType: () => isErrorType,
|
|
1314
|
+
isGatewayEnvelope: () => isGatewayEnvelope,
|
|
1315
|
+
isLafsError: () => isLafsError,
|
|
1316
|
+
isLafsSuccess: () => isLafsSuccess,
|
|
1317
|
+
isNoChangeCode: () => isNoChangeCode,
|
|
1318
|
+
isPeerIdentity: () => isPeerIdentity,
|
|
1319
|
+
isRecoverableCode: () => isRecoverableCode,
|
|
1320
|
+
isSuccessCode: () => isSuccessCode,
|
|
1321
|
+
isValidStatus: () => isValidStatus,
|
|
1322
|
+
lintGateSchema: () => lintGateSchema,
|
|
1323
|
+
lintReportRecordSchema: () => lintReportRecordSchema,
|
|
1324
|
+
llmsTxtAttachmentSchema: () => llmsTxtAttachmentSchema,
|
|
1325
|
+
llmtxtDocAttachmentSchema: () => llmtxtDocAttachmentSchema,
|
|
1326
|
+
localFileAttachmentSchema: () => localFileAttachmentSchema,
|
|
1327
|
+
logEvidenceSchema: () => logEvidenceSchema,
|
|
1328
|
+
manualGateSchema: () => manualGateSchema,
|
|
1329
|
+
normalizeError: () => normalizeError,
|
|
1330
|
+
ops: () => operations_exports,
|
|
1331
|
+
paramsToCittyArgs: () => paramsToCittyArgs,
|
|
1332
|
+
screenshotEvidenceSchema: () => screenshotEvidenceSchema,
|
|
1333
|
+
sessionJournalDebriefSummarySchema: () => sessionJournalDebriefSummarySchema,
|
|
1334
|
+
sessionJournalDoctorSummarySchema: () => sessionJournalDoctorSummarySchema,
|
|
1335
|
+
sessionJournalEntrySchema: () => sessionJournalEntrySchema,
|
|
1336
|
+
taskEvidenceSchema: () => taskEvidenceSchema,
|
|
1337
|
+
testGateSchema: () => testGateSchema,
|
|
1338
|
+
testOutputEvidenceSchema: () => testOutputEvidenceSchema,
|
|
1339
|
+
testOutputRecordSchema: () => testOutputRecordSchema,
|
|
1340
|
+
urlAttachmentSchema: () => urlAttachmentSchema,
|
|
1341
|
+
validateSpecCheckRecordSchema: () => validateSpecCheckRecordSchema
|
|
1342
|
+
});
|
|
851
1343
|
var init_src = __esm({
|
|
852
1344
|
"packages/contracts/src/index.ts"() {
|
|
853
1345
|
init_acceptance_gate_schema();
|
|
@@ -862,6 +1354,7 @@ var init_src = __esm({
|
|
|
862
1354
|
init_params();
|
|
863
1355
|
init_peer();
|
|
864
1356
|
init_session2();
|
|
1357
|
+
init_session_journal();
|
|
865
1358
|
init_status_registry();
|
|
866
1359
|
init_task_evidence();
|
|
867
1360
|
}
|
|
@@ -9007,6 +9500,18 @@ async function sessionStart(projectRoot, params) {
|
|
|
9007
9500
|
...previousDebrief && { previousDebrief },
|
|
9008
9501
|
...previousHandoff && { previousHandoff }
|
|
9009
9502
|
};
|
|
9503
|
+
import("@cleocode/core/sessions/session-journal.js").then(async ({ appendSessionJournalEntry }) => {
|
|
9504
|
+
const { SESSION_JOURNAL_SCHEMA_VERSION: SESSION_JOURNAL_SCHEMA_VERSION2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
9505
|
+
await appendSessionJournalEntry(projectRoot, {
|
|
9506
|
+
schemaVersion: SESSION_JOURNAL_SCHEMA_VERSION2,
|
|
9507
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9508
|
+
sessionId,
|
|
9509
|
+
eventType: "session_start",
|
|
9510
|
+
agentIdentifier: agentIdentifier ?? void 0,
|
|
9511
|
+
scope: params.scope
|
|
9512
|
+
});
|
|
9513
|
+
}).catch(() => {
|
|
9514
|
+
});
|
|
9010
9515
|
return { success: true, data: enrichedSession };
|
|
9011
9516
|
} catch {
|
|
9012
9517
|
return engineError("E_NOT_INITIALIZED", "Task database not initialized");
|
|
@@ -9067,6 +9572,38 @@ async function sessionEnd(projectRoot, notes, params) {
|
|
|
9067
9572
|
}
|
|
9068
9573
|
} catch {
|
|
9069
9574
|
}
|
|
9575
|
+
try {
|
|
9576
|
+
const { appendSessionJournalEntry } = await import("@cleocode/core/sessions/session-journal.js");
|
|
9577
|
+
const { SESSION_JOURNAL_SCHEMA_VERSION: SESSION_JOURNAL_SCHEMA_VERSION2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
9578
|
+
let doctorSummary;
|
|
9579
|
+
try {
|
|
9580
|
+
const { scanBrainNoise } = await import("@cleocode/core/memory/brain-doctor.js");
|
|
9581
|
+
const scanResult = await scanBrainNoise(projectRoot);
|
|
9582
|
+
doctorSummary = {
|
|
9583
|
+
isClean: scanResult.isClean,
|
|
9584
|
+
findingsCount: scanResult.findings.length,
|
|
9585
|
+
patterns: scanResult.findings.map((f) => f.pattern),
|
|
9586
|
+
totalScanned: scanResult.totalScanned
|
|
9587
|
+
};
|
|
9588
|
+
} catch {
|
|
9589
|
+
}
|
|
9590
|
+
const agentIdentifier = process.env.CLEO_AGENT_ID ?? process.env.CLAUDE_CODE_AGENT_ID ?? void 0;
|
|
9591
|
+
const duration = Math.floor(
|
|
9592
|
+
(Date.now() - new Date(activeSession.startedAt).getTime()) / 1e3
|
|
9593
|
+
);
|
|
9594
|
+
await appendSessionJournalEntry(projectRoot, {
|
|
9595
|
+
schemaVersion: SESSION_JOURNAL_SCHEMA_VERSION2,
|
|
9596
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9597
|
+
sessionId,
|
|
9598
|
+
eventType: "session_end",
|
|
9599
|
+
agentIdentifier,
|
|
9600
|
+
providerId: activeSession.providerId ?? void 0,
|
|
9601
|
+
duration,
|
|
9602
|
+
tasksCompleted: activeSession.tasksCompleted ?? [],
|
|
9603
|
+
...doctorSummary !== void 0 ? { doctorSummary } : {}
|
|
9604
|
+
});
|
|
9605
|
+
} catch {
|
|
9606
|
+
}
|
|
9070
9607
|
return {
|
|
9071
9608
|
success: true,
|
|
9072
9609
|
data: { sessionId, ended: true, ...memoryPrompt && { memoryPrompt } }
|
|
@@ -9155,6 +9692,11 @@ async function sessionGc(projectRoot, maxAgeDays = 1) {
|
|
|
9155
9692
|
await accessor.removeSingleSession(s.id);
|
|
9156
9693
|
}
|
|
9157
9694
|
}
|
|
9695
|
+
try {
|
|
9696
|
+
const { rotateSessionJournals } = await import("@cleocode/core/sessions/session-journal.js");
|
|
9697
|
+
await rotateSessionJournals(projectRoot);
|
|
9698
|
+
} catch {
|
|
9699
|
+
}
|
|
9158
9700
|
return { success: true, data: { orphaned, removed } };
|
|
9159
9701
|
} catch {
|
|
9160
9702
|
return engineError("E_NOT_INITIALIZED", "Task database not initialized");
|
|
@@ -11740,9 +12282,9 @@ async function systemLog(projectRoot, filters) {
|
|
|
11740
12282
|
}
|
|
11741
12283
|
async function queryAuditLogSqlite(projectRoot, filters) {
|
|
11742
12284
|
try {
|
|
11743
|
-
const { join:
|
|
12285
|
+
const { join: join23 } = await import("node:path");
|
|
11744
12286
|
const { existsSync: existsSync12 } = await import("node:fs");
|
|
11745
|
-
const dbPath =
|
|
12287
|
+
const dbPath = join23(projectRoot, CLEO_DIR_NAME, TASKS_DB_FILENAME);
|
|
11746
12288
|
if (!existsSync12(dbPath)) {
|
|
11747
12289
|
const offset = filters?.offset ?? 0;
|
|
11748
12290
|
const limit = filters?.limit ?? 20;
|
|
@@ -25339,6 +25881,8 @@ var init_state = __esm({
|
|
|
25339
25881
|
});
|
|
25340
25882
|
|
|
25341
25883
|
// packages/playbooks/src/runtime.ts
|
|
25884
|
+
import { appendFileSync, mkdirSync } from "node:fs";
|
|
25885
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
25342
25886
|
function buildEdgeIndex(def) {
|
|
25343
25887
|
const outgoing = /* @__PURE__ */ new Map();
|
|
25344
25888
|
const incoming = /* @__PURE__ */ new Map();
|
|
@@ -25506,16 +26050,19 @@ function resolveEdge(fromId, toId, edges) {
|
|
|
25506
26050
|
function auditContractViolation(projectRoot, runId, nodeId, field, key, playbookName) {
|
|
25507
26051
|
if (!projectRoot) return;
|
|
25508
26052
|
try {
|
|
25509
|
-
|
|
25510
|
-
|
|
25511
|
-
|
|
25512
|
-
|
|
25513
|
-
|
|
25514
|
-
|
|
25515
|
-
|
|
25516
|
-
|
|
25517
|
-
}
|
|
26053
|
+
const filePath = join4(projectRoot, ".cleo", "audit", "contract-violations.jsonl");
|
|
26054
|
+
mkdirSync(dirname2(filePath), { recursive: true });
|
|
26055
|
+
const entry = JSON.stringify({
|
|
26056
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26057
|
+
runId,
|
|
26058
|
+
nodeId,
|
|
26059
|
+
field,
|
|
26060
|
+
key,
|
|
26061
|
+
message: `contract_violation: ${field}['${key}'] check failed on node '${nodeId}'`,
|
|
26062
|
+
playbookName
|
|
25518
26063
|
});
|
|
26064
|
+
appendFileSync(filePath, `${entry}
|
|
26065
|
+
`, { encoding: "utf-8" });
|
|
25519
26066
|
} catch {
|
|
25520
26067
|
}
|
|
25521
26068
|
}
|
|
@@ -25912,8 +26459,8 @@ var init_runtime = __esm({
|
|
|
25912
26459
|
});
|
|
25913
26460
|
|
|
25914
26461
|
// packages/playbooks/src/index.ts
|
|
25915
|
-
var
|
|
25916
|
-
__export(
|
|
26462
|
+
var src_exports2 = {};
|
|
26463
|
+
__export(src_exports2, {
|
|
25917
26464
|
DEFAULT_POLICY_RULES: () => DEFAULT_POLICY_RULES,
|
|
25918
26465
|
E_APPROVAL_ALREADY_DECIDED: () => E_APPROVAL_ALREADY_DECIDED,
|
|
25919
26466
|
E_APPROVAL_NOT_FOUND: () => E_APPROVAL_NOT_FOUND,
|
|
@@ -25960,7 +26507,7 @@ var init_src2 = __esm({
|
|
|
25960
26507
|
// packages/cleo/src/dispatch/domains/playbook.ts
|
|
25961
26508
|
import { existsSync as existsSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
25962
26509
|
import { homedir } from "node:os";
|
|
25963
|
-
import { dirname as
|
|
26510
|
+
import { dirname as dirname3, join as join5, resolve as resolvePath2 } from "node:path";
|
|
25964
26511
|
import { fileURLToPath } from "node:url";
|
|
25965
26512
|
function normalizeListStatus(raw) {
|
|
25966
26513
|
if (typeof raw !== "string" || raw.length === 0) return void 0;
|
|
@@ -25988,8 +26535,8 @@ function resolvePlaybookDirs() {
|
|
|
25988
26535
|
if (__playbookRuntimeOverrides.playbookBaseDirs) {
|
|
25989
26536
|
return __playbookRuntimeOverrides.playbookBaseDirs;
|
|
25990
26537
|
}
|
|
25991
|
-
const globalDir =
|
|
25992
|
-
const here =
|
|
26538
|
+
const globalDir = join5(homedir(), ".local", "share", "cleo", "playbooks");
|
|
26539
|
+
const here = dirname3(fileURLToPath(import.meta.url));
|
|
25993
26540
|
const sourceStarter = resolvePath2(here, "..", "..", "..", "..", "playbooks", "starter");
|
|
25994
26541
|
const bundledStarter = resolvePath2(here, "..", "..", "..", "playbooks", "starter");
|
|
25995
26542
|
return [globalDir, sourceStarter, bundledStarter];
|
|
@@ -25998,7 +26545,7 @@ function loadPlaybookByName(name) {
|
|
|
25998
26545
|
const candidates = resolvePlaybookDirs();
|
|
25999
26546
|
const fileName = name.endsWith(".cantbook") ? name : `${name}.cantbook`;
|
|
26000
26547
|
for (const dir of candidates) {
|
|
26001
|
-
const full =
|
|
26548
|
+
const full = join5(dir, fileName);
|
|
26002
26549
|
if (existsSync3(full)) {
|
|
26003
26550
|
return { sourcePath: full, source: readFileSync6(full, "utf8") };
|
|
26004
26551
|
}
|
|
@@ -26562,7 +27109,7 @@ async function orchestrateClassify(request, context, projectRoot) {
|
|
|
26562
27109
|
try {
|
|
26563
27110
|
const { getCleoCantWorkflowsDir: getCleoCantWorkflowsDir2 } = await import("@cleocode/core/internal");
|
|
26564
27111
|
const { readFileSync: readFileSync16, readdirSync: readdirSync4, existsSync: existsSync12 } = await import("node:fs");
|
|
26565
|
-
const { join:
|
|
27112
|
+
const { join: join23 } = await import("node:path");
|
|
26566
27113
|
const workflowsDir = getCleoCantWorkflowsDir2();
|
|
26567
27114
|
const combined = `${request} ${context ?? ""}`.toLowerCase();
|
|
26568
27115
|
const matches = [];
|
|
@@ -26570,7 +27117,7 @@ async function orchestrateClassify(request, context, projectRoot) {
|
|
|
26570
27117
|
const files = readdirSync4(workflowsDir).filter((f) => f.endsWith(".cant"));
|
|
26571
27118
|
for (const file of files) {
|
|
26572
27119
|
try {
|
|
26573
|
-
const src = readFileSync16(
|
|
27120
|
+
const src = readFileSync16(join23(workflowsDir, file), "utf-8");
|
|
26574
27121
|
const teamMatch = /^team\s+(\S+):/m.exec(src);
|
|
26575
27122
|
if (!teamMatch) continue;
|
|
26576
27123
|
const teamName = teamMatch[1];
|
|
@@ -26585,12 +27132,12 @@ async function orchestrateClassify(request, context, projectRoot) {
|
|
|
26585
27132
|
}
|
|
26586
27133
|
}
|
|
26587
27134
|
}
|
|
26588
|
-
const localCantDir =
|
|
27135
|
+
const localCantDir = join23(projectRoot, CLEO_DIR_NAME, WORKFLOWS_SUBDIR);
|
|
26589
27136
|
if (existsSync12(localCantDir)) {
|
|
26590
27137
|
const files = readdirSync4(localCantDir).filter((f) => f.endsWith(".cant"));
|
|
26591
27138
|
for (const file of files) {
|
|
26592
27139
|
try {
|
|
26593
|
-
const src = readFileSync16(
|
|
27140
|
+
const src = readFileSync16(join23(localCantDir, file), "utf-8");
|
|
26594
27141
|
const teamMatch = /^team\s+(\S+):/m.exec(src);
|
|
26595
27142
|
if (!teamMatch) continue;
|
|
26596
27143
|
const teamName = teamMatch[1];
|
|
@@ -26866,7 +27413,7 @@ async function handleApproveGate(params, startTime) {
|
|
|
26866
27413
|
);
|
|
26867
27414
|
}
|
|
26868
27415
|
const db = await acquirePlaybookDb();
|
|
26869
|
-
const { approveGate: approveGate2 } = await Promise.resolve().then(() => (init_src2(),
|
|
27416
|
+
const { approveGate: approveGate2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|
|
26870
27417
|
const updated = approveGate2(db, resumeToken, approver, reason);
|
|
26871
27418
|
return {
|
|
26872
27419
|
meta: dispatchMeta("mutate", "orchestrate", "approve", startTime),
|
|
@@ -26956,7 +27503,7 @@ async function handleRejectGate(params, startTime) {
|
|
|
26956
27503
|
);
|
|
26957
27504
|
}
|
|
26958
27505
|
const db = await acquirePlaybookDb();
|
|
26959
|
-
const { rejectGate: rejectGate2 } = await Promise.resolve().then(() => (init_src2(),
|
|
27506
|
+
const { rejectGate: rejectGate2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|
|
26960
27507
|
const updated = rejectGate2(db, resumeToken, approver, reason);
|
|
26961
27508
|
return {
|
|
26962
27509
|
meta: dispatchMeta("mutate", "orchestrate", "reject", startTime),
|
|
@@ -28568,7 +29115,7 @@ var init_pipeline2 = __esm({
|
|
|
28568
29115
|
});
|
|
28569
29116
|
|
|
28570
29117
|
// packages/cleo/src/dispatch/domains/sentient.ts
|
|
28571
|
-
import { join as
|
|
29118
|
+
import { join as join6 } from "node:path";
|
|
28572
29119
|
import { getProjectRoot as getProjectRoot11 } from "@cleocode/core";
|
|
28573
29120
|
function safeParseJsonArray(json2) {
|
|
28574
29121
|
if (!json2) return [];
|
|
@@ -28597,7 +29144,7 @@ async function incrementTier2Stat(projectRoot, field) {
|
|
|
28597
29144
|
try {
|
|
28598
29145
|
const { patchSentientState: patchSentientState2, readSentientState: readSentientState2 } = await import("@cleocode/core/sentient/state.js");
|
|
28599
29146
|
const { SENTIENT_STATE_FILE: SENTIENT_STATE_FILE2 } = await import("@cleocode/core/sentient/daemon.js");
|
|
28600
|
-
const statePath =
|
|
29147
|
+
const statePath = join6(projectRoot, SENTIENT_STATE_FILE2);
|
|
28601
29148
|
const state = await readSentientState2(statePath);
|
|
28602
29149
|
await patchSentientState2(statePath, {
|
|
28603
29150
|
tier2Stats: {
|
|
@@ -28874,7 +29421,7 @@ var init_sentient = __esm({
|
|
|
28874
29421
|
async runProposeTick(projectRoot, params) {
|
|
28875
29422
|
const { safeRunProposeTick: safeRunProposeTick2 } = await import("@cleocode/core/sentient/propose-tick.js");
|
|
28876
29423
|
const { SENTIENT_STATE_FILE: SENTIENT_STATE_FILE2 } = await import("@cleocode/core/sentient/daemon.js");
|
|
28877
|
-
const statePath =
|
|
29424
|
+
const statePath = join6(projectRoot, SENTIENT_STATE_FILE2);
|
|
28878
29425
|
const outcome = await safeRunProposeTick2({ projectRoot, statePath });
|
|
28879
29426
|
const _ = params;
|
|
28880
29427
|
void _;
|
|
@@ -28922,7 +29469,7 @@ var init_sentient = __esm({
|
|
|
28922
29469
|
async setTier2Enabled(projectRoot, enabled) {
|
|
28923
29470
|
const { patchSentientState: patchSentientState2 } = await import("@cleocode/core/sentient/state.js");
|
|
28924
29471
|
const { SENTIENT_STATE_FILE: SENTIENT_STATE_FILE2 } = await import("@cleocode/core/sentient/daemon.js");
|
|
28925
|
-
const statePath =
|
|
29472
|
+
const statePath = join6(projectRoot, SENTIENT_STATE_FILE2);
|
|
28926
29473
|
const updated = await patchSentientState2(statePath, { tier2Enabled: enabled });
|
|
28927
29474
|
return {
|
|
28928
29475
|
success: true,
|
|
@@ -30303,7 +30850,7 @@ var init_tasks3 = __esm({
|
|
|
30303
30850
|
});
|
|
30304
30851
|
|
|
30305
30852
|
// packages/cleo/src/dispatch/engines/code-engine.ts
|
|
30306
|
-
import { join as
|
|
30853
|
+
import { join as join7 } from "node:path";
|
|
30307
30854
|
import { getProjectRoot as getProjectRoot15 } from "@cleocode/core";
|
|
30308
30855
|
async function codeOutline(params) {
|
|
30309
30856
|
const { smartOutline } = await import("@cleocode/core/internal");
|
|
@@ -30314,7 +30861,7 @@ async function codeOutline(params) {
|
|
|
30314
30861
|
error: { code: "E_INVALID_INPUT", message: "file parameter required" }
|
|
30315
30862
|
};
|
|
30316
30863
|
const root = getProjectRoot15();
|
|
30317
|
-
const absPath = filePath.startsWith("/") ? filePath :
|
|
30864
|
+
const absPath = filePath.startsWith("/") ? filePath : join7(root, filePath);
|
|
30318
30865
|
return { success: true, data: smartOutline(absPath, root) };
|
|
30319
30866
|
}
|
|
30320
30867
|
async function codeSearch(params) {
|
|
@@ -30346,7 +30893,7 @@ async function codeUnfold(params) {
|
|
|
30346
30893
|
error: { code: "E_INVALID_INPUT", message: "file and symbol parameters required" }
|
|
30347
30894
|
};
|
|
30348
30895
|
const root = getProjectRoot15();
|
|
30349
|
-
const absPath = filePath.startsWith("/") ? filePath :
|
|
30896
|
+
const absPath = filePath.startsWith("/") ? filePath : join7(root, filePath);
|
|
30350
30897
|
return { success: true, data: smartUnfold(absPath, symbol, root) };
|
|
30351
30898
|
}
|
|
30352
30899
|
async function codeParse(params) {
|
|
@@ -30358,7 +30905,7 @@ async function codeParse(params) {
|
|
|
30358
30905
|
error: { code: "E_INVALID_INPUT", message: "file parameter required" }
|
|
30359
30906
|
};
|
|
30360
30907
|
const root = getProjectRoot15();
|
|
30361
|
-
const absPath = filePath.startsWith("/") ? filePath :
|
|
30908
|
+
const absPath = filePath.startsWith("/") ? filePath : join7(root, filePath);
|
|
30362
30909
|
return { success: true, data: parseFile(absPath, root) };
|
|
30363
30910
|
}
|
|
30364
30911
|
var init_code_engine = __esm({
|
|
@@ -31528,7 +32075,7 @@ var init_defaults = __esm({
|
|
|
31528
32075
|
|
|
31529
32076
|
// packages/cleo/src/dispatch/lib/config-loader.ts
|
|
31530
32077
|
import { existsSync as existsSync4, readFileSync as readFileSync7 } from "fs";
|
|
31531
|
-
import { join as
|
|
32078
|
+
import { join as join8 } from "path";
|
|
31532
32079
|
function loadFromEnv(key) {
|
|
31533
32080
|
const envKey = `${ENV_PREFIX}${key.toUpperCase()}`;
|
|
31534
32081
|
return process.env[envKey];
|
|
@@ -31549,7 +32096,7 @@ function parseEnvValue(key, value) {
|
|
|
31549
32096
|
}
|
|
31550
32097
|
function loadFromFile(projectRoot) {
|
|
31551
32098
|
const root = projectRoot || process.cwd();
|
|
31552
|
-
const configPath =
|
|
32099
|
+
const configPath = join8(root, CLEO_DIR_NAME, CONFIG_JSON);
|
|
31553
32100
|
if (!existsSync4(configPath)) {
|
|
31554
32101
|
return {};
|
|
31555
32102
|
}
|
|
@@ -32023,7 +32570,7 @@ __export(cli_exports, {
|
|
|
32023
32570
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
32024
32571
|
import { existsSync as existsSync5 } from "node:fs";
|
|
32025
32572
|
import { createRequire as createRequire2 } from "node:module";
|
|
32026
|
-
import { dirname as
|
|
32573
|
+
import { dirname as dirname4, join as join9 } from "node:path";
|
|
32027
32574
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32028
32575
|
import { catalog as catalog2, registerSkillLibraryFromPath } from "@cleocode/caamp";
|
|
32029
32576
|
import { autoRecordDispatchTokenUsage, getProjectRoot as getProjectRoot17, hooks } from "@cleocode/core/internal";
|
|
@@ -32034,17 +32581,17 @@ function ensureCaampLibrary() {
|
|
|
32034
32581
|
try {
|
|
32035
32582
|
const req = createRequire2(import.meta.url);
|
|
32036
32583
|
const skillsPkgJson = req.resolve("@cleocode/skills/package.json");
|
|
32037
|
-
const candidate =
|
|
32038
|
-
if (existsSync5(
|
|
32584
|
+
const candidate = dirname4(skillsPkgJson);
|
|
32585
|
+
if (existsSync5(join9(candidate, "skills.json"))) {
|
|
32039
32586
|
skillsRoot = candidate;
|
|
32040
32587
|
}
|
|
32041
32588
|
} catch {
|
|
32042
32589
|
}
|
|
32043
32590
|
if (!skillsRoot) {
|
|
32044
32591
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
32045
|
-
const packageRoot =
|
|
32046
|
-
const candidate =
|
|
32047
|
-
if (existsSync5(
|
|
32592
|
+
const packageRoot = join9(dirname4(thisFile), "..", "..", "..", "..", "..");
|
|
32593
|
+
const candidate = join9(packageRoot, "packages", "skills");
|
|
32594
|
+
if (existsSync5(join9(candidate, "skills.json"))) {
|
|
32048
32595
|
skillsRoot = candidate;
|
|
32049
32596
|
}
|
|
32050
32597
|
}
|
|
@@ -32264,7 +32811,7 @@ var init_cli = __esm({
|
|
|
32264
32811
|
|
|
32265
32812
|
// packages/cleo/src/cli/index.ts
|
|
32266
32813
|
import { readFileSync as readFileSync15 } from "node:fs";
|
|
32267
|
-
import { dirname as
|
|
32814
|
+
import { dirname as dirname10, join as join22 } from "node:path";
|
|
32268
32815
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
32269
32816
|
import {
|
|
32270
32817
|
detectAndRemoveLegacyGlobalFiles,
|
|
@@ -33891,13 +34438,13 @@ var registerCommand = defineCommand({
|
|
|
33891
34438
|
transportConfig: {},
|
|
33892
34439
|
isActive: true
|
|
33893
34440
|
});
|
|
33894
|
-
const { existsSync: existsSync12, mkdirSync:
|
|
33895
|
-
const { join:
|
|
33896
|
-
const cantDir =
|
|
33897
|
-
const cantPath =
|
|
34441
|
+
const { existsSync: existsSync12, mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("node:fs");
|
|
34442
|
+
const { join: join23 } = await import("node:path");
|
|
34443
|
+
const cantDir = join23(CLEO_DIR_NAME, AGENTS_SUBDIR);
|
|
34444
|
+
const cantPath = join23(cantDir, `${agentId}.cant`);
|
|
33898
34445
|
let cantScaffolded = false;
|
|
33899
34446
|
if (!existsSync12(cantPath)) {
|
|
33900
|
-
|
|
34447
|
+
mkdirSync5(cantDir, { recursive: true });
|
|
33901
34448
|
const role = classification ?? "specialist";
|
|
33902
34449
|
const cantContent = `---
|
|
33903
34450
|
kind: agent
|
|
@@ -34076,7 +34623,7 @@ var startCommand = defineCommand({
|
|
|
34076
34623
|
const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
|
|
34077
34624
|
const { createRuntime } = await import("@cleocode/runtime");
|
|
34078
34625
|
const { existsSync: existsSync12, readFileSync: readFileSync16 } = await import("node:fs");
|
|
34079
|
-
const { join:
|
|
34626
|
+
const { join: join23 } = await import("node:path");
|
|
34080
34627
|
await getDb3();
|
|
34081
34628
|
const registry = new AgentRegistryAccessor(process.cwd());
|
|
34082
34629
|
const credential = await registry.get(args.agentId);
|
|
@@ -34096,7 +34643,7 @@ var startCommand = defineCommand({
|
|
|
34096
34643
|
}
|
|
34097
34644
|
let profile = null;
|
|
34098
34645
|
let cantValidation = null;
|
|
34099
|
-
const cantPath = args.cant ??
|
|
34646
|
+
const cantPath = args.cant ?? join23(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
|
|
34100
34647
|
if (existsSync12(cantPath)) {
|
|
34101
34648
|
profile = readFileSync16(cantPath, "utf-8");
|
|
34102
34649
|
try {
|
|
@@ -34622,7 +35169,7 @@ var workCommand = defineCommand({
|
|
|
34622
35169
|
const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
|
|
34623
35170
|
const { createRuntime } = await import("@cleocode/runtime");
|
|
34624
35171
|
const { existsSync: existsSync12 } = await import("node:fs");
|
|
34625
|
-
const { join:
|
|
35172
|
+
const { join: join23 } = await import("node:path");
|
|
34626
35173
|
const { execFile: execFile2 } = await import("node:child_process");
|
|
34627
35174
|
const { promisify: promisify2 } = await import("node:util");
|
|
34628
35175
|
const execFileAsync = promisify2(execFile2);
|
|
@@ -34642,7 +35189,7 @@ var workCommand = defineCommand({
|
|
|
34642
35189
|
}
|
|
34643
35190
|
await registry.update(args.agentId, { isActive: true });
|
|
34644
35191
|
await registry.markUsed(args.agentId);
|
|
34645
|
-
const cantPath =
|
|
35192
|
+
const cantPath = join23(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
|
|
34646
35193
|
const hasProfile = existsSync12(cantPath);
|
|
34647
35194
|
const runtime = await createRuntime(registry, {
|
|
34648
35195
|
agentId: args.agentId,
|
|
@@ -35493,8 +36040,8 @@ var installCommand = defineCommand({
|
|
|
35493
36040
|
async run({ args }) {
|
|
35494
36041
|
let tempDir = null;
|
|
35495
36042
|
try {
|
|
35496
|
-
const { existsSync: existsSync12, mkdirSync:
|
|
35497
|
-
const { join:
|
|
36043
|
+
const { existsSync: existsSync12, mkdirSync: mkdirSync5, statSync, readdirSync: readdirSync4, copyFileSync } = await import("node:fs");
|
|
36044
|
+
const { join: join23, basename: basename2, resolve: resolve5, extname } = await import("node:path");
|
|
35498
36045
|
const { tmpdir } = await import("node:os");
|
|
35499
36046
|
const resolvedPath = resolve5(args.path);
|
|
35500
36047
|
if (!existsSync12(resolvedPath)) {
|
|
@@ -35518,8 +36065,8 @@ var installCommand = defineCommand({
|
|
|
35518
36065
|
cantPath = resolvedPath;
|
|
35519
36066
|
} else if (stat2.isFile() && ext === ".cantz") {
|
|
35520
36067
|
const { execFileSync: execFileSync6 } = await import("node:child_process");
|
|
35521
|
-
tempDir =
|
|
35522
|
-
|
|
36068
|
+
tempDir = join23(tmpdir(), `cleo-agent-install-${Date.now()}`);
|
|
36069
|
+
mkdirSync5(tempDir, { recursive: true });
|
|
35523
36070
|
try {
|
|
35524
36071
|
execFileSync6("unzip", ["-o", "-q", resolvedPath, "-d", tempDir], {
|
|
35525
36072
|
encoding: "utf-8",
|
|
@@ -35540,7 +36087,7 @@ var installCommand = defineCommand({
|
|
|
35540
36087
|
return;
|
|
35541
36088
|
}
|
|
35542
36089
|
const topLevel = readdirSync4(tempDir).filter(
|
|
35543
|
-
(entry) => statSync(
|
|
36090
|
+
(entry) => statSync(join23(tempDir, entry)).isDirectory()
|
|
35544
36091
|
);
|
|
35545
36092
|
if (topLevel.length !== 1) {
|
|
35546
36093
|
cliOutput(
|
|
@@ -35557,7 +36104,7 @@ var installCommand = defineCommand({
|
|
|
35557
36104
|
return;
|
|
35558
36105
|
}
|
|
35559
36106
|
const agentName = topLevel[0];
|
|
35560
|
-
const personaPath =
|
|
36107
|
+
const personaPath = join23(tempDir, agentName, "persona.cant");
|
|
35561
36108
|
if (!existsSync12(personaPath)) {
|
|
35562
36109
|
cliOutput(
|
|
35563
36110
|
{
|
|
@@ -35572,11 +36119,11 @@ var installCommand = defineCommand({
|
|
|
35572
36119
|
process.exitCode = 6;
|
|
35573
36120
|
return;
|
|
35574
36121
|
}
|
|
35575
|
-
cantPath =
|
|
36122
|
+
cantPath = join23(tempDir, `${agentName}.cant`);
|
|
35576
36123
|
copyFileSync(personaPath, cantPath);
|
|
35577
36124
|
} else if (stat2.isDirectory()) {
|
|
35578
36125
|
const agentName = basename2(resolvedPath);
|
|
35579
|
-
const personaPath =
|
|
36126
|
+
const personaPath = join23(resolvedPath, "persona.cant");
|
|
35580
36127
|
if (!existsSync12(personaPath)) {
|
|
35581
36128
|
cliOutput(
|
|
35582
36129
|
{
|
|
@@ -35591,9 +36138,9 @@ var installCommand = defineCommand({
|
|
|
35591
36138
|
process.exitCode = 6;
|
|
35592
36139
|
return;
|
|
35593
36140
|
}
|
|
35594
|
-
tempDir =
|
|
35595
|
-
|
|
35596
|
-
cantPath =
|
|
36141
|
+
tempDir = join23(tmpdir(), `cleo-agent-install-${Date.now()}`);
|
|
36142
|
+
mkdirSync5(tempDir, { recursive: true });
|
|
36143
|
+
cantPath = join23(tempDir, `${agentName}.cant`);
|
|
35597
36144
|
copyFileSync(personaPath, cantPath);
|
|
35598
36145
|
} else {
|
|
35599
36146
|
cliOutput(
|
|
@@ -35721,7 +36268,7 @@ var packCommand = defineCommand({
|
|
|
35721
36268
|
async run({ args }) {
|
|
35722
36269
|
try {
|
|
35723
36270
|
const { existsSync: existsSync12, statSync } = await import("node:fs");
|
|
35724
|
-
const { resolve: resolve5, basename: basename2, dirname:
|
|
36271
|
+
const { resolve: resolve5, basename: basename2, dirname: dirname11 } = await import("node:path");
|
|
35725
36272
|
const { execFileSync: execFileSync6 } = await import("node:child_process");
|
|
35726
36273
|
const resolvedDir = resolve5(args.dir);
|
|
35727
36274
|
if (!existsSync12(resolvedDir) || !statSync(resolvedDir).isDirectory()) {
|
|
@@ -35738,8 +36285,8 @@ var packCommand = defineCommand({
|
|
|
35738
36285
|
process.exitCode = 4;
|
|
35739
36286
|
return;
|
|
35740
36287
|
}
|
|
35741
|
-
const { join:
|
|
35742
|
-
const personaPath =
|
|
36288
|
+
const { join: join23 } = await import("node:path");
|
|
36289
|
+
const personaPath = join23(resolvedDir, "persona.cant");
|
|
35743
36290
|
if (!existsSync12(personaPath)) {
|
|
35744
36291
|
cliOutput(
|
|
35745
36292
|
{
|
|
@@ -35757,7 +36304,7 @@ var packCommand = defineCommand({
|
|
|
35757
36304
|
const agentName = basename2(resolvedDir);
|
|
35758
36305
|
const archiveName = `${agentName}.cantz`;
|
|
35759
36306
|
const archivePath = resolve5(archiveName);
|
|
35760
|
-
const parentDir =
|
|
36307
|
+
const parentDir = dirname11(resolvedDir);
|
|
35761
36308
|
try {
|
|
35762
36309
|
execFileSync6("zip", ["-r", archivePath, agentName], {
|
|
35763
36310
|
cwd: parentDir,
|
|
@@ -35787,7 +36334,7 @@ var packCommand = defineCommand({
|
|
|
35787
36334
|
if (entry.isFile()) {
|
|
35788
36335
|
fileCount++;
|
|
35789
36336
|
} else if (entry.isDirectory()) {
|
|
35790
|
-
countFiles(
|
|
36337
|
+
countFiles(join23(dirPath, entry.name));
|
|
35791
36338
|
}
|
|
35792
36339
|
}
|
|
35793
36340
|
};
|
|
@@ -35856,8 +36403,8 @@ var createCommand = defineCommand({
|
|
|
35856
36403
|
},
|
|
35857
36404
|
async run({ args }) {
|
|
35858
36405
|
try {
|
|
35859
|
-
const { existsSync: existsSync12, mkdirSync:
|
|
35860
|
-
const { join:
|
|
36406
|
+
const { existsSync: existsSync12, mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("node:fs");
|
|
36407
|
+
const { join: join23 } = await import("node:path");
|
|
35861
36408
|
const { homedir: homedir6 } = await import("node:os");
|
|
35862
36409
|
const name = args.name;
|
|
35863
36410
|
const role = args.role;
|
|
@@ -35917,12 +36464,12 @@ var createCommand = defineCommand({
|
|
|
35917
36464
|
let targetRoot;
|
|
35918
36465
|
if (isGlobal) {
|
|
35919
36466
|
const home = homedir6();
|
|
35920
|
-
const xdgData = process.env["XDG_DATA_HOME"] ??
|
|
35921
|
-
targetRoot =
|
|
36467
|
+
const xdgData = process.env["XDG_DATA_HOME"] ?? join23(home, ".local", "share");
|
|
36468
|
+
targetRoot = join23(xdgData, "cleo", "cant", "agents");
|
|
35922
36469
|
} else {
|
|
35923
|
-
targetRoot =
|
|
36470
|
+
targetRoot = join23(process.cwd(), CLEO_DIR_NAME, CANT_AGENTS_SUBDIR);
|
|
35924
36471
|
}
|
|
35925
|
-
const agentDir =
|
|
36472
|
+
const agentDir = join23(targetRoot, name);
|
|
35926
36473
|
if (existsSync12(agentDir)) {
|
|
35927
36474
|
cliOutput(
|
|
35928
36475
|
{
|
|
@@ -35938,7 +36485,7 @@ var createCommand = defineCommand({
|
|
|
35938
36485
|
process.exitCode = 6;
|
|
35939
36486
|
return;
|
|
35940
36487
|
}
|
|
35941
|
-
|
|
36488
|
+
mkdirSync5(agentDir, { recursive: true });
|
|
35942
36489
|
const personaContent = generatePersonaCant({
|
|
35943
36490
|
name,
|
|
35944
36491
|
role,
|
|
@@ -35947,29 +36494,29 @@ var createCommand = defineCommand({
|
|
|
35947
36494
|
domain,
|
|
35948
36495
|
parent
|
|
35949
36496
|
});
|
|
35950
|
-
writeFileSync5(
|
|
36497
|
+
writeFileSync5(join23(agentDir, "persona.cant"), personaContent, "utf-8");
|
|
35951
36498
|
const manifest = generateManifest({ name, role, tier, domain });
|
|
35952
36499
|
writeFileSync5(
|
|
35953
|
-
|
|
36500
|
+
join23(agentDir, "manifest.json"),
|
|
35954
36501
|
`${JSON.stringify(manifest, null, 2)}
|
|
35955
36502
|
`,
|
|
35956
36503
|
"utf-8"
|
|
35957
36504
|
);
|
|
35958
36505
|
const createdFiles = [
|
|
35959
|
-
|
|
35960
|
-
|
|
36506
|
+
join23(agentDir, "persona.cant"),
|
|
36507
|
+
join23(agentDir, "manifest.json")
|
|
35961
36508
|
];
|
|
35962
36509
|
if (team) {
|
|
35963
36510
|
const teamConfigContent = generateTeamConfig(name, role, team);
|
|
35964
|
-
writeFileSync5(
|
|
35965
|
-
createdFiles.push(
|
|
36511
|
+
writeFileSync5(join23(agentDir, "team-config.cant"), teamConfigContent, "utf-8");
|
|
36512
|
+
createdFiles.push(join23(agentDir, "team-config.cant"));
|
|
35966
36513
|
}
|
|
35967
36514
|
if (seedBrain) {
|
|
35968
|
-
const expertiseDir =
|
|
35969
|
-
|
|
36515
|
+
const expertiseDir = join23(agentDir, "expertise");
|
|
36516
|
+
mkdirSync5(expertiseDir, { recursive: true });
|
|
35970
36517
|
const seedContent = generateMentalModelSeed(name, role, domain);
|
|
35971
|
-
writeFileSync5(
|
|
35972
|
-
createdFiles.push(
|
|
36518
|
+
writeFileSync5(join23(expertiseDir, "mental-model-seed.md"), seedContent, "utf-8");
|
|
36519
|
+
createdFiles.push(join23(expertiseDir, "mental-model-seed.md"));
|
|
35973
36520
|
try {
|
|
35974
36521
|
const { execFile: execFile2 } = await import("node:child_process");
|
|
35975
36522
|
const { promisify: promisify2 } = await import("node:util");
|
|
@@ -36067,8 +36614,8 @@ var mintCommand = defineCommand({
|
|
|
36067
36614
|
},
|
|
36068
36615
|
async run({ args }) {
|
|
36069
36616
|
try {
|
|
36070
|
-
const { existsSync: existsSync12, readFileSync: readFileSync16, mkdirSync:
|
|
36071
|
-
const { resolve: resolve5, join:
|
|
36617
|
+
const { existsSync: existsSync12, readFileSync: readFileSync16, mkdirSync: mkdirSync5 } = await import("node:fs");
|
|
36618
|
+
const { resolve: resolve5, join: join23 } = await import("node:path");
|
|
36072
36619
|
const specPath = resolve5(args.spec);
|
|
36073
36620
|
if (!existsSync12(specPath)) {
|
|
36074
36621
|
const errEnv = {
|
|
@@ -36087,8 +36634,8 @@ var mintCommand = defineCommand({
|
|
|
36087
36634
|
}
|
|
36088
36635
|
const specContent = readFileSync16(specPath, "utf-8");
|
|
36089
36636
|
const projectRoot = process.cwd();
|
|
36090
|
-
const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) :
|
|
36091
|
-
|
|
36637
|
+
const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join23(projectRoot, ".cleo", "cant", "agents");
|
|
36638
|
+
mkdirSync5(outputDir, { recursive: true });
|
|
36092
36639
|
if (args["dry-run"]) {
|
|
36093
36640
|
const preview = {
|
|
36094
36641
|
success: true,
|
|
@@ -38095,7 +38642,7 @@ var briefingCommand = defineCommand({
|
|
|
38095
38642
|
// packages/cleo/src/cli/commands/bug.ts
|
|
38096
38643
|
import { existsSync as existsSync7 } from "node:fs";
|
|
38097
38644
|
import { appendFile as appendFile2, mkdir as mkdir2, readFile as readFile2 } from "node:fs/promises";
|
|
38098
|
-
import { dirname as
|
|
38645
|
+
import { dirname as dirname5, join as join10 } from "node:path";
|
|
38099
38646
|
import { getCleoDirAbsolute as getCleoDirAbsolute2, getCleoIdentity, getConfigPath, signAuditLine } from "@cleocode/core";
|
|
38100
38647
|
init_cli();
|
|
38101
38648
|
var SEVERITY_MAP = {
|
|
@@ -38148,8 +38695,8 @@ async function appendSignedBugSeverity(record) {
|
|
|
38148
38695
|
const sig = await signAuditLine(id, canonical);
|
|
38149
38696
|
const line = `${JSON.stringify({ ...full, _sig: sig })}
|
|
38150
38697
|
`;
|
|
38151
|
-
const auditPath =
|
|
38152
|
-
await mkdir2(
|
|
38698
|
+
const auditPath = join10(getCleoDirAbsolute2(), "audit", "bug-severity.jsonl");
|
|
38699
|
+
await mkdir2(dirname5(auditPath), { recursive: true });
|
|
38153
38700
|
await appendFile2(auditPath, line, { encoding: "utf-8" });
|
|
38154
38701
|
}
|
|
38155
38702
|
var bugCommand = defineCommand({
|
|
@@ -38261,8 +38808,8 @@ var cancelCommand = defineCommand({
|
|
|
38261
38808
|
});
|
|
38262
38809
|
|
|
38263
38810
|
// packages/cleo/src/cli/commands/cant.ts
|
|
38264
|
-
import { existsSync as existsSync8, mkdirSync, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "node:fs";
|
|
38265
|
-
import { dirname as
|
|
38811
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "node:fs";
|
|
38812
|
+
import { dirname as dirname6, isAbsolute, join as join11, resolve as resolve3 } from "node:path";
|
|
38266
38813
|
init_renderers();
|
|
38267
38814
|
function resolveFilePath(file) {
|
|
38268
38815
|
return isAbsolute(file) ? file : resolve3(process.cwd(), file);
|
|
@@ -38422,8 +38969,8 @@ var cantMigrateCommand = defineCommand({
|
|
|
38422
38969
|
const projectRoot = process.cwd();
|
|
38423
38970
|
let written = 0;
|
|
38424
38971
|
for (const outputFile of result.outputFiles) {
|
|
38425
|
-
const outputPath = isAbsolute(outputFile.path) ? outputFile.path :
|
|
38426
|
-
|
|
38972
|
+
const outputPath = isAbsolute(outputFile.path) ? outputFile.path : join11(projectRoot, outputFile.path);
|
|
38973
|
+
mkdirSync2(dirname6(outputPath), { recursive: true });
|
|
38427
38974
|
writeFileSync2(outputPath, outputFile.content, "utf-8");
|
|
38428
38975
|
written++;
|
|
38429
38976
|
}
|
|
@@ -39021,9 +39568,9 @@ var codeCommand = defineCommand({
|
|
|
39021
39568
|
async run({ args }) {
|
|
39022
39569
|
await requireTreeSitter();
|
|
39023
39570
|
const { smartOutline } = await import("@cleocode/core/internal");
|
|
39024
|
-
const { join:
|
|
39571
|
+
const { join: join23 } = await import("node:path");
|
|
39025
39572
|
const root = process.cwd();
|
|
39026
|
-
const absPath = args.file.startsWith("/") ? args.file :
|
|
39573
|
+
const absPath = args.file.startsWith("/") ? args.file : join23(root, args.file);
|
|
39027
39574
|
const result = smartOutline(absPath, root);
|
|
39028
39575
|
if (result.errors.length > 0 && result.symbols.length === 0) {
|
|
39029
39576
|
console.error(`Error: ${result.errors.join(", ")}`);
|
|
@@ -39114,9 +39661,9 @@ var codeCommand = defineCommand({
|
|
|
39114
39661
|
async run({ args }) {
|
|
39115
39662
|
await requireTreeSitter();
|
|
39116
39663
|
const { smartUnfold } = await import("@cleocode/core/internal");
|
|
39117
|
-
const { join:
|
|
39664
|
+
const { join: join23 } = await import("node:path");
|
|
39118
39665
|
const root = process.cwd();
|
|
39119
|
-
const absPath = args.file.startsWith("/") ? args.file :
|
|
39666
|
+
const absPath = args.file.startsWith("/") ? args.file : join23(root, args.file);
|
|
39120
39667
|
const result = smartUnfold(absPath, args.symbol, root);
|
|
39121
39668
|
if (!result.found) {
|
|
39122
39669
|
console.error(`Symbol "${args.symbol}" not found in ${args.file}`);
|
|
@@ -40159,7 +40706,7 @@ var currentCommand = defineCommand({
|
|
|
40159
40706
|
|
|
40160
40707
|
// packages/cleo/src/cli/commands/daemon.ts
|
|
40161
40708
|
import { homedir as homedir2 } from "node:os";
|
|
40162
|
-
import { join as
|
|
40709
|
+
import { join as join12 } from "node:path";
|
|
40163
40710
|
import { getGCDaemonStatus, spawnGCDaemon, stopGCDaemon } from "@cleocode/core/gc/daemon.js";
|
|
40164
40711
|
async function showDaemonStatus(cleoDir, json2) {
|
|
40165
40712
|
try {
|
|
@@ -40212,7 +40759,7 @@ var startCommand3 = defineCommand({
|
|
|
40212
40759
|
}
|
|
40213
40760
|
},
|
|
40214
40761
|
async run({ args }) {
|
|
40215
|
-
const cleoDir = args["cleo-dir"] ??
|
|
40762
|
+
const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
|
|
40216
40763
|
const jsonMode = args.json ?? false;
|
|
40217
40764
|
try {
|
|
40218
40765
|
const status = await getGCDaemonStatus(cleoDir);
|
|
@@ -40243,7 +40790,7 @@ var startCommand3 = defineCommand({
|
|
|
40243
40790
|
} else {
|
|
40244
40791
|
process.stdout.write(`GC daemon started (PID ${pid})
|
|
40245
40792
|
`);
|
|
40246
|
-
process.stdout.write(`Logs: ${
|
|
40793
|
+
process.stdout.write(`Logs: ${join12(cleoDir, "logs", "gc.log")}
|
|
40247
40794
|
`);
|
|
40248
40795
|
}
|
|
40249
40796
|
} catch (err) {
|
|
@@ -40272,7 +40819,7 @@ var stopCommand3 = defineCommand({
|
|
|
40272
40819
|
}
|
|
40273
40820
|
},
|
|
40274
40821
|
async run({ args }) {
|
|
40275
|
-
const cleoDir = args["cleo-dir"] ??
|
|
40822
|
+
const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
|
|
40276
40823
|
const jsonMode = args.json ?? false;
|
|
40277
40824
|
try {
|
|
40278
40825
|
const stopResult = await stopGCDaemon(cleoDir);
|
|
@@ -40318,7 +40865,7 @@ var statusCommand4 = defineCommand({
|
|
|
40318
40865
|
}
|
|
40319
40866
|
},
|
|
40320
40867
|
async run({ args }) {
|
|
40321
|
-
const cleoDir = args["cleo-dir"] ??
|
|
40868
|
+
const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
|
|
40322
40869
|
await showDaemonStatus(cleoDir, args.json ?? false);
|
|
40323
40870
|
}
|
|
40324
40871
|
});
|
|
@@ -40344,7 +40891,7 @@ var daemonCommand = defineCommand({
|
|
|
40344
40891
|
},
|
|
40345
40892
|
async run({ args, cmd, rawArgs }) {
|
|
40346
40893
|
if (isSubCommandDispatch(rawArgs, cmd.subCommands)) return;
|
|
40347
|
-
const cleoDir = args["cleo-dir"] ??
|
|
40894
|
+
const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
|
|
40348
40895
|
await showDaemonStatus(cleoDir, args.json ?? false);
|
|
40349
40896
|
}
|
|
40350
40897
|
});
|
|
@@ -40696,16 +41243,16 @@ var detectCommand2 = defineCommand({
|
|
|
40696
41243
|
// packages/cleo/src/cli/commands/detect-drift.ts
|
|
40697
41244
|
init_src();
|
|
40698
41245
|
import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync11 } from "node:fs";
|
|
40699
|
-
import { dirname as
|
|
41246
|
+
import { dirname as dirname7, join as join13 } from "node:path";
|
|
40700
41247
|
init_paths();
|
|
40701
41248
|
init_renderers();
|
|
40702
41249
|
function findProjectRoot() {
|
|
40703
41250
|
let currentDir = process.cwd();
|
|
40704
41251
|
while (currentDir !== "/") {
|
|
40705
|
-
if (existsSync9(
|
|
41252
|
+
if (existsSync9(join13(currentDir, "package.json"))) {
|
|
40706
41253
|
return currentDir;
|
|
40707
41254
|
}
|
|
40708
|
-
const parent =
|
|
41255
|
+
const parent = dirname7(currentDir);
|
|
40709
41256
|
if (parent === currentDir) break;
|
|
40710
41257
|
currentDir = parent;
|
|
40711
41258
|
}
|
|
@@ -40718,8 +41265,8 @@ var detectDriftCommand = defineCommand({
|
|
|
40718
41265
|
},
|
|
40719
41266
|
async run() {
|
|
40720
41267
|
const projectRoot = findProjectRoot();
|
|
40721
|
-
const isCleoRepo = existsSync9(
|
|
40722
|
-
const cleoSrcRoot = isCleoRepo ?
|
|
41268
|
+
const isCleoRepo = existsSync9(join13(projectRoot, "packages", "cleo", "src"));
|
|
41269
|
+
const cleoSrcRoot = isCleoRepo ? join13(projectRoot, "packages", "cleo", "src") : join13(projectRoot, "src");
|
|
40723
41270
|
const safeRead = (filePath) => {
|
|
40724
41271
|
try {
|
|
40725
41272
|
return readFileSync11(filePath, "utf-8");
|
|
@@ -40733,7 +41280,7 @@ var detectDriftCommand = defineCommand({
|
|
|
40733
41280
|
checks: [],
|
|
40734
41281
|
recommendations: []
|
|
40735
41282
|
};
|
|
40736
|
-
const injPath =
|
|
41283
|
+
const injPath = join13(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
|
|
40737
41284
|
if (existsSync9(injPath)) {
|
|
40738
41285
|
const content = safeRead(injPath);
|
|
40739
41286
|
userResult.checks.push({
|
|
@@ -40785,9 +41332,9 @@ var detectDriftCommand = defineCommand({
|
|
|
40785
41332
|
}
|
|
40786
41333
|
};
|
|
40787
41334
|
try {
|
|
40788
|
-
const specPath =
|
|
40789
|
-
const registryPath =
|
|
40790
|
-
const dispatchDomainsDir =
|
|
41335
|
+
const specPath = join13(projectRoot, "docs", "specs", "CLEO-OPERATION-CONSTITUTION.md");
|
|
41336
|
+
const registryPath = join13(cleoSrcRoot, "dispatch", "registry.ts");
|
|
41337
|
+
const dispatchDomainsDir = join13(cleoSrcRoot, "dispatch", "domains");
|
|
40791
41338
|
if (!existsSync9(specPath)) {
|
|
40792
41339
|
addCheck("Gateway-to-spec sync", "fail", "CLEO-OPERATION-CONSTITUTION.md missing", [
|
|
40793
41340
|
{
|
|
@@ -40856,8 +41403,8 @@ var detectDriftCommand = defineCommand({
|
|
|
40856
41403
|
]);
|
|
40857
41404
|
}
|
|
40858
41405
|
try {
|
|
40859
|
-
const cliDir =
|
|
40860
|
-
const coreDir = isCleoRepo ?
|
|
41406
|
+
const cliDir = join13(cleoSrcRoot, "cli", "commands");
|
|
41407
|
+
const coreDir = isCleoRepo ? join13(projectRoot, "packages", "core", "src") : join13(projectRoot, "src", "core");
|
|
40861
41408
|
if (!existsSync9(cliDir)) {
|
|
40862
41409
|
addCheck("CLI-to-core sync", "fail", "CLI commands directory missing", [
|
|
40863
41410
|
{
|
|
@@ -40884,7 +41431,7 @@ var detectDriftCommand = defineCommand({
|
|
|
40884
41431
|
addCheck("CLI-to-core sync", "fail", `Error: ${getErrorMessage(e)}`);
|
|
40885
41432
|
}
|
|
40886
41433
|
try {
|
|
40887
|
-
const domainsDir =
|
|
41434
|
+
const domainsDir = join13(cleoSrcRoot, "dispatch", "domains");
|
|
40888
41435
|
if (!existsSync9(domainsDir)) {
|
|
40889
41436
|
addCheck("Domain handler coverage", "fail", "Dispatch domains directory missing", [
|
|
40890
41437
|
{
|
|
@@ -40902,7 +41449,7 @@ var detectDriftCommand = defineCommand({
|
|
|
40902
41449
|
addCheck("Domain handler coverage", "fail", `Error: ${getErrorMessage(e)}`);
|
|
40903
41450
|
}
|
|
40904
41451
|
try {
|
|
40905
|
-
const matrixPath =
|
|
41452
|
+
const matrixPath = join13(cleoSrcRoot, "dispatch", "lib", "capability-matrix.ts");
|
|
40906
41453
|
if (!existsSync9(matrixPath)) {
|
|
40907
41454
|
addCheck("Capability matrix", "fail", "Capability matrix missing", [
|
|
40908
41455
|
{
|
|
@@ -40919,7 +41466,7 @@ var detectDriftCommand = defineCommand({
|
|
|
40919
41466
|
addCheck("Capability matrix", "fail", `Error: ${getErrorMessage(e)}`);
|
|
40920
41467
|
}
|
|
40921
41468
|
try {
|
|
40922
|
-
const schemaPath =
|
|
41469
|
+
const schemaPath = join13(projectRoot, "src", "store", "schema.ts");
|
|
40923
41470
|
if (!existsSync9(schemaPath)) {
|
|
40924
41471
|
addCheck("Schema validation", "fail", "Schema definition missing", [
|
|
40925
41472
|
{
|
|
@@ -40954,8 +41501,8 @@ var detectDriftCommand = defineCommand({
|
|
|
40954
41501
|
addCheck("Schema validation", "fail", `Error: ${getErrorMessage(e)}`);
|
|
40955
41502
|
}
|
|
40956
41503
|
try {
|
|
40957
|
-
const visionPath =
|
|
40958
|
-
const specPath =
|
|
41504
|
+
const visionPath = join13(projectRoot, "docs", "concepts", "CLEO-VISION.md");
|
|
41505
|
+
const specPath = join13(projectRoot, "docs", "specs", "CLEO-PORTABLE-PROJECT-BRAIN-SPEC.md");
|
|
40959
41506
|
const issues = [];
|
|
40960
41507
|
if (!existsSync9(visionPath)) {
|
|
40961
41508
|
issues.push({
|
|
@@ -41010,7 +41557,7 @@ var detectDriftCommand = defineCommand({
|
|
|
41010
41557
|
addCheck("Canonical identity", "fail", `Error: ${getErrorMessage(e)}`);
|
|
41011
41558
|
}
|
|
41012
41559
|
try {
|
|
41013
|
-
const injectionPath =
|
|
41560
|
+
const injectionPath = join13(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
|
|
41014
41561
|
if (!existsSync9(injectionPath)) {
|
|
41015
41562
|
addCheck("Agent injection", "fail", "Agent injection template missing", [
|
|
41016
41563
|
{
|
|
@@ -41040,7 +41587,7 @@ var detectDriftCommand = defineCommand({
|
|
|
41040
41587
|
addCheck("Agent injection", "fail", `Error: ${getErrorMessage(e)}`);
|
|
41041
41588
|
}
|
|
41042
41589
|
try {
|
|
41043
|
-
const exitCodesPath =
|
|
41590
|
+
const exitCodesPath = join13(cleoSrcRoot, "dispatch", "lib", "exit-codes.ts");
|
|
41044
41591
|
if (!existsSync9(exitCodesPath)) {
|
|
41045
41592
|
addCheck("Exit codes", "fail", "Exit codes definition missing", [
|
|
41046
41593
|
{
|
|
@@ -41173,7 +41720,7 @@ var diagnosticsCommand = defineCommand({
|
|
|
41173
41720
|
// packages/cleo/src/cli/commands/docs.ts
|
|
41174
41721
|
init_src();
|
|
41175
41722
|
import { mkdir as mkdir3, readdir, readFile as readFile3, writeFile } from "node:fs/promises";
|
|
41176
|
-
import { dirname as
|
|
41723
|
+
import { dirname as dirname8, isAbsolute as isAbsolute2, join as join14, resolve as resolve4 } from "node:path";
|
|
41177
41724
|
import {
|
|
41178
41725
|
buildDocsGraph,
|
|
41179
41726
|
CleoError as CleoError3,
|
|
@@ -41191,7 +41738,7 @@ import {
|
|
|
41191
41738
|
init_cli();
|
|
41192
41739
|
init_renderers();
|
|
41193
41740
|
async function getScriptNames(projectRoot) {
|
|
41194
|
-
const scriptsDir =
|
|
41741
|
+
const scriptsDir = join14(projectRoot, "scripts");
|
|
41195
41742
|
try {
|
|
41196
41743
|
const files = await readdir(scriptsDir);
|
|
41197
41744
|
return files.filter((f) => f.endsWith(".sh")).map((f) => f.replace(".sh", "")).sort();
|
|
@@ -41200,7 +41747,7 @@ async function getScriptNames(projectRoot) {
|
|
|
41200
41747
|
}
|
|
41201
41748
|
}
|
|
41202
41749
|
async function getIndexedCommands(projectRoot) {
|
|
41203
|
-
const indexPath =
|
|
41750
|
+
const indexPath = join14(projectRoot, "docs", "commands", "COMMANDS-INDEX.json");
|
|
41204
41751
|
const index = await readJson(indexPath);
|
|
41205
41752
|
if (!index) return [];
|
|
41206
41753
|
return index.commands.map((c) => c.name).sort();
|
|
@@ -41233,7 +41780,7 @@ async function runGapCheck(_projectRoot, filterId) {
|
|
|
41233
41780
|
const reviewFiles = files.filter((f) => f.endsWith(".md"));
|
|
41234
41781
|
for (const file of reviewFiles) {
|
|
41235
41782
|
if (filterId && !file.includes(filterId)) continue;
|
|
41236
|
-
const filePath =
|
|
41783
|
+
const filePath = join14(reviewDir, file);
|
|
41237
41784
|
const content = await readFile3(filePath, "utf-8");
|
|
41238
41785
|
const taskMatch = file.match(/^(T\d+)/);
|
|
41239
41786
|
const taskId = taskMatch ? taskMatch[1] : "UNKNOWN";
|
|
@@ -41480,7 +42027,7 @@ var exportCommand4 = defineCommand({
|
|
|
41480
42027
|
let writtenPath;
|
|
41481
42028
|
if (typeof args.out === "string" && args.out.length > 0) {
|
|
41482
42029
|
const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
|
|
41483
|
-
await mkdir3(
|
|
42030
|
+
await mkdir3(dirname8(outPath), { recursive: true });
|
|
41484
42031
|
await writeFile(outPath, result.markdown, "utf8");
|
|
41485
42032
|
writtenPath = outPath;
|
|
41486
42033
|
}
|
|
@@ -41595,7 +42142,7 @@ var mergeCommand = defineCommand({
|
|
|
41595
42142
|
});
|
|
41596
42143
|
if (typeof args.out === "string" && args.out.length > 0) {
|
|
41597
42144
|
const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
|
|
41598
|
-
await mkdir3(
|
|
42145
|
+
await mkdir3(dirname8(outPath), { recursive: true });
|
|
41599
42146
|
await writeFile(outPath, result.merged, "utf8");
|
|
41600
42147
|
process.stderr.write(`Wrote merged content to ${outPath}
|
|
41601
42148
|
`);
|
|
@@ -41667,7 +42214,7 @@ var graphCommand = defineCommand({
|
|
|
41667
42214
|
}
|
|
41668
42215
|
if (typeof args.out === "string" && args.out.length > 0) {
|
|
41669
42216
|
const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
|
|
41670
|
-
await mkdir3(
|
|
42217
|
+
await mkdir3(dirname8(outPath), { recursive: true });
|
|
41671
42218
|
await writeFile(outPath, output, "utf8");
|
|
41672
42219
|
process.stderr.write(`Wrote graph to ${outPath}
|
|
41673
42220
|
`);
|
|
@@ -42591,7 +43138,7 @@ var findCommand2 = defineCommand({
|
|
|
42591
43138
|
|
|
42592
43139
|
// packages/cleo/src/cli/commands/gc.ts
|
|
42593
43140
|
import { homedir as homedir3 } from "node:os";
|
|
42594
|
-
import { join as
|
|
43141
|
+
import { join as join15 } from "node:path";
|
|
42595
43142
|
import { runGC } from "@cleocode/core/gc/runner.js";
|
|
42596
43143
|
import { readGCState } from "@cleocode/core/gc/state.js";
|
|
42597
43144
|
function formatBytes(bytes) {
|
|
@@ -42623,7 +43170,7 @@ var runCommand2 = defineCommand({
|
|
|
42623
43170
|
}
|
|
42624
43171
|
},
|
|
42625
43172
|
async run({ args }) {
|
|
42626
|
-
const cleoDir = args["cleo-dir"] ??
|
|
43173
|
+
const cleoDir = args["cleo-dir"] ?? join15(homedir3(), ".cleo");
|
|
42627
43174
|
const dryRun = args["dry-run"];
|
|
42628
43175
|
try {
|
|
42629
43176
|
const gcResult = await runGC({ cleoDir, dryRun });
|
|
@@ -42678,8 +43225,8 @@ var statusCommand6 = defineCommand({
|
|
|
42678
43225
|
}
|
|
42679
43226
|
},
|
|
42680
43227
|
async run({ args }) {
|
|
42681
|
-
const cleoDir = args["cleo-dir"] ??
|
|
42682
|
-
const statePath =
|
|
43228
|
+
const cleoDir = args["cleo-dir"] ?? join15(homedir3(), ".cleo");
|
|
43229
|
+
const statePath = join15(cleoDir, "gc-state.json");
|
|
42683
43230
|
try {
|
|
42684
43231
|
const state = await readGCState(statePath);
|
|
42685
43232
|
const result = { success: true, data: state };
|
|
@@ -42738,8 +43285,8 @@ var gcCommand = defineCommand({
|
|
|
42738
43285
|
// packages/cleo/src/cli/commands/generate-changelog.ts
|
|
42739
43286
|
init_src();
|
|
42740
43287
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
42741
|
-
import { existsSync as existsSync10, mkdirSync as
|
|
42742
|
-
import { dirname as
|
|
43288
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync3 } from "node:fs";
|
|
43289
|
+
import { dirname as dirname9, join as join16 } from "node:path";
|
|
42743
43290
|
import { CleoError as CleoError4, formatError as formatError6, getConfigPath as getConfigPath2, getProjectRoot as getProjectRoot21 } from "@cleocode/core";
|
|
42744
43291
|
init_renderers();
|
|
42745
43292
|
function getChangelogSource(cwd) {
|
|
@@ -42898,7 +43445,7 @@ var generateChangelogCommand = defineCommand({
|
|
|
42898
43445
|
const targetPlatform = args.platform;
|
|
42899
43446
|
const dryRun = args["dry-run"] === true;
|
|
42900
43447
|
const sourceFile = getChangelogSource();
|
|
42901
|
-
const sourcePath =
|
|
43448
|
+
const sourcePath = join16(getProjectRoot21(), sourceFile);
|
|
42902
43449
|
if (!existsSync10(sourcePath)) {
|
|
42903
43450
|
throw new CleoError4(4 /* NOT_FOUND */, `Changelog source not found: ${sourcePath}`);
|
|
42904
43451
|
}
|
|
@@ -42911,8 +43458,8 @@ var generateChangelogCommand = defineCommand({
|
|
|
42911
43458
|
const outputPath = platformConfig?.path ?? getDefaultOutputPath(targetPlatform);
|
|
42912
43459
|
const content = generateForPlatform(targetPlatform, sourceContent, repoSlug, limit);
|
|
42913
43460
|
if (!dryRun) {
|
|
42914
|
-
const fullPath =
|
|
42915
|
-
|
|
43461
|
+
const fullPath = join16(getProjectRoot21(), outputPath);
|
|
43462
|
+
mkdirSync3(dirname9(fullPath), { recursive: true });
|
|
42916
43463
|
writeFileSync3(fullPath, content, "utf-8");
|
|
42917
43464
|
}
|
|
42918
43465
|
results.push({ platform: targetPlatform, path: outputPath, written: !dryRun });
|
|
@@ -42932,8 +43479,8 @@ var generateChangelogCommand = defineCommand({
|
|
|
42932
43479
|
limit
|
|
42933
43480
|
);
|
|
42934
43481
|
if (!dryRun) {
|
|
42935
|
-
const fullPath =
|
|
42936
|
-
|
|
43482
|
+
const fullPath = join16(getProjectRoot21(), platformConfig.path);
|
|
43483
|
+
mkdirSync3(dirname9(fullPath), { recursive: true });
|
|
42937
43484
|
writeFileSync3(fullPath, content, "utf-8");
|
|
42938
43485
|
}
|
|
42939
43486
|
results.push({
|
|
@@ -44342,9 +44889,9 @@ var mapCommand = defineCommand({
|
|
|
44342
44889
|
|
|
44343
44890
|
// packages/cleo/src/cli/commands/memory.ts
|
|
44344
44891
|
import { createHash as createHash3 } from "node:crypto";
|
|
44345
|
-
import { existsSync as existsSync11, mkdirSync as
|
|
44892
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync4 } from "node:fs";
|
|
44346
44893
|
import { homedir as homedir4 } from "node:os";
|
|
44347
|
-
import { join as
|
|
44894
|
+
import { join as join17 } from "node:path";
|
|
44348
44895
|
import {
|
|
44349
44896
|
getBrainDb as getBrainDb2,
|
|
44350
44897
|
getBrainNativeDb as getBrainNativeDb3,
|
|
@@ -44397,7 +44944,7 @@ function loadImportHashes(stateFile) {
|
|
|
44397
44944
|
}
|
|
44398
44945
|
function saveImportHashes(stateFile, hashes) {
|
|
44399
44946
|
const dir = stateFile.slice(0, stateFile.lastIndexOf("/"));
|
|
44400
|
-
if (!existsSync11(dir))
|
|
44947
|
+
if (!existsSync11(dir)) mkdirSync4(dir, { recursive: true });
|
|
44401
44948
|
writeFileSync4(stateFile, JSON.stringify({ hashes: [...hashes] }, null, 2), "utf-8");
|
|
44402
44949
|
}
|
|
44403
44950
|
var storeCommand = defineCommand({
|
|
@@ -45642,11 +46189,11 @@ var importCommand3 = defineCommand({
|
|
|
45642
46189
|
}
|
|
45643
46190
|
},
|
|
45644
46191
|
async run({ args }) {
|
|
45645
|
-
const sourceDir = args.from ??
|
|
46192
|
+
const sourceDir = args.from ?? join17(homedir4(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
|
|
45646
46193
|
const isDryRun = !!args["dry-run"];
|
|
45647
46194
|
const isJson = !!args.json;
|
|
45648
46195
|
const projectRoot = getProjectRoot22();
|
|
45649
|
-
const stateFile =
|
|
46196
|
+
const stateFile = join17(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
|
|
45650
46197
|
if (!existsSync11(sourceDir)) {
|
|
45651
46198
|
const msg = `Source directory not found: ${sourceDir}`;
|
|
45652
46199
|
if (isJson) {
|
|
@@ -45656,7 +46203,7 @@ var importCommand3 = defineCommand({
|
|
|
45656
46203
|
}
|
|
45657
46204
|
process.exit(1);
|
|
45658
46205
|
}
|
|
45659
|
-
const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) =>
|
|
46206
|
+
const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) => join17(sourceDir, f));
|
|
45660
46207
|
const importedHashes = isDryRun ? /* @__PURE__ */ new Set() : loadImportHashes(stateFile);
|
|
45661
46208
|
const stats = { total: files.length, imported: 0, skipped: 0, errors: 0 };
|
|
45662
46209
|
const importedEntries = [];
|
|
@@ -54932,7 +55479,7 @@ var schemaCommand = defineCommand({
|
|
|
54932
55479
|
init_src();
|
|
54933
55480
|
import { execFile } from "node:child_process";
|
|
54934
55481
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
54935
|
-
import { join as
|
|
55482
|
+
import { join as join18 } from "node:path";
|
|
54936
55483
|
import * as readline2 from "node:readline";
|
|
54937
55484
|
import { promisify } from "node:util";
|
|
54938
55485
|
import {
|
|
@@ -54951,7 +55498,7 @@ var GITHUB_REPO = BUILD_CONFIG2.repository.fullName;
|
|
|
54951
55498
|
async function getCurrentVersion() {
|
|
54952
55499
|
const cleoHome = getCleoHome2();
|
|
54953
55500
|
try {
|
|
54954
|
-
const content = await readFile4(
|
|
55501
|
+
const content = await readFile4(join18(cleoHome, "VERSION"), "utf-8");
|
|
54955
55502
|
return (content.split("\n")[0] ?? "unknown").trim();
|
|
54956
55503
|
} catch {
|
|
54957
55504
|
return "unknown";
|
|
@@ -55005,7 +55552,7 @@ async function writeRuntimeVersionMetadata(mode, source, version) {
|
|
|
55005
55552
|
];
|
|
55006
55553
|
await import("node:fs/promises").then(
|
|
55007
55554
|
({ writeFile: writeFile3, mkdir: mkdir5 }) => mkdir5(cleoHome, { recursive: true }).then(
|
|
55008
|
-
() => writeFile3(
|
|
55555
|
+
() => writeFile3(join18(cleoHome, "VERSION"), `${lines.join("\n")}
|
|
55009
55556
|
`, "utf-8")
|
|
55010
55557
|
)
|
|
55011
55558
|
);
|
|
@@ -55406,7 +55953,7 @@ async function runPostUpdateDiagnostics(opts) {
|
|
|
55406
55953
|
}
|
|
55407
55954
|
|
|
55408
55955
|
// packages/cleo/src/cli/commands/sentient.ts
|
|
55409
|
-
import { join as
|
|
55956
|
+
import { join as join19 } from "node:path";
|
|
55410
55957
|
import { cwd as processCwd } from "node:process";
|
|
55411
55958
|
import {
|
|
55412
55959
|
getSentientDaemonStatus,
|
|
@@ -55477,7 +56024,7 @@ var startSub = defineCommand({
|
|
|
55477
56024
|
return;
|
|
55478
56025
|
}
|
|
55479
56026
|
if (dryRun) {
|
|
55480
|
-
const statePath2 =
|
|
56027
|
+
const statePath2 = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55481
56028
|
const outcome = await safeRunTick({ projectRoot, statePath: statePath2, dryRun: true });
|
|
55482
56029
|
emitSuccess(
|
|
55483
56030
|
{ dryRun: true, outcome },
|
|
@@ -55611,7 +56158,7 @@ var tickSub = defineCommand({
|
|
|
55611
56158
|
const jsonMode = args.json === true;
|
|
55612
56159
|
const dryRun = args["dry-run"] === true;
|
|
55613
56160
|
try {
|
|
55614
|
-
const statePath =
|
|
56161
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55615
56162
|
const outcome = await safeRunTick({ projectRoot, statePath, dryRun });
|
|
55616
56163
|
emitSuccess(
|
|
55617
56164
|
{ outcome, dryRun },
|
|
@@ -55680,7 +56227,7 @@ var proposeAcceptSub = defineCommand({
|
|
|
55680
56227
|
return;
|
|
55681
56228
|
}
|
|
55682
56229
|
await db.update(tasks).set({ status: "pending", updatedAt: now }).where(eq2(tasks.id, id)).run();
|
|
55683
|
-
const statePath =
|
|
56230
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55684
56231
|
const state = await readSentientState(statePath);
|
|
55685
56232
|
await patchSentientState(statePath, {
|
|
55686
56233
|
tier2Stats: {
|
|
@@ -55732,7 +56279,7 @@ var proposeRejectSub = defineCommand({
|
|
|
55732
56279
|
return;
|
|
55733
56280
|
}
|
|
55734
56281
|
await db.update(tasks).set({ status: "cancelled", cancellationReason: reason, cancelledAt: now, updatedAt: now }).where(eq2(tasks.id, id)).run();
|
|
55735
|
-
const statePath =
|
|
56282
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55736
56283
|
const state = await readSentientState(statePath);
|
|
55737
56284
|
await patchSentientState(statePath, {
|
|
55738
56285
|
tier2Stats: {
|
|
@@ -55777,7 +56324,7 @@ var proposeRunSub = defineCommand({
|
|
|
55777
56324
|
const projectRoot = resolveProjectRoot7(args.project);
|
|
55778
56325
|
const jsonMode = args.json === true;
|
|
55779
56326
|
try {
|
|
55780
|
-
const statePath =
|
|
56327
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55781
56328
|
const outcome = await safeRunProposeTick({ projectRoot, statePath });
|
|
55782
56329
|
emitSuccess(
|
|
55783
56330
|
{ outcome },
|
|
@@ -55797,7 +56344,7 @@ var proposeEnableSub = defineCommand({
|
|
|
55797
56344
|
const projectRoot = resolveProjectRoot7(args.project);
|
|
55798
56345
|
const jsonMode = args.json === true;
|
|
55799
56346
|
try {
|
|
55800
|
-
const statePath =
|
|
56347
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55801
56348
|
const updated = await patchSentientState(statePath, { tier2Enabled: true });
|
|
55802
56349
|
emitSuccess({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals enabled");
|
|
55803
56350
|
} catch (err) {
|
|
@@ -55816,7 +56363,7 @@ var proposeDisableSub = defineCommand({
|
|
|
55816
56363
|
const projectRoot = resolveProjectRoot7(args.project);
|
|
55817
56364
|
const jsonMode = args.json === true;
|
|
55818
56365
|
try {
|
|
55819
|
-
const statePath =
|
|
56366
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55820
56367
|
const updated = await patchSentientState(statePath, { tier2Enabled: false });
|
|
55821
56368
|
emitSuccess({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals disabled");
|
|
55822
56369
|
} catch (err) {
|
|
@@ -55847,7 +56394,7 @@ var proposeSub = defineCommand({
|
|
|
55847
56394
|
const projectRoot = resolveProjectRoot7(args.project);
|
|
55848
56395
|
const jsonMode = args.json === true;
|
|
55849
56396
|
try {
|
|
55850
|
-
const statePath =
|
|
56397
|
+
const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
|
|
55851
56398
|
const state = await readSentientState(statePath);
|
|
55852
56399
|
emitSuccess(
|
|
55853
56400
|
{
|
|
@@ -57922,7 +58469,7 @@ var tokenCommand = defineCommand({
|
|
|
57922
58469
|
|
|
57923
58470
|
// packages/cleo/src/cli/commands/transcript.ts
|
|
57924
58471
|
import { homedir as homedir5 } from "node:os";
|
|
57925
|
-
import { join as
|
|
58472
|
+
import { join as join20 } from "node:path";
|
|
57926
58473
|
import { getProjectRoot as getProjectRoot27 } from "@cleocode/core";
|
|
57927
58474
|
import {
|
|
57928
58475
|
parseDurationMs,
|
|
@@ -57980,7 +58527,7 @@ var scanCommand = defineCommand({
|
|
|
57980
58527
|
}
|
|
57981
58528
|
return;
|
|
57982
58529
|
}
|
|
57983
|
-
const projectsDir = args["projects-dir"] ??
|
|
58530
|
+
const projectsDir = args["projects-dir"] ?? join20(homedir5(), ".claude", "projects");
|
|
57984
58531
|
try {
|
|
57985
58532
|
const result = await scanTranscripts(projectsDir);
|
|
57986
58533
|
const envelope = {
|
|
@@ -58365,7 +58912,7 @@ var pruneCommand = defineCommand({
|
|
|
58365
58912
|
process.exit(2);
|
|
58366
58913
|
return;
|
|
58367
58914
|
}
|
|
58368
|
-
const projectsDir = args["projects-dir"] ??
|
|
58915
|
+
const projectsDir = args["projects-dir"] ?? join20(homedir5(), ".claude", "projects");
|
|
58369
58916
|
try {
|
|
58370
58917
|
const pruneResult = await pruneTranscripts({
|
|
58371
58918
|
olderThanMs,
|
|
@@ -58791,7 +59338,7 @@ var verifyCommand2 = defineCommand({
|
|
|
58791
59338
|
init_src();
|
|
58792
59339
|
import { execFileSync as execFileSync5, spawn } from "node:child_process";
|
|
58793
59340
|
import { mkdir as mkdir4, open, readFile as readFile5, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
58794
|
-
import { join as
|
|
59341
|
+
import { join as join21 } from "node:path";
|
|
58795
59342
|
import { CleoError as CleoError12, formatError as formatError14, getCleoHome as getCleoHome3 } from "@cleocode/core";
|
|
58796
59343
|
init_renderers();
|
|
58797
59344
|
var DEFAULT_PORT = 3456;
|
|
@@ -58799,10 +59346,10 @@ var DEFAULT_HOST = "127.0.0.1";
|
|
|
58799
59346
|
function getWebPaths() {
|
|
58800
59347
|
const cleoHome = getCleoHome3();
|
|
58801
59348
|
return {
|
|
58802
|
-
pidFile:
|
|
58803
|
-
configFile:
|
|
58804
|
-
logDir:
|
|
58805
|
-
logFile:
|
|
59349
|
+
pidFile: join21(cleoHome, "web-server.pid"),
|
|
59350
|
+
configFile: join21(cleoHome, "web-server.json"),
|
|
59351
|
+
logDir: join21(cleoHome, "logs"),
|
|
59352
|
+
logFile: join21(cleoHome, "logs", "web-server.log")
|
|
58806
59353
|
};
|
|
58807
59354
|
}
|
|
58808
59355
|
function isProcessRunning(pid) {
|
|
@@ -58841,7 +59388,7 @@ async function startWebServer(port, host) {
|
|
|
58841
59388
|
throw new CleoError12(1 /* GENERAL_ERROR */, `Server already running (PID: ${status.pid})`);
|
|
58842
59389
|
}
|
|
58843
59390
|
const projectRoot = process.env["CLEO_ROOT"] ?? process.cwd();
|
|
58844
|
-
const studioDir = process.env["CLEO_STUDIO_DIR"] ??
|
|
59391
|
+
const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join21(projectRoot, "packages", "studio", "build");
|
|
58845
59392
|
await mkdir4(logDir, { recursive: true });
|
|
58846
59393
|
await writeFile2(
|
|
58847
59394
|
configFile,
|
|
@@ -58851,7 +59398,7 @@ async function startWebServer(port, host) {
|
|
|
58851
59398
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
58852
59399
|
})
|
|
58853
59400
|
);
|
|
58854
|
-
const webIndexPath =
|
|
59401
|
+
const webIndexPath = join21(studioDir, "index.js");
|
|
58855
59402
|
try {
|
|
58856
59403
|
await stat(webIndexPath);
|
|
58857
59404
|
} catch {
|
|
@@ -59130,7 +59677,7 @@ Or via NodeSource: https://github.com/nodesource/distributions
|
|
|
59130
59677
|
}
|
|
59131
59678
|
}
|
|
59132
59679
|
function getPackageVersion() {
|
|
59133
|
-
const pkgPath =
|
|
59680
|
+
const pkgPath = join22(dirname10(fileURLToPath3(import.meta.url)), "../../package.json");
|
|
59134
59681
|
const pkg = JSON.parse(readFileSync15(pkgPath, "utf-8"));
|
|
59135
59682
|
return pkg.version;
|
|
59136
59683
|
}
|