claude-code-infinite 1.0.31 → 1.0.33

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 (79) hide show
  1. package/README.md +71 -56
  2. package/dist/claude-auth-status.d.ts +50 -0
  3. package/dist/claude-auth-status.d.ts.map +1 -0
  4. package/dist/claude-auth-status.js +213 -0
  5. package/dist/claude-auth-status.js.map +1 -0
  6. package/dist/claude-auth.d.ts +2 -1
  7. package/dist/claude-auth.d.ts.map +1 -1
  8. package/dist/claude-auth.js +2 -1
  9. package/dist/claude-auth.js.map +1 -1
  10. package/dist/claude-plan-warning.d.ts +13 -40
  11. package/dist/claude-plan-warning.d.ts.map +1 -1
  12. package/dist/claude-plan-warning.js +24 -75
  13. package/dist/claude-plan-warning.js.map +1 -1
  14. package/dist/cli-args.d.ts +7 -0
  15. package/dist/cli-args.d.ts.map +1 -1
  16. package/dist/cli-args.js +19 -0
  17. package/dist/cli-args.js.map +1 -1
  18. package/dist/cli-main.js +117 -17
  19. package/dist/cli-main.js.map +1 -1
  20. package/dist/count-tokens.d.ts +7 -3
  21. package/dist/count-tokens.d.ts.map +1 -1
  22. package/dist/count-tokens.js +6 -2
  23. package/dist/count-tokens.js.map +1 -1
  24. package/dist/diagnostics-schema.d.ts +5 -2
  25. package/dist/diagnostics-schema.d.ts.map +1 -1
  26. package/dist/diagnostics-schema.js +26 -6
  27. package/dist/diagnostics-schema.js.map +1 -1
  28. package/dist/diagnostics.d.ts +5 -1
  29. package/dist/diagnostics.d.ts.map +1 -1
  30. package/dist/diagnostics.js +7 -2
  31. package/dist/diagnostics.js.map +1 -1
  32. package/dist/hooks.d.ts +18 -1
  33. package/dist/hooks.d.ts.map +1 -1
  34. package/dist/hooks.js +57 -4
  35. package/dist/hooks.js.map +1 -1
  36. package/dist/memtree-mcp.d.ts +7 -0
  37. package/dist/memtree-mcp.d.ts.map +1 -1
  38. package/dist/memtree-mcp.js +12 -1
  39. package/dist/memtree-mcp.js.map +1 -1
  40. package/dist/memtree.d.ts +86 -3
  41. package/dist/memtree.d.ts.map +1 -1
  42. package/dist/memtree.js +305 -18
  43. package/dist/memtree.js.map +1 -1
  44. package/dist/notices.d.ts +2 -0
  45. package/dist/notices.d.ts.map +1 -1
  46. package/dist/notices.js +2 -0
  47. package/dist/notices.js.map +1 -1
  48. package/dist/open-url.d.ts +49 -0
  49. package/dist/open-url.d.ts.map +1 -0
  50. package/dist/open-url.js +100 -0
  51. package/dist/open-url.js.map +1 -0
  52. package/dist/proxy.d.ts +77 -1
  53. package/dist/proxy.d.ts.map +1 -1
  54. package/dist/proxy.js +618 -77
  55. package/dist/proxy.js.map +1 -1
  56. package/dist/reqlog.d.ts +21 -2
  57. package/dist/reqlog.d.ts.map +1 -1
  58. package/dist/reqlog.js.map +1 -1
  59. package/dist/request-sizing.d.ts +2 -0
  60. package/dist/request-sizing.d.ts.map +1 -1
  61. package/dist/request-sizing.js +5 -0
  62. package/dist/request-sizing.js.map +1 -1
  63. package/dist/resume-guidance.d.ts +102 -0
  64. package/dist/resume-guidance.d.ts.map +1 -0
  65. package/dist/resume-guidance.js +182 -0
  66. package/dist/resume-guidance.js.map +1 -0
  67. package/dist/route-fallback.d.ts +23 -0
  68. package/dist/route-fallback.d.ts.map +1 -1
  69. package/dist/route-fallback.js +44 -0
  70. package/dist/route-fallback.js.map +1 -1
  71. package/dist/sign-in-notice.d.ts +137 -0
  72. package/dist/sign-in-notice.d.ts.map +1 -0
  73. package/dist/sign-in-notice.js +300 -0
  74. package/dist/sign-in-notice.js.map +1 -0
  75. package/dist/subagent-hint.d.ts +31 -0
  76. package/dist/subagent-hint.d.ts.map +1 -0
  77. package/dist/subagent-hint.js +47 -0
  78. package/dist/subagent-hint.js.map +1 -0
  79. package/package.json +1 -1
