@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
package/README.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# @tph/team-prompt-history
|
|
2
2
|
|
|
3
|
-
Team Prompt History —
|
|
3
|
+
Team Prompt History — multi-platform capture (Cursor / Claude Code / Codex / OpenCode / Antigravity), push-on-capture, and team sync.
|
|
4
4
|
|
|
5
5
|
## Install (developers)
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm config set @tph:registry
|
|
9
|
-
npm install -g @tph/team-prompt-history
|
|
8
|
+
npm config set @tph:registry=https://registry.npmjs.org/
|
|
9
|
+
npm install -g @tph/team-prompt-history@latest
|
|
10
10
|
prompt-history install-plugin
|
|
11
|
+
prompt-history install-hooks --platform all
|
|
11
12
|
prompt-history register --server https://YOUR_TPH_HOST --key tph_… --device-name "$(hostname -s)"
|
|
12
13
|
```
|
|
13
14
|
|
|
14
|
-
Reload Cursor after `install-plugin`.
|
|
15
|
+
Reload Cursor after `install-plugin`. See `docs/PROMPT-PLATFORMS.md` for verified hooks and gaps.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Antigravity PreInvocation hook entry (observe-only).
|
|
5
|
+
*
|
|
6
|
+
* Verified: https://antigravity.google/docs/hooks/
|
|
7
|
+
* Antigravity has no UserPromptSubmit / beforeSubmitPrompt. Closest event is
|
|
8
|
+
* PreInvocation, whose stdin JSON does NOT include prompt text — only
|
|
9
|
+
* transcriptPath (plus conversationId, invocationNum, …).
|
|
10
|
+
*
|
|
11
|
+
* Capture strategy: read newest USER_INPUT from transcript JSONL, unwrap
|
|
12
|
+
* <USER_REQUEST>…</USER_REQUEST>, tag promptPlatform=antigravity.
|
|
13
|
+
* Mid-turn PreInvocation repeats are deduped via conversationId:step_index.
|
|
14
|
+
* Stdout is always `{}` (no injectSteps).
|
|
15
|
+
*/
|
|
16
|
+
const handler_1 = require("./capture/handler");
|
|
17
|
+
const antigravity_transcript_1 = require("./capture/antigravity-transcript");
|
|
18
|
+
const push_1 = require("./sync/push");
|
|
19
|
+
async function readStdin() {
|
|
20
|
+
const chunks = [];
|
|
21
|
+
for await (const chunk of process.stdin) {
|
|
22
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
23
|
+
}
|
|
24
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
25
|
+
}
|
|
26
|
+
function respondEmpty() {
|
|
27
|
+
process.stdout.write("{}");
|
|
28
|
+
}
|
|
29
|
+
async function main() {
|
|
30
|
+
try {
|
|
31
|
+
const raw = await readStdin();
|
|
32
|
+
let payload = {};
|
|
33
|
+
if (raw.trim()) {
|
|
34
|
+
try {
|
|
35
|
+
payload = JSON.parse(raw);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
respondEmpty();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const transcriptPath = typeof payload.transcriptPath === "string" ? payload.transcriptPath : "";
|
|
43
|
+
if (!transcriptPath) {
|
|
44
|
+
respondEmpty();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const conversationId = typeof payload.conversationId === "string" ? payload.conversationId : "";
|
|
48
|
+
const found = await (0, antigravity_transcript_1.waitForLatestUserInput)(transcriptPath);
|
|
49
|
+
if (!found?.prompt) {
|
|
50
|
+
// Prompt not on disk yet / empty — skip, never invent.
|
|
51
|
+
respondEmpty();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const generationId = conversationId && found.stepIndex != null
|
|
55
|
+
? `agy:${conversationId}:${found.stepIndex}`
|
|
56
|
+
: conversationId
|
|
57
|
+
? `agy:${conversationId}:${found.prompt.slice(0, 64)}`
|
|
58
|
+
: undefined;
|
|
59
|
+
const result = await (0, handler_1.capturePrompt)({
|
|
60
|
+
prompt: found.prompt,
|
|
61
|
+
promptPlatform: "antigravity",
|
|
62
|
+
generationId,
|
|
63
|
+
});
|
|
64
|
+
if (result.reason === "error") {
|
|
65
|
+
process.stderr.write(`[prompt-history] antigravity capture error: ${result.detail ?? "unknown"}\n`);
|
|
66
|
+
}
|
|
67
|
+
respondEmpty();
|
|
68
|
+
try {
|
|
69
|
+
await (0, push_1.flushPushQueue)();
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* ignore */
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
const message = err instanceof Error ? err.message : "unknown";
|
|
77
|
+
process.stderr.write(`[prompt-history] antigravity hook failed (agent still allowed): ${message}\n`);
|
|
78
|
+
respondEmpty();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
void main();
|
|
82
|
+
//# sourceMappingURL=antigravity-hook-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antigravity-hook-entry.js","sourceRoot":"","sources":["../src/antigravity-hook-entry.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;GAYG;AACH,+CAAkD;AAClD,6EAA0E;AAC1E,sCAA6C;AAE7C,KAAK,UAAU,SAAS;IACtB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED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,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAa,EAAC;YACjC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,cAAc,EAAE,aAAa;YAC7B,YAAY;SACb,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,+CAA+C,MAAM,CAAC,MAAM,IAAI,SAAS,IAAI,CAC9E,CAAC;QACJ,CAAC;QAED,YAAY,EAAE,CAAC;QAEf,IAAI,CAAC;YACH,MAAM,IAAA,qBAAc,GAAE,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,mEAAmE,OAAO,IAAI,CAC/E,CAAC;QACF,YAAY,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface AntigravityUserInput {
|
|
2
|
+
prompt: string;
|
|
3
|
+
stepIndex: number | null;
|
|
4
|
+
createdAt: string | null;
|
|
5
|
+
}
|
|
6
|
+
/** Expand leading ~/ to home. */
|
|
7
|
+
export declare function expandHomePath(p: string, homeDir?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Prefer transcript_full.jsonl (untruncated) when present next to transcript.jsonl.
|
|
10
|
+
* Docs: https://antigravity.google/docs/hooks/
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveTranscriptPath(transcriptPath: string, homeDir?: string): string | null;
|
|
13
|
+
/** Strip Antigravity <USER_REQUEST>…</USER_REQUEST> wrapper when present. */
|
|
14
|
+
export declare function extractUserRequest(content: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Scan Antigravity transcript JSONL for the newest USER_INPUT step.
|
|
17
|
+
* Returns null when the prompt is not on disk yet (known PreInvocation race).
|
|
18
|
+
*/
|
|
19
|
+
export declare function latestUserInputFromTranscript(fileContents: string, opts?: {
|
|
20
|
+
minStepIndex?: number | null;
|
|
21
|
+
}): AntigravityUserInput | null;
|
|
22
|
+
export declare function readLatestUserInput(transcriptPath: string, opts?: {
|
|
23
|
+
homeDir?: string;
|
|
24
|
+
minStepIndex?: number | null;
|
|
25
|
+
}): AntigravityUserInput | null;
|
|
26
|
+
/**
|
|
27
|
+
* PreInvocation often fires before the current USER_INPUT is flushed.
|
|
28
|
+
* Brief rescan; never invent prompt text.
|
|
29
|
+
*/
|
|
30
|
+
export declare function waitForLatestUserInput(transcriptPath: string, opts?: {
|
|
31
|
+
homeDir?: string;
|
|
32
|
+
minStepIndex?: number | null;
|
|
33
|
+
attempts?: number;
|
|
34
|
+
delayMs?: number;
|
|
35
|
+
}): Promise<AntigravityUserInput | null>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.expandHomePath = expandHomePath;
|
|
37
|
+
exports.resolveTranscriptPath = resolveTranscriptPath;
|
|
38
|
+
exports.extractUserRequest = extractUserRequest;
|
|
39
|
+
exports.latestUserInputFromTranscript = latestUserInputFromTranscript;
|
|
40
|
+
exports.readLatestUserInput = readLatestUserInput;
|
|
41
|
+
exports.waitForLatestUserInput = waitForLatestUserInput;
|
|
42
|
+
const fs = __importStar(require("node:fs"));
|
|
43
|
+
const os = __importStar(require("node:os"));
|
|
44
|
+
const path = __importStar(require("node:path"));
|
|
45
|
+
/** Expand leading ~/ to home. */
|
|
46
|
+
function expandHomePath(p, homeDir = os.homedir()) {
|
|
47
|
+
if (!p)
|
|
48
|
+
return p;
|
|
49
|
+
if (p === "~")
|
|
50
|
+
return homeDir;
|
|
51
|
+
if (p.startsWith("~/"))
|
|
52
|
+
return path.join(homeDir, p.slice(2));
|
|
53
|
+
return p;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Prefer transcript_full.jsonl (untruncated) when present next to transcript.jsonl.
|
|
57
|
+
* Docs: https://antigravity.google/docs/hooks/
|
|
58
|
+
*/
|
|
59
|
+
function resolveTranscriptPath(transcriptPath, homeDir = os.homedir()) {
|
|
60
|
+
const primary = expandHomePath(transcriptPath, homeDir);
|
|
61
|
+
if (!primary)
|
|
62
|
+
return null;
|
|
63
|
+
const dir = path.dirname(primary);
|
|
64
|
+
const full = path.join(dir, "transcript_full.jsonl");
|
|
65
|
+
if (fs.existsSync(full))
|
|
66
|
+
return full;
|
|
67
|
+
if (fs.existsSync(primary))
|
|
68
|
+
return primary;
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
/** Strip Antigravity <USER_REQUEST>…</USER_REQUEST> wrapper when present. */
|
|
72
|
+
function extractUserRequest(content) {
|
|
73
|
+
if (!content)
|
|
74
|
+
return null;
|
|
75
|
+
const m = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/i);
|
|
76
|
+
if (m) {
|
|
77
|
+
const inner = m[1].trim();
|
|
78
|
+
return inner || null;
|
|
79
|
+
}
|
|
80
|
+
// Fallback: strip other ALL_CAPS XML-ish wrappers used in transcripts.
|
|
81
|
+
const stripped = content.replace(/<[A-Z_]+>[\s\S]*?<\/[A-Z_]+>/g, "").trim();
|
|
82
|
+
return stripped || content.trim() || null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Scan Antigravity transcript JSONL for the newest USER_INPUT step.
|
|
86
|
+
* Returns null when the prompt is not on disk yet (known PreInvocation race).
|
|
87
|
+
*/
|
|
88
|
+
function latestUserInputFromTranscript(fileContents, opts) {
|
|
89
|
+
const minStep = opts?.minStepIndex == null || Number.isNaN(opts.minStepIndex)
|
|
90
|
+
? null
|
|
91
|
+
: opts.minStepIndex;
|
|
92
|
+
let best = null;
|
|
93
|
+
for (const line of fileContents.split("\n")) {
|
|
94
|
+
const trimmed = line.trim();
|
|
95
|
+
if (!trimmed)
|
|
96
|
+
continue;
|
|
97
|
+
let row;
|
|
98
|
+
try {
|
|
99
|
+
row = JSON.parse(trimmed);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const type = String(row.type ?? "").toUpperCase();
|
|
105
|
+
if (type !== "USER_INPUT")
|
|
106
|
+
continue;
|
|
107
|
+
const stepRaw = row.step_index ?? row.stepIndex;
|
|
108
|
+
const stepIndex = typeof stepRaw === "number"
|
|
109
|
+
? stepRaw
|
|
110
|
+
: typeof stepRaw === "string" && stepRaw.trim()
|
|
111
|
+
? Number(stepRaw)
|
|
112
|
+
: null;
|
|
113
|
+
if (minStep != null && stepIndex != null && stepIndex <= minStep)
|
|
114
|
+
continue;
|
|
115
|
+
const content = typeof row.content === "string" ? row.content : "";
|
|
116
|
+
const prompt = extractUserRequest(content);
|
|
117
|
+
if (!prompt)
|
|
118
|
+
continue;
|
|
119
|
+
const createdAt = typeof row.created_at === "string"
|
|
120
|
+
? row.created_at
|
|
121
|
+
: typeof row.createdAt === "string"
|
|
122
|
+
? row.createdAt
|
|
123
|
+
: null;
|
|
124
|
+
if (!best ||
|
|
125
|
+
(stepIndex != null &&
|
|
126
|
+
(best.stepIndex == null || stepIndex >= best.stepIndex))) {
|
|
127
|
+
best = { prompt, stepIndex, createdAt };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return best;
|
|
131
|
+
}
|
|
132
|
+
function readLatestUserInput(transcriptPath, opts) {
|
|
133
|
+
const resolved = resolveTranscriptPath(transcriptPath, opts?.homeDir);
|
|
134
|
+
if (!resolved)
|
|
135
|
+
return null;
|
|
136
|
+
try {
|
|
137
|
+
const body = fs.readFileSync(resolved, "utf8");
|
|
138
|
+
return latestUserInputFromTranscript(body, {
|
|
139
|
+
minStepIndex: opts?.minStepIndex,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* PreInvocation often fires before the current USER_INPUT is flushed.
|
|
148
|
+
* Brief rescan; never invent prompt text.
|
|
149
|
+
*/
|
|
150
|
+
async function waitForLatestUserInput(transcriptPath, opts) {
|
|
151
|
+
const attempts = opts?.attempts ?? 8;
|
|
152
|
+
const delayMs = opts?.delayMs ?? 40;
|
|
153
|
+
for (let i = 0; i < attempts; i++) {
|
|
154
|
+
const found = readLatestUserInput(transcriptPath, opts);
|
|
155
|
+
if (found)
|
|
156
|
+
return found;
|
|
157
|
+
if (i < attempts - 1) {
|
|
158
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=antigravity-transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"antigravity-transcript.js","sourceRoot":"","sources":["../../src/capture/antigravity-transcript.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,wCAKC;AAMD,sDAWC;AAGD,gDAUC;AAMD,sEAmDC;AAED,kDAcC;AAMD,wDAmBC;AAhJD,4CAA8B;AAC9B,4CAA8B;AAC9B,gDAAkC;AAQlC,iCAAiC;AACjC,SAAgB,cAAc,CAAC,CAAS,EAAE,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE;IAC9D,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC;IAC9B,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,CAAC;AACX,CAAC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE;IAEtB,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,EAAE,OAAO,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,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HookSubmitPayload } from "../types/prompt";
|
|
2
|
+
import type { PromptPlatform } from "@tph/shared";
|
|
2
3
|
export interface CaptureResult {
|
|
3
4
|
captured: boolean;
|
|
4
5
|
reason: "ok" | "not_configured" | "disabled" | "paused" | "empty" | "duplicate" | "config_noise" | "error";
|
|
@@ -6,10 +7,20 @@ export interface CaptureResult {
|
|
|
6
7
|
detail?: string;
|
|
7
8
|
/** Queued for background server push (enrolled + sync on). */
|
|
8
9
|
pushQueued?: boolean;
|
|
10
|
+
promptPlatform?: PromptPlatform;
|
|
9
11
|
}
|
|
12
|
+
export interface CapturePromptInput {
|
|
13
|
+
prompt: string;
|
|
14
|
+
promptPlatform: PromptPlatform;
|
|
15
|
+
/** Optional dedupe key component (e.g. generation_id). */
|
|
16
|
+
generationId?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Shared capture path for Cursor hook and CLI wrappers (claude/codex/opencode).
|
|
20
|
+
*/
|
|
21
|
+
export declare function capturePrompt(input: CapturePromptInput, homeDir?: string): Promise<CaptureResult>;
|
|
10
22
|
/**
|
|
11
|
-
* Process
|
|
12
|
-
* for normal skip paths. Does not log prompt contents.
|
|
23
|
+
* Process Cursor beforeSubmitPrompt payload. Always tags promptPlatform=cursor.
|
|
13
24
|
*/
|
|
14
25
|
export declare function handleBeforeSubmitPrompt(payload: HookSubmitPayload, homeDir?: string): Promise<CaptureResult>;
|
|
15
26
|
/** Hook stdout response — observe only; never block submission. */
|
package/dist/capture/handler.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.capturePrompt = capturePrompt;
|
|
3
4
|
exports.handleBeforeSubmitPrompt = handleBeforeSubmitPrompt;
|
|
4
5
|
exports.hookAllowResponse = hookAllowResponse;
|
|
5
6
|
const store_1 = require("../config/store");
|
|
6
7
|
const writer_1 = require("../storage/writer");
|
|
7
8
|
const push_1 = require("../sync/push");
|
|
8
9
|
const dedupe_1 = require("./dedupe");
|
|
10
|
+
const platform_1 = require("./platform");
|
|
9
11
|
const record_1 = require("./record");
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
* for normal skip paths. Does not log prompt contents.
|
|
13
|
+
* Shared capture path for Cursor hook and CLI wrappers (claude/codex/opencode).
|
|
13
14
|
*/
|
|
14
|
-
async function
|
|
15
|
+
async function capturePrompt(input, homeDir) {
|
|
15
16
|
try {
|
|
16
17
|
const config = (0, store_1.loadConfig)(homeDir);
|
|
17
18
|
if (!config || !(0, store_1.isConfigured)(config)) {
|
|
@@ -23,20 +24,21 @@ async function handleBeforeSubmitPrompt(payload, homeDir) {
|
|
|
23
24
|
if (config.captureState === "paused") {
|
|
24
25
|
return { captured: false, reason: "paused" };
|
|
25
26
|
}
|
|
26
|
-
const prompt =
|
|
27
|
+
const prompt = input.prompt;
|
|
27
28
|
if ((0, record_1.isEmptyPrompt)(prompt)) {
|
|
28
29
|
return { captured: false, reason: "empty" };
|
|
29
30
|
}
|
|
30
31
|
if ((0, record_1.looksLikeConfigUiNoise)(prompt)) {
|
|
31
32
|
return { captured: false, reason: "config_noise" };
|
|
32
33
|
}
|
|
33
|
-
const key = (0, dedupe_1.buildDedupeKey)(
|
|
34
|
+
const key = (0, dedupe_1.buildDedupeKey)(input.generationId, prompt);
|
|
34
35
|
if (!(0, dedupe_1.shouldCaptureOnce)(key, homeDir)) {
|
|
35
36
|
return { captured: false, reason: "duplicate" };
|
|
36
37
|
}
|
|
37
|
-
const record = (0, record_1.createPromptRecord)(prompt, config.historyName
|
|
38
|
+
const record = (0, record_1.createPromptRecord)(prompt, config.historyName, {
|
|
39
|
+
promptPlatform: input.promptPlatform,
|
|
40
|
+
});
|
|
38
41
|
const { fullPath } = (0, store_1.resolveConfigStorage)(config);
|
|
39
|
-
// Local append first — never lose the prompt if the network fails.
|
|
40
42
|
await (0, writer_1.appendRecord)(fullPath, record, config.historyName);
|
|
41
43
|
const push = (0, push_1.schedulePushAfterCapture)(record, homeDir);
|
|
42
44
|
return {
|
|
@@ -44,14 +46,24 @@ async function handleBeforeSubmitPrompt(payload, homeDir) {
|
|
|
44
46
|
reason: "ok",
|
|
45
47
|
detail: record.id,
|
|
46
48
|
pushQueued: push.enqueued,
|
|
49
|
+
promptPlatform: record.promptPlatform,
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
catch (err) {
|
|
50
53
|
const message = err instanceof Error ? err.message : "unknown error";
|
|
51
|
-
// Permission / IO errors — never include prompt text
|
|
52
54
|
return { captured: false, reason: "error", detail: message };
|
|
53
55
|
}
|
|
54
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Process Cursor beforeSubmitPrompt payload. Always tags promptPlatform=cursor.
|
|
59
|
+
*/
|
|
60
|
+
async function handleBeforeSubmitPrompt(payload, homeDir) {
|
|
61
|
+
return capturePrompt({
|
|
62
|
+
prompt: typeof payload.prompt === "string" ? payload.prompt : "",
|
|
63
|
+
promptPlatform: (0, platform_1.platformFromCursorHook)(),
|
|
64
|
+
generationId: typeof payload.generation_id === "string" ? payload.generation_id : undefined,
|
|
65
|
+
}, homeDir);
|
|
66
|
+
}
|
|
55
67
|
/** Hook stdout response — observe only; never block submission. */
|
|
56
68
|
function hookAllowResponse() {
|
|
57
69
|
return { continue: true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/capture/handler.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/capture/handler.ts"],"names":[],"mappings":";;AA6CA,sCA8CC;AAKD,4DAaC;AAGD,8CAEC;AAlHD,2CAIyB;AACzB,8CAAiD;AACjD,uCAAwD;AAExD,qCAA6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AAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { applicationLabelForPlatform, normalizePromptPlatform, type PromptPlatform } from "@tph/shared";
|
|
2
|
+
export type { PromptPlatform };
|
|
3
|
+
export { applicationLabelForPlatform, normalizePromptPlatform };
|
|
4
|
+
/**
|
|
5
|
+
* Detect platform for Cursor's verified beforeSubmitPrompt hook.
|
|
6
|
+
* Always cursor — that hook only exists in Cursor.
|
|
7
|
+
*/
|
|
8
|
+
export declare function platformFromCursorHook(): PromptPlatform;
|
|
9
|
+
/** Parse CLI --platform / -p value. */
|
|
10
|
+
export declare function platformFromCliArg(raw: string | undefined): PromptPlatform;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizePromptPlatform = exports.applicationLabelForPlatform = void 0;
|
|
4
|
+
exports.platformFromCursorHook = platformFromCursorHook;
|
|
5
|
+
exports.platformFromCliArg = platformFromCliArg;
|
|
6
|
+
const shared_1 = require("@tph/shared");
|
|
7
|
+
Object.defineProperty(exports, "applicationLabelForPlatform", { enumerable: true, get: function () { return shared_1.applicationLabelForPlatform; } });
|
|
8
|
+
Object.defineProperty(exports, "normalizePromptPlatform", { enumerable: true, get: function () { return shared_1.normalizePromptPlatform; } });
|
|
9
|
+
/**
|
|
10
|
+
* Detect platform for Cursor's verified beforeSubmitPrompt hook.
|
|
11
|
+
* Always cursor — that hook only exists in Cursor.
|
|
12
|
+
*/
|
|
13
|
+
function platformFromCursorHook() {
|
|
14
|
+
return "cursor";
|
|
15
|
+
}
|
|
16
|
+
/** Parse CLI --platform / -p value. */
|
|
17
|
+
function platformFromCliArg(raw) {
|
|
18
|
+
if (!raw)
|
|
19
|
+
return "unknown";
|
|
20
|
+
const n = (0, shared_1.normalizePromptPlatform)(raw);
|
|
21
|
+
if (n === "unknown" && raw.trim()) {
|
|
22
|
+
// allow aliases
|
|
23
|
+
const a = raw.trim().toLowerCase();
|
|
24
|
+
if (a === "openai-codex" || a === "openai")
|
|
25
|
+
return "codex";
|
|
26
|
+
if (a === "anthropic" || a === "claude-code")
|
|
27
|
+
return "claude";
|
|
28
|
+
if (a === "open-code" || a === "oc")
|
|
29
|
+
return "opencode";
|
|
30
|
+
if (a === "agy" || a === "google-antigravity" || a === "gemini-antigravity") {
|
|
31
|
+
return "antigravity";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return n;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/capture/platform.ts"],"names":[],"mappings":";;;AAcA,wDAEC;AAGD,gDAcC;AAjCD,wCAIqB;AAIZ,4GAPP,oCAA2B,OAOO;AAAE,wGANpC,gCAAuB,OAMoC;AAE7D;;;GAGG;AACH,SAAgB,sBAAsB;IACpC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,uCAAuC;AACvC,SAAgB,kBAAkB,CAAC,GAAuB;IACxD,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,MAAM,CAAC,GAAG,IAAA,gCAAuB,EAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAClC,gBAAgB;QAChB,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC;QAC3D,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,aAAa;YAAE,OAAO,QAAQ,CAAC;QAC9D,IAAI,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,UAAU,CAAC;QACvD,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,oBAAoB,IAAI,CAAC,KAAK,oBAAoB,EAAE,CAAC;YAC5E,OAAO,aAAa,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/capture/record.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { PromptPlatform } from "@tph/shared";
|
|
1
2
|
import type { PromptRecord } from "../types/prompt";
|
|
2
|
-
export declare function createPromptRecord(prompt: string, historyName: string,
|
|
3
|
+
export declare function createPromptRecord(prompt: string, historyName: string, opts?: {
|
|
4
|
+
now?: Date;
|
|
5
|
+
promptPlatform?: PromptPlatform;
|
|
6
|
+
}): PromptRecord;
|
|
3
7
|
export declare function formatIsoWithOffset(date: Date): string;
|
|
4
8
|
export declare function formatLocalDate(date: Date): string;
|
|
5
9
|
export declare function formatLocalTime(date: Date): string;
|
package/dist/capture/record.js
CHANGED
|
@@ -7,7 +7,10 @@ exports.formatLocalTime = formatLocalTime;
|
|
|
7
7
|
exports.isEmptyPrompt = isEmptyPrompt;
|
|
8
8
|
exports.looksLikeConfigUiNoise = looksLikeConfigUiNoise;
|
|
9
9
|
const node_crypto_1 = require("node:crypto");
|
|
10
|
-
|
|
10
|
+
const platform_1 = require("./platform");
|
|
11
|
+
function createPromptRecord(prompt, historyName, opts) {
|
|
12
|
+
const now = opts?.now ?? new Date();
|
|
13
|
+
const promptPlatform = opts?.promptPlatform ?? "cursor";
|
|
11
14
|
const timestamp = formatIsoWithOffset(now);
|
|
12
15
|
const date = formatLocalDate(now);
|
|
13
16
|
const time = formatLocalTime(now);
|
|
@@ -16,9 +19,10 @@ function createPromptRecord(prompt, historyName, now = new Date()) {
|
|
|
16
19
|
date,
|
|
17
20
|
time,
|
|
18
21
|
timestamp,
|
|
19
|
-
application:
|
|
22
|
+
application: (0, platform_1.applicationLabelForPlatform)(promptPlatform),
|
|
20
23
|
historyName,
|
|
21
24
|
prompt,
|
|
25
|
+
promptPlatform,
|
|
22
26
|
};
|
|
23
27
|
}
|
|
24
28
|
function formatIsoWithOffset(date) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/capture/record.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/capture/record.ts"],"names":[],"mappings":";;AAKA,gDAoBC;AAED,kDAaC;AAED,0CAGC;AAED,0CAGC;AAED,sCAEC;AAGD,wDAIC;AA7DD,6CAAyC;AAEzC,yCAAyD;AAGzD,SAAgB,kBAAkB,CAChC,MAAc,EACd,WAAmB,EACnB,IAAsD;IAEtD,MAAM,GAAG,GAAG,IAAI,EAAE,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;IACpC,MAAM,cAAc,GAAG,IAAI,EAAE,cAAc,IAAI,QAAQ,CAAC;IACxD,MAAM,SAAS,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO;QACL,EAAE,EAAE,IAAA,wBAAU,GAAE;QAChB,IAAI;QACJ,IAAI;QACJ,SAAS;QACT,WAAW,EAAE,IAAA,sCAA2B,EAAC,cAAc,CAAC;QACxD,WAAW;QACX,MAAM;QACN,cAAc;KACf,CAAC;AACJ,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAU;IAC5C,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACvE,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ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