@preapexis/pi-kit 1.2.2 → 1.3.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/extensions/agent-rules.ts +60 -0
- package/extensions/ask-options.ts +158 -0
- package/extensions/safety.ts +0 -23
- package/extensions/workspace-guard.ts +0 -17
- package/package.json +1 -1
- package/prompts/init.md +182 -157
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// cSpell:words preapexis
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
export default function (pi: ExtensionAPI): void {
|
|
5
|
+
pi.on("before_agent_start", async (event) => {
|
|
6
|
+
return {
|
|
7
|
+
systemPrompt:
|
|
8
|
+
event.systemPrompt +
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
PreApeXis Agent Behavior Rules:
|
|
12
|
+
|
|
13
|
+
Safety rules:
|
|
14
|
+
- Make small, reviewable changes.
|
|
15
|
+
- Do not read or edit secret files such as .env files.
|
|
16
|
+
- Do not expose secrets, API keys, tokens, passwords, or private credentials.
|
|
17
|
+
- Ask before installing, removing, or upgrading packages.
|
|
18
|
+
- Explain risky commands before running them.
|
|
19
|
+
- Prefer safe, additive changes.
|
|
20
|
+
- Run tests or type checks after code changes when available.
|
|
21
|
+
- Ask before destructive Git operations such as reset, clean, force-push, or deleting branches.
|
|
22
|
+
|
|
23
|
+
Clarification rules:
|
|
24
|
+
- If the task is clear, continue without asking unnecessary questions.
|
|
25
|
+
- If clarification is required before editing files, use the ask_user tool.
|
|
26
|
+
- Ask one question at a time.
|
|
27
|
+
- Provide 2 to 5 short, useful options.
|
|
28
|
+
- Do not manually add "Write something else"; the ask_user tool adds the custom-answer option.
|
|
29
|
+
- After the user answers, continue the same task using that answer.
|
|
30
|
+
- Do not edit files that depend on unanswered clarification.
|
|
31
|
+
- If a reasonable safe default exists, proceed with the default and clearly mention the assumption instead of asking.
|
|
32
|
+
- Do not ask broad open-ended questions when a multiple-choice question would work better.
|
|
33
|
+
|
|
34
|
+
Workspace boundary rules:
|
|
35
|
+
- Treat the current working directory as the workspace root.
|
|
36
|
+
- By default, only read, search, edit, write, delete, or inspect files inside the current workspace.
|
|
37
|
+
- Do not look outside the current workspace just because it might be useful.
|
|
38
|
+
- Do not read parent folders, sibling folders, home directories, global config folders, or unrelated repositories unless the user explicitly asks.
|
|
39
|
+
- Even when the user explicitly asks to access something outside the workspace, ask for confirmation before each outside read, search, write, edit, delete, or command.
|
|
40
|
+
- Prefer relative paths inside the current repository.
|
|
41
|
+
- Do not run commands that cd, pushd, Set-Location, sl, git -C, npm --prefix, pnpm -C, or otherwise move outside the workspace unless explicitly requested and confirmed.
|
|
42
|
+
- If outside-workspace context seems useful, ask first instead of checking it silently.
|
|
43
|
+
- If no UI is available to ask permission, block outside-workspace access.
|
|
44
|
+
|
|
45
|
+
Repository behavior:
|
|
46
|
+
- Follow AGENTS.md when present.
|
|
47
|
+
- Keep AGENTS.md concise.
|
|
48
|
+
- Put detailed repository mapping in docs/PROJECT_MAP.md.
|
|
49
|
+
- Do not duplicate docs/PROJECT_MAP.md inside AGENTS.md.
|
|
50
|
+
- Prefer editing existing files over creating duplicate files.
|
|
51
|
+
- Prefer npm install instructions for this package unless the user explicitly asks for GitHub install instructions.
|
|
52
|
+
|
|
53
|
+
Pi kit behavior:
|
|
54
|
+
- Do not duplicate Pi's built-in model, branch, context, or token footer information.
|
|
55
|
+
- Keep workspace guard behavior strict by default.
|
|
56
|
+
- Keep provider setup commands safe and avoid printing API keys.
|
|
57
|
+
`
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// cSpell:words preapexis
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
type AskUserParams = {
|
|
5
|
+
question: string;
|
|
6
|
+
options: string[];
|
|
7
|
+
allowCustom?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const CUSTOM_OPTION = "✍ Write something else";
|
|
11
|
+
|
|
12
|
+
export default function (pi: ExtensionAPI): void {
|
|
13
|
+
pi.registerTool({
|
|
14
|
+
name: "ask_user",
|
|
15
|
+
label: "Ask User",
|
|
16
|
+
description:
|
|
17
|
+
"Ask the user a multiple-choice question and wait for their answer before continuing.",
|
|
18
|
+
promptSnippet:
|
|
19
|
+
"Ask the user a multiple-choice question when clarification is required.",
|
|
20
|
+
promptGuidelines: [
|
|
21
|
+
"Use ask_user when you need clarification before continuing.",
|
|
22
|
+
"Use ask_user instead of guessing when multiple reasonable choices exist.",
|
|
23
|
+
"Use ask_user with short, clear options.",
|
|
24
|
+
"Do not ask open-ended clarification questions directly in chat when ask_user can be used.",
|
|
25
|
+
"Always include useful default options. The ask_user tool automatically adds a custom-answer option."
|
|
26
|
+
],
|
|
27
|
+
parameters: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
question: {
|
|
31
|
+
type: "string",
|
|
32
|
+
description: "The question to ask the user."
|
|
33
|
+
},
|
|
34
|
+
options: {
|
|
35
|
+
type: "array",
|
|
36
|
+
items: { type: "string" },
|
|
37
|
+
description:
|
|
38
|
+
"Short answer choices. Do not include 'Write something else'; it is added automatically."
|
|
39
|
+
},
|
|
40
|
+
allowCustom: {
|
|
41
|
+
type: "boolean",
|
|
42
|
+
description:
|
|
43
|
+
"Whether the user can write a custom answer. Defaults to true."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
required: ["question", "options"]
|
|
47
|
+
} as any,
|
|
48
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
49
|
+
const input = params as AskUserParams;
|
|
50
|
+
|
|
51
|
+
if (!ctx.hasUI) {
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: "text",
|
|
56
|
+
text: [
|
|
57
|
+
"Cannot ask the user with options because Pi UI is not available.",
|
|
58
|
+
"",
|
|
59
|
+
`Question: ${input.question}`,
|
|
60
|
+
"",
|
|
61
|
+
"Options:",
|
|
62
|
+
...input.options.map(
|
|
63
|
+
(option, index) => `${index + 1}. ${option}`
|
|
64
|
+
)
|
|
65
|
+
].join("\n")
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
details: {
|
|
69
|
+
answered: false,
|
|
70
|
+
reason: "missing_ui"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const cleanOptions = input.options
|
|
76
|
+
.map((option) => option.trim())
|
|
77
|
+
.filter(Boolean);
|
|
78
|
+
|
|
79
|
+
const allowCustom = input.allowCustom !== false;
|
|
80
|
+
|
|
81
|
+
const choices = allowCustom
|
|
82
|
+
? [...cleanOptions, CUSTOM_OPTION]
|
|
83
|
+
: cleanOptions;
|
|
84
|
+
|
|
85
|
+
if (choices.length === 0) {
|
|
86
|
+
const answer = await ctx.ui.input("Question", input.question);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
{
|
|
91
|
+
type: "text",
|
|
92
|
+
text: `User answered: ${answer}`
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
details: {
|
|
96
|
+
answered: true,
|
|
97
|
+
answer,
|
|
98
|
+
custom: true
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const choice = await ctx.ui.select(input.question, choices);
|
|
104
|
+
|
|
105
|
+
if (!choice) {
|
|
106
|
+
return {
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: "text",
|
|
110
|
+
text: "User cancelled the question. Stop and ask again only if the answer is required."
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
details: {
|
|
114
|
+
answered: false,
|
|
115
|
+
cancelled: true
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (choice === CUSTOM_OPTION) {
|
|
121
|
+
const answer = await ctx.ui.input(
|
|
122
|
+
"Write something else",
|
|
123
|
+
input.question
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
content: [
|
|
128
|
+
{
|
|
129
|
+
type: "text",
|
|
130
|
+
text: `User answered: ${answer}`
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
details: {
|
|
134
|
+
answered: true,
|
|
135
|
+
answer,
|
|
136
|
+
custom: true
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
content: [
|
|
143
|
+
{
|
|
144
|
+
type: "text",
|
|
145
|
+
text: `User selected: ${choice}`
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
details: {
|
|
149
|
+
answered: true,
|
|
150
|
+
answer: choice,
|
|
151
|
+
custom: false
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
}
|
package/extensions/safety.ts
CHANGED
|
@@ -110,29 +110,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
110
110
|
return riskyCommands.some((pattern) => pattern.test(command));
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
pi.on("before_agent_start", async (event) => {
|
|
114
|
-
return {
|
|
115
|
-
systemPrompt:
|
|
116
|
-
event.systemPrompt +
|
|
117
|
-
`
|
|
118
|
-
Safety rules:
|
|
119
|
-
- Make small, reviewable changes.
|
|
120
|
-
- Do not read or edit secret files such as .env files.
|
|
121
|
-
- Ask before installing or removing packages.
|
|
122
|
-
- Explain risky commands before running them.
|
|
123
|
-
- Prefer safe, additive changes.
|
|
124
|
-
- Run tests or type checks after code changes when available.
|
|
125
|
-
|
|
126
|
-
Clarification rules:
|
|
127
|
-
- If the request is unclear, ask questions before editing files.
|
|
128
|
-
- Ask only important questions.
|
|
129
|
-
- Do not ask more than 5 questions.
|
|
130
|
-
- If the task is clear, continue without asking.
|
|
131
|
-
- Do not edit files until the user answers clarification questions.
|
|
132
|
-
`
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
|
|
136
113
|
pi.on("tool_call", async (event, ctx) => {
|
|
137
114
|
if (event.toolName === "bash") {
|
|
138
115
|
const command = String(event.input.command ?? "");
|
|
@@ -134,23 +134,6 @@ export default function (pi: ExtensionAPI): void {
|
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
pi.on("before_agent_start", async (event) => {
|
|
138
|
-
return {
|
|
139
|
-
systemPrompt:
|
|
140
|
-
event.systemPrompt +
|
|
141
|
-
`
|
|
142
|
-
|
|
143
|
-
Workspace boundary rules:
|
|
144
|
-
- Treat the current working directory as the workspace root.
|
|
145
|
-
- Do not read, search, edit, write, delete, or inspect files outside the current workspace unless the user explicitly asks.
|
|
146
|
-
- Before using any path outside the workspace, ask the user for permission.
|
|
147
|
-
- Prefer relative paths inside the current repository.
|
|
148
|
-
- Do not run commands that cd, pushd, Set-Location, or otherwise move outside the workspace unless explicitly requested.
|
|
149
|
-
- If outside-workspace context seems useful, ask first instead of checking it silently.
|
|
150
|
-
`
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
|
|
154
137
|
pi.on("tool_call", async (event, ctx) => {
|
|
155
138
|
if (!workspaceRoot) {
|
|
156
139
|
workspaceRoot = normalize(ctx.cwd);
|
package/package.json
CHANGED
package/prompts/init.md
CHANGED
|
@@ -1,228 +1,253 @@
|
|
|
1
|
-
# Initialize
|
|
1
|
+
# Initialize Repository Understanding
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This prompt must **not** duplicate the full repository map. The detailed repository map belongs in:
|
|
6
|
-
|
|
7
|
-
`docs/PROJECT_MAP.md`
|
|
8
|
-
|
|
9
|
-
If `docs/PROJECT_MAP.md` exists, read it and use it as the main source for repository structure.
|
|
10
|
-
|
|
11
|
-
If `docs/PROJECT_MAP.md` does not exist, do **not** create a large project map inside `AGENTS.md`. Instead, inspect only the most important project files and add a note in `AGENTS.md` saying that `/repo-map` should be run to generate `docs/PROJECT_MAP.md`.
|
|
3
|
+
> This prompt initializes or updates the repository-level `AGENTS.md` file for Pi.
|
|
4
|
+
> It should rely on `docs/PROJECT_MAP.md` when available and avoid doing full repository mapping itself.
|
|
12
5
|
|
|
13
6
|
## Goal
|
|
14
7
|
|
|
15
|
-
Create
|
|
8
|
+
Create or update an `AGENTS.md` file that gives future Pi sessions clear, durable instructions for working in this repository.
|
|
9
|
+
|
|
10
|
+
The `AGENTS.md` file should help future agents quickly understand:
|
|
16
11
|
|
|
17
12
|
- what this project does
|
|
18
|
-
-
|
|
13
|
+
- where important files live
|
|
19
14
|
- which commands to run
|
|
20
15
|
- which files are risky
|
|
21
|
-
- which files to inspect
|
|
22
|
-
- what rules agents
|
|
16
|
+
- which files to inspect for common tasks
|
|
17
|
+
- what repository-specific rules agents should follow
|
|
23
18
|
|
|
24
|
-
|
|
19
|
+
## Core Rule
|
|
25
20
|
|
|
26
|
-
|
|
21
|
+
`/init` must not duplicate the work of `/repo-map`.
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
Use `docs/PROJECT_MAP.md` if it exists. If it does not exist, recommend running `/repo-map`.
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
When creating or updating `AGENTS.md`, ensure it contains this line exactly once:
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
> Use `docs/PROJECT_MAP.md` if it exists. If it does not exist, recommend running `/repo-map`.
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
Do not add duplicate copies of this line if it already exists.
|
|
35
30
|
|
|
36
|
-
|
|
31
|
+
## What `/init` Should Do
|
|
37
32
|
|
|
38
|
-
|
|
33
|
+
1. Check whether `AGENTS.md` exists.
|
|
34
|
+
2. Check whether `docs/PROJECT_MAP.md` exists.
|
|
35
|
+
3. If `docs/PROJECT_MAP.md` exists:
|
|
36
|
+
- Read it.
|
|
37
|
+
- Use it as the primary source for repository structure and important files.
|
|
38
|
+
- Do not re-map the full repository.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
4. If `docs/PROJECT_MAP.md` does not exist:
|
|
41
|
+
- Do not perform full repository mapping.
|
|
42
|
+
- Recommend running `/repo-map`.
|
|
43
|
+
- Inspect only lightweight top-level files needed to create a useful minimal `AGENTS.md`, such as:
|
|
44
|
+
- `README.md`
|
|
45
|
+
- `package.json`
|
|
46
|
+
- `pnpm-workspace.yaml`
|
|
47
|
+
- `tsconfig.json`
|
|
48
|
+
- `pyproject.toml`
|
|
49
|
+
- `Cargo.toml`
|
|
50
|
+
- `go.mod`
|
|
51
|
+
- `.github/workflows/*`
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
- Clearly mention in `AGENTS.md` that the repository map is missing.
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- Keep the file concise.
|
|
55
|
+
5. Create or update `AGENTS.md`.
|
|
56
|
+
6. Preserve any existing useful project-specific instructions.
|
|
57
|
+
7. Remove or rewrite outdated, duplicated, or generic content only when clearly safe.
|
|
58
|
+
8. Keep `AGENTS.md` concise and durable.
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
- If it exists, read it.
|
|
52
|
-
- Use it to understand the project structure.
|
|
53
|
-
- Reference it from `AGENTS.md`.
|
|
54
|
-
- Do not duplicate it.
|
|
60
|
+
## What `/init` Should Not Do
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
Do not:
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
- scan the entire repository when `docs/PROJECT_MAP.md` is missing
|
|
65
|
+
- duplicate large sections from `docs/PROJECT_MAP.md`
|
|
66
|
+
- turn `AGENTS.md` into a full repository map
|
|
67
|
+
- include long file trees
|
|
68
|
+
- include temporary investigation notes
|
|
69
|
+
- include speculative rules
|
|
70
|
+
- overwrite existing project-specific instructions without reason
|
|
71
|
+
- remove safety, testing, build, or deployment rules unless clearly outdated
|
|
72
|
+
- add the required `docs/PROJECT_MAP.md` line more than once
|
|
73
|
+
|
|
74
|
+
## AGENTS.md Content Requirements
|
|
75
|
+
|
|
76
|
+
The final `AGENTS.md` should include these sections when relevant.
|
|
77
|
+
|
|
78
|
+
### Project Overview
|
|
79
|
+
|
|
80
|
+
Briefly describe what the project is and what it does.
|
|
81
|
+
|
|
82
|
+
Keep this section short.
|
|
83
|
+
|
|
84
|
+
### Repository Map
|
|
85
|
+
|
|
86
|
+
Reference the project map instead of duplicating it.
|
|
87
|
+
|
|
88
|
+
This section must include the following line exactly once:
|
|
89
|
+
|
|
90
|
+
> Use `docs/PROJECT_MAP.md` if it exists. If it does not exist, recommend running `/repo-map`.
|
|
91
|
+
|
|
92
|
+
If `docs/PROJECT_MAP.md` exists, summarize only the most important locations from it.
|
|
93
|
+
|
|
94
|
+
If it does not exist, write that the repository map is missing and that `/repo-map` should be run.
|
|
95
|
+
|
|
96
|
+
### Common Commands
|
|
97
|
+
|
|
98
|
+
Include important commands for:
|
|
99
|
+
|
|
100
|
+
- installing dependencies
|
|
101
|
+
- running locally
|
|
102
|
+
- building
|
|
103
|
+
- testing
|
|
104
|
+
- linting
|
|
105
|
+
- formatting
|
|
106
|
+
- type-checking
|
|
107
|
+
|
|
108
|
+
Only include commands that are supported by files in the repository.
|
|
68
109
|
|
|
69
|
-
|
|
70
|
-
- `extensions/`
|
|
71
|
-
- `prompts/`
|
|
72
|
-
- `skills/`
|
|
73
|
-
- `themes/`
|
|
74
|
-
- `tests/`
|
|
110
|
+
Do not invent commands.
|
|
75
111
|
|
|
76
|
-
|
|
112
|
+
### Important Files and Directories
|
|
77
113
|
|
|
78
|
-
|
|
114
|
+
List only high-value files and directories that future agents should know about.
|
|
79
115
|
|
|
80
|
-
|
|
81
|
-
- install
|
|
82
|
-
- test
|
|
83
|
-
- typecheck
|
|
84
|
-
- release
|
|
85
|
-
- local Pi usage
|
|
86
|
-
- package publishing, if applicable
|
|
116
|
+
Prefer concise bullets.
|
|
87
117
|
|
|
88
|
-
|
|
118
|
+
Do not include a full tree.
|
|
89
119
|
|
|
90
|
-
|
|
91
|
-
- auth files
|
|
92
|
-
- env files
|
|
93
|
-
- GitHub Actions publishing workflows
|
|
94
|
-
- release scripts
|
|
95
|
-
- package version files
|
|
96
|
-
- lockfiles
|
|
97
|
-
- destructive commands
|
|
98
|
-
- workspace boundary rules
|
|
120
|
+
### Development Rules
|
|
99
121
|
|
|
100
|
-
|
|
122
|
+
Include repository-specific rules, such as:
|
|
101
123
|
|
|
102
|
-
|
|
124
|
+
- preferred package manager
|
|
125
|
+
- coding style
|
|
126
|
+
- branch or commit expectations
|
|
127
|
+
- test requirements
|
|
128
|
+
- generated file rules
|
|
129
|
+
- environment variable rules
|
|
130
|
+
- API or security constraints
|
|
103
131
|
|
|
104
|
-
|
|
132
|
+
Do not add generic rules unless they are clearly useful for this repository.
|
|
105
133
|
|
|
106
|
-
|
|
134
|
+
### Risky Areas
|
|
107
135
|
|
|
108
|
-
|
|
136
|
+
Mention files or areas that require extra caution, such as:
|
|
109
137
|
|
|
110
|
-
|
|
138
|
+
- authentication
|
|
139
|
+
- billing
|
|
140
|
+
- migrations
|
|
141
|
+
- deployment
|
|
142
|
+
- generated files
|
|
143
|
+
- config files
|
|
144
|
+
- shared types
|
|
145
|
+
- public APIs
|
|
146
|
+
- data deletion
|
|
147
|
+
- security-sensitive code
|
|
111
148
|
|
|
112
|
-
|
|
149
|
+
### Before Making Changes
|
|
113
150
|
|
|
114
|
-
|
|
115
|
-
- `README.md`
|
|
116
|
-
- `docs/PROJECT_MAP.md`, if present
|
|
117
|
-
- `package.json`
|
|
118
|
-
- key task-specific files
|
|
151
|
+
Include a short checklist future agents should follow before editing.
|
|
119
152
|
|
|
120
|
-
|
|
121
|
-
- Run `/repo-map` to generate `docs/PROJECT_MAP.md`.
|
|
153
|
+
Example:
|
|
122
154
|
|
|
123
|
-
|
|
155
|
+
- Read `AGENTS.md`.
|
|
156
|
+
- Read `docs/PROJECT_MAP.md` if available.
|
|
157
|
+
- Inspect the files directly related to the requested change.
|
|
158
|
+
- Run the smallest relevant validation command.
|
|
159
|
+
- Avoid broad rewrites unless explicitly requested.
|
|
124
160
|
|
|
125
|
-
|
|
161
|
+
### Notes for Future Agents
|
|
126
162
|
|
|
127
|
-
|
|
128
|
-
- Full repository map: `docs/PROJECT_MAP.md`
|
|
163
|
+
Include any durable notes that will help future Pi sessions.
|
|
129
164
|
|
|
130
|
-
|
|
165
|
+
Avoid temporary notes like “today I checked…” or “currently investigating…”.
|
|
131
166
|
|
|
132
|
-
|
|
167
|
+
## Update Strategy
|
|
133
168
|
|
|
134
|
-
|
|
135
|
-
| ------------- | ---------------------- |
|
|
136
|
-
| `extensions/` | Pi extension modules |
|
|
137
|
-
| `prompts/` | Slash prompt workflows |
|
|
138
|
-
| `skills/` | Packaged Pi skills |
|
|
139
|
-
| `themes/` | Pi themes |
|
|
140
|
-
| `tests/` | Vitest tests |
|
|
169
|
+
When updating an existing `AGENTS.md`:
|
|
141
170
|
|
|
142
|
-
|
|
171
|
+
1. Read the full existing file.
|
|
172
|
+
2. Preserve accurate project-specific content.
|
|
173
|
+
3. Add missing required sections.
|
|
174
|
+
4. Add the required `docs/PROJECT_MAP.md` line if missing.
|
|
175
|
+
5. Remove duplicate copies of the required line.
|
|
176
|
+
6. Keep the file organized and easy to skim.
|
|
177
|
+
7. Prefer small, careful edits over full rewrites.
|
|
178
|
+
8. If a full rewrite is necessary, preserve all accurate rules from the old file.
|
|
143
179
|
|
|
144
|
-
|
|
180
|
+
## Minimal AGENTS.md Template
|
|
145
181
|
|
|
146
|
-
|
|
182
|
+
Use this structure when creating a new `AGENTS.md`.
|
|
147
183
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
| Change branding/UI | `extensions/brand-ui.ts`, `themes/` |
|
|
151
|
-
| Change update behavior | `extensions/update.ts` |
|
|
152
|
-
| Change safety behavior | `extensions/safety.ts`, `extensions/git-guard.ts`, `extensions/workspace-guard.ts` |
|
|
153
|
-
| Change prompt workflows | `prompts/`, `extensions/prompts.ts` |
|
|
154
|
-
| Change LiteLLM provider | `extensions/litellm-provider.ts` |
|
|
155
|
-
| Change release behavior | `scripts/git-release.mjs`, `.github/workflows/` |
|
|
184
|
+
```md
|
|
185
|
+
# AGENTS.md
|
|
156
186
|
|
|
157
|
-
|
|
187
|
+
## Project Overview
|
|
158
188
|
|
|
159
|
-
|
|
189
|
+
Briefly describe what this project does.
|
|
160
190
|
|
|
161
|
-
|
|
191
|
+
## Repository Map
|
|
162
192
|
|
|
163
|
-
|
|
164
|
-
| ----------------------------- | ---------------------------------------------- |
|
|
165
|
-
| `npm test` | Run tests |
|
|
166
|
-
| `npm run git --msg="message"` | Commit, optionally bump version, tag, and push |
|
|
193
|
+
Use `docs/PROJECT_MAP.md` if it exists. If it does not exist, recommend running `/repo-map`.
|
|
167
194
|
|
|
168
|
-
|
|
195
|
+
## Common Commands
|
|
169
196
|
|
|
170
|
-
|
|
197
|
+
- Install:
|
|
198
|
+
- Run:
|
|
199
|
+
- Build:
|
|
200
|
+
- Test:
|
|
201
|
+
- Lint:
|
|
202
|
+
- Type-check:
|
|
171
203
|
|
|
172
|
-
|
|
204
|
+
Only keep commands that are confirmed by repository files.
|
|
173
205
|
|
|
174
|
-
|
|
206
|
+
## Important Files and Directories
|
|
175
207
|
|
|
176
|
-
|
|
208
|
+
- `README.md` — project overview and usage.
|
|
209
|
+
- Add only important confirmed paths here.
|
|
177
210
|
|
|
178
|
-
|
|
179
|
-
- Do not read `.env` files.
|
|
180
|
-
- Do not expose secrets.
|
|
181
|
-
- Do not modify files outside the current workspace unless explicitly allowed.
|
|
182
|
-
- Be careful with release scripts, npm publishing, GitHub workflows, and package version files.
|
|
183
|
-
- Ask before destructive Git commands.
|
|
184
|
-
- Do not duplicate `docs/PROJECT_MAP.md` inside `AGENTS.md`.
|
|
211
|
+
## Development Rules
|
|
185
212
|
|
|
186
|
-
|
|
213
|
+
- Add repository-specific rules here.
|
|
214
|
+
- Do not invent rules.
|
|
187
215
|
|
|
188
|
-
|
|
216
|
+
## Risky Areas
|
|
189
217
|
|
|
190
|
-
|
|
218
|
+
- Add files or workflows that require extra caution.
|
|
191
219
|
|
|
192
|
-
|
|
220
|
+
## Before Making Changes
|
|
193
221
|
|
|
194
|
-
|
|
222
|
+
- Read this file.
|
|
223
|
+
- Read `docs/PROJECT_MAP.md` if it exists.
|
|
224
|
+
- Inspect the files directly related to the requested change.
|
|
225
|
+
- Run the smallest relevant validation command.
|
|
226
|
+
- Avoid broad rewrites unless explicitly requested.
|
|
195
227
|
|
|
196
|
-
|
|
197
|
-
- Prefer editing existing extension files over creating duplicates.
|
|
198
|
-
- Keep `AGENTS.md` concise.
|
|
199
|
-
- Put detailed repository mapping in `docs/PROJECT_MAP.md`.
|
|
200
|
-
- Do not add GitHub install instructions if this package should be installed from npm.
|
|
201
|
-
- Do not duplicate Pi’s built-in status/footer information.
|
|
202
|
-
- Keep workspace guard behavior strict by default.
|
|
228
|
+
## Notes for Future Agents
|
|
203
229
|
|
|
204
|
-
|
|
230
|
+
Add durable notes that will help future sessions.
|
|
231
|
+
```
|
|
205
232
|
|
|
206
|
-
|
|
233
|
+
## Output Requirements
|
|
207
234
|
|
|
208
|
-
|
|
235
|
+
After running `/init`, respond with:
|
|
209
236
|
|
|
210
|
-
|
|
237
|
+
1. Whether `AGENTS.md` was created or updated.
|
|
238
|
+
2. Whether `docs/PROJECT_MAP.md` was found.
|
|
239
|
+
3. A short summary of the important changes made.
|
|
240
|
+
4. Any recommended next step, especially running `/repo-map` if the project map is missing.
|
|
211
241
|
|
|
212
|
-
|
|
242
|
+
Keep the response concise.
|
|
213
243
|
|
|
214
|
-
|
|
215
|
-
- Do not modify source code.
|
|
216
|
-
- Do not modify `docs/PROJECT_MAP.md`.
|
|
217
|
-
- Do not create a second project map inside `AGENTS.md`.
|
|
218
|
-
- Keep `AGENTS.md` concise.
|
|
219
|
-
- Prefer references to `docs/PROJECT_MAP.md` over duplicated file lists.
|
|
220
|
-
- Do not include secrets, API keys, tokens, passwords, or sensitive data.
|
|
221
|
-
- Do not read actual `.env` files.
|
|
244
|
+
## Success Criteria
|
|
222
245
|
|
|
223
|
-
|
|
246
|
+
The task is successful when:
|
|
224
247
|
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
-
|
|
228
|
-
-
|
|
248
|
+
- `AGENTS.md` exists.
|
|
249
|
+
- It contains the required `docs/PROJECT_MAP.md` line exactly once.
|
|
250
|
+
- Existing useful instructions were preserved.
|
|
251
|
+
- Repository details are accurate and not invented.
|
|
252
|
+
- `/init` did not perform full repository mapping.
|
|
253
|
+
- The file is concise, durable, and useful for future Pi sessions.
|