@gi4nks/ph 1.3.2 → 1.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.
- package/CHANGELOG.md +40 -5
- package/README.md +172 -91
- package/dist/cli.js +3890 -1952
- package/dist/cli.js.map +1 -1
- package/docs/hooks.md +33 -71
- package/docs/ph-manual.md +246 -8
- package/hooks/opencode/install.sh +45 -0
- package/hooks/opencode/ph-plugin.ts +101 -0
- package/package.json +36 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,55 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/gi4nks/ph/compare/v1.4.0...v1.5.0) (2026-05-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add timeline CLI command and two new MCP tools (get_project_timeline, check_project_knowledge) ([12d667c](https://github.com/gi4nks/ph/commit/12d667c69e35f4aff31a2e13018a00949587fb55))
|
|
7
|
+
|
|
8
|
+
# [1.4.0](https://github.com/gi4nks/ph/compare/v1.3.2...v1.4.0) (2026-05-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove provenance from publishConfig, restore scope+npm ci in release workflow ([734df6c](https://github.com/gi4nks/ph/commit/734df6cf53b15ff661ad95c530a897a802571ecc))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* v2.0.0 — HTTP server, remote sync, MCP prompt tools, OpenCode plugin ([a9c0b03](https://github.com/gi4nks/ph/commit/a9c0b032b91275edfb8948c7d136d93eb734fa12))
|
|
19
|
+
|
|
1
20
|
# Changelog
|
|
2
21
|
|
|
3
22
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
23
|
|
|
5
|
-
### [
|
|
6
|
-
|
|
7
|
-
### [1.3.1](https://github.com/gi4nks/ph/compare/v1.3.0...v1.3.1) (2026-04-13)
|
|
24
|
+
### [2.0.1](https://github.com/gi4nks/ph/compare/v1.3.2...v2.0.1) (2026-05-16)
|
|
8
25
|
|
|
9
26
|
|
|
10
27
|
### Features
|
|
11
28
|
|
|
12
|
-
*
|
|
29
|
+
* v2.0.0 — HTTP server, remote sync, MCP prompt tools, OpenCode plugin ([a9c0b03](https://github.com/gi4nks/ph/commit/a9c0b032b91275edfb8948c7d136d93eb734fa12))
|
|
13
30
|
|
|
14
31
|
|
|
15
32
|
### Bug Fixes
|
|
16
33
|
|
|
17
|
-
*
|
|
34
|
+
* remove provenance from publishConfig, restore scope+npm ci in release workflow ([734df6c](https://github.com/gi4nks/ph/commit/734df6cf53b15ff661ad95c530a897a802571ecc))
|
|
35
|
+
|
|
36
|
+
## [2.0.0](https://github.com/gi4nks/ph/compare/v1.3.2...v2.0.0) (2026-05-16)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### ⚠ BREAKING CHANGES
|
|
40
|
+
|
|
41
|
+
* **cli:** major refactor of cli.ts into command modules. All commands keep the same interface but the internal architecture changed significantly.
|
|
42
|
+
|
|
43
|
+
### Features
|
|
44
|
+
|
|
45
|
+
* **server:** `ph server` — HTTP REST server (zero deps, Node http module). Endpoints: /health, /api/prompts/search, /api/prompts/by-id, /api/prompts/semantic, /api/sync/push, /api/sync/pull, /api/memories/search, /api/memories/summary, /api/stats
|
|
46
|
+
* **remote:** `ph remote push|pull|status` — sync prompts across laptops. Dedup via sha256(tool|prompt|response). Background push on each `ph log`.
|
|
47
|
+
* **mcp:** `search_prompts`, `get_prompt`, `search_prompts_semantic` tools for querying raw prompt history via MCP
|
|
48
|
+
* **config:** `remote-url`, `remote-api-key` config keys + `PH_REMOTE_URL` env var support
|
|
49
|
+
* **opencode:** native importer (`ph import opencode`) + real-time plugin hook
|
|
50
|
+
|
|
51
|
+
### (prima di continuare con il commit fammi vedere se ti piace la situazione ) vabene?
|
|
52
|
+
|
|
18
53
|
|
|
19
54
|
## [1.3.0](https://github.com/gi4nks/ph/compare/v1.2.0...v1.3.0) (2026-04-12)
|
|
20
55
|
|
package/README.md
CHANGED
|
@@ -1,146 +1,227 @@
|
|
|
1
1
|
# ph — Prompt History & Analysis Tool
|
|
2
2
|
|
|
3
|
-
`ph` is a transparent
|
|
3
|
+
`ph` is a transparent observability layer for AI CLI tools. It captures every prompt+response into a local SQLite database with full-text and semantic search, automatic LLM analysis, interactive TUI browser, MCP server, and optional remote sync for cross-laptop memory sharing.
|
|
4
4
|
|
|
5
5
|
## Key Features
|
|
6
6
|
|
|
7
|
-
- 📥 **Automatic Capture**:
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- 📥 **Automatic Capture**: Wrapper mode (`ph claude "..."`), hook mode (Claude/Gemini/OpenCode), or direct (`ph log`).
|
|
8
|
+
- 🔍 **Advanced Search**: FTS5 full-text search and sqlite-vec semantic search with rich filters (tool, project, role, tag, date range).
|
|
9
|
+
- 🧠 **Background Analysis**: Automatic prompt classification (role, tags, relevance) via Ollama or Gemini — builds project-level memories.
|
|
10
|
+
- 🖥️ **Interactive TUI**: Full-screen browser with filter panel, preview pane, project memory viewer, and session grouping.
|
|
11
|
+
- 🔌 **MCP Server**: Exposes prompt history and project knowledge as MCP tools (`search_prompts`, `get_prompt`, `search_project_memory`, etc.) — usable by any MCP client including OpenCode.
|
|
12
|
+
- 🌐 **HTTP Server & Remote Sync**: `ph server` starts a REST API. `ph remote push|pull` syncs prompts across laptops. Background push after each `ph log`.
|
|
13
|
+
- 🔗 **OpenCode Plugin**: Native plugin for real-time capture via OpenCode hooks.
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
14
16
|
|
|
17
|
+
### From npm
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @gi4nks/ph
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### From source
|
|
24
|
+
|
|
15
25
|
```bash
|
|
16
|
-
# Clone and local build
|
|
17
26
|
git clone git@github.com:gi4nks/ph.git
|
|
18
27
|
cd ph
|
|
19
28
|
npm install
|
|
20
29
|
make build
|
|
21
|
-
make install
|
|
30
|
+
make install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Wrap an AI tool
|
|
37
|
+
ph claude "explain goroutines"
|
|
38
|
+
|
|
39
|
+
# Search history
|
|
40
|
+
ph search "goroutines"
|
|
41
|
+
ph search --semantic "concurrency patterns"
|
|
42
|
+
ph search --tool claude --role debug --since 2026-01-01
|
|
43
|
+
|
|
44
|
+
# Browse with TUI
|
|
45
|
+
ph browse
|
|
46
|
+
|
|
47
|
+
# Start HTTP server for remote sync
|
|
48
|
+
ph server --port 3001
|
|
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
|
|
22
54
|
```
|
|
23
55
|
|
|
24
56
|
## Configuration
|
|
25
57
|
|
|
26
|
-
|
|
58
|
+
Config file at `~/.ph_config.json`:
|
|
27
59
|
|
|
28
60
|
```bash
|
|
29
|
-
ph config set
|
|
30
|
-
ph config set
|
|
31
|
-
ph config set
|
|
61
|
+
ph config set analyze-provider ollama # or 'gemini' (default: ollama)
|
|
62
|
+
ph config set background-analysis true # auto-analyze after each log
|
|
63
|
+
ph config set remote-url http://server:3001 # remote sync target
|
|
32
64
|
```
|
|
33
65
|
|
|
34
|
-
|
|
66
|
+
Environment variable `PH_REMOTE_URL` takes precedence over config.
|
|
35
67
|
|
|
36
|
-
|
|
68
|
+
| Option | Default | Description |
|
|
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) |
|
|
37
81
|
|
|
38
|
-
|
|
82
|
+
## Remote Server Setup
|
|
39
83
|
|
|
40
|
-
|
|
41
|
-
|------|--------------|-------------|
|
|
42
|
-
| **Database** | `~/.prompt_history.db` | SQLite database with FTS5 and vector embeddings. |
|
|
43
|
-
| **Config** | `~/.ph_config.json` | JSON configuration file (stored with `0o600` permissions). |
|
|
84
|
+
### Ubuntu (systemd)
|
|
44
85
|
|
|
45
|
-
|
|
46
|
-
You can move your database to a different location (e.g., an external drive or a cloud-synced folder):
|
|
86
|
+
Install ph on your remote server:
|
|
47
87
|
|
|
48
88
|
```bash
|
|
49
|
-
|
|
89
|
+
sudo npm install -g @gi4nks/ph
|
|
50
90
|
```
|
|
51
91
|
|
|
52
|
-
|
|
53
|
-
|
|
92
|
+
Create `/etc/systemd/system/ph.service`:
|
|
93
|
+
|
|
94
|
+
```ini
|
|
95
|
+
[Unit]
|
|
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
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Find `<path-to-ph>` with `which ph` on the server. Start the service:
|
|
54
114
|
|
|
55
115
|
```bash
|
|
56
|
-
|
|
57
|
-
|
|
116
|
+
sudo systemctl daemon-reload
|
|
117
|
+
sudo systemctl enable --now ph.service
|
|
118
|
+
sudo ufw allow 3001/tcp # if firewall is active
|
|
119
|
+
```
|
|
58
120
|
|
|
59
|
-
|
|
60
|
-
|
|
121
|
+
### macOS (launchd)
|
|
122
|
+
|
|
123
|
+
Create `~/Library/LaunchAgents/com.gi4nks.ph.plist`:
|
|
124
|
+
|
|
125
|
+
```xml
|
|
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>
|
|
151
|
+
```
|
|
61
152
|
|
|
62
|
-
|
|
63
|
-
|
|
153
|
+
```bash
|
|
154
|
+
launchctl load ~/Library/LaunchAgents/com.gi4nks.ph.plist
|
|
64
155
|
```
|
|
65
156
|
|
|
66
|
-
###
|
|
67
|
-
The database uses **WAL (Write-Ahead Logging)** mode, which allows concurrent read and write operations. This is crucial for the **Background Analysis** system to work without locking your CLI session.
|
|
157
|
+
### Client configuration
|
|
68
158
|
|
|
69
|
-
|
|
159
|
+
```bash
|
|
160
|
+
# Set remote URL (config or env)
|
|
161
|
+
ph config set remote-url http://your-server:3001
|
|
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
|
|
168
|
+
```
|
|
70
169
|
|
|
71
|
-
|
|
170
|
+
## How Releases Work
|
|
72
171
|
|
|
73
|
-
|
|
74
|
-
Hooks are located in the `hooks/` folder. Instead of wrapping the execution, they act as post-action handlers (e.g., `AfterAgent` in Gemini CLI or `Stop` in Claude Code) that send the prompt and response to `ph log` in the background.
|
|
172
|
+
Releases are automated via **semantic-release** on push to `main`:
|
|
75
173
|
|
|
76
|
-
|
|
174
|
+
1. Push conventional commits (`feat:`, `fix:`, `chore:`, etc.) to `main`
|
|
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
|
|
77
182
|
|
|
78
|
-
|
|
79
|
-
1. Link the hook script to your `.gemini` folder:
|
|
80
|
-
```bash
|
|
81
|
-
ln -sf /path/to/ph/hooks/gemini/ph-hook.sh ~/.gemini/ph-hook.sh
|
|
82
|
-
```
|
|
83
|
-
2. Register the hook in `~/.gemini/settings.json`:
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"hooks": { "AfterAgent": [ { "hooks": [ { "type": "command", "command": "~/.gemini/ph-hook.sh" } ] } ] }
|
|
87
|
-
}
|
|
88
|
-
```
|
|
183
|
+
The published package is signed with provenance — you can verify it with:
|
|
89
184
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
ln -sf /path/to/ph/hooks/claude/ph-hook.sh ~/.claude/ph-hook.sh
|
|
94
|
-
```
|
|
95
|
-
2. Register the hook in `~/.claude/settings.json`:
|
|
96
|
-
```json
|
|
97
|
-
{
|
|
98
|
-
"hooks": { "Stop": [ { "matcher": ".*", "hooks": [ { "type": "command", "command": "~/.claude/ph-hook.sh", "async": true } ] } ] }
|
|
99
|
-
}
|
|
100
|
-
```
|
|
185
|
+
```bash
|
|
186
|
+
npm audit signatures
|
|
187
|
+
```
|
|
101
188
|
|
|
102
|
-
|
|
189
|
+
## Storage
|
|
103
190
|
|
|
104
|
-
|
|
191
|
+
| Item | Default Path | Description |
|
|
192
|
+
|------|--------------|-------------|
|
|
193
|
+
| Database | `~/.prompt_history.db` | SQLite with FTS5 + sqlite-vec |
|
|
194
|
+
| Config | `~/.ph_config.json` | JSON with 0o600 permissions |
|
|
105
195
|
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
ph search "how to refactor" # Textual search
|
|
109
|
-
ph search --semantic "refactoring" # Semantic search
|
|
110
|
-
```
|
|
196
|
+
## Architecture
|
|
111
197
|
|
|
112
|
-
### TUI Browser
|
|
113
|
-
```bash
|
|
114
|
-
ph browse
|
|
115
198
|
```
|
|
116
|
-
|
|
199
|
+
Capture modes: wrapper → hook → direct → OpenCode plugin
|
|
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)
|
|
207
|
+
```
|
|
117
208
|
|
|
118
|
-
##
|
|
209
|
+
## Hooks
|
|
119
210
|
|
|
120
|
-
|
|
211
|
+
Hooks in `hooks/` integrate with AI CLI tools natively:
|
|
121
212
|
|
|
122
|
-
|
|
123
|
-
|
|
213
|
+
- **Claude Code**: `hooks/claude/ph-hook.sh` — Stop hook
|
|
214
|
+
- **Gemini CLI**: `hooks/gemini/ph-hook.sh` — AfterAgent hook
|
|
215
|
+
- **OpenCode**: `hooks/opencode/ph-plugin.ts` — native plugin (captures streaming responses)
|
|
124
216
|
|
|
125
|
-
|
|
126
|
-
make release-patch # Increments: 0.1.0 -> 0.1.1 (fixes and small changes)
|
|
127
|
-
make release-minor # Increments: 0.1.1 -> 0.2.0 (new compatible features)
|
|
128
|
-
make release-major # Increments: 0.2.0 -> 1.0.0 (breaking changes)
|
|
129
|
-
```
|
|
217
|
+
## Development
|
|
130
218
|
|
|
131
|
-
After the release, remember to push the tags to trigger the **GitHub Action** for publication:
|
|
132
219
|
```bash
|
|
133
|
-
|
|
220
|
+
make build # tsup build
|
|
221
|
+
make test # vitest
|
|
222
|
+
make lint # eslint
|
|
134
223
|
```
|
|
135
|
-
The package will be automatically built and published to [npmjs.org](https://www.npmjs.com/package/@gi4nks/ph).
|
|
136
224
|
|
|
137
|
-
|
|
138
|
-
Install globally with:
|
|
139
|
-
```bash
|
|
140
|
-
npm install -g @gi4nks/ph
|
|
141
|
-
```
|
|
225
|
+
## License
|
|
142
226
|
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
ph export --format md --limit 5 > prompts.md
|
|
146
|
-
```
|
|
227
|
+
MIT
|