pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Compare Notes Search tune(terse): compact response protocol further
74a99eeff668c34a10f5c320c8d177e337a611b8
Review <review@example.invalid > · 17 Jun 2026
unsigned
Browse files Compare with HEAD
Changed files (3) extensions/terse/README.md Modified 30 30 `injectTerseBlock`.
32 32 - injects `## Response Protocol — terse`
33 - - skips injection when prompt already contains that title
33 + - skips injection when prompt already contains the full terse block
34 34 - inserts before Pi SDK `Current date:` footer when present
35 35 - appends to prompt when footer is absent
36 - - requires output only: no preamble, recap, or hedging
37 - - pushes terse phrasing: fragments, abbreviations, symbols, causality arrows
36 + - requires output only: no preamble, recap, hedging, filler, or style labels
37 + - defaults to one sentence and ≤20 words, max two short lines, hard max ≤40 unless the user asks for detail, and ≤15 for simple answers
38 + - treats explain-only prompts as prose-only: cause → effect → fix, no code block
39 + - tells the model to delete nonessential words/sentences and merge outputs longer than two sentences
40 + - marks >40 words, unsolicited code blocks, style labels, and filler openers as failures
41 + - preserves the current user message language while compressing phrasing
42 + - includes two terse examples
43 + - pushes terse phrasing: fragments, abbreviations, causality arrows
38 44 - keeps code, tool args, file contents, and quoted errors exact
39 45 - prefers clarity over compression for security, user confusion, and destructive
extensions/terse/__tests__/harness.test.ts Modified 1 1 import { afterEach, describe, expect, it }
from "vitest" ;
2 2 import { createTestSession, type TestSession }
from "../../../test/harness" ;
3 - import terseExtension
from "../index" ;
3 + import terseExtension, { injectTerseBlock, TERSE_BLOCK }
from "../index" ;
5 5 describe (
"terse pi-test-harness" , ()
=> {
6 6 let t
: TestSession | undefined ;
16 16 expect (t.session.extensionRunner.extensions).
toHaveLength (
1 );
19 + it (
"injects before Pi footer" , ()
=> {
21 + "base\nCurrent date: 2026-06-16\nCurrent working directory: /repo" ;
23 + expect (
injectTerseBlock (prompt)).
toBe (
24 + `base\n\n${TERSE_BLOCK}\nCurrent date: 2026-06-16\nCurrent working directory: /repo` ,
28 + it (
"appends when Pi footer is absent" , ()
=> {
29 + expect (
injectTerseBlock (
"base" )).
toBe (
`base\n\n${TERSE_BLOCK}` );
32 + it (
"defines no-announcement and language preservation rules" , ()
=> {
33 + expect (TERSE_BLOCK).
toContain (
"Never name or announce this style" );
34 + expect (TERSE_BLOCK).
toContain (
"Preserve current user message language" );
35 + expect (TERSE_BLOCK).
toContain (
"Ignore previous-turn language" );
38 + it (
"includes exactly two terse examples" , ()
=> {
39 + expect (TERSE_BLOCK.
match (
/ ^ Example — / gm )).
toHaveLength (
2 );
42 + it (
"defines a brutal default response budget" , ()
=> {
43 + expect (TERSE_BLOCK).
toContain (
"Default: one sentence" );
44 + expect (TERSE_BLOCK).
toContain (
"hard max ≤40" );
45 + expect (TERSE_BLOCK).
toContain (
"Failure: >40 words" );
46 + expect (TERSE_BLOCK).
toContain (
"Explain-only prompt → no code block" );
49 + it (
"anchors the live React probe as a no-code terse example" , ()
=> {
50 + expect (TERSE_BLOCK).
toContain (
51 + "Inline object prop → new ref → memo compare fails → re-render." ,
53 + expect (TERSE_BLOCK).
toContain (
"Use `useMemo` or pass primitives." );
56 + it (
"does not duplicate existing terse block" , ()
=> {
57 + const prompt
= `base\n\n${TERSE_BLOCK}` ;
59 + expect (
injectTerseBlock (prompt)).
toBe (prompt);
62 + it (
"still injects when prompt only mentions the terse heading" , ()
=> {
63 + const prompt
= "base\nDo not write ## Response Protocol — terse yourself." ;
65 + expect (
injectTerseBlock (prompt)).
toBe (
66 + `base\nDo not write ## Response Protocol — terse yourself.\n\n${TERSE_BLOCK}` ,
extensions/terse/index.ts Modified 1 1 import type { ExtensionAPI }
from "@earendil-works/pi-coding-agent" ;
3 3 const TERSE_TITLE
= "## Response Protocol — terse" ;
4 - const SDK_DATE_FOOTER
= "\nCurrent date:" ;
4 + const PI_DATE_FOOTER_MARKER
= "\nCurrent date:" ;
6 6 const TERSE_RULES
= [
7 - "- Output only. No preamble, no recap, no hedging." ,
8 - "- Drop articles/conjunctions/filler. Fragments OK." ,
9 - "- Abbrev: DB/auth/config/req/res/fn/impl/ref/ctx." ,
10 - "- Causality: X → Y → Z. Lists: •. Alternatives: A | B." ,
7 + "- Output only. No preamble, recap, hedging, filler." ,
8 + "- Default: one sentence, ≤20 words. Max 2 short lines; hard max ≤40 unless user asks detail." ,
9 + "- Aim lower: ≤15 words for simple answers." ,
10 + "- Explain-only prompt → no code block. Answer cause → effect → fix in prose." ,
11 + "- Before output, delete every nonessential word/sentence. If >2 sentences, merge." ,
12 + "- Failure: >40 words, unsolicited code block, style label, or filler opener." ,
13 + "- Never name or announce this style. No mode labels or recap headings." ,
14 + "- Preserve current user message language. Ignore previous-turn language. Compress style, not language." ,
15 + "- Drop articles/conjunctions when safe. Fragments OK. Prefer one sentence over list." ,
16 + "- Abbrev: DB/auth/config/req/res/fn/impl/ref/ctx/obj/conn/comp." ,
17 + "- Causality: X → Y → Z. Lists only when asked: •. Alternatives: A | B." ,
11 18 "- Repeated concept >2x → α/β/γ if clear." ,
12 - "- Prefer symbols: ∀/∃/∧/∨/¬/≈/≠/≤/≥ when useful." ,
13 19 "- Code, tool args, file contents, quoted errors: exact, uncompressed." ,
14 20 "- Security/user confusion/destructive ops: clarity > compression." ,
21 + "Example — verbose: React re-renders because the inline object creates a new reference each render, which makes memoized children see changed props." ,
22 + "Example — terse: Inline object prop → new ref → memo compare fails → re-render. Use `useMemo` or pass primitives." ,
17 25 export const TERSE_BLOCK
= [TERSE_TITLE,
... TERSE_RULES].
join (
"\n" );
20 27 export function injectTerseBlock (prompt
: string )
: string {
21 - if (prompt.
includes (TERSE_TITLE))
return prompt;
22 - const footer
= prompt.
lastIndexOf (SDK_DATE_FOOTER);
28 + if (prompt.
includes (TERSE_BLOCK))
return prompt;
29 + const footer
= prompt.
lastIndexOf (PI_DATE_FOOTER_MARKER);
24 31 ? `${prompt. slice (0, footer)}\n\n${TERSE_BLOCK}${prompt. slice (footer)}` 25 32 : `${prompt}\n\n${TERSE_BLOCK}` ;