dsh-fast 0.1.2 → 0.2.0

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 CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.0] - 2026-08-26
9
+
10
+ ### Added
11
+
12
+ - System prompt bucket breakdown (AGENTS.md / skills / persona).
13
+
14
+ ## [0.1.3] - 2026-08-22
15
+
16
+ ### Changed
17
+
18
+ - DeepSeek Harness rc2 compatibility release: every `@deepseek-ai/dsh-*` peer moves from `0.1.0-rc.8` to `0.1.1-rc.2` (devDependencies pinned to the exact `0.1.1-rc.2`, peerDependencies kept at `>=0.1.0-rc.8 <0.2.0`), and the five-language READMEs, AGENTS.md, THIRD_PARTY_NOTICES.md, the pnpm release-age exclusions, and the CI workflows now target the `0.1.1-rc.2` family. The commands/tools/storage seams are verified against the rc2 peers unchanged.
19
+
8
20
  ## [0.1.2] - 2026-08-21
9
21
 
10
22
  ### Changed
package/README.es.md CHANGED
@@ -22,9 +22,9 @@
22
22
 
23
23
  ## Compatibility
24
24
 
25
- - DeepSeek Harness `0.1.0-rc.8` (peers fijados a `0.1.0-rc.8`).
25
+ - DeepSeek Harness `0.1.1-rc.2` (peers fijados a `0.1.1-rc.2`).
26
26
  - Node `^22.19.0 || >=24.0.0`, solo ESM (`"type": "module"`).
27
- - Peers: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, y `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` en `0.1.0-rc.8`.
27
+ - Peers: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, y `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` en `0.1.1-rc.2`.
28
28
 
29
29
  ## What you get
30
30
 
@@ -100,7 +100,7 @@ Todos los ajustes son campos Schemastery `Config`; valores inválidos fallan la
100
100
 
101
101
  ## Known limitations
102
102
 
103
- - **Dominio de almacenamiento, no eventos de sesión** — el `Session.append` de rc.8 no ofrece marcador `ignorable` ni superficie de registro de eventos externa; un evento `fast/*` haría que el coordinador de persistencia rechace el log al restaurar. Las métricas van al dominio de almacenamiento; los eventos crudos siguen siendo la fuente reconstruible.
103
+ - **Dominio de almacenamiento, no eventos de sesión** — el `Session.append` de rc.2 no ofrece marcador `ignorable` ni superficie de registro de eventos externa; un evento `fast/*` haría que el coordinador de persistencia rechace el log al restaurar. Las métricas van al dominio de almacenamiento; los eventos crudos siguen siendo la fuente reconstruible.
104
104
  - **La detección de spill es heurística** — lee el aviso persistente (`Full … stored at:`); no hay evento de sesión dedicado.
105
105
  - **El system prompt es un solo cajón** — AGENTS.md, skills y persona forman el system prompt ensamblado; no hay contabilidad por sección.
106
106
  - **El tiempo de carga empieza en la publicación** — la lectura de disco de una restauración ocurre antes de `session/created`; la duración reportada es publicación→primera petición.
@@ -123,7 +123,9 @@ pnpm pack
123
123
 
124
124
  ## Contributors
125
125
 
