Commit 611be1bedbdb
Changed files (2)
dots
config
gh-news
pi
agent
extensions
git
dots/config/gh-news/config.toml
@@ -66,5 +66,5 @@ show_output = true
[[actions]]
name = "Review with Pi"
-command = "cd $(repo-find {full_name}) && pi -m '/review {url}'"
+command = "cd $(repo-find {full_name}) && pir '/review {url}'"
interactive = true
dots/pi/agent/extensions/git/index.ts
@@ -524,86 +524,4 @@ export default function (pi: ExtensionAPI) {
}
},
});
-
- // =========================================================================
- // Worktree Context: Auto-inject note on session start
- // =========================================================================
-
- let worktreeContext: {
- name: string;
- branch: string;
- note: string;
- isMain: boolean;
- } | null = null;
- let contextInjected = false;
-
- pi.on("session_start", async (_event, ctx) => {
- contextInjected = false;
- worktreeContext = null;
-
- try {
- const wtCtx = getCurrentWorktreeContext(ctx.cwd);
- if (wtCtx && wtCtx.note) {
- worktreeContext = {
- name: wtCtx.name,
- branch: wtCtx.branch,
- note: wtCtx.note,
- isMain: wtCtx.isMain,
- };
- }
- } catch {
- // Silently ignore โ not critical
- }
- });
-
- pi.on("before_agent_start", async (_event, _ctx) => {
- if (contextInjected || !worktreeContext) return;
- contextInjected = true;
-
- const label = worktreeContext.isMain ? "main worktree" : "worktree";
- return {
- message: {
- customType: "worktree-context",
- content: `๐ ${label} "${worktreeContext.name}" (branch: ${worktreeContext.branch})\nNote: ${worktreeContext.note}`,
- display: true,
- },
- };
- });
-
- // =========================================================================
- // Auto-update worktree note on save_session_to_history
- // =========================================================================
-
- pi.on("tool_result", async (event, _ctx) => {
- if (event.toolName !== "save_session_to_history") return;
- if (event.isError) return;
-
- try {
- const input = event.input as { description?: string; content?: string } | undefined;
- if (!input?.description) return;
-
- const wtCtx = getCurrentWorktreeContext(_ctx.cwd);
- if (!wtCtx) return;
-
- const date = new Date().toISOString().split("T")[0];
- const sessionLine = `๐ค pi (${date}): ${input.description}`;
-
- // Read existing note, update or append the AI session line
- const existing = wtCtx.note ?? "";
- const aiLineRegex = /^๐ค pi \(\d{4}-\d{2}-\d{2}\):.*$/m;
-
- let newNote: string;
- if (aiLineRegex.test(existing)) {
- newNote = existing.replace(aiLineRegex, sessionLine);
- } else if (existing.trim()) {
- newNote = `${existing.trim()}\n${sessionLine}`;
- } else {
- newNote = sessionLine;
- }
-
- setWorktreeNote(wtCtx.name, newNote, _ctx.cwd);
- } catch {
- // Non-critical, don't break the session
- }
- });
}