Add Pi event guards for workflow state

This commit is contained in:
Advait Paliwal
2026-04-17 11:13:57 -07:00
parent f0bbb25910
commit 92914acff7
12 changed files with 356 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { getExtensionCommandSpec } from "../../metadata/commands.mjs";
import { buildProjectAgentsTemplate, buildSessionLogsReadme } from "./project-scaffold.js";
import { collectManagedGc } from "./state.js";
async function pathExists(path: string): Promise<boolean> {
try {
@@ -104,7 +105,15 @@ export function registerInitCommand(pi: ExtensionAPI): void {
export function registerOutputsCommand(pi: ExtensionAPI): void {
pi.registerCommand("outputs", {
description: "Browse all research artifacts (papers, outputs, experiments, notes).",
handler: async (_args, ctx) => {
handler: async (args, ctx) => {
const trimmedArgs = args.trim();
if (trimmedArgs === "gc" || trimmedArgs === "gc --dry-run") {
const dryRun = trimmedArgs.includes("--dry-run");
const result = collectManagedGc(ctx.cwd, Date.now(), undefined, { dryRun });
ctx.ui.notify(`${dryRun ? "Would remove" : "Removed"} ${result.deleted.length} managed cache file(s).`, "info");
return;
}
const items = await collectArtifacts(ctx.cwd);
if (items.length === 0) {
ctx.ui.notify("No artifacts found. Use /lit, /draft, /review, or /deepresearch to create some.", "info");