t3-auto-build 1.0.1 → 2.0.0

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/hooks/_shared.mjs CHANGED
@@ -7,14 +7,21 @@ import { fileURLToPath } from 'node:url';
7
7
 
8
8
  export const CONFIG_FILE = 'auto-build.config.json';
9
9
  export const COOLDOWN_FILE = 'auto-build-cooldowns.json';
10
+ export const AVAILABILITY_FILE = 'auto-build-availability.json';
11
+ export const SCHEMA_VERSION = 2;
12
+
13
+ /** Always blocked: config can add to this list, never shrink it. */
14
+ export const RETIRED_MODELS = Object.freeze([
15
+ 'gemini-4-argon', 'gemini-3.8-flash', 'claude-4.6', 'claude-4.6-*', 'gpt-5.4', 'gpt-5.4-*', 'gpt-5.5', 'gpt-5.5-*',
16
+ ]);
10
17
 
11
18
  export const DEFAULTS = {
12
19
  allowlist: {
13
- Codex: ['gpt-5.6-luna', 'gpt-5.6-terra', 'gpt-6-luna'],
20
+ Codex: ['gpt-6-luna', 'gpt-6.1-terra', 'gpt-6.1-sol'],
14
21
  Antigravity: ['Gemini 4 Hydrogen', 'Gemini 4 Neon', 'Gemini 4 Carbon'],
15
22
  Claude: ['Claude Haiku 5.5', 'Claude Sonnet 5.5', 'Claude Opus 5.5'],
16
23
  },
17
- bannedModels: ['Argon', 'Fable/Mythos'],
24
+ bannedModels: [],
18
25
  };
19
26
 
20
27
  export const warn = (message) => process.stderr.write(`t3-auto-build: ${message}\n`);
@@ -67,6 +74,65 @@ export function modelKeys(model, config) {
67
74
  return keys;
68
75
  }
69
76
 
77
+ /** True when the model is a retired one; a pattern ending "-*" also covers every "<stem>-..." variant. */
78
+ export function matchRetired(model, patterns = RETIRED_MODELS) {
79
+ if (typeof model !== 'string') return false;
80
+ const key = (name) => normalizeName(normalizeModel(name.trim())).replace(/^-+|-+$/g, '');
81
+ const name = key(model);
82
+ return patterns.some((pattern) => {
83
+ const family = pattern.endsWith('-*');
84
+ const stem = key(family ? pattern.slice(0, -2) : pattern);
85
+ return name === stem || (family && name.startsWith(`${stem}-`));
86
+ });
87
+ }
88
+
89
+ // T3 provider ids to provider keys. Custom instances (codex-2) resolve by driverKind or this prefix.
90
+ export const PROVIDER_ALIASES = new Map([
91
+ ['claudeagent', 'claude'], ['claude', 'claude'], ['codex', 'codex'], ['antigravity', 'antigravity'],
92
+ ]);
93
+
94
+ /** 'claude' | 'codex' | 'antigravity' from a provider or instance id, else null. */
95
+ export function canonicalProvider(id) {
96
+ if (typeof id !== 'string') return null;
97
+ const compact = id.toLowerCase().replace(/[^a-z0-9]/g, '');
98
+ const alias = [...PROVIDER_ALIASES.keys()].find((prefix) => compact.startsWith(prefix));
99
+ return PROVIDER_ALIASES.get(alias) ?? null;
100
+ }
101
+
102
+ /**
103
+ * Which hosting a request means. A bare model resolves to its native provider; another provider hosts it only when
104
+ * named explicitly and declared in config.models. A set `conflict` means the request must not be trusted.
105
+ */
106
+ export function resolveTarget({ providers = [], model } = {}, config) {
107
+ const list = Array.isArray(providers) ? providers : [providers];
108
+ const canon = [...new Set(list.map(canonicalProvider).filter(Boolean))];
109
+ const name = typeof model === 'string' && model ? model : null;
110
+ const inferred = inferProvider(name);
111
+ const declared = canon[0] ?? null;
112
+ const provider = declared ?? inferred;
113
+ let entry = null;
114
+ if (name && provider) {
115
+ const keys = modelKeys(name, config);
116
+ const models = Array.isArray(config?.models) ? config.models : [];
117
+ entry = models.find((item) => typeof item?.model === 'string' && canonicalProvider(item.provider) === provider
118
+ && [...modelKeys(item.model, config)].some((key) => keys.has(key))) ?? null;
119
+ }
120
+ let conflict = null;
121
+ if (canon.length > 1) conflict = `conflicting providers: ${canon.join(', ')}`;
122
+ else if (declared && !entry && inferred && declared !== inferred) {
123
+ conflict = `model ${name} is not hosted on provider ${declared}`;
124
+ }
125
+ return {
126
+ provider,
127
+ model: name,
128
+ entry,
129
+ pool: entry?.pool ?? 'standard',
130
+ scarceQuota: Boolean(entry?.scarceQuota),
131
+ crossHosted: provider !== inferred && Boolean(entry),
132
+ conflict,
133
+ };
134
+ }
135
+
70
136
  /** Banned entries match as substrings of the raw or normalized name; "A/B" bans both A and B. */
