@git-stunts/git-cas 5.3.1 → 5.3.2

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/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.3.2] — Unreleased
9
+
10
+ ### Changed
11
+ - **Vitest workspace split** — unit, integration, and benchmark suites now live in explicit workspace projects so the integration suite always runs with `fileParallelism: false`, regardless of the exact CLI invocation shape.
12
+ - **Status semantics** — `STATUS.md` now distinguishes the last released version (`v5.3.1`) from the current branch version (`v5.3.2`).
13
+
14
+ ### Fixed
15
+ - **CLI version drift** — `bin/git-cas.js` now reads the package version instead of carrying a stale hardcoded literal, so `git-cas --version` tracks the in-repo release line correctly.
16
+
8
17
  ## [5.3.1] — 2026-03-15
9
18
 
10
19
  ### Fixed
package/README.md CHANGED
@@ -32,7 +32,7 @@ We use the object database.
32
32
  - **Lifecycle management** `readManifest`, `inspectAsset`, `collectReferencedChunks` — inspect trees, plan deletions, audit storage.
33
33
  - **Vault** GC-safe ref-based storage. One ref (`refs/cas/vault`) indexes all assets by slug. No more silent data loss from `git gc`.
34
34
  - **Interactive dashboard** `git cas inspect` with chunk heatmap, animated progress bars, and rich manifest views.
35
- - **Verify & JSON output** `git cas verify` checks integrity; `--json` on all commands for CI/scripting.
35
+ - **Verify & JSON output** `git cas verify` checks integrity; `--json` on all current human-facing commands provides convenient structured output for CI/scripting.
36
36
 
37
37
  **Use it for:** binary assets, build artifacts, model weights, data packs, secret bundles, weird experiments, etc.
38
38
 
