harnessed 4.47.0 → 4.49.0
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/README-en.md +66 -65
- package/README.md +66 -65
- package/bin/harnessed-inject-state.mjs +72 -16
- package/bin/harnessed-stop-hook.mjs +51 -10
- package/dist/cli.mjs +1754 -962
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/messages/en.json +2 -0
- package/messages/zh-Hans.json +2 -0
- package/package.json +2 -1
package/dist/cli.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import { Type } from '@sinclair/typebox';
|
|
|
6
6
|
import { readFile, readdir, stat, rm, unlink, writeFile, cp, mkdir, access, rename, appendFile, copyFile, chmod, mkdtemp } from 'fs/promises';
|
|
7
7
|
import { Value } from '@sinclair/typebox/value';
|
|
8
8
|
import lockfile from 'proper-lockfile';
|
|
9
|
+
import { createHash, verify, createPublicKey } from 'crypto';
|
|
10
|
+
import { pathToFileURL, fileURLToPath } from 'url';
|
|
9
11
|
import { LineCounter, parseDocument, parse, isSeq, isScalar, stringify } from 'yaml';
|
|
10
12
|
import { Ajv } from 'ajv';
|
|
11
13
|
import * as ajvFormatsNs from 'ajv-formats';
|
|
12
14
|
import { execFileSync, spawnSync, spawn, execFile, exec } from 'child_process';
|
|
13
|
-
import { pathToFileURL, fileURLToPath } from 'url';
|
|
14
|
-
import { createHash, verify, createPublicKey } from 'crypto';
|
|
15
15
|
import { promisify } from 'util';
|
|
16
16
|
import * as p from '@clack/prompts';
|
|
17
17
|
import { createPatch } from 'diff';
|
|
@@ -38,7 +38,7 @@ var init_package = __esm({
|
|
|
38
38
|
"package.json"() {
|
|
39
39
|
package_default = {
|
|
40
40
|
name: "harnessed",
|
|
41
|
-
version: "4.
|
|
41
|
+
version: "4.49.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -124,6 +124,7 @@ var init_package = __esm({
|
|
|
124
124
|
"expr-eval": "^2.0.2",
|
|
125
125
|
picocolors: "^1.1.1",
|
|
126
126
|
"proper-lockfile": "^4.1.2",
|
|
127
|
+
undici: "^8.12.1",
|
|
127
128
|
yaml: "^2.9.0"
|
|
128
129
|
},
|
|
129
130
|
devDependencies: {
|
|
@@ -148,15 +149,19 @@ var init_package = __esm({
|
|
|
148
149
|
// src/platform/platform.ts
|
|
149
150
|
var platform_exports = {};
|
|
150
151
|
__export(platform_exports, {
|
|
152
|
+
HOST_IDS: () => HOST_IDS,
|
|
151
153
|
claudeDescriptor: () => claudeDescriptor,
|
|
152
154
|
codexDescriptor: () => codexDescriptor,
|
|
155
|
+
descriptorFor: () => descriptorFor,
|
|
153
156
|
detectPlatform: () => detectPlatform,
|
|
154
157
|
getCommandsDir: () => getCommandsDir,
|
|
155
158
|
getMcpConfigPath: () => getMcpConfigPath,
|
|
156
159
|
getPluginsRegistry: () => getPluginsRegistry,
|
|
157
160
|
getSettingsPath: () => getSettingsPath,
|
|
158
161
|
getSkillsDir: () => getSkillsDir,
|
|
159
|
-
harnessSkillsDirs: () => harnessSkillsDirs
|
|
162
|
+
harnessSkillsDirs: () => harnessSkillsDirs,
|
|
163
|
+
isHostId: () => isHostId,
|
|
164
|
+
resolveHostWithReason: () => resolveHostWithReason
|
|
160
165
|
});
|
|
161
166
|
function claudeDescriptor(home = homedir()) {
|
|
162
167
|
const claudeHome = join(home, ".claude");
|
|
@@ -195,10 +200,14 @@ function codexDescriptor(home = homedir()) {
|
|
|
195
200
|
sessionIdEnv: "CODEX_SESSION_ID"
|
|
196
201
|
};
|
|
197
202
|
}
|
|
203
|
+
function isHostId(id) {
|
|
204
|
+
return HOST_IDS.includes(id);
|
|
205
|
+
}
|
|
206
|
+
function descriptorFor(id, home = homedir()) {
|
|
207
|
+
return id === "codex" ? codexDescriptor(home) : claudeDescriptor(home);
|
|
208
|
+
}
|
|
198
209
|
function descriptorById(id, home) {
|
|
199
|
-
|
|
200
|
-
if (id === "codex") return codexDescriptor(home);
|
|
201
|
-
return void 0;
|
|
210
|
+
return isHostId(id) ? descriptorFor(id, home) : void 0;
|
|
202
211
|
}
|
|
203
212
|
function detectPlatform(home = homedir()) {
|
|
204
213
|
const resolved = resolveHost(home);
|
|
@@ -207,29 +216,65 @@ function detectPlatform(home = homedir()) {
|
|
|
207
216
|
return resolved;
|
|
208
217
|
}
|
|
209
218
|
function resolveHost(home) {
|
|
219
|
+
return resolveHostWithReason(home).descriptor;
|
|
220
|
+
}
|
|
221
|
+
function resolveHostWithReason(home = homedir()) {
|
|
210
222
|
const base = claudeDescriptor(home);
|
|
223
|
+
const skipped = [];
|
|
211
224
|
const envPlatform = process.env.HARNESSED_PLATFORM;
|
|
212
225
|
if (envPlatform !== void 0 && envPlatform !== "") {
|
|
213
226
|
const d = descriptorById(envPlatform, home);
|
|
214
|
-
if (d)
|
|
227
|
+
if (d) {
|
|
228
|
+
return {
|
|
229
|
+
descriptor: d,
|
|
230
|
+
reason: { kind: "env-platform", envVar: "HARNESSED_PLATFORM", value: envPlatform },
|
|
231
|
+
skipped
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
skipped.push({ kind: "env-platform-unknown", envVar: "HARNESSED_PLATFORM", value: envPlatform });
|
|
215
235
|
}
|
|
216
236
|
const inClaude = Boolean(process.env.CLAUDE_CODE_SESSION_ID?.trim());
|
|
217
237
|
const inCodex = Boolean(process.env.CODEX_SESSION_ID?.trim());
|
|
218
|
-
if (inClaude !== inCodex)
|
|
238
|
+
if (inClaude !== inCodex) {
|
|
239
|
+
return {
|
|
240
|
+
descriptor: inClaude ? base : codexDescriptor(home),
|
|
241
|
+
reason: {
|
|
242
|
+
kind: "host-session-env",
|
|
243
|
+
envVar: inClaude ? "CLAUDE_CODE_SESSION_ID" : "CODEX_SESSION_ID"
|
|
244
|
+
},
|
|
245
|
+
skipped
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
if (inClaude && inCodex) skipped.push({ kind: "host-session-env-ambiguous" });
|
|
219
249
|
for (const pinRoot of [codexDescriptor(home).stateRoot, base.stateRoot]) {
|
|
250
|
+
const pinPath = join(pinRoot, ".platform");
|
|
220
251
|
try {
|
|
221
|
-
const
|
|
222
|
-
|
|
252
|
+
const value = readFileSync(pinPath, "utf8").trim();
|
|
253
|
+
const d = descriptorById(value, home);
|
|
254
|
+
if (d) return { descriptor: d, reason: { kind: "platform-pin", pinPath, value }, skipped };
|
|
255
|
+
skipped.push({ kind: "platform-pin-unknown", pinPath, value });
|
|
223
256
|
} catch {
|
|
224
257
|
}
|
|
225
258
|
}
|
|
226
259
|
try {
|
|
227
|
-
if (existsSync(base.homeDir))
|
|
260
|
+
if (existsSync(base.homeDir)) {
|
|
261
|
+
return {
|
|
262
|
+
descriptor: base,
|
|
263
|
+
reason: { kind: "directory-probe", probedDir: base.homeDir },
|
|
264
|
+
skipped
|
|
265
|
+
};
|
|
266
|
+
}
|
|
228
267
|
const codex = codexDescriptor(home);
|
|
229
|
-
if (existsSync(codex.homeDir))
|
|
268
|
+
if (existsSync(codex.homeDir)) {
|
|
269
|
+
return {
|
|
270
|
+
descriptor: codex,
|
|
271
|
+
reason: { kind: "directory-probe", probedDir: codex.homeDir },
|
|
272
|
+
skipped
|
|
273
|
+
};
|
|
274
|
+
}
|
|
230
275
|
} catch {
|
|
231
276
|
}
|
|
232
|
-
return base;
|
|
277
|
+
return { descriptor: base, reason: { kind: "fallback" }, skipped };
|
|
233
278
|
}
|
|
234
279
|
function getSettingsPath(home) {
|
|
235
280
|
return detectPlatform(home).settingsPath;
|
|
@@ -251,8 +296,10 @@ function harnessSkillsDirs(home) {
|
|
|
251
296
|
const dirs = [claudeDescriptor(home).skillsDir, codex.skillsDir, join(codex.homeDir, "skills")];
|
|
252
297
|
return [...new Set(dirs)];
|
|
253
298
|
}
|
|
299
|
+
var HOST_IDS;
|
|
254
300
|
var init_platform = __esm({
|
|
255
301
|
"src/platform/platform.ts"() {
|
|
302
|
+
HOST_IDS = ["claude", "codex"];
|
|
256
303
|
}
|
|
257
304
|
});
|
|
258
305
|
function getHarnessedRoot() {
|
|
@@ -416,37 +463,6 @@ var init_atomicWrite = __esm({
|
|
|
416
463
|
isTransient = (e) => TRANSIENT_RENAME.has(e?.code ?? "");
|
|
417
464
|
}
|
|
418
465
|
});
|
|
419
|
-
var CheckpointStatus, CheckpointV1;
|
|
420
|
-
var init_checkpoint_v1 = __esm({
|
|
421
|
-
"src/checkpoint/schema/checkpoint.v1.ts"() {
|
|
422
|
-
init_schemaVersion();
|
|
423
|
-
CheckpointStatus = Type.Union([
|
|
424
|
-
Type.Literal("active"),
|
|
425
|
-
Type.Literal("paused"),
|
|
426
|
-
Type.Literal("complete")
|
|
427
|
-
]);
|
|
428
|
-
CheckpointV1 = Type.Object(
|
|
429
|
-
{
|
|
430
|
-
schemaVersion: Type.Literal(SCHEMA_VERSIONS.checkpoint),
|
|
431
|
-
phase: Type.String({ minLength: 1 }),
|
|
432
|
-
status: CheckpointStatus,
|
|
433
|
-
last_task: Type.String(),
|
|
434
|
-
key_decisions: Type.Array(Type.String()),
|
|
435
|
-
canonical_refs: Type.Array(Type.String()),
|
|
436
|
-
/** D-04 WIRE-IN: optional SDK session_id captured via `sdkSpawn`
|
|
437
|
-
* `onSessionId` callback (CD-4 closure-ready) for future `--resume`. */
|
|
438
|
-
session_id: Type.Optional(Type.String()),
|
|
439
|
-
/** RESEARCH § 1.3 critical constraint — SDK session resume requires cwd
|
|
440
|
-
* match; we capture and validate at restore time. */
|
|
441
|
-
cwd: Type.String({ minLength: 1 }),
|
|
442
|
-
timestamp: Type.String({ minLength: 1 }),
|
|
443
|
-
// ISO-8601 by convention (TypeBox `format` requires Ajv-style format registry; we keep shape-check only — drift caught in writeCheckpoint path)
|
|
444
|
-
archive_path: Type.String({ minLength: 1 })
|
|
445
|
-
},
|
|
446
|
-
{ additionalProperties: false }
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
466
|
|
|
451
467
|
// src/workflow/lib/spawnFailure.ts
|
|
452
468
|
var spawnFailure_exports = {};
|
|
@@ -644,6 +660,37 @@ var init_currentWorkflow_v1 = __esm({
|
|
|
644
660
|
);
|
|
645
661
|
}
|
|
646
662
|
});
|
|
663
|
+
var CheckpointStatus, CheckpointV1;
|
|
664
|
+
var init_checkpoint_v1 = __esm({
|
|
665
|
+
"src/checkpoint/schema/checkpoint.v1.ts"() {
|
|
666
|
+
init_schemaVersion();
|
|
667
|
+
CheckpointStatus = Type.Union([
|
|
668
|
+
Type.Literal("active"),
|
|
669
|
+
Type.Literal("paused"),
|
|
670
|
+
Type.Literal("complete")
|
|
671
|
+
]);
|
|
672
|
+
CheckpointV1 = Type.Object(
|
|
673
|
+
{
|
|
674
|
+
schemaVersion: Type.Literal(SCHEMA_VERSIONS.checkpoint),
|
|
675
|
+
phase: Type.String({ minLength: 1 }),
|
|
676
|
+
status: CheckpointStatus,
|
|
677
|
+
last_task: Type.String(),
|
|
678
|
+
key_decisions: Type.Array(Type.String()),
|
|
679
|
+
canonical_refs: Type.Array(Type.String()),
|
|
680
|
+
/** D-04 WIRE-IN: optional SDK session_id captured via `sdkSpawn`
|
|
681
|
+
* `onSessionId` callback (CD-4 closure-ready) for future `--resume`. */
|
|
682
|
+
session_id: Type.Optional(Type.String()),
|
|
683
|
+
/** RESEARCH § 1.3 critical constraint — SDK session resume requires cwd
|
|
684
|
+
* match; we capture and validate at restore time. */
|
|
685
|
+
cwd: Type.String({ minLength: 1 }),
|
|
686
|
+
timestamp: Type.String({ minLength: 1 }),
|
|
687
|
+
// ISO-8601 by convention (TypeBox `format` requires Ajv-style format registry; we keep shape-check only — drift caught in writeCheckpoint path)
|
|
688
|
+
archive_path: Type.String({ minLength: 1 })
|
|
689
|
+
},
|
|
690
|
+
{ additionalProperties: false }
|
|
691
|
+
);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
647
694
|
|
|
648
695
|
// src/checkpoint/schema/index.ts
|
|
649
696
|
var init_schema = __esm({
|
|
@@ -653,113 +700,6 @@ var init_schema = __esm({
|
|
|
653
700
|
}
|
|
654
701
|
});
|
|
655
702
|
|
|
656
|
-
// src/checkpoint/workflowStore.ts
|
|
657
|
-
var workflowStore_exports = {};
|
|
658
|
-
__export(workflowStore_exports, {
|
|
659
|
-
IntentEntry: () => IntentEntry,
|
|
660
|
-
RetroMetaEntry: () => RetroMetaEntry,
|
|
661
|
-
WorkflowStoreV1: () => WorkflowStoreV1,
|
|
662
|
-
activeKey: () => activeKey,
|
|
663
|
-
listWorkflows: () => listWorkflows,
|
|
664
|
-
readIntent: () => readIntent,
|
|
665
|
-
readStoreRaw: () => readStoreRaw,
|
|
666
|
-
repoKey: () => repoKey,
|
|
667
|
-
writeStoreRaw: () => writeStoreRaw
|
|
668
|
-
});
|
|
669
|
-
function storePath() {
|
|
670
|
-
return harnessedFile("workflows.json");
|
|
671
|
-
}
|
|
672
|
-
function emptyStore() {
|
|
673
|
-
return { schemaVersion: SCHEMA_VERSIONS.workflowStore, workflows: {} };
|
|
674
|
-
}
|
|
675
|
-
function repoKey(cwd = process.cwd()) {
|
|
676
|
-
let dir = resolve(cwd);
|
|
677
|
-
for (; ; ) {
|
|
678
|
-
if (existsSync(join(dir, ".git"))) return dir;
|
|
679
|
-
const parent = dirname(dir);
|
|
680
|
-
if (parent === dir) break;
|
|
681
|
-
dir = parent;
|
|
682
|
-
}
|
|
683
|
-
return resolve(cwd);
|
|
684
|
-
}
|
|
685
|
-
function activeKey(cwd = process.cwd()) {
|
|
686
|
-
const base = repoKey(cwd);
|
|
687
|
-
const envName = detectPlatform().sessionIdEnv;
|
|
688
|
-
const sid = envName ? process.env[envName]?.trim() : void 0;
|
|
689
|
-
return sid ? `${base}::${sid}` : base;
|
|
690
|
-
}
|
|
691
|
-
async function readStoreRaw() {
|
|
692
|
-
try {
|
|
693
|
-
const parsed = JSON.parse(await readFile(storePath(), "utf8"));
|
|
694
|
-
if (Value.Check(WorkflowStoreV1, parsed)) return parsed;
|
|
695
|
-
} catch {
|
|
696
|
-
}
|
|
697
|
-
return emptyStore();
|
|
698
|
-
}
|
|
699
|
-
async function writeStoreRaw(store) {
|
|
700
|
-
if (!Value.Check(WorkflowStoreV1, store)) {
|
|
701
|
-
const errs = [...Value.Errors(WorkflowStoreV1, store)].map((e) => e.message).join("; ");
|
|
702
|
-
throw new Error(`workflow-store schema validation failed: ${errs}`);
|
|
703
|
-
}
|
|
704
|
-
const p8 = storePath();
|
|
705
|
-
await mkdir(dirname(p8), { recursive: true });
|
|
706
|
-
await writeFileAtomic(p8, JSON.stringify(store, null, 2));
|
|
707
|
-
}
|
|
708
|
-
async function readIntent(cwd = process.cwd()) {
|
|
709
|
-
const store = await readStoreRaw();
|
|
710
|
-
return store.intents?.[activeKey(cwd)] ?? store.intents?.[repoKey(cwd)] ?? null;
|
|
711
|
-
}
|
|
712
|
-
async function listWorkflows() {
|
|
713
|
-
const store = await readStoreRaw();
|
|
714
|
-
return Object.entries(store.workflows).map(([key, wf]) => ({
|
|
715
|
-
key,
|
|
716
|
-
phase: wf.phase,
|
|
717
|
-
status: wf.status
|
|
718
|
-
}));
|
|
719
|
-
}
|
|
720
|
-
var RetroMetaEntry, IntentEntry, WorkflowStoreV1;
|
|
721
|
-
var init_workflowStore = __esm({
|
|
722
|
-
"src/checkpoint/workflowStore.ts"() {
|
|
723
|
-
init_harnessedRoot();
|
|
724
|
-
init_platform();
|
|
725
|
-
init_schemaVersion();
|
|
726
|
-
init_atomicWrite();
|
|
727
|
-
init_currentWorkflow_v1();
|
|
728
|
-
RetroMetaEntry = Type.Object(
|
|
729
|
-
{
|
|
730
|
-
phases_since_retro: Type.Integer({ minimum: 0 }),
|
|
731
|
-
last_retro_at: Type.Optional(Type.String({ minLength: 1 }))
|
|
732
|
-
},
|
|
733
|
-
{ additionalProperties: false }
|
|
734
|
-
);
|
|
735
|
-
IntentEntry = Type.Object(
|
|
736
|
-
{
|
|
737
|
-
// Invoked command name (master OR leaf sub — field name kept for 765cbc9
|
|
738
|
-
// store back-compat; kind carries the distinction).
|
|
739
|
-
master: Type.String({ minLength: 1 }),
|
|
740
|
-
ts: Type.String({ minLength: 1 }),
|
|
741
|
-
// 4.22.0 T6 — additive-optional: absent = 'master' (765cbc9 only ever wrote
|
|
742
|
-
// master intents). 'leaf' switches banner/nag to the leaf SOP wording
|
|
743
|
-
// (prompt → spawn → checkpoint complete) and the absorb trigger to that
|
|
744
|
-
// sub's complete/fail instead of `checkpoint start`.
|
|
745
|
-
kind: Type.Optional(Type.Union([Type.Literal("master"), Type.Literal("leaf")]))
|
|
746
|
-
},
|
|
747
|
-
{ additionalProperties: false }
|
|
748
|
-
);
|
|
749
|
-
WorkflowStoreV1 = Type.Object(
|
|
750
|
-
{
|
|
751
|
-
schemaVersion: Type.Literal(SCHEMA_VERSIONS.workflowStore),
|
|
752
|
-
workflows: Type.Record(Type.String(), CurrentWorkflowV1),
|
|
753
|
-
// Additive-optional (no schemaVersion bump — old stores Value.Check-pass).
|
|
754
|
-
retro_meta: Type.Optional(Type.Record(Type.String(), RetroMetaEntry)),
|
|
755
|
-
// 4.22.0 — additive-optional, same rationale.
|
|
756
|
-
intents: Type.Optional(Type.Record(Type.String(), IntentEntry))
|
|
757
|
-
},
|
|
758
|
-
{ additionalProperties: false }
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
|
|
763
703
|
// src/checkpoint/state.ts
|
|
764
704
|
var state_exports = {};
|
|
765
705
|
__export(state_exports, {
|
|
@@ -887,61 +827,250 @@ var init_state = __esm({
|
|
|
887
827
|
}
|
|
888
828
|
});
|
|
889
829
|
|
|
890
|
-
// src/checkpoint/
|
|
891
|
-
var
|
|
892
|
-
__export(
|
|
893
|
-
|
|
830
|
+
// src/checkpoint/workflowStore.ts
|
|
831
|
+
var workflowStore_exports = {};
|
|
832
|
+
__export(workflowStore_exports, {
|
|
833
|
+
IntentEntry: () => IntentEntry,
|
|
834
|
+
RetroMetaEntry: () => RetroMetaEntry,
|
|
835
|
+
WorkflowStoreV1: () => WorkflowStoreV1,
|
|
836
|
+
activeKey: () => activeKey,
|
|
837
|
+
listWorkflows: () => listWorkflows,
|
|
838
|
+
migrateRepoKeyCase: () => migrateRepoKeyCase,
|
|
839
|
+
normalizeRepoKey: () => normalizeRepoKey,
|
|
840
|
+
readIntent: () => readIntent,
|
|
841
|
+
readStoreAt: () => readStoreAt,
|
|
842
|
+
readStoreRaw: () => readStoreRaw,
|
|
843
|
+
repoKey: () => repoKey,
|
|
844
|
+
writeStoreRaw: () => writeStoreRaw
|
|
894
845
|
});
|
|
895
|
-
function
|
|
896
|
-
|
|
897
|
-
const wf = opts.currentWorkflow ?? null;
|
|
898
|
-
return {
|
|
899
|
-
subProgress: wf?.sub_progress ?? [],
|
|
900
|
-
currentPhase: wf?.phase ?? null,
|
|
901
|
-
phases: scanPhases(repoRoot, opts.includeTasks ?? false)
|
|
902
|
-
};
|
|
846
|
+
function storePath() {
|
|
847
|
+
return harnessedFile("workflows.json");
|
|
903
848
|
}
|
|
904
|
-
function
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
849
|
+
function emptyStore() {
|
|
850
|
+
return { schemaVersion: SCHEMA_VERSIONS.workflowStore, workflows: {} };
|
|
851
|
+
}
|
|
852
|
+
function normalizeRepoKey(key, platform = process.platform) {
|
|
853
|
+
return platform === "win32" ? key.toLowerCase() : key;
|
|
854
|
+
}
|
|
855
|
+
function repoKey(cwd = process.cwd()) {
|
|
856
|
+
let dir = resolve(cwd);
|
|
857
|
+
for (; ; ) {
|
|
858
|
+
if (existsSync(join(dir, ".git"))) return normalizeRepoKey(dir);
|
|
859
|
+
const parent = dirname(dir);
|
|
860
|
+
if (parent === dir) break;
|
|
861
|
+
dir = parent;
|
|
862
|
+
}
|
|
863
|
+
return normalizeRepoKey(resolve(cwd));
|
|
864
|
+
}
|
|
865
|
+
function activeKey(cwd = process.cwd()) {
|
|
866
|
+
const base = repoKey(cwd);
|
|
867
|
+
const envName = detectPlatform().sessionIdEnv;
|
|
868
|
+
const sid = envName ? process.env[envName]?.trim() : void 0;
|
|
869
|
+
return sid ? `${base}::${sid}` : base;
|
|
870
|
+
}
|
|
871
|
+
async function readStoreRaw() {
|
|
872
|
+
return readStoreAt(getHarnessedRoot());
|
|
873
|
+
}
|
|
874
|
+
async function readStoreAt(root) {
|
|
875
|
+
try {
|
|
876
|
+
const parsed = JSON.parse(await readFile(join(root, "workflows.json"), "utf8"));
|
|
877
|
+
if (Value.Check(WorkflowStoreV1, parsed)) return parsed;
|
|
878
|
+
} catch {
|
|
879
|
+
}
|
|
880
|
+
return emptyStore();
|
|
881
|
+
}
|
|
882
|
+
async function writeStoreRaw(store) {
|
|
883
|
+
if (!Value.Check(WorkflowStoreV1, store)) {
|
|
884
|
+
const errs = [...Value.Errors(WorkflowStoreV1, store)].map((e) => e.message).join("; ");
|
|
885
|
+
throw new Error(`workflow-store schema validation failed: ${errs}`);
|
|
886
|
+
}
|
|
887
|
+
const p8 = storePath();
|
|
888
|
+
await mkdir(dirname(p8), { recursive: true });
|
|
889
|
+
await writeFileAtomic(p8, JSON.stringify(store, null, 2));
|
|
890
|
+
}
|
|
891
|
+
async function readIntent(cwd = process.cwd()) {
|
|
892
|
+
const store = await readStoreRaw();
|
|
893
|
+
return store.intents?.[activeKey(cwd)] ?? store.intents?.[repoKey(cwd)] ?? null;
|
|
894
|
+
}
|
|
895
|
+
async function listWorkflows() {
|
|
896
|
+
const store = await readStoreRaw();
|
|
897
|
+
return Object.entries(store.workflows).map(([key, wf]) => ({
|
|
898
|
+
key,
|
|
899
|
+
phase: wf.phase,
|
|
900
|
+
status: wf.status
|
|
901
|
+
}));
|
|
902
|
+
}
|
|
903
|
+
function shortHash(key) {
|
|
904
|
+
return createHash("sha256").update(key).digest("hex").slice(0, 6);
|
|
905
|
+
}
|
|
906
|
+
function foldStoreKey(key, platform) {
|
|
907
|
+
const i = key.indexOf("::");
|
|
908
|
+
return i === -1 ? normalizeRepoKey(key, platform) : normalizeRepoKey(key.slice(0, i), platform) + key.slice(i);
|
|
909
|
+
}
|
|
910
|
+
function needsFold(store, platform) {
|
|
911
|
+
for (const map of [store.workflows, store.retro_meta, store.intents]) {
|
|
912
|
+
if (!map) continue;
|
|
913
|
+
for (const k of Object.keys(map)) if (foldStoreKey(k, platform) !== k) return true;
|
|
914
|
+
}
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
function foldMap(map, newer, platform) {
|
|
918
|
+
const groups = /* @__PURE__ */ new Map();
|
|
919
|
+
let folded = 0;
|
|
920
|
+
for (const [key, value] of Object.entries(map)) {
|
|
921
|
+
const k = foldStoreKey(key, platform);
|
|
922
|
+
if (k !== key) folded++;
|
|
923
|
+
const g = groups.get(k);
|
|
924
|
+
if (g) g.push({ key, value });
|
|
925
|
+
else groups.set(k, [{ key, value }]);
|
|
926
|
+
}
|
|
927
|
+
const next = {};
|
|
928
|
+
let archived = 0;
|
|
929
|
+
for (const [k, entries] of groups) {
|
|
930
|
+
let win = entries[0];
|
|
931
|
+
for (const e of entries) if (e !== win && newer(e.value, win.value)) win = e;
|
|
932
|
+
next[k] = win.value;
|
|
933
|
+
for (const e of entries) {
|
|
934
|
+
if (e === win) continue;
|
|
935
|
+
next[`${k}${PREMIGRATE}${shortHash(e.key)}`] = e.value;
|
|
936
|
+
archived++;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return { next, folded, archived };
|
|
940
|
+
}
|
|
941
|
+
async function migrateRepoKeyCase(platform = process.platform) {
|
|
942
|
+
const noop = { folded: 0, archived: 0 };
|
|
943
|
+
if (platform !== "win32") return noop;
|
|
944
|
+
if (!needsFold(await readStoreRaw(), platform)) return noop;
|
|
945
|
+
let result = noop;
|
|
946
|
+
const { mutateStore: mutateStore2 } = await Promise.resolve().then(() => (init_state(), state_exports));
|
|
947
|
+
await mutateStore2((store) => {
|
|
948
|
+
const w = foldMap(
|
|
949
|
+
store.workflows,
|
|
950
|
+
(a, b) => (a.updated_at ?? "") > (b.updated_at ?? ""),
|
|
951
|
+
platform
|
|
952
|
+
);
|
|
953
|
+
const r = store.retro_meta ? foldMap(
|
|
954
|
+
store.retro_meta,
|
|
955
|
+
(a, b) => a.phases_since_retro !== b.phases_since_retro ? a.phases_since_retro > b.phases_since_retro : (a.last_retro_at ?? "") > (b.last_retro_at ?? ""),
|
|
956
|
+
platform
|
|
957
|
+
) : void 0;
|
|
958
|
+
const i = store.intents ? foldMap(store.intents, (a, b) => a.ts > b.ts, platform) : void 0;
|
|
959
|
+
result = {
|
|
960
|
+
folded: w.folded + (r?.folded ?? 0) + (i?.folded ?? 0),
|
|
961
|
+
archived: w.archived + (r?.archived ?? 0) + (i?.archived ?? 0)
|
|
962
|
+
};
|
|
963
|
+
const next = { ...store, workflows: w.next };
|
|
964
|
+
if (r) next.retro_meta = r.next;
|
|
965
|
+
if (i) next.intents = i.next;
|
|
966
|
+
return next;
|
|
967
|
+
});
|
|
968
|
+
if (result.folded > 0 || result.archived > 0) {
|
|
969
|
+
console.error(
|
|
970
|
+
`[harnessed] folded ${result.folded} ledger key(s) to canonical case (Windows paths are case-insensitive; differently-cased spellings of one repo held separate workflow slots)` + (result.archived > 0 ? ` \u2014 ${result.archived} colliding entr${result.archived === 1 ? "y" : "ies"} preserved under ${PREMIGRATE}* (archive only; nothing dropped)` : "")
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
return result;
|
|
974
|
+
}
|
|
975
|
+
var RetroMetaEntry, IntentEntry, WorkflowStoreV1, PREMIGRATE;
|
|
976
|
+
var init_workflowStore = __esm({
|
|
977
|
+
"src/checkpoint/workflowStore.ts"() {
|
|
978
|
+
init_harnessedRoot();
|
|
979
|
+
init_platform();
|
|
980
|
+
init_schemaVersion();
|
|
981
|
+
init_atomicWrite();
|
|
982
|
+
init_currentWorkflow_v1();
|
|
983
|
+
RetroMetaEntry = Type.Object(
|
|
984
|
+
{
|
|
985
|
+
phases_since_retro: Type.Integer({ minimum: 0 }),
|
|
986
|
+
last_retro_at: Type.Optional(Type.String({ minLength: 1 }))
|
|
987
|
+
},
|
|
988
|
+
{ additionalProperties: false }
|
|
989
|
+
);
|
|
990
|
+
IntentEntry = Type.Object(
|
|
991
|
+
{
|
|
992
|
+
// Invoked command name (master OR leaf sub — field name kept for 765cbc9
|
|
993
|
+
// store back-compat; kind carries the distinction).
|
|
994
|
+
master: Type.String({ minLength: 1 }),
|
|
995
|
+
ts: Type.String({ minLength: 1 }),
|
|
996
|
+
// 4.22.0 T6 — additive-optional: absent = 'master' (765cbc9 only ever wrote
|
|
997
|
+
// master intents). 'leaf' switches banner/nag to the leaf SOP wording
|
|
998
|
+
// (prompt → spawn → checkpoint complete) and the absorb trigger to that
|
|
999
|
+
// sub's complete/fail instead of `checkpoint start`.
|
|
1000
|
+
kind: Type.Optional(Type.Union([Type.Literal("master"), Type.Literal("leaf")]))
|
|
1001
|
+
},
|
|
1002
|
+
{ additionalProperties: false }
|
|
1003
|
+
);
|
|
1004
|
+
WorkflowStoreV1 = Type.Object(
|
|
1005
|
+
{
|
|
1006
|
+
schemaVersion: Type.Literal(SCHEMA_VERSIONS.workflowStore),
|
|
1007
|
+
workflows: Type.Record(Type.String(), CurrentWorkflowV1),
|
|
1008
|
+
// Additive-optional (no schemaVersion bump — old stores Value.Check-pass).
|
|
1009
|
+
retro_meta: Type.Optional(Type.Record(Type.String(), RetroMetaEntry)),
|
|
1010
|
+
// 4.22.0 — additive-optional, same rationale.
|
|
1011
|
+
intents: Type.Optional(Type.Record(Type.String(), IntentEntry))
|
|
1012
|
+
},
|
|
1013
|
+
{ additionalProperties: false }
|
|
1014
|
+
);
|
|
1015
|
+
PREMIGRATE = "::premigrate-";
|
|
1016
|
+
}
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
// src/checkpoint/planningScan.ts
|
|
1020
|
+
var planningScan_exports = {};
|
|
1021
|
+
__export(planningScan_exports, {
|
|
1022
|
+
scanPlanning: () => scanPlanning
|
|
1023
|
+
});
|
|
1024
|
+
function scanPlanning(opts = {}) {
|
|
1025
|
+
const repoRoot = opts.repoRoot ?? process.cwd();
|
|
1026
|
+
const wf = opts.currentWorkflow ?? null;
|
|
1027
|
+
return {
|
|
1028
|
+
subProgress: wf?.sub_progress ?? [],
|
|
1029
|
+
currentPhase: wf?.phase ?? null,
|
|
1030
|
+
phases: scanPhases(repoRoot, opts.includeTasks ?? false)
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
function scanPhases(repoRoot, includeTasks) {
|
|
1034
|
+
try {
|
|
1035
|
+
const phasesDir = join(repoRoot, ".planning", "phases");
|
|
1036
|
+
if (!existsSync(phasesDir)) return [];
|
|
1037
|
+
const out = [];
|
|
1038
|
+
for (const dir of readdirSync(phasesDir)) {
|
|
1039
|
+
const m = PHASE_DIR.exec(dir);
|
|
1040
|
+
const num = m?.[1];
|
|
1041
|
+
if (!num) continue;
|
|
1042
|
+
const dirPath = join(phasesDir, dir);
|
|
1043
|
+
let entries;
|
|
1044
|
+
try {
|
|
1045
|
+
entries = readdirSync(dirPath);
|
|
1046
|
+
} catch {
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
let plans = 0;
|
|
1050
|
+
let summaries = 0;
|
|
1051
|
+
const prefix = `${num}-`;
|
|
1052
|
+
for (const f of entries) {
|
|
1053
|
+
if (!f.startsWith(prefix)) continue;
|
|
1054
|
+
if (f.endsWith("-PLAN.md")) plans++;
|
|
1055
|
+
else if (f.endsWith("-SUMMARY.md")) summaries++;
|
|
1056
|
+
}
|
|
1057
|
+
const complete2 = plans > 0 && summaries >= plans;
|
|
1058
|
+
const phase = {
|
|
1059
|
+
phase: num,
|
|
1060
|
+
name: m?.[2] ?? "",
|
|
1061
|
+
plans,
|
|
1062
|
+
summaries,
|
|
1063
|
+
complete: complete2,
|
|
1064
|
+
order: Number.parseFloat(num)
|
|
1065
|
+
};
|
|
1066
|
+
if (includeTasks && !complete2) phase.tasks = scanTasks(dirPath);
|
|
1067
|
+
out.push(phase);
|
|
1068
|
+
}
|
|
1069
|
+
out.sort((a, b) => a.order - b.order);
|
|
1070
|
+
return out;
|
|
1071
|
+
} catch {
|
|
1072
|
+
return [];
|
|
1073
|
+
}
|
|
945
1074
|
}
|
|
946
1075
|
function scanTasks(dirPath) {
|
|
947
1076
|
for (const fname of ["task_plan.md", "progress.md"]) {
|
|
@@ -1209,18 +1338,676 @@ function resolveAdvance(snapshot, force = false) {
|
|
|
1209
1338
|
if (gate && force) {
|
|
1210
1339
|
lines.push(`AUDIT: --force override \u2014 advancing past unfinished ${gate.unit} (${gate.reason})`);
|
|
1211
1340
|
}
|
|
1212
|
-
lines.push("ADVANCE: advance", `UNIT: ${u}`, cmd);
|
|
1213
|
-
return {
|
|
1214
|
-
next: "advance",
|
|
1215
|
-
unit,
|
|
1216
|
-
exitCode: 0,
|
|
1217
|
-
lines,
|
|
1218
|
-
json: { next: "advance", unit: u, hint: cmd }
|
|
1219
|
-
};
|
|
1341
|
+
lines.push("ADVANCE: advance", `UNIT: ${u}`, cmd);
|
|
1342
|
+
return {
|
|
1343
|
+
next: "advance",
|
|
1344
|
+
unit,
|
|
1345
|
+
exitCode: 0,
|
|
1346
|
+
lines,
|
|
1347
|
+
json: { next: "advance", unit: u, hint: cmd }
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
var init_forwardStep = __esm({
|
|
1351
|
+
"src/checkpoint/forwardStep.ts"() {
|
|
1352
|
+
init_deriveNext();
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
// messages/en.json
|
|
1357
|
+
var en_default;
|
|
1358
|
+
var init_en = __esm({
|
|
1359
|
+
"messages/en.json"() {
|
|
1360
|
+
en_default = {
|
|
1361
|
+
"setup.workflows_not_found": "error: workflows directory not found at {{path}}",
|
|
1362
|
+
"setup.nothing_to_install": "setup: no workflow directories with SKILL.md found \u2014 nothing to install",
|
|
1363
|
+
"setup.dry_run.header": "[dry-run] setup would install {{count}} workflow(s) to {{path}}:",
|
|
1364
|
+
"setup.dry_run.run_hint": " run without --dry-run to execute",
|
|
1365
|
+
"setup.copy_failed": " error: failed to copy {{name}}: {{message}}",
|
|
1366
|
+
"setup.step_a_complete": "Step A: {{count}} workflows installed to {{path}}",
|
|
1367
|
+
"setup.step_a_render.complete": " generated {{count}}/{{total}} command files",
|
|
1368
|
+
"setup.step_a_render.warnings_header": " [A.5] warnings \u2014 some capability cmds could not be fully resolved:",
|
|
1369
|
+
"setup.step_c.created": " [C] created {{path}} + enabled Agent Teams",
|
|
1370
|
+
"setup.step_c.already_enabled": " [C] Agent Teams already enabled ({{path}})",
|
|
1371
|
+
"setup.step_c.enabled_backup": " [C] enabled Agent Teams in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
1372
|
+
"setup.step_c.skipped": " [C] Agent Teams enable skipped: {{message}}",
|
|
1373
|
+
"setup.step_d.created": " [D] created {{path}} + wrote env.HARNESSED_USER_LANG={{lang}}",
|
|
1374
|
+
"setup.step_d.already_set": " [D] env.HARNESSED_USER_LANG={{lang}} already set in {{path}} \u2014 respecting user override",
|
|
1375
|
+
"setup.step_d.enabled_backup": " [D] wrote env.HARNESSED_USER_LANG={{lang}} in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
1376
|
+
"setup.step_d.skipped": " [D] User language write skipped: {{message}}",
|
|
1377
|
+
"setup.step_b_complete": "Upstream components: {{installed}} installed / {{already}} already-installed / {{skipped}} skipped / {{failed}} failed [{{seconds}}s]",
|
|
1378
|
+
"setup.complete": "setup complete \u2014 {{skills}} workflows + {{manifests}} base manifests configured",
|
|
1379
|
+
"setup.mcp_hint": "Run /mcp in Claude Code to verify MCP server connections.",
|
|
1380
|
+
"setup.mcp_hint_codex": "Run codex mcp list to verify MCP server connections.",
|
|
1381
|
+
"setup.search_key_hint.header": "\n\u26A0 Search MCP API keys missing \u2014 the server(s) below are installed but will fail at query time until the key is configured:",
|
|
1382
|
+
"setup.search_key_hint.line": ' {{server}}: set {{envVar}} \u2014 add it to the ~/.claude/settings.json "env" block (e.g. {"env": {"{{envVar}}": "<your-key>"}}) or export {{envVar}} in your shell',
|
|
1383
|
+
"setup.optional_offer.ecc_note": " ecc (bonus tier): installing it unlocks finer-grained scenario orchestration (per-language review/build expert routing etc.); the trade-off is ~20k+ tokens/session of static listing overhead \u2014 inherent to ECC's own scale (281 skills / 94 commands / 67 agents), not introduced by harnessed.",
|
|
1384
|
+
"setup.bundled_summary": "\nharnessed workflows bundled at <packageRoot>/workflows/ (share-only, read-only)",
|
|
1385
|
+
"setup.bundled_location": "",
|
|
1386
|
+
"setup.doctor_hint": "\nRun harnessed doctor to verify your environment.",
|
|
1387
|
+
"agent_teams.missing_header": "\n\u26A0\uFE0F Agent Teams not enabled \u2014 parallelism upgrade path unavailable",
|
|
1388
|
+
"agent_teams.missing_fix": " fix: claude config set env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS 1",
|
|
1389
|
+
"agent_teams.missing_explanation": " harnessed task parallelism uses Subagent or Agent Teams (CC 2.1.178+)",
|
|
1390
|
+
"agent_teams.missing_nonblocking": " non-blocking \u2014 auto-degrades to subagent fan-out\n",
|
|
1391
|
+
"install.manifest_not_found": "error: manifest '{{name}}' not found",
|
|
1392
|
+
"install.manifest_not_found.fix": " fix: ensure manifests/tools/{{name}}.yaml, manifests/skill-packs/{{name}}.yaml, or manifests/optional/{{name}}.yaml exists",
|
|
1393
|
+
"install.audit_hint": " fix: run 'harnessed audit' to inspect manifest issues",
|
|
1394
|
+
"install.success": "installed {{name}}",
|
|
1395
|
+
"install.success_with_version": "installed {{name}}@{{version}}",
|
|
1396
|
+
"install.already_installed": "already-installed {{name}} (idempotent check hit; nothing to do)",
|
|
1397
|
+
"install.already_installed_with_version": "already-installed {{name}}@{{version}} (idempotent check hit; nothing to do)",
|
|
1398
|
+
"install.aborted": "aborted: {{reason}}",
|
|
1399
|
+
"uninstall.dry_run.preview": "[dry-run] would uninstall '{{name}}' via method '{{method}}'",
|
|
1400
|
+
"uninstall.dry_run.run_hint": " run without --dry-run to execute",
|
|
1401
|
+
"uninstall.confirm.prompt": "Uninstall '{{name}}'? This cannot be undone.",
|
|
1402
|
+
"uninstall.cancelled": "aborted: user cancelled",
|
|
1403
|
+
"uninstall.completed": "uninstalled {{name}}",
|
|
1404
|
+
"uninstall.unified.nothing": "nothing to do \u2014 no harnessed artifacts found",
|
|
1405
|
+
"uninstall.unified.header": "harnessed uninstall will remove the following:",
|
|
1406
|
+
"uninstall.unified.commands": " Commands: {{count}} harnessed-generated slash command file(s) in ~/.claude/commands/",
|
|
1407
|
+
"uninstall.unified.agent_roles": " Agent roles: {{count}} harnessed-generated codex agent role file(s) in ~/.codex/agents/",
|
|
1408
|
+
"uninstall.unified.skills": " Skills: {{count}} workflow skill directory(ies) in ~/.claude/skills/",
|
|
1409
|
+
"uninstall.unified.settings": " Settings: harnessed env vars (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, HARNESSED_USER_LANG) from ~/.claude/settings.json",
|
|
1410
|
+
"uninstall.unified.hooks": " Hooks: {{count}} harnessed Stop/UserPromptSubmit hook(s) in ~/.claude/settings.json",
|
|
1411
|
+
"uninstall.unified.state_dir": " State directory: ~/.claude/harnessed/ (includes backups, audit log, state, lock)",
|
|
1412
|
+
"uninstall.unified.upstream_note": "\nUpstream components (npm packages, MCP servers, CC plugins, git-cloned repos, npx skills) are NOT affected.",
|
|
1413
|
+
"uninstall.unified.dry_run_hint": "\n(dry-run \u2014 re-run without --dry-run to actually remove)",
|
|
1414
|
+
"uninstall.unified.confirm": "Remove harnessed's own files? Upstream components (npm packages, MCP servers, CC plugins, etc.) will NOT be affected. This cannot be undone.",
|
|
1415
|
+
"uninstall.unified.removing": "removing harnessed files...",
|
|
1416
|
+
"uninstall.unified.removed_commands": " removed {{count}} command file(s)",
|
|
1417
|
+
"uninstall.unified.removed_agent_roles": " removed {{count}} codex agent role file(s)",
|
|
1418
|
+
"uninstall.unified.removed_skills": " removed {{count}} skill directory(ies)",
|
|
1419
|
+
"uninstall.unified.removed_settings": " removed harnessed env vars from ~/.claude/settings.json",
|
|
1420
|
+
"uninstall.unified.removed_hooks": " removed {{count}} harnessed hook(s) from ~/.claude/settings.json",
|
|
1421
|
+
"uninstall.unified.removed_state_dir": " removed ~/.claude/harnessed/",
|
|
1422
|
+
"uninstall.unified.partial_failure": "\n{{count}} item(s) could not be removed (permission denied or already gone):",
|
|
1423
|
+
"uninstall.unified.complete": "uninstall complete \u2014 harnessed's own files have been removed",
|
|
1424
|
+
"uninstall.unified.cli_hint_header": "\nto remove the harnessed CLI itself (the step above did not \u2014 it only cleared setup files):",
|
|
1425
|
+
"uninstall.unified.cli_hint_binary": " binary: delete {{path}}\n then remove {{dir}} from your PATH",
|
|
1426
|
+
"uninstall.unified.cli_hint_npm": " npm: npm uninstall -g harnessed",
|
|
1427
|
+
"uninstall.unified.cli_hint_other": " installed both ways? remove the other too \u2014 npm: 'npm uninstall -g harnessed' / binary: delete the exe + its bin dir from PATH",
|
|
1428
|
+
"gc.invalid_duration": "error: invalid --older-than '{{value}}'",
|
|
1429
|
+
"gc.invalid_duration.fix": " fix: use format <N>{d|h|m|w} e.g. 30d / 24h / 60m / 4w",
|
|
1430
|
+
"gc.no_backups": "no backups found ({{root}} absent) \u2014 nothing to gc",
|
|
1431
|
+
"gc.no_old_snapshots": "no snapshots older than {{cutoff}} (kept {{keptCount}} most-recent)",
|
|
1432
|
+
"gc.summary_will_delete": "would delete {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
1433
|
+
"gc.summary_deleting": "deleting {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
1434
|
+
"gc.dry_run_rerun_hint": "\n(dry-run \u2014 re-run without --dry-run to actually delete)",
|
|
1435
|
+
"gc.ledger_will_prune": "would prune {{count}} stale workflow slot(s) from the ledger (kept {{kept}}):",
|
|
1436
|
+
"gc.ledger_pruned": "pruned {{count}} stale workflow slot(s) from the ledger (kept {{kept}}):",
|
|
1437
|
+
"doctor.summary.fail": "\nsome checks failed (see fix hints above)",
|
|
1438
|
+
"doctor.summary.warn": "\nall checks ok (with warnings \u2014 see hints above)",
|
|
1439
|
+
"doctor.summary.pass": "\nall checks passed",
|
|
1440
|
+
"doctor.host_scope": "host: {{host}} \u2014 {{applied}} of {{total}} checks apply\n",
|
|
1441
|
+
"doctor.matrix.legend": "\nn/a = the check is not declared for that host in the registry, so it was not run",
|
|
1442
|
+
"check_docs.clean": "documentation discipline: no violations",
|
|
1443
|
+
"check_docs.state_line_limit": "STATE.md is {{lines}} lines > the {{limit}}-line digest limit \u2014 archive older phase narrative to RETROSPECTIVE.md (override for one run: HARNESSED_ALLOW_LONG_STATE=1)",
|
|
1444
|
+
"check_docs.state_key_decisions": "{{count}} '\u5173\u952E\u51B3\u8BAE ship \u603B\u7ED3' section(s) > {{limit}} \u2014 keep only the current one; move the rest to RETROSPECTIVE.md",
|
|
1445
|
+
"check_docs.state_errata": "historical commentary '{{excerpt}}' belongs in RETROSPECTIVE.md, not in the STATE digest",
|
|
1446
|
+
"check_docs.roadmap_narrative": "closing narrative inlined in an overview doc ({{signals}}) \u2014 ROADMAP carries one line + a pointer per phase; narrative goes to SUMMARY / VERIFICATION",
|
|
1447
|
+
"check_docs.summary_halt": "\ndocumentation discipline: {{halt}} blocking + {{warn}} advisory violation(s)",
|
|
1448
|
+
"check_docs.summary_warn": "\ndocumentation discipline: {{warn}} advisory violation(s) (non-blocking)",
|
|
1449
|
+
"backup.no_backups": "no backups found ({{root}} absent)",
|
|
1450
|
+
"backup.no_backups_empty": "no backups found ({{root}} empty)",
|
|
1451
|
+
"backup.total_snapshots": "\n{{count}} snapshot(s) total",
|
|
1452
|
+
"rollback.metadata_unreadable": "error: cannot read {{path}}: {{message}}",
|
|
1453
|
+
"rollback.metadata_unreadable.fix": " fix: run 'harnessed backup list' to see available timestamps",
|
|
1454
|
+
"rollback.checksum_mismatch": "error: backup checksum mismatch for {{target}} (expected {{expected}}, got {{actual}})",
|
|
1455
|
+
"rollback.restored": "restored {{count}} file(s) from {{timestamp}}",
|
|
1456
|
+
"status.no_installs": "no installs recorded ({{path}} absent or empty)",
|
|
1457
|
+
"status.summary_installs": "\n{{count}} install(s) recorded",
|
|
1458
|
+
"status.lock_held": "\nlock: held (since {{since}}){{staleSuffix}}",
|
|
1459
|
+
"status.lock_held.stale_suffix": " \u2014 STALE",
|
|
1460
|
+
"status.lock_release_hint": " to release: wait for process to finish or delete {{path}}",
|
|
1461
|
+
"status.lock_free": "\nlock: free",
|
|
1462
|
+
"here.no_workflow": "no active workflow for this repo ({{path}} has no entry for cwd)",
|
|
1463
|
+
"here.no_workflow.hint": " to start: run a stage (e.g. `harnessed gates discuss`) or `harnessed run <workflow>`",
|
|
1464
|
+
"audit_log.no_records_file": "no audit records found ({{path}} does not exist)",
|
|
1465
|
+
"audit_log.no_records_empty": "no audit records found (audit.log is empty)",
|
|
1466
|
+
"audit_log.jq_missing": "\u2717 jq not found in PATH \u2014 run: harnessed doctor",
|
|
1467
|
+
"audit_log.tail_invalid": "\u2717 --tail must be a positive integer",
|
|
1468
|
+
"audit_log.head_invalid": "\u2717 --head must be a positive integer",
|
|
1469
|
+
"execute_task.require_task": "error: --task <text> is required",
|
|
1470
|
+
"execute_task.load_phases_failed": "error: failed to load workflows/{{workflow}}/phases.yaml \u2014 {{message}}",
|
|
1471
|
+
"execute_task.precommit_skipped": "\u26A0\uFE0F before-commit pre-flight skipped ({{message}}); subagent will biome-check at commit time.",
|
|
1472
|
+
"research.require_query": "error: --query <text> is required",
|
|
1473
|
+
"manifest_add.non_interactive_warn": "[ee-5-gate] WARN: --non-interactive skips 5-question prompt (D-03 dry-run-only). plan-phase hard reject still applies.",
|
|
1474
|
+
"manifest_add.dry_run_preview": "[manifest-add] dry-run preview for upstream: {{upstream}} \u2192 {{path}}",
|
|
1475
|
+
"manifest_add.empty_answer": "error: EE-5 gate requires non-empty answer",
|
|
1476
|
+
"manifest_add.gate_passed_wrote": "[manifest-add] EE-5 gate passed; wrote {{path}}",
|
|
1477
|
+
"manifest_add.gate_passed_dry_run": "[manifest-add] EE-5 gate passed (dry-run); would write {{path}}",
|
|
1478
|
+
"resume.fail": "\u2717 {{error}}",
|
|
1479
|
+
"resume.corrupt": "\u2717 {{error}}\n path: {{path}}"
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
function mapToSupported(raw) {
|
|
1484
|
+
if (!raw) return "en";
|
|
1485
|
+
if (/^zh([^a-z]|$)/i.test(raw)) return "zh-Hans";
|
|
1486
|
+
return "en";
|
|
1487
|
+
}
|
|
1488
|
+
function detectLocale() {
|
|
1489
|
+
const raw = process.env.HARNESSED_LANG || process.env.LC_ALL || process.env.LANG || process.env.LANGUAGE || safeIntlLocale();
|
|
1490
|
+
return mapToSupported(raw);
|
|
1491
|
+
}
|
|
1492
|
+
function safeIntlLocale() {
|
|
1493
|
+
try {
|
|
1494
|
+
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
1495
|
+
} catch {
|
|
1496
|
+
return void 0;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
function wireMessagesDir(provider) {
|
|
1500
|
+
wiredMessagesDirProvider = provider;
|
|
1501
|
+
}
|
|
1502
|
+
function messagesDir() {
|
|
1503
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
1504
|
+
const candidates = [];
|
|
1505
|
+
if (wiredMessagesDirProvider) {
|
|
1506
|
+
try {
|
|
1507
|
+
candidates.push(wiredMessagesDirProvider());
|
|
1508
|
+
} catch {
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
candidates.push(resolve(here, "..", "..", "messages"), resolve(here, "..", "messages"));
|
|
1512
|
+
for (const c of candidates) {
|
|
1513
|
+
try {
|
|
1514
|
+
readFileSync(join(c, "en.json"), "utf8");
|
|
1515
|
+
return c;
|
|
1516
|
+
} catch {
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
return resolve(process.cwd(), "messages");
|
|
1520
|
+
}
|
|
1521
|
+
function loadLocale(locale) {
|
|
1522
|
+
if (cache[locale]) return cache[locale];
|
|
1523
|
+
const path = join(messagesDir(), `${locale}.json`);
|
|
1524
|
+
try {
|
|
1525
|
+
const raw = readFileSync(path, "utf8");
|
|
1526
|
+
cache[locale] = JSON.parse(raw);
|
|
1527
|
+
} catch {
|
|
1528
|
+
cache[locale] = locale === "en" ? en_default : {};
|
|
1529
|
+
}
|
|
1530
|
+
return cache[locale];
|
|
1531
|
+
}
|
|
1532
|
+
function setLocale(locale) {
|
|
1533
|
+
if (!locale) return;
|
|
1534
|
+
const mapped = mapToSupported(locale);
|
|
1535
|
+
if (SUPPORTED.has(mapped)) currentLocale = mapped;
|
|
1536
|
+
}
|
|
1537
|
+
function getLocale() {
|
|
1538
|
+
if (currentLocale === null) currentLocale = detectLocale();
|
|
1539
|
+
return currentLocale;
|
|
1540
|
+
}
|
|
1541
|
+
function t(key, params) {
|
|
1542
|
+
const locale = getLocale();
|
|
1543
|
+
const primary = loadLocale(locale);
|
|
1544
|
+
let template = primary[key];
|
|
1545
|
+
if (template === void 0 && locale !== "en") {
|
|
1546
|
+
template = loadLocale("en")[key];
|
|
1547
|
+
}
|
|
1548
|
+
if (template === void 0) template = key;
|
|
1549
|
+
if (!params) return template;
|
|
1550
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_match, name) => {
|
|
1551
|
+
const v = params[name];
|
|
1552
|
+
return v === void 0 ? `{{${name}}}` : String(v);
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
var SUPPORTED, currentLocale, cache, wiredMessagesDirProvider;
|
|
1556
|
+
var init_i18n = __esm({
|
|
1557
|
+
"src/i18n/index.ts"() {
|
|
1558
|
+
init_en();
|
|
1559
|
+
SUPPORTED = /* @__PURE__ */ new Set(["en", "zh-Hans"]);
|
|
1560
|
+
currentLocale = null;
|
|
1561
|
+
cache = {};
|
|
1562
|
+
wiredMessagesDirProvider = null;
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
function getPackageRoot() {
|
|
1566
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
1567
|
+
const thisDir = dirname(thisFile);
|
|
1568
|
+
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
1569
|
+
return resolve(thisDir, "..");
|
|
1570
|
+
}
|
|
1571
|
+
return resolve(thisDir, "..", "..");
|
|
1572
|
+
}
|
|
1573
|
+
var init_packagePath = __esm({
|
|
1574
|
+
"src/platform/packagePath.ts"() {
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
|
|
1578
|
+
// src/platform/assetsRoot.ts
|
|
1579
|
+
var assetsRoot_exports = {};
|
|
1580
|
+
__export(assetsRoot_exports, {
|
|
1581
|
+
compiledAssetsDir: () => compiledAssetsDir,
|
|
1582
|
+
computeAssetsRoot: () => computeAssetsRoot,
|
|
1583
|
+
getAssetsRoot: () => getAssetsRoot,
|
|
1584
|
+
isCompiledModuleUrl: () => isCompiledModuleUrl,
|
|
1585
|
+
isCompiledRuntime: () => isCompiledRuntime
|
|
1586
|
+
});
|
|
1587
|
+
function isCompiledRuntime(url = import.meta.url) {
|
|
1588
|
+
return isCompiledModuleUrl(url);
|
|
1589
|
+
}
|
|
1590
|
+
function isCompiledModuleUrl(url) {
|
|
1591
|
+
let s = url;
|
|
1592
|
+
try {
|
|
1593
|
+
s = decodeURIComponent(url);
|
|
1594
|
+
} catch {
|
|
1595
|
+
}
|
|
1596
|
+
const normalized2 = s.replace(/\\/g, "/").toLowerCase();
|
|
1597
|
+
return BUNFS_MARKERS.some((m) => normalized2.includes(m));
|
|
1598
|
+
}
|
|
1599
|
+
function computeAssetsRoot(d) {
|
|
1600
|
+
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
1601
|
+
if (override && override.trim().length > 0) {
|
|
1602
|
+
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
1603
|
+
}
|
|
1604
|
+
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
1605
|
+
const root = join(d.stateRoot(), "assets", d.version);
|
|
1606
|
+
const present = d.exists(join(root, "workflows"));
|
|
1607
|
+
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
1608
|
+
}
|
|
1609
|
+
return { root: d.packageRoot, source: "package", compiledAssetsMissing: false };
|
|
1610
|
+
}
|
|
1611
|
+
function compiledAssetsDir(version) {
|
|
1612
|
+
return join(detectPlatform().stateRoot, "assets", version);
|
|
1613
|
+
}
|
|
1614
|
+
function realDeps() {
|
|
1615
|
+
return {
|
|
1616
|
+
env: process.env,
|
|
1617
|
+
moduleUrl: import.meta.url,
|
|
1618
|
+
exists: (p8) => {
|
|
1619
|
+
try {
|
|
1620
|
+
return existsSync(p8);
|
|
1621
|
+
} catch {
|
|
1622
|
+
return false;
|
|
1623
|
+
}
|
|
1624
|
+
},
|
|
1625
|
+
stateRoot: () => detectPlatform().stateRoot,
|
|
1626
|
+
packageRoot: getPackageRoot(),
|
|
1627
|
+
version: package_default.version
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
function getAssetsRoot() {
|
|
1631
|
+
const r = computeAssetsRoot(realDeps());
|
|
1632
|
+
if (r.source === "compiled" && r.compiledAssetsMissing && !warnedMissing) {
|
|
1633
|
+
warnedMissing = true;
|
|
1634
|
+
console.error(
|
|
1635
|
+
`warning: compiled harnessed binary but bundled assets are not unpacked at ${r.root} \u2014 asset-dependent commands (setup / run / prompt / install) will fail. Reinstall the binary, or use the npm distribution (npm i -g harnessed). (asset unpack pipeline lands in a later release \u2014 B1 seam)`
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
return r.root;
|
|
1639
|
+
}
|
|
1640
|
+
var BUNFS_MARKERS, warnedMissing;
|
|
1641
|
+
var init_assetsRoot = __esm({
|
|
1642
|
+
"src/platform/assetsRoot.ts"() {
|
|
1643
|
+
init_package();
|
|
1644
|
+
init_packagePath();
|
|
1645
|
+
init_platform();
|
|
1646
|
+
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
1647
|
+
warnedMissing = false;
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
function resolveLocaleYaml(dir, baseName, locale = getLocale()) {
|
|
1651
|
+
if (locale !== "en") {
|
|
1652
|
+
const sibling = join(dir, `${baseName}.${locale}.yaml`);
|
|
1653
|
+
if (existsSync(sibling)) return sibling;
|
|
1654
|
+
}
|
|
1655
|
+
return join(dir, `${baseName}.yaml`);
|
|
1656
|
+
}
|
|
1657
|
+
var init_localeYaml = __esm({
|
|
1658
|
+
"src/i18n/localeYaml.ts"() {
|
|
1659
|
+
init_i18n();
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
async function loadRolePrompts(workflowsDir, locale = getLocale()) {
|
|
1663
|
+
const path = resolveLocaleYaml(workflowsDir, "role-prompts", locale);
|
|
1664
|
+
let raw;
|
|
1665
|
+
try {
|
|
1666
|
+
raw = await readFile(path, "utf8");
|
|
1667
|
+
} catch {
|
|
1668
|
+
return {};
|
|
1669
|
+
}
|
|
1670
|
+
const doc = parse(raw);
|
|
1671
|
+
return doc?.prompts ?? {};
|
|
1672
|
+
}
|
|
1673
|
+
function mapRolePromptText(rp, render) {
|
|
1674
|
+
const s = (v) => typeof v === "string" ? render(v) : v;
|
|
1675
|
+
return {
|
|
1676
|
+
...rp,
|
|
1677
|
+
specialist: s(rp.specialist),
|
|
1678
|
+
responsibility: s(rp.responsibility),
|
|
1679
|
+
checklist: Array.isArray(rp.checklist) ? rp.checklist.map((c) => s(c)) : rp.checklist,
|
|
1680
|
+
severity: s(rp.severity)
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
function mapRolePromptsText(prompts, render) {
|
|
1684
|
+
const out = {};
|
|
1685
|
+
for (const [name, rp] of Object.entries(prompts)) out[name] = mapRolePromptText(rp, render);
|
|
1686
|
+
return out;
|
|
1687
|
+
}
|
|
1688
|
+
var init_rolePrompts = __esm({
|
|
1689
|
+
"src/workflow/rolePrompts.ts"() {
|
|
1690
|
+
init_i18n();
|
|
1691
|
+
init_localeYaml();
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
async function scanWorkflowsNested(workflowsDir, entries) {
|
|
1695
|
+
const workflows = [];
|
|
1696
|
+
for (const entry of entries.sort()) {
|
|
1697
|
+
if (NON_WORKFLOW_DIRS.has(entry)) continue;
|
|
1698
|
+
const src = join(workflowsDir, entry);
|
|
1699
|
+
let s;
|
|
1700
|
+
try {
|
|
1701
|
+
s = await stat(src);
|
|
1702
|
+
} catch {
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
if (!s.isDirectory()) continue;
|
|
1706
|
+
let hasFlatSkill = false;
|
|
1707
|
+
try {
|
|
1708
|
+
await stat(join(src, "SKILL.md"));
|
|
1709
|
+
hasFlatSkill = true;
|
|
1710
|
+
} catch {
|
|
1711
|
+
hasFlatSkill = false;
|
|
1712
|
+
}
|
|
1713
|
+
if (hasFlatSkill) {
|
|
1714
|
+
if (FLAT_LEGACY_KEEP.has(entry)) {
|
|
1715
|
+
workflows.push({ name: entry, relPath: entry, isMaster: FLAT_TOP_LEVEL_MASTERS.has(entry) });
|
|
1716
|
+
continue;
|
|
1717
|
+
}
|
|
1718
|
+
workflows.push({ name: entry, relPath: entry, isMaster: false });
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
let subEntries;
|
|
1722
|
+
try {
|
|
1723
|
+
subEntries = await readdir(src);
|
|
1724
|
+
} catch {
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1727
|
+
for (const sub of subEntries.sort()) {
|
|
1728
|
+
const subDir = join(src, sub);
|
|
1729
|
+
let ss;
|
|
1730
|
+
try {
|
|
1731
|
+
ss = await stat(subDir);
|
|
1732
|
+
} catch {
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
if (!ss.isDirectory()) continue;
|
|
1736
|
+
try {
|
|
1737
|
+
await stat(join(subDir, "SKILL.md"));
|
|
1738
|
+
} catch {
|
|
1739
|
+
continue;
|
|
1740
|
+
}
|
|
1741
|
+
const name = sub === "auto" ? entry : `${entry}-${sub}`;
|
|
1742
|
+
workflows.push({ name, relPath: `${entry}/${sub}`, isMaster: sub === "auto" });
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
return { workflows };
|
|
1746
|
+
}
|
|
1747
|
+
var FLAT_LEGACY_KEEP, FLAT_TOP_LEVEL_MASTERS, NON_WORKFLOW_DIRS;
|
|
1748
|
+
var init_scan_nested = __esm({
|
|
1749
|
+
"src/workflow/scan-nested.ts"() {
|
|
1750
|
+
FLAT_LEGACY_KEEP = /* @__PURE__ */ new Set(["research", "retro", "auto"]);
|
|
1751
|
+
FLAT_TOP_LEVEL_MASTERS = /* @__PURE__ */ new Set(["auto"]);
|
|
1752
|
+
NON_WORKFLOW_DIRS = /* @__PURE__ */ new Set(["disciplines", "judgments"]);
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
function toHostId(id) {
|
|
1756
|
+
return id === "codex" ? "codex" : "claude";
|
|
1757
|
+
}
|
|
1758
|
+
async function loadHostPrimitives(opts) {
|
|
1759
|
+
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
1760
|
+
let raw;
|
|
1761
|
+
try {
|
|
1762
|
+
raw = await readFile(path, "utf8");
|
|
1763
|
+
} catch {
|
|
1764
|
+
return {};
|
|
1765
|
+
}
|
|
1766
|
+
const doc = parse(raw);
|
|
1767
|
+
return doc?.primitives ?? {};
|
|
1768
|
+
}
|
|
1769
|
+
async function loadHostMapNotes(opts) {
|
|
1770
|
+
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
1771
|
+
let raw;
|
|
1772
|
+
try {
|
|
1773
|
+
raw = await readFile(path, "utf8");
|
|
1774
|
+
} catch {
|
|
1775
|
+
return [];
|
|
1776
|
+
}
|
|
1777
|
+
const doc = parse(raw);
|
|
1778
|
+
const notes = doc?.host_map_notes?.[opts.host];
|
|
1779
|
+
return Array.isArray(notes) ? notes.filter((n) => typeof n === "string") : [];
|
|
1780
|
+
}
|
|
1781
|
+
function loadHostPrimitivesCached(opts) {
|
|
1782
|
+
const locale = opts.locale ?? getLocale();
|
|
1783
|
+
const key = `${opts.workflowsDir}|${locale}`;
|
|
1784
|
+
const hit = _tableCache.get(key);
|
|
1785
|
+
if (hit) return hit;
|
|
1786
|
+
const p8 = loadHostPrimitives({ workflowsDir: opts.workflowsDir, locale });
|
|
1787
|
+
_tableCache.set(key, p8);
|
|
1788
|
+
return p8;
|
|
1789
|
+
}
|
|
1790
|
+
function templateRe() {
|
|
1791
|
+
return new RegExp(HOST_PRIMITIVE_TEMPLATE.source, "g");
|
|
1792
|
+
}
|
|
1793
|
+
function lineOf(body, offset) {
|
|
1794
|
+
let line = 1;
|
|
1795
|
+
for (let i = 0; i < offset && i < body.length; i++) if (body[i] === "\n") line++;
|
|
1796
|
+
return line;
|
|
1797
|
+
}
|
|
1798
|
+
function renderHostPrimitives(body, opts) {
|
|
1799
|
+
const { host, table } = opts;
|
|
1800
|
+
return body.replace(
|
|
1801
|
+
templateRe(),
|
|
1802
|
+
(match, primitive, variant, offset) => {
|
|
1803
|
+
const name = variant ?? DEFAULT_VARIANT;
|
|
1804
|
+
const where = `'${match}' at line ${lineOf(body, offset)} (offset ${offset})`;
|
|
1805
|
+
const variants = table[primitive];
|
|
1806
|
+
if (!variants) {
|
|
1807
|
+
throw new Error(
|
|
1808
|
+
`unknown host primitive 'host.${primitive}' \u2014 ${where}; not defined in host-primitives.yaml`
|
|
1809
|
+
);
|
|
1810
|
+
}
|
|
1811
|
+
const entry = variants[name];
|
|
1812
|
+
if (!entry) {
|
|
1813
|
+
throw new Error(
|
|
1814
|
+
`unknown variant '${name}' for host primitive '${primitive}' \u2014 ${where}; defined variants: ${Object.keys(variants).sort().join(", ") || "(none)"}`
|
|
1815
|
+
);
|
|
1816
|
+
}
|
|
1817
|
+
const text = entry[host];
|
|
1818
|
+
if (text === void 0) {
|
|
1819
|
+
throw new Error(
|
|
1820
|
+
`host primitive '${primitive}.${name}' has no text for host '${host}' \u2014 ${where}; defined hosts: ${Object.keys(entry).sort().join(", ") || "(none)"}`
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
return text;
|
|
1824
|
+
}
|
|
1825
|
+
);
|
|
1826
|
+
}
|
|
1827
|
+
function cell(text) {
|
|
1828
|
+
return text.replaceAll("|", "\\|");
|
|
1829
|
+
}
|
|
1830
|
+
function code(text) {
|
|
1831
|
+
return text.includes("`") ? text : `\`${text}\``;
|
|
1832
|
+
}
|
|
1833
|
+
function hostMapRows(table) {
|
|
1834
|
+
const rows = [];
|
|
1835
|
+
for (const primitive of Object.keys(table).sort()) {
|
|
1836
|
+
const entry = table[primitive]?.[DEFAULT_VARIANT];
|
|
1837
|
+
const claude = entry?.claude;
|
|
1838
|
+
const codex = entry?.codex;
|
|
1839
|
+
if (claude === void 0 || codex === void 0) continue;
|
|
1840
|
+
if (claude.includes("\n") || codex.includes("\n")) continue;
|
|
1841
|
+
if (claude.length > TERM_MAX_LEN || codex.length > TERM_MAX_LEN) continue;
|
|
1842
|
+
rows.push({ primitive, claude, codex });
|
|
1843
|
+
}
|
|
1844
|
+
return rows;
|
|
1845
|
+
}
|
|
1846
|
+
function buildHostMapSection(opts) {
|
|
1847
|
+
const { host, table } = opts;
|
|
1848
|
+
if (host === "claude") return "";
|
|
1849
|
+
const rows = hostMapRows(table);
|
|
1850
|
+
const notes = opts.notes ?? [];
|
|
1851
|
+
if (rows.length === 0 && notes.length === 0) return "";
|
|
1852
|
+
const skillsDir = table.skills_dir?.[DEFAULT_VARIANT]?.[host];
|
|
1853
|
+
const where = skillsDir ? ` and installed it under ${code(skillsDir)}` : "";
|
|
1854
|
+
const lines = [
|
|
1855
|
+
HOST_MAP_START,
|
|
1856
|
+
`## Host map \u2014 ${host}`,
|
|
1857
|
+
"",
|
|
1858
|
+
`harnessed rendered this artifact for the **${host}** harness${where}. The workflow prose was authored against Claude Code, so where a step names a tool it names the ${host} one. Use the table to decode any instruction that still reads as Claude-Code-shaped; do not substitute the Claude Code names back.`
|
|
1859
|
+
];
|
|
1860
|
+
if (rows.length > 0) {
|
|
1861
|
+
lines.push(
|
|
1862
|
+
"",
|
|
1863
|
+
`| primitive | Claude Code | ${host} |`,
|
|
1864
|
+
"| --- | --- | --- |",
|
|
1865
|
+
...rows.map(
|
|
1866
|
+
(r) => `| \`${r.primitive}\` | ${cell(code(r.claude))} | ${cell(code(r.codex))} |`
|
|
1867
|
+
)
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
if (notes.length > 0) {
|
|
1871
|
+
lines.push("", "Caveats \u2014 these hold for the whole artifact:", "");
|
|
1872
|
+
for (const n of notes) lines.push(`- ${n}`);
|
|
1873
|
+
}
|
|
1874
|
+
lines.push(HOST_MAP_END);
|
|
1875
|
+
return lines.join("\n");
|
|
1876
|
+
}
|
|
1877
|
+
function regionRe() {
|
|
1878
|
+
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1879
|
+
return new RegExp(`${esc(HOST_MAP_START)}[\\s\\S]*?${esc(HOST_MAP_END)}\\n*`, "g");
|
|
1880
|
+
}
|
|
1881
|
+
function insertHostMapSection(body, section) {
|
|
1882
|
+
if (section === "") return body;
|
|
1883
|
+
const stripped = body.replace(regionRe(), "");
|
|
1884
|
+
const fm = FRONTMATTER_RX.exec(stripped);
|
|
1885
|
+
const offset = fm ? fm[0].length : 0;
|
|
1886
|
+
const before = stripped.slice(0, offset);
|
|
1887
|
+
const after = stripped.slice(offset).replace(/^\n+/, "");
|
|
1888
|
+
const lead = offset === 0 ? "" : "\n";
|
|
1889
|
+
return `${before}${lead}${section}
|
|
1890
|
+
|
|
1891
|
+
${after}`;
|
|
1892
|
+
}
|
|
1893
|
+
var DEFAULT_VARIANT, YAML_BASE, _tableCache, HOST_PRIMITIVE_TEMPLATE, HOST_MAP_START, HOST_MAP_END, TERM_MAX_LEN, FRONTMATTER_RX;
|
|
1894
|
+
var init_hostPrimitives = __esm({
|
|
1895
|
+
"src/cli/lib/hostPrimitives.ts"() {
|
|
1896
|
+
init_i18n();
|
|
1897
|
+
init_localeYaml();
|
|
1898
|
+
DEFAULT_VARIANT = "default";
|
|
1899
|
+
YAML_BASE = "host-primitives";
|
|
1900
|
+
_tableCache = /* @__PURE__ */ new Map();
|
|
1901
|
+
HOST_PRIMITIVE_TEMPLATE = /\{\{\s*host\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?\s*\}\}/g;
|
|
1902
|
+
HOST_MAP_START = "<!-- harnessed:host-map:start -->";
|
|
1903
|
+
HOST_MAP_END = "<!-- harnessed:host-map:end -->";
|
|
1904
|
+
TERM_MAX_LEN = 64;
|
|
1905
|
+
FRONTMATTER_RX = /^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(\r?\n|$)/;
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
|
|
1909
|
+
// src/cli/lib/agentsMd.ts
|
|
1910
|
+
var agentsMd_exports = {};
|
|
1911
|
+
__export(agentsMd_exports, {
|
|
1912
|
+
AGENTS_MD_END: () => AGENTS_MD_END,
|
|
1913
|
+
AGENTS_MD_START: () => AGENTS_MD_START,
|
|
1914
|
+
agentsMdPath: () => agentsMdPath,
|
|
1915
|
+
buildAgentsMdSection: () => buildAgentsMdSection,
|
|
1916
|
+
insertAgentsMdSection: () => insertAgentsMdSection,
|
|
1917
|
+
resolveCommandNames: () => resolveCommandNames,
|
|
1918
|
+
runAgentsMd: () => runAgentsMd,
|
|
1919
|
+
stripAgentsMdSection: () => stripAgentsMdSection
|
|
1920
|
+
});
|
|
1921
|
+
function agentsMdPath() {
|
|
1922
|
+
return join(detectPlatform().homeDir, "AGENTS.md");
|
|
1220
1923
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1924
|
+
function buildAgentsMdSection(opts) {
|
|
1925
|
+
const { commands, commandsDir, table } = opts;
|
|
1926
|
+
const hostMap = buildHostMapSection({ host: "codex", table, notes: opts.notes });
|
|
1927
|
+
const lines = [
|
|
1928
|
+
AGENTS_MD_START,
|
|
1929
|
+
"",
|
|
1930
|
+
"## harnessed",
|
|
1931
|
+
"",
|
|
1932
|
+
"This block is GENERATED by `harnessed agents-md`. Edits inside the markers are",
|
|
1933
|
+
"overwritten on the next run; put anything hand-written OUTSIDE them.",
|
|
1934
|
+
"",
|
|
1935
|
+
`harnessed installs its slash commands as prompt files under \`${commandsDir}\`.`,
|
|
1936
|
+
"Invoke one by name to enter the orchestration engine:",
|
|
1937
|
+
"",
|
|
1938
|
+
...commands.length > 0 ? commands.map((c) => `- \`/${c}\``) : ["- (none installed \u2014 run `harnessed setup`)"],
|
|
1939
|
+
"",
|
|
1940
|
+
"Each command file carries its own description in frontmatter; read it there rather",
|
|
1941
|
+
"than guessing from the name.",
|
|
1942
|
+
""
|
|
1943
|
+
];
|
|
1944
|
+
if (hostMap !== "") lines.push(hostMap.trimEnd(), "");
|
|
1945
|
+
lines.push(AGENTS_MD_END, "");
|
|
1946
|
+
return lines.join("\n");
|
|
1947
|
+
}
|
|
1948
|
+
function stripAgentsMdSection(body) {
|
|
1949
|
+
const a = body.indexOf(AGENTS_MD_START);
|
|
1950
|
+
if (a === -1) return body;
|
|
1951
|
+
const b = body.indexOf(AGENTS_MD_END, a);
|
|
1952
|
+
if (b === -1) return body;
|
|
1953
|
+
const head = body.slice(0, a);
|
|
1954
|
+
const tail = body.slice(b + AGENTS_MD_END.length);
|
|
1955
|
+
return `${head.replace(/\n+$/, "\n")}${tail.replace(/^\n+/, "")}`;
|
|
1956
|
+
}
|
|
1957
|
+
function insertAgentsMdSection(body, section) {
|
|
1958
|
+
const base = stripAgentsMdSection(body);
|
|
1959
|
+
if (section === "") return base;
|
|
1960
|
+
const sep3 = base === "" || base.endsWith("\n\n") ? "" : base.endsWith("\n") ? "\n" : "\n\n";
|
|
1961
|
+
return `${base}${sep3}${section}`;
|
|
1962
|
+
}
|
|
1963
|
+
async function resolveCommandNames(workflowsDir) {
|
|
1964
|
+
const { readdir: readdir20 } = await import('fs/promises');
|
|
1965
|
+
const entries = await readdir20(workflowsDir);
|
|
1966
|
+
const { workflows } = await scanWorkflowsNested(workflowsDir, entries);
|
|
1967
|
+
const prompts = await loadRolePrompts(workflowsDir);
|
|
1968
|
+
return workflows.map((w) => w.name).filter((n) => prompts[n] !== void 0).sort();
|
|
1969
|
+
}
|
|
1970
|
+
async function runAgentsMd(opts) {
|
|
1971
|
+
const path = agentsMdPath();
|
|
1972
|
+
const read2 = opts.deps?.readFile ?? ((p8) => readFile(p8, "utf8"));
|
|
1973
|
+
const write = opts.deps?.writeFile ?? ((p8, c) => writeFile(p8, c, "utf8"));
|
|
1974
|
+
let current = "";
|
|
1975
|
+
let existed = true;
|
|
1976
|
+
try {
|
|
1977
|
+
current = await read2(path);
|
|
1978
|
+
} catch {
|
|
1979
|
+
existed = false;
|
|
1980
|
+
}
|
|
1981
|
+
if (opts.remove === true) {
|
|
1982
|
+
if (!existed) return { status: "absent", path };
|
|
1983
|
+
const next2 = stripAgentsMdSection(current);
|
|
1984
|
+
if (next2 === current) return { status: "unchanged", path };
|
|
1985
|
+
if (opts.dryRun !== true) await write(path, next2);
|
|
1986
|
+
return { status: "removed", path };
|
|
1987
|
+
}
|
|
1988
|
+
const locale = opts.locale ?? "en";
|
|
1989
|
+
const section = buildAgentsMdSection({
|
|
1990
|
+
commands: await resolveCommandNames(opts.workflowsDir),
|
|
1991
|
+
commandsDir: detectPlatform().commandsDir,
|
|
1992
|
+
table: await loadHostPrimitives({ workflowsDir: opts.workflowsDir, locale }),
|
|
1993
|
+
notes: await loadHostMapNotes({ workflowsDir: opts.workflowsDir, locale, host: "codex" })
|
|
1994
|
+
});
|
|
1995
|
+
const next = insertAgentsMdSection(current, section);
|
|
1996
|
+
if (existed && next === current) return { status: "unchanged", path };
|
|
1997
|
+
const action = !existed ? "create" : current.includes(AGENTS_MD_START) ? "replace" : "append";
|
|
1998
|
+
if (opts.dryRun === true) return { status: "preview", path, action, section };
|
|
1999
|
+
await write(path, next);
|
|
2000
|
+
return { status: "written", path, action };
|
|
2001
|
+
}
|
|
2002
|
+
var AGENTS_MD_START, AGENTS_MD_END;
|
|
2003
|
+
var init_agentsMd = __esm({
|
|
2004
|
+
"src/cli/lib/agentsMd.ts"() {
|
|
2005
|
+
init_platform();
|
|
2006
|
+
init_rolePrompts();
|
|
2007
|
+
init_scan_nested();
|
|
2008
|
+
init_hostPrimitives();
|
|
2009
|
+
AGENTS_MD_START = "<!-- harnessed:agents-md:start -->";
|
|
2010
|
+
AGENTS_MD_END = "<!-- harnessed:agents-md:end -->";
|
|
1224
2011
|
}
|
|
1225
2012
|
});
|
|
1226
2013
|
|
|
@@ -1748,7 +2535,7 @@ var init_schema2 = __esm({
|
|
|
1748
2535
|
};
|
|
1749
2536
|
}
|
|
1750
2537
|
});
|
|
1751
|
-
function
|
|
2538
|
+
function lineOf2(node, lineCounter) {
|
|
1752
2539
|
if (!node?.range) return null;
|
|
1753
2540
|
const offset = node.range[0];
|
|
1754
2541
|
return lineCounter.linePos(offset).line;
|
|
@@ -1770,7 +2557,7 @@ function checkScalarCmd(doc, lineCounter, path, filename) {
|
|
|
1770
2557
|
file: filename,
|
|
1771
2558
|
path: `/${path.join("/")}`,
|
|
1772
2559
|
message: `shell escape detected: '${pat.label}' (${pat.hint}) at ${path.join(".")} \u2014 v0.1 forbids dynamic shell evaluation; v0.2 will use \`requires_secret\` + \`\${secret:KEY}\` for env placeholders`,
|
|
1773
|
-
line:
|
|
2560
|
+
line: lineOf2(node, lineCounter),
|
|
1774
2561
|
column: null,
|
|
1775
2562
|
keyword: "security"
|
|
1776
2563
|
};
|
|
@@ -1810,7 +2597,7 @@ function checkSecurityViolations(doc, filename, lineCounter) {
|
|
|
1810
2597
|
file: filename,
|
|
1811
2598
|
path: `/spec/uninstall/cleanup_paths/${idx}`,
|
|
1812
2599
|
message: `shell escape detected: '${pat.label}' (${pat.hint}) at spec.uninstall.cleanup_paths[${idx}] \u2014 v0.1 forbids dynamic shell evaluation`,
|
|
1813
|
-
line:
|
|
2600
|
+
line: lineOf2(item, lineCounter),
|
|
1814
2601
|
column: null,
|
|
1815
2602
|
keyword: "security"
|
|
1816
2603
|
});
|
|
@@ -1879,310 +2666,102 @@ function validateManifestFile(yamlSource, filename) {
|
|
|
1879
2666
|
};
|
|
1880
2667
|
}
|
|
1881
2668
|
const securityErrors = checkSecurityViolations(doc, filename, lineCounter);
|
|
1882
|
-
if (securityErrors.length > 0) {
|
|
1883
|
-
return { ok: false, errors: securityErrors };
|
|
1884
|
-
}
|
|
1885
|
-
const data = doc.toJS();
|
|
1886
|
-
const validate = getValidator();
|
|
1887
|
-
if (!validate(data)) {
|
|
1888
|
-
const errs = validate.errors ?? [];
|
|
1889
|
-
return {
|
|
1890
|
-
ok: false,
|
|
1891
|
-
errors: errs.map((err2) => ajvErrorToFriendly(err2, filename, doc, lineCounter))
|
|
1892
|
-
};
|
|
1893
|
-
}
|
|
1894
|
-
const manifest = data;
|
|
1895
|
-
const crossFieldErrors = checkInstallTypeMismatch(manifest, filename);
|
|
1896
|
-
if (crossFieldErrors.length > 0) {
|
|
1897
|
-
return { ok: false, errors: crossFieldErrors };
|
|
1898
|
-
}
|
|
1899
|
-
return { ok: true, manifest };
|
|
1900
|
-
}
|
|
1901
|
-
var addFormats, ajv, _compiled, INSTALL_TYPE_METHODS;
|
|
1902
|
-
var init_validate = __esm({
|
|
1903
|
-
"src/manifest/validate.ts"() {
|
|
1904
|
-
init_errors();
|
|
1905
|
-
init_schema2();
|
|
1906
|
-
init_security();
|
|
1907
|
-
addFormats = ajvFormatsNs.default;
|
|
1908
|
-
ajv = addFormats(
|
|
1909
|
-
new Ajv({
|
|
1910
|
-
strict: true,
|
|
1911
|
-
strictSchema: true,
|
|
1912
|
-
strictTypes: true,
|
|
1913
|
-
strictRequired: true,
|
|
1914
|
-
allErrors: true,
|
|
1915
|
-
discriminator: true,
|
|
1916
|
-
allowUnionTypes: false
|
|
1917
|
-
})
|
|
1918
|
-
);
|
|
1919
|
-
_compiled = null;
|
|
1920
|
-
INSTALL_TYPE_METHODS = {
|
|
1921
|
-
npm: ["npm-cli"],
|
|
1922
|
-
mcp: ["mcp-stdio-add", "mcp-http-add"],
|
|
1923
|
-
git: ["git-clone-with-setup"],
|
|
1924
|
-
skill: ["cc-plugin-marketplace", "npx-skill-installer"],
|
|
1925
|
-
// 5th install_type (Phase 2.4). Missing here meant `install_type: hook` accepted
|
|
1926
|
-
// ANY method: an unconstrained bucket, not a closed one (external review L10).
|
|
1927
|
-
hook: ["cc-hook-add"]
|
|
1928
|
-
};
|
|
1929
|
-
}
|
|
1930
|
-
});
|
|
1931
|
-
|
|
1932
|
-
// src/cli/lib/origin-check.ts
|
|
1933
|
-
var origin_check_exports = {};
|
|
1934
|
-
__export(origin_check_exports, {
|
|
1935
|
-
checkOrigin: () => checkOrigin
|
|
1936
|
-
});
|
|
1937
|
-
function normalizeUrl(s) {
|
|
1938
|
-
return s.trim().replace(/^(https?:\/\/|git@github\.com:|ssh:\/\/git@github\.com\/)/, "").replace(/\.git$/, "").replace(":", "/").replace(/\/$/, "").toLowerCase();
|
|
1939
|
-
}
|
|
1940
|
-
function checkOrigin(cwd = process.cwd(), opts = {}) {
|
|
1941
|
-
const allowFork = opts.allowFork ?? true;
|
|
1942
|
-
let expected = null;
|
|
1943
|
-
try {
|
|
1944
|
-
const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
|
|
1945
|
-
expected = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url ?? null;
|
|
1946
|
-
} catch {
|
|
1947
|
-
}
|
|
1948
|
-
if (!expected) {
|
|
1949
|
-
return {
|
|
1950
|
-
status: "warn",
|
|
1951
|
-
detail: "package.json has no repository.url field",
|
|
1952
|
-
fix: "add `repository` field to package.json"
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
const r = spawnSync("git", ["config", "--get", "remote.origin.url"], {
|
|
1956
|
-
cwd,
|
|
1957
|
-
encoding: "utf8"
|
|
1958
|
-
});
|
|
1959
|
-
if (r.status !== 0) {
|
|
1960
|
-
return {
|
|
1961
|
-
status: "warn",
|
|
1962
|
-
detail: "no git remote origin (detached / non-clone)",
|
|
1963
|
-
fix: "git remote add origin <expected-url>"
|
|
1964
|
-
};
|
|
1965
|
-
}
|
|
1966
|
-
const actual = r.stdout.trim();
|
|
1967
|
-
if (normalizeUrl(actual) === normalizeUrl(expected)) {
|
|
1968
|
-
return { status: "pass", detail: actual };
|
|
1969
|
-
}
|
|
1970
|
-
return {
|
|
1971
|
-
status: allowFork ? "warn" : "fail",
|
|
1972
|
-
detail: `origin '${actual}' \u2260 expected '${expected}'`,
|
|
1973
|
-
fix: allowFork ? "verify intentional fork; if not, `git remote set-url origin <expected>`" : "origin URL drift \u2014 possible tamper, `git remote set-url origin <expected>` to restore"
|
|
1974
|
-
};
|
|
1975
|
-
}
|
|
1976
|
-
var init_origin_check = __esm({
|
|
1977
|
-
"src/cli/lib/origin-check.ts"() {
|
|
1978
|
-
}
|
|
1979
|
-
});
|
|
1980
|
-
|
|
1981
|
-
// messages/en.json
|
|
1982
|
-
var en_default;
|
|
1983
|
-
var init_en = __esm({
|
|
1984
|
-
"messages/en.json"() {
|
|
1985
|
-
en_default = {
|
|
1986
|
-
"setup.workflows_not_found": "error: workflows directory not found at {{path}}",
|
|
1987
|
-
"setup.nothing_to_install": "setup: no workflow directories with SKILL.md found \u2014 nothing to install",
|
|
1988
|
-
"setup.dry_run.header": "[dry-run] setup would install {{count}} workflow(s) to {{path}}:",
|
|
1989
|
-
"setup.dry_run.run_hint": " run without --dry-run to execute",
|
|
1990
|
-
"setup.copy_failed": " error: failed to copy {{name}}: {{message}}",
|
|
1991
|
-
"setup.step_a_complete": "Step A: {{count}} workflows installed to {{path}}",
|
|
1992
|
-
"setup.step_a_render.complete": " generated {{count}}/{{total}} command files",
|
|
1993
|
-
"setup.step_a_render.warnings_header": " [A.5] warnings \u2014 some capability cmds could not be fully resolved:",
|
|
1994
|
-
"setup.step_c.created": " [C] created {{path}} + enabled Agent Teams",
|
|
1995
|
-
"setup.step_c.already_enabled": " [C] Agent Teams already enabled ({{path}})",
|
|
1996
|
-
"setup.step_c.enabled_backup": " [C] enabled Agent Teams in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
1997
|
-
"setup.step_c.skipped": " [C] Agent Teams enable skipped: {{message}}",
|
|
1998
|
-
"setup.step_d.created": " [D] created {{path}} + wrote env.HARNESSED_USER_LANG={{lang}}",
|
|
1999
|
-
"setup.step_d.already_set": " [D] env.HARNESSED_USER_LANG={{lang}} already set in {{path}} \u2014 respecting user override",
|
|
2000
|
-
"setup.step_d.enabled_backup": " [D] wrote env.HARNESSED_USER_LANG={{lang}} in {{path}} (backup saved \u2192 {{backupPath}})",
|
|
2001
|
-
"setup.step_d.skipped": " [D] User language write skipped: {{message}}",
|
|
2002
|
-
"setup.step_b_complete": "Upstream components: {{installed}} installed / {{already}} already-installed / {{skipped}} skipped / {{failed}} failed [{{seconds}}s]",
|
|
2003
|
-
"setup.complete": "setup complete \u2014 {{skills}} workflows + {{manifests}} base manifests configured",
|
|
2004
|
-
"setup.mcp_hint": "Run /mcp in Claude Code to verify MCP server connections.",
|
|
2005
|
-
"setup.mcp_hint_codex": "Run codex mcp list to verify MCP server connections.",
|
|
2006
|
-
"setup.search_key_hint.header": "\n\u26A0 Search MCP API keys missing \u2014 the server(s) below are installed but will fail at query time until the key is configured:",
|
|
2007
|
-
"setup.search_key_hint.line": ' {{server}}: set {{envVar}} \u2014 add it to the ~/.claude/settings.json "env" block (e.g. {"env": {"{{envVar}}": "<your-key>"}}) or export {{envVar}} in your shell',
|
|
2008
|
-
"setup.optional_offer.ecc_note": " ecc (bonus tier): installing it unlocks finer-grained scenario orchestration (per-language review/build expert routing etc.); the trade-off is ~20k+ tokens/session of static listing overhead \u2014 inherent to ECC's own scale (281 skills / 94 commands / 67 agents), not introduced by harnessed.",
|
|
2009
|
-
"setup.bundled_summary": "\nharnessed workflows bundled at <packageRoot>/workflows/ (share-only, read-only)",
|
|
2010
|
-
"setup.bundled_location": "",
|
|
2011
|
-
"setup.doctor_hint": "\nRun harnessed doctor to verify your environment.",
|
|
2012
|
-
"agent_teams.missing_header": "\n\u26A0\uFE0F Agent Teams not enabled \u2014 parallelism upgrade path unavailable",
|
|
2013
|
-
"agent_teams.missing_fix": " fix: claude config set env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS 1",
|
|
2014
|
-
"agent_teams.missing_explanation": " harnessed task parallelism uses Subagent or Agent Teams (CC 2.1.178+)",
|
|
2015
|
-
"agent_teams.missing_nonblocking": " non-blocking \u2014 auto-degrades to subagent fan-out\n",
|
|
2016
|
-
"install.manifest_not_found": "error: manifest '{{name}}' not found",
|
|
2017
|
-
"install.manifest_not_found.fix": " fix: ensure manifests/tools/{{name}}.yaml, manifests/skill-packs/{{name}}.yaml, or manifests/optional/{{name}}.yaml exists",
|
|
2018
|
-
"install.audit_hint": " fix: run 'harnessed audit' to inspect manifest issues",
|
|
2019
|
-
"install.success": "installed {{name}}",
|
|
2020
|
-
"install.success_with_version": "installed {{name}}@{{version}}",
|
|
2021
|
-
"install.already_installed": "already-installed {{name}} (idempotent check hit; nothing to do)",
|
|
2022
|
-
"install.already_installed_with_version": "already-installed {{name}}@{{version}} (idempotent check hit; nothing to do)",
|
|
2023
|
-
"install.aborted": "aborted: {{reason}}",
|
|
2024
|
-
"uninstall.dry_run.preview": "[dry-run] would uninstall '{{name}}' via method '{{method}}'",
|
|
2025
|
-
"uninstall.dry_run.run_hint": " run without --dry-run to execute",
|
|
2026
|
-
"uninstall.confirm.prompt": "Uninstall '{{name}}'? This cannot be undone.",
|
|
2027
|
-
"uninstall.cancelled": "aborted: user cancelled",
|
|
2028
|
-
"uninstall.completed": "uninstalled {{name}}",
|
|
2029
|
-
"uninstall.unified.nothing": "nothing to do \u2014 no harnessed artifacts found",
|
|
2030
|
-
"uninstall.unified.header": "harnessed uninstall will remove the following:",
|
|
2031
|
-
"uninstall.unified.commands": " Commands: {{count}} harnessed-generated slash command file(s) in ~/.claude/commands/",
|
|
2032
|
-
"uninstall.unified.agent_roles": " Agent roles: {{count}} harnessed-generated codex agent role file(s) in ~/.codex/agents/",
|
|
2033
|
-
"uninstall.unified.skills": " Skills: {{count}} workflow skill directory(ies) in ~/.claude/skills/",
|
|
2034
|
-
"uninstall.unified.settings": " Settings: harnessed env vars (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, HARNESSED_USER_LANG) from ~/.claude/settings.json",
|
|
2035
|
-
"uninstall.unified.hooks": " Hooks: {{count}} harnessed Stop/UserPromptSubmit hook(s) in ~/.claude/settings.json",
|
|
2036
|
-
"uninstall.unified.state_dir": " State directory: ~/.claude/harnessed/ (includes backups, audit log, state, lock)",
|
|
2037
|
-
"uninstall.unified.upstream_note": "\nUpstream components (npm packages, MCP servers, CC plugins, git-cloned repos, npx skills) are NOT affected.",
|
|
2038
|
-
"uninstall.unified.dry_run_hint": "\n(dry-run \u2014 re-run without --dry-run to actually remove)",
|
|
2039
|
-
"uninstall.unified.confirm": "Remove harnessed's own files? Upstream components (npm packages, MCP servers, CC plugins, etc.) will NOT be affected. This cannot be undone.",
|
|
2040
|
-
"uninstall.unified.removing": "removing harnessed files...",
|
|
2041
|
-
"uninstall.unified.removed_commands": " removed {{count}} command file(s)",
|
|
2042
|
-
"uninstall.unified.removed_agent_roles": " removed {{count}} codex agent role file(s)",
|
|
2043
|
-
"uninstall.unified.removed_skills": " removed {{count}} skill directory(ies)",
|
|
2044
|
-
"uninstall.unified.removed_settings": " removed harnessed env vars from ~/.claude/settings.json",
|
|
2045
|
-
"uninstall.unified.removed_hooks": " removed {{count}} harnessed hook(s) from ~/.claude/settings.json",
|
|
2046
|
-
"uninstall.unified.removed_state_dir": " removed ~/.claude/harnessed/",
|
|
2047
|
-
"uninstall.unified.partial_failure": "\n{{count}} item(s) could not be removed (permission denied or already gone):",
|
|
2048
|
-
"uninstall.unified.complete": "uninstall complete \u2014 harnessed's own files have been removed",
|
|
2049
|
-
"uninstall.unified.cli_hint_header": "\nto remove the harnessed CLI itself (the step above did not \u2014 it only cleared setup files):",
|
|
2050
|
-
"uninstall.unified.cli_hint_binary": " binary: delete {{path}}\n then remove {{dir}} from your PATH",
|
|
2051
|
-
"uninstall.unified.cli_hint_npm": " npm: npm uninstall -g harnessed",
|
|
2052
|
-
"uninstall.unified.cli_hint_other": " installed both ways? remove the other too \u2014 npm: 'npm uninstall -g harnessed' / binary: delete the exe + its bin dir from PATH",
|
|
2053
|
-
"gc.invalid_duration": "error: invalid --older-than '{{value}}'",
|
|
2054
|
-
"gc.invalid_duration.fix": " fix: use format <N>{d|h|m|w} e.g. 30d / 24h / 60m / 4w",
|
|
2055
|
-
"gc.no_backups": "no backups found ({{root}} absent) \u2014 nothing to gc",
|
|
2056
|
-
"gc.no_old_snapshots": "no snapshots older than {{cutoff}} (kept {{keptCount}} most-recent)",
|
|
2057
|
-
"gc.summary_will_delete": "would delete {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
2058
|
-
"gc.summary_deleting": "deleting {{count}} snapshot(s), ~{{sizeKb}} KB total:",
|
|
2059
|
-
"gc.dry_run_rerun_hint": "\n(dry-run \u2014 re-run without --dry-run to actually delete)",
|
|
2060
|
-
"doctor.summary.fail": "\nsome checks failed (see fix hints above)",
|
|
2061
|
-
"doctor.summary.warn": "\nall checks ok (with warnings \u2014 see hints above)",
|
|
2062
|
-
"doctor.summary.pass": "\nall checks passed",
|
|
2063
|
-
"doctor.host_scope": "host: {{host}} \u2014 {{applied}} of {{total}} checks apply\n",
|
|
2064
|
-
"doctor.matrix.legend": "\nn/a = the check is not declared for that host in the registry, so it was not run",
|
|
2065
|
-
"check_docs.clean": "documentation discipline: no violations",
|
|
2066
|
-
"check_docs.state_line_limit": "STATE.md is {{lines}} lines > the {{limit}}-line digest limit \u2014 archive older phase narrative to RETROSPECTIVE.md (override for one run: HARNESSED_ALLOW_LONG_STATE=1)",
|
|
2067
|
-
"check_docs.state_key_decisions": "{{count}} '\u5173\u952E\u51B3\u8BAE ship \u603B\u7ED3' section(s) > {{limit}} \u2014 keep only the current one; move the rest to RETROSPECTIVE.md",
|
|
2068
|
-
"check_docs.state_errata": "historical commentary '{{excerpt}}' belongs in RETROSPECTIVE.md, not in the STATE digest",
|
|
2069
|
-
"check_docs.roadmap_narrative": "closing narrative inlined in an overview doc ({{signals}}) \u2014 ROADMAP carries one line + a pointer per phase; narrative goes to SUMMARY / VERIFICATION",
|
|
2070
|
-
"check_docs.summary_halt": "\ndocumentation discipline: {{halt}} blocking + {{warn}} advisory violation(s)",
|
|
2071
|
-
"check_docs.summary_warn": "\ndocumentation discipline: {{warn}} advisory violation(s) (non-blocking)",
|
|
2072
|
-
"backup.no_backups": "no backups found ({{root}} absent)",
|
|
2073
|
-
"backup.no_backups_empty": "no backups found ({{root}} empty)",
|
|
2074
|
-
"backup.total_snapshots": "\n{{count}} snapshot(s) total",
|
|
2075
|
-
"rollback.metadata_unreadable": "error: cannot read {{path}}: {{message}}",
|
|
2076
|
-
"rollback.metadata_unreadable.fix": " fix: run 'harnessed backup list' to see available timestamps",
|
|
2077
|
-
"rollback.checksum_mismatch": "error: backup checksum mismatch for {{target}} (expected {{expected}}, got {{actual}})",
|
|
2078
|
-
"rollback.restored": "restored {{count}} file(s) from {{timestamp}}",
|
|
2079
|
-
"status.no_installs": "no installs recorded ({{path}} absent or empty)",
|
|
2080
|
-
"status.summary_installs": "\n{{count}} install(s) recorded",
|
|
2081
|
-
"status.lock_held": "\nlock: held (since {{since}}){{staleSuffix}}",
|
|
2082
|
-
"status.lock_held.stale_suffix": " \u2014 STALE",
|
|
2083
|
-
"status.lock_release_hint": " to release: wait for process to finish or delete {{path}}",
|
|
2084
|
-
"status.lock_free": "\nlock: free",
|
|
2085
|
-
"here.no_workflow": "no active workflow for this repo ({{path}} has no entry for cwd)",
|
|
2086
|
-
"here.no_workflow.hint": " to start: run a stage (e.g. `harnessed gates discuss`) or `harnessed run <workflow>`",
|
|
2087
|
-
"audit_log.no_records_file": "no audit records found ({{path}} does not exist)",
|
|
2088
|
-
"audit_log.no_records_empty": "no audit records found (audit.log is empty)",
|
|
2089
|
-
"audit_log.jq_missing": "\u2717 jq not found in PATH \u2014 run: harnessed doctor",
|
|
2090
|
-
"audit_log.tail_invalid": "\u2717 --tail must be a positive integer",
|
|
2091
|
-
"audit_log.head_invalid": "\u2717 --head must be a positive integer",
|
|
2092
|
-
"execute_task.require_task": "error: --task <text> is required",
|
|
2093
|
-
"execute_task.load_phases_failed": "error: failed to load workflows/{{workflow}}/phases.yaml \u2014 {{message}}",
|
|
2094
|
-
"execute_task.precommit_skipped": "\u26A0\uFE0F before-commit pre-flight skipped ({{message}}); subagent will biome-check at commit time.",
|
|
2095
|
-
"research.require_query": "error: --query <text> is required",
|
|
2096
|
-
"manifest_add.non_interactive_warn": "[ee-5-gate] WARN: --non-interactive skips 5-question prompt (D-03 dry-run-only). plan-phase hard reject still applies.",
|
|
2097
|
-
"manifest_add.dry_run_preview": "[manifest-add] dry-run preview for upstream: {{upstream}} \u2192 {{path}}",
|
|
2098
|
-
"manifest_add.empty_answer": "error: EE-5 gate requires non-empty answer",
|
|
2099
|
-
"manifest_add.gate_passed_wrote": "[manifest-add] EE-5 gate passed; wrote {{path}}",
|
|
2100
|
-
"manifest_add.gate_passed_dry_run": "[manifest-add] EE-5 gate passed (dry-run); would write {{path}}",
|
|
2101
|
-
"resume.fail": "\u2717 {{error}}",
|
|
2102
|
-
"resume.corrupt": "\u2717 {{error}}\n path: {{path}}"
|
|
2669
|
+
if (securityErrors.length > 0) {
|
|
2670
|
+
return { ok: false, errors: securityErrors };
|
|
2671
|
+
}
|
|
2672
|
+
const data = doc.toJS();
|
|
2673
|
+
const validate = getValidator();
|
|
2674
|
+
if (!validate(data)) {
|
|
2675
|
+
const errs = validate.errors ?? [];
|
|
2676
|
+
return {
|
|
2677
|
+
ok: false,
|
|
2678
|
+
errors: errs.map((err2) => ajvErrorToFriendly(err2, filename, doc, lineCounter))
|
|
2103
2679
|
};
|
|
2104
2680
|
}
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
if (
|
|
2108
|
-
|
|
2109
|
-
return "en";
|
|
2110
|
-
}
|
|
2111
|
-
function detectLocale() {
|
|
2112
|
-
const raw = process.env.HARNESSED_LANG || process.env.LC_ALL || process.env.LANG || process.env.LANGUAGE || safeIntlLocale();
|
|
2113
|
-
return mapToSupported(raw);
|
|
2114
|
-
}
|
|
2115
|
-
function safeIntlLocale() {
|
|
2116
|
-
try {
|
|
2117
|
-
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
2118
|
-
} catch {
|
|
2119
|
-
return void 0;
|
|
2681
|
+
const manifest = data;
|
|
2682
|
+
const crossFieldErrors = checkInstallTypeMismatch(manifest, filename);
|
|
2683
|
+
if (crossFieldErrors.length > 0) {
|
|
2684
|
+
return { ok: false, errors: crossFieldErrors };
|
|
2120
2685
|
}
|
|
2686
|
+
return { ok: true, manifest };
|
|
2121
2687
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2688
|
+
var addFormats, ajv, _compiled, INSTALL_TYPE_METHODS;
|
|
2689
|
+
var init_validate = __esm({
|
|
2690
|
+
"src/manifest/validate.ts"() {
|
|
2691
|
+
init_errors();
|
|
2692
|
+
init_schema2();
|
|
2693
|
+
init_security();
|
|
2694
|
+
addFormats = ajvFormatsNs.default;
|
|
2695
|
+
ajv = addFormats(
|
|
2696
|
+
new Ajv({
|
|
2697
|
+
strict: true,
|
|
2698
|
+
strictSchema: true,
|
|
2699
|
+
strictTypes: true,
|
|
2700
|
+
strictRequired: true,
|
|
2701
|
+
allErrors: true,
|
|
2702
|
+
discriminator: true,
|
|
2703
|
+
allowUnionTypes: false
|
|
2704
|
+
})
|
|
2705
|
+
);
|
|
2706
|
+
_compiled = null;
|
|
2707
|
+
INSTALL_TYPE_METHODS = {
|
|
2708
|
+
npm: ["npm-cli"],
|
|
2709
|
+
mcp: ["mcp-stdio-add", "mcp-http-add"],
|
|
2710
|
+
git: ["git-clone-with-setup"],
|
|
2711
|
+
skill: ["cc-plugin-marketplace", "npx-skill-installer"],
|
|
2712
|
+
// 5th install_type (Phase 2.4). Missing here meant `install_type: hook` accepted
|
|
2713
|
+
// ANY method: an unconstrained bucket, not a closed one (external review L10).
|
|
2714
|
+
hook: ["cc-hook-add"]
|
|
2715
|
+
};
|
|
2141
2716
|
}
|
|
2142
|
-
|
|
2717
|
+
});
|
|
2718
|
+
|
|
2719
|
+
// src/cli/lib/origin-check.ts
|
|
2720
|
+
var origin_check_exports = {};
|
|
2721
|
+
__export(origin_check_exports, {
|
|
2722
|
+
checkOrigin: () => checkOrigin
|
|
2723
|
+
});
|
|
2724
|
+
function normalizeUrl(s) {
|
|
2725
|
+
return s.trim().replace(/^(https?:\/\/|git@github\.com:|ssh:\/\/git@github\.com\/)/, "").replace(/\.git$/, "").replace(":", "/").replace(/\/$/, "").toLowerCase();
|
|
2143
2726
|
}
|
|
2144
|
-
function
|
|
2145
|
-
|
|
2146
|
-
|
|
2727
|
+
function checkOrigin(cwd = process.cwd(), opts = {}) {
|
|
2728
|
+
const allowFork = opts.allowFork ?? true;
|
|
2729
|
+
let expected = null;
|
|
2147
2730
|
try {
|
|
2148
|
-
const
|
|
2149
|
-
|
|
2731
|
+
const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
|
|
2732
|
+
expected = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url ?? null;
|
|
2150
2733
|
} catch {
|
|
2151
|
-
cache[locale] = locale === "en" ? en_default : {};
|
|
2152
2734
|
}
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
}
|
|
2160
|
-
function getLocale() {
|
|
2161
|
-
if (currentLocale === null) currentLocale = detectLocale();
|
|
2162
|
-
return currentLocale;
|
|
2163
|
-
}
|
|
2164
|
-
function t(key, params) {
|
|
2165
|
-
const locale = getLocale();
|
|
2166
|
-
const primary = loadLocale(locale);
|
|
2167
|
-
let template = primary[key];
|
|
2168
|
-
if (template === void 0 && locale !== "en") {
|
|
2169
|
-
template = loadLocale("en")[key];
|
|
2735
|
+
if (!expected) {
|
|
2736
|
+
return {
|
|
2737
|
+
status: "warn",
|
|
2738
|
+
detail: "package.json has no repository.url field",
|
|
2739
|
+
fix: "add `repository` field to package.json"
|
|
2740
|
+
};
|
|
2170
2741
|
}
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
const v = params[name];
|
|
2175
|
-
return v === void 0 ? `{{${name}}}` : String(v);
|
|
2742
|
+
const r = spawnSync("git", ["config", "--get", "remote.origin.url"], {
|
|
2743
|
+
cwd,
|
|
2744
|
+
encoding: "utf8"
|
|
2176
2745
|
});
|
|
2746
|
+
if (r.status !== 0) {
|
|
2747
|
+
return {
|
|
2748
|
+
status: "warn",
|
|
2749
|
+
detail: "no git remote origin (detached / non-clone)",
|
|
2750
|
+
fix: "git remote add origin <expected-url>"
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
const actual = r.stdout.trim();
|
|
2754
|
+
if (normalizeUrl(actual) === normalizeUrl(expected)) {
|
|
2755
|
+
return { status: "pass", detail: actual };
|
|
2756
|
+
}
|
|
2757
|
+
return {
|
|
2758
|
+
status: allowFork ? "warn" : "fail",
|
|
2759
|
+
detail: `origin '${actual}' \u2260 expected '${expected}'`,
|
|
2760
|
+
fix: allowFork ? "verify intentional fork; if not, `git remote set-url origin <expected>`" : "origin URL drift \u2014 possible tamper, `git remote set-url origin <expected>` to restore"
|
|
2761
|
+
};
|
|
2177
2762
|
}
|
|
2178
|
-
var
|
|
2179
|
-
|
|
2180
|
-
"src/i18n/index.ts"() {
|
|
2181
|
-
init_en();
|
|
2182
|
-
SUPPORTED = /* @__PURE__ */ new Set(["en", "zh-Hans"]);
|
|
2183
|
-
currentLocale = null;
|
|
2184
|
-
cache = {};
|
|
2185
|
-
wiredMessagesDirProvider = null;
|
|
2763
|
+
var init_origin_check = __esm({
|
|
2764
|
+
"src/cli/lib/origin-check.ts"() {
|
|
2186
2765
|
}
|
|
2187
2766
|
});
|
|
2188
2767
|
function getBackupRoot() {
|
|
@@ -2558,7 +3137,7 @@ function resolveWindowsBin(bin, env = process.env, isFile = (p8) => existsSync(p
|
|
|
2558
3137
|
const candidates = extname(bin) ? [""] : exts;
|
|
2559
3138
|
for (const dir of dirs) {
|
|
2560
3139
|
for (const ext of candidates) {
|
|
2561
|
-
const p8 =
|
|
3140
|
+
const p8 = join18(dir, `${bin}${ext}`);
|
|
2562
3141
|
if (isFile(p8)) return p8;
|
|
2563
3142
|
}
|
|
2564
3143
|
}
|
|
@@ -2573,10 +3152,10 @@ function planWindowsSpawn(bin, args, resolved) {
|
|
|
2573
3152
|
const line = [escapeCommand(resolved), ...args.map((a) => escapeArgument(a))].join(" ");
|
|
2574
3153
|
return { command: "cmd.exe", args: ["/d", "/s", "/c", `"${line}"`], verbatim: true };
|
|
2575
3154
|
}
|
|
2576
|
-
var extname,
|
|
3155
|
+
var extname, join18, META;
|
|
2577
3156
|
var init_winSpawn = __esm({
|
|
2578
3157
|
"src/installers/lib/winSpawn.ts"() {
|
|
2579
|
-
({ extname, join:
|
|
3158
|
+
({ extname, join: join18 } = win32);
|
|
2580
3159
|
META = /([()\][%!^"`<>&|;, *?])/g;
|
|
2581
3160
|
}
|
|
2582
3161
|
});
|
|
@@ -3214,147 +3793,62 @@ async function checkArtifacts(sub, packageRoot) {
|
|
|
3214
3793
|
if (declared.length === 0) return { status: "none_declared", found: [], missing: [] };
|
|
3215
3794
|
const cwd = process.cwd();
|
|
3216
3795
|
const found = [];
|
|
3217
|
-
const missing = [];
|
|
3218
|
-
for (const rel of declared) {
|
|
3219
|
-
const abs = await resolveDeclaredArtifact(cwd, rel);
|
|
3220
|
-
if (abs) found.push({ path: abs, sha256: await hashFile(abs) });
|
|
3221
|
-
else missing.push(rel);
|
|
3222
|
-
}
|
|
3223
|
-
return { status: missing.length === 0 ? "verified" : "missing", found, missing };
|
|
3224
|
-
}
|
|
3225
|
-
async function resolveDeclaredArtifact(cwd, rel) {
|
|
3226
|
-
const isFileAt = (p8) => stat(p8).then((s) => s.isFile()).catch(() => false);
|
|
3227
|
-
if (/[\\/]/.test(rel)) {
|
|
3228
|
-
const abs = resolve(cwd, rel);
|
|
3229
|
-
return await isFileAt(abs) ? abs : null;
|
|
3230
|
-
}
|
|
3231
|
-
const atRoot = resolve(cwd, rel);
|
|
3232
|
-
if (await isFileAt(atRoot)) return atRoot;
|
|
3233
|
-
for (const base of [resolve(cwd, ".planning", "phases"), resolve(cwd, ".planning")]) {
|
|
3234
|
-
let entries;
|
|
3235
|
-
try {
|
|
3236
|
-
entries = await readdir(base);
|
|
3237
|
-
} catch {
|
|
3238
|
-
continue;
|
|
3239
|
-
}
|
|
3240
|
-
let best = null;
|
|
3241
|
-
for (const entry of entries) {
|
|
3242
|
-
if (base.endsWith(".planning") && entry === "phases") continue;
|
|
3243
|
-
const cand = resolve(base, entry, rel);
|
|
3244
|
-
const st = await stat(cand).catch(() => null);
|
|
3245
|
-
if (st?.isFile() && (!best || st.mtimeMs > best.mtime)) {
|
|
3246
|
-
best = { abs: cand, mtime: st.mtimeMs };
|
|
3247
|
-
}
|
|
3248
|
-
}
|
|
3249
|
-
if (best) return best.abs;
|
|
3250
|
-
}
|
|
3251
|
-
return null;
|
|
3252
|
-
}
|
|
3253
|
-
async function checkPlanningSync(cwd, _workflowState) {
|
|
3254
|
-
const planningDir = resolve(cwd, ".planning");
|
|
3255
|
-
const hasPlanningDir = await stat(planningDir).then((s) => s.isDirectory()).catch(() => false);
|
|
3256
|
-
if (!hasPlanningDir) return { status: "none_declared", missing: [] };
|
|
3257
|
-
const stateFile = resolve(cwd, ".planning", "STATE.md");
|
|
3258
|
-
const hasStateFile = await stat(stateFile).then((s) => s.isFile()).catch(() => false);
|
|
3259
|
-
if (!hasStateFile) return { status: "missing", missing: [".planning/STATE.md"] };
|
|
3260
|
-
return { status: "verified", missing: [] };
|
|
3261
|
-
}
|
|
3262
|
-
async function detectDrift(evidence) {
|
|
3263
|
-
const drift = [];
|
|
3264
|
-
for (const ref of evidence) {
|
|
3265
|
-
const now = await hashFile(ref.path).catch(() => "");
|
|
3266
|
-
if (now !== ref.sha256) drift.push({ path: ref.path, was: ref.sha256, now });
|
|
3267
|
-
}
|
|
3268
|
-
return drift;
|
|
3269
|
-
}
|
|
3270
|
-
var init_evidence = __esm({
|
|
3271
|
-
"src/checkpoint/evidence.ts"() {
|
|
3272
|
-
init_resolveYaml();
|
|
3273
|
-
}
|
|
3274
|
-
});
|
|
3275
|
-
function getPackageRoot() {
|
|
3276
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
3277
|
-
const thisDir = dirname(thisFile);
|
|
3278
|
-
if (thisDir.endsWith("dist") || thisDir.replace(/\\/g, "/").endsWith("/dist")) {
|
|
3279
|
-
return resolve(thisDir, "..");
|
|
3280
|
-
}
|
|
3281
|
-
return resolve(thisDir, "..", "..");
|
|
3282
|
-
}
|
|
3283
|
-
var init_packagePath = __esm({
|
|
3284
|
-
"src/platform/packagePath.ts"() {
|
|
3285
|
-
}
|
|
3286
|
-
});
|
|
3287
|
-
|
|
3288
|
-
// src/platform/assetsRoot.ts
|
|
3289
|
-
var assetsRoot_exports = {};
|
|
3290
|
-
__export(assetsRoot_exports, {
|
|
3291
|
-
compiledAssetsDir: () => compiledAssetsDir,
|
|
3292
|
-
computeAssetsRoot: () => computeAssetsRoot,
|
|
3293
|
-
getAssetsRoot: () => getAssetsRoot,
|
|
3294
|
-
isCompiledModuleUrl: () => isCompiledModuleUrl,
|
|
3295
|
-
isCompiledRuntime: () => isCompiledRuntime
|
|
3296
|
-
});
|
|
3297
|
-
function isCompiledRuntime(url = import.meta.url) {
|
|
3298
|
-
return isCompiledModuleUrl(url);
|
|
3299
|
-
}
|
|
3300
|
-
function isCompiledModuleUrl(url) {
|
|
3301
|
-
let s = url;
|
|
3302
|
-
try {
|
|
3303
|
-
s = decodeURIComponent(url);
|
|
3304
|
-
} catch {
|
|
3305
|
-
}
|
|
3306
|
-
const normalized2 = s.replace(/\\/g, "/").toLowerCase();
|
|
3307
|
-
return BUNFS_MARKERS.some((m) => normalized2.includes(m));
|
|
3308
|
-
}
|
|
3309
|
-
function computeAssetsRoot(d) {
|
|
3310
|
-
const override = d.env.HARNESSED_ASSETS_OVERRIDE;
|
|
3311
|
-
if (override && override.trim().length > 0) {
|
|
3312
|
-
return { root: override.trim(), source: "override", compiledAssetsMissing: false };
|
|
3313
|
-
}
|
|
3314
|
-
if (isCompiledModuleUrl(d.moduleUrl)) {
|
|
3315
|
-
const root = join(d.stateRoot(), "assets", d.version);
|
|
3316
|
-
const present = d.exists(join(root, "workflows"));
|
|
3317
|
-
return { root, source: "compiled", compiledAssetsMissing: !present };
|
|
3796
|
+
const missing = [];
|
|
3797
|
+
for (const rel of declared) {
|
|
3798
|
+
const abs = await resolveDeclaredArtifact(cwd, rel);
|
|
3799
|
+
if (abs) found.push({ path: abs, sha256: await hashFile(abs) });
|
|
3800
|
+
else missing.push(rel);
|
|
3318
3801
|
}
|
|
3319
|
-
return {
|
|
3320
|
-
}
|
|
3321
|
-
function compiledAssetsDir(version) {
|
|
3322
|
-
return join(detectPlatform().stateRoot, "assets", version);
|
|
3802
|
+
return { status: missing.length === 0 ? "verified" : "missing", found, missing };
|
|
3323
3803
|
}
|
|
3324
|
-
function
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3804
|
+
async function resolveDeclaredArtifact(cwd, rel) {
|
|
3805
|
+
const isFileAt = (p8) => stat(p8).then((s) => s.isFile()).catch(() => false);
|
|
3806
|
+
if (/[\\/]/.test(rel)) {
|
|
3807
|
+
const abs = resolve(cwd, rel);
|
|
3808
|
+
return await isFileAt(abs) ? abs : null;
|
|
3809
|
+
}
|
|
3810
|
+
const atRoot = resolve(cwd, rel);
|
|
3811
|
+
if (await isFileAt(atRoot)) return atRoot;
|
|
3812
|
+
for (const base of [resolve(cwd, ".planning", "phases"), resolve(cwd, ".planning")]) {
|
|
3813
|
+
let entries;
|
|
3814
|
+
try {
|
|
3815
|
+
entries = await readdir(base);
|
|
3816
|
+
} catch {
|
|
3817
|
+
continue;
|
|
3818
|
+
}
|
|
3819
|
+
let best = null;
|
|
3820
|
+
for (const entry of entries) {
|
|
3821
|
+
if (base.endsWith(".planning") && entry === "phases") continue;
|
|
3822
|
+
const cand = resolve(base, entry, rel);
|
|
3823
|
+
const st = await stat(cand).catch(() => null);
|
|
3824
|
+
if (st?.isFile() && (!best || st.mtimeMs > best.mtime)) {
|
|
3825
|
+
best = { abs: cand, mtime: st.mtimeMs };
|
|
3333
3826
|
}
|
|
3334
|
-
}
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
};
|
|
3827
|
+
}
|
|
3828
|
+
if (best) return best.abs;
|
|
3829
|
+
}
|
|
3830
|
+
return null;
|
|
3339
3831
|
}
|
|
3340
|
-
function
|
|
3341
|
-
const
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3832
|
+
async function checkPlanningSync(cwd, _workflowState) {
|
|
3833
|
+
const planningDir = resolve(cwd, ".planning");
|
|
3834
|
+
const hasPlanningDir = await stat(planningDir).then((s) => s.isDirectory()).catch(() => false);
|
|
3835
|
+
if (!hasPlanningDir) return { status: "none_declared", missing: [] };
|
|
3836
|
+
const stateFile = resolve(cwd, ".planning", "STATE.md");
|
|
3837
|
+
const hasStateFile = await stat(stateFile).then((s) => s.isFile()).catch(() => false);
|
|
3838
|
+
if (!hasStateFile) return { status: "missing", missing: [".planning/STATE.md"] };
|
|
3839
|
+
return { status: "verified", missing: [] };
|
|
3840
|
+
}
|
|
3841
|
+
async function detectDrift(evidence) {
|
|
3842
|
+
const drift = [];
|
|
3843
|
+
for (const ref of evidence) {
|
|
3844
|
+
const now = await hashFile(ref.path).catch(() => "");
|
|
3845
|
+
if (now !== ref.sha256) drift.push({ path: ref.path, was: ref.sha256, now });
|
|
3347
3846
|
}
|
|
3348
|
-
return
|
|
3847
|
+
return drift;
|
|
3349
3848
|
}
|
|
3350
|
-
var
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
init_package();
|
|
3354
|
-
init_packagePath();
|
|
3355
|
-
init_platform();
|
|
3356
|
-
BUNFS_MARKERS = ["/$bunfs/", "/~bun/"];
|
|
3357
|
-
warnedMissing = false;
|
|
3849
|
+
var init_evidence = __esm({
|
|
3850
|
+
"src/checkpoint/evidence.ts"() {
|
|
3851
|
+
init_resolveYaml();
|
|
3358
3852
|
}
|
|
3359
3853
|
});
|
|
3360
3854
|
|
|
@@ -4152,6 +4646,287 @@ var init_breakLoop = __esm({
|
|
|
4152
4646
|
}
|
|
4153
4647
|
});
|
|
4154
4648
|
|
|
4649
|
+
// src/checkpoint/pruneSlots.ts
|
|
4650
|
+
function classifyKey(key) {
|
|
4651
|
+
const i = key.indexOf("::");
|
|
4652
|
+
if (i === -1) return "bare";
|
|
4653
|
+
const segment = key.slice(i + 2);
|
|
4654
|
+
if (segment === "" || segment.includes("::")) return "other";
|
|
4655
|
+
return ARCHIVE_SEGMENT_PREFIXES.some((p8) => segment.startsWith(p8)) ? "archive" : "session";
|
|
4656
|
+
}
|
|
4657
|
+
function slotTimeMs(slot) {
|
|
4658
|
+
const raw = slot.updated_at ?? slot.completed_at ?? slot.started_at;
|
|
4659
|
+
const ms = Date.parse(raw);
|
|
4660
|
+
return Number.isNaN(ms) ? void 0 : ms;
|
|
4661
|
+
}
|
|
4662
|
+
function isOlder(slot, nowMs, olderThanMs) {
|
|
4663
|
+
const t2 = slotTimeMs(slot);
|
|
4664
|
+
return t2 !== void 0 && nowMs - t2 >= olderThanMs;
|
|
4665
|
+
}
|
|
4666
|
+
function isStaleSessionSlot(key, slot, nowMs, olderThanMs) {
|
|
4667
|
+
return classifyKey(key) === "session" && slot.status === "complete" && isOlder(slot, nowMs, olderThanMs);
|
|
4668
|
+
}
|
|
4669
|
+
function planPrune(store, nowMs, olderThanMs, protectedKeys) {
|
|
4670
|
+
const out = [];
|
|
4671
|
+
for (const [key, slot] of Object.entries(store.workflows)) {
|
|
4672
|
+
if (protectedKeys.has(key)) continue;
|
|
4673
|
+
const kind = classifyKey(key);
|
|
4674
|
+
if (kind === "archive" ? isOlder(slot, nowMs, olderThanMs) : isStaleSessionSlot(key, slot, nowMs, olderThanMs)) {
|
|
4675
|
+
out.push(key);
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
return out;
|
|
4679
|
+
}
|
|
4680
|
+
function dropKeys(map, gone) {
|
|
4681
|
+
if (!map) return { next: map, dropped: 0 };
|
|
4682
|
+
const kept = Object.entries(map).filter(([k]) => !gone.has(k));
|
|
4683
|
+
const dropped = Object.keys(map).length - kept.length;
|
|
4684
|
+
return dropped === 0 ? { next: map, dropped: 0 } : { next: Object.fromEntries(kept), dropped };
|
|
4685
|
+
}
|
|
4686
|
+
function applyPrune(store, keys) {
|
|
4687
|
+
const gone = new Set(keys);
|
|
4688
|
+
const workflows = Object.fromEntries(
|
|
4689
|
+
Object.entries(store.workflows).filter(([k]) => !gone.has(k))
|
|
4690
|
+
);
|
|
4691
|
+
const next = { ...store, workflows };
|
|
4692
|
+
const r = dropKeys(store.retro_meta, gone);
|
|
4693
|
+
const i = dropKeys(store.intents, gone);
|
|
4694
|
+
if (r.next) next.retro_meta = r.next;
|
|
4695
|
+
if (i.next) next.intents = i.next;
|
|
4696
|
+
return { store: next, cascaded: r.dropped + i.dropped };
|
|
4697
|
+
}
|
|
4698
|
+
async function pruneSlots(options = {}) {
|
|
4699
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
4700
|
+
const olderThanMs = options.olderThanMs ?? DEFAULT_STALE_MS;
|
|
4701
|
+
const dryRun = options.dryRun === true;
|
|
4702
|
+
const protectedKeys = /* @__PURE__ */ new Set([activeKey(options.cwd)]);
|
|
4703
|
+
const snapshot = await readStoreRaw();
|
|
4704
|
+
const plan = planPrune(snapshot, nowMs, olderThanMs, protectedKeys);
|
|
4705
|
+
if (plan.length === 0) {
|
|
4706
|
+
return { pruned: [], keptCount: Object.keys(snapshot.workflows).length, cascaded: 0, dryRun };
|
|
4707
|
+
}
|
|
4708
|
+
if (dryRun) {
|
|
4709
|
+
const { cascaded } = applyPrune(snapshot, plan);
|
|
4710
|
+
return {
|
|
4711
|
+
pruned: plan,
|
|
4712
|
+
keptCount: Object.keys(snapshot.workflows).length - plan.length,
|
|
4713
|
+
cascaded,
|
|
4714
|
+
dryRun
|
|
4715
|
+
};
|
|
4716
|
+
}
|
|
4717
|
+
await options.onPlanned?.(plan);
|
|
4718
|
+
let result = { pruned: [], keptCount: 0, cascaded: 0, dryRun };
|
|
4719
|
+
await mutateStore((store) => {
|
|
4720
|
+
const locked = planPrune(store, nowMs, olderThanMs, protectedKeys);
|
|
4721
|
+
const applied = applyPrune(store, locked);
|
|
4722
|
+
result = {
|
|
4723
|
+
pruned: locked,
|
|
4724
|
+
keptCount: Object.keys(applied.store.workflows).length,
|
|
4725
|
+
cascaded: applied.cascaded,
|
|
4726
|
+
dryRun
|
|
4727
|
+
};
|
|
4728
|
+
return applied.store;
|
|
4729
|
+
});
|
|
4730
|
+
return result;
|
|
4731
|
+
}
|
|
4732
|
+
var DEFAULT_STALE_MS, ARCHIVE_SEGMENT_PREFIXES;
|
|
4733
|
+
var init_pruneSlots = __esm({
|
|
4734
|
+
"src/checkpoint/pruneSlots.ts"() {
|
|
4735
|
+
init_state();
|
|
4736
|
+
init_workflowStore();
|
|
4737
|
+
DEFAULT_STALE_MS = 30 * 864e5;
|
|
4738
|
+
ARCHIVE_SEGMENT_PREFIXES = ["displaced-", "premigrate-"];
|
|
4739
|
+
}
|
|
4740
|
+
});
|
|
4741
|
+
|
|
4742
|
+
// src/checkpoint/adoptSlot.ts
|
|
4743
|
+
var adoptSlot_exports = {};
|
|
4744
|
+
__export(adoptSlot_exports, {
|
|
4745
|
+
adoptSlot: () => adoptSlot
|
|
4746
|
+
});
|
|
4747
|
+
async function destIsSetUp(commandsDir) {
|
|
4748
|
+
let names;
|
|
4749
|
+
try {
|
|
4750
|
+
names = (await readdir(commandsDir)).filter((n) => n.endsWith(".md"));
|
|
4751
|
+
} catch {
|
|
4752
|
+
return false;
|
|
4753
|
+
}
|
|
4754
|
+
for (const n of names) {
|
|
4755
|
+
try {
|
|
4756
|
+
if ((await readFile(join(commandsDir, n), "utf8")).includes(GENERATED_COMMAND_MARKER)) {
|
|
4757
|
+
return true;
|
|
4758
|
+
}
|
|
4759
|
+
} catch {
|
|
4760
|
+
}
|
|
4761
|
+
}
|
|
4762
|
+
return false;
|
|
4763
|
+
}
|
|
4764
|
+
function findCandidateKeys(workflows, key, nowMs = Date.now()) {
|
|
4765
|
+
const prefix = `${key}::`;
|
|
4766
|
+
return Object.keys(workflows).filter((k) => {
|
|
4767
|
+
if (k === key) return true;
|
|
4768
|
+
if (!k.startsWith(prefix)) return false;
|
|
4769
|
+
const segment = k.slice(prefix.length);
|
|
4770
|
+
if (segment === "" || segment.includes("::")) return false;
|
|
4771
|
+
if (ARCHIVE_SEGMENT_PREFIXES2.some((p8) => segment.startsWith(p8))) return false;
|
|
4772
|
+
return !isStaleSessionSlot(k, workflows[k], nowMs, DEFAULT_STALE_MS);
|
|
4773
|
+
});
|
|
4774
|
+
}
|
|
4775
|
+
function mergeRetroMeta(src, dest) {
|
|
4776
|
+
const last = [src.last_retro_at, dest?.last_retro_at].filter((v) => v !== void 0);
|
|
4777
|
+
const newest = last.length > 0 ? last.reduce((a, b) => a > b ? a : b) : void 0;
|
|
4778
|
+
return {
|
|
4779
|
+
phases_since_retro: Math.max(src.phases_since_retro, dest?.phases_since_retro ?? 0),
|
|
4780
|
+
...newest !== void 0 ? { last_retro_at: newest } : {}
|
|
4781
|
+
};
|
|
4782
|
+
}
|
|
4783
|
+
function ledgerShape(slot) {
|
|
4784
|
+
const entries = slot.sub_progress ?? [];
|
|
4785
|
+
return { done: entries.filter((e) => e.status === "done").length, total: entries.length };
|
|
4786
|
+
}
|
|
4787
|
+
function selfDescribesEmptyLedger(raw) {
|
|
4788
|
+
try {
|
|
4789
|
+
const parsed = JSON.parse(raw);
|
|
4790
|
+
if (typeof parsed !== "object" || parsed === null) return false;
|
|
4791
|
+
const wf = parsed.workflows;
|
|
4792
|
+
return typeof wf === "object" && wf !== null && Object.keys(wf).length === 0;
|
|
4793
|
+
} catch {
|
|
4794
|
+
return false;
|
|
4795
|
+
}
|
|
4796
|
+
}
|
|
4797
|
+
function isVacuous(store) {
|
|
4798
|
+
return Object.keys(store.workflows).length === 0 && store.retro_meta === void 0 && store.intents === void 0;
|
|
4799
|
+
}
|
|
4800
|
+
async function adoptSlot(options = {}) {
|
|
4801
|
+
const home = options.home ?? homedir();
|
|
4802
|
+
const cwd = options.cwd ?? process.cwd();
|
|
4803
|
+
const me = resolveHostWithReason(home);
|
|
4804
|
+
const destHost = me.descriptor.id;
|
|
4805
|
+
let from;
|
|
4806
|
+
if (options.from !== void 0) {
|
|
4807
|
+
if (!isHostId(options.from)) {
|
|
4808
|
+
return refuse({ kind: "unknown-from", value: options.from, known: HOST_IDS });
|
|
4809
|
+
}
|
|
4810
|
+
from = options.from;
|
|
4811
|
+
} else {
|
|
4812
|
+
const others = HOST_IDS.filter((id) => id !== destHost);
|
|
4813
|
+
const inferred = others.length === 1 ? others[0] : void 0;
|
|
4814
|
+
if (inferred === void 0) {
|
|
4815
|
+
return refuse({ kind: "from-required", host: destHost, known: HOST_IDS });
|
|
4816
|
+
}
|
|
4817
|
+
from = inferred;
|
|
4818
|
+
}
|
|
4819
|
+
if (from === destHost) {
|
|
4820
|
+
const other = HOST_IDS.find((id) => id !== destHost) ?? destHost;
|
|
4821
|
+
return refuse({ kind: "same-host", host: from, other, reason: me.reason, skipped: me.skipped });
|
|
4822
|
+
}
|
|
4823
|
+
if (!await destIsSetUp(me.descriptor.commandsDir)) {
|
|
4824
|
+
return refuse({
|
|
4825
|
+
kind: "dest-not-set-up",
|
|
4826
|
+
host: destHost,
|
|
4827
|
+
commandsDir: me.descriptor.commandsDir
|
|
4828
|
+
});
|
|
4829
|
+
}
|
|
4830
|
+
const sourceRoot = descriptorFor(from, home).stateRoot;
|
|
4831
|
+
const sourcePath = join(sourceRoot, "workflows.json");
|
|
4832
|
+
if (!existsSync(sourcePath)) {
|
|
4833
|
+
return refuse({ kind: "no-source-ledger", from, path: sourcePath });
|
|
4834
|
+
}
|
|
4835
|
+
const source = await readStoreAt(sourceRoot);
|
|
4836
|
+
if (isVacuous(source)) {
|
|
4837
|
+
let raw;
|
|
4838
|
+
try {
|
|
4839
|
+
raw = await readFile(sourcePath, "utf8");
|
|
4840
|
+
} catch {
|
|
4841
|
+
raw = void 0;
|
|
4842
|
+
}
|
|
4843
|
+
if (raw === void 0 || !selfDescribesEmptyLedger(raw)) {
|
|
4844
|
+
return refuse({ kind: "source-ledger-unreadable", from, path: sourcePath });
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
const key = repoKey(cwd);
|
|
4848
|
+
const sourceKeys = Object.keys(source.workflows);
|
|
4849
|
+
const candidates = findCandidateKeys(source.workflows, key);
|
|
4850
|
+
if (candidates.length === 0) {
|
|
4851
|
+
return refuse({ kind: "no-candidate", from, repoKey: key, sourceKeys });
|
|
4852
|
+
}
|
|
4853
|
+
if (candidates.length > 1) {
|
|
4854
|
+
return refuse({ kind: "ambiguous", from, candidates });
|
|
4855
|
+
}
|
|
4856
|
+
const sourceKey = candidates[0];
|
|
4857
|
+
const slot = source.workflows[sourceKey];
|
|
4858
|
+
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4859
|
+
let archivedKey;
|
|
4860
|
+
let retroMeta;
|
|
4861
|
+
try {
|
|
4862
|
+
await mutateStore((store) => {
|
|
4863
|
+
const occupant = store.workflows[key];
|
|
4864
|
+
if (occupant?.status === "active") {
|
|
4865
|
+
throw new AdoptRefused({
|
|
4866
|
+
kind: "dest-occupied",
|
|
4867
|
+
from,
|
|
4868
|
+
mine: { phase: occupant.phase, status: occupant.status, ...ledgerShape(occupant) },
|
|
4869
|
+
theirs: { phase: slot.phase }
|
|
4870
|
+
});
|
|
4871
|
+
}
|
|
4872
|
+
const workflows = { ...store.workflows };
|
|
4873
|
+
if (occupant?.status === "paused") {
|
|
4874
|
+
archivedKey = `${key}${DISPLACED}${updatedAt}`;
|
|
4875
|
+
workflows[archivedKey] = occupant;
|
|
4876
|
+
}
|
|
4877
|
+
workflows[key] = { ...slot, updated_at: updatedAt };
|
|
4878
|
+
const next = { ...store, workflows };
|
|
4879
|
+
const srcRetro = source.retro_meta?.[key];
|
|
4880
|
+
if (srcRetro) {
|
|
4881
|
+
retroMeta = mergeRetroMeta(srcRetro, store.retro_meta?.[key]);
|
|
4882
|
+
next.retro_meta = { ...store.retro_meta ?? {}, [key]: retroMeta };
|
|
4883
|
+
}
|
|
4884
|
+
return next;
|
|
4885
|
+
});
|
|
4886
|
+
} catch (e) {
|
|
4887
|
+
if (e instanceof AdoptRefused) return refuse(e.refusal);
|
|
4888
|
+
throw e;
|
|
4889
|
+
}
|
|
4890
|
+
return {
|
|
4891
|
+
ok: true,
|
|
4892
|
+
from,
|
|
4893
|
+
to: destHost,
|
|
4894
|
+
key,
|
|
4895
|
+
sourceKey,
|
|
4896
|
+
sourceRoot,
|
|
4897
|
+
destRoot: getHarnessedRoot(),
|
|
4898
|
+
phase: slot.phase,
|
|
4899
|
+
status: slot.status,
|
|
4900
|
+
// D12 — verbatim. The evidence file itself is NOT copied.
|
|
4901
|
+
evidencePath: slot.last_checkpoint_path,
|
|
4902
|
+
updatedAt,
|
|
4903
|
+
...archivedKey !== void 0 ? { archivedKey } : {},
|
|
4904
|
+
...retroMeta !== void 0 ? { retroMeta } : {}
|
|
4905
|
+
};
|
|
4906
|
+
}
|
|
4907
|
+
var DISPLACED, ARCHIVE_SEGMENT_PREFIXES2, GENERATED_COMMAND_MARKER, AdoptRefused, refuse;
|
|
4908
|
+
var init_adoptSlot = __esm({
|
|
4909
|
+
"src/checkpoint/adoptSlot.ts"() {
|
|
4910
|
+
init_harnessedRoot();
|
|
4911
|
+
init_platform();
|
|
4912
|
+
init_pruneSlots();
|
|
4913
|
+
init_state();
|
|
4914
|
+
init_workflowStore();
|
|
4915
|
+
DISPLACED = "::displaced-";
|
|
4916
|
+
ARCHIVE_SEGMENT_PREFIXES2 = ["displaced-", "premigrate-"];
|
|
4917
|
+
GENERATED_COMMAND_MARKER = "harnessed-generated:";
|
|
4918
|
+
AdoptRefused = class extends Error {
|
|
4919
|
+
constructor(refusal) {
|
|
4920
|
+
super(`adopt refused: ${refusal.kind}`);
|
|
4921
|
+
this.refusal = refusal;
|
|
4922
|
+
this.name = "AdoptRefused";
|
|
4923
|
+
}
|
|
4924
|
+
refusal;
|
|
4925
|
+
};
|
|
4926
|
+
refuse = (refusal) => ({ ok: false, refusal });
|
|
4927
|
+
}
|
|
4928
|
+
});
|
|
4929
|
+
|
|
4155
4930
|
// src/checkpoint/intentKind.ts
|
|
4156
4931
|
var intentKind_exports = {};
|
|
4157
4932
|
__export(intentKind_exports, {
|
|
@@ -4175,6 +4950,7 @@ var init_intentKind = __esm({
|
|
|
4175
4950
|
var checkpoint_exports = {};
|
|
4176
4951
|
__export(checkpoint_exports, {
|
|
4177
4952
|
registerCheckpoint: () => registerCheckpoint,
|
|
4953
|
+
runCheckpointAdopt: () => runCheckpointAdopt,
|
|
4178
4954
|
runCheckpointComplete: () => runCheckpointComplete,
|
|
4179
4955
|
runCheckpointFail: () => runCheckpointFail,
|
|
4180
4956
|
runCheckpointReopen: () => runCheckpointReopen,
|
|
@@ -4580,9 +5356,133 @@ async function runCheckpointReopen(sub, opts, deps = defaultRunDeps) {
|
|
|
4580
5356
|
);
|
|
4581
5357
|
deps.exit(0);
|
|
4582
5358
|
}
|
|
5359
|
+
function tildify(p8) {
|
|
5360
|
+
const home = homedir();
|
|
5361
|
+
if (home === "" || !p8.startsWith(home)) return p8;
|
|
5362
|
+
return `~${p8.slice(home.length).replace(/\\/g, "/")}`;
|
|
5363
|
+
}
|
|
5364
|
+
function renderHostReason(reason) {
|
|
5365
|
+
switch (reason.kind) {
|
|
5366
|
+
case "env-platform":
|
|
5367
|
+
return `${reason.envVar}=${reason.value} (\u73AF\u5883\u53D8\u91CF\u663E\u5F0F\u6307\u5B9A)`;
|
|
5368
|
+
case "host-session-env":
|
|
5369
|
+
return `\u5BBF\u4E3B session \u73AF\u5883\u53D8\u91CF ${reason.envVar} \u5DF2\u8BBE\u7F6E`;
|
|
5370
|
+
case "platform-pin":
|
|
5371
|
+
return `.platform pin: ${tildify(reason.pinPath)} \u5199\u7740 ${reason.value}`;
|
|
5372
|
+
case "directory-probe":
|
|
5373
|
+
return `directory probe (${tildify(reason.probedDir)} \u5B58\u5728,incumbent)`;
|
|
5374
|
+
case "fallback":
|
|
5375
|
+
return "\u65E0\u4EFB\u4F55\u5BBF\u4E3B\u4FE1\u53F7 \u2192 \u9ED8\u8BA4 claude";
|
|
5376
|
+
}
|
|
5377
|
+
}
|
|
5378
|
+
function renderHostSkip(skip) {
|
|
5379
|
+
switch (skip.kind) {
|
|
5380
|
+
case "env-platform-unknown":
|
|
5381
|
+
return `\u5FFD\u7565: ${skip.envVar}=${skip.value} \u4E0D\u662F\u5DF2\u77E5\u5BBF\u4E3B id`;
|
|
5382
|
+
case "host-session-env-ambiguous":
|
|
5383
|
+
return "\u5FFD\u7565: CLAUDE_CODE_SESSION_ID \u4E0E CODEX_SESSION_ID \u540C\u65F6\u5B58\u5728,\u65E0\u6CD5\u636E\u6B64\u5224\u5B9A\u5BBF\u4E3B";
|
|
5384
|
+
case "platform-pin-unknown":
|
|
5385
|
+
return `\u5FFD\u7565: .platform pin ${tildify(skip.pinPath)} \u5199\u7740 ${skip.value},\u4E0D\u662F\u5DF2\u77E5\u5BBF\u4E3B id`;
|
|
5386
|
+
}
|
|
5387
|
+
}
|
|
5388
|
+
function renderAdoptRefusal(r) {
|
|
5389
|
+
switch (r.kind) {
|
|
5390
|
+
case "unknown-from":
|
|
5391
|
+
return [`refused: --from \u672A\u77E5\u5BBF\u4E3B id '${r.value}'(\u5DF2\u77E5: ${r.known.join(" | ")})`];
|
|
5392
|
+
case "from-required":
|
|
5393
|
+
return [
|
|
5394
|
+
`refused: \u672C\u5BBF\u4E3B\u662F ${r.host},\u6E90\u5BBF\u4E3B\u6709\u591A\u4E2A\u5019\u9009,\u4E0D\u731C(\u5DF2\u77E5: ${r.known.join(" | ")})`,
|
|
5395
|
+
" \u663E\u5F0F\u6307\u5B9A --from <id>\u3002"
|
|
5396
|
+
];
|
|
5397
|
+
case "same-host": {
|
|
5398
|
+
const lines = [
|
|
5399
|
+
`refused: \u672C\u8FDB\u7A0B\u88AB\u89E3\u6790\u4E3A\u5BBF\u4E3B ${r.host}`,
|
|
5400
|
+
` \u4F9D\u636E: ${renderHostReason(r.reason)}`
|
|
5401
|
+
];
|
|
5402
|
+
for (const s of r.skipped) lines.push(` ${renderHostSkip(s)}`);
|
|
5403
|
+
lines.push(" --from \u4E0E\u5F53\u524D\u5BBF\u4E3B\u76F8\u540C,\u65E0\u4E8B\u53EF\u505A\u3002");
|
|
5404
|
+
lines.push(`\u4FEE\u6CD5: HARNESSED_PLATFORM=${r.other} harnessed checkpoint adopt --from ${r.host}`);
|
|
5405
|
+
return lines;
|
|
5406
|
+
}
|
|
5407
|
+
case "dest-not-set-up":
|
|
5408
|
+
return [
|
|
5409
|
+
`refused: \u76EE\u6807\u5BBF\u4E3B ${r.host} \u8FD8\u6CA1 setup \u8FC7`,
|
|
5410
|
+
` \u8BC1\u636E: \u547D\u4EE4\u76EE\u5F55\u91CC\u6CA1\u6709 harnessed \u751F\u6210\u7684\u547D\u4EE4: ${tildify(r.commandsDir)}`,
|
|
5411
|
+
" \u8D26\u672C\u4E0D\u662F\u76EE\u6807\u5BBF\u4E3B\u9700\u8981\u7684\u5168\u90E8 \u2014\u2014 \u6CA1\u6709\u547D\u4EE4,adopt \u6210\u529F\u4E86\u4E5F\u6CA1\u4E1C\u897F\u53EF\u8DD1\u3002\u5148\u8DD1:",
|
|
5412
|
+
` harnessed setup --platform ${r.host}`
|
|
5413
|
+
];
|
|
5414
|
+
case "no-source-ledger":
|
|
5415
|
+
return [`refused: \u6E90\u5BBF\u4E3B ${r.from} \u8FD8\u6CA1\u6709\u8D26\u672C`, ` \u67E5\u8FC7: ${tildify(r.path)}`];
|
|
5416
|
+
case "source-ledger-unreadable":
|
|
5417
|
+
return [
|
|
5418
|
+
`refused: \u6E90\u8D26\u672C\u5728\u4F46\u8BFB\u4E0D\u52A8(JSON \u635F\u574F\u6216 schema \u4E0D\u5BF9): ${r.path}`,
|
|
5419
|
+
" \u4E0D\u81EA\u52A8\u4FEE\u3002\u5907\u4EFD\u540E\u68C0\u67E5,\u6216\u5728\u6E90\u5BBF\u4E3B\u91CD\u5EFA\u3002"
|
|
5420
|
+
];
|
|
5421
|
+
case "no-candidate": {
|
|
5422
|
+
const lines = [
|
|
5423
|
+
`refused: \u6E90\u5BBF\u4E3B ${r.from} \u7684\u8D26\u672C\u91CC\u6CA1\u6709\u8FD9\u4E2A\u4ED3\u7684\u69FD\u4F4D`,
|
|
5424
|
+
` \u4ED3\u952E: ${r.repoKey}`,
|
|
5425
|
+
" \u6E90\u8D26\u672C\u73B0\u6709\u952E:"
|
|
5426
|
+
];
|
|
5427
|
+
if (r.sourceKeys.length === 0) lines.push(" (\u7A7A)");
|
|
5428
|
+
else for (const k of r.sourceKeys) lines.push(` - ${k}`);
|
|
5429
|
+
return lines;
|
|
5430
|
+
}
|
|
5431
|
+
case "ambiguous": {
|
|
5432
|
+
const lines = [`refused: \u6E90\u5BBF\u4E3B ${r.from} \u6709 ${r.candidates.length} \u4E2A\u5019\u9009\u69FD\u4F4D,\u4E0D\u731C`];
|
|
5433
|
+
for (const k of r.candidates) lines.push(` - ${k}`);
|
|
5434
|
+
lines.push(" \u5B83\u4EEC\u662F\u540C\u4E00\u5BBF\u4E3B\u5185\u7684\u591A\u4F1A\u8BDD\u69FD\u4F4D,--from \u65E0\u4ECE\u6D88\u6B67\u3002");
|
|
5435
|
+
lines.push(" \u5728\u6E90\u5BBF\u4E3B\u4FA7\u628A\u591A\u4F59\u7684 complete / pause \u6389\u3001\u53EA\u7559\u4E00\u4E2A,\u518D adopt\u3002");
|
|
5436
|
+
return lines;
|
|
5437
|
+
}
|
|
5438
|
+
case "dest-occupied": {
|
|
5439
|
+
const subs = r.mine.total > 0 ? `, ${r.mine.done}/${r.mine.total} subs done` : "";
|
|
5440
|
+
return [
|
|
5441
|
+
"refused: \u672C\u5BBF\u4E3B\u5F53\u524D\u69FD\u4F4D\u975E\u7A7A",
|
|
5442
|
+
` \u6211\u7684: ${r.mine.phase} (status:${r.mine.status}${subs})`,
|
|
5443
|
+
` \u8981\u63A5: ${r.theirs.phase} (\u6765\u81EA ${r.from})`,
|
|
5444
|
+
" adopt \u4E0D\u8986\u76D6\u5728\u9014\u8D26\u672C\u3002\u5148\u8DD1:",
|
|
5445
|
+
" harnessed checkpoint complete # \u6216 pause"
|
|
5446
|
+
];
|
|
5447
|
+
}
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
function renderAdoptSuccess(r) {
|
|
5451
|
+
const lines = [
|
|
5452
|
+
`adopted: ${r.phase} \u2190 \u5BBF\u4E3B ${r.from}`,
|
|
5453
|
+
` \u5199\u5165: ${tildify(r.destRoot)}/workflows.json \u7684\u88F8\u4ED3\u952E ${r.key}`,
|
|
5454
|
+
` \u6E90\u69FD\u4F4D\u952E: ${r.sourceKey} (status:${r.status})`
|
|
5455
|
+
];
|
|
5456
|
+
if (r.archivedKey !== void 0) {
|
|
5457
|
+
lines.push(` \u88AB\u9876\u6389\u7684 paused \u69FD\u4F4D\u5DF2\u5F52\u6863(\u4EC5\u5F52\u6863,\u4EFB\u4F55\u8BFB\u8DEF\u5F84\u90FD\u4E0D\u8BA4\u5B83): ${r.archivedKey}`);
|
|
5458
|
+
}
|
|
5459
|
+
if (r.retroMeta !== void 0) {
|
|
5460
|
+
lines.push(` retro \u8282\u594F\u5DF2\u5E26\u8D70: phases_since_retro=${r.retroMeta.phases_since_retro}`);
|
|
5461
|
+
}
|
|
5462
|
+
lines.push(
|
|
5463
|
+
` \u8BC1\u636E\u6307\u9488\u672A\u52A8: ${r.evidencePath ?? "(\u65E0)"}`,
|
|
5464
|
+
" \u5B83\u4ECD\u6307\u5411\u6E90\u6839;\u4E0B\u4E00\u6761 `harnessed checkpoint complete` \u4F1A\u5728\u672C\u5BBF\u4E3B\u6839\u5199\u540C\u540D\u6587\u4EF6,\u6307\u9488\u81EA\u7136\u8F6C\u6B63\u3002",
|
|
5465
|
+
" \u63A5\u529B\u5BFF\u547D = \u672C\u4F1A\u8BDD: \u9996\u6B21 `harnessed checkpoint complete` \u628A\u69FD\u4F4D\u53C9\u5230\u672C\u4F1A\u8BDD\u7684\u590D\u5408\u952E,\u88F8\u69FD\u4F4D\u4ECE\u6B64\u51BB\u7ED3(\u4E0E\u540C\u5BBF\u4E3B\u591A\u4F1A\u8BDD\u884C\u4E3A\u4E00\u81F4)\u3002",
|
|
5466
|
+
` \u6E90\u69FD\u4F4D\u4ECD\u5728\u3001\u672A\u88AB\u6539: ${r.from} \u7684 ${r.sourceKey} \u8FD8\u662F status:${r.status}`,
|
|
5467
|
+
` \u5728\u6E90\u5BBF\u4E3B\u4FA7\u9000\u4F11\u5B83: HARNESSED_PLATFORM=${r.from} harnessed checkpoint complete ${r.phase} --force`,
|
|
5468
|
+
"\u8DE8\u6839\u8BBF\u95EE: \u53EA\u8BFB, \u5168\u7A0B\u672A\u5199\u6E90\u6839"
|
|
5469
|
+
);
|
|
5470
|
+
return lines;
|
|
5471
|
+
}
|
|
5472
|
+
async function runCheckpointAdopt(opts, deps = defaultRunDeps) {
|
|
5473
|
+
const { adoptSlot: adoptSlot2 } = await Promise.resolve().then(() => (init_adoptSlot(), adoptSlot_exports));
|
|
5474
|
+
const outcome = await adoptSlot2({ ...opts.from !== void 0 ? { from: opts.from } : {} });
|
|
5475
|
+
if (!outcome.ok) {
|
|
5476
|
+
for (const line of renderAdoptRefusal(outcome.refusal)) deps.error(line);
|
|
5477
|
+
deps.exit(1);
|
|
5478
|
+
return;
|
|
5479
|
+
}
|
|
5480
|
+
for (const line of renderAdoptSuccess(outcome)) deps.log(line);
|
|
5481
|
+
deps.exit(0);
|
|
5482
|
+
}
|
|
4583
5483
|
function registerCheckpoint(program2) {
|
|
4584
|
-
program2.command("checkpoint <action>
|
|
4585
|
-
"Record workflow progress: intent | start | complete | fail | reopen <sub-workflow
|
|
5484
|
+
program2.command("checkpoint <action> [sub]").description(
|
|
5485
|
+
"Record workflow progress: intent | start | complete | fail | reopen <sub-workflow>, or adopt (cross-host relay) (writes under the active host state root)"
|
|
4586
5486
|
).option("--summary <text>", "short summary stored as the checkpoint lastTask").option("--plan <json>", "gates plan JSON (start only) \u2014 seeds the sub-progress ledger").option(
|
|
4587
5487
|
"--force",
|
|
4588
5488
|
"complete/fail \u2014 override a fail-closed guard: the missing-artifact evidence block (complete; records overridden) or the serial-order guard"
|
|
@@ -4604,6 +5504,9 @@ function registerCheckpoint(program2) {
|
|
|
4604
5504
|
).option(
|
|
4605
5505
|
"--failure <kind>",
|
|
4606
5506
|
"fail only \u2014 which named spawn failure ended the attempt: SpawnTimeout | SpawnExitNonZero | SpawnOutputMalformed | SpawnAuthFailed | SpawnRefused (recorded on the ledger entry; an unknown value is rejected)"
|
|
5507
|
+
).option(
|
|
5508
|
+
"--from <host>",
|
|
5509
|
+
`adopt only \u2014 which host's ledger to copy this repo's slot FROM: ${HOST_IDS.join(" | ")} (omitted \u2192 the other host)`
|
|
4607
5510
|
).action(
|
|
4608
5511
|
async (action, sub, opts) => {
|
|
4609
5512
|
if (!isAction(action)) {
|
|
@@ -4613,6 +5516,17 @@ function registerCheckpoint(program2) {
|
|
|
4613
5516
|
process.exit(1);
|
|
4614
5517
|
return;
|
|
4615
5518
|
}
|
|
5519
|
+
if (action === "adopt") {
|
|
5520
|
+
await runCheckpointAdopt(opts);
|
|
5521
|
+
return;
|
|
5522
|
+
}
|
|
5523
|
+
if (sub === void 0) {
|
|
5524
|
+
console.error(
|
|
5525
|
+
`[harnessed] checkpoint ${action}: missing required argument <sub> (the sub-workflow name)`
|
|
5526
|
+
);
|
|
5527
|
+
process.exit(1);
|
|
5528
|
+
return;
|
|
5529
|
+
}
|
|
4616
5530
|
if (action === "intent") {
|
|
4617
5531
|
try {
|
|
4618
5532
|
checkPathSafe(sub);
|
|
@@ -4664,9 +5578,10 @@ var ACTIONS;
|
|
|
4664
5578
|
var init_checkpoint = __esm({
|
|
4665
5579
|
"src/cli/checkpoint.ts"() {
|
|
4666
5580
|
init_path_guard();
|
|
5581
|
+
init_platform();
|
|
4667
5582
|
init_runDeps();
|
|
4668
5583
|
init_ledger();
|
|
4669
|
-
ACTIONS = ["start", "complete", "fail", "reopen", "intent"];
|
|
5584
|
+
ACTIONS = ["start", "complete", "fail", "reopen", "intent", "adopt"];
|
|
4670
5585
|
}
|
|
4671
5586
|
});
|
|
4672
5587
|
function realProbe(p8) {
|
|
@@ -4728,7 +5643,7 @@ function compute(d) {
|
|
|
4728
5643
|
const gitFirst = d.where("git")[0];
|
|
4729
5644
|
if (gitFirst && /git\.exe$/i.test(gitFirst)) {
|
|
4730
5645
|
const root = dirname9(dirname9(gitFirst));
|
|
4731
|
-
for (const cand of [
|
|
5646
|
+
for (const cand of [join27(root, "bin", "bash.exe"), join27(root, "usr", "bin", "bash.exe")]) {
|
|
4732
5647
|
if (d.exists(cand) && usable(cand)) return { path: cand, source: "git-derived", wslOnPath };
|
|
4733
5648
|
}
|
|
4734
5649
|
}
|
|
@@ -4736,13 +5651,13 @@ function compute(d) {
|
|
|
4736
5651
|
d.env.ProgramFiles,
|
|
4737
5652
|
d.env.ProgramW6432,
|
|
4738
5653
|
d.env["ProgramFiles(x86)"],
|
|
4739
|
-
d.env.LOCALAPPDATA ?
|
|
5654
|
+
d.env.LOCALAPPDATA ? join27(d.env.LOCALAPPDATA, "Programs") : void 0
|
|
4740
5655
|
];
|
|
4741
5656
|
for (const base of bases) {
|
|
4742
5657
|
if (!base) continue;
|
|
4743
5658
|
for (const cand of [
|
|
4744
|
-
|
|
4745
|
-
|
|
5659
|
+
join27(base, "Git", "bin", "bash.exe"),
|
|
5660
|
+
join27(base, "Git", "usr", "bin", "bash.exe")
|
|
4746
5661
|
]) {
|
|
4747
5662
|
if (d.exists(cand) && usable(cand))
|
|
4748
5663
|
return { path: cand, source: "standard-location", wslOnPath };
|
|
@@ -4755,10 +5670,10 @@ function compute(d) {
|
|
|
4755
5670
|
}
|
|
4756
5671
|
return { path: "bash", source: "path-fallback" };
|
|
4757
5672
|
}
|
|
4758
|
-
var dirname9,
|
|
5673
|
+
var dirname9, join27, WSL_STUB_RE, cache4;
|
|
4759
5674
|
var init_resolveBash = __esm({
|
|
4760
5675
|
"src/installers/lib/resolveBash.ts"() {
|
|
4761
|
-
({ dirname: dirname9, join:
|
|
5676
|
+
({ dirname: dirname9, join: join27 } = win32);
|
|
4762
5677
|
WSL_STUB_RE = /[\\/](windows[\\/](system32|sysnative|syswow64)|microsoft[\\/]windowsapps)[\\/]bash\.exe$/i;
|
|
4763
5678
|
cache4 = null;
|
|
4764
5679
|
}
|
|
@@ -5392,14 +6307,14 @@ __export(check_mcp_availability_exports, {
|
|
|
5392
6307
|
checkMcpAvailability: () => checkMcpAvailability
|
|
5393
6308
|
});
|
|
5394
6309
|
async function checkMcpAvailability() {
|
|
5395
|
-
const
|
|
6310
|
+
const installed2 = [];
|
|
5396
6311
|
const missing = [];
|
|
5397
6312
|
for (const s of TARGET_SERVERS) {
|
|
5398
|
-
if (await isMcpServerRegistered(s))
|
|
6313
|
+
if (await isMcpServerRegistered(s)) installed2.push(s);
|
|
5399
6314
|
else missing.push(s);
|
|
5400
6315
|
}
|
|
5401
6316
|
const keyless = [];
|
|
5402
|
-
for (const s of
|
|
6317
|
+
for (const s of installed2) {
|
|
5403
6318
|
const probe = await probeSearchMcpKey(s);
|
|
5404
6319
|
if (!probe.present) keyless.push(probe);
|
|
5405
6320
|
}
|
|
@@ -5407,11 +6322,11 @@ async function checkMcpAvailability() {
|
|
|
5407
6322
|
return {
|
|
5408
6323
|
name: CHECK_NAME,
|
|
5409
6324
|
status: "pass",
|
|
5410
|
-
message: `installed: ${
|
|
6325
|
+
message: `installed: ${installed2.join(", ")} (API keys configured)`
|
|
5411
6326
|
};
|
|
5412
6327
|
}
|
|
5413
6328
|
const parts = [];
|
|
5414
|
-
if (
|
|
6329
|
+
if (installed2.length > 0) parts.push(`installed: ${installed2.join(", ")}`);
|
|
5415
6330
|
if (missing.length > 0) parts.push(`not registered: ${missing.join(", ")}`);
|
|
5416
6331
|
if (keyless.length > 0) {
|
|
5417
6332
|
parts.push(`API key missing: ${keyless.map((k) => `${k.server} \u2192 ${k.envVar}`).join(", ")}`);
|
|
@@ -5520,74 +6435,13 @@ function checkBun(deps) {
|
|
|
5520
6435
|
install_commands: ["brew install oven-sh/bun/bun"]
|
|
5521
6436
|
};
|
|
5522
6437
|
}
|
|
5523
|
-
return {
|
|
5524
|
-
...missing,
|
|
5525
|
-
fix: "see https://bun.sh/docs/installation (curl -fsSL https://bun.sh/install | bash \u2014 review the script first)"
|
|
5526
|
-
};
|
|
5527
|
-
}
|
|
5528
|
-
var init_check_bun = __esm({
|
|
5529
|
-
"src/cli/lib/check-bun.ts"() {
|
|
5530
|
-
}
|
|
5531
|
-
});
|
|
5532
|
-
async function scanWorkflowsNested(workflowsDir, entries) {
|
|
5533
|
-
const workflows = [];
|
|
5534
|
-
for (const entry of entries.sort()) {
|
|
5535
|
-
if (NON_WORKFLOW_DIRS.has(entry)) continue;
|
|
5536
|
-
const src = join(workflowsDir, entry);
|
|
5537
|
-
let s;
|
|
5538
|
-
try {
|
|
5539
|
-
s = await stat(src);
|
|
5540
|
-
} catch {
|
|
5541
|
-
continue;
|
|
5542
|
-
}
|
|
5543
|
-
if (!s.isDirectory()) continue;
|
|
5544
|
-
let hasFlatSkill = false;
|
|
5545
|
-
try {
|
|
5546
|
-
await stat(join(src, "SKILL.md"));
|
|
5547
|
-
hasFlatSkill = true;
|
|
5548
|
-
} catch {
|
|
5549
|
-
hasFlatSkill = false;
|
|
5550
|
-
}
|
|
5551
|
-
if (hasFlatSkill) {
|
|
5552
|
-
if (FLAT_LEGACY_KEEP.has(entry)) {
|
|
5553
|
-
workflows.push({ name: entry, relPath: entry, isMaster: FLAT_TOP_LEVEL_MASTERS.has(entry) });
|
|
5554
|
-
continue;
|
|
5555
|
-
}
|
|
5556
|
-
workflows.push({ name: entry, relPath: entry, isMaster: false });
|
|
5557
|
-
continue;
|
|
5558
|
-
}
|
|
5559
|
-
let subEntries;
|
|
5560
|
-
try {
|
|
5561
|
-
subEntries = await readdir(src);
|
|
5562
|
-
} catch {
|
|
5563
|
-
continue;
|
|
5564
|
-
}
|
|
5565
|
-
for (const sub of subEntries.sort()) {
|
|
5566
|
-
const subDir = join(src, sub);
|
|
5567
|
-
let ss;
|
|
5568
|
-
try {
|
|
5569
|
-
ss = await stat(subDir);
|
|
5570
|
-
} catch {
|
|
5571
|
-
continue;
|
|
5572
|
-
}
|
|
5573
|
-
if (!ss.isDirectory()) continue;
|
|
5574
|
-
try {
|
|
5575
|
-
await stat(join(subDir, "SKILL.md"));
|
|
5576
|
-
} catch {
|
|
5577
|
-
continue;
|
|
5578
|
-
}
|
|
5579
|
-
const name = sub === "auto" ? entry : `${entry}-${sub}`;
|
|
5580
|
-
workflows.push({ name, relPath: `${entry}/${sub}`, isMaster: sub === "auto" });
|
|
5581
|
-
}
|
|
5582
|
-
}
|
|
5583
|
-
return { workflows };
|
|
6438
|
+
return {
|
|
6439
|
+
...missing,
|
|
6440
|
+
fix: "see https://bun.sh/docs/installation (curl -fsSL https://bun.sh/install | bash \u2014 review the script first)"
|
|
6441
|
+
};
|
|
5584
6442
|
}
|
|
5585
|
-
var
|
|
5586
|
-
|
|
5587
|
-
"src/workflow/scan-nested.ts"() {
|
|
5588
|
-
FLAT_LEGACY_KEEP = /* @__PURE__ */ new Set(["research", "retro", "auto"]);
|
|
5589
|
-
FLAT_TOP_LEVEL_MASTERS = /* @__PURE__ */ new Set(["auto"]);
|
|
5590
|
-
NON_WORKFLOW_DIRS = /* @__PURE__ */ new Set(["disciplines", "judgments"]);
|
|
6443
|
+
var init_check_bun = __esm({
|
|
6444
|
+
"src/cli/lib/check-bun.ts"() {
|
|
5591
6445
|
}
|
|
5592
6446
|
});
|
|
5593
6447
|
|
|
@@ -5661,17 +6515,17 @@ async function auditInstalledSkills(workflows, skillsBase, workflowsDir, opts =
|
|
|
5661
6515
|
const srcMarker = typeof src === "string" ? HARNESSED_MARKER_RX.exec(src) : null;
|
|
5662
6516
|
if (!srcMarker) continue;
|
|
5663
6517
|
const srcVersion = srcMarker[1] ?? "0.0.0";
|
|
5664
|
-
let
|
|
6518
|
+
let installed2;
|
|
5665
6519
|
try {
|
|
5666
|
-
|
|
6520
|
+
installed2 = await readFile(join(skillsBase, wf.name, "SKILL.md"), "utf8");
|
|
5667
6521
|
} catch {
|
|
5668
|
-
|
|
6522
|
+
installed2 = null;
|
|
5669
6523
|
}
|
|
5670
|
-
if (
|
|
6524
|
+
if (installed2 === null || typeof installed2 !== "string") {
|
|
5671
6525
|
out.push({ name: wf.name, status: "missing" });
|
|
5672
6526
|
continue;
|
|
5673
6527
|
}
|
|
5674
|
-
const marker = HARNESSED_MARKER_RX.exec(
|
|
6528
|
+
const marker = HARNESSED_MARKER_RX.exec(installed2);
|
|
5675
6529
|
if (!marker) {
|
|
5676
6530
|
out.push({ name: wf.name, status: "foreign" });
|
|
5677
6531
|
continue;
|
|
@@ -5688,7 +6542,7 @@ async function auditInstalledSkills(workflows, skillsBase, workflowsDir, opts =
|
|
|
5688
6542
|
}
|
|
5689
6543
|
out.push({
|
|
5690
6544
|
name: wf.name,
|
|
5691
|
-
status: sha256Of(
|
|
6545
|
+
status: sha256Of(installed2) === record.sha256 ? "ok" : "tampered"
|
|
5692
6546
|
});
|
|
5693
6547
|
}
|
|
5694
6548
|
return out;
|
|
@@ -5806,8 +6660,8 @@ function parse3(v) {
|
|
|
5806
6660
|
if (!m) return null;
|
|
5807
6661
|
return { nums: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ?? null };
|
|
5808
6662
|
}
|
|
5809
|
-
function compareVersions(
|
|
5810
|
-
const a = parse3(
|
|
6663
|
+
function compareVersions(installed2, latest) {
|
|
6664
|
+
const a = parse3(installed2);
|
|
5811
6665
|
const b = parse3(latest);
|
|
5812
6666
|
if (!a || !b) return "unknown";
|
|
5813
6667
|
for (let i = 0; i < 3; i++) {
|
|
@@ -5854,6 +6708,42 @@ var init_version_check = __esm({
|
|
|
5854
6708
|
}
|
|
5855
6709
|
});
|
|
5856
6710
|
|
|
6711
|
+
// src/cli/lib/proxyDispatcher.ts
|
|
6712
|
+
function hasProxyEnv() {
|
|
6713
|
+
return PROXY_VARS.some((k) => (process.env[k] ?? "").trim() !== "");
|
|
6714
|
+
}
|
|
6715
|
+
async function ensureProxyDispatcher(deps = {}) {
|
|
6716
|
+
if (installed) return "already";
|
|
6717
|
+
if (!hasProxyEnv()) return "no-proxy-env";
|
|
6718
|
+
const isCompiled = deps.isCompiled ?? (() => isCompiledRuntime());
|
|
6719
|
+
if (isCompiled()) return "native-runtime";
|
|
6720
|
+
const load = deps.loadUndici ?? (async () => {
|
|
6721
|
+
const spec = "undici";
|
|
6722
|
+
return await import(spec);
|
|
6723
|
+
});
|
|
6724
|
+
try {
|
|
6725
|
+
const mod = await load();
|
|
6726
|
+
const Agent = mod.EnvHttpProxyAgent;
|
|
6727
|
+
const setGlobalDispatcher = mod.setGlobalDispatcher;
|
|
6728
|
+
if (typeof Agent !== "function" || typeof setGlobalDispatcher !== "function") {
|
|
6729
|
+
return "unavailable";
|
|
6730
|
+
}
|
|
6731
|
+
setGlobalDispatcher(new Agent());
|
|
6732
|
+
installed = true;
|
|
6733
|
+
return "installed";
|
|
6734
|
+
} catch {
|
|
6735
|
+
return "unavailable";
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6738
|
+
var PROXY_VARS, installed;
|
|
6739
|
+
var init_proxyDispatcher = __esm({
|
|
6740
|
+
"src/cli/lib/proxyDispatcher.ts"() {
|
|
6741
|
+
init_assetsRoot();
|
|
6742
|
+
PROXY_VARS = ["HTTP_PROXY", "http_proxy", "HTTPS_PROXY", "https_proxy", "ALL_PROXY"];
|
|
6743
|
+
installed = false;
|
|
6744
|
+
}
|
|
6745
|
+
});
|
|
6746
|
+
|
|
5857
6747
|
// src/cli/lib/update-check-cache.ts
|
|
5858
6748
|
var update_check_cache_exports = {};
|
|
5859
6749
|
__export(update_check_cache_exports, {
|
|
@@ -5901,6 +6791,7 @@ async function resolveLatestCached(d) {
|
|
|
5901
6791
|
}
|
|
5902
6792
|
async function fetchGitHubLatestVersion(timeoutMs) {
|
|
5903
6793
|
try {
|
|
6794
|
+
await ensureProxyDispatcher();
|
|
5904
6795
|
const ac = new AbortController();
|
|
5905
6796
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
5906
6797
|
try {
|
|
@@ -5941,6 +6832,7 @@ var init_update_check_cache = __esm({
|
|
|
5941
6832
|
init_package();
|
|
5942
6833
|
init_assetsRoot();
|
|
5943
6834
|
init_platform();
|
|
6835
|
+
init_proxyDispatcher();
|
|
5944
6836
|
init_version_check();
|
|
5945
6837
|
DEFAULT_UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
5946
6838
|
DEFAULT_UPDATE_CHECK_TIMEOUT_MS = 2e3;
|
|
@@ -5956,20 +6848,20 @@ async function defaultResolver() {
|
|
|
5956
6848
|
const { resolveLatestCachedDefault: resolveLatestCachedDefault2 } = await Promise.resolve().then(() => (init_update_check_cache(), update_check_cache_exports));
|
|
5957
6849
|
return resolveLatestCachedDefault2();
|
|
5958
6850
|
}
|
|
5959
|
-
async function checkUpdate(
|
|
6851
|
+
async function checkUpdate(installed2 = package_default.version, fetch2 = defaultResolver) {
|
|
5960
6852
|
const latest = await fetch2();
|
|
5961
6853
|
if (!latest) {
|
|
5962
6854
|
return { name: "update", status: "pass", message: "update check skipped (npm unreachable)" };
|
|
5963
6855
|
}
|
|
5964
|
-
if (compareVersions(
|
|
6856
|
+
if (compareVersions(installed2, latest) === "behind") {
|
|
5965
6857
|
return {
|
|
5966
6858
|
name: "update",
|
|
5967
6859
|
status: "warn",
|
|
5968
|
-
message: `update available: ${
|
|
6860
|
+
message: `update available: ${installed2} \u2192 ${latest}`,
|
|
5969
6861
|
fix: "run `harnessed update`"
|
|
5970
6862
|
};
|
|
5971
6863
|
}
|
|
5972
|
-
return { name: "update", status: "pass", message: `up to date (${
|
|
6864
|
+
return { name: "update", status: "pass", message: `up to date (${installed2})` };
|
|
5973
6865
|
}
|
|
5974
6866
|
var init_check_update = __esm({
|
|
5975
6867
|
"src/cli/lib/check-update.ts"() {
|
|
@@ -6616,15 +7508,15 @@ function checkPluginStaleness(overrides) {
|
|
|
6616
7508
|
if (deps.registryPath === null) {
|
|
6617
7509
|
return { name: NAME4, status: "skipped", message: "no plugin registry on this harness" };
|
|
6618
7510
|
}
|
|
6619
|
-
const
|
|
6620
|
-
if (
|
|
7511
|
+
const installed2 = readInstalledVersions(deps, deps.registryPath);
|
|
7512
|
+
if (installed2 === null) {
|
|
6621
7513
|
return { name: NAME4, status: "pass", message: "plugin registry unreadable \u2014 skipped" };
|
|
6622
7514
|
}
|
|
6623
7515
|
const manifests = collectPluginManifests(deps);
|
|
6624
7516
|
const behind = [];
|
|
6625
7517
|
let compared = 0;
|
|
6626
7518
|
for (const m of manifests) {
|
|
6627
|
-
const have =
|
|
7519
|
+
const have = installed2.get(m.name);
|
|
6628
7520
|
if (have === void 0) continue;
|
|
6629
7521
|
compared += 1;
|
|
6630
7522
|
if (compareVersions(have, m.recorded) === "behind") {
|
|
@@ -7507,7 +8399,7 @@ async function checkCodexHooks(deps) {
|
|
|
7507
8399
|
const plugins = await d.pluginDirs();
|
|
7508
8400
|
if (plugins.length === 0)
|
|
7509
8401
|
return { name: NAME6, status: "pass", message: "no harnessed codex hook plugins installed" };
|
|
7510
|
-
const [
|
|
8402
|
+
const [installed2, listed] = await Promise.all([d.installedPlugins(), d.listHooks()]);
|
|
7511
8403
|
const problems = [];
|
|
7512
8404
|
const fixes = [];
|
|
7513
8405
|
const ok = [];
|
|
@@ -7515,7 +8407,7 @@ async function checkCodexHooks(deps) {
|
|
|
7515
8407
|
const manifest = pluginName.replace(/^harnessed-/, "");
|
|
7516
8408
|
const pluginId = `${pluginName}@${CODEX_HOOK_MARKETPLACE}`;
|
|
7517
8409
|
const issues = [];
|
|
7518
|
-
if (
|
|
8410
|
+
if (installed2 && !installed2.has(pluginId)) issues.push("not installed in codex");
|
|
7519
8411
|
const hooks = listed.ok ? listed.value.filter((h) => h.key.startsWith(`${pluginId}:`)) : [];
|
|
7520
8412
|
const trust = !listed.ok ? "unknown" : hooks.length === 0 ? "unknown" : hooks.find((h) => h.trustStatus !== "trusted")?.trustStatus ?? "trusted";
|
|
7521
8413
|
if (trust !== "trusted") issues.push(`trust: ${trust}`);
|
|
@@ -7727,203 +8619,6 @@ var init_doctor_registry = __esm({
|
|
|
7727
8619
|
];
|
|
7728
8620
|
}
|
|
7729
8621
|
});
|
|
7730
|
-
function resolveLocaleYaml(dir, baseName, locale = getLocale()) {
|
|
7731
|
-
if (locale !== "en") {
|
|
7732
|
-
const sibling = join(dir, `${baseName}.${locale}.yaml`);
|
|
7733
|
-
if (existsSync(sibling)) return sibling;
|
|
7734
|
-
}
|
|
7735
|
-
return join(dir, `${baseName}.yaml`);
|
|
7736
|
-
}
|
|
7737
|
-
var init_localeYaml = __esm({
|
|
7738
|
-
"src/i18n/localeYaml.ts"() {
|
|
7739
|
-
init_i18n();
|
|
7740
|
-
}
|
|
7741
|
-
});
|
|
7742
|
-
async function loadRolePrompts(workflowsDir, locale = getLocale()) {
|
|
7743
|
-
const path = resolveLocaleYaml(workflowsDir, "role-prompts", locale);
|
|
7744
|
-
let raw;
|
|
7745
|
-
try {
|
|
7746
|
-
raw = await readFile(path, "utf8");
|
|
7747
|
-
} catch {
|
|
7748
|
-
return {};
|
|
7749
|
-
}
|
|
7750
|
-
const doc = parse(raw);
|
|
7751
|
-
return doc?.prompts ?? {};
|
|
7752
|
-
}
|
|
7753
|
-
function mapRolePromptText(rp, render) {
|
|
7754
|
-
const s = (v) => typeof v === "string" ? render(v) : v;
|
|
7755
|
-
return {
|
|
7756
|
-
...rp,
|
|
7757
|
-
specialist: s(rp.specialist),
|
|
7758
|
-
responsibility: s(rp.responsibility),
|
|
7759
|
-
checklist: Array.isArray(rp.checklist) ? rp.checklist.map((c) => s(c)) : rp.checklist,
|
|
7760
|
-
severity: s(rp.severity)
|
|
7761
|
-
};
|
|
7762
|
-
}
|
|
7763
|
-
function mapRolePromptsText(prompts, render) {
|
|
7764
|
-
const out = {};
|
|
7765
|
-
for (const [name, rp] of Object.entries(prompts)) out[name] = mapRolePromptText(rp, render);
|
|
7766
|
-
return out;
|
|
7767
|
-
}
|
|
7768
|
-
var init_rolePrompts = __esm({
|
|
7769
|
-
"src/workflow/rolePrompts.ts"() {
|
|
7770
|
-
init_i18n();
|
|
7771
|
-
init_localeYaml();
|
|
7772
|
-
}
|
|
7773
|
-
});
|
|
7774
|
-
function toHostId(id) {
|
|
7775
|
-
return id === "codex" ? "codex" : "claude";
|
|
7776
|
-
}
|
|
7777
|
-
async function loadHostPrimitives(opts) {
|
|
7778
|
-
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
7779
|
-
let raw;
|
|
7780
|
-
try {
|
|
7781
|
-
raw = await readFile(path, "utf8");
|
|
7782
|
-
} catch {
|
|
7783
|
-
return {};
|
|
7784
|
-
}
|
|
7785
|
-
const doc = parse(raw);
|
|
7786
|
-
return doc?.primitives ?? {};
|
|
7787
|
-
}
|
|
7788
|
-
async function loadHostMapNotes(opts) {
|
|
7789
|
-
const path = resolveLocaleYaml(opts.workflowsDir, YAML_BASE, opts.locale ?? getLocale());
|
|
7790
|
-
let raw;
|
|
7791
|
-
try {
|
|
7792
|
-
raw = await readFile(path, "utf8");
|
|
7793
|
-
} catch {
|
|
7794
|
-
return [];
|
|
7795
|
-
}
|
|
7796
|
-
const doc = parse(raw);
|
|
7797
|
-
const notes = doc?.host_map_notes?.[opts.host];
|
|
7798
|
-
return Array.isArray(notes) ? notes.filter((n) => typeof n === "string") : [];
|
|
7799
|
-
}
|
|
7800
|
-
function loadHostPrimitivesCached(opts) {
|
|
7801
|
-
const locale = opts.locale ?? getLocale();
|
|
7802
|
-
const key = `${opts.workflowsDir}|${locale}`;
|
|
7803
|
-
const hit = _tableCache.get(key);
|
|
7804
|
-
if (hit) return hit;
|
|
7805
|
-
const p8 = loadHostPrimitives({ workflowsDir: opts.workflowsDir, locale });
|
|
7806
|
-
_tableCache.set(key, p8);
|
|
7807
|
-
return p8;
|
|
7808
|
-
}
|
|
7809
|
-
function templateRe() {
|
|
7810
|
-
return new RegExp(HOST_PRIMITIVE_TEMPLATE.source, "g");
|
|
7811
|
-
}
|
|
7812
|
-
function lineOf2(body, offset) {
|
|
7813
|
-
let line = 1;
|
|
7814
|
-
for (let i = 0; i < offset && i < body.length; i++) if (body[i] === "\n") line++;
|
|
7815
|
-
return line;
|
|
7816
|
-
}
|
|
7817
|
-
function renderHostPrimitives(body, opts) {
|
|
7818
|
-
const { host, table } = opts;
|
|
7819
|
-
return body.replace(
|
|
7820
|
-
templateRe(),
|
|
7821
|
-
(match, primitive, variant, offset) => {
|
|
7822
|
-
const name = variant ?? DEFAULT_VARIANT;
|
|
7823
|
-
const where = `'${match}' at line ${lineOf2(body, offset)} (offset ${offset})`;
|
|
7824
|
-
const variants = table[primitive];
|
|
7825
|
-
if (!variants) {
|
|
7826
|
-
throw new Error(
|
|
7827
|
-
`unknown host primitive 'host.${primitive}' \u2014 ${where}; not defined in host-primitives.yaml`
|
|
7828
|
-
);
|
|
7829
|
-
}
|
|
7830
|
-
const entry = variants[name];
|
|
7831
|
-
if (!entry) {
|
|
7832
|
-
throw new Error(
|
|
7833
|
-
`unknown variant '${name}' for host primitive '${primitive}' \u2014 ${where}; defined variants: ${Object.keys(variants).sort().join(", ") || "(none)"}`
|
|
7834
|
-
);
|
|
7835
|
-
}
|
|
7836
|
-
const text = entry[host];
|
|
7837
|
-
if (text === void 0) {
|
|
7838
|
-
throw new Error(
|
|
7839
|
-
`host primitive '${primitive}.${name}' has no text for host '${host}' \u2014 ${where}; defined hosts: ${Object.keys(entry).sort().join(", ") || "(none)"}`
|
|
7840
|
-
);
|
|
7841
|
-
}
|
|
7842
|
-
return text;
|
|
7843
|
-
}
|
|
7844
|
-
);
|
|
7845
|
-
}
|
|
7846
|
-
function cell(text) {
|
|
7847
|
-
return text.replaceAll("|", "\\|");
|
|
7848
|
-
}
|
|
7849
|
-
function code(text) {
|
|
7850
|
-
return text.includes("`") ? text : `\`${text}\``;
|
|
7851
|
-
}
|
|
7852
|
-
function hostMapRows(table) {
|
|
7853
|
-
const rows = [];
|
|
7854
|
-
for (const primitive of Object.keys(table).sort()) {
|
|
7855
|
-
const entry = table[primitive]?.[DEFAULT_VARIANT];
|
|
7856
|
-
const claude = entry?.claude;
|
|
7857
|
-
const codex = entry?.codex;
|
|
7858
|
-
if (claude === void 0 || codex === void 0) continue;
|
|
7859
|
-
if (claude.includes("\n") || codex.includes("\n")) continue;
|
|
7860
|
-
if (claude.length > TERM_MAX_LEN || codex.length > TERM_MAX_LEN) continue;
|
|
7861
|
-
rows.push({ primitive, claude, codex });
|
|
7862
|
-
}
|
|
7863
|
-
return rows;
|
|
7864
|
-
}
|
|
7865
|
-
function buildHostMapSection(opts) {
|
|
7866
|
-
const { host, table } = opts;
|
|
7867
|
-
if (host === "claude") return "";
|
|
7868
|
-
const rows = hostMapRows(table);
|
|
7869
|
-
const notes = opts.notes ?? [];
|
|
7870
|
-
if (rows.length === 0 && notes.length === 0) return "";
|
|
7871
|
-
const skillsDir = table.skills_dir?.[DEFAULT_VARIANT]?.[host];
|
|
7872
|
-
const where = skillsDir ? ` and installed it under ${code(skillsDir)}` : "";
|
|
7873
|
-
const lines = [
|
|
7874
|
-
HOST_MAP_START,
|
|
7875
|
-
`## Host map \u2014 ${host}`,
|
|
7876
|
-
"",
|
|
7877
|
-
`harnessed rendered this artifact for the **${host}** harness${where}. The workflow prose was authored against Claude Code, so where a step names a tool it names the ${host} one. Use the table to decode any instruction that still reads as Claude-Code-shaped; do not substitute the Claude Code names back.`
|
|
7878
|
-
];
|
|
7879
|
-
if (rows.length > 0) {
|
|
7880
|
-
lines.push(
|
|
7881
|
-
"",
|
|
7882
|
-
`| primitive | Claude Code | ${host} |`,
|
|
7883
|
-
"| --- | --- | --- |",
|
|
7884
|
-
...rows.map(
|
|
7885
|
-
(r) => `| \`${r.primitive}\` | ${cell(code(r.claude))} | ${cell(code(r.codex))} |`
|
|
7886
|
-
)
|
|
7887
|
-
);
|
|
7888
|
-
}
|
|
7889
|
-
if (notes.length > 0) {
|
|
7890
|
-
lines.push("", "Caveats \u2014 these hold for the whole artifact:", "");
|
|
7891
|
-
for (const n of notes) lines.push(`- ${n}`);
|
|
7892
|
-
}
|
|
7893
|
-
lines.push(HOST_MAP_END);
|
|
7894
|
-
return lines.join("\n");
|
|
7895
|
-
}
|
|
7896
|
-
function regionRe() {
|
|
7897
|
-
const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7898
|
-
return new RegExp(`${esc(HOST_MAP_START)}[\\s\\S]*?${esc(HOST_MAP_END)}\\n*`, "g");
|
|
7899
|
-
}
|
|
7900
|
-
function insertHostMapSection(body, section) {
|
|
7901
|
-
if (section === "") return body;
|
|
7902
|
-
const stripped = body.replace(regionRe(), "");
|
|
7903
|
-
const fm = FRONTMATTER_RX.exec(stripped);
|
|
7904
|
-
const offset = fm ? fm[0].length : 0;
|
|
7905
|
-
const before = stripped.slice(0, offset);
|
|
7906
|
-
const after = stripped.slice(offset).replace(/^\n+/, "");
|
|
7907
|
-
const lead = offset === 0 ? "" : "\n";
|
|
7908
|
-
return `${before}${lead}${section}
|
|
7909
|
-
|
|
7910
|
-
${after}`;
|
|
7911
|
-
}
|
|
7912
|
-
var DEFAULT_VARIANT, YAML_BASE, _tableCache, HOST_PRIMITIVE_TEMPLATE, HOST_MAP_START, HOST_MAP_END, TERM_MAX_LEN, FRONTMATTER_RX;
|
|
7913
|
-
var init_hostPrimitives = __esm({
|
|
7914
|
-
"src/cli/lib/hostPrimitives.ts"() {
|
|
7915
|
-
init_i18n();
|
|
7916
|
-
init_localeYaml();
|
|
7917
|
-
DEFAULT_VARIANT = "default";
|
|
7918
|
-
YAML_BASE = "host-primitives";
|
|
7919
|
-
_tableCache = /* @__PURE__ */ new Map();
|
|
7920
|
-
HOST_PRIMITIVE_TEMPLATE = /\{\{\s*host\.([A-Za-z0-9_-]+)(?:\.([A-Za-z0-9_-]+))?\s*\}\}/g;
|
|
7921
|
-
HOST_MAP_START = "<!-- harnessed:host-map:start -->";
|
|
7922
|
-
HOST_MAP_END = "<!-- harnessed:host-map:end -->";
|
|
7923
|
-
TERM_MAX_LEN = 64;
|
|
7924
|
-
FRONTMATTER_RX = /^---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(\r?\n|$)/;
|
|
7925
|
-
}
|
|
7926
|
-
});
|
|
7927
8622
|
|
|
7928
8623
|
// src/cli/lib/rolePromptHostRender.ts
|
|
7929
8624
|
var rolePromptHostRender_exports = {};
|
|
@@ -10573,6 +11268,7 @@ var init_gates = __esm({
|
|
|
10573
11268
|
var gc_exports = {};
|
|
10574
11269
|
__export(gc_exports, {
|
|
10575
11270
|
gcCompiledArtifacts: () => gcCompiledArtifacts,
|
|
11271
|
+
gcLedger: () => gcLedger,
|
|
10576
11272
|
registerGc: () => registerGc
|
|
10577
11273
|
});
|
|
10578
11274
|
function byVersion(a, b) {
|
|
@@ -10653,6 +11349,21 @@ async function dirSizeKb(dir) {
|
|
|
10653
11349
|
}
|
|
10654
11350
|
return Math.round(total / 1024);
|
|
10655
11351
|
}
|
|
11352
|
+
async function gcLedger(olderMs, dryRun) {
|
|
11353
|
+
try {
|
|
11354
|
+
const r = await pruneSlots({ olderThanMs: olderMs, dryRun });
|
|
11355
|
+
if (r.pruned.length === 0) return;
|
|
11356
|
+
console.log(
|
|
11357
|
+
t(dryRun ? "gc.ledger_will_prune" : "gc.ledger_pruned", {
|
|
11358
|
+
count: r.pruned.length,
|
|
11359
|
+
kept: r.keptCount
|
|
11360
|
+
})
|
|
11361
|
+
);
|
|
11362
|
+
for (const k of r.pruned) console.log(` ${k}`);
|
|
11363
|
+
} catch (e) {
|
|
11364
|
+
console.error(`gc: ledger prune skipped: ${e instanceof Error ? e.message : String(e)}`);
|
|
11365
|
+
}
|
|
11366
|
+
}
|
|
10656
11367
|
function registerGc(program2) {
|
|
10657
11368
|
program2.command("gc").description(
|
|
10658
11369
|
"Garbage-collect old backup snapshots (immediate by default \u2014 use --dry-run for preview)"
|
|
@@ -10667,6 +11378,7 @@ ${t("gc.invalid_duration.fix")}`
|
|
|
10667
11378
|
process.exit(1);
|
|
10668
11379
|
return;
|
|
10669
11380
|
}
|
|
11381
|
+
await gcLedger(olderMs, dryRun);
|
|
10670
11382
|
const keepLast = Number.parseInt(opts.keepLast ?? "0", 10);
|
|
10671
11383
|
const root = getBackupRoot();
|
|
10672
11384
|
let dirs;
|
|
@@ -10735,6 +11447,7 @@ var DURATION_RE;
|
|
|
10735
11447
|
var init_gc = __esm({
|
|
10736
11448
|
"src/cli/gc.ts"() {
|
|
10737
11449
|
init_package();
|
|
11450
|
+
init_pruneSlots();
|
|
10738
11451
|
init_i18n();
|
|
10739
11452
|
init_backup();
|
|
10740
11453
|
init_version_check();
|
|
@@ -12663,7 +13376,7 @@ async function listBaseManifests(cwd) {
|
|
|
12663
13376
|
return out;
|
|
12664
13377
|
}
|
|
12665
13378
|
async function installBaseProfile(opts) {
|
|
12666
|
-
const
|
|
13379
|
+
const installed2 = [];
|
|
12667
13380
|
const alreadyInstalled = [];
|
|
12668
13381
|
const skipped = [];
|
|
12669
13382
|
const failed = [];
|
|
@@ -12684,10 +13397,10 @@ async function installBaseProfile(opts) {
|
|
|
12684
13397
|
const r = await runInstall(v.manifest, opts);
|
|
12685
13398
|
if ("aborted" in r) skipped.push({ name, reason: `aborted: ${r.reason}` });
|
|
12686
13399
|
else if (r.ok && "alreadyInstalled" in r && r.alreadyInstalled) alreadyInstalled.push(name);
|
|
12687
|
-
else if (r.ok)
|
|
13400
|
+
else if (r.ok) installed2.push(name);
|
|
12688
13401
|
else failed.push({ name, reason: r.error.message });
|
|
12689
13402
|
}
|
|
12690
|
-
return { installed, alreadyInstalled, skipped, failed };
|
|
13403
|
+
return { installed: installed2, alreadyInstalled, skipped, failed };
|
|
12691
13404
|
}
|
|
12692
13405
|
function registerInstallBase(program2) {
|
|
12693
13406
|
program2.command("install-base").description(
|
|
@@ -12702,18 +13415,18 @@ function registerInstallBase(program2) {
|
|
|
12702
13415
|
fullDiff: false,
|
|
12703
13416
|
color: "auto"
|
|
12704
13417
|
};
|
|
12705
|
-
const { installed, alreadyInstalled, skipped, failed } = await installBaseProfile(opts);
|
|
13418
|
+
const { installed: installed2, alreadyInstalled, skipped, failed } = await installBaseProfile(opts);
|
|
12706
13419
|
console.log(
|
|
12707
13420
|
`
|
|
12708
|
-
installed: ${
|
|
13421
|
+
installed: ${installed2.length} / already-installed: ${alreadyInstalled.length} / skipped (user-aborted): ${skipped.length} / failed: ${failed.length}`
|
|
12709
13422
|
);
|
|
12710
|
-
for (const i of
|
|
13423
|
+
for (const i of installed2) console.log(` installed ${i}`);
|
|
12711
13424
|
for (const a of alreadyInstalled)
|
|
12712
13425
|
console.log(` already-installed ${a} \u2014 run \`/mcp\` in Claude Code to verify connection`);
|
|
12713
13426
|
for (const s of skipped) console.log(` skipped ${s.name} \u2014 ${s.reason}`);
|
|
12714
13427
|
for (const f of failed) console.error(` failed ${f.name} \u2014 ${f.reason}`);
|
|
12715
13428
|
if (failed.length > 0) process.exit(1);
|
|
12716
|
-
if (
|
|
13429
|
+
if (installed2.length === 0 && alreadyInstalled.length === 0) process.exit(2);
|
|
12717
13430
|
process.exit(0);
|
|
12718
13431
|
});
|
|
12719
13432
|
}
|
|
@@ -13130,8 +13843,8 @@ async function runResume() {
|
|
|
13130
13843
|
}
|
|
13131
13844
|
const cwd = process.cwd();
|
|
13132
13845
|
const cwdWarn = validated.cwd !== cwd ? `\u26A0 checkpoint cwd '${validated.cwd}' \u2260 current cwd '${cwd}' \u2014 SDK session resume may fail (\xA7 1.3); fresh-session fallback` : void 0;
|
|
13133
|
-
const sidHint = validated.session_id ? ` (session_id: ${validated.session_id}
|
|
13134
|
-
const resumeHint = `\u2192
|
|
13846
|
+
const sidHint = validated.session_id ? ` (recorded session_id: ${validated.session_id}, resumable only on the host that created it; other hosts reload context from the checkpoint)` : " (fresh session \u2014 context reloaded from checkpoint)";
|
|
13847
|
+
const resumeHint = `\u2192 next: /gsd-execute-phase ${validated.phase}${sidHint}`;
|
|
13135
13848
|
const allEvidence = (current.sub_progress ?? []).flatMap(
|
|
13136
13849
|
(e) => e.evidence ?? []
|
|
13137
13850
|
);
|
|
@@ -13968,6 +14681,7 @@ async function runBinaryRollback(deps, opts) {
|
|
|
13968
14681
|
return { status: "rolled-back", from: deps.currentVersion, to: target, backupUsed: backupBin };
|
|
13969
14682
|
}
|
|
13970
14683
|
async function fetchWithTimeout(url, timeoutMs) {
|
|
14684
|
+
await ensureProxyDispatcher();
|
|
13971
14685
|
const ac = new AbortController();
|
|
13972
14686
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
13973
14687
|
try {
|
|
@@ -14052,6 +14766,7 @@ var init_selfUpdateBinary = __esm({
|
|
|
14052
14766
|
"src/cli/lib/selfUpdateBinary.ts"() {
|
|
14053
14767
|
init_package();
|
|
14054
14768
|
init_platform();
|
|
14769
|
+
init_proxyDispatcher();
|
|
14055
14770
|
init_updateSignature();
|
|
14056
14771
|
init_version_check();
|
|
14057
14772
|
OWNER_REPO = "easyinplay/harnessed";
|
|
@@ -14096,6 +14811,7 @@ var init_migration_report = __esm({
|
|
|
14096
14811
|
|
|
14097
14812
|
// src/cli.ts
|
|
14098
14813
|
init_package();
|
|
14814
|
+
init_workflowStore();
|
|
14099
14815
|
|
|
14100
14816
|
// src/cli/advance.ts
|
|
14101
14817
|
function registerAdvance(program2) {
|
|
@@ -14121,6 +14837,61 @@ function registerAdvance(program2) {
|
|
|
14121
14837
|
});
|
|
14122
14838
|
}
|
|
14123
14839
|
|
|
14840
|
+
// src/cli/agents-md.ts
|
|
14841
|
+
init_i18n();
|
|
14842
|
+
init_assetsRoot();
|
|
14843
|
+
init_platform();
|
|
14844
|
+
init_agentsMd();
|
|
14845
|
+
function registerAgentsMd(program2) {
|
|
14846
|
+
program2.command("agents-md").description(
|
|
14847
|
+
"Write the harnessed block into <CODEX_HOME>/AGENTS.md (marker-delimited, idempotent) \u2014 command list + host-primitive glossary, all derived; your own prose outside the markers is untouched"
|
|
14848
|
+
).option("--dry-run", "print what would be written; touch nothing").option("--remove", "strip the harnessed block (leaves the rest of the file alone)").action(async (raw) => {
|
|
14849
|
+
const platform = detectPlatform();
|
|
14850
|
+
if (platform.id !== "codex") {
|
|
14851
|
+
console.error(
|
|
14852
|
+
`harness-mismatch: AGENTS.md is codex's session-start contract; this process resolved to '${platform.id}'. Nothing written \u2014 run this from codex, or force the host with HARNESSED_PLATFORM=codex, because a copy nobody reads is worse than no copy.`
|
|
14853
|
+
);
|
|
14854
|
+
process.exitCode = 1;
|
|
14855
|
+
return;
|
|
14856
|
+
}
|
|
14857
|
+
const locale = getLocale();
|
|
14858
|
+
try {
|
|
14859
|
+
const r = await runAgentsMd({
|
|
14860
|
+
workflowsDir: join(getAssetsRoot(), "workflows"),
|
|
14861
|
+
dryRun: raw.dryRun === true,
|
|
14862
|
+
remove: raw.remove === true,
|
|
14863
|
+
locale: locale === "zh-Hans" ? "zh-Hans" : "en"
|
|
14864
|
+
});
|
|
14865
|
+
switch (r.status) {
|
|
14866
|
+
case "preview":
|
|
14867
|
+
console.log(r.section.trimEnd());
|
|
14868
|
+
console.log(
|
|
14869
|
+
`
|
|
14870
|
+
[dry-run] would ${r.action} the block above in ${r.path}. Nothing outside the markers is touched.`
|
|
14871
|
+
);
|
|
14872
|
+
break;
|
|
14873
|
+
case "written":
|
|
14874
|
+
console.log(
|
|
14875
|
+
`${r.action === "replace" ? "refreshed" : "wrote"} the harnessed block in ${r.path}`
|
|
14876
|
+
);
|
|
14877
|
+
break;
|
|
14878
|
+
case "removed":
|
|
14879
|
+
console.log(`removed the harnessed block from ${r.path}`);
|
|
14880
|
+
break;
|
|
14881
|
+
case "unchanged":
|
|
14882
|
+
console.log(`${r.path} already up to date \u2014 nothing to do`);
|
|
14883
|
+
break;
|
|
14884
|
+
case "absent":
|
|
14885
|
+
console.log(`${r.path} does not exist \u2014 nothing to remove`);
|
|
14886
|
+
break;
|
|
14887
|
+
}
|
|
14888
|
+
} catch (e) {
|
|
14889
|
+
console.error(`agents-md failed: ${e.message}`);
|
|
14890
|
+
process.exitCode = 1;
|
|
14891
|
+
}
|
|
14892
|
+
});
|
|
14893
|
+
}
|
|
14894
|
+
|
|
14124
14895
|
// src/cli/audit.ts
|
|
14125
14896
|
init_validate();
|
|
14126
14897
|
|
|
@@ -17416,18 +18187,18 @@ async function runStepBInstall(manifestPaths, runOpts = {}) {
|
|
|
17416
18187
|
const restEntries = restSettled.map(
|
|
17417
18188
|
(s) => s.status === "fulfilled" ? s.value : { status: "failed", name: "?", reason: String(s.reason) }
|
|
17418
18189
|
);
|
|
17419
|
-
const
|
|
18190
|
+
const installed2 = [];
|
|
17420
18191
|
const alreadyInstalled = [];
|
|
17421
18192
|
const skipped = [];
|
|
17422
18193
|
const failed = [];
|
|
17423
18194
|
for (const v of [...invalid, ...mcpEntries, ...restEntries]) {
|
|
17424
|
-
if (v.status === "installed")
|
|
18195
|
+
if (v.status === "installed") installed2.push(v.name);
|
|
17425
18196
|
else if (v.status === "already-installed") alreadyInstalled.push(v.name);
|
|
17426
18197
|
else if (v.status === "skipped") skipped.push({ name: v.name, reason: v.reason });
|
|
17427
18198
|
else if (v.status === "failed") failed.push(`${v.name}: ${v.reason}`);
|
|
17428
18199
|
}
|
|
17429
18200
|
return {
|
|
17430
|
-
installed,
|
|
18201
|
+
installed: installed2,
|
|
17431
18202
|
alreadyInstalled,
|
|
17432
18203
|
skipped,
|
|
17433
18204
|
failed,
|
|
@@ -17494,19 +18265,19 @@ async function makeIdempotentProbe(manifestPaths) {
|
|
|
17494
18265
|
init_package();
|
|
17495
18266
|
init_assetsRoot();
|
|
17496
18267
|
init_version_check();
|
|
17497
|
-
function versionBannerLines(
|
|
17498
|
-
const lines = [`harnessed setup v${
|
|
18268
|
+
function versionBannerLines(installed2, latest, updateHint = "npm install -g harnessed@latest") {
|
|
18269
|
+
const lines = [`harnessed setup v${installed2}`];
|
|
17499
18270
|
if (latest === null) {
|
|
17500
18271
|
lines.push(" could not check latest version");
|
|
17501
18272
|
return lines;
|
|
17502
18273
|
}
|
|
17503
|
-
const cmp = compareVersions(
|
|
18274
|
+
const cmp = compareVersions(installed2, latest);
|
|
17504
18275
|
if (cmp === "behind") {
|
|
17505
|
-
lines.push(`\u26A0 update available: ${
|
|
18276
|
+
lines.push(`\u26A0 update available: ${installed2} \u2192 ${latest} \u2014 ${updateHint}`);
|
|
17506
18277
|
} else if (cmp === "current") {
|
|
17507
18278
|
lines.push(`\u2713 latest (v${latest})`);
|
|
17508
18279
|
} else if (cmp === "ahead") {
|
|
17509
|
-
lines.push(`\u2713 latest (v${
|
|
18280
|
+
lines.push(`\u2713 latest (v${installed2})`);
|
|
17510
18281
|
}
|
|
17511
18282
|
return lines;
|
|
17512
18283
|
}
|
|
@@ -17525,7 +18296,7 @@ async function printSetupVersionBanner() {
|
|
|
17525
18296
|
}
|
|
17526
18297
|
|
|
17527
18298
|
// src/cli/setup.ts
|
|
17528
|
-
var KNOWN_PLATFORMS =
|
|
18299
|
+
var KNOWN_PLATFORMS = HOST_IDS;
|
|
17529
18300
|
async function applyPlatformOption(platform, persist) {
|
|
17530
18301
|
if (!KNOWN_PLATFORMS.includes(platform)) {
|
|
17531
18302
|
console.error(
|
|
@@ -18577,6 +19348,20 @@ async function runUnifiedUninstall(home, dryRun) {
|
|
|
18577
19348
|
failures.push(`${path}: ${e.message}`);
|
|
18578
19349
|
}
|
|
18579
19350
|
}
|
|
19351
|
+
let removedAgentsMdBlock = false;
|
|
19352
|
+
if (platform.id === "codex") {
|
|
19353
|
+
try {
|
|
19354
|
+
const { agentsMdPath: agentsMdPath2, stripAgentsMdSection: stripAgentsMdSection2 } = await Promise.resolve().then(() => (init_agentsMd(), agentsMd_exports));
|
|
19355
|
+
const p8 = agentsMdPath2();
|
|
19356
|
+
const before = await readFile(p8, "utf8");
|
|
19357
|
+
const after = stripAgentsMdSection2(before);
|
|
19358
|
+
if (after !== before) {
|
|
19359
|
+
await writeFile(p8, after, "utf8");
|
|
19360
|
+
removedAgentsMdBlock = true;
|
|
19361
|
+
}
|
|
19362
|
+
} catch {
|
|
19363
|
+
}
|
|
19364
|
+
}
|
|
18580
19365
|
let removedAgentRoles = 0;
|
|
18581
19366
|
for (const path of agentRoleFiles) {
|
|
18582
19367
|
try {
|
|
@@ -18586,6 +19371,7 @@ async function runUnifiedUninstall(home, dryRun) {
|
|
|
18586
19371
|
failures.push(`${path}: ${e.message}`);
|
|
18587
19372
|
}
|
|
18588
19373
|
}
|
|
19374
|
+
if (removedAgentsMdBlock) console.log(` AGENTS.md: harnessed block removed`);
|
|
18589
19375
|
let removedSkills = 0;
|
|
18590
19376
|
for (const dir of skillDirs) {
|
|
18591
19377
|
try {
|
|
@@ -18923,6 +19709,11 @@ process.on("unhandledRejection", (reason) => {
|
|
|
18923
19709
|
process.on("uncaughtException", (err2) => {
|
|
18924
19710
|
fatal(err2 instanceof Error ? err2.message : String(err2));
|
|
18925
19711
|
});
|
|
19712
|
+
await migrateRepoKeyCase().catch((e) => {
|
|
19713
|
+
console.error(
|
|
19714
|
+
`[harnessed] WARN: repo-key case migration deferred: ${e instanceof Error ? e.message : String(e)}`
|
|
19715
|
+
);
|
|
19716
|
+
});
|
|
18926
19717
|
var program = new Command();
|
|
18927
19718
|
program.name("harnessed").description("AI coding harness package manager + composition orchestrator").version(package_default.version).option("--lang <code>", "output language: en | zh (auto-detect from $LANG / Intl if absent)");
|
|
18928
19719
|
registerInstall(program);
|
|
@@ -18949,6 +19740,7 @@ registerReject(program);
|
|
|
18949
19740
|
registerCompact(program);
|
|
18950
19741
|
registerWorkflows(program);
|
|
18951
19742
|
registerExemptGateguard(program);
|
|
19743
|
+
registerAgentsMd(program);
|
|
18952
19744
|
registerLearn(program);
|
|
18953
19745
|
registerUpdate(program);
|
|
18954
19746
|
registerReleasePreflight(program);
|