harnessed 4.39.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.
@@ -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.39.0",
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) {
@@ -5947,14 +5958,30 @@ async function pathExists(p7) {
5947
5958
  return false;
5948
5959
  }
5949
5960
  }
5950
- async function checkEcc() {
5961
+ function codexPluginPresent() {
5962
+ try {
5963
+ const r = spawnSync(process.platform === "win32" ? "codex.cmd" : "codex", ["plugin", "list"], {
5964
+ encoding: "utf8",
5965
+ timeout: 1e4,
5966
+ windowsHide: true
5967
+ });
5968
+ if (r.error || r.status !== 0) return false;
5969
+ return /\becc\b/.test(`${r.stdout ?? ""}`);
5970
+ } catch {
5971
+ return false;
5972
+ }
5973
+ }
5974
+ async function checkEcc(deps) {
5975
+ const probeCodexPlugin = deps?.codexPluginPresent ?? codexPluginPresent;
5951
5976
  const cdt = await probeChromeDevtools();
5952
5977
  const ccInstalled = cdt.ecc;
5953
5978
  const codexHome = join(homedir(), ".codex");
5954
5979
  const codexPresent = await pathExists(join(codexHome, "config.toml"));
5955
- const codexInstalled = codexPresent && await pathExists(join(codexHome, ".cache", "ecc", ".git"));
5980
+ const codexLegacy = codexPresent && await pathExists(join(codexHome, ".cache", "ecc", ".git"));
5981
+ const codexNative = codexPresent && !codexLegacy && probeCodexPlugin();
5982
+ const codexInstalled = codexLegacy || codexNative;
5956
5983
  const ccPart = ccInstalled ? "CC: installed (plugin ecc@ecc)" : "CC: not installed";
5957
- const codexPart = codexPresent ? codexInstalled ? "codex: installed (~/.codex/.cache/ecc sync clone)" : "codex: not installed" : "codex: not present (no ~/.codex/config.toml)";
5984
+ const codexPart = codexPresent ? codexInstalled ? codexNative ? "codex: installed (native plugin ecc@ecc)" : "codex: installed (legacy ~/.codex/.cache/ecc sync clone \u2014 upstream deprecated it in 2.2; migrate with `node scripts/ecc.js uninstall --legacy-codex-sync` then `codex plugin marketplace add affaan-m/ECC && codex plugin add ecc@ecc`)" : "codex: not installed" : "codex: not present (no ~/.codex/config.toml)";
5958
5985
  if (ccInstalled) {
5959
5986
  const leftovers = [];
5960
5987
  const fixes = [];
@@ -6052,6 +6079,162 @@ var init_check_inject_invalidate = __esm({
6052
6079
  }
6053
6080
  });
6054
6081
 
6082
+ // src/cli/lib/check-plugin-staleness.ts
6083
+ var check_plugin_staleness_exports = {};
6084
+ __export(check_plugin_staleness_exports, {
6085
+ checkPluginStaleness: () => checkPluginStaleness
6086
+ });
6087
+ function defaultDeps3() {
6088
+ return {
6089
+ assetsRoot: getAssetsRoot(),
6090
+ registryPath: getPluginsRegistry(),
6091
+ readText: (p7) => {
6092
+ try {
6093
+ return readFileSync(p7, "utf8");
6094
+ } catch {
6095
+ return null;
6096
+ }
6097
+ },
6098
+ listDir: (p7) => {
6099
+ try {
6100
+ return readdirSync(p7);
6101
+ } catch {
6102
+ return null;
6103
+ }
6104
+ },
6105
+ isDir: (p7) => {
6106
+ try {
6107
+ return statSync(p7).isDirectory();
6108
+ } catch {
6109
+ return false;
6110
+ }
6111
+ }
6112
+ };
6113
+ }
6114
+ function collectPluginManifests(deps) {
6115
+ const out = [];
6116
+ const root = join(deps.assetsRoot, "manifests");
6117
+ const walk = (dir) => {
6118
+ const entries = deps.listDir(dir);
6119
+ if (entries === null) return;
6120
+ for (const entry of entries) {
6121
+ const full = join(dir, entry);
6122
+ if (deps.isDir(full)) {
6123
+ walk(full);
6124
+ continue;
6125
+ }
6126
+ if (!entry.endsWith(".yaml") || entry.endsWith(".zh-Hans.yaml")) continue;
6127
+ const raw = deps.readText(full);
6128
+ if (raw === null) continue;
6129
+ let doc;
6130
+ try {
6131
+ doc = parse(raw);
6132
+ } catch {
6133
+ continue;
6134
+ }
6135
+ const d = doc;
6136
+ if (d.spec?.install?.method !== "cc-plugin-marketplace") continue;
6137
+ const name = d.metadata?.name;
6138
+ const recorded = d.spec?.upstream_health?.last_known_good_version;
6139
+ if (typeof name !== "string" || typeof recorded !== "string") continue;
6140
+ out.push({ name, recorded });
6141
+ }
6142
+ };
6143
+ walk(root);
6144
+ return out;
6145
+ }
6146
+ function readInstalledVersions(deps, registryPath) {
6147
+ const raw = deps.readText(registryPath);
6148
+ if (raw === null) return null;
6149
+ let parsed;
6150
+ try {
6151
+ parsed = JSON.parse(raw);
6152
+ } catch {
6153
+ return null;
6154
+ }
6155
+ const plugins = parsed.plugins;
6156
+ if (!plugins || typeof plugins !== "object") return null;
6157
+ const map = /* @__PURE__ */ new Map();
6158
+ for (const [key, value] of Object.entries(plugins)) {
6159
+ const pluginName = key.split("@")[0];
6160
+ if (!pluginName || !Array.isArray(value)) continue;
6161
+ for (const entry of value) {
6162
+ const v = entry?.version;
6163
+ if (typeof v === "string" && v.length > 0) {
6164
+ map.set(pluginName, v);
6165
+ break;
6166
+ }
6167
+ }
6168
+ }
6169
+ return map;
6170
+ }
6171
+ function checkPluginStaleness(overrides) {
6172
+ const deps = { ...defaultDeps3(), ...overrides };
6173
+ if (deps.registryPath === null) {
6174
+ return { name: NAME4, status: "pass", message: "no plugin registry on this harness" };
6175
+ }
6176
+ const installed = readInstalledVersions(deps, deps.registryPath);
6177
+ if (installed === null) {
6178
+ return { name: NAME4, status: "pass", message: "plugin registry unreadable \u2014 skipped" };
6179
+ }
6180
+ const manifests = collectPluginManifests(deps);
6181
+ const behind = [];
6182
+ let compared = 0;
6183
+ for (const m of manifests) {
6184
+ const have = installed.get(m.name);
6185
+ if (have === void 0) continue;
6186
+ compared += 1;
6187
+ if (compareVersions(have, m.recorded) === "behind") {
6188
+ behind.push(`${m.name} ${have} \u2192 ${m.recorded}`);
6189
+ }
6190
+ }
6191
+ if (compared === 0) {
6192
+ return { name: NAME4, status: "pass", message: "no marketplace plugins installed" };
6193
+ }
6194
+ if (behind.length === 0) {
6195
+ return { name: NAME4, status: "pass", message: `${compared} marketplace plugin(s) current` };
6196
+ }
6197
+ return {
6198
+ name: NAME4,
6199
+ status: "warn",
6200
+ message: `${behind.length}/${compared} marketplace plugin(s) behind the version harnessed verified: ${behind.join(", ")} \u2014 \`claude plugin install\` pins a version at install time and never re-resolves`,
6201
+ fix: `claude plugin update ${behind.map((b) => b.split(" ")[0]).join(" && claude plugin update ")}`
6202
+ };
6203
+ }
6204
+ var NAME4;
6205
+ var init_check_plugin_staleness = __esm({
6206
+ "src/cli/lib/check-plugin-staleness.ts"() {
6207
+ init_assetsRoot();
6208
+ init_platform();
6209
+ init_version_check();
6210
+ NAME4 = "plugin install freshness";
6211
+ }
6212
+ });
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
+
6055
6238
  // src/cli/lib/doctor-registry.ts
6056
6239
  var CHECKS;
6057
6240
  var init_doctor_registry = __esm({
@@ -6107,7 +6290,17 @@ var init_doctor_registry = __esm({
6107
6290
  // 4.38.0 — half-installed per-turn injection (warn-only): perturn-inject
6108
6291
  // without perturn-inject-invalidate keeps skipping <project-context> after a
6109
6292
  // compact/clear has already dropped the copy it is skipping on behalf of.
6110
- async () => (await Promise.resolve().then(() => (init_check_inject_invalidate(), check_inject_invalidate_exports))).checkInjectInvalidate()
6293
+ async () => (await Promise.resolve().then(() => (init_check_inject_invalidate(), check_inject_invalidate_exports))).checkInjectInvalidate(),
6294
+ // Phase 56 — silently stale marketplace plugins (warn-only): `claude plugin
6295
+ // install` pins a version into a versioned cache dir and never re-resolves, so
6296
+ // the four cc-plugin-marketplace components drift behind without any signal.
6297
+ // The only comparison in the codebase between a genuinely DETECTED version and
6298
+ // a recorded one — see the header for why the installer-state layer cannot do it.
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()
6111
6304
  ];
6112
6305
  }
6113
6306
  });
@@ -7056,6 +7249,20 @@ async function updateInstalled(cwd, name, version, manifestSha1) {
7056
7249
  };
7057
7250
  await writeState(cwd, state);
7058
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
+ }
7059
7266
  var DEFAULT_STATE;
7060
7267
  var init_state2 = __esm({
7061
7268
  "src/installers/lib/state.ts"() {
@@ -7668,6 +7875,7 @@ var init_ccPluginMarketplace2 = __esm({
7668
7875
  return { ok: false, phase: "preflight", error: e };
7669
7876
  }
7670
7877
  if (await isAlreadyInstalled(ctx)) {
7878
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
7671
7879
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
7672
7880
  }
7673
7881
  const parsed = parseCmd(install.cmd);
@@ -7955,6 +8163,7 @@ var init_gitCloneWithSetup2 = __esm({
7955
8163
  return { ok: false, phase: "preflight", error: e };
7956
8164
  }
7957
8165
  if (await isAlreadyInstalled(ctx)) {
8166
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.git_ref, "");
7958
8167
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
7959
8168
  }
7960
8169
  if (!/^[a-f0-9]{7,40}$/.test(install.git_ref)) {
@@ -8151,6 +8360,7 @@ var init_mcpHttpAdd2 = __esm({
8151
8360
  return { ok: false, phase: "preflight", error: e };
8152
8361
  }
8153
8362
  if (await isAlreadyInstalled(ctx, { honorUpdateFlag: false })) {
8363
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
8154
8364
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
8155
8365
  }
8156
8366
  const name = ctx.manifest.metadata.name;
@@ -8255,6 +8465,7 @@ ${newEntry}
8255
8465
  const r = await runHarnessArgs(bin, addArgs, spawnCwd);
8256
8466
  if (r.exitCode !== 0) {
8257
8467
  if (r.stderr.includes("already exists")) {
8468
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
8258
8469
  return { ok: true, alreadyInstalled: true, backupId: bk.backupId };
8259
8470
  }
8260
8471
  return {
@@ -8331,6 +8542,7 @@ var init_mcpStdioAdd2 = __esm({
8331
8542
  return { ok: false, phase: "preflight", error: e };
8332
8543
  }
8333
8544
  if (await isAlreadyInstalled(ctx, { honorUpdateFlag: false })) {
8545
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
8334
8546
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
8335
8547
  }
8336
8548
  const name = ctx.manifest.metadata.name;
@@ -8401,6 +8613,7 @@ ${newEntry}
8401
8613
  const r = await runHarnessArgs(bin, addArgs, spawnCwd);
8402
8614
  if (r.exitCode !== 0) {
8403
8615
  if (r.stderr.includes("already exists")) {
8616
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
8404
8617
  return { ok: true, alreadyInstalled: true, backupId: bk.backupId };
8405
8618
  }
8406
8619
  return {
@@ -8477,6 +8690,7 @@ var init_npmCli2 = __esm({
8477
8690
  return { ok: false, phase: "preflight", error: e };
8478
8691
  }
8479
8692
  if (await isAlreadyInstalled(ctx)) {
8693
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
8480
8694
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
8481
8695
  }
8482
8696
  let level = detectLevel(install.cmd);
@@ -8596,6 +8810,7 @@ var init_npxSkillInstaller2 = __esm({
8596
8810
  return { ok: false, phase: "preflight", error: e };
8597
8811
  }
8598
8812
  if (await isAlreadyInstalled(ctx)) {
8813
+ await recordObservedInstall(ctx.cwd, ctx.manifest.metadata.name, install.npm_version, "");
8599
8814
  return { ok: true, alreadyInstalled: true, backupId: "noop-idempotent" };
8600
8815
  }
8601
8816
  if (!/\B--copy\b/.test(install.cmd)) {
@@ -9174,7 +9389,7 @@ var release_preflight_exports = {};
9174
9389
  __export(release_preflight_exports, {
9175
9390
  anyFailed: () => anyFailed,
9176
9391
  collectPreflight: () => collectPreflight,
9177
- defaultDeps: () => defaultDeps3
9392
+ defaultDeps: () => defaultDeps4
9178
9393
  });
9179
9394
  function unreleasedSection(changelog) {
9180
9395
  const start = changelog.indexOf("## [Unreleased]");
@@ -9229,7 +9444,7 @@ function collectPreflight(deps) {
9229
9444
  function anyFailed(checks) {
9230
9445
  return checks.some((c) => c.status === "fail");
9231
9446
  }
9232
- function defaultDeps3(cwd) {
9447
+ function defaultDeps4(cwd) {
9233
9448
  let changelog = "";
9234
9449
  let version = "";
9235
9450
  try {
@@ -10498,6 +10713,7 @@ function registerBackupList(program2) {
10498
10713
 
10499
10714
  // src/cli/checkDocs.ts
10500
10715
  init_i18n();
10716
+ init_ablation();
10501
10717
  var DEFAULT_MAX_STATE_LINES = 100;
10502
10718
  var KEY_DECISIONS_SECTION_RE = /^##\s+.*关键决议\s*ship\s*总结/gm;
10503
10719
  var KEY_DECISIONS_SECTION_LIMIT = 1;
@@ -10617,6 +10833,7 @@ function registerCheckDocs(program2) {
10617
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."
10618
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(
10619
10835
  async (opts) => {
10836
+ if (opts.hook && isAblated()) process.exit(0);
10620
10837
  if (opts.hook && !shouldGateForHookPayload(await readStdin())) process.exit(0);
10621
10838
  const parsed = Number(opts.maxStateLines);
10622
10839
  const violations = collectDocViolations({
@@ -10674,7 +10891,7 @@ init_i18n();
10674
10891
  init_doctor_registry();
10675
10892
  function registerDoctor(program2) {
10676
10893
  program2.command("doctor").description(
10677
- "Preflight checks (Node / MCP scope / jq / Win bash / origin URL / gstack prefix / deprecations / token budget / Agent Teams / planning-with-files / mattpocock-skills / MCP availability / ECC)"
10894
+ "Preflight checks (Node / MCP scope / jq / Win bash / origin URL / gstack prefix / deprecations / token budget / Agent Teams / planning-with-files / mattpocock-skills / MCP availability / ECC / plugin freshness)"
10678
10895
  ).option("--json", "output JSON instead of human-readable").action(async (opts) => {
10679
10896
  const settled = await Promise.allSettled(CHECKS.map((c) => c()));
10680
10897
  const results = settled.map(
@@ -13479,8 +13696,8 @@ function registerReleasePreflight(program2) {
13479
13696
  program2.command("release-preflight").description(
13480
13697
  "Read-only release-readiness gate (CHANGELOG / version / git-clean / tag). Exits 1 if not ready."
13481
13698
  ).action(async () => {
13482
- const { collectPreflight: collectPreflight2, anyFailed: anyFailed2, defaultDeps: defaultDeps4 } = await Promise.resolve().then(() => (init_release_preflight(), release_preflight_exports));
13483
- const checks = collectPreflight2(defaultDeps4(process.cwd()));
13699
+ const { collectPreflight: collectPreflight2, anyFailed: anyFailed2, defaultDeps: defaultDeps5 } = await Promise.resolve().then(() => (init_release_preflight(), release_preflight_exports));
13700
+ const checks = collectPreflight2(defaultDeps5(process.cwd()));
13484
13701
  console.log("\n release preflight (read-only \u2014 nothing is pushed/published):\n");
13485
13702
  for (const c of checks) {
13486
13703
  const mark = c.status === "pass" ? "\u2713" : c.status === "warn" ? "\u26A0" : "\u2717";
@@ -14293,7 +14510,7 @@ var V3_4_3_SIGNATURE_MASTER_RX = /\*\*Preferred path\*\*[\s\S]*dispatch to the p
14293
14510
  function shouldOverwriteFile(content) {
14294
14511
  return HARNESSED_MARKER_RX2.test(content) || V3_4_3_SIGNATURE_SUB_RX.test(content) || V3_4_3_SIGNATURE_MASTER_RX.test(content);
14295
14512
  }
14296
- async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync24 = (p7) => readFileSync(p7, "utf8")) {
14513
+ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabilities, installedPlugins, installedUserSkills, writer, fileExists2 = existsSync, readFileSync25 = (p7) => readFileSync(p7, "utf8")) {
14297
14514
  const results = [];
14298
14515
  const aggregatedWarnings = /* @__PURE__ */ new Set();
14299
14516
  for (const name of slashNames) {
@@ -14312,7 +14529,7 @@ async function writeAllCommands(slashNames, commandsDir, rolePrompts, capabiliti
14312
14529
  if (fileExists2(path)) {
14313
14530
  let existing = "";
14314
14531
  try {
14315
- existing = readFileSync24(path);
14532
+ existing = readFileSync25(path);
14316
14533
  } catch {
14317
14534
  existing = "";
14318
14535
  }