@caddis/cli 0.2.6 → 0.3.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.
Files changed (51) hide show
  1. package/bundles/antigravity-plugin/agents/claude-md-curator.md +1 -1
  2. package/bundles/antigravity-plugin/caddis_statusline.py +803 -0
  3. package/bundles/antigravity-plugin/claude-md/folder-agents.md.tmpl +21 -0
  4. package/bundles/antigravity-plugin/guard_agy.py +23 -4
  5. package/bundles/antigravity-plugin/plugin.json +1 -1
  6. package/bundles/antigravity-plugin/scripts/caddis_gate.py +524 -0
  7. package/bundles/antigravity-plugin/scripts/caddis_inventory.py +369 -0
  8. package/bundles/antigravity-plugin/scripts/caddis_migrate_dir.py +270 -0
  9. package/bundles/antigravity-plugin/scripts/caddis_spawn.py +300 -0
  10. package/bundles/antigravity-plugin/scripts/caddis_statusline.py +803 -0
  11. package/bundles/antigravity-plugin/scripts/caddis_tidy.py +366 -0
  12. package/bundles/antigravity-plugin/scripts/check_doc_coverage.py +924 -0
  13. package/bundles/antigravity-plugin/scripts/claude-deepseek.ps1 +4 -0
  14. package/bundles/antigravity-plugin/scripts/claude-deepseek.sh +3 -0
  15. package/bundles/antigravity-plugin/scripts/claude-glm.ps1 +4 -0
  16. package/bundles/antigravity-plugin/scripts/claude-glm.sh +3 -0
  17. package/bundles/antigravity-plugin/scripts/claude-oss.ps1 +64 -0
  18. package/bundles/antigravity-plugin/scripts/claude-oss.sh +60 -0
  19. package/bundles/antigravity-plugin/scripts/claudster_config.py +126 -0
  20. package/bundles/antigravity-plugin/scripts/claudster_doctor.py +356 -0
  21. package/bundles/antigravity-plugin/scripts/claudster_init.py +400 -0
  22. package/bundles/antigravity-plugin/scripts/claudster_migrate_rules.py +300 -0
  23. package/bundles/antigravity-plugin/scripts/dream_capture.py +249 -0
  24. package/bundles/antigravity-plugin/scripts/dream_memory.py +438 -0
  25. package/bundles/antigravity-plugin/scripts/enforcement_inventory.py +261 -0
  26. package/bundles/antigravity-plugin/scripts/hook_log.py +156 -0
  27. package/bundles/antigravity-plugin/scripts/oss_ask.py +98 -0
  28. package/bundles/antigravity-plugin/scripts/oss_model.py +166 -0
  29. package/bundles/antigravity-plugin/scripts/oss_review.py +718 -0
  30. package/bundles/antigravity-plugin/scripts/setup_project_ai.py +1429 -0
  31. package/bundles/antigravity-plugin/scripts/usage_review.py +1323 -0
  32. package/bundles/antigravity-plugin/session_end_agy.py +21 -2
  33. package/bundles/antigravity-plugin/skills/_registry.md +1 -0
  34. package/bundles/antigravity-plugin/skills/fastapi-dev/SKILL.md +1 -1
  35. package/bundles/antigravity-plugin/skills/ship/SKILL.md +1 -1
  36. package/bundles/antigravity-plugin/skills/ship-merge/SKILL.md +1 -1
  37. package/bundles/antigravity-plugin/skills/ship-pr/SKILL.md +1 -1
  38. package/bundles/antigravity-plugin/skills/statusline/SKILL.md +105 -0
  39. package/bundles/antigravity-plugin/skills/use-model/SKILL.md +15 -3
  40. package/bundles/antigravity-plugin/warm_start_agy.py +21 -2
  41. package/bundles/antigravity-plugin-extras/plugin.json +1 -1
  42. package/bundles/antigravity-plugin-extras/skills/architecture-design/SKILL.md +1 -1
  43. package/bundles/antigravity-plugin-extras/skills/caching-patterns/SKILL.md +1 -1
  44. package/bundles/antigravity-plugin-extras/skills/webapp-development/SKILL.md +1 -1
  45. package/bundles/manifest.json +3 -3
  46. package/dist/claude-deepseek.js +544 -0
  47. package/dist/claude-glm.js +544 -0
  48. package/dist/claude-oss.js +544 -0
  49. package/dist/cli.js +365 -44
  50. package/package.json +5 -2
  51. package/bundles/antigravity-plugin/statusline-command-agy.sh +0 -91
