@workermill/agent 0.1.1 β 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/planner.js +21 -13
- package/package.json +1 -1
package/dist/planner.js
CHANGED
|
@@ -51,14 +51,22 @@ async function postProgress(taskId, phase, elapsedSeconds, detail, charsGenerate
|
|
|
51
51
|
// Fire and forget
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
/** Consistent prefix matching local workermill dashboard format */
|
|
55
|
+
const PREFIX = "[πΊοΈ planning_agent π€]";
|
|
56
|
+
/** Format elapsed seconds as human-readable string (e.g. "28s", "1m 25s") */
|
|
57
|
+
function formatElapsed(seconds) {
|
|
58
|
+
const mins = Math.floor(seconds / 60);
|
|
59
|
+
const secs = seconds % 60;
|
|
60
|
+
return mins > 0 ? `${mins}m ${secs}s` : `${secs}s`;
|
|
61
|
+
}
|
|
54
62
|
function phaseLabel(phase, elapsed) {
|
|
55
63
|
switch (phase) {
|
|
56
|
-
case "initializing": return
|
|
57
|
-
case "reading_repo": return
|
|
58
|
-
case "analyzing": return
|
|
59
|
-
case "generating_plan": return
|
|
60
|
-
case "validating": return
|
|
61
|
-
case "complete": return
|
|
64
|
+
case "initializing": return `${PREFIX} Starting planning agent...`;
|
|
65
|
+
case "reading_repo": return `${PREFIX} Reading repository structure...`;
|
|
66
|
+
case "analyzing": return `${PREFIX} Analyzing requirements...`;
|
|
67
|
+
case "generating_plan": return `${PREFIX} Planning in progress β analyzing requirements and decomposing into steps (${formatElapsed(elapsed)} elapsed)`;
|
|
68
|
+
case "validating": return `${PREFIX} Validating plan...`;
|
|
69
|
+
case "complete": return `${PREFIX} Planning complete`;
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
/**
|
|
@@ -119,7 +127,7 @@ function runClaudeCli(claudePath, model, prompt, env, taskId, startTime) {
|
|
|
119
127
|
// Periodic progress during generation
|
|
120
128
|
if (currentPhase === "generating_plan" && elapsed - lastProgressLogAt >= 30) {
|
|
121
129
|
lastProgressLogAt = elapsed;
|
|
122
|
-
const msg =
|
|
130
|
+
const msg = `${PREFIX} Planning in progress β analyzing requirements and decomposing into steps (${formatElapsed(elapsed)} elapsed)`;
|
|
123
131
|
postLog(taskId, msg);
|
|
124
132
|
console.log(`${ts()} ${taskLabel} ${chalk.dim(msg)}`);
|
|
125
133
|
}
|
|
@@ -217,7 +225,7 @@ function runClaudeCli(claudePath, model, prompt, env, taskId, startTime) {
|
|
|
217
225
|
export async function planTask(task, config) {
|
|
218
226
|
const taskLabel = chalk.cyan(task.id.slice(0, 8));
|
|
219
227
|
console.log(`${ts()} ${taskLabel} Fetching planning prompt...`);
|
|
220
|
-
await postLog(task.id,
|
|
228
|
+
await postLog(task.id, `${PREFIX} Fetching planning prompt from cloud API...`);
|
|
221
229
|
// 1. Fetch the assembled planning prompt from the cloud API
|
|
222
230
|
const promptResponse = await api.get("/api/agent/planning-prompt", {
|
|
223
231
|
params: { taskId: task.id },
|
|
@@ -225,7 +233,7 @@ export async function planTask(task, config) {
|
|
|
225
233
|
const { prompt, model } = promptResponse.data;
|
|
226
234
|
const cliModel = model || "sonnet";
|
|
227
235
|
console.log(`${ts()} ${taskLabel} Running Claude CLI ${chalk.dim(`(model: ${chalk.yellow(cliModel)})`)}`);
|
|
228
|
-
await postLog(task.id,
|
|
236
|
+
await postLog(task.id, `${PREFIX} Starting planning agent using anthropic/${cliModel}`);
|
|
229
237
|
// 2. Run Claude CLI asynchronously with progress logging
|
|
230
238
|
const claudePath = process.env.CLAUDE_CLI_PATH || findClaudePath() || "claude";
|
|
231
239
|
const cleanEnv = { ...process.env };
|
|
@@ -239,12 +247,12 @@ export async function planTask(task, config) {
|
|
|
239
247
|
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
240
248
|
const errMsg = error instanceof Error ? error.message : String(error);
|
|
241
249
|
console.error(`${ts()} ${taskLabel} ${chalk.red("β")} Failed after ${elapsed}s: ${errMsg.substring(0, 100)}`);
|
|
242
|
-
await postLog(task.id,
|
|
250
|
+
await postLog(task.id, `${PREFIX} Planning failed after ${formatElapsed(elapsed)}: ${errMsg.substring(0, 200)}`, "error", "error");
|
|
243
251
|
return false;
|
|
244
252
|
}
|
|
245
253
|
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
246
254
|
console.log(`${ts()} ${taskLabel} ${chalk.green("β")} Claude CLI done ${chalk.dim(`(${elapsed}s, ${rawOutput.length} chars)`)}`);
|
|
247
|
-
await postLog(task.id,
|
|
255
|
+
await postLog(task.id, `${PREFIX} Planning complete (${formatElapsed(elapsed)}). Validating plan...`);
|
|
248
256
|
// 3. Post raw output back to cloud API for validation
|
|
249
257
|
try {
|
|
250
258
|
const result = await api.post("/api/agent/plan-result", {
|
|
@@ -254,7 +262,7 @@ export async function planTask(task, config) {
|
|
|
254
262
|
});
|
|
255
263
|
const storyCount = result.data.storyCount;
|
|
256
264
|
console.log(`${ts()} ${taskLabel} ${chalk.green("β")} Plan validated: ${chalk.bold(storyCount)} stories β ${chalk.green("queued")}`);
|
|
257
|
-
await postLog(task.id,
|
|
265
|
+
await postLog(task.id, `${PREFIX} Plan validated: ${storyCount} stories. Task queued for execution.`);
|
|
258
266
|
await postProgress(task.id, "complete", elapsed, "Planning complete", 0, 0);
|
|
259
267
|
return true;
|
|
260
268
|
}
|
|
@@ -262,7 +270,7 @@ export async function planTask(task, config) {
|
|
|
262
270
|
const err = error;
|
|
263
271
|
const detail = err.response?.data?.detail || String(error);
|
|
264
272
|
console.error(`${ts()} ${taskLabel} ${chalk.red("β")} Validation failed: ${detail.substring(0, 100)}`);
|
|
265
|
-
await postLog(task.id,
|
|
273
|
+
await postLog(task.id, `${PREFIX} Plan validation failed: ${detail.substring(0, 200)}`, "error", "error");
|
|
266
274
|
return false;
|
|
267
275
|
}
|
|
268
276
|
}
|