sparkecoder 0.1.75 → 0.1.77
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.d.ts +3 -3
- package/dist/agent/index.js +123 -46
- package/dist/agent/index.js.map +1 -1
- package/dist/cli.js +206 -118
- package/dist/cli.js.map +1 -1
- package/dist/db/index.d.ts +2 -2
- package/dist/{index-DRscBFFX.d.ts → index-DT1l57s0.d.ts} +25 -25
- package/dist/index.d.ts +5 -5
- package/dist/index.js +194 -106
- package/dist/index.js.map +1 -1
- package/dist/{schema-C7Mm4Ykn.d.ts → schema-XcP0dedO.d.ts} +3 -3
- package/dist/{search-CVVfuBPZ.d.ts → search-CCffrVJE.d.ts} +4 -4
- package/dist/server/index.js +194 -106
- package/dist/server/index.js.map +1 -1
- package/dist/tools/index.d.ts +3 -3
- 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/package-lock.json +3 -3
- /package/web/.next/standalone/web/.next/static/{static/xfMAecV1v1MVUkZE1r3BT → jEMyQksXLQ60IvC0f9PYc}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{static/xfMAecV1v1MVUkZE1r3BT → jEMyQksXLQ60IvC0f9PYc}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{static/xfMAecV1v1MVUkZE1r3BT → jEMyQksXLQ60IvC0f9PYc}/_ssgManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → static/jEMyQksXLQ60IvC0f9PYc}/_buildManifest.js +0 -0
- /package/web/.next/standalone/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → static/jEMyQksXLQ60IvC0f9PYc}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/standalone/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → static/jEMyQksXLQ60IvC0f9PYc}/_ssgManifest.js +0 -0
- /package/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → jEMyQksXLQ60IvC0f9PYc}/_buildManifest.js +0 -0
- /package/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → jEMyQksXLQ60IvC0f9PYc}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{xfMAecV1v1MVUkZE1r3BT → jEMyQksXLQ60IvC0f9PYc}/_ssgManifest.js +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'ai';
|
|
2
|
-
import '../schema-
|
|
3
|
-
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, C as ContextManager, M as MessageAttachment, d as buildSystemPrompt, e as buildTaskPromptAddendum } from '../index-
|
|
4
|
-
import '../search-
|
|
2
|
+
import '../schema-XcP0dedO.js';
|
|
3
|
+
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, C as ContextManager, M as MessageAttachment, d as buildSystemPrompt, e as buildTaskPromptAddendum } from '../index-DT1l57s0.js';
|
|
4
|
+
import '../search-CCffrVJE.js';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
6
6
|
import 'zod';
|
package/dist/agent/index.js
CHANGED
|
@@ -684,7 +684,7 @@ __export(skills_exports, {
|
|
|
684
684
|
});
|
|
685
685
|
import { readFile as readFile6, readdir } from "fs/promises";
|
|
686
686
|
import { resolve as resolve6, basename, extname as extname4, relative as relative4 } from "path";
|
|
687
|
-
import { existsSync as
|
|
687
|
+
import { existsSync as existsSync9 } from "fs";
|
|
688
688
|
import { minimatch } from "minimatch";
|
|
689
689
|
function parseSkillFrontmatter(content) {
|
|
690
690
|
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
@@ -762,7 +762,7 @@ async function loadSkillsFromDirectory(directory, options = {}) {
|
|
|
762
762
|
defaultLoadType = "on_demand",
|
|
763
763
|
forceAlwaysApply = false
|
|
764
764
|
} = options;
|
|
765
|
-
if (!
|
|
765
|
+
if (!existsSync9(directory)) {
|
|
766
766
|
return [];
|
|
767
767
|
}
|
|
768
768
|
const skills = [];
|
|
@@ -772,7 +772,7 @@ async function loadSkillsFromDirectory(directory, options = {}) {
|
|
|
772
772
|
let fileName;
|
|
773
773
|
if (entry.isDirectory()) {
|
|
774
774
|
const skillMdPath = resolve6(directory, entry.name, "SKILL.md");
|
|
775
|
-
if (
|
|
775
|
+
if (existsSync9(skillMdPath)) {
|
|
776
776
|
filePath = skillMdPath;
|
|
777
777
|
fileName = entry.name;
|
|
778
778
|
} else {
|
|
@@ -912,7 +912,7 @@ async function getGlobMatchedSkills(skills, activeFiles, workingDirectory) {
|
|
|
912
912
|
return matchedWithContent;
|
|
913
913
|
}
|
|
914
914
|
async function loadAgentsMd(agentsMdPath) {
|
|
915
|
-
if (!agentsMdPath || !
|
|
915
|
+
if (!agentsMdPath || !existsSync9(agentsMdPath)) {
|
|
916
916
|
return null;
|
|
917
917
|
}
|
|
918
918
|
const content = await readFile6(agentsMdPath, "utf-8");
|
|
@@ -1051,7 +1051,7 @@ var init_namespace = __esm({
|
|
|
1051
1051
|
});
|
|
1052
1052
|
|
|
1053
1053
|
// src/semantic/hasher.ts
|
|
1054
|
-
import { createHash } from "crypto";
|
|
1054
|
+
import { createHash as createHash2 } from "crypto";
|
|
1055
1055
|
var init_hasher = __esm({
|
|
1056
1056
|
"src/semantic/hasher.ts"() {
|
|
1057
1057
|
"use strict";
|
|
@@ -1187,7 +1187,7 @@ var init_client = __esm({
|
|
|
1187
1187
|
});
|
|
1188
1188
|
|
|
1189
1189
|
// src/semantic/indexer.ts
|
|
1190
|
-
import { readFileSync as
|
|
1190
|
+
import { readFileSync as readFileSync4, statSync } from "fs";
|
|
1191
1191
|
import { relative as relative6 } from "path";
|
|
1192
1192
|
import { minimatch as minimatch2 } from "minimatch";
|
|
1193
1193
|
async function getIndexStatus(workingDirectory) {
|
|
@@ -1272,8 +1272,8 @@ __export(semantic_search_exports, {
|
|
|
1272
1272
|
});
|
|
1273
1273
|
import { tool as tool8 } from "ai";
|
|
1274
1274
|
import { z as z9 } from "zod";
|
|
1275
|
-
import { existsSync as
|
|
1276
|
-
import { join as
|
|
1275
|
+
import { existsSync as existsSync12, readFileSync as readFileSync5 } from "fs";
|
|
1276
|
+
import { join as join5 } from "path";
|
|
1277
1277
|
import { minimatch as minimatch3 } from "minimatch";
|
|
1278
1278
|
function createSemanticSearchTool(options) {
|
|
1279
1279
|
return tool8({
|
|
@@ -1340,13 +1340,13 @@ Returns matching code snippets with file paths, line numbers, and relevance scor
|
|
|
1340
1340
|
if (language && matchLanguage !== language.toLowerCase()) {
|
|
1341
1341
|
continue;
|
|
1342
1342
|
}
|
|
1343
|
-
const fullPath =
|
|
1344
|
-
if (!
|
|
1343
|
+
const fullPath = join5(options.workingDirectory, filePath);
|
|
1344
|
+
if (!existsSync12(fullPath)) {
|
|
1345
1345
|
continue;
|
|
1346
1346
|
}
|
|
1347
1347
|
let snippet = "";
|
|
1348
1348
|
try {
|
|
1349
|
-
const content =
|
|
1349
|
+
const content = readFileSync5(fullPath, "utf-8");
|
|
1350
1350
|
const lines = content.split("\n");
|
|
1351
1351
|
const snippetLines = lines.slice(
|
|
1352
1352
|
Math.max(0, startLine - 1),
|
|
@@ -1614,7 +1614,7 @@ __export(recorder_exports, {
|
|
|
1614
1614
|
import { exec as exec5 } from "child_process";
|
|
1615
1615
|
import { promisify as promisify5 } from "util";
|
|
1616
1616
|
import { writeFile as writeFile4, mkdir as mkdir4, readFile as readFile10, unlink as unlink2, readdir as readdir5, rm } from "fs/promises";
|
|
1617
|
-
import { join as
|
|
1617
|
+
import { join as join7 } from "path";
|
|
1618
1618
|
import { tmpdir } from "os";
|
|
1619
1619
|
import { nanoid as nanoid3 } from "nanoid";
|
|
1620
1620
|
async function checkFfmpeg() {
|
|
@@ -1671,21 +1671,21 @@ var init_recorder = __esm({
|
|
|
1671
1671
|
*/
|
|
1672
1672
|
async encode() {
|
|
1673
1673
|
if (this.frames.length === 0) return null;
|
|
1674
|
-
const workDir =
|
|
1674
|
+
const workDir = join7(tmpdir(), `sparkecoder-recording-${nanoid3(8)}`);
|
|
1675
1675
|
await mkdir4(workDir, { recursive: true });
|
|
1676
1676
|
try {
|
|
1677
1677
|
for (let i = 0; i < this.frames.length; i++) {
|
|
1678
|
-
const framePath =
|
|
1678
|
+
const framePath = join7(workDir, `frame_${String(i).padStart(6, "0")}.jpg`);
|
|
1679
1679
|
await writeFile4(framePath, this.frames[i].data);
|
|
1680
1680
|
}
|
|
1681
1681
|
const duration = (this.frames[this.frames.length - 1].timestamp - this.frames[0].timestamp) / 1e3;
|
|
1682
1682
|
const fps = duration > 0 ? Math.round(this.frames.length / duration) : 10;
|
|
1683
1683
|
const clampedFps = Math.max(1, Math.min(fps, 30));
|
|
1684
|
-
const outputPath =
|
|
1684
|
+
const outputPath = join7(workDir, `recording_${this.sessionId}.mp4`);
|
|
1685
1685
|
const hasFfmpeg = await checkFfmpeg();
|
|
1686
1686
|
if (hasFfmpeg) {
|
|
1687
1687
|
await execAsync5(
|
|
1688
|
-
`ffmpeg -y -framerate ${clampedFps} -i "${
|
|
1688
|
+
`ffmpeg -y -framerate ${clampedFps} -i "${join7(workDir, "frame_%06d.jpg")}" -c:v libx264 -pix_fmt yuv420p -preset fast -crf 23 "${outputPath}"`,
|
|
1689
1689
|
{ timeout: 12e4 }
|
|
1690
1690
|
);
|
|
1691
1691
|
} else {
|
|
@@ -1697,7 +1697,7 @@ var init_recorder = __esm({
|
|
|
1697
1697
|
const files = await readdir5(workDir);
|
|
1698
1698
|
for (const f of files) {
|
|
1699
1699
|
if (f.startsWith("frame_")) {
|
|
1700
|
-
await unlink2(
|
|
1700
|
+
await unlink2(join7(workDir, f)).catch(() => {
|
|
1701
1701
|
});
|
|
1702
1702
|
}
|
|
1703
1703
|
}
|
|
@@ -2499,7 +2499,77 @@ import { tool as tool2 } from "ai";
|
|
|
2499
2499
|
import { z as z3 } from "zod";
|
|
2500
2500
|
import { readFile as readFile2, stat } from "fs/promises";
|
|
2501
2501
|
import { resolve as resolve2, relative, isAbsolute, extname } from "path";
|
|
2502
|
-
import { existsSync as
|
|
2502
|
+
import { existsSync as existsSync4 } from "fs";
|
|
2503
|
+
|
|
2504
|
+
// src/utils/resize-image.ts
|
|
2505
|
+
init_config();
|
|
2506
|
+
import sharp from "sharp";
|
|
2507
|
+
import { createHash } from "crypto";
|
|
2508
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
2509
|
+
import { join as join3 } from "path";
|
|
2510
|
+
var MAX_LONG_EDGE = 1568;
|
|
2511
|
+
var MAX_FILE_BYTES = 5 * 1024 * 1024;
|
|
2512
|
+
var CACHE_DIR_NAME = "image-cache";
|
|
2513
|
+
function getCacheDir() {
|
|
2514
|
+
const dir = join3(getAppDataDirectory(), CACHE_DIR_NAME);
|
|
2515
|
+
if (!existsSync3(dir)) mkdirSync3(dir, { recursive: true });
|
|
2516
|
+
return dir;
|
|
2517
|
+
}
|
|
2518
|
+
function cacheKey(buffer) {
|
|
2519
|
+
return createHash("sha256").update(buffer).digest("hex");
|
|
2520
|
+
}
|
|
2521
|
+
async function resizeImageIfNeeded(buffer, mediaType) {
|
|
2522
|
+
let metadata;
|
|
2523
|
+
try {
|
|
2524
|
+
metadata = await sharp(buffer).metadata();
|
|
2525
|
+
} catch {
|
|
2526
|
+
return buffer;
|
|
2527
|
+
}
|
|
2528
|
+
const { width, height } = metadata;
|
|
2529
|
+
if (!width || !height) return buffer;
|
|
2530
|
+
const longEdge = Math.max(width, height);
|
|
2531
|
+
const needsResize = longEdge > MAX_LONG_EDGE;
|
|
2532
|
+
const needsShrink = buffer.length > MAX_FILE_BYTES;
|
|
2533
|
+
if (!needsResize && !needsShrink) return buffer;
|
|
2534
|
+
const key = cacheKey(buffer);
|
|
2535
|
+
const cacheDir = getCacheDir();
|
|
2536
|
+
const isPng = mediaType?.includes("png");
|
|
2537
|
+
const ext = isPng ? ".png" : ".jpg";
|
|
2538
|
+
const cachePath = join3(cacheDir, key + ext);
|
|
2539
|
+
if (existsSync3(cachePath)) {
|
|
2540
|
+
console.log(`[image-resize] Cache hit for ${width}x${height} image`);
|
|
2541
|
+
return readFileSync2(cachePath);
|
|
2542
|
+
}
|
|
2543
|
+
let pipeline = sharp(buffer);
|
|
2544
|
+
if (needsResize) {
|
|
2545
|
+
pipeline = pipeline.resize(MAX_LONG_EDGE, MAX_LONG_EDGE, {
|
|
2546
|
+
fit: "inside",
|
|
2547
|
+
withoutEnlargement: true
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
let result;
|
|
2551
|
+
if (isPng && (needsShrink || buffer.length > 2 * 1024 * 1024)) {
|
|
2552
|
+
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
2553
|
+
} else if (isPng) {
|
|
2554
|
+
result = await pipeline.png().toBuffer();
|
|
2555
|
+
} else {
|
|
2556
|
+
result = await pipeline.jpeg({ quality: 85 }).toBuffer();
|
|
2557
|
+
}
|
|
2558
|
+
if (result.length > MAX_FILE_BYTES) {
|
|
2559
|
+
for (const quality of [70, 50, 30]) {
|
|
2560
|
+
result = await sharp(buffer).resize(MAX_LONG_EDGE, MAX_LONG_EDGE, { fit: "inside", withoutEnlargement: true }).jpeg({ quality }).toBuffer();
|
|
2561
|
+
if (result.length <= MAX_FILE_BYTES) break;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
writeFileSync2(cachePath, result);
|
|
2565
|
+
const resultMeta = await sharp(result).metadata();
|
|
2566
|
+
console.log(
|
|
2567
|
+
`[image-resize] ${width}x${height} -> ${resultMeta.width}x${resultMeta.height} (${(buffer.length / 1024).toFixed(0)}KB -> ${(result.length / 1024).toFixed(0)}KB)`
|
|
2568
|
+
);
|
|
2569
|
+
return result;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
// src/tools/read-file.ts
|
|
2503
2573
|
var MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
2504
2574
|
var MAX_IMAGE_SIZE = 20 * 1024 * 1024;
|
|
2505
2575
|
var MAX_OUTPUT_CHARS3 = 5e4;
|
|
@@ -2539,7 +2609,7 @@ Use this to understand existing code, check file contents, view screenshots, or
|
|
|
2539
2609
|
content: null
|
|
2540
2610
|
};
|
|
2541
2611
|
}
|
|
2542
|
-
if (!
|
|
2612
|
+
if (!existsSync4(absolutePath)) {
|
|
2543
2613
|
return {
|
|
2544
2614
|
success: false,
|
|
2545
2615
|
error: `File not found: ${filePath}`,
|
|
@@ -2562,9 +2632,10 @@ Use this to understand existing code, check file contents, view screenshots, or
|
|
|
2562
2632
|
content: null
|
|
2563
2633
|
};
|
|
2564
2634
|
}
|
|
2565
|
-
const
|
|
2566
|
-
const base64 = buffer.toString("base64");
|
|
2635
|
+
const rawBuffer = await readFile2(absolutePath);
|
|
2567
2636
|
const mediaType = getImageMediaType(absolutePath);
|
|
2637
|
+
const buffer = await resizeImageIfNeeded(rawBuffer, mediaType);
|
|
2638
|
+
const base64 = buffer.toString("base64");
|
|
2568
2639
|
return {
|
|
2569
2640
|
success: true,
|
|
2570
2641
|
path: absolutePath,
|
|
@@ -2643,12 +2714,12 @@ import { tool as tool3 } from "ai";
|
|
|
2643
2714
|
import { z as z4 } from "zod";
|
|
2644
2715
|
import { readFile as readFile5, writeFile as writeFile3, mkdir as mkdir3 } from "fs/promises";
|
|
2645
2716
|
import { resolve as resolve5, relative as relative3, isAbsolute as isAbsolute2, dirname as dirname5 } from "path";
|
|
2646
|
-
import { existsSync as
|
|
2717
|
+
import { existsSync as existsSync8 } from "fs";
|
|
2647
2718
|
|
|
2648
2719
|
// src/checkpoints/index.ts
|
|
2649
2720
|
init_db();
|
|
2650
2721
|
import { readFile as readFile3, writeFile as writeFile2, unlink, mkdir as mkdir2 } from "fs/promises";
|
|
2651
|
-
import { existsSync as
|
|
2722
|
+
import { existsSync as existsSync5 } from "fs";
|
|
2652
2723
|
import { resolve as resolve3, relative as relative2, dirname as dirname2 } from "path";
|
|
2653
2724
|
import { exec as exec3 } from "child_process";
|
|
2654
2725
|
import { promisify as promisify3 } from "util";
|
|
@@ -2679,7 +2750,7 @@ async function backupFile(sessionId, workingDirectory, filePath) {
|
|
|
2679
2750
|
}
|
|
2680
2751
|
let originalContent = null;
|
|
2681
2752
|
let existed = false;
|
|
2682
|
-
if (
|
|
2753
|
+
if (existsSync5(absolutePath)) {
|
|
2683
2754
|
try {
|
|
2684
2755
|
originalContent = await readFile3(absolutePath, "utf-8");
|
|
2685
2756
|
existed = true;
|
|
@@ -2702,14 +2773,14 @@ import { extname as extname3, dirname as dirname4 } from "path";
|
|
|
2702
2773
|
|
|
2703
2774
|
// src/lsp/servers.ts
|
|
2704
2775
|
import { spawn } from "child_process";
|
|
2705
|
-
import { existsSync as
|
|
2776
|
+
import { existsSync as existsSync6 } from "fs";
|
|
2706
2777
|
import { resolve as resolve4, dirname as dirname3 } from "path";
|
|
2707
2778
|
function findNearestRoot(startDir, markers) {
|
|
2708
2779
|
let dir = startDir;
|
|
2709
2780
|
const root = "/";
|
|
2710
2781
|
while (dir !== root) {
|
|
2711
2782
|
for (const marker of markers) {
|
|
2712
|
-
if (
|
|
2783
|
+
if (existsSync6(resolve4(dir, marker))) {
|
|
2713
2784
|
return dir;
|
|
2714
2785
|
}
|
|
2715
2786
|
}
|
|
@@ -2820,7 +2891,7 @@ import {
|
|
|
2820
2891
|
} from "vscode-jsonrpc/node.js";
|
|
2821
2892
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
2822
2893
|
import { readFile as readFile4 } from "fs/promises";
|
|
2823
|
-
import { existsSync as
|
|
2894
|
+
import { existsSync as existsSync7 } from "fs";
|
|
2824
2895
|
import { extname as extname2, normalize } from "path";
|
|
2825
2896
|
function getLanguageId(filePath) {
|
|
2826
2897
|
const ext = extname2(filePath).toLowerCase();
|
|
@@ -2946,7 +3017,7 @@ async function createClient(serverId, handle, root) {
|
|
|
2946
3017
|
diagnostics,
|
|
2947
3018
|
async notifyOpen(filePath) {
|
|
2948
3019
|
const normalized = normalizePath(filePath);
|
|
2949
|
-
if (!
|
|
3020
|
+
if (!existsSync7(normalized)) {
|
|
2950
3021
|
return;
|
|
2951
3022
|
}
|
|
2952
3023
|
try {
|
|
@@ -2977,7 +3048,7 @@ async function createClient(serverId, handle, root) {
|
|
|
2977
3048
|
},
|
|
2978
3049
|
async notifyChange(filePath) {
|
|
2979
3050
|
const normalized = normalizePath(filePath);
|
|
2980
|
-
if (!
|
|
3051
|
+
if (!existsSync7(normalized)) {
|
|
2981
3052
|
return;
|
|
2982
3053
|
}
|
|
2983
3054
|
try {
|
|
@@ -3353,7 +3424,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
3353
3424
|
error: 'Content is required for "full" mode'
|
|
3354
3425
|
};
|
|
3355
3426
|
}
|
|
3356
|
-
const existed =
|
|
3427
|
+
const existed = existsSync8(absolutePath);
|
|
3357
3428
|
const action = existed ? "replaced" : "created";
|
|
3358
3429
|
console.log("[WRITE-FILE] onProgress callback exists:", !!options.onProgress);
|
|
3359
3430
|
console.log("[WRITE-FILE] Emitting started event for:", relativePath);
|
|
@@ -3400,7 +3471,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
3400
3471
|
}
|
|
3401
3472
|
await backupFile(options.sessionId, options.workingDirectory, absolutePath);
|
|
3402
3473
|
const dir = dirname5(absolutePath);
|
|
3403
|
-
if (!
|
|
3474
|
+
if (!existsSync8(dir)) {
|
|
3404
3475
|
await mkdir3(dir, { recursive: true });
|
|
3405
3476
|
}
|
|
3406
3477
|
await writeFile3(absolutePath, content, "utf-8");
|
|
@@ -3434,7 +3505,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
3434
3505
|
error: 'Both old_string and new_string are required for "str_replace" mode'
|
|
3435
3506
|
};
|
|
3436
3507
|
}
|
|
3437
|
-
if (!
|
|
3508
|
+
if (!existsSync8(absolutePath)) {
|
|
3438
3509
|
return {
|
|
3439
3510
|
success: false,
|
|
3440
3511
|
error: `File not found: ${path}. Use "full" mode to create new files.`
|
|
@@ -3732,7 +3803,7 @@ Once loaded, a skill's content will be available in the conversation context.`,
|
|
|
3732
3803
|
import { tool as tool6 } from "ai";
|
|
3733
3804
|
import { z as z7 } from "zod";
|
|
3734
3805
|
import { resolve as resolve7, relative as relative5, isAbsolute as isAbsolute3, extname as extname5 } from "path";
|
|
3735
|
-
import { existsSync as
|
|
3806
|
+
import { existsSync as existsSync10 } from "fs";
|
|
3736
3807
|
import { readdir as readdir2, stat as stat2 } from "fs/promises";
|
|
3737
3808
|
var linterInputSchema = z7.object({
|
|
3738
3809
|
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."),
|
|
@@ -3800,7 +3871,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
3800
3871
|
const filesToCheck = [];
|
|
3801
3872
|
for (const path of paths) {
|
|
3802
3873
|
const absolutePath = isAbsolute3(path) ? path : resolve7(options.workingDirectory, path);
|
|
3803
|
-
if (!
|
|
3874
|
+
if (!existsSync10(absolutePath)) {
|
|
3804
3875
|
continue;
|
|
3805
3876
|
}
|
|
3806
3877
|
const stats = await stat2(absolutePath);
|
|
@@ -4114,7 +4185,7 @@ import { exec as exec4 } from "child_process";
|
|
|
4114
4185
|
import { promisify as promisify4 } from "util";
|
|
4115
4186
|
import { readFile as readFile8, stat as stat3, readdir as readdir4 } from "fs/promises";
|
|
4116
4187
|
import { resolve as resolve9, relative as relative8, isAbsolute as isAbsolute5 } from "path";
|
|
4117
|
-
import { existsSync as
|
|
4188
|
+
import { existsSync as existsSync13 } from "fs";
|
|
4118
4189
|
init_semantic();
|
|
4119
4190
|
|
|
4120
4191
|
// src/tools/code-graph.ts
|
|
@@ -4122,7 +4193,7 @@ import { tool as tool7 } from "ai";
|
|
|
4122
4193
|
import { z as z8 } from "zod";
|
|
4123
4194
|
import { resolve as resolve8, relative as relative7, isAbsolute as isAbsolute4, basename as basename3 } from "path";
|
|
4124
4195
|
import { readFile as readFile7, readdir as readdir3 } from "fs/promises";
|
|
4125
|
-
import { existsSync as
|
|
4196
|
+
import { existsSync as existsSync11 } from "fs";
|
|
4126
4197
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4127
4198
|
import { execFileSync } from "child_process";
|
|
4128
4199
|
var codeGraphInputSchema = z8.object({
|
|
@@ -4308,7 +4379,7 @@ Working directory: ${options.workingDirectory}`,
|
|
|
4308
4379
|
let defSymbol = null;
|
|
4309
4380
|
if (filePath) {
|
|
4310
4381
|
const absPath = isAbsolute4(filePath) ? filePath : resolve8(options.workingDirectory, filePath);
|
|
4311
|
-
if (!
|
|
4382
|
+
if (!existsSync11(absPath)) {
|
|
4312
4383
|
return { success: false, error: `File not found: ${filePath}` };
|
|
4313
4384
|
}
|
|
4314
4385
|
if (!isSupported(absPath)) {
|
|
@@ -4735,7 +4806,7 @@ Keep it concise but INCLUDE THE ACTUAL DATA.`;
|
|
|
4735
4806
|
execute: async ({ path, startLine, endLine }) => {
|
|
4736
4807
|
try {
|
|
4737
4808
|
const absolutePath = isAbsolute5(path) ? path : resolve9(workingDirectory, path);
|
|
4738
|
-
if (!
|
|
4809
|
+
if (!existsSync13(absolutePath)) {
|
|
4739
4810
|
return {
|
|
4740
4811
|
success: false,
|
|
4741
4812
|
error: `File not found: ${path}`
|
|
@@ -4779,7 +4850,7 @@ Keep it concise but INCLUDE THE ACTUAL DATA.`;
|
|
|
4779
4850
|
execute: async ({ path, recursive, maxDepth }) => {
|
|
4780
4851
|
try {
|
|
4781
4852
|
const absolutePath = isAbsolute5(path) ? path : resolve9(workingDirectory, path);
|
|
4782
|
-
if (!
|
|
4853
|
+
if (!existsSync13(absolutePath)) {
|
|
4783
4854
|
return {
|
|
4784
4855
|
success: false,
|
|
4785
4856
|
error: `Directory not found: ${path}`
|
|
@@ -5147,7 +5218,7 @@ function createTaskFailedTool(options) {
|
|
|
5147
5218
|
import { tool as tool12 } from "ai";
|
|
5148
5219
|
import { z as z13 } from "zod";
|
|
5149
5220
|
import { readFile as readFile9, stat as stat4 } from "fs/promises";
|
|
5150
|
-
import { join as
|
|
5221
|
+
import { join as join6, basename as basename4, extname as extname7 } from "path";
|
|
5151
5222
|
var MIME_TYPES = {
|
|
5152
5223
|
".txt": "text/plain",
|
|
5153
5224
|
".md": "text/markdown",
|
|
@@ -5189,7 +5260,7 @@ function createUploadFileTool(options) {
|
|
|
5189
5260
|
error: "File upload is not available \u2014 remote server with GCS is not configured."
|
|
5190
5261
|
};
|
|
5191
5262
|
}
|
|
5192
|
-
const fullPath = input.path.startsWith("/") ? input.path :
|
|
5263
|
+
const fullPath = input.path.startsWith("/") ? input.path : join6(options.workingDirectory, input.path);
|
|
5193
5264
|
try {
|
|
5194
5265
|
await stat4(fullPath);
|
|
5195
5266
|
} catch {
|
|
@@ -6214,6 +6285,13 @@ function truncateWriteFileInput(input) {
|
|
|
6214
6285
|
return out;
|
|
6215
6286
|
}
|
|
6216
6287
|
var approvalResolvers = /* @__PURE__ */ new Map();
|
|
6288
|
+
function stripDataUrlPrefix(data) {
|
|
6289
|
+
const commaIdx = data.indexOf(",");
|
|
6290
|
+
if (commaIdx !== -1 && data.startsWith("data:")) {
|
|
6291
|
+
return data.slice(commaIdx + 1);
|
|
6292
|
+
}
|
|
6293
|
+
return data;
|
|
6294
|
+
}
|
|
6217
6295
|
var Agent = class _Agent {
|
|
6218
6296
|
session;
|
|
6219
6297
|
context;
|
|
@@ -6314,8 +6392,7 @@ ${prompt}` });
|
|
|
6314
6392
|
if (attachment.type === "image") {
|
|
6315
6393
|
contentParts.push({
|
|
6316
6394
|
type: "image",
|
|
6317
|
-
image: attachment.data,
|
|
6318
|
-
// base64 data URL or raw base64
|
|
6395
|
+
image: stripDataUrlPrefix(attachment.data),
|
|
6319
6396
|
mediaType: attachment.mediaType,
|
|
6320
6397
|
filename: attachment.filename,
|
|
6321
6398
|
savedPath: attachment.savedPath
|
|
@@ -6323,7 +6400,7 @@ ${prompt}` });
|
|
|
6323
6400
|
} else {
|
|
6324
6401
|
contentParts.push({
|
|
6325
6402
|
type: "file",
|
|
6326
|
-
data: attachment.data,
|
|
6403
|
+
data: stripDataUrlPrefix(attachment.data),
|
|
6327
6404
|
mediaType: attachment.mediaType || "application/octet-stream",
|
|
6328
6405
|
filename: attachment.filename,
|
|
6329
6406
|
savedPath: attachment.savedPath
|
|
@@ -6772,11 +6849,11 @@ ${taskAddendum}`;
|
|
|
6772
6849
|
const { isRemoteConfigured: isRemoteConfigured2, storageQueries: storageQueries2 } = await Promise.resolve().then(() => (init_remote(), remote_exports));
|
|
6773
6850
|
if (!isRemoteConfigured2()) return [];
|
|
6774
6851
|
const { readFile: readFile11 } = await import("fs/promises");
|
|
6775
|
-
const { join:
|
|
6852
|
+
const { join: join8, basename: basename5 } = await import("path");
|
|
6776
6853
|
const urls = [];
|
|
6777
6854
|
for (const filePath of filePaths) {
|
|
6778
6855
|
try {
|
|
6779
|
-
const fullPath = filePath.startsWith("/") ? filePath :
|
|
6856
|
+
const fullPath = filePath.startsWith("/") ? filePath : join8(this.session.workingDirectory, filePath);
|
|
6780
6857
|
const fileName = basename5(fullPath);
|
|
6781
6858
|
const ext = fileName.split(".").pop()?.toLowerCase() || "";
|
|
6782
6859
|
const mimeMap = {
|