@comfanion/usethis_todo 0.1.15-dev.2 → 0.1.15-dev.3

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 (3) hide show
  1. package/index.ts +8 -33
  2. package/package.json +1 -1
  3. package/tools.ts +1 -15
package/index.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { Plugin } from "@opencode-ai/plugin"
2
- import path from "path"
3
- import fs from "fs/promises"
4
2
 
5
- import { write, read, read_five, read_by_id, update, setNativeStorageBase } from "./tools"
3
+ import { write, read, read_five, read_by_id, update } from "./tools"
6
4
 
7
5
  interface TodoPruneState {
8
6
  lastToolCallId: string | null
@@ -19,18 +17,6 @@ const UsethisTodoPlugin: Plugin = async ({ directory, client }) => {
19
17
  // ignore
20
18
  }
21
19
 
22
- // Resolve native storage path (non-blocking — MUST NOT await in init)
23
- client.path.get().then((res) => {
24
- try {
25
- const state = (res as any)?.data?.state
26
- if (state && typeof state === "string") {
27
- setNativeStorageBase(state)
28
- }
29
- } catch {
30
- // ignore
31
- }
32
- }).catch(() => {})
33
-
34
20
  return {
35
21
  "experimental.chat.messages.transform": async (_input: unknown, output: { messages: any[] }) => {
36
22
  const messages = output.messages || []
@@ -141,28 +127,17 @@ const UsethisTodoPlugin: Plugin = async ({ directory, client }) => {
141
127
  output.title = "📋 Task details"
142
128
  }
143
129
 
144
- // Only publish for our write/update tools
145
- const writeTools = new Set([
130
+ // Publish snapshot into chat (helps when sidebar doesn't refresh)
131
+ const publishTools = new Set([
146
132
  "usethis_todo_write",
147
133
  "usethis_todo_update",
134
+ "usethis_todo_read",
135
+ "usethis_todo_read_five",
136
+ "usethis_todo_read_by_id",
148
137
  ])
149
138
 
150
- if (!writeTools.has(input.tool)) return
151
-
152
- // Attempt sidebar refresh via tui.command.execute hack
153
- // The server may recognize a command that forces re-read of todo storage
154
- try {
155
- await (client as any)?.tui?.publish?.({
156
- body: {
157
- type: "tui.command.execute",
158
- properties: { command: "session.todo.refresh" },
159
- },
160
- })
161
- } catch {
162
- // ignore — experimental
163
- }
139
+ if (!publishTools.has(input.tool)) return
164
140
 
165
- // Fallback: publish snapshot into chat (helps when sidebar doesn't refresh)
166
141
  const text = ["## TODO", "", out].join("\n")
167
142
 
168
143
  try {
@@ -180,4 +155,4 @@ const UsethisTodoPlugin: Plugin = async ({ directory, client }) => {
180
155
  }
181
156
  }
182
157
 
183
- export default UsethisTodoPlugin;
158
+ export default UsethisTodoPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comfanion/usethis_todo",
3
- "version": "0.1.15-dev.2",
3
+ "version": "0.1.15-dev.3",
4
4
  "description": "OpenCode plugin: enhanced TODO tools (dual storage + dependency graph)",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/tools.ts CHANGED
@@ -111,13 +111,6 @@ interface TodoGraph {
111
111
  // Storage — dual write
112
112
  // ============================================================================
113
113
 
114
- // Native storage base path (resolved from client.path.get() at runtime)
115
- let nativeStorageBase: string | null = null
116
-
117
- export function setNativeStorageBase(statePath: string): void {
118
- nativeStorageBase = statePath
119
- }
120
-
121
114
  // Resolve project directory (context.directory may be undefined via MCP)
122
115
  function dir(directory?: string): string {
123
116
  return directory || process.env.OPENCODE_PROJECT_DIR || process.cwd()
@@ -164,15 +157,8 @@ async function getNativeDataDirs(): Promise<string[]> {
164
157
  }
165
158
 
166
159
  async function getNativePaths(sid: string): Promise<string[]> {
167
- const file = `${sid || "current"}.json`
168
-
169
- // Prefer resolved path from client.path.get()
170
- if (nativeStorageBase) {
171
- return [path.join(nativeStorageBase, "storage", "todo", file)]
172
- }
173
-
174
- // Fallback to guessed paths
175
160
  const baseDirs = await getNativeDataDirs()
161
+ const file = `${sid || "current"}.json`
176
162
  return baseDirs.map((base) => path.join(base, "opencode", "storage", "todo", file))
177
163
  }
178
164