harnessed 4.23.1 → 4.24.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/dist/cli.mjs +263 -62
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/workflows/role-prompts.yaml +1 -0
- package/workflows/role-prompts.zh-Hans.yaml +1 -0
package/dist/cli.mjs
CHANGED
|
@@ -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.24.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -3470,6 +3470,51 @@ var init_before_spawn = __esm({
|
|
|
3470
3470
|
init_disciplineLoader();
|
|
3471
3471
|
}
|
|
3472
3472
|
});
|
|
3473
|
+
function isUndefinedVariableError(e) {
|
|
3474
|
+
return e instanceof GateEvalError && /undefined variable/i.test(e.message);
|
|
3475
|
+
}
|
|
3476
|
+
function evalGate(expression, context) {
|
|
3477
|
+
try {
|
|
3478
|
+
const parsed = _parserSingleton.parse(expression);
|
|
3479
|
+
const result = parsed.evaluate(context);
|
|
3480
|
+
if (typeof result !== "boolean") {
|
|
3481
|
+
throw new GateEvalError(
|
|
3482
|
+
`Expression must evaluate to boolean, got ${typeof result}`,
|
|
3483
|
+
expression
|
|
3484
|
+
);
|
|
3485
|
+
}
|
|
3486
|
+
return result;
|
|
3487
|
+
} catch (err2) {
|
|
3488
|
+
if (err2 instanceof GateEvalError) throw err2;
|
|
3489
|
+
throw new GateEvalError(`Gate eval failed: ${err2.message}`, expression);
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
var PARSER_OPTIONS, _parserSingleton, GateEvalError;
|
|
3493
|
+
var init_exprBuilder = __esm({
|
|
3494
|
+
"src/workflow/exprBuilder.ts"() {
|
|
3495
|
+
PARSER_OPTIONS = {
|
|
3496
|
+
operators: {
|
|
3497
|
+
add: false,
|
|
3498
|
+
subtract: false,
|
|
3499
|
+
multiply: false,
|
|
3500
|
+
divide: false,
|
|
3501
|
+
logical: true,
|
|
3502
|
+
comparison: true,
|
|
3503
|
+
in: true,
|
|
3504
|
+
assignment: false
|
|
3505
|
+
}
|
|
3506
|
+
};
|
|
3507
|
+
_parserSingleton = new Parser(PARSER_OPTIONS);
|
|
3508
|
+
GateEvalError = class extends Error {
|
|
3509
|
+
constructor(message, expression) {
|
|
3510
|
+
super(message);
|
|
3511
|
+
this.expression = expression;
|
|
3512
|
+
this.name = "GateEvalError";
|
|
3513
|
+
}
|
|
3514
|
+
expression;
|
|
3515
|
+
};
|
|
3516
|
+
}
|
|
3517
|
+
});
|
|
3473
3518
|
var GovernanceStatus, GovernanceV1;
|
|
3474
3519
|
var init_governance = __esm({
|
|
3475
3520
|
"src/workflow/schema/governance.ts"() {
|
|
@@ -3529,48 +3574,6 @@ var init_governance2 = __esm({
|
|
|
3529
3574
|
init_governance();
|
|
3530
3575
|
}
|
|
3531
3576
|
});
|
|
3532
|
-
function evalGate(expression, context) {
|
|
3533
|
-
try {
|
|
3534
|
-
const parsed = _parserSingleton.parse(expression);
|
|
3535
|
-
const result = parsed.evaluate(context);
|
|
3536
|
-
if (typeof result !== "boolean") {
|
|
3537
|
-
throw new GateEvalError(
|
|
3538
|
-
`Expression must evaluate to boolean, got ${typeof result}`,
|
|
3539
|
-
expression
|
|
3540
|
-
);
|
|
3541
|
-
}
|
|
3542
|
-
return result;
|
|
3543
|
-
} catch (err2) {
|
|
3544
|
-
if (err2 instanceof GateEvalError) throw err2;
|
|
3545
|
-
throw new GateEvalError(`Gate eval failed: ${err2.message}`, expression);
|
|
3546
|
-
}
|
|
3547
|
-
}
|
|
3548
|
-
var PARSER_OPTIONS, _parserSingleton, GateEvalError;
|
|
3549
|
-
var init_exprBuilder = __esm({
|
|
3550
|
-
"src/workflow/exprBuilder.ts"() {
|
|
3551
|
-
PARSER_OPTIONS = {
|
|
3552
|
-
operators: {
|
|
3553
|
-
add: false,
|
|
3554
|
-
subtract: false,
|
|
3555
|
-
multiply: false,
|
|
3556
|
-
divide: false,
|
|
3557
|
-
logical: true,
|
|
3558
|
-
comparison: true,
|
|
3559
|
-
in: true,
|
|
3560
|
-
assignment: false
|
|
3561
|
-
}
|
|
3562
|
-
};
|
|
3563
|
-
_parserSingleton = new Parser(PARSER_OPTIONS);
|
|
3564
|
-
GateEvalError = class extends Error {
|
|
3565
|
-
constructor(message, expression) {
|
|
3566
|
-
super(message);
|
|
3567
|
-
this.expression = expression;
|
|
3568
|
-
this.name = "GateEvalError";
|
|
3569
|
-
}
|
|
3570
|
-
expression;
|
|
3571
|
-
};
|
|
3572
|
-
}
|
|
3573
|
-
});
|
|
3574
3577
|
var TriggerInvocation, RequiresCapabilities, JudgmentTrigger, FallbackRule, JudgmentTriggersFile, JudgmentRulesFile, UserOverrideEntry, UserOverridesFile;
|
|
3575
3578
|
var init_judgment = __esm({
|
|
3576
3579
|
"src/workflow/schema/judgment.ts"() {
|
|
@@ -3887,6 +3890,26 @@ var init_sdkSpawn = __esm({
|
|
|
3887
3890
|
};
|
|
3888
3891
|
}
|
|
3889
3892
|
});
|
|
3893
|
+
|
|
3894
|
+
// src/workflow/skipSubs.ts
|
|
3895
|
+
function matchSkipSub(requested, sub, master) {
|
|
3896
|
+
if (requested.has(sub)) return sub;
|
|
3897
|
+
const alias = `${master}-${sub}`;
|
|
3898
|
+
if (requested.has(alias)) return alias;
|
|
3899
|
+
return null;
|
|
3900
|
+
}
|
|
3901
|
+
function warnUnmatchedSkips(requested, matched, master, validSubs, warn) {
|
|
3902
|
+
for (const name of requested) {
|
|
3903
|
+
if (matched.has(name)) continue;
|
|
3904
|
+
warn(
|
|
3905
|
+
`\u26A0\uFE0F --skip-sub "${name}" ignored: not a sub of master ${master}; valid subs: ${validSubs.join(", ")}`
|
|
3906
|
+
);
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
var init_skipSubs = __esm({
|
|
3910
|
+
"src/workflow/skipSubs.ts"() {
|
|
3911
|
+
}
|
|
3912
|
+
});
|
|
3890
3913
|
function resolveMasterYamlPath(masterName, packageRoot) {
|
|
3891
3914
|
return masterName === "auto" ? resolve(packageRoot, "workflows", "auto", "workflow.yaml") : resolve(packageRoot, "workflows", masterName, "auto", "workflow.yaml");
|
|
3892
3915
|
}
|
|
@@ -4025,8 +4048,11 @@ async function runMasterOrchestrator(masterName, context, packageRoot, spawnDriv
|
|
|
4025
4048
|
}
|
|
4026
4049
|
const skipSubs = new Set(Array.isArray(context.skip_subs) ? context.skip_subs : []);
|
|
4027
4050
|
const gateEvalled = [];
|
|
4051
|
+
const matchedSkips = /* @__PURE__ */ new Set();
|
|
4028
4052
|
for (const clause of master.delegates_to) {
|
|
4029
|
-
|
|
4053
|
+
const skipHit = matchSkipSub(skipSubs, clause.sub, masterName);
|
|
4054
|
+
if (skipHit !== null) {
|
|
4055
|
+
matchedSkips.add(skipHit);
|
|
4030
4056
|
gateEvalled.push({
|
|
4031
4057
|
clause,
|
|
4032
4058
|
passes: false,
|
|
@@ -4046,16 +4072,34 @@ async function runMasterOrchestrator(masterName, context, packageRoot, spawnDriv
|
|
|
4046
4072
|
reason: passes ? void 0 : `gate ${clause.gate} = false`
|
|
4047
4073
|
});
|
|
4048
4074
|
} catch (e) {
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4075
|
+
if (isUndefinedVariableError(e)) {
|
|
4076
|
+
console.warn(
|
|
4077
|
+
`\u26A0\uFE0F master ${masterName} sub ${clause.sub} gate ${clause.gate} references a variable missing from the gate context (${e.message}). Treating as NOT fired (fail-closed for config errors) \u2014 fix the judgments yaml expression or supply the variable via --context / gateContext defaults.`
|
|
4078
|
+
);
|
|
4079
|
+
gateEvalled.push({
|
|
4080
|
+
clause,
|
|
4081
|
+
passes: false,
|
|
4082
|
+
reason: `gate ${clause.gate} misconfigured (undefined variable) \u2014 fail-closed, not fired`
|
|
4083
|
+
});
|
|
4084
|
+
} else {
|
|
4085
|
+
console.warn(
|
|
4086
|
+
`\u26A0\uFE0F master ${masterName} sub ${clause.sub} gate ${clause.gate} eval failed (${e.message}); proceeding with sub as if gate fired=true (ADR 0029 fail-soft).`
|
|
4087
|
+
);
|
|
4088
|
+
gateEvalled.push({
|
|
4089
|
+
clause,
|
|
4090
|
+
passes: true,
|
|
4091
|
+
reason: `gate eval error (fail-soft fires=true): ${e.message}`
|
|
4092
|
+
});
|
|
4093
|
+
}
|
|
4057
4094
|
}
|
|
4058
4095
|
}
|
|
4096
|
+
warnUnmatchedSkips(
|
|
4097
|
+
skipSubs,
|
|
4098
|
+
matchedSkips,
|
|
4099
|
+
masterName,
|
|
4100
|
+
master.delegates_to.map((c) => c.sub),
|
|
4101
|
+
(m) => console.warn(m)
|
|
4102
|
+
);
|
|
4059
4103
|
emitGateTransparency(masterName, master.delegates_to.length, gateEvalled);
|
|
4060
4104
|
const PARALLEL_MID_ANCHOR = 50;
|
|
4061
4105
|
const firedClauses = gateEvalled.filter((g) => g.passes).map((g) => g.clause);
|
|
@@ -4106,8 +4150,10 @@ async function runMasterOrchestrator(masterName, context, packageRoot, spawnDriv
|
|
|
4106
4150
|
}
|
|
4107
4151
|
var init_masterOrchestrator = __esm({
|
|
4108
4152
|
"src/workflow/masterOrchestrator.ts"() {
|
|
4153
|
+
init_exprBuilder();
|
|
4109
4154
|
init_judgmentResolver();
|
|
4110
4155
|
init_workflow();
|
|
4156
|
+
init_skipSubs();
|
|
4111
4157
|
init_masterOrchestrator_helpers();
|
|
4112
4158
|
}
|
|
4113
4159
|
});
|
|
@@ -4229,9 +4275,16 @@ async function runWorkflow(yamlPath, vars, opts = {}) {
|
|
|
4229
4275
|
try {
|
|
4230
4276
|
fires = await resolveJudgmentGate(ph.gate, gateContext, packageRoot);
|
|
4231
4277
|
} catch (err2) {
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4278
|
+
if (isUndefinedVariableError(err2)) {
|
|
4279
|
+
console.warn(
|
|
4280
|
+
`\u26A0\uFE0F phase ${ph.id} gate ${ph.gate} references a variable missing from the gate context (${err2.message}). Treating as NOT fired (fail-closed for config errors) \u2014 fix the judgments yaml expression or supply the variable via --context / gateContext defaults.`
|
|
4281
|
+
);
|
|
4282
|
+
fires = false;
|
|
4283
|
+
} else {
|
|
4284
|
+
console.warn(
|
|
4285
|
+
`\u26A0\uFE0F phase ${ph.id} gate ${ph.gate} eval failed (${err2.message}); proceeding with phase as if gate fired=true (ADR 0029 fail-soft).`
|
|
4286
|
+
);
|
|
4287
|
+
}
|
|
4235
4288
|
}
|
|
4236
4289
|
if (!fires) {
|
|
4237
4290
|
skippedPhases.push(ph.id);
|
|
@@ -4311,6 +4364,7 @@ var init_run = __esm({
|
|
|
4311
4364
|
init_before_commit();
|
|
4312
4365
|
init_before_phase_execute();
|
|
4313
4366
|
init_before_spawn();
|
|
4367
|
+
init_exprBuilder();
|
|
4314
4368
|
init_governance2();
|
|
4315
4369
|
init_judgmentResolver();
|
|
4316
4370
|
init_ralphLoop();
|
|
@@ -4472,6 +4526,12 @@ function buildDefaultGateContext(task, stage) {
|
|
|
4472
4526
|
shared_task_list: false,
|
|
4473
4527
|
opposing_hypothesis_debate: false,
|
|
4474
4528
|
fullstack_three_way: false,
|
|
4529
|
+
// 4.23.2 (issue #5) — stage-routing.yaml verify-multispec-critical-release
|
|
4530
|
+
// references the BARE identifier (root-flat schema contract, sister
|
|
4531
|
+
// src/workflow/schema/phaseFactContext.ts). Missing here since the v4.1.2
|
|
4532
|
+
// extraction → eval threw undefined-variable → ADR 0029 fail-soft fired the
|
|
4533
|
+
// 4-specialist multispec team on EVERY verify. Opt-in via --context.
|
|
4534
|
+
is_critical_release: false,
|
|
4475
4535
|
phase: {
|
|
4476
4536
|
stage,
|
|
4477
4537
|
is_critical_module: true,
|
|
@@ -5956,6 +6016,7 @@ __export(skillIntegrity_exports, {
|
|
|
5956
6016
|
attachCulprits: () => attachCulprits,
|
|
5957
6017
|
auditInstalledSkills: () => auditInstalledSkills,
|
|
5958
6018
|
buildCulpritIndex: () => buildCulpritIndex,
|
|
6019
|
+
healPreviewFix: () => healPreviewFix,
|
|
5959
6020
|
integrityReportLines: () => integrityReportLines,
|
|
5960
6021
|
ledgerPath: () => ledgerPath,
|
|
5961
6022
|
readHashLedger: () => readHashLedger,
|
|
@@ -6072,6 +6133,10 @@ function attachCulprits(entries, culpritIndex) {
|
|
|
6072
6133
|
(e) => e.status === "foreign" ? { ...e, culprit: culpritIndex.get(e.name) ?? e.culprit } : e
|
|
6073
6134
|
);
|
|
6074
6135
|
}
|
|
6136
|
+
function healPreviewFix(bad) {
|
|
6137
|
+
const names = bad.map((e) => e.name).join(", ");
|
|
6138
|
+
return `would reinstall: ${names}; run \`harnessed setup\` to heal (a backup of the current content is taken first, under \`~/.claude/harnessed/backups/\`)`;
|
|
6139
|
+
}
|
|
6075
6140
|
function integrityReportLines(entries) {
|
|
6076
6141
|
const bad = entries.filter((e) => e.status !== "ok");
|
|
6077
6142
|
if (bad.length === 0) return [];
|
|
@@ -6132,7 +6197,9 @@ async function checkSkillIntegrity() {
|
|
|
6132
6197
|
name,
|
|
6133
6198
|
status: "warn",
|
|
6134
6199
|
message: `${bad.length} workflow skill(s) diverged from the install-time state (foreign/tampered/stale/missing) \u2014 the slash command may NOT enter the engine: ${detail}`,
|
|
6135
|
-
|
|
6200
|
+
// 4.24.0 (intel G4) — heal preview: name what setup would reinstall +
|
|
6201
|
+
// the backup-first guarantee, instead of a generic "re-run setup".
|
|
6202
|
+
fix: healPreviewFix(bad)
|
|
6136
6203
|
};
|
|
6137
6204
|
} catch {
|
|
6138
6205
|
return { name, status: "pass", message: "skipped (environment not auditable)" };
|
|
@@ -8877,6 +8944,66 @@ var init_resume = __esm({
|
|
|
8877
8944
|
}
|
|
8878
8945
|
});
|
|
8879
8946
|
|
|
8947
|
+
// src/cli/lib/skillBackup.ts
|
|
8948
|
+
var skillBackup_exports = {};
|
|
8949
|
+
__export(skillBackup_exports, {
|
|
8950
|
+
backupSkillDir: () => backupSkillDir,
|
|
8951
|
+
newBackupSessionDir: () => newBackupSessionDir,
|
|
8952
|
+
skillContentMatchesLedger: () => skillContentMatchesLedger
|
|
8953
|
+
});
|
|
8954
|
+
function newBackupSessionDir(label, root = getBackupRoot()) {
|
|
8955
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-");
|
|
8956
|
+
return join(root, `${ts}-${label}`);
|
|
8957
|
+
}
|
|
8958
|
+
async function backupSkillDir(name, skillsBase, sessionDir) {
|
|
8959
|
+
const src = join(skillsBase, name);
|
|
8960
|
+
try {
|
|
8961
|
+
await stat(src);
|
|
8962
|
+
} catch (err2) {
|
|
8963
|
+
const code = err2.code;
|
|
8964
|
+
if (code === "ENOENT") return { ok: false, code: "ENOENT", message: "nothing on disk" };
|
|
8965
|
+
return { ok: false, code: "ERR", message: err2.message };
|
|
8966
|
+
}
|
|
8967
|
+
const dest = join(sessionDir, name);
|
|
8968
|
+
try {
|
|
8969
|
+
await mkdir(sessionDir, { recursive: true });
|
|
8970
|
+
await cp(src, dest, { recursive: true, force: true });
|
|
8971
|
+
} catch (err2) {
|
|
8972
|
+
return { ok: false, code: "ERR", message: err2.message };
|
|
8973
|
+
}
|
|
8974
|
+
try {
|
|
8975
|
+
await writeFile(
|
|
8976
|
+
join(sessionDir, "README.txt"),
|
|
8977
|
+
"Pre-overwrite copies of installed skill dirs, taken by `harnessed setup` before replacing them. Restore = copy a dir back into ~/.claude/skills/.\n",
|
|
8978
|
+
"utf8"
|
|
8979
|
+
);
|
|
8980
|
+
} catch {
|
|
8981
|
+
}
|
|
8982
|
+
return { ok: true, dir: dest };
|
|
8983
|
+
}
|
|
8984
|
+
async function skillContentMatchesLedger(name, skillsBase, ledger) {
|
|
8985
|
+
const record = ledger?.[name];
|
|
8986
|
+
if (!record) return null;
|
|
8987
|
+
let text;
|
|
8988
|
+
try {
|
|
8989
|
+
text = await readFile(join(skillsBase, name, "SKILL.md"), "utf8");
|
|
8990
|
+
} catch {
|
|
8991
|
+
return null;
|
|
8992
|
+
}
|
|
8993
|
+
if (typeof text !== "string") return null;
|
|
8994
|
+
try {
|
|
8995
|
+
return sha256Of(text) === record.sha256;
|
|
8996
|
+
} catch {
|
|
8997
|
+
return null;
|
|
8998
|
+
}
|
|
8999
|
+
}
|
|
9000
|
+
var init_skillBackup = __esm({
|
|
9001
|
+
"src/cli/lib/skillBackup.ts"() {
|
|
9002
|
+
init_backup();
|
|
9003
|
+
init_skillIntegrity();
|
|
9004
|
+
}
|
|
9005
|
+
});
|
|
9006
|
+
|
|
8880
9007
|
// src/cli/lib/l4-rescue.ts
|
|
8881
9008
|
var l4_rescue_exports = {};
|
|
8882
9009
|
__export(l4_rescue_exports, {
|
|
@@ -9903,7 +10030,9 @@ function registerExemptGateguard(program2) {
|
|
|
9903
10030
|
|
|
9904
10031
|
// src/cli/gates.ts
|
|
9905
10032
|
init_path_guard();
|
|
10033
|
+
init_exprBuilder();
|
|
9906
10034
|
init_judgmentResolver();
|
|
10035
|
+
init_skipSubs();
|
|
9907
10036
|
init_assetsRoot();
|
|
9908
10037
|
init_gateContext();
|
|
9909
10038
|
var VALID_MASTERS = /* @__PURE__ */ new Set(["auto", "discuss", "plan", "task", "verify", "ship"]);
|
|
@@ -9984,8 +10113,11 @@ function registerGates(program2) {
|
|
|
9984
10113
|
ctx.skip_subs = [...skipSubs];
|
|
9985
10114
|
const fire = [];
|
|
9986
10115
|
const skip = [];
|
|
10116
|
+
const matchedSkips = /* @__PURE__ */ new Set();
|
|
9987
10117
|
for (const clause of clauses) {
|
|
9988
|
-
|
|
10118
|
+
const skipHit = matchSkipSub(skipSubs, clause.sub, master);
|
|
10119
|
+
if (skipHit !== null) {
|
|
10120
|
+
matchedSkips.add(skipHit);
|
|
9989
10121
|
skip.push({
|
|
9990
10122
|
sub: clause.sub,
|
|
9991
10123
|
reason: "skipped via skip_subs (done interactively in main session)"
|
|
@@ -10004,12 +10136,29 @@ function registerGates(program2) {
|
|
|
10004
10136
|
skip.push({ sub: clause.sub, reason: `gate ${clause.gate} = false` });
|
|
10005
10137
|
}
|
|
10006
10138
|
} catch (e) {
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10139
|
+
if (isUndefinedVariableError(e)) {
|
|
10140
|
+
console.warn(
|
|
10141
|
+
`\u26A0\uFE0F master ${master} sub ${clause.sub} gate ${clause.gate} references a variable missing from the gate context (${e.message}). Treating as NOT fired (fail-closed for config errors) \u2014 fix the judgments yaml expression or supply the variable via --context / gateContext defaults.`
|
|
10142
|
+
);
|
|
10143
|
+
skip.push({
|
|
10144
|
+
sub: clause.sub,
|
|
10145
|
+
reason: `gate ${clause.gate} misconfigured (undefined variable) \u2014 fail-closed, not fired`
|
|
10146
|
+
});
|
|
10147
|
+
} else {
|
|
10148
|
+
console.warn(
|
|
10149
|
+
`\u26A0\uFE0F master ${master} sub ${clause.sub} gate ${clause.gate} eval failed (${e.message}); firing sub as if gate=true (ADR 0029 fail-soft).`
|
|
10150
|
+
);
|
|
10151
|
+
fire.push(fireEntry(clause, master));
|
|
10152
|
+
}
|
|
10011
10153
|
}
|
|
10012
10154
|
}
|
|
10155
|
+
warnUnmatchedSkips(
|
|
10156
|
+
skipSubs,
|
|
10157
|
+
matchedSkips,
|
|
10158
|
+
master,
|
|
10159
|
+
clauses.map((c) => c.sub),
|
|
10160
|
+
(m) => console.warn(m)
|
|
10161
|
+
);
|
|
10013
10162
|
let parallelism = { escalate_to_teams: false, reason: null };
|
|
10014
10163
|
try {
|
|
10015
10164
|
const escalate = await resolveJudgmentGate(PARALLELISM_GATE, ctx, packageRoot);
|
|
@@ -11604,11 +11753,38 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
|
|
|
11604
11753
|
}
|
|
11605
11754
|
}
|
|
11606
11755
|
}
|
|
11756
|
+
let skillBackupApi = null;
|
|
11757
|
+
let stepALedger = null;
|
|
11758
|
+
try {
|
|
11759
|
+
skillBackupApi = await Promise.resolve().then(() => (init_skillBackup(), skillBackup_exports));
|
|
11760
|
+
const { readHashLedger: readHashLedger2 } = await Promise.resolve().then(() => (init_skillIntegrity(), skillIntegrity_exports));
|
|
11761
|
+
stepALedger = await readHashLedger2();
|
|
11762
|
+
} catch {
|
|
11763
|
+
skillBackupApi = null;
|
|
11764
|
+
}
|
|
11765
|
+
let stepASession = null;
|
|
11766
|
+
const stepABackups = [];
|
|
11607
11767
|
let skillsInstalled = 0;
|
|
11608
11768
|
for (const wf of toInstall) {
|
|
11609
11769
|
const src = join(workflowsDir, wf.relPath);
|
|
11610
11770
|
const dst = join(skillsBase, wf.name);
|
|
11611
11771
|
try {
|
|
11772
|
+
if (skillBackupApi) {
|
|
11773
|
+
try {
|
|
11774
|
+
const pristine = await skillBackupApi.skillContentMatchesLedger(
|
|
11775
|
+
wf.name,
|
|
11776
|
+
skillsBase,
|
|
11777
|
+
stepALedger
|
|
11778
|
+
);
|
|
11779
|
+
if (pristine !== true) {
|
|
11780
|
+
stepASession ??= skillBackupApi.newBackupSessionDir("step-a");
|
|
11781
|
+
const b2 = await skillBackupApi.backupSkillDir(wf.name, skillsBase, stepASession);
|
|
11782
|
+
if (b2.ok) stepABackups.push({ name: wf.name, dir: b2.dir });
|
|
11783
|
+
else if (b2.code !== "ENOENT") stepABackups.push({ name: wf.name, error: b2.message });
|
|
11784
|
+
}
|
|
11785
|
+
} catch {
|
|
11786
|
+
}
|
|
11787
|
+
}
|
|
11612
11788
|
await cp(src, dst, { recursive: true, force: true });
|
|
11613
11789
|
skillsInstalled++;
|
|
11614
11790
|
} catch (e) {
|
|
@@ -11616,6 +11792,17 @@ Force-update pass complete: ${b2.installed.length} installed / ${b2.keptExisting
|
|
|
11616
11792
|
process.exit(1);
|
|
11617
11793
|
}
|
|
11618
11794
|
}
|
|
11795
|
+
if (stepABackups.length > 0) {
|
|
11796
|
+
console.warn(
|
|
11797
|
+
`
|
|
11798
|
+
${stepABackups.length} existing skill dir(s) were not the pristine installed state \u2014 backed up before overwriting:`
|
|
11799
|
+
);
|
|
11800
|
+
for (const b2 of stepABackups) {
|
|
11801
|
+
console.warn(
|
|
11802
|
+
b2.dir ? ` ${b2.name} \u2192 ${b2.dir}` : ` \u26A0 ${b2.name}: backup FAILED (${b2.error}) \u2014 overwritten anyway (engine integrity first)`
|
|
11803
|
+
);
|
|
11804
|
+
}
|
|
11805
|
+
}
|
|
11619
11806
|
console.log(t("setup.step_a_complete", { count: skillsInstalled, path: skillsBase }));
|
|
11620
11807
|
const skillNames = toInstall.map((wf) => wf.name);
|
|
11621
11808
|
const rendered = await renderAllSkills(
|
|
@@ -11729,10 +11916,24 @@ ${b.failed.length} component(s) failed \u2014 see the notes in the tables above;
|
|
|
11729
11916
|
for (const line of integrityReportLines2(audit)) console.warn(line);
|
|
11730
11917
|
let healed = 0;
|
|
11731
11918
|
const healedNames = [];
|
|
11919
|
+
let healSession = null;
|
|
11920
|
+
let healBackedUp = false;
|
|
11732
11921
|
for (const e of bad) {
|
|
11733
11922
|
const wf = toInstall.find((w) => w.name === e.name);
|
|
11734
11923
|
if (!wf) continue;
|
|
11735
11924
|
try {
|
|
11925
|
+
try {
|
|
11926
|
+
const skb = await Promise.resolve().then(() => (init_skillBackup(), skillBackup_exports));
|
|
11927
|
+
healSession ??= skb.newBackupSessionDir("skill-heal");
|
|
11928
|
+
const b2 = await skb.backupSkillDir(e.name, skillsBase, healSession);
|
|
11929
|
+
if (b2.ok) healBackedUp = true;
|
|
11930
|
+
else if (b2.code !== "ENOENT") {
|
|
11931
|
+
console.warn(
|
|
11932
|
+
` \u26A0 backup of '${e.name}' FAILED (${b2.message}) \u2014 healing anyway (engine integrity first)`
|
|
11933
|
+
);
|
|
11934
|
+
}
|
|
11935
|
+
} catch {
|
|
11936
|
+
}
|
|
11736
11937
|
await cp(join(workflowsDir, wf.relPath), join(skillsBase, wf.name), {
|
|
11737
11938
|
recursive: true,
|
|
11738
11939
|
force: true
|
|
@@ -11750,7 +11951,7 @@ ${b.failed.length} component(s) failed \u2014 see the notes in the tables above;
|
|
|
11750
11951
|
}
|
|
11751
11952
|
await recordSkillHashes2(healedNames, skillsBase);
|
|
11752
11953
|
console.warn(
|
|
11753
|
-
` \u2713 restored ${healed} harnessed workflow skill(s) from the bundle (packs keep their other skills; the colliding name belongs to the engine)`
|
|
11954
|
+
` \u2713 restored ${healed} harnessed workflow skill(s) from the bundle (packs keep their other skills; the colliding name belongs to the engine)${healBackedUp && healSession ? ` \u2014 replaced content backed up to ${healSession}` : ""}`
|
|
11754
11955
|
);
|
|
11755
11956
|
}
|
|
11756
11957
|
}
|