package/bin/actions.js CHANGED
@@ -70,10 +70,13 @@ function defaultDelay(ms) {
70
70
  *
71
71
  * @param {(...args: any[]) => Promise<void>} fn - The async action function.
72
72
  * @param {() => boolean} getJson - Lazy getter for --json flag value.
73
- * @param {{ delay?: (ms: number) => Promise<void> }} [options] - Injectable dependencies.
73
+ * @param {{ delay?: (ms: number) => Promise<void>, setExitCode?: (code: number) => void }} [options] - Injectable dependencies.
74
74
  * @returns {(...args: any[]) => Promise<void>} Wrapped action.
75
75
  */
76
- export function runAction(fn, getJson, { delay = defaultDelay } = {}) {
76
+ export function runAction(fn, getJson, {
77
+ delay = defaultDelay,
78
+ setExitCode = (code) => { process.exitCode = code; },
79
+ } = {}) {
77
80
  return async (/** @type {any[]} */ ...args) => {
78
81
  try {
79
82
  await fn(...args);
@@ -81,8 +84,8 @@ export function runAction(fn, getJson, { delay = defaultDelay } = {}) {
81
84
  if (err?.code === 'INTEGRITY_ERROR') {
82
85
  await delay(1000);
83
86
  }
87
+ setExitCode(1);
84
88
  writeError(err, getJson());
85
- process.exitCode = 1;
86
89
  }
87
90
  };
88
91
  }
package/bin/git-cas.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { readFileSync } from 'node:fs';
4
+ import path from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
4
6
  import { program, Option } from 'commander';
5
7
  import GitPlumbing, { ShellRunnerFactory } from '@git-stunts/plumbing';
6
8
  import ContentAddressableStore, { EventEmitterObserver, CborCodec } from '../index.js';
@@ -11,16 +13,23 @@ import { renderHistoryTimeline } from './ui/history-timeline.js';
11
13
  import { renderManifestView } from './ui/manifest-view.js';
12
14
  import { renderHeatmap } from './ui/heatmap.js';
13
15
  import { runAction } from './actions.js';
16
+ import { flushStdioAndExit, installBrokenPipeHandlers } from './io.js';
14
17
  import { filterEntries, formatTable, formatTabSeparated } from './ui/vault-list.js';
15
18
  import { readPassphraseFile, promptPassphrase } from './ui/passphrase-prompt.js';
16
19
  import { loadConfig, mergeConfig } from './config.js';
17
20
 
21
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
22
+ const { version: CLI_VERSION } = JSON.parse(
23
+ readFileSync(path.resolve(__dirname, '../package.json'), 'utf8'),
24
+ );
25
+
18
26
  const getJson = () => program.opts().json;
27
+ installBrokenPipeHandlers();
19
28
 
20
29
  program
21
30
  .name('git-cas')
22
31
  .description('Content Addressable Storage backed by Git')
23
- .version('5.2.2')
32
+ .version(CLI_VERSION)
24
33
  .option('-q, --quiet', 'Suppress progress output')
25
34
  .option('--json', 'Output results as JSON');
26
35
 
@@ -751,5 +760,4 @@ await program.parseAsync();
751
760
 
752
761
  // Flush stdout/stderr before exiting — spawned git child processes leave
753
762
  // libuv handles that prevent natural exit in containerized environments.
754
- const code = process.exitCode || 0;
755
- process.stdout.write('', () => process.stderr.write('', () => process.exit(code)));
763
+ await flushStdioAndExit();
package/bin/io.js ADDED
@@ -0,0 +1,86 @@
1
+ import { setTimeout as delay } from 'node:timers/promises';
2
+
3
+ /**
4
+ * @param {unknown} err
5
+ * @returns {err is NodeJS.ErrnoException}
6
+ */
7
+ function isBrokenPipeError(err) {
8
+ return Boolean(err && typeof err === 'object' && /** @type {NodeJS.ErrnoException} */ (err).code === 'EPIPE');
9
+ }
10
+
11
+ /**
12
+ * Install stdout/stderr error handlers that exit cleanly when the downstream
13
+ * consumer closes the pipe before the CLI finishes writing.
14
+ *
15
+ * @param {Object} [options]
16
+ * @param {{ on(event: string, listener: (...args: any[]) => void): any, removeListener(event: string, listener: (...args: any[]) => void): any }} [options.stdout]
17
+ * @param {{ on(event: string, listener: (...args: any[]) => void): any, removeListener(event: string, listener: (...args: any[]) => void): any }} [options.stderr]
18
+ * @param {(code?: number) => never} [options.exit]
19
+ * @param {() => number} [options.getExitCode]
20
+ * @returns {{ dispose(): void }}
21
+ */
22
+ export function installBrokenPipeHandlers({
23
+ stdout = process.stdout,
24
+ stderr = process.stderr,
25
+ exit = process.exit,
26
+ getExitCode = () => process.exitCode || 0,
27
+ } = {}) {
28
+ const onError = (/** @type {unknown} */ err) => {
29
+ if (isBrokenPipeError(err)) {
30
+ exit(getExitCode());
31
+ }
32
+ };
33
+
34
+ stdout.on('error', onError);
35
+ stderr.on('error', onError);
36
+
37
+ return {
38
+ dispose() {
39
+ stdout.removeListener('error', onError);
40
+ stderr.removeListener('error', onError);
41
+ },
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Flush stdout/stderr before exit so the CLI does not hang on open handles in
47
+ * containerized test environments.
48
+ *
49
+ * @param {Object} [options]
50
+ * @param {{ write(chunk: string, callback?: () => void): boolean }} [options.stdout]
51
+ * @param {{ write(chunk: string, callback?: () => void): boolean }} [options.stderr]
52
+ * @param {(code?: number) => void} [options.exit]
53
+ * @param {number} [options.code]
54
+ * @returns {Promise<void>}
55
+ */
56
+ export async function flushStdioAndExit({
57
+ stdout = process.stdout,
58
+ stderr = process.stderr,
59
+ exit = process.exit,
60
+ code = process.exitCode || 0,
61
+ } = {}) {
62
+ await flushStream(stdout);
63
+ await flushStream(stderr);
64
+ exit(code);
65
+ }
66
+
67
+ /**
68
+ * @param {{ write(chunk: string, callback?: () => void): boolean }} stream
69
+ * @returns {Promise<void>}
70
+ */
71
+ async function flushStream(stream) {
72
+ try {
73
+ await new Promise((resolve) => {
74
+ stream.write('', resolve);
75
+ });
76
+ } catch (err) {
77
+ if (!isBrokenPipeError(err)) {
78
+ throw err;
79
+ }
80
+ }
81
+
82
+ // Give stream error handlers one turn to observe late EPIPE events before exit.
83
+ await delay(0);
84
+ }
85
+
86
+ export { isBrokenPipeError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git-stunts/git-cas",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "Content-addressed storage backed by Git's object database, with optional encryption and pluggable codecs",
5
5
  "type": "module",
6
6
  "main": "index.js",