@llman-sdd/cli 0.10.1 → 0.12.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/package.json +13 -5
- package/src/cli-shared.ts +87 -62
- package/src/commands/archive.ts +4 -19
- package/src/commands/change.ts +132 -172
- package/src/commands/config.ts +1 -29
- package/src/commands/init.ts +39 -11
- package/src/commands/list.ts +0 -2
- package/src/commands/project.ts +25 -115
- package/src/commands/review.ts +0 -1
- package/src/commands/self.ts +3 -1
- package/src/commands/show.ts +8 -46
- package/src/commands/spec.ts +6 -86
- package/src/commands/studio.ts +1315 -0
- package/src/commands/studioMcp.ts +862 -0
- package/src/commands/studioShared.ts +87 -0
- package/src/commands/theorem-write.ts +608 -0
- package/src/commands/theorem.ts +479 -0
- package/src/commands/validate.ts +108 -47
- package/src/io.ts +0 -1
- package/src/main.ts +3 -18
- package/src/program.ts +16 -16
- package/src/progress.ts +1 -3
- package/src/studio-server/changeScope.ts +295 -0
- package/src/studio-server/hub.ts +98 -0
- package/src/studio-server/negotiate.ts +60 -0
- package/src/studio-server/security.ts +71 -0
- package/src/studio-server/server.ts +1694 -0
- package/src/studio-server/static.ts +184 -0
- package/src/studio-server/syncDisk.ts +116 -0
- package/src/theorems/base.ts +53 -0
- package/src/theorems/diagnose.ts +90 -0
- package/src/theorems/draft.ts +252 -0
- package/src/theorems/os-lock.ts +364 -0
- package/src/theorems/paths.ts +11 -0
- package/src/theorems/prompts.ts +79 -0
- package/src/theorems/quiet.ts +21 -0
- package/src/theorems/runner.ts +48 -0
- package/src/theorems/transaction.ts +272 -0
- package/src/theorems/workspace.ts +103 -0
- package/studio-dist/index.html +14 -0
- package/studio-dist/static/css/index.00cf48cf.css +1 -0
- package/studio-dist/static/js/610.51883f69.js +218 -0
- package/studio-dist/static/js/610.51883f69.js.LICENSE.txt +26 -0
- package/studio-dist/static/js/index.c5f7c530.js +13 -0
- package/studio-dist/static/js/lib-react.a4b07007.js +2 -0
- package/studio-dist/static/js/lib-react.a4b07007.js.LICENSE.txt +49 -0
- package/src/commands/context.ts +0 -88
- package/src/commands/index.ts +0 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llman-sdd/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Spec-driven development workflow CLI (the `llman-sdd` command)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"llman-sdd": "./src/main.ts"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"src"
|
|
15
|
+
"src",
|
|
16
|
+
"studio-dist"
|
|
16
17
|
],
|
|
17
18
|
"type": "module",
|
|
18
19
|
"exports": {
|
|
@@ -24,11 +25,18 @@
|
|
|
24
25
|
"format:check": "bun run --cwd ../.. format:check",
|
|
25
26
|
"format:write": "bun run --cwd ../.. format:write",
|
|
26
27
|
"typecheck": "bun run --cwd ../.. typecheck",
|
|
27
|
-
"build": "bun run ./scripts/build-binary.ts"
|
|
28
|
+
"build": "bun run ./scripts/build-binary.ts",
|
|
29
|
+
"sync:studio-dist": "bun run ./scripts/sync-studio-dist.ts",
|
|
30
|
+
"prepack": "bun run ./scripts/sync-studio-dist.ts"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
33
|
+
"@hono/node-server": "^1.19.6",
|
|
34
|
+
"@inquirer/prompts": "^8.8.1",
|
|
35
|
+
"@llman-sdd/core": "0.12.0",
|
|
36
|
+
"@modelcontextprotocol/server": "^2.4.0",
|
|
37
|
+
"commander": "^15.1.0",
|
|
38
|
+
"hono": "^4.10.6",
|
|
39
|
+
"zod": "^4.6.7"
|
|
32
40
|
},
|
|
33
41
|
"engines": {
|
|
34
42
|
"bun": ">=1.4.0",
|
package/src/cli-shared.ts
CHANGED
|
@@ -8,8 +8,11 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
8
8
|
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
+
ChangeIdResolveError,
|
|
12
|
+
collectChanges,
|
|
11
13
|
discoverSpecs,
|
|
12
14
|
embeddedTemplates,
|
|
15
|
+
formatCliHint,
|
|
13
16
|
loadConfig,
|
|
14
17
|
loadConfigDetail,
|
|
15
18
|
makeEmbeddedTemplateIo,
|
|
@@ -18,7 +21,9 @@ import {
|
|
|
18
21
|
resolveInstanceRoot,
|
|
19
22
|
renderMachine,
|
|
20
23
|
semverLt,
|
|
24
|
+
shouldEmitCliHint,
|
|
21
25
|
specsPrefixOfInstance,
|
|
26
|
+
type CliHint,
|
|
22
27
|
type TemplateIo,
|
|
23
28
|
} from '@llman-sdd/core';
|
|
24
29
|
import type { Command } from 'commander';
|
|
@@ -26,8 +31,6 @@ import type { Command } from 'commander';
|
|
|
26
31
|
import pkg from '../package.json' with { type: 'json' };
|
|
27
32
|
import { makeCliGit, makeIo } from './io.ts';
|
|
28
33
|
|
|
29
|
-
// Re-exported so leaf consumers (e.g. regression gates under tests/) can type
|
|
30
|
-
// against the commander surface without resolving 'commander' themselves.
|
|
31
34
|
export type { Command } from 'commander';
|
|
32
35
|
|
|
33
36
|
/**
|
|
@@ -48,14 +51,7 @@ export function makeCliContext(cwd: string = process.cwd()): CliContext {
|
|
|
48
51
|
return { io: makeIo(cwd), git: makeCliGit(cwd), root: cwd, cwd };
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
// single-file binary has no on-disk package.json to read); binary builds
|
|
53
|
-
// additionally override it through the LLMAN_SDD_VERSION define injected by
|
|
54
|
-
// scripts/build-binary.ts (git tag > package version).
|
|
55
|
-
|
|
56
|
-
// Injected at binary build time by scripts/build-binary.ts; falls back to the
|
|
57
|
-
// package version when running from source.
|
|
58
|
-
const baseVersion = process.env.LLMAN_SDD_VERSION ?? pkg.version;
|
|
54
|
+
const baseVersion = process.env.LLMAN_SDD_DEV_BUILD_VERSION ?? pkg.version;
|
|
59
55
|
|
|
60
56
|
/**
|
|
61
57
|
* Dev-tree marker (`+dirty.N`): appended when the checkout has uncommitted
|
|
@@ -66,7 +62,7 @@ const baseVersion = process.env.LLMAN_SDD_VERSION ?? pkg.version;
|
|
|
66
62
|
let dirtySuffix: string | null | undefined;
|
|
67
63
|
|
|
68
64
|
function computeDirtySuffix(): string {
|
|
69
|
-
// Dual-runtime surface: `node:child_process.spawnSync` (not `Bun.spawnSync`).
|
|
65
|
+
// Dual-runtime surface: `node:child_process.spawnSync` (not `Bun.spawnSync`). ~keep
|
|
70
66
|
// It reports a missing git binary through `error` and a non-zero exit through
|
|
71
67
|
// `status` instead of throwing, so the degradation is explicit — a wide catch
|
|
72
68
|
// around this block would also swallow ReferenceError from the parsing below.
|
|
@@ -90,14 +86,14 @@ export function versionDisplay(): string {
|
|
|
90
86
|
/** Package version without the dirty suffix (drift comparison baseline). */
|
|
91
87
|
export const version: string = baseVersion;
|
|
92
88
|
|
|
93
|
-
// Compiled single-file binaries have no on-disk templates and Bun <= 1.4.x has
|
|
89
|
+
// Compiled single-file binaries have no on-disk templates and Bun <= 1.4.x has ~keep
|
|
94
90
|
// no embedding mechanism, so scripts/build-binary.ts injects the template
|
|
95
|
-
// table through the literal define `process.env.
|
|
91
|
+
// table through the literal define `process.env.LLMAN_SDD_DEV_BUILD_EMBEDDED_TEMPLATES`
|
|
96
92
|
// (define only rewrites literal member access — the read must stay here, not
|
|
97
93
|
// in core); every non-compiled run keeps reading the real filesystem (npm/
|
|
98
94
|
// source/Node). Both init and `review --export-html` resolve through this one
|
|
99
95
|
// seam.
|
|
100
|
-
const embedded = embeddedTemplates(process.env.
|
|
96
|
+
const embedded = embeddedTemplates(process.env.LLMAN_SDD_DEV_BUILD_EMBEDDED_TEMPLATES);
|
|
101
97
|
export const templateIo: TemplateIo = embedded
|
|
102
98
|
? makeEmbeddedTemplateIo(embedded)
|
|
103
99
|
: {
|
|
@@ -123,6 +119,53 @@ export class CliError extends Error {
|
|
|
123
119
|
}
|
|
124
120
|
}
|
|
125
121
|
|
|
122
|
+
function levenshtein(a: string, b: string): number {
|
|
123
|
+
const m = a.length;
|
|
124
|
+
const n = b.length;
|
|
125
|
+
const dp: number[][] = Array.from({ length: m + 1 }, () =>
|
|
126
|
+
Array.from({ length: n + 1 }, () => 0),
|
|
127
|
+
);
|
|
128
|
+
for (let i = 0; i <= m; i++) dp[i]![0] = i;
|
|
129
|
+
for (let j = 0; j <= n; j++) dp[0]![j] = j;
|
|
130
|
+
for (let i = 1; i <= m; i++) {
|
|
131
|
+
for (let j = 1; j <= n; j++) {
|
|
132
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
133
|
+
dp[i]![j] = Math.min(dp[i - 1]![j]! + 1, dp[i]![j - 1]! + 1, dp[i - 1]![j - 1]! + cost);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return dp[m]![n]!;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Deterministic not-found candidates: prefix (lexicographic), then substring
|
|
141
|
+
* (non-prefix, lexicographic), then edit distance <= 2 (distance then lex).
|
|
142
|
+
* Case-sensitive. At most `limit` entries. Same input always same output.
|
|
143
|
+
*/
|
|
144
|
+
export function pickNotFoundCandidates(query: string, ids: readonly string[], limit = 5): string[] {
|
|
145
|
+
const unique = [...new Set(ids)];
|
|
146
|
+
const byLex = (a: string, b: string): number => a.localeCompare(b);
|
|
147
|
+
const prefix = unique.filter((id) => id.startsWith(query)).toSorted(byLex);
|
|
148
|
+
const used = new Set(prefix);
|
|
149
|
+
const substr = unique.filter((id) => !used.has(id) && id.includes(query)).toSorted(byLex);
|
|
150
|
+
for (const id of substr) used.add(id);
|
|
151
|
+
const fuzzy = unique
|
|
152
|
+
.filter((id) => !used.has(id) && levenshtein(query, id) <= 2)
|
|
153
|
+
.toSorted((a, b) => {
|
|
154
|
+
const da = levenshtein(query, a);
|
|
155
|
+
const db = levenshtein(query, b);
|
|
156
|
+
return da !== db ? da - db : byLex(a, b);
|
|
157
|
+
});
|
|
158
|
+
for (const id of fuzzy) used.add(id);
|
|
159
|
+
const rest = unique.filter((id) => !used.has(id)).toSorted(byLex);
|
|
160
|
+
return [...prefix, ...substr, ...fuzzy, ...rest].slice(0, limit);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function formatNotFound(kind: string, query: string, ids: readonly string[]): string {
|
|
164
|
+
const picks = pickNotFoundCandidates(query, ids);
|
|
165
|
+
if (picks.length === 0) return `${kind} not found: ${query}`;
|
|
166
|
+
return `${kind} not found: ${query}. Available: ${picks.join(', ')}`;
|
|
167
|
+
}
|
|
168
|
+
|
|
126
169
|
/** Single exit-code write point for non-error result paths (e.g. sweep verdicts). */
|
|
127
170
|
export function exitWith(code: number): void {
|
|
128
171
|
process.exitCode = code;
|
|
@@ -138,21 +181,11 @@ export function resolveRootSpecsDir(
|
|
|
138
181
|
directory?: string,
|
|
139
182
|
io: ReturnType<typeof makeIo> = newIo(),
|
|
140
183
|
): string {
|
|
141
|
-
// r115: the default start is the io's own anchor, NOT the ambient cwd — a
|
|
142
|
-
// re-rooted io (reRootContext) must discover its own instance, otherwise
|
|
143
|
-
// every re-rooted read silently falls back to the launch directory.
|
|
144
184
|
const start = directory ?? io.root;
|
|
145
185
|
const root = resolveInstanceRoot(start, io);
|
|
146
186
|
if (root === null) {
|
|
147
187
|
throw new CliError(`no llmanspec root at or above: ${start}`);
|
|
148
188
|
}
|
|
149
|
-
// r115: the legacy relative identity is only valid when the resolved
|
|
150
|
-
// instance IS this io's own anchor (the single-root default) — there the
|
|
151
|
-
// returned path means `llmanspec/specs` relative to that very anchor, never
|
|
152
|
-
// to the ambient cwd. Every other instance is addressed absolutely, so a
|
|
153
|
-
// caller consuming the result with its own io cannot re-join a
|
|
154
|
-
// launch-relative path into a non-existent directory (which would silently
|
|
155
|
-
// empty the registry and turn a red gate green).
|
|
156
189
|
const absolute = isAbsolute(root) ? root : resolve(io.root, root);
|
|
157
190
|
return sameDir(absolute, io.root) ? 'llmanspec/specs' : join(absolute, 'llmanspec', 'specs');
|
|
158
191
|
}
|
|
@@ -190,7 +223,7 @@ function warnLegacyCheckTransitions(stripped: boolean): void {
|
|
|
190
223
|
if (!stripped || legacyCheckTransitionsWarningShown) return;
|
|
191
224
|
legacyCheckTransitionsWarningShown = true;
|
|
192
225
|
console.error(
|
|
193
|
-
'[WARNING] llmanspec/config.yaml `specs.check_transitions` was removed —
|
|
226
|
+
'[WARNING] llmanspec/config.yaml `specs.check_transitions` was removed — graph validation is whitelist tag-scoped per scenario (@flow / @state / @nodes / @decision_table). Delete the key. See migrations/v0.8-v0.9/README.md.',
|
|
194
227
|
);
|
|
195
228
|
}
|
|
196
229
|
|
|
@@ -219,7 +252,7 @@ export function noteVersionDriftOnce(root: string = process.cwd()): void {
|
|
|
219
252
|
if (state === null) return;
|
|
220
253
|
if (!semverLt(state.cli_version, version)) return;
|
|
221
254
|
console.error(
|
|
222
|
-
`[NOTE] this project was scaffolded with llman-sdd ${state.cli_version}; installed CLI is ${version}.
|
|
255
|
+
`[NOTE] this project was scaffolded with llman-sdd ${state.cli_version}; installed CLI is ${version}. Run \`llman-sdd init --check\` and, if it reports a mismatch, \`llman-sdd init --update\`.`,
|
|
223
256
|
);
|
|
224
257
|
}
|
|
225
258
|
|
|
@@ -253,13 +286,22 @@ export function resolveChangeIdOrExit(
|
|
|
253
286
|
input: string,
|
|
254
287
|
opts: { suppressHint?: boolean } = {},
|
|
255
288
|
): { id: string; viaPrefix: boolean } {
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
289
|
+
const maxScanDepth = cliMaxScanDepth(program);
|
|
290
|
+
try {
|
|
291
|
+
const resolved = resolveChangeId(ctx.io, ctx.root, input, { maxScanDepth });
|
|
292
|
+
if (resolved.viaPrefix && opts.suppressHint !== true) {
|
|
293
|
+
console.error(`'${input}' -> '${resolved.id}' (prefix match)`);
|
|
294
|
+
}
|
|
295
|
+
return resolved;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
if (error instanceof ChangeIdResolveError && error.message.startsWith('change not found:')) {
|
|
298
|
+
const ids = collectChanges(ctx.io, ctx.root, new Date(0), { maxScanDepth }).map(
|
|
299
|
+
(c) => c.name,
|
|
300
|
+
);
|
|
301
|
+
throw new CliError(formatNotFound('change', input, ids), 1);
|
|
302
|
+
}
|
|
303
|
+
throw error;
|
|
261
304
|
}
|
|
262
|
-
return resolved;
|
|
263
305
|
}
|
|
264
306
|
|
|
265
307
|
export type OutMode = 'toon' | 'json' | 'compact-json' | 'human';
|
|
@@ -317,9 +359,6 @@ export function assertCompactJsonPairing(options: {
|
|
|
317
359
|
json?: boolean;
|
|
318
360
|
output?: string;
|
|
319
361
|
}): void {
|
|
320
|
-
// r76: `--compact-json` is a pairing modifier of `--json`. Standalone use is
|
|
321
|
-
// rejected; combining with an explicit `--output toon|human` is ambiguous
|
|
322
|
-
// (two modes requested) and equally a usage error.
|
|
323
362
|
if (options.compactJson === true && options.json !== true) {
|
|
324
363
|
if (options.output === undefined || options.output === 'toon' || options.output === 'human') {
|
|
325
364
|
throw new CliError('--compact-json requires --json', 2);
|
|
@@ -328,30 +367,22 @@ export function assertCompactJsonPairing(options: {
|
|
|
328
367
|
}
|
|
329
368
|
|
|
330
369
|
export const SKILL_DESCRIPTIONS: Record<string, string> = {
|
|
331
|
-
'llman-sdd-
|
|
332
|
-
'llman-sdd-
|
|
333
|
-
|
|
334
|
-
'llman-sdd-
|
|
335
|
-
'llman-sdd-
|
|
336
|
-
'llman-sdd-
|
|
370
|
+
'llman-sdd-specs': 'Author, evolve, and validate llmanspec/specs/*.feature behavior specs',
|
|
371
|
+
'llman-sdd-studio':
|
|
372
|
+
'Visual spec negotiation, onboarding, and code-drift reconciliation in Studio',
|
|
373
|
+
'llman-sdd-change': 'Optional cross-session change scaffolding, branch binding, and archiving',
|
|
374
|
+
'llman-sdd-review': 'Independent read-only multi-perspective review with preflight enforcement',
|
|
375
|
+
'llman-sdd-autopilot': 'Manual-only controlled implementation, gate, and independent review loop',
|
|
337
376
|
};
|
|
338
377
|
export const skillDesc = (name: string): string => SKILL_DESCRIPTIONS[name] ?? '';
|
|
339
378
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
'Backend `rag` is no longer supported. Use the default pageindex backend instead:\nSet `LLMAN_SDD_INDEX_CHAT_MODEL` to a tool-calling chat model, then\nrun `llman-sdd index rebuild`.',
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
const normalized = chosen === 'page-index' ? 'pageindex' : chosen;
|
|
351
|
-
if (normalized !== 'pageindex') {
|
|
352
|
-
throw new Error(`Unsupported backend: ${chosen}`);
|
|
353
|
-
}
|
|
354
|
-
return 'pageindex';
|
|
379
|
+
/**
|
|
380
|
+
* Emit a single-line JIT hint (`next:` / `fix:`) to stderr in non-JSON modes.
|
|
381
|
+
* Keeps stdout 100% pure for JSON / compact-json / TOON consumers (cli r203).
|
|
382
|
+
*/
|
|
383
|
+
export function emitCliHint(hint: CliHint | null | undefined, mode: OutMode = 'human'): void {
|
|
384
|
+
if (!hint || !shouldEmitCliHint(mode)) return;
|
|
385
|
+
console.error(formatCliHint(hint));
|
|
355
386
|
}
|
|
356
387
|
|
|
357
388
|
/**
|
|
@@ -398,12 +429,6 @@ export function reRootContext(ctx: CliContext, directory?: string): CliContext {
|
|
|
398
429
|
* Throws the shared domain error when no instance exists at or above start.
|
|
399
430
|
*/
|
|
400
431
|
export function resolveCommandRoot(ctx: CliContext, directory?: string): string {
|
|
401
|
-
// r109/r115: the start is absolutized at this CLI boundary — a relative
|
|
402
|
-
// `--directory` (`packages`, `..`, `.`) is relative to the process cwd, and
|
|
403
|
-
// the core walk-up cannot climb above a single-segment relative name (its
|
|
404
|
-
// parent is the empty string, which terminates the walk). The returned root
|
|
405
|
-
// is therefore always absolute, so every downstream path/io join stays
|
|
406
|
-
// single-anchored. The error keeps the user's own spelling of the start.
|
|
407
432
|
const given = directory ?? ctx.root;
|
|
408
433
|
const root = resolveInstanceRoot(resolve(given), ctx.io);
|
|
409
434
|
if (root === null) throw new CliError(`no llmanspec root at or above: ${given}`);
|
package/src/commands/archive.ts
CHANGED
|
@@ -28,26 +28,20 @@ function warnIfNotMainCheckout(git: ReturnType<typeof makeCliGit>): void {
|
|
|
28
28
|
/**
|
|
29
29
|
* Compiled binaries have no on-disk 7zz.wasm (Emscripten would probe $bunfs
|
|
30
30
|
* and abort), so scripts/build-binary.ts injects it as base64 through the
|
|
31
|
-
* literal define `process.env.
|
|
31
|
+
* literal define `process.env.LLMAN_SDD_DEV_BUILD_EMBEDDED_7ZZ_WASM_B64` (define only
|
|
32
32
|
* rewrites literal member access — the read must stay here, not in core);
|
|
33
33
|
* unset in source/npm/Node runs → the 7z-wasm glue loads the .wasm from disk.
|
|
34
34
|
* Directory creation for extraction is likewise injected (core stays pure).
|
|
35
35
|
*/
|
|
36
36
|
function makeEmbeddedSevenZip(): Promise<SevenZipPort> {
|
|
37
37
|
return makeWasmSevenZip({
|
|
38
|
-
wasmB64: process.env.
|
|
38
|
+
wasmB64: process.env.LLMAN_SDD_DEV_BUILD_EMBEDDED_7ZZ_WASM_B64,
|
|
39
39
|
mkdirp: (dir) => mkdirSync(dir, { recursive: true }),
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function registerArchive(program: Command, ctx: CliContext): void {
|
|
44
|
-
const
|
|
45
|
-
.command('archive')
|
|
46
|
-
.description(
|
|
47
|
-
'Archive workflow commands (cold backup). Seal a change with `llman-sdd change finalize` first',
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const freeze = archive
|
|
44
|
+
const freeze = program
|
|
51
45
|
.command('freeze')
|
|
52
46
|
.description('Freeze dated archived changes into a single 7z cold backup')
|
|
53
47
|
.option('--before <date>', 'freeze entries older than this date (YYYY-MM-DD)')
|
|
@@ -73,8 +67,6 @@ export function registerArchive(program: Command, ctx: CliContext): void {
|
|
|
73
67
|
ignoreFile: string[];
|
|
74
68
|
directory?: string;
|
|
75
69
|
}) => {
|
|
76
|
-
// r118: the cold-backup reads and writes stay inside the resolved
|
|
77
|
-
// instance root (`llmanspec/changes/archive`), never the launch cwd.
|
|
78
70
|
const rctx = reRootContext(ctx, options.directory);
|
|
79
71
|
const root = rctx.root;
|
|
80
72
|
warnIfNotMainCheckout(ctx.git);
|
|
@@ -84,20 +76,18 @@ export function registerArchive(program: Command, ctx: CliContext): void {
|
|
|
84
76
|
for (const line of await runList(io, sz, root)) console.log(line);
|
|
85
77
|
return;
|
|
86
78
|
}
|
|
87
|
-
// 7z 压缩可能耗时 — 进度提示防止看上去卡住(B1);dry-run/list 不走压缩
|
|
88
79
|
if (!options.dryRun) progressNote('freeze.pack', root);
|
|
89
80
|
const result = await runFreeze(io, sz, root, {
|
|
90
81
|
before: options.before,
|
|
91
82
|
keepRecent: Number(options.keepRecent),
|
|
92
83
|
dryRun: options.dryRun,
|
|
93
|
-
// r116 exemption: user-supplied paths keep their cwd-literal meaning.
|
|
94
84
|
ignoreFiles: options.ignoreFile.map((p) => resolve(p)),
|
|
95
85
|
});
|
|
96
86
|
for (const line of result.lines) console.log(line);
|
|
97
87
|
},
|
|
98
88
|
);
|
|
99
89
|
|
|
100
|
-
const thaw =
|
|
90
|
+
const thaw = program
|
|
101
91
|
.command('thaw')
|
|
102
92
|
.description('Restore archived change directories from the cold-backup archive')
|
|
103
93
|
.requiredOption(
|
|
@@ -120,13 +110,8 @@ export function registerArchive(program: Command, ctx: CliContext): void {
|
|
|
120
110
|
warnIfNotMainCheckout(ctx.git);
|
|
121
111
|
const sz = await makeEmbeddedSevenZip();
|
|
122
112
|
const io = rctx.io;
|
|
123
|
-
// r116 exemption: `--dest` is a user-supplied path and keeps its
|
|
124
|
-
// cwd-literal meaning. Core resolves it against the (possibly re-rooted)
|
|
125
|
-
// instance io, so hand it over already made absolute — single-root
|
|
126
|
-
// invocations keep the literal spelling untouched.
|
|
127
113
|
const dest =
|
|
128
114
|
options.dest === undefined || rctx.root === ctx.root ? options.dest : resolve(options.dest);
|
|
129
|
-
// 7z 解包可能耗时 — 进度提示防止看上去卡住(B1)
|
|
130
115
|
progressNote('thaw.unpack', root);
|
|
131
116
|
const result = await runThaw(io, sz, root, options.change, { dest });
|
|
132
117
|
for (const line of result.lines) console.log(line);
|