refactor(coding-agent): replace AgentSessionRuntimeHost with closure-based AgentSessionRuntime
- Replace AgentSessionRuntimeHost and bootstrap abstractions with AgentSessionRuntime - Runtime creation is now closure-based via CreateAgentSessionRuntimeFactory - Factory closes over process-global fixed inputs, recreates cwd-bound services per effective cwd - Session config (model, thinking, tools, scoped models) re-resolved per target cwd - CLI resource paths resolved once at startup as absolute paths - Swap lifecycle: teardown old, create next, apply next (hard fail on creation error) - Unified diagnostics model (info/warning/error) for args, services, session resolution, resources - No logging or process exits inside creation/parsing logic - Removed session_directory support - Removed session_switch and session_fork extension events (use session_start with reason) - Moved package/config CLI to package-manager-cli.ts - Fixed theme init for --resume session picker - Fixed flaky reftable footer test (content-based polling) - Fixed silent drop of unknown single-dash CLI flags - Added error diagnostics for missing explicit CLI resource paths - Updated SDK docs, examples, plans, exports, tests, changelog fixes #2753
This commit is contained in:
@@ -6,6 +6,7 @@ import chalk from "chalk";
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
||||
import { dirname, join } from "path";
|
||||
import { CONFIG_DIR_NAME, getAgentDir, getBinDir } from "./config.js";
|
||||
import { migrateKeybindingsConfig } from "./core/keybindings.js";
|
||||
|
||||
const MIGRATION_GUIDE_URL =
|
||||
"https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/CHANGELOG.md#extensions-migration";
|
||||
@@ -152,6 +153,23 @@ function migrateCommandsToPrompts(baseDir: string, label: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
function migrateKeybindingsConfigFile(): void {
|
||||
const configPath = join(getAgentDir(), "keybindings.json");
|
||||
if (!existsSync(configPath)) return;
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(readFileSync(configPath, "utf-8")) as unknown;
|
||||
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
||||
return;
|
||||
}
|
||||
const { config, migrated } = migrateKeybindingsConfig(parsed as Record<string, unknown>);
|
||||
if (!migrated) return;
|
||||
writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
||||
} catch {
|
||||
// Ignore malformed files during migration
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move fd/rg binaries from tools/ to bin/ if they exist.
|
||||
*/
|
||||
@@ -290,6 +308,7 @@ export function runMigrations(cwd: string = process.cwd()): {
|
||||
const migratedAuthProviders = migrateAuthToAuthJson();
|
||||
migrateSessionsFromAgentRoot();
|
||||
migrateToolsToBin();
|
||||
migrateKeybindingsConfigFile();
|
||||
const deprecationWarnings = migrateExtensionSystem(cwd);
|
||||
return { migratedAuthProviders, deprecationWarnings };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user