71
137
  export function isBanned(model, bannedModels) {
72
138
  const name = model.toLowerCase();
@@ -95,7 +161,18 @@ function presetDefaults(preset) {
95
161
  return { ...DEFAULTS, allowlist };
96
162
  }
97
163
 
98
- /** Missing or invalid keys come from the config's own preset, as in the installer. */
164
+ export const isV2 = (raw) => raw?.schemaVersion === SCHEMA_VERSION;
165
+
166
+ const isModelList = (v) => Array.isArray(v) && v.every((m) => isObject(m) && isStringList([m.provider, m.model])
167
+ && (m.pool === undefined || typeof m.pool === 'string')
168
+ && (m.scarceQuota === undefined || typeof m.scarceQuota === 'boolean'));
169
+ const isBoolean = (v) => typeof v === 'boolean';
170
+ const isCount = (v) => Number.isInteger(v) && v >= 0;
171
+
172
+ /**
173
+ * Missing or invalid keys come from the config's own preset, as in the installer. An unreadable file or an unknown
174
+ * schemaVersion gives DEFAULTS, so an allowlist is always enforced.
175
+ */
99
176
  export function loadConfig(configDir) {
100
177
  let raw = {};
101
178
  try {
@@ -105,17 +182,40 @@ export function loadConfig(configDir) {
105
182
  if (error.code !== 'ENOENT') warn(`ignoring ${CONFIG_FILE} (${error.name}); using defaults`);
106
183
  raw = {};
107
184
  }
185
+ if (raw.schemaVersion !== undefined && !isV2(raw)) {
186
+ warn(`unknown "schemaVersion" in ${CONFIG_FILE}; using defaults`);
187
+ raw = {};
188
+ }
189
+ const v2 = isV2(raw);
108
190
  const defaults = presetDefaults(raw.preset);
109
- const pick = (key, valid) => {
110
- if (raw[key] === undefined) return defaults[key];
191
+ const pick = (key, valid, fallback = defaults[key]) => {
192
+ if (raw[key] === undefined) return fallback;
111
193
  if (valid(raw[key])) return raw[key];
112
194
  warn(`invalid "${key}" in ${CONFIG_FILE}; using default`);
113
- return defaults[key];
195
+ return fallback;
196
+ };
197
+ const config = {
198
+ schemaVersion: v2 ? SCHEMA_VERSION : 1,
199
+ allowlist: pick('allowlist', isAllowlist),
200
+ bannedModels: pick('bannedModels', isStringList),
201
+ retiredModels: [...RETIRED_MODELS],
202
+ planRestrictedModels: [],
203
+ models: [],
204
+ allowFastModes: false,
114
205
  };
115
- const config = { allowlist: pick('allowlist', isAllowlist), bannedModels: pick('bannedModels', isStringList) };
116
- // Optional keys: present only when set to an object.
117
- for (const key of ['tiers', 'modelIds']) {
118
- const value = pick(key, isObject);
206
+ const optional = [['tiers', isObject], ['modelIds', isObject]];
207
+ if (v2) {
208
+ // Both ban lists apply.
209
+ config.bannedModels = [...new Set([...config.bannedModels, ...pick('userBannedModels', isStringList, [])])];
210
+ config.retiredModels = [...new Set([...RETIRED_MODELS, ...pick('retiredModels', isStringList, [])])];
211
+ config.planRestrictedModels = pick('planRestrictedModels', isStringList, []);
212
+ config.models = pick('models', isModelList, []);
213
+ config.allowFastModes = pick('allowFastModes', isBoolean, false);
214
+ optional.push(['subscriptions', isObject], ['maxParallelBuilders', isCount]);
215
+ }
216
+ // Optional keys: present only when set to a valid value.
217
+ for (const [key, valid] of optional) {
218
+ const value = pick(key, valid);
119
219
  if (value !== undefined) config[key] = value;
120
220
  }
121
221
  return config;
@@ -144,6 +244,58 @@ export function prop(object, name) {
144
244
  return key === undefined ? undefined : object[key];
145
245
  }
146
246
 
247
+ /** Why a parsed payload must be blocked: it names a tool but its input is not an object. Else null. */
248
+ export function payloadProblem(payload) {
249
+ const tool = prop(payload, 'tool_name');
250
+ if (typeof tool !== 'string' || tool === '') return null;
251
+ const input = prop(payload, 'tool_input');
252
+ return input === undefined || isObject(input) ? null : `tool_input of '${tool}' is not an object`;
253
+ }
254
+
255
+ const FAST_KEY = /fast|speed|servicetier/i;
256
+ const FAST_VALUE = /^(true|fast|ultrafast|priority)$/i;
257
+ const FAST_DEPTH = 6;
258
+
259
+ /** True when a tool input asks for a fast or priority mode, as a key or as an {id, value} option pair. */
260
+ export function fastModeRequested(input, depth = 1) {
261
+ if (depth > FAST_DEPTH || input === null || typeof input !== 'object') return false;
262
+ const asks = (key, value) => typeof key === 'string' && FAST_KEY.test(key.replace(/[^a-z0-9]/gi, ''))
263
+ && (value === true || (typeof value === 'string' && FAST_VALUE.test(value)));
264
+ if (asks(prop(input, 'id'), prop(input, 'value'))) return true;
265
+ return Object.entries(input).some(([key, value]) => asks(key, value) || fastModeRequested(value, depth + 1));
266
+ }
267
+
268
+ const AVAILABILITY_TTL = 12 * 60 * 60_000;
269
+
270
+ /** { data, stale } of the availability file; data is null when it is missing or malformed. Never throws. */
271
+ export function readAvailability(file, now = Date.now()) {
272
+ try {
273
+ const data = readJson(file);
274
+ if (isObject(data) && data.schemaVersion === 1 && isObject(data.models)) {
275
+ const ttl = data.ttlMs > 0 ? data.ttlMs : AVAILABILITY_TTL;
276
+ return { data, stale: !(now - Date.parse(data.checkedAt) < ttl) };
277
+ }
278
+ } catch {
279
+ // reported as no data
280
+ }
281
+ return { data: null, stale: true };
282
+ }
283
+
284
+ /** The entry restricting provider:model, or null. Takes readAvailability's data (or its whole result). */
285
+ export function restrictedBy(availability, provider, model, now = Date.now()) {
286
+ const wanted = canonicalProvider(provider);
287
+ if (!wanted || typeof model !== 'string') return null;
288
+ const keys = modelKeys(model);
289
+ const models = (availability?.data ?? availability)?.models;
290
+ return Object.entries(isObject(models) ? models : {}).find(([ref, entry]) => {
291
+ const [, host, name] = ref.match(/^([^:]+):(.+)$/) ?? [];
292
+ return name !== undefined && canonicalProvider(host) === wanted && [...modelKeys(name)].some((key) => keys.has(key))
293
+ && ['plan-restricted', 'unavailable'].includes(entry?.status)
294
+ // An unreadable "until" keeps the restriction.
295
+ && (entry.until === undefined || !(Date.parse(entry.until) <= now));
296
+ })?.[1] ?? null;
297
+ }
298
+
147
299
  /** PowerShell-like "$($value)" stringification. */
148
300
  export function str(value) {
149
301
  if (value === undefined || value === null) return '';
@@ -2,26 +2,63 @@
2
2
  import { randomBytes } from 'node:crypto';
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
+ import { readCooldowns, summarize } from './_quota.mjs';
5
6
  import {
6
- COOLDOWN_FILE, configDirOf, displayPath, effectiveAllowlist, isObject, loadConfig, prop, readJson, readPayload, run, warn,
7
- which,
7
+ AVAILABILITY_FILE, COOLDOWN_FILE, configDirOf, displayPath, effectiveAllowlist, isObject, loadConfig, matchRetired, prop,
8
+ readAvailability, readJson, readPayload, restrictedBy, run, warn, which,
8
9
  } from './_shared.mjs';
9
10
 
10
11
  const joinNames = (names) =>
11
12
  names.length < 2 ? names.join('') : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
12
13
 
14
+ const LIST_LIMIT = 20;
15
+ const listed = (items) => {
16
+ if (items.length === 0) return 'none';
17
+ const more = items.length > LIST_LIMIT ? `, +${items.length - LIST_LIMIT} more` : '';
18
+ return `${items.slice(0, LIST_LIMIT).join(', ')}${more}`;
19
+ };
20
+
21
+ /** Active availability restrictions as "provider:model (status)". */
22
+ function unavailable(configDir) {
23
+ const { data } = readAvailability(path.join(configDir, AVAILABILITY_FILE));
24
+ return Object.keys(data?.models ?? {}).flatMap((ref) => {
25
+ // The file's text goes into the session context, so only plain refs are echoed.
26
+ const [, host, model] = ref.match(/^([a-z]{1,20}):([\w.-]{1,60})$/i) ?? [];
27
+ const entry = model && restrictedBy(data, host, model);
28
+ return entry ? [`${ref} (${entry.status})`] : [];
29
+ });
30
+ }
31
+
32
+ function activeLocks(configDir) {
33
+ try {
34
+ // The first summary line is a heading.
35
+ const lines = summarize(readCooldowns(path.join(configDir, COOLDOWN_FILE))).slice(1);
36
+ return lines.length ? lines.map((line) => `\n - ${line}`).join('') : '\n - Active locks: none';
37
+ } catch (error) {
38
+ warn(`ignoring ${COOLDOWN_FILE} (${error.name})`);
39
+ return '\n - Active locks: unknown (file unreadable)';
40
+ }
41
+ }
42
+
13
43
  function rules(configDir) {
14
44
  const config = loadConfig(configDir);
15
- const groups = effectiveAllowlist(config);
45
+ const groups = effectiveAllowlist(config)
46
+ .map(([provider, models]) => [provider, models.filter((m) => !matchRetired(m, config.retiredModels))])
47
+ .filter(([, models]) => models.length > 0);
16
48
  const count = groups.reduce((total, [, models]) => total + models.length, 0);
17
49
  const allowed = groups.map(([provider, models]) => `${models.join(', ')} (${provider})`).join('; ');
18
50
  const banned = config.bannedModels;
19
51
  const bannedText = banned.length ? ` ${joinNames(banned)} ${banned.length > 1 || banned[0].includes('/') ? 'are' : 'is'} strictly banned.` : '';
52
+ const scarce = config.models.filter((m) => m.scarceQuota).map((m) => `${m.provider}:${m.model} [${m.pool ?? 'standard'}]`);
20
53
  return `MANDATORY COMPACTION PRESERVATION RULES:
21
54
  When summarizing this session, you MUST preserve verbatim:
22
55
  1. STRICT ${count}-MODEL ALLOWLIST: Only ${allowed}.${bannedText}
56
+ - Retired (always blocked): ${listed(config.retiredModels)}
57
+ - Plan-restricted: ${listed(config.planRestrictedModels)}
58
+ - Unavailable now: ${listed(unavailable(configDir))}
59
+ - Scarce pools (overflow/escalation only): ${listed(scarce)}
23
60
  2. ORCHESTRATOR STATE (if $auto-build is active): Active inline flags (--fast/--strict/--plan-only/--budget/etc.), complexity tier (L0-L3), full REPO_BRIEF, IMPLEMENTER_PROVIDER, in-run EXHAUSTED models, current pipeline step, files modified so far, and exact failing test/audit file:line items.
24
- 3. COOLDOWN STATE: Any active rate-limit/quota cooldowns recorded in ${displayPath(configDir, COOLDOWN_FILE)}.
61
+ 3. COOLDOWN STATE: Any active rate-limit/quota cooldowns recorded in ${displayPath(configDir, COOLDOWN_FILE)}.${activeLocks(configDir)}
25
62
  4. ACTIVE SESSION STATE (all threads): Preserve a compact digest of:
26
63
  - Key architectural/constraint decisions already agreed upon.
27
64
  - Files already inspected or modified (so you do NOT re-read unchanged files after compaction).
@@ -2,8 +2,9 @@
2
2
  import path from 'node:path';
3
3
  import { isLocked, readCooldowns } from './_quota.mjs';
4
4
  import {
5
- COOLDOWN_FILE, configDirOf, effectiveAllowlist, isBanned, loadConfig, modelKeys, normalizeModel, prop, readPayload, str,
6
- warn,
5
+ AVAILABILITY_FILE, COOLDOWN_FILE, canonicalProvider, configDirOf, effectiveAllowlist, fastModeRequested, isBanned,
6
+ loadConfig, matchRetired, modelKeys, normalizeModel, payloadProblem, prop, readAvailability, readPayload, resolveTarget,
7
+ restrictedBy, str, warn,
7
8
  } from './_shared.mjs';
8
9
 
9
10
  // (?=\n?$) mirrors .NET's "$", which also matches before a trailing newline.
@@ -63,12 +64,10 @@ function cooldownBlock(configDir, models, providers, config) {
63
64
  try {
64
65
  const data = readCooldowns(path.join(configDir, COOLDOWN_FILE));
65
66
  for (const model of models.length ? models : [undefined]) {
66
- for (const provider of providers.length ? providers : [undefined]) {
67
- const lock = isLocked(data, { provider, model, config });
68
- if (lock) {
69
- return `Blocked by cooldown hook: '${lock.key}' is on active cooldown until ${lock.until} `
70
- + `(scope: ${lock.scope}; window: ${lock.window}; reason: ${lock.reason}).`;
71
- }
67
+ const lock = isLocked(data, { providers, model, config });
68
+ if (lock) {
69
+ return `Blocked by cooldown hook: '${lock.key}' is on active cooldown until ${lock.until} `
70
+ + `(scope: ${lock.scope}; window: ${lock.window}; reason: ${lock.reason}).`;
72
71
  }
73
72
  }
74
73
  } catch (error) {
@@ -77,7 +76,45 @@ function cooldownBlock(configDir, models, providers, config) {
77
76
  return null;
78
77
  }
79
78
 
79
+ /** "provider:model" restricts that hosting only; a bare model restricts every hosting. */
80
+ function planRestricted(refs, provider, keys, config) {
81
+ return refs.some((ref) => {
82
+ const [, host, name] = ref.match(/^([^:]+):(.+)$/) ?? [];
83
+ const hosting = canonicalProvider(host);
84
+ if (hosting && hosting !== provider) return false;
85
+ return [...modelKeys(hosting ? name : ref, config)].some((key) => keys.includes(key));
86
+ });
87
+ }
88
+
89
+ /** Why one requested model is refused, or null. The order of the checks decides which reason is reported. */
90
+ function modelBlock(model, { providers, config, availability, allowed, known }) {
91
+ const target = resolveTarget({ providers, model }, config);
92
+ if (target.conflict) return `Blocked by allowlist hook: ${target.conflict}.`;
93
+ const keys = [...modelKeys(model, config)];
94
+ if ([model, ...keys].some((name) => matchRetired(name, config.retiredModels))) {
95
+ return `Blocked by allowlist hook: model '${model}' is banned (retired).`;
96
+ }
97
+ if ([model, normalizeModel(model)].some((name) => isBanned(name, config.bannedModels))) {
98
+ return `Blocked by allowlist hook: model '${model}' is banned.`;
99
+ }
100
+ if (planRestricted(config.planRestrictedModels, target.provider, keys, config)) {
101
+ return `Blocked by plan hook: model '${model}' is plan-restricted on the configured subscription.`;
102
+ }
103
+ const restriction = keys.map((key) => restrictedBy(availability, target.provider, key)).find(Boolean);
104
+ if (restriction) {
105
+ const until = Date.parse(restriction.until);
106
+ return `Blocked by availability hook: model '${model}' is ${restriction.status} on ${target.provider}`
107
+ + `${Number.isNaN(until) ? '' : ` until ${new Date(until).toISOString()}`}.`;
108
+ }
109
+ if (!keys.some((key) => known.has(key))) {
110
+ return `Blocked by allowlist hook: model '${model}' is outside the ${allowed.length}-model allowlist.`;
111
+ }
112
+ return null;
113
+ }
114
+
80
115
  function blockReason(payload) {
116
+ const problem = payloadProblem(payload);
117
+ if (problem) return `Blocked by safety hook: ${problem}.`;
81
118
  const tool = str(prop(payload, 'tool_name'));
82
119
  const input = prop(payload, 'tool_input');
83
120
 
@@ -102,19 +139,19 @@ function blockReason(payload) {
102
139
  const field = (name) => refs.map((ref) => str(prop(ref, name))).filter(Boolean);
103
140
  const models = field('model');
104
141
  const providers = ['provider', 'providerInstanceId', 'driverKind'].flatMap(field);
105
- if (!models.length && !providers.length) return null;
106
142
  const configDir = configDirOf(import.meta.url);
107
143
  const config = loadConfig(configDir);
144
+ if (!config.allowFastModes && fastModeRequested(input)) {
145
+ return 'Blocked by fast-mode hook: fast/priority service modes are disabled (config "allowFastModes").';
146
+ }
147
+ if (!models.length && !providers.length) return null;
108
148
  if (models.length) {
109
149
  const allowed = effectiveAllowlist(config).flatMap(([, names]) => names);
110
150
  const known = new Set(allowed.flatMap((name) => [...modelKeys(name)]));
151
+ const { data: availability } = readAvailability(path.join(configDir, AVAILABILITY_FILE));
111
152
  for (const model of models) {
112
- if ([model, normalizeModel(model)].some((name) => isBanned(name, config.bannedModels))) {
113
- return `Blocked by allowlist hook: model '${model}' is banned.`;
114
- }
115
- if (![...modelKeys(model, config)].some((key) => known.has(key))) {
116
- return `Blocked by allowlist hook: model '${model}' is outside the ${allowed.length}-model allowlist.`;
117
- }
153
+ const reason = modelBlock(model, { providers, config, availability, allowed, known });
154
+ if (reason) return reason;
118
155
  }
119
156
  }
120
157
  return cooldownBlock(configDir, models, providers, config);
@@ -1,15 +1,61 @@
1
- // SessionStart: report the active lockouts and prune expired cooldowns.
1
+ // SessionStart: report subscriptions, active lockouts and the availability cache (6 lines at most); prune cooldowns.
2
2
  import path from 'node:path';
3
3
  import { prune, readCooldowns, summarize, writeCooldowns } from './_quota.mjs';
4
- import { COOLDOWN_FILE, configDirOf, warn } from './_shared.mjs';
4
+ import {
5
+ AVAILABILITY_FILE, COOLDOWN_FILE, PROVIDER_ALIASES, configDirOf, loadConfig, readAvailability, warn,
6
+ } from './_shared.mjs';
5
7
 
6
- try {
7
- const file = path.join(configDirOf(import.meta.url), COOLDOWN_FILE);
8
+ const HOUR = 60 * 60_000;
9
+ const lines = [];
10
+
11
+ // Each section fails alone, so one bad file never hides the others.
12
+ function section(name, report) {
13
+ try {
14
+ report();
15
+ } catch (error) {
16
+ warn(`ignoring ${name} (${error.name})`);
17
+ }
18
+ }
19
+
20
+ const configDir = configDirOf(import.meta.url);
21
+
22
+ section('subscriptions', () => {
23
+ const config = loadConfig(configDir);
24
+ if (config.schemaVersion !== 2) {
25
+ lines.push('AUTO-BUILD: legacy v1 config: run t3-auto-build upgrade');
26
+ return;
27
+ }
28
+ // Config text goes into the session context: only known providers with a plain tier id are echoed.
29
+ const tiers = [...new Set(PROVIDER_ALIASES.values())].flatMap((provider) => {
30
+ const tier = config.subscriptions?.[provider];
31
+ return typeof tier === 'string' && /^[a-z0-9-]{1,20}$/.test(tier) ? [`${provider}: ${tier}`] : [];
32
+ });
33
+ lines.push(`AUTO-BUILD subscriptions: ${tiers.join(', ') || 'unknown'}`);
34
+ });
35
+
36
+ section(COOLDOWN_FILE, () => {
37
+ const file = path.join(configDir, COOLDOWN_FILE);
8
38
  // A malformed file throws here, so it is never overwritten.
9
39
  const { kept, removed } = prune(readCooldowns(file));
10
- const lines = summarize(kept);
11
- if (lines.length) process.stdout.write(`${lines.join('\n')}\n`);
40
+ lines.push(...summarize(kept));
12
41
  if (Object.keys(removed).length) writeCooldowns(file, kept);
13
- } catch (error) {
14
- warn(`ignoring ${COOLDOWN_FILE} (${error.name})`);
15
- }
42
+ });
43
+
44
+ section(AVAILABILITY_FILE, () => {
45
+ const { data, stale } = readAvailability(path.join(configDir, AVAILABILITY_FILE));
46
+ if (!data) {
47
+ lines.push('AUTO-BUILD availability cache: missing — run t3-auto-build check-models');
48
+ return;
49
+ }
50
+ const age = Math.max(0, Math.floor((Date.now() - Date.parse(data.checkedAt)) / HOUR));
51
+ lines.push(`AUTO-BUILD availability cache: ${stale ? 'stale' : `fresh (${age}h old)`}`);
52
+ // Counts only: discovered ids are never echoed, and never allowed automatically.
53
+ const count = (list) => (Array.isArray(list) ? list.length : 0);
54
+ const added = count(data.discoveredNew);
55
+ const missing = count(data.missingConfigured);
56
+ if (added || missing) {
57
+ lines.push(`AUTO-BUILD model drift: ${added} new, ${missing} missing (not auto-allowed; run t3-auto-build check-models)`);
58
+ }
59
+ });
60
+
61
+ if (lines.length) process.stdout.write(`${lines.join('\n')}\n`);
package/lib/detect.mjs CHANGED
@@ -4,6 +4,7 @@ import os from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { which as findOnPath } from '../hooks/_shared.mjs';
6
6
  import { CliError } from './paths.mjs';
7
+ import { MODELS } from './plans.mjs';
7
8
 
8
9
  // Config directories under the home folder. Only their existence is checked; nothing inside is opened.
9
10
  const MARKERS = { claude: ['.claude'], codex: ['.codex'], antigravity: ['.antigravity', '.gemini/antigravity'] };
@@ -26,7 +27,10 @@ const PLANS = {
26
27
  codex: { plus: 'provider', pro: 'heavy-tier-only' },
27
28
  antigravity: { standard: 'provider', ultra: 'heavy-tier-only' },
28
29
  };
29
- export const HEAVY_MODELS = { claude: ['Claude Opus 5.5'], codex: ['gpt-6-luna'], antigravity: ['Gemini 4 Carbon'] };
30
+ export const HEAVY_MODELS = Object.fromEntries(['claude', 'codex', 'antigravity'].map((provider) => [
31
+ provider,
32
+ Object.entries(MODELS).filter(([, model]) => model.provider === provider && model.scarceQuota).map(([id]) => id),
33
+ ]));
30
34
  const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
31
35
 
32
36
  /** "claude:max,codex:pro:monday" to { claude: { plan, sharing, resetDay?, heavyModels }, ... }. */