@gi4nks/ph 1.5.0 → 1.6.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 +2 -2
- package/README.md +118 -152
- package/dist/cli.js +2049 -1055
- 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 +337 -376
- 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/codex/README.md +54 -0
- package/hooks/codex/ph-hook.sh +14 -0
- package/hooks/opencode/ph-plugin.ts +60 -57
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# [1.
|
|
1
|
+
# [1.6.0](https://github.com/gi4nks/ph/compare/v1.5.0...v1.6.0) (2026-10-09)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* publish current ph snapshot against GitHub main ([943ced9](https://github.com/gi4nks/ph/commit/943ced97aa63e1c183ac029ae76833583559ce98))
|
|
7
7
|
|
|
8
8
|
# [1.4.0](https://github.com/gi4nks/ph/compare/v1.3.2...v1.4.0) (2026-05-16)
|
|
9
9
|
|
package/README.md
CHANGED
|
@@ -1,227 +1,193 @@
|
|
|
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 optional Ollama or Gemini analysis.
|
|
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
|
+
- Supports optional HTTP sync between a local database and a remote `ph` server.
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Install
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Install from npm:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
npm install -g @gi4nks/ph
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Or build from source:
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
git clone
|
|
26
|
+
git clone https://github.com/gi4nks/ph.git
|
|
27
27
|
cd ph
|
|
28
|
-
npm
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
npm ci
|
|
29
|
+
npm run build
|
|
30
|
+
npm link
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Requires Node.js 20 or later. Ollama is optional; it is used for local analysis and semantic embeddings. Gemini can be used for analysis when configured.
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
34
36
|
|
|
35
37
|
```bash
|
|
36
|
-
#
|
|
38
|
+
# Capture a prompt by wrapping an installed AI CLI tool
|
|
37
39
|
ph claude "explain goroutines"
|
|
38
40
|
|
|
39
|
-
# Search history
|
|
41
|
+
# Search prompt history
|
|
40
42
|
ph search "goroutines"
|
|
41
43
|
ph search --semantic "concurrency patterns"
|
|
42
|
-
ph search --tool claude --role debug --since 2026-01-01
|
|
43
44
|
|
|
44
|
-
#
|
|
45
|
+
# Open the interactive browser
|
|
45
46
|
ph browse
|
|
46
47
|
|
|
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
|
|
48
|
+
# Add a record directly
|
|
49
|
+
ph log --tool claude --prompt "Explain this function" --response "It parses..."
|
|
54
50
|
```
|
|
55
51
|
|
|
56
|
-
##
|
|
52
|
+
## Capture history
|
|
53
|
+
|
|
54
|
+
### Wrapper
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
Run an installed tool through `ph` to record its prompt and response:
|
|
59
57
|
|
|
60
58
|
```bash
|
|
61
|
-
ph
|
|
62
|
-
ph
|
|
63
|
-
ph config set remote-url http://server:3001 # remote sync target
|
|
59
|
+
ph claude "explain goroutines"
|
|
60
|
+
ph --ph-role debug --ph-tag auth claude "fix JWT expiration"
|
|
64
61
|
```
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
Interactive wrapper mode is available when the wrapped tool is run without command-line prompt arguments.
|
|
64
|
+
|
|
65
|
+
### Native hooks
|
|
67
66
|
|
|
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) |
|
|
67
|
+
Hooks capture completed exchanges without changing the tool invocation:
|
|
81
68
|
|
|
82
|
-
|
|
69
|
+
- Claude Code: [hooks/claude/ph-hook.sh](hooks/claude/ph-hook.sh)
|
|
70
|
+
- Codex CLI: [hooks/codex/ph-hook.sh](hooks/codex/ph-hook.sh)
|
|
71
|
+
- Gemini CLI: [hooks/gemini/ph-hook.sh](hooks/gemini/ph-hook.sh)
|
|
72
|
+
- OpenCode: [hooks/opencode/ph-plugin.ts](hooks/opencode/ph-plugin.ts)
|
|
83
73
|
|
|
84
|
-
|
|
74
|
+
See [docs/hooks.md](docs/hooks.md) for the integration overview and [docs/ph-manual.md](docs/ph-manual.md) for setup details.
|
|
85
75
|
|
|
86
|
-
|
|
76
|
+
### Direct logging and history import
|
|
87
77
|
|
|
88
78
|
```bash
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
ph log --tool claude --prompt "Explain this function" --response "It parses..."
|
|
80
|
+
echo '{"tool":"claude","prompt":"Explain this function","response":"It parses..."}' | ph log --stdin
|
|
91
81
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
Description=ph remote sync server
|
|
97
|
-
After=network.target
|
|
98
|
-
|
|
99
|
-
[Service]
|
|
100
|
-
Type=simple
|
|
101
|
-
ExecStart=<path-to-ph> server --port 3001 --host 0.0.0.0
|
|
102
|
-
Restart=always
|
|
103
|
-
RestartSec=5
|
|
104
|
-
User=<your-user>
|
|
105
|
-
Environment=NODE_ENV=production
|
|
106
|
-
StandardOutput=append:/var/log/ph-server.log
|
|
107
|
-
StandardError=append:/var/log/ph-server.log
|
|
108
|
-
|
|
109
|
-
[Install]
|
|
110
|
-
WantedBy=multi-user.target
|
|
82
|
+
ph import claude --dry-run
|
|
83
|
+
ph import gemini --filter
|
|
84
|
+
ph import opencode
|
|
85
|
+
ph import codex --dry-run
|
|
111
86
|
```
|
|
112
87
|
|
|
113
|
-
|
|
88
|
+
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).
|
|
89
|
+
|
|
90
|
+
## Search and project context
|
|
114
91
|
|
|
115
92
|
```bash
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
```
|
|
93
|
+
ph search --tool claude --role debug --since 2026-01-01
|
|
94
|
+
ph search --semantic "How did I configure SQLite migrations?"
|
|
95
|
+
ph search --archive "database migration"
|
|
120
96
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
127
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
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>
|
|
97
|
+
# Retrieve project knowledge and related prompts for the current directory
|
|
98
|
+
ph context "How are database migrations handled?"
|
|
99
|
+
|
|
100
|
+
# Limit the output to project summaries and memories
|
|
101
|
+
ph context --memories-only --project ph
|
|
151
102
|
```
|
|
152
103
|
|
|
104
|
+
`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.
|
|
105
|
+
|
|
106
|
+
## Project memory and analysis
|
|
107
|
+
|
|
108
|
+
Enable background analysis after each capture:
|
|
109
|
+
|
|
153
110
|
```bash
|
|
154
|
-
|
|
111
|
+
ph config set background-analysis true
|
|
112
|
+
ph config set analyze-provider ollama
|
|
113
|
+
ph config set ollama-model llama3.1:latest
|
|
114
|
+
ph config set ollama-embed-model nomic-embed-text-v2-moe
|
|
155
115
|
```
|
|
156
116
|
|
|
157
|
-
|
|
117
|
+
For Gemini analysis:
|
|
158
118
|
|
|
159
119
|
```bash
|
|
160
|
-
|
|
161
|
-
ph config set
|
|
162
|
-
# export PH_REMOTE_URL=http://your-server:3001
|
|
163
|
-
|
|
164
|
-
# Sync
|
|
165
|
-
ph remote push # send local prompts to server
|
|
166
|
-
ph remote pull # fetch server prompts locally
|
|
167
|
-
ph remote status # check sync state
|
|
120
|
+
ph config set analyze-provider gemini
|
|
121
|
+
ph config set gemini-api-key "$GEMINI_API_KEY"
|
|
168
122
|
```
|
|
169
123
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
Releases are automated via **semantic-release** on push to `main`:
|
|
124
|
+
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
125
|
|
|
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
|
|
126
|
+
## MCP integration
|
|
182
127
|
|
|
183
|
-
|
|
128
|
+
Start the stdio server with:
|
|
184
129
|
|
|
185
130
|
```bash
|
|
186
|
-
|
|
131
|
+
ph mcp
|
|
187
132
|
```
|
|
188
133
|
|
|
189
|
-
|
|
134
|
+
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
135
|
|
|
191
|
-
|
|
192
|
-
|------|--------------|-------------|
|
|
193
|
-
| Database | `~/.prompt_history.db` | SQLite with FTS5 + sqlite-vec |
|
|
194
|
-
| Config | `~/.ph_config.json` | JSON with 0o600 permissions |
|
|
136
|
+
## Remote sync
|
|
195
137
|
|
|
196
|
-
|
|
138
|
+
Run an HTTP server on the machine that will store the shared database:
|
|
197
139
|
|
|
140
|
+
```bash
|
|
141
|
+
ph config set remote-api-key "$PH_REMOTE_API_KEY"
|
|
142
|
+
ph server --host 127.0.0.1 --port 3001
|
|
198
143
|
```
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
144
|
+
|
|
145
|
+
Set a client remote URL and synchronize:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
ph config set remote-url http://127.0.0.1:3001
|
|
149
|
+
ph remote push
|
|
150
|
+
ph remote pull
|
|
151
|
+
ph remote status
|
|
207
152
|
```
|
|
208
153
|
|
|
209
|
-
|
|
154
|
+
`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.
|
|
210
155
|
|
|
211
|
-
|
|
156
|
+
## Configuration and storage
|
|
212
157
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
158
|
+
Configuration is stored in `~/.ph_config.json`; the database defaults to `~/.prompt_history.db`.
|
|
159
|
+
|
|
160
|
+
| Setting | Default | Purpose |
|
|
161
|
+
|---|---|---|
|
|
162
|
+
| `db-path` | `~/.prompt_history.db` | SQLite database location |
|
|
163
|
+
| `analyze-provider` | `ollama` | Analysis provider: `ollama` or `gemini` |
|
|
164
|
+
| `ollama-url` | `http://localhost:11434` | Ollama endpoint |
|
|
165
|
+
| `ollama-model` | `llama3.1:latest` | Analysis model |
|
|
166
|
+
| `ollama-embed-model` | `nomic-embed-text-v2-moe` | Embedding model; current schema expects 768 dimensions |
|
|
167
|
+
| `background-analysis` | `false` | Analyze newly captured prompts asynchronously |
|
|
168
|
+
| `filter-min-length` | `15` | Minimum prompt length accepted by filtering |
|
|
169
|
+
| `filter-min-relevance` | `3` | Relevance threshold for filtered imports/analysis workflows |
|
|
170
|
+
| `remote-url` | unset | Remote `ph` server; `PH_REMOTE_URL` takes precedence |
|
|
171
|
+
| `remote-api-key` | unset | Optional server authentication key |
|
|
216
172
|
|
|
217
173
|
## Development
|
|
218
174
|
|
|
219
175
|
```bash
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
176
|
+
npm ci
|
|
177
|
+
npm test
|
|
178
|
+
npm run lint
|
|
179
|
+
npx tsc --noEmit
|
|
180
|
+
npm run build
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Run the optional model-backed retrieval evaluation when an Ollama embedding endpoint is available:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npm run eval:retrieval
|
|
223
187
|
```
|
|
224
188
|
|
|
189
|
+
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.
|
|
190
|
+
|
|
225
191
|
## License
|
|
226
192
|
|
|
227
193
|
MIT
|