@staff0rd/assist 0.470.0 → 0.472.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/README.md +1 -0
- package/claude/commands/refine.md +17 -15
- package/dist/commands/sessions/web/bundle.js +377 -377
- package/dist/index.js +827 -528
- 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.472.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -9046,28 +9046,6 @@ async function handleItemRoute(req, res, pathname) {
|
|
|
9046
9046
|
return false;
|
|
9047
9047
|
}
|
|
9048
9048
|
|
|
9049
|
-
// src/commands/sessions/web/execGit.ts
|
|
9050
|
-
import { execFile as execFile3 } from "child_process";
|
|
9051
|
-
import { promisify as promisify2 } from "util";
|
|
9052
|
-
var execFileAsync2 = promisify2(execFile3);
|
|
9053
|
-
async function execGit(cwd, args, opts = {}) {
|
|
9054
|
-
const { maxBuffer, allowFailure } = opts;
|
|
9055
|
-
const { file, argv } = /^[A-Za-z]:[\\/]/.test(cwd) ? { file: "git.exe", argv: ["-C", cwd, ...args] } : { file: "git", argv: args };
|
|
9056
|
-
try {
|
|
9057
|
-
const { stdout } = await execFileAsync2(file, argv, {
|
|
9058
|
-
encoding: "utf8",
|
|
9059
|
-
...maxBuffer ? { maxBuffer } : {},
|
|
9060
|
-
...file === "git" ? { cwd } : {}
|
|
9061
|
-
});
|
|
9062
|
-
return stdout;
|
|
9063
|
-
} catch (error) {
|
|
9064
|
-
if (allowFailure && error && typeof error === "object" && "stdout" in error) {
|
|
9065
|
-
return String(error.stdout);
|
|
9066
|
-
}
|
|
9067
|
-
throw error;
|
|
9068
|
-
}
|
|
9069
|
-
}
|
|
9070
|
-
|
|
9071
9049
|
// src/commands/sessions/web/getCwdParam.ts
|
|
9072
9050
|
function getCwdParam(req, res) {
|
|
9073
9051
|
const url = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -9085,6 +9063,31 @@ function getSessionParam(req) {
|
|
|
9085
9063
|
return url.searchParams.get("session") ?? void 0;
|
|
9086
9064
|
}
|
|
9087
9065
|
|
|
9066
|
+
// src/commands/sessions/web/windowsCwdToWslPath.ts
|
|
9067
|
+
function windowsCwdToWslPath(cwd) {
|
|
9068
|
+
const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
|
|
9069
|
+
if (!match) return cwd;
|
|
9070
|
+
const drive = match[1].toLowerCase();
|
|
9071
|
+
const rest = match[2].replace(/\\/g, "/");
|
|
9072
|
+
return `/mnt/${drive}/${rest}`;
|
|
9073
|
+
}
|
|
9074
|
+
|
|
9075
|
+
// src/commands/sessions/web/toGitCwd.ts
|
|
9076
|
+
function toGitCwd(cwd) {
|
|
9077
|
+
return detectPlatform() === "wsl" ? windowsCwdToWslPath(cwd) : cwd;
|
|
9078
|
+
}
|
|
9079
|
+
|
|
9080
|
+
// src/commands/sessions/web/includesCommittedChanges.ts
|
|
9081
|
+
function includesCommittedChanges(cwd) {
|
|
9082
|
+
try {
|
|
9083
|
+
return Boolean(
|
|
9084
|
+
loadConfigFrom(toGitCwd(cwd)).sessions?.includeCommittedChanges
|
|
9085
|
+
);
|
|
9086
|
+
} catch {
|
|
9087
|
+
return false;
|
|
9088
|
+
}
|
|
9089
|
+
}
|
|
9090
|
+
|
|
9088
9091
|
// src/shared/db/findItemBySessionId.ts
|
|
9089
9092
|
import { asc as asc6, eq as eq16 } from "drizzle-orm";
|
|
9090
9093
|
async function findItemBySessionId(db, claudeSessionId) {
|
|
@@ -9121,15 +9124,53 @@ async function itemCommits(sessionId) {
|
|
|
9121
9124
|
}
|
|
9122
9125
|
}
|
|
9123
9126
|
|
|
9127
|
+
// src/commands/sessions/web/itemScopeCommits.ts
|
|
9128
|
+
async function itemScopeCommits(cwd, sessionId) {
|
|
9129
|
+
if (!sessionId || !includesCommittedChanges(cwd)) return [];
|
|
9130
|
+
return itemCommits(sessionId);
|
|
9131
|
+
}
|
|
9132
|
+
|
|
9133
|
+
// src/commands/sessions/web/resolveDiffScope.ts
|
|
9134
|
+
async function resolveDiffScope(cwd, sessionId, scope) {
|
|
9135
|
+
if (!scope || scope === "all") return { kind: "all" };
|
|
9136
|
+
if (scope === "uncommitted") return { kind: "uncommitted" };
|
|
9137
|
+
const commits2 = await itemScopeCommits(cwd, sessionId);
|
|
9138
|
+
if (!commits2.some((commit2) => commit2.sha === scope)) return void 0;
|
|
9139
|
+
return { kind: "commit", sha: scope };
|
|
9140
|
+
}
|
|
9141
|
+
|
|
9142
|
+
// src/commands/sessions/web/execGit.ts
|
|
9143
|
+
import { execFile as execFile3 } from "child_process";
|
|
9144
|
+
import { promisify as promisify2 } from "util";
|
|
9145
|
+
var execFileAsync2 = promisify2(execFile3);
|
|
9146
|
+
async function execGit(cwd, args, opts = {}) {
|
|
9147
|
+
const { maxBuffer, allowFailure } = opts;
|
|
9148
|
+
const { file, argv } = /^[A-Za-z]:[\\/]/.test(cwd) ? { file: "git.exe", argv: ["-C", cwd, ...args] } : { file: "git", argv: args };
|
|
9149
|
+
try {
|
|
9150
|
+
const { stdout } = await execFileAsync2(file, argv, {
|
|
9151
|
+
encoding: "utf8",
|
|
9152
|
+
...maxBuffer ? { maxBuffer } : {},
|
|
9153
|
+
...file === "git" ? { cwd } : {}
|
|
9154
|
+
});
|
|
9155
|
+
return stdout;
|
|
9156
|
+
} catch (error) {
|
|
9157
|
+
if (allowFailure && error && typeof error === "object" && "stdout" in error) {
|
|
9158
|
+
return String(error.stdout);
|
|
9159
|
+
}
|
|
9160
|
+
throw error;
|
|
9161
|
+
}
|
|
9162
|
+
}
|
|
9163
|
+
|
|
9124
9164
|
// src/commands/sessions/web/resolveCommit.ts
|
|
9125
9165
|
var GIT_EMPTY_TREE_HASH = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
9126
|
-
async function
|
|
9166
|
+
async function commitBase(cwd, sha) {
|
|
9127
9167
|
if (!await commitExists(cwd, sha)) return void 0;
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9168
|
+
return await parentOf(cwd, sha) ?? GIT_EMPTY_TREE_HASH;
|
|
9169
|
+
}
|
|
9170
|
+
async function resolveCommit(cwd, sha) {
|
|
9171
|
+
const base = await commitBase(cwd, sha);
|
|
9172
|
+
if (!base) return void 0;
|
|
9173
|
+
return { base, paths: await commitPaths(cwd, sha) };
|
|
9133
9174
|
}
|
|
9134
9175
|
async function commitExists(cwd, sha) {
|
|
9135
9176
|
try {
|
|
@@ -9198,20 +9239,6 @@ async function loadCommittedPaths(cwd, sessionId) {
|
|
|
9198
9239
|
return { commits: commits2, bases };
|
|
9199
9240
|
}
|
|
9200
9241
|
|
|
9201
|
-
// src/commands/sessions/web/windowsCwdToWslPath.ts
|
|
9202
|
-
function windowsCwdToWslPath(cwd) {
|
|
9203
|
-
const match = /^([A-Za-z]):[\\/](.*)$/.exec(cwd);
|
|
9204
|
-
if (!match) return cwd;
|
|
9205
|
-
const drive = match[1].toLowerCase();
|
|
9206
|
-
const rest = match[2].replace(/\\/g, "/");
|
|
9207
|
-
return `/mnt/${drive}/${rest}`;
|
|
9208
|
-
}
|
|
9209
|
-
|
|
9210
|
-
// src/commands/sessions/web/toGitCwd.ts
|
|
9211
|
-
function toGitCwd(cwd) {
|
|
9212
|
-
return detectPlatform() === "wsl" ? windowsCwdToWslPath(cwd) : cwd;
|
|
9213
|
-
}
|
|
9214
|
-
|
|
9215
9242
|
// src/commands/sessions/web/itemChangeSet.ts
|
|
9216
9243
|
async function itemChangeSet(cwd, sessionId) {
|
|
9217
9244
|
if (!sessionId || !includesCommittedChanges(cwd)) return void 0;
|
|
@@ -9222,15 +9249,6 @@ async function itemChangeSet(cwd, sessionId) {
|
|
|
9222
9249
|
if (dirty.length > 0) groups.push({ base: "HEAD", paths: dirty });
|
|
9223
9250
|
return { commits: commits2, groups };
|
|
9224
9251
|
}
|
|
9225
|
-
function includesCommittedChanges(cwd) {
|
|
9226
|
-
try {
|
|
9227
|
-
return Boolean(
|
|
9228
|
-
loadConfigFrom(toGitCwd(cwd)).sessions?.includeCommittedChanges
|
|
9229
|
-
);
|
|
9230
|
-
} catch {
|
|
9231
|
-
return false;
|
|
9232
|
-
}
|
|
9233
|
-
}
|
|
9234
9252
|
function groupByBase(bases) {
|
|
9235
9253
|
const groups = /* @__PURE__ */ new Map();
|
|
9236
9254
|
for (const [path71, base] of bases) {
|
|
@@ -9245,8 +9263,13 @@ async function dirtyPaths(cwd, bases) {
|
|
|
9245
9263
|
return output.split("\n").filter((path71) => path71 && !bases.has(path71)).sort();
|
|
9246
9264
|
}
|
|
9247
9265
|
|
|
9248
|
-
// src/commands/sessions/web/
|
|
9266
|
+
// src/commands/sessions/web/scopedDiff.ts
|
|
9249
9267
|
var MAX_DIFF_BYTES = 50 * 1024 * 1024;
|
|
9268
|
+
async function scopedDiff(cwd, session, scope) {
|
|
9269
|
+
if (scope.kind === "commit") return commitDiff(cwd, scope.sha);
|
|
9270
|
+
const tracked = scope.kind === "uncommitted" ? await workingTreeDiff(cwd) : await trackedDiff(cwd, session);
|
|
9271
|
+
return tracked + await untrackedDiff(cwd);
|
|
9272
|
+
}
|
|
9250
9273
|
async function untrackedFileDiff(cwd, path71) {
|
|
9251
9274
|
return execGit(cwd, ["diff", "--no-index", "--", "/dev/null", path71], {
|
|
9252
9275
|
maxBuffer: MAX_DIFF_BYTES,
|
|
@@ -9275,25 +9298,56 @@ async function groupedDiff(cwd, groups) {
|
|
|
9275
9298
|
);
|
|
9276
9299
|
return diffs.join("");
|
|
9277
9300
|
}
|
|
9301
|
+
async function workingTreeDiff(cwd) {
|
|
9302
|
+
return execGit(cwd, ["diff", "HEAD"], { maxBuffer: MAX_DIFF_BYTES });
|
|
9303
|
+
}
|
|
9278
9304
|
async function trackedDiff(cwd, session) {
|
|
9279
9305
|
const changeSet = await itemChangeSet(cwd, session);
|
|
9280
9306
|
if (changeSet) return groupedDiff(cwd, changeSet.groups);
|
|
9281
|
-
return
|
|
9307
|
+
return workingTreeDiff(cwd);
|
|
9308
|
+
}
|
|
9309
|
+
async function commitDiff(cwd, sha) {
|
|
9310
|
+
const base = await commitBase(cwd, sha);
|
|
9311
|
+
if (!base) return "";
|
|
9312
|
+
return execGit(cwd, ["diff", base, sha], { maxBuffer: MAX_DIFF_BYTES });
|
|
9313
|
+
}
|
|
9314
|
+
|
|
9315
|
+
// src/commands/sessions/web/diff.ts
|
|
9316
|
+
function getScopeParam(req) {
|
|
9317
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
9318
|
+
return url.searchParams.get("scope") ?? void 0;
|
|
9282
9319
|
}
|
|
9283
9320
|
async function diff2(req, res) {
|
|
9284
9321
|
const cwd = getCwdParam(req, res);
|
|
9285
9322
|
if (!cwd) return;
|
|
9323
|
+
const session = getSessionParam(req);
|
|
9286
9324
|
try {
|
|
9287
|
-
const
|
|
9288
|
-
|
|
9325
|
+
const scope = await resolveDiffScope(cwd, session, getScopeParam(req));
|
|
9326
|
+
if (!scope) {
|
|
9327
|
+
respondJson(res, 400, { error: "Invalid scope" });
|
|
9328
|
+
return;
|
|
9329
|
+
}
|
|
9330
|
+
const body = await scopedDiff(cwd, session, scope);
|
|
9289
9331
|
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
9290
|
-
res.end(
|
|
9332
|
+
res.end(body);
|
|
9291
9333
|
} catch {
|
|
9292
9334
|
res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
|
|
9293
9335
|
res.end("");
|
|
9294
9336
|
}
|
|
9295
9337
|
}
|
|
9296
9338
|
|
|
9339
|
+
// src/commands/sessions/web/diffScopes.ts
|
|
9340
|
+
async function diffScopes(req, res) {
|
|
9341
|
+
const cwd = getCwdParam(req, res);
|
|
9342
|
+
if (!cwd) return;
|
|
9343
|
+
try {
|
|
9344
|
+
const commits2 = await itemScopeCommits(cwd, getSessionParam(req));
|
|
9345
|
+
respondJson(res, 200, { commits: commits2 });
|
|
9346
|
+
} catch {
|
|
9347
|
+
respondJson(res, 200, { commits: [] });
|
|
9348
|
+
}
|
|
9349
|
+
}
|
|
9350
|
+
|
|
9297
9351
|
// src/commands/sessions/web/fileContent.ts
|
|
9298
9352
|
import { readFile, stat as stat2 } from "fs/promises";
|
|
9299
9353
|
import { isAbsolute, relative as relative2, resolve as resolve9 } from "path";
|
|
@@ -10937,6 +10991,7 @@ var routes2 = {
|
|
|
10937
10991
|
"GET /api/github-url": githubUrl,
|
|
10938
10992
|
"GET /api/git-status": gitStatus,
|
|
10939
10993
|
"GET /api/diff": diff2,
|
|
10994
|
+
"GET /api/diff-scopes": diffScopes,
|
|
10940
10995
|
"GET /api/file": fileContent,
|
|
10941
10996
|
"GET /api/files": listFiles,
|
|
10942
10997
|
"GET /api/jira-site": jiraSite,
|
|
@@ -12362,26 +12417,9 @@ async function list2(options2) {
|
|
|
12362
12417
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
12363
12418
|
import chalk79 from "chalk";
|
|
12364
12419
|
|
|
12365
|
-
// src/commands/backlog/
|
|
12420
|
+
// src/commands/backlog/readJsonPayload.ts
|
|
12366
12421
|
import { readFileSync as readFileSync23 } from "fs";
|
|
12367
12422
|
import chalk78 from "chalk";
|
|
12368
|
-
|
|
12369
|
-
// src/commands/backlog/propose/proposedItemSchema.ts
|
|
12370
|
-
import { z as z5 } from "zod";
|
|
12371
|
-
var proposedPhaseSchema = z5.strictObject({
|
|
12372
|
-
name: z5.string().trim().min(1, "phase name is required"),
|
|
12373
|
-
tasks: z5.array(z5.string().trim().min(1)).min(1, "a phase needs at least one task"),
|
|
12374
|
-
manualChecks: z5.array(z5.string().trim().min(1)).default([])
|
|
12375
|
-
});
|
|
12376
|
-
var proposedItemSchema = z5.strictObject({
|
|
12377
|
-
name: z5.string().trim().min(1, "name is required"),
|
|
12378
|
-
type: z5.enum(["story", "bug"]),
|
|
12379
|
-
description: z5.string().optional(),
|
|
12380
|
-
acceptanceCriteria: z5.array(z5.string().trim().min(1)).default([]),
|
|
12381
|
-
phases: z5.array(proposedPhaseSchema).default([])
|
|
12382
|
-
});
|
|
12383
|
-
|
|
12384
|
-
// src/commands/backlog/propose/readProposedItem.ts
|
|
12385
12423
|
function fail3(message2) {
|
|
12386
12424
|
console.error(chalk78.red(message2));
|
|
12387
12425
|
process.exit(1);
|
|
@@ -12399,7 +12437,7 @@ async function readSource(source) {
|
|
|
12399
12437
|
);
|
|
12400
12438
|
}
|
|
12401
12439
|
}
|
|
12402
|
-
async function
|
|
12440
|
+
async function readJsonPayload(source, schema2, subject) {
|
|
12403
12441
|
const raw = await readSource(source);
|
|
12404
12442
|
let json;
|
|
12405
12443
|
try {
|
|
@@ -12407,15 +12445,35 @@ async function readProposedItem(source) {
|
|
|
12407
12445
|
} catch (error) {
|
|
12408
12446
|
return fail3(`The payload is not valid JSON: ${describe(error)}`);
|
|
12409
12447
|
}
|
|
12410
|
-
const parsed =
|
|
12448
|
+
const parsed = schema2.safeParse(json);
|
|
12411
12449
|
if (!parsed.success) {
|
|
12412
12450
|
const issues = parsed.error.issues.map((i) => ` ${i.path.join(".") || "(root)"}: ${i.message}`).join("\n");
|
|
12413
|
-
return fail3(`The payload is not a valid
|
|
12451
|
+
return fail3(`The payload is not a valid ${subject}:
|
|
12414
12452
|
${issues}`);
|
|
12415
12453
|
}
|
|
12416
12454
|
return parsed.data;
|
|
12417
12455
|
}
|
|
12418
12456
|
|
|
12457
|
+
// src/commands/backlog/propose/proposedItemSchema.ts
|
|
12458
|
+
import { z as z5 } from "zod";
|
|
12459
|
+
var proposedPhaseSchema = z5.strictObject({
|
|
12460
|
+
name: z5.string().trim().min(1, "phase name is required"),
|
|
12461
|
+
tasks: z5.array(z5.string().trim().min(1)).min(1, "a phase needs at least one task"),
|
|
12462
|
+
manualChecks: z5.array(z5.string().trim().min(1)).default([])
|
|
12463
|
+
});
|
|
12464
|
+
var proposedItemSchema = z5.strictObject({
|
|
12465
|
+
name: z5.string().trim().min(1, "name is required"),
|
|
12466
|
+
type: z5.enum(["story", "bug"]),
|
|
12467
|
+
description: z5.string().optional(),
|
|
12468
|
+
acceptanceCriteria: z5.array(z5.string().trim().min(1)).default([]),
|
|
12469
|
+
phases: z5.array(proposedPhaseSchema).default([])
|
|
12470
|
+
});
|
|
12471
|
+
|
|
12472
|
+
// src/commands/backlog/propose/readProposedItem.ts
|
|
12473
|
+
function readProposedItem(source) {
|
|
12474
|
+
return readJsonPayload(source, proposedItemSchema, "backlog item");
|
|
12475
|
+
}
|
|
12476
|
+
|
|
12419
12477
|
// src/commands/backlog/propose/renderProposedItem.ts
|
|
12420
12478
|
function renderProposedItem(item) {
|
|
12421
12479
|
const sections = [`**Type:** ${item.type}`];
|
|
@@ -13798,6 +13856,241 @@ async function update(id, options2) {
|
|
|
13798
13856
|
);
|
|
13799
13857
|
}
|
|
13800
13858
|
|
|
13859
|
+
// src/commands/backlog/updatePlan/index.ts
|
|
13860
|
+
import chalk113 from "chalk";
|
|
13861
|
+
|
|
13862
|
+
// src/commands/backlog/updatePlan/planUpdateSchema.ts
|
|
13863
|
+
import { z as z6 } from "zod";
|
|
13864
|
+
var planUpdateSchema = z6.strictObject({
|
|
13865
|
+
phases: z6.array(proposedPhaseSchema).min(1, "a plan needs at least one phase")
|
|
13866
|
+
});
|
|
13867
|
+
|
|
13868
|
+
// src/commands/backlog/updatePlan/readPlanUpdate.ts
|
|
13869
|
+
function readPlanUpdate(source) {
|
|
13870
|
+
return readJsonPayload(source, planUpdateSchema, "plan");
|
|
13871
|
+
}
|
|
13872
|
+
|
|
13873
|
+
// src/commands/backlog/updatePlan/replacePlan.ts
|
|
13874
|
+
import { eq as eq41 } from "drizzle-orm";
|
|
13875
|
+
|
|
13876
|
+
// src/commands/backlog/updatePlan/clampCurrentPhase.ts
|
|
13877
|
+
function clampCurrentPhase(currentPhase, phaseCount) {
|
|
13878
|
+
if (phaseCount === 0) return null;
|
|
13879
|
+
return Math.min(currentPhase, phaseCount);
|
|
13880
|
+
}
|
|
13881
|
+
|
|
13882
|
+
// src/commands/backlog/updatePlan/replacePlan.ts
|
|
13883
|
+
async function replacePlan(orm, itemId2, phases, currentPhase) {
|
|
13884
|
+
await orm.transaction(async (tx) => {
|
|
13885
|
+
await tx.delete(planTasks).where(eq41(planTasks.itemId, itemId2));
|
|
13886
|
+
await tx.delete(planPhases).where(eq41(planPhases.itemId, itemId2));
|
|
13887
|
+
if (phases.length > 0) {
|
|
13888
|
+
await tx.insert(planPhases).values(
|
|
13889
|
+
phases.map((phase, idx) => ({
|
|
13890
|
+
itemId: itemId2,
|
|
13891
|
+
idx,
|
|
13892
|
+
name: phase.name,
|
|
13893
|
+
manualChecks: serializeManualChecks(phase.manualChecks)
|
|
13894
|
+
}))
|
|
13895
|
+
);
|
|
13896
|
+
}
|
|
13897
|
+
const tasks = phases.flatMap(
|
|
13898
|
+
(phase, phaseIdx) => phase.tasks.map((task, idx) => ({ itemId: itemId2, phaseIdx, idx, task }))
|
|
13899
|
+
);
|
|
13900
|
+
if (tasks.length > 0) await tx.insert(planTasks).values(tasks);
|
|
13901
|
+
if (currentPhase === void 0) return;
|
|
13902
|
+
const clamped = clampCurrentPhase(currentPhase, phases.length);
|
|
13903
|
+
if (clamped === currentPhase) return;
|
|
13904
|
+
await tx.update(items).set({ currentPhase: clamped }).where(eq41(items.id, itemId2));
|
|
13905
|
+
});
|
|
13906
|
+
}
|
|
13907
|
+
|
|
13908
|
+
// src/commands/backlog/updatePlan/reviewPlanUpdate.ts
|
|
13909
|
+
import { randomUUID as randomUUID5 } from "crypto";
|
|
13910
|
+
import chalk112 from "chalk";
|
|
13911
|
+
|
|
13912
|
+
// src/commands/backlog/updatePlan/isCompleted.ts
|
|
13913
|
+
function isCompleted(previousPosition, currentPhase) {
|
|
13914
|
+
return currentPhase !== void 0 && previousPosition < currentPhase;
|
|
13915
|
+
}
|
|
13916
|
+
|
|
13917
|
+
// src/commands/backlog/updatePlan/matchStoredPhases.ts
|
|
13918
|
+
function sameList(a, b) {
|
|
13919
|
+
return a.length === b.length && a.every((value, idx) => value === b[idx]);
|
|
13920
|
+
}
|
|
13921
|
+
function isIdenticalPhase(a, b) {
|
|
13922
|
+
return a.name === b.name && sameList(a.tasks, b.tasks) && sameList(a.manualChecks, b.manualChecks);
|
|
13923
|
+
}
|
|
13924
|
+
function matchStoredPhases(payload, stored) {
|
|
13925
|
+
const taken = /* @__PURE__ */ new Set();
|
|
13926
|
+
const matches = payload.map(() => void 0);
|
|
13927
|
+
const claim = (payloadIdx, isCandidate) => {
|
|
13928
|
+
if (matches[payloadIdx] !== void 0) return;
|
|
13929
|
+
const storedIdx = stored.findIndex(
|
|
13930
|
+
(candidate, idx) => !taken.has(idx) && isCandidate(candidate)
|
|
13931
|
+
);
|
|
13932
|
+
if (storedIdx === -1) return;
|
|
13933
|
+
taken.add(storedIdx);
|
|
13934
|
+
matches[payloadIdx] = storedIdx;
|
|
13935
|
+
};
|
|
13936
|
+
payload.forEach(
|
|
13937
|
+
(phase, idx) => claim(idx, (candidate) => candidate.name === phase.name)
|
|
13938
|
+
);
|
|
13939
|
+
payload.forEach(
|
|
13940
|
+
(phase, idx) => claim(idx, (candidate) => sameList(candidate.tasks, phase.tasks))
|
|
13941
|
+
);
|
|
13942
|
+
return matches;
|
|
13943
|
+
}
|
|
13944
|
+
|
|
13945
|
+
// src/commands/backlog/updatePlan/classifyPhase.ts
|
|
13946
|
+
function classifyPhase(phase, payloadIdx, storedIdx, stored, currentPhase) {
|
|
13947
|
+
if (storedIdx === void 0)
|
|
13948
|
+
return { phase, change: "added", wasCompleted: false };
|
|
13949
|
+
const previous = stored[storedIdx];
|
|
13950
|
+
const previousPosition = storedIdx + 1;
|
|
13951
|
+
const wasCompleted = isCompleted(previousPosition, currentPhase);
|
|
13952
|
+
if (isIdenticalPhase(previous, phase))
|
|
13953
|
+
return {
|
|
13954
|
+
phase,
|
|
13955
|
+
change: storedIdx === payloadIdx ? "unchanged" : "moved",
|
|
13956
|
+
previousPosition,
|
|
13957
|
+
wasCompleted
|
|
13958
|
+
};
|
|
13959
|
+
return {
|
|
13960
|
+
phase,
|
|
13961
|
+
change: "edited",
|
|
13962
|
+
previousPosition,
|
|
13963
|
+
wasCompleted,
|
|
13964
|
+
...previous.name === phase.name ? {} : { previousName: previous.name },
|
|
13965
|
+
...sameList(previous.tasks, phase.tasks) ? {} : { previousTasks: previous.tasks }
|
|
13966
|
+
};
|
|
13967
|
+
}
|
|
13968
|
+
|
|
13969
|
+
// src/commands/backlog/updatePlan/diffPlan.ts
|
|
13970
|
+
function fromStored(phase) {
|
|
13971
|
+
return {
|
|
13972
|
+
name: phase.name,
|
|
13973
|
+
tasks: phase.tasks.map((t) => t.task),
|
|
13974
|
+
manualChecks: phase.manualChecks ?? []
|
|
13975
|
+
};
|
|
13976
|
+
}
|
|
13977
|
+
function diffPlan(storedPlan, payloadPhases, currentPhase) {
|
|
13978
|
+
const stored = (storedPlan ?? []).map(fromStored);
|
|
13979
|
+
const payload = payloadPhases.map((phase) => ({
|
|
13980
|
+
name: phase.name,
|
|
13981
|
+
tasks: phase.tasks,
|
|
13982
|
+
manualChecks: phase.manualChecks
|
|
13983
|
+
}));
|
|
13984
|
+
const matches = matchStoredPhases(payload, stored);
|
|
13985
|
+
const phases = payload.map(
|
|
13986
|
+
(phase, idx) => classifyPhase(phase, idx, matches[idx], stored, currentPhase)
|
|
13987
|
+
);
|
|
13988
|
+
const matched = new Set(matches.filter((idx) => idx !== void 0));
|
|
13989
|
+
const removed = stored.flatMap(
|
|
13990
|
+
(phase, idx) => matched.has(idx) ? [] : [
|
|
13991
|
+
{
|
|
13992
|
+
phase,
|
|
13993
|
+
previousPosition: idx + 1,
|
|
13994
|
+
wasCompleted: isCompleted(idx + 1, currentPhase)
|
|
13995
|
+
}
|
|
13996
|
+
]
|
|
13997
|
+
);
|
|
13998
|
+
return { phases, removed };
|
|
13999
|
+
}
|
|
14000
|
+
|
|
14001
|
+
// src/commands/backlog/updatePlan/renderPlanDiff.ts
|
|
14002
|
+
function phaseNotes(entry, position) {
|
|
14003
|
+
if (entry.change === "unchanged") return ["unchanged"];
|
|
14004
|
+
if (entry.change === "added") return ["added"];
|
|
14005
|
+
const notes = entry.change === "moved" ? [`moved from phase ${entry.previousPosition}`] : ["edited"];
|
|
14006
|
+
if (entry.change === "edited") {
|
|
14007
|
+
if (entry.previousName) notes.push(`renamed from "${entry.previousName}"`);
|
|
14008
|
+
if (entry.previousPosition !== position)
|
|
14009
|
+
notes.push(`moved from phase ${entry.previousPosition}`);
|
|
14010
|
+
}
|
|
14011
|
+
if (entry.wasCompleted) notes.push("already completed");
|
|
14012
|
+
return notes;
|
|
14013
|
+
}
|
|
14014
|
+
function renderDiffPhase(entry, idx) {
|
|
14015
|
+
const notes = phaseNotes(entry, idx + 1);
|
|
14016
|
+
const section3 = renderPhaseSection(
|
|
14017
|
+
{ ...entry.phase, name: `${entry.phase.name} (${notes.join(", ")})` },
|
|
14018
|
+
idx
|
|
14019
|
+
);
|
|
14020
|
+
if (!entry.previousTasks) return section3;
|
|
14021
|
+
return [
|
|
14022
|
+
section3,
|
|
14023
|
+
"**Previously:**",
|
|
14024
|
+
entry.previousTasks.map((task) => `- ${task}`).join("\n")
|
|
14025
|
+
].join("\n\n");
|
|
14026
|
+
}
|
|
14027
|
+
function renderRemovedPhase(entry) {
|
|
14028
|
+
const notes = entry.wasCompleted ? "removed, already completed" : "removed";
|
|
14029
|
+
return renderPhaseSection(
|
|
14030
|
+
{ ...entry.phase, name: `${entry.phase.name} (${notes})` },
|
|
14031
|
+
entry.previousPosition - 1
|
|
14032
|
+
);
|
|
14033
|
+
}
|
|
14034
|
+
function renderPlanDiff(diff3) {
|
|
14035
|
+
const sections = ["## Plan", ...diff3.phases.map(renderDiffPhase)];
|
|
14036
|
+
if (diff3.removed.length === 0) return sections;
|
|
14037
|
+
return [
|
|
14038
|
+
...sections,
|
|
14039
|
+
"## Removed phases",
|
|
14040
|
+
...diff3.removed.map(renderRemovedPhase)
|
|
14041
|
+
];
|
|
14042
|
+
}
|
|
14043
|
+
|
|
14044
|
+
// src/commands/backlog/updatePlan/renderPlanUpdate.ts
|
|
14045
|
+
function clampNote(item, phaseCount) {
|
|
14046
|
+
const currentPhase = item.currentPhase;
|
|
14047
|
+
if (currentPhase === void 0) return void 0;
|
|
14048
|
+
const clamped = clampCurrentPhase(currentPhase, phaseCount);
|
|
14049
|
+
if (clamped === currentPhase) return void 0;
|
|
14050
|
+
return `**Current phase:** ${currentPhase} \u2192 ${clamped ?? "none"} (clamped into the new plan of ${phaseCount} phase${phaseCount === 1 ? "" : "s"})`;
|
|
14051
|
+
}
|
|
14052
|
+
function renderPlanUpdate(item, phases) {
|
|
14053
|
+
const note = clampNote(item, phases.length);
|
|
14054
|
+
const diff3 = diffPlan(item.plan, phases, item.currentPhase);
|
|
14055
|
+
const sections = note ? [note] : [];
|
|
14056
|
+
return [...sections, ...renderPlanDiff(diff3)].join("\n\n");
|
|
14057
|
+
}
|
|
14058
|
+
|
|
14059
|
+
// src/commands/backlog/updatePlan/reviewPlanUpdate.ts
|
|
14060
|
+
async function reviewPlanUpdate(item, phases) {
|
|
14061
|
+
const body = renderPlanUpdate(item, phases);
|
|
14062
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
14063
|
+
if (process.env.ASSIST_SESSION === "1" && sessionId) {
|
|
14064
|
+
await awaitPreviewApproval("Plan update preview", {
|
|
14065
|
+
sessionId,
|
|
14066
|
+
requestId: randomUUID5(),
|
|
14067
|
+
title: `Update the plan for ${formatItemId(item.id)}: ${item.name}`,
|
|
14068
|
+
body,
|
|
14069
|
+
prNumber: null,
|
|
14070
|
+
kind: "backlog-item",
|
|
14071
|
+
itemType: item.type
|
|
14072
|
+
});
|
|
14073
|
+
return;
|
|
14074
|
+
}
|
|
14075
|
+
console.log(chalk112.bold(item.name));
|
|
14076
|
+
console.log(renderMarkdownTerminal(body));
|
|
14077
|
+
}
|
|
14078
|
+
|
|
14079
|
+
// src/commands/backlog/updatePlan/index.ts
|
|
14080
|
+
async function updatePlan(id, options2) {
|
|
14081
|
+
const { phases } = await readPlanUpdate(options2.json);
|
|
14082
|
+
const found = await findOneItem(id);
|
|
14083
|
+
if (!found) return;
|
|
14084
|
+
const { orm, item } = found;
|
|
14085
|
+
await reviewPlanUpdate(item, phases);
|
|
14086
|
+
await replacePlan(orm, item.id, phases, item.currentPhase);
|
|
14087
|
+
console.log(
|
|
14088
|
+
chalk113.green(
|
|
14089
|
+
`Replaced the plan on item ${formatItemId(item.id)} with ${phases.length} phase${phases.length === 1 ? "" : "s"}.`
|
|
14090
|
+
)
|
|
14091
|
+
);
|
|
14092
|
+
}
|
|
14093
|
+
|
|
13801
14094
|
// src/commands/backlog/registerUpdateCommands.ts
|
|
13802
14095
|
function collect2(value, previous) {
|
|
13803
14096
|
return [...previous, value];
|
|
@@ -13820,6 +14113,12 @@ function registerUpdateCommands(cmd) {
|
|
|
13820
14113
|
).action(update);
|
|
13821
14114
|
registerUpdatePhaseCommand(cmd);
|
|
13822
14115
|
cmd.command("remove-phase <id> <phase>").description("Remove a plan phase from a backlog item").action(removePhase);
|
|
14116
|
+
cmd.command("update-plan <id>").description(
|
|
14117
|
+
"Replace an item's whole plan from a JSON payload, previewed and applied in one approval"
|
|
14118
|
+
).requiredOption(
|
|
14119
|
+
"--json <file|->",
|
|
14120
|
+
"Path to a JSON payload of { phases: [{ name, tasks, manualChecks }] }, or - to read it from stdin"
|
|
14121
|
+
).action(updatePlan);
|
|
13823
14122
|
cmd.command("move-phase <id> <from> <to>").description(
|
|
13824
14123
|
"Reorder a plan phase from one 1-based position to another, moving its tasks with it"
|
|
13825
14124
|
).action(movePhase);
|
|
@@ -14604,11 +14903,11 @@ function assertCliExists(cli) {
|
|
|
14604
14903
|
}
|
|
14605
14904
|
|
|
14606
14905
|
// src/commands/permitCliReads/colorize.ts
|
|
14607
|
-
import
|
|
14906
|
+
import chalk114 from "chalk";
|
|
14608
14907
|
function colorize(plainOutput) {
|
|
14609
14908
|
return plainOutput.split("\n").map((line) => {
|
|
14610
|
-
if (line.startsWith(" R ")) return
|
|
14611
|
-
if (line.startsWith(" W ")) return
|
|
14909
|
+
if (line.startsWith(" R ")) return chalk114.green(line);
|
|
14910
|
+
if (line.startsWith(" W ")) return chalk114.red(line);
|
|
14612
14911
|
return line;
|
|
14613
14912
|
}).join("\n");
|
|
14614
14913
|
}
|
|
@@ -14901,7 +15200,7 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
14901
15200
|
}
|
|
14902
15201
|
|
|
14903
15202
|
// src/commands/deny/denyAdd.ts
|
|
14904
|
-
import
|
|
15203
|
+
import chalk115 from "chalk";
|
|
14905
15204
|
|
|
14906
15205
|
// src/commands/deny/loadDenyConfig.ts
|
|
14907
15206
|
function loadDenyConfig(global) {
|
|
@@ -14921,16 +15220,16 @@ function loadDenyConfig(global) {
|
|
|
14921
15220
|
function denyAdd(pattern2, message2, options2) {
|
|
14922
15221
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
14923
15222
|
if (deny.some((r) => r.pattern === pattern2)) {
|
|
14924
|
-
console.log(
|
|
15223
|
+
console.log(chalk115.yellow(`Deny rule already exists for: ${pattern2}`));
|
|
14925
15224
|
return;
|
|
14926
15225
|
}
|
|
14927
15226
|
deny.push({ pattern: pattern2, message: message2 });
|
|
14928
15227
|
saveDeny(deny);
|
|
14929
|
-
console.log(
|
|
15228
|
+
console.log(chalk115.green(`Added deny rule: ${pattern2} \u2192 ${message2}`));
|
|
14930
15229
|
}
|
|
14931
15230
|
|
|
14932
15231
|
// src/commands/deny/denyList.ts
|
|
14933
|
-
import
|
|
15232
|
+
import chalk116 from "chalk";
|
|
14934
15233
|
function denyList() {
|
|
14935
15234
|
const globalRaw = loadGlobalConfigRaw();
|
|
14936
15235
|
const projectRaw = loadProjectConfig();
|
|
@@ -14941,7 +15240,7 @@ function denyList() {
|
|
|
14941
15240
|
projectDeny.length > 0 ? projectDeny : void 0
|
|
14942
15241
|
);
|
|
14943
15242
|
if (!merged || merged.length === 0) {
|
|
14944
|
-
console.log(
|
|
15243
|
+
console.log(chalk116.dim("No deny rules configured."));
|
|
14945
15244
|
return;
|
|
14946
15245
|
}
|
|
14947
15246
|
const projectPatterns = new Set(projectDeny.map((r) => r.pattern));
|
|
@@ -14949,23 +15248,23 @@ function denyList() {
|
|
|
14949
15248
|
for (const rule of merged) {
|
|
14950
15249
|
const inProject = projectPatterns.has(rule.pattern);
|
|
14951
15250
|
const inGlobal = globalPatterns.has(rule.pattern);
|
|
14952
|
-
const label2 = inProject && inGlobal ?
|
|
14953
|
-
console.log(`${
|
|
15251
|
+
const label2 = inProject && inGlobal ? chalk116.dim(" (project, overrides global)") : inGlobal ? chalk116.dim(" (global)") : "";
|
|
15252
|
+
console.log(`${chalk116.red(rule.pattern)} \u2192 ${rule.message}${label2}`);
|
|
14954
15253
|
}
|
|
14955
15254
|
}
|
|
14956
15255
|
|
|
14957
15256
|
// src/commands/deny/denyRemove.ts
|
|
14958
|
-
import
|
|
15257
|
+
import chalk117 from "chalk";
|
|
14959
15258
|
function denyRemove(pattern2, options2) {
|
|
14960
15259
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
14961
15260
|
const index3 = deny.findIndex((r) => r.pattern === pattern2);
|
|
14962
15261
|
if (index3 === -1) {
|
|
14963
|
-
console.log(
|
|
15262
|
+
console.log(chalk117.yellow(`No deny rule found for: ${pattern2}`));
|
|
14964
15263
|
return;
|
|
14965
15264
|
}
|
|
14966
15265
|
deny.splice(index3, 1);
|
|
14967
15266
|
saveDeny(deny.length > 0 ? deny : void 0);
|
|
14968
|
-
console.log(
|
|
15267
|
+
console.log(chalk117.green(`Removed deny rule: ${pattern2}`));
|
|
14969
15268
|
}
|
|
14970
15269
|
|
|
14971
15270
|
// src/commands/registerDeny.ts
|
|
@@ -15009,7 +15308,7 @@ function registerCliHook(program2) {
|
|
|
15009
15308
|
|
|
15010
15309
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
15011
15310
|
import { existsSync as existsSync33, readFileSync as readFileSync28, unlinkSync as unlinkSync8, writeFileSync as writeFileSync24 } from "fs";
|
|
15012
|
-
import
|
|
15311
|
+
import chalk118 from "chalk";
|
|
15013
15312
|
|
|
15014
15313
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
15015
15314
|
import { homedir as homedir17 } from "os";
|
|
@@ -15062,12 +15361,12 @@ function codeCommentConfirm(pin) {
|
|
|
15062
15361
|
sweepRestrictedDir();
|
|
15063
15362
|
const state = readPinState(pin);
|
|
15064
15363
|
if (!state) {
|
|
15065
|
-
console.error(
|
|
15364
|
+
console.error(chalk118.red(`No pending comment for pin: ${pin}`));
|
|
15066
15365
|
process.exitCode = 1;
|
|
15067
15366
|
return;
|
|
15068
15367
|
}
|
|
15069
15368
|
if (!existsSync33(state.file)) {
|
|
15070
|
-
console.error(
|
|
15369
|
+
console.error(chalk118.red(`Target file no longer exists: ${state.file}`));
|
|
15071
15370
|
process.exitCode = 1;
|
|
15072
15371
|
return;
|
|
15073
15372
|
}
|
|
@@ -15076,7 +15375,7 @@ function codeCommentConfirm(pin) {
|
|
|
15076
15375
|
const index3 = state.line - 1;
|
|
15077
15376
|
if (index3 > lines.length) {
|
|
15078
15377
|
console.error(
|
|
15079
|
-
|
|
15378
|
+
chalk118.red(
|
|
15080
15379
|
`Line ${state.line} is beyond the end of ${state.file} (${lines.length} lines).`
|
|
15081
15380
|
)
|
|
15082
15381
|
);
|
|
@@ -15090,14 +15389,14 @@ function codeCommentConfirm(pin) {
|
|
|
15090
15389
|
writeFileSync24(state.file, lines.join("\n"));
|
|
15091
15390
|
unlinkSync8(getPinStatePath(pin));
|
|
15092
15391
|
console.log(
|
|
15093
|
-
|
|
15392
|
+
chalk118.green(
|
|
15094
15393
|
`Inserted "${marker} ${state.text}" at ${state.file}:${state.line}`
|
|
15095
15394
|
)
|
|
15096
15395
|
);
|
|
15097
15396
|
}
|
|
15098
15397
|
|
|
15099
15398
|
// src/commands/codeComment/codeCommentSet.ts
|
|
15100
|
-
import
|
|
15399
|
+
import chalk119 from "chalk";
|
|
15101
15400
|
|
|
15102
15401
|
// src/commands/codeComment/validateCommentText.ts
|
|
15103
15402
|
var MAX_COMMENT_LENGTH = 50;
|
|
@@ -15148,7 +15447,7 @@ function generatePin() {
|
|
|
15148
15447
|
function codeCommentSet(file, line, text17) {
|
|
15149
15448
|
const lineNumber = Number.parseInt(line, 10);
|
|
15150
15449
|
if (!Number.isInteger(lineNumber) || lineNumber < 1) {
|
|
15151
|
-
console.error(
|
|
15450
|
+
console.error(chalk119.red(`Invalid line number: ${line}`));
|
|
15152
15451
|
process.exitCode = 1;
|
|
15153
15452
|
return;
|
|
15154
15453
|
}
|
|
@@ -15156,20 +15455,20 @@ function codeCommentSet(file, line, text17) {
|
|
|
15156
15455
|
const marker = hash ? "#" : "//";
|
|
15157
15456
|
const validation = validateCommentText(text17, hash);
|
|
15158
15457
|
if (!validation.ok) {
|
|
15159
|
-
console.error(
|
|
15160
|
-
console.error(
|
|
15458
|
+
console.error(chalk119.red(`Refused: ${validation.reason}`));
|
|
15459
|
+
console.error(chalk119.red("No pin issued."));
|
|
15161
15460
|
process.exitCode = 1;
|
|
15162
15461
|
return;
|
|
15163
15462
|
}
|
|
15164
15463
|
console.error(
|
|
15165
|
-
|
|
15464
|
+
chalk119.yellow.bold(
|
|
15166
15465
|
"THIS IS YOUR LAST CHANCE TO RECONSIDER BEFORE INVOLVING A HUMAN.\nRequesting this pin pages a real person to approve a comment. DO NOT WASTE THEIR TIME.\nYou had BETTER BE RIGHT that this comment is genuinely necessary.\n\nComments are a last resort, not a habit. Almost every comment you reach for is a sign\nthe code should be clearer instead. Before a human is pulled in, ask whether a better\nname, a smaller function, or a test would make the comment redundant. ONLY if you are\ncertain this one line earns its keep should you proceed to the confirm step below."
|
|
15167
15466
|
)
|
|
15168
15467
|
);
|
|
15169
15468
|
const delivered = issuePin(file, lineNumber, validation.text);
|
|
15170
15469
|
if (!delivered) {
|
|
15171
15470
|
console.error(
|
|
15172
|
-
|
|
15471
|
+
chalk119.red(
|
|
15173
15472
|
"Could not deliver the confirmation pin via notification.\nThe comment cannot be confirmed until the notification channel works."
|
|
15174
15473
|
)
|
|
15175
15474
|
);
|
|
@@ -15179,7 +15478,7 @@ function codeCommentSet(file, line, text17) {
|
|
|
15179
15478
|
console.log(
|
|
15180
15479
|
`A confirmation pin was sent to your desktop notifications.
|
|
15181
15480
|
To insert "${marker} ${validation.text}" at ${file}:${lineNumber}, run:
|
|
15182
|
-
${
|
|
15481
|
+
${chalk119.cyan(" assist code-comment confirm <PIN>")}
|
|
15183
15482
|
using the pin from that notification.`
|
|
15184
15483
|
);
|
|
15185
15484
|
}
|
|
@@ -15258,15 +15557,15 @@ function registerCodexHook(program2) {
|
|
|
15258
15557
|
}
|
|
15259
15558
|
|
|
15260
15559
|
// src/commands/complexity/analyze.ts
|
|
15261
|
-
import
|
|
15560
|
+
import chalk128 from "chalk";
|
|
15262
15561
|
|
|
15263
15562
|
// src/commands/complexity/cyclomatic.ts
|
|
15264
|
-
import
|
|
15563
|
+
import chalk121 from "chalk";
|
|
15265
15564
|
|
|
15266
15565
|
// src/commands/complexity/shared/index.ts
|
|
15267
15566
|
import fs20 from "fs";
|
|
15268
15567
|
import path27 from "path";
|
|
15269
|
-
import
|
|
15568
|
+
import chalk120 from "chalk";
|
|
15270
15569
|
import ts5 from "typescript";
|
|
15271
15570
|
|
|
15272
15571
|
// src/commands/complexity/findSourceFiles.ts
|
|
@@ -15517,7 +15816,7 @@ function createSourceFromFile(filePath) {
|
|
|
15517
15816
|
function withSourceFiles(pattern2, callback, extraIgnore = []) {
|
|
15518
15817
|
const files = findSourceFiles2(pattern2, ".", extraIgnore);
|
|
15519
15818
|
if (files.length === 0) {
|
|
15520
|
-
console.log(
|
|
15819
|
+
console.log(chalk120.yellow("No files found matching pattern"));
|
|
15521
15820
|
return void 0;
|
|
15522
15821
|
}
|
|
15523
15822
|
return callback(files);
|
|
@@ -15550,11 +15849,11 @@ async function cyclomatic(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
15550
15849
|
results.sort((a, b) => b.complexity - a.complexity);
|
|
15551
15850
|
for (const { file, name, complexity } of results) {
|
|
15552
15851
|
const exceedsThreshold = options2.threshold !== void 0 && complexity > options2.threshold;
|
|
15553
|
-
const color = exceedsThreshold ?
|
|
15554
|
-
console.log(`${color(`${file}:${name}`)} \u2192 ${
|
|
15852
|
+
const color = exceedsThreshold ? chalk121.red : chalk121.white;
|
|
15853
|
+
console.log(`${color(`${file}:${name}`)} \u2192 ${chalk121.cyan(complexity)}`);
|
|
15555
15854
|
}
|
|
15556
15855
|
console.log(
|
|
15557
|
-
|
|
15856
|
+
chalk121.dim(
|
|
15558
15857
|
`
|
|
15559
15858
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
15560
15859
|
)
|
|
@@ -15566,7 +15865,7 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
15566
15865
|
}
|
|
15567
15866
|
|
|
15568
15867
|
// src/commands/complexity/halstead.ts
|
|
15569
|
-
import
|
|
15868
|
+
import chalk122 from "chalk";
|
|
15570
15869
|
async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
15571
15870
|
withSourceFiles(pattern2, (files) => {
|
|
15572
15871
|
const results = [];
|
|
@@ -15581,13 +15880,13 @@ async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
15581
15880
|
results.sort((a, b) => b.metrics.effort - a.metrics.effort);
|
|
15582
15881
|
for (const { file, name, metrics } of results) {
|
|
15583
15882
|
const exceedsThreshold = options2.threshold !== void 0 && metrics.volume > options2.threshold;
|
|
15584
|
-
const color = exceedsThreshold ?
|
|
15883
|
+
const color = exceedsThreshold ? chalk122.red : chalk122.white;
|
|
15585
15884
|
console.log(
|
|
15586
|
-
`${color(`${file}:${name}`)} \u2192 volume: ${
|
|
15885
|
+
`${color(`${file}:${name}`)} \u2192 volume: ${chalk122.cyan(metrics.volume.toFixed(1))}, difficulty: ${chalk122.yellow(metrics.difficulty.toFixed(1))}, effort: ${chalk122.magenta(metrics.effort.toFixed(1))}`
|
|
15587
15886
|
);
|
|
15588
15887
|
}
|
|
15589
15888
|
console.log(
|
|
15590
|
-
|
|
15889
|
+
chalk122.dim(
|
|
15591
15890
|
`
|
|
15592
15891
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
15593
15892
|
)
|
|
@@ -15656,15 +15955,15 @@ function collectFileMetrics(files) {
|
|
|
15656
15955
|
}
|
|
15657
15956
|
|
|
15658
15957
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
15659
|
-
import
|
|
15958
|
+
import chalk126 from "chalk";
|
|
15660
15959
|
|
|
15661
15960
|
// src/commands/complexity/maintainability/formatResultLine.ts
|
|
15662
|
-
import
|
|
15961
|
+
import chalk123 from "chalk";
|
|
15663
15962
|
function formatResultLine(entry, failing) {
|
|
15664
15963
|
const { file, avgMaintainability, minMaintainability, override } = entry;
|
|
15665
|
-
const name = failing ?
|
|
15666
|
-
const suffix = override !== void 0 ?
|
|
15667
|
-
return `${name} \u2192 avg: ${
|
|
15964
|
+
const name = failing ? chalk123.red(file) : chalk123.white(file);
|
|
15965
|
+
const suffix = override !== void 0 ? chalk123.magenta(` (override: ${override})`) : "";
|
|
15966
|
+
return `${name} \u2192 avg: ${chalk123.cyan(avgMaintainability.toFixed(1))}, min: ${chalk123.yellow(minMaintainability.toFixed(1))}${suffix}`;
|
|
15668
15967
|
}
|
|
15669
15968
|
|
|
15670
15969
|
// src/commands/complexity/maintainability/getMaintainabilityGitState.ts
|
|
@@ -15715,38 +16014,38 @@ function getMaintainabilityGitState() {
|
|
|
15715
16014
|
|
|
15716
16015
|
// src/commands/complexity/maintainability/printMaintainabilityFailure.ts
|
|
15717
16016
|
import path29 from "path";
|
|
15718
|
-
import
|
|
16017
|
+
import chalk124 from "chalk";
|
|
15719
16018
|
var extractTemplate = "assist refactor extract <file> <functionName> <destination> --apply";
|
|
15720
16019
|
function remediationLine(entry) {
|
|
15721
|
-
return ` ${
|
|
16020
|
+
return ` ${chalk124.bold(entry.file)}
|
|
15722
16021
|
Pick a responsibility and extract it:
|
|
15723
|
-
${
|
|
16022
|
+
${chalk124.cyan(extractTemplate)}`;
|
|
15724
16023
|
}
|
|
15725
16024
|
function cheatLine(entry, gitState) {
|
|
15726
16025
|
const shrank = gitState.shrunkFiles.has(path29.resolve(entry.file));
|
|
15727
16026
|
if (!shrank || gitState.newFileCreated) return "";
|
|
15728
16027
|
return `
|
|
15729
|
-
${
|
|
16028
|
+
${chalk124.red("\u2717 You shrank existing lines in this file without creating a new file. That cannot clear the gate \u2014 extract a responsibility to a new file.")}`;
|
|
15730
16029
|
}
|
|
15731
16030
|
function printMaintainabilityFailure(failing, gitState) {
|
|
15732
16031
|
const blocks = failing.map((entry) => `${remediationLine(entry)}${cheatLine(entry, gitState)}`).join("\n");
|
|
15733
16032
|
console.error(
|
|
15734
|
-
|
|
16033
|
+
chalk124.red(
|
|
15735
16034
|
`
|
|
15736
16035
|
Fail: ${failing.length} file(s) below threshold \u2192 extract a responsibility to a new file.
|
|
15737
16036
|
|
|
15738
16037
|
${blocks}
|
|
15739
16038
|
|
|
15740
|
-
${
|
|
16039
|
+
${chalk124.bold("Diagnose and fix one file at a time.")} Only a new file (Write) or 'assist refactor extract' clears this gate \u2014 editing the existing lines does not.`
|
|
15741
16040
|
)
|
|
15742
16041
|
);
|
|
15743
16042
|
}
|
|
15744
16043
|
|
|
15745
16044
|
// src/commands/complexity/maintainability/printMaintainabilityFormula.ts
|
|
15746
|
-
import
|
|
16045
|
+
import chalk125 from "chalk";
|
|
15747
16046
|
var MI_FORMULA = "171 - 5.2*ln(HalsteadVolume) - 0.23*CyclomaticComplexity - 16.2*ln(SLOC), clamped 0-100";
|
|
15748
16047
|
function printMaintainabilityFormula() {
|
|
15749
|
-
console.log(
|
|
16048
|
+
console.log(chalk125.dim(MI_FORMULA));
|
|
15750
16049
|
}
|
|
15751
16050
|
|
|
15752
16051
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
@@ -15755,7 +16054,7 @@ function displayMaintainabilityResults(results, threshold, gitState = getMaintai
|
|
|
15755
16054
|
if (!gating) {
|
|
15756
16055
|
printMaintainabilityFormula();
|
|
15757
16056
|
for (const entry of results) console.log(formatResultLine(entry, false));
|
|
15758
|
-
console.log(
|
|
16057
|
+
console.log(chalk126.dim(`
|
|
15759
16058
|
Analyzed ${results.length} files`));
|
|
15760
16059
|
return;
|
|
15761
16060
|
}
|
|
@@ -15764,14 +16063,14 @@ Analyzed ${results.length} files`));
|
|
|
15764
16063
|
return limit !== void 0 && r.minMaintainability < limit;
|
|
15765
16064
|
});
|
|
15766
16065
|
if (failing.length === 0) {
|
|
15767
|
-
console.log(
|
|
16066
|
+
console.log(chalk126.green("All files pass maintainability threshold"));
|
|
15768
16067
|
}
|
|
15769
16068
|
const passingOverrides = results.filter(
|
|
15770
16069
|
(r) => r.override !== void 0 && !failing.includes(r)
|
|
15771
16070
|
);
|
|
15772
16071
|
for (const entry of passingOverrides)
|
|
15773
16072
|
console.log(formatResultLine(entry, false));
|
|
15774
|
-
console.log(
|
|
16073
|
+
console.log(chalk126.dim(`
|
|
15775
16074
|
Analyzed ${results.length} files`));
|
|
15776
16075
|
if (failing.length > 0) {
|
|
15777
16076
|
printMaintainabilityFailure(failing, gitState);
|
|
@@ -15794,7 +16093,7 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
15794
16093
|
|
|
15795
16094
|
// src/commands/complexity/sloc.ts
|
|
15796
16095
|
import fs22 from "fs";
|
|
15797
|
-
import
|
|
16096
|
+
import chalk127 from "chalk";
|
|
15798
16097
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
15799
16098
|
withSourceFiles(pattern2, (files) => {
|
|
15800
16099
|
const results = [];
|
|
@@ -15810,12 +16109,12 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
15810
16109
|
results.sort((a, b) => b.lines - a.lines);
|
|
15811
16110
|
for (const { file, lines } of results) {
|
|
15812
16111
|
const exceedsThreshold = options2.threshold !== void 0 && lines > options2.threshold;
|
|
15813
|
-
const color = exceedsThreshold ?
|
|
15814
|
-
console.log(`${color(file)} \u2192 ${
|
|
16112
|
+
const color = exceedsThreshold ? chalk127.red : chalk127.white;
|
|
16113
|
+
console.log(`${color(file)} \u2192 ${chalk127.cyan(lines)} lines`);
|
|
15815
16114
|
}
|
|
15816
16115
|
const total = results.reduce((sum, r) => sum + r.lines, 0);
|
|
15817
16116
|
console.log(
|
|
15818
|
-
|
|
16117
|
+
chalk127.dim(`
|
|
15819
16118
|
Total: ${total} lines across ${files.length} files`)
|
|
15820
16119
|
);
|
|
15821
16120
|
if (hasViolation) {
|
|
@@ -15829,25 +16128,25 @@ async function analyze(pattern2) {
|
|
|
15829
16128
|
const searchPattern = pattern2.includes("*") || pattern2.includes("/") ? pattern2 : `**/${pattern2}`;
|
|
15830
16129
|
const files = findSourceFiles2(searchPattern);
|
|
15831
16130
|
if (files.length === 0) {
|
|
15832
|
-
console.log(
|
|
16131
|
+
console.log(chalk128.yellow("No files found matching pattern"));
|
|
15833
16132
|
return;
|
|
15834
16133
|
}
|
|
15835
16134
|
if (files.length === 1) {
|
|
15836
16135
|
const file = files[0];
|
|
15837
|
-
console.log(
|
|
16136
|
+
console.log(chalk128.bold.underline("SLOC"));
|
|
15838
16137
|
await sloc(file);
|
|
15839
16138
|
console.log();
|
|
15840
|
-
console.log(
|
|
16139
|
+
console.log(chalk128.bold.underline("Cyclomatic Complexity"));
|
|
15841
16140
|
await cyclomatic(file);
|
|
15842
16141
|
console.log();
|
|
15843
|
-
console.log(
|
|
16142
|
+
console.log(chalk128.bold.underline("Halstead Metrics"));
|
|
15844
16143
|
await halstead(file);
|
|
15845
16144
|
console.log();
|
|
15846
|
-
console.log(
|
|
16145
|
+
console.log(chalk128.bold.underline("Maintainability Index"));
|
|
15847
16146
|
await maintainability(file);
|
|
15848
16147
|
console.log();
|
|
15849
16148
|
console.log(
|
|
15850
|
-
|
|
16149
|
+
chalk128.dim(
|
|
15851
16150
|
"To improve the maintainability index, extract functions and logic out of this file into separate, smaller modules. Collapsing whitespace or removing comments is not the goal."
|
|
15852
16151
|
)
|
|
15853
16152
|
);
|
|
@@ -15898,7 +16197,7 @@ function configList() {
|
|
|
15898
16197
|
}
|
|
15899
16198
|
|
|
15900
16199
|
// src/commands/config/configGet.ts
|
|
15901
|
-
import
|
|
16200
|
+
import chalk129 from "chalk";
|
|
15902
16201
|
function configGet(key) {
|
|
15903
16202
|
console.log(
|
|
15904
16203
|
formatOutput(
|
|
@@ -15915,12 +16214,12 @@ function requireNestedValue(config, key) {
|
|
|
15915
16214
|
return value;
|
|
15916
16215
|
}
|
|
15917
16216
|
function exitKeyNotSet(key) {
|
|
15918
|
-
console.error(
|
|
16217
|
+
console.error(chalk129.red(`Key "${key}" is not set`));
|
|
15919
16218
|
process.exit(1);
|
|
15920
16219
|
}
|
|
15921
16220
|
|
|
15922
16221
|
// src/commands/config/configSet.ts
|
|
15923
|
-
import
|
|
16222
|
+
import chalk131 from "chalk";
|
|
15924
16223
|
|
|
15925
16224
|
// src/shared/resolveNamedRepoWriteLabel.ts
|
|
15926
16225
|
var UnknownRepoConfigError = class extends Error {
|
|
@@ -15945,9 +16244,9 @@ function resolveNamedRepoWriteLabel(globalRaw, name) {
|
|
|
15945
16244
|
}
|
|
15946
16245
|
|
|
15947
16246
|
// src/commands/config/exitWithConfigErrors.ts
|
|
15948
|
-
import
|
|
16247
|
+
import chalk130 from "chalk";
|
|
15949
16248
|
function exitWithConfigErrors(errors) {
|
|
15950
|
-
for (const error of errors) console.error(
|
|
16249
|
+
for (const error of errors) console.error(chalk130.red(error));
|
|
15951
16250
|
process.exit(1);
|
|
15952
16251
|
}
|
|
15953
16252
|
|
|
@@ -15983,19 +16282,19 @@ function resolveRepoTarget(key, value, repo) {
|
|
|
15983
16282
|
function configSet(key, value, options2 = {}) {
|
|
15984
16283
|
if (options2.repo !== void 0 && !options2.global) {
|
|
15985
16284
|
console.error(
|
|
15986
|
-
|
|
16285
|
+
chalk131.red("--repo writes to the global config; add -g (e.g. -g --repo)")
|
|
15987
16286
|
);
|
|
15988
16287
|
process.exit(1);
|
|
15989
16288
|
}
|
|
15990
16289
|
const resolved = resolveRepoTarget(key, value, options2.repo);
|
|
15991
16290
|
if (resolved.value === void 0) {
|
|
15992
|
-
console.error(
|
|
16291
|
+
console.error(chalk131.red(`Missing required argument for '${resolved.key}'`));
|
|
15993
16292
|
process.exit(1);
|
|
15994
16293
|
}
|
|
15995
16294
|
const coerced = coerceValue(resolved.value);
|
|
15996
16295
|
const target = resolved.useRepo ? `repo: ${applyRepoConfigSet(resolved.key, coerced, resolved.repoName)}` : applyOrExit(resolved.key, coerced, options2.global ?? false);
|
|
15997
16296
|
console.log(
|
|
15998
|
-
|
|
16297
|
+
chalk131.green(`Set ${resolved.key} = ${JSON.stringify(coerced)} (${target})`)
|
|
15999
16298
|
);
|
|
16000
16299
|
}
|
|
16001
16300
|
function applyOrExit(key, coerced, global) {
|
|
@@ -16010,17 +16309,17 @@ function coerceValue(value) {
|
|
|
16010
16309
|
}
|
|
16011
16310
|
|
|
16012
16311
|
// src/commands/config/configUnset.ts
|
|
16013
|
-
import
|
|
16312
|
+
import chalk132 from "chalk";
|
|
16014
16313
|
function configUnset(key, options2 = {}) {
|
|
16015
16314
|
const result = applyConfigUnset(key, options2.global ?? false);
|
|
16016
16315
|
if (!result.ok) exitWithConfigErrors(result.errors);
|
|
16017
16316
|
if (!result.removed) {
|
|
16018
16317
|
console.log(
|
|
16019
|
-
|
|
16318
|
+
chalk132.yellow(`${key} is not set in the ${result.target} config`)
|
|
16020
16319
|
);
|
|
16021
16320
|
return;
|
|
16022
16321
|
}
|
|
16023
|
-
console.log(
|
|
16322
|
+
console.log(chalk132.green(`Unset ${key} (${result.target})`));
|
|
16024
16323
|
}
|
|
16025
16324
|
|
|
16026
16325
|
// src/commands/registerConfig.ts
|
|
@@ -16036,40 +16335,40 @@ function registerConfig(program2) {
|
|
|
16036
16335
|
}
|
|
16037
16336
|
|
|
16038
16337
|
// src/commands/db/reportMigrationStatus.ts
|
|
16039
|
-
import
|
|
16338
|
+
import chalk133 from "chalk";
|
|
16040
16339
|
function reportApplied(applied) {
|
|
16041
16340
|
if (applied.length === 0) {
|
|
16042
|
-
console.error(
|
|
16341
|
+
console.error(chalk133.green("Database is up to date; nothing to apply."));
|
|
16043
16342
|
return;
|
|
16044
16343
|
}
|
|
16045
16344
|
for (const migration of applied) {
|
|
16046
16345
|
console.error(
|
|
16047
|
-
|
|
16346
|
+
chalk133.green(`Applied migration ${migration.id} (${migration.name}).`)
|
|
16048
16347
|
);
|
|
16049
16348
|
}
|
|
16050
16349
|
}
|
|
16051
16350
|
function reportMigrationStatus(status3) {
|
|
16052
16351
|
if (status3.state === "in-sync") {
|
|
16053
16352
|
console.error(
|
|
16054
|
-
|
|
16353
|
+
chalk133.green(`In sync at migration ${status3.version} (latest).`)
|
|
16055
16354
|
);
|
|
16056
16355
|
return;
|
|
16057
16356
|
}
|
|
16058
16357
|
if (status3.state === "behind") {
|
|
16059
16358
|
console.error(
|
|
16060
|
-
|
|
16359
|
+
chalk133.yellow(
|
|
16061
16360
|
`Behind: applied ${status3.applied}, build expects ${status3.expected}.`
|
|
16062
16361
|
)
|
|
16063
16362
|
);
|
|
16064
16363
|
console.error(
|
|
16065
|
-
|
|
16364
|
+
chalk133.yellow(
|
|
16066
16365
|
`Pending: ${status3.pending.join(", ")}. Run \`assist db migrate\`.`
|
|
16067
16366
|
)
|
|
16068
16367
|
);
|
|
16069
16368
|
return;
|
|
16070
16369
|
}
|
|
16071
16370
|
console.error(
|
|
16072
|
-
|
|
16371
|
+
chalk133.red(
|
|
16073
16372
|
`Ahead: applied ${status3.applied}, build knows ${status3.expected}. Update assist.`
|
|
16074
16373
|
)
|
|
16075
16374
|
);
|
|
@@ -16104,7 +16403,7 @@ function registerDb(program2) {
|
|
|
16104
16403
|
|
|
16105
16404
|
// src/commands/dbMigration/dbMigrationConfirm.ts
|
|
16106
16405
|
import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs";
|
|
16107
|
-
import
|
|
16406
|
+
import chalk134 from "chalk";
|
|
16108
16407
|
|
|
16109
16408
|
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
16110
16409
|
import { join as join35 } from "path";
|
|
@@ -16135,7 +16434,7 @@ function dbMigrationConfirm(pin) {
|
|
|
16135
16434
|
sweepRestrictedDir();
|
|
16136
16435
|
const state = readMigrationPinState(pin);
|
|
16137
16436
|
if (!state) {
|
|
16138
|
-
console.error(
|
|
16437
|
+
console.error(chalk134.red(`No pending migration unlock for pin: ${pin}`));
|
|
16139
16438
|
process.exitCode = 1;
|
|
16140
16439
|
return;
|
|
16141
16440
|
}
|
|
@@ -16145,7 +16444,7 @@ function dbMigrationConfirm(pin) {
|
|
|
16145
16444
|
);
|
|
16146
16445
|
unlinkSync9(getMigrationPinPath(pin));
|
|
16147
16446
|
console.log(
|
|
16148
|
-
|
|
16447
|
+
chalk134.green(
|
|
16149
16448
|
`Approved creation of migration ${state.migrationId}. The next write of that migration module will be allowed once.`
|
|
16150
16449
|
)
|
|
16151
16450
|
);
|
|
@@ -16154,7 +16453,7 @@ function dbMigrationConfirm(pin) {
|
|
|
16154
16453
|
// src/commands/dbMigration/dbMigrationUnlock.ts
|
|
16155
16454
|
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync27 } from "fs";
|
|
16156
16455
|
import { randomInt as randomInt2 } from "crypto";
|
|
16157
|
-
import
|
|
16456
|
+
import chalk135 from "chalk";
|
|
16158
16457
|
|
|
16159
16458
|
// src/commands/dbMigration/nextMigrationId.ts
|
|
16160
16459
|
function nextMigrationId() {
|
|
@@ -16169,7 +16468,7 @@ function dbMigrationUnlock() {
|
|
|
16169
16468
|
sweepRestrictedDir();
|
|
16170
16469
|
writeFileSync27(getMigrationPinPath(pin), JSON.stringify({ pin, migrationId }));
|
|
16171
16470
|
console.error(
|
|
16172
|
-
|
|
16471
|
+
chalk135.yellow.bold(
|
|
16173
16472
|
"THIS IS YOUR LAST CHANCE TO RECONSIDER BEFORE INVOLVING A HUMAN.\nRequesting this pin pages a real person to approve a new database migration.\nA schema change is hard to reverse once shipped. You had BETTER have confirmed\nthe change with the user and be certain this migration is genuinely necessary."
|
|
16174
16473
|
)
|
|
16175
16474
|
);
|
|
@@ -16179,7 +16478,7 @@ function dbMigrationUnlock() {
|
|
|
16179
16478
|
});
|
|
16180
16479
|
if (!delivered) {
|
|
16181
16480
|
console.error(
|
|
16182
|
-
|
|
16481
|
+
chalk135.red(
|
|
16183
16482
|
"Could not deliver the confirmation pin via notification.\nThe migration cannot be approved until the notification channel works."
|
|
16184
16483
|
)
|
|
16185
16484
|
);
|
|
@@ -16189,7 +16488,7 @@ function dbMigrationUnlock() {
|
|
|
16189
16488
|
console.log(
|
|
16190
16489
|
`A confirmation pin was sent to your desktop notifications.
|
|
16191
16490
|
To approve creating migration ${migrationId}, run:
|
|
16192
|
-
${
|
|
16491
|
+
${chalk135.cyan(" assist db-migration confirm <PIN>")}
|
|
16193
16492
|
using the pin from that notification.`
|
|
16194
16493
|
);
|
|
16195
16494
|
}
|
|
@@ -16209,7 +16508,7 @@ function registerDbMigration(parent) {
|
|
|
16209
16508
|
|
|
16210
16509
|
// src/commands/deploy/redirect.ts
|
|
16211
16510
|
import { existsSync as existsSync35, readFileSync as readFileSync30, writeFileSync as writeFileSync28 } from "fs";
|
|
16212
|
-
import
|
|
16511
|
+
import chalk136 from "chalk";
|
|
16213
16512
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
16214
16513
|
if (!window.location.pathname.endsWith('/')) {
|
|
16215
16514
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -16218,23 +16517,23 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
16218
16517
|
function redirect() {
|
|
16219
16518
|
const indexPath = "index.html";
|
|
16220
16519
|
if (!existsSync35(indexPath)) {
|
|
16221
|
-
console.log(
|
|
16520
|
+
console.log(chalk136.yellow("No index.html found"));
|
|
16222
16521
|
return;
|
|
16223
16522
|
}
|
|
16224
16523
|
const content = readFileSync30(indexPath, "utf8");
|
|
16225
16524
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
16226
|
-
console.log(
|
|
16525
|
+
console.log(chalk136.dim("Trailing slash script already present"));
|
|
16227
16526
|
return;
|
|
16228
16527
|
}
|
|
16229
16528
|
const headCloseIndex = content.indexOf("</head>");
|
|
16230
16529
|
if (headCloseIndex === -1) {
|
|
16231
|
-
console.log(
|
|
16530
|
+
console.log(chalk136.red("Could not find </head> tag in index.html"));
|
|
16232
16531
|
return;
|
|
16233
16532
|
}
|
|
16234
16533
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
16235
16534
|
${content.slice(headCloseIndex)}`;
|
|
16236
16535
|
writeFileSync28(indexPath, newContent);
|
|
16237
|
-
console.log(
|
|
16536
|
+
console.log(chalk136.green("Added trailing slash redirect to index.html"));
|
|
16238
16537
|
}
|
|
16239
16538
|
|
|
16240
16539
|
// src/commands/registerDeploy.ts
|
|
@@ -16261,7 +16560,7 @@ function loadBlogSkipDays(repoName) {
|
|
|
16261
16560
|
|
|
16262
16561
|
// src/commands/devlog/shared.ts
|
|
16263
16562
|
import { execSync as execSync35 } from "child_process";
|
|
16264
|
-
import
|
|
16563
|
+
import chalk137 from "chalk";
|
|
16265
16564
|
|
|
16266
16565
|
// src/shared/getRepoName.ts
|
|
16267
16566
|
import { existsSync as existsSync36, readFileSync as readFileSync31 } from "fs";
|
|
@@ -16370,13 +16669,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
16370
16669
|
}
|
|
16371
16670
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
16372
16671
|
for (const commit2 of commits2) {
|
|
16373
|
-
console.log(` ${
|
|
16672
|
+
console.log(` ${chalk137.yellow(commit2.hash)} ${commit2.message}`);
|
|
16374
16673
|
if (verbose) {
|
|
16375
16674
|
const visibleFiles = commit2.files.filter(
|
|
16376
16675
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
16377
16676
|
);
|
|
16378
16677
|
for (const file of visibleFiles) {
|
|
16379
|
-
console.log(` ${
|
|
16678
|
+
console.log(` ${chalk137.dim(file)}`);
|
|
16380
16679
|
}
|
|
16381
16680
|
}
|
|
16382
16681
|
}
|
|
@@ -16401,15 +16700,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
16401
16700
|
}
|
|
16402
16701
|
|
|
16403
16702
|
// src/commands/devlog/list/printDateHeader.ts
|
|
16404
|
-
import
|
|
16703
|
+
import chalk138 from "chalk";
|
|
16405
16704
|
function printDateHeader(date, isSkipped, entries) {
|
|
16406
16705
|
if (isSkipped) {
|
|
16407
|
-
console.log(`${
|
|
16706
|
+
console.log(`${chalk138.bold.blue(date)} ${chalk138.dim("skipped")}`);
|
|
16408
16707
|
} else if (entries && entries.length > 0) {
|
|
16409
|
-
const entryInfo = entries.map((e) => `${
|
|
16410
|
-
console.log(`${
|
|
16708
|
+
const entryInfo = entries.map((e) => `${chalk138.green(e.version)} ${e.title}`).join(" | ");
|
|
16709
|
+
console.log(`${chalk138.bold.blue(date)} ${entryInfo}`);
|
|
16411
16710
|
} else {
|
|
16412
|
-
console.log(`${
|
|
16711
|
+
console.log(`${chalk138.bold.blue(date)} ${chalk138.red("\u26A0 devlog missing")}`);
|
|
16413
16712
|
}
|
|
16414
16713
|
}
|
|
16415
16714
|
|
|
@@ -16513,24 +16812,24 @@ function bumpVersion(version2, type) {
|
|
|
16513
16812
|
|
|
16514
16813
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
16515
16814
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
16516
|
-
import
|
|
16815
|
+
import chalk140 from "chalk";
|
|
16517
16816
|
|
|
16518
16817
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
16519
|
-
import
|
|
16818
|
+
import chalk139 from "chalk";
|
|
16520
16819
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
16521
16820
|
if (conventional && firstHash) {
|
|
16522
16821
|
const version2 = getVersionAtCommit(firstHash);
|
|
16523
16822
|
if (version2) {
|
|
16524
|
-
console.log(`${
|
|
16823
|
+
console.log(`${chalk139.bold("version:")} ${stripToMinor(version2)}`);
|
|
16525
16824
|
} else {
|
|
16526
|
-
console.log(`${
|
|
16825
|
+
console.log(`${chalk139.bold("version:")} ${chalk139.red("unknown")}`);
|
|
16527
16826
|
}
|
|
16528
16827
|
} else if (patchVersion && minorVersion) {
|
|
16529
16828
|
console.log(
|
|
16530
|
-
`${
|
|
16829
|
+
`${chalk139.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
16531
16830
|
);
|
|
16532
16831
|
} else {
|
|
16533
|
-
console.log(`${
|
|
16832
|
+
console.log(`${chalk139.bold("version:")} v0.1 (initial)`);
|
|
16534
16833
|
}
|
|
16535
16834
|
}
|
|
16536
16835
|
|
|
@@ -16578,16 +16877,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
16578
16877
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
16579
16878
|
}
|
|
16580
16879
|
function logName(repoName) {
|
|
16581
|
-
console.log(`${
|
|
16880
|
+
console.log(`${chalk140.bold("name:")} ${repoName}`);
|
|
16582
16881
|
}
|
|
16583
16882
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
16584
16883
|
logName(ctx.repoName);
|
|
16585
16884
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
16586
|
-
console.log(
|
|
16885
|
+
console.log(chalk140.bold.blue(targetDate));
|
|
16587
16886
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
16588
16887
|
}
|
|
16589
16888
|
function logNoCommits(lastInfo) {
|
|
16590
|
-
console.log(
|
|
16889
|
+
console.log(chalk140.dim(noCommitsMessage(!!lastInfo)));
|
|
16591
16890
|
}
|
|
16592
16891
|
|
|
16593
16892
|
// src/commands/devlog/next/index.ts
|
|
@@ -16628,11 +16927,11 @@ function next2(options2) {
|
|
|
16628
16927
|
import { execSync as execSync37 } from "child_process";
|
|
16629
16928
|
|
|
16630
16929
|
// src/commands/devlog/repos/printReposTable.ts
|
|
16631
|
-
import
|
|
16930
|
+
import chalk141 from "chalk";
|
|
16632
16931
|
function colorStatus(status3) {
|
|
16633
|
-
if (status3 === "missing") return
|
|
16634
|
-
if (status3 === "outdated") return
|
|
16635
|
-
return
|
|
16932
|
+
if (status3 === "missing") return chalk141.red(status3);
|
|
16933
|
+
if (status3 === "outdated") return chalk141.yellow(status3);
|
|
16934
|
+
return chalk141.green(status3);
|
|
16636
16935
|
}
|
|
16637
16936
|
function formatRow(row, nameWidth) {
|
|
16638
16937
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -16646,8 +16945,8 @@ function printReposTable(rows) {
|
|
|
16646
16945
|
"Last Devlog".padEnd(11),
|
|
16647
16946
|
"Status"
|
|
16648
16947
|
].join(" ");
|
|
16649
|
-
console.log(
|
|
16650
|
-
console.log(
|
|
16948
|
+
console.log(chalk141.dim(header));
|
|
16949
|
+
console.log(chalk141.dim("-".repeat(header.length)));
|
|
16651
16950
|
for (const row of rows) {
|
|
16652
16951
|
console.log(formatRow(row, nameWidth));
|
|
16653
16952
|
}
|
|
@@ -16705,14 +17004,14 @@ function repos(options2) {
|
|
|
16705
17004
|
// src/commands/devlog/skip.ts
|
|
16706
17005
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
16707
17006
|
import { join as join39 } from "path";
|
|
16708
|
-
import
|
|
17007
|
+
import chalk142 from "chalk";
|
|
16709
17008
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
16710
17009
|
function getBlogConfigPath() {
|
|
16711
17010
|
return join39(BLOG_REPO_ROOT, "assist.yml");
|
|
16712
17011
|
}
|
|
16713
17012
|
function skip(date) {
|
|
16714
17013
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
16715
|
-
console.log(
|
|
17014
|
+
console.log(chalk142.red("Invalid date format. Use YYYY-MM-DD"));
|
|
16716
17015
|
process.exit(1);
|
|
16717
17016
|
}
|
|
16718
17017
|
const repoName = getRepoName();
|
|
@@ -16723,7 +17022,7 @@ function skip(date) {
|
|
|
16723
17022
|
const skipDays = skip2[repoName] ?? [];
|
|
16724
17023
|
if (skipDays.includes(date)) {
|
|
16725
17024
|
console.log(
|
|
16726
|
-
|
|
17025
|
+
chalk142.yellow(`${date} is already in skip list for ${repoName}`)
|
|
16727
17026
|
);
|
|
16728
17027
|
return;
|
|
16729
17028
|
}
|
|
@@ -16733,20 +17032,20 @@ function skip(date) {
|
|
|
16733
17032
|
devlog.skip = skip2;
|
|
16734
17033
|
config.devlog = devlog;
|
|
16735
17034
|
writeFileSync29(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
16736
|
-
console.log(
|
|
17035
|
+
console.log(chalk142.green(`Added ${date} to skip list for ${repoName}`));
|
|
16737
17036
|
}
|
|
16738
17037
|
|
|
16739
17038
|
// src/commands/devlog/version.ts
|
|
16740
|
-
import
|
|
17039
|
+
import chalk143 from "chalk";
|
|
16741
17040
|
function version() {
|
|
16742
17041
|
const config = loadConfig();
|
|
16743
17042
|
const name = getRepoName();
|
|
16744
17043
|
const lastInfo = getLastVersionInfo(name, config);
|
|
16745
17044
|
const lastVersion = lastInfo?.version ?? null;
|
|
16746
17045
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
16747
|
-
console.log(`${
|
|
16748
|
-
console.log(`${
|
|
16749
|
-
console.log(`${
|
|
17046
|
+
console.log(`${chalk143.bold("name:")} ${name}`);
|
|
17047
|
+
console.log(`${chalk143.bold("last:")} ${lastVersion ?? chalk143.dim("none")}`);
|
|
17048
|
+
console.log(`${chalk143.bold("next:")} ${nextVersion ?? chalk143.dim("none")}`);
|
|
16750
17049
|
}
|
|
16751
17050
|
|
|
16752
17051
|
// src/commands/devlog/devlogConfigHelp.ts
|
|
@@ -16790,7 +17089,7 @@ function registerDevlog(program2) {
|
|
|
16790
17089
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
16791
17090
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5 } from "fs";
|
|
16792
17091
|
import { join as join40 } from "path";
|
|
16793
|
-
import
|
|
17092
|
+
import chalk144 from "chalk";
|
|
16794
17093
|
|
|
16795
17094
|
// src/shared/findRepoRoot.ts
|
|
16796
17095
|
import { existsSync as existsSync37 } from "fs";
|
|
@@ -16853,14 +17152,14 @@ function checkBuildLocks(startDir) {
|
|
|
16853
17152
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
16854
17153
|
if (locked) {
|
|
16855
17154
|
console.error(
|
|
16856
|
-
|
|
17155
|
+
chalk144.red("Build output locked (is VS debugging?): ") + locked
|
|
16857
17156
|
);
|
|
16858
17157
|
process.exit(1);
|
|
16859
17158
|
}
|
|
16860
17159
|
}
|
|
16861
17160
|
async function checkBuildLocksCommand() {
|
|
16862
17161
|
checkBuildLocks();
|
|
16863
|
-
console.log(
|
|
17162
|
+
console.log(chalk144.green("No build locks detected"));
|
|
16864
17163
|
}
|
|
16865
17164
|
|
|
16866
17165
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -16959,30 +17258,30 @@ function escapeRegex(s) {
|
|
|
16959
17258
|
}
|
|
16960
17259
|
|
|
16961
17260
|
// src/commands/dotnet/printTree.ts
|
|
16962
|
-
import
|
|
17261
|
+
import chalk145 from "chalk";
|
|
16963
17262
|
function printNodes(nodes, prefix2) {
|
|
16964
17263
|
for (let i = 0; i < nodes.length; i++) {
|
|
16965
17264
|
const isLast = i === nodes.length - 1;
|
|
16966
17265
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
16967
17266
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
16968
17267
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
16969
|
-
const label2 = isMissing ?
|
|
17268
|
+
const label2 = isMissing ? chalk145.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
16970
17269
|
console.log(`${prefix2}${connector}${label2}`);
|
|
16971
17270
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
16972
17271
|
}
|
|
16973
17272
|
}
|
|
16974
17273
|
function printTree(tree, totalCount, solutions) {
|
|
16975
|
-
console.log(
|
|
16976
|
-
console.log(
|
|
17274
|
+
console.log(chalk145.bold("\nProject Dependency Tree"));
|
|
17275
|
+
console.log(chalk145.cyan(tree.relativePath));
|
|
16977
17276
|
printNodes(tree.children, "");
|
|
16978
|
-
console.log(
|
|
17277
|
+
console.log(chalk145.dim(`
|
|
16979
17278
|
${totalCount} projects total (including root)`));
|
|
16980
|
-
console.log(
|
|
17279
|
+
console.log(chalk145.bold("\nSolution Membership"));
|
|
16981
17280
|
if (solutions.length === 0) {
|
|
16982
|
-
console.log(
|
|
17281
|
+
console.log(chalk145.yellow(" Not found in any .sln"));
|
|
16983
17282
|
} else {
|
|
16984
17283
|
for (const sln of solutions) {
|
|
16985
|
-
console.log(` ${
|
|
17284
|
+
console.log(` ${chalk145.green(sln)}`);
|
|
16986
17285
|
}
|
|
16987
17286
|
}
|
|
16988
17287
|
console.log();
|
|
@@ -17011,16 +17310,16 @@ function printJson(tree, totalCount, solutions) {
|
|
|
17011
17310
|
// src/commands/dotnet/resolveCsproj.ts
|
|
17012
17311
|
import { existsSync as existsSync38 } from "fs";
|
|
17013
17312
|
import path33 from "path";
|
|
17014
|
-
import
|
|
17313
|
+
import chalk146 from "chalk";
|
|
17015
17314
|
function resolveCsproj(csprojPath) {
|
|
17016
17315
|
const resolved = path33.resolve(csprojPath);
|
|
17017
17316
|
if (!existsSync38(resolved)) {
|
|
17018
|
-
console.error(
|
|
17317
|
+
console.error(chalk146.red(`File not found: ${resolved}`));
|
|
17019
17318
|
process.exit(1);
|
|
17020
17319
|
}
|
|
17021
17320
|
const repoRoot = findRepoRoot(path33.dirname(resolved));
|
|
17022
17321
|
if (!repoRoot) {
|
|
17023
|
-
console.error(
|
|
17322
|
+
console.error(chalk146.red("Could not find git repository root"));
|
|
17024
17323
|
process.exit(1);
|
|
17025
17324
|
}
|
|
17026
17325
|
return { resolved, repoRoot };
|
|
@@ -17070,12 +17369,12 @@ function getChangedCsFiles(scope) {
|
|
|
17070
17369
|
}
|
|
17071
17370
|
|
|
17072
17371
|
// src/commands/dotnet/inSln.ts
|
|
17073
|
-
import
|
|
17372
|
+
import chalk147 from "chalk";
|
|
17074
17373
|
async function inSln(csprojPath) {
|
|
17075
17374
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
17076
17375
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
17077
17376
|
if (solutions.length === 0) {
|
|
17078
|
-
console.log(
|
|
17377
|
+
console.log(chalk147.yellow("Not found in any .sln file"));
|
|
17079
17378
|
process.exit(1);
|
|
17080
17379
|
}
|
|
17081
17380
|
for (const sln of solutions) {
|
|
@@ -17084,7 +17383,7 @@ async function inSln(csprojPath) {
|
|
|
17084
17383
|
}
|
|
17085
17384
|
|
|
17086
17385
|
// src/commands/dotnet/inspect.ts
|
|
17087
|
-
import
|
|
17386
|
+
import chalk153 from "chalk";
|
|
17088
17387
|
|
|
17089
17388
|
// src/shared/formatElapsed.ts
|
|
17090
17389
|
function formatElapsed(ms) {
|
|
@@ -17096,12 +17395,12 @@ function formatElapsed(ms) {
|
|
|
17096
17395
|
}
|
|
17097
17396
|
|
|
17098
17397
|
// src/commands/dotnet/displayIssues.ts
|
|
17099
|
-
import
|
|
17398
|
+
import chalk148 from "chalk";
|
|
17100
17399
|
var SEVERITY_COLOR = {
|
|
17101
|
-
ERROR:
|
|
17102
|
-
WARNING:
|
|
17103
|
-
SUGGESTION:
|
|
17104
|
-
HINT:
|
|
17400
|
+
ERROR: chalk148.red,
|
|
17401
|
+
WARNING: chalk148.yellow,
|
|
17402
|
+
SUGGESTION: chalk148.cyan,
|
|
17403
|
+
HINT: chalk148.dim
|
|
17105
17404
|
};
|
|
17106
17405
|
function groupByFile(issues) {
|
|
17107
17406
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -17117,15 +17416,15 @@ function groupByFile(issues) {
|
|
|
17117
17416
|
}
|
|
17118
17417
|
function displayIssues(issues) {
|
|
17119
17418
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
17120
|
-
console.log(
|
|
17419
|
+
console.log(chalk148.bold(file));
|
|
17121
17420
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
17122
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
17421
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk148.white;
|
|
17123
17422
|
console.log(
|
|
17124
|
-
` ${
|
|
17423
|
+
` ${chalk148.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
17125
17424
|
);
|
|
17126
17425
|
}
|
|
17127
17426
|
}
|
|
17128
|
-
console.log(
|
|
17427
|
+
console.log(chalk148.dim(`
|
|
17129
17428
|
${issues.length} issue(s) found`));
|
|
17130
17429
|
}
|
|
17131
17430
|
|
|
@@ -17184,12 +17483,12 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
17184
17483
|
// src/commands/dotnet/resolveSolution.ts
|
|
17185
17484
|
import { existsSync as existsSync39 } from "fs";
|
|
17186
17485
|
import path34 from "path";
|
|
17187
|
-
import
|
|
17486
|
+
import chalk150 from "chalk";
|
|
17188
17487
|
|
|
17189
17488
|
// src/commands/dotnet/findSolution.ts
|
|
17190
17489
|
import { readdirSync as readdirSync7 } from "fs";
|
|
17191
17490
|
import { dirname as dirname22, join as join41 } from "path";
|
|
17192
|
-
import
|
|
17491
|
+
import chalk149 from "chalk";
|
|
17193
17492
|
function findSlnInDir(dir) {
|
|
17194
17493
|
try {
|
|
17195
17494
|
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) => join41(dir, f));
|
|
@@ -17205,17 +17504,17 @@ function findSolution() {
|
|
|
17205
17504
|
const slnFiles = findSlnInDir(current);
|
|
17206
17505
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
17207
17506
|
if (slnFiles.length > 1) {
|
|
17208
|
-
console.error(
|
|
17507
|
+
console.error(chalk149.red(`Multiple .sln files found in ${current}:`));
|
|
17209
17508
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
17210
17509
|
console.error(
|
|
17211
|
-
|
|
17510
|
+
chalk149.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
17212
17511
|
);
|
|
17213
17512
|
process.exit(1);
|
|
17214
17513
|
}
|
|
17215
17514
|
if (current === ceiling) break;
|
|
17216
17515
|
current = dirname22(current);
|
|
17217
17516
|
}
|
|
17218
|
-
console.error(
|
|
17517
|
+
console.error(chalk149.red("No .sln file found between cwd and repo root"));
|
|
17219
17518
|
process.exit(1);
|
|
17220
17519
|
}
|
|
17221
17520
|
|
|
@@ -17224,7 +17523,7 @@ function resolveSolution(sln) {
|
|
|
17224
17523
|
if (sln) {
|
|
17225
17524
|
const resolved = path34.resolve(sln);
|
|
17226
17525
|
if (!existsSync39(resolved)) {
|
|
17227
|
-
console.error(
|
|
17526
|
+
console.error(chalk150.red(`Solution file not found: ${resolved}`));
|
|
17228
17527
|
process.exit(1);
|
|
17229
17528
|
}
|
|
17230
17529
|
return resolved;
|
|
@@ -17266,14 +17565,14 @@ import { execSync as execSync39 } from "child_process";
|
|
|
17266
17565
|
import { existsSync as existsSync40, readFileSync as readFileSync35, unlinkSync as unlinkSync10 } from "fs";
|
|
17267
17566
|
import { tmpdir as tmpdir4 } from "os";
|
|
17268
17567
|
import path35 from "path";
|
|
17269
|
-
import
|
|
17568
|
+
import chalk151 from "chalk";
|
|
17270
17569
|
function assertJbInstalled() {
|
|
17271
17570
|
try {
|
|
17272
17571
|
execSync39("jb inspectcode --version", { stdio: "pipe" });
|
|
17273
17572
|
} catch {
|
|
17274
|
-
console.error(
|
|
17573
|
+
console.error(chalk151.red("jb is not installed. Install with:"));
|
|
17275
17574
|
console.error(
|
|
17276
|
-
|
|
17575
|
+
chalk151.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
17277
17576
|
);
|
|
17278
17577
|
process.exit(1);
|
|
17279
17578
|
}
|
|
@@ -17291,11 +17590,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
17291
17590
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
17292
17591
|
process.stderr.write(error.stderr);
|
|
17293
17592
|
}
|
|
17294
|
-
console.error(
|
|
17593
|
+
console.error(chalk151.red("jb inspectcode failed"));
|
|
17295
17594
|
process.exit(1);
|
|
17296
17595
|
}
|
|
17297
17596
|
if (!existsSync40(reportPath)) {
|
|
17298
|
-
console.error(
|
|
17597
|
+
console.error(chalk151.red("Report file not generated"));
|
|
17299
17598
|
process.exit(1);
|
|
17300
17599
|
}
|
|
17301
17600
|
const xml = readFileSync35(reportPath, "utf8");
|
|
@@ -17305,7 +17604,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
17305
17604
|
|
|
17306
17605
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
17307
17606
|
import { execSync as execSync40 } from "child_process";
|
|
17308
|
-
import
|
|
17607
|
+
import chalk152 from "chalk";
|
|
17309
17608
|
function resolveMsbuildPath() {
|
|
17310
17609
|
const { run: run4 } = loadConfig();
|
|
17311
17610
|
const configs = resolveRunConfigs(run4, getConfigDir());
|
|
@@ -17317,9 +17616,9 @@ function assertMsbuildInstalled() {
|
|
|
17317
17616
|
try {
|
|
17318
17617
|
execSync40(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
17319
17618
|
} catch {
|
|
17320
|
-
console.error(
|
|
17619
|
+
console.error(chalk152.red(`msbuild not found at: ${msbuild}`));
|
|
17321
17620
|
console.error(
|
|
17322
|
-
|
|
17621
|
+
chalk152.yellow(
|
|
17323
17622
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
17324
17623
|
)
|
|
17325
17624
|
);
|
|
@@ -17366,17 +17665,17 @@ function runEngine(resolved, changedFiles2, options2) {
|
|
|
17366
17665
|
// src/commands/dotnet/inspect.ts
|
|
17367
17666
|
function logScope(changedFiles2) {
|
|
17368
17667
|
if (changedFiles2 === null) {
|
|
17369
|
-
console.log(
|
|
17668
|
+
console.log(chalk153.dim("Inspecting full solution..."));
|
|
17370
17669
|
} else {
|
|
17371
17670
|
console.log(
|
|
17372
|
-
|
|
17671
|
+
chalk153.dim(`Inspecting ${changedFiles2.length} changed file(s)...`)
|
|
17373
17672
|
);
|
|
17374
17673
|
}
|
|
17375
17674
|
}
|
|
17376
17675
|
function reportResults(issues, elapsed) {
|
|
17377
17676
|
if (issues.length > 0) displayIssues(issues);
|
|
17378
|
-
else console.log(
|
|
17379
|
-
console.log(
|
|
17677
|
+
else console.log(chalk153.green("No issues found"));
|
|
17678
|
+
console.log(chalk153.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
17380
17679
|
if (issues.length > 0) process.exit(1);
|
|
17381
17680
|
}
|
|
17382
17681
|
async function inspect(sln, options2) {
|
|
@@ -17387,7 +17686,7 @@ async function inspect(sln, options2) {
|
|
|
17387
17686
|
const scope = parseScope(options2.scope);
|
|
17388
17687
|
const changedFiles2 = getChangedCsFiles(scope);
|
|
17389
17688
|
if (changedFiles2 !== null && changedFiles2.length === 0) {
|
|
17390
|
-
console.log(
|
|
17689
|
+
console.log(chalk153.green("No changed .cs files found"));
|
|
17391
17690
|
return;
|
|
17392
17691
|
}
|
|
17393
17692
|
logScope(changedFiles2);
|
|
@@ -17770,25 +18069,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
17770
18069
|
}
|
|
17771
18070
|
|
|
17772
18071
|
// src/commands/github/printCountTable.ts
|
|
17773
|
-
import
|
|
18072
|
+
import chalk154 from "chalk";
|
|
17774
18073
|
function printCountTable(labelHeader, rows) {
|
|
17775
18074
|
const labelWidth = Math.max(
|
|
17776
18075
|
labelHeader.length,
|
|
17777
18076
|
...rows.map((row) => row.label.length)
|
|
17778
18077
|
);
|
|
17779
18078
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
17780
|
-
console.log(
|
|
17781
|
-
console.log(
|
|
18079
|
+
console.log(chalk154.dim(header));
|
|
18080
|
+
console.log(chalk154.dim("-".repeat(header.length)));
|
|
17782
18081
|
for (const row of rows) {
|
|
17783
18082
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
17784
18083
|
}
|
|
17785
18084
|
}
|
|
17786
18085
|
|
|
17787
18086
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
17788
|
-
import
|
|
18087
|
+
import chalk155 from "chalk";
|
|
17789
18088
|
function printRepoAuthorBreakdown(repos2) {
|
|
17790
18089
|
for (const repo of repos2) {
|
|
17791
|
-
console.log(
|
|
18090
|
+
console.log(chalk155.bold(repo.name));
|
|
17792
18091
|
const authorWidth = Math.max(
|
|
17793
18092
|
0,
|
|
17794
18093
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -17885,9 +18184,9 @@ function registerGithub(program2) {
|
|
|
17885
18184
|
}
|
|
17886
18185
|
|
|
17887
18186
|
// src/commands/handover/countPendingHandovers.ts
|
|
17888
|
-
import { and as and20, eq as
|
|
18187
|
+
import { and as and20, eq as eq42, isNull, sql as sql18 } from "drizzle-orm";
|
|
17889
18188
|
async function countPendingHandovers(orm, origin) {
|
|
17890
|
-
const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and20(
|
|
18189
|
+
const [row] = await orm.select({ count: sql18`count(*)::int` }).from(handovers).where(and20(eq42(handovers.origin, origin), isNull(handovers.recalledAt)));
|
|
17891
18190
|
return row?.count ?? 0;
|
|
17892
18191
|
}
|
|
17893
18192
|
|
|
@@ -18027,13 +18326,13 @@ async function load2(options2 = {}) {
|
|
|
18027
18326
|
}
|
|
18028
18327
|
|
|
18029
18328
|
// src/commands/handover/listPendingHandovers.ts
|
|
18030
|
-
import { and as and21, desc as desc4, eq as
|
|
18329
|
+
import { and as and21, desc as desc4, eq as eq43, isNull as isNull2 } from "drizzle-orm";
|
|
18031
18330
|
async function listPendingHandovers(orm, origin) {
|
|
18032
18331
|
return orm.select({
|
|
18033
18332
|
id: handovers.id,
|
|
18034
18333
|
summary: handovers.summary,
|
|
18035
18334
|
createdAt: handovers.createdAt
|
|
18036
|
-
}).from(handovers).where(and21(
|
|
18335
|
+
}).from(handovers).where(and21(eq43(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
|
|
18037
18336
|
}
|
|
18038
18337
|
|
|
18039
18338
|
// src/commands/handover/printPendingHandovers.ts
|
|
@@ -18046,17 +18345,17 @@ async function printPendingHandovers() {
|
|
|
18046
18345
|
}
|
|
18047
18346
|
|
|
18048
18347
|
// src/commands/handover/recallHandover.ts
|
|
18049
|
-
import { and as and22, desc as desc5, eq as
|
|
18348
|
+
import { and as and22, desc as desc5, eq as eq44, isNull as isNull3 } from "drizzle-orm";
|
|
18050
18349
|
async function recallHandover(orm, origin, id) {
|
|
18051
18350
|
const [row] = await orm.select().from(handovers).where(
|
|
18052
18351
|
and22(
|
|
18053
|
-
|
|
18352
|
+
eq44(handovers.origin, origin),
|
|
18054
18353
|
isNull3(handovers.recalledAt),
|
|
18055
|
-
...id === void 0 ? [] : [
|
|
18354
|
+
...id === void 0 ? [] : [eq44(handovers.id, id)]
|
|
18056
18355
|
)
|
|
18057
18356
|
).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
|
|
18058
18357
|
if (!row) return void 0;
|
|
18059
|
-
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(
|
|
18358
|
+
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq44(handovers.id, row.id));
|
|
18060
18359
|
return row.content;
|
|
18061
18360
|
}
|
|
18062
18361
|
|
|
@@ -18106,7 +18405,7 @@ function registerHandover(program2) {
|
|
|
18106
18405
|
}
|
|
18107
18406
|
|
|
18108
18407
|
// src/commands/jira/acceptanceCriteria.ts
|
|
18109
|
-
import
|
|
18408
|
+
import chalk156 from "chalk";
|
|
18110
18409
|
|
|
18111
18410
|
// src/commands/jira/adfToText.ts
|
|
18112
18411
|
function renderInline(node) {
|
|
@@ -18173,7 +18472,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
18173
18472
|
const parsed = fetchIssue(issueKey, field);
|
|
18174
18473
|
const acValue = parsed?.fields?.[field];
|
|
18175
18474
|
if (!acValue) {
|
|
18176
|
-
console.log(
|
|
18475
|
+
console.log(chalk156.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
18177
18476
|
return;
|
|
18178
18477
|
}
|
|
18179
18478
|
if (typeof acValue === "string") {
|
|
@@ -18239,14 +18538,14 @@ async function jiraAuth() {
|
|
|
18239
18538
|
}
|
|
18240
18539
|
|
|
18241
18540
|
// src/commands/jira/viewIssue.ts
|
|
18242
|
-
import
|
|
18541
|
+
import chalk157 from "chalk";
|
|
18243
18542
|
function viewIssue(issueKey) {
|
|
18244
18543
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
18245
18544
|
const fields = parsed?.fields;
|
|
18246
18545
|
const summary = fields?.summary;
|
|
18247
18546
|
const description = fields?.description;
|
|
18248
18547
|
if (summary) {
|
|
18249
|
-
console.log(
|
|
18548
|
+
console.log(chalk157.bold(summary));
|
|
18250
18549
|
}
|
|
18251
18550
|
if (description) {
|
|
18252
18551
|
if (summary) console.log();
|
|
@@ -18260,7 +18559,7 @@ function viewIssue(issueKey) {
|
|
|
18260
18559
|
}
|
|
18261
18560
|
if (!summary && !description) {
|
|
18262
18561
|
console.log(
|
|
18263
|
-
|
|
18562
|
+
chalk157.yellow(`No summary or description found on ${issueKey}.`)
|
|
18264
18563
|
);
|
|
18265
18564
|
}
|
|
18266
18565
|
}
|
|
@@ -18314,11 +18613,11 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
18314
18613
|
}
|
|
18315
18614
|
|
|
18316
18615
|
// src/commands/reviewPrComments.ts
|
|
18317
|
-
import { randomUUID as
|
|
18616
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
18318
18617
|
|
|
18319
18618
|
// src/commands/review/checkoutPr.ts
|
|
18320
18619
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
18321
|
-
import
|
|
18620
|
+
import chalk158 from "chalk";
|
|
18322
18621
|
|
|
18323
18622
|
// src/commands/sessions/daemon/daemonLog.ts
|
|
18324
18623
|
var RING_CAPACITY = 1e3;
|
|
@@ -18508,26 +18807,26 @@ function wouldDisturbWorkInProgress(clone, forCheckout) {
|
|
|
18508
18807
|
}
|
|
18509
18808
|
|
|
18510
18809
|
// src/commands/sessions/daemon/persistedSessionSchema.ts
|
|
18511
|
-
import { z as
|
|
18512
|
-
var persistedSessionSchema =
|
|
18513
|
-
name:
|
|
18514
|
-
title:
|
|
18515
|
-
generatedTitle:
|
|
18516
|
-
subtitle:
|
|
18517
|
-
commandType:
|
|
18518
|
-
harness:
|
|
18519
|
-
status:
|
|
18520
|
-
cwd:
|
|
18521
|
-
startedAt:
|
|
18522
|
-
runningMs:
|
|
18523
|
-
claudeSessionId:
|
|
18524
|
-
initialPrompt:
|
|
18525
|
-
runName:
|
|
18526
|
-
runArgs:
|
|
18527
|
-
assistArgs:
|
|
18810
|
+
import { z as z7 } from "zod";
|
|
18811
|
+
var persistedSessionSchema = z7.object({
|
|
18812
|
+
name: z7.string(),
|
|
18813
|
+
title: z7.string().optional(),
|
|
18814
|
+
generatedTitle: z7.string().optional(),
|
|
18815
|
+
subtitle: z7.string().optional(),
|
|
18816
|
+
commandType: z7.enum(["claude", "run", "assist"]),
|
|
18817
|
+
harness: z7.enum(["claude", "codex", "pi"]).optional(),
|
|
18818
|
+
status: z7.enum(["running", "waiting", "done", "error", "stopped"]).optional(),
|
|
18819
|
+
cwd: z7.string(),
|
|
18820
|
+
startedAt: z7.number(),
|
|
18821
|
+
runningMs: z7.number().optional(),
|
|
18822
|
+
claudeSessionId: z7.string().optional(),
|
|
18823
|
+
initialPrompt: z7.string().optional(),
|
|
18824
|
+
runName: z7.string().optional(),
|
|
18825
|
+
runArgs: z7.array(z7.string()).optional(),
|
|
18826
|
+
assistArgs: z7.array(z7.string()).optional(),
|
|
18528
18827
|
activity: activitySchema.optional(),
|
|
18529
|
-
starred:
|
|
18530
|
-
undurable:
|
|
18828
|
+
starred: z7.boolean().optional(),
|
|
18829
|
+
undurable: z7.object({ reason: z7.string(), removesTree: z7.boolean().optional() }).optional()
|
|
18531
18830
|
});
|
|
18532
18831
|
|
|
18533
18832
|
// src/commands/sessions/daemon/toPersistedSession.ts
|
|
@@ -18696,7 +18995,7 @@ async function checkoutPr(number) {
|
|
|
18696
18995
|
try {
|
|
18697
18996
|
execFileSync6("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
18698
18997
|
} catch {
|
|
18699
|
-
console.error(
|
|
18998
|
+
console.error(chalk158.red(`gh pr checkout ${number} failed; aborting.`));
|
|
18700
18999
|
process.exit(1);
|
|
18701
19000
|
}
|
|
18702
19001
|
}
|
|
@@ -18704,7 +19003,7 @@ async function checkoutPr(number) {
|
|
|
18704
19003
|
// src/commands/reviewPrComments.ts
|
|
18705
19004
|
async function reviewPrComments(number) {
|
|
18706
19005
|
if (number) await checkoutPr(number);
|
|
18707
|
-
const claudeSessionId =
|
|
19006
|
+
const claudeSessionId = randomUUID6();
|
|
18708
19007
|
emitActivity({
|
|
18709
19008
|
kind: "command",
|
|
18710
19009
|
name: "review-pr-comments",
|
|
@@ -18773,15 +19072,15 @@ function registerList(program2) {
|
|
|
18773
19072
|
// src/commands/mermaid/index.ts
|
|
18774
19073
|
import { mkdirSync as mkdirSync17, readdirSync as readdirSync9 } from "fs";
|
|
18775
19074
|
import { resolve as resolve13 } from "path";
|
|
18776
|
-
import
|
|
19075
|
+
import chalk161 from "chalk";
|
|
18777
19076
|
|
|
18778
19077
|
// src/commands/mermaid/exportFile.ts
|
|
18779
19078
|
import { readFileSync as readFileSync37, writeFileSync as writeFileSync31 } from "fs";
|
|
18780
19079
|
import { basename as basename13, extname as extname2, resolve as resolve12 } from "path";
|
|
18781
|
-
import
|
|
19080
|
+
import chalk160 from "chalk";
|
|
18782
19081
|
|
|
18783
19082
|
// src/commands/mermaid/renderBlock.ts
|
|
18784
|
-
import
|
|
19083
|
+
import chalk159 from "chalk";
|
|
18785
19084
|
async function renderBlock(krokiUrl, source) {
|
|
18786
19085
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
18787
19086
|
method: "POST",
|
|
@@ -18790,7 +19089,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
18790
19089
|
});
|
|
18791
19090
|
if (!response.ok) {
|
|
18792
19091
|
console.error(
|
|
18793
|
-
|
|
19092
|
+
chalk159.red(
|
|
18794
19093
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
18795
19094
|
)
|
|
18796
19095
|
);
|
|
@@ -18808,19 +19107,19 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
18808
19107
|
if (onlyIndex !== void 0) {
|
|
18809
19108
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
18810
19109
|
console.error(
|
|
18811
|
-
|
|
19110
|
+
chalk160.red(
|
|
18812
19111
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
18813
19112
|
)
|
|
18814
19113
|
);
|
|
18815
19114
|
process.exit(1);
|
|
18816
19115
|
}
|
|
18817
19116
|
console.log(
|
|
18818
|
-
|
|
19117
|
+
chalk160.gray(
|
|
18819
19118
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
18820
19119
|
)
|
|
18821
19120
|
);
|
|
18822
19121
|
} else {
|
|
18823
|
-
console.log(
|
|
19122
|
+
console.log(chalk160.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
18824
19123
|
}
|
|
18825
19124
|
for (const [i, source] of blocks.entries()) {
|
|
18826
19125
|
const idx = i + 1;
|
|
@@ -18828,7 +19127,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
18828
19127
|
const outPath = resolve12(outDir, `${stem}-${idx}.svg`);
|
|
18829
19128
|
const svg = await renderBlock(krokiUrl, source);
|
|
18830
19129
|
writeFileSync31(outPath, svg, "utf8");
|
|
18831
|
-
console.log(
|
|
19130
|
+
console.log(chalk160.green(` \u2192 ${outPath}`));
|
|
18832
19131
|
}
|
|
18833
19132
|
}
|
|
18834
19133
|
function extractMermaidBlocks(markdown) {
|
|
@@ -18844,18 +19143,18 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
18844
19143
|
if (options2.index !== void 0) {
|
|
18845
19144
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
18846
19145
|
console.error(
|
|
18847
|
-
|
|
19146
|
+
chalk161.red(`--index must be a positive integer (got ${options2.index})`)
|
|
18848
19147
|
);
|
|
18849
19148
|
process.exit(1);
|
|
18850
19149
|
}
|
|
18851
19150
|
if (!file) {
|
|
18852
|
-
console.error(
|
|
19151
|
+
console.error(chalk161.red("--index requires a file argument"));
|
|
18853
19152
|
process.exit(1);
|
|
18854
19153
|
}
|
|
18855
19154
|
}
|
|
18856
19155
|
const files = file ? [file] : readdirSync9(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
18857
19156
|
if (files.length === 0) {
|
|
18858
|
-
console.log(
|
|
19157
|
+
console.log(chalk161.gray("No markdown files found in current directory."));
|
|
18859
19158
|
return;
|
|
18860
19159
|
}
|
|
18861
19160
|
for (const f of files) {
|
|
@@ -18888,7 +19187,7 @@ function registerMermaid(program2) {
|
|
|
18888
19187
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
18889
19188
|
import { createServer as createServer2 } from "http";
|
|
18890
19189
|
import { dirname as dirname26 } from "path";
|
|
18891
|
-
import
|
|
19190
|
+
import chalk163 from "chalk";
|
|
18892
19191
|
|
|
18893
19192
|
// src/commands/netcap/corsHeaders.ts
|
|
18894
19193
|
var corsHeaders = {
|
|
@@ -18967,7 +19266,7 @@ function createNetcapHandler(options2) {
|
|
|
18967
19266
|
import { cp, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
18968
19267
|
import { networkInterfaces } from "os";
|
|
18969
19268
|
import { join as join50 } from "path";
|
|
18970
|
-
import
|
|
19269
|
+
import chalk162 from "chalk";
|
|
18971
19270
|
|
|
18972
19271
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
18973
19272
|
import { dirname as dirname25, join as join49 } from "path";
|
|
@@ -19011,7 +19310,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
19011
19310
|
const host = lanIPv4();
|
|
19012
19311
|
if (!host) {
|
|
19013
19312
|
console.log(
|
|
19014
|
-
|
|
19313
|
+
chalk162.yellow("could not determine the WSL IP for the extension")
|
|
19015
19314
|
);
|
|
19016
19315
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
19017
19316
|
return source;
|
|
@@ -19022,7 +19321,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
19022
19321
|
return WSL_WINDOWS_PATH;
|
|
19023
19322
|
} catch {
|
|
19024
19323
|
console.log(
|
|
19025
|
-
|
|
19324
|
+
chalk162.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
19026
19325
|
);
|
|
19027
19326
|
return source;
|
|
19028
19327
|
}
|
|
@@ -19055,30 +19354,30 @@ async function netcap(options2) {
|
|
|
19055
19354
|
let count8 = 0;
|
|
19056
19355
|
const handler = createNetcapHandler({
|
|
19057
19356
|
outPath,
|
|
19058
|
-
onPing: () => console.log(
|
|
19357
|
+
onPing: () => console.log(chalk163.dim("ping from extension")),
|
|
19059
19358
|
onCapture: (entry) => {
|
|
19060
19359
|
count8 += 1;
|
|
19061
19360
|
console.log(
|
|
19062
|
-
|
|
19063
|
-
|
|
19361
|
+
chalk163.green(`captured #${count8}`),
|
|
19362
|
+
chalk163.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
19064
19363
|
);
|
|
19065
19364
|
}
|
|
19066
19365
|
});
|
|
19067
19366
|
const server = createServer2(handler);
|
|
19068
19367
|
server.listen(port, () => {
|
|
19069
19368
|
console.log(
|
|
19070
|
-
|
|
19369
|
+
chalk163.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
19071
19370
|
);
|
|
19072
|
-
console.log(
|
|
19371
|
+
console.log(chalk163.dim(`appending captures to ${outPath}`));
|
|
19073
19372
|
if (filter)
|
|
19074
|
-
console.log(
|
|
19075
|
-
console.log(
|
|
19076
|
-
console.log(
|
|
19373
|
+
console.log(chalk163.dim(`forwarding only URLs matching "${filter}"`));
|
|
19374
|
+
console.log(chalk163.dim(`load the unpacked extension from ${extensionPath}`));
|
|
19375
|
+
console.log(chalk163.dim("press Ctrl-C to stop"));
|
|
19077
19376
|
});
|
|
19078
19377
|
process.on("SIGINT", () => {
|
|
19079
19378
|
server.close();
|
|
19080
19379
|
console.log(
|
|
19081
|
-
|
|
19380
|
+
chalk163.bold(
|
|
19082
19381
|
`
|
|
19083
19382
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
19084
19383
|
)
|
|
@@ -19090,7 +19389,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
19090
19389
|
// src/commands/netcap/netcapExtract.ts
|
|
19091
19390
|
import { writeFileSync as writeFileSync32 } from "fs";
|
|
19092
19391
|
import { join as join53 } from "path";
|
|
19093
|
-
import
|
|
19392
|
+
import chalk164 from "chalk";
|
|
19094
19393
|
|
|
19095
19394
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
19096
19395
|
import { readFileSync as readFileSync38 } from "fs";
|
|
@@ -19538,8 +19837,8 @@ function netcapExtract(file) {
|
|
|
19538
19837
|
writeFileSync32(outFile, `${JSON.stringify(posts, null, 2)}
|
|
19539
19838
|
`);
|
|
19540
19839
|
console.log(
|
|
19541
|
-
|
|
19542
|
-
|
|
19840
|
+
chalk164.green(`extracted ${posts.length} posts`),
|
|
19841
|
+
chalk164.dim(`-> ${outFile}`)
|
|
19543
19842
|
);
|
|
19544
19843
|
}
|
|
19545
19844
|
|
|
@@ -19560,7 +19859,7 @@ function registerNetcap(program2) {
|
|
|
19560
19859
|
}
|
|
19561
19860
|
|
|
19562
19861
|
// src/commands/news/add/index.ts
|
|
19563
|
-
import
|
|
19862
|
+
import chalk165 from "chalk";
|
|
19564
19863
|
import enquirer8 from "enquirer";
|
|
19565
19864
|
async function add2(url) {
|
|
19566
19865
|
if (!url) {
|
|
@@ -19582,10 +19881,10 @@ async function add2(url) {
|
|
|
19582
19881
|
const { orm } = await getReady();
|
|
19583
19882
|
const added = await addFeed(orm, url);
|
|
19584
19883
|
if (!added) {
|
|
19585
|
-
console.log(
|
|
19884
|
+
console.log(chalk165.yellow("Feed already exists"));
|
|
19586
19885
|
return;
|
|
19587
19886
|
}
|
|
19588
|
-
console.log(
|
|
19887
|
+
console.log(chalk165.green(`Added feed: ${url}`));
|
|
19589
19888
|
}
|
|
19590
19889
|
|
|
19591
19890
|
// src/commands/registerNews.ts
|
|
@@ -19632,7 +19931,7 @@ function registerPiHook(program2) {
|
|
|
19632
19931
|
}
|
|
19633
19932
|
|
|
19634
19933
|
// src/commands/prompts/printPromptsTable.ts
|
|
19635
|
-
import
|
|
19934
|
+
import chalk166 from "chalk";
|
|
19636
19935
|
function truncate(str, max) {
|
|
19637
19936
|
if (str.length <= max) return str;
|
|
19638
19937
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -19650,14 +19949,14 @@ function printPromptsTable(rows) {
|
|
|
19650
19949
|
"Command".padEnd(commandWidth),
|
|
19651
19950
|
"Repos"
|
|
19652
19951
|
].join(" ");
|
|
19653
|
-
console.log(
|
|
19654
|
-
console.log(
|
|
19952
|
+
console.log(chalk166.dim(header));
|
|
19953
|
+
console.log(chalk166.dim("-".repeat(header.length)));
|
|
19655
19954
|
for (const row of rows) {
|
|
19656
19955
|
const count8 = String(row.count).padStart(countWidth);
|
|
19657
19956
|
const tool = row.tool.padEnd(toolWidth);
|
|
19658
19957
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
19659
19958
|
console.log(
|
|
19660
|
-
`${
|
|
19959
|
+
`${chalk166.yellow(count8)} ${tool} ${command} ${chalk166.dim(row.repos)}`
|
|
19661
19960
|
);
|
|
19662
19961
|
}
|
|
19663
19962
|
}
|
|
@@ -20224,20 +20523,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
20224
20523
|
}
|
|
20225
20524
|
|
|
20226
20525
|
// src/commands/prs/listComments/printComments.ts
|
|
20227
|
-
import
|
|
20526
|
+
import chalk167 from "chalk";
|
|
20228
20527
|
function formatForHuman(comment3) {
|
|
20229
20528
|
if (comment3.type === "review") {
|
|
20230
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
20529
|
+
const stateColor = comment3.state === "APPROVED" ? chalk167.green : comment3.state === "CHANGES_REQUESTED" ? chalk167.red : chalk167.yellow;
|
|
20231
20530
|
return [
|
|
20232
|
-
`${
|
|
20531
|
+
`${chalk167.cyan("Review")} by ${chalk167.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
20233
20532
|
comment3.body,
|
|
20234
20533
|
""
|
|
20235
20534
|
].join("\n");
|
|
20236
20535
|
}
|
|
20237
20536
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
20238
20537
|
return [
|
|
20239
|
-
`${
|
|
20240
|
-
|
|
20538
|
+
`${chalk167.cyan("Line comment")} by ${chalk167.bold(comment3.user)} on ${chalk167.dim(`${comment3.path}${location}`)}`,
|
|
20539
|
+
chalk167.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
20241
20540
|
comment3.body,
|
|
20242
20541
|
""
|
|
20243
20542
|
].join("\n");
|
|
@@ -20327,13 +20626,13 @@ import { execSync as execSync48 } from "child_process";
|
|
|
20327
20626
|
import enquirer9 from "enquirer";
|
|
20328
20627
|
|
|
20329
20628
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
20330
|
-
import
|
|
20629
|
+
import chalk168 from "chalk";
|
|
20331
20630
|
var STATUS_MAP = {
|
|
20332
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
20333
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
20631
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk168.magenta("merged"), date: pr.mergedAt } : null,
|
|
20632
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk168.red("closed"), date: pr.closedAt } : null
|
|
20334
20633
|
};
|
|
20335
20634
|
function defaultStatus(pr) {
|
|
20336
|
-
return { label:
|
|
20635
|
+
return { label: chalk168.green("opened"), date: pr.createdAt };
|
|
20337
20636
|
}
|
|
20338
20637
|
function getStatus2(pr) {
|
|
20339
20638
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -20342,11 +20641,11 @@ function formatDate(dateStr) {
|
|
|
20342
20641
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
20343
20642
|
}
|
|
20344
20643
|
function formatPrHeader(pr, status3) {
|
|
20345
|
-
return `${
|
|
20644
|
+
return `${chalk168.cyan(`#${pr.number}`)} ${pr.title} ${chalk168.dim(`(${pr.author.login},`)} ${status3.label} ${chalk168.dim(`${formatDate(status3.date)})`)}`;
|
|
20346
20645
|
}
|
|
20347
20646
|
function logPrDetails(pr) {
|
|
20348
20647
|
console.log(
|
|
20349
|
-
|
|
20648
|
+
chalk168.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
20350
20649
|
);
|
|
20351
20650
|
console.log();
|
|
20352
20651
|
}
|
|
@@ -20560,7 +20859,7 @@ async function placePr(prNumber, title, body, options2) {
|
|
|
20560
20859
|
}
|
|
20561
20860
|
|
|
20562
20861
|
// src/commands/prs/previewAndPlace.ts
|
|
20563
|
-
import { randomUUID as
|
|
20862
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
20564
20863
|
|
|
20565
20864
|
// src/commands/prs/appendScreenshots.ts
|
|
20566
20865
|
function appendScreenshots(body, screenshots) {
|
|
@@ -20576,7 +20875,7 @@ ${screenshots.join("\n\n")}`;
|
|
|
20576
20875
|
async function previewAndPlace(args) {
|
|
20577
20876
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
20578
20877
|
sessionId: args.sessionId,
|
|
20579
|
-
requestId:
|
|
20878
|
+
requestId: randomUUID7(),
|
|
20580
20879
|
title: args.title,
|
|
20581
20880
|
body: args.body,
|
|
20582
20881
|
prNumber: args.prNumber
|
|
@@ -20861,10 +21160,10 @@ function registerPrs(program2) {
|
|
|
20861
21160
|
}
|
|
20862
21161
|
|
|
20863
21162
|
// src/commands/ravendb/ravendbAuth.ts
|
|
20864
|
-
import
|
|
21163
|
+
import chalk174 from "chalk";
|
|
20865
21164
|
|
|
20866
21165
|
// src/shared/createConnectionAuth.ts
|
|
20867
|
-
import
|
|
21166
|
+
import chalk169 from "chalk";
|
|
20868
21167
|
function listConnections(connections, format) {
|
|
20869
21168
|
if (connections.length === 0) {
|
|
20870
21169
|
console.log("No connections configured.");
|
|
@@ -20877,7 +21176,7 @@ function listConnections(connections, format) {
|
|
|
20877
21176
|
function removeConnection(connections, name, save) {
|
|
20878
21177
|
const filtered = connections.filter((c) => c.name !== name);
|
|
20879
21178
|
if (filtered.length === connections.length) {
|
|
20880
|
-
console.error(
|
|
21179
|
+
console.error(chalk169.red(`Connection "${name}" not found.`));
|
|
20881
21180
|
process.exit(1);
|
|
20882
21181
|
}
|
|
20883
21182
|
save(filtered);
|
|
@@ -20923,15 +21222,15 @@ function saveConnections(connections) {
|
|
|
20923
21222
|
}
|
|
20924
21223
|
|
|
20925
21224
|
// src/commands/ravendb/promptConnection.ts
|
|
20926
|
-
import
|
|
21225
|
+
import chalk172 from "chalk";
|
|
20927
21226
|
|
|
20928
21227
|
// src/commands/ravendb/selectOpSecret.ts
|
|
20929
|
-
import
|
|
21228
|
+
import chalk171 from "chalk";
|
|
20930
21229
|
import Enquirer2 from "enquirer";
|
|
20931
21230
|
|
|
20932
21231
|
// src/commands/ravendb/searchItems.ts
|
|
20933
21232
|
import { execSync as execSync51 } from "child_process";
|
|
20934
|
-
import
|
|
21233
|
+
import chalk170 from "chalk";
|
|
20935
21234
|
function opExec(args) {
|
|
20936
21235
|
return execSync51(`op ${args}`, {
|
|
20937
21236
|
encoding: "utf8",
|
|
@@ -20944,7 +21243,7 @@ function searchItems(search2) {
|
|
|
20944
21243
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
20945
21244
|
} catch {
|
|
20946
21245
|
console.error(
|
|
20947
|
-
|
|
21246
|
+
chalk170.red(
|
|
20948
21247
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
20949
21248
|
)
|
|
20950
21249
|
);
|
|
@@ -20958,7 +21257,7 @@ function getItemFields(itemId2) {
|
|
|
20958
21257
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
20959
21258
|
return item.fields.filter((f) => f.reference && f.label);
|
|
20960
21259
|
} catch {
|
|
20961
|
-
console.error(
|
|
21260
|
+
console.error(chalk170.red("Failed to get item details from 1Password."));
|
|
20962
21261
|
process.exit(1);
|
|
20963
21262
|
}
|
|
20964
21263
|
}
|
|
@@ -20977,7 +21276,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
20977
21276
|
}).run();
|
|
20978
21277
|
const items2 = searchItems(search2);
|
|
20979
21278
|
if (items2.length === 0) {
|
|
20980
|
-
console.error(
|
|
21279
|
+
console.error(chalk171.red(`No items found matching "${search2}".`));
|
|
20981
21280
|
process.exit(1);
|
|
20982
21281
|
}
|
|
20983
21282
|
const itemId2 = await selectOne(
|
|
@@ -20986,7 +21285,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
20986
21285
|
);
|
|
20987
21286
|
const fields = getItemFields(itemId2);
|
|
20988
21287
|
if (fields.length === 0) {
|
|
20989
|
-
console.error(
|
|
21288
|
+
console.error(chalk171.red("No fields with references found on this item."));
|
|
20990
21289
|
process.exit(1);
|
|
20991
21290
|
}
|
|
20992
21291
|
const ref = await selectOne(
|
|
@@ -21000,7 +21299,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
21000
21299
|
async function promptConnection(existingNames) {
|
|
21001
21300
|
const name = await promptInput("name", "Connection name:");
|
|
21002
21301
|
if (existingNames.includes(name)) {
|
|
21003
|
-
console.error(
|
|
21302
|
+
console.error(chalk172.red(`Connection "${name}" already exists.`));
|
|
21004
21303
|
process.exit(1);
|
|
21005
21304
|
}
|
|
21006
21305
|
const url = await promptInput(
|
|
@@ -21009,22 +21308,22 @@ async function promptConnection(existingNames) {
|
|
|
21009
21308
|
);
|
|
21010
21309
|
const database = await promptInput("database", "Database name:");
|
|
21011
21310
|
if (!name || !url || !database) {
|
|
21012
|
-
console.error(
|
|
21311
|
+
console.error(chalk172.red("All fields are required."));
|
|
21013
21312
|
process.exit(1);
|
|
21014
21313
|
}
|
|
21015
21314
|
const apiKeyRef = await selectOpSecret();
|
|
21016
|
-
console.log(
|
|
21315
|
+
console.log(chalk172.dim(`Using: ${apiKeyRef}`));
|
|
21017
21316
|
return { name, url, database, apiKeyRef };
|
|
21018
21317
|
}
|
|
21019
21318
|
|
|
21020
21319
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
21021
|
-
import
|
|
21320
|
+
import chalk173 from "chalk";
|
|
21022
21321
|
function ravendbSetConnection(name) {
|
|
21023
21322
|
const raw = loadGlobalConfigRaw();
|
|
21024
21323
|
const ravendb = raw.ravendb ?? {};
|
|
21025
21324
|
const connections = ravendb.connections ?? [];
|
|
21026
21325
|
if (!connections.some((c) => c.name === name)) {
|
|
21027
|
-
console.error(
|
|
21326
|
+
console.error(chalk173.red(`Connection "${name}" not found.`));
|
|
21028
21327
|
console.error(
|
|
21029
21328
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
21030
21329
|
);
|
|
@@ -21040,16 +21339,16 @@ function ravendbSetConnection(name) {
|
|
|
21040
21339
|
var ravendbAuth = createConnectionAuth({
|
|
21041
21340
|
load: loadConnections,
|
|
21042
21341
|
save: saveConnections,
|
|
21043
|
-
format: (c) => `${
|
|
21342
|
+
format: (c) => `${chalk174.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
21044
21343
|
promptNew: promptConnection,
|
|
21045
21344
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
21046
21345
|
});
|
|
21047
21346
|
|
|
21048
21347
|
// src/commands/ravendb/ravendbCollections.ts
|
|
21049
|
-
import
|
|
21348
|
+
import chalk178 from "chalk";
|
|
21050
21349
|
|
|
21051
21350
|
// src/commands/ravendb/ravenFetch.ts
|
|
21052
|
-
import
|
|
21351
|
+
import chalk176 from "chalk";
|
|
21053
21352
|
|
|
21054
21353
|
// src/commands/ravendb/getAccessToken.ts
|
|
21055
21354
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -21086,10 +21385,10 @@ ${errorText}`
|
|
|
21086
21385
|
|
|
21087
21386
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
21088
21387
|
import { execSync as execSync52 } from "child_process";
|
|
21089
|
-
import
|
|
21388
|
+
import chalk175 from "chalk";
|
|
21090
21389
|
function resolveOpSecret(reference) {
|
|
21091
21390
|
if (!reference.startsWith("op://")) {
|
|
21092
|
-
console.error(
|
|
21391
|
+
console.error(chalk175.red(`Invalid secret reference: must start with op://`));
|
|
21093
21392
|
process.exit(1);
|
|
21094
21393
|
}
|
|
21095
21394
|
try {
|
|
@@ -21099,7 +21398,7 @@ function resolveOpSecret(reference) {
|
|
|
21099
21398
|
}).trim();
|
|
21100
21399
|
} catch {
|
|
21101
21400
|
console.error(
|
|
21102
|
-
|
|
21401
|
+
chalk175.red(
|
|
21103
21402
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
21104
21403
|
)
|
|
21105
21404
|
);
|
|
@@ -21126,7 +21425,7 @@ async function ravenFetch(connection, path71) {
|
|
|
21126
21425
|
if (!response.ok) {
|
|
21127
21426
|
const body = await response.text();
|
|
21128
21427
|
console.error(
|
|
21129
|
-
|
|
21428
|
+
chalk176.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
21130
21429
|
);
|
|
21131
21430
|
console.error(body.substring(0, 500));
|
|
21132
21431
|
process.exit(1);
|
|
@@ -21135,7 +21434,7 @@ async function ravenFetch(connection, path71) {
|
|
|
21135
21434
|
}
|
|
21136
21435
|
|
|
21137
21436
|
// src/commands/ravendb/resolveConnection.ts
|
|
21138
|
-
import
|
|
21437
|
+
import chalk177 from "chalk";
|
|
21139
21438
|
function loadRavendb() {
|
|
21140
21439
|
const raw = loadGlobalConfigRaw();
|
|
21141
21440
|
const ravendb = raw.ravendb;
|
|
@@ -21149,7 +21448,7 @@ function resolveConnection(name) {
|
|
|
21149
21448
|
const connectionName = name ?? defaultConnection;
|
|
21150
21449
|
if (!connectionName) {
|
|
21151
21450
|
console.error(
|
|
21152
|
-
|
|
21451
|
+
chalk177.red(
|
|
21153
21452
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
21154
21453
|
)
|
|
21155
21454
|
);
|
|
@@ -21157,7 +21456,7 @@ function resolveConnection(name) {
|
|
|
21157
21456
|
}
|
|
21158
21457
|
const connection = connections.find((c) => c.name === connectionName);
|
|
21159
21458
|
if (!connection) {
|
|
21160
|
-
console.error(
|
|
21459
|
+
console.error(chalk177.red(`Connection "${connectionName}" not found.`));
|
|
21161
21460
|
console.error(
|
|
21162
21461
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
21163
21462
|
);
|
|
@@ -21188,7 +21487,7 @@ async function ravendbCollections(connectionName) {
|
|
|
21188
21487
|
return;
|
|
21189
21488
|
}
|
|
21190
21489
|
for (const c of collections) {
|
|
21191
|
-
console.log(`${
|
|
21490
|
+
console.log(`${chalk178.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
21192
21491
|
}
|
|
21193
21492
|
}
|
|
21194
21493
|
|
|
@@ -21207,10 +21506,10 @@ var ravendbConfigHelp = [
|
|
|
21207
21506
|
];
|
|
21208
21507
|
|
|
21209
21508
|
// src/commands/ravendb/ravendbQuery.ts
|
|
21210
|
-
import
|
|
21509
|
+
import chalk180 from "chalk";
|
|
21211
21510
|
|
|
21212
21511
|
// src/commands/ravendb/fetchAllPages.ts
|
|
21213
|
-
import
|
|
21512
|
+
import chalk179 from "chalk";
|
|
21214
21513
|
|
|
21215
21514
|
// src/commands/ravendb/buildQueryPath.ts
|
|
21216
21515
|
function buildQueryPath(opts) {
|
|
@@ -21248,7 +21547,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
21248
21547
|
allResults.push(...results);
|
|
21249
21548
|
start3 += results.length;
|
|
21250
21549
|
process.stderr.write(
|
|
21251
|
-
`\r${
|
|
21550
|
+
`\r${chalk179.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
21252
21551
|
);
|
|
21253
21552
|
if (start3 >= totalResults) break;
|
|
21254
21553
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -21263,7 +21562,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
21263
21562
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
21264
21563
|
const resolved = resolveArgs(connectionName, collection);
|
|
21265
21564
|
if (!resolved.collection && !options2.query) {
|
|
21266
|
-
console.error(
|
|
21565
|
+
console.error(chalk180.red("Provide a collection name or --query filter."));
|
|
21267
21566
|
process.exit(1);
|
|
21268
21567
|
}
|
|
21269
21568
|
const { collection: col } = resolved;
|
|
@@ -21302,7 +21601,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
21302
21601
|
import * as path36 from "path";
|
|
21303
21602
|
|
|
21304
21603
|
// src/commands/refactor/logViolations.ts
|
|
21305
|
-
import
|
|
21604
|
+
import chalk181 from "chalk";
|
|
21306
21605
|
var DEFAULT_MAX_LINES = 100;
|
|
21307
21606
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
21308
21607
|
if (violations.length === 0) {
|
|
@@ -21311,43 +21610,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
21311
21610
|
}
|
|
21312
21611
|
return;
|
|
21313
21612
|
}
|
|
21314
|
-
console.error(
|
|
21613
|
+
console.error(chalk181.red(`
|
|
21315
21614
|
Refactor check failed:
|
|
21316
21615
|
`));
|
|
21317
|
-
console.error(
|
|
21616
|
+
console.error(chalk181.red(` The following files exceed ${maxLines} lines:
|
|
21318
21617
|
`));
|
|
21319
21618
|
for (const violation of violations) {
|
|
21320
|
-
console.error(
|
|
21619
|
+
console.error(chalk181.red(` ${violation.file} (${violation.lines} lines)`));
|
|
21321
21620
|
}
|
|
21322
21621
|
console.error(
|
|
21323
|
-
|
|
21622
|
+
chalk181.yellow(
|
|
21324
21623
|
`
|
|
21325
21624
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
21326
21625
|
way to refactor it, ignore it with:
|
|
21327
21626
|
`
|
|
21328
21627
|
)
|
|
21329
21628
|
);
|
|
21330
|
-
console.error(
|
|
21629
|
+
console.error(chalk181.gray(` assist refactor ignore <file>
|
|
21331
21630
|
`));
|
|
21332
21631
|
if (process.env.CLAUDECODE) {
|
|
21333
|
-
console.error(
|
|
21632
|
+
console.error(chalk181.cyan(`
|
|
21334
21633
|
## Extracting Code to New Files
|
|
21335
21634
|
`));
|
|
21336
21635
|
console.error(
|
|
21337
|
-
|
|
21636
|
+
chalk181.cyan(
|
|
21338
21637
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
21339
21638
|
`
|
|
21340
21639
|
)
|
|
21341
21640
|
);
|
|
21342
21641
|
console.error(
|
|
21343
|
-
|
|
21642
|
+
chalk181.cyan(
|
|
21344
21643
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
21345
21644
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
21346
21645
|
`
|
|
21347
21646
|
)
|
|
21348
21647
|
);
|
|
21349
21648
|
console.error(
|
|
21350
|
-
|
|
21649
|
+
chalk181.cyan(
|
|
21351
21650
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
21352
21651
|
domains, move it to a common/shared folder.
|
|
21353
21652
|
`
|
|
@@ -21503,7 +21802,7 @@ async function check(pattern2, options2) {
|
|
|
21503
21802
|
|
|
21504
21803
|
// src/commands/refactor/extract/index.ts
|
|
21505
21804
|
import path44 from "path";
|
|
21506
|
-
import
|
|
21805
|
+
import chalk184 from "chalk";
|
|
21507
21806
|
|
|
21508
21807
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
21509
21808
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -22102,23 +22401,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
22102
22401
|
|
|
22103
22402
|
// src/commands/refactor/extract/displayPlan.ts
|
|
22104
22403
|
import path40 from "path";
|
|
22105
|
-
import
|
|
22404
|
+
import chalk182 from "chalk";
|
|
22106
22405
|
function section2(title) {
|
|
22107
22406
|
return `
|
|
22108
|
-
${
|
|
22407
|
+
${chalk182.cyan(title)}`;
|
|
22109
22408
|
}
|
|
22110
22409
|
function displayImporters(plan2, cwd) {
|
|
22111
22410
|
if (plan2.importersToUpdate.length === 0) return;
|
|
22112
22411
|
console.log(section2("Update importers:"));
|
|
22113
22412
|
for (const imp of plan2.importersToUpdate) {
|
|
22114
22413
|
const rel = path40.relative(cwd, imp.file.getFilePath());
|
|
22115
|
-
console.log(` ${
|
|
22414
|
+
console.log(` ${chalk182.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
22116
22415
|
}
|
|
22117
22416
|
}
|
|
22118
22417
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
22119
|
-
console.log(
|
|
22418
|
+
console.log(chalk182.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
22120
22419
|
`));
|
|
22121
|
-
console.log(` ${
|
|
22420
|
+
console.log(` ${chalk182.cyan("Functions to move:")}`);
|
|
22122
22421
|
for (const name of plan2.extractedNames) {
|
|
22123
22422
|
console.log(` ${name}`);
|
|
22124
22423
|
}
|
|
@@ -22152,7 +22451,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
22152
22451
|
|
|
22153
22452
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
22154
22453
|
import path43 from "path";
|
|
22155
|
-
import
|
|
22454
|
+
import chalk183 from "chalk";
|
|
22156
22455
|
import { Project as Project4 } from "ts-morph";
|
|
22157
22456
|
|
|
22158
22457
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -22244,7 +22543,7 @@ function loadProjectFile(file) {
|
|
|
22244
22543
|
});
|
|
22245
22544
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
22246
22545
|
if (!sourceFile) {
|
|
22247
|
-
console.log(
|
|
22546
|
+
console.log(chalk183.red(`File not found in project: ${file}`));
|
|
22248
22547
|
process.exit(1);
|
|
22249
22548
|
}
|
|
22250
22549
|
return { project, sourceFile };
|
|
@@ -22267,19 +22566,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
22267
22566
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
22268
22567
|
if (options2.apply) {
|
|
22269
22568
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
22270
|
-
console.log(
|
|
22569
|
+
console.log(chalk184.green("\nExtraction complete"));
|
|
22271
22570
|
} else {
|
|
22272
|
-
console.log(
|
|
22571
|
+
console.log(chalk184.dim("\nDry run. Use --apply to execute."));
|
|
22273
22572
|
}
|
|
22274
22573
|
}
|
|
22275
22574
|
|
|
22276
22575
|
// src/commands/refactor/ignore.ts
|
|
22277
22576
|
import fs28 from "fs";
|
|
22278
|
-
import
|
|
22577
|
+
import chalk185 from "chalk";
|
|
22279
22578
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
22280
22579
|
function ignore2(file) {
|
|
22281
22580
|
if (!fs28.existsSync(file)) {
|
|
22282
|
-
console.error(
|
|
22581
|
+
console.error(chalk185.red(`Error: File does not exist: ${file}`));
|
|
22283
22582
|
process.exit(1);
|
|
22284
22583
|
}
|
|
22285
22584
|
const content = fs28.readFileSync(file, "utf8");
|
|
@@ -22295,7 +22594,7 @@ function ignore2(file) {
|
|
|
22295
22594
|
fs28.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
22296
22595
|
}
|
|
22297
22596
|
console.log(
|
|
22298
|
-
|
|
22597
|
+
chalk185.green(
|
|
22299
22598
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
22300
22599
|
)
|
|
22301
22600
|
);
|
|
@@ -22304,12 +22603,12 @@ function ignore2(file) {
|
|
|
22304
22603
|
// src/commands/refactor/rename/index.ts
|
|
22305
22604
|
import fs31 from "fs";
|
|
22306
22605
|
import path49 from "path";
|
|
22307
|
-
import
|
|
22606
|
+
import chalk188 from "chalk";
|
|
22308
22607
|
|
|
22309
22608
|
// src/commands/refactor/rename/applyRename.ts
|
|
22310
22609
|
import fs30 from "fs";
|
|
22311
22610
|
import path46 from "path";
|
|
22312
|
-
import
|
|
22611
|
+
import chalk186 from "chalk";
|
|
22313
22612
|
|
|
22314
22613
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
22315
22614
|
import path45 from "path";
|
|
@@ -22414,13 +22713,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
22414
22713
|
const updatedContents = applyRewrites(rewrites);
|
|
22415
22714
|
for (const [file, content] of updatedContents) {
|
|
22416
22715
|
fs30.writeFileSync(file, content, "utf8");
|
|
22417
|
-
console.log(
|
|
22716
|
+
console.log(chalk186.cyan(` Updated imports in ${path46.relative(cwd, file)}`));
|
|
22418
22717
|
}
|
|
22419
22718
|
const destDir = path46.dirname(destPath);
|
|
22420
22719
|
if (!fs30.existsSync(destDir)) fs30.mkdirSync(destDir, { recursive: true });
|
|
22421
22720
|
fs30.renameSync(sourcePath, destPath);
|
|
22422
22721
|
console.log(
|
|
22423
|
-
|
|
22722
|
+
chalk186.white(
|
|
22424
22723
|
` Moved ${path46.relative(cwd, sourcePath)} \u2192 ${path46.relative(cwd, destPath)}`
|
|
22425
22724
|
)
|
|
22426
22725
|
);
|
|
@@ -22507,16 +22806,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
22507
22806
|
|
|
22508
22807
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
22509
22808
|
import path48 from "path";
|
|
22510
|
-
import
|
|
22809
|
+
import chalk187 from "chalk";
|
|
22511
22810
|
function printRenamePreview(rewrites, cwd) {
|
|
22512
22811
|
for (const rewrite of rewrites) {
|
|
22513
22812
|
console.log(
|
|
22514
|
-
|
|
22813
|
+
chalk187.dim(
|
|
22515
22814
|
` ${path48.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
22516
22815
|
)
|
|
22517
22816
|
);
|
|
22518
22817
|
}
|
|
22519
|
-
console.log(
|
|
22818
|
+
console.log(chalk187.dim("Dry run. Use --apply to execute."));
|
|
22520
22819
|
}
|
|
22521
22820
|
|
|
22522
22821
|
// src/commands/refactor/rename/index.ts
|
|
@@ -22527,20 +22826,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
22527
22826
|
const relSource = path49.relative(cwd, sourcePath);
|
|
22528
22827
|
const relDest = path49.relative(cwd, destPath);
|
|
22529
22828
|
if (!fs31.existsSync(sourcePath)) {
|
|
22530
|
-
console.log(
|
|
22829
|
+
console.log(chalk188.red(`File not found: ${source}`));
|
|
22531
22830
|
process.exit(1);
|
|
22532
22831
|
}
|
|
22533
22832
|
if (destPath !== sourcePath && fs31.existsSync(destPath)) {
|
|
22534
|
-
console.log(
|
|
22833
|
+
console.log(chalk188.red(`Destination already exists: ${destination}`));
|
|
22535
22834
|
process.exit(1);
|
|
22536
22835
|
}
|
|
22537
|
-
console.log(
|
|
22538
|
-
console.log(
|
|
22539
|
-
console.log(
|
|
22836
|
+
console.log(chalk188.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
22837
|
+
console.log(chalk188.dim("Loading project..."));
|
|
22838
|
+
console.log(chalk188.dim("Scanning imports across the project..."));
|
|
22540
22839
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
22541
22840
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
22542
22841
|
console.log(
|
|
22543
|
-
|
|
22842
|
+
chalk188.dim(
|
|
22544
22843
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
22545
22844
|
)
|
|
22546
22845
|
);
|
|
@@ -22549,11 +22848,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
22549
22848
|
return;
|
|
22550
22849
|
}
|
|
22551
22850
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
22552
|
-
console.log(
|
|
22851
|
+
console.log(chalk188.green("Done"));
|
|
22553
22852
|
}
|
|
22554
22853
|
|
|
22555
22854
|
// src/commands/refactor/renameSymbol/index.ts
|
|
22556
|
-
import
|
|
22855
|
+
import chalk189 from "chalk";
|
|
22557
22856
|
|
|
22558
22857
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
22559
22858
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -22599,33 +22898,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
22599
22898
|
const { project, sourceFile } = loadProjectFile(file);
|
|
22600
22899
|
const symbol = findSymbol(sourceFile, oldName);
|
|
22601
22900
|
if (!symbol) {
|
|
22602
|
-
console.log(
|
|
22901
|
+
console.log(chalk189.red(`Symbol "${oldName}" not found in ${file}`));
|
|
22603
22902
|
process.exit(1);
|
|
22604
22903
|
}
|
|
22605
22904
|
const grouped = groupReferences(symbol, cwd);
|
|
22606
22905
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
22607
22906
|
console.log(
|
|
22608
|
-
|
|
22907
|
+
chalk189.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
22609
22908
|
`)
|
|
22610
22909
|
);
|
|
22611
22910
|
for (const [refFile, lines] of grouped) {
|
|
22612
22911
|
console.log(
|
|
22613
|
-
` ${
|
|
22912
|
+
` ${chalk189.dim(refFile)}: lines ${chalk189.cyan(lines.join(", "))}`
|
|
22614
22913
|
);
|
|
22615
22914
|
}
|
|
22616
22915
|
if (options2.apply) {
|
|
22617
22916
|
symbol.rename(newName);
|
|
22618
22917
|
await project.save();
|
|
22619
|
-
console.log(
|
|
22918
|
+
console.log(chalk189.green(`
|
|
22620
22919
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
22621
22920
|
} else {
|
|
22622
|
-
console.log(
|
|
22921
|
+
console.log(chalk189.dim("\nDry run. Use --apply to execute."));
|
|
22623
22922
|
}
|
|
22624
22923
|
}
|
|
22625
22924
|
|
|
22626
22925
|
// src/commands/refactor/restructure/index.ts
|
|
22627
22926
|
import path57 from "path";
|
|
22628
|
-
import
|
|
22927
|
+
import chalk192 from "chalk";
|
|
22629
22928
|
|
|
22630
22929
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
22631
22930
|
import path51 from "path";
|
|
@@ -22704,50 +23003,50 @@ function clusterFiles(graph) {
|
|
|
22704
23003
|
|
|
22705
23004
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
22706
23005
|
import path53 from "path";
|
|
22707
|
-
import
|
|
23006
|
+
import chalk190 from "chalk";
|
|
22708
23007
|
function relPath(filePath) {
|
|
22709
23008
|
return path53.relative(process.cwd(), filePath);
|
|
22710
23009
|
}
|
|
22711
23010
|
function displayMoves(plan2) {
|
|
22712
23011
|
if (plan2.moves.length === 0) return;
|
|
22713
|
-
console.log(
|
|
23012
|
+
console.log(chalk190.bold("\nFile moves:"));
|
|
22714
23013
|
for (const move2 of plan2.moves) {
|
|
22715
23014
|
console.log(
|
|
22716
|
-
` ${
|
|
23015
|
+
` ${chalk190.red(relPath(move2.from))} \u2192 ${chalk190.green(relPath(move2.to))}`
|
|
22717
23016
|
);
|
|
22718
|
-
console.log(
|
|
23017
|
+
console.log(chalk190.dim(` ${move2.reason}`));
|
|
22719
23018
|
}
|
|
22720
23019
|
}
|
|
22721
23020
|
function displayRewrites(rewrites) {
|
|
22722
23021
|
if (rewrites.length === 0) return;
|
|
22723
23022
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
22724
|
-
console.log(
|
|
23023
|
+
console.log(chalk190.bold(`
|
|
22725
23024
|
Import rewrites (${affectedFiles.size} files):`));
|
|
22726
23025
|
for (const file of affectedFiles) {
|
|
22727
|
-
console.log(` ${
|
|
23026
|
+
console.log(` ${chalk190.cyan(relPath(file))}:`);
|
|
22728
23027
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
22729
23028
|
(r) => r.file === file
|
|
22730
23029
|
)) {
|
|
22731
23030
|
console.log(
|
|
22732
|
-
` ${
|
|
23031
|
+
` ${chalk190.red(`"${oldSpecifier}"`)} \u2192 ${chalk190.green(`"${newSpecifier}"`)}`
|
|
22733
23032
|
);
|
|
22734
23033
|
}
|
|
22735
23034
|
}
|
|
22736
23035
|
}
|
|
22737
23036
|
function displayPlan2(plan2) {
|
|
22738
23037
|
if (plan2.warnings.length > 0) {
|
|
22739
|
-
console.log(
|
|
22740
|
-
for (const w of plan2.warnings) console.log(
|
|
23038
|
+
console.log(chalk190.yellow("\nWarnings:"));
|
|
23039
|
+
for (const w of plan2.warnings) console.log(chalk190.yellow(` ${w}`));
|
|
22741
23040
|
}
|
|
22742
23041
|
if (plan2.newDirectories.length > 0) {
|
|
22743
|
-
console.log(
|
|
23042
|
+
console.log(chalk190.bold("\nNew directories:"));
|
|
22744
23043
|
for (const dir of plan2.newDirectories)
|
|
22745
|
-
console.log(
|
|
23044
|
+
console.log(chalk190.green(` ${dir}/`));
|
|
22746
23045
|
}
|
|
22747
23046
|
displayMoves(plan2);
|
|
22748
23047
|
displayRewrites(plan2.rewrites);
|
|
22749
23048
|
console.log(
|
|
22750
|
-
|
|
23049
|
+
chalk190.dim(
|
|
22751
23050
|
`
|
|
22752
23051
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
22753
23052
|
)
|
|
@@ -22757,18 +23056,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
22757
23056
|
// src/commands/refactor/restructure/executePlan.ts
|
|
22758
23057
|
import fs32 from "fs";
|
|
22759
23058
|
import path54 from "path";
|
|
22760
|
-
import
|
|
23059
|
+
import chalk191 from "chalk";
|
|
22761
23060
|
function executePlan(plan2) {
|
|
22762
23061
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
22763
23062
|
for (const [file, content] of updatedContents) {
|
|
22764
23063
|
fs32.writeFileSync(file, content, "utf8");
|
|
22765
23064
|
console.log(
|
|
22766
|
-
|
|
23065
|
+
chalk191.cyan(` Rewrote imports in ${path54.relative(process.cwd(), file)}`)
|
|
22767
23066
|
);
|
|
22768
23067
|
}
|
|
22769
23068
|
for (const dir of plan2.newDirectories) {
|
|
22770
23069
|
fs32.mkdirSync(dir, { recursive: true });
|
|
22771
|
-
console.log(
|
|
23070
|
+
console.log(chalk191.green(` Created ${path54.relative(process.cwd(), dir)}/`));
|
|
22772
23071
|
}
|
|
22773
23072
|
for (const move2 of plan2.moves) {
|
|
22774
23073
|
const targetDir = path54.dirname(move2.to);
|
|
@@ -22777,7 +23076,7 @@ function executePlan(plan2) {
|
|
|
22777
23076
|
}
|
|
22778
23077
|
fs32.renameSync(move2.from, move2.to);
|
|
22779
23078
|
console.log(
|
|
22780
|
-
|
|
23079
|
+
chalk191.white(
|
|
22781
23080
|
` Moved ${path54.relative(process.cwd(), move2.from)} \u2192 ${path54.relative(process.cwd(), move2.to)}`
|
|
22782
23081
|
)
|
|
22783
23082
|
);
|
|
@@ -22792,7 +23091,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
22792
23091
|
if (entries.length === 0) {
|
|
22793
23092
|
fs32.rmdirSync(dir);
|
|
22794
23093
|
console.log(
|
|
22795
|
-
|
|
23094
|
+
chalk191.dim(
|
|
22796
23095
|
` Removed empty directory ${path54.relative(process.cwd(), dir)}`
|
|
22797
23096
|
)
|
|
22798
23097
|
);
|
|
@@ -22925,22 +23224,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
22925
23224
|
const targetPattern = pattern2 ?? "src";
|
|
22926
23225
|
const files = findSourceFiles2(targetPattern);
|
|
22927
23226
|
if (files.length === 0) {
|
|
22928
|
-
console.log(
|
|
23227
|
+
console.log(chalk192.yellow("No files found matching pattern"));
|
|
22929
23228
|
return;
|
|
22930
23229
|
}
|
|
22931
23230
|
const tsConfigPath = findTsConfig(path57.resolve(files[0]));
|
|
22932
23231
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
22933
23232
|
if (plan2.moves.length === 0) {
|
|
22934
|
-
console.log(
|
|
23233
|
+
console.log(chalk192.green("No restructuring needed"));
|
|
22935
23234
|
return;
|
|
22936
23235
|
}
|
|
22937
23236
|
displayPlan2(plan2);
|
|
22938
23237
|
if (options2.apply) {
|
|
22939
|
-
console.log(
|
|
23238
|
+
console.log(chalk192.bold("\nApplying changes..."));
|
|
22940
23239
|
executePlan(plan2);
|
|
22941
|
-
console.log(
|
|
23240
|
+
console.log(chalk192.green("\nRestructuring complete"));
|
|
22942
23241
|
} else {
|
|
22943
|
-
console.log(
|
|
23242
|
+
console.log(chalk192.dim("\nDry run. Use --apply to execute."));
|
|
22944
23243
|
}
|
|
22945
23244
|
}
|
|
22946
23245
|
|
|
@@ -23520,18 +23819,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
23520
23819
|
}
|
|
23521
23820
|
|
|
23522
23821
|
// src/commands/review/warnOutOfDiff.ts
|
|
23523
|
-
import
|
|
23822
|
+
import chalk193 from "chalk";
|
|
23524
23823
|
function warnOutOfDiff(outOfDiff) {
|
|
23525
23824
|
if (outOfDiff.length === 0) return;
|
|
23526
23825
|
console.warn(
|
|
23527
|
-
|
|
23826
|
+
chalk193.yellow(
|
|
23528
23827
|
`Skipped ${outOfDiff.length} finding(s) whose lines fall outside the PR diff (GitHub would silently drop these):`
|
|
23529
23828
|
)
|
|
23530
23829
|
);
|
|
23531
23830
|
for (const finding of outOfDiff) {
|
|
23532
23831
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
23533
23832
|
console.warn(
|
|
23534
|
-
` ${
|
|
23833
|
+
` ${chalk193.yellow("\xB7")} ${finding.title} ${chalk193.dim(
|
|
23535
23834
|
`(${finding.file}:${range})`
|
|
23536
23835
|
)}`
|
|
23537
23836
|
);
|
|
@@ -23550,18 +23849,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
23550
23849
|
}
|
|
23551
23850
|
|
|
23552
23851
|
// src/commands/review/warnUnlocated.ts
|
|
23553
|
-
import
|
|
23852
|
+
import chalk194 from "chalk";
|
|
23554
23853
|
function warnUnlocated(unlocated) {
|
|
23555
23854
|
if (unlocated.length === 0) return;
|
|
23556
23855
|
console.warn(
|
|
23557
|
-
|
|
23856
|
+
chalk194.yellow(
|
|
23558
23857
|
`Skipped ${unlocated.length} finding(s) without a parseable file:line:`
|
|
23559
23858
|
)
|
|
23560
23859
|
);
|
|
23561
23860
|
for (const finding of unlocated) {
|
|
23562
|
-
const where = finding.location ||
|
|
23861
|
+
const where = finding.location || chalk194.dim("missing");
|
|
23563
23862
|
console.warn(
|
|
23564
|
-
` ${
|
|
23863
|
+
` ${chalk194.yellow("\xB7")} ${finding.title} ${chalk194.dim(`(${where})`)}`
|
|
23565
23864
|
);
|
|
23566
23865
|
}
|
|
23567
23866
|
}
|
|
@@ -23712,7 +24011,7 @@ Read ${synthesisPath}. It contains a list of findings under the \`## Findings\`
|
|
|
23712
24011
|
File ONE bug backlog item covering the review findings:
|
|
23713
24012
|
- Include EVERY finding in the file as a phase on that single item \u2014 including findings whose Source is \`already-raised\`.
|
|
23714
24013
|
- Each phase should be named after its finding's title and its tasks should capture the finding's Location, Impact, and Recommendation.
|
|
23715
|
-
-
|
|
24014
|
+
- File the item with \`assist backlog propose\`, then apply the whole plan with a single \`assist backlog update-plan <id> --json -\` call whose payload lists every finding as a phase. Do not run \`assist backlog add-phase\` per finding \u2014 the plan lands in one preview, or not at all.
|
|
23716
24015
|
|
|
23717
24016
|
Important constraints:
|
|
23718
24017
|
- Do not edit ${synthesisPath} \u2014 leave it untouched.
|
|
@@ -24726,7 +25025,7 @@ function registerReview(program2) {
|
|
|
24726
25025
|
}
|
|
24727
25026
|
|
|
24728
25027
|
// src/commands/seq/seqAuth.ts
|
|
24729
|
-
import
|
|
25028
|
+
import chalk196 from "chalk";
|
|
24730
25029
|
|
|
24731
25030
|
// src/commands/seq/loadConnections.ts
|
|
24732
25031
|
function loadConnections2() {
|
|
@@ -24755,10 +25054,10 @@ function setDefaultConnection(name) {
|
|
|
24755
25054
|
}
|
|
24756
25055
|
|
|
24757
25056
|
// src/shared/assertUniqueName.ts
|
|
24758
|
-
import
|
|
25057
|
+
import chalk195 from "chalk";
|
|
24759
25058
|
function assertUniqueName(existingNames, name) {
|
|
24760
25059
|
if (existingNames.includes(name)) {
|
|
24761
|
-
console.error(
|
|
25060
|
+
console.error(chalk195.red(`Connection "${name}" already exists.`));
|
|
24762
25061
|
process.exit(1);
|
|
24763
25062
|
}
|
|
24764
25063
|
}
|
|
@@ -24776,7 +25075,7 @@ async function promptConnection2(existingNames) {
|
|
|
24776
25075
|
var seqAuth = createConnectionAuth({
|
|
24777
25076
|
load: loadConnections2,
|
|
24778
25077
|
save: saveConnections2,
|
|
24779
|
-
format: (c) => `${
|
|
25078
|
+
format: (c) => `${chalk196.bold(c.name)} ${c.url}`,
|
|
24780
25079
|
promptNew: promptConnection2,
|
|
24781
25080
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
24782
25081
|
});
|
|
@@ -24796,10 +25095,10 @@ var seqConfigHelp = [
|
|
|
24796
25095
|
];
|
|
24797
25096
|
|
|
24798
25097
|
// src/commands/seq/seqQuery.ts
|
|
24799
|
-
import
|
|
25098
|
+
import chalk200 from "chalk";
|
|
24800
25099
|
|
|
24801
25100
|
// src/commands/seq/fetchSeq.ts
|
|
24802
|
-
import
|
|
25101
|
+
import chalk197 from "chalk";
|
|
24803
25102
|
async function fetchSeq(conn, path71, params) {
|
|
24804
25103
|
const url = `${conn.url}${path71}?${params}`;
|
|
24805
25104
|
const response = await fetch(url, {
|
|
@@ -24810,7 +25109,7 @@ async function fetchSeq(conn, path71, params) {
|
|
|
24810
25109
|
});
|
|
24811
25110
|
if (!response.ok) {
|
|
24812
25111
|
const body = await response.text();
|
|
24813
|
-
console.error(
|
|
25112
|
+
console.error(chalk197.red(`Seq returned ${response.status}: ${body}`));
|
|
24814
25113
|
process.exit(1);
|
|
24815
25114
|
}
|
|
24816
25115
|
return response;
|
|
@@ -24869,23 +25168,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
24869
25168
|
}
|
|
24870
25169
|
|
|
24871
25170
|
// src/commands/seq/formatEvent.ts
|
|
24872
|
-
import
|
|
25171
|
+
import chalk198 from "chalk";
|
|
24873
25172
|
function levelColor(level) {
|
|
24874
25173
|
switch (level) {
|
|
24875
25174
|
case "Fatal":
|
|
24876
|
-
return
|
|
25175
|
+
return chalk198.bgRed.white;
|
|
24877
25176
|
case "Error":
|
|
24878
|
-
return
|
|
25177
|
+
return chalk198.red;
|
|
24879
25178
|
case "Warning":
|
|
24880
|
-
return
|
|
25179
|
+
return chalk198.yellow;
|
|
24881
25180
|
case "Information":
|
|
24882
|
-
return
|
|
25181
|
+
return chalk198.cyan;
|
|
24883
25182
|
case "Debug":
|
|
24884
|
-
return
|
|
25183
|
+
return chalk198.gray;
|
|
24885
25184
|
case "Verbose":
|
|
24886
|
-
return
|
|
25185
|
+
return chalk198.dim;
|
|
24887
25186
|
default:
|
|
24888
|
-
return
|
|
25187
|
+
return chalk198.white;
|
|
24889
25188
|
}
|
|
24890
25189
|
}
|
|
24891
25190
|
function levelAbbrev(level) {
|
|
@@ -24926,12 +25225,12 @@ function formatTimestamp(iso) {
|
|
|
24926
25225
|
function formatEvent(event) {
|
|
24927
25226
|
const color = levelColor(event.Level);
|
|
24928
25227
|
const abbrev = levelAbbrev(event.Level);
|
|
24929
|
-
const ts8 =
|
|
25228
|
+
const ts8 = chalk198.dim(formatTimestamp(event.Timestamp));
|
|
24930
25229
|
const msg = renderMessage(event);
|
|
24931
25230
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
24932
25231
|
if (event.Exception) {
|
|
24933
25232
|
for (const line of event.Exception.split("\n")) {
|
|
24934
|
-
lines.push(
|
|
25233
|
+
lines.push(chalk198.red(` ${line}`));
|
|
24935
25234
|
}
|
|
24936
25235
|
}
|
|
24937
25236
|
return lines.join("\n");
|
|
@@ -24964,11 +25263,11 @@ function rejectTimestampFilter(filter) {
|
|
|
24964
25263
|
}
|
|
24965
25264
|
|
|
24966
25265
|
// src/shared/resolveNamedConnection.ts
|
|
24967
|
-
import
|
|
25266
|
+
import chalk199 from "chalk";
|
|
24968
25267
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
24969
25268
|
if (connections.length === 0) {
|
|
24970
25269
|
console.error(
|
|
24971
|
-
|
|
25270
|
+
chalk199.red(
|
|
24972
25271
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
24973
25272
|
)
|
|
24974
25273
|
);
|
|
@@ -24977,7 +25276,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
24977
25276
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
24978
25277
|
const connection = connections.find((c) => c.name === target);
|
|
24979
25278
|
if (!connection) {
|
|
24980
|
-
console.error(
|
|
25279
|
+
console.error(chalk199.red(`${kind} connection "${target}" not found.`));
|
|
24981
25280
|
process.exit(1);
|
|
24982
25281
|
}
|
|
24983
25282
|
return connection;
|
|
@@ -25006,7 +25305,7 @@ async function seqQuery(filter, options2) {
|
|
|
25006
25305
|
new URLSearchParams({ filter, count: String(count8) })
|
|
25007
25306
|
);
|
|
25008
25307
|
if (events.length === 0) {
|
|
25009
|
-
console.log(
|
|
25308
|
+
console.log(chalk200.yellow("No events found."));
|
|
25010
25309
|
return;
|
|
25011
25310
|
}
|
|
25012
25311
|
if (options2.json) {
|
|
@@ -25017,11 +25316,11 @@ async function seqQuery(filter, options2) {
|
|
|
25017
25316
|
for (const event of chronological) {
|
|
25018
25317
|
console.log(formatEvent(event));
|
|
25019
25318
|
}
|
|
25020
|
-
console.log(
|
|
25319
|
+
console.log(chalk200.dim(`
|
|
25021
25320
|
${events.length} events`));
|
|
25022
25321
|
if (events.length >= count8) {
|
|
25023
25322
|
console.log(
|
|
25024
|
-
|
|
25323
|
+
chalk200.yellow(
|
|
25025
25324
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
25026
25325
|
)
|
|
25027
25326
|
);
|
|
@@ -25029,10 +25328,10 @@ ${events.length} events`));
|
|
|
25029
25328
|
}
|
|
25030
25329
|
|
|
25031
25330
|
// src/shared/setNamedDefaultConnection.ts
|
|
25032
|
-
import
|
|
25331
|
+
import chalk201 from "chalk";
|
|
25033
25332
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
25034
25333
|
if (!connections.find((c) => c.name === name)) {
|
|
25035
|
-
console.error(
|
|
25334
|
+
console.error(chalk201.red(`Connection "${name}" not found.`));
|
|
25036
25335
|
process.exit(1);
|
|
25037
25336
|
}
|
|
25038
25337
|
setDefault(name);
|
|
@@ -25081,7 +25380,7 @@ function registerSignal(program2) {
|
|
|
25081
25380
|
}
|
|
25082
25381
|
|
|
25083
25382
|
// src/commands/sql/sqlAuth.ts
|
|
25084
|
-
import
|
|
25383
|
+
import chalk203 from "chalk";
|
|
25085
25384
|
|
|
25086
25385
|
// src/commands/sql/loadConnections.ts
|
|
25087
25386
|
function loadConnections3() {
|
|
@@ -25110,7 +25409,7 @@ function setDefaultConnection2(name) {
|
|
|
25110
25409
|
}
|
|
25111
25410
|
|
|
25112
25411
|
// src/commands/sql/promptConnection.ts
|
|
25113
|
-
import
|
|
25412
|
+
import chalk202 from "chalk";
|
|
25114
25413
|
async function promptConnection3(existingNames) {
|
|
25115
25414
|
const name = await promptInput("name", "Connection name:", "default");
|
|
25116
25415
|
assertUniqueName(existingNames, name);
|
|
@@ -25118,7 +25417,7 @@ async function promptConnection3(existingNames) {
|
|
|
25118
25417
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
25119
25418
|
const port = Number.parseInt(portStr, 10);
|
|
25120
25419
|
if (!Number.isFinite(port)) {
|
|
25121
|
-
console.error(
|
|
25420
|
+
console.error(chalk202.red(`Invalid port "${portStr}".`));
|
|
25122
25421
|
process.exit(1);
|
|
25123
25422
|
}
|
|
25124
25423
|
const user = await promptInput("user", "User:");
|
|
@@ -25131,13 +25430,13 @@ async function promptConnection3(existingNames) {
|
|
|
25131
25430
|
var sqlAuth = createConnectionAuth({
|
|
25132
25431
|
load: loadConnections3,
|
|
25133
25432
|
save: saveConnections3,
|
|
25134
|
-
format: (c) => `${
|
|
25433
|
+
format: (c) => `${chalk203.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
25135
25434
|
promptNew: promptConnection3,
|
|
25136
25435
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
25137
25436
|
});
|
|
25138
25437
|
|
|
25139
25438
|
// src/commands/sql/printTable.ts
|
|
25140
|
-
import
|
|
25439
|
+
import chalk204 from "chalk";
|
|
25141
25440
|
function formatCell(value) {
|
|
25142
25441
|
if (value === null || value === void 0) return "";
|
|
25143
25442
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -25146,7 +25445,7 @@ function formatCell(value) {
|
|
|
25146
25445
|
}
|
|
25147
25446
|
function printTable(rows) {
|
|
25148
25447
|
if (rows.length === 0) {
|
|
25149
|
-
console.log(
|
|
25448
|
+
console.log(chalk204.yellow("(no rows)"));
|
|
25150
25449
|
return;
|
|
25151
25450
|
}
|
|
25152
25451
|
const columns = Object.keys(rows[0]);
|
|
@@ -25154,13 +25453,13 @@ function printTable(rows) {
|
|
|
25154
25453
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
25155
25454
|
);
|
|
25156
25455
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
25157
|
-
console.log(
|
|
25158
|
-
console.log(
|
|
25456
|
+
console.log(chalk204.dim(header));
|
|
25457
|
+
console.log(chalk204.dim("-".repeat(header.length)));
|
|
25159
25458
|
for (const row of rows) {
|
|
25160
25459
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
25161
25460
|
console.log(line);
|
|
25162
25461
|
}
|
|
25163
|
-
console.log(
|
|
25462
|
+
console.log(chalk204.dim(`
|
|
25164
25463
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
25165
25464
|
}
|
|
25166
25465
|
|
|
@@ -25234,7 +25533,7 @@ var sqlConfigHelp = [
|
|
|
25234
25533
|
];
|
|
25235
25534
|
|
|
25236
25535
|
// src/commands/sql/sqlMutate.ts
|
|
25237
|
-
import
|
|
25536
|
+
import chalk205 from "chalk";
|
|
25238
25537
|
|
|
25239
25538
|
// src/commands/sql/isMutation.ts
|
|
25240
25539
|
var MUTATION_KEYWORDS = [
|
|
@@ -25268,7 +25567,7 @@ function isMutation(sql25) {
|
|
|
25268
25567
|
async function sqlMutate(query, connectionName) {
|
|
25269
25568
|
if (!isMutation(query)) {
|
|
25270
25569
|
console.error(
|
|
25271
|
-
|
|
25570
|
+
chalk205.red(
|
|
25272
25571
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
25273
25572
|
)
|
|
25274
25573
|
);
|
|
@@ -25278,18 +25577,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
25278
25577
|
const pool = await sqlConnect(conn);
|
|
25279
25578
|
try {
|
|
25280
25579
|
const result = await pool.request().query(query);
|
|
25281
|
-
console.log(
|
|
25580
|
+
console.log(chalk205.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
25282
25581
|
} finally {
|
|
25283
25582
|
await pool.close();
|
|
25284
25583
|
}
|
|
25285
25584
|
}
|
|
25286
25585
|
|
|
25287
25586
|
// src/commands/sql/sqlQuery.ts
|
|
25288
|
-
import
|
|
25587
|
+
import chalk206 from "chalk";
|
|
25289
25588
|
async function sqlQuery(query, connectionName) {
|
|
25290
25589
|
if (isMutation(query)) {
|
|
25291
25590
|
console.error(
|
|
25292
|
-
|
|
25591
|
+
chalk206.red(
|
|
25293
25592
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
25294
25593
|
)
|
|
25295
25594
|
);
|
|
@@ -25304,7 +25603,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
25304
25603
|
printTable(rows);
|
|
25305
25604
|
} else {
|
|
25306
25605
|
console.log(
|
|
25307
|
-
|
|
25606
|
+
chalk206.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
25308
25607
|
);
|
|
25309
25608
|
}
|
|
25310
25609
|
} finally {
|
|
@@ -26356,7 +26655,7 @@ function registerWatch(program2) {
|
|
|
26356
26655
|
|
|
26357
26656
|
// src/commands/roam/auth.ts
|
|
26358
26657
|
import { randomBytes } from "crypto";
|
|
26359
|
-
import
|
|
26658
|
+
import chalk207 from "chalk";
|
|
26360
26659
|
|
|
26361
26660
|
// src/commands/roam/waitForCallback.ts
|
|
26362
26661
|
import { createServer as createServer3 } from "http";
|
|
@@ -26487,13 +26786,13 @@ async function auth() {
|
|
|
26487
26786
|
saveGlobalConfig(config);
|
|
26488
26787
|
const state = randomBytes(16).toString("hex");
|
|
26489
26788
|
console.log(
|
|
26490
|
-
|
|
26789
|
+
chalk207.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
26491
26790
|
);
|
|
26492
|
-
console.log(
|
|
26493
|
-
console.log(
|
|
26494
|
-
console.log(
|
|
26791
|
+
console.log(chalk207.white("http://localhost:14523/callback\n"));
|
|
26792
|
+
console.log(chalk207.blue("Opening browser for authorization..."));
|
|
26793
|
+
console.log(chalk207.dim("Waiting for authorization callback..."));
|
|
26495
26794
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
26496
|
-
console.log(
|
|
26795
|
+
console.log(chalk207.dim("Exchanging code for tokens..."));
|
|
26497
26796
|
const tokens = await exchangeToken({
|
|
26498
26797
|
code,
|
|
26499
26798
|
clientId,
|
|
@@ -26509,7 +26808,7 @@ async function auth() {
|
|
|
26509
26808
|
};
|
|
26510
26809
|
saveGlobalConfig(config);
|
|
26511
26810
|
console.log(
|
|
26512
|
-
|
|
26811
|
+
chalk207.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
26513
26812
|
);
|
|
26514
26813
|
}
|
|
26515
26814
|
|
|
@@ -26612,11 +26911,11 @@ function registerRoam(program2) {
|
|
|
26612
26911
|
}
|
|
26613
26912
|
|
|
26614
26913
|
// src/commands/sync/printAutoConfirmHint.ts
|
|
26615
|
-
import
|
|
26914
|
+
import chalk208 from "chalk";
|
|
26616
26915
|
var autoConfirmHintCommand = "assist config set sync.autoConfirm true --global";
|
|
26617
26916
|
function printAutoConfirmHint() {
|
|
26618
26917
|
console.log(
|
|
26619
|
-
|
|
26918
|
+
chalk208.dim(
|
|
26620
26919
|
`Tip: run \`${autoConfirmHintCommand}\` to overwrite automatically next time`
|
|
26621
26920
|
)
|
|
26622
26921
|
);
|
|
@@ -27064,7 +27363,7 @@ import { execSync as execSync60 } from "child_process";
|
|
|
27064
27363
|
import { existsSync as existsSync60, mkdirSync as mkdirSync25, unlinkSync as unlinkSync21, writeFileSync as writeFileSync42 } from "fs";
|
|
27065
27364
|
import { tmpdir as tmpdir8 } from "os";
|
|
27066
27365
|
import { join as join70, resolve as resolve17 } from "path";
|
|
27067
|
-
import
|
|
27366
|
+
import chalk209 from "chalk";
|
|
27068
27367
|
|
|
27069
27368
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
27070
27369
|
var captureWindowPs1 = `
|
|
@@ -27215,13 +27514,13 @@ function screenshot(processName) {
|
|
|
27215
27514
|
const config = loadConfig();
|
|
27216
27515
|
const outputDir = resolve17(config.screenshot.outputDir);
|
|
27217
27516
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
27218
|
-
console.log(
|
|
27517
|
+
console.log(chalk209.gray(`Capturing window for process "${processName}" ...`));
|
|
27219
27518
|
try {
|
|
27220
27519
|
runPowerShellScript(processName, outputPath);
|
|
27221
|
-
console.log(
|
|
27520
|
+
console.log(chalk209.green(`Screenshot saved: ${outputPath}`));
|
|
27222
27521
|
} catch (error) {
|
|
27223
27522
|
const msg = error instanceof Error ? error.message : String(error);
|
|
27224
|
-
console.error(
|
|
27523
|
+
console.error(chalk209.red(`Failed to capture screenshot: ${msg}`));
|
|
27225
27524
|
process.exit(1);
|
|
27226
27525
|
}
|
|
27227
27526
|
}
|
|
@@ -27441,9 +27740,9 @@ function createAutoExit(exit, graceMs = DEFAULT_GRACE_MS) {
|
|
|
27441
27740
|
}
|
|
27442
27741
|
|
|
27443
27742
|
// src/commands/sessions/daemon/loadActiveSelection.ts
|
|
27444
|
-
import { z as
|
|
27743
|
+
import { z as z8 } from "zod";
|
|
27445
27744
|
var ACTIVE_FILE = "active.json";
|
|
27446
|
-
var activeSelectionSchema =
|
|
27745
|
+
var activeSelectionSchema = z8.record(z8.string(), z8.string());
|
|
27447
27746
|
function loadActiveSelection() {
|
|
27448
27747
|
const parsed = activeSelectionSchema.safeParse(
|
|
27449
27748
|
loadJson(ACTIVE_FILE)
|
|
@@ -27646,7 +27945,7 @@ var ClientHub = class extends Set {
|
|
|
27646
27945
|
};
|
|
27647
27946
|
|
|
27648
27947
|
// src/commands/sessions/daemon/createSession.ts
|
|
27649
|
-
import { randomUUID as
|
|
27948
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
27650
27949
|
|
|
27651
27950
|
// src/commands/sessions/daemon/resolveRunConfig.ts
|
|
27652
27951
|
function resolveRunConfig(name, cwd) {
|
|
@@ -27786,7 +28085,7 @@ function sessionBase(id, status3) {
|
|
|
27786
28085
|
// src/commands/sessions/daemon/createSession.ts
|
|
27787
28086
|
function createSession(id, prompt, cwd, design, harness, holdPty) {
|
|
27788
28087
|
if (harness === "pi") return createPiSession(id, prompt, cwd, holdPty);
|
|
27789
|
-
const claudeSessionId =
|
|
28088
|
+
const claudeSessionId = randomUUID8();
|
|
27790
28089
|
return {
|
|
27791
28090
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
27792
28091
|
name: `Session ${id}`,
|
|
@@ -28425,10 +28724,10 @@ function applyReviewPause(session, activity2) {
|
|
|
28425
28724
|
}
|
|
28426
28725
|
|
|
28427
28726
|
// src/shared/db/getPhaseActiveMs.ts
|
|
28428
|
-
import { and as and23, eq as
|
|
28727
|
+
import { and as and23, eq as eq45 } from "drizzle-orm";
|
|
28429
28728
|
async function getPhaseActiveMs(db, itemId2, phaseIdx) {
|
|
28430
28729
|
const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
28431
|
-
and23(
|
|
28730
|
+
and23(eq45(phaseUsage.itemId, itemId2), eq45(phaseUsage.phaseIdx, phaseIdx))
|
|
28432
28731
|
);
|
|
28433
28732
|
return row?.activeMs ?? 0;
|
|
28434
28733
|
}
|
|
@@ -28940,7 +29239,7 @@ async function recordPhaseTranscriptUsage(db, itemId2, phaseIdx, responses) {
|
|
|
28940
29239
|
}
|
|
28941
29240
|
|
|
28942
29241
|
// src/shared/db/recordWindowTokens.ts
|
|
28943
|
-
import { and as and24, eq as
|
|
29242
|
+
import { and as and24, eq as eq46, sql as sql24 } from "drizzle-orm";
|
|
28944
29243
|
async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
|
|
28945
29244
|
if (tokensUp <= 0 && tokensDown <= 0) return;
|
|
28946
29245
|
await db.update(usagePeaks).set({
|
|
@@ -28948,9 +29247,9 @@ async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
|
|
|
28948
29247
|
tokensDown: sql24`${usagePeaks.tokensDown} + ${tokensDown}`
|
|
28949
29248
|
}).where(
|
|
28950
29249
|
and24(
|
|
28951
|
-
|
|
28952
|
-
|
|
28953
|
-
|
|
29250
|
+
eq46(usagePeaks.window, window),
|
|
29251
|
+
eq46(usagePeaks.resetsAt, resetsAt),
|
|
29252
|
+
eq46(usagePeaks.segment, 0)
|
|
28954
29253
|
)
|
|
28955
29254
|
);
|
|
28956
29255
|
}
|
|
@@ -29179,7 +29478,7 @@ function respawnSession(session, respawn, status3, clients, onStatusChange) {
|
|
|
29179
29478
|
}
|
|
29180
29479
|
|
|
29181
29480
|
// src/commands/sessions/daemon/respawnPlan.ts
|
|
29182
|
-
import { randomUUID as
|
|
29481
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
29183
29482
|
|
|
29184
29483
|
// src/commands/sessions/daemon/assistResumeArgs.ts
|
|
29185
29484
|
function assistResumeArgs(session) {
|
|
@@ -29220,7 +29519,7 @@ function respawnPlan(session) {
|
|
|
29220
29519
|
return null;
|
|
29221
29520
|
}
|
|
29222
29521
|
function freshClaudePlan(session, prompt, cwd) {
|
|
29223
|
-
const claudeSessionId =
|
|
29522
|
+
const claudeSessionId = randomUUID9();
|
|
29224
29523
|
return {
|
|
29225
29524
|
spawn: () => {
|
|
29226
29525
|
session.claudeSessionId = claudeSessionId;
|
|
@@ -31511,7 +31810,7 @@ var sessionsConfigHelp = [
|
|
|
31511
31810
|
|
|
31512
31811
|
// src/commands/sessions/summarise/index.ts
|
|
31513
31812
|
import * as fs41 from "fs";
|
|
31514
|
-
import
|
|
31813
|
+
import chalk210 from "chalk";
|
|
31515
31814
|
|
|
31516
31815
|
// src/commands/sessions/summarise/shared.ts
|
|
31517
31816
|
import * as fs40 from "fs";
|
|
@@ -31585,22 +31884,22 @@ ${firstMessage}`);
|
|
|
31585
31884
|
async function summarise2(options2) {
|
|
31586
31885
|
const files = await discoverSessionFiles();
|
|
31587
31886
|
if (files.length === 0) {
|
|
31588
|
-
console.log(
|
|
31887
|
+
console.log(chalk210.yellow("No sessions found."));
|
|
31589
31888
|
return;
|
|
31590
31889
|
}
|
|
31591
31890
|
const toProcess = selectCandidates(files, options2);
|
|
31592
31891
|
if (toProcess.length === 0) {
|
|
31593
|
-
console.log(
|
|
31892
|
+
console.log(chalk210.green("All sessions already summarised."));
|
|
31594
31893
|
return;
|
|
31595
31894
|
}
|
|
31596
31895
|
console.log(
|
|
31597
|
-
|
|
31896
|
+
chalk210.cyan(
|
|
31598
31897
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
31599
31898
|
)
|
|
31600
31899
|
);
|
|
31601
31900
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
31602
31901
|
console.log(
|
|
31603
|
-
|
|
31902
|
+
chalk210.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk210.yellow(`, ${failed2} skipped`) : "")
|
|
31604
31903
|
);
|
|
31605
31904
|
}
|
|
31606
31905
|
function selectCandidates(files, options2) {
|
|
@@ -31620,16 +31919,16 @@ function processSessions(files) {
|
|
|
31620
31919
|
let failed2 = 0;
|
|
31621
31920
|
for (let i = 0; i < files.length; i++) {
|
|
31622
31921
|
const file = files[i];
|
|
31623
|
-
process.stdout.write(
|
|
31922
|
+
process.stdout.write(chalk210.dim(` [${i + 1}/${files.length}] `));
|
|
31624
31923
|
const summary = summariseSession(file);
|
|
31625
31924
|
if (summary) {
|
|
31626
31925
|
writeSummary(file, summary);
|
|
31627
31926
|
succeeded++;
|
|
31628
|
-
process.stdout.write(`${
|
|
31927
|
+
process.stdout.write(`${chalk210.green("\u2713")} ${summary}
|
|
31629
31928
|
`);
|
|
31630
31929
|
} else {
|
|
31631
31930
|
failed2++;
|
|
31632
|
-
process.stdout.write(` ${
|
|
31931
|
+
process.stdout.write(` ${chalk210.yellow("skip")}
|
|
31633
31932
|
`);
|
|
31634
31933
|
}
|
|
31635
31934
|
}
|
|
@@ -31650,7 +31949,7 @@ function registerSessions(program2) {
|
|
|
31650
31949
|
}
|
|
31651
31950
|
|
|
31652
31951
|
// src/commands/statusLine.ts
|
|
31653
|
-
import
|
|
31952
|
+
import chalk212 from "chalk";
|
|
31654
31953
|
|
|
31655
31954
|
// src/shared/contextLevel.ts
|
|
31656
31955
|
function contextLevel(pct) {
|
|
@@ -31660,7 +31959,7 @@ function contextLevel(pct) {
|
|
|
31660
31959
|
}
|
|
31661
31960
|
|
|
31662
31961
|
// src/commands/buildLimitsSegment.ts
|
|
31663
|
-
import
|
|
31962
|
+
import chalk211 from "chalk";
|
|
31664
31963
|
|
|
31665
31964
|
// src/shared/rateLimitLevel.ts
|
|
31666
31965
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -31691,9 +31990,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
31691
31990
|
|
|
31692
31991
|
// src/commands/buildLimitsSegment.ts
|
|
31693
31992
|
var LEVEL_COLOR = {
|
|
31694
|
-
ok:
|
|
31695
|
-
warn:
|
|
31696
|
-
over:
|
|
31993
|
+
ok: chalk211.green,
|
|
31994
|
+
warn: chalk211.yellow,
|
|
31995
|
+
over: chalk211.red
|
|
31697
31996
|
};
|
|
31698
31997
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
31699
31998
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -31789,7 +32088,7 @@ async function relayUsage(claudeSessionId, transcriptPath, usedPct) {
|
|
|
31789
32088
|
}
|
|
31790
32089
|
|
|
31791
32090
|
// src/commands/statusLine.ts
|
|
31792
|
-
|
|
32091
|
+
chalk212.level = 3;
|
|
31793
32092
|
function formatNumber(num) {
|
|
31794
32093
|
return num.toLocaleString("en-US");
|
|
31795
32094
|
}
|
|
@@ -31797,9 +32096,9 @@ function colorizePercent(pct) {
|
|
|
31797
32096
|
const label2 = `${Math.round(pct)}%`;
|
|
31798
32097
|
switch (contextLevel(pct)) {
|
|
31799
32098
|
case "red":
|
|
31800
|
-
return
|
|
32099
|
+
return chalk212.red(label2);
|
|
31801
32100
|
case "yellow":
|
|
31802
|
-
return
|
|
32101
|
+
return chalk212.yellow(label2);
|
|
31803
32102
|
default:
|
|
31804
32103
|
return label2;
|
|
31805
32104
|
}
|
|
@@ -31812,7 +32111,7 @@ async function statusLine() {
|
|
|
31812
32111
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
31813
32112
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
31814
32113
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
31815
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
32114
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk212.cyan(branch2)} | ` : "";
|
|
31816
32115
|
console.log(
|
|
31817
32116
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
31818
32117
|
);
|
|
@@ -31833,7 +32132,7 @@ import { fileURLToPath as fileURLToPath9 } from "url";
|
|
|
31833
32132
|
// src/commands/sync/syncClaudeMd.ts
|
|
31834
32133
|
import * as fs42 from "fs";
|
|
31835
32134
|
import * as path61 from "path";
|
|
31836
|
-
import
|
|
32135
|
+
import chalk213 from "chalk";
|
|
31837
32136
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
31838
32137
|
const source = path61.join(claudeDir, "CLAUDE.md");
|
|
31839
32138
|
const target = path61.join(targetBase, "CLAUDE.md");
|
|
@@ -31842,14 +32141,14 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
31842
32141
|
const targetContent = fs42.readFileSync(target, "utf8");
|
|
31843
32142
|
if (sourceContent !== targetContent) {
|
|
31844
32143
|
console.log(
|
|
31845
|
-
|
|
32144
|
+
chalk213.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
31846
32145
|
);
|
|
31847
32146
|
console.log();
|
|
31848
32147
|
printDiff(targetContent, sourceContent);
|
|
31849
32148
|
if (!options2?.yes) {
|
|
31850
32149
|
printAutoConfirmHint();
|
|
31851
32150
|
const confirm = await promptConfirm(
|
|
31852
|
-
|
|
32151
|
+
chalk213.red("Overwrite existing CLAUDE.md?"),
|
|
31853
32152
|
false
|
|
31854
32153
|
);
|
|
31855
32154
|
if (!confirm) {
|
|
@@ -32044,7 +32343,7 @@ function syncPi(claudeDir) {
|
|
|
32044
32343
|
// src/commands/sync/syncSettings.ts
|
|
32045
32344
|
import * as fs47 from "fs";
|
|
32046
32345
|
import * as path68 from "path";
|
|
32047
|
-
import
|
|
32346
|
+
import chalk214 from "chalk";
|
|
32048
32347
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
32049
32348
|
const source = path68.join(claudeDir, "settings.json");
|
|
32050
32349
|
const target = path68.join(targetBase, "settings.json");
|
|
@@ -32063,7 +32362,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
32063
32362
|
if (mergedContent !== normalizedTarget) {
|
|
32064
32363
|
if (!options2?.yes) {
|
|
32065
32364
|
console.log(
|
|
32066
|
-
|
|
32365
|
+
chalk214.yellow(
|
|
32067
32366
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
32068
32367
|
)
|
|
32069
32368
|
);
|
|
@@ -32071,7 +32370,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
32071
32370
|
printDiff(targetContent, mergedContent);
|
|
32072
32371
|
printAutoConfirmHint();
|
|
32073
32372
|
const confirm = await promptConfirm(
|
|
32074
|
-
|
|
32373
|
+
chalk214.red("Overwrite existing settings.json?"),
|
|
32075
32374
|
false
|
|
32076
32375
|
);
|
|
32077
32376
|
if (!confirm) {
|
|
@@ -32170,10 +32469,10 @@ async function update2() {
|
|
|
32170
32469
|
}
|
|
32171
32470
|
|
|
32172
32471
|
// src/reportCliError.ts
|
|
32173
|
-
import
|
|
32472
|
+
import chalk215 from "chalk";
|
|
32174
32473
|
function reportCliError(error) {
|
|
32175
32474
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError) {
|
|
32176
|
-
console.error(
|
|
32475
|
+
console.error(chalk215.red(error.message));
|
|
32177
32476
|
} else {
|
|
32178
32477
|
console.error(error);
|
|
32179
32478
|
}
|