@trevonistrevon/pi-loop 0.5.7 → 0.5.8

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.
Files changed (53) hide show
  1. package/coverage/coverage-final.json +23 -23
  2. package/coverage/index.html +39 -39
  3. package/coverage/src/commands/index.html +1 -1
  4. package/coverage/src/commands/loop-command.ts.html +1 -1
  5. package/coverage/src/commands/tasks-command.ts.html +1 -1
  6. package/coverage/src/coordinator.ts.html +20 -20
  7. package/coverage/src/goal-coordinator.ts.html +1 -1
  8. package/coverage/src/goal-reducer.ts.html +1 -1
  9. package/coverage/src/goal-store.ts.html +1 -1
  10. package/coverage/src/goal-verifier.ts.html +1 -1
  11. package/coverage/src/index.html +33 -33
  12. package/coverage/src/index.ts.html +16 -16
  13. package/coverage/src/loop-parse.ts.html +62 -62
  14. package/coverage/src/loop-reducer.ts.html +21 -21
  15. package/coverage/src/monitor-completion-coordinator.ts.html +3 -3
  16. package/coverage/src/monitor-manager.ts.html +75 -69
  17. package/coverage/src/monitor-reducer.ts.html +28 -28
  18. package/coverage/src/notification-reducer.ts.html +6 -6
  19. package/coverage/src/reducer-backed-store.ts.html +28 -28
  20. package/coverage/src/runtime/index.html +45 -45
  21. package/coverage/src/runtime/monitor-ondone-runtime.ts.html +39 -39
  22. package/coverage/src/runtime/notification-runtime.ts.html +15 -15
  23. package/coverage/src/runtime/scope.ts.html +34 -34
  24. package/coverage/src/runtime/session-runtime.ts.html +58 -52
  25. package/coverage/src/runtime/task-backlog-runtime.ts.html +48 -48
  26. package/coverage/src/runtime/task-rpc.ts.html +80 -80
  27. package/coverage/src/scheduler.ts.html +35 -35
  28. package/coverage/src/store.ts.html +24 -24
  29. package/coverage/src/task-backlog-coordinator.ts.html +8 -8
  30. package/coverage/src/task-reducer.ts.html +39 -39
  31. package/coverage/src/task-store.ts.html +55 -55
  32. package/coverage/src/tools/index.html +43 -43
  33. package/coverage/src/tools/loop-tools.ts.html +94 -94
  34. package/coverage/src/tools/monitor-tools.ts.html +53 -53
  35. package/coverage/src/tools/native-task-tools.ts.html +66 -66
  36. package/coverage/src/trigger-system.ts.html +1 -1
  37. package/coverage/src/ui/index.html +1 -1
  38. package/coverage/src/ui/widget.ts.html +1 -1
  39. package/dist/commands/tasks-command.js +12 -9
  40. package/dist/monitor-manager.js +3 -1
  41. package/dist/runtime/session-runtime.js +3 -1
  42. package/dist/runtime/task-events.d.ts +15 -0
  43. package/dist/runtime/task-events.js +13 -0
  44. package/dist/runtime/task-rpc.js +2 -0
  45. package/dist/tools/native-task-tools.js +20 -9
  46. package/package.json +1 -1
  47. package/src/commands/tasks-command.ts +9 -9
  48. package/src/monitor-manager.ts +3 -1
  49. package/src/runtime/session-runtime.ts +3 -1
  50. package/src/runtime/task-events.ts +41 -0
  51. package/src/runtime/task-rpc.ts +2 -0
  52. package/src/tools/native-task-tools.ts +16 -9
  53. package/vitest.config.ts +7 -7
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import { Type } from "typebox";
3
+ import { emitNativeTaskEvent } from "../runtime/task-events.js";
3
4
  import { TaskStore } from "../task-store.js";
4
5
 
5
6
  export interface TaskBacklogResult {
@@ -47,12 +48,7 @@ Fields:
47
48
  }),
