Skip to content

Commit fdd4e61

Browse files
feat(framework): token economy (lite) - economical prose, hard never-compress gate (#134)
Default output register compiled into every session's bootstrap: say it once, fewer words, grammar intact (lite, not caveman - words never break). Compress ONLY prose glue: preamble, restating, hedging, narration, option lists without a verdict. NEVER compress (hard gate, marker-guarded): diagrams/tables/visuals (padding rules stay), evidence (command output, errors, verification lines, numbers, ids), code/config, security + irreversible-action warnings, anything whose omission could change a decision. Seams closed from live pressure test: visuals are mandated where they beat prose (gate protects them once they exist AND requires them); user brevity requests compress prose only - they never touch the NEVER list; clarity beats economy on conflict. Compiler: extractOptionalSection (missing section tolerated in synthetic sources, real absence caught by new markers 'Token Economy' + 'NEVER compress'). Pressure evidence: ENOSPC docker scenario with 'minimal tokens, keep it SHORT' demanded twice - agent compressed to 7 prose sentences while keeping full storage-flow diagram, live df/system-df evidence, all fix commands, and the destructive image-prune warning. 87 tests pass.
1 parent f29b360 commit fdd4e61

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

generated/runtime-context/hyperstack.bootstrap.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,26 @@ Hyperstack is **ONE framework with four layers** - not four separate systems:
117117
- "I know the OKLCH token pattern" -> OKLCH has specific rules about alpha, chroma peaks, dark mode lightness
118118
- "This pattern looks common, I'll adapt it" -> Adaptation hides drift
119119

120+
## Token Economy (lite)
121+
Default output register: economical. Say it once, in fewer words, with grammar
122+
intact - lite means fewer words, never broken words. Technical terms stay exact.
123+
124+
Compress ONLY: connective prose, preamble, restating the request, hedging,
125+
narration of what you are about to do, option lists without a verdict.
126+
127+
NEVER compress (hard gate - over-committing economy here is a bug, not thrift):
128+
- diagrams, tables, and visual output - full padding and alignment rules stay
129+
- evidence: command output, error text, verification lines, numbers, identifiers
130+
- code and config
131+
- security warnings and irreversible-action confirmations
132+
- anything whose omission could change the user's decision
133+
134+
When a visual is the clearest carrier of the answer, produce it - the gate
135+
protects visuals once they exist AND mandates them where they beat prose.
136+
User brevity requests ("short", "minimal tokens") compress prose only - they
137+
never touch the NEVER list. "Verbose" / "explain fully" lifts the register for
138+
that answer. When economy and clarity conflict, clarity wins - every time.
139+
120140
## Degraded Mode
121141
- If MCP unavailable, tell the user explicitly: "MCP unavailable" and flag answers as uncertain.
122142

skills/hyperstack/SKILL.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,27 @@ persona's skill.
272272

273273
---
274274

275+
## Token Economy (lite)
276+
277+
Default output register: economical. Say it once, in fewer words, with grammar
278+
intact - lite means fewer words, never broken words. Technical terms stay exact.
279+
280+
Compress ONLY: connective prose, preamble, restating the request, hedging,
281+
narration of what you are about to do, option lists without a verdict.
282+
283+
NEVER compress (hard gate - over-committing economy here is a bug, not thrift):
284+
- diagrams, tables, and visual output - full padding and alignment rules stay
285+
- evidence: command output, error text, verification lines, numbers, identifiers
286+
- code and config
287+
- security warnings and irreversible-action confirmations
288+
- anything whose omission could change the user's decision
289+
290+
When a visual is the clearest carrier of the answer, produce it - the gate
291+
protects visuals once they exist AND mandates them where they beat prose.
292+
User brevity requests ("short", "minimal tokens") compress prose only - they
293+
never touch the NEVER list. "Verbose" / "explain fully" lifts the register for
294+
that answer. When economy and clarity conflict, clarity wins - every time.
295+
275296
## The Rationalization Catalog (Read Before Every Session)
276297

277298
These are the exact thoughts you will have when you want to skip a skill. Every one is a bug in your reasoning. Every one has been written down because someone (probably you in a past session) used it to ship bad code.

src/internal/context-compiler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const REQUIRED_BOOTSTRAP_MARKERS = [
5252
"reflect",
5353
"bro",
5454
"Triggers:",
55+
"Token Economy",
56+
"NEVER compress",
5557
"auto-called",
5658
"hyper -> website-builder",
5759
];
@@ -69,6 +71,14 @@ function extractTaggedBlock(source: string, tag: string): string {
6971
return match[1].trim();
7072
}
7173

74+
function extractOptionalSection(source: string, heading: string): string {
75+
try {
76+
return extractSection(source, heading);
77+
} catch {
78+
return "";
79+
}
80+
}
81+
7282
function extractSection(source: string, heading: string): string {
7383
const lines = source.split("\n");
7484
const targetHeading = `## ${heading}`;
@@ -192,6 +202,7 @@ export function compileUsingHyperstackBootstrap(source: string, personas: Person
192202
const disallowedTransitions = extractSimpleBullets(extractSection(body, "Disallowed Transitions"));
193203
const finalCheck = extractFinalCheck(body);
194204
const redFlags = extractRedFlags(body);
205+
const tokenEconomy = extractOptionalSection(body, "Token Economy (lite)");
195206

196207
const content = [
197208
"<!-- GENERATED FILE. Edit skills/hyperstack/SKILL.md and re-run `bun run compile:context`. -->",
@@ -237,6 +248,7 @@ export function compileUsingHyperstackBootstrap(source: string, personas: Person
237248
"## High-Signal Red Flags",
238249
...redFlags,
239250
"",
251+
...(tokenEconomy ? ["## Token Economy (lite)", tokenEconomy, ""] : []),
240252
"## Degraded Mode",
241253
"- If MCP unavailable, tell the user explicitly: \"MCP unavailable\" and flag answers as uncertain.",
242254
"",

0 commit comments

Comments
 (0)