@@ -0,0 +1,544 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __caddisCreateRequire } from 'node:module';
3
+ const require = __caddisCreateRequire(import.meta.url);
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
+ });
16
+ var __commonJS = (cb, mod) => function __require2() {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
33
+ mod
34
+ ));
35
+
36
+ // node_modules/picocolors/picocolors.js
37
+ var require_picocolors = __commonJS({
38
+ "node_modules/picocolors/picocolors.js"(exports, module) {
39
+ "use strict";
40
+ var p = process || {};
41
+ var argv = p.argv || [];
42
+ var env = p.env || {};
43
+ var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
44
+ var formatter = (open, close, replace = open) => (input) => {
45
+ let string = "" + input, index = string.indexOf(close, open.length);
46
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
47
+ };
48
+ var replaceClose = (string, close, replace, index) => {
49
+ let result = "", cursor = 0;
50
+ do {
51
+ result += string.substring(cursor, index) + replace;
52
+ cursor = index + close.length;
53
+ index = string.indexOf(close, cursor);
54
+ } while (~index);
55
+ return result + string.substring(cursor);
56
+ };
57
+ var createColors = (enabled = isColorSupported) => {
58
+ let f = enabled ? formatter : () => String;
59
+ return {
60
+ isColorSupported: enabled,
61
+ reset: f("\x1B[0m", "\x1B[0m"),
62
+ bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
63
+ dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
64
+ italic: f("\x1B[3m", "\x1B[23m"),
65
+ underline: f("\x1B[4m", "\x1B[24m"),
66
+ inverse: f("\x1B[7m", "\x1B[27m"),
67
+ hidden: f("\x1B[8m", "\x1B[28m"),
68
+ strikethrough: f("\x1B[9m", "\x1B[29m"),
69
+ black: f("\x1B[30m", "\x1B[39m"),
70
+ red: f("\x1B[31m", "\x1B[39m"),
71
+ green: f("\x1B[32m", "\x1B[39m"),
72
+ yellow: f("\x1B[33m", "\x1B[39m"),
73
+ blue: f("\x1B[34m", "\x1B[39m"),
74
+ magenta: f("\x1B[35m", "\x1B[39m"),
75
+ cyan: f("\x1B[36m", "\x1B[39m"),
76
+ white: f("\x1B[37m", "\x1B[39m"),
77
+ gray: f("\x1B[90m", "\x1B[39m"),
78
+ bgBlack: f("\x1B[40m", "\x1B[49m"),
79
+ bgRed: f("\x1B[41m", "\x1B[49m"),
80
+ bgGreen: f("\x1B[42m", "\x1B[49m"),
81
+ bgYellow: f("\x1B[43m", "\x1B[49m"),
82
+ bgBlue: f("\x1B[44m", "\x1B[49m"),
83
+ bgMagenta: f("\x1B[45m", "\x1B[49m"),
84
+ bgCyan: f("\x1B[46m", "\x1B[49m"),
85
+ bgWhite: f("\x1B[47m", "\x1B[49m"),
86
+ blackBright: f("\x1B[90m", "\x1B[39m"),
87
+ redBright: f("\x1B[91m", "\x1B[39m"),
88
+ greenBright: f("\x1B[92m", "\x1B[39m"),
89
+ yellowBright: f("\x1B[93m", "\x1B[39m"),
90
+ blueBright: f("\x1B[94m", "\x1B[39m"),
91
+ magentaBright: f("\x1B[95m", "\x1B[39m"),
92
+ cyanBright: f("\x1B[96m", "\x1B[39m"),
93
+ whiteBright: f("\x1B[97m", "\x1B[39m"),
94
+ bgBlackBright: f("\x1B[100m", "\x1B[49m"),
95
+ bgRedBright: f("\x1B[101m", "\x1B[49m"),
96
+ bgGreenBright: f("\x1B[102m", "\x1B[49m"),
97
+ bgYellowBright: f("\x1B[103m", "\x1B[49m"),
98
+ bgBlueBright: f("\x1B[104m", "\x1B[49m"),
99
+ bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
100
+ bgCyanBright: f("\x1B[106m", "\x1B[49m"),
101
+ bgWhiteBright: f("\x1B[107m", "\x1B[49m")
102
+ };
103
+ };
104
+ module.exports = createColors();
105
+ module.exports.createColors = createColors;
106
+ }
107
+ });
108
+
109
+ // node_modules/isexe/dist/commonjs/index.min.js
110
+ var require_index_min = __commonJS({
111
+ "node_modules/isexe/dist/commonjs/index.min.js"(exports) {
112
+ "use strict";
113
+ var a = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
114
+ var _ = a((i) => {
115
+ "use strict";
116
+ Object.defineProperty(i, "__esModule", { value: true });
117
+ i.sync = i.isexe = void 0;
118
+ var M = __require("fs"), x = __require("fs/promises"), q = async (t, e = {}) => {
119
+ let { ignoreErrors: r = false } = e;
120
+ try {
121
+ return d(await (0, x.stat)(t), e);
122
+ } catch (s) {
123
+ let n = s;
124
+ if (r || n.code === "EACCES") return false;
125
+ throw n;
126
+ }
127
+ };
128
+ i.isexe = q;
129
+ var m = (t, e = {}) => {
130
+ let { ignoreErrors: r = false } = e;
131
+ try {
132
+ return d((0, M.statSync)(t), e);
133
+ } catch (s) {
134
+ let n = s;
135
+ if (r || n.code === "EACCES") return false;
136
+ throw n;
137
+ }
138
+ };
139
+ i.sync = m;
140
+ var d = (t, e) => t.isFile() && A(t, e), A = (t, e) => {
141
+ let r = e.uid ?? process.getuid?.(), s = e.groups ?? process.getgroups?.() ?? [], n = e.gid ?? process.getgid?.() ?? s[0];
142
+ if (r === void 0 || n === void 0) throw new Error("cannot get uid or gid");
143
+ let u = /* @__PURE__ */ new Set([n, ...s]), c = t.mode, S = t.uid, P = t.gid, f = parseInt("100", 8), l = parseInt("010", 8), j = parseInt("001", 8), C = f | l;
144
+ return !!(c & j || c & l && u.has(P) || c & f && S === r || c & C && r === 0);
145
+ };
146
+ });
147
+ var g = a((o) => {
148
+ "use strict";
149
+ Object.defineProperty(o, "__esModule", { value: true });
150
+ o.sync = o.isexe = void 0;
151
+ var T = __require("fs"), I = __require("fs/promises"), D = __require("path"), F = async (t, e = {}) => {
152
+ let { ignoreErrors: r = false } = e;
153
+ try {
154
+ return y(await (0, I.stat)(t), t, e);
155
+ } catch (s) {
156
+ let n = s;
157
+ if (r || n.code === "EACCES") return false;
158
+ throw n;
159
+ }
160
+ };
161
+ o.isexe = F;
162
+ var L = (t, e = {}) => {
163
+ let { ignoreErrors: r = false } = e;
164
+ try {
165
+ return y((0, T.statSync)(t), t, e);
166
+ } catch (s) {
167
+ let n = s;
168
+ if (r || n.code === "EACCES") return false;
169
+ throw n;
170
+ }
171
+ };
172
+ o.sync = L;
173
+ var B = (t, e) => {
174
+ let { pathExt: r = process.env.PATHEXT || "" } = e, s = r.split(D.delimiter);
175
+ if (s.indexOf("") !== -1) return true;
176
+ for (let n of s) {
177
+ let u = n.toLowerCase(), c = t.substring(t.length - u.length).toLowerCase();
178
+ if (u && c === u) return true;
179
+ }
180
+ return false;
181
+ }, y = (t, e, r) => t.isFile() && B(e, r);
182
+ });
183
+ var p = a((h) => {
184
+ "use strict";
185
+ Object.defineProperty(h, "__esModule", { value: true });
186
+ });
187
+ var v = exports && exports.__createBinding || (Object.create ? (function(t, e, r, s) {
188
+ s === void 0 && (s = r);
189
+ var n = Object.getOwnPropertyDescriptor(e, r);
190
+ (!n || ("get" in n ? !e.__esModule : n.writable || n.configurable)) && (n = { enumerable: true, get: function() {
191
+ return e[r];
192
+ } }), Object.defineProperty(t, s, n);
193
+ }) : (function(t, e, r, s) {
194
+ s === void 0 && (s = r), t[s] = e[r];
195
+ }));
196
+ var G = exports && exports.__setModuleDefault || (Object.create ? (function(t, e) {
197
+ Object.defineProperty(t, "default", { enumerable: true, value: e });
198
+ }) : function(t, e) {
199
+ t.default = e;
200
+ });
201
+ var w = exports && exports.__importStar || /* @__PURE__ */ (function() {
202
+ var t = function(e) {
203
+ return t = Object.getOwnPropertyNames || function(r) {
204
+ var s = [];
205
+ for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (s[s.length] = n);
206
+ return s;
207
+ }, t(e);
208
+ };
209
+ return function(e) {
210
+ if (e && e.__esModule) return e;
211
+ var r = {};
212
+ if (e != null) for (var s = t(e), n = 0; n < s.length; n++) s[n] !== "default" && v(r, e, s[n]);
213
+ return G(r, e), r;
214
+ };
215
+ })();
216
+ var X = exports && exports.__exportStar || function(t, e) {
217
+ for (var r in t) r !== "default" && !Object.prototype.hasOwnProperty.call(e, r) && v(e, t, r);
218
+ };
219
+ Object.defineProperty(exports, "__esModule", { value: true });
220
+ exports.sync = exports.isexe = exports.posix = exports.win32 = void 0;
221
+ var E = w(_());
222
+ exports.posix = E;
223
+ var O = w(g());
224
+ exports.win32 = O;
225
+ X(p(), exports);
226
+ var H = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
227
+ var b = H === "win32" ? O : E;
228
+ exports.isexe = b.isexe;
229
+ exports.sync = b.sync;
230
+ }
231
+ });
232
+
233
+ // node_modules/which/lib/index.js
234
+ var require_lib = __commonJS({
235
+ "node_modules/which/lib/index.js"(exports, module) {
236
+ "use strict";
237
+ var { isexe, sync: isexeSync } = require_index_min();
238
+ var { join: join2, delimiter, sep, posix } = __require("path");
239
+ var isWindows = process.platform === "win32";
240
+ var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
241
+ var rRel = new RegExp(`^\\.${rSlash.source}`);
242
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
243
+ var getPathInfo = (cmd, {
244
+ path: optPath = process.env.PATH,
245
+ pathExt: optPathExt = process.env.PATHEXT,
246
+ delimiter: optDelimiter = delimiter
247
+ }) => {
248
+ const pathEnv = cmd.match(rSlash) ? [""] : [
249
+ // windows always checks the cwd first
250
+ ...isWindows ? [process.cwd()] : [],
251
+ ...(optPath || /* istanbul ignore next: very unusual */
252
+ "").split(optDelimiter)
253
+ ];
254
+ if (isWindows) {
255
+ const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
256
+ const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]);
257
+ if (cmd.includes(".") && pathExt[0] !== "") {
258
+ pathExt.unshift("");
259
+ }
260
+ return { pathEnv, pathExt, pathExtExe };
261
+ }
262
+ return { pathEnv, pathExt: [""] };
263
+ };
264
+ var getPathPart = (raw, cmd) => {
265
+ const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
266
+ const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
267
+ return prefix + join2(pathPart, cmd);
268
+ };
269
+ var which = async (cmd, opt = {}) => {
270
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
271
+ const found = [];
272
+ for (const envPart of pathEnv) {
273
+ const p = getPathPart(envPart, cmd);
274
+ for (const ext of pathExt) {
275
+ const withExt = p + ext;
276
+ const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
277
+ if (is) {
278
+ if (!opt.all) {
279
+ return withExt;
280
+ }
281
+ found.push(withExt);
282
+ }
283
+ }
284
+ }
285
+ if (opt.all && found.length) {
286
+ return found;
287
+ }
288
+ if (opt.nothrow) {
289
+ return null;
290
+ }
291
+ throw getNotFoundError(cmd);
292
+ };
293
+ var whichSync = (cmd, opt = {}) => {
294
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
295
+ const found = [];
296
+ for (const pathEnvPart of pathEnv) {
297
+ const p = getPathPart(pathEnvPart, cmd);
298
+ for (const ext of pathExt) {
299
+ const withExt = p + ext;
300
+ const is = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
301
+ if (is) {
302
+ if (!opt.all) {
303
+ return withExt;
304
+ }
305
+ found.push(withExt);
306
+ }
307
+ }
308
+ }
309
+ if (opt.all && found.length) {
310
+ return found;
311
+ }
312
+ if (opt.nothrow) {
313
+ return null;
314
+ }
315
+ throw getNotFoundError(cmd);
316
+ };
317
+ module.exports = which;
318
+ which.sync = whichSync;
319
+ }
320
+ });
321
+
322
+ // src/providers/resolve.ts
323
+ import { readFileSync } from "fs";
324
+ import { homedir } from "os";
325
+ import { isAbsolute, join } from "path";
326
+ var PROVIDERS = {
327
+ deepseek: {
328
+ baseUrl: "https://api.deepseek.com/anthropic",
329
+ model: "deepseek-v4-flash",
330
+ keyEnv: "DEEPSEEK_API_KEY"
331
+ },
332
+ glm: {
333
+ baseUrl: "https://api.z.ai/api/anthropic",
334
+ model: "glm-5.2",
335
+ keyEnv: "GLM_API_KEY"
336
+ },
337
+ // OpenRouter has no Anthropic-protocol endpoint. It works only through an
338
+ // Anthropic-compatible gateway (e.g. LiteLLM — see claude-harness/LOCAL-MODELS.md)
339
+ // whose URL you supply via OSS_BASE_URL.
340
+ openrouter: {
341
+ baseUrl: "",
342
+ model: "deepseek/deepseek-v4-flash",
343
+ keyEnv: "OPENROUTER_API_KEY"
344
+ }
345
+ };
346
+ var DEFAULT_PROVIDER = "deepseek";
347
+ var DEFAULT_KEYS_FILE = "~/.caddis/keys.env";
348
+ var KEYS_FILE_ENV = "CADDIS_KEYS_FILE";
349
+ var ConfigError = class extends Error {
350
+ };
351
+ function expandHome(p) {
352
+ if (p === "~") return homedir();
353
+ if (p.startsWith("~/") || p.startsWith("~\\")) return join(homedir(), p.slice(2));
354
+ return p;
355
+ }
356
+ function keysFilePath(env) {
357
+ const configured = (env[KEYS_FILE_ENV] || "").trim() || DEFAULT_KEYS_FILE;
358
+ const expanded = expandHome(configured);
359
+ return isAbsolute(expanded) ? expanded : expanded;
360
+ }
361
+ function parseKeysFile(path) {
362
+ let text;
363
+ try {
364
+ text = readFileSync(path, "utf8");
365
+ } catch {
366
+ return {};
367
+ }
368
+ const out = {};
369
+ for (const raw of text.split(/\r?\n/)) {
370
+ const line = raw.trim();
371
+ if (!line || line.startsWith("#") || !line.includes("=")) continue;
372
+ const idx = line.indexOf("=");
373
+ const key = line.slice(0, idx).trim();
374
+ let val = line.slice(idx + 1).trim();
375
+ if (val.length >= 2 && (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'"))) {
376
+ val = val.slice(1, -1);
377
+ }
378
+ out[key] = val;
379
+ }
380
+ return out;
381
+ }
382
+ function configuredProviders(env) {
383
+ const fileKeys = parseKeysFile(keysFilePath(env));
384
+ const generic = (env.OSS_API_KEY || fileKeys.OSS_API_KEY || "").trim();
385
+ const out = [];
386
+ for (const name of Object.keys(PROVIDERS).sort()) {
387
+ const keyEnv = PROVIDERS[name].keyEnv;
388
+ if (generic || (env[keyEnv] || "").trim() || (fileKeys[keyEnv] || "").trim()) out.push(name);
389
+ }
390
+ return out;
391
+ }
392
+ function resolveKey(provider, keyEnv, env) {
393
+ for (const name of [keyEnv, "OSS_API_KEY"]) {
394
+ const val = (env[name] || "").trim();
395
+ if (val) return val;
396
+ }
397
+ const keysPath = keysFilePath(env);
398
+ const fileKeys = parseKeysFile(keysPath);
399
+ for (const name of [keyEnv, "OSS_API_KEY"]) {
400
+ const val = (fileKeys[name] || "").trim();
401
+ if (val) return val;
402
+ }
403
+ const others = configuredProviders(env).filter((p) => p !== provider);
404
+ const have = others.length ? `
405
+ Providers that DO have a key here: ${others.join(", ")}. To use one now: claude-${others[0]}.` : "\nRun `caddis keys` to add one.";
406
+ throw new ConfigError(
407
+ `no API key for provider '${provider}'. Set $${keyEnv} (or $OSS_API_KEY), or add
408
+ ${keyEnv}=<your-key>
409
+ to your keys file (${keysPath}). Override the file path with $${KEYS_FILE_ENV}.` + have
410
+ );
411
+ }
412
+ function resolve(provider, env) {
413
+ const name = (provider || env.OSS_PROVIDER || DEFAULT_PROVIDER).trim().toLowerCase();
414
+ const preset = PROVIDERS[name];
415
+ const baseUrl = (env.OSS_BASE_URL || "").trim() || preset?.baseUrl || "";
416
+ const model = (env.OSS_MODEL || "").trim() || preset?.model || "";
417
+ if (!preset && (!baseUrl || !model)) {
418
+ throw new ConfigError(
419
+ `unknown provider '${name}'. Known: ${Object.keys(PROVIDERS).sort().join(", ")}.
420
+ For anything else, supply both $OSS_BASE_URL and $OSS_MODEL (an Anthropic-protocol
421
+ endpoint \u2014 see claude-harness/LOCAL-MODELS.md for the gateway setup).`
422
+ );
423
+ }
424
+ if (!baseUrl || !model) {
425
+ throw new ConfigError(
426
+ `provider '${name}' has no ${!baseUrl ? "base_url" : "model"}. Supply $OSS_BASE_URL and $OSS_MODEL, or pick another provider.`
427
+ );
428
+ }
429
+ const keyEnv = preset?.keyEnv || `${name.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_API_KEY`;
430
+ return { provider: name, baseUrl, model, apiKey: resolveKey(name, keyEnv, env) };
431
+ }
432
+ function maskKey(key) {
433
+ if (!key) return "(none)";
434
+ return key.length <= 4 ? "*".repeat(key.length) : `${"*".repeat(8)}${key.slice(-4)}`;
435
+ }
436
+
437
+ // src/util/log.ts
438
+ var import_picocolors = __toESM(require_picocolors(), 1);
439
+ var OK = import_picocolors.default.green("OK");
440
+ var WARN = import_picocolors.default.yellow("!!");
441
+ var FAIL = import_picocolors.default.red("XX");
442
+ var SKIP = import_picocolors.default.dim("--");
443
+ var MARKS = {
444
+ ok: import_picocolors.default.green("\u2713"),
445
+ warn: import_picocolors.default.yellow("\u25B2"),
446
+ fail: import_picocolors.default.red("\u2717"),
447
+ skip: import_picocolors.default.dim("\xB7"),
448
+ info: import_picocolors.default.cyan("\u2022")
449
+ };
450
+ function errorLine(text) {
451
+ process.stderr.write(`${import_picocolors.default.red("error")} ${text}
452
+ `);
453
+ }
454
+
455
+ // src/util/which.ts
456
+ var import_which = __toESM(require_lib(), 1);
457
+ async function findBin(name) {
458
+ try {
459
+ const found = await (0, import_which.default)(name, { nothrow: true });
460
+ return found ?? null;
461
+ } catch {
462
+ return null;
463
+ }
464
+ }
465
+
466
+ // src/lanes/launch.ts
467
+ function isHeadless(args) {
468
+ return args.some((a) => a === "-p" || a === "--print");
469
+ }
470
+ async function launch(options) {
471
+ const env = options.env ?? process.env;
472
+ const args = options.args;
473
+ const printConfig = args.includes("--print-config");
474
+ const forwarded = args.filter((a) => a !== "--print-config");
475
+ let resolved;
476
+ try {
477
+ resolved = resolve(options.provider, env);
478
+ } catch (error) {
479
+ if (error instanceof ConfigError) {
480
+ errorLine(error.message);
481
+ return 3;
482
+ }
483
+ throw error;
484
+ }
485
+ if (printConfig) {
486
+ process.stdout.write(
487
+ `provider ${resolved.provider}
488
+ base_url ${resolved.baseUrl}
489
+ model ${resolved.model}
490
+ api_key ${maskKey(resolved.apiKey)}
491
+ `
492
+ );
493
+ return 0;
494
+ }
495
+ const claude = await findBin("claude");
496
+ if (!claude) {
497
+ errorLine(
498
+ "claude is not on PATH. The lanes drive Claude Code itself \u2014 install it first:\n npm i -g @anthropic-ai/claude-code"
499
+ );
500
+ return 127;
501
+ }
502
+ const childEnv = {
503
+ ...env,
504
+ ANTHROPIC_BASE_URL: resolved.baseUrl,
505
+ ANTHROPIC_MODEL: resolved.model,
506
+ ANTHROPIC_AUTH_TOKEN: resolved.apiKey
507
+ };
508
+ if (isHeadless(forwarded)) childEnv.CADDIS_HEADLESS = "1";
509
+ const { execa } = await import("execa");
510
+ try {
511
+ const result = await execa(claude, forwarded, {
512
+ env: childEnv,
513
+ extendEnv: false,
514
+ stdio: "inherit",
515
+ reject: false,
516
+ windowsHide: true
517
+ // No timeout: this is an interactive session, however long the user wants it.
518
+ });
519
+ if (typeof result.exitCode === "number") return result.exitCode;
520
+ return result.failed ? 1 : 0;
521
+ } catch (error) {
522
+ errorLine(`could not start claude: ${error instanceof Error ? error.message : String(error)}`);
523
+ return 127;
524
+ }
525
+ }
526
+ async function laneMain(fixedProvider, argv) {
527
+ let provider = fixedProvider;
528
+ let args = argv;
529
+ if (!fixedProvider) {
530
+ const first = argv[0];
531
+ if (!first || first.startsWith("-")) {
532
+ errorLine(
533
+ "usage: claude-oss <provider> [claude args...]\n providers: deepseek, glm, openrouter\n or use the direct lanes: claude-glm, claude-deepseek"
534
+ );
535
+ return 2;
536
+ }
537
+ provider = first;
538
+ args = argv.slice(1);
539
+ }
540
+ return await launch({ provider, args });
541
+ }
542
+
543
+ // src/lanes/claude-deepseek.ts
544
+ process.exitCode = await laneMain("deepseek", process.argv.slice(2));