@xynogen/pix-commands 0.1.6 → 0.1.8
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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/clear.ts +3 -12
- package/src/once.ts +2 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Pi extension — slash commands. `/clear`; more commands are planned.
|
|
|
4
4
|
|
|
5
5
|
## What it does
|
|
6
6
|
|
|
7
|
-
Registers slash commands. Currently `/clear`, which deletes `~/.cache/pi` — useful for flushing stale model-data
|
|
7
|
+
Registers slash commands. Currently `/clear`, which deletes `~/.cache/pi` — useful for flushing stale model-data cache — and prompts you to run `/reload` to apply the change. **More commands are on the way.** No extra dependencies beyond Pi.
|
|
8
8
|
|
|
9
9
|
> Diff review moved to the `diff` skill in [`@xynogen/pix-skills`](https://github.com/xynogen/pix-mono/tree/main/packages/pix-skills), which pre-populates `git status` + staged/unstaged diffs via the `` !`cmd` `` directive.
|
|
10
10
|
|
package/package.json
CHANGED
package/src/clear.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ExtensionAPI,
|
|
3
|
-
ExtensionCommandContext,
|
|
4
|
-
} from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
5
2
|
|
|
6
3
|
async function clearCache(pi: ExtensionAPI, ctx: ExtensionCommandContext) {
|
|
7
4
|
ctx.ui.notify("Clearing ~/.cache/pi", "info");
|
|
8
5
|
const result = await pi.exec("/bin/sh", ["-lc", 'rm -rf "$HOME/.cache/pi"'], {
|
|
9
6
|
timeout: 10_000,
|
|
10
7
|
});
|
|
11
|
-
const output = [result.stdout, result.stderr]
|
|
12
|
-
.filter(Boolean)
|
|
13
|
-
.join("\n")
|
|
14
|
-
.trim();
|
|
8
|
+
const output = [result.stdout, result.stderr].filter(Boolean).join("\n").trim();
|
|
15
9
|
if ((result.code ?? 0) !== 0) {
|
|
16
10
|
ctx.ui.notify(`Cache clear failed. ${output || "No output."}`, "error");
|
|
17
11
|
return;
|
|
18
12
|
}
|
|
19
|
-
ctx.ui.notify(
|
|
20
|
-
"~/.cache/pi cleared. Run /reload to apply changes.",
|
|
21
|
-
"warning",
|
|
22
|
-
);
|
|
13
|
+
ctx.ui.notify("~/.cache/pi cleared. Run /reload to apply changes.", "warning");
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
export default function (pi: ExtensionAPI) {
|
package/src/once.ts
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export function once(pi: object, key: string, fn: () => void): void {
|
|
16
16
|
const g = globalThis as { __pixOnce?: WeakMap<object, Set<string>> };
|
|
17
|
-
|
|
17
|
+
if (!g.__pixOnce) g.__pixOnce = new WeakMap<object, Set<string>>();
|
|
18
|
+
const registry = g.__pixOnce;
|
|
18
19
|
let loaded = registry.get(pi);
|
|
19
20
|
if (!loaded) {
|
|
20
21
|
loaded = new Set<string>();
|