@@ -1,13 +1,14 @@
1
1
  /**
2
- * The "no Claude plan" line. ccc runs the user's own Claude Code, so it only
3
- * works well signed in with a Claude Pro or Max plan; on an API key every token
4
- * is billed by Anthropic, and a key with no credit is refused outright
5
- * (credit_balance_too_low, the most common first-prompt failure). The line is
6
- * printed once before Claude Code starts when its sign-in is an API key or
7
- * missing, and never for a subscription. When ANTHROPIC_AUTH_TOKEN,
8
- * ANTHROPIC_API_KEY or an apiKeyHelper beats a Claude.ai login on file, a
9
- * line says so instead. A credit refusal gets the plan advice as ccc exits,
10
- * whatever the sign-in (claude-auth.ts creditNoticeText).
2
+ * The "no Claude plan" decision from config files, and the credit-refusal
3
+ * advice. ccc runs the user's own Claude Code, so it only works well signed in
4
+ * with a Claude Pro or Max plan; on an API key every token is billed by
5
+ * Anthropic, and a key with no credit is refused outright
6
+ * (credit_balance_too_low, the most common first-prompt failure). What is said
7
+ * before Claude Code starts is sign-in-notice.ts's; this module is its
8
+ * fallback when Claude Code cannot be asked (needsPlanWarning). When
9
+ * ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY or an apiKeyHelper beats a Claude.ai
10
+ * login on file, apiKeyOverrideText says so. A credit refusal gets the plan
11
+ * advice as ccc exits, whatever the sign-in (claude-auth.ts creditNoticeText).
11
12
  *
12
13
  * A credit refusal is also remembered (CREDIT_REFUSED_FILE, a bare marker) until
13
14
  * Anthropic answers a request or a paid tier is on record, so the next launch
@@ -19,11 +20,11 @@
19
20
  * fact rather than on the config files' guess.
20
21
  */
21
22
  import type { ApiKeyOverride, ApiKeySource, ClaudeAuthType, ClaudePlan } from "./claude-auth.js";
22
- export declare const NO_PLAN_TEXT: string;
23
23
  /** The file in ccc's config directory holding the last sign-in type Claude Code sent. */
24
24
  export declare const SEEN_AUTH_FILE = "claude-auth-seen";
25
25
  /** Present while Anthropic's last answer to Claude Code was a credit refusal. */
26
26
  export declare const CREDIT_REFUSED_FILE = "claude-credit-refused";
