@staff0rd/assist 0.345.0 → 0.346.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +288 -212
- 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.346.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1755,10 +1755,20 @@ import { basename, resolve as resolve5 } from "path";
|
|
|
1755
1755
|
|
|
1756
1756
|
// src/commands/verify/blockComments/findComments.ts
|
|
1757
1757
|
import { execSync as execSync6 } from "child_process";
|
|
1758
|
-
import
|
|
1758
|
+
import fs14 from "fs";
|
|
1759
1759
|
import { minimatch } from "minimatch";
|
|
1760
1760
|
import { Project as Project2 } from "ts-morph";
|
|
1761
1761
|
|
|
1762
|
+
// src/commands/verify/blockComments/collectFileComments.ts
|
|
1763
|
+
import fs13 from "fs";
|
|
1764
|
+
|
|
1765
|
+
// src/shared/isYamlFile.ts
|
|
1766
|
+
var YAML_EXTENSIONS = [".yml", ".yaml"];
|
|
1767
|
+
function isYamlFile(filePath) {
|
|
1768
|
+
if (!filePath) return false;
|
|
1769
|
+
return YAML_EXTENSIONS.some((ext) => filePath.endsWith(ext));
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1762
1772
|
// src/commands/verify/blockComments/collectComments.ts
|
|
1763
1773
|
function collectComments(sourceFile) {
|
|
1764
1774
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1779,6 +1789,18 @@ function collectComments(sourceFile) {
|
|
|
1779
1789
|
return comments3;
|
|
1780
1790
|
}
|
|
1781
1791
|
|
|
1792
|
+
// src/commands/verify/blockComments/collectYamlComments.ts
|
|
1793
|
+
import { Lexer } from "yaml";
|
|
1794
|
+
function collectYamlComments(content) {
|
|
1795
|
+
const comments3 = [];
|
|
1796
|
+
let line = 1;
|
|
1797
|
+
for (const token of new Lexer().lex(content)) {
|
|
1798
|
+
if (token.startsWith("#")) comments3.push({ line, text: token });
|
|
1799
|
+
for (const char of token) if (char === "\n") line++;
|
|
1800
|
+
}
|
|
1801
|
+
return comments3;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1782
1804
|
// src/commands/complexity/maintainability/parseMaintainabilityOverride.ts
|
|
1783
1805
|
var MAINTAINABILITY_OVERRIDE_MARKER = "assist-maintainability-override";
|
|
1784
1806
|
var OVERRIDE_MARKER = /^\s*\/\/\s*assist-maintainability-override:?\s*(-?\d+)\s*$/;
|
|
@@ -1817,6 +1839,31 @@ function isCommentExempt(text7) {
|
|
|
1817
1839
|
return MACHINE_DIRECTIVES.some((d) => lower.includes(d));
|
|
1818
1840
|
}
|
|
1819
1841
|
|
|
1842
|
+
// src/commands/verify/blockComments/collectFileComments.ts
|
|
1843
|
+
function toSingleLine(text7) {
|
|
1844
|
+
return text7.replace(/\s+/g, " ").trim();
|
|
1845
|
+
}
|
|
1846
|
+
function collectFileComments(file, lines, project) {
|
|
1847
|
+
const findings = [];
|
|
1848
|
+
if (isYamlFile(file)) {
|
|
1849
|
+
for (const { line, text: text7 } of collectYamlComments(
|
|
1850
|
+
fs13.readFileSync(file, "utf8")
|
|
1851
|
+
)) {
|
|
1852
|
+
if (lines.has(line))
|
|
1853
|
+
findings.push({ file, line, text: toSingleLine(text7) });
|
|
1854
|
+
}
|
|
1855
|
+
return findings;
|
|
1856
|
+
}
|
|
1857
|
+
const sourceFile = project.addSourceFileAtPath(file);
|
|
1858
|
+
for (const { pos, text: text7 } of collectComments(sourceFile)) {
|
|
1859
|
+
const { line } = sourceFile.getLineAndColumnAtPos(pos);
|
|
1860
|
+
if (!lines.has(line)) continue;
|
|
1861
|
+
if (isCommentExempt(text7)) continue;
|
|
1862
|
+
findings.push({ file, line, text: toSingleLine(text7) });
|
|
1863
|
+
}
|
|
1864
|
+
return findings;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1820
1867
|
// src/commands/verify/blockComments/parseDiffAddedLines.ts
|
|
1821
1868
|
var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
|
|
1822
1869
|
var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
|
|
@@ -1853,14 +1900,20 @@ function parseDiffAddedLines(diff2) {
|
|
|
1853
1900
|
}
|
|
1854
1901
|
|
|
1855
1902
|
// src/commands/verify/blockComments/findComments.ts
|
|
1856
|
-
var
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1903
|
+
var SCANNED_EXTENSIONS = [
|
|
1904
|
+
".ts",
|
|
1905
|
+
".tsx",
|
|
1906
|
+
".cts",
|
|
1907
|
+
".mts",
|
|
1908
|
+
".js",
|
|
1909
|
+
".jsx",
|
|
1910
|
+
".yml",
|
|
1911
|
+
".yaml"
|
|
1912
|
+
];
|
|
1860
1913
|
function shouldScan(file, ignoreGlobs) {
|
|
1861
|
-
if (!
|
|
1914
|
+
if (!SCANNED_EXTENSIONS.some((ext) => file.endsWith(ext))) return false;
|
|
1862
1915
|
if (ignoreGlobs.some((glob) => minimatch(file, glob))) return false;
|
|
1863
|
-
return
|
|
1916
|
+
return fs14.existsSync(file);
|
|
1864
1917
|
}
|
|
1865
1918
|
function findComments(options2) {
|
|
1866
1919
|
const diff2 = execSync6("git diff HEAD", {
|
|
@@ -1875,13 +1928,7 @@ function findComments(options2) {
|
|
|
1875
1928
|
const findings = [];
|
|
1876
1929
|
for (const [file, lines] of addedLines) {
|
|
1877
1930
|
if (!shouldScan(file, options2.ignoreGlobs)) continue;
|
|
1878
|
-
|
|
1879
|
-
for (const { pos, text: text7 } of collectComments(sourceFile)) {
|
|
1880
|
-
const { line } = sourceFile.getLineAndColumnAtPos(pos);
|
|
1881
|
-
if (!lines.has(line)) continue;
|
|
1882
|
-
if (isCommentExempt(text7)) continue;
|
|
1883
|
-
findings.push({ file, line, text: toSingleLine(text7) });
|
|
1884
|
-
}
|
|
1931
|
+
findings.push(...collectFileComments(file, lines, project));
|
|
1885
1932
|
}
|
|
1886
1933
|
findings.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
1887
1934
|
return findings;
|
|
@@ -2661,7 +2708,7 @@ function detectPlatform() {
|
|
|
2661
2708
|
|
|
2662
2709
|
// src/commands/notify/showNotification/showWindowsNotificationFromWsl.ts
|
|
2663
2710
|
import { spawn as spawn2 } from "child_process";
|
|
2664
|
-
import
|
|
2711
|
+
import fs15 from "fs";
|
|
2665
2712
|
import { createRequire } from "module";
|
|
2666
2713
|
import path19 from "path";
|
|
2667
2714
|
var require2 = createRequire(import.meta.url);
|
|
@@ -2673,7 +2720,7 @@ function showWindowsNotificationFromWsl(options2) {
|
|
|
2673
2720
|
const { title, message, sound } = options2;
|
|
2674
2721
|
const snoreToastPath = getSnoreToastPath();
|
|
2675
2722
|
try {
|
|
2676
|
-
|
|
2723
|
+
fs15.chmodSync(snoreToastPath, 493);
|
|
2677
2724
|
} catch {
|
|
2678
2725
|
}
|
|
2679
2726
|
const args = ["-t", title, "-m", message];
|
|
@@ -9712,7 +9759,7 @@ function registerCliHook(program2) {
|
|
|
9712
9759
|
}
|
|
9713
9760
|
|
|
9714
9761
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
9715
|
-
import { existsSync as
|
|
9762
|
+
import { existsSync as existsSync29, readFileSync as readFileSync24, unlinkSync as unlinkSync8, writeFileSync as writeFileSync22 } from "fs";
|
|
9716
9763
|
import chalk95 from "chalk";
|
|
9717
9764
|
|
|
9718
9765
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
@@ -9747,7 +9794,8 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
9747
9794
|
}
|
|
9748
9795
|
}
|
|
9749
9796
|
|
|
9750
|
-
// src/commands/codeComment/
|
|
9797
|
+
// src/commands/codeComment/readPinState.ts
|
|
9798
|
+
import { existsSync as existsSync28, readFileSync as readFileSync23 } from "fs";
|
|
9751
9799
|
function readPinState(pin) {
|
|
9752
9800
|
const path57 = getPinStatePath(pin);
|
|
9753
9801
|
if (!existsSync28(path57)) return void 0;
|
|
@@ -9759,6 +9807,8 @@ function readPinState(pin) {
|
|
|
9759
9807
|
return void 0;
|
|
9760
9808
|
}
|
|
9761
9809
|
}
|
|
9810
|
+
|
|
9811
|
+
// src/commands/codeComment/codeCommentConfirm.ts
|
|
9762
9812
|
function codeCommentConfirm(pin) {
|
|
9763
9813
|
sweepRestrictedDir();
|
|
9764
9814
|
const state = readPinState(pin);
|
|
@@ -9767,12 +9817,12 @@ function codeCommentConfirm(pin) {
|
|
|
9767
9817
|
process.exitCode = 1;
|
|
9768
9818
|
return;
|
|
9769
9819
|
}
|
|
9770
|
-
if (!
|
|
9820
|
+
if (!existsSync29(state.file)) {
|
|
9771
9821
|
console.error(chalk95.red(`Target file no longer exists: ${state.file}`));
|
|
9772
9822
|
process.exitCode = 1;
|
|
9773
9823
|
return;
|
|
9774
9824
|
}
|
|
9775
|
-
const original =
|
|
9825
|
+
const original = readFileSync24(state.file, "utf8");
|
|
9776
9826
|
const lines = original.split("\n");
|
|
9777
9827
|
const index3 = state.line - 1;
|
|
9778
9828
|
if (index3 > lines.length) {
|
|
@@ -9784,13 +9834,16 @@ function codeCommentConfirm(pin) {
|
|
|
9784
9834
|
process.exitCode = 1;
|
|
9785
9835
|
return;
|
|
9786
9836
|
}
|
|
9837
|
+
const marker = isYamlFile(state.file) ? "#" : "//";
|
|
9787
9838
|
const indentSource = lines[index3] ?? "";
|
|
9788
9839
|
const indent2 = indentSource.match(/^\s*/)?.[0] ?? "";
|
|
9789
|
-
lines.splice(index3, 0, `${indent2}
|
|
9840
|
+
lines.splice(index3, 0, `${indent2}${marker} ${state.text}`);
|
|
9790
9841
|
writeFileSync22(state.file, lines.join("\n"));
|
|
9791
9842
|
unlinkSync8(getPinStatePath(pin));
|
|
9792
9843
|
console.log(
|
|
9793
|
-
chalk95.green(
|
|
9844
|
+
chalk95.green(
|
|
9845
|
+
`Inserted "${marker} ${state.text}" at ${state.file}:${state.line}`
|
|
9846
|
+
)
|
|
9794
9847
|
);
|
|
9795
9848
|
}
|
|
9796
9849
|
|
|
@@ -9799,15 +9852,15 @@ import chalk96 from "chalk";
|
|
|
9799
9852
|
|
|
9800
9853
|
// src/commands/codeComment/validateCommentText.ts
|
|
9801
9854
|
var MAX_COMMENT_LENGTH = 50;
|
|
9802
|
-
function validateCommentText(raw) {
|
|
9803
|
-
const text7 = raw.replace(/^\/\/\s?/, "");
|
|
9855
|
+
function validateCommentText(raw, isYaml = false) {
|
|
9856
|
+
const text7 = isYaml ? raw.replace(/^#\s?/, "") : raw.replace(/^\/\/\s?/, "");
|
|
9804
9857
|
if (/[\r\n]/.test(text7)) {
|
|
9805
9858
|
return {
|
|
9806
9859
|
ok: false,
|
|
9807
9860
|
reason: "Comment must be a single line \u2014 multi-line comments are not allowed."
|
|
9808
9861
|
};
|
|
9809
9862
|
}
|
|
9810
|
-
if (text7.includes("/*") || text7.includes("*/")) {
|
|
9863
|
+
if (!isYaml && (text7.includes("/*") || text7.includes("*/"))) {
|
|
9811
9864
|
return {
|
|
9812
9865
|
ok: false,
|
|
9813
9866
|
reason: "Block comments (/* */) are not allowed \u2014 only single-line // comments."
|
|
@@ -9850,7 +9903,8 @@ function codeCommentSet(file, line, text7) {
|
|
|
9850
9903
|
process.exitCode = 1;
|
|
9851
9904
|
return;
|
|
9852
9905
|
}
|
|
9853
|
-
const
|
|
9906
|
+
const marker = isYamlFile(file) ? "#" : "//";
|
|
9907
|
+
const validation = validateCommentText(text7, isYamlFile(file));
|
|
9854
9908
|
if (!validation.ok) {
|
|
9855
9909
|
console.error(chalk96.red(`Refused: ${validation.reason}`));
|
|
9856
9910
|
console.error(chalk96.red("No pin issued."));
|
|
@@ -9874,7 +9928,7 @@ function codeCommentSet(file, line, text7) {
|
|
|
9874
9928
|
}
|
|
9875
9929
|
console.log(
|
|
9876
9930
|
`A confirmation pin was sent to your desktop notifications.
|
|
9877
|
-
To insert "
|
|
9931
|
+
To insert "${marker} ${validation.text}" at ${file}:${lineNumber}, run:
|
|
9878
9932
|
${chalk96.cyan(" assist code-comment confirm <PIN>")}
|
|
9879
9933
|
using the pin from that notification.`
|
|
9880
9934
|
);
|
|
@@ -9901,13 +9955,13 @@ import chalk105 from "chalk";
|
|
|
9901
9955
|
import chalk98 from "chalk";
|
|
9902
9956
|
|
|
9903
9957
|
// src/commands/complexity/shared/index.ts
|
|
9904
|
-
import
|
|
9958
|
+
import fs17 from "fs";
|
|
9905
9959
|
import path21 from "path";
|
|
9906
9960
|
import chalk97 from "chalk";
|
|
9907
9961
|
import ts5 from "typescript";
|
|
9908
9962
|
|
|
9909
9963
|
// src/commands/complexity/findSourceFiles.ts
|
|
9910
|
-
import
|
|
9964
|
+
import fs16 from "fs";
|
|
9911
9965
|
import path20 from "path";
|
|
9912
9966
|
import { minimatch as minimatch5 } from "minimatch";
|
|
9913
9967
|
function applyIgnoreGlobs(files, extraIgnore = []) {
|
|
@@ -9916,11 +9970,11 @@ function applyIgnoreGlobs(files, extraIgnore = []) {
|
|
|
9916
9970
|
return files.filter((f) => !ignore2.some((glob) => minimatch5(f, glob)));
|
|
9917
9971
|
}
|
|
9918
9972
|
function walk(dir, results) {
|
|
9919
|
-
if (!
|
|
9973
|
+
if (!fs16.existsSync(dir)) {
|
|
9920
9974
|
return;
|
|
9921
9975
|
}
|
|
9922
9976
|
const extensions = [".ts", ".tsx"];
|
|
9923
|
-
const entries =
|
|
9977
|
+
const entries = fs16.readdirSync(dir, { withFileTypes: true });
|
|
9924
9978
|
for (const entry of entries) {
|
|
9925
9979
|
const fullPath = path20.join(dir, entry.name);
|
|
9926
9980
|
if (entry.isDirectory()) {
|
|
@@ -9941,10 +9995,10 @@ function findSourceFiles2(pattern2, baseDir = ".", extraIgnore = []) {
|
|
|
9941
9995
|
extraIgnore
|
|
9942
9996
|
);
|
|
9943
9997
|
}
|
|
9944
|
-
if (
|
|
9998
|
+
if (fs16.existsSync(pattern2) && fs16.statSync(pattern2).isFile()) {
|
|
9945
9999
|
return [pattern2];
|
|
9946
10000
|
}
|
|
9947
|
-
if (
|
|
10001
|
+
if (fs16.existsSync(pattern2) && fs16.statSync(pattern2).isDirectory()) {
|
|
9948
10002
|
walk(pattern2, results);
|
|
9949
10003
|
return applyIgnoreGlobs(results, extraIgnore);
|
|
9950
10004
|
}
|
|
@@ -10142,7 +10196,7 @@ function countSloc(content) {
|
|
|
10142
10196
|
|
|
10143
10197
|
// src/commands/complexity/shared/index.ts
|
|
10144
10198
|
function createSourceFromFile(filePath) {
|
|
10145
|
-
const content =
|
|
10199
|
+
const content = fs17.readFileSync(filePath, "utf8");
|
|
10146
10200
|
return ts5.createSourceFile(
|
|
10147
10201
|
path21.basename(filePath),
|
|
10148
10202
|
content,
|
|
@@ -10302,7 +10356,7 @@ function printMaintainabilityFormula() {
|
|
|
10302
10356
|
}
|
|
10303
10357
|
|
|
10304
10358
|
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
10305
|
-
import
|
|
10359
|
+
import fs18 from "fs";
|
|
10306
10360
|
|
|
10307
10361
|
// src/commands/complexity/maintainability/calculateMaintainabilityIndex.ts
|
|
10308
10362
|
function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, sloc2) {
|
|
@@ -10317,7 +10371,7 @@ function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, slo
|
|
|
10317
10371
|
function collectFileMetrics(files) {
|
|
10318
10372
|
const fileMetrics = /* @__PURE__ */ new Map();
|
|
10319
10373
|
for (const file of files) {
|
|
10320
|
-
const content =
|
|
10374
|
+
const content = fs18.readFileSync(file, "utf8");
|
|
10321
10375
|
fileMetrics.set(file, {
|
|
10322
10376
|
sloc: countSloc(content),
|
|
10323
10377
|
functions: [],
|
|
@@ -10373,14 +10427,14 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
10373
10427
|
}
|
|
10374
10428
|
|
|
10375
10429
|
// src/commands/complexity/sloc.ts
|
|
10376
|
-
import
|
|
10430
|
+
import fs19 from "fs";
|
|
10377
10431
|
import chalk104 from "chalk";
|
|
10378
10432
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
10379
10433
|
withSourceFiles(pattern2, (files) => {
|
|
10380
10434
|
const results = [];
|
|
10381
10435
|
let hasViolation = false;
|
|
10382
10436
|
for (const file of files) {
|
|
10383
|
-
const content =
|
|
10437
|
+
const content = fs19.readFileSync(file, "utf8");
|
|
10384
10438
|
const lines = countSloc(content);
|
|
10385
10439
|
results.push({ file, lines });
|
|
10386
10440
|
if (options2.threshold !== void 0 && lines > options2.threshold) {
|
|
@@ -10618,7 +10672,7 @@ function registerConfig(program2) {
|
|
|
10618
10672
|
}
|
|
10619
10673
|
|
|
10620
10674
|
// src/commands/deploy/redirect.ts
|
|
10621
|
-
import { existsSync as
|
|
10675
|
+
import { existsSync as existsSync30, readFileSync as readFileSync25, writeFileSync as writeFileSync24 } from "fs";
|
|
10622
10676
|
import chalk108 from "chalk";
|
|
10623
10677
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
10624
10678
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -10627,11 +10681,11 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
10627
10681
|
</script>`;
|
|
10628
10682
|
function redirect() {
|
|
10629
10683
|
const indexPath = "index.html";
|
|
10630
|
-
if (!
|
|
10684
|
+
if (!existsSync30(indexPath)) {
|
|
10631
10685
|
console.log(chalk108.yellow("No index.html found"));
|
|
10632
10686
|
return;
|
|
10633
10687
|
}
|
|
10634
|
-
const content =
|
|
10688
|
+
const content = readFileSync25(indexPath, "utf8");
|
|
10635
10689
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
10636
10690
|
console.log(chalk108.dim("Trailing slash script already present"));
|
|
10637
10691
|
return;
|
|
@@ -10674,7 +10728,7 @@ import { execSync as execSync24 } from "child_process";
|
|
|
10674
10728
|
import chalk109 from "chalk";
|
|
10675
10729
|
|
|
10676
10730
|
// src/shared/getRepoName.ts
|
|
10677
|
-
import { existsSync as
|
|
10731
|
+
import { existsSync as existsSync31, readFileSync as readFileSync26 } from "fs";
|
|
10678
10732
|
import { basename as basename5, join as join30 } from "path";
|
|
10679
10733
|
function getRepoName() {
|
|
10680
10734
|
const config = loadConfig();
|
|
@@ -10682,9 +10736,9 @@ function getRepoName() {
|
|
|
10682
10736
|
return config.devlog.name;
|
|
10683
10737
|
}
|
|
10684
10738
|
const packageJsonPath = join30(process.cwd(), "package.json");
|
|
10685
|
-
if (
|
|
10739
|
+
if (existsSync31(packageJsonPath)) {
|
|
10686
10740
|
try {
|
|
10687
|
-
const content =
|
|
10741
|
+
const content = readFileSync26(packageJsonPath, "utf8");
|
|
10688
10742
|
const pkg = JSON.parse(content);
|
|
10689
10743
|
if (pkg.name) {
|
|
10690
10744
|
return pkg.name;
|
|
@@ -10696,7 +10750,7 @@ function getRepoName() {
|
|
|
10696
10750
|
}
|
|
10697
10751
|
|
|
10698
10752
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
10699
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
10753
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync27 } from "fs";
|
|
10700
10754
|
import { join as join31 } from "path";
|
|
10701
10755
|
var DEVLOG_DIR = join31(BLOG_REPO_ROOT, "src/content/devlog");
|
|
10702
10756
|
function extractFrontmatter(content) {
|
|
@@ -10726,7 +10780,7 @@ function readDevlogFiles(callback) {
|
|
|
10726
10780
|
try {
|
|
10727
10781
|
const files = readdirSync3(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
10728
10782
|
for (const file of files) {
|
|
10729
|
-
const content =
|
|
10783
|
+
const content = readFileSync27(join31(DEVLOG_DIR, file), "utf8");
|
|
10730
10784
|
const parsed = parseFrontmatter(content, file);
|
|
10731
10785
|
if (parsed) callback(parsed);
|
|
10732
10786
|
}
|
|
@@ -11183,12 +11237,12 @@ import { join as join33 } from "path";
|
|
|
11183
11237
|
import chalk116 from "chalk";
|
|
11184
11238
|
|
|
11185
11239
|
// src/shared/findRepoRoot.ts
|
|
11186
|
-
import { existsSync as
|
|
11240
|
+
import { existsSync as existsSync32 } from "fs";
|
|
11187
11241
|
import path22 from "path";
|
|
11188
11242
|
function findRepoRoot(dir) {
|
|
11189
11243
|
let current = dir;
|
|
11190
11244
|
while (current !== path22.dirname(current)) {
|
|
11191
|
-
if (
|
|
11245
|
+
if (existsSync32(path22.join(current, ".git"))) {
|
|
11192
11246
|
return current;
|
|
11193
11247
|
}
|
|
11194
11248
|
current = path22.dirname(current);
|
|
@@ -11254,11 +11308,11 @@ async function checkBuildLocksCommand() {
|
|
|
11254
11308
|
}
|
|
11255
11309
|
|
|
11256
11310
|
// src/commands/dotnet/buildTree.ts
|
|
11257
|
-
import { readFileSync as
|
|
11311
|
+
import { readFileSync as readFileSync28 } from "fs";
|
|
11258
11312
|
import path23 from "path";
|
|
11259
11313
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
11260
11314
|
function getProjectRefs(csprojPath) {
|
|
11261
|
-
const content =
|
|
11315
|
+
const content = readFileSync28(csprojPath, "utf8");
|
|
11262
11316
|
const refs = [];
|
|
11263
11317
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
11264
11318
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -11275,7 +11329,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
11275
11329
|
for (const ref of getProjectRefs(abs)) {
|
|
11276
11330
|
const childAbs = path23.resolve(dir, ref);
|
|
11277
11331
|
try {
|
|
11278
|
-
|
|
11332
|
+
readFileSync28(childAbs);
|
|
11279
11333
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
11280
11334
|
} catch {
|
|
11281
11335
|
node.children.push({
|
|
@@ -11300,7 +11354,7 @@ function collectAllDeps(node) {
|
|
|
11300
11354
|
}
|
|
11301
11355
|
|
|
11302
11356
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
11303
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
11357
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync29, statSync as statSync4 } from "fs";
|
|
11304
11358
|
import path24 from "path";
|
|
11305
11359
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
11306
11360
|
if (depth > maxDepth) return [];
|
|
@@ -11335,7 +11389,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
11335
11389
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
11336
11390
|
for (const sln of slnFiles) {
|
|
11337
11391
|
try {
|
|
11338
|
-
const content =
|
|
11392
|
+
const content = readFileSync29(sln, "utf8");
|
|
11339
11393
|
if (pattern2.test(content)) {
|
|
11340
11394
|
matches.push(path24.relative(repoRoot, sln));
|
|
11341
11395
|
}
|
|
@@ -11399,12 +11453,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
11399
11453
|
}
|
|
11400
11454
|
|
|
11401
11455
|
// src/commands/dotnet/resolveCsproj.ts
|
|
11402
|
-
import { existsSync as
|
|
11456
|
+
import { existsSync as existsSync33 } from "fs";
|
|
11403
11457
|
import path25 from "path";
|
|
11404
11458
|
import chalk118 from "chalk";
|
|
11405
11459
|
function resolveCsproj(csprojPath) {
|
|
11406
11460
|
const resolved = path25.resolve(csprojPath);
|
|
11407
|
-
if (!
|
|
11461
|
+
if (!existsSync33(resolved)) {
|
|
11408
11462
|
console.error(chalk118.red(`File not found: ${resolved}`));
|
|
11409
11463
|
process.exit(1);
|
|
11410
11464
|
}
|
|
@@ -11572,7 +11626,7 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
11572
11626
|
}
|
|
11573
11627
|
|
|
11574
11628
|
// src/commands/dotnet/resolveSolution.ts
|
|
11575
|
-
import { existsSync as
|
|
11629
|
+
import { existsSync as existsSync34 } from "fs";
|
|
11576
11630
|
import path26 from "path";
|
|
11577
11631
|
import chalk122 from "chalk";
|
|
11578
11632
|
|
|
@@ -11613,7 +11667,7 @@ function findSolution() {
|
|
|
11613
11667
|
function resolveSolution(sln) {
|
|
11614
11668
|
if (sln) {
|
|
11615
11669
|
const resolved = path26.resolve(sln);
|
|
11616
|
-
if (!
|
|
11670
|
+
if (!existsSync34(resolved)) {
|
|
11617
11671
|
console.error(chalk122.red(`Solution file not found: ${resolved}`));
|
|
11618
11672
|
process.exit(1);
|
|
11619
11673
|
}
|
|
@@ -11653,7 +11707,7 @@ function parseInspectReport(json) {
|
|
|
11653
11707
|
|
|
11654
11708
|
// src/commands/dotnet/runInspectCode.ts
|
|
11655
11709
|
import { execSync as execSync28 } from "child_process";
|
|
11656
|
-
import { existsSync as
|
|
11710
|
+
import { existsSync as existsSync35, readFileSync as readFileSync30, unlinkSync as unlinkSync9 } from "fs";
|
|
11657
11711
|
import { tmpdir as tmpdir3 } from "os";
|
|
11658
11712
|
import path27 from "path";
|
|
11659
11713
|
import chalk123 from "chalk";
|
|
@@ -11684,11 +11738,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
11684
11738
|
console.error(chalk123.red("jb inspectcode failed"));
|
|
11685
11739
|
process.exit(1);
|
|
11686
11740
|
}
|
|
11687
|
-
if (!
|
|
11741
|
+
if (!existsSync35(reportPath)) {
|
|
11688
11742
|
console.error(chalk123.red("Report file not generated"));
|
|
11689
11743
|
process.exit(1);
|
|
11690
11744
|
}
|
|
11691
|
-
const xml =
|
|
11745
|
+
const xml = readFileSync30(reportPath, "utf8");
|
|
11692
11746
|
unlinkSync9(reportPath);
|
|
11693
11747
|
return xml;
|
|
11694
11748
|
}
|
|
@@ -11803,10 +11857,10 @@ function registerDotnet(program2) {
|
|
|
11803
11857
|
}
|
|
11804
11858
|
|
|
11805
11859
|
// src/commands/editHook/index.ts
|
|
11806
|
-
import
|
|
11860
|
+
import fs20 from "fs";
|
|
11807
11861
|
|
|
11808
11862
|
// src/commands/editHook/extractComments.ts
|
|
11809
|
-
var
|
|
11863
|
+
var SOURCE_EXTENSIONS = [
|
|
11810
11864
|
".ts",
|
|
11811
11865
|
".tsx",
|
|
11812
11866
|
".cts",
|
|
@@ -11818,7 +11872,7 @@ var SOURCE_EXTENSIONS2 = [
|
|
|
11818
11872
|
];
|
|
11819
11873
|
function isSourceFile(filePath) {
|
|
11820
11874
|
if (!filePath) return false;
|
|
11821
|
-
return
|
|
11875
|
+
return SOURCE_EXTENSIONS.some((ext) => filePath.endsWith(ext));
|
|
11822
11876
|
}
|
|
11823
11877
|
function blankNonNewline(text7) {
|
|
11824
11878
|
return text7.replace(/[^\n]/g, " ");
|
|
@@ -11839,6 +11893,22 @@ function extractComments(text7) {
|
|
|
11839
11893
|
return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0).filter((comment3) => !isCommentExempt(comment3));
|
|
11840
11894
|
}
|
|
11841
11895
|
|
|
11896
|
+
// src/commands/editHook/extractYamlComments.ts
|
|
11897
|
+
function blankNonNewline2(text7) {
|
|
11898
|
+
return text7.replace(/[^\n]/g, " ");
|
|
11899
|
+
}
|
|
11900
|
+
function extractYamlComments(text7) {
|
|
11901
|
+
const work = text7.replace(
|
|
11902
|
+
/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g,
|
|
11903
|
+
blankNonNewline2
|
|
11904
|
+
);
|
|
11905
|
+
const comments3 = [];
|
|
11906
|
+
for (const match of work.matchAll(/(?:^|\s)(#.*)/gm)) {
|
|
11907
|
+
comments3.push(match[1]);
|
|
11908
|
+
}
|
|
11909
|
+
return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0);
|
|
11910
|
+
}
|
|
11911
|
+
|
|
11842
11912
|
// src/commands/editHook/introducedComments.ts
|
|
11843
11913
|
function introducedComments(added, removed) {
|
|
11844
11914
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -11863,7 +11933,10 @@ function commentWords(comment3) {
|
|
|
11863
11933
|
}
|
|
11864
11934
|
|
|
11865
11935
|
// src/commands/editHook/decideCommentGuard.ts
|
|
11866
|
-
|
|
11936
|
+
function denyReason(marker) {
|
|
11937
|
+
const blockClause = marker === "//" ? ", no block comments" : "";
|
|
11938
|
+
return `This edit introduces a code comment (${marker}), which is blocked by the comment gate. Comments are a last resort \u2014 prefer a clearer name, a smaller function, or a test that makes the comment unnecessary. The comment must not appear in your edit itself. If this one line genuinely earns its keep, use the escape hatch: run \`assist code-comment set <file> <line> "<text>"\` (single line, max 50 chars${blockClause}) to get a pin, then \`assist code-comment confirm <pin>\` to insert it.`;
|
|
11939
|
+
}
|
|
11867
11940
|
function defined(values) {
|
|
11868
11941
|
return values.filter((value) => value != null);
|
|
11869
11942
|
}
|
|
@@ -11892,17 +11965,20 @@ function partitionStrings(input, existingContent) {
|
|
|
11892
11965
|
}
|
|
11893
11966
|
}
|
|
11894
11967
|
function decideCommentGuard(input, existingContent) {
|
|
11895
|
-
|
|
11968
|
+
const filePath = input.tool_input.file_path;
|
|
11969
|
+
const yaml = isYamlFile(filePath);
|
|
11970
|
+
if (!isSourceFile(filePath) && !yaml) return void 0;
|
|
11971
|
+
const extract2 = yaml ? extractYamlComments : extractComments;
|
|
11896
11972
|
const { added, removed } = partitionStrings(input, existingContent);
|
|
11897
11973
|
const introduced = introducedComments(
|
|
11898
|
-
added.flatMap(
|
|
11899
|
-
removed.flatMap(
|
|
11974
|
+
added.flatMap(extract2),
|
|
11975
|
+
removed.flatMap(extract2)
|
|
11900
11976
|
);
|
|
11901
|
-
return introduced.length > 0 ?
|
|
11977
|
+
return introduced.length > 0 ? denyReason(yaml ? "#" : "//") : void 0;
|
|
11902
11978
|
}
|
|
11903
11979
|
|
|
11904
11980
|
// src/commands/editHook/decideOverrideGuard.ts
|
|
11905
|
-
var
|
|
11981
|
+
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.`;
|
|
11906
11982
|
function candidateStrings(input, existingContent) {
|
|
11907
11983
|
const { tool_name, tool_input } = input;
|
|
11908
11984
|
switch (tool_name) {
|
|
@@ -11928,7 +12004,7 @@ function decideOverrideGuard(input, existingContent) {
|
|
|
11928
12004
|
const touchesMarker = candidateStrings(input, existingContent).some(
|
|
11929
12005
|
(s) => s.includes(MAINTAINABILITY_OVERRIDE_MARKER)
|
|
11930
12006
|
);
|
|
11931
|
-
return touchesMarker ?
|
|
12007
|
+
return touchesMarker ? DENY_REASON : void 0;
|
|
11932
12008
|
}
|
|
11933
12009
|
|
|
11934
12010
|
// src/commands/editHook/index.ts
|
|
@@ -11945,7 +12021,7 @@ function tryParseInput2(raw) {
|
|
|
11945
12021
|
function readExisting(filePath) {
|
|
11946
12022
|
if (!filePath) return void 0;
|
|
11947
12023
|
try {
|
|
11948
|
-
return
|
|
12024
|
+
return fs20.readFileSync(filePath, "utf8");
|
|
11949
12025
|
} catch {
|
|
11950
12026
|
return void 0;
|
|
11951
12027
|
}
|
|
@@ -12203,9 +12279,9 @@ async function countPendingHandovers(orm, origin) {
|
|
|
12203
12279
|
|
|
12204
12280
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
12205
12281
|
import {
|
|
12206
|
-
existsSync as
|
|
12282
|
+
existsSync as existsSync36,
|
|
12207
12283
|
readdirSync as readdirSync7,
|
|
12208
|
-
readFileSync as
|
|
12284
|
+
readFileSync as readFileSync31,
|
|
12209
12285
|
rmSync as rmSync2,
|
|
12210
12286
|
statSync as statSync5
|
|
12211
12287
|
} from "fs";
|
|
@@ -12258,7 +12334,7 @@ function summariseHandoverContent(content) {
|
|
|
12258
12334
|
|
|
12259
12335
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
12260
12336
|
function collectMarkdown(dir) {
|
|
12261
|
-
if (!
|
|
12337
|
+
if (!existsSync36(dir)) return [];
|
|
12262
12338
|
const out = [];
|
|
12263
12339
|
for (const entry of readdirSync7(dir, { withFileTypes: true })) {
|
|
12264
12340
|
const full = join38(dir, entry.name);
|
|
@@ -12268,7 +12344,7 @@ function collectMarkdown(dir) {
|
|
|
12268
12344
|
return out;
|
|
12269
12345
|
}
|
|
12270
12346
|
async function migrateFile(orm, origin, file, createdAt) {
|
|
12271
|
-
const content =
|
|
12347
|
+
const content = readFileSync31(file, "utf8");
|
|
12272
12348
|
await saveHandover(orm, {
|
|
12273
12349
|
origin,
|
|
12274
12350
|
summary: summariseHandoverContent(content),
|
|
@@ -12285,7 +12361,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
12285
12361
|
migrated++;
|
|
12286
12362
|
}
|
|
12287
12363
|
const handoverPath = getHandoverPath(cwd);
|
|
12288
|
-
if (
|
|
12364
|
+
if (existsSync36(handoverPath)) {
|
|
12289
12365
|
await migrateFile(orm, origin, handoverPath, statSync5(handoverPath).mtime);
|
|
12290
12366
|
migrated++;
|
|
12291
12367
|
}
|
|
@@ -12501,7 +12577,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
12501
12577
|
import { execSync as execSync30 } from "child_process";
|
|
12502
12578
|
|
|
12503
12579
|
// src/shared/loadJson.ts
|
|
12504
|
-
import { existsSync as
|
|
12580
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync13, readFileSync as readFileSync32, writeFileSync as writeFileSync27 } from "fs";
|
|
12505
12581
|
import { homedir as homedir15 } from "os";
|
|
12506
12582
|
import { join as join39 } from "path";
|
|
12507
12583
|
function getStoreDir() {
|
|
@@ -12512,9 +12588,9 @@ function getStorePath(filename) {
|
|
|
12512
12588
|
}
|
|
12513
12589
|
function loadJson(filename) {
|
|
12514
12590
|
const path57 = getStorePath(filename);
|
|
12515
|
-
if (
|
|
12591
|
+
if (existsSync37(path57)) {
|
|
12516
12592
|
try {
|
|
12517
|
-
return JSON.parse(
|
|
12593
|
+
return JSON.parse(readFileSync32(path57, "utf8"));
|
|
12518
12594
|
} catch {
|
|
12519
12595
|
return {};
|
|
12520
12596
|
}
|
|
@@ -12523,7 +12599,7 @@ function loadJson(filename) {
|
|
|
12523
12599
|
}
|
|
12524
12600
|
function saveJson(filename, data) {
|
|
12525
12601
|
const dir = getStoreDir();
|
|
12526
|
-
if (!
|
|
12602
|
+
if (!existsSync37(dir)) {
|
|
12527
12603
|
mkdirSync13(dir, { recursive: true });
|
|
12528
12604
|
}
|
|
12529
12605
|
writeFileSync27(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
@@ -12698,7 +12774,7 @@ import { resolve as resolve11 } from "path";
|
|
|
12698
12774
|
import chalk133 from "chalk";
|
|
12699
12775
|
|
|
12700
12776
|
// src/commands/mermaid/exportFile.ts
|
|
12701
|
-
import { readFileSync as
|
|
12777
|
+
import { readFileSync as readFileSync33, writeFileSync as writeFileSync28 } from "fs";
|
|
12702
12778
|
import { basename as basename8, extname, resolve as resolve10 } from "path";
|
|
12703
12779
|
import chalk132 from "chalk";
|
|
12704
12780
|
|
|
@@ -12724,7 +12800,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
12724
12800
|
|
|
12725
12801
|
// src/commands/mermaid/exportFile.ts
|
|
12726
12802
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
12727
|
-
const content =
|
|
12803
|
+
const content = readFileSync33(file, "utf8");
|
|
12728
12804
|
const blocks = extractMermaidBlocks(content);
|
|
12729
12805
|
const stem = basename8(file, extname(file));
|
|
12730
12806
|
if (onlyIndex !== void 0) {
|
|
@@ -13008,7 +13084,7 @@ import { join as join44 } from "path";
|
|
|
13008
13084
|
import chalk136 from "chalk";
|
|
13009
13085
|
|
|
13010
13086
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
13011
|
-
import { readFileSync as
|
|
13087
|
+
import { readFileSync as readFileSync34 } from "fs";
|
|
13012
13088
|
|
|
13013
13089
|
// src/commands/netcap/parseRscRows.ts
|
|
13014
13090
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -13404,7 +13480,7 @@ function extractVoyagerPosts(body) {
|
|
|
13404
13480
|
|
|
13405
13481
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
13406
13482
|
function captureEntries(captureFile) {
|
|
13407
|
-
const lines =
|
|
13483
|
+
const lines = readFileSync34(captureFile, "utf8").split("\n").filter(Boolean);
|
|
13408
13484
|
const entries = [];
|
|
13409
13485
|
for (const line of lines) {
|
|
13410
13486
|
let entry;
|
|
@@ -13888,7 +13964,7 @@ import { tmpdir as tmpdir5 } from "os";
|
|
|
13888
13964
|
import { join as join46 } from "path";
|
|
13889
13965
|
|
|
13890
13966
|
// src/commands/prs/loadCommentsCache.ts
|
|
13891
|
-
import { existsSync as
|
|
13967
|
+
import { existsSync as existsSync38, readFileSync as readFileSync35, unlinkSync as unlinkSync11 } from "fs";
|
|
13892
13968
|
import { join as join45 } from "path";
|
|
13893
13969
|
import { parse as parse2 } from "yaml";
|
|
13894
13970
|
function getCachePath(prNumber) {
|
|
@@ -13896,15 +13972,15 @@ function getCachePath(prNumber) {
|
|
|
13896
13972
|
}
|
|
13897
13973
|
function loadCommentsCache(prNumber) {
|
|
13898
13974
|
const cachePath = getCachePath(prNumber);
|
|
13899
|
-
if (!
|
|
13975
|
+
if (!existsSync38(cachePath)) {
|
|
13900
13976
|
return null;
|
|
13901
13977
|
}
|
|
13902
|
-
const content =
|
|
13978
|
+
const content = readFileSync35(cachePath, "utf8");
|
|
13903
13979
|
return parse2(content);
|
|
13904
13980
|
}
|
|
13905
13981
|
function deleteCommentsCache(prNumber) {
|
|
13906
13982
|
const cachePath = getCachePath(prNumber);
|
|
13907
|
-
if (
|
|
13983
|
+
if (existsSync38(cachePath)) {
|
|
13908
13984
|
unlinkSync11(cachePath);
|
|
13909
13985
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
13910
13986
|
}
|
|
@@ -14004,7 +14080,7 @@ function fixed(commentId, sha) {
|
|
|
14004
14080
|
}
|
|
14005
14081
|
|
|
14006
14082
|
// src/commands/prs/listComments/index.ts
|
|
14007
|
-
import { existsSync as
|
|
14083
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync15, writeFileSync as writeFileSync32 } from "fs";
|
|
14008
14084
|
import { join as join48 } from "path";
|
|
14009
14085
|
import { stringify } from "yaml";
|
|
14010
14086
|
|
|
@@ -14130,7 +14206,7 @@ function printComments2(result) {
|
|
|
14130
14206
|
// src/commands/prs/listComments/index.ts
|
|
14131
14207
|
function writeCommentsCache(prNumber, comments3) {
|
|
14132
14208
|
const assistDir = join48(process.cwd(), ".assist");
|
|
14133
|
-
if (!
|
|
14209
|
+
if (!existsSync39(assistDir)) {
|
|
14134
14210
|
mkdirSync15(assistDir, { recursive: true });
|
|
14135
14211
|
}
|
|
14136
14212
|
const cacheData = {
|
|
@@ -14995,17 +15071,17 @@ Refactor check failed:
|
|
|
14995
15071
|
|
|
14996
15072
|
// src/commands/refactor/check/getViolations/index.ts
|
|
14997
15073
|
import { execSync as execSync43 } from "child_process";
|
|
14998
|
-
import
|
|
15074
|
+
import fs22 from "fs";
|
|
14999
15075
|
import { minimatch as minimatch6 } from "minimatch";
|
|
15000
15076
|
|
|
15001
15077
|
// src/commands/refactor/check/getViolations/getIgnoredFiles.ts
|
|
15002
|
-
import
|
|
15078
|
+
import fs21 from "fs";
|
|
15003
15079
|
var REFACTOR_YML_PATH = "refactor.yml";
|
|
15004
15080
|
function parseRefactorYml() {
|
|
15005
|
-
if (!
|
|
15081
|
+
if (!fs21.existsSync(REFACTOR_YML_PATH)) {
|
|
15006
15082
|
return [];
|
|
15007
15083
|
}
|
|
15008
|
-
const content =
|
|
15084
|
+
const content = fs21.readFileSync(REFACTOR_YML_PATH, "utf8");
|
|
15009
15085
|
const entries = [];
|
|
15010
15086
|
const lines = content.split("\n");
|
|
15011
15087
|
let currentEntry = {};
|
|
@@ -15035,7 +15111,7 @@ function getIgnoredFiles() {
|
|
|
15035
15111
|
|
|
15036
15112
|
// src/commands/refactor/check/getViolations/index.ts
|
|
15037
15113
|
function countLines(filePath) {
|
|
15038
|
-
const content =
|
|
15114
|
+
const content = fs22.readFileSync(filePath, "utf8");
|
|
15039
15115
|
return content.split("\n").length;
|
|
15040
15116
|
}
|
|
15041
15117
|
function getGitFiles(options2) {
|
|
@@ -15769,12 +15845,12 @@ import chalk155 from "chalk";
|
|
|
15769
15845
|
import { Project as Project4 } from "ts-morph";
|
|
15770
15846
|
|
|
15771
15847
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
15772
|
-
import
|
|
15848
|
+
import fs23 from "fs";
|
|
15773
15849
|
import path33 from "path";
|
|
15774
15850
|
import { Project as Project3 } from "ts-morph";
|
|
15775
15851
|
function findTsConfig(sourcePath) {
|
|
15776
15852
|
const rootConfig = path33.resolve("tsconfig.json");
|
|
15777
|
-
if (!
|
|
15853
|
+
if (!fs23.existsSync(rootConfig)) return rootConfig;
|
|
15778
15854
|
const tried = /* @__PURE__ */ new Set();
|
|
15779
15855
|
const candidates = [rootConfig, ...readReferences(rootConfig)];
|
|
15780
15856
|
for (const candidate of candidates) {
|
|
@@ -15782,7 +15858,7 @@ function findTsConfig(sourcePath) {
|
|
|
15782
15858
|
tried.add(candidate);
|
|
15783
15859
|
if (projectIncludes(candidate, sourcePath)) return candidate;
|
|
15784
15860
|
}
|
|
15785
|
-
const siblings =
|
|
15861
|
+
const siblings = fs23.readdirSync(path33.dirname(rootConfig)).filter((f) => /^tsconfig.*\.json$/.test(f)).map((f) => path33.resolve(path33.dirname(rootConfig), f));
|
|
15786
15862
|
for (const sibling of siblings) {
|
|
15787
15863
|
if (tried.has(sibling)) continue;
|
|
15788
15864
|
tried.add(sibling);
|
|
@@ -15791,8 +15867,8 @@ function findTsConfig(sourcePath) {
|
|
|
15791
15867
|
return rootConfig;
|
|
15792
15868
|
}
|
|
15793
15869
|
function readReferences(configPath) {
|
|
15794
|
-
if (!
|
|
15795
|
-
const raw =
|
|
15870
|
+
if (!fs23.existsSync(configPath)) return [];
|
|
15871
|
+
const raw = fs23.readFileSync(configPath, "utf8");
|
|
15796
15872
|
const stripped = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15797
15873
|
let parsed;
|
|
15798
15874
|
try {
|
|
@@ -15804,8 +15880,8 @@ function readReferences(configPath) {
|
|
|
15804
15880
|
const cwd = path33.dirname(configPath);
|
|
15805
15881
|
return parsed.references.map((ref) => {
|
|
15806
15882
|
const refPath = path33.resolve(cwd, ref.path);
|
|
15807
|
-
return
|
|
15808
|
-
}).filter((p) =>
|
|
15883
|
+
return fs23.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ? path33.join(refPath, "tsconfig.json") : refPath;
|
|
15884
|
+
}).filter((p) => fs23.existsSync(p));
|
|
15809
15885
|
}
|
|
15810
15886
|
function projectIncludes(configPath, sourcePath) {
|
|
15811
15887
|
try {
|
|
@@ -15855,25 +15931,25 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
15855
15931
|
}
|
|
15856
15932
|
|
|
15857
15933
|
// src/commands/refactor/ignore.ts
|
|
15858
|
-
import
|
|
15934
|
+
import fs24 from "fs";
|
|
15859
15935
|
import chalk157 from "chalk";
|
|
15860
15936
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
15861
15937
|
function ignore(file) {
|
|
15862
|
-
if (!
|
|
15938
|
+
if (!fs24.existsSync(file)) {
|
|
15863
15939
|
console.error(chalk157.red(`Error: File does not exist: ${file}`));
|
|
15864
15940
|
process.exit(1);
|
|
15865
15941
|
}
|
|
15866
|
-
const content =
|
|
15942
|
+
const content = fs24.readFileSync(file, "utf8");
|
|
15867
15943
|
const lineCount = content.split("\n").length;
|
|
15868
15944
|
const maxLines = lineCount + 10;
|
|
15869
15945
|
const entry = `- file: ${file}
|
|
15870
15946
|
maxLines: ${maxLines}
|
|
15871
15947
|
`;
|
|
15872
|
-
if (
|
|
15873
|
-
const existing =
|
|
15874
|
-
|
|
15948
|
+
if (fs24.existsSync(REFACTOR_YML_PATH2)) {
|
|
15949
|
+
const existing = fs24.readFileSync(REFACTOR_YML_PATH2, "utf8");
|
|
15950
|
+
fs24.writeFileSync(REFACTOR_YML_PATH2, existing + entry);
|
|
15875
15951
|
} else {
|
|
15876
|
-
|
|
15952
|
+
fs24.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
15877
15953
|
}
|
|
15878
15954
|
console.log(
|
|
15879
15955
|
chalk157.green(
|
|
@@ -15883,12 +15959,12 @@ function ignore(file) {
|
|
|
15883
15959
|
}
|
|
15884
15960
|
|
|
15885
15961
|
// src/commands/refactor/rename/index.ts
|
|
15886
|
-
import
|
|
15962
|
+
import fs27 from "fs";
|
|
15887
15963
|
import path40 from "path";
|
|
15888
15964
|
import chalk160 from "chalk";
|
|
15889
15965
|
|
|
15890
15966
|
// src/commands/refactor/rename/applyRename.ts
|
|
15891
|
-
import
|
|
15967
|
+
import fs26 from "fs";
|
|
15892
15968
|
import path37 from "path";
|
|
15893
15969
|
import chalk158 from "chalk";
|
|
15894
15970
|
|
|
@@ -15896,7 +15972,7 @@ import chalk158 from "chalk";
|
|
|
15896
15972
|
import path36 from "path";
|
|
15897
15973
|
|
|
15898
15974
|
// src/commands/refactor/restructure/computeRewrites/applyRewrites.ts
|
|
15899
|
-
import
|
|
15975
|
+
import fs25 from "fs";
|
|
15900
15976
|
function getOrCreateList(map, key) {
|
|
15901
15977
|
const list5 = map.get(key) ?? [];
|
|
15902
15978
|
if (!map.has(key)) map.set(key, list5);
|
|
@@ -15915,7 +15991,7 @@ function rewriteSpecifier(content, oldSpecifier, newSpecifier) {
|
|
|
15915
15991
|
return content.replace(pattern2, `$1${newSpecifier}$2`);
|
|
15916
15992
|
}
|
|
15917
15993
|
function applyFileRewrites(file, fileRewrites) {
|
|
15918
|
-
let content =
|
|
15994
|
+
let content = fs25.readFileSync(file, "utf8");
|
|
15919
15995
|
for (const { oldSpecifier, newSpecifier } of fileRewrites) {
|
|
15920
15996
|
content = rewriteSpecifier(content, oldSpecifier, newSpecifier);
|
|
15921
15997
|
}
|
|
@@ -15994,12 +16070,12 @@ function computeRewrites(moves, edges, allProjectFiles) {
|
|
|
15994
16070
|
function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
15995
16071
|
const updatedContents = applyRewrites(rewrites);
|
|
15996
16072
|
for (const [file, content] of updatedContents) {
|
|
15997
|
-
|
|
16073
|
+
fs26.writeFileSync(file, content, "utf8");
|
|
15998
16074
|
console.log(chalk158.cyan(` Updated imports in ${path37.relative(cwd, file)}`));
|
|
15999
16075
|
}
|
|
16000
16076
|
const destDir = path37.dirname(destPath);
|
|
16001
|
-
if (!
|
|
16002
|
-
|
|
16077
|
+
if (!fs26.existsSync(destDir)) fs26.mkdirSync(destDir, { recursive: true });
|
|
16078
|
+
fs26.renameSync(sourcePath, destPath);
|
|
16003
16079
|
console.log(
|
|
16004
16080
|
chalk158.white(
|
|
16005
16081
|
` Moved ${path37.relative(cwd, sourcePath)} \u2192 ${path37.relative(cwd, destPath)}`
|
|
@@ -16107,11 +16183,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
16107
16183
|
const cwd = process.cwd();
|
|
16108
16184
|
const relSource = path40.relative(cwd, sourcePath);
|
|
16109
16185
|
const relDest = path40.relative(cwd, destPath);
|
|
16110
|
-
if (!
|
|
16186
|
+
if (!fs27.existsSync(sourcePath)) {
|
|
16111
16187
|
console.log(chalk160.red(`File not found: ${source}`));
|
|
16112
16188
|
process.exit(1);
|
|
16113
16189
|
}
|
|
16114
|
-
if (destPath !== sourcePath &&
|
|
16190
|
+
if (destPath !== sourcePath && fs27.existsSync(destPath)) {
|
|
16115
16191
|
console.log(chalk160.red(`Destination already exists: ${destination}`));
|
|
16116
16192
|
process.exit(1);
|
|
16117
16193
|
}
|
|
@@ -16336,27 +16412,27 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
16336
16412
|
}
|
|
16337
16413
|
|
|
16338
16414
|
// src/commands/refactor/restructure/executePlan.ts
|
|
16339
|
-
import
|
|
16415
|
+
import fs28 from "fs";
|
|
16340
16416
|
import path45 from "path";
|
|
16341
16417
|
import chalk163 from "chalk";
|
|
16342
16418
|
function executePlan(plan2) {
|
|
16343
16419
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
16344
16420
|
for (const [file, content] of updatedContents) {
|
|
16345
|
-
|
|
16421
|
+
fs28.writeFileSync(file, content, "utf8");
|
|
16346
16422
|
console.log(
|
|
16347
16423
|
chalk163.cyan(` Rewrote imports in ${path45.relative(process.cwd(), file)}`)
|
|
16348
16424
|
);
|
|
16349
16425
|
}
|
|
16350
16426
|
for (const dir of plan2.newDirectories) {
|
|
16351
|
-
|
|
16427
|
+
fs28.mkdirSync(dir, { recursive: true });
|
|
16352
16428
|
console.log(chalk163.green(` Created ${path45.relative(process.cwd(), dir)}/`));
|
|
16353
16429
|
}
|
|
16354
16430
|
for (const move2 of plan2.moves) {
|
|
16355
16431
|
const targetDir = path45.dirname(move2.to);
|
|
16356
|
-
if (!
|
|
16357
|
-
|
|
16432
|
+
if (!fs28.existsSync(targetDir)) {
|
|
16433
|
+
fs28.mkdirSync(targetDir, { recursive: true });
|
|
16358
16434
|
}
|
|
16359
|
-
|
|
16435
|
+
fs28.renameSync(move2.from, move2.to);
|
|
16360
16436
|
console.log(
|
|
16361
16437
|
chalk163.white(
|
|
16362
16438
|
` Moved ${path45.relative(process.cwd(), move2.from)} \u2192 ${path45.relative(process.cwd(), move2.to)}`
|
|
@@ -16368,10 +16444,10 @@ function executePlan(plan2) {
|
|
|
16368
16444
|
function removeEmptyDirectories(dirs) {
|
|
16369
16445
|
const unique = [...new Set(dirs)];
|
|
16370
16446
|
for (const dir of unique) {
|
|
16371
|
-
if (!
|
|
16372
|
-
const entries =
|
|
16447
|
+
if (!fs28.existsSync(dir)) continue;
|
|
16448
|
+
const entries = fs28.readdirSync(dir);
|
|
16373
16449
|
if (entries.length === 0) {
|
|
16374
|
-
|
|
16450
|
+
fs28.rmdirSync(dir);
|
|
16375
16451
|
console.log(
|
|
16376
16452
|
chalk163.dim(
|
|
16377
16453
|
` Removed empty directory ${path45.relative(process.cwd(), dir)}`
|
|
@@ -16385,18 +16461,18 @@ function removeEmptyDirectories(dirs) {
|
|
|
16385
16461
|
import path47 from "path";
|
|
16386
16462
|
|
|
16387
16463
|
// src/commands/refactor/restructure/planFileMoves/shared.ts
|
|
16388
|
-
import
|
|
16464
|
+
import fs29 from "fs";
|
|
16389
16465
|
function emptyResult() {
|
|
16390
16466
|
return { moves: [], directories: [], warnings: [] };
|
|
16391
16467
|
}
|
|
16392
16468
|
function checkDirConflict(result, label2, dir) {
|
|
16393
|
-
if (!
|
|
16469
|
+
if (!fs29.existsSync(dir)) return false;
|
|
16394
16470
|
result.warnings.push(`Skipping ${label2}: directory ${dir} already exists`);
|
|
16395
16471
|
return true;
|
|
16396
16472
|
}
|
|
16397
16473
|
|
|
16398
16474
|
// src/commands/refactor/restructure/planFileMoves/planDirectoryMoves.ts
|
|
16399
|
-
import
|
|
16475
|
+
import fs30 from "fs";
|
|
16400
16476
|
import path46 from "path";
|
|
16401
16477
|
function collectEntry(results, dir, entry) {
|
|
16402
16478
|
const full = path46.join(dir, entry.name);
|
|
@@ -16404,9 +16480,9 @@ function collectEntry(results, dir, entry) {
|
|
|
16404
16480
|
results.push(...items2);
|
|
16405
16481
|
}
|
|
16406
16482
|
function listFilesRecursive(dir) {
|
|
16407
|
-
if (!
|
|
16483
|
+
if (!fs30.existsSync(dir)) return [];
|
|
16408
16484
|
const results = [];
|
|
16409
|
-
for (const entry of
|
|
16485
|
+
for (const entry of fs30.readdirSync(dir, { withFileTypes: true })) {
|
|
16410
16486
|
collectEntry(results, dir, entry);
|
|
16411
16487
|
}
|
|
16412
16488
|
return results;
|
|
@@ -16834,7 +16910,7 @@ function gatherContext() {
|
|
|
16834
16910
|
}
|
|
16835
16911
|
|
|
16836
16912
|
// src/commands/review/postReviewToPr.ts
|
|
16837
|
-
import { readFileSync as
|
|
16913
|
+
import { readFileSync as readFileSync36 } from "fs";
|
|
16838
16914
|
|
|
16839
16915
|
// src/commands/review/parseFindings.ts
|
|
16840
16916
|
var SEVERITIES = ["blocker", "major", "minor", "nit"];
|
|
@@ -17149,7 +17225,7 @@ async function confirmPost(prNumber, count7, options2) {
|
|
|
17149
17225
|
async function postReviewToPr(synthesisPath, options2) {
|
|
17150
17226
|
const prInfo = fetchPrDiffInfo();
|
|
17151
17227
|
const prNumber = prInfo.prNumber;
|
|
17152
|
-
const markdown =
|
|
17228
|
+
const markdown = readFileSync36(synthesisPath, "utf8");
|
|
17153
17229
|
const findings = parseFindings(markdown);
|
|
17154
17230
|
if (findings.length === 0) {
|
|
17155
17231
|
console.log("Synthesis contains no findings; nothing to post.");
|
|
@@ -17231,10 +17307,10 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
17231
17307
|
}
|
|
17232
17308
|
|
|
17233
17309
|
// src/commands/review/prepareReviewDir.ts
|
|
17234
|
-
import { existsSync as
|
|
17310
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync16, unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
17235
17311
|
function clearReviewFiles(paths) {
|
|
17236
17312
|
for (const path57 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
17237
|
-
if (
|
|
17313
|
+
if (existsSync40(path57)) unlinkSync14(path57);
|
|
17238
17314
|
}
|
|
17239
17315
|
}
|
|
17240
17316
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -17519,7 +17595,7 @@ function printReviewerFailures(results) {
|
|
|
17519
17595
|
}
|
|
17520
17596
|
|
|
17521
17597
|
// src/commands/review/runAndSynthesise.ts
|
|
17522
|
-
import { existsSync as
|
|
17598
|
+
import { existsSync as existsSync42, unlinkSync as unlinkSync16 } from "fs";
|
|
17523
17599
|
|
|
17524
17600
|
// src/commands/review/buildReviewerStdin.ts
|
|
17525
17601
|
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.
|
|
@@ -17939,7 +18015,7 @@ function resolveClaude(args) {
|
|
|
17939
18015
|
}
|
|
17940
18016
|
|
|
17941
18017
|
// src/commands/review/runCodexReviewer.ts
|
|
17942
|
-
import { existsSync as
|
|
18018
|
+
import { existsSync as existsSync41, unlinkSync as unlinkSync15 } from "fs";
|
|
17943
18019
|
|
|
17944
18020
|
// src/commands/review/parseCodexEvent.ts
|
|
17945
18021
|
function isItemStarted(value) {
|
|
@@ -17991,7 +18067,7 @@ async function runCodexReviewer(spec) {
|
|
|
17991
18067
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
17992
18068
|
}
|
|
17993
18069
|
});
|
|
17994
|
-
if (result.exitCode !== 0 &&
|
|
18070
|
+
if (result.exitCode !== 0 && existsSync41(spec.outputPath)) {
|
|
17995
18071
|
unlinkSync15(spec.outputPath);
|
|
17996
18072
|
}
|
|
17997
18073
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -18033,7 +18109,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
18033
18109
|
}
|
|
18034
18110
|
|
|
18035
18111
|
// src/commands/review/synthesise.ts
|
|
18036
|
-
import { readFileSync as
|
|
18112
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
18037
18113
|
|
|
18038
18114
|
// src/commands/review/buildSynthesisStdin.ts
|
|
18039
18115
|
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.
|
|
@@ -18089,7 +18165,7 @@ Files:
|
|
|
18089
18165
|
|
|
18090
18166
|
// src/commands/review/synthesise.ts
|
|
18091
18167
|
function printSummary2(synthesisPath) {
|
|
18092
|
-
const markdown =
|
|
18168
|
+
const markdown = readFileSync37(synthesisPath, "utf8");
|
|
18093
18169
|
console.log("");
|
|
18094
18170
|
console.log(buildReviewSummary(markdown));
|
|
18095
18171
|
console.log("");
|
|
@@ -18137,7 +18213,7 @@ async function runAndSynthesise(args) {
|
|
|
18137
18213
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
18138
18214
|
return { ok: false, failures };
|
|
18139
18215
|
}
|
|
18140
|
-
if (anyFresh &&
|
|
18216
|
+
if (anyFresh && existsSync42(paths.synthesisPath)) {
|
|
18141
18217
|
unlinkSync16(paths.synthesisPath);
|
|
18142
18218
|
}
|
|
18143
18219
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -18987,11 +19063,11 @@ async function configure() {
|
|
|
18987
19063
|
}
|
|
18988
19064
|
|
|
18989
19065
|
// src/commands/transcript/list.ts
|
|
18990
|
-
import { existsSync as
|
|
19066
|
+
import { existsSync as existsSync43, readdirSync as readdirSync9, statSync as statSync7 } from "fs";
|
|
18991
19067
|
import { join as join50 } from "path";
|
|
18992
19068
|
function list4() {
|
|
18993
19069
|
const { vttDir } = getTranscriptConfig();
|
|
18994
|
-
if (!
|
|
19070
|
+
if (!existsSync43(vttDir)) return;
|
|
18995
19071
|
for (const entry of readdirSync9(vttDir)) {
|
|
18996
19072
|
if (!entry.endsWith(".vtt")) continue;
|
|
18997
19073
|
if (statSync7(join50(vttDir, entry)).isDirectory()) continue;
|
|
@@ -19001,9 +19077,9 @@ function list4() {
|
|
|
19001
19077
|
|
|
19002
19078
|
// src/commands/transcript/move.ts
|
|
19003
19079
|
import {
|
|
19004
|
-
existsSync as
|
|
19080
|
+
existsSync as existsSync44,
|
|
19005
19081
|
mkdirSync as mkdirSync17,
|
|
19006
|
-
readFileSync as
|
|
19082
|
+
readFileSync as readFileSync38,
|
|
19007
19083
|
renameSync as renameSync2,
|
|
19008
19084
|
writeFileSync as writeFileSync35
|
|
19009
19085
|
} from "fs";
|
|
@@ -19215,7 +19291,7 @@ function formatChatLog(messages) {
|
|
|
19215
19291
|
// src/commands/transcript/move.ts
|
|
19216
19292
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
19217
19293
|
function convertVttToMarkdown(inputPath) {
|
|
19218
|
-
const cues = parseVtt(
|
|
19294
|
+
const cues = parseVtt(readFileSync38(inputPath, "utf8"));
|
|
19219
19295
|
const messages = cuesToChatMessages(deduplicateCues(cues));
|
|
19220
19296
|
return formatChatLog(messages);
|
|
19221
19297
|
}
|
|
@@ -19233,7 +19309,7 @@ function move(file, options2) {
|
|
|
19233
19309
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
19234
19310
|
const filename = basename10(file);
|
|
19235
19311
|
const sourcePath = join51(vttDir, filename);
|
|
19236
|
-
if (!
|
|
19312
|
+
if (!existsSync44(sourcePath)) {
|
|
19237
19313
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
19238
19314
|
process.exit(1);
|
|
19239
19315
|
}
|
|
@@ -19328,14 +19404,14 @@ function devices() {
|
|
|
19328
19404
|
}
|
|
19329
19405
|
|
|
19330
19406
|
// src/commands/voice/logs.ts
|
|
19331
|
-
import { existsSync as
|
|
19407
|
+
import { existsSync as existsSync45, readFileSync as readFileSync39 } from "fs";
|
|
19332
19408
|
function logs(options2) {
|
|
19333
|
-
if (!
|
|
19409
|
+
if (!existsSync45(voicePaths.log)) {
|
|
19334
19410
|
console.log("No voice log file found");
|
|
19335
19411
|
return;
|
|
19336
19412
|
}
|
|
19337
19413
|
const count7 = Number.parseInt(options2.lines ?? "150", 10);
|
|
19338
|
-
const content =
|
|
19414
|
+
const content = readFileSync39(voicePaths.log, "utf8").trim();
|
|
19339
19415
|
if (!content) {
|
|
19340
19416
|
console.log("Voice log is empty");
|
|
19341
19417
|
return;
|
|
@@ -19362,7 +19438,7 @@ import { join as join55 } from "path";
|
|
|
19362
19438
|
|
|
19363
19439
|
// src/commands/voice/checkLockFile.ts
|
|
19364
19440
|
import { execSync as execSync48 } from "child_process";
|
|
19365
|
-
import { existsSync as
|
|
19441
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync18, readFileSync as readFileSync40, writeFileSync as writeFileSync36 } from "fs";
|
|
19366
19442
|
import { join as join54 } from "path";
|
|
19367
19443
|
function isProcessAlive2(pid) {
|
|
19368
19444
|
try {
|
|
@@ -19374,9 +19450,9 @@ function isProcessAlive2(pid) {
|
|
|
19374
19450
|
}
|
|
19375
19451
|
function checkLockFile() {
|
|
19376
19452
|
const lockFile = getLockFile();
|
|
19377
|
-
if (!
|
|
19453
|
+
if (!existsSync46(lockFile)) return;
|
|
19378
19454
|
try {
|
|
19379
|
-
const lock2 = JSON.parse(
|
|
19455
|
+
const lock2 = JSON.parse(readFileSync40(lockFile, "utf8"));
|
|
19380
19456
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
19381
19457
|
console.error(
|
|
19382
19458
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -19387,7 +19463,7 @@ function checkLockFile() {
|
|
|
19387
19463
|
}
|
|
19388
19464
|
}
|
|
19389
19465
|
function bootstrapVenv() {
|
|
19390
|
-
if (
|
|
19466
|
+
if (existsSync46(getVenvPython())) return;
|
|
19391
19467
|
console.log("Setting up Python environment...");
|
|
19392
19468
|
const pythonDir = getPythonDir();
|
|
19393
19469
|
execSync48(
|
|
@@ -19478,7 +19554,7 @@ function start2(options2) {
|
|
|
19478
19554
|
}
|
|
19479
19555
|
|
|
19480
19556
|
// src/commands/voice/status.ts
|
|
19481
|
-
import { existsSync as
|
|
19557
|
+
import { existsSync as existsSync47, readFileSync as readFileSync41 } from "fs";
|
|
19482
19558
|
function isProcessAlive3(pid) {
|
|
19483
19559
|
try {
|
|
19484
19560
|
process.kill(pid, 0);
|
|
@@ -19488,16 +19564,16 @@ function isProcessAlive3(pid) {
|
|
|
19488
19564
|
}
|
|
19489
19565
|
}
|
|
19490
19566
|
function readRecentLogs(count7) {
|
|
19491
|
-
if (!
|
|
19492
|
-
const lines =
|
|
19567
|
+
if (!existsSync47(voicePaths.log)) return [];
|
|
19568
|
+
const lines = readFileSync41(voicePaths.log, "utf8").trim().split("\n");
|
|
19493
19569
|
return lines.slice(-count7);
|
|
19494
19570
|
}
|
|
19495
19571
|
function status() {
|
|
19496
|
-
if (!
|
|
19572
|
+
if (!existsSync47(voicePaths.pid)) {
|
|
19497
19573
|
console.log("Voice daemon: not running (no PID file)");
|
|
19498
19574
|
return;
|
|
19499
19575
|
}
|
|
19500
|
-
const pid = Number.parseInt(
|
|
19576
|
+
const pid = Number.parseInt(readFileSync41(voicePaths.pid, "utf8").trim(), 10);
|
|
19501
19577
|
const alive = isProcessAlive3(pid);
|
|
19502
19578
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
19503
19579
|
const recent = readRecentLogs(5);
|
|
@@ -19516,13 +19592,13 @@ function status() {
|
|
|
19516
19592
|
}
|
|
19517
19593
|
|
|
19518
19594
|
// src/commands/voice/stop.ts
|
|
19519
|
-
import { existsSync as
|
|
19595
|
+
import { existsSync as existsSync48, readFileSync as readFileSync42, unlinkSync as unlinkSync17 } from "fs";
|
|
19520
19596
|
function stop2() {
|
|
19521
|
-
if (!
|
|
19597
|
+
if (!existsSync48(voicePaths.pid)) {
|
|
19522
19598
|
console.log("Voice daemon is not running (no PID file)");
|
|
19523
19599
|
return;
|
|
19524
19600
|
}
|
|
19525
|
-
const pid = Number.parseInt(
|
|
19601
|
+
const pid = Number.parseInt(readFileSync42(voicePaths.pid, "utf8").trim(), 10);
|
|
19526
19602
|
try {
|
|
19527
19603
|
process.kill(pid, "SIGTERM");
|
|
19528
19604
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -19535,7 +19611,7 @@ function stop2() {
|
|
|
19535
19611
|
}
|
|
19536
19612
|
try {
|
|
19537
19613
|
const lockFile = getLockFile();
|
|
19538
|
-
if (
|
|
19614
|
+
if (existsSync48(lockFile)) unlinkSync17(lockFile);
|
|
19539
19615
|
} catch {
|
|
19540
19616
|
}
|
|
19541
19617
|
console.log("Voice daemon stopped");
|
|
@@ -19713,7 +19789,7 @@ async function auth() {
|
|
|
19713
19789
|
|
|
19714
19790
|
// src/commands/roam/postRoamActivity.ts
|
|
19715
19791
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
19716
|
-
import { readdirSync as readdirSync10, readFileSync as
|
|
19792
|
+
import { readdirSync as readdirSync10, readFileSync as readFileSync43, statSync as statSync8 } from "fs";
|
|
19717
19793
|
import { join as join57 } from "path";
|
|
19718
19794
|
function findPortFile(roamDir) {
|
|
19719
19795
|
let entries;
|
|
@@ -19739,7 +19815,7 @@ function postRoamActivity(app, event) {
|
|
|
19739
19815
|
if (!portFile) return;
|
|
19740
19816
|
let port;
|
|
19741
19817
|
try {
|
|
19742
|
-
port =
|
|
19818
|
+
port = readFileSync43(portFile, "utf8").trim();
|
|
19743
19819
|
} catch {
|
|
19744
19820
|
return;
|
|
19745
19821
|
}
|
|
@@ -19881,7 +19957,7 @@ function runPreCommands(pre, cwd) {
|
|
|
19881
19957
|
|
|
19882
19958
|
// src/commands/run/spawnRunCommand.ts
|
|
19883
19959
|
import { execFileSync as execFileSync8, spawn as spawn8 } from "child_process";
|
|
19884
|
-
import { existsSync as
|
|
19960
|
+
import { existsSync as existsSync49 } from "fs";
|
|
19885
19961
|
import { dirname as dirname25, join as join58, resolve as resolve13 } from "path";
|
|
19886
19962
|
function resolveCommand2(command) {
|
|
19887
19963
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
@@ -19889,7 +19965,7 @@ function resolveCommand2(command) {
|
|
|
19889
19965
|
const gitPath = execFileSync8("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
19890
19966
|
const gitRoot = resolve13(dirname25(gitPath), "..");
|
|
19891
19967
|
const gitBash = join58(gitRoot, "bin", "bash.exe");
|
|
19892
|
-
if (
|
|
19968
|
+
if (existsSync49(gitBash)) return gitBash;
|
|
19893
19969
|
} catch {
|
|
19894
19970
|
}
|
|
19895
19971
|
return command;
|
|
@@ -20100,7 +20176,7 @@ function link2() {
|
|
|
20100
20176
|
}
|
|
20101
20177
|
|
|
20102
20178
|
// src/commands/run/remove.ts
|
|
20103
|
-
import { existsSync as
|
|
20179
|
+
import { existsSync as existsSync50, unlinkSync as unlinkSync18 } from "fs";
|
|
20104
20180
|
import { join as join60 } from "path";
|
|
20105
20181
|
function findRemoveIndex() {
|
|
20106
20182
|
const idx = process.argv.indexOf("remove");
|
|
@@ -20117,7 +20193,7 @@ function parseRemoveName() {
|
|
|
20117
20193
|
}
|
|
20118
20194
|
function deleteCommandFile(name) {
|
|
20119
20195
|
const filePath = join60(".claude", "commands", `${name}.md`);
|
|
20120
|
-
if (
|
|
20196
|
+
if (existsSync50(filePath)) {
|
|
20121
20197
|
unlinkSync18(filePath);
|
|
20122
20198
|
console.log(`Deleted command file: ${filePath}`);
|
|
20123
20199
|
}
|
|
@@ -20156,7 +20232,7 @@ function registerRun(program2) {
|
|
|
20156
20232
|
|
|
20157
20233
|
// src/commands/screenshot/index.ts
|
|
20158
20234
|
import { execSync as execSync50 } from "child_process";
|
|
20159
|
-
import { existsSync as
|
|
20235
|
+
import { existsSync as existsSync51, mkdirSync as mkdirSync22, unlinkSync as unlinkSync19, writeFileSync as writeFileSync39 } from "fs";
|
|
20160
20236
|
import { tmpdir as tmpdir7 } from "os";
|
|
20161
20237
|
import { join as join61, resolve as resolve15 } from "path";
|
|
20162
20238
|
import chalk180 from "chalk";
|
|
@@ -20288,7 +20364,7 @@ Write-Output $OutputPath
|
|
|
20288
20364
|
|
|
20289
20365
|
// src/commands/screenshot/index.ts
|
|
20290
20366
|
function buildOutputPath(outputDir, processName) {
|
|
20291
|
-
if (!
|
|
20367
|
+
if (!existsSync51(outputDir)) {
|
|
20292
20368
|
mkdirSync22(outputDir, { recursive: true });
|
|
20293
20369
|
}
|
|
20294
20370
|
const timestamp4 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -20372,7 +20448,7 @@ function applyLine(result, pending, line) {
|
|
|
20372
20448
|
}
|
|
20373
20449
|
|
|
20374
20450
|
// src/commands/sessions/daemon/reportStolenSocket.ts
|
|
20375
|
-
import { readFileSync as
|
|
20451
|
+
import { readFileSync as readFileSync44 } from "fs";
|
|
20376
20452
|
function reportStolenSocket(socketPid) {
|
|
20377
20453
|
if (!socketPid) return;
|
|
20378
20454
|
const filePid = readPidFile();
|
|
@@ -20384,7 +20460,7 @@ function reportStolenSocket(socketPid) {
|
|
|
20384
20460
|
function readPidFile() {
|
|
20385
20461
|
try {
|
|
20386
20462
|
const pid = Number.parseInt(
|
|
20387
|
-
|
|
20463
|
+
readFileSync44(daemonPaths.pid, "utf8").trim(),
|
|
20388
20464
|
10
|
|
20389
20465
|
);
|
|
20390
20466
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -20738,7 +20814,7 @@ var ClientHub = class extends Set {
|
|
|
20738
20814
|
import * as pty from "node-pty";
|
|
20739
20815
|
|
|
20740
20816
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
20741
|
-
import { chmodSync, existsSync as
|
|
20817
|
+
import { chmodSync, existsSync as existsSync52, statSync as statSync9 } from "fs";
|
|
20742
20818
|
import { createRequire as createRequire3 } from "module";
|
|
20743
20819
|
import path49 from "path";
|
|
20744
20820
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -20753,7 +20829,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
20753
20829
|
`${process.platform}-${process.arch}`,
|
|
20754
20830
|
"spawn-helper"
|
|
20755
20831
|
);
|
|
20756
|
-
if (!
|
|
20832
|
+
if (!existsSync52(helper)) return;
|
|
20757
20833
|
const mode = statSync9(helper).mode;
|
|
20758
20834
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
20759
20835
|
}
|
|
@@ -21288,7 +21364,7 @@ function resumeSession(id2, sessionId, cwd, name) {
|
|
|
21288
21364
|
}
|
|
21289
21365
|
|
|
21290
21366
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
21291
|
-
import { existsSync as
|
|
21367
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync23, watch } from "fs";
|
|
21292
21368
|
import { dirname as dirname26 } from "path";
|
|
21293
21369
|
|
|
21294
21370
|
// src/commands/sessions/daemon/applyReviewPause.ts
|
|
@@ -21367,7 +21443,7 @@ function watchActivity(session, notify2) {
|
|
|
21367
21443
|
if (timer) clearTimeout(timer);
|
|
21368
21444
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
21369
21445
|
});
|
|
21370
|
-
if (
|
|
21446
|
+
if (existsSync53(path57)) read();
|
|
21371
21447
|
}
|
|
21372
21448
|
function refreshActivity(session) {
|
|
21373
21449
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -22246,12 +22322,12 @@ import * as net3 from "net";
|
|
|
22246
22322
|
import { createInterface as createInterface9 } from "readline";
|
|
22247
22323
|
|
|
22248
22324
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
22249
|
-
import * as
|
|
22325
|
+
import * as fs32 from "fs";
|
|
22250
22326
|
import * as os from "os";
|
|
22251
22327
|
import * as path51 from "path";
|
|
22252
22328
|
|
|
22253
22329
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
22254
|
-
import * as
|
|
22330
|
+
import * as fs31 from "fs";
|
|
22255
22331
|
import * as path50 from "path";
|
|
22256
22332
|
|
|
22257
22333
|
// src/commands/sessions/shared/deriveHistoryFields.ts
|
|
@@ -22349,10 +22425,10 @@ function matchMarker(text7, tag) {
|
|
|
22349
22425
|
async function parseSessionFile(filePath, origin = "wsl") {
|
|
22350
22426
|
let handle;
|
|
22351
22427
|
try {
|
|
22352
|
-
handle = await
|
|
22428
|
+
handle = await fs31.promises.open(filePath, "r");
|
|
22353
22429
|
const meta = extractSessionMeta(await readHeadLines(handle));
|
|
22354
22430
|
if (!meta.sessionId) return null;
|
|
22355
|
-
const timestamp4 = meta.timestamp || (await
|
|
22431
|
+
const timestamp4 = meta.timestamp || (await fs31.promises.stat(filePath)).mtime.toISOString();
|
|
22356
22432
|
return {
|
|
22357
22433
|
sessionId: meta.sessionId,
|
|
22358
22434
|
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
@@ -22398,7 +22474,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
22398
22474
|
sessionRoots().map(async ({ dir, origin }) => {
|
|
22399
22475
|
let projectDirs;
|
|
22400
22476
|
try {
|
|
22401
|
-
projectDirs = await
|
|
22477
|
+
projectDirs = await fs32.promises.readdir(dir);
|
|
22402
22478
|
} catch {
|
|
22403
22479
|
return;
|
|
22404
22480
|
}
|
|
@@ -22407,7 +22483,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
22407
22483
|
const dirPath = path51.join(dir, dirName);
|
|
22408
22484
|
let entries;
|
|
22409
22485
|
try {
|
|
22410
|
-
entries = await
|
|
22486
|
+
entries = await fs32.promises.readdir(dirPath);
|
|
22411
22487
|
} catch {
|
|
22412
22488
|
return;
|
|
22413
22489
|
}
|
|
@@ -22440,7 +22516,7 @@ async function discoverSessions() {
|
|
|
22440
22516
|
}
|
|
22441
22517
|
|
|
22442
22518
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
22443
|
-
import * as
|
|
22519
|
+
import * as fs33 from "fs";
|
|
22444
22520
|
|
|
22445
22521
|
// src/commands/sessions/shared/toolTarget.ts
|
|
22446
22522
|
function toolTarget(input) {
|
|
@@ -22507,7 +22583,7 @@ async function parseTranscript(sessionId) {
|
|
|
22507
22583
|
const filePath = await findSessionJsonlPath(sessionId);
|
|
22508
22584
|
if (!filePath) return [];
|
|
22509
22585
|
try {
|
|
22510
|
-
const raw = await
|
|
22586
|
+
const raw = await fs33.promises.readFile(filePath, "utf8");
|
|
22511
22587
|
return parseTranscriptLines(raw.split("\n"));
|
|
22512
22588
|
} catch {
|
|
22513
22589
|
return [];
|
|
@@ -22674,7 +22750,7 @@ function handleConnection(socket, manager) {
|
|
|
22674
22750
|
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync40 } from "fs";
|
|
22675
22751
|
|
|
22676
22752
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
22677
|
-
import { readFileSync as
|
|
22753
|
+
import { readFileSync as readFileSync45 } from "fs";
|
|
22678
22754
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
22679
22755
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
22680
22756
|
const timer = setInterval(() => {
|
|
@@ -22685,7 +22761,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
22685
22761
|
}
|
|
22686
22762
|
function ownsPidFile() {
|
|
22687
22763
|
try {
|
|
22688
|
-
return
|
|
22764
|
+
return readFileSync45(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
22689
22765
|
} catch {
|
|
22690
22766
|
return false;
|
|
22691
22767
|
}
|
|
@@ -22812,17 +22888,17 @@ function registerDaemon(program2) {
|
|
|
22812
22888
|
}
|
|
22813
22889
|
|
|
22814
22890
|
// src/commands/sessions/summarise/index.ts
|
|
22815
|
-
import * as
|
|
22891
|
+
import * as fs36 from "fs";
|
|
22816
22892
|
import chalk181 from "chalk";
|
|
22817
22893
|
|
|
22818
22894
|
// src/commands/sessions/summarise/shared.ts
|
|
22819
|
-
import * as
|
|
22895
|
+
import * as fs34 from "fs";
|
|
22820
22896
|
function writeSummary(jsonlPath2, summary) {
|
|
22821
|
-
|
|
22897
|
+
fs34.writeFileSync(summaryPathFor(jsonlPath2), `${summary.trim()}
|
|
22822
22898
|
`, "utf8");
|
|
22823
22899
|
}
|
|
22824
22900
|
function hasSummary(jsonlPath2) {
|
|
22825
|
-
return
|
|
22901
|
+
return fs34.existsSync(summaryPathFor(jsonlPath2));
|
|
22826
22902
|
}
|
|
22827
22903
|
function summaryPathFor(jsonlPath2) {
|
|
22828
22904
|
return jsonlPath2.replace(/\.jsonl$/, ".summary");
|
|
@@ -22832,7 +22908,7 @@ function summaryPathFor(jsonlPath2) {
|
|
|
22832
22908
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
22833
22909
|
|
|
22834
22910
|
// src/commands/sessions/summarise/iterateUserMessages.ts
|
|
22835
|
-
import * as
|
|
22911
|
+
import * as fs35 from "fs";
|
|
22836
22912
|
|
|
22837
22913
|
// src/commands/sessions/summarise/parseUserLine.ts
|
|
22838
22914
|
function parseUserLine(line) {
|
|
@@ -22863,13 +22939,13 @@ function parseUserLine(line) {
|
|
|
22863
22939
|
function* iterateUserMessages(filePath, maxBytes = 65536) {
|
|
22864
22940
|
let content;
|
|
22865
22941
|
try {
|
|
22866
|
-
const fd =
|
|
22942
|
+
const fd = fs35.openSync(filePath, "r");
|
|
22867
22943
|
try {
|
|
22868
22944
|
const buf = Buffer.alloc(maxBytes);
|
|
22869
|
-
const bytesRead =
|
|
22945
|
+
const bytesRead = fs35.readSync(fd, buf, 0, buf.length, 0);
|
|
22870
22946
|
content = buf.toString("utf8", 0, bytesRead);
|
|
22871
22947
|
} finally {
|
|
22872
|
-
|
|
22948
|
+
fs35.closeSync(fd);
|
|
22873
22949
|
}
|
|
22874
22950
|
} catch {
|
|
22875
22951
|
return;
|
|
@@ -22989,7 +23065,7 @@ function selectCandidates(files, options2) {
|
|
|
22989
23065
|
const candidates = options2.force ? files : files.filter((f) => !hasSummary(f));
|
|
22990
23066
|
candidates.sort((a, b) => {
|
|
22991
23067
|
try {
|
|
22992
|
-
return
|
|
23068
|
+
return fs36.statSync(b).mtimeMs - fs36.statSync(a).mtimeMs;
|
|
22993
23069
|
} catch {
|
|
22994
23070
|
return 0;
|
|
22995
23071
|
}
|
|
@@ -23138,21 +23214,21 @@ async function statusLine() {
|
|
|
23138
23214
|
}
|
|
23139
23215
|
|
|
23140
23216
|
// src/commands/sync.ts
|
|
23141
|
-
import * as
|
|
23217
|
+
import * as fs39 from "fs";
|
|
23142
23218
|
import * as os2 from "os";
|
|
23143
23219
|
import * as path55 from "path";
|
|
23144
23220
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
23145
23221
|
|
|
23146
23222
|
// src/commands/sync/syncClaudeMd.ts
|
|
23147
|
-
import * as
|
|
23223
|
+
import * as fs37 from "fs";
|
|
23148
23224
|
import * as path53 from "path";
|
|
23149
23225
|
import chalk184 from "chalk";
|
|
23150
23226
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
23151
23227
|
const source = path53.join(claudeDir, "CLAUDE.md");
|
|
23152
23228
|
const target = path53.join(targetBase, "CLAUDE.md");
|
|
23153
|
-
const sourceContent =
|
|
23154
|
-
if (
|
|
23155
|
-
const targetContent =
|
|
23229
|
+
const sourceContent = fs37.readFileSync(source, "utf8");
|
|
23230
|
+
if (fs37.existsSync(target)) {
|
|
23231
|
+
const targetContent = fs37.readFileSync(target, "utf8");
|
|
23156
23232
|
if (sourceContent !== targetContent) {
|
|
23157
23233
|
console.log(
|
|
23158
23234
|
chalk184.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
@@ -23169,21 +23245,21 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
23169
23245
|
}
|
|
23170
23246
|
}
|
|
23171
23247
|
}
|
|
23172
|
-
|
|
23248
|
+
fs37.copyFileSync(source, target);
|
|
23173
23249
|
console.log("Copied CLAUDE.md to ~/.claude/CLAUDE.md");
|
|
23174
23250
|
}
|
|
23175
23251
|
|
|
23176
23252
|
// src/commands/sync/syncSettings.ts
|
|
23177
|
-
import * as
|
|
23253
|
+
import * as fs38 from "fs";
|
|
23178
23254
|
import * as path54 from "path";
|
|
23179
23255
|
import chalk185 from "chalk";
|
|
23180
23256
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
23181
23257
|
const source = path54.join(claudeDir, "settings.json");
|
|
23182
23258
|
const target = path54.join(targetBase, "settings.json");
|
|
23183
|
-
const sourceContent =
|
|
23259
|
+
const sourceContent = fs38.readFileSync(source, "utf8");
|
|
23184
23260
|
const mergedContent = JSON.stringify(JSON.parse(sourceContent), null, " ");
|
|
23185
|
-
if (
|
|
23186
|
-
const targetContent =
|
|
23261
|
+
if (fs38.existsSync(target)) {
|
|
23262
|
+
const targetContent = fs38.readFileSync(target, "utf8");
|
|
23187
23263
|
const normalizedTarget = JSON.stringify(
|
|
23188
23264
|
JSON.parse(targetContent),
|
|
23189
23265
|
null,
|
|
@@ -23209,7 +23285,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
23209
23285
|
}
|
|
23210
23286
|
}
|
|
23211
23287
|
}
|
|
23212
|
-
|
|
23288
|
+
fs38.writeFileSync(target, mergedContent);
|
|
23213
23289
|
console.log("Copied settings.json to ~/.claude/settings.json");
|
|
23214
23290
|
}
|
|
23215
23291
|
|
|
@@ -23228,10 +23304,10 @@ async function sync(options2) {
|
|
|
23228
23304
|
function syncCommands(claudeDir, targetBase) {
|
|
23229
23305
|
const sourceDir = path55.join(claudeDir, "commands");
|
|
23230
23306
|
const targetDir = path55.join(targetBase, "commands");
|
|
23231
|
-
|
|
23232
|
-
const files =
|
|
23307
|
+
fs39.mkdirSync(targetDir, { recursive: true });
|
|
23308
|
+
const files = fs39.readdirSync(sourceDir);
|
|
23233
23309
|
for (const file of files) {
|
|
23234
|
-
|
|
23310
|
+
fs39.copyFileSync(path55.join(sourceDir, file), path55.join(targetDir, file));
|
|
23235
23311
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
23236
23312
|
}
|
|
23237
23313
|
console.log(`Synced ${files.length} command(s) to ~/.claude/commands`);
|