@tph/team-prompt-history 2.0.2 → 2.0.4
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/.cursor-plugin/plugin.json +1 -1
- package/README.md +5 -4
- package/dist/antigravity-hook-entry.d.ts +1 -0
- package/dist/antigravity-hook-entry.js +82 -0
- package/dist/antigravity-hook-entry.js.map +1 -0
- package/dist/capture/antigravity-transcript.d.ts +35 -0
- package/dist/capture/antigravity-transcript.js +163 -0
- package/dist/capture/antigravity-transcript.js.map +1 -0
- package/dist/capture/handler.d.ts +13 -2
- package/dist/capture/handler.js +20 -8
- package/dist/capture/handler.js.map +1 -1
- package/dist/capture/platform.d.ts +10 -0
- package/dist/capture/platform.js +36 -0
- package/dist/capture/platform.js.map +1 -0
- package/dist/capture/record.d.ts +5 -1
- package/dist/capture/record.js +6 -2
- package/dist/capture/record.js.map +1 -1
- package/dist/cli.js +94 -0
- package/dist/cli.js.map +1 -1
- package/dist/history/search.js +4 -0
- package/dist/history/search.js.map +1 -1
- package/dist/install-hooks.d.ts +48 -0
- package/dist/install-hooks.js +291 -0
- package/dist/install-hooks.js.map +1 -0
- package/dist/platform-hook-entry.d.ts +1 -0
- package/dist/platform-hook-entry.js +86 -0
- package/dist/platform-hook-entry.js.map +1 -0
- package/dist/storage/format.js +14 -3
- package/dist/storage/format.js.map +1 -1
- package/dist/sync/collector.js +1 -0
- package/dist/sync/collector.js.map +1 -1
- package/dist/sync/doctor.js +9 -2
- package/dist/sync/doctor.js.map +1 -1
- package/dist/sync/push.js +1 -0
- package/dist/sync/push.js.map +1 -1
- package/dist/types/prompt.d.ts +6 -2
- package/dist/ui/display.js +2 -1
- package/dist/ui/display.js.map +1 -1
- package/docs/API-VERIFICATION.md +63 -0
- package/docs/PROMPT-PLATFORMS.md +148 -0
- package/node_modules/@tph/shared/dist/index.d.ts +8 -1
- package/node_modules/@tph/shared/dist/index.js +42 -1
- package/node_modules/@tph/shared/package.json +1 -1
- package/opencode/tph-prompt-history.js +77 -0
- package/package.json +7 -4
- package/scripts/capture-claude.js +9 -0
- package/scripts/capture-codex.js +9 -0
- package/skills/prompt-history/SKILL.md +3 -2
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode plugin — Team Prompt History Manager
|
|
3
|
+
*
|
|
4
|
+
* Verified mechanism: plugin hook `chat.message` (Hooks in @opencode-ai/plugin).
|
|
5
|
+
* Reads user text from `output.parts` (type === "text") and captures via the
|
|
6
|
+
* local prompt-history CLI with --platform opencode.
|
|
7
|
+
*
|
|
8
|
+
* Gap: some OpenCode builds have delivered empty `parts` to this hook
|
|
9
|
+
* (see anomalyco/opencode#22831). When parts are empty we skip capture rather
|
|
10
|
+
* than invent content — use `prompt-history capture --platform opencode` as a
|
|
11
|
+
* manual/CLI fallback.
|
|
12
|
+
*
|
|
13
|
+
* Install: prompt-history install-hooks --platform opencode
|
|
14
|
+
* (copies into ~/.config/opencode/plugins/)
|
|
15
|
+
*/
|
|
16
|
+
import { spawn } from "node:child_process";
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import process from "node:process";
|
|
20
|
+
|
|
21
|
+
/** @type {string | null} */
|
|
22
|
+
const PACKAGE_ROOT = __TPH_PACKAGE_ROOT__;
|
|
23
|
+
|
|
24
|
+
function resolveCli() {
|
|
25
|
+
if (PACKAGE_ROOT) {
|
|
26
|
+
const cli = path.join(PACKAGE_ROOT, "dist", "cli.js");
|
|
27
|
+
if (fs.existsSync(cli)) return { cmd: process.execPath || "node", args: [cli] };
|
|
28
|
+
}
|
|
29
|
+
return { cmd: "prompt-history", args: [] };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function extractText(parts) {
|
|
33
|
+
if (!Array.isArray(parts)) return "";
|
|
34
|
+
return parts
|
|
35
|
+
.filter((p) => p && p.type === "text" && typeof p.text === "string")
|
|
36
|
+
.map((p) => p.text)
|
|
37
|
+
.join("\n")
|
|
38
|
+
.trim();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function captureAsync(prompt, messageId) {
|
|
42
|
+
const { cmd, args } = resolveCli();
|
|
43
|
+
const fullArgs = [...args, "capture", "--platform", "opencode", "--json"];
|
|
44
|
+
const child = spawn(cmd, fullArgs, {
|
|
45
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
46
|
+
detached: true,
|
|
47
|
+
env: { ...process.env, TPH_PROMPT_PLATFORM: "opencode" },
|
|
48
|
+
});
|
|
49
|
+
const payload = JSON.stringify({
|
|
50
|
+
prompt,
|
|
51
|
+
prompt_id: messageId || undefined,
|
|
52
|
+
hook_event_name: "chat.message",
|
|
53
|
+
});
|
|
54
|
+
child.stdin.write(payload);
|
|
55
|
+
child.stdin.end();
|
|
56
|
+
child.unref();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const PromptHistoryPlugin = async () => {
|
|
60
|
+
return {
|
|
61
|
+
"chat.message": async (input, output) => {
|
|
62
|
+
try {
|
|
63
|
+
const prompt = extractText(output && output.parts);
|
|
64
|
+
if (!prompt) return;
|
|
65
|
+
const messageID =
|
|
66
|
+
(input && input.messageID) ||
|
|
67
|
+
(output && output.message && output.message.id) ||
|
|
68
|
+
undefined;
|
|
69
|
+
captureAsync(prompt, messageID);
|
|
70
|
+
} catch {
|
|
71
|
+
/* never block OpenCode */
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default PromptHistoryPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tph/team-prompt-history",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Cursor plugin — local capture, push-on-capture, and team collection client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
"hooks",
|
|
15
15
|
"commands",
|
|
16
16
|
"skills",
|
|
17
|
-
"scripts
|
|
17
|
+
"scripts",
|
|
18
|
+
"opencode",
|
|
18
19
|
"examples",
|
|
20
|
+
"docs",
|
|
19
21
|
"README.md"
|
|
20
22
|
],
|
|
21
23
|
"engines": {
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"team"
|
|
29
31
|
],
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"@tph/shared": "2.0.
|
|
33
|
+
"@tph/shared": "2.0.4"
|
|
32
34
|
},
|
|
33
35
|
"bundledDependencies": [
|
|
34
36
|
"@tph/shared"
|
|
@@ -36,7 +38,8 @@
|
|
|
36
38
|
"scripts": {
|
|
37
39
|
"start": "node dist/cli.js",
|
|
38
40
|
"cli": "node dist/cli.js",
|
|
39
|
-
"install-plugin": "node dist/cli.js install-plugin"
|
|
41
|
+
"install-plugin": "node dist/cli.js install-plugin",
|
|
42
|
+
"install-hooks": "node dist/cli.js install-hooks"
|
|
40
43
|
},
|
|
41
44
|
"publishConfig": {
|
|
42
45
|
"access": "public",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Claude Code UserPromptSubmit shim.
|
|
5
|
+
* Verified API: https://code.claude.com/docs/en/hooks
|
|
6
|
+
*/
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
process.env.TPH_PROMPT_PLATFORM = "claude";
|
|
9
|
+
require(path.join(__dirname, "..", "dist", "platform-hook-entry.js"));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Codex UserPromptSubmit shim.
|
|
5
|
+
* Verified API: https://developers.openai.com/codex/hooks
|
|
6
|
+
*/
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
process.env.TPH_PROMPT_PLATFORM = "codex";
|
|
9
|
+
require(path.join(__dirname, "..", "dist", "platform-hook-entry.js"));
|
|
@@ -7,15 +7,16 @@ description: Manage Team Prompt History — local capture, push-on-capture, enro
|
|
|
7
7
|
|
|
8
8
|
## Default behavior (push-on-capture)
|
|
9
9
|
|
|
10
|
-
1. Cursor
|
|
10
|
+
1. A verified product hook (Cursor `beforeSubmitPrompt`, Claude/Codex `UserPromptSubmit`, OpenCode `chat.message`) appends to the local `.txt` with `promptPlatform` set.
|
|
11
11
|
2. If the device is enrolled and sync is enabled, the same prompt is **queued and pushed** to the team server in the background (non-blocking).
|
|
12
12
|
3. If the server is down, the local file and durable queue keep the prompt; the background service retries with backoff.
|
|
13
13
|
4. Admin **Collections** remain as a **fallback/backfill** (upload remaining local history + verified backup/rotate).
|
|
14
14
|
|
|
15
15
|
## Local
|
|
16
16
|
|
|
17
|
-
-
|
|
17
|
+
- Cursor: **`beforeSubmitPrompt`**. Claude Code / Codex / OpenCode: `prompt-history install-hooks`.
|
|
18
18
|
- Never loses prompts: local append always wins over network.
|
|
19
|
+
- Never invent platform tags without a real hook — see `docs/PROMPT-PLATFORMS.md`.
|
|
19
20
|
|
|
20
21
|
## Team
|
|
21
22
|
|