@dzhechkov/harness-cli 0.3.238 → 0.3.240

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzhechkov/harness-cli",
3
- "version": "0.3.238",
3
+ "version": "0.3.240",
4
4
  "description": "The dz CLI — install AI skills for Claude Code, Codex, OpenCode, Hermes, OpenClaude, GitHub Copilot. 35 commands, 13 presets, 6 platform targets.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -57,7 +57,7 @@
57
57
  "@dzhechkov/skills-reverse-engineering": "^0.1.0",
58
58
  "@dzhechkov/skills-presentation-storyteller": "^0.1.0",
59
59
  "@dzhechkov/skills-website-cloner": "^0.1.0",
60
- "@dzhechkov/harness-core": "0.3.129"
60
+ "@dzhechkov/harness-core": "0.3.131"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "^25.6.0",
package/sbom.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "hashes": [
26
26
  {
27
27
  "alg": "SHA-256",
28
- "content": "ef6603652143fc1517c81506dad9d5e7b79e5d5138aad9f6281ad77492d58b71"
28
+ "content": "1356d1ebf22352d0ab57ebe17fb91bb8c4df17da8b6968863a92b92402921bb7"
29
29
  }
30
30
  ]
31
31
  },
@@ -105,7 +105,7 @@
105
105
  "hashes": [
106
106
  {
107
107
  "alg": "SHA-256",
108
- "content": "8f8807920c7ddd901361eb5a602df9c85fa69726e47535a146937038eab6b281"
108
+ "content": "eb431a9aaed2c853b19a797cd49668bed9fe1e700880a8d18d9a1a4cfe243f55"
109
109
  }
110
110
  ]
111
111
  },
@@ -115,7 +115,7 @@
115
115
  "hashes": [
116
116
  {
117
117
  "alg": "SHA-256",
118
- "content": "5f5fbcc7c040a272f6af992ef1f9c39482b941d74dbcadec9f3d9008babcb08a"
118
+ "content": "9a46ece09ee1ac72ca3d7715ae86c1b5dc3747b18287c6f558a3c5d6569de7da"
119
119
  }
120
120
  ]
121
121
  },
@@ -125,7 +125,7 @@
125
125
  "hashes": [
126
126
  {
127
127
  "alg": "SHA-256",
128
- "content": "420d1178a513e54f315095a17e9c5722543ca6cbdbebd9a674d4d50ef61b8aa0"
128
+ "content": "02dcf19b1e616487f3840482e9af6f9028749b5a8c9d8da143126be5d7ee5779"
129
129
  }
130
130
  ]
131
131
  },
@@ -185,7 +185,7 @@
185
185
  "hashes": [
186
186
  {
187
187
  "alg": "SHA-256",
188
- "content": "8fbaf10d29b5733cf9445e1ef5804a3e124f733c3390a99937d2d8dc3b4cf02a"
188
+ "content": "b729864fd3fb9fc4cf2fcab96c6aa36f13ed181f3aa2bb37c6b3ca0c893afd76"
189
189
  }
190
190
  ]
191
191
  },
@@ -205,7 +205,7 @@
205
205
  "hashes": [
206
206
  {
207
207
  "alg": "SHA-256",
208
- "content": "131f23a50187e1be19875d4ccd76d8c354b1fbb8d193c03e73fda16ff64f51dc"
208
+ "content": "8477517b028f8258d5f11a2197167210de2db0acefa901f0f393579dc14bd409"
209
209
  }
210
210
  ]
211
211
  },
