claude-code-infinite 1.0.2 → 1.0.5
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/README.md +43 -15
- package/dist/cli.js +6 -31
- package/dist/cli.js.map +1 -1
- package/dist/keychain.d.ts.map +1 -1
- package/dist/keychain.js +62 -21
- package/dist/keychain.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,36 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="470" height="214" alt="cc-inf-wide-transparent" src="https://github.com/user-attachments/assets/1524e5dc-637f-4d25-9a15-f7f7b65c8182" />
|
|
3
|
+
</p>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
_Claude Code can now handle infinitely long sessions using [PolyChat's](https://polychat.co) memory API, [MemTree](https://memtree.dev)._
|
|
5
|
+
# Claude Code Infinite
|
|
8
6
|
|
|
7
|
+
* Maximize Claude's intelligence with [MemTree.dev](https://memtree.dev), an advanced context-management engine
|
|
8
|
+
* Supports unlimited-length coding sessions
|
|
9
|
+
* Feels fast and fresh with every message
|
|
10
|
+
* Automatically recalls only the relevant past information
|
|
11
|
+
* Allows you to finish your work without summarizing, compacting, clearing context, or starting a new session
|
|
12
|
+
|
|
9
13
|
## Requirements
|
|
10
14
|
|
|
11
|
-
*
|
|
15
|
+
* [node.js 18 or newer](https://nodejs.org/en/download/)
|
|
16
|
+
* [Claude Code (the terminal version)](https://code.claude.com/docs/en/quickstart)
|
|
17
|
+
* **Claude Subscription** - optional but highly recommended as this offers up to 1000x cost savings vs Anthropic's API pricing.
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
> [!NOTE]
|
|
20
|
+
> If you do not want to buy a Claude Code subscription, then during setup, choose option 2. "Anthropic Console account".
|
|
21
|
+
>
|
|
22
|
+
> Note that you don't need to buy API credits, just login and Claude Code will let you complete the setup wizard. API usage will be billed through https://polychat.co.
|
|
23
|
+
> Then run `/logout` within Claude Code if you are **not** using a Claude subscription
|
|
14
24
|
|
|
15
|
-
|
|
25
|
+
## Setup
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
1. Install with npm
|
|
18
28
|
```bash
|
|
19
29
|
npm install -g claude-code-infinite
|
|
20
30
|
```
|
|
21
|
-
|
|
31
|
+
2. Run Claude Code Infinite with
|
|
22
32
|
```bash
|
|
23
|
-
|
|
33
|
+
ccc
|
|
24
34
|
```
|
|
25
35
|
|
|
26
36
|
## How it works
|
|
27
37
|
|
|
28
38
|
When you send a message, we retrieve relevant details and summaries from the prior messages in your thread. These details and summaries populate a **memory message**. Following the memory message, we append a compressed version of your recent message history. The resulting context-window is dramatically smaller, allowing Claude to process your request with much greater efficacy, lower latency, and reduced cost.
|
|
29
39
|
|
|
40
|
+
## Why it works
|
|
41
|
+
|
|
42
|
+
LLMs get exponentially dumber as their input grows.
|
|
43
|
+
|
|
44
|
+
References:
|
|
45
|
+
- [Lost in the Middle: How Language Models Use Long Contexts](https://arxiv.org/abs/2307.03172) (2023)
|
|
46
|
+
- [RULER: What's the Real Context Size of Your Long-Context Language Models?](https://arxiv.org/abs/2404.06654) (2024)
|
|
47
|
+
- [Context Rot](https://research.trychroma.com/context-rot) from Chroma
|
|
48
|
+
[](https://www.youtube.com/watch?v=TUjQuC4ugak)
|
|
49
|
+
|
|
50
|
+
Furthermore, the above research primarily tests on needle-in-a-haystack tasks, which underestimates the effect for more difficult tasks encountered in coding, where relevant context is more dense.
|
|
51
|
+
|
|
52
|
+
This is why starting sessions from scratch provides such a significant uplift in ability. What we're essentially doing is keeping each session as close to from-scratch as possible by limiting the tokens in Claude's context window to around 30k, or 15% of the standard 200k context-limit, filled precisely with the information relevant to your **last** message. I.e. This is **not** a static summary missing important details. More details [here](https://api.polychat.co/context-memory)
|
|
53
|
+
|
|
54
|
+
### Operating System Analogy
|
|
55
|
+
|
|
56
|
+
It may seem strange that we are advocating for small context windows in a product called Claude Code Infinite. But Infinite is referring to the size of a new memory layer, the MemTree, which is a layer above the context window. This layer is larger and updated more slowly than the LLMs main input, just as disk is larger + slower than RAM.
|
|
57
|
+
|
|
58
|
+
So you can think of MemTree as an operating system's virtual memory manager. Just as an OS manages RAM by swapping less-used data to disk, MemTree manages the model's context window by intelligently recalling only the most relevant information from past interactions. This ensures that the model always has access to the most pertinent data without being overwhelmed by the entire history of the conversation.
|
|
59
|
+
|
|
60
|
+
|
|
30
61
|
## Usage
|
|
31
62
|
|
|
32
63
|
> [!TIP]
|
|
33
64
|
> If you want your session to apply to many different tasks, we recommend giving the overall high level goal you want for your session in the first message, e.g. "Refactor this project to remove code smells and bugs". Then followup with lower level tasks in subsequent messages. This as Anthropic models key heavily off the first message. You should also feel free to start new sessions for new tasks. This as the model will continue to have a focused context with your CLAUDE.md and first message always included. Reach out to support@polychat.co if you have any questions or concerns!
|
|
34
|
-
|
|
35
|
-
## Known Issues:
|
|
36
|
-
- Running a `/resume` on a very long conversation can change the message history and therefore invalidate our index. So, if you resume, you may have to wait for your messages to be re-indexed. Altneratively, you can start a new thread to continue working right away.
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import spawn from "cross-spawn";
|
|
3
3
|
import * as readline from "node:readline";
|
|
4
4
|
import { getOAuthToken, isTokenExpired } from "./keychain.js";
|
|
5
5
|
import { getPolychatApiKey, setPolychatApiKey, getLocalPolychatApiKey, setLocalPolychatApiKey, } from "./config.js";
|
|
@@ -11,17 +11,10 @@ async function promptForApiKey(isLocal) {
|
|
|
11
11
|
input: process.stdin,
|
|
12
12
|
output: process.stdout,
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
console.log("\nPOLYCHAT_API_KEY not found.");
|
|
21
|
-
console.log(`Please visit: ${POLYCHAT_AUTH_URL}`);
|
|
22
|
-
console.log("to obtain your API key.\n");
|
|
23
|
-
}
|
|
24
|
-
const prompt = isLocal ? "Enter your local POLYCHAT_API_KEY: " : "Enter your POLYCHAT_API_KEY: ";
|
|
14
|
+
const url = isLocal
|
|
15
|
+
? "http://local.polychat.co:5173/memtree-api"
|
|
16
|
+
: POLYCHAT_AUTH_URL;
|
|
17
|
+
const prompt = `\nEnter your PolyChat API key from ${url}: `;
|
|
25
18
|
return new Promise((resolve) => {
|
|
26
19
|
rl.question(prompt, (answer) => {
|
|
27
20
|
rl.close();
|
|
@@ -87,25 +80,7 @@ async function refreshOAuthToken(debug) {
|
|
|
87
80
|
return refreshedToken;
|
|
88
81
|
}
|
|
89
82
|
function printBanner() {
|
|
90
|
-
|
|
91
|
-
\x1b[38;5;209m ██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗
|
|
92
|
-
██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝ ██╔════╝██╔═══██╗██╔══██╗██╔════╝
|
|
93
|
-
██║ ██║ ███████║██║ ██║██║ ██║█████╗ ██║ ██║ ██║██║ ██║█████╗
|
|
94
|
-
██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝ ██║ ██║ ██║██║ ██║██╔══╝
|
|
95
|
-
╚██████╗███████╗██║ ██║╚██████╔╝██████╔╝███████╗ ╚██████╗╚██████╔╝██████╔╝███████╗
|
|
96
|
-
╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝
|
|
97
|
-
\x1b[1;38;2;255;165;0m██╗███╗ ██╗███████╗██╗███╗ ██╗██╗████████╗███████╗
|
|
98
|
-
██║████╗ ██║██╔════╝██║████╗ ██║██║╚══██╔══╝██╔════╝
|
|
99
|
-
██║██╔██╗ ██║█████╗ ██║██╔██╗ ██║██║ ██║ █████╗
|
|
100
|
-
██║██║╚██╗██║██╔══╝ ██║██║╚██╗██║██║ ██║ ██╔══╝
|
|
101
|
-
██║██║ ╚████║██║ ██║██║ ╚████║██║ ██║ ███████╗
|
|
102
|
-
╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚══════╝\x1b[0m
|
|
103
|
-
|
|
104
|
-
\x1b[1;38;5;48m✦ Infinitely-long coding sessions for Claude, powered by \x1b]8;;https://MemTree.dev\x1b\\MemTree.dev\x1b]8;;\x1b\\\x1b[0m
|
|
105
|
-
\x1b[1;38;5;87m✦ Get the speed and quality of a fresh chat with every message\x1b[0m
|
|
106
|
-
\x1b[1;38;5;87m✦ Retrieves relevant info from all past messages \x1b[0m
|
|
107
|
-
`;
|
|
108
|
-
console.log(banner);
|
|
83
|
+
console.log(`\n\x1b[1;38;5;209mClaude Code Infinite:\x1b[0m \x1b[38;5;48mMaximizing Claude's intelligence with context-management from \x1b]8;;https://MemTree.dev\x1b\\MemTree.dev\x1b]8;;\x1b\\\x1b[0m\n`);
|
|
109
84
|
}
|
|
110
85
|
async function main() {
|
|
111
86
|
// Check for local mode and debug flag
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAyB,MAAM,eAAe,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAErB,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACnD,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,MAAM,iBAAiB,GAA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cAAc,EAAE;QAC/C,CAAC,CAAC,cAAc,CAAC;IAEnB,gCAAgC;IAChC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEjE,8CAA8C;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE;QACxC,GAAG,EAAE;YACH,GAAG,OAAO,CAAC,GAAG;YACd,kBAAkB,EAAE,OAAO;YAC3B,oBAAoB,EAAE,iBAAiB;SACxC;QACD,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAU,EAAE,EAAE;QAC/B,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC;QACxF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAmB,EAAE,EAAE;QACvC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/keychain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AA2DD,wBAAgB,aAAa,CAAC,KAAK,UAAQ,GAAG,mBAAmB,GAAG,IAAI,CA+BvE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,UAAQ,GAAG,OAAO,CAY9E"}
|
package/dist/keychain.js
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { userInfo, homedir } from "node:os";
|
|
5
|
+
function getCredentialsFromFile(debug = false) {
|
|
6
|
+
const credentialsPath = join(homedir(), ".claude", ".credentials.json");
|
|
7
|
+
if (debug) {
|
|
8
|
+
console.log(`[DEBUG] Looking for credentials at: ${credentialsPath}`);
|
|
9
|
+
}
|
|
10
|
+
if (!existsSync(credentialsPath)) {
|
|
11
|
+
if (debug) {
|
|
12
|
+
console.log(`[DEBUG] No credentials file found at ${credentialsPath}`);
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const fileContent = readFileSync(credentialsPath, { encoding: "utf-8" });
|
|
18
|
+
const parsed = JSON.parse(fileContent);
|
|
19
|
+
if (!parsed || typeof parsed !== "object" || !("claudeAiOauth" in parsed)) {
|
|
20
|
+
console.error("Invalid credentials file: expected JSON object");
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error("Failed to read credentials file:", error);
|
|
6
27
|
return null;
|
|
7
28
|
}
|
|
29
|
+
}
|
|
30
|
+
function getCredentialsFromMacOSKeychain(debug = false) {
|
|
8
31
|
const username = userInfo().username;
|
|
9
32
|
try {
|
|
10
33
|
if (debug) {
|
|
11
34
|
console.log(`[DEBUG] Reading keychain for user: ${username}`);
|
|
12
35
|
}
|
|
13
36
|
const result = execSync(`security find-generic-password -s "Claude Code-credentials" -a "${username}" -w`, { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const expiresAt = token.expiresAt;
|
|
19
|
-
const expiresInMs = expiresAt - now;
|
|
20
|
-
const expiresInMins = Math.round(expiresInMs / 1000 / 60);
|
|
21
|
-
console.log(`[DEBUG] Token retrieved from keychain:`);
|
|
22
|
-
console.log(` - expiresAt: ${expiresAt} (${new Date(expiresAt).toISOString()})`);
|
|
23
|
-
console.log(` - now: ${now} (${new Date(now).toISOString()})`);
|
|
24
|
-
console.log(` - expires in: ${expiresInMins} minutes (${expiresInMs}ms)`);
|
|
25
|
-
console.log(` - subscriptionType: ${token.subscriptionType}`);
|
|
26
|
-
console.log(` - rateLimitTier: ${token.rateLimitTier}`);
|
|
27
|
-
console.log(` - scopes: ${token.scopes?.join(", ")}`);
|
|
28
|
-
console.log(` - accessToken length: ${token.accessToken?.length ?? 0}`);
|
|
29
|
-
console.log(` - refreshToken length: ${token.refreshToken?.length ?? 0}`);
|
|
37
|
+
const parsed = JSON.parse(result.trim());
|
|
38
|
+
if (!parsed || typeof parsed !== "object" || !("claudeAiOauth" in parsed)) {
|
|
39
|
+
console.error("Invalid keychain credentials: expected JSON object");
|
|
40
|
+
return null;
|
|
30
41
|
}
|
|
31
|
-
return
|
|
42
|
+
return parsed;
|
|
32
43
|
}
|
|
33
44
|
catch (error) {
|
|
34
45
|
if (error instanceof Error && error.message.includes("could not be found")) {
|
|
@@ -40,6 +51,36 @@ export function getOAuthToken(debug = false) {
|
|
|
40
51
|
return null;
|
|
41
52
|
}
|
|
42
53
|
}
|
|
54
|
+
export function getOAuthToken(debug = false) {
|
|
55
|
+
let credentials = null;
|
|
56
|
+
if (process.platform === "darwin") {
|
|
57
|
+
credentials = getCredentialsFromMacOSKeychain(debug);
|
|
58
|
+
}
|
|
59
|
+
else if (process.platform === "win32" || process.platform === "linux") {
|
|
60
|
+
credentials = getCredentialsFromFile(debug);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
console.error(`OAuth token extraction is not supported on ${process.platform}`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
if (debug && credentials?.claudeAiOauth) {
|
|
67
|
+
const token = credentials.claudeAiOauth;
|
|
68
|
+
const now = Date.now();
|
|
69
|
+
const expiresAt = token.expiresAt;
|
|
70
|
+
const expiresInMs = expiresAt - now;
|
|
71
|
+
const expiresInMins = Math.round(expiresInMs / 1000 / 60);
|
|
72
|
+
console.log(`[DEBUG] Token retrieved:`);
|
|
73
|
+
console.log(` - expiresAt: ${expiresAt} (${new Date(expiresAt).toISOString()})`);
|
|
74
|
+
console.log(` - now: ${now} (${new Date(now).toISOString()})`);
|
|
75
|
+
console.log(` - expires in: ${expiresInMins} minutes (${expiresInMs}ms)`);
|
|
76
|
+
console.log(` - subscriptionType: ${token.subscriptionType}`);
|
|
77
|
+
console.log(` - rateLimitTier: ${token.rateLimitTier}`);
|
|
78
|
+
console.log(` - scopes: ${token.scopes?.join(", ")}`);
|
|
79
|
+
console.log(` - accessToken length: ${token.accessToken?.length ?? 0}`);
|
|
80
|
+
console.log(` - refreshToken length: ${token.refreshToken?.length ?? 0}`);
|
|
81
|
+
}
|
|
82
|
+
return credentials;
|
|
83
|
+
}
|
|
43
84
|
export function isTokenExpired(token, debug = false) {
|
|
44
85
|
const now = Date.now();
|
|
45
86
|
const expired = now > token.expiresAt;
|
package/dist/keychain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAe5C,SAAS,sBAAsB,CAAC,KAAK,GAAG,KAAK;IAC3C,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAExE,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,uCAAuC,eAAe,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjC,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,wCAAwC,eAAe,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,YAAY,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QACzE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,CAAC,eAAe,IAAI,MAAM,CAAC,EAAE,CAAC;YAC1E,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO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AO,CAAC,GAAG,CAAC,sBAAsB,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAuB,EAAE,KAAK,GAAG,KAAK;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,OAAO,GAAG,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC;IAEtC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QAC9F,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-infinite",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Wrapper for Claude Code CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"bin": {
|
|
8
|
-
"
|
|
8
|
+
"ccc": "dist/cli.js"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
11
|
"files": [
|
|
@@ -28,7 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"author": "crizCraig",
|
|
30
30
|
"license": "ISC",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"cross-spawn": "^7.0.6"
|
|
33
|
+
},
|
|
31
34
|
"devDependencies": {
|
|
35
|
+
"@types/cross-spawn": "^6.0.6",
|
|
32
36
|
"@types/node": "^25.0.0",
|
|
33
37
|
"typescript": "^5.9.3"
|
|
34
38
|
}
|