@xynogen/pix-commands 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/clear.ts +9 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-commands",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Pi extension — slash commands for cache clearing and isolated side questions",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/clear.ts CHANGED
@@ -1,13 +1,15 @@
1
+ import { rm } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
1
4
  import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
5
 
3
- async function clearCache(pi: ExtensionAPI, ctx: ExtensionCommandContext) {
6
+ async function clearCache(_pi: ExtensionAPI, ctx: ExtensionCommandContext) {
4
7
  ctx.ui.notify("Clearing ~/.cache/pi", "info");
5
- const result = await pi.exec("/bin/sh", ["-lc", 'rm -rf "$HOME/.cache/pi"'], {
6
- timeout: 10_000,
7
- });
8
- const output = [result.stdout, result.stderr].filter(Boolean).join("\n").trim();
9
- if ((result.code ?? 0) !== 0) {
10
- ctx.ui.notify(`Cache clear failed. ${output || "No output."}`, "error");
8
+ try {
9
+ await rm(join(homedir(), ".cache", "pi"), { recursive: true, force: true });
10
+ } catch (err) {
11
+ const msg = err instanceof Error ? err.message : String(err);
12
+ ctx.ui.notify(`Cache clear failed. ${msg}`, "error");
11
13
  return;
12
14
  }
13
15
  ctx.ui.notify("~/.cache/pi cleared. Run /reload to apply changes.", "warning");