@comfanion/usethis_todo 0.1.2 → 0.1.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 +1 -5
- package/package.json +1 -1
- package/tools.ts +20 -2
package/index.ts
CHANGED
|
@@ -2,9 +2,6 @@ import type { Plugin } from "@opencode-ai/plugin"
|
|
|
2
2
|
|
|
3
3
|
import { write, read, read_five, read_by_id, update } from "./tools"
|
|
4
4
|
|
|
5
|
-
// Re-export tools for programmatic use/tests
|
|
6
|
-
export { write, read, read_five, read_by_id, update } from "./tools"
|
|
7
|
-
|
|
8
5
|
const UsethisTodoPlugin: Plugin = async ({ client }) => {
|
|
9
6
|
return {
|
|
10
7
|
tool: {
|
|
@@ -65,5 +62,4 @@ const UsethisTodoPlugin: Plugin = async ({ client }) => {
|
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
export default UsethisTodoPlugin;
|
|
69
|
-
export { UsethisTodoPlugin };
|
|
65
|
+
export default UsethisTodoPlugin;
|
package/package.json
CHANGED
package/tools.ts
CHANGED
|
@@ -66,7 +66,17 @@ function dir(directory?: string): string {
|
|
|
66
66
|
|
|
67
67
|
// Enhanced storage path (project-local)
|
|
68
68
|
function getEnhancedPath(sid: string, directory?: string): string {
|
|
69
|
-
return path.join(dir(directory), ".opencode", "session-
|
|
69
|
+
return path.join(dir(directory), ".opencode", "session-todo", `${sid || "current"}.json`)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function logAction(directory: string, action: string, details: string): Promise<void> {
|
|
73
|
+
try {
|
|
74
|
+
const logPath = path.join(dir(directory), ".opencode", "todo.log")
|
|
75
|
+
const timestamp = new Date().toISOString()
|
|
76
|
+
await fs.appendFile(logPath, `[${timestamp}] ${action.toUpperCase()}: ${details}\n`)
|
|
77
|
+
} catch {
|
|
78
|
+
// ignore
|
|
79
|
+
}
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
async function getNativeDataDirs(): Promise<string[]> {
|
|
@@ -419,6 +429,7 @@ export const write = tool({
|
|
|
419
429
|
const now = Date.now()
|
|
420
430
|
const todos = args.todos.map((t: any) => normalizeTodo({ ...t, createdAt: t.createdAt || now, updatedAt: now }))
|
|
421
431
|
await writeTodos(todos, context.sessionID, context.directory)
|
|
432
|
+
await logAction(context.directory, "write", `Created/Updated ${todos.length} tasks in session ${context.sessionID}`)
|
|
422
433
|
return formatGraph(analyzeGraph(todos))
|
|
423
434
|
},
|
|
424
435
|
})
|
|
@@ -429,6 +440,7 @@ export const read_five = tool({
|
|
|
429
440
|
async execute(_args, context) {
|
|
430
441
|
const todos = await readTodos(context.sessionID, context.directory)
|
|
431
442
|
const ready = sortTodosForList(todos.filter(t => normalizeStatus(t.status) === "todo"))
|
|
443
|
+
await logAction(context.directory, "read_five", `Read next 5 tasks (total ready: ${ready.length})`)
|
|
432
444
|
if (ready.length === 0) return "No tasks in todo."
|
|
433
445
|
|
|
434
446
|
const items = ready.slice(0, 5)
|
|
@@ -463,6 +475,7 @@ export const read = tool({
|
|
|
463
475
|
args: {},
|
|
464
476
|
async execute(_args, context) {
|
|
465
477
|
const todos = await readTodos(context.sessionID, context.directory)
|
|
478
|
+
await logAction(context.directory, "read", `Read all tasks (total: ${todos.length})`)
|
|
466
479
|
if (todos.length === 0) return "No todos. Use usethis_todo_write to create."
|
|
467
480
|
return formatGraph(analyzeGraph(todos))
|
|
468
481
|
},
|
|
@@ -476,9 +489,13 @@ export const read_by_id = tool({
|
|
|
476
489
|
async execute(args, context) {
|
|
477
490
|
const todos = await readTodos(context.sessionID, context.directory)
|
|
478
491
|
const todo = todos.find(t => t.id === args.id)
|
|
479
|
-
if (!todo)
|
|
492
|
+
if (!todo) {
|
|
493
|
+
await logAction(context.directory, "read_by_id", `FAILED: Task ${args.id} not found`)
|
|
494
|
+
return `❌ Task ${args.id} not found`
|
|
495
|
+
}
|
|
480
496
|
|
|
481
497
|
const { blockers, missing } = resolveBlockers(todos, [todo.id])
|
|
498
|
+
await logAction(context.directory, "read_by_id", `Read task ${args.id}`)
|
|
482
499
|
|
|
483
500
|
const lines: string[] = []
|
|
484
501
|
lines.push("Task:")
|
|
@@ -533,6 +550,7 @@ export const update = tool({
|
|
|
533
550
|
|
|
534
551
|
const merged = [...byId.values()]
|
|
535
552
|
await writeTodos(merged, context.sessionID, context.directory)
|
|
553
|
+
await logAction(context.directory, "update", `Updated ${args.todos.length} task(s) in session ${context.sessionID}`)
|
|
536
554
|
return `✅ Updated ${args.todos.length} task(s)\n\n${formatGraph(analyzeGraph(merged))}`
|
|
537
555
|
},
|
|
538
556
|
})
|