@staff0rd/assist 0.1091.0 → 0.1092.1
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/dist/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +305 -305
- package/dist/index.js +274 -209
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.1092.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1898,9 +1898,6 @@ function isExtensionOrigin(origin) {
|
|
|
1898
1898
|
return !!origin && EXTENSION_ORIGIN.test(origin);
|
|
1899
1899
|
}
|
|
1900
1900
|
|
|
1901
|
-
// src/commands/sessions/web/handleSocket.ts
|
|
1902
|
-
import { createInterface } from "readline";
|
|
1903
|
-
|
|
1904
1901
|
// src/commands/sessions/daemon/links/isLinkCreate.ts
|
|
1905
1902
|
var CREATE_TYPES = /* @__PURE__ */ new Set([
|
|
1906
1903
|
"create",
|
|
@@ -1954,6 +1951,46 @@ function resolveNodeName() {
|
|
|
1954
1951
|
return loadConfig().sessions?.nodeName?.trim() || defaultNodeName();
|
|
1955
1952
|
}
|
|
1956
1953
|
|
|
1954
|
+
// src/commands/sessions/web/forEachCompleteLine.ts
|
|
1955
|
+
import { StringDecoder } from "string_decoder";
|
|
1956
|
+
function forEachCompleteLine(input, onLine, onTruncated) {
|
|
1957
|
+
const decoder = new StringDecoder("utf8");
|
|
1958
|
+
let buffered = "";
|
|
1959
|
+
input.on("data", (chunk2) => {
|
|
1960
|
+
const searchFrom = buffered.length;
|
|
1961
|
+
buffered += typeof chunk2 === "string" ? chunk2 : decoder.write(chunk2);
|
|
1962
|
+
let lineStart = 0;
|
|
1963
|
+
let newline = buffered.indexOf("\n", searchFrom);
|
|
1964
|
+
while (newline !== -1) {
|
|
1965
|
+
const line = buffered.slice(lineStart, newline);
|
|
1966
|
+
onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
1967
|
+
lineStart = newline + 1;
|
|
1968
|
+
newline = buffered.indexOf("\n", lineStart);
|
|
1969
|
+
}
|
|
1970
|
+
buffered = buffered.slice(lineStart);
|
|
1971
|
+
});
|
|
1972
|
+
const flushTruncated = () => {
|
|
1973
|
+
const partial = buffered + decoder.end();
|
|
1974
|
+
buffered = "";
|
|
1975
|
+
if (partial) onTruncated(partial);
|
|
1976
|
+
};
|
|
1977
|
+
input.on("end", flushTruncated);
|
|
1978
|
+
input.on("close", flushTruncated);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
// src/commands/sessions/web/withRepoCwd.ts
|
|
1982
|
+
function withRepoCwd(line, repoCwd) {
|
|
1983
|
+
if (!repoCwd) return line;
|
|
1984
|
+
try {
|
|
1985
|
+
const data = JSON.parse(line);
|
|
1986
|
+
if (data.type !== "sessions" || data.cwd) return line;
|
|
1987
|
+
data.cwd = repoCwd;
|
|
1988
|
+
return JSON.stringify(data);
|
|
1989
|
+
} catch {
|
|
1990
|
+
return line;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1957
1994
|
// src/commands/sessions/web/handleSocket.ts
|
|
1958
1995
|
var CWD_DEFAULTED_TYPES = /* @__PURE__ */ new Set(["create", "create-run", "create-assist"]);
|
|
1959
1996
|
function handleSocket(ws, ctx) {
|
|
@@ -1982,12 +2019,15 @@ async function openDaemonConnection(ws, ctx) {
|
|
|
1982
2019
|
}
|
|
1983
2020
|
}
|
|
1984
2021
|
function relayDaemonLines(conn, ws, repoCwd) {
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
2022
|
+
forEachCompleteLine(
|
|
2023
|
+
conn,
|
|
2024
|
+
(line) => {
|
|
2025
|
+
if (ws.readyState === ws.OPEN) ws.send(withRepoCwd(line, repoCwd));
|
|
2026
|
+
},
|
|
2027
|
+
(partial) => console.log(
|
|
2028
|
+
`ws relay: dropped truncated daemon message (${partial.length} chars) after the daemon connection closed`
|
|
2029
|
+
)
|
|
2030
|
+
);
|
|
1991
2031
|
conn.on("error", () => {
|
|
1992
2032
|
});
|
|
1993
2033
|
conn.on("close", () => ws.close());
|
|
@@ -2016,17 +2056,6 @@ function withDefaultCwd(raw, serverCwd) {
|
|
|
2016
2056
|
function targetsLinkedNode(data) {
|
|
2017
2057
|
return resolveLinkTarget(data, resolveNodeName(), () => true).kind !== "local";
|
|
2018
2058
|
}
|
|
2019
|
-
function withRepoCwd(line, repoCwd) {
|
|
2020
|
-
if (!repoCwd) return line;
|
|
2021
|
-
try {
|
|
2022
|
-
const data = JSON.parse(line);
|
|
2023
|
-
if (data.type !== "sessions" || data.cwd) return line;
|
|
2024
|
-
data.cwd = repoCwd;
|
|
2025
|
-
return JSON.stringify(data);
|
|
2026
|
-
} catch {
|
|
2027
|
-
return line;
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
2059
|
|
|
2031
2060
|
// src/commands/sessions/web/isAppOrigin.ts
|
|
2032
2061
|
var APP_ORIGIN = "capacitor://localhost";
|
|
@@ -5307,7 +5336,7 @@ function recordPromptJournal(entry) {
|
|
|
5307
5336
|
}
|
|
5308
5337
|
|
|
5309
5338
|
// src/commands/sessions/daemon/requestDaemonReply.ts
|
|
5310
|
-
import { createInterface
|
|
5339
|
+
import { createInterface } from "readline";
|
|
5311
5340
|
var QUERY_TIMEOUT_MS = 3e3;
|
|
5312
5341
|
async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_MS) {
|
|
5313
5342
|
let socket;
|
|
@@ -5323,7 +5352,7 @@ async function requestDaemonReply(request, replyType, timeoutMs = QUERY_TIMEOUT_
|
|
|
5323
5352
|
resolve34(result);
|
|
5324
5353
|
};
|
|
5325
5354
|
const timer = setTimeout(() => finish2(void 0), timeoutMs);
|
|
5326
|
-
const lines =
|
|
5355
|
+
const lines = createInterface({ input: socket });
|
|
5327
5356
|
lines.on("error", () => {
|
|
5328
5357
|
});
|
|
5329
5358
|
lines.on("line", (line) => {
|
|
@@ -8556,8 +8585,8 @@ function deriveProject(cwd, filePath, origin) {
|
|
|
8556
8585
|
}
|
|
8557
8586
|
function dirNameToProject(filePath) {
|
|
8558
8587
|
const dirName = path8.basename(path8.dirname(filePath));
|
|
8559
|
-
const
|
|
8560
|
-
return
|
|
8588
|
+
const parts2 = dirName.split("--");
|
|
8589
|
+
return parts2[parts2.length - 1].replace(/-/g, "/");
|
|
8561
8590
|
}
|
|
8562
8591
|
|
|
8563
8592
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
@@ -9034,9 +9063,9 @@ function negotiateProtocol(msg) {
|
|
|
9034
9063
|
const common = Math.min(peer.max, PROTOCOL_VERSION);
|
|
9035
9064
|
return common >= Math.max(peer.min, MIN_PROTOCOL_VERSION) ? common : void 0;
|
|
9036
9065
|
}
|
|
9037
|
-
function formatRange(
|
|
9038
|
-
if (!
|
|
9039
|
-
return
|
|
9066
|
+
function formatRange(range) {
|
|
9067
|
+
if (!range) return "legacy (no protocol)";
|
|
9068
|
+
return range.min === range.max ? `protocol ${range.max}` : `protocols ${range.min}\u2013${range.max}`;
|
|
9040
9069
|
}
|
|
9041
9070
|
function describeProtocolGap(node, msg) {
|
|
9042
9071
|
const peer = peerProtocolRange(msg);
|
|
@@ -10269,10 +10298,10 @@ function splitTitle(rest) {
|
|
|
10269
10298
|
}
|
|
10270
10299
|
function parseRulesSection(content) {
|
|
10271
10300
|
const lines = content.split(/\r?\n/);
|
|
10272
|
-
const
|
|
10273
|
-
if (!
|
|
10301
|
+
const range = rulesSectionRange(lines);
|
|
10302
|
+
if (!range) return [];
|
|
10274
10303
|
const rules2 = [];
|
|
10275
|
-
for (const line of lines.slice(
|
|
10304
|
+
for (const line of lines.slice(range.start + 1, range.end)) {
|
|
10276
10305
|
const match = RULE_BULLET.exec(line);
|
|
10277
10306
|
if (!match) continue;
|
|
10278
10307
|
const code = match[1].trim();
|
|
@@ -10441,11 +10470,11 @@ function parseWindow(value) {
|
|
|
10441
10470
|
return parsed ? usageWindowKey(parsed.harness, parsed.window) : void 0;
|
|
10442
10471
|
}
|
|
10443
10472
|
function listUsageHistory(req, res) {
|
|
10444
|
-
return respondPagedRows(req, res, async (
|
|
10473
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
10445
10474
|
const window = parseWindow(params.get("window"));
|
|
10446
10475
|
const db = await getDb();
|
|
10447
10476
|
const [rows, total2] = await Promise.all([
|
|
10448
|
-
listUsagePeaks(db, { ...
|
|
10477
|
+
listUsagePeaks(db, { ...range, window }),
|
|
10449
10478
|
countUsagePeaks(db, window)
|
|
10450
10479
|
]);
|
|
10451
10480
|
return { rows, total: total2 };
|
|
@@ -10595,7 +10624,7 @@ async function listItemUsageSummaries(db, options2) {
|
|
|
10595
10624
|
|
|
10596
10625
|
// src/commands/sessions/web/listUsageItems.ts
|
|
10597
10626
|
function listUsageItems(req, res) {
|
|
10598
|
-
return respondPagedRows(req, res, async (
|
|
10627
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
10599
10628
|
const origin = params.get("origin") || void 0;
|
|
10600
10629
|
const status2 = parseItemUsageStatus(params.get("status"));
|
|
10601
10630
|
const sort = parseItemUsageSort(
|
|
@@ -10604,7 +10633,7 @@ function listUsageItems(req, res) {
|
|
|
10604
10633
|
);
|
|
10605
10634
|
const db = await getDb();
|
|
10606
10635
|
const [rows, summary, origins] = await Promise.all([
|
|
10607
|
-
listItemUsageSummaries(db, { ...
|
|
10636
|
+
listItemUsageSummaries(db, { ...range, origin, status: status2, sort }),
|
|
10608
10637
|
itemUsageStats(db, { origin, status: status2 }),
|
|
10609
10638
|
countItemUsageByOrigin(db)
|
|
10610
10639
|
]);
|
|
@@ -10643,13 +10672,13 @@ async function jobRunTotals(db, since) {
|
|
|
10643
10672
|
|
|
10644
10673
|
// src/shared/db/listJobRuns.ts
|
|
10645
10674
|
import { and as and13, count as count3, desc as desc8, eq as eq29 } from "drizzle-orm";
|
|
10646
|
-
async function listJobRuns(db,
|
|
10675
|
+
async function listJobRuns(db, range, filters = {}) {
|
|
10647
10676
|
const where = and13(
|
|
10648
10677
|
filters.kind ? eq29(jobRuns.kind, filters.kind) : void 0,
|
|
10649
10678
|
filters.trigger ? eq29(jobRuns.trigger, filters.trigger) : void 0
|
|
10650
10679
|
);
|
|
10651
10680
|
const [rows, [{ total: total2 }]] = await Promise.all([
|
|
10652
|
-
db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(
|
|
10681
|
+
db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(range.limit).offset(range.offset),
|
|
10653
10682
|
db.select({ total: count3() }).from(jobRuns).where(where)
|
|
10654
10683
|
]);
|
|
10655
10684
|
return { rows, total: total2 };
|
|
@@ -11072,11 +11101,11 @@ function parseJobRunFilters(params) {
|
|
|
11072
11101
|
};
|
|
11073
11102
|
}
|
|
11074
11103
|
function listUsageJobs(req, res) {
|
|
11075
|
-
return respondPagedRows(req, res, async (
|
|
11104
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
11076
11105
|
const db = await getDb();
|
|
11077
11106
|
await failTimedOutInboxScans(db);
|
|
11078
11107
|
const [page, totals] = await Promise.all([
|
|
11079
|
-
listJobRuns(db,
|
|
11108
|
+
listJobRuns(db, range, parseJobRunFilters(params)),
|
|
11080
11109
|
jobRunTotals(db, new Date(Date.now() - TOTALS_WINDOW_MS))
|
|
11081
11110
|
]);
|
|
11082
11111
|
return { ...page, totals };
|
|
@@ -11353,16 +11382,16 @@ function toReleaseCompareCommit({
|
|
|
11353
11382
|
// src/commands/sessions/web/releases/newestCommits.ts
|
|
11354
11383
|
var PAGE_SIZE = 100;
|
|
11355
11384
|
var MAX_PAGES2 = 3;
|
|
11356
|
-
function comparePage(cwd, repo,
|
|
11385
|
+
function comparePage(cwd, repo, range, page) {
|
|
11357
11386
|
return ghJson(cwd, [
|
|
11358
11387
|
"api",
|
|
11359
|
-
`repos/${repo}/compare/${
|
|
11388
|
+
`repos/${repo}/compare/${range}?per_page=${PAGE_SIZE}&page=${page}`,
|
|
11360
11389
|
"--jq",
|
|
11361
11390
|
`{total_commits, commits: [.commits[] | ${API_COMMIT_JQ}]}`
|
|
11362
11391
|
]);
|
|
11363
11392
|
}
|
|
11364
|
-
async function newestCommits(cwd, repo,
|
|
11365
|
-
const first = await comparePage(cwd, repo,
|
|
11393
|
+
async function newestCommits(cwd, repo, range) {
|
|
11394
|
+
const first = await comparePage(cwd, repo, range, 1);
|
|
11366
11395
|
const last = Math.ceil(first.total_commits / PAGE_SIZE);
|
|
11367
11396
|
if (last <= 1) return first.commits;
|
|
11368
11397
|
const pages = Array.from(
|
|
@@ -11371,7 +11400,7 @@ async function newestCommits(cwd, repo, range2) {
|
|
|
11371
11400
|
).reverse();
|
|
11372
11401
|
const tail = await Promise.all(
|
|
11373
11402
|
pages.map(
|
|
11374
|
-
(page) => page === 1 ? first : comparePage(cwd, repo,
|
|
11403
|
+
(page) => page === 1 ? first : comparePage(cwd, repo, range, page)
|
|
11375
11404
|
)
|
|
11376
11405
|
);
|
|
11377
11406
|
return tail.flatMap((page) => page.commits);
|
|
@@ -14698,7 +14727,7 @@ function installRestartMenu(options2 = {}) {
|
|
|
14698
14727
|
}
|
|
14699
14728
|
|
|
14700
14729
|
// src/commands/sessions/web/streamDaemonLogs.ts
|
|
14701
|
-
import { createInterface as
|
|
14730
|
+
import { createInterface as createInterface3 } from "readline";
|
|
14702
14731
|
var RECONNECT_MS = 3e3;
|
|
14703
14732
|
function streamDaemonLogs() {
|
|
14704
14733
|
void connect2();
|
|
@@ -14717,7 +14746,7 @@ async function connect2() {
|
|
|
14717
14746
|
}
|
|
14718
14747
|
}
|
|
14719
14748
|
function wire(socket) {
|
|
14720
|
-
const lines =
|
|
14749
|
+
const lines = createInterface3({ input: socket });
|
|
14721
14750
|
lines.on("error", () => {
|
|
14722
14751
|
});
|
|
14723
14752
|
lines.on("line", emit);
|
|
@@ -15254,8 +15283,8 @@ function setupVerifyRunEntry(scriptName, command, options2) {
|
|
|
15254
15283
|
if (!config.run) config.run = [];
|
|
15255
15284
|
const runList = config.run;
|
|
15256
15285
|
if (runList.find((r) => r.name === scriptName)) return;
|
|
15257
|
-
const
|
|
15258
|
-
const needsNpx = !GLOBAL_COMMANDS.has(
|
|
15286
|
+
const parts2 = command.split(/\s+/);
|
|
15287
|
+
const needsNpx = !GLOBAL_COMMANDS.has(parts2[0]);
|
|
15259
15288
|
const fullCommand = needsNpx ? `npx ${command}` : command;
|
|
15260
15289
|
const entry = buildRunEntry(
|
|
15261
15290
|
scriptName,
|
|
@@ -17973,28 +18002,28 @@ function findBlockRange(lines) {
|
|
|
17973
18002
|
function upsertScheduleBlock(crontab, every, cronLine) {
|
|
17974
18003
|
const lines = crontab.length === 0 ? [] : crontab.replace(/\n$/, "").split("\n");
|
|
17975
18004
|
const block = buildBlock(every, cronLine);
|
|
17976
|
-
const
|
|
17977
|
-
const next3 =
|
|
17978
|
-
...lines.slice(0,
|
|
18005
|
+
const range = findBlockRange(lines);
|
|
18006
|
+
const next3 = range === void 0 ? [...lines, ...block] : [
|
|
18007
|
+
...lines.slice(0, range.start),
|
|
17979
18008
|
...block,
|
|
17980
|
-
...lines.slice(
|
|
18009
|
+
...lines.slice(range.end + 1)
|
|
17981
18010
|
];
|
|
17982
18011
|
return `${next3.join("\n")}
|
|
17983
18012
|
`;
|
|
17984
18013
|
}
|
|
17985
18014
|
function removeScheduleBlock(crontab) {
|
|
17986
18015
|
const lines = crontab.length === 0 ? [] : crontab.replace(/\n$/, "").split("\n");
|
|
17987
|
-
const
|
|
17988
|
-
if (
|
|
17989
|
-
const next3 = [...lines.slice(0,
|
|
18016
|
+
const range = findBlockRange(lines);
|
|
18017
|
+
if (range === void 0) return crontab;
|
|
18018
|
+
const next3 = [...lines.slice(0, range.start), ...lines.slice(range.end + 1)];
|
|
17990
18019
|
return next3.length === 0 ? "" : `${next3.join("\n")}
|
|
17991
18020
|
`;
|
|
17992
18021
|
}
|
|
17993
18022
|
function readScheduleBlock(crontab) {
|
|
17994
18023
|
const lines = crontab.length === 0 ? [] : crontab.split("\n");
|
|
17995
|
-
const
|
|
17996
|
-
if (
|
|
17997
|
-
const body = lines.slice(
|
|
18024
|
+
const range = findBlockRange(lines);
|
|
18025
|
+
if (range === void 0) return void 0;
|
|
18026
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
17998
18027
|
const everyLine = body.find((line) => line.startsWith("# every "));
|
|
17999
18028
|
const cronLine = body.find(
|
|
18000
18029
|
(line) => !line.startsWith("#") && line.trim() !== ""
|
|
@@ -18073,15 +18102,15 @@ async function buildDump(tables, copyOut) {
|
|
|
18073
18102
|
version: DUMP_VERSION,
|
|
18074
18103
|
tables: tables.map(({ name, columns }) => ({ name, columns }))
|
|
18075
18104
|
});
|
|
18076
|
-
const
|
|
18105
|
+
const parts2 = [Buffer.from(`${header}
|
|
18077
18106
|
`, "utf8")];
|
|
18078
18107
|
for (const table of tables) {
|
|
18079
18108
|
const data = await copyOut(table);
|
|
18080
|
-
|
|
18109
|
+
parts2.push(Buffer.from(`@table ${table.name} ${data.length}
|
|
18081
18110
|
`, "utf8"));
|
|
18082
|
-
|
|
18111
|
+
parts2.push(data);
|
|
18083
18112
|
}
|
|
18084
|
-
return Buffer.concat(
|
|
18113
|
+
return Buffer.concat(parts2);
|
|
18085
18114
|
}
|
|
18086
18115
|
|
|
18087
18116
|
// src/commands/backlog/dump/copyTableOut.ts
|
|
@@ -18246,12 +18275,12 @@ function parseChartSeries(lines) {
|
|
|
18246
18275
|
for (const line of lines) {
|
|
18247
18276
|
const trimmed = line.trim();
|
|
18248
18277
|
if (trimmed === "") continue;
|
|
18249
|
-
const
|
|
18250
|
-
if (
|
|
18278
|
+
const parts2 = trimmed.split(/[,\t ]+/).filter((part) => part !== "");
|
|
18279
|
+
if (parts2.length < 2) {
|
|
18251
18280
|
throw new Error(`Expected a label and a value, got: ${trimmed}`);
|
|
18252
18281
|
}
|
|
18253
|
-
const label =
|
|
18254
|
-
const raw =
|
|
18282
|
+
const label = parts2.slice(0, -1).join(" ");
|
|
18283
|
+
const raw = parts2[parts2.length - 1];
|
|
18255
18284
|
const value = Number(raw);
|
|
18256
18285
|
if (!Number.isFinite(value)) {
|
|
18257
18286
|
throw new Error(`Value "${raw}" is not numeric, on line: ${trimmed}`);
|
|
@@ -19214,17 +19243,17 @@ import { randomUUID as randomUUID8 } from "crypto";
|
|
|
19214
19243
|
|
|
19215
19244
|
// src/commands/backlog/renderPhaseSection.ts
|
|
19216
19245
|
function renderPhaseSection(phase, idx) {
|
|
19217
|
-
const
|
|
19246
|
+
const parts2 = [
|
|
19218
19247
|
`### Phase ${idx + 1}: ${phase.name}`,
|
|
19219
19248
|
phase.tasks.map((task) => `- ${task}`).join("\n")
|
|
19220
19249
|
];
|
|
19221
19250
|
const manualChecks = phase.manualChecks ?? [];
|
|
19222
19251
|
if (manualChecks.length > 0)
|
|
19223
|
-
|
|
19252
|
+
parts2.push(
|
|
19224
19253
|
"**Manual checks:**",
|
|
19225
19254
|
manualChecks.map((check2) => `- ${check2}`).join("\n")
|
|
19226
19255
|
);
|
|
19227
|
-
return
|
|
19256
|
+
return parts2.join("\n\n");
|
|
19228
19257
|
}
|
|
19229
19258
|
|
|
19230
19259
|
// src/commands/backlog/addPhase/reviewProposedPhase.ts
|
|
@@ -23526,9 +23555,9 @@ function splitCompound(command) {
|
|
|
23526
23555
|
if (!tokens) return UNPARSEABLE2;
|
|
23527
23556
|
const grouped = groupByOperator(tokens);
|
|
23528
23557
|
if (!grouped.ok) return grouped;
|
|
23529
|
-
const
|
|
23530
|
-
if (
|
|
23531
|
-
return { ok: true, parts };
|
|
23558
|
+
const parts2 = grouped.groups.map((g) => stripEnvPrefix(g.filter((word) => word !== "")).join(" ")).filter((cmd) => cmd !== "");
|
|
23559
|
+
if (parts2.length === 0) return UNPARSEABLE2;
|
|
23560
|
+
return { ok: true, parts: parts2 };
|
|
23532
23561
|
}
|
|
23533
23562
|
function tokenizeCommand(command) {
|
|
23534
23563
|
const trimmed = separateCommandLines(stripHeredocBodies(command.trim())).replace(FD_DEVNULL_RE, "").replace(FD_REDIRECT_RE, "");
|
|
@@ -23540,10 +23569,10 @@ function tokenizeCommand(command) {
|
|
|
23540
23569
|
return void 0;
|
|
23541
23570
|
}
|
|
23542
23571
|
}
|
|
23543
|
-
function stripEnvPrefix(
|
|
23572
|
+
function stripEnvPrefix(parts2) {
|
|
23544
23573
|
let i = 0;
|
|
23545
|
-
while (i <
|
|
23546
|
-
return i > 0 ?
|
|
23574
|
+
while (i < parts2.length && /^[A-Za-z_]\w*=/.test(parts2[i])) i++;
|
|
23575
|
+
return i > 0 ? parts2.slice(i) : parts2;
|
|
23547
23576
|
}
|
|
23548
23577
|
|
|
23549
23578
|
// src/commands/cliHook/isGhGraphqlIssueMutation.ts
|
|
@@ -23683,8 +23712,8 @@ function toDecision(rule) {
|
|
|
23683
23712
|
permissionDecisionReason: rule.message
|
|
23684
23713
|
};
|
|
23685
23714
|
}
|
|
23686
|
-
function findBuiltinDeny(
|
|
23687
|
-
for (const part of
|
|
23715
|
+
function findBuiltinDeny(parts2) {
|
|
23716
|
+
for (const part of parts2) {
|
|
23688
23717
|
const decision = toDecision(matchBuiltinDeny(part));
|
|
23689
23718
|
if (decision) return decision;
|
|
23690
23719
|
}
|
|
@@ -23714,8 +23743,8 @@ function findRestrictedPathDenyRaw(rawCommand) {
|
|
|
23714
23743
|
permissionDecisionReason: `Do not read '~/${rule.path}'. The directory is off limits to every tool and command, and no settings allow entry, config rule or allowed read binary overrides that.`
|
|
23715
23744
|
};
|
|
23716
23745
|
}
|
|
23717
|
-
function findRestrictedPathDeny(
|
|
23718
|
-
for (const part of
|
|
23746
|
+
function findRestrictedPathDeny(parts2) {
|
|
23747
|
+
for (const part of parts2) {
|
|
23719
23748
|
const decision = findRestrictedPathDenyRaw(part);
|
|
23720
23749
|
if (decision) return decision;
|
|
23721
23750
|
}
|
|
@@ -23798,12 +23827,12 @@ function gatedDecision(gated) {
|
|
|
23798
23827
|
permissionDecisionReason: `Do not pipe '${gated}' through head or tail. It gates on a preview the reviewer can reject with inline comments, and those comments print at the end of the output. Nothing persists them, so a truncated read discards the reviewer's feedback for good and they have to retype it. Run '${gated}' bare and read all of it.`
|
|
23799
23828
|
};
|
|
23800
23829
|
}
|
|
23801
|
-
function findTruncatedReadDeny(
|
|
23802
|
-
const read4 =
|
|
23803
|
-
if (read4 &&
|
|
23830
|
+
function findTruncatedReadDeny(parts2) {
|
|
23831
|
+
const read4 = parts2.map(matchUntruncatableRead).find(Boolean);
|
|
23832
|
+
if (read4 && parts2.some((part) => startsWithFilter(part, read4.filters)))
|
|
23804
23833
|
return readDecision(read4);
|
|
23805
|
-
const gated =
|
|
23806
|
-
if (gated &&
|
|
23834
|
+
const gated = parts2.map(matchApprovalGatedCommand).find(Boolean);
|
|
23835
|
+
if (gated && parts2.some((part) => startsWithFilter(part, TRUNCATOR_BINARIES)))
|
|
23807
23836
|
return gatedDecision(gated);
|
|
23808
23837
|
return void 0;
|
|
23809
23838
|
}
|
|
@@ -24184,16 +24213,16 @@ function isApprovedRead(command, toolName = "Bash") {
|
|
|
24184
24213
|
return void 0;
|
|
24185
24214
|
}
|
|
24186
24215
|
function isCdToCwd(command) {
|
|
24187
|
-
const
|
|
24188
|
-
if (
|
|
24189
|
-
if (
|
|
24190
|
-
const resolved = resolve19(normalizeMsysPath(
|
|
24216
|
+
const parts2 = command.split(/\s+/);
|
|
24217
|
+
if (parts2[0] !== "cd" || parts2.length > 2) return false;
|
|
24218
|
+
if (parts2.length === 1) return false;
|
|
24219
|
+
const resolved = resolve19(normalizeMsysPath(parts2[1]));
|
|
24191
24220
|
return resolved === resolve19(process.cwd());
|
|
24192
24221
|
}
|
|
24193
24222
|
function isCdToReadAllowedDir(command) {
|
|
24194
|
-
const
|
|
24195
|
-
if (
|
|
24196
|
-
const target = resolve19(normalizeMsysPath(
|
|
24223
|
+
const parts2 = command.split(/\s+/);
|
|
24224
|
+
if (parts2[0] !== "cd" || parts2.length !== 2) return void 0;
|
|
24225
|
+
const target = resolve19(normalizeMsysPath(parts2[1]));
|
|
24197
24226
|
for (const entry of readSettingsPerms("allow")) {
|
|
24198
24227
|
const m = entry.match(READ_RE);
|
|
24199
24228
|
if (!m) continue;
|
|
@@ -24231,9 +24260,9 @@ var SUBCOMMAND_READS = [
|
|
|
24231
24260
|
subcommands: ["maintainability", "cyclomatic", "halstead"]
|
|
24232
24261
|
}
|
|
24233
24262
|
];
|
|
24234
|
-
function findSubcommandAdvice(
|
|
24235
|
-
if (
|
|
24236
|
-
for (const part of
|
|
24263
|
+
function findSubcommandAdvice(parts2) {
|
|
24264
|
+
if (parts2.length <= 1) return void 0;
|
|
24265
|
+
for (const part of parts2) {
|
|
24237
24266
|
const rule = matchesSubcommandRead(part);
|
|
24238
24267
|
if (rule) {
|
|
24239
24268
|
return {
|
|
@@ -24251,14 +24280,14 @@ function matchesSubcommandRead(part) {
|
|
|
24251
24280
|
}
|
|
24252
24281
|
|
|
24253
24282
|
// src/commands/cliHook/resolvePermission.ts
|
|
24254
|
-
function findDeny(toolName,
|
|
24255
|
-
const restrictedPathDeny = findRestrictedPathDeny(
|
|
24283
|
+
function findDeny(toolName, parts2) {
|
|
24284
|
+
const restrictedPathDeny = findRestrictedPathDeny(parts2);
|
|
24256
24285
|
if (restrictedPathDeny) return restrictedPathDeny;
|
|
24257
|
-
const builtinDeny = findBuiltinDeny(
|
|
24286
|
+
const builtinDeny = findBuiltinDeny(parts2);
|
|
24258
24287
|
if (builtinDeny) return builtinDeny;
|
|
24259
|
-
const truncatedRead = findTruncatedReadDeny(
|
|
24288
|
+
const truncatedRead = findTruncatedReadDeny(parts2);
|
|
24260
24289
|
if (truncatedRead) return truncatedRead;
|
|
24261
|
-
for (const part of
|
|
24290
|
+
for (const part of parts2) {
|
|
24262
24291
|
const configDeny = matchesConfigDeny(part);
|
|
24263
24292
|
if (configDeny) {
|
|
24264
24293
|
return {
|
|
@@ -24267,9 +24296,9 @@ function findDeny(toolName, parts) {
|
|
|
24267
24296
|
};
|
|
24268
24297
|
}
|
|
24269
24298
|
}
|
|
24270
|
-
const subcommandAdvice = findSubcommandAdvice(
|
|
24299
|
+
const subcommandAdvice = findSubcommandAdvice(parts2);
|
|
24271
24300
|
if (subcommandAdvice) return subcommandAdvice;
|
|
24272
|
-
for (const part of
|
|
24301
|
+
for (const part of parts2) {
|
|
24273
24302
|
const denied = matchesDeny(toolName, part);
|
|
24274
24303
|
if (denied) {
|
|
24275
24304
|
return {
|
|
@@ -24280,11 +24309,11 @@ function findDeny(toolName, parts) {
|
|
|
24280
24309
|
}
|
|
24281
24310
|
return void 0;
|
|
24282
24311
|
}
|
|
24283
|
-
function resolvePermission(toolName,
|
|
24284
|
-
const denied = findDeny(toolName,
|
|
24312
|
+
function resolvePermission(toolName, parts2) {
|
|
24313
|
+
const denied = findDeny(toolName, parts2);
|
|
24285
24314
|
if (denied) return denied;
|
|
24286
24315
|
const reasons = [];
|
|
24287
|
-
for (const part of
|
|
24316
|
+
for (const part of parts2) {
|
|
24288
24317
|
const reason4 = isApprovedRead(part, toolName);
|
|
24289
24318
|
if (!reason4) return void 0;
|
|
24290
24319
|
reasons.push(reason4);
|
|
@@ -24350,8 +24379,8 @@ function mentionsDocsPath(command, root2 = getProjectRoot()) {
|
|
|
24350
24379
|
// src/commands/cliHook/findDocsPathDeny.ts
|
|
24351
24380
|
function findDocsPathDeny(toolName, rawCommand, root2) {
|
|
24352
24381
|
const result = splitCompound(rawCommand);
|
|
24353
|
-
const
|
|
24354
|
-
const writes =
|
|
24382
|
+
const parts2 = result.ok ? result.parts : [rawCommand];
|
|
24383
|
+
const writes = parts2.some(
|
|
24355
24384
|
(part) => mentionsDocsPath(part, root2) && !isApprovedRead(part, toolName)
|
|
24356
24385
|
);
|
|
24357
24386
|
if (!writes) return void 0;
|
|
@@ -24612,8 +24641,8 @@ function reportDecision(decision) {
|
|
|
24612
24641
|
process.exitCode = 1;
|
|
24613
24642
|
return true;
|
|
24614
24643
|
}
|
|
24615
|
-
function reportDeny(toolName,
|
|
24616
|
-
return reportDecision(findDeny(toolName,
|
|
24644
|
+
function reportDeny(toolName, parts2) {
|
|
24645
|
+
return reportDecision(findDeny(toolName, parts2));
|
|
24617
24646
|
}
|
|
24618
24647
|
function cliHookCheck(command, toolName = "Bash") {
|
|
24619
24648
|
const trimmed = command.trim();
|
|
@@ -24627,10 +24656,10 @@ function cliHookCheck(command, toolName = "Bash") {
|
|
|
24627
24656
|
process.exitCode = 1;
|
|
24628
24657
|
return;
|
|
24629
24658
|
}
|
|
24630
|
-
const
|
|
24631
|
-
if (reportDeny(toolName,
|
|
24659
|
+
const parts2 = result.parts;
|
|
24660
|
+
if (reportDeny(toolName, parts2)) return;
|
|
24632
24661
|
const reasons = [];
|
|
24633
|
-
for (const part of
|
|
24662
|
+
for (const part of parts2) {
|
|
24634
24663
|
const reason4 = isApprovedRead(part, toolName);
|
|
24635
24664
|
if (!reason4) {
|
|
24636
24665
|
console.log(`not approved (unrecognised: ${part})`);
|
|
@@ -24933,9 +24962,9 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
24933
24962
|
);
|
|
24934
24963
|
process.exit(1);
|
|
24935
24964
|
}
|
|
24936
|
-
const
|
|
24937
|
-
const binary =
|
|
24938
|
-
const prefixPath =
|
|
24965
|
+
const parts2 = cli.split(/\s+/);
|
|
24966
|
+
const binary = parts2[0];
|
|
24967
|
+
const prefixPath = parts2.slice(1);
|
|
24939
24968
|
if (!options2.noCache) {
|
|
24940
24969
|
const cached2 = readCache(cli);
|
|
24941
24970
|
if (cached2) {
|
|
@@ -28114,7 +28143,7 @@ function parseNameOnlyLog(output, ignore3, afterDate) {
|
|
|
28114
28143
|
return byDate;
|
|
28115
28144
|
}
|
|
28116
28145
|
function fetchCommitsAfter(ignore3, afterDate) {
|
|
28117
|
-
const
|
|
28146
|
+
const range = afterDate ? [`--since=${afterDate}T00:00:00`] : [];
|
|
28118
28147
|
const output = execFileSync7(
|
|
28119
28148
|
"git",
|
|
28120
28149
|
[
|
|
@@ -28122,7 +28151,7 @@ function fetchCommitsAfter(ignore3, afterDate) {
|
|
|
28122
28151
|
"--name-only",
|
|
28123
28152
|
`--pretty=format:${RECORD_SEPARATOR}%ad|%h|%s`,
|
|
28124
28153
|
"--date=short",
|
|
28125
|
-
...
|
|
28154
|
+
...range
|
|
28126
28155
|
],
|
|
28127
28156
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024 }
|
|
28128
28157
|
);
|
|
@@ -28677,20 +28706,56 @@ function readDevEntryFile(path110) {
|
|
|
28677
28706
|
return { ...frontmatter2, lede: match[2].trim() };
|
|
28678
28707
|
}
|
|
28679
28708
|
|
|
28709
|
+
// src/commands/devlog/slack/formatDateRange.ts
|
|
28710
|
+
var MONTHS = [
|
|
28711
|
+
"Jan",
|
|
28712
|
+
"Feb",
|
|
28713
|
+
"Mar",
|
|
28714
|
+
"Apr",
|
|
28715
|
+
"May",
|
|
28716
|
+
"Jun",
|
|
28717
|
+
"Jul",
|
|
28718
|
+
"Aug",
|
|
28719
|
+
"Sep",
|
|
28720
|
+
"Oct",
|
|
28721
|
+
"Nov",
|
|
28722
|
+
"Dec"
|
|
28723
|
+
];
|
|
28724
|
+
function parts(date) {
|
|
28725
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
28726
|
+
return { year, month: MONTHS[month - 1], day };
|
|
28727
|
+
}
|
|
28728
|
+
function formatDateRange(first, last) {
|
|
28729
|
+
const a = parts(first);
|
|
28730
|
+
const b = parts(last);
|
|
28731
|
+
if (first === last) return `${a.day} ${a.month} ${a.year}`;
|
|
28732
|
+
if (a.year !== b.year)
|
|
28733
|
+
return `${a.day} ${a.month} ${a.year} \u2013 ${b.day} ${b.month} ${b.year}`;
|
|
28734
|
+
if (a.month !== b.month)
|
|
28735
|
+
return `${a.day} ${a.month} \u2013 ${b.day} ${b.month} ${b.year}`;
|
|
28736
|
+
return `${a.day}\u2013${b.day} ${b.month} ${b.year}`;
|
|
28737
|
+
}
|
|
28738
|
+
|
|
28680
28739
|
// src/commands/devlog/slack/renderDevlogSlackParts.ts
|
|
28681
28740
|
var SECTIONS = [
|
|
28682
28741
|
["added", "Added"],
|
|
28683
28742
|
["changed", "Changed"],
|
|
28684
28743
|
["fixed", "Fixed"]
|
|
28685
28744
|
];
|
|
28686
|
-
function
|
|
28687
|
-
if (!
|
|
28688
|
-
return
|
|
28745
|
+
function versionRange2(versions) {
|
|
28746
|
+
if (!versions?.first || !versions.last) return null;
|
|
28747
|
+
return versions.first === versions.last ? versions.first : `${versions.first} \u2192 ${versions.last}`;
|
|
28748
|
+
}
|
|
28749
|
+
function dateRange(entry, week) {
|
|
28750
|
+
const { first, last } = entry.dates ?? {};
|
|
28751
|
+
if (first && last) return formatDateRange(first, last);
|
|
28752
|
+
const { start: start2, end } = isoWeekRange(week);
|
|
28753
|
+
return formatDateRange(start2, end);
|
|
28689
28754
|
}
|
|
28690
28755
|
function renderHeader(entry, project, week) {
|
|
28691
|
-
const
|
|
28692
|
-
const
|
|
28693
|
-
return
|
|
28756
|
+
const head = `**${project} \xB7 ${dateRange(entry, week)}**`;
|
|
28757
|
+
const versions = versionRange2(entry.versions);
|
|
28758
|
+
return versions ? `${head} \xB7 ${versions}` : head;
|
|
28694
28759
|
}
|
|
28695
28760
|
function renderCounts(entry) {
|
|
28696
28761
|
const counts2 = SECTIONS.map(
|
|
@@ -28742,9 +28807,9 @@ function fail8(message3) {
|
|
|
28742
28807
|
console.error(chalk166.red(message3));
|
|
28743
28808
|
process.exit(1);
|
|
28744
28809
|
}
|
|
28745
|
-
function writeParts(channel,
|
|
28810
|
+
function writeParts(channel, parts2) {
|
|
28746
28811
|
mkdirSync22(slackWorkingFile(channel).dir, { recursive: true });
|
|
28747
|
-
return
|
|
28812
|
+
return parts2.map((part, index3) => {
|
|
28748
28813
|
const { bodyPath } = slackWorkingFile(channel, index3 + 1);
|
|
28749
28814
|
writeFileSync34(bodyPath, `${part}
|
|
28750
28815
|
`);
|
|
@@ -28773,17 +28838,17 @@ async function slack2(week) {
|
|
|
28773
28838
|
const entry = readDevEntryFile(path110);
|
|
28774
28839
|
if (!entry) fail8(`No dev entry for ${week} at ${path110}`);
|
|
28775
28840
|
if (entry.slack) fail8(`${week} is already posted: slack: ${entry.slack}`);
|
|
28776
|
-
const
|
|
28841
|
+
const parts2 = renderDevlogSlackParts(
|
|
28777
28842
|
entry,
|
|
28778
28843
|
entry.project ?? repoName,
|
|
28779
28844
|
week,
|
|
28780
28845
|
loadConfig().devlog?.url?.trim() || void 0
|
|
28781
28846
|
);
|
|
28782
|
-
if (
|
|
28783
|
-
await postSlackMessage(channel, { body:
|
|
28847
|
+
if (parts2.length === 1) {
|
|
28848
|
+
await postSlackMessage(channel, { body: parts2[0] });
|
|
28784
28849
|
return;
|
|
28785
28850
|
}
|
|
28786
|
-
await postSlackMessage(channel, { parts: writeParts(channel,
|
|
28851
|
+
await postSlackMessage(channel, { parts: writeParts(channel, parts2) });
|
|
28787
28852
|
}
|
|
28788
28853
|
|
|
28789
28854
|
// src/commands/devlog/write.ts
|
|
@@ -35267,7 +35332,7 @@ function linkifyMentions(text20, mentions) {
|
|
|
35267
35332
|
|
|
35268
35333
|
// src/commands/netcap/buildPost.ts
|
|
35269
35334
|
var profileUrl = (slug2) => `https://www.linkedin.com/in/${slug2}/`;
|
|
35270
|
-
var joinText = (
|
|
35335
|
+
var joinText = (parts2) => parts2.join(" ").replace(/\s+/g, " ").replace(/\s+([.,!?])/g, "$1").trim();
|
|
35271
35336
|
function resolveMentions(raw, mentionMap, author) {
|
|
35272
35337
|
const slugs = /* @__PURE__ */ new Set();
|
|
35273
35338
|
for (const url of raw.profileUrls) {
|
|
@@ -35939,13 +36004,13 @@ async function comment2(path110, line, body, options2 = {}) {
|
|
|
35939
36004
|
validateBody(body);
|
|
35940
36005
|
validateLine(line);
|
|
35941
36006
|
if (startLine !== void 0) validateLine(startLine);
|
|
35942
|
-
const
|
|
36007
|
+
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
35943
36008
|
if (!skipPreview)
|
|
35944
|
-
await reviewProposedPrComment(`Comment on ${path110}:${
|
|
36009
|
+
await reviewProposedPrComment(`Comment on ${path110}:${range}`, body, null);
|
|
35945
36010
|
try {
|
|
35946
36011
|
const prId = getCurrentPrNodeId();
|
|
35947
36012
|
postReviewComment({ prId, body, path: path110, line, startLine });
|
|
35948
|
-
console.log(`Added review comment on ${path110}:${
|
|
36013
|
+
console.log(`Added review comment on ${path110}:${range}`);
|
|
35949
36014
|
} catch (error) {
|
|
35950
36015
|
if (isGhNotInstalled(error)) {
|
|
35951
36016
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -36826,7 +36891,7 @@ Resolves ${refs}`;
|
|
|
36826
36891
|
return why;
|
|
36827
36892
|
}
|
|
36828
36893
|
function buildPrBody(sections) {
|
|
36829
|
-
const
|
|
36894
|
+
const parts2 = [
|
|
36830
36895
|
`## What
|
|
36831
36896
|
|
|
36832
36897
|
${sections.what}`,
|
|
@@ -36835,11 +36900,11 @@ ${sections.what}`,
|
|
|
36835
36900
|
${renderWhy(sections.why, sections.resolves)}`
|
|
36836
36901
|
];
|
|
36837
36902
|
if (sections.how) {
|
|
36838
|
-
|
|
36903
|
+
parts2.push(`## How
|
|
36839
36904
|
|
|
36840
36905
|
${sections.how}`);
|
|
36841
36906
|
}
|
|
36842
|
-
return
|
|
36907
|
+
return parts2.join("\n\n");
|
|
36843
36908
|
}
|
|
36844
36909
|
|
|
36845
36910
|
// src/commands/prs/parsePrBody.ts
|
|
@@ -40401,15 +40466,15 @@ function analyseTarget(sourceFile, functionName) {
|
|
|
40401
40466
|
|
|
40402
40467
|
// src/commands/refactor/extract/formatImportLine.ts
|
|
40403
40468
|
function formatImportLine(imp) {
|
|
40404
|
-
const
|
|
40405
|
-
if (imp.isTypeOnly)
|
|
40406
|
-
if (imp.defaultImport)
|
|
40407
|
-
if (imp.namespaceImport)
|
|
40469
|
+
const parts2 = [];
|
|
40470
|
+
if (imp.isTypeOnly) parts2.push("type ");
|
|
40471
|
+
if (imp.defaultImport) parts2.push(imp.defaultImport);
|
|
40472
|
+
if (imp.namespaceImport) parts2.push(`* as ${imp.namespaceImport}`);
|
|
40408
40473
|
if (imp.namedImports.length > 0) {
|
|
40409
|
-
if (imp.defaultImport)
|
|
40410
|
-
|
|
40474
|
+
if (imp.defaultImport) parts2.push(", ");
|
|
40475
|
+
parts2.push(`{ ${imp.namedImports.join(", ")} }`);
|
|
40411
40476
|
}
|
|
40412
|
-
return `import ${
|
|
40477
|
+
return `import ${parts2.join("")} from "${imp.moduleSpecifier}";`;
|
|
40413
40478
|
}
|
|
40414
40479
|
|
|
40415
40480
|
// src/commands/refactor/extract/buildDestinationContent.ts
|
|
@@ -41300,9 +41365,9 @@ import path71 from "path";
|
|
|
41300
41365
|
function lowestCommonAncestor(dirs) {
|
|
41301
41366
|
const [first, ...rest] = dirs.map((d) => d.split(path71.sep));
|
|
41302
41367
|
let common = first;
|
|
41303
|
-
for (const
|
|
41368
|
+
for (const parts2 of rest) {
|
|
41304
41369
|
let i = 0;
|
|
41305
|
-
while (i < common.length && i <
|
|
41370
|
+
while (i < common.length && i < parts2.length && common[i] === parts2[i]) i++;
|
|
41306
41371
|
common = common.slice(0, i);
|
|
41307
41372
|
}
|
|
41308
41373
|
return common.join(path71.sep) || path71.sep;
|
|
@@ -41749,9 +41814,9 @@ function computeDepthStats(targets, scopeRoot) {
|
|
|
41749
41814
|
|
|
41750
41815
|
// src/commands/refactor/restructure/formatTree.ts
|
|
41751
41816
|
import path83 from "path";
|
|
41752
|
-
function insert(root2,
|
|
41817
|
+
function insert(root2, parts2) {
|
|
41753
41818
|
let node = root2;
|
|
41754
|
-
for (const part of
|
|
41819
|
+
for (const part of parts2) {
|
|
41755
41820
|
const child = node.get(part) ?? /* @__PURE__ */ new Map();
|
|
41756
41821
|
node.set(part, child);
|
|
41757
41822
|
node = child;
|
|
@@ -45680,10 +45745,10 @@ function warnOutOfDiff(outOfDiff) {
|
|
|
45680
45745
|
)
|
|
45681
45746
|
);
|
|
45682
45747
|
for (const finding of outOfDiff) {
|
|
45683
|
-
const
|
|
45748
|
+
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
45684
45749
|
console.warn(
|
|
45685
45750
|
` ${chalk264.yellow("\xB7")} ${finding.title} ${chalk264.dim(
|
|
45686
|
-
`(${finding.file}:${
|
|
45751
|
+
`(${finding.file}:${range})`
|
|
45687
45752
|
)}`
|
|
45688
45753
|
);
|
|
45689
45754
|
}
|
|
@@ -45775,10 +45840,10 @@ function stillOnReviewedPr(prNumber) {
|
|
|
45775
45840
|
|
|
45776
45841
|
// src/commands/review/describeWork.ts
|
|
45777
45842
|
function describeWork(comments3, carried) {
|
|
45778
|
-
const
|
|
45779
|
-
if (comments3 > 0)
|
|
45780
|
-
if (carried > 0)
|
|
45781
|
-
return
|
|
45843
|
+
const parts2 = [];
|
|
45844
|
+
if (comments3 > 0) parts2.push(`${comments3} line comment(s)`);
|
|
45845
|
+
if (carried > 0) parts2.push(`${carried} finding(s) in the review body`);
|
|
45846
|
+
return parts2.join(" and ");
|
|
45782
45847
|
}
|
|
45783
45848
|
|
|
45784
45849
|
// src/commands/review/postReviewToPr.ts
|
|
@@ -46177,9 +46242,9 @@ function pointerLine(directories) {
|
|
|
46177
46242
|
}
|
|
46178
46243
|
function upsertScopedRulesPointer(content, directories) {
|
|
46179
46244
|
const lines = contentLines(content);
|
|
46180
|
-
const
|
|
46245
|
+
const range = rulesSectionRange(lines);
|
|
46181
46246
|
const existing = lines.findIndex(
|
|
46182
|
-
(line, index3) =>
|
|
46247
|
+
(line, index3) => range !== void 0 && index3 > range.start && index3 < range.end && line.startsWith(POINTER_PREFIX)
|
|
46183
46248
|
);
|
|
46184
46249
|
if (directories.length === 0) {
|
|
46185
46250
|
if (existing === -1) return content;
|
|
@@ -46195,9 +46260,9 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
46195
46260
|
return `${replaced.join("\n")}
|
|
46196
46261
|
`;
|
|
46197
46262
|
}
|
|
46198
|
-
if (!
|
|
46199
|
-
let at2 =
|
|
46200
|
-
while (at2 >
|
|
46263
|
+
if (!range) return appendRulesSection(lines, pointer);
|
|
46264
|
+
let at2 = range.end;
|
|
46265
|
+
while (at2 > range.start + 1 && (lines[at2 - 1] ?? "").trim() === "") at2--;
|
|
46201
46266
|
return `${[...lines.slice(0, at2), "", pointer, ...lines.slice(at2)].join("\n")}
|
|
46202
46267
|
`;
|
|
46203
46268
|
}
|
|
@@ -46270,14 +46335,14 @@ function ruleBullet({ code, title, text: text20 }) {
|
|
|
46270
46335
|
function insertRuleBullet(content, rule) {
|
|
46271
46336
|
const bullet = ruleBullet(rule);
|
|
46272
46337
|
const lines = contentLines(content);
|
|
46273
|
-
const
|
|
46274
|
-
if (!
|
|
46275
|
-
const body = lines.slice(
|
|
46338
|
+
const range = rulesSectionRange(lines);
|
|
46339
|
+
if (!range) return appendRulesSection(lines, bullet);
|
|
46340
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
46276
46341
|
const lastBullet = body.reduce(
|
|
46277
46342
|
(last, line, index3) => RULE_BULLET.test(line) ? index3 : last,
|
|
46278
46343
|
-1
|
|
46279
46344
|
);
|
|
46280
|
-
const at2 = lastBullet === -1 ?
|
|
46345
|
+
const at2 = lastBullet === -1 ? range.start + 1 : range.start + lastBullet + 2;
|
|
46281
46346
|
const inserted = lastBullet === -1 ? ["", bullet] : [bullet];
|
|
46282
46347
|
return `${[...lines.slice(0, at2), ...inserted, ...lines.slice(at2)].join("\n")}
|
|
46283
46348
|
`;
|
|
@@ -47121,9 +47186,9 @@ async function sqlColumns(table, connectionName) {
|
|
|
47121
47186
|
const conn = resolveConnection3(connectionName);
|
|
47122
47187
|
const pool = await sqlConnect(conn);
|
|
47123
47188
|
try {
|
|
47124
|
-
const
|
|
47125
|
-
const schema2 =
|
|
47126
|
-
const name =
|
|
47189
|
+
const parts2 = table.split(".");
|
|
47190
|
+
const schema2 = parts2.length > 1 ? parts2[0] : void 0;
|
|
47191
|
+
const name = parts2.length > 1 ? parts2[1] : parts2[0];
|
|
47127
47192
|
const request = pool.request().input("table", name);
|
|
47128
47193
|
let where = "TABLE_NAME = @table";
|
|
47129
47194
|
if (schema2) {
|
|
@@ -47891,9 +47956,9 @@ function parseHMS(h, m, s) {
|
|
|
47891
47956
|
function parseMS(m, s) {
|
|
47892
47957
|
return Number.parseInt(m, 10) * 60 + Number.parseFloat(s);
|
|
47893
47958
|
}
|
|
47894
|
-
function toSeconds(
|
|
47895
|
-
if (
|
|
47896
|
-
if (
|
|
47959
|
+
function toSeconds(parts2) {
|
|
47960
|
+
if (parts2.length === 3) return parseHMS(parts2[0], parts2[1], parts2[2]);
|
|
47961
|
+
if (parts2.length === 2) return parseMS(parts2[0], parts2[1]);
|
|
47897
47962
|
return 0;
|
|
47898
47963
|
}
|
|
47899
47964
|
function parseTimestamp(ts10) {
|
|
@@ -48217,24 +48282,24 @@ function lastEndMs(cues) {
|
|
|
48217
48282
|
|
|
48218
48283
|
// src/commands/transcript/selectPassages.ts
|
|
48219
48284
|
var CLOCK = /^(?:(\d{1,3}):)?(\d{1,2}):(\d{1,2})(?:\.(\d{1,3}))?$/;
|
|
48220
|
-
function describeRange(
|
|
48221
|
-
return `${
|
|
48285
|
+
function describeRange(range) {
|
|
48286
|
+
return `${range.from} --> ${range.to} in ${range.file}`;
|
|
48222
48287
|
}
|
|
48223
|
-
function parseClock(value,
|
|
48288
|
+
function parseClock(value, range) {
|
|
48224
48289
|
const match = value.match(CLOCK);
|
|
48225
48290
|
if (!match) {
|
|
48226
48291
|
failTranscript(
|
|
48227
|
-
`malformed timestamp "${value}" in selection range ${describeRange(
|
|
48292
|
+
`malformed timestamp "${value}" in selection range ${describeRange(range)}`
|
|
48228
48293
|
);
|
|
48229
48294
|
}
|
|
48230
48295
|
const [, hours, minutes, seconds, millis] = match;
|
|
48231
48296
|
return (Number(hours ?? 0) * 3600 + Number(minutes) * 60 + Number(seconds)) * 1e3 + Number((millis ?? "").padEnd(3, "0"));
|
|
48232
48297
|
}
|
|
48233
|
-
function findSource(sources,
|
|
48298
|
+
function findSource(sources, range) {
|
|
48234
48299
|
const match = sources.find(
|
|
48235
|
-
(source) => source.path ===
|
|
48300
|
+
(source) => source.path === range.file || source.name === range.file
|
|
48236
48301
|
);
|
|
48237
|
-
return match ?? failTranscript(`selection names a file that was not given: ${
|
|
48302
|
+
return match ?? failTranscript(`selection names a file that was not given: ${range.file}`);
|
|
48238
48303
|
}
|
|
48239
48304
|
function spanOf(source) {
|
|
48240
48305
|
return {
|
|
@@ -48242,24 +48307,24 @@ function spanOf(source) {
|
|
|
48242
48307
|
endMs: Math.max(...source.cues.map((cue) => cue.endMs))
|
|
48243
48308
|
};
|
|
48244
48309
|
}
|
|
48245
|
-
function boundsOf(source,
|
|
48246
|
-
const fromMs = parseClock(
|
|
48247
|
-
const toMs = parseClock(
|
|
48310
|
+
function boundsOf(source, range) {
|
|
48311
|
+
const fromMs = parseClock(range.from, range);
|
|
48312
|
+
const toMs = parseClock(range.to, range);
|
|
48248
48313
|
if (toMs < fromMs) {
|
|
48249
48314
|
failTranscript(
|
|
48250
|
-
`selection range ${describeRange(
|
|
48315
|
+
`selection range ${describeRange(range)} ends before it starts`
|
|
48251
48316
|
);
|
|
48252
48317
|
}
|
|
48253
48318
|
const span = spanOf(source);
|
|
48254
48319
|
if (fromMs > span.endMs || toMs < span.startMs) {
|
|
48255
48320
|
failTranscript(
|
|
48256
|
-
`selection range ${describeRange(
|
|
48321
|
+
`selection range ${describeRange(range)} lies outside that file's cues`
|
|
48257
48322
|
);
|
|
48258
48323
|
}
|
|
48259
48324
|
return { fromMs, toMs };
|
|
48260
48325
|
}
|
|
48261
|
-
function cuesInRange(source,
|
|
48262
|
-
const { fromMs, toMs } = boundsOf(source,
|
|
48326
|
+
function cuesInRange(source, range) {
|
|
48327
|
+
const { fromMs, toMs } = boundsOf(source, range);
|
|
48263
48328
|
return source.cues.filter(
|
|
48264
48329
|
(cue) => cue.startMs >= fromMs && cue.startMs <= toMs
|
|
48265
48330
|
);
|
|
@@ -48268,9 +48333,9 @@ function toPassage(source, cues) {
|
|
|
48268
48333
|
return { source: source.name, sourceStartMs: cues[0].startMs, cues };
|
|
48269
48334
|
}
|
|
48270
48335
|
function selectPassages(sources, selection) {
|
|
48271
|
-
const passages = selection.keep.flatMap((
|
|
48272
|
-
const source = findSource(sources,
|
|
48273
|
-
const cues = cuesInRange(source,
|
|
48336
|
+
const passages = selection.keep.flatMap((range) => {
|
|
48337
|
+
const source = findSource(sources, range);
|
|
48338
|
+
const cues = cuesInRange(source, range);
|
|
48274
48339
|
return cues.length ? [toPassage(source, cues)] : [];
|
|
48275
48340
|
});
|
|
48276
48341
|
if (passages.length === 0) {
|
|
@@ -48564,14 +48629,14 @@ function collectComments(sourceFile) {
|
|
|
48564
48629
|
const seen = /* @__PURE__ */ new Set();
|
|
48565
48630
|
const comments3 = [];
|
|
48566
48631
|
const collect8 = (node) => {
|
|
48567
|
-
for (const
|
|
48632
|
+
for (const range of [
|
|
48568
48633
|
...node.getLeadingCommentRanges(),
|
|
48569
48634
|
...node.getTrailingCommentRanges()
|
|
48570
48635
|
]) {
|
|
48571
|
-
const pos =
|
|
48636
|
+
const pos = range.getPos();
|
|
48572
48637
|
if (seen.has(pos)) continue;
|
|
48573
48638
|
seen.add(pos);
|
|
48574
|
-
comments3.push({ pos, text:
|
|
48639
|
+
comments3.push({ pos, text: range.getText() });
|
|
48575
48640
|
}
|
|
48576
48641
|
};
|
|
48577
48642
|
collect8(sourceFile);
|
|
@@ -50694,7 +50759,7 @@ function listDaemonPids() {
|
|
|
50694
50759
|
}
|
|
50695
50760
|
|
|
50696
50761
|
// src/commands/sessions/daemon/queryDaemon.ts
|
|
50697
|
-
import { createInterface as
|
|
50762
|
+
import { createInterface as createInterface7 } from "readline";
|
|
50698
50763
|
var STATUS_TIMEOUT_MS2 = 5e3;
|
|
50699
50764
|
function queryDaemon(socket) {
|
|
50700
50765
|
socket.write(`${JSON.stringify({ type: "ping" })}
|
|
@@ -50703,7 +50768,7 @@ function queryDaemon(socket) {
|
|
|
50703
50768
|
const result = { sessions: [] };
|
|
50704
50769
|
const pending = /* @__PURE__ */ new Set(["sessions", "pong"]);
|
|
50705
50770
|
const timer = setTimeout(() => resolve34(result), STATUS_TIMEOUT_MS2);
|
|
50706
|
-
const lines =
|
|
50771
|
+
const lines = createInterface7({ input: socket });
|
|
50707
50772
|
lines.on("error", () => {
|
|
50708
50773
|
});
|
|
50709
50774
|
lines.on("line", (line) => {
|
|
@@ -50797,7 +50862,7 @@ function reportStrays(pids) {
|
|
|
50797
50862
|
}
|
|
50798
50863
|
|
|
50799
50864
|
// src/commands/sessions/daemon/drainDaemon.ts
|
|
50800
|
-
import { createInterface as
|
|
50865
|
+
import { createInterface as createInterface8 } from "readline";
|
|
50801
50866
|
|
|
50802
50867
|
// src/commands/sessions/daemon/clearPersistedSessionsOnDrain.ts
|
|
50803
50868
|
function clearPersistedSessionsOnDrain() {
|
|
@@ -50839,7 +50904,7 @@ async function drainDaemon(options2 = {}) {
|
|
|
50839
50904
|
clearPersistedSessionsOnDrain();
|
|
50840
50905
|
return;
|
|
50841
50906
|
}
|
|
50842
|
-
const lines =
|
|
50907
|
+
const lines = createInterface8({ input: socket });
|
|
50843
50908
|
lines.on("error", () => {
|
|
50844
50909
|
});
|
|
50845
50910
|
const live = await liveSessions(lines);
|
|
@@ -53370,16 +53435,16 @@ function describeOccupants(occupants) {
|
|
|
53370
53435
|
if (o.vscode) continue;
|
|
53371
53436
|
others.set(o.name, [...others.get(o.name) ?? [], o.pid]);
|
|
53372
53437
|
}
|
|
53373
|
-
const
|
|
53438
|
+
const parts2 = [];
|
|
53374
53439
|
if (vscode.length > 0)
|
|
53375
|
-
|
|
53440
|
+
parts2.push(`VS Code has this worktree open (${pidList(vscode)})`);
|
|
53376
53441
|
if (others.size > 0) {
|
|
53377
53442
|
const programs = [...others].map(
|
|
53378
53443
|
([name, pids]) => `${name} (${pidList(pids)})`
|
|
53379
53444
|
);
|
|
53380
|
-
|
|
53445
|
+
parts2.push(`a live process is still running in it: ${programs.join(", ")}`);
|
|
53381
53446
|
}
|
|
53382
|
-
return
|
|
53447
|
+
return parts2.join("; ");
|
|
53383
53448
|
}
|
|
53384
53449
|
function pidList(pids) {
|
|
53385
53450
|
return `pid ${[...pids].sort((a, b) => a - b).join(", ")}`;
|
|
@@ -54649,13 +54714,13 @@ function extractLastAssistantMessage(entries) {
|
|
|
54649
54714
|
function assistantText(entry) {
|
|
54650
54715
|
const content = asRecord4(entry.message)?.content;
|
|
54651
54716
|
if (!Array.isArray(content)) return "";
|
|
54652
|
-
const
|
|
54717
|
+
const parts2 = [];
|
|
54653
54718
|
for (const block of content) {
|
|
54654
54719
|
const b = asRecord4(block);
|
|
54655
54720
|
if (b?.type === "text" && typeof b.text === "string" && b.text.trim())
|
|
54656
|
-
|
|
54721
|
+
parts2.push(b.text.trim());
|
|
54657
54722
|
}
|
|
54658
|
-
return
|
|
54723
|
+
return parts2.join("\n");
|
|
54659
54724
|
}
|
|
54660
54725
|
function cap(text20) {
|
|
54661
54726
|
return text20.length <= MAX_LENGTH2 ? text20 : `${text20.slice(0, MAX_LENGTH2).trimEnd()}\u2026`;
|
|
@@ -54702,15 +54767,15 @@ function promptTextOrNull(entry) {
|
|
|
54702
54767
|
const content = asRecord5(entry.message)?.content;
|
|
54703
54768
|
if (typeof content === "string") return isInterrupt(content) ? null : content;
|
|
54704
54769
|
if (!Array.isArray(content)) return null;
|
|
54705
|
-
const
|
|
54770
|
+
const parts2 = [];
|
|
54706
54771
|
for (const block of content) {
|
|
54707
54772
|
const b = asRecord5(block);
|
|
54708
54773
|
if (b?.type !== "text") continue;
|
|
54709
54774
|
const text20 = typeof b.text === "string" ? b.text : "";
|
|
54710
54775
|
if (isInterrupt(text20)) return null;
|
|
54711
|
-
|
|
54776
|
+
parts2.push(text20);
|
|
54712
54777
|
}
|
|
54713
|
-
return
|
|
54778
|
+
return parts2.length === 0 ? null : parts2.join("\n");
|
|
54714
54779
|
}
|
|
54715
54780
|
function cap2(message3, maxLength) {
|
|
54716
54781
|
return message3.length <= maxLength ? message3 : `${message3.slice(0, maxLength).trimEnd()}\u2026`;
|
|
@@ -54832,16 +54897,16 @@ var MAX_CONTEXT_CHARS = 800;
|
|
|
54832
54897
|
function extractContextAfterReference(filePath) {
|
|
54833
54898
|
const head = readTranscriptHead(filePath);
|
|
54834
54899
|
if (head === void 0) return void 0;
|
|
54835
|
-
const
|
|
54900
|
+
const parts2 = [];
|
|
54836
54901
|
let length = 0;
|
|
54837
54902
|
for (const text20 of conversationText(head)) {
|
|
54838
|
-
if (
|
|
54839
|
-
|
|
54903
|
+
if (parts2.length === 0 && isBareReferencePrompt(text20)) continue;
|
|
54904
|
+
parts2.push(text20);
|
|
54840
54905
|
length += text20.length;
|
|
54841
54906
|
if (length >= MAX_CONTEXT_CHARS) break;
|
|
54842
54907
|
}
|
|
54843
54908
|
if (length < MIN_CONTEXT_CHARS) return void 0;
|
|
54844
|
-
return
|
|
54909
|
+
return parts2.join("\n").slice(0, MAX_CONTEXT_CHARS);
|
|
54845
54910
|
}
|
|
54846
54911
|
function* conversationText(head) {
|
|
54847
54912
|
for (const line of head.split("\n")) {
|
|
@@ -58511,7 +58576,7 @@ function exitAfterFlush(code) {
|
|
|
58511
58576
|
}
|
|
58512
58577
|
|
|
58513
58578
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
58514
|
-
import { createInterface as
|
|
58579
|
+
import { createInterface as createInterface10 } from "readline";
|
|
58515
58580
|
|
|
58516
58581
|
// src/commands/sessions/daemon/routed.ts
|
|
58517
58582
|
function routed(local) {
|
|
@@ -59775,7 +59840,7 @@ function handleConnection(socket, manager) {
|
|
|
59775
59840
|
};
|
|
59776
59841
|
manager.addClient(client);
|
|
59777
59842
|
manager.clients.greet(client);
|
|
59778
|
-
const lines =
|
|
59843
|
+
const lines = createInterface10({ input: socket });
|
|
59779
59844
|
lines.on("error", () => {
|
|
59780
59845
|
});
|
|
59781
59846
|
lines.on("line", (line) => {
|
|
@@ -60426,14 +60491,14 @@ function registerNodes(sessions) {
|
|
|
60426
60491
|
}
|
|
60427
60492
|
|
|
60428
60493
|
// src/commands/sessions/daemon/requestSessionOutput.ts
|
|
60429
|
-
import { createInterface as
|
|
60494
|
+
import { createInterface as createInterface11 } from "readline";
|
|
60430
60495
|
var OUTPUT_TIMEOUT_MS = 5e3;
|
|
60431
60496
|
async function requestSessionOutput(target) {
|
|
60432
60497
|
const socket = await connectToDaemon().catch(() => {
|
|
60433
60498
|
throw new Error("No sessions daemon is running");
|
|
60434
60499
|
});
|
|
60435
60500
|
try {
|
|
60436
|
-
const lines =
|
|
60501
|
+
const lines = createInterface11({ input: socket });
|
|
60437
60502
|
lines.on("error", () => {
|
|
60438
60503
|
});
|
|
60439
60504
|
const reply2 = readDaemonMessage(
|