48
49
  async execute(_toolCallId, params) {
49
50
  const entry = taskStore.create(params.subject, params.description);
50
- pi.events.emit("tasks:created", {
51
- taskId: entry.id,
52
- subject: entry.subject,
53
- description: entry.description,
54
- status: entry.status,
55
- });
51
+ emitNativeTaskEvent(pi, "tasks:created", entry);
56
52
  const backlog = await evaluateTaskBacklog(taskStore, taskStore.pendingCount());
57
53
  updateWidget();
58
54
 
@@ -111,13 +107,22 @@ Parameters: id (required), status, subject, description`,
111
107
  let entry = taskStore.get(id);
112
108
  if (!entry) return Promise.resolve(textResult(`Task #${id} not found`));
113
109
 
114
- if (status === "in_progress") entry = taskStore.start(id);
115
- else if (status === "completed") entry = taskStore.complete(id);
116
- else if (status === "pending") entry = taskStore.reopen(id);
110
+ const previousStatus = entry.status;
111
+ if (status === "in_progress") {
112
+ entry = taskStore.start(id);
113
+ if (entry) emitNativeTaskEvent(pi, "tasks:started", entry, previousStatus);
114
+ } else if (status === "completed") {
115
+ entry = taskStore.complete(id);
116
+ if (entry) emitNativeTaskEvent(pi, "tasks:completed", entry, previousStatus);
117
+ } else if (status === "pending") {
118
+ entry = taskStore.reopen(id);
119
+ if (entry) emitNativeTaskEvent(pi, "tasks:reopened", entry, previousStatus);
120
+ }
117
121
 
118
122
  if (!entry) return Promise.resolve(textResult(`Task #${id} not found`));
119
123
  if (subject !== undefined || description !== undefined) {
120
124
  entry = taskStore.updateDetails(id, { subject, description });
125
+ if (entry) emitNativeTaskEvent(pi, "tasks:updated", entry, previousStatus);
121
126
  }
122
127
  if (!entry) return Promise.resolve(textResult(`Task #${id} not found`));
123
128
  updateWidget();
@@ -138,9 +143,11 @@ Parameters: id (required), status, subject, description`,
138
143
  id: Type.String({ description: "Task ID to delete" }),
139
144
  }),
140
145
  async execute(_toolCallId, params) {
146
+ const existing = taskStore.get(params.id);
141
147
  const deleted = taskStore.delete(params.id);
142
148
  updateWidget();
143
149
  if (deleted) {
150
+ if (existing) emitNativeTaskEvent(pi, "tasks:deleted", existing, existing.status);
144
151
  await evaluateTaskBacklog(taskStore, taskStore.pendingCount());
145
152
  return Promise.resolve(textResult(`Task #${params.id} deleted`));
146
153
  }
package/vitest.config.ts CHANGED
@@ -11,14 +11,14 @@ export default defineConfig({
11
11
  include: ["src/**/*.ts"],
12
12
  // Type-only modules and test helpers carry no executable logic worth gating.
13
13
  exclude: ["src/**/*-types.ts", "src/types.ts"],
14
- // Floors set just below current actuals (stmts 80%, branches 69.5%,
15
- // funcs 92.5%, lines 82.9%) to catch regressions. Ratchet up as the
16
- // runtime/ and tools/ suites land in Phase 4.
14
+ // Floors set just below current actuals (stmts 84%, branches 75%,
15
+ // funcs 95%, lines 86%) to catch regressions. Raised in Phase 4 after the
16
+ // runtime/ + tools/ suites landed.
17
17
  thresholds: {
18
- statements: 78,
19
- branches: 67,
20
- functions: 90,
21
- lines: 80,
18
+ statements: 82,
19
+ branches: 73,
20
+ functions: 94,
21
+ lines: 84,
22
22
  },
23
23
  },
24
24
  },