package/src/cli.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  import { chmodSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmdirSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';
8
8
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
- import { execSync } from 'node:child_process';
10
+ import { execSync, spawn } from 'node:child_process';
11
11
  import { homedir, tmpdir } from 'node:os';
12
12
  import { createRequire } from 'node:module';
13
13
 
@@ -192,6 +192,12 @@ import {
192
192
  classifyDelivery,
193
193
  isUsablePlaneResult,
194
194
  renderDeliveryReview,
195
+ scanSkillsLayout,
196
+ parseInitFacts,
197
+ verifyRegistration,
198
+ findNonRegistrableSkillDirs,
199
+ registrationExitCode,
200
+ renderRegistrationReport,
195
201
  } from '@dzhechkov/harness-core';
196
202
  import type { Family, ModelRung, Candidate as BtoCandidate, DimScores } from '@dzhechkov/harness-core';
197
203
  import type { SetupSpec } from '@dzhechkov/harness-core';
@@ -222,6 +228,7 @@ Usage:
222
228
  dz release [--filter <name>] [--tag] [--publish] [--json] [--dry-run] [--no-issue] (VERIFIED release: 4 HARD gates in FRONT of dz publish — full package test suites, audit >=high, node --check of every dist/bin file, bin smoke-boot via "node <bin> --help" — any red gate STOPS the release (exit 1) + best-effort gh issue; all green ⇒ re-sign reminder, then prints the ready dz publish command (or chains with --publish); never duplicates publish's own gates)
223
229
  dz parity [--target <name>] [--json] (the honest feature×target map, COMPUTED from the capability model — which harness feature is full / manual / absent on each of the ${TARGET_NAMES.length} targets, and via which form)
224
230
  dz delivery-check --slug <slug> [--context-only] [--findings <f.json>] [--strict] [--author <model>] [--json] (portable Step-10 Delivery Gate: prints the 4-plane review brief + artifact probes; --findings classifies a fed-back review into a fail-closed ready|blocked hand-off and writes features/<slug>/10_delivery_review.md; --strict exits 1 on blocked)
231
+ dz skills-verify [--dir <project>] [--expect a,b] [--static] [--strict] [--json] (does .claude/skills/ actually REGISTER? --static = instant layout scan for CI; default reads the authoritative system/init listing from a real session. exit 0 pass / 1 fail / 2 inconclusive — never a false pass)
225
232
  dz setup --target <name> [--preset <name>] [--select id,id,...] [--skills-dir <dir>] [--project <dir>] [--memory agentdb] [--no-memory] [--no-hooks] [--install-driver] [--force] [--enrich]
226
233
  dz teach "<pattern>" [--reward <0-1>] [--domain <name>] [--type rule|success-pattern|lesson-learned] [--project <dir>] [--no-mirror] (--project pins the learned store to <dir>/.dz, not the cwd — pin to a canonical brain)
227
234
  dz teach --from-json <file> [--project <dir>] [--no-mirror] (bulk-import a 'dz recall --all --json' export — share a learned store across machines)
@@ -4802,6 +4809,21 @@ function gatherGuardFacts(op: string, root: string, text: string | undefined, st
4802
4809
  }
4803
4810
  facts['readmeFirst'] = [...perPack.entries()].map(([name, e]) => ({ name: '@dzhechkov/' + name, versionBumped: e.pkgJson, readmeChanged: e.readme }));
4804
4811
  } catch { /* not a git repo — rule skips */ }
4812
+
4813
+ // skills-registrable: every skill dir in a skill pack must carry a depth-1 SKILL.md, or it ships
4814
+ // registering nowhere (the health-advisor 1.2.0 class). Pure-toolkit packages yield nothing.
4815
+ try {
4816
+ const packsDir = join(root, 'packages', '@dzhechkov');
4817
+ const packs = readdirSync(packsDir, { withFileTypes: true })
4818
+ .filter((e) => e.isDirectory())
4819
+ .map((e) => e.name);
4820
+ const skillPacks: { name: string; nonRegistrable: string[] }[] = [];
4821
+ for (const pack of packs) {
4822
+ const nonRegistrable = findNonRegistrableSkillDirs(join(packsDir, pack));
4823
+ if (nonRegistrable.length > 0) skillPacks.push({ name: '@dzhechkov/' + pack, nonRegistrable });
4824
+ }
4825
+ facts['skillPacks'] = skillPacks;
4826
+ } catch { /* unreadable packages dir — rule reports nothing rather than inventing a violation */ }
4805
4827
  }
