sparkecoder 0.1.75 → 0.1.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.js +114 -43
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +186 -110
- package/dist/cli.js.map +1 -1
- package/dist/index.js +174 -98
- package/dist/index.js.map +1 -1
- package/dist/server/index.js +174 -98
- package/dist/server/index.js.map +1 -1
- package/dist/tools/index.js +105 -34
- package/dist/tools/index.js.map +1 -1
- package/package.json +2 -1
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/standalone/node_modules/.pnpm/sharp@0.34.5/node_modules/sharp/package.json +202 -0
- package/web/.next/standalone/web/.next/BUILD_ID +1 -1
- package/web/.next/standalone/web/.next/build-manifest.json +2 -2
- package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
- package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.html +2 -2
- package/web/.next/standalone/web/.next/server/app/docs.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.html +1 -1
- package/web/.next/standalone/web/.next/server/app/index.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
- package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
- package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
- /package/web/.next/standalone/web/.next/static/{static/xfMAecV1v1MVUkZE1r3BT → nZpzcWd5nqIPZFd3PiefU}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/xfMAecV1v1MVUkZE1r3BT → nZpzcWd5nqIPZFd3PiefU}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{static/xfMAecV1v1MVUkZE1r3BT → nZpzcWd5nqIPZFd3PiefU}/_ssgManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → static/nZpzcWd5nqIPZFd3PiefU}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → static/nZpzcWd5nqIPZFd3PiefU}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → static/nZpzcWd5nqIPZFd3PiefU}/_ssgManifest.js +0 -0
- /package/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → nZpzcWd5nqIPZFd3PiefU}/_buildManifest.js +0 -0
- /package/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → nZpzcWd5nqIPZFd3PiefU}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → nZpzcWd5nqIPZFd3PiefU}/_ssgManifest.js +0 -0
package/dist/tools/index.js
CHANGED
|
@@ -711,7 +711,7 @@ var init_namespace = __esm({
|
|
|
711
711
|
});
|
|
712
712
|
|
|
713
713
|
// src/semantic/hasher.ts
|
|
714
|
-
import { createHash } from "crypto";
|
|
714
|
+
import { createHash as createHash2 } from "crypto";
|
|
715
715
|
var init_hasher = __esm({
|
|
716
716
|
"src/semantic/hasher.ts"() {
|
|
717
717
|
"use strict";
|
|
@@ -847,7 +847,7 @@ var init_client = __esm({
|
|
|
847
847
|
});
|
|
848
848
|
|
|
849
849
|
// src/semantic/indexer.ts
|
|
850
|
-
import { readFileSync as
|
|
850
|
+
import { readFileSync as readFileSync4, statSync } from "fs";
|
|
851
851
|
import { relative as relative6 } from "path";
|
|
852
852
|
import { minimatch as minimatch2 } from "minimatch";
|
|
853
853
|
async function getIndexStatus(workingDirectory) {
|
|
@@ -932,8 +932,8 @@ __export(semantic_search_exports, {
|
|
|
932
932
|
});
|
|
933
933
|
import { tool as tool8 } from "ai";
|
|
934
934
|
import { z as z9 } from "zod";
|
|
935
|
-
import { existsSync as
|
|
936
|
-
import { join as
|
|
935
|
+
import { existsSync as existsSync12, readFileSync as readFileSync5 } from "fs";
|
|
936
|
+
import { join as join5 } from "path";
|
|
937
937
|
import { minimatch as minimatch3 } from "minimatch";
|
|
938
938
|
function createSemanticSearchTool(options) {
|
|
939
939
|
return tool8({
|
|
@@ -1000,13 +1000,13 @@ Returns matching code snippets with file paths, line numbers, and relevance scor
|
|
|
1000
1000
|
if (language && matchLanguage !== language.toLowerCase()) {
|
|
1001
1001
|
continue;
|
|
1002
1002
|
}
|
|
1003
|
-
const fullPath =
|
|
1004
|
-
if (!
|
|
1003
|
+
const fullPath = join5(options.workingDirectory, filePath);
|
|
1004
|
+
if (!existsSync12(fullPath)) {
|
|
1005
1005
|
continue;
|
|
1006
1006
|
}
|
|
1007
1007
|
let snippet = "";
|
|
1008
1008
|
try {
|
|
1009
|
-
const content =
|
|
1009
|
+
const content = readFileSync5(fullPath, "utf-8");
|
|
1010
1010
|
const lines = content.split("\n");
|
|
1011
1011
|
const snippetLines = lines.slice(
|
|
1012
1012
|
Math.max(0, startLine - 1),
|
|
@@ -1629,7 +1629,77 @@ import { tool as tool2 } from "ai";
|
|
|
1629
1629
|
import { z as z3 } from "zod";
|
|
1630
1630
|
import { readFile as readFile2, stat } from "fs/promises";
|
|
1631
1631
|
import { resolve as resolve2, relative, isAbsolute, extname } from "path";
|
|
1632
|
-
import { existsSync as
|
|
1632
|
+
import { existsSync as existsSync4 } from "fs";
|
|
1633
|
+
|
|
1634
|
+
// src/utils/resize-image.ts
|
|
1635
|
+
init_config();
|
|
1636
|
+
import sharp from "sharp";
|
|
1637
|
+
import { createHash } from "crypto";
|
|
1638
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
1639
|
+
import { join as join3 } from "path";
|
|
1640
|
+
var MAX_LONG_EDGE = 1568;
|
|
1641
|
+
var MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
1642
|
+
var CACHE_DIR_NAME = "image-cache";
|
|
1643
|
+
function getCacheDir() {
|
|
1644
|
+
const dir = join3(getAppDataDirectory(), CACHE_DIR_NAME);
|
|
1645
|
+
if (!existsSync3(dir)) mkdirSync3(dir, { recursive: true });
|
|
1646
|
+
return dir;
|
|
1647
|
+
}
|
|
1648
|
+
function cacheKey(buffer) {
|
|
1649
|
+
return createHash("sha256").update(buffer).digest("hex");
|
|
1650
|
+
}
|
|
1651
|
+
async function resizeImageIfNeeded(buffer, mediaType) {
|
|
1652
|
+
let metadata;
|
|
1653
|
+
try {
|
|
1654
|
+
metadata = await sharp(buffer).metadata();
|
|
1655
|
+
} catch {
|
|
1656
|
+
return buffer;
|
|
1657
|
+
}
|
|
1658
|
+
const { width, height } = metadata;
|
|
1659
|
+
if (!width || !height) return buffer;
|
|
1660
|
+
const longEdge = Math.max(width, height);
|
|
1661
|
+
const needsResize = longEdge > MAX_LONG_EDGE;
|
|
1662
|
+
const needsShrink = buffer.length > MAX_FILE_BYTES;
|
|
1663
|
+
if (!needsResize && !needsShrink) return buffer;
|
|
1664
|
+
const key = cacheKey(buffer);
|
|
1665
|
+
const cacheDir = getCacheDir();
|
|
1666
|
+
const isPng = mediaType?.includes("png");
|
|
1667
|
+
const ext = isPng ? ".png" : ".jpg";
|
|
1668
|
+
const cachePath = join3(cacheDir, key + ext);
|
|
1669
|
+
if (existsSync3(cachePath)) {
|
|
1670
|
+
console.log(`[image-resize] Cache hit for ${width}x${height} image`);
|
|
1671
|
+
return readFileSync2(cachePath);
|
|
1672
|
+
}
|
|
1673
|
+
let pipeline = sharp(buffer);
|
|
1674
|
+
if (needsResize) {
|
|
1675
|
+
pipeline = pipeline.resize(MAX_LONG_EDGE, MAX_LONG_EDGE, {
|
|
1676
|
+
fit: "inside",
|
|
1677
|
+
withoutEnlargement: true
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
let result;
|
|
1681
|
+
if (isPng && (needsShrink || buffer.length > 2 * 1024 * 1024)) {
|
|
1682
|
+
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
1683
|
+
} else if (isPng) {
|
|
1684
|
+
result = await pipeline.png().toBuffer();
|
|
1685
|
+
} else {
|
|
1686
|
+
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
1687
|
+
}
|
|
1688
|
+
if (result.length > MAX_FILE_BYTES) {
|
|
1689
|
+
for (const quality of [70, 50, 30]) {
|
|
1690
|
+
result = await sharp(buffer).resize(MAX_LONG_EDGE, MAX_LONG_EDGE, { fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
|
|
1691
|
+
if (result.length <= MAX_FILE_BYTES) break;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
writeFileSync2(cachePath, result);
|
|
1695
|
+
const resultMeta = await sharp(result).metadata();
|
|
1696
|
+
console.log(
|
|
1697
|
+
`[image-resize] ${width}x${height} -> ${resultMeta.width}x${resultMeta.height} (${(buffer.length / 1024).toFixed(0)}KB -> ${(result.length / 1024).toFixed(0)}KB)`
|
|
1698
|
+
);
|
|
1699
|
+
return result;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
// src/tools/read-file.ts
|
|
1633
1703
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
1634
1704
|
var MAX_IMAGE_SIZE = 20 * 1024 * 1024;
|
|
1635
1705
|
var MAX_OUTPUT_CHARS3 = 5e4;
|
|
@@ -1669,7 +1739,7 @@ Use this to understand existing code, check file contents, view screenshots, or
|
|
|
1669
1739
|
content: null
|
|
1670
1740
|
};
|
|
1671
1741
|
}
|
|
1672
|
-
if (!
|
|
1742
|
+
if (!existsSync4(absolutePath)) {
|
|
1673
1743
|
return {
|
|
1674
1744
|
success: false,
|
|
1675
1745
|
error: `File not found: ${filePath}`,
|
|
@@ -1692,9 +1762,10 @@ Use this to understand existing code, check file contents, view screenshots, or
|
|
|
1692
1762
|
content: null
|
|
1693
1763
|
};
|
|
1694
1764
|
}
|
|
1695
|
-
const
|
|
1696
|
-
const base64 = buffer.toString("base64");
|
|
1765
|
+
const rawBuffer = await readFile2(absolutePath);
|
|
1697
1766
|
const mediaType = getImageMediaType(absolutePath);
|
|
1767
|
+
const buffer = await resizeImageIfNeeded(rawBuffer, mediaType);
|
|
1768
|
+
const base64 = buffer.toString("base64");
|
|
1698
1769
|
return {
|
|
1699
1770
|
success: true,
|
|
1700
1771
|
path: absolutePath,
|
|
@@ -1773,12 +1844,12 @@ import { tool as tool3 } from "ai";
|
|
|
1773
1844
|
import { z as z4 } from "zod";
|
|
1774
1845
|
import { readFile as readFile5, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
1775
1846
|
import { resolve as resolve5, relative as relative3, isAbsolute as isAbsolute2, dirname as dirname5 } from "path";
|
|
1776
|
-
import { existsSync as
|
|
1847
|
+
import { existsSync as existsSync8 } from "fs";
|
|
1777
1848
|
|
|
1778
1849
|
// src/checkpoints/index.ts
|
|
1779
1850
|
init_db();
|
|
1780
1851
|
import { readFile as readFile3, writeFile as writeFile2, unlink, mkdir as mkdir2 } from "fs/promises";
|
|
1781
|
-
import { existsSync as
|
|
1852
|
+
import { existsSync as existsSync5 } from "fs";
|
|
1782
1853
|
import { resolve as resolve3, relative as relative2, dirname as dirname2 } from "path";
|
|
1783
1854
|
import { exec as exec3 } from "child_process";
|
|
1784
1855
|
import { promisify as promisify3 } from "util";
|
|
@@ -1809,7 +1880,7 @@ async function backupFile(sessionId, workingDirectory, filePath) {
|
|
|
1809
1880
|
}
|
|
1810
1881
|
let originalContent = null;
|
|
1811
1882
|
let existed = false;
|
|
1812
|
-
if (
|
|
1883
|
+
if (existsSync5(absolutePath)) {
|
|
1813
1884
|
try {
|
|
1814
1885
|
originalContent = await readFile3(absolutePath, "utf-8");
|
|
1815
1886
|
existed = true;
|
|
@@ -1832,14 +1903,14 @@ import { extname as extname3, dirname as dirname4 } from "path";
|
|
|
1832
1903
|
|
|
1833
1904
|
// src/lsp/servers.ts
|
|
1834
1905
|
import { spawn } from "child_process";
|
|
1835
|
-
import { existsSync as
|
|
1906
|
+
import { existsSync as existsSync6 } from "fs";
|
|
1836
1907
|
import { resolve as resolve4, dirname as dirname3 } from "path";
|
|
1837
1908
|
function findNearestRoot(startDir, markers) {
|
|
1838
1909
|
let dir = startDir;
|
|
1839
1910
|
const root = "/";
|
|
1840
1911
|
while (dir !== root) {
|
|
1841
1912
|
for (const marker of markers) {
|
|
1842
|
-
if (
|
|
1913
|
+
if (existsSync6(resolve4(dir, marker))) {
|
|
1843
1914
|
return dir;
|
|
1844
1915
|
}
|
|
1845
1916
|
}
|
|
@@ -1950,7 +2021,7 @@ import {
|
|
|
1950
2021
|
} from "vscode-jsonrpc/node.js";
|
|
1951
2022
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
1952
2023
|
import { readFile as readFile4 } from "fs/promises";
|
|
1953
|
-
import { existsSync as
|
|
2024
|
+
import { existsSync as existsSync7 } from "fs";
|
|
1954
2025
|
import { extname as extname2, normalize } from "path";
|
|
1955
2026
|
function getLanguageId(filePath) {
|
|
1956
2027
|
const ext = extname2(filePath).toLowerCase();
|
|
@@ -2076,7 +2147,7 @@ async function createClient(serverId, handle, root) {
|
|
|
2076
2147
|
diagnostics,
|
|
2077
2148
|
async notifyOpen(filePath) {
|
|
2078
2149
|
const normalized = normalizePath(filePath);
|
|
2079
|
-
if (!
|
|
2150
|
+
if (!existsSync7(normalized)) {
|
|
2080
2151
|
return;
|
|
2081
2152
|
}
|
|
2082
2153
|
try {
|
|
@@ -2107,7 +2178,7 @@ async function createClient(serverId, handle, root) {
|
|
|
2107
2178
|
},
|
|
2108
2179
|
async notifyChange(filePath) {
|
|
2109
2180
|
const normalized = normalizePath(filePath);
|
|
2110
|
-
if (!
|
|
2181
|
+
if (!existsSync7(normalized)) {
|
|
2111
2182
|
return;
|
|
2112
2183
|
}
|
|
2113
2184
|
try {
|
|
@@ -2483,7 +2554,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
2483
2554
|
error: 'Content is required for "full" mode'
|
|
2484
2555
|
};
|
|
2485
2556
|
}
|
|
2486
|
-
const existed =
|
|
2557
|
+
const existed = existsSync8(absolutePath);
|
|
2487
2558
|
const action = existed ? "replaced" : "created";
|
|
2488
2559
|
console.log("[WRITE-FILE] onProgress callback exists:", !!options.onProgress);
|
|
2489
2560
|
console.log("[WRITE-FILE] Emitting started event for:", relativePath);
|
|
@@ -2530,7 +2601,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
2530
2601
|
}
|
|
2531
2602
|
await backupFile(options.sessionId, options.workingDirectory, absolutePath);
|
|
2532
2603
|
const dir = dirname5(absolutePath);
|
|
2533
|
-
if (!
|
|
2604
|
+
if (!existsSync8(dir)) {
|
|
2534
2605
|
await mkdir3(dir, { recursive: true });
|
|
2535
2606
|
}
|
|
2536
2607
|
await writeFile3(absolutePath, content, "utf-8");
|
|
@@ -2564,7 +2635,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
2564
2635
|
error: 'Both old_string and new_string are required for "str_replace" mode'
|
|
2565
2636
|
};
|
|
2566
2637
|
}
|
|
2567
|
-
if (!
|
|
2638
|
+
if (!existsSync8(absolutePath)) {
|
|
2568
2639
|
return {
|
|
2569
2640
|
success: false,
|
|
2570
2641
|
error: `File not found: ${path}. Use "full" mode to create new files.`
|
|
@@ -2782,7 +2853,7 @@ import { z as z6 } from "zod";
|
|
|
2782
2853
|
init_types();
|
|
2783
2854
|
import { readFile as readFile6, readdir } from "fs/promises";
|
|
2784
2855
|
import { resolve as resolve6, basename, extname as extname4, relative as relative4 } from "path";
|
|
2785
|
-
import { existsSync as
|
|
2856
|
+
import { existsSync as existsSync9 } from "fs";
|
|
2786
2857
|
import { minimatch } from "minimatch";
|
|
2787
2858
|
function parseSkillFrontmatter(content) {
|
|
2788
2859
|
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
@@ -2860,7 +2931,7 @@ async function loadSkillsFromDirectory(directory, options = {}) {
|
|
|
2860
2931
|
defaultLoadType = "on_demand",
|
|
2861
2932
|
forceAlwaysApply = false
|
|
2862
2933
|
} = options;
|
|
2863
|
-
if (!
|
|
2934
|
+
if (!existsSync9(directory)) {
|
|
2864
2935
|
return [];
|
|
2865
2936
|
}
|
|
2866
2937
|
const skills = [];
|
|
@@ -2870,7 +2941,7 @@ async function loadSkillsFromDirectory(directory, options = {}) {
|
|
|
2870
2941
|
let fileName;
|
|
2871
2942
|
if (entry.isDirectory()) {
|
|
2872
2943
|
const skillMdPath = resolve6(directory, entry.name, "SKILL.md");
|
|
2873
|
-
if (
|
|
2944
|
+
if (existsSync9(skillMdPath)) {
|
|
2874
2945
|
filePath = skillMdPath;
|
|
2875
2946
|
fileName = entry.name;
|
|
2876
2947
|
} else {
|
|
@@ -3041,7 +3112,7 @@ Once loaded, a skill's content will be available in the conversation context.`,
|
|
|
3041
3112
|
import { tool as tool6 } from "ai";
|
|
3042
3113
|
import { z as z7 } from "zod";
|
|
3043
3114
|
import { resolve as resolve7, relative as relative5, isAbsolute as isAbsolute3, extname as extname5 } from "path";
|
|
3044
|
-
import { existsSync as
|
|
3115
|
+
import { existsSync as existsSync10 } from "fs";
|
|
3045
3116
|
import { readdir as readdir2, stat as stat2 } from "fs/promises";
|
|
3046
3117
|
var linterInputSchema = z7.object({
|
|
3047
3118
|
paths: z7.array(z7.string()).optional().describe("File or directory paths to check for lint errors. If not provided, returns diagnostics for all recently touched files."),
|
|
@@ -3109,7 +3180,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
3109
3180
|
const filesToCheck = [];
|
|
3110
3181
|
for (const path of paths) {
|
|
3111
3182
|
const absolutePath = isAbsolute3(path) ? path : resolve7(options.workingDirectory, path);
|
|
3112
|
-
if (!
|
|
3183
|
+
if (!existsSync10(absolutePath)) {
|
|
3113
3184
|
continue;
|
|
3114
3185
|
}
|
|
3115
3186
|
const stats = await stat2(absolutePath);
|
|
@@ -3604,7 +3675,7 @@ import { exec as exec4 } from "child_process";
|
|
|
3604
3675
|
import { promisify as promisify4 } from "util";
|
|
3605
3676
|
import { readFile as readFile8, stat as stat3, readdir as readdir4 } from "fs/promises";
|
|
3606
3677
|
import { resolve as resolve9, relative as relative8, isAbsolute as isAbsolute5 } from "path";
|
|
3607
|
-
import { existsSync as
|
|
3678
|
+
import { existsSync as existsSync13 } from "fs";
|
|
3608
3679
|
init_semantic();
|
|
3609
3680
|
|
|
3610
3681
|
// src/tools/code-graph.ts
|
|
@@ -3612,7 +3683,7 @@ import { tool as tool7 } from "ai";
|
|
|
3612
3683
|
import { z as z8 } from "zod";
|
|
3613
3684
|
import { resolve as resolve8, relative as relative7, isAbsolute as isAbsolute4, basename as basename3 } from "path";
|
|
3614
3685
|
import { readFile as readFile7, readdir as readdir3 } from "fs/promises";
|
|
3615
|
-
import { existsSync as
|
|
3686
|
+
import { existsSync as existsSync11 } from "fs";
|
|
3616
3687
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3617
3688
|
import { execFileSync } from "child_process";
|
|
3618
3689
|
var codeGraphInputSchema = z8.object({
|
|
@@ -3798,7 +3869,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
3798
3869
|
let defSymbol = null;
|
|
3799
3870
|
if (filePath) {
|
|
3800
3871
|
const absPath = isAbsolute4(filePath) ? filePath : resolve8(options.workingDirectory, filePath);
|
|
3801
|
-
if (!
|
|
3872
|
+
if (!existsSync11(absPath)) {
|
|
3802
3873
|
return { success: false, error: `File not found: ${filePath}` };
|
|
3803
3874
|
}
|
|
3804
3875
|
if (!isSupported(absPath)) {
|
|
@@ -4225,7 +4296,7 @@ Keep it concise but INCLUDE THE ACTUAL DATA.`;
|
|
|
4225
4296
|
execute: async ({ path, startLine, endLine }) => {
|
|
4226
4297
|
try {
|
|
4227
4298
|
const absolutePath = isAbsolute5(path) ? path : resolve9(workingDirectory, path);
|
|
4228
|
-
if (!
|
|
4299
|
+
if (!existsSync13(absolutePath)) {
|
|
4229
4300
|
return {
|
|
4230
4301
|
success: false,
|
|
4231
4302
|
error: `File not found: ${path}`
|
|
@@ -4269,7 +4340,7 @@ Keep it concise but INCLUDE THE ACTUAL DATA.`;
|
|
|
4269
4340
|
execute: async ({ path, recursive, maxDepth }) => {
|
|
4270
4341
|
try {
|
|
4271
4342
|
const absolutePath = isAbsolute5(path) ? path : resolve9(workingDirectory, path);
|
|
4272
|
-
if (!
|
|
4343
|
+
if (!existsSync13(absolutePath)) {
|
|
4273
4344
|
return {
|
|
4274
4345
|
success: false,
|
|
4275
4346
|
error: `Directory not found: ${path}`
|
|
@@ -4637,7 +4708,7 @@ function createTaskFailedTool(options) {
|
|
|
4637
4708
|
import { tool as tool12 } from "ai";
|
|
4638
4709
|
import { z as z13 } from "zod";
|
|
4639
4710
|
import { readFile as readFile9, stat as stat4 } from "fs/promises";
|
|
4640
|
-
import { join as
|
|
4711
|
+
import { join as join6, basename as basename4, extname as extname7 } from "path";
|
|
4641
4712
|
var MIME_TYPES = {
|
|
4642
4713
|
".txt": "text/plain",
|
|
4643
4714
|
".md": "text/markdown",
|
|
@@ -4679,7 +4750,7 @@ function createUploadFileTool(options) {
|
|
|
4679
4750
|
error: "File upload is not available \u2014 remote server with GCS is not configured."
|
|
4680
4751
|
};
|
|
4681
4752
|
}
|
|
4682
|
-
const fullPath = input.path.startsWith("/") ? input.path :
|
|
4753
|
+
const fullPath = input.path.startsWith("/") ? input.path : join6(options.workingDirectory, input.path);
|
|
4683
4754
|
try {
|
|
4684
4755
|
await stat4(fullPath);
|
|
4685
4756
|
} catch {
|