peaks-loop 4.1.4 → 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.
- package/.claude-plugin/marketplace.json +7 -2
- package/CHANGELOG.md +148 -0
- package/README-en.md +47 -183
- package/README.md +24 -188
- package/dist/cli/cli-helpers.d.ts +20 -0
- package/dist/cli/cli-helpers.js +34 -0
- package/dist/cli/commands/_register.js +2 -0
- 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/code-commands.d.ts +6 -4
- package/dist/cli/commands/code-commands.js +6 -4
- package/dist/cli/commands/code-gate-command.d.ts +5 -5
- package/dist/cli/commands/code-gate-command.js +49 -9
- package/dist/cli/commands/code-mode-gate-plan-command.d.ts +1 -1
- package/dist/cli/commands/code-mode-gate-plan-command.js +2 -2
- package/dist/cli/commands/core/memory-extract-command.js +10 -5
- package/dist/cli/commands/dispatch-cli-invocation-check.d.ts +108 -0
- package/dist/cli/commands/dispatch-cli-invocation-check.js +87 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.d.ts +66 -0
- package/dist/cli/commands/dispatch-cli-invocation-scan.js +162 -0
- package/dist/cli/commands/dispatch-command-spec.js +1 -1
- package/dist/cli/commands/dispatch-commands.js +12 -5
- 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-preflight.js +46 -0
- package/dist/cli/commands/dispatch-prompt-blocks.d.ts +1 -1
- package/dist/cli/commands/dispatch-prompt-composition.d.ts +7 -1
- package/dist/cli/commands/dispatch-prompt-composition.js +29 -7
- 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/doc-commands.js +1 -1
- package/dist/cli/commands/feedback-commands-helpers.js +1 -1
- package/dist/cli/commands/final-review-prepare-command.js +22 -1
- package/dist/cli/commands/gate-commands-enforce.js +3 -3
- package/dist/cli/commands/hook-handle.js +41 -20
- package/dist/cli/commands/lint-commands.js +3 -1
- package/dist/cli/commands/loop-eval-capture-index.js +2 -4
- package/dist/cli/commands/openspec-command-shared.js +2 -2
- package/dist/cli/commands/perf-audit-commands.js +15 -5
- package/dist/cli/commands/project-commands.js +9 -6
- package/dist/cli/commands/race-commands.d.ts +15 -0
- package/dist/cli/commands/race-commands.js +65 -0
- package/dist/cli/commands/race-pilot-gate-record-command.d.ts +3 -0
- package/dist/cli/commands/race-pilot-gate-record-command.js +81 -0
- package/dist/cli/commands/request-command-options.d.ts +8 -0
- package/dist/cli/commands/request-commands.js +2 -0
- package/dist/cli/commands/request-init-command.js +67 -12
- package/dist/cli/commands/{vm-status-command.d.ts → request-retag-command.d.ts} +1 -1
- package/dist/cli/commands/request-retag-command.js +50 -0
- package/dist/cli/commands/request-show-command.d.ts +8 -0
- package/dist/cli/commands/request-show-command.js +14 -1
- package/dist/cli/commands/request-transition-command.js +12 -4
- package/dist/cli/commands/request-transition-failures.d.ts +14 -0
- package/dist/cli/commands/request-transition-failures.js +76 -7
- package/dist/cli/commands/request-transition-preflight.js +1 -1
- package/dist/cli/commands/scan-scope-commands.js +2 -2
- package/dist/cli/commands/security-audit-commands.js +26 -6
- 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/commands/worktree-lease-gc-command.js +1 -1
- package/dist/cli/program.js +0 -2
- package/dist/services/artifacts/artifact-contract-block.d.ts +53 -0
- package/dist/services/artifacts/artifact-contract-block.js +231 -0
- package/dist/services/artifacts/artifact-prerequisites.d.ts +27 -19
- package/dist/services/artifacts/artifact-prerequisites.js +65 -135
- package/dist/services/artifacts/artifact-templates.d.ts +1 -1
- package/dist/services/artifacts/artifact-templates.js +17 -10
- package/dist/services/artifacts/prerequisite-checks.d.ts +87 -0
- package/dist/services/artifacts/prerequisite-checks.js +198 -0
- package/dist/services/artifacts/prerequisite-transition-event.d.ts +20 -0
- package/dist/services/artifacts/prerequisite-transition-event.js +27 -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-metadata.d.ts +31 -0
- package/dist/services/artifacts/request-artifact-metadata.js +44 -0
- package/dist/services/artifacts/request-artifact-service.d.ts +5 -0
- package/dist/services/artifacts/request-artifact-service.js +43 -69
- package/dist/services/artifacts/request-artifact-state-helpers.d.ts +21 -1
- package/dist/services/artifacts/request-artifact-state-helpers.js +34 -8
- package/dist/services/artifacts/request-retag-service.d.ts +68 -0
- package/dist/services/artifacts/request-retag-service.js +125 -0
- package/dist/services/artifacts/request-state-order.d.ts +38 -0
- package/dist/services/artifacts/request-state-order.js +99 -0
- package/dist/services/artifacts/request-type-demand.d.ts +44 -0
- package/dist/services/artifacts/request-type-demand.js +71 -0
- package/dist/services/audit/audit-goal-service.d.ts +7 -0
- package/dist/services/audit/enforcers/active-skill-resolver.d.ts +18 -0
- package/dist/services/audit/enforcers/active-skill-resolver.js +48 -1
- package/dist/services/audit/enforcers/code-ban.d.ts +11 -2
- package/dist/services/audit/enforcers/code-ban.js +21 -1
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.d.ts +17 -0
- package/dist/services/audit/red-line-catalog-p2-a-bee-runtime.js +24 -7
- package/dist/services/audit-independent/handoff-missing-refusal.d.ts +26 -0
- package/dist/services/audit-independent/handoff-missing-refusal.js +109 -0
- package/dist/services/audit-independent/handoff-readers.d.ts +37 -0
- package/dist/services/audit-independent/handoff-readers.js +81 -0
- package/dist/services/audit-independent/index.d.ts +6 -1
- package/dist/services/audit-independent/index.js +6 -1
- package/dist/services/audit-independent/judged-declaration-build.d.ts +48 -0
- package/dist/services/audit-independent/judged-declaration-build.js +73 -0
- package/dist/services/audit-independent/judged-declaration-check.d.ts +80 -0
- package/dist/services/audit-independent/judged-declaration-check.js +216 -0
- package/dist/services/audit-independent/judged-declaration.d.ts +94 -0
- package/dist/services/audit-independent/judged-declaration.js +218 -0
- package/dist/services/audit-independent/perf-audit-service.js +12 -14
- package/dist/services/audit-independent/security-audit-artifact.d.ts +28 -0
- package/dist/services/audit-independent/security-audit-artifact.js +90 -0
- package/dist/services/audit-independent/security-audit-service.d.ts +6 -53
- package/dist/services/audit-independent/security-audit-service.js +34 -178
- package/dist/services/capability-guard-runner/contracts/J05.js +60 -14
- package/dist/services/codegraph/codegraph-index-integrity.js +2 -0
- package/dist/services/context/build-dispatch-system-prompt.d.ts +8 -12
- package/dist/services/context/build-dispatch-system-prompt.js +18 -18
- package/dist/services/context/collector.js +5 -1
- package/dist/services/context/post-compact-reinjection.js +1 -1
- package/dist/services/dispatch/active-dispatch-index.d.ts +36 -0
- package/dist/services/dispatch/active-dispatch-index.js +118 -0
- package/dist/services/dispatch/batch-counter.js +1 -2
- package/dist/services/dispatch/dispatch-record-writer.d.ts +29 -16
- package/dist/services/dispatch/dispatch-record-writer.js +58 -100
- package/dist/services/dispatch/dispatch-sub-agent.js +1 -1
- package/dist/services/dispatch/karpathy-block.d.ts +55 -0
- package/dist/services/dispatch/karpathy-block.js +101 -0
- package/dist/services/dispatch/ledger-reaper.d.ts +80 -0
- package/dist/services/dispatch/ledger-reaper.js +131 -0
- package/dist/services/dispatch/test-tool-detection.d.ts +17 -1
- package/dist/services/dispatch/test-tool-detection.js +12 -1
- package/dist/services/evidence/evidence-generator.js +23 -12
- package/dist/services/feedback/feedback-promotion-service.d.ts +8 -11
- package/dist/services/feedback/feedback-promotion-service.js +30 -35
- package/dist/services/feedback/promotion-artifact-json-evidence.d.ts +18 -0
- package/dist/services/feedback/promotion-artifact-missing.d.ts +22 -0
- package/dist/services/feedback/promotion-artifact-missing.js +63 -0
- package/dist/services/final-review/final-review-contract.d.ts +95 -4
- package/dist/services/final-review/final-review-contract.js +64 -0
- package/dist/services/final-review/final-review-delivery.d.ts +13 -0
- package/dist/services/final-review/final-review-delivery.js +26 -12
- package/dist/services/final-review/final-review-evidence-collect.js +8 -53
- package/dist/services/final-review/final-review-evidence-records.d.ts +21 -0
- package/dist/services/final-review/final-review-evidence-records.js +67 -0
- package/dist/services/final-review/final-review-evidence-sources.d.ts +22 -0
- package/dist/services/final-review/final-review-evidence-sources.js +28 -4
- package/dist/services/final-review/final-review-prompt.js +19 -6
- package/dist/services/final-review/final-review-runner.js +5 -0
- package/dist/services/final-review/final-review-service.d.ts +2 -2
- package/dist/services/final-review/index.d.ts +1 -1
- package/dist/services/final-review/pre-post-diff.d.ts +2 -75
- package/dist/services/final-review/pre-post-diff.js +60 -59
- package/dist/services/hooks/pre-tool-code-gate.d.ts +7 -1
- package/dist/services/hooks/pre-tool-code-gate.js +21 -2
- package/dist/services/hooks/worktree-authorization-gate.js +6 -31
- package/dist/services/hooks/worktree-refusal-messages.d.ts +74 -0
- package/dist/services/hooks/worktree-refusal-messages.js +102 -0
- package/dist/services/lint/eslint-runner-support.d.ts +1 -1
- package/dist/services/lint/eslint-runner-support.js +2 -1
- package/dist/services/lint/eslint-runner-types.d.ts +8 -0
- package/dist/services/lint/eslint-runner.js +17 -4
- package/dist/services/llm/anthropic-runner.js +24 -7
- package/dist/services/loop/loop-observability.d.ts +39 -0
- package/dist/services/loop/loop-observability.js +55 -0
- package/dist/services/loop/monotonic-guard.js +6 -9
- package/dist/services/loop/monotonic-runner.js +8 -7
- package/dist/services/loop/run-driver.js +18 -22
- package/dist/services/memory/project-memory-service/index/kind-dispatch.js +14 -1
- package/dist/services/memory/project-memory-service/index/project-memory-plan-exec.js +13 -2
- package/dist/services/memory/project-memory-service/index.d.ts +2 -2
- package/dist/services/memory/project-memory-service/index.js +1 -1
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.d.ts +36 -0
- package/dist/services/memory/project-memory-service/parsers/frontmatter-parse.js +48 -2
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.d.ts +23 -1
- package/dist/services/memory/project-memory-service/parsers/markdown-pure.js +37 -0
- package/dist/services/memory/project-memory-service/types.d.ts +32 -0
- package/dist/services/observability/observability-service.d.ts +7 -0
- package/dist/services/observability/observability-service.js +2 -1
- 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/prd/gate-evidence-derivation.d.ts +4 -3
- package/dist/services/prd/gate-evidence-derivation.js +4 -3
- package/dist/services/qa/bdd-test-style-verifier.js +22 -8
- package/dist/services/race/gate2-evaluator.d.ts +58 -0
- package/dist/services/race/gate2-evaluator.js +111 -0
- package/dist/services/race/gate2-policy.d.ts +17 -0
- package/dist/services/race/gate2-policy.js +31 -0
- package/dist/services/race/lane-phase.d.ts +19 -0
- package/dist/services/race/lane-phase.js +113 -0
- package/dist/services/race/pilot-gate-store.d.ts +67 -0
- package/dist/services/race/pilot-gate-store.js +227 -0
- package/dist/services/scan/file-size-baseline.d.ts +33 -0
- package/dist/services/scan/file-size-baseline.js +173 -0
- package/dist/services/scan/file-size-scan.d.ts +35 -3
- package/dist/services/scan/file-size-scan.js +63 -42
- 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 +23 -22
- 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 +11 -11
- package/dist/services/skills/hooks-codegate-superpowers.d.ts +5 -6
- package/dist/services/skills/hooks-codegate-superpowers.js +7 -8
- package/dist/services/skills/hooks-settings-service.d.ts +1 -1
- package/dist/services/skills/hooks-settings-service.js +1 -1
- package/dist/services/skills/presence-lease-order.d.ts +13 -0
- package/dist/services/skills/presence-lease-order.js +24 -0
- package/dist/services/skills/skill-conformance-service.js +1 -0
- package/dist/services/skills/skill-statusline-service.js +4 -7
- package/dist/services/slice/slice-check-service.js +8 -8
- package/dist/services/workflow/pipeline-verify-gate-support.d.ts +24 -8
- package/dist/services/workflow/pipeline-verify-gate-support.js +34 -39
- 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-service.js +27 -28
- 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 -20
- package/dist/services/workflow/workflow-skip-service.js +22 -25
- 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/claude-settings-retirements.d.ts +54 -0
- package/dist/services/workspace/claude-settings-retirements.js +112 -0
- package/dist/services/workspace/claude-settings-template-merge.d.ts +35 -15
- package/dist/services/workspace/claude-settings-template-merge.js +33 -53
- package/dist/services/workspace/claude-settings-template.d.ts +62 -12
- package/dist/services/workspace/claude-settings-template.js +58 -58
- package/dist/services/workspace/migrate-1-4-1-service.js +3 -0
- package/dist/services/workspace/reconcile-service.js +0 -1
- package/dist/shared/incrementing-number.d.ts +33 -2
- package/dist/shared/incrementing-number.js +72 -3
- package/package.json +5 -7
- package/skills/bee/peaks-perf-audit/SKILL.md +1 -1
- package/skills/bee/peaks-prd/SKILL.md +4 -3
- package/skills/bee/peaks-qa/SKILL.md +1 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
- package/skills/bee/peaks-qa/references/qa-transition-gates.md +1 -1
- package/skills/bee/peaks-rd/SKILL.md +2 -2
- package/skills/bee/peaks-rd/references/rd-fanout-contracts.md +1 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +8 -4
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +3 -3
- package/skills/bee/peaks-rd/references/v2-12-fanout-collapse.md +2 -2
- package/skills/bee/peaks-rd/references/writing-handoff-frontmatter.md +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +1 -1
- package/skills/bee/peaks-sc/SKILL.md +1 -1
- package/skills/bee/peaks-security-audit/SKILL.md +10 -2
- package/skills/bee/peaks-txt/SKILL.md +4 -3
- package/skills/bee/peaks-ui/SKILL.md +3 -3
- package/skills/peaks-audit/SKILL.md +29 -1
- package/skills/peaks-code/SKILL.md +37 -17
- package/skills/peaks-code/references/fast-lane-norm.md +42 -0
- package/skills/peaks-code/references/fast-mode.md +3 -2
- package/skills/peaks-code/references/local-artifact-workspace.md +3 -3
- package/skills/peaks-code/references/micro-cycle.md +3 -3
- package/skills/peaks-code/references/resume-detection.md +1 -1
- package/skills/peaks-code/references/runbook.md +12 -6
- package/skills/peaks-code/references/step-11-memory-sediment.md +4 -0
- package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
- package/skills/peaks-code/references/swarm-dispatch-contract.md +40 -16
- package/skills/peaks-code/references/workflow-gates-and-types.md +6 -6
- package/skills/peaks-code/references/worktree-governance.md +4 -4
- package/skills/peaks-content/SKILL.md +1 -1
- package/skills/peaks-doctor/SKILL.md +1 -1
- package/skills/peaks-final-review/SKILL.md +31 -11
- package/skills/peaks-ide/SKILL.md +1 -1
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +1 -1
- package/skills/peaks-race-code/SKILL.md +185 -0
- package/skills/peaks-resume/SKILL.md +1 -1
- package/skills/peaks-slice-decompose/SKILL.md +1 -1
- package/skills/peaks-solo/SKILL.md +1 -1
- package/skills/peaks-sop/SKILL.md +1 -1
- package/skills/peaks-status/SKILL.md +1 -1
- package/skills/peaks-test/SKILL.md +7 -4
- 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.js +0 -50
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.d.ts +0 -23
- package/dist/services/audit/enforcers/lint-peaks-skill-runtime.js +0 -64
- package/dist/services/vm/vm-lease.d.ts +0 -40
- package/dist/services/vm/vm-lease.js +0 -160
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: peaks-race-code
|
|
3
|
+
description: Fast lane for code work — this window edits source directly, with no sub-agents and no paperwork. Use it when a code task is small enough that opening a second context window is the whole cost, i.e. trivial and everyday small features and bug fixes whose diff you can hold in your head. Not for a task that touches one of the risk surfaces the fast-lane norm names (`../peaks-code/references/fast-lane-norm.md`), and not for work that needs a durable audit trail — those belong to peaks-code; read the norm before you decide. Triggers on "/peaks-race-code", "peaks race", "race this", "fast lane", "直接改,别走全流程".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
7
|
+
|
|
8
|
+
## Loop hygiene (every turn — MANDATORY)
|
|
9
|
+
|
|
10
|
+
**Skill header.** While this skill is active, open every turn with
|
|
11
|
+
`Peaks-Loop Skill: <skill> | Peaks-Loop Gate: <gate> | Next: <one short action>`.
|
|
12
|
+
Every turn, not only the first — it is how the user knows which skill is driving.
|
|
13
|
+
|
|
14
|
+
**Context is this skill's own business.** Run `peaks skill presence --json` every turn and
|
|
15
|
+
read its `context` block. When `action` is `auto-fire`, `pre-compact`, or `red-line`,
|
|
16
|
+
run `peaks code auto-compact --project .` **yourself**, then continue. Tell the user the
|
|
17
|
+
ratio in one line if it helps, but never hand them the compaction step: asking the user to
|
|
18
|
+
run `/compact` is the regression the zero-pause contract forbids. This holds in **every
|
|
19
|
+
mode** — standard *and* 24h. The mode moves the threshold, never the obligation.
|
|
20
|
+
|
|
21
|
+
**Read before you edit.** Read a file before your first `Edit` / `Write` / `MultiEdit` on
|
|
22
|
+
it — the normal way to work here — for every path outside `.peaks/**` (source, tests, docs,
|
|
23
|
+
config); `.peaks/**` writes are exempt.
|
|
24
|
+
|
|
25
|
+
**Expect one denial per file anyway — and do NOT pre-empt it.** A `PreToolUse` gate (ECC's
|
|
26
|
+
"Fact-Forcing Gate") denies the FIRST edit a session makes to any given path, once, by
|
|
27
|
+
design. Reading does NOT prevent it: the gate keys on the path's first touch, not on whether
|
|
28
|
+
you read it. **Do not recite its four questions before every edit** — it asks when it wants
|
|
29
|
+
them, and reciting unprompted burns a round-trip per file for nothing. Answer only when a
|
|
30
|
+
denial actually arrives.
|
|
31
|
+
|
|
32
|
+
**When one does arrive:** a denial is not a failure and the tool is not broken — your edit
|
|
33
|
+
was NOT applied. State the facts it asks for (importers, affected API, data schemas if any,
|
|
34
|
+
the user's verbatim instruction), then retry the SAME operation. The retry is allowed. Do not
|
|
35
|
+
switch tools, do not give up, do not retry blindly. One more thing worth knowing: an idle gap
|
|
36
|
+
of ~30 minutes clears the gate's "already passed" list, so a file you cleared earlier can be
|
|
37
|
+
denied again after a long pause. That is the gate resetting, not you regressing.
|
|
38
|
+
<!-- /peaks:loop-hygiene -->
|
|
39
|
+
|
|
40
|
+
# Peaks-Loop Race Code (the fast lane)
|
|
41
|
+
|
|
42
|
+
**This is a lane, not a mode of `peaks-code`.** `peaks-code`'s red line — the orchestrator is
|
|
43
|
+
not the implementer — is the reason it opens separate context windows, so a lane that lets
|
|
44
|
+
one window both orchestrate and implement cannot be one of its switches. It is a sibling
|
|
45
|
+
skill. There are three lanes, and this is the third:
|
|
46
|
+
|
|
47
|
+
| Lane | Who implements | Ceremony kept |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `peaks-code` (full) | a separate RD sub-agent | the whole workflow: all steps, Gate A–G, transition state machine |
|
|
50
|
+
| `peaks-code` fast mode | a separate RD sub-agent | fewer steps, the same separation of duties |
|
|
51
|
+
| **`peaks-race-code`** | **this window** | none of the above — see "What this lane does not write" |
|
|
52
|
+
|
|
53
|
+
Do not offer `peaks-code` fast mode as a working alternative: it is designed but not proven —
|
|
54
|
+
its executable path has no callers and `peaks code plan --fast` only prints a plan. Why the
|
|
55
|
+
three rungs stay apart, stated here so no reader needs a document outside this one: the two
|
|
56
|
+
fast rungs buy their speed from different things. `--fast` cuts ceremony — the full memory
|
|
57
|
+
load, the standards fan-out, the QA repair loop — and keeps a separate implementer for the
|
|
58
|
+
diff. This rung removes the separate implementer, which is the one cost that cutting ceremony
|
|
59
|
+
cannot reach. Merging them into a single rung would strand the work in between: tasks that do
|
|
60
|
+
want their diff implemented and reviewed by someone else, and do not want the rest of the
|
|
61
|
+
workflow.
|
|
62
|
+
|
|
63
|
+
**Loop Engineering role.** The red lines that govern every Loop-Engineering-participating
|
|
64
|
+
`peaks-*` skill live at `.peaks/standards/loop-engineering-guidelines.md`. This skill honours
|
|
65
|
+
`RL-1` (the user speaks or picks; the user never types a CLI verb) and `RL-8`. Read the RL-8
|
|
66
|
+
boundary carefully, because this name sits close to it: **`race` is a lane axis, not a
|
|
67
|
+
variant of `peaks-code`.** This skill shares peaks-code's domain and shares none of its
|
|
68
|
+
implementation right — that difference is the whole of it.
|
|
69
|
+
|
|
70
|
+
## The gate: what lets this window edit source
|
|
71
|
+
|
|
72
|
+
The CLI gate over direct source edits opens when **the driver resolved for this session is
|
|
73
|
+
`peaks-race-code`** — and that resolution has a precondition this file cannot meet for you:
|
|
74
|
+
the hook payload's caller id (`caller_id ?? session_id`) must equal the lease's own
|
|
75
|
+
`callerId`. When they differ the driver resolves to nothing, the edit is denied, and nothing
|
|
76
|
+
available here changes that — it is spec §12 **U4**, the design's own recorded biggest
|
|
77
|
+
engineering risk, deliberately left outside this slice. Where the two agree, set the driver
|
|
78
|
+
before your first edit, not after:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
peaks skill presence:set peaks-race-code --project . --mode <mode> --gate <gate>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The name is a self-report — the command accepts any string — so read the next four points
|
|
85
|
+
as the terms of the deal, not as caveats:
|
|
86
|
+
|
|
87
|
+
- **This is a discipline gate, not a security boundary.** It stops the reflex ("this change
|
|
88
|
+
is small, I will just do it here"), not an actor. It already fails open on a malformed
|
|
89
|
+
payload, a missing path and an internal error, and it is not hardened against a deliberate
|
|
90
|
+
bypass. Never describe it as enforcement, and do not spend effort making it one.
|
|
91
|
+
- **Once the hook entry is installed**, a direct edit under a hard-blocked path family is
|
|
92
|
+
refused unless the resolved driver is `peaks-race-code` (exit 2,
|
|
93
|
+
`PEAKS_CODE_PROHIBITED_DIRECT_EDIT`); a driver that resolves to nothing gets the same
|
|
94
|
+
verdict. Fix the driver when the driver is what is wrong; when the deny is the U4 mismatch
|
|
95
|
+
above, do not hunt for a fix that does not exist — name it as the known gap, and never
|
|
96
|
+
route around the refusal either way.
|
|
97
|
+
- **Nothing in this lane is blocked before the fact.** The gate bites only where its hook
|
|
98
|
+
entry is installed (`peaks hooks install`), and the commit-side rule is detect-only (proof
|
|
99
|
+
3 below). Never tell the user a rule was enforced when the only thing that happened is that
|
|
100
|
+
nobody looked.
|
|
101
|
+
- **A second gate exists, and this section does not speak for it.** `peaks hooks install
|
|
102
|
+
--scope global` also copies `src/services/hooks/pre-tool-code-gate.sh` into the IDE's
|
|
103
|
+
skills directory; a project-scope install copies nothing. Nothing wires that copy up —
|
|
104
|
+
every hook entry the installer writes is a `peaks …` command, and no settings template
|
|
105
|
+
invokes a `.sh`, so it lies inert until a harness is pointed at it by hand. If one is: it
|
|
106
|
+
takes no driver input at all and denies the hard-blocked families unconditionally, refused
|
|
107
|
+
even in this lane, and its refusal will not mention this file. That asymmetry is known and
|
|
108
|
+
left conservative on purpose — assigning it is not this skill's job, and teaching the shell
|
|
109
|
+
gate about lanes is not yours.
|
|
110
|
+
|
|
111
|
+
## Completion proofs — four, and they are actions, not a document
|
|
112
|
+
|
|
113
|
+
Show the command and its real output. "It should pass" is not a proof, and this lane has no
|
|
114
|
+
gate machinery behind you to catch it.
|
|
115
|
+
|
|
116
|
+
1. & 2. **The shared acceptance gate** — whatever §1 of
|
|
117
|
+
`../peaks-code/references/fast-lane-norm.md` says it is, no more and no less. It is stated
|
|
118
|
+
once, for both fast lanes, there. Go and run it there; do not re-derive it from this file,
|
|
119
|
+
and do not restate it in the trace as if this file said it.
|
|
120
|
+
3. **An honest commit.** The message says what changed and why. **No part of the commit path
|
|
121
|
+
intercepts an AI-attribution trailer before the commit exists.** A pre-commit hook does run
|
|
122
|
+
— it lints the staged files and ratchets the gate — but it reads files and never the
|
|
123
|
+
message, and there is no commit-msg hook in `.husky/` (its absence is a recorded decision,
|
|
124
|
+
not an oversight). The only mechanical support is
|
|
125
|
+
`tests/unit/standards/no-ai-co-author-trailer.test.ts`, which reads `git log` and fails;
|
|
126
|
+
its remedy is rewriting history, so it cannot un-land a trailer. Never add the trailer, and
|
|
127
|
+
never tell the user one was blocked.
|
|
128
|
+
4. **A retractable unit.** Land the change on one commit (or one branch) and be able to say
|
|
129
|
+
the exact command that undoes it. This lane is the only one allowed to edit source
|
|
130
|
+
directly and it skips the transition checks, so "it can be undone" is the only backstop
|
|
131
|
+
left. Say the command out loud rather than assuming it.
|
|
132
|
+
|
|
133
|
+
## Risk surfaces — where this lane stops
|
|
134
|
+
|
|
135
|
+
The list of changes that do not belong in a fast lane lives in
|
|
136
|
+
`../peaks-code/references/fast-lane-norm.md` §2. That file is the single source: read it
|
|
137
|
+
before you start, and again once a diff exists. It is not restated here, and a second copy
|
|
138
|
+
here would be exactly the drift the norm exists to prevent.
|
|
139
|
+
|
|
140
|
+
Two things that section says about itself, and that you must not paper over on its behalf: it
|
|
141
|
+
is a judgement list rather than a gate, and its size row has no threshold behind it yet, so a
|
|
142
|
+
size is not a decision you can make from it. What happens when a row is hit is the next
|
|
143
|
+
section.
|
|
144
|
+
|
|
145
|
+
## Escalation — one way for you, never for the user
|
|
146
|
+
|
|
147
|
+
- **If you find mid-task that the change crosses a risk row: stop, say so, and hand the task
|
|
148
|
+
to `peaks-code`.** Do not press on because you are nearly done. That is the one thing this
|
|
149
|
+
lane may not do — peaks-code does not get to downgrade a task either, and neither do you.
|
|
150
|
+
- **The user may push it back.** Say the risk in one sentence, do not block, and write the
|
|
151
|
+
override and the row it overrode into the trace. Silently allowing it is not an option
|
|
152
|
+
either.
|
|
153
|
+
- **Per task, not per session.** The one-way rule binds the task that hit the wall. The next
|
|
154
|
+
task may take this lane again; one misjudgement must not lock the user out of the fast lane.
|
|
155
|
+
- **Hand over, do not walk away.** Before you escalate, record whether the tree is clean,
|
|
156
|
+
whether the half-done work is committed, whether it passes the acceptance gate, which files
|
|
157
|
+
you touched and why you stopped. Ownership moves when that record lands — an unexplained
|
|
158
|
+
dirty tree is the one state `peaks-code` cannot start from.
|
|
159
|
+
- Hold all of this in the trace and in the user's presence in the window. The
|
|
160
|
+
machine-checkable half of the risk list does not exist, so nothing else is holding it.
|
|
161
|
+
|
|
162
|
+
## Traces
|
|
163
|
+
|
|
164
|
+
- Create the session workspace once — `peaks workspace init --project .`. It is the
|
|
165
|
+
precondition of `presence:set`, which refuses when no session is bound. One CLI call, not a
|
|
166
|
+
step.
|
|
167
|
+
- Write one short record at `.peaks/_runtime/<sessionId>/race/<rid>.md`: the need in one
|
|
168
|
+
sentence; the lane and who chose it; the files you changed; the four proofs with their
|
|
169
|
+
actual results and the commands that produced them; and any risk row you hit, with the
|
|
170
|
+
user's override if there was one.
|
|
171
|
+
- **Memory is for boundaries and new pitfalls only.** Sediment into `.peaks/memory/` when the
|
|
172
|
+
change drew a risk boundary or tripped something new; everyday small changes stay in the
|
|
173
|
+
runtime record. Sediment everything and memory stops being worth reading.
|
|
174
|
+
|
|
175
|
+
## What this lane does not write
|
|
176
|
+
|
|
177
|
+
No sub-agent dispatches. No Gate A–G file chain. No `peaks request transition` state machine.
|
|
178
|
+
No planning or review documents — no tech doc, bug analysis, review envelope, audit envelope,
|
|
179
|
+
QA report or verdict. No job shape, no slice DAG, no swarm fan-out, no PRD phase, no
|
|
180
|
+
orchestrator-to-implementer handoff.
|
|
181
|
+
|
|
182
|
+
Keep the parts that cost no wall-clock, because they are habits rather than ceremony: read a
|
|
183
|
+
file before editing it, the TDD micro-cycle, the four Karpathy guidelines, one codegraph
|
|
184
|
+
query for the affected surface, one sentence before you start on what you will change and
|
|
185
|
+
why, and nothing dropped in the project root.
|
|
@@ -3,7 +3,7 @@ name: peaks-resume
|
|
|
3
3
|
description: Universal resume primitive for any in-flight Peaks-Loop workflow (orchestrator-agnostic). Detects the current session's deepest completed gate and surfaces a resume option via AskUserQuestion. Use when ANY bee (peaks-code, future peaks-research, future peaks-content, …) needs to recover from /compact or session interruption. Triggers on "/peaks-resume", "continue the unfinished work", "继续完成", "把刚才没做完的收尾". (Replaces peaks-resume as a top-level primitive.)
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all
|
|
6
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
7
7
|
|
|
8
8
|
## Loop hygiene (every turn — MANDATORY)
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@ name: peaks-slice-decompose
|
|
|
3
3
|
description: Run multi-pass slice decomposition on a PRD-ready request and emit a v2 envelope with passes, cross-pass edges, and an LLM-arbitration trace. Use when a PRD is ready and the caller needs service-level and/or file-level cuts in one artifact.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all
|
|
6
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
7
7
|
|
|
8
8
|
## Loop hygiene (every turn — MANDATORY)
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ metadata:
|
|
|
14
14
|
red_lines: [RL-1, RL-8, HC-7, HC-8, HC-9, HC-10, HC-11]
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all
|
|
17
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
18
18
|
|
|
19
19
|
## Loop hygiene (every turn — MANDATORY)
|
|
20
20
|
|
|
@@ -3,7 +3,7 @@ name: peaks-sop
|
|
|
3
3
|
description: 'Authoring skill for user-defined SOPs (standard operating procedures) in Peaks. Use when a user wants to create, edit, debug, or register their own gated workflow — ordered phases plus gates that block advancement until conditions are met — by describing it in natural language instead of hand-writing JSON or memorizing CLI commands. DOMAIN-AGNOSTIC: not just software/release flows — equally for content publishing, compliance and approval checklists, data pipelines, onboarding, ops runbooks, or any personal repeatable procedure, wherever "don''t enter the next stage until X is true" applies and X is checkable via a file, file content, or a command.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all
|
|
6
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
7
7
|
|
|
8
8
|
## Loop hygiene (every turn — MANDATORY)
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@ name: peaks-status
|
|
|
3
3
|
description: Universal status primitive for any in-flight Peaks-Loop workflow (orchestrator-agnostic). Reads the existing CLI primitives (peaks skill presence, peaks session list, peaks project dashboard, peaks request show) and renders a 1-screen status table. Use when the user asks "where are we", "现在到哪了", "what's the current state" for ANY bee (peaks-code, future peaks-research, …). Triggers on "/peaks-status", "现在到哪了", "what is the current state", "show me the dashboard". (Replaces peaks-status as a top-level primitive.)
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all
|
|
6
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
7
7
|
|
|
8
8
|
## Loop hygiene (every turn — MANDATORY)
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@ name: peaks-test
|
|
|
3
3
|
description: Universal test-runner primitive for any in-flight Peaks-Loop workflow (orchestrator-agnostic). Runs the project's test suite on the current repo and reports results. Use when the user asks "run the tests", "跑一下 test", "跑测试" for ANY bee (peaks-code, future peaks-research, …). Triggers on "/peaks-test", "跑一下 test", "跑测试", "run the tests", "test now". (Replaces peaks-test as a top-level primitive.)
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all
|
|
6
|
+
<!-- peaks:loop-hygiene — HAND-MAINTAINED block, NOT generated; byte-identical in every SKILL.md, enforced by tests/unit/skills/loop-hygiene-block.test.ts. Edit one, edit all 23. -->
|
|
7
7
|
|
|
8
8
|
## Loop hygiene (every turn — MANDATORY)
|
|
9
9
|
|
|
@@ -64,11 +64,14 @@ For non-vitest projects (jest, mocha, pytest, etc.), the wrapper respects the pr
|
|
|
64
64
|
## Step 2: Run the test suite
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
# Run with a reasonable timeout (5 min default; override for slow suites)
|
|
68
|
-
|
|
67
|
+
# Run with a reasonable timeout (5 min default; override for slow suites),
|
|
68
|
+
# redirect to a file, and read the RUNNER's exit code.
|
|
69
|
+
timeout 300 pnpm vitest run > suite.log 2>&1; echo "EXIT=$?"
|
|
69
70
|
```
|
|
70
71
|
|
|
71
|
-
Capture both stdout and stderr.
|
|
72
|
+
Capture both stdout and stderr — `suite.log` holds them. `EXIT=0` means the runner exited 0, i.e. tests passed; anything non-zero means they failed or the command errored out. Read `suite.log` in a separate command.
|
|
73
|
+
|
|
74
|
+
**Do NOT pipe the run into a filter or pager** (`pnpm vitest run | tail -100`). After a pipeline `$?` is the LAST command's status, so the number you read is `tail`'s, not the suite's — and a `tail`-terminated command reads 0 whether the suite passed or not. Wrapping the runner does not help either: `timeout 300 pnpm vitest run 2>&1 | tail -100` still reports `tail`'s status. Note that the Peaks-Loop `PreToolUse` hook refuses the unwrapped piped form outright; the wrapped form it cannot see, which is why the redirect above is the form this skill prescribes rather than relying on the hook.
|
|
72
75
|
|
|
73
76
|
## Step 3: Summarize the result
|
|
74
77
|
|
|
@@ -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;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// src/cli/commands/vm-hypervisor-runtime.ts
|
|
2
|
-
//
|
|
3
|
-
// The two hypervisor dispatch helpers `peaks vm spawn` / `peaks vm release`
|
|
4
|
-
// call: create a domain and destroy one. Split out of `vm-commands.ts`; every
|
|
5
|
-
// command line, cwd, stdio tuple and `windowsHide` flag is unchanged.
|
|
6
|
-
import { execSync } from 'node:child_process';
|
|
7
|
-
import { writeFileSync } from 'node:fs';
|
|
8
|
-
export function spawnVmWithHypervisor(args) {
|
|
9
|
-
if (args.hypervisor === 'kvm') {
|
|
10
|
-
// virsh create expects a domain XML file. We emit a minimal
|
|
11
|
-
// XML with the image, mount, and our peaks labels.
|
|
12
|
-
const xml = `<?xml version="1.0"?>
|
|
13
|
-
<domain type="kvm">
|
|
14
|
-
<name>peaks-${args.leaseId}</name>
|
|
15
|
-
<metadata><peaks:label xmlns:peaks="urn:peaks">peaks.leaseId=${args.leaseId};peaks.rid=${args.rid}</peaks:label></metadata>
|
|
16
|
-
<memory>1048576</memory>
|
|
17
|
-
<vcpu>1</vcpu>
|
|
18
|
-
<os><type arch="x86_64">hvm</type></os>
|
|
19
|
-
<devices>
|
|
20
|
-
<disk type="file"><source file="${args.image}"/><target dev="vda"/></disk>
|
|
21
|
-
<filesystem type="mount"><source dir="${args.mount}"/><target dir="/work"/></filesystem>
|
|
22
|
-
</devices>
|
|
23
|
-
</domain>`;
|
|
24
|
-
const xmlPath = `${args.workdir}/.peaks-vm-${args.leaseId}.xml`;
|
|
25
|
-
writeFileSync(xmlPath, xml, 'utf8');
|
|
26
|
-
const out = execSync(`virsh create ${xmlPath}`, {
|
|
27
|
-
cwd: args.workdir,
|
|
28
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
29
|
-
encoding: 'utf8',
|
|
30
|
-
windowsHide: true
|
|
31
|
-
});
|
|
32
|
-
return { vmId: out.trim() };
|
|
33
|
-
}
|
|
34
|
-
if (args.hypervisor === 'hyperkit') {
|
|
35
|
-
const out = execSync(`hvftool create --image ${args.image} --mount ${args.mount}:/work --label peaks.leaseId=${args.leaseId} --label peaks.rid=${args.rid} --entrypoint sleep -- infinity`, { cwd: args.workdir, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', windowsHide: true });
|
|
36
|
-
return { vmId: out.trim() };
|
|
37
|
-
}
|
|
38
|
-
// hyperv: the hvc shim writes a vhdx + emits the new VM id.
|
|
39
|
-
const out = execSync(`hvc create --image ${args.image} --mount ${args.mount} --label peaks.leaseId=${args.leaseId} --label peaks.rid=${args.rid}`, { cwd: args.workdir, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', windowsHide: true });
|
|
40
|
-
return { vmId: out.trim() };
|
|
41
|
-
}
|
|
42
|
-
export function destroyVmWithHypervisor(args) {
|
|
43
|
-
try {
|
|
44
|
-
if (args.hypervisor === 'kvm') {
|
|
45
|
-
execSync(`virsh destroy ${args.vmId}`, {
|
|
46
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
47
|
-
windowsHide: true
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
else if (args.hypervisor === 'hyperkit') {
|
|
51
|
-
execSync(`hvftool stop ${args.vmId}`, {
|
|
52
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
53
|
-
windowsHide: true
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
execSync(`hvc stop ${args.vmId}`, { stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
import { type ProgramIO } from '../cli-helpers.js';
|
|
3
|
-
import { type ReleaseOptions } from './vm-command-shared.js';
|
|
4
|
-
export declare function runVmRelease(io: ProgramIO, options: ReleaseOptions): void;
|
|
5
|
-
export declare function registerVmReleaseCommand(cmd: Command, io: ProgramIO): void;
|