4806
4828
  if (op === 'consolidate') {
4807
4829
  try { facts['drift'] = sweepSkillDrift(root, { scope: 'packages', allowlist: readDriftAllowlist(root) }).drifted.map((d) => d.name); } catch { /* skip */ }
@@ -5552,6 +5574,190 @@ function nameFor(t: { file: string; name?: string }, outcome: 'pass' | 'fail' |
5552
5574
  * --author <model> cosmetic: the reviewer to dispatch, printed alongside the brief
5553
5575
  * --json machine contract { planesChecked, planesSkipped, findings, handoff, artifact }
5554
5576
  */
5577
+ /**
5578
+ * Env vars an INHERITED Claude session leaks into a child. Left in place, the probe can silently
5579
+ * read the parent's project instead of the target — the exact confound that made a hand-rolled
5580
+ * 2026-07-23 probe untrustworthy until controls were added (feature skills-verify, ADR-001).
5581
+ */
5582
+ const PROBE_SCRUB_ENV = [
5583
+ 'CLAUDE_CODE_CHILD_SESSION',
5584
+ 'CLAUDE_CODE_SESSION_ID',
5585
+ 'CLAUDECODE',
5586
+ 'CLAUDE_CODE_ENTRYPOINT',
5587
+ 'CLAUDE_CODE_EXECPATH',
5588
+ 'CLAUDE_PLUGIN_DATA',
5589
+ 'AI_AGENT',
5590
+ ];
5591
+
5592
+ /**
5593
+ * Start a real Claude session in `projectDir` and capture its stream until the `system/init` event
5594
+ * lands, then kill it — the model never answers, so the probe costs ~no tokens. Never throws:
5595
+ * every failure becomes an `error` string, which the pure classifier turns into `inconclusive`.
5596
+ */
5597
+ function probeInitStream(projectDir: string, timeoutMs: number): Promise<{ stream: string; error: string | null }> {
5598
+ return new Promise((resolveProbe) => {
5599
+ const env: NodeJS.ProcessEnv = { ...process.env };
5600
+ for (const key of PROBE_SCRUB_ENV) delete env[key];
5601
+ env.CLAUDE_PROJECT_DIR = projectDir;
5602
+
5603
+ let out = '';
5604
+ let err = '';
5605
+ let settled = false;
5606
+ let child: ReturnType<typeof spawn>;
5607
+
5608
+ const finish = (error: string | null): void => {
5609
+ if (settled) return;
5610
+ settled = true;
5611
+ clearTimeout(timer);
5612
+ try {
5613
+ child?.kill('SIGTERM');
5614
+ } catch {
5615
+ /* the child may already be gone */
5616
+ }
5617
+ resolveProbe({ stream: out, error });
5618
+ };
5619
+
5620
+ const timer = setTimeout(
5621
+ () => finish(`no init event within ${Math.round(timeoutMs / 1000)}s (is \`claude\` logged in?)`),
5622
+ timeoutMs,
5623
+ );
5624
+
5625
+ try {
5626
+ // NOT `--bare`: that mode skips plugin credentials and fails with "Not logged in".
5627
+ child = spawn('claude', ['-p', 'ok', '--output-format', 'stream-json', '--verbose'], {
5628
+ cwd: projectDir,
5629
+ env,
5630
+ stdio: ['ignore', 'pipe', 'pipe'],
5631
+ });
5632
+ } catch (error) {
5633
+ finish(`cannot run \`claude\`: ${error instanceof Error ? error.message : String(error)}`);
5634
+ return;
5635
+ }
5636
+
5637
+ child.stdout?.on('data', (chunk: Buffer) => {
5638
+ out += chunk.toString();
5639
+ // Reuse the pure parser so a partially-flushed line simply waits for more data.
5640
+ if (parseInitFacts(out)) finish(null);
5641
+ });
5642
+ child.stderr?.on('data', (chunk: Buffer) => {
5643
+ err += chunk.toString();
5644
+ });
5645
+ child.on('error', (error: Error) => finish(`cannot run \`claude\`: ${error.message}`));
5646
+ child.on('close', (code) => {
5647
+ if (parseInitFacts(out)) finish(null);
5648
+ else finish(err.trim() || `\`claude\` exited ${code} without an init event`);
5649
+ });
5650
+ });
5651
+ }
5652
+
5653
+ /**
5654
+ * `dz skills-verify` — does this project's `.claude/skills/` actually REGISTER? (feature
5655
+ * skills-verify, ADR-001.) L1 static scan is instant and CI-safe; the live layer reads the
5656
+ * authoritative `system/init` listing. Fail-closed: unobservable ⇒ inconclusive, never pass.
5657
+ */
5658
+ async function cmdSkillsVerify(
5659
+ options: Map<string, string>,
5660
+ flags: Set<string>,
5661
+ cwd: string,
5662
+ write: Write,
5663
+ ): Promise<number> {
5664
+ const json = flags.has('json');
5665
+ if (flags.has('help')) {
5666
+ write('dz skills-verify [--dir <project>] [--expect a,b] [--static] [--strict] [--timeout <s>] [--json]');
5667
+ write(' Verifies that a project\'s .claude/skills/ actually register in Claude Code.');
5668
+ write(' --static layout scan only (no Claude session, CI-safe): flags dirs that can never register');
5669
+ write(' default also starts a real session and reads the authoritative system/init listing');
5670
+ write(' exit: 0 pass · 1 fail · 2 inconclusive (--strict makes inconclusive exit 1)');
5671
+ return 0;
5672
+ }
5673
+
5674
+ const allowedFlags = new Set(['json', 'help', 'static', 'strict']);
5675
+ const allowedOptions = new Set(['dir', 'expect', 'timeout']);
5676
+ const usage = ' allowed: --dir <project>, --expect a,b, --timeout <s>, --static, --strict, --json';
5677
+ if (options.has('_positional_0')) {
5678
+ const message = `unexpected argument "${options.get('_positional_0')}"`;
5679
+ write(json ? JSON.stringify({ error: message, exitCode: 1 }) : `dz skills-verify: ${message}\n${usage}`);
5680
+ return 1;
5681
+ }
5682
+ for (const flag of flags) {
5683
+ if (!allowedFlags.has(flag)) {
5684
+ write(json ? JSON.stringify({ error: `unknown option --${flag}`, exitCode: 1 }) : `dz skills-verify: unknown option --${flag}\n${usage}`);
5685
+ return 1;
5686
+ }
5687
+ }
5688
+ for (const key of options.keys()) {
5689
+ if (key.startsWith('_positional_')) continue;
5690
+ if (!allowedOptions.has(key)) {
5691
+ write(json ? JSON.stringify({ error: `unknown option --${key}`, exitCode: 1 }) : `dz skills-verify: unknown option --${key}\n${usage}`);
5692
+ return 1;
5693
+ }
5694
+ }
5695
+
5696
+ const projectDir = resolve(cwd, options.get('dir') ?? '.');
5697
+ const scan = scanSkillsLayout(projectDir);
5698
+
5699
+ const expected = options.has('expect')
5700
+ ? (options.get('expect') ?? '')
5701
+ .split(',')
5702
+ .map((s) => s.trim())
5703
+ .filter(Boolean)
5704
+ : scan.registrable;
5705
+
5706
+ // ── L1 only: deterministic, no session, safe for CI ──
5707
+ if (flags.has('static')) {
5708
+ const exitCode = scan.findings.length > 0 ? 1 : 0;
5709
+ if (json) {
5710
+ write(JSON.stringify({ mode: 'static', ...scan, expected, exitCode }, null, 2));
5711
+ } else {
5712
+ write(`dz skills-verify (static): ${scan.registrable.length} registrable skill dir(s) under ${scan.skillsRoot}`);
5713
+ if (!scan.exists) write(' no .claude/skills/ directory here');
5714
+ for (const f of scan.findings) write(` [${f.kind}] ${f.detail}`);
5715
+ write(scan.findings.length ? ` ${scan.findings.length} layout problem(s) — these can never register` : ' no layout problems found');
5716
+ write(' (static is a PROXY — run without --static to read the real registration listing)');
5717
+ }
5718
+ return exitCode;
5719
+ }
5720
+
5721
+ // ── L2: the authoritative listing ──
5722
+ const timeoutSec = Number(options.get('timeout') ?? '180');
5723
+ const timeoutMs = Number.isFinite(timeoutSec) && timeoutSec > 0 ? timeoutSec * 1000 : 180_000;
5724
+ if (!json) write(`dz skills-verify: starting a session in ${projectDir} to read the real registration listing…`);
5725
+
5726
+ const { stream, error } = await probeInitStream(projectDir, timeoutMs);
5727
+
5728
+ // `init.skills` carries names, not provenance: a USER-level skill of the same name would satisfy
5729
+ // the expectation while the project's own copy stays broken. Collect the collisions so the
5730
+ // classifier can refuse to attribute registration to this project (Codex QE #2).
5731
+ const userSkillsDir = join(homedir(), '.claude', 'skills');
5732
+ const ambiguous = expected.filter((name) => existsSync(join(userSkillsDir, name, 'SKILL.md')));
5733
+
5734
+ // realpath so a symlinked project still matches its canonical cwd (Codex QE #6).
5735
+ const canonical = (p: string): string => {
5736
+ try {
5737
+ return realpathSync(p);
5738
+ } catch {
5739
+ return resolve(p);
5740
+ }
5741
+ };
5742
+
5743
+ const result = verifyRegistration(
5744
+ {
5745
+ projectDir,
5746
+ scan,
5747
+ probe: error === null ? { ok: true, stream } : { ok: false, error },
5748
+ // The provenance check RAN (that is what `checked: true` asserts) — see `ambiguous` above.
5749
+ provenance: { checked: true, ambiguous },
5750
+ ...(options.has('expect') ? { expected } : {}),
5751
+ },
5752
+ { resolvePath: canonical },
5753
+ );
5754
+ const exitCode = registrationExitCode(result.verdict, flags.has('strict'));
5755
+
5756
+ if (json) write(JSON.stringify({ mode: 'live', ...result, skillsRoot: scan.skillsRoot, exitCode }, null, 2));
5757
+ else write(renderRegistrationReport(result, scan));
5758
+ return exitCode;
5759
+ }
5760
+
5555
5761
  function cmdDeliveryCheck(options: Map<string, string>, flags: Set<string>, cwd: string, write: Write): number {
5556
5762
  let repoRoot = cwd;
5557
5763
  try { repoRoot = execSync('git rev-parse --show-toplevel', { cwd, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { /* not git */ }
@@ -6095,6 +6301,8 @@ export async function runCli(argv: string[], io: CliIo = {}): Promise<number> {
6095
6301
  return cmdDiscriminationCheck(options, flags, cwd, write);
6096
6302
  case 'delivery-check':
6097
6303
  return cmdDeliveryCheck(options, flags, cwd, write);
6304
+ case 'skills-verify':
6305
+ return cmdSkillsVerify(options, flags, cwd, write);
6098
6306
  case 'routing':
6099
6307
  return cmdRouting(options, flags, cwd, write);
6100
6308
  case 'bto-optimize':