@getpochi/cli 0.5.92 → 0.5.93
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/cli.js +152 -79
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -127436,7 +127436,7 @@ var require_snapshot_utils = __commonJS((exports, module) => {
|
|
|
127436
127436
|
|
|
127437
127437
|
// ../../node_modules/@effect/platform-node/node_modules/undici/lib/mock/snapshot-recorder.js
|
|
127438
127438
|
var require_snapshot_recorder = __commonJS((exports, module) => {
|
|
127439
|
-
var { writeFile: writeFile2, readFile:
|
|
127439
|
+
var { writeFile: writeFile2, readFile: readFile6, mkdir: mkdir2 } = __require("node:fs/promises");
|
|
127440
127440
|
var { dirname: dirname2, resolve: resolve5 } = __require("node:path");
|
|
127441
127441
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
127442
127442
|
var { InvalidArgumentError: InvalidArgumentError5, UndiciError } = require_errors2();
|
|
@@ -127606,7 +127606,7 @@ var require_snapshot_recorder = __commonJS((exports, module) => {
|
|
|
127606
127606
|
throw new InvalidArgumentError5("Snapshot path is required");
|
|
127607
127607
|
}
|
|
127608
127608
|
try {
|
|
127609
|
-
const data = await
|
|
127609
|
+
const data = await readFile6(resolve5(path14), "utf8");
|
|
127610
127610
|
const parsed = JSON.parse(data);
|
|
127611
127611
|
if (Array.isArray(parsed)) {
|
|
127612
127612
|
this.#snapshots.clear();
|
|
@@ -139587,7 +139587,7 @@ var handleBadArgument = (method) => (cause3) => new BadArgument({
|
|
|
139587
139587
|
}, makeTempFile, makeTempFileScoped, readDirectory = (path14, options4) => tryPromise2({
|
|
139588
139588
|
try: () => NFS2.promises.readdir(path14, options4),
|
|
139589
139589
|
catch: (err) => handleErrnoException("FileSystem", "readDirectory")(err, [path14])
|
|
139590
|
-
}),
|
|
139590
|
+
}), readFile7 = (path14) => async((resume2, signal2) => {
|
|
139591
139591
|
try {
|
|
139592
139592
|
NFS2.readFile(path14, {
|
|
139593
139593
|
signal: signal2
|
|
@@ -139895,7 +139895,7 @@ var init_fileSystem2 = __esm(() => {
|
|
|
139895
139895
|
makeTempFileScoped,
|
|
139896
139896
|
open: open3,
|
|
139897
139897
|
readDirectory,
|
|
139898
|
-
readFile:
|
|
139898
|
+
readFile: readFile7,
|
|
139899
139899
|
readLink,
|
|
139900
139900
|
realPath,
|
|
139901
139901
|
remove: remove21,
|
|
@@ -361184,8 +361184,11 @@ var isVSCodeEnvironment = () => {
|
|
|
361184
361184
|
};
|
|
361185
361185
|
|
|
361186
361186
|
// ../common/src/base/logger.ts
|
|
361187
|
+
function isNodeEnvironment() {
|
|
361188
|
+
return typeof process !== "undefined" && typeof process.stderr !== "undefined";
|
|
361189
|
+
}
|
|
361187
361190
|
var mainLogger = new Logger({
|
|
361188
|
-
type: "hidden"
|
|
361191
|
+
type: isNodeEnvironment() ? "hidden" : "pretty"
|
|
361189
361192
|
});
|
|
361190
361193
|
function stringToLogLevel(level) {
|
|
361191
361194
|
switch (level) {
|
|
@@ -389871,17 +389874,20 @@ var OpenAIResponsesModelSettings = ExtendedModelSettings.extend({
|
|
|
389871
389874
|
var AnthropicModelSettings = ExtendedModelSettings.extend({
|
|
389872
389875
|
kind: v4_default.literal("anthropic")
|
|
389873
389876
|
});
|
|
389874
|
-
var GoogleVertexModel = v4_default.
|
|
389877
|
+
var GoogleVertexModel = v4_default.discriminatedUnion("type", [
|
|
389875
389878
|
v4_default.object({
|
|
389879
|
+
type: v4_default.literal("service-account"),
|
|
389876
389880
|
serviceAccountKey: v4_default.string().default(process.env.POCHI_VERTEX_SERVICE_ACCOUNT_KEY ?? ""),
|
|
389877
389881
|
location: v4_default.string().default(process.env.POCHI_VERTEX_LOCATION ?? "")
|
|
389878
389882
|
}),
|
|
389879
389883
|
v4_default.object({
|
|
389884
|
+
type: v4_default.literal("access-token"),
|
|
389880
389885
|
accessToken: v4_default.string().default(process.env.POCHI_VERTEX_ACCESS_TOKEN ?? ""),
|
|
389881
389886
|
projectId: v4_default.string().default(process.env.POCHI_VERTEX_PROJECT_ID ?? ""),
|
|
389882
389887
|
location: v4_default.string().default(process.env.POCHI_VERTEX_LOCATION ?? "")
|
|
389883
389888
|
}),
|
|
389884
389889
|
v4_default.object({
|
|
389890
|
+
type: v4_default.literal("model-url"),
|
|
389885
389891
|
issueUrl: v4_default.string().default(process.env.POCHI_VERTEX_ISSUE_URL ?? ""),
|
|
389886
389892
|
modelUrl: v4_default.string().default(process.env.POCHI_VERTEX_MODEL_URL ?? ""),
|
|
389887
389893
|
timeout: v4_default.number().default(Number.parseInt(process.env.POCHI_VERTEX_MODEL_TIMEOUT ?? "900000")).describe("Timeout in milliseconds when requesting model api")
|
|
@@ -392234,6 +392240,58 @@ function decodeJwt(jwt2) {
|
|
|
392234
392240
|
throw new JWTInvalid("Invalid JWT Claims Set");
|
|
392235
392241
|
return result2;
|
|
392236
392242
|
}
|
|
392243
|
+
// ../vendor-pochi/src/content-type.ts
|
|
392244
|
+
var ContentType = {
|
|
392245
|
+
gemini: [
|
|
392246
|
+
"image/png",
|
|
392247
|
+
"image/jpeg",
|
|
392248
|
+
"image/webp",
|
|
392249
|
+
"image/heic",
|
|
392250
|
+
"image/heif",
|
|
392251
|
+
"video/mp4",
|
|
392252
|
+
"video/mpeg",
|
|
392253
|
+
"video/mov",
|
|
392254
|
+
"video/avi",
|
|
392255
|
+
"video/x-flv",
|
|
392256
|
+
"video/mpg",
|
|
392257
|
+
"video/webm",
|
|
392258
|
+
"video/wmv",
|
|
392259
|
+
"video/3gpp",
|
|
392260
|
+
"audio/wav",
|
|
392261
|
+
"audio/mp3",
|
|
392262
|
+
"audio/aiff",
|
|
392263
|
+
"audio/aac",
|
|
392264
|
+
"audio/ogg",
|
|
392265
|
+
"audio/flac",
|
|
392266
|
+
"application/pdf"
|
|
392267
|
+
],
|
|
392268
|
+
claude: [
|
|
392269
|
+
"image/png",
|
|
392270
|
+
"image/jpeg",
|
|
392271
|
+
"image/gif",
|
|
392272
|
+
"image/webp",
|
|
392273
|
+
"application/pdf"
|
|
392274
|
+
],
|
|
392275
|
+
gpt: [
|
|
392276
|
+
"image/png",
|
|
392277
|
+
"image/jpeg",
|
|
392278
|
+
"image/gif",
|
|
392279
|
+
"image/webp",
|
|
392280
|
+
"application/pdf"
|
|
392281
|
+
]
|
|
392282
|
+
};
|
|
392283
|
+
var getContentTypesForModel = (modelId) => {
|
|
392284
|
+
if (modelId.includes("google/gemini")) {
|
|
392285
|
+
return ContentType.gemini;
|
|
392286
|
+
}
|
|
392287
|
+
if (modelId.includes("anthropic/claude")) {
|
|
392288
|
+
return ContentType.claude;
|
|
392289
|
+
}
|
|
392290
|
+
if (modelId.includes("openai/gpt")) {
|
|
392291
|
+
return ContentType.gpt;
|
|
392292
|
+
}
|
|
392293
|
+
};
|
|
392294
|
+
|
|
392237
392295
|
// ../vendor-pochi/src/credentials.ts
|
|
392238
392296
|
function getPochiCredentials() {
|
|
392239
392297
|
return config2.value.vendors?.pochi?.credentials;
|
|
@@ -392354,31 +392412,9 @@ class Pochi extends VendorBase {
|
|
|
392354
392412
|
x.id,
|
|
392355
392413
|
{
|
|
392356
392414
|
contextWindow: x.contextWindow,
|
|
392357
|
-
useToolCallMiddleware: x.id.includes("google
|
|
392415
|
+
useToolCallMiddleware: x.id.includes("google"),
|
|
392358
392416
|
label: x.costType === "basic" ? "swift" : "super",
|
|
392359
|
-
contentType: x.id
|
|
392360
|
-
"image/png",
|
|
392361
|
-
"image/jpeg",
|
|
392362
|
-
"image/webp",
|
|
392363
|
-
"image/heic",
|
|
392364
|
-
"image/heif",
|
|
392365
|
-
"video/mp4",
|
|
392366
|
-
"video/mpeg",
|
|
392367
|
-
"video/mov",
|
|
392368
|
-
"video/avi",
|
|
392369
|
-
"video/x-flv",
|
|
392370
|
-
"video/mpg",
|
|
392371
|
-
"video/webm",
|
|
392372
|
-
"video/wmv",
|
|
392373
|
-
"video/3gpp",
|
|
392374
|
-
"audio/wav",
|
|
392375
|
-
"audio/mp3",
|
|
392376
|
-
"audio/aiff",
|
|
392377
|
-
"audio/aac",
|
|
392378
|
-
"audio/ogg",
|
|
392379
|
-
"audio/flac",
|
|
392380
|
-
"application/pdf"
|
|
392381
|
-
] : undefined
|
|
392417
|
+
contentType: getContentTypesForModel(x.id)
|
|
392382
392418
|
}
|
|
392383
392419
|
]));
|
|
392384
392420
|
}
|
|
@@ -404241,7 +404277,7 @@ function createPatchedFetch3(getCredentials) {
|
|
|
404241
404277
|
registerModel(VendorId7, createQwenModel);
|
|
404242
404278
|
|
|
404243
404279
|
// src/cli.ts
|
|
404244
|
-
import
|
|
404280
|
+
import fs19 from "fs/promises";
|
|
404245
404281
|
import path28 from "path";
|
|
404246
404282
|
|
|
404247
404283
|
// ../../node_modules/@commander-js/extra-typings/esm.mjs
|
|
@@ -406533,7 +406569,7 @@ var {
|
|
|
406533
406569
|
// package.json
|
|
406534
406570
|
var package_default = {
|
|
406535
406571
|
name: "@getpochi/cli",
|
|
406536
|
-
version: "0.5.
|
|
406572
|
+
version: "0.5.93",
|
|
406537
406573
|
type: "module",
|
|
406538
406574
|
bin: {
|
|
406539
406575
|
pochi: "src/cli.ts"
|
|
@@ -408659,7 +408695,6 @@ async function parseWorktreeGitdir(cwd) {
|
|
|
408659
408695
|
}
|
|
408660
408696
|
}
|
|
408661
408697
|
// ../common/src/tool-utils/custom-rules.ts
|
|
408662
|
-
import { readFile as readFile4 } from "node:fs/promises";
|
|
408663
408698
|
import { homedir as homedir2 } from "node:os";
|
|
408664
408699
|
import path8 from "node:path";
|
|
408665
408700
|
var WorkspaceRulesFilePaths = ["README.pochi.md", "AGENTS.md"];
|
|
@@ -408672,31 +408707,65 @@ function makeGlobalRule(filePath) {
|
|
|
408672
408707
|
var GlobalRules = [
|
|
408673
408708
|
makeGlobalRule(path8.join(homedir2(), ".pochi", "README.pochi.md"))
|
|
408674
408709
|
];
|
|
408675
|
-
async function
|
|
408676
|
-
|
|
408677
|
-
|
|
408710
|
+
async function collectAllRuleFiles(cwd, readFileContent, options4 = {}) {
|
|
408711
|
+
const {
|
|
408712
|
+
includeDefaultRules = true,
|
|
408713
|
+
includeGlobalRules = true,
|
|
408714
|
+
customRuleFiles = []
|
|
408715
|
+
} = options4;
|
|
408716
|
+
const allRuleFiles = new Map;
|
|
408717
|
+
const visited = new Set;
|
|
408718
|
+
const processFile = async (filePath, isGlobal) => {
|
|
408719
|
+
if (visited.has(filePath)) {
|
|
408720
|
+
return;
|
|
408721
|
+
}
|
|
408722
|
+
if (!filePath.endsWith(".md") || !await isFileExists(filePath)) {
|
|
408723
|
+
return;
|
|
408724
|
+
}
|
|
408725
|
+
visited.add(filePath);
|
|
408726
|
+
let content = "";
|
|
408727
|
+
try {
|
|
408728
|
+
content = await readFileContent(filePath) ?? "";
|
|
408729
|
+
if (!allRuleFiles.has(filePath)) {
|
|
408730
|
+
const label = isGlobal ? filePath.replace(homedir2(), "~") : path8.relative(cwd, filePath);
|
|
408731
|
+
allRuleFiles.set(filePath, { filePath, label });
|
|
408732
|
+
}
|
|
408733
|
+
} catch {
|
|
408734
|
+
return;
|
|
408735
|
+
}
|
|
408736
|
+
const dir2 = path8.dirname(filePath);
|
|
408737
|
+
const importRegex = /@([./\\\w-]+.md)/gm;
|
|
408738
|
+
for (const match30 of content.matchAll(importRegex)) {
|
|
408739
|
+
const importPath = path8.resolve(dir2, match30[1]);
|
|
408740
|
+
await processFile(importPath, isGlobal);
|
|
408741
|
+
}
|
|
408742
|
+
};
|
|
408678
408743
|
if (includeGlobalRules) {
|
|
408679
|
-
|
|
408744
|
+
for (const rule of GlobalRules) {
|
|
408745
|
+
await processFile(rule.filePath, true);
|
|
408746
|
+
}
|
|
408680
408747
|
}
|
|
408681
408748
|
if (includeDefaultRules) {
|
|
408682
408749
|
for (const fileName of WorkspaceRulesFilePaths) {
|
|
408683
|
-
const
|
|
408684
|
-
|
|
408685
|
-
filePath: defaultRulesPath,
|
|
408686
|
-
label: fileName
|
|
408687
|
-
});
|
|
408750
|
+
const filePath = path8.join(cwd, fileName);
|
|
408751
|
+
await processFile(filePath, false);
|
|
408688
408752
|
}
|
|
408689
408753
|
}
|
|
408690
|
-
|
|
408691
|
-
|
|
408692
|
-
|
|
408693
|
-
|
|
408694
|
-
|
|
408695
|
-
|
|
408696
|
-
|
|
408754
|
+
for (const rulePath of customRuleFiles) {
|
|
408755
|
+
await processFile(rulePath, false);
|
|
408756
|
+
}
|
|
408757
|
+
return Array.from(allRuleFiles.values());
|
|
408758
|
+
}
|
|
408759
|
+
async function collectCustomRules(cwd, readFileContent, customRuleFiles = [], includeDefaultRules = true, includeGlobalRules = true) {
|
|
408760
|
+
let rules = "";
|
|
408761
|
+
const allRules = await collectAllRuleFiles(cwd, readFileContent, {
|
|
408762
|
+
customRuleFiles,
|
|
408763
|
+
includeDefaultRules,
|
|
408764
|
+
includeGlobalRules
|
|
408765
|
+
});
|
|
408697
408766
|
for (const rule of allRules) {
|
|
408698
408767
|
try {
|
|
408699
|
-
const content = await
|
|
408768
|
+
const content = await readFileContent(rule.filePath) ?? "";
|
|
408700
408769
|
if (content.trim().length > 0) {
|
|
408701
408770
|
rules += `# Rules from ${rule.label}
|
|
408702
408771
|
${content}
|
|
@@ -448746,7 +448815,7 @@ function createPatchedFetchForFinetune(accessToken) {
|
|
|
448746
448815
|
}
|
|
448747
448816
|
function createVertexModel(vertex2, modelId) {
|
|
448748
448817
|
const getBaseURL2 = (location3, projectId) => `https://${location3}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location3}/publishers/google`;
|
|
448749
|
-
if (
|
|
448818
|
+
if (vertex2.type === "service-account") {
|
|
448750
448819
|
const service_account_key = JSON.parse(vertex2.serviceAccountKey);
|
|
448751
448820
|
const location3 = vertex2.location;
|
|
448752
448821
|
const project3 = service_account_key.project_id;
|
|
@@ -448762,7 +448831,7 @@ function createVertexModel(vertex2, modelId) {
|
|
|
448762
448831
|
fetch: createPatchedFetchForFinetune()
|
|
448763
448832
|
})(modelId);
|
|
448764
448833
|
}
|
|
448765
|
-
if (
|
|
448834
|
+
if (vertex2.type === "access-token") {
|
|
448766
448835
|
const { location: location3, projectId, accessToken } = vertex2;
|
|
448767
448836
|
return createVertex({
|
|
448768
448837
|
project: projectId,
|
|
@@ -448771,7 +448840,7 @@ function createVertexModel(vertex2, modelId) {
|
|
|
448771
448840
|
fetch: createPatchedFetchForFinetune(accessToken)
|
|
448772
448841
|
})(modelId);
|
|
448773
448842
|
}
|
|
448774
|
-
if (
|
|
448843
|
+
if (vertex2.type === "model-url") {
|
|
448775
448844
|
const { issueUrl, modelUrl, timeout: timeout5 } = vertex2;
|
|
448776
448845
|
return createVertex({
|
|
448777
448846
|
project: "placeholder",
|
|
@@ -449096,9 +449165,9 @@ async function resolvePromise(o10) {
|
|
|
449096
449165
|
}
|
|
449097
449166
|
return resolved;
|
|
449098
449167
|
}
|
|
449099
|
-
function handleReadFileOutput(store,
|
|
449168
|
+
function handleReadFileOutput(store, readFile9) {
|
|
449100
449169
|
return tool({
|
|
449101
|
-
...
|
|
449170
|
+
...readFile9,
|
|
449102
449171
|
toModelOutput: (output2) => {
|
|
449103
449172
|
if (output2.type === "media") {
|
|
449104
449173
|
const blob3 = findBlob(store, new URL(output2.data), output2.mimeType);
|
|
@@ -449338,6 +449407,7 @@ class LiveChatKit {
|
|
|
449338
449407
|
};
|
|
449339
449408
|
}
|
|
449340
449409
|
// src/lib/read-environment.ts
|
|
449410
|
+
import fs11 from "node:fs/promises";
|
|
449341
449411
|
var readEnvironment = async (context15) => {
|
|
449342
449412
|
const { cwd: cwd2 } = context15;
|
|
449343
449413
|
const { files, isTruncated } = await listWorkspaceFiles({
|
|
@@ -449345,7 +449415,8 @@ var readEnvironment = async (context15) => {
|
|
|
449345
449415
|
recursive: true,
|
|
449346
449416
|
maxItems: 500
|
|
449347
449417
|
});
|
|
449348
|
-
const
|
|
449418
|
+
const readFileContent = async (filePath) => await fs11.readFile(filePath, "utf-8");
|
|
449419
|
+
const customRules = await collectCustomRules(cwd2, readFileContent);
|
|
449349
449420
|
const systemInfo = getSystemInfo2(cwd2);
|
|
449350
449421
|
const gitStatusReader = new GitStatusReader({ cwd: cwd2 });
|
|
449351
449422
|
const gitStatus = await gitStatusReader.readGitStatus();
|
|
@@ -449423,9 +449494,11 @@ class StepCount {
|
|
|
449423
449494
|
throw new MaxRetryReachedError(this.maxRetries);
|
|
449424
449495
|
}
|
|
449425
449496
|
}
|
|
449426
|
-
nextRetry() {
|
|
449497
|
+
async nextRetry() {
|
|
449427
449498
|
this.throwIfReachedMaxRetries();
|
|
449499
|
+
const baseRetryWaitMs = 3000;
|
|
449428
449500
|
this.retry++;
|
|
449501
|
+
await new Promise((resolve11) => setTimeout(resolve11, baseRetryWaitMs * 2 ** this.retry));
|
|
449429
449502
|
}
|
|
449430
449503
|
toString() {
|
|
449431
449504
|
return stepToString(this);
|
|
@@ -449540,7 +449613,7 @@ function executeBashCommand(cwd2, command) {
|
|
|
449540
449613
|
}
|
|
449541
449614
|
|
|
449542
449615
|
// src/tools/apply-diff.ts
|
|
449543
|
-
import * as
|
|
449616
|
+
import * as fs13 from "node:fs/promises";
|
|
449544
449617
|
|
|
449545
449618
|
// ../common/src/diff-utils.ts
|
|
449546
449619
|
var import_fast_levenshtein = __toESM(require_levenshtein(), 1);
|
|
@@ -449753,36 +449826,36 @@ var replaceMatches = (originalContent, matches2, replaceContent) => {
|
|
|
449753
449826
|
};
|
|
449754
449827
|
|
|
449755
449828
|
// src/lib/fs.ts
|
|
449756
|
-
import * as
|
|
449829
|
+
import * as fs12 from "node:fs/promises";
|
|
449757
449830
|
import * as path26 from "node:path";
|
|
449758
449831
|
async function ensureFileDirectoryExists(fileUri) {
|
|
449759
449832
|
const dirUri = path26.join(fileUri, "..");
|
|
449760
|
-
await
|
|
449833
|
+
await fs12.mkdir(dirUri, { recursive: true });
|
|
449761
449834
|
}
|
|
449762
449835
|
|
|
449763
449836
|
// src/tools/apply-diff.ts
|
|
449764
449837
|
var applyDiff2 = () => async ({ path: path27, searchContent, replaceContent, expectedReplacements }, { cwd: cwd2 }) => {
|
|
449765
449838
|
const fileUri = resolvePath(path27, cwd2);
|
|
449766
449839
|
await ensureFileDirectoryExists(fileUri);
|
|
449767
|
-
const fileBuffer = await
|
|
449840
|
+
const fileBuffer = await fs13.readFile(fileUri);
|
|
449768
449841
|
validateTextFile(fileBuffer);
|
|
449769
449842
|
const fileContent3 = fileBuffer.toString();
|
|
449770
449843
|
const updatedContent = await parseDiffAndApply(fileContent3, searchContent, replaceContent, expectedReplacements);
|
|
449771
|
-
await
|
|
449844
|
+
await fs13.writeFile(fileUri, updatedContent);
|
|
449772
449845
|
return { success: true };
|
|
449773
449846
|
};
|
|
449774
449847
|
|
|
449775
449848
|
// src/tools/edit-notebook.ts
|
|
449776
|
-
import * as
|
|
449849
|
+
import * as fs14 from "node:fs/promises";
|
|
449777
449850
|
var editNotebook2 = () => async ({ path: filePath, cellId, content: content3 }, { cwd: cwd2 }) => {
|
|
449778
449851
|
try {
|
|
449779
449852
|
const absolutePath = resolvePath(filePath, cwd2);
|
|
449780
449853
|
validateNotebookPath(absolutePath);
|
|
449781
|
-
const fileContent3 = await
|
|
449854
|
+
const fileContent3 = await fs14.readFile(absolutePath, "utf-8");
|
|
449782
449855
|
const notebook = parseNotebook(fileContent3);
|
|
449783
449856
|
const updatedNotebook = editNotebookCell(notebook, cellId, content3);
|
|
449784
449857
|
const serialized = serializeNotebook(updatedNotebook);
|
|
449785
|
-
await
|
|
449858
|
+
await fs14.writeFile(absolutePath, serialized, "utf-8");
|
|
449786
449859
|
return { success: true };
|
|
449787
449860
|
} catch (error46) {
|
|
449788
449861
|
return { success: false };
|
|
@@ -449895,15 +449968,15 @@ var listFiles3 = () => async ({ path: dirPath, recursive }, { abortSignal, cwd:
|
|
|
449895
449968
|
};
|
|
449896
449969
|
|
|
449897
449970
|
// src/tools/multi-apply-diff.ts
|
|
449898
|
-
import * as
|
|
449971
|
+
import * as fs15 from "node:fs/promises";
|
|
449899
449972
|
var multiApplyDiff2 = () => async ({ path: path28, edits }, { cwd: cwd2 }) => {
|
|
449900
449973
|
const fileUri = resolvePath(path28, cwd2);
|
|
449901
449974
|
await ensureFileDirectoryExists(fileUri);
|
|
449902
|
-
const fileBuffer = await
|
|
449975
|
+
const fileBuffer = await fs15.readFile(fileUri);
|
|
449903
449976
|
validateTextFile(fileBuffer);
|
|
449904
449977
|
const fileContent3 = fileBuffer.toString();
|
|
449905
449978
|
const updatedContent = await processMultipleDiffs(fileContent3, edits);
|
|
449906
|
-
await
|
|
449979
|
+
await fs15.writeFile(fileUri, updatedContent);
|
|
449907
449980
|
return { success: true };
|
|
449908
449981
|
};
|
|
449909
449982
|
|
|
@@ -449941,10 +450014,10 @@ var newTask = (options6) => async ({ _meta, agentType }) => {
|
|
|
449941
450014
|
};
|
|
449942
450015
|
|
|
449943
450016
|
// src/tools/read-file.ts
|
|
449944
|
-
import * as
|
|
449945
|
-
var
|
|
450017
|
+
import * as fs16 from "node:fs/promises";
|
|
450018
|
+
var readFile13 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2, contentType }) => {
|
|
449946
450019
|
const resolvedPath = resolvePath(path28, cwd2);
|
|
449947
|
-
const fileBuffer = await
|
|
450020
|
+
const fileBuffer = await fs16.readFile(resolvedPath);
|
|
449948
450021
|
const isPlainTextFile2 = isPlainText(fileBuffer);
|
|
449949
450022
|
if (contentType && contentType.length > 0 && !isPlainTextFile2) {
|
|
449950
450023
|
return readMediaFile(resolvedPath, fileBuffer, contentType);
|
|
@@ -449962,11 +450035,11 @@ var readFile14 = () => async ({ path: path28, startLine, endLine }, { cwd: cwd2,
|
|
|
449962
450035
|
};
|
|
449963
450036
|
|
|
449964
450037
|
// src/tools/search-files.ts
|
|
449965
|
-
import * as
|
|
450038
|
+
import * as fs17 from "node:fs";
|
|
449966
450039
|
var logger25 = getLogger("searchFiles");
|
|
449967
450040
|
var searchFiles2 = (context15) => async ({ path: path28, regex: regex3, filePattern }, { abortSignal, cwd: cwd2 }) => {
|
|
449968
450041
|
const rgPath = context15.rg;
|
|
449969
|
-
if (!rgPath || !
|
|
450042
|
+
if (!rgPath || !fs17.existsSync(rgPath)) {
|
|
449970
450043
|
logger25.error("Ripgrep not found at path", rgPath);
|
|
449971
450044
|
throw new Error(`Ripgrep not found at path: ${rgPath}`);
|
|
449972
450045
|
}
|
|
@@ -449981,22 +450054,22 @@ var todoWrite2 = (_options) => async () => {
|
|
|
449981
450054
|
};
|
|
449982
450055
|
|
|
449983
450056
|
// src/tools/write-to-file.ts
|
|
449984
|
-
import * as
|
|
450057
|
+
import * as fs18 from "node:fs/promises";
|
|
449985
450058
|
import * as nodePath from "node:path";
|
|
449986
450059
|
var writeToFile2 = () => async ({ path: path28, content: content3 }, { cwd: cwd2 }) => {
|
|
449987
450060
|
const filePath = resolvePath(path28, cwd2);
|
|
449988
450061
|
if (!await isFileExists(filePath)) {
|
|
449989
450062
|
const dirPath = nodePath.dirname(filePath);
|
|
449990
|
-
await
|
|
450063
|
+
await fs18.mkdir(dirPath, { recursive: true });
|
|
449991
450064
|
}
|
|
449992
450065
|
const processedContent = fixCodeGenerationOutput(content3);
|
|
449993
|
-
await
|
|
450066
|
+
await fs18.writeFile(filePath, processedContent);
|
|
449994
450067
|
return { success: true };
|
|
449995
450068
|
};
|
|
449996
450069
|
|
|
449997
450070
|
// src/tools/index.ts
|
|
449998
450071
|
var ToolMap = {
|
|
449999
|
-
readFile:
|
|
450072
|
+
readFile: readFile13,
|
|
450000
450073
|
applyDiff: applyDiff2,
|
|
450001
450074
|
editNotebook: editNotebook2,
|
|
450002
450075
|
globFiles: globFiles3,
|
|
@@ -450139,7 +450212,7 @@ class TaskRunner {
|
|
|
450139
450212
|
break;
|
|
450140
450213
|
}
|
|
450141
450214
|
if (stepResult === "retry") {
|
|
450142
|
-
this.stepCount.nextRetry();
|
|
450215
|
+
await this.stepCount.nextRetry();
|
|
450143
450216
|
} else {
|
|
450144
450217
|
this.stepCount.nextStep();
|
|
450145
450218
|
}
|
|
@@ -450557,7 +450630,7 @@ var program5 = new Command().name("pochi").description(`${source_default.bold("P
|
|
|
450557
450630
|
for (const attachmentPath of attachments) {
|
|
450558
450631
|
try {
|
|
450559
450632
|
const absolutePath = path28.resolve(process.cwd(), attachmentPath);
|
|
450560
|
-
const buffer4 = await
|
|
450633
|
+
const buffer4 = await fs19.readFile(absolutePath);
|
|
450561
450634
|
const mimeType = getMimeType(attachmentPath);
|
|
450562
450635
|
const dataUrl = await fileToUri(store, new File([buffer4], attachmentPath, {
|
|
450563
450636
|
type: mimeType
|