@memstack/cli 0.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MemStack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # @memstack/cli
2
+
3
+ CLI for MemStack — shell-based agent memory. Use from bash scripts, Claude Code shell tool, CI pipelines, or any subprocess-capable agent.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @memstack/cli
9
+ # or
10
+ npx @memstack/cli [command]
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ All via environment variables. Same scheme as @memstack/mcp.
16
+
17
+ | Variable | Purpose | Default |
18
+ |---|---|---|
19
+ | `MEMSTACK_STORAGE` | Storage backend | `memory` |
20
+ | `MEMSTACK_DIR` | Directory for markdown/disk | `./memories` |
21
+ | `DATABASE_URL` | Postgres connection | — |
22
+ | `SQLITE_PATH` | SQLite database path | `./memstack.db` |
23
+ | `REDIS_URL` | Redis connection | `redis://localhost:6379` |
24
+ | `OPENAI_API_KEY` | OpenAI LLM + embeddings | — |
25
+ | `ANTHROPIC_API_KEY` | Anthropic LLM (summarization) | — |
26
+
27
+ ## Commands
28
+
29
+ All output is JSON to stdout. Errors go to stderr.
30
+
31
+ ### store
32
+ ```bash
33
+ memstack store --actor "agent-1" --content "User reported login bug" --type interaction --importance 0.8 --tags "bug,login"
34
+ # {"id":"mem_...","actorId":"agent-1","content":"User reported login bug",...}
35
+ ```
36
+
37
+ ### retrieve
38
+ ```bash
39
+ memstack retrieve --actor "agent-1" --query "login" --strategy hybrid --limit 5
40
+ memstack retrieve --actor "agent-1" --created-after "2026-01-01T00:00:00Z" --created-before "2026-06-01T00:00:00Z"
41
+ ```
42
+
43
+ ### context
44
+ ```bash
45
+ memstack context --actor "agent-1" --max-tokens 2000
46
+ # {"systemPrompt":"## Important Memories\n- ...", "tokenEstimate": 280, ...}
47
+ ```
48
+
49
+ ### summarize
50
+ ```bash
51
+ memstack summarize --actor "agent-1" --older-than 7d
52
+ # {"summary": {...}, "deletedCount": 47}
53
+ ```
54
+
55
+ ### prune
56
+ ```bash
57
+ memstack prune --actor "agent-1" --type byAge --max-age 30d
58
+ memstack prune --actor "agent-1" --type byImportance --min-importance 0.3
59
+ memstack prune --actor "agent-1" --type byCount --max-count 500
60
+ memstack prune --actor "agent-1" --type byAge --max-age 7d --dry-run # preview only
61
+ ```
62
+
63
+ ### purge
64
+ ```bash
65
+ memstack purge --actor "agent-1"
66
+ # 42 (number of deleted memories)
67
+ ```
68
+
69
+ ### merge
70
+ ```bash
71
+ memstack merge --ids "mem_abc,mem_def,mem_ghi"
72
+ # {merged memory object}
73
+ ```
74
+
75
+ ### stats
76
+ ```bash
77
+ memstack stats --actor "agent-1"
78
+ # {"total":1500,"expired":3,"oldest":"...","newest":"...","avgImportance":0.6,...}
79
+ ```
80
+
81
+ ### delete
82
+ ```bash
83
+ memstack delete --id "mem_abc123"
84
+ # {"deleted":true}
85
+ ```
86
+
87
+ ### health
88
+ ```bash
89
+ memstack health
90
+ # {"storage":true,"llm":true,"embedding":true}
91
+ ```
92
+
93
+ ### export
94
+ ```bash
95
+ memstack export --actor "agent-1"
96
+ memstack export --actor "agent-1" --out ./backup.json
97
+ # {"saved":"./backup.json","count":1500}
98
+ ```
99
+
100
+ ### import
101
+ ```bash
102
+ memstack import --actor "agent-1" --file ./backup.json
103
+ # {"imported":1500}
104
+ ```
105
+
106
+ ## Shell agent usage
107
+
108
+ ```bash
109
+ #!/bin/bash
110
+ AGENT_ID="support-bot"
111
+
112
+ # Before each turn: inject memory context
113
+ CONTEXT=$(memstack context --actor "$AGENT_ID" --max-tokens 1500)
114
+ SYSTEM_PROMPT=$(echo "$CONTEXT" | jq -r '.systemPrompt')
115
+
116
+ # After each turn: store what happened
117
+ memstack store --actor "$AGENT_ID" --content "$TURN_SUMMARY" --type interaction
118
+
119
+ # Periodic maintenance
120
+ memstack prune --actor "$AGENT_ID" --type byAge --max-age 30d
121
+ ```
122
+
123
+ ## Publishing
124
+
125
+ ```bash
126
+ cd packages/cli
127
+ pnpm build && pnpm check && pnpm test
128
+ npm publish --access public
129
+ ```
130
+
131
+ After publishing, users install with:
132
+
133
+ ```bash
134
+ npm install -g @memstack/cli
135
+ ```
136
+
137
+ ## License
138
+
139
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node