@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
package/bin/ui/dashboard-view.js
CHANGED
|
@@ -1,181 +1,648 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pure render functions for the
|
|
2
|
+
* Pure render functions for the V6 git-cas cockpit.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { boxSurface, createSurface, parseAnsiToSurface } from '@flyingrobots/bijou';
|
|
6
|
+
import {
|
|
7
|
+
canvas,
|
|
8
|
+
commandPaletteSurface,
|
|
9
|
+
drawer,
|
|
10
|
+
hstackSurface,
|
|
11
|
+
modal,
|
|
12
|
+
navigableTableSurface,
|
|
13
|
+
placeSurface,
|
|
14
|
+
renderNotificationStack,
|
|
15
|
+
statusBarSurface,
|
|
16
|
+
vstackSurface,
|
|
17
|
+
} from '@flyingrobots/bijou-tui';
|
|
18
|
+
import { renderRepoTreemapMap, renderRepoTreemapSidebar } from './repo-treemap.js';
|
|
19
|
+
import { shellRule, themeText } from './theme.js';
|
|
20
|
+
import { renderChunkTable, renderMerkleExplorer } from './blocks/merkle-explorer.js';
|
|
21
|
+
import { renderHealthDashboard } from './blocks/health-dashboard.js';
|
|
22
|
+
import { renderOperationFeed } from './blocks/operation-feed.js';
|
|
23
|
+
import { renderWizardSurface } from './store-wizard.js';
|
|
24
|
+
import { organicFlowShader } from './shaders/organic-flow.js';
|
|
25
|
+
import { shortShaStatus } from './components/short-sha.js';
|
|
8
26
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
/** @typedef {import('./dashboard.js').DashModel} DashModel */
|
|
28
|
+
/** @typedef {import('./dashboard.js').DashDeps} DashDeps */
|
|
29
|
+
/** @typedef {import('./dashboard.js').DashSource} DashSource */
|
|
30
|
+
|
|
31
|
+
const BG = '#25313a';
|
|
32
|
+
const HELP_WIDTH = 58;
|
|
33
|
+
|
|
34
|
+
function sourceLabel(source) {
|
|
35
|
+
if (source.type === 'vault') { return 'vault'; }
|
|
36
|
+
if (source.type === 'ref') { return `ref ${source.ref}`; }
|
|
37
|
+
return `oid ${source.treeOid}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function textSurface(content, width, height) {
|
|
41
|
+
return parseAnsiToSurface(content, Math.max(1, width), Math.max(1, height));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function blank(width, height) {
|
|
45
|
+
return createSurface(Math.max(1, width), Math.max(1, height), { char: ' ', bg: BG });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function verticalRail(ctx, height) {
|
|
49
|
+
return textSurface(Array.from({ length: Math.max(1, height) }, () =>
|
|
50
|
+
themeText(ctx, '│', { tone: 'accent', bold: true })).join('\n'), 1, height);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function panel({ title, body, width, height, ctx, active = false }) {
|
|
54
|
+
const safeWidth = Math.max(4, width);
|
|
55
|
+
const safeHeight = Math.max(3, height);
|
|
56
|
+
const innerWidth = Math.max(1, safeWidth - 2);
|
|
57
|
+
const innerHeight = Math.max(1, safeHeight - 2);
|
|
58
|
+
const bodySurface = typeof body === 'string'
|
|
59
|
+
? textSurface(body, innerWidth, innerHeight)
|
|
60
|
+
: placeSurface(body, { width: innerWidth, height: innerHeight });
|
|
61
|
+
const boxed = boxSurface(bodySurface, {
|
|
62
|
+
ctx,
|
|
63
|
+
title,
|
|
64
|
+
width: safeWidth,
|
|
65
|
+
borderToken: ctx.theme.theme.border.secondary,
|
|
66
|
+
bgToken: ctx.theme.theme.surface.primary,
|
|
67
|
+
});
|
|
68
|
+
const placed = placeSurface(boxed, { width: safeWidth, height: safeHeight });
|
|
69
|
+
if (active) { placed.blit(verticalRail(ctx, safeHeight), 0, 0); }
|
|
70
|
+
return placed;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function metricLine(model, ctx) {
|
|
74
|
+
if (model.statsStatus === 'ready' && model.statsReport) {
|
|
75
|
+
return [
|
|
76
|
+
`${themeText(ctx, 'entries', { tone: 'accent' })} ${model.statsReport.entries}`,
|
|
77
|
+
`${themeText(ctx, 'dedup', { tone: 'accent' })} ${model.statsReport.dedupRatio.toFixed(2)}x`,
|
|
78
|
+
`${themeText(ctx, 'logical', { tone: 'accent' })} ${formatSize(model.statsReport.totalLogicalSize)}`,
|
|
79
|
+
`${themeText(ctx, 'encrypted', { tone: 'accent' })} ${model.statsReport.encryptedEntries}`,
|
|
80
|
+
].join(' ');
|
|
81
|
+
}
|
|
82
|
+
return [
|
|
83
|
+
`${themeText(ctx, 'entries', { tone: 'accent' })} ${model.entries.length}`,
|
|
84
|
+
`${themeText(ctx, 'loaded manifests', { tone: 'accent' })} ${model.manifestCache.size}`,
|
|
85
|
+
`${themeText(ctx, 'source', { tone: 'accent' })} ${sourceLabel(model.source)}`,
|
|
86
|
+
].join(' ');
|
|
87
|
+
}
|
|
15
88
|
|
|
16
|
-
/**
|
|
17
|
-
* Format bytes as compact string.
|
|
18
|
-
*
|
|
19
|
-
* @param {number} bytes
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
22
89
|
function formatSize(bytes) {
|
|
90
|
+
if (!Number.isFinite(bytes)) { return '-'; }
|
|
23
91
|
if (bytes < 1024) { return `${bytes}B`; }
|
|
24
92
|
if (bytes < 1024 * 1024) { return `${(bytes / 1024).toFixed(1)}K`; }
|
|
25
93
|
if (bytes < 1024 * 1024 * 1024) { return `${(bytes / (1024 * 1024)).toFixed(1)}M`; }
|
|
26
94
|
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}G`;
|
|
27
95
|
}
|
|
28
96
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
97
|
+
function workspaceTabs(model, ctx) {
|
|
98
|
+
const tabs = [
|
|
99
|
+
['explorer', '1 Explorer'],
|
|
100
|
+
['atlas', '2 Atlas'],
|
|
101
|
+
['operations', '3 Operations'],
|
|
102
|
+
];
|
|
103
|
+
return tabs.map(([id, label]) => {
|
|
104
|
+
const active = model.workspace === id;
|
|
105
|
+
return themeText(ctx, active ? `▌ ${label}` : ` ${label}`, { tone: active ? 'brand' : 'secondary', bold: active });
|
|
106
|
+
}).join(' ');
|
|
38
107
|
}
|
|
39
108
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
109
|
+
function renderHeaderSurface(model, deps, width) {
|
|
110
|
+
const left = themeText(deps.ctx, ' git-cas cockpit', { tone: 'brand', bold: true });
|
|
111
|
+
const center = workspaceTabs(model, deps.ctx);
|
|
112
|
+
const right = model.gitBranch ? themeText(deps.ctx, model.gitBranch, { tone: 'info' }) : themeText(deps.ctx, model.status, { tone: 'secondary' });
|
|
113
|
+
const first = statusBarSurface({ left, center, right, width });
|
|
114
|
+
const economics = statusBarSurface({
|
|
115
|
+
left: ` ${metricLine(model, deps.ctx)}`,
|
|
116
|
+
right: themeText(deps.ctx, sourceLabel(model.source), { tone: 'primary' }),
|
|
117
|
+
width,
|
|
118
|
+
});
|
|
119
|
+
const filter = model.filtering
|
|
120
|
+
? `${themeText(deps.ctx, 'filter', { tone: 'accent' })} /${model.filterText}█`
|
|
121
|
+
: `${themeText(deps.ctx, 'filter', { tone: 'accent' })} ${model.filterText ? `/${model.filterText}` : 'none'}`;
|
|
122
|
+
const third = statusBarSurface({
|
|
123
|
+
left: ` ${filter}`,
|
|
124
|
+
right: model.error ? themeText(deps.ctx, model.error, { tone: 'danger' }) : '',
|
|
125
|
+
width,
|
|
126
|
+
});
|
|
127
|
+
const rule = textSurface(shellRule(deps.ctx, width), width, 1);
|
|
128
|
+
return vstackSurface(first, economics, third, rule);
|
|
54
129
|
}
|
|
55
130
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
131
|
+
function renderFooterSurface(model, ctx, width) {
|
|
132
|
+
const left = model.quitConfirm
|
|
133
|
+
? themeText(ctx, 'Quit? y/enter confirm, n/escape cancel', { tone: 'warning' })
|
|
134
|
+
: themeText(ctx, '? help / filter ctrl+p palette F2 settings q quit', { tone: 'subdued' });
|
|
135
|
+
const rightByWorkspace = {
|
|
136
|
+
explorer: model.focusPane === 'detail'
|
|
137
|
+
? 'tab focus j/k chunk u/d page enter ledger'
|
|
138
|
+
: 'tab focus j/k rows enter detail m merkle',
|
|
139
|
+
atlas: 'j/k focus +/- drill t scope i ignored',
|
|
140
|
+
operations: 'n store s stats x doctor',
|
|
141
|
+
};
|
|
142
|
+
const detailStatus = selectedShaFooter(model);
|
|
143
|
+
const footer = statusBarSurface({
|
|
144
|
+
left: ` ${left}`,
|
|
145
|
+
right: detailStatus
|
|
146
|
+
? themeText(ctx, detailStatus, { tone: 'info' })
|
|
147
|
+
: themeText(ctx, rightByWorkspace[model.workspace], { tone: 'secondary' }),
|
|
148
|
+
width,
|
|
149
|
+
});
|
|
150
|
+
return vstackSurface(textSurface(shellRule(ctx, width), width, 1), footer);
|
|
67
151
|
}
|
|
68
152
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
153
|
+
export function tableSchema(width) {
|
|
154
|
+
if (width >= 110) {
|
|
155
|
+
const slugWidth = Math.max(18, Math.min(36, width - 82));
|
|
156
|
+
return {
|
|
157
|
+
columns: [
|
|
158
|
+
{ header: 'Slug', width: slugWidth },
|
|
159
|
+
{ header: 'Tree OID', width: 14 },
|
|
160
|
+
{ header: 'Size', width: 10 },
|
|
161
|
+
{ header: 'Chunks', width: 8 },
|
|
162
|
+
{ header: 'Crypto', width: 10 },
|
|
163
|
+
{ header: 'Format', width: 12 },
|
|
164
|
+
{ header: 'State', width: 8 },
|
|
165
|
+
],
|
|
166
|
+
indexes: [0, 1, 2, 3, 4, 5, 6],
|
|
167
|
+
};
|
|
80
168
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
169
|
+
if (width >= 72) {
|
|
170
|
+
const slugWidth = Math.max(18, Math.min(34, width - 48));
|
|
171
|
+
return {
|
|
172
|
+
columns: [
|
|
173
|
+
{ header: 'Slug', width: slugWidth },
|
|
174
|
+
{ header: 'Size', width: 10 },
|
|
175
|
+
{ header: 'Chunks', width: 8 },
|
|
176
|
+
{ header: 'Crypto', width: 10 },
|
|
177
|
+
{ header: 'State', width: 8 },
|
|
178
|
+
],
|
|
179
|
+
indexes: [0, 2, 3, 4, 6],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
columns: [
|
|
184
|
+
{ header: 'Slug', width: Math.max(12, width - 14) },
|
|
185
|
+
{ header: 'State', width: 8 },
|
|
186
|
+
],
|
|
187
|
+
indexes: [0, 6],
|
|
188
|
+
};
|
|
84
189
|
}
|
|
85
190
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
191
|
+
export function renderDashboard(model, deps) {
|
|
192
|
+
if (model.phase === 'title' || model.phase === 'password') {
|
|
193
|
+
return renderTitleScreen(model, deps);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const width = Math.max(1, model.columns);
|
|
197
|
+
const height = Math.max(1, model.rows);
|
|
198
|
+
const screen = createSurface(width, height, { char: ' ', bg: BG });
|
|
199
|
+
const header = renderHeaderSurface(model, deps, width);
|
|
200
|
+
const footer = renderFooterSurface(model, deps.ctx, width);
|
|
201
|
+
const bodyHeight = Math.max(1, height - header.height - footer.height);
|
|
202
|
+
const body = renderBody(model, deps, { width: Math.max(1, width - 1), height: bodyHeight });
|
|
203
|
+
|
|
204
|
+
screen.blit(vstackSurface(header, hstackSurface(0, verticalRail(deps.ctx, bodyHeight), body), footer), 0, 0);
|
|
205
|
+
renderOverlays(model, deps, { screen, width, height });
|
|
206
|
+
return screen;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function renderTitleScreen(model, deps) {
|
|
210
|
+
const { columns: width, rows: height } = model;
|
|
211
|
+
const screen = createSurface(width, height, { char: ' ', bg: BG });
|
|
212
|
+
const { ctx } = deps;
|
|
213
|
+
const innerW = Math.min(56, width);
|
|
214
|
+
|
|
215
|
+
screen.blit(canvas(width, height, organicFlowShader, {
|
|
216
|
+
time: (model.titleTimeMs ?? 0) / 1000,
|
|
217
|
+
resolution: 'braille',
|
|
218
|
+
uniforms: { entryCount: model.vaultEntryCount, width, height },
|
|
219
|
+
}), 0, 0);
|
|
220
|
+
|
|
221
|
+
if (model.showPerfHud) {
|
|
222
|
+
const fpsText = ` ${model.fps} FPS `;
|
|
223
|
+
const hud = parseAnsiToSurface(fpsText, fpsText.length, 1);
|
|
224
|
+
hud.fill({ char: ' ', bg: '#000000', fg: '#ffffff' });
|
|
225
|
+
screen.blit(hud, 0, 0);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const surfaces = titlePanelSurfaces(model, ctx, innerW);
|
|
229
|
+
|
|
230
|
+
const titlePanel = boxSurface(vstackSurface(...surfaces), {
|
|
231
|
+
width: innerW + 4,
|
|
232
|
+
padding: { left: 2, right: 2, top: 1, bottom: 1 },
|
|
233
|
+
ctx,
|
|
234
|
+
borderToken: ctx.theme.theme.border.primary,
|
|
235
|
+
bgToken: ctx.theme.theme.surface.overlay,
|
|
236
|
+
});
|
|
237
|
+
screen.blit(titlePanel, Math.max(0, Math.floor((width - titlePanel.width) / 2)), Math.max(0, Math.floor((height - titlePanel.height) / 3)));
|
|
238
|
+
return screen;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function titlePanelSurfaces(model, ctx, width) {
|
|
242
|
+
const heading = [
|
|
243
|
+
textSurface(themeText(ctx, 'git-cas', { tone: 'brand', bold: true }), width, 1),
|
|
244
|
+
textSurface(themeText(ctx, 'content-addressable storage', { tone: 'secondary' }), width, 1),
|
|
245
|
+
createSurface(1, 1),
|
|
246
|
+
];
|
|
247
|
+
return model.phase === 'title'
|
|
248
|
+
? heading.concat(titlePhaseSurfaces(model, ctx, width))
|
|
249
|
+
: heading.concat(passwordPhaseSurfaces(model, ctx, width));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function titlePhaseSurfaces(model, ctx, width) {
|
|
253
|
+
const status = model.promptEnter ? 'Vault is ready.' : 'Checking vault...';
|
|
254
|
+
const tone = model.promptEnter ? 'success' : 'subdued';
|
|
255
|
+
const surfaces = [textSurface(themeText(ctx, status, { tone }), width, 1)];
|
|
256
|
+
if (model.promptEnter) {
|
|
257
|
+
surfaces.push(createSurface(1, 1), textSurface(themeText(ctx, 'enter to continue | escape to quit', { tone: 'subdued' }), width, 1));
|
|
258
|
+
}
|
|
259
|
+
return surfaces;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function passwordPhaseSurfaces(model, ctx, width) {
|
|
263
|
+
const mask = '•'.repeat(model.passphrase.length);
|
|
264
|
+
const surfaces = [
|
|
265
|
+
textSurface(themeText(ctx, 'Vault is encrypted. Enter passphrase to unlock.', { tone: 'warning' }), width, 1),
|
|
266
|
+
createSurface(1, 1),
|
|
267
|
+
hstackSurface(1, createSurface(2, 1), textSurface(themeText(ctx, 'Passphrase:', { tone: 'accent' }), 11, 1), textSurface(`${mask}█`, Math.max(1, width - 14), 1)),
|
|
268
|
+
];
|
|
269
|
+
if (model.authError) {
|
|
270
|
+
surfaces.push(createSurface(1, 1), hstackSurface(1, createSurface(2, 1), textSurface(themeText(ctx, model.authError, { tone: 'danger' }), Math.max(1, width - 3), 1)));
|
|
271
|
+
}
|
|
272
|
+
surfaces.push(createSurface(1, 1), textSurface(themeText(ctx, 'enter to unlock | escape to quit', { tone: 'subdued' }), width, 1));
|
|
273
|
+
return surfaces;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function renderBody(model, deps, options) {
|
|
277
|
+
if (model.workspace === 'atlas') { return renderAtlasWorkspace(model, deps, options); }
|
|
278
|
+
if (model.workspace === 'operations') { return renderOperationsWorkspace(model, deps, options); }
|
|
279
|
+
return renderExplorerWorkspace(model, deps, options);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function renderExplorerWorkspace(model, deps, options) {
|
|
283
|
+
if (options.width < 88) {
|
|
284
|
+
const ledgerHeight = Math.max(8, Math.floor(options.height * 0.52));
|
|
285
|
+
const detailHeight = Math.max(4, options.height - ledgerHeight - 1);
|
|
286
|
+
return vstackSurface(
|
|
287
|
+
renderLedgerPanel(model, deps.ctx, { width: options.width, height: ledgerHeight }),
|
|
288
|
+
blank(options.width, 1),
|
|
289
|
+
renderInspectorPanel(model, deps.ctx, { width: options.width, height: detailHeight }),
|
|
106
290
|
);
|
|
107
|
-
return padToHeight(msg, listHeight, filterLine);
|
|
108
291
|
}
|
|
292
|
+
const gap = 2;
|
|
293
|
+
const ledgerWidth = Math.max(36, Math.floor(options.width * 0.47));
|
|
294
|
+
const inspectorWidth = Math.max(24, options.width - ledgerWidth - gap);
|
|
295
|
+
return hstackSurface(
|
|
296
|
+
gap,
|
|
297
|
+
renderLedgerPanel(model, deps.ctx, { width: ledgerWidth, height: options.height }),
|
|
298
|
+
renderInspectorPanel(model, deps.ctx, { width: inspectorWidth, height: options.height }),
|
|
299
|
+
);
|
|
300
|
+
}
|
|
109
301
|
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
302
|
+
function renderLedgerPanel(model, ctx, box) {
|
|
303
|
+
const { width, height } = box;
|
|
304
|
+
const schema = tableSchema(Math.max(20, width - 2));
|
|
305
|
+
const projectedRows = model.table.rows.map((row) => schema.indexes.map((index) => row[index] ?? ''));
|
|
306
|
+
const tableSurface = navigableTableSurface({
|
|
307
|
+
columns: schema.columns,
|
|
308
|
+
rows: projectedRows,
|
|
309
|
+
focusRow: model.table.focusRow,
|
|
310
|
+
scrollY: model.table.scrollY,
|
|
311
|
+
height: Math.max(1, height - 5),
|
|
312
|
+
}, { ctx });
|
|
313
|
+
return panel({ title: 'Asset Ledger', body: tableSurface, width, height, ctx, active: model.focusPane === 'ledger' });
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function selectedEntry(model) {
|
|
317
|
+
return model.filtered[Math.min(model.table.focusRow, Math.max(0, model.filtered.length - 1))] ?? null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function manifestData(manifest) {
|
|
321
|
+
return manifest?.toJSON ? manifest.toJSON() : manifest;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function selectedManifest(model) {
|
|
325
|
+
const entry = selectedEntry(model);
|
|
326
|
+
return entry ? manifestData(model.manifestCache.get(entry.slug)) : null;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function selectedChunk(model) {
|
|
330
|
+
const chunks = selectedManifest(model)?.chunks ?? [];
|
|
331
|
+
const index = Math.max(0, Math.min(model.chunkFocus ?? 0, Math.max(0, chunks.length - 1)));
|
|
332
|
+
return chunks[index] ?? null;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function selectedShaFooter(model) {
|
|
336
|
+
if (model.workspace !== 'explorer' || model.focusPane !== 'detail') { return null; }
|
|
337
|
+
const chunk = selectedChunk(model);
|
|
338
|
+
if (!chunk) { return null; }
|
|
339
|
+
const digest = shortShaStatus('digest', chunk.digest);
|
|
340
|
+
const blob = shortShaStatus('blob', chunk.blob);
|
|
341
|
+
return [`#${chunk.index}`, digest, blob].filter(Boolean).join(' ');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function renderInspectorPanel(model, ctx, box) {
|
|
345
|
+
const { width, height } = box;
|
|
346
|
+
const entry = selectedEntry(model);
|
|
347
|
+
const manifest = selectedManifest(model);
|
|
348
|
+
if (!entry) {
|
|
349
|
+
return panel({ title: 'Inspector', body: 'No asset selected.', width, height, ctx, active: model.focusPane === 'detail' });
|
|
350
|
+
}
|
|
351
|
+
if (model.explorerMode === 'merkle') {
|
|
352
|
+
return panel({
|
|
353
|
+
title: `Merkle Lens [${model.merkleMode}]`,
|
|
354
|
+
body: renderMerkleBody({ model, manifest, ctx, box: { width, height } }),
|
|
355
|
+
width,
|
|
356
|
+
height,
|
|
357
|
+
ctx,
|
|
358
|
+
active: model.focusPane === 'detail',
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (model.explorerMode === 'manifest') {
|
|
362
|
+
const body = manifest
|
|
363
|
+
? renderManifestDetail({ model, manifest, ctx, box: { width, height } })
|
|
364
|
+
: `Loading manifest for ${entry.slug}...\n${entry.treeOid}`;
|
|
365
|
+
return panel({ title: 'Manifest Ledger', body, width, height, ctx, active: model.focusPane === 'detail' });
|
|
114
366
|
}
|
|
115
|
-
return
|
|
367
|
+
return panel({ title: 'Inspector', body: renderInspectorBody(entry, manifest, ctx), width, height, ctx, active: model.focusPane === 'detail' });
|
|
116
368
|
}
|
|
117
369
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
370
|
+
function renderInspectorBody(entry, manifest, ctx) {
|
|
371
|
+
const lines = [
|
|
372
|
+
`${themeText(ctx, 'slug', { tone: 'accent' })} ${entry.slug}`,
|
|
373
|
+
`${themeText(ctx, 'tree', { tone: 'accent' })} ${entry.treeOid}`,
|
|
374
|
+
];
|
|
375
|
+
if (!manifest) {
|
|
376
|
+
lines.push('', themeText(ctx, 'manifest pending', { tone: 'subdued' }));
|
|
377
|
+
return lines.join('\n');
|
|
378
|
+
}
|
|
379
|
+
lines.push(
|
|
380
|
+
`${themeText(ctx, 'size', { tone: 'accent' })} ${formatSize(manifest.size)}`,
|
|
381
|
+
`${themeText(ctx, 'chunks', { tone: 'accent' })} ${manifest.chunks?.length ?? 0}`,
|
|
382
|
+
`${themeText(ctx, 'crypto', { tone: 'accent' })} ${manifest.encryption ? 'encrypted' : 'plaintext'}`,
|
|
383
|
+
`${themeText(ctx, 'compress', { tone: 'accent' })} ${manifest.compression?.algorithm ?? 'none'}`,
|
|
384
|
+
`${themeText(ctx, 'format', { tone: 'accent' })} ${manifest.formatVersion ?? manifest.version ?? '-'}`,
|
|
385
|
+
'',
|
|
386
|
+
themeText(ctx, 'enter detail | tab detail focus | ctrl+p digest search', { tone: 'subdued' }),
|
|
387
|
+
);
|
|
388
|
+
return lines.join('\n');
|
|
130
389
|
}
|
|
131
390
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
*
|
|
135
|
-
* @param {DashModel} model
|
|
136
|
-
* @param {{ width: number, height: number, ctx: BijouContext }} opts
|
|
137
|
-
* @returns {string}
|
|
138
|
-
*/
|
|
139
|
-
function renderDetailPane(model, opts) {
|
|
140
|
-
const entry = model.filtered[model.cursor];
|
|
141
|
-
if (!entry) { return ''; }
|
|
142
|
-
const manifest = model.manifestCache.get(entry.slug);
|
|
143
|
-
if (!manifest) { return 'Loading manifest...'; }
|
|
144
|
-
const content = renderManifestView({ manifest, ctx: opts.ctx });
|
|
145
|
-
return viewport({ width: opts.width, height: opts.height, content, scrollY: model.detailScroll });
|
|
391
|
+
function pageSizeForDetail(height) {
|
|
392
|
+
return Math.max(1, height - 15);
|
|
146
393
|
}
|
|
147
394
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
395
|
+
function renderManifestDetail({ model, manifest, ctx, box }) {
|
|
396
|
+
const chunks = manifest.chunks ?? [];
|
|
397
|
+
const lines = [
|
|
398
|
+
themeText(ctx, 'Asset', { tone: 'accent', bold: true }),
|
|
399
|
+
`${themeText(ctx, 'slug', { tone: 'accent' })} ${manifest.slug ?? '-'}`,
|
|
400
|
+
`${themeText(ctx, 'filename', { tone: 'accent' })} ${manifest.filename ?? '-'}`,
|
|
401
|
+
`${themeText(ctx, 'size', { tone: 'accent' })} ${formatSize(manifest.size)}`,
|
|
402
|
+
`${themeText(ctx, 'crypto', { tone: 'accent' })} ${manifest.encryption ? 'encrypted' : 'plaintext'}`,
|
|
403
|
+
`${themeText(ctx, 'chunks', { tone: 'accent' })} ${chunks.length}`,
|
|
404
|
+
'',
|
|
405
|
+
themeText(ctx, `Chunk Ledger (${chunks.length})`, { tone: 'info', bold: true }),
|
|
406
|
+
];
|
|
407
|
+
if (chunks.length === 0) { return lines.concat('No chunks.').join('\n'); }
|
|
408
|
+
return lines.concat(renderChunkTable(manifest, ctx, {
|
|
409
|
+
selectedIndex: Math.min(model.chunkFocus ?? 0, chunks.length - 1),
|
|
410
|
+
pageSize: pageSizeForDetail(box.height),
|
|
411
|
+
width: Math.max(24, box.width - 4),
|
|
412
|
+
})).join('\n');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function renderMerkleBody({ model, manifest, ctx, box }) {
|
|
416
|
+
if (!manifest) { return 'No manifest loaded.'; }
|
|
417
|
+
const tabs = ['table', 'tree', 'dag']
|
|
418
|
+
.map((item) => item === model.merkleMode ? `[${item}]` : ` ${item} `)
|
|
419
|
+
.join(' ');
|
|
420
|
+
if (model.merkleMode !== 'table') {
|
|
421
|
+
return `${themeText(ctx, tabs, { tone: 'accent' })}\n\n${renderMerkleExplorer(manifest, model.merkleMode, ctx)}`;
|
|
422
|
+
}
|
|
423
|
+
return `${themeText(ctx, tabs, { tone: 'accent' })}\n\n${renderChunkTable(manifest, ctx, {
|
|
424
|
+
selectedIndex: Math.min(model.chunkFocus ?? 0, (manifest.chunks?.length ?? 1) - 1),
|
|
425
|
+
pageSize: pageSizeForDetail(box.height),
|
|
426
|
+
width: Math.max(24, box.width - 4),
|
|
427
|
+
})}`;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function renderAtlasWorkspace(model, deps, options) {
|
|
431
|
+
const gap = options.width >= 76 ? 2 : 1;
|
|
432
|
+
const sidebarWidth = Math.min(44, Math.max(28, Math.floor(options.width * 0.34)));
|
|
433
|
+
const mapWidth = Math.max(20, options.width - sidebarWidth - gap);
|
|
434
|
+
if (!model.treemapReport) {
|
|
435
|
+
const body = model.treemapStatus === 'error'
|
|
436
|
+
? `Atlas unavailable\n\n${model.treemapError}`
|
|
437
|
+
: 'Loading repository atlas...';
|
|
438
|
+
return panel({ title: 'Repository Atlas', body, width: options.width, height: options.height, ctx: deps.ctx });
|
|
439
|
+
}
|
|
440
|
+
const selected = model.treemapReport.tiles?.[model.treemapFocus]?.id ?? null;
|
|
441
|
+
const map = renderRepoTreemapMap(model.treemapReport, {
|
|
442
|
+
ctx: deps.ctx,
|
|
443
|
+
width: Math.max(12, mapWidth - 2),
|
|
444
|
+
height: Math.max(4, options.height - 2),
|
|
445
|
+
selectedTileId: selected,
|
|
446
|
+
});
|
|
447
|
+
const sidebar = renderRepoTreemapSidebar(model.treemapReport, {
|
|
448
|
+
ctx: deps.ctx,
|
|
449
|
+
width: Math.max(16, sidebarWidth - 2),
|
|
450
|
+
height: Math.max(4, options.height - 2),
|
|
451
|
+
selectedTileId: selected,
|
|
452
|
+
});
|
|
453
|
+
const briefing = [
|
|
454
|
+
themeText(deps.ctx, 'Overview', { tone: 'accent', bold: true }),
|
|
455
|
+
sidebar.overview,
|
|
456
|
+
'',
|
|
457
|
+
themeText(deps.ctx, 'Focused Region', { tone: 'accent', bold: true }),
|
|
458
|
+
sidebar.focused,
|
|
459
|
+
'',
|
|
460
|
+
themeText(deps.ctx, 'Legend', { tone: 'accent', bold: true }),
|
|
461
|
+
sidebar.legend,
|
|
462
|
+
'',
|
|
463
|
+
themeText(deps.ctx, 'Largest Regions', { tone: 'accent', bold: true }),
|
|
464
|
+
sidebar.regions,
|
|
465
|
+
'',
|
|
466
|
+
sidebar.notes,
|
|
467
|
+
].filter(Boolean).join('\n');
|
|
468
|
+
return hstackSurface(
|
|
469
|
+
gap,
|
|
470
|
+
panel({ title: 'Repository Atlas', body: map, width: mapWidth, height: options.height, ctx: deps.ctx }),
|
|
471
|
+
panel({ title: 'Atlas Briefing', body: briefing, width: sidebarWidth, height: options.height, ctx: deps.ctx }),
|
|
162
472
|
);
|
|
163
473
|
}
|
|
164
474
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
{
|
|
475
|
+
function renderOperationsWorkspace(model, deps, options) {
|
|
476
|
+
if (options.width < 100) {
|
|
477
|
+
const topHeight = Math.max(8, Math.floor(options.height / 2));
|
|
478
|
+
return vstackSurface(
|
|
479
|
+
renderEconomicsPanel(model, deps.ctx, { width: options.width, height: topHeight }),
|
|
480
|
+
renderOpsDetailPanel(model, deps.ctx, { width: options.width, height: Math.max(4, options.height - topHeight) }),
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
const gap = 2;
|
|
484
|
+
const leftWidth = Math.max(30, Math.floor((options.width - gap) * 0.42));
|
|
485
|
+
const rightWidth = Math.max(30, options.width - leftWidth - gap);
|
|
486
|
+
return hstackSurface(
|
|
487
|
+
gap,
|
|
488
|
+
renderEconomicsPanel(model, deps.ctx, { width: leftWidth, height: options.height }),
|
|
489
|
+
renderOpsDetailPanel(model, deps.ctx, { width: rightWidth, height: options.height }),
|
|
180
490
|
);
|
|
181
491
|
}
|
|
492
|
+
|
|
493
|
+
function renderEconomicsPanel(model, ctx, box) {
|
|
494
|
+
const { width, height } = box;
|
|
495
|
+
const body = model.statsStatus === 'ready' && model.statsReport
|
|
496
|
+
? renderStats(model.statsReport, ctx)
|
|
497
|
+
: `${themeText(ctx, 'Vault Economics', { tone: 'brand', bold: true })}\n\nStats are ${model.statsStatus}. Press s to refresh.`;
|
|
498
|
+
return panel({ title: 'Vault Economics', body, width, height, ctx });
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function renderStats(stats, ctx) {
|
|
502
|
+
const chunking = Object.entries(stats.chunkingStrategies ?? {})
|
|
503
|
+
.map(([strategy, count]) => `${strategy}:${count}`)
|
|
504
|
+
.join(', ') || '-';
|
|
505
|
+
return [
|
|
506
|
+
`${themeText(ctx, 'entries', { tone: 'accent' })} ${stats.entries}`,
|
|
507
|
+
`${themeText(ctx, 'logical size', { tone: 'accent' })} ${formatSize(stats.totalLogicalSize)}`,
|
|
508
|
+
`${themeText(ctx, 'chunk refs', { tone: 'accent' })} ${stats.totalChunkRefs}`,
|
|
509
|
+
`${themeText(ctx, 'unique chunks', { tone: 'accent' })} ${stats.uniqueChunks}`,
|
|
510
|
+
`${themeText(ctx, 'duplicate refs', { tone: 'accent' })} ${stats.duplicateChunkRefs}`,
|
|
511
|
+
`${themeText(ctx, 'dedup ratio', { tone: 'accent' })} ${stats.dedupRatio.toFixed(2)}x`,
|
|
512
|
+
`${themeText(ctx, 'encrypted', { tone: 'accent' })} ${stats.encryptedEntries}`,
|
|
513
|
+
`${themeText(ctx, 'compressed', { tone: 'accent' })} ${stats.compressedEntries}`,
|
|
514
|
+
`${themeText(ctx, 'chunking', { tone: 'accent' })} ${chunking}`,
|
|
515
|
+
].join('\n');
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function renderOpsDetailPanel(model, ctx, box) {
|
|
519
|
+
const { width, height } = box;
|
|
520
|
+
const doctor = model.doctorStatus === 'ready' && model.doctorReport
|
|
521
|
+
? (typeof model.doctorReport === 'string' ? model.doctorReport : renderHealthDashboard(model.doctorReport, ctx))
|
|
522
|
+
: `Doctor status: ${model.doctorStatus}\nPress x to run a sweep.`;
|
|
523
|
+
const feed = renderOperationFeed(model.operationFeed, ctx);
|
|
524
|
+
return panel({
|
|
525
|
+
title: 'Operations Deck',
|
|
526
|
+
body: `${doctor}\n\n${themeText(ctx, 'Operation Feed', { tone: 'accent', bold: true })}\n${feed}`,
|
|
527
|
+
width,
|
|
528
|
+
height,
|
|
529
|
+
ctx,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function renderOverlays(model, deps, options) {
|
|
534
|
+
if (model.settingsOpen) {
|
|
535
|
+
blitOverlay(options.screen, renderSettingsDrawer(model, deps, options));
|
|
536
|
+
}
|
|
537
|
+
if (model.palette) {
|
|
538
|
+
const width = Math.min(84, Math.max(24, options.width - 6));
|
|
539
|
+
const palette = panel({
|
|
540
|
+
title: 'Command Palette',
|
|
541
|
+
body: commandPaletteSurface(model.palette, { width: width - 2, ctx: deps.ctx, showScrollbar: true }),
|
|
542
|
+
width,
|
|
543
|
+
height: Math.min(14, options.height - 4),
|
|
544
|
+
ctx: deps.ctx,
|
|
545
|
+
});
|
|
546
|
+
options.screen.blit(palette, centerX(options.width, palette.width), topThirdY(options.height, palette.height));
|
|
547
|
+
}
|
|
548
|
+
if (model.showHelp) {
|
|
549
|
+
const help = renderHelpSurface(model, deps.ctx, { width: Math.min(HELP_WIDTH, options.width - 4), height: Math.min(20, options.height - 4) });
|
|
550
|
+
options.screen.blit(help, centerX(options.width, help.width), topThirdY(options.height, help.height));
|
|
551
|
+
}
|
|
552
|
+
if (model.storeWizard) {
|
|
553
|
+
const wizard = renderWizardSurface(model.storeWizard, { width: options.width, height: options.height, ctx: deps.ctx });
|
|
554
|
+
options.screen.blit(wizard, centerX(options.width, wizard.width), topThirdY(options.height, wizard.height));
|
|
555
|
+
}
|
|
556
|
+
if (model.quitConfirm) {
|
|
557
|
+
blitOverlay(options.screen, modal({
|
|
558
|
+
title: 'Quit git-cas?',
|
|
559
|
+
body: 'Leave the cockpit session now?',
|
|
560
|
+
hint: 'Y / Enter confirm | N / Esc cancel',
|
|
561
|
+
width: Math.min(52, options.width - 4),
|
|
562
|
+
screenWidth: options.width,
|
|
563
|
+
screenHeight: options.height,
|
|
564
|
+
borderToken: deps.ctx.theme.theme.border.warning,
|
|
565
|
+
bgToken: deps.ctx.theme.theme.surface.overlay,
|
|
566
|
+
ctx: deps.ctx,
|
|
567
|
+
}));
|
|
568
|
+
}
|
|
569
|
+
for (const overlay of renderNotificationStack(model.notifications, {
|
|
570
|
+
screenWidth: options.width,
|
|
571
|
+
screenHeight: options.height,
|
|
572
|
+
ctx: deps.ctx,
|
|
573
|
+
margin: 1,
|
|
574
|
+
gap: 1,
|
|
575
|
+
})) {
|
|
576
|
+
blitOverlay(options.screen, overlay);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function vaultStatus(model) {
|
|
581
|
+
if (model.metadata?.encryption && model.vaultEncryptionKey) { return 'encrypted / unlocked'; }
|
|
582
|
+
if (model.metadata?.encryption) { return 'encrypted / locked'; }
|
|
583
|
+
return 'plaintext vault';
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function renderSettingsDrawer(model, deps, options) {
|
|
587
|
+
const { ctx } = deps;
|
|
588
|
+
const body = [
|
|
589
|
+
themeText(ctx, 'Cockpit Settings', { tone: 'brand', bold: true }),
|
|
590
|
+
'',
|
|
591
|
+
`${themeText(ctx, 'theme', { tone: 'accent' })} bright cockpit`,
|
|
592
|
+
`${themeText(ctx, 'workspace', { tone: 'accent' })} ${model.workspace}`,
|
|
593
|
+
`${themeText(ctx, 'focus', { tone: 'accent' })} ${model.focusPane ?? '-'}`,
|
|
594
|
+
`${themeText(ctx, 'source', { tone: 'accent' })} ${sourceLabel(model.source)}`,
|
|
595
|
+
`${themeText(ctx, 'vault', { tone: 'accent' })} ${vaultStatus(model)}`,
|
|
596
|
+
`${themeText(ctx, 'short SHA', { tone: 'accent' })} selected chunk expands in footer`,
|
|
597
|
+
'',
|
|
598
|
+
themeText(ctx, 'F2 closes this drawer.', { tone: 'subdued' }),
|
|
599
|
+
].join('\n');
|
|
600
|
+
return drawer({
|
|
601
|
+
content: body,
|
|
602
|
+
anchor: 'right',
|
|
603
|
+
width: Math.min(46, Math.max(28, options.width - 4)),
|
|
604
|
+
screenWidth: options.width,
|
|
605
|
+
screenHeight: options.height,
|
|
606
|
+
title: 'Settings',
|
|
607
|
+
borderToken: ctx.theme.theme.border.primary,
|
|
608
|
+
bgToken: ctx.theme.theme.surface.overlay,
|
|
609
|
+
ctx,
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function renderHelpSurface(model, ctx, box) {
|
|
614
|
+
const lines = [
|
|
615
|
+
themeText(ctx, 'Frame', { tone: 'accent', bold: true }),
|
|
616
|
+
'1/e Explorer 2/a Atlas 3/o Operations',
|
|
617
|
+
'? Help F2 Settings q Quit',
|
|
618
|
+
'Esc Close overlay',
|
|
619
|
+
'',
|
|
620
|
+
themeText(ctx, 'Explorer', { tone: 'accent', bold: true }),
|
|
621
|
+
'Tab focus / Filter Ctrl+P Search digest',
|
|
622
|
+
'j/k rows/chunks u/d page Enter detail',
|
|
623
|
+
'm Merkle lens i Inspector mode',
|
|
624
|
+
'',
|
|
625
|
+
themeText(ctx, 'Atlas', { tone: 'accent', bold: true }),
|
|
626
|
+
'j/k focus + Drill in - Drill out',
|
|
627
|
+
't Scope i Path mode r Reload',
|
|
628
|
+
'',
|
|
629
|
+
themeText(ctx, 'Operations', { tone: 'accent', bold: true }),
|
|
630
|
+
'n Store wizard s Stats x Doctor',
|
|
631
|
+
'',
|
|
632
|
+
`Active workspace: ${model.workspace}`,
|
|
633
|
+
];
|
|
634
|
+
return panel({ title: 'Help', body: lines.join('\n'), width: box.width, height: box.height, ctx });
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function blitOverlay(screen, overlay) {
|
|
638
|
+
const surface = overlay.surface ?? textSurface(overlay.content, Math.max(1, overlay.content.split('\n').reduce((max, line) => Math.max(max, line.length), 0)), overlay.content.split('\n').length);
|
|
639
|
+
screen.blit(surface, overlay.col, overlay.row);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function centerX(containerWidth, overlayWidth) {
|
|
643
|
+
return Math.max(0, Math.floor((containerWidth - overlayWidth) / 2));
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
function topThirdY(containerHeight, overlayHeight) {
|
|
647
|
+
return Math.max(0, Math.floor((containerHeight - overlayHeight) / 3));
|
|
648
|
+
}
|