@rikkainc/ccp 0.2.1

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/cli/claude-pty-wrapper.d.ts +2 -0
  4. package/dist/cli/claude-pty-wrapper.js +421 -0
  5. package/dist/cli/claude-pty-wrapper.js.map +1 -0
  6. package/dist/cli/main.d.ts +2 -0
  7. package/dist/cli/main.js +4 -0
  8. package/dist/cli/main.js.map +1 -0
  9. package/dist/core/claude-paths.d.ts +7 -0
  10. package/dist/core/claude-paths.js +64 -0
  11. package/dist/core/claude-paths.js.map +1 -0
  12. package/dist/core/claude-records.d.ts +8 -0
  13. package/dist/core/claude-records.js +78 -0
  14. package/dist/core/claude-records.js.map +1 -0
  15. package/dist/core/claude-session-tail.d.ts +13 -0
  16. package/dist/core/claude-session-tail.js +88 -0
  17. package/dist/core/claude-session-tail.js.map +1 -0
  18. package/dist/core/errors.d.ts +5 -0
  19. package/dist/core/errors.js +15 -0
  20. package/dist/core/errors.js.map +1 -0
  21. package/dist/core/passthrough.d.ts +23 -0
  22. package/dist/core/passthrough.js +347 -0
  23. package/dist/core/passthrough.js.map +1 -0
  24. package/dist/core/pty-runner.d.ts +22 -0
  25. package/dist/core/pty-runner.js +40 -0
  26. package/dist/core/pty-runner.js.map +1 -0
  27. package/dist/core/stream-json.d.ts +16 -0
  28. package/dist/core/stream-json.js +149 -0
  29. package/dist/core/stream-json.js.map +1 -0
  30. package/dist/core/terminal-text.d.ts +1 -0
  31. package/dist/core/terminal-text.js +58 -0
  32. package/dist/core/terminal-text.js.map +1 -0
  33. package/dist/core/wrapper.d.ts +34 -0
  34. package/dist/core/wrapper.js +299 -0
  35. package/dist/core/wrapper.js.map +1 -0
  36. package/docs/stream-json.md +82 -0
  37. package/docs/usage.md +104 -0
  38. package/package.json +50 -0
  39. package/scripts/fix-node-pty-perms.mjs +27 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kevin
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,5 @@
1
+ # ccp
2
+
3
+ ```bash
4
+ npm install -g @rikkainc/ccp
5
+ ```
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function configureProgram(): Command;
@@ -0,0 +1,421 @@
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { Command, Option } from "commander";
5
+ import { ClaudePtyWrapperError } from "../core/errors.js";
6
+ import { runClaudeLoginOnly, runClaudePassthrough, } from "../core/passthrough.js";
7
+ import { runClaudePtyWrapper } from "../core/wrapper.js";
8
+ const DEFAULT_FRESHNESS_MESSAGE = "Please wait for further instructions.";
9
+ export function configureProgram() {
10
+ const root = new Command();
11
+ root
12
+ .name("ccp")
13
+ .description("Run interactive Claude through a PTY and stream durable session output.")
14
+ .version(packageVersion())
15
+ .argument("[prompt]", "prompt to pass to Claude")
16
+ .option("-p, --print", "run in print-compatible mode")
17
+ .addOption(new Option("--output-format <format>", "output format")
18
+ .choices(["text", "json", "stream-json"])
19
+ .default("text"))
20
+ .addOption(new Option("--input-format <format>", "input format")
21
+ .choices(["text", "stream-json"])
22
+ .default("text"))
23
+ .option("--session-jsonl", "wrapper diagnostic: emit raw appended Claude session JSONL records")
24
+ .option("-r, --resume [session-id]", "resume a Claude session")
25
+ .option("-c, --continue", "continue the most recent conversation")
26
+ .option("--session-id <uuid>", "use a specific session ID for a fresh run")
27
+ .option("--cwd <dir>", "working directory for Claude", process.cwd())
28
+ .option("--claude-bin <path>", "Claude binary", process.env.CLAUDE_BIN ?? "claude")
29
+ .addOption(new Option("--timeout <seconds>", "turn timeout in seconds")
30
+ .argParser((value) => parsePositiveSeconds(value))
31
+ .default(300))
32
+ .option("--model <model>", "forward model to Claude")
33
+ .option("--effort <level>", "forward effort level to Claude")
34
+ .option("--name <name>", "forward display name to Claude")
35
+ .option("--dangerously-skip-permissions", "forward permission bypass flag to Claude")
36
+ .option("--permission-mode <mode>", "forward permission mode to Claude")
37
+ .option("--append-system-prompt <prompt>", "forward appended system prompt to Claude")
38
+ .option("--system-prompt <prompt>", "forward system prompt to Claude")
39
+ .option("--allowedTools, --allowed-tools <tools...>", "forward allowed tools to Claude")
40
+ .option("--disallowedTools, --disallowed-tools <tools...>", "forward disallowed tools to Claude")
41
+ .option("--tools <tools...>", "forward enabled tools to Claude")
42
+ .option("--mcp-config <configs...>", "forward MCP config paths to Claude")
43
+ .option("--strict-mcp-config", "forward strict MCP config flag to Claude")
44
+ .option("--mcp-debug", "forward MCP debug flag to Claude")
45
+ .option("--debug [filter]", "forward Claude debug filter")
46
+ .option("--verbose", "forward verbose mode to Claude")
47
+ .option("--agents <json>", "forward agent definitions to Claude")
48
+ .option("--agent <agent>", "forward agent selection to Claude")
49
+ .option("--setting-sources <sources>", "forward setting sources to Claude")
50
+ .option("--settings <file-or-json>", "forward settings to Claude")
51
+ .option("--plugin-dir <path>", "forward plugin directory to Claude", collectString)
52
+ .option("--plugin-url <url>", "forward plugin URL to Claude", collectString)
53
+ .option("--file <specs...>", "forward file attachments to Claude")
54
+ .option("--add-dir <directories...>", "forward additional directories to Claude")
55
+ .option("--betas <betas...>", "forward beta headers to Claude")
56
+ .option("--fallback-model <model>", "forward fallback model to Claude")
57
+ .option("--json-schema <schema>", "forward JSON schema to Claude")
58
+ .option("--max-budget-usd <amount>", "forward maximum budget to Claude")
59
+ .option("--remote-control [name]", "forward remote-control mode to Claude")
60
+ .option("--remote-control-session-name-prefix <prefix>", "forward remote-control session prefix to Claude")
61
+ .option("--worktree [name]", "forward worktree mode to Claude")
62
+ .option("--from-pr [value]", "forward pull request context to Claude")
63
+ .option("--chrome", "forward Chrome integration flag to Claude")
64
+ .option("--no-chrome", "forward Chrome disable flag to Claude")
65
+ .option("--ide", "forward IDE integration flag to Claude")
66
+ .option("--bare", "forward bare mode to Claude")
67
+ .option("--brief", "forward brief mode to Claude")
68
+ .option("--disable-slash-commands", "forward slash-command disable flag to Claude")
69
+ .option("--fork-session", "forward fork-session flag to Claude")
70
+ .option("--tmux [mode]", "forward tmux mode to Claude")
71
+ .option("--no-session-persistence", "forward no-session-persistence flag to Claude")
72
+ .option("--replay-user-messages", "forward replay-user-messages flag to Claude")
73
+ .addOption(new Option("--freshness-interval <seconds>", "passthrough idle interval in seconds").argParser((value) => parsePositiveSeconds(value, "freshness interval")))
74
+ .option("--freshness-message <text>", "passthrough idle message", DEFAULT_FRESHNESS_MESSAGE)
75
+ .addOption(new Option("--freshness-max-iterations <count>", "maximum number of passthrough idle messages").argParser(parsePositiveInteger))
76
+ .addOption(new Option("--freshness-max-duration <seconds>", "maximum passthrough freshness duration in seconds").argParser((value) => parsePositiveSeconds(value, "freshness max duration")))
77
+ .option("--include-partial-messages", "accepted for Claude compatibility; partial events are not emitted")
78
+ .option("--include-hook-events", "forward in passthrough mode; unsupported by wrapper stream translation")
79
+ .option("--raw-pty-log <file>", "write raw PTY output to a diagnostics file")
80
+ .option("--wrapper-debug", "print wrapper diagnostics and raw PTY output to stderr")
81
+ .option("--trust-dir", "accept Claude Code's workspace trust prompt for this directory")
82
+ .option("--login-only", "refresh Claude login/session state and exit at the input prompt")
83
+ .action(async (prompt, options) => {
84
+ await run(async () => {
85
+ validateCommandOptions(root, options, prompt);
86
+ if (options.loginOnly) {
87
+ const code = await runClaudeLoginOnly({
88
+ claudeBin: options.claudeBin,
89
+ cwd: options.cwd,
90
+ args: buildLoginOnlyClaudeArgs(root, options),
91
+ timeoutMs: options.timeout * 1_000,
92
+ rawPtyLog: options.rawPtyLog,
93
+ });
94
+ process.exitCode = code;
95
+ return;
96
+ }
97
+ if (!wrapperModeRequested(root, options)) {
98
+ const code = await runClaudePassthrough({
99
+ claudeBin: options.claudeBin,
100
+ cwd: options.cwd,
101
+ args: buildPassthroughClaudeArgs(root, options, prompt),
102
+ freshness: buildFreshnessOptions(options),
103
+ });
104
+ process.exitCode = code;
105
+ return;
106
+ }
107
+ const resolvedPrompt = await resolvePrompt(prompt, options.inputFormat);
108
+ const outputMode = resolveOutputMode(root, options);
109
+ const code = await runClaudePtyWrapper({
110
+ prompt: resolvedPrompt,
111
+ outputMode,
112
+ cwd: options.cwd,
113
+ claudeBin: options.claudeBin,
114
+ timeoutMs: options.timeout * 1_000,
115
+ resumeSessionId: typeof options.resume === "string" ? options.resume : undefined,
116
+ sessionId: options.sessionId,
117
+ model: options.model,
118
+ effort: options.effort,
119
+ name: options.name,
120
+ dangerouslySkipPermissions: options.dangerouslySkipPermissions,
121
+ claudeArgs: buildSharedClaudeArgs(root, options, { includeRuntimeOutputFlags: false }),
122
+ rawPtyLog: options.rawPtyLog,
123
+ wrapperDebug: options.wrapperDebug,
124
+ trustDir: options.trustDir,
125
+ });
126
+ process.exitCode = code;
127
+ });
128
+ });
129
+ return root;
130
+ }
131
+ function validateCommandOptions(root, options, prompt) {
132
+ const outputFormatWasSet = root.getOptionValueSource("outputFormat") === "cli";
133
+ const inputFormatWasSet = root.getOptionValueSource("inputFormat") === "cli";
134
+ const wrapperMode = wrapperModeRequested(root, options);
135
+ if (!wrapperMode) {
136
+ rejectWrapperOnlyPassthroughOption(root, options);
137
+ }
138
+ else {
139
+ rejectPassthroughOnlyWrapperOptions(root);
140
+ }
141
+ validateFreshnessOptions(root, options);
142
+ if (options.loginOnly) {
143
+ validateLoginOnlyOptions(root, options, prompt);
144
+ }
145
+ if (options.continue && wrapperMode) {
146
+ throw new ClaudePtyWrapperError("--continue is not supported by the PTY wrapper; use --resume <session-id>");
147
+ }
148
+ if (options.inputFormat !== "text" && wrapperMode) {
149
+ throw new ClaudePtyWrapperError("--input-format stream-json is not supported by the PTY wrapper yet");
150
+ }
151
+ if (options.includeHookEvents && wrapperMode) {
152
+ throw new ClaudePtyWrapperError("--include-hook-events is only available from Claude runtime stream-json");
153
+ }
154
+ if (options.sessionJsonl && options.print) {
155
+ throw new ClaudePtyWrapperError("choose either --session-jsonl or --print");
156
+ }
157
+ if (options.sessionJsonl && outputFormatWasSet) {
158
+ throw new ClaudePtyWrapperError("choose either --session-jsonl or --output-format");
159
+ }
160
+ if (!options.print && outputFormatWasSet) {
161
+ throw new ClaudePtyWrapperError("--output-format requires -p/--print");
162
+ }
163
+ if (!options.print && inputFormatWasSet) {
164
+ throw new ClaudePtyWrapperError("--input-format requires -p/--print");
165
+ }
166
+ if (wrapperMode && options.resume === true) {
167
+ throw new ClaudePtyWrapperError("--resume requires a session id in wrapper mode");
168
+ }
169
+ }
170
+ function validateLoginOnlyOptions(root, options, prompt) {
171
+ if (options.print) {
172
+ throw new ClaudePtyWrapperError("--login-only cannot be used with -p/--print");
173
+ }
174
+ if (options.sessionJsonl) {
175
+ throw new ClaudePtyWrapperError("--login-only cannot be used with --session-jsonl");
176
+ }
177
+ if (root.getOptionValueSource("outputFormat") === "cli") {
178
+ throw new ClaudePtyWrapperError("--login-only cannot be used with --output-format");
179
+ }
180
+ if (root.getOptionValueSource("inputFormat") === "cli") {
181
+ throw new ClaudePtyWrapperError("--login-only cannot be used with --input-format");
182
+ }
183
+ if (prompt !== undefined) {
184
+ throw new ClaudePtyWrapperError("--login-only does not accept a prompt");
185
+ }
186
+ if (options.wrapperDebug) {
187
+ throw new ClaudePtyWrapperError("--login-only cannot be used with --wrapper-debug");
188
+ }
189
+ if (options.trustDir) {
190
+ throw new ClaudePtyWrapperError("--login-only cannot be used with --trust-dir");
191
+ }
192
+ }
193
+ function rejectPassthroughOnlyWrapperOptions(root) {
194
+ const freshnessFlags = [
195
+ "freshnessInterval",
196
+ "freshnessMessage",
197
+ "freshnessMaxIterations",
198
+ "freshnessMaxDuration",
199
+ ];
200
+ for (const flag of freshnessFlags) {
201
+ if (root.getOptionValueSource(flag) === "cli") {
202
+ throw new ClaudePtyWrapperError(`--${kebabCase(flag)} requires passthrough mode and cannot be used with wrapper output mode`);
203
+ }
204
+ }
205
+ }
206
+ function validateFreshnessOptions(root, options) {
207
+ const intervalWasSet = root.getOptionValueSource("freshnessInterval") === "cli";
208
+ if (root.getOptionValueSource("freshnessMessage") === "cli" && !intervalWasSet) {
209
+ throw new ClaudePtyWrapperError("--freshness-message requires --freshness-interval");
210
+ }
211
+ if (options.freshnessMaxIterations !== undefined && !intervalWasSet) {
212
+ throw new ClaudePtyWrapperError("--freshness-max-iterations requires --freshness-interval");
213
+ }
214
+ if (options.freshnessMaxDuration !== undefined && !intervalWasSet) {
215
+ throw new ClaudePtyWrapperError("--freshness-max-duration requires --freshness-interval");
216
+ }
217
+ if (options.freshnessMaxIterations !== undefined && options.freshnessMaxDuration !== undefined) {
218
+ throw new ClaudePtyWrapperError("choose either --freshness-max-iterations or --freshness-max-duration");
219
+ }
220
+ }
221
+ function rejectWrapperOnlyPassthroughOption(root, options) {
222
+ if (root.getOptionValueSource("timeout") === "cli") {
223
+ throw new ClaudePtyWrapperError("--timeout requires -p/--print or --session-jsonl");
224
+ }
225
+ if (options.rawPtyLog) {
226
+ throw new ClaudePtyWrapperError("--raw-pty-log requires -p/--print or --session-jsonl");
227
+ }
228
+ if (options.wrapperDebug) {
229
+ throw new ClaudePtyWrapperError("--wrapper-debug requires -p/--print or --session-jsonl");
230
+ }
231
+ if (options.trustDir) {
232
+ throw new ClaudePtyWrapperError("--trust-dir requires -p/--print or --session-jsonl");
233
+ }
234
+ }
235
+ function wrapperModeRequested(root, options) {
236
+ return (Boolean(options.print) ||
237
+ Boolean(options.sessionJsonl) ||
238
+ Boolean(options.loginOnly) ||
239
+ root.getOptionValueSource("outputFormat") === "cli" ||
240
+ root.getOptionValueSource("inputFormat") === "cli");
241
+ }
242
+ function resolveOutputMode(_root, options) {
243
+ if (options.sessionJsonl) {
244
+ return "session-jsonl";
245
+ }
246
+ return options.outputFormat;
247
+ }
248
+ function buildFreshnessOptions(options) {
249
+ if (options.freshnessInterval === undefined) {
250
+ return undefined;
251
+ }
252
+ return {
253
+ intervalMs: options.freshnessInterval * 1_000,
254
+ message: options.freshnessMessage ?? DEFAULT_FRESHNESS_MESSAGE,
255
+ maxIterations: options.freshnessMaxIterations,
256
+ maxDurationMs: options.freshnessMaxDuration === undefined ? undefined : options.freshnessMaxDuration * 1_000,
257
+ };
258
+ }
259
+ function buildPassthroughClaudeArgs(root, options, prompt) {
260
+ const args = [];
261
+ addOptionalString(args, "--resume", options.resume);
262
+ addBoolean(args, "-c", options.continue);
263
+ addString(args, "--session-id", options.sessionId);
264
+ addString(args, "--model", options.model);
265
+ addString(args, "--effort", options.effort);
266
+ addString(args, "--name", options.name);
267
+ addBoolean(args, "--dangerously-skip-permissions", options.dangerouslySkipPermissions);
268
+ args.push(...buildSharedClaudeArgs(root, options, { includeRuntimeOutputFlags: true }));
269
+ if (prompt !== undefined) {
270
+ args.push("--");
271
+ args.push(prompt);
272
+ }
273
+ return args;
274
+ }
275
+ function buildLoginOnlyClaudeArgs(root, options) {
276
+ const args = [];
277
+ addOptionalString(args, "--resume", options.resume);
278
+ addBoolean(args, "-c", options.continue);
279
+ addString(args, "--session-id", options.sessionId);
280
+ addString(args, "--model", options.model);
281
+ addString(args, "--effort", options.effort);
282
+ addString(args, "--name", options.name);
283
+ addBoolean(args, "--dangerously-skip-permissions", options.dangerouslySkipPermissions);
284
+ args.push(...buildSharedClaudeArgs(root, options, { includeRuntimeOutputFlags: true }));
285
+ return args;
286
+ }
287
+ function buildSharedClaudeArgs(root, options, settings) {
288
+ const args = [];
289
+ addString(args, "--permission-mode", options.permissionMode);
290
+ addString(args, "--append-system-prompt", options.appendSystemPrompt);
291
+ addString(args, "--system-prompt", options.systemPrompt);
292
+ addVariadic(args, "--allowed-tools", options.allowedTools);
293
+ addVariadic(args, "--disallowed-tools", options.disallowedTools);
294
+ addVariadic(args, "--tools", options.tools);
295
+ addVariadic(args, "--mcp-config", options.mcpConfig);
296
+ addBoolean(args, "--strict-mcp-config", options.strictMcpConfig);
297
+ addBoolean(args, "--mcp-debug", options.mcpDebug);
298
+ addOptionalString(args, "--debug", options.debug);
299
+ addBoolean(args, "--verbose", options.verbose);
300
+ addString(args, "--agents", options.agents);
301
+ addString(args, "--agent", options.agent);
302
+ addString(args, "--setting-sources", options.settingSources);
303
+ addString(args, "--settings", options.settings);
304
+ addRepeated(args, "--plugin-dir", options.pluginDir);
305
+ addRepeated(args, "--plugin-url", options.pluginUrl);
306
+ addVariadic(args, "--file", options.file);
307
+ addVariadic(args, "--add-dir", options.addDir);
308
+ addVariadic(args, "--betas", options.betas);
309
+ addString(args, "--fallback-model", options.fallbackModel);
310
+ addString(args, "--json-schema", options.jsonSchema);
311
+ addString(args, "--max-budget-usd", options.maxBudgetUsd);
312
+ addOptionalString(args, "--remote-control", options.remoteControl);
313
+ addString(args, "--remote-control-session-name-prefix", options.remoteControlSessionNamePrefix);
314
+ addOptionalString(args, "--worktree", options.worktree);
315
+ addOptionalString(args, "--from-pr", options.fromPr);
316
+ addBoolean(args, "--chrome", optionWasSet(root, "chrome") && options.chrome === true);
317
+ addBoolean(args, "--no-chrome", optionWasSet(root, "chrome") && options.chrome === false);
318
+ addBoolean(args, "--ide", options.ide);
319
+ addBoolean(args, "--bare", options.bare);
320
+ addBoolean(args, "--brief", options.brief);
321
+ addBoolean(args, "--disable-slash-commands", options.disableSlashCommands);
322
+ addBoolean(args, "--fork-session", options.forkSession);
323
+ addOptionalString(args, "--tmux", options.tmux);
324
+ addBoolean(args, "--no-session-persistence", optionWasSet(root, "sessionPersistence") && options.sessionPersistence === false);
325
+ addBoolean(args, "--replay-user-messages", options.replayUserMessages);
326
+ if (settings.includeRuntimeOutputFlags) {
327
+ addBoolean(args, "--include-partial-messages", options.includePartialMessages);
328
+ addBoolean(args, "--include-hook-events", options.includeHookEvents);
329
+ }
330
+ return args;
331
+ }
332
+ function optionWasSet(root, name) {
333
+ return root.getOptionValueSource(name) === "cli";
334
+ }
335
+ function addString(args, flag, value) {
336
+ if (typeof value === "string" && value.length > 0) {
337
+ args.push(flag, value);
338
+ }
339
+ }
340
+ function addOptionalString(args, flag, value) {
341
+ if (value === true) {
342
+ args.push(flag);
343
+ }
344
+ else {
345
+ addString(args, flag, value);
346
+ }
347
+ }
348
+ function addBoolean(args, flag, value) {
349
+ if (value === true) {
350
+ args.push(flag);
351
+ }
352
+ }
353
+ function addRepeated(args, flag, value) {
354
+ if (!Array.isArray(value)) {
355
+ return;
356
+ }
357
+ for (const item of value) {
358
+ addString(args, flag, item);
359
+ }
360
+ }
361
+ function addVariadic(args, flag, value) {
362
+ if (!Array.isArray(value) || value.length === 0) {
363
+ return;
364
+ }
365
+ args.push(flag, ...value.map(String));
366
+ }
367
+ function collectString(value, previous) {
368
+ return [...(previous ?? []), value];
369
+ }
370
+ async function resolvePrompt(prompt, inputFormat) {
371
+ if (inputFormat !== "text") {
372
+ throw new ClaudePtyWrapperError("--input-format stream-json is not supported by the PTY wrapper yet");
373
+ }
374
+ if (prompt !== undefined) {
375
+ return prompt;
376
+ }
377
+ if (process.stdin.isTTY) {
378
+ return "";
379
+ }
380
+ const chunks = [];
381
+ for await (const chunk of process.stdin) {
382
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
383
+ }
384
+ return Buffer.concat(chunks).toString("utf8");
385
+ }
386
+ function parsePositiveSeconds(value, label = "timeout") {
387
+ const seconds = Number(value);
388
+ if (!Number.isFinite(seconds) || seconds <= 0) {
389
+ throw new Error(`${label} must be a positive number of seconds`);
390
+ }
391
+ return seconds;
392
+ }
393
+ function parsePositiveInteger(value) {
394
+ const count = Number(value);
395
+ if (!Number.isInteger(count) || count <= 0) {
396
+ throw new Error("freshness max iterations must be a positive integer");
397
+ }
398
+ return count;
399
+ }
400
+ function kebabCase(value) {
401
+ return value.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`);
402
+ }
403
+ async function run(fn) {
404
+ try {
405
+ await fn();
406
+ }
407
+ catch (error) {
408
+ if (error instanceof ClaudePtyWrapperError) {
409
+ console.error(`ccp: ${error.message}`);
410
+ process.exitCode = error.exitCode;
411
+ return;
412
+ }
413
+ throw error;
414
+ }
415
+ }
416
+ function packageVersion() {
417
+ const packagePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../package.json");
418
+ const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
419
+ return pkg.version ?? "0.0.0";
420
+ }
421
+ //# sourceMappingURL=claude-pty-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-pty-wrapper.js","sourceRoot":"","sources":["../../src/cli/claude-pty-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAEL,kB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Program } from "./claude-pty-wrapper.js";
3
+ configureProgram().parseAsync(process.argv);
4
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,gBAAgB,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function encodeClaudeProjectDir(cwd: string): string;
2
+ export declare function claudeProjectDir(cwd: string): string;
3
+ export declare function validateClaudeSessionId(sessionId: string): void;
4
+ export declare function claudeSessionFilePath(cwd: string, sessionId: string): string;
5
+ export declare function fileSizeIfExists(path: string): number;
6
+ export declare function assertExistingSessionFileUnderProjectDir(cwd: string, sessionPath: string): void;
7
+ export declare function realFileIsUnderRoot(root: string, filePath: string): boolean;
@@ -0,0 +1,64 @@
1
+ import { existsSync, realpathSync, statSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { isAbsolute, join, relative, resolve } from "node:path";
4
+ import { ClaudePtyWrapperError } from "./errors.js";
5
+ const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6
+ export function encodeClaudeProjectDir(cwd) {
7
+ return cwd.replace(/[^A-Za-z0-9-]/g, "-");
8
+ }
9
+ export function claudeProjectDir(cwd) {
10
+ return join(homedir(), ".claude", "projects", encodeClaudeProjectDir(realpathSync(resolve(cwd))));
11
+ }
12
+ export function validateClaudeSessionId(sessionId) {
13
+ if (sessionId.includes("/") || sessionId.includes("\\") || sessionId.includes("..")) {
14
+ throw new ClaudePtyWrapperError("claude session id must be a session id, not a path");
15
+ }
16
+ if (!uuidPattern.test(sessionId)) {
17
+ throw new ClaudePtyWrapperError("claude session id must be a valid UUID");
18
+ }
19
+ }
20
+ export function claudeSessionFilePath(cwd, sessionId) {
21
+ validateClaudeSessionId(sessionId);
22
+ const projectDir = claudeProjectDir(cwd);
23
+ const sessionPath = resolve(projectDir, `${sessionId}.jsonl`);
24
+ const relativePath = relative(projectDir, sessionPath);
25
+ if (relativePath === "" || relativePath.startsWith("..") || isAbsolute(relativePath)) {
26
+ throw new ClaudePtyWrapperError("claude session id must resolve inside the cwd-bound project directory");
27
+ }
28
+ return sessionPath;
29
+ }
30
+ export function fileSizeIfExists(path) {
31
+ try {
32
+ return statSync(path).size;
33
+ }
34
+ catch (error) {
35
+ if (isNodeError(error) && error.code === "ENOENT") {
36
+ return 0;
37
+ }
38
+ throw error;
39
+ }
40
+ }
41
+ export function assertExistingSessionFileUnderProjectDir(cwd, sessionPath) {
42
+ const projectDir = claudeProjectDir(cwd);
43
+ if (!existsSync(sessionPath)) {
44
+ throw new ClaudePtyWrapperError(`claude session file not found: ${sessionPath}`);
45
+ }
46
+ if (!realFileIsUnderRoot(projectDir, sessionPath)) {
47
+ throw new ClaudePtyWrapperError("claude session file escaped the project directory");
48
+ }
49
+ }
50
+ export function realFileIsUnderRoot(root, filePath) {
51
+ try {
52
+ const realRoot = realpathSync(root);
53
+ const realPath = realpathSync(filePath);
54
+ const relativePath = relative(realRoot, realPath);
55
+ return relativePath !== "" && !relativePath.startsWith("..") && !isAbsolute(relativePath);
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ }
61
+ function isNodeError(error) {
62
+ return typeof error === "object" && error !== null && "code" in error;
63
+ }
64
+ //# sourceMappingURL=claude-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-paths.js","sourceRoot":"","sources":["../../src/core/claude-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM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AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,CAAC;AACxE,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
2
+ export declare function claudeContentBlocks(content: unknown): Record<string, unknown>[];
3
+ export declare function extractClaudeText(content: unknown): string;
4
+ export declare function isAllToolResultContent(content: unknown): boolean;
5
+ export declare function realClaudeUserText(record: Record<string, unknown>): string | null;
6
+ export declare function claudeAssistantRecordText(record: Record<string, unknown>): string | null;
7
+ export declare function isClaudeTurnTerminalRecord(record: Record<string, unknown>): boolean;
8
+ export declare function streamBoundarySeparator(prior: string, delta: string): string;