@git-stunts/git-cas 3.1.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 +53 -0
- package/README.md +24 -5
- package/bin/actions.js +54 -0
- package/bin/git-cas.js +210 -168
- package/bin/ui/progress.js +2 -2
- package/bin/ui/vault-list.js +63 -0
- package/index.d.ts +41 -1
- package/index.js +42 -8
- package/package.json +1 -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,59 @@ 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
|
+
|
|
8
61
|
## [3.1.0] — Bijou (2026-02-27)
|
|
9
62
|
|
|
10
63
|
### Added
|
package/README.md
CHANGED
|
@@ -44,15 +44,27 @@ We use the object database.
|
|
|
44
44
|
|
|
45
45
|
See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
|
|
46
46
|
|
|
47
|
-
## What's new in
|
|
47
|
+
## What's new in v4.0.1
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
**`git cas verify`** — verify stored asset integrity from the CLI without restoring (`git cas verify --slug my-asset`).
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
**`--json` everywhere** — all commands now support `--json` for structured output. Pipe `git cas vault list --json | jq` in CI.
|
|
52
52
|
|
|
53
|
-
**
|
|
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
54
|
|
|
55
|
-
**
|
|
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
|
|
62
|
+
|
|
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).
|
|
64
|
+
|
|
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.
|
|
56
68
|
|
|
57
69
|
See [CHANGELOG.md](./CHANGELOG.md) for the full list of changes.
|
|
58
70
|
|
|
@@ -135,6 +147,13 @@ git cas store ./secret.bin --slug vault-entry --tree
|
|
|
135
147
|
git cas restore --slug vault-entry --out ./decrypted.bin
|
|
136
148
|
```
|
|
137
149
|
|
|
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
|
+
|
|
138
157
|
## When to use git-cas (and when not to)
|
|
139
158
|
|
|
140
159
|
### "I just want screenshots in my README"
|
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 };
|