@staff0rd/assist 0.596.0 → 0.598.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.598.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -19047,48 +19047,181 @@ async function criteriaExtension() {
|
|
|
19047
19047
|
console.log(chalk139.dim(`load the unpacked extension from ${path84}`));
|
|
19048
19048
|
}
|
|
19049
19049
|
|
|
19050
|
+
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19051
|
+
import { rm as rm3 } from "fs/promises";
|
|
19052
|
+
import { homedir as homedir19, tmpdir as tmpdir4 } from "os";
|
|
19053
|
+
import { join as join47 } from "path";
|
|
19054
|
+
import chalk141 from "chalk";
|
|
19055
|
+
|
|
19056
|
+
// src/commands/criteriaExtension/copySignedXpi.ts
|
|
19057
|
+
import { copyFile } from "fs/promises";
|
|
19058
|
+
import { join as join43 } from "path";
|
|
19059
|
+
var SIGNED_XPI_NAME = "criteria-extension.xpi";
|
|
19060
|
+
async function copySignedXpi(xpi, dir) {
|
|
19061
|
+
const fixed2 = join43(dir, SIGNED_XPI_NAME);
|
|
19062
|
+
if (fixed2 === xpi) return fixed2;
|
|
19063
|
+
await copyFile(xpi, fixed2);
|
|
19064
|
+
return fixed2;
|
|
19065
|
+
}
|
|
19066
|
+
|
|
19067
|
+
// src/commands/criteriaExtension/findSignedXpi.ts
|
|
19068
|
+
import { existsSync as existsSync44 } from "fs";
|
|
19069
|
+
import { readdir } from "fs/promises";
|
|
19070
|
+
import { join as join44 } from "path";
|
|
19071
|
+
async function findSignedXpi(dir) {
|
|
19072
|
+
if (!existsSync44(dir)) return null;
|
|
19073
|
+
const name = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
19074
|
+
return name ? join44(dir, name) : null;
|
|
19075
|
+
}
|
|
19076
|
+
|
|
19077
|
+
// src/commands/criteriaExtension/signedAddonInstallPath.ts
|
|
19078
|
+
import { cp as cp2 } from "fs/promises";
|
|
19079
|
+
import chalk140 from "chalk";
|
|
19080
|
+
var WSL_WINDOWS_XPI = "/mnt/c/tools/criteria-extension.xpi";
|
|
19081
|
+
var WSL_WINDOWS_PATH2 = String.raw`C:\tools\criteria-extension.xpi`;
|
|
19082
|
+
async function signedAddonInstallPath(xpi) {
|
|
19083
|
+
if (detectPlatform() !== "wsl") return xpi;
|
|
19084
|
+
try {
|
|
19085
|
+
await cp2(xpi, WSL_WINDOWS_XPI);
|
|
19086
|
+
return WSL_WINDOWS_PATH2;
|
|
19087
|
+
} catch {
|
|
19088
|
+
console.log(
|
|
19089
|
+
chalk140.yellow(`could not copy the add-on to ${WSL_WINDOWS_PATH2}`)
|
|
19090
|
+
);
|
|
19091
|
+
return xpi;
|
|
19092
|
+
}
|
|
19093
|
+
}
|
|
19094
|
+
|
|
19095
|
+
// src/commands/criteriaExtension/signPreflightProblem.ts
|
|
19096
|
+
import { existsSync as existsSync45 } from "fs";
|
|
19097
|
+
import { join as join45 } from "path";
|
|
19098
|
+
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
19099
|
+
function signPreflightProblem(source) {
|
|
19100
|
+
if (!existsSync45(join45(source, "content.js")))
|
|
19101
|
+
return {
|
|
19102
|
+
message: `no content.js in ${source}`,
|
|
19103
|
+
hint: "run npm run build to bundle the content script"
|
|
19104
|
+
};
|
|
19105
|
+
if (!(process.env.WEB_EXT_API_KEY && process.env.WEB_EXT_API_SECRET))
|
|
19106
|
+
return {
|
|
19107
|
+
message: "WEB_EXT_API_KEY and WEB_EXT_API_SECRET are not both set",
|
|
19108
|
+
hint: `create an AMO API key at ${KEY_URL}`
|
|
19109
|
+
};
|
|
19110
|
+
return null;
|
|
19111
|
+
}
|
|
19112
|
+
|
|
19113
|
+
// src/commands/criteriaExtension/stageCriteriaExtension.ts
|
|
19114
|
+
import { cp as cp3, mkdir as mkdir4, readFile as readFile4, rm as rm2, writeFile as writeFile4 } from "fs/promises";
|
|
19115
|
+
import { join as join46 } from "path";
|
|
19116
|
+
|
|
19117
|
+
// src/commands/criteriaExtension/stampManifestVersion.ts
|
|
19118
|
+
function stampManifestVersion(manifest, version2) {
|
|
19119
|
+
const parsed = JSON.parse(manifest);
|
|
19120
|
+
return `${JSON.stringify({ ...parsed, version: version2 }, null, " ")}
|
|
19121
|
+
`;
|
|
19122
|
+
}
|
|
19123
|
+
|
|
19124
|
+
// src/commands/criteriaExtension/stageCriteriaExtension.ts
|
|
19125
|
+
async function stageCriteriaExtension(source, staging, version2) {
|
|
19126
|
+
await rm2(staging, { recursive: true, force: true });
|
|
19127
|
+
await mkdir4(staging, { recursive: true });
|
|
19128
|
+
await cp3(source, staging, { recursive: true });
|
|
19129
|
+
const manifest = join46(staging, "manifest.json");
|
|
19130
|
+
const stamped = stampManifestVersion(
|
|
19131
|
+
await readFile4(manifest, "utf8"),
|
|
19132
|
+
version2
|
|
19133
|
+
);
|
|
19134
|
+
await writeFile4(manifest, stamped);
|
|
19135
|
+
}
|
|
19136
|
+
|
|
19137
|
+
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19138
|
+
var ARTIFACTS_DIR = join47(homedir19(), ".assist", "criteria-extension");
|
|
19139
|
+
var STAGING_DIR = join47(tmpdir4(), "assist-criteria-extension");
|
|
19140
|
+
async function signCriteriaExtension() {
|
|
19141
|
+
const source = criteriaExtensionDir();
|
|
19142
|
+
const problem = signPreflightProblem(source);
|
|
19143
|
+
if (problem) {
|
|
19144
|
+
console.log(chalk141.red(problem.message));
|
|
19145
|
+
console.log(chalk141.dim(problem.hint));
|
|
19146
|
+
process.exitCode = 1;
|
|
19147
|
+
return;
|
|
19148
|
+
}
|
|
19149
|
+
const { version: version2 } = package_default;
|
|
19150
|
+
await stageCriteriaExtension(source, STAGING_DIR, version2);
|
|
19151
|
+
await rm3(ARTIFACTS_DIR, { recursive: true, force: true });
|
|
19152
|
+
console.log(chalk141.bold(`signing version ${version2} for self-distribution`));
|
|
19153
|
+
const { done: done2 } = spawnInherit("npx", [
|
|
19154
|
+
"--yes",
|
|
19155
|
+
"web-ext",
|
|
19156
|
+
"sign",
|
|
19157
|
+
`--source-dir=${STAGING_DIR}`,
|
|
19158
|
+
`--artifacts-dir=${ARTIFACTS_DIR}`,
|
|
19159
|
+
"--channel=unlisted"
|
|
19160
|
+
]);
|
|
19161
|
+
if (await done2 !== 0) {
|
|
19162
|
+
console.log(chalk141.red("web-ext sign failed"));
|
|
19163
|
+
process.exitCode = 1;
|
|
19164
|
+
return;
|
|
19165
|
+
}
|
|
19166
|
+
const xpi = await findSignedXpi(ARTIFACTS_DIR);
|
|
19167
|
+
if (!xpi) {
|
|
19168
|
+
console.log(chalk141.red(`web-ext wrote no .xpi into ${ARTIFACTS_DIR}`));
|
|
19169
|
+
process.exitCode = 1;
|
|
19170
|
+
return;
|
|
19171
|
+
}
|
|
19172
|
+
const path84 = await signedAddonInstallPath(
|
|
19173
|
+
await copySignedXpi(xpi, ARTIFACTS_DIR)
|
|
19174
|
+
);
|
|
19175
|
+
console.log(chalk141.dim(`install the signed add-on from ${path84}`));
|
|
19176
|
+
}
|
|
19177
|
+
|
|
19050
19178
|
// src/commands/registerCriteriaExtension.ts
|
|
19051
19179
|
function registerCriteriaExtension(program2) {
|
|
19052
19180
|
program2.command("criteria-extension").description(
|
|
19053
19181
|
"Print the directory to load the acceptance criteria outliner browser extension from (load unpacked)"
|
|
19054
|
-
).
|
|
19182
|
+
).option(
|
|
19183
|
+
"--sign",
|
|
19184
|
+
"Sign the extension on AMO's unlisted channel and print the .xpi to install permanently in Firefox (needs WEB_EXT_API_KEY and WEB_EXT_API_SECRET)"
|
|
19185
|
+
).action(
|
|
19186
|
+
(options2) => options2.sign ? signCriteriaExtension() : criteriaExtension()
|
|
19187
|
+
);
|
|
19055
19188
|
}
|
|
19056
19189
|
|
|
19057
19190
|
// src/commands/db/reportMigrationStatus.ts
|
|
19058
|
-
import
|
|
19191
|
+
import chalk142 from "chalk";
|
|
19059
19192
|
function reportApplied(applied) {
|
|
19060
19193
|
if (applied.length === 0) {
|
|
19061
|
-
console.error(
|
|
19194
|
+
console.error(chalk142.green("Database is up to date; nothing to apply."));
|
|
19062
19195
|
return;
|
|
19063
19196
|
}
|
|
19064
19197
|
for (const migration of applied) {
|
|
19065
19198
|
console.error(
|
|
19066
|
-
|
|
19199
|
+
chalk142.green(`Applied migration ${migration.id} (${migration.name}).`)
|
|
19067
19200
|
);
|
|
19068
19201
|
}
|
|
19069
19202
|
}
|
|
19070
19203
|
function reportMigrationStatus(status3) {
|
|
19071
19204
|
if (status3.state === "in-sync") {
|
|
19072
19205
|
console.error(
|
|
19073
|
-
|
|
19206
|
+
chalk142.green(`In sync at migration ${status3.version} (latest).`)
|
|
19074
19207
|
);
|
|
19075
19208
|
return;
|
|
19076
19209
|
}
|
|
19077
19210
|
if (status3.state === "behind") {
|
|
19078
19211
|
console.error(
|
|
19079
|
-
|
|
19212
|
+
chalk142.yellow(
|
|
19080
19213
|
`Behind: applied ${status3.applied}, build expects ${status3.expected}.`
|
|
19081
19214
|
)
|
|
19082
19215
|
);
|
|
19083
19216
|
console.error(
|
|
19084
|
-
|
|
19217
|
+
chalk142.yellow(
|
|
19085
19218
|
`Pending: ${status3.pending.join(", ")}. Run \`assist db migrate\`.`
|
|
19086
19219
|
)
|
|
19087
19220
|
);
|
|
19088
19221
|
return;
|
|
19089
19222
|
}
|
|
19090
19223
|
console.error(
|
|
19091
|
-
|
|
19224
|
+
chalk142.red(
|
|
19092
19225
|
`Ahead: applied ${status3.applied}, build knows ${status3.expected}. Update assist.`
|
|
19093
19226
|
)
|
|
19094
19227
|
);
|
|
@@ -19123,22 +19256,22 @@ function registerDb(program2) {
|
|
|
19123
19256
|
|
|
19124
19257
|
// src/commands/dbMigration/dbMigrationConfirm.ts
|
|
19125
19258
|
import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs";
|
|
19126
|
-
import
|
|
19259
|
+
import chalk143 from "chalk";
|
|
19127
19260
|
|
|
19128
19261
|
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
19129
|
-
import { join as
|
|
19262
|
+
import { join as join48 } from "path";
|
|
19130
19263
|
function getMigrationPinPath(pin) {
|
|
19131
|
-
return
|
|
19264
|
+
return join48(getRestrictedDir(), `db-migration-pin-${pin}.json`);
|
|
19132
19265
|
}
|
|
19133
19266
|
function getMigrationApprovalPath(migrationId) {
|
|
19134
|
-
return
|
|
19267
|
+
return join48(getRestrictedDir(), `db-migration-approval-${migrationId}.json`);
|
|
19135
19268
|
}
|
|
19136
19269
|
|
|
19137
19270
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
19138
|
-
import { existsSync as
|
|
19271
|
+
import { existsSync as existsSync46, readFileSync as readFileSync31 } from "fs";
|
|
19139
19272
|
function readMigrationPinState(pin) {
|
|
19140
19273
|
const path84 = getMigrationPinPath(pin);
|
|
19141
|
-
if (!
|
|
19274
|
+
if (!existsSync46(path84)) return void 0;
|
|
19142
19275
|
try {
|
|
19143
19276
|
const state = JSON.parse(readFileSync31(path84, "utf8"));
|
|
19144
19277
|
if (state.pin !== pin) return void 0;
|
|
@@ -19154,7 +19287,7 @@ function dbMigrationConfirm(pin) {
|
|
|
19154
19287
|
sweepRestrictedDir();
|
|
19155
19288
|
const state = readMigrationPinState(pin);
|
|
19156
19289
|
if (!state) {
|
|
19157
|
-
console.error(
|
|
19290
|
+
console.error(chalk143.red(`No pending migration unlock for pin: ${pin}`));
|
|
19158
19291
|
process.exitCode = 1;
|
|
19159
19292
|
return;
|
|
19160
19293
|
}
|
|
@@ -19164,7 +19297,7 @@ function dbMigrationConfirm(pin) {
|
|
|
19164
19297
|
);
|
|
19165
19298
|
unlinkSync9(getMigrationPinPath(pin));
|
|
19166
19299
|
console.log(
|
|
19167
|
-
|
|
19300
|
+
chalk143.green(
|
|
19168
19301
|
`Approved creation of migration ${state.migrationId}. The next write of that migration module will be allowed once.`
|
|
19169
19302
|
)
|
|
19170
19303
|
);
|
|
@@ -19173,7 +19306,7 @@ function dbMigrationConfirm(pin) {
|
|
|
19173
19306
|
// src/commands/dbMigration/dbMigrationUnlock.ts
|
|
19174
19307
|
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync27 } from "fs";
|
|
19175
19308
|
import { randomInt as randomInt2 } from "crypto";
|
|
19176
|
-
import
|
|
19309
|
+
import chalk144 from "chalk";
|
|
19177
19310
|
|
|
19178
19311
|
// src/commands/dbMigration/nextMigrationId.ts
|
|
19179
19312
|
function nextMigrationId() {
|
|
@@ -19188,7 +19321,7 @@ function dbMigrationUnlock() {
|
|
|
19188
19321
|
sweepRestrictedDir();
|
|
19189
19322
|
writeFileSync27(getMigrationPinPath(pin), JSON.stringify({ pin, migrationId }));
|
|
19190
19323
|
console.error(
|
|
19191
|
-
|
|
19324
|
+
chalk144.yellow.bold(
|
|
19192
19325
|
"THIS IS YOUR LAST CHANCE TO RECONSIDER BEFORE INVOLVING A HUMAN.\nRequesting this pin pages a real person to approve a new database migration.\nA schema change is hard to reverse once shipped. You had BETTER have confirmed\nthe change with the user and be certain this migration is genuinely necessary."
|
|
19193
19326
|
)
|
|
19194
19327
|
);
|
|
@@ -19198,7 +19331,7 @@ function dbMigrationUnlock() {
|
|
|
19198
19331
|
});
|
|
19199
19332
|
if (!delivered) {
|
|
19200
19333
|
console.error(
|
|
19201
|
-
|
|
19334
|
+
chalk144.red(
|
|
19202
19335
|
"Could not deliver the confirmation pin via notification.\nThe migration cannot be approved until the notification channel works."
|
|
19203
19336
|
)
|
|
19204
19337
|
);
|
|
@@ -19208,7 +19341,7 @@ function dbMigrationUnlock() {
|
|
|
19208
19341
|
console.log(
|
|
19209
19342
|
`A confirmation pin was sent to your desktop notifications.
|
|
19210
19343
|
To approve creating migration ${migrationId}, run:
|
|
19211
|
-
${
|
|
19344
|
+
${chalk144.cyan(" assist db-migration confirm <PIN>")}
|
|
19212
19345
|
using the pin from that notification.`
|
|
19213
19346
|
);
|
|
19214
19347
|
}
|
|
@@ -19227,8 +19360,8 @@ function registerDbMigration(parent) {
|
|
|
19227
19360
|
}
|
|
19228
19361
|
|
|
19229
19362
|
// src/commands/deploy/redirect.ts
|
|
19230
|
-
import { existsSync as
|
|
19231
|
-
import
|
|
19363
|
+
import { existsSync as existsSync47, readFileSync as readFileSync32, writeFileSync as writeFileSync28 } from "fs";
|
|
19364
|
+
import chalk145 from "chalk";
|
|
19232
19365
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
19233
19366
|
if (!window.location.pathname.endsWith('/')) {
|
|
19234
19367
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -19236,24 +19369,24 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
19236
19369
|
</script>`;
|
|
19237
19370
|
function redirect() {
|
|
19238
19371
|
const indexPath = "index.html";
|
|
19239
|
-
if (!
|
|
19240
|
-
console.log(
|
|
19372
|
+
if (!existsSync47(indexPath)) {
|
|
19373
|
+
console.log(chalk145.yellow("No index.html found"));
|
|
19241
19374
|
return;
|
|
19242
19375
|
}
|
|
19243
19376
|
const content = readFileSync32(indexPath, "utf8");
|
|
19244
19377
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
19245
|
-
console.log(
|
|
19378
|
+
console.log(chalk145.dim("Trailing slash script already present"));
|
|
19246
19379
|
return;
|
|
19247
19380
|
}
|
|
19248
19381
|
const headCloseIndex = content.indexOf("</head>");
|
|
19249
19382
|
if (headCloseIndex === -1) {
|
|
19250
|
-
console.log(
|
|
19383
|
+
console.log(chalk145.red("Could not find </head> tag in index.html"));
|
|
19251
19384
|
return;
|
|
19252
19385
|
}
|
|
19253
19386
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
19254
19387
|
${content.slice(headCloseIndex)}`;
|
|
19255
19388
|
writeFileSync28(indexPath, newContent);
|
|
19256
|
-
console.log(
|
|
19389
|
+
console.log(chalk145.green("Added trailing slash redirect to index.html"));
|
|
19257
19390
|
}
|
|
19258
19391
|
|
|
19259
19392
|
// src/commands/registerDeploy.ts
|
|
@@ -19268,11 +19401,11 @@ import { execFileSync as execFileSync3 } from "child_process";
|
|
|
19268
19401
|
import { basename as basename13 } from "path";
|
|
19269
19402
|
|
|
19270
19403
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
19271
|
-
import { homedir as
|
|
19272
|
-
import { join as
|
|
19273
|
-
var BLOG_REPO_ROOT =
|
|
19404
|
+
import { homedir as homedir20 } from "os";
|
|
19405
|
+
import { join as join49 } from "path";
|
|
19406
|
+
var BLOG_REPO_ROOT = join49(homedir20(), "git/blog");
|
|
19274
19407
|
function loadBlogSkipDays(repoName) {
|
|
19275
|
-
const config = loadRawYaml(
|
|
19408
|
+
const config = loadRawYaml(join49(BLOG_REPO_ROOT, "assist.yml"));
|
|
19276
19409
|
const devlog = config.devlog;
|
|
19277
19410
|
const skip2 = devlog?.skip;
|
|
19278
19411
|
return new Set(skip2?.[repoName]);
|
|
@@ -19280,18 +19413,18 @@ function loadBlogSkipDays(repoName) {
|
|
|
19280
19413
|
|
|
19281
19414
|
// src/commands/devlog/shared.ts
|
|
19282
19415
|
import { execSync as execSync36 } from "child_process";
|
|
19283
|
-
import
|
|
19416
|
+
import chalk146 from "chalk";
|
|
19284
19417
|
|
|
19285
19418
|
// src/shared/getRepoName.ts
|
|
19286
|
-
import { existsSync as
|
|
19287
|
-
import { basename as basename12, join as
|
|
19419
|
+
import { existsSync as existsSync48, readFileSync as readFileSync33 } from "fs";
|
|
19420
|
+
import { basename as basename12, join as join50 } from "path";
|
|
19288
19421
|
function getRepoName() {
|
|
19289
19422
|
const config = loadConfig();
|
|
19290
19423
|
if (config.devlog?.name) {
|
|
19291
19424
|
return config.devlog.name;
|
|
19292
19425
|
}
|
|
19293
|
-
const packageJsonPath =
|
|
19294
|
-
if (
|
|
19426
|
+
const packageJsonPath = join50(process.cwd(), "package.json");
|
|
19427
|
+
if (existsSync48(packageJsonPath)) {
|
|
19295
19428
|
try {
|
|
19296
19429
|
const content = readFileSync33(packageJsonPath, "utf8");
|
|
19297
19430
|
const pkg = JSON.parse(content);
|
|
@@ -19306,8 +19439,8 @@ function getRepoName() {
|
|
|
19306
19439
|
|
|
19307
19440
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
19308
19441
|
import { readdirSync as readdirSync6, readFileSync as readFileSync34 } from "fs";
|
|
19309
|
-
import { join as
|
|
19310
|
-
var DEVLOG_DIR =
|
|
19442
|
+
import { join as join51 } from "path";
|
|
19443
|
+
var DEVLOG_DIR = join51(BLOG_REPO_ROOT, "src/content/devlog");
|
|
19311
19444
|
function extractFrontmatter(content) {
|
|
19312
19445
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
19313
19446
|
return fm?.[1] ?? null;
|
|
@@ -19335,7 +19468,7 @@ function readDevlogFiles(callback) {
|
|
|
19335
19468
|
try {
|
|
19336
19469
|
const files = readdirSync6(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
19337
19470
|
for (const file of files) {
|
|
19338
|
-
const content = readFileSync34(
|
|
19471
|
+
const content = readFileSync34(join51(DEVLOG_DIR, file), "utf8");
|
|
19339
19472
|
const parsed = parseFrontmatter(content, file);
|
|
19340
19473
|
if (parsed) callback(parsed);
|
|
19341
19474
|
}
|
|
@@ -19389,13 +19522,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
19389
19522
|
}
|
|
19390
19523
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
19391
19524
|
for (const commit2 of commits2) {
|
|
19392
|
-
console.log(` ${
|
|
19525
|
+
console.log(` ${chalk146.yellow(commit2.hash)} ${commit2.message}`);
|
|
19393
19526
|
if (verbose) {
|
|
19394
19527
|
const visibleFiles = commit2.files.filter(
|
|
19395
19528
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
19396
19529
|
);
|
|
19397
19530
|
for (const file of visibleFiles) {
|
|
19398
|
-
console.log(` ${
|
|
19531
|
+
console.log(` ${chalk146.dim(file)}`);
|
|
19399
19532
|
}
|
|
19400
19533
|
}
|
|
19401
19534
|
}
|
|
@@ -19420,15 +19553,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
19420
19553
|
}
|
|
19421
19554
|
|
|
19422
19555
|
// src/commands/devlog/list/printDateHeader.ts
|
|
19423
|
-
import
|
|
19556
|
+
import chalk147 from "chalk";
|
|
19424
19557
|
function printDateHeader(date, isSkipped, entries) {
|
|
19425
19558
|
if (isSkipped) {
|
|
19426
|
-
console.log(`${
|
|
19559
|
+
console.log(`${chalk147.bold.blue(date)} ${chalk147.dim("skipped")}`);
|
|
19427
19560
|
} else if (entries && entries.length > 0) {
|
|
19428
|
-
const entryInfo = entries.map((e) => `${
|
|
19429
|
-
console.log(`${
|
|
19561
|
+
const entryInfo = entries.map((e) => `${chalk147.green(e.version)} ${e.title}`).join(" | ");
|
|
19562
|
+
console.log(`${chalk147.bold.blue(date)} ${entryInfo}`);
|
|
19430
19563
|
} else {
|
|
19431
|
-
console.log(`${
|
|
19564
|
+
console.log(`${chalk147.bold.blue(date)} ${chalk147.red("\u26A0 devlog missing")}`);
|
|
19432
19565
|
}
|
|
19433
19566
|
}
|
|
19434
19567
|
|
|
@@ -19532,24 +19665,24 @@ function bumpVersion(version2, type) {
|
|
|
19532
19665
|
|
|
19533
19666
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
19534
19667
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
19535
|
-
import
|
|
19668
|
+
import chalk149 from "chalk";
|
|
19536
19669
|
|
|
19537
19670
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
19538
|
-
import
|
|
19671
|
+
import chalk148 from "chalk";
|
|
19539
19672
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
19540
19673
|
if (conventional && firstHash) {
|
|
19541
19674
|
const version2 = getVersionAtCommit(firstHash);
|
|
19542
19675
|
if (version2) {
|
|
19543
|
-
console.log(`${
|
|
19676
|
+
console.log(`${chalk148.bold("version:")} ${stripToMinor(version2)}`);
|
|
19544
19677
|
} else {
|
|
19545
|
-
console.log(`${
|
|
19678
|
+
console.log(`${chalk148.bold("version:")} ${chalk148.red("unknown")}`);
|
|
19546
19679
|
}
|
|
19547
19680
|
} else if (patchVersion && minorVersion) {
|
|
19548
19681
|
console.log(
|
|
19549
|
-
`${
|
|
19682
|
+
`${chalk148.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
19550
19683
|
);
|
|
19551
19684
|
} else {
|
|
19552
|
-
console.log(`${
|
|
19685
|
+
console.log(`${chalk148.bold("version:")} v0.1 (initial)`);
|
|
19553
19686
|
}
|
|
19554
19687
|
}
|
|
19555
19688
|
|
|
@@ -19597,16 +19730,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
19597
19730
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
19598
19731
|
}
|
|
19599
19732
|
function logName(repoName) {
|
|
19600
|
-
console.log(`${
|
|
19733
|
+
console.log(`${chalk149.bold("name:")} ${repoName}`);
|
|
19601
19734
|
}
|
|
19602
19735
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
19603
19736
|
logName(ctx.repoName);
|
|
19604
19737
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
19605
|
-
console.log(
|
|
19738
|
+
console.log(chalk149.bold.blue(targetDate));
|
|
19606
19739
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
19607
19740
|
}
|
|
19608
19741
|
function logNoCommits(lastInfo) {
|
|
19609
|
-
console.log(
|
|
19742
|
+
console.log(chalk149.dim(noCommitsMessage(!!lastInfo)));
|
|
19610
19743
|
}
|
|
19611
19744
|
|
|
19612
19745
|
// src/commands/devlog/next/index.ts
|
|
@@ -19647,11 +19780,11 @@ function next2(options2) {
|
|
|
19647
19780
|
import { execSync as execSync38 } from "child_process";
|
|
19648
19781
|
|
|
19649
19782
|
// src/commands/devlog/repos/printReposTable.ts
|
|
19650
|
-
import
|
|
19783
|
+
import chalk150 from "chalk";
|
|
19651
19784
|
function colorStatus(status3) {
|
|
19652
|
-
if (status3 === "missing") return
|
|
19653
|
-
if (status3 === "outdated") return
|
|
19654
|
-
return
|
|
19785
|
+
if (status3 === "missing") return chalk150.red(status3);
|
|
19786
|
+
if (status3 === "outdated") return chalk150.yellow(status3);
|
|
19787
|
+
return chalk150.green(status3);
|
|
19655
19788
|
}
|
|
19656
19789
|
function formatRow(row, nameWidth) {
|
|
19657
19790
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -19665,8 +19798,8 @@ function printReposTable(rows) {
|
|
|
19665
19798
|
"Last Devlog".padEnd(11),
|
|
19666
19799
|
"Status"
|
|
19667
19800
|
].join(" ");
|
|
19668
|
-
console.log(
|
|
19669
|
-
console.log(
|
|
19801
|
+
console.log(chalk150.dim(header));
|
|
19802
|
+
console.log(chalk150.dim("-".repeat(header.length)));
|
|
19670
19803
|
for (const row of rows) {
|
|
19671
19804
|
console.log(formatRow(row, nameWidth));
|
|
19672
19805
|
}
|
|
@@ -19723,15 +19856,15 @@ function repos(options2) {
|
|
|
19723
19856
|
|
|
19724
19857
|
// src/commands/devlog/skip.ts
|
|
19725
19858
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
19726
|
-
import { join as
|
|
19727
|
-
import
|
|
19859
|
+
import { join as join52 } from "path";
|
|
19860
|
+
import chalk151 from "chalk";
|
|
19728
19861
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
19729
19862
|
function getBlogConfigPath() {
|
|
19730
|
-
return
|
|
19863
|
+
return join52(BLOG_REPO_ROOT, "assist.yml");
|
|
19731
19864
|
}
|
|
19732
19865
|
function skip(date) {
|
|
19733
19866
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
19734
|
-
console.log(
|
|
19867
|
+
console.log(chalk151.red("Invalid date format. Use YYYY-MM-DD"));
|
|
19735
19868
|
process.exit(1);
|
|
19736
19869
|
}
|
|
19737
19870
|
const repoName = getRepoName();
|
|
@@ -19742,7 +19875,7 @@ function skip(date) {
|
|
|
19742
19875
|
const skipDays = skip2[repoName] ?? [];
|
|
19743
19876
|
if (skipDays.includes(date)) {
|
|
19744
19877
|
console.log(
|
|
19745
|
-
|
|
19878
|
+
chalk151.yellow(`${date} is already in skip list for ${repoName}`)
|
|
19746
19879
|
);
|
|
19747
19880
|
return;
|
|
19748
19881
|
}
|
|
@@ -19752,20 +19885,20 @@ function skip(date) {
|
|
|
19752
19885
|
devlog.skip = skip2;
|
|
19753
19886
|
config.devlog = devlog;
|
|
19754
19887
|
writeFileSync29(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
19755
|
-
console.log(
|
|
19888
|
+
console.log(chalk151.green(`Added ${date} to skip list for ${repoName}`));
|
|
19756
19889
|
}
|
|
19757
19890
|
|
|
19758
19891
|
// src/commands/devlog/version.ts
|
|
19759
|
-
import
|
|
19892
|
+
import chalk152 from "chalk";
|
|
19760
19893
|
function version() {
|
|
19761
19894
|
const config = loadConfig();
|
|
19762
19895
|
const name = getRepoName();
|
|
19763
19896
|
const lastInfo = getLastVersionInfo(name, config);
|
|
19764
19897
|
const lastVersion = lastInfo?.version ?? null;
|
|
19765
19898
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
19766
|
-
console.log(`${
|
|
19767
|
-
console.log(`${
|
|
19768
|
-
console.log(`${
|
|
19899
|
+
console.log(`${chalk152.bold("name:")} ${name}`);
|
|
19900
|
+
console.log(`${chalk152.bold("last:")} ${lastVersion ?? chalk152.dim("none")}`);
|
|
19901
|
+
console.log(`${chalk152.bold("next:")} ${nextVersion ?? chalk152.dim("none")}`);
|
|
19769
19902
|
}
|
|
19770
19903
|
|
|
19771
19904
|
// src/commands/registerDevlog.ts
|
|
@@ -19789,8 +19922,8 @@ function registerDevlog(program2) {
|
|
|
19789
19922
|
|
|
19790
19923
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
19791
19924
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7 } from "fs";
|
|
19792
|
-
import { join as
|
|
19793
|
-
import
|
|
19925
|
+
import { join as join53 } from "path";
|
|
19926
|
+
import chalk153 from "chalk";
|
|
19794
19927
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
19795
19928
|
function isLockedDll(debugDir) {
|
|
19796
19929
|
let files;
|
|
@@ -19801,7 +19934,7 @@ function isLockedDll(debugDir) {
|
|
|
19801
19934
|
}
|
|
19802
19935
|
for (const file of files) {
|
|
19803
19936
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
19804
|
-
const dllPath =
|
|
19937
|
+
const dllPath = join53(debugDir, file);
|
|
19805
19938
|
try {
|
|
19806
19939
|
const fd = openSync3(dllPath, "r+");
|
|
19807
19940
|
closeSync3(fd);
|
|
@@ -19819,13 +19952,13 @@ function findFirstLockedDll(dir) {
|
|
|
19819
19952
|
return null;
|
|
19820
19953
|
}
|
|
19821
19954
|
if (entries.includes("bin")) {
|
|
19822
|
-
const locked = isLockedDll(
|
|
19955
|
+
const locked = isLockedDll(join53(dir, "bin", "Debug"));
|
|
19823
19956
|
if (locked) return locked;
|
|
19824
19957
|
}
|
|
19825
19958
|
for (const entry of entries) {
|
|
19826
19959
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
19827
19960
|
continue;
|
|
19828
|
-
const found = findFirstLockedDll(
|
|
19961
|
+
const found = findFirstLockedDll(join53(dir, entry));
|
|
19829
19962
|
if (found) return found;
|
|
19830
19963
|
}
|
|
19831
19964
|
return null;
|
|
@@ -19837,14 +19970,14 @@ function checkBuildLocks(startDir) {
|
|
|
19837
19970
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
19838
19971
|
if (locked) {
|
|
19839
19972
|
console.error(
|
|
19840
|
-
|
|
19973
|
+
chalk153.red("Build output locked (is VS debugging?): ") + locked
|
|
19841
19974
|
);
|
|
19842
19975
|
process.exit(1);
|
|
19843
19976
|
}
|
|
19844
19977
|
}
|
|
19845
19978
|
async function checkBuildLocksCommand() {
|
|
19846
19979
|
checkBuildLocks();
|
|
19847
|
-
console.log(
|
|
19980
|
+
console.log(chalk153.green("No build locks detected"));
|
|
19848
19981
|
}
|
|
19849
19982
|
|
|
19850
19983
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -19943,30 +20076,30 @@ function escapeRegex(s) {
|
|
|
19943
20076
|
}
|
|
19944
20077
|
|
|
19945
20078
|
// src/commands/dotnet/printTree.ts
|
|
19946
|
-
import
|
|
20079
|
+
import chalk154 from "chalk";
|
|
19947
20080
|
function printNodes(nodes, prefix2) {
|
|
19948
20081
|
for (let i = 0; i < nodes.length; i++) {
|
|
19949
20082
|
const isLast = i === nodes.length - 1;
|
|
19950
20083
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
19951
20084
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
19952
20085
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
19953
|
-
const label2 = isMissing ?
|
|
20086
|
+
const label2 = isMissing ? chalk154.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
19954
20087
|
console.log(`${prefix2}${connector}${label2}`);
|
|
19955
20088
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
19956
20089
|
}
|
|
19957
20090
|
}
|
|
19958
20091
|
function printTree(tree, totalCount, solutions) {
|
|
19959
|
-
console.log(
|
|
19960
|
-
console.log(
|
|
20092
|
+
console.log(chalk154.bold("\nProject Dependency Tree"));
|
|
20093
|
+
console.log(chalk154.cyan(tree.relativePath));
|
|
19961
20094
|
printNodes(tree.children, "");
|
|
19962
|
-
console.log(
|
|
20095
|
+
console.log(chalk154.dim(`
|
|
19963
20096
|
${totalCount} projects total (including root)`));
|
|
19964
|
-
console.log(
|
|
20097
|
+
console.log(chalk154.bold("\nSolution Membership"));
|
|
19965
20098
|
if (solutions.length === 0) {
|
|
19966
|
-
console.log(
|
|
20099
|
+
console.log(chalk154.yellow(" Not found in any .sln"));
|
|
19967
20100
|
} else {
|
|
19968
20101
|
for (const sln of solutions) {
|
|
19969
|
-
console.log(` ${
|
|
20102
|
+
console.log(` ${chalk154.green(sln)}`);
|
|
19970
20103
|
}
|
|
19971
20104
|
}
|
|
19972
20105
|
console.log();
|
|
@@ -19993,18 +20126,18 @@ function printJson(tree, totalCount, solutions) {
|
|
|
19993
20126
|
}
|
|
19994
20127
|
|
|
19995
20128
|
// src/commands/dotnet/resolveCsproj.ts
|
|
19996
|
-
import { existsSync as
|
|
20129
|
+
import { existsSync as existsSync49 } from "fs";
|
|
19997
20130
|
import path42 from "path";
|
|
19998
|
-
import
|
|
20131
|
+
import chalk155 from "chalk";
|
|
19999
20132
|
function resolveCsproj(csprojPath) {
|
|
20000
20133
|
const resolved = path42.resolve(csprojPath);
|
|
20001
|
-
if (!
|
|
20002
|
-
console.error(
|
|
20134
|
+
if (!existsSync49(resolved)) {
|
|
20135
|
+
console.error(chalk155.red(`File not found: ${resolved}`));
|
|
20003
20136
|
process.exit(1);
|
|
20004
20137
|
}
|
|
20005
20138
|
const repoRoot2 = findRepoRoot(path42.dirname(resolved));
|
|
20006
20139
|
if (!repoRoot2) {
|
|
20007
|
-
console.error(
|
|
20140
|
+
console.error(chalk155.red("Could not find git repository root"));
|
|
20008
20141
|
process.exit(1);
|
|
20009
20142
|
}
|
|
20010
20143
|
return { resolved, repoRoot: repoRoot2 };
|
|
@@ -20054,12 +20187,12 @@ function getChangedCsFiles(scope) {
|
|
|
20054
20187
|
}
|
|
20055
20188
|
|
|
20056
20189
|
// src/commands/dotnet/inSln.ts
|
|
20057
|
-
import
|
|
20190
|
+
import chalk156 from "chalk";
|
|
20058
20191
|
async function inSln(csprojPath) {
|
|
20059
20192
|
const { resolved, repoRoot: repoRoot2 } = resolveCsproj(csprojPath);
|
|
20060
20193
|
const solutions = findContainingSolutions(resolved, repoRoot2);
|
|
20061
20194
|
if (solutions.length === 0) {
|
|
20062
|
-
console.log(
|
|
20195
|
+
console.log(chalk156.yellow("Not found in any .sln file"));
|
|
20063
20196
|
process.exit(1);
|
|
20064
20197
|
}
|
|
20065
20198
|
for (const sln of solutions) {
|
|
@@ -20068,7 +20201,7 @@ async function inSln(csprojPath) {
|
|
|
20068
20201
|
}
|
|
20069
20202
|
|
|
20070
20203
|
// src/commands/dotnet/inspect.ts
|
|
20071
|
-
import
|
|
20204
|
+
import chalk162 from "chalk";
|
|
20072
20205
|
|
|
20073
20206
|
// src/shared/formatElapsed.ts
|
|
20074
20207
|
function formatElapsed(ms) {
|
|
@@ -20080,12 +20213,12 @@ function formatElapsed(ms) {
|
|
|
20080
20213
|
}
|
|
20081
20214
|
|
|
20082
20215
|
// src/commands/dotnet/displayIssues.ts
|
|
20083
|
-
import
|
|
20216
|
+
import chalk157 from "chalk";
|
|
20084
20217
|
var SEVERITY_COLOR = {
|
|
20085
|
-
ERROR:
|
|
20086
|
-
WARNING:
|
|
20087
|
-
SUGGESTION:
|
|
20088
|
-
HINT:
|
|
20218
|
+
ERROR: chalk157.red,
|
|
20219
|
+
WARNING: chalk157.yellow,
|
|
20220
|
+
SUGGESTION: chalk157.cyan,
|
|
20221
|
+
HINT: chalk157.dim
|
|
20089
20222
|
};
|
|
20090
20223
|
function groupByFile(issues) {
|
|
20091
20224
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -20101,15 +20234,15 @@ function groupByFile(issues) {
|
|
|
20101
20234
|
}
|
|
20102
20235
|
function displayIssues(issues) {
|
|
20103
20236
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
20104
|
-
console.log(
|
|
20237
|
+
console.log(chalk157.bold(file));
|
|
20105
20238
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
20106
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
20239
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk157.white;
|
|
20107
20240
|
console.log(
|
|
20108
|
-
` ${
|
|
20241
|
+
` ${chalk157.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
20109
20242
|
);
|
|
20110
20243
|
}
|
|
20111
20244
|
}
|
|
20112
|
-
console.log(
|
|
20245
|
+
console.log(chalk157.dim(`
|
|
20113
20246
|
${issues.length} issue(s) found`));
|
|
20114
20247
|
}
|
|
20115
20248
|
|
|
@@ -20166,17 +20299,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
20166
20299
|
}
|
|
20167
20300
|
|
|
20168
20301
|
// src/commands/dotnet/resolveSolution.ts
|
|
20169
|
-
import { existsSync as
|
|
20302
|
+
import { existsSync as existsSync50 } from "fs";
|
|
20170
20303
|
import path43 from "path";
|
|
20171
|
-
import
|
|
20304
|
+
import chalk159 from "chalk";
|
|
20172
20305
|
|
|
20173
20306
|
// src/commands/dotnet/findSolution.ts
|
|
20174
20307
|
import { readdirSync as readdirSync9 } from "fs";
|
|
20175
|
-
import { dirname as dirname25, join as
|
|
20176
|
-
import
|
|
20308
|
+
import { dirname as dirname25, join as join54 } from "path";
|
|
20309
|
+
import chalk158 from "chalk";
|
|
20177
20310
|
function findSlnInDir(dir) {
|
|
20178
20311
|
try {
|
|
20179
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
20312
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".sln")).map((f) => join54(dir, f));
|
|
20180
20313
|
} catch {
|
|
20181
20314
|
return [];
|
|
20182
20315
|
}
|
|
@@ -20189,17 +20322,17 @@ function findSolution() {
|
|
|
20189
20322
|
const slnFiles = findSlnInDir(current);
|
|
20190
20323
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
20191
20324
|
if (slnFiles.length > 1) {
|
|
20192
|
-
console.error(
|
|
20325
|
+
console.error(chalk158.red(`Multiple .sln files found in ${current}:`));
|
|
20193
20326
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
20194
20327
|
console.error(
|
|
20195
|
-
|
|
20328
|
+
chalk158.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
20196
20329
|
);
|
|
20197
20330
|
process.exit(1);
|
|
20198
20331
|
}
|
|
20199
20332
|
if (current === ceiling) break;
|
|
20200
20333
|
current = dirname25(current);
|
|
20201
20334
|
}
|
|
20202
|
-
console.error(
|
|
20335
|
+
console.error(chalk158.red("No .sln file found between cwd and repo root"));
|
|
20203
20336
|
process.exit(1);
|
|
20204
20337
|
}
|
|
20205
20338
|
|
|
@@ -20207,8 +20340,8 @@ function findSolution() {
|
|
|
20207
20340
|
function resolveSolution(sln) {
|
|
20208
20341
|
if (sln) {
|
|
20209
20342
|
const resolved = path43.resolve(sln);
|
|
20210
|
-
if (!
|
|
20211
|
-
console.error(
|
|
20343
|
+
if (!existsSync50(resolved)) {
|
|
20344
|
+
console.error(chalk159.red(`Solution file not found: ${resolved}`));
|
|
20212
20345
|
process.exit(1);
|
|
20213
20346
|
}
|
|
20214
20347
|
return resolved;
|
|
@@ -20247,23 +20380,23 @@ function parseInspectReport(json) {
|
|
|
20247
20380
|
|
|
20248
20381
|
// src/commands/dotnet/runInspectCode.ts
|
|
20249
20382
|
import { execSync as execSync40 } from "child_process";
|
|
20250
|
-
import { existsSync as
|
|
20251
|
-
import { tmpdir as
|
|
20383
|
+
import { existsSync as existsSync51, readFileSync as readFileSync37, unlinkSync as unlinkSync10 } from "fs";
|
|
20384
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
20252
20385
|
import path44 from "path";
|
|
20253
|
-
import
|
|
20386
|
+
import chalk160 from "chalk";
|
|
20254
20387
|
function assertJbInstalled() {
|
|
20255
20388
|
try {
|
|
20256
20389
|
execSync40("jb inspectcode --version", { stdio: "pipe" });
|
|
20257
20390
|
} catch {
|
|
20258
|
-
console.error(
|
|
20391
|
+
console.error(chalk160.red("jb is not installed. Install with:"));
|
|
20259
20392
|
console.error(
|
|
20260
|
-
|
|
20393
|
+
chalk160.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
20261
20394
|
);
|
|
20262
20395
|
process.exit(1);
|
|
20263
20396
|
}
|
|
20264
20397
|
}
|
|
20265
20398
|
function runInspectCode(slnPath, include, swea) {
|
|
20266
|
-
const reportPath = path44.join(
|
|
20399
|
+
const reportPath = path44.join(tmpdir5(), `inspect-${Date.now()}.xml`);
|
|
20267
20400
|
const includeFlag = include ? ` --include="${include}"` : "";
|
|
20268
20401
|
const sweaFlag = swea ? " --swea" : "";
|
|
20269
20402
|
try {
|
|
@@ -20275,11 +20408,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
20275
20408
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
20276
20409
|
process.stderr.write(error.stderr);
|
|
20277
20410
|
}
|
|
20278
|
-
console.error(
|
|
20411
|
+
console.error(chalk160.red("jb inspectcode failed"));
|
|
20279
20412
|
process.exit(1);
|
|
20280
20413
|
}
|
|
20281
|
-
if (!
|
|
20282
|
-
console.error(
|
|
20414
|
+
if (!existsSync51(reportPath)) {
|
|
20415
|
+
console.error(chalk160.red("Report file not generated"));
|
|
20283
20416
|
process.exit(1);
|
|
20284
20417
|
}
|
|
20285
20418
|
const xml = readFileSync37(reportPath, "utf8");
|
|
@@ -20289,7 +20422,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
20289
20422
|
|
|
20290
20423
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
20291
20424
|
import { execSync as execSync41 } from "child_process";
|
|
20292
|
-
import
|
|
20425
|
+
import chalk161 from "chalk";
|
|
20293
20426
|
function resolveMsbuildPath() {
|
|
20294
20427
|
const { run: run4 } = loadConfig();
|
|
20295
20428
|
const configs = resolveRunConfigs(run4, runConfigBaseDir());
|
|
@@ -20301,9 +20434,9 @@ function assertMsbuildInstalled() {
|
|
|
20301
20434
|
try {
|
|
20302
20435
|
execSync41(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
20303
20436
|
} catch {
|
|
20304
|
-
console.error(
|
|
20437
|
+
console.error(chalk161.red(`msbuild not found at: ${msbuild}`));
|
|
20305
20438
|
console.error(
|
|
20306
|
-
|
|
20439
|
+
chalk161.yellow(
|
|
20307
20440
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
20308
20441
|
)
|
|
20309
20442
|
);
|
|
@@ -20350,17 +20483,17 @@ function runEngine(resolved, changedFiles2, options2) {
|
|
|
20350
20483
|
// src/commands/dotnet/inspect.ts
|
|
20351
20484
|
function logScope(changedFiles2) {
|
|
20352
20485
|
if (changedFiles2 === null) {
|
|
20353
|
-
console.log(
|
|
20486
|
+
console.log(chalk162.dim("Inspecting full solution..."));
|
|
20354
20487
|
} else {
|
|
20355
20488
|
console.log(
|
|
20356
|
-
|
|
20489
|
+
chalk162.dim(`Inspecting ${changedFiles2.length} changed file(s)...`)
|
|
20357
20490
|
);
|
|
20358
20491
|
}
|
|
20359
20492
|
}
|
|
20360
20493
|
function reportResults(issues, elapsed) {
|
|
20361
20494
|
if (issues.length > 0) displayIssues(issues);
|
|
20362
|
-
else console.log(
|
|
20363
|
-
console.log(
|
|
20495
|
+
else console.log(chalk162.green("No issues found"));
|
|
20496
|
+
console.log(chalk162.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
20364
20497
|
if (issues.length > 0) process.exit(1);
|
|
20365
20498
|
}
|
|
20366
20499
|
async function inspect(sln, options2) {
|
|
@@ -20371,7 +20504,7 @@ async function inspect(sln, options2) {
|
|
|
20371
20504
|
const scope = parseScope(options2.scope);
|
|
20372
20505
|
const changedFiles2 = getChangedCsFiles(scope);
|
|
20373
20506
|
if (changedFiles2 !== null && changedFiles2.length === 0) {
|
|
20374
|
-
console.log(
|
|
20507
|
+
console.log(chalk162.green("No changed .cs files found"));
|
|
20375
20508
|
return;
|
|
20376
20509
|
}
|
|
20377
20510
|
logScope(changedFiles2);
|
|
@@ -20567,11 +20700,11 @@ function decideCommentGuard(input, existingContent) {
|
|
|
20567
20700
|
}
|
|
20568
20701
|
|
|
20569
20702
|
// src/commands/dbMigration/consumeMigrationApproval.ts
|
|
20570
|
-
import { existsSync as
|
|
20703
|
+
import { existsSync as existsSync52, unlinkSync as unlinkSync11 } from "fs";
|
|
20571
20704
|
function consumeMigrationApproval(migrationId) {
|
|
20572
20705
|
sweepRestrictedDir();
|
|
20573
20706
|
const path84 = getMigrationApprovalPath(migrationId);
|
|
20574
|
-
if (!
|
|
20707
|
+
if (!existsSync52(path84)) return false;
|
|
20575
20708
|
try {
|
|
20576
20709
|
unlinkSync11(path84);
|
|
20577
20710
|
return true;
|
|
@@ -20690,8 +20823,8 @@ function aggregateCommitters(authorLists) {
|
|
|
20690
20823
|
// src/shared/runGhGraphql.ts
|
|
20691
20824
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
20692
20825
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
20693
|
-
import { tmpdir as
|
|
20694
|
-
import { join as
|
|
20826
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
20827
|
+
import { join as join55 } from "path";
|
|
20695
20828
|
|
|
20696
20829
|
// src/shared/throwOnGraphqlErrors.ts
|
|
20697
20830
|
function throwOnGraphqlErrors(stdout) {
|
|
@@ -20720,7 +20853,7 @@ function buildArgs2(queryFile, vars) {
|
|
|
20720
20853
|
return args;
|
|
20721
20854
|
}
|
|
20722
20855
|
function runGhGraphql(mutation, vars) {
|
|
20723
|
-
const queryFile =
|
|
20856
|
+
const queryFile = join55(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
20724
20857
|
writeFileSync30(queryFile, mutation);
|
|
20725
20858
|
try {
|
|
20726
20859
|
const result = spawnSync4("gh", buildArgs2(queryFile, vars), {
|
|
@@ -20785,25 +20918,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
20785
20918
|
}
|
|
20786
20919
|
|
|
20787
20920
|
// src/commands/github/printCountTable.ts
|
|
20788
|
-
import
|
|
20921
|
+
import chalk163 from "chalk";
|
|
20789
20922
|
function printCountTable(labelHeader, rows) {
|
|
20790
20923
|
const labelWidth = Math.max(
|
|
20791
20924
|
labelHeader.length,
|
|
20792
20925
|
...rows.map((row) => row.label.length)
|
|
20793
20926
|
);
|
|
20794
20927
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
20795
|
-
console.log(
|
|
20796
|
-
console.log(
|
|
20928
|
+
console.log(chalk163.dim(header));
|
|
20929
|
+
console.log(chalk163.dim("-".repeat(header.length)));
|
|
20797
20930
|
for (const row of rows) {
|
|
20798
20931
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
20799
20932
|
}
|
|
20800
20933
|
}
|
|
20801
20934
|
|
|
20802
20935
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
20803
|
-
import
|
|
20936
|
+
import chalk164 from "chalk";
|
|
20804
20937
|
function printRepoAuthorBreakdown(repos2) {
|
|
20805
20938
|
for (const repo of repos2) {
|
|
20806
|
-
console.log(
|
|
20939
|
+
console.log(chalk164.bold(repo.name));
|
|
20807
20940
|
const authorWidth = Math.max(
|
|
20808
20941
|
0,
|
|
20809
20942
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -20886,10 +21019,10 @@ function parseTopCount(value) {
|
|
|
20886
21019
|
}
|
|
20887
21020
|
|
|
20888
21021
|
// src/commands/github/issue/fixStructure/applyAndVerifySubtree.ts
|
|
20889
|
-
import
|
|
21022
|
+
import chalk166 from "chalk";
|
|
20890
21023
|
|
|
20891
21024
|
// src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
|
|
20892
|
-
import
|
|
21025
|
+
import chalk165 from "chalk";
|
|
20893
21026
|
|
|
20894
21027
|
// src/shared/runGhGraphqlJson.ts
|
|
20895
21028
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
@@ -20940,7 +21073,7 @@ function writeLineNow(line) {
|
|
|
20940
21073
|
// src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
|
|
20941
21074
|
function applyFixStructurePlan(plan2) {
|
|
20942
21075
|
for (const entry of plan2.entries) {
|
|
20943
|
-
const where =
|
|
21076
|
+
const where = chalk165.cyan(`${entry.issue.repo}#${entry.issue.number}`);
|
|
20944
21077
|
const { typeChange, labelRemovals } = entry;
|
|
20945
21078
|
if (typeChange) {
|
|
20946
21079
|
writeLineNow(
|
|
@@ -21210,12 +21343,12 @@ function planSubtree(root, context) {
|
|
|
21210
21343
|
function applyAndVerifySubtree(target, plan2, context) {
|
|
21211
21344
|
if (plan2.typeChangeCount === 0 && plan2.labelRemovalCount === 0) return;
|
|
21212
21345
|
applyFixStructurePlan(plan2);
|
|
21213
|
-
writeLineNow(
|
|
21346
|
+
writeLineNow(chalk166.dim("Re-walking the subtree to confirm"));
|
|
21214
21347
|
assertNoResidualDrift(
|
|
21215
21348
|
planSubtree(fetchRootIssue(target), context),
|
|
21216
21349
|
context.chain
|
|
21217
21350
|
);
|
|
21218
|
-
writeLineNow(
|
|
21351
|
+
writeLineNow(chalk166.green("Subtree normalised"));
|
|
21219
21352
|
}
|
|
21220
21353
|
|
|
21221
21354
|
// src/commands/github/issue/fixStructure/assertChainTypesExist.ts
|
|
@@ -21251,22 +21384,22 @@ function parseTypeChain(value) {
|
|
|
21251
21384
|
}
|
|
21252
21385
|
|
|
21253
21386
|
// src/commands/github/issue/fixStructure/printFixStructurePlan.ts
|
|
21254
|
-
import
|
|
21387
|
+
import chalk167 from "chalk";
|
|
21255
21388
|
function annotate(entry) {
|
|
21256
21389
|
const notes = [];
|
|
21257
21390
|
if (entry.level === null) {
|
|
21258
|
-
notes.push(
|
|
21391
|
+
notes.push(chalk167.red("deeper than the leaf level"));
|
|
21259
21392
|
} else if (entry.typeChange) {
|
|
21260
21393
|
notes.push(
|
|
21261
|
-
|
|
21394
|
+
chalk167.yellow(
|
|
21262
21395
|
`${entry.typeChange.from ?? "no type"} -> ${entry.typeChange.to}`
|
|
21263
21396
|
)
|
|
21264
21397
|
);
|
|
21265
21398
|
} else {
|
|
21266
|
-
notes.push(
|
|
21399
|
+
notes.push(chalk167.dim(entry.issue.typeName ?? "no type"));
|
|
21267
21400
|
}
|
|
21268
21401
|
for (const label2 of entry.labelRemovals) {
|
|
21269
|
-
notes.push(
|
|
21402
|
+
notes.push(chalk167.yellow(`-${label2.name}`));
|
|
21270
21403
|
}
|
|
21271
21404
|
return notes;
|
|
21272
21405
|
}
|
|
@@ -21274,22 +21407,22 @@ function formatCount(count8, noun) {
|
|
|
21274
21407
|
return `${count8} ${noun}${count8 === 1 ? "" : "s"}`;
|
|
21275
21408
|
}
|
|
21276
21409
|
function printFixStructurePlan(plan2, chain2, apply) {
|
|
21277
|
-
writeLineNow(
|
|
21410
|
+
writeLineNow(chalk167.dim(`chain: ${chain2.join(" > ")}`));
|
|
21278
21411
|
for (const entry of plan2.entries) {
|
|
21279
21412
|
const indent3 = " ".repeat(entry.issue.depth);
|
|
21280
|
-
const name =
|
|
21413
|
+
const name = chalk167.cyan(`${entry.issue.repo}#${entry.issue.number}`);
|
|
21281
21414
|
writeLineNow(
|
|
21282
21415
|
`${indent3}${name} ${entry.issue.title} [${annotate(entry).join(", ")}]`
|
|
21283
21416
|
);
|
|
21284
21417
|
}
|
|
21285
21418
|
if (plan2.typeChangeCount === 0 && plan2.labelRemovalCount === 0) {
|
|
21286
|
-
writeLineNow(
|
|
21419
|
+
writeLineNow(chalk167.green("Nothing to change"));
|
|
21287
21420
|
return;
|
|
21288
21421
|
}
|
|
21289
21422
|
writeLineNow(
|
|
21290
21423
|
`${formatCount(plan2.typeChangeCount, "type change")}, ${formatCount(plan2.labelRemovalCount, "label removal")} planned`
|
|
21291
21424
|
);
|
|
21292
|
-
if (!apply) writeLineNow(
|
|
21425
|
+
if (!apply) writeLineNow(chalk167.dim("Dry run \u2014 nothing written"));
|
|
21293
21426
|
}
|
|
21294
21427
|
|
|
21295
21428
|
// src/commands/github/issue/fixStructure/resolveFixStructureTarget.ts
|
|
@@ -21627,24 +21760,24 @@ function fetchIssue2(number, repo) {
|
|
|
21627
21760
|
}
|
|
21628
21761
|
|
|
21629
21762
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
21630
|
-
import { existsSync as
|
|
21763
|
+
import { existsSync as existsSync53, readFileSync as readFileSync38 } from "fs";
|
|
21631
21764
|
|
|
21632
21765
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
21633
|
-
import { join as
|
|
21766
|
+
import { join as join56 } from "path";
|
|
21634
21767
|
function issueWorkingFile(slug, number) {
|
|
21635
21768
|
const [owner = "unknown", repo = "unknown"] = slug.split("/");
|
|
21636
|
-
const dir =
|
|
21769
|
+
const dir = join56(getStoreDir(), "github-issues", owner, repo);
|
|
21637
21770
|
return {
|
|
21638
21771
|
dir,
|
|
21639
|
-
bodyPath:
|
|
21640
|
-
metaPath:
|
|
21772
|
+
bodyPath: join56(dir, `${number}.md`),
|
|
21773
|
+
metaPath: join56(dir, `${number}.json`)
|
|
21641
21774
|
};
|
|
21642
21775
|
}
|
|
21643
21776
|
|
|
21644
21777
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
21645
21778
|
function resumeIssueBody(slug, number, updatedAt) {
|
|
21646
21779
|
const { bodyPath, metaPath } = issueWorkingFile(slug, number);
|
|
21647
|
-
if (!
|
|
21780
|
+
if (!existsSync53(bodyPath) || !existsSync53(metaPath)) return void 0;
|
|
21648
21781
|
try {
|
|
21649
21782
|
const meta = JSON.parse(readFileSync38(metaPath, "utf8"));
|
|
21650
21783
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
@@ -21837,24 +21970,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
21837
21970
|
|
|
21838
21971
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
21839
21972
|
import {
|
|
21840
|
-
existsSync as
|
|
21973
|
+
existsSync as existsSync54,
|
|
21841
21974
|
readdirSync as readdirSync10,
|
|
21842
21975
|
readFileSync as readFileSync39,
|
|
21843
21976
|
rmSync as rmSync3,
|
|
21844
21977
|
statSync as statSync9
|
|
21845
21978
|
} from "fs";
|
|
21846
|
-
import { basename as basename14, join as
|
|
21979
|
+
import { basename as basename14, join as join59 } from "path";
|
|
21847
21980
|
|
|
21848
21981
|
// src/commands/handover/getHandoverPath.ts
|
|
21849
|
-
import { join as
|
|
21982
|
+
import { join as join57 } from "path";
|
|
21850
21983
|
function getHandoverPath(cwd = process.cwd()) {
|
|
21851
|
-
return
|
|
21984
|
+
return join57(cwd, ".assist", "HANDOVER.md");
|
|
21852
21985
|
}
|
|
21853
21986
|
|
|
21854
21987
|
// src/commands/handover/getHandoversDir.ts
|
|
21855
|
-
import { join as
|
|
21988
|
+
import { join as join58 } from "path";
|
|
21856
21989
|
function getHandoversDir(cwd = process.cwd()) {
|
|
21857
|
-
return
|
|
21990
|
+
return join58(cwd, ".assist", "handovers");
|
|
21858
21991
|
}
|
|
21859
21992
|
|
|
21860
21993
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -21892,10 +22025,10 @@ function summariseHandoverContent(content) {
|
|
|
21892
22025
|
|
|
21893
22026
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
21894
22027
|
function collectMarkdown(dir) {
|
|
21895
|
-
if (!
|
|
22028
|
+
if (!existsSync54(dir)) return [];
|
|
21896
22029
|
const out = [];
|
|
21897
22030
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
21898
|
-
const full =
|
|
22031
|
+
const full = join59(dir, entry.name);
|
|
21899
22032
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
21900
22033
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
21901
22034
|
}
|
|
@@ -21919,7 +22052,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
21919
22052
|
migrated++;
|
|
21920
22053
|
}
|
|
21921
22054
|
const handoverPath = getHandoverPath(cwd);
|
|
21922
|
-
if (
|
|
22055
|
+
if (existsSync54(handoverPath)) {
|
|
21923
22056
|
await migrateFile(orm, origin, handoverPath, statSync9(handoverPath).mtime);
|
|
21924
22057
|
migrated++;
|
|
21925
22058
|
}
|
|
@@ -22050,7 +22183,7 @@ function registerHandover(program2) {
|
|
|
22050
22183
|
}
|
|
22051
22184
|
|
|
22052
22185
|
// src/commands/jira/acceptanceCriteria.ts
|
|
22053
|
-
import
|
|
22186
|
+
import chalk168 from "chalk";
|
|
22054
22187
|
|
|
22055
22188
|
// src/commands/jira/adfToText.ts
|
|
22056
22189
|
function renderInline(node) {
|
|
@@ -22117,7 +22250,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
22117
22250
|
const parsed = fetchIssue(issueKey, field);
|
|
22118
22251
|
const acValue = parsed?.fields?.[field];
|
|
22119
22252
|
if (!acValue) {
|
|
22120
|
-
console.log(
|
|
22253
|
+
console.log(chalk168.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
22121
22254
|
return;
|
|
22122
22255
|
}
|
|
22123
22256
|
if (typeof acValue === "string") {
|
|
@@ -22183,14 +22316,14 @@ async function jiraAuth() {
|
|
|
22183
22316
|
}
|
|
22184
22317
|
|
|
22185
22318
|
// src/commands/jira/viewIssue.ts
|
|
22186
|
-
import
|
|
22319
|
+
import chalk169 from "chalk";
|
|
22187
22320
|
function viewIssue2(issueKey) {
|
|
22188
22321
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
22189
22322
|
const fields = parsed?.fields;
|
|
22190
22323
|
const summary = fields?.summary;
|
|
22191
22324
|
const description = fields?.description;
|
|
22192
22325
|
if (summary) {
|
|
22193
|
-
console.log(
|
|
22326
|
+
console.log(chalk169.bold(summary));
|
|
22194
22327
|
}
|
|
22195
22328
|
if (description) {
|
|
22196
22329
|
if (summary) console.log();
|
|
@@ -22204,7 +22337,7 @@ function viewIssue2(issueKey) {
|
|
|
22204
22337
|
}
|
|
22205
22338
|
if (!summary && !description) {
|
|
22206
22339
|
console.log(
|
|
22207
|
-
|
|
22340
|
+
chalk169.yellow(`No summary or description found on ${issueKey}.`)
|
|
22208
22341
|
);
|
|
22209
22342
|
}
|
|
22210
22343
|
}
|
|
@@ -22239,7 +22372,7 @@ import { randomUUID as randomUUID10 } from "crypto";
|
|
|
22239
22372
|
|
|
22240
22373
|
// src/commands/review/checkoutPr.ts
|
|
22241
22374
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
22242
|
-
import
|
|
22375
|
+
import chalk170 from "chalk";
|
|
22243
22376
|
|
|
22244
22377
|
// src/commands/sessions/daemon/daemonLog.ts
|
|
22245
22378
|
var RING_CAPACITY = 1e3;
|
|
@@ -22276,18 +22409,18 @@ function canonicalTreePath(path84) {
|
|
|
22276
22409
|
}
|
|
22277
22410
|
|
|
22278
22411
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
22279
|
-
import { existsSync as
|
|
22412
|
+
import { existsSync as existsSync55 } from "fs";
|
|
22280
22413
|
import { basename as basename16, dirname as dirname26 } from "path";
|
|
22281
22414
|
|
|
22282
22415
|
// src/commands/sessions/daemon/worktree/planAllocation.ts
|
|
22283
|
-
import { basename as basename15, join as
|
|
22416
|
+
import { basename as basename15, join as join60 } from "path";
|
|
22284
22417
|
function planAllocation(clone, boundTreeRoots2) {
|
|
22285
22418
|
return boundTreeRoots2.has(clone) ? "spill" : "primary";
|
|
22286
22419
|
}
|
|
22287
22420
|
function nextWorktreePath(clone, base, isTaken) {
|
|
22288
22421
|
const name = basename15(clone);
|
|
22289
22422
|
for (let n = 2; n < 1e3; n++) {
|
|
22290
|
-
const candidate =
|
|
22423
|
+
const candidate = join60(base, `${name}-${n}`);
|
|
22291
22424
|
if (!isTaken(candidate)) return candidate;
|
|
22292
22425
|
}
|
|
22293
22426
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -22323,7 +22456,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
22323
22456
|
const base = strategy.root ? expandTilde2(strategy.root) : dirname26(clone);
|
|
22324
22457
|
const registered = new Set(listWorktreePaths(clone));
|
|
22325
22458
|
const branches = new Set(listLocalBranches(clone));
|
|
22326
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
22459
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync55(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename16(candidate));
|
|
22327
22460
|
const path84 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
22328
22461
|
const start3 = worktreeStartPoint(clone, strategy.trunk);
|
|
22329
22462
|
gitSync(clone, [
|
|
@@ -22349,7 +22482,7 @@ function keptInTree(cwd, reason4) {
|
|
|
22349
22482
|
}
|
|
22350
22483
|
|
|
22351
22484
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
22352
|
-
import { existsSync as
|
|
22485
|
+
import { existsSync as existsSync56 } from "fs";
|
|
22353
22486
|
var treeIsGone = { durable: true, gone: true };
|
|
22354
22487
|
function treeDurability(state) {
|
|
22355
22488
|
if (state.dirty) return { durable: false, reason: "uncommitted changes" };
|
|
@@ -22380,14 +22513,14 @@ function* durabilityProbes() {
|
|
|
22380
22513
|
});
|
|
22381
22514
|
}
|
|
22382
22515
|
async function checkDurability(cwd) {
|
|
22383
|
-
if (!
|
|
22516
|
+
if (!existsSync56(cwd)) return treeIsGone;
|
|
22384
22517
|
const probes = durabilityProbes();
|
|
22385
22518
|
let step2 = probes.next();
|
|
22386
22519
|
while (!step2.done) step2 = probes.next(await gitResult(cwd, step2.value));
|
|
22387
22520
|
return step2.value;
|
|
22388
22521
|
}
|
|
22389
22522
|
function checkDurabilitySync(cwd) {
|
|
22390
|
-
if (!
|
|
22523
|
+
if (!existsSync56(cwd)) return treeIsGone;
|
|
22391
22524
|
const probes = durabilityProbes();
|
|
22392
22525
|
let step2 = probes.next();
|
|
22393
22526
|
while (!step2.done) step2 = probes.next(gitSyncResult(cwd, step2.value));
|
|
@@ -22630,20 +22763,20 @@ function persistedTreeRoots() {
|
|
|
22630
22763
|
}
|
|
22631
22764
|
|
|
22632
22765
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
22633
|
-
import { copyFileSync, existsSync as
|
|
22634
|
-
import { dirname as dirname27, join as
|
|
22766
|
+
import { copyFileSync, existsSync as existsSync58, mkdirSync as mkdirSync17 } from "fs";
|
|
22767
|
+
import { dirname as dirname27, join as join62 } from "path";
|
|
22635
22768
|
|
|
22636
22769
|
// src/commands/sessions/daemon/worktree/runInstall.ts
|
|
22637
22770
|
import { spawn as spawn5 } from "child_process";
|
|
22638
22771
|
|
|
22639
22772
|
// src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
|
|
22640
|
-
import { existsSync as
|
|
22641
|
-
import { join as
|
|
22773
|
+
import { existsSync as existsSync57 } from "fs";
|
|
22774
|
+
import { join as join61 } from "path";
|
|
22642
22775
|
function detectInstallCommand(repoRoot2) {
|
|
22643
|
-
if (!
|
|
22644
|
-
if (
|
|
22645
|
-
if (
|
|
22646
|
-
if (
|
|
22776
|
+
if (!existsSync57(join61(repoRoot2, "package.json"))) return null;
|
|
22777
|
+
if (existsSync57(join61(repoRoot2, "pnpm-lock.yaml"))) return "pnpm install";
|
|
22778
|
+
if (existsSync57(join61(repoRoot2, "yarn.lock"))) return "yarn install";
|
|
22779
|
+
if (existsSync57(join61(repoRoot2, "bun.lockb"))) return "bun install";
|
|
22647
22780
|
return "npm install";
|
|
22648
22781
|
}
|
|
22649
22782
|
function resolveInstallCommand(repoRoot2, install) {
|
|
@@ -22755,9 +22888,9 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
22755
22888
|
}
|
|
22756
22889
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
22757
22890
|
for (const rel of copy) {
|
|
22758
|
-
const src =
|
|
22759
|
-
if (!
|
|
22760
|
-
const dest =
|
|
22891
|
+
const src = join62(clone, rel);
|
|
22892
|
+
if (!existsSync58(src)) continue;
|
|
22893
|
+
const dest = join62(worktreePath, rel);
|
|
22761
22894
|
try {
|
|
22762
22895
|
mkdirSync17(dirname27(dest), { recursive: true });
|
|
22763
22896
|
copyFileSync(src, dest);
|
|
@@ -22851,7 +22984,7 @@ async function checkoutPr(number) {
|
|
|
22851
22984
|
try {
|
|
22852
22985
|
execFileSync12("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
22853
22986
|
} catch {
|
|
22854
|
-
console.error(
|
|
22987
|
+
console.error(chalk170.red(`gh pr checkout ${number} failed; aborting.`));
|
|
22855
22988
|
process.exit(1);
|
|
22856
22989
|
}
|
|
22857
22990
|
}
|
|
@@ -22988,15 +23121,15 @@ function registerList(program2) {
|
|
|
22988
23121
|
// src/commands/mermaid/index.ts
|
|
22989
23122
|
import { mkdirSync as mkdirSync18, readdirSync as readdirSync11 } from "fs";
|
|
22990
23123
|
import { resolve as resolve16 } from "path";
|
|
22991
|
-
import
|
|
23124
|
+
import chalk173 from "chalk";
|
|
22992
23125
|
|
|
22993
23126
|
// src/commands/mermaid/exportFile.ts
|
|
22994
23127
|
import { readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
|
|
22995
23128
|
import { basename as basename17, extname as extname2, resolve as resolve15 } from "path";
|
|
22996
|
-
import
|
|
23129
|
+
import chalk172 from "chalk";
|
|
22997
23130
|
|
|
22998
23131
|
// src/commands/mermaid/renderBlock.ts
|
|
22999
|
-
import
|
|
23132
|
+
import chalk171 from "chalk";
|
|
23000
23133
|
async function renderBlock(krokiUrl, source) {
|
|
23001
23134
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
23002
23135
|
method: "POST",
|
|
@@ -23005,7 +23138,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
23005
23138
|
});
|
|
23006
23139
|
if (!response.ok) {
|
|
23007
23140
|
console.error(
|
|
23008
|
-
|
|
23141
|
+
chalk171.red(
|
|
23009
23142
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
23010
23143
|
)
|
|
23011
23144
|
);
|
|
@@ -23023,19 +23156,19 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
23023
23156
|
if (onlyIndex !== void 0) {
|
|
23024
23157
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
23025
23158
|
console.error(
|
|
23026
|
-
|
|
23159
|
+
chalk172.red(
|
|
23027
23160
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
23028
23161
|
)
|
|
23029
23162
|
);
|
|
23030
23163
|
process.exit(1);
|
|
23031
23164
|
}
|
|
23032
23165
|
console.log(
|
|
23033
|
-
|
|
23166
|
+
chalk172.gray(
|
|
23034
23167
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
23035
23168
|
)
|
|
23036
23169
|
);
|
|
23037
23170
|
} else {
|
|
23038
|
-
console.log(
|
|
23171
|
+
console.log(chalk172.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
23039
23172
|
}
|
|
23040
23173
|
for (const [i, source] of blocks.entries()) {
|
|
23041
23174
|
const idx = i + 1;
|
|
@@ -23043,7 +23176,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
23043
23176
|
const outPath = resolve15(outDir, `${stem}-${idx}.svg`);
|
|
23044
23177
|
const svg = await renderBlock(krokiUrl, source);
|
|
23045
23178
|
writeFileSync32(outPath, svg, "utf8");
|
|
23046
|
-
console.log(
|
|
23179
|
+
console.log(chalk172.green(` \u2192 ${outPath}`));
|
|
23047
23180
|
}
|
|
23048
23181
|
}
|
|
23049
23182
|
function extractMermaidBlocks(markdown) {
|
|
@@ -23059,18 +23192,18 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
23059
23192
|
if (options2.index !== void 0) {
|
|
23060
23193
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
23061
23194
|
console.error(
|
|
23062
|
-
|
|
23195
|
+
chalk173.red(`--index must be a positive integer (got ${options2.index})`)
|
|
23063
23196
|
);
|
|
23064
23197
|
process.exit(1);
|
|
23065
23198
|
}
|
|
23066
23199
|
if (!file) {
|
|
23067
|
-
console.error(
|
|
23200
|
+
console.error(chalk173.red("--index requires a file argument"));
|
|
23068
23201
|
process.exit(1);
|
|
23069
23202
|
}
|
|
23070
23203
|
}
|
|
23071
23204
|
const files = file ? [file] : readdirSync11(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
23072
23205
|
if (files.length === 0) {
|
|
23073
|
-
console.log(
|
|
23206
|
+
console.log(chalk173.gray("No markdown files found in current directory."));
|
|
23074
23207
|
return;
|
|
23075
23208
|
}
|
|
23076
23209
|
for (const f of files) {
|
|
@@ -23216,7 +23349,7 @@ function extractToSave(details, cwd = process.cwd()) {
|
|
|
23216
23349
|
}
|
|
23217
23350
|
|
|
23218
23351
|
// src/commands/miro/keptTexts.ts
|
|
23219
|
-
import
|
|
23352
|
+
import chalk174 from "chalk";
|
|
23220
23353
|
|
|
23221
23354
|
// src/commands/miro/applyIgnore.ts
|
|
23222
23355
|
function applyIgnore(texts, ignore3) {
|
|
@@ -23229,10 +23362,10 @@ function applyIgnore(texts, ignore3) {
|
|
|
23229
23362
|
}
|
|
23230
23363
|
|
|
23231
23364
|
// src/commands/miro/readIgnoreList.ts
|
|
23232
|
-
import { existsSync as
|
|
23365
|
+
import { existsSync as existsSync59, readFileSync as readFileSync41 } from "fs";
|
|
23233
23366
|
import { parse as parse2 } from "yaml";
|
|
23234
23367
|
function readIgnoreList(file) {
|
|
23235
|
-
if (!
|
|
23368
|
+
if (!existsSync59(file))
|
|
23236
23369
|
throw new MiroExtractError(
|
|
23237
23370
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
23238
23371
|
);
|
|
@@ -23255,7 +23388,7 @@ function warnUnmatched(file, unmatched) {
|
|
|
23255
23388
|
if (unmatched.length === 0) return;
|
|
23256
23389
|
const entries = unmatched.map((entry) => ` - ${entry}`).join("\n");
|
|
23257
23390
|
console.error(
|
|
23258
|
-
|
|
23391
|
+
chalk174.yellow(
|
|
23259
23392
|
`${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
|
|
23260
23393
|
${entries}`
|
|
23261
23394
|
)
|
|
@@ -23458,7 +23591,7 @@ function readMiroItems(file) {
|
|
|
23458
23591
|
}
|
|
23459
23592
|
|
|
23460
23593
|
// src/commands/miro/resolveExtractOptions.ts
|
|
23461
|
-
import
|
|
23594
|
+
import chalk175 from "chalk";
|
|
23462
23595
|
|
|
23463
23596
|
// src/commands/miro/extractLayers.ts
|
|
23464
23597
|
function extractsIn(layer) {
|
|
@@ -23536,7 +23669,7 @@ function resolveExtractOptions(name, options2, paths) {
|
|
|
23536
23669
|
paths.cwd,
|
|
23537
23670
|
paths.globalConfigPath
|
|
23538
23671
|
);
|
|
23539
|
-
console.error(
|
|
23672
|
+
console.error(chalk175.dim(`Extract "${name}" from ${resolved.from}`));
|
|
23540
23673
|
return resolved.options;
|
|
23541
23674
|
}
|
|
23542
23675
|
|
|
@@ -23635,10 +23768,10 @@ function registerMiro(program2) {
|
|
|
23635
23768
|
}
|
|
23636
23769
|
|
|
23637
23770
|
// src/commands/netcap/netcap.ts
|
|
23638
|
-
import { mkdir as
|
|
23771
|
+
import { mkdir as mkdir5 } from "fs/promises";
|
|
23639
23772
|
import { createServer as createServer2 } from "http";
|
|
23640
23773
|
import { dirname as dirname30 } from "path";
|
|
23641
|
-
import
|
|
23774
|
+
import chalk177 from "chalk";
|
|
23642
23775
|
|
|
23643
23776
|
// src/commands/netcap/corsHeaders.ts
|
|
23644
23777
|
var corsHeaders = {
|
|
@@ -23714,22 +23847,22 @@ function createNetcapHandler(options2) {
|
|
|
23714
23847
|
}
|
|
23715
23848
|
|
|
23716
23849
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
23717
|
-
import { cp as
|
|
23850
|
+
import { cp as cp4, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
23718
23851
|
import { networkInterfaces } from "os";
|
|
23719
|
-
import { join as
|
|
23720
|
-
import
|
|
23852
|
+
import { join as join64 } from "path";
|
|
23853
|
+
import chalk176 from "chalk";
|
|
23721
23854
|
|
|
23722
23855
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
23723
|
-
import { dirname as dirname29, join as
|
|
23856
|
+
import { dirname as dirname29, join as join63 } from "path";
|
|
23724
23857
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
23725
23858
|
var moduleDir2 = dirname29(fileURLToPath7(import.meta.url));
|
|
23726
23859
|
function netcapExtensionDir() {
|
|
23727
|
-
return
|
|
23860
|
+
return join63(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
23728
23861
|
}
|
|
23729
23862
|
|
|
23730
23863
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
23731
23864
|
var WSL_WINDOWS_DIR2 = "/mnt/c/tools/netcap-extension";
|
|
23732
|
-
var
|
|
23865
|
+
var WSL_WINDOWS_PATH3 = String.raw`C:\tools\netcap-extension`;
|
|
23733
23866
|
function lanIPv4() {
|
|
23734
23867
|
for (const addrs of Object.values(networkInterfaces())) {
|
|
23735
23868
|
for (const addr of addrs ?? []) {
|
|
@@ -23739,9 +23872,9 @@ function lanIPv4() {
|
|
|
23739
23872
|
return void 0;
|
|
23740
23873
|
}
|
|
23741
23874
|
async function configureBackground(dir, host, port, filter) {
|
|
23742
|
-
const file =
|
|
23743
|
-
const source = await
|
|
23744
|
-
await
|
|
23875
|
+
const file = join64(dir, "background.js");
|
|
23876
|
+
const source = await readFile5(file, "utf8");
|
|
23877
|
+
await writeFile5(
|
|
23745
23878
|
file,
|
|
23746
23879
|
source.replace(
|
|
23747
23880
|
/const RECEIVER = "[^"]*";/,
|
|
@@ -23761,38 +23894,38 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
23761
23894
|
const host = lanIPv4();
|
|
23762
23895
|
if (!host) {
|
|
23763
23896
|
console.log(
|
|
23764
|
-
|
|
23897
|
+
chalk176.yellow("could not determine the WSL IP for the extension")
|
|
23765
23898
|
);
|
|
23766
23899
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
23767
23900
|
return source;
|
|
23768
23901
|
}
|
|
23769
23902
|
try {
|
|
23770
|
-
await
|
|
23903
|
+
await cp4(source, WSL_WINDOWS_DIR2, { recursive: true });
|
|
23771
23904
|
await configureBackground(WSL_WINDOWS_DIR2, host, port, filter);
|
|
23772
|
-
return
|
|
23905
|
+
return WSL_WINDOWS_PATH3;
|
|
23773
23906
|
} catch {
|
|
23774
23907
|
console.log(
|
|
23775
|
-
|
|
23908
|
+
chalk176.yellow(`could not copy extension to ${WSL_WINDOWS_PATH3}`)
|
|
23776
23909
|
);
|
|
23777
23910
|
return source;
|
|
23778
23911
|
}
|
|
23779
23912
|
}
|
|
23780
23913
|
|
|
23781
23914
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
23782
|
-
import { isAbsolute as isAbsolute4, join as
|
|
23915
|
+
import { isAbsolute as isAbsolute4, join as join66, resolve as resolve18 } from "path";
|
|
23783
23916
|
|
|
23784
23917
|
// src/commands/netcap/defaultCapturePath.ts
|
|
23785
|
-
import { homedir as
|
|
23786
|
-
import { join as
|
|
23918
|
+
import { homedir as homedir21 } from "os";
|
|
23919
|
+
import { join as join65 } from "path";
|
|
23787
23920
|
function defaultCapturePath() {
|
|
23788
|
-
return
|
|
23921
|
+
return join65(homedir21(), ".assist", "netcap", "capture.jsonl");
|
|
23789
23922
|
}
|
|
23790
23923
|
|
|
23791
23924
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
23792
23925
|
function resolveNetcapOutPath(out) {
|
|
23793
23926
|
if (!out) return defaultCapturePath();
|
|
23794
23927
|
const dir = isAbsolute4(out) ? out : resolve18(process.cwd(), out);
|
|
23795
|
-
return
|
|
23928
|
+
return join66(dir, "capture.jsonl");
|
|
23796
23929
|
}
|
|
23797
23930
|
|
|
23798
23931
|
// src/commands/netcap/netcap.ts
|
|
@@ -23800,35 +23933,35 @@ async function netcap(options2) {
|
|
|
23800
23933
|
const port = Number(options2.port);
|
|
23801
23934
|
const outPath = resolveNetcapOutPath(options2.out);
|
|
23802
23935
|
const filter = options2.filter ?? "";
|
|
23803
|
-
await
|
|
23936
|
+
await mkdir5(dirname30(outPath), { recursive: true });
|
|
23804
23937
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
23805
23938
|
let count8 = 0;
|
|
23806
23939
|
const handler = createNetcapHandler({
|
|
23807
23940
|
outPath,
|
|
23808
|
-
onPing: () => console.log(
|
|
23941
|
+
onPing: () => console.log(chalk177.dim("ping from extension")),
|
|
23809
23942
|
onCapture: (entry) => {
|
|
23810
23943
|
count8 += 1;
|
|
23811
23944
|
console.log(
|
|
23812
|
-
|
|
23813
|
-
|
|
23945
|
+
chalk177.green(`captured #${count8}`),
|
|
23946
|
+
chalk177.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
23814
23947
|
);
|
|
23815
23948
|
}
|
|
23816
23949
|
});
|
|
23817
23950
|
const server = createServer2(handler);
|
|
23818
23951
|
server.listen(port, () => {
|
|
23819
23952
|
console.log(
|
|
23820
|
-
|
|
23953
|
+
chalk177.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
23821
23954
|
);
|
|
23822
|
-
console.log(
|
|
23955
|
+
console.log(chalk177.dim(`appending captures to ${outPath}`));
|
|
23823
23956
|
if (filter)
|
|
23824
|
-
console.log(
|
|
23825
|
-
console.log(
|
|
23826
|
-
console.log(
|
|
23957
|
+
console.log(chalk177.dim(`forwarding only URLs matching "${filter}"`));
|
|
23958
|
+
console.log(chalk177.dim(`load the unpacked extension from ${extensionPath}`));
|
|
23959
|
+
console.log(chalk177.dim("press Ctrl-C to stop"));
|
|
23827
23960
|
});
|
|
23828
23961
|
process.on("SIGINT", () => {
|
|
23829
23962
|
server.close();
|
|
23830
23963
|
console.log(
|
|
23831
|
-
|
|
23964
|
+
chalk177.bold(
|
|
23832
23965
|
`
|
|
23833
23966
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
23834
23967
|
)
|
|
@@ -23839,8 +23972,8 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
23839
23972
|
|
|
23840
23973
|
// src/commands/netcap/netcapExtract.ts
|
|
23841
23974
|
import { writeFileSync as writeFileSync34 } from "fs";
|
|
23842
|
-
import { join as
|
|
23843
|
-
import
|
|
23975
|
+
import { join as join67 } from "path";
|
|
23976
|
+
import chalk178 from "chalk";
|
|
23844
23977
|
|
|
23845
23978
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
23846
23979
|
import { readFileSync as readFileSync43 } from "fs";
|
|
@@ -24284,12 +24417,12 @@ function extractPostsFromCapture(captureFile) {
|
|
|
24284
24417
|
function netcapExtract(file) {
|
|
24285
24418
|
const captureFile = file ?? defaultCapturePath();
|
|
24286
24419
|
const posts = extractPostsFromCapture(captureFile);
|
|
24287
|
-
const outFile =
|
|
24420
|
+
const outFile = join67(captureFile, "..", "posts.json");
|
|
24288
24421
|
writeFileSync34(outFile, `${JSON.stringify(posts, null, 2)}
|
|
24289
24422
|
`);
|
|
24290
24423
|
console.log(
|
|
24291
|
-
|
|
24292
|
-
|
|
24424
|
+
chalk178.green(`extracted ${posts.length} posts`),
|
|
24425
|
+
chalk178.dim(`-> ${outFile}`)
|
|
24293
24426
|
);
|
|
24294
24427
|
}
|
|
24295
24428
|
|
|
@@ -24310,7 +24443,7 @@ function registerNetcap(program2) {
|
|
|
24310
24443
|
}
|
|
24311
24444
|
|
|
24312
24445
|
// src/commands/news/add/index.ts
|
|
24313
|
-
import
|
|
24446
|
+
import chalk179 from "chalk";
|
|
24314
24447
|
import enquirer8 from "enquirer";
|
|
24315
24448
|
async function add2(url) {
|
|
24316
24449
|
if (!url) {
|
|
@@ -24332,10 +24465,10 @@ async function add2(url) {
|
|
|
24332
24465
|
const { orm } = await getReady();
|
|
24333
24466
|
const added = await addFeed(orm, url);
|
|
24334
24467
|
if (!added) {
|
|
24335
|
-
console.log(
|
|
24468
|
+
console.log(chalk179.yellow("Feed already exists"));
|
|
24336
24469
|
return;
|
|
24337
24470
|
}
|
|
24338
|
-
console.log(
|
|
24471
|
+
console.log(chalk179.green(`Added feed: ${url}`));
|
|
24339
24472
|
}
|
|
24340
24473
|
|
|
24341
24474
|
// src/commands/registerNews.ts
|
|
@@ -24382,7 +24515,7 @@ function registerPiHook(program2) {
|
|
|
24382
24515
|
}
|
|
24383
24516
|
|
|
24384
24517
|
// src/commands/prompts/printPromptsTable.ts
|
|
24385
|
-
import
|
|
24518
|
+
import chalk180 from "chalk";
|
|
24386
24519
|
function truncate(str, max) {
|
|
24387
24520
|
if (str.length <= max) return str;
|
|
24388
24521
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -24400,14 +24533,14 @@ function printPromptsTable(rows) {
|
|
|
24400
24533
|
"Command".padEnd(commandWidth),
|
|
24401
24534
|
"Repos"
|
|
24402
24535
|
].join(" ");
|
|
24403
|
-
console.log(
|
|
24404
|
-
console.log(
|
|
24536
|
+
console.log(chalk180.dim(header));
|
|
24537
|
+
console.log(chalk180.dim("-".repeat(header.length)));
|
|
24405
24538
|
for (const row of rows) {
|
|
24406
24539
|
const count8 = String(row.count).padStart(countWidth);
|
|
24407
24540
|
const tool = row.tool.padEnd(toolWidth);
|
|
24408
24541
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
24409
24542
|
console.log(
|
|
24410
|
-
`${
|
|
24543
|
+
`${chalk180.yellow(count8)} ${tool} ${command} ${chalk180.dim(row.repos)}`
|
|
24411
24544
|
);
|
|
24412
24545
|
}
|
|
24413
24546
|
}
|
|
@@ -24809,19 +24942,19 @@ import { execSync as execSync45 } from "child_process";
|
|
|
24809
24942
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
24810
24943
|
import { execSync as execSync44 } from "child_process";
|
|
24811
24944
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync35 } from "fs";
|
|
24812
|
-
import { tmpdir as
|
|
24813
|
-
import { join as
|
|
24945
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
24946
|
+
import { join as join69 } from "path";
|
|
24814
24947
|
|
|
24815
24948
|
// src/commands/prs/loadCommentsCache.ts
|
|
24816
|
-
import { existsSync as
|
|
24949
|
+
import { existsSync as existsSync60, readFileSync as readFileSync44, unlinkSync as unlinkSync13 } from "fs";
|
|
24817
24950
|
import { parse as parse3 } from "yaml";
|
|
24818
24951
|
|
|
24819
24952
|
// src/commands/prs/commentsCachePath.ts
|
|
24820
|
-
import { homedir as
|
|
24821
|
-
import { join as
|
|
24953
|
+
import { homedir as homedir22 } from "os";
|
|
24954
|
+
import { join as join68 } from "path";
|
|
24822
24955
|
function commentsCachePath(org, repo, prNumber) {
|
|
24823
|
-
return
|
|
24824
|
-
|
|
24956
|
+
return join68(
|
|
24957
|
+
homedir22(),
|
|
24825
24958
|
".assist",
|
|
24826
24959
|
"pr-comments",
|
|
24827
24960
|
org,
|
|
@@ -24833,7 +24966,7 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
24833
24966
|
// src/commands/prs/loadCommentsCache.ts
|
|
24834
24967
|
function loadCommentsCache(org, repo, prNumber) {
|
|
24835
24968
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24836
|
-
if (!
|
|
24969
|
+
if (!existsSync60(cachePath)) {
|
|
24837
24970
|
return null;
|
|
24838
24971
|
}
|
|
24839
24972
|
const content = readFileSync44(cachePath, "utf8");
|
|
@@ -24841,7 +24974,7 @@ function loadCommentsCache(org, repo, prNumber) {
|
|
|
24841
24974
|
}
|
|
24842
24975
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
24843
24976
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24844
|
-
if (
|
|
24977
|
+
if (existsSync60(cachePath)) {
|
|
24845
24978
|
unlinkSync13(cachePath);
|
|
24846
24979
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
24847
24980
|
}
|
|
@@ -24869,7 +25002,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
24869
25002
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
24870
25003
|
function resolveThread(threadId) {
|
|
24871
25004
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
24872
|
-
const queryFile =
|
|
25005
|
+
const queryFile = join69(tmpdir7(), `gh-mutation-${Date.now()}.graphql`);
|
|
24873
25006
|
writeFileSync35(queryFile, mutation);
|
|
24874
25007
|
try {
|
|
24875
25008
|
execSync44(
|
|
@@ -24953,11 +25086,11 @@ function fixed(commentId, sha) {
|
|
|
24953
25086
|
// src/commands/prs/fetchThreadIds.ts
|
|
24954
25087
|
import { execSync as execSync46 } from "child_process";
|
|
24955
25088
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync36 } from "fs";
|
|
24956
|
-
import { tmpdir as
|
|
24957
|
-
import { join as
|
|
25089
|
+
import { tmpdir as tmpdir8 } from "os";
|
|
25090
|
+
import { join as join70 } from "path";
|
|
24958
25091
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
24959
25092
|
function fetchThreadIds(org, repo, prNumber) {
|
|
24960
|
-
const queryFile =
|
|
25093
|
+
const queryFile = join70(tmpdir8(), `gh-query-${Date.now()}.graphql`);
|
|
24961
25094
|
writeFileSync36(queryFile, THREAD_QUERY);
|
|
24962
25095
|
try {
|
|
24963
25096
|
const result = execSync46(
|
|
@@ -25032,10 +25165,10 @@ import { stringify as stringify3 } from "yaml";
|
|
|
25032
25165
|
|
|
25033
25166
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
25034
25167
|
import { readdirSync as readdirSync12, unlinkSync as unlinkSync16 } from "fs";
|
|
25035
|
-
import { join as
|
|
25168
|
+
import { join as join71 } from "path";
|
|
25036
25169
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
25037
25170
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
25038
|
-
const dir =
|
|
25171
|
+
const dir = join71(cwd, ".assist");
|
|
25039
25172
|
let entries;
|
|
25040
25173
|
try {
|
|
25041
25174
|
entries = readdirSync12(dir);
|
|
@@ -25043,7 +25176,7 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
|
25043
25176
|
return;
|
|
25044
25177
|
}
|
|
25045
25178
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
25046
|
-
unlinkSync16(
|
|
25179
|
+
unlinkSync16(join71(dir, entry));
|
|
25047
25180
|
}
|
|
25048
25181
|
}
|
|
25049
25182
|
|
|
@@ -25074,13 +25207,13 @@ function agentFooter(unresolvedCount) {
|
|
|
25074
25207
|
}
|
|
25075
25208
|
|
|
25076
25209
|
// src/commands/prs/listComments/commentStyle.ts
|
|
25077
|
-
import
|
|
25210
|
+
import chalk181 from "chalk";
|
|
25078
25211
|
var plain = (text18) => text18;
|
|
25079
25212
|
function colouredState(state) {
|
|
25080
25213
|
const label2 = `[${state}]`;
|
|
25081
|
-
if (state === "APPROVED") return
|
|
25082
|
-
if (state === "CHANGES_REQUESTED") return
|
|
25083
|
-
return
|
|
25214
|
+
if (state === "APPROVED") return chalk181.green(label2);
|
|
25215
|
+
if (state === "CHANGES_REQUESTED") return chalk181.red(label2);
|
|
25216
|
+
return chalk181.yellow(label2);
|
|
25084
25217
|
}
|
|
25085
25218
|
function commentStyle() {
|
|
25086
25219
|
if (isClaudeCode()) {
|
|
@@ -25094,9 +25227,9 @@ function commentStyle() {
|
|
|
25094
25227
|
};
|
|
25095
25228
|
}
|
|
25096
25229
|
return {
|
|
25097
|
-
cyan:
|
|
25098
|
-
bold:
|
|
25099
|
-
dim:
|
|
25230
|
+
cyan: chalk181.cyan,
|
|
25231
|
+
bold: chalk181.bold,
|
|
25232
|
+
dim: chalk181.dim,
|
|
25100
25233
|
state: colouredState,
|
|
25101
25234
|
diffHunk: true,
|
|
25102
25235
|
agent: false
|
|
@@ -25266,13 +25399,13 @@ import { execSync as execSync48 } from "child_process";
|
|
|
25266
25399
|
import enquirer9 from "enquirer";
|
|
25267
25400
|
|
|
25268
25401
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
25269
|
-
import
|
|
25402
|
+
import chalk182 from "chalk";
|
|
25270
25403
|
var STATUS_MAP = {
|
|
25271
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
25272
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
25404
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk182.magenta("merged"), date: pr.mergedAt } : null,
|
|
25405
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk182.red("closed"), date: pr.closedAt } : null
|
|
25273
25406
|
};
|
|
25274
25407
|
function defaultStatus(pr) {
|
|
25275
|
-
return { label:
|
|
25408
|
+
return { label: chalk182.green("opened"), date: pr.createdAt };
|
|
25276
25409
|
}
|
|
25277
25410
|
function getStatus2(pr) {
|
|
25278
25411
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -25281,11 +25414,11 @@ function formatDate(dateStr) {
|
|
|
25281
25414
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
25282
25415
|
}
|
|
25283
25416
|
function formatPrHeader(pr, status3) {
|
|
25284
|
-
return `${
|
|
25417
|
+
return `${chalk182.cyan(`#${pr.number}`)} ${pr.title} ${chalk182.dim(`(${pr.author.login},`)} ${status3.label} ${chalk182.dim(`${formatDate(status3.date)})`)}`;
|
|
25285
25418
|
}
|
|
25286
25419
|
function logPrDetails(pr) {
|
|
25287
25420
|
console.log(
|
|
25288
|
-
|
|
25421
|
+
chalk182.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
25289
25422
|
);
|
|
25290
25423
|
console.log();
|
|
25291
25424
|
}
|
|
@@ -26000,10 +26133,10 @@ function registerPrs(program2) {
|
|
|
26000
26133
|
}
|
|
26001
26134
|
|
|
26002
26135
|
// src/commands/ravendb/ravendbAuth.ts
|
|
26003
|
-
import
|
|
26136
|
+
import chalk188 from "chalk";
|
|
26004
26137
|
|
|
26005
26138
|
// src/shared/createConnectionAuth.ts
|
|
26006
|
-
import
|
|
26139
|
+
import chalk183 from "chalk";
|
|
26007
26140
|
function listConnections(connections, format) {
|
|
26008
26141
|
if (connections.length === 0) {
|
|
26009
26142
|
console.log("No connections configured.");
|
|
@@ -26016,7 +26149,7 @@ function listConnections(connections, format) {
|
|
|
26016
26149
|
function removeConnection(connections, name, save) {
|
|
26017
26150
|
const filtered = connections.filter((c) => c.name !== name);
|
|
26018
26151
|
if (filtered.length === connections.length) {
|
|
26019
|
-
console.error(
|
|
26152
|
+
console.error(chalk183.red(`Connection "${name}" not found.`));
|
|
26020
26153
|
process.exit(1);
|
|
26021
26154
|
}
|
|
26022
26155
|
save(filtered);
|
|
@@ -26062,15 +26195,15 @@ function saveConnections(connections) {
|
|
|
26062
26195
|
}
|
|
26063
26196
|
|
|
26064
26197
|
// src/commands/ravendb/promptConnection.ts
|
|
26065
|
-
import
|
|
26198
|
+
import chalk186 from "chalk";
|
|
26066
26199
|
|
|
26067
26200
|
// src/commands/ravendb/selectOpSecret.ts
|
|
26068
|
-
import
|
|
26201
|
+
import chalk185 from "chalk";
|
|
26069
26202
|
import Enquirer2 from "enquirer";
|
|
26070
26203
|
|
|
26071
26204
|
// src/commands/ravendb/searchItems.ts
|
|
26072
26205
|
import { execSync as execSync51 } from "child_process";
|
|
26073
|
-
import
|
|
26206
|
+
import chalk184 from "chalk";
|
|
26074
26207
|
function opExec(args) {
|
|
26075
26208
|
return execSync51(`op ${args}`, {
|
|
26076
26209
|
encoding: "utf8",
|
|
@@ -26083,7 +26216,7 @@ function searchItems(search2) {
|
|
|
26083
26216
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
26084
26217
|
} catch {
|
|
26085
26218
|
console.error(
|
|
26086
|
-
|
|
26219
|
+
chalk184.red(
|
|
26087
26220
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
26088
26221
|
)
|
|
26089
26222
|
);
|
|
@@ -26097,7 +26230,7 @@ function getItemFields(itemId2) {
|
|
|
26097
26230
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
26098
26231
|
return item.fields.filter((f) => f.reference && f.label);
|
|
26099
26232
|
} catch {
|
|
26100
|
-
console.error(
|
|
26233
|
+
console.error(chalk184.red("Failed to get item details from 1Password."));
|
|
26101
26234
|
process.exit(1);
|
|
26102
26235
|
}
|
|
26103
26236
|
}
|
|
@@ -26116,7 +26249,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
26116
26249
|
}).run();
|
|
26117
26250
|
const items2 = searchItems(search2);
|
|
26118
26251
|
if (items2.length === 0) {
|
|
26119
|
-
console.error(
|
|
26252
|
+
console.error(chalk185.red(`No items found matching "${search2}".`));
|
|
26120
26253
|
process.exit(1);
|
|
26121
26254
|
}
|
|
26122
26255
|
const itemId2 = await selectOne(
|
|
@@ -26125,7 +26258,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
26125
26258
|
);
|
|
26126
26259
|
const fields = getItemFields(itemId2);
|
|
26127
26260
|
if (fields.length === 0) {
|
|
26128
|
-
console.error(
|
|
26261
|
+
console.error(chalk185.red("No fields with references found on this item."));
|
|
26129
26262
|
process.exit(1);
|
|
26130
26263
|
}
|
|
26131
26264
|
const ref = await selectOne(
|
|
@@ -26139,7 +26272,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
26139
26272
|
async function promptConnection(existingNames) {
|
|
26140
26273
|
const name = await promptInput("name", "Connection name:");
|
|
26141
26274
|
if (existingNames.includes(name)) {
|
|
26142
|
-
console.error(
|
|
26275
|
+
console.error(chalk186.red(`Connection "${name}" already exists.`));
|
|
26143
26276
|
process.exit(1);
|
|
26144
26277
|
}
|
|
26145
26278
|
const url = await promptInput(
|
|
@@ -26148,22 +26281,22 @@ async function promptConnection(existingNames) {
|
|
|
26148
26281
|
);
|
|
26149
26282
|
const database = await promptInput("database", "Database name:");
|
|
26150
26283
|
if (!name || !url || !database) {
|
|
26151
|
-
console.error(
|
|
26284
|
+
console.error(chalk186.red("All fields are required."));
|
|
26152
26285
|
process.exit(1);
|
|
26153
26286
|
}
|
|
26154
26287
|
const apiKeyRef = await selectOpSecret();
|
|
26155
|
-
console.log(
|
|
26288
|
+
console.log(chalk186.dim(`Using: ${apiKeyRef}`));
|
|
26156
26289
|
return { name, url, database, apiKeyRef };
|
|
26157
26290
|
}
|
|
26158
26291
|
|
|
26159
26292
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
26160
|
-
import
|
|
26293
|
+
import chalk187 from "chalk";
|
|
26161
26294
|
function ravendbSetConnection(name) {
|
|
26162
26295
|
const raw = loadGlobalConfigRaw();
|
|
26163
26296
|
const ravendb = raw.ravendb ?? {};
|
|
26164
26297
|
const connections = ravendb.connections ?? [];
|
|
26165
26298
|
if (!connections.some((c) => c.name === name)) {
|
|
26166
|
-
console.error(
|
|
26299
|
+
console.error(chalk187.red(`Connection "${name}" not found.`));
|
|
26167
26300
|
console.error(
|
|
26168
26301
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
26169
26302
|
);
|
|
@@ -26179,16 +26312,16 @@ function ravendbSetConnection(name) {
|
|
|
26179
26312
|
var ravendbAuth = createConnectionAuth({
|
|
26180
26313
|
load: loadConnections,
|
|
26181
26314
|
save: saveConnections,
|
|
26182
|
-
format: (c) => `${
|
|
26315
|
+
format: (c) => `${chalk188.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
26183
26316
|
promptNew: promptConnection,
|
|
26184
26317
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
26185
26318
|
});
|
|
26186
26319
|
|
|
26187
26320
|
// src/commands/ravendb/ravendbCollections.ts
|
|
26188
|
-
import
|
|
26321
|
+
import chalk192 from "chalk";
|
|
26189
26322
|
|
|
26190
26323
|
// src/commands/ravendb/ravenFetch.ts
|
|
26191
|
-
import
|
|
26324
|
+
import chalk190 from "chalk";
|
|
26192
26325
|
|
|
26193
26326
|
// src/commands/ravendb/getAccessToken.ts
|
|
26194
26327
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -26225,10 +26358,10 @@ ${errorText}`
|
|
|
26225
26358
|
|
|
26226
26359
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
26227
26360
|
import { execSync as execSync52 } from "child_process";
|
|
26228
|
-
import
|
|
26361
|
+
import chalk189 from "chalk";
|
|
26229
26362
|
function resolveOpSecret(reference) {
|
|
26230
26363
|
if (!reference.startsWith("op://")) {
|
|
26231
|
-
console.error(
|
|
26364
|
+
console.error(chalk189.red(`Invalid secret reference: must start with op://`));
|
|
26232
26365
|
process.exit(1);
|
|
26233
26366
|
}
|
|
26234
26367
|
try {
|
|
@@ -26238,7 +26371,7 @@ function resolveOpSecret(reference) {
|
|
|
26238
26371
|
}).trim();
|
|
26239
26372
|
} catch {
|
|
26240
26373
|
console.error(
|
|
26241
|
-
|
|
26374
|
+
chalk189.red(
|
|
26242
26375
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
26243
26376
|
)
|
|
26244
26377
|
);
|
|
@@ -26265,7 +26398,7 @@ async function ravenFetch(connection, path84) {
|
|
|
26265
26398
|
if (!response.ok) {
|
|
26266
26399
|
const body = await response.text();
|
|
26267
26400
|
console.error(
|
|
26268
|
-
|
|
26401
|
+
chalk190.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
26269
26402
|
);
|
|
26270
26403
|
console.error(body.substring(0, 500));
|
|
26271
26404
|
process.exit(1);
|
|
@@ -26274,7 +26407,7 @@ async function ravenFetch(connection, path84) {
|
|
|
26274
26407
|
}
|
|
26275
26408
|
|
|
26276
26409
|
// src/commands/ravendb/resolveConnection.ts
|
|
26277
|
-
import
|
|
26410
|
+
import chalk191 from "chalk";
|
|
26278
26411
|
function loadRavendb() {
|
|
26279
26412
|
const raw = loadGlobalConfigRaw();
|
|
26280
26413
|
const ravendb = raw.ravendb;
|
|
@@ -26288,7 +26421,7 @@ function resolveConnection(name) {
|
|
|
26288
26421
|
const connectionName = name ?? defaultConnection;
|
|
26289
26422
|
if (!connectionName) {
|
|
26290
26423
|
console.error(
|
|
26291
|
-
|
|
26424
|
+
chalk191.red(
|
|
26292
26425
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
26293
26426
|
)
|
|
26294
26427
|
);
|
|
@@ -26296,7 +26429,7 @@ function resolveConnection(name) {
|
|
|
26296
26429
|
}
|
|
26297
26430
|
const connection = connections.find((c) => c.name === connectionName);
|
|
26298
26431
|
if (!connection) {
|
|
26299
|
-
console.error(
|
|
26432
|
+
console.error(chalk191.red(`Connection "${connectionName}" not found.`));
|
|
26300
26433
|
console.error(
|
|
26301
26434
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
26302
26435
|
);
|
|
@@ -26327,15 +26460,15 @@ async function ravendbCollections(connectionName) {
|
|
|
26327
26460
|
return;
|
|
26328
26461
|
}
|
|
26329
26462
|
for (const c of collections) {
|
|
26330
|
-
console.log(`${
|
|
26463
|
+
console.log(`${chalk192.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
26331
26464
|
}
|
|
26332
26465
|
}
|
|
26333
26466
|
|
|
26334
26467
|
// src/commands/ravendb/ravendbQuery.ts
|
|
26335
|
-
import
|
|
26468
|
+
import chalk194 from "chalk";
|
|
26336
26469
|
|
|
26337
26470
|
// src/commands/ravendb/fetchAllPages.ts
|
|
26338
|
-
import
|
|
26471
|
+
import chalk193 from "chalk";
|
|
26339
26472
|
|
|
26340
26473
|
// src/commands/ravendb/buildQueryPath.ts
|
|
26341
26474
|
function buildQueryPath(opts) {
|
|
@@ -26373,7 +26506,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
26373
26506
|
allResults.push(...results);
|
|
26374
26507
|
start3 += results.length;
|
|
26375
26508
|
process.stderr.write(
|
|
26376
|
-
`\r${
|
|
26509
|
+
`\r${chalk193.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
26377
26510
|
);
|
|
26378
26511
|
if (start3 >= totalResults) break;
|
|
26379
26512
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -26388,7 +26521,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
26388
26521
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
26389
26522
|
const resolved = resolveArgs(connectionName, collection);
|
|
26390
26523
|
if (!resolved.collection && !options2.query) {
|
|
26391
|
-
console.error(
|
|
26524
|
+
console.error(chalk194.red("Provide a collection name or --query filter."));
|
|
26392
26525
|
process.exit(1);
|
|
26393
26526
|
}
|
|
26394
26527
|
const { collection: col } = resolved;
|
|
@@ -26427,7 +26560,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
26427
26560
|
import * as path45 from "path";
|
|
26428
26561
|
|
|
26429
26562
|
// src/commands/refactor/logViolations.ts
|
|
26430
|
-
import
|
|
26563
|
+
import chalk195 from "chalk";
|
|
26431
26564
|
var DEFAULT_MAX_LINES2 = 100;
|
|
26432
26565
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
26433
26566
|
if (violations.length === 0) {
|
|
@@ -26436,43 +26569,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
26436
26569
|
}
|
|
26437
26570
|
return;
|
|
26438
26571
|
}
|
|
26439
|
-
console.error(
|
|
26572
|
+
console.error(chalk195.red(`
|
|
26440
26573
|
Refactor check failed:
|
|
26441
26574
|
`));
|
|
26442
|
-
console.error(
|
|
26575
|
+
console.error(chalk195.red(` The following files exceed ${maxLines} lines:
|
|
26443
26576
|
`));
|
|
26444
26577
|
for (const violation of violations) {
|
|
26445
|
-
console.error(
|
|
26578
|
+
console.error(chalk195.red(` ${violation.file} (${violation.lines} lines)`));
|
|
26446
26579
|
}
|
|
26447
26580
|
console.error(
|
|
26448
|
-
|
|
26581
|
+
chalk195.yellow(
|
|
26449
26582
|
`
|
|
26450
26583
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
26451
26584
|
way to refactor it, ignore it with:
|
|
26452
26585
|
`
|
|
26453
26586
|
)
|
|
26454
26587
|
);
|
|
26455
|
-
console.error(
|
|
26588
|
+
console.error(chalk195.gray(` assist refactor ignore <file>
|
|
26456
26589
|
`));
|
|
26457
26590
|
if (process.env.CLAUDECODE) {
|
|
26458
|
-
console.error(
|
|
26591
|
+
console.error(chalk195.cyan(`
|
|
26459
26592
|
## Extracting Code to New Files
|
|
26460
26593
|
`));
|
|
26461
26594
|
console.error(
|
|
26462
|
-
|
|
26595
|
+
chalk195.cyan(
|
|
26463
26596
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
26464
26597
|
`
|
|
26465
26598
|
)
|
|
26466
26599
|
);
|
|
26467
26600
|
console.error(
|
|
26468
|
-
|
|
26601
|
+
chalk195.cyan(
|
|
26469
26602
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
26470
26603
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
26471
26604
|
`
|
|
26472
26605
|
)
|
|
26473
26606
|
);
|
|
26474
26607
|
console.error(
|
|
26475
|
-
|
|
26608
|
+
chalk195.cyan(
|
|
26476
26609
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
26477
26610
|
domains, move it to a common/shared folder.
|
|
26478
26611
|
`
|
|
@@ -26628,7 +26761,7 @@ async function check(pattern2, options2) {
|
|
|
26628
26761
|
|
|
26629
26762
|
// src/commands/refactor/extract/index.ts
|
|
26630
26763
|
import path53 from "path";
|
|
26631
|
-
import
|
|
26764
|
+
import chalk198 from "chalk";
|
|
26632
26765
|
|
|
26633
26766
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
26634
26767
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -27227,23 +27360,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
27227
27360
|
|
|
27228
27361
|
// src/commands/refactor/extract/displayPlan.ts
|
|
27229
27362
|
import path49 from "path";
|
|
27230
|
-
import
|
|
27363
|
+
import chalk196 from "chalk";
|
|
27231
27364
|
function section2(title) {
|
|
27232
27365
|
return `
|
|
27233
|
-
${
|
|
27366
|
+
${chalk196.cyan(title)}`;
|
|
27234
27367
|
}
|
|
27235
27368
|
function displayImporters(plan2, cwd) {
|
|
27236
27369
|
if (plan2.importersToUpdate.length === 0) return;
|
|
27237
27370
|
console.log(section2("Update importers:"));
|
|
27238
27371
|
for (const imp of plan2.importersToUpdate) {
|
|
27239
27372
|
const rel = path49.relative(cwd, imp.file.getFilePath());
|
|
27240
|
-
console.log(` ${
|
|
27373
|
+
console.log(` ${chalk196.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
27241
27374
|
}
|
|
27242
27375
|
}
|
|
27243
27376
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
27244
|
-
console.log(
|
|
27377
|
+
console.log(chalk196.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
27245
27378
|
`));
|
|
27246
|
-
console.log(` ${
|
|
27379
|
+
console.log(` ${chalk196.cyan("Functions to move:")}`);
|
|
27247
27380
|
for (const name of plan2.extractedNames) {
|
|
27248
27381
|
console.log(` ${name}`);
|
|
27249
27382
|
}
|
|
@@ -27277,7 +27410,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
27277
27410
|
|
|
27278
27411
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
27279
27412
|
import path52 from "path";
|
|
27280
|
-
import
|
|
27413
|
+
import chalk197 from "chalk";
|
|
27281
27414
|
import { Project as Project4 } from "ts-morph";
|
|
27282
27415
|
|
|
27283
27416
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -27369,7 +27502,7 @@ function loadProjectFile(file) {
|
|
|
27369
27502
|
});
|
|
27370
27503
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
27371
27504
|
if (!sourceFile) {
|
|
27372
|
-
console.log(
|
|
27505
|
+
console.log(chalk197.red(`File not found in project: ${file}`));
|
|
27373
27506
|
process.exit(1);
|
|
27374
27507
|
}
|
|
27375
27508
|
return { project, sourceFile };
|
|
@@ -27392,19 +27525,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
27392
27525
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
27393
27526
|
if (options2.apply) {
|
|
27394
27527
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
27395
|
-
console.log(
|
|
27528
|
+
console.log(chalk198.green("\nExtraction complete"));
|
|
27396
27529
|
} else {
|
|
27397
|
-
console.log(
|
|
27530
|
+
console.log(chalk198.dim("\nDry run. Use --apply to execute."));
|
|
27398
27531
|
}
|
|
27399
27532
|
}
|
|
27400
27533
|
|
|
27401
27534
|
// src/commands/refactor/ignore.ts
|
|
27402
27535
|
import fs33 from "fs";
|
|
27403
|
-
import
|
|
27536
|
+
import chalk199 from "chalk";
|
|
27404
27537
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
27405
27538
|
function ignore2(file) {
|
|
27406
27539
|
if (!fs33.existsSync(file)) {
|
|
27407
|
-
console.error(
|
|
27540
|
+
console.error(chalk199.red(`Error: File does not exist: ${file}`));
|
|
27408
27541
|
process.exit(1);
|
|
27409
27542
|
}
|
|
27410
27543
|
const content = fs33.readFileSync(file, "utf8");
|
|
@@ -27420,7 +27553,7 @@ function ignore2(file) {
|
|
|
27420
27553
|
fs33.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
27421
27554
|
}
|
|
27422
27555
|
console.log(
|
|
27423
|
-
|
|
27556
|
+
chalk199.green(
|
|
27424
27557
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
27425
27558
|
)
|
|
27426
27559
|
);
|
|
@@ -27429,12 +27562,12 @@ function ignore2(file) {
|
|
|
27429
27562
|
// src/commands/refactor/rename/index.ts
|
|
27430
27563
|
import fs36 from "fs";
|
|
27431
27564
|
import path58 from "path";
|
|
27432
|
-
import
|
|
27565
|
+
import chalk202 from "chalk";
|
|
27433
27566
|
|
|
27434
27567
|
// src/commands/refactor/rename/applyRename.ts
|
|
27435
27568
|
import fs35 from "fs";
|
|
27436
27569
|
import path55 from "path";
|
|
27437
|
-
import
|
|
27570
|
+
import chalk200 from "chalk";
|
|
27438
27571
|
|
|
27439
27572
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
27440
27573
|
import path54 from "path";
|
|
@@ -27539,13 +27672,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
27539
27672
|
const updatedContents = applyRewrites(rewrites);
|
|
27540
27673
|
for (const [file, content] of updatedContents) {
|
|
27541
27674
|
fs35.writeFileSync(file, content, "utf8");
|
|
27542
|
-
console.log(
|
|
27675
|
+
console.log(chalk200.cyan(` Updated imports in ${path55.relative(cwd, file)}`));
|
|
27543
27676
|
}
|
|
27544
27677
|
const destDir = path55.dirname(destPath);
|
|
27545
27678
|
if (!fs35.existsSync(destDir)) fs35.mkdirSync(destDir, { recursive: true });
|
|
27546
27679
|
fs35.renameSync(sourcePath, destPath);
|
|
27547
27680
|
console.log(
|
|
27548
|
-
|
|
27681
|
+
chalk200.white(
|
|
27549
27682
|
` Moved ${path55.relative(cwd, sourcePath)} \u2192 ${path55.relative(cwd, destPath)}`
|
|
27550
27683
|
)
|
|
27551
27684
|
);
|
|
@@ -27632,16 +27765,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
27632
27765
|
|
|
27633
27766
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
27634
27767
|
import path57 from "path";
|
|
27635
|
-
import
|
|
27768
|
+
import chalk201 from "chalk";
|
|
27636
27769
|
function printRenamePreview(rewrites, cwd) {
|
|
27637
27770
|
for (const rewrite of rewrites) {
|
|
27638
27771
|
console.log(
|
|
27639
|
-
|
|
27772
|
+
chalk201.dim(
|
|
27640
27773
|
` ${path57.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
27641
27774
|
)
|
|
27642
27775
|
);
|
|
27643
27776
|
}
|
|
27644
|
-
console.log(
|
|
27777
|
+
console.log(chalk201.dim("Dry run. Use --apply to execute."));
|
|
27645
27778
|
}
|
|
27646
27779
|
|
|
27647
27780
|
// src/commands/refactor/rename/index.ts
|
|
@@ -27652,20 +27785,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27652
27785
|
const relSource = path58.relative(cwd, sourcePath);
|
|
27653
27786
|
const relDest = path58.relative(cwd, destPath);
|
|
27654
27787
|
if (!fs36.existsSync(sourcePath)) {
|
|
27655
|
-
console.log(
|
|
27788
|
+
console.log(chalk202.red(`File not found: ${source}`));
|
|
27656
27789
|
process.exit(1);
|
|
27657
27790
|
}
|
|
27658
27791
|
if (destPath !== sourcePath && fs36.existsSync(destPath)) {
|
|
27659
|
-
console.log(
|
|
27792
|
+
console.log(chalk202.red(`Destination already exists: ${destination}`));
|
|
27660
27793
|
process.exit(1);
|
|
27661
27794
|
}
|
|
27662
|
-
console.log(
|
|
27663
|
-
console.log(
|
|
27664
|
-
console.log(
|
|
27795
|
+
console.log(chalk202.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
27796
|
+
console.log(chalk202.dim("Loading project..."));
|
|
27797
|
+
console.log(chalk202.dim("Scanning imports across the project..."));
|
|
27665
27798
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
27666
27799
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
27667
27800
|
console.log(
|
|
27668
|
-
|
|
27801
|
+
chalk202.dim(
|
|
27669
27802
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
27670
27803
|
)
|
|
27671
27804
|
);
|
|
@@ -27674,11 +27807,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27674
27807
|
return;
|
|
27675
27808
|
}
|
|
27676
27809
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
27677
|
-
console.log(
|
|
27810
|
+
console.log(chalk202.green("Done"));
|
|
27678
27811
|
}
|
|
27679
27812
|
|
|
27680
27813
|
// src/commands/refactor/renameSymbol/index.ts
|
|
27681
|
-
import
|
|
27814
|
+
import chalk203 from "chalk";
|
|
27682
27815
|
|
|
27683
27816
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
27684
27817
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -27724,33 +27857,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
27724
27857
|
const { project, sourceFile } = loadProjectFile(file);
|
|
27725
27858
|
const symbol = findSymbol(sourceFile, oldName);
|
|
27726
27859
|
if (!symbol) {
|
|
27727
|
-
console.log(
|
|
27860
|
+
console.log(chalk203.red(`Symbol "${oldName}" not found in ${file}`));
|
|
27728
27861
|
process.exit(1);
|
|
27729
27862
|
}
|
|
27730
27863
|
const grouped = groupReferences(symbol, cwd);
|
|
27731
27864
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
27732
27865
|
console.log(
|
|
27733
|
-
|
|
27866
|
+
chalk203.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
27734
27867
|
`)
|
|
27735
27868
|
);
|
|
27736
27869
|
for (const [refFile, lines2] of grouped) {
|
|
27737
27870
|
console.log(
|
|
27738
|
-
` ${
|
|
27871
|
+
` ${chalk203.dim(refFile)}: lines ${chalk203.cyan(lines2.join(", "))}`
|
|
27739
27872
|
);
|
|
27740
27873
|
}
|
|
27741
27874
|
if (options2.apply) {
|
|
27742
27875
|
symbol.rename(newName);
|
|
27743
27876
|
await project.save();
|
|
27744
|
-
console.log(
|
|
27877
|
+
console.log(chalk203.green(`
|
|
27745
27878
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
27746
27879
|
} else {
|
|
27747
|
-
console.log(
|
|
27880
|
+
console.log(chalk203.dim("\nDry run. Use --apply to execute."));
|
|
27748
27881
|
}
|
|
27749
27882
|
}
|
|
27750
27883
|
|
|
27751
27884
|
// src/commands/refactor/restructure/index.ts
|
|
27752
27885
|
import path66 from "path";
|
|
27753
|
-
import
|
|
27886
|
+
import chalk206 from "chalk";
|
|
27754
27887
|
|
|
27755
27888
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
27756
27889
|
import path60 from "path";
|
|
@@ -27829,50 +27962,50 @@ function clusterFiles(graph) {
|
|
|
27829
27962
|
|
|
27830
27963
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
27831
27964
|
import path62 from "path";
|
|
27832
|
-
import
|
|
27965
|
+
import chalk204 from "chalk";
|
|
27833
27966
|
function relPath(filePath) {
|
|
27834
27967
|
return path62.relative(process.cwd(), filePath);
|
|
27835
27968
|
}
|
|
27836
27969
|
function displayMoves(plan2) {
|
|
27837
27970
|
if (plan2.moves.length === 0) return;
|
|
27838
|
-
console.log(
|
|
27971
|
+
console.log(chalk204.bold("\nFile moves:"));
|
|
27839
27972
|
for (const move2 of plan2.moves) {
|
|
27840
27973
|
console.log(
|
|
27841
|
-
` ${
|
|
27974
|
+
` ${chalk204.red(relPath(move2.from))} \u2192 ${chalk204.green(relPath(move2.to))}`
|
|
27842
27975
|
);
|
|
27843
|
-
console.log(
|
|
27976
|
+
console.log(chalk204.dim(` ${move2.reason}`));
|
|
27844
27977
|
}
|
|
27845
27978
|
}
|
|
27846
27979
|
function displayRewrites(rewrites) {
|
|
27847
27980
|
if (rewrites.length === 0) return;
|
|
27848
27981
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
27849
|
-
console.log(
|
|
27982
|
+
console.log(chalk204.bold(`
|
|
27850
27983
|
Import rewrites (${affectedFiles.size} files):`));
|
|
27851
27984
|
for (const file of affectedFiles) {
|
|
27852
|
-
console.log(` ${
|
|
27985
|
+
console.log(` ${chalk204.cyan(relPath(file))}:`);
|
|
27853
27986
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
27854
27987
|
(r) => r.file === file
|
|
27855
27988
|
)) {
|
|
27856
27989
|
console.log(
|
|
27857
|
-
` ${
|
|
27990
|
+
` ${chalk204.red(`"${oldSpecifier}"`)} \u2192 ${chalk204.green(`"${newSpecifier}"`)}`
|
|
27858
27991
|
);
|
|
27859
27992
|
}
|
|
27860
27993
|
}
|
|
27861
27994
|
}
|
|
27862
27995
|
function displayPlan2(plan2) {
|
|
27863
27996
|
if (plan2.warnings.length > 0) {
|
|
27864
|
-
console.log(
|
|
27865
|
-
for (const w of plan2.warnings) console.log(
|
|
27997
|
+
console.log(chalk204.yellow("\nWarnings:"));
|
|
27998
|
+
for (const w of plan2.warnings) console.log(chalk204.yellow(` ${w}`));
|
|
27866
27999
|
}
|
|
27867
28000
|
if (plan2.newDirectories.length > 0) {
|
|
27868
|
-
console.log(
|
|
28001
|
+
console.log(chalk204.bold("\nNew directories:"));
|
|
27869
28002
|
for (const dir of plan2.newDirectories)
|
|
27870
|
-
console.log(
|
|
28003
|
+
console.log(chalk204.green(` ${dir}/`));
|
|
27871
28004
|
}
|
|
27872
28005
|
displayMoves(plan2);
|
|
27873
28006
|
displayRewrites(plan2.rewrites);
|
|
27874
28007
|
console.log(
|
|
27875
|
-
|
|
28008
|
+
chalk204.dim(
|
|
27876
28009
|
`
|
|
27877
28010
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
27878
28011
|
)
|
|
@@ -27882,18 +28015,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
27882
28015
|
// src/commands/refactor/restructure/executePlan.ts
|
|
27883
28016
|
import fs37 from "fs";
|
|
27884
28017
|
import path63 from "path";
|
|
27885
|
-
import
|
|
28018
|
+
import chalk205 from "chalk";
|
|
27886
28019
|
function executePlan(plan2) {
|
|
27887
28020
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
27888
28021
|
for (const [file, content] of updatedContents) {
|
|
27889
28022
|
fs37.writeFileSync(file, content, "utf8");
|
|
27890
28023
|
console.log(
|
|
27891
|
-
|
|
28024
|
+
chalk205.cyan(` Rewrote imports in ${path63.relative(process.cwd(), file)}`)
|
|
27892
28025
|
);
|
|
27893
28026
|
}
|
|
27894
28027
|
for (const dir of plan2.newDirectories) {
|
|
27895
28028
|
fs37.mkdirSync(dir, { recursive: true });
|
|
27896
|
-
console.log(
|
|
28029
|
+
console.log(chalk205.green(` Created ${path63.relative(process.cwd(), dir)}/`));
|
|
27897
28030
|
}
|
|
27898
28031
|
for (const move2 of plan2.moves) {
|
|
27899
28032
|
const targetDir = path63.dirname(move2.to);
|
|
@@ -27902,7 +28035,7 @@ function executePlan(plan2) {
|
|
|
27902
28035
|
}
|
|
27903
28036
|
fs37.renameSync(move2.from, move2.to);
|
|
27904
28037
|
console.log(
|
|
27905
|
-
|
|
28038
|
+
chalk205.white(
|
|
27906
28039
|
` Moved ${path63.relative(process.cwd(), move2.from)} \u2192 ${path63.relative(process.cwd(), move2.to)}`
|
|
27907
28040
|
)
|
|
27908
28041
|
);
|
|
@@ -27917,7 +28050,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
27917
28050
|
if (entries.length === 0) {
|
|
27918
28051
|
fs37.rmdirSync(dir);
|
|
27919
28052
|
console.log(
|
|
27920
|
-
|
|
28053
|
+
chalk205.dim(
|
|
27921
28054
|
` Removed empty directory ${path63.relative(process.cwd(), dir)}`
|
|
27922
28055
|
)
|
|
27923
28056
|
);
|
|
@@ -28050,22 +28183,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
28050
28183
|
const targetPattern = pattern2 ?? "src";
|
|
28051
28184
|
const files = findSourceFiles2(targetPattern);
|
|
28052
28185
|
if (files.length === 0) {
|
|
28053
|
-
console.log(
|
|
28186
|
+
console.log(chalk206.yellow("No files found matching pattern"));
|
|
28054
28187
|
return;
|
|
28055
28188
|
}
|
|
28056
28189
|
const tsConfigPath = findTsConfig(path66.resolve(files[0]));
|
|
28057
28190
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
28058
28191
|
if (plan2.moves.length === 0) {
|
|
28059
|
-
console.log(
|
|
28192
|
+
console.log(chalk206.green("No restructuring needed"));
|
|
28060
28193
|
return;
|
|
28061
28194
|
}
|
|
28062
28195
|
displayPlan2(plan2);
|
|
28063
28196
|
if (options2.apply) {
|
|
28064
|
-
console.log(
|
|
28197
|
+
console.log(chalk206.bold("\nApplying changes..."));
|
|
28065
28198
|
executePlan(plan2);
|
|
28066
|
-
console.log(
|
|
28199
|
+
console.log(chalk206.green("\nRestructuring complete"));
|
|
28067
28200
|
} else {
|
|
28068
|
-
console.log(
|
|
28201
|
+
console.log(chalk206.dim("\nDry run. Use --apply to execute."));
|
|
28069
28202
|
}
|
|
28070
28203
|
}
|
|
28071
28204
|
|
|
@@ -28231,11 +28364,11 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
28231
28364
|
}
|
|
28232
28365
|
|
|
28233
28366
|
// src/commands/review/buildReviewPaths.ts
|
|
28234
|
-
import { homedir as
|
|
28235
|
-
import { basename as basename18, join as
|
|
28367
|
+
import { homedir as homedir23 } from "os";
|
|
28368
|
+
import { basename as basename18, join as join72 } from "path";
|
|
28236
28369
|
function buildReviewPaths(repoRoot2, key) {
|
|
28237
|
-
const reviewDir =
|
|
28238
|
-
|
|
28370
|
+
const reviewDir = join72(
|
|
28371
|
+
homedir23(),
|
|
28239
28372
|
".assist",
|
|
28240
28373
|
"reviews",
|
|
28241
28374
|
basename18(repoRoot2),
|
|
@@ -28243,10 +28376,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
28243
28376
|
);
|
|
28244
28377
|
return {
|
|
28245
28378
|
reviewDir,
|
|
28246
|
-
requestPath:
|
|
28247
|
-
claudePath:
|
|
28248
|
-
codexPath:
|
|
28249
|
-
synthesisPath:
|
|
28379
|
+
requestPath: join72(reviewDir, "request.md"),
|
|
28380
|
+
claudePath: join72(reviewDir, "claude.md"),
|
|
28381
|
+
codexPath: join72(reviewDir, "codex.md"),
|
|
28382
|
+
synthesisPath: join72(reviewDir, "synthesis.md")
|
|
28250
28383
|
};
|
|
28251
28384
|
}
|
|
28252
28385
|
|
|
@@ -28723,18 +28856,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
28723
28856
|
}
|
|
28724
28857
|
|
|
28725
28858
|
// src/commands/review/warnOutOfDiff.ts
|
|
28726
|
-
import
|
|
28859
|
+
import chalk207 from "chalk";
|
|
28727
28860
|
function warnOutOfDiff(outOfDiff) {
|
|
28728
28861
|
if (outOfDiff.length === 0) return;
|
|
28729
28862
|
console.warn(
|
|
28730
|
-
|
|
28863
|
+
chalk207.yellow(
|
|
28731
28864
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
28732
28865
|
)
|
|
28733
28866
|
);
|
|
28734
28867
|
for (const finding of outOfDiff) {
|
|
28735
28868
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
28736
28869
|
console.warn(
|
|
28737
|
-
` ${
|
|
28870
|
+
` ${chalk207.yellow("\xB7")} ${finding.title} ${chalk207.dim(
|
|
28738
28871
|
`(${finding.file}:${range})`
|
|
28739
28872
|
)}`
|
|
28740
28873
|
);
|
|
@@ -28758,18 +28891,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
28758
28891
|
}
|
|
28759
28892
|
|
|
28760
28893
|
// src/commands/review/warnUnlocated.ts
|
|
28761
|
-
import
|
|
28894
|
+
import chalk208 from "chalk";
|
|
28762
28895
|
function warnUnlocated(unlocated) {
|
|
28763
28896
|
if (unlocated.length === 0) return;
|
|
28764
28897
|
console.warn(
|
|
28765
|
-
|
|
28898
|
+
chalk208.yellow(
|
|
28766
28899
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
28767
28900
|
)
|
|
28768
28901
|
);
|
|
28769
28902
|
for (const finding of unlocated) {
|
|
28770
|
-
const where = finding.location ||
|
|
28903
|
+
const where = finding.location || chalk208.dim("missing");
|
|
28771
28904
|
console.warn(
|
|
28772
|
-
` ${
|
|
28905
|
+
` ${chalk208.yellow("\xB7")} ${finding.title} ${chalk208.dim(`(${where})`)}`
|
|
28773
28906
|
);
|
|
28774
28907
|
}
|
|
28775
28908
|
}
|
|
@@ -28972,10 +29105,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
28972
29105
|
}
|
|
28973
29106
|
|
|
28974
29107
|
// src/commands/review/prepareReviewDir.ts
|
|
28975
|
-
import { existsSync as
|
|
29108
|
+
import { existsSync as existsSync61, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
28976
29109
|
function clearReviewFiles(paths) {
|
|
28977
29110
|
for (const path84 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
28978
|
-
if (
|
|
29111
|
+
if (existsSync61(path84)) unlinkSync17(path84);
|
|
28979
29112
|
}
|
|
28980
29113
|
}
|
|
28981
29114
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -29202,7 +29335,7 @@ function printReviewerFailures(results) {
|
|
|
29202
29335
|
}
|
|
29203
29336
|
|
|
29204
29337
|
// src/commands/review/runAndSynthesise.ts
|
|
29205
|
-
import { existsSync as
|
|
29338
|
+
import { existsSync as existsSync63, unlinkSync as unlinkSync19 } from "fs";
|
|
29206
29339
|
|
|
29207
29340
|
// src/commands/review/buildReviewerStdin.ts
|
|
29208
29341
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
|
|
@@ -29631,7 +29764,7 @@ function resolveClaude(args) {
|
|
|
29631
29764
|
}
|
|
29632
29765
|
|
|
29633
29766
|
// src/commands/review/runCodexReviewer.ts
|
|
29634
|
-
import { existsSync as
|
|
29767
|
+
import { existsSync as existsSync62, unlinkSync as unlinkSync18 } from "fs";
|
|
29635
29768
|
|
|
29636
29769
|
// src/commands/review/parseCodexEvent.ts
|
|
29637
29770
|
function isItemStarted(value) {
|
|
@@ -29683,7 +29816,7 @@ async function runCodexReviewer(spec) {
|
|
|
29683
29816
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
29684
29817
|
}
|
|
29685
29818
|
});
|
|
29686
|
-
if (result.exitCode !== 0 &&
|
|
29819
|
+
if (result.exitCode !== 0 && existsSync62(spec.outputPath)) {
|
|
29687
29820
|
unlinkSync18(spec.outputPath);
|
|
29688
29821
|
}
|
|
29689
29822
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -29838,7 +29971,7 @@ async function runAndSynthesise(args) {
|
|
|
29838
29971
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
29839
29972
|
return { ok: false, failures };
|
|
29840
29973
|
}
|
|
29841
|
-
if (anyFresh &&
|
|
29974
|
+
if (anyFresh && existsSync63(paths.synthesisPath)) {
|
|
29842
29975
|
unlinkSync19(paths.synthesisPath);
|
|
29843
29976
|
}
|
|
29844
29977
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -30025,13 +30158,13 @@ function registerReview(program2) {
|
|
|
30025
30158
|
|
|
30026
30159
|
// src/commands/rules/listRules.ts
|
|
30027
30160
|
import path67 from "path";
|
|
30028
|
-
import
|
|
30161
|
+
import chalk209 from "chalk";
|
|
30029
30162
|
function listRules(target) {
|
|
30030
30163
|
const resolved = path67.resolve(target ?? process.cwd());
|
|
30031
30164
|
const rules3 = readScopedRules(resolved);
|
|
30032
30165
|
if (rules3.length === 0) {
|
|
30033
30166
|
const label2 = path67.relative(process.cwd(), resolved) || ".";
|
|
30034
|
-
console.log(
|
|
30167
|
+
console.log(chalk209.gray(`No rules in scope for ${label2}`));
|
|
30035
30168
|
return;
|
|
30036
30169
|
}
|
|
30037
30170
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -30041,10 +30174,10 @@ function listRules(target) {
|
|
|
30041
30174
|
if (rule.source !== shown) {
|
|
30042
30175
|
shown = rule.source;
|
|
30043
30176
|
console.log(
|
|
30044
|
-
|
|
30177
|
+
chalk209.dim(base ? path67.relative(base, rule.source) : rule.source)
|
|
30045
30178
|
);
|
|
30046
30179
|
}
|
|
30047
|
-
console.log(` ${
|
|
30180
|
+
console.log(` ${chalk209.cyan(rule.code.padEnd(width))} ${rule.text}`);
|
|
30048
30181
|
}
|
|
30049
30182
|
}
|
|
30050
30183
|
|
|
@@ -30057,7 +30190,7 @@ function registerRules(program2) {
|
|
|
30057
30190
|
}
|
|
30058
30191
|
|
|
30059
30192
|
// src/commands/seq/seqAuth.ts
|
|
30060
|
-
import
|
|
30193
|
+
import chalk211 from "chalk";
|
|
30061
30194
|
|
|
30062
30195
|
// src/commands/seq/loadConnections.ts
|
|
30063
30196
|
function loadConnections2() {
|
|
@@ -30086,10 +30219,10 @@ function setDefaultConnection(name) {
|
|
|
30086
30219
|
}
|
|
30087
30220
|
|
|
30088
30221
|
// src/shared/assertUniqueName.ts
|
|
30089
|
-
import
|
|
30222
|
+
import chalk210 from "chalk";
|
|
30090
30223
|
function assertUniqueName(existingNames, name) {
|
|
30091
30224
|
if (existingNames.includes(name)) {
|
|
30092
|
-
console.error(
|
|
30225
|
+
console.error(chalk210.red(`Connection "${name}" already exists.`));
|
|
30093
30226
|
process.exit(1);
|
|
30094
30227
|
}
|
|
30095
30228
|
}
|
|
@@ -30107,16 +30240,16 @@ async function promptConnection2(existingNames) {
|
|
|
30107
30240
|
var seqAuth = createConnectionAuth({
|
|
30108
30241
|
load: loadConnections2,
|
|
30109
30242
|
save: saveConnections2,
|
|
30110
|
-
format: (c) => `${
|
|
30243
|
+
format: (c) => `${chalk211.bold(c.name)} ${c.url}`,
|
|
30111
30244
|
promptNew: promptConnection2,
|
|
30112
30245
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
30113
30246
|
});
|
|
30114
30247
|
|
|
30115
30248
|
// src/commands/seq/seqQuery.ts
|
|
30116
|
-
import
|
|
30249
|
+
import chalk215 from "chalk";
|
|
30117
30250
|
|
|
30118
30251
|
// src/commands/seq/fetchSeq.ts
|
|
30119
|
-
import
|
|
30252
|
+
import chalk212 from "chalk";
|
|
30120
30253
|
async function fetchSeq(conn, path84, params) {
|
|
30121
30254
|
const url = `${conn.url}${path84}?${params}`;
|
|
30122
30255
|
const response = await fetch(url, {
|
|
@@ -30127,7 +30260,7 @@ async function fetchSeq(conn, path84, params) {
|
|
|
30127
30260
|
});
|
|
30128
30261
|
if (!response.ok) {
|
|
30129
30262
|
const body = await response.text();
|
|
30130
|
-
console.error(
|
|
30263
|
+
console.error(chalk212.red(`Seq returned ${response.status}: ${body}`));
|
|
30131
30264
|
process.exit(1);
|
|
30132
30265
|
}
|
|
30133
30266
|
return response;
|
|
@@ -30186,23 +30319,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
30186
30319
|
}
|
|
30187
30320
|
|
|
30188
30321
|
// src/commands/seq/formatEvent.ts
|
|
30189
|
-
import
|
|
30322
|
+
import chalk213 from "chalk";
|
|
30190
30323
|
function levelColor(level) {
|
|
30191
30324
|
switch (level) {
|
|
30192
30325
|
case "Fatal":
|
|
30193
|
-
return
|
|
30326
|
+
return chalk213.bgRed.white;
|
|
30194
30327
|
case "Error":
|
|
30195
|
-
return
|
|
30328
|
+
return chalk213.red;
|
|
30196
30329
|
case "Warning":
|
|
30197
|
-
return
|
|
30330
|
+
return chalk213.yellow;
|
|
30198
30331
|
case "Information":
|
|
30199
|
-
return
|
|
30332
|
+
return chalk213.cyan;
|
|
30200
30333
|
case "Debug":
|
|
30201
|
-
return
|
|
30334
|
+
return chalk213.gray;
|
|
30202
30335
|
case "Verbose":
|
|
30203
|
-
return
|
|
30336
|
+
return chalk213.dim;
|
|
30204
30337
|
default:
|
|
30205
|
-
return
|
|
30338
|
+
return chalk213.white;
|
|
30206
30339
|
}
|
|
30207
30340
|
}
|
|
30208
30341
|
function levelAbbrev(level) {
|
|
@@ -30243,12 +30376,12 @@ function formatTimestamp(iso) {
|
|
|
30243
30376
|
function formatEvent(event) {
|
|
30244
30377
|
const color = levelColor(event.Level);
|
|
30245
30378
|
const abbrev = levelAbbrev(event.Level);
|
|
30246
|
-
const ts8 =
|
|
30379
|
+
const ts8 = chalk213.dim(formatTimestamp(event.Timestamp));
|
|
30247
30380
|
const msg = renderMessage(event);
|
|
30248
30381
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
30249
30382
|
if (event.Exception) {
|
|
30250
30383
|
for (const line of event.Exception.split("\n")) {
|
|
30251
|
-
lines2.push(
|
|
30384
|
+
lines2.push(chalk213.red(` ${line}`));
|
|
30252
30385
|
}
|
|
30253
30386
|
}
|
|
30254
30387
|
return lines2.join("\n");
|
|
@@ -30281,11 +30414,11 @@ function rejectTimestampFilter(filter) {
|
|
|
30281
30414
|
}
|
|
30282
30415
|
|
|
30283
30416
|
// src/shared/resolveNamedConnection.ts
|
|
30284
|
-
import
|
|
30417
|
+
import chalk214 from "chalk";
|
|
30285
30418
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
30286
30419
|
if (connections.length === 0) {
|
|
30287
30420
|
console.error(
|
|
30288
|
-
|
|
30421
|
+
chalk214.red(
|
|
30289
30422
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
30290
30423
|
)
|
|
30291
30424
|
);
|
|
@@ -30294,7 +30427,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
30294
30427
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
30295
30428
|
const connection = connections.find((c) => c.name === target);
|
|
30296
30429
|
if (!connection) {
|
|
30297
|
-
console.error(
|
|
30430
|
+
console.error(chalk214.red(`${kind} connection "${target}" not found.`));
|
|
30298
30431
|
process.exit(1);
|
|
30299
30432
|
}
|
|
30300
30433
|
return connection;
|
|
@@ -30323,7 +30456,7 @@ async function seqQuery(filter, options2) {
|
|
|
30323
30456
|
new URLSearchParams({ filter, count: String(count8) })
|
|
30324
30457
|
);
|
|
30325
30458
|
if (events.length === 0) {
|
|
30326
|
-
console.log(
|
|
30459
|
+
console.log(chalk215.yellow("No events found."));
|
|
30327
30460
|
return;
|
|
30328
30461
|
}
|
|
30329
30462
|
if (options2.json) {
|
|
@@ -30334,11 +30467,11 @@ async function seqQuery(filter, options2) {
|
|
|
30334
30467
|
for (const event of chronological) {
|
|
30335
30468
|
console.log(formatEvent(event));
|
|
30336
30469
|
}
|
|
30337
|
-
console.log(
|
|
30470
|
+
console.log(chalk215.dim(`
|
|
30338
30471
|
${events.length} events`));
|
|
30339
30472
|
if (events.length >= count8) {
|
|
30340
30473
|
console.log(
|
|
30341
|
-
|
|
30474
|
+
chalk215.yellow(
|
|
30342
30475
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
30343
30476
|
)
|
|
30344
30477
|
);
|
|
@@ -30346,10 +30479,10 @@ ${events.length} events`));
|
|
|
30346
30479
|
}
|
|
30347
30480
|
|
|
30348
30481
|
// src/shared/setNamedDefaultConnection.ts
|
|
30349
|
-
import
|
|
30482
|
+
import chalk216 from "chalk";
|
|
30350
30483
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
30351
30484
|
if (!connections.find((c) => c.name === name)) {
|
|
30352
|
-
console.error(
|
|
30485
|
+
console.error(chalk216.red(`Connection "${name}" not found.`));
|
|
30353
30486
|
process.exit(1);
|
|
30354
30487
|
}
|
|
30355
30488
|
setDefault(name);
|
|
@@ -30398,7 +30531,7 @@ function registerSignal(program2) {
|
|
|
30398
30531
|
}
|
|
30399
30532
|
|
|
30400
30533
|
// src/commands/sql/sqlAuth.ts
|
|
30401
|
-
import
|
|
30534
|
+
import chalk218 from "chalk";
|
|
30402
30535
|
|
|
30403
30536
|
// src/commands/sql/loadConnections.ts
|
|
30404
30537
|
function loadConnections3() {
|
|
@@ -30427,7 +30560,7 @@ function setDefaultConnection2(name) {
|
|
|
30427
30560
|
}
|
|
30428
30561
|
|
|
30429
30562
|
// src/commands/sql/promptConnection.ts
|
|
30430
|
-
import
|
|
30563
|
+
import chalk217 from "chalk";
|
|
30431
30564
|
async function promptConnection3(existingNames) {
|
|
30432
30565
|
const name = await promptInput("name", "Connection name:", "default");
|
|
30433
30566
|
assertUniqueName(existingNames, name);
|
|
@@ -30435,7 +30568,7 @@ async function promptConnection3(existingNames) {
|
|
|
30435
30568
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
30436
30569
|
const port = Number.parseInt(portStr, 10);
|
|
30437
30570
|
if (!Number.isFinite(port)) {
|
|
30438
|
-
console.error(
|
|
30571
|
+
console.error(chalk217.red(`Invalid port "${portStr}".`));
|
|
30439
30572
|
process.exit(1);
|
|
30440
30573
|
}
|
|
30441
30574
|
const user = await promptInput("user", "User:");
|
|
@@ -30448,13 +30581,13 @@ async function promptConnection3(existingNames) {
|
|
|
30448
30581
|
var sqlAuth = createConnectionAuth({
|
|
30449
30582
|
load: loadConnections3,
|
|
30450
30583
|
save: saveConnections3,
|
|
30451
|
-
format: (c) => `${
|
|
30584
|
+
format: (c) => `${chalk218.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
30452
30585
|
promptNew: promptConnection3,
|
|
30453
30586
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
30454
30587
|
});
|
|
30455
30588
|
|
|
30456
30589
|
// src/commands/sql/printTable.ts
|
|
30457
|
-
import
|
|
30590
|
+
import chalk219 from "chalk";
|
|
30458
30591
|
function formatCell(value) {
|
|
30459
30592
|
if (value === null || value === void 0) return "";
|
|
30460
30593
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -30463,7 +30596,7 @@ function formatCell(value) {
|
|
|
30463
30596
|
}
|
|
30464
30597
|
function printTable(rows) {
|
|
30465
30598
|
if (rows.length === 0) {
|
|
30466
|
-
console.log(
|
|
30599
|
+
console.log(chalk219.yellow("(no rows)"));
|
|
30467
30600
|
return;
|
|
30468
30601
|
}
|
|
30469
30602
|
const columns = Object.keys(rows[0]);
|
|
@@ -30471,13 +30604,13 @@ function printTable(rows) {
|
|
|
30471
30604
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
30472
30605
|
);
|
|
30473
30606
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
30474
|
-
console.log(
|
|
30475
|
-
console.log(
|
|
30607
|
+
console.log(chalk219.dim(header));
|
|
30608
|
+
console.log(chalk219.dim("-".repeat(header.length)));
|
|
30476
30609
|
for (const row of rows) {
|
|
30477
30610
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
30478
30611
|
console.log(line);
|
|
30479
30612
|
}
|
|
30480
|
-
console.log(
|
|
30613
|
+
console.log(chalk219.dim(`
|
|
30481
30614
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
30482
30615
|
}
|
|
30483
30616
|
|
|
@@ -30537,7 +30670,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
30537
30670
|
}
|
|
30538
30671
|
|
|
30539
30672
|
// src/commands/sql/sqlMutate.ts
|
|
30540
|
-
import
|
|
30673
|
+
import chalk220 from "chalk";
|
|
30541
30674
|
|
|
30542
30675
|
// src/commands/sql/isMutation.ts
|
|
30543
30676
|
var MUTATION_KEYWORDS = [
|
|
@@ -30571,7 +30704,7 @@ function isMutation(sql25) {
|
|
|
30571
30704
|
async function sqlMutate(query, connectionName) {
|
|
30572
30705
|
if (!isMutation(query)) {
|
|
30573
30706
|
console.error(
|
|
30574
|
-
|
|
30707
|
+
chalk220.red(
|
|
30575
30708
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
30576
30709
|
)
|
|
30577
30710
|
);
|
|
@@ -30581,18 +30714,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
30581
30714
|
const pool = await sqlConnect(conn);
|
|
30582
30715
|
try {
|
|
30583
30716
|
const result = await pool.request().query(query);
|
|
30584
|
-
console.log(
|
|
30717
|
+
console.log(chalk220.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
30585
30718
|
} finally {
|
|
30586
30719
|
await pool.close();
|
|
30587
30720
|
}
|
|
30588
30721
|
}
|
|
30589
30722
|
|
|
30590
30723
|
// src/commands/sql/sqlQuery.ts
|
|
30591
|
-
import
|
|
30724
|
+
import chalk221 from "chalk";
|
|
30592
30725
|
async function sqlQuery(query, connectionName) {
|
|
30593
30726
|
if (isMutation(query)) {
|
|
30594
30727
|
console.error(
|
|
30595
|
-
|
|
30728
|
+
chalk221.red(
|
|
30596
30729
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
30597
30730
|
)
|
|
30598
30731
|
);
|
|
@@ -30607,7 +30740,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
30607
30740
|
printTable(rows);
|
|
30608
30741
|
} else {
|
|
30609
30742
|
console.log(
|
|
30610
|
-
|
|
30743
|
+
chalk221.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
30611
30744
|
);
|
|
30612
30745
|
}
|
|
30613
30746
|
} finally {
|
|
@@ -30752,7 +30885,7 @@ function reportPrune(label2, result, force) {
|
|
|
30752
30885
|
// src/commands/sync/syncClaudeMd.ts
|
|
30753
30886
|
import * as fs41 from "fs";
|
|
30754
30887
|
import * as path70 from "path";
|
|
30755
|
-
import
|
|
30888
|
+
import chalk222 from "chalk";
|
|
30756
30889
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
30757
30890
|
const source = path70.join(claudeDir, "CLAUDE.md");
|
|
30758
30891
|
const target = path70.join(targetBase, "CLAUDE.md");
|
|
@@ -30761,14 +30894,14 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
30761
30894
|
const targetContent = fs41.readFileSync(target, "utf8");
|
|
30762
30895
|
if (sourceContent !== targetContent) {
|
|
30763
30896
|
console.log(
|
|
30764
|
-
|
|
30897
|
+
chalk222.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
30765
30898
|
);
|
|
30766
30899
|
console.log();
|
|
30767
30900
|
printDiff(targetContent, sourceContent);
|
|
30768
30901
|
if (!options2?.yes) {
|
|
30769
30902
|
printAutoConfirmHint();
|
|
30770
30903
|
const confirm = await promptConfirm(
|
|
30771
|
-
|
|
30904
|
+
chalk222.red("Overwrite existing CLAUDE.md?"),
|
|
30772
30905
|
false
|
|
30773
30906
|
);
|
|
30774
30907
|
if (!confirm) {
|
|
@@ -31001,7 +31134,7 @@ function syncPi(claudeDir, options2) {
|
|
|
31001
31134
|
// src/commands/sync/syncSettings.ts
|
|
31002
31135
|
import * as fs47 from "fs";
|
|
31003
31136
|
import * as path77 from "path";
|
|
31004
|
-
import
|
|
31137
|
+
import chalk223 from "chalk";
|
|
31005
31138
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
31006
31139
|
const source = path77.join(claudeDir, "settings.json");
|
|
31007
31140
|
const target = path77.join(targetBase, "settings.json");
|
|
@@ -31020,7 +31153,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
31020
31153
|
if (mergedContent !== normalizedTarget) {
|
|
31021
31154
|
if (!options2?.yes) {
|
|
31022
31155
|
console.log(
|
|
31023
|
-
|
|
31156
|
+
chalk223.yellow(
|
|
31024
31157
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
31025
31158
|
)
|
|
31026
31159
|
);
|
|
@@ -31028,7 +31161,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
31028
31161
|
printDiff(targetContent, mergedContent);
|
|
31029
31162
|
printAutoConfirmHint();
|
|
31030
31163
|
const confirm = await promptConfirm(
|
|
31031
|
-
|
|
31164
|
+
chalk223.red("Overwrite existing settings.json?"),
|
|
31032
31165
|
false
|
|
31033
31166
|
);
|
|
31034
31167
|
if (!confirm) {
|
|
@@ -31100,7 +31233,7 @@ function registerSync(program2) {
|
|
|
31100
31233
|
}
|
|
31101
31234
|
|
|
31102
31235
|
// src/commands/transcript/clean.ts
|
|
31103
|
-
import { existsSync as
|
|
31236
|
+
import { existsSync as existsSync68 } from "fs";
|
|
31104
31237
|
|
|
31105
31238
|
// src/commands/transcript/cleanText.ts
|
|
31106
31239
|
function cleanText(text18) {
|
|
@@ -31345,7 +31478,7 @@ function clean(file, options2 = {}) {
|
|
|
31345
31478
|
);
|
|
31346
31479
|
process.exit(1);
|
|
31347
31480
|
}
|
|
31348
|
-
if (!
|
|
31481
|
+
if (!existsSync68(file)) {
|
|
31349
31482
|
console.error(`Error: VTT file not found: ${file}`);
|
|
31350
31483
|
process.exit(1);
|
|
31351
31484
|
}
|
|
@@ -31428,21 +31561,21 @@ async function configure() {
|
|
|
31428
31561
|
}
|
|
31429
31562
|
|
|
31430
31563
|
// src/commands/transcript/list.ts
|
|
31431
|
-
import { existsSync as
|
|
31432
|
-
import { join as
|
|
31564
|
+
import { existsSync as existsSync69, readdirSync as readdirSync19, statSync as statSync11 } from "fs";
|
|
31565
|
+
import { join as join83 } from "path";
|
|
31433
31566
|
function list4() {
|
|
31434
31567
|
const { vttDir } = getTranscriptConfig();
|
|
31435
|
-
if (!
|
|
31568
|
+
if (!existsSync69(vttDir)) return;
|
|
31436
31569
|
for (const entry of readdirSync19(vttDir)) {
|
|
31437
31570
|
if (!entry.endsWith(".vtt")) continue;
|
|
31438
|
-
if (statSync11(
|
|
31571
|
+
if (statSync11(join83(vttDir, entry)).isDirectory()) continue;
|
|
31439
31572
|
console.log(entry);
|
|
31440
31573
|
}
|
|
31441
31574
|
}
|
|
31442
31575
|
|
|
31443
31576
|
// src/commands/transcript/move.ts
|
|
31444
|
-
import { existsSync as
|
|
31445
|
-
import { basename as basename21, join as
|
|
31577
|
+
import { existsSync as existsSync70, mkdirSync as mkdirSync27, renameSync as renameSync2, writeFileSync as writeFileSync43 } from "fs";
|
|
31578
|
+
import { basename as basename21, join as join84 } from "path";
|
|
31446
31579
|
|
|
31447
31580
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
31448
31581
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -31452,9 +31585,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
31452
31585
|
// src/commands/transcript/move.ts
|
|
31453
31586
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
31454
31587
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
31455
|
-
const processedDir =
|
|
31588
|
+
const processedDir = join84(vttDir, "processed");
|
|
31456
31589
|
mkdirSync27(processedDir, { recursive: true });
|
|
31457
|
-
renameSync2(sourcePath,
|
|
31590
|
+
renameSync2(sourcePath, join84(processedDir, filename));
|
|
31458
31591
|
}
|
|
31459
31592
|
function move(file, options2) {
|
|
31460
31593
|
const { date, client } = options2;
|
|
@@ -31464,19 +31597,19 @@ function move(file, options2) {
|
|
|
31464
31597
|
}
|
|
31465
31598
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
31466
31599
|
const filename = basename21(file);
|
|
31467
|
-
const sourcePath =
|
|
31468
|
-
if (!
|
|
31600
|
+
const sourcePath = join84(vttDir, filename);
|
|
31601
|
+
if (!existsSync70(sourcePath)) {
|
|
31469
31602
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
31470
31603
|
process.exit(1);
|
|
31471
31604
|
}
|
|
31472
31605
|
const base = basename21(filename, ".vtt").replace(/ Transcription$/, "");
|
|
31473
31606
|
const outputName = `${date} ${base}.md`;
|
|
31474
|
-
const formattedDir =
|
|
31607
|
+
const formattedDir = join84(transcriptsDir, client);
|
|
31475
31608
|
mkdirSync27(formattedDir, { recursive: true });
|
|
31476
|
-
const formattedPath =
|
|
31609
|
+
const formattedPath = join84(formattedDir, outputName);
|
|
31477
31610
|
writeFileSync43(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
31478
31611
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
31479
|
-
const summaryPath =
|
|
31612
|
+
const summaryPath = join84(summaryDir, client, outputName);
|
|
31480
31613
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
31481
31614
|
console.log(`Summary target: ${summaryPath}`);
|
|
31482
31615
|
}
|
|
@@ -31559,45 +31692,45 @@ function registerVerify(program2) {
|
|
|
31559
31692
|
|
|
31560
31693
|
// src/commands/voice/devices.ts
|
|
31561
31694
|
import { spawnSync as spawnSync8 } from "child_process";
|
|
31562
|
-
import { join as
|
|
31695
|
+
import { join as join86 } from "path";
|
|
31563
31696
|
|
|
31564
31697
|
// src/commands/voice/shared.ts
|
|
31565
|
-
import { homedir as
|
|
31566
|
-
import { dirname as dirname36, join as
|
|
31698
|
+
import { homedir as homedir25 } from "os";
|
|
31699
|
+
import { dirname as dirname36, join as join85 } from "path";
|
|
31567
31700
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
31568
31701
|
var __dirname6 = dirname36(fileURLToPath9(import.meta.url));
|
|
31569
|
-
var VOICE_DIR =
|
|
31702
|
+
var VOICE_DIR = join85(homedir25(), ".assist", "voice");
|
|
31570
31703
|
var voicePaths = {
|
|
31571
31704
|
dir: VOICE_DIR,
|
|
31572
|
-
pid:
|
|
31573
|
-
log:
|
|
31574
|
-
venv:
|
|
31575
|
-
lock:
|
|
31705
|
+
pid: join85(VOICE_DIR, "voice.pid"),
|
|
31706
|
+
log: join85(VOICE_DIR, "voice.log"),
|
|
31707
|
+
venv: join85(VOICE_DIR, ".venv"),
|
|
31708
|
+
lock: join85(VOICE_DIR, "voice.lock")
|
|
31576
31709
|
};
|
|
31577
31710
|
function getPythonDir() {
|
|
31578
|
-
return
|
|
31711
|
+
return join85(__dirname6, "commands", "voice", "python");
|
|
31579
31712
|
}
|
|
31580
31713
|
function getVenvPython() {
|
|
31581
|
-
return process.platform === "win32" ?
|
|
31714
|
+
return process.platform === "win32" ? join85(voicePaths.venv, "Scripts", "python.exe") : join85(voicePaths.venv, "bin", "python");
|
|
31582
31715
|
}
|
|
31583
31716
|
function getLockDir() {
|
|
31584
31717
|
const config = loadConfig();
|
|
31585
31718
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
31586
31719
|
}
|
|
31587
31720
|
function getLockFile() {
|
|
31588
|
-
return
|
|
31721
|
+
return join85(getLockDir(), "voice.lock");
|
|
31589
31722
|
}
|
|
31590
31723
|
|
|
31591
31724
|
// src/commands/voice/devices.ts
|
|
31592
31725
|
function devices() {
|
|
31593
|
-
const script =
|
|
31726
|
+
const script = join86(getPythonDir(), "list_devices.py");
|
|
31594
31727
|
spawnSync8(getVenvPython(), [script], { stdio: "inherit" });
|
|
31595
31728
|
}
|
|
31596
31729
|
|
|
31597
31730
|
// src/commands/voice/logs.ts
|
|
31598
|
-
import { existsSync as
|
|
31731
|
+
import { existsSync as existsSync71, readFileSync as readFileSync52 } from "fs";
|
|
31599
31732
|
function logs(options2) {
|
|
31600
|
-
if (!
|
|
31733
|
+
if (!existsSync71(voicePaths.log)) {
|
|
31601
31734
|
console.log("No voice log file found");
|
|
31602
31735
|
return;
|
|
31603
31736
|
}
|
|
@@ -31625,12 +31758,12 @@ function logs(options2) {
|
|
|
31625
31758
|
// src/commands/voice/setup.ts
|
|
31626
31759
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
31627
31760
|
import { mkdirSync as mkdirSync29 } from "fs";
|
|
31628
|
-
import { join as
|
|
31761
|
+
import { join as join88 } from "path";
|
|
31629
31762
|
|
|
31630
31763
|
// src/commands/voice/checkLockFile.ts
|
|
31631
31764
|
import { execSync as execSync58 } from "child_process";
|
|
31632
|
-
import { existsSync as
|
|
31633
|
-
import { join as
|
|
31765
|
+
import { existsSync as existsSync72, mkdirSync as mkdirSync28, readFileSync as readFileSync53, writeFileSync as writeFileSync44 } from "fs";
|
|
31766
|
+
import { join as join87 } from "path";
|
|
31634
31767
|
function isProcessAlive2(pid) {
|
|
31635
31768
|
try {
|
|
31636
31769
|
process.kill(pid, 0);
|
|
@@ -31641,7 +31774,7 @@ function isProcessAlive2(pid) {
|
|
|
31641
31774
|
}
|
|
31642
31775
|
function checkLockFile() {
|
|
31643
31776
|
const lockFile = getLockFile();
|
|
31644
|
-
if (!
|
|
31777
|
+
if (!existsSync72(lockFile)) return;
|
|
31645
31778
|
try {
|
|
31646
31779
|
const lock2 = JSON.parse(readFileSync53(lockFile, "utf8"));
|
|
31647
31780
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
@@ -31654,7 +31787,7 @@ function checkLockFile() {
|
|
|
31654
31787
|
}
|
|
31655
31788
|
}
|
|
31656
31789
|
function bootstrapVenv() {
|
|
31657
|
-
if (
|
|
31790
|
+
if (existsSync72(getVenvPython())) return;
|
|
31658
31791
|
console.log("Setting up Python environment...");
|
|
31659
31792
|
const pythonDir = getPythonDir();
|
|
31660
31793
|
execSync58(
|
|
@@ -31667,7 +31800,7 @@ function bootstrapVenv() {
|
|
|
31667
31800
|
}
|
|
31668
31801
|
function writeLockFile(pid) {
|
|
31669
31802
|
const lockFile = getLockFile();
|
|
31670
|
-
mkdirSync28(
|
|
31803
|
+
mkdirSync28(join87(lockFile, ".."), { recursive: true });
|
|
31671
31804
|
writeFileSync44(
|
|
31672
31805
|
lockFile,
|
|
31673
31806
|
JSON.stringify({
|
|
@@ -31683,7 +31816,7 @@ function setup() {
|
|
|
31683
31816
|
mkdirSync29(voicePaths.dir, { recursive: true });
|
|
31684
31817
|
bootstrapVenv();
|
|
31685
31818
|
console.log("\nDownloading models...\n");
|
|
31686
|
-
const script =
|
|
31819
|
+
const script = join88(getPythonDir(), "setup_models.py");
|
|
31687
31820
|
const result = spawnSync9(getVenvPython(), [script], {
|
|
31688
31821
|
stdio: "inherit",
|
|
31689
31822
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -31697,7 +31830,7 @@ function setup() {
|
|
|
31697
31830
|
// src/commands/voice/start.ts
|
|
31698
31831
|
import { spawn as spawn8 } from "child_process";
|
|
31699
31832
|
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync45 } from "fs";
|
|
31700
|
-
import { join as
|
|
31833
|
+
import { join as join89 } from "path";
|
|
31701
31834
|
|
|
31702
31835
|
// src/commands/voice/buildDaemonEnv.ts
|
|
31703
31836
|
function buildDaemonEnv(options2) {
|
|
@@ -31735,7 +31868,7 @@ function start2(options2) {
|
|
|
31735
31868
|
bootstrapVenv();
|
|
31736
31869
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
31737
31870
|
const env = buildDaemonEnv({ debug });
|
|
31738
|
-
const script =
|
|
31871
|
+
const script = join89(getPythonDir(), "voice_daemon.py");
|
|
31739
31872
|
const python = getVenvPython();
|
|
31740
31873
|
if (options2.foreground) {
|
|
31741
31874
|
spawnForeground(python, script, env);
|
|
@@ -31745,7 +31878,7 @@ function start2(options2) {
|
|
|
31745
31878
|
}
|
|
31746
31879
|
|
|
31747
31880
|
// src/commands/voice/status.ts
|
|
31748
|
-
import { existsSync as
|
|
31881
|
+
import { existsSync as existsSync73, readFileSync as readFileSync54 } from "fs";
|
|
31749
31882
|
function isProcessAlive3(pid) {
|
|
31750
31883
|
try {
|
|
31751
31884
|
process.kill(pid, 0);
|
|
@@ -31755,12 +31888,12 @@ function isProcessAlive3(pid) {
|
|
|
31755
31888
|
}
|
|
31756
31889
|
}
|
|
31757
31890
|
function readRecentLogs(count8) {
|
|
31758
|
-
if (!
|
|
31891
|
+
if (!existsSync73(voicePaths.log)) return [];
|
|
31759
31892
|
const lines2 = readFileSync54(voicePaths.log, "utf8").trim().split("\n");
|
|
31760
31893
|
return lines2.slice(-count8);
|
|
31761
31894
|
}
|
|
31762
31895
|
function status2() {
|
|
31763
|
-
if (!
|
|
31896
|
+
if (!existsSync73(voicePaths.pid)) {
|
|
31764
31897
|
console.log("Voice daemon: not running (no PID file)");
|
|
31765
31898
|
return;
|
|
31766
31899
|
}
|
|
@@ -31783,9 +31916,9 @@ function status2() {
|
|
|
31783
31916
|
}
|
|
31784
31917
|
|
|
31785
31918
|
// src/commands/voice/stop.ts
|
|
31786
|
-
import { existsSync as
|
|
31919
|
+
import { existsSync as existsSync74, readFileSync as readFileSync55, unlinkSync as unlinkSync20 } from "fs";
|
|
31787
31920
|
function stop2() {
|
|
31788
|
-
if (!
|
|
31921
|
+
if (!existsSync74(voicePaths.pid)) {
|
|
31789
31922
|
console.log("Voice daemon is not running (no PID file)");
|
|
31790
31923
|
return;
|
|
31791
31924
|
}
|
|
@@ -31802,7 +31935,7 @@ function stop2() {
|
|
|
31802
31935
|
}
|
|
31803
31936
|
try {
|
|
31804
31937
|
const lockFile = getLockFile();
|
|
31805
|
-
if (
|
|
31938
|
+
if (existsSync74(lockFile)) unlinkSync20(lockFile);
|
|
31806
31939
|
} catch {
|
|
31807
31940
|
}
|
|
31808
31941
|
console.log("Voice daemon stopped");
|
|
@@ -31866,11 +31999,11 @@ function changedPaths(from, cwd) {
|
|
|
31866
31999
|
}
|
|
31867
32000
|
|
|
31868
32001
|
// src/commands/watch/readBuiltVersion.ts
|
|
31869
|
-
import { join as
|
|
32002
|
+
import { join as join90 } from "path";
|
|
31870
32003
|
function readBuiltVersion(cwd) {
|
|
31871
32004
|
try {
|
|
31872
32005
|
const root = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
31873
|
-
return readPackageJson(
|
|
32006
|
+
return readPackageJson(join90(root, "package.json")).version ?? "unknown";
|
|
31874
32007
|
} catch {
|
|
31875
32008
|
return "unknown";
|
|
31876
32009
|
}
|
|
@@ -32207,7 +32340,7 @@ function resolveParams(params, cliArgs) {
|
|
|
32207
32340
|
}
|
|
32208
32341
|
|
|
32209
32342
|
// src/commands/run/resolveRunCwd.ts
|
|
32210
|
-
import { existsSync as
|
|
32343
|
+
import { existsSync as existsSync75 } from "fs";
|
|
32211
32344
|
import { resolve as resolve19 } from "path";
|
|
32212
32345
|
var MissingRunCwdError = class extends Error {
|
|
32213
32346
|
constructor(runName, cwd) {
|
|
@@ -32220,25 +32353,25 @@ var MissingRunCwdError = class extends Error {
|
|
|
32220
32353
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
32221
32354
|
if (!config.cwd) return void 0;
|
|
32222
32355
|
const cwd = resolve19(baseDir, config.cwd);
|
|
32223
|
-
if (!
|
|
32356
|
+
if (!existsSync75(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
32224
32357
|
return cwd;
|
|
32225
32358
|
}
|
|
32226
32359
|
|
|
32227
32360
|
// src/commands/run/runCommandToCompletion.ts
|
|
32228
32361
|
import { spawn as spawn9 } from "child_process";
|
|
32229
|
-
import { existsSync as
|
|
32362
|
+
import { existsSync as existsSync77 } from "fs";
|
|
32230
32363
|
|
|
32231
32364
|
// src/commands/run/resolveCommand.ts
|
|
32232
32365
|
import { execFileSync as execFileSync16 } from "child_process";
|
|
32233
|
-
import { existsSync as
|
|
32234
|
-
import { dirname as dirname37, join as
|
|
32366
|
+
import { existsSync as existsSync76 } from "fs";
|
|
32367
|
+
import { dirname as dirname37, join as join91, resolve as resolve20 } from "path";
|
|
32235
32368
|
function resolveCommand2(command) {
|
|
32236
32369
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
32237
32370
|
try {
|
|
32238
32371
|
const gitPath = execFileSync16("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
32239
32372
|
const gitRoot = resolve20(dirname37(gitPath), "..");
|
|
32240
|
-
const gitBash =
|
|
32241
|
-
if (
|
|
32373
|
+
const gitBash = join91(gitRoot, "bin", "bash.exe");
|
|
32374
|
+
if (existsSync76(gitBash)) return gitBash;
|
|
32242
32375
|
} catch {
|
|
32243
32376
|
return command;
|
|
32244
32377
|
}
|
|
@@ -32248,7 +32381,7 @@ function resolveCommand2(command) {
|
|
|
32248
32381
|
// src/commands/run/runCommandToCompletion.ts
|
|
32249
32382
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
32250
32383
|
return new Promise((resolveResult) => {
|
|
32251
|
-
if (cwd && !
|
|
32384
|
+
if (cwd && !existsSync77(cwd)) {
|
|
32252
32385
|
resolveResult({
|
|
32253
32386
|
kind: "failed",
|
|
32254
32387
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -32505,7 +32638,7 @@ function registerWatch(program2) {
|
|
|
32505
32638
|
|
|
32506
32639
|
// src/commands/roam/auth.ts
|
|
32507
32640
|
import { randomBytes } from "crypto";
|
|
32508
|
-
import
|
|
32641
|
+
import chalk224 from "chalk";
|
|
32509
32642
|
|
|
32510
32643
|
// src/commands/roam/waitForCallback.ts
|
|
32511
32644
|
import { createServer as createServer3 } from "http";
|
|
@@ -32636,13 +32769,13 @@ async function auth() {
|
|
|
32636
32769
|
saveGlobalConfig(config);
|
|
32637
32770
|
const state = randomBytes(16).toString("hex");
|
|
32638
32771
|
console.log(
|
|
32639
|
-
|
|
32772
|
+
chalk224.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
32640
32773
|
);
|
|
32641
|
-
console.log(
|
|
32642
|
-
console.log(
|
|
32643
|
-
console.log(
|
|
32774
|
+
console.log(chalk224.white("http://localhost:14523/callback\n"));
|
|
32775
|
+
console.log(chalk224.blue("Opening browser for authorization..."));
|
|
32776
|
+
console.log(chalk224.dim("Waiting for authorization callback..."));
|
|
32644
32777
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
32645
|
-
console.log(
|
|
32778
|
+
console.log(chalk224.dim("Exchanging code for tokens..."));
|
|
32646
32779
|
const tokens = await exchangeToken({
|
|
32647
32780
|
code,
|
|
32648
32781
|
clientId,
|
|
@@ -32658,14 +32791,14 @@ async function auth() {
|
|
|
32658
32791
|
};
|
|
32659
32792
|
saveGlobalConfig(config);
|
|
32660
32793
|
console.log(
|
|
32661
|
-
|
|
32794
|
+
chalk224.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
32662
32795
|
);
|
|
32663
32796
|
}
|
|
32664
32797
|
|
|
32665
32798
|
// src/commands/roam/postRoamActivity.ts
|
|
32666
32799
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
32667
32800
|
import { readdirSync as readdirSync20, readFileSync as readFileSync56, statSync as statSync12 } from "fs";
|
|
32668
|
-
import { join as
|
|
32801
|
+
import { join as join92 } from "path";
|
|
32669
32802
|
function findPortFile(roamDir) {
|
|
32670
32803
|
let entries;
|
|
32671
32804
|
try {
|
|
@@ -32674,7 +32807,7 @@ function findPortFile(roamDir) {
|
|
|
32674
32807
|
return void 0;
|
|
32675
32808
|
}
|
|
32676
32809
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
32677
|
-
const path84 =
|
|
32810
|
+
const path84 = join92(roamDir, name);
|
|
32678
32811
|
try {
|
|
32679
32812
|
return { path: path84, mtimeMs: statSync12(path84).mtimeMs };
|
|
32680
32813
|
} catch {
|
|
@@ -32686,7 +32819,7 @@ function findPortFile(roamDir) {
|
|
|
32686
32819
|
function postRoamActivity(app, event) {
|
|
32687
32820
|
const appData = process.env.APPDATA;
|
|
32688
32821
|
if (!appData) return;
|
|
32689
|
-
const portFile = findPortFile(
|
|
32822
|
+
const portFile = findPortFile(join92(appData, "Roam"));
|
|
32690
32823
|
if (!portFile) return;
|
|
32691
32824
|
let port;
|
|
32692
32825
|
try {
|
|
@@ -32819,7 +32952,7 @@ async function run3(name, args) {
|
|
|
32819
32952
|
|
|
32820
32953
|
// src/commands/run/add.ts
|
|
32821
32954
|
import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync46 } from "fs";
|
|
32822
|
-
import { join as
|
|
32955
|
+
import { join as join93 } from "path";
|
|
32823
32956
|
|
|
32824
32957
|
// src/commands/run/extractOption.ts
|
|
32825
32958
|
function extractOption(args, flag) {
|
|
@@ -32880,7 +33013,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
32880
33013
|
saveConfig(config);
|
|
32881
33014
|
}
|
|
32882
33015
|
function createCommandFile(name) {
|
|
32883
|
-
const dir =
|
|
33016
|
+
const dir = join93(".claude", "commands");
|
|
32884
33017
|
mkdirSync31(dir, { recursive: true });
|
|
32885
33018
|
const content = `---
|
|
32886
33019
|
description: Run ${name}
|
|
@@ -32888,7 +33021,7 @@ description: Run ${name}
|
|
|
32888
33021
|
|
|
32889
33022
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
32890
33023
|
`;
|
|
32891
|
-
const filePath =
|
|
33024
|
+
const filePath = join93(dir, `${name}.md`);
|
|
32892
33025
|
writeFileSync46(filePath, content);
|
|
32893
33026
|
console.log(`Created command file: ${filePath}`);
|
|
32894
33027
|
}
|
|
@@ -32944,8 +33077,8 @@ function link2() {
|
|
|
32944
33077
|
}
|
|
32945
33078
|
|
|
32946
33079
|
// src/commands/run/remove.ts
|
|
32947
|
-
import { existsSync as
|
|
32948
|
-
import { join as
|
|
33080
|
+
import { existsSync as existsSync78, unlinkSync as unlinkSync21 } from "fs";
|
|
33081
|
+
import { join as join94 } from "path";
|
|
32949
33082
|
function findRemoveIndex() {
|
|
32950
33083
|
const idx = process.argv.indexOf("remove");
|
|
32951
33084
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -32960,8 +33093,8 @@ function parseRemoveName() {
|
|
|
32960
33093
|
return process.argv[idx + 1];
|
|
32961
33094
|
}
|
|
32962
33095
|
function deleteCommandFile(name) {
|
|
32963
|
-
const filePath =
|
|
32964
|
-
if (
|
|
33096
|
+
const filePath = join94(".claude", "commands", `${name}.md`);
|
|
33097
|
+
if (existsSync78(filePath)) {
|
|
32965
33098
|
unlinkSync21(filePath);
|
|
32966
33099
|
console.log(`Deleted command file: ${filePath}`);
|
|
32967
33100
|
}
|
|
@@ -33006,10 +33139,10 @@ function registerRun(program2) {
|
|
|
33006
33139
|
|
|
33007
33140
|
// src/commands/screenshot/index.ts
|
|
33008
33141
|
import { execSync as execSync60 } from "child_process";
|
|
33009
|
-
import { existsSync as
|
|
33010
|
-
import { tmpdir as
|
|
33011
|
-
import { join as
|
|
33012
|
-
import
|
|
33142
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync32, unlinkSync as unlinkSync22, writeFileSync as writeFileSync47 } from "fs";
|
|
33143
|
+
import { tmpdir as tmpdir9 } from "os";
|
|
33144
|
+
import { join as join95, resolve as resolve21 } from "path";
|
|
33145
|
+
import chalk225 from "chalk";
|
|
33013
33146
|
|
|
33014
33147
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
33015
33148
|
var captureWindowPs1 = `
|
|
@@ -33138,14 +33271,14 @@ Write-Output $OutputPath
|
|
|
33138
33271
|
|
|
33139
33272
|
// src/commands/screenshot/index.ts
|
|
33140
33273
|
function buildOutputPath(outputDir, processName) {
|
|
33141
|
-
if (!
|
|
33274
|
+
if (!existsSync79(outputDir)) {
|
|
33142
33275
|
mkdirSync32(outputDir, { recursive: true });
|
|
33143
33276
|
}
|
|
33144
33277
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
33145
33278
|
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
33146
33279
|
}
|
|
33147
33280
|
function runPowerShellScript(processName, outputPath) {
|
|
33148
|
-
const scriptPath =
|
|
33281
|
+
const scriptPath = join95(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
33149
33282
|
writeFileSync47(scriptPath, captureWindowPs1, "utf8");
|
|
33150
33283
|
try {
|
|
33151
33284
|
execSync60(
|
|
@@ -33160,13 +33293,13 @@ function screenshot(processName) {
|
|
|
33160
33293
|
const config = loadConfig();
|
|
33161
33294
|
const outputDir = resolve21(config.screenshot.outputDir);
|
|
33162
33295
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
33163
|
-
console.log(
|
|
33296
|
+
console.log(chalk225.gray(`Capturing window for process "${processName}" ...`));
|
|
33164
33297
|
try {
|
|
33165
33298
|
runPowerShellScript(processName, outputPath);
|
|
33166
|
-
console.log(
|
|
33299
|
+
console.log(chalk225.green(`Screenshot saved: ${outputPath}`));
|
|
33167
33300
|
} catch (error) {
|
|
33168
33301
|
const msg = error instanceof Error ? error.message : String(error);
|
|
33169
|
-
console.error(
|
|
33302
|
+
console.error(chalk225.red(`Failed to capture screenshot: ${msg}`));
|
|
33170
33303
|
process.exit(1);
|
|
33171
33304
|
}
|
|
33172
33305
|
}
|
|
@@ -33483,12 +33616,12 @@ function toSessionRunInfo({
|
|
|
33483
33616
|
}
|
|
33484
33617
|
|
|
33485
33618
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
33486
|
-
import { existsSync as
|
|
33619
|
+
import { existsSync as existsSync80 } from "fs";
|
|
33487
33620
|
function joinRefusal(session) {
|
|
33488
33621
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
33489
33622
|
if (session.closing === true) return "the session is closing";
|
|
33490
33623
|
if (!session.cwd) return "the session has no working directory";
|
|
33491
|
-
if (!
|
|
33624
|
+
if (!existsSync80(session.cwd))
|
|
33492
33625
|
return "the session's workspace no longer exists";
|
|
33493
33626
|
return void 0;
|
|
33494
33627
|
}
|
|
@@ -33652,11 +33785,11 @@ function sessionBase(id, status3) {
|
|
|
33652
33785
|
}
|
|
33653
33786
|
|
|
33654
33787
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
33655
|
-
import { existsSync as
|
|
33788
|
+
import { existsSync as existsSync82 } from "fs";
|
|
33656
33789
|
import * as pty from "node-pty";
|
|
33657
33790
|
|
|
33658
33791
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
33659
|
-
import { chmodSync, existsSync as
|
|
33792
|
+
import { chmodSync, existsSync as existsSync81, statSync as statSync13 } from "fs";
|
|
33660
33793
|
import { createRequire as createRequire3 } from "module";
|
|
33661
33794
|
import path79 from "path";
|
|
33662
33795
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -33671,7 +33804,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
33671
33804
|
`${process.platform}-${process.arch}`,
|
|
33672
33805
|
"spawn-helper"
|
|
33673
33806
|
);
|
|
33674
|
-
if (!
|
|
33807
|
+
if (!existsSync81(helper)) return;
|
|
33675
33808
|
const mode = statSync13(helper).mode;
|
|
33676
33809
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
33677
33810
|
}
|
|
@@ -33707,7 +33840,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
33707
33840
|
});
|
|
33708
33841
|
}
|
|
33709
33842
|
function refuseMissingCwd(cwd, sessionId) {
|
|
33710
|
-
if (!cwd ||
|
|
33843
|
+
if (!cwd || existsSync82(cwd)) return;
|
|
33711
33844
|
daemonLog(
|
|
33712
33845
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
33713
33846
|
);
|
|
@@ -33889,17 +34022,17 @@ function setStatus2(session, newStatus) {
|
|
|
33889
34022
|
}
|
|
33890
34023
|
|
|
33891
34024
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
33892
|
-
import { existsSync as
|
|
34025
|
+
import { existsSync as existsSync84 } from "fs";
|
|
33893
34026
|
import { basename as basename22 } from "path";
|
|
33894
34027
|
|
|
33895
34028
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
33896
|
-
import { existsSync as
|
|
33897
|
-
import { join as
|
|
34029
|
+
import { existsSync as existsSync83 } from "fs";
|
|
34030
|
+
import { join as join98 } from "path";
|
|
33898
34031
|
|
|
33899
34032
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
33900
34033
|
import { statSync as statSync14 } from "fs";
|
|
33901
|
-
import { rm as
|
|
33902
|
-
import { join as
|
|
34034
|
+
import { rm as rm4 } from "fs/promises";
|
|
34035
|
+
import { join as join97 } from "path";
|
|
33903
34036
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
33904
34037
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
33905
34038
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -33910,7 +34043,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
33910
34043
|
}
|
|
33911
34044
|
daemonLog(`worktree ${worktreePath} deleting its directory directly: ${why}`);
|
|
33912
34045
|
try {
|
|
33913
|
-
await
|
|
34046
|
+
await rm4(worktreePath, {
|
|
33914
34047
|
recursive: true,
|
|
33915
34048
|
force: true,
|
|
33916
34049
|
maxRetries: 3,
|
|
@@ -33927,7 +34060,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
33927
34060
|
return { removed: true };
|
|
33928
34061
|
}
|
|
33929
34062
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
33930
|
-
return statSync14(
|
|
34063
|
+
return statSync14(join97(worktreePath, ".git"), {
|
|
33931
34064
|
throwIfNoEntry: false
|
|
33932
34065
|
})?.isDirectory() === true;
|
|
33933
34066
|
}
|
|
@@ -33963,7 +34096,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
33963
34096
|
);
|
|
33964
34097
|
}
|
|
33965
34098
|
function strandedReason(worktreePath, cause) {
|
|
33966
|
-
if (!
|
|
34099
|
+
if (!existsSync83(join98(worktreePath, ".git")))
|
|
33967
34100
|
return "its .git link is already gone";
|
|
33968
34101
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
33969
34102
|
return "git no longer recognises it as a working tree";
|
|
@@ -34015,7 +34148,7 @@ function reason3(error) {
|
|
|
34015
34148
|
|
|
34016
34149
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
34017
34150
|
async function reapWorktree(worktreePath, force = false) {
|
|
34018
|
-
if (!
|
|
34151
|
+
if (!existsSync84(worktreePath)) {
|
|
34019
34152
|
forgetWorktree(worktreePath);
|
|
34020
34153
|
daemonLog(
|
|
34021
34154
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -34040,7 +34173,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
34040
34173
|
}
|
|
34041
34174
|
function owningClone(worktreePath) {
|
|
34042
34175
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
34043
|
-
if (recorded &&
|
|
34176
|
+
if (recorded && existsSync84(recorded)) return recorded;
|
|
34044
34177
|
const detected = mainWorktree(worktreePath);
|
|
34045
34178
|
if (detected) return detected;
|
|
34046
34179
|
daemonLog(
|
|
@@ -34171,12 +34304,12 @@ function closeGateApplies(sessions, session) {
|
|
|
34171
34304
|
}
|
|
34172
34305
|
|
|
34173
34306
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
34174
|
-
import { existsSync as
|
|
34307
|
+
import { existsSync as existsSync85, watch } from "fs";
|
|
34175
34308
|
var DEBOUNCE_MS = 500;
|
|
34176
34309
|
var POLL_MS = 3e4;
|
|
34177
34310
|
function watchGitState(cwd, onChange) {
|
|
34178
34311
|
const common = gitCommonDir(cwd);
|
|
34179
|
-
if (!common || !
|
|
34312
|
+
if (!common || !existsSync85(common)) return void 0;
|
|
34180
34313
|
const watchers = [
|
|
34181
34314
|
watchGitDir(common, onChange),
|
|
34182
34315
|
pollGitState(cwd, onChange)
|
|
@@ -34653,10 +34786,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
34653
34786
|
}
|
|
34654
34787
|
|
|
34655
34788
|
// src/commands/sessions/daemon/exitReason.ts
|
|
34656
|
-
import { existsSync as
|
|
34789
|
+
import { existsSync as existsSync86 } from "fs";
|
|
34657
34790
|
import { resolve as resolve22 } from "path";
|
|
34658
34791
|
function exitDetail(session) {
|
|
34659
|
-
if (session.cwd && !
|
|
34792
|
+
if (session.cwd && !existsSync86(session.cwd))
|
|
34660
34793
|
return `working directory ${session.cwd} no longer exists`;
|
|
34661
34794
|
return missingRunConfigCwd(session);
|
|
34662
34795
|
}
|
|
@@ -34670,7 +34803,7 @@ function missingRunConfigCwd(session) {
|
|
|
34670
34803
|
const config = resolveRunConfig(session.runName, dir);
|
|
34671
34804
|
if (!config?.cwd) return void 0;
|
|
34672
34805
|
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
34673
|
-
if (
|
|
34806
|
+
if (existsSync86(configured)) return void 0;
|
|
34674
34807
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
34675
34808
|
}
|
|
34676
34809
|
|
|
@@ -34711,7 +34844,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
34711
34844
|
}
|
|
34712
34845
|
|
|
34713
34846
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
34714
|
-
import { existsSync as
|
|
34847
|
+
import { existsSync as existsSync87, mkdirSync as mkdirSync33, watch as watch2 } from "fs";
|
|
34715
34848
|
import { dirname as dirname39 } from "path";
|
|
34716
34849
|
|
|
34717
34850
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -34797,7 +34930,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
34797
34930
|
if (timer) clearTimeout(timer);
|
|
34798
34931
|
timer = setTimeout(read2, DEBOUNCE_MS2);
|
|
34799
34932
|
});
|
|
34800
|
-
if (
|
|
34933
|
+
if (existsSync87(path84)) read2();
|
|
34801
34934
|
}
|
|
34802
34935
|
function refreshActivity(session) {
|
|
34803
34936
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -36122,10 +36255,10 @@ function deferralNotice(persisted, cap2) {
|
|
|
36122
36255
|
|
|
36123
36256
|
// src/commands/sessions/daemon/worktree/underTempRoot.ts
|
|
36124
36257
|
import { realpathSync as realpathSync3 } from "fs";
|
|
36125
|
-
import { tmpdir as
|
|
36258
|
+
import { tmpdir as tmpdir10 } from "os";
|
|
36126
36259
|
import { sep as sep2 } from "path";
|
|
36127
36260
|
function tempRoots() {
|
|
36128
|
-
const raw =
|
|
36261
|
+
const raw = tmpdir10();
|
|
36129
36262
|
const roots = /* @__PURE__ */ new Set([raw]);
|
|
36130
36263
|
try {
|
|
36131
36264
|
roots.add(realpathSync3(raw));
|
|
@@ -36448,7 +36581,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
36448
36581
|
}
|
|
36449
36582
|
|
|
36450
36583
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
36451
|
-
import { existsSync as
|
|
36584
|
+
import { existsSync as existsSync90 } from "fs";
|
|
36452
36585
|
import { basename as basename24 } from "path";
|
|
36453
36586
|
|
|
36454
36587
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -36503,9 +36636,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
36503
36636
|
}
|
|
36504
36637
|
|
|
36505
36638
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
36506
|
-
import { existsSync as
|
|
36639
|
+
import { existsSync as existsSync89 } from "fs";
|
|
36507
36640
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
36508
|
-
if (!
|
|
36641
|
+
if (!existsSync89(clone)) {
|
|
36509
36642
|
for (const { path: path84 } of paths) forgetWorktree(path84);
|
|
36510
36643
|
daemonLog(
|
|
36511
36644
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -36671,7 +36804,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
36671
36804
|
);
|
|
36672
36805
|
continue;
|
|
36673
36806
|
}
|
|
36674
|
-
if (!
|
|
36807
|
+
if (!existsSync90(path84)) {
|
|
36675
36808
|
logVanishedTree(sessions, path84);
|
|
36676
36809
|
vanished.set(clone, [
|
|
36677
36810
|
...vanished.get(clone) ?? [],
|
|
@@ -37288,13 +37421,13 @@ async function defaultConnect() {
|
|
|
37288
37421
|
}
|
|
37289
37422
|
|
|
37290
37423
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
37291
|
-
import { existsSync as
|
|
37424
|
+
import { existsSync as existsSync91, readFileSync as readFileSync59 } from "fs";
|
|
37292
37425
|
import { posix as posix3 } from "path";
|
|
37293
37426
|
function hasPersistedWindowsSessions() {
|
|
37294
37427
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
37295
37428
|
if (!sessionsFile) return false;
|
|
37296
37429
|
try {
|
|
37297
|
-
if (!
|
|
37430
|
+
if (!existsSync91(sessionsFile)) return false;
|
|
37298
37431
|
const data = JSON.parse(readFileSync59(sessionsFile, "utf8"));
|
|
37299
37432
|
return Array.isArray(data) && data.length > 0;
|
|
37300
37433
|
} catch (error) {
|
|
@@ -38029,7 +38162,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
38029
38162
|
}
|
|
38030
38163
|
|
|
38031
38164
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
38032
|
-
import { existsSync as
|
|
38165
|
+
import { existsSync as existsSync94 } from "fs";
|
|
38033
38166
|
|
|
38034
38167
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
38035
38168
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -38060,11 +38193,11 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
38060
38193
|
}
|
|
38061
38194
|
|
|
38062
38195
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
38063
|
-
import { existsSync as
|
|
38196
|
+
import { existsSync as existsSync93 } from "fs";
|
|
38064
38197
|
|
|
38065
38198
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
38066
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
38067
|
-
import { join as
|
|
38199
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync92, mkdirSync as mkdirSync35 } from "fs";
|
|
38200
|
+
import { join as join100 } from "path";
|
|
38068
38201
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
38069
38202
|
const dir = projectDirForCwd(toCwd);
|
|
38070
38203
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -38073,8 +38206,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
38073
38206
|
);
|
|
38074
38207
|
return;
|
|
38075
38208
|
}
|
|
38076
|
-
const dest =
|
|
38077
|
-
if (
|
|
38209
|
+
const dest = join100(dir, `${claudeSessionId}.jsonl`);
|
|
38210
|
+
if (existsSync92(dest)) {
|
|
38078
38211
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
38079
38212
|
return;
|
|
38080
38213
|
}
|
|
@@ -38125,7 +38258,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
38125
38258
|
}
|
|
38126
38259
|
function cloneForReapedTree(missingCwd) {
|
|
38127
38260
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
38128
|
-
if (!clone || !
|
|
38261
|
+
if (!clone || !existsSync93(clone))
|
|
38129
38262
|
throw new Error(
|
|
38130
38263
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
38131
38264
|
);
|
|
@@ -38134,7 +38267,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
38134
38267
|
|
|
38135
38268
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
38136
38269
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
38137
|
-
if (!
|
|
38270
|
+
if (!existsSync94(cwd))
|
|
38138
38271
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
38139
38272
|
const id = ctx.spawnWith(
|
|
38140
38273
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -38975,7 +39108,7 @@ function registerSetStatusCommand(cmd) {
|
|
|
38975
39108
|
|
|
38976
39109
|
// src/commands/sessions/summarise/index.ts
|
|
38977
39110
|
import * as fs56 from "fs";
|
|
38978
|
-
import
|
|
39111
|
+
import chalk226 from "chalk";
|
|
38979
39112
|
|
|
38980
39113
|
// src/commands/sessions/summarise/shared.ts
|
|
38981
39114
|
import * as fs55 from "fs";
|
|
@@ -39034,22 +39167,22 @@ ${firstMessage}`);
|
|
|
39034
39167
|
async function summarise2(options2) {
|
|
39035
39168
|
const files = await discoverSessionFiles();
|
|
39036
39169
|
if (files.length === 0) {
|
|
39037
|
-
console.log(
|
|
39170
|
+
console.log(chalk226.yellow("No sessions found."));
|
|
39038
39171
|
return;
|
|
39039
39172
|
}
|
|
39040
39173
|
const toProcess = selectCandidates(files, options2);
|
|
39041
39174
|
if (toProcess.length === 0) {
|
|
39042
|
-
console.log(
|
|
39175
|
+
console.log(chalk226.green("All sessions already summarised."));
|
|
39043
39176
|
return;
|
|
39044
39177
|
}
|
|
39045
39178
|
console.log(
|
|
39046
|
-
|
|
39179
|
+
chalk226.cyan(
|
|
39047
39180
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
39048
39181
|
)
|
|
39049
39182
|
);
|
|
39050
39183
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
39051
39184
|
console.log(
|
|
39052
|
-
|
|
39185
|
+
chalk226.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk226.yellow(`, ${failed2} skipped`) : "")
|
|
39053
39186
|
);
|
|
39054
39187
|
}
|
|
39055
39188
|
function selectCandidates(files, options2) {
|
|
@@ -39069,16 +39202,16 @@ function processSessions(files) {
|
|
|
39069
39202
|
let failed2 = 0;
|
|
39070
39203
|
for (let i = 0; i < files.length; i++) {
|
|
39071
39204
|
const file = files[i];
|
|
39072
|
-
process.stdout.write(
|
|
39205
|
+
process.stdout.write(chalk226.dim(` [${i + 1}/${files.length}] `));
|
|
39073
39206
|
const summary = summariseSession(file);
|
|
39074
39207
|
if (summary) {
|
|
39075
39208
|
writeSummary(file, summary);
|
|
39076
39209
|
succeeded++;
|
|
39077
|
-
process.stdout.write(`${
|
|
39210
|
+
process.stdout.write(`${chalk226.green("\u2713")} ${summary}
|
|
39078
39211
|
`);
|
|
39079
39212
|
} else {
|
|
39080
39213
|
failed2++;
|
|
39081
|
-
process.stdout.write(` ${
|
|
39214
|
+
process.stdout.write(` ${chalk226.yellow("skip")}
|
|
39082
39215
|
`);
|
|
39083
39216
|
}
|
|
39084
39217
|
}
|
|
@@ -39099,7 +39232,7 @@ function registerSessions(program2) {
|
|
|
39099
39232
|
}
|
|
39100
39233
|
|
|
39101
39234
|
// src/commands/statusLine.ts
|
|
39102
|
-
import
|
|
39235
|
+
import chalk228 from "chalk";
|
|
39103
39236
|
|
|
39104
39237
|
// src/shared/contextLevel.ts
|
|
39105
39238
|
function contextLevel(pct) {
|
|
@@ -39109,7 +39242,7 @@ function contextLevel(pct) {
|
|
|
39109
39242
|
}
|
|
39110
39243
|
|
|
39111
39244
|
// src/commands/buildLimitsSegment.ts
|
|
39112
|
-
import
|
|
39245
|
+
import chalk227 from "chalk";
|
|
39113
39246
|
|
|
39114
39247
|
// src/shared/rateLimitLevel.ts
|
|
39115
39248
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -39147,9 +39280,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
39147
39280
|
|
|
39148
39281
|
// src/commands/buildLimitsSegment.ts
|
|
39149
39282
|
var LEVEL_COLOR = {
|
|
39150
|
-
ok:
|
|
39151
|
-
warn:
|
|
39152
|
-
over:
|
|
39283
|
+
ok: chalk227.green,
|
|
39284
|
+
warn: chalk227.yellow,
|
|
39285
|
+
over: chalk227.red
|
|
39153
39286
|
};
|
|
39154
39287
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
39155
39288
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -39181,9 +39314,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
39181
39314
|
|
|
39182
39315
|
// src/commands/readGitBranch.ts
|
|
39183
39316
|
import { readFileSync as readFileSync62, statSync as statSync16 } from "fs";
|
|
39184
|
-
import { isAbsolute as isAbsolute5, join as
|
|
39317
|
+
import { isAbsolute as isAbsolute5, join as join101, resolve as resolve23 } from "path";
|
|
39185
39318
|
function resolveGitDir(cwd) {
|
|
39186
|
-
const dotGit =
|
|
39319
|
+
const dotGit = join101(cwd, ".git");
|
|
39187
39320
|
let stat4;
|
|
39188
39321
|
try {
|
|
39189
39322
|
stat4 = statSync16(dotGit);
|
|
@@ -39213,7 +39346,7 @@ function readGitBranch(cwd) {
|
|
|
39213
39346
|
}
|
|
39214
39347
|
let head;
|
|
39215
39348
|
try {
|
|
39216
|
-
head = readFileSync62(
|
|
39349
|
+
head = readFileSync62(join101(gitDir, "HEAD"), "utf8");
|
|
39217
39350
|
} catch {
|
|
39218
39351
|
return null;
|
|
39219
39352
|
}
|
|
@@ -39245,7 +39378,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
39245
39378
|
}
|
|
39246
39379
|
|
|
39247
39380
|
// src/commands/statusLine.ts
|
|
39248
|
-
|
|
39381
|
+
chalk228.level = 3;
|
|
39249
39382
|
function formatNumber(num) {
|
|
39250
39383
|
return num.toLocaleString("en-US");
|
|
39251
39384
|
}
|
|
@@ -39253,9 +39386,9 @@ function colorizePercent(pct) {
|
|
|
39253
39386
|
const label2 = `${Math.round(pct)}%`;
|
|
39254
39387
|
switch (contextLevel(pct)) {
|
|
39255
39388
|
case "red":
|
|
39256
|
-
return
|
|
39389
|
+
return chalk228.red(label2);
|
|
39257
39390
|
case "yellow":
|
|
39258
|
-
return
|
|
39391
|
+
return chalk228.yellow(label2);
|
|
39259
39392
|
default:
|
|
39260
39393
|
return label2;
|
|
39261
39394
|
}
|
|
@@ -39268,7 +39401,7 @@ async function statusLine() {
|
|
|
39268
39401
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
39269
39402
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
39270
39403
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
39271
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
39404
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk228.cyan(branch2)} | ` : "";
|
|
39272
39405
|
console.log(
|
|
39273
39406
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
39274
39407
|
);
|
|
@@ -39338,10 +39471,10 @@ async function update2() {
|
|
|
39338
39471
|
}
|
|
39339
39472
|
|
|
39340
39473
|
// src/reportCliError.ts
|
|
39341
|
-
import
|
|
39474
|
+
import chalk229 from "chalk";
|
|
39342
39475
|
function reportCliError(error) {
|
|
39343
39476
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
39344
|
-
console.error(
|
|
39477
|
+
console.error(chalk229.red(error.message));
|
|
39345
39478
|
} else {
|
|
39346
39479
|
console.error(error);
|
|
39347
39480
|
}
|