@staff0rd/assist 0.365.0 → 0.366.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 +561 -449
- 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.366.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -8964,45 +8964,148 @@ async function addSubtask(id2, options2) {
|
|
|
8964
8964
|
console.log(chalk91.green(`Added sub-task to item #${id2}: ${title}`));
|
|
8965
8965
|
}
|
|
8966
8966
|
|
|
8967
|
-
// src/commands/backlog/
|
|
8967
|
+
// src/commands/backlog/editSubtask.ts
|
|
8968
|
+
import chalk93 from "chalk";
|
|
8969
|
+
|
|
8970
|
+
// src/commands/backlog/resolveSubtaskIndex.ts
|
|
8968
8971
|
import chalk92 from "chalk";
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
+
function resolveSubtaskIndex(id2, index3, item) {
|
|
8973
|
+
const position = Number.parseInt(index3, 10);
|
|
8974
|
+
const subtasks = item.subtasks ?? [];
|
|
8975
|
+
if (Number.isNaN(position) || position < 1 || position > subtasks.length) {
|
|
8972
8976
|
console.log(
|
|
8973
8977
|
chalk92.red(
|
|
8974
|
-
`
|
|
8978
|
+
`Item #${id2} has no sub-task ${index3}${subtasks.length > 0 ? ` (1-${subtasks.length})` : ""}.`
|
|
8975
8979
|
)
|
|
8976
8980
|
);
|
|
8977
8981
|
process.exitCode = 1;
|
|
8978
|
-
return;
|
|
8982
|
+
return void 0;
|
|
8979
8983
|
}
|
|
8980
|
-
|
|
8984
|
+
return position - 1;
|
|
8985
|
+
}
|
|
8986
|
+
|
|
8987
|
+
// src/commands/backlog/findSubtask.ts
|
|
8988
|
+
async function findSubtask(id2, index3) {
|
|
8981
8989
|
const found = await findOneItem(id2);
|
|
8982
8990
|
if (!found) {
|
|
8991
|
+
process.exitCode = 1;
|
|
8992
|
+
return void 0;
|
|
8993
|
+
}
|
|
8994
|
+
const idx = resolveSubtaskIndex(id2, index3, found.item);
|
|
8995
|
+
if (idx === void 0) return void 0;
|
|
8996
|
+
return { orm: found.orm, item: found.item, idx };
|
|
8997
|
+
}
|
|
8998
|
+
|
|
8999
|
+
// src/commands/backlog/updateSubtask.ts
|
|
9000
|
+
import { and as and9, eq as eq26 } from "drizzle-orm";
|
|
9001
|
+
async function updateSubtask(orm, itemId, idx, fields) {
|
|
9002
|
+
const set = {};
|
|
9003
|
+
if (fields.title !== void 0) set.title = fields.title;
|
|
9004
|
+
if (fields.description !== void 0) set.description = fields.description;
|
|
9005
|
+
if (fields.status !== void 0) set.status = fields.status;
|
|
9006
|
+
const [row] = await orm.update(itemSubtasks).set(set).where(and9(eq26(itemSubtasks.itemId, itemId), eq26(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
9007
|
+
return row?.title;
|
|
9008
|
+
}
|
|
9009
|
+
|
|
9010
|
+
// src/commands/backlog/validSubtaskStatuses.ts
|
|
9011
|
+
var validSubtaskStatuses = [
|
|
9012
|
+
"todo",
|
|
9013
|
+
"in-progress",
|
|
9014
|
+
"done"
|
|
9015
|
+
];
|
|
9016
|
+
|
|
9017
|
+
// src/commands/backlog/editSubtask.ts
|
|
9018
|
+
function buildUpdate(options2) {
|
|
9019
|
+
const fields = {};
|
|
9020
|
+
if (options2.title !== void 0) {
|
|
9021
|
+
const title = options2.title.trim();
|
|
9022
|
+
if (!title) return "A sub-task title cannot be empty (--title).";
|
|
9023
|
+
fields.title = title;
|
|
9024
|
+
}
|
|
9025
|
+
if (options2.status !== void 0) {
|
|
9026
|
+
if (!validSubtaskStatuses.includes(options2.status)) {
|
|
9027
|
+
return `Invalid status "${options2.status}". Use one of: ${validSubtaskStatuses.join(", ")}.`;
|
|
9028
|
+
}
|
|
9029
|
+
fields.status = options2.status;
|
|
9030
|
+
}
|
|
9031
|
+
if (options2.desc !== void 0) {
|
|
9032
|
+
fields.description = options2.desc === "" ? null : options2.desc.replaceAll(String.raw`\n`, "\n");
|
|
9033
|
+
}
|
|
9034
|
+
if (Object.keys(fields).length === 0) {
|
|
9035
|
+
return "Nothing to update. Provide at least one of --title, --desc, --status.";
|
|
9036
|
+
}
|
|
9037
|
+
return fields;
|
|
9038
|
+
}
|
|
9039
|
+
async function editSubtask(id2, index3, options2) {
|
|
9040
|
+
const found = await findSubtask(id2, index3);
|
|
9041
|
+
if (!found) return;
|
|
9042
|
+
const fields = buildUpdate(options2);
|
|
9043
|
+
if (typeof fields === "string") {
|
|
9044
|
+
console.log(chalk93.red(fields));
|
|
8983
9045
|
process.exitCode = 1;
|
|
8984
9046
|
return;
|
|
8985
9047
|
}
|
|
8986
|
-
const { orm, item } = found;
|
|
8987
|
-
const
|
|
8988
|
-
|
|
9048
|
+
const { orm, item, idx } = found;
|
|
9049
|
+
const title = await updateSubtask(orm, item.id, idx, fields);
|
|
9050
|
+
console.log(
|
|
9051
|
+
chalk93.green(`Updated sub-task ${idx + 1} of item #${id2}: ${title}`)
|
|
9052
|
+
);
|
|
9053
|
+
}
|
|
9054
|
+
|
|
9055
|
+
// src/commands/backlog/removeSubtask.ts
|
|
9056
|
+
import chalk94 from "chalk";
|
|
9057
|
+
|
|
9058
|
+
// src/commands/backlog/deleteSubtask.ts
|
|
9059
|
+
import { and as and10, asc as asc6, eq as eq27 } from "drizzle-orm";
|
|
9060
|
+
async function deleteSubtask(orm, itemId, idx) {
|
|
9061
|
+
const [row] = await orm.delete(itemSubtasks).where(and10(eq27(itemSubtasks.itemId, itemId), eq27(itemSubtasks.idx, idx))).returning({ title: itemSubtasks.title });
|
|
9062
|
+
if (!row) return void 0;
|
|
9063
|
+
const remaining = await orm.select({ idx: itemSubtasks.idx }).from(itemSubtasks).where(eq27(itemSubtasks.itemId, itemId)).orderBy(asc6(itemSubtasks.idx));
|
|
9064
|
+
for (let i = 0; i < remaining.length; i++) {
|
|
9065
|
+
const oldIdx = remaining[i].idx;
|
|
9066
|
+
if (oldIdx === i) continue;
|
|
9067
|
+
await orm.update(itemSubtasks).set({ idx: i }).where(
|
|
9068
|
+
and10(eq27(itemSubtasks.itemId, itemId), eq27(itemSubtasks.idx, oldIdx))
|
|
9069
|
+
);
|
|
9070
|
+
}
|
|
9071
|
+
return row.title;
|
|
9072
|
+
}
|
|
9073
|
+
|
|
9074
|
+
// src/commands/backlog/removeSubtask.ts
|
|
9075
|
+
async function removeSubtask(id2, index3) {
|
|
9076
|
+
const found = await findSubtask(id2, index3);
|
|
9077
|
+
if (!found) return;
|
|
9078
|
+
const { orm, item, idx } = found;
|
|
9079
|
+
const title = await deleteSubtask(orm, item.id, idx);
|
|
9080
|
+
console.log(
|
|
9081
|
+
chalk94.green(`Removed sub-task ${idx + 1} of item #${id2}: ${title}`)
|
|
9082
|
+
);
|
|
9083
|
+
}
|
|
9084
|
+
|
|
9085
|
+
// src/commands/backlog/subtaskStatus.ts
|
|
9086
|
+
import chalk95 from "chalk";
|
|
9087
|
+
async function subtaskStatus(id2, index3, status2) {
|
|
9088
|
+
if (!validSubtaskStatuses.includes(status2)) {
|
|
8989
9089
|
console.log(
|
|
8990
|
-
|
|
8991
|
-
`
|
|
9090
|
+
chalk95.red(
|
|
9091
|
+
`Invalid status "${status2}". Use one of: ${validSubtaskStatuses.join(", ")}.`
|
|
8992
9092
|
)
|
|
8993
9093
|
);
|
|
8994
9094
|
process.exitCode = 1;
|
|
8995
9095
|
return;
|
|
8996
9096
|
}
|
|
9097
|
+
const found = await findSubtask(id2, index3);
|
|
9098
|
+
if (!found) return;
|
|
9099
|
+
const { orm, item, idx } = found;
|
|
8997
9100
|
const title = await updateSubtaskStatus(
|
|
8998
9101
|
orm,
|
|
8999
9102
|
item.id,
|
|
9000
|
-
|
|
9103
|
+
idx,
|
|
9001
9104
|
status2
|
|
9002
9105
|
);
|
|
9003
9106
|
console.log(
|
|
9004
|
-
|
|
9005
|
-
`Set sub-task ${
|
|
9107
|
+
chalk95.green(
|
|
9108
|
+
`Set sub-task ${idx + 1} of item #${id2} to ${status2}: ${title}`
|
|
9006
9109
|
)
|
|
9007
9110
|
);
|
|
9008
9111
|
}
|
|
@@ -9013,27 +9116,36 @@ function registerSubtaskCommands(cmd) {
|
|
|
9013
9116
|
"--desc <description>",
|
|
9014
9117
|
String.raw`Sub-task description (Markdown supported; use \n for line breaks)`
|
|
9015
9118
|
).action(addSubtask);
|
|
9119
|
+
cmd.command("edit-subtask <id> <idx>").description(
|
|
9120
|
+
"Edit a sub-task's title, description, and/or status by its 1-based index"
|
|
9121
|
+
).option("--title <title>", "New sub-task title").option(
|
|
9122
|
+
"--desc <description>",
|
|
9123
|
+
String.raw`New sub-task description (Markdown supported; use \n for line breaks; pass "" to clear)`
|
|
9124
|
+
).option("--status <status>", "New status (todo, in-progress, done)").action(editSubtask);
|
|
9125
|
+
cmd.command("remove-subtask <id> <idx>").description(
|
|
9126
|
+
"Remove a sub-task by its 1-based index and re-index the remaining sub-tasks"
|
|
9127
|
+
).action(removeSubtask);
|
|
9016
9128
|
cmd.command("subtask-status <id> <idx> <status>").description(
|
|
9017
9129
|
"Set a sub-task's status (todo, in-progress, done) by its 1-based index"
|
|
9018
9130
|
).action(subtaskStatus);
|
|
9019
9131
|
}
|
|
9020
9132
|
|
|
9021
9133
|
// src/commands/backlog/movePhase.ts
|
|
9022
|
-
import
|
|
9023
|
-
import { count as count6, eq as
|
|
9134
|
+
import chalk96 from "chalk";
|
|
9135
|
+
import { count as count6, eq as eq30 } from "drizzle-orm";
|
|
9024
9136
|
|
|
9025
9137
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
9026
|
-
import { and as
|
|
9138
|
+
import { and as and12, asc as asc8, eq as eq29 } from "drizzle-orm";
|
|
9027
9139
|
|
|
9028
9140
|
// src/commands/backlog/reindexPhases.ts
|
|
9029
|
-
import { and as
|
|
9141
|
+
import { and as and11, asc as asc7, count as count5, eq as eq28 } from "drizzle-orm";
|
|
9030
9142
|
async function reindexPhases(db, itemId) {
|
|
9031
|
-
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(
|
|
9143
|
+
const remaining = await db.select({ idx: planPhases.idx }).from(planPhases).where(eq28(planPhases.itemId, itemId)).orderBy(asc7(planPhases.idx));
|
|
9032
9144
|
for (let i = 0; i < remaining.length; i++) {
|
|
9033
9145
|
const oldIdx = remaining[i].idx;
|
|
9034
9146
|
if (oldIdx === i) continue;
|
|
9035
|
-
await db.update(planTasks).set({ phaseIdx: i }).where(
|
|
9036
|
-
await db.update(planPhases).set({ idx: i }).where(
|
|
9147
|
+
await db.update(planTasks).set({ phaseIdx: i }).where(and11(eq28(planTasks.itemId, itemId), eq28(planTasks.phaseIdx, oldIdx)));
|
|
9148
|
+
await db.update(planPhases).set({ idx: i }).where(and11(eq28(planPhases.itemId, itemId), eq28(planPhases.idx, oldIdx)));
|
|
9037
9149
|
}
|
|
9038
9150
|
}
|
|
9039
9151
|
async function adjustCurrentPhase(db, item, removedIdx) {
|
|
@@ -9041,24 +9153,24 @@ async function adjustCurrentPhase(db, item, removedIdx) {
|
|
|
9041
9153
|
if (currentPhase === void 0) return;
|
|
9042
9154
|
const currentIdx = currentPhase - 1;
|
|
9043
9155
|
if (removedIdx < currentIdx) {
|
|
9044
|
-
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(
|
|
9156
|
+
await db.update(items).set({ currentPhase: currentPhase - 1 }).where(eq28(items.id, item.id));
|
|
9045
9157
|
return;
|
|
9046
9158
|
}
|
|
9047
9159
|
if (removedIdx !== currentIdx) return;
|
|
9048
|
-
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(
|
|
9160
|
+
const [row] = await db.select({ cnt: count5() }).from(planPhases).where(eq28(planPhases.itemId, item.id));
|
|
9049
9161
|
const cnt = row?.cnt ?? 0;
|
|
9050
|
-
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(
|
|
9162
|
+
await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq28(items.id, item.id));
|
|
9051
9163
|
}
|
|
9052
9164
|
|
|
9053
9165
|
// src/commands/backlog/reorderPhaseRows.ts
|
|
9054
9166
|
async function reorderPhaseRows(orm, itemId, fromIdx, toIdx) {
|
|
9055
9167
|
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(
|
|
9168
|
+
const [phaseRow] = await tx.select({ name: planPhases.name, manualChecks: planPhases.manualChecks }).from(planPhases).where(and12(eq29(planPhases.itemId, itemId), eq29(planPhases.idx, fromIdx)));
|
|
9169
|
+
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
9170
|
await tx.delete(planTasks).where(
|
|
9059
|
-
|
|
9171
|
+
and12(eq29(planTasks.itemId, itemId), eq29(planTasks.phaseIdx, fromIdx))
|
|
9060
9172
|
);
|
|
9061
|
-
await tx.delete(planPhases).where(
|
|
9173
|
+
await tx.delete(planPhases).where(and12(eq29(planPhases.itemId, itemId), eq29(planPhases.idx, fromIdx)));
|
|
9062
9174
|
await reindexPhases(tx, itemId);
|
|
9063
9175
|
await shiftPhasesUp(tx, itemId, toIdx);
|
|
9064
9176
|
await tx.insert(planPhases).values({
|
|
@@ -9085,7 +9197,7 @@ function toIndex(value, phaseCount) {
|
|
|
9085
9197
|
const pos = Number.parseInt(value, 10);
|
|
9086
9198
|
if (Number.isNaN(pos) || pos < 1 || pos > phaseCount) {
|
|
9087
9199
|
console.log(
|
|
9088
|
-
|
|
9200
|
+
chalk96.red(
|
|
9089
9201
|
`Position "${value}" is out of range. Must be between 1 and ${phaseCount}.`
|
|
9090
9202
|
)
|
|
9091
9203
|
);
|
|
@@ -9099,7 +9211,7 @@ async function movePhase(id2, from, to) {
|
|
|
9099
9211
|
if (!found) return;
|
|
9100
9212
|
const { orm, item } = found;
|
|
9101
9213
|
const itemId = item.id;
|
|
9102
|
-
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(
|
|
9214
|
+
const [row] = await orm.select({ cnt: count6() }).from(planPhases).where(eq30(planPhases.itemId, itemId));
|
|
9103
9215
|
const phaseCount = row?.cnt ?? 0;
|
|
9104
9216
|
const fromIdx = toIndex(from, phaseCount);
|
|
9105
9217
|
if (fromIdx === void 0) return;
|
|
@@ -9108,29 +9220,29 @@ async function movePhase(id2, from, to) {
|
|
|
9108
9220
|
if (fromIdx !== toIdx) {
|
|
9109
9221
|
await reorderPhaseRows(orm, itemId, fromIdx, toIdx);
|
|
9110
9222
|
}
|
|
9111
|
-
console.log(
|
|
9223
|
+
console.log(chalk96.green(`Moved phase ${from} to position ${to}.`));
|
|
9112
9224
|
}
|
|
9113
9225
|
|
|
9114
9226
|
// src/commands/backlog/updatePhase.ts
|
|
9115
|
-
import
|
|
9227
|
+
import chalk98 from "chalk";
|
|
9116
9228
|
|
|
9117
9229
|
// src/commands/backlog/applyPhaseUpdate.ts
|
|
9118
|
-
import { and as
|
|
9230
|
+
import { and as and13, eq as eq31 } from "drizzle-orm";
|
|
9119
9231
|
async function applyPhaseUpdate(orm, itemId, phaseIdx, fields) {
|
|
9120
9232
|
await orm.transaction(async (tx) => {
|
|
9121
9233
|
if (fields.name) {
|
|
9122
9234
|
await tx.update(planPhases).set({ name: fields.name }).where(
|
|
9123
|
-
|
|
9235
|
+
and13(eq31(planPhases.itemId, itemId), eq31(planPhases.idx, phaseIdx))
|
|
9124
9236
|
);
|
|
9125
9237
|
}
|
|
9126
9238
|
if (fields.manualCheck) {
|
|
9127
9239
|
await tx.update(planPhases).set({ manualChecks: JSON.stringify(fields.manualCheck) }).where(
|
|
9128
|
-
|
|
9240
|
+
and13(eq31(planPhases.itemId, itemId), eq31(planPhases.idx, phaseIdx))
|
|
9129
9241
|
);
|
|
9130
9242
|
}
|
|
9131
9243
|
if (fields.task) {
|
|
9132
9244
|
await tx.delete(planTasks).where(
|
|
9133
|
-
|
|
9245
|
+
and13(eq31(planTasks.itemId, itemId), eq31(planTasks.phaseIdx, phaseIdx))
|
|
9134
9246
|
);
|
|
9135
9247
|
if (fields.task.length) {
|
|
9136
9248
|
await tx.insert(planTasks).values(
|
|
@@ -9147,18 +9259,18 @@ async function applyPhaseUpdate(orm, itemId, phaseIdx, fields) {
|
|
|
9147
9259
|
}
|
|
9148
9260
|
|
|
9149
9261
|
// src/commands/backlog/findPhase.ts
|
|
9150
|
-
import
|
|
9151
|
-
import { and as
|
|
9262
|
+
import chalk97 from "chalk";
|
|
9263
|
+
import { and as and14, count as count7, eq as eq32 } from "drizzle-orm";
|
|
9152
9264
|
async function findPhase(id2, phase) {
|
|
9153
9265
|
const found = await findOneItem(id2);
|
|
9154
9266
|
if (!found) return void 0;
|
|
9155
9267
|
const { orm, item } = found;
|
|
9156
9268
|
const itemId = item.id;
|
|
9157
9269
|
const phaseIdx = Number.parseInt(phase, 10) - 1;
|
|
9158
|
-
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(
|
|
9270
|
+
const [row] = await orm.select({ cnt: count7() }).from(planPhases).where(and14(eq32(planPhases.itemId, itemId), eq32(planPhases.idx, phaseIdx)));
|
|
9159
9271
|
if (!row || row.cnt === 0) {
|
|
9160
9272
|
console.log(
|
|
9161
|
-
|
|
9273
|
+
chalk97.red(`Phase ${phaseIdx + 1} not found on item #${itemId}.`)
|
|
9162
9274
|
);
|
|
9163
9275
|
process.exitCode = 1;
|
|
9164
9276
|
return void 0;
|
|
@@ -9290,7 +9402,7 @@ async function updatePhase(id2, phase, options2) {
|
|
|
9290
9402
|
const { item, orm, itemId, phaseIdx } = found;
|
|
9291
9403
|
const resolved = resolvePhaseFields(options2, item.plan?.[phaseIdx]);
|
|
9292
9404
|
if (!resolved.ok) {
|
|
9293
|
-
console.log(
|
|
9405
|
+
console.log(chalk98.red(resolved.error));
|
|
9294
9406
|
process.exitCode = 1;
|
|
9295
9407
|
return;
|
|
9296
9408
|
}
|
|
@@ -9302,7 +9414,7 @@ async function updatePhase(id2, phase, options2) {
|
|
|
9302
9414
|
manualCheck && "manual checks"
|
|
9303
9415
|
].filter(Boolean).join(", ");
|
|
9304
9416
|
console.log(
|
|
9305
|
-
|
|
9417
|
+
chalk98.green(
|
|
9306
9418
|
`Updated ${fields} on phase ${phaseIdx + 1} of item #${itemId}.`
|
|
9307
9419
|
)
|
|
9308
9420
|
);
|
|
@@ -9325,28 +9437,28 @@ function registerUpdatePhaseCommand(cmd) {
|
|
|
9325
9437
|
}
|
|
9326
9438
|
|
|
9327
9439
|
// src/commands/backlog/removePhase.ts
|
|
9328
|
-
import
|
|
9329
|
-
import { and as
|
|
9440
|
+
import chalk99 from "chalk";
|
|
9441
|
+
import { and as and15, eq as eq33 } from "drizzle-orm";
|
|
9330
9442
|
async function removePhase(id2, phase) {
|
|
9331
9443
|
const found = await findPhase(id2, phase);
|
|
9332
9444
|
if (!found) return;
|
|
9333
9445
|
const { item, orm, itemId, phaseIdx } = found;
|
|
9334
9446
|
await orm.transaction(async (tx) => {
|
|
9335
9447
|
await tx.delete(planTasks).where(
|
|
9336
|
-
|
|
9448
|
+
and15(eq33(planTasks.itemId, itemId), eq33(planTasks.phaseIdx, phaseIdx))
|
|
9337
9449
|
);
|
|
9338
|
-
await tx.delete(planPhases).where(
|
|
9450
|
+
await tx.delete(planPhases).where(and15(eq33(planPhases.itemId, itemId), eq33(planPhases.idx, phaseIdx)));
|
|
9339
9451
|
await reindexPhases(tx, itemId);
|
|
9340
9452
|
await adjustCurrentPhase(tx, item, phaseIdx);
|
|
9341
9453
|
});
|
|
9342
9454
|
console.log(
|
|
9343
|
-
|
|
9455
|
+
chalk99.green(`Removed phase ${phaseIdx + 1} from item #${itemId}.`)
|
|
9344
9456
|
);
|
|
9345
9457
|
}
|
|
9346
9458
|
|
|
9347
9459
|
// src/commands/backlog/update/index.ts
|
|
9348
|
-
import
|
|
9349
|
-
import { eq as
|
|
9460
|
+
import chalk101 from "chalk";
|
|
9461
|
+
import { eq as eq34 } from "drizzle-orm";
|
|
9350
9462
|
|
|
9351
9463
|
// src/commands/backlog/update/applyAcMutations.ts
|
|
9352
9464
|
function hasAcMutations(options2) {
|
|
@@ -9367,16 +9479,16 @@ function applyAcMutations(current, options2) {
|
|
|
9367
9479
|
}
|
|
9368
9480
|
|
|
9369
9481
|
// src/commands/backlog/update/buildUpdateValues.ts
|
|
9370
|
-
import
|
|
9482
|
+
import chalk100 from "chalk";
|
|
9371
9483
|
function buildUpdateValues(options2) {
|
|
9372
9484
|
const { name, desc: desc6, type, ac } = options2;
|
|
9373
9485
|
if (!name && !desc6 && !type && !ac) {
|
|
9374
|
-
console.log(
|
|
9486
|
+
console.log(chalk100.red("Nothing to update. Provide at least one flag."));
|
|
9375
9487
|
process.exitCode = 1;
|
|
9376
9488
|
return void 0;
|
|
9377
9489
|
}
|
|
9378
9490
|
if (type && type !== "story" && type !== "bug") {
|
|
9379
|
-
console.log(
|
|
9491
|
+
console.log(chalk100.red('Invalid type. Must be "story" or "bug".'));
|
|
9380
9492
|
process.exitCode = 1;
|
|
9381
9493
|
return void 0;
|
|
9382
9494
|
}
|
|
@@ -9409,14 +9521,14 @@ async function update(id2, options2) {
|
|
|
9409
9521
|
if (hasAcMutations(options2)) {
|
|
9410
9522
|
if (options2.ac) {
|
|
9411
9523
|
console.log(
|
|
9412
|
-
|
|
9524
|
+
chalk101.red("Cannot combine --ac with --add-ac/--edit-ac/--remove-ac.")
|
|
9413
9525
|
);
|
|
9414
9526
|
process.exitCode = 1;
|
|
9415
9527
|
return;
|
|
9416
9528
|
}
|
|
9417
9529
|
const mutation = applyAcMutations(found.item.acceptanceCriteria, options2);
|
|
9418
9530
|
if (!mutation.ok) {
|
|
9419
|
-
console.log(
|
|
9531
|
+
console.log(chalk101.red(mutation.error));
|
|
9420
9532
|
process.exitCode = 1;
|
|
9421
9533
|
return;
|
|
9422
9534
|
}
|
|
@@ -9426,8 +9538,8 @@ async function update(id2, options2) {
|
|
|
9426
9538
|
if (!built) return;
|
|
9427
9539
|
const { orm } = found;
|
|
9428
9540
|
const itemId = found.item.id;
|
|
9429
|
-
await orm.update(items).set(built.set).where(
|
|
9430
|
-
console.log(
|
|
9541
|
+
await orm.update(items).set(built.set).where(eq34(items.id, itemId));
|
|
9542
|
+
console.log(chalk101.green(`Updated ${built.fields} on item #${itemId}.`));
|
|
9431
9543
|
}
|
|
9432
9544
|
|
|
9433
9545
|
// src/commands/backlog/registerUpdateCommands.ts
|
|
@@ -10229,11 +10341,11 @@ function assertCliExists(cli) {
|
|
|
10229
10341
|
}
|
|
10230
10342
|
|
|
10231
10343
|
// src/commands/permitCliReads/colorize.ts
|
|
10232
|
-
import
|
|
10344
|
+
import chalk102 from "chalk";
|
|
10233
10345
|
function colorize(plainOutput) {
|
|
10234
10346
|
return plainOutput.split("\n").map((line) => {
|
|
10235
|
-
if (line.startsWith(" R ")) return
|
|
10236
|
-
if (line.startsWith(" W ")) return
|
|
10347
|
+
if (line.startsWith(" R ")) return chalk102.green(line);
|
|
10348
|
+
if (line.startsWith(" W ")) return chalk102.red(line);
|
|
10237
10349
|
return line;
|
|
10238
10350
|
}).join("\n");
|
|
10239
10351
|
}
|
|
@@ -10531,7 +10643,7 @@ async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
|
10531
10643
|
}
|
|
10532
10644
|
|
|
10533
10645
|
// src/commands/deny/denyAdd.ts
|
|
10534
|
-
import
|
|
10646
|
+
import chalk103 from "chalk";
|
|
10535
10647
|
|
|
10536
10648
|
// src/commands/deny/loadDenyConfig.ts
|
|
10537
10649
|
function loadDenyConfig(global) {
|
|
@@ -10551,16 +10663,16 @@ function loadDenyConfig(global) {
|
|
|
10551
10663
|
function denyAdd(pattern2, message, options2) {
|
|
10552
10664
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
10553
10665
|
if (deny.some((r) => r.pattern === pattern2)) {
|
|
10554
|
-
console.log(
|
|
10666
|
+
console.log(chalk103.yellow(`Deny rule already exists for: ${pattern2}`));
|
|
10555
10667
|
return;
|
|
10556
10668
|
}
|
|
10557
10669
|
deny.push({ pattern: pattern2, message });
|
|
10558
10670
|
saveDeny(deny);
|
|
10559
|
-
console.log(
|
|
10671
|
+
console.log(chalk103.green(`Added deny rule: ${pattern2} \u2192 ${message}`));
|
|
10560
10672
|
}
|
|
10561
10673
|
|
|
10562
10674
|
// src/commands/deny/denyList.ts
|
|
10563
|
-
import
|
|
10675
|
+
import chalk104 from "chalk";
|
|
10564
10676
|
function denyList() {
|
|
10565
10677
|
const globalRaw = loadGlobalConfigRaw();
|
|
10566
10678
|
const projectRaw = loadProjectConfig();
|
|
@@ -10571,7 +10683,7 @@ function denyList() {
|
|
|
10571
10683
|
projectDeny.length > 0 ? projectDeny : void 0
|
|
10572
10684
|
);
|
|
10573
10685
|
if (!merged || merged.length === 0) {
|
|
10574
|
-
console.log(
|
|
10686
|
+
console.log(chalk104.dim("No deny rules configured."));
|
|
10575
10687
|
return;
|
|
10576
10688
|
}
|
|
10577
10689
|
const projectPatterns = new Set(projectDeny.map((r) => r.pattern));
|
|
@@ -10579,23 +10691,23 @@ function denyList() {
|
|
|
10579
10691
|
for (const rule of merged) {
|
|
10580
10692
|
const inProject = projectPatterns.has(rule.pattern);
|
|
10581
10693
|
const inGlobal = globalPatterns.has(rule.pattern);
|
|
10582
|
-
const label2 = inProject && inGlobal ?
|
|
10583
|
-
console.log(`${
|
|
10694
|
+
const label2 = inProject && inGlobal ? chalk104.dim(" (project, overrides global)") : inGlobal ? chalk104.dim(" (global)") : "";
|
|
10695
|
+
console.log(`${chalk104.red(rule.pattern)} \u2192 ${rule.message}${label2}`);
|
|
10584
10696
|
}
|
|
10585
10697
|
}
|
|
10586
10698
|
|
|
10587
10699
|
// src/commands/deny/denyRemove.ts
|
|
10588
|
-
import
|
|
10700
|
+
import chalk105 from "chalk";
|
|
10589
10701
|
function denyRemove(pattern2, options2) {
|
|
10590
10702
|
const { deny, saveDeny } = loadDenyConfig(options2.global);
|
|
10591
10703
|
const index3 = deny.findIndex((r) => r.pattern === pattern2);
|
|
10592
10704
|
if (index3 === -1) {
|
|
10593
|
-
console.log(
|
|
10705
|
+
console.log(chalk105.yellow(`No deny rule found for: ${pattern2}`));
|
|
10594
10706
|
return;
|
|
10595
10707
|
}
|
|
10596
10708
|
deny.splice(index3, 1);
|
|
10597
10709
|
saveDeny(deny.length > 0 ? deny : void 0);
|
|
10598
|
-
console.log(
|
|
10710
|
+
console.log(chalk105.green(`Removed deny rule: ${pattern2}`));
|
|
10599
10711
|
}
|
|
10600
10712
|
|
|
10601
10713
|
// src/commands/registerDeny.ts
|
|
@@ -10625,7 +10737,7 @@ function registerCliHook(program2) {
|
|
|
10625
10737
|
|
|
10626
10738
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
10627
10739
|
import { existsSync as existsSync30, readFileSync as readFileSync25, unlinkSync as unlinkSync8, writeFileSync as writeFileSync23 } from "fs";
|
|
10628
|
-
import
|
|
10740
|
+
import chalk106 from "chalk";
|
|
10629
10741
|
|
|
10630
10742
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
10631
10743
|
import { homedir as homedir14 } from "os";
|
|
@@ -10678,12 +10790,12 @@ function codeCommentConfirm(pin) {
|
|
|
10678
10790
|
sweepRestrictedDir();
|
|
10679
10791
|
const state = readPinState(pin);
|
|
10680
10792
|
if (!state) {
|
|
10681
|
-
console.error(
|
|
10793
|
+
console.error(chalk106.red(`No pending comment for pin: ${pin}`));
|
|
10682
10794
|
process.exitCode = 1;
|
|
10683
10795
|
return;
|
|
10684
10796
|
}
|
|
10685
10797
|
if (!existsSync30(state.file)) {
|
|
10686
|
-
console.error(
|
|
10798
|
+
console.error(chalk106.red(`Target file no longer exists: ${state.file}`));
|
|
10687
10799
|
process.exitCode = 1;
|
|
10688
10800
|
return;
|
|
10689
10801
|
}
|
|
@@ -10692,7 +10804,7 @@ function codeCommentConfirm(pin) {
|
|
|
10692
10804
|
const index3 = state.line - 1;
|
|
10693
10805
|
if (index3 > lines.length) {
|
|
10694
10806
|
console.error(
|
|
10695
|
-
|
|
10807
|
+
chalk106.red(
|
|
10696
10808
|
`Line ${state.line} is beyond the end of ${state.file} (${lines.length} lines).`
|
|
10697
10809
|
)
|
|
10698
10810
|
);
|
|
@@ -10706,14 +10818,14 @@ function codeCommentConfirm(pin) {
|
|
|
10706
10818
|
writeFileSync23(state.file, lines.join("\n"));
|
|
10707
10819
|
unlinkSync8(getPinStatePath(pin));
|
|
10708
10820
|
console.log(
|
|
10709
|
-
|
|
10821
|
+
chalk106.green(
|
|
10710
10822
|
`Inserted "${marker} ${state.text}" at ${state.file}:${state.line}`
|
|
10711
10823
|
)
|
|
10712
10824
|
);
|
|
10713
10825
|
}
|
|
10714
10826
|
|
|
10715
10827
|
// src/commands/codeComment/codeCommentSet.ts
|
|
10716
|
-
import
|
|
10828
|
+
import chalk107 from "chalk";
|
|
10717
10829
|
|
|
10718
10830
|
// src/commands/codeComment/validateCommentText.ts
|
|
10719
10831
|
var MAX_COMMENT_LENGTH = 50;
|
|
@@ -10764,27 +10876,27 @@ function generatePin() {
|
|
|
10764
10876
|
function codeCommentSet(file, line, text9) {
|
|
10765
10877
|
const lineNumber = Number.parseInt(line, 10);
|
|
10766
10878
|
if (!Number.isInteger(lineNumber) || lineNumber < 1) {
|
|
10767
|
-
console.error(
|
|
10879
|
+
console.error(chalk107.red(`Invalid line number: ${line}`));
|
|
10768
10880
|
process.exitCode = 1;
|
|
10769
10881
|
return;
|
|
10770
10882
|
}
|
|
10771
10883
|
const marker = isYamlFile(file) ? "#" : "//";
|
|
10772
10884
|
const validation = validateCommentText(text9, isYamlFile(file));
|
|
10773
10885
|
if (!validation.ok) {
|
|
10774
|
-
console.error(
|
|
10775
|
-
console.error(
|
|
10886
|
+
console.error(chalk107.red(`Refused: ${validation.reason}`));
|
|
10887
|
+
console.error(chalk107.red("No pin issued."));
|
|
10776
10888
|
process.exitCode = 1;
|
|
10777
10889
|
return;
|
|
10778
10890
|
}
|
|
10779
10891
|
console.error(
|
|
10780
|
-
|
|
10892
|
+
chalk107.yellow.bold(
|
|
10781
10893
|
"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
10894
|
)
|
|
10783
10895
|
);
|
|
10784
10896
|
const delivered = issuePin(file, lineNumber, validation.text);
|
|
10785
10897
|
if (!delivered) {
|
|
10786
10898
|
console.error(
|
|
10787
|
-
|
|
10899
|
+
chalk107.red(
|
|
10788
10900
|
"Could not deliver the confirmation pin via notification.\nThe comment cannot be confirmed until the notification channel works."
|
|
10789
10901
|
)
|
|
10790
10902
|
);
|
|
@@ -10794,7 +10906,7 @@ function codeCommentSet(file, line, text9) {
|
|
|
10794
10906
|
console.log(
|
|
10795
10907
|
`A confirmation pin was sent to your desktop notifications.
|
|
10796
10908
|
To insert "${marker} ${validation.text}" at ${file}:${lineNumber}, run:
|
|
10797
|
-
${
|
|
10909
|
+
${chalk107.cyan(" assist code-comment confirm <PIN>")}
|
|
10798
10910
|
using the pin from that notification.`
|
|
10799
10911
|
);
|
|
10800
10912
|
}
|
|
@@ -10814,15 +10926,15 @@ function registerCodeComment(parent) {
|
|
|
10814
10926
|
}
|
|
10815
10927
|
|
|
10816
10928
|
// src/commands/complexity/analyze.ts
|
|
10817
|
-
import
|
|
10929
|
+
import chalk116 from "chalk";
|
|
10818
10930
|
|
|
10819
10931
|
// src/commands/complexity/cyclomatic.ts
|
|
10820
|
-
import
|
|
10932
|
+
import chalk109 from "chalk";
|
|
10821
10933
|
|
|
10822
10934
|
// src/commands/complexity/shared/index.ts
|
|
10823
10935
|
import fs17 from "fs";
|
|
10824
10936
|
import path21 from "path";
|
|
10825
|
-
import
|
|
10937
|
+
import chalk108 from "chalk";
|
|
10826
10938
|
import ts5 from "typescript";
|
|
10827
10939
|
|
|
10828
10940
|
// src/commands/complexity/findSourceFiles.ts
|
|
@@ -11073,7 +11185,7 @@ function createSourceFromFile(filePath) {
|
|
|
11073
11185
|
function withSourceFiles(pattern2, callback, extraIgnore = []) {
|
|
11074
11186
|
const files = findSourceFiles2(pattern2, ".", extraIgnore);
|
|
11075
11187
|
if (files.length === 0) {
|
|
11076
|
-
console.log(
|
|
11188
|
+
console.log(chalk108.yellow("No files found matching pattern"));
|
|
11077
11189
|
return void 0;
|
|
11078
11190
|
}
|
|
11079
11191
|
return callback(files);
|
|
@@ -11106,11 +11218,11 @@ async function cyclomatic(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11106
11218
|
results.sort((a, b) => b.complexity - a.complexity);
|
|
11107
11219
|
for (const { file, name, complexity } of results) {
|
|
11108
11220
|
const exceedsThreshold = options2.threshold !== void 0 && complexity > options2.threshold;
|
|
11109
|
-
const color = exceedsThreshold ?
|
|
11110
|
-
console.log(`${color(`${file}:${name}`)} \u2192 ${
|
|
11221
|
+
const color = exceedsThreshold ? chalk109.red : chalk109.white;
|
|
11222
|
+
console.log(`${color(`${file}:${name}`)} \u2192 ${chalk109.cyan(complexity)}`);
|
|
11111
11223
|
}
|
|
11112
11224
|
console.log(
|
|
11113
|
-
|
|
11225
|
+
chalk109.dim(
|
|
11114
11226
|
`
|
|
11115
11227
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
11116
11228
|
)
|
|
@@ -11122,7 +11234,7 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
11122
11234
|
}
|
|
11123
11235
|
|
|
11124
11236
|
// src/commands/complexity/halstead.ts
|
|
11125
|
-
import
|
|
11237
|
+
import chalk110 from "chalk";
|
|
11126
11238
|
async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
11127
11239
|
withSourceFiles(pattern2, (files) => {
|
|
11128
11240
|
const results = [];
|
|
@@ -11137,13 +11249,13 @@ async function halstead(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11137
11249
|
results.sort((a, b) => b.metrics.effort - a.metrics.effort);
|
|
11138
11250
|
for (const { file, name, metrics } of results) {
|
|
11139
11251
|
const exceedsThreshold = options2.threshold !== void 0 && metrics.volume > options2.threshold;
|
|
11140
|
-
const color = exceedsThreshold ?
|
|
11252
|
+
const color = exceedsThreshold ? chalk110.red : chalk110.white;
|
|
11141
11253
|
console.log(
|
|
11142
|
-
`${color(`${file}:${name}`)} \u2192 volume: ${
|
|
11254
|
+
`${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
11255
|
);
|
|
11144
11256
|
}
|
|
11145
11257
|
console.log(
|
|
11146
|
-
|
|
11258
|
+
chalk110.dim(
|
|
11147
11259
|
`
|
|
11148
11260
|
Analyzed ${results.length} functions across ${files.length} files`
|
|
11149
11261
|
)
|
|
@@ -11155,27 +11267,27 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
11155
11267
|
}
|
|
11156
11268
|
|
|
11157
11269
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
11158
|
-
import
|
|
11270
|
+
import chalk113 from "chalk";
|
|
11159
11271
|
|
|
11160
11272
|
// src/commands/complexity/maintainability/formatResultLine.ts
|
|
11161
|
-
import
|
|
11273
|
+
import chalk111 from "chalk";
|
|
11162
11274
|
function formatResultLine(entry, failing) {
|
|
11163
11275
|
const { file, avgMaintainability, minMaintainability, override } = entry;
|
|
11164
|
-
const name = failing ?
|
|
11165
|
-
const suffix = override !== void 0 ?
|
|
11166
|
-
return `${name} \u2192 avg: ${
|
|
11276
|
+
const name = failing ? chalk111.red(file) : chalk111.white(file);
|
|
11277
|
+
const suffix = override !== void 0 ? chalk111.magenta(` (override: ${override})`) : "";
|
|
11278
|
+
return `${name} \u2192 avg: ${chalk111.cyan(avgMaintainability.toFixed(1))}, min: ${chalk111.yellow(minMaintainability.toFixed(1))}${suffix}`;
|
|
11167
11279
|
}
|
|
11168
11280
|
|
|
11169
11281
|
// src/commands/complexity/maintainability/printMaintainabilityFailure.ts
|
|
11170
|
-
import
|
|
11282
|
+
import chalk112 from "chalk";
|
|
11171
11283
|
function printMaintainabilityFailure(failingCount, threshold) {
|
|
11172
11284
|
const thresholdLabel = threshold !== void 0 ? ` ${threshold}` : "";
|
|
11173
11285
|
console.error(
|
|
11174
|
-
|
|
11286
|
+
chalk112.red(
|
|
11175
11287
|
`
|
|
11176
11288
|
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
11289
|
|
|
11178
|
-
\u26A0\uFE0F ${
|
|
11290
|
+
\u26A0\uFE0F ${chalk112.bold("Diagnose and fix one file at a time")} \u2014 do not investigate or fix multiple files in parallel.
|
|
11179
11291
|
|
|
11180
11292
|
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
11293
|
)
|
|
@@ -11187,7 +11299,7 @@ function displayMaintainabilityResults(results, threshold) {
|
|
|
11187
11299
|
const gating = threshold !== void 0 || results.some((r) => r.override !== void 0);
|
|
11188
11300
|
if (!gating) {
|
|
11189
11301
|
for (const entry of results) console.log(formatResultLine(entry, false));
|
|
11190
|
-
console.log(
|
|
11302
|
+
console.log(chalk113.dim(`
|
|
11191
11303
|
Analyzed ${results.length} files`));
|
|
11192
11304
|
return;
|
|
11193
11305
|
}
|
|
@@ -11196,7 +11308,7 @@ Analyzed ${results.length} files`));
|
|
|
11196
11308
|
return limit !== void 0 && r.minMaintainability < limit;
|
|
11197
11309
|
});
|
|
11198
11310
|
if (failing.length === 0) {
|
|
11199
|
-
console.log(
|
|
11311
|
+
console.log(chalk113.green("All files pass maintainability threshold"));
|
|
11200
11312
|
} else {
|
|
11201
11313
|
for (const entry of failing) console.log(formatResultLine(entry, true));
|
|
11202
11314
|
}
|
|
@@ -11205,7 +11317,7 @@ Analyzed ${results.length} files`));
|
|
|
11205
11317
|
);
|
|
11206
11318
|
for (const entry of passingOverrides)
|
|
11207
11319
|
console.log(formatResultLine(entry, false));
|
|
11208
|
-
console.log(
|
|
11320
|
+
console.log(chalk113.dim(`
|
|
11209
11321
|
Analyzed ${results.length} files`));
|
|
11210
11322
|
if (failing.length > 0) {
|
|
11211
11323
|
printMaintainabilityFailure(failing.length, threshold);
|
|
@@ -11214,10 +11326,10 @@ Analyzed ${results.length} files`));
|
|
|
11214
11326
|
}
|
|
11215
11327
|
|
|
11216
11328
|
// src/commands/complexity/maintainability/printMaintainabilityFormula.ts
|
|
11217
|
-
import
|
|
11329
|
+
import chalk114 from "chalk";
|
|
11218
11330
|
var MI_FORMULA = "171 - 5.2*ln(HalsteadVolume) - 0.23*CyclomaticComplexity - 16.2*ln(SLOC), clamped 0-100";
|
|
11219
11331
|
function printMaintainabilityFormula() {
|
|
11220
|
-
console.log(
|
|
11332
|
+
console.log(chalk114.dim(MI_FORMULA));
|
|
11221
11333
|
}
|
|
11222
11334
|
|
|
11223
11335
|
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
@@ -11293,7 +11405,7 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11293
11405
|
|
|
11294
11406
|
// src/commands/complexity/sloc.ts
|
|
11295
11407
|
import fs19 from "fs";
|
|
11296
|
-
import
|
|
11408
|
+
import chalk115 from "chalk";
|
|
11297
11409
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
11298
11410
|
withSourceFiles(pattern2, (files) => {
|
|
11299
11411
|
const results = [];
|
|
@@ -11309,12 +11421,12 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
11309
11421
|
results.sort((a, b) => b.lines - a.lines);
|
|
11310
11422
|
for (const { file, lines } of results) {
|
|
11311
11423
|
const exceedsThreshold = options2.threshold !== void 0 && lines > options2.threshold;
|
|
11312
|
-
const color = exceedsThreshold ?
|
|
11313
|
-
console.log(`${color(file)} \u2192 ${
|
|
11424
|
+
const color = exceedsThreshold ? chalk115.red : chalk115.white;
|
|
11425
|
+
console.log(`${color(file)} \u2192 ${chalk115.cyan(lines)} lines`);
|
|
11314
11426
|
}
|
|
11315
11427
|
const total = results.reduce((sum, r) => sum + r.lines, 0);
|
|
11316
11428
|
console.log(
|
|
11317
|
-
|
|
11429
|
+
chalk115.dim(`
|
|
11318
11430
|
Total: ${total} lines across ${files.length} files`)
|
|
11319
11431
|
);
|
|
11320
11432
|
if (hasViolation) {
|
|
@@ -11328,25 +11440,25 @@ async function analyze(pattern2) {
|
|
|
11328
11440
|
const searchPattern = pattern2.includes("*") || pattern2.includes("/") ? pattern2 : `**/${pattern2}`;
|
|
11329
11441
|
const files = findSourceFiles2(searchPattern);
|
|
11330
11442
|
if (files.length === 0) {
|
|
11331
|
-
console.log(
|
|
11443
|
+
console.log(chalk116.yellow("No files found matching pattern"));
|
|
11332
11444
|
return;
|
|
11333
11445
|
}
|
|
11334
11446
|
if (files.length === 1) {
|
|
11335
11447
|
const file = files[0];
|
|
11336
|
-
console.log(
|
|
11448
|
+
console.log(chalk116.bold.underline("SLOC"));
|
|
11337
11449
|
await sloc(file);
|
|
11338
11450
|
console.log();
|
|
11339
|
-
console.log(
|
|
11451
|
+
console.log(chalk116.bold.underline("Cyclomatic Complexity"));
|
|
11340
11452
|
await cyclomatic(file);
|
|
11341
11453
|
console.log();
|
|
11342
|
-
console.log(
|
|
11454
|
+
console.log(chalk116.bold.underline("Halstead Metrics"));
|
|
11343
11455
|
await halstead(file);
|
|
11344
11456
|
console.log();
|
|
11345
|
-
console.log(
|
|
11457
|
+
console.log(chalk116.bold.underline("Maintainability Index"));
|
|
11346
11458
|
await maintainability(file);
|
|
11347
11459
|
console.log();
|
|
11348
11460
|
console.log(
|
|
11349
|
-
|
|
11461
|
+
chalk116.dim(
|
|
11350
11462
|
"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
11463
|
)
|
|
11352
11464
|
);
|
|
@@ -11380,7 +11492,7 @@ function registerComplexity(program2) {
|
|
|
11380
11492
|
}
|
|
11381
11493
|
|
|
11382
11494
|
// src/commands/config/index.ts
|
|
11383
|
-
import
|
|
11495
|
+
import chalk117 from "chalk";
|
|
11384
11496
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
11385
11497
|
|
|
11386
11498
|
// src/commands/config/setNestedValue.ts
|
|
@@ -11443,7 +11555,7 @@ function formatIssuePath(issue, key) {
|
|
|
11443
11555
|
function printValidationErrors(issues, key) {
|
|
11444
11556
|
for (const issue of issues) {
|
|
11445
11557
|
console.error(
|
|
11446
|
-
|
|
11558
|
+
chalk117.red(`${formatIssuePath(issue, key)}: ${issue.message}`)
|
|
11447
11559
|
);
|
|
11448
11560
|
}
|
|
11449
11561
|
}
|
|
@@ -11460,7 +11572,7 @@ var GLOBAL_ONLY_KEYS = ["sync.autoConfirm"];
|
|
|
11460
11572
|
function assertNotGlobalOnly(key, global) {
|
|
11461
11573
|
if (!global && GLOBAL_ONLY_KEYS.some((k) => key.startsWith(k))) {
|
|
11462
11574
|
console.error(
|
|
11463
|
-
|
|
11575
|
+
chalk117.red(
|
|
11464
11576
|
`"${key}" is a global-only key. Use --global to set it in ~/.assist.yml`
|
|
11465
11577
|
)
|
|
11466
11578
|
);
|
|
@@ -11483,7 +11595,7 @@ function configSet(key, value, options2 = {}) {
|
|
|
11483
11595
|
applyConfigSet(key, coerced, options2.global ?? false);
|
|
11484
11596
|
const target = options2.global ? "global" : "project";
|
|
11485
11597
|
console.log(
|
|
11486
|
-
|
|
11598
|
+
chalk117.green(`Set ${key} = ${JSON.stringify(coerced)} (${target})`)
|
|
11487
11599
|
);
|
|
11488
11600
|
}
|
|
11489
11601
|
function configList() {
|
|
@@ -11492,7 +11604,7 @@ function configList() {
|
|
|
11492
11604
|
}
|
|
11493
11605
|
|
|
11494
11606
|
// src/commands/config/configGet.ts
|
|
11495
|
-
import
|
|
11607
|
+
import chalk118 from "chalk";
|
|
11496
11608
|
|
|
11497
11609
|
// src/commands/config/getNestedValue.ts
|
|
11498
11610
|
function isTraversable(value) {
|
|
@@ -11524,7 +11636,7 @@ function requireNestedValue(config, key) {
|
|
|
11524
11636
|
return value;
|
|
11525
11637
|
}
|
|
11526
11638
|
function exitKeyNotSet(key) {
|
|
11527
|
-
console.error(
|
|
11639
|
+
console.error(chalk118.red(`Key "${key}" is not set`));
|
|
11528
11640
|
process.exit(1);
|
|
11529
11641
|
}
|
|
11530
11642
|
|
|
@@ -11538,7 +11650,7 @@ function registerConfig(program2) {
|
|
|
11538
11650
|
|
|
11539
11651
|
// src/commands/deploy/redirect.ts
|
|
11540
11652
|
import { existsSync as existsSync31, readFileSync as readFileSync26, writeFileSync as writeFileSync25 } from "fs";
|
|
11541
|
-
import
|
|
11653
|
+
import chalk119 from "chalk";
|
|
11542
11654
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
11543
11655
|
if (!window.location.pathname.endsWith('/')) {
|
|
11544
11656
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -11547,23 +11659,23 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
11547
11659
|
function redirect() {
|
|
11548
11660
|
const indexPath = "index.html";
|
|
11549
11661
|
if (!existsSync31(indexPath)) {
|
|
11550
|
-
console.log(
|
|
11662
|
+
console.log(chalk119.yellow("No index.html found"));
|
|
11551
11663
|
return;
|
|
11552
11664
|
}
|
|
11553
11665
|
const content = readFileSync26(indexPath, "utf8");
|
|
11554
11666
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
11555
|
-
console.log(
|
|
11667
|
+
console.log(chalk119.dim("Trailing slash script already present"));
|
|
11556
11668
|
return;
|
|
11557
11669
|
}
|
|
11558
11670
|
const headCloseIndex = content.indexOf("</head>");
|
|
11559
11671
|
if (headCloseIndex === -1) {
|
|
11560
|
-
console.log(
|
|
11672
|
+
console.log(chalk119.red("Could not find </head> tag in index.html"));
|
|
11561
11673
|
return;
|
|
11562
11674
|
}
|
|
11563
11675
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
11564
11676
|
${content.slice(headCloseIndex)}`;
|
|
11565
11677
|
writeFileSync25(indexPath, newContent);
|
|
11566
|
-
console.log(
|
|
11678
|
+
console.log(chalk119.green("Added trailing slash redirect to index.html"));
|
|
11567
11679
|
}
|
|
11568
11680
|
|
|
11569
11681
|
// src/commands/registerDeploy.ts
|
|
@@ -11590,7 +11702,7 @@ function loadBlogSkipDays(repoName) {
|
|
|
11590
11702
|
|
|
11591
11703
|
// src/commands/devlog/shared.ts
|
|
11592
11704
|
import { execSync as execSync27 } from "child_process";
|
|
11593
|
-
import
|
|
11705
|
+
import chalk120 from "chalk";
|
|
11594
11706
|
|
|
11595
11707
|
// src/shared/getRepoName.ts
|
|
11596
11708
|
import { existsSync as existsSync32, readFileSync as readFileSync27 } from "fs";
|
|
@@ -11699,13 +11811,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
11699
11811
|
}
|
|
11700
11812
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
11701
11813
|
for (const commit2 of commits2) {
|
|
11702
|
-
console.log(` ${
|
|
11814
|
+
console.log(` ${chalk120.yellow(commit2.hash)} ${commit2.message}`);
|
|
11703
11815
|
if (verbose) {
|
|
11704
11816
|
const visibleFiles = commit2.files.filter(
|
|
11705
11817
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
11706
11818
|
);
|
|
11707
11819
|
for (const file of visibleFiles) {
|
|
11708
|
-
console.log(` ${
|
|
11820
|
+
console.log(` ${chalk120.dim(file)}`);
|
|
11709
11821
|
}
|
|
11710
11822
|
}
|
|
11711
11823
|
}
|
|
@@ -11730,15 +11842,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
11730
11842
|
}
|
|
11731
11843
|
|
|
11732
11844
|
// src/commands/devlog/list/printDateHeader.ts
|
|
11733
|
-
import
|
|
11845
|
+
import chalk121 from "chalk";
|
|
11734
11846
|
function printDateHeader(date, isSkipped, entries) {
|
|
11735
11847
|
if (isSkipped) {
|
|
11736
|
-
console.log(`${
|
|
11848
|
+
console.log(`${chalk121.bold.blue(date)} ${chalk121.dim("skipped")}`);
|
|
11737
11849
|
} else if (entries && entries.length > 0) {
|
|
11738
|
-
const entryInfo = entries.map((e) => `${
|
|
11739
|
-
console.log(`${
|
|
11850
|
+
const entryInfo = entries.map((e) => `${chalk121.green(e.version)} ${e.title}`).join(" | ");
|
|
11851
|
+
console.log(`${chalk121.bold.blue(date)} ${entryInfo}`);
|
|
11740
11852
|
} else {
|
|
11741
|
-
console.log(`${
|
|
11853
|
+
console.log(`${chalk121.bold.blue(date)} ${chalk121.red("\u26A0 devlog missing")}`);
|
|
11742
11854
|
}
|
|
11743
11855
|
}
|
|
11744
11856
|
|
|
@@ -11842,24 +11954,24 @@ function bumpVersion(version2, type) {
|
|
|
11842
11954
|
|
|
11843
11955
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
11844
11956
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
11845
|
-
import
|
|
11957
|
+
import chalk123 from "chalk";
|
|
11846
11958
|
|
|
11847
11959
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
11848
|
-
import
|
|
11960
|
+
import chalk122 from "chalk";
|
|
11849
11961
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
11850
11962
|
if (conventional && firstHash) {
|
|
11851
11963
|
const version2 = getVersionAtCommit(firstHash);
|
|
11852
11964
|
if (version2) {
|
|
11853
|
-
console.log(`${
|
|
11965
|
+
console.log(`${chalk122.bold("version:")} ${stripToMinor(version2)}`);
|
|
11854
11966
|
} else {
|
|
11855
|
-
console.log(`${
|
|
11967
|
+
console.log(`${chalk122.bold("version:")} ${chalk122.red("unknown")}`);
|
|
11856
11968
|
}
|
|
11857
11969
|
} else if (patchVersion && minorVersion) {
|
|
11858
11970
|
console.log(
|
|
11859
|
-
`${
|
|
11971
|
+
`${chalk122.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
11860
11972
|
);
|
|
11861
11973
|
} else {
|
|
11862
|
-
console.log(`${
|
|
11974
|
+
console.log(`${chalk122.bold("version:")} v0.1 (initial)`);
|
|
11863
11975
|
}
|
|
11864
11976
|
}
|
|
11865
11977
|
|
|
@@ -11907,16 +12019,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
11907
12019
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
11908
12020
|
}
|
|
11909
12021
|
function logName(repoName) {
|
|
11910
|
-
console.log(`${
|
|
12022
|
+
console.log(`${chalk123.bold("name:")} ${repoName}`);
|
|
11911
12023
|
}
|
|
11912
12024
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
11913
12025
|
logName(ctx.repoName);
|
|
11914
12026
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
11915
|
-
console.log(
|
|
12027
|
+
console.log(chalk123.bold.blue(targetDate));
|
|
11916
12028
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
11917
12029
|
}
|
|
11918
12030
|
function logNoCommits(lastInfo) {
|
|
11919
|
-
console.log(
|
|
12031
|
+
console.log(chalk123.dim(noCommitsMessage(!!lastInfo)));
|
|
11920
12032
|
}
|
|
11921
12033
|
|
|
11922
12034
|
// src/commands/devlog/next/index.ts
|
|
@@ -11957,11 +12069,11 @@ function next2(options2) {
|
|
|
11957
12069
|
import { execSync as execSync29 } from "child_process";
|
|
11958
12070
|
|
|
11959
12071
|
// src/commands/devlog/repos/printReposTable.ts
|
|
11960
|
-
import
|
|
12072
|
+
import chalk124 from "chalk";
|
|
11961
12073
|
function colorStatus(status2) {
|
|
11962
|
-
if (status2 === "missing") return
|
|
11963
|
-
if (status2 === "outdated") return
|
|
11964
|
-
return
|
|
12074
|
+
if (status2 === "missing") return chalk124.red(status2);
|
|
12075
|
+
if (status2 === "outdated") return chalk124.yellow(status2);
|
|
12076
|
+
return chalk124.green(status2);
|
|
11965
12077
|
}
|
|
11966
12078
|
function formatRow(row, nameWidth) {
|
|
11967
12079
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -11975,8 +12087,8 @@ function printReposTable(rows) {
|
|
|
11975
12087
|
"Last Devlog".padEnd(11),
|
|
11976
12088
|
"Status"
|
|
11977
12089
|
].join(" ");
|
|
11978
|
-
console.log(
|
|
11979
|
-
console.log(
|
|
12090
|
+
console.log(chalk124.dim(header));
|
|
12091
|
+
console.log(chalk124.dim("-".repeat(header.length)));
|
|
11980
12092
|
for (const row of rows) {
|
|
11981
12093
|
console.log(formatRow(row, nameWidth));
|
|
11982
12094
|
}
|
|
@@ -12034,14 +12146,14 @@ function repos(options2) {
|
|
|
12034
12146
|
// src/commands/devlog/skip.ts
|
|
12035
12147
|
import { writeFileSync as writeFileSync26 } from "fs";
|
|
12036
12148
|
import { join as join33 } from "path";
|
|
12037
|
-
import
|
|
12149
|
+
import chalk125 from "chalk";
|
|
12038
12150
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
12039
12151
|
function getBlogConfigPath() {
|
|
12040
12152
|
return join33(BLOG_REPO_ROOT, "assist.yml");
|
|
12041
12153
|
}
|
|
12042
12154
|
function skip(date) {
|
|
12043
12155
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
12044
|
-
console.log(
|
|
12156
|
+
console.log(chalk125.red("Invalid date format. Use YYYY-MM-DD"));
|
|
12045
12157
|
process.exit(1);
|
|
12046
12158
|
}
|
|
12047
12159
|
const repoName = getRepoName();
|
|
@@ -12052,7 +12164,7 @@ function skip(date) {
|
|
|
12052
12164
|
const skipDays = skip2[repoName] ?? [];
|
|
12053
12165
|
if (skipDays.includes(date)) {
|
|
12054
12166
|
console.log(
|
|
12055
|
-
|
|
12167
|
+
chalk125.yellow(`${date} is already in skip list for ${repoName}`)
|
|
12056
12168
|
);
|
|
12057
12169
|
return;
|
|
12058
12170
|
}
|
|
@@ -12062,20 +12174,20 @@ function skip(date) {
|
|
|
12062
12174
|
devlog.skip = skip2;
|
|
12063
12175
|
config.devlog = devlog;
|
|
12064
12176
|
writeFileSync26(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
12065
|
-
console.log(
|
|
12177
|
+
console.log(chalk125.green(`Added ${date} to skip list for ${repoName}`));
|
|
12066
12178
|
}
|
|
12067
12179
|
|
|
12068
12180
|
// src/commands/devlog/version.ts
|
|
12069
|
-
import
|
|
12181
|
+
import chalk126 from "chalk";
|
|
12070
12182
|
function version() {
|
|
12071
12183
|
const config = loadConfig();
|
|
12072
12184
|
const name = getRepoName();
|
|
12073
12185
|
const lastInfo = getLastVersionInfo(name, config);
|
|
12074
12186
|
const lastVersion = lastInfo?.version ?? null;
|
|
12075
12187
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
12076
|
-
console.log(`${
|
|
12077
|
-
console.log(`${
|
|
12078
|
-
console.log(`${
|
|
12188
|
+
console.log(`${chalk126.bold("name:")} ${name}`);
|
|
12189
|
+
console.log(`${chalk126.bold("last:")} ${lastVersion ?? chalk126.dim("none")}`);
|
|
12190
|
+
console.log(`${chalk126.bold("next:")} ${nextVersion ?? chalk126.dim("none")}`);
|
|
12079
12191
|
}
|
|
12080
12192
|
|
|
12081
12193
|
// src/commands/registerDevlog.ts
|
|
@@ -12099,7 +12211,7 @@ function registerDevlog(program2) {
|
|
|
12099
12211
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
12100
12212
|
import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4 } from "fs";
|
|
12101
12213
|
import { join as join34 } from "path";
|
|
12102
|
-
import
|
|
12214
|
+
import chalk127 from "chalk";
|
|
12103
12215
|
|
|
12104
12216
|
// src/shared/findRepoRoot.ts
|
|
12105
12217
|
import { existsSync as existsSync33 } from "fs";
|
|
@@ -12162,14 +12274,14 @@ function checkBuildLocks(startDir) {
|
|
|
12162
12274
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
12163
12275
|
if (locked) {
|
|
12164
12276
|
console.error(
|
|
12165
|
-
|
|
12277
|
+
chalk127.red("Build output locked (is VS debugging?): ") + locked
|
|
12166
12278
|
);
|
|
12167
12279
|
process.exit(1);
|
|
12168
12280
|
}
|
|
12169
12281
|
}
|
|
12170
12282
|
async function checkBuildLocksCommand() {
|
|
12171
12283
|
checkBuildLocks();
|
|
12172
|
-
console.log(
|
|
12284
|
+
console.log(chalk127.green("No build locks detected"));
|
|
12173
12285
|
}
|
|
12174
12286
|
|
|
12175
12287
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -12268,30 +12380,30 @@ function escapeRegex(s) {
|
|
|
12268
12380
|
}
|
|
12269
12381
|
|
|
12270
12382
|
// src/commands/dotnet/printTree.ts
|
|
12271
|
-
import
|
|
12383
|
+
import chalk128 from "chalk";
|
|
12272
12384
|
function printNodes(nodes, prefix2) {
|
|
12273
12385
|
for (let i = 0; i < nodes.length; i++) {
|
|
12274
12386
|
const isLast = i === nodes.length - 1;
|
|
12275
12387
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
12276
12388
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
12277
12389
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
12278
|
-
const label2 = isMissing ?
|
|
12390
|
+
const label2 = isMissing ? chalk128.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
12279
12391
|
console.log(`${prefix2}${connector}${label2}`);
|
|
12280
12392
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
12281
12393
|
}
|
|
12282
12394
|
}
|
|
12283
12395
|
function printTree(tree, totalCount, solutions) {
|
|
12284
|
-
console.log(
|
|
12285
|
-
console.log(
|
|
12396
|
+
console.log(chalk128.bold("\nProject Dependency Tree"));
|
|
12397
|
+
console.log(chalk128.cyan(tree.relativePath));
|
|
12286
12398
|
printNodes(tree.children, "");
|
|
12287
|
-
console.log(
|
|
12399
|
+
console.log(chalk128.dim(`
|
|
12288
12400
|
${totalCount} projects total (including root)`));
|
|
12289
|
-
console.log(
|
|
12401
|
+
console.log(chalk128.bold("\nSolution Membership"));
|
|
12290
12402
|
if (solutions.length === 0) {
|
|
12291
|
-
console.log(
|
|
12403
|
+
console.log(chalk128.yellow(" Not found in any .sln"));
|
|
12292
12404
|
} else {
|
|
12293
12405
|
for (const sln of solutions) {
|
|
12294
|
-
console.log(` ${
|
|
12406
|
+
console.log(` ${chalk128.green(sln)}`);
|
|
12295
12407
|
}
|
|
12296
12408
|
}
|
|
12297
12409
|
console.log();
|
|
@@ -12320,16 +12432,16 @@ function printJson(tree, totalCount, solutions) {
|
|
|
12320
12432
|
// src/commands/dotnet/resolveCsproj.ts
|
|
12321
12433
|
import { existsSync as existsSync34 } from "fs";
|
|
12322
12434
|
import path25 from "path";
|
|
12323
|
-
import
|
|
12435
|
+
import chalk129 from "chalk";
|
|
12324
12436
|
function resolveCsproj(csprojPath) {
|
|
12325
12437
|
const resolved = path25.resolve(csprojPath);
|
|
12326
12438
|
if (!existsSync34(resolved)) {
|
|
12327
|
-
console.error(
|
|
12439
|
+
console.error(chalk129.red(`File not found: ${resolved}`));
|
|
12328
12440
|
process.exit(1);
|
|
12329
12441
|
}
|
|
12330
12442
|
const repoRoot = findRepoRoot(path25.dirname(resolved));
|
|
12331
12443
|
if (!repoRoot) {
|
|
12332
|
-
console.error(
|
|
12444
|
+
console.error(chalk129.red("Could not find git repository root"));
|
|
12333
12445
|
process.exit(1);
|
|
12334
12446
|
}
|
|
12335
12447
|
return { resolved, repoRoot };
|
|
@@ -12379,12 +12491,12 @@ function getChangedCsFiles(scope) {
|
|
|
12379
12491
|
}
|
|
12380
12492
|
|
|
12381
12493
|
// src/commands/dotnet/inSln.ts
|
|
12382
|
-
import
|
|
12494
|
+
import chalk130 from "chalk";
|
|
12383
12495
|
async function inSln(csprojPath) {
|
|
12384
12496
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
12385
12497
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
12386
12498
|
if (solutions.length === 0) {
|
|
12387
|
-
console.log(
|
|
12499
|
+
console.log(chalk130.yellow("Not found in any .sln file"));
|
|
12388
12500
|
process.exit(1);
|
|
12389
12501
|
}
|
|
12390
12502
|
for (const sln of solutions) {
|
|
@@ -12393,7 +12505,7 @@ async function inSln(csprojPath) {
|
|
|
12393
12505
|
}
|
|
12394
12506
|
|
|
12395
12507
|
// src/commands/dotnet/inspect.ts
|
|
12396
|
-
import
|
|
12508
|
+
import chalk136 from "chalk";
|
|
12397
12509
|
|
|
12398
12510
|
// src/shared/formatElapsed.ts
|
|
12399
12511
|
function formatElapsed(ms) {
|
|
@@ -12405,12 +12517,12 @@ function formatElapsed(ms) {
|
|
|
12405
12517
|
}
|
|
12406
12518
|
|
|
12407
12519
|
// src/commands/dotnet/displayIssues.ts
|
|
12408
|
-
import
|
|
12520
|
+
import chalk131 from "chalk";
|
|
12409
12521
|
var SEVERITY_COLOR = {
|
|
12410
|
-
ERROR:
|
|
12411
|
-
WARNING:
|
|
12412
|
-
SUGGESTION:
|
|
12413
|
-
HINT:
|
|
12522
|
+
ERROR: chalk131.red,
|
|
12523
|
+
WARNING: chalk131.yellow,
|
|
12524
|
+
SUGGESTION: chalk131.cyan,
|
|
12525
|
+
HINT: chalk131.dim
|
|
12414
12526
|
};
|
|
12415
12527
|
function groupByFile(issues) {
|
|
12416
12528
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -12426,15 +12538,15 @@ function groupByFile(issues) {
|
|
|
12426
12538
|
}
|
|
12427
12539
|
function displayIssues(issues) {
|
|
12428
12540
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
12429
|
-
console.log(
|
|
12541
|
+
console.log(chalk131.bold(file));
|
|
12430
12542
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
12431
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
12543
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk131.white;
|
|
12432
12544
|
console.log(
|
|
12433
|
-
` ${
|
|
12545
|
+
` ${chalk131.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
12434
12546
|
);
|
|
12435
12547
|
}
|
|
12436
12548
|
}
|
|
12437
|
-
console.log(
|
|
12549
|
+
console.log(chalk131.dim(`
|
|
12438
12550
|
${issues.length} issue(s) found`));
|
|
12439
12551
|
}
|
|
12440
12552
|
|
|
@@ -12493,12 +12605,12 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
12493
12605
|
// src/commands/dotnet/resolveSolution.ts
|
|
12494
12606
|
import { existsSync as existsSync35 } from "fs";
|
|
12495
12607
|
import path26 from "path";
|
|
12496
|
-
import
|
|
12608
|
+
import chalk133 from "chalk";
|
|
12497
12609
|
|
|
12498
12610
|
// src/commands/dotnet/findSolution.ts
|
|
12499
12611
|
import { readdirSync as readdirSync6 } from "fs";
|
|
12500
12612
|
import { dirname as dirname20, join as join35 } from "path";
|
|
12501
|
-
import
|
|
12613
|
+
import chalk132 from "chalk";
|
|
12502
12614
|
function findSlnInDir(dir) {
|
|
12503
12615
|
try {
|
|
12504
12616
|
return readdirSync6(dir).filter((f) => f.endsWith(".sln")).map((f) => join35(dir, f));
|
|
@@ -12514,17 +12626,17 @@ function findSolution() {
|
|
|
12514
12626
|
const slnFiles = findSlnInDir(current);
|
|
12515
12627
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
12516
12628
|
if (slnFiles.length > 1) {
|
|
12517
|
-
console.error(
|
|
12629
|
+
console.error(chalk132.red(`Multiple .sln files found in ${current}:`));
|
|
12518
12630
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
12519
12631
|
console.error(
|
|
12520
|
-
|
|
12632
|
+
chalk132.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
12521
12633
|
);
|
|
12522
12634
|
process.exit(1);
|
|
12523
12635
|
}
|
|
12524
12636
|
if (current === ceiling) break;
|
|
12525
12637
|
current = dirname20(current);
|
|
12526
12638
|
}
|
|
12527
|
-
console.error(
|
|
12639
|
+
console.error(chalk132.red("No .sln file found between cwd and repo root"));
|
|
12528
12640
|
process.exit(1);
|
|
12529
12641
|
}
|
|
12530
12642
|
|
|
@@ -12533,7 +12645,7 @@ function resolveSolution(sln) {
|
|
|
12533
12645
|
if (sln) {
|
|
12534
12646
|
const resolved = path26.resolve(sln);
|
|
12535
12647
|
if (!existsSync35(resolved)) {
|
|
12536
|
-
console.error(
|
|
12648
|
+
console.error(chalk133.red(`Solution file not found: ${resolved}`));
|
|
12537
12649
|
process.exit(1);
|
|
12538
12650
|
}
|
|
12539
12651
|
return resolved;
|
|
@@ -12575,14 +12687,14 @@ import { execSync as execSync31 } from "child_process";
|
|
|
12575
12687
|
import { existsSync as existsSync36, readFileSync as readFileSync31, unlinkSync as unlinkSync9 } from "fs";
|
|
12576
12688
|
import { tmpdir as tmpdir3 } from "os";
|
|
12577
12689
|
import path27 from "path";
|
|
12578
|
-
import
|
|
12690
|
+
import chalk134 from "chalk";
|
|
12579
12691
|
function assertJbInstalled() {
|
|
12580
12692
|
try {
|
|
12581
12693
|
execSync31("jb inspectcode --version", { stdio: "pipe" });
|
|
12582
12694
|
} catch {
|
|
12583
|
-
console.error(
|
|
12695
|
+
console.error(chalk134.red("jb is not installed. Install with:"));
|
|
12584
12696
|
console.error(
|
|
12585
|
-
|
|
12697
|
+
chalk134.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
12586
12698
|
);
|
|
12587
12699
|
process.exit(1);
|
|
12588
12700
|
}
|
|
@@ -12600,11 +12712,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
12600
12712
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
12601
12713
|
process.stderr.write(error.stderr);
|
|
12602
12714
|
}
|
|
12603
|
-
console.error(
|
|
12715
|
+
console.error(chalk134.red("jb inspectcode failed"));
|
|
12604
12716
|
process.exit(1);
|
|
12605
12717
|
}
|
|
12606
12718
|
if (!existsSync36(reportPath)) {
|
|
12607
|
-
console.error(
|
|
12719
|
+
console.error(chalk134.red("Report file not generated"));
|
|
12608
12720
|
process.exit(1);
|
|
12609
12721
|
}
|
|
12610
12722
|
const xml = readFileSync31(reportPath, "utf8");
|
|
@@ -12614,7 +12726,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
12614
12726
|
|
|
12615
12727
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
12616
12728
|
import { execSync as execSync32 } from "child_process";
|
|
12617
|
-
import
|
|
12729
|
+
import chalk135 from "chalk";
|
|
12618
12730
|
function resolveMsbuildPath() {
|
|
12619
12731
|
const { run: run4 } = loadConfig();
|
|
12620
12732
|
const configs = resolveRunConfigs(run4, getConfigDir());
|
|
@@ -12626,9 +12738,9 @@ function assertMsbuildInstalled() {
|
|
|
12626
12738
|
try {
|
|
12627
12739
|
execSync32(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
12628
12740
|
} catch {
|
|
12629
|
-
console.error(
|
|
12741
|
+
console.error(chalk135.red(`msbuild not found at: ${msbuild}`));
|
|
12630
12742
|
console.error(
|
|
12631
|
-
|
|
12743
|
+
chalk135.yellow(
|
|
12632
12744
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
12633
12745
|
)
|
|
12634
12746
|
);
|
|
@@ -12675,17 +12787,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
12675
12787
|
// src/commands/dotnet/inspect.ts
|
|
12676
12788
|
function logScope(changedFiles) {
|
|
12677
12789
|
if (changedFiles === null) {
|
|
12678
|
-
console.log(
|
|
12790
|
+
console.log(chalk136.dim("Inspecting full solution..."));
|
|
12679
12791
|
} else {
|
|
12680
12792
|
console.log(
|
|
12681
|
-
|
|
12793
|
+
chalk136.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
12682
12794
|
);
|
|
12683
12795
|
}
|
|
12684
12796
|
}
|
|
12685
12797
|
function reportResults(issues, elapsed) {
|
|
12686
12798
|
if (issues.length > 0) displayIssues(issues);
|
|
12687
|
-
else console.log(
|
|
12688
|
-
console.log(
|
|
12799
|
+
else console.log(chalk136.green("No issues found"));
|
|
12800
|
+
console.log(chalk136.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
12689
12801
|
if (issues.length > 0) process.exit(1);
|
|
12690
12802
|
}
|
|
12691
12803
|
async function inspect(sln, options2) {
|
|
@@ -12696,7 +12808,7 @@ async function inspect(sln, options2) {
|
|
|
12696
12808
|
const scope = parseScope(options2.scope);
|
|
12697
12809
|
const changedFiles = getChangedCsFiles(scope);
|
|
12698
12810
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
12699
|
-
console.log(
|
|
12811
|
+
console.log(chalk136.green("No changed .cs files found"));
|
|
12700
12812
|
return;
|
|
12701
12813
|
}
|
|
12702
12814
|
logScope(changedFiles);
|
|
@@ -13021,25 +13133,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
13021
13133
|
}
|
|
13022
13134
|
|
|
13023
13135
|
// src/commands/github/printCountTable.ts
|
|
13024
|
-
import
|
|
13136
|
+
import chalk137 from "chalk";
|
|
13025
13137
|
function printCountTable(labelHeader, rows) {
|
|
13026
13138
|
const labelWidth = Math.max(
|
|
13027
13139
|
labelHeader.length,
|
|
13028
13140
|
...rows.map((row) => row.label.length)
|
|
13029
13141
|
);
|
|
13030
13142
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
13031
|
-
console.log(
|
|
13032
|
-
console.log(
|
|
13143
|
+
console.log(chalk137.dim(header));
|
|
13144
|
+
console.log(chalk137.dim("-".repeat(header.length)));
|
|
13033
13145
|
for (const row of rows) {
|
|
13034
13146
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
13035
13147
|
}
|
|
13036
13148
|
}
|
|
13037
13149
|
|
|
13038
13150
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
13039
|
-
import
|
|
13151
|
+
import chalk138 from "chalk";
|
|
13040
13152
|
function printRepoAuthorBreakdown(repos2) {
|
|
13041
13153
|
for (const repo of repos2) {
|
|
13042
|
-
console.log(
|
|
13154
|
+
console.log(chalk138.bold(repo.name));
|
|
13043
13155
|
const authorWidth = Math.max(
|
|
13044
13156
|
0,
|
|
13045
13157
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -13136,9 +13248,9 @@ function registerGithub(program2) {
|
|
|
13136
13248
|
}
|
|
13137
13249
|
|
|
13138
13250
|
// src/commands/handover/countPendingHandovers.ts
|
|
13139
|
-
import { and as
|
|
13251
|
+
import { and as and16, eq as eq35, isNull, sql as sql5 } from "drizzle-orm";
|
|
13140
13252
|
async function countPendingHandovers(orm, origin) {
|
|
13141
|
-
const [row] = await orm.select({ count: sql5`count(*)::int` }).from(handovers).where(
|
|
13253
|
+
const [row] = await orm.select({ count: sql5`count(*)::int` }).from(handovers).where(and16(eq35(handovers.origin, origin), isNull(handovers.recalledAt)));
|
|
13142
13254
|
return row?.count ?? 0;
|
|
13143
13255
|
}
|
|
13144
13256
|
|
|
@@ -13278,13 +13390,13 @@ async function load2(options2 = {}) {
|
|
|
13278
13390
|
}
|
|
13279
13391
|
|
|
13280
13392
|
// src/commands/handover/listPendingHandovers.ts
|
|
13281
|
-
import { and as
|
|
13393
|
+
import { and as and17, desc as desc4, eq as eq36, isNull as isNull2 } from "drizzle-orm";
|
|
13282
13394
|
async function listPendingHandovers(orm, origin) {
|
|
13283
13395
|
return orm.select({
|
|
13284
13396
|
id: handovers.id,
|
|
13285
13397
|
summary: handovers.summary,
|
|
13286
13398
|
createdAt: handovers.createdAt
|
|
13287
|
-
}).from(handovers).where(
|
|
13399
|
+
}).from(handovers).where(and17(eq36(handovers.origin, origin), isNull2(handovers.recalledAt))).orderBy(desc4(handovers.createdAt), desc4(handovers.id));
|
|
13288
13400
|
}
|
|
13289
13401
|
|
|
13290
13402
|
// src/commands/handover/printPendingHandovers.ts
|
|
@@ -13297,17 +13409,17 @@ async function printPendingHandovers() {
|
|
|
13297
13409
|
}
|
|
13298
13410
|
|
|
13299
13411
|
// src/commands/handover/recallHandover.ts
|
|
13300
|
-
import { and as
|
|
13412
|
+
import { and as and18, desc as desc5, eq as eq37, isNull as isNull3 } from "drizzle-orm";
|
|
13301
13413
|
async function recallHandover(orm, origin, id2) {
|
|
13302
13414
|
const [row] = await orm.select().from(handovers).where(
|
|
13303
|
-
|
|
13304
|
-
|
|
13415
|
+
and18(
|
|
13416
|
+
eq37(handovers.origin, origin),
|
|
13305
13417
|
isNull3(handovers.recalledAt),
|
|
13306
|
-
...id2 === void 0 ? [] : [
|
|
13418
|
+
...id2 === void 0 ? [] : [eq37(handovers.id, id2)]
|
|
13307
13419
|
)
|
|
13308
13420
|
).orderBy(desc5(handovers.createdAt), desc5(handovers.id)).limit(1);
|
|
13309
13421
|
if (!row) return void 0;
|
|
13310
|
-
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(
|
|
13422
|
+
await orm.update(handovers).set({ recalledAt: /* @__PURE__ */ new Date() }).where(eq37(handovers.id, row.id));
|
|
13311
13423
|
return row.content;
|
|
13312
13424
|
}
|
|
13313
13425
|
|
|
@@ -13357,7 +13469,7 @@ function registerHandover(program2) {
|
|
|
13357
13469
|
}
|
|
13358
13470
|
|
|
13359
13471
|
// src/commands/jira/acceptanceCriteria.ts
|
|
13360
|
-
import
|
|
13472
|
+
import chalk139 from "chalk";
|
|
13361
13473
|
|
|
13362
13474
|
// src/commands/jira/adfToText.ts
|
|
13363
13475
|
function renderInline(node) {
|
|
@@ -13424,7 +13536,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
13424
13536
|
const parsed = fetchIssue(issueKey, field);
|
|
13425
13537
|
const acValue = parsed?.fields?.[field];
|
|
13426
13538
|
if (!acValue) {
|
|
13427
|
-
console.log(
|
|
13539
|
+
console.log(chalk139.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
13428
13540
|
return;
|
|
13429
13541
|
}
|
|
13430
13542
|
if (typeof acValue === "string") {
|
|
@@ -13490,14 +13602,14 @@ async function jiraAuth() {
|
|
|
13490
13602
|
}
|
|
13491
13603
|
|
|
13492
13604
|
// src/commands/jira/viewIssue.ts
|
|
13493
|
-
import
|
|
13605
|
+
import chalk140 from "chalk";
|
|
13494
13606
|
function viewIssue(issueKey) {
|
|
13495
13607
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
13496
13608
|
const fields = parsed?.fields;
|
|
13497
13609
|
const summary = fields?.summary;
|
|
13498
13610
|
const description = fields?.description;
|
|
13499
13611
|
if (summary) {
|
|
13500
|
-
console.log(
|
|
13612
|
+
console.log(chalk140.bold(summary));
|
|
13501
13613
|
}
|
|
13502
13614
|
if (description) {
|
|
13503
13615
|
if (summary) console.log();
|
|
@@ -13511,7 +13623,7 @@ function viewIssue(issueKey) {
|
|
|
13511
13623
|
}
|
|
13512
13624
|
if (!summary && !description) {
|
|
13513
13625
|
console.log(
|
|
13514
|
-
|
|
13626
|
+
chalk140.yellow(`No summary or description found on ${issueKey}.`)
|
|
13515
13627
|
);
|
|
13516
13628
|
}
|
|
13517
13629
|
}
|
|
@@ -13527,13 +13639,13 @@ function registerJira(program2) {
|
|
|
13527
13639
|
// src/commands/reviewComments.ts
|
|
13528
13640
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
13529
13641
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
13530
|
-
import
|
|
13642
|
+
import chalk141 from "chalk";
|
|
13531
13643
|
async function reviewComments(number) {
|
|
13532
13644
|
if (number) {
|
|
13533
13645
|
try {
|
|
13534
13646
|
execFileSync5("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
13535
13647
|
} catch {
|
|
13536
|
-
console.error(
|
|
13648
|
+
console.error(chalk141.red(`gh pr checkout ${number} failed; aborting.`));
|
|
13537
13649
|
process.exit(1);
|
|
13538
13650
|
}
|
|
13539
13651
|
}
|
|
@@ -13607,15 +13719,15 @@ function registerList(program2) {
|
|
|
13607
13719
|
// src/commands/mermaid/index.ts
|
|
13608
13720
|
import { mkdirSync as mkdirSync14, readdirSync as readdirSync8 } from "fs";
|
|
13609
13721
|
import { resolve as resolve11 } from "path";
|
|
13610
|
-
import
|
|
13722
|
+
import chalk144 from "chalk";
|
|
13611
13723
|
|
|
13612
13724
|
// src/commands/mermaid/exportFile.ts
|
|
13613
13725
|
import { readFileSync as readFileSync33, writeFileSync as writeFileSync28 } from "fs";
|
|
13614
13726
|
import { basename as basename8, extname, resolve as resolve10 } from "path";
|
|
13615
|
-
import
|
|
13727
|
+
import chalk143 from "chalk";
|
|
13616
13728
|
|
|
13617
13729
|
// src/commands/mermaid/renderBlock.ts
|
|
13618
|
-
import
|
|
13730
|
+
import chalk142 from "chalk";
|
|
13619
13731
|
async function renderBlock(krokiUrl, source) {
|
|
13620
13732
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
13621
13733
|
method: "POST",
|
|
@@ -13624,7 +13736,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
13624
13736
|
});
|
|
13625
13737
|
if (!response.ok) {
|
|
13626
13738
|
console.error(
|
|
13627
|
-
|
|
13739
|
+
chalk142.red(
|
|
13628
13740
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
13629
13741
|
)
|
|
13630
13742
|
);
|
|
@@ -13642,19 +13754,19 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
13642
13754
|
if (onlyIndex !== void 0) {
|
|
13643
13755
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
13644
13756
|
console.error(
|
|
13645
|
-
|
|
13757
|
+
chalk143.red(
|
|
13646
13758
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
13647
13759
|
)
|
|
13648
13760
|
);
|
|
13649
13761
|
process.exit(1);
|
|
13650
13762
|
}
|
|
13651
13763
|
console.log(
|
|
13652
|
-
|
|
13764
|
+
chalk143.gray(
|
|
13653
13765
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
13654
13766
|
)
|
|
13655
13767
|
);
|
|
13656
13768
|
} else {
|
|
13657
|
-
console.log(
|
|
13769
|
+
console.log(chalk143.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
13658
13770
|
}
|
|
13659
13771
|
for (const [i, source] of blocks.entries()) {
|
|
13660
13772
|
const idx = i + 1;
|
|
@@ -13662,7 +13774,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
13662
13774
|
const outPath = resolve10(outDir, `${stem}-${idx}.svg`);
|
|
13663
13775
|
const svg = await renderBlock(krokiUrl, source);
|
|
13664
13776
|
writeFileSync28(outPath, svg, "utf8");
|
|
13665
|
-
console.log(
|
|
13777
|
+
console.log(chalk143.green(` \u2192 ${outPath}`));
|
|
13666
13778
|
}
|
|
13667
13779
|
}
|
|
13668
13780
|
function extractMermaidBlocks(markdown) {
|
|
@@ -13678,18 +13790,18 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
13678
13790
|
if (options2.index !== void 0) {
|
|
13679
13791
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
13680
13792
|
console.error(
|
|
13681
|
-
|
|
13793
|
+
chalk144.red(`--index must be a positive integer (got ${options2.index})`)
|
|
13682
13794
|
);
|
|
13683
13795
|
process.exit(1);
|
|
13684
13796
|
}
|
|
13685
13797
|
if (!file) {
|
|
13686
|
-
console.error(
|
|
13798
|
+
console.error(chalk144.red("--index requires a file argument"));
|
|
13687
13799
|
process.exit(1);
|
|
13688
13800
|
}
|
|
13689
13801
|
}
|
|
13690
13802
|
const files = file ? [file] : readdirSync8(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
13691
13803
|
if (files.length === 0) {
|
|
13692
|
-
console.log(
|
|
13804
|
+
console.log(chalk144.gray("No markdown files found in current directory."));
|
|
13693
13805
|
return;
|
|
13694
13806
|
}
|
|
13695
13807
|
for (const f of files) {
|
|
@@ -13715,7 +13827,7 @@ function registerMermaid(program2) {
|
|
|
13715
13827
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
13716
13828
|
import { createServer as createServer2 } from "http";
|
|
13717
13829
|
import { dirname as dirname22 } from "path";
|
|
13718
|
-
import
|
|
13830
|
+
import chalk146 from "chalk";
|
|
13719
13831
|
|
|
13720
13832
|
// src/commands/netcap/corsHeaders.ts
|
|
13721
13833
|
var corsHeaders = {
|
|
@@ -13794,7 +13906,7 @@ function createNetcapHandler(options2) {
|
|
|
13794
13906
|
import { cp, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
13795
13907
|
import { networkInterfaces } from "os";
|
|
13796
13908
|
import { join as join41 } from "path";
|
|
13797
|
-
import
|
|
13909
|
+
import chalk145 from "chalk";
|
|
13798
13910
|
|
|
13799
13911
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
13800
13912
|
import { dirname as dirname21, join as join40 } from "path";
|
|
@@ -13838,7 +13950,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
13838
13950
|
const host = lanIPv4();
|
|
13839
13951
|
if (!host) {
|
|
13840
13952
|
console.log(
|
|
13841
|
-
|
|
13953
|
+
chalk145.yellow("could not determine the WSL IP for the extension")
|
|
13842
13954
|
);
|
|
13843
13955
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
13844
13956
|
return source;
|
|
@@ -13849,7 +13961,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
13849
13961
|
return WSL_WINDOWS_PATH;
|
|
13850
13962
|
} catch {
|
|
13851
13963
|
console.log(
|
|
13852
|
-
|
|
13964
|
+
chalk145.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
13853
13965
|
);
|
|
13854
13966
|
return source;
|
|
13855
13967
|
}
|
|
@@ -13882,30 +13994,30 @@ async function netcap(options2) {
|
|
|
13882
13994
|
let count8 = 0;
|
|
13883
13995
|
const handler = createNetcapHandler({
|
|
13884
13996
|
outPath,
|
|
13885
|
-
onPing: () => console.log(
|
|
13997
|
+
onPing: () => console.log(chalk146.dim("ping from extension")),
|
|
13886
13998
|
onCapture: (entry) => {
|
|
13887
13999
|
count8 += 1;
|
|
13888
14000
|
console.log(
|
|
13889
|
-
|
|
13890
|
-
|
|
14001
|
+
chalk146.green(`captured #${count8}`),
|
|
14002
|
+
chalk146.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
13891
14003
|
);
|
|
13892
14004
|
}
|
|
13893
14005
|
});
|
|
13894
14006
|
const server = createServer2(handler);
|
|
13895
14007
|
server.listen(port, () => {
|
|
13896
14008
|
console.log(
|
|
13897
|
-
|
|
14009
|
+
chalk146.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
13898
14010
|
);
|
|
13899
|
-
console.log(
|
|
14011
|
+
console.log(chalk146.dim(`appending captures to ${outPath}`));
|
|
13900
14012
|
if (filter)
|
|
13901
|
-
console.log(
|
|
13902
|
-
console.log(
|
|
13903
|
-
console.log(
|
|
14013
|
+
console.log(chalk146.dim(`forwarding only URLs matching "${filter}"`));
|
|
14014
|
+
console.log(chalk146.dim(`load the unpacked extension from ${extensionPath}`));
|
|
14015
|
+
console.log(chalk146.dim("press Ctrl-C to stop"));
|
|
13904
14016
|
});
|
|
13905
14017
|
process.on("SIGINT", () => {
|
|
13906
14018
|
server.close();
|
|
13907
14019
|
console.log(
|
|
13908
|
-
|
|
14020
|
+
chalk146.bold(
|
|
13909
14021
|
`
|
|
13910
14022
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
13911
14023
|
)
|
|
@@ -13917,7 +14029,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
13917
14029
|
// src/commands/netcap/netcapExtract.ts
|
|
13918
14030
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
13919
14031
|
import { join as join44 } from "path";
|
|
13920
|
-
import
|
|
14032
|
+
import chalk147 from "chalk";
|
|
13921
14033
|
|
|
13922
14034
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
13923
14035
|
import { readFileSync as readFileSync34 } from "fs";
|
|
@@ -14365,8 +14477,8 @@ function netcapExtract(file) {
|
|
|
14365
14477
|
writeFileSync29(outFile, `${JSON.stringify(posts, null, 2)}
|
|
14366
14478
|
`);
|
|
14367
14479
|
console.log(
|
|
14368
|
-
|
|
14369
|
-
|
|
14480
|
+
chalk147.green(`extracted ${posts.length} posts`),
|
|
14481
|
+
chalk147.dim(`-> ${outFile}`)
|
|
14370
14482
|
);
|
|
14371
14483
|
}
|
|
14372
14484
|
|
|
@@ -14387,7 +14499,7 @@ function registerNetcap(program2) {
|
|
|
14387
14499
|
}
|
|
14388
14500
|
|
|
14389
14501
|
// src/commands/news/add/index.ts
|
|
14390
|
-
import
|
|
14502
|
+
import chalk148 from "chalk";
|
|
14391
14503
|
import enquirer8 from "enquirer";
|
|
14392
14504
|
async function add2(url) {
|
|
14393
14505
|
if (!url) {
|
|
@@ -14409,10 +14521,10 @@ async function add2(url) {
|
|
|
14409
14521
|
const { orm } = await getReady();
|
|
14410
14522
|
const added = await addFeed(orm, url);
|
|
14411
14523
|
if (!added) {
|
|
14412
|
-
console.log(
|
|
14524
|
+
console.log(chalk148.yellow("Feed already exists"));
|
|
14413
14525
|
return;
|
|
14414
14526
|
}
|
|
14415
|
-
console.log(
|
|
14527
|
+
console.log(chalk148.green(`Added feed: ${url}`));
|
|
14416
14528
|
}
|
|
14417
14529
|
|
|
14418
14530
|
// src/commands/registerNews.ts
|
|
@@ -14422,7 +14534,7 @@ function registerNews(program2) {
|
|
|
14422
14534
|
}
|
|
14423
14535
|
|
|
14424
14536
|
// src/commands/prompts/printPromptsTable.ts
|
|
14425
|
-
import
|
|
14537
|
+
import chalk149 from "chalk";
|
|
14426
14538
|
function truncate(str, max) {
|
|
14427
14539
|
if (str.length <= max) return str;
|
|
14428
14540
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -14440,14 +14552,14 @@ function printPromptsTable(rows) {
|
|
|
14440
14552
|
"Command".padEnd(commandWidth),
|
|
14441
14553
|
"Repos"
|
|
14442
14554
|
].join(" ");
|
|
14443
|
-
console.log(
|
|
14444
|
-
console.log(
|
|
14555
|
+
console.log(chalk149.dim(header));
|
|
14556
|
+
console.log(chalk149.dim("-".repeat(header.length)));
|
|
14445
14557
|
for (const row of rows) {
|
|
14446
14558
|
const count8 = String(row.count).padStart(countWidth);
|
|
14447
14559
|
const tool = row.tool.padEnd(toolWidth);
|
|
14448
14560
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
14449
14561
|
console.log(
|
|
14450
|
-
`${
|
|
14562
|
+
`${chalk149.yellow(count8)} ${tool} ${command} ${chalk149.dim(row.repos)}`
|
|
14451
14563
|
);
|
|
14452
14564
|
}
|
|
14453
14565
|
}
|
|
@@ -14996,20 +15108,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
14996
15108
|
}
|
|
14997
15109
|
|
|
14998
15110
|
// src/commands/prs/listComments/printComments.ts
|
|
14999
|
-
import
|
|
15111
|
+
import chalk150 from "chalk";
|
|
15000
15112
|
function formatForHuman(comment3) {
|
|
15001
15113
|
if (comment3.type === "review") {
|
|
15002
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
15114
|
+
const stateColor = comment3.state === "APPROVED" ? chalk150.green : comment3.state === "CHANGES_REQUESTED" ? chalk150.red : chalk150.yellow;
|
|
15003
15115
|
return [
|
|
15004
|
-
`${
|
|
15116
|
+
`${chalk150.cyan("Review")} by ${chalk150.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
15005
15117
|
comment3.body,
|
|
15006
15118
|
""
|
|
15007
15119
|
].join("\n");
|
|
15008
15120
|
}
|
|
15009
15121
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
15010
15122
|
return [
|
|
15011
|
-
`${
|
|
15012
|
-
|
|
15123
|
+
`${chalk150.cyan("Line comment")} by ${chalk150.bold(comment3.user)} on ${chalk150.dim(`${comment3.path}${location}`)}`,
|
|
15124
|
+
chalk150.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
15013
15125
|
comment3.body,
|
|
15014
15126
|
""
|
|
15015
15127
|
].join("\n");
|
|
@@ -15099,13 +15211,13 @@ import { execSync as execSync41 } from "child_process";
|
|
|
15099
15211
|
import enquirer9 from "enquirer";
|
|
15100
15212
|
|
|
15101
15213
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
15102
|
-
import
|
|
15214
|
+
import chalk151 from "chalk";
|
|
15103
15215
|
var STATUS_MAP = {
|
|
15104
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
15105
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
15216
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk151.magenta("merged"), date: pr.mergedAt } : null,
|
|
15217
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk151.red("closed"), date: pr.closedAt } : null
|
|
15106
15218
|
};
|
|
15107
15219
|
function defaultStatus(pr) {
|
|
15108
|
-
return { label:
|
|
15220
|
+
return { label: chalk151.green("opened"), date: pr.createdAt };
|
|
15109
15221
|
}
|
|
15110
15222
|
function getStatus2(pr) {
|
|
15111
15223
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -15114,11 +15226,11 @@ function formatDate(dateStr) {
|
|
|
15114
15226
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
15115
15227
|
}
|
|
15116
15228
|
function formatPrHeader(pr, status2) {
|
|
15117
|
-
return `${
|
|
15229
|
+
return `${chalk151.cyan(`#${pr.number}`)} ${pr.title} ${chalk151.dim(`(${pr.author.login},`)} ${status2.label} ${chalk151.dim(`${formatDate(status2.date)})`)}`;
|
|
15118
15230
|
}
|
|
15119
15231
|
function logPrDetails(pr) {
|
|
15120
15232
|
console.log(
|
|
15121
|
-
|
|
15233
|
+
chalk151.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
15122
15234
|
);
|
|
15123
15235
|
console.log();
|
|
15124
15236
|
}
|
|
@@ -15457,10 +15569,10 @@ function registerPrs(program2) {
|
|
|
15457
15569
|
}
|
|
15458
15570
|
|
|
15459
15571
|
// src/commands/ravendb/ravendbAuth.ts
|
|
15460
|
-
import
|
|
15572
|
+
import chalk157 from "chalk";
|
|
15461
15573
|
|
|
15462
15574
|
// src/shared/createConnectionAuth.ts
|
|
15463
|
-
import
|
|
15575
|
+
import chalk152 from "chalk";
|
|
15464
15576
|
function listConnections(connections, format) {
|
|
15465
15577
|
if (connections.length === 0) {
|
|
15466
15578
|
console.log("No connections configured.");
|
|
@@ -15473,7 +15585,7 @@ function listConnections(connections, format) {
|
|
|
15473
15585
|
function removeConnection(connections, name, save) {
|
|
15474
15586
|
const filtered = connections.filter((c) => c.name !== name);
|
|
15475
15587
|
if (filtered.length === connections.length) {
|
|
15476
|
-
console.error(
|
|
15588
|
+
console.error(chalk152.red(`Connection "${name}" not found.`));
|
|
15477
15589
|
process.exit(1);
|
|
15478
15590
|
}
|
|
15479
15591
|
save(filtered);
|
|
@@ -15519,15 +15631,15 @@ function saveConnections(connections) {
|
|
|
15519
15631
|
}
|
|
15520
15632
|
|
|
15521
15633
|
// src/commands/ravendb/promptConnection.ts
|
|
15522
|
-
import
|
|
15634
|
+
import chalk155 from "chalk";
|
|
15523
15635
|
|
|
15524
15636
|
// src/commands/ravendb/selectOpSecret.ts
|
|
15525
|
-
import
|
|
15637
|
+
import chalk154 from "chalk";
|
|
15526
15638
|
import Enquirer2 from "enquirer";
|
|
15527
15639
|
|
|
15528
15640
|
// src/commands/ravendb/searchItems.ts
|
|
15529
15641
|
import { execSync as execSync45 } from "child_process";
|
|
15530
|
-
import
|
|
15642
|
+
import chalk153 from "chalk";
|
|
15531
15643
|
function opExec(args) {
|
|
15532
15644
|
return execSync45(`op ${args}`, {
|
|
15533
15645
|
encoding: "utf8",
|
|
@@ -15540,7 +15652,7 @@ function searchItems(search2) {
|
|
|
15540
15652
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
15541
15653
|
} catch {
|
|
15542
15654
|
console.error(
|
|
15543
|
-
|
|
15655
|
+
chalk153.red(
|
|
15544
15656
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
15545
15657
|
)
|
|
15546
15658
|
);
|
|
@@ -15554,7 +15666,7 @@ function getItemFields(itemId) {
|
|
|
15554
15666
|
const item = JSON.parse(opExec(`item get "${itemId}" --format=json`));
|
|
15555
15667
|
return item.fields.filter((f) => f.reference && f.label);
|
|
15556
15668
|
} catch {
|
|
15557
|
-
console.error(
|
|
15669
|
+
console.error(chalk153.red("Failed to get item details from 1Password."));
|
|
15558
15670
|
process.exit(1);
|
|
15559
15671
|
}
|
|
15560
15672
|
}
|
|
@@ -15573,7 +15685,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15573
15685
|
}).run();
|
|
15574
15686
|
const items2 = searchItems(search2);
|
|
15575
15687
|
if (items2.length === 0) {
|
|
15576
|
-
console.error(
|
|
15688
|
+
console.error(chalk154.red(`No items found matching "${search2}".`));
|
|
15577
15689
|
process.exit(1);
|
|
15578
15690
|
}
|
|
15579
15691
|
const itemId = await selectOne(
|
|
@@ -15582,7 +15694,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15582
15694
|
);
|
|
15583
15695
|
const fields = getItemFields(itemId);
|
|
15584
15696
|
if (fields.length === 0) {
|
|
15585
|
-
console.error(
|
|
15697
|
+
console.error(chalk154.red("No fields with references found on this item."));
|
|
15586
15698
|
process.exit(1);
|
|
15587
15699
|
}
|
|
15588
15700
|
const ref = await selectOne(
|
|
@@ -15596,7 +15708,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
15596
15708
|
async function promptConnection(existingNames) {
|
|
15597
15709
|
const name = await promptInput("name", "Connection name:");
|
|
15598
15710
|
if (existingNames.includes(name)) {
|
|
15599
|
-
console.error(
|
|
15711
|
+
console.error(chalk155.red(`Connection "${name}" already exists.`));
|
|
15600
15712
|
process.exit(1);
|
|
15601
15713
|
}
|
|
15602
15714
|
const url = await promptInput(
|
|
@@ -15605,22 +15717,22 @@ async function promptConnection(existingNames) {
|
|
|
15605
15717
|
);
|
|
15606
15718
|
const database = await promptInput("database", "Database name:");
|
|
15607
15719
|
if (!name || !url || !database) {
|
|
15608
|
-
console.error(
|
|
15720
|
+
console.error(chalk155.red("All fields are required."));
|
|
15609
15721
|
process.exit(1);
|
|
15610
15722
|
}
|
|
15611
15723
|
const apiKeyRef = await selectOpSecret();
|
|
15612
|
-
console.log(
|
|
15724
|
+
console.log(chalk155.dim(`Using: ${apiKeyRef}`));
|
|
15613
15725
|
return { name, url, database, apiKeyRef };
|
|
15614
15726
|
}
|
|
15615
15727
|
|
|
15616
15728
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
15617
|
-
import
|
|
15729
|
+
import chalk156 from "chalk";
|
|
15618
15730
|
function ravendbSetConnection(name) {
|
|
15619
15731
|
const raw = loadGlobalConfigRaw();
|
|
15620
15732
|
const ravendb = raw.ravendb ?? {};
|
|
15621
15733
|
const connections = ravendb.connections ?? [];
|
|
15622
15734
|
if (!connections.some((c) => c.name === name)) {
|
|
15623
|
-
console.error(
|
|
15735
|
+
console.error(chalk156.red(`Connection "${name}" not found.`));
|
|
15624
15736
|
console.error(
|
|
15625
15737
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
15626
15738
|
);
|
|
@@ -15636,16 +15748,16 @@ function ravendbSetConnection(name) {
|
|
|
15636
15748
|
var ravendbAuth = createConnectionAuth({
|
|
15637
15749
|
load: loadConnections,
|
|
15638
15750
|
save: saveConnections,
|
|
15639
|
-
format: (c) => `${
|
|
15751
|
+
format: (c) => `${chalk157.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
15640
15752
|
promptNew: promptConnection,
|
|
15641
15753
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
15642
15754
|
});
|
|
15643
15755
|
|
|
15644
15756
|
// src/commands/ravendb/ravendbCollections.ts
|
|
15645
|
-
import
|
|
15757
|
+
import chalk161 from "chalk";
|
|
15646
15758
|
|
|
15647
15759
|
// src/commands/ravendb/ravenFetch.ts
|
|
15648
|
-
import
|
|
15760
|
+
import chalk159 from "chalk";
|
|
15649
15761
|
|
|
15650
15762
|
// src/commands/ravendb/getAccessToken.ts
|
|
15651
15763
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -15682,10 +15794,10 @@ ${errorText}`
|
|
|
15682
15794
|
|
|
15683
15795
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
15684
15796
|
import { execSync as execSync46 } from "child_process";
|
|
15685
|
-
import
|
|
15797
|
+
import chalk158 from "chalk";
|
|
15686
15798
|
function resolveOpSecret(reference) {
|
|
15687
15799
|
if (!reference.startsWith("op://")) {
|
|
15688
|
-
console.error(
|
|
15800
|
+
console.error(chalk158.red(`Invalid secret reference: must start with op://`));
|
|
15689
15801
|
process.exit(1);
|
|
15690
15802
|
}
|
|
15691
15803
|
try {
|
|
@@ -15695,7 +15807,7 @@ function resolveOpSecret(reference) {
|
|
|
15695
15807
|
}).trim();
|
|
15696
15808
|
} catch {
|
|
15697
15809
|
console.error(
|
|
15698
|
-
|
|
15810
|
+
chalk158.red(
|
|
15699
15811
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
15700
15812
|
)
|
|
15701
15813
|
);
|
|
@@ -15722,7 +15834,7 @@ async function ravenFetch(connection, path57) {
|
|
|
15722
15834
|
if (!response.ok) {
|
|
15723
15835
|
const body = await response.text();
|
|
15724
15836
|
console.error(
|
|
15725
|
-
|
|
15837
|
+
chalk159.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
15726
15838
|
);
|
|
15727
15839
|
console.error(body.substring(0, 500));
|
|
15728
15840
|
process.exit(1);
|
|
@@ -15731,7 +15843,7 @@ async function ravenFetch(connection, path57) {
|
|
|
15731
15843
|
}
|
|
15732
15844
|
|
|
15733
15845
|
// src/commands/ravendb/resolveConnection.ts
|
|
15734
|
-
import
|
|
15846
|
+
import chalk160 from "chalk";
|
|
15735
15847
|
function loadRavendb() {
|
|
15736
15848
|
const raw = loadGlobalConfigRaw();
|
|
15737
15849
|
const ravendb = raw.ravendb;
|
|
@@ -15745,7 +15857,7 @@ function resolveConnection(name) {
|
|
|
15745
15857
|
const connectionName = name ?? defaultConnection;
|
|
15746
15858
|
if (!connectionName) {
|
|
15747
15859
|
console.error(
|
|
15748
|
-
|
|
15860
|
+
chalk160.red(
|
|
15749
15861
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
15750
15862
|
)
|
|
15751
15863
|
);
|
|
@@ -15753,7 +15865,7 @@ function resolveConnection(name) {
|
|
|
15753
15865
|
}
|
|
15754
15866
|
const connection = connections.find((c) => c.name === connectionName);
|
|
15755
15867
|
if (!connection) {
|
|
15756
|
-
console.error(
|
|
15868
|
+
console.error(chalk160.red(`Connection "${connectionName}" not found.`));
|
|
15757
15869
|
console.error(
|
|
15758
15870
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
15759
15871
|
);
|
|
@@ -15784,15 +15896,15 @@ async function ravendbCollections(connectionName) {
|
|
|
15784
15896
|
return;
|
|
15785
15897
|
}
|
|
15786
15898
|
for (const c of collections) {
|
|
15787
|
-
console.log(`${
|
|
15899
|
+
console.log(`${chalk161.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
15788
15900
|
}
|
|
15789
15901
|
}
|
|
15790
15902
|
|
|
15791
15903
|
// src/commands/ravendb/ravendbQuery.ts
|
|
15792
|
-
import
|
|
15904
|
+
import chalk163 from "chalk";
|
|
15793
15905
|
|
|
15794
15906
|
// src/commands/ravendb/fetchAllPages.ts
|
|
15795
|
-
import
|
|
15907
|
+
import chalk162 from "chalk";
|
|
15796
15908
|
|
|
15797
15909
|
// src/commands/ravendb/buildQueryPath.ts
|
|
15798
15910
|
function buildQueryPath(opts) {
|
|
@@ -15830,7 +15942,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15830
15942
|
allResults.push(...results);
|
|
15831
15943
|
start3 += results.length;
|
|
15832
15944
|
process.stderr.write(
|
|
15833
|
-
`\r${
|
|
15945
|
+
`\r${chalk162.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
15834
15946
|
);
|
|
15835
15947
|
if (start3 >= totalResults) break;
|
|
15836
15948
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -15845,7 +15957,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15845
15957
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
15846
15958
|
const resolved = resolveArgs(connectionName, collection);
|
|
15847
15959
|
if (!resolved.collection && !options2.query) {
|
|
15848
|
-
console.error(
|
|
15960
|
+
console.error(chalk163.red("Provide a collection name or --query filter."));
|
|
15849
15961
|
process.exit(1);
|
|
15850
15962
|
}
|
|
15851
15963
|
const { collection: col } = resolved;
|
|
@@ -15883,7 +15995,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
15883
15995
|
import * as path28 from "path";
|
|
15884
15996
|
|
|
15885
15997
|
// src/commands/refactor/logViolations.ts
|
|
15886
|
-
import
|
|
15998
|
+
import chalk164 from "chalk";
|
|
15887
15999
|
var DEFAULT_MAX_LINES = 100;
|
|
15888
16000
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
15889
16001
|
if (violations.length === 0) {
|
|
@@ -15892,43 +16004,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
15892
16004
|
}
|
|
15893
16005
|
return;
|
|
15894
16006
|
}
|
|
15895
|
-
console.error(
|
|
16007
|
+
console.error(chalk164.red(`
|
|
15896
16008
|
Refactor check failed:
|
|
15897
16009
|
`));
|
|
15898
|
-
console.error(
|
|
16010
|
+
console.error(chalk164.red(` The following files exceed ${maxLines} lines:
|
|
15899
16011
|
`));
|
|
15900
16012
|
for (const violation of violations) {
|
|
15901
|
-
console.error(
|
|
16013
|
+
console.error(chalk164.red(` ${violation.file} (${violation.lines} lines)`));
|
|
15902
16014
|
}
|
|
15903
16015
|
console.error(
|
|
15904
|
-
|
|
16016
|
+
chalk164.yellow(
|
|
15905
16017
|
`
|
|
15906
16018
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
15907
16019
|
way to refactor it, ignore it with:
|
|
15908
16020
|
`
|
|
15909
16021
|
)
|
|
15910
16022
|
);
|
|
15911
|
-
console.error(
|
|
16023
|
+
console.error(chalk164.gray(` assist refactor ignore <file>
|
|
15912
16024
|
`));
|
|
15913
16025
|
if (process.env.CLAUDECODE) {
|
|
15914
|
-
console.error(
|
|
16026
|
+
console.error(chalk164.cyan(`
|
|
15915
16027
|
## Extracting Code to New Files
|
|
15916
16028
|
`));
|
|
15917
16029
|
console.error(
|
|
15918
|
-
|
|
16030
|
+
chalk164.cyan(
|
|
15919
16031
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
15920
16032
|
`
|
|
15921
16033
|
)
|
|
15922
16034
|
);
|
|
15923
16035
|
console.error(
|
|
15924
|
-
|
|
16036
|
+
chalk164.cyan(
|
|
15925
16037
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
15926
16038
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
15927
16039
|
`
|
|
15928
16040
|
)
|
|
15929
16041
|
);
|
|
15930
16042
|
console.error(
|
|
15931
|
-
|
|
16043
|
+
chalk164.cyan(
|
|
15932
16044
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
15933
16045
|
domains, move it to a common/shared folder.
|
|
15934
16046
|
`
|
|
@@ -16084,7 +16196,7 @@ async function check(pattern2, options2) {
|
|
|
16084
16196
|
|
|
16085
16197
|
// src/commands/refactor/extract/index.ts
|
|
16086
16198
|
import path35 from "path";
|
|
16087
|
-
import
|
|
16199
|
+
import chalk167 from "chalk";
|
|
16088
16200
|
|
|
16089
16201
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
16090
16202
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -16659,23 +16771,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
16659
16771
|
|
|
16660
16772
|
// src/commands/refactor/extract/displayPlan.ts
|
|
16661
16773
|
import path32 from "path";
|
|
16662
|
-
import
|
|
16774
|
+
import chalk165 from "chalk";
|
|
16663
16775
|
function section(title) {
|
|
16664
16776
|
return `
|
|
16665
|
-
${
|
|
16777
|
+
${chalk165.cyan(title)}`;
|
|
16666
16778
|
}
|
|
16667
16779
|
function displayImporters(plan2, cwd) {
|
|
16668
16780
|
if (plan2.importersToUpdate.length === 0) return;
|
|
16669
16781
|
console.log(section("Update importers:"));
|
|
16670
16782
|
for (const imp of plan2.importersToUpdate) {
|
|
16671
16783
|
const rel = path32.relative(cwd, imp.file.getFilePath());
|
|
16672
|
-
console.log(` ${
|
|
16784
|
+
console.log(` ${chalk165.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
16673
16785
|
}
|
|
16674
16786
|
}
|
|
16675
16787
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
16676
|
-
console.log(
|
|
16788
|
+
console.log(chalk165.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
16677
16789
|
`));
|
|
16678
|
-
console.log(` ${
|
|
16790
|
+
console.log(` ${chalk165.cyan("Functions to move:")}`);
|
|
16679
16791
|
for (const name of plan2.extractedNames) {
|
|
16680
16792
|
console.log(` ${name}`);
|
|
16681
16793
|
}
|
|
@@ -16709,7 +16821,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
16709
16821
|
|
|
16710
16822
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
16711
16823
|
import path34 from "path";
|
|
16712
|
-
import
|
|
16824
|
+
import chalk166 from "chalk";
|
|
16713
16825
|
import { Project as Project4 } from "ts-morph";
|
|
16714
16826
|
|
|
16715
16827
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -16769,7 +16881,7 @@ function loadProjectFile(file) {
|
|
|
16769
16881
|
});
|
|
16770
16882
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
16771
16883
|
if (!sourceFile) {
|
|
16772
|
-
console.log(
|
|
16884
|
+
console.log(chalk166.red(`File not found in project: ${file}`));
|
|
16773
16885
|
process.exit(1);
|
|
16774
16886
|
}
|
|
16775
16887
|
return { project, sourceFile };
|
|
@@ -16792,19 +16904,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
16792
16904
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
16793
16905
|
if (options2.apply) {
|
|
16794
16906
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
16795
|
-
console.log(
|
|
16907
|
+
console.log(chalk167.green("\nExtraction complete"));
|
|
16796
16908
|
} else {
|
|
16797
|
-
console.log(
|
|
16909
|
+
console.log(chalk167.dim("\nDry run. Use --apply to execute."));
|
|
16798
16910
|
}
|
|
16799
16911
|
}
|
|
16800
16912
|
|
|
16801
16913
|
// src/commands/refactor/ignore.ts
|
|
16802
16914
|
import fs24 from "fs";
|
|
16803
|
-
import
|
|
16915
|
+
import chalk168 from "chalk";
|
|
16804
16916
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
16805
16917
|
function ignore2(file) {
|
|
16806
16918
|
if (!fs24.existsSync(file)) {
|
|
16807
|
-
console.error(
|
|
16919
|
+
console.error(chalk168.red(`Error: File does not exist: ${file}`));
|
|
16808
16920
|
process.exit(1);
|
|
16809
16921
|
}
|
|
16810
16922
|
const content = fs24.readFileSync(file, "utf8");
|
|
@@ -16820,7 +16932,7 @@ function ignore2(file) {
|
|
|
16820
16932
|
fs24.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
16821
16933
|
}
|
|
16822
16934
|
console.log(
|
|
16823
|
-
|
|
16935
|
+
chalk168.green(
|
|
16824
16936
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
16825
16937
|
)
|
|
16826
16938
|
);
|
|
@@ -16829,12 +16941,12 @@ function ignore2(file) {
|
|
|
16829
16941
|
// src/commands/refactor/rename/index.ts
|
|
16830
16942
|
import fs27 from "fs";
|
|
16831
16943
|
import path40 from "path";
|
|
16832
|
-
import
|
|
16944
|
+
import chalk171 from "chalk";
|
|
16833
16945
|
|
|
16834
16946
|
// src/commands/refactor/rename/applyRename.ts
|
|
16835
16947
|
import fs26 from "fs";
|
|
16836
16948
|
import path37 from "path";
|
|
16837
|
-
import
|
|
16949
|
+
import chalk169 from "chalk";
|
|
16838
16950
|
|
|
16839
16951
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
16840
16952
|
import path36 from "path";
|
|
@@ -16939,13 +17051,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
16939
17051
|
const updatedContents = applyRewrites(rewrites);
|
|
16940
17052
|
for (const [file, content] of updatedContents) {
|
|
16941
17053
|
fs26.writeFileSync(file, content, "utf8");
|
|
16942
|
-
console.log(
|
|
17054
|
+
console.log(chalk169.cyan(` Updated imports in ${path37.relative(cwd, file)}`));
|
|
16943
17055
|
}
|
|
16944
17056
|
const destDir = path37.dirname(destPath);
|
|
16945
17057
|
if (!fs26.existsSync(destDir)) fs26.mkdirSync(destDir, { recursive: true });
|
|
16946
17058
|
fs26.renameSync(sourcePath, destPath);
|
|
16947
17059
|
console.log(
|
|
16948
|
-
|
|
17060
|
+
chalk169.white(
|
|
16949
17061
|
` Moved ${path37.relative(cwd, sourcePath)} \u2192 ${path37.relative(cwd, destPath)}`
|
|
16950
17062
|
)
|
|
16951
17063
|
);
|
|
@@ -17032,16 +17144,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
17032
17144
|
|
|
17033
17145
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
17034
17146
|
import path39 from "path";
|
|
17035
|
-
import
|
|
17147
|
+
import chalk170 from "chalk";
|
|
17036
17148
|
function printRenamePreview(rewrites, cwd) {
|
|
17037
17149
|
for (const rewrite of rewrites) {
|
|
17038
17150
|
console.log(
|
|
17039
|
-
|
|
17151
|
+
chalk170.dim(
|
|
17040
17152
|
` ${path39.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
17041
17153
|
)
|
|
17042
17154
|
);
|
|
17043
17155
|
}
|
|
17044
|
-
console.log(
|
|
17156
|
+
console.log(chalk170.dim("Dry run. Use --apply to execute."));
|
|
17045
17157
|
}
|
|
17046
17158
|
|
|
17047
17159
|
// src/commands/refactor/rename/index.ts
|
|
@@ -17052,20 +17164,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
17052
17164
|
const relSource = path40.relative(cwd, sourcePath);
|
|
17053
17165
|
const relDest = path40.relative(cwd, destPath);
|
|
17054
17166
|
if (!fs27.existsSync(sourcePath)) {
|
|
17055
|
-
console.log(
|
|
17167
|
+
console.log(chalk171.red(`File not found: ${source}`));
|
|
17056
17168
|
process.exit(1);
|
|
17057
17169
|
}
|
|
17058
17170
|
if (destPath !== sourcePath && fs27.existsSync(destPath)) {
|
|
17059
|
-
console.log(
|
|
17171
|
+
console.log(chalk171.red(`Destination already exists: ${destination}`));
|
|
17060
17172
|
process.exit(1);
|
|
17061
17173
|
}
|
|
17062
|
-
console.log(
|
|
17063
|
-
console.log(
|
|
17064
|
-
console.log(
|
|
17174
|
+
console.log(chalk171.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
17175
|
+
console.log(chalk171.dim("Loading project..."));
|
|
17176
|
+
console.log(chalk171.dim("Scanning imports across the project..."));
|
|
17065
17177
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
17066
17178
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
17067
17179
|
console.log(
|
|
17068
|
-
|
|
17180
|
+
chalk171.dim(
|
|
17069
17181
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
17070
17182
|
)
|
|
17071
17183
|
);
|
|
@@ -17074,11 +17186,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
17074
17186
|
return;
|
|
17075
17187
|
}
|
|
17076
17188
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
17077
|
-
console.log(
|
|
17189
|
+
console.log(chalk171.green("Done"));
|
|
17078
17190
|
}
|
|
17079
17191
|
|
|
17080
17192
|
// src/commands/refactor/renameSymbol/index.ts
|
|
17081
|
-
import
|
|
17193
|
+
import chalk172 from "chalk";
|
|
17082
17194
|
|
|
17083
17195
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
17084
17196
|
import { SyntaxKind as SyntaxKind14 } from "ts-morph";
|
|
@@ -17124,33 +17236,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
17124
17236
|
const { project, sourceFile } = loadProjectFile(file);
|
|
17125
17237
|
const symbol = findSymbol(sourceFile, oldName);
|
|
17126
17238
|
if (!symbol) {
|
|
17127
|
-
console.log(
|
|
17239
|
+
console.log(chalk172.red(`Symbol "${oldName}" not found in ${file}`));
|
|
17128
17240
|
process.exit(1);
|
|
17129
17241
|
}
|
|
17130
17242
|
const grouped = groupReferences(symbol, cwd);
|
|
17131
17243
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
17132
17244
|
console.log(
|
|
17133
|
-
|
|
17245
|
+
chalk172.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
17134
17246
|
`)
|
|
17135
17247
|
);
|
|
17136
17248
|
for (const [refFile, lines] of grouped) {
|
|
17137
17249
|
console.log(
|
|
17138
|
-
` ${
|
|
17250
|
+
` ${chalk172.dim(refFile)}: lines ${chalk172.cyan(lines.join(", "))}`
|
|
17139
17251
|
);
|
|
17140
17252
|
}
|
|
17141
17253
|
if (options2.apply) {
|
|
17142
17254
|
symbol.rename(newName);
|
|
17143
17255
|
await project.save();
|
|
17144
|
-
console.log(
|
|
17256
|
+
console.log(chalk172.green(`
|
|
17145
17257
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
17146
17258
|
} else {
|
|
17147
|
-
console.log(
|
|
17259
|
+
console.log(chalk172.dim("\nDry run. Use --apply to execute."));
|
|
17148
17260
|
}
|
|
17149
17261
|
}
|
|
17150
17262
|
|
|
17151
17263
|
// src/commands/refactor/restructure/index.ts
|
|
17152
17264
|
import path48 from "path";
|
|
17153
|
-
import
|
|
17265
|
+
import chalk175 from "chalk";
|
|
17154
17266
|
|
|
17155
17267
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
17156
17268
|
import path42 from "path";
|
|
@@ -17229,50 +17341,50 @@ function clusterFiles(graph) {
|
|
|
17229
17341
|
|
|
17230
17342
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
17231
17343
|
import path44 from "path";
|
|
17232
|
-
import
|
|
17344
|
+
import chalk173 from "chalk";
|
|
17233
17345
|
function relPath(filePath) {
|
|
17234
17346
|
return path44.relative(process.cwd(), filePath);
|
|
17235
17347
|
}
|
|
17236
17348
|
function displayMoves(plan2) {
|
|
17237
17349
|
if (plan2.moves.length === 0) return;
|
|
17238
|
-
console.log(
|
|
17350
|
+
console.log(chalk173.bold("\nFile moves:"));
|
|
17239
17351
|
for (const move2 of plan2.moves) {
|
|
17240
17352
|
console.log(
|
|
17241
|
-
` ${
|
|
17353
|
+
` ${chalk173.red(relPath(move2.from))} \u2192 ${chalk173.green(relPath(move2.to))}`
|
|
17242
17354
|
);
|
|
17243
|
-
console.log(
|
|
17355
|
+
console.log(chalk173.dim(` ${move2.reason}`));
|
|
17244
17356
|
}
|
|
17245
17357
|
}
|
|
17246
17358
|
function displayRewrites(rewrites) {
|
|
17247
17359
|
if (rewrites.length === 0) return;
|
|
17248
17360
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
17249
|
-
console.log(
|
|
17361
|
+
console.log(chalk173.bold(`
|
|
17250
17362
|
Import rewrites (${affectedFiles.size} files):`));
|
|
17251
17363
|
for (const file of affectedFiles) {
|
|
17252
|
-
console.log(` ${
|
|
17364
|
+
console.log(` ${chalk173.cyan(relPath(file))}:`);
|
|
17253
17365
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
17254
17366
|
(r) => r.file === file
|
|
17255
17367
|
)) {
|
|
17256
17368
|
console.log(
|
|
17257
|
-
` ${
|
|
17369
|
+
` ${chalk173.red(`"${oldSpecifier}"`)} \u2192 ${chalk173.green(`"${newSpecifier}"`)}`
|
|
17258
17370
|
);
|
|
17259
17371
|
}
|
|
17260
17372
|
}
|
|
17261
17373
|
}
|
|
17262
17374
|
function displayPlan2(plan2) {
|
|
17263
17375
|
if (plan2.warnings.length > 0) {
|
|
17264
|
-
console.log(
|
|
17265
|
-
for (const w of plan2.warnings) console.log(
|
|
17376
|
+
console.log(chalk173.yellow("\nWarnings:"));
|
|
17377
|
+
for (const w of plan2.warnings) console.log(chalk173.yellow(` ${w}`));
|
|
17266
17378
|
}
|
|
17267
17379
|
if (plan2.newDirectories.length > 0) {
|
|
17268
|
-
console.log(
|
|
17380
|
+
console.log(chalk173.bold("\nNew directories:"));
|
|
17269
17381
|
for (const dir of plan2.newDirectories)
|
|
17270
|
-
console.log(
|
|
17382
|
+
console.log(chalk173.green(` ${dir}/`));
|
|
17271
17383
|
}
|
|
17272
17384
|
displayMoves(plan2);
|
|
17273
17385
|
displayRewrites(plan2.rewrites);
|
|
17274
17386
|
console.log(
|
|
17275
|
-
|
|
17387
|
+
chalk173.dim(
|
|
17276
17388
|
`
|
|
17277
17389
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
17278
17390
|
)
|
|
@@ -17282,18 +17394,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
17282
17394
|
// src/commands/refactor/restructure/executePlan.ts
|
|
17283
17395
|
import fs28 from "fs";
|
|
17284
17396
|
import path45 from "path";
|
|
17285
|
-
import
|
|
17397
|
+
import chalk174 from "chalk";
|
|
17286
17398
|
function executePlan(plan2) {
|
|
17287
17399
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
17288
17400
|
for (const [file, content] of updatedContents) {
|
|
17289
17401
|
fs28.writeFileSync(file, content, "utf8");
|
|
17290
17402
|
console.log(
|
|
17291
|
-
|
|
17403
|
+
chalk174.cyan(` Rewrote imports in ${path45.relative(process.cwd(), file)}`)
|
|
17292
17404
|
);
|
|
17293
17405
|
}
|
|
17294
17406
|
for (const dir of plan2.newDirectories) {
|
|
17295
17407
|
fs28.mkdirSync(dir, { recursive: true });
|
|
17296
|
-
console.log(
|
|
17408
|
+
console.log(chalk174.green(` Created ${path45.relative(process.cwd(), dir)}/`));
|
|
17297
17409
|
}
|
|
17298
17410
|
for (const move2 of plan2.moves) {
|
|
17299
17411
|
const targetDir = path45.dirname(move2.to);
|
|
@@ -17302,7 +17414,7 @@ function executePlan(plan2) {
|
|
|
17302
17414
|
}
|
|
17303
17415
|
fs28.renameSync(move2.from, move2.to);
|
|
17304
17416
|
console.log(
|
|
17305
|
-
|
|
17417
|
+
chalk174.white(
|
|
17306
17418
|
` Moved ${path45.relative(process.cwd(), move2.from)} \u2192 ${path45.relative(process.cwd(), move2.to)}`
|
|
17307
17419
|
)
|
|
17308
17420
|
);
|
|
@@ -17317,7 +17429,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
17317
17429
|
if (entries.length === 0) {
|
|
17318
17430
|
fs28.rmdirSync(dir);
|
|
17319
17431
|
console.log(
|
|
17320
|
-
|
|
17432
|
+
chalk174.dim(
|
|
17321
17433
|
` Removed empty directory ${path45.relative(process.cwd(), dir)}`
|
|
17322
17434
|
)
|
|
17323
17435
|
);
|
|
@@ -17450,22 +17562,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
17450
17562
|
const targetPattern = pattern2 ?? "src";
|
|
17451
17563
|
const files = findSourceFiles2(targetPattern);
|
|
17452
17564
|
if (files.length === 0) {
|
|
17453
|
-
console.log(
|
|
17565
|
+
console.log(chalk175.yellow("No files found matching pattern"));
|
|
17454
17566
|
return;
|
|
17455
17567
|
}
|
|
17456
17568
|
const tsConfigPath = path48.resolve("tsconfig.json");
|
|
17457
17569
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
17458
17570
|
if (plan2.moves.length === 0) {
|
|
17459
|
-
console.log(
|
|
17571
|
+
console.log(chalk175.green("No restructuring needed"));
|
|
17460
17572
|
return;
|
|
17461
17573
|
}
|
|
17462
17574
|
displayPlan2(plan2);
|
|
17463
17575
|
if (options2.apply) {
|
|
17464
|
-
console.log(
|
|
17576
|
+
console.log(chalk175.bold("\nApplying changes..."));
|
|
17465
17577
|
executePlan(plan2);
|
|
17466
|
-
console.log(
|
|
17578
|
+
console.log(chalk175.green("\nRestructuring complete"));
|
|
17467
17579
|
} else {
|
|
17468
|
-
console.log(
|
|
17580
|
+
console.log(chalk175.dim("\nDry run. Use --apply to execute."));
|
|
17469
17581
|
}
|
|
17470
17582
|
}
|
|
17471
17583
|
|
|
@@ -18038,18 +18150,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
18038
18150
|
}
|
|
18039
18151
|
|
|
18040
18152
|
// src/commands/review/warnOutOfDiff.ts
|
|
18041
|
-
import
|
|
18153
|
+
import chalk176 from "chalk";
|
|
18042
18154
|
function warnOutOfDiff(outOfDiff) {
|
|
18043
18155
|
if (outOfDiff.length === 0) return;
|
|
18044
18156
|
console.warn(
|
|
18045
|
-
|
|
18157
|
+
chalk176.yellow(
|
|
18046
18158
|
`Skipped ${outOfDiff.length} finding(s) whose lines fall outside the PR diff (GitHub would silently drop these):`
|
|
18047
18159
|
)
|
|
18048
18160
|
);
|
|
18049
18161
|
for (const finding of outOfDiff) {
|
|
18050
18162
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
18051
18163
|
console.warn(
|
|
18052
|
-
` ${
|
|
18164
|
+
` ${chalk176.yellow("\xB7")} ${finding.title} ${chalk176.dim(
|
|
18053
18165
|
`(${finding.file}:${range})`
|
|
18054
18166
|
)}`
|
|
18055
18167
|
);
|
|
@@ -18068,18 +18180,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
18068
18180
|
}
|
|
18069
18181
|
|
|
18070
18182
|
// src/commands/review/warnUnlocated.ts
|
|
18071
|
-
import
|
|
18183
|
+
import chalk177 from "chalk";
|
|
18072
18184
|
function warnUnlocated(unlocated) {
|
|
18073
18185
|
if (unlocated.length === 0) return;
|
|
18074
18186
|
console.warn(
|
|
18075
|
-
|
|
18187
|
+
chalk177.yellow(
|
|
18076
18188
|
`Skipped ${unlocated.length} finding(s) without a parseable file:line:`
|
|
18077
18189
|
)
|
|
18078
18190
|
);
|
|
18079
18191
|
for (const finding of unlocated) {
|
|
18080
|
-
const where = finding.location ||
|
|
18192
|
+
const where = finding.location || chalk177.dim("missing");
|
|
18081
18193
|
console.warn(
|
|
18082
|
-
` ${
|
|
18194
|
+
` ${chalk177.yellow("\xB7")} ${finding.title} ${chalk177.dim(`(${where})`)}`
|
|
18083
18195
|
);
|
|
18084
18196
|
}
|
|
18085
18197
|
}
|
|
@@ -19251,7 +19363,7 @@ function registerReview(program2) {
|
|
|
19251
19363
|
}
|
|
19252
19364
|
|
|
19253
19365
|
// src/commands/seq/seqAuth.ts
|
|
19254
|
-
import
|
|
19366
|
+
import chalk179 from "chalk";
|
|
19255
19367
|
|
|
19256
19368
|
// src/commands/seq/loadConnections.ts
|
|
19257
19369
|
function loadConnections2() {
|
|
@@ -19280,10 +19392,10 @@ function setDefaultConnection(name) {
|
|
|
19280
19392
|
}
|
|
19281
19393
|
|
|
19282
19394
|
// src/shared/assertUniqueName.ts
|
|
19283
|
-
import
|
|
19395
|
+
import chalk178 from "chalk";
|
|
19284
19396
|
function assertUniqueName(existingNames, name) {
|
|
19285
19397
|
if (existingNames.includes(name)) {
|
|
19286
|
-
console.error(
|
|
19398
|
+
console.error(chalk178.red(`Connection "${name}" already exists.`));
|
|
19287
19399
|
process.exit(1);
|
|
19288
19400
|
}
|
|
19289
19401
|
}
|
|
@@ -19301,16 +19413,16 @@ async function promptConnection2(existingNames) {
|
|
|
19301
19413
|
var seqAuth = createConnectionAuth({
|
|
19302
19414
|
load: loadConnections2,
|
|
19303
19415
|
save: saveConnections2,
|
|
19304
|
-
format: (c) => `${
|
|
19416
|
+
format: (c) => `${chalk179.bold(c.name)} ${c.url}`,
|
|
19305
19417
|
promptNew: promptConnection2,
|
|
19306
19418
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
19307
19419
|
});
|
|
19308
19420
|
|
|
19309
19421
|
// src/commands/seq/seqQuery.ts
|
|
19310
|
-
import
|
|
19422
|
+
import chalk183 from "chalk";
|
|
19311
19423
|
|
|
19312
19424
|
// src/commands/seq/fetchSeq.ts
|
|
19313
|
-
import
|
|
19425
|
+
import chalk180 from "chalk";
|
|
19314
19426
|
async function fetchSeq(conn, path57, params) {
|
|
19315
19427
|
const url = `${conn.url}${path57}?${params}`;
|
|
19316
19428
|
const response = await fetch(url, {
|
|
@@ -19321,7 +19433,7 @@ async function fetchSeq(conn, path57, params) {
|
|
|
19321
19433
|
});
|
|
19322
19434
|
if (!response.ok) {
|
|
19323
19435
|
const body = await response.text();
|
|
19324
|
-
console.error(
|
|
19436
|
+
console.error(chalk180.red(`Seq returned ${response.status}: ${body}`));
|
|
19325
19437
|
process.exit(1);
|
|
19326
19438
|
}
|
|
19327
19439
|
return response;
|
|
@@ -19380,23 +19492,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
19380
19492
|
}
|
|
19381
19493
|
|
|
19382
19494
|
// src/commands/seq/formatEvent.ts
|
|
19383
|
-
import
|
|
19495
|
+
import chalk181 from "chalk";
|
|
19384
19496
|
function levelColor(level) {
|
|
19385
19497
|
switch (level) {
|
|
19386
19498
|
case "Fatal":
|
|
19387
|
-
return
|
|
19499
|
+
return chalk181.bgRed.white;
|
|
19388
19500
|
case "Error":
|
|
19389
|
-
return
|
|
19501
|
+
return chalk181.red;
|
|
19390
19502
|
case "Warning":
|
|
19391
|
-
return
|
|
19503
|
+
return chalk181.yellow;
|
|
19392
19504
|
case "Information":
|
|
19393
|
-
return
|
|
19505
|
+
return chalk181.cyan;
|
|
19394
19506
|
case "Debug":
|
|
19395
|
-
return
|
|
19507
|
+
return chalk181.gray;
|
|
19396
19508
|
case "Verbose":
|
|
19397
|
-
return
|
|
19509
|
+
return chalk181.dim;
|
|
19398
19510
|
default:
|
|
19399
|
-
return
|
|
19511
|
+
return chalk181.white;
|
|
19400
19512
|
}
|
|
19401
19513
|
}
|
|
19402
19514
|
function levelAbbrev(level) {
|
|
@@ -19437,12 +19549,12 @@ function formatTimestamp(iso) {
|
|
|
19437
19549
|
function formatEvent(event) {
|
|
19438
19550
|
const color = levelColor(event.Level);
|
|
19439
19551
|
const abbrev = levelAbbrev(event.Level);
|
|
19440
|
-
const ts8 =
|
|
19552
|
+
const ts8 = chalk181.dim(formatTimestamp(event.Timestamp));
|
|
19441
19553
|
const msg = renderMessage(event);
|
|
19442
19554
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
19443
19555
|
if (event.Exception) {
|
|
19444
19556
|
for (const line of event.Exception.split("\n")) {
|
|
19445
|
-
lines.push(
|
|
19557
|
+
lines.push(chalk181.red(` ${line}`));
|
|
19446
19558
|
}
|
|
19447
19559
|
}
|
|
19448
19560
|
return lines.join("\n");
|
|
@@ -19475,11 +19587,11 @@ function rejectTimestampFilter(filter) {
|
|
|
19475
19587
|
}
|
|
19476
19588
|
|
|
19477
19589
|
// src/shared/resolveNamedConnection.ts
|
|
19478
|
-
import
|
|
19590
|
+
import chalk182 from "chalk";
|
|
19479
19591
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
19480
19592
|
if (connections.length === 0) {
|
|
19481
19593
|
console.error(
|
|
19482
|
-
|
|
19594
|
+
chalk182.red(
|
|
19483
19595
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
19484
19596
|
)
|
|
19485
19597
|
);
|
|
@@ -19488,7 +19600,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
19488
19600
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
19489
19601
|
const connection = connections.find((c) => c.name === target);
|
|
19490
19602
|
if (!connection) {
|
|
19491
|
-
console.error(
|
|
19603
|
+
console.error(chalk182.red(`${kind} connection "${target}" not found.`));
|
|
19492
19604
|
process.exit(1);
|
|
19493
19605
|
}
|
|
19494
19606
|
return connection;
|
|
@@ -19517,7 +19629,7 @@ async function seqQuery(filter, options2) {
|
|
|
19517
19629
|
new URLSearchParams({ filter, count: String(count8) })
|
|
19518
19630
|
);
|
|
19519
19631
|
if (events.length === 0) {
|
|
19520
|
-
console.log(
|
|
19632
|
+
console.log(chalk183.yellow("No events found."));
|
|
19521
19633
|
return;
|
|
19522
19634
|
}
|
|
19523
19635
|
if (options2.json) {
|
|
@@ -19528,11 +19640,11 @@ async function seqQuery(filter, options2) {
|
|
|
19528
19640
|
for (const event of chronological) {
|
|
19529
19641
|
console.log(formatEvent(event));
|
|
19530
19642
|
}
|
|
19531
|
-
console.log(
|
|
19643
|
+
console.log(chalk183.dim(`
|
|
19532
19644
|
${events.length} events`));
|
|
19533
19645
|
if (events.length >= count8) {
|
|
19534
19646
|
console.log(
|
|
19535
|
-
|
|
19647
|
+
chalk183.yellow(
|
|
19536
19648
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
19537
19649
|
)
|
|
19538
19650
|
);
|
|
@@ -19540,10 +19652,10 @@ ${events.length} events`));
|
|
|
19540
19652
|
}
|
|
19541
19653
|
|
|
19542
19654
|
// src/shared/setNamedDefaultConnection.ts
|
|
19543
|
-
import
|
|
19655
|
+
import chalk184 from "chalk";
|
|
19544
19656
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
19545
19657
|
if (!connections.find((c) => c.name === name)) {
|
|
19546
|
-
console.error(
|
|
19658
|
+
console.error(chalk184.red(`Connection "${name}" not found.`));
|
|
19547
19659
|
process.exit(1);
|
|
19548
19660
|
}
|
|
19549
19661
|
setDefault(name);
|
|
@@ -19591,7 +19703,7 @@ function registerSignal(program2) {
|
|
|
19591
19703
|
}
|
|
19592
19704
|
|
|
19593
19705
|
// src/commands/sql/sqlAuth.ts
|
|
19594
|
-
import
|
|
19706
|
+
import chalk186 from "chalk";
|
|
19595
19707
|
|
|
19596
19708
|
// src/commands/sql/loadConnections.ts
|
|
19597
19709
|
function loadConnections3() {
|
|
@@ -19620,7 +19732,7 @@ function setDefaultConnection2(name) {
|
|
|
19620
19732
|
}
|
|
19621
19733
|
|
|
19622
19734
|
// src/commands/sql/promptConnection.ts
|
|
19623
|
-
import
|
|
19735
|
+
import chalk185 from "chalk";
|
|
19624
19736
|
async function promptConnection3(existingNames) {
|
|
19625
19737
|
const name = await promptInput("name", "Connection name:", "default");
|
|
19626
19738
|
assertUniqueName(existingNames, name);
|
|
@@ -19628,7 +19740,7 @@ async function promptConnection3(existingNames) {
|
|
|
19628
19740
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
19629
19741
|
const port = Number.parseInt(portStr, 10);
|
|
19630
19742
|
if (!Number.isFinite(port)) {
|
|
19631
|
-
console.error(
|
|
19743
|
+
console.error(chalk185.red(`Invalid port "${portStr}".`));
|
|
19632
19744
|
process.exit(1);
|
|
19633
19745
|
}
|
|
19634
19746
|
const user = await promptInput("user", "User:");
|
|
@@ -19641,13 +19753,13 @@ async function promptConnection3(existingNames) {
|
|
|
19641
19753
|
var sqlAuth = createConnectionAuth({
|
|
19642
19754
|
load: loadConnections3,
|
|
19643
19755
|
save: saveConnections3,
|
|
19644
|
-
format: (c) => `${
|
|
19756
|
+
format: (c) => `${chalk186.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
19645
19757
|
promptNew: promptConnection3,
|
|
19646
19758
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
19647
19759
|
});
|
|
19648
19760
|
|
|
19649
19761
|
// src/commands/sql/printTable.ts
|
|
19650
|
-
import
|
|
19762
|
+
import chalk187 from "chalk";
|
|
19651
19763
|
function formatCell(value) {
|
|
19652
19764
|
if (value === null || value === void 0) return "";
|
|
19653
19765
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -19656,7 +19768,7 @@ function formatCell(value) {
|
|
|
19656
19768
|
}
|
|
19657
19769
|
function printTable(rows) {
|
|
19658
19770
|
if (rows.length === 0) {
|
|
19659
|
-
console.log(
|
|
19771
|
+
console.log(chalk187.yellow("(no rows)"));
|
|
19660
19772
|
return;
|
|
19661
19773
|
}
|
|
19662
19774
|
const columns = Object.keys(rows[0]);
|
|
@@ -19664,13 +19776,13 @@ function printTable(rows) {
|
|
|
19664
19776
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
19665
19777
|
);
|
|
19666
19778
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
19667
|
-
console.log(
|
|
19668
|
-
console.log(
|
|
19779
|
+
console.log(chalk187.dim(header));
|
|
19780
|
+
console.log(chalk187.dim("-".repeat(header.length)));
|
|
19669
19781
|
for (const row of rows) {
|
|
19670
19782
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
19671
19783
|
console.log(line);
|
|
19672
19784
|
}
|
|
19673
|
-
console.log(
|
|
19785
|
+
console.log(chalk187.dim(`
|
|
19674
19786
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
19675
19787
|
}
|
|
19676
19788
|
|
|
@@ -19730,7 +19842,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
19730
19842
|
}
|
|
19731
19843
|
|
|
19732
19844
|
// src/commands/sql/sqlMutate.ts
|
|
19733
|
-
import
|
|
19845
|
+
import chalk188 from "chalk";
|
|
19734
19846
|
|
|
19735
19847
|
// src/commands/sql/isMutation.ts
|
|
19736
19848
|
var MUTATION_KEYWORDS = [
|
|
@@ -19764,7 +19876,7 @@ function isMutation(sql9) {
|
|
|
19764
19876
|
async function sqlMutate(query, connectionName) {
|
|
19765
19877
|
if (!isMutation(query)) {
|
|
19766
19878
|
console.error(
|
|
19767
|
-
|
|
19879
|
+
chalk188.red(
|
|
19768
19880
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
19769
19881
|
)
|
|
19770
19882
|
);
|
|
@@ -19774,18 +19886,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
19774
19886
|
const pool = await sqlConnect(conn);
|
|
19775
19887
|
try {
|
|
19776
19888
|
const result = await pool.request().query(query);
|
|
19777
|
-
console.log(
|
|
19889
|
+
console.log(chalk188.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
19778
19890
|
} finally {
|
|
19779
19891
|
await pool.close();
|
|
19780
19892
|
}
|
|
19781
19893
|
}
|
|
19782
19894
|
|
|
19783
19895
|
// src/commands/sql/sqlQuery.ts
|
|
19784
|
-
import
|
|
19896
|
+
import chalk189 from "chalk";
|
|
19785
19897
|
async function sqlQuery(query, connectionName) {
|
|
19786
19898
|
if (isMutation(query)) {
|
|
19787
19899
|
console.error(
|
|
19788
|
-
|
|
19900
|
+
chalk189.red(
|
|
19789
19901
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
19790
19902
|
)
|
|
19791
19903
|
);
|
|
@@ -19800,7 +19912,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
19800
19912
|
printTable(rows);
|
|
19801
19913
|
} else {
|
|
19802
19914
|
console.log(
|
|
19803
|
-
|
|
19915
|
+
chalk189.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
19804
19916
|
);
|
|
19805
19917
|
}
|
|
19806
19918
|
} finally {
|
|
@@ -20497,7 +20609,7 @@ function registerVoice(program2) {
|
|
|
20497
20609
|
|
|
20498
20610
|
// src/commands/roam/auth.ts
|
|
20499
20611
|
import { randomBytes } from "crypto";
|
|
20500
|
-
import
|
|
20612
|
+
import chalk190 from "chalk";
|
|
20501
20613
|
|
|
20502
20614
|
// src/commands/roam/waitForCallback.ts
|
|
20503
20615
|
import { createServer as createServer3 } from "http";
|
|
@@ -20628,13 +20740,13 @@ async function auth() {
|
|
|
20628
20740
|
saveGlobalConfig(config);
|
|
20629
20741
|
const state = randomBytes(16).toString("hex");
|
|
20630
20742
|
console.log(
|
|
20631
|
-
|
|
20743
|
+
chalk190.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
20632
20744
|
);
|
|
20633
|
-
console.log(
|
|
20634
|
-
console.log(
|
|
20635
|
-
console.log(
|
|
20745
|
+
console.log(chalk190.white("http://localhost:14523/callback\n"));
|
|
20746
|
+
console.log(chalk190.blue("Opening browser for authorization..."));
|
|
20747
|
+
console.log(chalk190.dim("Waiting for authorization callback..."));
|
|
20636
20748
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
20637
|
-
console.log(
|
|
20749
|
+
console.log(chalk190.dim("Exchanging code for tokens..."));
|
|
20638
20750
|
const tokens = await exchangeToken({
|
|
20639
20751
|
code,
|
|
20640
20752
|
clientId,
|
|
@@ -20650,7 +20762,7 @@ async function auth() {
|
|
|
20650
20762
|
};
|
|
20651
20763
|
saveGlobalConfig(config);
|
|
20652
20764
|
console.log(
|
|
20653
|
-
|
|
20765
|
+
chalk190.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
20654
20766
|
);
|
|
20655
20767
|
}
|
|
20656
20768
|
|
|
@@ -21102,7 +21214,7 @@ import { execSync as execSync54 } from "child_process";
|
|
|
21102
21214
|
import { existsSync as existsSync51, mkdirSync as mkdirSync22, unlinkSync as unlinkSync19, writeFileSync as writeFileSync39 } from "fs";
|
|
21103
21215
|
import { tmpdir as tmpdir7 } from "os";
|
|
21104
21216
|
import { join as join61, resolve as resolve15 } from "path";
|
|
21105
|
-
import
|
|
21217
|
+
import chalk191 from "chalk";
|
|
21106
21218
|
|
|
21107
21219
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
21108
21220
|
var captureWindowPs1 = `
|
|
@@ -21253,13 +21365,13 @@ function screenshot(processName) {
|
|
|
21253
21365
|
const config = loadConfig();
|
|
21254
21366
|
const outputDir = resolve15(config.screenshot.outputDir);
|
|
21255
21367
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
21256
|
-
console.log(
|
|
21368
|
+
console.log(chalk191.gray(`Capturing window for process "${processName}" ...`));
|
|
21257
21369
|
try {
|
|
21258
21370
|
runPowerShellScript(processName, outputPath);
|
|
21259
|
-
console.log(
|
|
21371
|
+
console.log(chalk191.green(`Screenshot saved: ${outputPath}`));
|
|
21260
21372
|
} catch (error) {
|
|
21261
21373
|
const msg = error instanceof Error ? error.message : String(error);
|
|
21262
|
-
console.error(
|
|
21374
|
+
console.error(chalk191.red(`Failed to capture screenshot: ${msg}`));
|
|
21263
21375
|
process.exit(1);
|
|
21264
21376
|
}
|
|
21265
21377
|
}
|
|
@@ -22068,10 +22180,10 @@ function applyReviewPause(session, activity2) {
|
|
|
22068
22180
|
}
|
|
22069
22181
|
|
|
22070
22182
|
// src/shared/db/getPhaseActiveMs.ts
|
|
22071
|
-
import { and as
|
|
22183
|
+
import { and as and19, eq as eq38 } from "drizzle-orm";
|
|
22072
22184
|
async function getPhaseActiveMs(db, itemId, phaseIdx) {
|
|
22073
22185
|
const [row] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
|
|
22074
|
-
|
|
22186
|
+
and19(eq38(phaseUsage.itemId, itemId), eq38(phaseUsage.phaseIdx, phaseIdx))
|
|
22075
22187
|
);
|
|
22076
22188
|
return row?.activeMs ?? 0;
|
|
22077
22189
|
}
|
|
@@ -23920,7 +24032,7 @@ function registerDaemon(program2) {
|
|
|
23920
24032
|
|
|
23921
24033
|
// src/commands/sessions/summarise/index.ts
|
|
23922
24034
|
import * as fs36 from "fs";
|
|
23923
|
-
import
|
|
24035
|
+
import chalk192 from "chalk";
|
|
23924
24036
|
|
|
23925
24037
|
// src/commands/sessions/summarise/shared.ts
|
|
23926
24038
|
import * as fs34 from "fs";
|
|
@@ -24074,22 +24186,22 @@ ${firstMessage}`);
|
|
|
24074
24186
|
async function summarise2(options2) {
|
|
24075
24187
|
const files = await discoverSessionFiles();
|
|
24076
24188
|
if (files.length === 0) {
|
|
24077
|
-
console.log(
|
|
24189
|
+
console.log(chalk192.yellow("No sessions found."));
|
|
24078
24190
|
return;
|
|
24079
24191
|
}
|
|
24080
24192
|
const toProcess = selectCandidates(files, options2);
|
|
24081
24193
|
if (toProcess.length === 0) {
|
|
24082
|
-
console.log(
|
|
24194
|
+
console.log(chalk192.green("All sessions already summarised."));
|
|
24083
24195
|
return;
|
|
24084
24196
|
}
|
|
24085
24197
|
console.log(
|
|
24086
|
-
|
|
24198
|
+
chalk192.cyan(
|
|
24087
24199
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
24088
24200
|
)
|
|
24089
24201
|
);
|
|
24090
24202
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
24091
24203
|
console.log(
|
|
24092
|
-
|
|
24204
|
+
chalk192.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk192.yellow(`, ${failed2} skipped`) : "")
|
|
24093
24205
|
);
|
|
24094
24206
|
}
|
|
24095
24207
|
function selectCandidates(files, options2) {
|
|
@@ -24109,16 +24221,16 @@ function processSessions(files) {
|
|
|
24109
24221
|
let failed2 = 0;
|
|
24110
24222
|
for (let i = 0; i < files.length; i++) {
|
|
24111
24223
|
const file = files[i];
|
|
24112
|
-
process.stdout.write(
|
|
24224
|
+
process.stdout.write(chalk192.dim(` [${i + 1}/${files.length}] `));
|
|
24113
24225
|
const summary = summariseSession(file);
|
|
24114
24226
|
if (summary) {
|
|
24115
24227
|
writeSummary(file, summary);
|
|
24116
24228
|
succeeded++;
|
|
24117
|
-
process.stdout.write(`${
|
|
24229
|
+
process.stdout.write(`${chalk192.green("\u2713")} ${summary}
|
|
24118
24230
|
`);
|
|
24119
24231
|
} else {
|
|
24120
24232
|
failed2++;
|
|
24121
|
-
process.stdout.write(` ${
|
|
24233
|
+
process.stdout.write(` ${chalk192.yellow("skip")}
|
|
24122
24234
|
`);
|
|
24123
24235
|
}
|
|
24124
24236
|
}
|
|
@@ -24136,10 +24248,10 @@ function registerSessions(program2) {
|
|
|
24136
24248
|
}
|
|
24137
24249
|
|
|
24138
24250
|
// src/commands/statusLine.ts
|
|
24139
|
-
import
|
|
24251
|
+
import chalk194 from "chalk";
|
|
24140
24252
|
|
|
24141
24253
|
// src/commands/buildLimitsSegment.ts
|
|
24142
|
-
import
|
|
24254
|
+
import chalk193 from "chalk";
|
|
24143
24255
|
|
|
24144
24256
|
// src/shared/rateLimitLevel.ts
|
|
24145
24257
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -24170,9 +24282,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
24170
24282
|
|
|
24171
24283
|
// src/commands/buildLimitsSegment.ts
|
|
24172
24284
|
var LEVEL_COLOR = {
|
|
24173
|
-
ok:
|
|
24174
|
-
warn:
|
|
24175
|
-
over:
|
|
24285
|
+
ok: chalk193.green,
|
|
24286
|
+
warn: chalk193.yellow,
|
|
24287
|
+
over: chalk193.red
|
|
24176
24288
|
};
|
|
24177
24289
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
24178
24290
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -24263,14 +24375,14 @@ async function relayUsage(claudeSessionId, totalIn, totalOut) {
|
|
|
24263
24375
|
}
|
|
24264
24376
|
|
|
24265
24377
|
// src/commands/statusLine.ts
|
|
24266
|
-
|
|
24378
|
+
chalk194.level = 3;
|
|
24267
24379
|
function formatNumber(num) {
|
|
24268
24380
|
return num.toLocaleString("en-US");
|
|
24269
24381
|
}
|
|
24270
24382
|
function colorizePercent(pct) {
|
|
24271
24383
|
const label2 = `${Math.round(pct)}%`;
|
|
24272
|
-
if (pct > 80) return
|
|
24273
|
-
if (pct > 40) return
|
|
24384
|
+
if (pct > 80) return chalk194.red(label2);
|
|
24385
|
+
if (pct > 40) return chalk194.yellow(label2);
|
|
24274
24386
|
return label2;
|
|
24275
24387
|
}
|
|
24276
24388
|
async function statusLine() {
|
|
@@ -24281,7 +24393,7 @@ async function statusLine() {
|
|
|
24281
24393
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
24282
24394
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
24283
24395
|
const branch2 = dir ? readGitBranch(windowsCwdToWslPath(dir)) : null;
|
|
24284
|
-
const branchSegment = branch2 ? `\u{
|
|
24396
|
+
const branchSegment = branch2 ? `\u{1F33F} ${chalk194.cyan(branch2)} | ` : "";
|
|
24285
24397
|
console.log(
|
|
24286
24398
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalOut)} \u2191 : ${formatNumber(totalIn)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
24287
24399
|
);
|
|
@@ -24298,7 +24410,7 @@ import { fileURLToPath as fileURLToPath7 } from "url";
|
|
|
24298
24410
|
// src/commands/sync/syncClaudeMd.ts
|
|
24299
24411
|
import * as fs37 from "fs";
|
|
24300
24412
|
import * as path53 from "path";
|
|
24301
|
-
import
|
|
24413
|
+
import chalk195 from "chalk";
|
|
24302
24414
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
24303
24415
|
const source = path53.join(claudeDir, "CLAUDE.md");
|
|
24304
24416
|
const target = path53.join(targetBase, "CLAUDE.md");
|
|
@@ -24307,12 +24419,12 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24307
24419
|
const targetContent = fs37.readFileSync(target, "utf8");
|
|
24308
24420
|
if (sourceContent !== targetContent) {
|
|
24309
24421
|
console.log(
|
|
24310
|
-
|
|
24422
|
+
chalk195.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
24311
24423
|
);
|
|
24312
24424
|
console.log();
|
|
24313
24425
|
printDiff(targetContent, sourceContent);
|
|
24314
24426
|
const confirm = options2?.yes || await promptConfirm(
|
|
24315
|
-
|
|
24427
|
+
chalk195.red("Overwrite existing CLAUDE.md?"),
|
|
24316
24428
|
false
|
|
24317
24429
|
);
|
|
24318
24430
|
if (!confirm) {
|
|
@@ -24328,7 +24440,7 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24328
24440
|
// src/commands/sync/syncSettings.ts
|
|
24329
24441
|
import * as fs38 from "fs";
|
|
24330
24442
|
import * as path54 from "path";
|
|
24331
|
-
import
|
|
24443
|
+
import chalk196 from "chalk";
|
|
24332
24444
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
24333
24445
|
const source = path54.join(claudeDir, "settings.json");
|
|
24334
24446
|
const target = path54.join(targetBase, "settings.json");
|
|
@@ -24347,14 +24459,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
24347
24459
|
if (mergedContent !== normalizedTarget) {
|
|
24348
24460
|
if (!options2?.yes) {
|
|
24349
24461
|
console.log(
|
|
24350
|
-
|
|
24462
|
+
chalk196.yellow(
|
|
24351
24463
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
24352
24464
|
)
|
|
24353
24465
|
);
|
|
24354
24466
|
console.log();
|
|
24355
24467
|
printDiff(targetContent, mergedContent);
|
|
24356
24468
|
const confirm = await promptConfirm(
|
|
24357
|
-
|
|
24469
|
+
chalk196.red("Overwrite existing settings.json?"),
|
|
24358
24470
|
false
|
|
24359
24471
|
);
|
|
24360
24472
|
if (!confirm) {
|