@staff0rd/assist 0.368.0 → 0.370.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/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +656 -626
- 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.370.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -6500,6 +6500,17 @@ async function parseStarBody(req) {
|
|
|
6500
6500
|
return JSON.parse(await readBody(req));
|
|
6501
6501
|
}
|
|
6502
6502
|
|
|
6503
|
+
// src/commands/backlog/resolveRewindPlan.ts
|
|
6504
|
+
function resolveRewindPlan(item) {
|
|
6505
|
+
return [...resolvePlan(item), buildReviewPhase()];
|
|
6506
|
+
}
|
|
6507
|
+
|
|
6508
|
+
// src/commands/backlog/web/withReviewPhase.ts
|
|
6509
|
+
function withReviewPhase(item) {
|
|
6510
|
+
if (!item.plan || item.plan.length === 0) return item;
|
|
6511
|
+
return { ...item, plan: resolveRewindPlan(item) };
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6503
6514
|
// src/commands/backlog/web/shared.ts
|
|
6504
6515
|
async function listItems(req, res) {
|
|
6505
6516
|
applyCwdFromReq(req);
|
|
@@ -6517,7 +6528,7 @@ async function findItemOr404(res, id2) {
|
|
|
6517
6528
|
}
|
|
6518
6529
|
async function getItemById(res, id2) {
|
|
6519
6530
|
const result = await findItemOr404(res, id2);
|
|
6520
|
-
if (result) respondJson(res, 200, result.item);
|
|
6531
|
+
if (result) respondJson(res, 200, withReviewPhase(result.item));
|
|
6521
6532
|
}
|
|
6522
6533
|
async function deleteItem2(res, id2) {
|
|
6523
6534
|
const result = await findItemOr404(res, id2);
|
|
@@ -6591,12 +6602,33 @@ async function patchSubtaskStatus(req, res, id2, idx) {
|
|
|
6591
6602
|
respondJson(res, 200, await loadItem(orm, id2));
|
|
6592
6603
|
}
|
|
6593
6604
|
|
|
6594
|
-
// src/commands/backlog/
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6605
|
+
// src/commands/backlog/rewindItemToPhase.ts
|
|
6606
|
+
async function rewindItemToPhase(orm, item, phaseNumber, reason) {
|
|
6607
|
+
const plan2 = resolveRewindPlan(item);
|
|
6608
|
+
if (phaseNumber < 1 || phaseNumber > plan2.length) {
|
|
6609
|
+
return {
|
|
6610
|
+
ok: false,
|
|
6611
|
+
error: `Phase ${phaseNumber} does not exist. Valid range: 1\u2013${plan2.length}.`
|
|
6612
|
+
};
|
|
6613
|
+
}
|
|
6614
|
+
const currentPhase = item.currentPhase ?? 1;
|
|
6615
|
+
if (phaseNumber >= currentPhase) {
|
|
6616
|
+
return {
|
|
6617
|
+
ok: false,
|
|
6618
|
+
error: `Phase ${phaseNumber} is not earlier than the current phase (${currentPhase}).`
|
|
6619
|
+
};
|
|
6620
|
+
}
|
|
6621
|
+
const phaseName = plan2[phaseNumber - 1].name;
|
|
6622
|
+
await appendComment(
|
|
6623
|
+
orm,
|
|
6624
|
+
item.id,
|
|
6625
|
+
`Rewound to phase ${phaseNumber} (${phaseName}): ${reason}`,
|
|
6626
|
+
{ phase: phaseNumber }
|
|
6627
|
+
);
|
|
6628
|
+
await updateCurrentPhase(orm, item.id, phaseNumber);
|
|
6629
|
+
await updateStatus(orm, item.id, "in-progress");
|
|
6630
|
+
writeSignal("rewind", { itemId: item.id, targetPhase: phaseNumber - 1 });
|
|
6631
|
+
return { ok: true, phaseName };
|
|
6600
6632
|
}
|
|
6601
6633
|
|
|
6602
6634
|
// src/commands/backlog/web/rewindItemPhase.ts
|
|
@@ -6605,32 +6637,13 @@ async function rewindItemPhase(req, res, id2) {
|
|
|
6605
6637
|
const result = await findItemOr404(res, id2);
|
|
6606
6638
|
if (!result) return;
|
|
6607
6639
|
const { orm, item } = result;
|
|
6608
|
-
const
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
respondJson(res, 400, { error });
|
|
6640
|
+
const outcome = await rewindItemToPhase(orm, item, phase, reason);
|
|
6641
|
+
if (!outcome.ok) {
|
|
6642
|
+
respondJson(res, 400, { error: outcome.error });
|
|
6612
6643
|
return;
|
|
6613
6644
|
}
|
|
6614
|
-
const phaseName = plan2[phase - 1].name;
|
|
6615
|
-
await appendComment(
|
|
6616
|
-
orm,
|
|
6617
|
-
id2,
|
|
6618
|
-
`Rewound to phase ${phase} (${phaseName}): ${reason}`,
|
|
6619
|
-
{ phase }
|
|
6620
|
-
);
|
|
6621
|
-
await orm.update(items).set({ currentPhase: phase, status: "in-progress" }).where(eq16(items.id, id2));
|
|
6622
6645
|
respondJson(res, 200, await loadItem(orm, id2));
|
|
6623
6646
|
}
|
|
6624
|
-
function validateRewind(item, plan2, phase) {
|
|
6625
|
-
if (phase < 1 || phase > plan2.length) {
|
|
6626
|
-
return `Phase ${phase} does not exist. Valid range: 1\u2013${plan2.length}.`;
|
|
6627
|
-
}
|
|
6628
|
-
const currentPhase = item.currentPhase ?? 1;
|
|
6629
|
-
if (phase >= currentPhase) {
|
|
6630
|
-
return `Phase ${phase} is not earlier than the current phase (${currentPhase}).`;
|
|
6631
|
-
}
|
|
6632
|
-
return void 0;
|
|
6633
|
-
}
|
|
6634
6647
|
|
|
6635
6648
|
// src/commands/backlog/web/handleItemRoute.ts
|
|
6636
6649
|
var id = (match, group = 1) => Number.parseInt(match[group], 10);
|
|
@@ -7739,13 +7752,52 @@ async function web2(options2) {
|
|
|
7739
7752
|
});
|
|
7740
7753
|
}
|
|
7741
7754
|
|
|
7755
|
+
// src/commands/backlog/addActivity.ts
|
|
7756
|
+
import chalk60 from "chalk";
|
|
7757
|
+
async function addActivity(id2, kind, ref, options2) {
|
|
7758
|
+
const parsedKind = gitRefKindSchema.safeParse(kind);
|
|
7759
|
+
if (!parsedKind.success) {
|
|
7760
|
+
console.log(
|
|
7761
|
+
chalk60.red(
|
|
7762
|
+
`Invalid kind "${kind}". Expected one of: ${gitRefKindSchema.options.join(", ")}.`
|
|
7763
|
+
)
|
|
7764
|
+
);
|
|
7765
|
+
process.exitCode = 1;
|
|
7766
|
+
return;
|
|
7767
|
+
}
|
|
7768
|
+
const found = await findOneItem(id2);
|
|
7769
|
+
if (!found) {
|
|
7770
|
+
process.exitCode = 1;
|
|
7771
|
+
return;
|
|
7772
|
+
}
|
|
7773
|
+
const { orm, item } = found;
|
|
7774
|
+
const url = options2.url ?? (parsedKind.data === "pr" ? void 0 : gitRefUrl(parsedKind.data, ref));
|
|
7775
|
+
await recordGitRef(orm, item.id, {
|
|
7776
|
+
kind: parsedKind.data,
|
|
7777
|
+
ref,
|
|
7778
|
+
title: options2.title,
|
|
7779
|
+
url,
|
|
7780
|
+
state: options2.state
|
|
7781
|
+
});
|
|
7782
|
+
console.log(
|
|
7783
|
+
chalk60.green(`Attached ${parsedKind.data} "${ref}" to item #${id2}.`)
|
|
7784
|
+
);
|
|
7785
|
+
}
|
|
7786
|
+
|
|
7787
|
+
// src/commands/backlog/registerActivityCommands.ts
|
|
7788
|
+
function registerActivityCommands(cmd) {
|
|
7789
|
+
cmd.command("add-activity <id> <kind> <ref>").description(
|
|
7790
|
+
"Attach a git activity ref (branch|commit|pr) to a backlog item"
|
|
7791
|
+
).option("--title <title>", "Title metadata for the ref").option("--url <url>", "URL metadata (auto-filled for branch/commit)").option("--state <state>", "State metadata for the ref").action(addActivity);
|
|
7792
|
+
}
|
|
7793
|
+
|
|
7742
7794
|
// src/commands/backlog/associate-jira/index.ts
|
|
7743
|
-
import
|
|
7744
|
-
import { eq as
|
|
7795
|
+
import chalk62 from "chalk";
|
|
7796
|
+
import { eq as eq16 } from "drizzle-orm";
|
|
7745
7797
|
|
|
7746
7798
|
// src/commands/jira/fetchIssue.ts
|
|
7747
7799
|
import { execSync as execSync25 } from "child_process";
|
|
7748
|
-
import
|
|
7800
|
+
import chalk61 from "chalk";
|
|
7749
7801
|
function fetchIssue(issueKey, fields) {
|
|
7750
7802
|
let result;
|
|
7751
7803
|
try {
|
|
@@ -7758,15 +7810,15 @@ function fetchIssue(issueKey, fields) {
|
|
|
7758
7810
|
const stderr = error.stderr;
|
|
7759
7811
|
if (stderr.includes("unauthorized")) {
|
|
7760
7812
|
console.error(
|
|
7761
|
-
|
|
7813
|
+
chalk61.red("Jira authentication expired."),
|
|
7762
7814
|
"Run",
|
|
7763
|
-
|
|
7815
|
+
chalk61.cyan("assist jira auth"),
|
|
7764
7816
|
"to re-authenticate."
|
|
7765
7817
|
);
|
|
7766
7818
|
process.exit(1);
|
|
7767
7819
|
}
|
|
7768
7820
|
}
|
|
7769
|
-
console.error(
|
|
7821
|
+
console.error(chalk61.red(`Failed to fetch ${issueKey}.`));
|
|
7770
7822
|
process.exit(1);
|
|
7771
7823
|
}
|
|
7772
7824
|
return JSON.parse(result);
|
|
@@ -7783,18 +7835,18 @@ async function associateJira(id2, key, options2) {
|
|
|
7783
7835
|
const { orm } = found;
|
|
7784
7836
|
const itemId = found.item.id;
|
|
7785
7837
|
if (options2.clear) {
|
|
7786
|
-
await orm.update(items).set({ jiraKey: null }).where(
|
|
7787
|
-
console.log(
|
|
7838
|
+
await orm.update(items).set({ jiraKey: null }).where(eq16(items.id, itemId));
|
|
7839
|
+
console.log(chalk62.green(`Cleared Jira association on item #${itemId}.`));
|
|
7788
7840
|
return;
|
|
7789
7841
|
}
|
|
7790
7842
|
if (!key) {
|
|
7791
|
-
console.log(
|
|
7843
|
+
console.log(chalk62.red("Provide a Jira key, or use --clear to remove one."));
|
|
7792
7844
|
process.exitCode = 1;
|
|
7793
7845
|
return;
|
|
7794
7846
|
}
|
|
7795
7847
|
if (!JIRA_KEY_PATTERN.test(key)) {
|
|
7796
7848
|
console.log(
|
|
7797
|
-
|
|
7849
|
+
chalk62.red(`Malformed Jira key "${key}". Expected a key like PROJ-123.`)
|
|
7798
7850
|
);
|
|
7799
7851
|
process.exitCode = 1;
|
|
7800
7852
|
return;
|
|
@@ -7802,10 +7854,10 @@ async function associateJira(id2, key, options2) {
|
|
|
7802
7854
|
const parsed = fetchIssue(key, "summary");
|
|
7803
7855
|
const fields = parsed?.fields;
|
|
7804
7856
|
const summary = fields?.summary;
|
|
7805
|
-
await orm.update(items).set({ jiraKey: key }).where(
|
|
7857
|
+
await orm.update(items).set({ jiraKey: key }).where(eq16(items.id, itemId));
|
|
7806
7858
|
console.log(
|
|
7807
|
-
|
|
7808
|
-
summary ?
|
|
7859
|
+
chalk62.green(`Associated ${key} with item #${itemId}.`),
|
|
7860
|
+
summary ? chalk62.dim(`(${summary})`) : ""
|
|
7809
7861
|
);
|
|
7810
7862
|
}
|
|
7811
7863
|
|
|
@@ -7815,26 +7867,26 @@ function registerAssociateJiraCommand(cmd) {
|
|
|
7815
7867
|
}
|
|
7816
7868
|
|
|
7817
7869
|
// src/commands/backlog/comment/index.ts
|
|
7818
|
-
import
|
|
7870
|
+
import chalk63 from "chalk";
|
|
7819
7871
|
async function comment(id2, text9) {
|
|
7820
7872
|
const found = await findOneItem(id2);
|
|
7821
7873
|
if (!found) process.exit(1);
|
|
7822
7874
|
await appendComment(found.orm, found.item.id, text9);
|
|
7823
|
-
console.log(
|
|
7875
|
+
console.log(chalk63.green(`Comment added to item #${id2}.`));
|
|
7824
7876
|
}
|
|
7825
7877
|
|
|
7826
7878
|
// src/commands/backlog/comments/index.ts
|
|
7827
|
-
import
|
|
7879
|
+
import chalk64 from "chalk";
|
|
7828
7880
|
async function comments2(id2) {
|
|
7829
7881
|
const found = await findOneItem(id2);
|
|
7830
7882
|
if (!found) process.exit(1);
|
|
7831
7883
|
const { item } = found;
|
|
7832
7884
|
const entries = item.comments ?? [];
|
|
7833
7885
|
if (entries.length === 0) {
|
|
7834
|
-
console.log(
|
|
7886
|
+
console.log(chalk64.dim(`No comments on item #${id2}.`));
|
|
7835
7887
|
return;
|
|
7836
7888
|
}
|
|
7837
|
-
console.log(
|
|
7889
|
+
console.log(chalk64.bold(`Comments for #${id2}: ${item.name}
|
|
7838
7890
|
`));
|
|
7839
7891
|
for (const entry of entries) {
|
|
7840
7892
|
console.log(`${formatComment(entry)}
|
|
@@ -7843,7 +7895,7 @@ async function comments2(id2) {
|
|
|
7843
7895
|
}
|
|
7844
7896
|
|
|
7845
7897
|
// src/commands/backlog/delete-comment/index.ts
|
|
7846
|
-
import
|
|
7898
|
+
import chalk65 from "chalk";
|
|
7847
7899
|
async function deleteCommentCmd(id2, commentId) {
|
|
7848
7900
|
const found = await findOneItem(id2);
|
|
7849
7901
|
if (!found) process.exit(1);
|
|
@@ -7855,16 +7907,16 @@ async function deleteCommentCmd(id2, commentId) {
|
|
|
7855
7907
|
switch (outcome) {
|
|
7856
7908
|
case "deleted":
|
|
7857
7909
|
console.log(
|
|
7858
|
-
|
|
7910
|
+
chalk65.green(`Comment #${commentId} deleted from item #${id2}.`)
|
|
7859
7911
|
);
|
|
7860
7912
|
break;
|
|
7861
7913
|
case "not-found":
|
|
7862
|
-
console.log(
|
|
7914
|
+
console.log(chalk65.red(`Comment #${commentId} not found on item #${id2}.`));
|
|
7863
7915
|
process.exit(1);
|
|
7864
7916
|
break;
|
|
7865
7917
|
case "is-summary":
|
|
7866
7918
|
console.log(
|
|
7867
|
-
|
|
7919
|
+
chalk65.red(
|
|
7868
7920
|
`Comment #${commentId} is a phase summary and cannot be deleted.`
|
|
7869
7921
|
)
|
|
7870
7922
|
);
|
|
@@ -7889,7 +7941,7 @@ function registerExportCommand(cmd) {
|
|
|
7889
7941
|
|
|
7890
7942
|
// src/commands/backlog/import/index.ts
|
|
7891
7943
|
import { readFile } from "fs/promises";
|
|
7892
|
-
import
|
|
7944
|
+
import chalk67 from "chalk";
|
|
7893
7945
|
|
|
7894
7946
|
// src/commands/backlog/dump/countCopyRows.ts
|
|
7895
7947
|
function countCopyRows(data) {
|
|
@@ -7961,7 +8013,7 @@ function validateDump({ header, sections }) {
|
|
|
7961
8013
|
}
|
|
7962
8014
|
|
|
7963
8015
|
// src/commands/backlog/import/confirmReplace.ts
|
|
7964
|
-
import
|
|
8016
|
+
import chalk66 from "chalk";
|
|
7965
8017
|
async function countRows(client, table) {
|
|
7966
8018
|
const { rows } = await client.query(
|
|
7967
8019
|
`SELECT count(*)::int AS n FROM ${table}`
|
|
@@ -7972,7 +8024,7 @@ function printSummary(tables, current, incoming) {
|
|
|
7972
8024
|
const lines = tables.map(
|
|
7973
8025
|
(t, i) => ` ${t.name}: ${current[i]} \u2192 ${incoming[i]} rows`
|
|
7974
8026
|
);
|
|
7975
|
-
console.error(
|
|
8027
|
+
console.error(chalk66.bold("\nThis will REPLACE all backlog data:"));
|
|
7976
8028
|
console.error(`${lines.join("\n")}
|
|
7977
8029
|
`);
|
|
7978
8030
|
}
|
|
@@ -8074,13 +8126,13 @@ async function importBacklog(file, options2 = {}) {
|
|
|
8074
8126
|
);
|
|
8075
8127
|
await withDbClient(async (client) => {
|
|
8076
8128
|
if (!options2.yes && !await confirmReplace(client, tables, incoming, !file)) {
|
|
8077
|
-
console.error(
|
|
8129
|
+
console.error(chalk67.yellow("Import cancelled; no changes made."));
|
|
8078
8130
|
return;
|
|
8079
8131
|
}
|
|
8080
8132
|
await restore(client, parsed);
|
|
8081
8133
|
const total = incoming.reduce((sum, n) => sum + n, 0);
|
|
8082
8134
|
console.error(
|
|
8083
|
-
|
|
8135
|
+
chalk67.green(
|
|
8084
8136
|
`Imported backlog: ${total} rows restored across ${tables.length} tables.`
|
|
8085
8137
|
)
|
|
8086
8138
|
);
|
|
@@ -8097,25 +8149,25 @@ function registerImportCommand(cmd) {
|
|
|
8097
8149
|
}
|
|
8098
8150
|
|
|
8099
8151
|
// src/commands/backlog/add/index.ts
|
|
8100
|
-
import
|
|
8152
|
+
import chalk69 from "chalk";
|
|
8101
8153
|
|
|
8102
8154
|
// src/commands/backlog/insertPhaseAt.ts
|
|
8103
|
-
import { count as count2, eq as
|
|
8155
|
+
import { count as count2, eq as eq18 } from "drizzle-orm";
|
|
8104
8156
|
|
|
8105
8157
|
// src/commands/backlog/shiftPhasesUp.ts
|
|
8106
|
-
import { and as and6, desc as desc3, eq as
|
|
8158
|
+
import { and as and6, desc as desc3, eq as eq17, gte } from "drizzle-orm";
|
|
8107
8159
|
async function shiftPhasesUp(db, itemId, fromIdx) {
|
|
8108
|
-
const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and6(
|
|
8160
|
+
const toShift = await db.select({ idx: planPhases.idx }).from(planPhases).where(and6(eq17(planPhases.itemId, itemId), gte(planPhases.idx, fromIdx))).orderBy(desc3(planPhases.idx));
|
|
8109
8161
|
for (const p of toShift) {
|
|
8110
|
-
await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and6(
|
|
8111
|
-
await db.update(planPhases).set({ idx: p.idx + 1 }).where(and6(
|
|
8162
|
+
await db.update(planTasks).set({ phaseIdx: p.idx + 1 }).where(and6(eq17(planTasks.itemId, itemId), eq17(planTasks.phaseIdx, p.idx)));
|
|
8163
|
+
await db.update(planPhases).set({ idx: p.idx + 1 }).where(and6(eq17(planPhases.itemId, itemId), eq17(planPhases.idx, p.idx)));
|
|
8112
8164
|
}
|
|
8113
8165
|
}
|
|
8114
8166
|
|
|
8115
8167
|
// src/commands/backlog/insertPhaseAt.ts
|
|
8116
8168
|
async function insertPhaseAt(orm, itemId, phaseIdx, name, tasks, manualChecks, currentPhase) {
|
|
8117
8169
|
await orm.transaction(async (tx) => {
|
|
8118
|
-
const [row] = await tx.select({ cnt: count2() }).from(planPhases).where(
|
|
8170
|
+
const [row] = await tx.select({ cnt: count2() }).from(planPhases).where(eq18(planPhases.itemId, itemId));
|
|
8119
8171
|
const phaseCount = row?.cnt ?? 0;
|
|
8120
8172
|
await shiftPhasesUp(tx, itemId, phaseIdx);
|
|
8121
8173
|
await tx.insert(planPhases).values({ itemId, idx: phaseIdx, name, manualChecks });
|
|
@@ -8124,7 +8176,7 @@ async function insertPhaseAt(orm, itemId, phaseIdx, name, tasks, manualChecks, c
|
|
|
8124
8176
|
}
|
|
8125
8177
|
if (currentPhase !== void 0 && currentPhase - 1 >= phaseIdx) {
|
|
8126
8178
|
const atReviewSlot = currentPhase - 1 >= phaseCount;
|
|
8127
|
-
await tx.update(items).set({ currentPhase: atReviewSlot ? phaseIdx + 1 : currentPhase + 1 }).where(
|
|
8179
|
+
await tx.update(items).set({ currentPhase: atReviewSlot ? phaseIdx + 1 : currentPhase + 1 }).where(eq18(items.id, itemId));
|
|
8128
8180
|
}
|
|
8129
8181
|
});
|
|
8130
8182
|
}
|
|
@@ -8142,11 +8194,11 @@ async function insertSubtask(orm, itemId, title, description) {
|
|
|
8142
8194
|
}
|
|
8143
8195
|
|
|
8144
8196
|
// src/commands/backlog/ensureRemoteOrigin.ts
|
|
8145
|
-
import
|
|
8197
|
+
import chalk68 from "chalk";
|
|
8146
8198
|
function ensureRemoteOrigin() {
|
|
8147
8199
|
if (getRemoteOriginUrl(getBacklogDir())) return true;
|
|
8148
8200
|
console.log(
|
|
8149
|
-
|
|
8201
|
+
chalk68.red(
|
|
8150
8202
|
"Backlog requires a git remote so items get a stable origin.\nAdd one with: git remote add origin <url>"
|
|
8151
8203
|
)
|
|
8152
8204
|
);
|
|
@@ -8250,23 +8302,23 @@ async function add(options2) {
|
|
|
8250
8302
|
for (const subtask of loadConfig().subtasks ?? []) {
|
|
8251
8303
|
await insertSubtask(orm, id2, subtask.title, subtask.description);
|
|
8252
8304
|
}
|
|
8253
|
-
console.log(
|
|
8305
|
+
console.log(chalk69.green(`Added item #${id2}: ${name}`));
|
|
8254
8306
|
}
|
|
8255
8307
|
|
|
8256
8308
|
// src/commands/backlog/addPhase.ts
|
|
8257
|
-
import
|
|
8309
|
+
import chalk71 from "chalk";
|
|
8258
8310
|
|
|
8259
8311
|
// src/commands/backlog/resolveInsertPosition.ts
|
|
8260
|
-
import
|
|
8261
|
-
import { count as count3, eq as
|
|
8312
|
+
import chalk70 from "chalk";
|
|
8313
|
+
import { count as count3, eq as eq19 } from "drizzle-orm";
|
|
8262
8314
|
async function resolveInsertPosition(orm, itemId, position) {
|
|
8263
|
-
const [row] = await orm.select({ cnt: count3() }).from(planPhases).where(
|
|
8315
|
+
const [row] = await orm.select({ cnt: count3() }).from(planPhases).where(eq19(planPhases.itemId, itemId));
|
|
8264
8316
|
const phaseCount = row?.cnt ?? 0;
|
|
8265
8317
|
if (position === void 0) return phaseCount;
|
|
8266
8318
|
const pos = Number.parseInt(position, 10);
|
|
8267
8319
|
if (pos < 1 || pos > phaseCount + 1) {
|
|
8268
8320
|
console.log(
|
|
8269
|
-
|
|
8321
|
+
chalk70.red(
|
|
8270
8322
|
`Position ${pos} is out of range. Must be between 1 and ${phaseCount + 1}.`
|
|
8271
8323
|
)
|
|
8272
8324
|
);
|
|
@@ -8288,7 +8340,7 @@ async function addPhase(id2, name, options2) {
|
|
|
8288
8340
|
if (!found) return;
|
|
8289
8341
|
const tasks = options2.task ?? [];
|
|
8290
8342
|
if (tasks.length === 0) {
|
|
8291
|
-
console.log(
|
|
8343
|
+
console.log(chalk71.red("At least one --task is required."));
|
|
8292
8344
|
process.exitCode = 1;
|
|
8293
8345
|
return;
|
|
8294
8346
|
}
|
|
@@ -8307,14 +8359,14 @@ async function addPhase(id2, name, options2) {
|
|
|
8307
8359
|
);
|
|
8308
8360
|
const verb = options2.position !== void 0 ? "Inserted" : "Added";
|
|
8309
8361
|
console.log(
|
|
8310
|
-
|
|
8362
|
+
chalk71.green(
|
|
8311
8363
|
`${verb} phase ${phaseIdx + 1} "${name}" to item #${itemId} with ${tasks.length} task(s).`
|
|
8312
8364
|
)
|
|
8313
8365
|
);
|
|
8314
8366
|
}
|
|
8315
8367
|
|
|
8316
8368
|
// src/commands/backlog/list/index.ts
|
|
8317
|
-
import
|
|
8369
|
+
import chalk72 from "chalk";
|
|
8318
8370
|
function filterItems(items2, options2) {
|
|
8319
8371
|
if (options2.status) return items2.filter((i) => i.status === options2.status);
|
|
8320
8372
|
if (!options2.all)
|
|
@@ -8325,7 +8377,7 @@ async function list2(options2) {
|
|
|
8325
8377
|
const allItems = await loadBacklog(options2.allRepos);
|
|
8326
8378
|
const items2 = filterItems(allItems, options2);
|
|
8327
8379
|
if (items2.length === 0) {
|
|
8328
|
-
console.log(
|
|
8380
|
+
console.log(chalk72.dim("Backlog is empty."));
|
|
8329
8381
|
return;
|
|
8330
8382
|
}
|
|
8331
8383
|
const labels = originDisplayLabels(
|
|
@@ -8334,9 +8386,9 @@ async function list2(options2) {
|
|
|
8334
8386
|
const repoNameOf = (item) => item.origin ? labels.get(item.origin) ?? "" : "";
|
|
8335
8387
|
const prefixWidth = options2.allRepos ? Math.max(0, ...items2.map((i) => repoNameOf(i).length)) : 0;
|
|
8336
8388
|
for (const item of items2) {
|
|
8337
|
-
const repoPrefix = options2.allRepos ? `${
|
|
8389
|
+
const repoPrefix = options2.allRepos ? `${chalk72.dim(repoNameOf(item).padEnd(prefixWidth))} ` : "";
|
|
8338
8390
|
console.log(
|
|
8339
|
-
`${repoPrefix}${statusIcon(item.status)} ${typeLabel(item.type)} ${
|
|
8391
|
+
`${repoPrefix}${statusIcon(item.status)} ${typeLabel(item.type)} ${chalk72.dim(`#${item.id}`)} ${starMarker(item)}${item.name}${phaseLabel(item)}${dependencyLabel(item, allItems)}`
|
|
8340
8392
|
);
|
|
8341
8393
|
if (options2.verbose) {
|
|
8342
8394
|
printVerboseDetails(item);
|
|
@@ -8365,7 +8417,7 @@ function registerItemCommands(cmd) {
|
|
|
8365
8417
|
}
|
|
8366
8418
|
|
|
8367
8419
|
// src/commands/backlog/link.ts
|
|
8368
|
-
import
|
|
8420
|
+
import chalk74 from "chalk";
|
|
8369
8421
|
|
|
8370
8422
|
// src/commands/backlog/hasCycle.ts
|
|
8371
8423
|
function hasCycle(adjacency, fromId, toId) {
|
|
@@ -8384,9 +8436,9 @@ function hasCycle(adjacency, fromId, toId) {
|
|
|
8384
8436
|
}
|
|
8385
8437
|
|
|
8386
8438
|
// src/commands/backlog/loadDependencyGraph.ts
|
|
8387
|
-
import { eq as
|
|
8439
|
+
import { eq as eq20 } from "drizzle-orm";
|
|
8388
8440
|
async function loadDependencyGraph(orm) {
|
|
8389
|
-
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(
|
|
8441
|
+
const rows = await orm.select({ itemId: links.itemId, targetId: links.targetId }).from(links).where(eq20(links.type, "depends-on"));
|
|
8390
8442
|
const graph = /* @__PURE__ */ new Map();
|
|
8391
8443
|
for (const { itemId, targetId } of rows) {
|
|
8392
8444
|
const bucket = graph.get(itemId);
|
|
@@ -8397,14 +8449,14 @@ async function loadDependencyGraph(orm) {
|
|
|
8397
8449
|
}
|
|
8398
8450
|
|
|
8399
8451
|
// src/commands/backlog/validateLinkTarget.ts
|
|
8400
|
-
import
|
|
8452
|
+
import chalk73 from "chalk";
|
|
8401
8453
|
function validateLinkTarget(fromItem, fromNum, toNum, linkType) {
|
|
8402
8454
|
const duplicate = (fromItem.links ?? []).some(
|
|
8403
8455
|
(l) => l.targetId === toNum && l.type === linkType
|
|
8404
8456
|
);
|
|
8405
8457
|
if (duplicate) {
|
|
8406
8458
|
console.log(
|
|
8407
|
-
|
|
8459
|
+
chalk73.yellow(`Link already exists: #${fromNum} ${linkType} #${toNum}`)
|
|
8408
8460
|
);
|
|
8409
8461
|
return false;
|
|
8410
8462
|
}
|
|
@@ -8413,7 +8465,7 @@ function validateLinkTarget(fromItem, fromNum, toNum, linkType) {
|
|
|
8413
8465
|
|
|
8414
8466
|
// src/commands/backlog/link.ts
|
|
8415
8467
|
function fail2(message) {
|
|
8416
|
-
console.log(
|
|
8468
|
+
console.log(chalk74.red(message));
|
|
8417
8469
|
return void 0;
|
|
8418
8470
|
}
|
|
8419
8471
|
function parseLinkType(type) {
|
|
@@ -8443,32 +8495,32 @@ async function link(fromId, toId, opts) {
|
|
|
8443
8495
|
if (await createsCycle(orm, linkType, fromNum, toNum)) return;
|
|
8444
8496
|
await orm.insert(links).values({ itemId: fromNum, type: linkType, targetId: toNum });
|
|
8445
8497
|
console.log(
|
|
8446
|
-
|
|
8498
|
+
chalk74.green(`Linked #${fromNum} ${linkType} #${toNum} (${toItem.name})`)
|
|
8447
8499
|
);
|
|
8448
8500
|
}
|
|
8449
8501
|
|
|
8450
8502
|
// src/commands/backlog/unlink.ts
|
|
8451
|
-
import
|
|
8452
|
-
import { and as and7, eq as
|
|
8503
|
+
import chalk75 from "chalk";
|
|
8504
|
+
import { and as and7, eq as eq21 } from "drizzle-orm";
|
|
8453
8505
|
async function unlink(fromId, toId) {
|
|
8454
8506
|
const fromNum = Number.parseInt(fromId, 10);
|
|
8455
8507
|
const toNum = Number.parseInt(toId, 10);
|
|
8456
8508
|
const { orm } = await getReady();
|
|
8457
8509
|
const fromItem = await loadItem(orm, fromNum);
|
|
8458
8510
|
if (!fromItem) {
|
|
8459
|
-
console.log(
|
|
8511
|
+
console.log(chalk75.red(`Item #${fromId} not found.`));
|
|
8460
8512
|
return;
|
|
8461
8513
|
}
|
|
8462
8514
|
if (!fromItem.links || fromItem.links.length === 0) {
|
|
8463
|
-
console.log(
|
|
8515
|
+
console.log(chalk75.yellow(`No links found on item #${fromId}.`));
|
|
8464
8516
|
return;
|
|
8465
8517
|
}
|
|
8466
8518
|
if (!fromItem.links.some((l) => l.targetId === toNum)) {
|
|
8467
|
-
console.log(
|
|
8519
|
+
console.log(chalk75.yellow(`No link from #${fromId} to #${toId} found.`));
|
|
8468
8520
|
return;
|
|
8469
8521
|
}
|
|
8470
|
-
await orm.delete(links).where(and7(
|
|
8471
|
-
console.log(
|
|
8522
|
+
await orm.delete(links).where(and7(eq21(links.itemId, fromNum), eq21(links.targetId, toNum)));
|
|
8523
|
+
console.log(chalk75.green(`Removed link from #${fromId} to #${toId}.`));
|
|
8472
8524
|
}
|
|
8473
8525
|
|
|
8474
8526
|
// src/commands/backlog/registerLinkCommands.ts
|
|
@@ -8482,25 +8534,25 @@ function registerLinkCommands(cmd) {
|
|
|
8482
8534
|
}
|
|
8483
8535
|
|
|
8484
8536
|
// src/commands/backlog/move-repo/index.ts
|
|
8485
|
-
import
|
|
8486
|
-
import { eq as
|
|
8537
|
+
import chalk77 from "chalk";
|
|
8538
|
+
import { eq as eq23 } from "drizzle-orm";
|
|
8487
8539
|
|
|
8488
8540
|
// src/commands/backlog/move-repo/confirmMove.ts
|
|
8489
|
-
import
|
|
8541
|
+
import chalk76 from "chalk";
|
|
8490
8542
|
function pluralItems(n) {
|
|
8491
8543
|
return `${n} item${n === 1 ? "" : "s"}`;
|
|
8492
8544
|
}
|
|
8493
8545
|
async function confirmMove(cnt, oldOrigin, newOrigin) {
|
|
8494
8546
|
console.log(
|
|
8495
|
-
`${pluralItems(cnt)}: ${
|
|
8547
|
+
`${pluralItems(cnt)}: ${chalk76.cyan(oldOrigin)} \u2192 ${chalk76.cyan(newOrigin)}`
|
|
8496
8548
|
);
|
|
8497
8549
|
return promptConfirm(`Retag ${pluralItems(cnt)}?`);
|
|
8498
8550
|
}
|
|
8499
8551
|
|
|
8500
8552
|
// src/commands/backlog/move-repo/countByOrigin.ts
|
|
8501
|
-
import { count as count4, eq as
|
|
8553
|
+
import { count as count4, eq as eq22 } from "drizzle-orm";
|
|
8502
8554
|
async function countByOrigin(orm, origin) {
|
|
8503
|
-
const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(
|
|
8555
|
+
const [{ cnt }] = await orm.select({ cnt: count4() }).from(items).where(eq22(items.origin, origin));
|
|
8504
8556
|
return cnt;
|
|
8505
8557
|
}
|
|
8506
8558
|
|
|
@@ -8524,7 +8576,7 @@ Pass the full origin.`
|
|
|
8524
8576
|
|
|
8525
8577
|
// src/commands/backlog/move-repo/index.ts
|
|
8526
8578
|
function fail3(message) {
|
|
8527
|
-
console.log(
|
|
8579
|
+
console.log(chalk77.red(message));
|
|
8528
8580
|
process.exitCode = 1;
|
|
8529
8581
|
}
|
|
8530
8582
|
async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
|
|
@@ -8540,12 +8592,12 @@ async function moveRepo(oldOriginRaw, newOriginRaw, options2 = {}) {
|
|
|
8540
8592
|
}
|
|
8541
8593
|
const cnt = await countByOrigin(orm, oldOrigin);
|
|
8542
8594
|
if (!options2.yes && !await confirmMove(cnt, oldOrigin, newOrigin)) {
|
|
8543
|
-
console.log(
|
|
8595
|
+
console.log(chalk77.yellow("Move cancelled; no changes made."));
|
|
8544
8596
|
return;
|
|
8545
8597
|
}
|
|
8546
|
-
await orm.update(items).set({ origin: newOrigin }).where(
|
|
8598
|
+
await orm.update(items).set({ origin: newOrigin }).where(eq23(items.origin, oldOrigin));
|
|
8547
8599
|
console.log(
|
|
8548
|
-
|
|
8600
|
+
chalk77.green(
|
|
8549
8601
|
`Moved ${pluralItems(cnt)} from "${oldOrigin}" to "${newOrigin}".`
|
|
8550
8602
|
)
|
|
8551
8603
|
);
|
|
@@ -8574,14 +8626,14 @@ function registerPlanCommands(cmd) {
|
|
|
8574
8626
|
}
|
|
8575
8627
|
|
|
8576
8628
|
// src/commands/backlog/refine.ts
|
|
8577
|
-
import
|
|
8629
|
+
import chalk80 from "chalk";
|
|
8578
8630
|
import enquirer7 from "enquirer";
|
|
8579
8631
|
|
|
8580
8632
|
// src/commands/backlog/launchMode.ts
|
|
8581
8633
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
8582
8634
|
|
|
8583
8635
|
// src/commands/backlog/handleLaunchSignal.ts
|
|
8584
|
-
import
|
|
8636
|
+
import chalk79 from "chalk";
|
|
8585
8637
|
|
|
8586
8638
|
// src/commands/backlog/surfaceCreatedItem.ts
|
|
8587
8639
|
async function surfaceCreatedItem(slashCommand, id2) {
|
|
@@ -8599,31 +8651,31 @@ async function surfaceCreatedItem(slashCommand, id2) {
|
|
|
8599
8651
|
}
|
|
8600
8652
|
|
|
8601
8653
|
// src/commands/backlog/tryRunById.ts
|
|
8602
|
-
import
|
|
8654
|
+
import chalk78 from "chalk";
|
|
8603
8655
|
async function tryRunById(id2, options2) {
|
|
8604
8656
|
const numericId = Number.parseInt(id2, 10);
|
|
8605
8657
|
const { orm } = await getReady();
|
|
8606
8658
|
const item = Number.isNaN(numericId) ? void 0 : await loadItem(orm, numericId);
|
|
8607
8659
|
if (!item) {
|
|
8608
|
-
console.log(
|
|
8660
|
+
console.log(chalk78.red(`Item #${id2} not found.`));
|
|
8609
8661
|
return false;
|
|
8610
8662
|
}
|
|
8611
8663
|
if (item.status === "done") {
|
|
8612
|
-
console.log(
|
|
8664
|
+
console.log(chalk78.red(`Item #${id2} is already done.`));
|
|
8613
8665
|
return false;
|
|
8614
8666
|
}
|
|
8615
8667
|
if (item.status === "wontdo") {
|
|
8616
|
-
console.log(
|
|
8668
|
+
console.log(chalk78.red(`Item #${id2} is marked won't do.`));
|
|
8617
8669
|
return false;
|
|
8618
8670
|
}
|
|
8619
8671
|
const hasDeps = (item.links ?? []).some((l) => l.type === "depends-on");
|
|
8620
8672
|
if (hasDeps && isBlocked(item, await loadItemSummaries(orm, getOrigin()))) {
|
|
8621
8673
|
console.log(
|
|
8622
|
-
|
|
8674
|
+
chalk78.red(`Item #${id2} is blocked by unresolved dependencies.`)
|
|
8623
8675
|
);
|
|
8624
8676
|
return false;
|
|
8625
8677
|
}
|
|
8626
|
-
console.log(
|
|
8678
|
+
console.log(chalk78.bold(`
|
|
8627
8679
|
Running backlog item #${id2}...
|
|
8628
8680
|
`));
|
|
8629
8681
|
await run2(id2, options2);
|
|
@@ -8641,7 +8693,7 @@ async function handleLaunchSignal(slashCommand, once) {
|
|
|
8641
8693
|
if (typeof signal.id === "string" && signal.id) {
|
|
8642
8694
|
if (await tryRunById(signal.id, { allowEdits: true })) return;
|
|
8643
8695
|
}
|
|
8644
|
-
console.log(
|
|
8696
|
+
console.log(chalk79.bold("\nChaining into assist next...\n"));
|
|
8645
8697
|
await next({ allowEdits: true, once });
|
|
8646
8698
|
}
|
|
8647
8699
|
}
|
|
@@ -8682,12 +8734,12 @@ async function pickItemForRefine() {
|
|
|
8682
8734
|
(i) => i.status === "todo" || i.status === "in-progress"
|
|
8683
8735
|
);
|
|
8684
8736
|
if (active.length === 0) {
|
|
8685
|
-
console.log(
|
|
8737
|
+
console.log(chalk80.yellow("No active backlog items to refine."));
|
|
8686
8738
|
return void 0;
|
|
8687
8739
|
}
|
|
8688
8740
|
if (active.length === 1) {
|
|
8689
8741
|
const item = active[0];
|
|
8690
|
-
console.log(
|
|
8742
|
+
console.log(chalk80.bold(`Auto-selecting item #${item.id}: ${item.name}`));
|
|
8691
8743
|
return String(item.id);
|
|
8692
8744
|
}
|
|
8693
8745
|
const { selected } = await exitOnCancel(
|
|
@@ -8722,48 +8774,25 @@ function registerRefineCommand(cmd) {
|
|
|
8722
8774
|
}
|
|
8723
8775
|
|
|
8724
8776
|
// src/commands/backlog/rewindPhase.ts
|
|
8725
|
-
import
|
|
8726
|
-
function validateRewind2(item, plan2, phaseNumber) {
|
|
8727
|
-
if (phaseNumber < 1 || phaseNumber > plan2.length) {
|
|
8728
|
-
return `Phase ${phaseNumber} does not exist. Valid range: 1\u2013${plan2.length}.`;
|
|
8729
|
-
}
|
|
8730
|
-
const currentPhase = item.currentPhase ?? 1;
|
|
8731
|
-
if (phaseNumber >= currentPhase) {
|
|
8732
|
-
return `Phase ${phaseNumber} is not earlier than the current phase (${currentPhase}).`;
|
|
8733
|
-
}
|
|
8734
|
-
return void 0;
|
|
8735
|
-
}
|
|
8777
|
+
import chalk81 from "chalk";
|
|
8736
8778
|
async function rewindPhase(id2, phase, opts) {
|
|
8737
8779
|
const phaseNumber = Number.parseInt(phase, 10);
|
|
8738
|
-
const phaseIndex = phaseNumber - 1;
|
|
8739
8780
|
const { orm } = await getReady();
|
|
8740
8781
|
const item = await loadItem(orm, Number.parseInt(id2, 10));
|
|
8741
8782
|
if (!item) {
|
|
8742
|
-
console.log(
|
|
8783
|
+
console.log(chalk81.red(`Item #${id2} not found.`));
|
|
8743
8784
|
return;
|
|
8744
8785
|
}
|
|
8745
|
-
const
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
console.log(chalk80.red(error));
|
|
8786
|
+
const result = await rewindItemToPhase(orm, item, phaseNumber, opts.reason);
|
|
8787
|
+
if (!result.ok) {
|
|
8788
|
+
console.log(chalk81.red(result.error));
|
|
8749
8789
|
process.exitCode = 1;
|
|
8750
8790
|
return;
|
|
8751
8791
|
}
|
|
8752
|
-
const phaseName = plan2[phaseIndex].name;
|
|
8753
|
-
await appendComment(
|
|
8754
|
-
orm,
|
|
8755
|
-
item.id,
|
|
8756
|
-
`Rewound to phase ${phaseNumber} (${phaseName}): ${opts.reason}`,
|
|
8757
|
-
{ phase: phaseNumber }
|
|
8758
|
-
);
|
|
8759
|
-
await setCurrentPhase(id2, phaseNumber);
|
|
8760
|
-
await setStatus(id2, "in-progress");
|
|
8761
|
-
writeSignal("rewind", {
|
|
8762
|
-
itemId: Number.parseInt(id2, 10),
|
|
8763
|
-
targetPhase: phaseIndex
|
|
8764
|
-
});
|
|
8765
8792
|
console.log(
|
|
8766
|
-
|
|
8793
|
+
chalk81.green(
|
|
8794
|
+
`Rewound item #${id2} to phase ${phaseNumber} (${result.phaseName}).`
|
|
8795
|
+
)
|
|
8767
8796
|
);
|
|
8768
8797
|
}
|
|
8769
8798
|
|
|
@@ -8789,22 +8818,22 @@ function registerRunCommand(cmd) {
|
|
|
8789
8818
|
}
|
|
8790
8819
|
|
|
8791
8820
|
// src/commands/backlog/search/index.ts
|
|
8792
|
-
import
|
|
8821
|
+
import chalk82 from "chalk";
|
|
8793
8822
|
async function search(query) {
|
|
8794
8823
|
const items2 = await searchBacklog(query);
|
|
8795
8824
|
if (items2.length === 0) {
|
|
8796
|
-
console.log(
|
|
8825
|
+
console.log(chalk82.dim(`No items matching "${query}".`));
|
|
8797
8826
|
return;
|
|
8798
8827
|
}
|
|
8799
8828
|
console.log(
|
|
8800
|
-
|
|
8829
|
+
chalk82.dim(
|
|
8801
8830
|
`${items2.length} item${items2.length === 1 ? "" : "s"} matching "${query}":
|
|
8802
8831
|
`
|
|
8803
8832
|
)
|
|
8804
8833
|
);
|
|
8805
8834
|
for (const item of items2) {
|
|
8806
8835
|
console.log(
|
|
8807
|
-
`${statusIcon(item.status)} ${typeLabel(item.type)} ${
|
|
8836
|
+
`${statusIcon(item.status)} ${typeLabel(item.type)} ${chalk82.dim(`#${item.id}`)} ${item.name}`
|
|
8808
8837
|
);
|
|
8809
8838
|
}
|
|
8810
8839
|
}
|
|
@@ -8815,16 +8844,16 @@ function registerSearchCommand(cmd) {
|
|
|
8815
8844
|
}
|
|
8816
8845
|
|
|
8817
8846
|
// src/commands/backlog/delete/index.ts
|
|
8818
|
-
import
|
|
8847
|
+
import chalk83 from "chalk";
|
|
8819
8848
|
async function del(id2) {
|
|
8820
8849
|
const name = await removeItem(id2);
|
|
8821
8850
|
if (name) {
|
|
8822
|
-
console.log(
|
|
8851
|
+
console.log(chalk83.green(`Deleted item #${id2}: ${name}`));
|
|
8823
8852
|
}
|
|
8824
8853
|
}
|
|
8825
8854
|
|
|
8826
8855
|
// src/commands/backlog/done/index.ts
|
|
8827
|
-
import
|
|
8856
|
+
import chalk84 from "chalk";
|
|
8828
8857
|
async function done(id2, summary) {
|
|
8829
8858
|
const found = await findOneItem(id2);
|
|
8830
8859
|
if (!found) return;
|
|
@@ -8838,12 +8867,12 @@ async function done(id2, summary) {
|
|
|
8838
8867
|
const pending = item.plan.slice(completedCount);
|
|
8839
8868
|
if (pending.length > 0) {
|
|
8840
8869
|
console.log(
|
|
8841
|
-
|
|
8870
|
+
chalk84.red(
|
|
8842
8871
|
`Cannot complete item #${id2}: ${pending.length} pending phase(s):`
|
|
8843
8872
|
)
|
|
8844
8873
|
);
|
|
8845
8874
|
for (const phase of pending) {
|
|
8846
|
-
console.log(
|
|
8875
|
+
console.log(chalk84.yellow(` - ${phase.name}`));
|
|
8847
8876
|
}
|
|
8848
8877
|
process.exitCode = 1;
|
|
8849
8878
|
return;
|
|
@@ -8854,11 +8883,11 @@ async function done(id2, summary) {
|
|
|
8854
8883
|
const phase = item.currentPhase ?? 1;
|
|
8855
8884
|
await appendComment(orm, item.id, summary, { phase, type: "summary" });
|
|
8856
8885
|
}
|
|
8857
|
-
console.log(
|
|
8886
|
+
console.log(chalk84.green(`Completed item #${id2}: ${item.name}`));
|
|
8858
8887
|
}
|
|
8859
8888
|
|
|
8860
8889
|
// src/commands/backlog/set-status/index.ts
|
|
8861
|
-
import
|
|
8890
|
+
import chalk85 from "chalk";
|
|
8862
8891
|
var allowedStatuses = [
|
|
8863
8892
|
"todo",
|
|
8864
8893
|
"in-progress",
|
|
@@ -8868,7 +8897,7 @@ var allowedStatuses = [
|
|
|
8868
8897
|
async function setStatusCommand(id2, status2) {
|
|
8869
8898
|
if (!allowedStatuses.includes(status2)) {
|
|
8870
8899
|
console.log(
|
|
8871
|
-
|
|
8900
|
+
chalk85.red(
|
|
8872
8901
|
`Invalid status "${status2}". Must be one of: ${allowedStatuses.join(", ")}.`
|
|
8873
8902
|
)
|
|
8874
8903
|
);
|
|
@@ -8877,19 +8906,19 @@ async function setStatusCommand(id2, status2) {
|
|
|
8877
8906
|
}
|
|
8878
8907
|
const name = await setStatus(id2, status2);
|
|
8879
8908
|
if (name) {
|
|
8880
|
-
console.log(
|
|
8909
|
+
console.log(chalk85.green(`Set item #${id2} to ${status2}: ${name}`));
|
|
8881
8910
|
}
|
|
8882
8911
|
}
|
|
8883
8912
|
|
|
8884
8913
|
// src/commands/backlog/star/index.ts
|
|
8885
|
-
import
|
|
8914
|
+
import chalk87 from "chalk";
|
|
8886
8915
|
|
|
8887
8916
|
// src/commands/backlog/setStarred.ts
|
|
8888
|
-
import
|
|
8917
|
+
import chalk86 from "chalk";
|
|
8889
8918
|
async function setStarred(id2, starred) {
|
|
8890
8919
|
const { orm } = await getReady();
|
|
8891
8920
|
const name = await updateStarred(orm, Number.parseInt(id2, 10), starred);
|
|
8892
|
-
if (name === void 0) console.log(
|
|
8921
|
+
if (name === void 0) console.log(chalk86.red(`Item #${id2} not found.`));
|
|
8893
8922
|
return name;
|
|
8894
8923
|
}
|
|
8895
8924
|
|
|
@@ -8897,45 +8926,45 @@ async function setStarred(id2, starred) {
|
|
|
8897
8926
|
async function star(id2) {
|
|
8898
8927
|
const name = await setStarred(id2, true);
|
|
8899
8928
|
if (name) {
|
|
8900
|
-
console.log(
|
|
8929
|
+
console.log(chalk87.green(`Starred item #${id2}: ${name}`));
|
|
8901
8930
|
}
|
|
8902
8931
|
}
|
|
8903
8932
|
|
|
8904
8933
|
// src/commands/backlog/start/index.ts
|
|
8905
|
-
import
|
|
8934
|
+
import chalk88 from "chalk";
|
|
8906
8935
|
async function start(id2) {
|
|
8907
8936
|
const name = await setStatus(id2, "in-progress");
|
|
8908
8937
|
if (name) {
|
|
8909
|
-
console.log(
|
|
8938
|
+
console.log(chalk88.green(`Started item #${id2}: ${name}`));
|
|
8910
8939
|
}
|
|
8911
8940
|
}
|
|
8912
8941
|
|
|
8913
8942
|
// src/commands/backlog/stop/index.ts
|
|
8914
|
-
import
|
|
8915
|
-
import { and as and8, eq as
|
|
8943
|
+
import chalk89 from "chalk";
|
|
8944
|
+
import { and as and8, eq as eq24 } from "drizzle-orm";
|
|
8916
8945
|
async function stop() {
|
|
8917
8946
|
const { orm } = await getReady();
|
|
8918
|
-
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and8(
|
|
8947
|
+
const stopped = await orm.update(items).set({ status: "todo", currentPhase: 1 }).where(and8(eq24(items.status, "in-progress"), eq24(items.origin, getOrigin()))).returning({ id: items.id, name: items.name });
|
|
8919
8948
|
if (stopped.length === 0) {
|
|
8920
|
-
console.log(
|
|
8949
|
+
console.log(chalk89.yellow("No in-progress items to stop."));
|
|
8921
8950
|
return;
|
|
8922
8951
|
}
|
|
8923
8952
|
for (const item of stopped) {
|
|
8924
|
-
console.log(
|
|
8953
|
+
console.log(chalk89.yellow(`Stopped item #${item.id}: ${item.name}`));
|
|
8925
8954
|
}
|
|
8926
8955
|
}
|
|
8927
8956
|
|
|
8928
8957
|
// src/commands/backlog/unstar/index.ts
|
|
8929
|
-
import
|
|
8958
|
+
import chalk90 from "chalk";
|
|
8930
8959
|
async function unstar(id2) {
|
|
8931
8960
|
const name = await setStarred(id2, false);
|
|
8932
8961
|
if (name) {
|
|
8933
|
-
console.log(
|
|
8962
|
+
console.log(chalk90.green(`Unstarred item #${id2}: ${name}`));
|
|
8934
8963
|
}
|
|
8935
8964
|
}
|
|
8936
8965
|
|
|
8937
8966
|
// src/commands/backlog/wontdo/index.ts
|
|
8938
|
-
import
|
|
8967
|
+
import chalk91 from "chalk";
|
|
8939
8968
|
async function wontdo(id2, reason) {
|
|
8940
8969
|
const found = await findOneItem(id2);
|
|
8941
8970
|
if (!found) return;
|
|
@@ -8945,7 +8974,7 @@ async function wontdo(id2, reason) {
|
|
|
8945
8974
|
const phase = item.currentPhase ?? 1;
|
|
8946
8975
|
await appendComment(orm, item.id, reason, { phase, type: "summary" });
|
|
8947
8976
|
}
|
|
8948
|
-
console.log(
|
|
8977
|
+
console.log(chalk91.red(`Won't do item #${id2}: ${item.name}`));
|
|
8949
8978
|
}
|
|
8950
8979
|
|
|
8951
8980
|
// src/commands/backlog/registerStatusCommands.ts
|
|
@@ -8963,17 +8992,17 @@ function registerStatusCommands(cmd) {
|
|
|
8963
8992
|
}
|
|
8964
8993
|
|
|
8965
8994
|
// src/commands/backlog/addSubtask.ts
|
|
8966
|
-
import
|
|
8995
|
+
import chalk92 from "chalk";
|
|
8967
8996
|
async function addSubtask(id2, options2) {
|
|
8968
8997
|
const title = options2.title?.trim();
|
|
8969
8998
|
if (!title) {
|
|
8970
|
-
console.log(
|
|
8999
|
+
console.log(chalk92.red("A sub-task title is required (--title)."));
|
|
8971
9000
|
process.exitCode = 1;
|
|
8972
9001
|
return;
|
|
8973
9002
|
}
|
|
8974
9003
|
if (title.length > 50) {
|
|
8975
9004
|
console.log(
|
|
8976
|
-
|
|
9005
|
+
chalk92.red(
|
|
8977
9006
|
"A sub-task title must be 50 characters or fewer. Use --desc for longer detail."
|
|
8978
9007
|
)
|
|
8979
9008
|
);
|
|
@@ -8988,20 +9017,20 @@ async function addSubtask(id2, options2) {
|
|
|
8988
9017
|
const { orm, item } = found;
|
|
8989
9018
|
const description = options2.desc?.replaceAll(String.raw`\n`, "\n");
|
|
8990
9019
|
await insertSubtask(orm, item.id, title, description);
|
|
8991
|
-
console.log(
|
|
9020
|
+
console.log(chalk92.green(`Added sub-task to item #${id2}: ${title}`));
|
|
8992
9021
|
}
|
|
8993
9022
|
|
|
8994
9023
|
// src/commands/backlog/editSubtask.ts
|
|
8995
|
-
import
|
|
9024
|
+
import chalk94 from "chalk";
|
|
8996
9025
|
|
|
8997
9026
|
// src/commands/backlog/resolveSubtaskIndex.ts
|
|
8998
|
-
import
|
|
9027
|
+
import chalk93 from "chalk";
|
|
8999
9028
|
function resolveSubtaskIndex(id2, index3, item) {
|
|
9000
9029
|
const position = Number.parseInt(index3, 10);
|
|
9001
9030
|
const subtasks = item.subtasks ?? [];
|
|
9002
9031
|
if (Number.isNaN(position) || position < 1 || position > subtasks.length) {
|
|
9003
9032
|
console.log(
|
|
9004
|
-
|
|
9033
|
+
chalk93.red(
|
|
9005
9034
|
`Item #${id2} has no sub-task ${index3}${subtasks.length > 0 ? ` (1-${subtasks.length})` : ""}.`
|
|
9006
9035
|
)
|
|
9007
9036
|
);
|
|
@@ -9024,13 +9053,13 @@ async function findSubtask(id2, index3) {
|
|
|
9024
9053
|
}
|
|
9025
9054
|
|
|
9026
9055
|
// src/commands/backlog/updateSubtask.ts
|
|
9027
|
-
import { and as and9, eq as
|
|
9056
|
+
import { and as and9, eq as eq25 } from "drizzle-orm";
|
|
9028
9057
|
async function updateSubtask(orm, itemId, idx, fields) {
|
|
9029
9058
|
const set = {};
|
|
9030
9059
|
if (fields.title !== void 0) set.title = fields.title;
|
|
9031
9060
|
if (fields.description !== void 0) set.description = fields.description;
|
|
9032
9061
|
if (fields.status !== void 0) set.status = fields.status;
|
|
9033
|
-
const [row] = await orm.update(itemSubtasks).set(set).where(and9(
|
|
9062
|
+
const [row] = await orm.update(itemSubtasks).set(set).where(and9(eq25(itemSubtasks.itemId, itemId), eq25(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
9034
9063
|
return row?.title;
|
|
9035
9064
|
}
|
|
9036
9065
|
|
|
@@ -9068,31 +9097,31 @@ async function editSubtask(id2, index3, options2) {
|
|
|
9068
9097
|
if (!found) return;
|
|
9069
9098
|
const fields = buildUpdate(options2);
|
|
9070
9099
|
if (typeof fields === "string") {
|
|
9071
|
-
console.log(
|
|
9100
|
+
console.log(chalk94.red(fields));
|
|
9072
9101
|
process.exitCode = 1;
|
|
9073
9102
|
return;
|
|
9074
9103
|
}
|
|
9075
9104
|
const { orm, item, idx } = found;
|
|
9076
9105
|
const title = await updateSubtask(orm, item.id, idx, fields);
|
|
9077
9106
|
console.log(
|
|
9078
|
-
|
|
9107
|
+
chalk94.green(`Updated sub-task ${idx + 1} of item #${id2}: ${title}`)
|
|
9079
9108
|
);
|
|
9080
9109
|
}
|
|
9081
9110
|
|
|
9082
9111
|
// src/commands/backlog/removeSubtask.ts
|
|
9083
|
-
import
|
|
9112
|
+
import chalk95 from "chalk";
|
|
9084
9113
|
|
|
9085
9114
|
// src/commands/backlog/deleteSubtask.ts
|
|
9086
|
-
import { and as and10, asc as asc6, eq as
|
|
9115
|
+
import { and as and10, asc as asc6, eq as eq26 } from "drizzle-orm";
|
|
9087
9116
|
async function deleteSubtask(orm, itemId, idx) {
|
|
9088
|
-
const [row] = await orm.delete(itemSubtasks).where(and10(
|
|
9117
|
+
const [row] = await orm.delete(itemSubtasks).where(and10(eq26(itemSubtasks.itemId, itemId), eq26(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
9089
9118
|
if (!row) return void 0;
|
|
9090
|
-
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(
|
|
9119
|
+
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq26(itemSubtasks.itemId, itemId)).orderBy(asc6(itemSubtasks.idx));
|
|
9091
9120
|
for (let i = 0; i < remaining.length; i++) {
|
|
9092
9121
|
const oldIdx = remaining[i].idx;
|
|
9093
9122
|
if (oldIdx === i) continue;
|
|
9094
9123
|
await orm.update(itemSubtasks).set({ idx: i }).where(
|
|
9095
|
-
and10(
|
|
9124
|
+
and10(eq26(itemSubtasks.itemId, itemId), eq26(itemSubtasks.idx, oldIdx))
|
|
9096
9125
|
);
|
|
9097
9126
|
}
|
|
9098
9127
|
return row.title;
|
|
@@ -9105,16 +9134,16 @@ async function removeSubtask(id2, index3) {
|
|
|
9105
9134
|
const { orm, item, idx } = found;
|
|
9106
9135
|
const title = await deleteSubtask(orm, item.id, idx);
|
|
9107
9136
|
console.log(
|
|
9108
|
-
|
|
9137
|
+
chalk95.green(`Removed sub-task ${idx + 1} of item #${id2}: ${title}`)
|
|
9109
9138
|
);
|
|
9110
9139
|
}
|
|
9111
9140
|
|
|
9112
9141
|
// src/commands/backlog/subtaskStatus.ts
|
|
9113
|
-
import
|
|
9142
|
+
import chalk96 from "chalk";
|
|
9114
9143
|
async function subtaskStatus(id2, index3, status2) {
|
|
9115
9144
|
if (!validSubtaskStatuses.includes(status2)) {
|
|
9116
9145
|
console.log(
|
|
9117
|
-
|
|
9146
|
+
chalk96.red(
|
|
9118
9147
|
`Invalid status "${status2}". Use one of: ${validSubtaskStatuses.join(", ")}.`
|
|
9119
9148
|
)
|
|
9120
9149
|
);
|
|
@@ -9131,7 +9160,7 @@ async function subtaskStatus(id2, index3, status2) {
|
|
|
9131
9160
|
status2
|
|
9132
9161
|
);
|
|
9133
9162
|
console.log(
|
|
9134
|
-
|
|
9163
|
+
chalk96.green(
|
|
9135
9164
|
`Set sub-task ${idx + 1} of item #${id2} to ${status2}: ${title}`
|
|
9136
9165
|
)
|
|
9137
9166
|
);
|
|
@@ -9158,21 +9187,21 @@ function registerSubtaskCommands(cmd) {
|
|
|
9158
9187
|
}
|
|
9159
9188
|
|
|
9160
9189
|
// src/commands/backlog/movePhase.ts
|
|
9161
|
-
import
|
|
9162
|
-
import { count as count6, eq as
|
|
9190
|
+
import chalk97 from "chalk";
|
|
9191
|
+
import { count as count6, eq as eq29 } from "drizzle-orm";
|
|
9163
9192
|
|
|
9164
9193
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
9165
|
-
import { and as and12, asc as asc8, eq as
|
|
9194
|
+
import { and as and12, asc as asc8, eq as eq28 } from "drizzle-orm";
|
|
9166
9195
|
|
|
9167
9196
|
// src/commands/backlog/reindexPhases.ts
|
|
9168
|
-
import { and as and11, asc as asc7, count as count5, eq as
|
|
9197
|
+
import { and as and11, asc as asc7, count as count5, eq as eq27 } from "drizzle-orm";
|
|
9169
9198
|
async function reindexPhases(db, itemId) {
|
|
9170
|
-
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
9199
|
+
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq27(planPhases.itemId, itemId)).orderBy(asc7(planPhases.idx));
|
|
9171
9200
|
for (let i = 0; i < remaining.length; i++) {
|
|
9172
9201
|
const oldIdx = remaining[i].idx;
|
|
9173
9202
|
if (oldIdx === i) continue;
|
|
9174
|
-
await db.update(planTasks).set({ phaseIdx: i }).where(and11(
|
|
9175
|
-
await db.update(planPhases).set({ idx: i }).where(and11(
|
|
9203
|
+
await db.update(planTasks).set({ phaseIdx: i }).where(and11(eq27(planTasks.itemId, itemId), eq27(planTasks.phaseIdx, oldIdx)));
|
|
9204
|
+
await db.update(planPhases).set({ idx: i }).where(and11(eq27(planPhases.itemId, itemId), eq27(planPhases.idx, oldIdx)));
|
|
9176
9205
|
}
|
|
9177
9206
|
}
|
|
9178
9207
|
async function adjustCurrentPhase(db, item, removedIdx) {
|
|
@@ -9180,24 +9209,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
9180
9209
|
if (currentPhase === void 0) return;
|
|
9181
9210
|
const currentIdx = currentPhase - 1;
|
|
9182
9211
|
if (removedIdx < currentIdx) {
|
|
9183
|
-
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(
|
|
9212
|
+
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq27(items.id, item.id));
|
|
9184
9213
|
return;
|
|
9185
9214
|
}
|
|
9186
9215
|
if (removedIdx !== currentIdx) return;
|
|
9187
|
-
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(
|
|
9216
|
+
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(eq27(planPhases.itemId, item.id));
|
|
9188
9217
|
const cnt = row?.cnt ?? 0;
|
|
9189
|
-
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(
|
|
9218
|
+
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq27(items.id, item.id));
|
|
9190
9219
|
}
|
|
9191
9220
|
|
|
9192
9221
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
9193
9222
|
async function reorderPhaseRows(orm, itemId, fromIdx, toIdx) {
|
|
9194
9223
|
await orm.transaction(async (tx) => {
|
|
9195
|
-
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and12(
|
|
9196
|
-
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and12(
|
|
9224
|
+
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and12(eq28(planPhases.itemId, itemId), eq28(planPhases.idx, fromIdx)));
|
|
9225
|
+
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and12(eq28(planTasks.itemId, itemId), eq28(planTasks.phaseIdx, fromIdx))).orderBy(asc8(planTasks.idx));
|
|
9197
9226
|
await tx.delete(planTasks).where(
|
|
9198
|
-
and12(
|
|
9227
|
+
and12(eq28(planTasks.itemId, itemId), eq28(planTasks.phaseIdx, fromIdx))
|
|
9199
9228
|
);
|
|
9200
|
-
await tx.delete(planPhases).where(and12(
|
|
9229
|
+
await tx.delete(planPhases).where(and12(eq28(planPhases.itemId, itemId), eq28(planPhases.idx, fromIdx)));
|
|
9201
9230
|
await reindexPhases(tx, itemId);
|
|
9202
9231
|
await shiftPhasesUp(tx, itemId, toIdx);
|
|
9203
9232
|
await tx.insert(planPhases).values({
|
|
@@ -9224,7 +9253,7 @@ function toIndex(value, phaseCount) {
|
|
|
9224
9253
|
const pos = Number.parseInt(value, 10);
|
|
9225
9254
|
if (Number.isNaN(pos) || pos < 1 || pos > phaseCount) {
|
|
9226
9255
|
console.log(
|
|
9227
|
-
|
|
9256
|
+
chalk97.red(
|
|
9228
9257
|
`Position "${value}" is out of range. Must be between 1 and ${phaseCount}.`
|
|
9229
9258
|
)
|
|
9230
9259
|
);
|
|
@@ -9238,7 +9267,7 @@ async function movePhase(id2, from, to) {
|
|
|
9238
9267
|
if (!found) return;
|
|
9239
9268
|
const { orm, item } = found;
|
|
9240
9269
|
const itemId = item.id;
|
|
9241
|
-
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(
|
|
9270
|
+
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(eq29(planPhases.itemId, itemId));
|
|
9242
9271
|
const phaseCount = row?.cnt ?? 0;
|
|
9243
9272
|
const fromIdx = toIndex(from, phaseCount);
|
|
9244
9273
|
if (fromIdx === void 0) return;
|
|
@@ -9247,29 +9276,29 @@ async function movePhase(id2, from, to) {
|
|
|
9247
9276
|
if (fromIdx !== toIdx) {
|
|
9248
9277
|
await reorderPhaseRows(orm, itemId, fromIdx, toIdx);
|
|
9249
9278
|
}
|
|
9250
|
-
console.log(
|
|
9279
|
+
console.log(chalk97.green(`Moved phase ${from} to position ${to}.`));
|
|
9251
9280
|
}
|
|
9252
9281
|
|
|
9253
9282
|
// src/commands/backlog/updatePhase.ts
|
|
9254
|
-
import
|
|
9283
|
+
import chalk99 from "chalk";
|
|
9255
9284
|
|
|
9256
9285
|
// src/commands/backlog/applyPhaseUpdate.ts
|
|
9257
|
-
import { and as and13, eq as
|
|
9286
|
+
import { and as and13, eq as eq30 } from "drizzle-orm";
|
|
9258
9287
|
async function applyPhaseUpdate(orm, itemId, phaseIdx, fields) {
|
|
9259
9288
|
await orm.transaction(async (tx) => {
|
|
9260
9289
|
if (fields.name) {
|
|
9261
9290
|
await tx.update(planPhases).set({ name: fields.name }).where(
|
|
9262
|
-
and13(
|
|
9291
|
+
and13(eq30(planPhases.itemId, itemId), eq30(planPhases.idx, phaseIdx))
|
|
9263
9292
|
);
|
|
9264
9293
|
}
|
|
9265
9294
|
if (fields.manualCheck) {
|
|
9266
9295
|
await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
|
|
9267
|
-
and13(
|
|
9296
|
+
and13(eq30(planPhases.itemId, itemId), eq30(planPhases.idx, phaseIdx))
|
|
9268
9297
|
);
|
|
9269
9298
|
}
|
|
9270
9299
|
if (fields.task) {
|
|
9271
9300
|
await tx.delete(planTasks).where(
|
|
9272
|
-
and13(
|
|
9301
|
+
and13(eq30(planTasks.itemId, itemId), eq30(planTasks.phaseIdx, phaseIdx))
|
|
9273
9302
|
);
|
|
9274
9303
|
if (fields.task.length) {
|
|
9275
9304
|
await tx.insert(planTasks).values(
|
|
@@ -9286,18 +9315,18 @@ async function applyPhaseUpdate(orm, itemId, phaseIdx, fields) {
|
|
|
9286
9315
|
}
|
|
9287
9316
|
|
|
9288
9317
|
// src/commands/backlog/findPhase.ts
|
|
9289
|
-
import
|
|
9290
|
-
import { and as and14, count as count7, eq as
|
|
9318
|
+
import chalk98 from "chalk";
|
|
9319
|
+
import { and as and14, count as count7, eq as eq31 } from "drizzle-orm";
|
|
9291
9320
|
async function findPhase(id2, phase) {
|
|
9292
9321
|
const found = await findOneItem(id2);
|
|
9293
9322
|
if (!found) return void 0;
|
|
9294
9323
|
const { orm, item } = found;
|
|
9295
9324
|
const itemId = item.id;
|
|
9296
9325
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
9297
|
-
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and14(
|
|
9326
|
+
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and14(eq31(planPhases.itemId, itemId), eq31(planPhases.idx, phaseIdx)));
|
|
9298
9327
|
if (!row || row.cnt === 0) {
|
|
9299
9328
|
console.log(
|
|
9300
|
-
|
|
9329
|
+
chalk98.red(`Phase ${phaseIdx + 1} not found on item #${itemId}.`)
|
|
9301
9330
|
);
|
|
9302
9331
|
process.exitCode = 1;
|
|
9303
9332
|
return void 0;
|
|
@@ -9429,7 +9458,7 @@ async function updatePhase(id2, phase, options2) {
|
|
|
9429
9458
|
const { item, orm, itemId, phaseIdx } = found;
|
|
9430
9459
|
const resolved = resolvePhaseFields(options2, item.plan?.[phaseIdx]);
|
|
9431
9460
|
if (!resolved.ok) {
|
|
9432
|
-
console.log(
|
|
9461
|
+
console.log(chalk99.red(resolved.error));
|
|
9433
9462
|
process.exitCode = 1;
|
|
9434
9463
|
return;
|
|
9435
9464
|
}
|
|
@@ -9441,7 +9470,7 @@ async function updatePhase(id2, phase, options2) {
|
|
|
9441
9470
|
manualCheck && "manual checks"
|
|
9442
9471
|
].filter(Boolean).join(", ");
|
|
9443
9472
|
console.log(
|
|
9444
|
-
|
|
9473
|
+
chalk99.green(
|
|
9445
9474
|
`Updated ${fields} on phase ${phaseIdx + 1} of item #${itemId}.`
|
|
9446
9475
|
)
|
|
9447
9476
|
);
|
|
@@ -9464,28 +9493,28 @@ function registerUpdatePhaseCommand(cmd) {
|
|
|
9464
9493
|
}
|
|
9465
9494
|
|
|
9466
9495
|
// src/commands/backlog/removePhase.ts
|
|
9467
|
-
import
|
|
9468
|
-
import { and as and15, eq as
|
|
9496
|
+
import chalk100 from "chalk";
|
|
9497
|
+
import { and as and15, eq as eq32 } from "drizzle-orm";
|
|
9469
9498
|
async function removePhase(id2, phase) {
|
|
9470
9499
|
const found = await findPhase(id2, phase);
|
|
9471
9500
|
if (!found) return;
|
|
9472
9501
|
const { item, orm, itemId, phaseIdx } = found;
|
|
9473
9502
|
await orm.transaction(async (tx) => {
|
|
9474
9503
|
await tx.delete(planTasks).where(
|
|
9475
|
-
and15(
|
|
9504
|
+
and15(eq32(planTasks.itemId, itemId), eq32(planTasks.phaseIdx, phaseIdx))
|
|
9476
9505
|
);
|
|
9477
|
-
await tx.delete(planPhases).where(and15(
|
|
9506
|
+
await tx.delete(planPhases).where(and15(eq32(planPhases.itemId, itemId), eq32(planPhases.idx, phaseIdx)));
|
|
9478
9507
|
await reindexPhases(tx, itemId);
|
|
9479
9508
|
await adjustCurrentPhase(tx, item, phaseIdx);
|
|
9480
9509
|
});
|
|
9481
9510
|
console.log(
|
|
9482
|
-
|
|
9511
|
+
chalk100.green(`Removed phase ${phaseIdx + 1} from item #${itemId}.`)
|
|
9483
9512
|
);
|
|
9484
9513
|
}
|
|
9485
9514
|
|
|
9486
9515
|
// src/commands/backlog/update/index.ts
|
|
9487
|
-
import
|
|
9488
|
-
import { eq as
|
|
9516
|
+
import chalk102 from "chalk";
|
|
9517
|
+
import { eq as eq33 } from "drizzle-orm";
|
|
9489
9518
|
|
|
9490
9519
|
// src/commands/backlog/update/applyAcMutations.ts
|
|
9491
9520
|
function hasAcMutations(options2) {
|
|
@@ -9506,16 +9535,16 @@ function applyAcMutations(current, options2) {
|
|
|
9506
9535
|
}
|
|
9507
9536
|
|
|
9508
9537
|
// src/commands/backlog/update/buildUpdateValues.ts
|
|
9509
|
-
import
|
|
9538
|
+
import chalk101 from "chalk";
|
|
9510
9539
|
function buildUpdateValues(options2) {
|
|
9511
9540
|
const { name, desc: desc6, type, ac } = options2;
|
|
9512
9541
|
if (!name && !desc6 && !type && !ac) {
|
|
9513
|
-
console.log(
|
|
9542
|
+
console.log(chalk101.red("Nothing to update. Provide at least one flag."));
|
|
9514
9543
|
process.exitCode = 1;
|
|
9515
9544
|
return void 0;
|
|
9516
9545
|
}
|
|
9517
9546
|
if (type && type !== "story" && type !== "bug") {
|
|
9518
|
-
console.log(
|
|
9547
|
+
console.log(chalk101.red('Invalid type. Must be "story" or "bug".'));
|
|
9519
9548
|
process.exitCode = 1;
|
|
9520
9549
|
return void 0;
|
|
9521
9550
|
}
|
|
@@ -9548,14 +9577,14 @@ async function update(id2, options2) {
|
|
|
9548
9577
|
if (hasAcMutations(options2)) {
|
|
9549
9578
|
if (options2.ac) {
|
|
9550
9579
|
console.log(
|
|
9551
|
-
|
|
9580
|
+
chalk102.red("Cannot combine --ac with --add-ac/--edit-ac/--remove-ac.")
|
|
9552
9581
|
);
|
|
9553
9582
|
process.exitCode = 1;
|
|
9554
9583
|
return;
|
|
9555
9584
|
}
|
|
9556
9585
|
const mutation = applyAcMutations(found.item.acceptanceCriteria, options2);
|
|
9557
9586
|
if (!mutation.ok) {
|
|
9558
|
-
console.log(
|
|
9587
|
+
console.log(chalk102.red(mutation.error));
|
|
9559
9588
|
process.exitCode = 1;
|
|
9560
9589
|
return;
|
|
9561
9590
|
}
|
|
@@ -9565,8 +9594,8 @@ async function update(id2, options2) {
|
|
|
9565
9594
|
if (!built) return;
|
|
9566
9595
|
const { orm } = found;
|
|
9567
9596
|
const itemId = found.item.id;
|
|
9568
|
-
await orm.update(items).set(built.set).where(
|
|
9569
|
-
console.log(
|
|
9597
|
+
await orm.update(items).set(built.set).where(eq33(items.id, itemId));
|
|
9598
|
+
console.log(chalk102.green(`Updated ${built.fields} on item #${itemId}.`));
|
|
9570
9599
|
}
|
|
9571
9600
|
|
|
9572
9601
|
// src/commands/backlog/registerUpdateCommands.ts
|
|
@@ -9618,7 +9647,8 @@ var registrars = [
|
|
|
9618
9647
|
registerExportCommand,
|
|
9619
9648
|
registerImportCommand,
|
|
9620
9649
|
registerMoveRepoCommand,
|
|
9621
|
-
registerAssociateJiraCommand
|
|
9650
|
+
registerAssociateJiraCommand,
|
|
9651
|
+
registerActivityCommands
|
|
9622
9652
|
];
|
|
9623
9653
|
function registerBacklog(program2) {
|
|
9624
9654
|
const cmd = program2.command("backlog").description("Manage a backlog of work items").option("--dir <path>", "Override directory for backlog file discovery").option("--no-open", "Do not open a browser on startup").hook("preAction", (thisCommand) => {
|
|
@@ -10368,11 +10398,11 @@ function assertCliExists(cli) {
|
|
|
10368
10398
|
}
|
|
10369
10399
|
|
|
10370
10400
|
// src/commands/permitCliReads/colorize.ts
|
|
10371
|
-
import
|
|
10401
|
+
import chalk103 from "chalk";
|
|
10372
10402
|
function colorize(plainOutput) {
|
|
10373
10403
|
return plainOutput.split("\n").map((line) => {
|
|
10374
|
-
if (line.startsWith(" R ")) return
|
|
10375
|
-
if (line.startsWith(" W ")) return
|
|
10404
|
+
if (line.startsWith(" R ")) return chalk103.green(line);
|
|
10405
|
+
if (line.startsWith(" W ")) return chalk103.red(line);
|
|
10376
10406
|
return line;
|
|
10377
10407
|
}).join("\n");
|
|
10378
10408
|
}
|
|
@@ -10670,7 +10700,7 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
10670
10700
|
}
|
|
10671
10701
|
|
|
10672
10702
|
// src/commands/deny/denyAdd.ts
|
|
10673
|
-
import
|
|
10703
|
+
import chalk104 from "chalk";
|
|
10674
10704
|
|
|
10675
10705
|
// src/commands/deny/loadDenyConfig.ts
|
|
10676
10706
|
function loadDenyConfig(global) {
|
|
@@ -10690,16 +10720,16 @@ function loadDenyConfig(global) {
|
|
|
10690
10720
|
function denyAdd(pattern2, message, options2) {
|
|
10691
10721
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
10692
10722
|
if (deny.some((r) => r.pattern === pattern2)) {
|
|
10693
|
-
console.log(
|
|
10723
|
+
console.log(chalk104.yellow(`Deny rule already exists for: ${pattern2}`));
|
|
10694
10724
|
return;
|
|
10695
10725
|
}
|
|
10696
10726
|
deny.push({ pattern: pattern2, message });
|
|
10697
10727
|
saveDeny(deny);
|
|
10698
|
-
console.log(
|
|
10728
|
+
console.log(chalk104.green(`Added deny rule: ${pattern2} \u2192 ${message}`));
|
|
10699
10729
|
}
|
|
10700
10730
|
|
|
10701
10731
|
// src/commands/deny/denyList.ts
|
|
10702
|
-
import
|
|
10732
|
+
import chalk105 from "chalk";
|
|
10703
10733
|
function denyList() {
|
|
10704
10734
|
const globalRaw = loadGlobalConfigRaw();
|
|
10705
10735
|
const projectRaw = loadProjectConfig();
|
|
@@ -10710,7 +10740,7 @@ function denyList() {
|
|
|
10710
10740
|
projectDeny.length > 0 ? projectDeny : void 0
|
|
10711
10741
|
);
|
|
10712
10742
|
if (!merged || merged.length === 0) {
|
|
10713
|
-
console.log(
|
|
10743
|
+
console.log(chalk105.dim("No deny rules configured."));
|
|
10714
10744
|
return;
|
|
10715
10745
|
}
|
|
10716
10746
|
const projectPatterns = new Set(projectDeny.map((r) => r.pattern));
|
|
@@ -10718,23 +10748,23 @@ function denyList() {
|
|
|
10718
10748
|
for (const rule of merged) {
|
|
10719
10749
|
const inProject = projectPatterns.has(rule.pattern);
|
|
10720
10750
|
const inGlobal = globalPatterns.has(rule.pattern);
|
|
10721
|
-
const label2 = inProject && inGlobal ?
|
|
10722
|
-
console.log(`${
|
|
10751
|
+
const label2 = inProject && inGlobal ? chalk105.dim(" (project, overrides global)") : inGlobal ? chalk105.dim(" (global)") : "";
|
|
10752
|
+
console.log(`${chalk105.red(rule.pattern)} \u2192 ${rule.message}${label2}`);
|
|
10723
10753
|
}
|
|
10724
10754
|
}
|
|
10725
10755
|
|
|
10726
10756
|
// src/commands/deny/denyRemove.ts
|
|
10727
|
-
import
|
|
10757
|
+
import chalk106 from "chalk";
|
|
10728
10758
|
function denyRemove(pattern2, options2) {
|
|
10729
10759
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
10730
10760
|
const index3 = deny.findIndex((r) => r.pattern === pattern2);
|
|
10731
10761
|
if (index3 === -1) {
|
|
10732
|
-
console.log(
|
|
10762
|
+
console.log(chalk106.yellow(`No deny rule found for: ${pattern2}`));
|
|
10733
10763
|
return;
|
|
10734
10764
|
}
|
|
10735
10765
|
deny.splice(index3, 1);
|
|
10736
10766
|
saveDeny(deny.length > 0 ? deny : void 0);
|
|
10737
|
-
console.log(
|
|
10767
|
+
console.log(chalk106.green(`Removed deny rule: ${pattern2}`));
|
|
10738
10768
|
}
|
|
10739
10769
|
|
|
10740
10770
|
// src/commands/registerDeny.ts
|
|
@@ -10764,7 +10794,7 @@ function registerCliHook(program2) {
|
|
|
10764
10794
|
|
|
10765
10795
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
10766
10796
|
import { existsSync as existsSync30, readFileSync as readFileSync25, unlinkSync as unlinkSync8, writeFileSync as writeFileSync23 } from "fs";
|
|
10767
|
-
import
|
|
10797
|
+
import chalk107 from "chalk";
|
|
10768
10798
|
|
|
10769
10799
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
10770
10800
|
import { homedir as homedir14 } from "os";
|
|
@@ -10817,12 +10847,12 @@ function codeCommentConfirm(pin) {
|
|
|
10817
10847
|
sweepRestrictedDir();
|
|
10818
10848
|
const state = readPinState(pin);
|
|
10819
10849
|
if (!state) {
|
|
10820
|
-
console.error(
|
|
10850
|
+
console.error(chalk107.red(`No pending comment for pin: ${pin}`));
|
|
10821
10851
|
process.exitCode = 1;
|
|
10822
10852
|
return;
|
|
10823
10853
|
}
|
|
10824
10854
|
if (!existsSync30(state.file)) {
|
|
10825
|
-
console.error(
|
|
10855
|
+
console.error(chalk107.red(`Target file no longer exists: ${state.file}`));
|
|
10826
10856
|
process.exitCode = 1;
|
|
10827
10857
|
return;
|
|
10828
10858
|
}
|
|
@@ -10831,7 +10861,7 @@ function codeCommentConfirm(pin) {
|
|
|
10831
10861
|
const index3 = state.line - 1;
|
|
10832
10862
|
if (index3 > lines.length) {
|
|
10833
10863
|
console.error(
|
|
10834
|
-
|
|
10864
|
+
chalk107.red(
|
|
10835
10865
|
`Line ${state.line} is beyond the end of ${state.file} (${lines.length} lines).`
|
|
10836
10866
|
)
|
|
10837
10867
|
);
|
|
@@ -10845,14 +10875,14 @@ function codeCommentConfirm(pin) {
|
|
|
10845
10875
|
writeFileSync23(state.file, lines.join("\n"));
|
|
10846
10876
|
unlinkSync8(getPinStatePath(pin));
|
|
10847
10877
|
console.log(
|
|
10848
|
-
|
|
10878
|
+
chalk107.green(
|
|
10849
10879
|
`Inserted "${marker} ${state.text}" at ${state.file}:${state.line}`
|
|
10850
10880
|
)
|
|
10851
10881
|
);
|
|
10852
10882
|
}
|
|
10853
10883
|
|
|
10854
10884
|
// src/commands/codeComment/codeCommentSet.ts
|
|
10855
|
-
import
|
|
10885
|
+
import chalk108 from "chalk";
|
|
10856
10886
|
|
|
10857
10887
|
// src/commands/codeComment/validateCommentText.ts
|
|
10858
10888
|
var MAX_COMMENT_LENGTH = 50;
|
|
@@ -10903,27 +10933,27 @@ function generatePin() {
|
|
|
10903
10933
|
function codeCommentSet(file, line, text9) {
|
|
10904
10934
|
const lineNumber = Number.parseInt(line, 10);
|
|
10905
10935
|
if (!Number.isInteger(lineNumber) || lineNumber < 1) {
|
|
10906
|
-
console.error(
|
|
10936
|
+
console.error(chalk108.red(`Invalid line number: ${line}`));
|
|
10907
10937
|
process.exitCode = 1;
|
|
10908
10938
|
return;
|
|
10909
10939
|
}
|
|
10910
10940
|
const marker = isYamlFile(file) ? "#" : "//";
|
|
10911
10941
|
const validation = validateCommentText(text9, isYamlFile(file));
|
|
10912
10942
|
if (!validation.ok) {
|
|
10913
|
-
console.error(
|
|
10914
|
-
console.error(
|
|
10943
|
+
console.error(chalk108.red(`Refused: ${validation.reason}`));
|
|
10944
|
+
console.error(chalk108.red("No pin issued."));
|
|
10915
10945
|
process.exitCode = 1;
|
|
10916
10946
|
return;
|
|
10917
10947
|
}
|
|
10918
10948
|
console.error(
|
|
10919
|
-
|
|
10949
|
+
chalk108.yellow.bold(
|
|
10920
10950
|
"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."
|
|
10921
10951
|
)
|
|
10922
10952
|
);
|
|
10923
10953
|
const delivered = issuePin(file, lineNumber, validation.text);
|
|
10924
10954
|
if (!delivered) {
|
|
10925
10955
|
console.error(
|
|
10926
|
-
|
|
10956
|
+
chalk108.red(
|
|
10927
10957
|
"Could not deliver the confirmation pin via notification.\nThe comment cannot be confirmed until the notification channel works."
|
|
10928
10958
|
)
|
|
10929
10959
|
);
|
|
@@ -10933,7 +10963,7 @@ function codeCommentSet(file, line, text9) {
|
|
|
10933
10963
|
console.log(
|
|
10934
10964
|
`A confirmation pin was sent to your desktop notifications.
|
|
10935
10965
|
To insert "${marker} ${validation.text}" at ${file}:${lineNumber}, run:
|
|
10936
|
-
${
|
|
10966
|
+
${chalk108.cyan(" assist code-comment confirm <PIN>")}
|
|
10937
10967
|
using the pin from that notification.`
|
|
10938
10968
|
);
|
|
10939
10969
|
}
|
|
@@ -10953,15 +10983,15 @@ function registerCodeComment(parent) {
|
|
|
10953
10983
|
}
|
|
10954
10984
|
|
|
10955
10985
|
// src/commands/complexity/analyze.ts
|
|
10956
|
-
import
|
|
10986
|
+
import chalk117 from "chalk";
|
|
10957
10987
|
|
|
10958
10988
|
// src/commands/complexity/cyclomatic.ts
|
|
10959
|
-
import
|
|
10989
|
+
import chalk110 from "chalk";
|
|
10960
10990
|
|
|
10961
10991
|
// src/commands/complexity/shared/index.ts
|
|
10962
10992
|
import fs17 from "fs";
|
|
10963
10993
|
import path21 from "path";
|
|
10964
|
-
import
|
|
10994
|
+
import chalk109 from "chalk";
|
|
10965
10995
|
import ts5 from "typescript";
|
|
10966
10996
|
|
|
10967
10997
|
// src/commands/complexity/findSourceFiles.ts
|
|
@@ -11212,7 +11242,7 @@ function createSourceFromFile(filePath) {
|
|
|
11212
11242
|
function withSourceFiles(pattern2, callback, extraIgnore = []) {
|
|
11213
11243
|
const files = findSourceFiles2(pattern2, ".", extraIgnore);
|
|
11214
11244
|
if (files.length === 0) {
|
|
11215
|
-
console.log(
|
|
11245
|
+
console.log(chalk109.yellow("No files found matching pattern"));
|
|
11216
11246
|
return void 0;
|
|
11217
11247
|
}
|
|
11218
11248
|
return callback(files);
|
|
@@ -11245,11 +11275,11 @@ async function cyclomatic(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11245
11275
|
results.sort((a, b) => b.complexity - a.complexity);
|
|
11246
11276
|
for (const { file, name, complexity } of results) {
|
|
11247
11277
|
const exceedsThreshold = options2.threshold !== void 0 && complexity > options2.threshold;
|
|
11248
|
-
const color = exceedsThreshold ?
|
|
11249
|
-
console.log(`${color(`${file}:${name}`)} \u2192 ${
|
|
11278
|
+
const color = exceedsThreshold ? chalk110.red : chalk110.white;
|
|
11279
|
+
console.log(`${color(`${file}:${name}`)} \u2192 ${chalk110.cyan(complexity)}`);
|
|
11250
11280
|
}
|
|
11251
11281
|
console.log(
|
|
11252
|
-
|
|
11282
|
+
chalk110.dim(
|
|
11253
11283
|
`
|
|
11254
11284
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
11255
11285
|
)
|
|
@@ -11261,7 +11291,7 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
11261
11291
|
}
|
|
11262
11292
|
|
|
11263
11293
|
// src/commands/complexity/halstead.ts
|
|
11264
|
-
import
|
|
11294
|
+
import chalk111 from "chalk";
|
|
11265
11295
|
async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
11266
11296
|
withSourceFiles(pattern2, (files) => {
|
|
11267
11297
|
const results = [];
|
|
@@ -11276,13 +11306,13 @@ async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11276
11306
|
results.sort((a, b) => b.metrics.effort - a.metrics.effort);
|
|
11277
11307
|
for (const { file, name, metrics } of results) {
|
|
11278
11308
|
const exceedsThreshold = options2.threshold !== void 0 && metrics.volume > options2.threshold;
|
|
11279
|
-
const color = exceedsThreshold ?
|
|
11309
|
+
const color = exceedsThreshold ? chalk111.red : chalk111.white;
|
|
11280
11310
|
console.log(
|
|
11281
|
-
`${color(`${file}:${name}`)} \u2192 volume: ${
|
|
11311
|
+
`${color(`${file}:${name}`)} \u2192 volume: ${chalk111.cyan(metrics.volume.toFixed(1))}, difficulty: ${chalk111.yellow(metrics.difficulty.toFixed(1))}, effort: ${chalk111.magenta(metrics.effort.toFixed(1))}`
|
|
11282
11312
|
);
|
|
11283
11313
|
}
|
|
11284
11314
|
console.log(
|
|
11285
|
-
|
|
11315
|
+
chalk111.dim(
|
|
11286
11316
|
`
|
|
11287
11317
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
11288
11318
|
)
|
|
@@ -11294,27 +11324,27 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
11294
11324
|
}
|
|
11295
11325
|
|
|
11296
11326
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
11297
|
-
import
|
|
11327
|
+
import chalk114 from "chalk";
|
|
11298
11328
|
|
|
11299
11329
|
// src/commands/complexity/maintainability/formatResultLine.ts
|
|
11300
|
-
import
|
|
11330
|
+
import chalk112 from "chalk";
|
|
11301
11331
|
function formatResultLine(entry, failing) {
|
|
11302
11332
|
const { file, avgMaintainability, minMaintainability, override } = entry;
|
|
11303
|
-
const name = failing ?
|
|
11304
|
-
const suffix = override !== void 0 ?
|
|
11305
|
-
return `${name} \u2192 avg: ${
|
|
11333
|
+
const name = failing ? chalk112.red(file) : chalk112.white(file);
|
|
11334
|
+
const suffix = override !== void 0 ? chalk112.magenta(` (override: ${override})`) : "";
|
|
11335
|
+
return `${name} \u2192 avg: ${chalk112.cyan(avgMaintainability.toFixed(1))}, min: ${chalk112.yellow(minMaintainability.toFixed(1))}${suffix}`;
|
|
11306
11336
|
}
|
|
11307
11337
|
|
|
11308
11338
|
// src/commands/complexity/maintainability/printMaintainabilityFailure.ts
|
|
11309
|
-
import
|
|
11339
|
+
import chalk113 from "chalk";
|
|
11310
11340
|
function printMaintainabilityFailure(failingCount, threshold) {
|
|
11311
11341
|
const thresholdLabel = threshold !== void 0 ? ` ${threshold}` : "";
|
|
11312
11342
|
console.error(
|
|
11313
|
-
|
|
11343
|
+
chalk113.red(
|
|
11314
11344
|
`
|
|
11315
11345
|
Fail: ${failingCount} file(s) below threshold${thresholdLabel} (files marked "(override: N)" were judged against their own marker). Maintainability index (0\u2013100) is derived from Halstead volume, cyclomatic complexity, and lines of code.
|
|
11316
11346
|
|
|
11317
|
-
\u26A0\uFE0F ${
|
|
11347
|
+
\u26A0\uFE0F ${chalk113.bold("Diagnose and fix one file at a time")} \u2014 do not investigate or fix multiple files in parallel.
|
|
11318
11348
|
|
|
11319
11349
|
The score is a property of the whole file, not your diff: any existing logic counts, so the fix is to shrink the file \u2014 not to revert or micro-optimize the lines you just changed. Identify the largest cohesive responsibility (often the biggest function, or a related group of functions) and move it to a new file with 'assist refactor extract'. Run 'assist complexity <file>' for per-function metrics only to locate that responsibility, not to tweak individual lines.`
|
|
11320
11350
|
)
|
|
@@ -11326,7 +11356,7 @@ function displayMaintainabilityResults(results, threshold) {
|
|
|
11326
11356
|
const gating = threshold !== void 0 || results.some((r) => r.override !== void 0);
|
|
11327
11357
|
if (!gating) {
|
|
11328
11358
|
for (const entry of results) console.log(formatResultLine(entry, false));
|
|
11329
|
-
console.log(
|
|
11359
|
+
console.log(chalk114.dim(`
|
|
11330
11360
|
Analyzed ${results.length} files`));
|
|
11331
11361
|
return;
|
|
11332
11362
|
}
|
|
@@ -11335,7 +11365,7 @@ Analyzed ${results.length} files`));
|
|
|
11335
11365
|
return limit !== void 0 && r.minMaintainability < limit;
|
|
11336
11366
|
});
|
|
11337
11367
|
if (failing.length === 0) {
|
|
11338
|
-
console.log(
|
|
11368
|
+
console.log(chalk114.green("All files pass maintainability threshold"));
|
|
11339
11369
|
} else {
|
|
11340
11370
|
for (const entry of failing) console.log(formatResultLine(entry, true));
|
|
11341
11371
|
}
|
|
@@ -11344,7 +11374,7 @@ Analyzed ${results.length} files`));
|
|
|
11344
11374
|
);
|
|
11345
11375
|
for (const entry of passingOverrides)
|
|
11346
11376
|
console.log(formatResultLine(entry, false));
|
|
11347
|
-
console.log(
|
|
11377
|
+
console.log(chalk114.dim(`
|
|
11348
11378
|
Analyzed ${results.length} files`));
|
|
11349
11379
|
if (failing.length > 0) {
|
|
11350
11380
|
printMaintainabilityFailure(failing.length, threshold);
|
|
@@ -11353,10 +11383,10 @@ Analyzed ${results.length} files`));
|
|
|
11353
11383
|
}
|
|
11354
11384
|
|
|
11355
11385
|
// src/commands/complexity/maintainability/printMaintainabilityFormula.ts
|
|
11356
|
-
import
|
|
11386
|
+
import chalk115 from "chalk";
|
|
11357
11387
|
var MI_FORMULA = "171 - 5.2*ln(HalsteadVolume) - 0.23*CyclomaticComplexity - 16.2*ln(SLOC), clamped 0-100";
|
|
11358
11388
|
function printMaintainabilityFormula() {
|
|
11359
|
-
console.log(
|
|
11389
|
+
console.log(chalk115.dim(MI_FORMULA));
|
|
11360
11390
|
}
|
|
11361
11391
|
|
|
11362
11392
|
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
@@ -11432,7 +11462,7 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11432
11462
|
|
|
11433
11463
|
// src/commands/complexity/sloc.ts
|
|
11434
11464
|
import fs19 from "fs";
|
|
11435
|
-
import
|
|
11465
|
+
import chalk116 from "chalk";
|
|
11436
11466
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
11437
11467
|
withSourceFiles(pattern2, (files) => {
|
|
11438
11468
|
const results = [];
|
|
@@ -11448,12 +11478,12 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11448
11478
|
results.sort((a, b) => b.lines - a.lines);
|
|
11449
11479
|
for (const { file, lines } of results) {
|
|
11450
11480
|
const exceedsThreshold = options2.threshold !== void 0 && lines > options2.threshold;
|
|
11451
|
-
const color = exceedsThreshold ?
|
|
11452
|
-
console.log(`${color(file)} \u2192 ${
|
|
11481
|
+
const color = exceedsThreshold ? chalk116.red : chalk116.white;
|
|
11482
|
+
console.log(`${color(file)} \u2192 ${chalk116.cyan(lines)} lines`);
|
|
11453
11483
|
}
|
|
11454
11484
|
const total = results.reduce((sum, r) => sum + r.lines, 0);
|
|
11455
11485
|
console.log(
|
|
11456
|
-
|
|
11486
|
+
chalk116.dim(`
|
|
11457
11487
|
Total: ${total} lines across ${files.length} files`)
|
|
11458
11488
|
);
|
|
11459
11489
|
if (hasViolation) {
|
|
@@ -11467,25 +11497,25 @@ async function analyze(pattern2) {
|
|
|
11467
11497
|
const searchPattern = pattern2.includes("*") || pattern2.includes("/") ? pattern2 : `**/${pattern2}`;
|
|
11468
11498
|
const files = findSourceFiles2(searchPattern);
|
|
11469
11499
|
if (files.length === 0) {
|
|
11470
|
-
console.log(
|
|
11500
|
+
console.log(chalk117.yellow("No files found matching pattern"));
|
|
11471
11501
|
return;
|
|
11472
11502
|
}
|
|
11473
11503
|
if (files.length === 1) {
|
|
11474
11504
|
const file = files[0];
|
|
11475
|
-
console.log(
|
|
11505
|
+
console.log(chalk117.bold.underline("SLOC"));
|
|
11476
11506
|
await sloc(file);
|
|
11477
11507
|
console.log();
|
|
11478
|
-
console.log(
|
|
11508
|
+
console.log(chalk117.bold.underline("Cyclomatic Complexity"));
|
|
11479
11509
|
await cyclomatic(file);
|
|
11480
11510
|
console.log();
|
|
11481
|
-
console.log(
|
|
11511
|
+
console.log(chalk117.bold.underline("Halstead Metrics"));
|
|
11482
11512
|
await halstead(file);
|
|
11483
11513
|
console.log();
|
|
11484
|
-
console.log(
|
|
11514
|
+
console.log(chalk117.bold.underline("Maintainability Index"));
|
|
11485
11515
|
await maintainability(file);
|
|
11486
11516
|
console.log();
|
|
11487
11517
|
console.log(
|
|
11488
|
-
|
|
11518
|
+
chalk117.dim(
|
|
11489
11519
|
"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."
|
|
11490
11520
|
)
|
|
11491
11521
|
);
|
|
@@ -11519,7 +11549,7 @@ function registerComplexity(program2) {
|
|
|
11519
11549
|
}
|
|
11520
11550
|
|
|
11521
11551
|
// src/commands/config/index.ts
|
|
11522
|
-
import
|
|
11552
|
+
import chalk118 from "chalk";
|
|
11523
11553
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
11524
11554
|
|
|
11525
11555
|
// src/commands/config/setNestedValue.ts
|
|
@@ -11582,7 +11612,7 @@ function formatIssuePath(issue, key) {
|
|
|
11582
11612
|
function printValidationErrors(issues, key) {
|
|
11583
11613
|
for (const issue of issues) {
|
|
11584
11614
|
console.error(
|
|
11585
|
-
|
|
11615
|
+
chalk118.red(`${formatIssuePath(issue, key)}: ${issue.message}`)
|
|
11586
11616
|
);
|
|
11587
11617
|
}
|
|
11588
11618
|
}
|
|
@@ -11599,7 +11629,7 @@ var GLOBAL_ONLY_KEYS = ["sync.autoConfirm"];
|
|
|
11599
11629
|
function assertNotGlobalOnly(key, global) {
|
|
11600
11630
|
if (!global && GLOBAL_ONLY_KEYS.some((k) => key.startsWith(k))) {
|
|
11601
11631
|
console.error(
|
|
11602
|
-
|
|
11632
|
+
chalk118.red(
|
|
11603
11633
|
`"${key}" is a global-only key. Use --global to set it in ~/.assist.yml`
|
|
11604
11634
|
)
|
|
11605
11635
|
);
|
|
@@ -11622,7 +11652,7 @@ function configSet(key, value, options2 = {}) {
|
|
|
11622
11652
|
applyConfigSet(key, coerced, options2.global ?? false);
|
|
11623
11653
|
const target = options2.global ? "global" : "project";
|
|
11624
11654
|
console.log(
|
|
11625
|
-
|
|
11655
|
+
chalk118.green(`Set ${key} = ${JSON.stringify(coerced)} (${target})`)
|
|
11626
11656
|
);
|
|
11627
11657
|
}
|
|
11628
11658
|
function configList() {
|
|
@@ -11631,7 +11661,7 @@ function configList() {
|
|
|
11631
11661
|
}
|
|
11632
11662
|
|
|
11633
11663
|
// src/commands/config/configGet.ts
|
|
11634
|
-
import
|
|
11664
|
+
import chalk119 from "chalk";
|
|
11635
11665
|
|
|
11636
11666
|
// src/commands/config/getNestedValue.ts
|
|
11637
11667
|
function isTraversable(value) {
|
|
@@ -11663,7 +11693,7 @@ function requireNestedValue(config, key) {
|
|
|
11663
11693
|
return value;
|
|
11664
11694
|
}
|
|
11665
11695
|
function exitKeyNotSet(key) {
|
|
11666
|
-
console.error(
|
|
11696
|
+
console.error(chalk119.red(`Key "${key}" is not set`));
|
|
11667
11697
|
process.exit(1);
|
|
11668
11698
|
}
|
|
11669
11699
|
|
|
@@ -11677,7 +11707,7 @@ function registerConfig(program2) {
|
|
|
11677
11707
|
|
|
11678
11708
|
// src/commands/deploy/redirect.ts
|
|
11679
11709
|
import { existsSync as existsSync31, readFileSync as readFileSync26, writeFileSync as writeFileSync25 } from "fs";
|
|
11680
|
-
import
|
|
11710
|
+
import chalk120 from "chalk";
|
|
11681
11711
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
11682
11712
|
if (!window.location.pathname.endsWith('/')) {
|
|
11683
11713
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -11686,23 +11716,23 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
11686
11716
|
function redirect() {
|
|
11687
11717
|
const indexPath = "index.html";
|
|
11688
11718
|
if (!existsSync31(indexPath)) {
|
|
11689
|
-
console.log(
|
|
11719
|
+
console.log(chalk120.yellow("No index.html found"));
|
|
11690
11720
|
return;
|
|
11691
11721
|
}
|
|
11692
11722
|
const content = readFileSync26(indexPath, "utf8");
|
|
11693
11723
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
11694
|
-
console.log(
|
|
11724
|
+
console.log(chalk120.dim("Trailing slash script already present"));
|
|
11695
11725
|
return;
|
|
11696
11726
|
}
|
|
11697
11727
|
const headCloseIndex = content.indexOf("</head>");
|
|
11698
11728
|
if (headCloseIndex === -1) {
|
|
11699
|
-
console.log(
|
|
11729
|
+
console.log(chalk120.red("Could not find </head> tag in index.html"));
|
|
11700
11730
|
return;
|
|
11701
11731
|
}
|
|
11702
11732
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
11703
11733
|
${content.slice(headCloseIndex)}`;
|
|
11704
11734
|
writeFileSync25(indexPath, newContent);
|
|
11705
|
-
console.log(
|
|
11735
|
+
console.log(chalk120.green("Added trailing slash redirect to index.html"));
|
|
11706
11736
|
}
|
|
11707
11737
|
|
|
11708
11738
|
// src/commands/registerDeploy.ts
|
|
@@ -11729,7 +11759,7 @@ function loadBlogSkipDays(repoName) {
|
|
|
11729
11759
|
|
|
11730
11760
|
// src/commands/devlog/shared.ts
|
|
11731
11761
|
import { execSync as execSync27 } from "child_process";
|
|
11732
|
-
import
|
|
11762
|
+
import chalk121 from "chalk";
|
|
11733
11763
|
|
|
11734
11764
|
// src/shared/getRepoName.ts
|
|
11735
11765
|
import { existsSync as existsSync32, readFileSync as readFileSync27 } from "fs";
|
|
@@ -11838,13 +11868,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
11838
11868
|
}
|
|
11839
11869
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
11840
11870
|
for (const commit2 of commits2) {
|
|
11841
|
-
console.log(` ${
|
|
11871
|
+
console.log(` ${chalk121.yellow(commit2.hash)} ${commit2.message}`);
|
|
11842
11872
|
if (verbose) {
|
|
11843
11873
|
const visibleFiles = commit2.files.filter(
|
|
11844
11874
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
11845
11875
|
);
|
|
11846
11876
|
for (const file of visibleFiles) {
|
|
11847
|
-
console.log(` ${
|
|
11877
|
+
console.log(` ${chalk121.dim(file)}`);
|
|
11848
11878
|
}
|
|
11849
11879
|
}
|
|
11850
11880
|
}
|
|
@@ -11869,15 +11899,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
11869
11899
|
}
|
|
11870
11900
|
|
|
11871
11901
|
// src/commands/devlog/list/printDateHeader.ts
|
|
11872
|
-
import
|
|
11902
|
+
import chalk122 from "chalk";
|
|
11873
11903
|
function printDateHeader(date, isSkipped, entries) {
|
|
11874
11904
|
if (isSkipped) {
|
|
11875
|
-
console.log(`${
|
|
11905
|
+
console.log(`${chalk122.bold.blue(date)} ${chalk122.dim("skipped")}`);
|
|
11876
11906
|
} else if (entries && entries.length > 0) {
|
|
11877
|
-
const entryInfo = entries.map((e) => `${
|
|
11878
|
-
console.log(`${
|
|
11907
|
+
const entryInfo = entries.map((e) => `${chalk122.green(e.version)} ${e.title}`).join(" | ");
|
|
11908
|
+
console.log(`${chalk122.bold.blue(date)} ${entryInfo}`);
|
|
11879
11909
|
} else {
|
|
11880
|
-
console.log(`${
|
|
11910
|
+
console.log(`${chalk122.bold.blue(date)} ${chalk122.red("\u26A0 devlog missing")}`);
|
|
11881
11911
|
}
|
|
11882
11912
|
}
|
|
11883
11913
|
|
|
@@ -11981,24 +12011,24 @@ function bumpVersion(version2, type) {
|
|
|
11981
12011
|
|
|
11982
12012
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
11983
12013
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
11984
|
-
import
|
|
12014
|
+
import chalk124 from "chalk";
|
|
11985
12015
|
|
|
11986
12016
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
11987
|
-
import
|
|
12017
|
+
import chalk123 from "chalk";
|
|
11988
12018
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
11989
12019
|
if (conventional && firstHash) {
|
|
11990
12020
|
const version2 = getVersionAtCommit(firstHash);
|
|
11991
12021
|
if (version2) {
|
|
11992
|
-
console.log(`${
|
|
12022
|
+
console.log(`${chalk123.bold("version:")} ${stripToMinor(version2)}`);
|
|
11993
12023
|
} else {
|
|
11994
|
-
console.log(`${
|
|
12024
|
+
console.log(`${chalk123.bold("version:")} ${chalk123.red("unknown")}`);
|
|
11995
12025
|
}
|
|
11996
12026
|
} else if (patchVersion && minorVersion) {
|
|
11997
12027
|
console.log(
|
|
11998
|
-
`${
|
|
12028
|
+
`${chalk123.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
11999
12029
|
);
|
|
12000
12030
|
} else {
|
|
12001
|
-
console.log(`${
|
|
12031
|
+
console.log(`${chalk123.bold("version:")} v0.1 (initial)`);
|
|
12002
12032
|
}
|
|
12003
12033
|
}
|
|
12004
12034
|
|
|
@@ -12046,16 +12076,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
12046
12076
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
12047
12077
|
}
|
|
12048
12078
|
function logName(repoName) {
|
|
12049
|
-
console.log(`${
|
|
12079
|
+
console.log(`${chalk124.bold("name:")} ${repoName}`);
|
|
12050
12080
|
}
|
|
12051
12081
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
12052
12082
|
logName(ctx.repoName);
|
|
12053
12083
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
12054
|
-
console.log(
|
|
12084
|
+
console.log(chalk124.bold.blue(targetDate));
|
|
12055
12085
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
12056
12086
|
}
|
|
12057
12087
|
function logNoCommits(lastInfo) {
|
|
12058
|
-
console.log(
|
|
12088
|
+
console.log(chalk124.dim(noCommitsMessage(!!lastInfo)));
|
|
12059
12089
|
}
|
|
12060
12090
|
|
|
12061
12091
|
// src/commands/devlog/next/index.ts
|
|
@@ -12096,11 +12126,11 @@ function next2(options2) {
|
|
|
12096
12126
|
import { execSync as execSync29 } from "child_process";
|
|
12097
12127
|
|
|
12098
12128
|
// src/commands/devlog/repos/printReposTable.ts
|
|
12099
|
-
import
|
|
12129
|
+
import chalk125 from "chalk";
|
|
12100
12130
|
function colorStatus(status2) {
|
|
12101
|
-
if (status2 === "missing") return
|
|
12102
|
-
if (status2 === "outdated") return
|
|
12103
|
-
return
|
|
12131
|
+
if (status2 === "missing") return chalk125.red(status2);
|
|
12132
|
+
if (status2 === "outdated") return chalk125.yellow(status2);
|
|
12133
|
+
return chalk125.green(status2);
|
|
12104
12134
|
}
|
|
12105
12135
|
function formatRow(row, nameWidth) {
|
|
12106
12136
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -12114,8 +12144,8 @@ function printReposTable(rows) {
|
|
|
12114
12144
|
"Last Devlog".padEnd(11),
|
|
12115
12145
|
"Status"
|
|
12116
12146
|
].join(" ");
|
|
12117
|
-
console.log(
|
|
12118
|
-
console.log(
|
|
12147
|
+
console.log(chalk125.dim(header));
|
|
12148
|
+
console.log(chalk125.dim("-".repeat(header.length)));
|
|
12119
12149
|
for (const row of rows) {
|
|
12120
12150
|
console.log(formatRow(row, nameWidth));
|
|
12121
12151
|
}
|
|
@@ -12173,14 +12203,14 @@ function repos(options2) {
|
|
|
12173
12203
|
// src/commands/devlog/skip.ts
|
|
12174
12204
|
import { writeFileSync as writeFileSync26 } from "fs";
|
|
12175
12205
|
import { join as join33 } from "path";
|
|
12176
|
-
import
|
|
12206
|
+
import chalk126 from "chalk";
|
|
12177
12207
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
12178
12208
|
function getBlogConfigPath() {
|
|
12179
12209
|
return join33(BLOG_REPO_ROOT, "assist.yml");
|
|
12180
12210
|
}
|
|
12181
12211
|
function skip(date) {
|
|
12182
12212
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
12183
|
-
console.log(
|
|
12213
|
+
console.log(chalk126.red("Invalid date format. Use YYYY-MM-DD"));
|
|
12184
12214
|
process.exit(1);
|
|
12185
12215
|
}
|
|
12186
12216
|
const repoName = getRepoName();
|
|
@@ -12191,7 +12221,7 @@ function skip(date) {
|
|
|
12191
12221
|
const skipDays = skip2[repoName] ?? [];
|
|
12192
12222
|
if (skipDays.includes(date)) {
|
|
12193
12223
|
console.log(
|
|
12194
|
-
|
|
12224
|
+
chalk126.yellow(`${date} is already in skip list for ${repoName}`)
|
|
12195
12225
|
);
|
|
12196
12226
|
return;
|
|
12197
12227
|
}
|
|
@@ -12201,20 +12231,20 @@ function skip(date) {
|
|
|
12201
12231
|
devlog.skip = skip2;
|
|
12202
12232
|
config.devlog = devlog;
|
|
12203
12233
|
writeFileSync26(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
12204
|
-
console.log(
|
|
12234
|
+
console.log(chalk126.green(`Added ${date} to skip list for ${repoName}`));
|
|
12205
12235
|
}
|
|
12206
12236
|
|
|
12207
12237
|
// src/commands/devlog/version.ts
|
|
12208
|
-
import
|
|
12238
|
+
import chalk127 from "chalk";
|
|
12209
12239
|
function version() {
|
|
12210
12240
|
const config = loadConfig();
|
|
12211
12241
|
const name = getRepoName();
|
|
12212
12242
|
const lastInfo = getLastVersionInfo(name, config);
|
|
12213
12243
|
const lastVersion = lastInfo?.version ?? null;
|
|
12214
12244
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
12215
|
-
console.log(`${
|
|
12216
|
-
console.log(`${
|
|
12217
|
-
console.log(`${
|
|
12245
|
+
console.log(`${chalk127.bold("name:")} ${name}`);
|
|
12246
|
+
console.log(`${chalk127.bold("last:")} ${lastVersion ?? chalk127.dim("none")}`);
|
|
12247
|
+
console.log(`${chalk127.bold("next:")} ${nextVersion ?? chalk127.dim("none")}`);
|
|
12218
12248
|
}
|
|
12219
12249
|
|
|
12220
12250
|
// src/commands/registerDevlog.ts
|
|
@@ -12238,7 +12268,7 @@ function registerDevlog(program2) {
|
|
|
12238
12268
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
12239
12269
|
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4 } from "fs";
|
|
12240
12270
|
import { join as join34 } from "path";
|
|
12241
|
-
import
|
|
12271
|
+
import chalk128 from "chalk";
|
|
12242
12272
|
|
|
12243
12273
|
// src/shared/findRepoRoot.ts
|
|
12244
12274
|
import { existsSync as existsSync33 } from "fs";
|
|
@@ -12301,14 +12331,14 @@ function checkBuildLocks(startDir) {
|
|
|
12301
12331
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
12302
12332
|
if (locked) {
|
|
12303
12333
|
console.error(
|
|
12304
|
-
|
|
12334
|
+
chalk128.red("Build output locked (is VS debugging?): ") + locked
|
|
12305
12335
|
);
|
|
12306
12336
|
process.exit(1);
|
|
12307
12337
|
}
|
|
12308
12338
|
}
|
|
12309
12339
|
async function checkBuildLocksCommand() {
|
|
12310
12340
|
checkBuildLocks();
|
|
12311
|
-
console.log(
|
|
12341
|
+
console.log(chalk128.green("No build locks detected"));
|
|
12312
12342
|
}
|
|
12313
12343
|
|
|
12314
12344
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -12407,30 +12437,30 @@ function escapeRegex(s) {
|
|
|
12407
12437
|
}
|
|
12408
12438
|
|
|
12409
12439
|
// src/commands/dotnet/printTree.ts
|
|
12410
|
-
import
|
|
12440
|
+
import chalk129 from "chalk";
|
|
12411
12441
|
function printNodes(nodes, prefix2) {
|
|
12412
12442
|
for (let i = 0; i < nodes.length; i++) {
|
|
12413
12443
|
const isLast = i === nodes.length - 1;
|
|
12414
12444
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
12415
12445
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
12416
12446
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
12417
|
-
const label2 = isMissing ?
|
|
12447
|
+
const label2 = isMissing ? chalk129.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
12418
12448
|
console.log(`${prefix2}${connector}${label2}`);
|
|
12419
12449
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
12420
12450
|
}
|
|
12421
12451
|
}
|
|
12422
12452
|
function printTree(tree, totalCount, solutions) {
|
|
12423
|
-
console.log(
|
|
12424
|
-
console.log(
|
|
12453
|
+
console.log(chalk129.bold("\nProject Dependency Tree"));
|
|
12454
|
+
console.log(chalk129.cyan(tree.relativePath));
|
|
12425
12455
|
printNodes(tree.children, "");
|
|
12426
|
-
console.log(
|
|
12456
|
+
console.log(chalk129.dim(`
|
|
12427
12457
|
${totalCount} projects total (including root)`));
|
|
12428
|
-
console.log(
|
|
12458
|
+
console.log(chalk129.bold("\nSolution Membership"));
|
|
12429
12459
|
if (solutions.length === 0) {
|
|
12430
|
-
console.log(
|
|
12460
|
+
console.log(chalk129.yellow(" Not found in any .sln"));
|
|
12431
12461
|
} else {
|
|
12432
12462
|
for (const sln of solutions) {
|
|
12433
|
-
console.log(` ${
|
|
12463
|
+
console.log(` ${chalk129.green(sln)}`);
|
|
12434
12464
|
}
|
|
12435
12465
|
}
|
|
12436
12466
|
console.log();
|
|
@@ -12459,16 +12489,16 @@ function printJson(tree, totalCount, solutions) {
|
|
|
12459
12489
|
// src/commands/dotnet/resolveCsproj.ts
|
|
12460
12490
|
import { existsSync as existsSync34 } from "fs";
|
|
12461
12491
|
import path25 from "path";
|
|
12462
|
-
import
|
|
12492
|
+
import chalk130 from "chalk";
|
|
12463
12493
|
function resolveCsproj(csprojPath) {
|
|
12464
12494
|
const resolved = path25.resolve(csprojPath);
|
|
12465
12495
|
if (!existsSync34(resolved)) {
|
|
12466
|
-
console.error(
|
|
12496
|
+
console.error(chalk130.red(`File not found: ${resolved}`));
|
|
12467
12497
|
process.exit(1);
|
|
12468
12498
|
}
|
|
12469
12499
|
const repoRoot = findRepoRoot(path25.dirname(resolved));
|
|
12470
12500
|
if (!repoRoot) {
|
|
12471
|
-
console.error(
|
|
12501
|
+
console.error(chalk130.red("Could not find git repository root"));
|
|
12472
12502
|
process.exit(1);
|
|
12473
12503
|
}
|
|
12474
12504
|
return { resolved, repoRoot };
|
|
@@ -12518,12 +12548,12 @@ function getChangedCsFiles(scope) {
|
|
|
12518
12548
|
}
|
|
12519
12549
|
|
|
12520
12550
|
// src/commands/dotnet/inSln.ts
|
|
12521
|
-
import
|
|
12551
|
+
import chalk131 from "chalk";
|
|
12522
12552
|
async function inSln(csprojPath) {
|
|
12523
12553
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
12524
12554
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
12525
12555
|
if (solutions.length === 0) {
|
|
12526
|
-
console.log(
|
|
12556
|
+
console.log(chalk131.yellow("Not found in any .sln file"));
|
|
12527
12557
|
process.exit(1);
|
|
12528
12558
|
}
|
|
12529
12559
|
for (const sln of solutions) {
|
|
@@ -12532,7 +12562,7 @@ async function inSln(csprojPath) {
|
|
|
12532
12562
|
}
|
|
12533
12563
|
|
|
12534
12564
|
// src/commands/dotnet/inspect.ts
|
|
12535
|
-
import
|
|
12565
|
+
import chalk137 from "chalk";
|
|
12536
12566
|
|
|
12537
12567
|
// src/shared/formatElapsed.ts
|
|
12538
12568
|
function formatElapsed(ms) {
|
|
@@ -12544,12 +12574,12 @@ function formatElapsed(ms) {
|
|
|
12544
12574
|
}
|
|
12545
12575
|
|
|
12546
12576
|
// src/commands/dotnet/displayIssues.ts
|
|
12547
|
-
import
|
|
12577
|
+
import chalk132 from "chalk";
|
|
12548
12578
|
var SEVERITY_COLOR = {
|
|
12549
|
-
ERROR:
|
|
12550
|
-
WARNING:
|
|
12551
|
-
SUGGESTION:
|
|
12552
|
-
HINT:
|
|
12579
|
+
ERROR: chalk132.red,
|
|
12580
|
+
WARNING: chalk132.yellow,
|
|
12581
|
+
SUGGESTION: chalk132.cyan,
|
|
12582
|
+
HINT: chalk132.dim
|
|
12553
12583
|
};
|
|
12554
12584
|
function groupByFile(issues) {
|
|
12555
12585
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -12565,15 +12595,15 @@ function groupByFile(issues) {
|
|
|
12565
12595
|
}
|
|
12566
12596
|
function displayIssues(issues) {
|
|
12567
12597
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
12568
|
-
console.log(
|
|
12598
|
+
console.log(chalk132.bold(file));
|
|
12569
12599
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
12570
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
12600
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk132.white;
|
|
12571
12601
|
console.log(
|
|
12572
|
-
` ${
|
|
12602
|
+
` ${chalk132.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
12573
12603
|
);
|
|
12574
12604
|
}
|
|
12575
12605
|
}
|
|
12576
|
-
console.log(
|
|
12606
|
+
console.log(chalk132.dim(`
|
|
12577
12607
|
${issues.length} issue(s) found`));
|
|
12578
12608
|
}
|
|
12579
12609
|
|
|
@@ -12632,12 +12662,12 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
12632
12662
|
// src/commands/dotnet/resolveSolution.ts
|
|
12633
12663
|
import { existsSync as existsSync35 } from "fs";
|
|
12634
12664
|
import path26 from "path";
|
|
12635
|
-
import
|
|
12665
|
+
import chalk134 from "chalk";
|
|
12636
12666
|
|
|
12637
12667
|
// src/commands/dotnet/findSolution.ts
|
|
12638
12668
|
import { readdirSync as readdirSync6 } from "fs";
|
|
12639
12669
|
import { dirname as dirname20, join as join35 } from "path";
|
|
12640
|
-
import
|
|
12670
|
+
import chalk133 from "chalk";
|
|
12641
12671
|
function findSlnInDir(dir) {
|
|
12642
12672
|
try {
|
|
12643
12673
|
return readdirSync6(dir).filter((f) => f.endsWith(".sln")).map((f) => join35(dir, f));
|
|
@@ -12653,17 +12683,17 @@ function findSolution() {
|
|
|
12653
12683
|
const slnFiles = findSlnInDir(current);
|
|
12654
12684
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
12655
12685
|
if (slnFiles.length > 1) {
|
|
12656
|
-
console.error(
|
|
12686
|
+
console.error(chalk133.red(`Multiple .sln files found in ${current}:`));
|
|
12657
12687
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
12658
12688
|
console.error(
|
|
12659
|
-
|
|
12689
|
+
chalk133.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
12660
12690
|
);
|
|
12661
12691
|
process.exit(1);
|
|
12662
12692
|
}
|
|
12663
12693
|
if (current === ceiling) break;
|
|
12664
12694
|
current = dirname20(current);
|
|
12665
12695
|
}
|
|
12666
|
-
console.error(
|
|
12696
|
+
console.error(chalk133.red("No .sln file found between cwd and repo root"));
|
|
12667
12697
|
process.exit(1);
|
|
12668
12698
|
}
|
|
12669
12699
|
|
|
@@ -12672,7 +12702,7 @@ function resolveSolution(sln) {
|
|
|
12672
12702
|
if (sln) {
|
|
12673
12703
|
const resolved = path26.resolve(sln);
|
|
12674
12704
|
if (!existsSync35(resolved)) {
|
|
12675
|
-
console.error(
|
|
12705
|
+
console.error(chalk134.red(`Solution file not found: ${resolved}`));
|
|
12676
12706
|
process.exit(1);
|
|
12677
12707
|
}
|
|
12678
12708
|
return resolved;
|
|
@@ -12714,14 +12744,14 @@ import { execSync as execSync31 } from "child_process";
|
|
|
12714
12744
|
import { existsSync as existsSync36, readFileSync as readFileSync31, unlinkSync as unlinkSync9 } from "fs";
|
|
12715
12745
|
import { tmpdir as tmpdir3 } from "os";
|
|
12716
12746
|
import path27 from "path";
|
|
12717
|
-
import
|
|
12747
|
+
import chalk135 from "chalk";
|
|
12718
12748
|
function assertJbInstalled() {
|
|
12719
12749
|
try {
|
|
12720
12750
|
execSync31("jb inspectcode --version", { stdio: "pipe" });
|
|
12721
12751
|
} catch {
|
|
12722
|
-
console.error(
|
|
12752
|
+
console.error(chalk135.red("jb is not installed. Install with:"));
|
|
12723
12753
|
console.error(
|
|
12724
|
-
|
|
12754
|
+
chalk135.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
12725
12755
|
);
|
|
12726
12756
|
process.exit(1);
|
|
12727
12757
|
}
|
|
@@ -12739,11 +12769,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
12739
12769
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
12740
12770
|
process.stderr.write(error.stderr);
|
|
12741
12771
|
}
|
|
12742
|
-
console.error(
|
|
12772
|
+
console.error(chalk135.red("jb inspectcode failed"));
|
|
12743
12773
|
process.exit(1);
|
|
12744
12774
|
}
|
|
12745
12775
|
if (!existsSync36(reportPath)) {
|
|
12746
|
-
console.error(
|
|
12776
|
+
console.error(chalk135.red("Report file not generated"));
|
|
12747
12777
|
process.exit(1);
|
|
12748
12778
|
}
|
|
12749
12779
|
const xml = readFileSync31(reportPath, "utf8");
|
|
@@ -12753,7 +12783,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
12753
12783
|
|
|
12754
12784
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
12755
12785
|
import { execSync as execSync32 } from "child_process";
|
|
12756
|
-
import
|
|
12786
|
+
import chalk136 from "chalk";
|
|
12757
12787
|
function resolveMsbuildPath() {
|
|
12758
12788
|
const { run: run4 } = loadConfig();
|
|
12759
12789
|
const configs = resolveRunConfigs(run4, getConfigDir());
|
|
@@ -12765,9 +12795,9 @@ function assertMsbuildInstalled() {
|
|
|
12765
12795
|
try {
|
|
12766
12796
|
execSync32(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
12767
12797
|
} catch {
|
|
12768
|
-
console.error(
|
|
12798
|
+
console.error(chalk136.red(`msbuild not found at: ${msbuild}`));
|
|
12769
12799
|
console.error(
|
|
12770
|
-
|
|
12800
|
+
chalk136.yellow(
|
|
12771
12801
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
12772
12802
|
)
|
|
12773
12803
|
);
|
|
@@ -12814,17 +12844,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
12814
12844
|
// src/commands/dotnet/inspect.ts
|
|
12815
12845
|
function logScope(changedFiles) {
|
|
12816
12846
|
if (changedFiles === null) {
|
|
12817
|
-
console.log(
|
|
12847
|
+
console.log(chalk137.dim("Inspecting full solution..."));
|
|
12818
12848
|
} else {
|
|
12819
12849
|
console.log(
|
|
12820
|
-
|
|
12850
|
+
chalk137.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
12821
12851
|
);
|
|
12822
12852
|
}
|
|
12823
12853
|
}
|
|
12824
12854
|
function reportResults(issues, elapsed) {
|
|
12825
12855
|
if (issues.length > 0) displayIssues(issues);
|
|
12826
|
-
else console.log(
|
|
12827
|
-
console.log(
|
|
12856
|
+
else console.log(chalk137.green("No issues found"));
|
|
12857
|
+
console.log(chalk137.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
12828
12858
|
if (issues.length > 0) process.exit(1);
|
|
12829
12859
|
}
|
|
12830
12860
|
async function inspect(sln, options2) {
|
|
@@ -12835,7 +12865,7 @@ async function inspect(sln, options2) {
|
|
|
12835
12865
|
const scope = parseScope(options2.scope);
|
|
12836
12866
|
const changedFiles = getChangedCsFiles(scope);
|
|
12837
12867
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
12838
|
-
console.log(
|
|
12868
|
+
console.log(chalk137.green("No changed .cs files found"));
|
|
12839
12869
|
return;
|
|
12840
12870
|
}
|
|
12841
12871
|
logScope(changedFiles);
|
|
@@ -13160,25 +13190,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
13160
13190
|
}
|
|
13161
13191
|
|
|
13162
13192
|
// src/commands/github/printCountTable.ts
|
|
13163
|
-
import
|
|
13193
|
+
import chalk138 from "chalk";
|
|
13164
13194
|
function printCountTable(labelHeader, rows) {
|
|
13165
13195
|
const labelWidth = Math.max(
|
|
13166
13196
|
labelHeader.length,
|
|
13167
13197
|
...rows.map((row) => row.label.length)
|
|
13168
13198
|
);
|
|
13169
13199
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
13170
|
-
console.log(
|
|
13171
|
-
console.log(
|
|
13200
|
+
console.log(chalk138.dim(header));
|
|
13201
|
+
console.log(chalk138.dim("-".repeat(header.length)));
|
|
13172
13202
|
for (const row of rows) {
|
|
13173
13203
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
13174
13204
|
}
|
|
13175
13205
|
}
|
|
13176
13206
|
|
|
13177
13207
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
13178
|
-
import
|
|
13208
|
+
import chalk139 from "chalk";
|
|
13179
13209
|
function printRepoAuthorBreakdown(repos2) {
|
|
13180
13210
|
for (const repo of repos2) {
|
|
13181
|
-
console.log(
|
|
13211
|
+
console.log(chalk139.bold(repo.name));
|
|
13182
13212
|
const authorWidth = Math.max(
|
|
13183
13213
|
0,
|
|
13184
13214
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -13275,9 +13305,9 @@ function registerGithub(program2) {
|
|
|
13275
13305
|
}
|
|
13276
13306
|
|
|
13277
13307
|
// src/commands/handover/countPendingHandovers.ts
|
|
13278
|
-
import { and as and16, eq as
|
|
13308
|
+
import { and as and16, eq as eq34, isNull, sql as sql7 } from "drizzle-orm";
|
|
13279
13309
|
async function countPendingHandovers(orm, origin) {
|
|
13280
|
-
const [row] = await orm.select({ count: sql7`count(*)::int` }).from(handovers).where(and16(
|
|
13310
|
+
const [row] = await orm.select({ count: sql7`count(*)::int` }).from(handovers).where(and16(eq34(handovers.origin, origin), isNull(handovers.recalledAt)));
|
|
13281
13311
|
return row?.count ?? 0;
|
|
13282
13312
|
}
|
|
13283
13313
|
|
|
@@ -13417,13 +13447,13 @@ async function load2(options2 = {}) {
|
|
|
13417
13447
|
}
|
|
13418
13448
|
|
|
13419
13449
|
// src/commands/handover/listPendingHandovers.ts
|
|
13420
|
-
import { and as and17, desc as desc4, eq as
|
|
13450
|
+
import { and as and17, desc as desc4, eq as eq35, isNull as isNull2 } from "drizzle-orm";
|
|
13421
13451
|
async function listPendingHandovers(orm, origin) {
|
|
13422
13452
|
return orm.select({
|
|
13423
13453
|
id: handovers.id,
|
|
13424
13454
|
summary: handovers.summary,
|
|
13425
13455
|
createdAt: handovers.createdAt
|
|
13426
|
-
}).from(handovers).where(and17(
|
|
13456
|
+
}).from(handovers).where(and17(eq35(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
|
|
13427
13457
|
}
|
|
13428
13458
|
|
|
13429
13459
|
// src/commands/handover/printPendingHandovers.ts
|
|
@@ -13436,17 +13466,17 @@ async function printPendingHandovers() {
|
|
|
13436
13466
|
}
|
|
13437
13467
|
|
|
13438
13468
|
// src/commands/handover/recallHandover.ts
|
|
13439
|
-
import { and as and18, desc as desc5, eq as
|
|
13469
|
+
import { and as and18, desc as desc5, eq as eq36, isNull as isNull3 } from "drizzle-orm";
|
|
13440
13470
|
async function recallHandover(orm, origin, id2) {
|
|
13441
13471
|
const [row] = await orm.select().from(handovers).where(
|
|
13442
13472
|
and18(
|
|
13443
|
-
|
|
13473
|
+
eq36(handovers.origin, origin),
|
|
13444
13474
|
isNull3(handovers.recalledAt),
|
|
13445
|
-
...id2 === void 0 ? [] : [
|
|
13475
|
+
...id2 === void 0 ? [] : [eq36(handovers.id, id2)]
|
|
13446
13476
|
)
|
|
13447
13477
|
).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
|
|
13448
13478
|
if (!row) return void 0;
|
|
13449
|
-
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(
|
|
13479
|
+
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq36(handovers.id, row.id));
|
|
13450
13480
|
return row.content;
|
|
13451
13481
|
}
|
|
13452
13482
|
|
|
@@ -13496,7 +13526,7 @@ function registerHandover(program2) {
|
|
|
13496
13526
|
}
|
|
13497
13527
|
|
|
13498
13528
|
// src/commands/jira/acceptanceCriteria.ts
|
|
13499
|
-
import
|
|
13529
|
+
import chalk140 from "chalk";
|
|
13500
13530
|
|
|
13501
13531
|
// src/commands/jira/adfToText.ts
|
|
13502
13532
|
function renderInline(node) {
|
|
@@ -13563,7 +13593,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
13563
13593
|
const parsed = fetchIssue(issueKey, field);
|
|
13564
13594
|
const acValue = parsed?.fields?.[field];
|
|
13565
13595
|
if (!acValue) {
|
|
13566
|
-
console.log(
|
|
13596
|
+
console.log(chalk140.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
13567
13597
|
return;
|
|
13568
13598
|
}
|
|
13569
13599
|
if (typeof acValue === "string") {
|
|
@@ -13629,14 +13659,14 @@ async function jiraAuth() {
|
|
|
13629
13659
|
}
|
|
13630
13660
|
|
|
13631
13661
|
// src/commands/jira/viewIssue.ts
|
|
13632
|
-
import
|
|
13662
|
+
import chalk141 from "chalk";
|
|
13633
13663
|
function viewIssue(issueKey) {
|
|
13634
13664
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
13635
13665
|
const fields = parsed?.fields;
|
|
13636
13666
|
const summary = fields?.summary;
|
|
13637
13667
|
const description = fields?.description;
|
|
13638
13668
|
if (summary) {
|
|
13639
|
-
console.log(
|
|
13669
|
+
console.log(chalk141.bold(summary));
|
|
13640
13670
|
}
|
|
13641
13671
|
if (description) {
|
|
13642
13672
|
if (summary) console.log();
|
|
@@ -13650,7 +13680,7 @@ function viewIssue(issueKey) {
|
|
|
13650
13680
|
}
|
|
13651
13681
|
if (!summary && !description) {
|
|
13652
13682
|
console.log(
|
|
13653
|
-
|
|
13683
|
+
chalk141.yellow(`No summary or description found on ${issueKey}.`)
|
|
13654
13684
|
);
|
|
13655
13685
|
}
|
|
13656
13686
|
}
|
|
@@ -13666,13 +13696,13 @@ function registerJira(program2) {
|
|
|
13666
13696
|
// src/commands/reviewComments.ts
|
|
13667
13697
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
13668
13698
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
13669
|
-
import
|
|
13699
|
+
import chalk142 from "chalk";
|
|
13670
13700
|
async function reviewComments(number) {
|
|
13671
13701
|
if (number) {
|
|
13672
13702
|
try {
|
|
13673
13703
|
execFileSync5("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
13674
13704
|
} catch {
|
|
13675
|
-
console.error(
|
|
13705
|
+
console.error(chalk142.red(`gh pr checkout ${number} failed; aborting.`));
|
|
13676
13706
|
process.exit(1);
|
|
13677
13707
|
}
|
|
13678
13708
|
}
|
|
@@ -13746,15 +13776,15 @@ function registerList(program2) {
|
|
|
13746
13776
|
// src/commands/mermaid/index.ts
|
|
13747
13777
|
import { mkdirSync as mkdirSync14, readdirSync as readdirSync8 } from "fs";
|
|
13748
13778
|
import { resolve as resolve11 } from "path";
|
|
13749
|
-
import
|
|
13779
|
+
import chalk145 from "chalk";
|
|
13750
13780
|
|
|
13751
13781
|
// src/commands/mermaid/exportFile.ts
|
|
13752
13782
|
import { readFileSync as readFileSync33, writeFileSync as writeFileSync28 } from "fs";
|
|
13753
13783
|
import { basename as basename8, extname, resolve as resolve10 } from "path";
|
|
13754
|
-
import
|
|
13784
|
+
import chalk144 from "chalk";
|
|
13755
13785
|
|
|
13756
13786
|
// src/commands/mermaid/renderBlock.ts
|
|
13757
|
-
import
|
|
13787
|
+
import chalk143 from "chalk";
|
|
13758
13788
|
async function renderBlock(krokiUrl, source) {
|
|
13759
13789
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
13760
13790
|
method: "POST",
|
|
@@ -13763,7 +13793,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
13763
13793
|
});
|
|
13764
13794
|
if (!response.ok) {
|
|
13765
13795
|
console.error(
|
|
13766
|
-
|
|
13796
|
+
chalk143.red(
|
|
13767
13797
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
13768
13798
|
)
|
|
13769
13799
|
);
|
|
@@ -13781,19 +13811,19 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
13781
13811
|
if (onlyIndex !== void 0) {
|
|
13782
13812
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
13783
13813
|
console.error(
|
|
13784
|
-
|
|
13814
|
+
chalk144.red(
|
|
13785
13815
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
13786
13816
|
)
|
|
13787
13817
|
);
|
|
13788
13818
|
process.exit(1);
|
|
13789
13819
|
}
|
|
13790
13820
|
console.log(
|
|
13791
|
-
|
|
13821
|
+
chalk144.gray(
|
|
13792
13822
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
13793
13823
|
)
|
|
13794
13824
|
);
|
|
13795
13825
|
} else {
|
|
13796
|
-
console.log(
|
|
13826
|
+
console.log(chalk144.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
13797
13827
|
}
|
|
13798
13828
|
for (const [i, source] of blocks.entries()) {
|
|
13799
13829
|
const idx = i + 1;
|
|
@@ -13801,7 +13831,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
13801
13831
|
const outPath = resolve10(outDir, `${stem}-${idx}.svg`);
|
|
13802
13832
|
const svg = await renderBlock(krokiUrl, source);
|
|
13803
13833
|
writeFileSync28(outPath, svg, "utf8");
|
|
13804
|
-
console.log(
|
|
13834
|
+
console.log(chalk144.green(` \u2192 ${outPath}`));
|
|
13805
13835
|
}
|
|
13806
13836
|
}
|
|
13807
13837
|
function extractMermaidBlocks(markdown) {
|
|
@@ -13817,18 +13847,18 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
13817
13847
|
if (options2.index !== void 0) {
|
|
13818
13848
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
13819
13849
|
console.error(
|
|
13820
|
-
|
|
13850
|
+
chalk145.red(`--index must be a positive integer (got ${options2.index})`)
|
|
13821
13851
|
);
|
|
13822
13852
|
process.exit(1);
|
|
13823
13853
|
}
|
|
13824
13854
|
if (!file) {
|
|
13825
|
-
console.error(
|
|
13855
|
+
console.error(chalk145.red("--index requires a file argument"));
|
|
13826
13856
|
process.exit(1);
|
|
13827
13857
|
}
|
|
13828
13858
|
}
|
|
13829
13859
|
const files = file ? [file] : readdirSync8(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
13830
13860
|
if (files.length === 0) {
|
|
13831
|
-
console.log(
|
|
13861
|
+
console.log(chalk145.gray("No markdown files found in current directory."));
|
|
13832
13862
|
return;
|
|
13833
13863
|
}
|
|
13834
13864
|
for (const f of files) {
|
|
@@ -13854,7 +13884,7 @@ function registerMermaid(program2) {
|
|
|
13854
13884
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
13855
13885
|
import { createServer as createServer2 } from "http";
|
|
13856
13886
|
import { dirname as dirname22 } from "path";
|
|
13857
|
-
import
|
|
13887
|
+
import chalk147 from "chalk";
|
|
13858
13888
|
|
|
13859
13889
|
// src/commands/netcap/corsHeaders.ts
|
|
13860
13890
|
var corsHeaders = {
|
|
@@ -13933,7 +13963,7 @@ function createNetcapHandler(options2) {
|
|
|
13933
13963
|
import { cp, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
13934
13964
|
import { networkInterfaces } from "os";
|
|
13935
13965
|
import { join as join41 } from "path";
|
|
13936
|
-
import
|
|
13966
|
+
import chalk146 from "chalk";
|
|
13937
13967
|
|
|
13938
13968
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
13939
13969
|
import { dirname as dirname21, join as join40 } from "path";
|
|
@@ -13977,7 +14007,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
13977
14007
|
const host = lanIPv4();
|
|
13978
14008
|
if (!host) {
|
|
13979
14009
|
console.log(
|
|
13980
|
-
|
|
14010
|
+
chalk146.yellow("could not determine the WSL IP for the extension")
|
|
13981
14011
|
);
|
|
13982
14012
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
13983
14013
|
return source;
|
|
@@ -13988,7 +14018,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
13988
14018
|
return WSL_WINDOWS_PATH;
|
|
13989
14019
|
} catch {
|
|
13990
14020
|
console.log(
|
|
13991
|
-
|
|
14021
|
+
chalk146.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
13992
14022
|
);
|
|
13993
14023
|
return source;
|
|
13994
14024
|
}
|
|
@@ -14021,30 +14051,30 @@ async function netcap(options2) {
|
|
|
14021
14051
|
let count8 = 0;
|
|
14022
14052
|
const handler = createNetcapHandler({
|
|
14023
14053
|
outPath,
|
|
14024
|
-
onPing: () => console.log(
|
|
14054
|
+
onPing: () => console.log(chalk147.dim("ping from extension")),
|
|
14025
14055
|
onCapture: (entry) => {
|
|
14026
14056
|
count8 += 1;
|
|
14027
14057
|
console.log(
|
|
14028
|
-
|
|
14029
|
-
|
|
14058
|
+
chalk147.green(`captured #${count8}`),
|
|
14059
|
+
chalk147.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
14030
14060
|
);
|
|
14031
14061
|
}
|
|
14032
14062
|
});
|
|
14033
14063
|
const server = createServer2(handler);
|
|
14034
14064
|
server.listen(port, () => {
|
|
14035
14065
|
console.log(
|
|
14036
|
-
|
|
14066
|
+
chalk147.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
14037
14067
|
);
|
|
14038
|
-
console.log(
|
|
14068
|
+
console.log(chalk147.dim(`appending captures to ${outPath}`));
|
|
14039
14069
|
if (filter)
|
|
14040
|
-
console.log(
|
|
14041
|
-
console.log(
|
|
14042
|
-
console.log(
|
|
14070
|
+
console.log(chalk147.dim(`forwarding only URLs matching "${filter}"`));
|
|
14071
|
+
console.log(chalk147.dim(`load the unpacked extension from ${extensionPath}`));
|
|
14072
|
+
console.log(chalk147.dim("press Ctrl-C to stop"));
|
|
14043
14073
|
});
|
|
14044
14074
|
process.on("SIGINT", () => {
|
|
14045
14075
|
server.close();
|
|
14046
14076
|
console.log(
|
|
14047
|
-
|
|
14077
|
+
chalk147.bold(
|
|
14048
14078
|
`
|
|
14049
14079
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
14050
14080
|
)
|
|
@@ -14056,7 +14086,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
14056
14086
|
// src/commands/netcap/netcapExtract.ts
|
|
14057
14087
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
14058
14088
|
import { join as join44 } from "path";
|
|
14059
|
-
import
|
|
14089
|
+
import chalk148 from "chalk";
|
|
14060
14090
|
|
|
14061
14091
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
14062
14092
|
import { readFileSync as readFileSync34 } from "fs";
|
|
@@ -14504,8 +14534,8 @@ function netcapExtract(file) {
|
|
|
14504
14534
|
writeFileSync29(outFile, `${JSON.stringify(posts, null, 2)}
|
|
14505
14535
|
`);
|
|
14506
14536
|
console.log(
|
|
14507
|
-
|
|
14508
|
-
|
|
14537
|
+
chalk148.green(`extracted ${posts.length} posts`),
|
|
14538
|
+
chalk148.dim(`-> ${outFile}`)
|
|
14509
14539
|
);
|
|
14510
14540
|
}
|
|
14511
14541
|
|
|
@@ -14526,7 +14556,7 @@ function registerNetcap(program2) {
|
|
|
14526
14556
|
}
|
|
14527
14557
|
|
|
14528
14558
|
// src/commands/news/add/index.ts
|
|
14529
|
-
import
|
|
14559
|
+
import chalk149 from "chalk";
|
|
14530
14560
|
import enquirer8 from "enquirer";
|
|
14531
14561
|
async function add2(url) {
|
|
14532
14562
|
if (!url) {
|
|
@@ -14548,10 +14578,10 @@ async function add2(url) {
|
|
|
14548
14578
|
const { orm } = await getReady();
|
|
14549
14579
|
const added = await addFeed(orm, url);
|
|
14550
14580
|
if (!added) {
|
|
14551
|
-
console.log(
|
|
14581
|
+
console.log(chalk149.yellow("Feed already exists"));
|
|
14552
14582
|
return;
|
|
14553
14583
|
}
|
|
14554
|
-
console.log(
|
|
14584
|
+
console.log(chalk149.green(`Added feed: ${url}`));
|
|
14555
14585
|
}
|
|
14556
14586
|
|
|
14557
14587
|
// src/commands/registerNews.ts
|
|
@@ -14561,7 +14591,7 @@ function registerNews(program2) {
|
|
|
14561
14591
|
}
|
|
14562
14592
|
|
|
14563
14593
|
// src/commands/prompts/printPromptsTable.ts
|
|
14564
|
-
import
|
|
14594
|
+
import chalk150 from "chalk";
|
|
14565
14595
|
function truncate(str, max) {
|
|
14566
14596
|
if (str.length <= max) return str;
|
|
14567
14597
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -14579,14 +14609,14 @@ function printPromptsTable(rows) {
|
|
|
14579
14609
|
"Command".padEnd(commandWidth),
|
|
14580
14610
|
"Repos"
|
|
14581
14611
|
].join(" ");
|
|
14582
|
-
console.log(
|
|
14583
|
-
console.log(
|
|
14612
|
+
console.log(chalk150.dim(header));
|
|
14613
|
+
console.log(chalk150.dim("-".repeat(header.length)));
|
|
14584
14614
|
for (const row of rows) {
|
|
14585
14615
|
const count8 = String(row.count).padStart(countWidth);
|
|
14586
14616
|
const tool = row.tool.padEnd(toolWidth);
|
|
14587
14617
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
14588
14618
|
console.log(
|
|
14589
|
-
`${
|
|
14619
|
+
`${chalk150.yellow(count8)} ${tool} ${command} ${chalk150.dim(row.repos)}`
|
|
14590
14620
|
);
|
|
14591
14621
|
}
|
|
14592
14622
|
}
|
|
@@ -15135,20 +15165,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
15135
15165
|
}
|
|
15136
15166
|
|
|
15137
15167
|
// src/commands/prs/listComments/printComments.ts
|
|
15138
|
-
import
|
|
15168
|
+
import chalk151 from "chalk";
|
|
15139
15169
|
function formatForHuman(comment3) {
|
|
15140
15170
|
if (comment3.type === "review") {
|
|
15141
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
15171
|
+
const stateColor = comment3.state === "APPROVED" ? chalk151.green : comment3.state === "CHANGES_REQUESTED" ? chalk151.red : chalk151.yellow;
|
|
15142
15172
|
return [
|
|
15143
|
-
`${
|
|
15173
|
+
`${chalk151.cyan("Review")} by ${chalk151.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
15144
15174
|
comment3.body,
|
|
15145
15175
|
""
|
|
15146
15176
|
].join("\n");
|
|
15147
15177
|
}
|
|
15148
15178
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
15149
15179
|
return [
|
|
15150
|
-
`${
|
|
15151
|
-
|
|
15180
|
+
`${chalk151.cyan("Line comment")} by ${chalk151.bold(comment3.user)} on ${chalk151.dim(`${comment3.path}${location}`)}`,
|
|
15181
|
+
chalk151.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
15152
15182
|
comment3.body,
|
|
15153
15183
|
""
|
|
15154
15184
|
].join("\n");
|
|
@@ -15238,13 +15268,13 @@ import { execSync as execSync41 } from "child_process";
|
|
|
15238
15268
|
import enquirer9 from "enquirer";
|
|
15239
15269
|
|
|
15240
15270
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
15241
|
-
import
|
|
15271
|
+
import chalk152 from "chalk";
|
|
15242
15272
|
var STATUS_MAP = {
|
|
15243
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
15244
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
15273
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk152.magenta("merged"), date: pr.mergedAt } : null,
|
|
15274
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk152.red("closed"), date: pr.closedAt } : null
|
|
15245
15275
|
};
|
|
15246
15276
|
function defaultStatus(pr) {
|
|
15247
|
-
return { label:
|
|
15277
|
+
return { label: chalk152.green("opened"), date: pr.createdAt };
|
|
15248
15278
|
}
|
|
15249
15279
|
function getStatus2(pr) {
|
|
15250
15280
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -15253,11 +15283,11 @@ function formatDate(dateStr) {
|
|
|
15253
15283
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
15254
15284
|
}
|
|
15255
15285
|
function formatPrHeader(pr, status2) {
|
|
15256
|
-
return `${
|
|
15286
|
+
return `${chalk152.cyan(`#${pr.number}`)} ${pr.title} ${chalk152.dim(`(${pr.author.login},`)} ${status2.label} ${chalk152.dim(`${formatDate(status2.date)})`)}`;
|
|
15257
15287
|
}
|
|
15258
15288
|
function logPrDetails(pr) {
|
|
15259
15289
|
console.log(
|
|
15260
|
-
|
|
15290
|
+
chalk152.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
15261
15291
|
);
|
|
15262
15292
|
console.log();
|
|
15263
15293
|
}
|
|
@@ -15596,10 +15626,10 @@ function registerPrs(program2) {
|
|
|
15596
15626
|
}
|
|
15597
15627
|
|
|
15598
15628
|
// src/commands/ravendb/ravendbAuth.ts
|
|
15599
|
-
import
|
|
15629
|
+
import chalk158 from "chalk";
|
|
15600
15630
|
|
|
15601
15631
|
// src/shared/createConnectionAuth.ts
|
|
15602
|
-
import
|
|
15632
|
+
import chalk153 from "chalk";
|
|
15603
15633
|
function listConnections(connections, format) {
|
|
15604
15634
|
if (connections.length === 0) {
|
|
15605
15635
|
console.log("No connections configured.");
|
|
@@ -15612,7 +15642,7 @@ function listConnections(connections, format) {
|
|
|
15612
15642
|
function removeConnection(connections, name, save) {
|
|
15613
15643
|
const filtered = connections.filter((c) => c.name !== name);
|
|
15614
15644
|
if (filtered.length === connections.length) {
|
|
15615
|
-
console.error(
|
|
15645
|
+
console.error(chalk153.red(`Connection "${name}" not found.`));
|
|
15616
15646
|
process.exit(1);
|
|
15617
15647
|
}
|
|
15618
15648
|
save(filtered);
|
|
@@ -15658,15 +15688,15 @@ function saveConnections(connections) {
|
|
|
15658
15688
|
}
|
|
15659
15689
|
|
|
15660
15690
|
// src/commands/ravendb/promptConnection.ts
|
|
15661
|
-
import
|
|
15691
|
+
import chalk156 from "chalk";
|
|
15662
15692
|
|
|
15663
15693
|
// src/commands/ravendb/selectOpSecret.ts
|
|
15664
|
-
import
|
|
15694
|
+
import chalk155 from "chalk";
|
|
15665
15695
|
import Enquirer2 from "enquirer";
|
|
15666
15696
|
|
|
15667
15697
|
// src/commands/ravendb/searchItems.ts
|
|
15668
15698
|
import { execSync as execSync45 } from "child_process";
|
|
15669
|
-
import
|
|
15699
|
+
import chalk154 from "chalk";
|
|
15670
15700
|
function opExec(args) {
|
|
15671
15701
|
return execSync45(`op ${args}`, {
|
|
15672
15702
|
encoding: "utf8",
|
|
@@ -15679,7 +15709,7 @@ function searchItems(search2) {
|
|
|
15679
15709
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
15680
15710
|
} catch {
|
|
15681
15711
|
console.error(
|
|
15682
|
-
|
|
15712
|
+
chalk154.red(
|
|
15683
15713
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
15684
15714
|
)
|
|
15685
15715
|
);
|
|
@@ -15693,7 +15723,7 @@ function getItemFields(itemId) {
|
|
|
15693
15723
|
const item = JSON.parse(opExec(`item get "${itemId}" --format=json`));
|
|
15694
15724
|
return item.fields.filter((f) => f.reference && f.label);
|
|
15695
15725
|
} catch {
|
|
15696
|
-
console.error(
|
|
15726
|
+
console.error(chalk154.red("Failed to get item details from 1Password."));
|
|
15697
15727
|
process.exit(1);
|
|
15698
15728
|
}
|
|
15699
15729
|
}
|
|
@@ -15712,7 +15742,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15712
15742
|
}).run();
|
|
15713
15743
|
const items2 = searchItems(search2);
|
|
15714
15744
|
if (items2.length === 0) {
|
|
15715
|
-
console.error(
|
|
15745
|
+
console.error(chalk155.red(`No items found matching "${search2}".`));
|
|
15716
15746
|
process.exit(1);
|
|
15717
15747
|
}
|
|
15718
15748
|
const itemId = await selectOne(
|
|
@@ -15721,7 +15751,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15721
15751
|
);
|
|
15722
15752
|
const fields = getItemFields(itemId);
|
|
15723
15753
|
if (fields.length === 0) {
|
|
15724
|
-
console.error(
|
|
15754
|
+
console.error(chalk155.red("No fields with references found on this item."));
|
|
15725
15755
|
process.exit(1);
|
|
15726
15756
|
}
|
|
15727
15757
|
const ref = await selectOne(
|
|
@@ -15735,7 +15765,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15735
15765
|
async function promptConnection(existingNames) {
|
|
15736
15766
|
const name = await promptInput("name", "Connection name:");
|
|
15737
15767
|
if (existingNames.includes(name)) {
|
|
15738
|
-
console.error(
|
|
15768
|
+
console.error(chalk156.red(`Connection "${name}" already exists.`));
|
|
15739
15769
|
process.exit(1);
|
|
15740
15770
|
}
|
|
15741
15771
|
const url = await promptInput(
|
|
@@ -15744,22 +15774,22 @@ async function promptConnection(existingNames) {
|
|
|
15744
15774
|
);
|
|
15745
15775
|
const database = await promptInput("database", "Database name:");
|
|
15746
15776
|
if (!name || !url || !database) {
|
|
15747
|
-
console.error(
|
|
15777
|
+
console.error(chalk156.red("All fields are required."));
|
|
15748
15778
|
process.exit(1);
|
|
15749
15779
|
}
|
|
15750
15780
|
const apiKeyRef = await selectOpSecret();
|
|
15751
|
-
console.log(
|
|
15781
|
+
console.log(chalk156.dim(`Using: ${apiKeyRef}`));
|
|
15752
15782
|
return { name, url, database, apiKeyRef };
|
|
15753
15783
|
}
|
|
15754
15784
|
|
|
15755
15785
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
15756
|
-
import
|
|
15786
|
+
import chalk157 from "chalk";
|
|
15757
15787
|
function ravendbSetConnection(name) {
|
|
15758
15788
|
const raw = loadGlobalConfigRaw();
|
|
15759
15789
|
const ravendb = raw.ravendb ?? {};
|
|
15760
15790
|
const connections = ravendb.connections ?? [];
|
|
15761
15791
|
if (!connections.some((c) => c.name === name)) {
|
|
15762
|
-
console.error(
|
|
15792
|
+
console.error(chalk157.red(`Connection "${name}" not found.`));
|
|
15763
15793
|
console.error(
|
|
15764
15794
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
15765
15795
|
);
|
|
@@ -15775,16 +15805,16 @@ function ravendbSetConnection(name) {
|
|
|
15775
15805
|
var ravendbAuth = createConnectionAuth({
|
|
15776
15806
|
load: loadConnections,
|
|
15777
15807
|
save: saveConnections,
|
|
15778
|
-
format: (c) => `${
|
|
15808
|
+
format: (c) => `${chalk158.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
15779
15809
|
promptNew: promptConnection,
|
|
15780
15810
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
15781
15811
|
});
|
|
15782
15812
|
|
|
15783
15813
|
// src/commands/ravendb/ravendbCollections.ts
|
|
15784
|
-
import
|
|
15814
|
+
import chalk162 from "chalk";
|
|
15785
15815
|
|
|
15786
15816
|
// src/commands/ravendb/ravenFetch.ts
|
|
15787
|
-
import
|
|
15817
|
+
import chalk160 from "chalk";
|
|
15788
15818
|
|
|
15789
15819
|
// src/commands/ravendb/getAccessToken.ts
|
|
15790
15820
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -15821,10 +15851,10 @@ ${errorText}`
|
|
|
15821
15851
|
|
|
15822
15852
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
15823
15853
|
import { execSync as execSync46 } from "child_process";
|
|
15824
|
-
import
|
|
15854
|
+
import chalk159 from "chalk";
|
|
15825
15855
|
function resolveOpSecret(reference) {
|
|
15826
15856
|
if (!reference.startsWith("op://")) {
|
|
15827
|
-
console.error(
|
|
15857
|
+
console.error(chalk159.red(`Invalid secret reference: must start with op://`));
|
|
15828
15858
|
process.exit(1);
|
|
15829
15859
|
}
|
|
15830
15860
|
try {
|
|
@@ -15834,7 +15864,7 @@ function resolveOpSecret(reference) {
|
|
|
15834
15864
|
}).trim();
|
|
15835
15865
|
} catch {
|
|
15836
15866
|
console.error(
|
|
15837
|
-
|
|
15867
|
+
chalk159.red(
|
|
15838
15868
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
15839
15869
|
)
|
|
15840
15870
|
);
|
|
@@ -15861,7 +15891,7 @@ async function ravenFetch(connection, path57) {
|
|
|
15861
15891
|
if (!response.ok) {
|
|
15862
15892
|
const body = await response.text();
|
|
15863
15893
|
console.error(
|
|
15864
|
-
|
|
15894
|
+
chalk160.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
15865
15895
|
);
|
|
15866
15896
|
console.error(body.substring(0, 500));
|
|
15867
15897
|
process.exit(1);
|
|
@@ -15870,7 +15900,7 @@ async function ravenFetch(connection, path57) {
|
|
|
15870
15900
|
}
|
|
15871
15901
|
|
|
15872
15902
|
// src/commands/ravendb/resolveConnection.ts
|
|
15873
|
-
import
|
|
15903
|
+
import chalk161 from "chalk";
|
|
15874
15904
|
function loadRavendb() {
|
|
15875
15905
|
const raw = loadGlobalConfigRaw();
|
|
15876
15906
|
const ravendb = raw.ravendb;
|
|
@@ -15884,7 +15914,7 @@ function resolveConnection(name) {
|
|
|
15884
15914
|
const connectionName = name ?? defaultConnection;
|
|
15885
15915
|
if (!connectionName) {
|
|
15886
15916
|
console.error(
|
|
15887
|
-
|
|
15917
|
+
chalk161.red(
|
|
15888
15918
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
15889
15919
|
)
|
|
15890
15920
|
);
|
|
@@ -15892,7 +15922,7 @@ function resolveConnection(name) {
|
|
|
15892
15922
|
}
|
|
15893
15923
|
const connection = connections.find((c) => c.name === connectionName);
|
|
15894
15924
|
if (!connection) {
|
|
15895
|
-
console.error(
|
|
15925
|
+
console.error(chalk161.red(`Connection "${connectionName}" not found.`));
|
|
15896
15926
|
console.error(
|
|
15897
15927
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
15898
15928
|
);
|
|
@@ -15923,15 +15953,15 @@ async function ravendbCollections(connectionName) {
|
|
|
15923
15953
|
return;
|
|
15924
15954
|
}
|
|
15925
15955
|
for (const c of collections) {
|
|
15926
|
-
console.log(`${
|
|
15956
|
+
console.log(`${chalk162.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
15927
15957
|
}
|
|
15928
15958
|
}
|
|
15929
15959
|
|
|
15930
15960
|
// src/commands/ravendb/ravendbQuery.ts
|
|
15931
|
-
import
|
|
15961
|
+
import chalk164 from "chalk";
|
|
15932
15962
|
|
|
15933
15963
|
// src/commands/ravendb/fetchAllPages.ts
|
|
15934
|
-
import
|
|
15964
|
+
import chalk163 from "chalk";
|
|
15935
15965
|
|
|
15936
15966
|
// src/commands/ravendb/buildQueryPath.ts
|
|
15937
15967
|
function buildQueryPath(opts) {
|
|
@@ -15969,7 +15999,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15969
15999
|
allResults.push(...results);
|
|
15970
16000
|
start3 += results.length;
|
|
15971
16001
|
process.stderr.write(
|
|
15972
|
-
`\r${
|
|
16002
|
+
`\r${chalk163.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
15973
16003
|
);
|
|
15974
16004
|
if (start3 >= totalResults) break;
|
|
15975
16005
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -15984,7 +16014,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15984
16014
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
15985
16015
|
const resolved = resolveArgs(connectionName, collection);
|
|
15986
16016
|
if (!resolved.collection && !options2.query) {
|
|
15987
|
-
console.error(
|
|
16017
|
+
console.error(chalk164.red("Provide a collection name or --query filter."));
|
|
15988
16018
|
process.exit(1);
|
|
15989
16019
|
}
|
|
15990
16020
|
const { collection: col } = resolved;
|
|
@@ -16022,7 +16052,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
16022
16052
|
import * as path28 from "path";
|
|
16023
16053
|
|
|
16024
16054
|
// src/commands/refactor/logViolations.ts
|
|
16025
|
-
import
|
|
16055
|
+
import chalk165 from "chalk";
|
|
16026
16056
|
var DEFAULT_MAX_LINES = 100;
|
|
16027
16057
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
16028
16058
|
if (violations.length === 0) {
|
|
@@ -16031,43 +16061,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
16031
16061
|
}
|
|
16032
16062
|
return;
|
|
16033
16063
|
}
|
|
16034
|
-
console.error(
|
|
16064
|
+
console.error(chalk165.red(`
|
|
16035
16065
|
Refactor check failed:
|
|
16036
16066
|
`));
|
|
16037
|
-
console.error(
|
|
16067
|
+
console.error(chalk165.red(` The following files exceed ${maxLines} lines:
|
|
16038
16068
|
`));
|
|
16039
16069
|
for (const violation of violations) {
|
|
16040
|
-
console.error(
|
|
16070
|
+
console.error(chalk165.red(` ${violation.file} (${violation.lines} lines)`));
|
|
16041
16071
|
}
|
|
16042
16072
|
console.error(
|
|
16043
|
-
|
|
16073
|
+
chalk165.yellow(
|
|
16044
16074
|
`
|
|
16045
16075
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
16046
16076
|
way to refactor it, ignore it with:
|
|
16047
16077
|
`
|
|
16048
16078
|
)
|
|
16049
16079
|
);
|
|
16050
|
-
console.error(
|
|
16080
|
+
console.error(chalk165.gray(` assist refactor ignore <file>
|
|
16051
16081
|
`));
|
|
16052
16082
|
if (process.env.CLAUDECODE) {
|
|
16053
|
-
console.error(
|
|
16083
|
+
console.error(chalk165.cyan(`
|
|
16054
16084
|
## Extracting Code to New Files
|
|
16055
16085
|
`));
|
|
16056
16086
|
console.error(
|
|
16057
|
-
|
|
16087
|
+
chalk165.cyan(
|
|
16058
16088
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
16059
16089
|
`
|
|
16060
16090
|
)
|
|
16061
16091
|
);
|
|
16062
16092
|
console.error(
|
|
16063
|
-
|
|
16093
|
+
chalk165.cyan(
|
|
16064
16094
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
16065
16095
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
16066
16096
|
`
|
|
16067
16097
|
)
|
|
16068
16098
|
);
|
|
16069
16099
|
console.error(
|
|
16070
|
-
|
|
16100
|
+
chalk165.cyan(
|
|
16071
16101
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
16072
16102
|
domains, move it to a common/shared folder.
|
|
16073
16103
|
`
|
|
@@ -16223,7 +16253,7 @@ async function check(pattern2, options2) {
|
|
|
16223
16253
|
|
|
16224
16254
|
// src/commands/refactor/extract/index.ts
|
|
16225
16255
|
import path35 from "path";
|
|
16226
|
-
import
|
|
16256
|
+
import chalk168 from "chalk";
|
|
16227
16257
|
|
|
16228
16258
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
16229
16259
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -16798,23 +16828,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
16798
16828
|
|
|
16799
16829
|
// src/commands/refactor/extract/displayPlan.ts
|
|
16800
16830
|
import path32 from "path";
|
|
16801
|
-
import
|
|
16831
|
+
import chalk166 from "chalk";
|
|
16802
16832
|
function section(title) {
|
|
16803
16833
|
return `
|
|
16804
|
-
${
|
|
16834
|
+
${chalk166.cyan(title)}`;
|
|
16805
16835
|
}
|
|
16806
16836
|
function displayImporters(plan2, cwd) {
|
|
16807
16837
|
if (plan2.importersToUpdate.length === 0) return;
|
|
16808
16838
|
console.log(section("Update importers:"));
|
|
16809
16839
|
for (const imp of plan2.importersToUpdate) {
|
|
16810
16840
|
const rel = path32.relative(cwd, imp.file.getFilePath());
|
|
16811
|
-
console.log(` ${
|
|
16841
|
+
console.log(` ${chalk166.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
16812
16842
|
}
|
|
16813
16843
|
}
|
|
16814
16844
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
16815
|
-
console.log(
|
|
16845
|
+
console.log(chalk166.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
16816
16846
|
`));
|
|
16817
|
-
console.log(` ${
|
|
16847
|
+
console.log(` ${chalk166.cyan("Functions to move:")}`);
|
|
16818
16848
|
for (const name of plan2.extractedNames) {
|
|
16819
16849
|
console.log(` ${name}`);
|
|
16820
16850
|
}
|
|
@@ -16848,7 +16878,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
16848
16878
|
|
|
16849
16879
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
16850
16880
|
import path34 from "path";
|
|
16851
|
-
import
|
|
16881
|
+
import chalk167 from "chalk";
|
|
16852
16882
|
import { Project as Project4 } from "ts-morph";
|
|
16853
16883
|
|
|
16854
16884
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -16908,7 +16938,7 @@ function loadProjectFile(file) {
|
|
|
16908
16938
|
});
|
|
16909
16939
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
16910
16940
|
if (!sourceFile) {
|
|
16911
|
-
console.log(
|
|
16941
|
+
console.log(chalk167.red(`File not found in project: ${file}`));
|
|
16912
16942
|
process.exit(1);
|
|
16913
16943
|
}
|
|
16914
16944
|
return { project, sourceFile };
|
|
@@ -16931,19 +16961,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
16931
16961
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
16932
16962
|
if (options2.apply) {
|
|
16933
16963
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
16934
|
-
console.log(
|
|
16964
|
+
console.log(chalk168.green("\nExtraction complete"));
|
|
16935
16965
|
} else {
|
|
16936
|
-
console.log(
|
|
16966
|
+
console.log(chalk168.dim("\nDry run. Use --apply to execute."));
|
|
16937
16967
|
}
|
|
16938
16968
|
}
|
|
16939
16969
|
|
|
16940
16970
|
// src/commands/refactor/ignore.ts
|
|
16941
16971
|
import fs24 from "fs";
|
|
16942
|
-
import
|
|
16972
|
+
import chalk169 from "chalk";
|
|
16943
16973
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
16944
16974
|
function ignore2(file) {
|
|
16945
16975
|
if (!fs24.existsSync(file)) {
|
|
16946
|
-
console.error(
|
|
16976
|
+
console.error(chalk169.red(`Error: File does not exist: ${file}`));
|
|
16947
16977
|
process.exit(1);
|
|
16948
16978
|
}
|
|
16949
16979
|
const content = fs24.readFileSync(file, "utf8");
|
|
@@ -16959,7 +16989,7 @@ function ignore2(file) {
|
|
|
16959
16989
|
fs24.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
16960
16990
|
}
|
|
16961
16991
|
console.log(
|
|
16962
|
-
|
|
16992
|
+
chalk169.green(
|
|
16963
16993
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
16964
16994
|
)
|
|
16965
16995
|
);
|
|
@@ -16968,12 +16998,12 @@ function ignore2(file) {
|
|
|
16968
16998
|
// src/commands/refactor/rename/index.ts
|
|
16969
16999
|
import fs27 from "fs";
|
|
16970
17000
|
import path40 from "path";
|
|
16971
|
-
import
|
|
17001
|
+
import chalk172 from "chalk";
|
|
16972
17002
|
|
|
16973
17003
|
// src/commands/refactor/rename/applyRename.ts
|
|
16974
17004
|
import fs26 from "fs";
|
|
16975
17005
|
import path37 from "path";
|
|
16976
|
-
import
|
|
17006
|
+
import chalk170 from "chalk";
|
|
16977
17007
|
|
|
16978
17008
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
16979
17009
|
import path36 from "path";
|
|
@@ -17078,13 +17108,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
17078
17108
|
const updatedContents = applyRewrites(rewrites);
|
|
17079
17109
|
for (const [file, content] of updatedContents) {
|
|
17080
17110
|
fs26.writeFileSync(file, content, "utf8");
|
|
17081
|
-
console.log(
|
|
17111
|
+
console.log(chalk170.cyan(` Updated imports in ${path37.relative(cwd, file)}`));
|
|
17082
17112
|
}
|
|
17083
17113
|
const destDir = path37.dirname(destPath);
|
|
17084
17114
|
if (!fs26.existsSync(destDir)) fs26.mkdirSync(destDir, { recursive: true });
|
|
17085
17115
|
fs26.renameSync(sourcePath, destPath);
|
|
17086
17116
|
console.log(
|
|
17087
|
-
|
|
17117
|
+
chalk170.white(
|
|
17088
17118
|
` Moved ${path37.relative(cwd, sourcePath)} \u2192 ${path37.relative(cwd, destPath)}`
|
|
17089
17119
|
)
|
|
17090
17120
|
);
|
|
@@ -17171,16 +17201,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
17171
17201
|
|
|
17172
17202
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
17173
17203
|
import path39 from "path";
|
|
17174
|
-
import
|
|
17204
|
+
import chalk171 from "chalk";
|
|
17175
17205
|
function printRenamePreview(rewrites, cwd) {
|
|
17176
17206
|
for (const rewrite of rewrites) {
|
|
17177
17207
|
console.log(
|
|
17178
|
-
|
|
17208
|
+
chalk171.dim(
|
|
17179
17209
|
` ${path39.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
17180
17210
|
)
|
|
17181
17211
|
);
|
|
17182
17212
|
}
|
|
17183
|
-
console.log(
|
|
17213
|
+
console.log(chalk171.dim("Dry run. Use --apply to execute."));
|
|
17184
17214
|
}
|
|
17185
17215
|
|
|
17186
17216
|
// src/commands/refactor/rename/index.ts
|
|
@@ -17191,20 +17221,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
17191
17221
|
const relSource = path40.relative(cwd, sourcePath);
|
|
17192
17222
|
const relDest = path40.relative(cwd, destPath);
|
|
17193
17223
|
if (!fs27.existsSync(sourcePath)) {
|
|
17194
|
-
console.log(
|
|
17224
|
+
console.log(chalk172.red(`File not found: ${source}`));
|
|
17195
17225
|
process.exit(1);
|
|
17196
17226
|
}
|
|
17197
17227
|
if (destPath !== sourcePath && fs27.existsSync(destPath)) {
|
|
17198
|
-
console.log(
|
|
17228
|
+
console.log(chalk172.red(`Destination already exists: ${destination}`));
|
|
17199
17229
|
process.exit(1);
|
|
17200
17230
|
}
|
|
17201
|
-
console.log(
|
|
17202
|
-
console.log(
|
|
17203
|
-
console.log(
|
|
17231
|
+
console.log(chalk172.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
17232
|
+
console.log(chalk172.dim("Loading project..."));
|
|
17233
|
+
console.log(chalk172.dim("Scanning imports across the project..."));
|
|
17204
17234
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
17205
17235
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
17206
17236
|
console.log(
|
|
17207
|
-
|
|
17237
|
+
chalk172.dim(
|
|
17208
17238
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
17209
17239
|
)
|
|
17210
17240
|
);
|
|
@@ -17213,11 +17243,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
17213
17243
|
return;
|
|
17214
17244
|
}
|
|
17215
17245
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
17216
|
-
console.log(
|
|
17246
|
+
console.log(chalk172.green("Done"));
|
|
17217
17247
|
}
|
|
17218
17248
|
|
|
17219
17249
|
// src/commands/refactor/renameSymbol/index.ts
|
|
17220
|
-
import
|
|
17250
|
+
import chalk173 from "chalk";
|
|
17221
17251
|
|
|
17222
17252
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
17223
17253
|
import { SyntaxKind as SyntaxKind14 } from "ts-morph";
|
|
@@ -17263,33 +17293,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
17263
17293
|
const { project, sourceFile } = loadProjectFile(file);
|
|
17264
17294
|
const symbol = findSymbol(sourceFile, oldName);
|
|
17265
17295
|
if (!symbol) {
|
|
17266
|
-
console.log(
|
|
17296
|
+
console.log(chalk173.red(`Symbol "${oldName}" not found in ${file}`));
|
|
17267
17297
|
process.exit(1);
|
|
17268
17298
|
}
|
|
17269
17299
|
const grouped = groupReferences(symbol, cwd);
|
|
17270
17300
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
17271
17301
|
console.log(
|
|
17272
|
-
|
|
17302
|
+
chalk173.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
17273
17303
|
`)
|
|
17274
17304
|
);
|
|
17275
17305
|
for (const [refFile, lines] of grouped) {
|
|
17276
17306
|
console.log(
|
|
17277
|
-
` ${
|
|
17307
|
+
` ${chalk173.dim(refFile)}: lines ${chalk173.cyan(lines.join(", "))}`
|
|
17278
17308
|
);
|
|
17279
17309
|
}
|
|
17280
17310
|
if (options2.apply) {
|
|
17281
17311
|
symbol.rename(newName);
|
|
17282
17312
|
await project.save();
|
|
17283
|
-
console.log(
|
|
17313
|
+
console.log(chalk173.green(`
|
|
17284
17314
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
17285
17315
|
} else {
|
|
17286
|
-
console.log(
|
|
17316
|
+
console.log(chalk173.dim("\nDry run. Use --apply to execute."));
|
|
17287
17317
|
}
|
|
17288
17318
|
}
|
|
17289
17319
|
|
|
17290
17320
|
// src/commands/refactor/restructure/index.ts
|
|
17291
17321
|
import path48 from "path";
|
|
17292
|
-
import
|
|
17322
|
+
import chalk176 from "chalk";
|
|
17293
17323
|
|
|
17294
17324
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
17295
17325
|
import path42 from "path";
|
|
@@ -17368,50 +17398,50 @@ function clusterFiles(graph) {
|
|
|
17368
17398
|
|
|
17369
17399
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
17370
17400
|
import path44 from "path";
|
|
17371
|
-
import
|
|
17401
|
+
import chalk174 from "chalk";
|
|
17372
17402
|
function relPath(filePath) {
|
|
17373
17403
|
return path44.relative(process.cwd(), filePath);
|
|
17374
17404
|
}
|
|
17375
17405
|
function displayMoves(plan2) {
|
|
17376
17406
|
if (plan2.moves.length === 0) return;
|
|
17377
|
-
console.log(
|
|
17407
|
+
console.log(chalk174.bold("\nFile moves:"));
|
|
17378
17408
|
for (const move2 of plan2.moves) {
|
|
17379
17409
|
console.log(
|
|
17380
|
-
` ${
|
|
17410
|
+
` ${chalk174.red(relPath(move2.from))} \u2192 ${chalk174.green(relPath(move2.to))}`
|
|
17381
17411
|
);
|
|
17382
|
-
console.log(
|
|
17412
|
+
console.log(chalk174.dim(` ${move2.reason}`));
|
|
17383
17413
|
}
|
|
17384
17414
|
}
|
|
17385
17415
|
function displayRewrites(rewrites) {
|
|
17386
17416
|
if (rewrites.length === 0) return;
|
|
17387
17417
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
17388
|
-
console.log(
|
|
17418
|
+
console.log(chalk174.bold(`
|
|
17389
17419
|
Import rewrites (${affectedFiles.size} files):`));
|
|
17390
17420
|
for (const file of affectedFiles) {
|
|
17391
|
-
console.log(` ${
|
|
17421
|
+
console.log(` ${chalk174.cyan(relPath(file))}:`);
|
|
17392
17422
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
17393
17423
|
(r) => r.file === file
|
|
17394
17424
|
)) {
|
|
17395
17425
|
console.log(
|
|
17396
|
-
` ${
|
|
17426
|
+
` ${chalk174.red(`"${oldSpecifier}"`)} \u2192 ${chalk174.green(`"${newSpecifier}"`)}`
|
|
17397
17427
|
);
|
|
17398
17428
|
}
|
|
17399
17429
|
}
|
|
17400
17430
|
}
|
|
17401
17431
|
function displayPlan2(plan2) {
|
|
17402
17432
|
if (plan2.warnings.length > 0) {
|
|
17403
|
-
console.log(
|
|
17404
|
-
for (const w of plan2.warnings) console.log(
|
|
17433
|
+
console.log(chalk174.yellow("\nWarnings:"));
|
|
17434
|
+
for (const w of plan2.warnings) console.log(chalk174.yellow(` ${w}`));
|
|
17405
17435
|
}
|
|
17406
17436
|
if (plan2.newDirectories.length > 0) {
|
|
17407
|
-
console.log(
|
|
17437
|
+
console.log(chalk174.bold("\nNew directories:"));
|
|
17408
17438
|
for (const dir of plan2.newDirectories)
|
|
17409
|
-
console.log(
|
|
17439
|
+
console.log(chalk174.green(` ${dir}/`));
|
|
17410
17440
|
}
|
|
17411
17441
|
displayMoves(plan2);
|
|
17412
17442
|
displayRewrites(plan2.rewrites);
|
|
17413
17443
|
console.log(
|
|
17414
|
-
|
|
17444
|
+
chalk174.dim(
|
|
17415
17445
|
`
|
|
17416
17446
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
17417
17447
|
)
|
|
@@ -17421,18 +17451,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
17421
17451
|
// src/commands/refactor/restructure/executePlan.ts
|
|
17422
17452
|
import fs28 from "fs";
|
|
17423
17453
|
import path45 from "path";
|
|
17424
|
-
import
|
|
17454
|
+
import chalk175 from "chalk";
|
|
17425
17455
|
function executePlan(plan2) {
|
|
17426
17456
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
17427
17457
|
for (const [file, content] of updatedContents) {
|
|
17428
17458
|
fs28.writeFileSync(file, content, "utf8");
|
|
17429
17459
|
console.log(
|
|
17430
|
-
|
|
17460
|
+
chalk175.cyan(` Rewrote imports in ${path45.relative(process.cwd(), file)}`)
|
|
17431
17461
|
);
|
|
17432
17462
|
}
|
|
17433
17463
|
for (const dir of plan2.newDirectories) {
|
|
17434
17464
|
fs28.mkdirSync(dir, { recursive: true });
|
|
17435
|
-
console.log(
|
|
17465
|
+
console.log(chalk175.green(` Created ${path45.relative(process.cwd(), dir)}/`));
|
|
17436
17466
|
}
|
|
17437
17467
|
for (const move2 of plan2.moves) {
|
|
17438
17468
|
const targetDir = path45.dirname(move2.to);
|
|
@@ -17441,7 +17471,7 @@ function executePlan(plan2) {
|
|
|
17441
17471
|
}
|
|
17442
17472
|
fs28.renameSync(move2.from, move2.to);
|
|
17443
17473
|
console.log(
|
|
17444
|
-
|
|
17474
|
+
chalk175.white(
|
|
17445
17475
|
` Moved ${path45.relative(process.cwd(), move2.from)} \u2192 ${path45.relative(process.cwd(), move2.to)}`
|
|
17446
17476
|
)
|
|
17447
17477
|
);
|
|
@@ -17456,7 +17486,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
17456
17486
|
if (entries.length === 0) {
|
|
17457
17487
|
fs28.rmdirSync(dir);
|
|
17458
17488
|
console.log(
|
|
17459
|
-
|
|
17489
|
+
chalk175.dim(
|
|
17460
17490
|
` Removed empty directory ${path45.relative(process.cwd(), dir)}`
|
|
17461
17491
|
)
|
|
17462
17492
|
);
|
|
@@ -17589,22 +17619,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
17589
17619
|
const targetPattern = pattern2 ?? "src";
|
|
17590
17620
|
const files = findSourceFiles2(targetPattern);
|
|
17591
17621
|
if (files.length === 0) {
|
|
17592
|
-
console.log(
|
|
17622
|
+
console.log(chalk176.yellow("No files found matching pattern"));
|
|
17593
17623
|
return;
|
|
17594
17624
|
}
|
|
17595
17625
|
const tsConfigPath = path48.resolve("tsconfig.json");
|
|
17596
17626
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
17597
17627
|
if (plan2.moves.length === 0) {
|
|
17598
|
-
console.log(
|
|
17628
|
+
console.log(chalk176.green("No restructuring needed"));
|
|
17599
17629
|
return;
|
|
17600
17630
|
}
|
|
17601
17631
|
displayPlan2(plan2);
|
|
17602
17632
|
if (options2.apply) {
|
|
17603
|
-
console.log(
|
|
17633
|
+
console.log(chalk176.bold("\nApplying changes..."));
|
|
17604
17634
|
executePlan(plan2);
|
|
17605
|
-
console.log(
|
|
17635
|
+
console.log(chalk176.green("\nRestructuring complete"));
|
|
17606
17636
|
} else {
|
|
17607
|
-
console.log(
|
|
17637
|
+
console.log(chalk176.dim("\nDry run. Use --apply to execute."));
|
|
17608
17638
|
}
|
|
17609
17639
|
}
|
|
17610
17640
|
|
|
@@ -18177,18 +18207,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
18177
18207
|
}
|
|
18178
18208
|
|
|
18179
18209
|
// src/commands/review/warnOutOfDiff.ts
|
|
18180
|
-
import
|
|
18210
|
+
import chalk177 from "chalk";
|
|
18181
18211
|
function warnOutOfDiff(outOfDiff) {
|
|
18182
18212
|
if (outOfDiff.length === 0) return;
|
|
18183
18213
|
console.warn(
|
|
18184
|
-
|
|
18214
|
+
chalk177.yellow(
|
|
18185
18215
|
`Skipped ${outOfDiff.length} finding(s) whose lines fall outside the PR diff (GitHub would silently drop these):`
|
|
18186
18216
|
)
|
|
18187
18217
|
);
|
|
18188
18218
|
for (const finding of outOfDiff) {
|
|
18189
18219
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
18190
18220
|
console.warn(
|
|
18191
|
-
` ${
|
|
18221
|
+
` ${chalk177.yellow("\xB7")} ${finding.title} ${chalk177.dim(
|
|
18192
18222
|
`(${finding.file}:${range})`
|
|
18193
18223
|
)}`
|
|
18194
18224
|
);
|
|
@@ -18207,18 +18237,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
18207
18237
|
}
|
|
18208
18238
|
|
|
18209
18239
|
// src/commands/review/warnUnlocated.ts
|
|
18210
|
-
import
|
|
18240
|
+
import chalk178 from "chalk";
|
|
18211
18241
|
function warnUnlocated(unlocated) {
|
|
18212
18242
|
if (unlocated.length === 0) return;
|
|
18213
18243
|
console.warn(
|
|
18214
|
-
|
|
18244
|
+
chalk178.yellow(
|
|
18215
18245
|
`Skipped ${unlocated.length} finding(s) without a parseable file:line:`
|
|
18216
18246
|
)
|
|
18217
18247
|
);
|
|
18218
18248
|
for (const finding of unlocated) {
|
|
18219
|
-
const where = finding.location ||
|
|
18249
|
+
const where = finding.location || chalk178.dim("missing");
|
|
18220
18250
|
console.warn(
|
|
18221
|
-
` ${
|
|
18251
|
+
` ${chalk178.yellow("\xB7")} ${finding.title} ${chalk178.dim(`(${where})`)}`
|
|
18222
18252
|
);
|
|
18223
18253
|
}
|
|
18224
18254
|
}
|
|
@@ -19390,7 +19420,7 @@ function registerReview(program2) {
|
|
|
19390
19420
|
}
|
|
19391
19421
|
|
|
19392
19422
|
// src/commands/seq/seqAuth.ts
|
|
19393
|
-
import
|
|
19423
|
+
import chalk180 from "chalk";
|
|
19394
19424
|
|
|
19395
19425
|
// src/commands/seq/loadConnections.ts
|
|
19396
19426
|
function loadConnections2() {
|
|
@@ -19419,10 +19449,10 @@ function setDefaultConnection(name) {
|
|
|
19419
19449
|
}
|
|
19420
19450
|
|
|
19421
19451
|
// src/shared/assertUniqueName.ts
|
|
19422
|
-
import
|
|
19452
|
+
import chalk179 from "chalk";
|
|
19423
19453
|
function assertUniqueName(existingNames, name) {
|
|
19424
19454
|
if (existingNames.includes(name)) {
|
|
19425
|
-
console.error(
|
|
19455
|
+
console.error(chalk179.red(`Connection "${name}" already exists.`));
|
|
19426
19456
|
process.exit(1);
|
|
19427
19457
|
}
|
|
19428
19458
|
}
|
|
@@ -19440,16 +19470,16 @@ async function promptConnection2(existingNames) {
|
|
|
19440
19470
|
var seqAuth = createConnectionAuth({
|
|
19441
19471
|
load: loadConnections2,
|
|
19442
19472
|
save: saveConnections2,
|
|
19443
|
-
format: (c) => `${
|
|
19473
|
+
format: (c) => `${chalk180.bold(c.name)} ${c.url}`,
|
|
19444
19474
|
promptNew: promptConnection2,
|
|
19445
19475
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
19446
19476
|
});
|
|
19447
19477
|
|
|
19448
19478
|
// src/commands/seq/seqQuery.ts
|
|
19449
|
-
import
|
|
19479
|
+
import chalk184 from "chalk";
|
|
19450
19480
|
|
|
19451
19481
|
// src/commands/seq/fetchSeq.ts
|
|
19452
|
-
import
|
|
19482
|
+
import chalk181 from "chalk";
|
|
19453
19483
|
async function fetchSeq(conn, path57, params) {
|
|
19454
19484
|
const url = `${conn.url}${path57}?${params}`;
|
|
19455
19485
|
const response = await fetch(url, {
|
|
@@ -19460,7 +19490,7 @@ async function fetchSeq(conn, path57, params) {
|
|
|
19460
19490
|
});
|
|
19461
19491
|
if (!response.ok) {
|
|
19462
19492
|
const body = await response.text();
|
|
19463
|
-
console.error(
|
|
19493
|
+
console.error(chalk181.red(`Seq returned ${response.status}: ${body}`));
|
|
19464
19494
|
process.exit(1);
|
|
19465
19495
|
}
|
|
19466
19496
|
return response;
|
|
@@ -19519,23 +19549,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
19519
19549
|
}
|
|
19520
19550
|
|
|
19521
19551
|
// src/commands/seq/formatEvent.ts
|
|
19522
|
-
import
|
|
19552
|
+
import chalk182 from "chalk";
|
|
19523
19553
|
function levelColor(level) {
|
|
19524
19554
|
switch (level) {
|
|
19525
19555
|
case "Fatal":
|
|
19526
|
-
return
|
|
19556
|
+
return chalk182.bgRed.white;
|
|
19527
19557
|
case "Error":
|
|
19528
|
-
return
|
|
19558
|
+
return chalk182.red;
|
|
19529
19559
|
case "Warning":
|
|
19530
|
-
return
|
|
19560
|
+
return chalk182.yellow;
|
|
19531
19561
|
case "Information":
|
|
19532
|
-
return
|
|
19562
|
+
return chalk182.cyan;
|
|
19533
19563
|
case "Debug":
|
|
19534
|
-
return
|
|
19564
|
+
return chalk182.gray;
|
|
19535
19565
|
case "Verbose":
|
|
19536
|
-
return
|
|
19566
|
+
return chalk182.dim;
|
|
19537
19567
|
default:
|
|
19538
|
-
return
|
|
19568
|
+
return chalk182.white;
|
|
19539
19569
|
}
|
|
19540
19570
|
}
|
|
19541
19571
|
function levelAbbrev(level) {
|
|
@@ -19576,12 +19606,12 @@ function formatTimestamp(iso) {
|
|
|
19576
19606
|
function formatEvent(event) {
|
|
19577
19607
|
const color = levelColor(event.Level);
|
|
19578
19608
|
const abbrev = levelAbbrev(event.Level);
|
|
19579
|
-
const ts8 =
|
|
19609
|
+
const ts8 = chalk182.dim(formatTimestamp(event.Timestamp));
|
|
19580
19610
|
const msg = renderMessage(event);
|
|
19581
19611
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
19582
19612
|
if (event.Exception) {
|
|
19583
19613
|
for (const line of event.Exception.split("\n")) {
|
|
19584
|
-
lines.push(
|
|
19614
|
+
lines.push(chalk182.red(` ${line}`));
|
|
19585
19615
|
}
|
|
19586
19616
|
}
|
|
19587
19617
|
return lines.join("\n");
|
|
@@ -19614,11 +19644,11 @@ function rejectTimestampFilter(filter) {
|
|
|
19614
19644
|
}
|
|
19615
19645
|
|
|
19616
19646
|
// src/shared/resolveNamedConnection.ts
|
|
19617
|
-
import
|
|
19647
|
+
import chalk183 from "chalk";
|
|
19618
19648
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
19619
19649
|
if (connections.length === 0) {
|
|
19620
19650
|
console.error(
|
|
19621
|
-
|
|
19651
|
+
chalk183.red(
|
|
19622
19652
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
19623
19653
|
)
|
|
19624
19654
|
);
|
|
@@ -19627,7 +19657,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
19627
19657
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
19628
19658
|
const connection = connections.find((c) => c.name === target);
|
|
19629
19659
|
if (!connection) {
|
|
19630
|
-
console.error(
|
|
19660
|
+
console.error(chalk183.red(`${kind} connection "${target}" not found.`));
|
|
19631
19661
|
process.exit(1);
|
|
19632
19662
|
}
|
|
19633
19663
|
return connection;
|
|
@@ -19656,7 +19686,7 @@ async function seqQuery(filter, options2) {
|
|
|
19656
19686
|
new URLSearchParams({ filter, count: String(count8) })
|
|
19657
19687
|
);
|
|
19658
19688
|
if (events.length === 0) {
|
|
19659
|
-
console.log(
|
|
19689
|
+
console.log(chalk184.yellow("No events found."));
|
|
19660
19690
|
return;
|
|
19661
19691
|
}
|
|
19662
19692
|
if (options2.json) {
|
|
@@ -19667,11 +19697,11 @@ async function seqQuery(filter, options2) {
|
|
|
19667
19697
|
for (const event of chronological) {
|
|
19668
19698
|
console.log(formatEvent(event));
|
|
19669
19699
|
}
|
|
19670
|
-
console.log(
|
|
19700
|
+
console.log(chalk184.dim(`
|
|
19671
19701
|
${events.length} events`));
|
|
19672
19702
|
if (events.length >= count8) {
|
|
19673
19703
|
console.log(
|
|
19674
|
-
|
|
19704
|
+
chalk184.yellow(
|
|
19675
19705
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
19676
19706
|
)
|
|
19677
19707
|
);
|
|
@@ -19679,10 +19709,10 @@ ${events.length} events`));
|
|
|
19679
19709
|
}
|
|
19680
19710
|
|
|
19681
19711
|
// src/shared/setNamedDefaultConnection.ts
|
|
19682
|
-
import
|
|
19712
|
+
import chalk185 from "chalk";
|
|
19683
19713
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
19684
19714
|
if (!connections.find((c) => c.name === name)) {
|
|
19685
|
-
console.error(
|
|
19715
|
+
console.error(chalk185.red(`Connection "${name}" not found.`));
|
|
19686
19716
|
process.exit(1);
|
|
19687
19717
|
}
|
|
19688
19718
|
setDefault(name);
|
|
@@ -19730,7 +19760,7 @@ function registerSignal(program2) {
|
|
|
19730
19760
|
}
|
|
19731
19761
|
|
|
19732
19762
|
// src/commands/sql/sqlAuth.ts
|
|
19733
|
-
import
|
|
19763
|
+
import chalk187 from "chalk";
|
|
19734
19764
|
|
|
19735
19765
|
// src/commands/sql/loadConnections.ts
|
|
19736
19766
|
function loadConnections3() {
|
|
@@ -19759,7 +19789,7 @@ function setDefaultConnection2(name) {
|
|
|
19759
19789
|
}
|
|
19760
19790
|
|
|
19761
19791
|
// src/commands/sql/promptConnection.ts
|
|
19762
|
-
import
|
|
19792
|
+
import chalk186 from "chalk";
|
|
19763
19793
|
async function promptConnection3(existingNames) {
|
|
19764
19794
|
const name = await promptInput("name", "Connection name:", "default");
|
|
19765
19795
|
assertUniqueName(existingNames, name);
|
|
@@ -19767,7 +19797,7 @@ async function promptConnection3(existingNames) {
|
|
|
19767
19797
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
19768
19798
|
const port = Number.parseInt(portStr, 10);
|
|
19769
19799
|
if (!Number.isFinite(port)) {
|
|
19770
|
-
console.error(
|
|
19800
|
+
console.error(chalk186.red(`Invalid port "${portStr}".`));
|
|
19771
19801
|
process.exit(1);
|
|
19772
19802
|
}
|
|
19773
19803
|
const user = await promptInput("user", "User:");
|
|
@@ -19780,13 +19810,13 @@ async function promptConnection3(existingNames) {
|
|
|
19780
19810
|
var sqlAuth = createConnectionAuth({
|
|
19781
19811
|
load: loadConnections3,
|
|
19782
19812
|
save: saveConnections3,
|
|
19783
|
-
format: (c) => `${
|
|
19813
|
+
format: (c) => `${chalk187.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
19784
19814
|
promptNew: promptConnection3,
|
|
19785
19815
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
19786
19816
|
});
|
|
19787
19817
|
|
|
19788
19818
|
// src/commands/sql/printTable.ts
|
|
19789
|
-
import
|
|
19819
|
+
import chalk188 from "chalk";
|
|
19790
19820
|
function formatCell(value) {
|
|
19791
19821
|
if (value === null || value === void 0) return "";
|
|
19792
19822
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -19795,7 +19825,7 @@ function formatCell(value) {
|
|
|
19795
19825
|
}
|
|
19796
19826
|
function printTable(rows) {
|
|
19797
19827
|
if (rows.length === 0) {
|
|
19798
|
-
console.log(
|
|
19828
|
+
console.log(chalk188.yellow("(no rows)"));
|
|
19799
19829
|
return;
|
|
19800
19830
|
}
|
|
19801
19831
|
const columns = Object.keys(rows[0]);
|
|
@@ -19803,13 +19833,13 @@ function printTable(rows) {
|
|
|
19803
19833
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
19804
19834
|
);
|
|
19805
19835
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
19806
|
-
console.log(
|
|
19807
|
-
console.log(
|
|
19836
|
+
console.log(chalk188.dim(header));
|
|
19837
|
+
console.log(chalk188.dim("-".repeat(header.length)));
|
|
19808
19838
|
for (const row of rows) {
|
|
19809
19839
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
19810
19840
|
console.log(line);
|
|
19811
19841
|
}
|
|
19812
|
-
console.log(
|
|
19842
|
+
console.log(chalk188.dim(`
|
|
19813
19843
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
19814
19844
|
}
|
|
19815
19845
|
|
|
@@ -19869,7 +19899,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
19869
19899
|
}
|
|
19870
19900
|
|
|
19871
19901
|
// src/commands/sql/sqlMutate.ts
|
|
19872
|
-
import
|
|
19902
|
+
import chalk189 from "chalk";
|
|
19873
19903
|
|
|
19874
19904
|
// src/commands/sql/isMutation.ts
|
|
19875
19905
|
var MUTATION_KEYWORDS = [
|
|
@@ -19903,7 +19933,7 @@ function isMutation(sql11) {
|
|
|
19903
19933
|
async function sqlMutate(query, connectionName) {
|
|
19904
19934
|
if (!isMutation(query)) {
|
|
19905
19935
|
console.error(
|
|
19906
|
-
|
|
19936
|
+
chalk189.red(
|
|
19907
19937
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
19908
19938
|
)
|
|
19909
19939
|
);
|
|
@@ -19913,18 +19943,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
19913
19943
|
const pool = await sqlConnect(conn);
|
|
19914
19944
|
try {
|
|
19915
19945
|
const result = await pool.request().query(query);
|
|
19916
|
-
console.log(
|
|
19946
|
+
console.log(chalk189.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
19917
19947
|
} finally {
|
|
19918
19948
|
await pool.close();
|
|
19919
19949
|
}
|
|
19920
19950
|
}
|
|
19921
19951
|
|
|
19922
19952
|
// src/commands/sql/sqlQuery.ts
|
|
19923
|
-
import
|
|
19953
|
+
import chalk190 from "chalk";
|
|
19924
19954
|
async function sqlQuery(query, connectionName) {
|
|
19925
19955
|
if (isMutation(query)) {
|
|
19926
19956
|
console.error(
|
|
19927
|
-
|
|
19957
|
+
chalk190.red(
|
|
19928
19958
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
19929
19959
|
)
|
|
19930
19960
|
);
|
|
@@ -19939,7 +19969,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
19939
19969
|
printTable(rows);
|
|
19940
19970
|
} else {
|
|
19941
19971
|
console.log(
|
|
19942
|
-
|
|
19972
|
+
chalk190.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
19943
19973
|
);
|
|
19944
19974
|
}
|
|
19945
19975
|
} finally {
|
|
@@ -20636,7 +20666,7 @@ function registerVoice(program2) {
|
|
|
20636
20666
|
|
|
20637
20667
|
// src/commands/roam/auth.ts
|
|
20638
20668
|
import { randomBytes } from "crypto";
|
|
20639
|
-
import
|
|
20669
|
+
import chalk191 from "chalk";
|
|
20640
20670
|
|
|
20641
20671
|
// src/commands/roam/waitForCallback.ts
|
|
20642
20672
|
import { createServer as createServer3 } from "http";
|
|
@@ -20767,13 +20797,13 @@ async function auth() {
|
|
|
20767
20797
|
saveGlobalConfig(config);
|
|
20768
20798
|
const state = randomBytes(16).toString("hex");
|
|
20769
20799
|
console.log(
|
|
20770
|
-
|
|
20800
|
+
chalk191.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
20771
20801
|
);
|
|
20772
|
-
console.log(
|
|
20773
|
-
console.log(
|
|
20774
|
-
console.log(
|
|
20802
|
+
console.log(chalk191.white("http://localhost:14523/callback\n"));
|
|
20803
|
+
console.log(chalk191.blue("Opening browser for authorization..."));
|
|
20804
|
+
console.log(chalk191.dim("Waiting for authorization callback..."));
|
|
20775
20805
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
20776
|
-
console.log(
|
|
20806
|
+
console.log(chalk191.dim("Exchanging code for tokens..."));
|
|
20777
20807
|
const tokens = await exchangeToken({
|
|
20778
20808
|
code,
|
|
20779
20809
|
clientId,
|
|
@@ -20789,7 +20819,7 @@ async function auth() {
|
|
|
20789
20819
|
};
|
|
20790
20820
|
saveGlobalConfig(config);
|
|
20791
20821
|
console.log(
|
|
20792
|
-
|
|
20822
|
+
chalk191.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
20793
20823
|
);
|
|
20794
20824
|
}
|
|
20795
20825
|
|
|
@@ -21241,7 +21271,7 @@ import { execSync as execSync54 } from "child_process";
|
|
|
21241
21271
|
import { existsSync as existsSync51, mkdirSync as mkdirSync22, unlinkSync as unlinkSync19, writeFileSync as writeFileSync39 } from "fs";
|
|
21242
21272
|
import { tmpdir as tmpdir7 } from "os";
|
|
21243
21273
|
import { join as join61, resolve as resolve15 } from "path";
|
|
21244
|
-
import
|
|
21274
|
+
import chalk192 from "chalk";
|
|
21245
21275
|
|
|
21246
21276
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
21247
21277
|
var captureWindowPs1 = `
|
|
@@ -21392,13 +21422,13 @@ function screenshot(processName) {
|
|
|
21392
21422
|
const config = loadConfig();
|
|
21393
21423
|
const outputDir = resolve15(config.screenshot.outputDir);
|
|
21394
21424
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
21395
|
-
console.log(
|
|
21425
|
+
console.log(chalk192.gray(`Capturing window for process "${processName}" ...`));
|
|
21396
21426
|
try {
|
|
21397
21427
|
runPowerShellScript(processName, outputPath);
|
|
21398
|
-
console.log(
|
|
21428
|
+
console.log(chalk192.green(`Screenshot saved: ${outputPath}`));
|
|
21399
21429
|
} catch (error) {
|
|
21400
21430
|
const msg = error instanceof Error ? error.message : String(error);
|
|
21401
|
-
console.error(
|
|
21431
|
+
console.error(chalk192.red(`Failed to capture screenshot: ${msg}`));
|
|
21402
21432
|
process.exit(1);
|
|
21403
21433
|
}
|
|
21404
21434
|
}
|
|
@@ -22207,10 +22237,10 @@ function applyReviewPause(session, activity2) {
|
|
|
22207
22237
|
}
|
|
22208
22238
|
|
|
22209
22239
|
// src/shared/db/getPhaseActiveMs.ts
|
|
22210
|
-
import { and as and19, eq as
|
|
22240
|
+
import { and as and19, eq as eq37 } from "drizzle-orm";
|
|
22211
22241
|
async function getPhaseActiveMs(db, itemId, phaseIdx) {
|
|
22212
22242
|
const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
22213
|
-
and19(
|
|
22243
|
+
and19(eq37(phaseUsage.itemId, itemId), eq37(phaseUsage.phaseIdx, phaseIdx))
|
|
22214
22244
|
);
|
|
22215
22245
|
return row?.activeMs ?? 0;
|
|
22216
22246
|
}
|
|
@@ -24059,7 +24089,7 @@ function registerDaemon(program2) {
|
|
|
24059
24089
|
|
|
24060
24090
|
// src/commands/sessions/summarise/index.ts
|
|
24061
24091
|
import * as fs36 from "fs";
|
|
24062
|
-
import
|
|
24092
|
+
import chalk193 from "chalk";
|
|
24063
24093
|
|
|
24064
24094
|
// src/commands/sessions/summarise/shared.ts
|
|
24065
24095
|
import * as fs34 from "fs";
|
|
@@ -24213,22 +24243,22 @@ ${firstMessage}`);
|
|
|
24213
24243
|
async function summarise2(options2) {
|
|
24214
24244
|
const files = await discoverSessionFiles();
|
|
24215
24245
|
if (files.length === 0) {
|
|
24216
|
-
console.log(
|
|
24246
|
+
console.log(chalk193.yellow("No sessions found."));
|
|
24217
24247
|
return;
|
|
24218
24248
|
}
|
|
24219
24249
|
const toProcess = selectCandidates(files, options2);
|
|
24220
24250
|
if (toProcess.length === 0) {
|
|
24221
|
-
console.log(
|
|
24251
|
+
console.log(chalk193.green("All sessions already summarised."));
|
|
24222
24252
|
return;
|
|
24223
24253
|
}
|
|
24224
24254
|
console.log(
|
|
24225
|
-
|
|
24255
|
+
chalk193.cyan(
|
|
24226
24256
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
24227
24257
|
)
|
|
24228
24258
|
);
|
|
24229
24259
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
24230
24260
|
console.log(
|
|
24231
|
-
|
|
24261
|
+
chalk193.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk193.yellow(`, ${failed2} skipped`) : "")
|
|
24232
24262
|
);
|
|
24233
24263
|
}
|
|
24234
24264
|
function selectCandidates(files, options2) {
|
|
@@ -24248,16 +24278,16 @@ function processSessions(files) {
|
|
|
24248
24278
|
let failed2 = 0;
|
|
24249
24279
|
for (let i = 0; i < files.length; i++) {
|
|
24250
24280
|
const file = files[i];
|
|
24251
|
-
process.stdout.write(
|
|
24281
|
+
process.stdout.write(chalk193.dim(` [${i + 1}/${files.length}] `));
|
|
24252
24282
|
const summary = summariseSession(file);
|
|
24253
24283
|
if (summary) {
|
|
24254
24284
|
writeSummary(file, summary);
|
|
24255
24285
|
succeeded++;
|
|
24256
|
-
process.stdout.write(`${
|
|
24286
|
+
process.stdout.write(`${chalk193.green("\u2713")} ${summary}
|
|
24257
24287
|
`);
|
|
24258
24288
|
} else {
|
|
24259
24289
|
failed2++;
|
|
24260
|
-
process.stdout.write(` ${
|
|
24290
|
+
process.stdout.write(` ${chalk193.yellow("skip")}
|
|
24261
24291
|
`);
|
|
24262
24292
|
}
|
|
24263
24293
|
}
|
|
@@ -24275,10 +24305,10 @@ function registerSessions(program2) {
|
|
|
24275
24305
|
}
|
|
24276
24306
|
|
|
24277
24307
|
// src/commands/statusLine.ts
|
|
24278
|
-
import
|
|
24308
|
+
import chalk195 from "chalk";
|
|
24279
24309
|
|
|
24280
24310
|
// src/commands/buildLimitsSegment.ts
|
|
24281
|
-
import
|
|
24311
|
+
import chalk194 from "chalk";
|
|
24282
24312
|
|
|
24283
24313
|
// src/shared/rateLimitLevel.ts
|
|
24284
24314
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -24309,9 +24339,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
24309
24339
|
|
|
24310
24340
|
// src/commands/buildLimitsSegment.ts
|
|
24311
24341
|
var LEVEL_COLOR = {
|
|
24312
|
-
ok:
|
|
24313
|
-
warn:
|
|
24314
|
-
over:
|
|
24342
|
+
ok: chalk194.green,
|
|
24343
|
+
warn: chalk194.yellow,
|
|
24344
|
+
over: chalk194.red
|
|
24315
24345
|
};
|
|
24316
24346
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
24317
24347
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -24402,14 +24432,14 @@ async function relayUsage(claudeSessionId, totalIn, totalOut) {
|
|
|
24402
24432
|
}
|
|
24403
24433
|
|
|
24404
24434
|
// src/commands/statusLine.ts
|
|
24405
|
-
|
|
24435
|
+
chalk195.level = 3;
|
|
24406
24436
|
function formatNumber(num) {
|
|
24407
24437
|
return num.toLocaleString("en-US");
|
|
24408
24438
|
}
|
|
24409
24439
|
function colorizePercent(pct) {
|
|
24410
24440
|
const label2 = `${Math.round(pct)}%`;
|
|
24411
|
-
if (pct > 80) return
|
|
24412
|
-
if (pct > 40) return
|
|
24441
|
+
if (pct > 80) return chalk195.red(label2);
|
|
24442
|
+
if (pct > 40) return chalk195.yellow(label2);
|
|
24413
24443
|
return label2;
|
|
24414
24444
|
}
|
|
24415
24445
|
async function statusLine() {
|
|
@@ -24420,7 +24450,7 @@ async function statusLine() {
|
|
|
24420
24450
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
24421
24451
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
24422
24452
|
const branch2 = dir ? readGitBranch(windowsCwdToWslPath(dir)) : null;
|
|
24423
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
24453
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk195.cyan(branch2)} | ` : "";
|
|
24424
24454
|
console.log(
|
|
24425
24455
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalOut)} \u2191 : ${formatNumber(totalIn)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
24426
24456
|
);
|
|
@@ -24437,7 +24467,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
|
|
|
24437
24467
|
// src/commands/sync/syncClaudeMd.ts
|
|
24438
24468
|
import * as fs37 from "fs";
|
|
24439
24469
|
import * as path53 from "path";
|
|
24440
|
-
import
|
|
24470
|
+
import chalk196 from "chalk";
|
|
24441
24471
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
24442
24472
|
const source = path53.join(claudeDir, "CLAUDE.md");
|
|
24443
24473
|
const target = path53.join(targetBase, "CLAUDE.md");
|
|
@@ -24446,12 +24476,12 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24446
24476
|
const targetContent = fs37.readFileSync(target, "utf8");
|
|
24447
24477
|
if (sourceContent !== targetContent) {
|
|
24448
24478
|
console.log(
|
|
24449
|
-
|
|
24479
|
+
chalk196.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
24450
24480
|
);
|
|
24451
24481
|
console.log();
|
|
24452
24482
|
printDiff(targetContent, sourceContent);
|
|
24453
24483
|
const confirm = options2?.yes || await promptConfirm(
|
|
24454
|
-
|
|
24484
|
+
chalk196.red("Overwrite existing CLAUDE.md?"),
|
|
24455
24485
|
false
|
|
24456
24486
|
);
|
|
24457
24487
|
if (!confirm) {
|
|
@@ -24467,7 +24497,7 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24467
24497
|
// src/commands/sync/syncSettings.ts
|
|
24468
24498
|
import * as fs38 from "fs";
|
|
24469
24499
|
import * as path54 from "path";
|
|
24470
|
-
import
|
|
24500
|
+
import chalk197 from "chalk";
|
|
24471
24501
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
24472
24502
|
const source = path54.join(claudeDir, "settings.json");
|
|
24473
24503
|
const target = path54.join(targetBase, "settings.json");
|
|
@@ -24486,14 +24516,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
24486
24516
|
if (mergedContent !== normalizedTarget) {
|
|
24487
24517
|
if (!options2?.yes) {
|
|
24488
24518
|
console.log(
|
|
24489
|
-
|
|
24519
|
+
chalk197.yellow(
|
|
24490
24520
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
24491
24521
|
)
|
|
24492
24522
|
);
|
|
24493
24523
|
console.log();
|
|
24494
24524
|
printDiff(targetContent, mergedContent);
|
|
24495
24525
|
const confirm = await promptConfirm(
|
|
24496
|
-
|
|
24526
|
+
chalk197.red("Overwrite existing settings.json?"),
|
|
24497
24527
|
false
|
|
24498
24528
|
);
|
|
24499
24529
|
if (!confirm) {
|