peaks-loop 4.1.5 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +36 -0
  3. package/README-en.md +47 -183
  4. package/README.md +24 -188
  5. package/dist/cli/commands/best-practice-scan-command.d.ts +11 -6
  6. package/dist/cli/commands/best-practice-scan-command.js +35 -20
  7. package/dist/cli/commands/best-practice-scan-helpers.d.ts +47 -0
  8. package/dist/cli/commands/best-practice-scan-helpers.js +88 -5
  9. package/dist/cli/commands/best-practice-scan-lookup-results.d.ts +13 -0
  10. package/dist/cli/commands/best-practice-scan-lookup-results.js +237 -0
  11. package/dist/cli/commands/dispatch-command-spec.js +1 -1
  12. package/dist/cli/commands/dispatch-isolation-lease.d.ts +1 -1
  13. package/dist/cli/commands/dispatch-isolation-lease.js +6 -53
  14. package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
  15. package/dist/cli/commands/dispatch-prompt-composition.d.ts +1 -1
  16. package/dist/cli/commands/dispatch-record-write.d.ts +1 -1
  17. package/dist/cli/commands/dispatch-tool-call.d.ts +1 -1
  18. package/dist/cli/commands/openspec-command-shared.js +2 -2
  19. package/dist/cli/commands/request-transition-failures.js +31 -4
  20. package/dist/cli/commands/request-transition-preflight.js +1 -1
  21. package/dist/cli/commands/slice-decompose-artifacts.js +2 -1
  22. package/dist/cli/commands/verdict-aggregate-command.js +2 -1
  23. package/dist/cli/commands/workflow-gate-commands.js +4 -4
  24. package/dist/cli/program.js +0 -2
  25. package/dist/services/artifacts/artifact-contract-block.js +21 -2
  26. package/dist/services/artifacts/artifact-prerequisites.js +7 -7
  27. package/dist/services/artifacts/rd-transition-gates.d.ts +33 -0
  28. package/dist/services/artifacts/rd-transition-gates.js +71 -0
  29. package/dist/services/artifacts/request-artifact-service.js +22 -20
  30. package/dist/services/artifacts/request-artifact-state-helpers.d.ts +9 -1
  31. package/dist/services/artifacts/request-artifact-state-helpers.js +6 -4
  32. package/dist/services/audit-independent/judged-declaration-check.d.ts +1 -0
  33. package/dist/services/audit-independent/judged-declaration-check.js +62 -1
  34. package/dist/services/context/build-dispatch-system-prompt.d.ts +5 -9
  35. package/dist/services/context/build-dispatch-system-prompt.js +11 -11
  36. package/dist/services/context/post-compact-reinjection.js +1 -1
  37. package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
  38. package/dist/services/dispatch/test-tool-detection.js +12 -1
  39. package/dist/services/evidence/evidence-generator.js +8 -4
  40. package/dist/services/openspec/coverage-evidence-reader.d.ts +9 -9
  41. package/dist/services/openspec/coverage-evidence-reader.js +8 -8
  42. package/dist/services/openspec/openspec-archive-service.d.ts +1 -1
  43. package/dist/services/openspec/openspec-archive-service.js +6 -6
  44. package/dist/services/scan/file-size-baseline.d.ts +13 -6
  45. package/dist/services/scan/file-size-baseline.js +54 -31
  46. package/dist/services/scan/file-size-scan.d.ts +7 -14
  47. package/dist/services/scan/file-size-scan.js +6 -1
  48. package/dist/services/scan/type-corroboration.d.ts +32 -0
  49. package/dist/services/scan/type-corroboration.js +51 -0
  50. package/dist/services/scan/type-sanity-service.d.ts +14 -0
  51. package/dist/services/scan/type-sanity-service.js +10 -19
  52. package/dist/services/security/safe-settings-path.d.ts +5 -0
  53. package/dist/services/security/safe-settings-path.js +64 -8
  54. package/dist/services/skill/resume-detector.js +8 -8
  55. package/dist/services/workflow/pipeline-verify-gate-support.d.ts +24 -8
  56. package/dist/services/workflow/pipeline-verify-gate-support.js +32 -38
  57. package/dist/services/workflow/pipeline-verify-qa-phase.d.ts +102 -0
  58. package/dist/services/workflow/pipeline-verify-qa-phase.js +176 -0
  59. package/dist/services/workflow/pipeline-verify-service.js +26 -27
  60. package/dist/services/workflow/request-type-resolution.d.ts +99 -0
  61. package/dist/services/workflow/request-type-resolution.js +130 -0
  62. package/dist/services/workflow/workflow-skip-service.d.ts +1 -0
  63. package/dist/services/workflow/workflow-skip-service.js +19 -21
  64. package/dist/services/workflow/workflow-state-store.d.ts +9 -0
  65. package/dist/services/workflow/workflow-state-store.js +26 -1
  66. package/dist/shared/incrementing-number.d.ts +23 -2
  67. package/dist/shared/incrementing-number.js +57 -15
  68. package/package.json +5 -7
  69. package/skills/bee/peaks-prd/SKILL.md +3 -2
  70. package/skills/peaks-code/SKILL.md +32 -15
  71. package/dist/cli/commands/vm-command-shared.d.ts +0 -23
  72. package/dist/cli/commands/vm-command-shared.js +0 -23
  73. package/dist/cli/commands/vm-commands.d.ts +0 -3
  74. package/dist/cli/commands/vm-commands.js +0 -45
  75. package/dist/cli/commands/vm-hypervisor-probe.d.ts +0 -27
  76. package/dist/cli/commands/vm-hypervisor-probe.js +0 -78
  77. package/dist/cli/commands/vm-hypervisor-runtime.d.ts +0 -15
  78. package/dist/cli/commands/vm-hypervisor-runtime.js +0 -64
  79. package/dist/cli/commands/vm-release-command.d.ts +0 -5
  80. package/dist/cli/commands/vm-release-command.js +0 -101
  81. package/dist/cli/commands/vm-spawn-command.d.ts +0 -5
  82. package/dist/cli/commands/vm-spawn-command.js +0 -177
  83. package/dist/cli/commands/vm-status-command.d.ts +0 -3
  84. package/dist/cli/commands/vm-status-command.js +0 -50
  85. package/dist/services/vm/vm-lease.d.ts +0 -40
  86. package/dist/services/vm/vm-lease.js +0 -160
