@flowrail/init 0.0.11 → 0.0.12

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.
@@ -35,11 +35,22 @@ const INSTALL_NPM_ARGS = ['install', '--save-dev', exports.HOOK_PACKAGE];
35
35
  * be a false positive.
36
36
  * 3. Spawns the bin file via `node` with no args. The hook entry
37
37
  * point writes `flowrail-hook: unknown subcommand ...` to stderr
38
- * and exits 2 when invoked without `pre-write`/`pre-bash`. We
39
- * require both signals. This proves the file is parseable, all
38
+ * when invoked without `pre-write`/`pre-bash`. We require that
39
+ * message AND the bin name. This proves the file is parseable, all
40
40
  * imports resolve at runtime, and the entry-point code runs to
41
41
  * completion — catching broken shims, syntax errors, missing
42
42
  * runtime deps, or a wrong binary masquerading at the bin path.
43
+ *
44
+ * The EXIT CODE is deliberately accepted as either 0 or 2, because
45
+ * hook >=0.0.18 (ADR-019 / PR #309) splits it by event provenance:
46
+ * a provable PreToolUse invocation exits 2, everything else exits 0
47
+ * so a stale hook can never fail CLOSED on version skew. This
48
+ * self-test spawns the bin bare — no PreToolUse stdin — so it takes
49
+ * the exit-0 path on >=0.0.18 and the exit-2 path on <=0.0.17.
50
+ * Pinning `status === 2` broke `npx @flowrail/init@latest` against
51
+ * hook 0.0.18. The two stderr signals, not the exit code, are what
52
+ * establish the binary's identity; a silent `exit(0)` imposter still
53
+ * fails because it emits neither.
43
54
  */
44
55
  function buildVerifyNodeScript(pkg, bin) {
45
56
  const pkgJson = JSON.stringify(`${pkg}/package.json`);
@@ -56,7 +67,10 @@ function buildVerifyNodeScript(pkg, bin) {
56
67
  '}',
57
68
  'const binPath = path.resolve(path.dirname(pkgPath), binEntry);',
58
69
  "const result = cp.spawnSync(process.execPath, [binPath], { encoding: 'utf8' });",
59
- `if (result.status !== 2 || !/unknown subcommand/.test(result.stderr || '') || !new RegExp(${binName}).test(result.stderr || '')) {`,
70
+ // Accept BOTH of hook's documented unknown-subcommand exit paths:
71
+ // 2 (provable PreToolUse) and 0 (anything else, >=0.0.18). Identity is
72
+ // established by the two stderr signals below, not the exit code.
73
+ `if ((result.status !== 0 && result.status !== 2) || !/unknown subcommand/.test(result.stderr || '') || !new RegExp(${binName}).test(result.stderr || '')) {`,
60
74
  " console.error('binary self-test failed: status=' + result.status + ' stderr=' + (result.stderr || '').slice(0, 300));",
61
75
  ' process.exit(2);',
62
76
  '}',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowrail/init",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "One-shot FlowRail installer for Claude Code. Wires PreToolUse hooks, MCP server config, and skill markdown into a tester's repo, then probes the FlowRail server with their bearer.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,