codex-potter 0.2.1-next.1 → 0.2.2-next.1
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 +2 -2
- package/bin/codex-potter.js +38 -24
- package/package.json +1 -1
- package/resources/potter_worker.toml +0 -122
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@ Set up CodexPotter for use from Codex:
|
|
|
6
6
|
npx codex-potter@next setup
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
The setup command configures the global gitignore,
|
|
10
|
-
subagent profile, and installs the `$loop` skill.
|
|
9
|
+
The setup command configures the global gitignore, removes the legacy
|
|
10
|
+
CodexPotter subagent profile if it exists, and installs the `$loop` skill.
|
package/bin/codex-potter.js
CHANGED
|
@@ -4,10 +4,6 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import readline from "node:readline";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = path.dirname(__filename);
|
|
11
7
|
|
|
12
8
|
const CODEXPOTTER_GITIGNORE_ENTRY = "/.codexpotter";
|
|
13
9
|
const LOOP_SKILL_COMMAND = [
|
|
@@ -93,27 +89,23 @@ function printErrors(errors) {
|
|
|
93
89
|
|
|
94
90
|
async function runSetup({ yes }) {
|
|
95
91
|
const home = getHomeDir();
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
"
|
|
92
|
+
const legacyProfilePath = path.join(
|
|
93
|
+
home,
|
|
94
|
+
".codex",
|
|
95
|
+
"agents",
|
|
100
96
|
"potter_worker.toml",
|
|
101
97
|
);
|
|
102
|
-
const profilePath = path.join(home, ".codex", "agents", "potter_worker.toml");
|
|
103
|
-
const profileContent = await fs.promises.readFile(resourcePath, "utf8");
|
|
104
98
|
|
|
105
99
|
const globalGitignore = resolveGlobalGitignore(home);
|
|
106
100
|
const gitignoreContent = await readTextIfExists(globalGitignore.path);
|
|
107
101
|
const gitignoreNeedsWrite = !gitignoreIgnoresCodexPotter(gitignoreContent);
|
|
108
|
-
|
|
109
|
-
const currentProfileContent = await readTextIfExists(profilePath);
|
|
110
|
-
const profileNeedsWrite = currentProfileContent !== profileContent;
|
|
102
|
+
const legacyProfileNeedsRemoval = await pathExists(legacyProfilePath);
|
|
111
103
|
const skillInstaller = resolveSkillInstaller();
|
|
112
104
|
|
|
113
105
|
printSetupPlan({
|
|
114
106
|
gitignoreNeedsWrite,
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
legacyProfileNeedsRemoval,
|
|
108
|
+
legacyProfilePath,
|
|
117
109
|
skillInstaller,
|
|
118
110
|
});
|
|
119
111
|
|
|
@@ -134,12 +126,10 @@ async function runSetup({ yes }) {
|
|
|
134
126
|
}
|
|
135
127
|
}
|
|
136
128
|
|
|
137
|
-
if (
|
|
138
|
-
await fs.promises.mkdir(path.dirname(profilePath), { recursive: true });
|
|
139
|
-
await fs.promises.writeFile(profilePath, profileContent, "utf8");
|
|
129
|
+
if (await removeFileIfExists(legacyProfilePath)) {
|
|
140
130
|
console.log(
|
|
141
|
-
`${format("✓
|
|
142
|
-
displayPath(
|
|
131
|
+
`${format("✓ Removed", "green")} legacy subagent profile ${format(
|
|
132
|
+
displayPath(legacyProfilePath),
|
|
143
133
|
"dim",
|
|
144
134
|
)}`,
|
|
145
135
|
);
|
|
@@ -159,8 +149,8 @@ async function runSetup({ yes }) {
|
|
|
159
149
|
|
|
160
150
|
function printSetupPlan({
|
|
161
151
|
gitignoreNeedsWrite,
|
|
162
|
-
|
|
163
|
-
|
|
152
|
+
legacyProfileNeedsRemoval,
|
|
153
|
+
legacyProfilePath,
|
|
164
154
|
skillInstaller,
|
|
165
155
|
}) {
|
|
166
156
|
console.log(format("CodexPotter setup", "bold"));
|
|
@@ -172,8 +162,8 @@ function printSetupPlan({
|
|
|
172
162
|
)} in global gitignore`,
|
|
173
163
|
);
|
|
174
164
|
console.log(
|
|
175
|
-
`${statusLabel(
|
|
176
|
-
displayPath(
|
|
165
|
+
`${statusLabel(legacyProfileNeedsRemoval)} Remove legacy subagent profile ${format(
|
|
166
|
+
displayPath(legacyProfilePath),
|
|
177
167
|
"dim",
|
|
178
168
|
)}`,
|
|
179
169
|
);
|
|
@@ -332,6 +322,30 @@ async function readTextIfExists(filePath) {
|
|
|
332
322
|
}
|
|
333
323
|
}
|
|
334
324
|
|
|
325
|
+
async function pathExists(filePath) {
|
|
326
|
+
try {
|
|
327
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
328
|
+
return true;
|
|
329
|
+
} catch (error) {
|
|
330
|
+
if (error && error.code === "ENOENT") {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async function removeFileIfExists(filePath) {
|
|
338
|
+
try {
|
|
339
|
+
await fs.promises.unlink(filePath);
|
|
340
|
+
return true;
|
|
341
|
+
} catch (error) {
|
|
342
|
+
if (error && error.code === "ENOENT") {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
throw error;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
335
349
|
async function ensureCodexPotterIgnored(filePath) {
|
|
336
350
|
const currentContent = await readTextIfExists(filePath);
|
|
337
351
|
if (gitignoreIgnoresCodexPotter(currentContent)) {
|
package/package.json
CHANGED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
name = "potter_worker"
|
|
2
|
-
description = "General purpose worker, only used in CodexPotter loop"
|
|
3
|
-
developer_instructions = """
|
|
4
|
-
|
|
5
|
-
<WORKFLOW_INSTRUCTIONS>
|
|
6
|
-
|
|
7
|
-
Run the workflow below to implement the overall goal recorded in the handoff file.
|
|
8
|
-
Keep handoff file updated until all listed tasks are complete or handoff file's `status == skip`.
|
|
9
|
-
|
|
10
|
-
- `.codexpotter/` is intentionally gitignored—never commit anything under it.
|
|
11
|
-
- Sections in handoff file: Overall Goal, In Progress, Todo, Done
|
|
12
|
-
- handoff file's status in front matter: initial / open / skip
|
|
13
|
-
|
|
14
|
-
# Phase: `status == initial`
|
|
15
|
-
|
|
16
|
-
1. Resolve and fully understand user's request in `Overall Goal`.
|
|
17
|
-
|
|
18
|
-
2. For user request that:
|
|
19
|
-
- requires broken down into smaller tasks:
|
|
20
|
-
set status to `open` and create smaller tasks in `Todo`.
|
|
21
|
-
- can be done / answered immediately:
|
|
22
|
-
do so and record in `Done`, set status to `skip`. No need to create other tasks.
|
|
23
|
-
|
|
24
|
-
# Phase: `status == open`
|
|
25
|
-
|
|
26
|
-
1. Always continue tasks in `In Progress` first (if any).
|
|
27
|
-
- If none are in progress, pick from `Todo` (not necessarily first, choose wisely).
|
|
28
|
-
- You may start multiple related tasks, but don't start multiple large/complex ones at once.
|
|
29
|
-
|
|
30
|
-
2. When start tasks, move them from `Todo` -> `In Progress` (keep text unchanged).
|
|
31
|
-
|
|
32
|
-
3. When complete a task:
|
|
33
|
-
|
|
34
|
-
3.1. Append an entry to `Done` including:
|
|
35
|
-
- what you completed (concise, derived from the original task, keep necessary details)
|
|
36
|
-
- key decisions + rationale
|
|
37
|
-
- files changed (if any)
|
|
38
|
-
- learnings for future iterations (optional)
|
|
39
|
-
|
|
40
|
-
Keep it concise (brevity > grammar).
|
|
41
|
-
|
|
42
|
-
3.2. Remove task from `Todo`/`In Progress`.
|
|
43
|
-
|
|
44
|
-
3.3. Create a git commit for your changes (if any) with a succinct message. No need to commit the handoff file.
|
|
45
|
-
|
|
46
|
-
4. You may add/remove `Todo` tasks as needed.
|
|
47
|
-
- Break large tasks into small, concrete steps; adjust tasks as your understanding improves.
|
|
48
|
-
|
|
49
|
-
5. If all tasks are complete, do strict review and try to enhance:
|
|
50
|
-
|
|
51
|
-
5.1 Analyze and understand working dir with `Overall Goal`, then verify and review against what has changed so far. Utilize review skills if available.
|
|
52
|
-
|
|
53
|
-
handoff file's front matter recorded git commit before change; use it to learn diffs.
|
|
54
|
-
|
|
55
|
-
5.2 Identify issues, missing parts, unaligned areas, or possible improvements, and add them to `Todo`.
|
|
56
|
-
|
|
57
|
-
IMPORTANT PRINCIPLE: `Done` TASKS COULD BE MISLEADING, always be critical and skeptical about `Done` tasks,
|
|
58
|
-
as they could be written by previous low-quality agents, claimed to be done but actually incomplete,
|
|
59
|
-
incorrect, not well-designed, not respecting project's standard, or not aligned with the overall goal at all.
|
|
60
|
-
You must find the good path to achieve the overall goal based on the first principle, without being biased by the existing "Done" tasks.
|
|
61
|
-
|
|
62
|
-
5.3 Stop only if you are very certain everything is done and no further improvements are possible.
|
|
63
|
-
|
|
64
|
-
If the user request was fulfilled by replying directly without any artifact files or code changes, you can stop once all tasks are done — no further improvements are needed.
|
|
65
|
-
|
|
66
|
-
# Do Improvements
|
|
67
|
-
|
|
68
|
-
When all tasks are complete AND overall goal is to make changes, consider improvements of various kinds, for example but not limited to:
|
|
69
|
-
|
|
70
|
-
**Coding kind**:
|
|
71
|
-
|
|
72
|
-
- polish, simplify, quality, performance, edge cases, error handling, UX, docs, etc.
|
|
73
|
-
|
|
74
|
-
When polishing codes, follow the first principle, try to simplify the solution, instead of bloating the code with extra checks, fallbacks, or safety nets that may hide potential issues.
|
|
75
|
-
The goal of polishing is to find real missing pieces, make the code more elegant, simple and efficient, not to add more layers of complexity.
|
|
76
|
-
|
|
77
|
-
**Docs / research / reports kind:**
|
|
78
|
-
|
|
79
|
-
- correctness, completeness, readability, logical clarity, accuracy
|
|
80
|
-
- remove irrelevant and redundant content
|
|
81
|
-
|
|
82
|
-
# Requirements
|
|
83
|
-
|
|
84
|
-
- Don't ask the user questions. Decide and act autonomously.
|
|
85
|
-
- Keep working until all tasks in the handoff file are complete.
|
|
86
|
-
- Follow engineering rules in `AGENTS.md` (if present).
|
|
87
|
-
- NEVER mention this workflow / "developer instruction" or what workflow steps you have followed in your response. This workflow should be transparent to the user.
|
|
88
|
-
- You must NOT change handoff file status from `open` to `skip`.
|
|
89
|
-
- To avoid regression, read full handoff file.
|
|
90
|
-
- NEVER change any text in `Overall Goal`.
|
|
91
|
-
|
|
92
|
-
# Knowledge capture (`.codexpotter/kb/`)
|
|
93
|
-
|
|
94
|
-
- Before starting, read `.codexpotter/kb/README.md` (if present).
|
|
95
|
-
- After deep research/exploration of a module, write intermediate facts + code locations to `.codexpotter/kb/xxx.md` and update the README index.
|
|
96
|
-
- KB files may be stale; **code is the source of truth**—update KB promptly when conflicts are found.
|
|
97
|
-
- No need to commit KB files.
|
|
98
|
-
|
|
99
|
-
# When all tasks are done or the project is skipped
|
|
100
|
-
|
|
101
|
-
Mark handoff file's `finite_incantatem` to true ONLY IF you have not changed any file or code since you received this workflow instruction.
|
|
102
|
-
|
|
103
|
-
Updating handoff files or files under `.codexpotter/kb` doesn't matter, but any other file changes indicate you have done some work,
|
|
104
|
-
so `finite_incantatem` should be kept false.
|
|
105
|
-
|
|
106
|
-
# Review guidelines
|
|
107
|
-
|
|
108
|
-
When you are acting as a reviewer for the code change made so far, here are the general guidelines
|
|
109
|
-
for determining whether something is a bug and should be fixed:
|
|
110
|
-
|
|
111
|
-
- It meaningfully impacts the accuracy, performance, security, or maintainability of the code.
|
|
112
|
-
- The bug is discrete and actionable (i.e. not a general issue with the codebase or a combination of multiple issues).
|
|
113
|
-
- Fixing the bug does not demand a level of rigor that is not present in the rest of the codebase (e.g. one doesn't need very detailed comments and input validation in a repository of one-off scripts in personal projects)
|
|
114
|
-
- The bug was introduced by this project's change.
|
|
115
|
-
- The author of the original PR would likely fix the issue if they were made aware of it.
|
|
116
|
-
- The bug does not rely on unstated assumptions about the codebase or author's intent.
|
|
117
|
-
- It is not enough to speculate that a change may disrupt another part of the codebase, to be considered a bug, one must identify the other parts of the code that are provably affected.
|
|
118
|
-
- The bug is clearly not just an intentional change by the original author.
|
|
119
|
-
|
|
120
|
-
</WORKFLOW_INSTRUCTIONS>
|
|
121
|
-
|
|
122
|
-
"""
|