claude-mem 3.3.7 → 3.3.9
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/README.md +183 -46
- package/dist/bin/cli.d.ts +2 -0
- package/dist/bin/cli.js +179 -0
- package/dist/commands/compress.d.ts +2 -0
- package/dist/commands/compress.js +27 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +131 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/install.js +836 -0
- package/dist/commands/load-context.d.ts +2 -0
- package/dist/commands/load-context.js +151 -0
- package/dist/commands/logs.d.ts +2 -0
- package/dist/commands/logs.js +76 -0
- package/dist/commands/migrate-to-jsonl.d.ts +5 -0
- package/dist/commands/migrate-to-jsonl.js +99 -0
- package/dist/commands/restore.d.ts +1 -0
- package/dist/commands/restore.js +20 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +136 -0
- package/dist/commands/trash-empty.d.ts +3 -0
- package/dist/commands/trash-empty.js +56 -0
- package/dist/commands/trash-view.d.ts +1 -0
- package/dist/commands/trash-view.js +101 -0
- package/dist/commands/trash.d.ts +6 -0
- package/dist/commands/trash.js +49 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.js +107 -0
- package/dist/constants.d.ts +271 -0
- package/dist/constants.js +199 -0
- package/dist/core/compression/TranscriptCompressor.d.ts +79 -0
- package/dist/core/compression/TranscriptCompressor.js +585 -0
- package/dist/core/orchestration/PromptOrchestrator.d.ts +165 -0
- package/dist/core/orchestration/PromptOrchestrator.js +182 -0
- package/dist/lib/time-utils.d.ts +5 -0
- package/dist/lib/time-utils.js +70 -0
- package/dist/prompts/constants.d.ts +126 -0
- package/dist/prompts/constants.js +161 -0
- package/dist/prompts/index.d.ts +10 -0
- package/dist/prompts/index.js +11 -0
- package/dist/prompts/templates/analysis/AnalysisTemplates.d.ts +13 -0
- package/dist/prompts/templates/analysis/AnalysisTemplates.js +94 -0
- package/dist/prompts/templates/context/ContextTemplates.d.ts +119 -0
- package/dist/prompts/templates/context/ContextTemplates.js +399 -0
- package/dist/prompts/templates/hooks/HookTemplates.d.ts +175 -0
- package/dist/prompts/templates/hooks/HookTemplates.js +394 -0
- package/dist/prompts/templates/hooks/HookTemplates.test.d.ts +7 -0
- package/dist/prompts/templates/hooks/HookTemplates.test.js +127 -0
- package/dist/shared/config.d.ts +4 -0
- package/dist/shared/config.js +41 -0
- package/dist/shared/error-handler.d.ts +22 -0
- package/dist/shared/error-handler.js +142 -0
- package/dist/shared/logger.d.ts +19 -0
- package/dist/shared/logger.js +51 -0
- package/dist/shared/paths.d.ts +28 -0
- package/dist/shared/paths.js +100 -0
- package/dist/shared/settings.d.ts +41 -0
- package/dist/shared/settings.js +81 -0
- package/dist/shared/types.d.ts +145 -0
- package/dist/shared/types.js +78 -0
- package/docs/STATUS.md +155 -0
- package/docs/chroma-backend-migration.md +161 -0
- package/docs/landing-page-outline.md +287 -0
- package/docs/multi-platform-builds.md +96 -0
- package/docs/plans/cloud-service-plan.md +274 -0
- package/docs/plans/fix-response-format-issue.md +61 -0
- package/docs/plans/restructure-session-hook-output.md +102 -0
- package/docs/plans/session-start-hook-investigation.md +45 -0
- package/docs/plans/src-reorganization-plan.md +181 -0
- package/docs/plans/terminal-effects-decision.md +22 -0
- package/docs/plans/terminal-effects-integration.md +82 -0
- package/docs/plans/trash-bin-feature-plan.md +240 -0
- package/docs/plans/trash-bin-minimal-plan.md +102 -0
- package/docs/reference/bun-single-executable.md +584 -0
- package/docs/reference/cc-output-styles.md +99 -0
- package/docs/reference/chroma-mcp-project-memory-example.md +80 -0
- package/docs/reference/chroma-mcp-team-example.md +92 -0
- package/docs/reference/claude-code/cc-hooks.md +787 -0
- package/docs/reference/claude-code/cc-status-line.md +202 -0
- package/docs/reference/claude-code/hook-configuration.md +173 -0
- package/docs/reference/claude-code/hook-responses.md +127 -0
- package/docs/reference/claude-code/hooks.md +175 -0
- package/docs/reference/claude-code/mcp-configuration.md +133 -0
- package/docs/reference/claude-code/session-start-hook.md +82 -0
- package/docs/reference/load-context-format-example.md +33 -0
- package/docs/reference/mcp-sdk/mcp-typescript-sdk-readme.md +1323 -0
- package/docs/reference/mcp-sdk/server-implementation.md +286 -0
- package/docs/reference/mcp-sdk/stdio-transport.md +345 -0
- package/docs/todos/fix-response-format-tasks.md +43 -0
- package/docs/todos/implementation-todos.md +280 -0
- package/docs/todos/restructure-hook-output-tasks.md +103 -0
- package/docs/todos/session-start-hook-fix.md +26 -0
- package/docs/todos/terminal-effects-tasks.md +42 -0
- package/docs/todos/trash-bin-implementation-todos.md +348 -0
- package/docs/todos/trash-bin-minimal-todos.md +27 -0
- package/package.json +56 -6
- package/claude-mem +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Terminal Effects Integration Plan
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Enhance the claude-mem installer with better visual feedback using the existing `@clack/prompts` library (v0.11.0). Focus strictly on improving user experience without adding dependencies or over-engineering.
|
|
6
|
+
|
|
7
|
+
## Current State Analysis
|
|
8
|
+
|
|
9
|
+
The installation wizard in `src/commands/install.ts` already uses @clack/prompts with:
|
|
10
|
+
- Basic spinners (`p.spinner()`)
|
|
11
|
+
- Interactive prompts (`p.select()`, `p.confirm()`, `p.text()`)
|
|
12
|
+
- Basic logging (`p.log.info()`, `p.log.warn()`, `p.log.error()`)
|
|
13
|
+
- Group operations (`p.group()`)
|
|
14
|
+
- Intro/outro messaging (`p.intro()`, `p.outro()`)
|
|
15
|
+
|
|
16
|
+
## Enhancement Targets
|
|
17
|
+
|
|
18
|
+
### 1. Multi-Step Progress Visualization
|
|
19
|
+
**Current:** Sequential spinners that stop/start individually
|
|
20
|
+
**Enhancement:** Add progress indication for the overall installation flow
|
|
21
|
+
|
|
22
|
+
### 2. Better Error Display Hierarchy
|
|
23
|
+
**Current:** Basic error messages mixed with regular output
|
|
24
|
+
**Enhancement:** Consistent error formatting with clear visual separation
|
|
25
|
+
|
|
26
|
+
### 3. Status Message Improvements
|
|
27
|
+
**Current:** Generic spinner messages
|
|
28
|
+
**Enhancement:** More descriptive, contextual status messages
|
|
29
|
+
|
|
30
|
+
### 4. Enhanced Verification Feedback
|
|
31
|
+
**Current:** Simple success/failure reporting
|
|
32
|
+
**Enhancement:** Detailed verification with clear visual results
|
|
33
|
+
|
|
34
|
+
## Technical Approach
|
|
35
|
+
|
|
36
|
+
### Keep It Simple
|
|
37
|
+
- Use only existing @clack/prompts features
|
|
38
|
+
- No new dependencies
|
|
39
|
+
- No architectural changes
|
|
40
|
+
- Focus on visual polish only
|
|
41
|
+
|
|
42
|
+
### Minimal Changes Required
|
|
43
|
+
1. Enhance spinner messages with more context
|
|
44
|
+
2. Add step counting to the main installation flow
|
|
45
|
+
3. Improve error message formatting
|
|
46
|
+
4. Add visual separators for better organization
|
|
47
|
+
|
|
48
|
+
## Implementation Scope
|
|
49
|
+
|
|
50
|
+
**File to Modify:** `src/commands/install.ts`
|
|
51
|
+
|
|
52
|
+
**Specific Areas:**
|
|
53
|
+
1. `validatePrerequisites()` - Better progress feedback
|
|
54
|
+
2. `installChromaMcp()` - Enhanced status messages
|
|
55
|
+
3. `p.group()` section - Add step progress indicators
|
|
56
|
+
4. `verifyInstallation()` - Improved results display
|
|
57
|
+
5. Error handling throughout - Consistent formatting
|
|
58
|
+
|
|
59
|
+
**Not In Scope:**
|
|
60
|
+
- New UI components
|
|
61
|
+
- Complex progress bars (not available in @clack/prompts 0.11.0)
|
|
62
|
+
- Color customization
|
|
63
|
+
- Animation effects
|
|
64
|
+
- New prompts or interactions
|
|
65
|
+
|
|
66
|
+
## Success Criteria
|
|
67
|
+
|
|
68
|
+
1. **Visual Clarity:** Users can easily track installation progress
|
|
69
|
+
2. **Error Visibility:** Problems are clearly highlighted and actionable
|
|
70
|
+
3. **Professional Feel:** Installation feels polished and confident
|
|
71
|
+
4. **Zero Regression:** All existing functionality works exactly the same
|
|
72
|
+
|
|
73
|
+
## Risk Mitigation
|
|
74
|
+
|
|
75
|
+
- Changes are cosmetic only - no functional modifications
|
|
76
|
+
- Existing user interactions remain identical
|
|
77
|
+
- Fallback to current behavior if any issues arise
|
|
78
|
+
- Minimal code changes reduce chance of introducing bugs
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
*Following KISS principles: Make what already works look better, don't reinvent anything.*
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Claude-Mem Trash Bin Feature Plan
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
Add a trash bin safety feature to claude-mem that intercepts destructive file operations in Claude Code sessions, replacing permanent deletion with recoverable trash operations. This feature will install trash-cli during setup, configure Claude Code settings to block dangerous rm commands, and provide interactive trash management through the claude-mem CLI.
|
|
6
|
+
|
|
7
|
+
## Core Objectives
|
|
8
|
+
|
|
9
|
+
1. **Prevent accidental data loss** by intercepting rm/rm -rf commands in Claude Code sessions
|
|
10
|
+
2. **Provide recovery mechanism** through centralized trash at ~/.claude-mem/trash
|
|
11
|
+
3. **Interactive management** via claude-mem CLI with restore, empty, and view operations
|
|
12
|
+
4. **Seamless integration** with existing claude-mem architecture and installation flow
|
|
13
|
+
|
|
14
|
+
## Technical Architecture
|
|
15
|
+
|
|
16
|
+
### Component Overview
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
claude-mem trash system
|
|
20
|
+
├── Installation Layer
|
|
21
|
+
│ ├── trash-cli npm package installation
|
|
22
|
+
│ ├── Claude Code settings configuration
|
|
23
|
+
│ └── Directory structure creation
|
|
24
|
+
├── Interception Layer
|
|
25
|
+
│ ├── Claude Code permission denials for rm
|
|
26
|
+
│ └── Bash alias recommendations
|
|
27
|
+
├── Storage Layer
|
|
28
|
+
│ ├── ~/.claude-mem/trash/files/
|
|
29
|
+
│ ├── ~/.claude-mem/trash/info/
|
|
30
|
+
│ └── ~/.claude-mem/trash/index.jsonl
|
|
31
|
+
└── Management Layer
|
|
32
|
+
├── CLI commands (trash, restore, empty)
|
|
33
|
+
├── Interactive prompts (@clack/prompts)
|
|
34
|
+
└── Trash metadata tracking
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Key Design Decisions
|
|
38
|
+
|
|
39
|
+
1. **Use sindresorhus/trash-cli** (npm version) for better cross-platform support and faster startup
|
|
40
|
+
2. **Store trash in ~/.claude-mem/trash** to keep all claude-mem data centralized
|
|
41
|
+
3. **Block rm commands via Claude Code permissions** rather than environment aliases
|
|
42
|
+
4. **Follow XDG specification** for trash directory structure
|
|
43
|
+
5. **Maintain operation logs** in ~/.claude-mem/logs for audit trail
|
|
44
|
+
|
|
45
|
+
## Implementation Strategy
|
|
46
|
+
|
|
47
|
+
### Phase 1: Core Infrastructure
|
|
48
|
+
|
|
49
|
+
#### Installation Enhancement
|
|
50
|
+
- Extend `src/commands/install.ts` to include trash-cli installation
|
|
51
|
+
- Add trash directory to `ensureDirectoryStructure()`
|
|
52
|
+
- Update Claude Code settings with rm command denials
|
|
53
|
+
|
|
54
|
+
#### Directory Structure
|
|
55
|
+
```
|
|
56
|
+
~/.claude-mem/trash/
|
|
57
|
+
├── files/ # Actual trashed files
|
|
58
|
+
├── info/ # Metadata (.trashinfo files)
|
|
59
|
+
└── index.jsonl # claude-mem specific tracking
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Phase 2: CLI Commands
|
|
63
|
+
|
|
64
|
+
#### New Commands Structure
|
|
65
|
+
```
|
|
66
|
+
claude-mem trash # Interactive trash management
|
|
67
|
+
claude-mem trash list # List trashed items
|
|
68
|
+
claude-mem trash restore <file> # Restore specific file
|
|
69
|
+
claude-mem trash empty # Empty trash (with confirmation)
|
|
70
|
+
claude-mem trash stats # Show trash statistics
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Interactive Flow
|
|
74
|
+
Using @clack/prompts for consistency:
|
|
75
|
+
1. Main menu: List, Restore, Empty, Stats, Exit
|
|
76
|
+
2. List view: Shows files with deletion date, original path, size
|
|
77
|
+
3. Restore: Multi-select interface for batch restoration
|
|
78
|
+
4. Empty: Progressive confirmation (show what will be deleted)
|
|
79
|
+
|
|
80
|
+
### Phase 3: Safety Configuration
|
|
81
|
+
|
|
82
|
+
#### Claude Code Settings Modification
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"permissions": {
|
|
86
|
+
"deny": [
|
|
87
|
+
"Bash(rm *)",
|
|
88
|
+
"Bash(rm -rf *)",
|
|
89
|
+
"Bash(rm -r *)",
|
|
90
|
+
"Bash(sudo rm *)"
|
|
91
|
+
],
|
|
92
|
+
"allowedTools": [
|
|
93
|
+
"Bash(trash *)"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Shell Configuration (Optional)
|
|
100
|
+
Provide recommendations for user's shell profile:
|
|
101
|
+
```bash
|
|
102
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
103
|
+
alias rm='echo "Use trash command instead (or \\rm for bypass)" && false'
|
|
104
|
+
alias del='trash'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## File System Operations
|
|
108
|
+
|
|
109
|
+
### Trash Operation Flow
|
|
110
|
+
1. **File deletion intercepted** → trash-cli moves to ~/.claude-mem/trash
|
|
111
|
+
2. **Metadata recorded** → .trashinfo file created with original path, deletion time
|
|
112
|
+
3. **Index updated** → claude-mem tracks in index.jsonl for fast queries
|
|
113
|
+
4. **Log entry created** → Operation logged to ~/.claude-mem/logs
|
|
114
|
+
|
|
115
|
+
### Restore Operation Flow
|
|
116
|
+
1. **User selects file(s)** → Interactive prompt or direct command
|
|
117
|
+
2. **Validate restoration path** → Check if original location exists
|
|
118
|
+
3. **Move file back** → From trash to original location
|
|
119
|
+
4. **Update index** → Remove from trash index
|
|
120
|
+
5. **Log operation** → Record restoration in logs
|
|
121
|
+
|
|
122
|
+
## User Experience
|
|
123
|
+
|
|
124
|
+
### Installation Experience
|
|
125
|
+
```
|
|
126
|
+
┌ Claude-Mem Installation
|
|
127
|
+
│
|
|
128
|
+
◆ Installing core components...
|
|
129
|
+
│ ✔ Created directory structure
|
|
130
|
+
│ ✔ Installed trash-cli safety system
|
|
131
|
+
│ ✔ Configured Claude Code settings
|
|
132
|
+
│ ✔ Added rm command protection
|
|
133
|
+
│
|
|
134
|
+
◇ Trash bin configured at ~/.claude-mem/trash
|
|
135
|
+
│ Use 'claude-mem trash' to manage deleted files
|
|
136
|
+
│
|
|
137
|
+
└ Installation complete!
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Trash Management Experience
|
|
141
|
+
```
|
|
142
|
+
┌ Claude-Mem Trash Manager
|
|
143
|
+
│
|
|
144
|
+
◆ What would you like to do?
|
|
145
|
+
│ ○ List trashed items (3 files)
|
|
146
|
+
│ ○ Restore files
|
|
147
|
+
│ ○ Empty trash
|
|
148
|
+
│ ○ View statistics
|
|
149
|
+
│ ○ Exit
|
|
150
|
+
│
|
|
151
|
+
└
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Error Handling
|
|
155
|
+
|
|
156
|
+
### Graceful Degradation
|
|
157
|
+
1. If trash-cli installation fails → Warn user, continue installation
|
|
158
|
+
2. If Claude Code settings update fails → Log warning, provide manual instructions
|
|
159
|
+
3. If trash directory creation fails → Fall back to system trash location
|
|
160
|
+
|
|
161
|
+
### Recovery Mechanisms
|
|
162
|
+
- Manual bypass: Users can use `\rm` to bypass alias if needed
|
|
163
|
+
- Restore from backup: Keep 24-hour backup of trash index
|
|
164
|
+
- Conflict resolution: If restore path exists, prompt for new location
|
|
165
|
+
|
|
166
|
+
## Integration Points
|
|
167
|
+
|
|
168
|
+
### With Existing claude-mem Systems
|
|
169
|
+
1. **Logger**: Use existing FileLogger for all operations
|
|
170
|
+
2. **PathResolver**: Extend with `getTrashDir()`, `getTrashInfoDir()`
|
|
171
|
+
3. **Settings**: Add trash preferences to Settings interface
|
|
172
|
+
4. **CLI Structure**: Follow established command patterns
|
|
173
|
+
|
|
174
|
+
### With Claude Code
|
|
175
|
+
1. **Settings.json**: Modify permissions on installation
|
|
176
|
+
2. **Hooks**: Consider pre-delete hook for future enhancement
|
|
177
|
+
3. **MCP Server**: Potential future integration for trash queries
|
|
178
|
+
|
|
179
|
+
## Success Metrics
|
|
180
|
+
|
|
181
|
+
1. **Zero data loss** from accidental rm commands in Claude Code
|
|
182
|
+
2. **<100ms** trash operation latency
|
|
183
|
+
3. **95% recovery success rate** for trashed files
|
|
184
|
+
4. **<1% storage overhead** from metadata
|
|
185
|
+
|
|
186
|
+
## Security Considerations
|
|
187
|
+
|
|
188
|
+
1. **Path validation** to prevent directory traversal
|
|
189
|
+
2. **Permission preservation** when restoring files
|
|
190
|
+
3. **Size limits** to prevent trash from filling disk
|
|
191
|
+
4. **Age-based cleanup** option (30-day default)
|
|
192
|
+
|
|
193
|
+
## Future Enhancements
|
|
194
|
+
|
|
195
|
+
1. **Smart recovery suggestions** based on file patterns
|
|
196
|
+
2. **Integration with claude-mem memories** for tracking deleted code
|
|
197
|
+
3. **Undo stack** for recent operations
|
|
198
|
+
4. **Cloud backup** integration for critical files
|
|
199
|
+
5. **Project-specific trash** for better organization
|
|
200
|
+
|
|
201
|
+
## Dependencies
|
|
202
|
+
|
|
203
|
+
- **trash-cli** (npm): Core trash functionality
|
|
204
|
+
- **@clack/prompts**: Interactive CLI (existing)
|
|
205
|
+
- **commander**: CLI framework (existing)
|
|
206
|
+
- No additional dependencies required
|
|
207
|
+
|
|
208
|
+
## Testing Strategy
|
|
209
|
+
|
|
210
|
+
1. **Unit tests** for trash operations
|
|
211
|
+
2. **Integration tests** with Claude Code settings
|
|
212
|
+
3. **Cross-platform testing** (macOS, Linux, Windows)
|
|
213
|
+
4. **Recovery scenarios** testing
|
|
214
|
+
|
|
215
|
+
## Documentation Updates
|
|
216
|
+
|
|
217
|
+
1. Update README with trash feature description
|
|
218
|
+
2. Add trash commands to CLI help
|
|
219
|
+
3. Create troubleshooting guide for common issues
|
|
220
|
+
4. Add configuration examples to documentation
|
|
221
|
+
|
|
222
|
+
## Risk Mitigation
|
|
223
|
+
|
|
224
|
+
| Risk | Impact | Mitigation |
|
|
225
|
+
|------|--------|------------|
|
|
226
|
+
| trash-cli installation fails | Medium | Graceful degradation, manual instructions |
|
|
227
|
+
| Claude Code ignores settings | High | Test thoroughly, provide workarounds |
|
|
228
|
+
| Disk space issues | Medium | Size limits, age-based cleanup |
|
|
229
|
+
| Performance impact | Low | Lazy loading, indexed operations |
|
|
230
|
+
| User confusion | Low | Clear documentation, intuitive UI |
|
|
231
|
+
|
|
232
|
+
## Implementation Timeline
|
|
233
|
+
|
|
234
|
+
- **Week 1**: Core infrastructure and installation integration
|
|
235
|
+
- **Week 2**: CLI commands and interactive interface
|
|
236
|
+
- **Week 3**: Testing, documentation, and release
|
|
237
|
+
|
|
238
|
+
## Conclusion
|
|
239
|
+
|
|
240
|
+
This trash bin feature provides essential safety for Claude Code users while maintaining the simplicity and efficiency that claude-mem is known for. By following existing architectural patterns and using proven tools, we can deliver a robust solution that prevents data loss without adding complexity to the user experience.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Claude-Mem Trash Bin - Minimal Implementation Plan
|
|
2
|
+
|
|
3
|
+
## Core Truth
|
|
4
|
+
Make a trash command that moves files to ~/.claude-mem/trash. Make a restore command that moves them back. Ship it. Fix what breaks.
|
|
5
|
+
|
|
6
|
+
## The ONE Thing That Matters
|
|
7
|
+
Prevent permanent data loss when Claude Code deletes files. Everything else is noise.
|
|
8
|
+
|
|
9
|
+
## Implementation (Make It Work First)
|
|
10
|
+
|
|
11
|
+
### Step 1: Basic Trash Command
|
|
12
|
+
```typescript
|
|
13
|
+
// src/commands/trash.ts
|
|
14
|
+
export async function trash(filePath: string) {
|
|
15
|
+
const trashDir = join(homedir(), '.claude-mem', 'trash');
|
|
16
|
+
if (!existsSync(trashDir)) mkdirSync(trashDir, { recursive: true });
|
|
17
|
+
|
|
18
|
+
const fileName = basename(filePath);
|
|
19
|
+
const destination = join(trashDir, fileName);
|
|
20
|
+
renameSync(filePath, destination);
|
|
21
|
+
|
|
22
|
+
console.log(`Moved ${fileName} to trash`);
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Step 2: Basic Restore Command
|
|
27
|
+
```typescript
|
|
28
|
+
// src/commands/restore.ts
|
|
29
|
+
export async function restore() {
|
|
30
|
+
const trashDir = join(homedir(), '.claude-mem', 'trash');
|
|
31
|
+
const files = readdirSync(trashDir);
|
|
32
|
+
|
|
33
|
+
if (files.length === 0) {
|
|
34
|
+
console.log('Trash is empty');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Use existing clack prompts - we already have it
|
|
39
|
+
const file = await p.select({
|
|
40
|
+
message: 'Select file to restore:',
|
|
41
|
+
options: files.map(f => ({ value: f, label: f }))
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
renameSync(join(trashDir, file), join(process.cwd(), file));
|
|
45
|
+
console.log(`Restored ${file}`);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Step 3: Add to CLI
|
|
50
|
+
```typescript
|
|
51
|
+
// src/bin/cli.ts
|
|
52
|
+
program.command('trash <file>').action(trash);
|
|
53
|
+
program.command('restore').action(restore);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Step 4: Update Install (Optional)
|
|
57
|
+
During install, show:
|
|
58
|
+
```
|
|
59
|
+
💡 Tip: Use 'claude-mem trash <file>' instead of rm for safe deletion
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## That's It. Ship It.
|
|
63
|
+
|
|
64
|
+
## What We DON'T Do (Yet)
|
|
65
|
+
|
|
66
|
+
❌ NO trash-cli installation - use native fs operations
|
|
67
|
+
❌ NO Claude Code settings modification - let users discover the need
|
|
68
|
+
❌ NO metadata tracking - filename is enough to start
|
|
69
|
+
❌ NO original path storage - restore to current directory
|
|
70
|
+
❌ NO conflict resolution - let it fail naturally
|
|
71
|
+
❌ NO size limits - fix when someone's disk fills
|
|
72
|
+
❌ NO age cleanup - fix when someone complains
|
|
73
|
+
❌ NO shell aliases - users can add if they want
|
|
74
|
+
❌ NO permissions validation - fs.rename will fail if not allowed
|
|
75
|
+
❌ NO XDG compliance - our own directory is simpler
|
|
76
|
+
|
|
77
|
+
## When to Add Features
|
|
78
|
+
|
|
79
|
+
Only add when these ACTUALLY happen:
|
|
80
|
+
1. **Filename collision** → Add timestamp suffix
|
|
81
|
+
2. **Users can't find files** → Add list command
|
|
82
|
+
3. **Need original location** → Add simple JSON tracking
|
|
83
|
+
4. **Trash gets huge** → Add empty command
|
|
84
|
+
5. **Users forget about trash** → Add install tip
|
|
85
|
+
|
|
86
|
+
## Success Metric
|
|
87
|
+
|
|
88
|
+
One user successfully recovers one accidentally deleted file. That's it.
|
|
89
|
+
|
|
90
|
+
## Timeline
|
|
91
|
+
|
|
92
|
+
Day 1: Write the 20 lines of code above
|
|
93
|
+
Day 2: Test it, ship it
|
|
94
|
+
Day 3: Wait for real feedback
|
|
95
|
+
|
|
96
|
+
## The Test
|
|
97
|
+
|
|
98
|
+
Can someone understand what this does in 5 seconds?
|
|
99
|
+
- `claude-mem trash file.txt` → Moves file to trash
|
|
100
|
+
- `claude-mem restore` → Brings it back
|
|
101
|
+
|
|
102
|
+
YES. Ship it.
|