126
- `dsh-fast` contributors.
126
+ Gracias a todas las personas que han contribuido a `dsh-fast`:
127
+
128
+ - **[PerryLink](https://github.com/PerryLink)** — autor y mantenedor: diseñó y construyó los diagnósticos de solo lectura (latencia de carga de sesión, recuentos de spill, métricas de compactación, volumen de inyección de contexto, tasa de aciertos de la caché LLM), el comando `/fast` y la herramienta `fast_report`, el dominio de almacenamiento `dsh_fast` y la documentación en cinco idiomas.
127
129
 
128
130
  ## PerryLink DSH Plugin Family
129
131
 
package/README.hi.md CHANGED
@@ -22,9 +22,9 @@
22
22
 
23
23
  ## Compatibility
24
24
 
25
- - DeepSeek Harness `0.1.0-rc.8` (peers `0.1.0-rc.8` पर पिन किए गए)।
25
+ - DeepSeek Harness `0.1.1-rc.2` (peers `0.1.1-rc.2` पर पिन किए गए)।
26
26
  - Node `^22.19.0 || >=24.0.0`, केवल ESM (`"type": "module"`)।
27
- - Peers: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, और `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` (`0.1.0-rc.8`)।
27
+ - Peers: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, और `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` (`0.1.1-rc.2`)।
28
28
 
29
29
  ## What you get
30
30
 
@@ -100,7 +100,7 @@ dsh plugin --profile demo remove dsh-fast # हटाएँ
100
100
 
101
101
  ## Known limitations
102
102
 
103
- - **स्टोरेज डोमेन, सत्र घटनाएँ नहीं** — rc.8 का `Session.append` `ignorable` मार्कर या बाहरी घटना-पंजीकरण सतह नहीं देता; कस्टम `fast/*` घटना पुनर्स्थापना पर लॉग को अस्वीकार करवा देती। इसलिए मेट्रिक्स स्टोरेज डोमेन में जाते हैं; कच्ची घटनाएँ पुनर्निर्माण-योग्य स्रोत बनी रहती हैं।
103
+ - **स्टोरेज डोमेन, सत्र घटनाएँ नहीं** — rc.2 का `Session.append` `ignorable` मार्कर या बाहरी घटना-पंजीकरण सतह नहीं देता; कस्टम `fast/*` घटना पुनर्स्थापना पर लॉग को अस्वीकार करवा देती। इसलिए मेट्रिक्स स्टोरेज डोमेन में जाते हैं; कच्ची घटनाएँ पुनर्निर्माण-योग्य स्रोत बनी रहती हैं।
104
104
  - **spill पहचान अनुमानी है** — यह स्थायी सूचना (`Full … stored at:`) पढ़ती है; कोई समर्पित सत्र घटना नहीं है।
105
105
  - **system prompt एक ही बकेट है** — AGENTS.md, skills और persona असेंबल किए गए system prompt का हिस्सा हैं; header में प्रति-अनुभाग गणना नहीं होती।
106
106
  - **लोड समय प्रकाशन से शुरू होता है** — पुनर्स्थापना का डिस्क-रीड `session/created` से पहले होता है; रिपोर्ट की गई अवधि प्रकाशन→पहली अनुरोध है।
@@ -123,7 +123,9 @@ pnpm pack
123
123
 
124
124
  ## Contributors
125
125
 
126
- `dsh-fast` contributors.
126
+ `dsh-fast` में योगदान देने वाले सभी लोगों का धन्यवाद:
127
+
128
+ - **[PerryLink](https://github.com/PerryLink)** — लेखक और अनुरक्षक: रीड-ओनली डायग्नोस्टिक्स (सेशन-लोड विलंब, स्पिल-हिट गणना, कम्पैक्शन मीट्रिक्स, कॉन्टेक्स्ट-इंजेक्शन वॉल्यूम, LLM कैश हिट रेट), `/fast` कमांड और `fast_report` टूल, `dsh_fast` स्टोरेज डोमेन तथा पाँच-भाषा दस्तावेज़ का डिज़ाइन व निर्माण किया।
127
129
 
128
130
  ## PerryLink DSH Plugin Family
129
131
 
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  <div align="center">
2
2
 
3
3
  # ⚡ dsh-fast
4
+ [![Gitee](https://img.shields.io/badge/Gitee-mirror-c71d23?logo=gitee)](https://gitee.com/perrylink/dsh-fast)
4
5
 
5
6
  **Read-only performance diagnostics for DeepSeek Harness.**
6
7
 
@@ -22,9 +23,9 @@
22
23
 
23
24
  ## Compatibility
24
25
 
25
- - DeepSeek Harness `0.1.0-rc.8` (peers pinned to `0.1.0-rc.8`).
26
+ - DeepSeek Harness `0.1.1-rc.2` (peers pinned to `0.1.1-rc.2`).
26
27
  - Node `^22.19.0 || >=24.0.0`, ESM only (`"type": "module"`).
27
- - Peer dependencies: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, and `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` at `0.1.0-rc.8`.
28
+ - Peer dependencies: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, and `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` at `0.1.1-rc.2`.
28
29
 
29
30
  ## What you get
30
31
 
@@ -100,7 +101,7 @@ All tunables are Schemastery `Config` fields; invalid values fail the profile lo
100
101
 
101
102
  ## Known limitations
102
103
 
103
- - **Storage domain, not session events** — rc.8 `Session.append` offers no `ignorable` marker and no external event-registration surface, so a custom `fast/*` session event would make the persistence coordinator refuse the log on restore. Metrics are therefore persisted to the storage domain; the raw events remain the reconstructable source of truth.
104
+ - **Storage domain, not session events** — rc.2 `Session.append` offers no `ignorable` marker and no external event-registration surface, so a custom `fast/*` session event would make the persistence coordinator refuse the log on restore. Metrics are therefore persisted to the storage domain; the raw events remain the reconstructable source of truth.
104
105
  - **Spill detection is heuristic** — it reads the durable spill notice (`Full … stored at:`); no dedicated session event exists.
105
106
  - **System prompt is one bucket** — AGENTS.md, skill directory, and persona are all part of the assembled system prompt; the header carries no per-section token accounting, so they are reported together.
106
107
  - **Load timing starts at publication** — the disk-read portion of a restore happens before `session/created` (owned by `sessionPersistence`) and is not observable from this plugin's allowed events; the reported duration is publication-to-first-request.
@@ -123,7 +124,9 @@ pnpm pack
123
124
 
124
125
  ## Contributors
125
126
 
126
- `dsh-fast` contributors.
127
+ Thanks to everyone who has contributed to `dsh-fast`:
128
+
129
+ - **[PerryLink](https://github.com/PerryLink)** — author and maintainer: designed and built the read-only diagnostics (session-load timing, spill-hit counts, compaction metrics, context-injection volume, LLM cache hit rate), the `/fast` command and `fast_report` tool, the `dsh_fast` storage domain, and the five-language documentation.
127
130
 
128
131
  ## PerryLink DSH Plugin Family
129
132
 
package/README.pt.md CHANGED
@@ -22,9 +22,9 @@
22
22
 
23
23
  ## Compatibility
24
24
 
25
- - DeepSeek Harness `0.1.0-rc.8` (peers fixados em `0.1.0-rc.8`).
25
+ - DeepSeek Harness `0.1.1-rc.2` (peers fixados em `0.1.1-rc.2`).
26
26
  - Node `^22.19.0 || >=24.0.0`, somente ESM (`"type": "module"`).
27
- - Peers: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, e `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` em `0.1.0-rc.8`.
27
+ - Peers: `@deepseek-ai/cordis ^4.0.1`, `@deepseek-ai/schemastery ^3.18.0`, e `@deepseek-ai/dsh-session`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/dsh-commands`, `@deepseek-ai/dsh-compaction`, `@deepseek-ai/dsh-storage-domain` em `0.1.1-rc.2`.
28
28
 
29
29
  ## What you get
30
30
 
@@ -100,7 +100,7 @@ O `dsh-fast` consome apenas seams públicos: eventos `session/*` e `agent/*`, o
100
100
 
101
101
  ## Known limitations
102
102
 
103
- - **Domínio de armazenamento, não eventos de sessão** — o `Session.append` do rc.8 não oferece marcador `ignorable` nem superfície de registro de eventos externa; um evento `fast/*` faria o coordenador de persistência recusar o log ao restaurar. As métricas vão ao domínio de armazenamento; os eventos brutos seguem como fonte reconstruível.
103
+ - **Domínio de armazenamento, não eventos de sessão** — o `Session.append` do rc.2 não oferece marcador `ignorable` nem superfície de registro de eventos externa; um evento `fast/*` faria o coordenador de persistência recusar o log ao restaurar. As métricas vão ao domínio de armazenamento; os eventos brutos seguem como fonte reconstruível.
104
104
  - **A detecção de spill é heurística** — lê o aviso persistente (`Full … stored at:`); não há evento de sessão dedicado.
105
105
  - **O system prompt é um único balde** — AGENTS.md, skills e persona formam o system prompt montado; não há contagem por seção.
106
106
  - **O tempo de carga começa na publicação** — a leitura de disco de uma restauração ocorre antes de `session/created`; a duração reportada é publicação→primeira requisição.
@@ -123,7 +123,9 @@ pnpm pack
123
123
 
124
124
  ## Contributors
125
125
 
126
- `dsh-fast` contributors.
126
+ Obrigado a todas as pessoas que contribuíram com o `dsh-fast`:
127
+
128
+ - **[PerryLink](https://github.com/PerryLink)** — autor e mantenedor: projetou e construiu os diagnósticos somente leitura (latência de carregamento de sessão, contagens de spill, métricas de compactação, volume de injeção de contexto, taxa de acertos de cache do LLM), o comando `/fast` e a ferramenta `fast_report`, o domínio de armazenamento `dsh_fast` e a documentação em cinco idiomas.
127
129
 
128
130
  ## PerryLink DSH Plugin Family
129
131
 
package/README.zh.md CHANGED
@@ -22,9 +22,9 @@
22
22
 
23
23
  ## Compatibility
24
24
 
25
- - DeepSeek Harness `0.1.0-rc.8`(peer 钉在 `0.1.0-rc.8`)。
25
+ - DeepSeek Harness `0.1.1-rc.2`(peer 钉在 `0.1.1-rc.2`)。
26
26
  - Node `^22.19.0 || >=24.0.0`,纯 ESM(`"type": "module"`)。
27
- - peer 依赖:`@deepseek-ai/cordis ^4.0.1`、`@deepseek-ai/schemastery ^3.18.0`,以及 `@deepseek-ai/dsh-session`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/dsh-commands`、`@deepseek-ai/dsh-compaction`、`@deepseek-ai/dsh-storage-domain`(`0.1.0-rc.8`)。
27
+ - peer 依赖:`@deepseek-ai/cordis ^4.0.1`、`@deepseek-ai/schemastery ^3.18.0`,以及 `@deepseek-ai/dsh-session`、`@deepseek-ai/dsh-tools`、`@deepseek-ai/dsh-commands`、`@deepseek-ai/dsh-compaction`、`@deepseek-ai/dsh-storage-domain`(`0.1.1-rc.2`)。
28
28
 
29
29
  ## What you get
30
30
 
@@ -100,7 +100,7 @@ dsh plugin --profile demo remove dsh-fast # 卸载
100
100
 
101
101
  ## Known limitations
102
102
 
103
- - **用存储域而非会话事件** —— rc.8 的 `Session.append` 没有 `ignorable` 标记能力,也没有外部事件注册面,写自定义 `fast/*` 会话事件会让持久化协调器在恢复时拒绝日志。因此度量改为持久化到存储域;原始事件仍是可重建的事实来源。
103
+ - **用存储域而非会话事件** —— rc.2 的 `Session.append` 没有 `ignorable` 标记能力,也没有外部事件注册面,写自定义 `fast/*` 会话事件会让持久化协调器在恢复时拒绝日志。因此度量改为持久化到存储域;原始事件仍是可重建的事实来源。
104
104
  - **spill 检测是启发式** —— 读取持久化的 spill 提示(`Full … stored at:`);没有专门的会话事件。
105
105
  - **系统提示词是单个桶** —— AGENTS.md、技能目录与人设都属于组装后的系统提示词;header 不携带分段 token 统计,因此合并上报。
106
106
  - **加载耗时从发布时刻起算** —— 恢复时的磁盘读取发生在 `session/created` 之前(由 `sessionPersistence` 负责),本插件允许的事件观察不到;上报的时长是发布到首次请求的延迟。
@@ -123,7 +123,9 @@ pnpm pack
123
123
 
124
124
  ## Contributors
125
125
 
126
- `dsh-fast` contributors.
126
+ 感谢所有为 `dsh-fast` 做出贡献的人:
127
+
128
+ - **[PerryLink](https://github.com/PerryLink)** —— 作者与维护者:设计并实现了只读诊断(会话加载耗时、spill 命中统计、compaction 指标、上下文注入体量、LLM 缓存命中率)、`/fast` 命令与 `fast_report` 工具、`dsh_fast` 存储域以及五语文档。
127
129
 
128
130
  ## PerryLink DSH Plugin Family
129
131
 
@@ -14,7 +14,7 @@ published tarball except where noted; these are install-time dependencies:
14
14
  | [zod](https://github.com/colinhacks/zod) | `^4.4.3` | MIT | Runtime value schema for the `dsh_fast` storage-domain table (bundled into `lib/`) |
15
15
  | [@deepseek-ai/cordis](https://www.npmjs.com/package/@deepseek-ai/cordis) | `^4.0.1` (peer) | See package | The plugin runtime |
16
16
  | [@deepseek-ai/schemastery](https://www.npmjs.com/package/@deepseek-ai/schemastery) | `^3.18.0` (peer) | See package | Configuration schema |
17
- | `@deepseek-ai/dsh-*` peers | `0.1.0-rc.8` (peer) | See packages | Official harness seams (`dsh-session`, `dsh-tools`, `dsh-commands`, `dsh-compaction`, `dsh-storage-domain`) |
17
+ | `@deepseek-ai/dsh-*` peers | `0.1.1-rc.2` (peer) | See packages | Official harness seams (`dsh-session`, `dsh-tools`, `dsh-commands`, `dsh-compaction`, `dsh-storage-domain`) |
18
18
 
19
19
  At runtime the plugin only talks to the harness services listed as
20
20
  peerDependencies; it performs no network requests and stores no credentials.
package/lib/index.js CHANGED
@@ -97,9 +97,70 @@ const CHARS_PER_TOKEN = 4;
97
97
  const ROLE_OVERHEAD = 4;
98
98
  /** Per-block structural overhead for JSON framing and type tags. */
99
99
  const BLOCK_OVERHEAD = 4;
100
+ /** Which tracked bucket a section name belongs to. */
101
+ function bucketOf(name) {
102
+ if (name === "deployment:persona") return "persona";
103
+ if (name.toLowerCase().includes("skill")) return "skills";
104
+ if (/agent|instructions?/iu.test(name)) return "agentsMd";
105
+ return "other";
106
+ }
107
+ /** An empty breakdown (all buckets zeroed). */
108
+ function emptyBreakdown() {
109
+ return {
110
+ agentsMd: {
111
+ tokens: 0,
112
+ chars: 0,
113
+ share: 0
114
+ },
115
+ skills: {
116
+ tokens: 0,
117
+ chars: 0,
118
+ share: 0
119
+ },
120
+ persona: {
121
+ tokens: 0,
122
+ chars: 0,
123
+ share: 0
124
+ },
125
+ other: {
126
+ tokens: 0,
127
+ chars: 0,
128
+ share: 0
129
+ }
130
+ };
131
+ }
100
132
  /**
101
- * Price the assembled system prompt (AGENTS.md + skill directory + persona +
102
- * harness instructions).
133
+ * Classify the named system-prompt sections into the AGENTS.md / skills /
134
+ * persona / other buckets, with heuristic tokens and per-bucket shares. The
135
+ * caller supplies either the real assembled sections (via the optional
136
+ * `systemPrompt` service) or a single synthetic `{ name: 'other' }` section
137
+ * carrying the rendered prompt, so the breakdown always sums to the system
138
+ * prompt.
139
+ * @param sections - named sections (never empty in practice).
140
+ * @returns the per-bucket breakdown.
141
+ */
142
+ function classifySystemSections(sections) {
143
+ const breakdown = emptyBreakdown();
144
+ for (const section of sections) {
145
+ const chars = section.text.length;
146
+ if (chars === 0) continue;
147
+ const bucket = breakdown[bucketOf(section.name)];
148
+ bucket.chars += chars;
149
+ bucket.tokens += Math.ceil(chars / CHARS_PER_TOKEN);
150
+ }
151
+ const total = breakdown.agentsMd.tokens + breakdown.skills.tokens + breakdown.persona.tokens + breakdown.other.tokens;
152
+ if (total <= 0) return breakdown;
153
+ for (const bucket of [
154
+ breakdown.agentsMd,
155
+ breakdown.skills,
156
+ breakdown.persona,
157
+ breakdown.other
158
+ ]) bucket.share = bucket.tokens / total;
159
+ return breakdown;
160
+ }
161
+ /**
162
+ * Price the assembled system prompt (harness identity + persona + tool
163
+ * guidance + plugin sections).
103
164
  * @param header - canonical request envelope, or undefined before any request.
104
165
  * @returns heuristic system-prompt tokens; 0 when absent.
105
166
  */
@@ -234,9 +295,12 @@ var FastCollector = class {
234
295
  * the optional token meter is consulted, so it never runs in the append path.
235
296
  * @param session - the session to snapshot.
236
297
  * @param measure - optional token-meter measure function.
298
+ * @param sections - optional named system-prompt sections (from the optional
299
+ * `systemPrompt` service); absent = the whole rendered system prompt is
300
+ * attributed to the `other` bucket.
237
301
  * @returns the snapshot.
238
302
  */
239
- snapshot(session, measure) {
303
+ snapshot(session, measure, sections) {
240
304
  const state = this.live.get(session);
241
305
  if (state === void 0) return emptySnapshot();
242
306
  const measurement = measure === void 0 ? void 0 : measure(session);
@@ -244,6 +308,11 @@ var FastCollector = class {
244
308
  const toolSchemaTokens = estimateToolsTokens(state.lastHeader);
245
309
  const surfaceTokens = measurement?.surfaceTokens ?? 0;
246
310
  const totalTokens = measurement?.totalTokens ?? systemTokens + toolSchemaTokens + surfaceTokens;
311
+ const systemChars = state.lastHeader?.system?.length ?? 0;
312
+ const systemBreakdown = classifySystemSections(sections ?? (systemChars > 0 ? [{
313
+ name: "other",
314
+ text: state.lastHeader.system
315
+ }] : []));
247
316
  return {
248
317
  load: {
249
318
  kind: state.kind,
@@ -265,7 +334,8 @@ var FastCollector = class {
265
334
  systemTokens,
266
335
  toolSchemaTokens,
267
336
  surfaceTokens,
268
- ...sharesOf(totalTokens, systemTokens, toolSchemaTokens, surfaceTokens)
337
+ ...sharesOf(totalTokens, systemTokens, toolSchemaTokens, surfaceTokens),
338
+ systemBreakdown
269
339
  },
270
340
  cache: this.cacheStats(state)
271
341
  };
@@ -340,7 +410,29 @@ function emptySnapshot() {
340
410
  surfaceTokens: 0,
341
411
  systemShare: 0,
342
412
  toolsShare: 0,
343
- surfaceShare: 0
413
+ surfaceShare: 0,
414
+ systemBreakdown: {
415
+ agentsMd: {
416
+ tokens: 0,
417
+ chars: 0,
418
+ share: 0
419
+ },
420
+ skills: {
421
+ tokens: 0,
422
+ chars: 0,
423
+ share: 0
424
+ },
425
+ persona: {
426
+ tokens: 0,
427
+ chars: 0,
428
+ share: 0
429
+ },
430
+ other: {
431
+ tokens: 0,
432
+ chars: 0,
433
+ share: 0
434
+ }
435
+ }
344
436
  },
345
437
  cache: {
346
438
  inputTokens: 0,
@@ -467,6 +559,12 @@ function renderFastText(report) {
467
559
  `tool schema: ${context.toolSchemaTokens} (${formatPercent(context.toolsShare)})`,
468
560
  `surface: ${context.surfaceTokens} (${formatPercent(context.surfaceShare)})`,
469
561
  "",
562
+ "## System prompt breakdown",
563
+ `persona: ${context.systemBreakdown.persona.tokens} tokens / ${context.systemBreakdown.persona.chars} chars (${formatPercent(context.systemBreakdown.persona.share)})`,
564
+ `skills: ${context.systemBreakdown.skills.tokens} tokens / ${context.systemBreakdown.skills.chars} chars (${formatPercent(context.systemBreakdown.skills.share)})`,
565
+ `AGENTS.md: ${context.systemBreakdown.agentsMd.tokens} tokens / ${context.systemBreakdown.agentsMd.chars} chars (${formatPercent(context.systemBreakdown.agentsMd.share)})`,
566
+ `other (harness identity + tool guidance): ${context.systemBreakdown.other.tokens} tokens / ${context.systemBreakdown.other.chars} chars (${formatPercent(context.systemBreakdown.other.share)})`,
567
+ "",
470
568
  "## LLM cache",
471
569
  `input: ${cache.inputTokens}, cache read: ${cache.cacheReadTokens}, cache write: ${cache.cacheWriteTokens}, output: ${cache.outputTokens}`,
472
570
  `hit rate: ${formatPercent(cache.hitRate)}`
@@ -504,7 +602,7 @@ function buildReport(snapshot, meta, config, version) {
504
602
  * Durable metric storage over the harness storage domain. The `dsh-fast`
505
603
  * domain keeps one bounded history per session, so `/fast` and `fast_report`
506
604
  * metrics survive a restart and the trend stays queryable without touching the
507
- * session log (the rc.8 `Session.append` offers no `ignorable` marker and no
605
+ * session log (the rc.2 `Session.append` offers no `ignorable` marker and no
508
606
  * external event-registration surface, so a custom session event would make
509
607
  * the persistence coordinator refuse the log on restore).
510
608
  * @module dsh-fast/store
@@ -527,6 +625,19 @@ const compactionSchema = z$1.object({
527
625
  automatic: z$1.number().int().nonnegative(),
528
626
  shadowedTokens: z$1.number().int().nonnegative()
529
627
  });
628
+ /** Zod schema for one prompt bucket. */
629
+ const bucketSchema = z$1.object({
630
+ tokens: z$1.number().nonnegative(),
631
+ chars: z$1.number().nonnegative(),
632
+ share: z$1.number()
633
+ });
634
+ /** Zod schema for the system-prompt breakdown. */
635
+ const breakdownSchema = z$1.object({
636
+ agentsMd: bucketSchema,
637
+ skills: bucketSchema,
638
+ persona: bucketSchema,
639
+ other: bucketSchema
640
+ });
530
641
  /** Zod schema for the context section. */
531
642
  const contextSchema = z$1.object({
532
643
  totalTokens: z$1.number().nonnegative(),
@@ -535,7 +646,8 @@ const contextSchema = z$1.object({
535
646
  surfaceTokens: z$1.number().nonnegative(),
536
647
  systemShare: z$1.number(),
537
648
  toolsShare: z$1.number(),
538
- surfaceShare: z$1.number()
649
+ surfaceShare: z$1.number(),
650
+ systemBreakdown: breakdownSchema
539
651
  });
540
652
  /** Zod schema for the cache section. */
541
653
  const cacheSchema = z$1.object({
@@ -579,7 +691,7 @@ function appendSample(history, sample, maxSamples) {
579
691
  //#endregion
580
692
  //#region src/version.ts
581
693
  /** Single-source plugin version, bumped by `scripts/release.mjs`. @module dsh-fast/version */
582
- const VERSION = "0.1.2";
694
+ const VERSION = "0.2.0";
583
695
  //#endregion
584
696
  //#region src/index.ts
585
697
  const name = "fast";
@@ -620,17 +732,31 @@ async function apply(ctx, config = {}) {
620
732
  return;
621
733
  }
622
734
  };
735
+ /** Assemble the named system-prompt sections for the per-section breakdown. */
736
+ const assembleSections = async () => {
737
+ const systemPrompt = ctx.get("systemPrompt");
738
+ if (systemPrompt === void 0) return void 0;
739
+ try {
740
+ return (await systemPrompt.assemble()).sections.map((section) => ({
741
+ name: section.name,
742
+ text: section.text
743
+ }));
744
+ } catch (error) {
745
+ logger.warn(`system-prompt section assembly failed: ${error instanceof Error ? error.message : String(error)}`);
746
+ return;
747
+ }
748
+ };
623
749
  /** Build the complete report for one session. */
624
- const reportFor = (session) => {
625
- return buildReport(collector.snapshot(session, measure), {
750
+ const reportFor = async (session) => {
751
+ return buildReport(collector.snapshot(session, measure, await assembleSections()), {
626
752
  sessionId: session.id,
627
753
  ...resolved.includeCwd && session.header.cwd !== void 0 ? { cwd: session.header.cwd } : {},
628
754
  generatedAt: Date.now()
629
755
  }, resolved, VERSION);
630
756
  };
631
757
  /** Append one snapshot to the session's durable history (fire-and-forget). */
632
- const persist = (session) => {
633
- const snapshot = collector.snapshot(session, measure);
758
+ const persist = async (session) => {
759
+ const snapshot = collector.snapshot(session, measure, await assembleSections());
634
760
  const next = appendSample(sessions.get(session.id), {
635
761
  at: Date.now(),
636
762
  snapshot
@@ -642,10 +768,10 @@ async function apply(ctx, config = {}) {
642
768
  ctx.commands.register({
643
769
  name: "fast",
644
770
  description: "Print the dsh-fast performance report for the active session.",
645
- handler: (invocation) => {
771
+ async handler(invocation) {
646
772
  return {
647
773
  kind: "success",
648
- text: renderFastText(reportFor(invocation.agent.session))
774
+ text: renderFastText(await reportFor(invocation.agent.session))
649
775
  };
650
776
  }
651
777
  });
@@ -761,6 +887,89 @@ async function apply(ctx, config = {}) {
761
887
  surfaceShare: {
762
888
  type: "number",
763
889
  required: true
890
+ },
891
+ systemBreakdown: {
892
+ type: "object",
893
+ properties: {
894
+ agentsMd: {
895
+ type: "object",
896
+ properties: {
897
+ tokens: {
898
+ type: "number",
899
+ required: true
900
+ },
901
+ chars: {
902
+ type: "number",
903
+ required: true
904
+ },
905
+ share: {
906
+ type: "number",
907
+ required: true
908
+ }
909
+ },
910
+ additionalProperties: false,
911
+ required: true
912
+ },
913
+ skills: {
914
+ type: "object",
915
+ properties: {
916
+ tokens: {
917
+ type: "number",
918
+ required: true
919
+ },
920
+ chars: {
921
+ type: "number",
922
+ required: true
923
+ },
924
+ share: {
925
+ type: "number",
926
+ required: true
927
+ }
928
+ },
929
+ additionalProperties: false,
930
+ required: true
931
+ },
932
+ persona: {
933
+ type: "object",
934
+ properties: {
935
+ tokens: {
936
+ type: "number",
937
+ required: true
938
+ },
939
+ chars: {
940
+ type: "number",
941
+ required: true
942
+ },
943
+ share: {
944
+ type: "number",
945
+ required: true
946
+ }
947
+ },
948
+ additionalProperties: false,
949
+ required: true
950
+ },
951
+ other: {
952
+ type: "object",
953
+ properties: {
954
+ tokens: {
955
+ type: "number",
956
+ required: true
957
+ },
958
+ chars: {
959
+ type: "number",
960
+ required: true
961
+ },
962
+ share: {
963
+ type: "number",
964
+ required: true
965
+ }
966
+ },
967
+ additionalProperties: false,
968
+ required: true
969
+ }
970
+ },
971
+ additionalProperties: false,
972
+ required: true
764
973
  }
765
974
  },
766
975
  additionalProperties: false,
@@ -810,7 +1019,7 @@ async function apply(ctx, config = {}) {
810
1019
  async execute(_args, exec) {
811
1020
  const session = exec.agent?.session;
812
1021
  if (session === void 0) throw new Error("fast_report requires an agent-owned session");
813
- return reportFor(session);
1022
+ return await reportFor(session);
814
1023
  }
815
1024
  }));
816
1025
  ctx.on("session/created", (session) => {
@@ -841,4 +1050,4 @@ async function apply(ctx, config = {}) {
841
1050
  });
842
1051
  }
843
1052
  //#endregion
844
- export { Config, FastCollector, VERSION, appendSample, apply, buildReport, buildSuggestions, detectSpilledResult, fastDomainSpec, flattenToolResultText, historySchema, hitRateOf, inject, name, renderFastText, resolveConfig, sanitizePath, sanitizeText, sharesOf, stripControl, truncate };
1053
+ export { Config, FastCollector, VERSION, appendSample, apply, buildReport, buildSuggestions, classifySystemSections, detectSpilledResult, fastDomainSpec, flattenToolResultText, historySchema, hitRateOf, inject, name, renderFastText, resolveConfig, sanitizePath, sanitizeText, sharesOf, stripControl, truncate };
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CA4CzF;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAsCzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAUzH"}
1
+ {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,MAAM,EAAE,CA4CzF;AAYD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA4CzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAUzH"}
@@ -80,6 +80,12 @@ export function renderFastText(report) {
80
80
  `tool schema: ${context.toolSchemaTokens} (${formatPercent(context.toolsShare)})`,
81
81
  `surface: ${context.surfaceTokens} (${formatPercent(context.surfaceShare)})`,
82
82
  '',
83
+ '## System prompt breakdown',
84
+ `persona: ${context.systemBreakdown.persona.tokens} tokens / ${context.systemBreakdown.persona.chars} chars (${formatPercent(context.systemBreakdown.persona.share)})`,
85
+ `skills: ${context.systemBreakdown.skills.tokens} tokens / ${context.systemBreakdown.skills.chars} chars (${formatPercent(context.systemBreakdown.skills.share)})`,
86
+ `AGENTS.md: ${context.systemBreakdown.agentsMd.tokens} tokens / ${context.systemBreakdown.agentsMd.chars} chars (${formatPercent(context.systemBreakdown.agentsMd.share)})`,
87
+ `other (harness identity + tool guidance): ${context.systemBreakdown.other.tokens} tokens / ${context.systemBreakdown.other.chars} chars (${formatPercent(context.systemBreakdown.other.share)})`,
88
+ '',
83
89
  '## LLM cache',
84
90
  `input: ${cache.inputTokens}, cache read: ${cache.cacheReadTokens}, cache write: ${cache.cacheWriteTokens}, output: ${cache.outputTokens}`,
85
91
  `hit rate: ${formatPercent(cache.hitRate)}`,
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MA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C,MAAM,EAAE,CAAC,EAAE,QAAQ,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;IACrD,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAA;IAChC,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtB,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,WAAW;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,QAAsB,EAAE,IAAgB,EAAE,MAAsB,EAAE,OAAe;IAC3G,OAAO;QACL,GAAG,QAAQ;QACX,SAAS,EAAE,UAAU;QACrB,OAAO;QACP,SAAS,EAAE,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC;QAC5C,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC/C,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;KACxE,CAAA;AACH,CAAC"}
@@ -10,6 +10,7 @@
10
10
  import type { Session, SessionEvent, ToolResultMessage } from '@deepseek-ai/dsh-session';
11
11
  import type { FastSnapshot, ContextStats } from './model.js';
12
12
  import type { ResolvedConfig } from './config.js';
13
+ import { type SystemSection } from './estimate.js';
13
14
  /**
14
15
  * The structural surface of the optional `ctx.tokenMeter` service. Only the
15
16
  * fields dsh-fast reads are declared; the service is optional, so a host
@@ -69,9 +70,12 @@ export declare class FastCollector {
69
70
  * the optional token meter is consulted, so it never runs in the append path.
70
71
  * @param session - the session to snapshot.
71
72
  * @param measure - optional token-meter measure function.
73
+ * @param sections - optional named system-prompt sections (from the optional
74
+ * `systemPrompt` service); absent = the whole rendered system prompt is
75
+ * attributed to the `other` bucket.
72
76
  * @returns the snapshot.
73
77
  */
74
- snapshot(session: Session, measure?: MeasureFn): FastSnapshot;
78
+ snapshot(session: Session, measure?: MeasureFn, sections?: readonly SystemSection[]): FastSnapshot;
75
79
  /** Aggregate cache counters into the report shape. */
76
80
  private cacheStats;
77
81
  /** Fold one provider usage record. */
@@ -1 +1 @@
1
- {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAGxF,OAAO,KAAK,EAAE,YAAY,EAAc,YAAY,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,+CAA+C;AAC/C,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,gBAAgB,GAAG,SAAS,CAAA;AAK1E,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAQxE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAGvE;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,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