@gi4nks/ph 1.3.2 → 1.4.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 +33 -5
- package/README.md +59 -101
- package/dist/cli.js +3828 -2167
- package/dist/cli.js.map +1 -1
- package/docs/hooks.md +33 -71
- package/docs/ph-manual.md +86 -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,48 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/gi4nks/ph/compare/v1.3.2...v1.4.0) (2026-05-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* remove provenance from publishConfig, restore scope+npm ci in release workflow ([734df6c](https://github.com/gi4nks/ph/commit/734df6cf53b15ff661ad95c530a897a802571ecc))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* v2.0.0 — HTTP server, remote sync, MCP prompt tools, OpenCode plugin ([a9c0b03](https://github.com/gi4nks/ph/commit/a9c0b032b91275edfb8948c7d136d93eb734fa12))
|
|
12
|
+
|
|
1
13
|
# Changelog
|
|
2
14
|
|
|
3
15
|
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
16
|
|
|
5
|
-
### [
|
|
6
|
-
|
|
7
|
-
### [1.3.1](https://github.com/gi4nks/ph/compare/v1.3.0...v1.3.1) (2026-04-13)
|
|
17
|
+
### [2.0.1](https://github.com/gi4nks/ph/compare/v1.3.2...v2.0.1) (2026-05-16)
|
|
8
18
|
|
|
9
19
|
|
|
10
20
|
### Features
|
|
11
21
|
|
|
12
|
-
*
|
|
22
|
+
* v2.0.0 — HTTP server, remote sync, MCP prompt tools, OpenCode plugin ([a9c0b03](https://github.com/gi4nks/ph/commit/a9c0b032b91275edfb8948c7d136d93eb734fa12))
|
|
13
23
|
|
|
14
24
|
|
|
15
25
|
### Bug Fixes
|
|
16
26
|
|
|
17
|
-
*
|
|
27
|
+
* remove provenance from publishConfig, restore scope+npm ci in release workflow ([734df6c](https://github.com/gi4nks/ph/commit/734df6cf53b15ff661ad95c530a897a802571ecc))
|
|
28
|
+
|
|
29
|
+
## [2.0.0](https://github.com/gi4nks/ph/compare/v1.3.2...v2.0.0) (2026-05-16)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### ⚠ BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
* **cli:** major refactor of cli.ts into command modules. All commands keep the same interface but the internal architecture changed significantly.
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **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
|
|
39
|
+
* **remote:** `ph remote push|pull|status` — sync prompts across laptops. Dedup via sha256(tool|prompt|response). Background push on each `ph log`.
|
|
40
|
+
* **mcp:** `search_prompts`, `get_prompt`, `search_prompts_semantic` tools for querying raw prompt history via MCP
|
|
41
|
+
* **config:** `remote-url`, `remote-api-key` config keys + `PH_REMOTE_URL` env var support
|
|
42
|
+
* **opencode:** native importer (`ph import opencode`) + real-time plugin hook
|
|
43
|
+
|
|
44
|
+
### (prima di continuare con il commit fammi vedere se ti piace la situazione ) vabene?
|
|
45
|
+
|
|
18
46
|
|
|
19
47
|
## [1.3.0](https://github.com/gi4nks/ph/compare/v1.2.0...v1.3.0) (2026-04-12)
|
|
20
48
|
|
package/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
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
|
|
|
@@ -18,129 +20,85 @@ git clone git@github.com:gi4nks/ph.git
|
|
|
18
20
|
cd ph
|
|
19
21
|
npm install
|
|
20
22
|
make build
|
|
21
|
-
make install
|
|
23
|
+
make install
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
The tool uses a configuration file at `~/.ph_config.json`.
|
|
27
|
-
|
|
26
|
+
Or install from npm:
|
|
28
27
|
```bash
|
|
29
|
-
|
|
30
|
-
ph config set analyze-provider gemini # or 'ollama' (default)
|
|
31
|
-
ph config set background-analysis true # Enable auto-analysis
|
|
28
|
+
npm install -g @gi4nks/ph
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
##
|
|
35
|
-
|
|
36
|
-
`ph` stores its data locally to ensure privacy and fast access.
|
|
37
|
-
|
|
38
|
-
### Files and Locations
|
|
39
|
-
|
|
40
|
-
| Item | Default Path | Description |
|
|
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). |
|
|
44
|
-
|
|
45
|
-
### Customizing the Database Path
|
|
46
|
-
You can move your database to a different location (e.g., an external drive or a cloud-synced folder):
|
|
31
|
+
## Quick Start
|
|
47
32
|
|
|
48
33
|
```bash
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
# Wrap an AI tool
|
|
35
|
+
ph claude "explain goroutines"
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
# Search history
|
|
38
|
+
ph search "goroutines"
|
|
39
|
+
ph search --semantic "concurrency patterns"
|
|
40
|
+
ph search --tool claude --role debug --since 2026-01-01
|
|
54
41
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
ph cleanup --min-length 20 --days 30
|
|
42
|
+
# Browse with TUI
|
|
43
|
+
ph browse
|
|
58
44
|
|
|
59
|
-
#
|
|
60
|
-
ph
|
|
45
|
+
# Start HTTP server for remote sync
|
|
46
|
+
ph server --port 3001
|
|
61
47
|
|
|
62
|
-
#
|
|
63
|
-
|
|
48
|
+
# Sync with another machine
|
|
49
|
+
export PH_REMOTE_URL=http://my-server:3001
|
|
50
|
+
ph remote push # push local prompts to server
|
|
51
|
+
ph remote pull # pull remote prompts into local DB
|
|
64
52
|
```
|
|
65
53
|
|
|
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.
|
|
68
|
-
|
|
69
|
-
## Hooks (Integration with AI CLI)
|
|
70
|
-
|
|
71
|
-
Hooks allow `ph` to automatically capture prompts and responses from other AI CLI tools by integrating directly with their native hook systems.
|
|
54
|
+
## Configuration
|
|
72
55
|
|
|
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.
|
|
56
|
+
Config file at `~/.ph_config.json`:
|
|
75
57
|
|
|
76
|
-
|
|
58
|
+
```bash
|
|
59
|
+
ph config set analyze-provider ollama # or 'gemini' (default: ollama)
|
|
60
|
+
ph config set background-analysis true # auto-analyze after each log
|
|
61
|
+
ph config set remote-url http://server:3001 # remote sync target
|
|
62
|
+
```
|
|
77
63
|
|
|
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
|
-
```
|
|
64
|
+
Environment variable `PH_REMOTE_URL` takes precedence over config.
|
|
89
65
|
|
|
90
|
-
|
|
91
|
-
1. Link the hook script to your `.claude` folder:
|
|
92
|
-
```bash
|
|
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
|
-
```
|
|
66
|
+
## Storage
|
|
101
67
|
|
|
102
|
-
|
|
68
|
+
| Item | Default Path | Description |
|
|
69
|
+
|------|--------------|-------------|
|
|
70
|
+
| Database | `~/.prompt_history.db` | SQLite with FTS5 + sqlite-vec |
|
|
71
|
+
| Config | `~/.ph_config.json` | JSON with 0o600 permissions |
|
|
103
72
|
|
|
104
|
-
##
|
|
73
|
+
## Architecture
|
|
105
74
|
|
|
106
|
-
### Search
|
|
107
|
-
```bash
|
|
108
|
-
ph search "how to refactor" # Textual search
|
|
109
|
-
ph search --semantic "refactoring" # Semantic search
|
|
110
75
|
```
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
76
|
+
Capture modes: wrapper → hook → direct → OpenCode plugin
|
|
77
|
+
|
|
|
78
|
+
v
|
|
79
|
+
Local SQLite (FTS5 + vec0 + memories)
|
|
80
|
+
|
|
|
81
|
+
├── MCP server (stdio) → OpenCode / any MCP client
|
|
82
|
+
├── HTTP server (REST) → remote ph instances
|
|
83
|
+
└── Background analysis → memories table (append-only per project)
|
|
115
84
|
```
|
|
116
|
-
*Hotkeys:* `f` (filters), `e` (edit metadata), `r` (rerun prompt), `y` (copy), `x` (delete).
|
|
117
85
|
|
|
118
|
-
##
|
|
86
|
+
## Hooks
|
|
119
87
|
|
|
120
|
-
|
|
88
|
+
Hooks in `hooks/` integrate with AI CLI tools natively:
|
|
121
89
|
|
|
122
|
-
|
|
123
|
-
|
|
90
|
+
- **Claude Code**: `hooks/claude/ph-hook.sh` — Stop hook
|
|
91
|
+
- **Gemini CLI**: `hooks/gemini/ph-hook.sh` — AfterAgent hook
|
|
92
|
+
- **OpenCode**: `hooks/opencode/ph-plugin.ts` — native plugin (captures streaming responses)
|
|
124
93
|
|
|
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
|
-
```
|
|
94
|
+
## Development
|
|
130
95
|
|
|
131
|
-
After the release, remember to push the tags to trigger the **GitHub Action** for publication:
|
|
132
96
|
```bash
|
|
133
|
-
|
|
97
|
+
make build # tsup build
|
|
98
|
+
make test # vitest
|
|
99
|
+
make lint # eslint
|
|
134
100
|
```
|
|
135
|
-
The package will be automatically built and published to [npmjs.org](https://www.npmjs.com/package/@gi4nks/ph).
|
|
136
101
|
|
|
137
|
-
|
|
138
|
-
Install globally with:
|
|
139
|
-
```bash
|
|
140
|
-
npm install -g @gi4nks/ph
|
|
141
|
-
```
|
|
102
|
+
## License
|
|
142
103
|
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
ph export --format md --limit 5 > prompts.md
|
|
146
|
-
```
|
|
104
|
+
MIT
|