@xynogen/pix-commands 0.1.0
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/package.json +43 -0
- package/src/clear.ts +32 -0
- package/src/diff.ts +38 -0
- package/src/extension.ts +8 -0
- package/src/index.ts +2 -0
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xynogen/pix-commands",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pi extension — /diff and /clear commands",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "bun test"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"pi": {
|
|
16
|
+
"extensions": [
|
|
17
|
+
"src/extension.ts"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"pi",
|
|
22
|
+
"pi-package",
|
|
23
|
+
"pi-extension",
|
|
24
|
+
"pix"
|
|
25
|
+
],
|
|
26
|
+
"author": "xynogen",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/xynogen/pix-mono.git",
|
|
31
|
+
"directory": "packages/pix-commands"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/xynogen/pix-mono/tree/main/packages/pix-commands#readme",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/xynogen/pix-mono/issues"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/clear.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtensionAPI,
|
|
3
|
+
ExtensionCommandContext,
|
|
4
|
+
} from "@earendil-works/pi-coding-agent";
|
|
5
|
+
|
|
6
|
+
async function clearCache(pi: ExtensionAPI, ctx: ExtensionCommandContext) {
|
|
7
|
+
ctx.ui.notify("Clearing ~/.cache/pi", "info");
|
|
8
|
+
const result = await pi.exec("/bin/sh", ["-lc", 'rm -rf "$HOME/.cache/pi"'], {
|
|
9
|
+
timeout: 10_000,
|
|
10
|
+
});
|
|
11
|
+
const output = [result.stdout, result.stderr]
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join("\n")
|
|
14
|
+
.trim();
|
|
15
|
+
if ((result.code ?? 0) !== 0) {
|
|
16
|
+
ctx.ui.notify(`Cache clear failed. ${output || "No output."}`, "error");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
ctx.ui.notify(
|
|
20
|
+
"~/.cache/pi cleared. Run /reload to apply changes.",
|
|
21
|
+
"warning",
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function (pi: ExtensionAPI) {
|
|
26
|
+
pi.registerCommand("clear", {
|
|
27
|
+
description: "Remove ~/.cache/pi and reload",
|
|
28
|
+
handler: async (_args, ctx) => {
|
|
29
|
+
await clearCache(pi, ctx);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
package/src/diff.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /diff — summarise unstaged git diff: what changed, why, and impact.
|
|
3
|
+
*
|
|
4
|
+
* The agent runs `git status` + `git diff`, then replies with:
|
|
5
|
+
* 1. One-line TL;DR of the overall change
|
|
6
|
+
* 2. Per-file summary: what changed and why (not just counts)
|
|
7
|
+
* 3. Brief impact note (behaviour change, bug fix, refactor, etc.)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
const DIFF_PROMPT = `Run \`git status\` and \`git diff\` to inspect all unstaged changes, then respond with:
|
|
13
|
+
|
|
14
|
+
**TL;DR** — one sentence: what is the overall change.
|
|
15
|
+
|
|
16
|
+
**Per-file breakdown** — for each changed file:
|
|
17
|
+
- Filename (+lines/-lines)
|
|
18
|
+
- What changed (describe the actual code change)
|
|
19
|
+
- Why it changed (intent / reason behind the edit)
|
|
20
|
+
|
|
21
|
+
**Impact** — one sentence: what effect does this have on behaviour, tests, or users.
|
|
22
|
+
|
|
23
|
+
Rules: base everything on the actual diff content. Use \`git diff --stat\` for line counts. Skip staged-only changes. Be concise — each file entry should fit in 1-2 lines.`;
|
|
24
|
+
|
|
25
|
+
export default function (pi: ExtensionAPI) {
|
|
26
|
+
pi.registerCommand("diff", {
|
|
27
|
+
description:
|
|
28
|
+
"Summarise unstaged diff: TL;DR, per-file what/why/counts, impact",
|
|
29
|
+
handler: async (_args, ctx) => {
|
|
30
|
+
if (!ctx.isIdle()) {
|
|
31
|
+
pi.sendUserMessage(DIFF_PROMPT, { deliverAs: "followUp" });
|
|
32
|
+
ctx.ui.notify("Queued /diff after the current turn finishes.", "info");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
pi.sendUserMessage(DIFF_PROMPT);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
package/src/extension.ts
ADDED
package/src/index.ts
ADDED