@gi4nks/ph 1.5.0 → 1.7.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/CHANGELOG.md +9 -2
- package/LICENSE +1 -1
- package/README.md +155 -145
- package/dist/cli.js +2279 -1052
- package/dist/cli.js.map +1 -1
- package/docs/evals/context-retrieval-golden.json +26 -0
- package/docs/evals/context-retrieval.md +27 -0
- package/docs/hooks.md +13 -7
- package/docs/ph-analysis.html +145 -0
- package/docs/ph-manual.md +375 -373
- package/docs/specs/SPEC-001-architecture-cli.md +82 -0
- package/docs/specs/SPEC-002-database-layer.md +105 -0
- package/docs/specs/SPEC-003-capture-modes.md +110 -0
- package/docs/specs/SPEC-004-filter-metadata.md +82 -0
- package/docs/specs/SPEC-005-search.md +102 -0
- package/docs/specs/SPEC-006-analysis-pipeline.md +98 -0
- package/docs/specs/SPEC-007-memory-summaries.md +96 -0
- package/docs/specs/SPEC-008-embeddings.md +90 -0
- package/docs/specs/SPEC-009-retention-archive.md +91 -0
- package/docs/specs/SPEC-010-remote-sync.md +106 -0
- package/docs/specs/SPEC-011-mcp-server.md +94 -0
- package/docs/specs/SPEC-012-tui-browser.md +98 -0
- package/docs/specs/SPEC-013-importers.md +109 -0
- package/docs/specs/SPEC-014-analytics-commands.md +109 -0
- package/docs/specs/SPEC-015-config-env.md +85 -0
- package/docs/specs/SPEC-INDEX.md +35 -0
- package/docs/specs/SPEC-ISSUES.md +122 -0
- package/docs/specs/_TEMPLATE.md +65 -0
- package/docs/superpowers/plans/2026-06-12-ph-evolution-phase1.md +466 -0
- package/docs/superpowers/plans/2026-06-12-ph-evolution-phase2.md +351 -0
- package/docs/superpowers/specs/2026-06-12-ph-evolution-design.md +173 -0
- package/hooks/claude/README.md +1 -1
- package/hooks/codex/README.md +54 -0
- package/hooks/codex/ph-hook.sh +14 -0
- package/hooks/gemini/README.md +1 -1
- package/hooks/opencode/ph-plugin.ts +60 -57
- package/package.json +18 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
# [1.
|
|
1
|
+
# [1.7.0](https://github.com/gi4nks/ph/compare/v1.6.0...v1.7.0) (2026-10-18)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* integrate Wise providers in ph ([4f8094e](https://github.com/gi4nks/ph/commit/4f8094e506430f43a96eaca299c6fc85a65870a9))
|
|
7
|
+
|
|
8
|
+
# [1.6.0](https://github.com/gi4nks/ph/compare/v1.5.0...v1.6.0) (2026-10-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* publish current ph snapshot against GitHub main ([943ced9](https://github.com/gi4nks/ph/commit/943ced97aa63e1c183ac029ae76833583559ce98))
|
|
7
14
|
|
|
8
15
|
# [1.4.0](https://github.com/gi4nks/ph/compare/v1.3.2...v1.4.0) (2026-05-16)
|
|
9
16
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,227 +1,237 @@
|
|
|
1
|
-
# ph — Prompt History
|
|
1
|
+
# ph — Prompt History and Project Memory
|
|
2
2
|
|
|
3
|
-
`ph`
|
|
3
|
+
`ph` captures prompt and response history from AI command-line tools and makes it searchable from the terminal or available to agents through MCP. It stores data in a local SQLite database and can optionally analyze, archive, or synchronize that data.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What it does
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- Captures conversations through a transparent command wrapper, native hooks, direct logging, or history import.
|
|
8
|
+
- Searches prompts and responses with SQLite FTS5, or searches by semantic similarity with Ollama embeddings and sqlite-vec.
|
|
9
|
+
- Groups records by project, tool, language, role, tags, time, and quality metadata.
|
|
10
|
+
- Builds project summaries and an append-only analysis history with Ollama, Gemini, OpenRouter, or MLX-Serve through `@gi4nks/wise`.
|
|
11
|
+
- Exposes prompt history and project knowledge through an MCP server over stdio.
|
|
12
|
+
- Provides an interactive terminal browser for filtering, reviewing, editing metadata, starring, exporting, and rerunning prompts.
|
|
13
|
+
- The TUI `p` action sends the selected prompt to a configured Wise analysis provider; `r` reruns it with its original CLI tool.
|
|
14
|
+
- Supports optional HTTP sync between a local database and a remote `ph` server.
|
|
14
15
|
|
|
15
|
-
##
|
|
16
|
+
## Install
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
Install from npm:
|
|
18
19
|
|
|
19
20
|
```bash
|
|
20
21
|
npm install -g @gi4nks/ph
|
|
21
22
|
```
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Or build from source:
|
|
24
25
|
|
|
25
26
|
```bash
|
|
26
|
-
git clone
|
|
27
|
+
git clone https://github.com/gi4nks/ph.git
|
|
27
28
|
cd ph
|
|
28
|
-
npm
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
npm ci
|
|
30
|
+
npm run build
|
|
31
|
+
npm link
|
|
31
32
|
```
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
Requires Node.js 22 or later (the Wise/AI SDK provider stack requires Node 22). Ollama is optional; it is used for local analysis and semantic embeddings. Gemini can be used for analysis when configured.
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
34
37
|
|
|
35
38
|
```bash
|
|
36
|
-
#
|
|
39
|
+
# Capture a prompt by wrapping an installed AI CLI tool
|
|
37
40
|
ph claude "explain goroutines"
|
|
38
41
|
|
|
39
|
-
# Search history
|
|
42
|
+
# Search prompt history
|
|
40
43
|
ph search "goroutines"
|
|
41
44
|
ph search --semantic "concurrency patterns"
|
|
42
|
-
ph search --tool claude --role debug --since 2026-01-01
|
|
43
45
|
|
|
44
|
-
#
|
|
46
|
+
# Open the interactive browser
|
|
45
47
|
ph browse
|
|
46
48
|
|
|
47
|
-
#
|
|
48
|
-
ph
|
|
49
|
-
|
|
50
|
-
# Sync with another machine
|
|
51
|
-
export PH_REMOTE_URL=http://my-server:3001
|
|
52
|
-
ph remote push # push local prompts to server
|
|
53
|
-
ph remote pull # pull remote prompts into local DB
|
|
49
|
+
# Add a record directly
|
|
50
|
+
ph log --tool claude --prompt "Explain this function" --response "It parses..."
|
|
54
51
|
```
|
|
55
52
|
|
|
56
|
-
##
|
|
53
|
+
## Capture history
|
|
54
|
+
|
|
55
|
+
### Wrapper
|
|
57
56
|
|
|
58
|
-
|
|
57
|
+
Run an installed tool through `ph` to record its prompt and response:
|
|
59
58
|
|
|
60
59
|
```bash
|
|
61
|
-
ph
|
|
62
|
-
ph
|
|
63
|
-
ph config set remote-url http://server:3001 # remote sync target
|
|
60
|
+
ph claude "explain goroutines"
|
|
61
|
+
ph --ph-role debug --ph-tag auth claude "fix JWT expiration"
|
|
64
62
|
```
|
|
65
63
|
|
|
66
|
-
|
|
64
|
+
Interactive wrapper mode is available when the wrapped tool is run without command-line prompt arguments.
|
|
65
|
+
|
|
66
|
+
### Native hooks
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|--------|---------|-------------|
|
|
70
|
-
| `analyze-provider` | `ollama` | LLM provider for analysis (`ollama` or `gemini`) |
|
|
71
|
-
| `gemini-api-key` | — | API key for Gemini provider |
|
|
72
|
-
| `ollama-url` | `http://localhost:11434` | Ollama server URL |
|
|
73
|
-
| `ollama-model` | `llama3.1:latest` | Ollama model for analysis |
|
|
74
|
-
| `ollama-embed-model` | `nomic-embed-text-v2-moe` | Ollama model for embeddings |
|
|
75
|
-
| `background-analysis` | `false` | Auto-analyze after each `ph log` |
|
|
76
|
-
| `remote-url` | — | HTTP URL of remote ph server |
|
|
77
|
-
| `remote-api-key` | — | Optional API key for remote server |
|
|
78
|
-
| `db-path` | `~/.prompt_history.db` | Custom database path |
|
|
79
|
-
| `filter-min-length` | `15` | Ignore prompts shorter than N chars |
|
|
80
|
-
| `filter-min-relevance` | `3` | Minimum relevance score (0–10) |
|
|
68
|
+
Hooks capture completed exchanges without changing the tool invocation:
|
|
81
69
|
|
|
82
|
-
|
|
70
|
+
- Claude Code: [hooks/claude/ph-hook.sh](hooks/claude/ph-hook.sh)
|
|
71
|
+
- Codex CLI: [hooks/codex/ph-hook.sh](hooks/codex/ph-hook.sh)
|
|
72
|
+
- Gemini CLI: [hooks/gemini/ph-hook.sh](hooks/gemini/ph-hook.sh)
|
|
73
|
+
- OpenCode: [hooks/opencode/ph-plugin.ts](hooks/opencode/ph-plugin.ts)
|
|
83
74
|
|
|
84
|
-
|
|
75
|
+
See [docs/hooks.md](docs/hooks.md) for the integration overview and [docs/ph-manual.md](docs/ph-manual.md) for setup details.
|
|
85
76
|
|
|
86
|
-
|
|
77
|
+
### Direct logging and history import
|
|
87
78
|
|
|
88
79
|
```bash
|
|
89
|
-
|
|
80
|
+
ph log --tool claude --prompt "Explain this function" --response "It parses..."
|
|
81
|
+
echo '{"tool":"claude","prompt":"Explain this function","response":"It parses..."}' | ph log --stdin
|
|
82
|
+
|
|
83
|
+
ph import claude --dry-run
|
|
84
|
+
ph import gemini --filter
|
|
85
|
+
ph import opencode
|
|
86
|
+
ph import codex --dry-run
|
|
90
87
|
```
|
|
91
88
|
|
|
92
|
-
|
|
89
|
+
Codex is also available through wrapper and context-injected modes: `ph codex exec "prompt"` and `ph chat codex exec "prompt"`. See [Codex hook setup](hooks/codex/README.md).
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
[Unit]
|
|
96
|
-
Description=ph remote sync server
|
|
97
|
-
After=network.target
|
|
91
|
+
## Search and project context
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
StandardOutput=append:/var/log/ph-server.log
|
|
107
|
-
StandardError=append:/var/log/ph-server.log
|
|
93
|
+
```bash
|
|
94
|
+
ph search --tool claude --role debug --since 2026-01-01
|
|
95
|
+
ph search --semantic "How did I configure SQLite migrations?"
|
|
96
|
+
ph search --archive "database migration"
|
|
97
|
+
|
|
98
|
+
# Retrieve project knowledge and related prompts for the current directory
|
|
99
|
+
ph context "How are database migrations handled?"
|
|
108
100
|
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
# Limit the output to project summaries and memories
|
|
102
|
+
ph context --memories-only --project ph
|
|
111
103
|
```
|
|
112
104
|
|
|
113
|
-
|
|
105
|
+
`ph context`, `ph chat`, and MCP project-context tools use shared retrieval and formatting. Semantic results are scoped to the requested project before the result limit is applied.
|
|
106
|
+
|
|
107
|
+
## Project memory and analysis
|
|
108
|
+
|
|
109
|
+
Enable background analysis after each capture:
|
|
114
110
|
|
|
115
111
|
```bash
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
ph config set background-analysis true
|
|
113
|
+
ph config set analyze-provider ollama
|
|
114
|
+
ph config set ollama-model llama3.1:latest
|
|
115
|
+
ph config set ollama-embed-model nomic-embed-text-v2-moe
|
|
119
116
|
```
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Create `~/Library/LaunchAgents/com.gi4nks.ph.plist`:
|
|
118
|
+
For Gemini analysis:
|
|
124
119
|
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<plist version="1.0">
|
|
129
|
-
<dict>
|
|
130
|
-
<key>Label</key>
|
|
131
|
-
<string>com.gi4nks.ph</string>
|
|
132
|
-
<key>ProgramArguments</key>
|
|
133
|
-
<array>
|
|
134
|
-
<string>/usr/local/bin/ph</string>
|
|
135
|
-
<string>server</string>
|
|
136
|
-
<string>--port</string>
|
|
137
|
-
<string>3001</string>
|
|
138
|
-
<string>--host</string>
|
|
139
|
-
<string>0.0.0.0</string>
|
|
140
|
-
</array>
|
|
141
|
-
<key>RunAtLoad</key>
|
|
142
|
-
<true/>
|
|
143
|
-
<key>KeepAlive</key>
|
|
144
|
-
<true/>
|
|
145
|
-
<key>StandardOutPath</key>
|
|
146
|
-
<string>/tmp/ph-server.log</string>
|
|
147
|
-
<key>StandardErrorPath</key>
|
|
148
|
-
<string>/tmp/ph-server.err</string>
|
|
149
|
-
</dict>
|
|
150
|
-
</plist>
|
|
120
|
+
```bash
|
|
121
|
+
ph config set analyze-provider gemini
|
|
122
|
+
ph config set gemini-api-key "$GEMINI_API_KEY"
|
|
151
123
|
```
|
|
152
124
|
|
|
125
|
+
For OpenRouter, use the environment or enter the key through ph's hidden prompt, then select an exact model ID:
|
|
126
|
+
|
|
153
127
|
```bash
|
|
154
|
-
|
|
128
|
+
export OPENROUTER_API_KEY="your_openrouter_api_key"
|
|
129
|
+
ph models openrouter
|
|
130
|
+
ph config set openrouter-api-key # prompts securely; stored in ~/.ph_config.json
|
|
131
|
+
ph config set analyze-provider openrouter
|
|
132
|
+
ph config set openrouter-model "provider/model-id"
|
|
133
|
+
ph config show # shows active settings, redacts keys
|
|
134
|
+
ph analyze
|
|
155
135
|
```
|
|
156
136
|
|
|
157
|
-
|
|
137
|
+
For MLX-Serve on Parmenide, open an SSH tunnel to its API port (11234 by default),
|
|
138
|
+
then select an ID returned by the server. Keep the tunnel running in a separate terminal:
|
|
158
139
|
|
|
159
140
|
```bash
|
|
160
|
-
#
|
|
161
|
-
|
|
162
|
-
|
|
141
|
+
# Terminal 1
|
|
142
|
+
ssh -N -L 11234:127.0.0.1:11234 parmenide
|
|
143
|
+
```
|
|
163
144
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
ph
|
|
167
|
-
ph
|
|
145
|
+
```bash
|
|
146
|
+
# Terminal 2
|
|
147
|
+
ph models mlx-serve
|
|
148
|
+
ph config set analyze-provider mlx-serve
|
|
149
|
+
ph config set mlx-serve-model "exact-model-id-from-server"
|
|
150
|
+
ph analyze
|
|
168
151
|
```
|
|
169
152
|
|
|
170
|
-
|
|
153
|
+
The MLX-Serve URL defaults to `http://127.0.0.1:11234/v1`; override it with
|
|
154
|
+
`MLX_SERVE_BASE_URL` or `ph config set mlx-serve-url <url>`. If the server requires
|
|
155
|
+
authentication, set `MLX_SERVE_API_KEY` or run `ph config set mlx-serve-api-key`
|
|
156
|
+
for a hidden prompt. `ph config show` redacts credentials. The model catalog
|
|
157
|
+
marks installed models as `[loaded]` or `[unloaded]`.
|
|
171
158
|
|
|
172
|
-
|
|
159
|
+
Project summaries merge deduplicated insights and technical decisions. Individual analysis results remain in an append-only memory timeline. Analysis and embeddings require the corresponding provider to be available; basic capture and full-text search do not.
|
|
173
160
|
|
|
174
|
-
|
|
175
|
-
2. GitHub Actions runs `npx semantic-release`
|
|
176
|
-
3. Semantic-release analyzes commits since last release
|
|
177
|
-
4. Bumps version automatically (major/minor/patch)
|
|
178
|
-
5. Generates `CHANGELOG.md`
|
|
179
|
-
6. Creates a git tag
|
|
180
|
-
7. Publishes to npm with **OIDC trusted publishing** (provenance attestation)
|
|
181
|
-
8. Creates a GitHub Release
|
|
161
|
+
## MCP integration
|
|
182
162
|
|
|
183
|
-
|
|
163
|
+
Start the stdio server with:
|
|
184
164
|
|
|
185
165
|
```bash
|
|
186
|
-
|
|
166
|
+
ph mcp
|
|
187
167
|
```
|
|
188
168
|
|
|
189
|
-
|
|
169
|
+
The server exposes tools for prompt search and lookup, project context and summaries, project timelines, knowledge checks, and saving decisions. Configure `ph mcp` as a stdio server in the MCP client you use.
|
|
190
170
|
|
|
191
|
-
|
|
192
|
-
|------|--------------|-------------|
|
|
193
|
-
| Database | `~/.prompt_history.db` | SQLite with FTS5 + sqlite-vec |
|
|
194
|
-
| Config | `~/.ph_config.json` | JSON with 0o600 permissions |
|
|
171
|
+
## Remote sync
|
|
195
172
|
|
|
196
|
-
|
|
173
|
+
Run an HTTP server on the machine that will store the shared database:
|
|
197
174
|
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
v
|
|
202
|
-
Local SQLite (FTS5 + vec0 + memories)
|
|
203
|
-
|
|
|
204
|
-
├── MCP server (stdio) → OpenCode / any MCP client
|
|
205
|
-
├── HTTP server (REST) → remote ph instances
|
|
206
|
-
└── Background analysis → memories table (append-only per project)
|
|
175
|
+
```bash
|
|
176
|
+
ph config set remote-api-key "$PH_REMOTE_API_KEY"
|
|
177
|
+
ph server --host 127.0.0.1 --port 3001
|
|
207
178
|
```
|
|
208
179
|
|
|
209
|
-
|
|
180
|
+
Set a client remote URL and synchronize:
|
|
210
181
|
|
|
211
|
-
|
|
182
|
+
```bash
|
|
183
|
+
ph config set remote-url http://127.0.0.1:3001
|
|
184
|
+
ph remote push
|
|
185
|
+
ph remote pull
|
|
186
|
+
ph remote status
|
|
187
|
+
```
|
|
212
188
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
189
|
+
`PH_REMOTE_URL` overrides the configured remote URL. If `remote-api-key` is set on the server, clients must also provide that key. Use a private network or a TLS-terminating proxy when connecting across machines. Each `ph log` performs a non-blocking push when a remote is configured.
|
|
190
|
+
|
|
191
|
+
## Configuration and storage
|
|
192
|
+
|
|
193
|
+
Configuration is stored in `~/.ph_config.json`; the database defaults to `~/.prompt_history.db`.
|
|
194
|
+
|
|
195
|
+
| Setting | Default | Purpose |
|
|
196
|
+
|---|---|---|
|
|
197
|
+
| `db-path` | `~/.prompt_history.db` | SQLite database location |
|
|
198
|
+
| `analyze-provider` | `ollama` | Analysis provider: `ollama`, `gemini`, `openrouter`, or `mlx-serve` |
|
|
199
|
+
| `ollama-url` | `http://localhost:11434` | Ollama endpoint |
|
|
200
|
+
| `ollama-model` | `llama3.1:latest` | Analysis model |
|
|
201
|
+
| `openrouter-model` | unset | Exact OpenRouter model ID, including its provider prefix |
|
|
202
|
+
| `openrouter-url` | `https://openrouter.ai/api/v1` | OpenRouter-compatible API root |
|
|
203
|
+
| `mlx-serve-model` | unset | Exact model ID returned by MLX-Serve |
|
|
204
|
+
| `mlx-serve-url` | `http://127.0.0.1:11234/v1` | MLX-Serve API root, normally the Parmenide SSH tunnel |
|
|
205
|
+
| `ollama-embed-model` | `nomic-embed-text-v2-moe` | Embedding model; current schema expects 768 dimensions |
|
|
206
|
+
| `background-analysis` | `false` | Analyze newly captured prompts asynchronously |
|
|
207
|
+
| `filter-min-length` | `15` | Minimum prompt length accepted by filtering |
|
|
208
|
+
| `filter-min-relevance` | `3` | Relevance threshold for filtered imports/analysis workflows |
|
|
209
|
+
| `remote-url` | unset | Remote `ph` server; `PH_REMOTE_URL` takes precedence |
|
|
210
|
+
| `remote-api-key` | unset | Optional server authentication key |
|
|
211
|
+
|
|
212
|
+
Provider credentials can be stored in `~/.ph_config.json` through the hidden
|
|
213
|
+
`ph config set <provider>-api-key` prompts or supplied through environment
|
|
214
|
+
variables. Environment values take precedence; MLX-Serve also accepts the
|
|
215
|
+
existing `GLB_OMLX_API_KEY` variable.
|
|
216
216
|
|
|
217
217
|
## Development
|
|
218
218
|
|
|
219
219
|
```bash
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
npm ci
|
|
221
|
+
npm test
|
|
222
|
+
npm run lint
|
|
223
|
+
npx tsc --noEmit
|
|
224
|
+
npm run build
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Run the optional model-backed retrieval evaluation when an Ollama embedding endpoint is available:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npm run eval:retrieval
|
|
223
231
|
```
|
|
224
232
|
|
|
233
|
+
See [docs/ph-manual.md](docs/ph-manual.md), [docs/specs/SPEC-INDEX.md](docs/specs/SPEC-INDEX.md), and [docs/ph-analysis.html](docs/ph-analysis.html) for the user guide, behavior specifications, and architecture report.
|
|
234
|
+
|
|
225
235
|
## License
|
|
226
236
|
|
|
227
237
|
MIT
|