@git-stunts/git-cas 5.2.1 → 5.3.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/README.md +67 -5
  3. package/bin/actions.js +38 -8
  4. package/bin/config.js +203 -0
  5. package/bin/git-cas.js +200 -54
  6. package/bin/ui/context.js +13 -0
  7. package/bin/ui/dashboard-cmds.js +14 -6
  8. package/bin/ui/dashboard-view.js +55 -6
  9. package/bin/ui/dashboard.js +109 -7
  10. package/bin/ui/encryption-card.js +2 -2
  11. package/bin/ui/heatmap.js +20 -2
  12. package/bin/ui/history-timeline.js +8 -6
  13. package/bin/ui/manifest-view.js +37 -8
  14. package/bin/ui/passphrase-prompt.js +100 -0
  15. package/bin/ui/progress.js +60 -38
  16. package/index.d.ts +20 -1
  17. package/index.js +74 -218
  18. package/package.json +2 -1
  19. package/src/domain/errors/CasError.js +3 -1
  20. package/src/domain/helpers/buildKdfMetadata.js +18 -0
  21. package/src/domain/services/CasService.d.ts +21 -1
  22. package/src/domain/services/CasService.js +134 -228
  23. package/src/domain/services/KeyResolver.js +220 -0
  24. package/src/domain/services/Semaphore.js +2 -2
  25. package/src/domain/services/VaultService.js +72 -29
  26. package/src/domain/services/rotateVaultPassphrase.js +143 -0
  27. package/src/infrastructure/adapters/BunCryptoAdapter.js +38 -6
  28. package/src/infrastructure/adapters/EventEmitterObserver.js +19 -7
  29. package/src/infrastructure/adapters/FileIOHelper.js +64 -0
  30. package/src/infrastructure/adapters/GitPersistenceAdapter.js +21 -5
  31. package/src/infrastructure/adapters/GitRefAdapter.js +27 -5
  32. package/src/infrastructure/adapters/NodeCryptoAdapter.js +49 -8
  33. package/src/infrastructure/adapters/SilentObserver.js +15 -0
  34. package/src/infrastructure/adapters/StatsCollector.js +15 -1
  35. package/src/infrastructure/adapters/WebCryptoAdapter.js +120 -42
  36. package/src/infrastructure/adapters/createCryptoAdapter.js +25 -0
  37. package/src/infrastructure/chunkers/CdcChunker.js +5 -0
  38. package/src/infrastructure/chunkers/FixedChunker.js +28 -8
  39. package/src/infrastructure/chunkers/resolveChunker.js +45 -0
  40. package/src/infrastructure/codecs/CborCodec.js +11 -3
  41. package/src/infrastructure/codecs/JsonCodec.js +10 -2
  42. package/src/ports/CodecPort.js +3 -3
  43. package/src/ports/CryptoPort.js +56 -23
  44. package/src/ports/GitPersistencePort.js +4 -4
  45. package/src/ports/GitRefPort.js +10 -10
  46. package/src/types/ambient.d.ts +37 -0
