@maxiaochao/pi-toolkit 0.1.3 → 0.1.4
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/CHANGELOG.md +4 -0
- package/global/AGENTS.md +91 -0
- package/package.json +6 -3
- package/scripts/install-agents.mjs +15 -0
package/CHANGELOG.md
CHANGED
package/global/AGENTS.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
|
|
4
|
+
|
|
5
|
+
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
|
|
6
|
+
|
|
7
|
+
## 1. Think Before Coding
|
|
8
|
+
|
|
9
|
+
**Don't assume. Don't hide confusion. Surface tradeoffs.**
|
|
10
|
+
|
|
11
|
+
Before implementing:
|
|
12
|
+
- State your assumptions explicitly. If uncertain, ask.
|
|
13
|
+
- If multiple interpretations exist, present them - don't pick silently.
|
|
14
|
+
- If a simpler approach exists, say so. Push back when warranted.
|
|
15
|
+
- If something is unclear, stop. Name what's confusing. Ask.
|
|
16
|
+
|
|
17
|
+
## 2. Simplicity First
|
|
18
|
+
|
|
19
|
+
**Minimum code that solves the problem. Nothing speculative.**
|
|
20
|
+
|
|
21
|
+
- No features beyond what was asked.
|
|
22
|
+
- No abstractions for single-use code.
|
|
23
|
+
- No "flexibility" or "configurability" that wasn't requested.
|
|
24
|
+
- No error handling for impossible scenarios.
|
|
25
|
+
- If you write 200 lines and it could be 50, rewrite.
|
|
26
|
+
|
|
27
|
+
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
|
|
28
|
+
|
|
29
|
+
## 3. Surgical Changes
|
|
30
|
+
|
|
31
|
+
**Touch only what you must. Clean up only your own mess.**
|
|
32
|
+
|
|
33
|
+
When editing existing code:
|
|
34
|
+
- Don't "improve" adjacent code, comments, or formatting.
|
|
35
|
+
- Don't refactor things that aren't broken.
|
|
36
|
+
- Match existing style, even if you'd do it differently.
|
|
37
|
+
- If you notice unrelated dead code, mention it - don't delete it.
|
|
38
|
+
|
|
39
|
+
When your changes create orphans:
|
|
40
|
+
- Remove imports/variables/functions that YOUR changes made unused.
|
|
41
|
+
- Don't remove pre-existing dead code unless asked.
|
|
42
|
+
|
|
43
|
+
The test: Every changed line should trace directly to the user's request.
|
|
44
|
+
|
|
45
|
+
## 4. Goal-Driven Execution
|
|
46
|
+
|
|
47
|
+
**Define success criteria. Loop until verified.**
|
|
48
|
+
|
|
49
|
+
Transform tasks into verifiable goals:
|
|
50
|
+
- "Add validation" -> "Write tests for invalid inputs, then make them pass"
|
|
51
|
+
- "Fix the bug" -> "Write a test that reproduces it, then make it pass"
|
|
52
|
+
- "Refactor X" -> "Ensure tests pass before and after"
|
|
53
|
+
|
|
54
|
+
For multi-step tasks, state a brief plan:
|
|
55
|
+
1. [Step] -> verify: [check]
|
|
56
|
+
2. [Step] -> verify: [check]
|
|
57
|
+
3. [Step] -> verify: [check]
|
|
58
|
+
|
|
59
|
+
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
|
|
60
|
+
|
|
61
|
+
## 5. Read Before You Write
|
|
62
|
+
|
|
63
|
+
**Understand adjacent code before changing it. "Looks orthogonal" is a dangerous assumption.**
|
|
64
|
+
|
|
65
|
+
Before adding code to any file:
|
|
66
|
+
- Read the file's exports and public API.
|
|
67
|
+
- Read the immediate callers of the function you're modifying.
|
|
68
|
+
- Check shared utilities in the same module.
|
|
69
|
+
- If you're unsure why code is structured a certain way, ask before writing.
|
|
70
|
+
|
|
71
|
+
## 6. Checkpoint Long-Running Work
|
|
72
|
+
|
|
73
|
+
**Multi-step work needs checkpoints. Don't keep going from a state you can't describe.**
|
|
74
|
+
|
|
75
|
+
After each significant step:
|
|
76
|
+
- Summarize what was done.
|
|
77
|
+
- State what was verified.
|
|
78
|
+
- State what remains.
|
|
79
|
+
- If you can't describe the current state back, stop and restate instead of continuing.
|
|
80
|
+
|
|
81
|
+
## 7. Fail Visibly, Not Silently
|
|
82
|
+
|
|
83
|
+
**Silent skips are failures. Surface uncertainty instead of hiding it.**
|
|
84
|
+
|
|
85
|
+
- "Completed" is wrong if anything was silently skipped.
|
|
86
|
+
- "Tests pass" is wrong if any test was skipped.
|
|
87
|
+
- Default to surfacing uncertainty. When in doubt, over-communicate what you're unsure about.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxiaochao/pi-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Personal pi coding agent toolkit: /todos extension + /cache_export interactive cache dashboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"extensions",
|
|
12
12
|
"README.md",
|
|
13
|
-
"CHANGELOG.md"
|
|
13
|
+
"CHANGELOG.md",
|
|
14
|
+
"global/AGENTS.md",
|
|
15
|
+
"scripts/install-agents.mjs"
|
|
14
16
|
],
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
@@ -30,7 +32,8 @@
|
|
|
30
32
|
},
|
|
31
33
|
"scripts": {
|
|
32
34
|
"test": "cd extensions/cache-export && node --experimental-strip-types tests/run-tests.mjs",
|
|
33
|
-
"load-test": "pi -e ./extensions/todo.ts && pi -e ./extensions/cache-export/index.ts"
|
|
35
|
+
"load-test": "pi -ne -e ./extensions/todo.ts && pi -ne -e ./extensions/cache-export/index.ts",
|
|
36
|
+
"postinstall": "node scripts/install-agents.mjs"
|
|
34
37
|
},
|
|
35
38
|
"publishConfig": {
|
|
36
39
|
"access": "public"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// postinstall hook: sync the bundled global AGENTS.md to ~/.pi/agent/AGENTS.md
|
|
2
|
+
// (pi's native global context file). Idempotent: writes only when different.
|
|
3
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const bundled = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "global", "AGENTS.md"), "utf8");
|
|
9
|
+
const target = join(homedir(), ".pi", "agent", "AGENTS.md");
|
|
10
|
+
|
|
11
|
+
if (!existsSync(target) || readFileSync(target, "utf8") !== bundled) {
|
|
12
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
13
|
+
writeFileSync(target, bundled, "utf8");
|
|
14
|
+
console.log("[pi-toolkit] global AGENTS.md synced ->", target);
|
|
15
|
+
}
|