pmem-ai 0.5.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE +21 -0
  3. package/README.md +349 -0
  4. package/dist/commands/ask.d.ts +3 -0
  5. package/dist/commands/ask.d.ts.map +1 -0
  6. package/dist/commands/ask.js +303 -0
  7. package/dist/commands/ask.js.map +1 -0
  8. package/dist/commands/distill.d.ts +6 -0
  9. package/dist/commands/distill.d.ts.map +1 -0
  10. package/dist/commands/distill.js +425 -0
  11. package/dist/commands/distill.js.map +1 -0
  12. package/dist/commands/graph.d.ts +6 -0
  13. package/dist/commands/graph.d.ts.map +1 -0
  14. package/dist/commands/graph.js +216 -0
  15. package/dist/commands/graph.js.map +1 -0
  16. package/dist/commands/init.d.ts +5 -0
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/commands/init.js +566 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/integration.d.ts +2 -0
  21. package/dist/commands/integration.d.ts.map +1 -0
  22. package/dist/commands/integration.js +216 -0
  23. package/dist/commands/integration.js.map +1 -0
  24. package/dist/commands/migrate.d.ts +6 -0
  25. package/dist/commands/migrate.d.ts.map +1 -0
  26. package/dist/commands/migrate.js +379 -0
  27. package/dist/commands/migrate.js.map +1 -0
  28. package/dist/commands/rebuild.d.ts +8 -0
  29. package/dist/commands/rebuild.d.ts.map +1 -0
  30. package/dist/commands/rebuild.js +299 -0
  31. package/dist/commands/rebuild.js.map +1 -0
  32. package/dist/commands/recall.d.ts +3 -0
  33. package/dist/commands/recall.d.ts.map +1 -0
  34. package/dist/commands/recall.js +140 -0
  35. package/dist/commands/recall.js.map +1 -0
  36. package/dist/commands/session.d.ts +3 -0
  37. package/dist/commands/session.d.ts.map +1 -0
  38. package/dist/commands/session.js +147 -0
  39. package/dist/commands/session.js.map +1 -0
  40. package/dist/commands/status.d.ts +5 -0
  41. package/dist/commands/status.d.ts.map +1 -0
  42. package/dist/commands/status.js +275 -0
  43. package/dist/commands/status.js.map +1 -0
  44. package/dist/commands/update.d.ts +14 -0
  45. package/dist/commands/update.d.ts.map +1 -0
  46. package/dist/commands/update.js +536 -0
  47. package/dist/commands/update.js.map +1 -0
  48. package/dist/commands/verify.d.ts +4 -0
  49. package/dist/commands/verify.d.ts.map +1 -0
  50. package/dist/commands/verify.js +296 -0
  51. package/dist/commands/verify.js.map +1 -0
  52. package/dist/core/db.d.ts +47 -0
  53. package/dist/core/db.d.ts.map +1 -0
  54. package/dist/core/db.js +326 -0
  55. package/dist/core/db.js.map +1 -0
  56. package/dist/core/format.d.ts +3 -0
  57. package/dist/core/format.d.ts.map +1 -0
  58. package/dist/core/format.js +221 -0
  59. package/dist/core/format.js.map +1 -0
  60. package/dist/core/fs.d.ts +16 -0
  61. package/dist/core/fs.d.ts.map +1 -0
  62. package/dist/core/fs.js +175 -0
  63. package/dist/core/fs.js.map +1 -0
  64. package/dist/core/git.d.ts +6 -0
  65. package/dist/core/git.d.ts.map +1 -0
  66. package/dist/core/git.js +20 -0
  67. package/dist/core/git.js.map +1 -0
  68. package/dist/core/hash.d.ts +10 -0
  69. package/dist/core/hash.d.ts.map +1 -0
  70. package/dist/core/hash.js +25 -0
  71. package/dist/core/hash.js.map +1 -0
  72. package/dist/core/manifest.d.ts +6 -0
  73. package/dist/core/manifest.d.ts.map +1 -0
  74. package/dist/core/manifest.js +207 -0
  75. package/dist/core/manifest.js.map +1 -0
  76. package/dist/core/yaml.d.ts +11 -0
  77. package/dist/core/yaml.d.ts.map +1 -0
  78. package/dist/core/yaml.js +94 -0
  79. package/dist/core/yaml.js.map +1 -0
  80. package/dist/index.d.ts +3 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +167 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/types.d.ts +351 -0
  85. package/dist/types.d.ts.map +1 -0
  86. package/dist/types.js +4 -0
  87. package/dist/types.js.map +1 -0
  88. package/docs/Voorlopige projekidee.md +695 -0
  89. package/docs/handover-v0.3.md +355 -0
  90. package/docs/handover-v0.4.md +367 -0
  91. package/docs/prd.md +318 -0
  92. package/docs/project-roadmap.md +279 -0
  93. package/docs/release-checklist-v0.5.md +109 -0
  94. package/docs/v0.2 pre-design.md +182 -0
  95. package/docs/v0.2 pre-roadmap.md +270 -0
  96. package/docs/v0.3 pre-design.md +686 -0
  97. package/docs/v0.4 pre-design.md +417 -0
  98. package/docs/v0.5 pre-design.md +481 -0
  99. package/package.json +67 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,57 @@
