@selesai/code 0.1.0 → 0.1.2
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/dist/extensions/prototype.ts +17 -27
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
} from "@earendil-works/pi-coding-agent";
|
|
7
7
|
import { Text } from "@earendil-works/pi-tui";
|
|
8
8
|
import { Type } from "typebox";
|
|
9
|
+
import { access, mkdir } from "node:fs/promises";
|
|
9
10
|
|
|
10
11
|
// ponytail: tool result content carries the full phase prompt for the model;
|
|
11
12
|
// renderResult shows only a short label so the user sees a clean progression
|
|
@@ -125,20 +126,21 @@ const PHASE_ARTIFACT: Partial<Record<Phase, string>> = {
|
|
|
125
126
|
audit: "review.md",
|
|
126
127
|
};
|
|
127
128
|
|
|
128
|
-
async function
|
|
129
|
-
pi: ExtensionAPI,
|
|
130
|
-
p: Phase,
|
|
131
|
-
): Promise<boolean> {
|
|
132
|
-
const file = PHASE_ARTIFACT[p];
|
|
133
|
-
if (!file) return true;
|
|
129
|
+
async function fileExists(path: string): Promise<boolean> {
|
|
134
130
|
try {
|
|
135
|
-
|
|
136
|
-
return
|
|
131
|
+
await access(path);
|
|
132
|
+
return true;
|
|
137
133
|
} catch {
|
|
138
134
|
return false;
|
|
139
135
|
}
|
|
140
136
|
}
|
|
141
137
|
|
|
138
|
+
async function phaseArtifactExists(p: Phase): Promise<boolean> {
|
|
139
|
+
const file = PHASE_ARTIFACT[p];
|
|
140
|
+
if (!file) return true;
|
|
141
|
+
return fileExists(`${artifactDir}/${file}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
142
144
|
function nextPhase(p: Phase): Phase | null {
|
|
143
145
|
const i = PHASE_ORDER.indexOf(p);
|
|
144
146
|
if (i < 0 || i >= PHASE_ORDER.length - 1) return null;
|
|
@@ -160,20 +162,14 @@ async function advancePhase(
|
|
|
160
162
|
): Promise<AdvanceOutcome> {
|
|
161
163
|
if (!active) return { status: "idle", phase };
|
|
162
164
|
const expected = PHASE_ARTIFACT[phase];
|
|
163
|
-
if (expected && !(await phaseArtifactExists(
|
|
165
|
+
if (expected && !(await phaseArtifactExists(phase))) {
|
|
164
166
|
return { status: "blocked", phase, missing: expected };
|
|
165
167
|
}
|
|
166
168
|
const next = nextPhase(phase);
|
|
167
169
|
if (!next) {
|
|
168
170
|
// audit terminal: need review.md + audit.md before closing.
|
|
169
|
-
const reviewExists = await phaseArtifactExists(
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
auditExists =
|
|
173
|
-
(await pi.exec("test", ["-f", `${artifactDir}/audit.md`])).code === 0;
|
|
174
|
-
} catch {
|
|
175
|
-
auditExists = false;
|
|
176
|
-
}
|
|
171
|
+
const reviewExists = await phaseArtifactExists("audit");
|
|
172
|
+
const auditExists = await fileExists(`${artifactDir}/audit.md`);
|
|
177
173
|
if (!reviewExists || !auditExists) {
|
|
178
174
|
return {
|
|
179
175
|
status: "terminal",
|
|
@@ -221,14 +217,8 @@ async function endWorkflow(
|
|
|
221
217
|
phase,
|
|
222
218
|
};
|
|
223
219
|
}
|
|
224
|
-
const reviewExists = await phaseArtifactExists(
|
|
225
|
-
|
|
226
|
-
try {
|
|
227
|
-
auditExists =
|
|
228
|
-
(await pi.exec("test", ["-f", `${artifactDir}/audit.md`])).code === 0;
|
|
229
|
-
} catch {
|
|
230
|
-
auditExists = false;
|
|
231
|
-
}
|
|
220
|
+
const reviewExists = await phaseArtifactExists("audit");
|
|
221
|
+
const auditExists = await fileExists(`${artifactDir}/audit.md`);
|
|
232
222
|
if (!reviewExists || !auditExists) {
|
|
233
223
|
return {
|
|
234
224
|
ok: false,
|
|
@@ -369,7 +359,7 @@ async function beginWorkflow(
|
|
|
369
359
|
userPrompt = goal.trim();
|
|
370
360
|
// ponytail: 1 workflow = 1 folder under ./.selesai/artifacts/. Timestamp prefix avoids collisions.
|
|
371
361
|
artifactDir = artifactPathFor(userPrompt);
|
|
372
|
-
await
|
|
362
|
+
await mkdir(artifactDir, { recursive: true });
|
|
373
363
|
active = true;
|
|
374
364
|
setPhase(pi, "grilling");
|
|
375
365
|
updateFooter(pi, ctx);
|
|
@@ -622,7 +612,7 @@ export default function prototypeExtension(pi: ExtensionAPI): void {
|
|
|
622
612
|
// phaseArtifactExists and both advance the phase.
|
|
623
613
|
advancing = true;
|
|
624
614
|
try {
|
|
625
|
-
if (!(await phaseArtifactExists(
|
|
615
|
+
if (!(await phaseArtifactExists(phase))) return;
|
|
626
616
|
autoArmed = false;
|
|
627
617
|
dbg("artifact detected", { phase, artifactDir, expected });
|
|
628
618
|
const from = phase;
|