@staff0rd/assist 0.344.2 → 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 +85 -85
- package/dist/index.js +370 -261
- 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];
|
|
@@ -5656,11 +5703,6 @@ function delay(ms) {
|
|
|
5656
5703
|
return new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
5657
5704
|
}
|
|
5658
5705
|
|
|
5659
|
-
// src/commands/sessions/web/handleRequest.ts
|
|
5660
|
-
import { createHash as createHash2 } from "crypto";
|
|
5661
|
-
import { readFileSync as readFileSync18 } from "fs";
|
|
5662
|
-
import { createRequire as createRequire2 } from "module";
|
|
5663
|
-
|
|
5664
5706
|
// src/shared/createBundleHandler.ts
|
|
5665
5707
|
import { createHash } from "crypto";
|
|
5666
5708
|
import { readFileSync as readFileSync16 } from "fs";
|
|
@@ -5764,6 +5806,79 @@ async function getBacklogExists(req, res) {
|
|
|
5764
5806
|
respondJson(res, 200, { exists: await backlogHasItems() });
|
|
5765
5807
|
}
|
|
5766
5808
|
|
|
5809
|
+
// src/commands/backlog/originDisplayName.ts
|
|
5810
|
+
function originDisplayName(origin) {
|
|
5811
|
+
if (origin.startsWith("local:")) {
|
|
5812
|
+
const path57 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
5813
|
+
const segments = path57.split("/").filter(Boolean);
|
|
5814
|
+
return segments[segments.length - 1] ?? origin;
|
|
5815
|
+
}
|
|
5816
|
+
const firstSlash = origin.indexOf("/");
|
|
5817
|
+
if (firstSlash === -1) return origin;
|
|
5818
|
+
return origin.slice(firstSlash + 1);
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
// src/commands/backlog/originDisplayLabels.ts
|
|
5822
|
+
function originDisplayLabels(origins) {
|
|
5823
|
+
const isLocal = (origin) => origin.startsWith("local:");
|
|
5824
|
+
const bareName = (origin) => {
|
|
5825
|
+
const full = originDisplayName(origin);
|
|
5826
|
+
const segments = full.split("/");
|
|
5827
|
+
return segments[segments.length - 1] ?? full;
|
|
5828
|
+
};
|
|
5829
|
+
const remoteCounts = /* @__PURE__ */ new Map();
|
|
5830
|
+
for (const origin of new Set(origins)) {
|
|
5831
|
+
if (isLocal(origin)) continue;
|
|
5832
|
+
const name = bareName(origin);
|
|
5833
|
+
remoteCounts.set(name, (remoteCounts.get(name) ?? 0) + 1);
|
|
5834
|
+
}
|
|
5835
|
+
const labels = /* @__PURE__ */ new Map();
|
|
5836
|
+
for (const origin of origins) {
|
|
5837
|
+
if (isLocal(origin)) {
|
|
5838
|
+
labels.set(origin, originDisplayName(origin));
|
|
5839
|
+
continue;
|
|
5840
|
+
}
|
|
5841
|
+
const name = bareName(origin);
|
|
5842
|
+
const collides = (remoteCounts.get(name) ?? 0) > 1;
|
|
5843
|
+
labels.set(origin, collides ? originDisplayName(origin) : name);
|
|
5844
|
+
}
|
|
5845
|
+
return labels;
|
|
5846
|
+
}
|
|
5847
|
+
|
|
5848
|
+
// src/commands/backlog/loadRepoSummaries.ts
|
|
5849
|
+
var completedStatuses = /* @__PURE__ */ new Set(["done", "wontdo"]);
|
|
5850
|
+
async function loadRepoSummaries(currentOrigin, knownCwds = []) {
|
|
5851
|
+
const { orm } = await getReady();
|
|
5852
|
+
const summaries = await loadItemSummaries(orm, void 0);
|
|
5853
|
+
const openCounts = /* @__PURE__ */ new Map();
|
|
5854
|
+
for (const item of summaries) {
|
|
5855
|
+
if (!item.origin || completedStatuses.has(item.status)) continue;
|
|
5856
|
+
openCounts.set(item.origin, (openCounts.get(item.origin) ?? 0) + 1);
|
|
5857
|
+
}
|
|
5858
|
+
const cwdByOrigin = /* @__PURE__ */ new Map();
|
|
5859
|
+
for (const cwd of knownCwds) {
|
|
5860
|
+
const origin = getCurrentOrigin(cwd);
|
|
5861
|
+
if (!cwdByOrigin.has(origin)) cwdByOrigin.set(origin, cwd);
|
|
5862
|
+
}
|
|
5863
|
+
const labels = originDisplayLabels([...openCounts.keys()]);
|
|
5864
|
+
return [...openCounts.entries()].map(([origin, openCount]) => ({
|
|
5865
|
+
origin,
|
|
5866
|
+
displayName: labels.get(origin) ?? origin,
|
|
5867
|
+
openCount,
|
|
5868
|
+
isCurrent: origin === currentOrigin,
|
|
5869
|
+
cwd: cwdByOrigin.get(origin)
|
|
5870
|
+
})).sort((a, b) => a.displayName.localeCompare(b.displayName));
|
|
5871
|
+
}
|
|
5872
|
+
|
|
5873
|
+
// src/commands/backlog/web/getBacklogSummary.ts
|
|
5874
|
+
async function getBacklogSummary(req, res) {
|
|
5875
|
+
const url = new URL(req.url ?? "/", "http://localhost");
|
|
5876
|
+
const cwd = url.searchParams.get("cwd") ?? void 0;
|
|
5877
|
+
const knownCwds = url.searchParams.getAll("knownCwd");
|
|
5878
|
+
const currentOrigin = cwd ? getCurrentOrigin(cwd) : getOrigin();
|
|
5879
|
+
respondJson(res, 200, await loadRepoSummaries(currentOrigin, knownCwds));
|
|
5880
|
+
}
|
|
5881
|
+
|
|
5767
5882
|
// src/commands/backlog/deleteComment.ts
|
|
5768
5883
|
import { and as and4, eq as eq14 } from "drizzle-orm";
|
|
5769
5884
|
async function deleteComment(orm, itemId, commentId) {
|
|
@@ -5782,13 +5897,13 @@ async function updateStarred(orm, id2, starred) {
|
|
|
5782
5897
|
}
|
|
5783
5898
|
|
|
5784
5899
|
// src/commands/backlog/web/loadVisibleItems.ts
|
|
5785
|
-
var
|
|
5900
|
+
var completedStatuses2 = /* @__PURE__ */ new Set(["done", "wontdo"]);
|
|
5786
5901
|
async function loadVisibleItems(req) {
|
|
5787
5902
|
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
5788
5903
|
const q = params.get("q");
|
|
5789
5904
|
const loaded = q ? await searchBacklogSummaries(q) : await loadBacklogSummaries();
|
|
5790
5905
|
if (params.get("showCompleted") === "true") return loaded;
|
|
5791
|
-
return loaded.filter((item) => !
|
|
5906
|
+
return loaded.filter((item) => !completedStatuses2.has(item.status));
|
|
5792
5907
|
}
|
|
5793
5908
|
|
|
5794
5909
|
// src/commands/backlog/web/parseStatusBody.ts
|
|
@@ -6575,7 +6690,10 @@ async function restartWeb(req, res, deps2 = {}) {
|
|
|
6575
6690
|
}
|
|
6576
6691
|
}
|
|
6577
6692
|
|
|
6578
|
-
// src/commands/sessions/web/
|
|
6693
|
+
// src/commands/sessions/web/createCssHandler.ts
|
|
6694
|
+
import { createHash as createHash2 } from "crypto";
|
|
6695
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
6696
|
+
import { createRequire as createRequire2 } from "module";
|
|
6579
6697
|
var require3 = createRequire2(import.meta.url);
|
|
6580
6698
|
function createCssHandler(packageEntry) {
|
|
6581
6699
|
let cache;
|
|
@@ -6596,6 +6714,8 @@ function createCssHandler(packageEntry) {
|
|
|
6596
6714
|
res.end(cache.body);
|
|
6597
6715
|
};
|
|
6598
6716
|
}
|
|
6717
|
+
|
|
6718
|
+
// src/commands/sessions/web/handleRequest.ts
|
|
6599
6719
|
var htmlHandler = createHtmlHandler(getHtml);
|
|
6600
6720
|
var routes2 = {
|
|
6601
6721
|
"GET /": htmlHandler,
|
|
@@ -6606,6 +6726,7 @@ var routes2 = {
|
|
|
6606
6726
|
"GET /xterm.css": createCssHandler("@xterm/xterm/css/xterm.css"),
|
|
6607
6727
|
"GET /api/items": listItems,
|
|
6608
6728
|
"GET /api/backlog/exists": getBacklogExists,
|
|
6729
|
+
"GET /api/backlog/summary": getBacklogSummary,
|
|
6609
6730
|
"POST /api/backlog/init": initBacklog,
|
|
6610
6731
|
"POST /api/open-in-code": openInCode,
|
|
6611
6732
|
"POST /api/restart": restartWeb,
|
|
@@ -7547,47 +7668,6 @@ async function addPhase(id2, name, options2) {
|
|
|
7547
7668
|
|
|
7548
7669
|
// src/commands/backlog/list/index.ts
|
|
7549
7670
|
import chalk66 from "chalk";
|
|
7550
|
-
|
|
7551
|
-
// src/commands/backlog/originDisplayName.ts
|
|
7552
|
-
function originDisplayName(origin) {
|
|
7553
|
-
if (origin.startsWith("local:")) {
|
|
7554
|
-
const path57 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
7555
|
-
const segments = path57.split("/").filter(Boolean);
|
|
7556
|
-
return segments[segments.length - 1] ?? origin;
|
|
7557
|
-
}
|
|
7558
|
-
const firstSlash = origin.indexOf("/");
|
|
7559
|
-
if (firstSlash === -1) return origin;
|
|
7560
|
-
return origin.slice(firstSlash + 1);
|
|
7561
|
-
}
|
|
7562
|
-
|
|
7563
|
-
// src/commands/backlog/originDisplayLabels.ts
|
|
7564
|
-
function originDisplayLabels(origins) {
|
|
7565
|
-
const isLocal = (origin) => origin.startsWith("local:");
|
|
7566
|
-
const bareName = (origin) => {
|
|
7567
|
-
const full = originDisplayName(origin);
|
|
7568
|
-
const segments = full.split("/");
|
|
7569
|
-
return segments[segments.length - 1] ?? full;
|
|
7570
|
-
};
|
|
7571
|
-
const remoteCounts = /* @__PURE__ */ new Map();
|
|
7572
|
-
for (const origin of new Set(origins)) {
|
|
7573
|
-
if (isLocal(origin)) continue;
|
|
7574
|
-
const name = bareName(origin);
|
|
7575
|
-
remoteCounts.set(name, (remoteCounts.get(name) ?? 0) + 1);
|
|
7576
|
-
}
|
|
7577
|
-
const labels = /* @__PURE__ */ new Map();
|
|
7578
|
-
for (const origin of origins) {
|
|
7579
|
-
if (isLocal(origin)) {
|
|
7580
|
-
labels.set(origin, originDisplayName(origin));
|
|
7581
|
-
continue;
|
|
7582
|
-
}
|
|
7583
|
-
const name = bareName(origin);
|
|
7584
|
-
const collides = (remoteCounts.get(name) ?? 0) > 1;
|
|
7585
|
-
labels.set(origin, collides ? originDisplayName(origin) : name);
|
|
7586
|
-
}
|
|
7587
|
-
return labels;
|
|
7588
|
-
}
|
|
7589
|
-
|
|
7590
|
-
// src/commands/backlog/list/index.ts
|
|
7591
7671
|
function filterItems(items2, options2) {
|
|
7592
7672
|
if (options2.status) return items2.filter((i) => i.status === options2.status);
|
|
7593
7673
|
if (!options2.all)
|
|
@@ -9679,7 +9759,7 @@ function registerCliHook(program2) {
|
|
|
9679
9759
|
}
|
|
9680
9760
|
|
|
9681
9761
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
9682
|
-
import { existsSync as
|
|
9762
|
+
import { existsSync as existsSync29, readFileSync as readFileSync24, unlinkSync as unlinkSync8, writeFileSync as writeFileSync22 } from "fs";
|
|
9683
9763
|
import chalk95 from "chalk";
|
|
9684
9764
|
|
|
9685
9765
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
@@ -9714,7 +9794,8 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
9714
9794
|
}
|
|
9715
9795
|
}
|
|
9716
9796
|
|
|
9717
|
-
// src/commands/codeComment/
|
|
9797
|
+
// src/commands/codeComment/readPinState.ts
|
|
9798
|
+
import { existsSync as existsSync28, readFileSync as readFileSync23 } from "fs";
|
|
9718
9799
|
function readPinState(pin) {
|
|
9719
9800
|
const path57 = getPinStatePath(pin);
|
|
9720
9801
|
if (!existsSync28(path57)) return void 0;
|
|
@@ -9726,6 +9807,8 @@ function readPinState(pin) {
|
|
|
9726
9807
|
return void 0;
|
|
9727
9808
|
}
|
|
9728
9809
|
}
|
|
9810
|
+
|
|
9811
|
+
// src/commands/codeComment/codeCommentConfirm.ts
|
|
9729
9812
|
function codeCommentConfirm(pin) {
|
|
9730
9813
|
sweepRestrictedDir();
|
|
9731
9814
|
const state = readPinState(pin);
|
|
@@ -9734,12 +9817,12 @@ function codeCommentConfirm(pin) {
|
|
|
9734
9817
|
process.exitCode = 1;
|
|
9735
9818
|
return;
|
|
9736
9819
|
}
|
|
9737
|
-
if (!
|
|
9820
|
+
if (!existsSync29(state.file)) {
|
|
9738
9821
|
console.error(chalk95.red(`Target file no longer exists: ${state.file}`));
|
|
9739
9822
|
process.exitCode = 1;
|
|
9740
9823
|
return;
|
|
9741
9824
|
}
|
|
9742
|
-
const original =
|
|
9825
|
+
const original = readFileSync24(state.file, "utf8");
|
|
9743
9826
|
const lines = original.split("\n");
|
|
9744
9827
|
const index3 = state.line - 1;
|
|
9745
9828
|
if (index3 > lines.length) {
|
|
@@ -9751,13 +9834,16 @@ function codeCommentConfirm(pin) {
|
|
|
9751
9834
|
process.exitCode = 1;
|
|
9752
9835
|
return;
|
|
9753
9836
|
}
|
|
9837
|
+
const marker = isYamlFile(state.file) ? "#" : "//";
|
|
9754
9838
|
const indentSource = lines[index3] ?? "";
|
|
9755
9839
|
const indent2 = indentSource.match(/^\s*/)?.[0] ?? "";
|
|
9756
|
-
lines.splice(index3, 0, `${indent2}
|
|
9840
|
+
lines.splice(index3, 0, `${indent2}${marker} ${state.text}`);
|
|
9757
9841
|
writeFileSync22(state.file, lines.join("\n"));
|
|
9758
9842
|
unlinkSync8(getPinStatePath(pin));
|
|
9759
9843
|
console.log(
|
|
9760
|
-
chalk95.green(
|
|
9844
|
+
chalk95.green(
|
|
9845
|
+
`Inserted "${marker} ${state.text}" at ${state.file}:${state.line}`
|
|
9846
|
+
)
|
|
9761
9847
|
);
|
|
9762
9848
|
}
|
|
9763
9849
|
|
|
@@ -9766,15 +9852,15 @@ import chalk96 from "chalk";
|
|
|
9766
9852
|
|
|
9767
9853
|
// src/commands/codeComment/validateCommentText.ts
|
|
9768
9854
|
var MAX_COMMENT_LENGTH = 50;
|
|
9769
|
-
function validateCommentText(raw) {
|
|
9770
|
-
const text7 = raw.replace(/^\/\/\s?/, "");
|
|
9855
|
+
function validateCommentText(raw, isYaml = false) {
|
|
9856
|
+
const text7 = isYaml ? raw.replace(/^#\s?/, "") : raw.replace(/^\/\/\s?/, "");
|
|
9771
9857
|
if (/[\r\n]/.test(text7)) {
|
|
9772
9858
|
return {
|
|
9773
9859
|
ok: false,
|
|
9774
9860
|
reason: "Comment must be a single line \u2014 multi-line comments are not allowed."
|
|
9775
9861
|
};
|
|
9776
9862
|
}
|
|
9777
|
-
if (text7.includes("/*") || text7.includes("*/")) {
|
|
9863
|
+
if (!isYaml && (text7.includes("/*") || text7.includes("*/"))) {
|
|
9778
9864
|
return {
|
|
9779
9865
|
ok: false,
|
|
9780
9866
|
reason: "Block comments (/* */) are not allowed \u2014 only single-line // comments."
|
|
@@ -9817,7 +9903,8 @@ function codeCommentSet(file, line, text7) {
|
|
|
9817
9903
|
process.exitCode = 1;
|
|
9818
9904
|
return;
|
|
9819
9905
|
}
|
|
9820
|
-
const
|
|
9906
|
+
const marker = isYamlFile(file) ? "#" : "//";
|
|
9907
|
+
const validation = validateCommentText(text7, isYamlFile(file));
|
|
9821
9908
|
if (!validation.ok) {
|
|
9822
9909
|
console.error(chalk96.red(`Refused: ${validation.reason}`));
|
|
9823
9910
|
console.error(chalk96.red("No pin issued."));
|
|
@@ -9841,7 +9928,7 @@ function codeCommentSet(file, line, text7) {
|
|
|
9841
9928
|
}
|
|
9842
9929
|
console.log(
|
|
9843
9930
|
`A confirmation pin was sent to your desktop notifications.
|
|
9844
|
-
To insert "
|
|
9931
|
+
To insert "${marker} ${validation.text}" at ${file}:${lineNumber}, run:
|
|
9845
9932
|
${chalk96.cyan(" assist code-comment confirm <PIN>")}
|
|
9846
9933
|
using the pin from that notification.`
|
|
9847
9934
|
);
|
|
@@ -9868,13 +9955,13 @@ import chalk105 from "chalk";
|
|
|
9868
9955
|
import chalk98 from "chalk";
|
|
9869
9956
|
|
|
9870
9957
|
// src/commands/complexity/shared/index.ts
|
|
9871
|
-
import
|
|
9958
|
+
import fs17 from "fs";
|
|
9872
9959
|
import path21 from "path";
|
|
9873
9960
|
import chalk97 from "chalk";
|
|
9874
9961
|
import ts5 from "typescript";
|
|
9875
9962
|
|
|
9876
9963
|
// src/commands/complexity/findSourceFiles.ts
|
|
9877
|
-
import
|
|
9964
|
+
import fs16 from "fs";
|
|
9878
9965
|
import path20 from "path";
|
|
9879
9966
|
import { minimatch as minimatch5 } from "minimatch";
|
|
9880
9967
|
function applyIgnoreGlobs(files, extraIgnore = []) {
|
|
@@ -9883,11 +9970,11 @@ function applyIgnoreGlobs(files, extraIgnore = []) {
|
|
|
9883
9970
|
return files.filter((f) => !ignore2.some((glob) => minimatch5(f, glob)));
|
|
9884
9971
|
}
|
|
9885
9972
|
function walk(dir, results) {
|
|
9886
|
-
if (!
|
|
9973
|
+
if (!fs16.existsSync(dir)) {
|
|
9887
9974
|
return;
|
|
9888
9975
|
}
|
|
9889
9976
|
const extensions = [".ts", ".tsx"];
|
|
9890
|
-
const entries =
|
|
9977
|
+
const entries = fs16.readdirSync(dir, { withFileTypes: true });
|
|
9891
9978
|
for (const entry of entries) {
|
|
9892
9979
|
const fullPath = path20.join(dir, entry.name);
|
|
9893
9980
|
if (entry.isDirectory()) {
|
|
@@ -9908,10 +9995,10 @@ function findSourceFiles2(pattern2, baseDir = ".", extraIgnore = []) {
|
|
|
9908
9995
|
extraIgnore
|
|
9909
9996
|
);
|
|
9910
9997
|
}
|
|
9911
|
-
if (
|
|
9998
|
+
if (fs16.existsSync(pattern2) && fs16.statSync(pattern2).isFile()) {
|
|
9912
9999
|
return [pattern2];
|
|
9913
10000
|
}
|
|
9914
|
-
if (
|
|
10001
|
+
if (fs16.existsSync(pattern2) && fs16.statSync(pattern2).isDirectory()) {
|
|
9915
10002
|
walk(pattern2, results);
|
|
9916
10003
|
return applyIgnoreGlobs(results, extraIgnore);
|
|
9917
10004
|
}
|
|
@@ -10109,7 +10196,7 @@ function countSloc(content) {
|
|
|
10109
10196
|
|
|
10110
10197
|
// src/commands/complexity/shared/index.ts
|
|
10111
10198
|
function createSourceFromFile(filePath) {
|
|
10112
|
-
const content =
|
|
10199
|
+
const content = fs17.readFileSync(filePath, "utf8");
|
|
10113
10200
|
return ts5.createSourceFile(
|
|
10114
10201
|
path21.basename(filePath),
|
|
10115
10202
|
content,
|
|
@@ -10269,7 +10356,7 @@ function printMaintainabilityFormula() {
|
|
|
10269
10356
|
}
|
|
10270
10357
|
|
|
10271
10358
|
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
10272
|
-
import
|
|
10359
|
+
import fs18 from "fs";
|
|
10273
10360
|
|
|
10274
10361
|
// src/commands/complexity/maintainability/calculateMaintainabilityIndex.ts
|
|
10275
10362
|
function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, sloc2) {
|
|
@@ -10284,7 +10371,7 @@ function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, slo
|
|
|
10284
10371
|
function collectFileMetrics(files) {
|
|
10285
10372
|
const fileMetrics = /* @__PURE__ */ new Map();
|
|
10286
10373
|
for (const file of files) {
|
|
10287
|
-
const content =
|
|
10374
|
+
const content = fs18.readFileSync(file, "utf8");
|
|
10288
10375
|
fileMetrics.set(file, {
|
|
10289
10376
|
sloc: countSloc(content),
|
|
10290
10377
|
functions: [],
|
|
@@ -10340,14 +10427,14 @@ async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
10340
10427
|
}
|
|
10341
10428
|
|
|
10342
10429
|
// src/commands/complexity/sloc.ts
|
|
10343
|
-
import
|
|
10430
|
+
import fs19 from "fs";
|
|
10344
10431
|
import chalk104 from "chalk";
|
|
10345
10432
|
async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
10346
10433
|
withSourceFiles(pattern2, (files) => {
|
|
10347
10434
|
const results = [];
|
|
10348
10435
|
let hasViolation = false;
|
|
10349
10436
|
for (const file of files) {
|
|
10350
|
-
const content =
|
|
10437
|
+
const content = fs19.readFileSync(file, "utf8");
|
|
10351
10438
|
const lines = countSloc(content);
|
|
10352
10439
|
results.push({ file, lines });
|
|
10353
10440
|
if (options2.threshold !== void 0 && lines > options2.threshold) {
|
|
@@ -10585,7 +10672,7 @@ function registerConfig(program2) {
|
|
|
10585
10672
|
}
|
|
10586
10673
|
|
|
10587
10674
|
// src/commands/deploy/redirect.ts
|
|
10588
|
-
import { existsSync as
|
|
10675
|
+
import { existsSync as existsSync30, readFileSync as readFileSync25, writeFileSync as writeFileSync24 } from "fs";
|
|
10589
10676
|
import chalk108 from "chalk";
|
|
10590
10677
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
10591
10678
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -10594,11 +10681,11 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
10594
10681
|
</script>`;
|
|
10595
10682
|
function redirect() {
|
|
10596
10683
|
const indexPath = "index.html";
|
|
10597
|
-
if (!
|
|
10684
|
+
if (!existsSync30(indexPath)) {
|
|
10598
10685
|
console.log(chalk108.yellow("No index.html found"));
|
|
10599
10686
|
return;
|
|
10600
10687
|
}
|
|
10601
|
-
const content =
|
|
10688
|
+
const content = readFileSync25(indexPath, "utf8");
|
|
10602
10689
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
10603
10690
|
console.log(chalk108.dim("Trailing slash script already present"));
|
|
10604
10691
|
return;
|
|
@@ -10641,7 +10728,7 @@ import { execSync as execSync24 } from "child_process";
|
|
|
10641
10728
|
import chalk109 from "chalk";
|
|
10642
10729
|
|
|
10643
10730
|
// src/shared/getRepoName.ts
|
|
10644
|
-
import { existsSync as
|
|
10731
|
+
import { existsSync as existsSync31, readFileSync as readFileSync26 } from "fs";
|
|
10645
10732
|
import { basename as basename5, join as join30 } from "path";
|
|
10646
10733
|
function getRepoName() {
|
|
10647
10734
|
const config = loadConfig();
|
|
@@ -10649,9 +10736,9 @@ function getRepoName() {
|
|
|
10649
10736
|
return config.devlog.name;
|
|
10650
10737
|
}
|
|
10651
10738
|
const packageJsonPath = join30(process.cwd(), "package.json");
|
|
10652
|
-
if (
|
|
10739
|
+
if (existsSync31(packageJsonPath)) {
|
|
10653
10740
|
try {
|
|
10654
|
-
const content =
|
|
10741
|
+
const content = readFileSync26(packageJsonPath, "utf8");
|
|
10655
10742
|
const pkg = JSON.parse(content);
|
|
10656
10743
|
if (pkg.name) {
|
|
10657
10744
|
return pkg.name;
|
|
@@ -10663,7 +10750,7 @@ function getRepoName() {
|
|
|
10663
10750
|
}
|
|
10664
10751
|
|
|
10665
10752
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
10666
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
10753
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync27 } from "fs";
|
|
10667
10754
|
import { join as join31 } from "path";
|
|
10668
10755
|
var DEVLOG_DIR = join31(BLOG_REPO_ROOT, "src/content/devlog");
|
|
10669
10756
|
function extractFrontmatter(content) {
|
|
@@ -10693,7 +10780,7 @@ function readDevlogFiles(callback) {
|
|
|
10693
10780
|
try {
|
|
10694
10781
|
const files = readdirSync3(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
10695
10782
|
for (const file of files) {
|
|
10696
|
-
const content =
|
|
10783
|
+
const content = readFileSync27(join31(DEVLOG_DIR, file), "utf8");
|
|
10697
10784
|
const parsed = parseFrontmatter(content, file);
|
|
10698
10785
|
if (parsed) callback(parsed);
|
|
10699
10786
|
}
|
|
@@ -11150,12 +11237,12 @@ import { join as join33 } from "path";
|
|
|
11150
11237
|
import chalk116 from "chalk";
|
|
11151
11238
|
|
|
11152
11239
|
// src/shared/findRepoRoot.ts
|
|
11153
|
-
import { existsSync as
|
|
11240
|
+
import { existsSync as existsSync32 } from "fs";
|
|
11154
11241
|
import path22 from "path";
|
|
11155
11242
|
function findRepoRoot(dir) {
|
|
11156
11243
|
let current = dir;
|
|
11157
11244
|
while (current !== path22.dirname(current)) {
|
|
11158
|
-
if (
|
|
11245
|
+
if (existsSync32(path22.join(current, ".git"))) {
|
|
11159
11246
|
return current;
|
|
11160
11247
|
}
|
|
11161
11248
|
current = path22.dirname(current);
|
|
@@ -11221,11 +11308,11 @@ async function checkBuildLocksCommand() {
|
|
|
11221
11308
|
}
|
|
11222
11309
|
|
|
11223
11310
|
// src/commands/dotnet/buildTree.ts
|
|
11224
|
-
import { readFileSync as
|
|
11311
|
+
import { readFileSync as readFileSync28 } from "fs";
|
|
11225
11312
|
import path23 from "path";
|
|
11226
11313
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
11227
11314
|
function getProjectRefs(csprojPath) {
|
|
11228
|
-
const content =
|
|
11315
|
+
const content = readFileSync28(csprojPath, "utf8");
|
|
11229
11316
|
const refs = [];
|
|
11230
11317
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
11231
11318
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -11242,7 +11329,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
11242
11329
|
for (const ref of getProjectRefs(abs)) {
|
|
11243
11330
|
const childAbs = path23.resolve(dir, ref);
|
|
11244
11331
|
try {
|
|
11245
|
-
|
|
11332
|
+
readFileSync28(childAbs);
|
|
11246
11333
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
11247
11334
|
} catch {
|
|
11248
11335
|
node.children.push({
|
|
@@ -11267,7 +11354,7 @@ function collectAllDeps(node) {
|
|
|
11267
11354
|
}
|
|
11268
11355
|
|
|
11269
11356
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
11270
|
-
import { readdirSync as readdirSync5, readFileSync as
|
|
11357
|
+
import { readdirSync as readdirSync5, readFileSync as readFileSync29, statSync as statSync4 } from "fs";
|
|
11271
11358
|
import path24 from "path";
|
|
11272
11359
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
11273
11360
|
if (depth > maxDepth) return [];
|
|
@@ -11302,7 +11389,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
11302
11389
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
11303
11390
|
for (const sln of slnFiles) {
|
|
11304
11391
|
try {
|
|
11305
|
-
const content =
|
|
11392
|
+
const content = readFileSync29(sln, "utf8");
|
|
11306
11393
|
if (pattern2.test(content)) {
|
|
11307
11394
|
matches.push(path24.relative(repoRoot, sln));
|
|
11308
11395
|
}
|
|
@@ -11366,12 +11453,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
11366
11453
|
}
|
|
11367
11454
|
|
|
11368
11455
|
// src/commands/dotnet/resolveCsproj.ts
|
|
11369
|
-
import { existsSync as
|
|
11456
|
+
import { existsSync as existsSync33 } from "fs";
|
|
11370
11457
|
import path25 from "path";
|
|
11371
11458
|
import chalk118 from "chalk";
|
|
11372
11459
|
function resolveCsproj(csprojPath) {
|
|
11373
11460
|
const resolved = path25.resolve(csprojPath);
|
|
11374
|
-
if (!
|
|
11461
|
+
if (!existsSync33(resolved)) {
|
|
11375
11462
|
console.error(chalk118.red(`File not found: ${resolved}`));
|
|
11376
11463
|
process.exit(1);
|
|
11377
11464
|
}
|
|
@@ -11539,7 +11626,7 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
11539
11626
|
}
|
|
11540
11627
|
|
|
11541
11628
|
// src/commands/dotnet/resolveSolution.ts
|
|
11542
|
-
import { existsSync as
|
|
11629
|
+
import { existsSync as existsSync34 } from "fs";
|
|
11543
11630
|
import path26 from "path";
|
|
11544
11631
|
import chalk122 from "chalk";
|
|
11545
11632
|
|
|
@@ -11580,7 +11667,7 @@ function findSolution() {
|
|
|
11580
11667
|
function resolveSolution(sln) {
|
|
11581
11668
|
if (sln) {
|
|
11582
11669
|
const resolved = path26.resolve(sln);
|
|
11583
|
-
if (!
|
|
11670
|
+
if (!existsSync34(resolved)) {
|
|
11584
11671
|
console.error(chalk122.red(`Solution file not found: ${resolved}`));
|
|
11585
11672
|
process.exit(1);
|
|
11586
11673
|
}
|
|
@@ -11620,7 +11707,7 @@ function parseInspectReport(json) {
|
|
|
11620
11707
|
|
|
11621
11708
|
// src/commands/dotnet/runInspectCode.ts
|
|
11622
11709
|
import { execSync as execSync28 } from "child_process";
|
|
11623
|
-
import { existsSync as
|
|
11710
|
+
import { existsSync as existsSync35, readFileSync as readFileSync30, unlinkSync as unlinkSync9 } from "fs";
|
|
11624
11711
|
import { tmpdir as tmpdir3 } from "os";
|
|
11625
11712
|
import path27 from "path";
|
|
11626
11713
|
import chalk123 from "chalk";
|
|
@@ -11651,11 +11738,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
11651
11738
|
console.error(chalk123.red("jb inspectcode failed"));
|
|
11652
11739
|
process.exit(1);
|
|
11653
11740
|
}
|
|
11654
|
-
if (!
|
|
11741
|
+
if (!existsSync35(reportPath)) {
|
|
11655
11742
|
console.error(chalk123.red("Report file not generated"));
|
|
11656
11743
|
process.exit(1);
|
|
11657
11744
|
}
|
|
11658
|
-
const xml =
|
|
11745
|
+
const xml = readFileSync30(reportPath, "utf8");
|
|
11659
11746
|
unlinkSync9(reportPath);
|
|
11660
11747
|
return xml;
|
|
11661
11748
|
}
|
|
@@ -11770,10 +11857,10 @@ function registerDotnet(program2) {
|
|
|
11770
11857
|
}
|
|
11771
11858
|
|
|
11772
11859
|
// src/commands/editHook/index.ts
|
|
11773
|
-
import
|
|
11860
|
+
import fs20 from "fs";
|
|
11774
11861
|
|
|
11775
11862
|
// src/commands/editHook/extractComments.ts
|
|
11776
|
-
var
|
|
11863
|
+
var SOURCE_EXTENSIONS = [
|
|
11777
11864
|
".ts",
|
|
11778
11865
|
".tsx",
|
|
11779
11866
|
".cts",
|
|
@@ -11785,7 +11872,7 @@ var SOURCE_EXTENSIONS2 = [
|
|
|
11785
11872
|
];
|
|
11786
11873
|
function isSourceFile(filePath) {
|
|
11787
11874
|
if (!filePath) return false;
|
|
11788
|
-
return
|
|
11875
|
+
return SOURCE_EXTENSIONS.some((ext) => filePath.endsWith(ext));
|
|
11789
11876
|
}
|
|
11790
11877
|
function blankNonNewline(text7) {
|
|
11791
11878
|
return text7.replace(/[^\n]/g, " ");
|
|
@@ -11806,6 +11893,22 @@ function extractComments(text7) {
|
|
|
11806
11893
|
return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0).filter((comment3) => !isCommentExempt(comment3));
|
|
11807
11894
|
}
|
|
11808
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
|
+
|
|
11809
11912
|
// src/commands/editHook/introducedComments.ts
|
|
11810
11913
|
function introducedComments(added, removed) {
|
|
11811
11914
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -11830,7 +11933,10 @@ function commentWords(comment3) {
|
|
|
11830
11933
|
}
|
|
11831
11934
|
|
|
11832
11935
|
// src/commands/editHook/decideCommentGuard.ts
|
|
11833
|
-
|
|
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
|
+
}
|
|
11834
11940
|
function defined(values) {
|
|
11835
11941
|
return values.filter((value) => value != null);
|
|
11836
11942
|
}
|
|
@@ -11859,17 +11965,20 @@ function partitionStrings(input, existingContent) {
|
|
|
11859
11965
|
}
|
|
11860
11966
|
}
|
|
11861
11967
|
function decideCommentGuard(input, existingContent) {
|
|
11862
|
-
|
|
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;
|
|
11863
11972
|
const { added, removed } = partitionStrings(input, existingContent);
|
|
11864
11973
|
const introduced = introducedComments(
|
|
11865
|
-
added.flatMap(
|
|
11866
|
-
removed.flatMap(
|
|
11974
|
+
added.flatMap(extract2),
|
|
11975
|
+
removed.flatMap(extract2)
|
|
11867
11976
|
);
|
|
11868
|
-
return introduced.length > 0 ?
|
|
11977
|
+
return introduced.length > 0 ? denyReason(yaml ? "#" : "//") : void 0;
|
|
11869
11978
|
}
|
|
11870
11979
|
|
|
11871
11980
|
// src/commands/editHook/decideOverrideGuard.ts
|
|
11872
|
-
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.`;
|
|
11873
11982
|
function candidateStrings(input, existingContent) {
|
|
11874
11983
|
const { tool_name, tool_input } = input;
|
|
11875
11984
|
switch (tool_name) {
|
|
@@ -11895,7 +12004,7 @@ function decideOverrideGuard(input, existingContent) {
|
|
|
11895
12004
|
const touchesMarker = candidateStrings(input, existingContent).some(
|
|
11896
12005
|
(s) => s.includes(MAINTAINABILITY_OVERRIDE_MARKER)
|
|
11897
12006
|
);
|
|
11898
|
-
return touchesMarker ?
|
|
12007
|
+
return touchesMarker ? DENY_REASON : void 0;
|
|
11899
12008
|
}
|
|
11900
12009
|
|
|
11901
12010
|
// src/commands/editHook/index.ts
|
|
@@ -11912,7 +12021,7 @@ function tryParseInput2(raw) {
|
|
|
11912
12021
|
function readExisting(filePath) {
|
|
11913
12022
|
if (!filePath) return void 0;
|
|
11914
12023
|
try {
|
|
11915
|
-
return
|
|
12024
|
+
return fs20.readFileSync(filePath, "utf8");
|
|
11916
12025
|
} catch {
|
|
11917
12026
|
return void 0;
|
|
11918
12027
|
}
|
|
@@ -12170,9 +12279,9 @@ async function countPendingHandovers(orm, origin) {
|
|
|
12170
12279
|
|
|
12171
12280
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
12172
12281
|
import {
|
|
12173
|
-
existsSync as
|
|
12282
|
+
existsSync as existsSync36,
|
|
12174
12283
|
readdirSync as readdirSync7,
|
|
12175
|
-
readFileSync as
|
|
12284
|
+
readFileSync as readFileSync31,
|
|
12176
12285
|
rmSync as rmSync2,
|
|
12177
12286
|
statSync as statSync5
|
|
12178
12287
|
} from "fs";
|
|
@@ -12225,7 +12334,7 @@ function summariseHandoverContent(content) {
|
|
|
12225
12334
|
|
|
12226
12335
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
12227
12336
|
function collectMarkdown(dir) {
|
|
12228
|
-
if (!
|
|
12337
|
+
if (!existsSync36(dir)) return [];
|
|
12229
12338
|
const out = [];
|
|
12230
12339
|
for (const entry of readdirSync7(dir, { withFileTypes: true })) {
|
|
12231
12340
|
const full = join38(dir, entry.name);
|
|
@@ -12235,7 +12344,7 @@ function collectMarkdown(dir) {
|
|
|
12235
12344
|
return out;
|
|
12236
12345
|
}
|
|
12237
12346
|
async function migrateFile(orm, origin, file, createdAt) {
|
|
12238
|
-
const content =
|
|
12347
|
+
const content = readFileSync31(file, "utf8");
|
|
12239
12348
|
await saveHandover(orm, {
|
|
12240
12349
|
origin,
|
|
12241
12350
|
summary: summariseHandoverContent(content),
|
|
@@ -12252,7 +12361,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
12252
12361
|
migrated++;
|
|
12253
12362
|
}
|
|
12254
12363
|
const handoverPath = getHandoverPath(cwd);
|
|
12255
|
-
if (
|
|
12364
|
+
if (existsSync36(handoverPath)) {
|
|
12256
12365
|
await migrateFile(orm, origin, handoverPath, statSync5(handoverPath).mtime);
|
|
12257
12366
|
migrated++;
|
|
12258
12367
|
}
|
|
@@ -12468,7 +12577,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
12468
12577
|
import { execSync as execSync30 } from "child_process";
|
|
12469
12578
|
|
|
12470
12579
|
// src/shared/loadJson.ts
|
|
12471
|
-
import { existsSync as
|
|
12580
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync13, readFileSync as readFileSync32, writeFileSync as writeFileSync27 } from "fs";
|
|
12472
12581
|
import { homedir as homedir15 } from "os";
|
|
12473
12582
|
import { join as join39 } from "path";
|
|
12474
12583
|
function getStoreDir() {
|
|
@@ -12479,9 +12588,9 @@ function getStorePath(filename) {
|
|
|
12479
12588
|
}
|
|
12480
12589
|
function loadJson(filename) {
|
|
12481
12590
|
const path57 = getStorePath(filename);
|
|
12482
|
-
if (
|
|
12591
|
+
if (existsSync37(path57)) {
|
|
12483
12592
|
try {
|
|
12484
|
-
return JSON.parse(
|
|
12593
|
+
return JSON.parse(readFileSync32(path57, "utf8"));
|
|
12485
12594
|
} catch {
|
|
12486
12595
|
return {};
|
|
12487
12596
|
}
|
|
@@ -12490,7 +12599,7 @@ function loadJson(filename) {
|
|
|
12490
12599
|
}
|
|
12491
12600
|
function saveJson(filename, data) {
|
|
12492
12601
|
const dir = getStoreDir();
|
|
12493
|
-
if (!
|
|
12602
|
+
if (!existsSync37(dir)) {
|
|
12494
12603
|
mkdirSync13(dir, { recursive: true });
|
|
12495
12604
|
}
|
|
12496
12605
|
writeFileSync27(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
@@ -12665,7 +12774,7 @@ import { resolve as resolve11 } from "path";
|
|
|
12665
12774
|
import chalk133 from "chalk";
|
|
12666
12775
|
|
|
12667
12776
|
// src/commands/mermaid/exportFile.ts
|
|
12668
|
-
import { readFileSync as
|
|
12777
|
+
import { readFileSync as readFileSync33, writeFileSync as writeFileSync28 } from "fs";
|
|
12669
12778
|
import { basename as basename8, extname, resolve as resolve10 } from "path";
|
|
12670
12779
|
import chalk132 from "chalk";
|
|
12671
12780
|
|
|
@@ -12691,7 +12800,7 @@ async function renderBlock(krokiUrl, source) {
|
|
|
12691
12800
|
|
|
12692
12801
|
// src/commands/mermaid/exportFile.ts
|
|
12693
12802
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
12694
|
-
const content =
|
|
12803
|
+
const content = readFileSync33(file, "utf8");
|
|
12695
12804
|
const blocks = extractMermaidBlocks(content);
|
|
12696
12805
|
const stem = basename8(file, extname(file));
|
|
12697
12806
|
if (onlyIndex !== void 0) {
|
|
@@ -12975,7 +13084,7 @@ import { join as join44 } from "path";
|
|
|
12975
13084
|
import chalk136 from "chalk";
|
|
12976
13085
|
|
|
12977
13086
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
12978
|
-
import { readFileSync as
|
|
13087
|
+
import { readFileSync as readFileSync34 } from "fs";
|
|
12979
13088
|
|
|
12980
13089
|
// src/commands/netcap/parseRscRows.ts
|
|
12981
13090
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -13371,7 +13480,7 @@ function extractVoyagerPosts(body) {
|
|
|
13371
13480
|
|
|
13372
13481
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
13373
13482
|
function captureEntries(captureFile) {
|
|
13374
|
-
const lines =
|
|
13483
|
+
const lines = readFileSync34(captureFile, "utf8").split("\n").filter(Boolean);
|
|
13375
13484
|
const entries = [];
|
|
13376
13485
|
for (const line of lines) {
|
|
13377
13486
|
let entry;
|
|
@@ -13855,7 +13964,7 @@ import { tmpdir as tmpdir5 } from "os";
|
|
|
13855
13964
|
import { join as join46 } from "path";
|
|
13856
13965
|
|
|
13857
13966
|
// src/commands/prs/loadCommentsCache.ts
|
|
13858
|
-
import { existsSync as
|
|
13967
|
+
import { existsSync as existsSync38, readFileSync as readFileSync35, unlinkSync as unlinkSync11 } from "fs";
|
|
13859
13968
|
import { join as join45 } from "path";
|
|
13860
13969
|
import { parse as parse2 } from "yaml";
|
|
13861
13970
|
function getCachePath(prNumber) {
|
|
@@ -13863,15 +13972,15 @@ function getCachePath(prNumber) {
|
|
|
13863
13972
|
}
|
|
13864
13973
|
function loadCommentsCache(prNumber) {
|
|
13865
13974
|
const cachePath = getCachePath(prNumber);
|
|
13866
|
-
if (!
|
|
13975
|
+
if (!existsSync38(cachePath)) {
|
|
13867
13976
|
return null;
|
|
13868
13977
|
}
|
|
13869
|
-
const content =
|
|
13978
|
+
const content = readFileSync35(cachePath, "utf8");
|
|
13870
13979
|
return parse2(content);
|
|
13871
13980
|
}
|
|
13872
13981
|
function deleteCommentsCache(prNumber) {
|
|
13873
13982
|
const cachePath = getCachePath(prNumber);
|
|
13874
|
-
if (
|
|
13983
|
+
if (existsSync38(cachePath)) {
|
|
13875
13984
|
unlinkSync11(cachePath);
|
|
13876
13985
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
13877
13986
|
}
|
|
@@ -13971,7 +14080,7 @@ function fixed(commentId, sha) {
|
|
|
13971
14080
|
}
|
|
13972
14081
|
|
|
13973
14082
|
// src/commands/prs/listComments/index.ts
|
|
13974
|
-
import { existsSync as
|
|
14083
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync15, writeFileSync as writeFileSync32 } from "fs";
|
|
13975
14084
|
import { join as join48 } from "path";
|
|
13976
14085
|
import { stringify } from "yaml";
|
|
13977
14086
|
|
|
@@ -14097,7 +14206,7 @@ function printComments2(result) {
|
|
|
14097
14206
|
// src/commands/prs/listComments/index.ts
|
|
14098
14207
|
function writeCommentsCache(prNumber, comments3) {
|
|
14099
14208
|
const assistDir = join48(process.cwd(), ".assist");
|
|
14100
|
-
if (!
|
|
14209
|
+
if (!existsSync39(assistDir)) {
|
|
14101
14210
|
mkdirSync15(assistDir, { recursive: true });
|
|
14102
14211
|
}
|
|
14103
14212
|
const cacheData = {
|
|
@@ -14962,17 +15071,17 @@ Refactor check failed:
|
|
|
14962
15071
|
|
|
14963
15072
|
// src/commands/refactor/check/getViolations/index.ts
|
|
14964
15073
|
import { execSync as execSync43 } from "child_process";
|
|
14965
|
-
import
|
|
15074
|
+
import fs22 from "fs";
|
|
14966
15075
|
import { minimatch as minimatch6 } from "minimatch";
|
|
14967
15076
|
|
|
14968
15077
|
// src/commands/refactor/check/getViolations/getIgnoredFiles.ts
|
|
14969
|
-
import
|
|
15078
|
+
import fs21 from "fs";
|
|
14970
15079
|
var REFACTOR_YML_PATH = "refactor.yml";
|
|
14971
15080
|
function parseRefactorYml() {
|
|
14972
|
-
if (!
|
|
15081
|
+
if (!fs21.existsSync(REFACTOR_YML_PATH)) {
|
|
14973
15082
|
return [];
|
|
14974
15083
|
}
|
|
14975
|
-
const content =
|
|
15084
|
+
const content = fs21.readFileSync(REFACTOR_YML_PATH, "utf8");
|
|
14976
15085
|
const entries = [];
|
|
14977
15086
|
const lines = content.split("\n");
|
|
14978
15087
|
let currentEntry = {};
|
|
@@ -15002,7 +15111,7 @@ function getIgnoredFiles() {
|
|
|
15002
15111
|
|
|
15003
15112
|
// src/commands/refactor/check/getViolations/index.ts
|
|
15004
15113
|
function countLines(filePath) {
|
|
15005
|
-
const content =
|
|
15114
|
+
const content = fs22.readFileSync(filePath, "utf8");
|
|
15006
15115
|
return content.split("\n").length;
|
|
15007
15116
|
}
|
|
15008
15117
|
function getGitFiles(options2) {
|
|
@@ -15736,12 +15845,12 @@ import chalk155 from "chalk";
|
|
|
15736
15845
|
import { Project as Project4 } from "ts-morph";
|
|
15737
15846
|
|
|
15738
15847
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
15739
|
-
import
|
|
15848
|
+
import fs23 from "fs";
|
|
15740
15849
|
import path33 from "path";
|
|
15741
15850
|
import { Project as Project3 } from "ts-morph";
|
|
15742
15851
|
function findTsConfig(sourcePath) {
|
|
15743
15852
|
const rootConfig = path33.resolve("tsconfig.json");
|
|
15744
|
-
if (!
|
|
15853
|
+
if (!fs23.existsSync(rootConfig)) return rootConfig;
|
|
15745
15854
|
const tried = /* @__PURE__ */ new Set();
|
|
15746
15855
|
const candidates = [rootConfig, ...readReferences(rootConfig)];
|
|
15747
15856
|
for (const candidate of candidates) {
|
|
@@ -15749,7 +15858,7 @@ function findTsConfig(sourcePath) {
|
|
|
15749
15858
|
tried.add(candidate);
|
|
15750
15859
|
if (projectIncludes(candidate, sourcePath)) return candidate;
|
|
15751
15860
|
}
|
|
15752
|
-
const siblings =
|
|
15861
|
+
const siblings = fs23.readdirSync(path33.dirname(rootConfig)).filter((f) => /^tsconfig.*\.json$/.test(f)).map((f) => path33.resolve(path33.dirname(rootConfig), f));
|
|
15753
15862
|
for (const sibling of siblings) {
|
|
15754
15863
|
if (tried.has(sibling)) continue;
|
|
15755
15864
|
tried.add(sibling);
|
|
@@ -15758,8 +15867,8 @@ function findTsConfig(sourcePath) {
|
|
|
15758
15867
|
return rootConfig;
|
|
15759
15868
|
}
|
|
15760
15869
|
function readReferences(configPath) {
|
|
15761
|
-
if (!
|
|
15762
|
-
const raw =
|
|
15870
|
+
if (!fs23.existsSync(configPath)) return [];
|
|
15871
|
+
const raw = fs23.readFileSync(configPath, "utf8");
|
|
15763
15872
|
const stripped = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
15764
15873
|
let parsed;
|
|
15765
15874
|
try {
|
|
@@ -15771,8 +15880,8 @@ function readReferences(configPath) {
|
|
|
15771
15880
|
const cwd = path33.dirname(configPath);
|
|
15772
15881
|
return parsed.references.map((ref) => {
|
|
15773
15882
|
const refPath = path33.resolve(cwd, ref.path);
|
|
15774
|
-
return
|
|
15775
|
-
}).filter((p) =>
|
|
15883
|
+
return fs23.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ? path33.join(refPath, "tsconfig.json") : refPath;
|
|
15884
|
+
}).filter((p) => fs23.existsSync(p));
|
|
15776
15885
|
}
|
|
15777
15886
|
function projectIncludes(configPath, sourcePath) {
|
|
15778
15887
|
try {
|
|
@@ -15822,25 +15931,25 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
15822
15931
|
}
|
|
15823
15932
|
|
|
15824
15933
|
// src/commands/refactor/ignore.ts
|
|
15825
|
-
import
|
|
15934
|
+
import fs24 from "fs";
|
|
15826
15935
|
import chalk157 from "chalk";
|
|
15827
15936
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
15828
15937
|
function ignore(file) {
|
|
15829
|
-
if (!
|
|
15938
|
+
if (!fs24.existsSync(file)) {
|
|
15830
15939
|
console.error(chalk157.red(`Error: File does not exist: ${file}`));
|
|
15831
15940
|
process.exit(1);
|
|
15832
15941
|
}
|
|
15833
|
-
const content =
|
|
15942
|
+
const content = fs24.readFileSync(file, "utf8");
|
|
15834
15943
|
const lineCount = content.split("\n").length;
|
|
15835
15944
|
const maxLines = lineCount + 10;
|
|
15836
15945
|
const entry = `- file: ${file}
|
|
15837
15946
|
maxLines: ${maxLines}
|
|
15838
15947
|
`;
|
|
15839
|
-
if (
|
|
15840
|
-
const existing =
|
|
15841
|
-
|
|
15948
|
+
if (fs24.existsSync(REFACTOR_YML_PATH2)) {
|
|
15949
|
+
const existing = fs24.readFileSync(REFACTOR_YML_PATH2, "utf8");
|
|
15950
|
+
fs24.writeFileSync(REFACTOR_YML_PATH2, existing + entry);
|
|
15842
15951
|
} else {
|
|
15843
|
-
|
|
15952
|
+
fs24.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
15844
15953
|
}
|
|
15845
15954
|
console.log(
|
|
15846
15955
|
chalk157.green(
|
|
@@ -15850,12 +15959,12 @@ function ignore(file) {
|
|
|
15850
15959
|
}
|
|
15851
15960
|
|
|
15852
15961
|
// src/commands/refactor/rename/index.ts
|
|
15853
|
-
import
|
|
15962
|
+
import fs27 from "fs";
|
|
15854
15963
|
import path40 from "path";
|
|
15855
15964
|
import chalk160 from "chalk";
|
|
15856
15965
|
|
|
15857
15966
|
// src/commands/refactor/rename/applyRename.ts
|
|
15858
|
-
import
|
|
15967
|
+
import fs26 from "fs";
|
|
15859
15968
|
import path37 from "path";
|
|
15860
15969
|
import chalk158 from "chalk";
|
|
15861
15970
|
|
|
@@ -15863,7 +15972,7 @@ import chalk158 from "chalk";
|
|
|
15863
15972
|
import path36 from "path";
|
|
15864
15973
|
|
|
15865
15974
|
// src/commands/refactor/restructure/computeRewrites/applyRewrites.ts
|
|
15866
|
-
import
|
|
15975
|
+
import fs25 from "fs";
|
|
15867
15976
|
function getOrCreateList(map, key) {
|
|
15868
15977
|
const list5 = map.get(key) ?? [];
|
|
15869
15978
|
if (!map.has(key)) map.set(key, list5);
|
|
@@ -15882,7 +15991,7 @@ function rewriteSpecifier(content, oldSpecifier, newSpecifier) {
|
|
|
15882
15991
|
return content.replace(pattern2, `$1${newSpecifier}$2`);
|
|
15883
15992
|
}
|
|
15884
15993
|
function applyFileRewrites(file, fileRewrites) {
|
|
15885
|
-
let content =
|
|
15994
|
+
let content = fs25.readFileSync(file, "utf8");
|
|
15886
15995
|
for (const { oldSpecifier, newSpecifier } of fileRewrites) {
|
|
15887
15996
|
content = rewriteSpecifier(content, oldSpecifier, newSpecifier);
|
|
15888
15997
|
}
|
|
@@ -15961,12 +16070,12 @@ function computeRewrites(moves, edges, allProjectFiles) {
|
|
|
15961
16070
|
function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
15962
16071
|
const updatedContents = applyRewrites(rewrites);
|
|
15963
16072
|
for (const [file, content] of updatedContents) {
|
|
15964
|
-
|
|
16073
|
+
fs26.writeFileSync(file, content, "utf8");
|
|
15965
16074
|
console.log(chalk158.cyan(` Updated imports in ${path37.relative(cwd, file)}`));
|
|
15966
16075
|
}
|
|
15967
16076
|
const destDir = path37.dirname(destPath);
|
|
15968
|
-
if (!
|
|
15969
|
-
|
|
16077
|
+
if (!fs26.existsSync(destDir)) fs26.mkdirSync(destDir, { recursive: true });
|
|
16078
|
+
fs26.renameSync(sourcePath, destPath);
|
|
15970
16079
|
console.log(
|
|
15971
16080
|
chalk158.white(
|
|
15972
16081
|
` Moved ${path37.relative(cwd, sourcePath)} \u2192 ${path37.relative(cwd, destPath)}`
|
|
@@ -16074,11 +16183,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
16074
16183
|
const cwd = process.cwd();
|
|
16075
16184
|
const relSource = path40.relative(cwd, sourcePath);
|
|
16076
16185
|
const relDest = path40.relative(cwd, destPath);
|
|
16077
|
-
if (!
|
|
16186
|
+
if (!fs27.existsSync(sourcePath)) {
|
|
16078
16187
|
console.log(chalk160.red(`File not found: ${source}`));
|
|
16079
16188
|
process.exit(1);
|
|
16080
16189
|
}
|
|
16081
|
-
if (destPath !== sourcePath &&
|
|
16190
|
+
if (destPath !== sourcePath && fs27.existsSync(destPath)) {
|
|
16082
16191
|
console.log(chalk160.red(`Destination already exists: ${destination}`));
|
|
16083
16192
|
process.exit(1);
|
|
16084
16193
|
}
|
|
@@ -16303,27 +16412,27 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
16303
16412
|
}
|
|
16304
16413
|
|
|
16305
16414
|
// src/commands/refactor/restructure/executePlan.ts
|
|
16306
|
-
import
|
|
16415
|
+
import fs28 from "fs";
|
|
16307
16416
|
import path45 from "path";
|
|
16308
16417
|
import chalk163 from "chalk";
|
|
16309
16418
|
function executePlan(plan2) {
|
|
16310
16419
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
16311
16420
|
for (const [file, content] of updatedContents) {
|
|
16312
|
-
|
|
16421
|
+
fs28.writeFileSync(file, content, "utf8");
|
|
16313
16422
|
console.log(
|
|
16314
16423
|
chalk163.cyan(` Rewrote imports in ${path45.relative(process.cwd(), file)}`)
|
|
16315
16424
|
);
|
|
16316
16425
|
}
|
|
16317
16426
|
for (const dir of plan2.newDirectories) {
|
|
16318
|
-
|
|
16427
|
+
fs28.mkdirSync(dir, { recursive: true });
|
|
16319
16428
|
console.log(chalk163.green(` Created ${path45.relative(process.cwd(), dir)}/`));
|
|
16320
16429
|
}
|
|
16321
16430
|
for (const move2 of plan2.moves) {
|
|
16322
16431
|
const targetDir = path45.dirname(move2.to);
|
|
16323
|
-
if (!
|
|
16324
|
-
|
|
16432
|
+
if (!fs28.existsSync(targetDir)) {
|
|
16433
|
+
fs28.mkdirSync(targetDir, { recursive: true });
|
|
16325
16434
|
}
|
|
16326
|
-
|
|
16435
|
+
fs28.renameSync(move2.from, move2.to);
|
|
16327
16436
|
console.log(
|
|
16328
16437
|
chalk163.white(
|
|
16329
16438
|
` Moved ${path45.relative(process.cwd(), move2.from)} \u2192 ${path45.relative(process.cwd(), move2.to)}`
|
|
@@ -16335,10 +16444,10 @@ function executePlan(plan2) {
|
|
|
16335
16444
|
function removeEmptyDirectories(dirs) {
|
|
16336
16445
|
const unique = [...new Set(dirs)];
|
|
16337
16446
|
for (const dir of unique) {
|
|
16338
|
-
if (!
|
|
16339
|
-
const entries =
|
|
16447
|
+
if (!fs28.existsSync(dir)) continue;
|
|
16448
|
+
const entries = fs28.readdirSync(dir);
|
|
16340
16449
|
if (entries.length === 0) {
|
|
16341
|
-
|
|
16450
|
+
fs28.rmdirSync(dir);
|
|
16342
16451
|
console.log(
|
|
16343
16452
|
chalk163.dim(
|
|
16344
16453
|
` Removed empty directory ${path45.relative(process.cwd(), dir)}`
|
|
@@ -16352,18 +16461,18 @@ function removeEmptyDirectories(dirs) {
|
|
|
16352
16461
|
import path47 from "path";
|
|
16353
16462
|
|
|
16354
16463
|
// src/commands/refactor/restructure/planFileMoves/shared.ts
|
|
16355
|
-
import
|
|
16464
|
+
import fs29 from "fs";
|
|
16356
16465
|
function emptyResult() {
|
|
16357
16466
|
return { moves: [], directories: [], warnings: [] };
|
|
16358
16467
|
}
|
|
16359
16468
|
function checkDirConflict(result, label2, dir) {
|
|
16360
|
-
if (!
|
|
16469
|
+
if (!fs29.existsSync(dir)) return false;
|
|
16361
16470
|
result.warnings.push(`Skipping ${label2}: directory ${dir} already exists`);
|
|
16362
16471
|
return true;
|
|
16363
16472
|
}
|
|
16364
16473
|
|
|
16365
16474
|
// src/commands/refactor/restructure/planFileMoves/planDirectoryMoves.ts
|
|
16366
|
-
import
|
|
16475
|
+
import fs30 from "fs";
|
|
16367
16476
|
import path46 from "path";
|
|
16368
16477
|
function collectEntry(results, dir, entry) {
|
|
16369
16478
|
const full = path46.join(dir, entry.name);
|
|
@@ -16371,9 +16480,9 @@ function collectEntry(results, dir, entry) {
|
|
|
16371
16480
|
results.push(...items2);
|
|
16372
16481
|
}
|
|
16373
16482
|
function listFilesRecursive(dir) {
|
|
16374
|
-
if (!
|
|
16483
|
+
if (!fs30.existsSync(dir)) return [];
|
|
16375
16484
|
const results = [];
|
|
16376
|
-
for (const entry of
|
|
16485
|
+
for (const entry of fs30.readdirSync(dir, { withFileTypes: true })) {
|
|
16377
16486
|
collectEntry(results, dir, entry);
|
|
16378
16487
|
}
|
|
16379
16488
|
return results;
|
|
@@ -16801,7 +16910,7 @@ function gatherContext() {
|
|
|
16801
16910
|
}
|
|
16802
16911
|
|
|
16803
16912
|
// src/commands/review/postReviewToPr.ts
|
|
16804
|
-
import { readFileSync as
|
|
16913
|
+
import { readFileSync as readFileSync36 } from "fs";
|
|
16805
16914
|
|
|
16806
16915
|
// src/commands/review/parseFindings.ts
|
|
16807
16916
|
var SEVERITIES = ["blocker", "major", "minor", "nit"];
|
|
@@ -17116,7 +17225,7 @@ async function confirmPost(prNumber, count7, options2) {
|
|
|
17116
17225
|
async function postReviewToPr(synthesisPath, options2) {
|
|
17117
17226
|
const prInfo = fetchPrDiffInfo();
|
|
17118
17227
|
const prNumber = prInfo.prNumber;
|
|
17119
|
-
const markdown =
|
|
17228
|
+
const markdown = readFileSync36(synthesisPath, "utf8");
|
|
17120
17229
|
const findings = parseFindings(markdown);
|
|
17121
17230
|
if (findings.length === 0) {
|
|
17122
17231
|
console.log("Synthesis contains no findings; nothing to post.");
|
|
@@ -17198,10 +17307,10 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
17198
17307
|
}
|
|
17199
17308
|
|
|
17200
17309
|
// src/commands/review/prepareReviewDir.ts
|
|
17201
|
-
import { existsSync as
|
|
17310
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync16, unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
17202
17311
|
function clearReviewFiles(paths) {
|
|
17203
17312
|
for (const path57 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
17204
|
-
if (
|
|
17313
|
+
if (existsSync40(path57)) unlinkSync14(path57);
|
|
17205
17314
|
}
|
|
17206
17315
|
}
|
|
17207
17316
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -17486,7 +17595,7 @@ function printReviewerFailures(results) {
|
|
|
17486
17595
|
}
|
|
17487
17596
|
|
|
17488
17597
|
// src/commands/review/runAndSynthesise.ts
|
|
17489
|
-
import { existsSync as
|
|
17598
|
+
import { existsSync as existsSync42, unlinkSync as unlinkSync16 } from "fs";
|
|
17490
17599
|
|
|
17491
17600
|
// src/commands/review/buildReviewerStdin.ts
|
|
17492
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.
|
|
@@ -17906,7 +18015,7 @@ function resolveClaude(args) {
|
|
|
17906
18015
|
}
|
|
17907
18016
|
|
|
17908
18017
|
// src/commands/review/runCodexReviewer.ts
|
|
17909
|
-
import { existsSync as
|
|
18018
|
+
import { existsSync as existsSync41, unlinkSync as unlinkSync15 } from "fs";
|
|
17910
18019
|
|
|
17911
18020
|
// src/commands/review/parseCodexEvent.ts
|
|
17912
18021
|
function isItemStarted(value) {
|
|
@@ -17958,7 +18067,7 @@ async function runCodexReviewer(spec) {
|
|
|
17958
18067
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
17959
18068
|
}
|
|
17960
18069
|
});
|
|
17961
|
-
if (result.exitCode !== 0 &&
|
|
18070
|
+
if (result.exitCode !== 0 && existsSync41(spec.outputPath)) {
|
|
17962
18071
|
unlinkSync15(spec.outputPath);
|
|
17963
18072
|
}
|
|
17964
18073
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -18000,7 +18109,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
18000
18109
|
}
|
|
18001
18110
|
|
|
18002
18111
|
// src/commands/review/synthesise.ts
|
|
18003
|
-
import { readFileSync as
|
|
18112
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
18004
18113
|
|
|
18005
18114
|
// src/commands/review/buildSynthesisStdin.ts
|
|
18006
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.
|
|
@@ -18056,7 +18165,7 @@ Files:
|
|
|
18056
18165
|
|
|
18057
18166
|
// src/commands/review/synthesise.ts
|
|
18058
18167
|
function printSummary2(synthesisPath) {
|
|
18059
|
-
const markdown =
|
|
18168
|
+
const markdown = readFileSync37(synthesisPath, "utf8");
|
|
18060
18169
|
console.log("");
|
|
18061
18170
|
console.log(buildReviewSummary(markdown));
|
|
18062
18171
|
console.log("");
|
|
@@ -18104,7 +18213,7 @@ async function runAndSynthesise(args) {
|
|
|
18104
18213
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
18105
18214
|
return { ok: false, failures };
|
|
18106
18215
|
}
|
|
18107
|
-
if (anyFresh &&
|
|
18216
|
+
if (anyFresh && existsSync42(paths.synthesisPath)) {
|
|
18108
18217
|
unlinkSync16(paths.synthesisPath);
|
|
18109
18218
|
}
|
|
18110
18219
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -18954,11 +19063,11 @@ async function configure() {
|
|
|
18954
19063
|
}
|
|
18955
19064
|
|
|
18956
19065
|
// src/commands/transcript/list.ts
|
|
18957
|
-
import { existsSync as
|
|
19066
|
+
import { existsSync as existsSync43, readdirSync as readdirSync9, statSync as statSync7 } from "fs";
|
|
18958
19067
|
import { join as join50 } from "path";
|
|
18959
19068
|
function list4() {
|
|
18960
19069
|
const { vttDir } = getTranscriptConfig();
|
|
18961
|
-
if (!
|
|
19070
|
+
if (!existsSync43(vttDir)) return;
|
|
18962
19071
|
for (const entry of readdirSync9(vttDir)) {
|
|
18963
19072
|
if (!entry.endsWith(".vtt")) continue;
|
|
18964
19073
|
if (statSync7(join50(vttDir, entry)).isDirectory()) continue;
|
|
@@ -18968,9 +19077,9 @@ function list4() {
|
|
|
18968
19077
|
|
|
18969
19078
|
// src/commands/transcript/move.ts
|
|
18970
19079
|
import {
|
|
18971
|
-
existsSync as
|
|
19080
|
+
existsSync as existsSync44,
|
|
18972
19081
|
mkdirSync as mkdirSync17,
|
|
18973
|
-
readFileSync as
|
|
19082
|
+
readFileSync as readFileSync38,
|
|
18974
19083
|
renameSync as renameSync2,
|
|
18975
19084
|
writeFileSync as writeFileSync35
|
|
18976
19085
|
} from "fs";
|
|
@@ -19182,7 +19291,7 @@ function formatChatLog(messages) {
|
|
|
19182
19291
|
// src/commands/transcript/move.ts
|
|
19183
19292
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
19184
19293
|
function convertVttToMarkdown(inputPath) {
|
|
19185
|
-
const cues = parseVtt(
|
|
19294
|
+
const cues = parseVtt(readFileSync38(inputPath, "utf8"));
|
|
19186
19295
|
const messages = cuesToChatMessages(deduplicateCues(cues));
|
|
19187
19296
|
return formatChatLog(messages);
|
|
19188
19297
|
}
|
|
@@ -19200,7 +19309,7 @@ function move(file, options2) {
|
|
|
19200
19309
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
19201
19310
|
const filename = basename10(file);
|
|
19202
19311
|
const sourcePath = join51(vttDir, filename);
|
|
19203
|
-
if (!
|
|
19312
|
+
if (!existsSync44(sourcePath)) {
|
|
19204
19313
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
19205
19314
|
process.exit(1);
|
|
19206
19315
|
}
|
|
@@ -19295,14 +19404,14 @@ function devices() {
|
|
|
19295
19404
|
}
|
|
19296
19405
|
|
|
19297
19406
|
// src/commands/voice/logs.ts
|
|
19298
|
-
import { existsSync as
|
|
19407
|
+
import { existsSync as existsSync45, readFileSync as readFileSync39 } from "fs";
|
|
19299
19408
|
function logs(options2) {
|
|
19300
|
-
if (!
|
|
19409
|
+
if (!existsSync45(voicePaths.log)) {
|
|
19301
19410
|
console.log("No voice log file found");
|
|
19302
19411
|
return;
|
|
19303
19412
|
}
|
|
19304
19413
|
const count7 = Number.parseInt(options2.lines ?? "150", 10);
|
|
19305
|
-
const content =
|
|
19414
|
+
const content = readFileSync39(voicePaths.log, "utf8").trim();
|
|
19306
19415
|
if (!content) {
|
|
19307
19416
|
console.log("Voice log is empty");
|
|
19308
19417
|
return;
|
|
@@ -19329,7 +19438,7 @@ import { join as join55 } from "path";
|
|
|
19329
19438
|
|
|
19330
19439
|
// src/commands/voice/checkLockFile.ts
|
|
19331
19440
|
import { execSync as execSync48 } from "child_process";
|
|
19332
|
-
import { existsSync as
|
|
19441
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync18, readFileSync as readFileSync40, writeFileSync as writeFileSync36 } from "fs";
|
|
19333
19442
|
import { join as join54 } from "path";
|
|
19334
19443
|
function isProcessAlive2(pid) {
|
|
19335
19444
|
try {
|
|
@@ -19341,9 +19450,9 @@ function isProcessAlive2(pid) {
|
|
|
19341
19450
|
}
|
|
19342
19451
|
function checkLockFile() {
|
|
19343
19452
|
const lockFile = getLockFile();
|
|
19344
|
-
if (!
|
|
19453
|
+
if (!existsSync46(lockFile)) return;
|
|
19345
19454
|
try {
|
|
19346
|
-
const lock2 = JSON.parse(
|
|
19455
|
+
const lock2 = JSON.parse(readFileSync40(lockFile, "utf8"));
|
|
19347
19456
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
19348
19457
|
console.error(
|
|
19349
19458
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -19354,7 +19463,7 @@ function checkLockFile() {
|
|
|
19354
19463
|
}
|
|
19355
19464
|
}
|
|
19356
19465
|
function bootstrapVenv() {
|
|
19357
|
-
if (
|
|
19466
|
+
if (existsSync46(getVenvPython())) return;
|
|
19358
19467
|
console.log("Setting up Python environment...");
|
|
19359
19468
|
const pythonDir = getPythonDir();
|
|
19360
19469
|
execSync48(
|
|
@@ -19445,7 +19554,7 @@ function start2(options2) {
|
|
|
19445
19554
|
}
|
|
19446
19555
|
|
|
19447
19556
|
// src/commands/voice/status.ts
|
|
19448
|
-
import { existsSync as
|
|
19557
|
+
import { existsSync as existsSync47, readFileSync as readFileSync41 } from "fs";
|
|
19449
19558
|
function isProcessAlive3(pid) {
|
|
19450
19559
|
try {
|
|
19451
19560
|
process.kill(pid, 0);
|
|
@@ -19455,16 +19564,16 @@ function isProcessAlive3(pid) {
|
|
|
19455
19564
|
}
|
|
19456
19565
|
}
|
|
19457
19566
|
function readRecentLogs(count7) {
|
|
19458
|
-
if (!
|
|
19459
|
-
const lines =
|
|
19567
|
+
if (!existsSync47(voicePaths.log)) return [];
|
|
19568
|
+
const lines = readFileSync41(voicePaths.log, "utf8").trim().split("\n");
|
|
19460
19569
|
return lines.slice(-count7);
|
|
19461
19570
|
}
|
|
19462
19571
|
function status() {
|
|
19463
|
-
if (!
|
|
19572
|
+
if (!existsSync47(voicePaths.pid)) {
|
|
19464
19573
|
console.log("Voice daemon: not running (no PID file)");
|
|
19465
19574
|
return;
|
|
19466
19575
|
}
|
|
19467
|
-
const pid = Number.parseInt(
|
|
19576
|
+
const pid = Number.parseInt(readFileSync41(voicePaths.pid, "utf8").trim(), 10);
|
|
19468
19577
|
const alive = isProcessAlive3(pid);
|
|
19469
19578
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
19470
19579
|
const recent = readRecentLogs(5);
|
|
@@ -19483,13 +19592,13 @@ function status() {
|
|
|
19483
19592
|
}
|
|
19484
19593
|
|
|
19485
19594
|
// src/commands/voice/stop.ts
|
|
19486
|
-
import { existsSync as
|
|
19595
|
+
import { existsSync as existsSync48, readFileSync as readFileSync42, unlinkSync as unlinkSync17 } from "fs";
|
|
19487
19596
|
function stop2() {
|
|
19488
|
-
if (!
|
|
19597
|
+
if (!existsSync48(voicePaths.pid)) {
|
|
19489
19598
|
console.log("Voice daemon is not running (no PID file)");
|
|
19490
19599
|
return;
|
|
19491
19600
|
}
|
|
19492
|
-
const pid = Number.parseInt(
|
|
19601
|
+
const pid = Number.parseInt(readFileSync42(voicePaths.pid, "utf8").trim(), 10);
|
|
19493
19602
|
try {
|
|
19494
19603
|
process.kill(pid, "SIGTERM");
|
|
19495
19604
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -19502,7 +19611,7 @@ function stop2() {
|
|
|
19502
19611
|
}
|
|
19503
19612
|
try {
|
|
19504
19613
|
const lockFile = getLockFile();
|
|
19505
|
-
if (
|
|
19614
|
+
if (existsSync48(lockFile)) unlinkSync17(lockFile);
|
|
19506
19615
|
} catch {
|
|
19507
19616
|
}
|
|
19508
19617
|
console.log("Voice daemon stopped");
|
|
@@ -19680,7 +19789,7 @@ async function auth() {
|
|
|
19680
19789
|
|
|
19681
19790
|
// src/commands/roam/postRoamActivity.ts
|
|
19682
19791
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
19683
|
-
import { readdirSync as readdirSync10, readFileSync as
|
|
19792
|
+
import { readdirSync as readdirSync10, readFileSync as readFileSync43, statSync as statSync8 } from "fs";
|
|
19684
19793
|
import { join as join57 } from "path";
|
|
19685
19794
|
function findPortFile(roamDir) {
|
|
19686
19795
|
let entries;
|
|
@@ -19706,7 +19815,7 @@ function postRoamActivity(app, event) {
|
|
|
19706
19815
|
if (!portFile) return;
|
|
19707
19816
|
let port;
|
|
19708
19817
|
try {
|
|
19709
|
-
port =
|
|
19818
|
+
port = readFileSync43(portFile, "utf8").trim();
|
|
19710
19819
|
} catch {
|
|
19711
19820
|
return;
|
|
19712
19821
|
}
|
|
@@ -19848,7 +19957,7 @@ function runPreCommands(pre, cwd) {
|
|
|
19848
19957
|
|
|
19849
19958
|
// src/commands/run/spawnRunCommand.ts
|
|
19850
19959
|
import { execFileSync as execFileSync8, spawn as spawn8 } from "child_process";
|
|
19851
|
-
import { existsSync as
|
|
19960
|
+
import { existsSync as existsSync49 } from "fs";
|
|
19852
19961
|
import { dirname as dirname25, join as join58, resolve as resolve13 } from "path";
|
|
19853
19962
|
function resolveCommand2(command) {
|
|
19854
19963
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
@@ -19856,7 +19965,7 @@ function resolveCommand2(command) {
|
|
|
19856
19965
|
const gitPath = execFileSync8("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
19857
19966
|
const gitRoot = resolve13(dirname25(gitPath), "..");
|
|
19858
19967
|
const gitBash = join58(gitRoot, "bin", "bash.exe");
|
|
19859
|
-
if (
|
|
19968
|
+
if (existsSync49(gitBash)) return gitBash;
|
|
19860
19969
|
} catch {
|
|
19861
19970
|
}
|
|
19862
19971
|
return command;
|
|
@@ -20067,7 +20176,7 @@ function link2() {
|
|
|
20067
20176
|
}
|
|
20068
20177
|
|
|
20069
20178
|
// src/commands/run/remove.ts
|
|
20070
|
-
import { existsSync as
|
|
20179
|
+
import { existsSync as existsSync50, unlinkSync as unlinkSync18 } from "fs";
|
|
20071
20180
|
import { join as join60 } from "path";
|
|
20072
20181
|
function findRemoveIndex() {
|
|
20073
20182
|
const idx = process.argv.indexOf("remove");
|
|
@@ -20084,7 +20193,7 @@ function parseRemoveName() {
|
|
|
20084
20193
|
}
|
|
20085
20194
|
function deleteCommandFile(name) {
|
|
20086
20195
|
const filePath = join60(".claude", "commands", `${name}.md`);
|
|
20087
|
-
if (
|
|
20196
|
+
if (existsSync50(filePath)) {
|
|
20088
20197
|
unlinkSync18(filePath);
|
|
20089
20198
|
console.log(`Deleted command file: ${filePath}`);
|
|
20090
20199
|
}
|
|
@@ -20123,7 +20232,7 @@ function registerRun(program2) {
|
|
|
20123
20232
|
|
|
20124
20233
|
// src/commands/screenshot/index.ts
|
|
20125
20234
|
import { execSync as execSync50 } from "child_process";
|
|
20126
|
-
import { existsSync as
|
|
20235
|
+
import { existsSync as existsSync51, mkdirSync as mkdirSync22, unlinkSync as unlinkSync19, writeFileSync as writeFileSync39 } from "fs";
|
|
20127
20236
|
import { tmpdir as tmpdir7 } from "os";
|
|
20128
20237
|
import { join as join61, resolve as resolve15 } from "path";
|
|
20129
20238
|
import chalk180 from "chalk";
|
|
@@ -20255,7 +20364,7 @@ Write-Output $OutputPath
|
|
|
20255
20364
|
|
|
20256
20365
|
// src/commands/screenshot/index.ts
|
|
20257
20366
|
function buildOutputPath(outputDir, processName) {
|
|
20258
|
-
if (!
|
|
20367
|
+
if (!existsSync51(outputDir)) {
|
|
20259
20368
|
mkdirSync22(outputDir, { recursive: true });
|
|
20260
20369
|
}
|
|
20261
20370
|
const timestamp4 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -20339,7 +20448,7 @@ function applyLine(result, pending, line) {
|
|
|
20339
20448
|
}
|
|
20340
20449
|
|
|
20341
20450
|
// src/commands/sessions/daemon/reportStolenSocket.ts
|
|
20342
|
-
import { readFileSync as
|
|
20451
|
+
import { readFileSync as readFileSync44 } from "fs";
|
|
20343
20452
|
function reportStolenSocket(socketPid) {
|
|
20344
20453
|
if (!socketPid) return;
|
|
20345
20454
|
const filePid = readPidFile();
|
|
@@ -20351,7 +20460,7 @@ function reportStolenSocket(socketPid) {
|
|
|
20351
20460
|
function readPidFile() {
|
|
20352
20461
|
try {
|
|
20353
20462
|
const pid = Number.parseInt(
|
|
20354
|
-
|
|
20463
|
+
readFileSync44(daemonPaths.pid, "utf8").trim(),
|
|
20355
20464
|
10
|
|
20356
20465
|
);
|
|
20357
20466
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -20705,7 +20814,7 @@ var ClientHub = class extends Set {
|
|
|
20705
20814
|
import * as pty from "node-pty";
|
|
20706
20815
|
|
|
20707
20816
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
20708
|
-
import { chmodSync, existsSync as
|
|
20817
|
+
import { chmodSync, existsSync as existsSync52, statSync as statSync9 } from "fs";
|
|
20709
20818
|
import { createRequire as createRequire3 } from "module";
|
|
20710
20819
|
import path49 from "path";
|
|
20711
20820
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -20720,7 +20829,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
20720
20829
|
`${process.platform}-${process.arch}`,
|
|
20721
20830
|
"spawn-helper"
|
|
20722
20831
|
);
|
|
20723
|
-
if (!
|
|
20832
|
+
if (!existsSync52(helper)) return;
|
|
20724
20833
|
const mode = statSync9(helper).mode;
|
|
20725
20834
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
20726
20835
|
}
|
|
@@ -21255,7 +21364,7 @@ function resumeSession(id2, sessionId, cwd, name) {
|
|
|
21255
21364
|
}
|
|
21256
21365
|
|
|
21257
21366
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
21258
|
-
import { existsSync as
|
|
21367
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync23, watch } from "fs";
|
|
21259
21368
|
import { dirname as dirname26 } from "path";
|
|
21260
21369
|
|
|
21261
21370
|
// src/commands/sessions/daemon/applyReviewPause.ts
|
|
@@ -21334,7 +21443,7 @@ function watchActivity(session, notify2) {
|
|
|
21334
21443
|
if (timer) clearTimeout(timer);
|
|
21335
21444
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
21336
21445
|
});
|
|
21337
|
-
if (
|
|
21446
|
+
if (existsSync53(path57)) read();
|
|
21338
21447
|
}
|
|
21339
21448
|
function refreshActivity(session) {
|
|
21340
21449
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -22213,12 +22322,12 @@ import * as net3 from "net";
|
|
|
22213
22322
|
import { createInterface as createInterface9 } from "readline";
|
|
22214
22323
|
|
|
22215
22324
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
22216
|
-
import * as
|
|
22325
|
+
import * as fs32 from "fs";
|
|
22217
22326
|
import * as os from "os";
|
|
22218
22327
|
import * as path51 from "path";
|
|
22219
22328
|
|
|
22220
22329
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
22221
|
-
import * as
|
|
22330
|
+
import * as fs31 from "fs";
|
|
22222
22331
|
import * as path50 from "path";
|
|
22223
22332
|
|
|
22224
22333
|
// src/commands/sessions/shared/deriveHistoryFields.ts
|
|
@@ -22316,10 +22425,10 @@ function matchMarker(text7, tag) {
|
|
|
22316
22425
|
async function parseSessionFile(filePath, origin = "wsl") {
|
|
22317
22426
|
let handle;
|
|
22318
22427
|
try {
|
|
22319
|
-
handle = await
|
|
22428
|
+
handle = await fs31.promises.open(filePath, "r");
|
|
22320
22429
|
const meta = extractSessionMeta(await readHeadLines(handle));
|
|
22321
22430
|
if (!meta.sessionId) return null;
|
|
22322
|
-
const timestamp4 = meta.timestamp || (await
|
|
22431
|
+
const timestamp4 = meta.timestamp || (await fs31.promises.stat(filePath)).mtime.toISOString();
|
|
22323
22432
|
return {
|
|
22324
22433
|
sessionId: meta.sessionId,
|
|
22325
22434
|
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
@@ -22365,7 +22474,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
22365
22474
|
sessionRoots().map(async ({ dir, origin }) => {
|
|
22366
22475
|
let projectDirs;
|
|
22367
22476
|
try {
|
|
22368
|
-
projectDirs = await
|
|
22477
|
+
projectDirs = await fs32.promises.readdir(dir);
|
|
22369
22478
|
} catch {
|
|
22370
22479
|
return;
|
|
22371
22480
|
}
|
|
@@ -22374,7 +22483,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
22374
22483
|
const dirPath = path51.join(dir, dirName);
|
|
22375
22484
|
let entries;
|
|
22376
22485
|
try {
|
|
22377
|
-
entries = await
|
|
22486
|
+
entries = await fs32.promises.readdir(dirPath);
|
|
22378
22487
|
} catch {
|
|
22379
22488
|
return;
|
|
22380
22489
|
}
|
|
@@ -22407,7 +22516,7 @@ async function discoverSessions() {
|
|
|
22407
22516
|
}
|
|
22408
22517
|
|
|
22409
22518
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
22410
|
-
import * as
|
|
22519
|
+
import * as fs33 from "fs";
|
|
22411
22520
|
|
|
22412
22521
|
// src/commands/sessions/shared/toolTarget.ts
|
|
22413
22522
|
function toolTarget(input) {
|
|
@@ -22474,7 +22583,7 @@ async function parseTranscript(sessionId) {
|
|
|
22474
22583
|
const filePath = await findSessionJsonlPath(sessionId);
|
|
22475
22584
|
if (!filePath) return [];
|
|
22476
22585
|
try {
|
|
22477
|
-
const raw = await
|
|
22586
|
+
const raw = await fs33.promises.readFile(filePath, "utf8");
|
|
22478
22587
|
return parseTranscriptLines(raw.split("\n"));
|
|
22479
22588
|
} catch {
|
|
22480
22589
|
return [];
|
|
@@ -22641,7 +22750,7 @@ function handleConnection(socket, manager) {
|
|
|
22641
22750
|
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync40 } from "fs";
|
|
22642
22751
|
|
|
22643
22752
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
22644
|
-
import { readFileSync as
|
|
22753
|
+
import { readFileSync as readFileSync45 } from "fs";
|
|
22645
22754
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
22646
22755
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
22647
22756
|
const timer = setInterval(() => {
|
|
@@ -22652,7 +22761,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
22652
22761
|
}
|
|
22653
22762
|
function ownsPidFile() {
|
|
22654
22763
|
try {
|
|
22655
|
-
return
|
|
22764
|
+
return readFileSync45(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
22656
22765
|
} catch {
|
|
22657
22766
|
return false;
|
|
22658
22767
|
}
|
|
@@ -22779,17 +22888,17 @@ function registerDaemon(program2) {
|
|
|
22779
22888
|
}
|
|
22780
22889
|
|
|
22781
22890
|
// src/commands/sessions/summarise/index.ts
|
|
22782
|
-
import * as
|
|
22891
|
+
import * as fs36 from "fs";
|
|
22783
22892
|
import chalk181 from "chalk";
|
|
22784
22893
|
|
|
22785
22894
|
// src/commands/sessions/summarise/shared.ts
|
|
22786
|
-
import * as
|
|
22895
|
+
import * as fs34 from "fs";
|
|
22787
22896
|
function writeSummary(jsonlPath2, summary) {
|
|
22788
|
-
|
|
22897
|
+
fs34.writeFileSync(summaryPathFor(jsonlPath2), `${summary.trim()}
|
|
22789
22898
|
`, "utf8");
|
|
22790
22899
|
}
|
|
22791
22900
|
function hasSummary(jsonlPath2) {
|
|
22792
|
-
return
|
|
22901
|
+
return fs34.existsSync(summaryPathFor(jsonlPath2));
|
|
22793
22902
|
}
|
|
22794
22903
|
function summaryPathFor(jsonlPath2) {
|
|
22795
22904
|
return jsonlPath2.replace(/\.jsonl$/, ".summary");
|
|
@@ -22799,7 +22908,7 @@ function summaryPathFor(jsonlPath2) {
|
|
|
22799
22908
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
22800
22909
|
|
|
22801
22910
|
// src/commands/sessions/summarise/iterateUserMessages.ts
|
|
22802
|
-
import * as
|
|
22911
|
+
import * as fs35 from "fs";
|
|
22803
22912
|
|
|
22804
22913
|
// src/commands/sessions/summarise/parseUserLine.ts
|
|
22805
22914
|
function parseUserLine(line) {
|
|
@@ -22830,13 +22939,13 @@ function parseUserLine(line) {
|
|
|
22830
22939
|
function* iterateUserMessages(filePath, maxBytes = 65536) {
|
|
22831
22940
|
let content;
|
|
22832
22941
|
try {
|
|
22833
|
-
const fd =
|
|
22942
|
+
const fd = fs35.openSync(filePath, "r");
|
|
22834
22943
|
try {
|
|
22835
22944
|
const buf = Buffer.alloc(maxBytes);
|
|
22836
|
-
const bytesRead =
|
|
22945
|
+
const bytesRead = fs35.readSync(fd, buf, 0, buf.length, 0);
|
|
22837
22946
|
content = buf.toString("utf8", 0, bytesRead);
|
|
22838
22947
|
} finally {
|
|
22839
|
-
|
|
22948
|
+
fs35.closeSync(fd);
|
|
22840
22949
|
}
|
|
22841
22950
|
} catch {
|
|
22842
22951
|
return;
|
|
@@ -22956,7 +23065,7 @@ function selectCandidates(files, options2) {
|
|
|
22956
23065
|
const candidates = options2.force ? files : files.filter((f) => !hasSummary(f));
|
|
22957
23066
|
candidates.sort((a, b) => {
|
|
22958
23067
|
try {
|
|
22959
|
-
return
|
|
23068
|
+
return fs36.statSync(b).mtimeMs - fs36.statSync(a).mtimeMs;
|
|
22960
23069
|
} catch {
|
|
22961
23070
|
return 0;
|
|
22962
23071
|
}
|
|
@@ -23105,21 +23214,21 @@ async function statusLine() {
|
|
|
23105
23214
|
}
|
|
23106
23215
|
|
|
23107
23216
|
// src/commands/sync.ts
|
|
23108
|
-
import * as
|
|
23217
|
+
import * as fs39 from "fs";
|
|
23109
23218
|
import * as os2 from "os";
|
|
23110
23219
|
import * as path55 from "path";
|
|
23111
23220
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
23112
23221
|
|
|
23113
23222
|
// src/commands/sync/syncClaudeMd.ts
|
|
23114
|
-
import * as
|
|
23223
|
+
import * as fs37 from "fs";
|
|
23115
23224
|
import * as path53 from "path";
|
|
23116
23225
|
import chalk184 from "chalk";
|
|
23117
23226
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
23118
23227
|
const source = path53.join(claudeDir, "CLAUDE.md");
|
|
23119
23228
|
const target = path53.join(targetBase, "CLAUDE.md");
|
|
23120
|
-
const sourceContent =
|
|
23121
|
-
if (
|
|
23122
|
-
const targetContent =
|
|
23229
|
+
const sourceContent = fs37.readFileSync(source, "utf8");
|
|
23230
|
+
if (fs37.existsSync(target)) {
|
|
23231
|
+
const targetContent = fs37.readFileSync(target, "utf8");
|
|
23123
23232
|
if (sourceContent !== targetContent) {
|
|
23124
23233
|
console.log(
|
|
23125
23234
|
chalk184.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
@@ -23136,21 +23245,21 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
23136
23245
|
}
|
|
23137
23246
|
}
|
|
23138
23247
|
}
|
|
23139
|
-
|
|
23248
|
+
fs37.copyFileSync(source, target);
|
|
23140
23249
|
console.log("Copied CLAUDE.md to ~/.claude/CLAUDE.md");
|
|
23141
23250
|
}
|
|
23142
23251
|
|
|
23143
23252
|
// src/commands/sync/syncSettings.ts
|
|
23144
|
-
import * as
|
|
23253
|
+
import * as fs38 from "fs";
|
|
23145
23254
|
import * as path54 from "path";
|
|
23146
23255
|
import chalk185 from "chalk";
|
|
23147
23256
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
23148
23257
|
const source = path54.join(claudeDir, "settings.json");
|
|
23149
23258
|
const target = path54.join(targetBase, "settings.json");
|
|
23150
|
-
const sourceContent =
|
|
23259
|
+
const sourceContent = fs38.readFileSync(source, "utf8");
|
|
23151
23260
|
const mergedContent = JSON.stringify(JSON.parse(sourceContent), null, " ");
|
|
23152
|
-
if (
|
|
23153
|
-
const targetContent =
|
|
23261
|
+
if (fs38.existsSync(target)) {
|
|
23262
|
+
const targetContent = fs38.readFileSync(target, "utf8");
|
|
23154
23263
|
const normalizedTarget = JSON.stringify(
|
|
23155
23264
|
JSON.parse(targetContent),
|
|
23156
23265
|
null,
|
|
@@ -23176,7 +23285,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
23176
23285
|
}
|
|
23177
23286
|
}
|
|
23178
23287
|
}
|
|
23179
|
-
|
|
23288
|
+
fs38.writeFileSync(target, mergedContent);
|
|
23180
23289
|
console.log("Copied settings.json to ~/.claude/settings.json");
|
|
23181
23290
|
}
|
|
23182
23291
|
|
|
@@ -23195,10 +23304,10 @@ async function sync(options2) {
|
|
|
23195
23304
|
function syncCommands(claudeDir, targetBase) {
|
|
23196
23305
|
const sourceDir = path55.join(claudeDir, "commands");
|
|
23197
23306
|
const targetDir = path55.join(targetBase, "commands");
|
|
23198
|
-
|
|
23199
|
-
const files =
|
|
23307
|
+
fs39.mkdirSync(targetDir, { recursive: true });
|
|
23308
|
+
const files = fs39.readdirSync(sourceDir);
|
|
23200
23309
|
for (const file of files) {
|
|
23201
|
-
|
|
23310
|
+
fs39.copyFileSync(path55.join(sourceDir, file), path55.join(targetDir, file));
|
|
23202
23311
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
23203
23312
|
}
|
|
23204
23313
|
console.log(`Synced ${files.length} command(s) to ~/.claude/commands`);
|