@git-stunts/git-cas 5.3.2 → 6.0.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/ADVANCED_GUIDE.md +1006 -0
- package/ARCHITECTURE.md +514 -0
- package/CHANGELOG.md +393 -5
- package/CODE_OF_CONDUCT.md +33 -0
- package/GUIDE.md +872 -0
- package/README.md +219 -325
- package/SECURITY.md +993 -0
- package/SUPPORT.md +54 -0
- package/UPGRADING.md +299 -0
- package/bin/actions.js +70 -21
- package/bin/agent/cli.js +51 -0
- package/bin/agent/commands/doctor.js +99 -0
- package/bin/agent/commands/index.js +1489 -0
- package/bin/agent/input.js +619 -0
- package/bin/agent/passphrase-source.js +123 -0
- package/bin/agent/protocol.js +193 -0
- package/bin/build-version.js +64 -0
- package/bin/credentials.js +425 -0
- package/bin/git-cas.js +595 -449
- package/bin/passphrase-source.js +266 -0
- package/bin/restore-output-target.js +28 -0
- package/bin/ui/blocks/asset-card.js +109 -0
- package/bin/ui/blocks/health-dashboard.js +149 -0
- package/bin/ui/blocks/heatmap-block.js +67 -0
- package/bin/ui/blocks/merkle-explorer.js +163 -0
- package/bin/ui/blocks/operation-feed.js +176 -0
- package/bin/ui/blocks/wizard-block.js +168 -0
- package/bin/ui/components/short-sha.js +36 -0
- package/bin/ui/context.js +56 -1
- package/bin/ui/dashboard-cmds.js +1578 -13
- package/bin/ui/dashboard-view.js +612 -145
- package/bin/ui/dashboard.js +998 -214
- package/bin/ui/encryption-card.js +69 -26
- package/bin/ui/heatmap.js +26 -54
- package/bin/ui/history-timeline.js +51 -19
- package/bin/ui/manifest-view.js +115 -60
- package/bin/ui/merkle-dag.js +83 -0
- package/bin/ui/progress.js +15 -9
- package/bin/ui/repo-treemap.js +328 -0
- package/bin/ui/shaders/bak-sneppen.js +180 -0
- package/bin/ui/shaders/fractal-zoom.js +99 -0
- package/bin/ui/shaders/merkle-tree.js +142 -0
- package/bin/ui/shaders/organic-flow.js +96 -0
- package/bin/ui/shaders/phase-portrait.js +93 -0
- package/bin/ui/store-wizard.js +296 -0
- package/bin/ui/theme.js +155 -0
- package/bin/ui/vault-report.js +495 -0
- package/build-info.json +4 -0
- package/docs/API.md +2224 -0
- package/docs/ENCRYPTION_MODES.md +33 -0
- package/docs/EXTENDING.md +174 -0
- package/docs/STORE_RESTORE_PIPELINE.md +199 -0
- package/docs/THREAT_MODEL.md +269 -0
- package/docs/VAULT_INTERNALS.md +251 -0
- package/docs/WALKTHROUGH.md +1868 -0
- package/docs/demo.gif +0 -0
- package/docs/releases/v6.0.0.md +104 -0
- package/examples/README.md +260 -0
- package/index.d.ts +208 -65
- package/index.js +163 -54
- package/package.json +35 -6
- package/scripts/migrate-encryption.js +680 -0
- package/src/domain/bytes/ByteLayout.js +96 -0
- package/src/domain/encoding/base64.js +91 -0
- package/src/domain/encoding/hex.js +14 -0
- package/src/domain/encoding/utf8.js +123 -0
- package/src/domain/encryption/schemes.js +132 -0
- package/src/domain/errors/CannotRemoveLastRecipientError.js +10 -0
- package/src/domain/errors/CasError.d.ts +28 -0
- package/src/domain/errors/CasError.js +43 -6
- package/src/domain/errors/Codes.js +54 -0
- package/src/domain/errors/DekUnwrapFailedError.js +10 -0
- package/src/domain/errors/GitError.js +10 -0
- package/src/domain/errors/GitPlumbingInitializationError.js +10 -0
- package/src/domain/errors/IntegrityError.js +10 -0
- package/src/domain/errors/InvalidChunkingStrategyError.js +10 -0
- package/src/domain/errors/InvalidOidError.js +10 -0
- package/src/domain/errors/InvalidOptionsError.js +10 -0
- package/src/domain/errors/ManifestIntegrityError.js +10 -0
- package/src/domain/errors/ManifestNotFoundError.js +10 -0
- package/src/domain/errors/NoMatchingRecipientError.js +10 -0
- package/src/domain/errors/PersistenceCapabilityRequiredError.js +10 -0
- package/src/domain/errors/PortNotImplementedError.js +10 -0
- package/src/domain/errors/RecipientAlreadyExistsError.js +10 -0
- package/src/domain/errors/RecipientNotFoundError.js +10 -0
- package/src/domain/errors/RestoreTooLargeError.js +10 -0
- package/src/domain/errors/RotationNotSupportedError.js +10 -0
- package/src/domain/errors/createCasError.js +68 -0
- package/src/domain/errors/index.js +20 -0
- package/src/domain/helpers/buildKdfMetadata.js +4 -2
- package/src/domain/helpers/codecBytes.js +34 -0
- package/src/domain/helpers/gitRefErrors.js +84 -0
- package/src/domain/helpers/scryptMaxmem.js +22 -0
- package/src/domain/outcomes/RestoreFailure.js +15 -0
- package/src/domain/outcomes/RestoreOutcome.js +11 -0
- package/src/domain/outcomes/RestoreSuccess.js +34 -0
- package/src/domain/outcomes/StoreFailure.js +15 -0
- package/src/domain/outcomes/StoreOutcome.js +11 -0
- package/src/domain/outcomes/StoreSuccess.js +17 -0
- package/src/domain/schemas/ManifestSchema.d.ts +40 -9
- package/src/domain/schemas/ManifestSchema.js +67 -13
- package/src/domain/services/CasService.d.ts +123 -38
- package/src/domain/services/CasService.js +298 -834
- package/src/domain/services/ChunkRepository.js +230 -0
- package/src/domain/services/CompressionStreams.js +72 -0
- package/src/domain/services/ConvergentEncryption.js +128 -0
- package/src/domain/services/GitTreeBuilder.js +86 -0
- package/src/domain/services/IntegrityVerifier.js +199 -0
- package/src/domain/services/KeyResolver.js +49 -42
- package/src/domain/services/ManifestDiff.js +56 -0
- package/src/domain/services/ManifestRepository.js +286 -0
- package/src/domain/services/PrefetchWindow.js +48 -0
- package/src/domain/services/RecipientService.js +157 -0
- package/src/domain/services/RedactingObservability.js +169 -0
- package/src/domain/services/RestorePipeline.js +68 -0
- package/src/domain/services/StorePipeline.js +201 -0
- package/src/domain/services/VaultKeyVerifier.js +101 -0
- package/src/domain/services/VaultMetadataCodec.js +206 -0
- package/src/domain/services/VaultMutationRetryPolicy.js +105 -0
- package/src/domain/services/VaultPersistence.js +410 -0
- package/src/domain/services/VaultPrivacyIndex.js +191 -0
- package/src/domain/services/VaultService.js +749 -251
- package/src/domain/services/VaultStateCache.js +225 -0
- package/src/domain/services/VaultTreeCodec.js +121 -0
- package/src/domain/services/rotateVaultPassphrase.js +37 -20
- package/src/domain/strategies/Aad.js +39 -0
- package/src/domain/strategies/FramedRecordCodec.js +204 -0
- package/src/domain/strategies/RestoreCompressed.js +40 -0
- package/src/domain/strategies/RestoreConvergent.js +44 -0
- package/src/domain/strategies/RestoreFramed.js +55 -0
- package/src/domain/strategies/RestorePlain.js +37 -0
- package/src/domain/strategies/RestoreStrategy.js +35 -0
- package/src/domain/strategies/RestoreWhole.js +135 -0
- package/src/domain/strategies/StoreConvergent.js +28 -0
- package/src/domain/strategies/StoreFramed.js +39 -0
- package/src/domain/strategies/StorePlain.js +20 -0
- package/src/domain/strategies/StoreStrategy.js +61 -0
- package/src/domain/strategies/StoreWhole.js +34 -0
- package/src/domain/value-objects/Chunk.js +1 -2
- package/src/domain/value-objects/EncryptionMetadata.js +87 -0
- package/src/domain/value-objects/Manifest.d.ts +40 -4
- package/src/domain/value-objects/Manifest.js +61 -20
- package/src/domain/value-objects/Oid.js +45 -0
- package/src/domain/value-objects/Slug.js +124 -0
- package/src/domain/value-objects/StoreEncryptionConfig.js +114 -0
- package/src/helpers/aesGcmMeta.js +55 -0
- package/src/helpers/canonicalBase64.js +1 -0
- package/src/helpers/kdfPolicy.js +194 -0
- package/src/infrastructure/adapters/BunCryptoAdapter.js +124 -8
- package/src/infrastructure/adapters/FileIOHelper.js +178 -13
- package/src/infrastructure/adapters/GitPersistenceAdapter.js +235 -42
- package/src/infrastructure/adapters/GitPlumbingFactoryAdapter.js +62 -0
- package/src/infrastructure/adapters/GitRefAdapter.js +19 -6
- package/src/infrastructure/adapters/NodeCompressionAdapter.js +64 -0
- package/src/infrastructure/adapters/NodeCryptoAdapter.js +130 -10
- package/src/infrastructure/adapters/WebCryptoAdapter.js +187 -77
- package/src/infrastructure/chunkers/CdcChunker.js +53 -19
- package/src/infrastructure/chunkers/FixedChunker.js +15 -7
- package/src/infrastructure/chunkers/resolveChunker.js +3 -1
- package/src/infrastructure/codecs/CborCodec.js +3 -3
- package/src/infrastructure/codecs/JsonCodec.js +5 -5
- package/src/infrastructure/createGitPlumbing.js +22 -0
- package/src/package-version.js +1 -0
- package/src/ports/ChunkingPort.js +3 -3
- package/src/ports/CodecPort.js +4 -4
- package/src/ports/CompressionPort.js +57 -0
- package/src/ports/CryptoPort.js +138 -50
- package/src/ports/GitPersistencePort.js +32 -2
- package/src/ports/GitPlumbingFactoryPort.js +16 -0
- package/src/ports/GitRefPort.js +1 -1
- package/src/types/ambient.d.ts +10 -5
- package/test/CONVENTIONS.md +94 -0
- package/test/cycles/README.md +13 -0
|
@@ -2,48 +2,91 @@
|
|
|
2
2
|
* Encryption info card — visual summary of vault crypto configuration.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { badge, createSurface, parseAnsiToSurface } from '@flyingrobots/bijou';
|
|
6
|
+
import { hstackSurface, vstackSurface } from '@flyingrobots/bijou-tui';
|
|
6
7
|
import { getCliContext } from './context.js';
|
|
8
|
+
import { sectionHeading, themeText } from './theme.js';
|
|
9
|
+
|
|
10
|
+
function textSurface(text, width) {
|
|
11
|
+
return parseAnsiToSurface(text, Math.max(1, width), 1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function stripAnsiLength(str) {
|
|
15
|
+
// eslint-disable-next-line no-control-regex
|
|
16
|
+
return str.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Build key-value rows for the encryption profile.
|
|
21
|
+
*
|
|
22
|
+
* @param {{ cipher: string, kdf: any }} encryption
|
|
23
|
+
* @returns {[string, string][]}
|
|
24
|
+
*/
|
|
25
|
+
function buildKdfRows(encryption) {
|
|
26
|
+
const { kdf } = encryption;
|
|
27
|
+
/** @type {[string, string][]} */
|
|
28
|
+
const rows = [
|
|
29
|
+
['cipher', encryption.cipher],
|
|
30
|
+
['kdf', kdf.algorithm],
|
|
31
|
+
];
|
|
32
|
+
if (kdf.algorithm === 'pbkdf2') {
|
|
33
|
+
rows.push(['iterations', /** @type {number} */ (kdf.iterations).toLocaleString()]);
|
|
34
|
+
} else if (kdf.algorithm === 'scrypt') {
|
|
35
|
+
rows.push(['cost', String(kdf.cost)]);
|
|
36
|
+
rows.push(['blockSize', String(kdf.blockSize)]);
|
|
37
|
+
rows.push(['parallel', String(kdf.parallelization)]);
|
|
38
|
+
}
|
|
39
|
+
rows.push(['key length', `${kdf.keyLength} bytes`]);
|
|
40
|
+
rows.push(['salt', `${kdf.salt.slice(0, 12)}...`]);
|
|
41
|
+
return rows;
|
|
42
|
+
}
|
|
7
43
|
|
|
8
44
|
/**
|
|
9
45
|
* Render an encryption info card for the vault.
|
|
10
46
|
*
|
|
11
47
|
* @param {Object} options
|
|
12
|
-
* @param {import('../../index.js').VaultMetadata | null} options.metadata
|
|
13
|
-
* @param {boolean} [options.unlocked]
|
|
14
|
-
* @returns {
|
|
48
|
+
* @param {import('../../index.js').VaultMetadata | null} options.metadata
|
|
49
|
+
* @param {boolean} [options.unlocked]
|
|
50
|
+
* @returns {import('@flyingrobots/bijou').Surface}
|
|
15
51
|
*/
|
|
16
52
|
export function renderEncryptionCard({ metadata, unlocked = false }) {
|
|
17
53
|
const ctx = getCliContext();
|
|
18
54
|
|
|
19
55
|
if (!metadata?.encryption) {
|
|
20
|
-
return
|
|
56
|
+
return textSurface('No encryption configured', 26);
|
|
21
57
|
}
|
|
22
58
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
59
|
+
const rows = buildKdfRows(metadata.encryption);
|
|
60
|
+
const maxKey = Math.max(...rows.map(([k]) => k.length));
|
|
25
61
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
62
|
+
const kvSurfaces = rows.map(([k, v]) => {
|
|
63
|
+
const label = themeText(ctx, k.padEnd(maxKey), { tone: 'accent' });
|
|
64
|
+
return hstackSurface(2,
|
|
65
|
+
createSurface(2, 1),
|
|
66
|
+
textSurface(label, stripAnsiLength(label)),
|
|
67
|
+
textSurface(v, stripAnsiLength(v))
|
|
68
|
+
);
|
|
69
|
+
});
|
|
29
70
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
71
|
+
const statusBadge = badge(unlocked ? 'unlocked' : 'locked', {
|
|
72
|
+
variant: unlocked ? 'success' : 'danger',
|
|
73
|
+
ctx,
|
|
74
|
+
});
|
|
34
75
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
76
|
+
const statusLabel = themeText(ctx, 'status'.padEnd(maxKey), { tone: 'accent' });
|
|
77
|
+
const statusRow = hstackSurface(2,
|
|
78
|
+
createSurface(2, 1),
|
|
79
|
+
textSurface(statusLabel, stripAnsiLength(statusLabel)),
|
|
80
|
+
statusBadge,
|
|
81
|
+
);
|
|
42
82
|
|
|
43
|
-
|
|
44
|
-
rows.push(` salt ${kdf.salt.slice(0, 12)}...`);
|
|
45
|
-
rows.push(` status ${status}`);
|
|
83
|
+
const headingText = sectionHeading(ctx, 'Encryption Profile', 'warning');
|
|
46
84
|
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
return vstackSurface(
|
|
86
|
+
textSurface(themeText(ctx, 'Vault Envelope', { tone: 'brand' }), 14),
|
|
87
|
+
textSurface(themeText(ctx, 'Cipher, KDF shape, and unlock posture.', { tone: 'subdued' }), 38),
|
|
88
|
+
textSurface(headingText, stripAnsiLength(headingText)),
|
|
89
|
+
...kvSurfaces,
|
|
90
|
+
statusRow
|
|
91
|
+
);
|
|
49
92
|
}
|
package/bin/ui/heatmap.js
CHANGED
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
* Chunk heatmap visualization — visual block map of chunks.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { gradientText } from '@flyingrobots/bijou';
|
|
6
5
|
import { getCliContext } from './context.js';
|
|
6
|
+
import { renderHeatmapGrid } from './blocks/heatmap-block.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {import('../../src/domain/value-objects/Manifest.js').ManifestData} ManifestData
|
|
10
10
|
* @typedef {import('../../src/domain/value-objects/Manifest.js').SubManifestRef} SubManifestRef
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
{ pos: 0, color: [0, 255, 255] },
|
|
16
|
-
{ pos: 1, color: [255, 0, 255] },
|
|
17
|
-
];
|
|
13
|
+
const HEATMAP_MAX_WIDTH = 60;
|
|
14
|
+
const HEATMAP_MARGIN = 10;
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* Format bytes as human-readable string.
|
|
@@ -35,39 +32,6 @@ function formatBytes(bytes) {
|
|
|
35
32
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GiB`;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
/**
|
|
39
|
-
* Build the block grid string from chunks.
|
|
40
|
-
*
|
|
41
|
-
* @param {ManifestData['chunks']} chunks
|
|
42
|
-
* @param {Set<number>} boundaries
|
|
43
|
-
* @param {number} width
|
|
44
|
-
* @returns {string}
|
|
45
|
-
*/
|
|
46
|
-
function buildGrid(chunks, boundaries, width) {
|
|
47
|
-
let grid = '';
|
|
48
|
-
let col = 0;
|
|
49
|
-
|
|
50
|
-
for (let i = 0; i < chunks.length; i++) {
|
|
51
|
-
if (boundaries.has(i) && col > 0) {
|
|
52
|
-
grid += '\n';
|
|
53
|
-
col = 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
grid += '\u2588';
|
|
57
|
-
col++;
|
|
58
|
-
|
|
59
|
-
if (col >= width) {
|
|
60
|
-
grid += '\n';
|
|
61
|
-
col = 0;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (col > 0) {
|
|
66
|
-
grid += '\n';
|
|
67
|
-
}
|
|
68
|
-
return grid;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
35
|
/**
|
|
72
36
|
* Build the legend line.
|
|
73
37
|
*
|
|
@@ -88,33 +52,41 @@ function buildLegend(chunks, subManifests) {
|
|
|
88
52
|
}
|
|
89
53
|
|
|
90
54
|
/**
|
|
91
|
-
*
|
|
55
|
+
* Collect sub-manifest boundary indices.
|
|
56
|
+
*
|
|
57
|
+
* @param {SubManifestRef[]} subManifests
|
|
58
|
+
* @returns {number[]}
|
|
59
|
+
*/
|
|
60
|
+
function collectBreaks(subManifests) {
|
|
61
|
+
return subManifests
|
|
62
|
+
.filter((sm) => sm.startIndex > 0)
|
|
63
|
+
.map((sm) => sm.startIndex);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Render a chunk heatmap for pre-normalized manifest data.
|
|
92
68
|
*
|
|
93
69
|
* @param {Object} options
|
|
94
|
-
* @param {ManifestData
|
|
70
|
+
* @param {ManifestData} options.manifest - Pre-normalized manifest data.
|
|
95
71
|
* @returns {string}
|
|
96
72
|
*/
|
|
97
73
|
export function renderHeatmap({ manifest }) {
|
|
98
74
|
const ctx = getCliContext();
|
|
99
|
-
const
|
|
100
|
-
const chunks = m.chunks || [];
|
|
75
|
+
const chunks = manifest.chunks || [];
|
|
101
76
|
|
|
102
77
|
if (chunks.length === 0) {
|
|
103
78
|
return 'No chunks to display\n';
|
|
104
79
|
}
|
|
105
80
|
|
|
106
|
-
const width = Math.min(
|
|
107
|
-
const subManifests =
|
|
108
|
-
|
|
109
|
-
const boundaries = new Set();
|
|
110
|
-
for (const sm of subManifests) {
|
|
111
|
-
if (sm.startIndex > 0) {
|
|
112
|
-
boundaries.add(sm.startIndex);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
81
|
+
const width = Math.min(HEATMAP_MAX_WIDTH, (ctx.runtime.columns || 80) - HEATMAP_MARGIN);
|
|
82
|
+
const subManifests = manifest.subManifests || [];
|
|
83
|
+
const breaks = collectBreaks(subManifests);
|
|
115
84
|
|
|
116
|
-
const
|
|
117
|
-
|
|
85
|
+
const colored = renderHeatmapGrid(chunks.length, {
|
|
86
|
+
width,
|
|
87
|
+
breaks,
|
|
88
|
+
style: ctx.style,
|
|
89
|
+
});
|
|
118
90
|
const legend = buildLegend(chunks, subManifests);
|
|
119
91
|
|
|
120
92
|
return `${colored}\n${legend}\n`;
|
|
@@ -5,14 +5,22 @@
|
|
|
5
5
|
import { timeline, paginator } from '@flyingrobots/bijou';
|
|
6
6
|
import { getCliContext } from './context.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {{ oid: string, operation: string, slug: string | null }} VaultCommitEvent
|
|
10
|
+
*/
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* Parse a vault commit line into structured data.
|
|
10
14
|
* Input format: "eff5569 vault: add photos/beach"
|
|
11
15
|
*
|
|
16
|
+
* This is git-log output parsing — an infrastructure/adapter concern
|
|
17
|
+
* exported here for convenience. Callers doing their own git interaction
|
|
18
|
+
* should use this to normalize raw log lines before passing to the view.
|
|
19
|
+
*
|
|
12
20
|
* @param {string} line
|
|
13
|
-
* @returns {
|
|
21
|
+
* @returns {VaultCommitEvent | null}
|
|
14
22
|
*/
|
|
15
|
-
function parseCommitLine(line) {
|
|
23
|
+
export function parseCommitLine(line) {
|
|
16
24
|
const trimmed = line.trim();
|
|
17
25
|
if (!trimmed) {
|
|
18
26
|
return null;
|
|
@@ -34,6 +42,20 @@ function parseCommitLine(line) {
|
|
|
34
42
|
return { oid, operation: match[1], slug: match[2] || null };
|
|
35
43
|
}
|
|
36
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Parse raw git log output into structured vault commit events.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} gitLogOutput - Raw output from `git log --oneline`.
|
|
49
|
+
* @returns {VaultCommitEvent[]}
|
|
50
|
+
*/
|
|
51
|
+
export function parseGitLog(gitLogOutput) {
|
|
52
|
+
return gitLogOutput
|
|
53
|
+
.split('\n')
|
|
54
|
+
.filter(Boolean)
|
|
55
|
+
.map(parseCommitLine)
|
|
56
|
+
.filter(/** @returns {e is VaultCommitEvent} */ (e) => e !== null);
|
|
57
|
+
}
|
|
58
|
+
|
|
37
59
|
/** @type {Record<string, string>} */
|
|
38
60
|
const STATUS_MAP = {
|
|
39
61
|
init: 'info',
|
|
@@ -44,39 +66,34 @@ const STATUS_MAP = {
|
|
|
44
66
|
};
|
|
45
67
|
|
|
46
68
|
/**
|
|
47
|
-
* Render vault history as a color-coded timeline.
|
|
69
|
+
* Render vault history as a color-coded timeline from pre-parsed events.
|
|
48
70
|
*
|
|
49
|
-
* @param {
|
|
71
|
+
* @param {VaultCommitEvent[]} events - Pre-parsed vault commit events.
|
|
50
72
|
* @param {Object} [options]
|
|
51
73
|
* @param {number} [options.page] - Current page (1-based).
|
|
52
74
|
* @param {number} [options.perPage] - Entries per page (default 20).
|
|
53
75
|
* @returns {string}
|
|
54
76
|
*/
|
|
55
|
-
export function
|
|
77
|
+
export function renderTimeline(events, options = {}) {
|
|
56
78
|
const ctx = getCliContext();
|
|
57
79
|
const perPage = options.perPage ?? 20;
|
|
58
80
|
const page = options.page ?? 1;
|
|
59
81
|
|
|
60
|
-
|
|
61
|
-
if (lines.length === 0) {
|
|
82
|
+
if (events.length === 0) {
|
|
62
83
|
return 'No history\n';
|
|
63
84
|
}
|
|
64
85
|
|
|
65
|
-
const totalPages = Math.ceil(
|
|
86
|
+
const totalPages = Math.ceil(events.length / perPage);
|
|
66
87
|
const start = (page - 1) * perPage;
|
|
67
|
-
const
|
|
88
|
+
const pageEvents = events.slice(start, start + perPage);
|
|
68
89
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
description: oid,
|
|
75
|
-
status: /** @type {import('@flyingrobots/bijou').BaseStatusKey} */ (STATUS_MAP[operation] || 'pending'),
|
|
76
|
-
};
|
|
77
|
-
});
|
|
90
|
+
const timelineData = pageEvents.map(({ oid, operation, slug }) => ({
|
|
91
|
+
label: slug ? `vault: ${operation} ${slug}` : `vault: ${operation}`,
|
|
92
|
+
description: oid,
|
|
93
|
+
status: /** @type {import('@flyingrobots/bijou').BaseStatusKey} */ (STATUS_MAP[operation] || 'pending'),
|
|
94
|
+
}));
|
|
78
95
|
|
|
79
|
-
let output = timeline(
|
|
96
|
+
let output = timeline(timelineData, { ctx });
|
|
80
97
|
|
|
81
98
|
if (totalPages > 1) {
|
|
82
99
|
output += `\n${paginator({ current: page, total: totalPages, ctx })}`;
|
|
@@ -84,3 +101,18 @@ export function renderHistoryTimeline(gitLogOutput, options = {}) {
|
|
|
84
101
|
|
|
85
102
|
return output;
|
|
86
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Render vault history from raw git log output (convenience wrapper).
|
|
107
|
+
*
|
|
108
|
+
* Parses the raw log, then delegates to renderTimeline.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} gitLogOutput - Raw output from `git log --oneline`.
|
|
111
|
+
* @param {Object} [options]
|
|
112
|
+
* @param {number} [options.page] - Current page (1-based).
|
|
113
|
+
* @param {number} [options.perPage] - Entries per page (default 20).
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
export function renderHistoryTimeline(gitLogOutput, options = {}) {
|
|
117
|
+
return renderTimeline(parseGitLog(gitLogOutput), options);
|
|
118
|
+
}
|
package/bin/ui/manifest-view.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
* Manifest anatomy view — rich visual breakdown of a manifest.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { box
|
|
5
|
+
import { box } from '@flyingrobots/bijou';
|
|
6
6
|
import { getCliContext } from './context.js';
|
|
7
|
+
import { renderBadgeRow } from './blocks/asset-card.js';
|
|
8
|
+
import { renderChunkTable, renderSubManifestTree } from './blocks/merkle-explorer.js';
|
|
9
|
+
import { sectionHeading, themeText } from './theme.js';
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* @typedef {import('../../src/domain/value-objects/Manifest.js').ManifestData} ManifestData
|
|
10
13
|
* @typedef {import('@flyingrobots/bijou').BijouContext} BijouContext
|
|
14
|
+
* @typedef {import('@flyingrobots/bijou').AccordionSection} AccordionSection
|
|
11
15
|
*/
|
|
12
16
|
|
|
13
17
|
/**
|
|
@@ -30,98 +34,114 @@ function formatBytes(bytes) {
|
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
|
-
*
|
|
37
|
+
* Format key-value pairs with aligned themed labels.
|
|
34
38
|
*
|
|
35
|
-
* @param {
|
|
39
|
+
* @param {[string, string][]} rows
|
|
36
40
|
* @param {BijouContext} ctx
|
|
37
41
|
* @returns {string}
|
|
38
42
|
*/
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
badges.push(badge('encrypted', { variant: 'warning', ctx }));
|
|
43
|
-
}
|
|
44
|
-
if (m.compression) {
|
|
45
|
-
badges.push(badge(m.compression.algorithm, { variant: 'info', ctx }));
|
|
46
|
-
}
|
|
47
|
-
if (m.subManifests?.length) {
|
|
48
|
-
badges.push(badge('merkle', { variant: 'info', ctx }));
|
|
49
|
-
}
|
|
50
|
-
return badges.join(' ');
|
|
43
|
+
function formatKv(rows, ctx) {
|
|
44
|
+
const maxKey = Math.max(...rows.map(([k]) => k.length));
|
|
45
|
+
return rows.map(([k, v]) => ` ${themeText(ctx, k.padEnd(maxKey), { tone: 'accent' })} ${v}`).join('\n');
|
|
51
46
|
}
|
|
52
47
|
|
|
48
|
+
// Badge rendering delegated to blocks/asset-card.js (renderBadgeRow)
|
|
49
|
+
|
|
53
50
|
/**
|
|
54
|
-
* Build the encryption section.
|
|
51
|
+
* Build the encryption section body.
|
|
55
52
|
*
|
|
56
53
|
* @param {NonNullable<ManifestData['encryption']>} enc
|
|
57
54
|
* @param {BijouContext} ctx
|
|
58
55
|
* @returns {string}
|
|
59
56
|
*/
|
|
60
|
-
function
|
|
61
|
-
|
|
57
|
+
function encryptionBody(enc, ctx) {
|
|
58
|
+
/** @type {[string, string][]} */
|
|
59
|
+
const rows = [['algorithm', enc.algorithm]];
|
|
62
60
|
if (enc.kdf) {
|
|
63
|
-
rows.push(
|
|
61
|
+
rows.push(['kdf', enc.kdf.algorithm]);
|
|
64
62
|
if (enc.kdf.iterations) {
|
|
65
|
-
rows.push(
|
|
63
|
+
rows.push(['iterations', enc.kdf.iterations.toLocaleString()]);
|
|
66
64
|
}
|
|
67
65
|
if (enc.kdf.cost) {
|
|
68
|
-
rows.push(
|
|
66
|
+
rows.push(['cost', String(enc.kdf.cost)]);
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
69
|
if (enc.nonce) {
|
|
72
|
-
rows.push(
|
|
70
|
+
rows.push(['nonce', `${enc.nonce.slice(0, 16)}...`]);
|
|
73
71
|
}
|
|
74
72
|
if (enc.tag) {
|
|
75
|
-
rows.push(
|
|
73
|
+
rows.push(['tag', `${enc.tag.slice(0, 16)}...`]);
|
|
76
74
|
}
|
|
77
|
-
return
|
|
75
|
+
return box(formatKv(rows, ctx), { ctx });
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
/**
|
|
81
|
-
* Build the
|
|
79
|
+
* Build the encryption section (headed).
|
|
80
|
+
*
|
|
81
|
+
* @param {NonNullable<ManifestData['encryption']>} enc
|
|
82
|
+
* @param {BijouContext} ctx
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
function renderEncryptionSection(enc, ctx) {
|
|
86
|
+
return `${sectionHeading(ctx, 'Encryption Profile', 'warning')}\n${encryptionBody(enc, ctx)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Build the chunks section body.
|
|
82
91
|
*
|
|
83
92
|
* @param {ManifestData['chunks']} chunks
|
|
84
93
|
* @param {BijouContext} ctx
|
|
85
94
|
* @returns {string}
|
|
86
95
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
rows: chunkRows,
|
|
98
|
-
ctx,
|
|
99
|
-
});
|
|
100
|
-
const suffix = chunks.length > 20
|
|
101
|
-
? `\n ...and ${chunks.length - 20} more`
|
|
102
|
-
: '';
|
|
103
|
-
return `${headerBox(`Chunks (${chunks.length})`, { ctx })}\n${chunkTable}${suffix}`;
|
|
96
|
+
/**
|
|
97
|
+
* Build the chunks section (headed). Delegates to MerkleExplorer block.
|
|
98
|
+
*
|
|
99
|
+
* @param {ManifestData} m
|
|
100
|
+
* @param {BijouContext} ctx
|
|
101
|
+
* @returns {string}
|
|
102
|
+
*/
|
|
103
|
+
function renderChunksSection(m, ctx) {
|
|
104
|
+
const chunks = m.chunks || [];
|
|
105
|
+
return `${sectionHeading(ctx, `Chunk Ledger (${chunks.length})`, 'info')}\n${renderChunkTable(m, ctx)}`;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
/**
|
|
107
|
-
* Build the metadata section.
|
|
109
|
+
* Build the metadata section body.
|
|
108
110
|
*
|
|
109
111
|
* @param {ManifestData} m
|
|
110
112
|
* @param {BijouContext} ctx
|
|
111
113
|
* @returns {string}
|
|
112
114
|
*/
|
|
113
|
-
function
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
function metadataBody(m, ctx) {
|
|
116
|
+
const rows = [
|
|
117
|
+
['slug', m.slug ?? '-'],
|
|
118
|
+
['filename', m.filename ?? '-'],
|
|
119
|
+
['size', formatBytes(m.size)],
|
|
120
|
+
['chunks', String(m.chunks?.length ?? 0)],
|
|
119
121
|
];
|
|
120
|
-
return
|
|
122
|
+
return box(formatKv(rows, ctx), { ctx });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Build the metadata section (headed).
|
|
127
|
+
*
|
|
128
|
+
* @param {ManifestData} m
|
|
129
|
+
* @param {BijouContext} ctx
|
|
130
|
+
* @returns {string}
|
|
131
|
+
*/
|
|
132
|
+
function renderMetadataSection(m, ctx) {
|
|
133
|
+
return `${sectionHeading(ctx, 'Asset Metadata', 'brand')}\n${metadataBody(m, ctx)}`;
|
|
121
134
|
}
|
|
122
135
|
|
|
123
136
|
/**
|
|
124
|
-
* Build the sub-manifests section.
|
|
137
|
+
* Build the sub-manifests section body.
|
|
138
|
+
*
|
|
139
|
+
* @param {ManifestData} m
|
|
140
|
+
* @param {BijouContext} ctx
|
|
141
|
+
* @returns {string}
|
|
142
|
+
*/
|
|
143
|
+
/**
|
|
144
|
+
* Build the sub-manifests section (headed). Delegates to MerkleExplorer block.
|
|
125
145
|
*
|
|
126
146
|
* @param {ManifestData} m
|
|
127
147
|
* @param {BijouContext} ctx
|
|
@@ -129,36 +149,71 @@ function renderMetadataSection(m, ctx) {
|
|
|
129
149
|
*/
|
|
130
150
|
function renderSubManifestsSection(m, ctx) {
|
|
131
151
|
const subs = m.subManifests || [];
|
|
132
|
-
|
|
133
|
-
label: `sub-${i} ${sm.chunkCount} chunks start: ${sm.startIndex} oid: ${sm.oid.slice(0, 8)}...`,
|
|
134
|
-
}));
|
|
135
|
-
return `${headerBox(`Sub-manifests (${subs.length})`, { ctx })}\n${tree(nodes, { ctx })}`;
|
|
152
|
+
return `${sectionHeading(ctx, `Merkle Branches (${subs.length})`, 'accent')}\n${renderSubManifestTree(m, ctx)}`;
|
|
136
153
|
}
|
|
137
154
|
|
|
138
155
|
/**
|
|
139
156
|
* Render a full manifest anatomy view.
|
|
140
157
|
*
|
|
141
158
|
* @param {Object} options
|
|
142
|
-
* @param {ManifestData
|
|
159
|
+
* @param {ManifestData} options.manifest - Pre-normalized manifest data.
|
|
143
160
|
* @param {BijouContext} [options.ctx] - Optional bijou context override.
|
|
144
161
|
* @returns {string}
|
|
145
162
|
*/
|
|
146
163
|
export function renderManifestView({ manifest, ctx = getCliContext() }) {
|
|
147
|
-
const m =
|
|
148
|
-
const
|
|
164
|
+
const m = manifest;
|
|
165
|
+
const badges = renderBadgeRow(m, ctx);
|
|
166
|
+
const sections = [themeText(ctx, 'Manifest Ledger', { tone: 'brand' })];
|
|
167
|
+
if (badges) {
|
|
168
|
+
sections.push(badges);
|
|
169
|
+
}
|
|
170
|
+
sections.push(renderMetadataSection(m, ctx));
|
|
149
171
|
|
|
150
172
|
if (m.encryption) {
|
|
151
173
|
sections.push(renderEncryptionSection(m.encryption, ctx));
|
|
152
174
|
}
|
|
153
175
|
if (m.compression) {
|
|
154
|
-
sections.push(`${
|
|
176
|
+
sections.push(`${sectionHeading(ctx, 'Compression Profile', 'info')}\n${box(` algorithm ${m.compression.algorithm}`, { ctx })}`);
|
|
155
177
|
}
|
|
156
178
|
if (m.subManifests?.length) {
|
|
157
179
|
sections.push(renderSubManifestsSection(m, ctx));
|
|
158
180
|
}
|
|
159
181
|
if (m.chunks?.length) {
|
|
160
|
-
sections.push(renderChunksSection(m
|
|
182
|
+
sections.push(renderChunksSection(m, ctx));
|
|
161
183
|
}
|
|
162
184
|
|
|
163
185
|
return `${sections.join('\n\n')}\n`;
|
|
164
186
|
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Build structured accordion sections from manifest data.
|
|
190
|
+
*
|
|
191
|
+
* Each section has a title and content string. Metadata is expanded by
|
|
192
|
+
* default; all other sections are collapsed. Only sections relevant to the
|
|
193
|
+
* manifest are included (e.g. no encryption section for plaintext assets).
|
|
194
|
+
*
|
|
195
|
+
* @param {Object} options
|
|
196
|
+
* @param {ManifestData} options.manifest - Pre-normalized manifest data.
|
|
197
|
+
* @param {BijouContext} [options.ctx] - Optional bijou context override.
|
|
198
|
+
* @returns {AccordionSection[]}
|
|
199
|
+
*/
|
|
200
|
+
export function buildManifestSections({ manifest, ctx = getCliContext() }) {
|
|
201
|
+
const m = manifest;
|
|
202
|
+
/** @type {AccordionSection[]} */
|
|
203
|
+
const sections = [
|
|
204
|
+
{ title: 'Asset Metadata', content: metadataBody(m, ctx), expanded: true },
|
|
205
|
+
];
|
|
206
|
+
if (m.encryption) {
|
|
207
|
+
sections.push({ title: 'Encryption Profile', content: encryptionBody(m.encryption, ctx), expanded: true });
|
|
208
|
+
}
|
|
209
|
+
if (m.compression) {
|
|
210
|
+
sections.push({ title: 'Compression Profile', content: box(` algorithm ${m.compression.algorithm}`, { ctx }), expanded: true });
|
|
211
|
+
}
|
|
212
|
+
if (m.subManifests?.length) {
|
|
213
|
+
sections.push({ title: `Merkle Branches (${m.subManifests.length})`, content: renderSubManifestTree(m, ctx), expanded: true });
|
|
214
|
+
}
|
|
215
|
+
if (m.chunks?.length) {
|
|
216
|
+
sections.push({ title: `Chunk Ledger (${m.chunks.length})`, content: renderChunkTable(m, ctx), expanded: true });
|
|
217
|
+
}
|
|
218
|
+
return sections;
|
|
219
|
+
}
|