@phren/cli 0.0.1

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 (185) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +590 -0
  3. package/mcp/dist/capabilities/cli.js +61 -0
  4. package/mcp/dist/capabilities/index.js +15 -0
  5. package/mcp/dist/capabilities/mcp.js +61 -0
  6. package/mcp/dist/capabilities/types.js +57 -0
  7. package/mcp/dist/capabilities/vscode.js +61 -0
  8. package/mcp/dist/capabilities/web-ui.js +61 -0
  9. package/mcp/dist/cli-actions.js +302 -0
  10. package/mcp/dist/cli-config.js +580 -0
  11. package/mcp/dist/cli-extract.js +305 -0
  12. package/mcp/dist/cli-govern.js +371 -0
  13. package/mcp/dist/cli-graph.js +169 -0
  14. package/mcp/dist/cli-hooks-citations.js +44 -0
  15. package/mcp/dist/cli-hooks-context.js +56 -0
  16. package/mcp/dist/cli-hooks-globs.js +83 -0
  17. package/mcp/dist/cli-hooks-output.js +130 -0
  18. package/mcp/dist/cli-hooks-retrieval.js +2 -0
  19. package/mcp/dist/cli-hooks-session.js +1402 -0
  20. package/mcp/dist/cli-hooks.js +350 -0
  21. package/mcp/dist/cli-namespaces.js +989 -0
  22. package/mcp/dist/cli-ops.js +253 -0
  23. package/mcp/dist/cli-search.js +407 -0
  24. package/mcp/dist/cli.js +108 -0
  25. package/mcp/dist/content-archive.js +278 -0
  26. package/mcp/dist/content-citation.js +391 -0
  27. package/mcp/dist/content-dedup.js +622 -0
  28. package/mcp/dist/content-learning.js +472 -0
  29. package/mcp/dist/content-metadata.js +186 -0
  30. package/mcp/dist/content-validate.js +462 -0
  31. package/mcp/dist/core-finding.js +54 -0
  32. package/mcp/dist/core-project.js +36 -0
  33. package/mcp/dist/core-search.js +50 -0
  34. package/mcp/dist/data-access.js +400 -0
  35. package/mcp/dist/data-tasks.js +821 -0
  36. package/mcp/dist/embedding.js +344 -0
  37. package/mcp/dist/entrypoint.js +387 -0
  38. package/mcp/dist/finding-context.js +172 -0
  39. package/mcp/dist/finding-impact.js +181 -0
  40. package/mcp/dist/finding-journal.js +122 -0
  41. package/mcp/dist/finding-lifecycle.js +259 -0
  42. package/mcp/dist/governance-audit.js +22 -0
  43. package/mcp/dist/governance-locks.js +96 -0
  44. package/mcp/dist/governance-policy.js +648 -0
  45. package/mcp/dist/governance-scores.js +355 -0
  46. package/mcp/dist/hooks.js +449 -0
  47. package/mcp/dist/impact-scoring.js +22 -0
  48. package/mcp/dist/index-query.js +168 -0
  49. package/mcp/dist/index.js +205 -0
  50. package/mcp/dist/init-config.js +336 -0
  51. package/mcp/dist/init-preferences.js +62 -0
  52. package/mcp/dist/init-setup.js +1305 -0
  53. package/mcp/dist/init-shared.js +29 -0
  54. package/mcp/dist/init.js +1730 -0
  55. package/mcp/dist/link-checksums.js +62 -0
  56. package/mcp/dist/link-context.js +257 -0
  57. package/mcp/dist/link-doctor.js +591 -0
  58. package/mcp/dist/link-skills.js +212 -0
  59. package/mcp/dist/link.js +596 -0
  60. package/mcp/dist/logger.js +15 -0
  61. package/mcp/dist/machine-identity.js +38 -0
  62. package/mcp/dist/mcp-config.js +254 -0
  63. package/mcp/dist/mcp-data.js +315 -0
  64. package/mcp/dist/mcp-extract-facts.js +78 -0
  65. package/mcp/dist/mcp-extract.js +133 -0
  66. package/mcp/dist/mcp-finding.js +557 -0
  67. package/mcp/dist/mcp-graph.js +339 -0
  68. package/mcp/dist/mcp-hooks.js +256 -0
  69. package/mcp/dist/mcp-memory.js +58 -0
  70. package/mcp/dist/mcp-ops.js +328 -0
  71. package/mcp/dist/mcp-search.js +628 -0
  72. package/mcp/dist/mcp-session.js +651 -0
  73. package/mcp/dist/mcp-skills.js +189 -0
  74. package/mcp/dist/mcp-tasks.js +551 -0
  75. package/mcp/dist/mcp-types.js +7 -0
  76. package/mcp/dist/memory-ui-assets.js +6 -0
  77. package/mcp/dist/memory-ui-data.js +513 -0
  78. package/mcp/dist/memory-ui-graph.js +1910 -0
  79. package/mcp/dist/memory-ui-page.js +353 -0
  80. package/mcp/dist/memory-ui-scripts.js +1387 -0
  81. package/mcp/dist/memory-ui-server.js +1218 -0
  82. package/mcp/dist/memory-ui-styles.js +555 -0
  83. package/mcp/dist/memory-ui.js +9 -0
  84. package/mcp/dist/package-metadata.js +13 -0
  85. package/mcp/dist/phren-art.js +52 -0
  86. package/mcp/dist/phren-core.js +108 -0
  87. package/mcp/dist/phren-dotenv.js +67 -0
  88. package/mcp/dist/phren-paths.js +476 -0
  89. package/mcp/dist/proactivity.js +172 -0
  90. package/mcp/dist/profile-store.js +228 -0
  91. package/mcp/dist/project-config.js +85 -0
  92. package/mcp/dist/project-locator.js +25 -0
  93. package/mcp/dist/project-topics.js +1134 -0
  94. package/mcp/dist/provider-adapters.js +176 -0
  95. package/mcp/dist/runtime-profile.js +18 -0
  96. package/mcp/dist/session-checkpoints.js +131 -0
  97. package/mcp/dist/session-utils.js +68 -0
  98. package/mcp/dist/shared-content.js +8 -0
  99. package/mcp/dist/shared-embedding-cache.js +143 -0
  100. package/mcp/dist/shared-fragment-graph.js +456 -0
  101. package/mcp/dist/shared-governance.js +4 -0
  102. package/mcp/dist/shared-index.js +1334 -0
  103. package/mcp/dist/shared-ollama.js +192 -0
  104. package/mcp/dist/shared-paths.js +1 -0
  105. package/mcp/dist/shared-retrieval.js +796 -0
  106. package/mcp/dist/shared-search-fallback.js +375 -0
  107. package/mcp/dist/shared-sqljs.js +42 -0
  108. package/mcp/dist/shared-stemmer.js +171 -0
  109. package/mcp/dist/shared-vector-index.js +199 -0
  110. package/mcp/dist/shared.js +114 -0
  111. package/mcp/dist/shell-entry.js +209 -0
  112. package/mcp/dist/shell-input.js +943 -0
  113. package/mcp/dist/shell-palette.js +119 -0
  114. package/mcp/dist/shell-render.js +252 -0
  115. package/mcp/dist/shell-state-store.js +81 -0
  116. package/mcp/dist/shell-types.js +13 -0
  117. package/mcp/dist/shell-view-list.js +14 -0
  118. package/mcp/dist/shell-view.js +707 -0
  119. package/mcp/dist/shell.js +352 -0
  120. package/mcp/dist/skill-files.js +117 -0
  121. package/mcp/dist/skill-registry.js +279 -0
  122. package/mcp/dist/skill-state.js +28 -0
  123. package/mcp/dist/startup-embedding.js +57 -0
  124. package/mcp/dist/status.js +323 -0
  125. package/mcp/dist/synonyms.json +670 -0
  126. package/mcp/dist/task-hygiene.js +251 -0
  127. package/mcp/dist/task-lifecycle.js +347 -0
  128. package/mcp/dist/tasks-github.js +76 -0
  129. package/mcp/dist/telemetry.js +165 -0
  130. package/mcp/dist/test-global-setup.js +37 -0
  131. package/mcp/dist/tool-registry.js +104 -0
  132. package/mcp/dist/update.js +97 -0
  133. package/mcp/dist/utils.js +543 -0
  134. package/package.json +67 -0
  135. package/skills/README.md +7 -0
  136. package/skills/consolidate/SKILL.md +152 -0
  137. package/skills/discover/SKILL.md +175 -0
  138. package/skills/init/SKILL.md +216 -0
  139. package/skills/profiles/SKILL.md +121 -0
  140. package/skills/sync/SKILL.md +261 -0
  141. package/starter/README.md +74 -0
  142. package/starter/global/CLAUDE.md +89 -0
  143. package/starter/global/skills/humanize.md +30 -0
  144. package/starter/global/skills/pipeline.md +35 -0
  145. package/starter/global/skills/release.md +35 -0
  146. package/starter/machines.yaml +8 -0
  147. package/starter/my-api/.claude/skills/README.md +7 -0
  148. package/starter/my-api/CLAUDE.md +33 -0
  149. package/starter/my-api/FINDINGS.md +9 -0
  150. package/starter/my-api/summary.md +7 -0
  151. package/starter/my-api/tasks.md +7 -0
  152. package/starter/my-first-project/.claude/skills/README.md +7 -0
  153. package/starter/my-first-project/CLAUDE.md +49 -0
  154. package/starter/my-first-project/FINDINGS.md +24 -0
  155. package/starter/my-first-project/summary.md +11 -0
  156. package/starter/my-first-project/tasks.md +25 -0
  157. package/starter/my-frontend/.claude/skills/README.md +7 -0
  158. package/starter/my-frontend/CLAUDE.md +33 -0
  159. package/starter/my-frontend/FINDINGS.md +9 -0
  160. package/starter/my-frontend/summary.md +7 -0
  161. package/starter/my-frontend/tasks.md +7 -0
  162. package/starter/profiles/default.yaml +4 -0
  163. package/starter/profiles/personal.yaml +4 -0
  164. package/starter/profiles/work.yaml +4 -0
  165. package/starter/templates/README.md +7 -0
  166. package/starter/templates/frontend/CLAUDE.md +23 -0
  167. package/starter/templates/frontend/FINDINGS.md +7 -0
  168. package/starter/templates/frontend/reference/README.md +4 -0
  169. package/starter/templates/frontend/summary.md +7 -0
  170. package/starter/templates/frontend/tasks.md +11 -0
  171. package/starter/templates/library/CLAUDE.md +22 -0
  172. package/starter/templates/library/FINDINGS.md +7 -0
  173. package/starter/templates/library/reference/README.md +4 -0
  174. package/starter/templates/library/summary.md +7 -0
  175. package/starter/templates/library/tasks.md +11 -0
  176. package/starter/templates/monorepo/CLAUDE.md +21 -0
  177. package/starter/templates/monorepo/FINDINGS.md +7 -0
  178. package/starter/templates/monorepo/reference/README.md +4 -0
  179. package/starter/templates/monorepo/summary.md +7 -0
  180. package/starter/templates/monorepo/tasks.md +11 -0
  181. package/starter/templates/python-project/CLAUDE.md +21 -0
  182. package/starter/templates/python-project/FINDINGS.md +7 -0
  183. package/starter/templates/python-project/reference/README.md +4 -0
  184. package/starter/templates/python-project/summary.md +7 -0
  185. package/starter/templates/python-project/tasks.md +10 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ala Arab
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,590 @@
1
+ <div align="center">
2
+ <br>
3
+
4
+ <img src="icon.svg" width="120" alt="phren" />
5
+
6
+ <br>
7
+
8
+ # phren
9
+
10
+ **Meet phren. He remembers so your agent doesn't have to.**
11
+
12
+ [![npm](https://img.shields.io/npm/v/%40alaarab%2Fphren?style=flat&labelColor=0D0D0D&color=7C3AED)](https://www.npmjs.com/package/@alaarab/phren)
13
+ [![Docs](https://img.shields.io/badge/docs-alaarab.github.io%2Fphren-A78BFA?style=flat&labelColor=0D0D0D)](https://alaarab.github.io/phren/)
14
+ [![Whitepaper PDF](https://img.shields.io/badge/whitepaper-PDF-2563EB?style=flat&labelColor=0D0D0D)](https://alaarab.github.io/phren/whitepaper.pdf)
15
+
16
+ <br>
17
+
18
+ Phren is your project's memory keeper. He collects fragments — insights, decisions, patterns — and surfaces them when they matter. Tell him what you learned, and he'll hold it in a git-backed store you control. Next session, next machine, next agent: phren remembers what happened and feeds back only what fits, so your agents keep building on what they already know instead of starting fresh every time.
19
+
20
+ <br>
21
+ </div>
22
+
23
+ ---
24
+
25
+ ## Getting started
26
+
27
+ ```bash
28
+ npm install -g @alaarab/phren
29
+ phren init
30
+ # Preview changes without writing files
31
+ phren init --dry-run
32
+ ```
33
+
34
+ | Scenario | What to do |
35
+ |---|---|
36
+ | First time | `npm install -g @alaarab/phren && phren init` |
37
+ | Add a project | Open a session there and let the agent ask, or run `phren add` |
38
+ | New machine | `phren init` and paste your phren repo URL |
39
+ | Repo-local install | `phren init --mode project-local` inside the repo |
40
+
41
+ `phren init` supports two install modes:
42
+
43
+ - `shared` (default): personal cross-machine memory rooted at `~/.phren`
44
+ - `project-local`: one repo-owned install rooted at `<repo>/.phren`
45
+
46
+ What init does depends on the mode:
47
+
48
+ - `shared`: creates `~/.phren`, registers supported MCP targets, sets up Claude hooks, registers the current machine/profile, and offers to add the current repo
49
+ - `project-local`: creates `<repo>/.phren`, writes a root manifest, configures VS Code workspace MCP in `.vscode/mcp.json`, and keeps all state inside the repo
50
+
51
+ Common init behavior:
52
+
53
+ - Writes a required `phren.root.yaml` manifest
54
+ - Offers to add the current repo when you run it inside a git project or a folder with `CLAUDE.md`
55
+ - Asks who should own repo-facing instruction files: `phren-managed`, `detached`, or `repo-managed`
56
+ - Asks how task handling should work: `off`, `manual`, `suggest`, or `auto`
57
+ - Supports `phren init --dry-run` for a no-write preview
58
+
59
+ After init, you'll see something like:
60
+
61
+ ```
62
+ phren initialized
63
+ Path: ~/.phren
64
+ Machine: work-laptop
65
+ Profile: personal (6 projects)
66
+ MCP: registered for Claude Code
67
+ Hooks: prompt injection, auto-save, session lifecycle
68
+
69
+ Open a prompt in your project directory. Your next prompt will already have context.
70
+ ```
71
+
72
+ ## Works with every major agent
73
+
74
+ Init detects your tools and registers them. Tell phren something in Claude Code, and he surfaces it in Codex next session — and the other way around.
75
+
76
+ | Agent | Shared mode | Project-local mode |
77
+ |-------|-------------|--------------------|
78
+ | Claude Code | MCP + hooks | not supported |
79
+ | VS Code Copilot | user MCP | workspace MCP |
80
+ | GitHub Copilot CLI | user MCP | not supported |
81
+ | Cursor | user MCP | not supported |
82
+ | OpenAI Codex | user MCP/TOML | not supported |
83
+
84
+ Automatic prompt injection and lifecycle hooks are still Claude-only. Other editors use MCP tools without hook-driven context injection.
85
+
86
+ ---
87
+
88
+ ## Positioning
89
+
90
+ Phren sits in the same broad agent-memory space as claude-mem, Supermemory, Mem0, GitHub Copilot Memory, and research systems such as MemoryBank and MemGPT. He does not claim to invent long-term memory, progressive disclosure, or hybrid retrieval as general ideas.
91
+
92
+ The distinction is architectural: phren applies those patterns to a repo-backed project memory system built from markdown + git, with explicit governance, review workflows, and shared use across agents, projects, and machines.
93
+
94
+ ---
95
+
96
+ ## Why phren
97
+
98
+ ### New in v1.33.0
99
+
100
+ - Finding lifecycle is now first-class: normalized status metadata, explicit supersede/retract/resolve operations, lifecycle-aware ranking, and lifecycle history preserved through consolidation.
101
+ - Findings now track provenance (`human`, `agent`, `hook`, `extract`) and impact scoring now accounts for passive surfacing with stronger decay resistance for repeatedly useful memories.
102
+ - Session continuity improved with automatic cross-session task checkpoints and richer resumption context.
103
+ - Onboarding is more adaptive: domain-aware init prompts, content-based topic suggestions with pinning, adaptive project-specific synonyms, and storage location selection (global, per-project, custom).
104
+ - Memory structure and integrations expanded: any file under `reference/` is indexed, scoped memory views are available for spawned agents, and settings are consolidated into a findings-first integrations surface.
105
+ - VS Code extension onboarding and release workflow were hardened (auto-install path, uninstall command, publish prep), with first-run reliability fixes and docs synced to the 60-tool MCP server.
106
+
107
+ **Compounding context, bounded retrieval.** Phren lets project memory grow over time, but he doesn't inject the whole store. He searches what you actually wrote and keeps injection selective — about 550 tokens by default — so long-lived context doesn't turn into prompt bloat. Tune it with `PHREN_CONTEXT_TOKEN_BUDGET`.
108
+
109
+ **Local retrieval keeps the hot path fast.** In the default path, search runs against a local SQLite index instead of a hosted memory API. That cuts out the network hop and helps keep exact-ish code-memory queries responsive.
110
+
111
+ **Stale context fades, recurring context stays.** Phren lets findings decay over time. Patterns that keep coming up stay strong. Things that haven't mattered in months fall back, so what phren surfaces reflects what's still useful instead of everything ever recorded.
112
+
113
+ **Cross-machine continuity through git sync.** Claude Code, Codex, Cursor — they all talk to the same phren. What one tool figures out, phren carries to the next machine through ordinary git sync cycles, without depending on a remote memory service. Profiles keep work and personal separate.
114
+
115
+ **Your project memory stays in a repo you control.** No account, no vendor, no hosted service in the default path. Markdown in a repo you control. Read it, edit it, grep it, delete it.
116
+
117
+ ---
118
+
119
+ ## How it runs itself
120
+
121
+ Three things happen every session without you doing anything:
122
+
123
+ **Before each prompt** — phren pulls keywords from your message, searches his index, and injects the best matches. Trust filtering drops low-confidence or outdated entries.
124
+
125
+ **After each response** — phren commits changes locally. If a remote is configured, he queues a background sync worker to push safely. If nothing changed, he skips.
126
+
127
+ **When context resets** — phren re-injects your project summary, recent findings, and active tasks so the agent picks up where it left off.
128
+
129
+ Two more things run in the background:
130
+
131
+ **Consolidation.** When findings pile up past the threshold, phren flags it once per session. He governs and prunes on his own schedule in the background, and `/phren-consolidate` remains the direct operator command for cleanup and pattern promotion.
132
+
133
+ **Review queue.** Findings that phren isn't confident about land in `MEMORY_QUEUE.md` for your review. Triage from the shell (press `m`) or with `:mq approve`, `:mq reject`, `:mq edit`.
134
+
135
+ ---
136
+
137
+ ## Reference
138
+
139
+ <details>
140
+ <summary><strong>What phren remembers</strong></summary>
141
+
142
+ `phren init` creates your project store with starter templates. Each project gets its own directory. Tell phren more as the project grows.
143
+
144
+ | File | What it's for |
145
+ |------|--------------|
146
+ | `summary.md` | Five-line card: what, stack, status, how to run, key insight |
147
+ | `CLAUDE.md` | Full context: architecture, commands, conventions |
148
+ | `REFERENCE.md` | Deep reference: API details, data models, things too long for CLAUDE.md |
149
+ | `FINDINGS.md` | Bugs hit, patterns discovered, things to avoid next time |
150
+ | `CANONICAL_MEMORIES.md` | Pinned memories that never expire and always inject |
151
+ | `tasks.md` | Task list that persists across sessions |
152
+ | `MEMORY_QUEUE.md` | Items waiting for your review |
153
+ | `skills/` | Project-local phren skill source files; the resolved agent-facing mirror is generated into `.claude/skills/` as local state and should not be committed from app repos |
154
+
155
+ </details>
156
+
157
+ <details>
158
+ <summary><strong>Memory across your machines</strong></summary>
159
+
160
+ Shared mode uses one phren repo that carries your project memory. Push it to a private remote, clone it anywhere you work.
161
+
162
+ ```bash
163
+ cd ~/.phren
164
+ git init && git add . && git commit -m "Initial phren"
165
+ git remote add origin git@github.com:YOU/my-phren.git
166
+ git push -u origin main
167
+ ```
168
+
169
+ On a new machine: run `phren init` and paste your repo URL when the walkthrough asks if you have an existing phren repo.
170
+
171
+ `SessionStart` pulls on open. The Stop hook commits locally after each response and queues a best-effort push when a remote exists. This is eventual consistency -- git gives you portability and auditability, not real-time sync.
172
+
173
+ Shared state lives in your phren repo. Generated local state does not. The `.claude/` mirrors created inside app repos, tool-specific instruction files such as `.github/copilot-instructions.md`, and the local machine alias file (`~/.phren/.machine-id`) are machine-local artifacts and should not be treated as canonical project memory.
174
+
175
+ `machines.yaml` maps each hostname to a profile:
176
+
177
+ ```yaml
178
+ work-desktop: work
179
+ home-laptop: personal
180
+ ```
181
+
182
+ Each profile lists its projects:
183
+
184
+ ```yaml
185
+ # profiles/personal.yaml
186
+ name: personal
187
+ projects:
188
+ - global
189
+ - my-api
190
+ - my-frontend
191
+ - side-project
192
+ ```
193
+
194
+ Profiles decide which projects are active on each machine. `phren init` is the normal refresh path: it registers the current machine/profile mapping, rewires supported agents, and offers to add the current repo when needed.
195
+
196
+ If you want stable names across laptops, desktops, and CI, set the machine name explicitly at onboarding instead of relying on the raw OS hostname:
197
+
198
+ ```bash
199
+ phren init --machine work-laptop --profile work
200
+ ```
201
+
202
+ For CI or unattended setup:
203
+
204
+ ```bash
205
+ phren init --machine ci-runner --profile work
206
+ ```
207
+
208
+ </details>
209
+
210
+ <details>
211
+ <summary><strong>Project-local mode</strong></summary>
212
+
213
+ Project-local mode is the repo-owned install:
214
+
215
+ ```bash
216
+ cd /path/to/repo
217
+ phren init --mode project-local
218
+ ```
219
+
220
+ That creates:
221
+
222
+ - `<repo>/.phren/phren.root.yaml`
223
+ - `<repo>/.phren/<project>/...`
224
+ - `<repo>/.vscode/mcp.json` entry for the workspace server
225
+
226
+ Design constraints:
227
+
228
+ - one phren root per repo
229
+ - one primary project per project-local root
230
+ - no home-directory writes by default
231
+ - no global hooks
232
+ - VS Code workspace MCP is the supported editor integration in this mode
233
+
234
+ This mode is for repo-owned memory, not cross-machine personal memory. If you want profiles, machine mappings, shared hooks, and the full personal-memory workflow, use shared mode.
235
+
236
+ </details>
237
+
238
+ <details>
239
+ <summary><strong>Shared project memory</strong></summary>
240
+
241
+ When more than one tool or session touches the same project, they all talk to the same phren. A Codex session hits a pitfall and tells him. Ten minutes later, a Claude Code session on a different machine gets that fragment in its context — phren carried it over on the next sync cycle. No coordination service or custom broker layer, just phren and a shared git repo.
242
+
243
+ - **Parallel agents** share findings on push/pull cycles
244
+ - **Sequential sessions** build on each other. Session 47 knows everything sessions 1 through 46 learned.
245
+ - **Cross-project patterns** surface when the same insight shows up in two or more projects
246
+ - **Tasks** persist across agents and sessions. One agent adds a task, another finishes it.
247
+
248
+ Because it's all markdown in git, you have a full record of what your agents learned, when, and which session produced each insight.
249
+
250
+ </details>
251
+
252
+ <details>
253
+ <summary><strong>Retrieval modes</strong></summary>
254
+
255
+ **Core mode (default).** Markdown is the source of truth. Git handles sync and audit history. Retrieval runs through a local SQLite FTS5 index. This is the simplest and most portable setup: no required hosted service, predictable token budgets, and a repo you can inspect with normal tools.
256
+
257
+ **Optional semantic mode.** Phren can also use Ollama or an embeddings API for gated semantic recovery when lexical retrieval comes up short. This is mainly for paraphrase-heavy or fuzzy queries. If you mostly search by filenames, symbols, commands, project names, or exact phrases, the lexical path is usually the important one and semantic mode may stay mostly dormant. Semantic mode helps phren find things when the words don't match exactly, not as a blanket speed claim.
258
+
259
+ </details>
260
+
261
+ <details>
262
+ <summary><strong>Init options and templates</strong></summary>
263
+
264
+ ### Install modes
265
+
266
+ Shared mode is the default:
267
+
268
+ ```bash
269
+ phren init
270
+ ```
271
+
272
+ Project-local mode is explicit:
273
+
274
+ ```bash
275
+ phren init --mode project-local
276
+ ```
277
+
278
+ In project-local mode:
279
+
280
+ - `phren mcp-mode on|off` manages `.vscode/mcp.json`
281
+ - `phren hooks-mode` is unsupported
282
+ - `phren config machines` and `phren config profiles` are shared-mode only
283
+ - `phren uninstall` removes `<repo>/.phren` and the workspace MCP entry
284
+
285
+ Hooks-only mode (no MCP tools):
286
+
287
+ ```bash
288
+ phren init --mcp off
289
+ ```
290
+
291
+ Toggle anytime:
292
+
293
+ ```bash
294
+ phren mcp-mode on # shared: user MCP, project-local: VS Code workspace MCP
295
+ phren mcp-mode off # disable MCP for the current install mode
296
+ phren hooks-mode off # shared mode only
297
+ phren hooks-mode on # shared mode only
298
+ ```
299
+
300
+ ### Templates
301
+
302
+ `phren init --template <name>` scaffolds with a project-specific starter:
303
+
304
+ | Template | Best for |
305
+ |----------|----------|
306
+ | `python-project` | Python packages and scripts |
307
+ | `monorepo` | Multi-package repos |
308
+ | `library` | Reusable libraries |
309
+ | `frontend` | React/Vue/web apps |
310
+
311
+ To add an existing repo, run `phren add` from that directory, or just open a session there and phren will suggest it. Phren auto-detects git repos and folders that already contain `CLAUDE.md`.
312
+
313
+ ### Adding projects
314
+
315
+ From a project directory:
316
+
317
+ ```bash
318
+ cd ~/code/my-project
319
+ phren add --ownership repo-managed
320
+ ```
321
+
322
+ Or just open a session in the project directory. Phren notices the unfamiliar repo and asks whether you want him to remember it. If yes, he'll ask whether he should manage repo-facing `CLAUDE.md` / `AGENTS.md` files or leave repo-owned files alone. If you say no, he'll point you to `phren add` for later.
323
+
324
+ For a brand-new scaffold inside Claude:
325
+
326
+ ```bash
327
+ /phren-init my-project
328
+ ```
329
+
330
+ - `phren add` is the supported path for existing repos.
331
+ - Change the default add behavior later with `phren config project-ownership <mode>`.
332
+ - Change task automation later with `phren config workflow set --taskMode=<off|manual|suggest|auto>`.
333
+ - Tune capture levels later with `phren config proactivity.findings <high|medium|low>` and `phren config proactivity.tasks <high|medium|low>`.
334
+ - Platform support and release expectations are documented in [docs/platform-matrix.md](docs/platform-matrix.md).
335
+ - Best-effort vs fail-closed behavior is documented in [docs/error-reporting.md](docs/error-reporting.md).
336
+ - Package/update behavior is documented in [docs/versioning.md](docs/versioning.md).
337
+ - Task items stay local by default. GitHub issue linkage is optional, and promotion is one-way unless you explicitly act on the linked issue.
338
+
339
+ </details>
340
+
341
+ <details>
342
+ <summary><strong>Skills</strong></summary>
343
+
344
+ Four skills for the things that can't be automatic:
345
+
346
+ | Skill | What it does |
347
+ |-------|-------------|
348
+ | `/phren-sync` | Pull latest from your phren repo and re-link on this machine. |
349
+ | `/phren-init` | Scaffold a brand-new project entry. Use this when the project does not exist yet; use `phren add` for an existing repo. |
350
+ | `/phren-discover` | Health audit. Missing files, stale content, stuck tasks. |
351
+ | `/phren-consolidate` | Read findings across all projects and surface patterns that repeat. |
352
+
353
+ **When to run these manually:**
354
+
355
+ - **`/phren-discover`** -- Run after your first week on a new project, or when you feel like things are slipping through the cracks. It tells you what's missing, what's stale, and what's stuck.
356
+ - **`/phren-consolidate`** -- Run after a burst of work across multiple projects, or monthly. It finds patterns that repeat across projects and promotes them to global knowledge so every agent benefits.
357
+ - **`phren maintain govern`** -- Run when search results feel noisy or after a long break from a project. It queues low-value and stale entries for review.
358
+ - **`phren maintain consolidate`** -- Run when findings in a single project feel repetitive. It deduplicates bullets in FINDINGS.md. Use `--dry-run` first to preview.
359
+
360
+ Put personal workflow skills in `~/.phren/global/skills/`. `phren init` and later refresh runs wire them into supported agents automatically.
361
+
362
+ ### Per-project agent config
363
+
364
+ Drop a `phren.project.yaml` in `~/.phren/<project>/` to control what gets injected for that project:
365
+
366
+ ```yaml
367
+ # Opt out of global skill injection for this project
368
+ skills: false
369
+
370
+ # Register extra MCP servers when this project is linked
371
+ mcpServers:
372
+ my-tool:
373
+ command: node
374
+ args: [/path/to/server.js]
375
+ my-api:
376
+ command: /usr/local/bin/api-server
377
+ env:
378
+ API_KEY: "from-your-env"
379
+ ```
380
+
381
+ `phren init` applies project MCP servers into your agent config under namespaced keys (`phren__<project>__<name>`) and cleans them up when the config changes.
382
+
383
+ </details>
384
+
385
+ <details>
386
+ <summary><strong>The MCP server (60 tools)</strong></summary>
387
+
388
+ The MCP server indexes your project store into a local SQLite FTS5 database and exposes 60 tools across 11 modules:
389
+
390
+ - Search and browse (5): `get_memory_detail`, `search_knowledge`, `get_project_summary`, `list_projects`, `get_findings`
391
+ - Task management (13): `get_tasks`, `add_task`, `add_tasks`, `complete_task`, `complete_tasks`, `remove_task`, `update_task`, `link_task_issue`, `promote_task_to_issue`, `pin_task`, `work_next_task`, `promote_task`, `tidy_done_tasks`
392
+ - Finding capture (9): `add_finding`, `add_findings`, `supersede_finding`, `retract_finding`, `resolve_contradiction`, `get_contradictions`, `remove_finding`, `remove_findings`, `push_changes`
393
+ - Memory quality (2): `pin_memory`, `memory_feedback`
394
+ - Data management (3): `export_project`, `import_project`, `manage_project`
395
+ - Fragment graph (5): `search_fragments`, `get_related_docs`, `read_graph`, `link_findings`, `cross_project_fragments`
396
+ - Session management (4): `session_start`, `session_end`, `session_context`, `session_history`
397
+ - Operations and review (8): `add_project`, `get_consolidation_status`, `health_check`, `list_hook_errors`, `get_review_queue`, `approve_queue_item`, `reject_queue_item`, `edit_queue_item`
398
+ - Skills management (6): `list_skills`, `read_skill`, `write_skill`, `remove_skill`, `enable_skill`, `disable_skill`
399
+ - Hooks management (4): `list_hooks`, `toggle_hooks`, `add_custom_hook`, `remove_custom_hook`
400
+ - Extraction (1): `auto_extract_findings`
401
+
402
+ For parameter schemas and examples, see [docs/api-reference.md](docs/api-reference.md).
403
+
404
+ Governance, policy, and maintenance tools are CLI-only (see `phren config` and `phren maintain`).
405
+
406
+ </details>
407
+
408
+ <details>
409
+ <summary><strong>Interactive shell</strong></summary>
410
+
411
+ `phren` in a terminal opens the shell. Seven views, single-key navigation:
412
+
413
+ | Key | View |
414
+ |-----|------|
415
+ | `p` | Projects |
416
+ | `b` | Tasks |
417
+ | `l` | Findings |
418
+ | `m` | Review Queue |
419
+ | `s` | Skills |
420
+ | `k` | Hooks |
421
+ | `h` | Health |
422
+ | `/` | Filter current view |
423
+ | `:` | Command palette |
424
+ | `q` | Quit |
425
+
426
+ ### Palette commands
427
+
428
+ **Tasks:** `:add`, `:complete`, `:move`, `:reprioritize`, `:context`, `:work next`, `:tidy`
429
+
430
+ **Findings:** `:find add`, `:find remove`
431
+
432
+ **Review queue:** `:mq approve`, `:mq reject`, `:mq edit`
433
+
434
+ **Memory quality:** `:govern`, `:consolidate`
435
+
436
+ **Git:** `:undo`, `:diff`, `:conflicts`
437
+
438
+ **Infrastructure:** `:run fix`, `:relink`, `:rerun hooks`, `:update`
439
+
440
+ **Navigation:** `:open <project>`, `:search <query>`, `:reset`
441
+
442
+ The shell works the same on every machine, for every agent.
443
+
444
+ </details>
445
+
446
+ <details>
447
+ <summary><strong>CLI reference</strong></summary>
448
+
449
+ For scripting, hooks, and quick lookups from the terminal:
450
+
451
+ ```bash
452
+ phren # interactive shell (TTY default)
453
+ phren search "rate limiting" # FTS5 search with synonym expansion
454
+ phren add-finding <project> "..." # tell phren something worth remembering
455
+ phren pin <project> "..." # promote canonical memory
456
+ phren tasks [project] # cross-project task view
457
+ phren status # health, active project, stats
458
+ phren doctor [--fix] # health checks + optional self-heal
459
+ phren verify # check init completed correctly
460
+ phren web-ui [--port=3499] # lightweight web UI in the browser
461
+ phren update [--refresh-starter] # update package; optionally refresh starter globals too
462
+ phren uninstall # remove phren config, integrations, and installed data
463
+
464
+ phren add [path] [--ownership <mode>] # add current directory (or path) as a project
465
+ phren projects list # list all projects
466
+ phren projects configure <name> --ownership=<mode> # change a project's ownership mode
467
+ phren projects remove <name> # remove a project (confirmation required)
468
+
469
+ phren mcp-mode [on|off|status] # shared: user MCP, project-local: VS Code workspace MCP
470
+ phren hooks-mode [on|off|status] # shared-mode only
471
+ phren config project-ownership [mode] # default ownership for future project enrollments
472
+ phren config workflow set --taskMode=manual # set task handling mode
473
+ phren config proactivity.findings [level] # findings auto-capture aggressiveness
474
+ phren config proactivity.tasks [level] # task auto-capture aggressiveness
475
+
476
+ phren skills list # list all installed skills
477
+ phren skills add <project> <path> # add a skill to a project
478
+ phren skills enable <project|global> <name> # enable a disabled skill without rewriting it
479
+ phren skills disable <project|global> <name> # disable a skill without deleting it
480
+ phren skills remove <project> <name> # remove a skill from a project
481
+ phren skill-list # alias for skills list
482
+
483
+ phren hooks list # show hook status per tool
484
+ phren hooks enable <tool> # enable hooks for tool (claude/copilot/cursor/codex)
485
+ phren hooks disable <tool> # disable hooks for tool
486
+ ```
487
+
488
+ Use `phren config` for policy tuning and `phren maintain` for governance operations. Run `--dry-run` before destructive maintenance commands.
489
+
490
+ ### phren doctor
491
+
492
+ `phren doctor` checks your setup. `--fix` repairs what it can. `--check-data` also validates config files.
493
+
494
+ | Check | What it verifies | What FAIL means |
495
+ |-------|-----------------|-----------------|
496
+ | `machine-registered` | Your hostname is in machines.yaml | Run `phren init` or add your machine manually |
497
+ | `profile-exists` | The profile YAML file exists in profiles/ | Create the profile file or fix the mapping in machines.yaml |
498
+ | `profile-projects` | At least one project is listed in the profile | Add projects to your profile YAML |
499
+ | `context-file` | ~/.phren-context.md exists | Run `phren doctor --fix` or rerun `phren init` to regenerate |
500
+ | `root-memory` | The generated MEMORY.md exists | Run `phren doctor --fix` or rerun `phren init` |
501
+ | `global-link` | ~/.claude/CLAUDE.md symlinks to your phren global | Run `phren doctor --fix` or rerun `phren init` |
502
+ | `symlink:<project>/<file>` | Per-project file symlinks are correct | Run `phren doctor --fix` or rerun `phren init` |
503
+ | `claude-hooks` | Prompt hook is configured in settings.json | Run `phren init` to reconfigure hooks |
504
+ | `lifecycle-hooks` | Session-start and stop hooks are configured | Run `phren init` to reconfigure hooks |
505
+ | `runtime-health-file` | The runtime health tracker file exists | Will be created on next hook run |
506
+ | `runtime-auto-save` | Last auto-save completed successfully | Check ~/.phren/.audit-log for details |
507
+ | `runtime-prompt` | Prompt hook has run at least once | Start a new agent session to trigger it |
508
+ | `fts-index` | SQLite FTS5 index builds and queries correctly | Check for corrupt data files, run `phren doctor --fix` |
509
+ | `copilot-hooks` | Copilot CLI hook config exists (if Copilot detected) | Run `phren init` to configure |
510
+ | `cursor-hooks` | Cursor hook config exists (if Cursor detected) | Run `phren init` to configure |
511
+ | `codex-hooks` | Codex hook config exists (if Codex detected) | Run `phren init` to configure |
512
+ | `config` | .governance/ config directory exists | Run `phren init` to create config files |
513
+
514
+ ### Access control (RBAC)
515
+
516
+ Four roles: `admin`, `maintainer`, `contributor`, `viewer`. Set in `.governance/access-control.json`. Identity comes from `PHREN_ACTOR`, then `USER`/`USERNAME`, then your OS username. Unknown actors default to `viewer`.
517
+
518
+ See [docs/environment.md](docs/environment.md) for all feature flags and env vars.
519
+
520
+ </details>
521
+
522
+ <details>
523
+ <summary><strong>Repository structure</strong></summary>
524
+
525
+ This repo has two roles: it's the source code for the `phren` npm package, and it ships the starter files that `phren init` copies to `~/.phren`. The top-level directories break down like this:
526
+
527
+ | Directory | What it is | When you'd touch it |
528
+ |-----------|-----------|---------------------|
529
+ | `mcp/` | MCP server and CLI source code (TypeScript). The core of phren. | Adding tools, fixing bugs, changing CLI behavior. |
530
+ | `global/` | Default user-level config shipped with the package. Contains the template `CLAUDE.md`, shared context files, and built-in skill definitions. Copied to `~/.phren/global/` on init. | Editing the default instructions or adding built-in skills that ship with every install. |
531
+ | `hooks/` | Shell scripts that plug into agent lifecycle events (Stop, SessionStart, UserPromptSubmit). Registered by init into agent settings. | Adding or modifying agent hooks. |
532
+ | `skills/` | Phren slash commands (`/phren-init`, `/phren-sync`, etc.). Each subdirectory has a `SKILL.md` with the full prompt. | Writing or editing built-in phren skills. |
533
+ | `starter/` | Complete `~/.phren` skeleton copied on first init: example projects, profiles, machines.yaml, and typed project templates. | Changing what new users get out of the box. |
534
+ | `templates/` | Default project scaffolding used by the `/phren-init` skill (no `--template` flag). Contains the bare project skeleton and example summary files. | Editing the default project scaffold or adding example files. |
535
+ | `profiles/` | Example profile YAML files (personal, work) showing how to map project sets to machines. Copied to `~/.phren/profiles/` on init. | Adding new example profiles that ship with the package. |
536
+ | `scripts/` | Dev scripts for maintainers: doc validation, retrieval evaluation. Not shipped to users. | Running CI checks or contributing to the test suite. |
537
+ | `docs/` | Documentation site, whitepaper, architecture docs, and internal design specs. Served via GitHub Pages. | Reading or updating docs. |
538
+
539
+ **starter/ vs templates/**: `starter/` is the full `~/.phren` directory tree (projects, profiles, machines.yaml). `templates/` holds the bare project skeleton used by the `/phren-init` skill. `starter/templates/` holds typed project templates (frontend, library, etc.) used by `phren init --template`. Three layers: starter seeds the whole store, templates seeds the default project, starter/templates seeds typed projects.
540
+
541
+ </details>
542
+
543
+ <details>
544
+ <summary><strong>Troubleshooting</strong></summary>
545
+
546
+ **Phren not injecting context into prompts**
547
+
548
+ Run `phren status` and check the Hooks line. If it says "off", run `phren hooks-mode on`. If hooks are on but nothing's appearing, run `phren doctor` to check the prompt hook config. In project-local mode, hooks are intentionally unsupported.
549
+
550
+ **MCP tools not connecting**
551
+
552
+ Run `phren status` and check the MCP line. If it's off, run `phren mcp-mode on`. If cfg shows "missing", run `phren init`. In shared mode, MCP lands in user config files. In project-local mode, VS Code MCP lands in `.vscode/mcp.json`.
553
+
554
+ **"I told phren something but can't find it"**
555
+
556
+ Findings are scoped to a project. Try `phren search "your term" --project <name>`. If it was flagged by trust filtering, check the review queue: `phren` then press `m`.
557
+
558
+ **Doctor says FAIL on symlinks**
559
+
560
+ Project directory probably moved or symlinks are stale. Run `phren doctor --fix`.
561
+
562
+ **Push failed or sync looks stuck**
563
+
564
+ Run `phren status` first. If the store says `saved-local`, your data is committed locally and waiting on sync. The shell health view and web UI also show the last push error and unsynced commit count. Fix the remote or network issue, then let the background worker retry or run a normal git push yourself.
565
+
566
+ **Hooks disabled or stale**
567
+
568
+ Run `phren hooks list`. If the target tool is off or misconfigured, enable it again with `phren hooks enable <tool>` or rerun `phren init`.
569
+
570
+ **Review queue keeps growing**
571
+
572
+ Your trust policy is probably pushing too much low-confidence content into review. Triage with `phren` then `m`, or tune policy with `phren config`.
573
+
574
+ **Governance writes are denied**
575
+
576
+ Check `.governance/access-control.json` and your `PHREN_ACTOR` identity. Phren will refuse the write rather than silently forgetting it.
577
+
578
+ **Merge conflicts after pulling on a new machine**
579
+
580
+ Run `phren` and type `:conflicts`. Phren handles most merges on his own (task items, findings). If he can't resolve it, conflict markers show in the files for you.
581
+
582
+ </details>
583
+
584
+ ---
585
+
586
+ Found a security issue? See [SECURITY.md](SECURITY.md) for responsible disclosure.
587
+
588
+ Phren uses `sql.js-fts5` for local SQLite FTS5 in Node. Pinned and tested in CI.
589
+
590
+ MIT License. Made by [Ala Arab](https://github.com/alaarab). [Contributions welcome](CONTRIBUTING.md).