airband 0.0.1 → 0.0.2
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 +1 -1
- package/airband-hook.js +152 -54
- package/airband-mcp.js +104 -96
- package/airband.js +273 -219
- package/package.json +1 -1
package/airband.js
CHANGED
|
@@ -2137,11 +2137,11 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
2137
2137
|
throw toThrow;
|
|
2138
2138
|
}, "quit_");
|
|
2139
2139
|
var scriptDirectory = "";
|
|
2140
|
-
function locateFile(
|
|
2140
|
+
function locateFile(path19) {
|
|
2141
2141
|
if (Module["locateFile"]) {
|
|
2142
|
-
return Module["locateFile"](
|
|
2142
|
+
return Module["locateFile"](path19, scriptDirectory);
|
|
2143
2143
|
}
|
|
2144
|
-
return scriptDirectory +
|
|
2144
|
+
return scriptDirectory + path19;
|
|
2145
2145
|
}
|
|
2146
2146
|
__name(locateFile, "locateFile");
|
|
2147
2147
|
var readAsync, readBinary;
|
|
@@ -4102,8 +4102,8 @@ init_define_AIRBAND_GRAMMARS();
|
|
|
4102
4102
|
// src/cli/main.ts
|
|
4103
4103
|
init_define_AIRBAND_GRAMMARS();
|
|
4104
4104
|
var import_node_child_process5 = require("node:child_process");
|
|
4105
|
-
var
|
|
4106
|
-
var
|
|
4105
|
+
var fs21 = __toESM(require("node:fs"));
|
|
4106
|
+
var path18 = __toESM(require("node:path"));
|
|
4107
4107
|
|
|
4108
4108
|
// src/core/paths.ts
|
|
4109
4109
|
init_define_AIRBAND_GRAMMARS();
|
|
@@ -4161,11 +4161,18 @@ function writeFileAtomic(file, text) {
|
|
|
4161
4161
|
throw err2;
|
|
4162
4162
|
}
|
|
4163
4163
|
}
|
|
4164
|
+
function readJson(file, fallback) {
|
|
4165
|
+
try {
|
|
4166
|
+
return JSON.parse(fs2.readFileSync(file, "utf8"));
|
|
4167
|
+
} catch {
|
|
4168
|
+
return fallback;
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4164
4171
|
|
|
4165
4172
|
// src/codemap/index.ts
|
|
4166
4173
|
init_define_AIRBAND_GRAMMARS();
|
|
4167
|
-
var
|
|
4168
|
-
var
|
|
4174
|
+
var fs9 = __toESM(require("node:fs"));
|
|
4175
|
+
var path8 = __toESM(require("node:path"));
|
|
4169
4176
|
|
|
4170
4177
|
// src/codemap/extract.ts
|
|
4171
4178
|
init_define_AIRBAND_GRAMMARS();
|
|
@@ -4419,8 +4426,8 @@ var TABLES = {
|
|
|
4419
4426
|
if (f?.type === "identifier") return [void 0, f.text];
|
|
4420
4427
|
if (f?.type === "scoped_identifier") {
|
|
4421
4428
|
const name2 = field(f, "name")?.text;
|
|
4422
|
-
const
|
|
4423
|
-
if (
|
|
4429
|
+
const path19 = field(f, "path")?.text.split("::").pop();
|
|
4430
|
+
if (path19 && /^[A-Z]\w*$/.test(path19)) return [void 0, path19];
|
|
4424
4431
|
if (name2) return [void 0, name2];
|
|
4425
4432
|
}
|
|
4426
4433
|
}
|
|
@@ -6069,12 +6076,17 @@ function makeResolver(root, files) {
|
|
|
6069
6076
|
|
|
6070
6077
|
// src/codemap/store.ts
|
|
6071
6078
|
init_define_AIRBAND_GRAMMARS();
|
|
6079
|
+
var crypto5 = __toESM(require("node:crypto"));
|
|
6080
|
+
var fs8 = __toESM(require("node:fs"));
|
|
6081
|
+
var path7 = __toESM(require("node:path"));
|
|
6082
|
+
var zlib = __toESM(require("node:zlib"));
|
|
6083
|
+
var import_node_child_process = require("node:child_process");
|
|
6084
|
+
|
|
6085
|
+
// src/codemap/where.ts
|
|
6086
|
+
init_define_AIRBAND_GRAMMARS();
|
|
6072
6087
|
var crypto4 = __toESM(require("node:crypto"));
|
|
6073
6088
|
var fs7 = __toESM(require("node:fs"));
|
|
6074
6089
|
var path6 = __toESM(require("node:path"));
|
|
6075
|
-
var zlib = __toESM(require("node:zlib"));
|
|
6076
|
-
var import_node_child_process = require("node:child_process");
|
|
6077
|
-
var STORE_VERSION = 1;
|
|
6078
6090
|
function folderId(root) {
|
|
6079
6091
|
let real = root;
|
|
6080
6092
|
try {
|
|
@@ -6087,14 +6099,17 @@ function folderId(root) {
|
|
|
6087
6099
|
function storeDir(root) {
|
|
6088
6100
|
return airbandFile("codemap", folderId(root));
|
|
6089
6101
|
}
|
|
6090
|
-
|
|
6091
|
-
|
|
6102
|
+
|
|
6103
|
+
// src/codemap/store.ts
|
|
6104
|
+
var STORE_VERSION = 1;
|
|
6105
|
+
var filesPath = (root) => path7.join(storeDir(root), "files.jsonl.gz");
|
|
6106
|
+
var metaPath = (root) => path7.join(storeDir(root), "meta.json");
|
|
6092
6107
|
function loadEntries(root) {
|
|
6093
6108
|
const out3 = /* @__PURE__ */ new Map();
|
|
6094
6109
|
try {
|
|
6095
|
-
const meta = JSON.parse(
|
|
6110
|
+
const meta = JSON.parse(fs8.readFileSync(metaPath(root), "utf8"));
|
|
6096
6111
|
if (meta.v !== STORE_VERSION) return out3;
|
|
6097
|
-
const text = zlib.gunzipSync(
|
|
6112
|
+
const text = zlib.gunzipSync(fs8.readFileSync(filesPath(root))).toString("utf8");
|
|
6098
6113
|
for (const line of text.split("\n")) {
|
|
6099
6114
|
if (!line) continue;
|
|
6100
6115
|
try {
|
|
@@ -6115,24 +6130,24 @@ function saveEntries(root, entries) {
|
|
|
6115
6130
|
files++;
|
|
6116
6131
|
}
|
|
6117
6132
|
const gz = zlib.gzipSync(lines.join("\n"), { level: 6 });
|
|
6118
|
-
|
|
6133
|
+
fs8.mkdirSync(storeDir(root), { recursive: true });
|
|
6119
6134
|
const tmp = `${filesPath(root)}.${process.pid}.${Date.now()}.tmp`;
|
|
6120
|
-
|
|
6121
|
-
|
|
6135
|
+
fs8.writeFileSync(tmp, gz);
|
|
6136
|
+
fs8.renameSync(tmp, filesPath(root));
|
|
6122
6137
|
const meta = { v: STORE_VERSION, root, builtAt: Date.now(), files, bytes: gz.length };
|
|
6123
6138
|
writeFileAtomic(metaPath(root), JSON.stringify(meta));
|
|
6124
6139
|
return meta;
|
|
6125
6140
|
}
|
|
6126
6141
|
function readMeta(root) {
|
|
6127
6142
|
try {
|
|
6128
|
-
const meta = JSON.parse(
|
|
6143
|
+
const meta = JSON.parse(fs8.readFileSync(metaPath(root), "utf8"));
|
|
6129
6144
|
return meta.v === STORE_VERSION ? meta : void 0;
|
|
6130
6145
|
} catch {
|
|
6131
6146
|
return void 0;
|
|
6132
6147
|
}
|
|
6133
6148
|
}
|
|
6134
6149
|
function contentHash(text) {
|
|
6135
|
-
return
|
|
6150
|
+
return crypto5.createHash("sha1").update(text).digest("hex").slice(0, 16);
|
|
6136
6151
|
}
|
|
6137
6152
|
var SKIP_DIR = /(^|\/)(node_modules|\.git|\.next|\.nuxt|\.svelte-kit|\.turbo|\.vercel|\.cache|dist|build|out|out-test|coverage|vendor|venv|\.venv|env|__pycache__|\.mypy_cache|\.pytest_cache|\.tox|site-packages|bower_components|\.airband|\.context|\.claude|\.codex|\.gemini|storybook-static|playwright-report|test-results)(\/|$)/;
|
|
6138
6153
|
var SKIP_FILE = /(\.min\.(js|mjs|cjs)|\.bundle\.js|\.chunk\.js|-lock\.json|\.map|\.generated\.(ts|js)|\.gen\.(ts|js)|_pb2(_grpc)?\.py)$/;
|
|
@@ -6155,14 +6170,14 @@ async function listFiles(root) {
|
|
|
6155
6170
|
if (depth > 20 || out3.length > 5e4) return;
|
|
6156
6171
|
let items;
|
|
6157
6172
|
try {
|
|
6158
|
-
items =
|
|
6173
|
+
items = fs8.readdirSync(dir, { withFileTypes: true });
|
|
6159
6174
|
} catch {
|
|
6160
6175
|
return;
|
|
6161
6176
|
}
|
|
6162
6177
|
for (const it of items) {
|
|
6163
6178
|
const r = rel ? `${rel}/${it.name}` : it.name;
|
|
6164
6179
|
if (it.isDirectory()) {
|
|
6165
|
-
if (!SKIP_DIR.test(`${r}/`) && !it.name.startsWith(".")) walk2(
|
|
6180
|
+
if (!SKIP_DIR.test(`${r}/`) && !it.name.startsWith(".")) walk2(path7.join(dir, it.name), r, depth + 1);
|
|
6166
6181
|
} else if (it.isFile() && mappable(r)) out3.push(r);
|
|
6167
6182
|
}
|
|
6168
6183
|
};
|
|
@@ -6239,7 +6254,7 @@ var CodeMap = class {
|
|
|
6239
6254
|
nameExists(name2) {
|
|
6240
6255
|
this.load();
|
|
6241
6256
|
const rel = name2.replace(/^\.\//, "");
|
|
6242
|
-
if (this.files.has(rel) ||
|
|
6257
|
+
if (this.files.has(rel) || fs9.existsSync(path8.join(this.root, rel))) return true;
|
|
6243
6258
|
for (const f of this.files.values()) if (f.d.some((d) => d.n === name2)) return true;
|
|
6244
6259
|
return false;
|
|
6245
6260
|
}
|
|
@@ -6290,7 +6305,7 @@ var CodeMap = class {
|
|
|
6290
6305
|
let removed = 0;
|
|
6291
6306
|
const listing = full || !this.files.size || Date.now() - this.lastListed > LIST_EVERY_MS || this.foldersChanged();
|
|
6292
6307
|
if (changed && !full) {
|
|
6293
|
-
paths = changed.map((p) => (
|
|
6308
|
+
paths = changed.map((p) => (path8.isAbsolute(p) ? path8.relative(this.root, p) : p).split(path8.sep).join("/")).filter((p) => !p.startsWith(".."));
|
|
6294
6309
|
} else if (listing) {
|
|
6295
6310
|
paths = await listFiles(this.root);
|
|
6296
6311
|
this.lastListed = Date.now();
|
|
@@ -6311,10 +6326,10 @@ var CodeMap = class {
|
|
|
6311
6326
|
let lastYield = Date.now();
|
|
6312
6327
|
for (const p of paths) {
|
|
6313
6328
|
if (!langOf(p)) continue;
|
|
6314
|
-
const abs =
|
|
6329
|
+
const abs = path8.join(this.root, p);
|
|
6315
6330
|
let st;
|
|
6316
6331
|
try {
|
|
6317
|
-
st =
|
|
6332
|
+
st = fs9.lstatSync(abs);
|
|
6318
6333
|
} catch {
|
|
6319
6334
|
if (this.files.delete(p)) removed++;
|
|
6320
6335
|
continue;
|
|
@@ -6327,7 +6342,7 @@ var CodeMap = class {
|
|
|
6327
6342
|
if (prev && prev.z === st.size && prev.m === Math.floor(st.mtimeMs)) continue;
|
|
6328
6343
|
let text;
|
|
6329
6344
|
try {
|
|
6330
|
-
text =
|
|
6345
|
+
text = fs9.readFileSync(abs, "utf8");
|
|
6331
6346
|
} catch {
|
|
6332
6347
|
continue;
|
|
6333
6348
|
}
|
|
@@ -6364,15 +6379,15 @@ var CodeMap = class {
|
|
|
6364
6379
|
this.dirTimes.clear();
|
|
6365
6380
|
const dirs = /* @__PURE__ */ new Set([""]);
|
|
6366
6381
|
for (const p of paths) {
|
|
6367
|
-
let d =
|
|
6382
|
+
let d = path8.posix.dirname(p);
|
|
6368
6383
|
while (d !== "." && !dirs.has(d)) {
|
|
6369
6384
|
dirs.add(d);
|
|
6370
|
-
d =
|
|
6385
|
+
d = path8.posix.dirname(d);
|
|
6371
6386
|
}
|
|
6372
6387
|
}
|
|
6373
6388
|
for (const d of dirs) {
|
|
6374
6389
|
try {
|
|
6375
|
-
this.dirTimes.set(d,
|
|
6390
|
+
this.dirTimes.set(d, fs9.statSync(path8.join(this.root, d)).mtimeMs);
|
|
6376
6391
|
} catch {
|
|
6377
6392
|
}
|
|
6378
6393
|
}
|
|
@@ -6382,7 +6397,7 @@ var CodeMap = class {
|
|
|
6382
6397
|
if (!this.dirTimes.size) return false;
|
|
6383
6398
|
for (const [d, t] of this.dirTimes) {
|
|
6384
6399
|
try {
|
|
6385
|
-
if (
|
|
6400
|
+
if (fs9.statSync(path8.join(this.root, d)).mtimeMs !== t) return true;
|
|
6386
6401
|
} catch {
|
|
6387
6402
|
return true;
|
|
6388
6403
|
}
|
|
@@ -6395,7 +6410,7 @@ var CodeMap = class {
|
|
|
6395
6410
|
const rank = graph.rank;
|
|
6396
6411
|
const near = /* @__PURE__ */ new Set();
|
|
6397
6412
|
for (const f of focus ?? []) {
|
|
6398
|
-
const rel =
|
|
6413
|
+
const rel = path8.isAbsolute(f) ? path8.relative(this.root, f).split(path8.sep).join("/") : f;
|
|
6399
6414
|
if (!this.files.has(rel)) continue;
|
|
6400
6415
|
near.add(rel);
|
|
6401
6416
|
for (const t of graph.imports.get(rel) ?? []) near.add(t);
|
|
@@ -6451,7 +6466,7 @@ var CodeMap = class {
|
|
|
6451
6466
|
outline(target, budget = 600) {
|
|
6452
6467
|
this.load();
|
|
6453
6468
|
const t = target.trim().replace(/^\.\//, "").replace(/\/$/, "");
|
|
6454
|
-
const rel =
|
|
6469
|
+
const rel = path8.isAbsolute(t) ? path8.relative(this.root, t).split(path8.sep).join("/") : t;
|
|
6455
6470
|
const file = this.files.get(rel);
|
|
6456
6471
|
if (file) return this.fileOutline(file, budget);
|
|
6457
6472
|
const prefix = rel === "" || rel === "." ? "" : `${rel}/`;
|
|
@@ -6471,7 +6486,7 @@ var CodeMap = class {
|
|
|
6471
6486
|
}
|
|
6472
6487
|
signature(file, d) {
|
|
6473
6488
|
try {
|
|
6474
|
-
const text =
|
|
6489
|
+
const text = fs9.readFileSync(path8.join(this.root, file.p), "utf8");
|
|
6475
6490
|
const lines = text.split("\n").slice(d.s - 1, Math.min(d.e, d.s + 3));
|
|
6476
6491
|
let sig = "";
|
|
6477
6492
|
for (const l of lines) {
|
|
@@ -6519,7 +6534,7 @@ var CodeMap = class {
|
|
|
6519
6534
|
}
|
|
6520
6535
|
const rank = (f) => this.graph.rank.get(f.p) ?? 0;
|
|
6521
6536
|
const out3 = [`${prefix || "./"} ${files.length} files`];
|
|
6522
|
-
const mod = this.modules().find((m) => `${m.id}/` === prefix) ?? (prefix &&
|
|
6537
|
+
const mod = this.modules().find((m) => `${m.id}/` === prefix) ?? (prefix && fs9.existsSync(docPath(this.root, prefix.slice(0, -1))) ? this.moduleOrFolder(prefix.slice(0, -1)) : void 0);
|
|
6523
6538
|
let doc;
|
|
6524
6539
|
if (mod) {
|
|
6525
6540
|
if (mod.dependsOn.length) out3.push(`uses: ${mod.dependsOn.join(", ")}`);
|
|
@@ -6623,15 +6638,15 @@ ${edgeLines(uses, "to", 10)}`);
|
|
|
6623
6638
|
overview(budget = 500) {
|
|
6624
6639
|
this.load();
|
|
6625
6640
|
const out3 = [];
|
|
6626
|
-
const pkg = readJsonFile(
|
|
6641
|
+
const pkg = readJsonFile(path8.join(this.root, "package.json"));
|
|
6627
6642
|
if (pkg?.scripts) {
|
|
6628
6643
|
const keep = Object.keys(pkg.scripts).filter((s) => /^(dev|start|build|test|lint|typecheck|check|e2e|format)(:|$)/.test(s)).slice(0, 8);
|
|
6629
6644
|
if (keep.length) out3.push(`commands: ${keep.map((s) => `npm run ${s}`).join(" \xB7 ")}`);
|
|
6630
6645
|
}
|
|
6631
|
-
if (
|
|
6632
|
-
if (
|
|
6646
|
+
if (fs9.existsSync(path8.join(this.root, "pyproject.toml"))) out3.push("python: pyproject.toml");
|
|
6647
|
+
if (fs9.existsSync(path8.join(this.root, "Makefile"))) {
|
|
6633
6648
|
try {
|
|
6634
|
-
const targets = [...
|
|
6649
|
+
const targets = [...fs9.readFileSync(path8.join(this.root, "Makefile"), "utf8").matchAll(/^([a-zA-Z][\w-]*):/gm)].map((m) => m[1]).slice(0, 8);
|
|
6635
6650
|
if (targets.length) out3.push(`make: ${targets.join(" \xB7 ")}`);
|
|
6636
6651
|
} catch {
|
|
6637
6652
|
}
|
|
@@ -6697,7 +6712,7 @@ ${conv.map((c) => ` ${c}`).join("\n")}`);
|
|
|
6697
6712
|
for (const f of this.files.values()) {
|
|
6698
6713
|
let text;
|
|
6699
6714
|
try {
|
|
6700
|
-
text =
|
|
6715
|
+
text = fs9.readFileSync(path8.join(this.root, f.p), "utf8");
|
|
6701
6716
|
} catch {
|
|
6702
6717
|
continue;
|
|
6703
6718
|
}
|
|
@@ -6735,7 +6750,7 @@ ${conv.map((c) => ` ${c}`).join("\n")}`);
|
|
|
6735
6750
|
};
|
|
6736
6751
|
function readJsonFile(file) {
|
|
6737
6752
|
try {
|
|
6738
|
-
return JSON.parse(
|
|
6753
|
+
return JSON.parse(fs9.readFileSync(file, "utf8"));
|
|
6739
6754
|
} catch {
|
|
6740
6755
|
return void 0;
|
|
6741
6756
|
}
|
|
@@ -6780,70 +6795,70 @@ function clip(text, budget) {
|
|
|
6780
6795
|
|
|
6781
6796
|
// src/core/backup.ts
|
|
6782
6797
|
init_define_AIRBAND_GRAMMARS();
|
|
6783
|
-
var
|
|
6798
|
+
var fs10 = __toESM(require("node:fs"));
|
|
6784
6799
|
var os2 = __toESM(require("node:os"));
|
|
6785
|
-
var
|
|
6800
|
+
var path9 = __toESM(require("node:path"));
|
|
6786
6801
|
var ITEMS = ["flightlogs", "library", "connections.json", "deliveries.jsonl"];
|
|
6787
6802
|
var machine = () => os2.hostname().replace(/\.local$/, "").replace(/[^A-Za-z0-9_-]/g, "_") || "this-computer";
|
|
6788
6803
|
function backupDirFor(folder) {
|
|
6789
|
-
return
|
|
6804
|
+
return path9.join(folder, "airband-backup", machine());
|
|
6790
6805
|
}
|
|
6791
6806
|
function walk(src, fn, rel = "", depth = 0) {
|
|
6792
6807
|
let st;
|
|
6793
6808
|
try {
|
|
6794
|
-
st =
|
|
6809
|
+
st = fs10.lstatSync(src);
|
|
6795
6810
|
} catch {
|
|
6796
6811
|
return;
|
|
6797
6812
|
}
|
|
6798
6813
|
if (st.isFile()) return fn(rel, src, st);
|
|
6799
6814
|
if (!st.isDirectory() || depth > 8) return;
|
|
6800
|
-
for (const name2 of
|
|
6815
|
+
for (const name2 of fs10.readdirSync(src)) walk(path9.join(src, name2), fn, rel ? path9.join(rel, name2) : name2, depth + 1);
|
|
6801
6816
|
}
|
|
6802
6817
|
function backUp(folder) {
|
|
6803
6818
|
const to = backupDirFor(folder);
|
|
6804
6819
|
let copied = 0;
|
|
6805
6820
|
let files = 0;
|
|
6806
6821
|
for (const item of ITEMS) {
|
|
6807
|
-
walk(
|
|
6822
|
+
walk(path9.join(airbandHome(), item), (rel, full, st) => {
|
|
6808
6823
|
files++;
|
|
6809
|
-
const dest =
|
|
6824
|
+
const dest = path9.join(to, item, rel);
|
|
6810
6825
|
try {
|
|
6811
|
-
const d =
|
|
6826
|
+
const d = fs10.statSync(dest);
|
|
6812
6827
|
if (d.size === st.size && Math.abs(d.mtimeMs - st.mtimeMs) < 1e3) return;
|
|
6813
6828
|
} catch {
|
|
6814
6829
|
}
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6830
|
+
fs10.mkdirSync(path9.dirname(dest), { recursive: true });
|
|
6831
|
+
fs10.copyFileSync(full, dest);
|
|
6832
|
+
fs10.utimesSync(dest, st.atime, st.mtime);
|
|
6818
6833
|
copied++;
|
|
6819
6834
|
});
|
|
6820
6835
|
}
|
|
6821
|
-
|
|
6822
|
-
|
|
6836
|
+
fs10.mkdirSync(to, { recursive: true });
|
|
6837
|
+
fs10.writeFileSync(path9.join(to, "README.txt"), `Airband's session logs from ${machine()}, last backed up ${(/* @__PURE__ */ new Date()).toISOString()}.
|
|
6823
6838
|
Restore with "Airband: Restore session logs" or: node ~/.airband/airband.js restore "${folder}"
|
|
6824
6839
|
`);
|
|
6825
6840
|
return { copied, files, to };
|
|
6826
6841
|
}
|
|
6827
6842
|
function restore(folder) {
|
|
6828
|
-
const root =
|
|
6843
|
+
const root = path9.join(folder, "airband-backup");
|
|
6829
6844
|
let machines = [];
|
|
6830
6845
|
try {
|
|
6831
|
-
machines =
|
|
6846
|
+
machines = fs10.readdirSync(root).filter((m) => fs10.lstatSync(path9.join(root, m)).isDirectory());
|
|
6832
6847
|
} catch {
|
|
6833
6848
|
return { restored: 0, from: [] };
|
|
6834
6849
|
}
|
|
6835
6850
|
let restored = 0;
|
|
6836
6851
|
for (const m of machines) {
|
|
6837
6852
|
for (const item of ITEMS) {
|
|
6838
|
-
walk(
|
|
6839
|
-
const dest =
|
|
6853
|
+
walk(path9.join(root, m, item), (rel, full, st) => {
|
|
6854
|
+
const dest = path9.join(airbandHome(), item, rel);
|
|
6840
6855
|
try {
|
|
6841
|
-
const d =
|
|
6856
|
+
const d = fs10.statSync(dest);
|
|
6842
6857
|
if (d.size >= st.size) return;
|
|
6843
6858
|
} catch {
|
|
6844
6859
|
}
|
|
6845
|
-
|
|
6846
|
-
|
|
6860
|
+
fs10.mkdirSync(path9.dirname(dest), { recursive: true });
|
|
6861
|
+
fs10.copyFileSync(full, dest);
|
|
6847
6862
|
restored++;
|
|
6848
6863
|
});
|
|
6849
6864
|
}
|
|
@@ -6853,7 +6868,7 @@ function restore(folder) {
|
|
|
6853
6868
|
|
|
6854
6869
|
// src/core/tokens.ts
|
|
6855
6870
|
init_define_AIRBAND_GRAMMARS();
|
|
6856
|
-
var
|
|
6871
|
+
var fs11 = __toESM(require("node:fs"));
|
|
6857
6872
|
var SEARCH_CMD = /^\s*(cd [^&;]+(&&|;)\s*)?(grep|rg|ag|ack|find|fd|ls|tree|git (grep|ls-files))\b/;
|
|
6858
6873
|
var READ_CMD = /^\s*(cd [^&;]+(&&|;)\s*)?(cat|head|tail|sed -n|less|bat|nl|wc|git (show|log|diff|blame))\b/;
|
|
6859
6874
|
var tokensOf2 = (chars) => Math.round(chars / 4);
|
|
@@ -6876,14 +6891,14 @@ function resultText(content) {
|
|
|
6876
6891
|
return "";
|
|
6877
6892
|
}
|
|
6878
6893
|
function eachLine(file, fn, maxBytes = 512 * 1024 * 1024) {
|
|
6879
|
-
const fd =
|
|
6894
|
+
const fd = fs11.openSync(file, "r");
|
|
6880
6895
|
try {
|
|
6881
|
-
const size = Math.min(
|
|
6896
|
+
const size = Math.min(fs11.fstatSync(fd).size, maxBytes);
|
|
6882
6897
|
const chunk = Buffer.alloc(4 * 1024 * 1024);
|
|
6883
6898
|
let pos = 0;
|
|
6884
6899
|
let rest = Buffer.alloc(0);
|
|
6885
6900
|
while (pos < size) {
|
|
6886
|
-
const n =
|
|
6901
|
+
const n = fs11.readSync(fd, chunk, 0, Math.min(chunk.length, size - pos), pos);
|
|
6887
6902
|
if (n <= 0) break;
|
|
6888
6903
|
pos += n;
|
|
6889
6904
|
let buf = Buffer.concat([rest, chunk.subarray(0, n)]);
|
|
@@ -6897,7 +6912,7 @@ function eachLine(file, fn, maxBytes = 512 * 1024 * 1024) {
|
|
|
6897
6912
|
}
|
|
6898
6913
|
if (rest.length) fn(rest.toString("utf8"));
|
|
6899
6914
|
} finally {
|
|
6900
|
-
|
|
6915
|
+
fs11.closeSync(fd);
|
|
6901
6916
|
}
|
|
6902
6917
|
}
|
|
6903
6918
|
function tokenReport(tool, file) {
|
|
@@ -6927,13 +6942,13 @@ function tokenReport(tool, file) {
|
|
|
6927
6942
|
pt.tokens += t;
|
|
6928
6943
|
pt.calls++;
|
|
6929
6944
|
perTool.set(name2, pt);
|
|
6930
|
-
const
|
|
6931
|
-
if (call && typeof
|
|
6932
|
-
const rd = reads.get(
|
|
6945
|
+
const path19 = call && (call.input.file_path ?? call.input.absolute_path ?? call.input.path);
|
|
6946
|
+
if (call && typeof path19 === "string" && /^(Read|read_file)$/.test(name2)) {
|
|
6947
|
+
const rd = reads.get(path19) ?? { times: 0, tokens: 0, whole: 0 };
|
|
6933
6948
|
rd.times++;
|
|
6934
6949
|
rd.tokens += t;
|
|
6935
6950
|
if (!call.input.offset && !call.input.limit) rd.whole = Math.max(rd.whole, t);
|
|
6936
|
-
reads.set(
|
|
6951
|
+
reads.set(path19, rd);
|
|
6937
6952
|
}
|
|
6938
6953
|
};
|
|
6939
6954
|
eachLine(file, (line) => {
|
|
@@ -7029,8 +7044,8 @@ function renderTokenReport(r, name2) {
|
|
|
7029
7044
|
|
|
7030
7045
|
// src/library/index.ts
|
|
7031
7046
|
init_define_AIRBAND_GRAMMARS();
|
|
7032
|
-
var
|
|
7033
|
-
var
|
|
7047
|
+
var fs12 = __toESM(require("node:fs"));
|
|
7048
|
+
var path10 = __toESM(require("node:path"));
|
|
7034
7049
|
|
|
7035
7050
|
// src/library/content/ci.md
|
|
7036
7051
|
var ci_default = "---\nname: ci\ntitle: Fix CI\npack: engineering\ndescription: Find why a CI run or deployment failed from its logs, and fix the cause rather than the symptom.\nargs: run = Failing run, PR or job (default: the latest failing run on this branch)\ntriggers: ci failing, fix ci, failing checks, github actions, pipeline failed, build failed, deploy failed, make ci green\n---\nFix the failure in {{run}}.\n\n1. **Read the failure first:** `gh run list --branch <branch> --limit 5`, then `gh run view <id> --log-failed`. Find the first real error, not the last line.\n2. **Reproduce locally** with the same command the job runs (read the workflow file for it). If it passes locally, compare versions, environment variables, caches and the files CI checks out.\n3. **Classify:** our code broke \xB7 a test is wrong or flaky (prove which: run it ten times) \xB7 environment or dependency changed \xB7 the workflow itself.\n4. **Fix the cause.** Never skip, retry-until-green, or loosen a check to get past it; if a check is truly wrong, say so and change it in its own commit with the reason.\n5. Run the same command again and show it passing. Ask before pushing.\n\nReport: the cause in one line, the fix, and how you verified it.\n";
|
|
@@ -7260,16 +7275,16 @@ function userCommands() {
|
|
|
7260
7275
|
const read = (d, depth) => {
|
|
7261
7276
|
let items;
|
|
7262
7277
|
try {
|
|
7263
|
-
items =
|
|
7278
|
+
items = fs12.readdirSync(d, { withFileTypes: true });
|
|
7264
7279
|
} catch {
|
|
7265
7280
|
return;
|
|
7266
7281
|
}
|
|
7267
7282
|
for (const it of items) {
|
|
7268
|
-
const p =
|
|
7283
|
+
const p = path10.join(d, it.name);
|
|
7269
7284
|
if (it.isDirectory() && depth < 1) read(p, depth + 1);
|
|
7270
7285
|
else if (it.isFile() && it.name.endsWith(".md")) {
|
|
7271
7286
|
try {
|
|
7272
|
-
const c = parseCommand(
|
|
7287
|
+
const c = parseCommand(fs12.readFileSync(p, "utf8"), p);
|
|
7273
7288
|
if (c && c.description !== STARTER_DESCRIPTION) out3.push(c);
|
|
7274
7289
|
} catch {
|
|
7275
7290
|
}
|
|
@@ -7324,16 +7339,16 @@ function suggest(ask, commands = allCommands(), n = 3) {
|
|
|
7324
7339
|
|
|
7325
7340
|
// src/core/setup.ts
|
|
7326
7341
|
init_define_AIRBAND_GRAMMARS();
|
|
7327
|
-
var
|
|
7342
|
+
var fs17 = __toESM(require("node:fs"));
|
|
7328
7343
|
var https2 = __toESM(require("node:https"));
|
|
7329
7344
|
var os7 = __toESM(require("node:os"));
|
|
7330
|
-
var
|
|
7345
|
+
var path15 = __toESM(require("node:path"));
|
|
7331
7346
|
|
|
7332
7347
|
// src/core/migrate.ts
|
|
7333
7348
|
init_define_AIRBAND_GRAMMARS();
|
|
7334
|
-
var
|
|
7349
|
+
var fs13 = __toESM(require("node:fs"));
|
|
7335
7350
|
var os3 = __toESM(require("node:os"));
|
|
7336
|
-
var
|
|
7351
|
+
var path11 = __toESM(require("node:path"));
|
|
7337
7352
|
var OLD_ONLY = /* @__PURE__ */ new Set([
|
|
7338
7353
|
"relay-hook.js",
|
|
7339
7354
|
"relay-mcp.js",
|
|
@@ -7348,28 +7363,28 @@ var OLD_ONLY = /* @__PURE__ */ new Set([
|
|
|
7348
7363
|
var OLD_HOME_NAMES = [".relay", ".crosstalk"];
|
|
7349
7364
|
var RENAMED = { sessions: "flightlogs" };
|
|
7350
7365
|
function merge(from, to) {
|
|
7351
|
-
if (!
|
|
7352
|
-
|
|
7366
|
+
if (!fs13.existsSync(from)) return 0;
|
|
7367
|
+
fs13.mkdirSync(to, { recursive: true });
|
|
7353
7368
|
let moved = 0;
|
|
7354
|
-
for (const name2 of
|
|
7369
|
+
for (const name2 of fs13.readdirSync(from)) {
|
|
7355
7370
|
if (OLD_ONLY.has(name2)) continue;
|
|
7356
|
-
const src =
|
|
7357
|
-
const dest =
|
|
7358
|
-
if (!
|
|
7359
|
-
|
|
7371
|
+
const src = path11.join(from, name2);
|
|
7372
|
+
const dest = path11.join(to, RENAMED[name2] ?? name2);
|
|
7373
|
+
if (!fs13.existsSync(dest)) {
|
|
7374
|
+
fs13.renameSync(src, dest);
|
|
7360
7375
|
moved++;
|
|
7361
|
-
} else if (
|
|
7376
|
+
} else if (fs13.statSync(src).isDirectory() && fs13.statSync(dest).isDirectory()) {
|
|
7362
7377
|
moved += merge(src, dest);
|
|
7363
7378
|
}
|
|
7364
7379
|
}
|
|
7365
|
-
|
|
7380
|
+
fs13.rmSync(from, { recursive: true, force: true });
|
|
7366
7381
|
return moved;
|
|
7367
7382
|
}
|
|
7368
|
-
function moveOldHome(home, olds = OLD_HOME_NAMES.map((n) =>
|
|
7383
|
+
function moveOldHome(home, olds = OLD_HOME_NAMES.map((n) => path11.join(os3.homedir(), n))) {
|
|
7369
7384
|
try {
|
|
7370
7385
|
let moved = 0;
|
|
7371
7386
|
for (const old of olds) moved += merge(old, home);
|
|
7372
|
-
if (
|
|
7387
|
+
if (fs13.existsSync(path11.join(home, "sessions"))) merge(path11.join(home, "sessions"), path11.join(home, "flightlogs"));
|
|
7373
7388
|
return moved;
|
|
7374
7389
|
} catch {
|
|
7375
7390
|
return 0;
|
|
@@ -7378,9 +7393,9 @@ function moveOldHome(home, olds = OLD_HOME_NAMES.map((n) => path10.join(os3.home
|
|
|
7378
7393
|
|
|
7379
7394
|
// src/core/hooks.ts
|
|
7380
7395
|
init_define_AIRBAND_GRAMMARS();
|
|
7381
|
-
var
|
|
7396
|
+
var fs14 = __toESM(require("node:fs"));
|
|
7382
7397
|
var os4 = __toESM(require("node:os"));
|
|
7383
|
-
var
|
|
7398
|
+
var path12 = __toESM(require("node:path"));
|
|
7384
7399
|
var import_node_child_process2 = require("node:child_process");
|
|
7385
7400
|
var HOOK_EVENTS = ["SessionStart", "UserPromptSubmit", "PostToolUse", "Notification", "Stop", "SessionEnd"];
|
|
7386
7401
|
var MARK = "airband-hook.js";
|
|
@@ -7388,10 +7403,10 @@ var OLD_MARKS = ["relay-hook.js", "crosstalk-hook.js"];
|
|
|
7388
7403
|
var ours = (command2) => !!command2 && (command2.includes(MARK) || OLD_MARKS.some((m) => command2.includes(m)));
|
|
7389
7404
|
function claudeSettingsPath() {
|
|
7390
7405
|
if (process.env.AIRBAND_CLAUDE_SETTINGS) return process.env.AIRBAND_CLAUDE_SETTINGS;
|
|
7391
|
-
return
|
|
7406
|
+
return path12.join(process.env.CLAUDE_CONFIG_DIR || path12.join(os4.homedir(), ".claude"), "settings.json");
|
|
7392
7407
|
}
|
|
7393
7408
|
function installedHookPath() {
|
|
7394
|
-
return
|
|
7409
|
+
return path12.join(airbandHome(), "airband-hook.js");
|
|
7395
7410
|
}
|
|
7396
7411
|
function findCommand(name2, platform = process.platform) {
|
|
7397
7412
|
const tryRun = (cmd, args2) => {
|
|
@@ -7402,22 +7417,22 @@ function findCommand(name2, platform = process.platform) {
|
|
|
7402
7417
|
}
|
|
7403
7418
|
};
|
|
7404
7419
|
if (platform === "win32") {
|
|
7405
|
-
const found = tryRun("where", [name2]).find((p) => /\.(exe|cmd|bat)$/i.test(p) &&
|
|
7420
|
+
const found = tryRun("where", [name2]).find((p) => /\.(exe|cmd|bat)$/i.test(p) && fs14.existsSync(p));
|
|
7406
7421
|
if (found) return found;
|
|
7407
7422
|
} else {
|
|
7408
|
-
const shells = [process.env.SHELL, "/bin/zsh", "/bin/bash", "/bin/sh"].filter((s) => !!s &&
|
|
7423
|
+
const shells = [process.env.SHELL, "/bin/zsh", "/bin/bash", "/bin/sh"].filter((s) => !!s && fs14.existsSync(s));
|
|
7409
7424
|
for (const shell of shells.slice(0, 2)) {
|
|
7410
7425
|
const found = tryRun(shell, ["-lc", `command -v ${name2}`]).pop();
|
|
7411
|
-
if (found &&
|
|
7426
|
+
if (found && path12.isAbsolute(found) && fs14.existsSync(found)) return found;
|
|
7412
7427
|
}
|
|
7413
7428
|
}
|
|
7414
7429
|
const home = os4.homedir();
|
|
7415
7430
|
const usual = platform === "win32" ? [
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
] : [
|
|
7420
|
-
return usual.find((p) =>
|
|
7431
|
+
path12.join(process.env.APPDATA ?? path12.join(home, "AppData", "Roaming"), "npm", `${name2}.cmd`),
|
|
7432
|
+
path12.join(home, ".local", "bin", `${name2}.exe`),
|
|
7433
|
+
path12.join(process.env.ProgramFiles ?? "C:\\Program Files", "nodejs", `${name2}.exe`)
|
|
7434
|
+
] : [path12.join(home, ".local", "bin", name2), `/opt/homebrew/bin/${name2}`, `/usr/local/bin/${name2}`, `/usr/bin/${name2}`];
|
|
7435
|
+
return usual.find((p) => fs14.existsSync(p));
|
|
7421
7436
|
}
|
|
7422
7437
|
function findNode() {
|
|
7423
7438
|
return findCommand("node") ?? "node";
|
|
@@ -7426,8 +7441,8 @@ function findClaude() {
|
|
|
7426
7441
|
return findCommand("claude");
|
|
7427
7442
|
}
|
|
7428
7443
|
function readSettings(file) {
|
|
7429
|
-
if (!
|
|
7430
|
-
const text =
|
|
7444
|
+
if (!fs14.existsSync(file)) return {};
|
|
7445
|
+
const text = fs14.readFileSync(file, "utf8");
|
|
7431
7446
|
return text.trim() ? JSON.parse(text) : {};
|
|
7432
7447
|
}
|
|
7433
7448
|
function isConnected(file = claudeSettingsPath(), events = HOOK_EVENTS) {
|
|
@@ -7442,7 +7457,7 @@ function connect(command2, file = claudeSettingsPath(), events = HOOK_EVENTS, ti
|
|
|
7442
7457
|
const settings = readSettings(file);
|
|
7443
7458
|
const backup2 = `${file}.airband-backup`;
|
|
7444
7459
|
guardRealHome(file);
|
|
7445
|
-
if (
|
|
7460
|
+
if (fs14.existsSync(file) && !fs14.existsSync(backup2)) fs14.copyFileSync(file, backup2);
|
|
7446
7461
|
const hooks = settings.hooks ?? {};
|
|
7447
7462
|
for (const event of events) {
|
|
7448
7463
|
const groups = (hooks[event] ?? []).map((g) => ({ ...g, hooks: (g.hooks ?? []).filter((h) => !ours(h.command)) }));
|
|
@@ -7457,7 +7472,7 @@ function connect(command2, file = claudeSettingsPath(), events = HOOK_EVENTS, ti
|
|
|
7457
7472
|
`);
|
|
7458
7473
|
}
|
|
7459
7474
|
function disconnect(file = claudeSettingsPath()) {
|
|
7460
|
-
if (!
|
|
7475
|
+
if (!fs14.existsSync(file)) return;
|
|
7461
7476
|
const settings = readSettings(file);
|
|
7462
7477
|
if (!settings.hooks) return;
|
|
7463
7478
|
for (const [event, groups] of Object.entries(settings.hooks)) {
|
|
@@ -7470,33 +7485,33 @@ function disconnect(file = claudeSettingsPath()) {
|
|
|
7470
7485
|
`);
|
|
7471
7486
|
}
|
|
7472
7487
|
function codexHome() {
|
|
7473
|
-
return process.env.CODEX_HOME ||
|
|
7488
|
+
return process.env.CODEX_HOME || path12.join(os4.homedir(), ".codex");
|
|
7474
7489
|
}
|
|
7475
7490
|
function geminiHome() {
|
|
7476
|
-
return process.env.AIRBAND_GEMINI_HOME ||
|
|
7491
|
+
return process.env.AIRBAND_GEMINI_HOME || path12.join(os4.homedir(), ".gemini");
|
|
7477
7492
|
}
|
|
7478
7493
|
function hookTargets() {
|
|
7479
7494
|
return [
|
|
7480
7495
|
{ tool: "Claude", file: claudeSettingsPath(), events: HOOK_EVENTS, timeout: 5, present: () => true },
|
|
7481
7496
|
{
|
|
7482
7497
|
tool: "Codex",
|
|
7483
|
-
file:
|
|
7498
|
+
file: path12.join(codexHome(), "hooks.json"),
|
|
7484
7499
|
// Codex's hooks match Claude Code's; PermissionRequest is its "needs you".
|
|
7485
7500
|
events: ["SessionStart", "UserPromptSubmit", "PostToolUse", "PermissionRequest", "Stop", "SessionEnd"],
|
|
7486
7501
|
timeout: 5,
|
|
7487
7502
|
// Codex gives a SessionEnd hook at most 3 seconds (and warns about anything longer).
|
|
7488
7503
|
timeouts: { SessionEnd: 3 },
|
|
7489
|
-
present: () =>
|
|
7504
|
+
present: () => fs14.existsSync(codexHome()),
|
|
7490
7505
|
note: "Codex runs new hooks only once you trust them: type /hooks in Codex and trust Airband's."
|
|
7491
7506
|
},
|
|
7492
7507
|
{
|
|
7493
7508
|
tool: "Gemini",
|
|
7494
|
-
file:
|
|
7509
|
+
file: path12.join(geminiHome(), "settings.json"),
|
|
7495
7510
|
// Gemini CLI's names: BeforeAgent = a prompt arrives, AfterAgent = a reply ended. Timeouts are in ms.
|
|
7496
7511
|
events: ["SessionStart", "BeforeAgent", "AfterAgent", "AfterTool", "Notification", "SessionEnd"],
|
|
7497
7512
|
timeout: 5e3,
|
|
7498
7513
|
// ~/.gemini alone is not enough: Antigravity makes it too. Gemini CLI leaves these behind.
|
|
7499
|
-
present: () => ["settings.json", "tmp", "projects.json", "oauth_creds.json"].some((n) =>
|
|
7514
|
+
present: () => ["settings.json", "tmp", "projects.json", "oauth_creds.json"].some((n) => fs14.existsSync(path12.join(geminiHome(), n)))
|
|
7500
7515
|
}
|
|
7501
7516
|
];
|
|
7502
7517
|
}
|
|
@@ -7517,7 +7532,7 @@ function staleHookTargets() {
|
|
|
7517
7532
|
const cmd = ourCommand(t.file);
|
|
7518
7533
|
if (!cmd) return false;
|
|
7519
7534
|
const node = /^"([^"]+)"/.exec(cmd)?.[1];
|
|
7520
|
-
const gone = !!node && node !== "node" && !
|
|
7535
|
+
const gone = !!node && node !== "node" && !fs14.existsSync(node);
|
|
7521
7536
|
return gone || !cmd.includes(MARK) || process.platform !== "win32" && !cmd.endsWith("|| true");
|
|
7522
7537
|
});
|
|
7523
7538
|
}
|
|
@@ -7528,31 +7543,31 @@ function isToolConnected(t) {
|
|
|
7528
7543
|
// src/core/toolkit.ts
|
|
7529
7544
|
init_define_AIRBAND_GRAMMARS();
|
|
7530
7545
|
var import_node_child_process3 = require("node:child_process");
|
|
7531
|
-
var
|
|
7546
|
+
var fs15 = __toESM(require("node:fs"));
|
|
7532
7547
|
var os5 = __toESM(require("node:os"));
|
|
7533
|
-
var
|
|
7548
|
+
var path13 = __toESM(require("node:path"));
|
|
7534
7549
|
var SERVER = "airband";
|
|
7535
7550
|
var mcpServerPath = () => airbandFile("airband-mcp.js");
|
|
7536
|
-
var codexHome2 = () => process.env.CODEX_HOME ||
|
|
7537
|
-
var geminiHome2 = () => process.env.AIRBAND_GEMINI_HOME ||
|
|
7538
|
-
var claudeHome = () => process.env.CLAUDE_CONFIG_DIR ||
|
|
7539
|
-
var claudeJsonPath = () => process.env.AIRBAND_CLAUDE_JSON || (process.env.CLAUDE_CONFIG_DIR ?
|
|
7540
|
-
var codexConfigPath = () =>
|
|
7541
|
-
var codexPromptsDir = () =>
|
|
7542
|
-
var geminiSettingsPath = () =>
|
|
7551
|
+
var codexHome2 = () => process.env.CODEX_HOME || path13.join(os5.homedir(), ".codex");
|
|
7552
|
+
var geminiHome2 = () => process.env.AIRBAND_GEMINI_HOME || path13.join(os5.homedir(), ".gemini");
|
|
7553
|
+
var claudeHome = () => process.env.CLAUDE_CONFIG_DIR || path13.join(os5.homedir(), ".claude");
|
|
7554
|
+
var claudeJsonPath = () => process.env.AIRBAND_CLAUDE_JSON || (process.env.CLAUDE_CONFIG_DIR ? path13.join(process.env.CLAUDE_CONFIG_DIR, ".claude.json") : path13.join(os5.homedir(), ".claude.json"));
|
|
7555
|
+
var codexConfigPath = () => path13.join(codexHome2(), "config.toml");
|
|
7556
|
+
var codexPromptsDir = () => path13.join(codexHome2(), "prompts");
|
|
7557
|
+
var geminiSettingsPath = () => path13.join(geminiHome2(), "settings.json");
|
|
7543
7558
|
var MANIFEST = ".airband-manifest";
|
|
7544
7559
|
var OLD_SERVERS = ["crosstalk"];
|
|
7545
7560
|
var OLD_MANIFESTS = [".crosstalk-manifest"];
|
|
7546
7561
|
function backup(file) {
|
|
7547
|
-
if (!
|
|
7562
|
+
if (!fs15.existsSync(file)) return;
|
|
7548
7563
|
guardRealHome(file);
|
|
7549
7564
|
const first = `${file}.airband-backup`;
|
|
7550
|
-
if (!
|
|
7551
|
-
|
|
7565
|
+
if (!fs15.existsSync(first)) fs15.copyFileSync(file, first);
|
|
7566
|
+
fs15.copyFileSync(file, `${file}.airband-last`);
|
|
7552
7567
|
}
|
|
7553
7568
|
function readJsonFile2(file) {
|
|
7554
7569
|
try {
|
|
7555
|
-
return JSON.parse(
|
|
7570
|
+
return JSON.parse(fs15.readFileSync(file, "utf8"));
|
|
7556
7571
|
} catch {
|
|
7557
7572
|
return void 0;
|
|
7558
7573
|
}
|
|
@@ -7562,7 +7577,7 @@ function agentStates() {
|
|
|
7562
7577
|
const gemini = readJsonFile2(geminiSettingsPath())?.mcpServers ?? {};
|
|
7563
7578
|
let codexToml = "";
|
|
7564
7579
|
try {
|
|
7565
|
-
codexToml =
|
|
7580
|
+
codexToml = fs15.readFileSync(codexConfigPath(), "utf8");
|
|
7566
7581
|
} catch {
|
|
7567
7582
|
}
|
|
7568
7583
|
const lib = builtinCommands().length;
|
|
@@ -7573,16 +7588,16 @@ function agentStates() {
|
|
|
7573
7588
|
{
|
|
7574
7589
|
id: "claude",
|
|
7575
7590
|
name: "Claude Code",
|
|
7576
|
-
present:
|
|
7591
|
+
present: fs15.existsSync(claudeHome()) || fs15.existsSync(claudeJsonPath()),
|
|
7577
7592
|
tools: SERVER in claudeServers,
|
|
7578
7593
|
allowed: Array.isArray(claudeAllow) && claudeAllow.includes(CLAUDE_ALLOW),
|
|
7579
7594
|
commands: SERVER in claudeServers ? lib : 0
|
|
7580
7595
|
},
|
|
7581
|
-
{ id: "codex", name: "Codex", present:
|
|
7596
|
+
{ id: "codex", name: "Codex", present: fs15.existsSync(codexHome2()), tools: codexTools, allowed: /^default_tools_approval_mode\s*=\s*"approve"/m.test(codexBlockText), commands: ownedPrompts().length },
|
|
7582
7597
|
{
|
|
7583
7598
|
id: "gemini",
|
|
7584
7599
|
name: "Gemini CLI",
|
|
7585
|
-
present:
|
|
7600
|
+
present: fs15.existsSync(geminiHome2()),
|
|
7586
7601
|
tools: SERVER in gemini,
|
|
7587
7602
|
allowed: gemini[SERVER]?.trust === true,
|
|
7588
7603
|
commands: SERVER in gemini ? lib : 0
|
|
@@ -7592,21 +7607,21 @@ function agentStates() {
|
|
|
7592
7607
|
var runCli = (cmd, args2) => new Promise((resolve5) => {
|
|
7593
7608
|
if (process.env.NODE_TEST_CONTEXT) throw new Error(`A test tried to run ${cmd}. Pass claudeCli: null.`);
|
|
7594
7609
|
const home = os5.homedir();
|
|
7595
|
-
const extra = process.platform === "win32" ? [
|
|
7610
|
+
const extra = process.platform === "win32" ? [path13.join(process.env.APPDATA ?? path13.join(home, "AppData", "Roaming"), "npm")] : [path13.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
|
|
7596
7611
|
const useShell = process.platform === "win32" && /\.(cmd|bat)$/i.test(cmd);
|
|
7597
7612
|
const quote = (a) => useShell && /[\s"&|<>^]/.test(a) ? `"${a.replace(/"/g, '""')}"` : a;
|
|
7598
7613
|
(0, import_node_child_process3.execFile)(
|
|
7599
7614
|
useShell ? quote(cmd) : cmd,
|
|
7600
7615
|
args2.map(quote),
|
|
7601
|
-
{ timeout: 3e4, windowsHide: true, shell: useShell, env: { ...process.env, PATH: [process.env.PATH ?? "", ...extra].join(
|
|
7616
|
+
{ timeout: 3e4, windowsHide: true, shell: useShell, env: { ...process.env, PATH: [process.env.PATH ?? "", ...extra].join(path13.delimiter) } },
|
|
7602
7617
|
(err2, stdout, stderr) => resolve5({ ok: !err2, out: `${stdout}${stderr}`.trim() })
|
|
7603
7618
|
);
|
|
7604
7619
|
});
|
|
7605
7620
|
var CLAUDE_ALLOW = `mcp__${SERVER}`;
|
|
7606
7621
|
function allowInClaude(on) {
|
|
7607
7622
|
const file = claudeSettingsPath();
|
|
7608
|
-
if (!
|
|
7609
|
-
const settings =
|
|
7623
|
+
if (!fs15.existsSync(file) && !on) return;
|
|
7624
|
+
const settings = fs15.existsSync(file) ? readJsonFile2(file) : {};
|
|
7610
7625
|
if (!settings || typeof settings !== "object" || Array.isArray(settings)) return;
|
|
7611
7626
|
const permissions = settings.permissions ?? {};
|
|
7612
7627
|
const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
|
|
@@ -7635,7 +7650,7 @@ async function addToClaude(node, claudeCli, run2) {
|
|
|
7635
7650
|
}
|
|
7636
7651
|
function editClaudeJson(change) {
|
|
7637
7652
|
const file = claudeJsonPath();
|
|
7638
|
-
const data =
|
|
7653
|
+
const data = fs15.existsSync(file) ? readJsonFile2(file) : {};
|
|
7639
7654
|
if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error(`${file} couldn't be read, so it was left as it is. Try again in a moment.`);
|
|
7640
7655
|
backup(file);
|
|
7641
7656
|
const servers = { ...data.mcpServers ?? {} };
|
|
@@ -7681,7 +7696,7 @@ function addToCodex(node) {
|
|
|
7681
7696
|
const file = codexConfigPath();
|
|
7682
7697
|
let toml = "";
|
|
7683
7698
|
try {
|
|
7684
|
-
toml =
|
|
7699
|
+
toml = fs15.readFileSync(file, "utf8");
|
|
7685
7700
|
} catch {
|
|
7686
7701
|
}
|
|
7687
7702
|
backup(file);
|
|
@@ -7696,7 +7711,7 @@ function removeFromCodex() {
|
|
|
7696
7711
|
const file = codexConfigPath();
|
|
7697
7712
|
let removedTools = false;
|
|
7698
7713
|
try {
|
|
7699
|
-
const toml =
|
|
7714
|
+
const toml = fs15.readFileSync(file, "utf8");
|
|
7700
7715
|
const next = withoutCodexBlock(toml);
|
|
7701
7716
|
if (next !== toml) {
|
|
7702
7717
|
backup(file);
|
|
@@ -7712,8 +7727,8 @@ function ownedPrompts() {
|
|
|
7712
7727
|
const out3 = /* @__PURE__ */ new Set();
|
|
7713
7728
|
for (const m of [MANIFEST, ...OLD_MANIFESTS]) {
|
|
7714
7729
|
try {
|
|
7715
|
-
for (const n of
|
|
7716
|
-
if (n &&
|
|
7730
|
+
for (const n of fs15.readFileSync(path13.join(codexPromptsDir(), m), "utf8").split("\n")) {
|
|
7731
|
+
if (n && fs15.existsSync(path13.join(codexPromptsDir(), n))) out3.add(n);
|
|
7717
7732
|
}
|
|
7718
7733
|
} catch {
|
|
7719
7734
|
}
|
|
@@ -7733,32 +7748,32 @@ ${body2}
|
|
|
7733
7748
|
}
|
|
7734
7749
|
function writeCodexPrompts(commands) {
|
|
7735
7750
|
const dir = codexPromptsDir();
|
|
7736
|
-
|
|
7751
|
+
fs15.mkdirSync(dir, { recursive: true });
|
|
7737
7752
|
const owned = new Set(ownedPrompts());
|
|
7738
7753
|
const written = [];
|
|
7739
7754
|
for (const c of commands) {
|
|
7740
7755
|
const file = `${c.name}.md`;
|
|
7741
|
-
if (
|
|
7742
|
-
writeFileAtomic(
|
|
7756
|
+
if (fs15.existsSync(path13.join(dir, file)) && !owned.has(file)) continue;
|
|
7757
|
+
writeFileAtomic(path13.join(dir, file), codexPrompt(c));
|
|
7743
7758
|
written.push(file);
|
|
7744
7759
|
}
|
|
7745
|
-
writeFileAtomic(
|
|
7760
|
+
writeFileAtomic(path13.join(dir, MANIFEST), `${written.join("\n")}
|
|
7746
7761
|
`);
|
|
7747
|
-
for (const f of owned) if (!written.includes(f))
|
|
7748
|
-
for (const m of OLD_MANIFESTS)
|
|
7762
|
+
for (const f of owned) if (!written.includes(f)) fs15.rmSync(path13.join(dir, f), { force: true });
|
|
7763
|
+
for (const m of OLD_MANIFESTS) fs15.rmSync(path13.join(dir, m), { force: true });
|
|
7749
7764
|
return written.length;
|
|
7750
7765
|
}
|
|
7751
7766
|
function removeCodexPrompts() {
|
|
7752
7767
|
const owned = ownedPrompts();
|
|
7753
7768
|
guardRealHome(codexPromptsDir());
|
|
7754
|
-
for (const f of owned)
|
|
7755
|
-
for (const m of [MANIFEST, ...OLD_MANIFESTS])
|
|
7769
|
+
for (const f of owned) fs15.rmSync(path13.join(codexPromptsDir(), f), { force: true });
|
|
7770
|
+
for (const m of [MANIFEST, ...OLD_MANIFESTS]) fs15.rmSync(path13.join(codexPromptsDir(), m), { force: true });
|
|
7756
7771
|
return owned.length;
|
|
7757
7772
|
}
|
|
7758
7773
|
function addToGemini(node) {
|
|
7759
7774
|
const file = geminiSettingsPath();
|
|
7760
7775
|
const settings = readJsonFile2(file) ?? {};
|
|
7761
|
-
if (
|
|
7776
|
+
if (fs15.existsSync(file) && !readJsonFile2(file)) return "Gemini CLI: its settings.json couldn't be read, so it was left alone.";
|
|
7762
7777
|
backup(file);
|
|
7763
7778
|
const servers = settings.mcpServers ?? {};
|
|
7764
7779
|
for (const old of OLD_SERVERS) delete servers[old];
|
|
@@ -7810,9 +7825,9 @@ async function removeToolkit(agents, opts) {
|
|
|
7810
7825
|
|
|
7811
7826
|
// src/core/skills.ts
|
|
7812
7827
|
init_define_AIRBAND_GRAMMARS();
|
|
7813
|
-
var
|
|
7828
|
+
var fs16 = __toESM(require("node:fs"));
|
|
7814
7829
|
var os6 = __toESM(require("node:os"));
|
|
7815
|
-
var
|
|
7830
|
+
var path14 = __toESM(require("node:path"));
|
|
7816
7831
|
|
|
7817
7832
|
// skills/airband-find-code/SKILL.md
|
|
7818
7833
|
var SKILL_default = '---\nname: airband-find-code\ndescription: Find code in this project fast, before searching or opening files. Use when you need where something is defined, what calls or imports it, or how a folder is laid out. Answers in a few hundred tokens from Airband\'s map of the code.\n---\n\n# Find code with the Airband map\n\nAsk the map first. Use grep or read whole files only when the map has nothing.\n\n1. **Where is it?** `airband_map` with `find: "<a name or plain words>"`. You get ranked matches as\n `path:start-end`; read only those lines.\n2. **What\'s in this file or folder?** `airband_map` with `outline: "<path or name>"`: one level, with\n line ranges.\n3. **What uses it, and what does it use?** `airband_map` with `graph: "<name or path>"`; add\n `hops: 2` for one more step.\n4. **New to the project?** `airband_map` with no arguments: the commands, entry points and main parts.\n\nWithout the tool (another agent, a terminal, CI), the same answers come from the command line:\n`node "$HOME/.airband/airband.js" find "<words>"` (bash, zsh and PowerShell alike), and `outline`, `graph`, `overview`.\n\nThe map is built by a parser on this computer and stays fresh as files are saved. It covers\nTypeScript, JavaScript, Python, Go, Rust, Java, C#, Ruby and PHP.\n';
|
|
@@ -7838,10 +7853,10 @@ function retireOldSkills(agents) {
|
|
|
7838
7853
|
for (const a of agents) {
|
|
7839
7854
|
for (const old of OLD_SKILLS) {
|
|
7840
7855
|
for (const name2 of old.names) {
|
|
7841
|
-
const dir =
|
|
7842
|
-
if (!
|
|
7856
|
+
const dir = path14.join(skillsDir(a), name2);
|
|
7857
|
+
if (!fs16.existsSync(path14.join(dir, old.mark))) continue;
|
|
7843
7858
|
guardRealHome(dir);
|
|
7844
|
-
|
|
7859
|
+
fs16.rmSync(dir, { recursive: true, force: true });
|
|
7845
7860
|
n++;
|
|
7846
7861
|
}
|
|
7847
7862
|
}
|
|
@@ -7849,18 +7864,18 @@ function retireOldSkills(agents) {
|
|
|
7849
7864
|
return n;
|
|
7850
7865
|
}
|
|
7851
7866
|
function skillsDir(agent) {
|
|
7852
|
-
if (agent === "claude") return process.env.AIRBAND_CLAUDE_SKILLS ||
|
|
7853
|
-
return process.env.AIRBAND_AGENTS_SKILLS ||
|
|
7867
|
+
if (agent === "claude") return process.env.AIRBAND_CLAUDE_SKILLS || path14.join(process.env.CLAUDE_CONFIG_DIR || path14.join(os6.homedir(), ".claude"), "skills");
|
|
7868
|
+
return process.env.AIRBAND_AGENTS_SKILLS || path14.join(os6.homedir(), ".agents", "skills");
|
|
7854
7869
|
}
|
|
7855
7870
|
function installSkills(agents) {
|
|
7856
7871
|
retireOldSkills(agents);
|
|
7857
7872
|
let n = 0;
|
|
7858
7873
|
for (const a of agents) {
|
|
7859
7874
|
for (const s of SKILLS) {
|
|
7860
|
-
const dir =
|
|
7861
|
-
if (
|
|
7862
|
-
writeFileAtomic(
|
|
7863
|
-
writeFileAtomic(
|
|
7875
|
+
const dir = path14.join(skillsDir(a), s.name);
|
|
7876
|
+
if (fs16.existsSync(dir) && !fs16.existsSync(path14.join(dir, MARK2))) continue;
|
|
7877
|
+
writeFileAtomic(path14.join(dir, "SKILL.md"), s.text);
|
|
7878
|
+
writeFileAtomic(path14.join(dir, MARK2), `Written by Airband ${"0.0.2"}. "airband remove" takes it away.
|
|
7864
7879
|
`);
|
|
7865
7880
|
n++;
|
|
7866
7881
|
}
|
|
@@ -7871,10 +7886,10 @@ function removeSkills(agents) {
|
|
|
7871
7886
|
let n = retireOldSkills(agents);
|
|
7872
7887
|
for (const a of agents) {
|
|
7873
7888
|
for (const s of SKILLS) {
|
|
7874
|
-
const dir =
|
|
7875
|
-
if (!
|
|
7889
|
+
const dir = path14.join(skillsDir(a), s.name);
|
|
7890
|
+
if (!fs16.existsSync(path14.join(dir, MARK2))) continue;
|
|
7876
7891
|
guardRealHome(dir);
|
|
7877
|
-
|
|
7892
|
+
fs16.rmSync(dir, { recursive: true, force: true });
|
|
7878
7893
|
n++;
|
|
7879
7894
|
}
|
|
7880
7895
|
}
|
|
@@ -7884,11 +7899,11 @@ function skillsState(agent) {
|
|
|
7884
7899
|
let installed = 0;
|
|
7885
7900
|
let current = 0;
|
|
7886
7901
|
for (const s of SKILLS) {
|
|
7887
|
-
const file =
|
|
7888
|
-
if (!
|
|
7902
|
+
const file = path14.join(skillsDir(agent), s.name, "SKILL.md");
|
|
7903
|
+
if (!fs16.existsSync(path14.join(skillsDir(agent), s.name, MARK2))) continue;
|
|
7889
7904
|
installed++;
|
|
7890
7905
|
try {
|
|
7891
|
-
if (
|
|
7906
|
+
if (fs16.readFileSync(file, "utf8") === s.text) current++;
|
|
7892
7907
|
} catch {
|
|
7893
7908
|
}
|
|
7894
7909
|
}
|
|
@@ -7896,14 +7911,14 @@ function skillsState(agent) {
|
|
|
7896
7911
|
}
|
|
7897
7912
|
|
|
7898
7913
|
// src/core/setup.ts
|
|
7899
|
-
var VERSION = "0.0.
|
|
7914
|
+
var VERSION = "0.0.2";
|
|
7900
7915
|
var NPM_PACKAGE = "airband";
|
|
7901
7916
|
var OLD_PACKAGES = ["crosstalk-ai"];
|
|
7902
7917
|
var FILES = ["airband-mcp.js", "airband-hook.js", "airband.js"];
|
|
7903
7918
|
function claudePlugins(name2) {
|
|
7904
7919
|
try {
|
|
7905
|
-
const file =
|
|
7906
|
-
const plugins = JSON.parse(
|
|
7920
|
+
const file = path15.join(process.env.CLAUDE_CONFIG_DIR || path15.join(os7.homedir(), ".claude"), "plugins", "installed_plugins.json");
|
|
7921
|
+
const plugins = JSON.parse(fs17.readFileSync(file, "utf8")).plugins ?? {};
|
|
7907
7922
|
return Object.keys(plugins).some((k) => k.split("@")[0] === name2);
|
|
7908
7923
|
} catch {
|
|
7909
7924
|
return false;
|
|
@@ -7918,17 +7933,17 @@ function oldClaudePluginInstalled() {
|
|
|
7918
7933
|
function installFiles(fromDir) {
|
|
7919
7934
|
const home = airbandHome();
|
|
7920
7935
|
guardRealHome(home);
|
|
7921
|
-
|
|
7936
|
+
fs17.mkdirSync(path15.join(home, "wasm"), { recursive: true });
|
|
7922
7937
|
let n = 0;
|
|
7923
|
-
if (
|
|
7938
|
+
if (path15.resolve(fromDir) !== path15.resolve(home)) {
|
|
7924
7939
|
for (const f of FILES) {
|
|
7925
|
-
const src =
|
|
7926
|
-
if (!
|
|
7927
|
-
|
|
7940
|
+
const src = path15.join(fromDir, f);
|
|
7941
|
+
if (!fs17.existsSync(src)) continue;
|
|
7942
|
+
fs17.copyFileSync(src, path15.join(home, f));
|
|
7928
7943
|
n++;
|
|
7929
7944
|
}
|
|
7930
|
-
const wasm =
|
|
7931
|
-
for (const f of
|
|
7945
|
+
const wasm = path15.join(fromDir, "wasm");
|
|
7946
|
+
for (const f of fs17.existsSync(wasm) ? fs17.readdirSync(wasm) : []) fs17.copyFileSync(path15.join(wasm, f), path15.join(home, "wasm", f));
|
|
7932
7947
|
}
|
|
7933
7948
|
writeFileAtomic(airbandFile("version.json"), `${JSON.stringify({ version: VERSION, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
7934
7949
|
`);
|
|
@@ -7936,7 +7951,7 @@ function installFiles(fromDir) {
|
|
|
7936
7951
|
}
|
|
7937
7952
|
function installedVersion() {
|
|
7938
7953
|
try {
|
|
7939
|
-
return JSON.parse(
|
|
7954
|
+
return JSON.parse(fs17.readFileSync(airbandFile("version.json"), "utf8")).version;
|
|
7940
7955
|
} catch {
|
|
7941
7956
|
return void 0;
|
|
7942
7957
|
}
|
|
@@ -7985,7 +8000,7 @@ async function remove(o = {}) {
|
|
|
7985
8000
|
lines.push(`Skills removed: ${removeSkills(["claude", "codex"])}.`);
|
|
7986
8001
|
if (o.purge) {
|
|
7987
8002
|
guardRealHome(airbandHome());
|
|
7988
|
-
|
|
8003
|
+
fs17.rmSync(airbandHome(), { recursive: true, force: true });
|
|
7989
8004
|
lines.push(`Deleted ${airbandHome()} (flightlogs, the Map, your own commands).`);
|
|
7990
8005
|
} else lines.push(`Your data stays in ${airbandHome()}; add --purge to delete it.`);
|
|
7991
8006
|
return lines;
|
|
@@ -7996,7 +8011,7 @@ function doctor(latest, self3 = "airband") {
|
|
|
7996
8011
|
const checks = [];
|
|
7997
8012
|
const major = Number(process.versions.node.split(".")[0]);
|
|
7998
8013
|
checks.push(major >= 20 ? { ok: true, what: `Node.js ${process.versions.node}` } : { ok: false, what: `Node.js ${process.versions.node} is too old`, fix: "Install Node.js 20 or newer." });
|
|
7999
|
-
const missing = ["airband-mcp.js", "airband-hook.js", "airband.js", "wasm/tree-sitter.wasm"].filter((f) => !
|
|
8014
|
+
const missing = ["airband-mcp.js", "airband-hook.js", "airband.js", "wasm/tree-sitter.wasm"].filter((f) => !fs17.existsSync(airbandFile(f)));
|
|
8000
8015
|
const iv = installedVersion();
|
|
8001
8016
|
checks.push(
|
|
8002
8017
|
missing.length ? { ok: false, what: `Missing in ${tilde(airbandHome())}: ${missing.join(", ")}`, fix: `Run: ${self3}` } : { ok: true, what: `Airband ${iv ?? "(version unknown)"} installed in ${tilde(airbandHome())}` }
|
|
@@ -8033,7 +8048,7 @@ function doctor(latest, self3 = "airband") {
|
|
|
8033
8048
|
);
|
|
8034
8049
|
}
|
|
8035
8050
|
}
|
|
8036
|
-
if (!
|
|
8051
|
+
if (!fs17.existsSync(installedHookPath()) && present.length) checks.push({ ok: false, what: "The hook script is missing", fix: `Run: ${self3}` });
|
|
8037
8052
|
return checks;
|
|
8038
8053
|
}
|
|
8039
8054
|
var VERSION_RE = /^\d{1,6}\.\d{1,6}\.\d{1,6}(-[0-9A-Za-z.]{1,40})?$/;
|
|
@@ -8052,7 +8067,7 @@ async function latestVersion(o = {}) {
|
|
|
8052
8067
|
const cache = airbandFile("update-check.json");
|
|
8053
8068
|
if (!o.force) {
|
|
8054
8069
|
try {
|
|
8055
|
-
const c = JSON.parse(
|
|
8070
|
+
const c = JSON.parse(fs17.readFileSync(cache, "utf8"));
|
|
8056
8071
|
if (Date.now() - c.at < 24 * 36e5) return c.latest;
|
|
8057
8072
|
} catch {
|
|
8058
8073
|
}
|
|
@@ -8103,7 +8118,7 @@ function agentSummary() {
|
|
|
8103
8118
|
function needsSetup() {
|
|
8104
8119
|
const iv = installedVersion();
|
|
8105
8120
|
if (!iv || newer(VERSION, iv)) return true;
|
|
8106
|
-
if (FILES.some((f) => !
|
|
8121
|
+
if (FILES.some((f) => !fs17.existsSync(airbandFile(f)))) return true;
|
|
8107
8122
|
const plugin = claudePluginInstalled();
|
|
8108
8123
|
for (const a of agentStates().filter((x) => x.present)) {
|
|
8109
8124
|
if (!a.tools && !(a.id === "claude" && plugin)) return true;
|
|
@@ -8116,10 +8131,10 @@ function needsSetup() {
|
|
|
8116
8131
|
return staleHookTargets().length > 0;
|
|
8117
8132
|
}
|
|
8118
8133
|
function npmCommand(bin, args2) {
|
|
8119
|
-
const dir =
|
|
8134
|
+
const dir = path15.dirname(process.execPath);
|
|
8120
8135
|
const cli = `${bin}-cli.js`;
|
|
8121
|
-
for (const p of [
|
|
8122
|
-
if (
|
|
8136
|
+
for (const p of [path15.join(dir, "node_modules", "npm", "bin", cli), path15.join(dir, "..", "lib", "node_modules", "npm", "bin", cli)]) {
|
|
8137
|
+
if (fs17.existsSync(p)) return { cmd: process.execPath, args: [p, ...args2], shell: false };
|
|
8123
8138
|
}
|
|
8124
8139
|
const win = process.platform === "win32";
|
|
8125
8140
|
return win ? { cmd: [bin, ...args2.map((a) => /[\s"]/.test(a) ? `"${a.replace(/"/g, '\\"')}"` : a)].join(" "), args: [], shell: true } : { cmd: bin, args: args2, shell: false };
|
|
@@ -8128,7 +8143,7 @@ function npmCommand(bin, args2) {
|
|
|
8128
8143
|
// src/cli/about.ts
|
|
8129
8144
|
init_define_AIRBAND_GRAMMARS();
|
|
8130
8145
|
var import_node_child_process4 = require("node:child_process");
|
|
8131
|
-
var
|
|
8146
|
+
var fs18 = __toESM(require("node:fs"));
|
|
8132
8147
|
var os8 = __toESM(require("node:os"));
|
|
8133
8148
|
var REPO = "https://github.com/HarshBaldaniya/airband";
|
|
8134
8149
|
var DOCS = `${REPO}#readme`;
|
|
@@ -8151,7 +8166,7 @@ function systemName() {
|
|
|
8151
8166
|
if (process.platform === "linux") {
|
|
8152
8167
|
let name2 = "";
|
|
8153
8168
|
try {
|
|
8154
|
-
name2 = /^PRETTY_NAME="?([^"\n]+)"?/m.exec(
|
|
8169
|
+
name2 = /^PRETTY_NAME="?([^"\n]+)"?/m.exec(fs18.readFileSync("/etc/os-release", "utf8"))?.[1] ?? "";
|
|
8155
8170
|
} catch {
|
|
8156
8171
|
}
|
|
8157
8172
|
return `${name2 || `Linux ${os8.release()}`} (${process.arch})`;
|
|
@@ -8259,6 +8274,14 @@ var COMMANDS = [
|
|
|
8259
8274
|
examples: ["airband update", "airband update --check"],
|
|
8260
8275
|
aliases: ["upgrade"]
|
|
8261
8276
|
},
|
|
8277
|
+
{
|
|
8278
|
+
name: "notices",
|
|
8279
|
+
group: "Get started",
|
|
8280
|
+
args: "[on|off]",
|
|
8281
|
+
summary: "Turn the short Airband lines in your agent's window on or off",
|
|
8282
|
+
about: "When a chat starts, Airband shows one line: that it is on, the map is ready, who the chat shares with, and which other chats worked in the folder lately. When another chat's work is added to your message, it says so. They are shown to you only and cost no tokens (Claude Code and Gemini CLI). With nothing after it, says whether they are on.",
|
|
8283
|
+
examples: ["airband notices", "airband notices off", "airband notices on"]
|
|
8284
|
+
},
|
|
8262
8285
|
{
|
|
8263
8286
|
name: "remove",
|
|
8264
8287
|
group: "Get started",
|
|
@@ -8440,8 +8463,8 @@ ${COMMANDS.map((c) => ` @('${q(c.name)}', '${q(c.summary)}')`).join(",\n")}
|
|
|
8440
8463
|
|
|
8441
8464
|
// src/cli/pm.ts
|
|
8442
8465
|
init_define_AIRBAND_GRAMMARS();
|
|
8443
|
-
var
|
|
8444
|
-
var
|
|
8466
|
+
var fs19 = __toESM(require("node:fs"));
|
|
8467
|
+
var path16 = __toESM(require("node:path"));
|
|
8445
8468
|
function startedBy(ua = process.env.npm_config_user_agent ?? "") {
|
|
8446
8469
|
const name2 = ua.split("/")[0];
|
|
8447
8470
|
return name2 === "pnpm" || name2 === "yarn" || name2 === "bun" ? name2 : "npm";
|
|
@@ -8478,10 +8501,10 @@ function findOnPath(name2, env = process.env, platform = process.platform) {
|
|
|
8478
8501
|
for (const dir of (env.PATH ?? env.Path ?? "").split(platform === "win32" ? ";" : ":")) {
|
|
8479
8502
|
if (!dir) continue;
|
|
8480
8503
|
for (const n of names) {
|
|
8481
|
-
const p =
|
|
8504
|
+
const p = path16.join(dir, n);
|
|
8482
8505
|
if (temporary(p)) continue;
|
|
8483
8506
|
try {
|
|
8484
|
-
if (
|
|
8507
|
+
if (fs19.statSync(p).isFile()) return p;
|
|
8485
8508
|
} catch {
|
|
8486
8509
|
}
|
|
8487
8510
|
}
|
|
@@ -8493,7 +8516,7 @@ function commandFrom(found, packages) {
|
|
|
8493
8516
|
if (!found || temporary(found)) return void 0;
|
|
8494
8517
|
let where = "";
|
|
8495
8518
|
try {
|
|
8496
|
-
where =
|
|
8519
|
+
where = fs19.realpathSync(found);
|
|
8497
8520
|
} catch {
|
|
8498
8521
|
return void 0;
|
|
8499
8522
|
}
|
|
@@ -8502,12 +8525,12 @@ function commandFrom(found, packages) {
|
|
|
8502
8525
|
let pkg = packages.find((n) => inPath(n, where));
|
|
8503
8526
|
if (!pkg) {
|
|
8504
8527
|
try {
|
|
8505
|
-
if (
|
|
8506
|
-
text =
|
|
8528
|
+
if (fs19.statSync(where).size > 64 * 1024) return void 0;
|
|
8529
|
+
text = fs19.readFileSync(where, "utf8");
|
|
8507
8530
|
} catch {
|
|
8508
8531
|
return void 0;
|
|
8509
8532
|
}
|
|
8510
|
-
pkg = packages.find((n) => inPath(n, text) ||
|
|
8533
|
+
pkg = packages.find((n) => inPath(n, text) || fs19.existsSync(path16.join(path16.dirname(found), "node_modules", ...n.split("/"))));
|
|
8511
8534
|
if (!pkg) return void 0;
|
|
8512
8535
|
}
|
|
8513
8536
|
const by = /pnpm/i.test(text) ? "pnpm" : /[\\/]\.bun[\\/]/.test(text) ? "bun" : /yarn/i.test(text) ? "yarn" : "npm";
|
|
@@ -8520,11 +8543,35 @@ function oldCommand(found = findOnPath("crosstalk")) {
|
|
|
8520
8543
|
return commandFrom(found, OLD_PACKAGES);
|
|
8521
8544
|
}
|
|
8522
8545
|
|
|
8546
|
+
// src/core/updates.ts
|
|
8547
|
+
init_define_AIRBAND_GRAMMARS();
|
|
8548
|
+
|
|
8549
|
+
// src/core/redact.ts
|
|
8550
|
+
init_define_AIRBAND_GRAMMARS();
|
|
8551
|
+
|
|
8552
|
+
// src/core/updates.ts
|
|
8553
|
+
var CONTEXT_BUDGET = { compact: 8e3, standard: 24e3, full: 6e4 };
|
|
8554
|
+
function readConfig() {
|
|
8555
|
+
const c = readJson(airbandFile("config.json"), {});
|
|
8556
|
+
return {
|
|
8557
|
+
contextSize: c.contextSize && c.contextSize in CONTEXT_BUDGET ? c.contextSize : "standard",
|
|
8558
|
+
autoDeliver: c.autoDeliver === true,
|
|
8559
|
+
// On unless turned off: they tell the person Airband is working, at no token cost.
|
|
8560
|
+
notices: c.notices !== false
|
|
8561
|
+
};
|
|
8562
|
+
}
|
|
8563
|
+
function setConfig(patch) {
|
|
8564
|
+
const file = airbandFile("config.json");
|
|
8565
|
+
const next = { ...readJson(file, {}), ...patch };
|
|
8566
|
+
writeFileAtomic(file, JSON.stringify(next));
|
|
8567
|
+
return readConfig();
|
|
8568
|
+
}
|
|
8569
|
+
|
|
8523
8570
|
// src/cli/changes.ts
|
|
8524
8571
|
init_define_AIRBAND_GRAMMARS();
|
|
8525
8572
|
|
|
8526
8573
|
// CHANGELOG.md
|
|
8527
|
-
var CHANGELOG_default = "# Changelog\n\n## 0.0.1 (first release)\n\nAirband was called Crosstalk. Installing Airband moves a Crosstalk setup over by itself: its data\n(`~/.crosstalk`), each agent's tools, hooks, skills and commands, Tab completion, and the old\n`crosstalk` command, which `airband` replaces.\n\n- **Tower**: every Claude Code, Codex and Gemini CLI chat as a card; connect chats so one gets the\n other's updates with its next message (Ping, Brief or Full).\n- **Flightlog**: a short record of each chat (asks, what was done, files, commits, PRs).\n- **Fuel**: plan limits as each agent reports them, and tokens per chat.\n- **Map**: a board of your project's parts and files, built by a parser on your computer (TypeScript,\n JavaScript, Python, Go, Rust, Java, C#, Ruby, PHP). Agents query it through `airband_map`.\n- **Commands**: ready-made commands for all three agents (plan, build, review, pr, tests and more),\n plus your own in `~/.airband/library/`.\n- **Agent tools**: `airband_map`, `airband_flightlog` and `airband_notes` over MCP, with\n instructions agents read at the start of a session, and three skills they use by themselves\n (`airband-find-code`, `airband-recall`, `airband-catchup`).\n- **One command to set up**: `npx airband` (or `npm i -g airband`) sets up every agent found and\n adds the `airband` command; `airband doctor`, `airband update`, `airband remove`. The same on\n macOS, Windows and Linux, with npm, pnpm, Yarn or Bun.\n- **Agents don't stop to ask**: setup allows Airband's tools in Claude Code, Codex and Gemini CLI.\n- **A full command line**: grouped help, `airband help <command>` with examples, `version`,\n `about`, `changelog`, `docs`, `bug`, `--json` for scripts, Tab completion for bash, zsh, fish and\n PowerShell, and \"did you mean\" for typos.\n- **Light**: the parsers for Go, Rust, Java, C#, Ruby and PHP are fetched the first time a project\n needs them, checked against fingerprints built into Airband.\n- **Claude Code plugin** and **Gemini CLI extension**, kept current by the agent itself.\n- **Safe by default**: secrets are removed before anything is recorded or shared; what one chat\n sends another is fenced and marked as information, never instructions; settings files keep their\n permissions and are backed up; `~/.airband` is readable only by you.\n";
|
|
8574
|
+
var CHANGELOG_default = "# Changelog\n\n## 0.0.2\n- **Airband says what it's doing.** When a chat starts, one line in the agent's window: Airband\n is on, the map of the folder is ready, who the chat shares with, and which other chats worked\n there in the last 12 hours, with what to say to catch up. When another chat's work is added to\n your message, a line names it. Shown to you only, so they cost no tokens (Claude Code; Gemini\n CLI at the start). Turn them off with `airband notices off` or the `airband.notices` setting.\n\n## 0.0.1 (first release)\n\nAirband was called Crosstalk. Installing Airband moves a Crosstalk setup over by itself: its data\n(`~/.crosstalk`), each agent's tools, hooks, skills and commands, Tab completion, and the old\n`crosstalk` command, which `airband` replaces.\n\n- **Tower**: every Claude Code, Codex and Gemini CLI chat as a card; connect chats so one gets the\n other's updates with its next message (Ping, Brief or Full).\n- **Flightlog**: a short record of each chat (asks, what was done, files, commits, PRs).\n- **Fuel**: plan limits as each agent reports them, and tokens per chat.\n- **Map**: a board of your project's parts and files, built by a parser on your computer (TypeScript,\n JavaScript, Python, Go, Rust, Java, C#, Ruby, PHP). Agents query it through `airband_map`.\n- **Commands**: ready-made commands for all three agents (plan, build, review, pr, tests and more),\n plus your own in `~/.airband/library/`.\n- **Agent tools**: `airband_map`, `airband_flightlog` and `airband_notes` over MCP, with\n instructions agents read at the start of a session, and three skills they use by themselves\n (`airband-find-code`, `airband-recall`, `airband-catchup`).\n- **One command to set up**: `npx airband` (or `npm i -g airband`) sets up every agent found and\n adds the `airband` command; `airband doctor`, `airband update`, `airband remove`. The same on\n macOS, Windows and Linux, with npm, pnpm, Yarn or Bun.\n- **Agents don't stop to ask**: setup allows Airband's tools in Claude Code, Codex and Gemini CLI.\n- **A full command line**: grouped help, `airband help <command>` with examples, `version`,\n `about`, `changelog`, `docs`, `bug`, `--json` for scripts, Tab completion for bash, zsh, fish and\n PowerShell, and \"did you mean\" for typos.\n- **Light**: the parsers for Go, Rust, Java, C#, Ruby and PHP are fetched the first time a project\n needs them, checked against fingerprints built into Airband.\n- **Claude Code plugin** and **Gemini CLI extension**, kept current by the agent itself.\n- **Safe by default**: secrets are removed before anything is recorded or shared; what one chat\n sends another is fenced and marked as information, never instructions; settings files keep their\n permissions and are backed up; `~/.airband` is readable only by you.\n";
|
|
8528
8575
|
|
|
8529
8576
|
// src/cli/changes.ts
|
|
8530
8577
|
function releases(text = CHANGELOG_default) {
|
|
@@ -8543,9 +8590,9 @@ function changesSince(from, to, text = CHANGELOG_default) {
|
|
|
8543
8590
|
|
|
8544
8591
|
// src/cli/shell.ts
|
|
8545
8592
|
init_define_AIRBAND_GRAMMARS();
|
|
8546
|
-
var
|
|
8593
|
+
var fs20 = __toESM(require("node:fs"));
|
|
8547
8594
|
var os9 = __toESM(require("node:os"));
|
|
8548
|
-
var
|
|
8595
|
+
var path17 = __toESM(require("node:path"));
|
|
8549
8596
|
var MARK3 = "# Airband: Tab completion for the airband command (airband remove takes this out)";
|
|
8550
8597
|
var OLD_MARKS2 = ["# Crosstalk: Tab completion for the crosstalk command (crosstalk remove takes this out)"];
|
|
8551
8598
|
var OLD_FISH = ["crosstalk.fish"];
|
|
@@ -8560,19 +8607,19 @@ function withoutBlock(text, mark) {
|
|
|
8560
8607
|
var shellHome = () => process.env.AIRBAND_SHELL_HOME || os9.homedir();
|
|
8561
8608
|
function currentShell() {
|
|
8562
8609
|
if (process.platform === "win32") return void 0;
|
|
8563
|
-
const name2 =
|
|
8610
|
+
const name2 = path17.basename(process.env.SHELL ?? "");
|
|
8564
8611
|
return name2 === "zsh" || name2 === "bash" || name2 === "fish" ? name2 : void 0;
|
|
8565
8612
|
}
|
|
8566
8613
|
function startupFile(shell) {
|
|
8567
|
-
if (shell === "zsh") return
|
|
8568
|
-
return
|
|
8614
|
+
if (shell === "zsh") return path17.join(process.env.ZDOTDIR || shellHome(), ".zshrc");
|
|
8615
|
+
return path17.join(shellHome(), ".bashrc");
|
|
8569
8616
|
}
|
|
8570
|
-
var fishFile = () =>
|
|
8617
|
+
var fishFile = () => path17.join(shellHome(), ".config", "fish", "completions", "airband.fish");
|
|
8571
8618
|
var scriptFile = (shell) => airbandFile(`completion.${shell}`);
|
|
8572
8619
|
function completionOn(shell) {
|
|
8573
|
-
if (shell === "fish") return [fishFile(), ...OLD_FISH.map((n) =>
|
|
8620
|
+
if (shell === "fish") return [fishFile(), ...OLD_FISH.map((n) => path17.join(path17.dirname(fishFile()), n))].some((f) => fs20.existsSync(f));
|
|
8574
8621
|
try {
|
|
8575
|
-
const text =
|
|
8622
|
+
const text = fs20.readFileSync(startupFile(shell), "utf8");
|
|
8576
8623
|
return [MARK3, ...OLD_MARKS2].some((m) => text.includes(m));
|
|
8577
8624
|
} catch {
|
|
8578
8625
|
return false;
|
|
@@ -8580,13 +8627,13 @@ function completionOn(shell) {
|
|
|
8580
8627
|
}
|
|
8581
8628
|
function turnCompletionOn(shell) {
|
|
8582
8629
|
if (shell === "fish") {
|
|
8583
|
-
for (const f of OLD_FISH)
|
|
8630
|
+
for (const f of OLD_FISH) fs20.rmSync(path17.join(path17.dirname(fishFile()), f), { force: true });
|
|
8584
8631
|
writeFileAtomic(fishFile(), completion("fish"));
|
|
8585
8632
|
return fishFile();
|
|
8586
8633
|
}
|
|
8587
8634
|
writeFileAtomic(scriptFile(shell), completion(shell));
|
|
8588
8635
|
const rc = startupFile(shell);
|
|
8589
|
-
const before =
|
|
8636
|
+
const before = fs20.existsSync(rc) ? fs20.readFileSync(rc, "utf8") : "";
|
|
8590
8637
|
let text = OLD_MARKS2.reduce(withoutBlock, before);
|
|
8591
8638
|
if (!text.includes(MARK3)) {
|
|
8592
8639
|
const line = `[ -f ${JSON.stringify(scriptFile(shell))} ] && source ${JSON.stringify(scriptFile(shell))}`;
|
|
@@ -8606,18 +8653,18 @@ function turnCompletionOff() {
|
|
|
8606
8653
|
for (const shell of ["zsh", "bash"]) {
|
|
8607
8654
|
const rc = startupFile(shell);
|
|
8608
8655
|
try {
|
|
8609
|
-
const text =
|
|
8656
|
+
const text = fs20.readFileSync(rc, "utf8");
|
|
8610
8657
|
const next = [MARK3, ...OLD_MARKS2].reduce(withoutBlock, text);
|
|
8611
8658
|
if (next === text) continue;
|
|
8612
8659
|
writeFileAtomic(rc, next);
|
|
8613
8660
|
changed = true;
|
|
8614
8661
|
} catch {
|
|
8615
8662
|
}
|
|
8616
|
-
|
|
8663
|
+
fs20.rmSync(scriptFile(shell), { force: true });
|
|
8617
8664
|
}
|
|
8618
|
-
for (const f of [fishFile(), ...OLD_FISH.map((n) =>
|
|
8619
|
-
if (!
|
|
8620
|
-
|
|
8665
|
+
for (const f of [fishFile(), ...OLD_FISH.map((n) => path17.join(path17.dirname(fishFile()), n))]) {
|
|
8666
|
+
if (!fs20.existsSync(f)) continue;
|
|
8667
|
+
fs20.rmSync(f, { force: true });
|
|
8621
8668
|
changed = true;
|
|
8622
8669
|
}
|
|
8623
8670
|
return changed;
|
|
@@ -8664,7 +8711,7 @@ async function main(argv) {
|
|
|
8664
8711
|
out2(renderCommandHelp(info2, self2()));
|
|
8665
8712
|
return 0;
|
|
8666
8713
|
}
|
|
8667
|
-
const folder =
|
|
8714
|
+
const folder = path18.resolve(option(args2, "--in") ?? process.cwd());
|
|
8668
8715
|
const hops = option(args2, "--hops") === "2" ? 2 : 1;
|
|
8669
8716
|
const limit = Number(option(args2, "--limit") ?? "") || void 0;
|
|
8670
8717
|
const rest = args2.filter((a) => !a.startsWith("--")).join(" ").trim();
|
|
@@ -8675,7 +8722,7 @@ async function main(argv) {
|
|
|
8675
8722
|
};
|
|
8676
8723
|
switch (cmd) {
|
|
8677
8724
|
case "map": {
|
|
8678
|
-
const root =
|
|
8725
|
+
const root = path18.resolve(rest || folder);
|
|
8679
8726
|
const m = new CodeMap(root);
|
|
8680
8727
|
const s = await m.refresh({ yieldEvery: 1e9 });
|
|
8681
8728
|
out2(`${root}: ${s.files} files, ${s.decls} declarations; read ${s.parsed}, ${s.removed} gone, in ${(s.ms / 1e3).toFixed(1)} s${s.bytes ? `, ${(s.bytes / 1024).toFixed(0)} KB` : ""}`);
|
|
@@ -8713,25 +8760,25 @@ async function main(argv) {
|
|
|
8713
8760
|
}
|
|
8714
8761
|
case "tokens": {
|
|
8715
8762
|
if (!rest) return usage("tokens <chat file (.jsonl)>");
|
|
8716
|
-
const file =
|
|
8717
|
-
out2(renderTokenReport(tokenReport(/[/\\]\.codex[/\\]|rollout-/.test(file) ? "codex" : "claude", file),
|
|
8763
|
+
const file = path18.resolve(rest);
|
|
8764
|
+
out2(renderTokenReport(tokenReport(/[/\\]\.codex[/\\]|rollout-/.test(file) ? "codex" : "claude", file), path18.basename(file)));
|
|
8718
8765
|
return 0;
|
|
8719
8766
|
}
|
|
8720
8767
|
case "backup": {
|
|
8721
8768
|
if (!rest) return usage("backup <folder>");
|
|
8722
|
-
const r = backUp(
|
|
8769
|
+
const r = backUp(path18.resolve(rest));
|
|
8723
8770
|
out2(`Backed up ${r.copied} new or changed of ${r.files} files to ${r.to}`);
|
|
8724
8771
|
return 0;
|
|
8725
8772
|
}
|
|
8726
8773
|
case "restore": {
|
|
8727
8774
|
if (!rest) return usage("restore <folder>");
|
|
8728
|
-
const r = restore(
|
|
8775
|
+
const r = restore(path18.resolve(rest));
|
|
8729
8776
|
out2(r.from.length ? `Restored ${r.restored} files from ${r.from.join(", ")}` : `No Airband backup in ${rest}`);
|
|
8730
8777
|
return 0;
|
|
8731
8778
|
}
|
|
8732
8779
|
case "mcp":
|
|
8733
8780
|
if (!process.env.AIRBAND_ROOT) process.env.AIRBAND_ROOT = folder;
|
|
8734
|
-
require(
|
|
8781
|
+
require(path18.join(__dirname, "airband-mcp.js"));
|
|
8735
8782
|
return -1;
|
|
8736
8783
|
case void 0:
|
|
8737
8784
|
case "status": {
|
|
@@ -8787,6 +8834,13 @@ async function main(argv) {
|
|
|
8787
8834
|
out2("");
|
|
8788
8835
|
return 0;
|
|
8789
8836
|
}
|
|
8837
|
+
case "notices": {
|
|
8838
|
+
const want = rest.toLowerCase();
|
|
8839
|
+
if (want && want !== "on" && want !== "off") return usage("notices [on|off]");
|
|
8840
|
+
const on = want ? setConfig({ notices: want === "on" }).notices : readConfig().notices;
|
|
8841
|
+
out2(on ? `${paint.ok("\u2713")} Airband's lines in your agent's window are on (when a chat starts, and when other chats' work is added).` : `Airband's lines in your agent's window are off. Turn them back on: ${self2()} notices on`);
|
|
8842
|
+
return 0;
|
|
8843
|
+
}
|
|
8790
8844
|
case "version": {
|
|
8791
8845
|
const latest = await latestVersion({ timeoutMs: 2500 });
|
|
8792
8846
|
if (asJson) {
|
|
@@ -9026,7 +9080,7 @@ function updateNote(cmd) {
|
|
|
9026
9080
|
const quiet = ["mcp", "update", "upgrade", "version", "--version", "-v", "about", "doctor", "setup", "install", "init", "status", "completion", "help", "--help", "-h"];
|
|
9027
9081
|
if (!process.stderr.isTTY || !cmd || quiet.includes(cmd) || process.argv.includes("--json") || updateChecksOff()) return;
|
|
9028
9082
|
try {
|
|
9029
|
-
const c = JSON.parse(
|
|
9083
|
+
const c = JSON.parse(fs21.readFileSync(path18.join(airbandHome(), "update-check.json"), "utf8"));
|
|
9030
9084
|
if (c.latest && newer(c.latest, VERSION)) process.stderr.write(`
|
|
9031
9085
|
Airband ${c.latest} is out (you have ${VERSION}). Run: ${self2()} update
|
|
9032
9086
|
`);
|