peaks-loop 4.0.25 → 4.0.27
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/CHANGELOG.md +23 -0
- package/dist/cli/commands/code-runtime-commands.js +7 -1
- package/dist/cli/commands/core/memory-command.js +1 -3
- package/dist/cli/commands/dispatch-commands.js +14 -67
- package/dist/cli/commands/memory-commands.d.ts +0 -2
- package/dist/cli/commands/memory-commands.js +4 -7
- package/dist/cli/commands/preferences-commands.js +0 -1
- package/dist/cli/commands/qa-commands.js +5 -5
- package/dist/cli/commands/sub-agent-shared.d.ts +0 -4
- package/dist/cli/commands/sub-agent-shared.js +0 -14
- package/dist/cli/commands/workflow-commands.js +5 -5
- package/dist/services/code/auto-compact-orchestrator.js +3 -0
- package/dist/services/context/auto-compact-reader.d.ts +45 -49
- package/dist/services/context/auto-compact-reader.js +21 -148
- package/dist/services/context/auto-compact-types.d.ts +17 -2
- package/dist/services/context/build-dispatch-system-prompt.d.ts +4 -4
- package/dist/services/context/build-dispatch-system-prompt.js +6 -6
- package/dist/services/context/context-guard.d.ts +2 -4
- package/dist/services/context/context-guard.js +4 -6
- package/dist/services/context/{headroom-fetcher.d.ts → doc-cache-fetcher.d.ts} +2 -2
- package/dist/services/context/{headroom-fetcher.js → doc-cache-fetcher.js} +4 -3
- package/dist/services/context/memory-preflight-service.js +6 -17
- package/dist/services/context/threshold.d.ts +0 -3
- package/dist/services/context/threshold.js +0 -3
- package/dist/services/dispatch/batch-counter.js +1 -1
- package/dist/services/dispatch/leak-detector.js +1 -1
- package/dist/services/fuzzy-matching/fzf-pick-service.d.ts +1 -1
- package/dist/services/fuzzy-matching/fzf-pick-service.js +1 -1
- package/dist/services/ide/adapters/claude-code-adapter.d.ts +12 -12
- package/dist/services/ide/adapters/claude-code-adapter.js +290 -1
- package/dist/services/ide/ide-types.d.ts +39 -0
- package/dist/services/memory/llm-reranker.d.ts +4 -5
- package/dist/services/memory/llm-reranker.js +6 -8
- package/dist/services/memory/memory-search-service.d.ts +0 -32
- package/dist/services/memory/memory-search-service.js +0 -37
- package/dist/services/preferences/preferences-service.d.ts +5 -8
- package/dist/services/preferences/preferences-service.js +0 -30
- package/dist/services/preferences/preferences-types.d.ts +0 -22
- package/dist/services/preferences/preferences-types.js +0 -12
- package/dist/services/retrospective/retrospective-search-service.d.ts +0 -18
- package/dist/services/retrospective/retrospective-search-service.js +0 -32
- package/dist/services/session/binding-status-service.d.ts +11 -0
- package/dist/services/session/binding-status-service.js +25 -4
- package/dist/services/skill/skill-search-service.d.ts +1 -1
- package/dist/services/slice/slice-benchmark-service.d.ts +1 -1
- package/dist/services/slice/slice-benchmark-service.js +1 -1
- package/dist/services/slice/slice-pick-service.d.ts +1 -1
- package/dist/services/slice/slice-pick-service.js +1 -1
- package/package.json +5 -6
- package/skills/bee/peaks-qa/references/qa-context-governance.md +1 -1
- package/skills/bee/peaks-rd/SKILL.md +2 -2
- package/skills/bee/peaks-rd/references/rd-context-governance.md +2 -2
- package/skills/bee/peaks-txt/SKILL.md +1 -1
- package/skills/bee/peaks-ui/SKILL.md +1 -1
- package/skills/peaks-code/SKILL.md +1 -1
- package/skills/peaks-code/references/context-governance.md +7 -34
- package/skills/peaks-code/references/envelope-contract.md +2 -7
- package/skills/peaks-code/references/sub-agent-dispatch.md +2 -4
- package/dist/services/context/headroom-client.d.ts +0 -34
- package/dist/services/context/headroom-client.js +0 -117
- package/dist/services/context/headroom-prefs.d.ts +0 -46
- package/dist/services/context/headroom-prefs.js +0 -34
- package/skills/peaks-code/references/headroom-integration.md +0 -107
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Headroom Integration — G7.7 opt-in compression channel
|
|
2
|
-
|
|
3
|
-
> Slice #010 (G7.7 headroom-ai integration route).
|
|
4
|
-
> Source: https://github.com/chopratejas/headroom
|
|
5
|
-
> Package: `headroom-ai@0.22.4` (Apache-2.0, MIT-compatible).
|
|
6
|
-
> See: `THIRD_PARTY_LICENSES.md` for the license record.
|
|
7
|
-
|
|
8
|
-
## Why headroom-ai is justified (R-14)
|
|
9
|
-
|
|
10
|
-
The dev-preference red line "非必要不添加新的 dep" is preserved:
|
|
11
|
-
headroom-ai is the only opt-in mechanism for G7.7 + G9 to compress
|
|
12
|
-
sub-agent prompts that exceed the 75% / 80% threshold. Without
|
|
13
|
-
headroom-ai, `--use-headroom` is a no-op and the only fallback is
|
|
14
|
-
`--force` override at CLI.
|
|
15
|
-
|
|
16
|
-
The user's explicit reference (https://github.com/chopratejas/headroom)
|
|
17
|
-
is the basis for the dev-preference override.
|
|
18
|
-
|
|
19
|
-
## API shape (real SDK, not the PRD's spec)
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import { compress } from 'headroom-ai';
|
|
23
|
-
|
|
24
|
-
const result = await compress(messages, {
|
|
25
|
-
model: 'claude-sonnet-4-5-20250929',
|
|
26
|
-
baseUrl: 'http://localhost:8787', // local proxy; not used in slice #010
|
|
27
|
-
apiKey: 'hr_...', // Headroom Cloud; not used in slice #010
|
|
28
|
-
timeout: 30_000,
|
|
29
|
-
fallback: true, // CRITICAL: return original messages if proxy is dead
|
|
30
|
-
retries: 1,
|
|
31
|
-
tokenBudget: 4000, // compress to fit this limit
|
|
32
|
-
hooks: new MyHooks(), // pre/post compression hooks
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
result.messages // compressed messages
|
|
36
|
-
result.tokensBefore // original token count
|
|
37
|
-
result.tokensAfter // compressed token count
|
|
38
|
-
result.tokensSaved // tokens removed
|
|
39
|
-
result.compressionRatio // tokensAfter / tokensBefore
|
|
40
|
-
result.transformsApplied // e.g. ['router:smart_crusher:0.35']
|
|
41
|
-
result.compressed // false if fallback kicked in
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
`fallback: true` is the key option: if the proxy is unavailable, the SDK
|
|
45
|
-
returns the original messages + `result.compressed: false` instead of
|
|
46
|
-
throwing. This makes the failure mode non-blocking (RL-22d / RL-32).
|
|
47
|
-
|
|
48
|
-
## Mode table (peaks wrapper)
|
|
49
|
-
|
|
50
|
-
The peaks wrapper maps the user-facing `HeadroomMode` to the SDK's
|
|
51
|
-
`tokenBudget` option. Slice #010 does not consume the SDK's internal
|
|
52
|
-
"audit" / "optimize" / "simulate" modes (those are SDK-internal);
|
|
53
|
-
|
|
54
|
-
| Mode | tokenBudget | Use case |
|
|
55
|
-
|---|---|---|
|
|
56
|
-
| `balanced` (default) | promptSize * 0.40 / 4 | General sub-agent dispatch |
|
|
57
|
-
| `aggressive` | promptSize * 0.20 / 4 | Last-resort large prompt |
|
|
58
|
-
| `conservative` | promptSize * 0.70 / 4 | Sensitive code analysis, accuracy-critical |
|
|
59
|
-
|
|
60
|
-
The `0.40 / 4` factor approximates 60% byte reduction (1 token ≈ 4 bytes
|
|
61
|
-
for English text). The SDK does its own tokenization internally; the
|
|
62
|
-
`tokenBudget` is a hint, not a hard cap.
|
|
63
|
-
|
|
64
|
-
## Failure semantics (RL-22d / RL-32)
|
|
65
|
-
|
|
66
|
-
- `result.compressed === false` → `code: "HEADROOM_UNAVAILABLE"` warning
|
|
67
|
-
- `compress()` throws (network error, JSON parse error) → caught and treated as `HEADROOM_UNAVAILABLE`
|
|
68
|
-
- Import failure (headroom-ai not installed) → caught and treated as `HEADROOM_UNAVAILABLE`
|
|
69
|
-
- **NOT blocking** — peak falls back to G7 metadata-only and continues dispatch
|
|
70
|
-
|
|
71
|
-
## CCR reversible hydration (slice #011+ TODO)
|
|
72
|
-
|
|
73
|
-
The PRD mentions "CCR (Cross-Context Reversible)" as a benefit of
|
|
74
|
-
headroom. In the SDK, this is implemented via the `hooks` option on
|
|
75
|
-
`compress()`. A pre/post hook can persist the `ccrHashes` to disk,
|
|
76
|
-
and a later `rehydrate()` call can re-hydrate the compressed prompt
|
|
77
|
-
to the original. Slice #010 does NOT consume CCR — it only uses
|
|
78
|
-
compression. R-17 (CCR for aggressive / conservative modes) is
|
|
79
|
-
deferred to slice #011+.
|
|
80
|
-
|
|
81
|
-
## Cross-platform behavior (R-19)
|
|
82
|
-
|
|
83
|
-
- In-process compression (the SDK's library mode) is platform-agnostic.
|
|
84
|
-
- The long-running `headroom proxy` daemon is platform-specific
|
|
85
|
-
(Unix socket on Linux/macOS, named pipe on Windows). Slice #010
|
|
86
|
-
does NOT consume the proxy daemon.
|
|
87
|
-
- All headroom-ai calls in slice #010 go through the in-process SDK
|
|
88
|
-
with `fallback: true`. The peak wrapper at
|
|
89
|
-
`src/services/context/headroom-client.ts` catches all errors and
|
|
90
|
-
treats them as fallback.
|
|
91
|
-
|
|
92
|
-
## What slice #010 does NOT do
|
|
93
|
-
|
|
94
|
-
- Does NOT install the `headroom proxy` daemon (N-7).
|
|
95
|
-
- Does NOT consume headroom's `SharedContext` directly (G7.7.3 in the
|
|
96
|
-
PRD); the peak-internal `SharedChannel` (G8) is the cross-sub-agent
|
|
97
|
-
state store. `buildSharedContextBridge()` is a stub that returns
|
|
98
|
-
the peak-internal channel ID + a placeholder headroom context ID.
|
|
99
|
-
- Does NOT use the SDK's `audit` / `optimize` / `simulate` modes
|
|
100
|
-
(those are SDK-internal; the peak wrapper exposes
|
|
101
|
-
`balanced` / `aggressive` / `conservative` to the user).
|
|
102
|
-
|
|
103
|
-
## Security + license
|
|
104
|
-
|
|
105
|
-
- License: Apache-2.0 (MIT-compatible) — see `THIRD_PARTY_LICENSES.md`.
|
|
106
|
-
- Pinned version: exact `0.22.4` (no `^` / `~` range) per dev-preference.
|
|
107
|
-
- `pnpm audit` ran on install; no new high-severity vulnerabilities.
|