@dreadedzombie/pi-init 1.2.0 → 1.4.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 +1 -1
- package/src/index.ts +29 -8
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -18,6 +18,9 @@ import * as path from "node:path";
|
|
|
18
18
|
|
|
19
19
|
const TEMPLATE_CODE = `# Project Agent
|
|
20
20
|
|
|
21
|
+
**Workspace Path:** \`{{CWD}}\`
|
|
22
|
+
*(Note to Pi: Your file write/edit tools run in a different directory by default. You MUST use absolute paths starting with the Workspace Path above for ALL file operations!)*
|
|
23
|
+
|
|
21
24
|
<!-- Pi: before writing anything, explore this project:
|
|
22
25
|
1. Read package.json / pyproject.toml / Cargo.toml / go.mod — identify stack and versions
|
|
23
26
|
2. Scan directory structure: rg --files | head -60
|
|
@@ -58,15 +61,14 @@ const TEMPLATE_CODE = `# Project Agent
|
|
|
58
61
|
|
|
59
62
|
const TEMPLATE_RESEARCH = `# Research Agent
|
|
60
63
|
|
|
61
|
-
**
|
|
64
|
+
**Workspace Path:** \`{{CWD}}\`
|
|
65
|
+
*(Note to Pi: Your file write/edit tools run in a different directory by default. You MUST use absolute paths starting with the Workspace Path above for ALL file operations!)*
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
Create the \`research/\` directory and write \`research/plan.md\` listing the topics you will investigate.
|
|
65
|
-
Do this before any searching or reading. This is not optional.
|
|
67
|
+
**Started:** <!-- Pi: insert today's date (YYYY-MM-DD) -->
|
|
66
68
|
|
|
67
69
|
## Output Rule — Files Before Chat
|
|
68
70
|
**Never summarize findings in chat.** Every finding goes into a file.
|
|
69
|
-
- Create \`research/<topic>.md\` as you complete each topic — not at the end
|
|
71
|
+
- Create \`{{CWD}}/research/<topic>.md\` as you complete each topic — not at the end
|
|
70
72
|
- Update the Research Findings section in this file after writing each doc
|
|
71
73
|
- Chat response comes last, only to say what files were written and what to do next
|
|
72
74
|
- **If you are about to type a finding into chat — stop. Write it to a file instead.**
|
|
@@ -89,7 +91,7 @@ Do this before any searching or reading. This is not optional.
|
|
|
89
91
|
2. **Dive** — read the full content of the 5-6 most relevant sources
|
|
90
92
|
3. **Cross-reference** — identify what sources agree and disagree on
|
|
91
93
|
4. **Synthesize** — build a coherent picture with citations
|
|
92
|
-
5. **Write** — save to \`research/<topic>.md\` with full detail, citations, code snippets, and gaps
|
|
94
|
+
5. **Write** — save to \`{{CWD}}/research/<topic>.md\` with full detail, citations, code snippets, and gaps
|
|
93
95
|
6. **Update AGENTS.md** — add the file to Research Findings below, one line per file
|
|
94
96
|
7. Repeat steps 1-6 for each sub-topic before moving on
|
|
95
97
|
|
|
@@ -111,13 +113,16 @@ Each file should contain:
|
|
|
111
113
|
- \`pi-docparser\` — for PDFs, papers, Word docs, spreadsheets
|
|
112
114
|
|
|
113
115
|
## Research Findings
|
|
114
|
-
<!-- Pi: after writing each research/<topic>.md, add a line here immediately:
|
|
116
|
+
<!-- Pi: after writing each {{CWD}}/research/<topic>.md, add a line here immediately:
|
|
115
117
|
- [Topic title](research/filename.md) — one-line summary of what was found
|
|
116
118
|
Do not wait until the end. Update this section after every file written. -->
|
|
117
119
|
`;
|
|
118
120
|
|
|
119
121
|
const TEMPLATE_DEBUG = `# Debug Agent
|
|
120
122
|
|
|
123
|
+
**Workspace Path:** \`{{CWD}}\`
|
|
124
|
+
*(Note to Pi: Your file write/edit tools run in a different directory by default. You MUST use absolute paths starting with the Workspace Path above for ALL file operations!)*
|
|
125
|
+
|
|
121
126
|
## Research Findings
|
|
122
127
|
<!-- Pi: read every file linked here before starting investigation — prior research is your context -->
|
|
123
128
|
|
|
@@ -264,11 +269,27 @@ export default function (pi: ExtensionAPI) {
|
|
|
264
269
|
}
|
|
265
270
|
}
|
|
266
271
|
|
|
267
|
-
|
|
272
|
+
let content = type === "research" ? TEMPLATE_RESEARCH
|
|
268
273
|
: type === "debug" ? TEMPLATE_DEBUG
|
|
269
274
|
: TEMPLATE_CODE;
|
|
270
275
|
|
|
276
|
+
// Ensure paths are absolute and formatted correctly for the LLM
|
|
277
|
+
const absoluteCwd = cwd.replace(/\\/g, "/");
|
|
278
|
+
content = content.replace(/\{\{CWD\}\}/g, absoluteCwd);
|
|
279
|
+
|
|
271
280
|
fs.writeFileSync(dest, content, "utf8");
|
|
281
|
+
|
|
282
|
+
// ── Research: scaffold research/ dir and plan.md so Pi fills in existing files ──
|
|
283
|
+
if (type === "research") {
|
|
284
|
+
const researchDir = path.join(cwd, "research");
|
|
285
|
+
if (!fs.existsSync(researchDir)) fs.mkdirSync(researchDir);
|
|
286
|
+
const planPath = path.join(researchDir, "plan.md");
|
|
287
|
+
if (!fs.existsSync(planPath)) {
|
|
288
|
+
fs.writeFileSync(planPath, `# Research Plan\n\n## Topic\n<!-- What are we researching? -->\n\n## Sub-topics to investigate\n<!-- Pi: list each angle you will cover, one per line. Write a <topic>.md file for each. -->\n\n## Key questions to answer\n<!-- Pi: what specific questions must be answered by the end of this session? -->\n\n## Known starting points\n<!-- Pi: any URLs, files, or repos already identified as relevant -->\n`, "utf8");
|
|
289
|
+
}
|
|
290
|
+
ctx.ui.notify(`[pi-init] research/plan.md created — Pi will fill this in before searching`, "info");
|
|
291
|
+
}
|
|
292
|
+
|
|
272
293
|
ctx.ui.notify(`[pi-init] AGENTS.md (${type}) written to ${cwd}`, "info");
|
|
273
294
|
ctx.ui.notify(getFollowUp(type), "info");
|
|
274
295
|
},
|