pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Reviews Compare Notes Search Review guide CI runs Remove tune legacy compatibility cruft
957fb4308e8b39945d4c6e0279096e84ee5d701e
Oliver Jan Krylow <oliver@bugabinga.net > · 9 Jun 2026
unsigned
Browse files Compare with HEAD
Changed files (7) Diff layout Auto Unified Split
+0 / −1 text lines
2 2 ** /node_modules/ ** /node_modules/ +0 / −1 text lines
5 5 - Rename `autoresearch` extension to `tune` and slash command to `/tune`- Rename `autoresearch` extension to `tune` and slash command to `/tune`6 6 - Move tune session state to `.pi/tune/`- Move tune session state to `.pi/tune/`7 7 - Restyle tune dashboard with the Nugu diff-review palette, theme selector, cards, side drawer, chart, and live session.jsonl refresh- Restyle tune dashboard with the Nugu diff-review palette, theme selector, cards, side drawer, chart, and live session.jsonl refresh8 - - Keep legacy `.pi/autoresearch/` state and `autoresearch.json` shortcuts readable
extensions/tune/CHANGELOG.md Modified +2 / −2 text lines
5 5 Fork of [pi-autoresearch](https://github.com/davebcn87/pi-autoresearch) with breaking changes:Fork of [pi-autoresearch](https://github.com/davebcn87/pi-autoresearch) with breaking changes:7 7 - Extension slug/package renamed to `tune` / `@bugabinga/pi-ext-tune`- Extension slug/package renamed to `tune` / `@bugabinga/pi-ext-tune`8 - - State dir moved to `.pi/tune/`; legacy `.pi/autoresearch/` is copied once8 + - State dir moved to `.pi/tune/`9 9 - Scripts renamed: `benchmark.mjs` (was `autoresearch.sh`), `checks.mjs` (was `autoresearch.checks.sh`)- Scripts renamed: `benchmark.mjs` (was `autoresearch.sh`), `checks.mjs` (was `autoresearch.checks.sh`)10 10 - Hooks are Node.js only (`.mjs`), no bash dependency- Hooks are Node.js only (`.mjs`), no bash dependency11 - - Command renamed to `/tune`; legacy `autoresearch.json` shortcuts still load11 + - Command renamed to `/tune`; shortcuts config moved to `tune.json`12 12 - `workingDir` config option removed (state always in `.pi/tune/`)- `workingDir` config option removed (state always in `.pi/tune/`)13 13 - Session files live under `.pi/tune/`: `session.jsonl`, `session.md`, `ideas.md`- Session files live under `.pi/tune/`: `session.jsonl`, `session.md`, `ideas.md`14 14 - Adapted to `@earendil-works/pi-coding-agent` and `typebox` packages- Adapted to `@earendil-works/pi-coding-agent` and `typebox` packagesextensions/tune/README.md Modified +0 / −2 text lines
23 23 Keyboard shortcuts configurable in `<agent-dir>/extensions/tune.json`.Keyboard shortcuts configurable in `<agent-dir>/extensions/tune.json`.24 - If missing, legacy `<agent-dir>/extensions/autoresearch.json` is still read.
36 35 All state lives in `.pi/tune/`.All state lives in `.pi/tune/`.37 - If `.pi/tune/` is missing and legacy `.pi/autoresearch/` exists, tune copies the legacy state once on session load/init; it does not delete the old directory.
39 37 | File | Purpose || File | Purpose |extensions/tune/__tests__/remaining.test.ts Modified +4 / −43 text lines
1 - import { afterEach , beforeAll, describe, expect, it } from "bun:test" ;1 + import { beforeAll, describe, expect, it } from "bun:test" ;2 2 import * as fs from "node:fs" ;import * as fs from "node:fs" ;3 3 import * as path from "node:path" ;import * as path from "node:path" ;11 11 import { __test } from "../index.ts" ;import { __test } from "../index.ts" ;13 13 const TESTDIR = "/tmp/pi-ext-20260530-164209-project" ;const TESTDIR = "/tmp/pi-ext-20260530-164209-project" ;14 - const MIGRATION_TESTDIR = "/tmp/pi-ext-tune-migration" ;
15 14 const TEST_JSONL = [const TEST_JSONL = [16 15 '{"type":"config","name":"Optimize sqrt/sin loop","metricName":"total_ms","metricUnit":"ms","bestDirection":"lower"}' , '{"type":"config","name":"Optimize sqrt/sin loop","metricName":"total_ms","metricUnit":"ms","bestDirection":"lower"}' ,17 16 '{"run":1,"commit":"92d4b83","metric":7,"metrics":{},"status":"keep","description":"Baseline: unoptimized sqrt/sin loop","timestamp":1780152220658,"segment":0,"confidence":null,"asi":{"hypothesis":"Baseline measurement"}}' , '{"run":1,"commit":"92d4b83","metric":7,"metrics":{},"status":"keep","description":"Baseline: unoptimized sqrt/sin loop","timestamp":1780152220658,"segment":0,"confidence":null,"asi":{"hypothesis":"Baseline measurement"}}' ,27 26 fs.writeFileSync (path.join (tuneDir, "session.jsonl" ), TEST_JSONL); fs.writeFileSync (path.join (tuneDir, "session.jsonl" ), TEST_JSONL);31 - fs.rmSync (MIGRATION_TESTDIR, { recursive: true , force: true });
36 31 describe ("compaction resume" , () => {describe ("compaction resume" , () => {109 - describe ("state migration" , () => {110 - it ("copies legacy .pi/autoresearch state into .pi/tune once" , () => {111 - const legacyDir = path.join (MIGRATION_TESTDIR, ".pi" , "autoresearch" );112 - const tuneDir = path.join (MIGRATION_TESTDIR, ".pi" , "tune" );113 - fs.mkdirSync (legacyDir, { recursive: true });114 - fs.writeFileSync (path.join (legacyDir, "session.jsonl" ), TEST_JSONL);115 - fs.writeFileSync (path.join (legacyDir, "ideas.md" ), "- keep this\n" );117 - expect (__test.migrateLegacyTuneState (MIGRATION_TESTDIR)).toBe (true );118 - expect (fs.readFileSync (path.join (tuneDir, "session.jsonl" ), "utf-8" )).toBe (121 - expect (fs.readFileSync (path.join (tuneDir, "ideas.md" ), "utf-8" )).toBe (124 - expect (fs.existsSync (path.join (legacyDir, "session.jsonl" ))).toBe (true );125 - expect (__test.migrateLegacyTuneState (MIGRATION_TESTDIR)).toBe (false );131 104 describe ("shortcuts" , () => {describe ("shortcuts" , () => {132 105 it ("returns defaults when no config file" , () => { it ("returns defaults when no config file" , () => {134 107 expect (s.toggleDashboard).toBe ("ctrl+shift+t" ); expect (s.toggleDashboard).toBe ("ctrl+shift+t" );135 108 expect (s.fullscreenDashboard).toBe ("ctrl+shift+f" ); expect (s.fullscreenDashboard).toBe ("ctrl+shift+f" );138 - it ("falls back to legacy autoresearch.json" , () => {139 - const configDir = path.join (MIGRATION_TESTDIR, "extensions" );140 - fs.mkdirSync (configDir, { recursive: true });142 - path.join (configDir, "autoresearch.json" ),143 - JSON .stringify ({ shortcuts: { toggleDashboard: "ctrl+x" } }),145 - expect (resolveTuneShortcuts (path.join (configDir, "tune.json" )).toggleDashboard).toBe (
153 114 describe ("hook paths" , () => {describe ("hook paths" , () => {154 115 it ("resolves to .pi/tune/hooks/{stage}.mjs" , () => { it ("resolves to .pi/tune/hooks/{stage}.mjs" , () => {166 127 describe ("export dashboard" , () => {describe ("export dashboard" , () => {167 128 it ("ships a dashboard template next to the tune extension" , () => { it ("ships a dashboard template next to the tune extension" , () => {extensions/tune/index.ts Modified +3 / −24 text lines
58 58 const EXPERIMENT_MAX_BYTES = 4 * 1024 ;const EXPERIMENT_MAX_BYTES = 4 * 1024 ;60 60 const STATE_DIR = ".pi/tune" ;const STATE_DIR = ".pi/tune" ;61 - const LEGACY_STATE_DIR = ".pi/autoresearch" ;
63 61 const TUNE_SUBCOMMAND_COMPLETIONS: AutocompleteItem [] = [const TUNE_SUBCOMMAND_COMPLETIONS: AutocompleteItem [] = [64 62 { value: "off" , label: "off" , description: "Turn tune mode off" }, { value: "off" , label: "off" , description: "Turn tune mode off" },65 63 { value: "clear" , label: "clear" , description: "Delete session.jsonl and stop" }, { value: "clear" , label: "clear" , description: "Delete session.jsonl and stop" },345 343 const stateDir = (dir: string ) => path.join (dir, STATE_DIR);const stateDir = (dir: string ) => path.join (dir, STATE_DIR);346 - const legacyStateDir = (dir: string ) => path.join (dir, LEGACY_STATE_DIR);
347 344 const tuneJsonlPath = (dir: string ) => path.join (stateDir (dir), "session.jsonl" );const tuneJsonlPath = (dir: string ) => path.join (stateDir (dir), "session.jsonl" );348 345 const tuneMdPath = (dir: string ) => path.join (stateDir (dir), "session.md" );const tuneMdPath = (dir: string ) => path.join (stateDir (dir), "session.md" );349 346 const tuneIdeasPath = (dir: string ) => path.join (stateDir (dir), "ideas.md" );const tuneIdeasPath = (dir: string ) => path.join (stateDir (dir), "ideas.md" );351 348 const tuneScriptPath = (dir: string ) => path.join (stateDir (dir), "benchmark.mjs" );const tuneScriptPath = (dir: string ) => path.join (stateDir (dir), "benchmark.mjs" );352 349 const tuneConfigPath = (dir: string ) => path.join (stateDir (dir), "config.json" );const tuneConfigPath = (dir: string ) => path.join (stateDir (dir), "config.json" );354 - function migrateLegacyTuneState (cwd: string ): boolean {355 - const current = stateDir (cwd);356 - const legacy = legacyStateDir (cwd);358 - if (fs.existsSync (current) || ! fs.existsSync (legacy)) return false ;359 - fs.cpSync (legacy, current, { recursive: true });
366 351 function findBaselineMetric (results: ExperimentResult [], segment: number ): number | null {function findBaselineMetric (results: ExperimentResult [], segment: number ): number | null {367 352 const cur = currentResults (results, segment); const cur = currentResults (results, segment);368 353 return cur.length > 0 ? cur[0 ].metric : null ; return cur.length > 0 ? cur[0 ].metric : null ;881 866 dashboardTemplatePath, dashboardTemplatePath,882 867 tuneArgumentCompletions, tuneArgumentCompletions,883 868 tuneCommandArgumentSuggestions, tuneCommandArgumentSuggestions,884 - migrateLegacyTuneState,
1122 1106 runtime.autoResumeTurns = 0 ; runtime.autoResumeTurns = 0 ;1123 1107 runtime.state = createExperimentState (); runtime.state = createExperimentState ();1125 - migrateLegacyTuneState (ctx.cwd);
1126 1109 const state = runtime.state; const state = runtime.state;1127 1110 const jsonlPath = tuneJsonlPath (ctx.cwd); const jsonlPath = tuneJsonlPath (ctx.cwd);1128 1111 let loadedFromJsonl = false ; let loadedFromJsonl = false ;1493 1476 state.bestMetric = null ; state.bestMetric = null ;1494 1477 state.secondaryMetrics = []; state.secondaryMetrics = [];1495 1478 state.confidence = null ; state.confidence = null ;1496 - migrateLegacyTuneState (ctx.cwd);1497 - state.maxExperiments = readMaxExperiments (ctx.cwd);1479 + state.maxExperiments = readMaxExperiments (ctx.cwd);1500 1482 const dir = stateDir (ctx.cwd); const dir = stateDir (ctx.cwd);2643 2625 async function exportDashboard (ctx: ExtensionContext ): Promise <void > { async function exportDashboard (ctx: ExtensionContext ): Promise <void > {2644 - migrateLegacyTuneState (ctx.cwd);
2645 2626 const jsonlPath = tuneJsonlPath (ctx.cwd); const jsonlPath = tuneJsonlPath (ctx.cwd);2646 2627 if (! fs.existsSync (jsonlPath)) { if (! fs.existsSync (jsonlPath)) {2647 2628 ctx.ui.notify ("No session.jsonl found — run some experiments first" , "error" ); ctx.ui.notify ("No session.jsonl found — run some experiments first" , "error" );2772 2753 if (command === "clear" ) { if (command === "clear" ) {2773 - migrateLegacyTuneState (ctx.cwd);2774 - const jsonlPath = tuneJsonlPath (ctx.cwd);2754 + const jsonlPath = tuneJsonlPath (ctx.cwd);2775 2755 runtime.tuneMode = false ; runtime.tuneMode = false ;2776 2756 runtime.dashboardExpanded = false ; runtime.dashboardExpanded = false ;2777 2757 runtime.autoResumeTurns = 0 ; runtime.autoResumeTurns = 0 ;2808 2788 runtime.tuneMode = true ; runtime.tuneMode = true ;2809 2789 runtime.autoResumeTurns = 0 ; runtime.autoResumeTurns = 0 ;2810 - migrateLegacyTuneState (ctx.cwd);2812 2791 const rulesLoaded = hasTuneRules (ctx); const rulesLoaded = hasTuneRules (ctx);2813 2792 const kickoff = rulesLoaded const kickoff = rulesLoaded2814 2793 ? `Tune active. ${trimmedArgs} ${BENCHMARK_GUARDRAIL}` ? `Tune active. ${trimmedArgs} ${BENCHMARK_GUARDRAIL}` extensions/tune/shortcuts.ts Modified +2 / −8 text lines
2 2 * Keyboard shortcut configuration for tune dashboard. * Keyboard shortcut configuration for tune dashboard.4 4 * Config file : <agent -dir >/ extensions/ tune.json * Config file : <agent -dir >/ extensions/ tune.json5 - * Fallback : <agent -dir >/ extensions/ autoresearch.json
6 5 * Keys : shortcuts.toggleDashboard, shortcuts.fullscreenDashboard * Keys : shortcuts.toggleDashboard, shortcuts.fullscreenDashboard9 8 import { existsSync, readFileSync } from "node:fs" ;import { existsSync, readFileSync } from "node:fs" ;10 - import { dirname , join } from "node:path" ;9 + import { join } from "node:path" ;11 10 import { getAgentDir } from "@earendil-works/pi-coding-agent" ;import { getAgentDir } from "@earendil-works/pi-coding-agent" ;16 15 export const DEFAULT_FULLSCREEN_DASHBOARD_SHORTCUT = "ctrl+shift+f" ;export const DEFAULT_FULLSCREEN_DASHBOARD_SHORTCUT = "ctrl+shift+f" ;18 17 const CONFIG_FILE_NAME = "tune.json" ;const CONFIG_FILE_NAME = "tune.json" ;19 - const LEGACY_CONFIG_FILE_NAME = "autoresearch.json" ;
78 76 export function resolveTuneShortcuts (export function resolveTuneShortcuts (79 77 configPath: string = tuneShortcutsConfigPath (), configPath: string = tuneShortcutsConfigPath (),80 78 ): TuneShortcuts {): TuneShortcuts {81 - if (! existsSync (configPath)) {82 - const legacyPath = join (dirname (configPath), LEGACY_CONFIG_FILE_NAME);83 - if (! existsSync (legacyPath )) return defaultTuneShortcuts ();84 - configPath = legacyPath;79 + if (! existsSync (configPath )) return defaultTuneShortcuts ();87 81 let parsed: unknown ; let parsed: unknown ;