omp-auto-loop 0.2.2 → 0.2.4

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/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from "@oh-my-pi/pi-coding-agent";
2
2
  import { buildPrompt, emptyState, getSystemPromptAddition, type LoopState, updateWidget } from "./state.ts";
3
+
3
4
  import { getLoopControlToolDefinition, handleLoopControlTool, renderLoopControlCall, renderLoopControlResult } from "./tool.ts";
4
5
 
5
6
  export default function (pi: ExtensionAPI) {
@@ -61,19 +62,21 @@ export default function (pi: ExtensionAPI) {
61
62
 
62
63
  if (state.nextScheduled) {
63
64
  state.nextScheduled = false;
65
+ pi.sendMessage(
66
+ { customType: "loop-iteration", content: buildPrompt(state), display: false },
67
+ { triggerTurn: true, deliverAs: "nextTurn" }
68
+ );
64
69
  return;
65
70
  }
66
71
 
67
72
  // Fallback: LLM stopped without calling loop_control or confirming done
68
73
  state.currentStep++;
69
74
  updateWidget(state, ctx);
70
- setTimeout(() => {
71
- pi.sendMessage({
72
- customType: "loop-fallback",
73
- content: "You stopped without calling `loop_control`. If the task is incomplete, continue working. If done, call `loop_control` with status 'done'.",
74
- display: false
75
- }, { triggerTurn: true, deliverAs: "steer" });
76
- }, 100);
75
+ pi.sendMessage({
76
+ customType: "loop-fallback",
77
+ content: "You stopped without calling `loop_control`. If the task is incomplete, continue working. If done, call `loop_control` with status 'done'.",
78
+ display: false
79
+ }, { triggerTurn: true, deliverAs: "nextTurn" });
77
80
  });
78
81
 
79
82
  pi.registerTool({
@@ -84,15 +87,15 @@ export default function (pi: ExtensionAPI) {
84
87
  updateWidget(state, ctx);
85
88
  return { content: result.content, details: result.details };
86
89
  },
87
- renderCall: renderLoopControlCall as any,
88
- renderResult: renderLoopControlResult as any,
89
- });
90
-
91
- const stopLoop = (ctx: ExtensionContext, reason: string) => {
92
- if (!state.active) {
93
- ctx.ui.notify("No active loop", "info");
94
- return;
95
- }
90
+ renderCall: renderLoopControlCall as any,
91
+ renderResult: renderLoopControlResult as any,
92
+ });
93
+
94
+ const stopLoop = (ctx: ExtensionContext, reason: string) => {
95
+ if (!state.active) {
96
+ ctx.ui.notify("No active loop", "info");
97
+ return;
98
+ }
96
99
  state.active = false;
97
100
  state.done = true;
98
101
  state.reasonDone = reason;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-auto-loop",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "General-purpose auto agent loop plugin for omp.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/state.ts CHANGED
@@ -25,15 +25,13 @@ export function buildPrompt(state: LoopState): string {
25
25
 
26
26
  export function updateWidget(state: LoopState, ctx: ExtensionContext) {
27
27
  if (!state.active) {
28
- ctx.ui.setStatus("loop", undefined);
29
28
  ctx.ui.setWidget("loop", undefined);
30
29
  return;
31
30
  }
32
31
  const label = `iteration ${state.currentStep + 1}`;
33
- ctx.ui.setStatus("loop", `🔄 ${label}`);
34
32
  ctx.ui.setWidget("loop", [
35
33
  `┌─ Loop ──────────`,
36
- `│ ${label}`,
34
+ `│ 🔄 ${label}`,
37
35
  `└─ Ctrl+Shift+X to stop ─`,
38
36
  ]);
39
37
  }
package/tool.ts CHANGED
@@ -33,9 +33,6 @@ export function handleLoopControlTool(opts: {
33
33
  }
34
34
 
35
35
  const newState = { ...state, currentStep: state.currentStep + 1, confirmingDone: false, nextScheduled: true };
36
- setTimeout(() => {
37
- pi.sendMessage({ customType: "loop-iteration", content: buildPrompt(newState), display: false }, { triggerTurn: true, deliverAs: "steer" });
38
- }, 100);
39
36
 
40
37
  return {
41
38
  content: [{ type: "text", text: `→ Advancing to step ${newState.currentStep + 1}. Summary: ${params.summary}` }],
@@ -57,8 +54,15 @@ export function getLoopControlToolDefinition() {
57
54
  };
58
55
  }
59
56
 
60
- export function renderLoopControlCall(args: { status: string }, theme: any) {
61
- return new Text(theme.fg("toolTitle", theme.bold("loop_control ")) + theme.fg(args.status === "done" ? "success" : "accent", args.status), 0, 0);
57
+ export function renderLoopControlCall(args: { status: string; summary?: string; reason?: string }, theme: any) {
58
+ let text = theme.fg("toolTitle", theme.bold("loop_control ")) + theme.fg(args.status === "done" ? "success" : "accent", args.status);
59
+ if (args.summary) {
60
+ text += `\n${theme.dim("Summary: ")}${args.summary}`;
61
+ }
62
+ if (args.reason) {
63
+ text += `\n${theme.dim("Reason: ")}${args.reason}`;
64
+ }
65
+ return new Text(text, 0, 0);
62
66
  }
63
67
 
64
68
  export function renderLoopControlResult(result: { details?: LoopState }, _opts: unknown, theme: any) {
package/test-run.ts DELETED
@@ -1,2 +0,0 @@
1
- import { loadExtensions } from "@oh-my-pi/pi-coding-agent/src/extensibility/extensions/loader";
2
- console.log("loader available");