t3-auto-build 1.0.1 → 2.0.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.
- package/CHANGELOG.md +115 -0
- package/README.md +384 -118
- package/bin/cli.mjs +155 -82
- package/hooks/_quota.mjs +75 -23
- package/hooks/_shared.mjs +165 -10
- package/hooks/pre-compact.mjs +41 -4
- package/hooks/pre-tool-use.mjs +52 -15
- package/hooks/session-start.mjs +55 -9
- package/lib/detect.mjs +5 -1
- package/lib/discover.mjs +492 -0
- package/lib/doctor.mjs +42 -2
- package/lib/install.mjs +234 -29
- package/lib/plans.mjs +318 -0
- package/lib/probe.mjs +49 -15
- package/lib/prompt.mjs +82 -5
- package/lib/quota.mjs +59 -18
- package/lib/render.mjs +25 -4
- package/lib/settings.mjs +41 -1
- package/package.json +12 -5
- package/presets/claude-codex.json +62 -14
- package/presets/claude-only.json +41 -11
- package/presets/tri-provider.json +80 -14
- package/skills/auto-build/SKILL.md.tmpl +12 -8
package/lib/install.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { isDeepStrictEqual } from 'node:util';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AVAILABILITY_FILE, CONFIG_FILE, canonicalProvider, inferProvider, isAllowlist, isObject, isStringList, isV2,
|
|
6
|
+
normalizeModel, normalizeName, readJson,
|
|
7
|
+
} from '../hooks/_shared.mjs';
|
|
5
8
|
import { MANIFEST_FILE, fileHash, hashOf, readManifest, writeManifest } from './manifest.mjs';
|
|
6
9
|
import { CliError, PACKAGE_ROOT, safePath } from './paths.mjs';
|
|
7
|
-
import {
|
|
10
|
+
import { CATALOG, PROVIDERS, resolveTiers, toConfig } from './plans.mjs';
|
|
11
|
+
import { summaryTable } from './prompt.mjs';
|
|
12
|
+
import { LADDERS, renderSkill } from './render.mjs';
|
|
8
13
|
import { HOOKS, HOOKS_DIR, hookCommand, mergeSettings, readSettings, taggedHooks, unmergeSettings, writeSettings } from './settings.mjs';
|
|
9
14
|
|
|
10
15
|
export const PRESETS = ['tri-provider', 'claude-codex', 'claude-only'];
|
|
@@ -56,6 +61,74 @@ export function completeConfig(config) {
|
|
|
56
61
|
return { ...preset, ...config, ladders: isObject(config.ladders ?? {}) ? { ...preset.ladders, ...config.ladders } : config.ladders };
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
/** What a v1 install is assumed to pay for: a low paid tier with a CLI. */
|
|
65
|
+
export const ASSUMED_TIERS = { claude: 'pro', codex: 'plus', antigravity: 'plus' };
|
|
66
|
+
const OLD_DEFAULT_BANS = ['argon', 'fable/mythos'];
|
|
67
|
+
|
|
68
|
+
function inferSubscriptions(config) {
|
|
69
|
+
const present = new Set(Object.entries(config.allowlist)
|
|
70
|
+
.filter(([, models]) => models.length > 0)
|
|
71
|
+
.map(([name]) => canonicalProvider(name)));
|
|
72
|
+
return Object.fromEntries(PROVIDERS.map((p) => [p, present.has(p) ? ASSUMED_TIERS[p] : 'none']));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The subscription selection to resolve, or null to keep the config as it is. Flags > prompts > existing config. */
|
|
76
|
+
function tierRequest(existing, options) {
|
|
77
|
+
const v2 = isV2(existing);
|
|
78
|
+
const flags = Object.fromEntries(PROVIDERS.map((p) => [p, options[`${p}Tier`]]));
|
|
79
|
+
const prompted = Object.values(options.subscriptions ?? {});
|
|
80
|
+
const wanted = Object.values(flags).some((tier) => tier !== undefined)
|
|
81
|
+
|| (v2 ? prompted.length > 0 || Boolean(options.parent) || options.allowUsageCredits !== undefined
|
|
82
|
+
: prompted.some((tier) => tier !== 'none'));
|
|
83
|
+
if (!wanted) {
|
|
84
|
+
if (options.parent) throw new CliError('--parent needs a subscription tier (--claude-tier)', 2);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const base = v2 ? existing.subscriptions : existing && inferSubscriptions(completeConfig(existing));
|
|
88
|
+
return {
|
|
89
|
+
subscriptions: Object.fromEntries(PROVIDERS.map(
|
|
90
|
+
(p) => [p, flags[p] ?? options.subscriptions?.[p] ?? base?.[p] ?? 'none'],
|
|
91
|
+
)),
|
|
92
|
+
allowUsageCredits: options.allowUsageCredits ?? existing?.allowUsageCredits ?? false,
|
|
93
|
+
parent: options.parent ?? undefined,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function resolve(subscriptions, settings) {
|
|
98
|
+
try {
|
|
99
|
+
return resolveTiers(subscriptions, settings);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
throw new CliError(error.message, 2);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const userBans = (config) => (isV2(config)
|
|
106
|
+
? union(config.userBannedModels ?? [], config.bannedModels ?? [])
|
|
107
|
+
: (config?.bannedModels ?? []).filter((entry) => !OLD_DEFAULT_BANS.includes(entry.trim().toLowerCase())));
|
|
108
|
+
|
|
109
|
+
/** A v2 config for the request. An unchanged selection keeps the existing ladders and models. */
|
|
110
|
+
function subscriptionConfig(existing, { subscriptions, allowUsageCredits, parent }) {
|
|
111
|
+
const claude = CATALOG.claude[subscriptions.claude];
|
|
112
|
+
const previous = existing?.parent?.model;
|
|
113
|
+
const keepParent = claude?.parentOptions?.includes(previous) && (!claude.usageBilled || allowUsageCredits);
|
|
114
|
+
const resolved = resolve(subscriptions, { parent: parent ?? (keepParent ? previous : undefined), allowUsageCredits });
|
|
115
|
+
if (isV2(existing) && isDeepStrictEqual(subscriptions, existing.subscriptions)
|
|
116
|
+
&& allowUsageCredits === (existing.allowUsageCredits ?? false)) {
|
|
117
|
+
return { ...existing, ...(parent && parent !== previous && { parent: resolved.parent }) };
|
|
118
|
+
}
|
|
119
|
+
const config = toConfig(resolved, {
|
|
120
|
+
allowUsageCredits,
|
|
121
|
+
allowFastModes: existing?.allowFastModes,
|
|
122
|
+
verifiedOrg: existing?.verifiedOrg,
|
|
123
|
+
userBannedModels: userBans(existing),
|
|
124
|
+
compactionThreshold: existing?.compactionThreshold,
|
|
125
|
+
});
|
|
126
|
+
for (const key of ['defaultEffort', 'modelIds', 'discovery']) {
|
|
127
|
+
if (existing?.[key] !== undefined) config[key] = existing[key];
|
|
128
|
+
}
|
|
129
|
+
return config;
|
|
130
|
+
}
|
|
131
|
+
|
|
59
132
|
/** Existing user config is the base; explicit flags override it. */
|
|
60
133
|
function planConfig(file, options) {
|
|
61
134
|
let existing = null;
|
|
@@ -74,8 +147,12 @@ function planConfig(file, options) {
|
|
|
74
147
|
if (invalid) existing = null;
|
|
75
148
|
}
|
|
76
149
|
|
|
77
|
-
|
|
78
|
-
|
|
150
|
+
const request = tierRequest(existing, options);
|
|
151
|
+
let config = request ? subscriptionConfig(existing, request)
|
|
152
|
+
: existing ? { ...existing } : loadPreset(options.preset ?? PRESETS[0]);
|
|
153
|
+
// A rebuilt roster replaces the user's ladders, so it is always backed up.
|
|
154
|
+
const rebuilt = Boolean(request && existing) && !isDeepStrictEqual(config.ladders, existing.ladders);
|
|
155
|
+
if (!isV2(config) && existing && options.preset && options.preset !== existing.preset) {
|
|
79
156
|
const preset = loadPreset(options.preset);
|
|
80
157
|
config = {
|
|
81
158
|
...preset,
|
|
@@ -89,8 +166,14 @@ function planConfig(file, options) {
|
|
|
89
166
|
};
|
|
90
167
|
}
|
|
91
168
|
if (options.compaction !== undefined) config.compactionThreshold = options.compaction;
|
|
92
|
-
if (options.banned?.length)
|
|
93
|
-
|
|
169
|
+
if (options.banned?.length) {
|
|
170
|
+
config.bannedModels = union(completeConfig(config).bannedModels, options.banned);
|
|
171
|
+
if (isV2(config)) config.userBannedModels = union(config.userBannedModels ?? [], options.banned);
|
|
172
|
+
}
|
|
173
|
+
if (isV2(config)) {
|
|
174
|
+
for (const key of ['allowFastModes', 'verifiedOrg']) if (options[key] !== undefined) config[key] = options[key];
|
|
175
|
+
}
|
|
176
|
+
for (const [name, tier] of Object.entries(isV2(config) ? {} : options.tiers ?? {})) {
|
|
94
177
|
const old = config.tiers?.[name];
|
|
95
178
|
config.tiers = { ...config.tiers, [name]: { ...old, ...tier, heavyModels: old?.heavyModels ?? tier.heavyModels } };
|
|
96
179
|
}
|
|
@@ -99,7 +182,8 @@ function planConfig(file, options) {
|
|
|
99
182
|
const problem = configProblem(complete);
|
|
100
183
|
if (problem) throw new CliError(`${file}: ${problem}`);
|
|
101
184
|
const changed = !existing || !isDeepStrictEqual(config, existing);
|
|
102
|
-
|
|
185
|
+
const text = changed ? `${JSON.stringify(config, null, 2)}\n` : null;
|
|
186
|
+
return { complete, invalid, rebuilt, selected: Boolean(request), text };
|
|
103
187
|
}
|
|
104
188
|
|
|
105
189
|
/** First of <file>.bak, .bak.1, ... that is free or already holds this content, so no backup is lost. */
|
|
@@ -118,6 +202,16 @@ function writeFile(file, content) {
|
|
|
118
202
|
fs.writeFileSync(file, content);
|
|
119
203
|
}
|
|
120
204
|
|
|
205
|
+
function writeAtomic(file, content) {
|
|
206
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
207
|
+
try {
|
|
208
|
+
writeFile(temp, content);
|
|
209
|
+
fs.renameSync(temp, file);
|
|
210
|
+
} finally {
|
|
211
|
+
fs.rmSync(temp, { force: true });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
121
215
|
/** Writes managed files, keeping the user's edits unless forced. Updates the hashes in "files". */
|
|
122
216
|
export function writeManaged(target, desired, files, { force = false, log = console.log } = {}) {
|
|
123
217
|
for (const [relative, content] of desired) {
|
|
@@ -150,10 +244,12 @@ export function writeManaged(target, desired, files, { force = false, log = cons
|
|
|
150
244
|
function writeConfig(file, text, files, { invalid = false, alwaysBackUp = false, log }) {
|
|
151
245
|
const exists = fs.existsSync(file);
|
|
152
246
|
const ours = !exists || invalid || files[CONFIG_FILE] === fileHash(file);
|
|
153
|
-
|
|
154
|
-
|
|
247
|
+
const backup = exists && (alwaysBackUp || invalid || !ours) ? backUp(file) : null;
|
|
248
|
+
if (backup) log(`backed up: ${backup}`);
|
|
249
|
+
writeAtomic(file, text);
|
|
155
250
|
if (ours) files[CONFIG_FILE] = hashOf(text);
|
|
156
251
|
log(`wrote: ${CONFIG_FILE}`);
|
|
252
|
+
return backup;
|
|
157
253
|
}
|
|
158
254
|
|
|
159
255
|
const renderInstalledSkill = (config, target) => Buffer.from(renderSkill(
|
|
@@ -215,11 +311,38 @@ function removeManaged(target, entries, log) {
|
|
|
215
311
|
return kept;
|
|
216
312
|
}
|
|
217
313
|
|
|
314
|
+
/** Contents of every managed file of a module selection, except the config. */
|
|
315
|
+
function desiredFiles(target, modules, config) {
|
|
316
|
+
const desired = new Map();
|
|
317
|
+
const source = (...parts) => fs.readFileSync(path.join(PACKAGE_ROOT, ...parts));
|
|
318
|
+
if (wantsCore(modules)) for (const file of CORE_FILES) desired.set(file, source('core', file));
|
|
319
|
+
if (wantsAuto(modules)) {
|
|
320
|
+
desired.set(SKILL, renderInstalledSkill(config, target));
|
|
321
|
+
for (const file of HOOK_FILES) {
|
|
322
|
+
if (!safePath(target, file)) throw new CliError(`${file} goes through a symlink; refusing to install hooks there`);
|
|
323
|
+
desired.set(file, source('hooks', path.posix.basename(file)));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return desired;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Writes the planned settings.json, warning when a hand-set compaction value is replaced. */
|
|
330
|
+
function applySettings(settings, merged, manifest, log) {
|
|
331
|
+
const next = merged ? merged.data : unmergeSettings(settings.data, manifest.env);
|
|
332
|
+
const previous = manifest?.env?.installed;
|
|
333
|
+
const current = settings.data.env?.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE;
|
|
334
|
+
if (merged && previous !== undefined && current !== undefined && current !== previous && current !== merged.env.installed) {
|
|
335
|
+
log('warning: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE was changed by hand; replaced with the configured value');
|
|
336
|
+
}
|
|
337
|
+
if (writeSettings(settings, next)) log('updated: settings.json');
|
|
338
|
+
}
|
|
339
|
+
|
|
218
340
|
export function install(target, options, log = console.log) {
|
|
219
341
|
const manifest = readManifest(target);
|
|
220
342
|
const modules = options.modules ?? manifest?.modules ?? 'full';
|
|
221
343
|
const auto = wantsAuto(modules);
|
|
222
|
-
|
|
344
|
+
const tierOptions = ['claudeTier', 'codexTier', 'antigravityTier', 'parent'].some((key) => options[key]);
|
|
345
|
+
if (!auto && (options.preset || options.compaction !== undefined || options.banned?.length || options.tiers || tierOptions)) {
|
|
223
346
|
log('warning: preset, compaction, banned models and tiers do not apply to the core module; ignored');
|
|
224
347
|
}
|
|
225
348
|
|
|
@@ -234,38 +357,35 @@ export function install(target, options, log = console.log) {
|
|
|
234
357
|
}
|
|
235
358
|
const config = auto ? planConfig(configPath, options) : null;
|
|
236
359
|
|
|
237
|
-
const desired =
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
360
|
+
const desired = desiredFiles(target, modules, config?.complete);
|
|
361
|
+
const v2 = auto && isV2(config.complete);
|
|
362
|
+
const merged = auto
|
|
363
|
+
? mergeSettings(settings.data, target, config.complete.compactionThreshold, manifest?.env, v2 ? config.complete.parent : undefined)
|
|
364
|
+
: null;
|
|
365
|
+
if (v2) {
|
|
366
|
+
if (options.preset && options.preset !== config.complete.preset) {
|
|
367
|
+
log('warning: --preset does not apply to a v2 config; subscription tiers decide the providers');
|
|
245
368
|
}
|
|
369
|
+
if (options.tiers) log('warning: --tiers does not apply to a v2 config; use --claude-tier, --codex-tier, --antigravity-tier');
|
|
370
|
+
if (config.selected) log(summaryTable(config.complete));
|
|
371
|
+
} else if (auto && (options.allowFastModes || options.verifiedOrg || options.allowUsageCredits)) {
|
|
372
|
+
log('warning: fast modes, verified org and usage credits need a subscription tier; ignored');
|
|
246
373
|
}
|
|
247
|
-
const merged = auto ? mergeSettings(settings.data, target, config.complete.compactionThreshold, manifest?.env) : null;
|
|
248
374
|
|
|
249
375
|
fs.mkdirSync(target, { recursive: true });
|
|
250
376
|
const files = { ...manifest?.files };
|
|
251
377
|
|
|
252
378
|
writeManaged(target, desired, files, { force: options.force, log });
|
|
253
379
|
|
|
254
|
-
if (config?.text)
|
|
380
|
+
if (config?.text) {
|
|
381
|
+
writeConfig(configPath, config.text, files, { invalid: config.invalid, alwaysBackUp: config.rebuilt, log });
|
|
382
|
+
}
|
|
255
383
|
|
|
256
384
|
const record = () => writeManifest(target, { version: 1, modules, files, ...(merged && { env: merged.env }) });
|
|
257
385
|
// Wiring: put the prior env value on record before settings.json changes.
|
|
258
386
|
if (merged) record();
|
|
259
387
|
|
|
260
|
-
if (settings)
|
|
261
|
-
const next = merged ? merged.data : unmergeSettings(settings.data, manifest.env);
|
|
262
|
-
const previous = manifest?.env?.installed;
|
|
263
|
-
const current = settings.data.env?.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE;
|
|
264
|
-
if (merged && previous !== undefined && current !== undefined && current !== previous && current !== merged.env.installed) {
|
|
265
|
-
log('warning: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE was changed by hand; replaced with the configured value');
|
|
266
|
-
}
|
|
267
|
-
if (writeSettings(settings, next)) log('updated: settings.json');
|
|
268
|
-
}
|
|
388
|
+
if (settings) applySettings(settings, merged, manifest, log);
|
|
269
389
|
|
|
270
390
|
// Stale files go after settings.json, so hooks never point at deleted scripts.
|
|
271
391
|
const owned = new Set(moduleFiles(modules));
|
|
@@ -277,6 +397,85 @@ export function install(target, options, log = console.log) {
|
|
|
277
397
|
if (auto) log('Restart T3 Code (and any running Claude Code session) so hooks and settings load.');
|
|
278
398
|
}
|
|
279
399
|
|
|
400
|
+
/** v1 ladder slots keep roster models (as canonical ids); the rest are filled from the resolved ladder. */
|
|
401
|
+
function migrateLadders(old, { models, ladders }) {
|
|
402
|
+
const key = (name) => normalizeName(normalizeModel(name.trim()));
|
|
403
|
+
const base = (entry) => entry.split('@')[0];
|
|
404
|
+
const canonical = (entry) => {
|
|
405
|
+
const [ref, effort] = entry.split('@');
|
|
406
|
+
const colon = ref.indexOf(':');
|
|
407
|
+
const provider = colon < 0 ? null : canonicalProvider(ref.slice(0, colon));
|
|
408
|
+
const found = models.find((m) => key(m.model) === key(ref.slice(colon + 1))
|
|
409
|
+
&& m.provider === (colon < 0 ? inferProvider(m.model) : provider));
|
|
410
|
+
if (!found) return null;
|
|
411
|
+
const id = found.provider === inferProvider(found.model) ? found.model : `${found.provider}:${found.model}`;
|
|
412
|
+
return effort ? `${id}@${effort.trim()}` : id;
|
|
413
|
+
};
|
|
414
|
+
return Object.fromEntries(LADDERS.map((name) => {
|
|
415
|
+
const kept = (old?.[name] ?? []).map(canonical);
|
|
416
|
+
if (!kept.some(Boolean)) return [name, ladders[name]];
|
|
417
|
+
const used = new Set(kept.filter(Boolean).map(base));
|
|
418
|
+
const spare = ladders[name].filter((entry) => !used.has(base(entry)));
|
|
419
|
+
return [name, kept.map((entry) => entry ?? spare.shift()).filter(Boolean)];
|
|
420
|
+
}));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Converts a v1 config to schema 2: backup, atomic write, then re-render of the files the manifest owns. */
|
|
424
|
+
export function upgrade(target, { log = console.log } = {}) {
|
|
425
|
+
const manifest = readManifest(target);
|
|
426
|
+
const file = path.join(target, CONFIG_FILE);
|
|
427
|
+
if (!fs.existsSync(file)) throw new CliError(`${file}: nothing to upgrade; run t3-auto-build init`);
|
|
428
|
+
if (!safePath(target, CONFIG_FILE)) throw new CliError(`${file} is a symlink; refusing to manage it`);
|
|
429
|
+
let existing;
|
|
430
|
+
try {
|
|
431
|
+
existing = readJson(file);
|
|
432
|
+
} catch {
|
|
433
|
+
throw new CliError(`${file}: not valid JSON; fix it, then run upgrade again`);
|
|
434
|
+
}
|
|
435
|
+
if (!isObject(existing)) throw new CliError(`${file}: not a JSON object`);
|
|
436
|
+
if (isV2(existing)) {
|
|
437
|
+
log(`${CONFIG_FILE} is already schema version 2; nothing to do`);
|
|
438
|
+
return { upgraded: false, backup: null, config: existing };
|
|
439
|
+
}
|
|
440
|
+
if (existing.schemaVersion !== undefined) {
|
|
441
|
+
throw new CliError(`${file}: unknown schemaVersion ${JSON.stringify(existing.schemaVersion)}; not upgrading`);
|
|
442
|
+
}
|
|
443
|
+
const old = completeConfig(existing);
|
|
444
|
+
const problem = configProblem(old);
|
|
445
|
+
if (problem) throw new CliError(`${file}: ${problem}`);
|
|
446
|
+
|
|
447
|
+
const resolved = resolve(inferSubscriptions(old));
|
|
448
|
+
const config = toConfig(resolved, { userBannedModels: userBans(existing), compactionThreshold: old.compactionThreshold });
|
|
449
|
+
config.ladders = migrateLadders(existing.ladders, resolved);
|
|
450
|
+
config.defaultEffort = old.defaultEffort;
|
|
451
|
+
for (const key of ['modelIds', 'discovery']) if (existing[key] !== undefined) config[key] = existing[key];
|
|
452
|
+
|
|
453
|
+
// Plan and validate everything before the first write.
|
|
454
|
+
const auto = manifest !== null && wantsAuto(manifest.modules);
|
|
455
|
+
if (auto) HOOKS.forEach((hook) => hookCommand(target, hook.script));
|
|
456
|
+
const settings = auto ? readSettings(target) : null;
|
|
457
|
+
renderInstalledSkill(config, target);
|
|
458
|
+
const desired = new Map(manifest
|
|
459
|
+
? [...desiredFiles(target, manifest.modules, config)].filter(([relative]) => Object.hasOwn(manifest.files, relative))
|
|
460
|
+
: []);
|
|
461
|
+
const merged = auto
|
|
462
|
+
? mergeSettings(settings.data, target, config.compactionThreshold, manifest.env, config.parent)
|
|
463
|
+
: null;
|
|
464
|
+
|
|
465
|
+
log(summaryTable(config));
|
|
466
|
+
log('note: tiers are assumed from your v1 providers; run init with --claude-tier, --codex-tier, --antigravity-tier to set yours');
|
|
467
|
+
const files = { ...manifest?.files };
|
|
468
|
+
const backup = writeConfig(file, `${JSON.stringify(config, null, 2)}\n`, files, { alwaysBackUp: true, log });
|
|
469
|
+
writeManaged(target, desired, files, { log });
|
|
470
|
+
// As in install: the prior settings values are on record before settings.json changes.
|
|
471
|
+
if (manifest) writeManifest(target, { ...manifest, files, ...(merged && { env: merged.env }) });
|
|
472
|
+
if (merged) {
|
|
473
|
+
applySettings(settings, merged, manifest, log);
|
|
474
|
+
log('Restart T3 Code (and any running Claude Code session) so hooks and settings load.');
|
|
475
|
+
}
|
|
476
|
+
return { upgraded: true, backup, config };
|
|
477
|
+
}
|
|
478
|
+
|
|
280
479
|
export function uninstall(target, log = console.log) {
|
|
281
480
|
const manifest = readManifest(target);
|
|
282
481
|
const settingsExists = fs.existsSync(path.join(target, 'settings.json'));
|
|
@@ -292,6 +491,12 @@ export function uninstall(target, log = console.log) {
|
|
|
292
491
|
return;
|
|
293
492
|
}
|
|
294
493
|
removeManaged(target, Object.entries(manifest.files), log);
|
|
494
|
+
// A generated cache, never listed in the manifest.
|
|
495
|
+
const cache = safePath(target, AVAILABILITY_FILE);
|
|
496
|
+
if (cache && fs.existsSync(cache) && fs.statSync(cache).isFile()) {
|
|
497
|
+
fs.rmSync(cache);
|
|
498
|
+
log(`removed: ${AVAILABILITY_FILE}`);
|
|
499
|
+
}
|
|
295
500
|
fs.rmSync(path.join(target, MANIFEST_FILE));
|
|
296
501
|
log(`done: uninstalled from ${target}`);
|
|
297
502
|
}
|