airband 0.0.2 → 0.0.4
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 +3 -2
- package/airband-hook.js +564 -16
- package/airband-mcp.js +369 -84
- package/airband.js +30296 -900
- package/package.json +2 -2
package/airband-mcp.js
CHANGED
|
@@ -940,10 +940,10 @@ var require_codegen = __commonJS({
|
|
|
940
940
|
return this._leafNode(new Throw(error62));
|
|
941
941
|
}
|
|
942
942
|
// start self-balancing block
|
|
943
|
-
block(
|
|
943
|
+
block(body3, nodeCount) {
|
|
944
944
|
this._blockStarts.push(this._nodes.length);
|
|
945
|
-
if (
|
|
946
|
-
this.code(
|
|
945
|
+
if (body3)
|
|
946
|
+
this.code(body3).endBlock(nodeCount);
|
|
947
947
|
return this;
|
|
948
948
|
}
|
|
949
949
|
// end the current self-balancing block
|
|
@@ -2383,15 +2383,15 @@ var require_validate = __commonJS({
|
|
|
2383
2383
|
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
2384
2384
|
}
|
|
2385
2385
|
exports2.validateFunctionCode = validateFunctionCode;
|
|
2386
|
-
function validateFunction({ gen, validateName, schema, schemaEnv, opts },
|
|
2386
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body3) {
|
|
2387
2387
|
if (opts.code.es5) {
|
|
2388
2388
|
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
|
|
2389
2389
|
gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
2390
2390
|
destructureValCxtES5(gen, opts);
|
|
2391
|
-
gen.code(
|
|
2391
|
+
gen.code(body3);
|
|
2392
2392
|
});
|
|
2393
2393
|
} else {
|
|
2394
|
-
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(
|
|
2394
|
+
gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body3));
|
|
2395
2395
|
}
|
|
2396
2396
|
}
|
|
2397
2397
|
function destructureValCxt(opts) {
|
|
@@ -3022,7 +3022,7 @@ var require_compile = __commonJS({
|
|
|
3022
3022
|
const schOrFunc = root2.refs[ref];
|
|
3023
3023
|
if (schOrFunc)
|
|
3024
3024
|
return schOrFunc;
|
|
3025
|
-
let _sch =
|
|
3025
|
+
let _sch = resolve5.call(this, root2, ref);
|
|
3026
3026
|
if (_sch === void 0) {
|
|
3027
3027
|
const schema = (_a3 = root2.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
3028
3028
|
const { schemaId } = this.opts;
|
|
@@ -3049,7 +3049,7 @@ var require_compile = __commonJS({
|
|
|
3049
3049
|
function sameSchemaEnv(s1, s2) {
|
|
3050
3050
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3051
3051
|
}
|
|
3052
|
-
function
|
|
3052
|
+
function resolve5(root2, ref) {
|
|
3053
3053
|
let sch;
|
|
3054
3054
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3055
3055
|
ref = sch;
|
|
@@ -3882,7 +3882,7 @@ var require_fast_uri = __commonJS({
|
|
|
3882
3882
|
}
|
|
3883
3883
|
return uri;
|
|
3884
3884
|
}
|
|
3885
|
-
function
|
|
3885
|
+
function resolve5(baseURI, relativeURI, options) {
|
|
3886
3886
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3887
3887
|
const {
|
|
3888
3888
|
parsed: baseParsed,
|
|
@@ -4251,7 +4251,7 @@ var require_fast_uri = __commonJS({
|
|
|
4251
4251
|
var fastUri = {
|
|
4252
4252
|
SCHEMES,
|
|
4253
4253
|
normalize,
|
|
4254
|
-
resolve:
|
|
4254
|
+
resolve: resolve5,
|
|
4255
4255
|
resolveComponent,
|
|
4256
4256
|
equal,
|
|
4257
4257
|
serialize,
|
|
@@ -9326,10 +9326,10 @@ var require_tree_sitter = __commonJS({
|
|
|
9326
9326
|
if (response.ok) {
|
|
9327
9327
|
return new Uint8Array(buffer);
|
|
9328
9328
|
} else {
|
|
9329
|
-
const
|
|
9329
|
+
const body22 = new TextDecoder("utf-8").decode(buffer);
|
|
9330
9330
|
throw new Error(`Language.load failed with status ${response.status}.
|
|
9331
9331
|
|
|
9332
|
-
${
|
|
9332
|
+
${body22}`);
|
|
9333
9333
|
}
|
|
9334
9334
|
}));
|
|
9335
9335
|
}
|
|
@@ -9352,8 +9352,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
9352
9352
|
var moduleRtn;
|
|
9353
9353
|
var Module = moduleArg;
|
|
9354
9354
|
var readyPromiseResolve, readyPromiseReject;
|
|
9355
|
-
var readyPromise = new Promise((
|
|
9356
|
-
readyPromiseResolve =
|
|
9355
|
+
var readyPromise = new Promise((resolve5, reject) => {
|
|
9356
|
+
readyPromiseResolve = resolve5;
|
|
9357
9357
|
readyPromiseReject = reject;
|
|
9358
9358
|
});
|
|
9359
9359
|
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
@@ -9394,10 +9394,10 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
9394
9394
|
}, "readBinary");
|
|
9395
9395
|
readAsync = /* @__PURE__ */ __name((filename, binary2 = true) => {
|
|
9396
9396
|
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
9397
|
-
return new Promise((
|
|
9397
|
+
return new Promise((resolve5, reject) => {
|
|
9398
9398
|
fs.readFile(filename, binary2 ? void 0 : "utf8", (err2, data) => {
|
|
9399
9399
|
if (err2) reject(err2);
|
|
9400
|
-
else
|
|
9400
|
+
else resolve5(binary2 ? data.buffer : data);
|
|
9401
9401
|
});
|
|
9402
9402
|
});
|
|
9403
9403
|
}, "readAsync");
|
|
@@ -9438,13 +9438,13 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
9438
9438
|
}
|
|
9439
9439
|
readAsync = /* @__PURE__ */ __name((url2) => {
|
|
9440
9440
|
if (isFileURI(url2)) {
|
|
9441
|
-
return new Promise((reject,
|
|
9441
|
+
return new Promise((reject, resolve5) => {
|
|
9442
9442
|
var xhr = new XMLHttpRequest();
|
|
9443
9443
|
xhr.open("GET", url2, true);
|
|
9444
9444
|
xhr.responseType = "arraybuffer";
|
|
9445
9445
|
xhr.onload = () => {
|
|
9446
9446
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
9447
|
-
|
|
9447
|
+
resolve5(xhr.response);
|
|
9448
9448
|
}
|
|
9449
9449
|
reject(xhr.status);
|
|
9450
9450
|
};
|
|
@@ -10458,8 +10458,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
10458
10458
|
}
|
|
10459
10459
|
var libFile = locateFile(libName2);
|
|
10460
10460
|
if (flags2.loadAsync) {
|
|
10461
|
-
return new Promise(function(
|
|
10462
|
-
asyncLoad(libFile,
|
|
10461
|
+
return new Promise(function(resolve5, reject) {
|
|
10462
|
+
asyncLoad(libFile, resolve5, reject);
|
|
10463
10463
|
});
|
|
10464
10464
|
}
|
|
10465
10465
|
if (!readBinary) {
|
|
@@ -11750,8 +11750,8 @@ var makeIssue = (params) => {
|
|
|
11750
11750
|
};
|
|
11751
11751
|
}
|
|
11752
11752
|
let errorMessage = "";
|
|
11753
|
-
const
|
|
11754
|
-
for (const map2 of
|
|
11753
|
+
const maps2 = errorMaps.filter((m) => !!m).slice().reverse();
|
|
11754
|
+
for (const map2 of maps2) {
|
|
11755
11755
|
errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
|
|
11756
11756
|
}
|
|
11757
11757
|
return {
|
|
@@ -20087,7 +20087,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
20087
20087
|
var NONE = 0;
|
|
20088
20088
|
var ASSUMED = 1;
|
|
20089
20089
|
var PROVEN = 2;
|
|
20090
|
-
function isRecursive(inst, stack,
|
|
20090
|
+
function isRecursive(inst, stack, resolve5) {
|
|
20091
20091
|
const cached2 = recursive.get(inst);
|
|
20092
20092
|
if (cached2 !== void 0)
|
|
20093
20093
|
return cached2 ? PROVEN : NONE;
|
|
@@ -20097,7 +20097,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
20097
20097
|
let result = NONE;
|
|
20098
20098
|
const check2 = (child) => {
|
|
20099
20099
|
if (result !== PROVEN && child?._zod) {
|
|
20100
|
-
const answer = isRecursive(child, stack,
|
|
20100
|
+
const answer = isRecursive(child, stack, resolve5);
|
|
20101
20101
|
if (answer > result)
|
|
20102
20102
|
result = answer;
|
|
20103
20103
|
}
|
|
@@ -20108,7 +20108,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
20108
20108
|
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
20109
20109
|
if (spread && !desc.enumerable)
|
|
20110
20110
|
continue;
|
|
20111
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
20111
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve5) : NONE;
|
|
20112
20112
|
if (child > answer)
|
|
20113
20113
|
answer = child;
|
|
20114
20114
|
}
|
|
@@ -20172,7 +20172,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
20172
20172
|
break;
|
|
20173
20173
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
20174
20174
|
case "lazy": {
|
|
20175
|
-
const inner = def._cachedInner ?? (
|
|
20175
|
+
const inner = def._cachedInner ?? (resolve5 ? inst._zod.innerType : void 0);
|
|
20176
20176
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
20177
20177
|
break;
|
|
20178
20178
|
}
|
|
@@ -25778,8 +25778,8 @@ var error43 = () => {
|
|
|
25778
25778
|
case "not_multiple_of":
|
|
25779
25779
|
return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
|
|
25780
25780
|
case "unrecognized_keys": {
|
|
25781
|
-
const
|
|
25782
|
-
return `Chave${
|
|
25781
|
+
const plural3 = issue2.keys.length > 1 ? "s" : "";
|
|
25782
|
+
return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
|
|
25783
25783
|
}
|
|
25784
25784
|
case "invalid_key":
|
|
25785
25785
|
return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
|
|
@@ -25924,8 +25924,8 @@ var error44 = () => {
|
|
|
25924
25924
|
case "not_multiple_of":
|
|
25925
25925
|
return `N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${issue2.divisor}`;
|
|
25926
25926
|
case "unrecognized_keys": {
|
|
25927
|
-
const
|
|
25928
|
-
return `Chave${
|
|
25927
|
+
const plural3 = issue2.keys.length > 1 ? "s" : "";
|
|
25928
|
+
return `Chave${plural3} inv\xE1lida${plural3}: ${joinValues(issue2.keys, ", ")}`;
|
|
25929
25929
|
}
|
|
25930
25930
|
case "invalid_key":
|
|
25931
25931
|
return `Entrada inv\xE1lida n${translateOriginWithArticle(issue2.origin, "definite")}`;
|
|
@@ -29447,7 +29447,7 @@ function generateRecordCheck(doc, ctx, schema, accessor) {
|
|
|
29447
29447
|
}, `return INVALID;`);
|
|
29448
29448
|
return outputVar;
|
|
29449
29449
|
}
|
|
29450
|
-
function emitOwnKeys(doc, ctx, accessor, kVar,
|
|
29450
|
+
function emitOwnKeys(doc, ctx, accessor, kVar, body3, onSymbol) {
|
|
29451
29451
|
const propIsEnumerableConst = addConstant(ctx, Object.prototype.propertyIsEnumerable);
|
|
29452
29452
|
const symsVar = newVar(ctx);
|
|
29453
29453
|
const keysVar = newVar(ctx);
|
|
@@ -29458,7 +29458,7 @@ function emitOwnKeys(doc, ctx, accessor, kVar, body2, onSymbol) {
|
|
|
29458
29458
|
doc.indented((d) => {
|
|
29459
29459
|
d.write(`const ${kVar} = ${keysVar}[${iVar}];`);
|
|
29460
29460
|
d.write(`if (${kVar} === "__proto__" || !${propIsEnumerableConst}.call(${accessor}, ${kVar})) continue;`);
|
|
29461
|
-
|
|
29461
|
+
body3(d);
|
|
29462
29462
|
});
|
|
29463
29463
|
doc.write(`}`);
|
|
29464
29464
|
doc.write(`for (let ${iVar} = 0; ${iVar} < ${symsVar}.length; ${iVar}++) {`);
|
|
@@ -29468,7 +29468,7 @@ function emitOwnKeys(doc, ctx, accessor, kVar, body2, onSymbol) {
|
|
|
29468
29468
|
if (onSymbol)
|
|
29469
29469
|
d.write(onSymbol);
|
|
29470
29470
|
else
|
|
29471
|
-
|
|
29471
|
+
body3(d);
|
|
29472
29472
|
});
|
|
29473
29473
|
doc.write(`}`);
|
|
29474
29474
|
}
|
|
@@ -38765,7 +38765,7 @@ var Protocol = class {
|
|
|
38765
38765
|
return;
|
|
38766
38766
|
}
|
|
38767
38767
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
38768
|
-
await new Promise((
|
|
38768
|
+
await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
|
|
38769
38769
|
options?.signal?.throwIfAborted();
|
|
38770
38770
|
}
|
|
38771
38771
|
} catch (error62) {
|
|
@@ -38782,7 +38782,7 @@ var Protocol = class {
|
|
|
38782
38782
|
*/
|
|
38783
38783
|
request(request, resultSchema, options) {
|
|
38784
38784
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
38785
|
-
return new Promise((
|
|
38785
|
+
return new Promise((resolve5, reject) => {
|
|
38786
38786
|
const earlyReject = (error62) => {
|
|
38787
38787
|
reject(error62);
|
|
38788
38788
|
};
|
|
@@ -38860,7 +38860,7 @@ var Protocol = class {
|
|
|
38860
38860
|
if (!parseResult.success) {
|
|
38861
38861
|
reject(parseResult.error);
|
|
38862
38862
|
} else {
|
|
38863
|
-
|
|
38863
|
+
resolve5(parseResult.data);
|
|
38864
38864
|
}
|
|
38865
38865
|
} catch (error62) {
|
|
38866
38866
|
reject(error62);
|
|
@@ -39122,12 +39122,12 @@ var Protocol = class {
|
|
|
39122
39122
|
}
|
|
39123
39123
|
} catch {
|
|
39124
39124
|
}
|
|
39125
|
-
return new Promise((
|
|
39125
|
+
return new Promise((resolve5, reject) => {
|
|
39126
39126
|
if (signal.aborted) {
|
|
39127
39127
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
39128
39128
|
return;
|
|
39129
39129
|
}
|
|
39130
|
-
const timeoutId = setTimeout(
|
|
39130
|
+
const timeoutId = setTimeout(resolve5, interval);
|
|
39131
39131
|
signal.addEventListener("abort", () => {
|
|
39132
39132
|
clearTimeout(timeoutId);
|
|
39133
39133
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -40270,7 +40270,7 @@ var McpServer = class {
|
|
|
40270
40270
|
let task = createTaskResult.task;
|
|
40271
40271
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
40272
40272
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
40273
|
-
await new Promise((
|
|
40273
|
+
await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
|
|
40274
40274
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
40275
40275
|
if (!updatedTask) {
|
|
40276
40276
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -40936,12 +40936,12 @@ var StdioServerTransport = class {
|
|
|
40936
40936
|
this.onclose?.();
|
|
40937
40937
|
}
|
|
40938
40938
|
send(message) {
|
|
40939
|
-
return new Promise((
|
|
40939
|
+
return new Promise((resolve5) => {
|
|
40940
40940
|
const json2 = serializeMessage(message);
|
|
40941
40941
|
if (this._stdout.write(json2)) {
|
|
40942
|
-
|
|
40942
|
+
resolve5();
|
|
40943
40943
|
} else {
|
|
40944
|
-
this._stdout.once("drain",
|
|
40944
|
+
this._stdout.once("drain", resolve5);
|
|
40945
40945
|
}
|
|
40946
40946
|
});
|
|
40947
40947
|
}
|
|
@@ -41243,8 +41243,8 @@ function codexMessages(lines) {
|
|
|
41243
41243
|
${text2}`;
|
|
41244
41244
|
else messages.push({ id: `codex-${n++}`, who, text: text2 });
|
|
41245
41245
|
} else if ((item.type === "function_call" || item.type === "custom_tool_call") && /patch/.test(String(item.name ?? ""))) {
|
|
41246
|
-
const
|
|
41247
|
-
for (const m of
|
|
41246
|
+
const body3 = String(item.arguments ?? item.input ?? "");
|
|
41247
|
+
for (const m of body3.matchAll(/\*\*\* (?:Add|Update|Delete) File: ([^\n\\"]+)/g)) files.add(m[1].trim());
|
|
41248
41248
|
}
|
|
41249
41249
|
}
|
|
41250
41250
|
return { messages, files: [...files] };
|
|
@@ -41361,7 +41361,7 @@ init_define_AIRBAND_GRAMMARS();
|
|
|
41361
41361
|
var ASK_MAX = 600;
|
|
41362
41362
|
var DID_MAX = 400;
|
|
41363
41363
|
var OPEN_MAX = 200;
|
|
41364
|
-
var REFS_MAX =
|
|
41364
|
+
var REFS_MAX = 12;
|
|
41365
41365
|
var HOOK_START_MAX = 8 * 1024 * 1024;
|
|
41366
41366
|
var HOOK_STEP_MAX = 16 * 1024 * 1024;
|
|
41367
41367
|
var dir = () => airbandFile("flightlogs");
|
|
@@ -41405,11 +41405,41 @@ function listHeads() {
|
|
|
41405
41405
|
}
|
|
41406
41406
|
var PR_URL = /github\.com\/[\w.-]+\/[\w.-]+\/pull\/(\d+)/g;
|
|
41407
41407
|
var PR_WORD = /\b(?:PR|pull request) #(\d{1,6})\b/gi;
|
|
41408
|
+
var ISSUE_URL = /github\.com\/[\w.-]+\/[\w.-]+\/issues\/(\d+)/g;
|
|
41409
|
+
var ISSUE_WORD = /\bissue #(\d{1,6})\b/gi;
|
|
41410
|
+
var HASH_NUMBER = /(?<![\w&/#])#(\d{2,6})(?![\w-])/g;
|
|
41411
|
+
var COLOUR_NEAR = /colou?r|css|hex|rgb|background|fill|stroke|border|text-\[|bg-\[/i;
|
|
41412
|
+
var TICKET = /(?<![\w-])(([A-Z][A-Z0-9]{1,9})-\d{1,6})(?![\w-])/g;
|
|
41413
|
+
var NOT_TICKETS = new Set("UTF SHA ISO ES GPT HTTP RFC CVE COVID MD AES RSA TLS SSL IPV ECMA PEP WCAG CSS HTML ARM UTC GMT IST PST CET EST ID OS AI TS JS UI UX API URL SQL NS IE PS RS XP UTF8 H2 R2 S3 EC2 K8S".split(" "));
|
|
41414
|
+
var TICKET_URL = /(?:linear\.app\/[\w-]+\/issue|atlassian\.net\/browse)\/([A-Za-z][A-Za-z0-9]{1,9}-\d{1,6})/g;
|
|
41415
|
+
var FIGMA_URL = /figma\.com\/(?:design|file|board|proto|make|slides)\/([A-Za-z0-9]{10,})(?:\/([^\s?#)\]"'`]+))?(?:\?[^\s)\]"'`]*?node-id=([\d]+[-:][\d]+))?/g;
|
|
41416
|
+
function figmaRef(m) {
|
|
41417
|
+
let name2 = m[2];
|
|
41418
|
+
try {
|
|
41419
|
+
name2 = name2 ? decodeURIComponent(name2) : void 0;
|
|
41420
|
+
} catch {
|
|
41421
|
+
}
|
|
41422
|
+
const node2 = m[3] ? ` node ${m[3].replace("-", ":")}` : "";
|
|
41423
|
+
return `Figma ${(name2 ?? m[1]).slice(0, 40)}${node2}`;
|
|
41424
|
+
}
|
|
41408
41425
|
var COMMIT_LINE = /\[[\w./-]+ ([0-9a-f]{7,12})\][^\[]{0,300}?(?:\n|\\n) ?\d+ files? changed/g;
|
|
41409
41426
|
var COMMIT_QUOTED = /`([0-9a-f]{7,12})`/g;
|
|
41410
41427
|
function refsIn(text2, into, raw) {
|
|
41411
41428
|
for (const m of text2.matchAll(PR_URL)) into.add(`PR #${m[1]}`);
|
|
41412
|
-
|
|
41429
|
+
for (const m of text2.matchAll(ISSUE_URL)) into.add(`issue #${m[1]}`);
|
|
41430
|
+
for (const m of text2.matchAll(TICKET_URL)) into.add(m[1].toUpperCase());
|
|
41431
|
+
for (const m of text2.matchAll(FIGMA_URL)) into.add(figmaRef(m));
|
|
41432
|
+
if (!raw) {
|
|
41433
|
+
for (const m of text2.matchAll(PR_WORD)) into.add(`PR #${m[1]}`);
|
|
41434
|
+
for (const m of text2.matchAll(ISSUE_WORD)) into.add(`issue #${m[1]}`);
|
|
41435
|
+
for (const m of text2.matchAll(TICKET)) if (!NOT_TICKETS.has(m[2])) into.add(m[1]);
|
|
41436
|
+
for (const m of text2.matchAll(HASH_NUMBER)) {
|
|
41437
|
+
const n = m[1];
|
|
41438
|
+
if (into.has(`PR #${n}`) || into.has(`issue #${n}`)) continue;
|
|
41439
|
+
if (COLOUR_NEAR.test(text2.slice(Math.max(0, (m.index ?? 0) - 40), (m.index ?? 0) + 12))) continue;
|
|
41440
|
+
into.add(`#${n}`);
|
|
41441
|
+
}
|
|
41442
|
+
}
|
|
41413
41443
|
for (const m of text2.matchAll(raw ? COMMIT_LINE : COMMIT_QUOTED)) if (/\d/.test(m[1]) && /[a-f]/.test(m[1])) into.add(m[1].slice(0, 9));
|
|
41414
41444
|
}
|
|
41415
41445
|
var SYSTEM_TURN = /^(<task-notification>|<agent-message|<local-command-|Stop hook feedback|Another Claude session sent a message|\[Request interrupted|Caveat: The messages below|<system-reminder>|\[(?:Airband|Crosstalk|Relay)\])/;
|
|
@@ -41516,6 +41546,7 @@ function openItem(reply) {
|
|
|
41516
41546
|
}
|
|
41517
41547
|
function toAsk(e, n) {
|
|
41518
41548
|
const refs = /* @__PURE__ */ new Set();
|
|
41549
|
+
refsIn(e.ask, refs, false);
|
|
41519
41550
|
refsIn(e.reply, refs, false);
|
|
41520
41551
|
for (const r of e.refs) refs.add(r);
|
|
41521
41552
|
const ask = {
|
|
@@ -41740,14 +41771,14 @@ function bundledDir() {
|
|
|
41740
41771
|
}
|
|
41741
41772
|
}
|
|
41742
41773
|
function httpsGet(url2, redirects = 3) {
|
|
41743
|
-
return new Promise((
|
|
41774
|
+
return new Promise((resolve5, reject) => {
|
|
41744
41775
|
const req = https.get(url2, { timeout: 3e4, headers: { "user-agent": "airband" } }, (res) => {
|
|
41745
41776
|
const status = res.statusCode ?? 0;
|
|
41746
41777
|
if (status >= 300 && status < 400 && res.headers.location && redirects > 0) {
|
|
41747
41778
|
res.resume();
|
|
41748
41779
|
const next = new URL(res.headers.location, url2);
|
|
41749
41780
|
if (next.protocol !== "https:") return reject(new Error("refused a redirect away from https"));
|
|
41750
|
-
return
|
|
41781
|
+
return resolve5(httpsGet(next.toString(), redirects - 1));
|
|
41751
41782
|
}
|
|
41752
41783
|
if (status !== 200) {
|
|
41753
41784
|
res.resume();
|
|
@@ -41760,7 +41791,7 @@ function httpsGet(url2, redirects = 3) {
|
|
|
41760
41791
|
if (size > 8 * 1024 * 1024) req.destroy(new Error("too large"));
|
|
41761
41792
|
else chunks.push(c);
|
|
41762
41793
|
});
|
|
41763
|
-
res.on("end", () =>
|
|
41794
|
+
res.on("end", () => resolve5(Buffer.concat(chunks)));
|
|
41764
41795
|
res.on("error", reject);
|
|
41765
41796
|
});
|
|
41766
41797
|
const deadline = setTimeout(() => req.destroy(new Error("timed out")), 3e4);
|
|
@@ -41829,7 +41860,7 @@ var nameField = (n) => field(n, "name")?.text;
|
|
|
41829
41860
|
var unquote = (t) => t.replace(/^[`'"]|[`'"]$/g, "");
|
|
41830
41861
|
var hasChild = (n, test) => n.children.some((c) => !!c && test(c));
|
|
41831
41862
|
var modifiersText = (n) => n.children.filter((c) => !!c && /modifier/.test(c.type)).map((c) => c.text).join(" ");
|
|
41832
|
-
var typeKind = (
|
|
41863
|
+
var typeKind = (body3) => body3?.type === "interface_type" ? "interface" : body3?.type === "struct_type" ? "class" : "type";
|
|
41833
41864
|
var TABLES = {
|
|
41834
41865
|
go: {
|
|
41835
41866
|
defs: { function_declaration: "function", method_declaration: "method", type_spec: "type", const_spec: "const" },
|
|
@@ -42274,8 +42305,8 @@ function tsDecls(root2, jsx, isLocal) {
|
|
|
42274
42305
|
if (re) imp.re = true;
|
|
42275
42306
|
imports.push(imp);
|
|
42276
42307
|
};
|
|
42277
|
-
const classBody = (
|
|
42278
|
-
for (const m of
|
|
42308
|
+
const classBody = (body3, cls, exported) => {
|
|
42309
|
+
for (const m of body3?.namedChildren ?? []) {
|
|
42279
42310
|
if (!m) continue;
|
|
42280
42311
|
if (m.type === "method_definition" || m.type === "method_signature" || m.type === "abstract_method_signature") {
|
|
42281
42312
|
const name2 = m.childForFieldName("name")?.text;
|
|
@@ -43262,7 +43293,7 @@ function parseDoc(text2) {
|
|
|
43262
43293
|
}
|
|
43263
43294
|
return { head, body: m[2].trim() };
|
|
43264
43295
|
}
|
|
43265
|
-
function render(head,
|
|
43296
|
+
function render(head, body3) {
|
|
43266
43297
|
const lines = [`module: ${head.module}`, `status: ${head.status}`];
|
|
43267
43298
|
if (head.code) lines.push(`code: ${head.code}`);
|
|
43268
43299
|
if (head.approved) lines.push(`approved: ${head.approved}`);
|
|
@@ -43270,7 +43301,7 @@ function render(head, body2) {
|
|
|
43270
43301
|
${lines.join("\n")}
|
|
43271
43302
|
---
|
|
43272
43303
|
|
|
43273
|
-
${
|
|
43304
|
+
${body3.trim()}
|
|
43274
43305
|
`;
|
|
43275
43306
|
}
|
|
43276
43307
|
function snapshotPath(storeDir2) {
|
|
@@ -43292,9 +43323,9 @@ function readModuleDoc(root2, module2, files, storeDir2) {
|
|
|
43292
43323
|
} catch {
|
|
43293
43324
|
return { module: module2.id, file: file2, status: "missing", currentCode, body: "" };
|
|
43294
43325
|
}
|
|
43295
|
-
const { head, body:
|
|
43326
|
+
const { head, body: body3 } = parseDoc(text2);
|
|
43296
43327
|
const status = head.status === "approved" ? "approved" : "draft";
|
|
43297
|
-
const doc = { module: module2.id, file: file2, status, approvedCode: head.code, currentCode, approvedOn: head.approved, body:
|
|
43328
|
+
const doc = { module: module2.id, file: file2, status, approvedCode: head.code, currentCode, approvedOn: head.approved, body: body3 };
|
|
43298
43329
|
if (status === "approved" && head.code && head.code !== currentCode) {
|
|
43299
43330
|
const snap = readSnapshots(storeDir2)[module2.id];
|
|
43300
43331
|
if (snap) {
|
|
@@ -43308,9 +43339,9 @@ function readModuleDoc(root2, module2, files, storeDir2) {
|
|
|
43308
43339
|
}
|
|
43309
43340
|
function approveModuleDoc(root2, module2, files, storeDir2, today2 = /* @__PURE__ */ new Date()) {
|
|
43310
43341
|
const file2 = docPath(root2, module2.id);
|
|
43311
|
-
const { body:
|
|
43342
|
+
const { body: body3 } = parseDoc(fs9.readFileSync(file2, "utf8"));
|
|
43312
43343
|
const code = codeFingerprint(module2, files);
|
|
43313
|
-
fs9.writeFileSync(file2, render({ module: module2.id, status: "approved", code, approved: today2.toISOString().slice(0, 10) },
|
|
43344
|
+
fs9.writeFileSync(file2, render({ module: module2.id, status: "approved", code, approved: today2.toISOString().slice(0, 10) }, body3));
|
|
43314
43345
|
const snaps = readSnapshots(storeDir2);
|
|
43315
43346
|
snaps[module2.id] = Object.fromEntries(module2.files.map((p) => [p, files.get(p)?.h ?? ""]));
|
|
43316
43347
|
fs9.mkdirSync(storeDir2, { recursive: true });
|
|
@@ -43584,6 +43615,38 @@ function folderId(root2) {
|
|
|
43584
43615
|
function storeDir(root2) {
|
|
43585
43616
|
return airbandFile("codemap", folderId(root2));
|
|
43586
43617
|
}
|
|
43618
|
+
function mappedProjects() {
|
|
43619
|
+
const out2 = [];
|
|
43620
|
+
let dirs = [];
|
|
43621
|
+
try {
|
|
43622
|
+
dirs = fs11.readdirSync(airbandFile("codemap"));
|
|
43623
|
+
} catch {
|
|
43624
|
+
return out2;
|
|
43625
|
+
}
|
|
43626
|
+
for (const d of dirs) {
|
|
43627
|
+
try {
|
|
43628
|
+
const meta3 = JSON.parse(fs11.readFileSync(airbandFile("codemap", d, "meta.json"), "utf8"));
|
|
43629
|
+
if (meta3.root && fs11.existsSync(meta3.root)) out2.push({ name: path8.basename(meta3.root), root: meta3.root, files: meta3.files ?? 0, builtAt: meta3.builtAt ?? 0 });
|
|
43630
|
+
} catch {
|
|
43631
|
+
}
|
|
43632
|
+
}
|
|
43633
|
+
return out2.sort((a, b) => b.builtAt - a.builtAt);
|
|
43634
|
+
}
|
|
43635
|
+
function findProject(name2, from = process.cwd()) {
|
|
43636
|
+
const q = name2.trim();
|
|
43637
|
+
const all = mappedProjects();
|
|
43638
|
+
const asPath = path8.resolve(from, q.replace(/^~(?=$|\/)/, process.env.HOME ?? "~"));
|
|
43639
|
+
const byPath = all.find((p) => p.root === asPath);
|
|
43640
|
+
if (byPath) return byPath;
|
|
43641
|
+
const lower = q.toLowerCase();
|
|
43642
|
+
const exact = all.filter((p) => p.name.toLowerCase() === lower);
|
|
43643
|
+
const hits = exact.length ? exact : all.filter((p) => p.name.toLowerCase().includes(lower));
|
|
43644
|
+
if (hits.length === 1 || hits.length > 1 && exact.length === 1) return hits[0];
|
|
43645
|
+
if (hits.length > 1) return `Several mapped projects match "${q}": ${hits.map((p) => p.root).join(", ")}. Name one by its path.`;
|
|
43646
|
+
if (fs11.existsSync(asPath) && fs11.statSync(asPath).isDirectory()) return { name: path8.basename(asPath), root: asPath, files: 0, builtAt: 0 };
|
|
43647
|
+
const names = all.map((p) => p.name);
|
|
43648
|
+
return `No mapped project called "${q}".${names.length ? ` Mapped here: ${names.slice(0, 12).join(", ")}.` : ""} Map one first: airband map <folder>.`;
|
|
43649
|
+
}
|
|
43587
43650
|
|
|
43588
43651
|
// src/codemap/store.ts
|
|
43589
43652
|
var STORE_VERSION = 1;
|
|
@@ -43641,12 +43704,12 @@ function mappable(rel) {
|
|
|
43641
43704
|
return !!langOf(rel) && !SKIP_DIR.test(rel) && !TABLE_SKIP_DIR.test(rel) && !SKIP_FILE.test(rel);
|
|
43642
43705
|
}
|
|
43643
43706
|
async function listFiles(root2) {
|
|
43644
|
-
const fromGit = await new Promise((
|
|
43707
|
+
const fromGit = await new Promise((resolve5) => {
|
|
43645
43708
|
(0, import_node_child_process.execFile)(
|
|
43646
43709
|
"git",
|
|
43647
43710
|
["ls-files", "-z", "--cached", "--others", "--exclude-standard"],
|
|
43648
43711
|
{ cwd: root2, maxBuffer: 256 * 1024 * 1024 },
|
|
43649
|
-
(err2, stdout) =>
|
|
43712
|
+
(err2, stdout) => resolve5(err2 ? void 0 : stdout.split("\0").filter(Boolean))
|
|
43650
43713
|
);
|
|
43651
43714
|
});
|
|
43652
43715
|
if (fromGit) return [...new Set(fromGit)].filter(mappable).sort();
|
|
@@ -44278,6 +44341,210 @@ function clip2(text2, budget) {
|
|
|
44278
44341
|
\u2026 (cut to fit; ask about one part for more)`;
|
|
44279
44342
|
}
|
|
44280
44343
|
|
|
44344
|
+
// src/codemap/diff.ts
|
|
44345
|
+
init_define_AIRBAND_GRAMMARS();
|
|
44346
|
+
var import_node_child_process2 = require("node:child_process");
|
|
44347
|
+
var REF = /^[A-Za-z0-9][A-Za-z0-9._/@~^{}-]*$/;
|
|
44348
|
+
var PR_NUMBER = /^(?:#|pr[-/ ]?|pull\/)(\d{1,7})$/i;
|
|
44349
|
+
var FILES_MAX = 40;
|
|
44350
|
+
var FILE_BYTES_MAX = 512 * 1024;
|
|
44351
|
+
var TEST_FILE = /(^|\/)(tests?|__tests__|spec|specs)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py)$|(^|\/)test_[^/]+\.py$|Tests?\.(cs|java)$|_spec\.rb$/;
|
|
44352
|
+
var isTestFile = (p) => TEST_FILE.test(p);
|
|
44353
|
+
function git(root2, args2, maxBuffer = 16 * 1024 * 1024) {
|
|
44354
|
+
return (0, import_node_child_process2.execFileSync)("git", ["-C", root2, ...args2], { encoding: "utf8", maxBuffer, timeout: 2e4, stdio: ["ignore", "pipe", "pipe"] });
|
|
44355
|
+
}
|
|
44356
|
+
function commit(root2, ref) {
|
|
44357
|
+
if (!REF.test(ref)) return void 0;
|
|
44358
|
+
try {
|
|
44359
|
+
return git(root2, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]).trim() || void 0;
|
|
44360
|
+
} catch {
|
|
44361
|
+
return void 0;
|
|
44362
|
+
}
|
|
44363
|
+
}
|
|
44364
|
+
function defaultBranch(root2) {
|
|
44365
|
+
try {
|
|
44366
|
+
const head = git(root2, ["symbolic-ref", "--quiet", "refs/remotes/origin/HEAD"]).trim().replace(/^refs\/remotes\//, "");
|
|
44367
|
+
if (head && commit(root2, head)) return head;
|
|
44368
|
+
} catch {
|
|
44369
|
+
}
|
|
44370
|
+
return ["origin/main", "main", "origin/master", "master", "origin/develop", "develop"].find((b) => commit(root2, b));
|
|
44371
|
+
}
|
|
44372
|
+
function fetchPull(root2, n) {
|
|
44373
|
+
try {
|
|
44374
|
+
git(root2, ["fetch", "--quiet", "--no-tags", "origin", `pull/${n}/head`]);
|
|
44375
|
+
return commit(root2, "FETCH_HEAD");
|
|
44376
|
+
} catch {
|
|
44377
|
+
return void 0;
|
|
44378
|
+
}
|
|
44379
|
+
}
|
|
44380
|
+
function resolveRange(root2, range) {
|
|
44381
|
+
const r = range.trim() || "HEAD";
|
|
44382
|
+
let baseRef;
|
|
44383
|
+
let headRef = r;
|
|
44384
|
+
const two = r.split(/\.{2,3}/);
|
|
44385
|
+
if (two.length === 2) [baseRef, headRef] = [two[0] || "HEAD", two[1] || "HEAD"];
|
|
44386
|
+
let head;
|
|
44387
|
+
const pr = PR_NUMBER.exec(headRef);
|
|
44388
|
+
if (pr) {
|
|
44389
|
+
head = commit(root2, `origin/pr/${pr[1]}`) ?? fetchPull(root2, pr[1]);
|
|
44390
|
+
if (!head) return `Could not get pull request #${pr[1]} from origin. Fetch it (git fetch origin pull/${pr[1]}/head) or name its branch.`;
|
|
44391
|
+
headRef = `#${pr[1]}`;
|
|
44392
|
+
} else {
|
|
44393
|
+
head = commit(root2, headRef);
|
|
44394
|
+
if (!head) return `"${headRef}" is not a branch, tag or commit here. Try git fetch, or name it as origin/${headRef}.`;
|
|
44395
|
+
}
|
|
44396
|
+
baseRef ??= defaultBranch(root2);
|
|
44397
|
+
if (!baseRef) return "No main or master branch to compare with: give a range like main..feature.";
|
|
44398
|
+
const baseTip = commit(root2, baseRef);
|
|
44399
|
+
if (!baseTip) return `"${baseRef}" is not a branch, tag or commit here.`;
|
|
44400
|
+
let base;
|
|
44401
|
+
try {
|
|
44402
|
+
base = git(root2, ["merge-base", baseTip, head]).trim();
|
|
44403
|
+
} catch {
|
|
44404
|
+
return `${baseRef} and ${headRef} share no history.`;
|
|
44405
|
+
}
|
|
44406
|
+
return { base, head, label: `${baseRef}...${headRef}` };
|
|
44407
|
+
}
|
|
44408
|
+
function show(root2, rev, file2) {
|
|
44409
|
+
try {
|
|
44410
|
+
const text2 = git(root2, ["show", `${rev}:${file2}`], FILE_BYTES_MAX * 2);
|
|
44411
|
+
return text2.length > FILE_BYTES_MAX ? void 0 : text2;
|
|
44412
|
+
} catch {
|
|
44413
|
+
return void 0;
|
|
44414
|
+
}
|
|
44415
|
+
}
|
|
44416
|
+
var declKey = (d) => `${memberName(d)}:${d.k}`;
|
|
44417
|
+
var body2 = (lines, d) => lines.slice(d.s - 1, d.e).map((l) => l.trim()).join("\n");
|
|
44418
|
+
async function diffReport(map2, range) {
|
|
44419
|
+
const root2 = map2.root;
|
|
44420
|
+
const ends = resolveRange(root2, range);
|
|
44421
|
+
if (typeof ends === "string") return ends;
|
|
44422
|
+
const { base, head, label } = ends;
|
|
44423
|
+
let listing;
|
|
44424
|
+
try {
|
|
44425
|
+
listing = git(root2, ["diff", "--name-status", "-M", "--no-color", base, head]);
|
|
44426
|
+
} catch (err2) {
|
|
44427
|
+
return `git could not compare them: ${err2 instanceof Error ? err2.message.split("\n")[0] : String(err2)}`;
|
|
44428
|
+
}
|
|
44429
|
+
const report = { base, head, label, decls: [], other: [], testsChanged: [], skipped: [], orphans: [] };
|
|
44430
|
+
const isLocal = (s) => map2.resolver.isLocal(s);
|
|
44431
|
+
let read = 0;
|
|
44432
|
+
for (const line of listing.split("\n").filter(Boolean)) {
|
|
44433
|
+
const [status, a, b] = line.split(" ");
|
|
44434
|
+
const oldPath = a;
|
|
44435
|
+
const newPath = status.startsWith("R") || status.startsWith("C") ? b : a;
|
|
44436
|
+
if (isTestFile(newPath)) {
|
|
44437
|
+
report.testsChanged.push(newPath);
|
|
44438
|
+
continue;
|
|
44439
|
+
}
|
|
44440
|
+
const lang = langOf(newPath) ?? langOf(oldPath);
|
|
44441
|
+
if (!lang) {
|
|
44442
|
+
report.other.push(newPath);
|
|
44443
|
+
continue;
|
|
44444
|
+
}
|
|
44445
|
+
if (read >= FILES_MAX) {
|
|
44446
|
+
report.skipped.push(newPath);
|
|
44447
|
+
continue;
|
|
44448
|
+
}
|
|
44449
|
+
read++;
|
|
44450
|
+
const before = status.startsWith("A") ? "" : show(root2, base, oldPath);
|
|
44451
|
+
const after = status.startsWith("D") ? "" : show(root2, head, newPath);
|
|
44452
|
+
if (before === void 0 || after === void 0) {
|
|
44453
|
+
report.other.push(newPath);
|
|
44454
|
+
continue;
|
|
44455
|
+
}
|
|
44456
|
+
const [was, now] = await Promise.all([before ? extract(lang, before, isLocal) : void 0, after ? extract(lang, after, isLocal) : void 0]);
|
|
44457
|
+
const wasLines = before.split("\n");
|
|
44458
|
+
const nowLines = after.split("\n");
|
|
44459
|
+
const old = new Map((was?.decls ?? []).map((d) => [declKey(d), d]));
|
|
44460
|
+
const fresh = new Map((now?.decls ?? []).map((d) => [declKey(d), d]));
|
|
44461
|
+
const found = [];
|
|
44462
|
+
for (const [k, d] of fresh) {
|
|
44463
|
+
const o = old.get(k);
|
|
44464
|
+
if (!o) found.push({ change: "added", d, file: newPath });
|
|
44465
|
+
else if (body2(wasLines, o) !== body2(nowLines, d)) found.push({ change: "changed", d, file: newPath });
|
|
44466
|
+
}
|
|
44467
|
+
for (const [k, d] of old) if (!fresh.has(k)) found.push({ change: "removed", d, file: oldPath });
|
|
44468
|
+
const parents = new Set(found.filter((f) => f.d.p).map((f) => `${f.file}#${f.d.p}`));
|
|
44469
|
+
for (const f of found) {
|
|
44470
|
+
if (f.change === "changed" && !f.d.p && parents.has(`${f.file}#${f.d.n}`)) continue;
|
|
44471
|
+
report.decls.push({ change: f.change, file: f.file, name: memberName(f.d), kind: f.d.k, s: f.d.s, e: f.d.e, exported: !!f.d.x, ...reach(map2, f.file, memberName(f.d)) });
|
|
44472
|
+
}
|
|
44473
|
+
}
|
|
44474
|
+
for (const gone of report.decls.filter((d) => d.change === "removed")) {
|
|
44475
|
+
const to = report.decls.find((d) => d.change === "added" && d.name === gone.name && d.kind === gone.kind && d.file !== gone.file);
|
|
44476
|
+
if (!to) continue;
|
|
44477
|
+
to.change = "moved";
|
|
44478
|
+
to.from = gone.file;
|
|
44479
|
+
report.decls.splice(report.decls.indexOf(gone), 1);
|
|
44480
|
+
}
|
|
44481
|
+
report.orphans = orphansOf(map2, report.decls);
|
|
44482
|
+
return report;
|
|
44483
|
+
}
|
|
44484
|
+
function orphansOf(map2, decls) {
|
|
44485
|
+
const gone = new Set(decls.filter((d) => d.change === "removed").map((d) => `${d.file}#${d.name}`));
|
|
44486
|
+
if (!gone.size) return [];
|
|
44487
|
+
const out2 = /* @__PURE__ */ new Map();
|
|
44488
|
+
for (const g of gone) {
|
|
44489
|
+
const [file2, name2] = [g.slice(0, g.indexOf("#")), g.slice(g.indexOf("#") + 1)];
|
|
44490
|
+
for (const e of map2.graph.uses(file2, name2)) {
|
|
44491
|
+
const k = `${e.to.file}#${e.to.name}`;
|
|
44492
|
+
if (gone.has(k) || out2.has(k) || isTestFile(e.to.file)) continue;
|
|
44493
|
+
const others = map2.graph.usedBy(e.to.file, e.to.name).filter((c) => !gone.has(`${c.from.file}#${c.from.name}`) && `${c.from.file}#${c.from.name}` !== k);
|
|
44494
|
+
if (others.length) continue;
|
|
44495
|
+
const was = map2.graph.usedBy(e.to.file, e.to.name).filter((c) => gone.has(`${c.from.file}#${c.from.name}`)).map((c) => c.from.name);
|
|
44496
|
+
out2.set(k, { file: e.to.file, name: e.to.name, was: [...new Set(was)] });
|
|
44497
|
+
}
|
|
44498
|
+
}
|
|
44499
|
+
return [...out2.values()];
|
|
44500
|
+
}
|
|
44501
|
+
function reach(map2, file2, name2) {
|
|
44502
|
+
const callers = map2.graph.usedBy(file2, name2).filter((e) => !(e.from.file === file2 && e.from.name === name2));
|
|
44503
|
+
const tests = new Set(callers.map((e) => e.from.file).filter(isTestFile));
|
|
44504
|
+
const top = name2.split(".")[0];
|
|
44505
|
+
const importing = [...map2.graph.importers.get(file2) ?? []].filter(isTestFile);
|
|
44506
|
+
for (const f of importing) if (map2.file(f)?.i.some((imp) => imp.n?.includes(top) || imp.n?.includes("*"))) tests.add(f);
|
|
44507
|
+
const fileTests = tests.size ? [] : importing;
|
|
44508
|
+
return { callers, tests: [...tests], fileTests };
|
|
44509
|
+
}
|
|
44510
|
+
var plural2 = (n, one) => `${n} ${one}${n === 1 ? "" : "s"}`;
|
|
44511
|
+
function callerList(edges, n) {
|
|
44512
|
+
const seen = /* @__PURE__ */ new Set();
|
|
44513
|
+
const uniq = edges.filter((e) => !seen.has(`${e.from.file}#${e.from.name}`) && seen.add(`${e.from.file}#${e.from.name}`));
|
|
44514
|
+
const shown = uniq.slice(0, n).map((e) => `${e.from.name} ${e.from.file}`);
|
|
44515
|
+
return `${shown.join(", ")}${uniq.length > n ? `, \u2026 ${uniq.length - n} more` : ""}`;
|
|
44516
|
+
}
|
|
44517
|
+
function renderDiff(r, budget = 900) {
|
|
44518
|
+
const out2 = [];
|
|
44519
|
+
const files = new Set(r.decls.map((d) => d.file));
|
|
44520
|
+
out2.push(`${r.label} (${r.base.slice(0, 9)} \u2192 ${r.head.slice(0, 9)}): ${plural2(r.decls.length, "declaration")} changed in ${plural2(files.size, "file")}. Callers are from this checkout's map.`);
|
|
44521
|
+
const order = { removed: 0, changed: 1, moved: 2, added: 3 };
|
|
44522
|
+
for (const file2 of files) {
|
|
44523
|
+
out2.push(file2);
|
|
44524
|
+
const decls = r.decls.filter((d) => d.file === file2).sort((a, b) => order[a.change] - order[b.change] || a.s - b.s);
|
|
44525
|
+
for (const d of decls) {
|
|
44526
|
+
const where = d.change === "removed" ? `was :${d.s}-${d.e}` : d.from ? `:${d.s}-${d.e} from ${d.from}` : `:${d.s}-${d.e}`;
|
|
44527
|
+
let reachText;
|
|
44528
|
+
if (d.change === "removed") reachText = d.callers.length ? `still used by ${d.callers.length}: ${callerList(d.callers, 4)} (check these)` : "used by nothing now";
|
|
44529
|
+
else reachText = d.callers.length ? `used by ${d.callers.length}: ${callerList(d.callers, 4)}` : d.exported && d.change !== "added" ? "used by nothing in this map" : "";
|
|
44530
|
+
const few = (t) => `${t.slice(0, 3).join(", ")}${t.length > 3 ? ` +${t.length - 3}` : ""}`;
|
|
44531
|
+
const tests = d.tests.length ? ` \xB7 tests: ${few(d.tests)}` : !d.exported || d.change === "removed" ? "" : d.fileTests.length ? ` \xB7 no test names it (tests import its file: ${few(d.fileTests)})` : d.change === "added" ? "" : " \xB7 no test reaches it";
|
|
44532
|
+
out2.push(` ${d.change.padEnd(7)} ${d.name} ${d.kind} ${where}${reachText ? ` \xB7 ${reachText}` : ""}${tests}`);
|
|
44533
|
+
}
|
|
44534
|
+
}
|
|
44535
|
+
if (r.orphans.length) out2.push(`Left with no caller (only removed code used it): ${r.orphans.slice(0, 8).map((o) => `${o.name} ${o.file}`).join(", ")}${r.orphans.length > 8 ? `, \u2026 ${r.orphans.length - 8} more` : ""}`);
|
|
44536
|
+
if (r.testsChanged.length) out2.push(`Tests changed: ${r.testsChanged.slice(0, 8).join(", ")}${r.testsChanged.length > 8 ? `, \u2026 ${r.testsChanged.length - 8} more` : ""}`);
|
|
44537
|
+
if (r.other.length) out2.push(`Other files: ${r.other.slice(0, 10).join(", ")}${r.other.length > 10 ? `, \u2026 ${r.other.length - 10} more` : ""}`);
|
|
44538
|
+
if (r.skipped.length) out2.push(`Not read (over ${FILES_MAX} code files): ${r.skipped.slice(0, 10).join(", ")}${r.skipped.length > 10 ? ` \u2026 ${r.skipped.length - 10} more` : ""}`);
|
|
44539
|
+
if (!r.decls.length && !r.other.length && !r.testsChanged.length) out2.push("No files differ.");
|
|
44540
|
+
const text2 = out2.join("\n");
|
|
44541
|
+
const max = budget * 4;
|
|
44542
|
+
if (text2.length <= max) return text2;
|
|
44543
|
+
const cut = text2.lastIndexOf("\n", max - 40);
|
|
44544
|
+
return `${text2.slice(0, cut > 0 ? cut : max - 40)}
|
|
44545
|
+
\u2026 (cut to fit; outline or graph one file for more)`;
|
|
44546
|
+
}
|
|
44547
|
+
|
|
44281
44548
|
// src/core/tokens.ts
|
|
44282
44549
|
init_define_AIRBAND_GRAMMARS();
|
|
44283
44550
|
var fs14 = __toESM(require("node:fs"));
|
|
@@ -44727,19 +44994,21 @@ var root = process.env.AIRBAND_ROOT || process.cwd();
|
|
|
44727
44994
|
var INSTRUCTIONS = [
|
|
44728
44995
|
"Airband gives this project a map of its code and the records of the person's other AI chats on this computer.",
|
|
44729
44996
|
"- To find code (where something is defined, what calls or imports it, how a folder is laid out), call airband_map before grep, glob or reading whole files: find for a name or plain words, outline for a file or folder, graph for who uses what, no arguments for an overview. It answers in a few hundred tokens.",
|
|
44730
|
-
|
|
44997
|
+
'- To review a branch or pull request, call airband_map with diff first ("main..feature", a branch, or "#128"): what it changed, who calls each change and which tests reach it, without checking it out. Add in to ask another project the person mapped ("my-api").',
|
|
44998
|
+
"- When the person refers to earlier work or another chat (what was done, which chat changed something, what happened while they were away, a ticket like ENG-142, a PR like #128), call airband_flightlog: with query to search every chat, or with chat to read one.",
|
|
44731
44999
|
"- airband_notes holds notes chats left for this project; read them before working in an unfamiliar area, and save one when you learn something the next chat should know."
|
|
44732
45000
|
].join("\n");
|
|
44733
|
-
var server = new McpServer({ name: "airband", version: "0.0.
|
|
45001
|
+
var server = new McpServer({ name: "airband", version: "0.0.4" }, { instructions: INSTRUCTIONS });
|
|
44734
45002
|
var text = (t, isError = false) => ({ content: [{ type: "text", text: t }], ...isError ? { isError } : {} });
|
|
44735
|
-
var
|
|
44736
|
-
|
|
44737
|
-
|
|
44738
|
-
if (
|
|
44739
|
-
|
|
44740
|
-
|
|
45003
|
+
var maps = /* @__PURE__ */ new Map();
|
|
45004
|
+
async function freshMap(folder = root) {
|
|
45005
|
+
let m = maps.get(folder);
|
|
45006
|
+
if (!m) maps.set(folder, m = { map: new CodeMap(folder), at: 0 });
|
|
45007
|
+
if (Date.now() - m.at > 1500) {
|
|
45008
|
+
await m.map.refresh();
|
|
45009
|
+
m.at = Date.now();
|
|
44741
45010
|
}
|
|
44742
|
-
return
|
|
45011
|
+
return m.map;
|
|
44743
45012
|
}
|
|
44744
45013
|
function recentFiles() {
|
|
44745
45014
|
try {
|
|
@@ -44753,26 +45022,42 @@ function recentFiles() {
|
|
|
44753
45022
|
server.registerTool(
|
|
44754
45023
|
"airband_map",
|
|
44755
45024
|
{
|
|
44756
|
-
description: "
|
|
45025
|
+
description: "Code map (no AI), cheaper than grep or reading files. find: words/name \u2192 ranked code, path:start-end. outline: path/name \u2192 parts. graph: its users and uses. check: unused code, stale docs. diff: branch, a..b or #PR \u2192 changes, callers, tests. in: another project. None: overview.",
|
|
44757
45026
|
inputSchema: {
|
|
44758
45027
|
find: external_exports.string().optional(),
|
|
44759
45028
|
outline: external_exports.string().optional(),
|
|
44760
45029
|
graph: external_exports.string().optional(),
|
|
44761
45030
|
hops: external_exports.number().int().min(1).max(2).optional(),
|
|
44762
|
-
check: external_exports.enum(["unused", "docs"]).optional()
|
|
45031
|
+
check: external_exports.enum(["unused", "docs"]).optional(),
|
|
45032
|
+
diff: external_exports.string().optional(),
|
|
45033
|
+
in: external_exports.string().optional()
|
|
44763
45034
|
}
|
|
44764
45035
|
},
|
|
44765
|
-
async ({ find, outline, graph, hops, check: check2 }) => {
|
|
44766
|
-
|
|
44767
|
-
|
|
45036
|
+
async ({ find, outline, graph, hops, check: check2, diff, in: other }) => {
|
|
45037
|
+
let folder = root;
|
|
45038
|
+
let label = "";
|
|
45039
|
+
if (other) {
|
|
45040
|
+
const p = findProject(other, root);
|
|
45041
|
+
if (typeof p === "string") return text(p, true);
|
|
45042
|
+
folder = p.root;
|
|
45043
|
+
label = folder === root ? "" : `In ${p.name} (${p.root}):
|
|
45044
|
+
`;
|
|
45045
|
+
}
|
|
45046
|
+
const map2 = await freshMap(folder);
|
|
45047
|
+
const answer = (t) => text(label + t);
|
|
45048
|
+
if (diff !== void 0) {
|
|
45049
|
+
const r = await diffReport(map2, diff);
|
|
45050
|
+
return typeof r === "string" ? text(r, true) : answer(renderDiff(r));
|
|
45051
|
+
}
|
|
45052
|
+
if (check2 === "unused") return answer(map2.unusedText());
|
|
44768
45053
|
if (check2 === "docs") {
|
|
44769
45054
|
const stale = map2.staleDocs();
|
|
44770
|
-
return
|
|
45055
|
+
return answer(stale.length ? stale.map((d) => `${d.file}:${d.line} names ${d.missing} (${d.kind}), which no longer exists`).join("\n") : "Every file, hook and script the docs name exists.");
|
|
44771
45056
|
}
|
|
44772
|
-
if (find) return
|
|
44773
|
-
if (outline) return
|
|
44774
|
-
if (graph) return
|
|
44775
|
-
return
|
|
45057
|
+
if (find) return answer(map2.find(find, { focus: folder === root ? recentFiles() : [] }));
|
|
45058
|
+
if (outline) return answer(map2.outline(outline));
|
|
45059
|
+
if (graph) return answer(map2.graphOf(graph, hops ?? 1));
|
|
45060
|
+
return answer(map2.overview());
|
|
44776
45061
|
}
|
|
44777
45062
|
);
|
|
44778
45063
|
var when = (at) => new Date(at).toLocaleString("en-GB", { day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" });
|
|
@@ -44795,7 +45080,7 @@ function askLine(a) {
|
|
|
44795
45080
|
server.registerTool(
|
|
44796
45081
|
"airband_flightlog",
|
|
44797
45082
|
{
|
|
44798
|
-
description: "What AI chats on this computer were asked and did, a line per ask. No chat:
|
|
45083
|
+
description: "What AI chats on this computer were asked and did, a line per ask. No chat: list; query: search all (words, code, tickets, PRs). n: one ask whole. tokens: its token use.",
|
|
44799
45084
|
inputSchema: {
|
|
44800
45085
|
chat: external_exports.string().optional(),
|
|
44801
45086
|
query: external_exports.string().optional(),
|
|
@@ -44878,20 +45163,20 @@ async function recall(query2) {
|
|
|
44878
45163
|
server.registerTool(
|
|
44879
45164
|
"airband_notes",
|
|
44880
45165
|
{
|
|
44881
|
-
description: "Notes chats leave for this project. None: list. name: read one. title and text: save one (
|
|
45166
|
+
description: "Notes chats leave for this project. None: list. name: read one. title and text: save one (a handover).",
|
|
44882
45167
|
inputSchema: {
|
|
44883
45168
|
name: external_exports.string().optional(),
|
|
44884
45169
|
title: external_exports.string().optional(),
|
|
44885
45170
|
text: external_exports.string().optional()
|
|
44886
45171
|
}
|
|
44887
45172
|
},
|
|
44888
|
-
async ({ name: name2, title, text:
|
|
44889
|
-
if (title &&
|
|
45173
|
+
async ({ name: name2, title, text: body3 }) => {
|
|
45174
|
+
if (title && body3) {
|
|
44890
45175
|
let saved;
|
|
44891
45176
|
try {
|
|
44892
45177
|
saved = saveNote(root, title, `# ${title}
|
|
44893
45178
|
|
|
44894
|
-
${
|
|
45179
|
+
${body3.trim()}`);
|
|
44895
45180
|
} catch (err2) {
|
|
44896
45181
|
return text(err2 instanceof Error ? err2.message : String(err2), true);
|
|
44897
45182
|
}
|