pathmark 0.1.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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/SECURITY.md +39 -0
  4. package/assets/pathmark-icon-v3-glyph.png +0 -0
  5. package/dist/chat.d.ts +6 -0
  6. package/dist/chat.js +169 -0
  7. package/dist/chat.js.map +1 -0
  8. package/dist/codex/capture.d.ts +12 -0
  9. package/dist/codex/capture.js +328 -0
  10. package/dist/codex/capture.js.map +1 -0
  11. package/dist/codex/cli.d.ts +1 -0
  12. package/dist/codex/cli.js +96 -0
  13. package/dist/codex/cli.js.map +1 -0
  14. package/dist/codex/config-file.d.ts +9 -0
  15. package/dist/codex/config-file.js +100 -0
  16. package/dist/codex/config-file.js.map +1 -0
  17. package/dist/codex/cursor.d.ts +11 -0
  18. package/dist/codex/cursor.js +35 -0
  19. package/dist/codex/cursor.js.map +1 -0
  20. package/dist/codex/hooks.d.ts +10 -0
  21. package/dist/codex/hooks.js +108 -0
  22. package/dist/codex/hooks.js.map +1 -0
  23. package/dist/codex/paths.d.ts +5 -0
  24. package/dist/codex/paths.js +29 -0
  25. package/dist/codex/paths.js.map +1 -0
  26. package/dist/codex/tool-summary.d.ts +5 -0
  27. package/dist/codex/tool-summary.js +223 -0
  28. package/dist/codex/tool-summary.js.map +1 -0
  29. package/dist/codex/transcript.d.ts +9 -0
  30. package/dist/codex/transcript.js +99 -0
  31. package/dist/codex/transcript.js.map +1 -0
  32. package/dist/config.d.ts +2 -0
  33. package/dist/config.js +40 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/format.d.ts +10 -0
  36. package/dist/format.js +48 -0
  37. package/dist/format.js.map +1 -0
  38. package/dist/ids.d.ts +1 -0
  39. package/dist/ids.js +6 -0
  40. package/dist/ids.js.map +1 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js +27 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/mcp.d.ts +1 -0
  45. package/dist/mcp.js +130 -0
  46. package/dist/mcp.js.map +1 -0
  47. package/dist/redact.d.ts +5 -0
  48. package/dist/redact.js +36 -0
  49. package/dist/redact.js.map +1 -0
  50. package/dist/setup.d.ts +1 -0
  51. package/dist/setup.js +208 -0
  52. package/dist/setup.js.map +1 -0
  53. package/dist/store.d.ts +27 -0
  54. package/dist/store.js +174 -0
  55. package/dist/store.js.map +1 -0
  56. package/dist/types.d.ts +38 -0
  57. package/dist/types.js +2 -0
  58. package/dist/types.js.map +1 -0
  59. package/examples/claude_code.md +21 -0
  60. package/examples/claude_desktop_config.json +10 -0
  61. package/examples/codex.md +39 -0
  62. package/examples/cursor_mcp_config.json +10 -0
  63. package/examples/gemini_settings.json +12 -0
  64. package/examples/generic_mcp_config.json +12 -0
  65. package/examples/openai_compatible.env +8 -0
  66. package/examples/opencode.jsonc +13 -0
  67. package/package.json +66 -0
  68. package/scripts/import-honcho.mjs +243 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pathmark Memory contributors
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,339 @@
1
+ # Pathmark Memory
2
+
3
+ <p align="center">
4
+ <img src="assets/pathmark-icon-v3-glyph.png" alt="Pathmark" width="160">
5
+ </p>
6
+
7
+ One memory for every coding agent on your machine.
8
+
9
+ Use Codex for a fix, Claude Code for review, opencode for cleanup, and Gemini CLI for a second pass. Pathmark gives each harness the same local context. Decisions, preferences, project notes, and conclusions land in one JSONL store. The next agent can pick them up without a recap.
10
+
11
+ ## Why Pathmark
12
+
13
+ AI coding agents trap useful context inside their own sessions. You switch tools and spend the first prompt rebuilding history.
14
+
15
+ Pathmark moves that context into a local MCP server:
16
+
17
+ - Local JSONL store by default.
18
+ - Standard MCP tools instead of a proprietary client.
19
+ - Cross-harness memory: every MCP-capable coding agent can read/write the same context.
20
+ - Works when the model lives in the MCP client.
21
+ - Optional subscription CLI bridge for server-side synthesis.
22
+ - Optional OpenAI-compatible API bridge for Kimi, GLM, OpenRouter, local gateways, and other compatible providers.
23
+ - Easy to inspect, back up, delete, or migrate.
24
+
25
+ Pathmark stays provider-neutral. Codex gets one optional synthesis preset. The core server works with any MCP client that can use local tools.
26
+
27
+ ## Cross-Harness Memory
28
+
29
+ Codex remembers one set of things. Claude Code learns another. opencode starts cold. Pathmark gives them one shared trail.
30
+
31
+ Point each harness at the same store:
32
+
33
+ ```text
34
+ Codex \
35
+ Claude Code \
36
+ opencode > Pathmark MCP > ~/.pathmark/memory/memory.jsonl
37
+ Gemini CLI /
38
+ Cursor /
39
+ ```
40
+
41
+ Install Pathmark in each harness and point all of them at the same `PATHMARK_STORE_DIR`. Any tool can save context with `remember` or `create_conclusion`; any other tool can later recover it with `search_memory`, `get_context`, or `ask_memory`.
42
+
43
+ Pathmark sits below the agents as a memory bus for your coding workflow.
44
+
45
+ ## Tools
46
+
47
+ Pathmark exposes these MCP tools:
48
+
49
+ | Tool | Purpose |
50
+ | --- | --- |
51
+ | `remember` | Save a raw memory item. |
52
+ | `create_conclusion` | Save a higher-signal durable conclusion or preference. |
53
+ | `search_memory` | Search memories and conclusions. |
54
+ | `get_context` | Return compact context for a task or question. |
55
+ | `list_conclusions` | List saved conclusions. |
56
+ | `delete_memory` | Soft-delete a memory or conclusion by id. |
57
+ | `ask_memory` | Return relevant context, or synthesize with `PATHMARK_CHAT_COMMAND` if configured. |
58
+ | `chat` | Chat-compatible alias for `ask_memory`; returns the retrieved context so the client can show what was used. |
59
+ | `get_config` | Show local store configuration. |
60
+
61
+ ## Quick Start
62
+
63
+ ```bash
64
+ npm install -g pathmark
65
+ ```
66
+
67
+ Then add the MCP server to your client.
68
+
69
+ Prefer npm for normal installs. To test the current GitHub `main` branch directly:
70
+
71
+ ```bash
72
+ npm install -g --install-links=true github:hacksurvivor/pathmark
73
+ ```
74
+
75
+ Generate a setup snippet for your harness:
76
+
77
+ ```bash
78
+ pathmark setup list
79
+ pathmark setup claude-code
80
+ pathmark setup opencode --json
81
+ pathmark setup gemini-cli
82
+ pathmark setup kimi
83
+ ```
84
+
85
+ See [docs/compatibility.md](docs/compatibility.md) for Codex, Claude Code, opencode, Gemini CLI, OpenClaw, Hermes Agent, Grok CLI, Kimi, GLM, and generic MCP setups.
86
+
87
+ ### Codex
88
+
89
+ ```bash
90
+ codex mcp add pathmark -- pathmark
91
+ ```
92
+
93
+ Codex users can also enable auto-capture:
94
+
95
+ ```bash
96
+ pathmark codex install --replace-honcho
97
+ ```
98
+
99
+ ### Claude Code
100
+
101
+ ```bash
102
+ claude mcp add pathmark -- pathmark
103
+ ```
104
+
105
+ ### opencode / Gemini CLI
106
+
107
+ Use the generated snippets:
108
+
109
+ ```bash
110
+ pathmark setup opencode
111
+ pathmark setup gemini-cli
112
+ ```
113
+
114
+ ### Claude Desktop
115
+
116
+ Add this to your Claude Desktop MCP config:
117
+
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "pathmark": {
122
+ "command": "pathmark",
123
+ "env": {
124
+ "PATHMARK_STORE_DIR": "~/.pathmark/memory"
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Cursor
132
+
133
+ Add the same command to Cursor's MCP server settings:
134
+
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "pathmark": {
139
+ "command": "pathmark"
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ ## Local Development
146
+
147
+ ```bash
148
+ npm install
149
+ npm run build
150
+ npm run smoke
151
+ ```
152
+
153
+ Run directly:
154
+
155
+ ```bash
156
+ PATHMARK_STORE_DIR=.pathmark npm run dev
157
+ ```
158
+
159
+ ## Migrate From Honcho
160
+
161
+ Pathmark can import local `codex-honcho` JSONL memory without deleting or moving the Honcho store.
162
+
163
+ ```bash
164
+ npm run import:honcho
165
+ ```
166
+
167
+ Defaults:
168
+
169
+ ```text
170
+ Honcho source: ~/.honcho/codex/local
171
+ Pathmark target: ~/.pathmark/memory/memory.jsonl
172
+ ```
173
+
174
+ The importer creates a `memory.jsonl.backup-*` file before writing, uses deterministic ids so reruns skip duplicates, and redacts obvious `KEY=...`, `TOKEN=...`, `PASSWORD=...`, and `Bearer ...` values.
175
+
176
+ Use a dry run first when migrating another machine:
177
+
178
+ ```bash
179
+ npm run import:honcho -- --dry-run
180
+ ```
181
+
182
+ ## Codex Auto-Capture
183
+
184
+ Install Pathmark as the Codex memory adapter:
185
+
186
+ ```bash
187
+ pathmark codex install --replace-honcho
188
+ ```
189
+
190
+ This registers the Pathmark MCP server, enables Codex hooks, and removes old Honcho hook commands from Codex. It does not delete or move Honcho memory; data at `~/.honcho/codex/local` is preserved.
191
+
192
+ Use `--replace-honcho` when you want Pathmark hooks to take over from `codex-honcho`. Without it, Pathmark installs alongside any existing Honcho hook commands.
193
+
194
+ Check the adapter status:
195
+
196
+ ```bash
197
+ pathmark codex status
198
+ ```
199
+
200
+ The status output is JSON and includes Pathmark hook state, MCP registration state, Honcho hook presence, the active store paths, and the current record count.
201
+
202
+ Remove Pathmark hooks and MCP registration without deleting memory:
203
+
204
+ ```bash
205
+ pathmark codex uninstall
206
+ ```
207
+
208
+ ## Configuration
209
+
210
+ | Variable | Default | Description |
211
+ | --- | --- | --- |
212
+ | `PATHMARK_STORE_DIR` | `~/.pathmark/memory` | Directory for `memory.jsonl`. |
213
+ | `PATHMARK_MAX_SEARCH_RESULTS` | `12` | Default search limit. |
214
+ | `PATHMARK_SYNTHESIS_PROVIDER` | `client` | `client`, `command`, `codex`, or `openai-compatible`. |
215
+ | `PATHMARK_CHAT_COMMAND` | unset | Command provider: receives a synthesized prompt on stdin and writes an answer on stdout. |
216
+ | `PATHMARK_CODEX_COMMAND` | `codex` | Codex provider command. |
217
+ | `PATHMARK_CODEX_MODEL` | unset | Optional Codex model override. |
218
+ | `PATHMARK_OPENAI_BASE_URL` | `https://api.openai.com/v1` | OpenAI-compatible API base URL. |
219
+ | `PATHMARK_OPENAI_API_KEY` | unset | OpenAI-compatible API key. |
220
+ | `PATHMARK_OPENAI_MODEL` | unset | Model id for OpenAI-compatible synthesis. |
221
+ | `PATHMARK_CHAT_TIMEOUT_MS` | `120000` | Synthesis command timeout. |
222
+
223
+ ## Synthesis Modes
224
+
225
+ Pathmark separates memory from reasoning.
226
+
227
+ ### `client`
228
+
229
+ Default. The MCP server returns relevant memory context, and your MCP client model synthesizes the answer. This works across Codex, Claude Desktop, Cursor, and any other MCP client without giving Pathmark a model credential.
230
+
231
+ ```bash
232
+ PATHMARK_SYNTHESIS_PROVIDER=client pathmark
233
+ ```
234
+
235
+ ### `command`
236
+
237
+ Use any local subscription or model CLI that accepts a prompt on stdin and writes an answer to stdout:
238
+
239
+ ```bash
240
+ PATHMARK_SYNTHESIS_PROVIDER=command \
241
+ PATHMARK_CHAT_COMMAND="your-ai-cli --model your-model" \
242
+ pathmark
243
+ ```
244
+
245
+ This is the general path for users with another paid subscription CLI or a local model runner.
246
+
247
+ ### `codex`
248
+
249
+ Use the proven Codex CLI bridge. It runs a controlled, non-interactive `codex exec` turn with hooks and memories disabled to avoid recursion:
250
+
251
+ ```bash
252
+ PATHMARK_SYNTHESIS_PROVIDER=codex \
253
+ PATHMARK_CODEX_MODEL=gpt-5.5 \
254
+ pathmark
255
+ ```
256
+
257
+ This is useful for Codex users who have ChatGPT/Codex subscription auth locally but do not want to add an OpenAI API key.
258
+
259
+ ### `openai-compatible`
260
+
261
+ Use any provider that exposes `/chat/completions`, including many Kimi, GLM/Z.ai, OpenRouter, LiteLLM, Ollama-compatible gateways, and self-hosted routers:
262
+
263
+ ```bash
264
+ PATHMARK_SYNTHESIS_PROVIDER=openai-compatible \
265
+ PATHMARK_OPENAI_BASE_URL=https://api.provider.example/v1 \
266
+ PATHMARK_OPENAI_API_KEY=... \
267
+ PATHMARK_OPENAI_MODEL=... \
268
+ pathmark
269
+ ```
270
+
271
+ This mode only affects `ask_memory`. Regular MCP tools still store and retrieve local memory without a model provider.
272
+
273
+ ## Setup CLI
274
+
275
+ `pathmark setup <client>` prints copy-paste setup for common harnesses. Add `--json` when you want structured output for scripts.
276
+
277
+ Supported targets:
278
+
279
+ ```text
280
+ codex
281
+ claude-code
282
+ claude-desktop
283
+ cursor
284
+ opencode
285
+ gemini-cli
286
+ generic
287
+ openai-compatible
288
+ command
289
+ ```
290
+
291
+ Aliases include `claude`, `gemini`, `kimi`, `glm`, and `z-ai`.
292
+
293
+ ## Data Format
294
+
295
+ Pathmark stores newline-delimited JSON at:
296
+
297
+ ```text
298
+ ~/.pathmark/memory/memory.jsonl
299
+ ```
300
+
301
+ Each record is inspectable:
302
+
303
+ ```json
304
+ {
305
+ "id": "uuid",
306
+ "kind": "memory",
307
+ "text": "The user prefers local-first tools.",
308
+ "tags": ["preference"],
309
+ "source": "mcp",
310
+ "createdAt": "2026-06-29T00:00:00.000Z",
311
+ "updatedAt": "2026-06-29T00:00:00.000Z"
312
+ }
313
+ ```
314
+
315
+ Deletes are soft deletes: the record gets a `deletedAt` timestamp.
316
+
317
+ ## Roadmap
318
+
319
+ - Harness installers for Codex, Claude Code, opencode, Gemini CLI, and other MCP clients.
320
+ - Optional auto-capture hooks/importers per harness, so useful context can be saved with less prompting.
321
+ - Provider presets for common local AI CLIs where stable commands exist.
322
+ - Import/export commands for other memory systems.
323
+ - Better ranking with optional local embeddings.
324
+ - Namespaces for projects, teams, and clients.
325
+ - Encrypted store option.
326
+ - Hosted sync as an opt-in layer, not a requirement.
327
+ - Example recipes for Codex, Claude Desktop, Cursor, ChatGPT, and local LLM tools.
328
+
329
+ ## Positioning
330
+
331
+ Pathmark gives your agents a shared working memory that stays on your machine.
332
+
333
+ > Switch agents. Keep the context.
334
+
335
+ > Bring your own subscription. Keep your memory local.
336
+
337
+ ## License
338
+
339
+ MIT
package/SECURITY.md ADDED
@@ -0,0 +1,39 @@
1
+ # Security Policy
2
+
3
+ Pathmark is local-first memory infrastructure. The default store is a JSONL file on your machine:
4
+
5
+ ```text
6
+ ~/.pathmark/memory/memory.jsonl
7
+ ```
8
+
9
+ ## Supported Version
10
+
11
+ Pathmark is currently pre-1.0. Security fixes are handled on `main` and released through GitHub installs.
12
+
13
+ ## Data Model
14
+
15
+ - Core memory tools do not require an API key or hosted account.
16
+ - The default synthesis mode is `client`; the MCP client model reads retrieved memory context.
17
+ - `openai-compatible`, `command`, and `codex` synthesis modes are opt-in.
18
+ - Deletes are soft deletes inside the JSONL store.
19
+ - Codex auto-capture redacts common secret-shaped values before storage, but users should still avoid pasting credentials into prompts.
20
+
21
+ ## Sensitive Data Guidance
22
+
23
+ - Treat `~/.pathmark/memory/memory.jsonl` as private working data.
24
+ - Back it up and sync it only through systems you trust.
25
+ - Review records before sharing logs, bug reports, or screenshots.
26
+ - Use `delete_memory` for targeted removal; manually inspect the JSONL file for high-risk cleanup.
27
+
28
+ ## Reporting a Vulnerability
29
+
30
+ Please report security issues privately by opening a GitHub security advisory for this repository when available, or by contacting the maintainer directly through the GitHub profile.
31
+
32
+ Include:
33
+
34
+ - Affected version or commit.
35
+ - Reproduction steps.
36
+ - Whether local memory, hook config, command execution, or remote synthesis is involved.
37
+ - Any suspected exposure path, without including real secrets.
38
+
39
+ Please do not post working exploits or sensitive memory contents in public issues.
package/dist/chat.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { PathmarkConfig, SearchResult } from "./types.js";
2
+ export declare function synthesizeWithCommand(input: {
3
+ config: PathmarkConfig;
4
+ question: string;
5
+ context: SearchResult[];
6
+ }): Promise<string | undefined>;
package/dist/chat.js ADDED
@@ -0,0 +1,169 @@
1
+ import { spawn } from "node:child_process";
2
+ export async function synthesizeWithCommand(input) {
3
+ if (input.config.synthesisProvider === "client")
4
+ return undefined;
5
+ const prompt = [
6
+ "Answer the question using the local memory context below.",
7
+ "If the context is insufficient, say what is missing.",
8
+ "",
9
+ `Question: ${input.question}`,
10
+ "",
11
+ "Memory context:",
12
+ ...input.context.map((result, index) => {
13
+ const record = result.record;
14
+ return [
15
+ `#${index + 1} ${record.kind} ${record.id}`,
16
+ `createdAt: ${record.createdAt}`,
17
+ `tags: ${record.tags.join(", ") || "none"}`,
18
+ record.text,
19
+ ].join("\n");
20
+ }),
21
+ ].join("\n");
22
+ if (input.config.synthesisProvider === "codex") {
23
+ return runCodex(input.config, prompt);
24
+ }
25
+ if (input.config.synthesisProvider === "openai-compatible") {
26
+ return runOpenAiCompatible(input.config, input.question, prompt);
27
+ }
28
+ if (!input.config.chatCommand)
29
+ return undefined;
30
+ return runShellCommand(input.config.chatCommand, prompt, input.config.chatTimeoutMs);
31
+ }
32
+ function runCodex(config, prompt) {
33
+ const args = [
34
+ "--ask-for-approval",
35
+ "never",
36
+ "--disable",
37
+ "hooks",
38
+ "--disable",
39
+ "memories",
40
+ "exec",
41
+ "--json",
42
+ "--ephemeral",
43
+ "--skip-git-repo-check",
44
+ "--ignore-user-config",
45
+ "--sandbox",
46
+ "read-only",
47
+ ];
48
+ if (config.codexModel)
49
+ args.push("--model", config.codexModel);
50
+ args.push(prompt);
51
+ return runCommand(config.codexCommand, args, "", config.chatTimeoutMs, parseCodexJsonAnswer);
52
+ }
53
+ async function runOpenAiCompatible(config, question, prompt) {
54
+ if (!config.openaiApiKey)
55
+ throw new Error("PATHMARK_OPENAI_API_KEY is required for openai-compatible synthesis");
56
+ if (!config.openaiModel)
57
+ throw new Error("PATHMARK_OPENAI_MODEL is required for openai-compatible synthesis");
58
+ const baseUrl = config.openaiBaseUrl.replace(/\/+$/, "");
59
+ const response = await fetch(`${baseUrl}/chat/completions`, {
60
+ method: "POST",
61
+ headers: {
62
+ Authorization: `Bearer ${config.openaiApiKey}`,
63
+ "Content-Type": "application/json",
64
+ },
65
+ body: JSON.stringify({
66
+ model: config.openaiModel,
67
+ messages: [
68
+ {
69
+ role: "system",
70
+ content: "Answer using only the provided local Pathmark memory context. If the context is insufficient, say what is missing.",
71
+ },
72
+ {
73
+ role: "user",
74
+ content: `Question:\n${question}\n\n${prompt}`,
75
+ },
76
+ ],
77
+ }),
78
+ signal: AbortSignal.timeout(config.chatTimeoutMs),
79
+ });
80
+ if (!response.ok) {
81
+ const body = await response.text().catch(() => "");
82
+ throw new Error(`OpenAI-compatible synthesis failed (${response.status}): ${body.slice(0, 500)}`);
83
+ }
84
+ const data = (await response.json());
85
+ const content = data.choices?.[0]?.message?.content;
86
+ if (typeof content === "string")
87
+ return content.trim();
88
+ if (Array.isArray(content))
89
+ return content.map((part) => part.text ?? "").join("").trim();
90
+ return "";
91
+ }
92
+ function parseCodexJsonAnswer(stdout) {
93
+ let answer = "";
94
+ for (const line of stdout.split(/\r?\n/)) {
95
+ const trimmed = line.trim();
96
+ if (!trimmed.startsWith("{"))
97
+ continue;
98
+ try {
99
+ const event = JSON.parse(trimmed);
100
+ if (event.type === "item.completed" && event.item?.type === "agent_message" && event.item.text) {
101
+ answer = event.item.text;
102
+ }
103
+ }
104
+ catch {
105
+ // Keep parsing robust against non-JSON warnings or future event types.
106
+ }
107
+ }
108
+ return answer.trim();
109
+ }
110
+ function runCommand(command, args, stdin, timeoutMs, parse = (stdout) => stdout.trim()) {
111
+ return new Promise((resolve, reject) => {
112
+ const child = spawn(command, args, {
113
+ stdio: ["pipe", "pipe", "pipe"],
114
+ env: process.env,
115
+ });
116
+ const timer = setTimeout(() => {
117
+ child.kill("SIGTERM");
118
+ reject(new Error(`Synthesis command timed out after ${timeoutMs}ms`));
119
+ }, timeoutMs);
120
+ const stdout = [];
121
+ const stderr = [];
122
+ child.stdout.on("data", (chunk) => stdout.push(chunk));
123
+ child.stderr.on("data", (chunk) => stderr.push(chunk));
124
+ child.on("error", (error) => {
125
+ clearTimeout(timer);
126
+ reject(error);
127
+ });
128
+ child.on("close", (code) => {
129
+ clearTimeout(timer);
130
+ if (code === 0) {
131
+ resolve(parse(Buffer.concat(stdout).toString("utf8")));
132
+ return;
133
+ }
134
+ reject(new Error(`PATHMARK_CHAT_COMMAND exited with code ${code}: ${Buffer.concat(stderr).toString("utf8").trim()}`));
135
+ });
136
+ child.stdin.end(stdin);
137
+ });
138
+ }
139
+ function runShellCommand(command, stdin, timeoutMs) {
140
+ return new Promise((resolve, reject) => {
141
+ const child = spawn(command, {
142
+ stdio: ["pipe", "pipe", "pipe"],
143
+ env: process.env,
144
+ shell: true,
145
+ });
146
+ const timer = setTimeout(() => {
147
+ child.kill("SIGTERM");
148
+ reject(new Error(`Synthesis command timed out after ${timeoutMs}ms`));
149
+ }, timeoutMs);
150
+ const stdout = [];
151
+ const stderr = [];
152
+ child.stdout.on("data", (chunk) => stdout.push(chunk));
153
+ child.stderr.on("data", (chunk) => stderr.push(chunk));
154
+ child.on("error", (error) => {
155
+ clearTimeout(timer);
156
+ reject(error);
157
+ });
158
+ child.on("close", (code) => {
159
+ clearTimeout(timer);
160
+ if (code === 0) {
161
+ resolve(Buffer.concat(stdout).toString("utf8").trim());
162
+ return;
163
+ }
164
+ reject(new Error(`PATHMARK_CHAT_COMMAND exited with code ${code}: ${Buffer.concat(stderr).toString("utf8").trim()}`));
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,EAAE,EAAE,CACnG,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface CodexHookInput {
2
+ cwd?: string;
3
+ session_id?: string;
4
+ prompt?: string;
5
+ transcript_path?: string;
6
+ tool_name?: string;
7
+ tool_input?: unknown;
8
+ }
9
+ export declare function recall(input: CodexHookInput): Promise<string>;
10
+ export declare function prompt(input: CodexHookInput): Promise<string>;
11
+ export declare function observe(input: CodexHookInput): Promise<string>;
12
+ export declare function writeback(input: CodexHookInput): Promise<string>;