oh-pi 0.1.37 → 0.1.38

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-pi",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "One-click setup for pi-coding-agent. Like oh-my-zsh for pi.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -241,21 +241,79 @@ For simple single-file tasks, work directly without the colony.`,
241
241
  const details = result.details as ColonyDetails | undefined;
242
242
 
243
243
  // ─── 运行中 ───
244
- if (!details?.state) {
244
+ if (!details?.state || (details.state.status !== "done" && details.state.status !== "failed")) {
245
+ const state = details?.state;
245
246
  const log = details?.log ?? [];
246
247
  const container = new Container();
247
- container.addChild(new Text(
248
- theme.fg("warning", "🐜 ") + theme.fg("toolTitle", theme.bold("Colony ")) +
249
- theme.fg("accent", details?.phase || "initializing..."),
250
- 0, 0,
251
- ));
252
- const recent = log.slice(expanded ? -20 : -5);
253
- if (recent.length > 0) {
254
- container.addChild(new Text(recent.map(l => theme.fg("dim", ` ${l}`)).join("\n"), 0, 0));
248
+
249
+ if (state) {
250
+ const m = state.metrics;
251
+ const elapsed = formatDuration(Date.now() - state.createdAt);
252
+
253
+ // 标题行:● N ants launched (phase)
254
+ const activeAnts = state.ants.filter(a => a.status === "working");
255
+ const totalAnts = state.ants.length;
256
+ container.addChild(new Text(
257
+ theme.fg("warning", "● ") +
258
+ theme.fg("toolTitle", theme.bold(`${totalAnts} ant${totalAnts !== 1 ? "s" : ""} launched `)) +
259
+ theme.fg("muted", `(${state.status}) `) +
260
+ theme.fg("dim", `${elapsed} │ ${formatCost(m.totalCost)}`),
261
+ 0, 0,
262
+ ));
263
+
264
+ // 进度条
265
+ if (m.tasksTotal > 0) {
266
+ container.addChild(new Text(` ${progressBar(m.tasksDone, m.tasksTotal, 20, theme)}`, 0, 0));
267
+ }
268
+
269
+ // 蚂蚁树
270
+ const ants = expanded ? state.ants : state.ants.slice(-8);
271
+ for (let i = 0; i < ants.length; i++) {
272
+ const a = ants[i];
273
+ const isLast = i === ants.length - 1;
274
+ const branch = isLast ? "└─" : "├─";
275
+ const pipe = isLast ? " " : "│ ";
276
+
277
+ const statusDot = a.status === "working" ? theme.fg("warning", "◉")
278
+ : a.status === "done" ? theme.fg("success", "✓")
279
+ : theme.fg("error", "✗");
280
+
281
+ const task = state.tasks.find(t => t.id === a.taskId);
282
+ const taskTitle = task?.title?.slice(0, 55) || "...";
283
+ const dur = a.finishedAt ? formatDuration(a.finishedAt - a.startedAt) : formatDuration(Date.now() - a.startedAt);
284
+ const turns = a.usage.turns > 0 ? `${a.usage.turns}t` : "";
285
+
286
+ container.addChild(new Text(
287
+ theme.fg("muted", ` ${branch} `) + statusDot + " " +
288
+ theme.fg("accent", `@${a.id.slice(0, 20)} `) +
289
+ theme.fg("dim", `(${a.caste}) ${dur}${turns ? " │ " + turns : ""}`),
290
+ 0, 0,
291
+ ));
292
+ container.addChild(new Text(
293
+ theme.fg("muted", ` ${pipe}`) + theme.fg("dim", `⎿ ${taskTitle}`),
294
+ 0, 0,
295
+ ));
296
+ }
297
+ if (!expanded && state.ants.length > 8) {
298
+ container.addChild(new Text(theme.fg("muted", ` ⋯ +${state.ants.length - 8} more (expand to see all)`), 0, 0));
299
+ }
300
+ } else {
301
+ container.addChild(new Text(
302
+ theme.fg("warning", "● ") + theme.fg("toolTitle", theme.bold("Colony ")) +
303
+ theme.fg("accent", details?.phase || "initializing..."),
304
+ 0, 0,
305
+ ));
255
306
  }
256
- if (!expanded && log.length > 5) {
257
- container.addChild(new Text(theme.fg("muted", ` ⋯ ${log.length - 5} more`), 0, 0));
307
+
308
+ // 最近日志(仅展开时)
309
+ if (expanded && log.length > 0) {
310
+ container.addChild(new Spacer(1));
311
+ const recent = log.slice(-10);
312
+ for (const l of recent) {
313
+ container.addChild(new Text(theme.fg("dim", ` ${l}`), 0, 0));
314
+ }
258
315
  }
316
+
259
317
  return container;
260
318
  }
261
319