claude-code-infinite 1.0.20 → 1.0.22
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 +165 -30
- package/dist/auto-update-runner.d.ts +52 -0
- package/dist/auto-update-runner.d.ts.map +1 -0
- package/dist/auto-update-runner.js +307 -0
- package/dist/auto-update-runner.js.map +1 -0
- package/dist/auto-update-setup.d.ts +38 -0
- package/dist/auto-update-setup.d.ts.map +1 -0
- package/dist/auto-update-setup.js +72 -0
- package/dist/auto-update-setup.js.map +1 -0
- package/dist/auto-update.d.ts +170 -0
- package/dist/auto-update.d.ts.map +1 -0
- package/dist/auto-update.js +401 -0
- package/dist/auto-update.js.map +1 -0
- package/dist/claude-env.d.ts +14 -1
- package/dist/claude-env.d.ts.map +1 -1
- package/dist/claude-env.js +17 -1
- package/dist/claude-env.js.map +1 -1
- package/dist/cli-lifecycle.d.ts +4 -0
- package/dist/cli-lifecycle.d.ts.map +1 -1
- package/dist/cli-lifecycle.js +18 -0
- package/dist/cli-lifecycle.js.map +1 -1
- package/dist/cli-main.js +139 -19
- package/dist/cli-main.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/count-tokens.d.ts +38 -3
- package/dist/count-tokens.d.ts.map +1 -1
- package/dist/count-tokens.js +94 -19
- package/dist/count-tokens.js.map +1 -1
- package/dist/diagnostics-schema.d.ts +44 -0
- package/dist/diagnostics-schema.d.ts.map +1 -0
- package/dist/diagnostics-schema.js +162 -0
- package/dist/diagnostics-schema.js.map +1 -0
- package/dist/diagnostics.d.ts +116 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +316 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/first-tree.d.ts +11 -0
- package/dist/first-tree.d.ts.map +1 -0
- package/dist/first-tree.js +45 -0
- package/dist/first-tree.js.map +1 -0
- package/dist/hooks.d.ts +37 -0
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +69 -9
- package/dist/hooks.js.map +1 -1
- package/dist/memtree-finder.d.ts +11 -0
- package/dist/memtree-finder.d.ts.map +1 -1
- package/dist/memtree-finder.js +18 -0
- package/dist/memtree-finder.js.map +1 -1
- package/dist/memtree-links.d.ts +2 -0
- package/dist/memtree-links.d.ts.map +1 -1
- package/dist/memtree-links.js +4 -0
- package/dist/memtree-links.js.map +1 -1
- package/dist/memtree-mcp-config.d.ts.map +1 -1
- package/dist/memtree-mcp-config.js +4 -2
- package/dist/memtree-mcp-config.js.map +1 -1
- package/dist/memtree-mcp.d.ts +24 -4
- package/dist/memtree-mcp.d.ts.map +1 -1
- package/dist/memtree-mcp.js +47 -14
- package/dist/memtree-mcp.js.map +1 -1
- package/dist/memtree-tools.d.ts +17 -1
- package/dist/memtree-tools.d.ts.map +1 -1
- package/dist/memtree-tools.js +50 -2
- package/dist/memtree-tools.js.map +1 -1
- package/dist/memtree.d.ts +17 -1
- package/dist/memtree.d.ts.map +1 -1
- package/dist/memtree.js +62 -19
- package/dist/memtree.js.map +1 -1
- package/dist/notices.d.ts +6 -1
- package/dist/notices.d.ts.map +1 -1
- package/dist/notices.js +13 -1
- package/dist/notices.js.map +1 -1
- package/dist/prefix-store.js +3 -0
- package/dist/prefix-store.js.map +1 -1
- package/dist/proxy.d.ts +45 -3
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +193 -54
- package/dist/proxy.js.map +1 -1
- package/dist/reqlog.d.ts +27 -1
- package/dist/reqlog.d.ts.map +1 -1
- package/dist/reqlog.js.map +1 -1
- package/dist/request-sizing.d.ts +21 -2
- package/dist/request-sizing.d.ts.map +1 -1
- package/dist/request-sizing.js +60 -7
- package/dist/request-sizing.js.map +1 -1
- package/dist/resume-hint.d.ts +25 -0
- package/dist/resume-hint.d.ts.map +1 -0
- package/dist/resume-hint.js +36 -0
- package/dist/resume-hint.js.map +1 -0
- package/dist/token-estimate.d.ts +35 -0
- package/dist/token-estimate.d.ts.map +1 -0
- package/dist/token-estimate.js +97 -0
- package/dist/token-estimate.js.map +1 -0
- package/dist/update-check.d.ts +4 -3
- package/dist/update-check.d.ts.map +1 -1
- package/dist/update-check.js +4 -3
- package/dist/update-check.js.map +1 -1
- package/dist/update-lock.d.ts +68 -0
- package/dist/update-lock.d.ts.map +1 -0
- package/dist/update-lock.js +176 -0
- package/dist/update-lock.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launch-time glue for auto-update.ts: decide what this interactive launch
|
|
3
|
+
* does about an available update, what the SessionStart banner says now, and
|
|
4
|
+
* when the background install starts (after Claude Code is up, never on the
|
|
5
|
+
* startup path).
|
|
6
|
+
*/
|
|
7
|
+
import { AutoUpdateNotices, type AutoUpdateConfig, type AutoUpdateDecision, type InstallMethod, type SpawnLike, type StartInstallResult } from "./auto-update.js";
|
|
8
|
+
import type { UpdateAvailable } from "./update-check.js";
|
|
9
|
+
export interface AutoUpdateSetupOptions {
|
|
10
|
+
update: UpdateAvailable | null;
|
|
11
|
+
currentVersion: string;
|
|
12
|
+
config: AutoUpdateConfig;
|
|
13
|
+
configDir: string;
|
|
14
|
+
color: boolean;
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
packageDir?: string;
|
|
17
|
+
now?: () => number;
|
|
18
|
+
spawnImpl?: SpawnLike;
|
|
19
|
+
platform?: NodeJS.Platform;
|
|
20
|
+
uid?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AutoUpdateSetup {
|
|
23
|
+
decision: AutoUpdateDecision;
|
|
24
|
+
/** Detected only when there is an update to act on. */
|
|
25
|
+
method: InstallMethod | null;
|
|
26
|
+
/** The banner's hint line: shown unless an install is about to run. */
|
|
27
|
+
bannerUpdate: UpdateAvailable | null;
|
|
28
|
+
/** The banner's "✔ installed" line, when an earlier install already landed. */
|
|
29
|
+
bannerInstalled: string | null;
|
|
30
|
+
/** The SessionStart line for later hooks in this process (proxy option). */
|
|
31
|
+
notices: AutoUpdateNotices;
|
|
32
|
+
/** Start the planned install after `delayMs`; a no-op unless planned. */
|
|
33
|
+
scheduleInstall(delayMs?: number, onResult?: (result: StartInstallResult) => void): void;
|
|
34
|
+
/** One line naming the install method and the decision, for --debug. */
|
|
35
|
+
debugLine: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function setupAutoUpdate(opts: AutoUpdateSetupOptions): AutoUpdateSetup;
|
|
38
|
+
//# sourceMappingURL=auto-update-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-update-setup.d.ts","sourceRoot":"","sources":["../src/auto-update-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAEL,iBAAiB,EASjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,uDAAuD;IACvD,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,uEAAuE;IACvE,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC;IACrC,+EAA+E;IAC/E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,OAAO,EAAE,iBAAiB,CAAC;IAC3B,yEAAyE;IACzE,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI,CAAC;IACzF,wEAAwE;IACxE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,eAAe,CA4C7E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Launch-time glue for auto-update.ts: decide what this interactive launch
|
|
3
|
+
* does about an available update, what the SessionStart banner says now, and
|
|
4
|
+
* when the background install starts (after Claude Code is up, never on the
|
|
5
|
+
* startup path).
|
|
6
|
+
*/
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { AUTO_UPDATE_DELAY_MS, AutoUpdateNotices, PACKAGE_DIR, detectInstallMethod, liveLockSince, planAutoUpdate, readInstalledVersion, readUpdateState, startAutoUpdateInstall, updateFiles, } from "./auto-update.js";
|
|
9
|
+
import { updateInstalledNoticeText, updateNoticeText } from "./notices.js";
|
|
10
|
+
export function setupAutoUpdate(opts) {
|
|
11
|
+
const env = opts.env ?? process.env;
|
|
12
|
+
const packageDir = opts.packageDir ?? PACKAGE_DIR;
|
|
13
|
+
const now = opts.now ?? Date.now;
|
|
14
|
+
const files = updateFiles(opts.configDir);
|
|
15
|
+
const method = opts.update ? detectMethod(opts, env, packageDir) : null;
|
|
16
|
+
const decision = method
|
|
17
|
+
? planAutoUpdate({
|
|
18
|
+
update: opts.update,
|
|
19
|
+
method,
|
|
20
|
+
state: readUpdateState(files.stateFile),
|
|
21
|
+
env,
|
|
22
|
+
config: opts.config,
|
|
23
|
+
now: now(),
|
|
24
|
+
installedVersion: readInstalledVersion(method.packageDir),
|
|
25
|
+
lockHeldSince: liveLockSince(files.lockDir, now()),
|
|
26
|
+
})
|
|
27
|
+
: { action: "skip", reason: "no update available" };
|
|
28
|
+
const notices = new AutoUpdateNotices({
|
|
29
|
+
currentVersion: opts.currentVersion,
|
|
30
|
+
packageDir: method?.packageDir ?? packageDir,
|
|
31
|
+
stateFile: files.stateFile,
|
|
32
|
+
startedAt: now(),
|
|
33
|
+
installedText: (version) => updateInstalledNoticeText(version, opts.color),
|
|
34
|
+
hintText: (update) => updateNoticeText(update, opts.color),
|
|
35
|
+
});
|
|
36
|
+
if (decision.action === "installed")
|
|
37
|
+
notices.markShown();
|
|
38
|
+
return {
|
|
39
|
+
decision,
|
|
40
|
+
method,
|
|
41
|
+
bannerUpdate: decision.action === "skip" ? opts.update : null,
|
|
42
|
+
bannerInstalled: decision.action === "installed" ? decision.version : null,
|
|
43
|
+
notices,
|
|
44
|
+
scheduleInstall(delayMs = AUTO_UPDATE_DELAY_MS, onResult) {
|
|
45
|
+
if (decision.action !== "install")
|
|
46
|
+
return;
|
|
47
|
+
const spawnImpl = opts.spawnImpl ?? spawn;
|
|
48
|
+
const timer = setTimeout(() => {
|
|
49
|
+
const result = startAutoUpdateInstall({ decision, files, spawnImpl, env, now });
|
|
50
|
+
onResult?.(result);
|
|
51
|
+
}, delayMs);
|
|
52
|
+
timer.unref();
|
|
53
|
+
},
|
|
54
|
+
debugLine: debugLine(method, decision),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function detectMethod(opts, env, packageDir) {
|
|
58
|
+
return detectInstallMethod({
|
|
59
|
+
packageDir,
|
|
60
|
+
env,
|
|
61
|
+
platform: opts.platform,
|
|
62
|
+
uid: opts.uid ?? process.getuid?.(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function debugLine(method, decision) {
|
|
66
|
+
const how = method ? `install method ${method.kind} (${method.detail})` : "no update to install";
|
|
67
|
+
const what = decision.action === "install" ? `installing ${decision.version} in the background`
|
|
68
|
+
: decision.action === "installed" ? `${decision.version} already installed, restart to use it`
|
|
69
|
+
: `not installing: ${decision.reason}`;
|
|
70
|
+
return `Auto-update: ${how}; ${what}`;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=auto-update-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-update-setup.js","sourceRoot":"","sources":["../src/auto-update-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,WAAW,GAMZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAiC3E,MAAM,UAAU,eAAe,CAAC,IAA4B;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACpC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,WAAW,CAAC;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACjC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,MAAM,QAAQ,GAAG,MAAM;QACrB,CAAC,CAAC,cAAc,CAAC;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM;YACN,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC;YACvC,GAAG;YACH,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,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC5B,MAAM,MAAM,GAAG,sBAAsB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;gBAChF,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC,EAAE,OAAO,CAAC,CAAC;YACZ,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;QACD,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,IAA4B,EAC5B,GAAsB,EACtB,UAAkB;IAElB,OAAO,mBAAmB,CAAC;QACzB,UAAU;QACV,GAAG;QACH,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE;KACpC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,SAAS,CAAC,MAA4B,EAAE,QAA4B;IAC3E,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,kBAAkB,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,sBAAsB,CAAC;IACjG,MAAM,IAAI,GACR,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,QAAQ,CAAC,OAAO,oBAAoB;QAClF,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,uCAAuC;YAC9F,CAAC,CAAC,mBAAmB,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzC,OAAO,gBAAgB,GAAG,KAAK,IAAI,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic updates: when the startup check (update-check.ts) finds a newer
|
|
3
|
+
* release, install exactly that version in the background, the way Claude
|
|
4
|
+
* Code does ("✔ Update installed · Restart to update").
|
|
5
|
+
*
|
|
6
|
+
* Only when self-updating is safe: a plain global npm install whose package
|
|
7
|
+
* directory is physically inside `<prefix>/lib/node_modules` and writable by
|
|
8
|
+
* this user (no sudo, ever). npm-linked and git checkouts, npx and local
|
|
9
|
+
* installs, pnpm/yarn/bun/volta globals, root/sudo runs and Windows get the
|
|
10
|
+
* hint line only. The install runs in a detached runner (auto-update-runner.ts)
|
|
11
|
+
* that loads no file from the package, so it survives this ccc exiting and
|
|
12
|
+
* npm replacing the package under it.
|
|
13
|
+
*
|
|
14
|
+
* One install at a time across sessions (a lock file with a stale timeout).
|
|
15
|
+
* Every attempt is recorded in update-state.json: a failure backs off for a
|
|
16
|
+
* day, and no version is tried more than twice. The result reaches running
|
|
17
|
+
* sessions through the SessionStart hook (AutoUpdateNotices): "✔ ccc X
|
|
18
|
+
* installed · restart ccc to use it", or on failure today's hint.
|
|
19
|
+
*
|
|
20
|
+
* Running sessions keep the code they started with: the proxy loads all its
|
|
21
|
+
* modules at startup, and the hooks it registers are HTTP calls into it or
|
|
22
|
+
* files in its own temp plugin dir. See README "Automatic updates".
|
|
23
|
+
*/
|
|
24
|
+
export { UPDATE_LOCK_STALE_MS, acquireUpdateLock, liveLockSince, releaseUpdateLock, } from "./update-lock.js";
|
|
25
|
+
import { type UpdateAvailable, type UpdateCheckConfig } from "./update-check.js";
|
|
26
|
+
export declare const DISABLE_AUTOUPDATE_ENV = "CCC_DISABLE_AUTOUPDATE";
|
|
27
|
+
/** Claude Code's own opt-out, honored too. */
|
|
28
|
+
export declare const CLAUDE_DISABLE_AUTOUPDATER_ENV = "DISABLE_AUTOUPDATER";
|
|
29
|
+
export declare const UPDATE_STATE_FILE = "update-state.json";
|
|
30
|
+
/** One entry per acquirer (update-lock.ts). */
|
|
31
|
+
export declare const UPDATE_LOCK_DIR = "update.lock.d";
|
|
32
|
+
export declare const UPDATE_LOG_FILE = "auto-update.log";
|
|
33
|
+
export declare const AUTO_UPDATE_BACKOFF_MS: number;
|
|
34
|
+
export declare const MAX_ATTEMPTS_PER_VERSION = 2;
|
|
35
|
+
export declare const INSTALL_TIMEOUT_MS: number;
|
|
36
|
+
/** Wait after launch so the install never competes with Claude Code starting. */
|
|
37
|
+
export declare const AUTO_UPDATE_DELAY_MS = 5000;
|
|
38
|
+
/** This package's own directory (dist/..), as Node resolved it. */
|
|
39
|
+
export declare const PACKAGE_DIR: string;
|
|
40
|
+
/** The config.json fields auto-update reads. */
|
|
41
|
+
export interface AutoUpdateConfig extends UpdateCheckConfig {
|
|
42
|
+
autoUpdate?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export type InstallMethodKind = "npm-global" | "npm-link" | "git-checkout" | "npx" | "local" | "pnpm" | "yarn" | "bun" | "volta" | "not-writable" | "root" | "unsupported-platform" | "unknown";
|
|
45
|
+
export interface InstallMethod {
|
|
46
|
+
kind: InstallMethodKind;
|
|
47
|
+
/** The package directory, resolved through symlinks when possible. */
|
|
48
|
+
packageDir: string;
|
|
49
|
+
/** Why it is (or is not) self-updatable, for the debug log. */
|
|
50
|
+
detail: string;
|
|
51
|
+
/** npm-global only: `<prefix>/lib/node_modules`, `<prefix>`. */
|
|
52
|
+
npmRoot?: string;
|
|
53
|
+
prefix?: string;
|
|
54
|
+
}
|
|
55
|
+
export type AttemptStatus = "running" | "ok" | "failed";
|
|
56
|
+
export interface UpdateAttempt {
|
|
57
|
+
version: string;
|
|
58
|
+
status: AttemptStatus;
|
|
59
|
+
/** Start time while running, else completion time. */
|
|
60
|
+
at: number;
|
|
61
|
+
packageDir: string;
|
|
62
|
+
error?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface UpdateState {
|
|
65
|
+
/** Install attempts per version (newest few kept). */
|
|
66
|
+
attempts: Record<string, number>;
|
|
67
|
+
last?: UpdateAttempt;
|
|
68
|
+
}
|
|
69
|
+
export type AutoUpdateDecision = {
|
|
70
|
+
action: "install";
|
|
71
|
+
version: string;
|
|
72
|
+
method: InstallMethod;
|
|
73
|
+
} | {
|
|
74
|
+
action: "installed";
|
|
75
|
+
version: string;
|
|
76
|
+
} | {
|
|
77
|
+
action: "skip";
|
|
78
|
+
reason: string;
|
|
79
|
+
};
|
|
80
|
+
export interface DetectInstallOptions {
|
|
81
|
+
packageDir: string;
|
|
82
|
+
platform?: NodeJS.Platform;
|
|
83
|
+
/** process.getuid(); undefined where there is none. */
|
|
84
|
+
uid?: number;
|
|
85
|
+
env?: NodeJS.ProcessEnv;
|
|
86
|
+
}
|
|
87
|
+
export interface PlanOptions {
|
|
88
|
+
update: UpdateAvailable | null;
|
|
89
|
+
method: InstallMethod;
|
|
90
|
+
state: UpdateState;
|
|
91
|
+
env: NodeJS.ProcessEnv;
|
|
92
|
+
config: AutoUpdateConfig;
|
|
93
|
+
now: number;
|
|
94
|
+
/** The version in the package's package.json now (may be newer than running). */
|
|
95
|
+
installedVersion: string | null;
|
|
96
|
+
/** liveLockSince: when the install lock was taken, if it is held. */
|
|
97
|
+
lockHeldSince?: number | null;
|
|
98
|
+
}
|
|
99
|
+
export interface UpdateFiles {
|
|
100
|
+
stateFile: string;
|
|
101
|
+
lockDir: string;
|
|
102
|
+
logFile: string;
|
|
103
|
+
}
|
|
104
|
+
export type SpawnLike = (command: string, args: string[], options: {
|
|
105
|
+
detached: boolean;
|
|
106
|
+
stdio: "ignore";
|
|
107
|
+
env: NodeJS.ProcessEnv;
|
|
108
|
+
}) => {
|
|
109
|
+
pid?: number;
|
|
110
|
+
unref(): void;
|
|
111
|
+
on(event: "error", cb: (err: Error) => void): unknown;
|
|
112
|
+
};
|
|
113
|
+
export interface StartInstallOptions {
|
|
114
|
+
decision: AutoUpdateDecision;
|
|
115
|
+
files: UpdateFiles;
|
|
116
|
+
spawnImpl: SpawnLike;
|
|
117
|
+
now?: () => number;
|
|
118
|
+
env?: NodeJS.ProcessEnv;
|
|
119
|
+
execPath?: string;
|
|
120
|
+
/** The npm to run; default the one beside this Node, else `npm` on PATH. */
|
|
121
|
+
npmPath?: string;
|
|
122
|
+
}
|
|
123
|
+
export type StartInstallResult = "started" | "locked" | "not-planned" | "spawn-failed"
|
|
124
|
+
/** Rechecked under the lock: backed off, tried enough, or already installed. */
|
|
125
|
+
| "skipped";
|
|
126
|
+
/** False when any opt-out is set: ccc's, Claude Code's, or the update check's. */
|
|
127
|
+
export declare function autoUpdateEnabled(env: NodeJS.ProcessEnv, config: AutoUpdateConfig): boolean;
|
|
128
|
+
/** A release version safe to hand to npm, or null. */
|
|
129
|
+
export declare function strictReleaseVersion(version: unknown): string | null;
|
|
130
|
+
/**
|
|
131
|
+
* How this copy of ccc was installed. Only "npm-global" self-updates; the
|
|
132
|
+
* runner re-checks the root against `npm root -g` before installing.
|
|
133
|
+
*/
|
|
134
|
+
export declare function detectInstallMethod(opts: DetectInstallOptions): InstallMethod;
|
|
135
|
+
/** Decide what this launch does about an available update. */
|
|
136
|
+
export declare function planAutoUpdate(opts: PlanOptions): AutoUpdateDecision;
|
|
137
|
+
/**
|
|
138
|
+
* Take the lock, count the attempt, and start the detached runner. Never
|
|
139
|
+
* throws; a failure to start is recorded like a failed install.
|
|
140
|
+
*/
|
|
141
|
+
export declare function startAutoUpdateInstall(opts: StartInstallOptions): StartInstallResult;
|
|
142
|
+
/**
|
|
143
|
+
* The SessionStart line about a background install, at most once per ccc
|
|
144
|
+
* process: "✔ ccc X installed · restart ccc to use it", or after a failure
|
|
145
|
+
* during this process the manual hint.
|
|
146
|
+
*/
|
|
147
|
+
export declare class AutoUpdateNotices {
|
|
148
|
+
private readonly opts;
|
|
149
|
+
private shown;
|
|
150
|
+
constructor(opts: {
|
|
151
|
+
currentVersion: string;
|
|
152
|
+
packageDir: string;
|
|
153
|
+
stateFile: string;
|
|
154
|
+
startedAt: number;
|
|
155
|
+
installedText: (version: string) => string;
|
|
156
|
+
hintText: (update: UpdateAvailable) => string;
|
|
157
|
+
readInstalledVersion?: (packageDir: string) => string | null;
|
|
158
|
+
});
|
|
159
|
+
/** The banner already carried a line: nothing more this process. */
|
|
160
|
+
markShown(): void;
|
|
161
|
+
sessionStartLine(): string | undefined;
|
|
162
|
+
private pendingLine;
|
|
163
|
+
}
|
|
164
|
+
/** The version in `<packageDir>/package.json`, or null. */
|
|
165
|
+
export declare function readInstalledVersion(packageDir: string): string | null;
|
|
166
|
+
export declare function updateFiles(configDir: string): UpdateFiles;
|
|
167
|
+
export declare function readUpdateState(file: string): UpdateState;
|
|
168
|
+
/** Best effort and atomic: a failed write only loses bookkeeping. */
|
|
169
|
+
export declare function writeUpdateState(file: string, state: UpdateState): void;
|
|
170
|
+
//# sourceMappingURL=auto-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-update.d.ts","sourceRoot":"","sources":["../src/auto-update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAeH,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,8CAA8C;AAC9C,eAAO,MAAM,8BAA8B,wBAAwB,CAAC;AACpE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,+CAA+C;AAC/C,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAC/C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,sBAAsB,QAAsB,CAAC;AAC1D,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1C,eAAO,MAAM,kBAAkB,QAAiB,CAAC;AACjD,iFAAiF;AACjF,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAG1C,mEAAmE;AACnE,eAAO,MAAM,WAAW,QAAgD,CAAC;AAMzE,gDAAgD;AAChD,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;I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