From 8586b26ba80df21b840c818f152b81072c2d1839 Mon Sep 17 00:00:00 2001 From: wassname <1103714+wassname@users.noreply.github.com> Date: Fri, 3 Jul 2026 11:12:36 +0800 Subject: [PATCH] rename stale .pi/goals.md to plan.md on session start so v1 goals aren't silently invisible Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com> --- src/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 89b6fb2..d35f61f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,7 +27,7 @@ */ import { spawn } from "node:child_process"; -import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs"; import { basename, join, resolve } from "node:path"; import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import { Type } from "@sinclair/typebox"; @@ -194,6 +194,13 @@ export default function piGoalsExtension(pi: ExtensionAPI): void { }); pi.on("session_start", async (_event, ctx) => { + // v1 wrote .pi/goals.md; v2 reads .pi/plan.md. Rename so old goals aren't silently invisible + // (dogfood finding). Claude: one-time migration, delete once v1 files are gone from the wild. + const v1Path = join(ctx.cwd, ".pi", "goals.md"); + if (existsSync(v1Path) && !existsSync(planPath(ctx))) { + renameSync(v1Path, planPath(ctx)); + ctx.ui.notify(`Renamed .pi/goals.md -> ${PLAN_REL} (v2 filename).`, "info"); + } const last = ctx.sessionManager .getEntries() .filter((e: { type?: string; customType?: string }) => e.type === "custom" && e.customType === STATE)