chore: initialize POM 2 repo (docs guards green; release gates recorded NOT RUN pending install)
This commit is contained in:
50
src/index.ts
Normal file
50
src/index.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
|
||||
import { join } from "node:path";
|
||||
import { createState, restoreLatest } from "./state";
|
||||
import { loadPomConfig } from "./config";
|
||||
import { DEFAULT_CONFIG, type PomConfig, type PomState } from "./domain";
|
||||
import { loadState, pathExists, saveState, syncKnowledgeBase } from "./persistence";
|
||||
import { registerPomCommand } from "./command";
|
||||
import { registerPomEvents } from "./events";
|
||||
import { registerPomTools } from "./tools";
|
||||
import { registerPomRenderers } from "./renderers";
|
||||
import type { PomRuntime } from "./runtime";
|
||||
|
||||
export default function pomExtension(pi: ExtensionAPI): void {
|
||||
pi.setLabel("POM · Produce Magnum Opus");
|
||||
let config: PomConfig = DEFAULT_CONFIG;
|
||||
let state: PomState = createState("Untitled Magnum Opus", process.cwd(), config);
|
||||
const runtime: PomRuntime = {
|
||||
telemetry: { activeAgents: 0, completedAgents: 0 },
|
||||
get: () => state,
|
||||
getConfig: () => config,
|
||||
refreshConfig: async (cwd) => {
|
||||
config = await loadPomConfig(cwd);
|
||||
return config;
|
||||
},
|
||||
set: async (next) => {
|
||||
state = { ...structuredClone(next), updatedAt: new Date().toISOString() };
|
||||
if (state.initialized) {
|
||||
pi.appendEntry("pom-state", state);
|
||||
await saveState(state);
|
||||
await syncKnowledgeBase(state);
|
||||
}
|
||||
},
|
||||
restore: async (ctx: ExtensionContext) => {
|
||||
const sessionState = restoreLatest(ctx.sessionManager.getBranch());
|
||||
if (sessionState) state = sessionState;
|
||||
else {
|
||||
const direct = join(ctx.cwd, "00_admin", "project_state.json");
|
||||
if (await pathExists(direct)) state = await loadState(direct);
|
||||
else state = createState("Untitled Magnum Opus", ctx.cwd, await loadPomConfig(ctx.cwd));
|
||||
}
|
||||
config = await loadPomConfig(state.initialized ? state.projectRoot : ctx.cwd);
|
||||
return state;
|
||||
},
|
||||
};
|
||||
|
||||
registerPomTools(pi, runtime);
|
||||
registerPomRenderers(pi, runtime);
|
||||
registerPomEvents(pi, runtime);
|
||||
registerPomCommand(pi, runtime);
|
||||
}
|
||||
Reference in New Issue
Block a user