@mndrk/memx 0.3.3 → 0.3.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.
Files changed (39) hide show
  1. package/README.md +98 -77
  2. package/coverage/clover.xml +1160 -0
  3. package/coverage/coverage-final.json +3 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +87 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +131 -0
  8. package/coverage/lcov-report/index.js.html +7255 -0
  9. package/coverage/lcov-report/mcp.js.html +1009 -0
  10. package/coverage/lcov-report/prettify.css +1 -0
  11. package/coverage/lcov-report/prettify.js +2 -0
  12. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  13. package/coverage/lcov-report/sorter.js +210 -0
  14. package/coverage/lcov.info +2017 -0
  15. package/index.js +651 -243
  16. package/package.json +24 -2
  17. package/test/additional.test.js +373 -0
  18. package/test/branches.test.js +247 -0
  19. package/test/commands.test.js +663 -0
  20. package/test/context.test.js +185 -0
  21. package/test/coverage.test.js +366 -0
  22. package/test/dispatch.test.js +220 -0
  23. package/test/edge-coverage.test.js +250 -0
  24. package/test/edge.test.js +434 -0
  25. package/test/final-coverage.test.js +316 -0
  26. package/test/final-edges.test.js +199 -0
  27. package/test/init-local.test.js +316 -0
  28. package/test/init.test.js +122 -0
  29. package/test/interactive.test.js +229 -0
  30. package/test/main-dispatch.test.js +164 -0
  31. package/test/main-full.test.js +590 -0
  32. package/test/main.test.js +197 -0
  33. package/test/mcp-server.test.js +320 -0
  34. package/test/mcp.test.js +288 -0
  35. package/test/more.test.js +312 -0
  36. package/test/new.test.js +175 -0
  37. package/test/skill.test.js +247 -0
  38. package/test/tasks-interactive.test.js +243 -0
  39. package/test/utils.test.js +367 -0
package/README.md CHANGED
@@ -12,52 +12,57 @@ npm install -g @mndrk/memx
12
12
  # Run mem in any directory - interactive setup
13
13
  mem
14
14
 
15
- # Or explicit init
16
- mem init landing "Build landing page for my project"
15
+ # Or create a task
16
+ mem new landing "Build landing page for my project"
17
17
 
18
18
  # Track progress
19
19
  mem checkpoint "Hero section complete"
20
20
  mem next "Add testimonials"
21
- mem stuck "Waiting on copy from client"
22
21
 
23
22
  # Record learnings
24
23
  mem learn "Tailwind is faster than custom CSS"
25
24
 
26
- # Get full context (on wake)
25
+ # Get full context
27
26
  mem context
28
-
29
- # See progress against success criteria
30
- mem progress
31
27
  ```
32
28
 
33
29
  ## Architecture
34
30
 
35
- ```
36
- WAKE → LOAD STATE → THINK → ACT → SAVE STATE → SLEEP
37
- ```
38
-
39
31
  - **Git-backed**: All state versioned and syncable
32
+ - **Central repo**: `~/.mem` with index mapping projects to tasks
40
33
  - **Branches = Tasks**: Each goal is a separate branch
41
34
  - **Two scopes**: Task-local memory + global playbook
42
- - **Adapters**: Export wake schedule to cron, pm2, etc.
35
+ - **KV primitives**: Generic set/get/pop for app-specific data
43
36
 
44
37
  ## File Structure
45
38
 
46
39
  ```
47
- .mem/
48
- goal.md # Objective + success criteria + constraints
49
- state.md # Progress, next step, blockers, wake schedule
50
- memory.md # Task-specific learnings
51
- playbook.md # Global learnings (shared across tasks)
40
+ ~/.mem/ # Central memory repo
41
+ index.json # Maps project dirs to task branches
42
+ playbook.md # Global learnings (shared)
43
+
44
+ # Per-task (on task branch):
45
+ goal.md # Objective + criteria
46
+ state.md # Status, next step, wake, KV data
47
+ memory.md # Task-specific learnings
52
48
  ```
53
49
 
54
50
  ## Commands
55
51
 
56
52
  ### Lifecycle
57
53
  ```bash
