@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
|
@@ -14,11 +14,13 @@ const sessions = new Map<string, {
|
|
|
14
14
|
}>();
|
|
15
15
|
|
|
16
16
|
function textFromParts(parts: { type?: string; text?: string }[]): string {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
try {
|
|
18
|
+
return parts
|
|
19
|
+
.filter(p => p.type === 'text')
|
|
20
|
+
.map(p => p.text || '')
|
|
21
|
+
.join('')
|
|
22
|
+
.trim();
|
|
23
|
+
} catch { return ''; }
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
async function callPhLog(
|
|
@@ -27,75 +29,76 @@ async function callPhLog(
|
|
|
27
29
|
response: string,
|
|
28
30
|
workdir: string,
|
|
29
31
|
): Promise<void> {
|
|
30
|
-
|
|
32
|
+
try {
|
|
33
|
+
if (!prompt.text || !response) return;
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const payload: Record<string, unknown> = {
|
|
36
|
+
tool: 'opencode',
|
|
37
|
+
prompt: prompt.text,
|
|
38
|
+
response,
|
|
39
|
+
workdir,
|
|
40
|
+
};
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const meta: Record<string, unknown> = { source: 'plugin' };
|
|
43
|
+
if (prompt.agent) meta.agent = prompt.agent;
|
|
44
|
+
if (prompt.model) meta.model = prompt.model;
|
|
45
|
+
payload.metadata = JSON.stringify(meta);
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
const json = JSON.stringify(payload);
|
|
48
|
+
$`echo ${json} | ph log > /dev/null 2>&1`.catch(() => {});
|
|
49
|
+
} catch { /* silent */ }
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export const PhOpenCodePlugin: Plugin = async ({ directory, $ }) => {
|
|
50
53
|
return {
|
|
51
54
|
"chat.message": async (input, output) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
try {
|
|
56
|
+
const { sessionID, agent, model } = input;
|
|
57
|
+
const { message, parts } = output;
|
|
58
|
+
const role = (message as Record<string, unknown>).role;
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if (role === 'user') {
|
|
61
|
+
const existing = sessions.get(sessionID);
|
|
62
|
+
const prompt = existing?.prompt;
|
|
63
|
+
const response = existing?.response;
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
+
if (prompt && response) {
|
|
66
|
+
await callPhLog($, prompt, response, directory);
|
|
67
|
+
}
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (!existing?.prompt) return;
|
|
69
|
+
const text = textFromParts(parts);
|
|
70
|
+
if (text) {
|
|
71
|
+
sessions.set(sessionID, {
|
|
72
|
+
prompt: {
|
|
73
|
+
text,
|
|
74
|
+
timestamp: new Date().toISOString(),
|
|
75
|
+
agent,
|
|
76
|
+
model: model ? `${model.providerID}/${model.modelID}` : undefined,
|
|
77
|
+
},
|
|
78
|
+
response: '',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
} else if (role === 'assistant') {
|
|
82
|
+
const existing = sessions.get(sessionID);
|
|
83
|
+
if (!existing?.prompt) return;
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const text = textFromParts(parts);
|
|
86
|
+
if (text) {
|
|
87
|
+
sessions.set(sessionID, { ...existing, response: text });
|
|
88
|
+
}
|
|
87
89
|
}
|
|
88
|
-
}
|
|
90
|
+
} catch { /* silent */ }
|
|
89
91
|
},
|
|
90
92
|
|
|
91
93
|
"experimental.text.complete": async (input, output) => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
try {
|
|
95
|
+
const session = sessions.get(input.sessionID);
|
|
96
|
+
if (!session?.prompt) return;
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
98
|
+
if (output.text) {
|
|
99
|
+
sessions.set(input.sessionID, { ...session, response: output.text });
|
|
100
|
+
}
|
|
101
|
+
} catch { /* silent */ }
|
|
99
102
|
},
|
|
100
103
|
};
|
|
101
104
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gi4nks/ph",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Transparent CLI wrapper that captures and indexes AI prompts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
7
10
|
"bin": {
|
|
8
11
|
"ph": "dist/cli.js"
|
|
9
12
|
},
|
|
@@ -51,36 +54,39 @@
|
|
|
51
54
|
"dev": "tsx src/cli.ts",
|
|
52
55
|
"start": "node dist/cli.js",
|
|
53
56
|
"test": "vitest run",
|
|
54
|
-
"lint": "eslint src"
|
|
57
|
+
"lint": "eslint src",
|
|
58
|
+
"eval:retrieval": "tsx scripts/eval-context-retrieval.ts"
|
|
55
59
|
},
|
|
56
60
|
"dependencies": {
|
|
57
61
|
"@gi4nks/ink": "^1.5.0",
|
|
62
|
+
"@gi4nks/wise": "^2.1.0",
|
|
58
63
|
"@lydell/node-pty": "^1.2.0-beta.3",
|
|
59
64
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
65
|
+
"ai": "^7.0.136",
|
|
60
66
|
"better-sqlite3": "^12.8.0",
|
|
61
|
-
"ink": "^
|
|
62
|
-
"react": "^19.2.
|
|
67
|
+
"ink": "^7.0.5",
|
|
68
|
+
"react": "^19.2.7",
|
|
63
69
|
"sqlite-vec": "^0.1.9",
|
|
64
70
|
"zod": "^4.3.6"
|
|
65
71
|
},
|
|
66
72
|
"devDependencies": {
|
|
73
|
+
"@eslint/js": "^9.39.5",
|
|
67
74
|
"@semantic-release/changelog": "^6.0.3",
|
|
68
75
|
"@semantic-release/git": "^10.0.1",
|
|
69
76
|
"@semantic-release/github": "^12.0.8",
|
|
70
77
|
"@semantic-release/npm": "^13.1.5",
|
|
71
78
|
"@types/better-sqlite3": "^7.6.13",
|
|
72
|
-
"@types/node": "^25.
|
|
73
|
-
"@types/react": "^19.2.
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
75
|
-
"@typescript-eslint/parser": "^8.
|
|
76
|
-
"eslint": "^9.39.
|
|
79
|
+
"@types/node": "^25.9.3",
|
|
80
|
+
"@types/react": "^19.2.7",
|
|
81
|
+
"@typescript-eslint/eslint-plugin": "^8.58.2",
|
|
82
|
+
"@typescript-eslint/parser": "^8.58.2",
|
|
83
|
+
"eslint": "^9.39.5",
|
|
77
84
|
"eslint-plugin-react": "^7.37.5",
|
|
78
85
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
79
86
|
"semantic-release": "^25.0.3",
|
|
80
|
-
"standard-version": "^9.5.0",
|
|
81
87
|
"tsup": "^8.5.1",
|
|
82
88
|
"tsx": "^4.21.0",
|
|
83
|
-
"typescript": "^
|
|
84
|
-
"vitest": "^4.1.
|
|
89
|
+
"typescript": "^6.0.3",
|
|
90
|
+
"vitest": "^4.1.8"
|
|
85
91
|
}
|
|
86
92
|
}
|