1
+ # Changelog
2
+
3
+ All notable changes to pmem are documented here.
4
+
5
+ ## 0.5.0 - Productization Beta
6
+
7
+ ### Added
8
+
9
+ - Added user-facing `README.md` with install, quick start, core concepts, agent workflow, CLI reference, exit codes, and troubleshooting.
10
+ - Added npm package readiness metadata: repository, bugs, homepage, engines, files whitelist, and expanded keywords.
11
+ - Added MIT `LICENSE`.
12
+ - Added install smoke E2E script: `npm run test:e2e:install`.
13
+ - Added real memory workflow E2E script: `npm run test:e2e:workflow`.
14
+ - Added `parseGitStatusPorcelain` helper with tests for modified, added, untracked, and renamed files.
15
+ - Added v0.5 pre-design and implementation plan docs.
16
+
17
+ ### Changed
18
+
19
+ - Updated CLI version to `0.5.0`.
20
+ - Updated `AGENTS.md` and `CLAUDE.md` to the v0.5 Productization Beta scope.
21
+ - Updated `pmem init` generated AGENTS and integration templates with v0.5 workflow instructions.
22
+ - Tightened npm tarball contents to runtime files, README, LICENSE, and top-level docs.
23
+
24
+ ### Fixed
25
+
26
+ - Fixed git porcelain parsing for modified files whose status begins with a leading space, such as ` M src/index.ts`.
27
+ - Fixed `mark-dirty --auto` and `status` path detection by sharing the same porcelain parser.
28
+
29
+ ## 0.4.0 - Agent Workflow Automation
30
+
31
+ - Added `pmem status`.
32
+ - Added `mark-dirty --auto`.
33
+ - Added `update --suggest` and `update --apply-suggestion`.
34
+ - Added `distill --suggest` and `distill --apply-suggestion`.
35
+ - Added session update log summary.
36
+ - Added hooks-friendly JSON output and exit code contracts.
37
+ - Added Claude Code, Cursor, and Codex integration templates.
38
+
39
+ ## 0.3.0 - SQLite Runtime
40
+
41
+ - Introduced `.pmem/pmem.db` as the primary runtime index.
42
+ - Added SQLite-backed cards, edges, aliases, tags, paths, dirty flags, sessions, and update logs.
43
+ - Added content-hash incremental rebuild.
44
+ - Added FTS5-backed search when available, with fallback behavior.
45
+
46
+ ## 0.2.0 - File Mode Trust
47
+
48
+ - Added guided initialization.
49
+ - Added schema migration.
50
+ - Added atomic writes and file locks.
51
+ - Added card policy validation.
52
+ - Added initial distillation workflow.
53
+
54
+ ## 0.1.0 - Core Loop
55
+
56
+ - Added initial CLI loop: init, rebuild, recall, ask, related, trace, verify, update, mark-dirty, and integration commands.
57
+ - Established Markdown cards as the source of truth.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pmem contributors
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,349 @@
1
+ # pmem
2
+
3
+ Project Memory for AI Agents.
4
+
5
+ `pmem` is a local CLI runtime that helps coding agents remember a project: where it is, what changed, what matters next, and why. It stores project memory as Markdown cards in `.pmem/`, then builds SQLite indexes so agents can recall context with fewer tokens and update memory as code changes.
6
+
7
+ ## Why pmem
8
+
9
+ Coding agents lose project context quickly. A repository has source files, docs, decisions, tasks, and traces, but the agent usually has to rediscover that context every session.
10
+
11
+ `pmem` gives the project a small, explicit memory layer:
12
+
13
+ - `pmem recall` restores the hot project context.
14
+ - `pmem ask "<query>"` finds relevant memory cards.
15
+ - `pmem status` maps changed files back to affected cards.
16
+ - `pmem update --suggest` tells an agent what memory likely needs attention.
17
+ - `pmem verify` checks that Markdown cards and runtime indexes still agree.
18
+
19
+ The design is intentionally local and Git-friendly. Markdown cards remain the source of truth. SQLite is a rebuildable runtime index, not a separate knowledge base.
20
+
21
+ ## Who It Is For
22
+
23
+ `pmem` is useful when:
24
+
25
+ - You use code agents such as Codex, Claude Code, Cursor, or similar tools.
26
+ - Your project has decisions and context that should survive across sessions.
27
+ - You want agents to update memory deliberately instead of auto-writing noisy logs.
28
+ - You prefer local files over hosted memory services.
29
+
30
+ It is not a vector database, MCP server, Graph UI, or remote multi-user service. v0.5 focuses on making the CLI product installable, understandable, and reliable as a Beta.
31
+
32
+ ## Install
33
+
34
+ From the repository:
35
+
36
+ ```bash
37
+ npm install
38
+ npm run build
39
+ npm link
40
+ pmem --version
41
+ ```
42
+
43
+ For release validation, build an installable tarball:
44
+
45
+ ```bash
46
+ npm run build
47
+ npm pack
48
+ npm install -g ./pmem-*.tgz
49
+ pmem --help
50
+ ```
51
+
52
+ Node.js 18 or newer is required.
53
+
54
+ ## 5-Minute Quick Start
55
+
56
+ Create project memory in a repository:
57
+
58
+ ```bash
59
+ pmem init my-project
60
+ pmem rebuild
61
+ pmem recall --budget 2000
62
+ pmem verify
63
+ ```
64
+
65
+ For a richer setup:
66
+
67
+ ```bash
68
+ pmem init my-project --guided
69
+ ```
70
+
71
+ Add a module card that points at source files:
72
+
73
+ ```bash
74
+ mkdir -p .pmem/modules src
75
+ cat > .pmem/modules/core.md <<'EOF'
76
+ ---
77
+ id: module.core
78
+ type: module
79
+ status: active
80
+ tags: [core]
81
+ source_files: [src/index.ts]
82
+ ---
83
+
84
+ # Core
85
+
86
+ ## Purpose
87
+ Main project entry point.
88
+ EOF
89
+
90
+ echo "export const value = 1;" > src/index.ts
91
+ pmem rebuild
92
+ pmem ask "core" --format compact
93
+ ```
94
+
95
+ Then make a code change and let pmem identify the affected memory:
96
+
97
+ ```bash
98
+ echo "export const value = 2;" > src/index.ts
99
+ pmem status --format json
100
+ pmem mark-dirty --auto
101
+ pmem update --suggest --format json
102
+ pmem update --confirm -s "Updated core module" -n "Continue development"
103
+ pmem verify
104
+ ```
105
+
106
+ Note: `pmem update --suggest` exits with code `1` when it found suggestions. That means "action suggested", not "command failed".
107
+
108
+ ## Core Concepts
109
+
110
+ ### Markdown Cards
111
+
112
+ Cards under `.pmem/**/*.md` are the source of truth. Each card has YAML frontmatter and Markdown body content.
113
+
114
+ Common card types include:
115
+
116
+ - `module`
117
+ - `feature`
118
+ - `decision`
119
+ - `task`
120
+ - `risk`
121
+ - `trace`
122
+
123
+ Important frontmatter fields:
124
+
125
+ ```yaml
126
+ id: module.core
127
+ type: module
128
+ status: active
129
+ tags: [core]
130
+ aliases: [runtime]
131
+ source_files: [src/index.ts]
132
+ depends_on: [decision.sqlite_runtime]
133
+ ```
134
+
135
+ ### SQLite Runtime
136
+
137
+ `.pmem/pmem.db` stores rebuildable indexes and runtime state:
138
+
139
+ - cards
140
+ - edges
141
+ - aliases
142
+ - tags
143
+ - paths
144
+ - sessions
145
+ - dirty flags
146
+ - update logs
147
+
148
+ Do not edit SQLite directly. Edit Markdown cards or use pmem workflow commands, then run `pmem rebuild`.
149
+
150
+ ### Recall And Ask
151
+
152
+ Use `recall` for the current project state:
153
+
154
+ ```bash
155
+ pmem recall --budget 2000
156
+ ```
157
+
158
+ Use `ask` for targeted retrieval:
159
+
160
+ ```bash
161
+ pmem ask "sqlite runtime" --format compact
162
+ pmem ask "release checklist" --format json
163
+ ```
164
+
165
+ ### Dirty, Update, Distill
166
+
167
+ The memory update flow is intentionally confirmation-first:
168
+
169
+ ```bash
170
+ pmem status
171
+ pmem mark-dirty --auto
172
+ pmem update --suggest
173
+ pmem update --confirm -s "<summary>" -n "<next step>"
174
+ pmem distill --suggest
175
+ pmem verify
176
+ ```
177
+
178
+ `distill` consolidates trace cards into stable cards when enough evidence accumulates.
179
+
180
+ ## Agent Workflow
181
+
182
+ At the start of an agent session:
183
+
184
+ ```bash
185
+ pmem session start -a "Codex"
186
+ pmem recall --format compact --budget 2000
187
+ ```
188
+
189
+ Before a specific task:
190
+
191
+ ```bash
192
+ pmem ask "<task or module>" --format compact
193
+ ```
194
+
195
+ After editing files:
196
+
197
+ ```bash
198
+ pmem status --format json
199
+ pmem mark-dirty --auto
200
+ pmem update --suggest --format json
201
+ ```
202
+
203
+ At session end:
204
+
205
+ ```bash
206
+ pmem update --confirm -s "<what changed>" -n "<next step>"
207
+ pmem session end -s "<task summary>"
208
+ pmem verify
209
+ ```
210
+
211
+ Installed integration templates are available under:
212
+
213
+ ```txt
214
+ .pmem/integrations/
215
+ ```
216
+
217
+ ## CLI Reference
218
+
219
+ ```bash
220
+ pmem init [project-name] [--guided]
221
+
222
+ pmem recall [--budget N] [--format compact|json|paths|pack]
223
+ pmem ask <query> [--format compact|json|paths|pack]
224
+ pmem related <id> [--depth N] [--type <edge-type>]
225
+ pmem trace <id>
226
+
227
+ pmem status [--since <timestamp>] [--format compact|json]
228
+ pmem mark-dirty [-r <reason>] [--auto]
229
+ pmem update [--auto|--suggest|--apply-suggestion <id>|--confirm|--force] \
230
+ [-s <summary>] [-n <next>] [--format compact|json]
231
+
232
+ pmem distill [--suggest|--apply-suggestion <id>|--confirm|--suggest-splits]
233
+ pmem rebuild [--changed|--full|--card <id>]
234
+ pmem verify [--fix]
235
+ pmem migrate --to 0.3 [--dry-run] [--backup]
236
+ pmem session start [-a <agent-name>]
237
+ pmem session end [-s <summary>]
238
+ pmem integration list|install <framework>|verify
239
+ ```
240
+
241
+ ## Exit Codes
242
+
243
+ Some pmem commands use exit code `1` as a workflow signal, not a hard failure.
244
+
245
+ | Command | 0 | 1 | 2 |
246
+ |---------|---|---|---|
247
+ | `pmem status` | changes found | no changes | error |
248
+ | `pmem update --suggest` | no suggestions | suggestions found | error |
249
+ | `pmem distill --suggest` | no distillation needed | distillation suggested | error |
250
+ | `pmem verify` | passed | warnings | errors |
251
+
252
+ Agents should parse command output and treat code `1` according to the command contract.
253
+
254
+ ## Project Layout
255
+
256
+ ```txt
257
+ .pmem/
258
+ manifest.yml
259
+ index.md
260
+ state.md
261
+ next.md
262
+ modules/
263
+ features/
264
+ decisions/
265
+ tasks/
266
+ traces/
267
+ summaries/
268
+ risks/
269
+ candidates/
270
+ skills/
271
+ integrations/
272
+ indexes/
273
+ pmem.db
274
+ ```
275
+
276
+ Source-of-truth files are Markdown cards. `pmem.db` and `indexes/` are generated runtime data.
277
+
278
+ ## Troubleshooting
279
+
280
+ ### No `.pmem` Directory
281
+
282
+ Run:
283
+
284
+ ```bash
285
+ pmem init <project-name>
286
+ ```
287
+
288
+ Run commands from the project root where `.pmem/` should live.
289
+
290
+ ### `.pmem/pmem.db` Missing
291
+
292
+ Run:
293
+
294
+ ```bash
295
+ pmem rebuild
296
+ ```
297
+
298
+ If the project has no memory cards yet, add a module, decision, or task card first.
299
+
300
+ ### `pmem ask` Returns No Matches
301
+
302
+ Try:
303
+
304
+ ```bash
305
+ pmem recall --budget 2000
306
+ ```
307
+
308
+ Then check whether the relevant card has useful `id`, `tags`, `aliases`, or `source_files` frontmatter.
309
+
310
+ ### Non-Git Projects
311
+
312
+ `pmem status` uses `git status --porcelain` when available. Outside Git repositories it falls back to mtime scanning and writes `.pmem/.last-status`.
313
+
314
+ ### FTS5 Unavailable
315
+
316
+ Some SQLite builds do not include FTS5. pmem falls back to `LIKE` search; this is slower but should not block normal use.
317
+
318
+ ### Dirty Flags Remain
319
+
320
+ Run:
321
+
322
+ ```bash
323
+ pmem update --suggest
324
+ pmem update --confirm -s "<summary>" -n "<next step>"
325
+ pmem verify
326
+ ```
327
+
328
+ ## Roadmap
329
+
330
+ v0.5 is the Productization Beta milestone:
331
+
332
+ - README and quick start
333
+ - npm package readiness
334
+ - install smoke E2E
335
+ - real project workflow E2E
336
+ - agent instruction sync
337
+ - release checklist
338
+
339
+ Deferred beyond v0.5:
340
+
341
+ - embedding
342
+ - `pmem serve` / MCP / REST
343
+ - Graph UI
344
+ - telemetry
345
+ - multi-user remote service
346
+
347
+ ## License
348
+
349
+ MIT
@@ -0,0 +1,3 @@
1
+ import type { CliFormat } from '../types';
2
+ export declare function askCommand(query: string, format?: CliFormat): void;
3
+ //# sourceMappingURL=ask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../src/commands/ask.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,UAAU,CAAC;AAwB5D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,SAAqB,GAAG,IAAI,CAwR7E"}