peaks-loop 4.1.17 → 4.1.19
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 +269 -0
- package/README-en.md +6 -0
- package/README.md +5 -0
- package/contracts/test-style-contract.md +14 -5
- package/dist/cli/commands/audit-red-lines-runners.js +6 -1
- package/dist/cli/commands/best-practice-scan-collision.d.ts +42 -0
- package/dist/cli/commands/best-practice-scan-collision.js +115 -0
- package/dist/cli/commands/best-practice-scan-command.d.ts +5 -0
- package/dist/cli/commands/best-practice-scan-command.js +9 -18
- package/dist/cli/commands/best-practice-scan-helpers.d.ts +12 -6
- package/dist/cli/commands/best-practice-scan-helpers.js +37 -17
- package/dist/cli/commands/code-auto-compact-command.js +71 -40
- package/dist/cli/commands/code-auto-compact-deferral.d.ts +34 -0
- package/dist/cli/commands/code-auto-compact-deferral.js +59 -0
- package/dist/cli/commands/code-gate-command.d.ts +4 -4
- package/dist/cli/commands/code-gate-command.js +4 -4
- package/dist/cli/commands/core/skill-generated-config-notice.d.ts +5 -0
- package/dist/cli/commands/core/skill-generated-config-notice.js +42 -8
- package/dist/cli/commands/core/skill-presence-commands.js +42 -74
- package/dist/cli/commands/core/skill-presence-set-command.d.ts +11 -0
- package/dist/cli/commands/core/skill-presence-set-command.js +175 -0
- package/dist/cli/commands/core/skill-registry-commands.js +32 -0
- package/dist/cli/commands/core/skill-store-report.d.ts +8 -0
- package/dist/cli/commands/core/skill-store-report.js +79 -0
- package/dist/cli/commands/core/standards-init-command.js +44 -8
- package/dist/cli/commands/core/standards-migrate-command.js +5 -4
- package/dist/cli/commands/dispatch-dag-runners.d.ts +1 -0
- package/dist/cli/commands/dispatch-dag-runners.js +11 -1
- package/dist/cli/commands/dispatch-detached-branch.js +19 -1
- package/dist/cli/commands/dispatch-prompt-composition.js +7 -2
- package/dist/cli/commands/dispatch-scratch-path-block.d.ts +73 -0
- package/dist/cli/commands/dispatch-scratch-path-block.js +131 -0
- package/dist/cli/commands/hooks-commands.js +36 -7
- package/dist/cli/commands/hooks-uninstall-command.js +5 -5
- package/dist/cli/commands/mut-commands-helpers.d.ts +72 -5
- package/dist/cli/commands/mut-commands-helpers.js +197 -4
- package/dist/cli/commands/mut-commands.d.ts +9 -1
- package/dist/cli/commands/mut-commands.js +82 -154
- package/dist/cli/commands/preferences-commands.js +27 -2
- package/dist/cli/commands/scan-scope-helpers.js +2 -2
- package/dist/services/24h-mode/auto-engage.d.ts +11 -3
- package/dist/services/24h-mode/auto-engage.js +14 -6
- package/dist/services/artifacts/artifact-templates.js +10 -0
- package/dist/services/artifacts/backcompat-acceptance.d.ts +8 -1
- package/dist/services/artifacts/backcompat-acceptance.js +8 -7
- package/dist/services/artifacts/rd-transition-gates.d.ts +32 -5
- package/dist/services/artifacts/rd-transition-gates.js +96 -19
- package/dist/services/artifacts/request-artifact-service.js +6 -6
- package/dist/services/audit/enforcers/lint-output-style.js +14 -2
- package/dist/services/audit/enforcers/root-scratch-artifacts.d.ts +46 -0
- package/dist/services/audit/enforcers/root-scratch-artifacts.js +97 -0
- package/dist/services/audit/static-service.js +4 -4
- package/dist/services/code/auto-compact-history.d.ts +6 -1
- package/dist/services/code/auto-compact-history.js +6 -1
- package/dist/services/code/auto-compact-modes.d.ts +60 -14
- package/dist/services/code/auto-compact-modes.js +75 -20
- package/dist/services/code/auto-compact-orchestrator.js +7 -5
- package/dist/services/code/auto-compact-profile.d.ts +23 -0
- package/dist/services/code/auto-compact-profile.js +51 -0
- package/dist/services/code/auto-compact-run-types.d.ts +8 -4
- package/dist/services/compact-history/compact-history-service.d.ts +6 -1
- package/dist/services/compact-history/compact-history-service.js +5 -1
- package/dist/services/context/auto-compact-types.d.ts +7 -5
- package/dist/services/dispatch/dispatch-ledger-reader.d.ts +13 -0
- package/dist/services/dispatch/dispatch-ledger-reader.js +164 -0
- package/dist/services/doctor/doctor-service/checks/canonical-store-version.d.ts +57 -0
- package/dist/services/doctor/doctor-service/checks/canonical-store-version.js +190 -0
- package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.d.ts +37 -0
- package/dist/services/doctor/doctor-service/checks/l3-runtime-root-census.js +100 -0
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.d.ts +11 -3
- package/dist/services/doctor/doctor-service/checks/skill-reference-parity.js +48 -29
- 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/hooks/hook-payload-cwd.d.ts +11 -4
- package/dist/services/hooks/hook-payload-cwd.js +11 -4
- package/dist/services/hooks/pre-tool-code-gate.d.ts +4 -4
- package/dist/services/hooks/pre-tool-code-gate.js +4 -4
- package/dist/services/hooks/presence-marker-detector.d.ts +3 -0
- package/dist/services/hooks/presence-marker-detector.js +21 -19
- package/dist/services/ide/adapters/claude-code-adapter.js +6 -8
- package/dist/services/ide/adapters/codex-adapter.js +23 -7
- package/dist/services/ide/adapters/cursor-adapter.js +23 -7
- package/dist/services/mode/mode-status-service.d.ts +26 -27
- package/dist/services/mode/mode-status-service.js +36 -60
- package/dist/services/preferences/preferences-types.d.ts +30 -0
- package/dist/services/preferences/preferences-types.js +13 -0
- package/dist/services/scan/acceptance-coverage-service.d.ts +14 -11
- package/dist/services/scan/acceptance-coverage-service.js +157 -52
- package/dist/services/scan/rid-change-claims.d.ts +15 -0
- package/dist/services/scan/rid-change-claims.js +116 -0
- package/dist/services/session/getSessionDir.d.ts +13 -0
- package/dist/services/session/getSessionDir.js +7 -1
- package/dist/services/skills/hooks-settings-types.d.ts +17 -21
- package/dist/services/skills/presence-caller-id.d.ts +51 -0
- package/dist/services/skills/presence-caller-id.js +43 -0
- package/dist/services/skills/presence-gate.d.ts +65 -0
- package/dist/services/skills/presence-gate.js +113 -0
- package/dist/services/skills/presence-lease-resolver.d.ts +63 -0
- package/dist/services/skills/presence-lease-resolver.js +114 -0
- package/dist/services/skills/presence-lease-selection.d.ts +91 -0
- package/dist/services/skills/presence-lease-selection.js +135 -0
- package/dist/services/skills/presence-lease-service.d.ts +3 -11
- package/dist/services/skills/presence-lease-service.js +34 -87
- package/dist/services/skills/presence-lease-store.d.ts +33 -0
- package/dist/services/skills/presence-lease-store.js +94 -0
- package/dist/services/skills/presence-lease-types.d.ts +31 -0
- package/dist/services/skills/presence-lease-types.js +27 -0
- package/dist/services/skills/presence-role.d.ts +35 -0
- package/dist/services/skills/presence-role.js +72 -0
- package/dist/services/skills/skill-presence-service.d.ts +39 -9
- package/dist/services/skills/skill-presence-service.js +143 -174
- package/dist/services/skills/skill-presence-write.d.ts +60 -0
- package/dist/services/skills/skill-presence-write.js +74 -0
- package/dist/services/skills/skill-statusline-service.js +7 -7
- package/dist/services/skills/sync-service-support.d.ts +27 -0
- package/dist/services/skills/sync-service.js +1 -0
- package/dist/services/standards/ide-aware-standards-service.d.ts +35 -23
- package/dist/services/standards/ide-aware-standards-service.js +45 -20
- package/dist/services/standards/migrate-claude-rules-service.d.ts +6 -0
- package/dist/services/standards/migrate-claude-rules-service.js +18 -0
- package/dist/services/standards/migrate-service.d.ts +1 -1
- package/dist/services/standards/migrate-service.js +27 -7
- package/dist/services/standards/project-scripts.d.ts +25 -0
- package/dist/services/standards/project-scripts.js +116 -0
- package/dist/services/standards/project-standards-service.d.ts +23 -15
- package/dist/services/standards/project-standards-service.js +176 -243
- package/dist/services/standards/standards-constitution.d.ts +89 -0
- package/dist/services/standards/standards-constitution.js +199 -0
- package/dist/services/standards/standards-files.d.ts +37 -0
- package/dist/services/standards/standards-files.js +138 -0
- package/dist/services/standards/standards-pointer.d.ts +73 -0
- package/dist/services/standards/standards-pointer.js +98 -0
- package/dist/services/standards/standards-render-agents.d.ts +34 -0
- package/dist/services/standards/standards-render-agents.js +149 -0
- package/dist/services/standards/standards-render-common.d.ts +38 -1
- package/dist/services/standards/standards-render-common.js +44 -7
- package/dist/services/standards/standards-render.d.ts +1 -3
- package/dist/services/standards/standards-render.js +6 -87
- package/dist/services/workflow/workflow-graph-ensure.d.ts +77 -0
- package/dist/services/workflow/workflow-graph-ensure.js +97 -0
- package/dist/services/workflow/workflow-inflight-probe.d.ts +68 -31
- package/dist/services/workflow/workflow-inflight-probe.js +163 -75
- package/dist/services/workflow/workflow-presence-lifecycle.js +21 -6
- package/dist/services/workspace/generated-artifacts-content.d.ts +46 -0
- package/dist/services/workspace/generated-artifacts-content.js +167 -0
- package/dist/services/workspace/generated-artifacts-stamp.d.ts +36 -13
- package/dist/services/workspace/generated-artifacts-stamp.js +37 -15
- package/dist/services/workspace/runtime-layout.d.ts +64 -0
- package/dist/services/workspace/runtime-layout.js +62 -0
- package/output-styles/peaks-skill-swarm.md +18 -2
- package/package.json +10 -9
- package/schemas/doctor-report.schema.json +1 -1
- package/scripts/canonical-store-fs.mjs +112 -0
- package/scripts/canonical-store-link.mjs +13 -22
- package/scripts/canonical-store-marker.mjs +241 -0
- package/scripts/canonical-store.mjs +119 -141
- package/scripts/install-skills-bundles.mjs +56 -13
- package/scripts/install-skills-fs.mjs +73 -0
- package/scripts/install-skills-output-styles.mjs +8 -2
- package/scripts/install-skills-report.mjs +19 -0
- package/scripts/install-skills.mjs +9 -0
- package/skills/bee/peaks-perf-audit/SKILL.md +3 -1
- package/skills/bee/peaks-prd/SKILL.md +5 -3
- package/skills/bee/peaks-qa/SKILL.md +4 -2
- package/skills/bee/peaks-qa/references/qa-skill-presence.md +1 -1
- package/skills/bee/peaks-qa/references/qa-standards-preflight.md +3 -1
- package/skills/bee/peaks-qa/references/qa-sub-agent-dispatch.md +2 -2
- package/skills/bee/peaks-rd/SKILL.md +4 -2
- package/skills/bee/peaks-rd/references/artifact-and-standards-output.md +1 -1
- package/skills/bee/peaks-rd/references/rd-runbook.md +11 -2
- package/skills/bee/peaks-rd/references/rd-standards-preflight.md +3 -1
- package/skills/bee/peaks-rd/references/rd-sub-agent-dispatch.md +24 -5
- package/skills/bee/peaks-rd/references/rd-transition-gates.md +49 -5
- package/skills/bee/peaks-rd/references/skill-presence-and-title.md +1 -1
- package/skills/bee/peaks-reviewer/SKILL.md +3 -1
- package/skills/bee/peaks-sc/SKILL.md +4 -2
- package/skills/bee/peaks-security-audit/SKILL.md +3 -1
- package/skills/bee/peaks-txt/SKILL.md +5 -3
- package/skills/bee/peaks-ui/SKILL.md +6 -4
- package/skills/peaks-audit/SKILL.md +3 -1
- package/skills/peaks-code/SKILL.md +4 -2
- package/skills/peaks-code/references/a2a-artifact-mapping.md +3 -3
- package/skills/peaks-code/references/completion-handoff.md +1 -1
- package/skills/peaks-code/references/local-artifact-workspace.md +10 -11
- package/skills/peaks-code/references/micro-cycle.md +2 -2
- package/skills/peaks-code/references/mode-selection-with-stale-presence.md +3 -3
- package/skills/peaks-code/references/runbook.md +4 -4
- package/skills/peaks-code/references/skill-presence-and-title.md +4 -2
- package/skills/peaks-code/references/standards-preflight.md +7 -6
- package/skills/peaks-code/references/sub-agent-dispatch.md +1 -1
- package/skills/peaks-code/references/swarm-dispatch-contract.md +5 -5
- package/skills/peaks-code/references/workflow-gates-and-types.md +37 -11
- package/skills/peaks-content/SKILL.md +3 -1
- package/skills/peaks-doctor/SKILL.md +3 -1
- package/skills/peaks-final-review/SKILL.md +3 -1
- package/skills/peaks-ide/SKILL.md +3 -1
- package/skills/peaks-issue-fix-orchestrator/SKILL.md +5 -3
- package/skills/peaks-race-code/SKILL.md +9 -4
- package/skills/peaks-resume/SKILL.md +3 -1
- package/skills/peaks-slice-decompose/SKILL.md +3 -1
- package/skills/peaks-solo/SKILL.md +3 -1
- package/skills/peaks-sop/SKILL.md +4 -2
- package/skills/peaks-status/SKILL.md +3 -1
- package/skills/peaks-test/SKILL.md +3 -1
|
@@ -1,36 +1,84 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* The PUBLIC auto-compact profiles.
|
|
2
3
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Two profiles, and BOTH are public: any project, in any mode, can pick
|
|
5
|
+
* either one. Nothing here belongs to the 24h long-run mode any more — a
|
|
6
|
+
* profile is a THRESHOLD choice, not a mode.
|
|
7
|
+
*
|
|
8
|
+
* `'standard'` keeps the v2.13.0 zero-pause contract thresholds
|
|
9
|
+
* (autoFire=0.80, preCompact=0.85, redLine=0.95).
|
|
10
|
+
*
|
|
11
|
+
* `'eager'` fires EARLIER (autoFire=0.65, preCompact=0.70, redLine=0.85).
|
|
12
|
+
*
|
|
13
|
+
* WHY THE NAME CHANGED. The profile used to be called `'partial'`, and that
|
|
14
|
+
* name promised a behaviour this product does not have: there is NO
|
|
15
|
+
* partial-compaction pathway — the profile only moves the THRESHOLDS at
|
|
16
|
+
* which the orchestrator fires. A public name that promises behaviour the
|
|
17
|
+
* product does not implement is a lie in the CLI surface, so the profile is
|
|
18
|
+
* named after what it actually does: it fires earlier. `'partial'` stays
|
|
19
|
+
* ACCEPTED as a compatibility alias — `--mode partial` is a published CLI
|
|
20
|
+
* surface, and dropping it would break existing callers harder than a
|
|
21
|
+
* no-op — and `normalizeAutoCompactMode` is the ONE place that maps it onto
|
|
22
|
+
* `'eager'`.
|
|
7
23
|
*
|
|
8
24
|
* `autoFire` tier is added between soft-warn and preCompact. peaks-loop
|
|
9
25
|
* preempts and runs `peaks code auto-compact` itself when
|
|
10
26
|
* context crosses `autoFire`; the LLM is NOT asked to "decide"
|
|
11
27
|
* (the LLM-judged 0.85–0.95 zone was the source of false-positive
|
|
12
28
|
* "context too low" reports at 60%+ free — the LLM was guessing).
|
|
13
|
-
*
|
|
14
|
-
* The mode only changes the THRESHOLDS at which the orchestrator fires.
|
|
15
|
-
* The actual partial-compaction behaviour (dropping low-priority context
|
|
16
|
-
* layers) is a follow-up slice; for now `partial` mode is logged +
|
|
17
|
-
* decision-emitted, no separate compaction pathway.
|
|
18
29
|
*/
|
|
19
|
-
|
|
30
|
+
/** The canonical profile names, in the order the CLI lists them. */
|
|
31
|
+
export const AUTO_COMPACT_PROFILES = ['standard', 'eager'];
|
|
32
|
+
/**
|
|
33
|
+
* The ONE alias table: a legacy mode name → the canonical profile it means.
|
|
34
|
+
* `normalizeAutoCompactMode` is its only reader, so the mapping cannot be
|
|
35
|
+
* restated — and therefore cannot drift — anywhere else.
|
|
36
|
+
*/
|
|
37
|
+
const LEGACY_MODE_ALIASES = { partial: 'eager' };
|
|
38
|
+
const EAGER_THRESHOLDS = { autoFire: 0.65, preCompact: 0.7, redLine: 0.85 };
|
|
39
|
+
const PROFILE_THRESHOLDS = {
|
|
20
40
|
standard: { autoFire: 0.8, preCompact: 0.85, redLine: 0.95 },
|
|
21
|
-
|
|
41
|
+
eager: EAGER_THRESHOLDS
|
|
22
42
|
};
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The threshold table. `partial` is the legacy alias and points at the SAME
|
|
45
|
+
* row as `eager` — the numbers are written once, so the alias cannot drift
|
|
46
|
+
* away from the profile it names.
|
|
47
|
+
*/
|
|
48
|
+
export const AUTO_COMPACT_THRESHOLDS = {
|
|
49
|
+
...PROFILE_THRESHOLDS,
|
|
50
|
+
partial: EAGER_THRESHOLDS
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Normalize a mode name to its canonical profile, or `null` when the name is
|
|
54
|
+
* not a mode this build knows.
|
|
55
|
+
*
|
|
56
|
+
* This is the single entry point for the alias mapping: `'partial'` in,
|
|
57
|
+
* `'eager'` out, and every caller that needs the canonical name goes
|
|
58
|
+
* through here.
|
|
59
|
+
*/
|
|
60
|
+
export function normalizeAutoCompactMode(value) {
|
|
61
|
+
if (value === 'standard' || value === 'eager')
|
|
62
|
+
return value;
|
|
63
|
+
const alias = LEGACY_MODE_ALIASES[value];
|
|
64
|
+
return alias ?? null;
|
|
25
65
|
}
|
|
66
|
+
/** True when `value` names a mode this build accepts (a canonical name or the legacy alias). */
|
|
26
67
|
export function isValidMode(value) {
|
|
27
|
-
return value
|
|
68
|
+
return normalizeAutoCompactMode(value) !== null;
|
|
69
|
+
}
|
|
70
|
+
/** The threshold a mode fires at. */
|
|
71
|
+
export function thresholdFor(mode, kind) {
|
|
72
|
+
// `mode` is typed, so the canonical name is always resolvable; the
|
|
73
|
+
// fallback keeps the function total for an untyped caller.
|
|
74
|
+
const canonical = normalizeAutoCompactMode(mode) ?? 'standard';
|
|
75
|
+
return AUTO_COMPACT_THRESHOLDS[canonical][kind];
|
|
28
76
|
}
|
|
29
77
|
function pct(ratio) {
|
|
30
78
|
return `${(ratio * 100).toFixed(0)}%`;
|
|
31
79
|
}
|
|
32
80
|
/**
|
|
33
|
-
* Human-readable form of a
|
|
81
|
+
* Human-readable form of a profile's threshold row.
|
|
34
82
|
*
|
|
35
83
|
* Derived from `AUTO_COMPACT_THRESHOLDS` rather than hand-written. Diagnosis
|
|
36
84
|
* 2026-09-15 (C1) found this string advertising `0.85/0.95` for `standard`
|
|
@@ -40,12 +88,19 @@ function pct(ratio) {
|
|
|
40
88
|
* numbers out of the table makes that drift unrepresentable.
|
|
41
89
|
*/
|
|
42
90
|
export function describeMode(mode) {
|
|
43
|
-
const
|
|
91
|
+
const canonical = normalizeAutoCompactMode(mode) ?? 'standard';
|
|
92
|
+
const { autoFire, preCompact, redLine } = AUTO_COMPACT_THRESHOLDS[canonical];
|
|
44
93
|
const bands = `auto-fire ${pct(autoFire)} / pre-compact ${pct(preCompact)} / red-line ${pct(redLine)}`;
|
|
45
|
-
return
|
|
94
|
+
return canonical === 'standard'
|
|
46
95
|
? `standard (${bands} — v2.13.0 zero-pause contract)`
|
|
47
|
-
: `
|
|
96
|
+
: `eager (${bands} — fires earlier than standard)`;
|
|
48
97
|
}
|
|
49
|
-
|
|
50
|
-
|
|
98
|
+
/** True when the context percentage has reached the `eager` profile's pre-compact line. */
|
|
99
|
+
export function isEagerModeEligible(contextPercent) {
|
|
100
|
+
return contextPercent >= EAGER_THRESHOLDS.preCompact;
|
|
51
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated The profile was renamed; `eager` is the canonical name. Kept
|
|
104
|
+
* so an existing caller keeps working — it now means the same thing.
|
|
105
|
+
*/
|
|
106
|
+
export const isPartialModeEligible = isEagerModeEligible;
|
|
@@ -173,12 +173,14 @@ async function openRun(input, sessionId, mode) {
|
|
|
173
173
|
});
|
|
174
174
|
const decision = evaluateAutoCompactDecision({
|
|
175
175
|
ratio: probe.ratio,
|
|
176
|
-
// Production `inFlightBatch` MUST come from the
|
|
177
|
-
// preserved as a TEST-ONLY seam: when `probeInflightBatch` is supplied we
|
|
178
|
-
// pass an `InFlightBatchProbe`, so the pure decision sees a
|
|
179
|
-
// CLI gates the boolean behind `PEAKS_TEST_SEAM === '1'`.
|
|
176
|
+
// Production `inFlightBatch` MUST come from the dispatch-ledger probe. The legacy
|
|
177
|
+
// boolean is preserved as a TEST-ONLY seam: when `probeInflightBatch` is supplied we
|
|
178
|
+
// call it and pass an `InFlightBatchProbe`, so the pure decision sees a
|
|
179
|
+
// ledger-backed value. The CLI gates the boolean behind `PEAKS_TEST_SEAM === '1'`.
|
|
180
|
+
// The session resolved above is the one the probe reads, so the two cannot name
|
|
181
|
+
// different sessions.
|
|
180
182
|
inFlightBatch: input.probeInflightBatch !== undefined
|
|
181
|
-
? { hasInFlightBatch: input.probeInflightBatch() }
|
|
183
|
+
? { hasInFlightBatch: input.probeInflightBatch(sessionId) }
|
|
182
184
|
: input.inFlightBatch,
|
|
183
185
|
force: input.force,
|
|
184
186
|
bypassRedLine: input.bypassRedLine,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AutoCompactProfile } from './auto-compact-modes.js';
|
|
2
|
+
/** Which of the three sources answered the profile question. */
|
|
3
|
+
export type AutoCompactProfileSource = 'cli' | 'preference' | 'default';
|
|
4
|
+
export interface ResolvedAutoCompactProfile {
|
|
5
|
+
readonly profile: AutoCompactProfile;
|
|
6
|
+
/** Where it came from: `'cli'`, `'preference'` or `'default'`. */
|
|
7
|
+
readonly source: AutoCompactProfileSource;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The profile the project pinned, or `null` when it pinned nothing: no key in
|
|
11
|
+
* the file, an unknown value, or the default `'standard'`. A file this build
|
|
12
|
+
* CANNOT READ answers `null` too, leaving the compaction path unbroken.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readAutoCompactProfilePreference(projectRoot: string): AutoCompactProfile | null;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the profile in force for one invocation — THE resolution order lives
|
|
17
|
+
* here, in one place, so it cannot drift between the CLI and the services.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveAutoCompactProfile(input: {
|
|
20
|
+
readonly projectRoot: string;
|
|
21
|
+
/** The normalized `--mode` value, when the caller named one. */
|
|
22
|
+
readonly cliMode?: AutoCompactProfile | null | undefined;
|
|
23
|
+
}): ResolvedAutoCompactProfile;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PUBLIC auto-compact profile resolution.
|
|
3
|
+
*
|
|
4
|
+
* The profile used to be derived from the 24h long-run state machine, which
|
|
5
|
+
* made the compaction cadence a private property of one mode. It is now a
|
|
6
|
+
* public choice, resolved in ONE order:
|
|
7
|
+
*
|
|
8
|
+
* 1. an explicit `--mode` on this invocation (highest; one call, one override)
|
|
9
|
+
* 2. the project setting `autoCompactProfile` (public, persistent, any mode)
|
|
10
|
+
* 3. the default `'standard'`
|
|
11
|
+
*
|
|
12
|
+
* The 24h mode does NOT participate: a project that wants to compact earlier
|
|
13
|
+
* says so with the project setting. Where the profile is STORED or REPORTED it
|
|
14
|
+
* is always the canonical profile name — never the legacy alias.
|
|
15
|
+
*/
|
|
16
|
+
import { loadPreferences } from '../preferences/preferences-service.js';
|
|
17
|
+
import { normalizeAutoCompactMode } from './auto-compact-modes.js';
|
|
18
|
+
/**
|
|
19
|
+
* The profile the project pinned, or `null` when it pinned nothing: no key in
|
|
20
|
+
* the file, an unknown value, or the default `'standard'`. A file this build
|
|
21
|
+
* CANNOT READ answers `null` too, leaving the compaction path unbroken.
|
|
22
|
+
*/
|
|
23
|
+
export function readAutoCompactProfilePreference(projectRoot) {
|
|
24
|
+
const read = readStoredProfile(projectRoot);
|
|
25
|
+
if (!read.ok)
|
|
26
|
+
return null;
|
|
27
|
+
const normalized = typeof read.value === 'string' ? normalizeAutoCompactMode(read.value) : null;
|
|
28
|
+
return normalized === null || normalized === 'standard' ? null : normalized;
|
|
29
|
+
}
|
|
30
|
+
/** Read the stored preference, naming the failure instead of hiding it. */
|
|
31
|
+
function readStoredProfile(projectRoot) {
|
|
32
|
+
try {
|
|
33
|
+
return { ok: true, value: loadPreferences(projectRoot).autoCompactProfile };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { ok: false, reason: 'unreadable' };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the profile in force for one invocation — THE resolution order lives
|
|
41
|
+
* here, in one place, so it cannot drift between the CLI and the services.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveAutoCompactProfile(input) {
|
|
44
|
+
if (input.cliMode !== undefined && input.cliMode !== null) {
|
|
45
|
+
return { profile: input.cliMode, source: 'cli' };
|
|
46
|
+
}
|
|
47
|
+
const preference = readAutoCompactProfilePreference(input.projectRoot);
|
|
48
|
+
if (preference !== null)
|
|
49
|
+
return { profile: preference, source: 'preference' };
|
|
50
|
+
return { profile: 'standard', source: 'default' };
|
|
51
|
+
}
|
|
@@ -24,16 +24,20 @@ export interface AutoCompactInput {
|
|
|
24
24
|
*/
|
|
25
25
|
readonly inFlightBatch?: InFlightBatchProbe | undefined;
|
|
26
26
|
/**
|
|
27
|
-
* Slice 4.0.8 (D4d):
|
|
28
|
-
*
|
|
29
|
-
* result as the production `inFlightBatch` signal. The legacy
|
|
27
|
+
* Slice 4.0.8 (D4d): the in-flight probe. When supplied, the
|
|
28
|
+
* orchestrator calls this function with the session it resolved and uses
|
|
29
|
+
* the boolean result as the production `inFlightBatch` signal. The legacy
|
|
30
30
|
* boolean parameter is suppressed in production callers — the
|
|
31
31
|
* CLI's `--in-flight-batch` flag is gated behind
|
|
32
32
|
* `PEAKS_TEST_SEAM === '1'`. The pure decision function
|
|
33
33
|
* `evaluateAutoCompactDecision` retains the boolean signature
|
|
34
34
|
* for the test seam + the red-line override.
|
|
35
|
+
*
|
|
36
|
+
* The session id is a parameter because the probe reads that session's
|
|
37
|
+
* dispatch ledger: the orchestrator already resolved the session, and a
|
|
38
|
+
* second resolution could name a different one.
|
|
35
39
|
*/
|
|
36
|
-
readonly probeInflightBatch?: (() => boolean) | undefined;
|
|
40
|
+
readonly probeInflightBatch?: ((sessionId: string) => boolean) | undefined;
|
|
37
41
|
/**
|
|
38
42
|
* Force execute even when ratio < threshold (test seam). In
|
|
39
43
|
* production this is always `false` — peaks-loop drives compact
|
|
@@ -2,7 +2,12 @@ export interface CompactHistoryEvent {
|
|
|
2
2
|
readonly schemaVersion: 1;
|
|
3
3
|
readonly ts: string;
|
|
4
4
|
readonly target: 'main' | 'sub-agent' | 'worker';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The profile the run used. `eager` is the canonical name of the
|
|
7
|
+
* earlier-firing profile; `partial` is its legacy alias and is still
|
|
8
|
+
* accepted so an old row keeps parsing; `aggressive` predates both.
|
|
9
|
+
*/
|
|
10
|
+
readonly mode: 'standard' | 'partial' | 'aggressive' | 'eager';
|
|
6
11
|
readonly ide: string;
|
|
7
12
|
readonly pathway: string;
|
|
8
13
|
readonly beforeRatio: number;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// read.
|
|
12
12
|
import { existsSync, readFileSync } from 'node:fs';
|
|
13
13
|
import { join } from 'node:path';
|
|
14
|
+
import { normalizeAutoCompactMode } from '../code/auto-compact-modes.js';
|
|
14
15
|
/**
|
|
15
16
|
* Pair each dispatched compact with the measurement that followed it. Pure;
|
|
16
17
|
* tolerates a file written by an earlier release (no `windowTokens`, no
|
|
@@ -79,7 +80,10 @@ export function readCompactHistory(input) {
|
|
|
79
80
|
parseErrors.push({ line: idx + 1, raw: line });
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
+
// A row written before the rename carries the legacy alias `partial`.
|
|
84
|
+
// It reads back as `eager`, so an old row and a new row describe the
|
|
85
|
+
// SAME profile and can be compared.
|
|
86
|
+
events.push({ ...parsed, mode: normalizeAutoCompactMode(parsed.mode) ?? parsed.mode });
|
|
83
87
|
}
|
|
84
88
|
catch {
|
|
85
89
|
parseErrors.push({ line: idx + 1, raw: line });
|
|
@@ -130,11 +130,13 @@ export type AutoCompactResult = {
|
|
|
130
130
|
*/
|
|
131
131
|
readonly target?: 'main' | 'sub-agent';
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
* (0.70/0.85)
|
|
135
|
-
*
|
|
133
|
+
* The profile the run used. Defaults to `'standard'` (pre-compact
|
|
134
|
+
* 0.85 / red-line 0.95). `'eager'` (0.70/0.85) fires earlier; it is
|
|
135
|
+
* selected by the project setting `autoCompactProfile` or by an
|
|
136
|
+
* explicit `--mode eager`. The legacy alias `'partial'` means
|
|
137
|
+
* `'eager'`.
|
|
136
138
|
*/
|
|
137
|
-
readonly mode?: 'standard' | 'partial';
|
|
139
|
+
readonly mode?: 'standard' | 'partial' | 'eager';
|
|
138
140
|
/**
|
|
139
141
|
* True when the ratio had crossed the red line and peaks-loop asked
|
|
140
142
|
* the harness to compact.
|
|
@@ -193,7 +195,7 @@ export interface ContextPercentProbe {
|
|
|
193
195
|
readonly ratio: number;
|
|
194
196
|
/**
|
|
195
197
|
* Adapter-driven source tag. Fixed values:
|
|
196
|
-
* - `user-overridden` (v2.14.0
|
|
198
|
+
* - `user-overridden` (since v2.14.0: an explicit `--prompt-size
|
|
197
199
|
* <bytes>` from the CLI / hook wrapper —
|
|
198
200
|
* takes priority P0 over EVERY other source.
|
|
199
201
|
* Mac escape hatch.)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LedgerFacts } from '../workflow/workflow-inflight-probe.js';
|
|
2
|
+
export interface DispatchLedgerInput {
|
|
3
|
+
readonly projectRoot: string;
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Read one session's dispatch ledger.
|
|
8
|
+
*
|
|
9
|
+
* `absent` when the session has no ledger at all (no dispatch was ever
|
|
10
|
+
* registered), `unreadable` when the index is there but cannot be parsed, and
|
|
11
|
+
* `readable` with one fact per row otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export declare function readDispatchLedgerFacts(input: DispatchLedgerInput): LedgerFacts;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dispatch-ledger reader: the half of the in-flight probe that touches the
|
|
3
|
+
* filesystem.
|
|
4
|
+
*
|
|
5
|
+
* WHAT IT READS. The session's ledger under `.peaks/_sub_agents/<sid>/`:
|
|
6
|
+
* the `active-dispatches.json` index (which rows are active) and the dispatch
|
|
7
|
+
* record each row names (what those dispatches are doing). The index is the
|
|
8
|
+
* enumeration and the records are the facts, and the two are read separately
|
|
9
|
+
* because only the record carries a lifecycle.
|
|
10
|
+
*
|
|
11
|
+
* WHY THE INDEX ENUMERATES. The index is bounded by the ledger reaper, so a
|
|
12
|
+
* session's index stays small while its records directory grows for the whole
|
|
13
|
+
* retention window. Reading the directory instead would read every record a
|
|
14
|
+
* session ever wrote on every probe.
|
|
15
|
+
*
|
|
16
|
+
* WHAT IT DOES NOT DECIDE. Nothing here says whether a dispatch is in flight.
|
|
17
|
+
* The reader reports facts — a record that is there, a record that is gone, a
|
|
18
|
+
* record that cannot be read — and the pure probe
|
|
19
|
+
* (`../workflow/workflow-inflight-probe.js`) turns them into the answer. That
|
|
20
|
+
* split is what lets the decision be tested without a filesystem.
|
|
21
|
+
*
|
|
22
|
+
* THE DIRECTION OF THE FACTS. A record that cannot be read is reported as
|
|
23
|
+
* unreadable rather than as absent, because "I could not look" and "there is
|
|
24
|
+
* nothing there" are different facts and only one of them may end a deferral.
|
|
25
|
+
*/
|
|
26
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
27
|
+
import { dirname, isAbsolute, resolve } from 'node:path';
|
|
28
|
+
import { activeDispatchIndexPath } from './active-dispatch-index.js';
|
|
29
|
+
import { upgradeRecord } from './dispatch-record-upgrade.js';
|
|
30
|
+
import { assertSafeDispatchRecordPath } from '../security/safe-settings-path.js';
|
|
31
|
+
import { isSinglePathSegment } from '../session/getSessionDir.js';
|
|
32
|
+
/**
|
|
33
|
+
* Read one session's dispatch ledger.
|
|
34
|
+
*
|
|
35
|
+
* `absent` when the session has no ledger at all (no dispatch was ever
|
|
36
|
+
* registered), `unreadable` when the index is there but cannot be parsed, and
|
|
37
|
+
* `readable` with one fact per row otherwise.
|
|
38
|
+
*/
|
|
39
|
+
export function readDispatchLedgerFacts(input) {
|
|
40
|
+
// The session id is the last caller-supplied segment of the ledger's path,
|
|
41
|
+
// so it is checked BEFORE the path is built: an id carrying a separator
|
|
42
|
+
// would point this reader outside the project root. A refused id is an
|
|
43
|
+
// unknown, not an absence, so the answer defers.
|
|
44
|
+
if (!isSinglePathSegment(input.sessionId)) {
|
|
45
|
+
return { ledgerState: 'unreadable', dispatches: [] };
|
|
46
|
+
}
|
|
47
|
+
const indexPath = activeDispatchIndexPath(input.projectRoot, input.sessionId);
|
|
48
|
+
if (!existsSync(indexPath))
|
|
49
|
+
return { ledgerState: 'absent', dispatches: [] };
|
|
50
|
+
const rows = readIndexRows(indexPath);
|
|
51
|
+
if (!rows.ok)
|
|
52
|
+
return { ledgerState: 'unreadable', dispatches: [] };
|
|
53
|
+
const ledgerDir = dirname(indexPath);
|
|
54
|
+
const dispatches = rows.recordPaths.map((recordPath) => readDispatchFact(input.projectRoot, ledgerDir, recordPath));
|
|
55
|
+
return { ledgerState: 'readable', dispatches };
|
|
56
|
+
}
|
|
57
|
+
/** The record paths the index names, or the refusal to enumerate them. */
|
|
58
|
+
function readIndexRows(indexPath) {
|
|
59
|
+
let raw;
|
|
60
|
+
try {
|
|
61
|
+
raw = readFileSync(indexPath, 'utf8');
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
void error;
|
|
65
|
+
return { ok: false };
|
|
66
|
+
}
|
|
67
|
+
let parsed;
|
|
68
|
+
try {
|
|
69
|
+
parsed = JSON.parse(raw);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
void error;
|
|
73
|
+
return { ok: false };
|
|
74
|
+
}
|
|
75
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
76
|
+
return { ok: false };
|
|
77
|
+
}
|
|
78
|
+
return { ok: true, recordPaths: Object.keys(parsed) };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The record's path, guarded.
|
|
82
|
+
*
|
|
83
|
+
* A row whose path leaves the ledger is refused here: the row may name a
|
|
84
|
+
* dispatch, but the path it names is not one this session may read, so the
|
|
85
|
+
* facts behind it stay unknown.
|
|
86
|
+
*/
|
|
87
|
+
function safeRecordPath(projectRoot, ledgerDir, recordPath) {
|
|
88
|
+
const candidate = isAbsolute(recordPath) ? recordPath : resolve(ledgerDir, recordPath);
|
|
89
|
+
try {
|
|
90
|
+
return assertSafeDispatchRecordPath(candidate, projectRoot);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
void error;
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/** One row's facts: the record behind it, or why there are none. */
|
|
98
|
+
function readDispatchFact(projectRoot, ledgerDir, recordPath) {
|
|
99
|
+
const safe = safeRecordPath(projectRoot, ledgerDir, recordPath);
|
|
100
|
+
if (safe === null)
|
|
101
|
+
return { kind: 'unreadable', recordPath };
|
|
102
|
+
if (!existsSync(safe))
|
|
103
|
+
return { kind: 'absent', recordPath: safe };
|
|
104
|
+
const parsed = parseRecord(safe);
|
|
105
|
+
if (!parsed.ok)
|
|
106
|
+
return { kind: 'unreadable', recordPath: safe };
|
|
107
|
+
return {
|
|
108
|
+
kind: 'record',
|
|
109
|
+
recordPath: safe,
|
|
110
|
+
status: parsed.status,
|
|
111
|
+
outcome: parsed.outcome,
|
|
112
|
+
lastBeatAt: parsed.lastBeatAt,
|
|
113
|
+
createdAt: parsed.createdAt,
|
|
114
|
+
disposed: parsed.disposed
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* One record's fields.
|
|
119
|
+
*
|
|
120
|
+
* The record is upgraded through the writer's own reader, so a legacy record
|
|
121
|
+
* is read the same way every other reader reads it and a record from a build
|
|
122
|
+
* this one does not understand is refused rather than half-believed. The
|
|
123
|
+
* STATUS is taken from the raw record rather than from the upgrade: the
|
|
124
|
+
* upgrade maps a status it does not recognise onto `unreadable`, and this
|
|
125
|
+
* reader must be able to tell the probe that the record said something the
|
|
126
|
+
* probe does not know.
|
|
127
|
+
*/
|
|
128
|
+
function parseRecord(recordPath) {
|
|
129
|
+
let raw;
|
|
130
|
+
try {
|
|
131
|
+
raw = readFileSync(recordPath, 'utf8');
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
void error;
|
|
135
|
+
return { ok: false };
|
|
136
|
+
}
|
|
137
|
+
let parsed;
|
|
138
|
+
try {
|
|
139
|
+
parsed = JSON.parse(raw);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
void error;
|
|
143
|
+
return { ok: false };
|
|
144
|
+
}
|
|
145
|
+
let upgraded;
|
|
146
|
+
try {
|
|
147
|
+
upgraded = upgradeRecord(parsed);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
void error;
|
|
151
|
+
return { ok: false };
|
|
152
|
+
}
|
|
153
|
+
const status = parsed.status;
|
|
154
|
+
if (typeof status !== 'string')
|
|
155
|
+
return { ok: false };
|
|
156
|
+
return {
|
|
157
|
+
ok: true,
|
|
158
|
+
status,
|
|
159
|
+
outcome: upgraded.outcome,
|
|
160
|
+
lastBeatAt: upgraded.lastBeatAt,
|
|
161
|
+
createdAt: upgraded.createdAt,
|
|
162
|
+
disposed: upgraded.disposed
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check: the canonical skill store against the installed package
|
|
3
|
+
* (`skills:store-version:store`).
|
|
4
|
+
*
|
|
5
|
+
* THE HOLE THIS CLOSES. `skill-reference-parity` compares the canonical store
|
|
6
|
+
* against the IDE trees — and on a normal install the IDE entry is a LINK INTO
|
|
7
|
+
* the store, so the two sides are the SAME tree and the comparison is always in
|
|
8
|
+
* parity. A store frozen at an old release is perfectly self-consistent, and
|
|
9
|
+
* therefore invisible to that check. The comparison this one makes is the other
|
|
10
|
+
* axis: STORE against PACKAGE. The store's sidecar records the version that
|
|
11
|
+
* produced each copy; the package's `package.json#version` is the version that
|
|
12
|
+
* SHOULD have produced it. A gap between them is staleness nothing else can see.
|
|
13
|
+
*
|
|
14
|
+
* THE PATTERN. It is the `dist-source-version` shape applied to the store: a
|
|
15
|
+
* missing input is INFORMATIONAL, never a red — a machine with no store at all
|
|
16
|
+
* has nothing stale, and saying so is not a finding. A store that cannot be
|
|
17
|
+
* read is a different case: it looks exactly like "no drift", so it is
|
|
18
|
+
* reported.
|
|
19
|
+
*
|
|
20
|
+
* IT ALWAYS EMITS A ROW. A check that stays silent when it finds nothing
|
|
21
|
+
* cannot be told apart from a check that never ran; this one says "clean" out
|
|
22
|
+
* loud, with the version it compared against.
|
|
23
|
+
*
|
|
24
|
+
* READ-ONLY. It lists the store and reads sidecars. It never writes, repairs
|
|
25
|
+
* or deletes; the remedy it names (`peaks skill sync`) is the repair.
|
|
26
|
+
*/
|
|
27
|
+
import type { DoctorCheckPlugin } from '../types.js';
|
|
28
|
+
/** One managed store entry, and the version its sidecar records. */
|
|
29
|
+
export type CanonicalStoreEntryVersion = {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
/** null when the sidecar records no version — the legacy shape. */
|
|
32
|
+
readonly version: string | null;
|
|
33
|
+
};
|
|
34
|
+
/** What the store holds, compared with the installed package. */
|
|
35
|
+
export type CanonicalStoreVersionInspection = {
|
|
36
|
+
readonly storeRoot: string;
|
|
37
|
+
readonly storePresent: boolean;
|
|
38
|
+
/** False when the store root exists but cannot be listed. */
|
|
39
|
+
readonly readable: boolean;
|
|
40
|
+
/** How many entries the store owns (they carry a `.peaks-managed` sidecar). */
|
|
41
|
+
readonly managed: number;
|
|
42
|
+
readonly entries: readonly CanonicalStoreEntryVersion[];
|
|
43
|
+
/** The entries whose recorded version is behind the installed one. */
|
|
44
|
+
readonly stale: readonly CanonicalStoreEntryVersion[];
|
|
45
|
+
readonly installedVersion: string;
|
|
46
|
+
};
|
|
47
|
+
/** The version a sidecar records, or null when it records none. */
|
|
48
|
+
export declare function readMarkerVersion(markerPath: string): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* The managed entries of one canonical skills store, and the ones behind.
|
|
51
|
+
*
|
|
52
|
+
* `storeRoot` is the canonical SKILLS directory (`<PEAKS_HOME or ~/.peaks>/skills`).
|
|
53
|
+
* An entry the user authored carries no sidecar and is not ours, so it is not
|
|
54
|
+
* counted and never reported.
|
|
55
|
+
*/
|
|
56
|
+
export declare function inspectCanonicalStoreVersions(storeRoot: string, installedVersion: string): CanonicalStoreVersionInspection;
|
|
57
|
+
export declare const check: DoctorCheckPlugin;
|