@staff0rd/assist 0.405.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 +3 -1
- package/claude/commands/bug.md +18 -0
- package/claude/commands/draft.md +18 -0
- package/claude/commands/refine.md +10 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +714 -560
- 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: {
|
|
@@ -9610,8 +9610,18 @@ function fetchIssue(issueKey, fields) {
|
|
|
9610
9610
|
return JSON.parse(result);
|
|
9611
9611
|
}
|
|
9612
9612
|
|
|
9613
|
+
// src/commands/backlog/associate-jira/normalizeJiraKey.ts
|
|
9614
|
+
var KEY_PATTERN = /^[A-Z]+-\d+$/;
|
|
9615
|
+
var URL_PATTERN2 = /^https?:\/\/[^/\s]+\/browse\/([A-Za-z]+-\d+)(?:[/?#].*)?$/;
|
|
9616
|
+
function normalizeJiraKey(input) {
|
|
9617
|
+
const trimmed = input.trim();
|
|
9618
|
+
if (KEY_PATTERN.test(trimmed)) return trimmed;
|
|
9619
|
+
const match = URL_PATTERN2.exec(trimmed);
|
|
9620
|
+
if (match) return match[1].toUpperCase();
|
|
9621
|
+
return null;
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9613
9624
|
// src/commands/backlog/associate-jira/index.ts
|
|
9614
|
-
var JIRA_KEY_PATTERN = /^[A-Z]+-\d+$/;
|
|
9615
9625
|
async function associateJira(id, key, options2) {
|
|
9616
9626
|
const target = await beginAssociation(id, options2, { jiraKey: null }, "Jira");
|
|
9617
9627
|
if (!target) return;
|
|
@@ -9621,19 +9631,22 @@ async function associateJira(id, key, options2) {
|
|
|
9621
9631
|
process.exitCode = 1;
|
|
9622
9632
|
return;
|
|
9623
9633
|
}
|
|
9624
|
-
|
|
9634
|
+
const normalized = normalizeJiraKey(key);
|
|
9635
|
+
if (!normalized) {
|
|
9625
9636
|
console.log(
|
|
9626
|
-
chalk65.red(
|
|
9637
|
+
chalk65.red(
|
|
9638
|
+
`Malformed Jira key "${key}". Expected a key like PROJ-123 or a browse URL.`
|
|
9639
|
+
)
|
|
9627
9640
|
);
|
|
9628
9641
|
process.exitCode = 1;
|
|
9629
9642
|
return;
|
|
9630
9643
|
}
|
|
9631
|
-
const parsed = fetchIssue(
|
|
9644
|
+
const parsed = fetchIssue(normalized, "summary");
|
|
9632
9645
|
const fields = parsed?.fields;
|
|
9633
9646
|
const summary = fields?.summary;
|
|
9634
|
-
await orm.update(items).set({ jiraKey:
|
|
9647
|
+
await orm.update(items).set({ jiraKey: normalized, githubIssue: null }).where(eq19(items.id, itemId2));
|
|
9635
9648
|
console.log(
|
|
9636
|
-
chalk65.green(`Associated ${
|
|
9649
|
+
chalk65.green(`Associated ${normalized} with item ${formatItemId(itemId2)}.`),
|
|
9637
9650
|
summary ? chalk65.dim(`(${summary})`) : ""
|
|
9638
9651
|
);
|
|
9639
9652
|
}
|
|
@@ -13747,9 +13760,114 @@ function registerDb(program2) {
|
|
|
13747
13760
|
).action(status);
|
|
13748
13761
|
}
|
|
13749
13762
|
|
|
13750
|
-
// src/commands/
|
|
13751
|
-
import {
|
|
13763
|
+
// src/commands/dbMigration/dbMigrationConfirm.ts
|
|
13764
|
+
import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs";
|
|
13752
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";
|
|
13753
13871
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
13754
13872
|
if (!window.location.pathname.endsWith('/')) {
|
|
13755
13873
|
window.location.href = \`\${window.location.pathname}/\${window.location.search}\${window.location.hash}\`;
|
|
@@ -13757,24 +13875,24 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
13757
13875
|
</script>`;
|
|
13758
13876
|
function redirect() {
|
|
13759
13877
|
const indexPath = "index.html";
|
|
13760
|
-
if (!
|
|
13761
|
-
console.log(
|
|
13878
|
+
if (!existsSync33(indexPath)) {
|
|
13879
|
+
console.log(chalk126.yellow("No index.html found"));
|
|
13762
13880
|
return;
|
|
13763
13881
|
}
|
|
13764
|
-
const content =
|
|
13882
|
+
const content = readFileSync29(indexPath, "utf8");
|
|
13765
13883
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
13766
|
-
console.log(
|
|
13884
|
+
console.log(chalk126.dim("Trailing slash script already present"));
|
|
13767
13885
|
return;
|
|
13768
13886
|
}
|
|
13769
13887
|
const headCloseIndex = content.indexOf("</head>");
|
|
13770
13888
|
if (headCloseIndex === -1) {
|
|
13771
|
-
console.log(
|
|
13889
|
+
console.log(chalk126.red("Could not find </head> tag in index.html"));
|
|
13772
13890
|
return;
|
|
13773
13891
|
}
|
|
13774
13892
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
13775
13893
|
${content.slice(headCloseIndex)}`;
|
|
13776
|
-
|
|
13777
|
-
console.log(
|
|
13894
|
+
writeFileSync28(indexPath, newContent);
|
|
13895
|
+
console.log(chalk126.green("Added trailing slash redirect to index.html"));
|
|
13778
13896
|
}
|
|
13779
13897
|
|
|
13780
13898
|
// src/commands/registerDeploy.ts
|
|
@@ -13790,10 +13908,10 @@ import { basename as basename9 } from "path";
|
|
|
13790
13908
|
|
|
13791
13909
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
13792
13910
|
import { homedir as homedir18 } from "os";
|
|
13793
|
-
import { join as
|
|
13794
|
-
var BLOG_REPO_ROOT =
|
|
13911
|
+
import { join as join34 } from "path";
|
|
13912
|
+
var BLOG_REPO_ROOT = join34(homedir18(), "git/blog");
|
|
13795
13913
|
function loadBlogSkipDays(repoName) {
|
|
13796
|
-
const config = loadRawYaml(
|
|
13914
|
+
const config = loadRawYaml(join34(BLOG_REPO_ROOT, "assist.yml"));
|
|
13797
13915
|
const devlog = config.devlog;
|
|
13798
13916
|
const skip2 = devlog?.skip;
|
|
13799
13917
|
return new Set(skip2?.[repoName]);
|
|
@@ -13801,20 +13919,20 @@ function loadBlogSkipDays(repoName) {
|
|
|
13801
13919
|
|
|
13802
13920
|
// src/commands/devlog/shared.ts
|
|
13803
13921
|
import { execSync as execSync32 } from "child_process";
|
|
13804
|
-
import
|
|
13922
|
+
import chalk127 from "chalk";
|
|
13805
13923
|
|
|
13806
13924
|
// src/shared/getRepoName.ts
|
|
13807
|
-
import { existsSync as
|
|
13808
|
-
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";
|
|
13809
13927
|
function getRepoName() {
|
|
13810
13928
|
const config = loadConfig();
|
|
13811
13929
|
if (config.devlog?.name) {
|
|
13812
13930
|
return config.devlog.name;
|
|
13813
13931
|
}
|
|
13814
|
-
const packageJsonPath =
|
|
13815
|
-
if (
|
|
13932
|
+
const packageJsonPath = join35(process.cwd(), "package.json");
|
|
13933
|
+
if (existsSync34(packageJsonPath)) {
|
|
13816
13934
|
try {
|
|
13817
|
-
const content =
|
|
13935
|
+
const content = readFileSync30(packageJsonPath, "utf8");
|
|
13818
13936
|
const pkg = JSON.parse(content);
|
|
13819
13937
|
if (pkg.name) {
|
|
13820
13938
|
return pkg.name;
|
|
@@ -13826,9 +13944,9 @@ function getRepoName() {
|
|
|
13826
13944
|
}
|
|
13827
13945
|
|
|
13828
13946
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
13829
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
13830
|
-
import { join as
|
|
13831
|
-
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");
|
|
13832
13950
|
function extractFrontmatter(content) {
|
|
13833
13951
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
13834
13952
|
return fm?.[1] ?? null;
|
|
@@ -13856,7 +13974,7 @@ function readDevlogFiles(callback) {
|
|
|
13856
13974
|
try {
|
|
13857
13975
|
const files = readdirSync4(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
13858
13976
|
for (const file of files) {
|
|
13859
|
-
const content =
|
|
13977
|
+
const content = readFileSync31(join36(DEVLOG_DIR, file), "utf8");
|
|
13860
13978
|
const parsed = parseFrontmatter(content, file);
|
|
13861
13979
|
if (parsed) callback(parsed);
|
|
13862
13980
|
}
|
|
@@ -13910,13 +14028,13 @@ function shouldIgnoreCommit(files, ignorePaths) {
|
|
|
13910
14028
|
}
|
|
13911
14029
|
function printCommitsWithFiles(commits2, ignore3, verbose) {
|
|
13912
14030
|
for (const commit2 of commits2) {
|
|
13913
|
-
console.log(` ${
|
|
14031
|
+
console.log(` ${chalk127.yellow(commit2.hash)} ${commit2.message}`);
|
|
13914
14032
|
if (verbose) {
|
|
13915
14033
|
const visibleFiles = commit2.files.filter(
|
|
13916
14034
|
(file) => !ignore3.some((p) => file.startsWith(p))
|
|
13917
14035
|
);
|
|
13918
14036
|
for (const file of visibleFiles) {
|
|
13919
|
-
console.log(` ${
|
|
14037
|
+
console.log(` ${chalk127.dim(file)}`);
|
|
13920
14038
|
}
|
|
13921
14039
|
}
|
|
13922
14040
|
}
|
|
@@ -13941,15 +14059,15 @@ function parseGitLogCommits(output, ignore3, afterDate) {
|
|
|
13941
14059
|
}
|
|
13942
14060
|
|
|
13943
14061
|
// src/commands/devlog/list/printDateHeader.ts
|
|
13944
|
-
import
|
|
14062
|
+
import chalk128 from "chalk";
|
|
13945
14063
|
function printDateHeader(date, isSkipped, entries) {
|
|
13946
14064
|
if (isSkipped) {
|
|
13947
|
-
console.log(`${
|
|
14065
|
+
console.log(`${chalk128.bold.blue(date)} ${chalk128.dim("skipped")}`);
|
|
13948
14066
|
} else if (entries && entries.length > 0) {
|
|
13949
|
-
const entryInfo = entries.map((e) => `${
|
|
13950
|
-
console.log(`${
|
|
14067
|
+
const entryInfo = entries.map((e) => `${chalk128.green(e.version)} ${e.title}`).join(" | ");
|
|
14068
|
+
console.log(`${chalk128.bold.blue(date)} ${entryInfo}`);
|
|
13951
14069
|
} else {
|
|
13952
|
-
console.log(`${
|
|
14070
|
+
console.log(`${chalk128.bold.blue(date)} ${chalk128.red("\u26A0 devlog missing")}`);
|
|
13953
14071
|
}
|
|
13954
14072
|
}
|
|
13955
14073
|
|
|
@@ -14053,24 +14171,24 @@ function bumpVersion(version2, type) {
|
|
|
14053
14171
|
|
|
14054
14172
|
// src/commands/devlog/next/displayNextEntry/index.ts
|
|
14055
14173
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14056
|
-
import
|
|
14174
|
+
import chalk130 from "chalk";
|
|
14057
14175
|
|
|
14058
14176
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
14059
|
-
import
|
|
14177
|
+
import chalk129 from "chalk";
|
|
14060
14178
|
function displayVersion(conventional, firstHash, patchVersion, minorVersion) {
|
|
14061
14179
|
if (conventional && firstHash) {
|
|
14062
14180
|
const version2 = getVersionAtCommit(firstHash);
|
|
14063
14181
|
if (version2) {
|
|
14064
|
-
console.log(`${
|
|
14182
|
+
console.log(`${chalk129.bold("version:")} ${stripToMinor(version2)}`);
|
|
14065
14183
|
} else {
|
|
14066
|
-
console.log(`${
|
|
14184
|
+
console.log(`${chalk129.bold("version:")} ${chalk129.red("unknown")}`);
|
|
14067
14185
|
}
|
|
14068
14186
|
} else if (patchVersion && minorVersion) {
|
|
14069
14187
|
console.log(
|
|
14070
|
-
`${
|
|
14188
|
+
`${chalk129.bold("version:")} ${patchVersion} (patch) or ${minorVersion} (minor)`
|
|
14071
14189
|
);
|
|
14072
14190
|
} else {
|
|
14073
|
-
console.log(`${
|
|
14191
|
+
console.log(`${chalk129.bold("version:")} v0.1 (initial)`);
|
|
14074
14192
|
}
|
|
14075
14193
|
}
|
|
14076
14194
|
|
|
@@ -14118,16 +14236,16 @@ function noCommitsMessage(hasLastInfo) {
|
|
|
14118
14236
|
return hasLastInfo ? "No commits after last versioned entry" : "No commits found";
|
|
14119
14237
|
}
|
|
14120
14238
|
function logName(repoName) {
|
|
14121
|
-
console.log(`${
|
|
14239
|
+
console.log(`${chalk130.bold("name:")} ${repoName}`);
|
|
14122
14240
|
}
|
|
14123
14241
|
function displayNextEntry(ctx, targetDate, commits2) {
|
|
14124
14242
|
logName(ctx.repoName);
|
|
14125
14243
|
printVersionInfo(ctx.config, ctx.lastInfo, commits2[0]?.hash);
|
|
14126
|
-
console.log(
|
|
14244
|
+
console.log(chalk130.bold.blue(targetDate));
|
|
14127
14245
|
printCommitsWithFiles(commits2, ctx.ignore, ctx.verbose);
|
|
14128
14246
|
}
|
|
14129
14247
|
function logNoCommits(lastInfo) {
|
|
14130
|
-
console.log(
|
|
14248
|
+
console.log(chalk130.dim(noCommitsMessage(!!lastInfo)));
|
|
14131
14249
|
}
|
|
14132
14250
|
|
|
14133
14251
|
// src/commands/devlog/next/index.ts
|
|
@@ -14168,11 +14286,11 @@ function next2(options2) {
|
|
|
14168
14286
|
import { execSync as execSync34 } from "child_process";
|
|
14169
14287
|
|
|
14170
14288
|
// src/commands/devlog/repos/printReposTable.ts
|
|
14171
|
-
import
|
|
14289
|
+
import chalk131 from "chalk";
|
|
14172
14290
|
function colorStatus(status3) {
|
|
14173
|
-
if (status3 === "missing") return
|
|
14174
|
-
if (status3 === "outdated") return
|
|
14175
|
-
return
|
|
14291
|
+
if (status3 === "missing") return chalk131.red(status3);
|
|
14292
|
+
if (status3 === "outdated") return chalk131.yellow(status3);
|
|
14293
|
+
return chalk131.green(status3);
|
|
14176
14294
|
}
|
|
14177
14295
|
function formatRow(row, nameWidth) {
|
|
14178
14296
|
const devlog = (row.lastDevlog ?? "-").padEnd(11);
|
|
@@ -14186,8 +14304,8 @@ function printReposTable(rows) {
|
|
|
14186
14304
|
"Last Devlog".padEnd(11),
|
|
14187
14305
|
"Status"
|
|
14188
14306
|
].join(" ");
|
|
14189
|
-
console.log(
|
|
14190
|
-
console.log(
|
|
14307
|
+
console.log(chalk131.dim(header));
|
|
14308
|
+
console.log(chalk131.dim("-".repeat(header.length)));
|
|
14191
14309
|
for (const row of rows) {
|
|
14192
14310
|
console.log(formatRow(row, nameWidth));
|
|
14193
14311
|
}
|
|
@@ -14243,16 +14361,16 @@ function repos(options2) {
|
|
|
14243
14361
|
}
|
|
14244
14362
|
|
|
14245
14363
|
// src/commands/devlog/skip.ts
|
|
14246
|
-
import { writeFileSync as
|
|
14247
|
-
import { join as
|
|
14248
|
-
import
|
|
14364
|
+
import { writeFileSync as writeFileSync29 } from "fs";
|
|
14365
|
+
import { join as join37 } from "path";
|
|
14366
|
+
import chalk132 from "chalk";
|
|
14249
14367
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
14250
14368
|
function getBlogConfigPath() {
|
|
14251
|
-
return
|
|
14369
|
+
return join37(BLOG_REPO_ROOT, "assist.yml");
|
|
14252
14370
|
}
|
|
14253
14371
|
function skip(date) {
|
|
14254
14372
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
14255
|
-
console.log(
|
|
14373
|
+
console.log(chalk132.red("Invalid date format. Use YYYY-MM-DD"));
|
|
14256
14374
|
process.exit(1);
|
|
14257
14375
|
}
|
|
14258
14376
|
const repoName = getRepoName();
|
|
@@ -14263,7 +14381,7 @@ function skip(date) {
|
|
|
14263
14381
|
const skipDays = skip2[repoName] ?? [];
|
|
14264
14382
|
if (skipDays.includes(date)) {
|
|
14265
14383
|
console.log(
|
|
14266
|
-
|
|
14384
|
+
chalk132.yellow(`${date} is already in skip list for ${repoName}`)
|
|
14267
14385
|
);
|
|
14268
14386
|
return;
|
|
14269
14387
|
}
|
|
@@ -14272,21 +14390,21 @@ function skip(date) {
|
|
|
14272
14390
|
skip2[repoName] = skipDays;
|
|
14273
14391
|
devlog.skip = skip2;
|
|
14274
14392
|
config.devlog = devlog;
|
|
14275
|
-
|
|
14276
|
-
console.log(
|
|
14393
|
+
writeFileSync29(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
14394
|
+
console.log(chalk132.green(`Added ${date} to skip list for ${repoName}`));
|
|
14277
14395
|
}
|
|
14278
14396
|
|
|
14279
14397
|
// src/commands/devlog/version.ts
|
|
14280
|
-
import
|
|
14398
|
+
import chalk133 from "chalk";
|
|
14281
14399
|
function version() {
|
|
14282
14400
|
const config = loadConfig();
|
|
14283
14401
|
const name = getRepoName();
|
|
14284
14402
|
const lastInfo = getLastVersionInfo(name, config);
|
|
14285
14403
|
const lastVersion = lastInfo?.version ?? null;
|
|
14286
14404
|
const nextVersion = lastVersion ? bumpVersion(lastVersion, "patch") : null;
|
|
14287
|
-
console.log(`${
|
|
14288
|
-
console.log(`${
|
|
14289
|
-
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")}`);
|
|
14290
14408
|
}
|
|
14291
14409
|
|
|
14292
14410
|
// src/commands/devlog/devlogConfigHelp.ts
|
|
@@ -14329,16 +14447,16 @@ function registerDevlog(program2) {
|
|
|
14329
14447
|
|
|
14330
14448
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
14331
14449
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5 } from "fs";
|
|
14332
|
-
import { join as
|
|
14333
|
-
import
|
|
14450
|
+
import { join as join38 } from "path";
|
|
14451
|
+
import chalk134 from "chalk";
|
|
14334
14452
|
|
|
14335
14453
|
// src/shared/findRepoRoot.ts
|
|
14336
|
-
import { existsSync as
|
|
14454
|
+
import { existsSync as existsSync35 } from "fs";
|
|
14337
14455
|
import path28 from "path";
|
|
14338
14456
|
function findRepoRoot(dir) {
|
|
14339
14457
|
let current = dir;
|
|
14340
14458
|
while (current !== path28.dirname(current)) {
|
|
14341
|
-
if (
|
|
14459
|
+
if (existsSync35(path28.join(current, ".git"))) {
|
|
14342
14460
|
return current;
|
|
14343
14461
|
}
|
|
14344
14462
|
current = path28.dirname(current);
|
|
@@ -14357,7 +14475,7 @@ function isLockedDll(debugDir) {
|
|
|
14357
14475
|
}
|
|
14358
14476
|
for (const file of files) {
|
|
14359
14477
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
14360
|
-
const dllPath =
|
|
14478
|
+
const dllPath = join38(debugDir, file);
|
|
14361
14479
|
try {
|
|
14362
14480
|
const fd = openSync3(dllPath, "r+");
|
|
14363
14481
|
closeSync3(fd);
|
|
@@ -14375,13 +14493,13 @@ function findFirstLockedDll(dir) {
|
|
|
14375
14493
|
return null;
|
|
14376
14494
|
}
|
|
14377
14495
|
if (entries.includes("bin")) {
|
|
14378
|
-
const locked = isLockedDll(
|
|
14496
|
+
const locked = isLockedDll(join38(dir, "bin", "Debug"));
|
|
14379
14497
|
if (locked) return locked;
|
|
14380
14498
|
}
|
|
14381
14499
|
for (const entry of entries) {
|
|
14382
14500
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
14383
14501
|
continue;
|
|
14384
|
-
const found = findFirstLockedDll(
|
|
14502
|
+
const found = findFirstLockedDll(join38(dir, entry));
|
|
14385
14503
|
if (found) return found;
|
|
14386
14504
|
}
|
|
14387
14505
|
return null;
|
|
@@ -14393,22 +14511,22 @@ function checkBuildLocks(startDir) {
|
|
|
14393
14511
|
const locked = findFirstLockedDll(startDir ?? getSearchRoot());
|
|
14394
14512
|
if (locked) {
|
|
14395
14513
|
console.error(
|
|
14396
|
-
|
|
14514
|
+
chalk134.red("Build output locked (is VS debugging?): ") + locked
|
|
14397
14515
|
);
|
|
14398
14516
|
process.exit(1);
|
|
14399
14517
|
}
|
|
14400
14518
|
}
|
|
14401
14519
|
async function checkBuildLocksCommand() {
|
|
14402
14520
|
checkBuildLocks();
|
|
14403
|
-
console.log(
|
|
14521
|
+
console.log(chalk134.green("No build locks detected"));
|
|
14404
14522
|
}
|
|
14405
14523
|
|
|
14406
14524
|
// src/commands/dotnet/buildTree.ts
|
|
14407
|
-
import { readFileSync as
|
|
14525
|
+
import { readFileSync as readFileSync32 } from "fs";
|
|
14408
14526
|
import path29 from "path";
|
|
14409
14527
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
14410
14528
|
function getProjectRefs(csprojPath) {
|
|
14411
|
-
const content =
|
|
14529
|
+
const content = readFileSync32(csprojPath, "utf8");
|
|
14412
14530
|
const refs = [];
|
|
14413
14531
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
14414
14532
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -14425,7 +14543,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
14425
14543
|
for (const ref of getProjectRefs(abs)) {
|
|
14426
14544
|
const childAbs = path29.resolve(dir, ref);
|
|
14427
14545
|
try {
|
|
14428
|
-
|
|
14546
|
+
readFileSync32(childAbs);
|
|
14429
14547
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
14430
14548
|
} catch {
|
|
14431
14549
|
node.children.push({
|
|
@@ -14450,7 +14568,7 @@ function collectAllDeps(node) {
|
|
|
14450
14568
|
}
|
|
14451
14569
|
|
|
14452
14570
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
14453
|
-
import { readdirSync as readdirSync6, readFileSync as
|
|
14571
|
+
import { readdirSync as readdirSync6, readFileSync as readFileSync33, statSync as statSync4 } from "fs";
|
|
14454
14572
|
import path30 from "path";
|
|
14455
14573
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
14456
14574
|
if (depth > maxDepth) return [];
|
|
@@ -14485,7 +14603,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
14485
14603
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
14486
14604
|
for (const sln of slnFiles) {
|
|
14487
14605
|
try {
|
|
14488
|
-
const content =
|
|
14606
|
+
const content = readFileSync33(sln, "utf8");
|
|
14489
14607
|
if (pattern2.test(content)) {
|
|
14490
14608
|
matches.push(path30.relative(repoRoot, sln));
|
|
14491
14609
|
}
|
|
@@ -14499,30 +14617,30 @@ function escapeRegex(s) {
|
|
|
14499
14617
|
}
|
|
14500
14618
|
|
|
14501
14619
|
// src/commands/dotnet/printTree.ts
|
|
14502
|
-
import
|
|
14620
|
+
import chalk135 from "chalk";
|
|
14503
14621
|
function printNodes(nodes, prefix2) {
|
|
14504
14622
|
for (let i = 0; i < nodes.length; i++) {
|
|
14505
14623
|
const isLast = i === nodes.length - 1;
|
|
14506
14624
|
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
14507
14625
|
const childPrefix = isLast ? " " : "\u2502 ";
|
|
14508
14626
|
const isMissing = nodes[i].relativePath.startsWith("[MISSING]");
|
|
14509
|
-
const label2 = isMissing ?
|
|
14627
|
+
const label2 = isMissing ? chalk135.red(nodes[i].relativePath) : nodes[i].relativePath;
|
|
14510
14628
|
console.log(`${prefix2}${connector}${label2}`);
|
|
14511
14629
|
printNodes(nodes[i].children, prefix2 + childPrefix);
|
|
14512
14630
|
}
|
|
14513
14631
|
}
|
|
14514
14632
|
function printTree(tree, totalCount, solutions) {
|
|
14515
|
-
console.log(
|
|
14516
|
-
console.log(
|
|
14633
|
+
console.log(chalk135.bold("\nProject Dependency Tree"));
|
|
14634
|
+
console.log(chalk135.cyan(tree.relativePath));
|
|
14517
14635
|
printNodes(tree.children, "");
|
|
14518
|
-
console.log(
|
|
14636
|
+
console.log(chalk135.dim(`
|
|
14519
14637
|
${totalCount} projects total (including root)`));
|
|
14520
|
-
console.log(
|
|
14638
|
+
console.log(chalk135.bold("\nSolution Membership"));
|
|
14521
14639
|
if (solutions.length === 0) {
|
|
14522
|
-
console.log(
|
|
14640
|
+
console.log(chalk135.yellow(" Not found in any .sln"));
|
|
14523
14641
|
} else {
|
|
14524
14642
|
for (const sln of solutions) {
|
|
14525
|
-
console.log(` ${
|
|
14643
|
+
console.log(` ${chalk135.green(sln)}`);
|
|
14526
14644
|
}
|
|
14527
14645
|
}
|
|
14528
14646
|
console.log();
|
|
@@ -14549,18 +14667,18 @@ function printJson(tree, totalCount, solutions) {
|
|
|
14549
14667
|
}
|
|
14550
14668
|
|
|
14551
14669
|
// src/commands/dotnet/resolveCsproj.ts
|
|
14552
|
-
import { existsSync as
|
|
14670
|
+
import { existsSync as existsSync36 } from "fs";
|
|
14553
14671
|
import path31 from "path";
|
|
14554
|
-
import
|
|
14672
|
+
import chalk136 from "chalk";
|
|
14555
14673
|
function resolveCsproj(csprojPath) {
|
|
14556
14674
|
const resolved = path31.resolve(csprojPath);
|
|
14557
|
-
if (!
|
|
14558
|
-
console.error(
|
|
14675
|
+
if (!existsSync36(resolved)) {
|
|
14676
|
+
console.error(chalk136.red(`File not found: ${resolved}`));
|
|
14559
14677
|
process.exit(1);
|
|
14560
14678
|
}
|
|
14561
14679
|
const repoRoot = findRepoRoot(path31.dirname(resolved));
|
|
14562
14680
|
if (!repoRoot) {
|
|
14563
|
-
console.error(
|
|
14681
|
+
console.error(chalk136.red("Could not find git repository root"));
|
|
14564
14682
|
process.exit(1);
|
|
14565
14683
|
}
|
|
14566
14684
|
return { resolved, repoRoot };
|
|
@@ -14610,12 +14728,12 @@ function getChangedCsFiles(scope) {
|
|
|
14610
14728
|
}
|
|
14611
14729
|
|
|
14612
14730
|
// src/commands/dotnet/inSln.ts
|
|
14613
|
-
import
|
|
14731
|
+
import chalk137 from "chalk";
|
|
14614
14732
|
async function inSln(csprojPath) {
|
|
14615
14733
|
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
14616
14734
|
const solutions = findContainingSolutions(resolved, repoRoot);
|
|
14617
14735
|
if (solutions.length === 0) {
|
|
14618
|
-
console.log(
|
|
14736
|
+
console.log(chalk137.yellow("Not found in any .sln file"));
|
|
14619
14737
|
process.exit(1);
|
|
14620
14738
|
}
|
|
14621
14739
|
for (const sln of solutions) {
|
|
@@ -14624,7 +14742,7 @@ async function inSln(csprojPath) {
|
|
|
14624
14742
|
}
|
|
14625
14743
|
|
|
14626
14744
|
// src/commands/dotnet/inspect.ts
|
|
14627
|
-
import
|
|
14745
|
+
import chalk143 from "chalk";
|
|
14628
14746
|
|
|
14629
14747
|
// src/shared/formatElapsed.ts
|
|
14630
14748
|
function formatElapsed(ms) {
|
|
@@ -14636,12 +14754,12 @@ function formatElapsed(ms) {
|
|
|
14636
14754
|
}
|
|
14637
14755
|
|
|
14638
14756
|
// src/commands/dotnet/displayIssues.ts
|
|
14639
|
-
import
|
|
14757
|
+
import chalk138 from "chalk";
|
|
14640
14758
|
var SEVERITY_COLOR = {
|
|
14641
|
-
ERROR:
|
|
14642
|
-
WARNING:
|
|
14643
|
-
SUGGESTION:
|
|
14644
|
-
HINT:
|
|
14759
|
+
ERROR: chalk138.red,
|
|
14760
|
+
WARNING: chalk138.yellow,
|
|
14761
|
+
SUGGESTION: chalk138.cyan,
|
|
14762
|
+
HINT: chalk138.dim
|
|
14645
14763
|
};
|
|
14646
14764
|
function groupByFile(issues) {
|
|
14647
14765
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -14657,15 +14775,15 @@ function groupByFile(issues) {
|
|
|
14657
14775
|
}
|
|
14658
14776
|
function displayIssues(issues) {
|
|
14659
14777
|
for (const [file, fileIssues] of groupByFile(issues)) {
|
|
14660
|
-
console.log(
|
|
14778
|
+
console.log(chalk138.bold(file));
|
|
14661
14779
|
for (const issue of fileIssues.sort((a, b) => a.line - b.line)) {
|
|
14662
|
-
const color = SEVERITY_COLOR[issue.severity] ??
|
|
14780
|
+
const color = SEVERITY_COLOR[issue.severity] ?? chalk138.white;
|
|
14663
14781
|
console.log(
|
|
14664
|
-
` ${
|
|
14782
|
+
` ${chalk138.dim(`${issue.line}:`)} ${color(issue.severity)} [${issue.typeId}] ${issue.message}`
|
|
14665
14783
|
);
|
|
14666
14784
|
}
|
|
14667
14785
|
}
|
|
14668
|
-
console.log(
|
|
14786
|
+
console.log(chalk138.dim(`
|
|
14669
14787
|
${issues.length} issue(s) found`));
|
|
14670
14788
|
}
|
|
14671
14789
|
|
|
@@ -14722,17 +14840,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
14722
14840
|
}
|
|
14723
14841
|
|
|
14724
14842
|
// src/commands/dotnet/resolveSolution.ts
|
|
14725
|
-
import { existsSync as
|
|
14843
|
+
import { existsSync as existsSync37 } from "fs";
|
|
14726
14844
|
import path32 from "path";
|
|
14727
|
-
import
|
|
14845
|
+
import chalk140 from "chalk";
|
|
14728
14846
|
|
|
14729
14847
|
// src/commands/dotnet/findSolution.ts
|
|
14730
14848
|
import { readdirSync as readdirSync7 } from "fs";
|
|
14731
|
-
import { dirname as dirname22, join as
|
|
14732
|
-
import
|
|
14849
|
+
import { dirname as dirname22, join as join39 } from "path";
|
|
14850
|
+
import chalk139 from "chalk";
|
|
14733
14851
|
function findSlnInDir(dir) {
|
|
14734
14852
|
try {
|
|
14735
|
-
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
14853
|
+
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) => join39(dir, f));
|
|
14736
14854
|
} catch {
|
|
14737
14855
|
return [];
|
|
14738
14856
|
}
|
|
@@ -14745,17 +14863,17 @@ function findSolution() {
|
|
|
14745
14863
|
const slnFiles = findSlnInDir(current);
|
|
14746
14864
|
if (slnFiles.length === 1) return slnFiles[0];
|
|
14747
14865
|
if (slnFiles.length > 1) {
|
|
14748
|
-
console.error(
|
|
14866
|
+
console.error(chalk139.red(`Multiple .sln files found in ${current}:`));
|
|
14749
14867
|
for (const f of slnFiles) console.error(` ${f}`);
|
|
14750
14868
|
console.error(
|
|
14751
|
-
|
|
14869
|
+
chalk139.yellow("Specify which one: assist dotnet inspect <sln>")
|
|
14752
14870
|
);
|
|
14753
14871
|
process.exit(1);
|
|
14754
14872
|
}
|
|
14755
14873
|
if (current === ceiling) break;
|
|
14756
14874
|
current = dirname22(current);
|
|
14757
14875
|
}
|
|
14758
|
-
console.error(
|
|
14876
|
+
console.error(chalk139.red("No .sln file found between cwd and repo root"));
|
|
14759
14877
|
process.exit(1);
|
|
14760
14878
|
}
|
|
14761
14879
|
|
|
@@ -14763,8 +14881,8 @@ function findSolution() {
|
|
|
14763
14881
|
function resolveSolution(sln) {
|
|
14764
14882
|
if (sln) {
|
|
14765
14883
|
const resolved = path32.resolve(sln);
|
|
14766
|
-
if (!
|
|
14767
|
-
console.error(
|
|
14884
|
+
if (!existsSync37(resolved)) {
|
|
14885
|
+
console.error(chalk140.red(`Solution file not found: ${resolved}`));
|
|
14768
14886
|
process.exit(1);
|
|
14769
14887
|
}
|
|
14770
14888
|
return resolved;
|
|
@@ -14803,17 +14921,17 @@ function parseInspectReport(json) {
|
|
|
14803
14921
|
|
|
14804
14922
|
// src/commands/dotnet/runInspectCode.ts
|
|
14805
14923
|
import { execSync as execSync36 } from "child_process";
|
|
14806
|
-
import { existsSync as
|
|
14924
|
+
import { existsSync as existsSync38, readFileSync as readFileSync34, unlinkSync as unlinkSync10 } from "fs";
|
|
14807
14925
|
import { tmpdir as tmpdir3 } from "os";
|
|
14808
14926
|
import path33 from "path";
|
|
14809
|
-
import
|
|
14927
|
+
import chalk141 from "chalk";
|
|
14810
14928
|
function assertJbInstalled() {
|
|
14811
14929
|
try {
|
|
14812
14930
|
execSync36("jb inspectcode --version", { stdio: "pipe" });
|
|
14813
14931
|
} catch {
|
|
14814
|
-
console.error(
|
|
14932
|
+
console.error(chalk141.red("jb is not installed. Install with:"));
|
|
14815
14933
|
console.error(
|
|
14816
|
-
|
|
14934
|
+
chalk141.yellow(" dotnet tool install -g JetBrains.ReSharper.GlobalTools")
|
|
14817
14935
|
);
|
|
14818
14936
|
process.exit(1);
|
|
14819
14937
|
}
|
|
@@ -14831,21 +14949,21 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
14831
14949
|
if (error && typeof error === "object" && "stderr" in error) {
|
|
14832
14950
|
process.stderr.write(error.stderr);
|
|
14833
14951
|
}
|
|
14834
|
-
console.error(
|
|
14952
|
+
console.error(chalk141.red("jb inspectcode failed"));
|
|
14835
14953
|
process.exit(1);
|
|
14836
14954
|
}
|
|
14837
|
-
if (!
|
|
14838
|
-
console.error(
|
|
14955
|
+
if (!existsSync38(reportPath)) {
|
|
14956
|
+
console.error(chalk141.red("Report file not generated"));
|
|
14839
14957
|
process.exit(1);
|
|
14840
14958
|
}
|
|
14841
|
-
const xml =
|
|
14842
|
-
|
|
14959
|
+
const xml = readFileSync34(reportPath, "utf8");
|
|
14960
|
+
unlinkSync10(reportPath);
|
|
14843
14961
|
return xml;
|
|
14844
14962
|
}
|
|
14845
14963
|
|
|
14846
14964
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
14847
14965
|
import { execSync as execSync37 } from "child_process";
|
|
14848
|
-
import
|
|
14966
|
+
import chalk142 from "chalk";
|
|
14849
14967
|
function resolveMsbuildPath() {
|
|
14850
14968
|
const { run: run4 } = loadConfig();
|
|
14851
14969
|
const configs = resolveRunConfigs(run4, getConfigDir());
|
|
@@ -14857,9 +14975,9 @@ function assertMsbuildInstalled() {
|
|
|
14857
14975
|
try {
|
|
14858
14976
|
execSync37(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
14859
14977
|
} catch {
|
|
14860
|
-
console.error(
|
|
14978
|
+
console.error(chalk142.red(`msbuild not found at: ${msbuild}`));
|
|
14861
14979
|
console.error(
|
|
14862
|
-
|
|
14980
|
+
chalk142.yellow(
|
|
14863
14981
|
"Configure it via a 'build' run entry in .claude/assist.yml or add msbuild to PATH."
|
|
14864
14982
|
)
|
|
14865
14983
|
);
|
|
@@ -14906,17 +15024,17 @@ function runEngine(resolved, changedFiles, options2) {
|
|
|
14906
15024
|
// src/commands/dotnet/inspect.ts
|
|
14907
15025
|
function logScope(changedFiles) {
|
|
14908
15026
|
if (changedFiles === null) {
|
|
14909
|
-
console.log(
|
|
15027
|
+
console.log(chalk143.dim("Inspecting full solution..."));
|
|
14910
15028
|
} else {
|
|
14911
15029
|
console.log(
|
|
14912
|
-
|
|
15030
|
+
chalk143.dim(`Inspecting ${changedFiles.length} changed file(s)...`)
|
|
14913
15031
|
);
|
|
14914
15032
|
}
|
|
14915
15033
|
}
|
|
14916
15034
|
function reportResults(issues, elapsed) {
|
|
14917
15035
|
if (issues.length > 0) displayIssues(issues);
|
|
14918
|
-
else console.log(
|
|
14919
|
-
console.log(
|
|
15036
|
+
else console.log(chalk143.green("No issues found"));
|
|
15037
|
+
console.log(chalk143.dim(`Completed in ${formatElapsed(elapsed)}`));
|
|
14920
15038
|
if (issues.length > 0) process.exit(1);
|
|
14921
15039
|
}
|
|
14922
15040
|
async function inspect(sln, options2) {
|
|
@@ -14927,7 +15045,7 @@ async function inspect(sln, options2) {
|
|
|
14927
15045
|
const scope = parseScope(options2.scope);
|
|
14928
15046
|
const changedFiles = getChangedCsFiles(scope);
|
|
14929
15047
|
if (changedFiles !== null && changedFiles.length === 0) {
|
|
14930
|
-
console.log(
|
|
15048
|
+
console.log(chalk143.green("No changed .cs files found"));
|
|
14931
15049
|
return;
|
|
14932
15050
|
}
|
|
14933
15051
|
logScope(changedFiles);
|
|
@@ -15096,6 +15214,41 @@ function decideCommentGuard(input, existingContent) {
|
|
|
15096
15214
|
return introduced.length > 0 ? denyReason(hash ? "#" : "//") : void 0;
|
|
15097
15215
|
}
|
|
15098
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
|
+
|
|
15099
15252
|
// src/commands/editHook/decideOverrideGuard.ts
|
|
15100
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.`;
|
|
15101
15254
|
function candidateStrings(input, existingContent) {
|
|
@@ -15149,7 +15302,7 @@ async function editHook() {
|
|
|
15149
15302
|
const input = tryParseInput2(await readStdin());
|
|
15150
15303
|
if (!input) return;
|
|
15151
15304
|
const existing = input.tool_name === "Write" ? readExisting(input.tool_input.file_path) : void 0;
|
|
15152
|
-
const reason = decideOverrideGuard(input, existing) ?? decideCommentGuard(input, existing);
|
|
15305
|
+
const reason = decideOverrideGuard(input, existing) ?? decideCommentGuard(input, existing) ?? decideMigrationGuard(input, existing);
|
|
15153
15306
|
if (!reason) return;
|
|
15154
15307
|
console.log(
|
|
15155
15308
|
JSON.stringify({
|
|
@@ -15184,9 +15337,9 @@ function aggregateCommitters(authorLists) {
|
|
|
15184
15337
|
|
|
15185
15338
|
// src/shared/runGhGraphql.ts
|
|
15186
15339
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
15187
|
-
import { unlinkSync as
|
|
15340
|
+
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
15188
15341
|
import { tmpdir as tmpdir4 } from "os";
|
|
15189
|
-
import { join as
|
|
15342
|
+
import { join as join40 } from "path";
|
|
15190
15343
|
function buildArgs2(queryFile, vars) {
|
|
15191
15344
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
15192
15345
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -15211,8 +15364,8 @@ function throwOnGraphqlErrors(stdout) {
|
|
|
15211
15364
|
throw new Error(messages || "GraphQL request returned errors");
|
|
15212
15365
|
}
|
|
15213
15366
|
function runGhGraphql(mutation, vars) {
|
|
15214
|
-
const queryFile =
|
|
15215
|
-
|
|
15367
|
+
const queryFile = join40(tmpdir4(), `gh-query-${Date.now()}.graphql`);
|
|
15368
|
+
writeFileSync30(queryFile, mutation);
|
|
15216
15369
|
try {
|
|
15217
15370
|
const result = spawnSync3("gh", buildArgs2(queryFile, vars), {
|
|
15218
15371
|
encoding: "utf8"
|
|
@@ -15221,7 +15374,7 @@ function runGhGraphql(mutation, vars) {
|
|
|
15221
15374
|
throwOnGraphqlErrors(result.stdout);
|
|
15222
15375
|
return result.stdout;
|
|
15223
15376
|
} finally {
|
|
15224
|
-
|
|
15377
|
+
unlinkSync12(queryFile);
|
|
15225
15378
|
}
|
|
15226
15379
|
}
|
|
15227
15380
|
|
|
@@ -15275,25 +15428,25 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
15275
15428
|
}
|
|
15276
15429
|
|
|
15277
15430
|
// src/commands/github/printCountTable.ts
|
|
15278
|
-
import
|
|
15431
|
+
import chalk144 from "chalk";
|
|
15279
15432
|
function printCountTable(labelHeader, rows) {
|
|
15280
15433
|
const labelWidth = Math.max(
|
|
15281
15434
|
labelHeader.length,
|
|
15282
15435
|
...rows.map((row) => row.label.length)
|
|
15283
15436
|
);
|
|
15284
15437
|
const header = `${labelHeader.padEnd(labelWidth)} Commits`;
|
|
15285
|
-
console.log(
|
|
15286
|
-
console.log(
|
|
15438
|
+
console.log(chalk144.dim(header));
|
|
15439
|
+
console.log(chalk144.dim("-".repeat(header.length)));
|
|
15287
15440
|
for (const row of rows) {
|
|
15288
15441
|
console.log(`${row.label.padEnd(labelWidth)} ${row.count}`);
|
|
15289
15442
|
}
|
|
15290
15443
|
}
|
|
15291
15444
|
|
|
15292
15445
|
// src/commands/github/printRepoAuthorBreakdown.ts
|
|
15293
|
-
import
|
|
15446
|
+
import chalk145 from "chalk";
|
|
15294
15447
|
function printRepoAuthorBreakdown(repos2) {
|
|
15295
15448
|
for (const repo of repos2) {
|
|
15296
|
-
console.log(
|
|
15449
|
+
console.log(chalk145.bold(repo.name));
|
|
15297
15450
|
const authorWidth = Math.max(
|
|
15298
15451
|
0,
|
|
15299
15452
|
...repo.authors.map((a) => a.author.length)
|
|
@@ -15398,24 +15551,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
15398
15551
|
|
|
15399
15552
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
15400
15553
|
import {
|
|
15401
|
-
existsSync as
|
|
15554
|
+
existsSync as existsSync40,
|
|
15402
15555
|
readdirSync as readdirSync8,
|
|
15403
|
-
readFileSync as
|
|
15556
|
+
readFileSync as readFileSync35,
|
|
15404
15557
|
rmSync as rmSync3,
|
|
15405
15558
|
statSync as statSync5
|
|
15406
15559
|
} from "fs";
|
|
15407
|
-
import { basename as basename10, join as
|
|
15560
|
+
import { basename as basename10, join as join43 } from "path";
|
|
15408
15561
|
|
|
15409
15562
|
// src/commands/handover/getHandoverPath.ts
|
|
15410
|
-
import { join as
|
|
15563
|
+
import { join as join41 } from "path";
|
|
15411
15564
|
function getHandoverPath(cwd = process.cwd()) {
|
|
15412
|
-
return
|
|
15565
|
+
return join41(cwd, ".assist", "HANDOVER.md");
|
|
15413
15566
|
}
|
|
15414
15567
|
|
|
15415
15568
|
// src/commands/handover/getHandoversDir.ts
|
|
15416
|
-
import { join as
|
|
15569
|
+
import { join as join42 } from "path";
|
|
15417
15570
|
function getHandoversDir(cwd = process.cwd()) {
|
|
15418
|
-
return
|
|
15571
|
+
return join42(cwd, ".assist", "handovers");
|
|
15419
15572
|
}
|
|
15420
15573
|
|
|
15421
15574
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -15453,17 +15606,17 @@ function summariseHandoverContent(content) {
|
|
|
15453
15606
|
|
|
15454
15607
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
15455
15608
|
function collectMarkdown(dir) {
|
|
15456
|
-
if (!
|
|
15609
|
+
if (!existsSync40(dir)) return [];
|
|
15457
15610
|
const out = [];
|
|
15458
15611
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
15459
|
-
const full =
|
|
15612
|
+
const full = join43(dir, entry.name);
|
|
15460
15613
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
15461
15614
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
15462
15615
|
}
|
|
15463
15616
|
return out;
|
|
15464
15617
|
}
|
|
15465
15618
|
async function migrateFile(orm, origin, file, createdAt) {
|
|
15466
|
-
const content =
|
|
15619
|
+
const content = readFileSync35(file, "utf8");
|
|
15467
15620
|
await saveHandover(orm, {
|
|
15468
15621
|
origin,
|
|
15469
15622
|
summary: summariseHandoverContent(content),
|
|
@@ -15480,7 +15633,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
15480
15633
|
migrated++;
|
|
15481
15634
|
}
|
|
15482
15635
|
const handoverPath = getHandoverPath(cwd);
|
|
15483
|
-
if (
|
|
15636
|
+
if (existsSync40(handoverPath)) {
|
|
15484
15637
|
await migrateFile(orm, origin, handoverPath, statSync5(handoverPath).mtime);
|
|
15485
15638
|
migrated++;
|
|
15486
15639
|
}
|
|
@@ -15611,7 +15764,7 @@ function registerHandover(program2) {
|
|
|
15611
15764
|
}
|
|
15612
15765
|
|
|
15613
15766
|
// src/commands/jira/acceptanceCriteria.ts
|
|
15614
|
-
import
|
|
15767
|
+
import chalk146 from "chalk";
|
|
15615
15768
|
|
|
15616
15769
|
// src/commands/jira/adfToText.ts
|
|
15617
15770
|
function renderInline(node) {
|
|
@@ -15678,7 +15831,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
15678
15831
|
const parsed = fetchIssue(issueKey, field);
|
|
15679
15832
|
const acValue = parsed?.fields?.[field];
|
|
15680
15833
|
if (!acValue) {
|
|
15681
|
-
console.log(
|
|
15834
|
+
console.log(chalk146.yellow(`No acceptance criteria found on ${issueKey}.`));
|
|
15682
15835
|
return;
|
|
15683
15836
|
}
|
|
15684
15837
|
if (typeof acValue === "string") {
|
|
@@ -15744,14 +15897,14 @@ async function jiraAuth() {
|
|
|
15744
15897
|
}
|
|
15745
15898
|
|
|
15746
15899
|
// src/commands/jira/viewIssue.ts
|
|
15747
|
-
import
|
|
15900
|
+
import chalk147 from "chalk";
|
|
15748
15901
|
function viewIssue(issueKey) {
|
|
15749
15902
|
const parsed = fetchIssue(issueKey, "summary,description");
|
|
15750
15903
|
const fields = parsed?.fields;
|
|
15751
15904
|
const summary = fields?.summary;
|
|
15752
15905
|
const description = fields?.description;
|
|
15753
15906
|
if (summary) {
|
|
15754
|
-
console.log(
|
|
15907
|
+
console.log(chalk147.bold(summary));
|
|
15755
15908
|
}
|
|
15756
15909
|
if (description) {
|
|
15757
15910
|
if (summary) console.log();
|
|
@@ -15765,7 +15918,7 @@ function viewIssue(issueKey) {
|
|
|
15765
15918
|
}
|
|
15766
15919
|
if (!summary && !description) {
|
|
15767
15920
|
console.log(
|
|
15768
|
-
|
|
15921
|
+
chalk147.yellow(`No summary or description found on ${issueKey}.`)
|
|
15769
15922
|
);
|
|
15770
15923
|
}
|
|
15771
15924
|
}
|
|
@@ -15821,13 +15974,13 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
15821
15974
|
// src/commands/reviewPrComments.ts
|
|
15822
15975
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
15823
15976
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
15824
|
-
import
|
|
15977
|
+
import chalk148 from "chalk";
|
|
15825
15978
|
async function reviewPrComments(number) {
|
|
15826
15979
|
if (number) {
|
|
15827
15980
|
try {
|
|
15828
15981
|
execFileSync5("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
15829
15982
|
} catch {
|
|
15830
|
-
console.error(
|
|
15983
|
+
console.error(chalk148.red(`gh pr checkout ${number} failed; aborting.`));
|
|
15831
15984
|
process.exit(1);
|
|
15832
15985
|
}
|
|
15833
15986
|
}
|
|
@@ -15898,17 +16051,17 @@ function registerList(program2) {
|
|
|
15898
16051
|
}
|
|
15899
16052
|
|
|
15900
16053
|
// src/commands/mermaid/index.ts
|
|
15901
|
-
import { mkdirSync as
|
|
16054
|
+
import { mkdirSync as mkdirSync16, readdirSync as readdirSync9 } from "fs";
|
|
15902
16055
|
import { resolve as resolve11 } from "path";
|
|
15903
|
-
import
|
|
16056
|
+
import chalk151 from "chalk";
|
|
15904
16057
|
|
|
15905
16058
|
// src/commands/mermaid/exportFile.ts
|
|
15906
|
-
import { readFileSync as
|
|
16059
|
+
import { readFileSync as readFileSync36, writeFileSync as writeFileSync31 } from "fs";
|
|
15907
16060
|
import { basename as basename11, extname, resolve as resolve10 } from "path";
|
|
15908
|
-
import
|
|
16061
|
+
import chalk150 from "chalk";
|
|
15909
16062
|
|
|
15910
16063
|
// src/commands/mermaid/renderBlock.ts
|
|
15911
|
-
import
|
|
16064
|
+
import chalk149 from "chalk";
|
|
15912
16065
|
async function renderBlock(krokiUrl, source) {
|
|
15913
16066
|
const response = await fetch(`${krokiUrl}/mermaid/svg`, {
|
|
15914
16067
|
method: "POST",
|
|
@@ -15917,7 +16070,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
15917
16070
|
});
|
|
15918
16071
|
if (!response.ok) {
|
|
15919
16072
|
console.error(
|
|
15920
|
-
|
|
16073
|
+
chalk149.red(
|
|
15921
16074
|
`Kroki request failed: ${response.status} ${response.statusText}`
|
|
15922
16075
|
)
|
|
15923
16076
|
);
|
|
@@ -15929,33 +16082,33 @@ async function renderBlock(krokiUrl, source) {
|
|
|
15929
16082
|
|
|
15930
16083
|
// src/commands/mermaid/exportFile.ts
|
|
15931
16084
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
15932
|
-
const content =
|
|
16085
|
+
const content = readFileSync36(file, "utf8");
|
|
15933
16086
|
const blocks = extractMermaidBlocks(content);
|
|
15934
16087
|
const stem = basename11(file, extname(file));
|
|
15935
16088
|
if (onlyIndex !== void 0) {
|
|
15936
16089
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
15937
16090
|
console.error(
|
|
15938
|
-
|
|
16091
|
+
chalk150.red(
|
|
15939
16092
|
`${file}: --index ${onlyIndex} out of range (file has ${blocks.length} diagram(s))`
|
|
15940
16093
|
)
|
|
15941
16094
|
);
|
|
15942
16095
|
process.exit(1);
|
|
15943
16096
|
}
|
|
15944
16097
|
console.log(
|
|
15945
|
-
|
|
16098
|
+
chalk150.gray(
|
|
15946
16099
|
`${file} \u2014 rendering diagram ${onlyIndex} of ${blocks.length}`
|
|
15947
16100
|
)
|
|
15948
16101
|
);
|
|
15949
16102
|
} else {
|
|
15950
|
-
console.log(
|
|
16103
|
+
console.log(chalk150.gray(`${file} \u2014 ${blocks.length} diagram(s)`));
|
|
15951
16104
|
}
|
|
15952
16105
|
for (const [i, source] of blocks.entries()) {
|
|
15953
16106
|
const idx = i + 1;
|
|
15954
16107
|
if (onlyIndex !== void 0 && idx !== onlyIndex) continue;
|
|
15955
16108
|
const outPath = resolve10(outDir, `${stem}-${idx}.svg`);
|
|
15956
16109
|
const svg = await renderBlock(krokiUrl, source);
|
|
15957
|
-
|
|
15958
|
-
console.log(
|
|
16110
|
+
writeFileSync31(outPath, svg, "utf8");
|
|
16111
|
+
console.log(chalk150.green(` \u2192 ${outPath}`));
|
|
15959
16112
|
}
|
|
15960
16113
|
}
|
|
15961
16114
|
function extractMermaidBlocks(markdown) {
|
|
@@ -15967,22 +16120,22 @@ function extractMermaidBlocks(markdown) {
|
|
|
15967
16120
|
async function mermaidExport(file, options2 = {}) {
|
|
15968
16121
|
const { mermaid } = loadConfig();
|
|
15969
16122
|
const outDir = resolve11(process.cwd(), options2.out ?? ".");
|
|
15970
|
-
|
|
16123
|
+
mkdirSync16(outDir, { recursive: true });
|
|
15971
16124
|
if (options2.index !== void 0) {
|
|
15972
16125
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
15973
16126
|
console.error(
|
|
15974
|
-
|
|
16127
|
+
chalk151.red(`--index must be a positive integer (got ${options2.index})`)
|
|
15975
16128
|
);
|
|
15976
16129
|
process.exit(1);
|
|
15977
16130
|
}
|
|
15978
16131
|
if (!file) {
|
|
15979
|
-
console.error(
|
|
16132
|
+
console.error(chalk151.red("--index requires a file argument"));
|
|
15980
16133
|
process.exit(1);
|
|
15981
16134
|
}
|
|
15982
16135
|
}
|
|
15983
16136
|
const files = file ? [file] : readdirSync9(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
15984
16137
|
if (files.length === 0) {
|
|
15985
|
-
console.log(
|
|
16138
|
+
console.log(chalk151.gray("No markdown files found in current directory."));
|
|
15986
16139
|
return;
|
|
15987
16140
|
}
|
|
15988
16141
|
for (const f of files) {
|
|
@@ -16015,7 +16168,7 @@ function registerMermaid(program2) {
|
|
|
16015
16168
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
16016
16169
|
import { createServer as createServer2 } from "http";
|
|
16017
16170
|
import { dirname as dirname24 } from "path";
|
|
16018
|
-
import
|
|
16171
|
+
import chalk153 from "chalk";
|
|
16019
16172
|
|
|
16020
16173
|
// src/commands/netcap/corsHeaders.ts
|
|
16021
16174
|
var corsHeaders = {
|
|
@@ -16093,15 +16246,15 @@ function createNetcapHandler(options2) {
|
|
|
16093
16246
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
16094
16247
|
import { cp, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
16095
16248
|
import { networkInterfaces } from "os";
|
|
16096
|
-
import { join as
|
|
16097
|
-
import
|
|
16249
|
+
import { join as join45 } from "path";
|
|
16250
|
+
import chalk152 from "chalk";
|
|
16098
16251
|
|
|
16099
16252
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
16100
|
-
import { dirname as dirname23, join as
|
|
16253
|
+
import { dirname as dirname23, join as join44 } from "path";
|
|
16101
16254
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
16102
16255
|
var moduleDir = dirname23(fileURLToPath6(import.meta.url));
|
|
16103
16256
|
function netcapExtensionDir() {
|
|
16104
|
-
return
|
|
16257
|
+
return join44(moduleDir, "commands", "netcap", "netcap-extension");
|
|
16105
16258
|
}
|
|
16106
16259
|
|
|
16107
16260
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -16116,7 +16269,7 @@ function lanIPv4() {
|
|
|
16116
16269
|
return void 0;
|
|
16117
16270
|
}
|
|
16118
16271
|
async function configureBackground(dir, host, port, filter) {
|
|
16119
|
-
const file =
|
|
16272
|
+
const file = join45(dir, "background.js");
|
|
16120
16273
|
const source = await readFile2(file, "utf8");
|
|
16121
16274
|
await writeFile2(
|
|
16122
16275
|
file,
|
|
@@ -16138,7 +16291,7 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
16138
16291
|
const host = lanIPv4();
|
|
16139
16292
|
if (!host) {
|
|
16140
16293
|
console.log(
|
|
16141
|
-
|
|
16294
|
+
chalk152.yellow("could not determine the WSL IP for the extension")
|
|
16142
16295
|
);
|
|
16143
16296
|
await configureBackground(source, "127.0.0.1", port, filter);
|
|
16144
16297
|
return source;
|
|
@@ -16149,27 +16302,27 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
16149
16302
|
return WSL_WINDOWS_PATH;
|
|
16150
16303
|
} catch {
|
|
16151
16304
|
console.log(
|
|
16152
|
-
|
|
16305
|
+
chalk152.yellow(`could not copy extension to ${WSL_WINDOWS_PATH}`)
|
|
16153
16306
|
);
|
|
16154
16307
|
return source;
|
|
16155
16308
|
}
|
|
16156
16309
|
}
|
|
16157
16310
|
|
|
16158
16311
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
16159
|
-
import { isAbsolute, join as
|
|
16312
|
+
import { isAbsolute, join as join47, resolve as resolve12 } from "path";
|
|
16160
16313
|
|
|
16161
16314
|
// src/commands/netcap/defaultCapturePath.ts
|
|
16162
16315
|
import { homedir as homedir19 } from "os";
|
|
16163
|
-
import { join as
|
|
16316
|
+
import { join as join46 } from "path";
|
|
16164
16317
|
function defaultCapturePath() {
|
|
16165
|
-
return
|
|
16318
|
+
return join46(homedir19(), ".assist", "netcap", "capture.jsonl");
|
|
16166
16319
|
}
|
|
16167
16320
|
|
|
16168
16321
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
16169
16322
|
function resolveNetcapOutPath(out) {
|
|
16170
16323
|
if (!out) return defaultCapturePath();
|
|
16171
16324
|
const dir = isAbsolute(out) ? out : resolve12(process.cwd(), out);
|
|
16172
|
-
return
|
|
16325
|
+
return join47(dir, "capture.jsonl");
|
|
16173
16326
|
}
|
|
16174
16327
|
|
|
16175
16328
|
// src/commands/netcap/netcap.ts
|
|
@@ -16182,30 +16335,30 @@ async function netcap(options2) {
|
|
|
16182
16335
|
let count7 = 0;
|
|
16183
16336
|
const handler = createNetcapHandler({
|
|
16184
16337
|
outPath,
|
|
16185
|
-
onPing: () => console.log(
|
|
16338
|
+
onPing: () => console.log(chalk153.dim("ping from extension")),
|
|
16186
16339
|
onCapture: (entry) => {
|
|
16187
16340
|
count7 += 1;
|
|
16188
16341
|
console.log(
|
|
16189
|
-
|
|
16190
|
-
|
|
16342
|
+
chalk153.green(`captured #${count7}`),
|
|
16343
|
+
chalk153.dim(`${entry.method ?? "?"} ${entry.url ?? "?"}`)
|
|
16191
16344
|
);
|
|
16192
16345
|
}
|
|
16193
16346
|
});
|
|
16194
16347
|
const server = createServer2(handler);
|
|
16195
16348
|
server.listen(port, () => {
|
|
16196
16349
|
console.log(
|
|
16197
|
-
|
|
16350
|
+
chalk153.bold(`netcap receiver listening on http://127.0.0.1:${port}`)
|
|
16198
16351
|
);
|
|
16199
|
-
console.log(
|
|
16352
|
+
console.log(chalk153.dim(`appending captures to ${outPath}`));
|
|
16200
16353
|
if (filter)
|
|
16201
|
-
console.log(
|
|
16202
|
-
console.log(
|
|
16203
|
-
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"));
|
|
16204
16357
|
});
|
|
16205
16358
|
process.on("SIGINT", () => {
|
|
16206
16359
|
server.close();
|
|
16207
16360
|
console.log(
|
|
16208
|
-
|
|
16361
|
+
chalk153.bold(
|
|
16209
16362
|
`
|
|
16210
16363
|
netcap stopped \u2014 captured ${count7} ${count7 === 1 ? "entry" : "entries"} to ${outPath}`
|
|
16211
16364
|
)
|
|
@@ -16215,12 +16368,12 @@ netcap stopped \u2014 captured ${count7} ${count7 === 1 ? "entry" : "entries"} t
|
|
|
16215
16368
|
}
|
|
16216
16369
|
|
|
16217
16370
|
// src/commands/netcap/netcapExtract.ts
|
|
16218
|
-
import { writeFileSync as
|
|
16219
|
-
import { join as
|
|
16220
|
-
import
|
|
16371
|
+
import { writeFileSync as writeFileSync32 } from "fs";
|
|
16372
|
+
import { join as join48 } from "path";
|
|
16373
|
+
import chalk154 from "chalk";
|
|
16221
16374
|
|
|
16222
16375
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
16223
|
-
import { readFileSync as
|
|
16376
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
16224
16377
|
|
|
16225
16378
|
// src/commands/netcap/parseRscRows.ts
|
|
16226
16379
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -16616,7 +16769,7 @@ function extractVoyagerPosts(body) {
|
|
|
16616
16769
|
|
|
16617
16770
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
16618
16771
|
function captureEntries(captureFile) {
|
|
16619
|
-
const lines =
|
|
16772
|
+
const lines = readFileSync37(captureFile, "utf8").split("\n").filter(Boolean);
|
|
16620
16773
|
const entries = [];
|
|
16621
16774
|
for (const line of lines) {
|
|
16622
16775
|
let entry;
|
|
@@ -16661,12 +16814,12 @@ function extractPostsFromCapture(captureFile) {
|
|
|
16661
16814
|
function netcapExtract(file) {
|
|
16662
16815
|
const captureFile = file ?? defaultCapturePath();
|
|
16663
16816
|
const posts = extractPostsFromCapture(captureFile);
|
|
16664
|
-
const outFile =
|
|
16665
|
-
|
|
16817
|
+
const outFile = join48(captureFile, "..", "posts.json");
|
|
16818
|
+
writeFileSync32(outFile, `${JSON.stringify(posts, null, 2)}
|
|
16666
16819
|
`);
|
|
16667
16820
|
console.log(
|
|
16668
|
-
|
|
16669
|
-
|
|
16821
|
+
chalk154.green(`extracted ${posts.length} posts`),
|
|
16822
|
+
chalk154.dim(`-> ${outFile}`)
|
|
16670
16823
|
);
|
|
16671
16824
|
}
|
|
16672
16825
|
|
|
@@ -16687,7 +16840,7 @@ function registerNetcap(program2) {
|
|
|
16687
16840
|
}
|
|
16688
16841
|
|
|
16689
16842
|
// src/commands/news/add/index.ts
|
|
16690
|
-
import
|
|
16843
|
+
import chalk155 from "chalk";
|
|
16691
16844
|
import enquirer8 from "enquirer";
|
|
16692
16845
|
async function add2(url) {
|
|
16693
16846
|
if (!url) {
|
|
@@ -16709,10 +16862,10 @@ async function add2(url) {
|
|
|
16709
16862
|
const { orm } = await getReady();
|
|
16710
16863
|
const added = await addFeed(orm, url);
|
|
16711
16864
|
if (!added) {
|
|
16712
|
-
console.log(
|
|
16865
|
+
console.log(chalk155.yellow("Feed already exists"));
|
|
16713
16866
|
return;
|
|
16714
16867
|
}
|
|
16715
|
-
console.log(
|
|
16868
|
+
console.log(chalk155.green(`Added feed: ${url}`));
|
|
16716
16869
|
}
|
|
16717
16870
|
|
|
16718
16871
|
// src/commands/registerNews.ts
|
|
@@ -16759,7 +16912,7 @@ function registerPiHook(program2) {
|
|
|
16759
16912
|
}
|
|
16760
16913
|
|
|
16761
16914
|
// src/commands/prompts/printPromptsTable.ts
|
|
16762
|
-
import
|
|
16915
|
+
import chalk156 from "chalk";
|
|
16763
16916
|
function truncate(str, max) {
|
|
16764
16917
|
if (str.length <= max) return str;
|
|
16765
16918
|
return `${str.slice(0, max - 1)}\u2026`;
|
|
@@ -16777,14 +16930,14 @@ function printPromptsTable(rows) {
|
|
|
16777
16930
|
"Command".padEnd(commandWidth),
|
|
16778
16931
|
"Repos"
|
|
16779
16932
|
].join(" ");
|
|
16780
|
-
console.log(
|
|
16781
|
-
console.log(
|
|
16933
|
+
console.log(chalk156.dim(header));
|
|
16934
|
+
console.log(chalk156.dim("-".repeat(header.length)));
|
|
16782
16935
|
for (const row of rows) {
|
|
16783
16936
|
const count7 = String(row.count).padStart(countWidth);
|
|
16784
16937
|
const tool = row.tool.padEnd(toolWidth);
|
|
16785
16938
|
const command = truncate(row.command, 60).padEnd(commandWidth);
|
|
16786
16939
|
console.log(
|
|
16787
|
-
`${
|
|
16940
|
+
`${chalk156.yellow(count7)} ${tool} ${command} ${chalk156.dim(row.repos)}`
|
|
16788
16941
|
);
|
|
16789
16942
|
}
|
|
16790
16943
|
}
|
|
@@ -17150,29 +17303,29 @@ import { execSync as execSync42 } from "child_process";
|
|
|
17150
17303
|
|
|
17151
17304
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
17152
17305
|
import { execSync as execSync41 } from "child_process";
|
|
17153
|
-
import { unlinkSync as
|
|
17306
|
+
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
17154
17307
|
import { tmpdir as tmpdir5 } from "os";
|
|
17155
|
-
import { join as
|
|
17308
|
+
import { join as join50 } from "path";
|
|
17156
17309
|
|
|
17157
17310
|
// src/commands/prs/loadCommentsCache.ts
|
|
17158
|
-
import { existsSync as
|
|
17159
|
-
import { join as
|
|
17311
|
+
import { existsSync as existsSync41, readFileSync as readFileSync38, unlinkSync as unlinkSync13 } from "fs";
|
|
17312
|
+
import { join as join49 } from "path";
|
|
17160
17313
|
import { parse as parse2 } from "yaml";
|
|
17161
17314
|
function getCachePath(prNumber) {
|
|
17162
|
-
return
|
|
17315
|
+
return join49(process.cwd(), ".assist", `pr-${prNumber}-comments.yaml`);
|
|
17163
17316
|
}
|
|
17164
17317
|
function loadCommentsCache(prNumber) {
|
|
17165
17318
|
const cachePath = getCachePath(prNumber);
|
|
17166
|
-
if (!
|
|
17319
|
+
if (!existsSync41(cachePath)) {
|
|
17167
17320
|
return null;
|
|
17168
17321
|
}
|
|
17169
|
-
const content =
|
|
17322
|
+
const content = readFileSync38(cachePath, "utf8");
|
|
17170
17323
|
return parse2(content);
|
|
17171
17324
|
}
|
|
17172
17325
|
function deleteCommentsCache(prNumber) {
|
|
17173
17326
|
const cachePath = getCachePath(prNumber);
|
|
17174
|
-
if (
|
|
17175
|
-
|
|
17327
|
+
if (existsSync41(cachePath)) {
|
|
17328
|
+
unlinkSync13(cachePath);
|
|
17176
17329
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
17177
17330
|
}
|
|
17178
17331
|
}
|
|
@@ -17189,15 +17342,15 @@ function replyToComment(org, repo, prNumber, commentId, message) {
|
|
|
17189
17342
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
17190
17343
|
function resolveThread(threadId) {
|
|
17191
17344
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
17192
|
-
const queryFile =
|
|
17193
|
-
|
|
17345
|
+
const queryFile = join50(tmpdir5(), `gh-mutation-${Date.now()}.graphql`);
|
|
17346
|
+
writeFileSync33(queryFile, mutation);
|
|
17194
17347
|
try {
|
|
17195
17348
|
execSync41(
|
|
17196
17349
|
`gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
|
|
17197
17350
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
17198
17351
|
);
|
|
17199
17352
|
} finally {
|
|
17200
|
-
|
|
17353
|
+
unlinkSync14(queryFile);
|
|
17201
17354
|
}
|
|
17202
17355
|
}
|
|
17203
17356
|
function requireCache(prNumber) {
|
|
@@ -17271,19 +17424,19 @@ function fixed(commentId, sha) {
|
|
|
17271
17424
|
}
|
|
17272
17425
|
|
|
17273
17426
|
// src/commands/prs/listComments/index.ts
|
|
17274
|
-
import { existsSync as
|
|
17275
|
-
import { join as
|
|
17427
|
+
import { existsSync as existsSync42, mkdirSync as mkdirSync17, writeFileSync as writeFileSync35 } from "fs";
|
|
17428
|
+
import { join as join52 } from "path";
|
|
17276
17429
|
import { stringify } from "yaml";
|
|
17277
17430
|
|
|
17278
17431
|
// src/commands/prs/fetchThreadIds.ts
|
|
17279
17432
|
import { execSync as execSync43 } from "child_process";
|
|
17280
|
-
import { unlinkSync as
|
|
17433
|
+
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync34 } from "fs";
|
|
17281
17434
|
import { tmpdir as tmpdir6 } from "os";
|
|
17282
|
-
import { join as
|
|
17435
|
+
import { join as join51 } from "path";
|
|
17283
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 } } } } } } }`;
|
|
17284
17437
|
function fetchThreadIds(org, repo, prNumber) {
|
|
17285
|
-
const queryFile =
|
|
17286
|
-
|
|
17438
|
+
const queryFile = join51(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
17439
|
+
writeFileSync34(queryFile, THREAD_QUERY);
|
|
17287
17440
|
try {
|
|
17288
17441
|
const result = execSync43(
|
|
17289
17442
|
`gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
|
|
@@ -17302,7 +17455,7 @@ function fetchThreadIds(org, repo, prNumber) {
|
|
|
17302
17455
|
}
|
|
17303
17456
|
return { threadMap, resolvedThreadIds };
|
|
17304
17457
|
} finally {
|
|
17305
|
-
|
|
17458
|
+
unlinkSync15(queryFile);
|
|
17306
17459
|
}
|
|
17307
17460
|
}
|
|
17308
17461
|
|
|
@@ -17351,20 +17504,20 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
17351
17504
|
}
|
|
17352
17505
|
|
|
17353
17506
|
// src/commands/prs/listComments/printComments.ts
|
|
17354
|
-
import
|
|
17507
|
+
import chalk157 from "chalk";
|
|
17355
17508
|
function formatForHuman(comment3) {
|
|
17356
17509
|
if (comment3.type === "review") {
|
|
17357
|
-
const stateColor = comment3.state === "APPROVED" ?
|
|
17510
|
+
const stateColor = comment3.state === "APPROVED" ? chalk157.green : comment3.state === "CHANGES_REQUESTED" ? chalk157.red : chalk157.yellow;
|
|
17358
17511
|
return [
|
|
17359
|
-
`${
|
|
17512
|
+
`${chalk157.cyan("Review")} by ${chalk157.bold(comment3.user)} ${stateColor(`[${comment3.state}]`)}`,
|
|
17360
17513
|
comment3.body,
|
|
17361
17514
|
""
|
|
17362
17515
|
].join("\n");
|
|
17363
17516
|
}
|
|
17364
17517
|
const location = comment3.line ? `:${comment3.line}` : "";
|
|
17365
17518
|
return [
|
|
17366
|
-
`${
|
|
17367
|
-
|
|
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")),
|
|
17368
17521
|
comment3.body,
|
|
17369
17522
|
""
|
|
17370
17523
|
].join("\n");
|
|
@@ -17396,17 +17549,17 @@ function printComments2(result) {
|
|
|
17396
17549
|
|
|
17397
17550
|
// src/commands/prs/listComments/index.ts
|
|
17398
17551
|
function writeCommentsCache(prNumber, comments3) {
|
|
17399
|
-
const assistDir =
|
|
17400
|
-
if (!
|
|
17401
|
-
|
|
17552
|
+
const assistDir = join52(process.cwd(), ".assist");
|
|
17553
|
+
if (!existsSync42(assistDir)) {
|
|
17554
|
+
mkdirSync17(assistDir, { recursive: true });
|
|
17402
17555
|
}
|
|
17403
17556
|
const cacheData = {
|
|
17404
17557
|
prNumber,
|
|
17405
17558
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17406
17559
|
comments: comments3
|
|
17407
17560
|
};
|
|
17408
|
-
const cachePath =
|
|
17409
|
-
|
|
17561
|
+
const cachePath = join52(assistDir, `pr-${prNumber}-comments.yaml`);
|
|
17562
|
+
writeFileSync35(cachePath, stringify(cacheData));
|
|
17410
17563
|
}
|
|
17411
17564
|
function handleKnownErrors(error) {
|
|
17412
17565
|
if (isGhNotInstalled(error)) {
|
|
@@ -17438,7 +17591,7 @@ async function listComments() {
|
|
|
17438
17591
|
];
|
|
17439
17592
|
updateCache(prNumber, allComments);
|
|
17440
17593
|
const hasLineComments = allComments.some((c) => c.type === "line");
|
|
17441
|
-
const cachePath = hasLineComments ?
|
|
17594
|
+
const cachePath = hasLineComments ? join52(process.cwd(), ".assist", `pr-${prNumber}-comments.yaml`) : null;
|
|
17442
17595
|
return { comments: allComments, cachePath };
|
|
17443
17596
|
} catch (error) {
|
|
17444
17597
|
const handled = handleKnownErrors(error);
|
|
@@ -17454,13 +17607,13 @@ import { execSync as execSync45 } from "child_process";
|
|
|
17454
17607
|
import enquirer9 from "enquirer";
|
|
17455
17608
|
|
|
17456
17609
|
// src/commands/prs/prs/displayPaginated/printPr.ts
|
|
17457
|
-
import
|
|
17610
|
+
import chalk158 from "chalk";
|
|
17458
17611
|
var STATUS_MAP = {
|
|
17459
|
-
MERGED: (pr) => pr.mergedAt ? { label:
|
|
17460
|
-
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
|
|
17461
17614
|
};
|
|
17462
17615
|
function defaultStatus(pr) {
|
|
17463
|
-
return { label:
|
|
17616
|
+
return { label: chalk158.green("opened"), date: pr.createdAt };
|
|
17464
17617
|
}
|
|
17465
17618
|
function getStatus2(pr) {
|
|
17466
17619
|
return STATUS_MAP[pr.state]?.(pr) ?? defaultStatus(pr);
|
|
@@ -17469,11 +17622,11 @@ function formatDate(dateStr) {
|
|
|
17469
17622
|
return new Date(dateStr).toISOString().split("T")[0];
|
|
17470
17623
|
}
|
|
17471
17624
|
function formatPrHeader(pr, status3) {
|
|
17472
|
-
return `${
|
|
17625
|
+
return `${chalk158.cyan(`#${pr.number}`)} ${pr.title} ${chalk158.dim(`(${pr.author.login},`)} ${status3.label} ${chalk158.dim(`${formatDate(status3.date)})`)}`;
|
|
17473
17626
|
}
|
|
17474
17627
|
function logPrDetails(pr) {
|
|
17475
17628
|
console.log(
|
|
17476
|
-
|
|
17629
|
+
chalk158.dim(` ${pr.changedFiles.toLocaleString()} files | ${pr.url}`)
|
|
17477
17630
|
);
|
|
17478
17631
|
console.log();
|
|
17479
17632
|
}
|
|
@@ -17822,10 +17975,10 @@ function registerPrs(program2) {
|
|
|
17822
17975
|
}
|
|
17823
17976
|
|
|
17824
17977
|
// src/commands/ravendb/ravendbAuth.ts
|
|
17825
|
-
import
|
|
17978
|
+
import chalk164 from "chalk";
|
|
17826
17979
|
|
|
17827
17980
|
// src/shared/createConnectionAuth.ts
|
|
17828
|
-
import
|
|
17981
|
+
import chalk159 from "chalk";
|
|
17829
17982
|
function listConnections(connections, format) {
|
|
17830
17983
|
if (connections.length === 0) {
|
|
17831
17984
|
console.log("No connections configured.");
|
|
@@ -17838,7 +17991,7 @@ function listConnections(connections, format) {
|
|
|
17838
17991
|
function removeConnection(connections, name, save) {
|
|
17839
17992
|
const filtered = connections.filter((c) => c.name !== name);
|
|
17840
17993
|
if (filtered.length === connections.length) {
|
|
17841
|
-
console.error(
|
|
17994
|
+
console.error(chalk159.red(`Connection "${name}" not found.`));
|
|
17842
17995
|
process.exit(1);
|
|
17843
17996
|
}
|
|
17844
17997
|
save(filtered);
|
|
@@ -17884,15 +18037,15 @@ function saveConnections(connections) {
|
|
|
17884
18037
|
}
|
|
17885
18038
|
|
|
17886
18039
|
// src/commands/ravendb/promptConnection.ts
|
|
17887
|
-
import
|
|
18040
|
+
import chalk162 from "chalk";
|
|
17888
18041
|
|
|
17889
18042
|
// src/commands/ravendb/selectOpSecret.ts
|
|
17890
|
-
import
|
|
18043
|
+
import chalk161 from "chalk";
|
|
17891
18044
|
import Enquirer2 from "enquirer";
|
|
17892
18045
|
|
|
17893
18046
|
// src/commands/ravendb/searchItems.ts
|
|
17894
18047
|
import { execSync as execSync48 } from "child_process";
|
|
17895
|
-
import
|
|
18048
|
+
import chalk160 from "chalk";
|
|
17896
18049
|
function opExec(args) {
|
|
17897
18050
|
return execSync48(`op ${args}`, {
|
|
17898
18051
|
encoding: "utf8",
|
|
@@ -17905,7 +18058,7 @@ function searchItems(search2) {
|
|
|
17905
18058
|
items2 = JSON.parse(opExec("item list --format=json"));
|
|
17906
18059
|
} catch {
|
|
17907
18060
|
console.error(
|
|
17908
|
-
|
|
18061
|
+
chalk160.red(
|
|
17909
18062
|
"Failed to search 1Password. Ensure the CLI is installed and you are signed in."
|
|
17910
18063
|
)
|
|
17911
18064
|
);
|
|
@@ -17919,7 +18072,7 @@ function getItemFields(itemId2) {
|
|
|
17919
18072
|
const item = JSON.parse(opExec(`item get "${itemId2}" --format=json`));
|
|
17920
18073
|
return item.fields.filter((f) => f.reference && f.label);
|
|
17921
18074
|
} catch {
|
|
17922
|
-
console.error(
|
|
18075
|
+
console.error(chalk160.red("Failed to get item details from 1Password."));
|
|
17923
18076
|
process.exit(1);
|
|
17924
18077
|
}
|
|
17925
18078
|
}
|
|
@@ -17938,7 +18091,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
17938
18091
|
}).run();
|
|
17939
18092
|
const items2 = searchItems(search2);
|
|
17940
18093
|
if (items2.length === 0) {
|
|
17941
|
-
console.error(
|
|
18094
|
+
console.error(chalk161.red(`No items found matching "${search2}".`));
|
|
17942
18095
|
process.exit(1);
|
|
17943
18096
|
}
|
|
17944
18097
|
const itemId2 = await selectOne(
|
|
@@ -17947,7 +18100,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
17947
18100
|
);
|
|
17948
18101
|
const fields = getItemFields(itemId2);
|
|
17949
18102
|
if (fields.length === 0) {
|
|
17950
|
-
console.error(
|
|
18103
|
+
console.error(chalk161.red("No fields with references found on this item."));
|
|
17951
18104
|
process.exit(1);
|
|
17952
18105
|
}
|
|
17953
18106
|
const ref = await selectOne(
|
|
@@ -17961,7 +18114,7 @@ async function selectOpSecret(searchTerm) {
|
|
|
17961
18114
|
async function promptConnection(existingNames) {
|
|
17962
18115
|
const name = await promptInput("name", "Connection name:");
|
|
17963
18116
|
if (existingNames.includes(name)) {
|
|
17964
|
-
console.error(
|
|
18117
|
+
console.error(chalk162.red(`Connection "${name}" already exists.`));
|
|
17965
18118
|
process.exit(1);
|
|
17966
18119
|
}
|
|
17967
18120
|
const url = await promptInput(
|
|
@@ -17970,22 +18123,22 @@ async function promptConnection(existingNames) {
|
|
|
17970
18123
|
);
|
|
17971
18124
|
const database = await promptInput("database", "Database name:");
|
|
17972
18125
|
if (!name || !url || !database) {
|
|
17973
|
-
console.error(
|
|
18126
|
+
console.error(chalk162.red("All fields are required."));
|
|
17974
18127
|
process.exit(1);
|
|
17975
18128
|
}
|
|
17976
18129
|
const apiKeyRef = await selectOpSecret();
|
|
17977
|
-
console.log(
|
|
18130
|
+
console.log(chalk162.dim(`Using: ${apiKeyRef}`));
|
|
17978
18131
|
return { name, url, database, apiKeyRef };
|
|
17979
18132
|
}
|
|
17980
18133
|
|
|
17981
18134
|
// src/commands/ravendb/ravendbSetConnection.ts
|
|
17982
|
-
import
|
|
18135
|
+
import chalk163 from "chalk";
|
|
17983
18136
|
function ravendbSetConnection(name) {
|
|
17984
18137
|
const raw = loadGlobalConfigRaw();
|
|
17985
18138
|
const ravendb = raw.ravendb ?? {};
|
|
17986
18139
|
const connections = ravendb.connections ?? [];
|
|
17987
18140
|
if (!connections.some((c) => c.name === name)) {
|
|
17988
|
-
console.error(
|
|
18141
|
+
console.error(chalk163.red(`Connection "${name}" not found.`));
|
|
17989
18142
|
console.error(
|
|
17990
18143
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
17991
18144
|
);
|
|
@@ -18001,16 +18154,16 @@ function ravendbSetConnection(name) {
|
|
|
18001
18154
|
var ravendbAuth = createConnectionAuth({
|
|
18002
18155
|
load: loadConnections,
|
|
18003
18156
|
save: saveConnections,
|
|
18004
|
-
format: (c) => `${
|
|
18157
|
+
format: (c) => `${chalk164.bold(c.name)} ${c.url} db=${c.database} key=${c.apiKeyRef}`,
|
|
18005
18158
|
promptNew: promptConnection,
|
|
18006
18159
|
onFirst: (c) => ravendbSetConnection(c.name)
|
|
18007
18160
|
});
|
|
18008
18161
|
|
|
18009
18162
|
// src/commands/ravendb/ravendbCollections.ts
|
|
18010
|
-
import
|
|
18163
|
+
import chalk168 from "chalk";
|
|
18011
18164
|
|
|
18012
18165
|
// src/commands/ravendb/ravenFetch.ts
|
|
18013
|
-
import
|
|
18166
|
+
import chalk166 from "chalk";
|
|
18014
18167
|
|
|
18015
18168
|
// src/commands/ravendb/getAccessToken.ts
|
|
18016
18169
|
var OAUTH_URL = "https://amazon-useast-1-oauth.ravenhq.com/ApiKeys/OAuth/AccessToken";
|
|
@@ -18047,10 +18200,10 @@ ${errorText}`
|
|
|
18047
18200
|
|
|
18048
18201
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
18049
18202
|
import { execSync as execSync49 } from "child_process";
|
|
18050
|
-
import
|
|
18203
|
+
import chalk165 from "chalk";
|
|
18051
18204
|
function resolveOpSecret(reference) {
|
|
18052
18205
|
if (!reference.startsWith("op://")) {
|
|
18053
|
-
console.error(
|
|
18206
|
+
console.error(chalk165.red(`Invalid secret reference: must start with op://`));
|
|
18054
18207
|
process.exit(1);
|
|
18055
18208
|
}
|
|
18056
18209
|
try {
|
|
@@ -18060,7 +18213,7 @@ function resolveOpSecret(reference) {
|
|
|
18060
18213
|
}).trim();
|
|
18061
18214
|
} catch {
|
|
18062
18215
|
console.error(
|
|
18063
|
-
|
|
18216
|
+
chalk165.red(
|
|
18064
18217
|
"Failed to resolve secret reference. Ensure 1Password CLI is installed and you are signed in."
|
|
18065
18218
|
)
|
|
18066
18219
|
);
|
|
@@ -18087,7 +18240,7 @@ async function ravenFetch(connection, path67) {
|
|
|
18087
18240
|
if (!response.ok) {
|
|
18088
18241
|
const body = await response.text();
|
|
18089
18242
|
console.error(
|
|
18090
|
-
|
|
18243
|
+
chalk166.red(`RavenDB error: ${response.status} ${response.statusText}`)
|
|
18091
18244
|
);
|
|
18092
18245
|
console.error(body.substring(0, 500));
|
|
18093
18246
|
process.exit(1);
|
|
@@ -18096,7 +18249,7 @@ async function ravenFetch(connection, path67) {
|
|
|
18096
18249
|
}
|
|
18097
18250
|
|
|
18098
18251
|
// src/commands/ravendb/resolveConnection.ts
|
|
18099
|
-
import
|
|
18252
|
+
import chalk167 from "chalk";
|
|
18100
18253
|
function loadRavendb() {
|
|
18101
18254
|
const raw = loadGlobalConfigRaw();
|
|
18102
18255
|
const ravendb = raw.ravendb;
|
|
@@ -18110,7 +18263,7 @@ function resolveConnection(name) {
|
|
|
18110
18263
|
const connectionName = name ?? defaultConnection;
|
|
18111
18264
|
if (!connectionName) {
|
|
18112
18265
|
console.error(
|
|
18113
|
-
|
|
18266
|
+
chalk167.red(
|
|
18114
18267
|
"No connection specified and no default set. Use assist ravendb set-connection <name> or pass a connection name."
|
|
18115
18268
|
)
|
|
18116
18269
|
);
|
|
@@ -18118,7 +18271,7 @@ function resolveConnection(name) {
|
|
|
18118
18271
|
}
|
|
18119
18272
|
const connection = connections.find((c) => c.name === connectionName);
|
|
18120
18273
|
if (!connection) {
|
|
18121
|
-
console.error(
|
|
18274
|
+
console.error(chalk167.red(`Connection "${connectionName}" not found.`));
|
|
18122
18275
|
console.error(
|
|
18123
18276
|
`Available: ${connections.map((c) => c.name).join(", ") || "(none)"}`
|
|
18124
18277
|
);
|
|
@@ -18149,7 +18302,7 @@ async function ravendbCollections(connectionName) {
|
|
|
18149
18302
|
return;
|
|
18150
18303
|
}
|
|
18151
18304
|
for (const c of collections) {
|
|
18152
|
-
console.log(`${
|
|
18305
|
+
console.log(`${chalk168.bold(c.Name)} ${c.CountOfDocuments} docs`);
|
|
18153
18306
|
}
|
|
18154
18307
|
}
|
|
18155
18308
|
|
|
@@ -18168,10 +18321,10 @@ var ravendbConfigHelp = [
|
|
|
18168
18321
|
];
|
|
18169
18322
|
|
|
18170
18323
|
// src/commands/ravendb/ravendbQuery.ts
|
|
18171
|
-
import
|
|
18324
|
+
import chalk170 from "chalk";
|
|
18172
18325
|
|
|
18173
18326
|
// src/commands/ravendb/fetchAllPages.ts
|
|
18174
|
-
import
|
|
18327
|
+
import chalk169 from "chalk";
|
|
18175
18328
|
|
|
18176
18329
|
// src/commands/ravendb/buildQueryPath.ts
|
|
18177
18330
|
function buildQueryPath(opts) {
|
|
@@ -18209,7 +18362,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18209
18362
|
allResults.push(...results);
|
|
18210
18363
|
start3 += results.length;
|
|
18211
18364
|
process.stderr.write(
|
|
18212
|
-
`\r${
|
|
18365
|
+
`\r${chalk169.dim(`Fetched ${allResults.length}/${totalResults}`)}`
|
|
18213
18366
|
);
|
|
18214
18367
|
if (start3 >= totalResults) break;
|
|
18215
18368
|
if (opts.limit !== void 0 && allResults.length >= opts.limit) break;
|
|
@@ -18224,7 +18377,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18224
18377
|
async function ravendbQuery(connectionName, collection, options2) {
|
|
18225
18378
|
const resolved = resolveArgs(connectionName, collection);
|
|
18226
18379
|
if (!resolved.collection && !options2.query) {
|
|
18227
|
-
console.error(
|
|
18380
|
+
console.error(chalk170.red("Provide a collection name or --query filter."));
|
|
18228
18381
|
process.exit(1);
|
|
18229
18382
|
}
|
|
18230
18383
|
const { collection: col } = resolved;
|
|
@@ -18263,7 +18416,7 @@ import { spawn as spawn5 } from "child_process";
|
|
|
18263
18416
|
import * as path34 from "path";
|
|
18264
18417
|
|
|
18265
18418
|
// src/commands/refactor/logViolations.ts
|
|
18266
|
-
import
|
|
18419
|
+
import chalk171 from "chalk";
|
|
18267
18420
|
var DEFAULT_MAX_LINES = 100;
|
|
18268
18421
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
18269
18422
|
if (violations.length === 0) {
|
|
@@ -18272,43 +18425,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES) {
|
|
|
18272
18425
|
}
|
|
18273
18426
|
return;
|
|
18274
18427
|
}
|
|
18275
|
-
console.error(
|
|
18428
|
+
console.error(chalk171.red(`
|
|
18276
18429
|
Refactor check failed:
|
|
18277
18430
|
`));
|
|
18278
|
-
console.error(
|
|
18431
|
+
console.error(chalk171.red(` The following files exceed ${maxLines} lines:
|
|
18279
18432
|
`));
|
|
18280
18433
|
for (const violation of violations) {
|
|
18281
|
-
console.error(
|
|
18434
|
+
console.error(chalk171.red(` ${violation.file} (${violation.lines} lines)`));
|
|
18282
18435
|
}
|
|
18283
18436
|
console.error(
|
|
18284
|
-
|
|
18437
|
+
chalk171.yellow(
|
|
18285
18438
|
`
|
|
18286
18439
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
18287
18440
|
way to refactor it, ignore it with:
|
|
18288
18441
|
`
|
|
18289
18442
|
)
|
|
18290
18443
|
);
|
|
18291
|
-
console.error(
|
|
18444
|
+
console.error(chalk171.gray(` assist refactor ignore <file>
|
|
18292
18445
|
`));
|
|
18293
18446
|
if (process.env.CLAUDECODE) {
|
|
18294
|
-
console.error(
|
|
18447
|
+
console.error(chalk171.cyan(`
|
|
18295
18448
|
## Extracting Code to New Files
|
|
18296
18449
|
`));
|
|
18297
18450
|
console.error(
|
|
18298
|
-
|
|
18451
|
+
chalk171.cyan(
|
|
18299
18452
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
18300
18453
|
`
|
|
18301
18454
|
)
|
|
18302
18455
|
);
|
|
18303
18456
|
console.error(
|
|
18304
|
-
|
|
18457
|
+
chalk171.cyan(
|
|
18305
18458
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
18306
18459
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
18307
18460
|
`
|
|
18308
18461
|
)
|
|
18309
18462
|
);
|
|
18310
18463
|
console.error(
|
|
18311
|
-
|
|
18464
|
+
chalk171.cyan(
|
|
18312
18465
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
18313
18466
|
domains, move it to a common/shared folder.
|
|
18314
18467
|
`
|
|
@@ -18464,7 +18617,7 @@ async function check(pattern2, options2) {
|
|
|
18464
18617
|
|
|
18465
18618
|
// src/commands/refactor/extract/index.ts
|
|
18466
18619
|
import path41 from "path";
|
|
18467
|
-
import
|
|
18620
|
+
import chalk174 from "chalk";
|
|
18468
18621
|
|
|
18469
18622
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
18470
18623
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -19063,23 +19216,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
19063
19216
|
|
|
19064
19217
|
// src/commands/refactor/extract/displayPlan.ts
|
|
19065
19218
|
import path38 from "path";
|
|
19066
|
-
import
|
|
19219
|
+
import chalk172 from "chalk";
|
|
19067
19220
|
function section2(title) {
|
|
19068
19221
|
return `
|
|
19069
|
-
${
|
|
19222
|
+
${chalk172.cyan(title)}`;
|
|
19070
19223
|
}
|
|
19071
19224
|
function displayImporters(plan2, cwd) {
|
|
19072
19225
|
if (plan2.importersToUpdate.length === 0) return;
|
|
19073
19226
|
console.log(section2("Update importers:"));
|
|
19074
19227
|
for (const imp of plan2.importersToUpdate) {
|
|
19075
19228
|
const rel = path38.relative(cwd, imp.file.getFilePath());
|
|
19076
|
-
console.log(` ${
|
|
19229
|
+
console.log(` ${chalk172.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
19077
19230
|
}
|
|
19078
19231
|
}
|
|
19079
19232
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
19080
|
-
console.log(
|
|
19233
|
+
console.log(chalk172.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
19081
19234
|
`));
|
|
19082
|
-
console.log(` ${
|
|
19235
|
+
console.log(` ${chalk172.cyan("Functions to move:")}`);
|
|
19083
19236
|
for (const name of plan2.extractedNames) {
|
|
19084
19237
|
console.log(` ${name}`);
|
|
19085
19238
|
}
|
|
@@ -19113,7 +19266,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
19113
19266
|
|
|
19114
19267
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
19115
19268
|
import path40 from "path";
|
|
19116
|
-
import
|
|
19269
|
+
import chalk173 from "chalk";
|
|
19117
19270
|
import { Project as Project4 } from "ts-morph";
|
|
19118
19271
|
|
|
19119
19272
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -19173,7 +19326,7 @@ function loadProjectFile(file) {
|
|
|
19173
19326
|
});
|
|
19174
19327
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
19175
19328
|
if (!sourceFile) {
|
|
19176
|
-
console.log(
|
|
19329
|
+
console.log(chalk173.red(`File not found in project: ${file}`));
|
|
19177
19330
|
process.exit(1);
|
|
19178
19331
|
}
|
|
19179
19332
|
return { project, sourceFile };
|
|
@@ -19196,19 +19349,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
19196
19349
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
19197
19350
|
if (options2.apply) {
|
|
19198
19351
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
19199
|
-
console.log(
|
|
19352
|
+
console.log(chalk174.green("\nExtraction complete"));
|
|
19200
19353
|
} else {
|
|
19201
|
-
console.log(
|
|
19354
|
+
console.log(chalk174.dim("\nDry run. Use --apply to execute."));
|
|
19202
19355
|
}
|
|
19203
19356
|
}
|
|
19204
19357
|
|
|
19205
19358
|
// src/commands/refactor/ignore.ts
|
|
19206
19359
|
import fs27 from "fs";
|
|
19207
|
-
import
|
|
19360
|
+
import chalk175 from "chalk";
|
|
19208
19361
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
19209
19362
|
function ignore2(file) {
|
|
19210
19363
|
if (!fs27.existsSync(file)) {
|
|
19211
|
-
console.error(
|
|
19364
|
+
console.error(chalk175.red(`Error: File does not exist: ${file}`));
|
|
19212
19365
|
process.exit(1);
|
|
19213
19366
|
}
|
|
19214
19367
|
const content = fs27.readFileSync(file, "utf8");
|
|
@@ -19224,7 +19377,7 @@ function ignore2(file) {
|
|
|
19224
19377
|
fs27.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
19225
19378
|
}
|
|
19226
19379
|
console.log(
|
|
19227
|
-
|
|
19380
|
+
chalk175.green(
|
|
19228
19381
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
19229
19382
|
)
|
|
19230
19383
|
);
|
|
@@ -19233,12 +19386,12 @@ function ignore2(file) {
|
|
|
19233
19386
|
// src/commands/refactor/rename/index.ts
|
|
19234
19387
|
import fs30 from "fs";
|
|
19235
19388
|
import path46 from "path";
|
|
19236
|
-
import
|
|
19389
|
+
import chalk178 from "chalk";
|
|
19237
19390
|
|
|
19238
19391
|
// src/commands/refactor/rename/applyRename.ts
|
|
19239
19392
|
import fs29 from "fs";
|
|
19240
19393
|
import path43 from "path";
|
|
19241
|
-
import
|
|
19394
|
+
import chalk176 from "chalk";
|
|
19242
19395
|
|
|
19243
19396
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
19244
19397
|
import path42 from "path";
|
|
@@ -19343,13 +19496,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
19343
19496
|
const updatedContents = applyRewrites(rewrites);
|
|
19344
19497
|
for (const [file, content] of updatedContents) {
|
|
19345
19498
|
fs29.writeFileSync(file, content, "utf8");
|
|
19346
|
-
console.log(
|
|
19499
|
+
console.log(chalk176.cyan(` Updated imports in ${path43.relative(cwd, file)}`));
|
|
19347
19500
|
}
|
|
19348
19501
|
const destDir = path43.dirname(destPath);
|
|
19349
19502
|
if (!fs29.existsSync(destDir)) fs29.mkdirSync(destDir, { recursive: true });
|
|
19350
19503
|
fs29.renameSync(sourcePath, destPath);
|
|
19351
19504
|
console.log(
|
|
19352
|
-
|
|
19505
|
+
chalk176.white(
|
|
19353
19506
|
` Moved ${path43.relative(cwd, sourcePath)} \u2192 ${path43.relative(cwd, destPath)}`
|
|
19354
19507
|
)
|
|
19355
19508
|
);
|
|
@@ -19436,16 +19589,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
19436
19589
|
|
|
19437
19590
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
19438
19591
|
import path45 from "path";
|
|
19439
|
-
import
|
|
19592
|
+
import chalk177 from "chalk";
|
|
19440
19593
|
function printRenamePreview(rewrites, cwd) {
|
|
19441
19594
|
for (const rewrite of rewrites) {
|
|
19442
19595
|
console.log(
|
|
19443
|
-
|
|
19596
|
+
chalk177.dim(
|
|
19444
19597
|
` ${path45.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
19445
19598
|
)
|
|
19446
19599
|
);
|
|
19447
19600
|
}
|
|
19448
|
-
console.log(
|
|
19601
|
+
console.log(chalk177.dim("Dry run. Use --apply to execute."));
|
|
19449
19602
|
}
|
|
19450
19603
|
|
|
19451
19604
|
// src/commands/refactor/rename/index.ts
|
|
@@ -19456,20 +19609,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
19456
19609
|
const relSource = path46.relative(cwd, sourcePath);
|
|
19457
19610
|
const relDest = path46.relative(cwd, destPath);
|
|
19458
19611
|
if (!fs30.existsSync(sourcePath)) {
|
|
19459
|
-
console.log(
|
|
19612
|
+
console.log(chalk178.red(`File not found: ${source}`));
|
|
19460
19613
|
process.exit(1);
|
|
19461
19614
|
}
|
|
19462
19615
|
if (destPath !== sourcePath && fs30.existsSync(destPath)) {
|
|
19463
|
-
console.log(
|
|
19616
|
+
console.log(chalk178.red(`Destination already exists: ${destination}`));
|
|
19464
19617
|
process.exit(1);
|
|
19465
19618
|
}
|
|
19466
|
-
console.log(
|
|
19467
|
-
console.log(
|
|
19468
|
-
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..."));
|
|
19469
19622
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
19470
19623
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
19471
19624
|
console.log(
|
|
19472
|
-
|
|
19625
|
+
chalk178.dim(
|
|
19473
19626
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
19474
19627
|
)
|
|
19475
19628
|
);
|
|
@@ -19478,11 +19631,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
19478
19631
|
return;
|
|
19479
19632
|
}
|
|
19480
19633
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
19481
|
-
console.log(
|
|
19634
|
+
console.log(chalk178.green("Done"));
|
|
19482
19635
|
}
|
|
19483
19636
|
|
|
19484
19637
|
// src/commands/refactor/renameSymbol/index.ts
|
|
19485
|
-
import
|
|
19638
|
+
import chalk179 from "chalk";
|
|
19486
19639
|
|
|
19487
19640
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
19488
19641
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -19528,33 +19681,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
19528
19681
|
const { project, sourceFile } = loadProjectFile(file);
|
|
19529
19682
|
const symbol = findSymbol(sourceFile, oldName);
|
|
19530
19683
|
if (!symbol) {
|
|
19531
|
-
console.log(
|
|
19684
|
+
console.log(chalk179.red(`Symbol "${oldName}" not found in ${file}`));
|
|
19532
19685
|
process.exit(1);
|
|
19533
19686
|
}
|
|
19534
19687
|
const grouped = groupReferences(symbol, cwd);
|
|
19535
19688
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
19536
19689
|
console.log(
|
|
19537
|
-
|
|
19690
|
+
chalk179.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
19538
19691
|
`)
|
|
19539
19692
|
);
|
|
19540
19693
|
for (const [refFile, lines] of grouped) {
|
|
19541
19694
|
console.log(
|
|
19542
|
-
` ${
|
|
19695
|
+
` ${chalk179.dim(refFile)}: lines ${chalk179.cyan(lines.join(", "))}`
|
|
19543
19696
|
);
|
|
19544
19697
|
}
|
|
19545
19698
|
if (options2.apply) {
|
|
19546
19699
|
symbol.rename(newName);
|
|
19547
19700
|
await project.save();
|
|
19548
|
-
console.log(
|
|
19701
|
+
console.log(chalk179.green(`
|
|
19549
19702
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
19550
19703
|
} else {
|
|
19551
|
-
console.log(
|
|
19704
|
+
console.log(chalk179.dim("\nDry run. Use --apply to execute."));
|
|
19552
19705
|
}
|
|
19553
19706
|
}
|
|
19554
19707
|
|
|
19555
19708
|
// src/commands/refactor/restructure/index.ts
|
|
19556
19709
|
import path54 from "path";
|
|
19557
|
-
import
|
|
19710
|
+
import chalk182 from "chalk";
|
|
19558
19711
|
|
|
19559
19712
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
19560
19713
|
import path48 from "path";
|
|
@@ -19633,50 +19786,50 @@ function clusterFiles(graph) {
|
|
|
19633
19786
|
|
|
19634
19787
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
19635
19788
|
import path50 from "path";
|
|
19636
|
-
import
|
|
19789
|
+
import chalk180 from "chalk";
|
|
19637
19790
|
function relPath(filePath) {
|
|
19638
19791
|
return path50.relative(process.cwd(), filePath);
|
|
19639
19792
|
}
|
|
19640
19793
|
function displayMoves(plan2) {
|
|
19641
19794
|
if (plan2.moves.length === 0) return;
|
|
19642
|
-
console.log(
|
|
19795
|
+
console.log(chalk180.bold("\nFile moves:"));
|
|
19643
19796
|
for (const move2 of plan2.moves) {
|
|
19644
19797
|
console.log(
|
|
19645
|
-
` ${
|
|
19798
|
+
` ${chalk180.red(relPath(move2.from))} \u2192 ${chalk180.green(relPath(move2.to))}`
|
|
19646
19799
|
);
|
|
19647
|
-
console.log(
|
|
19800
|
+
console.log(chalk180.dim(` ${move2.reason}`));
|
|
19648
19801
|
}
|
|
19649
19802
|
}
|
|
19650
19803
|
function displayRewrites(rewrites) {
|
|
19651
19804
|
if (rewrites.length === 0) return;
|
|
19652
19805
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
19653
|
-
console.log(
|
|
19806
|
+
console.log(chalk180.bold(`
|
|
19654
19807
|
Import rewrites (${affectedFiles.size} files):`));
|
|
19655
19808
|
for (const file of affectedFiles) {
|
|
19656
|
-
console.log(` ${
|
|
19809
|
+
console.log(` ${chalk180.cyan(relPath(file))}:`);
|
|
19657
19810
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
19658
19811
|
(r) => r.file === file
|
|
19659
19812
|
)) {
|
|
19660
19813
|
console.log(
|
|
19661
|
-
` ${
|
|
19814
|
+
` ${chalk180.red(`"${oldSpecifier}"`)} \u2192 ${chalk180.green(`"${newSpecifier}"`)}`
|
|
19662
19815
|
);
|
|
19663
19816
|
}
|
|
19664
19817
|
}
|
|
19665
19818
|
}
|
|
19666
19819
|
function displayPlan2(plan2) {
|
|
19667
19820
|
if (plan2.warnings.length > 0) {
|
|
19668
|
-
console.log(
|
|
19669
|
-
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}`));
|
|
19670
19823
|
}
|
|
19671
19824
|
if (plan2.newDirectories.length > 0) {
|
|
19672
|
-
console.log(
|
|
19825
|
+
console.log(chalk180.bold("\nNew directories:"));
|
|
19673
19826
|
for (const dir of plan2.newDirectories)
|
|
19674
|
-
console.log(
|
|
19827
|
+
console.log(chalk180.green(` ${dir}/`));
|
|
19675
19828
|
}
|
|
19676
19829
|
displayMoves(plan2);
|
|
19677
19830
|
displayRewrites(plan2.rewrites);
|
|
19678
19831
|
console.log(
|
|
19679
|
-
|
|
19832
|
+
chalk180.dim(
|
|
19680
19833
|
`
|
|
19681
19834
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
19682
19835
|
)
|
|
@@ -19686,18 +19839,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
19686
19839
|
// src/commands/refactor/restructure/executePlan.ts
|
|
19687
19840
|
import fs31 from "fs";
|
|
19688
19841
|
import path51 from "path";
|
|
19689
|
-
import
|
|
19842
|
+
import chalk181 from "chalk";
|
|
19690
19843
|
function executePlan(plan2) {
|
|
19691
19844
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
19692
19845
|
for (const [file, content] of updatedContents) {
|
|
19693
19846
|
fs31.writeFileSync(file, content, "utf8");
|
|
19694
19847
|
console.log(
|
|
19695
|
-
|
|
19848
|
+
chalk181.cyan(` Rewrote imports in ${path51.relative(process.cwd(), file)}`)
|
|
19696
19849
|
);
|
|
19697
19850
|
}
|
|
19698
19851
|
for (const dir of plan2.newDirectories) {
|
|
19699
19852
|
fs31.mkdirSync(dir, { recursive: true });
|
|
19700
|
-
console.log(
|
|
19853
|
+
console.log(chalk181.green(` Created ${path51.relative(process.cwd(), dir)}/`));
|
|
19701
19854
|
}
|
|
19702
19855
|
for (const move2 of plan2.moves) {
|
|
19703
19856
|
const targetDir = path51.dirname(move2.to);
|
|
@@ -19706,7 +19859,7 @@ function executePlan(plan2) {
|
|
|
19706
19859
|
}
|
|
19707
19860
|
fs31.renameSync(move2.from, move2.to);
|
|
19708
19861
|
console.log(
|
|
19709
|
-
|
|
19862
|
+
chalk181.white(
|
|
19710
19863
|
` Moved ${path51.relative(process.cwd(), move2.from)} \u2192 ${path51.relative(process.cwd(), move2.to)}`
|
|
19711
19864
|
)
|
|
19712
19865
|
);
|
|
@@ -19721,7 +19874,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
19721
19874
|
if (entries.length === 0) {
|
|
19722
19875
|
fs31.rmdirSync(dir);
|
|
19723
19876
|
console.log(
|
|
19724
|
-
|
|
19877
|
+
chalk181.dim(
|
|
19725
19878
|
` Removed empty directory ${path51.relative(process.cwd(), dir)}`
|
|
19726
19879
|
)
|
|
19727
19880
|
);
|
|
@@ -19854,22 +20007,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
19854
20007
|
const targetPattern = pattern2 ?? "src";
|
|
19855
20008
|
const files = findSourceFiles2(targetPattern);
|
|
19856
20009
|
if (files.length === 0) {
|
|
19857
|
-
console.log(
|
|
20010
|
+
console.log(chalk182.yellow("No files found matching pattern"));
|
|
19858
20011
|
return;
|
|
19859
20012
|
}
|
|
19860
20013
|
const tsConfigPath = path54.resolve("tsconfig.json");
|
|
19861
20014
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
19862
20015
|
if (plan2.moves.length === 0) {
|
|
19863
|
-
console.log(
|
|
20016
|
+
console.log(chalk182.green("No restructuring needed"));
|
|
19864
20017
|
return;
|
|
19865
20018
|
}
|
|
19866
20019
|
displayPlan2(plan2);
|
|
19867
20020
|
if (options2.apply) {
|
|
19868
|
-
console.log(
|
|
20021
|
+
console.log(chalk182.bold("\nApplying changes..."));
|
|
19869
20022
|
executePlan(plan2);
|
|
19870
|
-
console.log(
|
|
20023
|
+
console.log(chalk182.green("\nRestructuring complete"));
|
|
19871
20024
|
} else {
|
|
19872
|
-
console.log(
|
|
20025
|
+
console.log(chalk182.dim("\nDry run. Use --apply to execute."));
|
|
19873
20026
|
}
|
|
19874
20027
|
}
|
|
19875
20028
|
|
|
@@ -20035,9 +20188,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
20035
20188
|
|
|
20036
20189
|
// src/commands/review/buildReviewPaths.ts
|
|
20037
20190
|
import { homedir as homedir20 } from "os";
|
|
20038
|
-
import { basename as basename12, join as
|
|
20191
|
+
import { basename as basename12, join as join53 } from "path";
|
|
20039
20192
|
function buildReviewPaths(repoRoot, key) {
|
|
20040
|
-
const reviewDir =
|
|
20193
|
+
const reviewDir = join53(
|
|
20041
20194
|
homedir20(),
|
|
20042
20195
|
".assist",
|
|
20043
20196
|
"reviews",
|
|
@@ -20046,10 +20199,10 @@ function buildReviewPaths(repoRoot, key) {
|
|
|
20046
20199
|
);
|
|
20047
20200
|
return {
|
|
20048
20201
|
reviewDir,
|
|
20049
|
-
requestPath:
|
|
20050
|
-
claudePath:
|
|
20051
|
-
codexPath:
|
|
20052
|
-
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")
|
|
20053
20206
|
};
|
|
20054
20207
|
}
|
|
20055
20208
|
|
|
@@ -20191,7 +20344,7 @@ function gatherContext() {
|
|
|
20191
20344
|
}
|
|
20192
20345
|
|
|
20193
20346
|
// src/commands/review/postReviewToPr.ts
|
|
20194
|
-
import { readFileSync as
|
|
20347
|
+
import { readFileSync as readFileSync39 } from "fs";
|
|
20195
20348
|
|
|
20196
20349
|
// src/commands/review/parseFindings.ts
|
|
20197
20350
|
var SEVERITIES = ["blocker", "major", "minor", "nit"];
|
|
@@ -20452,18 +20605,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
20452
20605
|
}
|
|
20453
20606
|
|
|
20454
20607
|
// src/commands/review/warnOutOfDiff.ts
|
|
20455
|
-
import
|
|
20608
|
+
import chalk183 from "chalk";
|
|
20456
20609
|
function warnOutOfDiff(outOfDiff) {
|
|
20457
20610
|
if (outOfDiff.length === 0) return;
|
|
20458
20611
|
console.warn(
|
|
20459
|
-
|
|
20612
|
+
chalk183.yellow(
|
|
20460
20613
|
`Skipped ${outOfDiff.length} finding(s) whose lines fall outside the PR diff (GitHub would silently drop these):`
|
|
20461
20614
|
)
|
|
20462
20615
|
);
|
|
20463
20616
|
for (const finding of outOfDiff) {
|
|
20464
20617
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
20465
20618
|
console.warn(
|
|
20466
|
-
` ${
|
|
20619
|
+
` ${chalk183.yellow("\xB7")} ${finding.title} ${chalk183.dim(
|
|
20467
20620
|
`(${finding.file}:${range})`
|
|
20468
20621
|
)}`
|
|
20469
20622
|
);
|
|
@@ -20482,18 +20635,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
20482
20635
|
}
|
|
20483
20636
|
|
|
20484
20637
|
// src/commands/review/warnUnlocated.ts
|
|
20485
|
-
import
|
|
20638
|
+
import chalk184 from "chalk";
|
|
20486
20639
|
function warnUnlocated(unlocated) {
|
|
20487
20640
|
if (unlocated.length === 0) return;
|
|
20488
20641
|
console.warn(
|
|
20489
|
-
|
|
20642
|
+
chalk184.yellow(
|
|
20490
20643
|
`Skipped ${unlocated.length} finding(s) without a parseable file:line:`
|
|
20491
20644
|
)
|
|
20492
20645
|
);
|
|
20493
20646
|
for (const finding of unlocated) {
|
|
20494
|
-
const where = finding.location ||
|
|
20647
|
+
const where = finding.location || chalk184.dim("missing");
|
|
20495
20648
|
console.warn(
|
|
20496
|
-
` ${
|
|
20649
|
+
` ${chalk184.yellow("\xB7")} ${finding.title} ${chalk184.dim(`(${where})`)}`
|
|
20497
20650
|
);
|
|
20498
20651
|
}
|
|
20499
20652
|
}
|
|
@@ -20506,7 +20659,7 @@ async function confirmPost(prNumber, count7, options2) {
|
|
|
20506
20659
|
async function postReviewToPr(synthesisPath, options2) {
|
|
20507
20660
|
const prInfo = fetchPrDiffInfo();
|
|
20508
20661
|
const prNumber = prInfo.prNumber;
|
|
20509
|
-
const markdown =
|
|
20662
|
+
const markdown = readFileSync39(synthesisPath, "utf8");
|
|
20510
20663
|
const findings = parseFindings(markdown);
|
|
20511
20664
|
if (findings.length === 0) {
|
|
20512
20665
|
console.log("Synthesis contains no findings; nothing to post.");
|
|
@@ -20588,16 +20741,16 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
20588
20741
|
}
|
|
20589
20742
|
|
|
20590
20743
|
// src/commands/review/prepareReviewDir.ts
|
|
20591
|
-
import { existsSync as
|
|
20744
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync18, unlinkSync as unlinkSync16, writeFileSync as writeFileSync36 } from "fs";
|
|
20592
20745
|
function clearReviewFiles(paths) {
|
|
20593
20746
|
for (const path67 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
20594
|
-
if (
|
|
20747
|
+
if (existsSync43(path67)) unlinkSync16(path67);
|
|
20595
20748
|
}
|
|
20596
20749
|
}
|
|
20597
20750
|
function prepareReviewDir(paths, requestBody, force) {
|
|
20598
|
-
|
|
20751
|
+
mkdirSync18(paths.reviewDir, { recursive: true });
|
|
20599
20752
|
if (force) clearReviewFiles(paths);
|
|
20600
|
-
|
|
20753
|
+
writeFileSync36(paths.requestPath, requestBody);
|
|
20601
20754
|
}
|
|
20602
20755
|
|
|
20603
20756
|
// src/commands/review/runApplySession.ts
|
|
@@ -20876,7 +21029,7 @@ function printReviewerFailures(results) {
|
|
|
20876
21029
|
}
|
|
20877
21030
|
|
|
20878
21031
|
// src/commands/review/runAndSynthesise.ts
|
|
20879
|
-
import { existsSync as
|
|
21032
|
+
import { existsSync as existsSync45, unlinkSync as unlinkSync18 } from "fs";
|
|
20880
21033
|
|
|
20881
21034
|
// src/commands/review/buildReviewerStdin.ts
|
|
20882
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.
|
|
@@ -20942,7 +21095,7 @@ The review request is at: ${requestPath}
|
|
|
20942
21095
|
}
|
|
20943
21096
|
|
|
20944
21097
|
// src/commands/review/runClaudeReviewer.ts
|
|
20945
|
-
import { writeFileSync as
|
|
21098
|
+
import { writeFileSync as writeFileSync37 } from "fs";
|
|
20946
21099
|
|
|
20947
21100
|
// src/commands/review/finaliseReviewerSpinner.ts
|
|
20948
21101
|
var SUMMARY_MAX_LEN = 80;
|
|
@@ -21278,7 +21431,7 @@ async function runClaudeReviewer(spec) {
|
|
|
21278
21431
|
}
|
|
21279
21432
|
});
|
|
21280
21433
|
if (result.exitCode === 0 && finalText)
|
|
21281
|
-
|
|
21434
|
+
writeFileSync37(spec.outputPath, finalText);
|
|
21282
21435
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
21283
21436
|
}
|
|
21284
21437
|
|
|
@@ -21296,7 +21449,7 @@ function resolveClaude(args) {
|
|
|
21296
21449
|
}
|
|
21297
21450
|
|
|
21298
21451
|
// src/commands/review/runCodexReviewer.ts
|
|
21299
|
-
import { existsSync as
|
|
21452
|
+
import { existsSync as existsSync44, unlinkSync as unlinkSync17 } from "fs";
|
|
21300
21453
|
|
|
21301
21454
|
// src/commands/review/parseCodexEvent.ts
|
|
21302
21455
|
function isItemStarted(value) {
|
|
@@ -21348,8 +21501,8 @@ async function runCodexReviewer(spec) {
|
|
|
21348
21501
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
21349
21502
|
}
|
|
21350
21503
|
});
|
|
21351
|
-
if (result.exitCode !== 0 &&
|
|
21352
|
-
|
|
21504
|
+
if (result.exitCode !== 0 && existsSync44(spec.outputPath)) {
|
|
21505
|
+
unlinkSync17(spec.outputPath);
|
|
21353
21506
|
}
|
|
21354
21507
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
21355
21508
|
}
|
|
@@ -21390,7 +21543,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
21390
21543
|
}
|
|
21391
21544
|
|
|
21392
21545
|
// src/commands/review/synthesise.ts
|
|
21393
|
-
import { readFileSync as
|
|
21546
|
+
import { readFileSync as readFileSync40 } from "fs";
|
|
21394
21547
|
|
|
21395
21548
|
// src/commands/review/buildSynthesisStdin.ts
|
|
21396
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.
|
|
@@ -21446,7 +21599,7 @@ Files:
|
|
|
21446
21599
|
|
|
21447
21600
|
// src/commands/review/synthesise.ts
|
|
21448
21601
|
function printSummary2(synthesisPath) {
|
|
21449
|
-
const markdown =
|
|
21602
|
+
const markdown = readFileSync40(synthesisPath, "utf8");
|
|
21450
21603
|
console.log("");
|
|
21451
21604
|
console.log(buildReviewSummary(markdown));
|
|
21452
21605
|
console.log("");
|
|
@@ -21494,8 +21647,8 @@ async function runAndSynthesise(args) {
|
|
|
21494
21647
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
21495
21648
|
return { ok: false, failures };
|
|
21496
21649
|
}
|
|
21497
|
-
if (anyFresh &&
|
|
21498
|
-
|
|
21650
|
+
if (anyFresh && existsSync45(paths.synthesisPath)) {
|
|
21651
|
+
unlinkSync18(paths.synthesisPath);
|
|
21499
21652
|
}
|
|
21500
21653
|
const synthesisResult = await synthesise(paths, { multi });
|
|
21501
21654
|
if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
|
|
@@ -21665,7 +21818,7 @@ function registerReview(program2) {
|
|
|
21665
21818
|
}
|
|
21666
21819
|
|
|
21667
21820
|
// src/commands/seq/seqAuth.ts
|
|
21668
|
-
import
|
|
21821
|
+
import chalk186 from "chalk";
|
|
21669
21822
|
|
|
21670
21823
|
// src/commands/seq/loadConnections.ts
|
|
21671
21824
|
function loadConnections2() {
|
|
@@ -21694,10 +21847,10 @@ function setDefaultConnection(name) {
|
|
|
21694
21847
|
}
|
|
21695
21848
|
|
|
21696
21849
|
// src/shared/assertUniqueName.ts
|
|
21697
|
-
import
|
|
21850
|
+
import chalk185 from "chalk";
|
|
21698
21851
|
function assertUniqueName(existingNames, name) {
|
|
21699
21852
|
if (existingNames.includes(name)) {
|
|
21700
|
-
console.error(
|
|
21853
|
+
console.error(chalk185.red(`Connection "${name}" already exists.`));
|
|
21701
21854
|
process.exit(1);
|
|
21702
21855
|
}
|
|
21703
21856
|
}
|
|
@@ -21715,7 +21868,7 @@ async function promptConnection2(existingNames) {
|
|
|
21715
21868
|
var seqAuth = createConnectionAuth({
|
|
21716
21869
|
load: loadConnections2,
|
|
21717
21870
|
save: saveConnections2,
|
|
21718
|
-
format: (c) => `${
|
|
21871
|
+
format: (c) => `${chalk186.bold(c.name)} ${c.url}`,
|
|
21719
21872
|
promptNew: promptConnection2,
|
|
21720
21873
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
21721
21874
|
});
|
|
@@ -21735,10 +21888,10 @@ var seqConfigHelp = [
|
|
|
21735
21888
|
];
|
|
21736
21889
|
|
|
21737
21890
|
// src/commands/seq/seqQuery.ts
|
|
21738
|
-
import
|
|
21891
|
+
import chalk190 from "chalk";
|
|
21739
21892
|
|
|
21740
21893
|
// src/commands/seq/fetchSeq.ts
|
|
21741
|
-
import
|
|
21894
|
+
import chalk187 from "chalk";
|
|
21742
21895
|
async function fetchSeq(conn, path67, params) {
|
|
21743
21896
|
const url = `${conn.url}${path67}?${params}`;
|
|
21744
21897
|
const response = await fetch(url, {
|
|
@@ -21749,7 +21902,7 @@ async function fetchSeq(conn, path67, params) {
|
|
|
21749
21902
|
});
|
|
21750
21903
|
if (!response.ok) {
|
|
21751
21904
|
const body = await response.text();
|
|
21752
|
-
console.error(
|
|
21905
|
+
console.error(chalk187.red(`Seq returned ${response.status}: ${body}`));
|
|
21753
21906
|
process.exit(1);
|
|
21754
21907
|
}
|
|
21755
21908
|
return response;
|
|
@@ -21808,23 +21961,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
21808
21961
|
}
|
|
21809
21962
|
|
|
21810
21963
|
// src/commands/seq/formatEvent.ts
|
|
21811
|
-
import
|
|
21964
|
+
import chalk188 from "chalk";
|
|
21812
21965
|
function levelColor(level) {
|
|
21813
21966
|
switch (level) {
|
|
21814
21967
|
case "Fatal":
|
|
21815
|
-
return
|
|
21968
|
+
return chalk188.bgRed.white;
|
|
21816
21969
|
case "Error":
|
|
21817
|
-
return
|
|
21970
|
+
return chalk188.red;
|
|
21818
21971
|
case "Warning":
|
|
21819
|
-
return
|
|
21972
|
+
return chalk188.yellow;
|
|
21820
21973
|
case "Information":
|
|
21821
|
-
return
|
|
21974
|
+
return chalk188.cyan;
|
|
21822
21975
|
case "Debug":
|
|
21823
|
-
return
|
|
21976
|
+
return chalk188.gray;
|
|
21824
21977
|
case "Verbose":
|
|
21825
|
-
return
|
|
21978
|
+
return chalk188.dim;
|
|
21826
21979
|
default:
|
|
21827
|
-
return
|
|
21980
|
+
return chalk188.white;
|
|
21828
21981
|
}
|
|
21829
21982
|
}
|
|
21830
21983
|
function levelAbbrev(level) {
|
|
@@ -21865,12 +22018,12 @@ function formatTimestamp(iso) {
|
|
|
21865
22018
|
function formatEvent(event) {
|
|
21866
22019
|
const color = levelColor(event.Level);
|
|
21867
22020
|
const abbrev = levelAbbrev(event.Level);
|
|
21868
|
-
const ts8 =
|
|
22021
|
+
const ts8 = chalk188.dim(formatTimestamp(event.Timestamp));
|
|
21869
22022
|
const msg = renderMessage(event);
|
|
21870
22023
|
const lines = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
21871
22024
|
if (event.Exception) {
|
|
21872
22025
|
for (const line of event.Exception.split("\n")) {
|
|
21873
|
-
lines.push(
|
|
22026
|
+
lines.push(chalk188.red(` ${line}`));
|
|
21874
22027
|
}
|
|
21875
22028
|
}
|
|
21876
22029
|
return lines.join("\n");
|
|
@@ -21903,11 +22056,11 @@ function rejectTimestampFilter(filter) {
|
|
|
21903
22056
|
}
|
|
21904
22057
|
|
|
21905
22058
|
// src/shared/resolveNamedConnection.ts
|
|
21906
|
-
import
|
|
22059
|
+
import chalk189 from "chalk";
|
|
21907
22060
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
21908
22061
|
if (connections.length === 0) {
|
|
21909
22062
|
console.error(
|
|
21910
|
-
|
|
22063
|
+
chalk189.red(
|
|
21911
22064
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
21912
22065
|
)
|
|
21913
22066
|
);
|
|
@@ -21916,7 +22069,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
21916
22069
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
21917
22070
|
const connection = connections.find((c) => c.name === target);
|
|
21918
22071
|
if (!connection) {
|
|
21919
|
-
console.error(
|
|
22072
|
+
console.error(chalk189.red(`${kind} connection "${target}" not found.`));
|
|
21920
22073
|
process.exit(1);
|
|
21921
22074
|
}
|
|
21922
22075
|
return connection;
|
|
@@ -21945,7 +22098,7 @@ async function seqQuery(filter, options2) {
|
|
|
21945
22098
|
new URLSearchParams({ filter, count: String(count7) })
|
|
21946
22099
|
);
|
|
21947
22100
|
if (events.length === 0) {
|
|
21948
|
-
console.log(
|
|
22101
|
+
console.log(chalk190.yellow("No events found."));
|
|
21949
22102
|
return;
|
|
21950
22103
|
}
|
|
21951
22104
|
if (options2.json) {
|
|
@@ -21956,11 +22109,11 @@ async function seqQuery(filter, options2) {
|
|
|
21956
22109
|
for (const event of chronological) {
|
|
21957
22110
|
console.log(formatEvent(event));
|
|
21958
22111
|
}
|
|
21959
|
-
console.log(
|
|
22112
|
+
console.log(chalk190.dim(`
|
|
21960
22113
|
${events.length} events`));
|
|
21961
22114
|
if (events.length >= count7) {
|
|
21962
22115
|
console.log(
|
|
21963
|
-
|
|
22116
|
+
chalk190.yellow(
|
|
21964
22117
|
`Results limited to ${count7}. Use --count to retrieve more.`
|
|
21965
22118
|
)
|
|
21966
22119
|
);
|
|
@@ -21968,10 +22121,10 @@ ${events.length} events`));
|
|
|
21968
22121
|
}
|
|
21969
22122
|
|
|
21970
22123
|
// src/shared/setNamedDefaultConnection.ts
|
|
21971
|
-
import
|
|
22124
|
+
import chalk191 from "chalk";
|
|
21972
22125
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
21973
22126
|
if (!connections.find((c) => c.name === name)) {
|
|
21974
|
-
console.error(
|
|
22127
|
+
console.error(chalk191.red(`Connection "${name}" not found.`));
|
|
21975
22128
|
process.exit(1);
|
|
21976
22129
|
}
|
|
21977
22130
|
setDefault(name);
|
|
@@ -22020,7 +22173,7 @@ function registerSignal(program2) {
|
|
|
22020
22173
|
}
|
|
22021
22174
|
|
|
22022
22175
|
// src/commands/sql/sqlAuth.ts
|
|
22023
|
-
import
|
|
22176
|
+
import chalk193 from "chalk";
|
|
22024
22177
|
|
|
22025
22178
|
// src/commands/sql/loadConnections.ts
|
|
22026
22179
|
function loadConnections3() {
|
|
@@ -22049,7 +22202,7 @@ function setDefaultConnection2(name) {
|
|
|
22049
22202
|
}
|
|
22050
22203
|
|
|
22051
22204
|
// src/commands/sql/promptConnection.ts
|
|
22052
|
-
import
|
|
22205
|
+
import chalk192 from "chalk";
|
|
22053
22206
|
async function promptConnection3(existingNames) {
|
|
22054
22207
|
const name = await promptInput("name", "Connection name:", "default");
|
|
22055
22208
|
assertUniqueName(existingNames, name);
|
|
@@ -22057,7 +22210,7 @@ async function promptConnection3(existingNames) {
|
|
|
22057
22210
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
22058
22211
|
const port = Number.parseInt(portStr, 10);
|
|
22059
22212
|
if (!Number.isFinite(port)) {
|
|
22060
|
-
console.error(
|
|
22213
|
+
console.error(chalk192.red(`Invalid port "${portStr}".`));
|
|
22061
22214
|
process.exit(1);
|
|
22062
22215
|
}
|
|
22063
22216
|
const user = await promptInput("user", "User:");
|
|
@@ -22070,13 +22223,13 @@ async function promptConnection3(existingNames) {
|
|
|
22070
22223
|
var sqlAuth = createConnectionAuth({
|
|
22071
22224
|
load: loadConnections3,
|
|
22072
22225
|
save: saveConnections3,
|
|
22073
|
-
format: (c) => `${
|
|
22226
|
+
format: (c) => `${chalk193.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
22074
22227
|
promptNew: promptConnection3,
|
|
22075
22228
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
22076
22229
|
});
|
|
22077
22230
|
|
|
22078
22231
|
// src/commands/sql/printTable.ts
|
|
22079
|
-
import
|
|
22232
|
+
import chalk194 from "chalk";
|
|
22080
22233
|
function formatCell(value) {
|
|
22081
22234
|
if (value === null || value === void 0) return "";
|
|
22082
22235
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -22085,7 +22238,7 @@ function formatCell(value) {
|
|
|
22085
22238
|
}
|
|
22086
22239
|
function printTable(rows) {
|
|
22087
22240
|
if (rows.length === 0) {
|
|
22088
|
-
console.log(
|
|
22241
|
+
console.log(chalk194.yellow("(no rows)"));
|
|
22089
22242
|
return;
|
|
22090
22243
|
}
|
|
22091
22244
|
const columns = Object.keys(rows[0]);
|
|
@@ -22093,13 +22246,13 @@ function printTable(rows) {
|
|
|
22093
22246
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
22094
22247
|
);
|
|
22095
22248
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
22096
|
-
console.log(
|
|
22097
|
-
console.log(
|
|
22249
|
+
console.log(chalk194.dim(header));
|
|
22250
|
+
console.log(chalk194.dim("-".repeat(header.length)));
|
|
22098
22251
|
for (const row of rows) {
|
|
22099
22252
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
22100
22253
|
console.log(line);
|
|
22101
22254
|
}
|
|
22102
|
-
console.log(
|
|
22255
|
+
console.log(chalk194.dim(`
|
|
22103
22256
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
22104
22257
|
}
|
|
22105
22258
|
|
|
@@ -22173,7 +22326,7 @@ var sqlConfigHelp = [
|
|
|
22173
22326
|
];
|
|
22174
22327
|
|
|
22175
22328
|
// src/commands/sql/sqlMutate.ts
|
|
22176
|
-
import
|
|
22329
|
+
import chalk195 from "chalk";
|
|
22177
22330
|
|
|
22178
22331
|
// src/commands/sql/isMutation.ts
|
|
22179
22332
|
var MUTATION_KEYWORDS = [
|
|
@@ -22207,7 +22360,7 @@ function isMutation(sql24) {
|
|
|
22207
22360
|
async function sqlMutate(query, connectionName) {
|
|
22208
22361
|
if (!isMutation(query)) {
|
|
22209
22362
|
console.error(
|
|
22210
|
-
|
|
22363
|
+
chalk195.red(
|
|
22211
22364
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
22212
22365
|
)
|
|
22213
22366
|
);
|
|
@@ -22217,18 +22370,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
22217
22370
|
const pool = await sqlConnect(conn);
|
|
22218
22371
|
try {
|
|
22219
22372
|
const result = await pool.request().query(query);
|
|
22220
|
-
console.log(
|
|
22373
|
+
console.log(chalk195.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
22221
22374
|
} finally {
|
|
22222
22375
|
await pool.close();
|
|
22223
22376
|
}
|
|
22224
22377
|
}
|
|
22225
22378
|
|
|
22226
22379
|
// src/commands/sql/sqlQuery.ts
|
|
22227
|
-
import
|
|
22380
|
+
import chalk196 from "chalk";
|
|
22228
22381
|
async function sqlQuery(query, connectionName) {
|
|
22229
22382
|
if (isMutation(query)) {
|
|
22230
22383
|
console.error(
|
|
22231
|
-
|
|
22384
|
+
chalk196.red(
|
|
22232
22385
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
22233
22386
|
)
|
|
22234
22387
|
);
|
|
@@ -22243,7 +22396,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
22243
22396
|
printTable(rows);
|
|
22244
22397
|
} else {
|
|
22245
22398
|
console.log(
|
|
22246
|
-
|
|
22399
|
+
chalk196.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
22247
22400
|
);
|
|
22248
22401
|
}
|
|
22249
22402
|
} finally {
|
|
@@ -22374,27 +22527,27 @@ async function configure() {
|
|
|
22374
22527
|
}
|
|
22375
22528
|
|
|
22376
22529
|
// src/commands/transcript/list.ts
|
|
22377
|
-
import { existsSync as
|
|
22378
|
-
import { join as
|
|
22530
|
+
import { existsSync as existsSync46, readdirSync as readdirSync10, statSync as statSync7 } from "fs";
|
|
22531
|
+
import { join as join54 } from "path";
|
|
22379
22532
|
function list4() {
|
|
22380
22533
|
const { vttDir } = getTranscriptConfig();
|
|
22381
|
-
if (!
|
|
22534
|
+
if (!existsSync46(vttDir)) return;
|
|
22382
22535
|
for (const entry of readdirSync10(vttDir)) {
|
|
22383
22536
|
if (!entry.endsWith(".vtt")) continue;
|
|
22384
|
-
if (statSync7(
|
|
22537
|
+
if (statSync7(join54(vttDir, entry)).isDirectory()) continue;
|
|
22385
22538
|
console.log(entry);
|
|
22386
22539
|
}
|
|
22387
22540
|
}
|
|
22388
22541
|
|
|
22389
22542
|
// src/commands/transcript/move.ts
|
|
22390
22543
|
import {
|
|
22391
|
-
existsSync as
|
|
22392
|
-
mkdirSync as
|
|
22393
|
-
readFileSync as
|
|
22544
|
+
existsSync as existsSync47,
|
|
22545
|
+
mkdirSync as mkdirSync19,
|
|
22546
|
+
readFileSync as readFileSync41,
|
|
22394
22547
|
renameSync as renameSync2,
|
|
22395
|
-
writeFileSync as
|
|
22548
|
+
writeFileSync as writeFileSync38
|
|
22396
22549
|
} from "fs";
|
|
22397
|
-
import { basename as basename13, join as
|
|
22550
|
+
import { basename as basename13, join as join55 } from "path";
|
|
22398
22551
|
|
|
22399
22552
|
// src/commands/transcript/cleanText.ts
|
|
22400
22553
|
function cleanText(text17) {
|
|
@@ -22602,14 +22755,14 @@ function formatChatLog(messages) {
|
|
|
22602
22755
|
// src/commands/transcript/move.ts
|
|
22603
22756
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
22604
22757
|
function convertVttToMarkdown(inputPath) {
|
|
22605
|
-
const cues = parseVtt(
|
|
22758
|
+
const cues = parseVtt(readFileSync41(inputPath, "utf8"));
|
|
22606
22759
|
const messages = cuesToChatMessages(deduplicateCues(cues));
|
|
22607
22760
|
return formatChatLog(messages);
|
|
22608
22761
|
}
|
|
22609
22762
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
22610
|
-
const processedDir =
|
|
22611
|
-
|
|
22612
|
-
renameSync2(sourcePath,
|
|
22763
|
+
const processedDir = join55(vttDir, "processed");
|
|
22764
|
+
mkdirSync19(processedDir, { recursive: true });
|
|
22765
|
+
renameSync2(sourcePath, join55(processedDir, filename));
|
|
22613
22766
|
}
|
|
22614
22767
|
function move(file, options2) {
|
|
22615
22768
|
const { date, client } = options2;
|
|
@@ -22619,19 +22772,19 @@ function move(file, options2) {
|
|
|
22619
22772
|
}
|
|
22620
22773
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
22621
22774
|
const filename = basename13(file);
|
|
22622
|
-
const sourcePath =
|
|
22623
|
-
if (!
|
|
22775
|
+
const sourcePath = join55(vttDir, filename);
|
|
22776
|
+
if (!existsSync47(sourcePath)) {
|
|
22624
22777
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
22625
22778
|
process.exit(1);
|
|
22626
22779
|
}
|
|
22627
22780
|
const base = basename13(filename, ".vtt").replace(/ Transcription$/, "");
|
|
22628
22781
|
const outputName = `${date} ${base}.md`;
|
|
22629
|
-
const formattedDir =
|
|
22630
|
-
|
|
22631
|
-
const formattedPath =
|
|
22632
|
-
|
|
22782
|
+
const formattedDir = join55(transcriptsDir, client);
|
|
22783
|
+
mkdirSync19(formattedDir, { recursive: true });
|
|
22784
|
+
const formattedPath = join55(formattedDir, outputName);
|
|
22785
|
+
writeFileSync38(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
22633
22786
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
22634
|
-
const summaryPath =
|
|
22787
|
+
const summaryPath = join55(summaryDir, client, outputName);
|
|
22635
22788
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
22636
22789
|
console.log(`Summary target: ${summaryPath}`);
|
|
22637
22790
|
}
|
|
@@ -22751,50 +22904,50 @@ function registerVerify(program2) {
|
|
|
22751
22904
|
|
|
22752
22905
|
// src/commands/voice/devices.ts
|
|
22753
22906
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
22754
|
-
import { join as
|
|
22907
|
+
import { join as join57 } from "path";
|
|
22755
22908
|
|
|
22756
22909
|
// src/commands/voice/shared.ts
|
|
22757
22910
|
import { homedir as homedir21 } from "os";
|
|
22758
|
-
import { dirname as dirname26, join as
|
|
22911
|
+
import { dirname as dirname26, join as join56 } from "path";
|
|
22759
22912
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
22760
22913
|
var __dirname5 = dirname26(fileURLToPath7(import.meta.url));
|
|
22761
|
-
var VOICE_DIR =
|
|
22914
|
+
var VOICE_DIR = join56(homedir21(), ".assist", "voice");
|
|
22762
22915
|
var voicePaths = {
|
|
22763
22916
|
dir: VOICE_DIR,
|
|
22764
|
-
pid:
|
|
22765
|
-
log:
|
|
22766
|
-
venv:
|
|
22767
|
-
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")
|
|
22768
22921
|
};
|
|
22769
22922
|
function getPythonDir() {
|
|
22770
|
-
return
|
|
22923
|
+
return join56(__dirname5, "commands", "voice", "python");
|
|
22771
22924
|
}
|
|
22772
22925
|
function getVenvPython() {
|
|
22773
|
-
return process.platform === "win32" ?
|
|
22926
|
+
return process.platform === "win32" ? join56(voicePaths.venv, "Scripts", "python.exe") : join56(voicePaths.venv, "bin", "python");
|
|
22774
22927
|
}
|
|
22775
22928
|
function getLockDir() {
|
|
22776
22929
|
const config = loadConfig();
|
|
22777
22930
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
22778
22931
|
}
|
|
22779
22932
|
function getLockFile() {
|
|
22780
|
-
return
|
|
22933
|
+
return join56(getLockDir(), "voice.lock");
|
|
22781
22934
|
}
|
|
22782
22935
|
|
|
22783
22936
|
// src/commands/voice/devices.ts
|
|
22784
22937
|
function devices() {
|
|
22785
|
-
const script =
|
|
22938
|
+
const script = join57(getPythonDir(), "list_devices.py");
|
|
22786
22939
|
spawnSync5(getVenvPython(), [script], { stdio: "inherit" });
|
|
22787
22940
|
}
|
|
22788
22941
|
|
|
22789
22942
|
// src/commands/voice/logs.ts
|
|
22790
|
-
import { existsSync as
|
|
22943
|
+
import { existsSync as existsSync48, readFileSync as readFileSync42 } from "fs";
|
|
22791
22944
|
function logs(options2) {
|
|
22792
|
-
if (!
|
|
22945
|
+
if (!existsSync48(voicePaths.log)) {
|
|
22793
22946
|
console.log("No voice log file found");
|
|
22794
22947
|
return;
|
|
22795
22948
|
}
|
|
22796
22949
|
const count7 = Number.parseInt(options2.lines ?? "150", 10);
|
|
22797
|
-
const content =
|
|
22950
|
+
const content = readFileSync42(voicePaths.log, "utf8").trim();
|
|
22798
22951
|
if (!content) {
|
|
22799
22952
|
console.log("Voice log is empty");
|
|
22800
22953
|
return;
|
|
@@ -22816,13 +22969,13 @@ function logs(options2) {
|
|
|
22816
22969
|
|
|
22817
22970
|
// src/commands/voice/setup.ts
|
|
22818
22971
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
22819
|
-
import { mkdirSync as
|
|
22820
|
-
import { join as
|
|
22972
|
+
import { mkdirSync as mkdirSync21 } from "fs";
|
|
22973
|
+
import { join as join59 } from "path";
|
|
22821
22974
|
|
|
22822
22975
|
// src/commands/voice/checkLockFile.ts
|
|
22823
22976
|
import { execSync as execSync55 } from "child_process";
|
|
22824
|
-
import { existsSync as
|
|
22825
|
-
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";
|
|
22826
22979
|
function isProcessAlive2(pid) {
|
|
22827
22980
|
try {
|
|
22828
22981
|
process.kill(pid, 0);
|
|
@@ -22833,9 +22986,9 @@ function isProcessAlive2(pid) {
|
|
|
22833
22986
|
}
|
|
22834
22987
|
function checkLockFile() {
|
|
22835
22988
|
const lockFile = getLockFile();
|
|
22836
|
-
if (!
|
|
22989
|
+
if (!existsSync49(lockFile)) return;
|
|
22837
22990
|
try {
|
|
22838
|
-
const lock2 = JSON.parse(
|
|
22991
|
+
const lock2 = JSON.parse(readFileSync43(lockFile, "utf8"));
|
|
22839
22992
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
22840
22993
|
console.error(
|
|
22841
22994
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -22846,7 +22999,7 @@ function checkLockFile() {
|
|
|
22846
22999
|
}
|
|
22847
23000
|
}
|
|
22848
23001
|
function bootstrapVenv() {
|
|
22849
|
-
if (
|
|
23002
|
+
if (existsSync49(getVenvPython())) return;
|
|
22850
23003
|
console.log("Setting up Python environment...");
|
|
22851
23004
|
const pythonDir = getPythonDir();
|
|
22852
23005
|
execSync55(
|
|
@@ -22859,8 +23012,8 @@ function bootstrapVenv() {
|
|
|
22859
23012
|
}
|
|
22860
23013
|
function writeLockFile(pid) {
|
|
22861
23014
|
const lockFile = getLockFile();
|
|
22862
|
-
|
|
22863
|
-
|
|
23015
|
+
mkdirSync20(join58(lockFile, ".."), { recursive: true });
|
|
23016
|
+
writeFileSync39(
|
|
22864
23017
|
lockFile,
|
|
22865
23018
|
JSON.stringify({
|
|
22866
23019
|
pid,
|
|
@@ -22872,10 +23025,10 @@ function writeLockFile(pid) {
|
|
|
22872
23025
|
|
|
22873
23026
|
// src/commands/voice/setup.ts
|
|
22874
23027
|
function setup() {
|
|
22875
|
-
|
|
23028
|
+
mkdirSync21(voicePaths.dir, { recursive: true });
|
|
22876
23029
|
bootstrapVenv();
|
|
22877
23030
|
console.log("\nDownloading models...\n");
|
|
22878
|
-
const script =
|
|
23031
|
+
const script = join59(getPythonDir(), "setup_models.py");
|
|
22879
23032
|
const result = spawnSync6(getVenvPython(), [script], {
|
|
22880
23033
|
stdio: "inherit",
|
|
22881
23034
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -22888,8 +23041,8 @@ function setup() {
|
|
|
22888
23041
|
|
|
22889
23042
|
// src/commands/voice/start.ts
|
|
22890
23043
|
import { spawn as spawn7 } from "child_process";
|
|
22891
|
-
import { mkdirSync as
|
|
22892
|
-
import { join as
|
|
23044
|
+
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync40 } from "fs";
|
|
23045
|
+
import { join as join60 } from "path";
|
|
22893
23046
|
|
|
22894
23047
|
// src/commands/voice/buildDaemonEnv.ts
|
|
22895
23048
|
function buildDaemonEnv(options2) {
|
|
@@ -22917,17 +23070,17 @@ function spawnBackground(python, script, env) {
|
|
|
22917
23070
|
console.error("Failed to start voice daemon");
|
|
22918
23071
|
process.exit(1);
|
|
22919
23072
|
}
|
|
22920
|
-
|
|
23073
|
+
writeFileSync40(voicePaths.pid, String(pid));
|
|
22921
23074
|
writeLockFile(pid);
|
|
22922
23075
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
22923
23076
|
}
|
|
22924
23077
|
function start2(options2) {
|
|
22925
|
-
|
|
23078
|
+
mkdirSync22(voicePaths.dir, { recursive: true });
|
|
22926
23079
|
checkLockFile();
|
|
22927
23080
|
bootstrapVenv();
|
|
22928
23081
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
22929
23082
|
const env = buildDaemonEnv({ debug });
|
|
22930
|
-
const script =
|
|
23083
|
+
const script = join60(getPythonDir(), "voice_daemon.py");
|
|
22931
23084
|
const python = getVenvPython();
|
|
22932
23085
|
if (options2.foreground) {
|
|
22933
23086
|
spawnForeground(python, script, env);
|
|
@@ -22937,7 +23090,7 @@ function start2(options2) {
|
|
|
22937
23090
|
}
|
|
22938
23091
|
|
|
22939
23092
|
// src/commands/voice/status.ts
|
|
22940
|
-
import { existsSync as
|
|
23093
|
+
import { existsSync as existsSync50, readFileSync as readFileSync44 } from "fs";
|
|
22941
23094
|
function isProcessAlive3(pid) {
|
|
22942
23095
|
try {
|
|
22943
23096
|
process.kill(pid, 0);
|
|
@@ -22947,16 +23100,16 @@ function isProcessAlive3(pid) {
|
|
|
22947
23100
|
}
|
|
22948
23101
|
}
|
|
22949
23102
|
function readRecentLogs(count7) {
|
|
22950
|
-
if (!
|
|
22951
|
-
const lines =
|
|
23103
|
+
if (!existsSync50(voicePaths.log)) return [];
|
|
23104
|
+
const lines = readFileSync44(voicePaths.log, "utf8").trim().split("\n");
|
|
22952
23105
|
return lines.slice(-count7);
|
|
22953
23106
|
}
|
|
22954
23107
|
function status2() {
|
|
22955
|
-
if (!
|
|
23108
|
+
if (!existsSync50(voicePaths.pid)) {
|
|
22956
23109
|
console.log("Voice daemon: not running (no PID file)");
|
|
22957
23110
|
return;
|
|
22958
23111
|
}
|
|
22959
|
-
const pid = Number.parseInt(
|
|
23112
|
+
const pid = Number.parseInt(readFileSync44(voicePaths.pid, "utf8").trim(), 10);
|
|
22960
23113
|
const alive = isProcessAlive3(pid);
|
|
22961
23114
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
22962
23115
|
const recent = readRecentLogs(5);
|
|
@@ -22975,13 +23128,13 @@ function status2() {
|
|
|
22975
23128
|
}
|
|
22976
23129
|
|
|
22977
23130
|
// src/commands/voice/stop.ts
|
|
22978
|
-
import { existsSync as
|
|
23131
|
+
import { existsSync as existsSync51, readFileSync as readFileSync45, unlinkSync as unlinkSync19 } from "fs";
|
|
22979
23132
|
function stop2() {
|
|
22980
|
-
if (!
|
|
23133
|
+
if (!existsSync51(voicePaths.pid)) {
|
|
22981
23134
|
console.log("Voice daemon is not running (no PID file)");
|
|
22982
23135
|
return;
|
|
22983
23136
|
}
|
|
22984
|
-
const pid = Number.parseInt(
|
|
23137
|
+
const pid = Number.parseInt(readFileSync45(voicePaths.pid, "utf8").trim(), 10);
|
|
22985
23138
|
try {
|
|
22986
23139
|
process.kill(pid, "SIGTERM");
|
|
22987
23140
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -22989,12 +23142,12 @@ function stop2() {
|
|
|
22989
23142
|
console.log(`Voice daemon (PID ${pid}) is not running`);
|
|
22990
23143
|
}
|
|
22991
23144
|
try {
|
|
22992
|
-
|
|
23145
|
+
unlinkSync19(voicePaths.pid);
|
|
22993
23146
|
} catch {
|
|
22994
23147
|
}
|
|
22995
23148
|
try {
|
|
22996
23149
|
const lockFile = getLockFile();
|
|
22997
|
-
if (
|
|
23150
|
+
if (existsSync51(lockFile)) unlinkSync19(lockFile);
|
|
22998
23151
|
} catch {
|
|
22999
23152
|
}
|
|
23000
23153
|
console.log("Voice daemon stopped");
|
|
@@ -23058,7 +23211,7 @@ function registerVoice(program2) {
|
|
|
23058
23211
|
|
|
23059
23212
|
// src/commands/roam/auth.ts
|
|
23060
23213
|
import { randomBytes } from "crypto";
|
|
23061
|
-
import
|
|
23214
|
+
import chalk197 from "chalk";
|
|
23062
23215
|
|
|
23063
23216
|
// src/commands/roam/waitForCallback.ts
|
|
23064
23217
|
import { createServer as createServer3 } from "http";
|
|
@@ -23189,13 +23342,13 @@ async function auth() {
|
|
|
23189
23342
|
saveGlobalConfig(config);
|
|
23190
23343
|
const state = randomBytes(16).toString("hex");
|
|
23191
23344
|
console.log(
|
|
23192
|
-
|
|
23345
|
+
chalk197.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
23193
23346
|
);
|
|
23194
|
-
console.log(
|
|
23195
|
-
console.log(
|
|
23196
|
-
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..."));
|
|
23197
23350
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
23198
|
-
console.log(
|
|
23351
|
+
console.log(chalk197.dim("Exchanging code for tokens..."));
|
|
23199
23352
|
const tokens = await exchangeToken({
|
|
23200
23353
|
code,
|
|
23201
23354
|
clientId,
|
|
@@ -23211,14 +23364,14 @@ async function auth() {
|
|
|
23211
23364
|
};
|
|
23212
23365
|
saveGlobalConfig(config);
|
|
23213
23366
|
console.log(
|
|
23214
|
-
|
|
23367
|
+
chalk197.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
23215
23368
|
);
|
|
23216
23369
|
}
|
|
23217
23370
|
|
|
23218
23371
|
// src/commands/roam/postRoamActivity.ts
|
|
23219
23372
|
import { execFileSync as execFileSync9 } from "child_process";
|
|
23220
|
-
import { readdirSync as readdirSync11, readFileSync as
|
|
23221
|
-
import { join as
|
|
23373
|
+
import { readdirSync as readdirSync11, readFileSync as readFileSync46, statSync as statSync8 } from "fs";
|
|
23374
|
+
import { join as join61 } from "path";
|
|
23222
23375
|
function findPortFile(roamDir) {
|
|
23223
23376
|
let entries;
|
|
23224
23377
|
try {
|
|
@@ -23227,7 +23380,7 @@ function findPortFile(roamDir) {
|
|
|
23227
23380
|
return void 0;
|
|
23228
23381
|
}
|
|
23229
23382
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
23230
|
-
const path67 =
|
|
23383
|
+
const path67 = join61(roamDir, name);
|
|
23231
23384
|
try {
|
|
23232
23385
|
return { path: path67, mtimeMs: statSync8(path67).mtimeMs };
|
|
23233
23386
|
} catch {
|
|
@@ -23239,11 +23392,11 @@ function findPortFile(roamDir) {
|
|
|
23239
23392
|
function postRoamActivity(app, event) {
|
|
23240
23393
|
const appData = process.env.APPDATA;
|
|
23241
23394
|
if (!appData) return;
|
|
23242
|
-
const portFile = findPortFile(
|
|
23395
|
+
const portFile = findPortFile(join61(appData, "Roam"));
|
|
23243
23396
|
if (!portFile) return;
|
|
23244
23397
|
let port;
|
|
23245
23398
|
try {
|
|
23246
|
-
port =
|
|
23399
|
+
port = readFileSync46(portFile, "utf8").trim();
|
|
23247
23400
|
} catch {
|
|
23248
23401
|
return;
|
|
23249
23402
|
}
|
|
@@ -23459,15 +23612,15 @@ function runPreCommands(pre, cwd) {
|
|
|
23459
23612
|
|
|
23460
23613
|
// src/commands/run/spawnRunCommand.ts
|
|
23461
23614
|
import { execFileSync as execFileSync10, spawn as spawn8 } from "child_process";
|
|
23462
|
-
import { existsSync as
|
|
23463
|
-
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";
|
|
23464
23617
|
function resolveCommand2(command) {
|
|
23465
23618
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
23466
23619
|
try {
|
|
23467
23620
|
const gitPath = execFileSync10("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
23468
23621
|
const gitRoot = resolve13(dirname27(gitPath), "..");
|
|
23469
|
-
const gitBash =
|
|
23470
|
-
if (
|
|
23622
|
+
const gitBash = join62(gitRoot, "bin", "bash.exe");
|
|
23623
|
+
if (existsSync52(gitBash)) return gitBash;
|
|
23471
23624
|
} catch {
|
|
23472
23625
|
}
|
|
23473
23626
|
return command;
|
|
@@ -23554,8 +23707,8 @@ async function run3(name, args) {
|
|
|
23554
23707
|
}
|
|
23555
23708
|
|
|
23556
23709
|
// src/commands/run/add.ts
|
|
23557
|
-
import { mkdirSync as
|
|
23558
|
-
import { join as
|
|
23710
|
+
import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync41 } from "fs";
|
|
23711
|
+
import { join as join63 } from "path";
|
|
23559
23712
|
|
|
23560
23713
|
// src/commands/run/extractOption.ts
|
|
23561
23714
|
function extractOption(args, flag) {
|
|
@@ -23616,16 +23769,16 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
23616
23769
|
saveConfig(config);
|
|
23617
23770
|
}
|
|
23618
23771
|
function createCommandFile(name) {
|
|
23619
|
-
const dir =
|
|
23620
|
-
|
|
23772
|
+
const dir = join63(".claude", "commands");
|
|
23773
|
+
mkdirSync23(dir, { recursive: true });
|
|
23621
23774
|
const content = `---
|
|
23622
23775
|
description: Run ${name}
|
|
23623
23776
|
---
|
|
23624
23777
|
|
|
23625
23778
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
23626
23779
|
`;
|
|
23627
|
-
const filePath =
|
|
23628
|
-
|
|
23780
|
+
const filePath = join63(dir, `${name}.md`);
|
|
23781
|
+
writeFileSync41(filePath, content);
|
|
23629
23782
|
console.log(`Created command file: ${filePath}`);
|
|
23630
23783
|
}
|
|
23631
23784
|
function add3() {
|
|
@@ -23680,8 +23833,8 @@ function link2() {
|
|
|
23680
23833
|
}
|
|
23681
23834
|
|
|
23682
23835
|
// src/commands/run/remove.ts
|
|
23683
|
-
import { existsSync as
|
|
23684
|
-
import { join as
|
|
23836
|
+
import { existsSync as existsSync53, unlinkSync as unlinkSync20 } from "fs";
|
|
23837
|
+
import { join as join64 } from "path";
|
|
23685
23838
|
function findRemoveIndex() {
|
|
23686
23839
|
const idx = process.argv.indexOf("remove");
|
|
23687
23840
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -23696,9 +23849,9 @@ function parseRemoveName() {
|
|
|
23696
23849
|
return process.argv[idx + 1];
|
|
23697
23850
|
}
|
|
23698
23851
|
function deleteCommandFile(name) {
|
|
23699
|
-
const filePath =
|
|
23700
|
-
if (
|
|
23701
|
-
|
|
23852
|
+
const filePath = join64(".claude", "commands", `${name}.md`);
|
|
23853
|
+
if (existsSync53(filePath)) {
|
|
23854
|
+
unlinkSync20(filePath);
|
|
23702
23855
|
console.log(`Deleted command file: ${filePath}`);
|
|
23703
23856
|
}
|
|
23704
23857
|
}
|
|
@@ -23751,10 +23904,10 @@ function registerRun(program2) {
|
|
|
23751
23904
|
|
|
23752
23905
|
// src/commands/screenshot/index.ts
|
|
23753
23906
|
import { execSync as execSync57 } from "child_process";
|
|
23754
|
-
import { existsSync as
|
|
23907
|
+
import { existsSync as existsSync54, mkdirSync as mkdirSync24, unlinkSync as unlinkSync21, writeFileSync as writeFileSync42 } from "fs";
|
|
23755
23908
|
import { tmpdir as tmpdir7 } from "os";
|
|
23756
|
-
import { join as
|
|
23757
|
-
import
|
|
23909
|
+
import { join as join65, resolve as resolve15 } from "path";
|
|
23910
|
+
import chalk198 from "chalk";
|
|
23758
23911
|
|
|
23759
23912
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
23760
23913
|
var captureWindowPs1 = `
|
|
@@ -23883,35 +24036,35 @@ Write-Output $OutputPath
|
|
|
23883
24036
|
|
|
23884
24037
|
// src/commands/screenshot/index.ts
|
|
23885
24038
|
function buildOutputPath(outputDir, processName) {
|
|
23886
|
-
if (!
|
|
23887
|
-
|
|
24039
|
+
if (!existsSync54(outputDir)) {
|
|
24040
|
+
mkdirSync24(outputDir, { recursive: true });
|
|
23888
24041
|
}
|
|
23889
24042
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
23890
24043
|
return resolve15(outputDir, `${processName}-${timestamp6}.png`);
|
|
23891
24044
|
}
|
|
23892
24045
|
function runPowerShellScript(processName, outputPath) {
|
|
23893
|
-
const scriptPath =
|
|
23894
|
-
|
|
24046
|
+
const scriptPath = join65(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
24047
|
+
writeFileSync42(scriptPath, captureWindowPs1, "utf8");
|
|
23895
24048
|
try {
|
|
23896
24049
|
execSync57(
|
|
23897
24050
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
23898
24051
|
{ stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" }
|
|
23899
24052
|
);
|
|
23900
24053
|
} finally {
|
|
23901
|
-
|
|
24054
|
+
unlinkSync21(scriptPath);
|
|
23902
24055
|
}
|
|
23903
24056
|
}
|
|
23904
24057
|
function screenshot(processName) {
|
|
23905
24058
|
const config = loadConfig();
|
|
23906
24059
|
const outputDir = resolve15(config.screenshot.outputDir);
|
|
23907
24060
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
23908
|
-
console.log(
|
|
24061
|
+
console.log(chalk198.gray(`Capturing window for process "${processName}" ...`));
|
|
23909
24062
|
try {
|
|
23910
24063
|
runPowerShellScript(processName, outputPath);
|
|
23911
|
-
console.log(
|
|
24064
|
+
console.log(chalk198.green(`Screenshot saved: ${outputPath}`));
|
|
23912
24065
|
} catch (error) {
|
|
23913
24066
|
const msg = error instanceof Error ? error.message : String(error);
|
|
23914
|
-
console.error(
|
|
24067
|
+
console.error(chalk198.red(`Failed to capture screenshot: ${msg}`));
|
|
23915
24068
|
process.exit(1);
|
|
23916
24069
|
}
|
|
23917
24070
|
}
|
|
@@ -23967,7 +24120,7 @@ function applyLine(result, pending, line) {
|
|
|
23967
24120
|
}
|
|
23968
24121
|
|
|
23969
24122
|
// src/commands/sessions/daemon/reportStolenSocket.ts
|
|
23970
|
-
import { readFileSync as
|
|
24123
|
+
import { readFileSync as readFileSync47 } from "fs";
|
|
23971
24124
|
function reportStolenSocket(socketPid) {
|
|
23972
24125
|
if (!socketPid) return;
|
|
23973
24126
|
const filePid = readPidFile();
|
|
@@ -23979,7 +24132,7 @@ function reportStolenSocket(socketPid) {
|
|
|
23979
24132
|
function readPidFile() {
|
|
23980
24133
|
try {
|
|
23981
24134
|
const pid = Number.parseInt(
|
|
23982
|
-
|
|
24135
|
+
readFileSync47(daemonPaths.pid, "utf8").trim(),
|
|
23983
24136
|
10
|
|
23984
24137
|
);
|
|
23985
24138
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -24158,7 +24311,7 @@ function requestDrain(socket) {
|
|
|
24158
24311
|
}
|
|
24159
24312
|
|
|
24160
24313
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
24161
|
-
import { mkdirSync as
|
|
24314
|
+
import { mkdirSync as mkdirSync26 } from "fs";
|
|
24162
24315
|
|
|
24163
24316
|
// src/commands/sessions/daemon/createAutoExit.ts
|
|
24164
24317
|
var DEFAULT_GRACE_MS = 6e4;
|
|
@@ -24366,7 +24519,7 @@ var ClientHub = class extends Set {
|
|
|
24366
24519
|
import * as pty from "node-pty";
|
|
24367
24520
|
|
|
24368
24521
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
24369
|
-
import { chmodSync, existsSync as
|
|
24522
|
+
import { chmodSync, existsSync as existsSync55, statSync as statSync9 } from "fs";
|
|
24370
24523
|
import { createRequire as createRequire3 } from "module";
|
|
24371
24524
|
import path55 from "path";
|
|
24372
24525
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -24381,7 +24534,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
24381
24534
|
`${process.platform}-${process.arch}`,
|
|
24382
24535
|
"spawn-helper"
|
|
24383
24536
|
);
|
|
24384
|
-
if (!
|
|
24537
|
+
if (!existsSync55(helper)) return;
|
|
24385
24538
|
const mode = statSync9(helper).mode;
|
|
24386
24539
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
24387
24540
|
}
|
|
@@ -24925,7 +25078,7 @@ function errorTail(scrollback) {
|
|
|
24925
25078
|
}
|
|
24926
25079
|
|
|
24927
25080
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
24928
|
-
import { existsSync as
|
|
25081
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync25, watch } from "fs";
|
|
24929
25082
|
import { dirname as dirname29 } from "path";
|
|
24930
25083
|
|
|
24931
25084
|
// src/commands/sessions/daemon/applyReviewPause.ts
|
|
@@ -24982,7 +25135,7 @@ function watchActivity(session, notify2) {
|
|
|
24982
25135
|
const path67 = activityPath(session.id);
|
|
24983
25136
|
const dir = dirname29(path67);
|
|
24984
25137
|
try {
|
|
24985
|
-
|
|
25138
|
+
mkdirSync25(dir, { recursive: true });
|
|
24986
25139
|
} catch {
|
|
24987
25140
|
return;
|
|
24988
25141
|
}
|
|
@@ -25004,7 +25157,7 @@ function watchActivity(session, notify2) {
|
|
|
25004
25157
|
if (timer) clearTimeout(timer);
|
|
25005
25158
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
25006
25159
|
});
|
|
25007
|
-
if (
|
|
25160
|
+
if (existsSync56(path67)) read();
|
|
25008
25161
|
}
|
|
25009
25162
|
function refreshActivity(session) {
|
|
25010
25163
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -25583,14 +25736,14 @@ async function defaultConnect() {
|
|
|
25583
25736
|
}
|
|
25584
25737
|
|
|
25585
25738
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
25586
|
-
import { existsSync as
|
|
25739
|
+
import { existsSync as existsSync57, readFileSync as readFileSync49 } from "fs";
|
|
25587
25740
|
import { posix } from "path";
|
|
25588
25741
|
function hasPersistedWindowsSessions() {
|
|
25589
25742
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
25590
25743
|
if (!sessionsFile) return false;
|
|
25591
25744
|
try {
|
|
25592
|
-
if (!
|
|
25593
|
-
const data = JSON.parse(
|
|
25745
|
+
if (!existsSync57(sessionsFile)) return false;
|
|
25746
|
+
const data = JSON.parse(readFileSync49(sessionsFile, "utf8"));
|
|
25594
25747
|
return Array.isArray(data) && data.length > 0;
|
|
25595
25748
|
} catch (error) {
|
|
25596
25749
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -26328,7 +26481,7 @@ var SessionManager = class {
|
|
|
26328
26481
|
};
|
|
26329
26482
|
|
|
26330
26483
|
// src/commands/sessions/daemon/startDaemonServer.ts
|
|
26331
|
-
import { unlinkSync as
|
|
26484
|
+
import { unlinkSync as unlinkSync23 } from "fs";
|
|
26332
26485
|
import * as net3 from "net";
|
|
26333
26486
|
|
|
26334
26487
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
@@ -26573,10 +26726,10 @@ function handleConnection(socket, manager) {
|
|
|
26573
26726
|
}
|
|
26574
26727
|
|
|
26575
26728
|
// src/commands/sessions/daemon/onListening.ts
|
|
26576
|
-
import { unlinkSync as
|
|
26729
|
+
import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync43 } from "fs";
|
|
26577
26730
|
|
|
26578
26731
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
26579
|
-
import { readFileSync as
|
|
26732
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
26580
26733
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
26581
26734
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
26582
26735
|
const timer = setInterval(() => {
|
|
@@ -26587,7 +26740,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
26587
26740
|
}
|
|
26588
26741
|
function ownsPidFile() {
|
|
26589
26742
|
try {
|
|
26590
|
-
return
|
|
26743
|
+
return readFileSync50(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
26591
26744
|
} catch {
|
|
26592
26745
|
return false;
|
|
26593
26746
|
}
|
|
@@ -26595,7 +26748,7 @@ function ownsPidFile() {
|
|
|
26595
26748
|
|
|
26596
26749
|
// src/commands/sessions/daemon/onListening.ts
|
|
26597
26750
|
function onListening(manager, checkAutoExit) {
|
|
26598
|
-
|
|
26751
|
+
writeFileSync43(daemonPaths.pid, String(process.pid));
|
|
26599
26752
|
startPidFileWatchdog(() => {
|
|
26600
26753
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
26601
26754
|
void manager.flushActiveMs().finally(() => {
|
|
@@ -26616,12 +26769,12 @@ function onListening(manager, checkAutoExit) {
|
|
|
26616
26769
|
function cleanupOwnedFiles() {
|
|
26617
26770
|
if (!ownsPidFile()) return;
|
|
26618
26771
|
try {
|
|
26619
|
-
|
|
26772
|
+
unlinkSync22(daemonPaths.pid);
|
|
26620
26773
|
} catch {
|
|
26621
26774
|
}
|
|
26622
26775
|
if (process.platform !== "win32") {
|
|
26623
26776
|
try {
|
|
26624
|
-
|
|
26777
|
+
unlinkSync22(daemonPaths.socket);
|
|
26625
26778
|
} catch {
|
|
26626
26779
|
}
|
|
26627
26780
|
}
|
|
@@ -26668,7 +26821,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
26668
26821
|
daemonLog("removing stale socket left by a crashed daemon");
|
|
26669
26822
|
if (process.platform !== "win32") {
|
|
26670
26823
|
try {
|
|
26671
|
-
|
|
26824
|
+
unlinkSync23(daemonPaths.socket);
|
|
26672
26825
|
} catch {
|
|
26673
26826
|
}
|
|
26674
26827
|
}
|
|
@@ -26677,7 +26830,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
26677
26830
|
|
|
26678
26831
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
26679
26832
|
async function runDaemon() {
|
|
26680
|
-
|
|
26833
|
+
mkdirSync26(daemonPaths.dir, { recursive: true });
|
|
26681
26834
|
daemonLog(
|
|
26682
26835
|
`starting (reason: ${process.env.ASSIST_DAEMON_SPAWN_REASON ?? "manual"})`
|
|
26683
26836
|
);
|
|
@@ -26717,7 +26870,7 @@ function registerDaemon(program2) {
|
|
|
26717
26870
|
|
|
26718
26871
|
// src/commands/sessions/summarise/index.ts
|
|
26719
26872
|
import * as fs38 from "fs";
|
|
26720
|
-
import
|
|
26873
|
+
import chalk199 from "chalk";
|
|
26721
26874
|
|
|
26722
26875
|
// src/commands/sessions/summarise/shared.ts
|
|
26723
26876
|
import * as fs37 from "fs";
|
|
@@ -26791,22 +26944,22 @@ ${firstMessage}`);
|
|
|
26791
26944
|
async function summarise2(options2) {
|
|
26792
26945
|
const files = await discoverSessionFiles();
|
|
26793
26946
|
if (files.length === 0) {
|
|
26794
|
-
console.log(
|
|
26947
|
+
console.log(chalk199.yellow("No sessions found."));
|
|
26795
26948
|
return;
|
|
26796
26949
|
}
|
|
26797
26950
|
const toProcess = selectCandidates(files, options2);
|
|
26798
26951
|
if (toProcess.length === 0) {
|
|
26799
|
-
console.log(
|
|
26952
|
+
console.log(chalk199.green("All sessions already summarised."));
|
|
26800
26953
|
return;
|
|
26801
26954
|
}
|
|
26802
26955
|
console.log(
|
|
26803
|
-
|
|
26956
|
+
chalk199.cyan(
|
|
26804
26957
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
26805
26958
|
)
|
|
26806
26959
|
);
|
|
26807
26960
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
26808
26961
|
console.log(
|
|
26809
|
-
|
|
26962
|
+
chalk199.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk199.yellow(`, ${failed2} skipped`) : "")
|
|
26810
26963
|
);
|
|
26811
26964
|
}
|
|
26812
26965
|
function selectCandidates(files, options2) {
|
|
@@ -26826,16 +26979,16 @@ function processSessions(files) {
|
|
|
26826
26979
|
let failed2 = 0;
|
|
26827
26980
|
for (let i = 0; i < files.length; i++) {
|
|
26828
26981
|
const file = files[i];
|
|
26829
|
-
process.stdout.write(
|
|
26982
|
+
process.stdout.write(chalk199.dim(` [${i + 1}/${files.length}] `));
|
|
26830
26983
|
const summary = summariseSession(file);
|
|
26831
26984
|
if (summary) {
|
|
26832
26985
|
writeSummary(file, summary);
|
|
26833
26986
|
succeeded++;
|
|
26834
|
-
process.stdout.write(`${
|
|
26987
|
+
process.stdout.write(`${chalk199.green("\u2713")} ${summary}
|
|
26835
26988
|
`);
|
|
26836
26989
|
} else {
|
|
26837
26990
|
failed2++;
|
|
26838
|
-
process.stdout.write(` ${
|
|
26991
|
+
process.stdout.write(` ${chalk199.yellow("skip")}
|
|
26839
26992
|
`);
|
|
26840
26993
|
}
|
|
26841
26994
|
}
|
|
@@ -26879,7 +27032,7 @@ function registerSessions(program2) {
|
|
|
26879
27032
|
}
|
|
26880
27033
|
|
|
26881
27034
|
// src/commands/statusLine.ts
|
|
26882
|
-
import
|
|
27035
|
+
import chalk201 from "chalk";
|
|
26883
27036
|
|
|
26884
27037
|
// src/shared/contextLevel.ts
|
|
26885
27038
|
function contextLevel(pct) {
|
|
@@ -26889,7 +27042,7 @@ function contextLevel(pct) {
|
|
|
26889
27042
|
}
|
|
26890
27043
|
|
|
26891
27044
|
// src/commands/buildLimitsSegment.ts
|
|
26892
|
-
import
|
|
27045
|
+
import chalk200 from "chalk";
|
|
26893
27046
|
|
|
26894
27047
|
// src/shared/rateLimitLevel.ts
|
|
26895
27048
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -26920,9 +27073,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
26920
27073
|
|
|
26921
27074
|
// src/commands/buildLimitsSegment.ts
|
|
26922
27075
|
var LEVEL_COLOR = {
|
|
26923
|
-
ok:
|
|
26924
|
-
warn:
|
|
26925
|
-
over:
|
|
27076
|
+
ok: chalk200.green,
|
|
27077
|
+
warn: chalk200.yellow,
|
|
27078
|
+
over: chalk200.red
|
|
26926
27079
|
};
|
|
26927
27080
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
26928
27081
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -26953,10 +27106,10 @@ function buildLimitsSegment(rateLimits) {
|
|
|
26953
27106
|
}
|
|
26954
27107
|
|
|
26955
27108
|
// src/commands/readGitBranch.ts
|
|
26956
|
-
import { readFileSync as
|
|
26957
|
-
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";
|
|
26958
27111
|
function resolveGitDir(cwd) {
|
|
26959
|
-
const dotGit =
|
|
27112
|
+
const dotGit = join67(cwd, ".git");
|
|
26960
27113
|
let stat2;
|
|
26961
27114
|
try {
|
|
26962
27115
|
stat2 = statSync11(dotGit);
|
|
@@ -26968,7 +27121,7 @@ function resolveGitDir(cwd) {
|
|
|
26968
27121
|
}
|
|
26969
27122
|
let contents;
|
|
26970
27123
|
try {
|
|
26971
|
-
contents =
|
|
27124
|
+
contents = readFileSync52(dotGit, "utf8");
|
|
26972
27125
|
} catch {
|
|
26973
27126
|
return null;
|
|
26974
27127
|
}
|
|
@@ -26986,7 +27139,7 @@ function readGitBranch(cwd) {
|
|
|
26986
27139
|
}
|
|
26987
27140
|
let head;
|
|
26988
27141
|
try {
|
|
26989
|
-
head =
|
|
27142
|
+
head = readFileSync52(join67(gitDir, "HEAD"), "utf8");
|
|
26990
27143
|
} catch {
|
|
26991
27144
|
return null;
|
|
26992
27145
|
}
|
|
@@ -27018,7 +27171,7 @@ async function relayUsage(claudeSessionId, transcriptPath, usedPct) {
|
|
|
27018
27171
|
}
|
|
27019
27172
|
|
|
27020
27173
|
// src/commands/statusLine.ts
|
|
27021
|
-
|
|
27174
|
+
chalk201.level = 3;
|
|
27022
27175
|
function formatNumber(num) {
|
|
27023
27176
|
return num.toLocaleString("en-US");
|
|
27024
27177
|
}
|
|
@@ -27026,9 +27179,9 @@ function colorizePercent(pct) {
|
|
|
27026
27179
|
const label2 = `${Math.round(pct)}%`;
|
|
27027
27180
|
switch (contextLevel(pct)) {
|
|
27028
27181
|
case "red":
|
|
27029
|
-
return
|
|
27182
|
+
return chalk201.red(label2);
|
|
27030
27183
|
case "yellow":
|
|
27031
|
-
return
|
|
27184
|
+
return chalk201.yellow(label2);
|
|
27032
27185
|
default:
|
|
27033
27186
|
return label2;
|
|
27034
27187
|
}
|
|
@@ -27041,7 +27194,7 @@ async function statusLine() {
|
|
|
27041
27194
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
27042
27195
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
27043
27196
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
27044
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
27197
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk201.cyan(branch2)} | ` : "";
|
|
27045
27198
|
console.log(
|
|
27046
27199
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
27047
27200
|
);
|
|
@@ -27062,7 +27215,7 @@ import { fileURLToPath as fileURLToPath9 } from "url";
|
|
|
27062
27215
|
// src/commands/sync/syncClaudeMd.ts
|
|
27063
27216
|
import * as fs39 from "fs";
|
|
27064
27217
|
import * as path57 from "path";
|
|
27065
|
-
import
|
|
27218
|
+
import chalk202 from "chalk";
|
|
27066
27219
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
27067
27220
|
const source = path57.join(claudeDir, "CLAUDE.md");
|
|
27068
27221
|
const target = path57.join(targetBase, "CLAUDE.md");
|
|
@@ -27071,12 +27224,12 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
27071
27224
|
const targetContent = fs39.readFileSync(target, "utf8");
|
|
27072
27225
|
if (sourceContent !== targetContent) {
|
|
27073
27226
|
console.log(
|
|
27074
|
-
|
|
27227
|
+
chalk202.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
27075
27228
|
);
|
|
27076
27229
|
console.log();
|
|
27077
27230
|
printDiff(targetContent, sourceContent);
|
|
27078
27231
|
const confirm = options2?.yes || await promptConfirm(
|
|
27079
|
-
|
|
27232
|
+
chalk202.red("Overwrite existing CLAUDE.md?"),
|
|
27080
27233
|
false
|
|
27081
27234
|
);
|
|
27082
27235
|
if (!confirm) {
|
|
@@ -27270,7 +27423,7 @@ function syncPi(claudeDir) {
|
|
|
27270
27423
|
// src/commands/sync/syncSettings.ts
|
|
27271
27424
|
import * as fs44 from "fs";
|
|
27272
27425
|
import * as path64 from "path";
|
|
27273
|
-
import
|
|
27426
|
+
import chalk203 from "chalk";
|
|
27274
27427
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
27275
27428
|
const source = path64.join(claudeDir, "settings.json");
|
|
27276
27429
|
const target = path64.join(targetBase, "settings.json");
|
|
@@ -27289,14 +27442,14 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
27289
27442
|
if (mergedContent !== normalizedTarget) {
|
|
27290
27443
|
if (!options2?.yes) {
|
|
27291
27444
|
console.log(
|
|
27292
|
-
|
|
27445
|
+
chalk203.yellow(
|
|
27293
27446
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
27294
27447
|
)
|
|
27295
27448
|
);
|
|
27296
27449
|
console.log();
|
|
27297
27450
|
printDiff(targetContent, mergedContent);
|
|
27298
27451
|
const confirm = await promptConfirm(
|
|
27299
|
-
|
|
27452
|
+
chalk203.red("Overwrite existing settings.json?"),
|
|
27300
27453
|
false
|
|
27301
27454
|
);
|
|
27302
27455
|
if (!confirm) {
|
|
@@ -27395,10 +27548,10 @@ async function update2() {
|
|
|
27395
27548
|
}
|
|
27396
27549
|
|
|
27397
27550
|
// src/reportCliError.ts
|
|
27398
|
-
import
|
|
27551
|
+
import chalk204 from "chalk";
|
|
27399
27552
|
function reportCliError(error) {
|
|
27400
27553
|
if (error instanceof InvalidItemIdError) {
|
|
27401
|
-
console.error(
|
|
27554
|
+
console.error(chalk204.red(error.message));
|
|
27402
27555
|
} else {
|
|
27403
27556
|
console.error(error);
|
|
27404
27557
|
}
|
|
@@ -27434,6 +27587,7 @@ configHelp(screenshotCommand, rootConfigHelp.screenshot);
|
|
|
27434
27587
|
registerActivity(program);
|
|
27435
27588
|
registerBackup(program);
|
|
27436
27589
|
registerDb(program);
|
|
27590
|
+
registerDbMigration(program);
|
|
27437
27591
|
registerCliHook(program);
|
|
27438
27592
|
registerCodeComment(program);
|
|
27439
27593
|
registerCodexHook(program);
|