2026-02-10 14:53:39 +09:00
|
|
|
# CLAUDE TASKS KNOWLEDGE BASE
|
2026-02-01 22:42:28 +09:00
|
|
|
|
|
|
|
|
## OVERVIEW
|
|
|
|
|
|
2026-02-16 15:26:53 +09:00
|
|
|
Claude Code compatible task schema and storage. Core task management with file-based persistence, atomic writes, and OpenCode todo sync.
|
2026-02-01 22:42:28 +09:00
|
|
|
|
|
|
|
|
## STRUCTURE
|
|
|
|
|
```
|
|
|
|
|
claude-tasks/
|
2026-02-09 14:29:53 +09:00
|
|
|
├── types.ts # Task schema (Zod)
|
2026-02-10 14:53:39 +09:00
|
|
|
├── types.test.ts # Schema validation tests
|
|
|
|
|
├── storage.ts # File operations (atomic write, locking)
|
2026-02-09 14:29:53 +09:00
|
|
|
├── storage.test.ts # Storage tests (30 tests, 543 lines)
|
|
|
|
|
├── session-storage.ts # Session-scoped task storage
|
|
|
|
|
├── session-storage.test.ts
|
|
|
|
|
└── index.ts # Barrel exports
|
2026-02-01 22:42:28 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## TASK SCHEMA
|
|
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
|
type TaskStatus = "pending" | "in_progress" | "completed" | "deleted"
|
|
|
|
|
interface Task {
|
2026-02-10 14:53:39 +09:00
|
|
|
id: string // T-{uuid}
|
|
|
|
|
subject: string // Imperative: "Run tests"
|
2026-02-01 22:42:28 +09:00
|
|
|
description: string
|
|
|
|
|
status: TaskStatus
|
2026-02-10 14:53:39 +09:00
|
|
|
activeForm?: string // Present continuous: "Running tests"
|
|
|
|
|
blocks: string[] // Task IDs this task blocks
|
|
|
|
|
blockedBy: string[] // Task IDs blocking this task
|
|
|
|
|
owner?: string // Agent name
|
2026-02-01 22:42:28 +09:00
|
|
|
metadata?: Record<string, unknown>
|
2026-02-10 14:53:39 +09:00
|
|
|
repoURL?: string
|
|
|
|
|
parentID?: string
|
|
|
|
|
threadID?: string
|
2026-02-01 22:42:28 +09:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## STORAGE UTILITIES
|
|
|
|
|
|
2026-02-06 18:59:58 +09:00
|
|
|
| Function | Purpose |
|
|
|
|
|
|----------|---------|
|
2026-02-10 14:53:39 +09:00
|
|
|
| `getTaskDir(config)` | Task storage directory path |
|
|
|
|
|
| `resolveTaskListId(config)` | Task list ID (env → config → cwd) |
|
|
|
|
|
| `readJsonSafe(path, schema)` | Parse + validate, null on failure |
|
|
|
|
|
| `writeJsonAtomic(path, data)` | Atomic write via temp + rename |
|
|
|
|
|
| `acquireLock(dirPath)` | File lock with 30s stale threshold |
|
|
|
|
|
| `generateTaskId()` | `T-{uuid}` format |
|
|
|
|
|
| `findTaskAcrossSessions(config, taskId)` | Locate task in any session |
|
2026-02-01 22:42:28 +09:00
|
|
|
|
2026-02-10 16:43:54 +09:00
|
|
|
## TODO SYNC
|
|
|
|
|
|
2026-02-16 15:26:53 +09:00
|
|
|
Automatic bidirectional sync between tasks and OpenCode's todo system.
|
2026-02-10 16:43:54 +09:00
|
|
|
|
|
|
|
|
| Task Status | Todo Status |
|
|
|
|
|
|-------------|-------------|
|
|
|
|
|
| `pending` | `pending` |
|
|
|
|
|
| `in_progress` | `in_progress` |
|
|
|
|
|
| `completed` | `completed` |
|
2026-02-16 15:26:53 +09:00
|
|
|
| `deleted` | `null` (removed) |
|
2026-02-10 16:43:54 +09:00
|
|
|
|
2026-02-16 15:26:53 +09:00
|
|
|
Sync triggers: `task_create`, `task_update`.
|
2026-02-10 16:43:54 +09:00
|
|
|
|
2026-02-01 22:42:28 +09:00
|
|
|
## ANTI-PATTERNS
|
|
|
|
|
|
|
|
|
|
- Direct fs operations (use storage utilities)
|
|
|
|
|
- Skipping lock acquisition for writes
|
2026-02-10 14:53:39 +09:00
|
|
|
- Using old field names (title → subject, dependsOn → blockedBy)
|