@gi4nks/ph 1.3.2
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 +57 -0
- package/LICENSE +21 -0
- package/README.md +146 -0
- package/dist/cli.js +3885 -0
- package/dist/cli.js.map +1 -0
- package/docs/hooks.md +83 -0
- package/docs/ph-manual.md +283 -0
- package/hooks/claude/README.md +45 -0
- package/hooks/claude/ph-hook.sh +103 -0
- package/hooks/gemini/README.md +43 -0
- package/hooks/gemini/ph-hook.sh +56 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
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
|
+
|
|
5
|
+
### [1.3.2](https://github.com/gi4nks/ph/compare/v1.3.1...v1.3.2) (2026-04-17)
|
|
6
|
+
|
|
7
|
+
### [1.3.1](https://github.com/gi4nks/ph/compare/v1.3.0...v1.3.1) (2026-04-13)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **ui:** major redesign of browse view with split-pane and topic extraction ([53d9008](https://github.com/gi4nks/ph/commit/53d90087709ffda5913fc3026b6554f0aae4ddf4))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* resolve npm publish auth error and bin path warning ([5dfe49a](https://github.com/gi4nks/ph/commit/5dfe49ab6c169ec2eed8c16fe73139381efdf0ed))
|
|
18
|
+
|
|
19
|
+
## [1.3.0](https://github.com/gi4nks/ph/compare/v1.2.0...v1.3.0) (2026-04-12)
|
|
20
|
+
|
|
21
|
+
## [1.2.0](https://github.com/gi4nks/ph/compare/v1.1.2...v1.2.0) (2026-04-06)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* add cleanup-reusability command for strategic database cleanup ([efeefec](https://github.com/gi4nks/ph/commit/efeefec2552a850cae275925b5c64f0542eac8bf))
|
|
27
|
+
* use AppHeader and AppFooter from @gi4nks/ink ([bc48011](https://github.com/gi4nks/ph/commit/bc480119d4509d02926a698531e84ecf14cd05d5))
|
|
28
|
+
|
|
29
|
+
### [1.1.2](https://github.com/gi4nks/ph/compare/v1.1.1...v1.1.2) (2026-03-28)
|
|
30
|
+
|
|
31
|
+
### [1.1.1](https://github.com/gi4nks/ph/compare/v1.1.0...v1.1.1) (2026-03-28)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **hooks:** improve portability and update documentation ([861f0ac](https://github.com/gi4nks/ph/commit/861f0ac6b62d91881af11d0a488b3e6d688c6f5b))
|
|
37
|
+
|
|
38
|
+
## [1.1.0](https://github.com/gi4nks/ph/compare/v1.0.1...v1.1.0) (2026-03-28)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* add database maintenance commands (cleanup --days and vacuum) ([5657b14](https://github.com/gi4nks/ph/commit/5657b1424b582228516118be25021a60309025c7))
|
|
44
|
+
|
|
45
|
+
### [1.0.1](https://github.com/gi4nks/ph/compare/v1.0.0...v1.0.1) (2026-03-28)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
* add github packages workflow ([5185983](https://github.com/gi4nks/ph/commit/5185983b8fecd7be1ee8db6e821c675007571654))
|
|
51
|
+
|
|
52
|
+
## 1.0.0 (2026-03-28)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Features
|
|
56
|
+
|
|
57
|
+
* initial commit ([3803d81](https://github.com/gi4nks/ph/commit/3803d816ecf06ca0068f541a67a148d4c67215a2))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gianluca
|
|
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,146 @@
|
|
|
1
|
+
# ph — Prompt History & Analysis Tool
|
|
2
|
+
|
|
3
|
+
`ph` is a transparent wrapper for AI CLI tools (such as Gemini CLI, Claude CLI, etc.). It captures every prompt into a local SQLite database, providing full-text and semantic search, automatic background analysis, and Git context snapshots.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- 📥 **Automatic Capture**: Saves prompts, output (if non-interactive), and metadata.
|
|
8
|
+
- 🌳 **Git Context**: Saves branch, modified files, and diff at the time of the prompt.
|
|
9
|
+
- 🔍 **Advanced Search**: Textual search (FTS5) and semantic search (vectorial).
|
|
10
|
+
- 🧠 **Background Analysis**: Automatic prompt analysis (role, tags, relevance) via Ollama or Gemini.
|
|
11
|
+
- 🖥️ **Interactive TUI**: Interactive browser (`ph browse`) to manage history.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Clone and local build
|
|
17
|
+
git clone git@github.com:gi4nks/ph.git
|
|
18
|
+
cd ph
|
|
19
|
+
npm install
|
|
20
|
+
make build
|
|
21
|
+
make install # Installs the global 'ph' link
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
The tool uses a configuration file at `~/.ph_config.json`.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
ph config set gemini-api-key "YOUR_KEY"
|
|
30
|
+
ph config set analyze-provider gemini # or 'ollama' (default)
|
|
31
|
+
ph config set background-analysis true # Enable auto-analysis
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Storage & Architecture
|
|
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):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ph config set db-path "/path/to/your/custom.db"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Database Maintenance
|
|
53
|
+
As you use `ph`, the database might grow due to Git diffs and metadata. Use these commands to keep it lean:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Remove prompts shorter than 20 chars or older than 30 days
|
|
57
|
+
ph cleanup --min-length 20 --days 30
|
|
58
|
+
|
|
59
|
+
# Compact the database file to reclaim disk space
|
|
60
|
+
ph vacuum
|
|
61
|
+
|
|
62
|
+
# Run a dry-run to see what would be deleted
|
|
63
|
+
ph cleanup --dry-run --days 60
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Database Security
|
|
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.
|
|
72
|
+
|
|
73
|
+
### How they work
|
|
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.
|
|
75
|
+
|
|
76
|
+
### Hook Installation
|
|
77
|
+
|
|
78
|
+
#### Gemini CLI
|
|
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
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Claude Code
|
|
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
|
+
```
|
|
101
|
+
|
|
102
|
+
The hooks will automatically send every interaction to `ph` without requiring any shell aliases or manual capture commands.
|
|
103
|
+
|
|
104
|
+
## Usage
|
|
105
|
+
|
|
106
|
+
### Search
|
|
107
|
+
```bash
|
|
108
|
+
ph search "how to refactor" # Textual search
|
|
109
|
+
ph search --semantic "refactoring" # Semantic search
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### TUI Browser
|
|
113
|
+
```bash
|
|
114
|
+
ph browse
|
|
115
|
+
```
|
|
116
|
+
*Hotkeys:* `f` (filters), `e` (edit metadata), `r` (rerun prompt), `y` (copy), `x` (delete).
|
|
117
|
+
|
|
118
|
+
## Releases and Versioning
|
|
119
|
+
|
|
120
|
+
The project follows **Semantic Versioning (SemVer)** and uses [Conventional Commits](https://www.conventionalcommits.org/). Releases are managed via `standard-version`.
|
|
121
|
+
|
|
122
|
+
### Release Commands
|
|
123
|
+
To create a new version (updates `package.json`, generates `CHANGELOG.md`, and creates a Git tag):
|
|
124
|
+
|
|
125
|
+
```bash
|
|
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
|
+
```
|
|
130
|
+
|
|
131
|
+
After the release, remember to push the tags to trigger the **GitHub Action** for publication:
|
|
132
|
+
```bash
|
|
133
|
+
git push --follow-tags origin main
|
|
134
|
+
```
|
|
135
|
+
The package will be automatically built and published to [npmjs.org](https://www.npmjs.com/package/@gi4nks/ph).
|
|
136
|
+
|
|
137
|
+
### Installation via npm
|
|
138
|
+
Install globally with:
|
|
139
|
+
```bash
|
|
140
|
+
npm install -g @gi4nks/ph
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Export
|
|
144
|
+
```bash
|
|
145
|
+
ph export --format md --limit 5 > prompts.md
|
|
146
|
+
```
|