@oisin-ee/pi-todo 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -28,8 +28,8 @@ and the list stays as it was.
28
28
  ## State
29
29
 
30
30
  Each change is saved as a `todo-state` entry on the session branch. There is no other state. So a resumed session,
31
- a `/tree` move, and calls made from inside codemode all see the list of the current branch. A widget shows the list,
32
- and `/todos` prints it.
31
+ a `/tree` move, and calls made from inside codemode all see the list of the current branch. A widget shows the list
32
+ while it has tasks, and `/todos` prints it.
33
33
 
34
34
  ## Reminder
35
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oisin-ee/pi-todo",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A todo tool for pi with a Rust core: one active task, state on the session branch.",
5
5
  "keywords": [
6
6
  "pi-extension",
@@ -101,6 +101,15 @@ export function parse(snapshot: unknown): TodoList;
101
101
  */
102
102
  export function view(list: TodoList): string;
103
103
 
104
+ /**
105
+ * The widget lines for `list`, or `undefined` for an empty list.
106
+ *
107
+ * # Errors
108
+ *
109
+ * Throws when `list` is not a valid todo list.
110
+ */
111
+ export function widget(list: TodoList): string[] | undefined;
112
+
104
113
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
105
114
 
106
115
  export interface InitOutput {
@@ -110,6 +119,7 @@ export interface InitOutput {
110
119
  readonly init: (a: number, b: number, c: number) => void;
111
120
  readonly parse: (a: number, b: number) => void;
112
121
  readonly view: (a: number, b: number) => void;
122
+ readonly widget: (a: number, b: number) => void;
113
123
  readonly __wbindgen_export: (a: number, b: number) => number;
114
124
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
115
125
  readonly __wbindgen_export3: (a: number) => void;
@@ -147,6 +147,38 @@ export function view(list) {
147
147
  wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
148
148
  }
149
149
  }
150
+
151
+ /**
152
+ * The widget lines for `list`, or `undefined` for an empty list.
153
+ *
154
+ * # Errors
155
+ *
156
+ * Throws when `list` is not a valid todo list.
157
+ * @param {TodoList} list
158
+ * @returns {string[] | undefined}
159
+ */
160
+ export function widget(list) {
161
+ try {
162
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
163
+ wasm.widget(retptr, addBorrowedObject(list));
164
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
165
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
166
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
167
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
168
+ if (r3) {
169
+ throw takeObject(r2);
170
+ }
171
+ let v1;
172
+ if (r0 !== 0) {
173
+ v1 = getArrayJsValueFromWasm0(r0, r1);
174
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
175
+ }
176
+ return v1;
177
+ } finally {
178
+ wasm.__wbindgen_add_to_stack_pointer(16);
179
+ heap[stack_pointer++] = undefined;
180
+ }
181
+ }
150
182
  function __wbg_get_imports() {
151
183
  const import0 = {
152
184
  __proto__: null,
@@ -455,6 +487,16 @@ function dropObject(idx) {
455
487
  heap_next = idx;
456
488
  }
457
489
 
490
+ function getArrayJsValueFromWasm0(ptr, len) {
491
+ ptr = ptr >>> 0;
492
+ const mem = getDataViewMemory0();
493
+ const result = [];
494
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
495
+ result.push(takeObject(mem.getUint32(i, true)));
496
+ }
497
+ return result;
498
+ }
499
+
458
500
  function getArrayU8FromWasm0(ptr, len) {
459
501
  ptr = ptr >>> 0;
460
502
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
Binary file
@@ -6,6 +6,7 @@ export const completion_reminder: (a: number, b: number) => void;
6
6
  export const init: (a: number, b: number, c: number) => void;
7
7
  export const parse: (a: number, b: number) => void;
8
8
  export const view: (a: number, b: number) => void;
9
+ export const widget: (a: number, b: number) => void;
9
10
  export const __wbindgen_export: (a: number, b: number) => number;
10
11
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
11
12
  export const __wbindgen_export3: (a: number) => void;
package/src/lifecycle.ts CHANGED
@@ -5,7 +5,7 @@ import type {
5
5
  SessionEntry,
6
6
  } from "@earendil-works/pi-coding-agent";
7
7
  import { REMINDER_ENTRY, reminder } from "./reminder.ts";
8
- import { parse, view } from "./wasm.ts";
8
+ import { parse, view, widget } from "./wasm.ts";
9
9
  import { isOwnSource } from "./source.ts";
10
10
  import { latestSnapshot } from "./state.ts";
11
11
 
@@ -34,12 +34,12 @@ interface TodoHost {
34
34
  const ownsTodo = (pi: TodoHost): boolean =>
35
35
  pi.getAllTools().some((tool) => tool.name === "todo" && isOwnSource(tool.sourceInfo.path)),
36
36
  /**
37
- * Renders the selected branch snapshot.
37
+ * Renders the selected branch snapshot, and removes the widget when the list is empty.
38
38
  * @param {TodoContext} ctx Branch and UI methods.
39
39
  */
40
40
  replay = (ctx: TodoContext): void => {
41
41
  const list = parse(latestSnapshot(ctx.sessionManager.getBranch()));
42
- ctx.ui.setWidget("pi-todo", view(list).split("\n"));
42
+ ctx.ui.setWidget("pi-todo", widget(list));
43
43
  },
44
44
  /**
45
45
  * Applies the completion decision at pi's final actionable boundary.
package/src/wasm.ts CHANGED
@@ -19,6 +19,7 @@ export {
19
19
  init,
20
20
  parse,
21
21
  view,
22
+ widget,
22
23
  } from "./generated/todo_core.js";
23
24
  export type {
24
25
  Operation,