@git-stunts/git-cas 3.0.0 → 4.0.1
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 +77 -0
- package/README.md +54 -14
- package/bin/actions.js +54 -0
- package/bin/git-cas.js +254 -134
- package/bin/ui/context.js +54 -0
- package/bin/ui/dashboard-cmds.js +34 -0
- package/bin/ui/dashboard-view.js +132 -0
- package/bin/ui/dashboard.js +204 -0
- package/bin/ui/encryption-card.js +49 -0
- package/bin/ui/heatmap.js +103 -0
- package/bin/ui/history-timeline.js +84 -0
- package/bin/ui/manifest-view.js +135 -0
- package/bin/ui/progress.js +126 -0
- package/bin/ui/vault-list.js +63 -0
- package/index.d.ts +41 -1
- package/index.js +42 -8
- package/package.json +10 -1
- package/src/domain/services/CasService.d.ts +18 -2
- package/src/domain/services/CasService.js +181 -69
- package/src/domain/services/Semaphore.js +47 -0
- package/src/infrastructure/adapters/BunCryptoAdapter.js +12 -68
- package/src/infrastructure/adapters/EventEmitterObserver.js +70 -0
- package/src/infrastructure/adapters/NodeCryptoAdapter.js +11 -74
- package/src/infrastructure/adapters/SilentObserver.js +11 -0
- package/src/infrastructure/adapters/StatsCollector.js +45 -0
- package/src/infrastructure/adapters/WebCryptoAdapter.js +26 -81
- package/src/ports/CryptoPort.js +92 -1
- package/src/ports/ObservabilityPort.js +33 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,83 @@ 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
|
+
## [4.0.1] — M8 Spit Shine + M9 Cockpit (2026-02-28)
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **`git cas verify`** command — verify stored asset integrity from the CLI (checks blob hashes; no key needed).
|
|
12
|
+
- **`--json` global flag** — structured JSON output for all commands (`store`, `restore`, `verify`, `inspect`, `vault list/init/remove/info/history`).
|
|
13
|
+
- **`runAction` error handler** (`bin/actions.js`) — centralized `try`/`catch` with CasError code display and actionable hints for 5 common errors.
|
|
14
|
+
- **Vault list `--filter <pattern>`** — glob-based slug filtering with TTY-aware table formatting.
|
|
15
|
+
- **`CryptoPort` base class** — shared `_validateKey()`, `_buildMeta()`, and `deriveKey()` (template method pattern with `_doDeriveKey()`). Eliminates duplication across Node/Bun/Web adapters.
|
|
16
|
+
- **ADR-001** (`docs/ADR-001-vault-in-facade.md`) — architectural decision record for vault service composition.
|
|
17
|
+
- **STATUS.md** — project status dashboard with shipped versions, roadmap, dependency graph, and known concerns.
|
|
18
|
+
- **COMPLETED_TASKS.md** / **GRAVEYARD.md** — archived M1–M7 task cards and superseded tasks.
|
|
19
|
+
- `WebCryptoAdapter.finalize()` guard — throws `STREAM_NOT_CONSUMED` if called before encrypt stream is fully consumed.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- `verify` command uses `process.exitCode = 1` instead of `process.exit(1)` to allow stdout to drain on pipes.
|
|
23
|
+
- `runAction` uses `process.exitCode = 1` for consistent exit behavior across all commands.
|
|
24
|
+
- `vault info --json --encryption` now includes encryption metadata in JSON output.
|
|
25
|
+
- `store --force` without `--tree` now throws immediately instead of silently ignoring the flag.
|
|
26
|
+
- `inspect --json` now emits JSON even in TTY mode (previously fell through to rich view).
|
|
27
|
+
- `vault history --json` now emits structured JSON array of `{ commitOid, message }` objects.
|
|
28
|
+
- `NodeCryptoAdapter._validateKey` removed — inherits base class which accepts both `Buffer` and `Uint8Array`.
|
|
29
|
+
- `CasService.encrypt()` removed redundant `_validateKey` call.
|
|
30
|
+
- `matchGlob` rejects patterns > 200 chars (ReDoS guard); `?` no longer matches `/` path separator.
|
|
31
|
+
- `writeError` guards against non-Error throws.
|
|
32
|
+
- `_doDeriveKey` in `NodeCryptoAdapter` now properly `await`s promisified calls.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
- `CryptoPort` is now the single source of truth for key validation, metadata building, and KDF parameter normalization. All three adapters override only `_doDeriveKey()`.
|
|
36
|
+
- ROADMAP.md pruned: completed M1–M7 task cards moved to COMPLETED_TASKS.md.
|
|
37
|
+
|
|
38
|
+
## [4.0.0] — Conduit (2026-02-27)
|
|
39
|
+
|
|
40
|
+
### Breaking Changes
|
|
41
|
+
- **`CasService` no longer extends `EventEmitter`** — event subscriptions must use the new `ObservabilityPort` adapters instead of `service.on()`. The `EventEmitterObserver` adapter provides full backward compatibility for existing event-based code.
|
|
42
|
+
- **`observability` is a required constructor port** for `CasService`. The facade (`ContentAddressableStore`) defaults to `SilentObserver` when omitted.
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
- **ObservabilityPort** — new hexagonal port (`src/ports/ObservabilityPort.js`) with `metric(channel, data)`, `log(level, msg, meta?)`, and `span(name)` methods. Decouples the domain layer from Node's event infrastructure.
|
|
46
|
+
- **SilentObserver** — no-op adapter (default). Zero overhead when observability is not needed.
|
|
47
|
+
- **EventEmitterObserver** — bridges `metric()` calls to EventEmitter events (`chunk:stored`, `file:restored`, etc.) for backward-compatible progress tracking. Exposes `.on()`, `.removeListener()`, `.listenerCount()`.
|
|
48
|
+
- **StatsCollector** — accumulates metrics and exposes `summary()` with `chunksProcessed`, `bytesTotal`, `elapsed`, `throughput`, and `errors`.
|
|
49
|
+
- **`restoreStream()`** — new async generator on `CasService` and facade. Returns `AsyncIterable<Buffer>` for streaming restore with O(chunkSize) memory for unencrypted, uncompressed files. Encrypted/compressed files buffer internally but expose the same streaming API.
|
|
50
|
+
- **`restoreFile()` now uses streaming I/O** — writes via `createWriteStream` + `pipeline` instead of buffering the entire file with `writeFileSync`.
|
|
51
|
+
- **Parallel chunk I/O** — new `concurrency` option (default: 1). Store operations launch chunk writes through a counting semaphore. Streaming restore uses read-ahead for concurrent blob fetches. `concurrency: 1` produces identical sequential behavior.
|
|
52
|
+
- **Semaphore** — internal counting semaphore (`src/domain/services/Semaphore.js`) for concurrency control.
|
|
53
|
+
- 43 new unit tests (567 total).
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- CLI `store` and `restore` commands now create an `EventEmitterObserver` and pass it to the CAS instance, attaching progress tracking to the observer instead of the service.
|
|
57
|
+
- `restore()` reimplemented as a collector over `restoreStream()`.
|
|
58
|
+
- `_chunkAndStore()` refactored to use semaphore-gated parallel writes with `Promise.all`, sorting results by index after completion.
|
|
59
|
+
- Progress tracking example (`examples/progress-tracking.js`) updated to use `EventEmitterObserver` pattern.
|
|
60
|
+
|
|
61
|
+
## [3.1.0] — Bijou (2026-02-27)
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
- **Interactive vault dashboard** (`git cas vault dashboard`) — TEA-based TUI with split-pane layout, manifest detail view, keyboard navigation (`j`/`k`/`Enter`/`/`), and real-time filtering.
|
|
65
|
+
- **Manifest inspector** (`git cas inspect <tree-oid>`) — renders manifest details with chunk table, encryption info, and compression badges.
|
|
66
|
+
- **Progress bars** for `store` and `restore` operations — animated progress with throughput reporting, auto-disabled in non-TTY environments.
|
|
67
|
+
- **History timeline** (`git cas vault history --pretty`) — color-coded, paginated timeline view of vault commit history.
|
|
68
|
+
- **Encryption info card** (`git cas vault info --encryption`) — detailed KDF parameters and encryption configuration display.
|
|
69
|
+
- **Chunk heatmap** — chunk-size distribution grid with colored legend, displayed in manifest detail views.
|
|
70
|
+
- `--quiet` / `-q` flag to suppress all progress output.
|
|
71
|
+
- `GIT_CAS_PASSPHRASE` environment variable — alternative to `--vault-passphrase` flag for passphrase-based encryption.
|
|
72
|
+
- New runtime dependencies: `@flyingrobots/bijou`, `@flyingrobots/bijou-node`, `@flyingrobots/bijou-tui`.
|
|
73
|
+
|
|
74
|
+
### Fixed
|
|
75
|
+
- CLI `restore` now uses the canonical `readManifest` path instead of duplicating manifest resolution logic.
|
|
76
|
+
- Progress trackers wrapped in `try`/`finally` to prevent event listener leaks when `storeFile` or `restoreFile` throws.
|
|
77
|
+
- Dashboard filter and error lines clamped to pane width to prevent wrapping artifacts in narrow terminals.
|
|
78
|
+
- Dashboard differentiates entry vs manifest load errors — a single manifest preload failure no longer sets global error state.
|
|
79
|
+
- Dashboard clamps cursor position after applying filter on entry load.
|
|
80
|
+
- Passphrase resolution uses nullish coalescing for correct falsy-value handling.
|
|
81
|
+
- Locale-agnostic number formatting in encryption card tests.
|
|
82
|
+
- Consolidated duplicated restore flag validation into `validateRestoreFlags()`.
|
|
83
|
+
- Eliminated `vi.mock('node:fs')` pattern in progress tests for Bun Docker compatibility.
|
|
84
|
+
|
|
8
85
|
## [3.0.0] — Vault (2026-02-08)
|
|
9
86
|
|
|
10
87
|
### Added
|
package/README.md
CHANGED
|
@@ -32,6 +32,8 @@ We use the object database.
|
|
|
32
32
|
|
|
33
33
|
**Use it for:** binary assets, build artifacts, model weights, data packs, secret bundles, weird experiments, etc.
|
|
34
34
|
|
|
35
|
+
<img src="./docs/demo.gif" alt="git-cas demo" />
|
|
36
|
+
|
|
35
37
|
## What's new in v2.0.0
|
|
36
38
|
|
|
37
39
|
**Compression** — `compression: { algorithm: 'gzip' }` on `store()`. Compression runs before encryption. Decompression on `restore()` is automatic.
|
|
@@ -42,11 +44,27 @@ We use the object database.
|
|
|
42
44
|
|
|
43
45
|
See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
|
|
44
46
|
|
|
45
|
-
## What's new in
|
|
47
|
+
## What's new in v4.0.1
|
|
48
|
+
|
|
49
|
+
**`git cas verify`** — verify stored asset integrity from the CLI without restoring (`git cas verify --slug my-asset`).
|
|
50
|
+
|
|
51
|
+
**`--json` everywhere** — all commands now support `--json` for structured output. Pipe `git cas vault list --json | jq` in CI.
|
|
52
|
+
|
|
53
|
+
**CryptoPort base class** — shared key validation, metadata building, and KDF normalization. All three adapters (Node/Bun/Web) inherit from a single source of truth.
|
|
54
|
+
|
|
55
|
+
**Centralized error handling** — `runAction` wrapper with CasError codes and actionable hints (e.g., "Provide --key-file or --vault-passphrase").
|
|
56
|
+
|
|
57
|
+
**Vault list filtering** — `git cas vault list --filter "photos/*"` with TTY-aware table formatting.
|
|
58
|
+
|
|
59
|
+
See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
|
|
60
|
+
|
|
61
|
+
## What's new in v4.0.0
|
|
46
62
|
|
|
47
|
-
**
|
|
63
|
+
**ObservabilityPort** — `CasService` no longer extends `EventEmitter`. A new hexagonal `ObservabilityPort` decouples the domain from Node's event infrastructure. Three adapters ship out of the box: `SilentObserver` (no-op default), `EventEmitterObserver` (backward-compatible event bridge), and `StatsCollector` (metric accumulator).
|
|
48
64
|
|
|
49
|
-
**
|
|
65
|
+
**Streaming restore** — `restoreStream()` returns an `AsyncIterable<Buffer>` with O(chunkSize) memory for unencrypted files. `restoreFile()` now writes via `createWriteStream` + `pipeline` instead of buffering.
|
|
66
|
+
|
|
67
|
+
**Parallel chunk I/O** — new `concurrency` option gates store writes and restore reads through a counting semaphore. `concurrency: 4` can significantly speed up large-file operations.
|
|
50
68
|
|
|
51
69
|
See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
|
|
52
70
|
|
|
@@ -122,22 +140,44 @@ git cas vault info my-image
|
|
|
122
140
|
git cas vault remove my-image
|
|
123
141
|
git cas vault history
|
|
124
142
|
|
|
125
|
-
# Encrypted vault round-trip
|
|
126
|
-
|
|
127
|
-
git cas
|
|
128
|
-
git cas
|
|
143
|
+
# Encrypted vault round-trip (passphrase via env var or --vault-passphrase flag)
|
|
144
|
+
export GIT_CAS_PASSPHRASE="secret"
|
|
145
|
+
git cas vault init
|
|
146
|
+
git cas store ./secret.bin --slug vault-entry --tree
|
|
147
|
+
git cas restore --slug vault-entry --out ./decrypted.bin
|
|
129
148
|
```
|
|
130
149
|
|
|
131
|
-
##
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
- [Guide](./GUIDE.md) — progressive walkthrough
|
|
153
|
+
- [API Reference](./docs/API.md) — full method documentation
|
|
154
|
+
- [Architecture](./ARCHITECTURE.md) — hexagonal design overview
|
|
155
|
+
- [Security](./docs/SECURITY.md) — crypto design and threat model
|
|
156
|
+
|
|
157
|
+
## When to use git-cas (and when not to)
|
|
158
|
+
|
|
159
|
+
### "I just want screenshots in my README"
|
|
160
|
+
|
|
161
|
+
Use an **orphan branch**. Seriously. It's 5 git commands, zero dependencies, and GitHub renders the images inline. Google "git orphan branch assets" — that's all you need. git-cas is overkill for public images and demo GIFs.
|
|
162
|
+
|
|
163
|
+
### "I need encrypted secrets / large binaries / deduplicated assets in a Git repo"
|
|
164
|
+
|
|
165
|
+
That's git-cas. The orphan branch gives you none of:
|
|
166
|
+
|
|
167
|
+
| | Orphan branch | git-cas |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| **Encryption** | None — plaintext forever in history | AES-256-GCM + passphrase KDF |
|
|
170
|
+
| **Large files** | Bloats `git clone` for everyone | Chunked, restored on demand |
|
|
171
|
+
| **Dedup** | None | Chunk-level content addressing |
|
|
172
|
+
| **Integrity** | Git SHA-1 | SHA-256 per chunk + GCM auth tag |
|
|
173
|
+
| **Lifecycle** | `git rm` (still in reflog) | Vault with audit trail + `git gc` reclaims |
|
|
174
|
+
| **Compression** | None | gzip before encryption |
|
|
132
175
|
|
|
133
|
-
|
|
176
|
+
### "Why not Git LFS?"
|
|
134
177
|
|
|
135
|
-
|
|
136
|
-
- content-addressed
|
|
137
|
-
- locally replicable
|
|
138
|
-
- commit-addressable
|
|
178
|
+
Because sometimes you want the Git object database to be the store — deterministic, content-addressed, locally replicable, commit-addressable — with no external server, no LFS endpoint, and no second system to manage.
|
|
139
179
|
|
|
140
|
-
|
|
180
|
+
If your team uses GitHub and needs file locking + web UI previews, use LFS. If you want encrypted, self-contained, server-free binary storage that travels with `git clone`, use git-cas.
|
|
141
181
|
|
|
142
182
|
---
|
|
143
183
|
|
package/bin/actions.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI error handler — wraps command actions with structured error output.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const HINTS = {
|
|
6
|
+
MISSING_KEY: 'Provide --key-file or --vault-passphrase',
|
|
7
|
+
MANIFEST_NOT_FOUND: 'Verify the tree OID contains a manifest',
|
|
8
|
+
VAULT_ENTRY_NOT_FOUND: "Run 'git cas vault list' to see available entries",
|
|
9
|
+
VAULT_ENTRY_EXISTS: 'Use --force to overwrite',
|
|
10
|
+
INTEGRITY_ERROR: 'Check that the correct key or passphrase was used',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Format and write an error to stderr.
|
|
15
|
+
*
|
|
16
|
+
* @param {Error} err
|
|
17
|
+
* @param {boolean} json - Whether to output JSON.
|
|
18
|
+
*/
|
|
19
|
+
function writeError(err, json) {
|
|
20
|
+
const message = err?.message ?? String(err);
|
|
21
|
+
const code = typeof err?.code === 'string' ? err.code : undefined;
|
|
22
|
+
if (json) {
|
|
23
|
+
const obj = { error: message };
|
|
24
|
+
if (code) { obj.code = code; }
|
|
25
|
+
process.stderr.write(`${JSON.stringify(obj)}\n`);
|
|
26
|
+
} else {
|
|
27
|
+
const prefix = code ? `error [${code}]: ` : 'error: ';
|
|
28
|
+
process.stderr.write(`${prefix}${message}\n`);
|
|
29
|
+
const hint = code ? HINTS[code] : undefined;
|
|
30
|
+
if (hint) {
|
|
31
|
+
process.stderr.write(`hint: ${hint}\n`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Wrap a command action with structured error handling.
|
|
38
|
+
*
|
|
39
|
+
* @param {Function} fn - The async action function.
|
|
40
|
+
* @param {Function} getJson - Lazy getter for --json flag value.
|
|
41
|
+
* @returns {Function} Wrapped action.
|
|
42
|
+
*/
|
|
43
|
+
export function runAction(fn, getJson) {
|
|
44
|
+
return async (...args) => {
|
|
45
|
+
try {
|
|
46
|
+
await fn(...args);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
writeError(err, getJson());
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { writeError, HINTS };
|