58
- mem init <name> "<goal>" # Start new task (interactive if no args)
54
+ mem new <name> "<goal>" # Create task in central ~/.mem with index
55
+ mem init <name> "<goal>" # Start new task (creates branch)
59
56
  mem status # Current state summary
60
- mem done # Complete task, reflect, merge learnings
57
+ mem done # Complete task, merge learnings
58
+ mem delete <name> # Delete task and remove from index
59
+ ```
60
+
61
+ ### Context
62
+ ```bash
63
+ mem context # Full state: goal, progress, criteria, learnings
64
+ mem context --json # JSON output for programmatic use
65
+ mem context <task> # View specific task without switching
61
66
  ```
62
67
 
63
68
  ### Goal & Criteria
@@ -66,8 +71,6 @@ mem goal [value] # Get/set goal
66
71
  mem criteria add "..." # Add success criterion
67
72
  mem criteria <n> # Mark criterion #n complete
68
73
  mem progress # Show progress % with visual bar
69
- mem constraint add "..." # Add constraint/boundary
70
- mem constraints # List constraints
71
74
  ```
72
75
 
73
76
  ### Progress
@@ -86,44 +89,37 @@ mem playbook # View global playbook
86
89
  mem promote <n> # Promote learning #n to playbook
87
90
  ```
88
91
 
89
- ### Query
92
+ ### Tasks
90
93
  ```bash
91
- mem context # Full hydration for agent wake
92
- mem history # Task progression (git log)
93
- mem query "<search>" # Search all memory
94
+ mem tasks # Interactive task browser (TUI)
95
+ mem tasks --json # JSON: all tasks with status, progress, criteria
96
+ mem switch <name> # Switch to different task
97
+ mem delete <name> # Delete task
94
98
  ```
95
99
 
96
- ### Tasks (Isolation)
100
+ ### KV Primitives
97
101
  ```bash
98
- mem tasks # List all tasks (branches)
99
- mem switch <name> # Switch to different task
102
+ mem set <key> <value> # Store value in state.md frontmatter
103
+ mem get <key> # Retrieve value
104
+ mem pop <key> # Get value and delete (for queues)
105
+ mem pop <key> --json # JSON output: { "value": "..." }
100
106
  ```
101
107
 
102
108
  ### Wake & Sync
103
109
  ```bash
104
- mem wake "<pattern>" # Set wake schedule
105
- mem wake "every 15m" # Examples: every 15m, 8am daily, monday 9am
106
- mem wake --run "<cmd>" # Custom wake command
110
+ mem wake "<pattern>" # Set wake schedule (every 15m, 8am daily)
107
111
  mem wake clear # Clear wake schedule
108
112
  mem cron export # Export as crontab entry
109
113
  mem sync # Push/pull with remote
110
114
  ```
111
115
 
112
- ### Integration
113
- ```bash
114
- mem skill # View LLM skill
115
- mem skill install # Install skill to Claude/Gemini
116
- mem mcp # Start MCP server (stdio)
117
- mem mcp config # Show config for Claude Desktop
118
- ```
119
-
120
116
  ## Task Isolation
121
117
 
122
118
  Each task is a git branch. Switch instantly between contexts:
123
119
 
124
120
  ```bash
125
- mem init landing "Build landing page" # → task/landing branch
126
- mem init auth "Fix auth bug" # → task/auth branch
121
+ mem new landing "Build landing page" # → task/landing branch
122
+ mem new auth "Fix auth bug" # → task/auth branch
127
123
 
128
124
  mem switch landing # Work on landing
129
125
  mem switch auth # Context switch to auth
@@ -131,68 +127,93 @@ mem switch auth # Context switch to auth
131
127
  mem done # Complete, merge learnings to main
