@staff0rd/assist 0.1090.0 → 0.1092.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +284 -284
- package/dist/index.js +233 -179
- 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.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -713,7 +713,8 @@ var runConfigSchema = z3.strictObject({
|
|
|
713
713
|
quiet: z3.boolean().optional(),
|
|
714
714
|
server: z3.union([z3.boolean(), z3.string().min(1)]).optional(),
|
|
715
715
|
port: z3.number().optional(),
|
|
716
|
-
protocol: z3.enum(["http", "https"]).optional()
|
|
716
|
+
protocol: z3.enum(["http", "https"]).optional(),
|
|
717
|
+
path: z3.string().optional()
|
|
717
718
|
});
|
|
718
719
|
var runLinkSchema = z3.strictObject({
|
|
719
720
|
link: z3.string(),
|
|
@@ -8555,8 +8556,8 @@ function deriveProject(cwd, filePath, origin) {
|
|
|
8555
8556
|
}
|
|
8556
8557
|
function dirNameToProject(filePath) {
|
|
8557
8558
|
const dirName = path8.basename(path8.dirname(filePath));
|
|
8558
|
-
const
|
|
8559
|
-
return
|
|
8559
|
+
const parts2 = dirName.split("--");
|
|
8560
|
+
return parts2[parts2.length - 1].replace(/-/g, "/");
|
|
8560
8561
|
}
|
|
8561
8562
|
|
|
8562
8563
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
@@ -9033,9 +9034,9 @@ function negotiateProtocol(msg) {
|
|
|
9033
9034
|
const common = Math.min(peer.max, PROTOCOL_VERSION);
|
|
9034
9035
|
return common >= Math.max(peer.min, MIN_PROTOCOL_VERSION) ? common : void 0;
|
|
9035
9036
|
}
|
|
9036
|
-
function formatRange(
|
|
9037
|
-
if (!
|
|
9038
|
-
return
|
|
9037
|
+
function formatRange(range) {
|
|
9038
|
+
if (!range) return "legacy (no protocol)";
|
|
9039
|
+
return range.min === range.max ? `protocol ${range.max}` : `protocols ${range.min}\u2013${range.max}`;
|
|
9039
9040
|
}
|
|
9040
9041
|
function describeProtocolGap(node, msg) {
|
|
9041
9042
|
const peer = peerProtocolRange(msg);
|
|
@@ -10268,10 +10269,10 @@ function splitTitle(rest) {
|
|
|
10268
10269
|
}
|
|
10269
10270
|
function parseRulesSection(content) {
|
|
10270
10271
|
const lines = content.split(/\r?\n/);
|
|
10271
|
-
const
|
|
10272
|
-
if (!
|
|
10272
|
+
const range = rulesSectionRange(lines);
|
|
10273
|
+
if (!range) return [];
|
|
10273
10274
|
const rules2 = [];
|
|
10274
|
-
for (const line of lines.slice(
|
|
10275
|
+
for (const line of lines.slice(range.start + 1, range.end)) {
|
|
10275
10276
|
const match = RULE_BULLET.exec(line);
|
|
10276
10277
|
if (!match) continue;
|
|
10277
10278
|
const code = match[1].trim();
|
|
@@ -10440,11 +10441,11 @@ function parseWindow(value) {
|
|
|
10440
10441
|
return parsed ? usageWindowKey(parsed.harness, parsed.window) : void 0;
|
|
10441
10442
|
}
|
|
10442
10443
|
function listUsageHistory(req, res) {
|
|
10443
|
-
return respondPagedRows(req, res, async (
|
|
10444
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
10444
10445
|
const window = parseWindow(params.get("window"));
|
|
10445
10446
|
const db = await getDb();
|
|
10446
10447
|
const [rows, total2] = await Promise.all([
|
|
10447
|
-
listUsagePeaks(db, { ...
|
|
10448
|
+
listUsagePeaks(db, { ...range, window }),
|
|
10448
10449
|
countUsagePeaks(db, window)
|
|
10449
10450
|
]);
|
|
10450
10451
|
return { rows, total: total2 };
|
|
@@ -10594,7 +10595,7 @@ async function listItemUsageSummaries(db, options2) {
|
|
|
10594
10595
|
|
|
10595
10596
|
// src/commands/sessions/web/listUsageItems.ts
|
|
10596
10597
|
function listUsageItems(req, res) {
|
|
10597
|
-
return respondPagedRows(req, res, async (
|
|
10598
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
10598
10599
|
const origin = params.get("origin") || void 0;
|
|
10599
10600
|
const status2 = parseItemUsageStatus(params.get("status"));
|
|
10600
10601
|
const sort = parseItemUsageSort(
|
|
@@ -10603,7 +10604,7 @@ function listUsageItems(req, res) {
|
|
|
10603
10604
|
);
|
|
10604
10605
|
const db = await getDb();
|
|
10605
10606
|
const [rows, summary, origins] = await Promise.all([
|
|
10606
|
-
listItemUsageSummaries(db, { ...
|
|
10607
|
+
listItemUsageSummaries(db, { ...range, origin, status: status2, sort }),
|
|
10607
10608
|
itemUsageStats(db, { origin, status: status2 }),
|
|
10608
10609
|
countItemUsageByOrigin(db)
|
|
10609
10610
|
]);
|
|
@@ -10642,13 +10643,13 @@ async function jobRunTotals(db, since) {
|
|
|
10642
10643
|
|
|
10643
10644
|
// src/shared/db/listJobRuns.ts
|
|
10644
10645
|
import { and as and13, count as count3, desc as desc8, eq as eq29 } from "drizzle-orm";
|
|
10645
|
-
async function listJobRuns(db,
|
|
10646
|
+
async function listJobRuns(db, range, filters = {}) {
|
|
10646
10647
|
const where = and13(
|
|
10647
10648
|
filters.kind ? eq29(jobRuns.kind, filters.kind) : void 0,
|
|
10648
10649
|
filters.trigger ? eq29(jobRuns.trigger, filters.trigger) : void 0
|
|
10649
10650
|
);
|
|
10650
10651
|
const [rows, [{ total: total2 }]] = await Promise.all([
|
|
10651
|
-
db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(
|
|
10652
|
+
db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(range.limit).offset(range.offset),
|
|
10652
10653
|
db.select({ total: count3() }).from(jobRuns).where(where)
|
|
10653
10654
|
]);
|
|
10654
10655
|
return { rows, total: total2 };
|
|
@@ -11071,11 +11072,11 @@ function parseJobRunFilters(params) {
|
|
|
11071
11072
|
};
|
|
11072
11073
|
}
|
|
11073
11074
|
function listUsageJobs(req, res) {
|
|
11074
|
-
return respondPagedRows(req, res, async (
|
|
11075
|
+
return respondPagedRows(req, res, async (range, params) => {
|
|
11075
11076
|
const db = await getDb();
|
|
11076
11077
|
await failTimedOutInboxScans(db);
|
|
11077
11078
|
const [page, totals] = await Promise.all([
|
|
11078
|
-
listJobRuns(db,
|
|
11079
|
+
listJobRuns(db, range, parseJobRunFilters(params)),
|
|
11079
11080
|
jobRunTotals(db, new Date(Date.now() - TOTALS_WINDOW_MS))
|
|
11080
11081
|
]);
|
|
11081
11082
|
return { ...page, totals };
|
|
@@ -11352,16 +11353,16 @@ function toReleaseCompareCommit({
|
|
|
11352
11353
|
// src/commands/sessions/web/releases/newestCommits.ts
|
|
11353
11354
|
var PAGE_SIZE = 100;
|
|
11354
11355
|
var MAX_PAGES2 = 3;
|
|
11355
|
-
function comparePage(cwd, repo,
|
|
11356
|
+
function comparePage(cwd, repo, range, page) {
|
|
11356
11357
|
return ghJson(cwd, [
|
|
11357
11358
|
"api",
|
|
11358
|
-
`repos/${repo}/compare/${
|
|
11359
|
+
`repos/${repo}/compare/${range}?per_page=${PAGE_SIZE}&page=${page}`,
|
|
11359
11360
|
"--jq",
|
|
11360
11361
|
`{total_commits, commits: [.commits[] | ${API_COMMIT_JQ}]}`
|
|
11361
11362
|
]);
|
|
11362
11363
|
}
|
|
11363
|
-
async function newestCommits(cwd, repo,
|
|
11364
|
-
const first = await comparePage(cwd, repo,
|
|
11364
|
+
async function newestCommits(cwd, repo, range) {
|
|
11365
|
+
const first = await comparePage(cwd, repo, range, 1);
|
|
11365
11366
|
const last = Math.ceil(first.total_commits / PAGE_SIZE);
|
|
11366
11367
|
if (last <= 1) return first.commits;
|
|
11367
11368
|
const pages = Array.from(
|
|
@@ -11370,7 +11371,7 @@ async function newestCommits(cwd, repo, range2) {
|
|
|
11370
11371
|
).reverse();
|
|
11371
11372
|
const tail = await Promise.all(
|
|
11372
11373
|
pages.map(
|
|
11373
|
-
(page) => page === 1 ? first : comparePage(cwd, repo,
|
|
11374
|
+
(page) => page === 1 ? first : comparePage(cwd, repo, range, page)
|
|
11374
11375
|
)
|
|
11375
11376
|
);
|
|
11376
11377
|
return tail.flatMap((page) => page.commits);
|
|
@@ -15237,6 +15238,7 @@ function buildRunEntry(name, command, args, options2) {
|
|
|
15237
15238
|
if (options2?.server !== void 0) entry.server = options2.server;
|
|
15238
15239
|
if (options2?.port !== void 0) entry.port = options2.port;
|
|
15239
15240
|
if (options2?.protocol) entry.protocol = options2.protocol;
|
|
15241
|
+
if (options2?.path) entry.path = options2.path;
|
|
15240
15242
|
if (options2?.env) entry.env = options2.env;
|
|
15241
15243
|
if (options2?.pre) entry.pre = options2.pre;
|
|
15242
15244
|
if (options2?.filter) entry.filter = options2.filter;
|
|
@@ -15252,8 +15254,8 @@ function setupVerifyRunEntry(scriptName, command, options2) {
|
|
|
15252
15254
|
if (!config.run) config.run = [];
|
|
15253
15255
|
const runList = config.run;
|
|
15254
15256
|
if (runList.find((r) => r.name === scriptName)) return;
|
|
15255
|
-
const
|
|
15256
|
-
const needsNpx = !GLOBAL_COMMANDS.has(
|
|
15257
|
+
const parts2 = command.split(/\s+/);
|
|
15258
|
+
const needsNpx = !GLOBAL_COMMANDS.has(parts2[0]);
|
|
15257
15259
|
const fullCommand = needsNpx ? `npx ${command}` : command;
|
|
15258
15260
|
const entry = buildRunEntry(
|
|
15259
15261
|
scriptName,
|
|
@@ -17971,28 +17973,28 @@ function findBlockRange(lines) {
|
|
|
17971
17973
|
function upsertScheduleBlock(crontab, every, cronLine) {
|
|
17972
17974
|
const lines = crontab.length === 0 ? [] : crontab.replace(/\n$/, "").split("\n");
|
|
17973
17975
|
const block = buildBlock(every, cronLine);
|
|
17974
|
-
const
|
|
17975
|
-
const next3 =
|
|
17976
|
-
...lines.slice(0,
|
|
17976
|
+
const range = findBlockRange(lines);
|
|
17977
|
+
const next3 = range === void 0 ? [...lines, ...block] : [
|
|
17978
|
+
...lines.slice(0, range.start),
|
|
17977
17979
|
...block,
|
|
17978
|
-
...lines.slice(
|
|
17980
|
+
...lines.slice(range.end + 1)
|
|
17979
17981
|
];
|
|
17980
17982
|
return `${next3.join("\n")}
|
|
17981
17983
|
`;
|
|
17982
17984
|
}
|
|
17983
17985
|
function removeScheduleBlock(crontab) {
|
|
17984
17986
|
const lines = crontab.length === 0 ? [] : crontab.replace(/\n$/, "").split("\n");
|
|
17985
|
-
const
|
|
17986
|
-
if (
|
|
17987
|
-
const next3 = [...lines.slice(0,
|
|
17987
|
+
const range = findBlockRange(lines);
|
|
17988
|
+
if (range === void 0) return crontab;
|
|
17989
|
+
const next3 = [...lines.slice(0, range.start), ...lines.slice(range.end + 1)];
|
|
17988
17990
|
return next3.length === 0 ? "" : `${next3.join("\n")}
|
|
17989
17991
|
`;
|
|
17990
17992
|
}
|
|
17991
17993
|
function readScheduleBlock(crontab) {
|
|
17992
17994
|
const lines = crontab.length === 0 ? [] : crontab.split("\n");
|
|
17993
|
-
const
|
|
17994
|
-
if (
|
|
17995
|
-
const body = lines.slice(
|
|
17995
|
+
const range = findBlockRange(lines);
|
|
17996
|
+
if (range === void 0) return void 0;
|
|
17997
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
17996
17998
|
const everyLine = body.find((line) => line.startsWith("# every "));
|
|
17997
17999
|
const cronLine = body.find(
|
|
17998
18000
|
(line) => !line.startsWith("#") && line.trim() !== ""
|
|
@@ -18071,15 +18073,15 @@ async function buildDump(tables, copyOut) {
|
|
|
18071
18073
|
version: DUMP_VERSION,
|
|
18072
18074
|
tables: tables.map(({ name, columns }) => ({ name, columns }))
|
|
18073
18075
|
});
|
|
18074
|
-
const
|
|
18076
|
+
const parts2 = [Buffer.from(`${header}
|
|
18075
18077
|
`, "utf8")];
|
|
18076
18078
|
for (const table of tables) {
|
|
18077
18079
|
const data = await copyOut(table);
|
|
18078
|
-
|
|
18080
|
+
parts2.push(Buffer.from(`@table ${table.name} ${data.length}
|
|
18079
18081
|
`, "utf8"));
|
|
18080
|
-
|
|
18082
|
+
parts2.push(data);
|
|
18081
18083
|
}
|
|
18082
|
-
return Buffer.concat(
|
|
18084
|
+
return Buffer.concat(parts2);
|
|
18083
18085
|
}
|
|
18084
18086
|
|
|
18085
18087
|
// src/commands/backlog/dump/copyTableOut.ts
|
|
@@ -18244,12 +18246,12 @@ function parseChartSeries(lines) {
|
|
|
18244
18246
|
for (const line of lines) {
|
|
18245
18247
|
const trimmed = line.trim();
|
|
18246
18248
|
if (trimmed === "") continue;
|
|
18247
|
-
const
|
|
18248
|
-
if (
|
|
18249
|
+
const parts2 = trimmed.split(/[,\t ]+/).filter((part) => part !== "");
|
|
18250
|
+
if (parts2.length < 2) {
|
|
18249
18251
|
throw new Error(`Expected a label and a value, got: ${trimmed}`);
|
|
18250
18252
|
}
|
|
18251
|
-
const label =
|
|
18252
|
-
const raw =
|
|
18253
|
+
const label = parts2.slice(0, -1).join(" ");
|
|
18254
|
+
const raw = parts2[parts2.length - 1];
|
|
18253
18255
|
const value = Number(raw);
|
|
18254
18256
|
if (!Number.isFinite(value)) {
|
|
18255
18257
|
throw new Error(`Value "${raw}" is not numeric, on line: ${trimmed}`);
|
|
@@ -19212,17 +19214,17 @@ import { randomUUID as randomUUID8 } from "crypto";
|
|
|
19212
19214
|
|
|
19213
19215
|
// src/commands/backlog/renderPhaseSection.ts
|
|
19214
19216
|
function renderPhaseSection(phase, idx) {
|
|
19215
|
-
const
|
|
19217
|
+
const parts2 = [
|
|
19216
19218
|
`### Phase ${idx + 1}: ${phase.name}`,
|
|
19217
19219
|
phase.tasks.map((task) => `- ${task}`).join("\n")
|
|
19218
19220
|
];
|
|
19219
19221
|
const manualChecks = phase.manualChecks ?? [];
|
|
19220
19222
|
if (manualChecks.length > 0)
|
|
19221
|
-
|
|
19223
|
+
parts2.push(
|
|
19222
19224
|
"**Manual checks:**",
|
|
19223
19225
|
manualChecks.map((check2) => `- ${check2}`).join("\n")
|
|
19224
19226
|
);
|
|
19225
|
-
return
|
|
19227
|
+
return parts2.join("\n\n");
|
|
19226
19228
|
}
|
|
19227
19229
|
|
|
19228
19230
|
// src/commands/backlog/addPhase/reviewProposedPhase.ts
|
|
@@ -23524,9 +23526,9 @@ function splitCompound(command) {
|
|
|
23524
23526
|
if (!tokens) return UNPARSEABLE2;
|
|
23525
23527
|
const grouped = groupByOperator(tokens);
|
|
23526
23528
|
if (!grouped.ok) return grouped;
|
|
23527
|
-
const
|
|
23528
|
-
if (
|
|
23529
|
-
return { ok: true, parts };
|
|
23529
|
+
const parts2 = grouped.groups.map((g) => stripEnvPrefix(g.filter((word) => word !== "")).join(" ")).filter((cmd) => cmd !== "");
|
|
23530
|
+
if (parts2.length === 0) return UNPARSEABLE2;
|
|
23531
|
+
return { ok: true, parts: parts2 };
|
|
23530
23532
|
}
|
|
23531
23533
|
function tokenizeCommand(command) {
|
|
23532
23534
|
const trimmed = separateCommandLines(stripHeredocBodies(command.trim())).replace(FD_DEVNULL_RE, "").replace(FD_REDIRECT_RE, "");
|
|
@@ -23538,10 +23540,10 @@ function tokenizeCommand(command) {
|
|
|
23538
23540
|
return void 0;
|
|
23539
23541
|
}
|
|
23540
23542
|
}
|
|
23541
|
-
function stripEnvPrefix(
|
|
23543
|
+
function stripEnvPrefix(parts2) {
|
|
23542
23544
|
let i = 0;
|
|
23543
|
-
while (i <
|
|
23544
|
-
return i > 0 ?
|
|
23545
|
+
while (i < parts2.length && /^[A-Za-z_]\w*=/.test(parts2[i])) i++;
|
|
23546
|
+
return i > 0 ? parts2.slice(i) : parts2;
|
|
23545
23547
|
}
|
|
23546
23548
|
|
|
23547
23549
|
// src/commands/cliHook/isGhGraphqlIssueMutation.ts
|
|
@@ -23681,8 +23683,8 @@ function toDecision(rule) {
|
|
|
23681
23683
|
permissionDecisionReason: rule.message
|
|
23682
23684
|
};
|
|
23683
23685
|
}
|
|
23684
|
-
function findBuiltinDeny(
|
|
23685
|
-
for (const part of
|
|
23686
|
+
function findBuiltinDeny(parts2) {
|
|
23687
|
+
for (const part of parts2) {
|
|
23686
23688
|
const decision = toDecision(matchBuiltinDeny(part));
|
|
23687
23689
|
if (decision) return decision;
|
|
23688
23690
|
}
|
|
@@ -23712,8 +23714,8 @@ function findRestrictedPathDenyRaw(rawCommand) {
|
|
|
23712
23714
|
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.`
|
|
23713
23715
|
};
|
|
23714
23716
|
}
|
|
23715
|
-
function findRestrictedPathDeny(
|
|
23716
|
-
for (const part of
|
|
23717
|
+
function findRestrictedPathDeny(parts2) {
|
|
23718
|
+
for (const part of parts2) {
|
|
23717
23719
|
const decision = findRestrictedPathDenyRaw(part);
|
|
23718
23720
|
if (decision) return decision;
|
|
23719
23721
|
}
|
|
@@ -23796,12 +23798,12 @@ function gatedDecision(gated) {
|
|
|
23796
23798
|
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.`
|
|
23797
23799
|
};
|
|
23798
23800
|
}
|
|
23799
|
-
function findTruncatedReadDeny(
|
|
23800
|
-
const read4 =
|
|
23801
|
-
if (read4 &&
|
|
23801
|
+
function findTruncatedReadDeny(parts2) {
|
|
23802
|
+
const read4 = parts2.map(matchUntruncatableRead).find(Boolean);
|
|
23803
|
+
if (read4 && parts2.some((part) => startsWithFilter(part, read4.filters)))
|
|
23802
23804
|
return readDecision(read4);
|
|
23803
|
-
const gated =
|
|
23804
|
-
if (gated &&
|
|
23805
|
+
const gated = parts2.map(matchApprovalGatedCommand).find(Boolean);
|
|
23806
|
+
if (gated && parts2.some((part) => startsWithFilter(part, TRUNCATOR_BINARIES)))
|
|
23805
23807
|
return gatedDecision(gated);
|
|
23806
23808
|
return void 0;
|
|
23807
23809
|
}
|
|
@@ -24182,16 +24184,16 @@ function isApprovedRead(command, toolName = "Bash") {
|
|
|
24182
24184
|
return void 0;
|
|
24183
24185
|
}
|
|
24184
24186
|
function isCdToCwd(command) {
|
|
24185
|
-
const
|
|
24186
|
-
if (
|
|
24187
|
-
if (
|
|
24188
|
-
const resolved = resolve19(normalizeMsysPath(
|
|
24187
|
+
const parts2 = command.split(/\s+/);
|
|
24188
|
+
if (parts2[0] !== "cd" || parts2.length > 2) return false;
|
|
24189
|
+
if (parts2.length === 1) return false;
|
|
24190
|
+
const resolved = resolve19(normalizeMsysPath(parts2[1]));
|
|
24189
24191
|
return resolved === resolve19(process.cwd());
|
|
24190
24192
|
}
|
|
24191
24193
|
function isCdToReadAllowedDir(command) {
|
|
24192
|
-
const
|
|
24193
|
-
if (
|
|
24194
|
-
const target = resolve19(normalizeMsysPath(
|
|
24194
|
+
const parts2 = command.split(/\s+/);
|
|
24195
|
+
if (parts2[0] !== "cd" || parts2.length !== 2) return void 0;
|
|
24196
|
+
const target = resolve19(normalizeMsysPath(parts2[1]));
|
|
24195
24197
|
for (const entry of readSettingsPerms("allow")) {
|
|
24196
24198
|
const m = entry.match(READ_RE);
|
|
24197
24199
|
if (!m) continue;
|
|
@@ -24229,9 +24231,9 @@ var SUBCOMMAND_READS = [
|
|
|
24229
24231
|
subcommands: ["maintainability", "cyclomatic", "halstead"]
|
|
24230
24232
|
}
|
|
24231
24233
|
];
|
|
24232
|
-
function findSubcommandAdvice(
|
|
24233
|
-
if (
|
|
24234
|
-
for (const part of
|
|
24234
|
+
function findSubcommandAdvice(parts2) {
|
|
24235
|
+
if (parts2.length <= 1) return void 0;
|
|
24236
|
+
for (const part of parts2) {
|
|
24235
24237
|
const rule = matchesSubcommandRead(part);
|
|
24236
24238
|
if (rule) {
|
|
24237
24239
|
return {
|
|
@@ -24249,14 +24251,14 @@ function matchesSubcommandRead(part) {
|
|
|
24249
24251
|
}
|
|
24250
24252
|
|
|
24251
24253
|
// src/commands/cliHook/resolvePermission.ts
|
|
24252
|
-
function findDeny(toolName,
|
|
24253
|
-
const restrictedPathDeny = findRestrictedPathDeny(
|
|
24254
|
+
function findDeny(toolName, parts2) {
|
|
24255
|
+
const restrictedPathDeny = findRestrictedPathDeny(parts2);
|
|
24254
24256
|
if (restrictedPathDeny) return restrictedPathDeny;
|
|
24255
|
-
const builtinDeny = findBuiltinDeny(
|
|
24257
|
+
const builtinDeny = findBuiltinDeny(parts2);
|
|
24256
24258
|
if (builtinDeny) return builtinDeny;
|
|
24257
|
-
const truncatedRead = findTruncatedReadDeny(
|
|
24259
|
+
const truncatedRead = findTruncatedReadDeny(parts2);
|
|
24258
24260
|
if (truncatedRead) return truncatedRead;
|
|
24259
|
-
for (const part of
|
|
24261
|
+
for (const part of parts2) {
|
|
24260
24262
|
const configDeny = matchesConfigDeny(part);
|
|
24261
24263
|
if (configDeny) {
|
|
24262
24264
|
return {
|
|
@@ -24265,9 +24267,9 @@ function findDeny(toolName, parts) {
|
|
|
24265
24267
|
};
|
|
24266
24268
|
}
|
|
24267
24269
|
}
|
|
24268
|
-
const subcommandAdvice = findSubcommandAdvice(
|
|
24270
|
+
const subcommandAdvice = findSubcommandAdvice(parts2);
|
|
24269
24271
|
if (subcommandAdvice) return subcommandAdvice;
|
|
24270
|
-
for (const part of
|
|
24272
|
+
for (const part of parts2) {
|
|
24271
24273
|
const denied = matchesDeny(toolName, part);
|
|
24272
24274
|
if (denied) {
|
|
24273
24275
|
return {
|
|
@@ -24278,11 +24280,11 @@ function findDeny(toolName, parts) {
|
|
|
24278
24280
|
}
|
|
24279
24281
|
return void 0;
|
|
24280
24282
|
}
|
|
24281
|
-
function resolvePermission(toolName,
|
|
24282
|
-
const denied = findDeny(toolName,
|
|
24283
|
+
function resolvePermission(toolName, parts2) {
|
|
24284
|
+
const denied = findDeny(toolName, parts2);
|
|
24283
24285
|
if (denied) return denied;
|
|
24284
24286
|
const reasons = [];
|
|
24285
|
-
for (const part of
|
|
24287
|
+
for (const part of parts2) {
|
|
24286
24288
|
const reason4 = isApprovedRead(part, toolName);
|
|
24287
24289
|
if (!reason4) return void 0;
|
|
24288
24290
|
reasons.push(reason4);
|
|
@@ -24348,8 +24350,8 @@ function mentionsDocsPath(command, root2 = getProjectRoot()) {
|
|
|
24348
24350
|
// src/commands/cliHook/findDocsPathDeny.ts
|
|
24349
24351
|
function findDocsPathDeny(toolName, rawCommand, root2) {
|
|
24350
24352
|
const result = splitCompound(rawCommand);
|
|
24351
|
-
const
|
|
24352
|
-
const writes =
|
|
24353
|
+
const parts2 = result.ok ? result.parts : [rawCommand];
|
|
24354
|
+
const writes = parts2.some(
|
|
24353
24355
|
(part) => mentionsDocsPath(part, root2) && !isApprovedRead(part, toolName)
|
|
24354
24356
|
);
|
|
24355
24357
|
if (!writes) return void 0;
|
|
@@ -24610,8 +24612,8 @@ function reportDecision(decision) {
|
|
|
24610
24612
|
process.exitCode = 1;
|
|
24611
24613
|
return true;
|
|
24612
24614
|
}
|
|
24613
|
-
function reportDeny(toolName,
|
|
24614
|
-
return reportDecision(findDeny(toolName,
|
|
24615
|
+
function reportDeny(toolName, parts2) {
|
|
24616
|
+
return reportDecision(findDeny(toolName, parts2));
|
|
24615
24617
|
}
|
|
24616
24618
|
function cliHookCheck(command, toolName = "Bash") {
|
|
24617
24619
|
const trimmed = command.trim();
|
|
@@ -24625,10 +24627,10 @@ function cliHookCheck(command, toolName = "Bash") {
|
|
|
24625
24627
|
process.exitCode = 1;
|
|
24626
24628
|
return;
|
|
24627
24629
|
}
|
|
24628
|
-
const
|
|
24629
|
-
if (reportDeny(toolName,
|
|
24630
|
+
const parts2 = result.parts;
|
|
24631
|
+
if (reportDeny(toolName, parts2)) return;
|
|
24630
24632
|
const reasons = [];
|
|
24631
|
-
for (const part of
|
|
24633
|
+
for (const part of parts2) {
|
|
24632
24634
|
const reason4 = isApprovedRead(part, toolName);
|
|
24633
24635
|
if (!reason4) {
|
|
24634
24636
|
console.log(`not approved (unrecognised: ${part})`);
|
|
@@ -24931,9 +24933,9 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
24931
24933
|
);
|
|
24932
24934
|
process.exit(1);
|
|
24933
24935
|
}
|
|
24934
|
-
const
|
|
24935
|
-
const binary =
|
|
24936
|
-
const prefixPath =
|
|
24936
|
+
const parts2 = cli.split(/\s+/);
|
|
24937
|
+
const binary = parts2[0];
|
|
24938
|
+
const prefixPath = parts2.slice(1);
|
|
24937
24939
|
if (!options2.noCache) {
|
|
24938
24940
|
const cached2 = readCache(cli);
|
|
24939
24941
|
if (cached2) {
|
|
@@ -28112,7 +28114,7 @@ function parseNameOnlyLog(output, ignore3, afterDate) {
|
|
|
28112
28114
|
return byDate;
|
|
28113
28115
|
}
|
|
28114
28116
|
function fetchCommitsAfter(ignore3, afterDate) {
|
|
28115
|
-
const
|
|
28117
|
+
const range = afterDate ? [`--since=${afterDate}T00:00:00`] : [];
|
|
28116
28118
|
const output = execFileSync7(
|
|
28117
28119
|
"git",
|
|
28118
28120
|
[
|
|
@@ -28120,7 +28122,7 @@ function fetchCommitsAfter(ignore3, afterDate) {
|
|
|
28120
28122
|
"--name-only",
|
|
28121
28123
|
`--pretty=format:${RECORD_SEPARATOR}%ad|%h|%s`,
|
|
28122
28124
|
"--date=short",
|
|
28123
|
-
...
|
|
28125
|
+
...range
|
|
28124
28126
|
],
|
|
28125
28127
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024 }
|
|
28126
28128
|
);
|
|
@@ -28675,20 +28677,56 @@ function readDevEntryFile(path110) {
|
|
|
28675
28677
|
return { ...frontmatter2, lede: match[2].trim() };
|
|
28676
28678
|
}
|
|
28677
28679
|
|
|
28680
|
+
// src/commands/devlog/slack/formatDateRange.ts
|
|
28681
|
+
var MONTHS = [
|
|
28682
|
+
"Jan",
|
|
28683
|
+
"Feb",
|
|
28684
|
+
"Mar",
|
|
28685
|
+
"Apr",
|
|
28686
|
+
"May",
|
|
28687
|
+
"Jun",
|
|
28688
|
+
"Jul",
|
|
28689
|
+
"Aug",
|
|
28690
|
+
"Sep",
|
|
28691
|
+
"Oct",
|
|
28692
|
+
"Nov",
|
|
28693
|
+
"Dec"
|
|
28694
|
+
];
|
|
28695
|
+
function parts(date) {
|
|
28696
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
28697
|
+
return { year, month: MONTHS[month - 1], day };
|
|
28698
|
+
}
|
|
28699
|
+
function formatDateRange(first, last) {
|
|
28700
|
+
const a = parts(first);
|
|
28701
|
+
const b = parts(last);
|
|
28702
|
+
if (first === last) return `${a.day} ${a.month} ${a.year}`;
|
|
28703
|
+
if (a.year !== b.year)
|
|
28704
|
+
return `${a.day} ${a.month} ${a.year} \u2013 ${b.day} ${b.month} ${b.year}`;
|
|
28705
|
+
if (a.month !== b.month)
|
|
28706
|
+
return `${a.day} ${a.month} \u2013 ${b.day} ${b.month} ${b.year}`;
|
|
28707
|
+
return `${a.day}\u2013${b.day} ${b.month} ${b.year}`;
|
|
28708
|
+
}
|
|
28709
|
+
|
|
28678
28710
|
// src/commands/devlog/slack/renderDevlogSlackParts.ts
|
|
28679
28711
|
var SECTIONS = [
|
|
28680
28712
|
["added", "Added"],
|
|
28681
28713
|
["changed", "Changed"],
|
|
28682
28714
|
["fixed", "Fixed"]
|
|
28683
28715
|
];
|
|
28684
|
-
function
|
|
28685
|
-
if (!
|
|
28686
|
-
return
|
|
28716
|
+
function versionRange2(versions) {
|
|
28717
|
+
if (!versions?.first || !versions.last) return null;
|
|
28718
|
+
return versions.first === versions.last ? versions.first : `${versions.first} \u2192 ${versions.last}`;
|
|
28719
|
+
}
|
|
28720
|
+
function dateRange(entry, week) {
|
|
28721
|
+
const { first, last } = entry.dates ?? {};
|
|
28722
|
+
if (first && last) return formatDateRange(first, last);
|
|
28723
|
+
const { start: start2, end } = isoWeekRange(week);
|
|
28724
|
+
return formatDateRange(start2, end);
|
|
28687
28725
|
}
|
|
28688
28726
|
function renderHeader(entry, project, week) {
|
|
28689
|
-
const
|
|
28690
|
-
const
|
|
28691
|
-
return
|
|
28727
|
+
const head = `**${project} \xB7 ${dateRange(entry, week)}**`;
|
|
28728
|
+
const versions = versionRange2(entry.versions);
|
|
28729
|
+
return versions ? `${head} \xB7 ${versions}` : head;
|
|
28692
28730
|
}
|
|
28693
28731
|
function renderCounts(entry) {
|
|
28694
28732
|
const counts2 = SECTIONS.map(
|
|
@@ -28740,9 +28778,9 @@ function fail8(message3) {
|
|
|
28740
28778
|
console.error(chalk166.red(message3));
|
|
28741
28779
|
process.exit(1);
|
|
28742
28780
|
}
|
|
28743
|
-
function writeParts(channel,
|
|
28781
|
+
function writeParts(channel, parts2) {
|
|
28744
28782
|
mkdirSync22(slackWorkingFile(channel).dir, { recursive: true });
|
|
28745
|
-
return
|
|
28783
|
+
return parts2.map((part, index3) => {
|
|
28746
28784
|
const { bodyPath } = slackWorkingFile(channel, index3 + 1);
|
|
28747
28785
|
writeFileSync34(bodyPath, `${part}
|
|
28748
28786
|
`);
|
|
@@ -28771,17 +28809,17 @@ async function slack2(week) {
|
|
|
28771
28809
|
const entry = readDevEntryFile(path110);
|
|
28772
28810
|
if (!entry) fail8(`No dev entry for ${week} at ${path110}`);
|
|
28773
28811
|
if (entry.slack) fail8(`${week} is already posted: slack: ${entry.slack}`);
|
|
28774
|
-
const
|
|
28812
|
+
const parts2 = renderDevlogSlackParts(
|
|
28775
28813
|
entry,
|
|
28776
28814
|
entry.project ?? repoName,
|
|
28777
28815
|
week,
|
|
28778
28816
|
loadConfig().devlog?.url?.trim() || void 0
|
|
28779
28817
|
);
|
|
28780
|
-
if (
|
|
28781
|
-
await postSlackMessage(channel, { body:
|
|
28818
|
+
if (parts2.length === 1) {
|
|
28819
|
+
await postSlackMessage(channel, { body: parts2[0] });
|
|
28782
28820
|
return;
|
|
28783
28821
|
}
|
|
28784
|
-
await postSlackMessage(channel, { parts: writeParts(channel,
|
|
28822
|
+
await postSlackMessage(channel, { parts: writeParts(channel, parts2) });
|
|
28785
28823
|
}
|
|
28786
28824
|
|
|
28787
28825
|
// src/commands/devlog/write.ts
|
|
@@ -35265,7 +35303,7 @@ function linkifyMentions(text20, mentions) {
|
|
|
35265
35303
|
|
|
35266
35304
|
// src/commands/netcap/buildPost.ts
|
|
35267
35305
|
var profileUrl = (slug2) => `https://www.linkedin.com/in/${slug2}/`;
|
|
35268
|
-
var joinText = (
|
|
35306
|
+
var joinText = (parts2) => parts2.join(" ").replace(/\s+/g, " ").replace(/\s+([.,!?])/g, "$1").trim();
|
|
35269
35307
|
function resolveMentions(raw, mentionMap, author) {
|
|
35270
35308
|
const slugs = /* @__PURE__ */ new Set();
|
|
35271
35309
|
for (const url of raw.profileUrls) {
|
|
@@ -35937,13 +35975,13 @@ async function comment2(path110, line, body, options2 = {}) {
|
|
|
35937
35975
|
validateBody(body);
|
|
35938
35976
|
validateLine(line);
|
|
35939
35977
|
if (startLine !== void 0) validateLine(startLine);
|
|
35940
|
-
const
|
|
35978
|
+
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
35941
35979
|
if (!skipPreview)
|
|
35942
|
-
await reviewProposedPrComment(`Comment on ${path110}:${
|
|
35980
|
+
await reviewProposedPrComment(`Comment on ${path110}:${range}`, body, null);
|
|
35943
35981
|
try {
|
|
35944
35982
|
const prId = getCurrentPrNodeId();
|
|
35945
35983
|
postReviewComment({ prId, body, path: path110, line, startLine });
|
|
35946
|
-
console.log(`Added review comment on ${path110}:${
|
|
35984
|
+
console.log(`Added review comment on ${path110}:${range}`);
|
|
35947
35985
|
} catch (error) {
|
|
35948
35986
|
if (isGhNotInstalled(error)) {
|
|
35949
35987
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -36824,7 +36862,7 @@ Resolves ${refs}`;
|
|
|
36824
36862
|
return why;
|
|
36825
36863
|
}
|
|
36826
36864
|
function buildPrBody(sections) {
|
|
36827
|
-
const
|
|
36865
|
+
const parts2 = [
|
|
36828
36866
|
`## What
|
|
36829
36867
|
|
|
36830
36868
|
${sections.what}`,
|
|
@@ -36833,11 +36871,11 @@ ${sections.what}`,
|
|
|
36833
36871
|
${renderWhy(sections.why, sections.resolves)}`
|
|
36834
36872
|
];
|
|
36835
36873
|
if (sections.how) {
|
|
36836
|
-
|
|
36874
|
+
parts2.push(`## How
|
|
36837
36875
|
|
|
36838
36876
|
${sections.how}`);
|
|
36839
36877
|
}
|
|
36840
|
-
return
|
|
36878
|
+
return parts2.join("\n\n");
|
|
36841
36879
|
}
|
|
36842
36880
|
|
|
36843
36881
|
// src/commands/prs/parsePrBody.ts
|
|
@@ -40399,15 +40437,15 @@ function analyseTarget(sourceFile, functionName) {
|
|
|
40399
40437
|
|
|
40400
40438
|
// src/commands/refactor/extract/formatImportLine.ts
|
|
40401
40439
|
function formatImportLine(imp) {
|
|
40402
|
-
const
|
|
40403
|
-
if (imp.isTypeOnly)
|
|
40404
|
-
if (imp.defaultImport)
|
|
40405
|
-
if (imp.namespaceImport)
|
|
40440
|
+
const parts2 = [];
|
|
40441
|
+
if (imp.isTypeOnly) parts2.push("type ");
|
|
40442
|
+
if (imp.defaultImport) parts2.push(imp.defaultImport);
|
|
40443
|
+
if (imp.namespaceImport) parts2.push(`* as ${imp.namespaceImport}`);
|
|
40406
40444
|
if (imp.namedImports.length > 0) {
|
|
40407
|
-
if (imp.defaultImport)
|
|
40408
|
-
|
|
40445
|
+
if (imp.defaultImport) parts2.push(", ");
|
|
40446
|
+
parts2.push(`{ ${imp.namedImports.join(", ")} }`);
|
|
40409
40447
|
}
|
|
40410
|
-
return `import ${
|
|
40448
|
+
return `import ${parts2.join("")} from "${imp.moduleSpecifier}";`;
|
|
40411
40449
|
}
|
|
40412
40450
|
|
|
40413
40451
|
// src/commands/refactor/extract/buildDestinationContent.ts
|
|
@@ -41298,9 +41336,9 @@ import path71 from "path";
|
|
|
41298
41336
|
function lowestCommonAncestor(dirs) {
|
|
41299
41337
|
const [first, ...rest] = dirs.map((d) => d.split(path71.sep));
|
|
41300
41338
|
let common = first;
|
|
41301
|
-
for (const
|
|
41339
|
+
for (const parts2 of rest) {
|
|
41302
41340
|
let i = 0;
|
|
41303
|
-
while (i < common.length && i <
|
|
41341
|
+
while (i < common.length && i < parts2.length && common[i] === parts2[i]) i++;
|
|
41304
41342
|
common = common.slice(0, i);
|
|
41305
41343
|
}
|
|
41306
41344
|
return common.join(path71.sep) || path71.sep;
|
|
@@ -41747,9 +41785,9 @@ function computeDepthStats(targets, scopeRoot) {
|
|
|
41747
41785
|
|
|
41748
41786
|
// src/commands/refactor/restructure/formatTree.ts
|
|
41749
41787
|
import path83 from "path";
|
|
41750
|
-
function insert(root2,
|
|
41788
|
+
function insert(root2, parts2) {
|
|
41751
41789
|
let node = root2;
|
|
41752
|
-
for (const part of
|
|
41790
|
+
for (const part of parts2) {
|
|
41753
41791
|
const child = node.get(part) ?? /* @__PURE__ */ new Map();
|
|
41754
41792
|
node.set(part, child);
|
|
41755
41793
|
node = child;
|
|
@@ -45678,10 +45716,10 @@ function warnOutOfDiff(outOfDiff) {
|
|
|
45678
45716
|
)
|
|
45679
45717
|
);
|
|
45680
45718
|
for (const finding of outOfDiff) {
|
|
45681
|
-
const
|
|
45719
|
+
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
45682
45720
|
console.warn(
|
|
45683
45721
|
` ${chalk264.yellow("\xB7")} ${finding.title} ${chalk264.dim(
|
|
45684
|
-
`(${finding.file}:${
|
|
45722
|
+
`(${finding.file}:${range})`
|
|
45685
45723
|
)}`
|
|
45686
45724
|
);
|
|
45687
45725
|
}
|
|
@@ -45773,10 +45811,10 @@ function stillOnReviewedPr(prNumber) {
|
|
|
45773
45811
|
|
|
45774
45812
|
// src/commands/review/describeWork.ts
|
|
45775
45813
|
function describeWork(comments3, carried) {
|
|
45776
|
-
const
|
|
45777
|
-
if (comments3 > 0)
|
|
45778
|
-
if (carried > 0)
|
|
45779
|
-
return
|
|
45814
|
+
const parts2 = [];
|
|
45815
|
+
if (comments3 > 0) parts2.push(`${comments3} line comment(s)`);
|
|
45816
|
+
if (carried > 0) parts2.push(`${carried} finding(s) in the review body`);
|
|
45817
|
+
return parts2.join(" and ");
|
|
45780
45818
|
}
|
|
45781
45819
|
|
|
45782
45820
|
// src/commands/review/postReviewToPr.ts
|
|
@@ -46175,9 +46213,9 @@ function pointerLine(directories) {
|
|
|
46175
46213
|
}
|
|
46176
46214
|
function upsertScopedRulesPointer(content, directories) {
|
|
46177
46215
|
const lines = contentLines(content);
|
|
46178
|
-
const
|
|
46216
|
+
const range = rulesSectionRange(lines);
|
|
46179
46217
|
const existing = lines.findIndex(
|
|
46180
|
-
(line, index3) =>
|
|
46218
|
+
(line, index3) => range !== void 0 && index3 > range.start && index3 < range.end && line.startsWith(POINTER_PREFIX)
|
|
46181
46219
|
);
|
|
46182
46220
|
if (directories.length === 0) {
|
|
46183
46221
|
if (existing === -1) return content;
|
|
@@ -46193,9 +46231,9 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
46193
46231
|
return `${replaced.join("\n")}
|
|
46194
46232
|
`;
|
|
46195
46233
|
}
|
|
46196
|
-
if (!
|
|
46197
|
-
let at2 =
|
|
46198
|
-
while (at2 >
|
|
46234
|
+
if (!range) return appendRulesSection(lines, pointer);
|
|
46235
|
+
let at2 = range.end;
|
|
46236
|
+
while (at2 > range.start + 1 && (lines[at2 - 1] ?? "").trim() === "") at2--;
|
|
46199
46237
|
return `${[...lines.slice(0, at2), "", pointer, ...lines.slice(at2)].join("\n")}
|
|
46200
46238
|
`;
|
|
46201
46239
|
}
|
|
@@ -46268,14 +46306,14 @@ function ruleBullet({ code, title, text: text20 }) {
|
|
|
46268
46306
|
function insertRuleBullet(content, rule) {
|
|
46269
46307
|
const bullet = ruleBullet(rule);
|
|
46270
46308
|
const lines = contentLines(content);
|
|
46271
|
-
const
|
|
46272
|
-
if (!
|
|
46273
|
-
const body = lines.slice(
|
|
46309
|
+
const range = rulesSectionRange(lines);
|
|
46310
|
+
if (!range) return appendRulesSection(lines, bullet);
|
|
46311
|
+
const body = lines.slice(range.start + 1, range.end);
|
|
46274
46312
|
const lastBullet = body.reduce(
|
|
46275
46313
|
(last, line, index3) => RULE_BULLET.test(line) ? index3 : last,
|
|
46276
46314
|
-1
|
|
46277
46315
|
);
|
|
46278
|
-
const at2 = lastBullet === -1 ?
|
|
46316
|
+
const at2 = lastBullet === -1 ? range.start + 1 : range.start + lastBullet + 2;
|
|
46279
46317
|
const inserted = lastBullet === -1 ? ["", bullet] : [bullet];
|
|
46280
46318
|
return `${[...lines.slice(0, at2), ...inserted, ...lines.slice(at2)].join("\n")}
|
|
46281
46319
|
`;
|
|
@@ -47119,9 +47157,9 @@ async function sqlColumns(table, connectionName) {
|
|
|
47119
47157
|
const conn = resolveConnection3(connectionName);
|
|
47120
47158
|
const pool = await sqlConnect(conn);
|
|
47121
47159
|
try {
|
|
47122
|
-
const
|
|
47123
|
-
const schema2 =
|
|
47124
|
-
const name =
|
|
47160
|
+
const parts2 = table.split(".");
|
|
47161
|
+
const schema2 = parts2.length > 1 ? parts2[0] : void 0;
|
|
47162
|
+
const name = parts2.length > 1 ? parts2[1] : parts2[0];
|
|
47125
47163
|
const request = pool.request().input("table", name);
|
|
47126
47164
|
let where = "TABLE_NAME = @table";
|
|
47127
47165
|
if (schema2) {
|
|
@@ -47889,9 +47927,9 @@ function parseHMS(h, m, s) {
|
|
|
47889
47927
|
function parseMS(m, s) {
|
|
47890
47928
|
return Number.parseInt(m, 10) * 60 + Number.parseFloat(s);
|
|
47891
47929
|
}
|
|
47892
|
-
function toSeconds(
|
|
47893
|
-
if (
|
|
47894
|
-
if (
|
|
47930
|
+
function toSeconds(parts2) {
|
|
47931
|
+
if (parts2.length === 3) return parseHMS(parts2[0], parts2[1], parts2[2]);
|
|
47932
|
+
if (parts2.length === 2) return parseMS(parts2[0], parts2[1]);
|
|
47895
47933
|
return 0;
|
|
47896
47934
|
}
|
|
47897
47935
|
function parseTimestamp(ts10) {
|
|
@@ -48215,24 +48253,24 @@ function lastEndMs(cues) {
|
|
|
48215
48253
|
|
|
48216
48254
|
// src/commands/transcript/selectPassages.ts
|
|
48217
48255
|
var CLOCK = /^(?:(\d{1,3}):)?(\d{1,2}):(\d{1,2})(?:\.(\d{1,3}))?$/;
|
|
48218
|
-
function describeRange(
|
|
48219
|
-
return `${
|
|
48256
|
+
function describeRange(range) {
|
|
48257
|
+
return `${range.from} --> ${range.to} in ${range.file}`;
|
|
48220
48258
|
}
|
|
48221
|
-
function parseClock(value,
|
|
48259
|
+
function parseClock(value, range) {
|
|
48222
48260
|
const match = value.match(CLOCK);
|
|
48223
48261
|
if (!match) {
|
|
48224
48262
|
failTranscript(
|
|
48225
|
-
`malformed timestamp "${value}" in selection range ${describeRange(
|
|
48263
|
+
`malformed timestamp "${value}" in selection range ${describeRange(range)}`
|
|
48226
48264
|
);
|
|
48227
48265
|
}
|
|
48228
48266
|
const [, hours, minutes, seconds, millis] = match;
|
|
48229
48267
|
return (Number(hours ?? 0) * 3600 + Number(minutes) * 60 + Number(seconds)) * 1e3 + Number((millis ?? "").padEnd(3, "0"));
|
|
48230
48268
|
}
|
|
48231
|
-
function findSource(sources,
|
|
48269
|
+
function findSource(sources, range) {
|
|
48232
48270
|
const match = sources.find(
|
|
48233
|
-
(source) => source.path ===
|
|
48271
|
+
(source) => source.path === range.file || source.name === range.file
|
|
48234
48272
|
);
|
|
48235
|
-
return match ?? failTranscript(`selection names a file that was not given: ${
|
|
48273
|
+
return match ?? failTranscript(`selection names a file that was not given: ${range.file}`);
|
|
48236
48274
|
}
|
|
48237
48275
|
function spanOf(source) {
|
|
48238
48276
|
return {
|
|
@@ -48240,24 +48278,24 @@ function spanOf(source) {
|
|
|
48240
48278
|
endMs: Math.max(...source.cues.map((cue) => cue.endMs))
|
|
48241
48279
|
};
|
|
48242
48280
|
}
|
|
48243
|
-
function boundsOf(source,
|
|
48244
|
-
const fromMs = parseClock(
|
|
48245
|
-
const toMs = parseClock(
|
|
48281
|
+
function boundsOf(source, range) {
|
|
48282
|
+
const fromMs = parseClock(range.from, range);
|
|
48283
|
+
const toMs = parseClock(range.to, range);
|
|
48246
48284
|
if (toMs < fromMs) {
|
|
48247
48285
|
failTranscript(
|
|
48248
|
-
`selection range ${describeRange(
|
|
48286
|
+
`selection range ${describeRange(range)} ends before it starts`
|
|
48249
48287
|
);
|
|
48250
48288
|
}
|
|
48251
48289
|
const span = spanOf(source);
|
|
48252
48290
|
if (fromMs > span.endMs || toMs < span.startMs) {
|
|
48253
48291
|
failTranscript(
|
|
48254
|
-
`selection range ${describeRange(
|
|
48292
|
+
`selection range ${describeRange(range)} lies outside that file's cues`
|
|
48255
48293
|
);
|
|
48256
48294
|
}
|
|
48257
48295
|
return { fromMs, toMs };
|
|
48258
48296
|
}
|
|
48259
|
-
function cuesInRange(source,
|
|
48260
|
-
const { fromMs, toMs } = boundsOf(source,
|
|
48297
|
+
function cuesInRange(source, range) {
|
|
48298
|
+
const { fromMs, toMs } = boundsOf(source, range);
|
|
48261
48299
|
return source.cues.filter(
|
|
48262
48300
|
(cue) => cue.startMs >= fromMs && cue.startMs <= toMs
|
|
48263
48301
|
);
|
|
@@ -48266,9 +48304,9 @@ function toPassage(source, cues) {
|
|
|
48266
48304
|
return { source: source.name, sourceStartMs: cues[0].startMs, cues };
|
|
48267
48305
|
}
|
|
48268
48306
|
function selectPassages(sources, selection) {
|
|
48269
|
-
const passages = selection.keep.flatMap((
|
|
48270
|
-
const source = findSource(sources,
|
|
48271
|
-
const cues = cuesInRange(source,
|
|
48307
|
+
const passages = selection.keep.flatMap((range) => {
|
|
48308
|
+
const source = findSource(sources, range);
|
|
48309
|
+
const cues = cuesInRange(source, range);
|
|
48272
48310
|
return cues.length ? [toPassage(source, cues)] : [];
|
|
48273
48311
|
});
|
|
48274
48312
|
if (passages.length === 0) {
|
|
@@ -48562,14 +48600,14 @@ function collectComments(sourceFile) {
|
|
|
48562
48600
|
const seen = /* @__PURE__ */ new Set();
|
|
48563
48601
|
const comments3 = [];
|
|
48564
48602
|
const collect8 = (node) => {
|
|
48565
|
-
for (const
|
|
48603
|
+
for (const range of [
|
|
48566
48604
|
...node.getLeadingCommentRanges(),
|
|
48567
48605
|
...node.getTrailingCommentRanges()
|
|
48568
48606
|
]) {
|
|
48569
|
-
const pos =
|
|
48607
|
+
const pos = range.getPos();
|
|
48570
48608
|
if (seen.has(pos)) continue;
|
|
48571
48609
|
seen.add(pos);
|
|
48572
|
-
comments3.push({ pos, text:
|
|
48610
|
+
comments3.push({ pos, text: range.getText() });
|
|
48573
48611
|
}
|
|
48574
48612
|
};
|
|
48575
48613
|
collect8(sourceFile);
|
|
@@ -50398,7 +50436,8 @@ function extractAddArgs(addIndex) {
|
|
|
50398
50436
|
const cwd = extractOption(filter.remaining, "--cwd");
|
|
50399
50437
|
const port = extractOption(cwd.remaining, "--port");
|
|
50400
50438
|
const protocol = extractOption(port.remaining, "--protocol");
|
|
50401
|
-
const
|
|
50439
|
+
const path110 = extractOption(protocol.remaining, "--path");
|
|
50440
|
+
const server = extractOptionalValueFlag(path110.remaining, "--server");
|
|
50402
50441
|
const repo = extractOptionalValueFlag(server.remaining, "--repo");
|
|
50403
50442
|
return {
|
|
50404
50443
|
name: process.argv[addIndex + 1],
|
|
@@ -50409,6 +50448,7 @@ function extractAddArgs(addIndex) {
|
|
|
50409
50448
|
server: server.value,
|
|
50410
50449
|
port: parsePort(port.value),
|
|
50411
50450
|
protocol: parseProtocol(protocol.value),
|
|
50451
|
+
path: path110.value,
|
|
50412
50452
|
env: parseEnvPairs(env.values),
|
|
50413
50453
|
pre: pre.values.length > 0 ? pre.values : void 0,
|
|
50414
50454
|
filter: filter.value,
|
|
@@ -50498,6 +50538,11 @@ var properties = [
|
|
|
50498
50538
|
"--protocol <http|https>",
|
|
50499
50539
|
"protocol of the serving card's port link (default: http)"
|
|
50500
50540
|
],
|
|
50541
|
+
[
|
|
50542
|
+
"path",
|
|
50543
|
+
"--path <path>",
|
|
50544
|
+
"path of the serving card's port link, e.g. /swagger (default: /)"
|
|
50545
|
+
],
|
|
50501
50546
|
[
|
|
50502
50547
|
"pre",
|
|
50503
50548
|
"--pre <command>",
|
|
@@ -50552,6 +50597,9 @@ function registerRunAdd(runCommand) {
|
|
|
50552
50597
|
).option("--port <port>", "Display-only port shown on the serving card").option(
|
|
50553
50598
|
"--protocol <http|https>",
|
|
50554
50599
|
"Protocol for the serving card's port link (default: http)"
|
|
50600
|
+
).option(
|
|
50601
|
+
"--path <path>",
|
|
50602
|
+
"Path for the serving card's port link, e.g. /swagger (default: /)"
|
|
50555
50603
|
).option(
|
|
50556
50604
|
"--env <KEY=VALUE>",
|
|
50557
50605
|
"Environment variable for the command (repeatable)"
|
|
@@ -51281,6 +51329,7 @@ function toSessionRunInfo({
|
|
|
51281
51329
|
server,
|
|
51282
51330
|
serverPort,
|
|
51283
51331
|
serverProtocol,
|
|
51332
|
+
serverPath,
|
|
51284
51333
|
serverOrigin,
|
|
51285
51334
|
assistArgs,
|
|
51286
51335
|
cwd,
|
|
@@ -51300,6 +51349,7 @@ function toSessionRunInfo({
|
|
|
51300
51349
|
server,
|
|
51301
51350
|
port: serverPort,
|
|
51302
51351
|
protocol: serverProtocol,
|
|
51352
|
+
urlPath: serverPath,
|
|
51303
51353
|
remoteOrigin: serverOrigin ?? originForCwd(cwd),
|
|
51304
51354
|
assistArgs,
|
|
51305
51355
|
activity: activity2,
|
|
@@ -52285,6 +52335,7 @@ function serverRunMeta(runName, cwd) {
|
|
|
52285
52335
|
group: typeof config.server === "string" ? config.server : DEFAULT_SERVER_GROUP,
|
|
52286
52336
|
port: config.port,
|
|
52287
52337
|
protocol: config.protocol,
|
|
52338
|
+
path: config.path,
|
|
52288
52339
|
origin: getCurrentOrigin(dir)
|
|
52289
52340
|
};
|
|
52290
52341
|
}
|
|
@@ -52363,6 +52414,7 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
|
52363
52414
|
server: serverMeta.server || void 0,
|
|
52364
52415
|
serverPort: serverMeta.port,
|
|
52365
52416
|
serverProtocol: serverMeta.protocol,
|
|
52417
|
+
serverPath: serverMeta.path,
|
|
52366
52418
|
serverOrigin: serverMeta.origin,
|
|
52367
52419
|
serverGroup: serverMeta.group
|
|
52368
52420
|
};
|
|
@@ -53354,16 +53406,16 @@ function describeOccupants(occupants) {
|
|
|
53354
53406
|
if (o.vscode) continue;
|
|
53355
53407
|
others.set(o.name, [...others.get(o.name) ?? [], o.pid]);
|
|
53356
53408
|
}
|
|
53357
|
-
const
|
|
53409
|
+
const parts2 = [];
|
|
53358
53410
|
if (vscode.length > 0)
|
|
53359
|
-
|
|
53411
|
+
parts2.push(`VS Code has this worktree open (${pidList(vscode)})`);
|
|
53360
53412
|
if (others.size > 0) {
|
|
53361
53413
|
const programs = [...others].map(
|
|
53362
53414
|
([name, pids]) => `${name} (${pidList(pids)})`
|
|
53363
53415
|
);
|
|
53364
|
-
|
|
53416
|
+
parts2.push(`a live process is still running in it: ${programs.join(", ")}`);
|
|
53365
53417
|
}
|
|
53366
|
-
return
|
|
53418
|
+
return parts2.join("; ");
|
|
53367
53419
|
}
|
|
53368
53420
|
function pidList(pids) {
|
|
53369
53421
|
return `pid ${[...pids].sort((a, b) => a - b).join(", ")}`;
|
|
@@ -54633,13 +54685,13 @@ function extractLastAssistantMessage(entries) {
|
|
|
54633
54685
|
function assistantText(entry) {
|
|
54634
54686
|
const content = asRecord4(entry.message)?.content;
|
|
54635
54687
|
if (!Array.isArray(content)) return "";
|
|
54636
|
-
const
|
|
54688
|
+
const parts2 = [];
|
|
54637
54689
|
for (const block of content) {
|
|
54638
54690
|
const b = asRecord4(block);
|
|
54639
54691
|
if (b?.type === "text" && typeof b.text === "string" && b.text.trim())
|
|
54640
|
-
|
|
54692
|
+
parts2.push(b.text.trim());
|
|
54641
54693
|
}
|
|
54642
|
-
return
|
|
54694
|
+
return parts2.join("\n");
|
|
54643
54695
|
}
|
|
54644
54696
|
function cap(text20) {
|
|
54645
54697
|
return text20.length <= MAX_LENGTH2 ? text20 : `${text20.slice(0, MAX_LENGTH2).trimEnd()}\u2026`;
|
|
@@ -54686,15 +54738,15 @@ function promptTextOrNull(entry) {
|
|
|
54686
54738
|
const content = asRecord5(entry.message)?.content;
|
|
54687
54739
|
if (typeof content === "string") return isInterrupt(content) ? null : content;
|
|
54688
54740
|
if (!Array.isArray(content)) return null;
|
|
54689
|
-
const
|
|
54741
|
+
const parts2 = [];
|
|
54690
54742
|
for (const block of content) {
|
|
54691
54743
|
const b = asRecord5(block);
|
|
54692
54744
|
if (b?.type !== "text") continue;
|
|
54693
54745
|
const text20 = typeof b.text === "string" ? b.text : "";
|
|
54694
54746
|
if (isInterrupt(text20)) return null;
|
|
54695
|
-
|
|
54747
|
+
parts2.push(text20);
|
|
54696
54748
|
}
|
|
54697
|
-
return
|
|
54749
|
+
return parts2.length === 0 ? null : parts2.join("\n");
|
|
54698
54750
|
}
|
|
54699
54751
|
function cap2(message3, maxLength) {
|
|
54700
54752
|
return message3.length <= maxLength ? message3 : `${message3.slice(0, maxLength).trimEnd()}\u2026`;
|
|
@@ -54816,16 +54868,16 @@ var MAX_CONTEXT_CHARS = 800;
|
|
|
54816
54868
|
function extractContextAfterReference(filePath) {
|
|
54817
54869
|
const head = readTranscriptHead(filePath);
|
|
54818
54870
|
if (head === void 0) return void 0;
|
|
54819
|
-
const
|
|
54871
|
+
const parts2 = [];
|
|
54820
54872
|
let length = 0;
|
|
54821
54873
|
for (const text20 of conversationText(head)) {
|
|
54822
|
-
if (
|
|
54823
|
-
|
|
54874
|
+
if (parts2.length === 0 && isBareReferencePrompt(text20)) continue;
|
|
54875
|
+
parts2.push(text20);
|
|
54824
54876
|
length += text20.length;
|
|
54825
54877
|
if (length >= MAX_CONTEXT_CHARS) break;
|
|
54826
54878
|
}
|
|
54827
54879
|
if (length < MIN_CONTEXT_CHARS) return void 0;
|
|
54828
|
-
return
|
|
54880
|
+
return parts2.join("\n").slice(0, MAX_CONTEXT_CHARS);
|
|
54829
54881
|
}
|
|
54830
54882
|
function* conversationText(head) {
|
|
54831
54883
|
for (const line of head.split("\n")) {
|
|
@@ -56522,6 +56574,7 @@ function restoreServerRun(id, persisted, base) {
|
|
|
56522
56574
|
server: true,
|
|
56523
56575
|
serverPort: meta.port,
|
|
56524
56576
|
serverProtocol: meta.protocol,
|
|
56577
|
+
serverPath: meta.path,
|
|
56525
56578
|
serverOrigin: meta.origin,
|
|
56526
56579
|
serverGroup: meta.group
|
|
56527
56580
|
};
|
|
@@ -57042,6 +57095,7 @@ function tagServerSession(session, meta) {
|
|
|
57042
57095
|
session.server = meta.server || void 0;
|
|
57043
57096
|
session.serverPort = meta.port;
|
|
57044
57097
|
session.serverProtocol = meta.protocol;
|
|
57098
|
+
session.serverPath = meta.path;
|
|
57045
57099
|
session.serverOrigin = meta.origin;
|
|
57046
57100
|
session.serverGroup = meta.group;
|
|
57047
57101
|
}
|