@staff0rd/assist 0.365.0 → 0.367.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 +2 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +608 -485
- 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.367.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -963,7 +963,7 @@ function createPool() {
|
|
|
963
963
|
return pool;
|
|
964
964
|
}
|
|
965
965
|
async function initSchema(pool) {
|
|
966
|
-
await ensureSchema((
|
|
966
|
+
await ensureSchema((sql10) => pool.query(sql10));
|
|
967
967
|
const orm = makeOrmFromPool(pool);
|
|
968
968
|
await seedNewsFeeds(orm);
|
|
969
969
|
await runUsagePeakCleanup(orm);
|
|
@@ -3881,8 +3881,8 @@ async function buildDump(tables, copyOut) {
|
|
|
3881
3881
|
// src/commands/backlog/dump/copyTableOut.ts
|
|
3882
3882
|
import { to as copyTo } from "pg-copy-streams";
|
|
3883
3883
|
async function copyTableOut(client, table) {
|
|
3884
|
-
const
|
|
3885
|
-
const stream = client.query(copyTo(
|
|
3884
|
+
const sql10 = `COPY ${table.name} (${table.columns.join(", ")}) TO STDOUT`;
|
|
3885
|
+
const stream = client.query(copyTo(sql10));
|
|
3886
3886
|
const chunks = [];
|
|
3887
3887
|
for await (const chunk of stream) {
|
|
3888
3888
|
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
@@ -5000,9 +5000,10 @@ import { eq as eq7, sql as sql2 } from "drizzle-orm";
|
|
|
5000
5000
|
import { eq as eq6 } from "drizzle-orm";
|
|
5001
5001
|
|
|
5002
5002
|
// src/commands/backlog/searchItemIds.ts
|
|
5003
|
-
import { and as and3, asc as asc4, eq as eq8, ilike, or } from "drizzle-orm";
|
|
5003
|
+
import { and as and3, asc as asc4, eq as eq8, ilike, or, sql as sql3 } from "drizzle-orm";
|
|
5004
5004
|
async function searchItemIds(orm, query, origin) {
|
|
5005
5005
|
const pattern2 = `%${query}%`;
|
|
5006
|
+
const numberPattern = `%${query.replace(/^#/, "")}%`;
|
|
5006
5007
|
const rows = await orm.selectDistinct({ id: items.id }).from(items).leftJoin(comments, eq8(comments.itemId, items.id)).leftJoin(planPhases, eq8(planPhases.itemId, items.id)).where(
|
|
5007
5008
|
and3(
|
|
5008
5009
|
origin ? eq8(items.origin, origin) : void 0,
|
|
@@ -5012,7 +5013,8 @@ async function searchItemIds(orm, query, origin) {
|
|
|
5012
5013
|
ilike(items.acceptanceCriteria, pattern2),
|
|
5013
5014
|
ilike(items.jiraKey, pattern2),
|
|
5014
5015
|
ilike(comments.text, pattern2),
|
|
5015
|
-
ilike(planPhases.name, pattern2)
|
|
5016
|
+
ilike(planPhases.name, pattern2),
|
|
5017
|
+
ilike(sql3`${items.id}::text`, numberPattern)
|
|
5016
5018
|
)
|
|
5017
5019
|
)
|
|
5018
5020
|
).orderBy(asc4(items.id));
|
|
@@ -5720,11 +5722,11 @@ async function next(options2, startId) {
|
|
|
5720
5722
|
import chalk45 from "chalk";
|
|
5721
5723
|
|
|
5722
5724
|
// src/commands/backlog/appendComment.ts
|
|
5723
|
-
import { sql as
|
|
5725
|
+
import { sql as sql4 } from "drizzle-orm";
|
|
5724
5726
|
async function appendComment(orm, itemId, text9, opts = {}) {
|
|
5725
5727
|
await orm.insert(comments).values({
|
|
5726
5728
|
itemId,
|
|
5727
|
-
idx:
|
|
5729
|
+
idx: sql4`(SELECT COALESCE(MAX(${comments.idx}) + 1, 0) FROM ${comments} WHERE ${comments.itemId} = ${itemId})`,
|
|
5728
5730
|
text: text9,
|
|
5729
5731
|
phase: opts.phase ?? null,
|
|
5730
5732
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7984,8 +7986,8 @@ async function readStdinBuffer() {
|
|
|
7984
7986
|
import { finished } from "stream/promises";
|
|
7985
7987
|
import { from as copyFrom } from "pg-copy-streams";
|
|
7986
7988
|
async function copyTableIn(client, table, data) {
|
|
7987
|
-
const
|
|
7988
|
-
const stream = client.query(copyFrom(
|
|
7989
|
+
const sql10 = `COPY ${table.name} (${table.columns.join(", ")}) FROM STDIN`;
|
|
7990
|
+
const stream = client.query(copyFrom(sql10));
|
|
7989
7991
|
stream.end(data);
|
|
7990
7992
|
await finished(stream);
|
|
7991
7993
|
}
|
|
@@ -8112,11 +8114,11 @@ async function insertPhaseAt(orm, itemId, phaseIdx, name, tasks, manualChecks, c
|
|
|
8112
8114
|
}
|
|
8113
8115
|
|
|
8114
8116
|
// src/commands/backlog/insertSubtask.ts
|
|
8115
|
-
import { sql as
|
|
8117
|
+
import { sql as sql5 } from "drizzle-orm";
|
|
8116
8118
|
async function insertSubtask(orm, itemId, title, description) {
|
|
8117
8119
|
await orm.insert(itemSubtasks).values({
|
|
8118
8120
|
itemId,
|
|
8119
|
-
idx:
|
|
8121
|
+
idx: sql5`(SELECT COALESCE(MAX(${itemSubtasks.idx}) + 1, 0) FROM ${itemSubtasks} WHERE ${itemSubtasks.itemId} = ${itemId})`,
|
|
8120
8122
|
title,
|
|
8121
8123
|
description: description ?? null,
|
|
8122
8124
|
status: "todo"
|
|
@@ -8953,6 +8955,15 @@ async function addSubtask(id2, options2) {
|
|
|
8953
8955
|
process.exitCode = 1;
|
|
8954
8956
|
return;
|
|
8955
8957
|
}
|
|
8958
|
+
if (title.length > 50) {
|
|
8959
|
+
console.log(
|
|
8960
|
+
chalk91.red(
|
|
8961
|
+
"A sub-task title must be 50 characters or fewer. Use --desc for longer detail."
|
|
8962
|
+
)
|
|
8963
|
+
);
|
|
8964
|
+
process.exitCode = 1;
|
|
8965
|
+
return;
|
|
8966
|
+
}
|
|
8956
8967
|
const found = await findOneItem(id2);
|
|
8957
8968
|
if (!found) {
|
|
8958
8969
|
process.exitCode = 1;
|
|
@@ -8964,45 +8975,148 @@ async function addSubtask(id2, options2) {
|
|
|
8964
8975
|
console.log(chalk91.green(`Added sub-task to item #${id2}: ${title}`));
|
|
8965
8976
|
}
|
|
8966
8977
|
|
|
8967
|
-
// src/commands/backlog/
|
|
8978
|
+
// src/commands/backlog/editSubtask.ts
|
|
8979
|
+
import chalk93 from "chalk";
|
|
8980
|
+
|
|
8981
|
+
// src/commands/backlog/resolveSubtaskIndex.ts
|
|
8968
8982
|
import chalk92 from "chalk";
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8983
|
+
function resolveSubtaskIndex(id2, index3, item) {
|
|
8984
|
+
const position = Number.parseInt(index3, 10);
|
|
8985
|
+
const subtasks = item.subtasks ?? [];
|
|
8986
|
+
if (Number.isNaN(position) || position < 1 || position > subtasks.length) {
|
|
8972
8987
|
console.log(
|
|
8973
8988
|
chalk92.red(
|
|
8974
|
-
`
|
|
8989
|
+
`Item #${id2} has no sub-task ${index3}${subtasks.length > 0 ? ` (1-${subtasks.length})` : ""}.`
|
|
8975
8990
|
)
|
|
8976
8991
|
);
|
|
8977
8992
|
process.exitCode = 1;
|
|
8978
|
-
return;
|
|
8993
|
+
return void 0;
|
|
8979
8994
|
}
|
|
8980
|
-
|
|
8995
|
+
return position - 1;
|
|
8996
|
+
}
|
|
8997
|
+
|
|
8998
|
+
// src/commands/backlog/findSubtask.ts
|
|
8999
|
+
async function findSubtask(id2, index3) {
|
|
8981
9000
|
const found = await findOneItem(id2);
|
|
8982
9001
|
if (!found) {
|
|
9002
|
+
process.exitCode = 1;
|
|
9003
|
+
return void 0;
|
|
9004
|
+
}
|
|
9005
|
+
const idx = resolveSubtaskIndex(id2, index3, found.item);
|
|
9006
|
+
if (idx === void 0) return void 0;
|
|
9007
|
+
return { orm: found.orm, item: found.item, idx };
|
|
9008
|
+
}
|
|
9009
|
+
|
|
9010
|
+
// src/commands/backlog/updateSubtask.ts
|
|
9011
|
+
import { and as and9, eq as eq26 } from "drizzle-orm";
|
|
9012
|
+
async function updateSubtask(orm, itemId, idx, fields) {
|
|
9013
|
+
const set = {};
|
|
9014
|
+
if (fields.title !== void 0) set.title = fields.title;
|
|
9015
|
+
if (fields.description !== void 0) set.description = fields.description;
|
|
9016
|
+
if (fields.status !== void 0) set.status = fields.status;
|
|
9017
|
+
const [row] = await orm.update(itemSubtasks).set(set).where(and9(eq26(itemSubtasks.itemId, itemId), eq26(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
9018
|
+
return row?.title;
|
|
9019
|
+
}
|
|
9020
|
+
|
|
9021
|
+
// src/commands/backlog/validSubtaskStatuses.ts
|
|
9022
|
+
var validSubtaskStatuses = [
|
|
9023
|
+
"todo",
|
|
9024
|
+
"in-progress",
|
|
9025
|
+
"done"
|
|
9026
|
+
];
|
|
9027
|
+
|
|
9028
|
+
// src/commands/backlog/editSubtask.ts
|
|
9029
|
+
function buildUpdate(options2) {
|
|
9030
|
+
const fields = {};
|
|
9031
|
+
if (options2.title !== void 0) {
|
|
9032
|
+
const title = options2.title.trim();
|
|
9033
|
+
if (!title) return "A sub-task title cannot be empty (--title).";
|
|
9034
|
+
fields.title = title;
|
|
9035
|
+
}
|
|
9036
|
+
if (options2.status !== void 0) {
|
|
9037
|
+
if (!validSubtaskStatuses.includes(options2.status)) {
|
|
9038
|
+
return `Invalid status "${options2.status}". Use one of: ${validSubtaskStatuses.join(", ")}.`;
|
|
9039
|
+
}
|
|
9040
|
+
fields.status = options2.status;
|
|
9041
|
+
}
|
|
9042
|
+
if (options2.desc !== void 0) {
|
|
9043
|
+
fields.description = options2.desc === "" ? null : options2.desc.replaceAll(String.raw`\n`, "\n");
|
|
9044
|
+
}
|
|
9045
|
+
if (Object.keys(fields).length === 0) {
|
|
9046
|
+
return "Nothing to update. Provide at least one of --title, --desc, --status.";
|
|
9047
|
+
}
|
|
9048
|
+
return fields;
|
|
9049
|
+
}
|
|
9050
|
+
async function editSubtask(id2, index3, options2) {
|
|
9051
|
+
const found = await findSubtask(id2, index3);
|
|
9052
|
+
if (!found) return;
|
|
9053
|
+
const fields = buildUpdate(options2);
|
|
9054
|
+
if (typeof fields === "string") {
|
|
9055
|
+
console.log(chalk93.red(fields));
|
|
8983
9056
|
process.exitCode = 1;
|
|
8984
9057
|
return;
|
|
8985
9058
|
}
|
|
8986
|
-
const { orm, item } = found;
|
|
8987
|
-
const
|
|
8988
|
-
|
|
9059
|
+
const { orm, item, idx } = found;
|
|
9060
|
+
const title = await updateSubtask(orm, item.id, idx, fields);
|
|
9061
|
+
console.log(
|
|
9062
|
+
chalk93.green(`Updated sub-task ${idx + 1} of item #${id2}: ${title}`)
|
|
9063
|
+
);
|
|
9064
|
+
}
|
|
9065
|
+
|
|
9066
|
+
// src/commands/backlog/removeSubtask.ts
|
|
9067
|
+
import chalk94 from "chalk";
|
|
9068
|
+
|
|
9069
|
+
// src/commands/backlog/deleteSubtask.ts
|
|
9070
|
+
import { and as and10, asc as asc6, eq as eq27 } from "drizzle-orm";
|
|
9071
|
+
async function deleteSubtask(orm, itemId, idx) {
|
|
9072
|
+
const [row] = await orm.delete(itemSubtasks).where(and10(eq27(itemSubtasks.itemId, itemId), eq27(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
9073
|
+
if (!row) return void 0;
|
|
9074
|
+
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq27(itemSubtasks.itemId, itemId)).orderBy(asc6(itemSubtasks.idx));
|
|
9075
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
9076
|
+
const oldIdx = remaining[i].idx;
|
|
9077
|
+
if (oldIdx === i) continue;
|
|
9078
|
+
await orm.update(itemSubtasks).set({ idx: i }).where(
|
|
9079
|
+
and10(eq27(itemSubtasks.itemId, itemId), eq27(itemSubtasks.idx, oldIdx))
|
|
9080
|
+
);
|
|
9081
|
+
}
|
|
9082
|
+
return row.title;
|
|
9083
|
+
}
|
|
9084
|
+
|
|
9085
|
+
// src/commands/backlog/removeSubtask.ts
|
|
9086
|
+
async function removeSubtask(id2, index3) {
|
|
9087
|
+
const found = await findSubtask(id2, index3);
|
|
9088
|
+
if (!found) return;
|
|
9089
|
+
const { orm, item, idx } = found;
|
|
9090
|
+
const title = await deleteSubtask(orm, item.id, idx);
|
|
9091
|
+
console.log(
|
|
9092
|
+
chalk94.green(`Removed sub-task ${idx + 1} of item #${id2}: ${title}`)
|
|
9093
|
+
);
|
|
9094
|
+
}
|
|
9095
|
+
|
|
9096
|
+
// src/commands/backlog/subtaskStatus.ts
|
|
9097
|
+
import chalk95 from "chalk";
|
|
9098
|
+
async function subtaskStatus(id2, index3, status2) {
|
|
9099
|
+
if (!validSubtaskStatuses.includes(status2)) {
|
|
8989
9100
|
console.log(
|
|
8990
|
-
|
|
8991
|
-
`
|
|
9101
|
+
chalk95.red(
|
|
9102
|
+
`Invalid status "${status2}". Use one of: ${validSubtaskStatuses.join(", ")}.`
|
|
8992
9103
|
)
|
|
8993
9104
|
);
|
|
8994
9105
|
process.exitCode = 1;
|
|
8995
9106
|
return;
|
|
8996
9107
|
}
|
|
9108
|
+
const found = await findSubtask(id2, index3);
|
|
9109
|
+
if (!found) return;
|
|
9110
|
+
const { orm, item, idx } = found;
|
|
8997
9111
|
const title = await updateSubtaskStatus(
|
|
8998
9112
|
orm,
|
|
8999
9113
|
item.id,
|
|
9000
|
-
|
|
9114
|
+
idx,
|
|
9001
9115
|
status2
|
|
9002
9116
|
);
|
|
9003
9117
|
console.log(
|
|
9004
|
-
|
|
9005
|
-
`Set sub-task ${
|
|
9118
|
+
chalk95.green(
|
|
9119
|
+
`Set sub-task ${idx + 1} of item #${id2} to ${status2}: ${title}`
|
|
9006
9120
|
)
|
|
9007
9121
|
);
|
|
9008
9122
|
}
|
|
@@ -9013,27 +9127,36 @@ function registerSubtaskCommands(cmd) {
|
|
|
9013
9127
|
"--desc <description>",
|
|
9014
9128
|
String.raw`Sub-task description (Markdown supported; use \n for line breaks)`
|
|
9015
9129
|
).action(addSubtask);
|
|
9130
|
+
cmd.command("edit-subtask <id> <idx>").description(
|
|
9131
|
+
"Edit a sub-task's title, description, and/or status by its 1-based index"
|
|
9132
|
+
).option("--title <title>", "New sub-task title").option(
|
|
9133
|
+
"--desc <description>",
|
|
9134
|
+
String.raw`New sub-task description (Markdown supported; use \n for line breaks; pass "" to clear)`
|
|
9135
|
+
).option("--status <status>", "New status (todo, in-progress, done)").action(editSubtask);
|
|
9136
|
+
cmd.command("remove-subtask <id> <idx>").description(
|
|
9137
|
+
"Remove a sub-task by its 1-based index and re-index the remaining sub-tasks"
|
|
9138
|
+
).action(removeSubtask);
|
|
9016
9139
|
cmd.command("subtask-status <id> <idx> <status>").description(
|
|
9017
9140
|
"Set a sub-task's status (todo, in-progress, done) by its 1-based index"
|
|
9018
9141
|
).action(subtaskStatus);
|
|
9019
9142
|
}
|
|
9020
9143
|
|
|
9021
9144
|
// src/commands/backlog/movePhase.ts
|
|
9022
|
-
import
|
|
9023
|
-
import { count as count6, eq as
|
|
9145
|
+
import chalk96 from "chalk";
|
|
9146
|
+
import { count as count6, eq as eq30 } from "drizzle-orm";
|
|
9024
9147
|
|
|
9025
9148
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
9026
|
-
import { and as
|
|
9149
|
+
import { and as and12, asc as asc8, eq as eq29 } from "drizzle-orm";
|
|
9027
9150
|
|
|
9028
9151
|
// src/commands/backlog/reindexPhases.ts
|
|
9029
|
-
import { and as
|
|
9152
|
+
import { and as and11, asc as asc7, count as count5, eq as eq28 } from "drizzle-orm";
|
|
9030
9153
|
async function reindexPhases(db, itemId) {
|
|
9031
|
-
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
9154
|
+
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq28(planPhases.itemId, itemId)).orderBy(asc7(planPhases.idx));
|
|
9032
9155
|
for (let i = 0; i < remaining.length; i++) {
|
|
9033
9156
|
const oldIdx = remaining[i].idx;
|
|
9034
9157
|
if (oldIdx === i) continue;
|
|
9035
|
-
await db.update(planTasks).set({ phaseIdx: i }).where(
|
|
9036
|
-
await db.update(planPhases).set({ idx: i }).where(
|
|
9158
|
+
await db.update(planTasks).set({ phaseIdx: i }).where(and11(eq28(planTasks.itemId, itemId), eq28(planTasks.phaseIdx, oldIdx)));
|
|
9159
|
+
await db.update(planPhases).set({ idx: i }).where(and11(eq28(planPhases.itemId, itemId), eq28(planPhases.idx, oldIdx)));
|
|
9037
9160
|
}
|
|
9038
9161
|
}
|
|
9039
9162
|
async function adjustCurrentPhase(db, item, removedIdx) {
|
|
@@ -9041,24 +9164,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
9041
9164
|
if (currentPhase === void 0) return;
|
|
9042
9165
|
const currentIdx = currentPhase - 1;
|
|
9043
9166
|
if (removedIdx < currentIdx) {
|
|
9044
|
-
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(
|
|
9167
|
+
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq28(items.id, item.id));
|
|
9045
9168
|
return;
|
|
9046
9169
|
}
|
|
9047
9170
|
if (removedIdx !== currentIdx) return;
|
|
9048
|
-
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(
|
|
9171
|
+
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(eq28(planPhases.itemId, item.id));
|
|
9049
9172
|
const cnt = row?.cnt ?? 0;
|
|
9050
|
-
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(
|
|
9173
|
+
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq28(items.id, item.id));
|
|
9051
9174
|
}
|
|
9052
9175
|
|
|
9053
9176
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
9054
9177
|
async function reorderPhaseRows(orm, itemId, fromIdx, toIdx) {
|
|
9055
9178
|
await orm.transaction(async (tx) => {
|
|
9056
|
-
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(
|
|
9057
|
-
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(
|
|
9179
|
+
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and12(eq29(planPhases.itemId, itemId), eq29(planPhases.idx, fromIdx)));
|
|
9180
|
+
const tasks = await tx.select({ idx: planTasks.idx, task: planTasks.task }).from(planTasks).where(and12(eq29(planTasks.itemId, itemId), eq29(planTasks.phaseIdx, fromIdx))).orderBy(asc8(planTasks.idx));
|
|
9058
9181
|
await tx.delete(planTasks).where(
|
|
9059
|
-
|
|
9182
|
+
and12(eq29(planTasks.itemId, itemId), eq29(planTasks.phaseIdx, fromIdx))
|
|
9060
9183
|
);
|
|
9061
|
-
await tx.delete(planPhases).where(
|
|
9184
|
+
await tx.delete(planPhases).where(and12(eq29(planPhases.itemId, itemId), eq29(planPhases.idx, fromIdx)));
|
|
9062
9185
|
await reindexPhases(tx, itemId);
|
|
9063
9186
|
await shiftPhasesUp(tx, itemId, toIdx);
|
|
9064
9187
|
await tx.insert(planPhases).values({
|
|
@@ -9085,7 +9208,7 @@ function toIndex(value, phaseCount) {
|
|
|
9085
9208
|
const pos = Number.parseInt(value, 10);
|
|
9086
9209
|
if (Number.isNaN(pos) || pos < 1 || pos > phaseCount) {
|
|
9087
9210
|
console.log(
|
|
9088
|
-
|
|
9211
|
+
chalk96.red(
|
|
9089
9212
|
`Position "${value}" is out of range. Must be between 1 and ${phaseCount}.`
|
|
9090
9213
|
)
|
|
9091
9214
|
);
|
|
@@ -9099,7 +9222,7 @@ async function movePhase(id2, from, to) {
|
|
|
9099
9222
|
if (!found) return;
|
|
9100
9223
|
const { orm, item } = found;
|
|
9101
9224
|
const itemId = item.id;
|
|
9102
|
-
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(
|
|
9225
|
+
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(eq30(planPhases.itemId, itemId));
|
|
9103
9226
|
const phaseCount = row?.cnt ?? 0;
|
|
9104
9227
|
const fromIdx = toIndex(from, phaseCount);
|
|
9105
9228
|
if (fromIdx === void 0) return;
|
|
@@ -9108,29 +9231,29 @@ async function movePhase(id2, from, to) {
|
|
|
9108
9231
|
if (fromIdx !== toIdx) {
|
|
9109
9232
|
await reorderPhaseRows(orm, itemId, fromIdx, toIdx);
|
|
9110
9233
|
}
|
|
9111
|
-
console.log(
|
|
9234
|
+
console.log(chalk96.green(`Moved phase ${from} to position ${to}.`));
|
|
9112
9235
|
}
|
|
9113
9236
|
|
|
9114
9237
|
// src/commands/backlog/updatePhase.ts
|
|
9115
|
-
import
|
|
9238
|
+
import chalk98 from "chalk";
|
|
9116
9239
|
|
|
9117
9240
|
// src/commands/backlog/applyPhaseUpdate.ts
|
|
9118
|
-
import { and as
|
|
9241
|
+
import { and as and13, eq as eq31 } from "drizzle-orm";
|
|
9119
9242
|
async function applyPhaseUpdate(orm, itemId, phaseIdx, fields) {
|
|
9120
9243
|
await orm.transaction(async (tx) => {
|
|
9121
9244
|
if (fields.name) {
|
|
9122
9245
|
await tx.update(planPhases).set({ name: fields.name }).where(
|
|
9123
|
-
|
|
9246
|
+
and13(eq31(planPhases.itemId, itemId), eq31(planPhases.idx, phaseIdx))
|
|
9124
9247
|
);
|
|
9125
9248
|
}
|
|
9126
9249
|
if (fields.manualCheck) {
|
|
9127
9250
|
await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
|
|
9128
|
-
|
|
9251
|
+
and13(eq31(planPhases.itemId, itemId), eq31(planPhases.idx, phaseIdx))
|
|
9129
9252
|
);
|
|
9130
9253
|
}
|
|
9131
9254
|
if (fields.task) {
|
|
9132
9255
|
await tx.delete(planTasks).where(
|
|
9133
|
-
|
|
9256
|
+
and13(eq31(planTasks.itemId, itemId), eq31(planTasks.phaseIdx, phaseIdx))
|
|
9134
9257
|
);
|
|
9135
9258
|
if (fields.task.length) {
|
|
9136
9259
|
await tx.insert(planTasks).values(
|
|
@@ -9147,18 +9270,18 @@ async function applyPhaseUpdate(orm, itemId, phaseIdx, fields) {
|
|
|
9147
9270
|
}
|
|
9148
9271
|
|
|
9149
9272
|
// src/commands/backlog/findPhase.ts
|
|
9150
|
-
import
|
|
9151
|
-
import { and as
|
|
9273
|
+
import chalk97 from "chalk";
|
|
9274
|
+
import { and as and14, count as count7, eq as eq32 } from "drizzle-orm";
|
|
9152
9275
|
async function findPhase(id2, phase) {
|
|
9153
9276
|
const found = await findOneItem(id2);
|
|
9154
9277
|
if (!found) return void 0;
|
|
9155
9278
|
const { orm, item } = found;
|
|
9156
9279
|
const itemId = item.id;
|
|
9157
9280
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
9158
|
-
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(
|
|
9281
|
+
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and14(eq32(planPhases.itemId, itemId), eq32(planPhases.idx, phaseIdx)));
|
|
9159
9282
|
if (!row || row.cnt === 0) {
|
|
9160
9283
|
console.log(
|
|
9161
|
-
|
|
9284
|
+
chalk97.red(`Phase ${phaseIdx + 1} not found on item #${itemId}.`)
|
|
9162
9285
|
);
|
|
9163
9286
|
process.exitCode = 1;
|
|
9164
9287
|
return void 0;
|
|
@@ -9290,7 +9413,7 @@ async function updatePhase(id2, phase, options2) {
|
|
|
9290
9413
|
const { item, orm, itemId, phaseIdx } = found;
|
|
9291
9414
|
const resolved = resolvePhaseFields(options2, item.plan?.[phaseIdx]);
|
|
9292
9415
|
if (!resolved.ok) {
|
|
9293
|
-
console.log(
|
|
9416
|
+
console.log(chalk98.red(resolved.error));
|
|
9294
9417
|
process.exitCode = 1;
|
|
9295
9418
|
return;
|
|
9296
9419
|
}
|
|
@@ -9302,7 +9425,7 @@ async function updatePhase(id2, phase, options2) {
|
|
|
9302
9425
|
manualCheck && "manual checks"
|
|
9303
9426
|
].filter(Boolean).join(", ");
|
|
9304
9427
|
console.log(
|
|
9305
|
-
|
|
9428
|
+
chalk98.green(
|
|
9306
9429
|
`Updated ${fields} on phase ${phaseIdx + 1} of item #${itemId}.`
|
|
9307
9430
|
)
|
|
9308
9431
|
);
|
|
@@ -9325,28 +9448,28 @@ function registerUpdatePhaseCommand(cmd) {
|
|
|
9325
9448
|
}
|
|
9326
9449
|
|
|
9327
9450
|
// src/commands/backlog/removePhase.ts
|
|
9328
|
-
import
|
|
9329
|
-
import { and as
|
|
9451
|
+
import chalk99 from "chalk";
|
|
9452
|
+
import { and as and15, eq as eq33 } from "drizzle-orm";
|
|
9330
9453
|
async function removePhase(id2, phase) {
|
|
9331
9454
|
const found = await findPhase(id2, phase);
|
|
9332
9455
|
if (!found) return;
|
|
9333
9456
|
const { item, orm, itemId, phaseIdx } = found;
|
|
9334
9457
|
await orm.transaction(async (tx) => {
|
|
9335
9458
|
await tx.delete(planTasks).where(
|
|
9336
|
-
|
|
9459
|
+
and15(eq33(planTasks.itemId, itemId), eq33(planTasks.phaseIdx, phaseIdx))
|
|
9337
9460
|
);
|
|
9338
|
-
await tx.delete(planPhases).where(
|
|
9461
|
+
await tx.delete(planPhases).where(and15(eq33(planPhases.itemId, itemId), eq33(planPhases.idx, phaseIdx)));
|
|
9339
9462
|
await reindexPhases(tx, itemId);
|
|
9340
9463
|
await adjustCurrentPhase(tx, item, phaseIdx);
|
|
9341
9464
|
});
|
|
9342
9465
|
console.log(
|
|
9343
|
-
|
|
9466
|
+
chalk99.green(`Removed phase ${phaseIdx + 1} from item #${itemId}.`)
|
|
9344
9467
|
);
|
|
9345
9468
|
}
|
|
9346
9469
|
|
|
9347
9470
|
// src/commands/backlog/update/index.ts
|
|
9348
|
-
import
|
|
9349
|
-
import { eq as
|
|
9471
|
+
import chalk101 from "chalk";
|
|
9472
|
+
import { eq as eq34 } from "drizzle-orm";
|
|
9350
9473
|
|
|
9351
9474
|
// src/commands/backlog/update/applyAcMutations.ts
|
|
9352
9475
|
function hasAcMutations(options2) {
|
|
@@ -9367,16 +9490,16 @@ function applyAcMutations(current, options2) {
|
|
|
9367
9490
|
}
|
|
9368
9491
|
|
|
9369
9492
|
// src/commands/backlog/update/buildUpdateValues.ts
|
|
9370
|
-
import
|
|
9493
|
+
import chalk100 from "chalk";
|
|
9371
9494
|
function buildUpdateValues(options2) {
|
|
9372
9495
|
const { name, desc: desc6, type, ac } = options2;
|
|
9373
9496
|
if (!name && !desc6 && !type && !ac) {
|
|
9374
|
-
console.log(
|
|
9497
|
+
console.log(chalk100.red("Nothing to update. Provide at least one flag."));
|
|
9375
9498
|
process.exitCode = 1;
|
|
9376
9499
|
return void 0;
|
|
9377
9500
|
}
|
|
9378
9501
|
if (type && type !== "story" && type !== "bug") {
|
|
9379
|
-
console.log(
|
|
9502
|
+
console.log(chalk100.red('Invalid type. Must be "story" or "bug".'));
|
|
9380
9503
|
process.exitCode = 1;
|
|
9381
9504
|
return void 0;
|
|
9382
9505
|
}
|
|
@@ -9409,14 +9532,14 @@ async function update(id2, options2) {
|
|
|
9409
9532
|
if (hasAcMutations(options2)) {
|
|
9410
9533
|
if (options2.ac) {
|
|
9411
9534
|
console.log(
|
|
9412
|
-
|
|
9535
|
+
chalk101.red("Cannot combine --ac with --add-ac/--edit-ac/--remove-ac.")
|
|
9413
9536
|
);
|
|
9414
9537
|
process.exitCode = 1;
|
|
9415
9538
|
return;
|
|
9416
9539
|
}
|
|
9417
9540
|
const mutation = applyAcMutations(found.item.acceptanceCriteria, options2);
|
|
9418
9541
|
if (!mutation.ok) {
|
|
9419
|
-
console.log(
|
|
9542
|
+
console.log(chalk101.red(mutation.error));
|
|
9420
9543
|
process.exitCode = 1;
|
|
9421
9544
|
return;
|
|
9422
9545
|
}
|
|
@@ -9426,8 +9549,8 @@ async function update(id2, options2) {
|
|
|
9426
9549
|
if (!built) return;
|
|
9427
9550
|
const { orm } = found;
|
|
9428
9551
|
const itemId = found.item.id;
|
|
9429
|
-
await orm.update(items).set(built.set).where(
|
|
9430
|
-
console.log(
|
|
9552
|
+
await orm.update(items).set(built.set).where(eq34(items.id, itemId));
|
|
9553
|
+
console.log(chalk101.green(`Updated ${built.fields} on item #${itemId}.`));
|
|
9431
9554
|
}
|
|
9432
9555
|
|
|
9433
9556
|
// src/commands/backlog/registerUpdateCommands.ts
|
|
@@ -10229,11 +10352,11 @@ function assertCliExists(cli) {
|
|
|
10229
10352
|
}
|
|
10230
10353
|
|
|
10231
10354
|
// src/commands/permitCliReads/colorize.ts
|
|
10232
|
-
import
|
|
10355
|
+
import chalk102 from "chalk";
|
|
10233
10356
|
function colorize(plainOutput) {
|
|
10234
10357
|
return plainOutput.split("\n").map((line) => {
|
|
10235
|
-
if (line.startsWith(" R ")) return
|
|
10236
|
-
if (line.startsWith(" W ")) return
|
|
10358
|
+
if (line.startsWith(" R ")) return chalk102.green(line);
|
|
10359
|
+
if (line.startsWith(" W ")) return chalk102.red(line);
|
|
10237
10360
|
return line;
|
|
10238
10361
|
}).join("\n");
|
|
10239
10362
|
}
|
|
@@ -10531,7 +10654,7 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
10531
10654
|
}
|
|
10532
10655
|
|
|
10533
10656
|
// src/commands/deny/denyAdd.ts
|
|
10534
|
-
import
|
|
10657
|
+
import chalk103 from "chalk";
|
|
10535
10658
|
|
|
10536
10659
|
// src/commands/deny/loadDenyConfig.ts
|
|
10537
10660
|
function loadDenyConfig(global) {
|
|
@@ -10551,16 +10674,16 @@ function loadDenyConfig(global) {
|
|
|
10551
10674
|
function denyAdd(pattern2, message, options2) {
|
|
10552
10675
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
10553
10676
|
if (deny.some((r) => r.pattern === pattern2)) {
|
|
10554
|
-
console.log(
|
|
10677
|
+
console.log(chalk103.yellow(`Deny rule already exists for: ${pattern2}`));
|
|
10555
10678
|
return;
|
|
10556
10679
|
}
|
|
10557
10680
|
deny.push({ pattern: pattern2, message });
|
|
10558
10681
|
saveDeny(deny);
|
|
10559
|
-
console.log(
|
|
10682
|
+
console.log(chalk103.green(`Added deny rule: ${pattern2} \u2192 ${message}`));
|
|
10560
10683
|
}
|
|
10561
10684
|
|
|
10562
10685
|
// src/commands/deny/denyList.ts
|
|
10563
|
-
import
|
|
10686
|
+
import chalk104 from "chalk";
|
|
10564
10687
|
function denyList() {
|
|
10565
10688
|
const globalRaw = loadGlobalConfigRaw();
|
|
10566
10689
|
const projectRaw = loadProjectConfig();
|
|
@@ -10571,7 +10694,7 @@ function denyList() {
|
|
|
10571
10694
|
projectDeny.length > 0 ? projectDeny : void 0
|
|
10572
10695
|
);
|
|
10573
10696
|
if (!merged || merged.length === 0) {
|
|
10574
|
-
console.log(
|
|
10697
|
+
console.log(chalk104.dim("No deny rules configured."));
|
|
10575
10698
|
return;
|
|
10576
10699
|
}
|
|
10577
10700
|
const projectPatterns = new Set(projectDeny.map((r) => r.pattern));
|
|
@@ -10579,23 +10702,23 @@ function denyList() {
|
|
|
10579
10702
|
for (const rule of merged) {
|
|
10580
10703
|
const inProject = projectPatterns.has(rule.pattern);
|
|
10581
10704
|
const inGlobal = globalPatterns.has(rule.pattern);
|
|
10582
|
-
const label2 = inProject && inGlobal ?
|
|
10583
|
-
console.log(`${
|
|
10705
|
+
const label2 = inProject && inGlobal ? chalk104.dim(" (project, overrides global)") : inGlobal ? chalk104.dim(" (global)") : "";
|
|
10706
|
+
console.log(`${chalk104.red(rule.pattern)} \u2192 ${rule.message}${label2}`);
|
|
10584
10707
|
}
|
|
10585
10708
|
}
|
|
10586
10709
|
|
|
10587
10710
|
// src/commands/deny/denyRemove.ts
|
|
10588
|
-
import
|
|
10711
|
+
import chalk105 from "chalk";
|
|
10589
10712
|
function denyRemove(pattern2, options2) {
|
|
10590
10713
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
10591
10714
|
const index3 = deny.findIndex((r) => r.pattern === pattern2);
|
|
10592
10715
|
if (index3 === -1) {
|
|
10593
|
-
console.log(
|
|
10716
|
+
console.log(chalk105.yellow(`No deny rule found for: ${pattern2}`));
|
|
10594
10717
|
return;
|
|
10595
10718
|
}
|
|
10596
10719
|
deny.splice(index3, 1);
|
|
10597
10720
|
saveDeny(deny.length > 0 ? deny : void 0);
|
|
10598
|
-
console.log(
|
|
10721
|
+
console.log(chalk105.green(`Removed deny rule: ${pattern2}`));
|
|
10599
10722
|
}
|
|
10600
10723
|
|
|
10601
10724
|
// src/commands/registerDeny.ts
|
|
@@ -10625,7 +10748,7 @@ function registerCliHook(program2) {
|
|
|
10625
10748
|
|
|
10626
10749
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
10627
10750
|
import { existsSync as existsSync30, readFileSync as readFileSync25, unlinkSync as unlinkSync8, writeFileSync as writeFileSync23 } from "fs";
|
|
10628
|
-
import
|
|
10751
|
+
import chalk106 from "chalk";
|
|
10629
10752
|
|
|
10630
10753
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
10631
10754
|
import { homedir as homedir14 } from "os";
|
|
@@ -10678,12 +10801,12 @@ function codeCommentConfirm(pin) {
|
|
|
10678
10801
|
sweepRestrictedDir();
|
|
10679
10802
|
const state = readPinState(pin);
|
|
10680
10803
|
if (!state) {
|
|
10681
|
-
console.error(
|
|
10804
|
+
console.error(chalk106.red(`No pending comment for pin: ${pin}`));
|
|
10682
10805
|
process.exitCode = 1;
|
|
10683
10806
|
return;
|
|
10684
10807
|
}
|
|
10685
10808
|
if (!existsSync30(state.file)) {
|
|
10686
|
-
console.error(
|
|
10809
|
+
console.error(chalk106.red(`Target file no longer exists: ${state.file}`));
|
|
10687
10810
|
process.exitCode = 1;
|
|
10688
10811
|
return;
|
|
10689
10812
|
}
|
|
@@ -10692,7 +10815,7 @@ function codeCommentConfirm(pin) {
|
|
|
10692
10815
|
const index3 = state.line - 1;
|
|
10693
10816
|
if (index3 > lines.length) {
|
|
10694
10817
|
console.error(
|
|
10695
|
-
|
|
10818
|
+
chalk106.red(
|
|
10696
10819
|
`Line ${state.line} is beyond the end of ${state.file} (${lines.length} lines).`
|
|
10697
10820
|
)
|
|
10698
10821
|
);
|
|
@@ -10706,14 +10829,14 @@ function codeCommentConfirm(pin) {
|
|
|
10706
10829
|
writeFileSync23(state.file, lines.join("\n"));
|
|
10707
10830
|
unlinkSync8(getPinStatePath(pin));
|
|
10708
10831
|
console.log(
|
|
10709
|
-
|
|
10832
|
+
chalk106.green(
|
|
10710
10833
|
`Inserted "${marker} ${state.text}" at ${state.file}:${state.line}`
|
|
10711
10834
|
)
|
|
10712
10835
|
);
|
|
10713
10836
|
}
|
|
10714
10837
|
|
|
10715
10838
|
// src/commands/codeComment/codeCommentSet.ts
|
|
10716
|
-
import
|
|
10839
|
+
import chalk107 from "chalk";
|
|
10717
10840
|
|
|
10718
10841
|
// src/commands/codeComment/validateCommentText.ts
|
|
10719
10842
|
var MAX_COMMENT_LENGTH = 50;
|
|
@@ -10764,27 +10887,27 @@ function generatePin() {
|
|
|
10764
10887
|
function codeCommentSet(file, line, text9) {
|
|
10765
10888
|
const lineNumber = Number.parseInt(line, 10);
|
|
10766
10889
|
if (!Number.isInteger(lineNumber) || lineNumber < 1) {
|
|
10767
|
-
console.error(
|
|
10890
|
+
console.error(chalk107.red(`Invalid line number: ${line}`));
|
|
10768
10891
|
process.exitCode = 1;
|
|
10769
10892
|
return;
|
|
10770
10893
|
}
|
|
10771
10894
|
const marker = isYamlFile(file) ? "#" : "//";
|
|
10772
10895
|
const validation = validateCommentText(text9, isYamlFile(file));
|
|
10773
10896
|
if (!validation.ok) {
|
|
10774
|
-
console.error(
|
|
10775
|
-
console.error(
|
|
10897
|
+
console.error(chalk107.red(`Refused: ${validation.reason}`));
|
|
10898
|
+
console.error(chalk107.red("No pin issued."));
|
|
10776
10899
|
process.exitCode = 1;
|
|
10777
10900
|
return;
|
|
10778
10901
|
}
|
|
10779
10902
|
console.error(
|
|
10780
|
-
|
|
10903
|
+
chalk107.yellow.bold(
|
|
10781
10904
|
"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."
|
|
10782
10905
|
)
|
|
10783
10906
|
);
|
|
10784
10907
|
const delivered = issuePin(file, lineNumber, validation.text);
|
|
10785
10908
|
if (!delivered) {
|
|
10786
10909
|
console.error(
|
|
10787
|
-
|
|
10910
|
+
chalk107.red(
|
|
10788
10911
|
"Could not deliver the confirmation pin via notification.\nThe comment cannot be confirmed until the notification channel works."
|
|
10789
10912
|
)
|
|
10790
10913
|
);
|
|
@@ -10794,7 +10917,7 @@ function codeCommentSet(file, line, text9) {
|
|
|
10794
10917
|
console.log(
|
|
10795
10918
|
`A confirmation pin was sent to your desktop notifications.
|
|
10796
10919
|
To insert "${marker} ${validation.text}" at ${file}:${lineNumber}, run:
|
|
10797
|
-
${
|
|
10920
|
+
${chalk107.cyan(" assist code-comment confirm <PIN>")}
|
|
10798
10921
|
using the pin from that notification.`
|
|
10799
10922
|
);
|
|
10800
10923
|
}
|
|
@@ -10814,15 +10937,15 @@ function registerCodeComment(parent) {
|
|
|
10814
10937
|
}
|
|
10815
10938
|
|
|
10816
10939
|
// src/commands/complexity/analyze.ts
|
|
10817
|
-
import
|
|
10940
|
+
import chalk116 from "chalk";
|
|
10818
10941
|
|
|
10819
10942
|
// src/commands/complexity/cyclomatic.ts
|
|
10820
|
-
import
|
|
10943
|
+
import chalk109 from "chalk";
|
|
10821
10944
|
|
|
10822
10945
|
// src/commands/complexity/shared/index.ts
|
|
10823
10946
|
import fs17 from "fs";
|
|
10824
10947
|
import path21 from "path";
|
|
10825
|
-
import
|
|
10948
|
+
import chalk108 from "chalk";
|
|
10826
10949
|
import ts5 from "typescript";
|
|
10827
10950
|
|
|
10828
10951
|
// src/commands/complexity/findSourceFiles.ts
|
|
@@ -11073,7 +11196,7 @@ function createSourceFromFile(filePath) {
|
|
|
11073
11196
|
function withSourceFiles(pattern2, callback, extraIgnore = []) {
|
|
11074
11197
|
const files = findSourceFiles2(pattern2, ".", extraIgnore);
|
|
11075
11198
|
if (files.length === 0) {
|
|
11076
|
-
console.log(
|
|
11199
|
+
console.log(chalk108.yellow("No files found matching pattern"));
|
|
11077
11200
|
return void 0;
|
|
11078
11201
|
}
|
|
11079
11202
|
return callback(files);
|
|
@@ -11106,11 +11229,11 @@ async function cyclomatic(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11106
11229
|
results.sort((a, b) => b.complexity - a.complexity);
|
|
11107
11230
|
for (const { file, name, complexity } of results) {
|
|
11108
11231
|
const exceedsThreshold = options2.threshold !== void 0 && complexity > options2.threshold;
|
|
11109
|
-
const color = exceedsThreshold ?
|
|
11110
|
-
console.log(`${color(`${file}:${name}`)} \u2192 ${
|
|
11232
|
+
const color = exceedsThreshold ? chalk109.red : chalk109.white;
|
|
11233
|
+
console.log(`${color(`${file}:${name}`)} \u2192 ${chalk109.cyan(complexity)}`);
|
|
11111
11234
|
}
|
|
11112
11235
|
console.log(
|
|
11113
|
-
|
|
11236
|
+
chalk109.dim(
|
|
11114
11237
|
`
|
|
11115
11238
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
11116
11239
|
)
|
|
@@ -11122,7 +11245,7 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
11122
11245
|
}
|
|
11123
11246
|
|
|
11124
11247
|
// src/commands/complexity/halstead.ts
|
|
11125
|
-
import
|
|
11248
|
+
import chalk110 from "chalk";
|
|
11126
11249
|
async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
11127
11250
|
withSourceFiles(pattern2, (files) => {
|
|
11128
11251
|
const results = [];
|
|
@@ -11137,13 +11260,13 @@ async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11137
11260
|
results.sort((a, b) => b.metrics.effort - a.metrics.effort);
|
|
11138
11261
|
for (const { file, name, metrics } of results) {
|
|
11139
11262
|
const exceedsThreshold = options2.threshold !== void 0 && metrics.volume > options2.threshold;
|
|
11140
|
-
const color = exceedsThreshold ?
|
|
11263
|
+
const color = exceedsThreshold ? chalk110.red : chalk110.white;
|
|
11141
11264
|
console.log(
|
|
11142
|
-
`${color(`${file}:${name}`)} \u2192 volume: ${
|
|
11265
|
+
`${color(`${file}:${name}`)} \u2192 volume: ${chalk110.cyan(metrics.volume.toFixed(1))}, difficulty: ${chalk110.yellow(metrics.difficulty.toFixed(1))}, effort: ${chalk110.magenta(metrics.effort.toFixed(1))}`
|
|
11143
11266
|
);
|
|
11144
11267
|
}
|
|
11145
11268
|
console.log(
|
|
11146
|
-
|
|
11269
|
+
chalk110.dim(
|
|
11147
11270
|
`
|
|
11148
11271
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
11149
11272
|
)
|
|
@@ -11155,27 +11278,27 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
11155
11278
|
}
|
|
11156
11279
|
|
|
11157
11280
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
11158
|
-
import
|
|
11281
|
+
import chalk113 from "chalk";
|
|
11159
11282
|
|
|
11160
11283
|
// src/commands/complexity/maintainability/formatResultLine.ts
|
|
11161
|
-
import
|
|
11284
|
+
import chalk111 from "chalk";
|
|
11162
11285
|
function formatResultLine(entry, failing) {
|
|
11163
11286
|
const { file, avgMaintainability, minMaintainability, override } = entry;
|
|
11164
|
-
const name = failing ?
|
|
11165
|
-
const suffix = override !== void 0 ?
|
|
11166
|
-
return `${name} \u2192 avg: ${
|
|
11287
|
+
const name = failing ? chalk111.red(file) : chalk111.white(file);
|
|
11288
|
+
const suffix = override !== void 0 ? chalk111.magenta(` (override: ${override})`) : "";
|
|
11289
|
+
return `${name} \u2192 avg: ${chalk111.cyan(avgMaintainability.toFixed(1))}, min: ${chalk111.yellow(minMaintainability.toFixed(1))}${suffix}`;
|
|
11167
11290
|
}
|
|
11168
11291
|
|
|
11169
11292
|
// src/commands/complexity/maintainability/printMaintainabilityFailure.ts
|
|
11170
|
-
import
|
|
11293
|
+
import chalk112 from "chalk";
|
|
11171
11294
|
function printMaintainabilityFailure(failingCount, threshold) {
|
|
11172
11295
|
const thresholdLabel = threshold !== void 0 ? ` ${threshold}` : "";
|
|
11173
11296
|
console.error(
|
|
11174
|
-
|
|
11297
|
+
chalk112.red(
|
|
11175
11298
|
`
|
|
11176
11299
|
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.
|
|
11177
11300
|
|
|
11178
|
-
\u26A0\uFE0F ${
|
|
11301
|
+
\u26A0\uFE0F ${chalk112.bold("Diagnose and fix one file at a time")} \u2014 do not investigate or fix multiple files in parallel.
|
|
11179
11302
|
|
|
11180
11303
|
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.`
|
|
11181
11304
|
)
|
|
@@ -11187,7 +11310,7 @@ function displayMaintainabilityResults(results, threshold) {
|
|
|
11187
11310
|
const gating = threshold !== void 0 || results.some((r) => r.override !== void 0);
|
|
11188
11311
|
if (!gating) {
|
|
11189
11312
|
for (const entry of results) console.log(formatResultLine(entry, false));
|
|
11190
|
-
console.log(
|
|
11313
|
+
console.log(chalk113.dim(`
|
|
11191
11314
|
Analyzed ${results.length} files`));
|
|
11192
11315
|
return;
|
|
11193
11316
|
}
|
|
@@ -11196,7 +11319,7 @@ Analyzed ${results.length} files`));
|
|
|
11196
11319
|
return limit !== void 0 && r.minMaintainability < limit;
|
|
11197
11320
|
});
|
|
11198
11321
|
if (failing.length === 0) {
|
|
11199
|
-
console.log(
|
|
11322
|
+
console.log(chalk113.green("All files pass maintainability threshold"));
|
|
11200
11323
|
} else {
|
|
11201
11324
|
for (const entry of failing) console.log(formatResultLine(entry, true));
|
|
11202
11325
|
}
|
|
@@ -11205,7 +11328,7 @@ Analyzed ${results.length} files`));
|
|
|
11205
11328
|
);
|
|
11206
11329
|
for (const entry of passingOverrides)
|
|
11207
11330
|
console.log(formatResultLine(entry, false));
|
|
11208
|
-
console.log(
|
|
11331
|
+
console.log(chalk113.dim(`
|
|
11209
11332
|
Analyzed ${results.length} files`));
|
|
11210
11333
|
if (failing.length > 0) {
|
|
11211
11334
|
printMaintainabilityFailure(failing.length, threshold);
|
|
@@ -11214,10 +11337,10 @@ Analyzed ${results.length} files`));
|
|
|
11214
11337
|
}
|
|
11215
11338
|
|
|
11216
11339
|
// src/commands/complexity/maintainability/printMaintainabilityFormula.ts
|
|
11217
|
-
import
|
|
11340
|
+
import chalk114 from "chalk";
|
|
11218
11341
|
var MI_FORMULA = "171 - 5.2*ln(HalsteadVolume) - 0.23*CyclomaticComplexity - 16.2*ln(SLOC), clamped 0-100";
|
|
11219
11342
|
function printMaintainabilityFormula() {
|
|
11220
|
-
console.log(
|
|
11343
|
+
console.log(chalk114.dim(MI_FORMULA));
|
|
11221
11344
|
}
|
|
11222
11345
|
|
|
11223
11346
|
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
@@ -11293,7 +11416,7 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11293
11416
|
|
|
11294
11417
|
// src/commands/complexity/sloc.ts
|
|
11295
11418
|
import fs19 from "fs";
|
|
11296
|
-
import
|
|
11419
|
+
import chalk115 from "chalk";
|
|
11297
11420
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
11298
11421
|
withSourceFiles(pattern2, (files) => {
|
|
11299
11422
|
const results = [];
|
|
@@ -11309,12 +11432,12 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11309
11432
|
results.sort((a, b) => b.lines - a.lines);
|
|
11310
11433
|
for (const { file, lines } of results) {
|
|
11311
11434
|
const exceedsThreshold = options2.threshold !== void 0 && lines > options2.threshold;
|
|
11312
|
-
const color = exceedsThreshold ?
|
|
11313
|
-
console.log(`${color(file)} \u2192 ${
|
|
11435
|
+
const color = exceedsThreshold ? chalk115.red : chalk115.white;
|
|
11436
|
+
console.log(`${color(file)} \u2192 ${chalk115.cyan(lines)} lines`);
|
|
11314
11437
|
}
|
|
11315
11438
|
const total = results.reduce((sum, r) => sum + r.lines, 0);
|
|
11316
11439
|
console.log(
|
|
11317
|
-
|
|
11440
|
+
chalk115.dim(`
|
|
11318
11441
|
Total: ${total} lines across ${files.length} files`)
|
|
11319
11442
|
);
|
|
11320
11443
|
if (hasViolation) {
|
|
@@ -11328,25 +11451,25 @@ async function analyze(pattern2) {
|
|
|
11328
11451
|
const searchPattern = pattern2.includes("*") || pattern2.includes("/") ? pattern2 : `**/${pattern2}`;
|
|
11329
11452
|
const files = findSourceFiles2(searchPattern);
|
|
11330
11453
|
if (files.length === 0) {
|
|
11331
|
-
console.log(
|
|
11454
|
+
console.log(chalk116.yellow("No files found matching pattern"));
|
|
11332
11455
|
return;
|
|
11333
11456
|
}
|
|
11334
11457
|
if (files.length === 1) {
|
|
11335
11458
|
const file = files[0];
|
|
11336
|
-
console.log(
|
|
11459
|
+
console.log(chalk116.bold.underline("SLOC"));
|
|
11337
11460
|
await sloc(file);
|
|
11338
11461
|
console.log();
|
|
11339
|
-
console.log(
|
|
11462
|
+
console.log(chalk116.bold.underline("Cyclomatic Complexity"));
|
|
11340
11463
|
await cyclomatic(file);
|
|
11341
11464
|
console.log();
|
|
11342
|
-
console.log(
|
|
11465
|
+
console.log(chalk116.bold.underline("Halstead Metrics"));
|
|
11343
11466
|
await halstead(file);
|
|
11344
11467
|
console.log();
|
|
11345
|
-
console.log(
|
|
11468
|
+
console.log(chalk116.bold.underline("Maintainability Index"));
|
|
11346
11469
|
await maintainability(file);
|
|
11347
11470
|
console.log();
|
|
11348
11471
|
console.log(
|
|
11349
|
-
|
|
11472
|
+
chalk116.dim(
|
|
11350
11473
|
"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."
|
|
11351
11474
|
)
|
|
11352
11475
|
);
|
|
@@ -11380,7 +11503,7 @@ function registerComplexity(program2) {
|
|
|
11380
11503
|
}
|
|
11381
11504
|
|
|
11382
11505
|
// src/commands/config/index.ts
|
|
11383
|
-
import
|
|
11506
|
+
import chalk117 from "chalk";
|
|
11384
11507
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
11385
11508
|
|
|
11386
11509
|
// src/commands/config/setNestedValue.ts
|
|
@@ -11443,7 +11566,7 @@ function formatIssuePath(issue, key) {
|
|
|
11443
11566
|
function printValidationErrors(issues, key) {
|
|
11444
11567
|
for (const issue of issues) {
|
|
11445
11568
|
console.error(
|
|
11446
|
-
|
|
11569
|
+
chalk117.red(`${formatIssuePath(issue, key)}: ${issue.message}`)
|
|
11447
11570
|
);
|
|
11448
11571
|
}
|
|
11449
11572
|
}
|
|
@@ -11460,7 +11583,7 @@ var GLOBAL_ONLY_KEYS = ["sync.autoConfirm"];
|
|
|
11460
11583
|
function assertNotGlobalOnly(key, global) {
|
|
11461
11584
|
if (!global && GLOBAL_ONLY_KEYS.some((k) => key.startsWith(k))) {
|
|
11462
11585
|
console.error(
|
|
11463
|
-
|
|
11586
|
+
chalk117.red(
|
|
11464
11587
|
`"${key}" is a global-only key. Use --global to set it in ~/.assist.yml`
|
|
11465
11588
|
)
|
|
11466
11589
|
);
|
|
@@ -11483,7 +11606,7 @@ function configSet(key, value, options2 = {}) {
|
|
|
11483
11606
|
applyConfigSet(key, coerced, options2.global ?? false);
|
|
11484
11607
|
const target = options2.global ? "global" : "project";
|
|
11485
11608
|
console.log(
|
|
11486
|
-
|
|
11609
|
+
chalk117.green(`Set ${key} = ${JSON.stringify(coerced)} (${target})`)
|
|
11487
11610
|
);
|
|
11488
11611
|
}
|
|
11489
11612
|
function configList() {
|
|
@@ -11492,7 +11615,7 @@ function configList() {
|
|
|
11492
11615
|
}
|
|
11493
11616
|
|
|
11494
11617
|
// src/commands/config/configGet.ts
|
|
11495
|
-
import
|
|
11618
|
+
import chalk118 from "chalk";
|
|
11496
11619
|
|
|
11497
11620
|
// src/commands/config/getNestedValue.ts
|
|
11498
11621
|
function isTraversable(value) {
|
|
@@ -11524,7 +11647,7 @@ function requireNestedValue(config, key) {
|
|
|
11524
11647
|
return value;
|
|
11525
11648
|
}
|
|
11526
11649
|
function exitKeyNotSet(key) {
|
|
11527
|
-
console.error(
|
|
11650
|
+
console.error(chalk118.red(`Key "${key}" is not set`));
|
|
11528
11651
|
process.exit(1);
|
|
11529
11652
|
}
|
|
11530
11653
|
|
|
@@ -11538,7 +11661,7 @@ function registerConfig(program2) {
|
|
|
11538
11661
|
|
|
11539
11662
|
// src/commands/deploy/redirect.ts
|
|
11540
11663
|
import { existsSync as existsSync31, readFileSync as readFileSync26, writeFileSync as writeFileSync25 } from "fs";
|
|
11541
|
-
import
|
|
11664
|
+
import chalk119 from "chalk";
|
|
11542
11665
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
11543
11666
|
if (!window.location.pathname.endsWith('/')) {
|
|
11544
11667
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -11547,23 +11670,23 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
11547
11670
|
function redirect() {
|
|
11548
11671
|
const indexPath = "index.html";
|
|
11549
11672
|
if (!existsSync31(indexPath)) {
|
|
11550
|
-
console.log(
|
|
11673
|
+
console.log(chalk119.yellow("No index.html found"));
|
|
11551
11674
|
return;
|
|
11552
11675
|
}
|
|
11553
11676
|
const content = readFileSync26(indexPath, "utf8");
|
|
11554
11677
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
11555
|
-
console.log(
|
|
11678
|
+
console.log(chalk119.dim("Trailing slash script already present"));
|
|
11556
11679
|
return;
|
|
11557
11680
|
}
|
|
11558
11681
|
const headCloseIndex = content.indexOf("</head>");
|
|
11559
11682
|
if (headCloseIndex === -1) {
|
|
11560
|
-
console.log(
|
|
11683
|
+
console.log(chalk119.red("Could not find </head> tag in index.html"));
|
|
11561
11684
|
return;
|
|
11562
11685
|
}
|
|
11563
11686
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
11564
11687
|
${content.slice(headCloseIndex)}`;
|
|
11565
11688
|
writeFileSync25(indexPath, newContent);
|
|
11566
|
-
console.log(
|
|
11689
|
+
console.log(chalk119.green("Added trailing slash redirect to index.html"));
|
|
11567
11690
|
}
|
|
11568
11691
|
|
|
11569
11692
|
// src/commands/registerDeploy.ts
|
|
@@ -11590,7 +11713,7 @@ function loadBlogSkipDays(repoName) {
|
|
|
11590
11713
|
|
|
11591
11714
|
// src/commands/devlog/shared.ts
|
|
11592
11715
|
import { execSync as execSync27 } from "child_process";
|
|
11593
|
-
import
|
|
11716
|
+
import chalk120 from "chalk";
|
|
11594
11717
|
|
|
11595
11718
|
// src/shared/getRepoName.ts
|
|
11596
11719
|
import { existsSync as existsSync32, readFileSync as readFileSync27 } from "fs";
|
|
@@ -11699,13 +11822,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
11699
11822
|
}
|
|
11700
11823
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
11701
11824
|
for (const commit2 of commits2) {
|
|
11702
|
-
console.log(` ${
|
|
11825
|
+
console.log(` ${chalk120.yellow(commit2.hash)} ${commit2.message}`);
|
|
11703
11826
|
if (verbose) {
|
|
11704
11827
|
const visibleFiles = commit2.files.filter(
|
|
11705
11828
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
11706
11829
|
);
|
|
11707
11830
|
for (const file of visibleFiles) {
|
|
11708
|
-
console.log(` ${
|
|
11831
|
+
console.log(` ${chalk120.dim(file)}`);
|
|
11709
11832
|
}
|
|
11710
11833
|
}
|
|
11711
11834
|
}
|
|
@@ -11730,15 +11853,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
11730
11853
|
}
|
|
11731
11854
|
|
|
11732
11855
|
// src/commands/devlog/list/printDateHeader.ts
|
|
11733
|
-
import
|
|
11856
|
+
import chalk121 from "chalk";
|
|
11734
11857
|
function printDateHeader(date, isSkipped, entries) {
|
|
11735
11858
|
if (isSkipped) {
|
|
11736
|
-
console.log(`${
|
|
11859
|
+
console.log(`${chalk121.bold.blue(date)} ${chalk121.dim("skipped")}`);
|
|
11737
11860
|
} else if (entries && entries.length > 0) {
|
|
11738
|
-
const entryInfo = entries.map((e) => `${
|
|
11739
|
-
console.log(`${
|
|
11861
|
+
const entryInfo = entries.map((e) => `${chalk121.green(e.version)} ${e.title}`).join(" | ");
|
|
11862
|
+
console.log(`${chalk121.bold.blue(date)} ${entryInfo}`);
|
|
11740
11863
|
} else {
|
|
11741
|
-
console.log(`${
|
|
11864
|
+
console.log(`${chalk121.bold.blue(date)} ${chalk121.red("\u26A0 devlog missing")}`);
|
|
11742
11865
|
}
|
|
11743
11866
|
}
|
|
11744
11867
|
|
|
@@ -11842,24 +11965,24 @@ function bumpVersion(version2, type) {
|
|
|
11842
11965
|
|
|
11843
11966
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
11844
11967
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
11845
|
-
import
|
|
11968
|
+
import chalk123 from "chalk";
|
|
11846
11969
|
|
|
11847
11970
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
11848
|
-
import
|
|
11971
|
+
import chalk122 from "chalk";
|
|
11849
11972
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
11850
11973
|
if (conventional && firstHash) {
|
|
11851
11974
|
const version2 = getVersionAtCommit(firstHash);
|
|
11852
11975
|
if (version2) {
|
|
11853
|
-
console.log(`${
|
|
11976
|
+
console.log(`${chalk122.bold("version:")} ${stripToMinor(version2)}`);
|
|
11854
11977
|
} else {
|
|
11855
|
-
console.log(`${
|
|
11978
|
+
console.log(`${chalk122.bold("version:")} ${chalk122.red("unknown")}`);
|
|
11856
11979
|
}
|
|
11857
11980
|
} else if (patchVersion && minorVersion) {
|
|
11858
11981
|
console.log(
|
|
11859
|
-
`${
|
|
11982
|
+
`${chalk122.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
11860
11983
|
);
|
|
11861
11984
|
} else {
|
|
11862
|
-
console.log(`${
|
|
11985
|
+
console.log(`${chalk122.bold("version:")} v0.1 (initial)`);
|
|
11863
11986
|
}
|
|
11864
11987
|
}
|
|
11865
11988
|
|
|
@@ -11907,16 +12030,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
11907
12030
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
11908
12031
|
}
|
|
11909
12032
|
function logName(repoName) {
|
|
11910
|
-
console.log(`${
|
|
12033
|
+
console.log(`${chalk123.bold("name:")} ${repoName}`);
|
|
11911
12034
|
}
|
|
11912
12035
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
11913
12036
|
logName(ctx.repoName);
|
|
11914
12037
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
11915
|
-
console.log(
|
|
12038
|
+
console.log(chalk123.bold.blue(targetDate));
|
|
11916
12039
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
11917
12040
|
}
|
|
11918
12041
|
function logNoCommits(lastInfo) {
|
|
11919
|
-
console.log(
|
|
12042
|
+
console.log(chalk123.dim(noCommitsMessage(!!lastInfo)));
|
|
11920
12043
|
}
|
|
11921
12044
|
|
|
11922
12045
|
// src/commands/devlog/next/index.ts
|
|
@@ -11957,11 +12080,11 @@ function next2(options2) {
|
|
|
11957
12080
|
import { execSync as execSync29 } from "child_process";
|
|
11958
12081
|
|
|
11959
12082
|
// src/commands/devlog/repos/printReposTable.ts
|
|
11960
|
-
import
|
|
12083
|
+
import chalk124 from "chalk";
|
|
11961
12084
|
function colorStatus(status2) {
|
|
11962
|
-
if (status2 === "missing") return
|
|
11963
|
-
if (status2 === "outdated") return
|
|
11964
|
-
return
|
|
12085
|
+
if (status2 === "missing") return chalk124.red(status2);
|
|
12086
|
+
if (status2 === "outdated") return chalk124.yellow(status2);
|
|
12087
|
+
return chalk124.green(status2);
|
|
11965
12088
|
}
|
|
11966
12089
|
function formatRow(row, nameWidth) {
|
|
11967
12090
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -11975,8 +12098,8 @@ function printReposTable(rows) {
|
|
|
11975
12098
|
"Last Devlog".padEnd(11),
|
|
11976
12099
|
"Status"
|
|
11977
12100
|
].join(" ");
|
|
11978
|
-
console.log(
|
|
11979
|
-
console.log(
|
|
12101
|
+
console.log(chalk124.dim(header));
|
|
12102
|
+
console.log(chalk124.dim("-".repeat(header.length)));
|
|
11980
12103
|
for (const row of rows) {
|
|
11981
12104
|
console.log(formatRow(row, nameWidth));
|
|
11982
12105
|
}
|
|
@@ -12034,14 +12157,14 @@ function repos(options2) {
|
|
|
12034
12157
|
// src/commands/devlog/skip.ts
|
|
12035
12158
|
import { writeFileSync as writeFileSync26 } from "fs";
|
|
12036
12159
|
import { join as join33 } from "path";
|
|
12037
|
-
import
|
|
12160
|
+
import chalk125 from "chalk";
|
|
12038
12161
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
12039
12162
|
function getBlogConfigPath() {
|
|
12040
12163
|
return join33(BLOG_REPO_ROOT, "assist.yml");
|
|
12041
12164
|
}
|
|
12042
12165
|
function skip(date) {
|
|
12043
12166
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
12044
|
-
console.log(
|
|
12167
|
+
console.log(chalk125.red("Invalid date format. Use YYYY-MM-DD"));
|
|
12045
12168
|
process.exit(1);
|
|
12046
12169
|
}
|
|
12047
12170
|
const repoName = getRepoName();
|
|
@@ -12052,7 +12175,7 @@ function skip(date) {
|
|
|
12052
12175
|
const skipDays = skip2[repoName] ?? [];
|
|
12053
12176
|
if (skipDays.includes(date)) {
|
|
12054
12177
|
console.log(
|
|
12055
|
-
|
|
12178
|
+
chalk125.yellow(`${date} is already in skip list for ${repoName}`)
|
|
12056
12179
|
);
|
|
12057
12180
|
return;
|
|
12058
12181
|
}
|
|
@@ -12062,20 +12185,20 @@ function skip(date) {
|
|
|
12062
12185
|
devlog.skip = skip2;
|
|
12063
12186
|
config.devlog = devlog;
|
|
12064
12187
|
writeFileSync26(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
12065
|
-
console.log(
|
|
12188
|
+
console.log(chalk125.green(`Added ${date} to skip list for ${repoName}`));
|
|
12066
12189
|
}
|
|
12067
12190
|
|
|
12068
12191
|
// src/commands/devlog/version.ts
|
|
12069
|
-
import
|
|
12192
|
+
import chalk126 from "chalk";
|
|
12070
12193
|
function version() {
|
|
12071
12194
|
const config = loadConfig();
|
|
12072
12195
|
const name = getRepoName();
|
|
12073
12196
|
const lastInfo = getLastVersionInfo(name, config);
|
|
12074
12197
|
const lastVersion = lastInfo?.version ?? null;
|
|
12075
12198
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
12076
|
-
console.log(`${
|
|
12077
|
-
console.log(`${
|
|
12078
|
-
console.log(`${
|
|
12199
|
+
console.log(`${chalk126.bold("name:")} ${name}`);
|
|
12200
|
+
console.log(`${chalk126.bold("last:")} ${lastVersion ?? chalk126.dim("none")}`);
|
|
12201
|
+
console.log(`${chalk126.bold("next:")} ${nextVersion ?? chalk126.dim("none")}`);
|
|
12079
12202
|
}
|
|
12080
12203
|
|
|
12081
12204
|
// src/commands/registerDevlog.ts
|
|
@@ -12099,7 +12222,7 @@ function registerDevlog(program2) {
|
|
|
12099
12222
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
12100
12223
|
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4 } from "fs";
|
|
12101
12224
|
import { join as join34 } from "path";
|
|
12102
|
-
import
|
|
12225
|
+
import chalk127 from "chalk";
|
|
12103
12226
|
|
|
12104
12227
|
// src/shared/findRepoRoot.ts
|
|
12105
12228
|
import { existsSync as existsSync33 } from "fs";
|
|
@@ -12162,14 +12285,14 @@ function checkBuildLocks(startDir) {
|
|
|
12162
12285
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
12163
12286
|
if (locked) {
|
|
12164
12287
|
console.error(
|
|
12165
|
-
|
|
12288
|
+
chalk127.red("Build output locked (is VS debugging?): ") + locked
|
|
12166
12289
|
);
|
|
12167
12290
|
process.exit(1);
|
|
12168
12291
|
}
|
|
12169
12292
|
}
|
|
12170
12293
|
async function checkBuildLocksCommand() {
|
|
12171
12294
|
checkBuildLocks();
|
|
12172
|
-
console.log(
|
|
12295
|
+
console.log(chalk127.green("No build locks detected"));
|
|
12173
12296
|
}
|
|
12174
12297
|
|
|
12175
12298
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -12268,30 +12391,30 @@ function escapeRegex(s) {
|
|
|
12268
12391
|
}
|
|
12269
12392
|
|
|
12270
12393
|
// src/commands/dotnet/printTree.ts
|
|
12271
|
-
import
|
|
12394
|
+
import chalk128 from "chalk";
|
|
12272
12395
|
function printNodes(nodes, prefix2) {
|
|
12273
12396
|
for (let i = 0; i < nodes.length; i++) {
|
|
12274
12397
|
const isLast = i === nodes.length - 1;
|
|
12275
12398
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
12276
12399
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
12277
12400
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
12278
|
-
const label2 = isMissing ?
|
|
12401
|
+
const label2 = isMissing ? chalk128.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
12279
12402
|
console.log(`${prefix2}${connector}${label2}`);
|
|
12280
12403
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
12281
12404
|
}
|
|
12282
12405
|
}
|
|
12283
12406
|
function printTree(tree, totalCount, solutions) {
|
|
12284
|
-
console.log(
|
|
12285
|
-
console.log(
|
|
12407
|
+
console.log(chalk128.bold("\nProject Dependency Tree"));
|
|
12408
|
+
console.log(chalk128.cyan(tree.relativePath));
|
|
12286
12409
|
printNodes(tree.children, "");
|
|
12287
|
-
console.log(
|
|
12410
|
+
console.log(chalk128.dim(`
|
|
12288
12411
|
${totalCount} projects total (including root)`));
|
|
12289
|
-
console.log(
|
|
12412
|
+
console.log(chalk128.bold("\nSolution Membership"));
|
|
12290
12413
|
if (solutions.length === 0) {
|
|
12291
|
-
console.log(
|
|
12414
|
+
console.log(chalk128.yellow(" Not found in any .sln"));
|
|
12292
12415
|
} else {
|
|
12293
12416
|
for (const sln of solutions) {
|
|
12294
|
-
console.log(` ${
|
|
12417
|
+
console.log(` ${chalk128.green(sln)}`);
|
|
12295
12418
|
}
|
|
12296
12419
|
}
|
|
12297
12420
|
console.log();
|
|
@@ -12320,16 +12443,16 @@ function printJson(tree, totalCount, solutions) {
|
|
|
12320
12443
|
// src/commands/dotnet/resolveCsproj.ts
|
|
12321
12444
|
import { existsSync as existsSync34 } from "fs";
|
|
12322
12445
|
import path25 from "path";
|
|
12323
|
-
import
|
|
12446
|
+
import chalk129 from "chalk";
|
|
12324
12447
|
function resolveCsproj(csprojPath) {
|
|
12325
12448
|
const resolved = path25.resolve(csprojPath);
|
|
12326
12449
|
if (!existsSync34(resolved)) {
|
|
12327
|
-
console.error(
|
|
12450
|
+
console.error(chalk129.red(`File not found: ${resolved}`));
|
|
12328
12451
|
process.exit(1);
|
|
12329
12452
|
}
|
|
12330
12453
|
const repoRoot = findRepoRoot(path25.dirname(resolved));
|
|
12331
12454
|
if (!repoRoot) {
|
|
12332
|
-
console.error(
|
|
12455
|
+
console.error(chalk129.red("Could not find git repository root"));
|
|
12333
12456
|
process.exit(1);
|
|
12334
12457
|
}
|
|
12335
12458
|
return { resolved, repoRoot };
|
|
@@ -12379,12 +12502,12 @@ function getChangedCsFiles(scope) {
|
|
|
12379
12502
|
}
|
|
12380
12503
|
|
|
12381
12504
|
// src/commands/dotnet/inSln.ts
|
|
12382
|
-
import
|
|
12505
|
+
import chalk130 from "chalk";
|
|
12383
12506
|
async function inSln(csprojPath) {
|
|
12384
12507
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
12385
12508
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
12386
12509
|
if (solutions.length === 0) {
|
|
12387
|
-
console.log(
|
|
12510
|
+
console.log(chalk130.yellow("Not found in any .sln file"));
|
|
12388
12511
|
process.exit(1);
|
|
12389
12512
|
}
|
|
12390
12513
|
for (const sln of solutions) {
|
|
@@ -12393,7 +12516,7 @@ async function inSln(csprojPath) {
|
|
|
12393
12516
|
}
|
|
12394
12517
|
|
|
12395
12518
|
// src/commands/dotnet/inspect.ts
|
|
12396
|
-
import
|
|
12519
|
+
import chalk136 from "chalk";
|
|
12397
12520
|
|
|
12398
12521
|
// src/shared/formatElapsed.ts
|
|
12399
12522
|
function formatElapsed(ms) {
|
|
@@ -12405,12 +12528,12 @@ function formatElapsed(ms) {
|
|
|
12405
12528
|
}
|
|
12406
12529
|
|
|
12407
12530
|
// src/commands/dotnet/displayIssues.ts
|
|
12408
|
-
import
|
|
12531
|
+
import chalk131 from "chalk";
|
|
12409
12532
|
var SEVERITY_COLOR = {
|
|
12410
|
-
ERROR:
|
|
12411
|
-
WARNING:
|
|
12412
|
-
SUGGESTION:
|
|
12413
|
-
HINT:
|
|
12533
|
+
ERROR: chalk131.red,
|
|
12534
|
+
WARNING: chalk131.yellow,
|
|
12535
|
+
SUGGESTION: chalk131.cyan,
|
|
12536
|
+
HINT: chalk131.dim
|
|
12414
12537
|
};
|
|
12415
12538
|
function groupByFile(issues) {
|
|
12416
12539
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -12426,15 +12549,15 @@ function groupByFile(issues) {
|
|
|
12426
12549
|
}
|
|
12427
12550
|
function displayIssues(issues) {
|
|
12428
12551
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
12429
|
-
console.log(
|
|
12552
|
+
console.log(chalk131.bold(file));
|
|
12430
12553
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
12431
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
12554
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk131.white;
|
|
12432
12555
|
console.log(
|
|
12433
|
-
` ${
|
|
12556
|
+
` ${chalk131.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
12434
12557
|
);
|
|
12435
12558
|
}
|
|
12436
12559
|
}
|
|
12437
|
-
console.log(
|
|
12560
|
+
console.log(chalk131.dim(`
|
|
12438
12561
|
${issues.length} issue(s) found`));
|
|
12439
12562
|
}
|
|
12440
12563
|
|
|
@@ -12493,12 +12616,12 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
12493
12616
|
// src/commands/dotnet/resolveSolution.ts
|
|
12494
12617
|
import { existsSync as existsSync35 } from "fs";
|
|
12495
12618
|
import path26 from "path";
|
|
12496
|
-
import
|
|
12619
|
+
import chalk133 from "chalk";
|
|
12497
12620
|
|
|
12498
12621
|
// src/commands/dotnet/findSolution.ts
|
|
12499
12622
|
import { readdirSync as readdirSync6 } from "fs";
|
|
12500
12623
|
import { dirname as dirname20, join as join35 } from "path";
|
|
12501
|
-
import
|
|
12624
|
+
import chalk132 from "chalk";
|
|
12502
12625
|
function findSlnInDir(dir) {
|
|
12503
12626
|
try {
|
|
12504
12627
|
return readdirSync6(dir).filter((f) => f.endsWith(".sln")).map((f) => join35(dir, f));
|
|
@@ -12514,17 +12637,17 @@ function findSolution() {
|
|
|
12514
12637
|
const slnFiles = findSlnInDir(current);
|
|
12515
12638
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
12516
12639
|
if (slnFiles.length > 1) {
|
|
12517
|
-
console.error(
|
|
12640
|
+
console.error(chalk132.red(`Multiple .sln files found in ${current}:`));
|
|
12518
12641
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
12519
12642
|
console.error(
|
|
12520
|
-
|
|
12643
|
+
chalk132.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
12521
12644
|
);
|
|
12522
12645
|
process.exit(1);
|
|
12523
12646
|
}
|
|
12524
12647
|
if (current === ceiling) break;
|
|
12525
12648
|
current = dirname20(current);
|
|
12526
12649
|
}
|
|
12527
|
-
console.error(
|
|
12650
|
+
console.error(chalk132.red("No .sln file found between cwd and repo root"));
|
|
12528
12651
|
process.exit(1);
|
|
12529
12652
|
}
|
|
12530
12653
|
|
|
@@ -12533,7 +12656,7 @@ function resolveSolution(sln) {
|
|
|
12533
12656
|
if (sln) {
|
|
12534
12657
|
const resolved = path26.resolve(sln);
|
|
12535
12658
|
if (!existsSync35(resolved)) {
|
|
12536
|
-
console.error(
|
|
12659
|
+
console.error(chalk133.red(`Solution file not found: ${resolved}`));
|
|
12537
12660
|
process.exit(1);
|
|
12538
12661
|
}
|
|
12539
12662
|
return resolved;
|
|
@@ -12575,14 +12698,14 @@ import { execSync as execSync31 } from "child_process";
|
|
|
12575
12698
|
import { existsSync as existsSync36, readFileSync as readFileSync31, unlinkSync as unlinkSync9 } from "fs";
|
|
12576
12699
|
import { tmpdir as tmpdir3 } from "os";
|
|
12577
12700
|
import path27 from "path";
|
|
12578
|
-
import
|
|
12701
|
+
import chalk134 from "chalk";
|
|
12579
12702
|
function assertJbInstalled() {
|
|
12580
12703
|
try {
|
|
12581
12704
|
execSync31("jb inspectcode --version", { stdio: "pipe" });
|
|
12582
12705
|
} catch {
|
|
12583
|
-
console.error(
|
|
12706
|
+
console.error(chalk134.red("jb is not installed. Install with:"));
|
|
12584
12707
|
console.error(
|
|
12585
|
-
|
|
12708
|
+
chalk134.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
12586
12709
|
);
|
|
12587
12710
|
process.exit(1);
|
|
12588
12711
|
}
|
|
@@ -12600,11 +12723,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
12600
12723
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
12601
12724
|
process.stderr.write(error.stderr);
|
|
12602
12725
|
}
|
|
12603
|
-
console.error(
|
|
12726
|
+
console.error(chalk134.red("jb inspectcode failed"));
|
|
12604
12727
|
process.exit(1);
|
|
12605
12728
|
}
|
|
12606
12729
|
if (!existsSync36(reportPath)) {
|
|
12607
|
-
console.error(
|
|
12730
|
+
console.error(chalk134.red("Report file not generated"));
|
|
12608
12731
|
process.exit(1);
|
|
12609
12732
|
}
|
|
12610
12733
|
const xml = readFileSync31(reportPath, "utf8");
|
|
@@ -12614,7 +12737,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
12614
12737
|
|
|
12615
12738
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
12616
12739
|
import { execSync as execSync32 } from "child_process";
|
|
12617
|
-
import
|
|
12740
|
+
import chalk135 from "chalk";
|
|
12618
12741
|
function resolveMsbuildPath() {
|
|
12619
12742
|
const { run: run4 } = loadConfig();
|
|
12620
12743
|
const configs = resolveRunConfigs(run4, getConfigDir());
|
|
@@ -12626,9 +12749,9 @@ function assertMsbuildInstalled() {
|
|
|
12626
12749
|
try {
|
|
12627
12750
|
execSync32(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
12628
12751
|
} catch {
|
|
12629
|
-
console.error(
|
|
12752
|
+
console.error(chalk135.red(`msbuild not found at: ${msbuild}`));
|
|
12630
12753
|
console.error(
|
|
12631
|
-
|
|
12754
|
+
chalk135.yellow(
|
|
12632
12755
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
12633
12756
|
)
|
|
12634
12757
|
);
|
|
@@ -12675,17 +12798,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
12675
12798
|
// src/commands/dotnet/inspect.ts
|
|
12676
12799
|
function logScope(changedFiles) {
|
|
12677
12800
|
if (changedFiles === null) {
|
|
12678
|
-
console.log(
|
|
12801
|
+
console.log(chalk136.dim("Inspecting full solution..."));
|
|
12679
12802
|
} else {
|
|
12680
12803
|
console.log(
|
|
12681
|
-
|
|
12804
|
+
chalk136.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
12682
12805
|
);
|
|
12683
12806
|
}
|
|
12684
12807
|
}
|
|
12685
12808
|
function reportResults(issues, elapsed) {
|
|
12686
12809
|
if (issues.length > 0) displayIssues(issues);
|
|
12687
|
-
else console.log(
|
|
12688
|
-
console.log(
|
|
12810
|
+
else console.log(chalk136.green("No issues found"));
|
|
12811
|
+
console.log(chalk136.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
12689
12812
|
if (issues.length > 0) process.exit(1);
|
|
12690
12813
|
}
|
|
12691
12814
|
async function inspect(sln, options2) {
|
|
@@ -12696,7 +12819,7 @@ async function inspect(sln, options2) {
|
|
|
12696
12819
|
const scope = parseScope(options2.scope);
|
|
12697
12820
|
const changedFiles = getChangedCsFiles(scope);
|
|
12698
12821
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
12699
|
-
console.log(
|
|
12822
|
+
console.log(chalk136.green("No changed .cs files found"));
|
|
12700
12823
|
return;
|
|
12701
12824
|
}
|
|
12702
12825
|
logScope(changedFiles);
|
|
@@ -13021,25 +13144,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
13021
13144
|
}
|
|
13022
13145
|
|
|
13023
13146
|
// src/commands/github/printCountTable.ts
|
|
13024
|
-
import
|
|
13147
|
+
import chalk137 from "chalk";
|
|
13025
13148
|
function printCountTable(labelHeader, rows) {
|
|
13026
13149
|
const labelWidth = Math.max(
|
|
13027
13150
|
labelHeader.length,
|
|
13028
13151
|
...rows.map((row) => row.label.length)
|
|
13029
13152
|
);
|
|
13030
13153
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
13031
|
-
console.log(
|
|
13032
|
-
console.log(
|
|
13154
|
+
console.log(chalk137.dim(header));
|
|
13155
|
+
console.log(chalk137.dim("-".repeat(header.length)));
|
|
13033
13156
|
for (const row of rows) {
|
|
13034
13157
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
13035
13158
|
}
|
|
13036
13159
|
}
|
|
13037
13160
|
|
|
13038
13161
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
13039
|
-
import
|
|
13162
|
+
import chalk138 from "chalk";
|
|
13040
13163
|
function printRepoAuthorBreakdown(repos2) {
|
|
13041
13164
|
for (const repo of repos2) {
|
|
13042
|
-
console.log(
|
|
13165
|
+
console.log(chalk138.bold(repo.name));
|
|
13043
13166
|
const authorWidth = Math.max(
|
|
13044
13167
|
0,
|
|
13045
13168
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -13136,9 +13259,9 @@ function registerGithub(program2) {
|
|
|
13136
13259
|
}
|
|
13137
13260
|
|
|
13138
13261
|
// src/commands/handover/countPendingHandovers.ts
|
|
13139
|
-
import { and as
|
|
13262
|
+
import { and as and16, eq as eq35, isNull, sql as sql6 } from "drizzle-orm";
|
|
13140
13263
|
async function countPendingHandovers(orm, origin) {
|
|
13141
|
-
const [row] = await orm.select({ count:
|
|
13264
|
+
const [row] = await orm.select({ count: sql6`count(*)::int` }).from(handovers).where(and16(eq35(handovers.origin, origin), isNull(handovers.recalledAt)));
|
|
13142
13265
|
return row?.count ?? 0;
|
|
13143
13266
|
}
|
|
13144
13267
|
|
|
@@ -13278,13 +13401,13 @@ async function load2(options2 = {}) {
|
|
|
13278
13401
|
}
|
|
13279
13402
|
|
|
13280
13403
|
// src/commands/handover/listPendingHandovers.ts
|
|
13281
|
-
import { and as
|
|
13404
|
+
import { and as and17, desc as desc4, eq as eq36, isNull as isNull2 } from "drizzle-orm";
|
|
13282
13405
|
async function listPendingHandovers(orm, origin) {
|
|
13283
13406
|
return orm.select({
|
|
13284
13407
|
id: handovers.id,
|
|
13285
13408
|
summary: handovers.summary,
|
|
13286
13409
|
createdAt: handovers.createdAt
|
|
13287
|
-
}).from(handovers).where(
|
|
13410
|
+
}).from(handovers).where(and17(eq36(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
|
|
13288
13411
|
}
|
|
13289
13412
|
|
|
13290
13413
|
// src/commands/handover/printPendingHandovers.ts
|
|
@@ -13297,17 +13420,17 @@ async function printPendingHandovers() {
|
|
|
13297
13420
|
}
|
|
13298
13421
|
|
|
13299
13422
|
// src/commands/handover/recallHandover.ts
|
|
13300
|
-
import { and as
|
|
13423
|
+
import { and as and18, desc as desc5, eq as eq37, isNull as isNull3 } from "drizzle-orm";
|
|
13301
13424
|
async function recallHandover(orm, origin, id2) {
|
|
13302
13425
|
const [row] = await orm.select().from(handovers).where(
|
|
13303
|
-
|
|
13304
|
-
|
|
13426
|
+
and18(
|
|
13427
|
+
eq37(handovers.origin, origin),
|
|
13305
13428
|
isNull3(handovers.recalledAt),
|
|
13306
|
-
...id2 === void 0 ? [] : [
|
|
13429
|
+
...id2 === void 0 ? [] : [eq37(handovers.id, id2)]
|
|
13307
13430
|
)
|
|
13308
13431
|
).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
|
|
13309
13432
|
if (!row) return void 0;
|
|
13310
|
-
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(
|
|
13433
|
+
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq37(handovers.id, row.id));
|
|
13311
13434
|
return row.content;
|
|
13312
13435
|
}
|
|
13313
13436
|
|
|
@@ -13357,7 +13480,7 @@ function registerHandover(program2) {
|
|
|
13357
13480
|
}
|
|
13358
13481
|
|
|
13359
13482
|
// src/commands/jira/acceptanceCriteria.ts
|
|
13360
|
-
import
|
|
13483
|
+
import chalk139 from "chalk";
|
|
13361
13484
|
|
|
13362
13485
|
// src/commands/jira/adfToText.ts
|
|
13363
13486
|
function renderInline(node) {
|
|
@@ -13424,7 +13547,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
13424
13547
|
const parsed = fetchIssue(issueKey, field);
|
|
13425
13548
|
const acValue = parsed?.fields?.[field];
|
|
13426
13549
|
if (!acValue) {
|
|
13427
|
-
console.log(
|
|
13550
|
+
console.log(chalk139.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
13428
13551
|
return;
|
|
13429
13552
|
}
|
|
13430
13553
|
if (typeof acValue === "string") {
|
|
@@ -13490,14 +13613,14 @@ async function jiraAuth() {
|
|
|
13490
13613
|
}
|
|
13491
13614
|
|
|
13492
13615
|
// src/commands/jira/viewIssue.ts
|
|
13493
|
-
import
|
|
13616
|
+
import chalk140 from "chalk";
|
|
13494
13617
|
function viewIssue(issueKey) {
|
|
13495
13618
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
13496
13619
|
const fields = parsed?.fields;
|
|
13497
13620
|
const summary = fields?.summary;
|
|
13498
13621
|
const description = fields?.description;
|
|
13499
13622
|
if (summary) {
|
|
13500
|
-
console.log(
|
|
13623
|
+
console.log(chalk140.bold(summary));
|
|
13501
13624
|
}
|
|
13502
13625
|
if (description) {
|
|
13503
13626
|
if (summary) console.log();
|
|
@@ -13511,7 +13634,7 @@ function viewIssue(issueKey) {
|
|
|
13511
13634
|
}
|
|
13512
13635
|
if (!summary && !description) {
|
|
13513
13636
|
console.log(
|
|
13514
|
-
|
|
13637
|
+
chalk140.yellow(`No summary or description found on ${issueKey}.`)
|
|
13515
13638
|
);
|
|
13516
13639
|
}
|
|
13517
13640
|
}
|
|
@@ -13527,13 +13650,13 @@ function registerJira(program2) {
|
|
|
13527
13650
|
// src/commands/reviewComments.ts
|
|
13528
13651
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
13529
13652
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
13530
|
-
import
|
|
13653
|
+
import chalk141 from "chalk";
|
|
13531
13654
|
async function reviewComments(number) {
|
|
13532
13655
|
if (number) {
|
|
13533
13656
|
try {
|
|
13534
13657
|
execFileSync5("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
13535
13658
|
} catch {
|
|
13536
|
-
console.error(
|
|
13659
|
+
console.error(chalk141.red(`gh pr checkout ${number} failed; aborting.`));
|
|
13537
13660
|
process.exit(1);
|
|
13538
13661
|
}
|
|
13539
13662
|
}
|
|
@@ -13607,15 +13730,15 @@ function registerList(program2) {
|
|
|
13607
13730
|
// src/commands/mermaid/index.ts
|
|
13608
13731
|
import { mkdirSync as mkdirSync14, readdirSync as readdirSync8 } from "fs";
|
|
13609
13732
|
import { resolve as resolve11 } from "path";
|
|
13610
|
-
import
|
|
13733
|
+
import chalk144 from "chalk";
|
|
13611
13734
|
|
|
13612
13735
|
// src/commands/mermaid/exportFile.ts
|
|
13613
13736
|
import { readFileSync as readFileSync33, writeFileSync as writeFileSync28 } from "fs";
|
|
13614
13737
|
import { basename as basename8, extname, resolve as resolve10 } from "path";
|
|
13615
|
-
import
|
|
13738
|
+
import chalk143 from "chalk";
|
|
13616
13739
|
|
|
13617
13740
|
// src/commands/mermaid/renderBlock.ts
|
|
13618
|
-
import
|
|
13741
|
+
import chalk142 from "chalk";
|
|
13619
13742
|
async function renderBlock(krokiUrl, source) {
|
|
13620
13743
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
13621
13744
|
method: "POST",
|
|
@@ -13624,7 +13747,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
13624
13747
|
});
|
|
13625
13748
|
if (!response.ok) {
|
|
13626
13749
|
console.error(
|
|
13627
|
-
|
|
13750
|
+
chalk142.red(
|
|
13628
13751
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
13629
13752
|
)
|
|
13630
13753
|
);
|
|
@@ -13642,19 +13765,19 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
13642
13765
|
if (onlyIndex !== void 0) {
|
|
13643
13766
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
13644
13767
|
console.error(
|
|
13645
|
-
|
|
13768
|
+
chalk143.red(
|
|
13646
13769
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
13647
13770
|
)
|
|
13648
13771
|
);
|
|
13649
13772
|
process.exit(1);
|
|
13650
13773
|
}
|
|
13651
13774
|
console.log(
|
|
13652
|
-
|
|
13775
|
+
chalk143.gray(
|
|
13653
13776
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
13654
13777
|
)
|
|
13655
13778
|
);
|
|
13656
13779
|
} else {
|
|
13657
|
-
console.log(
|
|
13780
|
+
console.log(chalk143.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
13658
13781
|
}
|
|
13659
13782
|
for (const [i, source] of blocks.entries()) {
|
|
13660
13783
|
const idx = i + 1;
|
|
@@ -13662,7 +13785,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
13662
13785
|
const outPath = resolve10(outDir, `${stem}-${idx}.svg`);
|
|
13663
13786
|
const svg = await renderBlock(krokiUrl, source);
|
|
13664
13787
|
writeFileSync28(outPath, svg, "utf8");
|
|
13665
|
-
console.log(
|
|
13788
|
+
console.log(chalk143.green(` \u2192 ${outPath}`));
|
|
13666
13789
|
}
|
|
13667
13790
|
}
|
|
13668
13791
|
function extractMermaidBlocks(markdown) {
|
|
@@ -13678,18 +13801,18 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
13678
13801
|
if (options2.index !== void 0) {
|
|
13679
13802
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
13680
13803
|
console.error(
|
|
13681
|
-
|
|
13804
|
+
chalk144.red(`--index must be a positive integer (got ${options2.index})`)
|
|
13682
13805
|
);
|
|
13683
13806
|
process.exit(1);
|
|
13684
13807
|
}
|
|
13685
13808
|
if (!file) {
|
|
13686
|
-
console.error(
|
|
13809
|
+
console.error(chalk144.red("--index requires a file argument"));
|
|
13687
13810
|
process.exit(1);
|
|
13688
13811
|
}
|
|
13689
13812
|
}
|
|
13690
13813
|
const files = file ? [file] : readdirSync8(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
13691
13814
|
if (files.length === 0) {
|
|
13692
|
-
console.log(
|
|
13815
|
+
console.log(chalk144.gray("No markdown files found in current directory."));
|
|
13693
13816
|
return;
|
|
13694
13817
|
}
|
|
13695
13818
|
for (const f of files) {
|
|
@@ -13715,7 +13838,7 @@ function registerMermaid(program2) {
|
|
|
13715
13838
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
13716
13839
|
import { createServer as createServer2 } from "http";
|
|
13717
13840
|
import { dirname as dirname22 } from "path";
|
|
13718
|
-
import
|
|
13841
|
+
import chalk146 from "chalk";
|
|
13719
13842
|
|
|
13720
13843
|
// src/commands/netcap/corsHeaders.ts
|
|
13721
13844
|
var corsHeaders = {
|
|
@@ -13794,7 +13917,7 @@ function createNetcapHandler(options2) {
|
|
|
13794
13917
|
import { cp, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
13795
13918
|
import { networkInterfaces } from "os";
|
|
13796
13919
|
import { join as join41 } from "path";
|
|
13797
|
-
import
|
|
13920
|
+
import chalk145 from "chalk";
|
|
13798
13921
|
|
|
13799
13922
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
13800
13923
|
import { dirname as dirname21, join as join40 } from "path";
|
|
@@ -13838,7 +13961,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
13838
13961
|
const host = lanIPv4();
|
|
13839
13962
|
if (!host) {
|
|
13840
13963
|
console.log(
|
|
13841
|
-
|
|
13964
|
+
chalk145.yellow("could not determine the WSL IP for the extension")
|
|
13842
13965
|
);
|
|
13843
13966
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
13844
13967
|
return source;
|
|
@@ -13849,7 +13972,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
13849
13972
|
return WSL_WINDOWS_PATH;
|
|
13850
13973
|
} catch {
|
|
13851
13974
|
console.log(
|
|
13852
|
-
|
|
13975
|
+
chalk145.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
13853
13976
|
);
|
|
13854
13977
|
return source;
|
|
13855
13978
|
}
|
|
@@ -13882,30 +14005,30 @@ async function netcap(options2) {
|
|
|
13882
14005
|
let count8 = 0;
|
|
13883
14006
|
const handler = createNetcapHandler({
|
|
13884
14007
|
outPath,
|
|
13885
|
-
onPing: () => console.log(
|
|
14008
|
+
onPing: () => console.log(chalk146.dim("ping from extension")),
|
|
13886
14009
|
onCapture: (entry) => {
|
|
13887
14010
|
count8 += 1;
|
|
13888
14011
|
console.log(
|
|
13889
|
-
|
|
13890
|
-
|
|
14012
|
+
chalk146.green(`captured #${count8}`),
|
|
14013
|
+
chalk146.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
13891
14014
|
);
|
|
13892
14015
|
}
|
|
13893
14016
|
});
|
|
13894
14017
|
const server = createServer2(handler);
|
|
13895
14018
|
server.listen(port, () => {
|
|
13896
14019
|
console.log(
|
|
13897
|
-
|
|
14020
|
+
chalk146.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
13898
14021
|
);
|
|
13899
|
-
console.log(
|
|
14022
|
+
console.log(chalk146.dim(`appending captures to ${outPath}`));
|
|
13900
14023
|
if (filter)
|
|
13901
|
-
console.log(
|
|
13902
|
-
console.log(
|
|
13903
|
-
console.log(
|
|
14024
|
+
console.log(chalk146.dim(`forwarding only URLs matching "${filter}"`));
|
|
14025
|
+
console.log(chalk146.dim(`load the unpacked extension from ${extensionPath}`));
|
|
14026
|
+
console.log(chalk146.dim("press Ctrl-C to stop"));
|
|
13904
14027
|
});
|
|
13905
14028
|
process.on("SIGINT", () => {
|
|
13906
14029
|
server.close();
|
|
13907
14030
|
console.log(
|
|
13908
|
-
|
|
14031
|
+
chalk146.bold(
|
|
13909
14032
|
`
|
|
13910
14033
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
13911
14034
|
)
|
|
@@ -13917,7 +14040,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
13917
14040
|
// src/commands/netcap/netcapExtract.ts
|
|
13918
14041
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
13919
14042
|
import { join as join44 } from "path";
|
|
13920
|
-
import
|
|
14043
|
+
import chalk147 from "chalk";
|
|
13921
14044
|
|
|
13922
14045
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
13923
14046
|
import { readFileSync as readFileSync34 } from "fs";
|
|
@@ -14365,8 +14488,8 @@ function netcapExtract(file) {
|
|
|
14365
14488
|
writeFileSync29(outFile, `${JSON.stringify(posts, null, 2)}
|
|
14366
14489
|
`);
|
|
14367
14490
|
console.log(
|
|
14368
|
-
|
|
14369
|
-
|
|
14491
|
+
chalk147.green(`extracted ${posts.length} posts`),
|
|
14492
|
+
chalk147.dim(`-> ${outFile}`)
|
|
14370
14493
|
);
|
|
14371
14494
|
}
|
|
14372
14495
|
|
|
@@ -14387,7 +14510,7 @@ function registerNetcap(program2) {
|
|
|
14387
14510
|
}
|
|
14388
14511
|
|
|
14389
14512
|
// src/commands/news/add/index.ts
|
|
14390
|
-
import
|
|
14513
|
+
import chalk148 from "chalk";
|
|
14391
14514
|
import enquirer8 from "enquirer";
|
|
14392
14515
|
async function add2(url) {
|
|
14393
14516
|
if (!url) {
|
|
@@ -14409,10 +14532,10 @@ async function add2(url) {
|
|
|
14409
14532
|
const { orm } = await getReady();
|
|
14410
14533
|
const added = await addFeed(orm, url);
|
|
14411
14534
|
if (!added) {
|
|
14412
|
-
console.log(
|
|
14535
|
+
console.log(chalk148.yellow("Feed already exists"));
|
|
14413
14536
|
return;
|
|
14414
14537
|
}
|
|
14415
|
-
console.log(
|
|
14538
|
+
console.log(chalk148.green(`Added feed: ${url}`));
|
|
14416
14539
|
}
|
|
14417
14540
|
|
|
14418
14541
|
// src/commands/registerNews.ts
|
|
@@ -14422,7 +14545,7 @@ function registerNews(program2) {
|
|
|
14422
14545
|
}
|
|
14423
14546
|
|
|
14424
14547
|
// src/commands/prompts/printPromptsTable.ts
|
|
14425
|
-
import
|
|
14548
|
+
import chalk149 from "chalk";
|
|
14426
14549
|
function truncate(str, max) {
|
|
14427
14550
|
if (str.length <= max) return str;
|
|
14428
14551
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -14440,14 +14563,14 @@ function printPromptsTable(rows) {
|
|
|
14440
14563
|
"Command".padEnd(commandWidth),
|
|
14441
14564
|
"Repos"
|
|
14442
14565
|
].join(" ");
|
|
14443
|
-
console.log(
|
|
14444
|
-
console.log(
|
|
14566
|
+
console.log(chalk149.dim(header));
|
|
14567
|
+
console.log(chalk149.dim("-".repeat(header.length)));
|
|
14445
14568
|
for (const row of rows) {
|
|
14446
14569
|
const count8 = String(row.count).padStart(countWidth);
|
|
14447
14570
|
const tool = row.tool.padEnd(toolWidth);
|
|
14448
14571
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
14449
14572
|
console.log(
|
|
14450
|
-
`${
|
|
14573
|
+
`${chalk149.yellow(count8)} ${tool} ${command} ${chalk149.dim(row.repos)}`
|
|
14451
14574
|
);
|
|
14452
14575
|
}
|
|
14453
14576
|
}
|
|
@@ -14996,20 +15119,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
14996
15119
|
}
|
|
14997
15120
|
|
|
14998
15121
|
// src/commands/prs/listComments/printComments.ts
|
|
14999
|
-
import
|
|
15122
|
+
import chalk150 from "chalk";
|
|
15000
15123
|
function formatForHuman(comment3) {
|
|
15001
15124
|
if (comment3.type === "review") {
|
|
15002
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
15125
|
+
const stateColor = comment3.state === "APPROVED" ? chalk150.green : comment3.state === "CHANGES_REQUESTED" ? chalk150.red : chalk150.yellow;
|
|
15003
15126
|
return [
|
|
15004
|
-
`${
|
|
15127
|
+
`${chalk150.cyan("Review")} by ${chalk150.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
15005
15128
|
comment3.body,
|
|
15006
15129
|
""
|
|
15007
15130
|
].join("\n");
|
|
15008
15131
|
}
|
|
15009
15132
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
15010
15133
|
return [
|
|
15011
|
-
`${
|
|
15012
|
-
|
|
15134
|
+
`${chalk150.cyan("Line comment")} by ${chalk150.bold(comment3.user)} on ${chalk150.dim(`${comment3.path}${location}`)}`,
|
|
15135
|
+
chalk150.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
15013
15136
|
comment3.body,
|
|
15014
15137
|
""
|
|
15015
15138
|
].join("\n");
|
|
@@ -15099,13 +15222,13 @@ import { execSync as execSync41 } from "child_process";
|
|
|
15099
15222
|
import enquirer9 from "enquirer";
|
|
15100
15223
|
|
|
15101
15224
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
15102
|
-
import
|
|
15225
|
+
import chalk151 from "chalk";
|
|
15103
15226
|
var STATUS_MAP = {
|
|
15104
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
15105
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
15227
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk151.magenta("merged"), date: pr.mergedAt } : null,
|
|
15228
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk151.red("closed"), date: pr.closedAt } : null
|
|
15106
15229
|
};
|
|
15107
15230
|
function defaultStatus(pr) {
|
|
15108
|
-
return { label:
|
|
15231
|
+
return { label: chalk151.green("opened"), date: pr.createdAt };
|
|
15109
15232
|
}
|
|
15110
15233
|
function getStatus2(pr) {
|
|
15111
15234
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -15114,11 +15237,11 @@ function formatDate(dateStr) {
|
|
|
15114
15237
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
15115
15238
|
}
|
|
15116
15239
|
function formatPrHeader(pr, status2) {
|
|
15117
|
-
return `${
|
|
15240
|
+
return `${chalk151.cyan(`#${pr.number}`)} ${pr.title} ${chalk151.dim(`(${pr.author.login},`)} ${status2.label} ${chalk151.dim(`${formatDate(status2.date)})`)}`;
|
|
15118
15241
|
}
|
|
15119
15242
|
function logPrDetails(pr) {
|
|
15120
15243
|
console.log(
|
|
15121
|
-
|
|
15244
|
+
chalk151.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
15122
15245
|
);
|
|
15123
15246
|
console.log();
|
|
15124
15247
|
}
|
|
@@ -15457,10 +15580,10 @@ function registerPrs(program2) {
|
|
|
15457
15580
|
}
|
|
15458
15581
|
|
|
15459
15582
|
// src/commands/ravendb/ravendbAuth.ts
|
|
15460
|
-
import
|
|
15583
|
+
import chalk157 from "chalk";
|
|
15461
15584
|
|
|
15462
15585
|
// src/shared/createConnectionAuth.ts
|
|
15463
|
-
import
|
|
15586
|
+
import chalk152 from "chalk";
|
|
15464
15587
|
function listConnections(connections, format) {
|
|
15465
15588
|
if (connections.length === 0) {
|
|
15466
15589
|
console.log("No connections configured.");
|
|
@@ -15473,7 +15596,7 @@ function listConnections(connections, format) {
|
|
|
15473
15596
|
function removeConnection(connections, name, save) {
|
|
15474
15597
|
const filtered = connections.filter((c) => c.name !== name);
|
|
15475
15598
|
if (filtered.length === connections.length) {
|
|
15476
|
-
console.error(
|
|
15599
|
+
console.error(chalk152.red(`Connection "${name}" not found.`));
|
|
15477
15600
|
process.exit(1);
|
|
15478
15601
|
}
|
|
15479
15602
|
save(filtered);
|
|
@@ -15519,15 +15642,15 @@ function saveConnections(connections) {
|
|
|
15519
15642
|
}
|
|
15520
15643
|
|
|
15521
15644
|
// src/commands/ravendb/promptConnection.ts
|
|
15522
|
-
import
|
|
15645
|
+
import chalk155 from "chalk";
|
|
15523
15646
|
|
|
15524
15647
|
// src/commands/ravendb/selectOpSecret.ts
|
|
15525
|
-
import
|
|
15648
|
+
import chalk154 from "chalk";
|
|
15526
15649
|
import Enquirer2 from "enquirer";
|
|
15527
15650
|
|
|
15528
15651
|
// src/commands/ravendb/searchItems.ts
|
|
15529
15652
|
import { execSync as execSync45 } from "child_process";
|
|
15530
|
-
import
|
|
15653
|
+
import chalk153 from "chalk";
|
|
15531
15654
|
function opExec(args) {
|
|
15532
15655
|
return execSync45(`op ${args}`, {
|
|
15533
15656
|
encoding: "utf8",
|
|
@@ -15540,7 +15663,7 @@ function searchItems(search2) {
|
|
|
15540
15663
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
15541
15664
|
} catch {
|
|
15542
15665
|
console.error(
|
|
15543
|
-
|
|
15666
|
+
chalk153.red(
|
|
15544
15667
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
15545
15668
|
)
|
|
15546
15669
|
);
|
|
@@ -15554,7 +15677,7 @@ function getItemFields(itemId) {
|
|
|
15554
15677
|
const item = JSON.parse(opExec(`item get "${itemId}" --format=json`));
|
|
15555
15678
|
return item.fields.filter((f) => f.reference && f.label);
|
|
15556
15679
|
} catch {
|
|
15557
|
-
console.error(
|
|
15680
|
+
console.error(chalk153.red("Failed to get item details from 1Password."));
|
|
15558
15681
|
process.exit(1);
|
|
15559
15682
|
}
|
|
15560
15683
|
}
|
|
@@ -15573,7 +15696,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15573
15696
|
}).run();
|
|
15574
15697
|
const items2 = searchItems(search2);
|
|
15575
15698
|
if (items2.length === 0) {
|
|
15576
|
-
console.error(
|
|
15699
|
+
console.error(chalk154.red(`No items found matching "${search2}".`));
|
|
15577
15700
|
process.exit(1);
|
|
15578
15701
|
}
|
|
15579
15702
|
const itemId = await selectOne(
|
|
@@ -15582,7 +15705,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15582
15705
|
);
|
|
15583
15706
|
const fields = getItemFields(itemId);
|
|
15584
15707
|
if (fields.length === 0) {
|
|
15585
|
-
console.error(
|
|
15708
|
+
console.error(chalk154.red("No fields with references found on this item."));
|
|
15586
15709
|
process.exit(1);
|
|
15587
15710
|
}
|
|
15588
15711
|
const ref = await selectOne(
|
|
@@ -15596,7 +15719,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15596
15719
|
async function promptConnection(existingNames) {
|
|
15597
15720
|
const name = await promptInput("name", "Connection name:");
|
|
15598
15721
|
if (existingNames.includes(name)) {
|
|
15599
|
-
console.error(
|
|
15722
|
+
console.error(chalk155.red(`Connection "${name}" already exists.`));
|
|
15600
15723
|
process.exit(1);
|
|
15601
15724
|
}
|
|
15602
15725
|
const url = await promptInput(
|
|
@@ -15605,22 +15728,22 @@ async function promptConnection(existingNames) {
|
|
|
15605
15728
|
);
|
|
15606
15729
|
const database = await promptInput("database", "Database name:");
|
|
15607
15730
|
if (!name || !url || !database) {
|
|
15608
|
-
console.error(
|
|
15731
|
+
console.error(chalk155.red("All fields are required."));
|
|
15609
15732
|
process.exit(1);
|
|
15610
15733
|
}
|
|
15611
15734
|
const apiKeyRef = await selectOpSecret();
|
|
15612
|
-
console.log(
|
|
15735
|
+
console.log(chalk155.dim(`Using: ${apiKeyRef}`));
|
|
15613
15736
|
return { name, url, database, apiKeyRef };
|
|
15614
15737
|
}
|
|
15615
15738
|
|
|
15616
15739
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
15617
|
-
import
|
|
15740
|
+
import chalk156 from "chalk";
|
|
15618
15741
|
function ravendbSetConnection(name) {
|
|
15619
15742
|
const raw = loadGlobalConfigRaw();
|
|
15620
15743
|
const ravendb = raw.ravendb ?? {};
|
|
15621
15744
|
const connections = ravendb.connections ?? [];
|
|
15622
15745
|
if (!connections.some((c) => c.name === name)) {
|
|
15623
|
-
console.error(
|
|
15746
|
+
console.error(chalk156.red(`Connection "${name}" not found.`));
|
|
15624
15747
|
console.error(
|
|
15625
15748
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
15626
15749
|
);
|
|
@@ -15636,16 +15759,16 @@ function ravendbSetConnection(name) {
|
|
|
15636
15759
|
var ravendbAuth = createConnectionAuth({
|
|
15637
15760
|
load: loadConnections,
|
|
15638
15761
|
save: saveConnections,
|
|
15639
|
-
format: (c) => `${
|
|
15762
|
+
format: (c) => `${chalk157.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
15640
15763
|
promptNew: promptConnection,
|
|
15641
15764
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
15642
15765
|
});
|
|
15643
15766
|
|
|
15644
15767
|
// src/commands/ravendb/ravendbCollections.ts
|
|
15645
|
-
import
|
|
15768
|
+
import chalk161 from "chalk";
|
|
15646
15769
|
|
|
15647
15770
|
// src/commands/ravendb/ravenFetch.ts
|
|
15648
|
-
import
|
|
15771
|
+
import chalk159 from "chalk";
|
|
15649
15772
|
|
|
15650
15773
|
// src/commands/ravendb/getAccessToken.ts
|
|
15651
15774
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -15682,10 +15805,10 @@ ${errorText}`
|
|
|
15682
15805
|
|
|
15683
15806
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
15684
15807
|
import { execSync as execSync46 } from "child_process";
|
|
15685
|
-
import
|
|
15808
|
+
import chalk158 from "chalk";
|
|
15686
15809
|
function resolveOpSecret(reference) {
|
|
15687
15810
|
if (!reference.startsWith("op://")) {
|
|
15688
|
-
console.error(
|
|
15811
|
+
console.error(chalk158.red(`Invalid secret reference: must start with op://`));
|
|
15689
15812
|
process.exit(1);
|
|
15690
15813
|
}
|
|
15691
15814
|
try {
|
|
@@ -15695,7 +15818,7 @@ function resolveOpSecret(reference) {
|
|
|
15695
15818
|
}).trim();
|
|
15696
15819
|
} catch {
|
|
15697
15820
|
console.error(
|
|
15698
|
-
|
|
15821
|
+
chalk158.red(
|
|
15699
15822
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
15700
15823
|
)
|
|
15701
15824
|
);
|
|
@@ -15722,7 +15845,7 @@ async function ravenFetch(connection, path57) {
|
|
|
15722
15845
|
if (!response.ok) {
|
|
15723
15846
|
const body = await response.text();
|
|
15724
15847
|
console.error(
|
|
15725
|
-
|
|
15848
|
+
chalk159.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
15726
15849
|
);
|
|
15727
15850
|
console.error(body.substring(0, 500));
|
|
15728
15851
|
process.exit(1);
|
|
@@ -15731,7 +15854,7 @@ async function ravenFetch(connection, path57) {
|
|
|
15731
15854
|
}
|
|
15732
15855
|
|
|
15733
15856
|
// src/commands/ravendb/resolveConnection.ts
|
|
15734
|
-
import
|
|
15857
|
+
import chalk160 from "chalk";
|
|
15735
15858
|
function loadRavendb() {
|
|
15736
15859
|
const raw = loadGlobalConfigRaw();
|
|
15737
15860
|
const ravendb = raw.ravendb;
|
|
@@ -15745,7 +15868,7 @@ function resolveConnection(name) {
|
|
|
15745
15868
|
const connectionName = name ?? defaultConnection;
|
|
15746
15869
|
if (!connectionName) {
|
|
15747
15870
|
console.error(
|
|
15748
|
-
|
|
15871
|
+
chalk160.red(
|
|
15749
15872
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
15750
15873
|
)
|
|
15751
15874
|
);
|
|
@@ -15753,7 +15876,7 @@ function resolveConnection(name) {
|
|
|
15753
15876
|
}
|
|
15754
15877
|
const connection = connections.find((c) => c.name === connectionName);
|
|
15755
15878
|
if (!connection) {
|
|
15756
|
-
console.error(
|
|
15879
|
+
console.error(chalk160.red(`Connection "${connectionName}" not found.`));
|
|
15757
15880
|
console.error(
|
|
15758
15881
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
15759
15882
|
);
|
|
@@ -15784,15 +15907,15 @@ async function ravendbCollections(connectionName) {
|
|
|
15784
15907
|
return;
|
|
15785
15908
|
}
|
|
15786
15909
|
for (const c of collections) {
|
|
15787
|
-
console.log(`${
|
|
15910
|
+
console.log(`${chalk161.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
15788
15911
|
}
|
|
15789
15912
|
}
|
|
15790
15913
|
|
|
15791
15914
|
// src/commands/ravendb/ravendbQuery.ts
|
|
15792
|
-
import
|
|
15915
|
+
import chalk163 from "chalk";
|
|
15793
15916
|
|
|
15794
15917
|
// src/commands/ravendb/fetchAllPages.ts
|
|
15795
|
-
import
|
|
15918
|
+
import chalk162 from "chalk";
|
|
15796
15919
|
|
|
15797
15920
|
// src/commands/ravendb/buildQueryPath.ts
|
|
15798
15921
|
function buildQueryPath(opts) {
|
|
@@ -15830,7 +15953,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15830
15953
|
allResults.push(...results);
|
|
15831
15954
|
start3 += results.length;
|
|
15832
15955
|
process.stderr.write(
|
|
15833
|
-
`\r${
|
|
15956
|
+
`\r${chalk162.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
15834
15957
|
);
|
|
15835
15958
|
if (start3 >= totalResults) break;
|
|
15836
15959
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -15845,7 +15968,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15845
15968
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
15846
15969
|
const resolved = resolveArgs(connectionName, collection);
|
|
15847
15970
|
if (!resolved.collection && !options2.query) {
|
|
15848
|
-
console.error(
|
|
15971
|
+
console.error(chalk163.red("Provide a collection name or --query filter."));
|
|
15849
15972
|
process.exit(1);
|
|
15850
15973
|
}
|
|
15851
15974
|
const { collection: col } = resolved;
|
|
@@ -15883,7 +16006,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
15883
16006
|
import * as path28 from "path";
|
|
15884
16007
|
|
|
15885
16008
|
// src/commands/refactor/logViolations.ts
|
|
15886
|
-
import
|
|
16009
|
+
import chalk164 from "chalk";
|
|
15887
16010
|
var DEFAULT_MAX_LINES = 100;
|
|
15888
16011
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
15889
16012
|
if (violations.length === 0) {
|
|
@@ -15892,43 +16015,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
15892
16015
|
}
|
|
15893
16016
|
return;
|
|
15894
16017
|
}
|
|
15895
|
-
console.error(
|
|
16018
|
+
console.error(chalk164.red(`
|
|
15896
16019
|
Refactor check failed:
|
|
15897
16020
|
`));
|
|
15898
|
-
console.error(
|
|
16021
|
+
console.error(chalk164.red(` The following files exceed ${maxLines} lines:
|
|
15899
16022
|
`));
|
|
15900
16023
|
for (const violation of violations) {
|
|
15901
|
-
console.error(
|
|
16024
|
+
console.error(chalk164.red(` ${violation.file} (${violation.lines} lines)`));
|
|
15902
16025
|
}
|
|
15903
16026
|
console.error(
|
|
15904
|
-
|
|
16027
|
+
chalk164.yellow(
|
|
15905
16028
|
`
|
|
15906
16029
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
15907
16030
|
way to refactor it, ignore it with:
|
|
15908
16031
|
`
|
|
15909
16032
|
)
|
|
15910
16033
|
);
|
|
15911
|
-
console.error(
|
|
16034
|
+
console.error(chalk164.gray(` assist refactor ignore <file>
|
|
15912
16035
|
`));
|
|
15913
16036
|
if (process.env.CLAUDECODE) {
|
|
15914
|
-
console.error(
|
|
16037
|
+
console.error(chalk164.cyan(`
|
|
15915
16038
|
## Extracting Code to New Files
|
|
15916
16039
|
`));
|
|
15917
16040
|
console.error(
|
|
15918
|
-
|
|
16041
|
+
chalk164.cyan(
|
|
15919
16042
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
15920
16043
|
`
|
|
15921
16044
|
)
|
|
15922
16045
|
);
|
|
15923
16046
|
console.error(
|
|
15924
|
-
|
|
16047
|
+
chalk164.cyan(
|
|
15925
16048
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
15926
16049
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
15927
16050
|
`
|
|
15928
16051
|
)
|
|
15929
16052
|
);
|
|
15930
16053
|
console.error(
|
|
15931
|
-
|
|
16054
|
+
chalk164.cyan(
|
|
15932
16055
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
15933
16056
|
domains, move it to a common/shared folder.
|
|
15934
16057
|
`
|
|
@@ -16084,7 +16207,7 @@ async function check(pattern2, options2) {
|
|
|
16084
16207
|
|
|
16085
16208
|
// src/commands/refactor/extract/index.ts
|
|
16086
16209
|
import path35 from "path";
|
|
16087
|
-
import
|
|
16210
|
+
import chalk167 from "chalk";
|
|
16088
16211
|
|
|
16089
16212
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
16090
16213
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -16659,23 +16782,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
16659
16782
|
|
|
16660
16783
|
// src/commands/refactor/extract/displayPlan.ts
|
|
16661
16784
|
import path32 from "path";
|
|
16662
|
-
import
|
|
16785
|
+
import chalk165 from "chalk";
|
|
16663
16786
|
function section(title) {
|
|
16664
16787
|
return `
|
|
16665
|
-
${
|
|
16788
|
+
${chalk165.cyan(title)}`;
|
|
16666
16789
|
}
|
|
16667
16790
|
function displayImporters(plan2, cwd) {
|
|
16668
16791
|
if (plan2.importersToUpdate.length === 0) return;
|
|
16669
16792
|
console.log(section("Update importers:"));
|
|
16670
16793
|
for (const imp of plan2.importersToUpdate) {
|
|
16671
16794
|
const rel = path32.relative(cwd, imp.file.getFilePath());
|
|
16672
|
-
console.log(` ${
|
|
16795
|
+
console.log(` ${chalk165.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
16673
16796
|
}
|
|
16674
16797
|
}
|
|
16675
16798
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
16676
|
-
console.log(
|
|
16799
|
+
console.log(chalk165.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
16677
16800
|
`));
|
|
16678
|
-
console.log(` ${
|
|
16801
|
+
console.log(` ${chalk165.cyan("Functions to move:")}`);
|
|
16679
16802
|
for (const name of plan2.extractedNames) {
|
|
16680
16803
|
console.log(` ${name}`);
|
|
16681
16804
|
}
|
|
@@ -16709,7 +16832,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
16709
16832
|
|
|
16710
16833
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
16711
16834
|
import path34 from "path";
|
|
16712
|
-
import
|
|
16835
|
+
import chalk166 from "chalk";
|
|
16713
16836
|
import { Project as Project4 } from "ts-morph";
|
|
16714
16837
|
|
|
16715
16838
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -16769,7 +16892,7 @@ function loadProjectFile(file) {
|
|
|
16769
16892
|
});
|
|
16770
16893
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
16771
16894
|
if (!sourceFile) {
|
|
16772
|
-
console.log(
|
|
16895
|
+
console.log(chalk166.red(`File not found in project: ${file}`));
|
|
16773
16896
|
process.exit(1);
|
|
16774
16897
|
}
|
|
16775
16898
|
return { project, sourceFile };
|
|
@@ -16792,19 +16915,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
16792
16915
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
16793
16916
|
if (options2.apply) {
|
|
16794
16917
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
16795
|
-
console.log(
|
|
16918
|
+
console.log(chalk167.green("\nExtraction complete"));
|
|
16796
16919
|
} else {
|
|
16797
|
-
console.log(
|
|
16920
|
+
console.log(chalk167.dim("\nDry run. Use --apply to execute."));
|
|
16798
16921
|
}
|
|
16799
16922
|
}
|
|
16800
16923
|
|
|
16801
16924
|
// src/commands/refactor/ignore.ts
|
|
16802
16925
|
import fs24 from "fs";
|
|
16803
|
-
import
|
|
16926
|
+
import chalk168 from "chalk";
|
|
16804
16927
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
16805
16928
|
function ignore2(file) {
|
|
16806
16929
|
if (!fs24.existsSync(file)) {
|
|
16807
|
-
console.error(
|
|
16930
|
+
console.error(chalk168.red(`Error: File does not exist: ${file}`));
|
|
16808
16931
|
process.exit(1);
|
|
16809
16932
|
}
|
|
16810
16933
|
const content = fs24.readFileSync(file, "utf8");
|
|
@@ -16820,7 +16943,7 @@ function ignore2(file) {
|
|
|
16820
16943
|
fs24.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
16821
16944
|
}
|
|
16822
16945
|
console.log(
|
|
16823
|
-
|
|
16946
|
+
chalk168.green(
|
|
16824
16947
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
16825
16948
|
)
|
|
16826
16949
|
);
|
|
@@ -16829,12 +16952,12 @@ function ignore2(file) {
|
|
|
16829
16952
|
// src/commands/refactor/rename/index.ts
|
|
16830
16953
|
import fs27 from "fs";
|
|
16831
16954
|
import path40 from "path";
|
|
16832
|
-
import
|
|
16955
|
+
import chalk171 from "chalk";
|
|
16833
16956
|
|
|
16834
16957
|
// src/commands/refactor/rename/applyRename.ts
|
|
16835
16958
|
import fs26 from "fs";
|
|
16836
16959
|
import path37 from "path";
|
|
16837
|
-
import
|
|
16960
|
+
import chalk169 from "chalk";
|
|
16838
16961
|
|
|
16839
16962
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
16840
16963
|
import path36 from "path";
|
|
@@ -16939,13 +17062,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
16939
17062
|
const updatedContents = applyRewrites(rewrites);
|
|
16940
17063
|
for (const [file, content] of updatedContents) {
|
|
16941
17064
|
fs26.writeFileSync(file, content, "utf8");
|
|
16942
|
-
console.log(
|
|
17065
|
+
console.log(chalk169.cyan(` Updated imports in ${path37.relative(cwd, file)}`));
|
|
16943
17066
|
}
|
|
16944
17067
|
const destDir = path37.dirname(destPath);
|
|
16945
17068
|
if (!fs26.existsSync(destDir)) fs26.mkdirSync(destDir, { recursive: true });
|
|
16946
17069
|
fs26.renameSync(sourcePath, destPath);
|
|
16947
17070
|
console.log(
|
|
16948
|
-
|
|
17071
|
+
chalk169.white(
|
|
16949
17072
|
` Moved ${path37.relative(cwd, sourcePath)} \u2192 ${path37.relative(cwd, destPath)}`
|
|
16950
17073
|
)
|
|
16951
17074
|
);
|
|
@@ -17032,16 +17155,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
17032
17155
|
|
|
17033
17156
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
17034
17157
|
import path39 from "path";
|
|
17035
|
-
import
|
|
17158
|
+
import chalk170 from "chalk";
|
|
17036
17159
|
function printRenamePreview(rewrites, cwd) {
|
|
17037
17160
|
for (const rewrite of rewrites) {
|
|
17038
17161
|
console.log(
|
|
17039
|
-
|
|
17162
|
+
chalk170.dim(
|
|
17040
17163
|
` ${path39.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
17041
17164
|
)
|
|
17042
17165
|
);
|
|
17043
17166
|
}
|
|
17044
|
-
console.log(
|
|
17167
|
+
console.log(chalk170.dim("Dry run. Use --apply to execute."));
|
|
17045
17168
|
}
|
|
17046
17169
|
|
|
17047
17170
|
// src/commands/refactor/rename/index.ts
|
|
@@ -17052,20 +17175,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
17052
17175
|
const relSource = path40.relative(cwd, sourcePath);
|
|
17053
17176
|
const relDest = path40.relative(cwd, destPath);
|
|
17054
17177
|
if (!fs27.existsSync(sourcePath)) {
|
|
17055
|
-
console.log(
|
|
17178
|
+
console.log(chalk171.red(`File not found: ${source}`));
|
|
17056
17179
|
process.exit(1);
|
|
17057
17180
|
}
|
|
17058
17181
|
if (destPath !== sourcePath && fs27.existsSync(destPath)) {
|
|
17059
|
-
console.log(
|
|
17182
|
+
console.log(chalk171.red(`Destination already exists: ${destination}`));
|
|
17060
17183
|
process.exit(1);
|
|
17061
17184
|
}
|
|
17062
|
-
console.log(
|
|
17063
|
-
console.log(
|
|
17064
|
-
console.log(
|
|
17185
|
+
console.log(chalk171.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
17186
|
+
console.log(chalk171.dim("Loading project..."));
|
|
17187
|
+
console.log(chalk171.dim("Scanning imports across the project..."));
|
|
17065
17188
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
17066
17189
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
17067
17190
|
console.log(
|
|
17068
|
-
|
|
17191
|
+
chalk171.dim(
|
|
17069
17192
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
17070
17193
|
)
|
|
17071
17194
|
);
|
|
@@ -17074,11 +17197,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
17074
17197
|
return;
|
|
17075
17198
|
}
|
|
17076
17199
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
17077
|
-
console.log(
|
|
17200
|
+
console.log(chalk171.green("Done"));
|
|
17078
17201
|
}
|
|
17079
17202
|
|
|
17080
17203
|
// src/commands/refactor/renameSymbol/index.ts
|
|
17081
|
-
import
|
|
17204
|
+
import chalk172 from "chalk";
|
|
17082
17205
|
|
|
17083
17206
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
17084
17207
|
import { SyntaxKind as SyntaxKind14 } from "ts-morph";
|
|
@@ -17124,33 +17247,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
17124
17247
|
const { project, sourceFile } = loadProjectFile(file);
|
|
17125
17248
|
const symbol = findSymbol(sourceFile, oldName);
|
|
17126
17249
|
if (!symbol) {
|
|
17127
|
-
console.log(
|
|
17250
|
+
console.log(chalk172.red(`Symbol "${oldName}" not found in ${file}`));
|
|
17128
17251
|
process.exit(1);
|
|
17129
17252
|
}
|
|
17130
17253
|
const grouped = groupReferences(symbol, cwd);
|
|
17131
17254
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
17132
17255
|
console.log(
|
|
17133
|
-
|
|
17256
|
+
chalk172.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
17134
17257
|
`)
|
|
17135
17258
|
);
|
|
17136
17259
|
for (const [refFile, lines] of grouped) {
|
|
17137
17260
|
console.log(
|
|
17138
|
-
` ${
|
|
17261
|
+
` ${chalk172.dim(refFile)}: lines ${chalk172.cyan(lines.join(", "))}`
|
|
17139
17262
|
);
|
|
17140
17263
|
}
|
|
17141
17264
|
if (options2.apply) {
|
|
17142
17265
|
symbol.rename(newName);
|
|
17143
17266
|
await project.save();
|
|
17144
|
-
console.log(
|
|
17267
|
+
console.log(chalk172.green(`
|
|
17145
17268
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
17146
17269
|
} else {
|
|
17147
|
-
console.log(
|
|
17270
|
+
console.log(chalk172.dim("\nDry run. Use --apply to execute."));
|
|
17148
17271
|
}
|
|
17149
17272
|
}
|
|
17150
17273
|
|
|
17151
17274
|
// src/commands/refactor/restructure/index.ts
|
|
17152
17275
|
import path48 from "path";
|
|
17153
|
-
import
|
|
17276
|
+
import chalk175 from "chalk";
|
|
17154
17277
|
|
|
17155
17278
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
17156
17279
|
import path42 from "path";
|
|
@@ -17229,50 +17352,50 @@ function clusterFiles(graph) {
|
|
|
17229
17352
|
|
|
17230
17353
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
17231
17354
|
import path44 from "path";
|
|
17232
|
-
import
|
|
17355
|
+
import chalk173 from "chalk";
|
|
17233
17356
|
function relPath(filePath) {
|
|
17234
17357
|
return path44.relative(process.cwd(), filePath);
|
|
17235
17358
|
}
|
|
17236
17359
|
function displayMoves(plan2) {
|
|
17237
17360
|
if (plan2.moves.length === 0) return;
|
|
17238
|
-
console.log(
|
|
17361
|
+
console.log(chalk173.bold("\nFile moves:"));
|
|
17239
17362
|
for (const move2 of plan2.moves) {
|
|
17240
17363
|
console.log(
|
|
17241
|
-
` ${
|
|
17364
|
+
` ${chalk173.red(relPath(move2.from))} \u2192 ${chalk173.green(relPath(move2.to))}`
|
|
17242
17365
|
);
|
|
17243
|
-
console.log(
|
|
17366
|
+
console.log(chalk173.dim(` ${move2.reason}`));
|
|
17244
17367
|
}
|
|
17245
17368
|
}
|
|
17246
17369
|
function displayRewrites(rewrites) {
|
|
17247
17370
|
if (rewrites.length === 0) return;
|
|
17248
17371
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
17249
|
-
console.log(
|
|
17372
|
+
console.log(chalk173.bold(`
|
|
17250
17373
|
Import rewrites (${affectedFiles.size} files):`));
|
|
17251
17374
|
for (const file of affectedFiles) {
|
|
17252
|
-
console.log(` ${
|
|
17375
|
+
console.log(` ${chalk173.cyan(relPath(file))}:`);
|
|
17253
17376
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
17254
17377
|
(r) => r.file === file
|
|
17255
17378
|
)) {
|
|
17256
17379
|
console.log(
|
|
17257
|
-
` ${
|
|
17380
|
+
` ${chalk173.red(`"${oldSpecifier}"`)} \u2192 ${chalk173.green(`"${newSpecifier}"`)}`
|
|
17258
17381
|
);
|
|
17259
17382
|
}
|
|
17260
17383
|
}
|
|
17261
17384
|
}
|
|
17262
17385
|
function displayPlan2(plan2) {
|
|
17263
17386
|
if (plan2.warnings.length > 0) {
|
|
17264
|
-
console.log(
|
|
17265
|
-
for (const w of plan2.warnings) console.log(
|
|
17387
|
+
console.log(chalk173.yellow("\nWarnings:"));
|
|
17388
|
+
for (const w of plan2.warnings) console.log(chalk173.yellow(` ${w}`));
|
|
17266
17389
|
}
|
|
17267
17390
|
if (plan2.newDirectories.length > 0) {
|
|
17268
|
-
console.log(
|
|
17391
|
+
console.log(chalk173.bold("\nNew directories:"));
|
|
17269
17392
|
for (const dir of plan2.newDirectories)
|
|
17270
|
-
console.log(
|
|
17393
|
+
console.log(chalk173.green(` ${dir}/`));
|
|
17271
17394
|
}
|
|
17272
17395
|
displayMoves(plan2);
|
|
17273
17396
|
displayRewrites(plan2.rewrites);
|
|
17274
17397
|
console.log(
|
|
17275
|
-
|
|
17398
|
+
chalk173.dim(
|
|
17276
17399
|
`
|
|
17277
17400
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
17278
17401
|
)
|
|
@@ -17282,18 +17405,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
17282
17405
|
// src/commands/refactor/restructure/executePlan.ts
|
|
17283
17406
|
import fs28 from "fs";
|
|
17284
17407
|
import path45 from "path";
|
|
17285
|
-
import
|
|
17408
|
+
import chalk174 from "chalk";
|
|
17286
17409
|
function executePlan(plan2) {
|
|
17287
17410
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
17288
17411
|
for (const [file, content] of updatedContents) {
|
|
17289
17412
|
fs28.writeFileSync(file, content, "utf8");
|
|
17290
17413
|
console.log(
|
|
17291
|
-
|
|
17414
|
+
chalk174.cyan(` Rewrote imports in ${path45.relative(process.cwd(), file)}`)
|
|
17292
17415
|
);
|
|
17293
17416
|
}
|
|
17294
17417
|
for (const dir of plan2.newDirectories) {
|
|
17295
17418
|
fs28.mkdirSync(dir, { recursive: true });
|
|
17296
|
-
console.log(
|
|
17419
|
+
console.log(chalk174.green(` Created ${path45.relative(process.cwd(), dir)}/`));
|
|
17297
17420
|
}
|
|
17298
17421
|
for (const move2 of plan2.moves) {
|
|
17299
17422
|
const targetDir = path45.dirname(move2.to);
|
|
@@ -17302,7 +17425,7 @@ function executePlan(plan2) {
|
|
|
17302
17425
|
}
|
|
17303
17426
|
fs28.renameSync(move2.from, move2.to);
|
|
17304
17427
|
console.log(
|
|
17305
|
-
|
|
17428
|
+
chalk174.white(
|
|
17306
17429
|
` Moved ${path45.relative(process.cwd(), move2.from)} \u2192 ${path45.relative(process.cwd(), move2.to)}`
|
|
17307
17430
|
)
|
|
17308
17431
|
);
|
|
@@ -17317,7 +17440,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
17317
17440
|
if (entries.length === 0) {
|
|
17318
17441
|
fs28.rmdirSync(dir);
|
|
17319
17442
|
console.log(
|
|
17320
|
-
|
|
17443
|
+
chalk174.dim(
|
|
17321
17444
|
` Removed empty directory ${path45.relative(process.cwd(), dir)}`
|
|
17322
17445
|
)
|
|
17323
17446
|
);
|
|
@@ -17450,22 +17573,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
17450
17573
|
const targetPattern = pattern2 ?? "src";
|
|
17451
17574
|
const files = findSourceFiles2(targetPattern);
|
|
17452
17575
|
if (files.length === 0) {
|
|
17453
|
-
console.log(
|
|
17576
|
+
console.log(chalk175.yellow("No files found matching pattern"));
|
|
17454
17577
|
return;
|
|
17455
17578
|
}
|
|
17456
17579
|
const tsConfigPath = path48.resolve("tsconfig.json");
|
|
17457
17580
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
17458
17581
|
if (plan2.moves.length === 0) {
|
|
17459
|
-
console.log(
|
|
17582
|
+
console.log(chalk175.green("No restructuring needed"));
|
|
17460
17583
|
return;
|
|
17461
17584
|
}
|
|
17462
17585
|
displayPlan2(plan2);
|
|
17463
17586
|
if (options2.apply) {
|
|
17464
|
-
console.log(
|
|
17587
|
+
console.log(chalk175.bold("\nApplying changes..."));
|
|
17465
17588
|
executePlan(plan2);
|
|
17466
|
-
console.log(
|
|
17589
|
+
console.log(chalk175.green("\nRestructuring complete"));
|
|
17467
17590
|
} else {
|
|
17468
|
-
console.log(
|
|
17591
|
+
console.log(chalk175.dim("\nDry run. Use --apply to execute."));
|
|
17469
17592
|
}
|
|
17470
17593
|
}
|
|
17471
17594
|
|
|
@@ -18038,18 +18161,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
18038
18161
|
}
|
|
18039
18162
|
|
|
18040
18163
|
// src/commands/review/warnOutOfDiff.ts
|
|
18041
|
-
import
|
|
18164
|
+
import chalk176 from "chalk";
|
|
18042
18165
|
function warnOutOfDiff(outOfDiff) {
|
|
18043
18166
|
if (outOfDiff.length === 0) return;
|
|
18044
18167
|
console.warn(
|
|
18045
|
-
|
|
18168
|
+
chalk176.yellow(
|
|
18046
18169
|
`Skipped ${outOfDiff.length} finding(s) whose lines fall outside the PR diff (GitHub would silently drop these):`
|
|
18047
18170
|
)
|
|
18048
18171
|
);
|
|
18049
18172
|
for (const finding of outOfDiff) {
|
|
18050
18173
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
18051
18174
|
console.warn(
|
|
18052
|
-
` ${
|
|
18175
|
+
` ${chalk176.yellow("\xB7")} ${finding.title} ${chalk176.dim(
|
|
18053
18176
|
`(${finding.file}:${range})`
|
|
18054
18177
|
)}`
|
|
18055
18178
|
);
|
|
@@ -18068,18 +18191,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
18068
18191
|
}
|
|
18069
18192
|
|
|
18070
18193
|
// src/commands/review/warnUnlocated.ts
|
|
18071
|
-
import
|
|
18194
|
+
import chalk177 from "chalk";
|
|
18072
18195
|
function warnUnlocated(unlocated) {
|
|
18073
18196
|
if (unlocated.length === 0) return;
|
|
18074
18197
|
console.warn(
|
|
18075
|
-
|
|
18198
|
+
chalk177.yellow(
|
|
18076
18199
|
`Skipped ${unlocated.length} finding(s) without a parseable file:line:`
|
|
18077
18200
|
)
|
|
18078
18201
|
);
|
|
18079
18202
|
for (const finding of unlocated) {
|
|
18080
|
-
const where = finding.location ||
|
|
18203
|
+
const where = finding.location || chalk177.dim("missing");
|
|
18081
18204
|
console.warn(
|
|
18082
|
-
` ${
|
|
18205
|
+
` ${chalk177.yellow("\xB7")} ${finding.title} ${chalk177.dim(`(${where})`)}`
|
|
18083
18206
|
);
|
|
18084
18207
|
}
|
|
18085
18208
|
}
|
|
@@ -19251,7 +19374,7 @@ function registerReview(program2) {
|
|
|
19251
19374
|
}
|
|
19252
19375
|
|
|
19253
19376
|
// src/commands/seq/seqAuth.ts
|
|
19254
|
-
import
|
|
19377
|
+
import chalk179 from "chalk";
|
|
19255
19378
|
|
|
19256
19379
|
// src/commands/seq/loadConnections.ts
|
|
19257
19380
|
function loadConnections2() {
|
|
@@ -19280,10 +19403,10 @@ function setDefaultConnection(name) {
|
|
|
19280
19403
|
}
|
|
19281
19404
|
|
|
19282
19405
|
// src/shared/assertUniqueName.ts
|
|
19283
|
-
import
|
|
19406
|
+
import chalk178 from "chalk";
|
|
19284
19407
|
function assertUniqueName(existingNames, name) {
|
|
19285
19408
|
if (existingNames.includes(name)) {
|
|
19286
|
-
console.error(
|
|
19409
|
+
console.error(chalk178.red(`Connection "${name}" already exists.`));
|
|
19287
19410
|
process.exit(1);
|
|
19288
19411
|
}
|
|
19289
19412
|
}
|
|
@@ -19301,16 +19424,16 @@ async function promptConnection2(existingNames) {
|
|
|
19301
19424
|
var seqAuth = createConnectionAuth({
|
|
19302
19425
|
load: loadConnections2,
|
|
19303
19426
|
save: saveConnections2,
|
|
19304
|
-
format: (c) => `${
|
|
19427
|
+
format: (c) => `${chalk179.bold(c.name)} ${c.url}`,
|
|
19305
19428
|
promptNew: promptConnection2,
|
|
19306
19429
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
19307
19430
|
});
|
|
19308
19431
|
|
|
19309
19432
|
// src/commands/seq/seqQuery.ts
|
|
19310
|
-
import
|
|
19433
|
+
import chalk183 from "chalk";
|
|
19311
19434
|
|
|
19312
19435
|
// src/commands/seq/fetchSeq.ts
|
|
19313
|
-
import
|
|
19436
|
+
import chalk180 from "chalk";
|
|
19314
19437
|
async function fetchSeq(conn, path57, params) {
|
|
19315
19438
|
const url = `${conn.url}${path57}?${params}`;
|
|
19316
19439
|
const response = await fetch(url, {
|
|
@@ -19321,7 +19444,7 @@ async function fetchSeq(conn, path57, params) {
|
|
|
19321
19444
|
});
|
|
19322
19445
|
if (!response.ok) {
|
|
19323
19446
|
const body = await response.text();
|
|
19324
|
-
console.error(
|
|
19447
|
+
console.error(chalk180.red(`Seq returned ${response.status}: ${body}`));
|
|
19325
19448
|
process.exit(1);
|
|
19326
19449
|
}
|
|
19327
19450
|
return response;
|
|
@@ -19335,8 +19458,8 @@ function filterToSql(filter) {
|
|
|
19335
19458
|
// src/commands/seq/fetchSeqData.ts
|
|
19336
19459
|
function buildDataParams(filter, count8, from, to) {
|
|
19337
19460
|
const sqlFilter = filterToSql(filter);
|
|
19338
|
-
const
|
|
19339
|
-
const params = new URLSearchParams({ q:
|
|
19461
|
+
const sql10 = `select @Timestamp, @Level, @Exception, @Message from stream where ${sqlFilter} order by @Timestamp desc limit ${count8}`;
|
|
19462
|
+
const params = new URLSearchParams({ q: sql10 });
|
|
19340
19463
|
if (from) params.set("rangeStartUtc", from);
|
|
19341
19464
|
if (to) params.set("rangeEndUtc", to);
|
|
19342
19465
|
return params;
|
|
@@ -19380,23 +19503,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
19380
19503
|
}
|
|
19381
19504
|
|
|
19382
19505
|
// src/commands/seq/formatEvent.ts
|
|
19383
|
-
import
|
|
19506
|
+
import chalk181 from "chalk";
|
|
19384
19507
|
function levelColor(level) {
|
|
19385
19508
|
switch (level) {
|
|
19386
19509
|
case "Fatal":
|
|
19387
|
-
return
|
|
19510
|
+
return chalk181.bgRed.white;
|
|
19388
19511
|
case "Error":
|
|
19389
|
-
return
|
|
19512
|
+
return chalk181.red;
|
|
19390
19513
|
case "Warning":
|
|
19391
|
-
return
|
|
19514
|
+
return chalk181.yellow;
|
|
19392
19515
|
case "Information":
|
|
19393
|
-
return
|
|
19516
|
+
return chalk181.cyan;
|
|
19394
19517
|
case "Debug":
|
|
19395
|
-
return
|
|
19518
|
+
return chalk181.gray;
|
|
19396
19519
|
case "Verbose":
|
|
19397
|
-
return
|
|
19520
|
+
return chalk181.dim;
|
|
19398
19521
|
default:
|
|
19399
|
-
return
|
|
19522
|
+
return chalk181.white;
|
|
19400
19523
|
}
|
|
19401
19524
|
}
|
|
19402
19525
|
function levelAbbrev(level) {
|
|
@@ -19437,12 +19560,12 @@ function formatTimestamp(iso) {
|
|
|
19437
19560
|
function formatEvent(event) {
|
|
19438
19561
|
const color = levelColor(event.Level);
|
|
19439
19562
|
const abbrev = levelAbbrev(event.Level);
|
|
19440
|
-
const ts8 =
|
|
19563
|
+
const ts8 = chalk181.dim(formatTimestamp(event.Timestamp));
|
|
19441
19564
|
const msg = renderMessage(event);
|
|
19442
19565
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
19443
19566
|
if (event.Exception) {
|
|
19444
19567
|
for (const line of event.Exception.split("\n")) {
|
|
19445
|
-
lines.push(
|
|
19568
|
+
lines.push(chalk181.red(` ${line}`));
|
|
19446
19569
|
}
|
|
19447
19570
|
}
|
|
19448
19571
|
return lines.join("\n");
|
|
@@ -19475,11 +19598,11 @@ function rejectTimestampFilter(filter) {
|
|
|
19475
19598
|
}
|
|
19476
19599
|
|
|
19477
19600
|
// src/shared/resolveNamedConnection.ts
|
|
19478
|
-
import
|
|
19601
|
+
import chalk182 from "chalk";
|
|
19479
19602
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
19480
19603
|
if (connections.length === 0) {
|
|
19481
19604
|
console.error(
|
|
19482
|
-
|
|
19605
|
+
chalk182.red(
|
|
19483
19606
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
19484
19607
|
)
|
|
19485
19608
|
);
|
|
@@ -19488,7 +19611,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
19488
19611
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
19489
19612
|
const connection = connections.find((c) => c.name === target);
|
|
19490
19613
|
if (!connection) {
|
|
19491
|
-
console.error(
|
|
19614
|
+
console.error(chalk182.red(`${kind} connection "${target}" not found.`));
|
|
19492
19615
|
process.exit(1);
|
|
19493
19616
|
}
|
|
19494
19617
|
return connection;
|
|
@@ -19517,7 +19640,7 @@ async function seqQuery(filter, options2) {
|
|
|
19517
19640
|
new URLSearchParams({ filter, count: String(count8) })
|
|
19518
19641
|
);
|
|
19519
19642
|
if (events.length === 0) {
|
|
19520
|
-
console.log(
|
|
19643
|
+
console.log(chalk183.yellow("No events found."));
|
|
19521
19644
|
return;
|
|
19522
19645
|
}
|
|
19523
19646
|
if (options2.json) {
|
|
@@ -19528,11 +19651,11 @@ async function seqQuery(filter, options2) {
|
|
|
19528
19651
|
for (const event of chronological) {
|
|
19529
19652
|
console.log(formatEvent(event));
|
|
19530
19653
|
}
|
|
19531
|
-
console.log(
|
|
19654
|
+
console.log(chalk183.dim(`
|
|
19532
19655
|
${events.length} events`));
|
|
19533
19656
|
if (events.length >= count8) {
|
|
19534
19657
|
console.log(
|
|
19535
|
-
|
|
19658
|
+
chalk183.yellow(
|
|
19536
19659
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
19537
19660
|
)
|
|
19538
19661
|
);
|
|
@@ -19540,10 +19663,10 @@ ${events.length} events`));
|
|
|
19540
19663
|
}
|
|
19541
19664
|
|
|
19542
19665
|
// src/shared/setNamedDefaultConnection.ts
|
|
19543
|
-
import
|
|
19666
|
+
import chalk184 from "chalk";
|
|
19544
19667
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
19545
19668
|
if (!connections.find((c) => c.name === name)) {
|
|
19546
|
-
console.error(
|
|
19669
|
+
console.error(chalk184.red(`Connection "${name}" not found.`));
|
|
19547
19670
|
process.exit(1);
|
|
19548
19671
|
}
|
|
19549
19672
|
setDefault(name);
|
|
@@ -19591,36 +19714,36 @@ function registerSignal(program2) {
|
|
|
19591
19714
|
}
|
|
19592
19715
|
|
|
19593
19716
|
// src/commands/sql/sqlAuth.ts
|
|
19594
|
-
import
|
|
19717
|
+
import chalk186 from "chalk";
|
|
19595
19718
|
|
|
19596
19719
|
// src/commands/sql/loadConnections.ts
|
|
19597
19720
|
function loadConnections3() {
|
|
19598
19721
|
const raw = loadGlobalConfigRaw();
|
|
19599
|
-
const
|
|
19600
|
-
return
|
|
19722
|
+
const sql10 = raw.sql;
|
|
19723
|
+
return sql10?.connections ?? [];
|
|
19601
19724
|
}
|
|
19602
19725
|
function saveConnections3(connections) {
|
|
19603
19726
|
const raw = loadGlobalConfigRaw();
|
|
19604
|
-
const
|
|
19605
|
-
|
|
19606
|
-
raw.sql =
|
|
19727
|
+
const sql10 = raw.sql ?? {};
|
|
19728
|
+
sql10.connections = connections;
|
|
19729
|
+
raw.sql = sql10;
|
|
19607
19730
|
saveGlobalConfig(raw);
|
|
19608
19731
|
}
|
|
19609
19732
|
function getDefaultConnection2() {
|
|
19610
19733
|
const raw = loadGlobalConfigRaw();
|
|
19611
|
-
const
|
|
19612
|
-
return
|
|
19734
|
+
const sql10 = raw.sql;
|
|
19735
|
+
return sql10?.defaultConnection;
|
|
19613
19736
|
}
|
|
19614
19737
|
function setDefaultConnection2(name) {
|
|
19615
19738
|
const raw = loadGlobalConfigRaw();
|
|
19616
|
-
const
|
|
19617
|
-
|
|
19618
|
-
raw.sql =
|
|
19739
|
+
const sql10 = raw.sql ?? {};
|
|
19740
|
+
sql10.defaultConnection = name;
|
|
19741
|
+
raw.sql = sql10;
|
|
19619
19742
|
saveGlobalConfig(raw);
|
|
19620
19743
|
}
|
|
19621
19744
|
|
|
19622
19745
|
// src/commands/sql/promptConnection.ts
|
|
19623
|
-
import
|
|
19746
|
+
import chalk185 from "chalk";
|
|
19624
19747
|
async function promptConnection3(existingNames) {
|
|
19625
19748
|
const name = await promptInput("name", "Connection name:", "default");
|
|
19626
19749
|
assertUniqueName(existingNames, name);
|
|
@@ -19628,7 +19751,7 @@ async function promptConnection3(existingNames) {
|
|
|
19628
19751
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
19629
19752
|
const port = Number.parseInt(portStr, 10);
|
|
19630
19753
|
if (!Number.isFinite(port)) {
|
|
19631
|
-
console.error(
|
|
19754
|
+
console.error(chalk185.red(`Invalid port "${portStr}".`));
|
|
19632
19755
|
process.exit(1);
|
|
19633
19756
|
}
|
|
19634
19757
|
const user = await promptInput("user", "User:");
|
|
@@ -19641,13 +19764,13 @@ async function promptConnection3(existingNames) {
|
|
|
19641
19764
|
var sqlAuth = createConnectionAuth({
|
|
19642
19765
|
load: loadConnections3,
|
|
19643
19766
|
save: saveConnections3,
|
|
19644
|
-
format: (c) => `${
|
|
19767
|
+
format: (c) => `${chalk186.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
19645
19768
|
promptNew: promptConnection3,
|
|
19646
19769
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
19647
19770
|
});
|
|
19648
19771
|
|
|
19649
19772
|
// src/commands/sql/printTable.ts
|
|
19650
|
-
import
|
|
19773
|
+
import chalk187 from "chalk";
|
|
19651
19774
|
function formatCell(value) {
|
|
19652
19775
|
if (value === null || value === void 0) return "";
|
|
19653
19776
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -19656,7 +19779,7 @@ function formatCell(value) {
|
|
|
19656
19779
|
}
|
|
19657
19780
|
function printTable(rows) {
|
|
19658
19781
|
if (rows.length === 0) {
|
|
19659
|
-
console.log(
|
|
19782
|
+
console.log(chalk187.yellow("(no rows)"));
|
|
19660
19783
|
return;
|
|
19661
19784
|
}
|
|
19662
19785
|
const columns = Object.keys(rows[0]);
|
|
@@ -19664,13 +19787,13 @@ function printTable(rows) {
|
|
|
19664
19787
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
19665
19788
|
);
|
|
19666
19789
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
19667
|
-
console.log(
|
|
19668
|
-
console.log(
|
|
19790
|
+
console.log(chalk187.dim(header));
|
|
19791
|
+
console.log(chalk187.dim("-".repeat(header.length)));
|
|
19669
19792
|
for (const row of rows) {
|
|
19670
19793
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
19671
19794
|
console.log(line);
|
|
19672
19795
|
}
|
|
19673
|
-
console.log(
|
|
19796
|
+
console.log(chalk187.dim(`
|
|
19674
19797
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
19675
19798
|
}
|
|
19676
19799
|
|
|
@@ -19686,9 +19809,9 @@ function resolveConnection3(name) {
|
|
|
19686
19809
|
}
|
|
19687
19810
|
|
|
19688
19811
|
// src/commands/sql/sqlConnect.ts
|
|
19689
|
-
import
|
|
19812
|
+
import sql7 from "mssql";
|
|
19690
19813
|
async function sqlConnect(conn) {
|
|
19691
|
-
return await
|
|
19814
|
+
return await sql7.connect({
|
|
19692
19815
|
server: conn.server,
|
|
19693
19816
|
port: conn.port,
|
|
19694
19817
|
user: conn.user,
|
|
@@ -19730,7 +19853,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
19730
19853
|
}
|
|
19731
19854
|
|
|
19732
19855
|
// src/commands/sql/sqlMutate.ts
|
|
19733
|
-
import
|
|
19856
|
+
import chalk188 from "chalk";
|
|
19734
19857
|
|
|
19735
19858
|
// src/commands/sql/isMutation.ts
|
|
19736
19859
|
var MUTATION_KEYWORDS = [
|
|
@@ -19751,11 +19874,11 @@ var MUTATION_PATTERN = new RegExp(
|
|
|
19751
19874
|
`\\b(${MUTATION_KEYWORDS.join("|")})\\b`,
|
|
19752
19875
|
"i"
|
|
19753
19876
|
);
|
|
19754
|
-
function stripComments(
|
|
19755
|
-
return
|
|
19877
|
+
function stripComments(sql10) {
|
|
19878
|
+
return sql10.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " ");
|
|
19756
19879
|
}
|
|
19757
|
-
function isMutation(
|
|
19758
|
-
const stripped = stripComments(
|
|
19880
|
+
function isMutation(sql10) {
|
|
19881
|
+
const stripped = stripComments(sql10);
|
|
19759
19882
|
if (MUTATION_PATTERN.test(stripped)) return true;
|
|
19760
19883
|
return /\bSELECT\b[\s\S]+\bINTO\s+\w/i.test(stripped);
|
|
19761
19884
|
}
|
|
@@ -19764,7 +19887,7 @@ function isMutation(sql9) {
|
|
|
19764
19887
|
async function sqlMutate(query, connectionName) {
|
|
19765
19888
|
if (!isMutation(query)) {
|
|
19766
19889
|
console.error(
|
|
19767
|
-
|
|
19890
|
+
chalk188.red(
|
|
19768
19891
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
19769
19892
|
)
|
|
19770
19893
|
);
|
|
@@ -19774,18 +19897,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
19774
19897
|
const pool = await sqlConnect(conn);
|
|
19775
19898
|
try {
|
|
19776
19899
|
const result = await pool.request().query(query);
|
|
19777
|
-
console.log(
|
|
19900
|
+
console.log(chalk188.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
19778
19901
|
} finally {
|
|
19779
19902
|
await pool.close();
|
|
19780
19903
|
}
|
|
19781
19904
|
}
|
|
19782
19905
|
|
|
19783
19906
|
// src/commands/sql/sqlQuery.ts
|
|
19784
|
-
import
|
|
19907
|
+
import chalk189 from "chalk";
|
|
19785
19908
|
async function sqlQuery(query, connectionName) {
|
|
19786
19909
|
if (isMutation(query)) {
|
|
19787
19910
|
console.error(
|
|
19788
|
-
|
|
19911
|
+
chalk189.red(
|
|
19789
19912
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
19790
19913
|
)
|
|
19791
19914
|
);
|
|
@@ -19800,7 +19923,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
19800
19923
|
printTable(rows);
|
|
19801
19924
|
} else {
|
|
19802
19925
|
console.log(
|
|
19803
|
-
|
|
19926
|
+
chalk189.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
19804
19927
|
);
|
|
19805
19928
|
}
|
|
19806
19929
|
} finally {
|
|
@@ -20497,7 +20620,7 @@ function registerVoice(program2) {
|
|
|
20497
20620
|
|
|
20498
20621
|
// src/commands/roam/auth.ts
|
|
20499
20622
|
import { randomBytes } from "crypto";
|
|
20500
|
-
import
|
|
20623
|
+
import chalk190 from "chalk";
|
|
20501
20624
|
|
|
20502
20625
|
// src/commands/roam/waitForCallback.ts
|
|
20503
20626
|
import { createServer as createServer3 } from "http";
|
|
@@ -20628,13 +20751,13 @@ async function auth() {
|
|
|
20628
20751
|
saveGlobalConfig(config);
|
|
20629
20752
|
const state = randomBytes(16).toString("hex");
|
|
20630
20753
|
console.log(
|
|
20631
|
-
|
|
20754
|
+
chalk190.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
20632
20755
|
);
|
|
20633
|
-
console.log(
|
|
20634
|
-
console.log(
|
|
20635
|
-
console.log(
|
|
20756
|
+
console.log(chalk190.white("http://localhost:14523/callback\n"));
|
|
20757
|
+
console.log(chalk190.blue("Opening browser for authorization..."));
|
|
20758
|
+
console.log(chalk190.dim("Waiting for authorization callback..."));
|
|
20636
20759
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
20637
|
-
console.log(
|
|
20760
|
+
console.log(chalk190.dim("Exchanging code for tokens..."));
|
|
20638
20761
|
const tokens = await exchangeToken({
|
|
20639
20762
|
code,
|
|
20640
20763
|
clientId,
|
|
@@ -20650,7 +20773,7 @@ async function auth() {
|
|
|
20650
20773
|
};
|
|
20651
20774
|
saveGlobalConfig(config);
|
|
20652
20775
|
console.log(
|
|
20653
|
-
|
|
20776
|
+
chalk190.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
20654
20777
|
);
|
|
20655
20778
|
}
|
|
20656
20779
|
|
|
@@ -21102,7 +21225,7 @@ import { execSync as execSync54 } from "child_process";
|
|
|
21102
21225
|
import { existsSync as existsSync51, mkdirSync as mkdirSync22, unlinkSync as unlinkSync19, writeFileSync as writeFileSync39 } from "fs";
|
|
21103
21226
|
import { tmpdir as tmpdir7 } from "os";
|
|
21104
21227
|
import { join as join61, resolve as resolve15 } from "path";
|
|
21105
|
-
import
|
|
21228
|
+
import chalk191 from "chalk";
|
|
21106
21229
|
|
|
21107
21230
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
21108
21231
|
var captureWindowPs1 = `
|
|
@@ -21253,13 +21376,13 @@ function screenshot(processName) {
|
|
|
21253
21376
|
const config = loadConfig();
|
|
21254
21377
|
const outputDir = resolve15(config.screenshot.outputDir);
|
|
21255
21378
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
21256
|
-
console.log(
|
|
21379
|
+
console.log(chalk191.gray(`Capturing window for process "${processName}" ...`));
|
|
21257
21380
|
try {
|
|
21258
21381
|
runPowerShellScript(processName, outputPath);
|
|
21259
|
-
console.log(
|
|
21382
|
+
console.log(chalk191.green(`Screenshot saved: ${outputPath}`));
|
|
21260
21383
|
} catch (error) {
|
|
21261
21384
|
const msg = error instanceof Error ? error.message : String(error);
|
|
21262
|
-
console.error(
|
|
21385
|
+
console.error(chalk191.red(`Failed to capture screenshot: ${msg}`));
|
|
21263
21386
|
process.exit(1);
|
|
21264
21387
|
}
|
|
21265
21388
|
}
|
|
@@ -21869,13 +21992,13 @@ function logSpawnedSession(session) {
|
|
|
21869
21992
|
}
|
|
21870
21993
|
|
|
21871
21994
|
// src/shared/db/recordPhaseActiveMs.ts
|
|
21872
|
-
import { sql as
|
|
21995
|
+
import { sql as sql8 } from "drizzle-orm";
|
|
21873
21996
|
async function recordPhaseActiveMs(db, itemId, phaseIdx, activeMs) {
|
|
21874
21997
|
if (activeMs <= 0) return;
|
|
21875
21998
|
await db.insert(phaseUsage).values({ itemId, phaseIdx, activeMs }).onConflictDoUpdate({
|
|
21876
21999
|
target: [phaseUsage.itemId, phaseUsage.phaseIdx],
|
|
21877
22000
|
set: {
|
|
21878
|
-
activeMs:
|
|
22001
|
+
activeMs: sql8`${phaseUsage.activeMs} + excluded.active_ms`
|
|
21879
22002
|
}
|
|
21880
22003
|
});
|
|
21881
22004
|
}
|
|
@@ -22018,15 +22141,15 @@ function makeStatusChangeHandler(dismiss, notify2, reuseForRun) {
|
|
|
22018
22141
|
}
|
|
22019
22142
|
|
|
22020
22143
|
// src/shared/db/recordPhaseTokens.ts
|
|
22021
|
-
import { sql as
|
|
22144
|
+
import { sql as sql9 } from "drizzle-orm";
|
|
22022
22145
|
async function recordPhaseTokens(db, itemId, phaseIdx, totalIn, totalOut) {
|
|
22023
22146
|
await db.insert(phaseUsage).values({ itemId, phaseIdx, lastTotalIn: totalIn, lastTotalOut: totalOut }).onConflictDoUpdate({
|
|
22024
22147
|
target: [phaseUsage.itemId, phaseUsage.phaseIdx],
|
|
22025
22148
|
set: {
|
|
22026
|
-
tokensDown:
|
|
22027
|
-
tokensUp:
|
|
22028
|
-
lastTotalIn:
|
|
22029
|
-
lastTotalOut:
|
|
22149
|
+
tokensDown: sql9`${phaseUsage.tokensDown} + CASE WHEN ${phaseUsage.lastTotalIn} IS NULL THEN 0 ELSE GREATEST(excluded.last_total_in - ${phaseUsage.lastTotalIn}, 0) END`,
|
|
22150
|
+
tokensUp: sql9`${phaseUsage.tokensUp} + CASE WHEN ${phaseUsage.lastTotalOut} IS NULL THEN 0 ELSE GREATEST(excluded.last_total_out - ${phaseUsage.lastTotalOut}, 0) END`,
|
|
22151
|
+
lastTotalIn: sql9`excluded.last_total_in`,
|
|
22152
|
+
lastTotalOut: sql9`excluded.last_total_out`
|
|
22030
22153
|
}
|
|
22031
22154
|
});
|
|
22032
22155
|
}
|
|
@@ -22068,10 +22191,10 @@ function applyReviewPause(session, activity2) {
|
|
|
22068
22191
|
}
|
|
22069
22192
|
|
|
22070
22193
|
// src/shared/db/getPhaseActiveMs.ts
|
|
22071
|
-
import { and as
|
|
22194
|
+
import { and as and19, eq as eq38 } from "drizzle-orm";
|
|
22072
22195
|
async function getPhaseActiveMs(db, itemId, phaseIdx) {
|
|
22073
22196
|
const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
22074
|
-
|
|
22197
|
+
and19(eq38(phaseUsage.itemId, itemId), eq38(phaseUsage.phaseIdx, phaseIdx))
|
|
22075
22198
|
);
|
|
22076
22199
|
return row?.activeMs ?? 0;
|
|
22077
22200
|
}
|
|
@@ -23920,7 +24043,7 @@ function registerDaemon(program2) {
|
|
|
23920
24043
|
|
|
23921
24044
|
// src/commands/sessions/summarise/index.ts
|
|
23922
24045
|
import * as fs36 from "fs";
|
|
23923
|
-
import
|
|
24046
|
+
import chalk192 from "chalk";
|
|
23924
24047
|
|
|
23925
24048
|
// src/commands/sessions/summarise/shared.ts
|
|
23926
24049
|
import * as fs34 from "fs";
|
|
@@ -24074,22 +24197,22 @@ ${firstMessage}`);
|
|
|
24074
24197
|
async function summarise2(options2) {
|
|
24075
24198
|
const files = await discoverSessionFiles();
|
|
24076
24199
|
if (files.length === 0) {
|
|
24077
|
-
console.log(
|
|
24200
|
+
console.log(chalk192.yellow("No sessions found."));
|
|
24078
24201
|
return;
|
|
24079
24202
|
}
|
|
24080
24203
|
const toProcess = selectCandidates(files, options2);
|
|
24081
24204
|
if (toProcess.length === 0) {
|
|
24082
|
-
console.log(
|
|
24205
|
+
console.log(chalk192.green("All sessions already summarised."));
|
|
24083
24206
|
return;
|
|
24084
24207
|
}
|
|
24085
24208
|
console.log(
|
|
24086
|
-
|
|
24209
|
+
chalk192.cyan(
|
|
24087
24210
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
24088
24211
|
)
|
|
24089
24212
|
);
|
|
24090
24213
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
24091
24214
|
console.log(
|
|
24092
|
-
|
|
24215
|
+
chalk192.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk192.yellow(`, ${failed2} skipped`) : "")
|
|
24093
24216
|
);
|
|
24094
24217
|
}
|
|
24095
24218
|
function selectCandidates(files, options2) {
|
|
@@ -24109,16 +24232,16 @@ function processSessions(files) {
|
|
|
24109
24232
|
let failed2 = 0;
|
|
24110
24233
|
for (let i = 0; i < files.length; i++) {
|
|
24111
24234
|
const file = files[i];
|
|
24112
|
-
process.stdout.write(
|
|
24235
|
+
process.stdout.write(chalk192.dim(` [${i + 1}/${files.length}] `));
|
|
24113
24236
|
const summary = summariseSession(file);
|
|
24114
24237
|
if (summary) {
|
|
24115
24238
|
writeSummary(file, summary);
|
|
24116
24239
|
succeeded++;
|
|
24117
|
-
process.stdout.write(`${
|
|
24240
|
+
process.stdout.write(`${chalk192.green("\u2713")} ${summary}
|
|
24118
24241
|
`);
|
|
24119
24242
|
} else {
|
|
24120
24243
|
failed2++;
|
|
24121
|
-
process.stdout.write(` ${
|
|
24244
|
+
process.stdout.write(` ${chalk192.yellow("skip")}
|
|
24122
24245
|
`);
|
|
24123
24246
|
}
|
|
24124
24247
|
}
|
|
@@ -24136,10 +24259,10 @@ function registerSessions(program2) {
|
|
|
24136
24259
|
}
|
|
24137
24260
|
|
|
24138
24261
|
// src/commands/statusLine.ts
|
|
24139
|
-
import
|
|
24262
|
+
import chalk194 from "chalk";
|
|
24140
24263
|
|
|
24141
24264
|
// src/commands/buildLimitsSegment.ts
|
|
24142
|
-
import
|
|
24265
|
+
import chalk193 from "chalk";
|
|
24143
24266
|
|
|
24144
24267
|
// src/shared/rateLimitLevel.ts
|
|
24145
24268
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -24170,9 +24293,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
24170
24293
|
|
|
24171
24294
|
// src/commands/buildLimitsSegment.ts
|
|
24172
24295
|
var LEVEL_COLOR = {
|
|
24173
|
-
ok:
|
|
24174
|
-
warn:
|
|
24175
|
-
over:
|
|
24296
|
+
ok: chalk193.green,
|
|
24297
|
+
warn: chalk193.yellow,
|
|
24298
|
+
over: chalk193.red
|
|
24176
24299
|
};
|
|
24177
24300
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
24178
24301
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -24263,14 +24386,14 @@ async function relayUsage(claudeSessionId, totalIn, totalOut) {
|
|
|
24263
24386
|
}
|
|
24264
24387
|
|
|
24265
24388
|
// src/commands/statusLine.ts
|
|
24266
|
-
|
|
24389
|
+
chalk194.level = 3;
|
|
24267
24390
|
function formatNumber(num) {
|
|
24268
24391
|
return num.toLocaleString("en-US");
|
|
24269
24392
|
}
|
|
24270
24393
|
function colorizePercent(pct) {
|
|
24271
24394
|
const label2 = `${Math.round(pct)}%`;
|
|
24272
|
-
if (pct > 80) return
|
|
24273
|
-
if (pct > 40) return
|
|
24395
|
+
if (pct > 80) return chalk194.red(label2);
|
|
24396
|
+
if (pct > 40) return chalk194.yellow(label2);
|
|
24274
24397
|
return label2;
|
|
24275
24398
|
}
|
|
24276
24399
|
async function statusLine() {
|
|
@@ -24281,7 +24404,7 @@ async function statusLine() {
|
|
|
24281
24404
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
24282
24405
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
24283
24406
|
const branch2 = dir ? readGitBranch(windowsCwdToWslPath(dir)) : null;
|
|
24284
|
-
const branchSegment = branch2 ? `\u{
|
|
24407
|
+
const branchSegment = branch2 ? `\u{1F33F} ${chalk194.cyan(branch2)} | ` : "";
|
|
24285
24408
|
console.log(
|
|
24286
24409
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalOut)} \u2191 : ${formatNumber(totalIn)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
24287
24410
|
);
|
|
@@ -24298,7 +24421,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
|
|
|
24298
24421
|
// src/commands/sync/syncClaudeMd.ts
|
|
24299
24422
|
import * as fs37 from "fs";
|
|
24300
24423
|
import * as path53 from "path";
|
|
24301
|
-
import
|
|
24424
|
+
import chalk195 from "chalk";
|
|
24302
24425
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
24303
24426
|
const source = path53.join(claudeDir, "CLAUDE.md");
|
|
24304
24427
|
const target = path53.join(targetBase, "CLAUDE.md");
|
|
@@ -24307,12 +24430,12 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24307
24430
|
const targetContent = fs37.readFileSync(target, "utf8");
|
|
24308
24431
|
if (sourceContent !== targetContent) {
|
|
24309
24432
|
console.log(
|
|
24310
|
-
|
|
24433
|
+
chalk195.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
24311
24434
|
);
|
|
24312
24435
|
console.log();
|
|
24313
24436
|
printDiff(targetContent, sourceContent);
|
|
24314
24437
|
const confirm = options2?.yes || await promptConfirm(
|
|
24315
|
-
|
|
24438
|
+
chalk195.red("Overwrite existing CLAUDE.md?"),
|
|
24316
24439
|
false
|
|
24317
24440
|
);
|
|
24318
24441
|
if (!confirm) {
|
|
@@ -24328,7 +24451,7 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24328
24451
|
// src/commands/sync/syncSettings.ts
|
|
24329
24452
|
import * as fs38 from "fs";
|
|
24330
24453
|
import * as path54 from "path";
|
|
24331
|
-
import
|
|
24454
|
+
import chalk196 from "chalk";
|
|
24332
24455
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
24333
24456
|
const source = path54.join(claudeDir, "settings.json");
|
|
24334
24457
|
const target = path54.join(targetBase, "settings.json");
|
|
@@ -24347,14 +24470,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
24347
24470
|
if (mergedContent !== normalizedTarget) {
|
|
24348
24471
|
if (!options2?.yes) {
|
|
24349
24472
|
console.log(
|
|
24350
|
-
|
|
24473
|
+
chalk196.yellow(
|
|
24351
24474
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
24352
24475
|
)
|
|
24353
24476
|
);
|
|
24354
24477
|
console.log();
|
|
24355
24478
|
printDiff(targetContent, mergedContent);
|
|
24356
24479
|
const confirm = await promptConfirm(
|
|
24357
|
-
|
|
24480
|
+
chalk196.red("Overwrite existing settings.json?"),
|
|
24358
24481
|
false
|
|
24359
24482
|
);
|
|
24360
24483
|
if (!confirm) {
|