132
128
  ```
133
129
 
134
- Learnings stay isolated until promoted to the global playbook.
130
+ ## JSON Output
135
131
 
136
- ## Wake System
132
+ For programmatic use by agents/tools:
137
133
 
138
- Store wake intent in memory, export to any scheduler:
134
+ ```bash
135
+ mem context --json
136
+ ```
137
+
138
+ Returns:
139
+ ```json
140
+ {
141
+ "task": "my-task",
142
+ "branch": "task/my-task",
143
+ "status": "active",
144
+ "goal": "Build feature X",
145
+ "progress": 60,
146
+ "criteria": [
147
+ { "index": 1, "done": true, "text": "Design API" },
148
+ { "index": 2, "done": false, "text": "Implement endpoints" }
149
+ ],
150
+ "nextStep": "Add authentication",
151
+ "checkpoints": ["Completed schema design"],
152
+ "learnings": ["Use JWT for auth"],
153
+ "playbook": ["Always define done first"]
154
+ }
155
+ ```
139
156
 
140
157
  ```bash
141
- # Set wake schedule
142
- mem wake "every 15m"
143
- mem wake "8am daily" --run "mem context | claude -p 'continue'"
158
+ mem tasks --json
159
+ ```
160
+
161
+ Returns all tasks with their full state.
162
+
163
+ ## KV Primitives
164
+
165
+ Generic key-value storage for app-specific data:
166
+
167
+ ```bash
168
+ # Store data
169
+ mem set mykey "some value"
170
+
171
+ # Retrieve
172
+ mem get mykey
173
+ # → some value
144
174
 
145
- # Export to cron
146
- mem cron export >> /etc/crontab
175
+ # Get and delete (useful for queues)
176
+ mem pop mykey
177
+ # → some value (now deleted)
147
178
 
148
- # Or view for manual setup
149
- mem cron export
150
- # → */15 * * * * cd /path && mem context
179
+ # JSON output for programmatic use
180
+ mem pop mykey --json
181
+ # → {"value": "some value"}
182
+ ```
183
+
184
+ Used by `agx` for nudges:
185
+ ```bash
186
+ # agx stores nudges as JSON array
187
+ mem set nudges '["msg1", "msg2"]'
188
+ mem pop nudges --json # Read and clear
151
189
  ```
152
190
 
153
191
  ## For AI Agents
154
192
 
155
- ### Claude Code Plugin
193
+ ### With agx
156
194
 
157
- Install as a Claude Code plugin for automatic skill loading and slash commands:
195
+ `agx` uses mem for all state management:
158
196
 
159
197
  ```bash
160
- claude plugin install github:ramarlina/memx
198
+ agx -a -p "Build todo app" # Creates task via mem new
199
+ agx tasks # Lists via mem tasks --json
200
+ agx nudge task "hint" # Stores via mem set/get/pop
161
201
  ```
162
202
 
163
- This adds:
164
- - **Skill**: Claude learns how to use mem automatically
165
- - **MCP Server**: Direct tool access
166
- - **Commands**: `/mem:status`, `/mem:checkpoint`, `/mem:context`
167
-
168
- ### Manual Setup
203
+ ### Direct Integration
169
204
 
170
- Install the skill so LLMs know how to use mem:
205
+ Install skill for Claude/Gemini:
171
206
 
172
207
  ```bash
173
208
  mem skill install
174
209
  ```
175
210
 
176
- Or use MCP for direct integration:
211
+ Or use MCP server:
177
212
 
178
213
  ```bash
179
214
  mem mcp config # Get config for Claude Desktop
180
215
  ```
181
216
 
182
- ## How It Works
183
-
184
- 1. **Init**: Create `.mem/` with goal + criteria
185
- 2. **Wake**: Agent runs `mem context` to hydrate
186
- 3. **Work**: Execute, checkpoint, learn
187
- 4. **Sleep**: State persisted in git
188
- 5. **Repeat**: Next session picks up where left off
189
-
190
- The framework enforces:
191
- - Define done before starting (criteria in goal.md)
192
- - Track progress explicitly (checkpoints)
193
- - Capture learnings (memory.md)
194
- - Curate transferable knowledge (promote to playbook)
195
-
196
217
  ## License
197
218
 
198
219
  MIT