@codacy/verity-cli 0.34.2 → 0.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/bin/verity.js +503 -360
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -3919,8 +3919,8 @@ var require_Collection = __commonJS2({
|
|
|
3919
3919
|
return this.items.every((node) => {
|
|
3920
3920
|
if (!identity.isPair(node))
|
|
3921
3921
|
return false;
|
|
3922
|
-
const
|
|
3923
|
-
return
|
|
3922
|
+
const n2 = node.value;
|
|
3923
|
+
return n2 == null || allowScalar && identity.isScalar(n2) && n2.value == null && !n2.commentBefore && !n2.comment && !n2.tag;
|
|
3924
3924
|
});
|
|
3925
3925
|
}
|
|
3926
3926
|
/**
|
|
@@ -5360,18 +5360,18 @@ var require_stringifyNumber = __commonJS2({
|
|
|
5360
5360
|
const num = typeof value === "number" ? value : Number(value);
|
|
5361
5361
|
if (!isFinite(num))
|
|
5362
5362
|
return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf";
|
|
5363
|
-
let
|
|
5364
|
-
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(
|
|
5365
|
-
let i2 =
|
|
5363
|
+
let n2 = Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
5364
|
+
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^\d/.test(n2)) {
|
|
5365
|
+
let i2 = n2.indexOf(".");
|
|
5366
5366
|
if (i2 < 0) {
|
|
5367
|
-
i2 =
|
|
5368
|
-
|
|
5367
|
+
i2 = n2.length;
|
|
5368
|
+
n2 += ".";
|
|
5369
5369
|
}
|
|
5370
|
-
let d = minFractionDigits - (
|
|
5370
|
+
let d = minFractionDigits - (n2.length - i2 - 1);
|
|
5371
5371
|
while (d-- > 0)
|
|
5372
|
-
|
|
5372
|
+
n2 += "0";
|
|
5373
5373
|
}
|
|
5374
|
-
return
|
|
5374
|
+
return n2;
|
|
5375
5375
|
}
|
|
5376
5376
|
exports2.stringifyNumber = stringifyNumber;
|
|
5377
5377
|
}
|
|
@@ -5615,9 +5615,9 @@ var require_binary = __commonJS2({
|
|
|
5615
5615
|
type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
|
|
5616
5616
|
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
5617
5617
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
5618
|
-
const
|
|
5619
|
-
const lines = new Array(
|
|
5620
|
-
for (let i2 = 0, o = 0; i2 <
|
|
5618
|
+
const n2 = Math.ceil(str3.length / lineWidth);
|
|
5619
|
+
const lines = new Array(n2);
|
|
5620
|
+
for (let i2 = 0, o = 0; i2 < n2; ++i2, o += lineWidth) {
|
|
5621
5621
|
lines[i2] = str3.substr(o, lineWidth);
|
|
5622
5622
|
}
|
|
5623
5623
|
str3 = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
@@ -5889,11 +5889,11 @@ var require_int2 = __commonJS2({
|
|
|
5889
5889
|
str3 = `0x${str3}`;
|
|
5890
5890
|
break;
|
|
5891
5891
|
}
|
|
5892
|
-
const
|
|
5893
|
-
return sign === "-" ? BigInt(-1) *
|
|
5892
|
+
const n3 = BigInt(str3);
|
|
5893
|
+
return sign === "-" ? BigInt(-1) * n3 : n3;
|
|
5894
5894
|
}
|
|
5895
|
-
const
|
|
5896
|
-
return sign === "-" ? -1 *
|
|
5895
|
+
const n2 = parseInt(str3, radix);
|
|
5896
|
+
return sign === "-" ? -1 * n2 : n2;
|
|
5897
5897
|
}
|
|
5898
5898
|
function intStringify(node, radix, prefix) {
|
|
5899
5899
|
const { value } = node;
|
|
@@ -6042,15 +6042,15 @@ var require_timestamp = __commonJS2({
|
|
|
6042
6042
|
function parseSexagesimal(str3, asBigInt) {
|
|
6043
6043
|
const sign = str3[0];
|
|
6044
6044
|
const parts2 = sign === "-" || sign === "+" ? str3.substring(1) : str3;
|
|
6045
|
-
const num = (
|
|
6045
|
+
const num = (n2) => asBigInt ? BigInt(n2) : Number(n2);
|
|
6046
6046
|
const res = parts2.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
|
|
6047
6047
|
return sign === "-" ? num(-1) * res : res;
|
|
6048
6048
|
}
|
|
6049
6049
|
function stringifySexagesimal(node) {
|
|
6050
6050
|
let { value } = node;
|
|
6051
|
-
let num = (
|
|
6051
|
+
let num = (n2) => n2;
|
|
6052
6052
|
if (typeof value === "bigint")
|
|
6053
|
-
num = (
|
|
6053
|
+
num = (n2) => BigInt(n2);
|
|
6054
6054
|
else if (isNaN(value) || !isFinite(value))
|
|
6055
6055
|
return stringifyNumber.stringifyNumber(node);
|
|
6056
6056
|
let sign = "";
|
|
@@ -6070,7 +6070,7 @@ var require_timestamp = __commonJS2({
|
|
|
6070
6070
|
parts2.unshift(value);
|
|
6071
6071
|
}
|
|
6072
6072
|
}
|
|
6073
|
-
return sign + parts2.map((
|
|
6073
|
+
return sign + parts2.map((n2) => String(n2).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
|
|
6074
6074
|
}
|
|
6075
6075
|
var intTime = {
|
|
6076
6076
|
identify: (value) => typeof value === "bigint" || Number.isInteger(value),
|
|
@@ -7541,9 +7541,9 @@ var require_resolve_block_scalar = __commonJS2({
|
|
|
7541
7541
|
if (!chomp && (ch === "-" || ch === "+"))
|
|
7542
7542
|
chomp = ch;
|
|
7543
7543
|
else {
|
|
7544
|
-
const
|
|
7545
|
-
if (!indent &&
|
|
7546
|
-
indent =
|
|
7544
|
+
const n2 = Number(ch);
|
|
7545
|
+
if (!indent && n2)
|
|
7546
|
+
indent = n2;
|
|
7547
7547
|
else if (error === -1)
|
|
7548
7548
|
error = offset + i2;
|
|
7549
7549
|
}
|
|
@@ -8760,8 +8760,8 @@ var require_lexer = __commonJS2({
|
|
|
8760
8760
|
return this.buffer[i2 + 1] === "\n";
|
|
8761
8761
|
return false;
|
|
8762
8762
|
}
|
|
8763
|
-
charAt(
|
|
8764
|
-
return this.buffer[this.pos +
|
|
8763
|
+
charAt(n2) {
|
|
8764
|
+
return this.buffer[this.pos + n2];
|
|
8765
8765
|
}
|
|
8766
8766
|
continueScalar(offset) {
|
|
8767
8767
|
let ch = this.buffer[offset];
|
|
@@ -8795,8 +8795,8 @@ var require_lexer = __commonJS2({
|
|
|
8795
8795
|
end -= 1;
|
|
8796
8796
|
return this.buffer.substring(this.pos, end);
|
|
8797
8797
|
}
|
|
8798
|
-
hasChars(
|
|
8799
|
-
return this.pos +
|
|
8798
|
+
hasChars(n2) {
|
|
8799
|
+
return this.pos + n2 <= this.buffer.length;
|
|
8800
8800
|
}
|
|
8801
8801
|
setNext(state) {
|
|
8802
8802
|
this.buffer = this.buffer.substring(this.pos);
|
|
@@ -8805,8 +8805,8 @@ var require_lexer = __commonJS2({
|
|
|
8805
8805
|
this.next = state;
|
|
8806
8806
|
return null;
|
|
8807
8807
|
}
|
|
8808
|
-
peek(
|
|
8809
|
-
return this.buffer.substr(this.pos,
|
|
8808
|
+
peek(n2) {
|
|
8809
|
+
return this.buffer.substr(this.pos, n2);
|
|
8810
8810
|
}
|
|
8811
8811
|
*parseNext(next) {
|
|
8812
8812
|
switch (next) {
|
|
@@ -8855,8 +8855,8 @@ var require_lexer = __commonJS2({
|
|
|
8855
8855
|
else
|
|
8856
8856
|
break;
|
|
8857
8857
|
}
|
|
8858
|
-
const
|
|
8859
|
-
yield* this.pushCount(line2.length -
|
|
8858
|
+
const n2 = (yield* this.pushCount(dirEnd)) + (yield* this.pushSpaces(true));
|
|
8859
|
+
yield* this.pushCount(line2.length - n2);
|
|
8860
8860
|
this.pushNewline();
|
|
8861
8861
|
return "stream";
|
|
8862
8862
|
}
|
|
@@ -8894,9 +8894,9 @@ var require_lexer = __commonJS2({
|
|
|
8894
8894
|
if (!ch1 && !this.atEnd)
|
|
8895
8895
|
return this.setNext("block-start");
|
|
8896
8896
|
if ((ch0 === "-" || ch0 === "?" || ch0 === ":") && isEmpty(ch1)) {
|
|
8897
|
-
const
|
|
8897
|
+
const n2 = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
|
|
8898
8898
|
this.indentNext = this.indentValue + 1;
|
|
8899
|
-
this.indentValue +=
|
|
8899
|
+
this.indentValue += n2;
|
|
8900
8900
|
return yield* this.parseBlockStart();
|
|
8901
8901
|
}
|
|
8902
8902
|
return "doc";
|
|
@@ -8906,10 +8906,10 @@ var require_lexer = __commonJS2({
|
|
|
8906
8906
|
const line2 = this.getLine();
|
|
8907
8907
|
if (line2 === null)
|
|
8908
8908
|
return this.setNext("doc");
|
|
8909
|
-
let
|
|
8910
|
-
switch (line2[
|
|
8909
|
+
let n2 = yield* this.pushIndicators();
|
|
8910
|
+
switch (line2[n2]) {
|
|
8911
8911
|
case "#":
|
|
8912
|
-
yield* this.pushCount(line2.length -
|
|
8912
|
+
yield* this.pushCount(line2.length - n2);
|
|
8913
8913
|
// fallthrough
|
|
8914
8914
|
case void 0:
|
|
8915
8915
|
yield* this.pushNewline();
|
|
@@ -8932,9 +8932,9 @@ var require_lexer = __commonJS2({
|
|
|
8932
8932
|
return yield* this.parseQuotedScalar();
|
|
8933
8933
|
case "|":
|
|
8934
8934
|
case ">":
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
yield* this.pushCount(line2.length -
|
|
8935
|
+
n2 += yield* this.parseBlockScalarHeader();
|
|
8936
|
+
n2 += yield* this.pushSpaces(true);
|
|
8937
|
+
yield* this.pushCount(line2.length - n2);
|
|
8938
8938
|
yield* this.pushNewline();
|
|
8939
8939
|
return yield* this.parseBlockScalar();
|
|
8940
8940
|
default:
|
|
@@ -8965,18 +8965,18 @@ var require_lexer = __commonJS2({
|
|
|
8965
8965
|
return yield* this.parseLineStart();
|
|
8966
8966
|
}
|
|
8967
8967
|
}
|
|
8968
|
-
let
|
|
8969
|
-
while (line2[
|
|
8970
|
-
|
|
8971
|
-
|
|
8968
|
+
let n2 = 0;
|
|
8969
|
+
while (line2[n2] === ",") {
|
|
8970
|
+
n2 += yield* this.pushCount(1);
|
|
8971
|
+
n2 += yield* this.pushSpaces(true);
|
|
8972
8972
|
this.flowKey = false;
|
|
8973
8973
|
}
|
|
8974
|
-
|
|
8975
|
-
switch (line2[
|
|
8974
|
+
n2 += yield* this.pushIndicators();
|
|
8975
|
+
switch (line2[n2]) {
|
|
8976
8976
|
case void 0:
|
|
8977
8977
|
return "flow";
|
|
8978
8978
|
case "#":
|
|
8979
|
-
yield* this.pushCount(line2.length -
|
|
8979
|
+
yield* this.pushCount(line2.length - n2);
|
|
8980
8980
|
return "flow";
|
|
8981
8981
|
case "{":
|
|
8982
8982
|
case "[":
|
|
@@ -9020,10 +9020,10 @@ var require_lexer = __commonJS2({
|
|
|
9020
9020
|
end = this.buffer.indexOf("'", end + 2);
|
|
9021
9021
|
} else {
|
|
9022
9022
|
while (end !== -1) {
|
|
9023
|
-
let
|
|
9024
|
-
while (this.buffer[end - 1 -
|
|
9025
|
-
|
|
9026
|
-
if (
|
|
9023
|
+
let n2 = 0;
|
|
9024
|
+
while (this.buffer[end - 1 - n2] === "\\")
|
|
9025
|
+
n2 += 1;
|
|
9026
|
+
if (n2 % 2 === 0)
|
|
9027
9027
|
break;
|
|
9028
9028
|
end = this.buffer.indexOf('"', end + 1);
|
|
9029
9029
|
}
|
|
@@ -9177,11 +9177,11 @@ var require_lexer = __commonJS2({
|
|
|
9177
9177
|
yield* this.pushToIndex(end + 1, true);
|
|
9178
9178
|
return inFlow ? "flow" : "doc";
|
|
9179
9179
|
}
|
|
9180
|
-
*pushCount(
|
|
9181
|
-
if (
|
|
9182
|
-
yield this.buffer.substr(this.pos,
|
|
9183
|
-
this.pos +=
|
|
9184
|
-
return
|
|
9180
|
+
*pushCount(n2) {
|
|
9181
|
+
if (n2 > 0) {
|
|
9182
|
+
yield this.buffer.substr(this.pos, n2);
|
|
9183
|
+
this.pos += n2;
|
|
9184
|
+
return n2;
|
|
9185
9185
|
}
|
|
9186
9186
|
return 0;
|
|
9187
9187
|
}
|
|
@@ -9255,12 +9255,12 @@ var require_lexer = __commonJS2({
|
|
|
9255
9255
|
do {
|
|
9256
9256
|
ch = this.buffer[++i2];
|
|
9257
9257
|
} while (ch === " " || allowTabs && ch === " ");
|
|
9258
|
-
const
|
|
9259
|
-
if (
|
|
9260
|
-
yield this.buffer.substr(this.pos,
|
|
9258
|
+
const n2 = i2 - this.pos;
|
|
9259
|
+
if (n2 > 0) {
|
|
9260
|
+
yield this.buffer.substr(this.pos, n2);
|
|
9261
9261
|
this.pos = i2;
|
|
9262
9262
|
}
|
|
9263
|
-
return
|
|
9263
|
+
return n2;
|
|
9264
9264
|
}
|
|
9265
9265
|
*pushUntil(test) {
|
|
9266
9266
|
let i2 = this.pos;
|
|
@@ -9528,8 +9528,8 @@ var require_parser = __commonJS2({
|
|
|
9528
9528
|
}
|
|
9529
9529
|
yield* this.pop();
|
|
9530
9530
|
}
|
|
9531
|
-
peek(
|
|
9532
|
-
return this.stack[this.stack.length -
|
|
9531
|
+
peek(n2) {
|
|
9532
|
+
return this.stack[this.stack.length - n2];
|
|
9533
9533
|
}
|
|
9534
9534
|
*pop(error) {
|
|
9535
9535
|
const token = error ?? this.stack.pop();
|
|
@@ -10895,8 +10895,8 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
10895
10895
|
}, "getMemory");
|
|
10896
10896
|
var isInternalSym = /* @__PURE__ */ __name((symName) => ["__cpp_exception", "__c_longjmp", "__wasm_apply_data_relocs", "__dso_handle", "__tls_size", "__tls_align", "__set_stack_limits", "_emscripten_tls_init", "__wasm_init_tls", "__wasm_call_ctors", "__start_em_asm", "__stop_em_asm", "__start_em_js", "__stop_em_js"].includes(symName) || symName.startsWith("__em_js__"), "isInternalSym");
|
|
10897
10897
|
var uleb128EncodeWithLen = /* @__PURE__ */ __name((arr) => {
|
|
10898
|
-
const
|
|
10899
|
-
return [
|
|
10898
|
+
const n2 = arr.length;
|
|
10899
|
+
return [n2 % 128 | 128, n2 >> 7, ...arr];
|
|
10900
10900
|
}, "uleb128EncodeWithLen");
|
|
10901
10901
|
var wasmTypeCodes = {
|
|
10902
10902
|
"i": 127,
|
|
@@ -13001,13 +13001,13 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
13001
13001
|
symbols.push(65535);
|
|
13002
13002
|
}
|
|
13003
13003
|
}
|
|
13004
|
-
for (let i2 = 0,
|
|
13004
|
+
for (let i2 = 0, n2 = typesBySymbol.length; i2 < n2; i2++) {
|
|
13005
13005
|
if (types.includes(typesBySymbol[i2])) {
|
|
13006
13006
|
symbols.push(i2);
|
|
13007
13007
|
}
|
|
13008
13008
|
}
|
|
13009
13009
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
13010
|
-
for (let i2 = 0,
|
|
13010
|
+
for (let i2 = 0, n2 = symbols.length; i2 < n2; i2++) {
|
|
13011
13011
|
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
13012
13012
|
}
|
|
13013
13013
|
marshalNode(this);
|
|
@@ -13196,7 +13196,7 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
13196
13196
|
}
|
|
13197
13197
|
};
|
|
13198
13198
|
function unmarshalCaptures(query, tree, address, patternIndex, result) {
|
|
13199
|
-
for (let i2 = 0,
|
|
13199
|
+
for (let i2 = 0, n2 = result.length; i2 < n2; i2++) {
|
|
13200
13200
|
const captureIndex = C.getValue(address, "i32");
|
|
13201
13201
|
address += SIZE_OF_INT;
|
|
13202
13202
|
const node = unmarshalNode(tree, address);
|
|
@@ -13335,13 +13335,13 @@ var require_web_tree_sitter2 = __commonJS2({
|
|
|
13335
13335
|
assertInternal(internal);
|
|
13336
13336
|
this[0] = address;
|
|
13337
13337
|
this.types = new Array(C._ts_language_symbol_count(this[0]));
|
|
13338
|
-
for (let i2 = 0,
|
|
13338
|
+
for (let i2 = 0, n2 = this.types.length; i2 < n2; i2++) {
|
|
13339
13339
|
if (C._ts_language_symbol_type(this[0], i2) < 2) {
|
|
13340
13340
|
this.types[i2] = C.UTF8ToString(C._ts_language_symbol_name(this[0], i2));
|
|
13341
13341
|
}
|
|
13342
13342
|
}
|
|
13343
13343
|
this.fields = new Array(C._ts_language_field_count(this[0]) + 1);
|
|
13344
|
-
for (let i2 = 0,
|
|
13344
|
+
for (let i2 = 0, n2 = this.fields.length; i2 < n2; i2++) {
|
|
13345
13345
|
const fieldName = C._ts_language_field_name_for_id(this[0], i2);
|
|
13346
13346
|
if (fieldName !== 0) {
|
|
13347
13347
|
this.fields[i2] = C.UTF8ToString(fieldName);
|
|
@@ -13844,8 +13844,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
13844
13844
|
} else {
|
|
13845
13845
|
const captureName = steps[1].name;
|
|
13846
13846
|
const stringValue = steps[2].value;
|
|
13847
|
-
const matches = /* @__PURE__ */ __name((
|
|
13848
|
-
const doesNotMatch = /* @__PURE__ */ __name((
|
|
13847
|
+
const matches = /* @__PURE__ */ __name((n2) => n2.text === stringValue, "matches");
|
|
13848
|
+
const doesNotMatch = /* @__PURE__ */ __name((n2) => n2.text !== stringValue, "doesNotMatch");
|
|
13849
13849
|
textPredicates[index].push((captures) => {
|
|
13850
13850
|
const nodes = [];
|
|
13851
13851
|
for (const c of captures) {
|
|
@@ -15210,8 +15210,8 @@ function commitsSincePaths(sha, paths) {
|
|
|
15210
15210
|
encoding: "utf-8",
|
|
15211
15211
|
stdio: ["pipe", "pipe", "pipe"]
|
|
15212
15212
|
}).trim();
|
|
15213
|
-
const
|
|
15214
|
-
return Number.isFinite(
|
|
15213
|
+
const n2 = Number.parseInt(out2, 10);
|
|
15214
|
+
return Number.isFinite(n2) ? n2 : null;
|
|
15215
15215
|
} catch {
|
|
15216
15216
|
return null;
|
|
15217
15217
|
}
|
|
@@ -15579,15 +15579,15 @@ function reverifyNudge(who) {
|
|
|
15579
15579
|
}
|
|
15580
15580
|
return null;
|
|
15581
15581
|
}
|
|
15582
|
-
function isLegacyPerRepoCredential(
|
|
15583
|
-
return
|
|
15582
|
+
function isLegacyPerRepoCredential(auth3) {
|
|
15583
|
+
return auth3.source === "local" || auth3.source === "global" && auth3.keyed === true;
|
|
15584
15584
|
}
|
|
15585
|
-
async function shouldUpgradeOnLogin(
|
|
15586
|
-
if (!isLegacyPerRepoCredential(
|
|
15587
|
-
if (
|
|
15585
|
+
async function shouldUpgradeOnLogin(auth3) {
|
|
15586
|
+
if (!isLegacyPerRepoCredential(auth3)) return false;
|
|
15587
|
+
if (auth3.userId == null) return true;
|
|
15588
15588
|
const bare = await readGlobalCredential("");
|
|
15589
15589
|
if (bare?.userId == null) return true;
|
|
15590
|
-
return bare.userId ===
|
|
15590
|
+
return bare.userId === auth3.userId;
|
|
15591
15591
|
}
|
|
15592
15592
|
function authDenialRemedy(error) {
|
|
15593
15593
|
if (error.startsWith("STALE_VERIFICATION")) {
|
|
@@ -16073,8 +16073,8 @@ async function loginOnce(opts) {
|
|
|
16073
16073
|
|
|
16074
16074
|
// src/commands/auth.ts
|
|
16075
16075
|
function registerAuthCommands(program2) {
|
|
16076
|
-
const
|
|
16077
|
-
|
|
16076
|
+
const auth3 = program2.command("auth").description("Manage project authentication");
|
|
16077
|
+
auth3.command("register").description("Register a project with Verity").requiredOption("--project <name>", "Project name").option("--remote <url>", "Git remote URL (auto-detected if omitted)").action(async (opts) => {
|
|
16078
16078
|
const globals = program2.opts();
|
|
16079
16079
|
const serviceUrl = globals.serviceUrl ?? DEFAULT_SERVICE_URL;
|
|
16080
16080
|
let remote = opts.remote;
|
|
@@ -16101,7 +16101,7 @@ function registerAuthCommands(program2) {
|
|
|
16101
16101
|
if (email) printInfo(`Authenticated as: ${email}`);
|
|
16102
16102
|
printJson({ project_id: projectId, service_url: resolvedUrl });
|
|
16103
16103
|
});
|
|
16104
|
-
|
|
16104
|
+
auth3.command("verify").description("Verify the current token is valid").action(async () => {
|
|
16105
16105
|
const globals = program2.opts();
|
|
16106
16106
|
const tokenResult = await resolveToken(globals.token);
|
|
16107
16107
|
if (!tokenResult.ok) {
|
|
@@ -16127,7 +16127,7 @@ function registerAuthCommands(program2) {
|
|
|
16127
16127
|
printInfo(`Token valid. Project: ${result.data.project_name}`);
|
|
16128
16128
|
printJson(result.data);
|
|
16129
16129
|
});
|
|
16130
|
-
|
|
16130
|
+
auth3.command("discover").description("Check if a project is registered").option("--remote <url>", "Git remote URL (auto-detected if omitted)").action(async (opts) => {
|
|
16131
16131
|
const globals = program2.opts();
|
|
16132
16132
|
let remote = opts.remote;
|
|
16133
16133
|
if (!remote) {
|
|
@@ -16718,8 +16718,8 @@ function registerLogoutCommand(program2) {
|
|
|
16718
16718
|
explain(result.error);
|
|
16719
16719
|
process.exit(1);
|
|
16720
16720
|
}
|
|
16721
|
-
const
|
|
16722
|
-
printInfo(`Revoked ${
|
|
16721
|
+
const n2 = result.data.revoked;
|
|
16722
|
+
printInfo(`Revoked ${n2} login${n2 === 1 ? "" : "s"}. \u2713`);
|
|
16723
16723
|
if (opts.others) {
|
|
16724
16724
|
printInfo(" This machine is still signed in.");
|
|
16725
16725
|
return;
|
|
@@ -18631,12 +18631,12 @@ function renderIndex(orgName, nodes) {
|
|
|
18631
18631
|
""
|
|
18632
18632
|
];
|
|
18633
18633
|
const byKind = /* @__PURE__ */ new Map();
|
|
18634
|
-
for (const
|
|
18634
|
+
for (const n2 of nodes) byKind.set(n2.kind, [...byKind.get(n2.kind) ?? [], n2]);
|
|
18635
18635
|
for (const kind2 of ORG_KINDS) {
|
|
18636
18636
|
const list2 = byKind.get(kind2);
|
|
18637
18637
|
if (!list2?.length) continue;
|
|
18638
18638
|
lines.push(`## ${kind2}/ (${list2.length})`);
|
|
18639
|
-
for (const
|
|
18639
|
+
for (const n2 of list2) lines.push(`- [[${orgNodePath(n2).split("/")[1].replace(/\.md$/, "")}]] \u2014 ${n2.title} \xB7 ${n2.origin}`);
|
|
18640
18640
|
lines.push("");
|
|
18641
18641
|
}
|
|
18642
18642
|
if (nodes.length === 0) lines.push("No org knowledge yet.", "");
|
|
@@ -18661,26 +18661,26 @@ async function pullOrgKnowledge(opts) {
|
|
|
18661
18661
|
const page = res.data;
|
|
18662
18662
|
if (page.unchanged) return { ok: true, status: "unchanged", received: 0, dir };
|
|
18663
18663
|
const org = page.organization;
|
|
18664
|
-
const nodes = org ? (page.nodes ?? []).flatMap((
|
|
18665
|
-
tag_id:
|
|
18666
|
-
node_id: typeof
|
|
18667
|
-
kind: typeof
|
|
18668
|
-
title:
|
|
18669
|
-
body:
|
|
18670
|
-
origin: typeof
|
|
18671
|
-
signal: typeof
|
|
18672
|
-
tier: typeof
|
|
18673
|
-
applies_to: Array.isArray(
|
|
18674
|
-
source_repo_count: typeof
|
|
18675
|
-
promoted_at: typeof
|
|
18664
|
+
const nodes = org ? (page.nodes ?? []).flatMap((n2) => typeof n2.tag_id === "string" && typeof n2.title === "string" && typeof n2.body === "string" ? [{
|
|
18665
|
+
tag_id: n2.tag_id,
|
|
18666
|
+
node_id: typeof n2.node_id === "string" ? n2.node_id : "",
|
|
18667
|
+
kind: typeof n2.kind === "string" ? n2.kind : "domain",
|
|
18668
|
+
title: n2.title,
|
|
18669
|
+
body: n2.body.slice(0, BODY_MAX),
|
|
18670
|
+
origin: typeof n2.origin === "string" ? n2.origin : "",
|
|
18671
|
+
signal: typeof n2.signal === "string" ? n2.signal : "",
|
|
18672
|
+
tier: typeof n2.tier === "number" ? n2.tier : null,
|
|
18673
|
+
applies_to: Array.isArray(n2.applies_to) ? n2.applies_to.filter((v) => typeof v === "string") : [],
|
|
18674
|
+
source_repo_count: typeof n2.source_repo_count === "number" ? n2.source_repo_count : 1,
|
|
18675
|
+
promoted_at: typeof n2.promoted_at === "string" ? n2.promoted_at : ""
|
|
18676
18676
|
}] : []) : [];
|
|
18677
18677
|
const written = /* @__PURE__ */ new Set();
|
|
18678
18678
|
await (0, import_promises7.mkdir)(dir, { recursive: true });
|
|
18679
|
-
for (const
|
|
18680
|
-
const rel = orgNodePath(
|
|
18679
|
+
for (const n2 of nodes) {
|
|
18680
|
+
const rel = orgNodePath(n2);
|
|
18681
18681
|
if (written.has(rel)) continue;
|
|
18682
18682
|
await (0, import_promises7.mkdir)((0, import_node_path14.join)(dir, rel.split("/")[0]), { recursive: true });
|
|
18683
|
-
await (0, import_promises7.writeFile)((0, import_node_path14.join)(dir, rel), renderOrgNode(
|
|
18683
|
+
await (0, import_promises7.writeFile)((0, import_node_path14.join)(dir, rel), renderOrgNode(n2, org?.name ?? ""));
|
|
18684
18684
|
written.add(rel);
|
|
18685
18685
|
}
|
|
18686
18686
|
for (const rel of state.files) {
|
|
@@ -18779,9 +18779,9 @@ function readOpened(fd, size) {
|
|
|
18779
18779
|
const buffer = Buffer.alloc(size);
|
|
18780
18780
|
let offset = 0;
|
|
18781
18781
|
while (offset < size) {
|
|
18782
|
-
const
|
|
18783
|
-
if (
|
|
18784
|
-
offset +=
|
|
18782
|
+
const n2 = (0, import_node_fs15.readSync)(fd, buffer, offset, size - offset, offset);
|
|
18783
|
+
if (n2 === 0) break;
|
|
18784
|
+
offset += n2;
|
|
18785
18785
|
}
|
|
18786
18786
|
return buffer.subarray(0, offset);
|
|
18787
18787
|
} finally {
|
|
@@ -18976,18 +18976,18 @@ function posteriorFor(kind2, own, pooled) {
|
|
|
18976
18976
|
return { alpha: p.alpha + Math.max(0, own.alpha), beta: p.beta + Math.max(0, own.beta) };
|
|
18977
18977
|
}
|
|
18978
18978
|
function posteriorMean(p) {
|
|
18979
|
-
const
|
|
18980
|
-
return
|
|
18979
|
+
const n2 = p.alpha + p.beta;
|
|
18980
|
+
return n2 <= 0 ? DEFAULT_PRIOR_MEAN : p.alpha / n2;
|
|
18981
18981
|
}
|
|
18982
18982
|
function scoreCandidates(nodes, ctx, opts = {}) {
|
|
18983
18983
|
const floor = opts.relevanceFloor ?? RELEVANCE_FLOOR;
|
|
18984
18984
|
const out2 = [];
|
|
18985
|
-
for (const
|
|
18986
|
-
const rel = relevance(
|
|
18985
|
+
for (const n2 of nodes) {
|
|
18986
|
+
const rel = relevance(n2, ctx);
|
|
18987
18987
|
if (rel.score < floor) continue;
|
|
18988
|
-
const post = posteriorFor(
|
|
18988
|
+
const post = posteriorFor(n2.kind, opts.posteriors?.get(n2.id), opts.kindPosteriors?.get(n2.kind));
|
|
18989
18989
|
const usefulness = posteriorMean(post);
|
|
18990
|
-
out2.push({ id:
|
|
18990
|
+
out2.push({ id: n2.id, score: rel.score * usefulness, relevance: rel.score, usefulness, via: rel.via });
|
|
18991
18991
|
}
|
|
18992
18992
|
out2.sort((a, b) => b.score - a.score || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
18993
18993
|
return out2;
|
|
@@ -19007,23 +19007,23 @@ function orgTerms(text) {
|
|
|
19007
19007
|
);
|
|
19008
19008
|
}
|
|
19009
19009
|
function sharedTerms(a, b) {
|
|
19010
|
-
let
|
|
19011
|
-
for (const w of a) if (b.has(w))
|
|
19012
|
-
return
|
|
19010
|
+
let n2 = 0;
|
|
19011
|
+
for (const w of a) if (b.has(w)) n2++;
|
|
19012
|
+
return n2;
|
|
19013
19013
|
}
|
|
19014
|
-
function orgNodeToLocal(
|
|
19014
|
+
function orgNodeToLocal(n2) {
|
|
19015
19015
|
return {
|
|
19016
|
-
path: `org:${
|
|
19017
|
-
nodeId:
|
|
19018
|
-
kind:
|
|
19019
|
-
title:
|
|
19020
|
-
body:
|
|
19016
|
+
path: `org:${n2.tag_id}`,
|
|
19017
|
+
nodeId: n2.tag_id,
|
|
19018
|
+
kind: n2.kind,
|
|
19019
|
+
title: n2.title,
|
|
19020
|
+
body: n2.body.slice(0, 2e3),
|
|
19021
19021
|
fileGlobs: [],
|
|
19022
19022
|
confidence: 0.5,
|
|
19023
19023
|
citedCount: 0,
|
|
19024
|
-
tokenEstimate: Math.ceil((
|
|
19024
|
+
tokenEstimate: Math.ceil((n2.title.length + n2.body.length) / 4) + 20,
|
|
19025
19025
|
scope: "org",
|
|
19026
|
-
origin:
|
|
19026
|
+
origin: n2.origin
|
|
19027
19027
|
};
|
|
19028
19028
|
}
|
|
19029
19029
|
function globMatch(glob, filePath) {
|
|
@@ -19136,11 +19136,11 @@ async function retrieveForInjection(promptText, taskFiles = [], budgetTokens = D
|
|
|
19136
19136
|
} catch {
|
|
19137
19137
|
}
|
|
19138
19138
|
if (nodes.length === 0) return null;
|
|
19139
|
-
const scored = nodes.map((
|
|
19140
|
-
...
|
|
19141
|
-
score: scoreNode(
|
|
19139
|
+
const scored = nodes.map((n2) => ({
|
|
19140
|
+
...n2,
|
|
19141
|
+
score: scoreNode(n2, promptTokens, taskFiles)
|
|
19142
19142
|
}));
|
|
19143
|
-
const filtered = scored.filter((
|
|
19143
|
+
const filtered = scored.filter((n2) => n2.score >= MIN_SCORE);
|
|
19144
19144
|
filtered.sort((a, b) => b.score - a.score);
|
|
19145
19145
|
const selected = [];
|
|
19146
19146
|
let tokensUsed = 0;
|
|
@@ -19153,7 +19153,7 @@ async function retrieveForInjection(promptText, taskFiles = [], budgetTokens = D
|
|
|
19153
19153
|
const lines = [
|
|
19154
19154
|
"## Project Knowledge (auto-injected)",
|
|
19155
19155
|
"",
|
|
19156
|
-
`*${selected.length} node(s) relevant to your current task. See \`.verity/memory/index.md\` for the full knowledge base${selected.some((
|
|
19156
|
+
`*${selected.length} node(s) relevant to your current task. See \`.verity/memory/index.md\` for the full knowledge base${selected.some((n2) => n2.scope === "org") ? ", and `~/.verity/orgs/` for what the organization's other repositories learned" : ""}.*`,
|
|
19157
19157
|
""
|
|
19158
19158
|
];
|
|
19159
19159
|
for (const node of selected) {
|
|
@@ -19317,9 +19317,9 @@ function parseInjectionEvent(raw) {
|
|
|
19317
19317
|
if (!nonNegInt(o.eligible, 1e5) || !nonNegInt(o.tokens, 1e6)) return null;
|
|
19318
19318
|
if (!Array.isArray(o.nodes) || o.nodes.length > MAX_NODES) return null;
|
|
19319
19319
|
const nodes = [];
|
|
19320
|
-
for (const
|
|
19321
|
-
if (!
|
|
19322
|
-
const r =
|
|
19320
|
+
for (const n2 of o.nodes) {
|
|
19321
|
+
if (!n2 || typeof n2 !== "object") return null;
|
|
19322
|
+
const r = n2;
|
|
19323
19323
|
if (typeof r.id !== "string" || !SAFE_ID.test(r.id)) return null;
|
|
19324
19324
|
if (typeof r.score !== "number" || !Number.isFinite(r.score) || r.score < 0 || r.score > 10) return null;
|
|
19325
19325
|
if (typeof r.via !== "string" || !VIA.test(r.via)) return null;
|
|
@@ -19671,9 +19671,9 @@ function readFileInside(baseDir, candidate, maxBytes) {
|
|
|
19671
19671
|
// src/lib/glob-match.ts
|
|
19672
19672
|
function globToRegex(glob) {
|
|
19673
19673
|
let out2 = "";
|
|
19674
|
-
const
|
|
19674
|
+
const n2 = glob.length;
|
|
19675
19675
|
let i2 = 0;
|
|
19676
|
-
while (i2 <
|
|
19676
|
+
while (i2 < n2) {
|
|
19677
19677
|
const c = glob[i2];
|
|
19678
19678
|
if (c === "*" && glob[i2 + 1] === "*") {
|
|
19679
19679
|
if (i2 > 0 && glob[i2 - 1] === "/" && glob[i2 + 2] === "/") {
|
|
@@ -19681,7 +19681,7 @@ function globToRegex(glob) {
|
|
|
19681
19681
|
i2 += 3;
|
|
19682
19682
|
continue;
|
|
19683
19683
|
}
|
|
19684
|
-
if (i2 > 0 && glob[i2 - 1] === "/" && i2 + 2 ===
|
|
19684
|
+
if (i2 > 0 && glob[i2 - 1] === "/" && i2 + 2 === n2) {
|
|
19685
19685
|
out2 = out2.slice(0, -1) + "(?:/.*)?";
|
|
19686
19686
|
i2 += 2;
|
|
19687
19687
|
continue;
|
|
@@ -19821,7 +19821,7 @@ async function readSyncBaseline() {
|
|
|
19821
19821
|
try {
|
|
19822
19822
|
const parsed = JSON.parse(await (0, import_promises9.readFile)(syncStateFile(), "utf-8"));
|
|
19823
19823
|
if (Array.isArray(parsed?.nodes)) {
|
|
19824
|
-
for (const
|
|
19824
|
+
for (const n2 of parsed.nodes) if (n2?.path) out2.set(n2.path, n2.hash ?? null);
|
|
19825
19825
|
} else if (Array.isArray(parsed?.paths)) {
|
|
19826
19826
|
for (const p of parsed.paths) out2.set(p, null);
|
|
19827
19827
|
}
|
|
@@ -19901,7 +19901,7 @@ async function applyMemoryWrites(writes, opts = {}) {
|
|
|
19901
19901
|
}
|
|
19902
19902
|
}
|
|
19903
19903
|
const logLines = [`- ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16)} \u2014 Applied ${count} write(s) from server`];
|
|
19904
|
-
for (const
|
|
19904
|
+
for (const n2 of notes) logLines.push(` - ${n2}`);
|
|
19905
19905
|
try {
|
|
19906
19906
|
const existing = (0, import_node_fs21.existsSync)((0, import_node_path19.join)(memoryDir2(), "log.md")) ? await (0, import_promises9.readFile)((0, import_node_path19.join)(memoryDir2(), "log.md"), "utf-8") : "# Memory Log\n\n";
|
|
19907
19907
|
await (0, import_promises9.writeFile)((0, import_node_path19.join)(memoryDir2(), "log.md"), existing + logLines.join("\n") + "\n");
|
|
@@ -21246,7 +21246,7 @@ function compactState(s) {
|
|
|
21246
21246
|
// cached row.
|
|
21247
21247
|
g: s.goal.map((g) => [g.seq, ms(g.at), g.hash, g.superseded_by, g.text ?? 0, g.text_len ?? 0, g.source ?? 0, g.status ?? 0, g.repeats ?? 0, g.truncated ? 1 : 0, g.collapsed ? 1 : 0, g.delivered ? ms(g.delivered.at) : 0, g.delivered?.seq ?? 0, g.delivered?.summary ?? 0]),
|
|
21248
21248
|
a: s.authored?.map((a) => [a.path, a.origin, a.edits, a.hunks, a.adds, a.dels, a.hash_now, a.hash_at_last_verdict, a.first_seq, a.last_seq]) ?? null,
|
|
21249
|
-
n: s.not_mine?.map((
|
|
21249
|
+
n: s.not_mine?.map((n2) => [n2.path, n2.reason, ms(n2.at), n2.head_sha]) ?? null,
|
|
21250
21250
|
t: s.statements.map((x) => [x.anchor_key, x.file, x.line, x.pattern_id, x.title_hash, x.register, x.line_sha, x.said_at_seq, ms(x.said_at), x.outcome, x.outcome_at ? ms(x.outcome_at) : 0, x.repeats, x.carried ? 1 : 0]),
|
|
21251
21251
|
c: s.commands.map((c) => [c.cls, c.cmd_hash, c.head, c.last_status, ms(c.last_at), c.last_seq, c.streak, c.edits_since, c.runs]),
|
|
21252
21252
|
d: [s.divergence.events.map((e) => [e.kind, e.path, ms(e.at)]), s.divergence.counts, s.divergence.seen],
|
|
@@ -21257,10 +21257,10 @@ function compactState(s) {
|
|
|
21257
21257
|
}
|
|
21258
21258
|
function expandState(raw) {
|
|
21259
21259
|
try {
|
|
21260
|
-
const iso = (
|
|
21260
|
+
const iso = (n3) => new Date(n3).toISOString();
|
|
21261
21261
|
const g = raw.g;
|
|
21262
21262
|
const a = raw.a;
|
|
21263
|
-
const
|
|
21263
|
+
const n2 = raw.n;
|
|
21264
21264
|
const t = raw.t;
|
|
21265
21265
|
const c = raw.c;
|
|
21266
21266
|
const dv = raw.d;
|
|
@@ -21306,7 +21306,7 @@ function expandState(raw) {
|
|
|
21306
21306
|
// which always folds the live log. If the cache is ever put on that path,
|
|
21307
21307
|
// the full list has to be encoded — see the note on `authored_all`.
|
|
21308
21308
|
authored_all: decodedAuthored ?? [],
|
|
21309
|
-
not_mine:
|
|
21309
|
+
not_mine: n2?.map((x) => ({
|
|
21310
21310
|
path: x[0],
|
|
21311
21311
|
reason: x[1],
|
|
21312
21312
|
at: iso(x[2]),
|
|
@@ -21553,7 +21553,7 @@ function projectMemory(state, opts) {
|
|
|
21553
21553
|
}));
|
|
21554
21554
|
}
|
|
21555
21555
|
if (state.not_mine && state.not_mine.length > 0) {
|
|
21556
|
-
p.not_mine = { n: state.not_mine.length, paths: state.not_mine.map((
|
|
21556
|
+
p.not_mine = { n: state.not_mine.length, paths: state.not_mine.map((n2) => n2.path) };
|
|
21557
21557
|
} else if (state.not_mine === null) {
|
|
21558
21558
|
p.not_mine = { n: -1, paths: [] };
|
|
21559
21559
|
}
|
|
@@ -21647,8 +21647,8 @@ function stateProvenance(state, opts = {}) {
|
|
|
21647
21647
|
for (const c of state.commands) {
|
|
21648
21648
|
items.push({ key: `command:${c.cls}:${c.cmd_hash}`, kind: "command", owner: "agent", age: age(c.last_seq, false) });
|
|
21649
21649
|
}
|
|
21650
|
-
for (const
|
|
21651
|
-
items.push({ key: `not_mine:${
|
|
21650
|
+
for (const n2 of state.not_mine ?? []) {
|
|
21651
|
+
items.push({ key: `not_mine:${n2.path}`, kind: "not_mine", owner: "git", age: "this_session" });
|
|
21652
21652
|
}
|
|
21653
21653
|
for (const m of state.marks) {
|
|
21654
21654
|
items.push({ key: `mark:${m.kind}:${m.seq}`, kind: "mark", owner: "agent", age: age(m.seq, false) });
|
|
@@ -21979,9 +21979,9 @@ function normaliseClass(cls) {
|
|
|
21979
21979
|
const known = ["test", "build", "lint", "typecheck", "git", "other"];
|
|
21980
21980
|
return known.includes(cls) ? cls : "other";
|
|
21981
21981
|
}
|
|
21982
|
-
function toStatus(
|
|
21983
|
-
if (
|
|
21984
|
-
if (
|
|
21982
|
+
function toStatus(n2) {
|
|
21983
|
+
if (n2 === 0) return "pass";
|
|
21984
|
+
if (n2 === 1) return "fail";
|
|
21985
21985
|
return "unknown";
|
|
21986
21986
|
}
|
|
21987
21987
|
function recordVerdict(d, v) {
|
|
@@ -22187,10 +22187,10 @@ function registerIntentCommands(program2) {
|
|
|
22187
22187
|
arm: "injected",
|
|
22188
22188
|
eligible: injection.eligible,
|
|
22189
22189
|
tokens: injection.tokensUsed,
|
|
22190
|
-
nodes: injection.nodes.map((
|
|
22191
|
-
id:
|
|
22192
|
-
score: Math.round(
|
|
22193
|
-
via: `${
|
|
22190
|
+
nodes: injection.nodes.map((n2) => ({
|
|
22191
|
+
id: n2.nodeId,
|
|
22192
|
+
score: Math.round(n2.score * 1e3) / 1e3,
|
|
22193
|
+
via: `${n2.fileGlobs.length ? "g" : ""}${n2.scope === "org" ? "o" : ""}x`
|
|
22194
22194
|
}))
|
|
22195
22195
|
});
|
|
22196
22196
|
}
|
|
@@ -24483,8 +24483,8 @@ function formatFindingsSummary(fc) {
|
|
|
24483
24483
|
if (!fc) return "-";
|
|
24484
24484
|
const parts2 = [];
|
|
24485
24485
|
for (const [key, abbrev] of SEV_ABBREV) {
|
|
24486
|
-
const
|
|
24487
|
-
if (
|
|
24486
|
+
const n2 = fc[key] ?? 0;
|
|
24487
|
+
if (n2 > 0) parts2.push(`${n2} ${abbrev}`);
|
|
24488
24488
|
}
|
|
24489
24489
|
return parts2.length > 0 ? parts2.join(", ") : "clean";
|
|
24490
24490
|
}
|
|
@@ -24674,13 +24674,13 @@ function parseJsonState(raw) {
|
|
|
24674
24674
|
}
|
|
24675
24675
|
function parseLegacyState(raw) {
|
|
24676
24676
|
const parts2 = raw.split(":");
|
|
24677
|
-
const
|
|
24678
|
-
if (isNaN(
|
|
24677
|
+
const n2 = parseInt(parts2[0], 10);
|
|
24678
|
+
if (isNaN(n2)) return null;
|
|
24679
24679
|
return {
|
|
24680
|
-
attempts:
|
|
24680
|
+
attempts: n2,
|
|
24681
24681
|
// The old file has no separate block count; the old counter is the closest
|
|
24682
24682
|
// honest answer, and it errs toward releasing sooner rather than later.
|
|
24683
|
-
blocks:
|
|
24683
|
+
blocks: n2,
|
|
24684
24684
|
fingerprint: parts2.slice(3).join(":") || null,
|
|
24685
24685
|
commit: parts2[1] ?? "",
|
|
24686
24686
|
ts: parseInt(parts2[2] ?? "0", 10)
|
|
@@ -24723,12 +24723,12 @@ function parseDuration(input) {
|
|
|
24723
24723
|
if (!m) {
|
|
24724
24724
|
return { ok: false, error: `Could not read "${input}" as a duration. Use 30m, 45s, or 1h.` };
|
|
24725
24725
|
}
|
|
24726
|
-
const
|
|
24727
|
-
if (!Number.isFinite(
|
|
24726
|
+
const n2 = parseInt(m[1], 10);
|
|
24727
|
+
if (!Number.isFinite(n2) || n2 <= 0) {
|
|
24728
24728
|
return { ok: false, error: `A duration must be a positive number of seconds, minutes or hours \u2014 got "${input}".` };
|
|
24729
24729
|
}
|
|
24730
24730
|
const unit = m[2] ?? "m";
|
|
24731
|
-
const seconds = unit === "s" ?
|
|
24731
|
+
const seconds = unit === "s" ? n2 : unit === "h" ? n2 * 3600 : n2 * 60;
|
|
24732
24732
|
if (seconds > MAX_WINDOW_SECONDS) {
|
|
24733
24733
|
return {
|
|
24734
24734
|
ok: false,
|
|
@@ -25596,8 +25596,8 @@ function extractFileSymbols(path, content, signals) {
|
|
|
25596
25596
|
add(declNameOn(deleted, rules));
|
|
25597
25597
|
}
|
|
25598
25598
|
for (const [start2, end] of signals.addedRanges) {
|
|
25599
|
-
for (let
|
|
25600
|
-
add(declNameOn(lines[
|
|
25599
|
+
for (let n2 = start2; n2 <= Math.min(end, lines.length); n2++) {
|
|
25600
|
+
add(declNameOn(lines[n2 - 1] ?? "", rules));
|
|
25601
25601
|
}
|
|
25602
25602
|
}
|
|
25603
25603
|
const scanStarts = [
|
|
@@ -25606,8 +25606,8 @@ function extractFileSymbols(path, content, signals) {
|
|
|
25606
25606
|
];
|
|
25607
25607
|
for (const start2 of scanStarts) {
|
|
25608
25608
|
const floor = Math.max(1, start2 - ENCLOSING_SCAN_LINES);
|
|
25609
|
-
for (let
|
|
25610
|
-
const name2 = declNameOn(lines[
|
|
25609
|
+
for (let n2 = Math.min(start2, lines.length); n2 >= floor; n2--) {
|
|
25610
|
+
const name2 = declNameOn(lines[n2 - 1] ?? "", rules);
|
|
25611
25611
|
if (acceptable(name2)) {
|
|
25612
25612
|
add(name2);
|
|
25613
25613
|
break;
|
|
@@ -25681,9 +25681,9 @@ function parseRgLine(line2) {
|
|
|
25681
25681
|
if (first <= 0) return null;
|
|
25682
25682
|
const second = line2.indexOf(":", first + 1);
|
|
25683
25683
|
if (second < 0) return null;
|
|
25684
|
-
const
|
|
25685
|
-
if (!Number.isFinite(
|
|
25686
|
-
return { file: line2.slice(0, first), line:
|
|
25684
|
+
const n2 = parseInt(line2.slice(first + 1, second), 10);
|
|
25685
|
+
if (!Number.isFinite(n2) || n2 < 1) return null;
|
|
25686
|
+
return { file: line2.slice(0, first), line: n2, text: line2.slice(second + 1) };
|
|
25687
25687
|
}
|
|
25688
25688
|
var isWordChar = (c) => c !== void 0 && /[A-Za-z0-9_]/.test(c);
|
|
25689
25689
|
function wordHit(text, symbol) {
|
|
@@ -25743,8 +25743,8 @@ function partitionSites(rgLines, symbols, opts) {
|
|
|
25743
25743
|
if (text.length === 0 || IMPORT_LINE.test(h.text)) continue;
|
|
25744
25744
|
if (COMMENT_LINE.test(text)) continue;
|
|
25745
25745
|
if (BARE_MEMBER_LINE.test(text) || GO_IMPORT_PATH_LINE.test(text)) continue;
|
|
25746
|
-
const
|
|
25747
|
-
if (
|
|
25746
|
+
const n2 = perFile.get(h.file) ?? 0;
|
|
25747
|
+
if (n2 >= MAX_SITES_PER_FILE) continue;
|
|
25748
25748
|
const site = {
|
|
25749
25749
|
file: h.file,
|
|
25750
25750
|
line: h.line,
|
|
@@ -25757,11 +25757,11 @@ function partitionSites(rgLines, symbols, opts) {
|
|
|
25757
25757
|
if (isTestPath(h.file)) {
|
|
25758
25758
|
if (tests.length < MAX_TEST_SLOTS) {
|
|
25759
25759
|
tests.push(site);
|
|
25760
|
-
perFile.set(h.file,
|
|
25760
|
+
perFile.set(h.file, n2 + 1);
|
|
25761
25761
|
}
|
|
25762
25762
|
} else if (callers.length + tests.length < MAX_SITES) {
|
|
25763
25763
|
callers.push(site);
|
|
25764
|
-
perFile.set(h.file,
|
|
25764
|
+
perFile.set(h.file, n2 + 1);
|
|
25765
25765
|
}
|
|
25766
25766
|
}
|
|
25767
25767
|
while (callers.length + tests.length > MAX_SITES) callers.pop();
|
|
@@ -25809,9 +25809,9 @@ function partitionImporters(rgLines, changedPaths, opts) {
|
|
|
25809
25809
|
if (!resolved) continue;
|
|
25810
25810
|
const changed = changedByKey.get(resolved);
|
|
25811
25811
|
if (!changed) continue;
|
|
25812
|
-
const
|
|
25813
|
-
if (
|
|
25814
|
-
perFile.set(h.file,
|
|
25812
|
+
const used2 = perFile.get(h.file) ?? 0;
|
|
25813
|
+
if (used2 >= MAX_IMPORTERS_PER_FILE) continue;
|
|
25814
|
+
perFile.set(h.file, used2 + 1);
|
|
25815
25815
|
out2.push({ file: h.file, line: h.line, text: h.text.trim().slice(0, SITE_TEXT_MAX), symbol: changed });
|
|
25816
25816
|
}
|
|
25817
25817
|
return out2;
|
|
@@ -25909,9 +25909,9 @@ function revisionSearch(root, rev) {
|
|
|
25909
25909
|
const line2 = prefix && raw.startsWith(prefix) ? raw.slice(prefix.length) : raw;
|
|
25910
25910
|
const hit = parseRgLine(line2);
|
|
25911
25911
|
if (!hit) continue;
|
|
25912
|
-
const
|
|
25913
|
-
if (
|
|
25914
|
-
perFile.set(hit.file,
|
|
25912
|
+
const n2 = perFile.get(hit.file) ?? 0;
|
|
25913
|
+
if (n2 >= HITS_PER_FILE) continue;
|
|
25914
|
+
perFile.set(hit.file, n2 + 1);
|
|
25915
25915
|
lines.push(`${hit.file}:${hit.line}:${hit.text.slice(0, HIT_TEXT_COLUMNS)}`);
|
|
25916
25916
|
}
|
|
25917
25917
|
return { ok: true, lines };
|
|
@@ -26030,9 +26030,9 @@ function extractEnclosingExcerpt(content, siteLine, path) {
|
|
|
26030
26030
|
if (siteLine < 1 || siteLine > lines.length) return null;
|
|
26031
26031
|
let declStart = null;
|
|
26032
26032
|
const floor = Math.max(1, siteLine - EXCERPT_DECL_SCAN);
|
|
26033
|
-
for (let
|
|
26034
|
-
if (declNameOn(lines[
|
|
26035
|
-
declStart =
|
|
26033
|
+
for (let n2 = siteLine; n2 >= floor; n2--) {
|
|
26034
|
+
if (declNameOn(lines[n2 - 1] ?? "", rules) !== null) {
|
|
26035
|
+
declStart = n2;
|
|
26036
26036
|
break;
|
|
26037
26037
|
}
|
|
26038
26038
|
}
|
|
@@ -26059,8 +26059,8 @@ function upgradeToExcerpts(rc, opts) {
|
|
|
26059
26059
|
let totalBytes = 0;
|
|
26060
26060
|
for (const site of ranked) {
|
|
26061
26061
|
if (excerpts.length >= MAX_EXCERPTS) break;
|
|
26062
|
-
const
|
|
26063
|
-
if (
|
|
26062
|
+
const used2 = perFile.get(site.file) ?? 0;
|
|
26063
|
+
if (used2 >= MAX_EXCERPTS_PER_FILE) continue;
|
|
26064
26064
|
if (!contentCache.has(site.file)) contentCache.set(site.file, opts.readFile(site.file));
|
|
26065
26065
|
const content = contentCache.get(site.file);
|
|
26066
26066
|
if (content === null || content === void 0) continue;
|
|
@@ -26076,7 +26076,7 @@ function upgradeToExcerpts(rc, opts) {
|
|
|
26076
26076
|
text: ex.text
|
|
26077
26077
|
});
|
|
26078
26078
|
totalBytes += ex.text.length;
|
|
26079
|
-
perFile.set(site.file,
|
|
26079
|
+
perFile.set(site.file, used2 + 1);
|
|
26080
26080
|
}
|
|
26081
26081
|
if (excerpts.length > 0) rc.excerpts = excerpts;
|
|
26082
26082
|
}
|
|
@@ -27313,7 +27313,7 @@ function channelSilence(input) {
|
|
|
27313
27313
|
// src/lib/cli-version.ts
|
|
27314
27314
|
function cliVersion() {
|
|
27315
27315
|
try {
|
|
27316
|
-
return true ? "0.34.
|
|
27316
|
+
return true ? "0.34.3" : "dev";
|
|
27317
27317
|
} catch {
|
|
27318
27318
|
return "dev";
|
|
27319
27319
|
}
|
|
@@ -27668,10 +27668,10 @@ function interpretAnalyzerRun(run4) {
|
|
|
27668
27668
|
function reconcileCoverage(changed, coverage) {
|
|
27669
27669
|
const changedSet = new Set(changed);
|
|
27670
27670
|
const reviewed = coverage.reviewed.filter((p) => changedSet.has(p));
|
|
27671
|
-
const claimed = /* @__PURE__ */ new Set([...reviewed, ...coverage.notReviewed.map((
|
|
27671
|
+
const claimed = /* @__PURE__ */ new Set([...reviewed, ...coverage.notReviewed.map((n2) => n2.path)]);
|
|
27672
27672
|
const unaccounted = [...changedSet].filter((p) => !claimed.has(p)).sort();
|
|
27673
27673
|
const notReviewed = [
|
|
27674
|
-
...coverage.notReviewed.filter((
|
|
27674
|
+
...coverage.notReviewed.filter((n2) => changedSet.has(n2.path)),
|
|
27675
27675
|
...unaccounted.map((path) => ({
|
|
27676
27676
|
path,
|
|
27677
27677
|
reason: "unaccounted",
|
|
@@ -27692,18 +27692,18 @@ function reconcileCoverage(changed, coverage) {
|
|
|
27692
27692
|
}
|
|
27693
27693
|
function resolveVerdict(proposed, coverage) {
|
|
27694
27694
|
if (proposed === "FAIL") return "FAIL";
|
|
27695
|
-
const blocking = coverage.notReviewed.filter((
|
|
27695
|
+
const blocking = coverage.notReviewed.filter((n2) => (n2.kind ?? "capacity") !== "policy");
|
|
27696
27696
|
if (blocking.length === 0) return proposed;
|
|
27697
27697
|
return "WARN";
|
|
27698
27698
|
}
|
|
27699
27699
|
function describeCoverage(coverage, maxPaths = 5) {
|
|
27700
|
-
const relevant = coverage.notReviewed.filter((
|
|
27700
|
+
const relevant = coverage.notReviewed.filter((n2) => (n2.kind ?? "capacity") !== "policy");
|
|
27701
27701
|
if (relevant.length === 0) return null;
|
|
27702
27702
|
const byReason = /* @__PURE__ */ new Map();
|
|
27703
|
-
for (const
|
|
27704
|
-
const key = `${
|
|
27703
|
+
for (const n2 of relevant) {
|
|
27704
|
+
const key = `${n2.reason}`;
|
|
27705
27705
|
const list2 = byReason.get(key) ?? [];
|
|
27706
|
-
list2.push(
|
|
27706
|
+
list2.push(n2.path);
|
|
27707
27707
|
byReason.set(key, list2);
|
|
27708
27708
|
}
|
|
27709
27709
|
const lines = [];
|
|
@@ -29145,10 +29145,10 @@ var MAX_WITHIN = 6;
|
|
|
29145
29145
|
var PLACEHOLDER = "${\u2026}";
|
|
29146
29146
|
var MAX_PARAMS = 12;
|
|
29147
29147
|
var PY_LOCK_ITEM = /(?:lock|Lock|mutex|Mutex|semaphore|Semaphore)\b/;
|
|
29148
|
-
var line = (
|
|
29149
|
-
var cap = (s,
|
|
29148
|
+
var line = (n2) => n2.startPosition.row + 1;
|
|
29149
|
+
var cap = (s, n2) => {
|
|
29150
29150
|
const flat = s.replace(/\s+/g, " ");
|
|
29151
|
-
return flat.length >
|
|
29151
|
+
return flat.length > n2 ? `${flat.slice(0, n2)}\u2026` : flat;
|
|
29152
29152
|
};
|
|
29153
29153
|
function qualifierOf(node, spec) {
|
|
29154
29154
|
if (spec.id === "go" && node.type === "method_declaration") {
|
|
@@ -29174,38 +29174,38 @@ function definitionsIn(root, spec) {
|
|
|
29174
29174
|
const q = qualifierOf(owner, spec);
|
|
29175
29175
|
out2.push({ name: name2, qualified: q ? `${q}.${name2}` : name2, kind: kind2, extent, last, fn });
|
|
29176
29176
|
};
|
|
29177
|
-
const visit = (
|
|
29178
|
-
const kind2 = spec.definitions[
|
|
29179
|
-
if (kind2 &&
|
|
29180
|
-
const nameNode =
|
|
29177
|
+
const visit = (n2) => {
|
|
29178
|
+
const kind2 = spec.definitions[n2.type];
|
|
29179
|
+
if (kind2 && n2.childForFieldName("body")) {
|
|
29180
|
+
const nameNode = n2.childForFieldName("name");
|
|
29181
29181
|
if (nameNode && nameNode.type !== "computed_property_name") {
|
|
29182
|
-
const inClass = qualifierOf(
|
|
29182
|
+
const inClass = qualifierOf(n2, spec) !== null;
|
|
29183
29183
|
const k = spec.id === "python" ? inClass ? "method" : "function" : kind2;
|
|
29184
|
-
add(nameNode.text, k, extentOf(
|
|
29184
|
+
add(nameNode.text, k, extentOf(n2), n2, n2, n2.parent?.type === "decorated_definition" ? n2.parent : n2);
|
|
29185
29185
|
}
|
|
29186
|
-
} else if (spec.functionValues.has(
|
|
29187
|
-
const p =
|
|
29188
|
-
const kind3 =
|
|
29189
|
-
const bound = p.childForFieldName("value")?.id ===
|
|
29186
|
+
} else if (spec.functionValues.has(n2.type) && n2.parent) {
|
|
29187
|
+
const p = n2.parent;
|
|
29188
|
+
const kind3 = n2.type === "arrow_function" ? "arrow" : n2.type === "lambda" || n2.type === "lambda_expression" ? "lambda" : "function";
|
|
29189
|
+
const bound = p.childForFieldName("value")?.id === n2.id;
|
|
29190
29190
|
if (bound && p.type === "variable_declarator" && p.childForFieldName("name")?.type === "identifier") {
|
|
29191
29191
|
const decl = p.parent && p.parent.namedChildren.filter((c) => c.type === "variable_declarator").length === 1 ? p.parent : p;
|
|
29192
|
-
add(p.childForFieldName("name").text, kind3, decl,
|
|
29192
|
+
add(p.childForFieldName("name").text, kind3, decl, n2, p);
|
|
29193
29193
|
} else if (bound && (p.type === "public_field_definition" || p.type === "field_definition")) {
|
|
29194
29194
|
const nameNode = p.childForFieldName("name") ?? p.childForFieldName("property");
|
|
29195
|
-
if (nameNode && nameNode.type !== "computed_property_name") add(nameNode.text, kind3, extentOf(p),
|
|
29195
|
+
if (nameNode && nameNode.type !== "computed_property_name") add(nameNode.text, kind3, extentOf(p), n2, p, p);
|
|
29196
29196
|
} else if (bound && p.type === "pair") {
|
|
29197
29197
|
const key = p.childForFieldName("key");
|
|
29198
|
-
if (key && (key.type === "property_identifier" || key.type === "identifier")) add(key.text, kind3, p,
|
|
29198
|
+
if (key && (key.type === "property_identifier" || key.type === "identifier")) add(key.text, kind3, p, n2, p);
|
|
29199
29199
|
} else if (p.type === "arguments" && moduleCall(p.parent)) {
|
|
29200
29200
|
const call = p.parent;
|
|
29201
29201
|
const route = p.namedChildren[0];
|
|
29202
|
-
const quoted = route && route.id !==
|
|
29202
|
+
const quoted = route && route.id !== n2.id && route.type === "string" ? unquote2(route.text) : null;
|
|
29203
29203
|
const path = quoted && /^[\w/:.{}*-]{1,60}$/.test(quoted) ? quoted : null;
|
|
29204
29204
|
const callee = call.childForFieldName("function").text;
|
|
29205
|
-
add(path ? `${callee} ${path}` : callee, kind3, call.parent,
|
|
29205
|
+
add(path ? `${callee} ${path}` : callee, kind3, call.parent, n2, call);
|
|
29206
29206
|
}
|
|
29207
29207
|
}
|
|
29208
|
-
for (const c of
|
|
29208
|
+
for (const c of n2.namedChildren) visit(c);
|
|
29209
29209
|
};
|
|
29210
29210
|
visit(root);
|
|
29211
29211
|
return out2;
|
|
@@ -29219,10 +29219,10 @@ function unquote2(s) {
|
|
|
29219
29219
|
const q3 = body2.startsWith('"""') || body2.startsWith("'''");
|
|
29220
29220
|
return q3 ? body2.slice(3, -3) : body2.slice(1, -1);
|
|
29221
29221
|
}
|
|
29222
|
-
function callParts(
|
|
29223
|
-
const args2 =
|
|
29224
|
-
if (spec.id === "java") return { receiver:
|
|
29225
|
-
let f =
|
|
29222
|
+
function callParts(n2, spec) {
|
|
29223
|
+
const args2 = n2.childForFieldName("arguments");
|
|
29224
|
+
if (spec.id === "java") return { receiver: n2.childForFieldName("object"), name: n2.childForFieldName("name")?.text ?? null, args: args2 };
|
|
29225
|
+
let f = n2.childForFieldName("function");
|
|
29226
29226
|
if (f?.type === "await_expression") f = f.namedChildren[0] ?? null;
|
|
29227
29227
|
if (!f) return { receiver: null, name: null, args: args2 };
|
|
29228
29228
|
if (f.type === "identifier") return { receiver: null, name: f.text, args: args2 };
|
|
@@ -29252,14 +29252,14 @@ function withLabel(item) {
|
|
|
29252
29252
|
if (value.type === "attribute") return value.childForFieldName("attribute")?.text ?? null;
|
|
29253
29253
|
return value.text;
|
|
29254
29254
|
}
|
|
29255
|
-
function isChained(
|
|
29256
|
-
const p =
|
|
29255
|
+
function isChained(n2) {
|
|
29256
|
+
const p = n2.parent;
|
|
29257
29257
|
if (!p) return false;
|
|
29258
29258
|
const object = p.childForFieldName("object") ?? p.childForFieldName("operand");
|
|
29259
|
-
return object?.id ===
|
|
29259
|
+
return object?.id === n2.id && (p.type === "member_expression" || p.type === "attribute" || p.type === "selector_expression" || p.type === "method_invocation");
|
|
29260
29260
|
}
|
|
29261
|
-
function isAwaited(
|
|
29262
|
-
let p =
|
|
29261
|
+
function isAwaited(n2) {
|
|
29262
|
+
let p = n2.parent;
|
|
29263
29263
|
while (p && p.type === "parenthesized_expression") p = p.parent;
|
|
29264
29264
|
return !!p && (p.type === "await_expression" || p.type === "await");
|
|
29265
29265
|
}
|
|
@@ -29283,17 +29283,17 @@ function factsOf(def, spec, defs, path) {
|
|
|
29283
29283
|
const tries = [];
|
|
29284
29284
|
const locks = [];
|
|
29285
29285
|
const bindings = {};
|
|
29286
|
-
const bind = (
|
|
29286
|
+
const bind = (n2) => {
|
|
29287
29287
|
let name2 = null;
|
|
29288
29288
|
let value = null;
|
|
29289
|
-
if (
|
|
29290
|
-
name2 =
|
|
29291
|
-
value =
|
|
29292
|
-
} else if (
|
|
29293
|
-
name2 =
|
|
29294
|
-
value =
|
|
29295
|
-
} else if (
|
|
29296
|
-
const l =
|
|
29289
|
+
if (n2.type === "variable_declarator") {
|
|
29290
|
+
name2 = n2.childForFieldName("name");
|
|
29291
|
+
value = n2.childForFieldName("value");
|
|
29292
|
+
} else if (n2.type === "assignment" && spec.id === "python") {
|
|
29293
|
+
name2 = n2.childForFieldName("left");
|
|
29294
|
+
value = n2.childForFieldName("right");
|
|
29295
|
+
} else if (n2.type === "short_var_declaration") {
|
|
29296
|
+
const l = n2.childForFieldName("left"), r = n2.childForFieldName("right");
|
|
29297
29297
|
if (l?.namedChildren.length === 1 && r?.namedChildren.length === 1) {
|
|
29298
29298
|
name2 = l.namedChildren[0];
|
|
29299
29299
|
value = r.namedChildren[0];
|
|
@@ -29301,68 +29301,68 @@ function factsOf(def, spec, defs, path) {
|
|
|
29301
29301
|
}
|
|
29302
29302
|
if (name2?.type === "identifier" && value && Object.keys(bindings).length < 40 && !(name2.text in bindings)) bindings[name2.text] = cap(value.text, TEXT_CAP);
|
|
29303
29303
|
};
|
|
29304
|
-
const throwsIn = (
|
|
29305
|
-
if (spec.throws.has(
|
|
29306
|
-
if (defs.has(
|
|
29307
|
-
return
|
|
29304
|
+
const throwsIn = (n2) => {
|
|
29305
|
+
if (spec.throws.has(n2.type)) return true;
|
|
29306
|
+
if (defs.has(n2.id) || spec.functionValues.has(n2.type)) return false;
|
|
29307
|
+
return n2.namedChildren.some(throwsIn);
|
|
29308
29308
|
};
|
|
29309
|
-
const walk2 = (
|
|
29310
|
-
const anonymousMember =
|
|
29311
|
-
if (
|
|
29312
|
-
const t =
|
|
29313
|
-
bind(
|
|
29309
|
+
const walk2 = (n2, ctx) => {
|
|
29310
|
+
const anonymousMember = n2.parent?.type === "class_body" && n2.parent.parent?.type === "object_creation_expression";
|
|
29311
|
+
if (n2.id !== def.fn.id && !anonymousMember && (defs.has(n2.id) || spec.classes.has(n2.type) || spec.definitions[n2.type])) return;
|
|
29312
|
+
const t = n2.type;
|
|
29313
|
+
bind(n2);
|
|
29314
29314
|
const down = (c, next = ctx) => walk2(c, next);
|
|
29315
29315
|
if (spec.calls.has(t)) {
|
|
29316
|
-
const { receiver, name: name2, args: args2 } = callParts(
|
|
29316
|
+
const { receiver, name: name2, args: args2 } = callParts(n2, spec);
|
|
29317
29317
|
if (name2) {
|
|
29318
29318
|
calls.push({
|
|
29319
|
-
line: line(
|
|
29320
|
-
col:
|
|
29319
|
+
line: line(n2),
|
|
29320
|
+
col: n2.startPosition.column,
|
|
29321
29321
|
receiver: receiver ? cap(receiver.text, TEXT_CAP) : null,
|
|
29322
29322
|
name: name2,
|
|
29323
29323
|
args: argsOf(args2, spec),
|
|
29324
|
-
awaited: isAwaited(
|
|
29325
|
-
chained: isChained(
|
|
29324
|
+
awaited: isAwaited(n2) || n2.childForFieldName("function")?.type === "await_expression",
|
|
29325
|
+
chained: isChained(n2),
|
|
29326
29326
|
inLoop: ctx.inLoop,
|
|
29327
29327
|
inTry: ctx.tryAt !== null,
|
|
29328
29328
|
tryAt: ctx.tryAt,
|
|
29329
29329
|
within: ctx.within.slice(-MAX_WITHIN)
|
|
29330
29330
|
});
|
|
29331
|
-
if (spec.lockCalls.has(name2)) locks.push(line(
|
|
29332
|
-
for (const c of
|
|
29331
|
+
if (spec.lockCalls.has(name2)) locks.push(line(n2));
|
|
29332
|
+
for (const c of n2.namedChildren) down(c, c.id === args2?.id ? { ...ctx, within: [...ctx.within, name2] } : ctx);
|
|
29333
29333
|
return;
|
|
29334
29334
|
}
|
|
29335
29335
|
}
|
|
29336
|
-
if (spec.awaits.has(t)) awaits.push(line(
|
|
29336
|
+
if (spec.awaits.has(t)) awaits.push(line(n2));
|
|
29337
29337
|
if (t === "defer_statement") {
|
|
29338
|
-
for (const c of
|
|
29338
|
+
for (const c of n2.namedChildren) down(c, { ...ctx, within: [...ctx.within, "defer"] });
|
|
29339
29339
|
return;
|
|
29340
29340
|
}
|
|
29341
29341
|
if (spec.lockNodes.has(t)) {
|
|
29342
|
-
locks.push(line(
|
|
29343
|
-
for (const c of
|
|
29342
|
+
locks.push(line(n2));
|
|
29343
|
+
for (const c of n2.namedChildren) down(c, { ...ctx, within: [...ctx.within, "synchronized"] });
|
|
29344
29344
|
return;
|
|
29345
29345
|
}
|
|
29346
29346
|
if (t === "with_statement") {
|
|
29347
|
-
const item =
|
|
29348
|
-
if (PY_LOCK_ITEM.test(item?.text ?? "")) locks.push(line(
|
|
29347
|
+
const item = n2.namedChildren[0];
|
|
29348
|
+
if (PY_LOCK_ITEM.test(item?.text ?? "")) locks.push(line(n2));
|
|
29349
29349
|
const label2 = withLabel(item);
|
|
29350
|
-
for (const c of
|
|
29350
|
+
for (const c of n2.namedChildren) down(c, c.type === "block" && label2 ? { ...ctx, within: [...ctx.within, label2] } : ctx);
|
|
29351
29351
|
return;
|
|
29352
29352
|
}
|
|
29353
29353
|
if (spec.loops.has(t)) {
|
|
29354
|
-
loops.push(line(
|
|
29355
|
-
for (const c of
|
|
29354
|
+
loops.push(line(n2));
|
|
29355
|
+
for (const c of n2.namedChildren) down(c, { ...ctx, inLoop: true });
|
|
29356
29356
|
return;
|
|
29357
29357
|
}
|
|
29358
29358
|
if (spec.tries.has(t)) {
|
|
29359
|
-
const handlers =
|
|
29360
|
-
tries.push({ line: line(
|
|
29361
|
-
const body2 =
|
|
29362
|
-
for (const c of
|
|
29359
|
+
const handlers = n2.namedChildren.filter((c) => spec.handlers.has(c.type));
|
|
29360
|
+
tries.push({ line: line(n2), end: n2.endPosition.row + 1, catches: handlers.length > 0, rethrows: handlers.some(throwsIn) });
|
|
29361
|
+
const body2 = n2.childForFieldName("body");
|
|
29362
|
+
for (const c of n2.namedChildren) down(c, c.id === body2?.id ? { ...ctx, tryAt: line(n2) } : ctx);
|
|
29363
29363
|
return;
|
|
29364
29364
|
}
|
|
29365
|
-
for (const c of
|
|
29365
|
+
for (const c of n2.namedChildren) down(c);
|
|
29366
29366
|
};
|
|
29367
29367
|
const synchronizedMethod = spec.id === "java" && /\bsynchronized\b/.test(def.fn.namedChildren.find((c) => c.type === "modifiers")?.text ?? "");
|
|
29368
29368
|
walk2(def.fn, { inLoop: false, tryAt: null, within: synchronizedMethod ? ["synchronized"] : [] });
|
|
@@ -29432,11 +29432,11 @@ function regionOf(rt, path, content, fn, changed, maxLines, deadlineAt) {
|
|
|
29432
29432
|
if (!tree) return { source: "fallback", reason: "deadline", elapsedMs: Date.now() - started };
|
|
29433
29433
|
try {
|
|
29434
29434
|
const lines = content.split("\n");
|
|
29435
|
-
let
|
|
29435
|
+
let n2 = tree.rootNode.descendantForPosition({ row: from - 1, column: 0 }, { row: to - 1, column: (lines[to - 1] ?? "").length });
|
|
29436
29436
|
let block = null;
|
|
29437
|
-
for (;
|
|
29438
|
-
if (BLOCKS.has(
|
|
29439
|
-
block =
|
|
29437
|
+
for (; n2 && line(n2) >= fn.start.line; n2 = n2.parent) {
|
|
29438
|
+
if (BLOCKS.has(n2.type) && n2.endPosition.row + 1 - line(n2) + 1 > maxLines) {
|
|
29439
|
+
block = n2;
|
|
29440
29440
|
break;
|
|
29441
29441
|
}
|
|
29442
29442
|
}
|
|
@@ -29482,8 +29482,8 @@ var STABLE_EXPRESSION = (t) => {
|
|
|
29482
29482
|
function argResource(kind2, arg) {
|
|
29483
29483
|
if (!arg) return { kind: kind2, name: null, confidence: "unknown" };
|
|
29484
29484
|
if (arg.literal !== null) {
|
|
29485
|
-
const
|
|
29486
|
-
return
|
|
29485
|
+
const n2 = literalName(arg.literal);
|
|
29486
|
+
return n2 ? { kind: kind2, name: n2.name, confidence: n2.confidence } : { kind: kind2, name: null, confidence: "unknown" };
|
|
29487
29487
|
}
|
|
29488
29488
|
if (SIMPLE_EXPRESSION.test(arg.text) && STABLE_EXPRESSION(arg.text)) return { kind: kind2, name: arg.text, confidence: "expression" };
|
|
29489
29489
|
const keyed = keyedCall(arg.text);
|
|
@@ -29832,7 +29832,7 @@ function accessMap(input) {
|
|
|
29832
29832
|
const effects = effectsWithHelpers(target, fileFns, lang, 2, state);
|
|
29833
29833
|
const byName = new Map(fileFns.map((f) => [f.name, f]));
|
|
29834
29834
|
const helperNames = new Set(effects.flatMap((e) => e.via));
|
|
29835
|
-
const helpers = [...helperNames].map((
|
|
29835
|
+
const helpers = [...helperNames].map((n2) => byName.get(n2)).filter((f) => !!f && f !== target && !inside(f, target)).slice(0, MAX_HELPERS);
|
|
29836
29836
|
const named = effects.filter((e) => e.resource.name !== null && e.resource.confidence !== "unknown");
|
|
29837
29837
|
const resources = [];
|
|
29838
29838
|
for (const e of [...named.filter((x) => x.op === "write"), ...named.filter((x) => x.op === "read")]) {
|
|
@@ -29995,8 +29995,8 @@ function declaredType(scope2, v, lang) {
|
|
|
29995
29995
|
function classesIn(content, lang) {
|
|
29996
29996
|
const lines = content.split("\n");
|
|
29997
29997
|
const out2 = [];
|
|
29998
|
-
for (let
|
|
29999
|
-
const l = lines[
|
|
29998
|
+
for (let n2 = 0; n2 < lines.length; n2++) {
|
|
29999
|
+
const l = lines[n2];
|
|
30000
30000
|
let name2 = null, base = null, impl = [];
|
|
30001
30001
|
if (lang === "python") {
|
|
30002
30002
|
const m2 = /^(\s*)class\s+([A-Za-z_]\w*)\s*(?:\(([^)]*)\))?\s*:/.exec(l);
|
|
@@ -30004,17 +30004,17 @@ function classesIn(content, lang) {
|
|
|
30004
30004
|
name2 = m2[2];
|
|
30005
30005
|
base = (m2[3] ?? "").split(",").map((x) => x.trim().split(".").pop() ?? "").find((x) => /^[A-Z]/.test(x) && x !== "object") ?? null;
|
|
30006
30006
|
const indent = m2[1].length;
|
|
30007
|
-
let end2 =
|
|
30007
|
+
let end2 = n2 + 1;
|
|
30008
30008
|
while (end2 < lines.length && (lines[end2].trim() === "" || lines[end2].search(/\S/) > indent)) end2++;
|
|
30009
|
-
out2.push({ name: name2, base, implementsList: [], start:
|
|
30009
|
+
out2.push({ name: name2, base, implementsList: [], start: n2 + 1, end: end2 });
|
|
30010
30010
|
continue;
|
|
30011
30011
|
}
|
|
30012
30012
|
if (lang === "go") {
|
|
30013
30013
|
const m2 = /^\s*type\s+([A-Z_a-z]\w*)\s+(struct|interface)\s*\{/.exec(l);
|
|
30014
30014
|
if (!m2) continue;
|
|
30015
|
-
let end2 =
|
|
30015
|
+
let end2 = n2;
|
|
30016
30016
|
while (end2 < lines.length && !/^\s*\}/.test(lines[end2])) end2++;
|
|
30017
|
-
out2.push({ name: m2[1], base: null, implementsList: [], start:
|
|
30017
|
+
out2.push({ name: m2[1], base: null, implementsList: [], start: n2 + 1, end: end2 + 1 });
|
|
30018
30018
|
continue;
|
|
30019
30019
|
}
|
|
30020
30020
|
const m = /\b(?:class|interface)\s+([A-Za-z_$][\w$]*)(?:<[^{]*?>)?\s*(?:extends\s+([\w$.]+)(?:<[^{]*?>)?)?\s*(?:implements\s+([^{]+))?\{?/.exec(l);
|
|
@@ -30022,8 +30022,8 @@ function classesIn(content, lang) {
|
|
|
30022
30022
|
name2 = m[1];
|
|
30023
30023
|
base = m[2] ? m[2].split(".").pop() ?? null : null;
|
|
30024
30024
|
impl = (m[3] ?? "").split(",").map((x) => x.trim().replace(/<.*$/, "").split(".").pop() ?? "").filter(isIdent);
|
|
30025
|
-
let depth = 0, seen = false, end =
|
|
30026
|
-
for (let k =
|
|
30025
|
+
let depth = 0, seen = false, end = n2;
|
|
30026
|
+
for (let k = n2; k < lines.length; k++) {
|
|
30027
30027
|
for (const ch of lines[k]) {
|
|
30028
30028
|
if (ch === "{") {
|
|
30029
30029
|
depth++;
|
|
@@ -30036,7 +30036,7 @@ function classesIn(content, lang) {
|
|
|
30036
30036
|
}
|
|
30037
30037
|
end = k;
|
|
30038
30038
|
}
|
|
30039
|
-
out2.push({ name: name2, base, implementsList: impl, start:
|
|
30039
|
+
out2.push({ name: name2, base, implementsList: impl, start: n2 + 1, end: end + 1 });
|
|
30040
30040
|
}
|
|
30041
30041
|
return out2;
|
|
30042
30042
|
}
|
|
@@ -30494,7 +30494,7 @@ function definitionOf(input) {
|
|
|
30494
30494
|
const caller = at ? fns.filter((f) => f.start.line <= at && at <= f.end.line).sort((a, b) => a.end.line - a.start.line - (b.end.line - b.start.line))[0] ?? null : null;
|
|
30495
30495
|
const tsCache = /* @__PURE__ */ new Map();
|
|
30496
30496
|
const resolveImport = (spec, from) => moduleFiles(source2, spec, from, lang, tsCache);
|
|
30497
|
-
const imports = (c,
|
|
30497
|
+
const imports = (c, n2) => importOf(c, lang, n2, null);
|
|
30498
30498
|
let type = receiverType(content, lang, caller, receiver, at) ?? fieldChainType({ content, lang, caller, receiver, line: at, fromPath: path, source: source2, resolveImport, importOf: imports });
|
|
30499
30499
|
if (type?.startsWith(RESULT_OF)) {
|
|
30500
30500
|
const [fnName, idx] = type.slice(RESULT_OF.length).split("#");
|
|
@@ -30519,7 +30519,7 @@ function definitionOf(input) {
|
|
|
30519
30519
|
source: source2,
|
|
30520
30520
|
outline,
|
|
30521
30521
|
resolveImport: (spec, from) => moduleFiles(source2, spec, from, lang, tsCache),
|
|
30522
|
-
importOf: (c,
|
|
30522
|
+
importOf: (c, n2) => importOf(c, lang, n2, null)
|
|
30523
30523
|
});
|
|
30524
30524
|
for (const h of hits) add([h.fn], h.how === "class" ? "type" : h.how);
|
|
30525
30525
|
}
|
|
@@ -30663,7 +30663,7 @@ function callersOf(input) {
|
|
|
30663
30663
|
let tie = fileTie;
|
|
30664
30664
|
if (owner) {
|
|
30665
30665
|
if (!c.receiver) continue;
|
|
30666
|
-
const imports = (cc,
|
|
30666
|
+
const imports = (cc, n2) => importOf(cc, lang, n2, null);
|
|
30667
30667
|
const resolveImport = (spec, from) => moduleFiles(source2, spec, from, lang, cache);
|
|
30668
30668
|
const type = receiverType(read2.content, lang, fn, c.receiver, c.line) ?? fieldChainType({ content: read2.content, lang, caller: fn, receiver: c.receiver, line: c.line, fromPath: p, source: source2, resolveImport, importOf: imports });
|
|
30669
30669
|
if (type !== owner) continue;
|
|
@@ -30809,8 +30809,8 @@ var SOURCE_EXTS = ["ts", "tsx", "mts", "cts", "js", "jsx", "mjs", "cjs", "py", "
|
|
|
30809
30809
|
function parseHit(line2) {
|
|
30810
30810
|
const m = /^(.+?):(\d+):(.*)$/.exec(line2);
|
|
30811
30811
|
if (!m) return null;
|
|
30812
|
-
const
|
|
30813
|
-
return
|
|
30812
|
+
const n2 = Number(m[2]);
|
|
30813
|
+
return n2 >= 1 ? { path: m[1], line: n2, text: m[3] } : null;
|
|
30814
30814
|
}
|
|
30815
30815
|
function capHits(lines, maxHits) {
|
|
30816
30816
|
const hits = [];
|
|
@@ -31374,15 +31374,15 @@ function functionWindow(codeMap, path, content, line2, maxLines) {
|
|
|
31374
31374
|
}
|
|
31375
31375
|
function writerExcerpts(codeMap, writers, read2, maxLines, maxChars, budget) {
|
|
31376
31376
|
const out2 = [];
|
|
31377
|
-
let
|
|
31377
|
+
let used2 = 0;
|
|
31378
31378
|
for (const w of writers) {
|
|
31379
31379
|
const content = read2(w.file);
|
|
31380
31380
|
if (content === null) continue;
|
|
31381
31381
|
const win = functionWindow(codeMap, w.file, content, w.line, maxLines);
|
|
31382
31382
|
if (!win) continue;
|
|
31383
31383
|
const text = content.split("\n").slice(win.start_line - 1, win.end_line).join("\n").slice(0, maxChars);
|
|
31384
|
-
if (
|
|
31385
|
-
|
|
31384
|
+
if (used2 + text.length > budget) break;
|
|
31385
|
+
used2 += text.length;
|
|
31386
31386
|
out2.push({ file: w.file, start_line: win.start_line, symbol: `${w.symbol} (writes ${w.resource}, like ${w.changed})`, kind: "writer", text });
|
|
31387
31387
|
}
|
|
31388
31388
|
return out2;
|
|
@@ -31509,7 +31509,7 @@ function splitClaudeMdSections(content) {
|
|
|
31509
31509
|
}
|
|
31510
31510
|
function classifyClaudeSection(heading) {
|
|
31511
31511
|
const h = heading.toLowerCase();
|
|
31512
|
-
const hasAny = (needles) => needles.some((
|
|
31512
|
+
const hasAny = (needles) => needles.some((n2) => h.includes(n2));
|
|
31513
31513
|
if (hasAny(["security", "auth", "secret", "credential", "cwe", "vulnerabilit", "sanitiz"])) return "security";
|
|
31514
31514
|
if (hasAny(["gotcha", "caveat", "pitfall", "footgun", "beware", "watch out", "known issue", "warning"])) return "gotcha";
|
|
31515
31515
|
if (hasAny(["decision", "adr", "rationale", "why we", "chose", "trade-off", "tradeoff"])) return "decision";
|
|
@@ -31722,7 +31722,7 @@ async function serverSeedTitles(opts) {
|
|
|
31722
31722
|
});
|
|
31723
31723
|
if (!res.ok || !Array.isArray(res.data.nodes)) return null;
|
|
31724
31724
|
const titles = /* @__PURE__ */ new Set();
|
|
31725
|
-
for (const
|
|
31725
|
+
for (const n2 of res.data.nodes) if (typeof n2?.title === "string") titles.add(normalizeTitle(n2.title));
|
|
31726
31726
|
return titles;
|
|
31727
31727
|
}
|
|
31728
31728
|
function renderNodeMarkdown(candidate, nodeId, createdAt) {
|
|
@@ -32508,7 +32508,7 @@ function redactRequest(body2) {
|
|
|
32508
32508
|
undelivered: true,
|
|
32509
32509
|
total_files: files.length,
|
|
32510
32510
|
total_bytes: files.reduce(
|
|
32511
|
-
(
|
|
32511
|
+
(n2, f) => n2 + (typeof f.content === "string" ? f.content.length : 0),
|
|
32512
32512
|
0
|
|
32513
32513
|
),
|
|
32514
32514
|
// Paths only. A path is already visible in the repository; the content is not.
|
|
@@ -33027,10 +33027,10 @@ async function writePullState(state) {
|
|
|
33027
33027
|
} catch {
|
|
33028
33028
|
}
|
|
33029
33029
|
}
|
|
33030
|
-
function pullsAtSessionStart(
|
|
33030
|
+
function pullsAtSessionStart(auth3, source2) {
|
|
33031
33031
|
if (source2 === "compact") return false;
|
|
33032
|
-
if (
|
|
33033
|
-
return
|
|
33032
|
+
if (auth3.source === "env" || auth3.source === "flag") return true;
|
|
33033
|
+
return auth3.userId != null;
|
|
33034
33034
|
}
|
|
33035
33035
|
function spawnBackgroundPull(deps = {}) {
|
|
33036
33036
|
const d = {
|
|
@@ -33151,7 +33151,7 @@ async function render(run4) {
|
|
|
33151
33151
|
const memoryNodesUsed = response.memory_nodes_used;
|
|
33152
33152
|
const lessonsUsed = response.lessons_used;
|
|
33153
33153
|
if (memoryNodesUsed && memoryNodesUsed.length > 0) {
|
|
33154
|
-
const nodeRefs = memoryNodesUsed.slice(0, 5).map((
|
|
33154
|
+
const nodeRefs = memoryNodesUsed.slice(0, 5).map((n2) => n2.node_id).join(", ");
|
|
33155
33155
|
process.stderr.write(`${DIM}Memory: ${memoryNodesUsed.length} nodes \u2014 ${nodeRefs}${NC}
|
|
33156
33156
|
`);
|
|
33157
33157
|
} else if (lessonsUsed && lessonsUsed.length > 0) {
|
|
@@ -34057,9 +34057,9 @@ function trackedSourceFiles(root, opts = {}) {
|
|
|
34057
34057
|
}
|
|
34058
34058
|
var EFFECT_LINE = /\bawait\b|\basync\s+with\b|\.then\(|\bsetTimeout\(|\bsetInterval\(|\bwith\s+\w[\w.]*\.(?:lock|acquire)\b|\bLock\(\)/;
|
|
34059
34059
|
function countEffects(text) {
|
|
34060
|
-
let
|
|
34061
|
-
for (const line2 of text.split("\n")) if (EFFECT_LINE.test(line2))
|
|
34062
|
-
return
|
|
34060
|
+
let n2 = 0;
|
|
34061
|
+
for (const line2 of text.split("\n")) if (EFFECT_LINE.test(line2)) n2++;
|
|
34062
|
+
return n2;
|
|
34063
34063
|
}
|
|
34064
34064
|
function scanRisk(text) {
|
|
34065
34065
|
const counts = Object.fromEntries(RISK_PATTERNS.map(([c]) => [c, 0]));
|
|
@@ -34152,17 +34152,17 @@ function basisOf(source2, files) {
|
|
|
34152
34152
|
const m = LINE.exec(s);
|
|
34153
34153
|
if (!m) return { ok: false, why: s ? `"${s.slice(0, 60)}" is neither L<n>: <words> nor a rule` : "no source" };
|
|
34154
34154
|
const path = m[1];
|
|
34155
|
-
const
|
|
34155
|
+
const n2 = Number(m[2]);
|
|
34156
34156
|
const quoted = m[3].trim().replace(/^["'`“”]+|["'`“”]+$/g, "");
|
|
34157
34157
|
const fragments = quoted.split(/…|\.\.\./).map(norm).filter((f) => f.length >= 4);
|
|
34158
|
-
if (fragments.length === 0) return { ok: false, why: `L${
|
|
34158
|
+
if (fragments.length === 0) return { ok: false, why: `L${n2}: too few words to find on the line` };
|
|
34159
34159
|
const pool = path ? [...files].filter(([f]) => f === path || f.endsWith(`/${path}`)).map(([, c]) => c) : [...files.values()];
|
|
34160
34160
|
if (path && pool.length === 0) return { ok: false, why: `${path} is not one of the given files` };
|
|
34161
34161
|
for (const content of pool) {
|
|
34162
|
-
const line2 = content.split("\n")[
|
|
34163
|
-
if (line2 !== void 0 && fragments.every((f) => norm(line2).includes(f))) return { ok: true, basis: `L${
|
|
34162
|
+
const line2 = content.split("\n")[n2 - 1];
|
|
34163
|
+
if (line2 !== void 0 && fragments.every((f) => norm(line2).includes(f))) return { ok: true, basis: `L${n2}: ${quoted.slice(0, 120)}` };
|
|
34164
34164
|
}
|
|
34165
|
-
return { ok: false, why: `line ${
|
|
34165
|
+
return { ok: false, why: `line ${n2} does not contain "${quoted.slice(0, 60)}"` };
|
|
34166
34166
|
}
|
|
34167
34167
|
var NOT_A_MENTION = "(?<!\\b(?:even|including|also|or) )";
|
|
34168
34168
|
var UNTIL_FIRST = "(?:(?!\\bor\\b)[^,.;:]){0,60}?";
|
|
@@ -34260,13 +34260,13 @@ function changedExcerpt(content, changed, bytes, context = 30) {
|
|
|
34260
34260
|
else acc.push({ ...w });
|
|
34261
34261
|
return acc;
|
|
34262
34262
|
}, []);
|
|
34263
|
-
const isChanged = (
|
|
34263
|
+
const isChanged = (n2) => changed.some((r) => n2 >= r.from && n2 <= r.to);
|
|
34264
34264
|
const out2 = [];
|
|
34265
34265
|
let size = 0;
|
|
34266
34266
|
for (const w of windows) {
|
|
34267
34267
|
if (out2.length) out2.push(" \u2026");
|
|
34268
|
-
for (let
|
|
34269
|
-
const line2 = `${String(
|
|
34268
|
+
for (let n2 = w.from; n2 <= w.to; n2++) {
|
|
34269
|
+
const line2 = `${String(n2).padStart(5)}${isChanged(n2) ? "*" : " "}| ${lines[n2 - 1] ?? ""}`;
|
|
34270
34270
|
size += line2.length + 1;
|
|
34271
34271
|
if (size > bytes) {
|
|
34272
34272
|
out2.push(" \u2026 (truncated)");
|
|
@@ -34378,14 +34378,14 @@ var lunaRanker = {
|
|
|
34378
34378
|
}
|
|
34379
34379
|
}
|
|
34380
34380
|
};
|
|
34381
|
-
async function rankViaServer(candidates2, ctx,
|
|
34381
|
+
async function rankViaServer(candidates2, ctx, auth3) {
|
|
34382
34382
|
const fallback = deterministicOrder(candidates2);
|
|
34383
34383
|
const excerptBytes = ctx.excerptBytes ?? 6 * 1024;
|
|
34384
34384
|
const res = await apiRequest({
|
|
34385
34385
|
method: "POST",
|
|
34386
34386
|
path: "/prove/rank",
|
|
34387
|
-
serviceUrl:
|
|
34388
|
-
token:
|
|
34387
|
+
serviceUrl: auth3.serviceUrl,
|
|
34388
|
+
token: auth3.token,
|
|
34389
34389
|
body: {
|
|
34390
34390
|
candidates: candidates2.map((c) => ({
|
|
34391
34391
|
file: c.file,
|
|
@@ -34545,16 +34545,16 @@ function tokenizeLean(source2) {
|
|
|
34545
34545
|
const out2 = [];
|
|
34546
34546
|
const reasons = [];
|
|
34547
34547
|
let i2 = 0;
|
|
34548
|
-
const
|
|
34548
|
+
const n2 = source2.length;
|
|
34549
34549
|
const blank = (ch) => ch === "\n" ? "\n" : " ";
|
|
34550
|
-
while (i2 <
|
|
34550
|
+
while (i2 < n2) {
|
|
34551
34551
|
const c = source2[i2];
|
|
34552
34552
|
const next = source2[i2 + 1];
|
|
34553
34553
|
if (c === "/" && next === "-") {
|
|
34554
34554
|
let depth = 1;
|
|
34555
34555
|
out2.push(" ");
|
|
34556
34556
|
i2 += 2;
|
|
34557
|
-
while (i2 <
|
|
34557
|
+
while (i2 < n2 && depth > 0) {
|
|
34558
34558
|
if (source2[i2] === "/" && source2[i2 + 1] === "-") {
|
|
34559
34559
|
depth++;
|
|
34560
34560
|
out2.push(" ");
|
|
@@ -34573,7 +34573,7 @@ function tokenizeLean(source2) {
|
|
|
34573
34573
|
continue;
|
|
34574
34574
|
}
|
|
34575
34575
|
if (c === "-" && next === "-") {
|
|
34576
|
-
while (i2 <
|
|
34576
|
+
while (i2 < n2 && source2[i2] !== "\n") {
|
|
34577
34577
|
out2.push(" ");
|
|
34578
34578
|
i2++;
|
|
34579
34579
|
}
|
|
@@ -34590,11 +34590,11 @@ function tokenizeLean(source2) {
|
|
|
34590
34590
|
out2.push(" ".repeat(j + 1 - i2));
|
|
34591
34591
|
i2 = j + 1;
|
|
34592
34592
|
const close = '"' + "#".repeat(hashes);
|
|
34593
|
-
while (i2 <
|
|
34593
|
+
while (i2 < n2 && source2.slice(i2, i2 + close.length) !== close) {
|
|
34594
34594
|
out2.push(blank(source2[i2]));
|
|
34595
34595
|
i2++;
|
|
34596
34596
|
}
|
|
34597
|
-
out2.push(" ".repeat(Math.min(close.length,
|
|
34597
|
+
out2.push(" ".repeat(Math.min(close.length, n2 - i2)));
|
|
34598
34598
|
i2 += close.length;
|
|
34599
34599
|
continue;
|
|
34600
34600
|
}
|
|
@@ -34603,7 +34603,7 @@ function tokenizeLean(source2) {
|
|
|
34603
34603
|
const interpolated = source2[i2 - 1] === "!" && source2[i2 - 2] === "s";
|
|
34604
34604
|
out2.push(" ");
|
|
34605
34605
|
i2++;
|
|
34606
|
-
while (i2 <
|
|
34606
|
+
while (i2 < n2 && source2[i2] !== '"') {
|
|
34607
34607
|
if (source2[i2] === "\\") {
|
|
34608
34608
|
out2.push(" ");
|
|
34609
34609
|
i2 += 2;
|
|
@@ -34612,7 +34612,7 @@ function tokenizeLean(source2) {
|
|
|
34612
34612
|
if (interpolated && source2[i2] === "{") {
|
|
34613
34613
|
let j = i2 + 1;
|
|
34614
34614
|
let expr = "";
|
|
34615
|
-
while (j <
|
|
34615
|
+
while (j < n2 && source2[j] !== "}" && source2[j] !== '"' && source2[j] !== "\n") expr += source2[j++];
|
|
34616
34616
|
if (source2[j] !== "}") reasons.push(`string interpolation must close before a quote or line end: \`{${expr.trim().slice(0, 40)}\``);
|
|
34617
34617
|
const words = expr.trim().split(/\s+/);
|
|
34618
34618
|
if (words.length === 0 || words.some((w) => !/^[A-Za-z_][A-Za-z0-9_.']*$/.test(w))) {
|
|
@@ -35614,14 +35614,14 @@ async function runReplayInContainer(brief, opts) {
|
|
|
35614
35614
|
}
|
|
35615
35615
|
}
|
|
35616
35616
|
}
|
|
35617
|
-
async function runReplayViaServer(brief,
|
|
35617
|
+
async function runReplayViaServer(brief, auth3, budgetMs = 24e4) {
|
|
35618
35618
|
const started = Date.now();
|
|
35619
35619
|
const budget = Math.max(2e4, Math.round(budgetMs));
|
|
35620
35620
|
const res = await apiRequest({
|
|
35621
35621
|
method: "POST",
|
|
35622
35622
|
path: "/prove/replay",
|
|
35623
|
-
serviceUrl:
|
|
35624
|
-
token:
|
|
35623
|
+
serviceUrl: auth3.serviceUrl,
|
|
35624
|
+
token: auth3.token,
|
|
35625
35625
|
body: {
|
|
35626
35626
|
model: brief.model,
|
|
35627
35627
|
model_source: brief.modelSource,
|
|
@@ -36271,14 +36271,14 @@ function parseProperty(obj) {
|
|
|
36271
36271
|
if (!model || !id || !kind2 || !result || source2 === null || desc === null) return null;
|
|
36272
36272
|
const p = { model, id, kind: kind2, source: source2, desc, result };
|
|
36273
36273
|
if (obj.bound !== void 0) {
|
|
36274
|
-
const
|
|
36275
|
-
if (
|
|
36276
|
-
p.bound =
|
|
36274
|
+
const n2 = nat(obj.bound);
|
|
36275
|
+
if (n2 === null) return null;
|
|
36276
|
+
p.bound = n2;
|
|
36277
36277
|
}
|
|
36278
36278
|
if (obj.states !== void 0) {
|
|
36279
|
-
const
|
|
36280
|
-
if (
|
|
36281
|
-
p.states =
|
|
36279
|
+
const n2 = nat(obj.states);
|
|
36280
|
+
if (n2 === null) return null;
|
|
36281
|
+
p.states = n2;
|
|
36282
36282
|
}
|
|
36283
36283
|
if (obj.trace !== void 0) {
|
|
36284
36284
|
const t = strArr(obj.trace, LIMITS.traceItems, LIMITS.traceItem);
|
|
@@ -36887,14 +36887,14 @@ function readPersistedFindings(root) {
|
|
|
36887
36887
|
function waiveFormalFindings(root, file, reason) {
|
|
36888
36888
|
const all = readPersistedFindings(root);
|
|
36889
36889
|
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
36890
|
-
let
|
|
36890
|
+
let n2 = 0;
|
|
36891
36891
|
const next = all.map((f) => {
|
|
36892
36892
|
if (f.file !== file || f.waived) return f;
|
|
36893
|
-
|
|
36893
|
+
n2++;
|
|
36894
36894
|
return { ...f, waived: { reason: reason.slice(0, 500), at } };
|
|
36895
36895
|
});
|
|
36896
|
-
if (
|
|
36897
|
-
return
|
|
36896
|
+
if (n2 > 0) writePersistedFindings(root, next);
|
|
36897
|
+
return n2;
|
|
36898
36898
|
}
|
|
36899
36899
|
function writePersistedFindings(root, findings) {
|
|
36900
36900
|
if (!isLocalState(root, FINDINGS_FILE)) return;
|
|
@@ -37317,9 +37317,9 @@ function describeTarget(content, symbol, file, range, opts = {}) {
|
|
|
37317
37317
|
}
|
|
37318
37318
|
const body2 = extractSymbolBody(content, symbol, file);
|
|
37319
37319
|
if (!body2) return { numbered: numberLines(content.slice(0, 24 * 1024)), extent };
|
|
37320
|
-
const
|
|
37321
|
-
const from = all.findIndex((_, i2) => all.slice(i2, i2 +
|
|
37322
|
-
return { lines: from > 0 ? { from, to: from +
|
|
37320
|
+
const n2 = body2.split("\n").length;
|
|
37321
|
+
const from = all.findIndex((_, i2) => all.slice(i2, i2 + n2).join("\n") === body2) + 1;
|
|
37322
|
+
return { lines: from > 0 ? { from, to: from + n2 - 1 } : void 0, numbered: numberLines(body2, from > 0 ? from : 1), extent };
|
|
37323
37323
|
}
|
|
37324
37324
|
async function generateAndCheck(root, req, opts) {
|
|
37325
37325
|
const readSrc = opts.deps.readSource ?? workingTreeReader(root);
|
|
@@ -37333,7 +37333,7 @@ async function generateAndCheck(root, req, opts) {
|
|
|
37333
37333
|
if (outline?.source === "tree-sitter") {
|
|
37334
37334
|
const names2 = [...new Set(outline.value.filter((f) => f.name && f.kind !== "lambda").map((f) => f.qualified))];
|
|
37335
37335
|
const last = (req.symbol.split(/[.#:]/).pop() ?? req.symbol).toLowerCase();
|
|
37336
|
-
const close = names2.filter((
|
|
37336
|
+
const close = names2.filter((n2) => n2.toLowerCase().includes(last));
|
|
37337
37337
|
const shown = (close.length > 0 ? close : names2).slice(0, 12);
|
|
37338
37338
|
return { ok: false, error: `no function \`${req.symbol}\` in ${req.file}${shown.length ? ` (it has: ${shown.join(", ")})` : ""}. Name one as ${req.file}#<name>, or pass --lines a-b`, rounds: 0, costUsd: 0 };
|
|
37339
37339
|
}
|
|
@@ -37402,9 +37402,9 @@ async function generateAndCheck(root, req, opts) {
|
|
|
37402
37402
|
function skippedOutcome(skip, detail) {
|
|
37403
37403
|
return { status: "skipped", skip, ...detail ? { detail } : {}, findings: [], usage: { inputTokens: 0, outputTokens: 0, costUsd: 0, unpriced: 0 }, durationMs: 0 };
|
|
37404
37404
|
}
|
|
37405
|
-
async function prepareFormalPhase(root, env = process.env,
|
|
37405
|
+
async function prepareFormalPhase(root, env = process.env, auth3, readSource, codeSource) {
|
|
37406
37406
|
const direct = env.VERITY_PROVE_DIRECT === "1" && !!env.OPENAI_API_KEY;
|
|
37407
|
-
if (!
|
|
37407
|
+
if (!auth3 && !direct) return { ok: false, skip: "not-logged-in" };
|
|
37408
37408
|
const apiKey = direct ? env.OPENAI_API_KEY : void 0;
|
|
37409
37409
|
const toolchain = findToolchain(env);
|
|
37410
37410
|
if (!toolchain) return { ok: false, skip: "no-toolchain" };
|
|
@@ -37418,7 +37418,7 @@ async function prepareFormalPhase(root, env = process.env, auth2, readSource, co
|
|
|
37418
37418
|
const build = await buildLibraryAsync(toolchain, root, 9e4);
|
|
37419
37419
|
if (!build.ok) return { ok: false, skip: "library-build-failed", detail: build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).join(" ").slice(0, 200) };
|
|
37420
37420
|
const code = await loadCodeContext(root, env, codeSource);
|
|
37421
|
-
return { ok: true, deps: { ...defaultDeps({ auth:
|
|
37421
|
+
return { ok: true, deps: { ...defaultDeps({ auth: auth3, apiKey, env, toolchain, readSource, ...code }), codeSource: code.codeSource } };
|
|
37422
37422
|
}
|
|
37423
37423
|
async function loadCodeContext(root, env = process.env, codeSource) {
|
|
37424
37424
|
const loaded = await loadCodeMap(env);
|
|
@@ -37516,9 +37516,9 @@ function recordPostTimeout(now, deadlineAt, timeoutMs = RECORD_TIMEOUT_MS) {
|
|
|
37516
37516
|
var norm2 = (p) => p.replace(/\\/g, "/");
|
|
37517
37517
|
var SAFE_SEGMENT = /^[A-Za-z0-9._@+~$()[\]-]{1,255}$/;
|
|
37518
37518
|
function safeRepoPath(p) {
|
|
37519
|
-
const
|
|
37520
|
-
if (!
|
|
37521
|
-
return
|
|
37519
|
+
const n2 = norm2(p);
|
|
37520
|
+
if (!n2 || n2.length > 512 || n2.startsWith("/") || /^[A-Za-z]:\//.test(n2)) return null;
|
|
37521
|
+
return n2.split("/").every((s) => s !== "." && s !== ".." && SAFE_SEGMENT.test(s)) ? n2 : null;
|
|
37522
37522
|
}
|
|
37523
37523
|
var SYMBOL = /^[A-Za-z_$][\w$]*(?:[.#:][A-Za-z_$][\w$]*)*$/;
|
|
37524
37524
|
var IDENT3 = /^[A-Za-z][\w]*$/;
|
|
@@ -37538,7 +37538,7 @@ function recordTrace(trace) {
|
|
|
37538
37538
|
}
|
|
37539
37539
|
var ident2 = (s, re, max) => typeof s === "string" && s.length <= max && re.test(s) ? s : null;
|
|
37540
37540
|
var kind = (k) => k === "intent" ? "intent" : "structural";
|
|
37541
|
-
var signalsOf = (c) => c && typeof c.commits === "number" && typeof c.fixCommits === "number" ? { commits: c.commits, fix_commits: c.fixCommits, risk: Object.fromEntries(Object.entries(c.risk ?? {}).filter(([,
|
|
37541
|
+
var signalsOf = (c) => c && typeof c.commits === "number" && typeof c.fixCommits === "number" ? { commits: c.commits, fix_commits: c.fixCommits, risk: Object.fromEntries(Object.entries(c.risk ?? {}).filter(([, n2]) => typeof n2 === "number" && n2 > 0).slice(0, 16)) } : null;
|
|
37542
37542
|
function buildPhaseRecord(outcome, ctx) {
|
|
37543
37543
|
const pushed = new Set(ctx.pushedFiles.map(norm2));
|
|
37544
37544
|
const blocks = (f) => ctx.moment === "push" && f.verdict === "reproduced" && !f.waived && pushed.has(norm2(f.file));
|
|
@@ -37938,7 +37938,7 @@ function startAgentReview(input) {
|
|
|
37938
37938
|
diffs: await buildAgentDiffs(ctx, sentPaths),
|
|
37939
37939
|
repo_context: input.requestBody.repo_context,
|
|
37940
37940
|
static_results: input.requestBody.static_results,
|
|
37941
|
-
one_shot_chars: input.codeDelta.files.reduce((
|
|
37941
|
+
one_shot_chars: input.codeDelta.files.reduce((n2, f) => n2 + f.content.length, 0),
|
|
37942
37942
|
local_tools: offeredLocalTools(ctx)
|
|
37943
37943
|
},
|
|
37944
37944
|
oneShot: input.oneShot.then((r) => r.ok ? { ok: true, response: r.data } : { ok: false }),
|
|
@@ -37960,7 +37960,7 @@ function startFormalPhase(input) {
|
|
|
37960
37960
|
for (const [path, sig] of rangeChangeSignals(input.frame, input.range, files)) {
|
|
37961
37961
|
changedLines.set(path, [
|
|
37962
37962
|
...sig.addedRanges.map(([from, to]) => ({ from, to })),
|
|
37963
|
-
...sig.touchPoints.map((
|
|
37963
|
+
...sig.touchPoints.map((n2) => ({ from: n2, to: n2 }))
|
|
37964
37964
|
]);
|
|
37965
37965
|
}
|
|
37966
37966
|
} catch {
|
|
@@ -38534,11 +38534,11 @@ function printBanner(opts) {
|
|
|
38534
38534
|
}
|
|
38535
38535
|
process.stderr.write("\n");
|
|
38536
38536
|
}
|
|
38537
|
-
function printPhase(
|
|
38537
|
+
function printPhase(n2, of, title, subtitle) {
|
|
38538
38538
|
const color = colorEnabled();
|
|
38539
38539
|
const columns = process.stderr.columns ?? 72;
|
|
38540
38540
|
const width = Math.min(columns, 72);
|
|
38541
|
-
const label2 = `\u2500\u2500 Phase ${
|
|
38541
|
+
const label2 = `\u2500\u2500 Phase ${n2} of ${of} \xB7 ${title} `;
|
|
38542
38542
|
const rule = label2 + "\u2500".repeat(Math.max(0, width - label2.length - 2));
|
|
38543
38543
|
process.stderr.write("\n");
|
|
38544
38544
|
process.stderr.write(color ? ` ${DIM3}${rule}${RESET2}
|
|
@@ -38915,7 +38915,7 @@ function registerDoctorCommand(program2) {
|
|
|
38915
38915
|
if (report.next.length > 0) {
|
|
38916
38916
|
console.log("");
|
|
38917
38917
|
printWarn("Next:");
|
|
38918
|
-
for (const
|
|
38918
|
+
for (const n2 of report.next) printWarn(` - ${n2}`);
|
|
38919
38919
|
} else {
|
|
38920
38920
|
printInfo("Setup is complete.");
|
|
38921
38921
|
}
|
|
@@ -39306,8 +39306,8 @@ function renderSelect(question, choices, state, mode2, color = colorEnabled()) {
|
|
|
39306
39306
|
const marker = state.chosen.has(i2) ? "\u25C9" : "\u25CB";
|
|
39307
39307
|
const cursor = here ? "\u276F" : " ";
|
|
39308
39308
|
const label2 = labelOf(choice);
|
|
39309
|
-
const
|
|
39310
|
-
const hint = choice.hint ? `${
|
|
39309
|
+
const pad2 = choice.hint ? " ".repeat(gutter - label2.length) : "";
|
|
39310
|
+
const hint = choice.hint ? `${pad2} ${paint(choice.hint, DIM4)}` : "";
|
|
39311
39311
|
lines.push(` ${cursor} ${marker} ${here ? paint(label2, BOLD2) : label2}${hint}`);
|
|
39312
39312
|
});
|
|
39313
39313
|
const keys = mode2 === "multi" ? "\u2191\u2193 move \xB7 space or number toggle \xB7 enter confirm" : "\u2191\u2193 move \xB7 number jumps \xB7 enter confirm";
|
|
@@ -39418,9 +39418,9 @@ function parseMultiSelect(answer, choices, fallback) {
|
|
|
39418
39418
|
if (a === "") return { ids: [...fallback], recognized: true };
|
|
39419
39419
|
const picked = /* @__PURE__ */ new Set();
|
|
39420
39420
|
for (const part of a.split(",").map((s) => s.trim()).filter(Boolean)) {
|
|
39421
|
-
const
|
|
39422
|
-
if (Number.isInteger(
|
|
39423
|
-
picked.add(choices[
|
|
39421
|
+
const n2 = Number.parseInt(part, 10);
|
|
39422
|
+
if (Number.isInteger(n2) && n2 >= 1 && n2 <= choices.length) {
|
|
39423
|
+
picked.add(choices[n2 - 1].id);
|
|
39424
39424
|
continue;
|
|
39425
39425
|
}
|
|
39426
39426
|
const byId = choices.find((c) => c.id.toLowerCase() === part || c.label.toLowerCase() === part);
|
|
@@ -39590,7 +39590,7 @@ function inPlaceProgress(label2, write = (s) => process.stderr.write(s)) {
|
|
|
39590
39590
|
let active = false;
|
|
39591
39591
|
let lastAt = 0;
|
|
39592
39592
|
let lastPct = -1;
|
|
39593
|
-
const mb = (
|
|
39593
|
+
const mb = (n2) => (n2 / 1048576).toFixed(0);
|
|
39594
39594
|
return {
|
|
39595
39595
|
update(seen, total) {
|
|
39596
39596
|
const now = Date.now();
|
|
@@ -39625,7 +39625,7 @@ async function installLean(opts = {}) {
|
|
|
39625
39625
|
const free = freeBytes(home);
|
|
39626
39626
|
const needed = opts.minFreeBytes ?? LEAN_DISK_NEEDED_BYTES;
|
|
39627
39627
|
if (free !== null && free < needed) {
|
|
39628
|
-
const gb = (
|
|
39628
|
+
const gb = (n2) => (n2 / 1024 ** 3).toFixed(1);
|
|
39629
39629
|
return { ok: false, error: `not enough disk space for Lean: ${gb(free)} GB free where ${home} lives, needs about ${gb(needed)} GB` };
|
|
39630
39630
|
}
|
|
39631
39631
|
const tmp = (0, import_node_path52.join)(home, ".tmp");
|
|
@@ -40636,7 +40636,7 @@ function registerInitCommand(program2) {
|
|
|
40636
40636
|
...telemetryChoice ? { telemetry: telemetryChoice } : {},
|
|
40637
40637
|
init: {
|
|
40638
40638
|
completed_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
40639
|
-
cli_version: true ? "0.34.
|
|
40639
|
+
cli_version: true ? "0.34.3" : "dev"
|
|
40640
40640
|
}
|
|
40641
40641
|
});
|
|
40642
40642
|
} catch (err2) {
|
|
@@ -41616,6 +41616,148 @@ function registerTelemetryCommands(program2) {
|
|
|
41616
41616
|
});
|
|
41617
41617
|
}
|
|
41618
41618
|
|
|
41619
|
+
// src/commands/usage.ts
|
|
41620
|
+
var PLAN = { free: "Free", pro: "Pro", fleet: "Fleet" };
|
|
41621
|
+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
41622
|
+
function n(v) {
|
|
41623
|
+
return v.toLocaleString("en-US");
|
|
41624
|
+
}
|
|
41625
|
+
function used(v, limit) {
|
|
41626
|
+
return limit === void 0 ? n(v) : `${n(v)} / ${n(limit)}`;
|
|
41627
|
+
}
|
|
41628
|
+
function secs(ms) {
|
|
41629
|
+
return ms === null ? "\u2014" : `${(ms / 1e3).toFixed(1)} s`;
|
|
41630
|
+
}
|
|
41631
|
+
function utcHm(iso) {
|
|
41632
|
+
const d = new Date(iso);
|
|
41633
|
+
return `${String(d.getUTCHours()).padStart(2, "0")}:${String(d.getUTCMinutes()).padStart(2, "0")} UTC`;
|
|
41634
|
+
}
|
|
41635
|
+
function utcDay(iso) {
|
|
41636
|
+
const d = new Date(iso);
|
|
41637
|
+
return `${d.getUTCDate()} ${MONTHS[d.getUTCMonth()]}`;
|
|
41638
|
+
}
|
|
41639
|
+
function inText(now, at) {
|
|
41640
|
+
const min = Math.max(0, Math.round((at.getTime() - now.getTime()) / 6e4));
|
|
41641
|
+
if (min < 60) return `${min} min`;
|
|
41642
|
+
const h = Math.floor(min / 60);
|
|
41643
|
+
return h < 48 ? `${h} h ${min % 60} min` : `${Math.floor(h / 24)} d ${h % 24} h`;
|
|
41644
|
+
}
|
|
41645
|
+
function pad(s, w) {
|
|
41646
|
+
return s.length >= w ? s : s + " ".repeat(w - s.length);
|
|
41647
|
+
}
|
|
41648
|
+
function renderSeatUsage(d, now = /* @__PURE__ */ new Date()) {
|
|
41649
|
+
const lim = d.plan?.limits;
|
|
41650
|
+
const pool = d.plan?.week_pool ?? null;
|
|
41651
|
+
const memberWeek = (m) => pool ? void 0 : lim?.[m].week;
|
|
41652
|
+
const lines = [];
|
|
41653
|
+
lines.push(`=== Verity usage \xB7 ${d.organization.name}${d.plan ? ` (${PLAN[d.plan.id] ?? d.plan.id})` : ""} ===`);
|
|
41654
|
+
lines.push(
|
|
41655
|
+
`Session ${utcHm(d.session.start)}\u2013${utcHm(d.session.resets_at)} (resets in ${inText(now, new Date(d.session.resets_at))}) \xB7 week from Mon ${utcDay(d.week.start)} (resets Mon ${utcDay(d.week.resets_at)}, 00:00 UTC)`
|
|
41656
|
+
);
|
|
41657
|
+
if (!d.plan) lines.push("No plan is set for this org: counts only. Plan limits apply from Nov 2.");
|
|
41658
|
+
else if (!d.enforced) lines.push("Limits are shown for information. They are not enforced before Nov 2.");
|
|
41659
|
+
const me = d.members.find((m) => m.me);
|
|
41660
|
+
if (me) {
|
|
41661
|
+
const w = me.weeks[0];
|
|
41662
|
+
lines.push("");
|
|
41663
|
+
lines.push(`You (${me.email ?? `user #${me.user_id}`})`);
|
|
41664
|
+
lines.push(` ${pad("Commit & push reviews", 24)}session ${pad(used(me.session.commit, lim?.commit.session), 12)}week ${pad(used(w.commit, memberWeek("commit")), 14)}busiest session ${n(w.peak_session.commit)}`);
|
|
41665
|
+
lines.push(` ${pad("Turn reviews", 24)}session ${pad(used(me.session.turn, lim?.turn.session), 12)}week ${pad(used(w.turn, memberWeek("turn")), 14)}busiest session ${n(w.peak_session.turn)}`);
|
|
41666
|
+
lines.push(` This week: ${n(w.blocked)} blocked, ${n(w.warned)} warned \xB7 review time p50 ${secs(w.latency_ms.p50)}, p90 ${secs(w.latency_ms.p90)}`);
|
|
41667
|
+
}
|
|
41668
|
+
const t = d.totals.weeks[0];
|
|
41669
|
+
lines.push("");
|
|
41670
|
+
lines.push(`Team \xB7 ${n(d.totals.active_members)} active this week`);
|
|
41671
|
+
if (pool && lim) {
|
|
41672
|
+
lines.push(
|
|
41673
|
+
` Week pool: ${n(t.commit)} / ${n(pool.commit)} commit & push, ${n(t.turn)} / ${n(pool.turn)} turn (${n(pool.members)} members \xD7 ${n(lim.commit.week)} and ${n(lim.turn.week)}; the session limit is each member's)`
|
|
41674
|
+
);
|
|
41675
|
+
}
|
|
41676
|
+
if (d.viewer !== "member" && d.members.length > 0) {
|
|
41677
|
+
const rows = d.members.map((m) => [
|
|
41678
|
+
`${m.email ?? `user #${m.user_id}`}${m.me ? " (you)" : ""}`,
|
|
41679
|
+
used(m.session.commit, lim?.commit.session),
|
|
41680
|
+
used(m.weeks[0].commit, memberWeek("commit")),
|
|
41681
|
+
n(m.weeks[0].peak_session.commit),
|
|
41682
|
+
used(m.session.turn, lim?.turn.session),
|
|
41683
|
+
used(m.weeks[0].turn, memberWeek("turn")),
|
|
41684
|
+
n(m.weeks[0].blocked),
|
|
41685
|
+
`${secs(m.weeks[0].latency_ms.p50)} / ${secs(m.weeks[0].latency_ms.p90)}`
|
|
41686
|
+
]);
|
|
41687
|
+
const head = ["Member", "C&P session", "C&P week", "C&P peak", "Turn session", "Turn week", "Blocked", "p50 / p90"];
|
|
41688
|
+
const total = [
|
|
41689
|
+
"Team total",
|
|
41690
|
+
n(d.totals.session.commit),
|
|
41691
|
+
used(t.commit, pool?.commit),
|
|
41692
|
+
n(t.peak_session.commit),
|
|
41693
|
+
n(d.totals.session.turn),
|
|
41694
|
+
used(t.turn, pool?.turn),
|
|
41695
|
+
n(t.blocked),
|
|
41696
|
+
`${secs(t.latency_ms.p50)} / ${secs(t.latency_ms.p90)}`
|
|
41697
|
+
];
|
|
41698
|
+
const widths = head.map((h, i2) => Math.max(h.length, ...rows.map((r) => r[i2].length), total[i2].length) + 2);
|
|
41699
|
+
lines.push(" " + head.map((h, i2) => pad(h, widths[i2])).join("").trimEnd());
|
|
41700
|
+
for (const r of rows) lines.push(" " + r.map((c, i2) => pad(c, widths[i2])).join("").trimEnd());
|
|
41701
|
+
lines.push(" " + total.map((c, i2) => pad(c, widths[i2])).join("").trimEnd());
|
|
41702
|
+
} else {
|
|
41703
|
+
lines.push(` This week: ${n(t.commit)} commit & push reviews, ${n(t.turn)} turn reviews, ${n(t.blocked)} blocked.`);
|
|
41704
|
+
if (d.viewer === "member") lines.push(` Only the admins of ${d.organization.name} see every member.`);
|
|
41705
|
+
}
|
|
41706
|
+
if (d.truncated) lines.push(" (Partial: the org has more reviews than one report reads.)");
|
|
41707
|
+
lines.push("");
|
|
41708
|
+
lines.push(`Counted: ${d.counting}`);
|
|
41709
|
+
return lines;
|
|
41710
|
+
}
|
|
41711
|
+
async function auth2(globals) {
|
|
41712
|
+
const tokenResult = await resolveToken(globals.token);
|
|
41713
|
+
if (!tokenResult.ok) {
|
|
41714
|
+
printError(tokenResult.error);
|
|
41715
|
+
process.exit(1);
|
|
41716
|
+
}
|
|
41717
|
+
const urlResult = await resolveServiceUrl(globals.serviceUrl);
|
|
41718
|
+
if (!urlResult.ok) {
|
|
41719
|
+
printError(urlResult.error);
|
|
41720
|
+
process.exit(1);
|
|
41721
|
+
}
|
|
41722
|
+
return { token: tokenResult.data.token, serviceUrl: urlResult.data };
|
|
41723
|
+
}
|
|
41724
|
+
function registerUsageCommand(program2) {
|
|
41725
|
+
program2.command("usage").description("Show reviews per member of this org, this session and this week, against the plan limits").option("--org <name>", "The org to show (default: the org of this repository)").option("--weeks <n>", "Weeks of history in --json (1-12)", "4").option("--json", "Machine-readable output").action(async (opts) => {
|
|
41726
|
+
const globals = program2.opts();
|
|
41727
|
+
const { token, serviceUrl } = await auth2(globals);
|
|
41728
|
+
const weeks = Math.min(12, Math.max(1, Number.parseInt(opts.weeks ?? "4", 10) || 4));
|
|
41729
|
+
const query = `weeks=${weeks}${opts.org ? `&org=${encodeURIComponent(opts.org)}` : ""}`;
|
|
41730
|
+
const res = await apiRequest({
|
|
41731
|
+
method: "GET",
|
|
41732
|
+
path: `/usage/seats?${query}`,
|
|
41733
|
+
serviceUrl,
|
|
41734
|
+
token,
|
|
41735
|
+
verbose: globals.verbose,
|
|
41736
|
+
cmd: "usage"
|
|
41737
|
+
});
|
|
41738
|
+
if (!res.ok) {
|
|
41739
|
+
const denial = authDenialRemedy(res.error);
|
|
41740
|
+
printError(denial && denial.code !== "FORBIDDEN" ? denial.remedy : res.error);
|
|
41741
|
+
process.exit(1);
|
|
41742
|
+
}
|
|
41743
|
+
if (opts.json) {
|
|
41744
|
+
printJson(res.data);
|
|
41745
|
+
return;
|
|
41746
|
+
}
|
|
41747
|
+
if ("orgs" in res.data) {
|
|
41748
|
+
const orgs = res.data.orgs;
|
|
41749
|
+
if (orgs.length === 0) {
|
|
41750
|
+
printInfo("You have no repository in an org that Verity knows yet. Run a review in one first.");
|
|
41751
|
+
return;
|
|
41752
|
+
}
|
|
41753
|
+
printInfo("Choose an org: verity usage --org <name>");
|
|
41754
|
+
for (const o of orgs) printInfo(` ${o.name}${o.viewer === "admin" ? " (admin)" : ""}`);
|
|
41755
|
+
return;
|
|
41756
|
+
}
|
|
41757
|
+
for (const line2 of renderSeatUsage(res.data)) printInfo(line2);
|
|
41758
|
+
});
|
|
41759
|
+
}
|
|
41760
|
+
|
|
41619
41761
|
// src/commands/prove.ts
|
|
41620
41762
|
var import_node_fs73 = require("node:fs");
|
|
41621
41763
|
var import_node_path57 = require("node:path");
|
|
@@ -41871,8 +42013,8 @@ ${build.stderr.split("\n").filter((l) => !l.startsWith("trace:")).slice(0, 20).j
|
|
|
41871
42013
|
});
|
|
41872
42014
|
prove.command("replay <model>").description("Replay a model's counterexample on the real code in an OpenAI container (network off) \u2014 reproduced / diverged").option("--property <id>", "Only this property (default: every counterexample)").option("--model-name <name>", "OpenAI model for the replay", "gpt-5.6-terra").option("--timeout <ms>", "Per-property timeout in ms", "240000").option("--json", "Machine-readable output").action(async (model, opts) => {
|
|
41873
42015
|
const root = repoRoot();
|
|
41874
|
-
const
|
|
41875
|
-
if (!
|
|
42016
|
+
const auth3 = await proveAuth(program2);
|
|
42017
|
+
if (!auth3 && !(process.env.VERITY_PROVE_DIRECT === "1" && process.env.OPENAI_API_KEY)) {
|
|
41876
42018
|
printError("Not logged in \u2014 replays run on the Verity service. Run `verity login` first.");
|
|
41877
42019
|
process.exit(2);
|
|
41878
42020
|
}
|
|
@@ -41911,7 +42053,7 @@ ${report.error ?? ""}`);
|
|
|
41911
42053
|
if (!opts.json) printInfo(`replaying ${targets.length} counterexample(s) of ${model} in network-less containers (${Math.min(targets.length, REPLAY_CONCURRENCY)} at a time)\u2026`);
|
|
41912
42054
|
const outcomes = await mapPool(targets, REPLAY_CONCURRENCY, async (p) => {
|
|
41913
42055
|
const brief = buildReplayBrief(root, report, p, modelSource.ok ? modelSource.content : "");
|
|
41914
|
-
const outcome = await runReplay(brief, { auth:
|
|
42056
|
+
const outcome = await runReplay(brief, { auth: auth3 ?? void 0, apiKey: process.env.OPENAI_API_KEY, model: opts.modelName, timeoutMs: Math.max(1e4, Number(opts.timeout) || 24e4) });
|
|
41915
42057
|
if (!opts.json) process.stdout.write(renderReplay(model, p, outcome) + "\n");
|
|
41916
42058
|
try {
|
|
41917
42059
|
writeReplayResult(root, report.model, p.id, outcome);
|
|
@@ -41937,10 +42079,10 @@ ${report.error ?? ""}`);
|
|
|
41937
42079
|
printInfo("No changed files to consider (nothing ahead of upstream). Pass paths explicitly.");
|
|
41938
42080
|
return;
|
|
41939
42081
|
}
|
|
41940
|
-
const
|
|
41941
|
-
const prep = await prepareFormalPhase(root, process.env,
|
|
42082
|
+
const auth3 = await proveAuth(program2);
|
|
42083
|
+
const prep = await prepareFormalPhase(root, process.env, auth3 ?? void 0);
|
|
41942
42084
|
const outcome = prep.ok ? await runFormalPhaseWithin({ root, files, deadlineAt: Date.now() + Math.max(3e4, Number(opts.deadline) || 17e4), deps: prep.deps }).catch((err2) => skippedOutcome("error", String(err2?.message ?? err2).slice(0, 200))) : skippedOutcome(prep.skip, prep.detail);
|
|
41943
|
-
if (
|
|
42085
|
+
if (auth3) await postPhaseRecord(outcome, { moment: "on-demand", parentRunId: null, pushedFiles: [] }, auth3);
|
|
41944
42086
|
if (opts.json) {
|
|
41945
42087
|
printJson(outcome);
|
|
41946
42088
|
} else {
|
|
@@ -41972,8 +42114,8 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
41972
42114
|
opts[flag] = input.text;
|
|
41973
42115
|
}
|
|
41974
42116
|
const root = repoRoot();
|
|
41975
|
-
const
|
|
41976
|
-
if (!
|
|
42117
|
+
const auth3 = await proveAuth(program2);
|
|
42118
|
+
if (!auth3 && !(process.env.VERITY_PROVE_DIRECT === "1" && process.env.OPENAI_API_KEY)) {
|
|
41977
42119
|
printError("Not logged in \u2014 models are written by the Verity service. Run `verity login` first.");
|
|
41978
42120
|
process.exit(2);
|
|
41979
42121
|
}
|
|
@@ -42014,7 +42156,7 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
42014
42156
|
printError("Verity library did not build");
|
|
42015
42157
|
process.exit(2);
|
|
42016
42158
|
}
|
|
42017
|
-
const deps = await onDemandDeps(root, { auth:
|
|
42159
|
+
const deps = await onDemandDeps(root, { auth: auth3 ?? void 0, apiKey: process.env.VERITY_PROVE_DIRECT === "1" ? process.env.OPENAI_API_KEY : void 0, toolchain: tc });
|
|
42018
42160
|
if (!opts.json) printInfo(`asking the Verity service for a model of ${symbol || `${file}:${opts.lines}`} \u2026`);
|
|
42019
42161
|
const out2 = await generateAndCheck(root, { file, symbol: symbol || `${file}:${opts.lines}`, lines, hint: opts.hint, revise }, { deps, maxRounds: 3 });
|
|
42020
42162
|
if (!out2.ok) {
|
|
@@ -42052,9 +42194,9 @@ ${f.reason ? ` ${terminalText(f.reason, 2e3)}
|
|
|
42052
42194
|
printWarn(`No remembered formal finding on ${rel}. A finding is remembered only after a REPRODUCED replay at push.`);
|
|
42053
42195
|
process.exit(1);
|
|
42054
42196
|
}
|
|
42055
|
-
const
|
|
42056
|
-
logEvent("formal_waive", { file: rel, waived:
|
|
42057
|
-
printInfo(`Waived ${
|
|
42197
|
+
const n2 = waiveFormalFindings(root, rel, opts.reason);
|
|
42198
|
+
logEvent("formal_waive", { file: rel, waived: n2 });
|
|
42199
|
+
printInfo(`Waived ${n2} formal finding(s) on ${rel} for its current bytes; the waive voids when the file changes. Reason recorded: ${terminalText(opts.reason, 200)}`);
|
|
42058
42200
|
});
|
|
42059
42201
|
prove.command("hash <file>").description("Print the sha256 of a file, for a model header (Verity.model \u2026 sha256). Path is REPO-relative, as in the header").action((file) => {
|
|
42060
42202
|
const root = repoRoot();
|
|
@@ -42177,8 +42319,8 @@ function registerLeanCommand(program2) {
|
|
|
42177
42319
|
}
|
|
42178
42320
|
|
|
42179
42321
|
// src/cli.ts
|
|
42180
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.34.
|
|
42181
|
-
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.
|
|
42322
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.34.3").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async (_thisCommand, actionCommand) => {
|
|
42323
|
+
installStderrLog(actionCommand.name(), process.argv.slice(2), "0.34.3");
|
|
42182
42324
|
setUserNamedServiceUrl(program.opts().serviceUrl);
|
|
42183
42325
|
try {
|
|
42184
42326
|
await foldLegacyLocalCredential();
|
|
@@ -42213,6 +42355,7 @@ registerMemoryCommand(program);
|
|
|
42213
42355
|
registerRunCommand(program);
|
|
42214
42356
|
registerMigrateCommand(program);
|
|
42215
42357
|
registerTelemetryCommands(program);
|
|
42358
|
+
registerUsageCommand(program);
|
|
42216
42359
|
registerProveCommand(program);
|
|
42217
42360
|
registerLeanCommand(program);
|
|
42218
42361
|
program.parseAsync().catch((err2) => {
|