harnessed 4.40.0 → 4.41.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/bin/harnessed-inject-state.mjs +6 -0
- package/bin/harnessed-stop-hook.mjs +6 -0
- package/dist/cli.mjs +65 -2
- 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
|
@@ -9,6 +9,11 @@ import { existsSync as existsSync3, readFileSync as readFileSync4, statSync } fr
|
|
|
9
9
|
import { homedir } from 'node:os'
|
|
10
10
|
import { dirname, join as join4, resolve } from 'node:path'
|
|
11
11
|
|
|
12
|
+
// src/platform/ablation.ts
|
|
13
|
+
function isAblated(env = process.env) {
|
|
14
|
+
return env.HARNESSED_OFF === '1'
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
// src/checkpoint/injectCache.ts
|
|
13
18
|
import { createHash } from 'node:crypto'
|
|
14
19
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
@@ -467,6 +472,7 @@ function shouldEmitPc(root, repoRoot, sid, pc) {
|
|
|
467
472
|
}
|
|
468
473
|
}
|
|
469
474
|
function main() {
|
|
475
|
+
if (isAblated()) return
|
|
470
476
|
try {
|
|
471
477
|
const root = harnessedRoot()
|
|
472
478
|
if (process.argv.includes('--invalidate')) {
|
|
@@ -9,6 +9,11 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
|
9
9
|
import { homedir } from 'node:os'
|
|
10
10
|
import { join } from 'node:path'
|
|
11
11
|
|
|
12
|
+
// src/platform/ablation.ts
|
|
13
|
+
function isAblated(env = process.env) {
|
|
14
|
+
return env.HARNESSED_OFF === '1'
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
// src/checkpoint/modeBDetect.ts
|
|
13
18
|
var TAIL_WINDOW = 200
|
|
14
19
|
var INVOKE_RE = /<invoke name="/g
|
|
@@ -114,6 +119,7 @@ function readStdin() {
|
|
|
114
119
|
})
|
|
115
120
|
}
|
|
116
121
|
async function main() {
|
|
122
|
+
if (isAblated()) return
|
|
117
123
|
const raw = await readStdin()
|
|
118
124
|
let payload
|
|
119
125
|
try {
|
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.41.0",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -2186,6 +2186,17 @@ var init_backup = __esm({
|
|
|
2186
2186
|
}
|
|
2187
2187
|
});
|
|
2188
2188
|
|
|
2189
|
+
// src/platform/ablation.ts
|
|
2190
|
+
function isAblated(env = process.env) {
|
|
2191
|
+
return env.HARNESSED_OFF === "1";
|
|
2192
|
+
}
|
|
2193
|
+
var ABLATION_ENV;
|
|
2194
|
+
var init_ablation = __esm({
|
|
2195
|
+
"src/platform/ablation.ts"() {
|
|
2196
|
+
ABLATION_ENV = "HARNESSED_OFF";
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
|
|
2189
2200
|
// src/manifest/lib/path-guard.ts
|
|
2190
2201
|
function checkPathSafe(input) {
|
|
2191
2202
|
for (const re of PATH_TRAVERSAL_PATTERNS) {
|
|
@@ -6200,6 +6211,30 @@ var init_check_plugin_staleness = __esm({
|
|
|
6200
6211
|
}
|
|
6201
6212
|
});
|
|
6202
6213
|
|
|
6214
|
+
// src/cli/lib/check-ablation.ts
|
|
6215
|
+
var check_ablation_exports = {};
|
|
6216
|
+
__export(check_ablation_exports, {
|
|
6217
|
+
checkAblation: () => checkAblation
|
|
6218
|
+
});
|
|
6219
|
+
function checkAblation(env = process.env) {
|
|
6220
|
+
if (!isAblated(env)) {
|
|
6221
|
+
return { name: NAME5, status: "pass", message: "active" };
|
|
6222
|
+
}
|
|
6223
|
+
return {
|
|
6224
|
+
name: NAME5,
|
|
6225
|
+
status: "warn",
|
|
6226
|
+
message: `${ABLATION_ENV}=1 \u2014 harnessed's always-on surface is OFF: every first-party hook no-ops (per-turn injection, SessionStart invalidation, Stop recovery, doc-discipline gate, dashboard autospawn). Nothing else is disabled, and no files were moved.`,
|
|
6227
|
+
fix: `unset ${ABLATION_ENV} (or set it to anything other than 1) and start a new session`
|
|
6228
|
+
};
|
|
6229
|
+
}
|
|
6230
|
+
var NAME5;
|
|
6231
|
+
var init_check_ablation = __esm({
|
|
6232
|
+
"src/cli/lib/check-ablation.ts"() {
|
|
6233
|
+
init_ablation();
|
|
6234
|
+
NAME5 = "ablation switch";
|
|
6235
|
+
}
|
|
6236
|
+
});
|
|
6237
|
+
|
|
6203
6238
|
// src/cli/lib/doctor-registry.ts
|
|
6204
6239
|
var CHECKS;
|
|
6205
6240
|
var init_doctor_registry = __esm({
|
|
@@ -6261,7 +6296,11 @@ var init_doctor_registry = __esm({
|
|
|
6261
6296
|
// the four cc-plugin-marketplace components drift behind without any signal.
|
|
6262
6297
|
// The only comparison in the codebase between a genuinely DETECTED version and
|
|
6263
6298
|
// a recorded one — see the header for why the installer-state layer cannot do it.
|
|
6264
|
-
async () => (await Promise.resolve().then(() => (init_check_plugin_staleness(), check_plugin_staleness_exports))).checkPluginStaleness()
|
|
6299
|
+
async () => (await Promise.resolve().then(() => (init_check_plugin_staleness(), check_plugin_staleness_exports))).checkPluginStaleness(),
|
|
6300
|
+
// Phase 60 — HARNESSED_OFF left on (warn-only): the kill switch silences every
|
|
6301
|
+
// first-party hook, so a machine that forgot to unset it looks exactly like a
|
|
6302
|
+
// broken install. doctor is where that gets said out loud.
|
|
6303
|
+
async () => (await Promise.resolve().then(() => (init_check_ablation(), check_ablation_exports))).checkAblation()
|
|
6265
6304
|
];
|
|
6266
6305
|
}
|
|
6267
6306
|
});
|
|
@@ -7210,6 +7249,20 @@ async function updateInstalled(cwd, name, version, manifestSha1) {
|
|
|
7210
7249
|
};
|
|
7211
7250
|
await writeState(cwd, state);
|
|
7212
7251
|
}
|
|
7252
|
+
async function recordObservedInstall(cwd, name, version, manifestSha1) {
|
|
7253
|
+
try {
|
|
7254
|
+
const state = await readState(cwd);
|
|
7255
|
+
const prev = state.installed[name];
|
|
7256
|
+
if (prev && prev.version === version && prev.manifestSha1 === manifestSha1) return;
|
|
7257
|
+
state.installed[name] = {
|
|
7258
|
+
version,
|
|
7259
|
+
installedAt: prev?.installedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
7260
|
+
manifestSha1
|
|
7261
|
+
};
|
|
7262
|
+
await writeState(cwd, state);
|
|
7263
|
+
} catch {
|
|
7264
|
+
}
|
|
7265
|
+
}
|
|
7213
7266
|
var DEFAULT_STATE;
|
|
7214
7267
|
var init_state2 = __esm({
|
|
7215
7268
|
"src/installers/lib/state.ts"() {
|
|
@@ -7822,6 +7875,7 @@ var init_ccPluginMarketplace2 = __esm({
|
|
|
7822
7875
|
return { ok: false, phase: "preflight", error: e };
|
|
7823
7876
|
}
|
|
7824
7877
|
if (await isAlreadyInstalled(ctx)) {
|
|
7878
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
|
|
7825
7879
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
7826
7880
|
}
|
|
7827
7881
|
const parsed = parseCmd(install.cmd);
|
|
@@ -8109,6 +8163,7 @@ var init_gitCloneWithSetup2 = __esm({
|
|
|
8109
8163
|
return { ok: false, phase: "preflight", error: e };
|
|
8110
8164
|
}
|
|
8111
8165
|
if (await isAlreadyInstalled(ctx)) {
|
|
8166
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
|
|
8112
8167
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8113
8168
|
}
|
|
8114
8169
|
if (!/^[a-f0-9]{7,40}$/.test(install.git_ref)) {
|
|
@@ -8305,6 +8360,7 @@ var init_mcpHttpAdd2 = __esm({
|
|
|
8305
8360
|
return { ok: false, phase: "preflight", error: e };
|
|
8306
8361
|
}
|
|
8307
8362
|
if (await isAlreadyInstalled(ctx, { honorUpdateFlag: false })) {
|
|
8363
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8308
8364
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8309
8365
|
}
|
|
8310
8366
|
const name = ctx.manifest.metadata.name;
|
|
@@ -8409,6 +8465,7 @@ ${newEntry}
|
|
|
8409
8465
|
const r = await runHarnessArgs(bin, addArgs, spawnCwd);
|
|
8410
8466
|
if (r.exitCode !== 0) {
|
|
8411
8467
|
if (r.stderr.includes("already exists")) {
|
|
8468
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8412
8469
|
return { ok: true, alreadyInstalled: true, backupId: bk.backupId };
|
|
8413
8470
|
}
|
|
8414
8471
|
return {
|
|
@@ -8485,6 +8542,7 @@ var init_mcpStdioAdd2 = __esm({
|
|
|
8485
8542
|
return { ok: false, phase: "preflight", error: e };
|
|
8486
8543
|
}
|
|
8487
8544
|
if (await isAlreadyInstalled(ctx, { honorUpdateFlag: false })) {
|
|
8545
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8488
8546
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8489
8547
|
}
|
|
8490
8548
|
const name = ctx.manifest.metadata.name;
|
|
@@ -8555,6 +8613,7 @@ ${newEntry}
|
|
|
8555
8613
|
const r = await runHarnessArgs(bin, addArgs, spawnCwd);
|
|
8556
8614
|
if (r.exitCode !== 0) {
|
|
8557
8615
|
if (r.stderr.includes("already exists")) {
|
|
8616
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8558
8617
|
return { ok: true, alreadyInstalled: true, backupId: bk.backupId };
|
|
8559
8618
|
}
|
|
8560
8619
|
return {
|
|
@@ -8631,6 +8690,7 @@ var init_npmCli2 = __esm({
|
|
|
8631
8690
|
return { ok: false, phase: "preflight", error: e };
|
|
8632
8691
|
}
|
|
8633
8692
|
if (await isAlreadyInstalled(ctx)) {
|
|
8693
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8634
8694
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8635
8695
|
}
|
|
8636
8696
|
let level = detectLevel(install.cmd);
|
|
@@ -8750,6 +8810,7 @@ var init_npxSkillInstaller2 = __esm({
|
|
|
8750
8810
|
return { ok: false, phase: "preflight", error: e };
|
|
8751
8811
|
}
|
|
8752
8812
|
if (await isAlreadyInstalled(ctx)) {
|
|
8813
|
+
await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
|
|
8753
8814
|
return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
|
|
8754
8815
|
}
|
|
8755
8816
|
if (!/\B--copy\b/.test(install.cmd)) {
|
|
@@ -10652,6 +10713,7 @@ function registerBackupList(program2) {
|
|
|
10652
10713
|
|
|
10653
10714
|
// src/cli/checkDocs.ts
|
|
10654
10715
|
init_i18n();
|
|
10716
|
+
init_ablation();
|
|
10655
10717
|
var DEFAULT_MAX_STATE_LINES = 100;
|
|
10656
10718
|
var KEY_DECISIONS_SECTION_RE = /^##\s+.*关键决议\s*ship\s*总结/gm;
|
|
10657
10719
|
var KEY_DECISIONS_SECTION_LIMIT = 1;
|
|
@@ -10771,6 +10833,7 @@ function registerCheckDocs(program2) {
|
|
|
10771
10833
|
"Documentation-discipline gate over .planning/ (STATE digest limit + archive cadence + ROADMAP pointer-not-narrative). Exits 2 on a blocking violation, 1 on advisory-only."
|
|
10772
10834
|
).option("--json", "output JSON instead of human-readable").option("--cwd <dir>", "repo root holding .planning/ (default: current directory)").option("--max-state-lines <n>", `STATE.md digest ceiling (default ${DEFAULT_MAX_STATE_LINES})`).option("--hook", "PreToolUse mode: read the tool payload on stdin, gate only git commit").action(
|
|
10773
10835
|
async (opts) => {
|
|
10836
|
+
if (opts.hook && isAblated()) process.exit(0);
|
|
10774
10837
|
if (opts.hook && !shouldGateForHookPayload(await readStdin())) process.exit(0);
|
|
10775
10838
|
const parsed = Number(opts.maxStateLines);
|
|
10776
10839
|
const violations = collectDocViolations({
|