@@ -1,50 +0,0 @@
1
- // src/cli/commands/vm-status-command.ts
2
- //
3
- // `peaks vm status` — the read-only host probe that rides on the `vm` parent.
4
- //
5
- // `peaks vm spawn` refuses with VM_RUNTIME_UNAVAILABLE and
6
- // `peaks sub-agent dispatch --isolation vm` refuses with
7
- // ISOLATION_VM_NOT_YET_IMPLEMENTED, but neither said WHICH prerequisite is
8
- // missing on the machine actually running the command: the hypervisor binary,
9
- // the KVM device node, or a host with no hypervisor at all. The only way to
10
- // find out was to attempt a spawn that was going to fail.
11
- //
12
- // This reports it, and it does not pretend the runtime exists: a probe that
13
- // finds libvirt on PATH still leaves `--isolation vm` refused, because the
14
- // missing piece is peaks' VM runtime (image, `vm exec`, per-OS bindings), not
15
- // the hypervisor. The envelope says so rather than letting a green probe read
16
- // as "vm works now".
17
- //
18
- import { probeHypervisors } from './vm-hypervisor-probe.js';
19
- import { addJsonOption, printResult } from '../cli-helpers.js';
20
- import { fail, ok } from 'peaks-loop-shared/result';
21
- export function registerVmStatusCommand(vm, io) {
22
- addJsonOption(vm
23
- .command('status')
24
- .description('Report which VM hypervisor this host offers (read-only probe; the peaks VM runtime is a separate rid)')).action((options) => {
25
- const rows = probeHypervisors();
26
- const anyAvailable = rows.some((row) => row.available);
27
- const data = {
28
- platform: process.platform,
29
- hypervisors: rows,
30
- anyAvailable,
31
- // The runtime statement, kept next to the probe result so the two can
32
- // never be read apart.
33
- dispatchIsolationVm: 'not implemented'
34
- };
35
- for (const row of rows) {
36
- io.stdout(`${row.hypervisor} ${row.available ? 'present' : 'absent'} ${row.binary}: ${row.detail}`);
37
- }
38
- io.stdout(`platform: ${process.platform}`);
39
- const nextActions = [
40
- 'The peaks VM runtime (image build, `peaks vm exec`, Hyper-V/HyperKit bindings) is not implemented yet: `peaks sub-agent dispatch --isolation vm` stays refused even when a hypervisor is present.',
41
- 'For isolation today use --isolation worktree (L2, production) or --isolation container (L4, docker/podman).'
42
- ];
43
- if (!anyAvailable) {
44
- printResult(io, fail('vm.status', 'VM_RUNTIME_UNAVAILABLE', `no VM hypervisor is usable on ${process.platform}: install one of virsh (KVM/libvirt, Linux), hvftool (HyperKit, macOS) or hvc (Hyper-V, Windows) — and on Linux the /dev/kvm device node — or drop --isolation and use worktree/container.`, data, nextActions), options.json);
45
- process.exitCode = 1;
46
- return;
47
- }
48
- printResult(io, ok('vm.status', data, [], nextActions), options.json);
49
- });
50
- }
@@ -1,40 +0,0 @@
1
- export type VmHypervisor = 'kvm' | 'hyperkit' | 'hyperv';
2
- export declare const VM_HYPERVISORS: ReadonlyArray<VmHypervisor>;
3
- export declare const DEFAULT_TTL_BY_ROLE: Readonly<Record<string, number>>;
4
- export declare const DEFAULT_TTL_MS: number | undefined;
5
- export declare const DEFAULT_VM_IMAGE = "peaks-base:22-slim";
6
- export type VmLeaseStatus = 'active' | 'released' | 'expired' | 'gc';
7
- export interface VmLease {
8
- readonly leaseId: string;
9
- readonly rid: string;
10
- readonly role: string;
11
- /** Host path mounted into the VM working dir. */
12
- readonly path: string;
13
- /** Hypervisor the VM runs under (kvm | hyperkit | hyperv). */
14
- readonly hypervisor: VmHypervisor;
15
- /** VM image name (e.g. 'peaks-base:22-slim'). */
16
- readonly image: string;
17
- /** VM domain id reported by virsh / hvftool / hvc. */
18
- readonly vmId: string;
19
- /** Unix epoch ms when the lease was created. */
20
- readonly createdAt: number;
21
- /** Unix epoch ms when the lease expires. */
22
- readonly expiresAt: number;
23
- /** Operator-supplied purpose text (audit log). */
24
- readonly purpose: string;
25
- readonly status: VmLeaseStatus;
26
- readonly consumedBySubAgents: ReadonlyArray<string>;
27
- }
28
- export type VmLeaseDraft = Omit<VmLease, 'status' | 'consumedBySubAgents'>;
29
- export declare function vmLeaseStoreDir(sessionRuntimeDir: string): string;
30
- export declare function vmLeaseFilePath(sessionRuntimeDir: string, leaseId: string): string;
31
- export declare function generateVmLeaseId(): string;
32
- export declare function ttlForVmRole(role: string): number;
33
- export declare function finalizeVmLease(draft: VmLeaseDraft): VmLease;
34
- export declare function markVmReleased(lease: VmLease): VmLease;
35
- export declare function markVmExpired(lease: VmLease): VmLease;
36
- export declare function markVmGc(lease: VmLease): VmLease;
37
- export declare function recordVmConsumption(lease: VmLease, subAgentId: string): VmLease;
38
- export declare function isVmLeaseActive(lease: VmLease, now?: number): boolean;
39
- export declare function serializeVmLease(lease: VmLease): string;
40
- export declare function deserializeVmLease(raw: string): VmLease;
@@ -1,160 +0,0 @@
1
- /**
2
- * vm-lease — pure-function lease store for `peaks vm spawn`.
3
- *
4
- * Parallels the design of `worktree-lease.ts` (Part 1) and
5
- * `container-lease.ts` (Part 12). The L4 VM isolation mode
6
- * (`--isolation vm` in dispatch) needs its own lease surface
7
- * so the PreToolUse gate can grant `docker`-class operations
8
- * to sub-agents that own a VM lease.
9
- *
10
- * Hypervisor support:
11
- * - kvm: virsh create + virsh destroy (Linux KVM via libvirt)
12
- * - hyperkit: hvftool create + hvftool stop (macOS HyperKit)
13
- * - hyperv: hvc create + hvc stop (Windows Hyper-V via the
14
- * Hyper-V cmdlets; the operator wires the entry shim)
15
- *
16
- * Each hypervisor has its own spawn pattern; the lease file
17
- * records which hypervisor was used so `peaks vm release`
18
- * can dispatch to the right cleanup command.
19
- */
20
- import { randomBytes } from 'node:crypto';
21
- import { posix as path } from 'node:path';
22
- import { normalizePath } from '../../shared/path-utils.js';
23
- export const VM_HYPERVISORS = Object.freeze([
24
- 'kvm',
25
- 'hyperkit',
26
- 'hyperv'
27
- ]);
28
- // PRD-002b slice 2 — extract lease-TTL primitives (same shape as
29
- // container-lease.ts / worktree-lease.ts). See config diff comment.
30
- const MINUTES_PER_HOUR = 60;
31
- const MS_PER_MINUTE = MINUTES_PER_HOUR * 1_000;
32
- const LEASE_RD_TTL_MINUTES = 30;
33
- const LEASE_QA_TTL_MINUTES = 15;
34
- const LEASE_UI_TTL_MINUTES = MINUTES_PER_HOUR;
35
- const LEASE_SC_TTL_MINUTES = 30;
36
- const LEASE_PRD_TTL_MINUTES = 15;
37
- const LEASE_GENERAL_TTL_MINUTES = 30;
38
- const LEASE_ID_RANDOM_BYTES = 8;
39
- export const DEFAULT_TTL_BY_ROLE = Object.freeze({
40
- rd: LEASE_RD_TTL_MINUTES * MS_PER_MINUTE,
41
- qa: LEASE_QA_TTL_MINUTES * MS_PER_MINUTE,
42
- ui: LEASE_UI_TTL_MINUTES * MS_PER_MINUTE,
43
- sc: LEASE_SC_TTL_MINUTES * MS_PER_MINUTE,
44
- prd: LEASE_PRD_TTL_MINUTES * MS_PER_MINUTE,
45
- general: LEASE_GENERAL_TTL_MINUTES * MS_PER_MINUTE
46
- });
47
- export const DEFAULT_TTL_MS = DEFAULT_TTL_BY_ROLE.rd;
48
- export const DEFAULT_VM_IMAGE = 'peaks-base:22-slim';
49
- export function vmLeaseStoreDir(sessionRuntimeDir) {
50
- return joinPath(sessionRuntimeDir, 'vm-leases');
51
- }
52
- export function vmLeaseFilePath(sessionRuntimeDir, leaseId) {
53
- return joinPath(vmLeaseStoreDir(sessionRuntimeDir), `${leaseId}.json`);
54
- }
55
- export function generateVmLeaseId() {
56
- return randomBytes(LEASE_ID_RANDOM_BYTES).toString('hex');
57
- }
58
- export function ttlForVmRole(role) {
59
- const normalized = role.toLowerCase();
60
- const candidate = DEFAULT_TTL_BY_ROLE[normalized];
61
- const fallback = DEFAULT_TTL_BY_ROLE['rd'] ?? LEASE_RD_TTL_MINUTES * MS_PER_MINUTE;
62
- return candidate ?? fallback;
63
- }
64
- export function finalizeVmLease(draft) {
65
- return { ...draft, status: 'active', consumedBySubAgents: [] };
66
- }
67
- export function markVmReleased(lease) {
68
- return { ...lease, status: 'released' };
69
- }
70
- export function markVmExpired(lease) {
71
- return { ...lease, status: 'expired' };
72
- }
73
- export function markVmGc(lease) {
74
- return { ...lease, status: 'gc' };
75
- }
76
- export function recordVmConsumption(lease, subAgentId) {
77
- if (lease.consumedBySubAgents.includes(subAgentId))
78
- return lease;
79
- return { ...lease, consumedBySubAgents: [...lease.consumedBySubAgents, subAgentId] };
80
- }
81
- export function isVmLeaseActive(lease, now = Date.now()) {
82
- return lease.status === 'active' && lease.expiresAt > now;
83
- }
84
- export function serializeVmLease(lease) {
85
- return JSON.stringify(lease, null, 2) + '\n';
86
- }
87
- export function deserializeVmLease(raw) {
88
- const parsed = JSON.parse(raw);
89
- if (typeof parsed !== 'object' || parsed === null) {
90
- throw new Error('vm lease file must contain a JSON object');
91
- }
92
- const obj = parsed;
93
- const required = [
94
- 'leaseId',
95
- 'rid',
96
- 'role',
97
- 'path',
98
- 'hypervisor',
99
- 'image',
100
- 'vmId',
101
- 'createdAt',
102
- 'expiresAt',
103
- 'purpose',
104
- 'status',
105
- 'consumedBySubAgents'
106
- ];
107
- for (const k of required) {
108
- if (!(k in obj))
109
- throw new Error(`vm lease missing field: ${k}`);
110
- }
111
- if (!VM_HYPERVISORS.includes(obj.hypervisor)) {
112
- throw new Error(`vm lease hypervisor invalid: ${String(obj.hypervisor)}`);
113
- }
114
- if (typeof obj.leaseId !== 'string')
115
- throw new Error('leaseId missing');
116
- if (typeof obj.rid !== 'string')
117
- throw new Error('rid missing');
118
- if (typeof obj.role !== 'string')
119
- throw new Error('role missing');
120
- if (typeof obj.path !== 'string')
121
- throw new Error('path missing');
122
- if (typeof obj.image !== 'string')
123
- throw new Error('image missing');
124
- if (typeof obj.vmId !== 'string')
125
- throw new Error('vmId missing');
126
- if (typeof obj.createdAt !== 'number')
127
- throw new Error('createdAt missing');
128
- if (typeof obj.expiresAt !== 'number')
129
- throw new Error('expiresAt missing');
130
- if (typeof obj.purpose !== 'string')
131
- throw new Error('purpose missing');
132
- if (typeof obj.status !== 'string')
133
- throw new Error('status missing');
134
- if (!Array.isArray(obj.consumedBySubAgents))
135
- throw new Error('consumedBySubAgents missing');
136
- return {
137
- leaseId: obj.leaseId,
138
- rid: obj.rid,
139
- role: obj.role,
140
- path: obj.path,
141
- hypervisor: obj.hypervisor,
142
- image: obj.image,
143
- vmId: obj.vmId,
144
- createdAt: obj.createdAt,
145
- expiresAt: obj.expiresAt,
146
- purpose: obj.purpose,
147
- status: obj.status,
148
- consumedBySubAgents: obj.consumedBySubAgents
149
- };
150
- }
151
- function joinPath(...segments) {
152
- if (segments.length === 0)
153
- return '';
154
- const normalized = segments.map((s) => normalizePath(s));
155
- let acc = normalized[0];
156
- for (let i = 1; i < normalized.length; i++) {
157
- acc = path.join(acc, normalized[i]);
158
- }
159
- return acc;
160
- }