@dzhechkov/harness-cli 0.4.6 → 0.5.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/bin.js CHANGED
@@ -1,17 +1,50 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * `dz` executable entry point.
4
+ *
5
+ * Two phases, and the split is load-bearing (feature dz-cli-defects, D5):
6
+ *
7
+ * phase 1 — ZERO `@dzhechkov/harness-core` imports: probe the installed core version
8
+ * and refuse with a NAMED message if it is below `MIN_CORE`;
9
+ * phase 2 — `await import('./cli.js')`, which is where the ~100-name static graph is
10
+ * linked. A STATIC import here would link that graph before any guard could
11
+ * run, which is exactly how a cached lower core produced a bare
12
+ * `SyntaxError: … does not provide an export named 'GRADE_SUCCESS_FLOOR'`
13
+ * with nothing pointing at the cause.
4
14
  */
5
- import { runCli } from './cli.js';
6
- const code = await runCli(process.argv.slice(2));
7
- // `process.exit()` here TRUNCATED large output on a pipe, silently and at exactly the
8
- // pipe buffer size. On a pipe (not a TTY, not a file) Node's stdout is ASYNCHRONOUS, so
9
- // `process.exit` discards whatever has not flushed yet: `dz recall --all --json > file`
10
- // wrote 122826 bytes while `dz recall --all --json | jq` got exactly 65536 and a parse
11
- // error. That is data loss in the documented sharing path, and silent — the exit code
12
- // was 0 and the JSON simply stopped mid-string.
13
- //
14
- // So: set the code and let the process end when the event loop drains, which is what
15
- // flushes stdout. `process.exitCode` preserves the status without the race.
16
- process.exitCode = code;
15
+ import { checkCoreCompat, describeMissingExportError, resolveInstalledCoreVersion, MIN_CORE } from './core-compat.js';
16
+ const foundCore = resolveInstalledCoreVersion(import.meta.url);
17
+ const compat = checkCoreCompat({ found: foundCore, min: MIN_CORE });
18
+ if (!compat.ok) {
19
+ // stderr, and no stack: the user needs one actionable line, not a trace.
20
+ console.error(compat.message);
21
+ process.exitCode = 1;
22
+ }
23
+ else {
24
+ let code;
25
+ try {
26
+ const { runCli } = await import('./cli.js');
27
+ code = await runCli(process.argv.slice(2));
28
+ }
29
+ catch (error) {
30
+ // The version probe fails OPEN, so a missing-binding link error can still reach us.
31
+ // Translate exactly that class into the named form; re-throw everything else
32
+ // unchanged so real bugs still surface.
33
+ const named = describeMissingExportError(error, foundCore);
34
+ if (named === null)
35
+ throw error;
36
+ console.error(named);
37
+ code = 1;
38
+ }
39
+ // `process.exit()` here TRUNCATED large output on a pipe, silently and at exactly the
40
+ // pipe buffer size. On a pipe (not a TTY, not a file) Node's stdout is ASYNCHRONOUS, so
41
+ // `process.exit` discards whatever has not flushed yet: `dz recall --all --json > file`
42
+ // wrote 122826 bytes while `dz recall --all --json | jq` got exactly 65536 and a parse
43
+ // error. That is data loss in the documented sharing path, and silent — the exit code
44
+ // was 0 and the JSON simply stopped mid-string.
45
+ //
46
+ // So: set the code and let the process end when the event loop drains, which is what
47
+ // flushes stdout. `process.exitCode` preserves the status without the race.
48
+ process.exitCode = code;
49
+ }
17
50
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjD,sFAAsF;AACtF,wFAAwF;AACxF,wFAAwF;AACxF,uFAAuF;AACvF,sFAAsF;AACtF,gDAAgD;AAChD,EAAE;AACF,qFAAqF;AACrF,4EAA4E;AAC5E,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC"}
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEtH,MAAM,SAAS,GAAG,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/D,MAAM,MAAM,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEpE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;IACf,yEAAyE;IACzE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,CAAC;IACN,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,oFAAoF;QACpF,6EAA6E;QAC7E,wCAAwC;QACxC,MAAM,KAAK,GAAG,0BAA0B,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3D,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,KAAK,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,GAAG,CAAC,CAAC;IACX,CAAC;IAED,sFAAsF;IACtF,wFAAwF;IACxF,wFAAwF;IACxF,uFAAuF;IACvF,sFAAsF;IACtF,gDAAgD;IAChD,EAAE;IACF,qFAAqF;IACrF,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC1B,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -7,6 +7,18 @@
7
7
  export interface CliIo {
8
8
  readonly cwd?: string;
9
9
  readonly write?: (line: string) => void;
10
+ /**
11
+ * Diagnostics sink — **stderr**, defaulting to `console.error`.
12
+ *
13
+ * Before feature dz-cli-defects `CliIo` had no stderr seam at all, so every
14
+ * diagnostic (including the top-level error handler) landed on stdout and
15
+ * `dz list > skills.txt` wrote the error INTO the data file. `write` stays "data
16
+ * only"; `writeErr` is "diagnosis only".
17
+ *
18
+ * There is deliberately **no** fall-back to `write`: a test that wants to assert on
19
+ * stderr must inject `writeErr`, or the assertion would be theatre.
20
+ */
21
+ readonly writeErr?: (line: string) => void;
10
22
  /**
11
23
  * Pre-read STDIN content (injectable so `dz brain ground`'s hook path is testable without
12
24
  * an actual pipe). When omitted, the CLI reads fd 0 synchronously — but only for the one
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAucH,2EAA2E;AAC3E,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjE;AAED,yFAAyF;AACzF,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KACvD;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC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