@staff0rd/assist 0.596.0 → 0.597.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.597.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -19047,48 +19047,168 @@ 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 join46 } from "path";
|
|
19054
|
+
import chalk141 from "chalk";
|
|
19055
|
+
|
|
19056
|
+
// src/commands/criteriaExtension/findSignedXpi.ts
|
|
19057
|
+
import { existsSync as existsSync44 } from "fs";
|
|
19058
|
+
import { readdir } from "fs/promises";
|
|
19059
|
+
import { join as join43 } from "path";
|
|
19060
|
+
async function findSignedXpi(dir) {
|
|
19061
|
+
if (!existsSync44(dir)) return null;
|
|
19062
|
+
const name = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
19063
|
+
return name ? join43(dir, name) : null;
|
|
19064
|
+
}
|
|
19065
|
+
|
|
19066
|
+
// src/commands/criteriaExtension/signedAddonInstallPath.ts
|
|
19067
|
+
import { cp as cp2 } from "fs/promises";
|
|
19068
|
+
import chalk140 from "chalk";
|
|
19069
|
+
var WSL_WINDOWS_XPI = "/mnt/c/tools/criteria-extension.xpi";
|
|
19070
|
+
var WSL_WINDOWS_PATH2 = String.raw`C:\tools\criteria-extension.xpi`;
|
|
19071
|
+
async function signedAddonInstallPath(xpi) {
|
|
19072
|
+
if (detectPlatform() !== "wsl") return xpi;
|
|
19073
|
+
try {
|
|
19074
|
+
await cp2(xpi, WSL_WINDOWS_XPI);
|
|
19075
|
+
return WSL_WINDOWS_PATH2;
|
|
19076
|
+
} catch {
|
|
19077
|
+
console.log(
|
|
19078
|
+
chalk140.yellow(`could not copy the add-on to ${WSL_WINDOWS_PATH2}`)
|
|
19079
|
+
);
|
|
19080
|
+
return xpi;
|
|
19081
|
+
}
|
|
19082
|
+
}
|
|
19083
|
+
|
|
19084
|
+
// src/commands/criteriaExtension/signPreflightProblem.ts
|
|
19085
|
+
import { existsSync as existsSync45 } from "fs";
|
|
19086
|
+
import { join as join44 } from "path";
|
|
19087
|
+
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
19088
|
+
function signPreflightProblem(source) {
|
|
19089
|
+
if (!existsSync45(join44(source, "content.js")))
|
|
19090
|
+
return {
|
|
19091
|
+
message: `no content.js in ${source}`,
|
|
19092
|
+
hint: "run npm run build to bundle the content script"
|
|
19093
|
+
};
|
|
19094
|
+
if (!(process.env.WEB_EXT_API_KEY && process.env.WEB_EXT_API_SECRET))
|
|
19095
|
+
return {
|
|
19096
|
+
message: "WEB_EXT_API_KEY and WEB_EXT_API_SECRET are not both set",
|
|
19097
|
+
hint: `create an AMO API key at ${KEY_URL}`
|
|
19098
|
+
};
|
|
19099
|
+
return null;
|
|
19100
|
+
}
|
|
19101
|
+
|
|
19102
|
+
// src/commands/criteriaExtension/stageCriteriaExtension.ts
|
|
19103
|
+
import { cp as cp3, mkdir as mkdir4, readFile as readFile4, rm as rm2, writeFile as writeFile4 } from "fs/promises";
|
|
19104
|
+
import { join as join45 } from "path";
|
|
19105
|
+
|
|
19106
|
+
// src/commands/criteriaExtension/stampManifestVersion.ts
|
|
19107
|
+
function stampManifestVersion(manifest, version2) {
|
|
19108
|
+
const parsed = JSON.parse(manifest);
|
|
19109
|
+
return `${JSON.stringify({ ...parsed, version: version2 }, null, " ")}
|
|
19110
|
+
`;
|
|
19111
|
+
}
|
|
19112
|
+
|
|
19113
|
+
// src/commands/criteriaExtension/stageCriteriaExtension.ts
|
|
19114
|
+
async function stageCriteriaExtension(source, staging, version2) {
|
|
19115
|
+
await rm2(staging, { recursive: true, force: true });
|
|
19116
|
+
await mkdir4(staging, { recursive: true });
|
|
19117
|
+
await cp3(source, staging, { recursive: true });
|
|
19118
|
+
const manifest = join45(staging, "manifest.json");
|
|
19119
|
+
const stamped = stampManifestVersion(
|
|
19120
|
+
await readFile4(manifest, "utf8"),
|
|
19121
|
+
version2
|
|
19122
|
+
);
|
|
19123
|
+
await writeFile4(manifest, stamped);
|
|
19124
|
+
}
|
|
19125
|
+
|
|
19126
|
+
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19127
|
+
var ARTIFACTS_DIR = join46(homedir19(), ".assist", "criteria-extension");
|
|
19128
|
+
var STAGING_DIR = join46(tmpdir4(), "assist-criteria-extension");
|
|
19129
|
+
async function signCriteriaExtension() {
|
|
19130
|
+
const source = criteriaExtensionDir();
|
|
19131
|
+
const problem = signPreflightProblem(source);
|
|
19132
|
+
if (problem) {
|
|
19133
|
+
console.log(chalk141.red(problem.message));
|
|
19134
|
+
console.log(chalk141.dim(problem.hint));
|
|
19135
|
+
process.exitCode = 1;
|
|
19136
|
+
return;
|
|
19137
|
+
}
|
|
19138
|
+
const { version: version2 } = package_default;
|
|
19139
|
+
await stageCriteriaExtension(source, STAGING_DIR, version2);
|
|
19140
|
+
await rm3(ARTIFACTS_DIR, { recursive: true, force: true });
|
|
19141
|
+
console.log(chalk141.bold(`signing version ${version2} for self-distribution`));
|
|
19142
|
+
const { done: done2 } = spawnInherit("npx", [
|
|
19143
|
+
"--yes",
|
|
19144
|
+
"web-ext",
|
|
19145
|
+
"sign",
|
|
19146
|
+
`--source-dir=${STAGING_DIR}`,
|
|
19147
|
+
`--artifacts-dir=${ARTIFACTS_DIR}`,
|
|
19148
|
+
"--channel=unlisted"
|
|
19149
|
+
]);
|
|
19150
|
+
if (await done2 !== 0) {
|
|
19151
|
+
console.log(chalk141.red("web-ext sign failed"));
|
|
19152
|
+
process.exitCode = 1;
|
|
19153
|
+
return;
|
|
19154
|
+
}
|
|
19155
|
+
const xpi = await findSignedXpi(ARTIFACTS_DIR);
|
|
19156
|
+
if (!xpi) {
|
|
19157
|
+
console.log(chalk141.red(`web-ext wrote no .xpi into ${ARTIFACTS_DIR}`));
|
|
19158
|
+
process.exitCode = 1;
|
|
19159
|
+
return;
|
|
19160
|
+
}
|
|
19161
|
+
const path84 = await signedAddonInstallPath(xpi);
|
|
19162
|
+
console.log(chalk141.dim(`install the signed add-on from ${path84}`));
|
|
19163
|
+
}
|
|
19164
|
+
|
|
19050
19165
|
// src/commands/registerCriteriaExtension.ts
|
|
19051
19166
|
function registerCriteriaExtension(program2) {
|
|
19052
19167
|
program2.command("criteria-extension").description(
|
|
19053
19168
|
"Print the directory to load the acceptance criteria outliner browser extension from (load unpacked)"
|
|
19054
|
-
).
|
|
19169
|
+
).option(
|
|
19170
|
+
"--sign",
|
|
19171
|
+
"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)"
|
|
19172
|
+
).action(
|
|
19173
|
+
(options2) => options2.sign ? signCriteriaExtension() : criteriaExtension()
|
|
19174
|
+
);
|
|
19055
19175
|
}
|
|
19056
19176
|
|
|
19057
19177
|
// src/commands/db/reportMigrationStatus.ts
|
|
19058
|
-
import
|
|
19178
|
+
import chalk142 from "chalk";
|
|
19059
19179
|
function reportApplied(applied) {
|
|
19060
19180
|
if (applied.length === 0) {
|
|
19061
|
-
console.error(
|
|
19181
|
+
console.error(chalk142.green("Database is up to date; nothing to apply."));
|
|
19062
19182
|
return;
|
|
19063
19183
|
}
|
|
19064
19184
|
for (const migration of applied) {
|
|
19065
19185
|
console.error(
|
|
19066
|
-
|
|
19186
|
+
chalk142.green(`Applied migration ${migration.id} (${migration.name}).`)
|
|
19067
19187
|
);
|
|
19068
19188
|
}
|
|
19069
19189
|
}
|
|
19070
19190
|
function reportMigrationStatus(status3) {
|
|
19071
19191
|
if (status3.state === "in-sync") {
|
|
19072
19192
|
console.error(
|
|
19073
|
-
|
|
19193
|
+
chalk142.green(`In sync at migration ${status3.version} (latest).`)
|
|
19074
19194
|
);
|
|
19075
19195
|
return;
|
|
19076
19196
|
}
|
|
19077
19197
|
if (status3.state === "behind") {
|
|
19078
19198
|
console.error(
|
|
19079
|
-
|
|
19199
|
+
chalk142.yellow(
|
|
19080
19200
|
`Behind: applied ${status3.applied}, build expects ${status3.expected}.`
|
|
19081
19201
|
)
|
|
19082
19202
|
);
|
|
19083
19203
|
console.error(
|
|
19084
|
-
|
|
19204
|
+
chalk142.yellow(
|
|
19085
19205
|
`Pending: ${status3.pending.join(", ")}. Run \`assist db migrate\`.`
|
|
19086
19206
|
)
|
|
19087
19207
|
);
|
|
19088
19208
|
return;
|
|
19089
19209
|
}
|
|
19090
19210
|
console.error(
|
|
19091
|
-
|
|
19211
|
+
chalk142.red(
|
|
19092
19212
|
`Ahead: applied ${status3.applied}, build knows ${status3.expected}. Update assist.`
|
|
19093
19213
|
)
|
|
19094
19214
|
);
|
|
@@ -19123,22 +19243,22 @@ function registerDb(program2) {
|
|
|
19123
19243
|
|
|
19124
19244
|
// src/commands/dbMigration/dbMigrationConfirm.ts
|
|
19125
19245
|
import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs";
|
|
19126
|
-
import
|
|
19246
|
+
import chalk143 from "chalk";
|
|
19127
19247
|
|
|
19128
19248
|
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
19129
|
-
import { join as
|
|
19249
|
+
import { join as join47 } from "path";
|
|
19130
19250
|
function getMigrationPinPath(pin) {
|
|
19131
|
-
return
|
|
19251
|
+
return join47(getRestrictedDir(), `db-migration-pin-${pin}.json`);
|
|
19132
19252
|
}
|
|
19133
19253
|
function getMigrationApprovalPath(migrationId) {
|
|
19134
|
-
return
|
|
19254
|
+
return join47(getRestrictedDir(), `db-migration-approval-${migrationId}.json`);
|
|
19135
19255
|
}
|
|
19136
19256
|
|
|
19137
19257
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
19138
|
-
import { existsSync as
|
|
19258
|
+
import { existsSync as existsSync46, readFileSync as readFileSync31 } from "fs";
|
|
19139
19259
|
function readMigrationPinState(pin) {
|
|
19140
19260
|
const path84 = getMigrationPinPath(pin);
|
|
19141
|
-
if (!
|
|
19261
|
+
if (!existsSync46(path84)) return void 0;
|
|
19142
19262
|
try {
|
|
19143
19263
|
const state = JSON.parse(readFileSync31(path84, "utf8"));
|
|
19144
19264
|
if (state.pin !== pin) return void 0;
|
|
@@ -19154,7 +19274,7 @@ function dbMigrationConfirm(pin) {
|
|
|
19154
19274
|
sweepRestrictedDir();
|
|
19155
19275
|
const state = readMigrationPinState(pin);
|
|
19156
19276
|
if (!state) {
|
|
19157
|
-
console.error(
|
|
19277
|
+
console.error(chalk143.red(`No pending migration unlock for pin: ${pin}`));
|
|
19158
19278
|
process.exitCode = 1;
|
|
19159
19279
|
return;
|
|
19160
19280
|
}
|
|
@@ -19164,7 +19284,7 @@ function dbMigrationConfirm(pin) {
|
|
|
19164
19284
|
);
|
|
19165
19285
|
unlinkSync9(getMigrationPinPath(pin));
|
|
19166
19286
|
console.log(
|
|
19167
|
-
|
|
19287
|
+
chalk143.green(
|
|
19168
19288
|
`Approved creation of migration ${state.migrationId}. The next write of that migration module will be allowed once.`
|
|
19169
19289
|
)
|
|
19170
19290
|
);
|
|
@@ -19173,7 +19293,7 @@ function dbMigrationConfirm(pin) {
|
|
|
19173
19293
|
// src/commands/dbMigration/dbMigrationUnlock.ts
|
|
19174
19294
|
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync27 } from "fs";
|
|
19175
19295
|
import { randomInt as randomInt2 } from "crypto";
|
|
19176
|
-
import
|
|
19296
|
+
import chalk144 from "chalk";
|
|
19177
19297
|
|
|
19178
19298
|
// src/commands/dbMigration/nextMigrationId.ts
|
|
19179
19299
|
function nextMigrationId() {
|
|
@@ -19188,7 +19308,7 @@ function dbMigrationUnlock() {
|
|
|
19188
19308
|
sweepRestrictedDir();
|
|
19189
19309
|
writeFileSync27(getMigrationPinPath(pin), JSON.stringify({ pin, migrationId }));
|
|
19190
19310
|
console.error(
|
|
19191
|
-
|
|
19311
|
+
chalk144.yellow.bold(
|
|
19192
19312
|
"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
19313
|
)
|
|
19194
19314
|
);
|
|
@@ -19198,7 +19318,7 @@ function dbMigrationUnlock() {
|
|
|
19198
19318
|
});
|
|
19199
19319
|
if (!delivered) {
|
|
19200
19320
|
console.error(
|
|
19201
|
-
|
|
19321
|
+
chalk144.red(
|
|
19202
19322
|
"Could not deliver the confirmation pin via notification.\nThe migration cannot be approved until the notification channel works."
|
|
19203
19323
|
)
|
|
19204
19324
|
);
|
|
@@ -19208,7 +19328,7 @@ function dbMigrationUnlock() {
|
|
|
19208
19328
|
console.log(
|
|
19209
19329
|
`A confirmation pin was sent to your desktop notifications.
|
|
19210
19330
|
To approve creating migration ${migrationId}, run:
|
|
19211
|
-
${
|
|
19331
|
+
${chalk144.cyan(" assist db-migration confirm <PIN>")}
|
|
19212
19332
|
using the pin from that notification.`
|
|
19213
19333
|
);
|
|
19214
19334
|
}
|
|
@@ -19227,8 +19347,8 @@ function registerDbMigration(parent) {
|
|
|
19227
19347
|
}
|
|
19228
19348
|
|
|
19229
19349
|
// src/commands/deploy/redirect.ts
|
|
19230
|
-
import { existsSync as
|
|
19231
|
-
import
|
|
19350
|
+
import { existsSync as existsSync47, readFileSync as readFileSync32, writeFileSync as writeFileSync28 } from "fs";
|
|
19351
|
+
import chalk145 from "chalk";
|
|
19232
19352
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
19233
19353
|
if (!window.location.pathname.endsWith('/')) {
|
|
19234
19354
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -19236,24 +19356,24 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
19236
19356
|
</script>`;
|
|
19237
19357
|
function redirect() {
|
|
19238
19358
|
const indexPath = "index.html";
|
|
19239
|
-
if (!
|
|
19240
|
-
console.log(
|
|
19359
|
+
if (!existsSync47(indexPath)) {
|
|
19360
|
+
console.log(chalk145.yellow("No index.html found"));
|
|
19241
19361
|
return;
|
|
19242
19362
|
}
|
|
19243
19363
|
const content = readFileSync32(indexPath, "utf8");
|
|
19244
19364
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
19245
|
-
console.log(
|
|
19365
|
+
console.log(chalk145.dim("Trailing slash script already present"));
|
|
19246
19366
|
return;
|
|
19247
19367
|
}
|
|
19248
19368
|
const headCloseIndex = content.indexOf("</head>");
|
|
19249
19369
|
if (headCloseIndex === -1) {
|
|
19250
|
-
console.log(
|
|
19370
|
+
console.log(chalk145.red("Could not find </head> tag in index.html"));
|
|
19251
19371
|
return;
|
|
19252
19372
|
}
|
|
19253
19373
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
19254
19374
|
${content.slice(headCloseIndex)}`;
|
|
19255
19375
|
writeFileSync28(indexPath, newContent);
|
|
19256
|
-
console.log(
|
|
19376
|
+
console.log(chalk145.green("Added trailing slash redirect to index.html"));
|
|
19257
19377
|
}
|
|
19258
19378
|
|
|
19259
19379
|
// src/commands/registerDeploy.ts
|
|
@@ -19268,11 +19388,11 @@ import { execFileSync as execFileSync3 } from "child_process";
|
|
|
19268
19388
|
import { basename as basename13 } from "path";
|
|
19269
19389
|
|
|
19270
19390
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
19271
|
-
import { homedir as
|
|
19272
|
-
import { join as
|
|
19273
|
-
var BLOG_REPO_ROOT =
|
|
19391
|
+
import { homedir as homedir20 } from "os";
|
|
19392
|
+
import { join as join48 } from "path";
|
|
19393
|
+
var BLOG_REPO_ROOT = join48(homedir20(), "git/blog");
|
|
19274
19394
|
function loadBlogSkipDays(repoName) {
|
|
19275
|
-
const config = loadRawYaml(
|
|
19395
|
+
const config = loadRawYaml(join48(BLOG_REPO_ROOT, "assist.yml"));
|
|
19276
19396
|
const devlog = config.devlog;
|
|
19277
19397
|
const skip2 = devlog?.skip;
|
|
19278
19398
|
return new Set(skip2?.[repoName]);
|
|
@@ -19280,18 +19400,18 @@ function loadBlogSkipDays(repoName) {
|
|
|
19280
19400
|
|
|
19281
19401
|
// src/commands/devlog/shared.ts
|
|
19282
19402
|
import { execSync as execSync36 } from "child_process";
|
|
19283
|
-
import
|
|
19403
|
+
import chalk146 from "chalk";
|
|
19284
19404
|
|
|
19285
19405
|
// src/shared/getRepoName.ts
|
|
19286
|
-
import { existsSync as
|
|
19287
|
-
import { basename as basename12, join as
|
|
19406
|
+
import { existsSync as existsSync48, readFileSync as readFileSync33 } from "fs";
|
|
19407
|
+
import { basename as basename12, join as join49 } from "path";
|
|
19288
19408
|
function getRepoName() {
|
|
19289
19409
|
const config = loadConfig();
|
|
19290
19410
|
if (config.devlog?.name) {
|
|
19291
19411
|
return config.devlog.name;
|
|
19292
19412
|
}
|
|
19293
|
-
const packageJsonPath =
|
|
19294
|
-
if (
|
|
19413
|
+
const packageJsonPath = join49(process.cwd(), "package.json");
|
|
19414
|
+
if (existsSync48(packageJsonPath)) {
|
|
19295
19415
|
try {
|
|
19296
19416
|
const content = readFileSync33(packageJsonPath, "utf8");
|
|
19297
19417
|
const pkg = JSON.parse(content);
|
|
@@ -19306,8 +19426,8 @@ function getRepoName() {
|
|
|
19306
19426
|
|
|
19307
19427
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
19308
19428
|
import { readdirSync as readdirSync6, readFileSync as readFileSync34 } from "fs";
|
|
19309
|
-
import { join as
|
|
19310
|
-
var DEVLOG_DIR =
|
|
19429
|
+
import { join as join50 } from "path";
|
|
19430
|
+
var DEVLOG_DIR = join50(BLOG_REPO_ROOT, "src/content/devlog");
|
|
19311
19431
|
function extractFrontmatter(content) {
|
|
19312
19432
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
19313
19433
|
return fm?.[1] ?? null;
|
|
@@ -19335,7 +19455,7 @@ function readDevlogFiles(callback) {
|
|
|
19335
19455
|
try {
|
|
19336
19456
|
const files = readdirSync6(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
19337
19457
|
for (const file of files) {
|
|
19338
|
-
const content = readFileSync34(
|
|
19458
|
+
const content = readFileSync34(join50(DEVLOG_DIR, file), "utf8");
|
|
19339
19459
|
const parsed = parseFrontmatter(content, file);
|
|
19340
19460
|
if (parsed) callback(parsed);
|
|
19341
19461
|
}
|
|
@@ -19389,13 +19509,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
19389
19509
|
}
|
|
19390
19510
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
19391
19511
|
for (const commit2 of commits2) {
|
|
19392
|
-
console.log(` ${
|
|
19512
|
+
console.log(` ${chalk146.yellow(commit2.hash)} ${commit2.message}`);
|
|
19393
19513
|
if (verbose) {
|
|
19394
19514
|
const visibleFiles = commit2.files.filter(
|
|
19395
19515
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
19396
19516
|
);
|
|
19397
19517
|
for (const file of visibleFiles) {
|
|
19398
|
-
console.log(` ${
|
|
19518
|
+
console.log(` ${chalk146.dim(file)}`);
|
|
19399
19519
|
}
|
|
19400
19520
|
}
|
|
19401
19521
|
}
|
|
@@ -19420,15 +19540,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
19420
19540
|
}
|
|
19421
19541
|
|
|
19422
19542
|
// src/commands/devlog/list/printDateHeader.ts
|
|
19423
|
-
import
|
|
19543
|
+
import chalk147 from "chalk";
|
|
19424
19544
|
function printDateHeader(date, isSkipped, entries) {
|
|
19425
19545
|
if (isSkipped) {
|
|
19426
|
-
console.log(`${
|
|
19546
|
+
console.log(`${chalk147.bold.blue(date)} ${chalk147.dim("skipped")}`);
|
|
19427
19547
|
} else if (entries && entries.length > 0) {
|
|
19428
|
-
const entryInfo = entries.map((e) => `${
|
|
19429
|
-
console.log(`${
|
|
19548
|
+
const entryInfo = entries.map((e) => `${chalk147.green(e.version)} ${e.title}`).join(" | ");
|
|
19549
|
+
console.log(`${chalk147.bold.blue(date)} ${entryInfo}`);
|
|
19430
19550
|
} else {
|
|
19431
|
-
console.log(`${
|
|
19551
|
+
console.log(`${chalk147.bold.blue(date)} ${chalk147.red("\u26A0 devlog missing")}`);
|
|
19432
19552
|
}
|
|
19433
19553
|
}
|
|
19434
19554
|
|
|
@@ -19532,24 +19652,24 @@ function bumpVersion(version2, type) {
|
|
|
19532
19652
|
|
|
19533
19653
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
19534
19654
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
19535
|
-
import
|
|
19655
|
+
import chalk149 from "chalk";
|
|
19536
19656
|
|
|
19537
19657
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
19538
|
-
import
|
|
19658
|
+
import chalk148 from "chalk";
|
|
19539
19659
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
19540
19660
|
if (conventional && firstHash) {
|
|
19541
19661
|
const version2 = getVersionAtCommit(firstHash);
|
|
19542
19662
|
if (version2) {
|
|
19543
|
-
console.log(`${
|
|
19663
|
+
console.log(`${chalk148.bold("version:")} ${stripToMinor(version2)}`);
|
|
19544
19664
|
} else {
|
|
19545
|
-
console.log(`${
|
|
19665
|
+
console.log(`${chalk148.bold("version:")} ${chalk148.red("unknown")}`);
|
|
19546
19666
|
}
|
|
19547
19667
|
} else if (patchVersion && minorVersion) {
|
|
19548
19668
|
console.log(
|
|
19549
|
-
`${
|
|
19669
|
+
`${chalk148.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
19550
19670
|
);
|
|
19551
19671
|
} else {
|
|
19552
|
-
console.log(`${
|
|
19672
|
+
console.log(`${chalk148.bold("version:")} v0.1 (initial)`);
|
|
19553
19673
|
}
|
|
19554
19674
|
}
|
|
19555
19675
|
|
|
@@ -19597,16 +19717,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
19597
19717
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
19598
19718
|
}
|
|
19599
19719
|
function logName(repoName) {
|
|
19600
|
-
console.log(`${
|
|
19720
|
+
console.log(`${chalk149.bold("name:")} ${repoName}`);
|
|
19601
19721
|
}
|
|
19602
19722
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
19603
19723
|
logName(ctx.repoName);
|
|
19604
19724
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
19605
|
-
console.log(
|
|
19725
|
+
console.log(chalk149.bold.blue(targetDate));
|
|
19606
19726
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
19607
19727
|
}
|
|
19608
19728
|
function logNoCommits(lastInfo) {
|
|
19609
|
-
console.log(
|
|
19729
|
+
console.log(chalk149.dim(noCommitsMessage(!!lastInfo)));
|
|
19610
19730
|
}
|
|
19611
19731
|
|
|
19612
19732
|
// src/commands/devlog/next/index.ts
|
|
@@ -19647,11 +19767,11 @@ function next2(options2) {
|
|
|
19647
19767
|
import { execSync as execSync38 } from "child_process";
|
|
19648
19768
|
|
|
19649
19769
|
// src/commands/devlog/repos/printReposTable.ts
|
|
19650
|
-
import
|
|
19770
|
+
import chalk150 from "chalk";
|
|
19651
19771
|
function colorStatus(status3) {
|
|
19652
|
-
if (status3 === "missing") return
|
|
19653
|
-
if (status3 === "outdated") return
|
|
19654
|
-
return
|
|
19772
|
+
if (status3 === "missing") return chalk150.red(status3);
|
|
19773
|
+
if (status3 === "outdated") return chalk150.yellow(status3);
|
|
19774
|
+
return chalk150.green(status3);
|
|
19655
19775
|
}
|
|
19656
19776
|
function formatRow(row, nameWidth) {
|
|
19657
19777
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -19665,8 +19785,8 @@ function printReposTable(rows) {
|
|
|
19665
19785
|
"Last Devlog".padEnd(11),
|
|
19666
19786
|
"Status"
|
|
19667
19787
|
].join(" ");
|
|
19668
|
-
console.log(
|
|
19669
|
-
console.log(
|
|
19788
|
+
console.log(chalk150.dim(header));
|
|
19789
|
+
console.log(chalk150.dim("-".repeat(header.length)));
|
|
19670
19790
|
for (const row of rows) {
|
|
19671
19791
|
console.log(formatRow(row, nameWidth));
|
|
19672
19792
|
}
|
|
@@ -19723,15 +19843,15 @@ function repos(options2) {
|
|
|
19723
19843
|
|
|
19724
19844
|
// src/commands/devlog/skip.ts
|
|
19725
19845
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
19726
|
-
import { join as
|
|
19727
|
-
import
|
|
19846
|
+
import { join as join51 } from "path";
|
|
19847
|
+
import chalk151 from "chalk";
|
|
19728
19848
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
19729
19849
|
function getBlogConfigPath() {
|
|
19730
|
-
return
|
|
19850
|
+
return join51(BLOG_REPO_ROOT, "assist.yml");
|
|
19731
19851
|
}
|
|
19732
19852
|
function skip(date) {
|
|
19733
19853
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
19734
|
-
console.log(
|
|
19854
|
+
console.log(chalk151.red("Invalid date format. Use YYYY-MM-DD"));
|
|
19735
19855
|
process.exit(1);
|
|
19736
19856
|
}
|
|
19737
19857
|
const repoName = getRepoName();
|
|
@@ -19742,7 +19862,7 @@ function skip(date) {
|
|
|
19742
19862
|
const skipDays = skip2[repoName] ?? [];
|
|
19743
19863
|
if (skipDays.includes(date)) {
|
|
19744
19864
|
console.log(
|
|
19745
|
-
|
|
19865
|
+
chalk151.yellow(`${date} is already in skip list for ${repoName}`)
|
|
19746
19866
|
);
|
|
19747
19867
|
return;
|
|
19748
19868
|
}
|
|
@@ -19752,20 +19872,20 @@ function skip(date) {
|
|
|
19752
19872
|
devlog.skip = skip2;
|
|
19753
19873
|
config.devlog = devlog;
|
|
19754
19874
|
writeFileSync29(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
19755
|
-
console.log(
|
|
19875
|
+
console.log(chalk151.green(`Added ${date} to skip list for ${repoName}`));
|
|
19756
19876
|
}
|
|
19757
19877
|
|
|
19758
19878
|
// src/commands/devlog/version.ts
|
|
19759
|
-
import
|
|
19879
|
+
import chalk152 from "chalk";
|
|
19760
19880
|
function version() {
|
|
19761
19881
|
const config = loadConfig();
|
|
19762
19882
|
const name = getRepoName();
|
|
19763
19883
|
const lastInfo = getLastVersionInfo(name, config);
|
|
19764
19884
|
const lastVersion = lastInfo?.version ?? null;
|
|
19765
19885
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
19766
|
-
console.log(`${
|
|
19767
|
-
console.log(`${
|
|
19768
|
-
console.log(`${
|
|
19886
|
+
console.log(`${chalk152.bold("name:")} ${name}`);
|
|
19887
|
+
console.log(`${chalk152.bold("last:")} ${lastVersion ?? chalk152.dim("none")}`);
|
|
19888
|
+
console.log(`${chalk152.bold("next:")} ${nextVersion ?? chalk152.dim("none")}`);
|
|
19769
19889
|
}
|
|
19770
19890
|
|
|
19771
19891
|
// src/commands/registerDevlog.ts
|
|
@@ -19789,8 +19909,8 @@ function registerDevlog(program2) {
|
|
|
19789
19909
|
|
|
19790
19910
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
19791
19911
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7 } from "fs";
|
|
19792
|
-
import { join as
|
|
19793
|
-
import
|
|
19912
|
+
import { join as join52 } from "path";
|
|
19913
|
+
import chalk153 from "chalk";
|
|
19794
19914
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
19795
19915
|
function isLockedDll(debugDir) {
|
|
19796
19916
|
let files;
|
|
@@ -19801,7 +19921,7 @@ function isLockedDll(debugDir) {
|
|
|
19801
19921
|
}
|
|
19802
19922
|
for (const file of files) {
|
|
19803
19923
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
19804
|
-
const dllPath =
|
|
19924
|
+
const dllPath = join52(debugDir, file);
|
|
19805
19925
|
try {
|
|
19806
19926
|
const fd = openSync3(dllPath, "r+");
|
|
19807
19927
|
closeSync3(fd);
|
|
@@ -19819,13 +19939,13 @@ function findFirstLockedDll(dir) {
|
|
|
19819
19939
|
return null;
|
|
19820
19940
|
}
|
|
19821
19941
|
if (entries.includes("bin")) {
|
|
19822
|
-
const locked = isLockedDll(
|
|
19942
|
+
const locked = isLockedDll(join52(dir, "bin", "Debug"));
|
|
19823
19943
|
if (locked) return locked;
|
|
19824
19944
|
}
|
|
19825
19945
|
for (const entry of entries) {
|
|
19826
19946
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
19827
19947
|
continue;
|
|
19828
|
-
const found = findFirstLockedDll(
|
|
19948
|
+
const found = findFirstLockedDll(join52(dir, entry));
|
|
19829
19949
|
if (found) return found;
|
|
19830
19950
|
}
|
|
19831
19951
|
return null;
|
|
@@ -19837,14 +19957,14 @@ function checkBuildLocks(startDir) {
|
|
|
19837
19957
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
19838
19958
|
if (locked) {
|
|
19839
19959
|
console.error(
|
|
19840
|
-
|
|
19960
|
+
chalk153.red("Build output locked (is VS debugging?): ") + locked
|
|
19841
19961
|
);
|
|
19842
19962
|
process.exit(1);
|
|
19843
19963
|
}
|
|
19844
19964
|
}
|
|
19845
19965
|
async function checkBuildLocksCommand() {
|
|
19846
19966
|
checkBuildLocks();
|
|
19847
|
-
console.log(
|
|
19967
|
+
console.log(chalk153.green("No build locks detected"));
|
|
19848
19968
|
}
|
|
19849
19969
|
|
|
19850
19970
|
// src/commands/dotnet/buildTree.ts
|
|
@@ -19943,30 +20063,30 @@ function escapeRegex(s) {
|
|
|
19943
20063
|
}
|
|
19944
20064
|
|
|
19945
20065
|
// src/commands/dotnet/printTree.ts
|
|
19946
|
-
import
|
|
20066
|
+
import chalk154 from "chalk";
|
|
19947
20067
|
function printNodes(nodes, prefix2) {
|
|
19948
20068
|
for (let i = 0; i < nodes.length; i++) {
|
|
19949
20069
|
const isLast = i === nodes.length - 1;
|
|
19950
20070
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
19951
20071
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
19952
20072
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
19953
|
-
const label2 = isMissing ?
|
|
20073
|
+
const label2 = isMissing ? chalk154.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
19954
20074
|
console.log(`${prefix2}${connector}${label2}`);
|
|
19955
20075
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
19956
20076
|
}
|
|
19957
20077
|
}
|
|
19958
20078
|
function printTree(tree, totalCount, solutions) {
|
|
19959
|
-
console.log(
|
|
19960
|
-
console.log(
|
|
20079
|
+
console.log(chalk154.bold("\nProject Dependency Tree"));
|
|
20080
|
+
console.log(chalk154.cyan(tree.relativePath));
|
|
19961
20081
|
printNodes(tree.children, "");
|
|
19962
|
-
console.log(
|
|
20082
|
+
console.log(chalk154.dim(`
|
|
19963
20083
|
${totalCount} projects total (including root)`));
|
|
19964
|
-
console.log(
|
|
20084
|
+
console.log(chalk154.bold("\nSolution Membership"));
|
|
19965
20085
|
if (solutions.length === 0) {
|
|
19966
|
-
console.log(
|
|
20086
|
+
console.log(chalk154.yellow(" Not found in any .sln"));
|
|
19967
20087
|
} else {
|
|
19968
20088
|
for (const sln of solutions) {
|
|
19969
|
-
console.log(` ${
|
|
20089
|
+
console.log(` ${chalk154.green(sln)}`);
|
|
19970
20090
|
}
|
|
19971
20091
|
}
|
|
19972
20092
|
console.log();
|
|
@@ -19993,18 +20113,18 @@ function printJson(tree, totalCount, solutions) {
|
|
|
19993
20113
|
}
|
|
19994
20114
|
|
|
19995
20115
|
// src/commands/dotnet/resolveCsproj.ts
|
|
19996
|
-
import { existsSync as
|
|
20116
|
+
import { existsSync as existsSync49 } from "fs";
|
|
19997
20117
|
import path42 from "path";
|
|
19998
|
-
import
|
|
20118
|
+
import chalk155 from "chalk";
|
|
19999
20119
|
function resolveCsproj(csprojPath) {
|
|
20000
20120
|
const resolved = path42.resolve(csprojPath);
|
|
20001
|
-
if (!
|
|
20002
|
-
console.error(
|
|
20121
|
+
if (!existsSync49(resolved)) {
|
|
20122
|
+
console.error(chalk155.red(`File not found: ${resolved}`));
|
|
20003
20123
|
process.exit(1);
|
|
20004
20124
|
}
|
|
20005
20125
|
const repoRoot2 = findRepoRoot(path42.dirname(resolved));
|
|
20006
20126
|
if (!repoRoot2) {
|
|
20007
|
-
console.error(
|
|
20127
|
+
console.error(chalk155.red("Could not find git repository root"));
|
|
20008
20128
|
process.exit(1);
|
|
20009
20129
|
}
|
|
20010
20130
|
return { resolved, repoRoot: repoRoot2 };
|
|
@@ -20054,12 +20174,12 @@ function getChangedCsFiles(scope) {
|
|
|
20054
20174
|
}
|
|
20055
20175
|
|
|
20056
20176
|
// src/commands/dotnet/inSln.ts
|
|
20057
|
-
import
|
|
20177
|
+
import chalk156 from "chalk";
|
|
20058
20178
|
async function inSln(csprojPath) {
|
|
20059
20179
|
const { resolved, repoRoot: repoRoot2 } = resolveCsproj(csprojPath);
|
|
20060
20180
|
const solutions = findContainingSolutions(resolved, repoRoot2);
|
|
20061
20181
|
if (solutions.length === 0) {
|
|
20062
|
-
console.log(
|
|
20182
|
+
console.log(chalk156.yellow("Not found in any .sln file"));
|
|
20063
20183
|
process.exit(1);
|
|
20064
20184
|
}
|
|
20065
20185
|
for (const sln of solutions) {
|
|
@@ -20068,7 +20188,7 @@ async function inSln(csprojPath) {
|
|
|
20068
20188
|
}
|
|
20069
20189
|
|
|
20070
20190
|
// src/commands/dotnet/inspect.ts
|
|
20071
|
-
import
|
|
20191
|
+
import chalk162 from "chalk";
|
|
20072
20192
|
|
|
20073
20193
|
// src/shared/formatElapsed.ts
|
|
20074
20194
|
function formatElapsed(ms) {
|
|
@@ -20080,12 +20200,12 @@ function formatElapsed(ms) {
|
|
|
20080
20200
|
}
|
|
20081
20201
|
|
|
20082
20202
|
// src/commands/dotnet/displayIssues.ts
|
|
20083
|
-
import
|
|
20203
|
+
import chalk157 from "chalk";
|
|
20084
20204
|
var SEVERITY_COLOR = {
|
|
20085
|
-
ERROR:
|
|
20086
|
-
WARNING:
|
|
20087
|
-
SUGGESTION:
|
|
20088
|
-
HINT:
|
|
20205
|
+
ERROR: chalk157.red,
|
|
20206
|
+
WARNING: chalk157.yellow,
|
|
20207
|
+
SUGGESTION: chalk157.cyan,
|
|
20208
|
+
HINT: chalk157.dim
|
|
20089
20209
|
};
|
|
20090
20210
|
function groupByFile(issues) {
|
|
20091
20211
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -20101,15 +20221,15 @@ function groupByFile(issues) {
|
|
|
20101
20221
|
}
|
|
20102
20222
|
function displayIssues(issues) {
|
|
20103
20223
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
20104
|
-
console.log(
|
|
20224
|
+
console.log(chalk157.bold(file));
|
|
20105
20225
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
20106
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
20226
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk157.white;
|
|
20107
20227
|
console.log(
|
|
20108
|
-
` ${
|
|
20228
|
+
` ${chalk157.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
20109
20229
|
);
|
|
20110
20230
|
}
|
|
20111
20231
|
}
|
|
20112
|
-
console.log(
|
|
20232
|
+
console.log(chalk157.dim(`
|
|
20113
20233
|
${issues.length} issue(s) found`));
|
|
20114
20234
|
}
|
|
20115
20235
|
|
|
@@ -20166,17 +20286,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
20166
20286
|
}
|
|
20167
20287
|
|
|
20168
20288
|
// src/commands/dotnet/resolveSolution.ts
|
|
20169
|
-
import { existsSync as
|
|
20289
|
+
import { existsSync as existsSync50 } from "fs";
|
|
20170
20290
|
import path43 from "path";
|
|
20171
|
-
import
|
|
20291
|
+
import chalk159 from "chalk";
|
|
20172
20292
|
|
|
20173
20293
|
// src/commands/dotnet/findSolution.ts
|
|
20174
20294
|
import { readdirSync as readdirSync9 } from "fs";
|
|
20175
|
-
import { dirname as dirname25, join as
|
|
20176
|
-
import
|
|
20295
|
+
import { dirname as dirname25, join as join53 } from "path";
|
|
20296
|
+
import chalk158 from "chalk";
|
|
20177
20297
|
function findSlnInDir(dir) {
|
|
20178
20298
|
try {
|
|
20179
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
20299
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".sln")).map((f) => join53(dir, f));
|
|
20180
20300
|
} catch {
|
|
20181
20301
|
return [];
|
|
20182
20302
|
}
|
|
@@ -20189,17 +20309,17 @@ function findSolution() {
|
|
|
20189
20309
|
const slnFiles = findSlnInDir(current);
|
|
20190
20310
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
20191
20311
|
if (slnFiles.length > 1) {
|
|
20192
|
-
console.error(
|
|
20312
|
+
console.error(chalk158.red(`Multiple .sln files found in ${current}:`));
|
|
20193
20313
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
20194
20314
|
console.error(
|
|
20195
|
-
|
|
20315
|
+
chalk158.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
20196
20316
|
);
|
|
20197
20317
|
process.exit(1);
|
|
20198
20318
|
}
|
|
20199
20319
|
if (current === ceiling) break;
|
|
20200
20320
|
current = dirname25(current);
|
|
20201
20321
|
}
|
|
20202
|
-
console.error(
|
|
20322
|
+
console.error(chalk158.red("No .sln file found between cwd and repo root"));
|
|
20203
20323
|
process.exit(1);
|
|
20204
20324
|
}
|
|
20205
20325
|
|
|
@@ -20207,8 +20327,8 @@ function findSolution() {
|
|
|
20207
20327
|
function resolveSolution(sln) {
|
|
20208
20328
|
if (sln) {
|
|
20209
20329
|
const resolved = path43.resolve(sln);
|
|
20210
|
-
if (!
|
|
20211
|
-
console.error(
|
|
20330
|
+
if (!existsSync50(resolved)) {
|
|
20331
|
+
console.error(chalk159.red(`Solution file not found: ${resolved}`));
|
|
20212
20332
|
process.exit(1);
|
|
20213
20333
|
}
|
|
20214
20334
|
return resolved;
|
|
@@ -20247,23 +20367,23 @@ function parseInspectReport(json) {
|
|
|
20247
20367
|
|
|
20248
20368
|
// src/commands/dotnet/runInspectCode.ts
|
|
20249
20369
|
import { execSync as execSync40 } from "child_process";
|
|
20250
|
-
import { existsSync as
|
|
20251
|
-
import { tmpdir as
|
|
20370
|
+
import { existsSync as existsSync51, readFileSync as readFileSync37, unlinkSync as unlinkSync10 } from "fs";
|
|
20371
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
20252
20372
|
import path44 from "path";
|
|
20253
|
-
import
|
|
20373
|
+
import chalk160 from "chalk";
|
|
20254
20374
|
function assertJbInstalled() {
|
|
20255
20375
|
try {
|
|
20256
20376
|
execSync40("jb inspectcode --version", { stdio: "pipe" });
|
|
20257
20377
|
} catch {
|
|
20258
|
-
console.error(
|
|
20378
|
+
console.error(chalk160.red("jb is not installed. Install with:"));
|
|
20259
20379
|
console.error(
|
|
20260
|
-
|
|
20380
|
+
chalk160.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
20261
20381
|
);
|
|
20262
20382
|
process.exit(1);
|
|
20263
20383
|
}
|
|
20264
20384
|
}
|
|
20265
20385
|
function runInspectCode(slnPath, include, swea) {
|
|
20266
|
-
const reportPath = path44.join(
|
|
20386
|
+
const reportPath = path44.join(tmpdir5(), `inspect-${Date.now()}.xml`);
|
|
20267
20387
|
const includeFlag = include ? ` --include="${include}"` : "";
|
|
20268
20388
|
const sweaFlag = swea ? " --swea" : "";
|
|
20269
20389
|
try {
|
|
@@ -20275,11 +20395,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
20275
20395
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
20276
20396
|
process.stderr.write(error.stderr);
|
|
20277
20397
|
}
|
|
20278
|
-
console.error(
|
|
20398
|
+
console.error(chalk160.red("jb inspectcode failed"));
|
|
20279
20399
|
process.exit(1);
|
|
20280
20400
|
}
|
|
20281
|
-
if (!
|
|
20282
|
-
console.error(
|
|
20401
|
+
if (!existsSync51(reportPath)) {
|
|
20402
|
+
console.error(chalk160.red("Report file not generated"));
|
|
20283
20403
|
process.exit(1);
|
|
20284
20404
|
}
|
|
20285
20405
|
const xml = readFileSync37(reportPath, "utf8");
|
|
@@ -20289,7 +20409,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
20289
20409
|
|
|
20290
20410
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
20291
20411
|
import { execSync as execSync41 } from "child_process";
|
|
20292
|
-
import
|
|
20412
|
+
import chalk161 from "chalk";
|
|
20293
20413
|
function resolveMsbuildPath() {
|
|
20294
20414
|
const { run: run4 } = loadConfig();
|
|
20295
20415
|
const configs = resolveRunConfigs(run4, runConfigBaseDir());
|
|
@@ -20301,9 +20421,9 @@ function assertMsbuildInstalled() {
|
|
|
20301
20421
|
try {
|
|
20302
20422
|
execSync41(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
20303
20423
|
} catch {
|
|
20304
|
-
console.error(
|
|
20424
|
+
console.error(chalk161.red(`msbuild not found at: ${msbuild}`));
|
|
20305
20425
|
console.error(
|
|
20306
|
-
|
|
20426
|
+
chalk161.yellow(
|
|
20307
20427
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
20308
20428
|
)
|
|
20309
20429
|
);
|
|
@@ -20350,17 +20470,17 @@ function runEngine(resolved, changedFiles2, options2) {
|
|
|
20350
20470
|
// src/commands/dotnet/inspect.ts
|
|
20351
20471
|
function logScope(changedFiles2) {
|
|
20352
20472
|
if (changedFiles2 === null) {
|
|
20353
|
-
console.log(
|
|
20473
|
+
console.log(chalk162.dim("Inspecting full solution..."));
|
|
20354
20474
|
} else {
|
|
20355
20475
|
console.log(
|
|
20356
|
-
|
|
20476
|
+
chalk162.dim(`Inspecting ${changedFiles2.length} changed file(s)...`)
|
|
20357
20477
|
);
|
|
20358
20478
|
}
|
|
20359
20479
|
}
|
|
20360
20480
|
function reportResults(issues, elapsed) {
|
|
20361
20481
|
if (issues.length > 0) displayIssues(issues);
|
|
20362
|
-
else console.log(
|
|
20363
|
-
console.log(
|
|
20482
|
+
else console.log(chalk162.green("No issues found"));
|
|
20483
|
+
console.log(chalk162.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
20364
20484
|
if (issues.length > 0) process.exit(1);
|
|
20365
20485
|
}
|
|
20366
20486
|
async function inspect(sln, options2) {
|
|
@@ -20371,7 +20491,7 @@ async function inspect(sln, options2) {
|
|
|
20371
20491
|
const scope = parseScope(options2.scope);
|
|
20372
20492
|
const changedFiles2 = getChangedCsFiles(scope);
|
|
20373
20493
|
if (changedFiles2 !== null && changedFiles2.length === 0) {
|
|
20374
|
-
console.log(
|
|
20494
|
+
console.log(chalk162.green("No changed .cs files found"));
|
|
20375
20495
|
return;
|
|
20376
20496
|
}
|
|
20377
20497
|
logScope(changedFiles2);
|
|
@@ -20567,11 +20687,11 @@ function decideCommentGuard(input, existingContent) {
|
|
|
20567
20687
|
}
|
|
20568
20688
|
|
|
20569
20689
|
// src/commands/dbMigration/consumeMigrationApproval.ts
|
|
20570
|
-
import { existsSync as
|
|
20690
|
+
import { existsSync as existsSync52, unlinkSync as unlinkSync11 } from "fs";
|
|
20571
20691
|
function consumeMigrationApproval(migrationId) {
|
|
20572
20692
|
sweepRestrictedDir();
|
|
20573
20693
|
const path84 = getMigrationApprovalPath(migrationId);
|
|
20574
|
-
if (!
|
|
20694
|
+
if (!existsSync52(path84)) return false;
|
|
20575
20695
|
try {
|
|
20576
20696
|
unlinkSync11(path84);
|
|
20577
20697
|
return true;
|
|
@@ -20690,8 +20810,8 @@ function aggregateCommitters(authorLists) {
|
|
|
20690
20810
|
// src/shared/runGhGraphql.ts
|
|
20691
20811
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
20692
20812
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
20693
|
-
import { tmpdir as
|
|
20694
|
-
import { join as
|
|
20813
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
20814
|
+
import { join as join54 } from "path";
|
|
20695
20815
|
|
|
20696
20816
|
// src/shared/throwOnGraphqlErrors.ts
|
|
20697
20817
|
function throwOnGraphqlErrors(stdout) {
|
|
@@ -20720,7 +20840,7 @@ function buildArgs2(queryFile, vars) {
|
|
|
20720
20840
|
return args;
|
|
20721
20841
|
}
|
|
20722
20842
|
function runGhGraphql(mutation, vars) {
|
|
20723
|
-
const queryFile =
|
|
20843
|
+
const queryFile = join54(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
20724
20844
|
writeFileSync30(queryFile, mutation);
|
|
20725
20845
|
try {
|
|
20726
20846
|
const result = spawnSync4("gh", buildArgs2(queryFile, vars), {
|
|
@@ -20785,25 +20905,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
20785
20905
|
}
|
|
20786
20906
|
|
|
20787
20907
|
// src/commands/github/printCountTable.ts
|
|
20788
|
-
import
|
|
20908
|
+
import chalk163 from "chalk";
|
|
20789
20909
|
function printCountTable(labelHeader, rows) {
|
|
20790
20910
|
const labelWidth = Math.max(
|
|
20791
20911
|
labelHeader.length,
|
|
20792
20912
|
...rows.map((row) => row.label.length)
|
|
20793
20913
|
);
|
|
20794
20914
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
20795
|
-
console.log(
|
|
20796
|
-
console.log(
|
|
20915
|
+
console.log(chalk163.dim(header));
|
|
20916
|
+
console.log(chalk163.dim("-".repeat(header.length)));
|
|
20797
20917
|
for (const row of rows) {
|
|
20798
20918
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
20799
20919
|
}
|
|
20800
20920
|
}
|
|
20801
20921
|
|
|
20802
20922
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
20803
|
-
import
|
|
20923
|
+
import chalk164 from "chalk";
|
|
20804
20924
|
function printRepoAuthorBreakdown(repos2) {
|
|
20805
20925
|
for (const repo of repos2) {
|
|
20806
|
-
console.log(
|
|
20926
|
+
console.log(chalk164.bold(repo.name));
|
|
20807
20927
|
const authorWidth = Math.max(
|
|
20808
20928
|
0,
|
|
20809
20929
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -20886,10 +21006,10 @@ function parseTopCount(value) {
|
|
|
20886
21006
|
}
|
|
20887
21007
|
|
|
20888
21008
|
// src/commands/github/issue/fixStructure/applyAndVerifySubtree.ts
|
|
20889
|
-
import
|
|
21009
|
+
import chalk166 from "chalk";
|
|
20890
21010
|
|
|
20891
21011
|
// src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
|
|
20892
|
-
import
|
|
21012
|
+
import chalk165 from "chalk";
|
|
20893
21013
|
|
|
20894
21014
|
// src/shared/runGhGraphqlJson.ts
|
|
20895
21015
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
@@ -20940,7 +21060,7 @@ function writeLineNow(line) {
|
|
|
20940
21060
|
// src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
|
|
20941
21061
|
function applyFixStructurePlan(plan2) {
|
|
20942
21062
|
for (const entry of plan2.entries) {
|
|
20943
|
-
const where =
|
|
21063
|
+
const where = chalk165.cyan(`${entry.issue.repo}#${entry.issue.number}`);
|
|
20944
21064
|
const { typeChange, labelRemovals } = entry;
|
|
20945
21065
|
if (typeChange) {
|
|
20946
21066
|
writeLineNow(
|
|
@@ -21210,12 +21330,12 @@ function planSubtree(root, context) {
|
|
|
21210
21330
|
function applyAndVerifySubtree(target, plan2, context) {
|
|
21211
21331
|
if (plan2.typeChangeCount === 0 && plan2.labelRemovalCount === 0) return;
|
|
21212
21332
|
applyFixStructurePlan(plan2);
|
|
21213
|
-
writeLineNow(
|
|
21333
|
+
writeLineNow(chalk166.dim("Re-walking the subtree to confirm"));
|
|
21214
21334
|
assertNoResidualDrift(
|
|
21215
21335
|
planSubtree(fetchRootIssue(target), context),
|
|
21216
21336
|
context.chain
|
|
21217
21337
|
);
|
|
21218
|
-
writeLineNow(
|
|
21338
|
+
writeLineNow(chalk166.green("Subtree normalised"));
|
|
21219
21339
|
}
|
|
21220
21340
|
|
|
21221
21341
|
// src/commands/github/issue/fixStructure/assertChainTypesExist.ts
|
|
@@ -21251,22 +21371,22 @@ function parseTypeChain(value) {
|
|
|
21251
21371
|
}
|
|
21252
21372
|
|
|
21253
21373
|
// src/commands/github/issue/fixStructure/printFixStructurePlan.ts
|
|
21254
|
-
import
|
|
21374
|
+
import chalk167 from "chalk";
|
|
21255
21375
|
function annotate(entry) {
|
|
21256
21376
|
const notes = [];
|
|
21257
21377
|
if (entry.level === null) {
|
|
21258
|
-
notes.push(
|
|
21378
|
+
notes.push(chalk167.red("deeper than the leaf level"));
|
|
21259
21379
|
} else if (entry.typeChange) {
|
|
21260
21380
|
notes.push(
|
|
21261
|
-
|
|
21381
|
+
chalk167.yellow(
|
|
21262
21382
|
`${entry.typeChange.from ?? "no type"} -> ${entry.typeChange.to}`
|
|
21263
21383
|
)
|
|
21264
21384
|
);
|
|
21265
21385
|
} else {
|
|
21266
|
-
notes.push(
|
|
21386
|
+
notes.push(chalk167.dim(entry.issue.typeName ?? "no type"));
|
|
21267
21387
|
}
|
|
21268
21388
|
for (const label2 of entry.labelRemovals) {
|
|
21269
|
-
notes.push(
|
|
21389
|
+
notes.push(chalk167.yellow(`-${label2.name}`));
|
|
21270
21390
|
}
|
|
21271
21391
|
return notes;
|
|
21272
21392
|
}
|
|
@@ -21274,22 +21394,22 @@ function formatCount(count8, noun) {
|
|
|
21274
21394
|
return `${count8} ${noun}${count8 === 1 ? "" : "s"}`;
|
|
21275
21395
|
}
|
|
21276
21396
|
function printFixStructurePlan(plan2, chain2, apply) {
|
|
21277
|
-
writeLineNow(
|
|
21397
|
+
writeLineNow(chalk167.dim(`chain: ${chain2.join(" > ")}`));
|
|
21278
21398
|
for (const entry of plan2.entries) {
|
|
21279
21399
|
const indent3 = " ".repeat(entry.issue.depth);
|
|
21280
|
-
const name =
|
|
21400
|
+
const name = chalk167.cyan(`${entry.issue.repo}#${entry.issue.number}`);
|
|
21281
21401
|
writeLineNow(
|
|
21282
21402
|
`${indent3}${name} ${entry.issue.title} [${annotate(entry).join(", ")}]`
|
|
21283
21403
|
);
|
|
21284
21404
|
}
|
|
21285
21405
|
if (plan2.typeChangeCount === 0 && plan2.labelRemovalCount === 0) {
|
|
21286
|
-
writeLineNow(
|
|
21406
|
+
writeLineNow(chalk167.green("Nothing to change"));
|
|
21287
21407
|
return;
|
|
21288
21408
|
}
|
|
21289
21409
|
writeLineNow(
|
|
21290
21410
|
`${formatCount(plan2.typeChangeCount, "type change")}, ${formatCount(plan2.labelRemovalCount, "label removal")} planned`
|
|
21291
21411
|
);
|
|
21292
|
-
if (!apply) writeLineNow(
|
|
21412
|
+
if (!apply) writeLineNow(chalk167.dim("Dry run \u2014 nothing written"));
|
|
21293
21413
|
}
|
|
21294
21414
|
|
|
21295
21415
|
// src/commands/github/issue/fixStructure/resolveFixStructureTarget.ts
|
|
@@ -21627,24 +21747,24 @@ function fetchIssue2(number, repo) {
|
|
|
21627
21747
|
}
|
|
21628
21748
|
|
|
21629
21749
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
21630
|
-
import { existsSync as
|
|
21750
|
+
import { existsSync as existsSync53, readFileSync as readFileSync38 } from "fs";
|
|
21631
21751
|
|
|
21632
21752
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
21633
|
-
import { join as
|
|
21753
|
+
import { join as join55 } from "path";
|
|
21634
21754
|
function issueWorkingFile(slug, number) {
|
|
21635
21755
|
const [owner = "unknown", repo = "unknown"] = slug.split("/");
|
|
21636
|
-
const dir =
|
|
21756
|
+
const dir = join55(getStoreDir(), "github-issues", owner, repo);
|
|
21637
21757
|
return {
|
|
21638
21758
|
dir,
|
|
21639
|
-
bodyPath:
|
|
21640
|
-
metaPath:
|
|
21759
|
+
bodyPath: join55(dir, `${number}.md`),
|
|
21760
|
+
metaPath: join55(dir, `${number}.json`)
|
|
21641
21761
|
};
|
|
21642
21762
|
}
|
|
21643
21763
|
|
|
21644
21764
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
21645
21765
|
function resumeIssueBody(slug, number, updatedAt) {
|
|
21646
21766
|
const { bodyPath, metaPath } = issueWorkingFile(slug, number);
|
|
21647
|
-
if (!
|
|
21767
|
+
if (!existsSync53(bodyPath) || !existsSync53(metaPath)) return void 0;
|
|
21648
21768
|
try {
|
|
21649
21769
|
const meta = JSON.parse(readFileSync38(metaPath, "utf8"));
|
|
21650
21770
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
@@ -21837,24 +21957,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
21837
21957
|
|
|
21838
21958
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
21839
21959
|
import {
|
|
21840
|
-
existsSync as
|
|
21960
|
+
existsSync as existsSync54,
|
|
21841
21961
|
readdirSync as readdirSync10,
|
|
21842
21962
|
readFileSync as readFileSync39,
|
|
21843
21963
|
rmSync as rmSync3,
|
|
21844
21964
|
statSync as statSync9
|
|
21845
21965
|
} from "fs";
|
|
21846
|
-
import { basename as basename14, join as
|
|
21966
|
+
import { basename as basename14, join as join58 } from "path";
|
|
21847
21967
|
|
|
21848
21968
|
// src/commands/handover/getHandoverPath.ts
|
|
21849
|
-
import { join as
|
|
21969
|
+
import { join as join56 } from "path";
|
|
21850
21970
|
function getHandoverPath(cwd = process.cwd()) {
|
|
21851
|
-
return
|
|
21971
|
+
return join56(cwd, ".assist", "HANDOVER.md");
|
|
21852
21972
|
}
|
|
21853
21973
|
|
|
21854
21974
|
// src/commands/handover/getHandoversDir.ts
|
|
21855
|
-
import { join as
|
|
21975
|
+
import { join as join57 } from "path";
|
|
21856
21976
|
function getHandoversDir(cwd = process.cwd()) {
|
|
21857
|
-
return
|
|
21977
|
+
return join57(cwd, ".assist", "handovers");
|
|
21858
21978
|
}
|
|
21859
21979
|
|
|
21860
21980
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -21892,10 +22012,10 @@ function summariseHandoverContent(content) {
|
|
|
21892
22012
|
|
|
21893
22013
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
21894
22014
|
function collectMarkdown(dir) {
|
|
21895
|
-
if (!
|
|
22015
|
+
if (!existsSync54(dir)) return [];
|
|
21896
22016
|
const out = [];
|
|
21897
22017
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
21898
|
-
const full =
|
|
22018
|
+
const full = join58(dir, entry.name);
|
|
21899
22019
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
21900
22020
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
21901
22021
|
}
|
|
@@ -21919,7 +22039,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
21919
22039
|
migrated++;
|
|
21920
22040
|
}
|
|
21921
22041
|
const handoverPath = getHandoverPath(cwd);
|
|
21922
|
-
if (
|
|
22042
|
+
if (existsSync54(handoverPath)) {
|
|
21923
22043
|
await migrateFile(orm, origin, handoverPath, statSync9(handoverPath).mtime);
|
|
21924
22044
|
migrated++;
|
|
21925
22045
|
}
|
|
@@ -22050,7 +22170,7 @@ function registerHandover(program2) {
|
|
|
22050
22170
|
}
|
|
22051
22171
|
|
|
22052
22172
|
// src/commands/jira/acceptanceCriteria.ts
|
|
22053
|
-
import
|
|
22173
|
+
import chalk168 from "chalk";
|
|
22054
22174
|
|
|
22055
22175
|
// src/commands/jira/adfToText.ts
|
|
22056
22176
|
function renderInline(node) {
|
|
@@ -22117,7 +22237,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
22117
22237
|
const parsed = fetchIssue(issueKey, field);
|
|
22118
22238
|
const acValue = parsed?.fields?.[field];
|
|
22119
22239
|
if (!acValue) {
|
|
22120
|
-
console.log(
|
|
22240
|
+
console.log(chalk168.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
22121
22241
|
return;
|
|
22122
22242
|
}
|
|
22123
22243
|
if (typeof acValue === "string") {
|
|
@@ -22183,14 +22303,14 @@ async function jiraAuth() {
|
|
|
22183
22303
|
}
|
|
22184
22304
|
|
|
22185
22305
|
// src/commands/jira/viewIssue.ts
|
|
22186
|
-
import
|
|
22306
|
+
import chalk169 from "chalk";
|
|
22187
22307
|
function viewIssue2(issueKey) {
|
|
22188
22308
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
22189
22309
|
const fields = parsed?.fields;
|
|
22190
22310
|
const summary = fields?.summary;
|
|
22191
22311
|
const description = fields?.description;
|
|
22192
22312
|
if (summary) {
|
|
22193
|
-
console.log(
|
|
22313
|
+
console.log(chalk169.bold(summary));
|
|
22194
22314
|
}
|
|
22195
22315
|
if (description) {
|
|
22196
22316
|
if (summary) console.log();
|
|
@@ -22204,7 +22324,7 @@ function viewIssue2(issueKey) {
|
|
|
22204
22324
|
}
|
|
22205
22325
|
if (!summary && !description) {
|
|
22206
22326
|
console.log(
|
|
22207
|
-
|
|
22327
|
+
chalk169.yellow(`No summary or description found on ${issueKey}.`)
|
|
22208
22328
|
);
|
|
22209
22329
|
}
|
|
22210
22330
|
}
|
|
@@ -22239,7 +22359,7 @@ import { randomUUID as randomUUID10 } from "crypto";
|
|
|
22239
22359
|
|
|
22240
22360
|
// src/commands/review/checkoutPr.ts
|
|
22241
22361
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
22242
|
-
import
|
|
22362
|
+
import chalk170 from "chalk";
|
|
22243
22363
|
|
|
22244
22364
|
// src/commands/sessions/daemon/daemonLog.ts
|
|
22245
22365
|
var RING_CAPACITY = 1e3;
|
|
@@ -22276,18 +22396,18 @@ function canonicalTreePath(path84) {
|
|
|
22276
22396
|
}
|
|
22277
22397
|
|
|
22278
22398
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
22279
|
-
import { existsSync as
|
|
22399
|
+
import { existsSync as existsSync55 } from "fs";
|
|
22280
22400
|
import { basename as basename16, dirname as dirname26 } from "path";
|
|
22281
22401
|
|
|
22282
22402
|
// src/commands/sessions/daemon/worktree/planAllocation.ts
|
|
22283
|
-
import { basename as basename15, join as
|
|
22403
|
+
import { basename as basename15, join as join59 } from "path";
|
|
22284
22404
|
function planAllocation(clone, boundTreeRoots2) {
|
|
22285
22405
|
return boundTreeRoots2.has(clone) ? "spill" : "primary";
|
|
22286
22406
|
}
|
|
22287
22407
|
function nextWorktreePath(clone, base, isTaken) {
|
|
22288
22408
|
const name = basename15(clone);
|
|
22289
22409
|
for (let n = 2; n < 1e3; n++) {
|
|
22290
|
-
const candidate =
|
|
22410
|
+
const candidate = join59(base, `${name}-${n}`);
|
|
22291
22411
|
if (!isTaken(candidate)) return candidate;
|
|
22292
22412
|
}
|
|
22293
22413
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -22323,7 +22443,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
22323
22443
|
const base = strategy.root ? expandTilde2(strategy.root) : dirname26(clone);
|
|
22324
22444
|
const registered = new Set(listWorktreePaths(clone));
|
|
22325
22445
|
const branches = new Set(listLocalBranches(clone));
|
|
22326
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
22446
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync55(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename16(candidate));
|
|
22327
22447
|
const path84 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
22328
22448
|
const start3 = worktreeStartPoint(clone, strategy.trunk);
|
|
22329
22449
|
gitSync(clone, [
|
|
@@ -22349,7 +22469,7 @@ function keptInTree(cwd, reason4) {
|
|
|
22349
22469
|
}
|
|
22350
22470
|
|
|
22351
22471
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
22352
|
-
import { existsSync as
|
|
22472
|
+
import { existsSync as existsSync56 } from "fs";
|
|
22353
22473
|
var treeIsGone = { durable: true, gone: true };
|
|
22354
22474
|
function treeDurability(state) {
|
|
22355
22475
|
if (state.dirty) return { durable: false, reason: "uncommitted changes" };
|
|
@@ -22380,14 +22500,14 @@ function* durabilityProbes() {
|
|
|
22380
22500
|
});
|
|
22381
22501
|
}
|
|
22382
22502
|
async function checkDurability(cwd) {
|
|
22383
|
-
if (!
|
|
22503
|
+
if (!existsSync56(cwd)) return treeIsGone;
|
|
22384
22504
|
const probes = durabilityProbes();
|
|
22385
22505
|
let step2 = probes.next();
|
|
22386
22506
|
while (!step2.done) step2 = probes.next(await gitResult(cwd, step2.value));
|
|
22387
22507
|
return step2.value;
|
|
22388
22508
|
}
|
|
22389
22509
|
function checkDurabilitySync(cwd) {
|
|
22390
|
-
if (!
|
|
22510
|
+
if (!existsSync56(cwd)) return treeIsGone;
|
|
22391
22511
|
const probes = durabilityProbes();
|
|
22392
22512
|
let step2 = probes.next();
|
|
22393
22513
|
while (!step2.done) step2 = probes.next(gitSyncResult(cwd, step2.value));
|
|
@@ -22630,20 +22750,20 @@ function persistedTreeRoots() {
|
|
|
22630
22750
|
}
|
|
22631
22751
|
|
|
22632
22752
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
22633
|
-
import { copyFileSync, existsSync as
|
|
22634
|
-
import { dirname as dirname27, join as
|
|
22753
|
+
import { copyFileSync, existsSync as existsSync58, mkdirSync as mkdirSync17 } from "fs";
|
|
22754
|
+
import { dirname as dirname27, join as join61 } from "path";
|
|
22635
22755
|
|
|
22636
22756
|
// src/commands/sessions/daemon/worktree/runInstall.ts
|
|
22637
22757
|
import { spawn as spawn5 } from "child_process";
|
|
22638
22758
|
|
|
22639
22759
|
// src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
|
|
22640
|
-
import { existsSync as
|
|
22641
|
-
import { join as
|
|
22760
|
+
import { existsSync as existsSync57 } from "fs";
|
|
22761
|
+
import { join as join60 } from "path";
|
|
22642
22762
|
function detectInstallCommand(repoRoot2) {
|
|
22643
|
-
if (!
|
|
22644
|
-
if (
|
|
22645
|
-
if (
|
|
22646
|
-
if (
|
|
22763
|
+
if (!existsSync57(join60(repoRoot2, "package.json"))) return null;
|
|
22764
|
+
if (existsSync57(join60(repoRoot2, "pnpm-lock.yaml"))) return "pnpm install";
|
|
22765
|
+
if (existsSync57(join60(repoRoot2, "yarn.lock"))) return "yarn install";
|
|
22766
|
+
if (existsSync57(join60(repoRoot2, "bun.lockb"))) return "bun install";
|
|
22647
22767
|
return "npm install";
|
|
22648
22768
|
}
|
|
22649
22769
|
function resolveInstallCommand(repoRoot2, install) {
|
|
@@ -22755,9 +22875,9 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
22755
22875
|
}
|
|
22756
22876
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
22757
22877
|
for (const rel of copy) {
|
|
22758
|
-
const src =
|
|
22759
|
-
if (!
|
|
22760
|
-
const dest =
|
|
22878
|
+
const src = join61(clone, rel);
|
|
22879
|
+
if (!existsSync58(src)) continue;
|
|
22880
|
+
const dest = join61(worktreePath, rel);
|
|
22761
22881
|
try {
|
|
22762
22882
|
mkdirSync17(dirname27(dest), { recursive: true });
|
|
22763
22883
|
copyFileSync(src, dest);
|
|
@@ -22851,7 +22971,7 @@ async function checkoutPr(number) {
|
|
|
22851
22971
|
try {
|
|
22852
22972
|
execFileSync12("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
22853
22973
|
} catch {
|
|
22854
|
-
console.error(
|
|
22974
|
+
console.error(chalk170.red(`gh pr checkout ${number} failed; aborting.`));
|
|
22855
22975
|
process.exit(1);
|
|
22856
22976
|
}
|
|
22857
22977
|
}
|
|
@@ -22988,15 +23108,15 @@ function registerList(program2) {
|
|
|
22988
23108
|
// src/commands/mermaid/index.ts
|
|
22989
23109
|
import { mkdirSync as mkdirSync18, readdirSync as readdirSync11 } from "fs";
|
|
22990
23110
|
import { resolve as resolve16 } from "path";
|
|
22991
|
-
import
|
|
23111
|
+
import chalk173 from "chalk";
|
|
22992
23112
|
|
|
22993
23113
|
// src/commands/mermaid/exportFile.ts
|
|
22994
23114
|
import { readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
|
|
22995
23115
|
import { basename as basename17, extname as extname2, resolve as resolve15 } from "path";
|
|
22996
|
-
import
|
|
23116
|
+
import chalk172 from "chalk";
|
|
22997
23117
|
|
|
22998
23118
|
// src/commands/mermaid/renderBlock.ts
|
|
22999
|
-
import
|
|
23119
|
+
import chalk171 from "chalk";
|
|
23000
23120
|
async function renderBlock(krokiUrl, source) {
|
|
23001
23121
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
23002
23122
|
method: "POST",
|
|
@@ -23005,7 +23125,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
23005
23125
|
});
|
|
23006
23126
|
if (!response.ok) {
|
|
23007
23127
|
console.error(
|
|
23008
|
-
|
|
23128
|
+
chalk171.red(
|
|
23009
23129
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
23010
23130
|
)
|
|
23011
23131
|
);
|
|
@@ -23023,19 +23143,19 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
23023
23143
|
if (onlyIndex !== void 0) {
|
|
23024
23144
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
23025
23145
|
console.error(
|
|
23026
|
-
|
|
23146
|
+
chalk172.red(
|
|
23027
23147
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
23028
23148
|
)
|
|
23029
23149
|
);
|
|
23030
23150
|
process.exit(1);
|
|
23031
23151
|
}
|
|
23032
23152
|
console.log(
|
|
23033
|
-
|
|
23153
|
+
chalk172.gray(
|
|
23034
23154
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
23035
23155
|
)
|
|
23036
23156
|
);
|
|
23037
23157
|
} else {
|
|
23038
|
-
console.log(
|
|
23158
|
+
console.log(chalk172.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
23039
23159
|
}
|
|
23040
23160
|
for (const [i, source] of blocks.entries()) {
|
|
23041
23161
|
const idx = i + 1;
|
|
@@ -23043,7 +23163,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
23043
23163
|
const outPath = resolve15(outDir, `${stem}-${idx}.svg`);
|
|
23044
23164
|
const svg = await renderBlock(krokiUrl, source);
|
|
23045
23165
|
writeFileSync32(outPath, svg, "utf8");
|
|
23046
|
-
console.log(
|
|
23166
|
+
console.log(chalk172.green(` \u2192 ${outPath}`));
|
|
23047
23167
|
}
|
|
23048
23168
|
}
|
|
23049
23169
|
function extractMermaidBlocks(markdown) {
|
|
@@ -23059,18 +23179,18 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
23059
23179
|
if (options2.index !== void 0) {
|
|
23060
23180
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
23061
23181
|
console.error(
|
|
23062
|
-
|
|
23182
|
+
chalk173.red(`--index must be a positive integer (got ${options2.index})`)
|
|
23063
23183
|
);
|
|
23064
23184
|
process.exit(1);
|
|
23065
23185
|
}
|
|
23066
23186
|
if (!file) {
|
|
23067
|
-
console.error(
|
|
23187
|
+
console.error(chalk173.red("--index requires a file argument"));
|
|
23068
23188
|
process.exit(1);
|
|
23069
23189
|
}
|
|
23070
23190
|
}
|
|
23071
23191
|
const files = file ? [file] : readdirSync11(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
23072
23192
|
if (files.length === 0) {
|
|
23073
|
-
console.log(
|
|
23193
|
+
console.log(chalk173.gray("No markdown files found in current directory."));
|
|
23074
23194
|
return;
|
|
23075
23195
|
}
|
|
23076
23196
|
for (const f of files) {
|
|
@@ -23216,7 +23336,7 @@ function extractToSave(details, cwd = process.cwd()) {
|
|
|
23216
23336
|
}
|
|
23217
23337
|
|
|
23218
23338
|
// src/commands/miro/keptTexts.ts
|
|
23219
|
-
import
|
|
23339
|
+
import chalk174 from "chalk";
|
|
23220
23340
|
|
|
23221
23341
|
// src/commands/miro/applyIgnore.ts
|
|
23222
23342
|
function applyIgnore(texts, ignore3) {
|
|
@@ -23229,10 +23349,10 @@ function applyIgnore(texts, ignore3) {
|
|
|
23229
23349
|
}
|
|
23230
23350
|
|
|
23231
23351
|
// src/commands/miro/readIgnoreList.ts
|
|
23232
|
-
import { existsSync as
|
|
23352
|
+
import { existsSync as existsSync59, readFileSync as readFileSync41 } from "fs";
|
|
23233
23353
|
import { parse as parse2 } from "yaml";
|
|
23234
23354
|
function readIgnoreList(file) {
|
|
23235
|
-
if (!
|
|
23355
|
+
if (!existsSync59(file))
|
|
23236
23356
|
throw new MiroExtractError(
|
|
23237
23357
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
23238
23358
|
);
|
|
@@ -23255,7 +23375,7 @@ function warnUnmatched(file, unmatched) {
|
|
|
23255
23375
|
if (unmatched.length === 0) return;
|
|
23256
23376
|
const entries = unmatched.map((entry) => ` - ${entry}`).join("\n");
|
|
23257
23377
|
console.error(
|
|
23258
|
-
|
|
23378
|
+
chalk174.yellow(
|
|
23259
23379
|
`${unmatched.length} ${unmatched.length === 1 ? "entry" : "entries"} in ${file} matched no box text:
|
|
23260
23380
|
${entries}`
|
|
23261
23381
|
)
|
|
@@ -23458,7 +23578,7 @@ function readMiroItems(file) {
|
|
|
23458
23578
|
}
|
|
23459
23579
|
|
|
23460
23580
|
// src/commands/miro/resolveExtractOptions.ts
|
|
23461
|
-
import
|
|
23581
|
+
import chalk175 from "chalk";
|
|
23462
23582
|
|
|
23463
23583
|
// src/commands/miro/extractLayers.ts
|
|
23464
23584
|
function extractsIn(layer) {
|
|
@@ -23536,7 +23656,7 @@ function resolveExtractOptions(name, options2, paths) {
|
|
|
23536
23656
|
paths.cwd,
|
|
23537
23657
|
paths.globalConfigPath
|
|
23538
23658
|
);
|
|
23539
|
-
console.error(
|
|
23659
|
+
console.error(chalk175.dim(`Extract "${name}" from ${resolved.from}`));
|
|
23540
23660
|
return resolved.options;
|
|
23541
23661
|
}
|
|
23542
23662
|
|
|
@@ -23635,10 +23755,10 @@ function registerMiro(program2) {
|
|
|
23635
23755
|
}
|
|
23636
23756
|
|
|
23637
23757
|
// src/commands/netcap/netcap.ts
|
|
23638
|
-
import { mkdir as
|
|
23758
|
+
import { mkdir as mkdir5 } from "fs/promises";
|
|
23639
23759
|
import { createServer as createServer2 } from "http";
|
|
23640
23760
|
import { dirname as dirname30 } from "path";
|
|
23641
|
-
import
|
|
23761
|
+
import chalk177 from "chalk";
|
|
23642
23762
|
|
|
23643
23763
|
// src/commands/netcap/corsHeaders.ts
|
|
23644
23764
|
var corsHeaders = {
|
|
@@ -23714,22 +23834,22 @@ function createNetcapHandler(options2) {
|
|
|
23714
23834
|
}
|
|
23715
23835
|
|
|
23716
23836
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
23717
|
-
import { cp as
|
|
23837
|
+
import { cp as cp4, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
23718
23838
|
import { networkInterfaces } from "os";
|
|
23719
|
-
import { join as
|
|
23720
|
-
import
|
|
23839
|
+
import { join as join63 } from "path";
|
|
23840
|
+
import chalk176 from "chalk";
|
|
23721
23841
|
|
|
23722
23842
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
23723
|
-
import { dirname as dirname29, join as
|
|
23843
|
+
import { dirname as dirname29, join as join62 } from "path";
|
|
23724
23844
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
23725
23845
|
var moduleDir2 = dirname29(fileURLToPath7(import.meta.url));
|
|
23726
23846
|
function netcapExtensionDir() {
|
|
23727
|
-
return
|
|
23847
|
+
return join62(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
23728
23848
|
}
|
|
23729
23849
|
|
|
23730
23850
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
23731
23851
|
var WSL_WINDOWS_DIR2 = "/mnt/c/tools/netcap-extension";
|
|
23732
|
-
var
|
|
23852
|
+
var WSL_WINDOWS_PATH3 = String.raw`C:\tools\netcap-extension`;
|
|
23733
23853
|
function lanIPv4() {
|
|
23734
23854
|
for (const addrs of Object.values(networkInterfaces())) {
|
|
23735
23855
|
for (const addr of addrs ?? []) {
|
|
@@ -23739,9 +23859,9 @@ function lanIPv4() {
|
|
|
23739
23859
|
return void 0;
|
|
23740
23860
|
}
|
|
23741
23861
|
async function configureBackground(dir, host, port, filter) {
|
|
23742
|
-
const file =
|
|
23743
|
-
const source = await
|
|
23744
|
-
await
|
|
23862
|
+
const file = join63(dir, "background.js");
|
|
23863
|
+
const source = await readFile5(file, "utf8");
|
|
23864
|
+
await writeFile5(
|
|
23745
23865
|
file,
|
|
23746
23866
|
source.replace(
|
|
23747
23867
|
/const RECEIVER = "[^"]*";/,
|
|
@@ -23761,38 +23881,38 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
23761
23881
|
const host = lanIPv4();
|
|
23762
23882
|
if (!host) {
|
|
23763
23883
|
console.log(
|
|
23764
|
-
|
|
23884
|
+
chalk176.yellow("could not determine the WSL IP for the extension")
|
|
23765
23885
|
);
|
|
23766
23886
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
23767
23887
|
return source;
|
|
23768
23888
|
}
|
|
23769
23889
|
try {
|
|
23770
|
-
await
|
|
23890
|
+
await cp4(source, WSL_WINDOWS_DIR2, { recursive: true });
|
|
23771
23891
|
await configureBackground(WSL_WINDOWS_DIR2, host, port, filter);
|
|
23772
|
-
return
|
|
23892
|
+
return WSL_WINDOWS_PATH3;
|
|
23773
23893
|
} catch {
|
|
23774
23894
|
console.log(
|
|
23775
|
-
|
|
23895
|
+
chalk176.yellow(`could not copy extension to ${WSL_WINDOWS_PATH3}`)
|
|
23776
23896
|
);
|
|
23777
23897
|
return source;
|
|
23778
23898
|
}
|
|
23779
23899
|
}
|
|
23780
23900
|
|
|
23781
23901
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
23782
|
-
import { isAbsolute as isAbsolute4, join as
|
|
23902
|
+
import { isAbsolute as isAbsolute4, join as join65, resolve as resolve18 } from "path";
|
|
23783
23903
|
|
|
23784
23904
|
// src/commands/netcap/defaultCapturePath.ts
|
|
23785
|
-
import { homedir as
|
|
23786
|
-
import { join as
|
|
23905
|
+
import { homedir as homedir21 } from "os";
|
|
23906
|
+
import { join as join64 } from "path";
|
|
23787
23907
|
function defaultCapturePath() {
|
|
23788
|
-
return
|
|
23908
|
+
return join64(homedir21(), ".assist", "netcap", "capture.jsonl");
|
|
23789
23909
|
}
|
|
23790
23910
|
|
|
23791
23911
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
23792
23912
|
function resolveNetcapOutPath(out) {
|
|
23793
23913
|
if (!out) return defaultCapturePath();
|
|
23794
23914
|
const dir = isAbsolute4(out) ? out : resolve18(process.cwd(), out);
|
|
23795
|
-
return
|
|
23915
|
+
return join65(dir, "capture.jsonl");
|
|
23796
23916
|
}
|
|
23797
23917
|
|
|
23798
23918
|
// src/commands/netcap/netcap.ts
|
|
@@ -23800,35 +23920,35 @@ async function netcap(options2) {
|
|
|
23800
23920
|
const port = Number(options2.port);
|
|
23801
23921
|
const outPath = resolveNetcapOutPath(options2.out);
|
|
23802
23922
|
const filter = options2.filter ?? "";
|
|
23803
|
-
await
|
|
23923
|
+
await mkdir5(dirname30(outPath), { recursive: true });
|
|
23804
23924
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
23805
23925
|
let count8 = 0;
|
|
23806
23926
|
const handler = createNetcapHandler({
|
|
23807
23927
|
outPath,
|
|
23808
|
-
onPing: () => console.log(
|
|
23928
|
+
onPing: () => console.log(chalk177.dim("ping from extension")),
|
|
23809
23929
|
onCapture: (entry) => {
|
|
23810
23930
|
count8 += 1;
|
|
23811
23931
|
console.log(
|
|
23812
|
-
|
|
23813
|
-
|
|
23932
|
+
chalk177.green(`captured #${count8}`),
|
|
23933
|
+
chalk177.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
23814
23934
|
);
|
|
23815
23935
|
}
|
|
23816
23936
|
});
|
|
23817
23937
|
const server = createServer2(handler);
|
|
23818
23938
|
server.listen(port, () => {
|
|
23819
23939
|
console.log(
|
|
23820
|
-
|
|
23940
|
+
chalk177.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
23821
23941
|
);
|
|
23822
|
-
console.log(
|
|
23942
|
+
console.log(chalk177.dim(`appending captures to ${outPath}`));
|
|
23823
23943
|
if (filter)
|
|
23824
|
-
console.log(
|
|
23825
|
-
console.log(
|
|
23826
|
-
console.log(
|
|
23944
|
+
console.log(chalk177.dim(`forwarding only URLs matching "${filter}"`));
|
|
23945
|
+
console.log(chalk177.dim(`load the unpacked extension from ${extensionPath}`));
|
|
23946
|
+
console.log(chalk177.dim("press Ctrl-C to stop"));
|
|
23827
23947
|
});
|
|
23828
23948
|
process.on("SIGINT", () => {
|
|
23829
23949
|
server.close();
|
|
23830
23950
|
console.log(
|
|
23831
|
-
|
|
23951
|
+
chalk177.bold(
|
|
23832
23952
|
`
|
|
23833
23953
|
netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
23834
23954
|
)
|
|
@@ -23839,8 +23959,8 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
23839
23959
|
|
|
23840
23960
|
// src/commands/netcap/netcapExtract.ts
|
|
23841
23961
|
import { writeFileSync as writeFileSync34 } from "fs";
|
|
23842
|
-
import { join as
|
|
23843
|
-
import
|
|
23962
|
+
import { join as join66 } from "path";
|
|
23963
|
+
import chalk178 from "chalk";
|
|
23844
23964
|
|
|
23845
23965
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
23846
23966
|
import { readFileSync as readFileSync43 } from "fs";
|
|
@@ -24284,12 +24404,12 @@ function extractPostsFromCapture(captureFile) {
|
|
|
24284
24404
|
function netcapExtract(file) {
|
|
24285
24405
|
const captureFile = file ?? defaultCapturePath();
|
|
24286
24406
|
const posts = extractPostsFromCapture(captureFile);
|
|
24287
|
-
const outFile =
|
|
24407
|
+
const outFile = join66(captureFile, "..", "posts.json");
|
|
24288
24408
|
writeFileSync34(outFile, `${JSON.stringify(posts, null, 2)}
|
|
24289
24409
|
`);
|
|
24290
24410
|
console.log(
|
|
24291
|
-
|
|
24292
|
-
|
|
24411
|
+
chalk178.green(`extracted ${posts.length} posts`),
|
|
24412
|
+
chalk178.dim(`-> ${outFile}`)
|
|
24293
24413
|
);
|
|
24294
24414
|
}
|
|
24295
24415
|
|
|
@@ -24310,7 +24430,7 @@ function registerNetcap(program2) {
|
|
|
24310
24430
|
}
|
|
24311
24431
|
|
|
24312
24432
|
// src/commands/news/add/index.ts
|
|
24313
|
-
import
|
|
24433
|
+
import chalk179 from "chalk";
|
|
24314
24434
|
import enquirer8 from "enquirer";
|
|
24315
24435
|
async function add2(url) {
|
|
24316
24436
|
if (!url) {
|
|
@@ -24332,10 +24452,10 @@ async function add2(url) {
|
|
|
24332
24452
|
const { orm } = await getReady();
|
|
24333
24453
|
const added = await addFeed(orm, url);
|
|
24334
24454
|
if (!added) {
|
|
24335
|
-
console.log(
|
|
24455
|
+
console.log(chalk179.yellow("Feed already exists"));
|
|
24336
24456
|
return;
|
|
24337
24457
|
}
|
|
24338
|
-
console.log(
|
|
24458
|
+
console.log(chalk179.green(`Added feed: ${url}`));
|
|
24339
24459
|
}
|
|
24340
24460
|
|
|
24341
24461
|
// src/commands/registerNews.ts
|
|
@@ -24382,7 +24502,7 @@ function registerPiHook(program2) {
|
|
|
24382
24502
|
}
|
|
24383
24503
|
|
|
24384
24504
|
// src/commands/prompts/printPromptsTable.ts
|
|
24385
|
-
import
|
|
24505
|
+
import chalk180 from "chalk";
|
|
24386
24506
|
function truncate(str, max) {
|
|
24387
24507
|
if (str.length <= max) return str;
|
|
24388
24508
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -24400,14 +24520,14 @@ function printPromptsTable(rows) {
|
|
|
24400
24520
|
"Command".padEnd(commandWidth),
|
|
24401
24521
|
"Repos"
|
|
24402
24522
|
].join(" ");
|
|
24403
|
-
console.log(
|
|
24404
|
-
console.log(
|
|
24523
|
+
console.log(chalk180.dim(header));
|
|
24524
|
+
console.log(chalk180.dim("-".repeat(header.length)));
|
|
24405
24525
|
for (const row of rows) {
|
|
24406
24526
|
const count8 = String(row.count).padStart(countWidth);
|
|
24407
24527
|
const tool = row.tool.padEnd(toolWidth);
|
|
24408
24528
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
24409
24529
|
console.log(
|
|
24410
|
-
`${
|
|
24530
|
+
`${chalk180.yellow(count8)} ${tool} ${command} ${chalk180.dim(row.repos)}`
|
|
24411
24531
|
);
|
|
24412
24532
|
}
|
|
24413
24533
|
}
|
|
@@ -24809,19 +24929,19 @@ import { execSync as execSync45 } from "child_process";
|
|
|
24809
24929
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
24810
24930
|
import { execSync as execSync44 } from "child_process";
|
|
24811
24931
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync35 } from "fs";
|
|
24812
|
-
import { tmpdir as
|
|
24813
|
-
import { join as
|
|
24932
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
24933
|
+
import { join as join68 } from "path";
|
|
24814
24934
|
|
|
24815
24935
|
// src/commands/prs/loadCommentsCache.ts
|
|
24816
|
-
import { existsSync as
|
|
24936
|
+
import { existsSync as existsSync60, readFileSync as readFileSync44, unlinkSync as unlinkSync13 } from "fs";
|
|
24817
24937
|
import { parse as parse3 } from "yaml";
|
|
24818
24938
|
|
|
24819
24939
|
// src/commands/prs/commentsCachePath.ts
|
|
24820
|
-
import { homedir as
|
|
24821
|
-
import { join as
|
|
24940
|
+
import { homedir as homedir22 } from "os";
|
|
24941
|
+
import { join as join67 } from "path";
|
|
24822
24942
|
function commentsCachePath(org, repo, prNumber) {
|
|
24823
|
-
return
|
|
24824
|
-
|
|
24943
|
+
return join67(
|
|
24944
|
+
homedir22(),
|
|
24825
24945
|
".assist",
|
|
24826
24946
|
"pr-comments",
|
|
24827
24947
|
org,
|
|
@@ -24833,7 +24953,7 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
24833
24953
|
// src/commands/prs/loadCommentsCache.ts
|
|
24834
24954
|
function loadCommentsCache(org, repo, prNumber) {
|
|
24835
24955
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24836
|
-
if (!
|
|
24956
|
+
if (!existsSync60(cachePath)) {
|
|
24837
24957
|
return null;
|
|
24838
24958
|
}
|
|
24839
24959
|
const content = readFileSync44(cachePath, "utf8");
|
|
@@ -24841,7 +24961,7 @@ function loadCommentsCache(org, repo, prNumber) {
|
|
|
24841
24961
|
}
|
|
24842
24962
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
24843
24963
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
24844
|
-
if (
|
|
24964
|
+
if (existsSync60(cachePath)) {
|
|
24845
24965
|
unlinkSync13(cachePath);
|
|
24846
24966
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
24847
24967
|
}
|
|
@@ -24869,7 +24989,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
24869
24989
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
24870
24990
|
function resolveThread(threadId) {
|
|
24871
24991
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
24872
|
-
const queryFile =
|
|
24992
|
+
const queryFile = join68(tmpdir7(), `gh-mutation-${Date.now()}.graphql`);
|
|
24873
24993
|
writeFileSync35(queryFile, mutation);
|
|
24874
24994
|
try {
|
|
24875
24995
|
execSync44(
|
|
@@ -24953,11 +25073,11 @@ function fixed(commentId, sha) {
|
|
|
24953
25073
|
// src/commands/prs/fetchThreadIds.ts
|
|
24954
25074
|
import { execSync as execSync46 } from "child_process";
|
|
24955
25075
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync36 } from "fs";
|
|
24956
|
-
import { tmpdir as
|
|
24957
|
-
import { join as
|
|
25076
|
+
import { tmpdir as tmpdir8 } from "os";
|
|
25077
|
+
import { join as join69 } from "path";
|
|
24958
25078
|
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
25079
|
function fetchThreadIds(org, repo, prNumber) {
|
|
24960
|
-
const queryFile =
|
|
25080
|
+
const queryFile = join69(tmpdir8(), `gh-query-${Date.now()}.graphql`);
|
|
24961
25081
|
writeFileSync36(queryFile, THREAD_QUERY);
|
|
24962
25082
|
try {
|
|
24963
25083
|
const result = execSync46(
|
|
@@ -25032,10 +25152,10 @@ import { stringify as stringify3 } from "yaml";
|
|
|
25032
25152
|
|
|
25033
25153
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
25034
25154
|
import { readdirSync as readdirSync12, unlinkSync as unlinkSync16 } from "fs";
|
|
25035
|
-
import { join as
|
|
25155
|
+
import { join as join70 } from "path";
|
|
25036
25156
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
25037
25157
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
25038
|
-
const dir =
|
|
25158
|
+
const dir = join70(cwd, ".assist");
|
|
25039
25159
|
let entries;
|
|
25040
25160
|
try {
|
|
25041
25161
|
entries = readdirSync12(dir);
|
|
@@ -25043,7 +25163,7 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
|
25043
25163
|
return;
|
|
25044
25164
|
}
|
|
25045
25165
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
25046
|
-
unlinkSync16(
|
|
25166
|
+
unlinkSync16(join70(dir, entry));
|
|
25047
25167
|
}
|
|
25048
25168
|
}
|
|
25049
25169
|
|
|
@@ -25074,13 +25194,13 @@ function agentFooter(unresolvedCount) {
|
|
|
25074
25194
|
}
|
|
25075
25195
|
|
|
25076
25196
|
// src/commands/prs/listComments/commentStyle.ts
|
|
25077
|
-
import
|
|
25197
|
+
import chalk181 from "chalk";
|
|
25078
25198
|
var plain = (text18) => text18;
|
|
25079
25199
|
function colouredState(state) {
|
|
25080
25200
|
const label2 = `[${state}]`;
|
|
25081
|
-
if (state === "APPROVED") return
|
|
25082
|
-
if (state === "CHANGES_REQUESTED") return
|
|
25083
|
-
return
|
|
25201
|
+
if (state === "APPROVED") return chalk181.green(label2);
|
|
25202
|
+
if (state === "CHANGES_REQUESTED") return chalk181.red(label2);
|
|
25203
|
+
return chalk181.yellow(label2);
|
|
25084
25204
|
}
|
|
25085
25205
|
function commentStyle() {
|
|
25086
25206
|
if (isClaudeCode()) {
|
|
@@ -25094,9 +25214,9 @@ function commentStyle() {
|
|
|
25094
25214
|
};
|
|
25095
25215
|
}
|
|
25096
25216
|
return {
|
|
25097
|
-
cyan:
|
|
25098
|
-
bold:
|
|
25099
|
-
dim:
|
|
25217
|
+
cyan: chalk181.cyan,
|
|
25218
|
+
bold: chalk181.bold,
|
|
25219
|
+
dim: chalk181.dim,
|
|
25100
25220
|
state: colouredState,
|
|
25101
25221
|
diffHunk: true,
|
|
25102
25222
|
agent: false
|
|
@@ -25266,13 +25386,13 @@ import { execSync as execSync48 } from "child_process";
|
|
|
25266
25386
|
import enquirer9 from "enquirer";
|
|
25267
25387
|
|
|
25268
25388
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
25269
|
-
import
|
|
25389
|
+
import chalk182 from "chalk";
|
|
25270
25390
|
var STATUS_MAP = {
|
|
25271
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
25272
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
25391
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk182.magenta("merged"), date: pr.mergedAt } : null,
|
|
25392
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk182.red("closed"), date: pr.closedAt } : null
|
|
25273
25393
|
};
|
|
25274
25394
|
function defaultStatus(pr) {
|
|
25275
|
-
return { label:
|
|
25395
|
+
return { label: chalk182.green("opened"), date: pr.createdAt };
|
|
25276
25396
|
}
|
|
25277
25397
|
function getStatus2(pr) {
|
|
25278
25398
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -25281,11 +25401,11 @@ function formatDate(dateStr) {
|
|
|
25281
25401
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
25282
25402
|
}
|
|
25283
25403
|
function formatPrHeader(pr, status3) {
|
|
25284
|
-
return `${
|
|
25404
|
+
return `${chalk182.cyan(`#${pr.number}`)} ${pr.title} ${chalk182.dim(`(${pr.author.login},`)} ${status3.label} ${chalk182.dim(`${formatDate(status3.date)})`)}`;
|
|
25285
25405
|
}
|
|
25286
25406
|
function logPrDetails(pr) {
|
|
25287
25407
|
console.log(
|
|
25288
|
-
|
|
25408
|
+
chalk182.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
25289
25409
|
);
|
|
25290
25410
|
console.log();
|
|
25291
25411
|
}
|
|
@@ -26000,10 +26120,10 @@ function registerPrs(program2) {
|
|
|
26000
26120
|
}
|
|
26001
26121
|
|
|
26002
26122
|
// src/commands/ravendb/ravendbAuth.ts
|
|
26003
|
-
import
|
|
26123
|
+
import chalk188 from "chalk";
|
|
26004
26124
|
|
|
26005
26125
|
// src/shared/createConnectionAuth.ts
|
|
26006
|
-
import
|
|
26126
|
+
import chalk183 from "chalk";
|
|
26007
26127
|
function listConnections(connections, format) {
|
|
26008
26128
|
if (connections.length === 0) {
|
|
26009
26129
|
console.log("No connections configured.");
|
|
@@ -26016,7 +26136,7 @@ function listConnections(connections, format) {
|
|
|
26016
26136
|
function removeConnection(connections, name, save) {
|
|
26017
26137
|
const filtered = connections.filter((c) => c.name !== name);
|
|
26018
26138
|
if (filtered.length === connections.length) {
|
|
26019
|
-
console.error(
|
|
26139
|
+
console.error(chalk183.red(`Connection "${name}" not found.`));
|
|
26020
26140
|
process.exit(1);
|
|
26021
26141
|
}
|
|
26022
26142
|
save(filtered);
|
|
@@ -26062,15 +26182,15 @@ function saveConnections(connections) {
|
|
|
26062
26182
|
}
|
|
26063
26183
|
|
|
26064
26184
|
// src/commands/ravendb/promptConnection.ts
|
|
26065
|
-
import
|
|
26185
|
+
import chalk186 from "chalk";
|
|
26066
26186
|
|
|
26067
26187
|
// src/commands/ravendb/selectOpSecret.ts
|
|
26068
|
-
import
|
|
26188
|
+
import chalk185 from "chalk";
|
|
26069
26189
|
import Enquirer2 from "enquirer";
|
|
26070
26190
|
|
|
26071
26191
|
// src/commands/ravendb/searchItems.ts
|
|
26072
26192
|
import { execSync as execSync51 } from "child_process";
|
|
26073
|
-
import
|
|
26193
|
+
import chalk184 from "chalk";
|
|
26074
26194
|
function opExec(args) {
|
|
26075
26195
|
return execSync51(`op ${args}`, {
|
|
26076
26196
|
encoding: "utf8",
|
|
@@ -26083,7 +26203,7 @@ function searchItems(search2) {
|
|
|
26083
26203
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
26084
26204
|
} catch {
|
|
26085
26205
|
console.error(
|
|
26086
|
-
|
|
26206
|
+
chalk184.red(
|
|
26087
26207
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
26088
26208
|
)
|
|
26089
26209
|
);
|
|
@@ -26097,7 +26217,7 @@ function getItemFields(itemId2) {
|
|
|
26097
26217
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
26098
26218
|
return item.fields.filter((f) => f.reference && f.label);
|
|
26099
26219
|
} catch {
|
|
26100
|
-
console.error(
|
|
26220
|
+
console.error(chalk184.red("Failed to get item details from 1Password."));
|
|
26101
26221
|
process.exit(1);
|
|
26102
26222
|
}
|
|
26103
26223
|
}
|
|
@@ -26116,7 +26236,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
26116
26236
|
}).run();
|
|
26117
26237
|
const items2 = searchItems(search2);
|
|
26118
26238
|
if (items2.length === 0) {
|
|
26119
|
-
console.error(
|
|
26239
|
+
console.error(chalk185.red(`No items found matching "${search2}".`));
|
|
26120
26240
|
process.exit(1);
|
|
26121
26241
|
}
|
|
26122
26242
|
const itemId2 = await selectOne(
|
|
@@ -26125,7 +26245,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
26125
26245
|
);
|
|
26126
26246
|
const fields = getItemFields(itemId2);
|
|
26127
26247
|
if (fields.length === 0) {
|
|
26128
|
-
console.error(
|
|
26248
|
+
console.error(chalk185.red("No fields with references found on this item."));
|
|
26129
26249
|
process.exit(1);
|
|
26130
26250
|
}
|
|
26131
26251
|
const ref = await selectOne(
|
|
@@ -26139,7 +26259,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
26139
26259
|
async function promptConnection(existingNames) {
|
|
26140
26260
|
const name = await promptInput("name", "Connection name:");
|
|
26141
26261
|
if (existingNames.includes(name)) {
|
|
26142
|
-
console.error(
|
|
26262
|
+
console.error(chalk186.red(`Connection "${name}" already exists.`));
|
|
26143
26263
|
process.exit(1);
|
|
26144
26264
|
}
|
|
26145
26265
|
const url = await promptInput(
|
|
@@ -26148,22 +26268,22 @@ async function promptConnection(existingNames) {
|
|
|
26148
26268
|
);
|
|
26149
26269
|
const database = await promptInput("database", "Database name:");
|
|
26150
26270
|
if (!name || !url || !database) {
|
|
26151
|
-
console.error(
|
|
26271
|
+
console.error(chalk186.red("All fields are required."));
|
|
26152
26272
|
process.exit(1);
|
|
26153
26273
|
}
|
|
26154
26274
|
const apiKeyRef = await selectOpSecret();
|
|
26155
|
-
console.log(
|
|
26275
|
+
console.log(chalk186.dim(`Using: ${apiKeyRef}`));
|
|
26156
26276
|
return { name, url, database, apiKeyRef };
|
|
26157
26277
|
}
|
|
26158
26278
|
|
|
26159
26279
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
26160
|
-
import
|
|
26280
|
+
import chalk187 from "chalk";
|
|
26161
26281
|
function ravendbSetConnection(name) {
|
|
26162
26282
|
const raw = loadGlobalConfigRaw();
|
|
26163
26283
|
const ravendb = raw.ravendb ?? {};
|
|
26164
26284
|
const connections = ravendb.connections ?? [];
|
|
26165
26285
|
if (!connections.some((c) => c.name === name)) {
|
|
26166
|
-
console.error(
|
|
26286
|
+
console.error(chalk187.red(`Connection "${name}" not found.`));
|
|
26167
26287
|
console.error(
|
|
26168
26288
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
26169
26289
|
);
|
|
@@ -26179,16 +26299,16 @@ function ravendbSetConnection(name) {
|
|
|
26179
26299
|
var ravendbAuth = createConnectionAuth({
|
|
26180
26300
|
load: loadConnections,
|
|
26181
26301
|
save: saveConnections,
|
|
26182
|
-
format: (c) => `${
|
|
26302
|
+
format: (c) => `${chalk188.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
26183
26303
|
promptNew: promptConnection,
|
|
26184
26304
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
26185
26305
|
});
|
|
26186
26306
|
|
|
26187
26307
|
// src/commands/ravendb/ravendbCollections.ts
|
|
26188
|
-
import
|
|
26308
|
+
import chalk192 from "chalk";
|
|
26189
26309
|
|
|
26190
26310
|
// src/commands/ravendb/ravenFetch.ts
|
|
26191
|
-
import
|
|
26311
|
+
import chalk190 from "chalk";
|
|
26192
26312
|
|
|
26193
26313
|
// src/commands/ravendb/getAccessToken.ts
|
|
26194
26314
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -26225,10 +26345,10 @@ ${errorText}`
|
|
|
26225
26345
|
|
|
26226
26346
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
26227
26347
|
import { execSync as execSync52 } from "child_process";
|
|
26228
|
-
import
|
|
26348
|
+
import chalk189 from "chalk";
|
|
26229
26349
|
function resolveOpSecret(reference) {
|
|
26230
26350
|
if (!reference.startsWith("op://")) {
|
|
26231
|
-
console.error(
|
|
26351
|
+
console.error(chalk189.red(`Invalid secret reference: must start with op://`));
|
|
26232
26352
|
process.exit(1);
|
|
26233
26353
|
}
|
|
26234
26354
|
try {
|
|
@@ -26238,7 +26358,7 @@ function resolveOpSecret(reference) {
|
|
|
26238
26358
|
}).trim();
|
|
26239
26359
|
} catch {
|
|
26240
26360
|
console.error(
|
|
26241
|
-
|
|
26361
|
+
chalk189.red(
|
|
26242
26362
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
26243
26363
|
)
|
|
26244
26364
|
);
|
|
@@ -26265,7 +26385,7 @@ async function ravenFetch(connection, path84) {
|
|
|
26265
26385
|
if (!response.ok) {
|
|
26266
26386
|
const body = await response.text();
|
|
26267
26387
|
console.error(
|
|
26268
|
-
|
|
26388
|
+
chalk190.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
26269
26389
|
);
|
|
26270
26390
|
console.error(body.substring(0, 500));
|
|
26271
26391
|
process.exit(1);
|
|
@@ -26274,7 +26394,7 @@ async function ravenFetch(connection, path84) {
|
|
|
26274
26394
|
}
|
|
26275
26395
|
|
|
26276
26396
|
// src/commands/ravendb/resolveConnection.ts
|
|
26277
|
-
import
|
|
26397
|
+
import chalk191 from "chalk";
|
|
26278
26398
|
function loadRavendb() {
|
|
26279
26399
|
const raw = loadGlobalConfigRaw();
|
|
26280
26400
|
const ravendb = raw.ravendb;
|
|
@@ -26288,7 +26408,7 @@ function resolveConnection(name) {
|
|
|
26288
26408
|
const connectionName = name ?? defaultConnection;
|
|
26289
26409
|
if (!connectionName) {
|
|
26290
26410
|
console.error(
|
|
26291
|
-
|
|
26411
|
+
chalk191.red(
|
|
26292
26412
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
26293
26413
|
)
|
|
26294
26414
|
);
|
|
@@ -26296,7 +26416,7 @@ function resolveConnection(name) {
|
|
|
26296
26416
|
}
|
|
26297
26417
|
const connection = connections.find((c) => c.name === connectionName);
|
|
26298
26418
|
if (!connection) {
|
|
26299
|
-
console.error(
|
|
26419
|
+
console.error(chalk191.red(`Connection "${connectionName}" not found.`));
|
|
26300
26420
|
console.error(
|
|
26301
26421
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
26302
26422
|
);
|
|
@@ -26327,15 +26447,15 @@ async function ravendbCollections(connectionName) {
|
|
|
26327
26447
|
return;
|
|
26328
26448
|
}
|
|
26329
26449
|
for (const c of collections) {
|
|
26330
|
-
console.log(`${
|
|
26450
|
+
console.log(`${chalk192.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
26331
26451
|
}
|
|
26332
26452
|
}
|
|
26333
26453
|
|
|
26334
26454
|
// src/commands/ravendb/ravendbQuery.ts
|
|
26335
|
-
import
|
|
26455
|
+
import chalk194 from "chalk";
|
|
26336
26456
|
|
|
26337
26457
|
// src/commands/ravendb/fetchAllPages.ts
|
|
26338
|
-
import
|
|
26458
|
+
import chalk193 from "chalk";
|
|
26339
26459
|
|
|
26340
26460
|
// src/commands/ravendb/buildQueryPath.ts
|
|
26341
26461
|
function buildQueryPath(opts) {
|
|
@@ -26373,7 +26493,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
26373
26493
|
allResults.push(...results);
|
|
26374
26494
|
start3 += results.length;
|
|
26375
26495
|
process.stderr.write(
|
|
26376
|
-
`\r${
|
|
26496
|
+
`\r${chalk193.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
26377
26497
|
);
|
|
26378
26498
|
if (start3 >= totalResults) break;
|
|
26379
26499
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -26388,7 +26508,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
26388
26508
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
26389
26509
|
const resolved = resolveArgs(connectionName, collection);
|
|
26390
26510
|
if (!resolved.collection && !options2.query) {
|
|
26391
|
-
console.error(
|
|
26511
|
+
console.error(chalk194.red("Provide a collection name or --query filter."));
|
|
26392
26512
|
process.exit(1);
|
|
26393
26513
|
}
|
|
26394
26514
|
const { collection: col } = resolved;
|
|
@@ -26427,7 +26547,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
26427
26547
|
import * as path45 from "path";
|
|
26428
26548
|
|
|
26429
26549
|
// src/commands/refactor/logViolations.ts
|
|
26430
|
-
import
|
|
26550
|
+
import chalk195 from "chalk";
|
|
26431
26551
|
var DEFAULT_MAX_LINES2 = 100;
|
|
26432
26552
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
26433
26553
|
if (violations.length === 0) {
|
|
@@ -26436,43 +26556,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
26436
26556
|
}
|
|
26437
26557
|
return;
|
|
26438
26558
|
}
|
|
26439
|
-
console.error(
|
|
26559
|
+
console.error(chalk195.red(`
|
|
26440
26560
|
Refactor check failed:
|
|
26441
26561
|
`));
|
|
26442
|
-
console.error(
|
|
26562
|
+
console.error(chalk195.red(` The following files exceed ${maxLines} lines:
|
|
26443
26563
|
`));
|
|
26444
26564
|
for (const violation of violations) {
|
|
26445
|
-
console.error(
|
|
26565
|
+
console.error(chalk195.red(` ${violation.file} (${violation.lines} lines)`));
|
|
26446
26566
|
}
|
|
26447
26567
|
console.error(
|
|
26448
|
-
|
|
26568
|
+
chalk195.yellow(
|
|
26449
26569
|
`
|
|
26450
26570
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
26451
26571
|
way to refactor it, ignore it with:
|
|
26452
26572
|
`
|
|
26453
26573
|
)
|
|
26454
26574
|
);
|
|
26455
|
-
console.error(
|
|
26575
|
+
console.error(chalk195.gray(` assist refactor ignore <file>
|
|
26456
26576
|
`));
|
|
26457
26577
|
if (process.env.CLAUDECODE) {
|
|
26458
|
-
console.error(
|
|
26578
|
+
console.error(chalk195.cyan(`
|
|
26459
26579
|
## Extracting Code to New Files
|
|
26460
26580
|
`));
|
|
26461
26581
|
console.error(
|
|
26462
|
-
|
|
26582
|
+
chalk195.cyan(
|
|
26463
26583
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
26464
26584
|
`
|
|
26465
26585
|
)
|
|
26466
26586
|
);
|
|
26467
26587
|
console.error(
|
|
26468
|
-
|
|
26588
|
+
chalk195.cyan(
|
|
26469
26589
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
26470
26590
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
26471
26591
|
`
|
|
26472
26592
|
)
|
|
26473
26593
|
);
|
|
26474
26594
|
console.error(
|
|
26475
|
-
|
|
26595
|
+
chalk195.cyan(
|
|
26476
26596
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
26477
26597
|
domains, move it to a common/shared folder.
|
|
26478
26598
|
`
|
|
@@ -26628,7 +26748,7 @@ async function check(pattern2, options2) {
|
|
|
26628
26748
|
|
|
26629
26749
|
// src/commands/refactor/extract/index.ts
|
|
26630
26750
|
import path53 from "path";
|
|
26631
|
-
import
|
|
26751
|
+
import chalk198 from "chalk";
|
|
26632
26752
|
|
|
26633
26753
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
26634
26754
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -27227,23 +27347,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
27227
27347
|
|
|
27228
27348
|
// src/commands/refactor/extract/displayPlan.ts
|
|
27229
27349
|
import path49 from "path";
|
|
27230
|
-
import
|
|
27350
|
+
import chalk196 from "chalk";
|
|
27231
27351
|
function section2(title) {
|
|
27232
27352
|
return `
|
|
27233
|
-
${
|
|
27353
|
+
${chalk196.cyan(title)}`;
|
|
27234
27354
|
}
|
|
27235
27355
|
function displayImporters(plan2, cwd) {
|
|
27236
27356
|
if (plan2.importersToUpdate.length === 0) return;
|
|
27237
27357
|
console.log(section2("Update importers:"));
|
|
27238
27358
|
for (const imp of plan2.importersToUpdate) {
|
|
27239
27359
|
const rel = path49.relative(cwd, imp.file.getFilePath());
|
|
27240
|
-
console.log(` ${
|
|
27360
|
+
console.log(` ${chalk196.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
27241
27361
|
}
|
|
27242
27362
|
}
|
|
27243
27363
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
27244
|
-
console.log(
|
|
27364
|
+
console.log(chalk196.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
27245
27365
|
`));
|
|
27246
|
-
console.log(` ${
|
|
27366
|
+
console.log(` ${chalk196.cyan("Functions to move:")}`);
|
|
27247
27367
|
for (const name of plan2.extractedNames) {
|
|
27248
27368
|
console.log(` ${name}`);
|
|
27249
27369
|
}
|
|
@@ -27277,7 +27397,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
27277
27397
|
|
|
27278
27398
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
27279
27399
|
import path52 from "path";
|
|
27280
|
-
import
|
|
27400
|
+
import chalk197 from "chalk";
|
|
27281
27401
|
import { Project as Project4 } from "ts-morph";
|
|
27282
27402
|
|
|
27283
27403
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -27369,7 +27489,7 @@ function loadProjectFile(file) {
|
|
|
27369
27489
|
});
|
|
27370
27490
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
27371
27491
|
if (!sourceFile) {
|
|
27372
|
-
console.log(
|
|
27492
|
+
console.log(chalk197.red(`File not found in project: ${file}`));
|
|
27373
27493
|
process.exit(1);
|
|
27374
27494
|
}
|
|
27375
27495
|
return { project, sourceFile };
|
|
@@ -27392,19 +27512,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
27392
27512
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
27393
27513
|
if (options2.apply) {
|
|
27394
27514
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
27395
|
-
console.log(
|
|
27515
|
+
console.log(chalk198.green("\nExtraction complete"));
|
|
27396
27516
|
} else {
|
|
27397
|
-
console.log(
|
|
27517
|
+
console.log(chalk198.dim("\nDry run. Use --apply to execute."));
|
|
27398
27518
|
}
|
|
27399
27519
|
}
|
|
27400
27520
|
|
|
27401
27521
|
// src/commands/refactor/ignore.ts
|
|
27402
27522
|
import fs33 from "fs";
|
|
27403
|
-
import
|
|
27523
|
+
import chalk199 from "chalk";
|
|
27404
27524
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
27405
27525
|
function ignore2(file) {
|
|
27406
27526
|
if (!fs33.existsSync(file)) {
|
|
27407
|
-
console.error(
|
|
27527
|
+
console.error(chalk199.red(`Error: File does not exist: ${file}`));
|
|
27408
27528
|
process.exit(1);
|
|
27409
27529
|
}
|
|
27410
27530
|
const content = fs33.readFileSync(file, "utf8");
|
|
@@ -27420,7 +27540,7 @@ function ignore2(file) {
|
|
|
27420
27540
|
fs33.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
27421
27541
|
}
|
|
27422
27542
|
console.log(
|
|
27423
|
-
|
|
27543
|
+
chalk199.green(
|
|
27424
27544
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
27425
27545
|
)
|
|
27426
27546
|
);
|
|
@@ -27429,12 +27549,12 @@ function ignore2(file) {
|
|
|
27429
27549
|
// src/commands/refactor/rename/index.ts
|
|
27430
27550
|
import fs36 from "fs";
|
|
27431
27551
|
import path58 from "path";
|
|
27432
|
-
import
|
|
27552
|
+
import chalk202 from "chalk";
|
|
27433
27553
|
|
|
27434
27554
|
// src/commands/refactor/rename/applyRename.ts
|
|
27435
27555
|
import fs35 from "fs";
|
|
27436
27556
|
import path55 from "path";
|
|
27437
|
-
import
|
|
27557
|
+
import chalk200 from "chalk";
|
|
27438
27558
|
|
|
27439
27559
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
27440
27560
|
import path54 from "path";
|
|
@@ -27539,13 +27659,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
27539
27659
|
const updatedContents = applyRewrites(rewrites);
|
|
27540
27660
|
for (const [file, content] of updatedContents) {
|
|
27541
27661
|
fs35.writeFileSync(file, content, "utf8");
|
|
27542
|
-
console.log(
|
|
27662
|
+
console.log(chalk200.cyan(` Updated imports in ${path55.relative(cwd, file)}`));
|
|
27543
27663
|
}
|
|
27544
27664
|
const destDir = path55.dirname(destPath);
|
|
27545
27665
|
if (!fs35.existsSync(destDir)) fs35.mkdirSync(destDir, { recursive: true });
|
|
27546
27666
|
fs35.renameSync(sourcePath, destPath);
|
|
27547
27667
|
console.log(
|
|
27548
|
-
|
|
27668
|
+
chalk200.white(
|
|
27549
27669
|
` Moved ${path55.relative(cwd, sourcePath)} \u2192 ${path55.relative(cwd, destPath)}`
|
|
27550
27670
|
)
|
|
27551
27671
|
);
|
|
@@ -27632,16 +27752,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
27632
27752
|
|
|
27633
27753
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
27634
27754
|
import path57 from "path";
|
|
27635
|
-
import
|
|
27755
|
+
import chalk201 from "chalk";
|
|
27636
27756
|
function printRenamePreview(rewrites, cwd) {
|
|
27637
27757
|
for (const rewrite of rewrites) {
|
|
27638
27758
|
console.log(
|
|
27639
|
-
|
|
27759
|
+
chalk201.dim(
|
|
27640
27760
|
` ${path57.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
27641
27761
|
)
|
|
27642
27762
|
);
|
|
27643
27763
|
}
|
|
27644
|
-
console.log(
|
|
27764
|
+
console.log(chalk201.dim("Dry run. Use --apply to execute."));
|
|
27645
27765
|
}
|
|
27646
27766
|
|
|
27647
27767
|
// src/commands/refactor/rename/index.ts
|
|
@@ -27652,20 +27772,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27652
27772
|
const relSource = path58.relative(cwd, sourcePath);
|
|
27653
27773
|
const relDest = path58.relative(cwd, destPath);
|
|
27654
27774
|
if (!fs36.existsSync(sourcePath)) {
|
|
27655
|
-
console.log(
|
|
27775
|
+
console.log(chalk202.red(`File not found: ${source}`));
|
|
27656
27776
|
process.exit(1);
|
|
27657
27777
|
}
|
|
27658
27778
|
if (destPath !== sourcePath && fs36.existsSync(destPath)) {
|
|
27659
|
-
console.log(
|
|
27779
|
+
console.log(chalk202.red(`Destination already exists: ${destination}`));
|
|
27660
27780
|
process.exit(1);
|
|
27661
27781
|
}
|
|
27662
|
-
console.log(
|
|
27663
|
-
console.log(
|
|
27664
|
-
console.log(
|
|
27782
|
+
console.log(chalk202.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
27783
|
+
console.log(chalk202.dim("Loading project..."));
|
|
27784
|
+
console.log(chalk202.dim("Scanning imports across the project..."));
|
|
27665
27785
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
27666
27786
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
27667
27787
|
console.log(
|
|
27668
|
-
|
|
27788
|
+
chalk202.dim(
|
|
27669
27789
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
27670
27790
|
)
|
|
27671
27791
|
);
|
|
@@ -27674,11 +27794,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
27674
27794
|
return;
|
|
27675
27795
|
}
|
|
27676
27796
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
27677
|
-
console.log(
|
|
27797
|
+
console.log(chalk202.green("Done"));
|
|
27678
27798
|
}
|
|
27679
27799
|
|
|
27680
27800
|
// src/commands/refactor/renameSymbol/index.ts
|
|
27681
|
-
import
|
|
27801
|
+
import chalk203 from "chalk";
|
|
27682
27802
|
|
|
27683
27803
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
27684
27804
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -27724,33 +27844,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
27724
27844
|
const { project, sourceFile } = loadProjectFile(file);
|
|
27725
27845
|
const symbol = findSymbol(sourceFile, oldName);
|
|
27726
27846
|
if (!symbol) {
|
|
27727
|
-
console.log(
|
|
27847
|
+
console.log(chalk203.red(`Symbol "${oldName}" not found in ${file}`));
|
|
27728
27848
|
process.exit(1);
|
|
27729
27849
|
}
|
|
27730
27850
|
const grouped = groupReferences(symbol, cwd);
|
|
27731
27851
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
27732
27852
|
console.log(
|
|
27733
|
-
|
|
27853
|
+
chalk203.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
27734
27854
|
`)
|
|
27735
27855
|
);
|
|
27736
27856
|
for (const [refFile, lines2] of grouped) {
|
|
27737
27857
|
console.log(
|
|
27738
|
-
` ${
|
|
27858
|
+
` ${chalk203.dim(refFile)}: lines ${chalk203.cyan(lines2.join(", "))}`
|
|
27739
27859
|
);
|
|
27740
27860
|
}
|
|
27741
27861
|
if (options2.apply) {
|
|
27742
27862
|
symbol.rename(newName);
|
|
27743
27863
|
await project.save();
|
|
27744
|
-
console.log(
|
|
27864
|
+
console.log(chalk203.green(`
|
|
27745
27865
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
27746
27866
|
} else {
|
|
27747
|
-
console.log(
|
|
27867
|
+
console.log(chalk203.dim("\nDry run. Use --apply to execute."));
|
|
27748
27868
|
}
|
|
27749
27869
|
}
|
|
27750
27870
|
|
|
27751
27871
|
// src/commands/refactor/restructure/index.ts
|
|
27752
27872
|
import path66 from "path";
|
|
27753
|
-
import
|
|
27873
|
+
import chalk206 from "chalk";
|
|
27754
27874
|
|
|
27755
27875
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
27756
27876
|
import path60 from "path";
|
|
@@ -27829,50 +27949,50 @@ function clusterFiles(graph) {
|
|
|
27829
27949
|
|
|
27830
27950
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
27831
27951
|
import path62 from "path";
|
|
27832
|
-
import
|
|
27952
|
+
import chalk204 from "chalk";
|
|
27833
27953
|
function relPath(filePath) {
|
|
27834
27954
|
return path62.relative(process.cwd(), filePath);
|
|
27835
27955
|
}
|
|
27836
27956
|
function displayMoves(plan2) {
|
|
27837
27957
|
if (plan2.moves.length === 0) return;
|
|
27838
|
-
console.log(
|
|
27958
|
+
console.log(chalk204.bold("\nFile moves:"));
|
|
27839
27959
|
for (const move2 of plan2.moves) {
|
|
27840
27960
|
console.log(
|
|
27841
|
-
` ${
|
|
27961
|
+
` ${chalk204.red(relPath(move2.from))} \u2192 ${chalk204.green(relPath(move2.to))}`
|
|
27842
27962
|
);
|
|
27843
|
-
console.log(
|
|
27963
|
+
console.log(chalk204.dim(` ${move2.reason}`));
|
|
27844
27964
|
}
|
|
27845
27965
|
}
|
|
27846
27966
|
function displayRewrites(rewrites) {
|
|
27847
27967
|
if (rewrites.length === 0) return;
|
|
27848
27968
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
27849
|
-
console.log(
|
|
27969
|
+
console.log(chalk204.bold(`
|
|
27850
27970
|
Import rewrites (${affectedFiles.size} files):`));
|
|
27851
27971
|
for (const file of affectedFiles) {
|
|
27852
|
-
console.log(` ${
|
|
27972
|
+
console.log(` ${chalk204.cyan(relPath(file))}:`);
|
|
27853
27973
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
27854
27974
|
(r) => r.file === file
|
|
27855
27975
|
)) {
|
|
27856
27976
|
console.log(
|
|
27857
|
-
` ${
|
|
27977
|
+
` ${chalk204.red(`"${oldSpecifier}"`)} \u2192 ${chalk204.green(`"${newSpecifier}"`)}`
|
|
27858
27978
|
);
|
|
27859
27979
|
}
|
|
27860
27980
|
}
|
|
27861
27981
|
}
|
|
27862
27982
|
function displayPlan2(plan2) {
|
|
27863
27983
|
if (plan2.warnings.length > 0) {
|
|
27864
|
-
console.log(
|
|
27865
|
-
for (const w of plan2.warnings) console.log(
|
|
27984
|
+
console.log(chalk204.yellow("\nWarnings:"));
|
|
27985
|
+
for (const w of plan2.warnings) console.log(chalk204.yellow(` ${w}`));
|
|
27866
27986
|
}
|
|
27867
27987
|
if (plan2.newDirectories.length > 0) {
|
|
27868
|
-
console.log(
|
|
27988
|
+
console.log(chalk204.bold("\nNew directories:"));
|
|
27869
27989
|
for (const dir of plan2.newDirectories)
|
|
27870
|
-
console.log(
|
|
27990
|
+
console.log(chalk204.green(` ${dir}/`));
|
|
27871
27991
|
}
|
|
27872
27992
|
displayMoves(plan2);
|
|
27873
27993
|
displayRewrites(plan2.rewrites);
|
|
27874
27994
|
console.log(
|
|
27875
|
-
|
|
27995
|
+
chalk204.dim(
|
|
27876
27996
|
`
|
|
27877
27997
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
27878
27998
|
)
|
|
@@ -27882,18 +28002,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
27882
28002
|
// src/commands/refactor/restructure/executePlan.ts
|
|
27883
28003
|
import fs37 from "fs";
|
|
27884
28004
|
import path63 from "path";
|
|
27885
|
-
import
|
|
28005
|
+
import chalk205 from "chalk";
|
|
27886
28006
|
function executePlan(plan2) {
|
|
27887
28007
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
27888
28008
|
for (const [file, content] of updatedContents) {
|
|
27889
28009
|
fs37.writeFileSync(file, content, "utf8");
|
|
27890
28010
|
console.log(
|
|
27891
|
-
|
|
28011
|
+
chalk205.cyan(` Rewrote imports in ${path63.relative(process.cwd(), file)}`)
|
|
27892
28012
|
);
|
|
27893
28013
|
}
|
|
27894
28014
|
for (const dir of plan2.newDirectories) {
|
|
27895
28015
|
fs37.mkdirSync(dir, { recursive: true });
|
|
27896
|
-
console.log(
|
|
28016
|
+
console.log(chalk205.green(` Created ${path63.relative(process.cwd(), dir)}/`));
|
|
27897
28017
|
}
|
|
27898
28018
|
for (const move2 of plan2.moves) {
|
|
27899
28019
|
const targetDir = path63.dirname(move2.to);
|
|
@@ -27902,7 +28022,7 @@ function executePlan(plan2) {
|
|
|
27902
28022
|
}
|
|
27903
28023
|
fs37.renameSync(move2.from, move2.to);
|
|
27904
28024
|
console.log(
|
|
27905
|
-
|
|
28025
|
+
chalk205.white(
|
|
27906
28026
|
` Moved ${path63.relative(process.cwd(), move2.from)} \u2192 ${path63.relative(process.cwd(), move2.to)}`
|
|
27907
28027
|
)
|
|
27908
28028
|
);
|
|
@@ -27917,7 +28037,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
27917
28037
|
if (entries.length === 0) {
|
|
27918
28038
|
fs37.rmdirSync(dir);
|
|
27919
28039
|
console.log(
|
|
27920
|
-
|
|
28040
|
+
chalk205.dim(
|
|
27921
28041
|
` Removed empty directory ${path63.relative(process.cwd(), dir)}`
|
|
27922
28042
|
)
|
|
27923
28043
|
);
|
|
@@ -28050,22 +28170,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
28050
28170
|
const targetPattern = pattern2 ?? "src";
|
|
28051
28171
|
const files = findSourceFiles2(targetPattern);
|
|
28052
28172
|
if (files.length === 0) {
|
|
28053
|
-
console.log(
|
|
28173
|
+
console.log(chalk206.yellow("No files found matching pattern"));
|
|
28054
28174
|
return;
|
|
28055
28175
|
}
|
|
28056
28176
|
const tsConfigPath = findTsConfig(path66.resolve(files[0]));
|
|
28057
28177
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
28058
28178
|
if (plan2.moves.length === 0) {
|
|
28059
|
-
console.log(
|
|
28179
|
+
console.log(chalk206.green("No restructuring needed"));
|
|
28060
28180
|
return;
|
|
28061
28181
|
}
|
|
28062
28182
|
displayPlan2(plan2);
|
|
28063
28183
|
if (options2.apply) {
|
|
28064
|
-
console.log(
|
|
28184
|
+
console.log(chalk206.bold("\nApplying changes..."));
|
|
28065
28185
|
executePlan(plan2);
|
|
28066
|
-
console.log(
|
|
28186
|
+
console.log(chalk206.green("\nRestructuring complete"));
|
|
28067
28187
|
} else {
|
|
28068
|
-
console.log(
|
|
28188
|
+
console.log(chalk206.dim("\nDry run. Use --apply to execute."));
|
|
28069
28189
|
}
|
|
28070
28190
|
}
|
|
28071
28191
|
|
|
@@ -28231,11 +28351,11 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
28231
28351
|
}
|
|
28232
28352
|
|
|
28233
28353
|
// src/commands/review/buildReviewPaths.ts
|
|
28234
|
-
import { homedir as
|
|
28235
|
-
import { basename as basename18, join as
|
|
28354
|
+
import { homedir as homedir23 } from "os";
|
|
28355
|
+
import { basename as basename18, join as join71 } from "path";
|
|
28236
28356
|
function buildReviewPaths(repoRoot2, key) {
|
|
28237
|
-
const reviewDir =
|
|
28238
|
-
|
|
28357
|
+
const reviewDir = join71(
|
|
28358
|
+
homedir23(),
|
|
28239
28359
|
".assist",
|
|
28240
28360
|
"reviews",
|
|
28241
28361
|
basename18(repoRoot2),
|
|
@@ -28243,10 +28363,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
28243
28363
|
);
|
|
28244
28364
|
return {
|
|
28245
28365
|
reviewDir,
|
|
28246
|
-
requestPath:
|
|
28247
|
-
claudePath:
|
|
28248
|
-
codexPath:
|
|
28249
|
-
synthesisPath:
|
|
28366
|
+
requestPath: join71(reviewDir, "request.md"),
|
|
28367
|
+
claudePath: join71(reviewDir, "claude.md"),
|
|
28368
|
+
codexPath: join71(reviewDir, "codex.md"),
|
|
28369
|
+
synthesisPath: join71(reviewDir, "synthesis.md")
|
|
28250
28370
|
};
|
|
28251
28371
|
}
|
|
28252
28372
|
|
|
@@ -28723,18 +28843,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
28723
28843
|
}
|
|
28724
28844
|
|
|
28725
28845
|
// src/commands/review/warnOutOfDiff.ts
|
|
28726
|
-
import
|
|
28846
|
+
import chalk207 from "chalk";
|
|
28727
28847
|
function warnOutOfDiff(outOfDiff) {
|
|
28728
28848
|
if (outOfDiff.length === 0) return;
|
|
28729
28849
|
console.warn(
|
|
28730
|
-
|
|
28850
|
+
chalk207.yellow(
|
|
28731
28851
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
28732
28852
|
)
|
|
28733
28853
|
);
|
|
28734
28854
|
for (const finding of outOfDiff) {
|
|
28735
28855
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
28736
28856
|
console.warn(
|
|
28737
|
-
` ${
|
|
28857
|
+
` ${chalk207.yellow("\xB7")} ${finding.title} ${chalk207.dim(
|
|
28738
28858
|
`(${finding.file}:${range})`
|
|
28739
28859
|
)}`
|
|
28740
28860
|
);
|
|
@@ -28758,18 +28878,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
28758
28878
|
}
|
|
28759
28879
|
|
|
28760
28880
|
// src/commands/review/warnUnlocated.ts
|
|
28761
|
-
import
|
|
28881
|
+
import chalk208 from "chalk";
|
|
28762
28882
|
function warnUnlocated(unlocated) {
|
|
28763
28883
|
if (unlocated.length === 0) return;
|
|
28764
28884
|
console.warn(
|
|
28765
|
-
|
|
28885
|
+
chalk208.yellow(
|
|
28766
28886
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
28767
28887
|
)
|
|
28768
28888
|
);
|
|
28769
28889
|
for (const finding of unlocated) {
|
|
28770
|
-
const where = finding.location ||
|
|
28890
|
+
const where = finding.location || chalk208.dim("missing");
|
|
28771
28891
|
console.warn(
|
|
28772
|
-
` ${
|
|
28892
|
+
` ${chalk208.yellow("\xB7")} ${finding.title} ${chalk208.dim(`(${where})`)}`
|
|
28773
28893
|
);
|
|
28774
28894
|
}
|
|
28775
28895
|
}
|
|
@@ -28972,10 +29092,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
28972
29092
|
}
|
|
28973
29093
|
|
|
28974
29094
|
// src/commands/review/prepareReviewDir.ts
|
|
28975
|
-
import { existsSync as
|
|
29095
|
+
import { existsSync as existsSync61, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
28976
29096
|
function clearReviewFiles(paths) {
|
|
28977
29097
|
for (const path84 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
28978
|
-
if (
|
|
29098
|
+
if (existsSync61(path84)) unlinkSync17(path84);
|
|
28979
29099
|
}
|
|
28980
29100
|
}
|
|
28981
29101
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -29202,7 +29322,7 @@ function printReviewerFailures(results) {
|
|
|
29202
29322
|
}
|
|
29203
29323
|
|
|
29204
29324
|
// src/commands/review/runAndSynthesise.ts
|
|
29205
|
-
import { existsSync as
|
|
29325
|
+
import { existsSync as existsSync63, unlinkSync as unlinkSync19 } from "fs";
|
|
29206
29326
|
|
|
29207
29327
|
// src/commands/review/buildReviewerStdin.ts
|
|
29208
29328
|
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 +29751,7 @@ function resolveClaude(args) {
|
|
|
29631
29751
|
}
|
|
29632
29752
|
|
|
29633
29753
|
// src/commands/review/runCodexReviewer.ts
|
|
29634
|
-
import { existsSync as
|
|
29754
|
+
import { existsSync as existsSync62, unlinkSync as unlinkSync18 } from "fs";
|
|
29635
29755
|
|
|
29636
29756
|
// src/commands/review/parseCodexEvent.ts
|
|
29637
29757
|
function isItemStarted(value) {
|
|
@@ -29683,7 +29803,7 @@ async function runCodexReviewer(spec) {
|
|
|
29683
29803
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
29684
29804
|
}
|
|
29685
29805
|
});
|
|
29686
|
-
if (result.exitCode !== 0 &&
|
|
29806
|
+
if (result.exitCode !== 0 && existsSync62(spec.outputPath)) {
|
|
29687
29807
|
unlinkSync18(spec.outputPath);
|
|
29688
29808
|
}
|
|
29689
29809
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -29838,7 +29958,7 @@ async function runAndSynthesise(args) {
|
|
|
29838
29958
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
29839
29959
|
return { ok: false, failures };
|
|
29840
29960
|
}
|
|
29841
|
-
if (anyFresh &&
|
|
29961
|
+
if (anyFresh && existsSync63(paths.synthesisPath)) {
|
|
29842
29962
|
unlinkSync19(paths.synthesisPath);
|
|
29843
29963
|
}
|
|
29844
29964
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -30025,13 +30145,13 @@ function registerReview(program2) {
|
|
|
30025
30145
|
|
|
30026
30146
|
// src/commands/rules/listRules.ts
|
|
30027
30147
|
import path67 from "path";
|
|
30028
|
-
import
|
|
30148
|
+
import chalk209 from "chalk";
|
|
30029
30149
|
function listRules(target) {
|
|
30030
30150
|
const resolved = path67.resolve(target ?? process.cwd());
|
|
30031
30151
|
const rules3 = readScopedRules(resolved);
|
|
30032
30152
|
if (rules3.length === 0) {
|
|
30033
30153
|
const label2 = path67.relative(process.cwd(), resolved) || ".";
|
|
30034
|
-
console.log(
|
|
30154
|
+
console.log(chalk209.gray(`No rules in scope for ${label2}`));
|
|
30035
30155
|
return;
|
|
30036
30156
|
}
|
|
30037
30157
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -30041,10 +30161,10 @@ function listRules(target) {
|
|
|
30041
30161
|
if (rule.source !== shown) {
|
|
30042
30162
|
shown = rule.source;
|
|
30043
30163
|
console.log(
|
|
30044
|
-
|
|
30164
|
+
chalk209.dim(base ? path67.relative(base, rule.source) : rule.source)
|
|
30045
30165
|
);
|
|
30046
30166
|
}
|
|
30047
|
-
console.log(` ${
|
|
30167
|
+
console.log(` ${chalk209.cyan(rule.code.padEnd(width))} ${rule.text}`);
|
|
30048
30168
|
}
|
|
30049
30169
|
}
|
|
30050
30170
|
|
|
@@ -30057,7 +30177,7 @@ function registerRules(program2) {
|
|
|
30057
30177
|
}
|
|
30058
30178
|
|
|
30059
30179
|
// src/commands/seq/seqAuth.ts
|
|
30060
|
-
import
|
|
30180
|
+
import chalk211 from "chalk";
|
|
30061
30181
|
|
|
30062
30182
|
// src/commands/seq/loadConnections.ts
|
|
30063
30183
|
function loadConnections2() {
|
|
@@ -30086,10 +30206,10 @@ function setDefaultConnection(name) {
|
|
|
30086
30206
|
}
|
|
30087
30207
|
|
|
30088
30208
|
// src/shared/assertUniqueName.ts
|
|
30089
|
-
import
|
|
30209
|
+
import chalk210 from "chalk";
|
|
30090
30210
|
function assertUniqueName(existingNames, name) {
|
|
30091
30211
|
if (existingNames.includes(name)) {
|
|
30092
|
-
console.error(
|
|
30212
|
+
console.error(chalk210.red(`Connection "${name}" already exists.`));
|
|
30093
30213
|
process.exit(1);
|
|
30094
30214
|
}
|
|
30095
30215
|
}
|
|
@@ -30107,16 +30227,16 @@ async function promptConnection2(existingNames) {
|
|
|
30107
30227
|
var seqAuth = createConnectionAuth({
|
|
30108
30228
|
load: loadConnections2,
|
|
30109
30229
|
save: saveConnections2,
|
|
30110
|
-
format: (c) => `${
|
|
30230
|
+
format: (c) => `${chalk211.bold(c.name)} ${c.url}`,
|
|
30111
30231
|
promptNew: promptConnection2,
|
|
30112
30232
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
30113
30233
|
});
|
|
30114
30234
|
|
|
30115
30235
|
// src/commands/seq/seqQuery.ts
|
|
30116
|
-
import
|
|
30236
|
+
import chalk215 from "chalk";
|
|
30117
30237
|
|
|
30118
30238
|
// src/commands/seq/fetchSeq.ts
|
|
30119
|
-
import
|
|
30239
|
+
import chalk212 from "chalk";
|
|
30120
30240
|
async function fetchSeq(conn, path84, params) {
|
|
30121
30241
|
const url = `${conn.url}${path84}?${params}`;
|
|
30122
30242
|
const response = await fetch(url, {
|
|
@@ -30127,7 +30247,7 @@ async function fetchSeq(conn, path84, params) {
|
|
|
30127
30247
|
});
|
|
30128
30248
|
if (!response.ok) {
|
|
30129
30249
|
const body = await response.text();
|
|
30130
|
-
console.error(
|
|
30250
|
+
console.error(chalk212.red(`Seq returned ${response.status}: ${body}`));
|
|
30131
30251
|
process.exit(1);
|
|
30132
30252
|
}
|
|
30133
30253
|
return response;
|
|
@@ -30186,23 +30306,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
30186
30306
|
}
|
|
30187
30307
|
|
|
30188
30308
|
// src/commands/seq/formatEvent.ts
|
|
30189
|
-
import
|
|
30309
|
+
import chalk213 from "chalk";
|
|
30190
30310
|
function levelColor(level) {
|
|
30191
30311
|
switch (level) {
|
|
30192
30312
|
case "Fatal":
|
|
30193
|
-
return
|
|
30313
|
+
return chalk213.bgRed.white;
|
|
30194
30314
|
case "Error":
|
|
30195
|
-
return
|
|
30315
|
+
return chalk213.red;
|
|
30196
30316
|
case "Warning":
|
|
30197
|
-
return
|
|
30317
|
+
return chalk213.yellow;
|
|
30198
30318
|
case "Information":
|
|
30199
|
-
return
|
|
30319
|
+
return chalk213.cyan;
|
|
30200
30320
|
case "Debug":
|
|
30201
|
-
return
|
|
30321
|
+
return chalk213.gray;
|
|
30202
30322
|
case "Verbose":
|
|
30203
|
-
return
|
|
30323
|
+
return chalk213.dim;
|
|
30204
30324
|
default:
|
|
30205
|
-
return
|
|
30325
|
+
return chalk213.white;
|
|
30206
30326
|
}
|
|
30207
30327
|
}
|
|
30208
30328
|
function levelAbbrev(level) {
|
|
@@ -30243,12 +30363,12 @@ function formatTimestamp(iso) {
|
|
|
30243
30363
|
function formatEvent(event) {
|
|
30244
30364
|
const color = levelColor(event.Level);
|
|
30245
30365
|
const abbrev = levelAbbrev(event.Level);
|
|
30246
|
-
const ts8 =
|
|
30366
|
+
const ts8 = chalk213.dim(formatTimestamp(event.Timestamp));
|
|
30247
30367
|
const msg = renderMessage(event);
|
|
30248
30368
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
30249
30369
|
if (event.Exception) {
|
|
30250
30370
|
for (const line of event.Exception.split("\n")) {
|
|
30251
|
-
lines2.push(
|
|
30371
|
+
lines2.push(chalk213.red(` ${line}`));
|
|
30252
30372
|
}
|
|
30253
30373
|
}
|
|
30254
30374
|
return lines2.join("\n");
|
|
@@ -30281,11 +30401,11 @@ function rejectTimestampFilter(filter) {
|
|
|
30281
30401
|
}
|
|
30282
30402
|
|
|
30283
30403
|
// src/shared/resolveNamedConnection.ts
|
|
30284
|
-
import
|
|
30404
|
+
import chalk214 from "chalk";
|
|
30285
30405
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
30286
30406
|
if (connections.length === 0) {
|
|
30287
30407
|
console.error(
|
|
30288
|
-
|
|
30408
|
+
chalk214.red(
|
|
30289
30409
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
30290
30410
|
)
|
|
30291
30411
|
);
|
|
@@ -30294,7 +30414,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
30294
30414
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
30295
30415
|
const connection = connections.find((c) => c.name === target);
|
|
30296
30416
|
if (!connection) {
|
|
30297
|
-
console.error(
|
|
30417
|
+
console.error(chalk214.red(`${kind} connection "${target}" not found.`));
|
|
30298
30418
|
process.exit(1);
|
|
30299
30419
|
}
|
|
30300
30420
|
return connection;
|
|
@@ -30323,7 +30443,7 @@ async function seqQuery(filter, options2) {
|
|
|
30323
30443
|
new URLSearchParams({ filter, count: String(count8) })
|
|
30324
30444
|
);
|
|
30325
30445
|
if (events.length === 0) {
|
|
30326
|
-
console.log(
|
|
30446
|
+
console.log(chalk215.yellow("No events found."));
|
|
30327
30447
|
return;
|
|
30328
30448
|
}
|
|
30329
30449
|
if (options2.json) {
|
|
@@ -30334,11 +30454,11 @@ async function seqQuery(filter, options2) {
|
|
|
30334
30454
|
for (const event of chronological) {
|
|
30335
30455
|
console.log(formatEvent(event));
|
|
30336
30456
|
}
|
|
30337
|
-
console.log(
|
|
30457
|
+
console.log(chalk215.dim(`
|
|
30338
30458
|
${events.length} events`));
|
|
30339
30459
|
if (events.length >= count8) {
|
|
30340
30460
|
console.log(
|
|
30341
|
-
|
|
30461
|
+
chalk215.yellow(
|
|
30342
30462
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
30343
30463
|
)
|
|
30344
30464
|
);
|
|
@@ -30346,10 +30466,10 @@ ${events.length} events`));
|
|
|
30346
30466
|
}
|
|
30347
30467
|
|
|
30348
30468
|
// src/shared/setNamedDefaultConnection.ts
|
|
30349
|
-
import
|
|
30469
|
+
import chalk216 from "chalk";
|
|
30350
30470
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
30351
30471
|
if (!connections.find((c) => c.name === name)) {
|
|
30352
|
-
console.error(
|
|
30472
|
+
console.error(chalk216.red(`Connection "${name}" not found.`));
|
|
30353
30473
|
process.exit(1);
|
|
30354
30474
|
}
|
|
30355
30475
|
setDefault(name);
|
|
@@ -30398,7 +30518,7 @@ function registerSignal(program2) {
|
|
|
30398
30518
|
}
|
|
30399
30519
|
|
|
30400
30520
|
// src/commands/sql/sqlAuth.ts
|
|
30401
|
-
import
|
|
30521
|
+
import chalk218 from "chalk";
|
|
30402
30522
|
|
|
30403
30523
|
// src/commands/sql/loadConnections.ts
|
|
30404
30524
|
function loadConnections3() {
|
|
@@ -30427,7 +30547,7 @@ function setDefaultConnection2(name) {
|
|
|
30427
30547
|
}
|
|
30428
30548
|
|
|
30429
30549
|
// src/commands/sql/promptConnection.ts
|
|
30430
|
-
import
|
|
30550
|
+
import chalk217 from "chalk";
|
|
30431
30551
|
async function promptConnection3(existingNames) {
|
|
30432
30552
|
const name = await promptInput("name", "Connection name:", "default");
|
|
30433
30553
|
assertUniqueName(existingNames, name);
|
|
@@ -30435,7 +30555,7 @@ async function promptConnection3(existingNames) {
|
|
|
30435
30555
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
30436
30556
|
const port = Number.parseInt(portStr, 10);
|
|
30437
30557
|
if (!Number.isFinite(port)) {
|
|
30438
|
-
console.error(
|
|
30558
|
+
console.error(chalk217.red(`Invalid port "${portStr}".`));
|
|
30439
30559
|
process.exit(1);
|
|
30440
30560
|
}
|
|
30441
30561
|
const user = await promptInput("user", "User:");
|
|
@@ -30448,13 +30568,13 @@ async function promptConnection3(existingNames) {
|
|
|
30448
30568
|
var sqlAuth = createConnectionAuth({
|
|
30449
30569
|
load: loadConnections3,
|
|
30450
30570
|
save: saveConnections3,
|
|
30451
|
-
format: (c) => `${
|
|
30571
|
+
format: (c) => `${chalk218.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
30452
30572
|
promptNew: promptConnection3,
|
|
30453
30573
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
30454
30574
|
});
|
|
30455
30575
|
|
|
30456
30576
|
// src/commands/sql/printTable.ts
|
|
30457
|
-
import
|
|
30577
|
+
import chalk219 from "chalk";
|
|
30458
30578
|
function formatCell(value) {
|
|
30459
30579
|
if (value === null || value === void 0) return "";
|
|
30460
30580
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -30463,7 +30583,7 @@ function formatCell(value) {
|
|
|
30463
30583
|
}
|
|
30464
30584
|
function printTable(rows) {
|
|
30465
30585
|
if (rows.length === 0) {
|
|
30466
|
-
console.log(
|
|
30586
|
+
console.log(chalk219.yellow("(no rows)"));
|
|
30467
30587
|
return;
|
|
30468
30588
|
}
|
|
30469
30589
|
const columns = Object.keys(rows[0]);
|
|
@@ -30471,13 +30591,13 @@ function printTable(rows) {
|
|
|
30471
30591
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
30472
30592
|
);
|
|
30473
30593
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
30474
|
-
console.log(
|
|
30475
|
-
console.log(
|
|
30594
|
+
console.log(chalk219.dim(header));
|
|
30595
|
+
console.log(chalk219.dim("-".repeat(header.length)));
|
|
30476
30596
|
for (const row of rows) {
|
|
30477
30597
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
30478
30598
|
console.log(line);
|
|
30479
30599
|
}
|
|
30480
|
-
console.log(
|
|
30600
|
+
console.log(chalk219.dim(`
|
|
30481
30601
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
30482
30602
|
}
|
|
30483
30603
|
|
|
@@ -30537,7 +30657,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
30537
30657
|
}
|
|
30538
30658
|
|
|
30539
30659
|
// src/commands/sql/sqlMutate.ts
|
|
30540
|
-
import
|
|
30660
|
+
import chalk220 from "chalk";
|
|
30541
30661
|
|
|
30542
30662
|
// src/commands/sql/isMutation.ts
|
|
30543
30663
|
var MUTATION_KEYWORDS = [
|
|
@@ -30571,7 +30691,7 @@ function isMutation(sql25) {
|
|
|
30571
30691
|
async function sqlMutate(query, connectionName) {
|
|
30572
30692
|
if (!isMutation(query)) {
|
|
30573
30693
|
console.error(
|
|
30574
|
-
|
|
30694
|
+
chalk220.red(
|
|
30575
30695
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
30576
30696
|
)
|
|
30577
30697
|
);
|
|
@@ -30581,18 +30701,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
30581
30701
|
const pool = await sqlConnect(conn);
|
|
30582
30702
|
try {
|
|
30583
30703
|
const result = await pool.request().query(query);
|
|
30584
|
-
console.log(
|
|
30704
|
+
console.log(chalk220.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
30585
30705
|
} finally {
|
|
30586
30706
|
await pool.close();
|
|
30587
30707
|
}
|
|
30588
30708
|
}
|
|
30589
30709
|
|
|
30590
30710
|
// src/commands/sql/sqlQuery.ts
|
|
30591
|
-
import
|
|
30711
|
+
import chalk221 from "chalk";
|
|
30592
30712
|
async function sqlQuery(query, connectionName) {
|
|
30593
30713
|
if (isMutation(query)) {
|
|
30594
30714
|
console.error(
|
|
30595
|
-
|
|
30715
|
+
chalk221.red(
|
|
30596
30716
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
30597
30717
|
)
|
|
30598
30718
|
);
|
|
@@ -30607,7 +30727,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
30607
30727
|
printTable(rows);
|
|
30608
30728
|
} else {
|
|
30609
30729
|
console.log(
|
|
30610
|
-
|
|
30730
|
+
chalk221.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
30611
30731
|
);
|
|
30612
30732
|
}
|
|
30613
30733
|
} finally {
|
|
@@ -30752,7 +30872,7 @@ function reportPrune(label2, result, force) {
|
|
|
30752
30872
|
// src/commands/sync/syncClaudeMd.ts
|
|
30753
30873
|
import * as fs41 from "fs";
|
|
30754
30874
|
import * as path70 from "path";
|
|
30755
|
-
import
|
|
30875
|
+
import chalk222 from "chalk";
|
|
30756
30876
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
30757
30877
|
const source = path70.join(claudeDir, "CLAUDE.md");
|
|
30758
30878
|
const target = path70.join(targetBase, "CLAUDE.md");
|
|
@@ -30761,14 +30881,14 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
30761
30881
|
const targetContent = fs41.readFileSync(target, "utf8");
|
|
30762
30882
|
if (sourceContent !== targetContent) {
|
|
30763
30883
|
console.log(
|
|
30764
|
-
|
|
30884
|
+
chalk222.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
30765
30885
|
);
|
|
30766
30886
|
console.log();
|
|
30767
30887
|
printDiff(targetContent, sourceContent);
|
|
30768
30888
|
if (!options2?.yes) {
|
|
30769
30889
|
printAutoConfirmHint();
|
|
30770
30890
|
const confirm = await promptConfirm(
|
|
30771
|
-
|
|
30891
|
+
chalk222.red("Overwrite existing CLAUDE.md?"),
|
|
30772
30892
|
false
|
|
30773
30893
|
);
|
|
30774
30894
|
if (!confirm) {
|
|
@@ -31001,7 +31121,7 @@ function syncPi(claudeDir, options2) {
|
|
|
31001
31121
|
// src/commands/sync/syncSettings.ts
|
|
31002
31122
|
import * as fs47 from "fs";
|
|
31003
31123
|
import * as path77 from "path";
|
|
31004
|
-
import
|
|
31124
|
+
import chalk223 from "chalk";
|
|
31005
31125
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
31006
31126
|
const source = path77.join(claudeDir, "settings.json");
|
|
31007
31127
|
const target = path77.join(targetBase, "settings.json");
|
|
@@ -31020,7 +31140,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
31020
31140
|
if (mergedContent !== normalizedTarget) {
|
|
31021
31141
|
if (!options2?.yes) {
|
|
31022
31142
|
console.log(
|
|
31023
|
-
|
|
31143
|
+
chalk223.yellow(
|
|
31024
31144
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
31025
31145
|
)
|
|
31026
31146
|
);
|
|
@@ -31028,7 +31148,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
31028
31148
|
printDiff(targetContent, mergedContent);
|
|
31029
31149
|
printAutoConfirmHint();
|
|
31030
31150
|
const confirm = await promptConfirm(
|
|
31031
|
-
|
|
31151
|
+
chalk223.red("Overwrite existing settings.json?"),
|
|
31032
31152
|
false
|
|
31033
31153
|
);
|
|
31034
31154
|
if (!confirm) {
|
|
@@ -31100,7 +31220,7 @@ function registerSync(program2) {
|
|
|
31100
31220
|
}
|
|
31101
31221
|
|
|
31102
31222
|
// src/commands/transcript/clean.ts
|
|
31103
|
-
import { existsSync as
|
|
31223
|
+
import { existsSync as existsSync68 } from "fs";
|
|
31104
31224
|
|
|
31105
31225
|
// src/commands/transcript/cleanText.ts
|
|
31106
31226
|
function cleanText(text18) {
|
|
@@ -31345,7 +31465,7 @@ function clean(file, options2 = {}) {
|
|
|
31345
31465
|
);
|
|
31346
31466
|
process.exit(1);
|
|
31347
31467
|
}
|
|
31348
|
-
if (!
|
|
31468
|
+
if (!existsSync68(file)) {
|
|
31349
31469
|
console.error(`Error: VTT file not found: ${file}`);
|
|
31350
31470
|
process.exit(1);
|
|
31351
31471
|
}
|
|
@@ -31428,21 +31548,21 @@ async function configure() {
|
|
|
31428
31548
|
}
|
|
31429
31549
|
|
|
31430
31550
|
// src/commands/transcript/list.ts
|
|
31431
|
-
import { existsSync as
|
|
31432
|
-
import { join as
|
|
31551
|
+
import { existsSync as existsSync69, readdirSync as readdirSync19, statSync as statSync11 } from "fs";
|
|
31552
|
+
import { join as join82 } from "path";
|
|
31433
31553
|
function list4() {
|
|
31434
31554
|
const { vttDir } = getTranscriptConfig();
|
|
31435
|
-
if (!
|
|
31555
|
+
if (!existsSync69(vttDir)) return;
|
|
31436
31556
|
for (const entry of readdirSync19(vttDir)) {
|
|
31437
31557
|
if (!entry.endsWith(".vtt")) continue;
|
|
31438
|
-
if (statSync11(
|
|
31558
|
+
if (statSync11(join82(vttDir, entry)).isDirectory()) continue;
|
|
31439
31559
|
console.log(entry);
|
|
31440
31560
|
}
|
|
31441
31561
|
}
|
|
31442
31562
|
|
|
31443
31563
|
// src/commands/transcript/move.ts
|
|
31444
|
-
import { existsSync as
|
|
31445
|
-
import { basename as basename21, join as
|
|
31564
|
+
import { existsSync as existsSync70, mkdirSync as mkdirSync27, renameSync as renameSync2, writeFileSync as writeFileSync43 } from "fs";
|
|
31565
|
+
import { basename as basename21, join as join83 } from "path";
|
|
31446
31566
|
|
|
31447
31567
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
31448
31568
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -31452,9 +31572,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
31452
31572
|
// src/commands/transcript/move.ts
|
|
31453
31573
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
31454
31574
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
31455
|
-
const processedDir =
|
|
31575
|
+
const processedDir = join83(vttDir, "processed");
|
|
31456
31576
|
mkdirSync27(processedDir, { recursive: true });
|
|
31457
|
-
renameSync2(sourcePath,
|
|
31577
|
+
renameSync2(sourcePath, join83(processedDir, filename));
|
|
31458
31578
|
}
|
|
31459
31579
|
function move(file, options2) {
|
|
31460
31580
|
const { date, client } = options2;
|
|
@@ -31464,19 +31584,19 @@ function move(file, options2) {
|
|
|
31464
31584
|
}
|
|
31465
31585
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
31466
31586
|
const filename = basename21(file);
|
|
31467
|
-
const sourcePath =
|
|
31468
|
-
if (!
|
|
31587
|
+
const sourcePath = join83(vttDir, filename);
|
|
31588
|
+
if (!existsSync70(sourcePath)) {
|
|
31469
31589
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
31470
31590
|
process.exit(1);
|
|
31471
31591
|
}
|
|
31472
31592
|
const base = basename21(filename, ".vtt").replace(/ Transcription$/, "");
|
|
31473
31593
|
const outputName = `${date} ${base}.md`;
|
|
31474
|
-
const formattedDir =
|
|
31594
|
+
const formattedDir = join83(transcriptsDir, client);
|
|
31475
31595
|
mkdirSync27(formattedDir, { recursive: true });
|
|
31476
|
-
const formattedPath =
|
|
31596
|
+
const formattedPath = join83(formattedDir, outputName);
|
|
31477
31597
|
writeFileSync43(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
31478
31598
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
31479
|
-
const summaryPath =
|
|
31599
|
+
const summaryPath = join83(summaryDir, client, outputName);
|
|
31480
31600
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
31481
31601
|
console.log(`Summary target: ${summaryPath}`);
|
|
31482
31602
|
}
|
|
@@ -31559,45 +31679,45 @@ function registerVerify(program2) {
|
|
|
31559
31679
|
|
|
31560
31680
|
// src/commands/voice/devices.ts
|
|
31561
31681
|
import { spawnSync as spawnSync8 } from "child_process";
|
|
31562
|
-
import { join as
|
|
31682
|
+
import { join as join85 } from "path";
|
|
31563
31683
|
|
|
31564
31684
|
// src/commands/voice/shared.ts
|
|
31565
|
-
import { homedir as
|
|
31566
|
-
import { dirname as dirname36, join as
|
|
31685
|
+
import { homedir as homedir25 } from "os";
|
|
31686
|
+
import { dirname as dirname36, join as join84 } from "path";
|
|
31567
31687
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
31568
31688
|
var __dirname6 = dirname36(fileURLToPath9(import.meta.url));
|
|
31569
|
-
var VOICE_DIR =
|
|
31689
|
+
var VOICE_DIR = join84(homedir25(), ".assist", "voice");
|
|
31570
31690
|
var voicePaths = {
|
|
31571
31691
|
dir: VOICE_DIR,
|
|
31572
|
-
pid:
|
|
31573
|
-
log:
|
|
31574
|
-
venv:
|
|
31575
|
-
lock:
|
|
31692
|
+
pid: join84(VOICE_DIR, "voice.pid"),
|
|
31693
|
+
log: join84(VOICE_DIR, "voice.log"),
|
|
31694
|
+
venv: join84(VOICE_DIR, ".venv"),
|
|
31695
|
+
lock: join84(VOICE_DIR, "voice.lock")
|
|
31576
31696
|
};
|
|
31577
31697
|
function getPythonDir() {
|
|
31578
|
-
return
|
|
31698
|
+
return join84(__dirname6, "commands", "voice", "python");
|
|
31579
31699
|
}
|
|
31580
31700
|
function getVenvPython() {
|
|
31581
|
-
return process.platform === "win32" ?
|
|
31701
|
+
return process.platform === "win32" ? join84(voicePaths.venv, "Scripts", "python.exe") : join84(voicePaths.venv, "bin", "python");
|
|
31582
31702
|
}
|
|
31583
31703
|
function getLockDir() {
|
|
31584
31704
|
const config = loadConfig();
|
|
31585
31705
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
31586
31706
|
}
|
|
31587
31707
|
function getLockFile() {
|
|
31588
|
-
return
|
|
31708
|
+
return join84(getLockDir(), "voice.lock");
|
|
31589
31709
|
}
|
|
31590
31710
|
|
|
31591
31711
|
// src/commands/voice/devices.ts
|
|
31592
31712
|
function devices() {
|
|
31593
|
-
const script =
|
|
31713
|
+
const script = join85(getPythonDir(), "list_devices.py");
|
|
31594
31714
|
spawnSync8(getVenvPython(), [script], { stdio: "inherit" });
|
|
31595
31715
|
}
|
|
31596
31716
|
|
|
31597
31717
|
// src/commands/voice/logs.ts
|
|
31598
|
-
import { existsSync as
|
|
31718
|
+
import { existsSync as existsSync71, readFileSync as readFileSync52 } from "fs";
|
|
31599
31719
|
function logs(options2) {
|
|
31600
|
-
if (!
|
|
31720
|
+
if (!existsSync71(voicePaths.log)) {
|
|
31601
31721
|
console.log("No voice log file found");
|
|
31602
31722
|
return;
|
|
31603
31723
|
}
|
|
@@ -31625,12 +31745,12 @@ function logs(options2) {
|
|
|
31625
31745
|
// src/commands/voice/setup.ts
|
|
31626
31746
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
31627
31747
|
import { mkdirSync as mkdirSync29 } from "fs";
|
|
31628
|
-
import { join as
|
|
31748
|
+
import { join as join87 } from "path";
|
|
31629
31749
|
|
|
31630
31750
|
// src/commands/voice/checkLockFile.ts
|
|
31631
31751
|
import { execSync as execSync58 } from "child_process";
|
|
31632
|
-
import { existsSync as
|
|
31633
|
-
import { join as
|
|
31752
|
+
import { existsSync as existsSync72, mkdirSync as mkdirSync28, readFileSync as readFileSync53, writeFileSync as writeFileSync44 } from "fs";
|
|
31753
|
+
import { join as join86 } from "path";
|
|
31634
31754
|
function isProcessAlive2(pid) {
|
|
31635
31755
|
try {
|
|
31636
31756
|
process.kill(pid, 0);
|
|
@@ -31641,7 +31761,7 @@ function isProcessAlive2(pid) {
|
|
|
31641
31761
|
}
|
|
31642
31762
|
function checkLockFile() {
|
|
31643
31763
|
const lockFile = getLockFile();
|
|
31644
|
-
if (!
|
|
31764
|
+
if (!existsSync72(lockFile)) return;
|
|
31645
31765
|
try {
|
|
31646
31766
|
const lock2 = JSON.parse(readFileSync53(lockFile, "utf8"));
|
|
31647
31767
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
@@ -31654,7 +31774,7 @@ function checkLockFile() {
|
|
|
31654
31774
|
}
|
|
31655
31775
|
}
|
|
31656
31776
|
function bootstrapVenv() {
|
|
31657
|
-
if (
|
|
31777
|
+
if (existsSync72(getVenvPython())) return;
|
|
31658
31778
|
console.log("Setting up Python environment...");
|
|
31659
31779
|
const pythonDir = getPythonDir();
|
|
31660
31780
|
execSync58(
|
|
@@ -31667,7 +31787,7 @@ function bootstrapVenv() {
|
|
|
31667
31787
|
}
|
|
31668
31788
|
function writeLockFile(pid) {
|
|
31669
31789
|
const lockFile = getLockFile();
|
|
31670
|
-
mkdirSync28(
|
|
31790
|
+
mkdirSync28(join86(lockFile, ".."), { recursive: true });
|
|
31671
31791
|
writeFileSync44(
|
|
31672
31792
|
lockFile,
|
|
31673
31793
|
JSON.stringify({
|
|
@@ -31683,7 +31803,7 @@ function setup() {
|
|
|
31683
31803
|
mkdirSync29(voicePaths.dir, { recursive: true });
|
|
31684
31804
|
bootstrapVenv();
|
|
31685
31805
|
console.log("\nDownloading models...\n");
|
|
31686
|
-
const script =
|
|
31806
|
+
const script = join87(getPythonDir(), "setup_models.py");
|
|
31687
31807
|
const result = spawnSync9(getVenvPython(), [script], {
|
|
31688
31808
|
stdio: "inherit",
|
|
31689
31809
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -31697,7 +31817,7 @@ function setup() {
|
|
|
31697
31817
|
// src/commands/voice/start.ts
|
|
31698
31818
|
import { spawn as spawn8 } from "child_process";
|
|
31699
31819
|
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync45 } from "fs";
|
|
31700
|
-
import { join as
|
|
31820
|
+
import { join as join88 } from "path";
|
|
31701
31821
|
|
|
31702
31822
|
// src/commands/voice/buildDaemonEnv.ts
|
|
31703
31823
|
function buildDaemonEnv(options2) {
|
|
@@ -31735,7 +31855,7 @@ function start2(options2) {
|
|
|
31735
31855
|
bootstrapVenv();
|
|
31736
31856
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
31737
31857
|
const env = buildDaemonEnv({ debug });
|
|
31738
|
-
const script =
|
|
31858
|
+
const script = join88(getPythonDir(), "voice_daemon.py");
|
|
31739
31859
|
const python = getVenvPython();
|
|
31740
31860
|
if (options2.foreground) {
|
|
31741
31861
|
spawnForeground(python, script, env);
|
|
@@ -31745,7 +31865,7 @@ function start2(options2) {
|
|
|
31745
31865
|
}
|
|
31746
31866
|
|
|
31747
31867
|
// src/commands/voice/status.ts
|
|
31748
|
-
import { existsSync as
|
|
31868
|
+
import { existsSync as existsSync73, readFileSync as readFileSync54 } from "fs";
|
|
31749
31869
|
function isProcessAlive3(pid) {
|
|
31750
31870
|
try {
|
|
31751
31871
|
process.kill(pid, 0);
|
|
@@ -31755,12 +31875,12 @@ function isProcessAlive3(pid) {
|
|
|
31755
31875
|
}
|
|
31756
31876
|
}
|
|
31757
31877
|
function readRecentLogs(count8) {
|
|
31758
|
-
if (!
|
|
31878
|
+
if (!existsSync73(voicePaths.log)) return [];
|
|
31759
31879
|
const lines2 = readFileSync54(voicePaths.log, "utf8").trim().split("\n");
|
|
31760
31880
|
return lines2.slice(-count8);
|
|
31761
31881
|
}
|
|
31762
31882
|
function status2() {
|
|
31763
|
-
if (!
|
|
31883
|
+
if (!existsSync73(voicePaths.pid)) {
|
|
31764
31884
|
console.log("Voice daemon: not running (no PID file)");
|
|
31765
31885
|
return;
|
|
31766
31886
|
}
|
|
@@ -31783,9 +31903,9 @@ function status2() {
|
|
|
31783
31903
|
}
|
|
31784
31904
|
|
|
31785
31905
|
// src/commands/voice/stop.ts
|
|
31786
|
-
import { existsSync as
|
|
31906
|
+
import { existsSync as existsSync74, readFileSync as readFileSync55, unlinkSync as unlinkSync20 } from "fs";
|
|
31787
31907
|
function stop2() {
|
|
31788
|
-
if (!
|
|
31908
|
+
if (!existsSync74(voicePaths.pid)) {
|
|
31789
31909
|
console.log("Voice daemon is not running (no PID file)");
|
|
31790
31910
|
return;
|
|
31791
31911
|
}
|
|
@@ -31802,7 +31922,7 @@ function stop2() {
|
|
|
31802
31922
|
}
|
|
31803
31923
|
try {
|
|
31804
31924
|
const lockFile = getLockFile();
|
|
31805
|
-
if (
|
|
31925
|
+
if (existsSync74(lockFile)) unlinkSync20(lockFile);
|
|
31806
31926
|
} catch {
|
|
31807
31927
|
}
|
|
31808
31928
|
console.log("Voice daemon stopped");
|
|
@@ -31866,11 +31986,11 @@ function changedPaths(from, cwd) {
|
|
|
31866
31986
|
}
|
|
31867
31987
|
|
|
31868
31988
|
// src/commands/watch/readBuiltVersion.ts
|
|
31869
|
-
import { join as
|
|
31989
|
+
import { join as join89 } from "path";
|
|
31870
31990
|
function readBuiltVersion(cwd) {
|
|
31871
31991
|
try {
|
|
31872
31992
|
const root = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
31873
|
-
return readPackageJson(
|
|
31993
|
+
return readPackageJson(join89(root, "package.json")).version ?? "unknown";
|
|
31874
31994
|
} catch {
|
|
31875
31995
|
return "unknown";
|
|
31876
31996
|
}
|
|
@@ -32207,7 +32327,7 @@ function resolveParams(params, cliArgs) {
|
|
|
32207
32327
|
}
|
|
32208
32328
|
|
|
32209
32329
|
// src/commands/run/resolveRunCwd.ts
|
|
32210
|
-
import { existsSync as
|
|
32330
|
+
import { existsSync as existsSync75 } from "fs";
|
|
32211
32331
|
import { resolve as resolve19 } from "path";
|
|
32212
32332
|
var MissingRunCwdError = class extends Error {
|
|
32213
32333
|
constructor(runName, cwd) {
|
|
@@ -32220,25 +32340,25 @@ var MissingRunCwdError = class extends Error {
|
|
|
32220
32340
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
32221
32341
|
if (!config.cwd) return void 0;
|
|
32222
32342
|
const cwd = resolve19(baseDir, config.cwd);
|
|
32223
|
-
if (!
|
|
32343
|
+
if (!existsSync75(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
32224
32344
|
return cwd;
|
|
32225
32345
|
}
|
|
32226
32346
|
|
|
32227
32347
|
// src/commands/run/runCommandToCompletion.ts
|
|
32228
32348
|
import { spawn as spawn9 } from "child_process";
|
|
32229
|
-
import { existsSync as
|
|
32349
|
+
import { existsSync as existsSync77 } from "fs";
|
|
32230
32350
|
|
|
32231
32351
|
// src/commands/run/resolveCommand.ts
|
|
32232
32352
|
import { execFileSync as execFileSync16 } from "child_process";
|
|
32233
|
-
import { existsSync as
|
|
32234
|
-
import { dirname as dirname37, join as
|
|
32353
|
+
import { existsSync as existsSync76 } from "fs";
|
|
32354
|
+
import { dirname as dirname37, join as join90, resolve as resolve20 } from "path";
|
|
32235
32355
|
function resolveCommand2(command) {
|
|
32236
32356
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
32237
32357
|
try {
|
|
32238
32358
|
const gitPath = execFileSync16("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
32239
32359
|
const gitRoot = resolve20(dirname37(gitPath), "..");
|
|
32240
|
-
const gitBash =
|
|
32241
|
-
if (
|
|
32360
|
+
const gitBash = join90(gitRoot, "bin", "bash.exe");
|
|
32361
|
+
if (existsSync76(gitBash)) return gitBash;
|
|
32242
32362
|
} catch {
|
|
32243
32363
|
return command;
|
|
32244
32364
|
}
|
|
@@ -32248,7 +32368,7 @@ function resolveCommand2(command) {
|
|
|
32248
32368
|
// src/commands/run/runCommandToCompletion.ts
|
|
32249
32369
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
32250
32370
|
return new Promise((resolveResult) => {
|
|
32251
|
-
if (cwd && !
|
|
32371
|
+
if (cwd && !existsSync77(cwd)) {
|
|
32252
32372
|
resolveResult({
|
|
32253
32373
|
kind: "failed",
|
|
32254
32374
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -32505,7 +32625,7 @@ function registerWatch(program2) {
|
|
|
32505
32625
|
|
|
32506
32626
|
// src/commands/roam/auth.ts
|
|
32507
32627
|
import { randomBytes } from "crypto";
|
|
32508
|
-
import
|
|
32628
|
+
import chalk224 from "chalk";
|
|
32509
32629
|
|
|
32510
32630
|
// src/commands/roam/waitForCallback.ts
|
|
32511
32631
|
import { createServer as createServer3 } from "http";
|
|
@@ -32636,13 +32756,13 @@ async function auth() {
|
|
|
32636
32756
|
saveGlobalConfig(config);
|
|
32637
32757
|
const state = randomBytes(16).toString("hex");
|
|
32638
32758
|
console.log(
|
|
32639
|
-
|
|
32759
|
+
chalk224.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
32640
32760
|
);
|
|
32641
|
-
console.log(
|
|
32642
|
-
console.log(
|
|
32643
|
-
console.log(
|
|
32761
|
+
console.log(chalk224.white("http://localhost:14523/callback\n"));
|
|
32762
|
+
console.log(chalk224.blue("Opening browser for authorization..."));
|
|
32763
|
+
console.log(chalk224.dim("Waiting for authorization callback..."));
|
|
32644
32764
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
32645
|
-
console.log(
|
|
32765
|
+
console.log(chalk224.dim("Exchanging code for tokens..."));
|
|
32646
32766
|
const tokens = await exchangeToken({
|
|
32647
32767
|
code,
|
|
32648
32768
|
clientId,
|
|
@@ -32658,14 +32778,14 @@ async function auth() {
|
|
|
32658
32778
|
};
|
|
32659
32779
|
saveGlobalConfig(config);
|
|
32660
32780
|
console.log(
|
|
32661
|
-
|
|
32781
|
+
chalk224.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
32662
32782
|
);
|
|
32663
32783
|
}
|
|
32664
32784
|
|
|
32665
32785
|
// src/commands/roam/postRoamActivity.ts
|
|
32666
32786
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
32667
32787
|
import { readdirSync as readdirSync20, readFileSync as readFileSync56, statSync as statSync12 } from "fs";
|
|
32668
|
-
import { join as
|
|
32788
|
+
import { join as join91 } from "path";
|
|
32669
32789
|
function findPortFile(roamDir) {
|
|
32670
32790
|
let entries;
|
|
32671
32791
|
try {
|
|
@@ -32674,7 +32794,7 @@ function findPortFile(roamDir) {
|
|
|
32674
32794
|
return void 0;
|
|
32675
32795
|
}
|
|
32676
32796
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
32677
|
-
const path84 =
|
|
32797
|
+
const path84 = join91(roamDir, name);
|
|
32678
32798
|
try {
|
|
32679
32799
|
return { path: path84, mtimeMs: statSync12(path84).mtimeMs };
|
|
32680
32800
|
} catch {
|
|
@@ -32686,7 +32806,7 @@ function findPortFile(roamDir) {
|
|
|
32686
32806
|
function postRoamActivity(app, event) {
|
|
32687
32807
|
const appData = process.env.APPDATA;
|
|
32688
32808
|
if (!appData) return;
|
|
32689
|
-
const portFile = findPortFile(
|
|
32809
|
+
const portFile = findPortFile(join91(appData, "Roam"));
|
|
32690
32810
|
if (!portFile) return;
|
|
32691
32811
|
let port;
|
|
32692
32812
|
try {
|
|
@@ -32819,7 +32939,7 @@ async function run3(name, args) {
|
|
|
32819
32939
|
|
|
32820
32940
|
// src/commands/run/add.ts
|
|
32821
32941
|
import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync46 } from "fs";
|
|
32822
|
-
import { join as
|
|
32942
|
+
import { join as join92 } from "path";
|
|
32823
32943
|
|
|
32824
32944
|
// src/commands/run/extractOption.ts
|
|
32825
32945
|
function extractOption(args, flag) {
|
|
@@ -32880,7 +33000,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
32880
33000
|
saveConfig(config);
|
|
32881
33001
|
}
|
|
32882
33002
|
function createCommandFile(name) {
|
|
32883
|
-
const dir =
|
|
33003
|
+
const dir = join92(".claude", "commands");
|
|
32884
33004
|
mkdirSync31(dir, { recursive: true });
|
|
32885
33005
|
const content = `---
|
|
32886
33006
|
description: Run ${name}
|
|
@@ -32888,7 +33008,7 @@ description: Run ${name}
|
|
|
32888
33008
|
|
|
32889
33009
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
32890
33010
|
`;
|
|
32891
|
-
const filePath =
|
|
33011
|
+
const filePath = join92(dir, `${name}.md`);
|
|
32892
33012
|
writeFileSync46(filePath, content);
|
|
32893
33013
|
console.log(`Created command file: ${filePath}`);
|
|
32894
33014
|
}
|
|
@@ -32944,8 +33064,8 @@ function link2() {
|
|
|
32944
33064
|
}
|
|
32945
33065
|
|
|
32946
33066
|
// src/commands/run/remove.ts
|
|
32947
|
-
import { existsSync as
|
|
32948
|
-
import { join as
|
|
33067
|
+
import { existsSync as existsSync78, unlinkSync as unlinkSync21 } from "fs";
|
|
33068
|
+
import { join as join93 } from "path";
|
|
32949
33069
|
function findRemoveIndex() {
|
|
32950
33070
|
const idx = process.argv.indexOf("remove");
|
|
32951
33071
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -32960,8 +33080,8 @@ function parseRemoveName() {
|
|
|
32960
33080
|
return process.argv[idx + 1];
|
|
32961
33081
|
}
|
|
32962
33082
|
function deleteCommandFile(name) {
|
|
32963
|
-
const filePath =
|
|
32964
|
-
if (
|
|
33083
|
+
const filePath = join93(".claude", "commands", `${name}.md`);
|
|
33084
|
+
if (existsSync78(filePath)) {
|
|
32965
33085
|
unlinkSync21(filePath);
|
|
32966
33086
|
console.log(`Deleted command file: ${filePath}`);
|
|
32967
33087
|
}
|
|
@@ -33006,10 +33126,10 @@ function registerRun(program2) {
|
|
|
33006
33126
|
|
|
33007
33127
|
// src/commands/screenshot/index.ts
|
|
33008
33128
|
import { execSync as execSync60 } from "child_process";
|
|
33009
|
-
import { existsSync as
|
|
33010
|
-
import { tmpdir as
|
|
33011
|
-
import { join as
|
|
33012
|
-
import
|
|
33129
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync32, unlinkSync as unlinkSync22, writeFileSync as writeFileSync47 } from "fs";
|
|
33130
|
+
import { tmpdir as tmpdir9 } from "os";
|
|
33131
|
+
import { join as join94, resolve as resolve21 } from "path";
|
|
33132
|
+
import chalk225 from "chalk";
|
|
33013
33133
|
|
|
33014
33134
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
33015
33135
|
var captureWindowPs1 = `
|
|
@@ -33138,14 +33258,14 @@ Write-Output $OutputPath
|
|
|
33138
33258
|
|
|
33139
33259
|
// src/commands/screenshot/index.ts
|
|
33140
33260
|
function buildOutputPath(outputDir, processName) {
|
|
33141
|
-
if (!
|
|
33261
|
+
if (!existsSync79(outputDir)) {
|
|
33142
33262
|
mkdirSync32(outputDir, { recursive: true });
|
|
33143
33263
|
}
|
|
33144
33264
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
33145
33265
|
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
33146
33266
|
}
|
|
33147
33267
|
function runPowerShellScript(processName, outputPath) {
|
|
33148
|
-
const scriptPath =
|
|
33268
|
+
const scriptPath = join94(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
33149
33269
|
writeFileSync47(scriptPath, captureWindowPs1, "utf8");
|
|
33150
33270
|
try {
|
|
33151
33271
|
execSync60(
|
|
@@ -33160,13 +33280,13 @@ function screenshot(processName) {
|
|
|
33160
33280
|
const config = loadConfig();
|
|
33161
33281
|
const outputDir = resolve21(config.screenshot.outputDir);
|
|
33162
33282
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
33163
|
-
console.log(
|
|
33283
|
+
console.log(chalk225.gray(`Capturing window for process "${processName}" ...`));
|
|
33164
33284
|
try {
|
|
33165
33285
|
runPowerShellScript(processName, outputPath);
|
|
33166
|
-
console.log(
|
|
33286
|
+
console.log(chalk225.green(`Screenshot saved: ${outputPath}`));
|
|
33167
33287
|
} catch (error) {
|
|
33168
33288
|
const msg = error instanceof Error ? error.message : String(error);
|
|
33169
|
-
console.error(
|
|
33289
|
+
console.error(chalk225.red(`Failed to capture screenshot: ${msg}`));
|
|
33170
33290
|
process.exit(1);
|
|
33171
33291
|
}
|
|
33172
33292
|
}
|
|
@@ -33483,12 +33603,12 @@ function toSessionRunInfo({
|
|
|
33483
33603
|
}
|
|
33484
33604
|
|
|
33485
33605
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
33486
|
-
import { existsSync as
|
|
33606
|
+
import { existsSync as existsSync80 } from "fs";
|
|
33487
33607
|
function joinRefusal(session) {
|
|
33488
33608
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
33489
33609
|
if (session.closing === true) return "the session is closing";
|
|
33490
33610
|
if (!session.cwd) return "the session has no working directory";
|
|
33491
|
-
if (!
|
|
33611
|
+
if (!existsSync80(session.cwd))
|
|
33492
33612
|
return "the session's workspace no longer exists";
|
|
33493
33613
|
return void 0;
|
|
33494
33614
|
}
|
|
@@ -33652,11 +33772,11 @@ function sessionBase(id, status3) {
|
|
|
33652
33772
|
}
|
|
33653
33773
|
|
|
33654
33774
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
33655
|
-
import { existsSync as
|
|
33775
|
+
import { existsSync as existsSync82 } from "fs";
|
|
33656
33776
|
import * as pty from "node-pty";
|
|
33657
33777
|
|
|
33658
33778
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
33659
|
-
import { chmodSync, existsSync as
|
|
33779
|
+
import { chmodSync, existsSync as existsSync81, statSync as statSync13 } from "fs";
|
|
33660
33780
|
import { createRequire as createRequire3 } from "module";
|
|
33661
33781
|
import path79 from "path";
|
|
33662
33782
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -33671,7 +33791,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
33671
33791
|
`${process.platform}-${process.arch}`,
|
|
33672
33792
|
"spawn-helper"
|
|
33673
33793
|
);
|
|
33674
|
-
if (!
|
|
33794
|
+
if (!existsSync81(helper)) return;
|
|
33675
33795
|
const mode = statSync13(helper).mode;
|
|
33676
33796
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
33677
33797
|
}
|
|
@@ -33707,7 +33827,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
33707
33827
|
});
|
|
33708
33828
|
}
|
|
33709
33829
|
function refuseMissingCwd(cwd, sessionId) {
|
|
33710
|
-
if (!cwd ||
|
|
33830
|
+
if (!cwd || existsSync82(cwd)) return;
|
|
33711
33831
|
daemonLog(
|
|
33712
33832
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
33713
33833
|
);
|
|
@@ -33889,17 +34009,17 @@ function setStatus2(session, newStatus) {
|
|
|
33889
34009
|
}
|
|
33890
34010
|
|
|
33891
34011
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
33892
|
-
import { existsSync as
|
|
34012
|
+
import { existsSync as existsSync84 } from "fs";
|
|
33893
34013
|
import { basename as basename22 } from "path";
|
|
33894
34014
|
|
|
33895
34015
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
33896
|
-
import { existsSync as
|
|
33897
|
-
import { join as
|
|
34016
|
+
import { existsSync as existsSync83 } from "fs";
|
|
34017
|
+
import { join as join97 } from "path";
|
|
33898
34018
|
|
|
33899
34019
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
33900
34020
|
import { statSync as statSync14 } from "fs";
|
|
33901
|
-
import { rm as
|
|
33902
|
-
import { join as
|
|
34021
|
+
import { rm as rm4 } from "fs/promises";
|
|
34022
|
+
import { join as join96 } from "path";
|
|
33903
34023
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
33904
34024
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
33905
34025
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -33910,7 +34030,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
33910
34030
|
}
|
|
33911
34031
|
daemonLog(`worktree ${worktreePath} deleting its directory directly: ${why}`);
|
|
33912
34032
|
try {
|
|
33913
|
-
await
|
|
34033
|
+
await rm4(worktreePath, {
|
|
33914
34034
|
recursive: true,
|
|
33915
34035
|
force: true,
|
|
33916
34036
|
maxRetries: 3,
|
|
@@ -33927,7 +34047,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
33927
34047
|
return { removed: true };
|
|
33928
34048
|
}
|
|
33929
34049
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
33930
|
-
return statSync14(
|
|
34050
|
+
return statSync14(join96(worktreePath, ".git"), {
|
|
33931
34051
|
throwIfNoEntry: false
|
|
33932
34052
|
})?.isDirectory() === true;
|
|
33933
34053
|
}
|
|
@@ -33963,7 +34083,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
33963
34083
|
);
|
|
33964
34084
|
}
|
|
33965
34085
|
function strandedReason(worktreePath, cause) {
|
|
33966
|
-
if (!
|
|
34086
|
+
if (!existsSync83(join97(worktreePath, ".git")))
|
|
33967
34087
|
return "its .git link is already gone";
|
|
33968
34088
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
33969
34089
|
return "git no longer recognises it as a working tree";
|
|
@@ -34015,7 +34135,7 @@ function reason3(error) {
|
|
|
34015
34135
|
|
|
34016
34136
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
34017
34137
|
async function reapWorktree(worktreePath, force = false) {
|
|
34018
|
-
if (!
|
|
34138
|
+
if (!existsSync84(worktreePath)) {
|
|
34019
34139
|
forgetWorktree(worktreePath);
|
|
34020
34140
|
daemonLog(
|
|
34021
34141
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -34040,7 +34160,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
34040
34160
|
}
|
|
34041
34161
|
function owningClone(worktreePath) {
|
|
34042
34162
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
34043
|
-
if (recorded &&
|
|
34163
|
+
if (recorded && existsSync84(recorded)) return recorded;
|
|
34044
34164
|
const detected = mainWorktree(worktreePath);
|
|
34045
34165
|
if (detected) return detected;
|
|
34046
34166
|
daemonLog(
|
|
@@ -34171,12 +34291,12 @@ function closeGateApplies(sessions, session) {
|
|
|
34171
34291
|
}
|
|
34172
34292
|
|
|
34173
34293
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
34174
|
-
import { existsSync as
|
|
34294
|
+
import { existsSync as existsSync85, watch } from "fs";
|
|
34175
34295
|
var DEBOUNCE_MS = 500;
|
|
34176
34296
|
var POLL_MS = 3e4;
|
|
34177
34297
|
function watchGitState(cwd, onChange) {
|
|
34178
34298
|
const common = gitCommonDir(cwd);
|
|
34179
|
-
if (!common || !
|
|
34299
|
+
if (!common || !existsSync85(common)) return void 0;
|
|
34180
34300
|
const watchers = [
|
|
34181
34301
|
watchGitDir(common, onChange),
|
|
34182
34302
|
pollGitState(cwd, onChange)
|
|
@@ -34653,10 +34773,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
34653
34773
|
}
|
|
34654
34774
|
|
|
34655
34775
|
// src/commands/sessions/daemon/exitReason.ts
|
|
34656
|
-
import { existsSync as
|
|
34776
|
+
import { existsSync as existsSync86 } from "fs";
|
|
34657
34777
|
import { resolve as resolve22 } from "path";
|
|
34658
34778
|
function exitDetail(session) {
|
|
34659
|
-
if (session.cwd && !
|
|
34779
|
+
if (session.cwd && !existsSync86(session.cwd))
|
|
34660
34780
|
return `working directory ${session.cwd} no longer exists`;
|
|
34661
34781
|
return missingRunConfigCwd(session);
|
|
34662
34782
|
}
|
|
@@ -34670,7 +34790,7 @@ function missingRunConfigCwd(session) {
|
|
|
34670
34790
|
const config = resolveRunConfig(session.runName, dir);
|
|
34671
34791
|
if (!config?.cwd) return void 0;
|
|
34672
34792
|
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
34673
|
-
if (
|
|
34793
|
+
if (existsSync86(configured)) return void 0;
|
|
34674
34794
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
34675
34795
|
}
|
|
34676
34796
|
|
|
@@ -34711,7 +34831,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
34711
34831
|
}
|
|
34712
34832
|
|
|
34713
34833
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
34714
|
-
import { existsSync as
|
|
34834
|
+
import { existsSync as existsSync87, mkdirSync as mkdirSync33, watch as watch2 } from "fs";
|
|
34715
34835
|
import { dirname as dirname39 } from "path";
|
|
34716
34836
|
|
|
34717
34837
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -34797,7 +34917,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
34797
34917
|
if (timer) clearTimeout(timer);
|
|
34798
34918
|
timer = setTimeout(read2, DEBOUNCE_MS2);
|
|
34799
34919
|
});
|
|
34800
|
-
if (
|
|
34920
|
+
if (existsSync87(path84)) read2();
|
|
34801
34921
|
}
|
|
34802
34922
|
function refreshActivity(session) {
|
|
34803
34923
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -36122,10 +36242,10 @@ function deferralNotice(persisted, cap2) {
|
|
|
36122
36242
|
|
|
36123
36243
|
// src/commands/sessions/daemon/worktree/underTempRoot.ts
|
|
36124
36244
|
import { realpathSync as realpathSync3 } from "fs";
|
|
36125
|
-
import { tmpdir as
|
|
36245
|
+
import { tmpdir as tmpdir10 } from "os";
|
|
36126
36246
|
import { sep as sep2 } from "path";
|
|
36127
36247
|
function tempRoots() {
|
|
36128
|
-
const raw =
|
|
36248
|
+
const raw = tmpdir10();
|
|
36129
36249
|
const roots = /* @__PURE__ */ new Set([raw]);
|
|
36130
36250
|
try {
|
|
36131
36251
|
roots.add(realpathSync3(raw));
|
|
@@ -36448,7 +36568,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
36448
36568
|
}
|
|
36449
36569
|
|
|
36450
36570
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
36451
|
-
import { existsSync as
|
|
36571
|
+
import { existsSync as existsSync90 } from "fs";
|
|
36452
36572
|
import { basename as basename24 } from "path";
|
|
36453
36573
|
|
|
36454
36574
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -36503,9 +36623,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
36503
36623
|
}
|
|
36504
36624
|
|
|
36505
36625
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
36506
|
-
import { existsSync as
|
|
36626
|
+
import { existsSync as existsSync89 } from "fs";
|
|
36507
36627
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
36508
|
-
if (!
|
|
36628
|
+
if (!existsSync89(clone)) {
|
|
36509
36629
|
for (const { path: path84 } of paths) forgetWorktree(path84);
|
|
36510
36630
|
daemonLog(
|
|
36511
36631
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -36671,7 +36791,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
36671
36791
|
);
|
|
36672
36792
|
continue;
|
|
36673
36793
|
}
|
|
36674
|
-
if (!
|
|
36794
|
+
if (!existsSync90(path84)) {
|
|
36675
36795
|
logVanishedTree(sessions, path84);
|
|
36676
36796
|
vanished.set(clone, [
|
|
36677
36797
|
...vanished.get(clone) ?? [],
|
|
@@ -37288,13 +37408,13 @@ async function defaultConnect() {
|
|
|
37288
37408
|
}
|
|
37289
37409
|
|
|
37290
37410
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
37291
|
-
import { existsSync as
|
|
37411
|
+
import { existsSync as existsSync91, readFileSync as readFileSync59 } from "fs";
|
|
37292
37412
|
import { posix as posix3 } from "path";
|
|
37293
37413
|
function hasPersistedWindowsSessions() {
|
|
37294
37414
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
37295
37415
|
if (!sessionsFile) return false;
|
|
37296
37416
|
try {
|
|
37297
|
-
if (!
|
|
37417
|
+
if (!existsSync91(sessionsFile)) return false;
|
|
37298
37418
|
const data = JSON.parse(readFileSync59(sessionsFile, "utf8"));
|
|
37299
37419
|
return Array.isArray(data) && data.length > 0;
|
|
37300
37420
|
} catch (error) {
|
|
@@ -38029,7 +38149,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
38029
38149
|
}
|
|
38030
38150
|
|
|
38031
38151
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
38032
|
-
import { existsSync as
|
|
38152
|
+
import { existsSync as existsSync94 } from "fs";
|
|
38033
38153
|
|
|
38034
38154
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
38035
38155
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -38060,11 +38180,11 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
38060
38180
|
}
|
|
38061
38181
|
|
|
38062
38182
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
38063
|
-
import { existsSync as
|
|
38183
|
+
import { existsSync as existsSync93 } from "fs";
|
|
38064
38184
|
|
|
38065
38185
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
38066
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
38067
|
-
import { join as
|
|
38186
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync92, mkdirSync as mkdirSync35 } from "fs";
|
|
38187
|
+
import { join as join99 } from "path";
|
|
38068
38188
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
38069
38189
|
const dir = projectDirForCwd(toCwd);
|
|
38070
38190
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -38073,8 +38193,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
38073
38193
|
);
|
|
38074
38194
|
return;
|
|
38075
38195
|
}
|
|
38076
|
-
const dest =
|
|
38077
|
-
if (
|
|
38196
|
+
const dest = join99(dir, `${claudeSessionId}.jsonl`);
|
|
38197
|
+
if (existsSync92(dest)) {
|
|
38078
38198
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
38079
38199
|
return;
|
|
38080
38200
|
}
|
|
@@ -38125,7 +38245,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
38125
38245
|
}
|
|
38126
38246
|
function cloneForReapedTree(missingCwd) {
|
|
38127
38247
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
38128
|
-
if (!clone || !
|
|
38248
|
+
if (!clone || !existsSync93(clone))
|
|
38129
38249
|
throw new Error(
|
|
38130
38250
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
38131
38251
|
);
|
|
@@ -38134,7 +38254,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
38134
38254
|
|
|
38135
38255
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
38136
38256
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
38137
|
-
if (!
|
|
38257
|
+
if (!existsSync94(cwd))
|
|
38138
38258
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
38139
38259
|
const id = ctx.spawnWith(
|
|
38140
38260
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -38975,7 +39095,7 @@ function registerSetStatusCommand(cmd) {
|
|
|
38975
39095
|
|
|
38976
39096
|
// src/commands/sessions/summarise/index.ts
|
|
38977
39097
|
import * as fs56 from "fs";
|
|
38978
|
-
import
|
|
39098
|
+
import chalk226 from "chalk";
|
|
38979
39099
|
|
|
38980
39100
|
// src/commands/sessions/summarise/shared.ts
|
|
38981
39101
|
import * as fs55 from "fs";
|
|
@@ -39034,22 +39154,22 @@ ${firstMessage}`);
|
|
|
39034
39154
|
async function summarise2(options2) {
|
|
39035
39155
|
const files = await discoverSessionFiles();
|
|
39036
39156
|
if (files.length === 0) {
|
|
39037
|
-
console.log(
|
|
39157
|
+
console.log(chalk226.yellow("No sessions found."));
|
|
39038
39158
|
return;
|
|
39039
39159
|
}
|
|
39040
39160
|
const toProcess = selectCandidates(files, options2);
|
|
39041
39161
|
if (toProcess.length === 0) {
|
|
39042
|
-
console.log(
|
|
39162
|
+
console.log(chalk226.green("All sessions already summarised."));
|
|
39043
39163
|
return;
|
|
39044
39164
|
}
|
|
39045
39165
|
console.log(
|
|
39046
|
-
|
|
39166
|
+
chalk226.cyan(
|
|
39047
39167
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
39048
39168
|
)
|
|
39049
39169
|
);
|
|
39050
39170
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
39051
39171
|
console.log(
|
|
39052
|
-
|
|
39172
|
+
chalk226.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk226.yellow(`, ${failed2} skipped`) : "")
|
|
39053
39173
|
);
|
|
39054
39174
|
}
|
|
39055
39175
|
function selectCandidates(files, options2) {
|
|
@@ -39069,16 +39189,16 @@ function processSessions(files) {
|
|
|
39069
39189
|
let failed2 = 0;
|
|
39070
39190
|
for (let i = 0; i < files.length; i++) {
|
|
39071
39191
|
const file = files[i];
|
|
39072
|
-
process.stdout.write(
|
|
39192
|
+
process.stdout.write(chalk226.dim(` [${i + 1}/${files.length}] `));
|
|
39073
39193
|
const summary = summariseSession(file);
|
|
39074
39194
|
if (summary) {
|
|
39075
39195
|
writeSummary(file, summary);
|
|
39076
39196
|
succeeded++;
|
|
39077
|
-
process.stdout.write(`${
|
|
39197
|
+
process.stdout.write(`${chalk226.green("\u2713")} ${summary}
|
|
39078
39198
|
`);
|
|
39079
39199
|
} else {
|
|
39080
39200
|
failed2++;
|
|
39081
|
-
process.stdout.write(` ${
|
|
39201
|
+
process.stdout.write(` ${chalk226.yellow("skip")}
|
|
39082
39202
|
`);
|
|
39083
39203
|
}
|
|
39084
39204
|
}
|
|
@@ -39099,7 +39219,7 @@ function registerSessions(program2) {
|
|
|
39099
39219
|
}
|
|
39100
39220
|
|
|
39101
39221
|
// src/commands/statusLine.ts
|
|
39102
|
-
import
|
|
39222
|
+
import chalk228 from "chalk";
|
|
39103
39223
|
|
|
39104
39224
|
// src/shared/contextLevel.ts
|
|
39105
39225
|
function contextLevel(pct) {
|
|
@@ -39109,7 +39229,7 @@ function contextLevel(pct) {
|
|
|
39109
39229
|
}
|
|
39110
39230
|
|
|
39111
39231
|
// src/commands/buildLimitsSegment.ts
|
|
39112
|
-
import
|
|
39232
|
+
import chalk227 from "chalk";
|
|
39113
39233
|
|
|
39114
39234
|
// src/shared/rateLimitLevel.ts
|
|
39115
39235
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -39147,9 +39267,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
39147
39267
|
|
|
39148
39268
|
// src/commands/buildLimitsSegment.ts
|
|
39149
39269
|
var LEVEL_COLOR = {
|
|
39150
|
-
ok:
|
|
39151
|
-
warn:
|
|
39152
|
-
over:
|
|
39270
|
+
ok: chalk227.green,
|
|
39271
|
+
warn: chalk227.yellow,
|
|
39272
|
+
over: chalk227.red
|
|
39153
39273
|
};
|
|
39154
39274
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
39155
39275
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -39181,9 +39301,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
39181
39301
|
|
|
39182
39302
|
// src/commands/readGitBranch.ts
|
|
39183
39303
|
import { readFileSync as readFileSync62, statSync as statSync16 } from "fs";
|
|
39184
|
-
import { isAbsolute as isAbsolute5, join as
|
|
39304
|
+
import { isAbsolute as isAbsolute5, join as join100, resolve as resolve23 } from "path";
|
|
39185
39305
|
function resolveGitDir(cwd) {
|
|
39186
|
-
const dotGit =
|
|
39306
|
+
const dotGit = join100(cwd, ".git");
|
|
39187
39307
|
let stat4;
|
|
39188
39308
|
try {
|
|
39189
39309
|
stat4 = statSync16(dotGit);
|
|
@@ -39213,7 +39333,7 @@ function readGitBranch(cwd) {
|
|
|
39213
39333
|
}
|
|
39214
39334
|
let head;
|
|
39215
39335
|
try {
|
|
39216
|
-
head = readFileSync62(
|
|
39336
|
+
head = readFileSync62(join100(gitDir, "HEAD"), "utf8");
|
|
39217
39337
|
} catch {
|
|
39218
39338
|
return null;
|
|
39219
39339
|
}
|
|
@@ -39245,7 +39365,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
39245
39365
|
}
|
|
39246
39366
|
|
|
39247
39367
|
// src/commands/statusLine.ts
|
|
39248
|
-
|
|
39368
|
+
chalk228.level = 3;
|
|
39249
39369
|
function formatNumber(num) {
|
|
39250
39370
|
return num.toLocaleString("en-US");
|
|
39251
39371
|
}
|
|
@@ -39253,9 +39373,9 @@ function colorizePercent(pct) {
|
|
|
39253
39373
|
const label2 = `${Math.round(pct)}%`;
|
|
39254
39374
|
switch (contextLevel(pct)) {
|
|
39255
39375
|
case "red":
|
|
39256
|
-
return
|
|
39376
|
+
return chalk228.red(label2);
|
|
39257
39377
|
case "yellow":
|
|
39258
|
-
return
|
|
39378
|
+
return chalk228.yellow(label2);
|
|
39259
39379
|
default:
|
|
39260
39380
|
return label2;
|
|
39261
39381
|
}
|
|
@@ -39268,7 +39388,7 @@ async function statusLine() {
|
|
|
39268
39388
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
39269
39389
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
39270
39390
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
39271
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
39391
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk228.cyan(branch2)} | ` : "";
|
|
39272
39392
|
console.log(
|
|
39273
39393
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
39274
39394
|
);
|
|
@@ -39338,10 +39458,10 @@ async function update2() {
|
|
|
39338
39458
|
}
|
|
39339
39459
|
|
|
39340
39460
|
// src/reportCliError.ts
|
|
39341
|
-
import
|
|
39461
|
+
import chalk229 from "chalk";
|
|
39342
39462
|
function reportCliError(error) {
|
|
39343
39463
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
39344
|
-
console.error(
|
|
39464
|
+
console.error(chalk229.red(error.message));
|
|
39345
39465
|
} else {
|
|
39346
39466
|
console.error(error);
|
|
39347
39467
|
}
|