@staff0rd/assist 0.406.0 → 0.407.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +695 -554
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.407.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -13760,9 +13760,114 @@ function registerDb(program2) {
|
|
|
13760
13760
|
).action(status);
|
|
13761
13761
|
}
|
|
13762
13762
|
|
|
13763
|
-
// src/commands/
|
|
13764
|
-
import {
|
|
13763
|
+
// src/commands/dbMigration/dbMigrationConfirm.ts
|
|
13764
|
+
import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs";
|
|
13765
13765
|
import chalk124 from "chalk";
|
|
13766
|
+
|
|
13767
|
+
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
13768
|
+
import { join as join33 } from "path";
|
|
13769
|
+
function getMigrationPinPath(pin) {
|
|
13770
|
+
return join33(getRestrictedDir(), `db-migration-pin-${pin}.json`);
|
|
13771
|
+
}
|
|
13772
|
+
function getMigrationApprovalPath(migrationId) {
|
|
13773
|
+
return join33(getRestrictedDir(), `db-migration-approval-${migrationId}.json`);
|
|
13774
|
+
}
|
|
13775
|
+
|
|
13776
|
+
// src/commands/dbMigration/readMigrationPinState.ts
|
|
13777
|
+
import { existsSync as existsSync32, readFileSync as readFileSync28 } from "fs";
|
|
13778
|
+
function readMigrationPinState(pin) {
|
|
13779
|
+
const path67 = getMigrationPinPath(pin);
|
|
13780
|
+
if (!existsSync32(path67)) return void 0;
|
|
13781
|
+
try {
|
|
13782
|
+
const state = JSON.parse(readFileSync28(path67, "utf8"));
|
|
13783
|
+
if (state.pin !== pin) return void 0;
|
|
13784
|
+
if (!Number.isInteger(state.migrationId)) return void 0;
|
|
13785
|
+
return state;
|
|
13786
|
+
} catch {
|
|
13787
|
+
return void 0;
|
|
13788
|
+
}
|
|
13789
|
+
}
|
|
13790
|
+
|
|
13791
|
+
// src/commands/dbMigration/dbMigrationConfirm.ts
|
|
13792
|
+
function dbMigrationConfirm(pin) {
|
|
13793
|
+
sweepRestrictedDir();
|
|
13794
|
+
const state = readMigrationPinState(pin);
|
|
13795
|
+
if (!state) {
|
|
13796
|
+
console.error(chalk124.red(`No pending migration unlock for pin: ${pin}`));
|
|
13797
|
+
process.exitCode = 1;
|
|
13798
|
+
return;
|
|
13799
|
+
}
|
|
13800
|
+
writeFileSync26(
|
|
13801
|
+
getMigrationApprovalPath(state.migrationId),
|
|
13802
|
+
JSON.stringify({ migrationId: state.migrationId })
|
|
13803
|
+
);
|
|
13804
|
+
unlinkSync9(getMigrationPinPath(pin));
|
|
13805
|
+
console.log(
|
|
13806
|
+
chalk124.green(
|
|
13807
|
+
`Approved creation of migration ${state.migrationId}. The next write of that migration module will be allowed once.`
|
|
13808
|
+
)
|
|
13809
|
+
);
|
|
13810
|
+
}
|
|
13811
|
+
|
|
13812
|
+
// src/commands/dbMigration/dbMigrationUnlock.ts
|
|
13813
|
+
import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync27 } from "fs";
|
|
13814
|
+
import { randomInt as randomInt2 } from "crypto";
|
|
13815
|
+
import chalk125 from "chalk";
|
|
13816
|
+
|
|
13817
|
+
// src/commands/dbMigration/nextMigrationId.ts
|
|
13818
|
+
function nextMigrationId() {
|
|
13819
|
+
return latestMigrationId + 1;
|
|
13820
|
+
}
|
|
13821
|
+
|
|
13822
|
+
// src/commands/dbMigration/dbMigrationUnlock.ts
|
|
13823
|
+
function dbMigrationUnlock() {
|
|
13824
|
+
const migrationId = nextMigrationId();
|
|
13825
|
+
const pin = randomInt2(0, 1e3).toString().padStart(3, "0");
|
|
13826
|
+
mkdirSync15(getRestrictedDir(), { recursive: true });
|
|
13827
|
+
sweepRestrictedDir();
|
|
13828
|
+
writeFileSync27(getMigrationPinPath(pin), JSON.stringify({ pin, migrationId }));
|
|
13829
|
+
console.error(
|
|
13830
|
+
chalk125.yellow.bold(
|
|
13831
|
+
"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."
|
|
13832
|
+
)
|
|
13833
|
+
);
|
|
13834
|
+
const delivered = showNotification({
|
|
13835
|
+
title: "assist db-migration pin",
|
|
13836
|
+
message: `Pin ${pin} \u2014 run: assist db-migration confirm ${pin}`
|
|
13837
|
+
});
|
|
13838
|
+
if (!delivered) {
|
|
13839
|
+
console.error(
|
|
13840
|
+
chalk125.red(
|
|
13841
|
+
"Could not deliver the confirmation pin via notification.\nThe migration cannot be approved until the notification channel works."
|
|
13842
|
+
)
|
|
13843
|
+
);
|
|
13844
|
+
process.exitCode = 1;
|
|
13845
|
+
return;
|
|
13846
|
+
}
|
|
13847
|
+
console.log(
|
|
13848
|
+
`A confirmation pin was sent to your desktop notifications.
|
|
13849
|
+
To approve creating migration ${migrationId}, run:
|
|
13850
|
+
${chalk125.cyan(" assist db-migration confirm <PIN>")}
|
|
13851
|
+
using the pin from that notification.`
|
|
13852
|
+
);
|
|
13853
|
+
}
|
|
13854
|
+
|
|
13855
|
+
// src/commands/registerDbMigration.ts
|
|
13856
|
+
function registerDbMigration(parent) {
|
|
13857
|
+
const dbMigration = parent.command("db-migration").description(
|
|
13858
|
+
"Human-in-the-loop approval gate for creating a new database migration"
|
|
13859
|
+
);
|
|
13860
|
+
dbMigration.command("unlock").description(
|
|
13861
|
+
"Page a human by issuing a pin authorising the next new migration module"
|
|
13862
|
+
).action(dbMigrationUnlock);
|
|
13863
|
+
dbMigration.command("confirm").description(
|
|
13864
|
+
"Confirm a pin from 'db-migration unlock' to record a one-shot approval scoped to that migration id"
|
|
13865
|
+
).argument("<pin>", "Pin issued by 'db-migration unlock'").action(dbMigrationConfirm);
|
|
13866
|
+
}
|
|
13867
|
+
|
|
13868
|
+
// src/commands/deploy/redirect.ts
|
|
13869
|
+
import { existsSync as existsSync33, readFileSync as readFileSync29, writeFileSync as writeFileSync28 } from "fs";
|
|
13870
|
+
import chalk126 from "chalk";
|
|
13766
13871
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
13767
13872
|
if (!window.location.pathname.endsWith('/')) {
|
|
13768
13873
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -13770,24 +13875,24 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
13770
13875
|
</script>`;
|
|
13771
13876
|
function redirect() {
|
|
13772
13877
|
const indexPath = "index.html";
|
|
13773
|
-
if (!
|
|
13774
|
-
console.log(
|
|
13878
|
+
if (!existsSync33(indexPath)) {
|
|
13879
|
+
console.log(chalk126.yellow("No index.html found"));
|
|
13775
13880
|
return;
|
|
13776
13881
|
}
|
|
13777
|
-
const content =
|
|
13882
|
+
const content = readFileSync29(indexPath, "utf8");
|
|
13778
13883
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
13779
|
-
console.log(
|
|
13884
|
+
console.log(chalk126.dim("Trailing slash script already present"));
|
|
13780
13885
|
return;
|
|
13781
13886
|
}
|
|
13782
13887
|
const headCloseIndex = content.indexOf("</head>");
|
|
13783
13888
|
if (headCloseIndex === -1) {
|
|
13784
|
-
console.log(
|
|
13889
|
+
console.log(chalk126.red("Could not find </head> tag in index.html"));
|
|
13785
13890
|
return;
|
|
13786
13891
|
}
|
|
13787
13892
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
13788
13893
|
${content.slice(headCloseIndex)}`;
|
|
13789
|
-
|
|
13790
|
-
console.log(
|
|
13894
|
+
writeFileSync28(indexPath, newContent);
|
|
13895
|
+
console.log(chalk126.green("Added trailing slash redirect to index.html"));
|
|
13791
13896
|
}
|
|
13792
13897
|
|
|
13793
13898
|
// src/commands/registerDeploy.ts
|
|
@@ -13803,10 +13908,10 @@ import { basename as basename9 } from "path";
|
|
|
13803
13908
|
|
|
13804
13909
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
13805
13910
|
import { homedir as homedir18 } from "os";
|
|
13806
|
-
import { join as
|
|
13807
|
-
var BLOG_REPO_ROOT =
|
|
13911
|
+
import { join as join34 } from "path";
|
|
13912
|
+
var BLOG_REPO_ROOT = join34(homedir18(), "git/blog");
|
|
13808
13913
|
function loadBlogSkipDays(repoName) {
|
|
13809
|
-
const config = loadRawYaml(
|
|
13914
|
+
const config = loadRawYaml(join34(BLOG_REPO_ROOT, "assist.yml"));
|
|
13810
13915
|
const devlog = config.devlog;
|
|
13811
13916
|
const skip2 = devlog?.skip;
|
|
13812
13917
|
return new Set(skip2?.[repoName]);
|
|
@@ -13814,20 +13919,20 @@ function loadBlogSkipDays(repoName) {
|
|
|
13814
13919
|
|
|
13815
13920
|
// src/commands/devlog/shared.ts
|
|
13816
13921
|
import { execSync as execSync32 } from "child_process";
|
|
13817
|
-
import
|
|
13922
|
+
import chalk127 from "chalk";
|
|
13818
13923
|
|
|
13819
13924
|
// src/shared/getRepoName.ts
|
|
13820
|
-
import { existsSync as
|
|
13821
|
-
import { basename as basename8, join as
|
|
13925
|
+
import { existsSync as existsSync34, readFileSync as readFileSync30 } from "fs";
|
|
13926
|
+
import { basename as basename8, join as join35 } from "path";
|
|
13822
13927
|
function getRepoName() {
|
|
13823
13928
|
const config = loadConfig();
|
|
13824
13929
|
if (config.devlog?.name) {
|
|
13825
13930
|
return config.devlog.name;
|
|
13826
13931
|
}
|
|
13827
|
-
const packageJsonPath =
|
|
13828
|
-
if (
|
|
13932
|
+
const packageJsonPath = join35(process.cwd(), "package.json");
|
|
13933
|
+
if (existsSync34(packageJsonPath)) {
|
|
13829
13934
|
try {
|
|
13830
|
-
const content =
|
|
13935
|
+
const content = readFileSync30(packageJsonPath, "utf8");
|
|
13831
13936
|
const pkg = JSON.parse(content);
|
|
13832
13937
|
if (pkg.name) {
|
|
13833
13938
|
return pkg.name;
|
|
@@ -13839,9 +13944,9 @@ function getRepoName() {
|
|
|
13839
13944
|
}
|
|
13840
13945
|
|
|
13841
13946
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
13842
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
13843
|
-
import { join as
|
|
13844
|
-
var DEVLOG_DIR =
|
|
13947
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync31 } from "fs";
|
|
13948
|
+
import { join as join36 } from "path";
|
|
13949
|
+
var DEVLOG_DIR = join36(BLOG_REPO_ROOT, "src/content/devlog");
|
|
13845
13950
|
function extractFrontmatter(content) {
|
|
13846
13951
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
13847
13952
|
return fm?.[1] ?? null;
|
|
@@ -13869,7 +13974,7 @@ function readDevlogFiles(callback) {
|
|
|
13869
13974
|
try {
|
|
13870
13975
|
const files = readdirSync4(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
13871
13976
|
for (const file of files) {
|
|
13872
|
-
const content =
|
|
13977
|
+
const content = readFileSync31(join36(DEVLOG_DIR, file), "utf8");
|
|
13873
13978
|
const parsed = parseFrontmatter(content, file);
|
|
13874
13979
|
if (parsed) callback(parsed);
|
|
13875
13980
|
}
|
|
@@ -13923,13 +14028,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
13923
14028
|
}
|
|
13924
14029
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
13925
14030
|
for (const commit2 of commits2) {
|
|
13926
|
-
console.log(` ${
|
|
14031
|
+
console.log(` ${chalk127.yellow(commit2.hash)} ${commit2.message}`);
|
|
13927
14032
|
if (verbose) {
|
|
13928
14033
|
const visibleFiles = commit2.files.filter(
|
|
13929
14034
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
13930
14035
|
);
|
|
13931
14036
|
for (const file of visibleFiles) {
|
|
13932
|
-
console.log(` ${
|
|
14037
|
+
console.log(` ${chalk127.dim(file)}`);
|
|
13933
14038
|
}
|
|
13934
14039
|
}
|
|
13935
14040
|
}
|
|
@@ -13954,15 +14059,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
13954
14059
|
}
|
|
13955
14060
|
|
|
13956
14061
|
// src/commands/devlog/list/printDateHeader.ts
|
|
13957
|
-
import
|
|
14062
|
+
import chalk128 from "chalk";
|
|
13958
14063
|
function printDateHeader(date, isSkipped, entries) {
|
|
13959
14064
|
if (isSkipped) {
|
|
13960
|
-
console.log(`${
|
|
14065
|
+
console.log(`${chalk128.bold.blue(date)} ${chalk128.dim("skipped")}`);
|
|
13961
14066
|
} else if (entries && entries.length > 0) {
|
|
13962
|
-
const entryInfo = entries.map((e) => `${
|
|
13963
|
-
console.log(`${
|
|
14067
|
+
const entryInfo = entries.map((e) => `${chalk128.green(e.version)} ${e.title}`).join(" | ");
|
|
14068
|
+
console.log(`${chalk128.bold.blue(date)} ${entryInfo}`);
|
|
13964
14069
|
} else {
|
|
13965
|
-
console.log(`${
|
|
14070
|
+
console.log(`${chalk128.bold.blue(date)} ${chalk128.red("\u26A0 devlog missing")}`);
|
|
13966
14071
|
}
|
|
13967
14072
|
}
|
|
13968
14073
|
|
|
@@ -14066,24 +14171,24 @@ function bumpVersion(version2, type) {
|
|
|
14066
14171
|
|
|
14067
14172
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
14068
14173
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14069
|
-
import
|
|
14174
|
+
import chalk130 from "chalk";
|
|
14070
14175
|
|
|
14071
14176
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
14072
|
-
import
|
|
14177
|
+
import chalk129 from "chalk";
|
|
14073
14178
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
14074
14179
|
if (conventional && firstHash) {
|
|
14075
14180
|
const version2 = getVersionAtCommit(firstHash);
|
|
14076
14181
|
if (version2) {
|
|
14077
|
-
console.log(`${
|
|
14182
|
+
console.log(`${chalk129.bold("version:")} ${stripToMinor(version2)}`);
|
|
14078
14183
|
} else {
|
|
14079
|
-
console.log(`${
|
|
14184
|
+
console.log(`${chalk129.bold("version:")} ${chalk129.red("unknown")}`);
|
|
14080
14185
|
}
|
|
14081
14186
|
} else if (patchVersion && minorVersion) {
|
|
14082
14187
|
console.log(
|
|
14083
|
-
`${
|
|
14188
|
+
`${chalk129.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
14084
14189
|
);
|
|
14085
14190
|
} else {
|
|
14086
|
-
console.log(`${
|
|
14191
|
+
console.log(`${chalk129.bold("version:")} v0.1 (initial)`);
|
|
14087
14192
|
}
|
|
14088
14193
|
}
|
|
14089
14194
|
|
|
@@ -14131,16 +14236,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
14131
14236
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
14132
14237
|
}
|
|
14133
14238
|
function logName(repoName) {
|
|
14134
|
-
console.log(`${
|
|
14239
|
+
console.log(`${chalk130.bold("name:")} ${repoName}`);
|
|
14135
14240
|
}
|
|
14136
14241
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
14137
14242
|
logName(ctx.repoName);
|
|
14138
14243
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
14139
|
-
console.log(
|
|
14244
|
+
console.log(chalk130.bold.blue(targetDate));
|
|
14140
14245
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
14141
14246
|
}
|
|
14142
14247
|
function logNoCommits(lastInfo) {
|
|
14143
|
-
console.log(
|
|
14248
|
+
console.log(chalk130.dim(noCommitsMessage(!!lastInfo)));
|
|
14144
14249
|
}
|
|
14145
14250
|
|
|
14146
14251
|
// src/commands/devlog/next/index.ts
|
|
@@ -14181,11 +14286,11 @@ function next2(options2) {
|
|
|
14181
14286
|
import { execSync as execSync34 } from "child_process";
|
|
14182
14287
|
|
|
14183
14288
|
// src/commands/devlog/repos/printReposTable.ts
|
|
14184
|
-
import
|
|
14289
|
+
import chalk131 from "chalk";
|
|
14185
14290
|
function colorStatus(status3) {
|
|
14186
|
-
if (status3 === "missing") return
|
|
14187
|
-
if (status3 === "outdated") return
|
|
14188
|
-
return
|
|
14291
|
+
if (status3 === "missing") return chalk131.red(status3);
|
|
14292
|
+
if (status3 === "outdated") return chalk131.yellow(status3);
|
|
14293
|
+
return chalk131.green(status3);
|
|
14189
14294
|
}
|
|
14190
14295
|
function formatRow(row, nameWidth) {
|
|
14191
14296
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -14199,8 +14304,8 @@ function printReposTable(rows) {
|
|
|
14199
14304
|
"Last Devlog".padEnd(11),
|
|
14200
14305
|
"Status"
|
|
14201
14306
|
].join(" ");
|
|
14202
|
-
console.log(
|
|
14203
|
-
console.log(
|
|
14307
|
+
console.log(chalk131.dim(header));
|
|
14308
|
+
console.log(chalk131.dim("-".repeat(header.length)));
|
|
14204
14309
|
for (const row of rows) {
|
|
14205
14310
|
console.log(formatRow(row, nameWidth));
|
|
14206
14311
|
}
|
|
@@ -14256,16 +14361,16 @@ function repos(options2) {
|
|
|
14256
14361
|
}
|
|
14257
14362
|
|
|
14258
14363
|
// src/commands/devlog/skip.ts
|
|
14259
|
-
import { writeFileSync as
|
|
14260
|
-
import { join as
|
|
14261
|
-
import
|
|
14364
|
+
import { writeFileSync as writeFileSync29 } from "fs";
|
|
14365
|
+
import { join as join37 } from "path";
|
|
14366
|
+
import chalk132 from "chalk";
|
|
14262
14367
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
14263
14368
|
function getBlogConfigPath() {
|
|
14264
|
-
return
|
|
14369
|
+
return join37(BLOG_REPO_ROOT, "assist.yml");
|
|
14265
14370
|
}
|
|
14266
14371
|
function skip(date) {
|
|
14267
14372
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
14268
|
-
console.log(
|
|
14373
|
+
console.log(chalk132.red("Invalid date format. Use YYYY-MM-DD"));
|
|
14269
14374
|
process.exit(1);
|
|
14270
14375
|
}
|
|
14271
14376
|
const repoName = getRepoName();
|
|
@@ -14276,7 +14381,7 @@ function skip(date) {
|
|
|
14276
14381
|
const skipDays = skip2[repoName] ?? [];
|
|
14277
14382
|
if (skipDays.includes(date)) {
|
|
14278
14383
|
console.log(
|
|
14279
|
-
|
|
14384
|
+
chalk132.yellow(`${date} is already in skip list for ${repoName}`)
|
|
14280
14385
|
);
|
|
14281
14386
|
return;
|
|
14282
14387
|
}
|
|
@@ -14285,21 +14390,21 @@ function skip(date) {
|
|
|
14285
14390
|
skip2[repoName] = skipDays;
|
|
14286
14391
|
devlog.skip = skip2;
|
|
14287
14392
|
config.devlog = devlog;
|
|
14288
|
-
|
|
14289
|
-
console.log(
|
|
14393
|
+
writeFileSync29(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
14394
|
+
console.log(chalk132.green(`Added ${date} to skip list for ${repoName}`));
|
|
14290
14395
|
}
|
|
14291
14396
|
|
|
14292
14397
|
// src/commands/devlog/version.ts
|
|
14293
|
-
import
|
|
14398
|
+
import chalk133 from "chalk";
|
|
14294
14399
|
function version() {
|
|
14295
14400
|
const config = loadConfig();
|
|
14296
14401
|
const name = getRepoName();
|
|
14297
14402
|
const lastInfo = getLastVersionInfo(name, config);
|
|
14298
14403
|
const lastVersion = lastInfo?.version ?? null;
|
|
14299
14404
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
14300
|
-
console.log(`${
|
|
14301
|
-
console.log(`${
|
|
14302
|
-
console.log(`${
|
|
14405
|
+
console.log(`${chalk133.bold("name:")} ${name}`);
|
|
14406
|
+
console.log(`${chalk133.bold("last:")} ${lastVersion ?? chalk133.dim("none")}`);
|
|
14407
|
+
console.log(`${chalk133.bold("next:")} ${nextVersion ?? chalk133.dim("none")}`);
|
|
14303
14408
|
}
|
|
14304
14409
|
|
|
14305
14410
|
// src/commands/devlog/devlogConfigHelp.ts
|
|
@@ -14342,16 +14447,16 @@ function registerDevlog(program2) {
|
|
|
14342
14447
|
|
|
14343
14448
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
14344
14449
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5 } from "fs";
|
|
14345
|
-
import { join as
|
|
14346
|
-
import
|
|
14450
|
+
import { join as join38 } from "path";
|
|
14451
|
+
import chalk134 from "chalk";
|
|
14347
14452
|
|
|
14348
14453
|
// src/shared/findRepoRoot.ts
|
|
14349
|
-
import { existsSync as
|
|
14454
|
+
import { existsSync as existsSync35 } from "fs";
|
|
14350
14455
|
import path28 from "path";
|
|
14351
14456
|
function findRepoRoot(dir) {
|
|
14352
14457
|
let current = dir;
|
|
14353
14458
|
while (current !== path28.dirname(current)) {
|
|
14354
|
-
if (
|
|
14459
|
+
if (existsSync35(path28.join(current, ".git"))) {
|
|
14355
14460
|
return current;
|
|
14356
14461
|
}
|
|
14357
14462
|
current = path28.dirname(current);
|
|
@@ -14370,7 +14475,7 @@ function isLockedDll(debugDir) {
|
|
|
14370
14475
|
}
|
|
14371
14476
|
for (const file of files) {
|
|
14372
14477
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
14373
|
-
const dllPath =
|
|
14478
|
+
const dllPath = join38(debugDir, file);
|
|
14374
14479
|
try {
|
|
14375
14480
|
const fd = openSync3(dllPath, "r+");
|
|
14376
14481
|
closeSync3(fd);
|
|
@@ -14388,13 +14493,13 @@ function findFirstLockedDll(dir) {
|
|
|
14388
14493
|
return null;
|
|
14389
14494
|
}
|
|
14390
14495
|
if (entries.includes("bin")) {
|
|
14391
|
-
const locked = isLockedDll(
|
|
14496
|
+
const locked = isLockedDll(join38(dir, "bin", "Debug"));
|
|
14392
14497
|
if (locked) return locked;
|
|
14393
14498
|
}
|
|
14394
14499
|
for (const entry of entries) {
|
|
14395
14500
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
14396
14501
|
continue;
|
|
14397
|
-
const found = findFirstLockedDll(
|
|
14502
|
+
const found = findFirstLockedDll(join38(dir, entry));
|
|
14398
14503
|
if (found) return found;
|
|
14399
14504
|
}
|
|
14400
14505
|
return null;
|
|
@@ -14406,22 +14511,22 @@ function checkBuildLocks(startDir) {
|
|
|
14406
14511
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
14407
14512
|
if (locked) {
|
|
14408
14513
|
console.error(
|
|
14409
|
-
|
|
14514
|
+
chalk134.red("Build output locked (is VS debugging?): ") + locked
|
|
14410
14515
|
);
|
|
14411
14516
|
process.exit(1);
|
|
14412
14517
|
}
|
|
14413
14518
|
}
|
|
14414
14519
|
async function checkBuildLocksCommand() {
|
|
14415
14520
|
checkBuildLocks();
|
|
14416
|
-
console.log(
|
|
14521
|
+
console.log(chalk134.green("No build locks detected"));
|
|
14417
14522
|
}
|
|
14418
14523
|
|
|
14419
14524
|
// src/commands/dotnet/buildTree.ts
|
|
14420
|
-
import { readFileSync as
|
|
14525
|
+
import { readFileSync as readFileSync32 } from "fs";
|
|
14421
14526
|
import path29 from "path";
|
|
14422
14527
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
14423
14528
|
function getProjectRefs(csprojPath) {
|
|
14424
|
-
const content =
|
|
14529
|
+
const content = readFileSync32(csprojPath, "utf8");
|
|
14425
14530
|
const refs = [];
|
|
14426
14531
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
14427
14532
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -14438,7 +14543,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
14438
14543
|
for (const ref of getProjectRefs(abs)) {
|
|
14439
14544
|
const childAbs = path29.resolve(dir, ref);
|
|
14440
14545
|
try {
|
|
14441
|
-
|
|
14546
|
+
readFileSync32(childAbs);
|
|
14442
14547
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
14443
14548
|
} catch {
|
|
14444
14549
|
node.children.push({
|
|
@@ -14463,7 +14568,7 @@ function collectAllDeps(node) {
|
|
|
14463
14568
|
}
|
|
14464
14569
|
|
|
14465
14570
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
14466
|
-
import { readdirSync as readdirSync6, readFileSync as
|
|
14571
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync33, statSync as statSync4 } from "fs";
|
|
14467
14572
|
import path30 from "path";
|
|
14468
14573
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
14469
14574
|
if (depth > maxDepth) return [];
|
|
@@ -14498,7 +14603,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
14498
14603
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
14499
14604
|
for (const sln of slnFiles) {
|
|
14500
14605
|
try {
|
|
14501
|
-
const content =
|
|
14606
|
+
const content = readFileSync33(sln, "utf8");
|
|
14502
14607
|
if (pattern2.test(content)) {
|
|
14503
14608
|
matches.push(path30.relative(repoRoot, sln));
|
|
14504
14609
|
}
|
|
@@ -14512,30 +14617,30 @@ function escapeRegex(s) {
|
|
|
14512
14617
|
}
|
|
14513
14618
|
|
|
14514
14619
|
// src/commands/dotnet/printTree.ts
|
|
14515
|
-
import
|
|
14620
|
+
import chalk135 from "chalk";
|
|
14516
14621
|
function printNodes(nodes, prefix2) {
|
|
14517
14622
|
for (let i = 0; i < nodes.length; i++) {
|
|
14518
14623
|
const isLast = i === nodes.length - 1;
|
|
14519
14624
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
14520
14625
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
14521
14626
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
14522
|
-
const label2 = isMissing ?
|
|
14627
|
+
const label2 = isMissing ? chalk135.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
14523
14628
|
console.log(`${prefix2}${connector}${label2}`);
|
|
14524
14629
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
14525
14630
|
}
|
|
14526
14631
|
}
|
|
14527
14632
|
function printTree(tree, totalCount, solutions) {
|
|
14528
|
-
console.log(
|
|
14529
|
-
console.log(
|
|
14633
|
+
console.log(chalk135.bold("\nProject Dependency Tree"));
|
|
14634
|
+
console.log(chalk135.cyan(tree.relativePath));
|
|
14530
14635
|
printNodes(tree.children, "");
|
|
14531
|
-
console.log(
|
|
14636
|
+
console.log(chalk135.dim(`
|
|
14532
14637
|
${totalCount} projects total (including root)`));
|
|
14533
|
-
console.log(
|
|
14638
|
+
console.log(chalk135.bold("\nSolution Membership"));
|
|
14534
14639
|
if (solutions.length === 0) {
|
|
14535
|
-
console.log(
|
|
14640
|
+
console.log(chalk135.yellow(" Not found in any .sln"));
|
|
14536
14641
|
} else {
|
|
14537
14642
|
for (const sln of solutions) {
|
|
14538
|
-
console.log(` ${
|
|
14643
|
+
console.log(` ${chalk135.green(sln)}`);
|
|
14539
14644
|
}
|
|
14540
14645
|
}
|
|
14541
14646
|
console.log();
|
|
@@ -14562,18 +14667,18 @@ function printJson(tree, totalCount, solutions) {
|
|
|
14562
14667
|
}
|
|
14563
14668
|
|
|
14564
14669
|
// src/commands/dotnet/resolveCsproj.ts
|
|
14565
|
-
import { existsSync as
|
|
14670
|
+
import { existsSync as existsSync36 } from "fs";
|
|
14566
14671
|
import path31 from "path";
|
|
14567
|
-
import
|
|
14672
|
+
import chalk136 from "chalk";
|
|
14568
14673
|
function resolveCsproj(csprojPath) {
|
|
14569
14674
|
const resolved = path31.resolve(csprojPath);
|
|
14570
|
-
if (!
|
|
14571
|
-
console.error(
|
|
14675
|
+
if (!existsSync36(resolved)) {
|
|
14676
|
+
console.error(chalk136.red(`File not found: ${resolved}`));
|
|
14572
14677
|
process.exit(1);
|
|
14573
14678
|
}
|
|
14574
14679
|
const repoRoot = findRepoRoot(path31.dirname(resolved));
|
|
14575
14680
|
if (!repoRoot) {
|
|
14576
|
-
console.error(
|
|
14681
|
+
console.error(chalk136.red("Could not find git repository root"));
|
|
14577
14682
|
process.exit(1);
|
|
14578
14683
|
}
|
|
14579
14684
|
return { resolved, repoRoot };
|
|
@@ -14623,12 +14728,12 @@ function getChangedCsFiles(scope) {
|
|
|
14623
14728
|
}
|
|
14624
14729
|
|
|
14625
14730
|
// src/commands/dotnet/inSln.ts
|
|
14626
|
-
import
|
|
14731
|
+
import chalk137 from "chalk";
|
|
14627
14732
|
async function inSln(csprojPath) {
|
|
14628
14733
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
14629
14734
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
14630
14735
|
if (solutions.length === 0) {
|
|
14631
|
-
console.log(
|
|
14736
|
+
console.log(chalk137.yellow("Not found in any .sln file"));
|
|
14632
14737
|
process.exit(1);
|
|
14633
14738
|
}
|
|
14634
14739
|
for (const sln of solutions) {
|
|
@@ -14637,7 +14742,7 @@ async function inSln(csprojPath) {
|
|
|
14637
14742
|
}
|
|
14638
14743
|
|
|
14639
14744
|
// src/commands/dotnet/inspect.ts
|
|
14640
|
-
import
|
|
14745
|
+
import chalk143 from "chalk";
|
|
14641
14746
|
|
|
14642
14747
|
// src/shared/formatElapsed.ts
|
|
14643
14748
|
function formatElapsed(ms) {
|
|
@@ -14649,12 +14754,12 @@ function formatElapsed(ms) {
|
|
|
14649
14754
|
}
|
|
14650
14755
|
|
|
14651
14756
|
// src/commands/dotnet/displayIssues.ts
|
|
14652
|
-
import
|
|
14757
|
+
import chalk138 from "chalk";
|
|
14653
14758
|
var SEVERITY_COLOR = {
|
|
14654
|
-
ERROR:
|
|
14655
|
-
WARNING:
|
|
14656
|
-
SUGGESTION:
|
|
14657
|
-
HINT:
|
|
14759
|
+
ERROR: chalk138.red,
|
|
14760
|
+
WARNING: chalk138.yellow,
|
|
14761
|
+
SUGGESTION: chalk138.cyan,
|
|
14762
|
+
HINT: chalk138.dim
|
|
14658
14763
|
};
|
|
14659
14764
|
function groupByFile(issues) {
|
|
14660
14765
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -14670,15 +14775,15 @@ function groupByFile(issues) {
|
|
|
14670
14775
|
}
|
|
14671
14776
|
function displayIssues(issues) {
|
|
14672
14777
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
14673
|
-
console.log(
|
|
14778
|
+
console.log(chalk138.bold(file));
|
|
14674
14779
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
14675
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
14780
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk138.white;
|
|
14676
14781
|
console.log(
|
|
14677
|
-
` ${
|
|
14782
|
+
` ${chalk138.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
14678
14783
|
);
|
|
14679
14784
|
}
|
|
14680
14785
|
}
|
|
14681
|
-
console.log(
|
|
14786
|
+
console.log(chalk138.dim(`
|
|
14682
14787
|
${issues.length} issue(s) found`));
|
|
14683
14788
|
}
|
|
14684
14789
|
|
|
@@ -14735,17 +14840,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
14735
14840
|
}
|
|
14736
14841
|
|
|
14737
14842
|
// src/commands/dotnet/resolveSolution.ts
|
|
14738
|
-
import { existsSync as
|
|
14843
|
+
import { existsSync as existsSync37 } from "fs";
|
|
14739
14844
|
import path32 from "path";
|
|
14740
|
-
import
|
|
14845
|
+
import chalk140 from "chalk";
|
|
14741
14846
|
|
|
14742
14847
|
// src/commands/dotnet/findSolution.ts
|
|
14743
14848
|
import { readdirSync as readdirSync7 } from "fs";
|
|
14744
|
-
import { dirname as dirname22, join as
|
|
14745
|
-
import
|
|
14849
|
+
import { dirname as dirname22, join as join39 } from "path";
|
|
14850
|
+
import chalk139 from "chalk";
|
|
14746
14851
|
function findSlnInDir(dir) {
|
|
14747
14852
|
try {
|
|
14748
|
-
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
14853
|
+
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) => join39(dir, f));
|
|
14749
14854
|
} catch {
|
|
14750
14855
|
return [];
|
|
14751
14856
|
}
|
|
@@ -14758,17 +14863,17 @@ function findSolution() {
|
|
|
14758
14863
|
const slnFiles = findSlnInDir(current);
|
|
14759
14864
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
14760
14865
|
if (slnFiles.length > 1) {
|
|
14761
|
-
console.error(
|
|
14866
|
+
console.error(chalk139.red(`Multiple .sln files found in ${current}:`));
|
|
14762
14867
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
14763
14868
|
console.error(
|
|
14764
|
-
|
|
14869
|
+
chalk139.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
14765
14870
|
);
|
|
14766
14871
|
process.exit(1);
|
|
14767
14872
|
}
|
|
14768
14873
|
if (current === ceiling) break;
|
|
14769
14874
|
current = dirname22(current);
|
|
14770
14875
|
}
|
|
14771
|
-
console.error(
|
|
14876
|
+
console.error(chalk139.red("No .sln file found between cwd and repo root"));
|
|
14772
14877
|
process.exit(1);
|
|
14773
14878
|
}
|
|
14774
14879
|
|
|
@@ -14776,8 +14881,8 @@ function findSolution() {
|
|
|
14776
14881
|
function resolveSolution(sln) {
|
|
14777
14882
|
if (sln) {
|
|
14778
14883
|
const resolved = path32.resolve(sln);
|
|
14779
|
-
if (!
|
|
14780
|
-
console.error(
|
|
14884
|
+
if (!existsSync37(resolved)) {
|
|
14885
|
+
console.error(chalk140.red(`Solution file not found: ${resolved}`));
|
|
14781
14886
|
process.exit(1);
|
|
14782
14887
|
}
|
|
14783
14888
|
return resolved;
|
|
@@ -14816,17 +14921,17 @@ function parseInspectReport(json) {
|
|
|
14816
14921
|
|
|
14817
14922
|
// src/commands/dotnet/runInspectCode.ts
|
|
14818
14923
|
import { execSync as execSync36 } from "child_process";
|
|
14819
|
-
import { existsSync as
|
|
14924
|
+
import { existsSync as existsSync38, readFileSync as readFileSync34, unlinkSync as unlinkSync10 } from "fs";
|
|
14820
14925
|
import { tmpdir as tmpdir3 } from "os";
|
|
14821
14926
|
import path33 from "path";
|
|
14822
|
-
import
|
|
14927
|
+
import chalk141 from "chalk";
|
|
14823
14928
|
function assertJbInstalled() {
|
|
14824
14929
|
try {
|
|
14825
14930
|
execSync36("jb inspectcode --version", { stdio: "pipe" });
|
|
14826
14931
|
} catch {
|
|
14827
|
-
console.error(
|
|
14932
|
+
console.error(chalk141.red("jb is not installed. Install with:"));
|
|
14828
14933
|
console.error(
|
|
14829
|
-
|
|
14934
|
+
chalk141.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
14830
14935
|
);
|
|
14831
14936
|
process.exit(1);
|
|
14832
14937
|
}
|
|
@@ -14844,21 +14949,21 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
14844
14949
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
14845
14950
|
process.stderr.write(error.stderr);
|
|
14846
14951
|
}
|
|
14847
|
-
console.error(
|
|
14952
|
+
console.error(chalk141.red("jb inspectcode failed"));
|
|
14848
14953
|
process.exit(1);
|
|
14849
14954
|
}
|
|
14850
|
-
if (!
|
|
14851
|
-
console.error(
|
|
14955
|
+
if (!existsSync38(reportPath)) {
|
|
14956
|
+
console.error(chalk141.red("Report file not generated"));
|
|
14852
14957
|
process.exit(1);
|
|
14853
14958
|
}
|
|
14854
|
-
const xml =
|
|
14855
|
-
|
|
14959
|
+
const xml = readFileSync34(reportPath, "utf8");
|
|
14960
|
+
unlinkSync10(reportPath);
|
|
14856
14961
|
return xml;
|
|
14857
14962
|
}
|
|
14858
14963
|
|
|
14859
14964
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
14860
14965
|
import { execSync as execSync37 } from "child_process";
|
|
14861
|
-
import
|
|
14966
|
+
import chalk142 from "chalk";
|
|
14862
14967
|
function resolveMsbuildPath() {
|
|
14863
14968
|
const { run: run4 } = loadConfig();
|
|
14864
14969
|
const configs = resolveRunConfigs(run4, getConfigDir());
|
|
@@ -14870,9 +14975,9 @@ function assertMsbuildInstalled() {
|
|
|
14870
14975
|
try {
|
|
14871
14976
|
execSync37(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
14872
14977
|
} catch {
|
|
14873
|
-
console.error(
|
|
14978
|
+
console.error(chalk142.red(`msbuild not found at: ${msbuild}`));
|
|
14874
14979
|
console.error(
|
|
14875
|
-
|
|
14980
|
+
chalk142.yellow(
|
|
14876
14981
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
14877
14982
|
)
|
|
14878
14983
|
);
|
|
@@ -14919,17 +15024,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
14919
15024
|
// src/commands/dotnet/inspect.ts
|
|
14920
15025
|
function logScope(changedFiles) {
|
|
14921
15026
|
if (changedFiles === null) {
|
|
14922
|
-
console.log(
|
|
15027
|
+
console.log(chalk143.dim("Inspecting full solution..."));
|
|
14923
15028
|
} else {
|
|
14924
15029
|
console.log(
|
|
14925
|
-
|
|
15030
|
+
chalk143.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
14926
15031
|
);
|
|
14927
15032
|
}
|
|
14928
15033
|
}
|
|
14929
15034
|
function reportResults(issues, elapsed) {
|
|
14930
15035
|
if (issues.length > 0) displayIssues(issues);
|
|
14931
|
-
else console.log(
|
|
14932
|
-
console.log(
|
|
15036
|
+
else console.log(chalk143.green("No issues found"));
|
|
15037
|
+
console.log(chalk143.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
14933
15038
|
if (issues.length > 0) process.exit(1);
|
|
14934
15039
|
}
|
|
14935
15040
|
async function inspect(sln, options2) {
|
|
@@ -14940,7 +15045,7 @@ async function inspect(sln, options2) {
|
|
|
14940
15045
|
const scope = parseScope(options2.scope);
|
|
14941
15046
|
const changedFiles = getChangedCsFiles(scope);
|
|
14942
15047
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
14943
|
-
console.log(
|
|
15048
|
+
console.log(chalk143.green("No changed .cs files found"));
|
|
14944
15049
|
return;
|
|
14945
15050
|
}
|
|
14946
15051
|
logScope(changedFiles);
|
|
@@ -15109,6 +15214,41 @@ function decideCommentGuard(input, existingContent) {
|
|
|
15109
15214
|
return introduced.length > 0 ? denyReason(hash ? "#" : "//") : void 0;
|
|
15110
15215
|
}
|
|
15111
15216
|
|
|
15217
|
+
// src/commands/dbMigration/consumeMigrationApproval.ts
|
|
15218
|
+
import { existsSync as existsSync39, unlinkSync as unlinkSync11 } from "fs";
|
|
15219
|
+
function consumeMigrationApproval(migrationId) {
|
|
15220
|
+
sweepRestrictedDir();
|
|
15221
|
+
const path67 = getMigrationApprovalPath(migrationId);
|
|
15222
|
+
if (!existsSync39(path67)) return false;
|
|
15223
|
+
try {
|
|
15224
|
+
unlinkSync11(path67);
|
|
15225
|
+
return true;
|
|
15226
|
+
} catch {
|
|
15227
|
+
return false;
|
|
15228
|
+
}
|
|
15229
|
+
}
|
|
15230
|
+
|
|
15231
|
+
// src/commands/editHook/decideMigrationGuard.ts
|
|
15232
|
+
var MIGRATION_PATH = /(?:^|\/)src\/shared\/db\/migrations\/migration(\d{4})[^/]*\.ts$/;
|
|
15233
|
+
function denyReason2(migrationId) {
|
|
15234
|
+
return `This Write creates a new database migration (migration ${migrationId}), which is blocked by the migration gate. Schema changes must be approved by a human. Confirm the change with the user first, then run \`assist db-migration unlock\` to page a human for a pin, and \`assist db-migration confirm <pin>\` to approve this migration. The approved write is then allowed once.`;
|
|
15235
|
+
}
|
|
15236
|
+
function newMigrationId(input, existingContent) {
|
|
15237
|
+
if (input.tool_name !== "Write") return void 0;
|
|
15238
|
+
if (existingContent !== void 0) return void 0;
|
|
15239
|
+
const filePath = input.tool_input.file_path;
|
|
15240
|
+
if (!filePath) return void 0;
|
|
15241
|
+
const match = filePath.replace(/\\/g, "/").match(MIGRATION_PATH);
|
|
15242
|
+
if (!match) return void 0;
|
|
15243
|
+
return Number.parseInt(match[1], 10);
|
|
15244
|
+
}
|
|
15245
|
+
function decideMigrationGuard(input, existingContent) {
|
|
15246
|
+
const migrationId = newMigrationId(input, existingContent);
|
|
15247
|
+
if (migrationId === void 0) return void 0;
|
|
15248
|
+
if (consumeMigrationApproval(migrationId)) return void 0;
|
|
15249
|
+
return denyReason2(migrationId);
|
|
15250
|
+
}
|
|
15251
|
+
|
|
15112
15252
|
// src/commands/editHook/decideOverrideGuard.ts
|
|
15113
15253
|
var DENY_REASON = `Edits touching the '${MAINTAINABILITY_OVERRIDE_MARKER}' marker are blocked. This marker is a human-managed maintainability gate exception \u2014 an agent may not add, change, or remove it. If a file genuinely needs a different threshold, raise it with a human.`;
|
|
15114
15254
|
function candidateStrings(input, existingContent) {
|
|
@@ -15162,7 +15302,7 @@ async function editHook() {
|
|
|
15162
15302
|
const input = tryParseInput2(await readStdin());
|
|
15163
15303
|
if (!input) return;
|
|
15164
15304
|
const existing = input.tool_name === "Write" ? readExisting(input.tool_input.file_path) : void 0;
|
|
15165
|
-
const reason = decideOverrideGuard(input, existing) ?? decideCommentGuard(input, existing);
|
|
15305
|
+
const reason = decideOverrideGuard(input, existing) ?? decideCommentGuard(input, existing) ?? decideMigrationGuard(input, existing);
|
|
15166
15306
|
if (!reason) return;
|
|
15167
15307
|
console.log(
|
|
15168
15308
|
JSON.stringify({
|
|
@@ -15197,9 +15337,9 @@ function aggregateCommitters(authorLists) {
|
|
|
15197
15337
|
|
|
15198
15338
|
// src/shared/runGhGraphql.ts
|
|
15199
15339
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
15200
|
-
import { unlinkSync as
|
|
15340
|
+
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
15201
15341
|
import { tmpdir as tmpdir4 } from "os";
|
|
15202
|
-
import { join as
|
|
15342
|
+
import { join as join40 } from "path";
|
|
15203
15343
|
function buildArgs2(queryFile, vars) {
|
|
15204
15344
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
15205
15345
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -15224,8 +15364,8 @@ function throwOnGraphqlErrors(stdout) {
|
|
|
15224
15364
|
throw new Error(messages || "GraphQL request returned errors");
|
|
15225
15365
|
}
|
|
15226
15366
|
function runGhGraphql(mutation, vars) {
|
|
15227
|
-
const queryFile =
|
|
15228
|
-
|
|
15367
|
+
const queryFile = join40(tmpdir4(), `gh-query-${Date.now()}.graphql`);
|
|
15368
|
+
writeFileSync30(queryFile, mutation);
|
|
15229
15369
|
try {
|
|
15230
15370
|
const result = spawnSync3("gh", buildArgs2(queryFile, vars), {
|
|
15231
15371
|
encoding: "utf8"
|
|
@@ -15234,7 +15374,7 @@ function runGhGraphql(mutation, vars) {
|
|
|
15234
15374
|
throwOnGraphqlErrors(result.stdout);
|
|
15235
15375
|
return result.stdout;
|
|
15236
15376
|
} finally {
|
|
15237
|
-
|
|
15377
|
+
unlinkSync12(queryFile);
|
|
15238
15378
|
}
|
|
15239
15379
|
}
|
|
15240
15380
|
|
|
@@ -15288,25 +15428,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
15288
15428
|
}
|
|
15289
15429
|
|
|
15290
15430
|
// src/commands/github/printCountTable.ts
|
|
15291
|
-
import
|
|
15431
|
+
import chalk144 from "chalk";
|
|
15292
15432
|
function printCountTable(labelHeader, rows) {
|
|
15293
15433
|
const labelWidth = Math.max(
|
|
15294
15434
|
labelHeader.length,
|
|
15295
15435
|
...rows.map((row) => row.label.length)
|
|
15296
15436
|
);
|
|
15297
15437
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
15298
|
-
console.log(
|
|
15299
|
-
console.log(
|
|
15438
|
+
console.log(chalk144.dim(header));
|
|
15439
|
+
console.log(chalk144.dim("-".repeat(header.length)));
|
|
15300
15440
|
for (const row of rows) {
|
|
15301
15441
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
15302
15442
|
}
|
|
15303
15443
|
}
|
|
15304
15444
|
|
|
15305
15445
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
15306
|
-
import
|
|
15446
|
+
import chalk145 from "chalk";
|
|
15307
15447
|
function printRepoAuthorBreakdown(repos2) {
|
|
15308
15448
|
for (const repo of repos2) {
|
|
15309
|
-
console.log(
|
|
15449
|
+
console.log(chalk145.bold(repo.name));
|
|
15310
15450
|
const authorWidth = Math.max(
|
|
15311
15451
|
0,
|
|
15312
15452
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -15411,24 +15551,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
15411
15551
|
|
|
15412
15552
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
15413
15553
|
import {
|
|
15414
|
-
existsSync as
|
|
15554
|
+
existsSync as existsSync40,
|
|
15415
15555
|
readdirSync as readdirSync8,
|
|
15416
|
-
readFileSync as
|
|
15556
|
+
readFileSync as readFileSync35,
|
|
15417
15557
|
rmSync as rmSync3,
|
|
15418
15558
|
statSync as statSync5
|
|
15419
15559
|
} from "fs";
|
|
15420
|
-
import { basename as basename10, join as
|
|
15560
|
+
import { basename as basename10, join as join43 } from "path";
|
|
15421
15561
|
|
|
15422
15562
|
// src/commands/handover/getHandoverPath.ts
|
|
15423
|
-
import { join as
|
|
15563
|
+
import { join as join41 } from "path";
|
|
15424
15564
|
function getHandoverPath(cwd = process.cwd()) {
|
|
15425
|
-
return
|
|
15565
|
+
return join41(cwd, ".assist", "HANDOVER.md");
|
|
15426
15566
|
}
|
|
15427
15567
|
|
|
15428
15568
|
// src/commands/handover/getHandoversDir.ts
|
|
15429
|
-
import { join as
|
|
15569
|
+
import { join as join42 } from "path";
|
|
15430
15570
|
function getHandoversDir(cwd = process.cwd()) {
|
|
15431
|
-
return
|
|
15571
|
+
return join42(cwd, ".assist", "handovers");
|
|
15432
15572
|
}
|
|
15433
15573
|
|
|
15434
15574
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -15466,17 +15606,17 @@ function summariseHandoverContent(content) {
|
|
|
15466
15606
|
|
|
15467
15607
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
15468
15608
|
function collectMarkdown(dir) {
|
|
15469
|
-
if (!
|
|
15609
|
+
if (!existsSync40(dir)) return [];
|
|
15470
15610
|
const out = [];
|
|
15471
15611
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
15472
|
-
const full =
|
|
15612
|
+
const full = join43(dir, entry.name);
|
|
15473
15613
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
15474
15614
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
15475
15615
|
}
|
|
15476
15616
|
return out;
|
|
15477
15617
|
}
|
|
15478
15618
|
async function migrateFile(orm, origin, file, createdAt) {
|
|
15479
|
-
const content =
|
|
15619
|
+
const content = readFileSync35(file, "utf8");
|
|
15480
15620
|
await saveHandover(orm, {
|
|
15481
15621
|
origin,
|
|
15482
15622
|
summary: summariseHandoverContent(content),
|
|
@@ -15493,7 +15633,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
15493
15633
|
migrated++;
|
|
15494
15634
|
}
|
|
15495
15635
|
const handoverPath = getHandoverPath(cwd);
|
|
15496
|
-
if (
|
|
15636
|
+
if (existsSync40(handoverPath)) {
|
|
15497
15637
|
await migrateFile(orm, origin, handoverPath, statSync5(handoverPath).mtime);
|
|
15498
15638
|
migrated++;
|
|
15499
15639
|
}
|
|
@@ -15624,7 +15764,7 @@ function registerHandover(program2) {
|
|
|
15624
15764
|
}
|
|
15625
15765
|
|
|
15626
15766
|
// src/commands/jira/acceptanceCriteria.ts
|
|
15627
|
-
import
|
|
15767
|
+
import chalk146 from "chalk";
|
|
15628
15768
|
|
|
15629
15769
|
// src/commands/jira/adfToText.ts
|
|
15630
15770
|
function renderInline(node) {
|
|
@@ -15691,7 +15831,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
15691
15831
|
const parsed = fetchIssue(issueKey, field);
|
|
15692
15832
|
const acValue = parsed?.fields?.[field];
|
|
15693
15833
|
if (!acValue) {
|
|
15694
|
-
console.log(
|
|
15834
|
+
console.log(chalk146.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
15695
15835
|
return;
|
|
15696
15836
|
}
|
|
15697
15837
|
if (typeof acValue === "string") {
|
|
@@ -15757,14 +15897,14 @@ async function jiraAuth() {
|
|
|
15757
15897
|
}
|
|
15758
15898
|
|
|
15759
15899
|
// src/commands/jira/viewIssue.ts
|
|
15760
|
-
import
|
|
15900
|
+
import chalk147 from "chalk";
|
|
15761
15901
|
function viewIssue(issueKey) {
|
|
15762
15902
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
15763
15903
|
const fields = parsed?.fields;
|
|
15764
15904
|
const summary = fields?.summary;
|
|
15765
15905
|
const description = fields?.description;
|
|
15766
15906
|
if (summary) {
|
|
15767
|
-
console.log(
|
|
15907
|
+
console.log(chalk147.bold(summary));
|
|
15768
15908
|
}
|
|
15769
15909
|
if (description) {
|
|
15770
15910
|
if (summary) console.log();
|
|
@@ -15778,7 +15918,7 @@ function viewIssue(issueKey) {
|
|
|
15778
15918
|
}
|
|
15779
15919
|
if (!summary && !description) {
|
|
15780
15920
|
console.log(
|
|
15781
|
-
|
|
15921
|
+
chalk147.yellow(`No summary or description found on ${issueKey}.`)
|
|
15782
15922
|
);
|
|
15783
15923
|
}
|
|
15784
15924
|
}
|
|
@@ -15834,13 +15974,13 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
15834
15974
|
// src/commands/reviewPrComments.ts
|
|
15835
15975
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
15836
15976
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
15837
|
-
import
|
|
15977
|
+
import chalk148 from "chalk";
|
|
15838
15978
|
async function reviewPrComments(number) {
|
|
15839
15979
|
if (number) {
|
|
15840
15980
|
try {
|
|
15841
15981
|
execFileSync5("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
15842
15982
|
} catch {
|
|
15843
|
-
console.error(
|
|
15983
|
+
console.error(chalk148.red(`gh pr checkout ${number} failed; aborting.`));
|
|
15844
15984
|
process.exit(1);
|
|
15845
15985
|
}
|
|
15846
15986
|
}
|
|
@@ -15911,17 +16051,17 @@ function registerList(program2) {
|
|
|
15911
16051
|
}
|
|
15912
16052
|
|
|
15913
16053
|
// src/commands/mermaid/index.ts
|
|
15914
|
-
import { mkdirSync as
|
|
16054
|
+
import { mkdirSync as mkdirSync16, readdirSync as readdirSync9 } from "fs";
|
|
15915
16055
|
import { resolve as resolve11 } from "path";
|
|
15916
|
-
import
|
|
16056
|
+
import chalk151 from "chalk";
|
|
15917
16057
|
|
|
15918
16058
|
// src/commands/mermaid/exportFile.ts
|
|
15919
|
-
import { readFileSync as
|
|
16059
|
+
import { readFileSync as readFileSync36, writeFileSync as writeFileSync31 } from "fs";
|
|
15920
16060
|
import { basename as basename11, extname, resolve as resolve10 } from "path";
|
|
15921
|
-
import
|
|
16061
|
+
import chalk150 from "chalk";
|
|
15922
16062
|
|
|
15923
16063
|
// src/commands/mermaid/renderBlock.ts
|
|
15924
|
-
import
|
|
16064
|
+
import chalk149 from "chalk";
|
|
15925
16065
|
async function renderBlock(krokiUrl, source) {
|
|
15926
16066
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
15927
16067
|
method: "POST",
|
|
@@ -15930,7 +16070,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
15930
16070
|
});
|
|
15931
16071
|
if (!response.ok) {
|
|
15932
16072
|
console.error(
|
|
15933
|
-
|
|
16073
|
+
chalk149.red(
|
|
15934
16074
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
15935
16075
|
)
|
|
15936
16076
|
);
|
|
@@ -15942,33 +16082,33 @@ async function renderBlock(krokiUrl, source) {
|
|
|
15942
16082
|
|
|
15943
16083
|
// src/commands/mermaid/exportFile.ts
|
|
15944
16084
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
15945
|
-
const content =
|
|
16085
|
+
const content = readFileSync36(file, "utf8");
|
|
15946
16086
|
const blocks = extractMermaidBlocks(content);
|
|
15947
16087
|
const stem = basename11(file, extname(file));
|
|
15948
16088
|
if (onlyIndex !== void 0) {
|
|
15949
16089
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
15950
16090
|
console.error(
|
|
15951
|
-
|
|
16091
|
+
chalk150.red(
|
|
15952
16092
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
15953
16093
|
)
|
|
15954
16094
|
);
|
|
15955
16095
|
process.exit(1);
|
|
15956
16096
|
}
|
|
15957
16097
|
console.log(
|
|
15958
|
-
|
|
16098
|
+
chalk150.gray(
|
|
15959
16099
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
15960
16100
|
)
|
|
15961
16101
|
);
|
|
15962
16102
|
} else {
|
|
15963
|
-
console.log(
|
|
16103
|
+
console.log(chalk150.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
15964
16104
|
}
|
|
15965
16105
|
for (const [i, source] of blocks.entries()) {
|
|
15966
16106
|
const idx = i + 1;
|
|
15967
16107
|
if (onlyIndex !== void 0 && idx !== onlyIndex) continue;
|
|
15968
16108
|
const outPath = resolve10(outDir, `${stem}-${idx}.svg`);
|
|
15969
16109
|
const svg = await renderBlock(krokiUrl, source);
|
|
15970
|
-
|
|
15971
|
-
console.log(
|
|
16110
|
+
writeFileSync31(outPath, svg, "utf8");
|
|
16111
|
+
console.log(chalk150.green(` \u2192 ${outPath}`));
|
|
15972
16112
|
}
|
|
15973
16113
|
}
|
|
15974
16114
|
function extractMermaidBlocks(markdown) {
|
|
@@ -15980,22 +16120,22 @@ function extractMermaidBlocks(markdown) {
|
|
|
15980
16120
|
async function mermaidExport(file, options2 = {}) {
|
|
15981
16121
|
const { mermaid } = loadConfig();
|
|
15982
16122
|
const outDir = resolve11(process.cwd(), options2.out ?? ".");
|
|
15983
|
-
|
|
16123
|
+
mkdirSync16(outDir, { recursive: true });
|
|
15984
16124
|
if (options2.index !== void 0) {
|
|
15985
16125
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
15986
16126
|
console.error(
|
|
15987
|
-
|
|
16127
|
+
chalk151.red(`--index must be a positive integer (got ${options2.index})`)
|
|
15988
16128
|
);
|
|
15989
16129
|
process.exit(1);
|
|
15990
16130
|
}
|
|
15991
16131
|
if (!file) {
|
|
15992
|
-
console.error(
|
|
16132
|
+
console.error(chalk151.red("--index requires a file argument"));
|
|
15993
16133
|
process.exit(1);
|
|
15994
16134
|
}
|
|
15995
16135
|
}
|
|
15996
16136
|
const files = file ? [file] : readdirSync9(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
15997
16137
|
if (files.length === 0) {
|
|
15998
|
-
console.log(
|
|
16138
|
+
console.log(chalk151.gray("No markdown files found in current directory."));
|
|
15999
16139
|
return;
|
|
16000
16140
|
}
|
|
16001
16141
|
for (const f of files) {
|
|
@@ -16028,7 +16168,7 @@ function registerMermaid(program2) {
|
|
|
16028
16168
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
16029
16169
|
import { createServer as createServer2 } from "http";
|
|
16030
16170
|
import { dirname as dirname24 } from "path";
|
|
16031
|
-
import
|
|
16171
|
+
import chalk153 from "chalk";
|
|
16032
16172
|
|
|
16033
16173
|
// src/commands/netcap/corsHeaders.ts
|
|
16034
16174
|
var corsHeaders = {
|
|
@@ -16106,15 +16246,15 @@ function createNetcapHandler(options2) {
|
|
|
16106
16246
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
16107
16247
|
import { cp, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
16108
16248
|
import { networkInterfaces } from "os";
|
|
16109
|
-
import { join as
|
|
16110
|
-
import
|
|
16249
|
+
import { join as join45 } from "path";
|
|
16250
|
+
import chalk152 from "chalk";
|
|
16111
16251
|
|
|
16112
16252
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
16113
|
-
import { dirname as dirname23, join as
|
|
16253
|
+
import { dirname as dirname23, join as join44 } from "path";
|
|
16114
16254
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
16115
16255
|
var moduleDir = dirname23(fileURLToPath6(import.meta.url));
|
|
16116
16256
|
function netcapExtensionDir() {
|
|
16117
|
-
return
|
|
16257
|
+
return join44(moduleDir, "commands", "netcap", "netcap-extension");
|
|
16118
16258
|
}
|
|
16119
16259
|
|
|
16120
16260
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -16129,7 +16269,7 @@ function lanIPv4() {
|
|
|
16129
16269
|
return void 0;
|
|
16130
16270
|
}
|
|
16131
16271
|
async function configureBackground(dir, host, port, filter) {
|
|
16132
|
-
const file =
|
|
16272
|
+
const file = join45(dir, "background.js");
|
|
16133
16273
|
const source = await readFile2(file, "utf8");
|
|
16134
16274
|
await writeFile2(
|
|
16135
16275
|
file,
|
|
@@ -16151,7 +16291,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
16151
16291
|
const host = lanIPv4();
|
|
16152
16292
|
if (!host) {
|
|
16153
16293
|
console.log(
|
|
16154
|
-
|
|
16294
|
+
chalk152.yellow("could not determine the WSL IP for the extension")
|
|
16155
16295
|
);
|
|
16156
16296
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
16157
16297
|
return source;
|
|
@@ -16162,27 +16302,27 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
16162
16302
|
return WSL_WINDOWS_PATH;
|
|
16163
16303
|
} catch {
|
|
16164
16304
|
console.log(
|
|
16165
|
-
|
|
16305
|
+
chalk152.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
16166
16306
|
);
|
|
16167
16307
|
return source;
|
|
16168
16308
|
}
|
|
16169
16309
|
}
|
|
16170
16310
|
|
|
16171
16311
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
16172
|
-
import { isAbsolute, join as
|
|
16312
|
+
import { isAbsolute, join as join47, resolve as resolve12 } from "path";
|
|
16173
16313
|
|
|
16174
16314
|
// src/commands/netcap/defaultCapturePath.ts
|
|
16175
16315
|
import { homedir as homedir19 } from "os";
|
|
16176
|
-
import { join as
|
|
16316
|
+
import { join as join46 } from "path";
|
|
16177
16317
|
function defaultCapturePath() {
|
|
16178
|
-
return
|
|
16318
|
+
return join46(homedir19(), ".assist", "netcap", "capture.jsonl");
|
|
16179
16319
|
}
|
|
16180
16320
|
|
|
16181
16321
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
16182
16322
|
function resolveNetcapOutPath(out) {
|
|
16183
16323
|
if (!out) return defaultCapturePath();
|
|
16184
16324
|
const dir = isAbsolute(out) ? out : resolve12(process.cwd(), out);
|
|
16185
|
-
return
|
|
16325
|
+
return join47(dir, "capture.jsonl");
|
|
16186
16326
|
}
|
|
16187
16327
|
|
|
16188
16328
|
// src/commands/netcap/netcap.ts
|
|
@@ -16195,30 +16335,30 @@ async function netcap(options2) {
|
|
|
16195
16335
|
let count7 = 0;
|
|
16196
16336
|
const handler = createNetcapHandler({
|
|
16197
16337
|
outPath,
|
|
16198
|
-
onPing: () => console.log(
|
|
16338
|
+
onPing: () => console.log(chalk153.dim("ping from extension")),
|
|
16199
16339
|
onCapture: (entry) => {
|
|
16200
16340
|
count7 += 1;
|
|
16201
16341
|
console.log(
|
|
16202
|
-
|
|
16203
|
-
|
|
16342
|
+
chalk153.green(`captured #${count7}`),
|
|
16343
|
+
chalk153.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
16204
16344
|
);
|
|
16205
16345
|
}
|
|
16206
16346
|
});
|
|
16207
16347
|
const server = createServer2(handler);
|
|
16208
16348
|
server.listen(port, () => {
|
|
16209
16349
|
console.log(
|
|
16210
|
-
|
|
16350
|
+
chalk153.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
16211
16351
|
);
|
|
16212
|
-
console.log(
|
|
16352
|
+
console.log(chalk153.dim(`appending captures to ${outPath}`));
|
|
16213
16353
|
if (filter)
|
|
16214
|
-
console.log(
|
|
16215
|
-
console.log(
|
|
16216
|
-
console.log(
|
|
16354
|
+
console.log(chalk153.dim(`forwarding only URLs matching "${filter}"`));
|
|
16355
|
+
console.log(chalk153.dim(`load the unpacked extension from ${extensionPath}`));
|
|
16356
|
+
console.log(chalk153.dim("press Ctrl-C to stop"));
|
|
16217
16357
|
});
|
|
16218
16358
|
process.on("SIGINT", () => {
|
|
16219
16359
|
server.close();
|
|
16220
16360
|
console.log(
|
|
16221
|
-
|
|
16361
|
+
chalk153.bold(
|
|
16222
16362
|
`
|
|
16223
16363
|
netcap stopped \u2014 captured ${count7} ${count7 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
16224
16364
|
)
|
|
@@ -16228,12 +16368,12 @@ netcap stopped \u2014 captured ${count7} ${count7 === 1 ? "entry" : "entries"} t
|
|
|
16228
16368
|
}
|
|
16229
16369
|
|
|
16230
16370
|
// src/commands/netcap/netcapExtract.ts
|
|
16231
|
-
import { writeFileSync as
|
|
16232
|
-
import { join as
|
|
16233
|
-
import
|
|
16371
|
+
import { writeFileSync as writeFileSync32 } from "fs";
|
|
16372
|
+
import { join as join48 } from "path";
|
|
16373
|
+
import chalk154 from "chalk";
|
|
16234
16374
|
|
|
16235
16375
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
16236
|
-
import { readFileSync as
|
|
16376
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
16237
16377
|
|
|
16238
16378
|
// src/commands/netcap/parseRscRows.ts
|
|
16239
16379
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -16629,7 +16769,7 @@ function extractVoyagerPosts(body) {
|
|
|
16629
16769
|
|
|
16630
16770
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
16631
16771
|
function captureEntries(captureFile) {
|
|
16632
|
-
const lines =
|
|
16772
|
+
const lines = readFileSync37(captureFile, "utf8").split("\n").filter(Boolean);
|
|
16633
16773
|
const entries = [];
|
|
16634
16774
|
for (const line of lines) {
|
|
16635
16775
|
let entry;
|
|
@@ -16674,12 +16814,12 @@ function extractPostsFromCapture(captureFile) {
|
|
|
16674
16814
|
function netcapExtract(file) {
|
|
16675
16815
|
const captureFile = file ?? defaultCapturePath();
|
|
16676
16816
|
const posts = extractPostsFromCapture(captureFile);
|
|
16677
|
-
const outFile =
|
|
16678
|
-
|
|
16817
|
+
const outFile = join48(captureFile, "..", "posts.json");
|
|
16818
|
+
writeFileSync32(outFile, `${JSON.stringify(posts, null, 2)}
|
|
16679
16819
|
`);
|
|
16680
16820
|
console.log(
|
|
16681
|
-
|
|
16682
|
-
|
|
16821
|
+
chalk154.green(`extracted ${posts.length} posts`),
|
|
16822
|
+
chalk154.dim(`-> ${outFile}`)
|
|
16683
16823
|
);
|
|
16684
16824
|
}
|
|
16685
16825
|
|
|
@@ -16700,7 +16840,7 @@ function registerNetcap(program2) {
|
|
|
16700
16840
|
}
|
|
16701
16841
|
|
|
16702
16842
|
// src/commands/news/add/index.ts
|
|
16703
|
-
import
|
|
16843
|
+
import chalk155 from "chalk";
|
|
16704
16844
|
import enquirer8 from "enquirer";
|
|
16705
16845
|
async function add2(url) {
|
|
16706
16846
|
if (!url) {
|
|
@@ -16722,10 +16862,10 @@ async function add2(url) {
|
|
|
16722
16862
|
const { orm } = await getReady();
|
|
16723
16863
|
const added = await addFeed(orm, url);
|
|
16724
16864
|
if (!added) {
|
|
16725
|
-
console.log(
|
|
16865
|
+
console.log(chalk155.yellow("Feed already exists"));
|
|
16726
16866
|
return;
|
|
16727
16867
|
}
|
|
16728
|
-
console.log(
|
|
16868
|
+
console.log(chalk155.green(`Added feed: ${url}`));
|
|
16729
16869
|
}
|
|
16730
16870
|
|
|
16731
16871
|
// src/commands/registerNews.ts
|
|
@@ -16772,7 +16912,7 @@ function registerPiHook(program2) {
|
|
|
16772
16912
|
}
|
|
16773
16913
|
|
|
16774
16914
|
// src/commands/prompts/printPromptsTable.ts
|
|
16775
|
-
import
|
|
16915
|
+
import chalk156 from "chalk";
|
|
16776
16916
|
function truncate(str, max) {
|
|
16777
16917
|
if (str.length <= max) return str;
|
|
16778
16918
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -16790,14 +16930,14 @@ function printPromptsTable(rows) {
|
|
|
16790
16930
|
"Command".padEnd(commandWidth),
|
|
16791
16931
|
"Repos"
|
|
16792
16932
|
].join(" ");
|
|
16793
|
-
console.log(
|
|
16794
|
-
console.log(
|
|
16933
|
+
console.log(chalk156.dim(header));
|
|
16934
|
+
console.log(chalk156.dim("-".repeat(header.length)));
|
|
16795
16935
|
for (const row of rows) {
|
|
16796
16936
|
const count7 = String(row.count).padStart(countWidth);
|
|
16797
16937
|
const tool = row.tool.padEnd(toolWidth);
|
|
16798
16938
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
16799
16939
|
console.log(
|
|
16800
|
-
`${
|
|
16940
|
+
`${chalk156.yellow(count7)} ${tool} ${command} ${chalk156.dim(row.repos)}`
|
|
16801
16941
|
);
|
|
16802
16942
|
}
|
|
16803
16943
|
}
|
|
@@ -17163,29 +17303,29 @@ import { execSync as execSync42 } from "child_process";
|
|
|
17163
17303
|
|
|
17164
17304
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
17165
17305
|
import { execSync as execSync41 } from "child_process";
|
|
17166
|
-
import { unlinkSync as
|
|
17306
|
+
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
17167
17307
|
import { tmpdir as tmpdir5 } from "os";
|
|
17168
|
-
import { join as
|
|
17308
|
+
import { join as join50 } from "path";
|
|
17169
17309
|
|
|
17170
17310
|
// src/commands/prs/loadCommentsCache.ts
|
|
17171
|
-
import { existsSync as
|
|
17172
|
-
import { join as
|
|
17311
|
+
import { existsSync as existsSync41, readFileSync as readFileSync38, unlinkSync as unlinkSync13 } from "fs";
|
|
17312
|
+
import { join as join49 } from "path";
|
|
17173
17313
|
import { parse as parse2 } from "yaml";
|
|
17174
17314
|
function getCachePath(prNumber) {
|
|
17175
|
-
return
|
|
17315
|
+
return join49(process.cwd(), ".assist", `pr-${prNumber}-comments.yaml`);
|
|
17176
17316
|
}
|
|
17177
17317
|
function loadCommentsCache(prNumber) {
|
|
17178
17318
|
const cachePath = getCachePath(prNumber);
|
|
17179
|
-
if (!
|
|
17319
|
+
if (!existsSync41(cachePath)) {
|
|
17180
17320
|
return null;
|
|
17181
17321
|
}
|
|
17182
|
-
const content =
|
|
17322
|
+
const content = readFileSync38(cachePath, "utf8");
|
|
17183
17323
|
return parse2(content);
|
|
17184
17324
|
}
|
|
17185
17325
|
function deleteCommentsCache(prNumber) {
|
|
17186
17326
|
const cachePath = getCachePath(prNumber);
|
|
17187
|
-
if (
|
|
17188
|
-
|
|
17327
|
+
if (existsSync41(cachePath)) {
|
|
17328
|
+
unlinkSync13(cachePath);
|
|
17189
17329
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
17190
17330
|
}
|
|
17191
17331
|
}
|
|
@@ -17202,15 +17342,15 @@ function replyToComment(org, repo, prNumber, commentId, message) {
|
|
|
17202
17342
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
17203
17343
|
function resolveThread(threadId) {
|
|
17204
17344
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
17205
|
-
const queryFile =
|
|
17206
|
-
|
|
17345
|
+
const queryFile = join50(tmpdir5(), `gh-mutation-${Date.now()}.graphql`);
|
|
17346
|
+
writeFileSync33(queryFile, mutation);
|
|
17207
17347
|
try {
|
|
17208
17348
|
execSync41(
|
|
17209
17349
|
`gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
|
|
17210
17350
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
17211
17351
|
);
|
|
17212
17352
|
} finally {
|
|
17213
|
-
|
|
17353
|
+
unlinkSync14(queryFile);
|
|
17214
17354
|
}
|
|
17215
17355
|
}
|
|
17216
17356
|
function requireCache(prNumber) {
|
|
@@ -17284,19 +17424,19 @@ function fixed(commentId, sha) {
|
|
|
17284
17424
|
}
|
|
17285
17425
|
|
|
17286
17426
|
// src/commands/prs/listComments/index.ts
|
|
17287
|
-
import { existsSync as
|
|
17288
|
-
import { join as
|
|
17427
|
+
import { existsSync as existsSync42, mkdirSync as mkdirSync17, writeFileSync as writeFileSync35 } from "fs";
|
|
17428
|
+
import { join as join52 } from "path";
|
|
17289
17429
|
import { stringify } from "yaml";
|
|
17290
17430
|
|
|
17291
17431
|
// src/commands/prs/fetchThreadIds.ts
|
|
17292
17432
|
import { execSync as execSync43 } from "child_process";
|
|
17293
|
-
import { unlinkSync as
|
|
17433
|
+
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync34 } from "fs";
|
|
17294
17434
|
import { tmpdir as tmpdir6 } from "os";
|
|
17295
|
-
import { join as
|
|
17435
|
+
import { join as join51 } from "path";
|
|
17296
17436
|
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 } } } } } } }`;
|
|
17297
17437
|
function fetchThreadIds(org, repo, prNumber) {
|
|
17298
|
-
const queryFile =
|
|
17299
|
-
|
|
17438
|
+
const queryFile = join51(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
17439
|
+
writeFileSync34(queryFile, THREAD_QUERY);
|
|
17300
17440
|
try {
|
|
17301
17441
|
const result = execSync43(
|
|
17302
17442
|
`gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
|
|
@@ -17315,7 +17455,7 @@ function fetchThreadIds(org, repo, prNumber) {
|
|
|
17315
17455
|
}
|
|
17316
17456
|
return { threadMap, resolvedThreadIds };
|
|
17317
17457
|
} finally {
|
|
17318
|
-
|
|
17458
|
+
unlinkSync15(queryFile);
|
|
17319
17459
|
}
|
|
17320
17460
|
}
|
|
17321
17461
|
|
|
@@ -17364,20 +17504,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
17364
17504
|
}
|
|
17365
17505
|
|
|
17366
17506
|
// src/commands/prs/listComments/printComments.ts
|
|
17367
|
-
import
|
|
17507
|
+
import chalk157 from "chalk";
|
|
17368
17508
|
function formatForHuman(comment3) {
|
|
17369
17509
|
if (comment3.type === "review") {
|
|
17370
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
17510
|
+
const stateColor = comment3.state === "APPROVED" ? chalk157.green : comment3.state === "CHANGES_REQUESTED" ? chalk157.red : chalk157.yellow;
|
|
17371
17511
|
return [
|
|
17372
|
-
`${
|
|
17512
|
+
`${chalk157.cyan("Review")} by ${chalk157.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
17373
17513
|
comment3.body,
|
|
17374
17514
|
""
|
|
17375
17515
|
].join("\n");
|
|
17376
17516
|
}
|
|
17377
17517
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
17378
17518
|
return [
|
|
17379
|
-
`${
|
|
17380
|
-
|
|
17519
|
+
`${chalk157.cyan("Line comment")} by ${chalk157.bold(comment3.user)} on ${chalk157.dim(`${comment3.path}${location}`)}`,
|
|
17520
|
+
chalk157.dim(comment3.diff_hunk.split("\n").slice(-3).join("\n")),
|
|
17381
17521
|
comment3.body,
|
|
17382
17522
|
""
|
|
17383
17523
|
].join("\n");
|
|
@@ -17409,17 +17549,17 @@ function printComments2(result) {
|
|
|
17409
17549
|
|
|
17410
17550
|
// src/commands/prs/listComments/index.ts
|
|
17411
17551
|
function writeCommentsCache(prNumber, comments3) {
|
|
17412
|
-
const assistDir =
|
|
17413
|
-
if (!
|
|
17414
|
-
|
|
17552
|
+
const assistDir = join52(process.cwd(), ".assist");
|
|
17553
|
+
if (!existsSync42(assistDir)) {
|
|
17554
|
+
mkdirSync17(assistDir, { recursive: true });
|
|
17415
17555
|
}
|
|
17416
17556
|
const cacheData = {
|
|
17417
17557
|
prNumber,
|
|
17418
17558
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17419
17559
|
comments: comments3
|
|
17420
17560
|
};
|
|
17421
|
-
const cachePath =
|
|
17422
|
-
|
|
17561
|
+
const cachePath = join52(assistDir, `pr-${prNumber}-comments.yaml`);
|
|
17562
|
+
writeFileSync35(cachePath, stringify(cacheData));
|
|
17423
17563
|
}
|
|
17424
17564
|
function handleKnownErrors(error) {
|
|
17425
17565
|
if (isGhNotInstalled(error)) {
|
|
@@ -17451,7 +17591,7 @@ async function listComments() {
|
|
|
17451
17591
|
];
|
|
17452
17592
|
updateCache(prNumber, allComments);
|
|
17453
17593
|
const hasLineComments = allComments.some((c) => c.type === "line");
|
|
17454
|
-
const cachePath = hasLineComments ?
|
|
17594
|
+
const cachePath = hasLineComments ? join52(process.cwd(), ".assist", `pr-${prNumber}-comments.yaml`) : null;
|
|
17455
17595
|
return { comments: allComments, cachePath };
|
|
17456
17596
|
} catch (error) {
|
|
17457
17597
|
const handled = handleKnownErrors(error);
|
|
@@ -17467,13 +17607,13 @@ import { execSync as execSync45 } from "child_process";
|
|
|
17467
17607
|
import enquirer9 from "enquirer";
|
|
17468
17608
|
|
|
17469
17609
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
17470
|
-
import
|
|
17610
|
+
import chalk158 from "chalk";
|
|
17471
17611
|
var STATUS_MAP = {
|
|
17472
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
17473
|
-
CLOSED: (pr) => pr.closedAt ? { label:
|
|
17612
|
+
MERGED: (pr) => pr.mergedAt ? { label: chalk158.magenta("merged"), date: pr.mergedAt } : null,
|
|
17613
|
+
CLOSED: (pr) => pr.closedAt ? { label: chalk158.red("closed"), date: pr.closedAt } : null
|
|
17474
17614
|
};
|
|
17475
17615
|
function defaultStatus(pr) {
|
|
17476
|
-
return { label:
|
|
17616
|
+
return { label: chalk158.green("opened"), date: pr.createdAt };
|
|
17477
17617
|
}
|
|
17478
17618
|
function getStatus2(pr) {
|
|
17479
17619
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -17482,11 +17622,11 @@ function formatDate(dateStr) {
|
|
|
17482
17622
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
17483
17623
|
}
|
|
17484
17624
|
function formatPrHeader(pr, status3) {
|
|
17485
|
-
return `${
|
|
17625
|
+
return `${chalk158.cyan(`#${pr.number}`)} ${pr.title} ${chalk158.dim(`(${pr.author.login},`)} ${status3.label} ${chalk158.dim(`${formatDate(status3.date)})`)}`;
|
|
17486
17626
|
}
|
|
17487
17627
|
function logPrDetails(pr) {
|
|
17488
17628
|
console.log(
|
|
17489
|
-
|
|
17629
|
+
chalk158.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
17490
17630
|
);
|
|
17491
17631
|
console.log();
|
|
17492
17632
|
}
|
|
@@ -17835,10 +17975,10 @@ function registerPrs(program2) {
|
|
|
17835
17975
|
}
|
|
17836
17976
|
|
|
17837
17977
|
// src/commands/ravendb/ravendbAuth.ts
|
|
17838
|
-
import
|
|
17978
|
+
import chalk164 from "chalk";
|
|
17839
17979
|
|
|
17840
17980
|
// src/shared/createConnectionAuth.ts
|
|
17841
|
-
import
|
|
17981
|
+
import chalk159 from "chalk";
|
|
17842
17982
|
function listConnections(connections, format) {
|
|
17843
17983
|
if (connections.length === 0) {
|
|
17844
17984
|
console.log("No connections configured.");
|
|
@@ -17851,7 +17991,7 @@ function listConnections(connections, format) {
|
|
|
17851
17991
|
function removeConnection(connections, name, save) {
|
|
17852
17992
|
const filtered = connections.filter((c) => c.name !== name);
|
|
17853
17993
|
if (filtered.length === connections.length) {
|
|
17854
|
-
console.error(
|
|
17994
|
+
console.error(chalk159.red(`Connection "${name}" not found.`));
|
|
17855
17995
|
process.exit(1);
|
|
17856
17996
|
}
|
|
17857
17997
|
save(filtered);
|
|
@@ -17897,15 +18037,15 @@ function saveConnections(connections) {
|
|
|
17897
18037
|
}
|
|
17898
18038
|
|
|
17899
18039
|
// src/commands/ravendb/promptConnection.ts
|
|
17900
|
-
import
|
|
18040
|
+
import chalk162 from "chalk";
|
|
17901
18041
|
|
|
17902
18042
|
// src/commands/ravendb/selectOpSecret.ts
|
|
17903
|
-
import
|
|
18043
|
+
import chalk161 from "chalk";
|
|
17904
18044
|
import Enquirer2 from "enquirer";
|
|
17905
18045
|
|
|
17906
18046
|
// src/commands/ravendb/searchItems.ts
|
|
17907
18047
|
import { execSync as execSync48 } from "child_process";
|
|
17908
|
-
import
|
|
18048
|
+
import chalk160 from "chalk";
|
|
17909
18049
|
function opExec(args) {
|
|
17910
18050
|
return execSync48(`op ${args}`, {
|
|
17911
18051
|
encoding: "utf8",
|
|
@@ -17918,7 +18058,7 @@ function searchItems(search2) {
|
|
|
17918
18058
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
17919
18059
|
} catch {
|
|
17920
18060
|
console.error(
|
|
17921
|
-
|
|
18061
|
+
chalk160.red(
|
|
17922
18062
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
17923
18063
|
)
|
|
17924
18064
|
);
|
|
@@ -17932,7 +18072,7 @@ function getItemFields(itemId2) {
|
|
|
17932
18072
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
17933
18073
|
return item.fields.filter((f) => f.reference && f.label);
|
|
17934
18074
|
} catch {
|
|
17935
|
-
console.error(
|
|
18075
|
+
console.error(chalk160.red("Failed to get item details from 1Password."));
|
|
17936
18076
|
process.exit(1);
|
|
17937
18077
|
}
|
|
17938
18078
|
}
|
|
@@ -17951,7 +18091,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
17951
18091
|
}).run();
|
|
17952
18092
|
const items2 = searchItems(search2);
|
|
17953
18093
|
if (items2.length === 0) {
|
|
17954
|
-
console.error(
|
|
18094
|
+
console.error(chalk161.red(`No items found matching "${search2}".`));
|
|
17955
18095
|
process.exit(1);
|
|
17956
18096
|
}
|
|
17957
18097
|
const itemId2 = await selectOne(
|
|
@@ -17960,7 +18100,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
17960
18100
|
);
|
|
17961
18101
|
const fields = getItemFields(itemId2);
|
|
17962
18102
|
if (fields.length === 0) {
|
|
17963
|
-
console.error(
|
|
18103
|
+
console.error(chalk161.red("No fields with references found on this item."));
|
|
17964
18104
|
process.exit(1);
|
|
17965
18105
|
}
|
|
17966
18106
|
const ref = await selectOne(
|
|
@@ -17974,7 +18114,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
17974
18114
|
async function promptConnection(existingNames) {
|
|
17975
18115
|
const name = await promptInput("name", "Connection name:");
|
|
17976
18116
|
if (existingNames.includes(name)) {
|
|
17977
|
-
console.error(
|
|
18117
|
+
console.error(chalk162.red(`Connection "${name}" already exists.`));
|
|
17978
18118
|
process.exit(1);
|
|
17979
18119
|
}
|
|
17980
18120
|
const url = await promptInput(
|
|
@@ -17983,22 +18123,22 @@ async function promptConnection(existingNames) {
|
|
|
17983
18123
|
);
|
|
17984
18124
|
const database = await promptInput("database", "Database name:");
|
|
17985
18125
|
if (!name || !url || !database) {
|
|
17986
|
-
console.error(
|
|
18126
|
+
console.error(chalk162.red("All fields are required."));
|
|
17987
18127
|
process.exit(1);
|
|
17988
18128
|
}
|
|
17989
18129
|
const apiKeyRef = await selectOpSecret();
|
|
17990
|
-
console.log(
|
|
18130
|
+
console.log(chalk162.dim(`Using: ${apiKeyRef}`));
|
|
17991
18131
|
return { name, url, database, apiKeyRef };
|
|
17992
18132
|
}
|
|
17993
18133
|
|
|
17994
18134
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
17995
|
-
import
|
|
18135
|
+
import chalk163 from "chalk";
|
|
17996
18136
|
function ravendbSetConnection(name) {
|
|
17997
18137
|
const raw = loadGlobalConfigRaw();
|
|
17998
18138
|
const ravendb = raw.ravendb ?? {};
|
|
17999
18139
|
const connections = ravendb.connections ?? [];
|
|
18000
18140
|
if (!connections.some((c) => c.name === name)) {
|
|
18001
|
-
console.error(
|
|
18141
|
+
console.error(chalk163.red(`Connection "${name}" not found.`));
|
|
18002
18142
|
console.error(
|
|
18003
18143
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
18004
18144
|
);
|
|
@@ -18014,16 +18154,16 @@ function ravendbSetConnection(name) {
|
|
|
18014
18154
|
var ravendbAuth = createConnectionAuth({
|
|
18015
18155
|
load: loadConnections,
|
|
18016
18156
|
save: saveConnections,
|
|
18017
|
-
format: (c) => `${
|
|
18157
|
+
format: (c) => `${chalk164.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
18018
18158
|
promptNew: promptConnection,
|
|
18019
18159
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
18020
18160
|
});
|
|
18021
18161
|
|
|
18022
18162
|
// src/commands/ravendb/ravendbCollections.ts
|
|
18023
|
-
import
|
|
18163
|
+
import chalk168 from "chalk";
|
|
18024
18164
|
|
|
18025
18165
|
// src/commands/ravendb/ravenFetch.ts
|
|
18026
|
-
import
|
|
18166
|
+
import chalk166 from "chalk";
|
|
18027
18167
|
|
|
18028
18168
|
// src/commands/ravendb/getAccessToken.ts
|
|
18029
18169
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -18060,10 +18200,10 @@ ${errorText}`
|
|
|
18060
18200
|
|
|
18061
18201
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
18062
18202
|
import { execSync as execSync49 } from "child_process";
|
|
18063
|
-
import
|
|
18203
|
+
import chalk165 from "chalk";
|
|
18064
18204
|
function resolveOpSecret(reference) {
|
|
18065
18205
|
if (!reference.startsWith("op://")) {
|
|
18066
|
-
console.error(
|
|
18206
|
+
console.error(chalk165.red(`Invalid secret reference: must start with op://`));
|
|
18067
18207
|
process.exit(1);
|
|
18068
18208
|
}
|
|
18069
18209
|
try {
|
|
@@ -18073,7 +18213,7 @@ function resolveOpSecret(reference) {
|
|
|
18073
18213
|
}).trim();
|
|
18074
18214
|
} catch {
|
|
18075
18215
|
console.error(
|
|
18076
|
-
|
|
18216
|
+
chalk165.red(
|
|
18077
18217
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
18078
18218
|
)
|
|
18079
18219
|
);
|
|
@@ -18100,7 +18240,7 @@ async function ravenFetch(connection, path67) {
|
|
|
18100
18240
|
if (!response.ok) {
|
|
18101
18241
|
const body = await response.text();
|
|
18102
18242
|
console.error(
|
|
18103
|
-
|
|
18243
|
+
chalk166.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
18104
18244
|
);
|
|
18105
18245
|
console.error(body.substring(0, 500));
|
|
18106
18246
|
process.exit(1);
|
|
@@ -18109,7 +18249,7 @@ async function ravenFetch(connection, path67) {
|
|
|
18109
18249
|
}
|
|
18110
18250
|
|
|
18111
18251
|
// src/commands/ravendb/resolveConnection.ts
|
|
18112
|
-
import
|
|
18252
|
+
import chalk167 from "chalk";
|
|
18113
18253
|
function loadRavendb() {
|
|
18114
18254
|
const raw = loadGlobalConfigRaw();
|
|
18115
18255
|
const ravendb = raw.ravendb;
|
|
@@ -18123,7 +18263,7 @@ function resolveConnection(name) {
|
|
|
18123
18263
|
const connectionName = name ?? defaultConnection;
|
|
18124
18264
|
if (!connectionName) {
|
|
18125
18265
|
console.error(
|
|
18126
|
-
|
|
18266
|
+
chalk167.red(
|
|
18127
18267
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
18128
18268
|
)
|
|
18129
18269
|
);
|
|
@@ -18131,7 +18271,7 @@ function resolveConnection(name) {
|
|
|
18131
18271
|
}
|
|
18132
18272
|
const connection = connections.find((c) => c.name === connectionName);
|
|
18133
18273
|
if (!connection) {
|
|
18134
|
-
console.error(
|
|
18274
|
+
console.error(chalk167.red(`Connection "${connectionName}" not found.`));
|
|
18135
18275
|
console.error(
|
|
18136
18276
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
18137
18277
|
);
|
|
@@ -18162,7 +18302,7 @@ async function ravendbCollections(connectionName) {
|
|
|
18162
18302
|
return;
|
|
18163
18303
|
}
|
|
18164
18304
|
for (const c of collections) {
|
|
18165
|
-
console.log(`${
|
|
18305
|
+
console.log(`${chalk168.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
18166
18306
|
}
|
|
18167
18307
|
}
|
|
18168
18308
|
|
|
@@ -18181,10 +18321,10 @@ var ravendbConfigHelp = [
|
|
|
18181
18321
|
];
|
|
18182
18322
|
|
|
18183
18323
|
// src/commands/ravendb/ravendbQuery.ts
|
|
18184
|
-
import
|
|
18324
|
+
import chalk170 from "chalk";
|
|
18185
18325
|
|
|
18186
18326
|
// src/commands/ravendb/fetchAllPages.ts
|
|
18187
|
-
import
|
|
18327
|
+
import chalk169 from "chalk";
|
|
18188
18328
|
|
|
18189
18329
|
// src/commands/ravendb/buildQueryPath.ts
|
|
18190
18330
|
function buildQueryPath(opts) {
|
|
@@ -18222,7 +18362,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18222
18362
|
allResults.push(...results);
|
|
18223
18363
|
start3 += results.length;
|
|
18224
18364
|
process.stderr.write(
|
|
18225
|
-
`\r${
|
|
18365
|
+
`\r${chalk169.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
18226
18366
|
);
|
|
18227
18367
|
if (start3 >= totalResults) break;
|
|
18228
18368
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -18237,7 +18377,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18237
18377
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
18238
18378
|
const resolved = resolveArgs(connectionName, collection);
|
|
18239
18379
|
if (!resolved.collection && !options2.query) {
|
|
18240
|
-
console.error(
|
|
18380
|
+
console.error(chalk170.red("Provide a collection name or --query filter."));
|
|
18241
18381
|
process.exit(1);
|
|
18242
18382
|
}
|
|
18243
18383
|
const { collection: col } = resolved;
|
|
@@ -18276,7 +18416,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
18276
18416
|
import * as path34 from "path";
|
|
18277
18417
|
|
|
18278
18418
|
// src/commands/refactor/logViolations.ts
|
|
18279
|
-
import
|
|
18419
|
+
import chalk171 from "chalk";
|
|
18280
18420
|
var DEFAULT_MAX_LINES = 100;
|
|
18281
18421
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
18282
18422
|
if (violations.length === 0) {
|
|
@@ -18285,43 +18425,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
18285
18425
|
}
|
|
18286
18426
|
return;
|
|
18287
18427
|
}
|
|
18288
|
-
console.error(
|
|
18428
|
+
console.error(chalk171.red(`
|
|
18289
18429
|
Refactor check failed:
|
|
18290
18430
|
`));
|
|
18291
|
-
console.error(
|
|
18431
|
+
console.error(chalk171.red(` The following files exceed ${maxLines} lines:
|
|
18292
18432
|
`));
|
|
18293
18433
|
for (const violation of violations) {
|
|
18294
|
-
console.error(
|
|
18434
|
+
console.error(chalk171.red(` ${violation.file} (${violation.lines} lines)`));
|
|
18295
18435
|
}
|
|
18296
18436
|
console.error(
|
|
18297
|
-
|
|
18437
|
+
chalk171.yellow(
|
|
18298
18438
|
`
|
|
18299
18439
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
18300
18440
|
way to refactor it, ignore it with:
|
|
18301
18441
|
`
|
|
18302
18442
|
)
|
|
18303
18443
|
);
|
|
18304
|
-
console.error(
|
|
18444
|
+
console.error(chalk171.gray(` assist refactor ignore <file>
|
|
18305
18445
|
`));
|
|
18306
18446
|
if (process.env.CLAUDECODE) {
|
|
18307
|
-
console.error(
|
|
18447
|
+
console.error(chalk171.cyan(`
|
|
18308
18448
|
## Extracting Code to New Files
|
|
18309
18449
|
`));
|
|
18310
18450
|
console.error(
|
|
18311
|
-
|
|
18451
|
+
chalk171.cyan(
|
|
18312
18452
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
18313
18453
|
`
|
|
18314
18454
|
)
|
|
18315
18455
|
);
|
|
18316
18456
|
console.error(
|
|
18317
|
-
|
|
18457
|
+
chalk171.cyan(
|
|
18318
18458
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
18319
18459
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
18320
18460
|
`
|
|
18321
18461
|
)
|
|
18322
18462
|
);
|
|
18323
18463
|
console.error(
|
|
18324
|
-
|
|
18464
|
+
chalk171.cyan(
|
|
18325
18465
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
18326
18466
|
domains, move it to a common/shared folder.
|
|
18327
18467
|
`
|
|
@@ -18477,7 +18617,7 @@ async function check(pattern2, options2) {
|
|
|
18477
18617
|
|
|
18478
18618
|
// src/commands/refactor/extract/index.ts
|
|
18479
18619
|
import path41 from "path";
|
|
18480
|
-
import
|
|
18620
|
+
import chalk174 from "chalk";
|
|
18481
18621
|
|
|
18482
18622
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
18483
18623
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -19076,23 +19216,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
19076
19216
|
|
|
19077
19217
|
// src/commands/refactor/extract/displayPlan.ts
|
|
19078
19218
|
import path38 from "path";
|
|
19079
|
-
import
|
|
19219
|
+
import chalk172 from "chalk";
|
|
19080
19220
|
function section2(title) {
|
|
19081
19221
|
return `
|
|
19082
|
-
${
|
|
19222
|
+
${chalk172.cyan(title)}`;
|
|
19083
19223
|
}
|
|
19084
19224
|
function displayImporters(plan2, cwd) {
|
|
19085
19225
|
if (plan2.importersToUpdate.length === 0) return;
|
|
19086
19226
|
console.log(section2("Update importers:"));
|
|
19087
19227
|
for (const imp of plan2.importersToUpdate) {
|
|
19088
19228
|
const rel = path38.relative(cwd, imp.file.getFilePath());
|
|
19089
|
-
console.log(` ${
|
|
19229
|
+
console.log(` ${chalk172.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
19090
19230
|
}
|
|
19091
19231
|
}
|
|
19092
19232
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
19093
|
-
console.log(
|
|
19233
|
+
console.log(chalk172.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
19094
19234
|
`));
|
|
19095
|
-
console.log(` ${
|
|
19235
|
+
console.log(` ${chalk172.cyan("Functions to move:")}`);
|
|
19096
19236
|
for (const name of plan2.extractedNames) {
|
|
19097
19237
|
console.log(` ${name}`);
|
|
19098
19238
|
}
|
|
@@ -19126,7 +19266,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
19126
19266
|
|
|
19127
19267
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
19128
19268
|
import path40 from "path";
|
|
19129
|
-
import
|
|
19269
|
+
import chalk173 from "chalk";
|
|
19130
19270
|
import { Project as Project4 } from "ts-morph";
|
|
19131
19271
|
|
|
19132
19272
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -19186,7 +19326,7 @@ function loadProjectFile(file) {
|
|
|
19186
19326
|
});
|
|
19187
19327
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
19188
19328
|
if (!sourceFile) {
|
|
19189
|
-
console.log(
|
|
19329
|
+
console.log(chalk173.red(`File not found in project: ${file}`));
|
|
19190
19330
|
process.exit(1);
|
|
19191
19331
|
}
|
|
19192
19332
|
return { project, sourceFile };
|
|
@@ -19209,19 +19349,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
19209
19349
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
19210
19350
|
if (options2.apply) {
|
|
19211
19351
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
19212
|
-
console.log(
|
|
19352
|
+
console.log(chalk174.green("\nExtraction complete"));
|
|
19213
19353
|
} else {
|
|
19214
|
-
console.log(
|
|
19354
|
+
console.log(chalk174.dim("\nDry run. Use --apply to execute."));
|
|
19215
19355
|
}
|
|
19216
19356
|
}
|
|
19217
19357
|
|
|
19218
19358
|
// src/commands/refactor/ignore.ts
|
|
19219
19359
|
import fs27 from "fs";
|
|
19220
|
-
import
|
|
19360
|
+
import chalk175 from "chalk";
|
|
19221
19361
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
19222
19362
|
function ignore2(file) {
|
|
19223
19363
|
if (!fs27.existsSync(file)) {
|
|
19224
|
-
console.error(
|
|
19364
|
+
console.error(chalk175.red(`Error: File does not exist: ${file}`));
|
|
19225
19365
|
process.exit(1);
|
|
19226
19366
|
}
|
|
19227
19367
|
const content = fs27.readFileSync(file, "utf8");
|
|
@@ -19237,7 +19377,7 @@ function ignore2(file) {
|
|
|
19237
19377
|
fs27.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
19238
19378
|
}
|
|
19239
19379
|
console.log(
|
|
19240
|
-
|
|
19380
|
+
chalk175.green(
|
|
19241
19381
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
19242
19382
|
)
|
|
19243
19383
|
);
|
|
@@ -19246,12 +19386,12 @@ function ignore2(file) {
|
|
|
19246
19386
|
// src/commands/refactor/rename/index.ts
|
|
19247
19387
|
import fs30 from "fs";
|
|
19248
19388
|
import path46 from "path";
|
|
19249
|
-
import
|
|
19389
|
+
import chalk178 from "chalk";
|
|
19250
19390
|
|
|
19251
19391
|
// src/commands/refactor/rename/applyRename.ts
|
|
19252
19392
|
import fs29 from "fs";
|
|
19253
19393
|
import path43 from "path";
|
|
19254
|
-
import
|
|
19394
|
+
import chalk176 from "chalk";
|
|
19255
19395
|
|
|
19256
19396
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
19257
19397
|
import path42 from "path";
|
|
@@ -19356,13 +19496,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
19356
19496
|
const updatedContents = applyRewrites(rewrites);
|
|
19357
19497
|
for (const [file, content] of updatedContents) {
|
|
19358
19498
|
fs29.writeFileSync(file, content, "utf8");
|
|
19359
|
-
console.log(
|
|
19499
|
+
console.log(chalk176.cyan(` Updated imports in ${path43.relative(cwd, file)}`));
|
|
19360
19500
|
}
|
|
19361
19501
|
const destDir = path43.dirname(destPath);
|
|
19362
19502
|
if (!fs29.existsSync(destDir)) fs29.mkdirSync(destDir, { recursive: true });
|
|
19363
19503
|
fs29.renameSync(sourcePath, destPath);
|
|
19364
19504
|
console.log(
|
|
19365
|
-
|
|
19505
|
+
chalk176.white(
|
|
19366
19506
|
` Moved ${path43.relative(cwd, sourcePath)} \u2192 ${path43.relative(cwd, destPath)}`
|
|
19367
19507
|
)
|
|
19368
19508
|
);
|
|
@@ -19449,16 +19589,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
19449
19589
|
|
|
19450
19590
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
19451
19591
|
import path45 from "path";
|
|
19452
|
-
import
|
|
19592
|
+
import chalk177 from "chalk";
|
|
19453
19593
|
function printRenamePreview(rewrites, cwd) {
|
|
19454
19594
|
for (const rewrite of rewrites) {
|
|
19455
19595
|
console.log(
|
|
19456
|
-
|
|
19596
|
+
chalk177.dim(
|
|
19457
19597
|
` ${path45.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
19458
19598
|
)
|
|
19459
19599
|
);
|
|
19460
19600
|
}
|
|
19461
|
-
console.log(
|
|
19601
|
+
console.log(chalk177.dim("Dry run. Use --apply to execute."));
|
|
19462
19602
|
}
|
|
19463
19603
|
|
|
19464
19604
|
// src/commands/refactor/rename/index.ts
|
|
@@ -19469,20 +19609,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
19469
19609
|
const relSource = path46.relative(cwd, sourcePath);
|
|
19470
19610
|
const relDest = path46.relative(cwd, destPath);
|
|
19471
19611
|
if (!fs30.existsSync(sourcePath)) {
|
|
19472
|
-
console.log(
|
|
19612
|
+
console.log(chalk178.red(`File not found: ${source}`));
|
|
19473
19613
|
process.exit(1);
|
|
19474
19614
|
}
|
|
19475
19615
|
if (destPath !== sourcePath && fs30.existsSync(destPath)) {
|
|
19476
|
-
console.log(
|
|
19616
|
+
console.log(chalk178.red(`Destination already exists: ${destination}`));
|
|
19477
19617
|
process.exit(1);
|
|
19478
19618
|
}
|
|
19479
|
-
console.log(
|
|
19480
|
-
console.log(
|
|
19481
|
-
console.log(
|
|
19619
|
+
console.log(chalk178.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
19620
|
+
console.log(chalk178.dim("Loading project..."));
|
|
19621
|
+
console.log(chalk178.dim("Scanning imports across the project..."));
|
|
19482
19622
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
19483
19623
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
19484
19624
|
console.log(
|
|
19485
|
-
|
|
19625
|
+
chalk178.dim(
|
|
19486
19626
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
19487
19627
|
)
|
|
19488
19628
|
);
|
|
@@ -19491,11 +19631,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
19491
19631
|
return;
|
|
19492
19632
|
}
|
|
19493
19633
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
19494
|
-
console.log(
|
|
19634
|
+
console.log(chalk178.green("Done"));
|
|
19495
19635
|
}
|
|
19496
19636
|
|
|
19497
19637
|
// src/commands/refactor/renameSymbol/index.ts
|
|
19498
|
-
import
|
|
19638
|
+
import chalk179 from "chalk";
|
|
19499
19639
|
|
|
19500
19640
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
19501
19641
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -19541,33 +19681,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
19541
19681
|
const { project, sourceFile } = loadProjectFile(file);
|
|
19542
19682
|
const symbol = findSymbol(sourceFile, oldName);
|
|
19543
19683
|
if (!symbol) {
|
|
19544
|
-
console.log(
|
|
19684
|
+
console.log(chalk179.red(`Symbol "${oldName}" not found in ${file}`));
|
|
19545
19685
|
process.exit(1);
|
|
19546
19686
|
}
|
|
19547
19687
|
const grouped = groupReferences(symbol, cwd);
|
|
19548
19688
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
19549
19689
|
console.log(
|
|
19550
|
-
|
|
19690
|
+
chalk179.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
19551
19691
|
`)
|
|
19552
19692
|
);
|
|
19553
19693
|
for (const [refFile, lines] of grouped) {
|
|
19554
19694
|
console.log(
|
|
19555
|
-
` ${
|
|
19695
|
+
` ${chalk179.dim(refFile)}: lines ${chalk179.cyan(lines.join(", "))}`
|
|
19556
19696
|
);
|
|
19557
19697
|
}
|
|
19558
19698
|
if (options2.apply) {
|
|
19559
19699
|
symbol.rename(newName);
|
|
19560
19700
|
await project.save();
|
|
19561
|
-
console.log(
|
|
19701
|
+
console.log(chalk179.green(`
|
|
19562
19702
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
19563
19703
|
} else {
|
|
19564
|
-
console.log(
|
|
19704
|
+
console.log(chalk179.dim("\nDry run. Use --apply to execute."));
|
|
19565
19705
|
}
|
|
19566
19706
|
}
|
|
19567
19707
|
|
|
19568
19708
|
// src/commands/refactor/restructure/index.ts
|
|
19569
19709
|
import path54 from "path";
|
|
19570
|
-
import
|
|
19710
|
+
import chalk182 from "chalk";
|
|
19571
19711
|
|
|
19572
19712
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
19573
19713
|
import path48 from "path";
|
|
@@ -19646,50 +19786,50 @@ function clusterFiles(graph) {
|
|
|
19646
19786
|
|
|
19647
19787
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
19648
19788
|
import path50 from "path";
|
|
19649
|
-
import
|
|
19789
|
+
import chalk180 from "chalk";
|
|
19650
19790
|
function relPath(filePath) {
|
|
19651
19791
|
return path50.relative(process.cwd(), filePath);
|
|
19652
19792
|
}
|
|
19653
19793
|
function displayMoves(plan2) {
|
|
19654
19794
|
if (plan2.moves.length === 0) return;
|
|
19655
|
-
console.log(
|
|
19795
|
+
console.log(chalk180.bold("\nFile moves:"));
|
|
19656
19796
|
for (const move2 of plan2.moves) {
|
|
19657
19797
|
console.log(
|
|
19658
|
-
` ${
|
|
19798
|
+
` ${chalk180.red(relPath(move2.from))} \u2192 ${chalk180.green(relPath(move2.to))}`
|
|
19659
19799
|
);
|
|
19660
|
-
console.log(
|
|
19800
|
+
console.log(chalk180.dim(` ${move2.reason}`));
|
|
19661
19801
|
}
|
|
19662
19802
|
}
|
|
19663
19803
|
function displayRewrites(rewrites) {
|
|
19664
19804
|
if (rewrites.length === 0) return;
|
|
19665
19805
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
19666
|
-
console.log(
|
|
19806
|
+
console.log(chalk180.bold(`
|
|
19667
19807
|
Import rewrites (${affectedFiles.size} files):`));
|
|
19668
19808
|
for (const file of affectedFiles) {
|
|
19669
|
-
console.log(` ${
|
|
19809
|
+
console.log(` ${chalk180.cyan(relPath(file))}:`);
|
|
19670
19810
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
19671
19811
|
(r) => r.file === file
|
|
19672
19812
|
)) {
|
|
19673
19813
|
console.log(
|
|
19674
|
-
` ${
|
|
19814
|
+
` ${chalk180.red(`"${oldSpecifier}"`)} \u2192 ${chalk180.green(`"${newSpecifier}"`)}`
|
|
19675
19815
|
);
|
|
19676
19816
|
}
|
|
19677
19817
|
}
|
|
19678
19818
|
}
|
|
19679
19819
|
function displayPlan2(plan2) {
|
|
19680
19820
|
if (plan2.warnings.length > 0) {
|
|
19681
|
-
console.log(
|
|
19682
|
-
for (const w of plan2.warnings) console.log(
|
|
19821
|
+
console.log(chalk180.yellow("\nWarnings:"));
|
|
19822
|
+
for (const w of plan2.warnings) console.log(chalk180.yellow(` ${w}`));
|
|
19683
19823
|
}
|
|
19684
19824
|
if (plan2.newDirectories.length > 0) {
|
|
19685
|
-
console.log(
|
|
19825
|
+
console.log(chalk180.bold("\nNew directories:"));
|
|
19686
19826
|
for (const dir of plan2.newDirectories)
|
|
19687
|
-
console.log(
|
|
19827
|
+
console.log(chalk180.green(` ${dir}/`));
|
|
19688
19828
|
}
|
|
19689
19829
|
displayMoves(plan2);
|
|
19690
19830
|
displayRewrites(plan2.rewrites);
|
|
19691
19831
|
console.log(
|
|
19692
|
-
|
|
19832
|
+
chalk180.dim(
|
|
19693
19833
|
`
|
|
19694
19834
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
19695
19835
|
)
|
|
@@ -19699,18 +19839,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
19699
19839
|
// src/commands/refactor/restructure/executePlan.ts
|
|
19700
19840
|
import fs31 from "fs";
|
|
19701
19841
|
import path51 from "path";
|
|
19702
|
-
import
|
|
19842
|
+
import chalk181 from "chalk";
|
|
19703
19843
|
function executePlan(plan2) {
|
|
19704
19844
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
19705
19845
|
for (const [file, content] of updatedContents) {
|
|
19706
19846
|
fs31.writeFileSync(file, content, "utf8");
|
|
19707
19847
|
console.log(
|
|
19708
|
-
|
|
19848
|
+
chalk181.cyan(` Rewrote imports in ${path51.relative(process.cwd(), file)}`)
|
|
19709
19849
|
);
|
|
19710
19850
|
}
|
|
19711
19851
|
for (const dir of plan2.newDirectories) {
|
|
19712
19852
|
fs31.mkdirSync(dir, { recursive: true });
|
|
19713
|
-
console.log(
|
|
19853
|
+
console.log(chalk181.green(` Created ${path51.relative(process.cwd(), dir)}/`));
|
|
19714
19854
|
}
|
|
19715
19855
|
for (const move2 of plan2.moves) {
|
|
19716
19856
|
const targetDir = path51.dirname(move2.to);
|
|
@@ -19719,7 +19859,7 @@ function executePlan(plan2) {
|
|
|
19719
19859
|
}
|
|
19720
19860
|
fs31.renameSync(move2.from, move2.to);
|
|
19721
19861
|
console.log(
|
|
19722
|
-
|
|
19862
|
+
chalk181.white(
|
|
19723
19863
|
` Moved ${path51.relative(process.cwd(), move2.from)} \u2192 ${path51.relative(process.cwd(), move2.to)}`
|
|
19724
19864
|
)
|
|
19725
19865
|
);
|
|
@@ -19734,7 +19874,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
19734
19874
|
if (entries.length === 0) {
|
|
19735
19875
|
fs31.rmdirSync(dir);
|
|
19736
19876
|
console.log(
|
|
19737
|
-
|
|
19877
|
+
chalk181.dim(
|
|
19738
19878
|
` Removed empty directory ${path51.relative(process.cwd(), dir)}`
|
|
19739
19879
|
)
|
|
19740
19880
|
);
|
|
@@ -19867,22 +20007,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
19867
20007
|
const targetPattern = pattern2 ?? "src";
|
|
19868
20008
|
const files = findSourceFiles2(targetPattern);
|
|
19869
20009
|
if (files.length === 0) {
|
|
19870
|
-
console.log(
|
|
20010
|
+
console.log(chalk182.yellow("No files found matching pattern"));
|
|
19871
20011
|
return;
|
|
19872
20012
|
}
|
|
19873
20013
|
const tsConfigPath = path54.resolve("tsconfig.json");
|
|
19874
20014
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
19875
20015
|
if (plan2.moves.length === 0) {
|
|
19876
|
-
console.log(
|
|
20016
|
+
console.log(chalk182.green("No restructuring needed"));
|
|
19877
20017
|
return;
|
|
19878
20018
|
}
|
|
19879
20019
|
displayPlan2(plan2);
|
|
19880
20020
|
if (options2.apply) {
|
|
19881
|
-
console.log(
|
|
20021
|
+
console.log(chalk182.bold("\nApplying changes..."));
|
|
19882
20022
|
executePlan(plan2);
|
|
19883
|
-
console.log(
|
|
20023
|
+
console.log(chalk182.green("\nRestructuring complete"));
|
|
19884
20024
|
} else {
|
|
19885
|
-
console.log(
|
|
20025
|
+
console.log(chalk182.dim("\nDry run. Use --apply to execute."));
|
|
19886
20026
|
}
|
|
19887
20027
|
}
|
|
19888
20028
|
|
|
@@ -20048,9 +20188,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
20048
20188
|
|
|
20049
20189
|
// src/commands/review/buildReviewPaths.ts
|
|
20050
20190
|
import { homedir as homedir20 } from "os";
|
|
20051
|
-
import { basename as basename12, join as
|
|
20191
|
+
import { basename as basename12, join as join53 } from "path";
|
|
20052
20192
|
function buildReviewPaths(repoRoot, key) {
|
|
20053
|
-
const reviewDir =
|
|
20193
|
+
const reviewDir = join53(
|
|
20054
20194
|
homedir20(),
|
|
20055
20195
|
".assist",
|
|
20056
20196
|
"reviews",
|
|
@@ -20059,10 +20199,10 @@ function buildReviewPaths(repoRoot, key) {
|
|
|
20059
20199
|
);
|
|
20060
20200
|
return {
|
|
20061
20201
|
reviewDir,
|
|
20062
|
-
requestPath:
|
|
20063
|
-
claudePath:
|
|
20064
|
-
codexPath:
|
|
20065
|
-
synthesisPath:
|
|
20202
|
+
requestPath: join53(reviewDir, "request.md"),
|
|
20203
|
+
claudePath: join53(reviewDir, "claude.md"),
|
|
20204
|
+
codexPath: join53(reviewDir, "codex.md"),
|
|
20205
|
+
synthesisPath: join53(reviewDir, "synthesis.md")
|
|
20066
20206
|
};
|
|
20067
20207
|
}
|
|
20068
20208
|
|
|
@@ -20204,7 +20344,7 @@ function gatherContext() {
|
|
|
20204
20344
|
}
|
|
20205
20345
|
|
|
20206
20346
|
// src/commands/review/postReviewToPr.ts
|
|
20207
|
-
import { readFileSync as
|
|
20347
|
+
import { readFileSync as readFileSync39 } from "fs";
|
|
20208
20348
|
|
|
20209
20349
|
// src/commands/review/parseFindings.ts
|
|
20210
20350
|
var SEVERITIES = ["blocker", "major", "minor", "nit"];
|
|
@@ -20465,18 +20605,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
20465
20605
|
}
|
|
20466
20606
|
|
|
20467
20607
|
// src/commands/review/warnOutOfDiff.ts
|
|
20468
|
-
import
|
|
20608
|
+
import chalk183 from "chalk";
|
|
20469
20609
|
function warnOutOfDiff(outOfDiff) {
|
|
20470
20610
|
if (outOfDiff.length === 0) return;
|
|
20471
20611
|
console.warn(
|
|
20472
|
-
|
|
20612
|
+
chalk183.yellow(
|
|
20473
20613
|
`Skipped ${outOfDiff.length} finding(s) whose lines fall outside the PR diff (GitHub would silently drop these):`
|
|
20474
20614
|
)
|
|
20475
20615
|
);
|
|
20476
20616
|
for (const finding of outOfDiff) {
|
|
20477
20617
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
20478
20618
|
console.warn(
|
|
20479
|
-
` ${
|
|
20619
|
+
` ${chalk183.yellow("\xB7")} ${finding.title} ${chalk183.dim(
|
|
20480
20620
|
`(${finding.file}:${range})`
|
|
20481
20621
|
)}`
|
|
20482
20622
|
);
|
|
@@ -20495,18 +20635,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
20495
20635
|
}
|
|
20496
20636
|
|
|
20497
20637
|
// src/commands/review/warnUnlocated.ts
|
|
20498
|
-
import
|
|
20638
|
+
import chalk184 from "chalk";
|
|
20499
20639
|
function warnUnlocated(unlocated) {
|
|
20500
20640
|
if (unlocated.length === 0) return;
|
|
20501
20641
|
console.warn(
|
|
20502
|
-
|
|
20642
|
+
chalk184.yellow(
|
|
20503
20643
|
`Skipped ${unlocated.length} finding(s) without a parseable file:line:`
|
|
20504
20644
|
)
|
|
20505
20645
|
);
|
|
20506
20646
|
for (const finding of unlocated) {
|
|
20507
|
-
const where = finding.location ||
|
|
20647
|
+
const where = finding.location || chalk184.dim("missing");
|
|
20508
20648
|
console.warn(
|
|
20509
|
-
` ${
|
|
20649
|
+
` ${chalk184.yellow("\xB7")} ${finding.title} ${chalk184.dim(`(${where})`)}`
|
|
20510
20650
|
);
|
|
20511
20651
|
}
|
|
20512
20652
|
}
|
|
@@ -20519,7 +20659,7 @@ async function confirmPost(prNumber, count7, options2) {
|
|
|
20519
20659
|
async function postReviewToPr(synthesisPath, options2) {
|
|
20520
20660
|
const prInfo = fetchPrDiffInfo();
|
|
20521
20661
|
const prNumber = prInfo.prNumber;
|
|
20522
|
-
const markdown =
|
|
20662
|
+
const markdown = readFileSync39(synthesisPath, "utf8");
|
|
20523
20663
|
const findings = parseFindings(markdown);
|
|
20524
20664
|
if (findings.length === 0) {
|
|
20525
20665
|
console.log("Synthesis contains no findings; nothing to post.");
|
|
@@ -20601,16 +20741,16 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
20601
20741
|
}
|
|
20602
20742
|
|
|
20603
20743
|
// src/commands/review/prepareReviewDir.ts
|
|
20604
|
-
import { existsSync as
|
|
20744
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync18, unlinkSync as unlinkSync16, writeFileSync as writeFileSync36 } from "fs";
|
|
20605
20745
|
function clearReviewFiles(paths) {
|
|
20606
20746
|
for (const path67 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
20607
|
-
if (
|
|
20747
|
+
if (existsSync43(path67)) unlinkSync16(path67);
|
|
20608
20748
|
}
|
|
20609
20749
|
}
|
|
20610
20750
|
function prepareReviewDir(paths, requestBody, force) {
|
|
20611
|
-
|
|
20751
|
+
mkdirSync18(paths.reviewDir, { recursive: true });
|
|
20612
20752
|
if (force) clearReviewFiles(paths);
|
|
20613
|
-
|
|
20753
|
+
writeFileSync36(paths.requestPath, requestBody);
|
|
20614
20754
|
}
|
|
20615
20755
|
|
|
20616
20756
|
// src/commands/review/runApplySession.ts
|
|
@@ -20889,7 +21029,7 @@ function printReviewerFailures(results) {
|
|
|
20889
21029
|
}
|
|
20890
21030
|
|
|
20891
21031
|
// src/commands/review/runAndSynthesise.ts
|
|
20892
|
-
import { existsSync as
|
|
21032
|
+
import { existsSync as existsSync45, unlinkSync as unlinkSync18 } from "fs";
|
|
20893
21033
|
|
|
20894
21034
|
// src/commands/review/buildReviewerStdin.ts
|
|
20895
21035
|
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.
|
|
@@ -20955,7 +21095,7 @@ The review request is at: ${requestPath}
|
|
|
20955
21095
|
}
|
|
20956
21096
|
|
|
20957
21097
|
// src/commands/review/runClaudeReviewer.ts
|
|
20958
|
-
import { writeFileSync as
|
|
21098
|
+
import { writeFileSync as writeFileSync37 } from "fs";
|
|
20959
21099
|
|
|
20960
21100
|
// src/commands/review/finaliseReviewerSpinner.ts
|
|
20961
21101
|
var SUMMARY_MAX_LEN = 80;
|
|
@@ -21291,7 +21431,7 @@ async function runClaudeReviewer(spec) {
|
|
|
21291
21431
|
}
|
|
21292
21432
|
});
|
|
21293
21433
|
if (result.exitCode === 0 && finalText)
|
|
21294
|
-
|
|
21434
|
+
writeFileSync37(spec.outputPath, finalText);
|
|
21295
21435
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
21296
21436
|
}
|
|
21297
21437
|
|
|
@@ -21309,7 +21449,7 @@ function resolveClaude(args) {
|
|
|
21309
21449
|
}
|
|
21310
21450
|
|
|
21311
21451
|
// src/commands/review/runCodexReviewer.ts
|
|
21312
|
-
import { existsSync as
|
|
21452
|
+
import { existsSync as existsSync44, unlinkSync as unlinkSync17 } from "fs";
|
|
21313
21453
|
|
|
21314
21454
|
// src/commands/review/parseCodexEvent.ts
|
|
21315
21455
|
function isItemStarted(value) {
|
|
@@ -21361,8 +21501,8 @@ async function runCodexReviewer(spec) {
|
|
|
21361
21501
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
21362
21502
|
}
|
|
21363
21503
|
});
|
|
21364
|
-
if (result.exitCode !== 0 &&
|
|
21365
|
-
|
|
21504
|
+
if (result.exitCode !== 0 && existsSync44(spec.outputPath)) {
|
|
21505
|
+
unlinkSync17(spec.outputPath);
|
|
21366
21506
|
}
|
|
21367
21507
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
21368
21508
|
}
|
|
@@ -21403,7 +21543,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
21403
21543
|
}
|
|
21404
21544
|
|
|
21405
21545
|
// src/commands/review/synthesise.ts
|
|
21406
|
-
import { readFileSync as
|
|
21546
|
+
import { readFileSync as readFileSync40 } from "fs";
|
|
21407
21547
|
|
|
21408
21548
|
// src/commands/review/buildSynthesisStdin.ts
|
|
21409
21549
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -21459,7 +21599,7 @@ Files:
|
|
|
21459
21599
|
|
|
21460
21600
|
// src/commands/review/synthesise.ts
|
|
21461
21601
|
function printSummary2(synthesisPath) {
|
|
21462
|
-
const markdown =
|
|
21602
|
+
const markdown = readFileSync40(synthesisPath, "utf8");
|
|
21463
21603
|
console.log("");
|
|
21464
21604
|
console.log(buildReviewSummary(markdown));
|
|
21465
21605
|
console.log("");
|
|
@@ -21507,8 +21647,8 @@ async function runAndSynthesise(args) {
|
|
|
21507
21647
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
21508
21648
|
return { ok: false, failures };
|
|
21509
21649
|
}
|
|
21510
|
-
if (anyFresh &&
|
|
21511
|
-
|
|
21650
|
+
if (anyFresh && existsSync45(paths.synthesisPath)) {
|
|
21651
|
+
unlinkSync18(paths.synthesisPath);
|
|
21512
21652
|
}
|
|
21513
21653
|
const synthesisResult = await synthesise(paths, { multi });
|
|
21514
21654
|
if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
|
|
@@ -21678,7 +21818,7 @@ function registerReview(program2) {
|
|
|
21678
21818
|
}
|
|
21679
21819
|
|
|
21680
21820
|
// src/commands/seq/seqAuth.ts
|
|
21681
|
-
import
|
|
21821
|
+
import chalk186 from "chalk";
|
|
21682
21822
|
|
|
21683
21823
|
// src/commands/seq/loadConnections.ts
|
|
21684
21824
|
function loadConnections2() {
|
|
@@ -21707,10 +21847,10 @@ function setDefaultConnection(name) {
|
|
|
21707
21847
|
}
|
|
21708
21848
|
|
|
21709
21849
|
// src/shared/assertUniqueName.ts
|
|
21710
|
-
import
|
|
21850
|
+
import chalk185 from "chalk";
|
|
21711
21851
|
function assertUniqueName(existingNames, name) {
|
|
21712
21852
|
if (existingNames.includes(name)) {
|
|
21713
|
-
console.error(
|
|
21853
|
+
console.error(chalk185.red(`Connection "${name}" already exists.`));
|
|
21714
21854
|
process.exit(1);
|
|
21715
21855
|
}
|
|
21716
21856
|
}
|
|
@@ -21728,7 +21868,7 @@ async function promptConnection2(existingNames) {
|
|
|
21728
21868
|
var seqAuth = createConnectionAuth({
|
|
21729
21869
|
load: loadConnections2,
|
|
21730
21870
|
save: saveConnections2,
|
|
21731
|
-
format: (c) => `${
|
|
21871
|
+
format: (c) => `${chalk186.bold(c.name)} ${c.url}`,
|
|
21732
21872
|
promptNew: promptConnection2,
|
|
21733
21873
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
21734
21874
|
});
|
|
@@ -21748,10 +21888,10 @@ var seqConfigHelp = [
|
|
|
21748
21888
|
];
|
|
21749
21889
|
|
|
21750
21890
|
// src/commands/seq/seqQuery.ts
|
|
21751
|
-
import
|
|
21891
|
+
import chalk190 from "chalk";
|
|
21752
21892
|
|
|
21753
21893
|
// src/commands/seq/fetchSeq.ts
|
|
21754
|
-
import
|
|
21894
|
+
import chalk187 from "chalk";
|
|
21755
21895
|
async function fetchSeq(conn, path67, params) {
|
|
21756
21896
|
const url = `${conn.url}${path67}?${params}`;
|
|
21757
21897
|
const response = await fetch(url, {
|
|
@@ -21762,7 +21902,7 @@ async function fetchSeq(conn, path67, params) {
|
|
|
21762
21902
|
});
|
|
21763
21903
|
if (!response.ok) {
|
|
21764
21904
|
const body = await response.text();
|
|
21765
|
-
console.error(
|
|
21905
|
+
console.error(chalk187.red(`Seq returned ${response.status}: ${body}`));
|
|
21766
21906
|
process.exit(1);
|
|
21767
21907
|
}
|
|
21768
21908
|
return response;
|
|
@@ -21821,23 +21961,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
21821
21961
|
}
|
|
21822
21962
|
|
|
21823
21963
|
// src/commands/seq/formatEvent.ts
|
|
21824
|
-
import
|
|
21964
|
+
import chalk188 from "chalk";
|
|
21825
21965
|
function levelColor(level) {
|
|
21826
21966
|
switch (level) {
|
|
21827
21967
|
case "Fatal":
|
|
21828
|
-
return
|
|
21968
|
+
return chalk188.bgRed.white;
|
|
21829
21969
|
case "Error":
|
|
21830
|
-
return
|
|
21970
|
+
return chalk188.red;
|
|
21831
21971
|
case "Warning":
|
|
21832
|
-
return
|
|
21972
|
+
return chalk188.yellow;
|
|
21833
21973
|
case "Information":
|
|
21834
|
-
return
|
|
21974
|
+
return chalk188.cyan;
|
|
21835
21975
|
case "Debug":
|
|
21836
|
-
return
|
|
21976
|
+
return chalk188.gray;
|
|
21837
21977
|
case "Verbose":
|
|
21838
|
-
return
|
|
21978
|
+
return chalk188.dim;
|
|
21839
21979
|
default:
|
|
21840
|
-
return
|
|
21980
|
+
return chalk188.white;
|
|
21841
21981
|
}
|
|
21842
21982
|
}
|
|
21843
21983
|
function levelAbbrev(level) {
|
|
@@ -21878,12 +22018,12 @@ function formatTimestamp(iso) {
|
|
|
21878
22018
|
function formatEvent(event) {
|
|
21879
22019
|
const color = levelColor(event.Level);
|
|
21880
22020
|
const abbrev = levelAbbrev(event.Level);
|
|
21881
|
-
const ts8 =
|
|
22021
|
+
const ts8 = chalk188.dim(formatTimestamp(event.Timestamp));
|
|
21882
22022
|
const msg = renderMessage(event);
|
|
21883
22023
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
21884
22024
|
if (event.Exception) {
|
|
21885
22025
|
for (const line of event.Exception.split("\n")) {
|
|
21886
|
-
lines.push(
|
|
22026
|
+
lines.push(chalk188.red(` ${line}`));
|
|
21887
22027
|
}
|
|
21888
22028
|
}
|
|
21889
22029
|
return lines.join("\n");
|
|
@@ -21916,11 +22056,11 @@ function rejectTimestampFilter(filter) {
|
|
|
21916
22056
|
}
|
|
21917
22057
|
|
|
21918
22058
|
// src/shared/resolveNamedConnection.ts
|
|
21919
|
-
import
|
|
22059
|
+
import chalk189 from "chalk";
|
|
21920
22060
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
21921
22061
|
if (connections.length === 0) {
|
|
21922
22062
|
console.error(
|
|
21923
|
-
|
|
22063
|
+
chalk189.red(
|
|
21924
22064
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
21925
22065
|
)
|
|
21926
22066
|
);
|
|
@@ -21929,7 +22069,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
21929
22069
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
21930
22070
|
const connection = connections.find((c) => c.name === target);
|
|
21931
22071
|
if (!connection) {
|
|
21932
|
-
console.error(
|
|
22072
|
+
console.error(chalk189.red(`${kind} connection "${target}" not found.`));
|
|
21933
22073
|
process.exit(1);
|
|
21934
22074
|
}
|
|
21935
22075
|
return connection;
|
|
@@ -21958,7 +22098,7 @@ async function seqQuery(filter, options2) {
|
|
|
21958
22098
|
new URLSearchParams({ filter, count: String(count7) })
|
|
21959
22099
|
);
|
|
21960
22100
|
if (events.length === 0) {
|
|
21961
|
-
console.log(
|
|
22101
|
+
console.log(chalk190.yellow("No events found."));
|
|
21962
22102
|
return;
|
|
21963
22103
|
}
|
|
21964
22104
|
if (options2.json) {
|
|
@@ -21969,11 +22109,11 @@ async function seqQuery(filter, options2) {
|
|
|
21969
22109
|
for (const event of chronological) {
|
|
21970
22110
|
console.log(formatEvent(event));
|
|
21971
22111
|
}
|
|
21972
|
-
console.log(
|
|
22112
|
+
console.log(chalk190.dim(`
|
|
21973
22113
|
${events.length} events`));
|
|
21974
22114
|
if (events.length >= count7) {
|
|
21975
22115
|
console.log(
|
|
21976
|
-
|
|
22116
|
+
chalk190.yellow(
|
|
21977
22117
|
`Results limited to ${count7}. Use --count to retrieve more.`
|
|
21978
22118
|
)
|
|
21979
22119
|
);
|
|
@@ -21981,10 +22121,10 @@ ${events.length} events`));
|
|
|
21981
22121
|
}
|
|
21982
22122
|
|
|
21983
22123
|
// src/shared/setNamedDefaultConnection.ts
|
|
21984
|
-
import
|
|
22124
|
+
import chalk191 from "chalk";
|
|
21985
22125
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
21986
22126
|
if (!connections.find((c) => c.name === name)) {
|
|
21987
|
-
console.error(
|
|
22127
|
+
console.error(chalk191.red(`Connection "${name}" not found.`));
|
|
21988
22128
|
process.exit(1);
|
|
21989
22129
|
}
|
|
21990
22130
|
setDefault(name);
|
|
@@ -22033,7 +22173,7 @@ function registerSignal(program2) {
|
|
|
22033
22173
|
}
|
|
22034
22174
|
|
|
22035
22175
|
// src/commands/sql/sqlAuth.ts
|
|
22036
|
-
import
|
|
22176
|
+
import chalk193 from "chalk";
|
|
22037
22177
|
|
|
22038
22178
|
// src/commands/sql/loadConnections.ts
|
|
22039
22179
|
function loadConnections3() {
|
|
@@ -22062,7 +22202,7 @@ function setDefaultConnection2(name) {
|
|
|
22062
22202
|
}
|
|
22063
22203
|
|
|
22064
22204
|
// src/commands/sql/promptConnection.ts
|
|
22065
|
-
import
|
|
22205
|
+
import chalk192 from "chalk";
|
|
22066
22206
|
async function promptConnection3(existingNames) {
|
|
22067
22207
|
const name = await promptInput("name", "Connection name:", "default");
|
|
22068
22208
|
assertUniqueName(existingNames, name);
|
|
@@ -22070,7 +22210,7 @@ async function promptConnection3(existingNames) {
|
|
|
22070
22210
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
22071
22211
|
const port = Number.parseInt(portStr, 10);
|
|
22072
22212
|
if (!Number.isFinite(port)) {
|
|
22073
|
-
console.error(
|
|
22213
|
+
console.error(chalk192.red(`Invalid port "${portStr}".`));
|
|
22074
22214
|
process.exit(1);
|
|
22075
22215
|
}
|
|
22076
22216
|
const user = await promptInput("user", "User:");
|
|
@@ -22083,13 +22223,13 @@ async function promptConnection3(existingNames) {
|
|
|
22083
22223
|
var sqlAuth = createConnectionAuth({
|
|
22084
22224
|
load: loadConnections3,
|
|
22085
22225
|
save: saveConnections3,
|
|
22086
|
-
format: (c) => `${
|
|
22226
|
+
format: (c) => `${chalk193.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
22087
22227
|
promptNew: promptConnection3,
|
|
22088
22228
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
22089
22229
|
});
|
|
22090
22230
|
|
|
22091
22231
|
// src/commands/sql/printTable.ts
|
|
22092
|
-
import
|
|
22232
|
+
import chalk194 from "chalk";
|
|
22093
22233
|
function formatCell(value) {
|
|
22094
22234
|
if (value === null || value === void 0) return "";
|
|
22095
22235
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -22098,7 +22238,7 @@ function formatCell(value) {
|
|
|
22098
22238
|
}
|
|
22099
22239
|
function printTable(rows) {
|
|
22100
22240
|
if (rows.length === 0) {
|
|
22101
|
-
console.log(
|
|
22241
|
+
console.log(chalk194.yellow("(no rows)"));
|
|
22102
22242
|
return;
|
|
22103
22243
|
}
|
|
22104
22244
|
const columns = Object.keys(rows[0]);
|
|
@@ -22106,13 +22246,13 @@ function printTable(rows) {
|
|
|
22106
22246
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
22107
22247
|
);
|
|
22108
22248
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
22109
|
-
console.log(
|
|
22110
|
-
console.log(
|
|
22249
|
+
console.log(chalk194.dim(header));
|
|
22250
|
+
console.log(chalk194.dim("-".repeat(header.length)));
|
|
22111
22251
|
for (const row of rows) {
|
|
22112
22252
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
22113
22253
|
console.log(line);
|
|
22114
22254
|
}
|
|
22115
|
-
console.log(
|
|
22255
|
+
console.log(chalk194.dim(`
|
|
22116
22256
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
22117
22257
|
}
|
|
22118
22258
|
|
|
@@ -22186,7 +22326,7 @@ var sqlConfigHelp = [
|
|
|
22186
22326
|
];
|
|
22187
22327
|
|
|
22188
22328
|
// src/commands/sql/sqlMutate.ts
|
|
22189
|
-
import
|
|
22329
|
+
import chalk195 from "chalk";
|
|
22190
22330
|
|
|
22191
22331
|
// src/commands/sql/isMutation.ts
|
|
22192
22332
|
var MUTATION_KEYWORDS = [
|
|
@@ -22220,7 +22360,7 @@ function isMutation(sql24) {
|
|
|
22220
22360
|
async function sqlMutate(query, connectionName) {
|
|
22221
22361
|
if (!isMutation(query)) {
|
|
22222
22362
|
console.error(
|
|
22223
|
-
|
|
22363
|
+
chalk195.red(
|
|
22224
22364
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
22225
22365
|
)
|
|
22226
22366
|
);
|
|
@@ -22230,18 +22370,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
22230
22370
|
const pool = await sqlConnect(conn);
|
|
22231
22371
|
try {
|
|
22232
22372
|
const result = await pool.request().query(query);
|
|
22233
|
-
console.log(
|
|
22373
|
+
console.log(chalk195.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
22234
22374
|
} finally {
|
|
22235
22375
|
await pool.close();
|
|
22236
22376
|
}
|
|
22237
22377
|
}
|
|
22238
22378
|
|
|
22239
22379
|
// src/commands/sql/sqlQuery.ts
|
|
22240
|
-
import
|
|
22380
|
+
import chalk196 from "chalk";
|
|
22241
22381
|
async function sqlQuery(query, connectionName) {
|
|
22242
22382
|
if (isMutation(query)) {
|
|
22243
22383
|
console.error(
|
|
22244
|
-
|
|
22384
|
+
chalk196.red(
|
|
22245
22385
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
22246
22386
|
)
|
|
22247
22387
|
);
|
|
@@ -22256,7 +22396,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
22256
22396
|
printTable(rows);
|
|
22257
22397
|
} else {
|
|
22258
22398
|
console.log(
|
|
22259
|
-
|
|
22399
|
+
chalk196.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
22260
22400
|
);
|
|
22261
22401
|
}
|
|
22262
22402
|
} finally {
|
|
@@ -22387,27 +22527,27 @@ async function configure() {
|
|
|
22387
22527
|
}
|
|
22388
22528
|
|
|
22389
22529
|
// src/commands/transcript/list.ts
|
|
22390
|
-
import { existsSync as
|
|
22391
|
-
import { join as
|
|
22530
|
+
import { existsSync as existsSync46, readdirSync as readdirSync10, statSync as statSync7 } from "fs";
|
|
22531
|
+
import { join as join54 } from "path";
|
|
22392
22532
|
function list4() {
|
|
22393
22533
|
const { vttDir } = getTranscriptConfig();
|
|
22394
|
-
if (!
|
|
22534
|
+
if (!existsSync46(vttDir)) return;
|
|
22395
22535
|
for (const entry of readdirSync10(vttDir)) {
|
|
22396
22536
|
if (!entry.endsWith(".vtt")) continue;
|
|
22397
|
-
if (statSync7(
|
|
22537
|
+
if (statSync7(join54(vttDir, entry)).isDirectory()) continue;
|
|
22398
22538
|
console.log(entry);
|
|
22399
22539
|
}
|
|
22400
22540
|
}
|
|
22401
22541
|
|
|
22402
22542
|
// src/commands/transcript/move.ts
|
|
22403
22543
|
import {
|
|
22404
|
-
existsSync as
|
|
22405
|
-
mkdirSync as
|
|
22406
|
-
readFileSync as
|
|
22544
|
+
existsSync as existsSync47,
|
|
22545
|
+
mkdirSync as mkdirSync19,
|
|
22546
|
+
readFileSync as readFileSync41,
|
|
22407
22547
|
renameSync as renameSync2,
|
|
22408
|
-
writeFileSync as
|
|
22548
|
+
writeFileSync as writeFileSync38
|
|
22409
22549
|
} from "fs";
|
|
22410
|
-
import { basename as basename13, join as
|
|
22550
|
+
import { basename as basename13, join as join55 } from "path";
|
|
22411
22551
|
|
|
22412
22552
|
// src/commands/transcript/cleanText.ts
|
|
22413
22553
|
function cleanText(text17) {
|
|
@@ -22615,14 +22755,14 @@ function formatChatLog(messages) {
|
|
|
22615
22755
|
// src/commands/transcript/move.ts
|
|
22616
22756
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
22617
22757
|
function convertVttToMarkdown(inputPath) {
|
|
22618
|
-
const cues = parseVtt(
|
|
22758
|
+
const cues = parseVtt(readFileSync41(inputPath, "utf8"));
|
|
22619
22759
|
const messages = cuesToChatMessages(deduplicateCues(cues));
|
|
22620
22760
|
return formatChatLog(messages);
|
|
22621
22761
|
}
|
|
22622
22762
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
22623
|
-
const processedDir =
|
|
22624
|
-
|
|
22625
|
-
renameSync2(sourcePath,
|
|
22763
|
+
const processedDir = join55(vttDir, "processed");
|
|
22764
|
+
mkdirSync19(processedDir, { recursive: true });
|
|
22765
|
+
renameSync2(sourcePath, join55(processedDir, filename));
|
|
22626
22766
|
}
|
|
22627
22767
|
function move(file, options2) {
|
|
22628
22768
|
const { date, client } = options2;
|
|
@@ -22632,19 +22772,19 @@ function move(file, options2) {
|
|
|
22632
22772
|
}
|
|
22633
22773
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
22634
22774
|
const filename = basename13(file);
|
|
22635
|
-
const sourcePath =
|
|
22636
|
-
if (!
|
|
22775
|
+
const sourcePath = join55(vttDir, filename);
|
|
22776
|
+
if (!existsSync47(sourcePath)) {
|
|
22637
22777
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
22638
22778
|
process.exit(1);
|
|
22639
22779
|
}
|
|
22640
22780
|
const base = basename13(filename, ".vtt").replace(/ Transcription$/, "");
|
|
22641
22781
|
const outputName = `${date} ${base}.md`;
|
|
22642
|
-
const formattedDir =
|
|
22643
|
-
|
|
22644
|
-
const formattedPath =
|
|
22645
|
-
|
|
22782
|
+
const formattedDir = join55(transcriptsDir, client);
|
|
22783
|
+
mkdirSync19(formattedDir, { recursive: true });
|
|
22784
|
+
const formattedPath = join55(formattedDir, outputName);
|
|
22785
|
+
writeFileSync38(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
22646
22786
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
22647
|
-
const summaryPath =
|
|
22787
|
+
const summaryPath = join55(summaryDir, client, outputName);
|
|
22648
22788
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
22649
22789
|
console.log(`Summary target: ${summaryPath}`);
|
|
22650
22790
|
}
|
|
@@ -22764,50 +22904,50 @@ function registerVerify(program2) {
|
|
|
22764
22904
|
|
|
22765
22905
|
// src/commands/voice/devices.ts
|
|
22766
22906
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
22767
|
-
import { join as
|
|
22907
|
+
import { join as join57 } from "path";
|
|
22768
22908
|
|
|
22769
22909
|
// src/commands/voice/shared.ts
|
|
22770
22910
|
import { homedir as homedir21 } from "os";
|
|
22771
|
-
import { dirname as dirname26, join as
|
|
22911
|
+
import { dirname as dirname26, join as join56 } from "path";
|
|
22772
22912
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
22773
22913
|
var __dirname5 = dirname26(fileURLToPath7(import.meta.url));
|
|
22774
|
-
var VOICE_DIR =
|
|
22914
|
+
var VOICE_DIR = join56(homedir21(), ".assist", "voice");
|
|
22775
22915
|
var voicePaths = {
|
|
22776
22916
|
dir: VOICE_DIR,
|
|
22777
|
-
pid:
|
|
22778
|
-
log:
|
|
22779
|
-
venv:
|
|
22780
|
-
lock:
|
|
22917
|
+
pid: join56(VOICE_DIR, "voice.pid"),
|
|
22918
|
+
log: join56(VOICE_DIR, "voice.log"),
|
|
22919
|
+
venv: join56(VOICE_DIR, ".venv"),
|
|
22920
|
+
lock: join56(VOICE_DIR, "voice.lock")
|
|
22781
22921
|
};
|
|
22782
22922
|
function getPythonDir() {
|
|
22783
|
-
return
|
|
22923
|
+
return join56(__dirname5, "commands", "voice", "python");
|
|
22784
22924
|
}
|
|
22785
22925
|
function getVenvPython() {
|
|
22786
|
-
return process.platform === "win32" ?
|
|
22926
|
+
return process.platform === "win32" ? join56(voicePaths.venv, "Scripts", "python.exe") : join56(voicePaths.venv, "bin", "python");
|
|
22787
22927
|
}
|
|
22788
22928
|
function getLockDir() {
|
|
22789
22929
|
const config = loadConfig();
|
|
22790
22930
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
22791
22931
|
}
|
|
22792
22932
|
function getLockFile() {
|
|
22793
|
-
return
|
|
22933
|
+
return join56(getLockDir(), "voice.lock");
|
|
22794
22934
|
}
|
|
22795
22935
|
|
|
22796
22936
|
// src/commands/voice/devices.ts
|
|
22797
22937
|
function devices() {
|
|
22798
|
-
const script =
|
|
22938
|
+
const script = join57(getPythonDir(), "list_devices.py");
|
|
22799
22939
|
spawnSync5(getVenvPython(), [script], { stdio: "inherit" });
|
|
22800
22940
|
}
|
|
22801
22941
|
|
|
22802
22942
|
// src/commands/voice/logs.ts
|
|
22803
|
-
import { existsSync as
|
|
22943
|
+
import { existsSync as existsSync48, readFileSync as readFileSync42 } from "fs";
|
|
22804
22944
|
function logs(options2) {
|
|
22805
|
-
if (!
|
|
22945
|
+
if (!existsSync48(voicePaths.log)) {
|
|
22806
22946
|
console.log("No voice log file found");
|
|
22807
22947
|
return;
|
|
22808
22948
|
}
|
|
22809
22949
|
const count7 = Number.parseInt(options2.lines ?? "150", 10);
|
|
22810
|
-
const content =
|
|
22950
|
+
const content = readFileSync42(voicePaths.log, "utf8").trim();
|
|
22811
22951
|
if (!content) {
|
|
22812
22952
|
console.log("Voice log is empty");
|
|
22813
22953
|
return;
|
|
@@ -22829,13 +22969,13 @@ function logs(options2) {
|
|
|
22829
22969
|
|
|
22830
22970
|
// src/commands/voice/setup.ts
|
|
22831
22971
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
22832
|
-
import { mkdirSync as
|
|
22833
|
-
import { join as
|
|
22972
|
+
import { mkdirSync as mkdirSync21 } from "fs";
|
|
22973
|
+
import { join as join59 } from "path";
|
|
22834
22974
|
|
|
22835
22975
|
// src/commands/voice/checkLockFile.ts
|
|
22836
22976
|
import { execSync as execSync55 } from "child_process";
|
|
22837
|
-
import { existsSync as
|
|
22838
|
-
import { join as
|
|
22977
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync39 } from "fs";
|
|
22978
|
+
import { join as join58 } from "path";
|
|
22839
22979
|
function isProcessAlive2(pid) {
|
|
22840
22980
|
try {
|
|
22841
22981
|
process.kill(pid, 0);
|
|
@@ -22846,9 +22986,9 @@ function isProcessAlive2(pid) {
|
|
|
22846
22986
|
}
|
|
22847
22987
|
function checkLockFile() {
|
|
22848
22988
|
const lockFile = getLockFile();
|
|
22849
|
-
if (!
|
|
22989
|
+
if (!existsSync49(lockFile)) return;
|
|
22850
22990
|
try {
|
|
22851
|
-
const lock2 = JSON.parse(
|
|
22991
|
+
const lock2 = JSON.parse(readFileSync43(lockFile, "utf8"));
|
|
22852
22992
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
22853
22993
|
console.error(
|
|
22854
22994
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -22859,7 +22999,7 @@ function checkLockFile() {
|
|
|
22859
22999
|
}
|
|
22860
23000
|
}
|
|
22861
23001
|
function bootstrapVenv() {
|
|
22862
|
-
if (
|
|
23002
|
+
if (existsSync49(getVenvPython())) return;
|
|
22863
23003
|
console.log("Setting up Python environment...");
|
|
22864
23004
|
const pythonDir = getPythonDir();
|
|
22865
23005
|
execSync55(
|
|
@@ -22872,8 +23012,8 @@ function bootstrapVenv() {
|
|
|
22872
23012
|
}
|
|
22873
23013
|
function writeLockFile(pid) {
|
|
22874
23014
|
const lockFile = getLockFile();
|
|
22875
|
-
|
|
22876
|
-
|
|
23015
|
+
mkdirSync20(join58(lockFile, ".."), { recursive: true });
|
|
23016
|
+
writeFileSync39(
|
|
22877
23017
|
lockFile,
|
|
22878
23018
|
JSON.stringify({
|
|
22879
23019
|
pid,
|
|
@@ -22885,10 +23025,10 @@ function writeLockFile(pid) {
|
|
|
22885
23025
|
|
|
22886
23026
|
// src/commands/voice/setup.ts
|
|
22887
23027
|
function setup() {
|
|
22888
|
-
|
|
23028
|
+
mkdirSync21(voicePaths.dir, { recursive: true });
|
|
22889
23029
|
bootstrapVenv();
|
|
22890
23030
|
console.log("\nDownloading models...\n");
|
|
22891
|
-
const script =
|
|
23031
|
+
const script = join59(getPythonDir(), "setup_models.py");
|
|
22892
23032
|
const result = spawnSync6(getVenvPython(), [script], {
|
|
22893
23033
|
stdio: "inherit",
|
|
22894
23034
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -22901,8 +23041,8 @@ function setup() {
|
|
|
22901
23041
|
|
|
22902
23042
|
// src/commands/voice/start.ts
|
|
22903
23043
|
import { spawn as spawn7 } from "child_process";
|
|
22904
|
-
import { mkdirSync as
|
|
22905
|
-
import { join as
|
|
23044
|
+
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync40 } from "fs";
|
|
23045
|
+
import { join as join60 } from "path";
|
|
22906
23046
|
|
|
22907
23047
|
// src/commands/voice/buildDaemonEnv.ts
|
|
22908
23048
|
function buildDaemonEnv(options2) {
|
|
@@ -22930,17 +23070,17 @@ function spawnBackground(python, script, env) {
|
|
|
22930
23070
|
console.error("Failed to start voice daemon");
|
|
22931
23071
|
process.exit(1);
|
|
22932
23072
|
}
|
|
22933
|
-
|
|
23073
|
+
writeFileSync40(voicePaths.pid, String(pid));
|
|
22934
23074
|
writeLockFile(pid);
|
|
22935
23075
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
22936
23076
|
}
|
|
22937
23077
|
function start2(options2) {
|
|
22938
|
-
|
|
23078
|
+
mkdirSync22(voicePaths.dir, { recursive: true });
|
|
22939
23079
|
checkLockFile();
|
|
22940
23080
|
bootstrapVenv();
|
|
22941
23081
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
22942
23082
|
const env = buildDaemonEnv({ debug });
|
|
22943
|
-
const script =
|
|
23083
|
+
const script = join60(getPythonDir(), "voice_daemon.py");
|
|
22944
23084
|
const python = getVenvPython();
|
|
22945
23085
|
if (options2.foreground) {
|
|
22946
23086
|
spawnForeground(python, script, env);
|
|
@@ -22950,7 +23090,7 @@ function start2(options2) {
|
|
|
22950
23090
|
}
|
|
22951
23091
|
|
|
22952
23092
|
// src/commands/voice/status.ts
|
|
22953
|
-
import { existsSync as
|
|
23093
|
+
import { existsSync as existsSync50, readFileSync as readFileSync44 } from "fs";
|
|
22954
23094
|
function isProcessAlive3(pid) {
|
|
22955
23095
|
try {
|
|
22956
23096
|
process.kill(pid, 0);
|
|
@@ -22960,16 +23100,16 @@ function isProcessAlive3(pid) {
|
|
|
22960
23100
|
}
|
|
22961
23101
|
}
|
|
22962
23102
|
function readRecentLogs(count7) {
|
|
22963
|
-
if (!
|
|
22964
|
-
const lines =
|
|
23103
|
+
if (!existsSync50(voicePaths.log)) return [];
|
|
23104
|
+
const lines = readFileSync44(voicePaths.log, "utf8").trim().split("\n");
|
|
22965
23105
|
return lines.slice(-count7);
|
|
22966
23106
|
}
|
|
22967
23107
|
function status2() {
|
|
22968
|
-
if (!
|
|
23108
|
+
if (!existsSync50(voicePaths.pid)) {
|
|
22969
23109
|
console.log("Voice daemon: not running (no PID file)");
|
|
22970
23110
|
return;
|
|
22971
23111
|
}
|
|
22972
|
-
const pid = Number.parseInt(
|
|
23112
|
+
const pid = Number.parseInt(readFileSync44(voicePaths.pid, "utf8").trim(), 10);
|
|
22973
23113
|
const alive = isProcessAlive3(pid);
|
|
22974
23114
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
22975
23115
|
const recent = readRecentLogs(5);
|
|
@@ -22988,13 +23128,13 @@ function status2() {
|
|
|
22988
23128
|
}
|
|
22989
23129
|
|
|
22990
23130
|
// src/commands/voice/stop.ts
|
|
22991
|
-
import { existsSync as
|
|
23131
|
+
import { existsSync as existsSync51, readFileSync as readFileSync45, unlinkSync as unlinkSync19 } from "fs";
|
|
22992
23132
|
function stop2() {
|
|
22993
|
-
if (!
|
|
23133
|
+
if (!existsSync51(voicePaths.pid)) {
|
|
22994
23134
|
console.log("Voice daemon is not running (no PID file)");
|
|
22995
23135
|
return;
|
|
22996
23136
|
}
|
|
22997
|
-
const pid = Number.parseInt(
|
|
23137
|
+
const pid = Number.parseInt(readFileSync45(voicePaths.pid, "utf8").trim(), 10);
|
|
22998
23138
|
try {
|
|
22999
23139
|
process.kill(pid, "SIGTERM");
|
|
23000
23140
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -23002,12 +23142,12 @@ function stop2() {
|
|
|
23002
23142
|
console.log(`Voice daemon (PID ${pid}) is not running`);
|
|
23003
23143
|
}
|
|
23004
23144
|
try {
|
|
23005
|
-
|
|
23145
|
+
unlinkSync19(voicePaths.pid);
|
|
23006
23146
|
} catch {
|
|
23007
23147
|
}
|
|
23008
23148
|
try {
|
|
23009
23149
|
const lockFile = getLockFile();
|
|
23010
|
-
if (
|
|
23150
|
+
if (existsSync51(lockFile)) unlinkSync19(lockFile);
|
|
23011
23151
|
} catch {
|
|
23012
23152
|
}
|
|
23013
23153
|
console.log("Voice daemon stopped");
|
|
@@ -23071,7 +23211,7 @@ function registerVoice(program2) {
|
|
|
23071
23211
|
|
|
23072
23212
|
// src/commands/roam/auth.ts
|
|
23073
23213
|
import { randomBytes } from "crypto";
|
|
23074
|
-
import
|
|
23214
|
+
import chalk197 from "chalk";
|
|
23075
23215
|
|
|
23076
23216
|
// src/commands/roam/waitForCallback.ts
|
|
23077
23217
|
import { createServer as createServer3 } from "http";
|
|
@@ -23202,13 +23342,13 @@ async function auth() {
|
|
|
23202
23342
|
saveGlobalConfig(config);
|
|
23203
23343
|
const state = randomBytes(16).toString("hex");
|
|
23204
23344
|
console.log(
|
|
23205
|
-
|
|
23345
|
+
chalk197.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
23206
23346
|
);
|
|
23207
|
-
console.log(
|
|
23208
|
-
console.log(
|
|
23209
|
-
console.log(
|
|
23347
|
+
console.log(chalk197.white("http://localhost:14523/callback\n"));
|
|
23348
|
+
console.log(chalk197.blue("Opening browser for authorization..."));
|
|
23349
|
+
console.log(chalk197.dim("Waiting for authorization callback..."));
|
|
23210
23350
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
23211
|
-
console.log(
|
|
23351
|
+
console.log(chalk197.dim("Exchanging code for tokens..."));
|
|
23212
23352
|
const tokens = await exchangeToken({
|
|
23213
23353
|
code,
|
|
23214
23354
|
clientId,
|
|
@@ -23224,14 +23364,14 @@ async function auth() {
|
|
|
23224
23364
|
};
|
|
23225
23365
|
saveGlobalConfig(config);
|
|
23226
23366
|
console.log(
|
|
23227
|
-
|
|
23367
|
+
chalk197.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
23228
23368
|
);
|
|
23229
23369
|
}
|
|
23230
23370
|
|
|
23231
23371
|
// src/commands/roam/postRoamActivity.ts
|
|
23232
23372
|
import { execFileSync as execFileSync9 } from "child_process";
|
|
23233
|
-
import { readdirSync as readdirSync11, readFileSync as
|
|
23234
|
-
import { join as
|
|
23373
|
+
import { readdirSync as readdirSync11, readFileSync as readFileSync46, statSync as statSync8 } from "fs";
|
|
23374
|
+
import { join as join61 } from "path";
|
|
23235
23375
|
function findPortFile(roamDir) {
|
|
23236
23376
|
let entries;
|
|
23237
23377
|
try {
|
|
@@ -23240,7 +23380,7 @@ function findPortFile(roamDir) {
|
|
|
23240
23380
|
return void 0;
|
|
23241
23381
|
}
|
|
23242
23382
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
23243
|
-
const path67 =
|
|
23383
|
+
const path67 = join61(roamDir, name);
|
|
23244
23384
|
try {
|
|
23245
23385
|
return { path: path67, mtimeMs: statSync8(path67).mtimeMs };
|
|
23246
23386
|
} catch {
|
|
@@ -23252,11 +23392,11 @@ function findPortFile(roamDir) {
|
|
|
23252
23392
|
function postRoamActivity(app, event) {
|
|
23253
23393
|
const appData = process.env.APPDATA;
|
|
23254
23394
|
if (!appData) return;
|
|
23255
|
-
const portFile = findPortFile(
|
|
23395
|
+
const portFile = findPortFile(join61(appData, "Roam"));
|
|
23256
23396
|
if (!portFile) return;
|
|
23257
23397
|
let port;
|
|
23258
23398
|
try {
|
|
23259
|
-
port =
|
|
23399
|
+
port = readFileSync46(portFile, "utf8").trim();
|
|
23260
23400
|
} catch {
|
|
23261
23401
|
return;
|
|
23262
23402
|
}
|
|
@@ -23472,15 +23612,15 @@ function runPreCommands(pre, cwd) {
|
|
|
23472
23612
|
|
|
23473
23613
|
// src/commands/run/spawnRunCommand.ts
|
|
23474
23614
|
import { execFileSync as execFileSync10, spawn as spawn8 } from "child_process";
|
|
23475
|
-
import { existsSync as
|
|
23476
|
-
import { dirname as dirname27, join as
|
|
23615
|
+
import { existsSync as existsSync52 } from "fs";
|
|
23616
|
+
import { dirname as dirname27, join as join62, resolve as resolve13 } from "path";
|
|
23477
23617
|
function resolveCommand2(command) {
|
|
23478
23618
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
23479
23619
|
try {
|
|
23480
23620
|
const gitPath = execFileSync10("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
23481
23621
|
const gitRoot = resolve13(dirname27(gitPath), "..");
|
|
23482
|
-
const gitBash =
|
|
23483
|
-
if (
|
|
23622
|
+
const gitBash = join62(gitRoot, "bin", "bash.exe");
|
|
23623
|
+
if (existsSync52(gitBash)) return gitBash;
|
|
23484
23624
|
} catch {
|
|
23485
23625
|
}
|
|
23486
23626
|
return command;
|
|
@@ -23567,8 +23707,8 @@ async function run3(name, args) {
|
|
|
23567
23707
|
}
|
|
23568
23708
|
|
|
23569
23709
|
// src/commands/run/add.ts
|
|
23570
|
-
import { mkdirSync as
|
|
23571
|
-
import { join as
|
|
23710
|
+
import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync41 } from "fs";
|
|
23711
|
+
import { join as join63 } from "path";
|
|
23572
23712
|
|
|
23573
23713
|
// src/commands/run/extractOption.ts
|
|
23574
23714
|
function extractOption(args, flag) {
|
|
@@ -23629,16 +23769,16 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
23629
23769
|
saveConfig(config);
|
|
23630
23770
|
}
|
|
23631
23771
|
function createCommandFile(name) {
|
|
23632
|
-
const dir =
|
|
23633
|
-
|
|
23772
|
+
const dir = join63(".claude", "commands");
|
|
23773
|
+
mkdirSync23(dir, { recursive: true });
|
|
23634
23774
|
const content = `---
|
|
23635
23775
|
description: Run ${name}
|
|
23636
23776
|
---
|
|
23637
23777
|
|
|
23638
23778
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
23639
23779
|
`;
|
|
23640
|
-
const filePath =
|
|
23641
|
-
|
|
23780
|
+
const filePath = join63(dir, `${name}.md`);
|
|
23781
|
+
writeFileSync41(filePath, content);
|
|
23642
23782
|
console.log(`Created command file: ${filePath}`);
|
|
23643
23783
|
}
|
|
23644
23784
|
function add3() {
|
|
@@ -23693,8 +23833,8 @@ function link2() {
|
|
|
23693
23833
|
}
|
|
23694
23834
|
|
|
23695
23835
|
// src/commands/run/remove.ts
|
|
23696
|
-
import { existsSync as
|
|
23697
|
-
import { join as
|
|
23836
|
+
import { existsSync as existsSync53, unlinkSync as unlinkSync20 } from "fs";
|
|
23837
|
+
import { join as join64 } from "path";
|
|
23698
23838
|
function findRemoveIndex() {
|
|
23699
23839
|
const idx = process.argv.indexOf("remove");
|
|
23700
23840
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -23709,9 +23849,9 @@ function parseRemoveName() {
|
|
|
23709
23849
|
return process.argv[idx + 1];
|
|
23710
23850
|
}
|
|
23711
23851
|
function deleteCommandFile(name) {
|
|
23712
|
-
const filePath =
|
|
23713
|
-
if (
|
|
23714
|
-
|
|
23852
|
+
const filePath = join64(".claude", "commands", `${name}.md`);
|
|
23853
|
+
if (existsSync53(filePath)) {
|
|
23854
|
+
unlinkSync20(filePath);
|
|
23715
23855
|
console.log(`Deleted command file: ${filePath}`);
|
|
23716
23856
|
}
|
|
23717
23857
|
}
|
|
@@ -23764,10 +23904,10 @@ function registerRun(program2) {
|
|
|
23764
23904
|
|
|
23765
23905
|
// src/commands/screenshot/index.ts
|
|
23766
23906
|
import { execSync as execSync57 } from "child_process";
|
|
23767
|
-
import { existsSync as
|
|
23907
|
+
import { existsSync as existsSync54, mkdirSync as mkdirSync24, unlinkSync as unlinkSync21, writeFileSync as writeFileSync42 } from "fs";
|
|
23768
23908
|
import { tmpdir as tmpdir7 } from "os";
|
|
23769
|
-
import { join as
|
|
23770
|
-
import
|
|
23909
|
+
import { join as join65, resolve as resolve15 } from "path";
|
|
23910
|
+
import chalk198 from "chalk";
|
|
23771
23911
|
|
|
23772
23912
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
23773
23913
|
var captureWindowPs1 = `
|
|
@@ -23896,35 +24036,35 @@ Write-Output $OutputPath
|
|
|
23896
24036
|
|
|
23897
24037
|
// src/commands/screenshot/index.ts
|
|
23898
24038
|
function buildOutputPath(outputDir, processName) {
|
|
23899
|
-
if (!
|
|
23900
|
-
|
|
24039
|
+
if (!existsSync54(outputDir)) {
|
|
24040
|
+
mkdirSync24(outputDir, { recursive: true });
|
|
23901
24041
|
}
|
|
23902
24042
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
23903
24043
|
return resolve15(outputDir, `${processName}-${timestamp6}.png`);
|
|
23904
24044
|
}
|
|
23905
24045
|
function runPowerShellScript(processName, outputPath) {
|
|
23906
|
-
const scriptPath =
|
|
23907
|
-
|
|
24046
|
+
const scriptPath = join65(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
24047
|
+
writeFileSync42(scriptPath, captureWindowPs1, "utf8");
|
|
23908
24048
|
try {
|
|
23909
24049
|
execSync57(
|
|
23910
24050
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
23911
24051
|
{ stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" }
|
|
23912
24052
|
);
|
|
23913
24053
|
} finally {
|
|
23914
|
-
|
|
24054
|
+
unlinkSync21(scriptPath);
|
|
23915
24055
|
}
|
|
23916
24056
|
}
|
|
23917
24057
|
function screenshot(processName) {
|
|
23918
24058
|
const config = loadConfig();
|
|
23919
24059
|
const outputDir = resolve15(config.screenshot.outputDir);
|
|
23920
24060
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
23921
|
-
console.log(
|
|
24061
|
+
console.log(chalk198.gray(`Capturing window for process "${processName}" ...`));
|
|
23922
24062
|
try {
|
|
23923
24063
|
runPowerShellScript(processName, outputPath);
|
|
23924
|
-
console.log(
|
|
24064
|
+
console.log(chalk198.green(`Screenshot saved: ${outputPath}`));
|
|
23925
24065
|
} catch (error) {
|
|
23926
24066
|
const msg = error instanceof Error ? error.message : String(error);
|
|
23927
|
-
console.error(
|
|
24067
|
+
console.error(chalk198.red(`Failed to capture screenshot: ${msg}`));
|
|
23928
24068
|
process.exit(1);
|
|
23929
24069
|
}
|
|
23930
24070
|
}
|
|
@@ -23980,7 +24120,7 @@ function applyLine(result, pending, line) {
|
|
|
23980
24120
|
}
|
|
23981
24121
|
|
|
23982
24122
|
// src/commands/sessions/daemon/reportStolenSocket.ts
|
|
23983
|
-
import { readFileSync as
|
|
24123
|
+
import { readFileSync as readFileSync47 } from "fs";
|
|
23984
24124
|
function reportStolenSocket(socketPid) {
|
|
23985
24125
|
if (!socketPid) return;
|
|
23986
24126
|
const filePid = readPidFile();
|
|
@@ -23992,7 +24132,7 @@ function reportStolenSocket(socketPid) {
|
|
|
23992
24132
|
function readPidFile() {
|
|
23993
24133
|
try {
|
|
23994
24134
|
const pid = Number.parseInt(
|
|
23995
|
-
|
|
24135
|
+
readFileSync47(daemonPaths.pid, "utf8").trim(),
|
|
23996
24136
|
10
|
|
23997
24137
|
);
|
|
23998
24138
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -24171,7 +24311,7 @@ function requestDrain(socket) {
|
|
|
24171
24311
|
}
|
|
24172
24312
|
|
|
24173
24313
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
24174
|
-
import { mkdirSync as
|
|
24314
|
+
import { mkdirSync as mkdirSync26 } from "fs";
|
|
24175
24315
|
|
|
24176
24316
|
// src/commands/sessions/daemon/createAutoExit.ts
|
|
24177
24317
|
var DEFAULT_GRACE_MS = 6e4;
|
|
@@ -24379,7 +24519,7 @@ var ClientHub = class extends Set {
|
|
|
24379
24519
|
import * as pty from "node-pty";
|
|
24380
24520
|
|
|
24381
24521
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
24382
|
-
import { chmodSync, existsSync as
|
|
24522
|
+
import { chmodSync, existsSync as existsSync55, statSync as statSync9 } from "fs";
|
|
24383
24523
|
import { createRequire as createRequire3 } from "module";
|
|
24384
24524
|
import path55 from "path";
|
|
24385
24525
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -24394,7 +24534,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
24394
24534
|
`${process.platform}-${process.arch}`,
|
|
24395
24535
|
"spawn-helper"
|
|
24396
24536
|
);
|
|
24397
|
-
if (!
|
|
24537
|
+
if (!existsSync55(helper)) return;
|
|
24398
24538
|
const mode = statSync9(helper).mode;
|
|
24399
24539
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
24400
24540
|
}
|
|
@@ -24938,7 +25078,7 @@ function errorTail(scrollback) {
|
|
|
24938
25078
|
}
|
|
24939
25079
|
|
|
24940
25080
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
24941
|
-
import { existsSync as
|
|
25081
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync25, watch } from "fs";
|
|
24942
25082
|
import { dirname as dirname29 } from "path";
|
|
24943
25083
|
|
|
24944
25084
|
// src/commands/sessions/daemon/applyReviewPause.ts
|
|
@@ -24995,7 +25135,7 @@ function watchActivity(session, notify2) {
|
|
|
24995
25135
|
const path67 = activityPath(session.id);
|
|
24996
25136
|
const dir = dirname29(path67);
|
|
24997
25137
|
try {
|
|
24998
|
-
|
|
25138
|
+
mkdirSync25(dir, { recursive: true });
|
|
24999
25139
|
} catch {
|
|
25000
25140
|
return;
|
|
25001
25141
|
}
|
|
@@ -25017,7 +25157,7 @@ function watchActivity(session, notify2) {
|
|
|
25017
25157
|
if (timer) clearTimeout(timer);
|
|
25018
25158
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
25019
25159
|
});
|
|
25020
|
-
if (
|
|
25160
|
+
if (existsSync56(path67)) read();
|
|
25021
25161
|
}
|
|
25022
25162
|
function refreshActivity(session) {
|
|
25023
25163
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -25596,14 +25736,14 @@ async function defaultConnect() {
|
|
|
25596
25736
|
}
|
|
25597
25737
|
|
|
25598
25738
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
25599
|
-
import { existsSync as
|
|
25739
|
+
import { existsSync as existsSync57, readFileSync as readFileSync49 } from "fs";
|
|
25600
25740
|
import { posix } from "path";
|
|
25601
25741
|
function hasPersistedWindowsSessions() {
|
|
25602
25742
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
25603
25743
|
if (!sessionsFile) return false;
|
|
25604
25744
|
try {
|
|
25605
|
-
if (!
|
|
25606
|
-
const data = JSON.parse(
|
|
25745
|
+
if (!existsSync57(sessionsFile)) return false;
|
|
25746
|
+
const data = JSON.parse(readFileSync49(sessionsFile, "utf8"));
|
|
25607
25747
|
return Array.isArray(data) && data.length > 0;
|
|
25608
25748
|
} catch (error) {
|
|
25609
25749
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -26341,7 +26481,7 @@ var SessionManager = class {
|
|
|
26341
26481
|
};
|
|
26342
26482
|
|
|
26343
26483
|
// src/commands/sessions/daemon/startDaemonServer.ts
|
|
26344
|
-
import { unlinkSync as
|
|
26484
|
+
import { unlinkSync as unlinkSync23 } from "fs";
|
|
26345
26485
|
import * as net3 from "net";
|
|
26346
26486
|
|
|
26347
26487
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
@@ -26586,10 +26726,10 @@ function handleConnection(socket, manager) {
|
|
|
26586
26726
|
}
|
|
26587
26727
|
|
|
26588
26728
|
// src/commands/sessions/daemon/onListening.ts
|
|
26589
|
-
import { unlinkSync as
|
|
26729
|
+
import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync43 } from "fs";
|
|
26590
26730
|
|
|
26591
26731
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
26592
|
-
import { readFileSync as
|
|
26732
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
26593
26733
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
26594
26734
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
26595
26735
|
const timer = setInterval(() => {
|
|
@@ -26600,7 +26740,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
26600
26740
|
}
|
|
26601
26741
|
function ownsPidFile() {
|
|
26602
26742
|
try {
|
|
26603
|
-
return
|
|
26743
|
+
return readFileSync50(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
26604
26744
|
} catch {
|
|
26605
26745
|
return false;
|
|
26606
26746
|
}
|
|
@@ -26608,7 +26748,7 @@ function ownsPidFile() {
|
|
|
26608
26748
|
|
|
26609
26749
|
// src/commands/sessions/daemon/onListening.ts
|
|
26610
26750
|
function onListening(manager, checkAutoExit) {
|
|
26611
|
-
|
|
26751
|
+
writeFileSync43(daemonPaths.pid, String(process.pid));
|
|
26612
26752
|
startPidFileWatchdog(() => {
|
|
26613
26753
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
26614
26754
|
void manager.flushActiveMs().finally(() => {
|
|
@@ -26629,12 +26769,12 @@ function onListening(manager, checkAutoExit) {
|
|
|
26629
26769
|
function cleanupOwnedFiles() {
|
|
26630
26770
|
if (!ownsPidFile()) return;
|
|
26631
26771
|
try {
|
|
26632
|
-
|
|
26772
|
+
unlinkSync22(daemonPaths.pid);
|
|
26633
26773
|
} catch {
|
|
26634
26774
|
}
|
|
26635
26775
|
if (process.platform !== "win32") {
|
|
26636
26776
|
try {
|
|
26637
|
-
|
|
26777
|
+
unlinkSync22(daemonPaths.socket);
|
|
26638
26778
|
} catch {
|
|
26639
26779
|
}
|
|
26640
26780
|
}
|
|
@@ -26681,7 +26821,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
26681
26821
|
daemonLog("removing stale socket left by a crashed daemon");
|
|
26682
26822
|
if (process.platform !== "win32") {
|
|
26683
26823
|
try {
|
|
26684
|
-
|
|
26824
|
+
unlinkSync23(daemonPaths.socket);
|
|
26685
26825
|
} catch {
|
|
26686
26826
|
}
|
|
26687
26827
|
}
|
|
@@ -26690,7 +26830,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
26690
26830
|
|
|
26691
26831
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
26692
26832
|
async function runDaemon() {
|
|
26693
|
-
|
|
26833
|
+
mkdirSync26(daemonPaths.dir, { recursive: true });
|
|
26694
26834
|
daemonLog(
|
|
26695
26835
|
`starting (reason: ${process.env.ASSIST_DAEMON_SPAWN_REASON ?? "manual"})`
|
|
26696
26836
|
);
|
|
@@ -26730,7 +26870,7 @@ function registerDaemon(program2) {
|
|
|
26730
26870
|
|
|
26731
26871
|
// src/commands/sessions/summarise/index.ts
|
|
26732
26872
|
import * as fs38 from "fs";
|
|
26733
|
-
import
|
|
26873
|
+
import chalk199 from "chalk";
|
|
26734
26874
|
|
|
26735
26875
|
// src/commands/sessions/summarise/shared.ts
|
|
26736
26876
|
import * as fs37 from "fs";
|
|
@@ -26804,22 +26944,22 @@ ${firstMessage}`);
|
|
|
26804
26944
|
async function summarise2(options2) {
|
|
26805
26945
|
const files = await discoverSessionFiles();
|
|
26806
26946
|
if (files.length === 0) {
|
|
26807
|
-
console.log(
|
|
26947
|
+
console.log(chalk199.yellow("No sessions found."));
|
|
26808
26948
|
return;
|
|
26809
26949
|
}
|
|
26810
26950
|
const toProcess = selectCandidates(files, options2);
|
|
26811
26951
|
if (toProcess.length === 0) {
|
|
26812
|
-
console.log(
|
|
26952
|
+
console.log(chalk199.green("All sessions already summarised."));
|
|
26813
26953
|
return;
|
|
26814
26954
|
}
|
|
26815
26955
|
console.log(
|
|
26816
|
-
|
|
26956
|
+
chalk199.cyan(
|
|
26817
26957
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
26818
26958
|
)
|
|
26819
26959
|
);
|
|
26820
26960
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
26821
26961
|
console.log(
|
|
26822
|
-
|
|
26962
|
+
chalk199.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk199.yellow(`, ${failed2} skipped`) : "")
|
|
26823
26963
|
);
|
|
26824
26964
|
}
|
|
26825
26965
|
function selectCandidates(files, options2) {
|
|
@@ -26839,16 +26979,16 @@ function processSessions(files) {
|
|
|
26839
26979
|
let failed2 = 0;
|
|
26840
26980
|
for (let i = 0; i < files.length; i++) {
|
|
26841
26981
|
const file = files[i];
|
|
26842
|
-
process.stdout.write(
|
|
26982
|
+
process.stdout.write(chalk199.dim(` [${i + 1}/${files.length}] `));
|
|
26843
26983
|
const summary = summariseSession(file);
|
|
26844
26984
|
if (summary) {
|
|
26845
26985
|
writeSummary(file, summary);
|
|
26846
26986
|
succeeded++;
|
|
26847
|
-
process.stdout.write(`${
|
|
26987
|
+
process.stdout.write(`${chalk199.green("\u2713")} ${summary}
|
|
26848
26988
|
`);
|
|
26849
26989
|
} else {
|
|
26850
26990
|
failed2++;
|
|
26851
|
-
process.stdout.write(` ${
|
|
26991
|
+
process.stdout.write(` ${chalk199.yellow("skip")}
|
|
26852
26992
|
`);
|
|
26853
26993
|
}
|
|
26854
26994
|
}
|
|
@@ -26892,7 +27032,7 @@ function registerSessions(program2) {
|
|
|
26892
27032
|
}
|
|
26893
27033
|
|
|
26894
27034
|
// src/commands/statusLine.ts
|
|
26895
|
-
import
|
|
27035
|
+
import chalk201 from "chalk";
|
|
26896
27036
|
|
|
26897
27037
|
// src/shared/contextLevel.ts
|
|
26898
27038
|
function contextLevel(pct) {
|
|
@@ -26902,7 +27042,7 @@ function contextLevel(pct) {
|
|
|
26902
27042
|
}
|
|
26903
27043
|
|
|
26904
27044
|
// src/commands/buildLimitsSegment.ts
|
|
26905
|
-
import
|
|
27045
|
+
import chalk200 from "chalk";
|
|
26906
27046
|
|
|
26907
27047
|
// src/shared/rateLimitLevel.ts
|
|
26908
27048
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -26933,9 +27073,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
26933
27073
|
|
|
26934
27074
|
// src/commands/buildLimitsSegment.ts
|
|
26935
27075
|
var LEVEL_COLOR = {
|
|
26936
|
-
ok:
|
|
26937
|
-
warn:
|
|
26938
|
-
over:
|
|
27076
|
+
ok: chalk200.green,
|
|
27077
|
+
warn: chalk200.yellow,
|
|
27078
|
+
over: chalk200.red
|
|
26939
27079
|
};
|
|
26940
27080
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
26941
27081
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -26966,10 +27106,10 @@ function buildLimitsSegment(rateLimits) {
|
|
|
26966
27106
|
}
|
|
26967
27107
|
|
|
26968
27108
|
// src/commands/readGitBranch.ts
|
|
26969
|
-
import { readFileSync as
|
|
26970
|
-
import { isAbsolute as isAbsolute2, join as
|
|
27109
|
+
import { readFileSync as readFileSync52, statSync as statSync11 } from "fs";
|
|
27110
|
+
import { isAbsolute as isAbsolute2, join as join67, resolve as resolve16 } from "path";
|
|
26971
27111
|
function resolveGitDir(cwd) {
|
|
26972
|
-
const dotGit =
|
|
27112
|
+
const dotGit = join67(cwd, ".git");
|
|
26973
27113
|
let stat2;
|
|
26974
27114
|
try {
|
|
26975
27115
|
stat2 = statSync11(dotGit);
|
|
@@ -26981,7 +27121,7 @@ function resolveGitDir(cwd) {
|
|
|
26981
27121
|
}
|
|
26982
27122
|
let contents;
|
|
26983
27123
|
try {
|
|
26984
|
-
contents =
|
|
27124
|
+
contents = readFileSync52(dotGit, "utf8");
|
|
26985
27125
|
} catch {
|
|
26986
27126
|
return null;
|
|
26987
27127
|
}
|
|
@@ -26999,7 +27139,7 @@ function readGitBranch(cwd) {
|
|
|
26999
27139
|
}
|
|
27000
27140
|
let head;
|
|
27001
27141
|
try {
|
|
27002
|
-
head =
|
|
27142
|
+
head = readFileSync52(join67(gitDir, "HEAD"), "utf8");
|
|
27003
27143
|
} catch {
|
|
27004
27144
|
return null;
|
|
27005
27145
|
}
|
|
@@ -27031,7 +27171,7 @@ async function relayUsage(claudeSessionId, transcriptPath, usedPct) {
|
|
|
27031
27171
|
}
|
|
27032
27172
|
|
|
27033
27173
|
// src/commands/statusLine.ts
|
|
27034
|
-
|
|
27174
|
+
chalk201.level = 3;
|
|
27035
27175
|
function formatNumber(num) {
|
|
27036
27176
|
return num.toLocaleString("en-US");
|
|
27037
27177
|
}
|
|
@@ -27039,9 +27179,9 @@ function colorizePercent(pct) {
|
|
|
27039
27179
|
const label2 = `${Math.round(pct)}%`;
|
|
27040
27180
|
switch (contextLevel(pct)) {
|
|
27041
27181
|
case "red":
|
|
27042
|
-
return
|
|
27182
|
+
return chalk201.red(label2);
|
|
27043
27183
|
case "yellow":
|
|
27044
|
-
return
|
|
27184
|
+
return chalk201.yellow(label2);
|
|
27045
27185
|
default:
|
|
27046
27186
|
return label2;
|
|
27047
27187
|
}
|
|
@@ -27054,7 +27194,7 @@ async function statusLine() {
|
|
|
27054
27194
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
27055
27195
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
27056
27196
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
27057
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
27197
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk201.cyan(branch2)} | ` : "";
|
|
27058
27198
|
console.log(
|
|
27059
27199
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
27060
27200
|
);
|
|
@@ -27075,7 +27215,7 @@ import { fileURLToPath as fileURLToPath9 } from "url";
|
|
|
27075
27215
|
// src/commands/sync/syncClaudeMd.ts
|
|
27076
27216
|
import * as fs39 from "fs";
|
|
27077
27217
|
import * as path57 from "path";
|
|
27078
|
-
import
|
|
27218
|
+
import chalk202 from "chalk";
|
|
27079
27219
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
27080
27220
|
const source = path57.join(claudeDir, "CLAUDE.md");
|
|
27081
27221
|
const target = path57.join(targetBase, "CLAUDE.md");
|
|
@@ -27084,12 +27224,12 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
27084
27224
|
const targetContent = fs39.readFileSync(target, "utf8");
|
|
27085
27225
|
if (sourceContent !== targetContent) {
|
|
27086
27226
|
console.log(
|
|
27087
|
-
|
|
27227
|
+
chalk202.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
27088
27228
|
);
|
|
27089
27229
|
console.log();
|
|
27090
27230
|
printDiff(targetContent, sourceContent);
|
|
27091
27231
|
const confirm = options2?.yes || await promptConfirm(
|
|
27092
|
-
|
|
27232
|
+
chalk202.red("Overwrite existing CLAUDE.md?"),
|
|
27093
27233
|
false
|
|
27094
27234
|
);
|
|
27095
27235
|
if (!confirm) {
|
|
@@ -27283,7 +27423,7 @@ function syncPi(claudeDir) {
|
|
|
27283
27423
|
// src/commands/sync/syncSettings.ts
|
|
27284
27424
|
import * as fs44 from "fs";
|
|
27285
27425
|
import * as path64 from "path";
|
|
27286
|
-
import
|
|
27426
|
+
import chalk203 from "chalk";
|
|
27287
27427
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
27288
27428
|
const source = path64.join(claudeDir, "settings.json");
|
|
27289
27429
|
const target = path64.join(targetBase, "settings.json");
|
|
@@ -27302,14 +27442,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
27302
27442
|
if (mergedContent !== normalizedTarget) {
|
|
27303
27443
|
if (!options2?.yes) {
|
|
27304
27444
|
console.log(
|
|
27305
|
-
|
|
27445
|
+
chalk203.yellow(
|
|
27306
27446
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
27307
27447
|
)
|
|
27308
27448
|
);
|
|
27309
27449
|
console.log();
|
|
27310
27450
|
printDiff(targetContent, mergedContent);
|
|
27311
27451
|
const confirm = await promptConfirm(
|
|
27312
|
-
|
|
27452
|
+
chalk203.red("Overwrite existing settings.json?"),
|
|
27313
27453
|
false
|
|
27314
27454
|
);
|
|
27315
27455
|
if (!confirm) {
|
|
@@ -27408,10 +27548,10 @@ async function update2() {
|
|
|
27408
27548
|
}
|
|
27409
27549
|
|
|
27410
27550
|
// src/reportCliError.ts
|
|
27411
|
-
import
|
|
27551
|
+
import chalk204 from "chalk";
|
|
27412
27552
|
function reportCliError(error) {
|
|
27413
27553
|
if (error instanceof InvalidItemIdError) {
|
|
27414
|
-
console.error(
|
|
27554
|
+
console.error(chalk204.red(error.message));
|
|
27415
27555
|
} else {
|
|
27416
27556
|
console.error(error);
|
|
27417
27557
|
}
|
|
@@ -27447,6 +27587,7 @@ configHelp(screenshotCommand, rootConfigHelp.screenshot);
|
|
|
27447
27587
|
registerActivity(program);
|
|
27448
27588
|
registerBackup(program);
|
|
27449
27589
|
registerDb(program);
|
|
27590
|
+
registerDbMigration(program);
|
|
27450
27591
|
registerCliHook(program);
|
|
27451
27592
|
registerCodeComment(program);
|
|
27452
27593
|
registerCodexHook(program);
|