27
+ export declare const PAID_PLANS: readonly ClaudePlan[];
27
28
  export interface PlanWarningInput {
28
29
  /** From env and Claude Code's config files (claudeAuthFromConfig). */
29
30
  auth: ClaudeAuthType;
@@ -54,11 +55,6 @@ export declare function isInfoOnlyRun(args: readonly string[]): boolean;
54
55
  export declare function creditAdviceApplies(auth: ClaudeAuthType | undefined, plan: ClaudePlan): boolean;
55
56
  /** The credit refusal's advice, naming the env variable or setting when one is known. */
56
57
  export declare function creditAdviceText(color: boolean, source?: ApiKeySource): string;
57
- /**
58
- * The line when an API key beats a Claude.ai login that is on file (stderr,
59
- * like the no-plan line). Returns whether it was printed.
60
- */
61
- export declare function printApiKeyOverrideWarning(override: ApiKeyOverride | undefined, subscriptionLogin: boolean, color: boolean): boolean;
62
58
  export declare function apiKeyOverrideText(override: ApiKeyOverride, color: boolean): string;
63
59
  export interface CreditReminderInput {
64
60
  /** A credit refusal is on file from an earlier session (creditRefusedOnFile). */
@@ -68,24 +64,6 @@ export interface CreditReminderInput {
68
64
  }
69
65
  /** True when an earlier session was refused for credit and no paid tier is on record yet. */
70
66
  export declare function needsCreditReminder(input: CreditReminderInput): boolean;
71
- export interface StartupSignInInput extends CreditReminderInput {
72
- signIn: PlanWarningInput;
73
- /** An API key that beats the user's `/login` (claude-auth.ts apiKeyOverride). */
74
- override: ApiKeyOverride | undefined;
75
- color: boolean;
76
- }
77
- /**
78
- * The sign-in lines before Claude Code starts: a remembered credit refusal's
79
- * advice (naming the overriding key, so the override line would repeat it),
80
- * else the no-plan line, plus the override line. `warned` is whether a
81
- * no-plan or credit line is among them.
82
- */
83
- export declare function startupSignInLines(input: StartupSignInInput): {
84
- lines: string[];
85
- warned: boolean;
86
- };
87
- /** startupSignInLines on stderr (stdout stays Claude Code's); returns `warned`. */
88
- export declare function printStartupSignInLines(input: StartupSignInInput): boolean;
89
67
  /**
90
68
  * Remembers a credit refusal across launches and sessions: every refusal
91
69
  * writes the marker and every answered request removes it, whatever this
@@ -99,13 +77,6 @@ export declare class CreditRefusalMemory {
99
77
  refused(): void;
100
78
  answered(): void;
101
79
  }
102
- export declare function noPlanWarningText(color: boolean): string;
103
- /**
104
- * The line on stderr when it applies: stdout stays Claude Code's in print
105
- * runs, and in a terminal stderr shows above the session just the same.
106
- * Returns whether it was printed.
107
- */
108
- export declare function printNoPlanWarning(input: PlanWarningInput, color: boolean): boolean;
109
80
  /** The last sign-in type Claude Code's requests showed, or undefined. */
110
81
  export declare function readSeenClaudeAuth(configDir: string): ClaudeAuthType | undefined;
111
82
  /** Keep a subscription or API-key sign-in for the next launch; never throws. */
@@ -115,4 +86,6 @@ export declare function markCreditRefused(configDir: string): void;
115
86
  /** Forget a remembered credit refusal; never throws. */
116
87
  export declare function clearCreditRefused(configDir: string): void;
117
88
  export declare function creditRefusedOnFile(configDir: string): boolean;
89
+ /** Before the first prompt: an earlier session's credit refusal and its advice (uncoloured). */
90
+ export declare function creditReminderText(source: ApiKeySource | undefined): string;
118
91
  //# sourceMappingURL=claude-plan-warning.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-plan-warning.d.ts","sourceRoot":"","sources":["../src/claude-plan-warning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEjG,eAAO,MAAM,YAAY,QAE4D,CAAC;AAiBtF,yFAAyF;AACzF,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAQ3D,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,IAAI,EAAE,cAAc,CAAC;IACrB,8DAA8D;IAC9D,IAAI,EAAE,UAAU,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,oFAAoF;IACpF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAOjE;AAQD,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG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;AACxD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAM1D;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CAE3E"}
@@ -1,13 +1,14 @@
1
1
  /**
2
- * The "no Claude plan" line. ccc runs the user's own Claude Code, so it only
3
- * works well signed in with a Claude Pro or Max plan; on an API key every token
4
- * is billed by Anthropic, and a key with no credit is refused outright
5
- * (credit_balance_too_low, the most common first-prompt failure). The line is
6
- * printed once before Claude Code starts when its sign-in is an API key or
7
- * missing, and never for a subscription. When ANTHROPIC_AUTH_TOKEN,
8
- * ANTHROPIC_API_KEY or an apiKeyHelper beats a Claude.ai login on file, a
9
- * line says so instead. A credit refusal gets the plan advice as ccc exits,
10
- * whatever the sign-in (claude-auth.ts creditNoticeText).
2
+ * The "no Claude plan" decision from config files, and the credit-refusal
3
+ * advice. ccc runs the user's own Claude Code, so it only works well signed in
4
+ * with a Claude Pro or Max plan; on an API key every token is billed by
5
+ * Anthropic, and a key with no credit is refused outright
6
+ * (credit_balance_too_low, the most common first-prompt failure). What is said
7
+ * before Claude Code starts is sign-in-notice.ts's; this module is its
8
+ * fallback when Claude Code cannot be asked (needsPlanWarning). When
9
+ * ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY or an apiKeyHelper beats a Claude.ai
10
+ * login on file, apiKeyOverrideText says so. A credit refusal gets the plan
11
+ * advice as ccc exits, whatever the sign-in (claude-auth.ts creditNoticeText).
11
12
  *
12
13
  * A credit refusal is also remembered (CREDIT_REFUSED_FILE, a bare marker) until
13
14
  * Anthropic answers a request or a paid tier is on record, so the next launch
@@ -20,26 +21,27 @@
20
21
  */
21
22
  import * as fs from "node:fs";
22
23
  import * as path from "node:path";
23
- export const NO_PLAN_TEXT = "ccc needs Claude Code signed in with a Claude Pro or Max plan (run `claude`, then `/login`). " +
24
- "With an API key you pay Anthropic per token, and a key with no credit won't work.";
25
24
  /**
26
25
  * What a credit refusal means: the sign-in bills prepaid credit (an API key, or
27
26
  * Claude Code's keyless "Anthropic Console account" sign-in, which sends an
28
27
  * OAuth token too) or is a Claude account without a paid plan, and that
29
28
  * balance is empty.
30
29
  */
31
- const CREDIT_ADVICE = "Claude Code is billing an API key, an Anthropic Console account or a Claude account " +
32
- "without a paid plan. ccc needs a Pro or Max plan: run `claude`, `/logout`, then `/login` " +
33
- "and choose \"Claude account with subscription\".";
30
+ const CREDIT_ADVICE = "Claude Code is billing an Anthropic API account (a Console sign-in, an API key, or a " +
31
+ "Claude account without Pro or Max), and it has no credit left. Your MemTree credit covers " +
32
+ "MemTree, not Claude itself. To use Claude Pro or Max instead, run /login in Claude Code and " +
33
+ "choose \"Claude account with subscription\" (no plan yet? https://claude.ai/upgrade).";
34
34
  const CREDIT_TEXT = `Anthropic refused Claude Code's request: credit balance too low. ${CREDIT_ADVICE}`;
35
- const CREDIT_ENV_HINT = " If ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is set, unset it too: it beats `/login`.";
35
+ const CREDIT_ENV_HINT = " If ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is set, unset it too: it beats /login.";
36
36
  /** The file in ccc's config directory holding the last sign-in type Claude Code sent. */
37
37
  export const SEEN_AUTH_FILE = "claude-auth-seen";
38
38
  /** Present while Anthropic's last answer to Claude Code was a credit refusal. */
39
39
  export const CREDIT_REFUSED_FILE = "claude-credit-refused";
40
40
  const CREDIT_REMINDER_LEAD = "Last time, Anthropic refused Claude Code's requests: credit " +
41
41
  "balance too low. ";
42
- const PAID_PLANS = ["pro", "max", "max_5x", "max_20x", "team", "enterprise"];
42
+ export const PAID_PLANS = [
43
+ "pro", "max", "max_5x", "max_20x", "team", "enterprise",
44
+ ];
43
45
  const SEEN_TYPES = ["subscription", "api_key"];
44
46
  const CLOUD_AUTH = ["bedrock", "vertex", "foundry"];
45
47
  /**
@@ -87,16 +89,6 @@ export function creditAdviceText(color, source) {
87
89
  const text = `${CREDIT_TEXT}${creditSourceHint(source)}`;
88
90
  return color ? `\x1b[33m${text}\x1b[39m` : text;
89
91
  }
90
- /**
91
- * The line when an API key beats a Claude.ai login that is on file (stderr,
92
- * like the no-plan line). Returns whether it was printed.
93
- */
94
- export function printApiKeyOverrideWarning(override, subscriptionLogin, color) {
95
- if (!override || !subscriptionLogin)
96
- return false;
97
- process.stderr.write(`${apiKeyOverrideText(override, color)}\n`);
98
- return true;
99
- }
100
92
  export function apiKeyOverrideText(override, color) {
101
93
  const text = override.source === "apiKeyHelper"
102
94
  ? "Claude Code's settings set an apiKeyHelper, so Claude Code bills that API key instead " +
@@ -110,11 +102,11 @@ export function apiKeyOverrideText(override, color) {
110
102
  }
111
103
  function creditSourceHint(source) {
112
104
  if (source === "apiKeyHelper") {
113
- return " Claude Code's settings set an apiKeyHelper, and it beats `/login`: remove it " +
105
+ return " Claude Code's settings set an apiKeyHelper, and it beats /login: remove it " +
114
106
  "from settings.json.";
115
107
  }
116
108
  if (source) {
117
- return ` ${source} is set, and it beats \`/login\`: unset it (or run \`ccc\` without it).`;
109
+ return ` ${source} is set, and it beats /login: unset it (or run \`ccc\` without it).`;
118
110
  }
119
111
  return CREDIT_ENV_HINT;
120
112
  }
@@ -122,39 +114,6 @@ function creditSourceHint(source) {
122
114
  export function needsCreditReminder(input) {
123
115
  return input.refused && !PAID_PLANS.includes(input.plan);
124
116
  }
125
- /**
126
- * The sign-in lines before Claude Code starts: a remembered credit refusal's
127
- * advice (naming the overriding key, so the override line would repeat it),
128
- * else the no-plan line, plus the override line. `warned` is whether a
129
- * no-plan or credit line is among them.
130
- */
131
- export function startupSignInLines(input) {
132
- const { override, color } = input;
133
- // Bedrock, Vertex and Foundry bill elsewhere: an Anthropic refusal no longer applies.
134
- if (CLOUD_AUTH.includes(input.signIn.auth))
135
- return { lines: [], warned: false };
136
- if (needsCreditReminder(input)) {
137
- // A key the user may decline at Claude Code's question isn't named (as at exit).
138
- const source = override?.asks ? undefined : override?.source;
139
- const text = `${CREDIT_REMINDER_LEAD}${creditAdviceBody(source)}`;
140
- return { lines: [color ? `\x1b[33m${text}\x1b[39m` : text], warned: true };
141
- }
142
- const lines = [];
143
- const warned = needsPlanWarning(input.signIn);
144
- if (warned)
145
- lines.push(noPlanWarningText(color));
146
- if (override && input.signIn.subscriptionLogin === true) {
147
- lines.push(apiKeyOverrideText(override, color));
148
- }
149
- return { lines, warned };
150
- }
151
- /** startupSignInLines on stderr (stdout stays Claude Code's); returns `warned`. */
152
- export function printStartupSignInLines(input) {
153
- const { lines, warned } = startupSignInLines(input);
154
- for (const line of lines)
155
- process.stderr.write(`${line}\n`);
156
- return warned;
157
- }
158
117
  /**
159
118
  * Remembers a credit refusal across launches and sessions: every refusal
160
119
  * writes the marker and every answered request removes it, whatever this
@@ -176,20 +135,6 @@ export class CreditRefusalMemory {
176
135
  clearCreditRefused(this.configDir);
177
136
  }
178
137
  }
179
- export function noPlanWarningText(color) {
180
- return color ? `\x1b[33m${NO_PLAN_TEXT}\x1b[39m` : NO_PLAN_TEXT;
181
- }
182
- /**
183
- * The line on stderr when it applies: stdout stays Claude Code's in print
184
- * runs, and in a terminal stderr shows above the session just the same.
185
- * Returns whether it was printed.
186
- */
187
- export function printNoPlanWarning(input, color) {
188
- if (!needsPlanWarning(input))
189
- return false;
190
- process.stderr.write(`${noPlanWarningText(color)}\n`);
191
- return true;
192
- }
193
138
  /** The last sign-in type Claude Code's requests showed, or undefined. */
194
139
  export function readSeenClaudeAuth(configDir) {
195
140
  try {
@@ -232,6 +177,10 @@ export function clearCreditRefused(configDir) {
232
177
  export function creditRefusedOnFile(configDir) {
233
178
  return fs.existsSync(path.join(configDir, CREDIT_REFUSED_FILE));
234
179
  }
180
+ /** Before the first prompt: an earlier session's credit refusal and its advice (uncoloured). */
181
+ export function creditReminderText(source) {
182
+ return `${CREDIT_REMINDER_LEAD}${creditAdviceBody(source)}`;
183
+ }
235
184
  /** The credit advice after its "Anthropic refused…" sentence, with the source hint. */
236
185
  function creditAdviceBody(source) {
237
186
  return `${CREDIT_ADVICE}${creditSourceHint(source)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"claude-plan-warning.js","sourceRoot":"","sources":["../src/claude-plan-warning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,MAAM,CAAC,MAAM,YAAY,GACvB,+FAA+F;IAC/F,mFAAmF,CAAC;AAEtF;;;;;GAKG;AACH,MAAM,aAAa,GACjB,sFAAsF;IACtF,2FAA2F;IAC3F,kDAAkD,CAAC;AACrD,MAAM,WAAW,GACf,oEAAoE,aAAa,EAAE,CAAC;AACtF,MAAM,eAAe,GACnB,wFAAwF,CAAC;AAE3F,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AACjD,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,oBAAoB,GAAG,8DAA8D;IACzF,mBAAmB,CAAC;AAEtB,MAAM,UAAU,GAA0B,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACpG,MAAM,UAAU,GAA8B,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAC1E,MAAM,UAAU,GAA8B,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAa/E;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAuB;IACtD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACnC,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAA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AAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IACjE,OAAO,GAAG,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,uFAAuF;AACvF,SAAS,gBAAgB,CAAC,MAAgC;IACxD,OAAO,GAAG,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;AACvD,CAAC"}
@@ -5,6 +5,13 @@ export interface WrapperArgs {
5
5
  }
6
6
  /** Whether Claude's own print mode was requested before its `--` separator. */
7
7
  export declare function isPrintInvocation(args: string[]): boolean;
8
+ /**
9
+ * isPrintInvocation, plus forms it leaves to Claude: a combined short-flag
10
+ * cluster with p among its leading letters (`-pc`, `-cp`, `-pr<id>`) or
11
+ * `--print=…`, anywhere in the arguments. Conservative: for
12
+ * choices that must never happen in print mode, such as opening a browser.
13
+ */
14
+ export declare function mayBePrintInvocation(args: string[]): boolean;
8
15
  /**
9
16
  * `ccc --version` / `ccc -v` (alone, or after `local`/`staging`): answered by ccc itself,
10
17
  * with no MemTree key, proxy or session, so it works right after installing.
@@ -1 +1 @@
1
- {"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,+EAA+E;AAC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CAAC;AAEF;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,oBAAoB,GAAG,SAAS,CAKlC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EACjD,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAWxD;AAKD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB;IAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAmBjD"}
package/dist/cli-args.js CHANGED
@@ -8,6 +8,25 @@ export function isPrintInvocation(args) {
8
8
  }
9
9
  return false;
10
10
  }
11
+ /**
12
+ * isPrintInvocation, plus forms it leaves to Claude: a combined short-flag
13
+ * cluster with p among its leading letters (`-pc`, `-cp`, `-pr<id>`) or
14
+ * `--print=…`, anywhere in the arguments. Conservative: for
15
+ * choices that must never happen in print mode, such as opening a browser.
16
+ */
17
+ export function mayBePrintInvocation(args) {
18
+ // Every argument, `--` included: an option's value can be `--` itself
19
+ // (`--append-system-prompt -- -cp`), so it need not end Claude's options.
20
+ for (const arg of args) {
21
+ if (arg === "--print" || arg.startsWith("--print="))
22
+ return true;
23
+ // Commander reads a cluster up to a flag that takes a value, the rest being
24
+ // that value (`-pr<session-id>`, `-pdapi,http`): p among the leading letters.
25
+ if (/^-[A-Za-z]*p/.test(arg))
26
+ return true;
27
+ }
28
+ return false;
29
+ }
11
30
  /**
12
31
  * `ccc --version` / `ccc -v` (alone, or after `local`/`staging`): answered by ccc itself,
13
32
  * with no MemTree key, proxy or session, so it works right after installing.
@@ -1 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L,KAAK,EAAE,SAAS;YAChB,6DAA6D;YAC7D,OAAO,EAAE,6FAA6F;SACvG,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAI,CAAC,MAAM,EAAE,CAAC;AAChC,CAAC"}
package/dist/cli-main.js CHANGED
@@ -23,17 +23,19 @@ import { StablePrefixStore } from "./prefix-store.js";
23
23
  import { ToolOutputStore } from "./tool-output-store.js";
24
24
  import { NewestTreeLookup } from "./memtree-newest.js";
25
25
  import { ClaudeTranscriptUsage } from "./transcript-usage.js";
26
- import { createSessionNoticePlugin, supportsMessageDisplay, terminalSupportsColor, withSessionNoticePluginArgs, } from "./hooks.js";
26
+ import { createSessionNoticePlugin, createSubagentHookPlugin, supportsMessageDisplay, terminalSupportsColor, withSessionNoticePluginArgs, } from "./hooks.js";
27
27
  import { CLIENT_NAME, CLIENT_VERSION, MemtreeClient } from "./memtree.js";
28
28
  import { RequestLogger } from "./reqlog.js";
29
29
  import { memtreeOffNoticeText, startupNoticeText, updateInstalledNoticeText, updateNoticeText, } from "./notices.js";
30
30
  import { FALLBACK_SUBSCRIBE_URL, MEMTREE_OFF_LINE, PRINT_PAUSED_LINE, RESUMED_PAUSED_LINE, formatPaymentNotice, parsePaymentChoice, paymentGatePrompt, hyperlink, } from "./payment-gate.js";
31
31
  import { PaymentLinkCache, fetchPaymentLink } from "./payment-link.js";
32
32
  import { resumesSession, runWithoutMemtree } from "./paused-session.js";
33
+ import { SubagentMemoryHint } from "./subagent-hint.js";
34
+ import { resumeGuidanceFor } from "./resume-guidance.js";
33
35
  import { KEY_PAGE_URL, LOCAL_KEY_PAGE_URL, fetchKeyStatus, keyPageUrl, resolveInvalidKey, } from "./key-status.js";
34
36
  import { UPDATE_CHECK_CACHE_FILE, checkForUpdate } from "./update-check.js";
35
37
  import { setupAutoUpdate } from "./auto-update-setup.js";
36
- import { anthropicUpstreamFromEnv, compactTargetFromEnv, isPrintInvocation, parseWrapperArgs, memtreeLinkPlacementFromEnv, environmentOf, isVersionRequest, subcommandArgs, } from "./cli-args.js";
38
+ import { anthropicUpstreamFromEnv, compactTargetFromEnv, isPrintInvocation, mayBePrintInvocation, parseWrapperArgs, memtreeLinkPlacementFromEnv, environmentOf, isVersionRequest, subcommandArgs, } from "./cli-args.js";
37
39
  import { routeConsoleToStderr } from "./cli-output.js";
38
40
  import { runMemtreeFetchCommand } from "./memtree-fetch.js";
39
41
  import { runLinkCommand } from "./link-command.js";
@@ -51,8 +53,11 @@ import { claudeDesktopInstalled, claudeDesktopOnlyText, claudeMissingText, cwdHi
51
53
  import { INSTALL_PROMPT_ENV, offerClaudeInstall, runInstaller } from "./claude-install.js";
52
54
  import { RateLimitNotices, rateLimitNoticeText } from "./rate-limit.js";
53
55
  import { apiKeyOverride, claudeAuthFromConfig, claudePlanFromConfig, claudeSubscriptionLogin, creditNoticeText, envApiKeySet, } from "./claude-auth.js";
54
- import { CreditRefusalMemory, creditAdviceApplies, isInfoOnlyRun, printStartupSignInLines, readSeenClaudeAuth, writeSeenClaudeAuth, } from "./claude-plan-warning.js";
56
+ import { CreditRefusalMemory, creditAdviceApplies, isInfoOnlyRun, readSeenClaudeAuth, writeSeenClaudeAuth, } from "./claude-plan-warning.js";
57
+ import { probeAnswersForSession, probeClaudeAuthStatus, skippedProbe, } from "./claude-auth-status.js";
58
+ import { mayWaitForEnter, presentSignInNotice, sessionProbe, signInNotice, signInNoticeApplies, SignInTracker, } from "./sign-in-notice.js";
55
59
  import { exitResumeHint } from "./resume-hint.js";
60
+ import { urlOpenerFor } from "./open-url.js";
56
61
  // MemTree (polychat) API hosts — /v1/context_memory lives at the app root.
57
62
  const POLYCHAT_BASE_URL = "https://api.polychat.co";
58
63
  const STAGING_BASE_URL = "https://polychat-staging-421312241218.us-west2.run.app";
@@ -232,6 +237,56 @@ function askLine(question) {
232
237
  });
233
238
  });
234
239
  }
240
+ /**
241
+ * Record what `claude auth status` said, then show the sign-in message when one
242
+ * applies (sign-in-notice.ts). Exits when the user quits at its Enter prompt.
243
+ * Returns the line to repeat inside Claude Code, if any.
244
+ */
245
+ async function showSignInNotice(probe, applies, ctx) {
246
+ ctx.diagnostics.record("claude_auth_probe", { result: probe.result, ms: probe.ms });
247
+ // An env key the user rejected: the probe counts it, this session won't.
248
+ probe = sessionProbe(probe, ctx.override);
249
+ const status = probe.status;
250
+ if (status && status.auth !== "unknown") {
251
+ const plan = status.plan !== "unknown" ? status.plan : ctx.claudeSignIn.plan;
252
+ ctx.diagnostics.setContext({ claude_auth: status.auth, claude_plan: plan });
253
+ ctx.tracker.started(status.auth);
254
+ }
255
+ if (!applies)
256
+ return undefined;
257
+ const notice = signInNotice({
258
+ probe, fallback: ctx.claudeSignIn, creditRefused: ctx.creditRefused,
259
+ override: ctx.override, color: process.stderr.isTTY === true && terminalSupportsColor(),
260
+ });
261
+ if (!notice)
262
+ return undefined;
263
+ const auth = status && status.auth !== "unknown"
264
+ ? status.auth : ctx.claudeSignIn.seen ?? ctx.claudeSignIn.auth;
265
+ const go = await presentSignInNotice(notice, {
266
+ // The prompt is on stderr: never wait where it can't be seen (`ccc 2>log`), nor in CI.
267
+ interactive: mayWaitForEnter(ctx.interactive, process.stderr.isTTY === true, process.env),
268
+ auth, tracker: ctx.tracker,
269
+ record: (name, fields) => ctx.diagnostics.record(name, fields),
270
+ });
271
+ if (!go) {
272
+ await ctx.diagnostics.flush();
273
+ process.exit(0);
274
+ }
275
+ return notice.sessionLine;
276
+ }
277
+ /** The SessionStart extra line: the update notice and the sign-in line, each once. */
278
+ function sessionStartLines(autoUpdate, signIn) {
279
+ return () => {
280
+ const lines = [autoUpdate?.notices.sessionStartLine()];
281
+ if (signIn.text) {
282
+ const color = terminalSupportsColor();
283
+ lines.push(color ? `\x1b[33m${signIn.text}\x1b[39m` : signIn.text);
284
+ signIn.text = undefined;
285
+ }
286
+ const shown = lines.filter((l) => typeof l === "string");
287
+ return shown.length ? shown.join("\n") : undefined;
288
+ };
289
+ }
235
290
  function printBanner() {
236
291
  console.log(`\n\x1b[38;5;209m∞\x1b[0m \x1b[1;38;5;209mClaude Code Infinite\x1b[0m \x1b[38;5;209m∞\x1b[0m \x1b[38;5;48mfrom \x1b]8;;https://MemTree.dev\x1b\\MemTree\x1b]8;;\x1b\\\x1b[0m\n`);
237
292
  }
@@ -359,6 +414,13 @@ async function main() {
359
414
  await diagnostics.flush();
360
415
  process.exit(1);
361
416
  }
417
+ // Claude Code's own answer to "signed in?" (sign-in-notice.ts), run while
418
+ // the key is checked; awaited (bounded) just before the sign-in message.
419
+ // Not for --version/--help-style runs, which start no session and show no message.
420
+ // Not asked either when the session's options (--settings, --bare) change its sign-in.
421
+ const authProbe = isInfoOnlyRun(claudeArgs) ? null
422
+ : probeAnswersForSession(claudeArgs) ? probeClaudeAuthStatus(claude.command)
423
+ : Promise.resolve(skippedProbe());
362
424
  if (isDebugMode)
363
425
  console.log(`[DEBUG] Claude Code: ${claude.command} (${claude.source})`);
364
426
  if (!polychatApiKey) {
@@ -467,6 +529,10 @@ async function main() {
467
529
  // A refusal is also remembered for the next launch's startup line, until
468
530
  // Anthropic answers a request (claude-plan-warning.ts CREDIT_REFUSED_FILE).
469
531
  const creditMemory = new CreditRefusalMemory(getConfigDir());
532
+ // The API-billing message again inside Claude Code, at its first SessionStart.
533
+ const signInSessionLine = {};
534
+ // A sign-in completed after ccc's warning, between launches or mid-session.
535
+ const signInTracker = new SignInTracker(getConfigDir(), (event) => diagnostics.record("sign_in_completed", { ...event }));
470
536
  const observedLog = new DiagnosticsRequestSink(reqlog, diagnostics, (auth) => {
471
537
  if (!creditAdviceApplies(auth, claudeSignIn.plan))
472
538
  return;
@@ -477,12 +543,13 @@ async function main() {
477
543
  if (auth !== claudeSignIn.seen)
478
544
  writeSeenClaudeAuth(getConfigDir(), auth);
479
545
  claudeSignIn.seen = auth;
546
+ signInTracker.requestAuth(auth);
480
547
  }, () => creditMemory.answered(), (info, startedAt) => {
481
548
  if (!info)
482
549
  rateLimits.answered(startedAt);
483
550
  else if (rateLimits.observe(info) && !interactiveUi)
484
551
  console.error(rateLimitNoticeText(info));
485
- });
552
+ }, () => signInTracker.sinceWarningMs());
486
553
  // The `memtree` MCP server (memtree-mcp-config.ts): registered by ccc for
487
554
  // every session, interactive or print/non-TTY, unless CCC_MEMTREE_MCP=0,
488
555
  // the caller's own --mcp-config names a `memtree` server, or its
@@ -511,6 +578,17 @@ async function main() {
511
578
  fetchJson: (pathAndQuery, signal) => memtree.fetchMemTree(pathAndQuery, "application/json", signal),
512
579
  });
513
580
  projectTrees?.prefetch();
581
+ // A subagent is told whose memory to search (subagent-hint.ts) when the
582
+ // session has the `search` tool the hint names.
583
+ const subagentHint = memtreeMcpPlan.tools.includes("search")
584
+ ? new SubagentMemoryHint() : undefined;
585
+ // A resumed session is given the current MemTree guidance (resume-guidance.ts):
586
+ // Claude Code keeps the server instructions it first announced.
587
+ const resumeGuidance = resumeGuidanceFor({
588
+ interactive: interactiveUi,
589
+ memtreeOff: memtreeOff || checked.check === "invalid",
590
+ tools: memtreeMcpPlan.tools,
591
+ });
514
592
  const nativeOneMillionContext = claudeNativeOneMillionContextEnabled(process.env);
515
593
  const memtreeLinkPlacement = memtreeLinkPlacementFromEnv(process.env.CCC_MEMTREE_LINK);
516
594
  const memtreeLinkStore = new MemtreeLinkStore();
@@ -561,24 +639,31 @@ async function main() {
561
639
  projectMeta,
562
640
  // "✔ ccc X installed · restart ccc to use it" (or the hint after a failed
563
641
  // install) on a later SessionStart of this session, once.
564
- sessionStartNotice: autoUpdate ? () => autoUpdate.notices.sessionStartLine() : undefined,
642
+ sessionStartNotice: sessionStartLines(autoUpdate, signInSessionLine),
565
643
  promptSubmitNotice: interactiveUi ? () => rateLimits.promptLine() : undefined,
644
+ // `/memtree-view` opens its link only where a browser would appear in
645
+ // front of the user: interactive (also not `-pc`-style print), not SSH
646
+ // or CI (open-url.ts).
647
+ openUrl: urlOpenerFor({
648
+ interactive: interactiveUi && !mayBePrintInvocation(claudeArgs),
649
+ env: process.env, platform: process.platform,
650
+ memtreeBaseUrl,
651
+ }),
566
652
  projectTrees,
653
+ subagentHint,
654
+ resumeGuidance,
567
655
  });
568
656
  // One unobtrusive (dim) line so users can find the log during an incident.
569
657
  console.log(`\x1b[2mRequest log: ${reqlog.path}\x1b[0m\n`);
570
- // On an API key or not signed in: one line before the first prompt (stderr).
571
- const stderrColor = process.stderr.isTTY === true && terminalSupportsColor();
572
- // An earlier session's credit refusal (its advice, in place of the no-plan
573
- // line), else the no-plan line; then a subscriber whose env or settings make
574
- // Claude Code bill an API key instead.
658
+ // Not signed in, API billing or an earlier credit refusal: said before the
659
+ // first prompt (stderr), and when not signed in, held until Enter so it is read.
575
660
  // Not right after ccc installed Claude Code: it has just said Claude Code asks to sign in.
576
- if (found && !isInfoOnlyRun(claudeArgs) && printStartupSignInLines({
577
- refused: creditMemory.refusedAtStart, plan: claudeSignIn.plan, signIn: claudeSignIn,
578
- override: keyOverride, color: stderrColor,
579
- })) {
580
- diagnostics.record("no_plan_warning", { auth: claudeSignIn.seen ?? claudeSignIn.auth });
581
- }
661
+ const probe = await authProbe;
662
+ if (probe)
663
+ signInSessionLine.text = await showSignInNotice(probe, signInNoticeApplies(found), {
664
+ claudeSignIn, creditRefused: creditMemory.refusedAtStart, override: keyOverride,
665
+ interactive: interactiveUi, diagnostics, tracker: signInTracker,
666
+ });
582
667
  reportStrandedResumeRepair(claudeArgs, nativeOneMillionContext, claude.command);
583
668
  // The first request after a resume must count the whole session's thinking.
584
669
  const resumedSession = resumeSessionId(claudeArgs);
@@ -598,7 +683,8 @@ async function main() {
598
683
  // --plugin-dir composes with user hooks/settings; adding another --settings
599
684
  // would not, because Claude keeps only its final --settings occurrence.
600
685
  // Print/non-TTY calls are programmatic interfaces: omit all UI hooks so their
601
- // stdout/events remain byte-for-byte vanilla.
686
+ // stdout stays Claude Code's own; they get only the subagent hooks, which
687
+ // print nothing (the plugin is listed in a stream-json `init` event).
602
688
  let noticePlugin = null;
603
689
  let childArgs = [...claudeArgs];
604
690
  if (interactiveUi) {
@@ -609,6 +695,7 @@ async function main() {
609
695
  // Also carries the unpaid-key notice on resume, so it is on even
610
696
  // when MemTree links are off (the proxy then answers links-free).
611
697
  resumeLink: true,
698
+ resumeGuidance: resumeGuidance !== undefined,
612
699
  // CCC_AUTO_COMPACT=1 hands compaction back to Claude Code: /compact runs as typed.
613
700
  interceptCompact: process.env.CCC_AUTO_COMPACT !== "1",
614
701
  });
@@ -624,6 +711,17 @@ async function main() {
624
711
  }
625
712
  }
626
713
  }
714
+ else if (subagentHint) {
715
+ // Print/non-TTY: no display hooks, but subagents still get the memory hint.
716
+ try {
717
+ noticePlugin = createSubagentHookPlugin(proxy.hookUrl);
718
+ childArgs = withSessionNoticePluginArgs(childArgs, noticePlugin.dir);
719
+ }
720
+ catch (err) {
721
+ if (isDebugMode)
722
+ console.error(`[DEBUG] Subagent hook plugin disabled: ${String(err)}`);
723
+ }
724
+ }
627
725
  let memtreeMcpConfig = null;
628
726
  if (memtreeMcpPlan.register) {
629
727
  try {
@@ -635,6 +733,8 @@ async function main() {
635
733
  // tools the session lacks (ccc registers only when the caller has none).
636
734
  memtree.setMemtreeTools(undefined);
637
735
  projectTrees?.disable();
736
+ subagentHint?.disable();
737
+ resumeGuidance?.disable();
638
738
  if (isDebugMode) {
639
739
  console.error(`[DEBUG] MemTree MCP server disabled: ${String(err)}`);
640
740
  }