@@ -5,7 +5,7 @@
5
5
  export default class GitPersistencePort {
6
6
  /**
7
7
  * Writes content as a Git blob object.
8
- * @param {Buffer|string} content - Data to store.
8
+ * @param {Buffer|string} _content - Data to store.
9
9
  * @returns {Promise<string>} The Git OID of the stored blob.
10
10
  */
11
11
  async writeBlob(_content) {
@@ -14,7 +14,7 @@ export default class GitPersistencePort {
14
14
 
15
15
  /**
16
16
  * Creates a Git tree object from formatted entries.
17
- * @param {string[]} entries - Lines in `git mktree` format.
17
+ * @param {string[]} _entries - Lines in `git mktree` format.
18
18
  * @returns {Promise<string>} The Git OID of the created tree.
19
19
  */
20
20
  async writeTree(_entries) {
@@ -23,7 +23,7 @@ export default class GitPersistencePort {
23
23
 
24
24
  /**
25
25
  * Reads a Git blob by its OID.
26
- * @param {string} oid - Git object ID.
26
+ * @param {string} _oid - Git object ID.
27
27
  * @returns {Promise<Buffer>} The blob content.
28
28
  */
29
29
  async readBlob(_oid) {
@@ -32,7 +32,7 @@ export default class GitPersistencePort {
32
32
 
33
33
  /**
34
34
  * Reads and parses a Git tree object.
35
- * @param {string} treeOid - Git tree OID.
35
+ * @param {string} _treeOid - Git tree OID.
36
36
  * @returns {Promise<Array<{ mode: string, type: string, oid: string, name: string }>>} Parsed tree entries.
37
37
  */
38
38
  async readTree(_treeOid) {
@@ -5,7 +5,7 @@
5
5
  export default class GitRefPort {
6
6
  /**
7
7
  * Resolves a Git ref to its commit OID.
8
- * @param {string} ref - Git ref (e.g. 'refs/cas/vault').
8
+ * @param {string} _ref - Git ref (e.g. 'refs/cas/vault').
9
9
  * @returns {Promise<string>} The commit OID.
10
10
  * @throws If the ref does not exist.
11
11
  */
@@ -15,7 +15,7 @@ export default class GitRefPort {
15
15
 
16
16
  /**
17
17
  * Resolves the tree OID from a commit OID.
18
- * @param {string} commitOid - Git commit OID.
18
+ * @param {string} _commitOid - Git commit OID.
19
19
  * @returns {Promise<string>} The tree OID.
20
20
  */
21
21
  async resolveTree(_commitOid) {
@@ -24,10 +24,10 @@ export default class GitRefPort {
24
24
 
25
25
  /**
26
26
  * Creates a Git commit object.
27
- * @param {Object} options
28
- * @param {string} options.treeOid - Tree OID for the commit.
29
- * @param {string|null} [options.parentOid] - Parent commit OID (null for root commit).
30
- * @param {string} options.message - Commit message.
27
+ * @param {Object} _options
28
+ * @param {string} _options.treeOid - Tree OID for the commit.
29
+ * @param {string|null} [_options.parentOid] - Parent commit OID (null for root commit).
30
+ * @param {string} _options.message - Commit message.
31
31
  * @returns {Promise<string>} The new commit OID.
32
32
  */
33
33
  async createCommit(_options) {
@@ -36,10 +36,10 @@ export default class GitRefPort {
36
36
 
37
37
  /**
38
38
  * Atomically updates a Git ref with optional CAS (compare-and-swap) semantics.
39
- * @param {Object} options
40
- * @param {string} options.ref - Git ref to update.
41
- * @param {string} options.newOid - New OID to set.
42
- * @param {string|null} [options.expectedOldOid] - Expected current OID for CAS. If provided and mismatched, throws.
39
+ * @param {Object} _options
40
+ * @param {string} _options.ref - Git ref to update.
41
+ * @param {string} _options.newOid - New OID to set.
42
+ * @param {string|null} [_options.expectedOldOid] - Expected current OID for CAS.
43
43
  * @returns {Promise<void>}
44
44
  */
45
45
  async updateRef(_options) {
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Ambient module declarations for dependencies that lack type definitions.
3
+ */
4
+
5
+ declare module '@git-stunts/plumbing' {
6
+ interface ExecuteOptions {
7
+ args: string[];
8
+ input?: string | Buffer;
9
+ }
10
+
11
+ interface StreamResult {
12
+ collect(options?: { asString?: boolean }): Promise<Uint8Array>;
13
+ }
14
+
15
+ interface ShellRunner {
16
+ run(command: string, args: string[], options?: Record<string, unknown>): Promise<unknown>;
17
+ }
18
+
19
+ export class ShellRunnerFactory {
20
+ static create(options?: Record<string, unknown>): ShellRunner;
21
+ }
22
+
23
+ export default class GitPlumbing {
24
+ constructor(options: { runner: ShellRunner; cwd?: string });
25
+ execute(options: ExecuteOptions): Promise<string>;
26
+ executeStream(options: ExecuteOptions): Promise<StreamResult>;
27
+ }
28
+ }
29
+
30
+ declare module 'bun' {
31
+ export class CryptoHasher {
32
+ constructor(algorithm: string);
33
+ update(data: Buffer | Uint8Array | string): this;
34
+ digest(encoding: 'hex'): string;
35
+ digest(): Uint8Array;
36
+ }
37
+ }