peaks-loop 4.1.5 → 4.1.7
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/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +67 -0
- package/README-en.md +47 -183
- package/README.md +24 -188
- package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
- package/dist/cli/commands/best-practice-scan-command.js +35 -20
- package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
- package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
- package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
- package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
- package/dist/cli/commands/core/skill-registry-commands.js +9 -4
- package/dist/cli/commands/dispatch-command-spec.js +1 -1
- package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
- package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
- package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +1 -1
- package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
- package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
- package/dist/cli/commands/openspec-command-shared.js +2 -2
- package/dist/cli/commands/request-transition-failures.js +31 -4
- package/dist/cli/commands/request-transition-preflight.js +1 -1
- package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
- package/dist/cli/commands/verdict-aggregate-command.js +2 -1
- package/dist/cli/commands/workflow-gate-commands.js +4 -4
- package/dist/cli/program.js +0 -2
- package/dist/services/artifacts/artifact-contract-block.js +21 -2
- package/dist/services/artifacts/artifact-prerequisites.d.ts +1 -0
- package/dist/services/artifacts/artifact-prerequisites.js +11 -99
- package/dist/services/artifacts/backcompat-acceptance.d.ts +66 -0
- package/dist/services/artifacts/backcompat-acceptance.js +220 -0
- package/dist/services/artifacts/prerequisite-checks.d.ts +8 -0
- package/dist/services/artifacts/prerequisite-checks.js +7 -2
- package/dist/services/artifacts/prerequisite-path-resolver.d.ts +39 -0
- package/dist/services/artifacts/prerequisite-path-resolver.js +110 -0
- package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
- package/dist/services/artifacts/rd-transition-gates.js +71 -0
- package/dist/services/artifacts/request-artifact-service.js +22 -20
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +9 -1
- package/dist/services/artifacts/request-artifact-state-helpers.js +6 -4
- package/dist/services/audit-independent/judged-declaration-check.d.ts +1 -0
- package/dist/services/audit-independent/judged-declaration-check.js +62 -1
- package/dist/services/context/build-dispatch-system-prompt.d.ts +5 -9
- package/dist/services/context/build-dispatch-system-prompt.js +11 -11
- package/dist/services/context/post-compact-reinjection.js +1 -1
- package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
- package/dist/services/dispatch/test-tool-detection.js +12 -1
- package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.d.ts +15 -0
- package/dist/services/doctor/doctor-service/checks/backcompat-acceptance.js +53 -0
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +38 -0
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +243 -0
- package/dist/services/doctor/doctor-service/plugin-registry.js +4 -0
- package/dist/services/doctor/doctor-service/types.d.ts +12 -0
- package/dist/services/evidence/evidence-generator.js +8 -4
- package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
- package/dist/services/openspec/coverage-evidence-reader.js +8 -8
- package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
- package/dist/services/openspec/openspec-archive-service.js +6 -6
- package/dist/services/scan/file-size-baseline.d.ts +13 -6
- package/dist/services/scan/file-size-baseline.js +54 -31
- package/dist/services/scan/file-size-scan.d.ts +7 -14
- package/dist/services/scan/file-size-scan.js +6 -1
- package/dist/services/scan/type-corroboration.d.ts +32 -0
- package/dist/services/scan/type-corroboration.js +51 -0
- package/dist/services/scan/type-sanity-service.d.ts +14 -0
- package/dist/services/scan/type-sanity-service.js +10 -19
- package/dist/services/security/safe-settings-path.d.ts +5 -0
- package/dist/services/security/safe-settings-path.js +64 -8
- package/dist/services/skill/resume-detector.js +8 -8
- package/dist/services/workflow/pipeline-verify-gate-support.d.ts +28 -9
- package/dist/services/workflow/pipeline-verify-gate-support.js +40 -117
- package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
- package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
- package/dist/services/workflow/pipeline-verify-rd-phase.d.ts +67 -0
- package/dist/services/workflow/pipeline-verify-rd-phase.js +122 -0
- package/dist/services/workflow/pipeline-verify-service.js +42 -44
- package/dist/services/workflow/request-type-resolution.d.ts +99 -0
- package/dist/services/workflow/request-type-resolution.js +130 -0
- package/dist/services/workflow/workflow-skip-service.d.ts +1 -0
- package/dist/services/workflow/workflow-skip-service.js +19 -21
- package/dist/services/workflow/workflow-state-store.d.ts +9 -0
- package/dist/services/workflow/workflow-state-store.js +26 -1
- package/dist/services/workspace/workspace-service.js +4 -16
- package/dist/shared/incrementing-number.d.ts +23 -2
- package/dist/shared/incrementing-number.js +57 -15
- package/package.json +5 -7
- package/schemas/doctor-report.schema.json +2 -2
- package/skills/bee/peaks-prd/SKILL.md +3 -2
- package/skills/peaks-code/SKILL.md +32 -15
- package/dist/cli/commands/vm-command-shared.d.ts +0 -23
- package/dist/cli/commands/vm-command-shared.js +0 -23
- package/dist/cli/commands/vm-commands.d.ts +0 -3
- package/dist/cli/commands/vm-commands.js +0 -45
- package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
- package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
- package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
- package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
- package/dist/cli/commands/vm-release-command.d.ts +0 -5
- package/dist/cli/commands/vm-release-command.js +0 -101
- package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
- package/dist/cli/commands/vm-spawn-command.js +0 -177
- package/dist/cli/commands/vm-status-command.d.ts +0 -3
- package/dist/cli/commands/vm-status-command.js +0 -50
- package/dist/services/vm/vm-lease.d.ts +0 -40
- package/dist/services/vm/vm-lease.js +0 -160
|
@@ -6,10 +6,19 @@ export type WorkflowSkipState = {
|
|
|
6
6
|
skipAppliedBy: string;
|
|
7
7
|
callerKind: 'human' | 'llm' | 'script';
|
|
8
8
|
};
|
|
9
|
+
/** C0/C1 controls and DEL. A newline or escape in a printed field is a spoofed line. */
|
|
10
|
+
export declare function hasControlChars(value: string): boolean;
|
|
9
11
|
/**
|
|
10
12
|
* Read the skip-state for a rid, or `null` if no state file exists or
|
|
11
13
|
* the file is malformed. The caller is expected to treat `null` as
|
|
12
14
|
* "no skip applied; evaluate all gates normally".
|
|
15
|
+
*
|
|
16
|
+
* A NULL IS SILENCE, AND SILENCE MEANS "NO SKIP HONOURED". The shape check refuses
|
|
17
|
+
* a record the write path could not have produced — an empty reason, or no gate
|
|
18
|
+
* named — so a hand-planted file that satisfies field PRESENCE but not the write
|
|
19
|
+
* rules lands here as `null` and the gates are evaluated. That is the safe
|
|
20
|
+
* direction: the cost is a skip that stops applying, stated in the RD artifact,
|
|
21
|
+
* not a bypass that starts applying.
|
|
13
22
|
*/
|
|
14
23
|
export declare function readSkipState(projectRoot: string, sessionId: string, rid: string): WorkflowSkipState | null;
|
|
15
24
|
/**
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
22
22
|
import { dirname, join } from 'node:path';
|
|
23
23
|
const STATE_FILE_NAME = 'workflow-state.json';
|
|
24
|
+
/** C0/C1 controls and DEL. A newline or escape in a printed field is a spoofed line. */
|
|
25
|
+
export function hasControlChars(value) {
|
|
26
|
+
for (const char of value) {
|
|
27
|
+
if (char < ' ' || char === '\u007f' || (char >= '\u0080' && char <= '\u009f'))
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
24
32
|
function stateFilePath(projectRoot, sessionId, rid) {
|
|
25
33
|
return join(projectRoot, '.peaks', '_runtime', sessionId, 'workflow-state', `${rid}.json`);
|
|
26
34
|
}
|
|
@@ -28,6 +36,13 @@ function stateFilePath(projectRoot, sessionId, rid) {
|
|
|
28
36
|
* Read the skip-state for a rid, or `null` if no state file exists or
|
|
29
37
|
* the file is malformed. The caller is expected to treat `null` as
|
|
30
38
|
* "no skip applied; evaluate all gates normally".
|
|
39
|
+
*
|
|
40
|
+
* A NULL IS SILENCE, AND SILENCE MEANS "NO SKIP HONOURED". The shape check refuses
|
|
41
|
+
* a record the write path could not have produced — an empty reason, or no gate
|
|
42
|
+
* named — so a hand-planted file that satisfies field PRESENCE but not the write
|
|
43
|
+
* rules lands here as `null` and the gates are evaluated. That is the safe
|
|
44
|
+
* direction: the cost is a skip that stops applying, stated in the RD artifact,
|
|
45
|
+
* not a bypass that starts applying.
|
|
31
46
|
*/
|
|
32
47
|
export function readSkipState(projectRoot, sessionId, rid) {
|
|
33
48
|
const path = stateFilePath(projectRoot, sessionId, rid);
|
|
@@ -81,14 +96,24 @@ function isWorkflowSkipState(value) {
|
|
|
81
96
|
return false;
|
|
82
97
|
if (!Array.isArray(v.skippedGates))
|
|
83
98
|
return false;
|
|
84
|
-
if (
|
|
99
|
+
if (v.skippedGates.length === 0)
|
|
100
|
+
return false;
|
|
101
|
+
if (!v.skippedGates.every((g) => typeof g === 'string' && g.trim().length > 0 && g === g.trim() && !hasControlChars(g)))
|
|
85
102
|
return false;
|
|
86
103
|
if (typeof v.skipReason !== 'string')
|
|
87
104
|
return false;
|
|
105
|
+
if (v.skipReason.trim().length === 0)
|
|
106
|
+
return false;
|
|
107
|
+
if (hasControlChars(v.skipReason))
|
|
108
|
+
return false;
|
|
88
109
|
if (typeof v.skipAppliedAt !== 'string')
|
|
89
110
|
return false;
|
|
111
|
+
if (hasControlChars(v.skipAppliedAt))
|
|
112
|
+
return false;
|
|
90
113
|
if (typeof v.skipAppliedBy !== 'string')
|
|
91
114
|
return false;
|
|
115
|
+
if (hasControlChars(v.skipAppliedBy))
|
|
116
|
+
return false;
|
|
92
117
|
if (v.callerKind !== 'human' && v.callerKind !== 'llm' && v.callerKind !== 'script')
|
|
93
118
|
return false;
|
|
94
119
|
return true;
|
|
@@ -7,6 +7,7 @@ import { updateCallerBindingSessionId } from '../session/caller-binding-service.
|
|
|
7
7
|
import { resolveCallerProjection } from '../session/resolve-caller-id.js';
|
|
8
8
|
import { normalizePath } from '../../shared/path-utils.js';
|
|
9
9
|
import { assertWritableProjectRoot } from '../config/config-safety.js';
|
|
10
|
+
import { seedBackCompatAcceptance } from '../artifacts/backcompat-acceptance.js';
|
|
10
11
|
/**
|
|
11
12
|
* calling process's own per-caller binding at the session id this init just
|
|
12
13
|
* bound. `getSessionIdCanonical` reads `callers/<callerId>.json` FIRST, so a
|
|
@@ -46,22 +47,6 @@ function listPeaksRuntimeSiblings(projectRoot) {
|
|
|
46
47
|
return [];
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
/**
|
|
50
|
-
* `.peaks/_runtime/` so the legacy sibling-dir guard can enumerate
|
|
51
|
-
* date-stamped residue dirs at the runtime layer. Returns `[]` when
|
|
52
|
-
* the `.peaks/_runtime/` dir does not exist.
|
|
53
|
-
*/
|
|
54
|
-
function listRuntimeSiblings(projectRoot) {
|
|
55
|
-
const runtimeDir = join(projectRoot, '.peaks', '_runtime');
|
|
56
|
-
if (!existsSync(runtimeDir))
|
|
57
|
-
return [];
|
|
58
|
-
try {
|
|
59
|
-
return readdirSync(runtimeDir);
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
50
|
/**
|
|
66
51
|
* basename matches the auto-generated session-id shape
|
|
67
52
|
* `YYYY-MM-DD-<slug>` (the v2.8.3 hard-ban target). Bare dates
|
|
@@ -365,6 +350,9 @@ export async function initWorkspace(options) {
|
|
|
365
350
|
// last regenerate this project", not "when did the bytes change". See
|
|
366
351
|
// `generated-artifacts-stamp.ts`.
|
|
367
352
|
writeGeneratedArtifactsStamp(options.projectRoot);
|
|
353
|
+
// The commit-leg expiry gate is opt-in by the presence of this tracked list;
|
|
354
|
+
// seeding it here (idempotently) is how a project opts in.
|
|
355
|
+
seedBackCompatAcceptance(options.projectRoot);
|
|
368
356
|
return {
|
|
369
357
|
sessionId: options.sessionId,
|
|
370
358
|
sessionRoot,
|
|
@@ -2,10 +2,27 @@
|
|
|
2
2
|
* Utilities for generating incrementing numbered filenames.
|
|
3
3
|
* Used by session-based artifact storage to create files like 001-feature.md.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* The `<NNN>-` prefix family: EXACTLY three digits, anchored at the start. The one
|
|
7
|
+
* definition the counting side (`getNextNumber`), the writing side
|
|
8
|
+
* (`buildNumberedFilename`) and the stripping side (`requestIdFromFileName`) all
|
|
9
|
+
* read, so neither side can widen the family without the others.
|
|
10
|
+
*
|
|
11
|
+
* Three digits is what the writer pads to for every number it can hand out, and a
|
|
12
|
+
* WIDER pattern on the counting side is the whole defect this constant closes: with
|
|
13
|
+
* `^(\d+)-` the leading YEAR of a bare date-shaped name (`2026-10-15-<slug>`) reads
|
|
14
|
+
* as a file number. Four digits is out of family by construction — `\d{3}` is
|
|
15
|
+
* followed by `-`, and `2026-` has a digit there.
|
|
16
|
+
*/
|
|
17
|
+
export declare const NUMBERED_PREFIX_RE: RegExp;
|
|
5
18
|
/**
|
|
6
19
|
* Get the next available number in a directory.
|
|
7
|
-
* Scans existing .md files and finds the highest numeric prefix.
|
|
8
|
-
* Returns 1 if directory is empty or
|
|
20
|
+
* Scans existing .md files and finds the highest IN-FAMILY numeric prefix.
|
|
21
|
+
* Returns 1 if the directory is empty, missing, or holds no in-family name.
|
|
22
|
+
*
|
|
23
|
+
* A name whose leading digits are not a whole prefix in the family — a bare
|
|
24
|
+
* date-shaped name, whose leading digits are a year — is ignored rather than
|
|
25
|
+
* counted, so it can never move the answer.
|
|
9
26
|
*
|
|
10
27
|
* @param dirPath - Directory to scan for numbered files
|
|
11
28
|
* @returns Next available number (1, 2, 3, ...)
|
|
@@ -27,6 +44,10 @@ export declare function buildNumberedFilename(number: number, description: strin
|
|
|
27
44
|
* markdown artifact at all. The READ side of `buildNumberedFilename`, in the same
|
|
28
45
|
* module, so writer and reader cannot drift apart from each other.
|
|
29
46
|
*
|
|
47
|
+
* The prefix it strips is `NUMBERED_PREFIX_RE` — the same family `getNextNumber`
|
|
48
|
+
* counts — so a name the writer produced always reads back as the id it was given.
|
|
49
|
+
* A bare date-shaped stem carries no in-family prefix and is returned verbatim.
|
|
50
|
+
*
|
|
30
51
|
* The returned stem is not yet checked against the id pattern the artifact service
|
|
31
52
|
* owns; a caller that needs a legal request id applies that there rather than the
|
|
32
53
|
* pattern being imported here.
|
|
@@ -4,10 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { existsSync, readdirSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* The `<NNN>-` prefix family: EXACTLY three digits, anchored at the start. The one
|
|
9
|
+
* definition the counting side (`getNextNumber`), the writing side
|
|
10
|
+
* (`buildNumberedFilename`) and the stripping side (`requestIdFromFileName`) all
|
|
11
|
+
* read, so neither side can widen the family without the others.
|
|
12
|
+
*
|
|
13
|
+
* Three digits is what the writer pads to for every number it can hand out, and a
|
|
14
|
+
* WIDER pattern on the counting side is the whole defect this constant closes: with
|
|
15
|
+
* `^(\d+)-` the leading YEAR of a bare date-shaped name (`2026-10-15-<slug>`) reads
|
|
16
|
+
* as a file number. Four digits is out of family by construction — `\d{3}` is
|
|
17
|
+
* followed by `-`, and `2026-` has a digit there.
|
|
18
|
+
*/
|
|
19
|
+
export const NUMBERED_PREFIX_RE = /^(\d{3})-/;
|
|
7
20
|
/**
|
|
8
21
|
* Get the next available number in a directory.
|
|
9
|
-
* Scans existing .md files and finds the highest numeric prefix.
|
|
10
|
-
* Returns 1 if directory is empty or
|
|
22
|
+
* Scans existing .md files and finds the highest IN-FAMILY numeric prefix.
|
|
23
|
+
* Returns 1 if the directory is empty, missing, or holds no in-family name.
|
|
24
|
+
*
|
|
25
|
+
* A name whose leading digits are not a whole prefix in the family — a bare
|
|
26
|
+
* date-shaped name, whose leading digits are a year — is ignored rather than
|
|
27
|
+
* counted, so it can never move the answer.
|
|
11
28
|
*
|
|
12
29
|
* @param dirPath - Directory to scan for numbered files
|
|
13
30
|
* @returns Next available number (1, 2, 3, ...)
|
|
@@ -20,7 +37,7 @@ export function getNextNumber(dirPath) {
|
|
|
20
37
|
return 1;
|
|
21
38
|
const numbers = files
|
|
22
39
|
.map((f) => {
|
|
23
|
-
const match =
|
|
40
|
+
const match = NUMBERED_PREFIX_RE.exec(f);
|
|
24
41
|
return match && match[1] ? parseInt(match[1], 10) : NaN;
|
|
25
42
|
})
|
|
26
43
|
.filter((n) => !isNaN(n));
|
|
@@ -35,17 +52,29 @@ export function getNextNumber(dirPath) {
|
|
|
35
52
|
* @returns Formatted filename like "001-feature-name.md"
|
|
36
53
|
*/
|
|
37
54
|
/**
|
|
38
|
-
* The `<NNN>` prefix in a numbered filename is COSMETIC
|
|
39
|
-
* the
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* number
|
|
45
|
-
* and
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
55
|
+
* The `<NNN>` prefix in a numbered filename is COSMETIC — but that is a claim about
|
|
56
|
+
* the NUMBER, not about the prefix's WIDTH. The width is `NUMBERED_PREFIX_RE`:
|
|
57
|
+
* exactly three digits, the one family the counting, writing and stripping sides all
|
|
58
|
+
* read. `getNextNumber` scans the directory's highest in-family prefix and adds one,
|
|
59
|
+
* and nothing claims a number in between — so two writers running at once can both
|
|
60
|
+
* read the same maximum and both stamp the same number. That is harmless only
|
|
61
|
+
* because the number is not an identity: what names an artifact is the slug (the
|
|
62
|
+
* request id), and every reader strips a prefix in the family. Measured 2026-10-12:
|
|
63
|
+
* the sole consumers of the number are this module's writer path (`getNextNumber` ->
|
|
64
|
+
* `buildNumberedFilename`) and the read side (`requestIdFromFileName`, which
|
|
65
|
+
* discards it); the artifact service's duplicate check and lookup both key on the
|
|
66
|
+
* slug. Read that as a constraint: give the number a meaning and you must claim it
|
|
67
|
+
* atomically first, rather than assume this scan hands out unique values.
|
|
68
|
+
*
|
|
69
|
+
* WHY THE FAMILY IS STATED RATHER THAN ASSUMED — the defect this replaced. The
|
|
70
|
+
* counting side once matched `^(\d+)-` while the stripping side knew only `^0\d{2}-`.
|
|
71
|
+
* Two patterns on one naming rule disagree from the day they are written, and a
|
|
72
|
+
* directory of nothing but bare date-shaped names is where it showed: the count
|
|
73
|
+
* answered 2027 (the year 2026, plus one), the writer stamped `2027-` onto a fresh
|
|
74
|
+
* artifact, and the stripping side handed back an id carrying a prefix the state
|
|
75
|
+
* machine had never been given. A four-digit prefix is out of family, so
|
|
76
|
+
* `buildNumberedFilename` refuses to write one instead of letting the writer walk
|
|
77
|
+
* past the reader.
|
|
49
78
|
*/
|
|
50
79
|
// Windows supports up to 255 chars per filename component (and 260 for the
|
|
51
80
|
// full path). Pre-#015 the slug was silently truncated to 50 chars, which
|
|
@@ -75,6 +104,15 @@ export function slugifyDescription(description) {
|
|
|
75
104
|
}
|
|
76
105
|
export function buildNumberedFilename(number, description) {
|
|
77
106
|
const padded = String(number).padStart(3, '0');
|
|
107
|
+
// The writer is held to the reader's own family. A number with no three-digit
|
|
108
|
+
// spelling (1000 and up) would produce a prefix `requestIdFromFileName` does not
|
|
109
|
+
// strip, and the artifact's id would then disagree with the id it was given —
|
|
110
|
+
// the counting/stripping disagreement on a second axis. Refuse rather than widen
|
|
111
|
+
// the reader: a four-digit prefix on a filename is a year to every reader.
|
|
112
|
+
if (!NUMBERED_PREFIX_RE.test(`${padded}-`)) {
|
|
113
|
+
throw new Error(`Cannot number a file ${number}: the prefix family is exactly three digits, and ${padded}- is ` +
|
|
114
|
+
'outside it. A directory that has filled the family needs a second directory, not a fourth digit.');
|
|
115
|
+
}
|
|
78
116
|
const slug = slugifyDescription(description);
|
|
79
117
|
return `${padded}-${slug}.md`;
|
|
80
118
|
}
|
|
@@ -83,6 +121,10 @@ export function buildNumberedFilename(number, description) {
|
|
|
83
121
|
* markdown artifact at all. The READ side of `buildNumberedFilename`, in the same
|
|
84
122
|
* module, so writer and reader cannot drift apart from each other.
|
|
85
123
|
*
|
|
124
|
+
* The prefix it strips is `NUMBERED_PREFIX_RE` — the same family `getNextNumber`
|
|
125
|
+
* counts — so a name the writer produced always reads back as the id it was given.
|
|
126
|
+
* A bare date-shaped stem carries no in-family prefix and is returned verbatim.
|
|
127
|
+
*
|
|
86
128
|
* The returned stem is not yet checked against the id pattern the artifact service
|
|
87
129
|
* owns; a caller that needs a legal request id applies that there rather than the
|
|
88
130
|
* pattern being imported here.
|
|
@@ -90,7 +132,7 @@ export function buildNumberedFilename(number, description) {
|
|
|
90
132
|
export function requestIdFromFileName(fileName) {
|
|
91
133
|
if (!fileName.endsWith('.md'))
|
|
92
134
|
return null;
|
|
93
|
-
return fileName.replace(
|
|
135
|
+
return fileName.replace(NUMBERED_PREFIX_RE, '').replace(/\.md$/, '');
|
|
94
136
|
}
|
|
95
137
|
/**
|
|
96
138
|
* Get the next numbered file path in a directory.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peaks-loop",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.7",
|
|
4
4
|
"description": "Loop Engineering CLI — workflow primitive / loop guards / evaluators / slice orchestration",
|
|
5
5
|
"author": "SquabbyZ",
|
|
6
6
|
"keywords": [
|
|
@@ -129,10 +129,10 @@
|
|
|
129
129
|
"picomatch": "4.0.4",
|
|
130
130
|
"yaml": "^2.9.0",
|
|
131
131
|
"zod": "^4.4.3",
|
|
132
|
-
"peaks-loop-internal-runtime": "0.0.
|
|
133
|
-
"peaks-loop-
|
|
134
|
-
"peaks-loop-
|
|
135
|
-
"peaks-loop-shared": "0.0.
|
|
132
|
+
"peaks-loop-internal-runtime": "0.0.47",
|
|
133
|
+
"peaks-loop-mut": "0.1.61",
|
|
134
|
+
"peaks-loop-shared": "0.0.96",
|
|
135
|
+
"peaks-loop-shared-channel": "0.0.64"
|
|
136
136
|
},
|
|
137
137
|
"devDependencies": {
|
|
138
138
|
"@changesets/cli": "2.31.1",
|
|
@@ -185,8 +185,6 @@
|
|
|
185
185
|
"test:race": "vitest run --no-file-parallelism packages/peaks-loop-shared-channel/tests/shared-channel.test.ts tests/unit/services/dispatch/dispatch-record-writer.test.ts",
|
|
186
186
|
"test:replay": "node scripts/fixture-capture-setup.mjs && vitest run tests/unit/services/dispatch/conflict-replay.test.ts tests/unit/services/dispatch/e2e-fixtures.test.ts",
|
|
187
187
|
"fixture:capture-setup": "node scripts/fixture-capture-setup.mjs",
|
|
188
|
-
"test:coverage": "node ./scripts/coverage-c8.mjs",
|
|
189
|
-
"test:coverage:c8": "node ./scripts/coverage-c8.mjs",
|
|
190
188
|
"test:coverage:vitest": "vitest run --coverage",
|
|
191
189
|
"test:coverage:workflow": "vitest run --coverage --coverage.include='src/services/workflow/plan-*.ts' tests/unit/services/workflow/",
|
|
192
190
|
"schema:generate": "node scripts/generate-context-schema.mjs",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"properties": {
|
|
14
14
|
"id": {
|
|
15
15
|
"type": "string",
|
|
16
|
-
"pattern": "^(skill|skill-name|skill-parse|skill-runbook|skill-apply-note|skill-presence|statusline|schema|config|doctor-self|capability|build|integration|L3):[A-Za-z0-9][A-Za-z0-9._-]
|
|
17
|
-
"description": "Stable check id. Known prefixes: skill:<name> (required skill present), skill-name:<dir> (directory matches declared name), skill-parse:<dir> (skill metadata parsed), skill-runbook:<name> (Default runbook section exists), skill-apply-note:<name> (destructive --apply lines carry an authorization/--dry-run note), skill-presence:<topic> (status of .peaks/.active-skill.json — current/freshness/workspace), statusline:<topic> (out-of-band Claude Code statusLine — install/runtime), schema:<file> (schema file exists and is valid JSON), config:<scope> (optional config locations), doctor-self:<topic> (doctor validates its own output against this schema), capability:<name> (third-party capability is resolvable at the pinned version), build:<topic> (build-hygiene checks — dist/source version consistency), integration:<name> (third-party integration probe — e.g. gateguard-fact-force PreToolUse hook conflict on .peaks/**)."
|
|
16
|
+
"pattern": "^(?:(?:skill|skill-name|skill-parse|skill-runbook|skill-apply-note|skill-presence|statusline|schema|config|doctor-self|capability|build|integration|L3):[A-Za-z0-9][A-Za-z0-9._-]*|skills:[A-Za-z0-9][A-Za-z0-9._-]*(?::[A-Za-z0-9][A-Za-z0-9._-]*)+)$",
|
|
17
|
+
"description": "Stable check id. Known prefixes: skill:<name> (required skill present), skill-name:<dir> (directory matches declared name), skill-parse:<dir> (skill metadata parsed), skill-runbook:<name> (Default runbook section exists), skill-apply-note:<name> (destructive --apply lines carry an authorization/--dry-run note), skill-presence:<topic> (status of .peaks/.active-skill.json — current/freshness/workspace), skills:<topic>:<ide>:<skill> (canonical-store vs IDE skill-tree parity — a file present on one side and absent on the other; topic store means the canonical store is absent), statusline:<topic> (out-of-band Claude Code statusLine — install/runtime), schema:<file> (schema file exists and is valid JSON), config:<scope> (optional config locations), doctor-self:<topic> (doctor validates its own output against this schema), capability:<name> (third-party capability is resolvable at the pinned version), build:<topic> (build-hygiene checks — dist/source version consistency), integration:<name> (third-party integration probe — e.g. gateguard-fact-force PreToolUse hook conflict on .peaks/**)."
|
|
18
18
|
},
|
|
19
19
|
"ok": { "type": "boolean" },
|
|
20
20
|
"message": { "type": "string", "minLength": 1 }
|
|
@@ -383,8 +383,9 @@ scan BEFORE transitioning to Step 3 RD.
|
|
|
383
383
|
|
|
384
384
|
**Handoff contract:**
|
|
385
385
|
- Input: `businessGoal` (natural language) + `.peaks/project-scan/project-scan.md` (auto-generated by `peaks workspace init`)
|
|
386
|
-
-
|
|
387
|
-
-
|
|
386
|
+
- Lookup (LLM-side, and required for a real scan): query Context7 priority-1 → WebSearch priority-2 with your own tools, then write the results to `.peaks/_runtime/<sessionId>/best-practice/lookup-results.json` as `{ "intent": "<businessGoal>", "context7": { "ok", "results": [{ "title", "url", "snippet" }] }, "websearch": { … } }`. A lookup that returned nothing is `"ok": false, "results": []`, and **if every seam you supply returns nothing the scan refuses with `BEST_PRACTICE_SCAN_NO_FRAGMENTS` and writes no artifact** — zero fragments never renders. Each fragment carries `title`/`url`/`snippet` and no other key, and the `url` is one you construct: Context7 returns no URL, only a library ID.
|
|
387
|
+
- Output: best-practice scan artifact at `<repo>/best-practice/<date>-<slug>.md` (gitignored; `<slug>` is a 32-char slice of the goal). A refusal never overwrites it — it is recorded beside it at `<repo>/best-practice/skipped/<date>-<slug>.md`, so a real recommendation survives the auto-triggered scan that shares its intent.
|
|
388
|
+
- Trigger CLI: `peaks best-practice-scan --project <repo> --intent "<businessGoal>" --lookup-results .peaks/_runtime/<sessionId>/best-practice/lookup-results.json --json`
|
|
388
389
|
- Status: `awaiting-user-ack` (3 valid user responses per spec §7: 接受 / 接受方案 N / 拒绝 + 原因)
|
|
389
390
|
|
|
390
391
|
**State machine:** peak-prd's state machine refuses `--allow-incomplete` style bypass for
|
|
@@ -262,25 +262,42 @@ language-aware, LLM-recommended best-practice scan** before RD kicks off.
|
|
|
262
262
|
**Trigger:** Fires at peak-prd exit when business-goal is non-empty + sub-step not yet
|
|
263
263
|
triggered for this intent.
|
|
264
264
|
|
|
265
|
-
**Action sequence:**
|
|
265
|
+
**Action sequence — the LLM performs the lookup; the CLI never calls Context7:**
|
|
266
266
|
1. Detect project language (TS / JS / Python / Go / Java) via `language-detector` (5-lang
|
|
267
|
-
priority chain).
|
|
268
|
-
2.
|
|
269
|
-
priority-
|
|
270
|
-
3.
|
|
271
|
-
|
|
267
|
+
priority chain), or let the CLI auto-detect it.
|
|
268
|
+
2. **You** query Context7 (`@upstash/context7-mcp`) with your own MCP tool — priority 1, 30s budget —
|
|
269
|
+
and WebSearch as the priority-2 fallback when Context7 answers nothing.
|
|
270
|
+
3. **You** write those results to `.peaks/_runtime/<sessionId>/best-practice/lookup-results.json` in
|
|
271
|
+
the scan seam's own vocabulary — `{ "intent": "<the --intent value>", "context7": { "ok": …,
|
|
272
|
+
"results": [{ "title", "url", "snippet" }] }, "websearch": { … } }` — then run
|
|
273
|
+
`peaks best-practice-scan --project <repo> --intent "<goal>" --lookup-results <that file>`. The
|
|
274
|
+
path is resolved against your cwd, so pass it explicitly. A lookup that returned nothing is
|
|
275
|
+
`"ok": false, "results": []`; `"ok": true` with an empty `results` is refused, because that is
|
|
276
|
+
the shape a fabrication would take. Each fragment may carry `title`/`url`/`snippet` and nothing
|
|
277
|
+
else, and **the `url` is yours to construct** — Context7's response contains no URL, only a
|
|
278
|
+
library ID (`/org/project`), so state that when the recommendation is read.
|
|
279
|
+
4. The CLI validates the file and renders the 8-row markdown comparison table per `output-formatter`
|
|
280
|
+
into `<project>/best-practice/<date>-<intent-slug>.md`.
|
|
272
281
|
5. LLM picks one recommendation (★ marker) with reasoning block.
|
|
273
282
|
6. **Mandatory ⚠️ catch gate** — user explicitly acks / picks alt / rejects + reason.
|
|
274
283
|
|
|
275
|
-
**When the scan cannot be performed, the sub-step is SKIPPED — never fabricated.**
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
`
|
|
283
|
-
|
|
284
|
+
**When the scan cannot be performed, the sub-step is SKIPPED — never fabricated.** With no
|
|
285
|
+
`--lookup-results`, the CLI's built-in lookups are stubs and return synthetic fragments: the scan
|
|
286
|
+
**refuses** — `ok:false`, `BEST_PRACTICE_SCAN_SYNTHETIC_LOOKUP`, exit 1 — and prints no recommendation,
|
|
287
|
+
no comparison table and no ⚠️ catch gate, because there is nothing real for the user to judge. Record
|
|
288
|
+
the sub-step as **skipped with reason `synthetic-lookup`** and carry on; do not synthesise a
|
|
289
|
+
recommendation to satisfy the gate. **Every miss is refused**, in one of two ways: with no real
|
|
290
|
+
WebSearch behind a Context7 miss the fall-through lands on the stub and gives the refusal above; when
|
|
291
|
+
you supply the `websearch` seam and it *also* reports `ok: false`, the chain is real and found nothing,
|
|
292
|
+
and the command refuses with `BEST_PRACTICE_SCAN_NO_FRAGMENTS` and writes no artifact at all. A scan
|
|
293
|
+
with zero fragments never renders — a table with a `★` on it and nothing behind it is the fabrication
|
|
294
|
+
this sub-step exists to prevent. `--intent <text>` is required (the business goal, not the project
|
|
295
|
+
path) — omitting it is `BEST_PRACTICE_SCAN_INTENT_REQUIRED`, also exit 1. Supply real results with
|
|
296
|
+
`--lookup-results <file>`; a malformed, mismatched or empty-results file is refused as
|
|
297
|
+
`BEST_PRACTICE_SCAN_INVALID_RESULTS` without scanning. A real scan renders the full table and the gate
|
|
298
|
+
normally. Run the injected scan **after** the PRD state transition, so the real recommendation is the
|
|
299
|
+
artifact left on disk; a refusal never overwrites it — it is recorded under
|
|
300
|
+
`<project>/best-practice/skipped/` instead.
|
|
284
301
|
|
|
285
302
|
**Out of scope for this sub-step:**
|
|
286
303
|
- ❌ No changes to RD dispatch Karpathy prose (Step 3 unchanged)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type VmHypervisor } from '../../services/vm/vm-lease.js';
|
|
2
|
-
export type VmOptions = {
|
|
3
|
-
session?: string;
|
|
4
|
-
project?: string;
|
|
5
|
-
json?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type SpawnOptions = VmOptions & {
|
|
8
|
-
rid: string;
|
|
9
|
-
role: string;
|
|
10
|
-
purpose: string;
|
|
11
|
-
hypervisor?: VmHypervisor;
|
|
12
|
-
image?: string;
|
|
13
|
-
ttl?: string;
|
|
14
|
-
mount?: string;
|
|
15
|
-
};
|
|
16
|
-
export type ReleaseOptions = VmOptions & {
|
|
17
|
-
leaseId: string;
|
|
18
|
-
};
|
|
19
|
-
/** `--session`, else `PEAKS_SESSION_ID`, else the project's bound session, else `unknown-sid`. */
|
|
20
|
-
export declare function resolveVmSessionId(projectRoot: string, session: string | undefined): string;
|
|
21
|
-
/** `<projectRoot>/.peaks/_runtime/<sessionId>` — trailing separators collapsed. */
|
|
22
|
-
export declare function joinPathSession(projectRoot: string, sessionId: string): string;
|
|
23
|
-
export declare function resolveTtlMs(raw: string | undefined, role: string): number;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// src/cli/commands/vm-command-shared.ts
|
|
2
|
-
//
|
|
3
|
-
// What `peaks vm` verbs share: the option shapes, the session-id resolution and
|
|
4
|
-
// the role-aware TTL. Split out of `vm-commands.ts`; every resolution order and
|
|
5
|
-
// default is unchanged.
|
|
6
|
-
import { getCurrentSessionId } from '../../services/skills/skill-presence-service.js';
|
|
7
|
-
import { ttlForVmRole } from '../../services/vm/vm-lease.js';
|
|
8
|
-
/** `--session`, else `PEAKS_SESSION_ID`, else the project's bound session, else `unknown-sid`. */
|
|
9
|
-
export function resolveVmSessionId(projectRoot, session) {
|
|
10
|
-
return (session ?? process.env.PEAKS_SESSION_ID ?? getCurrentSessionId(projectRoot) ?? 'unknown-sid');
|
|
11
|
-
}
|
|
12
|
-
/** `<projectRoot>/.peaks/_runtime/<sessionId>` — trailing separators collapsed. */
|
|
13
|
-
export function joinPathSession(projectRoot, sessionId) {
|
|
14
|
-
return `${projectRoot.replace(/[\\/]+$/, '')}/.peaks/_runtime/${sessionId}`;
|
|
15
|
-
}
|
|
16
|
-
export function resolveTtlMs(raw, role) {
|
|
17
|
-
if (typeof raw !== 'string' || raw.length === 0)
|
|
18
|
-
return ttlForVmRole(role);
|
|
19
|
-
const parsed = Number.parseInt(raw, 10);
|
|
20
|
-
if (!Number.isInteger(parsed) || parsed <= 0)
|
|
21
|
-
return ttlForVmRole(role);
|
|
22
|
-
return parsed;
|
|
23
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// src/cli/commands/vm-commands.ts
|
|
2
|
-
//
|
|
3
|
-
// L4 VM isolation: the `peaks vm` parent, its status probe, and the
|
|
4
|
-
// spawn/release pair. Split out of the single file this used to be; the parent
|
|
5
|
-
// description, the registration order and every verb's surface are unchanged.
|
|
6
|
-
//
|
|
7
|
-
// Hypervisor dispatch:
|
|
8
|
-
// - `kvm` : `virsh create` + `virsh destroy` (Linux KVM via libvirt)
|
|
9
|
-
// - `hyperkit` : `hvftool create` + `hvftool stop` (macOS HyperKit)
|
|
10
|
-
// - `hyperv` : `hvc create` + `hvftool stop` (Windows Hyper-V via
|
|
11
|
-
// the operator-installed `hvc` shim)
|
|
12
|
-
//
|
|
13
|
-
// The runtime check: which hypervisor binary is on PATH +
|
|
14
|
-
// (for kvm) whether the host kernel exposes /dev/kvm. The
|
|
15
|
-
// spawn is fail-fast: if the requested hypervisor is not
|
|
16
|
-
// available, the CLI returns VM_RUNTIME_UNAVAILABLE with a
|
|
17
|
-
// remediation hint rather than falling through to a different
|
|
18
|
-
// hypervisor (the caller chose a specific mode for a reason).
|
|
19
|
-
//
|
|
20
|
-
// Each spawned VM runs `sleep infinity` as the entrypoint; the
|
|
21
|
-
// VM's working dir is mounted from the host path, and the
|
|
22
|
-
// `peaks.leaseId` / `peaks.rid` labels are propagated via
|
|
23
|
-
// cloud-init metadata. Real workloads are expected to use
|
|
24
|
-
// `peaks vm exec` (a follow-up rid) to run commands inside
|
|
25
|
-
// the VM; Part 35 ships the lease + spawn/release surface
|
|
26
|
-
// only.
|
|
27
|
-
//
|
|
28
|
-
// The verb bodies live beside this file (`vm-spawn-command.ts`,
|
|
29
|
-
// `vm-release-command.ts`), over the shared vocabulary in
|
|
30
|
-
// `vm-command-shared.ts` and the dispatch helpers in
|
|
31
|
-
// `vm-hypervisor-runtime.ts`; `vm-hypervisor-probe.ts` and
|
|
32
|
-
// `vm-status-command.ts` were already siblings.
|
|
33
|
-
import { registerVmStatusCommand } from './vm-status-command.js';
|
|
34
|
-
import { registerVmSpawnCommand } from './vm-spawn-command.js';
|
|
35
|
-
import { registerVmReleaseCommand } from './vm-release-command.js';
|
|
36
|
-
export function registerVmCommand(program, io) {
|
|
37
|
-
const cmd = program
|
|
38
|
-
.command('vm')
|
|
39
|
-
.description('L4 VM isolation: spawn/release VM leases via kvm | hyperkit | hyperv (Part 35; pairs with --isolation vm on dispatch).');
|
|
40
|
-
// The host probe rides on the same parent, so `peaks vm status`
|
|
41
|
-
// can say which prerequisite is missing before a spawn fails.
|
|
42
|
-
registerVmStatusCommand(cmd, io);
|
|
43
|
-
registerVmSpawnCommand(cmd, io);
|
|
44
|
-
registerVmReleaseCommand(cmd, io);
|
|
45
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { VmHypervisor } from '../../services/vm/vm-lease.js';
|
|
2
|
-
export type HypervisorProbeRow = {
|
|
3
|
-
readonly hypervisor: VmHypervisor;
|
|
4
|
-
readonly binary: string;
|
|
5
|
-
readonly available: boolean;
|
|
6
|
-
/** The version line when available; why not when it is not. */
|
|
7
|
-
readonly detail: string;
|
|
8
|
-
};
|
|
9
|
-
/** Every hypervisor the CLI can dispatch to, and the binary it shells out to. */
|
|
10
|
-
export declare const VM_HYPERVISOR_BINARIES: ReadonlyArray<{
|
|
11
|
-
hypervisor: VmHypervisor;
|
|
12
|
-
binary: string;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function binaryForHypervisor(requested: VmHypervisor): string;
|
|
15
|
-
/**
|
|
16
|
-
* Is this hypervisor usable here right now? `kvm` needs both the libvirt CLI
|
|
17
|
-
* and the kernel device node; the others need their binary to answer.
|
|
18
|
-
*/
|
|
19
|
-
export declare function detectHypervisor(requested: VmHypervisor): {
|
|
20
|
-
ok: true;
|
|
21
|
-
binary: string;
|
|
22
|
-
} | {
|
|
23
|
-
ok: false;
|
|
24
|
-
stderr: string;
|
|
25
|
-
};
|
|
26
|
-
/** Probe every dispatchable hypervisor, in the order the CLI lists them. */
|
|
27
|
-
export declare function probeHypervisors(): HypervisorProbeRow[];
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// src/cli/commands/vm-hypervisor-probe.ts
|
|
2
|
-
//
|
|
3
|
-
// The host-side question every `peaks vm` path has to answer: is there a
|
|
4
|
-
// hypervisor on this machine that a VM could actually be created with?
|
|
5
|
-
//
|
|
6
|
-
// Split out of `vm-commands.ts` because two consumers need it — `vm spawn`
|
|
7
|
-
// (fail-fast before leasing) and `vm status` (report every hypervisor,
|
|
8
|
-
// including the ones that are absent) — and because a command file that both
|
|
9
|
-
// registers commands and answers host questions is the shape this repo keeps
|
|
10
|
-
// paying for in `max-lines` findings.
|
|
11
|
-
//
|
|
12
|
-
// Detection is a real probe, not a platform guess: the binary must answer
|
|
13
|
-
// `--version`, and for KVM the kernel device node must exist. That means the
|
|
14
|
-
// answer can change between two calls (an operator installs libvirt mid-run),
|
|
15
|
-
// which is exactly why `vm status` reports it instead of caching it.
|
|
16
|
-
import { execSync } from 'node:child_process';
|
|
17
|
-
import { existsSync } from 'node:fs';
|
|
18
|
-
/** Every hypervisor the CLI can dispatch to, and the binary it shells out to. */
|
|
19
|
-
export const VM_HYPERVISOR_BINARIES = [
|
|
20
|
-
{ hypervisor: 'kvm', binary: 'virsh' },
|
|
21
|
-
{ hypervisor: 'hyperkit', binary: 'hvftool' },
|
|
22
|
-
{ hypervisor: 'hyperv', binary: 'hvc' }
|
|
23
|
-
];
|
|
24
|
-
export function binaryForHypervisor(requested) {
|
|
25
|
-
const entry = VM_HYPERVISOR_BINARIES.find((row) => row.hypervisor === requested);
|
|
26
|
-
if (entry === undefined) {
|
|
27
|
-
throw new Error(`unknown hypervisor: ${requested}`);
|
|
28
|
-
}
|
|
29
|
-
return entry.binary;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Is this hypervisor usable here right now? `kvm` needs both the libvirt CLI
|
|
33
|
-
* and the kernel device node; the others need their binary to answer.
|
|
34
|
-
*/
|
|
35
|
-
export function detectHypervisor(requested) {
|
|
36
|
-
const binary = binaryForHypervisor(requested);
|
|
37
|
-
try {
|
|
38
|
-
const version = execSync(`${binary} --version`, {
|
|
39
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
40
|
-
encoding: 'utf8',
|
|
41
|
-
windowsHide: true
|
|
42
|
-
});
|
|
43
|
-
if (requested === 'kvm' && !existsSync('/dev/kvm')) {
|
|
44
|
-
return { ok: false, stderr: 'KVM kernel module not loaded (/dev/kvm absent)' };
|
|
45
|
-
}
|
|
46
|
-
return { ok: true, binary: `${binary} (${version.trim().split('\n')[0] ?? ''})` };
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
const message = error.message;
|
|
50
|
-
// A binary that is not installed fails at exec time, and on Windows that
|
|
51
|
-
// error arrives in the console codepage — it renders as mojibake in the
|
|
52
|
-
// terminal. Name the cause instead of quoting it.
|
|
53
|
-
const absent = /not recognized|not found|ENOENT|Command failed/i.test(message);
|
|
54
|
-
return {
|
|
55
|
-
ok: false,
|
|
56
|
-
stderr: absent ? `${binary} is not on PATH` : (message.split('\n')[0] ?? '')
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/** Probe every dispatchable hypervisor, in the order the CLI lists them. */
|
|
61
|
-
export function probeHypervisors() {
|
|
62
|
-
return VM_HYPERVISOR_BINARIES.map((entry) => {
|
|
63
|
-
const detected = detectHypervisor(entry.hypervisor);
|
|
64
|
-
return detected.ok
|
|
65
|
-
? {
|
|
66
|
-
hypervisor: entry.hypervisor,
|
|
67
|
-
binary: entry.binary,
|
|
68
|
-
available: true,
|
|
69
|
-
detail: detected.binary
|
|
70
|
-
}
|
|
71
|
-
: {
|
|
72
|
-
hypervisor: entry.hypervisor,
|
|
73
|
-
binary: entry.binary,
|
|
74
|
-
available: false,
|
|
75
|
-
detail: detected.stderr
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { VmHypervisor } from '../../services/vm/vm-lease.js';
|
|
2
|
-
export declare function spawnVmWithHypervisor(args: {
|
|
3
|
-
hypervisor: VmHypervisor;
|
|
4
|
-
image: string;
|
|
5
|
-
mount: string;
|
|
6
|
-
leaseId: string;
|
|
7
|
-
rid: string;
|
|
8
|
-
workdir: string;
|
|
9
|
-
}): {
|
|
10
|
-
vmId: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function destroyVmWithHypervisor(args: {
|
|
13
|
-
hypervisor: VmHypervisor;
|
|
14
|
-
vmId: string;
|
|
15
|
-
}): boolean;
|