thought-cabinet 0.0.4 → 0.1.0
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/.thought-cabinet/hooks.example.json +34 -0
- package/.thought-cabinet/hooks.json +14 -0
- package/LICENSE +188 -2
- package/README.md +306 -74
- package/dist/index.js +1295 -608
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/agent-assets/commands/code-simplifier.md +52 -0
package/README.md
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
# Thought Cabinet
|
|
2
2
|
|
|
3
|
-
A CLI tool
|
|
3
|
+
A CLI tool that integrates AI coding agents into structured development workflows through filesystem-based memory and context management.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Why Thought Cabinet?
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
AI coding agents like Claude Code are powerful but face key challenges:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- **Context limits**: Large codebases exceed model context windows
|
|
10
|
+
- **No persistent memory**: Agents forget learnings between sessions
|
|
11
|
+
- **Unstructured work**: Complex tasks benefit from planning before implementation
|
|
12
|
+
- **Isolation**: AI-generated knowledge isn't easily shared with teams
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
14
|
+
Thought Cabinet solves these by providing:
|
|
15
|
+
|
|
16
|
+
- **Context offloading**: Research and plans are saved to disk, freeing model context
|
|
17
|
+
- **Filesystem memory**: Version-controlled thoughts persist across sessions
|
|
18
|
+
- **Structured workflows**: Slash commands guide agents through research → plan → implement → validate
|
|
19
|
+
- **Team sharing**: Thoughts sync via git, enabling knowledge sharing
|
|
20
|
+
|
|
21
|
+
## Core Concepts
|
|
22
|
+
|
|
23
|
+
### Thoughts as Memory
|
|
24
|
+
|
|
25
|
+
The `thoughts/` directory is a filesystem-based memory system for AI agents:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
thoughts/
|
|
29
|
+
├── {user}/ → Personal notes (your learnings, scratchpad)
|
|
30
|
+
├── shared/ → Team-shared knowledge
|
|
31
|
+
│ ├── research/ → Codebase research documents
|
|
32
|
+
│ └── plans/ → Implementation plans
|
|
33
|
+
└── global/ → Cross-repository thoughts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
All thoughts are version-controlled via a dedicated git repository, separate from your code.
|
|
37
|
+
|
|
38
|
+
### Structured Workflows
|
|
39
|
+
|
|
40
|
+
Instead of asking an AI to "implement feature X" directly, Thought Cabinet encourages a disciplined workflow:
|
|
41
|
+
|
|
42
|
+
1. **Research** → Understand the codebase deeply
|
|
43
|
+
2. **Plan** → Design the implementation with explicit phases
|
|
44
|
+
3. **Implement** → Execute the plan systematically
|
|
45
|
+
4. **Validate** → Verify against success criteria
|
|
46
|
+
|
|
47
|
+
### Worktree Isolation
|
|
48
|
+
|
|
49
|
+
Each feature gets its own git worktree with a dedicated tmux session, enabling:
|
|
50
|
+
|
|
51
|
+
- Parallel development on multiple features
|
|
52
|
+
- Clean separation between research (main branch) and implementation (worktree)
|
|
53
|
+
- Easy cleanup and merge when done
|
|
16
54
|
|
|
17
55
|
## Installation
|
|
18
56
|
|
|
@@ -20,126 +58,320 @@ Thought Cabinet provides a systematic way to organize and version-control your d
|
|
|
20
58
|
npm install -g thought-cabinet
|
|
21
59
|
```
|
|
22
60
|
|
|
23
|
-
##
|
|
61
|
+
## Claude Code Integration
|
|
24
62
|
|
|
25
|
-
|
|
63
|
+
Thought Cabinet provides slash commands, agents, and skills that integrate with Claude Code. Install them via `thc agent init`.
|
|
64
|
+
|
|
65
|
+
### Installing Agent Configuration
|
|
26
66
|
|
|
27
67
|
```bash
|
|
28
68
|
cd your-project
|
|
29
|
-
|
|
69
|
+
thc agent init
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This interactively installs to `.claude/`:
|
|
73
|
+
- **Commands** - Slash commands for workflow phases (`/research_codebase`, `/create_plan`, etc.)
|
|
74
|
+
- **Agents** - Specialized sub-agents for code analysis and research
|
|
75
|
+
- **Skills** - Extended capabilities like document generation
|
|
76
|
+
- **Settings** - Project permissions and configuration
|
|
77
|
+
|
|
78
|
+
Options:
|
|
79
|
+
```bash
|
|
80
|
+
thc agent init --all # Copy all files without prompting
|
|
81
|
+
thc agent init --force # Overwrite existing .claude directory
|
|
82
|
+
thc agent init --name codebuddy # Use alternative agent (codebuddy)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Slash Commands
|
|
86
|
+
|
|
87
|
+
These commands guide the AI through each phase of development:
|
|
88
|
+
|
|
89
|
+
| Command | Purpose |
|
|
90
|
+
|---------|---------|
|
|
91
|
+
| `/research_codebase` | Deep-dive into codebase, save findings to `thoughts/shared/research/` |
|
|
92
|
+
| `/create_plan` | Create implementation plan with phases and success criteria |
|
|
93
|
+
| `/iterate_plan` | Refine existing plans based on feedback |
|
|
94
|
+
| `/implement_plan` | Execute plan phase-by-phase with verification |
|
|
95
|
+
| `/validate_plan` | Verify implementation against plan's success criteria |
|
|
96
|
+
|
|
97
|
+
### Context Offloading
|
|
98
|
+
|
|
99
|
+
AI agents have limited context windows. Thought Cabinet offloads context to the filesystem:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
┌─────────────────┐ ┌─────────────────────────────┐
|
|
103
|
+
│ Model Context │ │ filesystem (thoughts/) │
|
|
104
|
+
├─────────────────┤ ├─────────────────────────────┤
|
|
105
|
+
│ Current task │ ←── │ research/auth-system.md │
|
|
106
|
+
│ Active code │ │ plans/add-oauth.md │
|
|
107
|
+
│ Recent changes │ │ previous session learnings │
|
|
108
|
+
└─────────────────┘ └─────────────────────────────┘
|
|
30
109
|
```
|
|
31
110
|
|
|
32
|
-
|
|
111
|
+
- `/research_codebase` writes comprehensive analysis to disk, then only the relevant sections are read when needed
|
|
112
|
+
- `/create_plan` produces detailed plans that persist across sessions
|
|
113
|
+
- The AI can reference previous research without re-exploring the entire codebase
|
|
33
114
|
|
|
34
|
-
|
|
35
|
-
2. Create directory structure for this project
|
|
36
|
-
3. Install git hooks for protection and auto-sync
|
|
37
|
-
4. Create symlinks in `thoughts/` directory
|
|
115
|
+
### Filesystem-Based Memory
|
|
38
116
|
|
|
39
|
-
|
|
117
|
+
Unlike conversation history that disappears, thoughts persist:
|
|
40
118
|
|
|
41
119
|
```bash
|
|
42
|
-
|
|
120
|
+
# Research from last week is still available
|
|
121
|
+
cat thoughts/shared/research/2024-01-05-payment-system.md
|
|
122
|
+
|
|
123
|
+
# Plans from past features inform new ones
|
|
124
|
+
ls thoughts/shared/plans/
|
|
125
|
+
|
|
126
|
+
# Personal learnings accumulate
|
|
127
|
+
cat thoughts/yourusername/gotchas.md
|
|
43
128
|
```
|
|
44
129
|
|
|
45
|
-
|
|
130
|
+
All thoughts are git-tracked, so you can:
|
|
131
|
+
- Share knowledge with team members via `thc sync`
|
|
132
|
+
- See how understanding evolved over time
|
|
133
|
+
- Recover context even after months
|
|
134
|
+
|
|
135
|
+
## The Worktree + tmux + Parallel Workflow
|
|
136
|
+
|
|
137
|
+
For complex features, Thought Cabinet enables a powerful parallel workflow:
|
|
138
|
+
|
|
139
|
+
### Phase 1: Research & Planning (Main Branch)
|
|
46
140
|
|
|
47
141
|
```bash
|
|
48
|
-
|
|
142
|
+
# In your main branch, start Claude Code
|
|
143
|
+
cd your-project
|
|
144
|
+
claude
|
|
145
|
+
|
|
146
|
+
# Research the codebase
|
|
147
|
+
> /research_codebase
|
|
148
|
+
> How does the authentication system work?
|
|
149
|
+
|
|
150
|
+
# Create an implementation plan
|
|
151
|
+
> /create_plan
|
|
152
|
+
> Add OAuth2 support based on the research
|
|
153
|
+
|
|
154
|
+
# Iterate until the plan is solid
|
|
155
|
+
> /iterate_plan thoughts/shared/plans/add-oauth.md
|
|
49
156
|
```
|
|
50
157
|
|
|
51
|
-
|
|
158
|
+
### Phase 2: Create Worktree
|
|
52
159
|
|
|
53
|
-
|
|
160
|
+
```bash
|
|
161
|
+
# Create isolated worktree with tmux session
|
|
162
|
+
thc worktree add add-oauth
|
|
54
163
|
|
|
164
|
+
# This creates:
|
|
165
|
+
# - New git worktree at ../your-project-add-oauth/
|
|
166
|
+
# - Dedicated tmux session (thc-add-oauth)
|
|
167
|
+
# - Thoughts initialized and synced in worktree
|
|
55
168
|
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
169
|
+
|
|
170
|
+
### Phase 3: Parallel Implementation (Worktree)
|
|
171
|
+
|
|
172
|
+
In the worktree's tmux session:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Start Claude Code in the worktree
|
|
176
|
+
claude
|
|
177
|
+
|
|
178
|
+
# Implement the plan (the plan persists from main branch!)
|
|
179
|
+
> /implement_plan thoughts/shared/plans/add-oauth.md
|
|
180
|
+
|
|
181
|
+
# Validate against success criteria
|
|
182
|
+
> /validate_plan thoughts/shared/plans/add-oauth.md
|
|
64
183
|
```
|
|
65
184
|
|
|
66
|
-
|
|
185
|
+
**Parallel work**: While implementation runs, you can continue other work in the main branch. Multiple worktrees can run simultaneously.
|
|
67
186
|
|
|
68
|
-
###
|
|
187
|
+
### Phase 4: Merge & Cleanup
|
|
69
188
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
189
|
+
```bash
|
|
190
|
+
# Back in main branch
|
|
191
|
+
thc worktree merge add-oauth
|
|
192
|
+
|
|
193
|
+
# This:
|
|
194
|
+
# - Rebases the feature branch
|
|
195
|
+
# - Fast-forward merges to target
|
|
196
|
+
# - Cleans up worktree and tmux session
|
|
197
|
+
# - Syncs thoughts
|
|
198
|
+
```
|
|
75
199
|
|
|
76
|
-
###
|
|
200
|
+
### Workflow Diagram
|
|
77
201
|
|
|
78
|
-
|
|
202
|
+
```
|
|
203
|
+
Main Branch Worktree (parallel)
|
|
204
|
+
│
|
|
205
|
+
├── /research_codebase
|
|
206
|
+
│ └── writes to thoughts/shared/research/
|
|
207
|
+
│
|
|
208
|
+
├── /create_plan
|
|
209
|
+
│ └── writes to thoughts/shared/plans/
|
|
210
|
+
│
|
|
211
|
+
├── /iterate_plan (until ready)
|
|
212
|
+
│
|
|
213
|
+
├── thc worktree add ──────────────────┐
|
|
214
|
+
│ │
|
|
215
|
+
│ (continue other work here) ├── /implement_plan
|
|
216
|
+
│ │ └── reads plan, writes code
|
|
217
|
+
│ │
|
|
218
|
+
│ ├── /validate_plan
|
|
219
|
+
│ │ └── verifies success criteria
|
|
220
|
+
│ │
|
|
221
|
+
├── thc worktree merge ←───────────────┘
|
|
222
|
+
│
|
|
223
|
+
▼
|
|
224
|
+
```
|
|
79
225
|
|
|
80
|
-
|
|
81
|
-
- `thoughtcabinet profile list` - List all profiles
|
|
82
|
-
- `thoughtcabinet profile show <name>` - Show profile details
|
|
83
|
-
- `thoughtcabinet profile delete <name>` - Delete a profile
|
|
226
|
+
## Quick Start
|
|
84
227
|
|
|
85
|
-
|
|
228
|
+
### Initialize Thoughts
|
|
86
229
|
|
|
87
230
|
```bash
|
|
88
|
-
|
|
231
|
+
cd your-project
|
|
232
|
+
thc init
|
|
89
233
|
```
|
|
90
234
|
|
|
91
|
-
|
|
235
|
+
This sets up:
|
|
236
|
+
- A global thoughts repository (default: `~/thoughts`)
|
|
237
|
+
- Directory structure for this project
|
|
238
|
+
- Git hooks for protection and auto-sync
|
|
239
|
+
- Symlinks in `thoughts/` directory
|
|
92
240
|
|
|
93
|
-
|
|
241
|
+
### Basic Usage
|
|
94
242
|
|
|
95
|
-
|
|
243
|
+
```bash
|
|
244
|
+
# Edit thoughts directly
|
|
245
|
+
vim thoughts/yourusername/notes.md
|
|
246
|
+
|
|
247
|
+
# Sync changes
|
|
248
|
+
thc sync
|
|
249
|
+
|
|
250
|
+
# Check status
|
|
251
|
+
thc status
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Worktree Commands
|
|
96
255
|
|
|
97
256
|
```bash
|
|
98
|
-
|
|
257
|
+
# Create worktree with tmux session
|
|
258
|
+
thc worktree add feature-name
|
|
259
|
+
|
|
260
|
+
# List active worktrees
|
|
261
|
+
thc worktree list
|
|
262
|
+
|
|
263
|
+
# Merge and cleanup
|
|
264
|
+
thc worktree merge feature-name
|
|
99
265
|
```
|
|
100
266
|
|
|
101
|
-
|
|
267
|
+
## CLI Commands
|
|
268
|
+
|
|
269
|
+
### Agent Configuration
|
|
102
270
|
|
|
103
271
|
```bash
|
|
104
|
-
|
|
272
|
+
thc agent init # Install Claude Code slash commands, agents, and skills
|
|
273
|
+
thc agent init --all # Install all without prompting
|
|
274
|
+
thc agent init --force # Overwrite existing configuration
|
|
105
275
|
```
|
|
106
276
|
|
|
107
|
-
|
|
277
|
+
### Thoughts Management
|
|
108
278
|
|
|
109
|
-
|
|
279
|
+
```bash
|
|
280
|
+
thc init # Initialize thoughts for current repository
|
|
281
|
+
thc sync # Sync thoughts to repository
|
|
282
|
+
thc status # Show status of thoughts repository
|
|
283
|
+
thc destroy # Remove thoughts setup from repository
|
|
284
|
+
thc prune # Clean up stale repository mappings
|
|
285
|
+
```
|
|
110
286
|
|
|
111
|
-
|
|
112
|
-
2. **post-commit**: Auto-syncs thoughts after each code commit
|
|
287
|
+
### Worktree Management
|
|
113
288
|
|
|
114
|
-
|
|
289
|
+
```bash
|
|
290
|
+
thc worktree add <name> # Create worktree + tmux session
|
|
291
|
+
thc worktree list # List worktrees and sessions
|
|
292
|
+
thc worktree merge <name> # Merge and cleanup worktree
|
|
293
|
+
```
|
|
115
294
|
|
|
116
|
-
|
|
295
|
+
### Profiles
|
|
296
|
+
|
|
297
|
+
Use different thoughts repositories for different contexts (work, personal):
|
|
117
298
|
|
|
118
299
|
```bash
|
|
119
|
-
|
|
120
|
-
|
|
300
|
+
thc profile create <name> # Create a new profile
|
|
301
|
+
thc profile list # List all profiles
|
|
302
|
+
thc init --profile work # Initialize with specific profile
|
|
121
303
|
```
|
|
122
304
|
|
|
123
|
-
|
|
305
|
+
### Configuration
|
|
124
306
|
|
|
125
|
-
|
|
307
|
+
```bash
|
|
308
|
+
thc config # View configuration
|
|
309
|
+
thc config --edit # Edit configuration
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Configuration is stored in `~/.config/thought-cabinet/config.json`.
|
|
313
|
+
|
|
314
|
+
## Hooks
|
|
126
315
|
|
|
127
|
-
|
|
128
|
-
2. Use `shared/` for team documentation that should be version-controlled
|
|
129
|
-
3. Use `global/yourusername/` for cross-repository personal notes
|
|
130
|
-
4. Use `global/shared/` for cross-repository team documentation
|
|
131
|
-
5. Run `thoughtcabinet sync` before sharing important updates
|
|
132
|
-
6. Never commit the `thoughts/` directory to your code repository
|
|
316
|
+
### Custom Hooks
|
|
133
317
|
|
|
134
|
-
|
|
318
|
+
Configure hooks in `.thought-cabinet/hooks.json` to run commands on events:
|
|
135
319
|
|
|
136
|
-
|
|
320
|
+
```json
|
|
321
|
+
{
|
|
322
|
+
"hooks": {
|
|
323
|
+
"PostWorktreeAdd": [
|
|
324
|
+
{
|
|
325
|
+
"hooks": [
|
|
326
|
+
{ "type": "command", "command": "npm install", "timeout": 300 }
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Available events:**
|
|
335
|
+
- `PreWorktreeAdd`, `PostWorktreeAdd` - Worktree creation
|
|
336
|
+
- `PreWorktreeMerge`, `PostWorktreeMerge` - Worktree merge
|
|
337
|
+
- `PostThoughtsInit`, `PostThoughtsDestroy`, `PostThoughtsSync` - Thoughts lifecycle
|
|
338
|
+
|
|
339
|
+
### Git Hooks
|
|
137
340
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
341
|
+
Automatically installed git hooks:
|
|
342
|
+
- **pre-commit**: Prevents accidental commits of `thoughts/` directory
|
|
343
|
+
- **post-commit**: Auto-syncs thoughts after each commit
|
|
344
|
+
|
|
345
|
+
## Directory Structure
|
|
346
|
+
|
|
347
|
+
```
|
|
348
|
+
your-project/
|
|
349
|
+
└── thoughts/
|
|
350
|
+
├── yourusername/ → Personal notes for this project
|
|
351
|
+
├── shared/ → Team-shared notes
|
|
352
|
+
│ ├── research/ → Codebase research documents
|
|
353
|
+
│ └── plans/ → Implementation plans
|
|
354
|
+
├── global/ → Cross-project thoughts
|
|
355
|
+
└── searchable/ → Hard links for grep/ripgrep
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Best Practices
|
|
359
|
+
|
|
360
|
+
**For AI-assisted development:**
|
|
361
|
+
- Always run `/research_codebase` before planning complex features
|
|
362
|
+
- Use `/create_plan` to make implementation explicit and verifiable
|
|
363
|
+
- Implement in worktrees for maximum throughput
|
|
364
|
+
- Run `/validate_plan` before merging to catch deviations
|
|
365
|
+
|
|
366
|
+
**General tips:**
|
|
367
|
+
- Run `thc sync` frequently to share knowledge
|
|
368
|
+
- Use `thc prune` to clean up stale mappings
|
|
142
369
|
|
|
143
370
|
## License
|
|
144
371
|
|
|
145
372
|
Apache-2.0
|
|
373
|
+
|
|
374
|
+
## Credits
|
|
375
|
+
|
|
376
|
+
- the name "Thought Cabinet" is from CRPG [Disco Elysium](https://en.wikipedia.org/wiki/Disco_Elysium) created by Robert Kurvitz, Aleksander Rostov, Helen Hindpere and others
|
|
377
|
+
- the thoughts system is based on [humanlayer](https://github.com/humanlayer/humanlayer)
|