@encoredigitalgroup/opencode 0.2.11 → 0.2.12

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.
@@ -346,15 +346,22 @@ class TodoTrackerEnforcement {
346
346
  return existing;
347
347
  }
348
348
  const state = trackerStateFromMessages(await this.context.session.context({ sessionID }));
349
+ const current = this.states.get(sessionID);
350
+ if (current !== undefined) {
351
+ return current;
352
+ }
349
353
  this.states.set(sessionID, state);
350
354
  return state;
351
355
  }
352
- async requireTrackerRefresh(sessionID) {
356
+ async requireTrackerRefresh(sessionID, completedAt) {
353
357
  const state = await this.stateFor(sessionID);
354
- if (state.kind === "tracked") {
358
+ if (state.kind === "tracked" && state.refreshedAt < completedAt) {
355
359
  state.refreshRequired = true;
356
360
  }
357
361
  }
362
+ recordTrackerUpdate(sessionID, todos) {
363
+ this.states.set(sessionID, stateFromTodoResult({ todos }, JSON.stringify(todos)));
364
+ }
358
365
  async register(enforceRefresh) {
359
366
  let before;
360
367
  let after;
@@ -421,7 +428,7 @@ class TodoTrackerEnforcement {
421
428
  }
422
429
  const session = await this.context.session.get({ sessionID: event.data.sessionID });
423
430
  if (session.parentID !== undefined) {
424
- await this.requireTrackerRefresh(session.parentID);
431
+ await this.requireTrackerRefresh(session.parentID, event.created);
425
432
  }
426
433
  }
427
434
  } catch (error) {
@@ -454,26 +461,28 @@ class TodoTracker {
454
461
  return [...todos.slice(0, -1), { ...finalTodo, status: "completed" }];
455
462
  }
456
463
  static async register(context, config) {
464
+ const enforcement = new TodoTrackerEnforcement(context);
457
465
  const tool = await context.tool.transform((tools) => {
458
466
  tools.add({
459
467
  name: todoTrackerName,
460
468
  description: todoTrackerDescription,
461
469
  input: todoTrackerInput,
462
470
  options: { codemode: false },
463
- async execute(input) {
471
+ async execute(input, executionContext) {
464
472
  if (!isTodoTrackerInput(input)) {
465
473
  throw new Error("Invalid todotracker input.");
466
474
  }
475
+ enforcement.recordTrackerUpdate(executionContext.sessionID, input.todos);
467
476
  return { content: JSON.stringify(input.todos), metadata: { todos: input.todos } };
468
477
  }
469
478
  });
470
479
  });
471
480
  try {
472
- const enforcement = await new TodoTrackerEnforcement(context).register(config.enforceTodoTracker);
481
+ const registration = await enforcement.register(config.enforceTodoTracker);
473
482
  return {
474
483
  dispose: async () => {
475
484
  try {
476
- await enforcement.dispose();
485
+ await registration.dispose();
477
486
  } finally {
478
487
  await tool.dispose();
479
488
  }
package/dist/tui/index.js CHANGED
@@ -6845,15 +6845,22 @@ class TodoTrackerEnforcement {
6845
6845
  return existing;
6846
6846
  }
6847
6847
  const state = trackerStateFromMessages(await this.context.session.context({ sessionID }));
6848
+ const current = this.states.get(sessionID);
6849
+ if (current !== undefined) {
6850
+ return current;
6851
+ }
6848
6852
  this.states.set(sessionID, state);
6849
6853
  return state;
6850
6854
  }
6851
- async requireTrackerRefresh(sessionID) {
6855
+ async requireTrackerRefresh(sessionID, completedAt) {
6852
6856
  const state = await this.stateFor(sessionID);
6853
- if (state.kind === "tracked") {
6857
+ if (state.kind === "tracked" && state.refreshedAt < completedAt) {
6854
6858
  state.refreshRequired = true;
6855
6859
  }
6856
6860
  }
6861
+ recordTrackerUpdate(sessionID, todos) {
6862
+ this.states.set(sessionID, stateFromTodoResult({ todos }, JSON.stringify(todos)));
6863
+ }
6857
6864
  async register(enforceRefresh) {
6858
6865
  let before;
6859
6866
  let after;
@@ -6920,7 +6927,7 @@ class TodoTrackerEnforcement {
6920
6927
  }
6921
6928
  const session = await this.context.session.get({ sessionID: event.data.sessionID });
6922
6929
  if (session.parentID !== undefined) {
6923
- await this.requireTrackerRefresh(session.parentID);
6930
+ await this.requireTrackerRefresh(session.parentID, event.created);
6924
6931
  }
6925
6932
  }
6926
6933
  } catch (error) {
@@ -6953,26 +6960,28 @@ class TodoTracker {
6953
6960
  return [...todos.slice(0, -1), { ...finalTodo, status: "completed" }];
6954
6961
  }
6955
6962
  static async register(context, config) {
6963
+ const enforcement = new TodoTrackerEnforcement(context);
6956
6964
  const tool = await context.tool.transform((tools) => {
6957
6965
  tools.add({
6958
6966
  name: todoTrackerName,
6959
6967
  description: todoTrackerDescription,
6960
6968
  input: todoTrackerInput,
6961
6969
  options: { codemode: false },
6962
- async execute(input) {
6970
+ async execute(input, executionContext) {
6963
6971
  if (!isTodoTrackerInput(input)) {
6964
6972
  throw new Error("Invalid todotracker input.");
6965
6973
  }
6974
+ enforcement.recordTrackerUpdate(executionContext.sessionID, input.todos);
6966
6975
  return { content: JSON.stringify(input.todos), metadata: { todos: input.todos } };
6967
6976
  }
6968
6977
  });
6969
6978
  });
6970
6979
  try {
6971
- const enforcement = await new TodoTrackerEnforcement(context).register(config.enforceTodoTracker);
6980
+ const registration = await enforcement.register(config.enforceTodoTracker);
6972
6981
  return {
6973
6982
  dispose: async () => {
6974
6983
  try {
6975
- await enforcement.dispose();
6984
+ await registration.dispose();
6976
6985
  } finally {
6977
6986
  await tool.dispose();
6978
6987
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@encoredigitalgroup/opencode",
3
3
  "type": "module",
4
- "version": "0.2.11",
4
+ "version": "0.2.12",
5
5
  "description": "OpenCode planning pickers, a todo tracker, and a quota sidebar.",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -22,13 +22,13 @@
22
22
  "solid-js": "1.9.12"
23
23
  },
24
24
  "devDependencies": {
25
- "@opencode/cli": "2.1.4",
26
- "@opencode/client": "2.1.4",
27
- "@opencode/plugin": "2.1.4",
25
+ "@opencode/cli": "2.3.0",
26
+ "@opencode/client": "2.3.0",
27
+ "@opencode/plugin": "2.3.0",
28
28
  "@opentui/core": "0.5.14",
29
29
  "@types/node": "^22.20.5",
30
30
  "@types/bun": "1.4.0",
31
- "tsfmt": "^0.3.0-beta9",
31
+ "tsfmt": "0.3.0-beta15",
32
32
  "typescript": "5.8.2"
33
33
  },
34
34
  "scripts": {