@bike4mind/cli 0.2.1-feat-cli-file-reference.17022 → 0.2.1-feat-cli-file-reference.17024
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/index.js +84 -112
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -95,7 +95,6 @@ var StatusBar = React.memo(function StatusBar2({ sessionName, model, tokenUsage
|
|
|
95
95
|
|
|
96
96
|
// src/components/InputPrompt.tsx
|
|
97
97
|
import React4, { useState, useMemo, useEffect } from "react";
|
|
98
|
-
import path2 from "path";
|
|
99
98
|
import { Box as Box4, Text as Text4, useInput } from "ink";
|
|
100
99
|
import TextInput from "ink-text-input";
|
|
101
100
|
|
|
@@ -404,39 +403,7 @@ function searchCommands(query) {
|
|
|
404
403
|
return results.map((result) => result.item);
|
|
405
404
|
}
|
|
406
405
|
|
|
407
|
-
// src/utils/constants.ts
|
|
408
|
-
var NAME_SUFFIXES = ["jr", "sr", "ii", "iii", "iv", "v", "phd", "md", "esq"];
|
|
409
|
-
function isNameSuffix(value) {
|
|
410
|
-
return NAME_SUFFIXES.includes(value);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
406
|
// src/components/InputPrompt.tsx
|
|
414
|
-
function looksLikeFilePath(query) {
|
|
415
|
-
if (query === "") {
|
|
416
|
-
return true;
|
|
417
|
-
}
|
|
418
|
-
if (query.includes("/") || query.includes(path2.sep)) {
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
const extensionMatch = /\.(\w*)$/.exec(query);
|
|
422
|
-
if (extensionMatch) {
|
|
423
|
-
const ext = extensionMatch[1].toLowerCase();
|
|
424
|
-
if (ext === "") {
|
|
425
|
-
return true;
|
|
426
|
-
}
|
|
427
|
-
if (isNameSuffix(ext)) {
|
|
428
|
-
return false;
|
|
429
|
-
}
|
|
430
|
-
if (ext.length > 10) {
|
|
431
|
-
return false;
|
|
432
|
-
}
|
|
433
|
-
return true;
|
|
434
|
-
}
|
|
435
|
-
if (query.startsWith(".")) {
|
|
436
|
-
return true;
|
|
437
|
-
}
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
407
|
function findAtTrigger(value) {
|
|
441
408
|
for (let i = value.length - 1; i >= 0; i--) {
|
|
442
409
|
if (value[i] === "@") {
|
|
@@ -446,9 +413,6 @@ function findAtTrigger(value) {
|
|
|
446
413
|
if (query.includes(" ")) {
|
|
447
414
|
return null;
|
|
448
415
|
}
|
|
449
|
-
if (!looksLikeFilePath(query)) {
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
416
|
return { startIndex: i, query };
|
|
453
417
|
}
|
|
454
418
|
}
|
|
@@ -691,10 +655,18 @@ function PermissionPrompt({
|
|
|
691
655
|
|
|
692
656
|
// src/utils/processFileReferences.ts
|
|
693
657
|
import * as fs2 from "fs";
|
|
694
|
-
import * as
|
|
658
|
+
import * as path2 from "path";
|
|
659
|
+
|
|
660
|
+
// src/utils/constants.ts
|
|
661
|
+
var NAME_SUFFIXES = ["jr", "sr", "ii", "iii", "iv", "v", "phd", "md", "esq"];
|
|
662
|
+
function isNameSuffix(value) {
|
|
663
|
+
return NAME_SUFFIXES.includes(value);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// src/utils/processFileReferences.ts
|
|
695
667
|
var FILE_REFERENCE_REGEX = /(?:^|\s)@([^\s@]+)/g;
|
|
696
|
-
function
|
|
697
|
-
if (ref.includes("/") || ref.includes(
|
|
668
|
+
function looksLikeFilePath(ref) {
|
|
669
|
+
if (ref.includes("/") || ref.includes(path2.sep)) {
|
|
698
670
|
return true;
|
|
699
671
|
}
|
|
700
672
|
const extensionMatch = /\.(\w+)$/.exec(ref);
|
|
@@ -716,7 +688,7 @@ function extractFileReferences(message) {
|
|
|
716
688
|
let match;
|
|
717
689
|
while ((match = regex.exec(message)) !== null) {
|
|
718
690
|
const ref = match[1];
|
|
719
|
-
if (
|
|
691
|
+
if (looksLikeFilePath(ref)) {
|
|
720
692
|
references.push(ref);
|
|
721
693
|
}
|
|
722
694
|
}
|
|
@@ -724,7 +696,7 @@ function extractFileReferences(message) {
|
|
|
724
696
|
}
|
|
725
697
|
function readFileContents(filePath) {
|
|
726
698
|
const cwd = process.cwd();
|
|
727
|
-
const absolutePath =
|
|
699
|
+
const absolutePath = path2.resolve(cwd, filePath);
|
|
728
700
|
if (!isPathWithinCwd(filePath)) {
|
|
729
701
|
return { error: `Security: Path "${filePath}" is outside the current working directory` };
|
|
730
702
|
}
|
|
@@ -1078,11 +1050,11 @@ function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, o
|
|
|
1078
1050
|
|
|
1079
1051
|
// src/storage/SessionStore.ts
|
|
1080
1052
|
import { promises as fs3 } from "fs";
|
|
1081
|
-
import
|
|
1053
|
+
import path3 from "path";
|
|
1082
1054
|
import { homedir } from "os";
|
|
1083
1055
|
var SessionStore = class {
|
|
1084
1056
|
constructor(basePath) {
|
|
1085
|
-
this.basePath = basePath ||
|
|
1057
|
+
this.basePath = basePath || path3.join(homedir(), ".bike4mind", "sessions");
|
|
1086
1058
|
}
|
|
1087
1059
|
/**
|
|
1088
1060
|
* Initialize storage directory
|
|
@@ -1100,7 +1072,7 @@ var SessionStore = class {
|
|
|
1100
1072
|
*/
|
|
1101
1073
|
async save(session) {
|
|
1102
1074
|
await this.init();
|
|
1103
|
-
const filePath =
|
|
1075
|
+
const filePath = path3.join(this.basePath, `${session.id}.json`);
|
|
1104
1076
|
try {
|
|
1105
1077
|
await fs3.writeFile(filePath, JSON.stringify(session, null, 2), "utf-8");
|
|
1106
1078
|
} catch (error) {
|
|
@@ -1112,7 +1084,7 @@ var SessionStore = class {
|
|
|
1112
1084
|
* Load a session from disk by ID
|
|
1113
1085
|
*/
|
|
1114
1086
|
async load(id) {
|
|
1115
|
-
const filePath =
|
|
1087
|
+
const filePath = path3.join(this.basePath, `${id}.json`);
|
|
1116
1088
|
try {
|
|
1117
1089
|
const data = await fs3.readFile(filePath, "utf-8");
|
|
1118
1090
|
return JSON.parse(data);
|
|
@@ -1142,7 +1114,7 @@ var SessionStore = class {
|
|
|
1142
1114
|
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
|
1143
1115
|
const sessions = await Promise.all(
|
|
1144
1116
|
jsonFiles.map(async (file) => {
|
|
1145
|
-
const filePath =
|
|
1117
|
+
const filePath = path3.join(this.basePath, file);
|
|
1146
1118
|
const data = await fs3.readFile(filePath, "utf-8");
|
|
1147
1119
|
return JSON.parse(data);
|
|
1148
1120
|
})
|
|
@@ -1157,7 +1129,7 @@ var SessionStore = class {
|
|
|
1157
1129
|
* Delete a session
|
|
1158
1130
|
*/
|
|
1159
1131
|
async delete(id) {
|
|
1160
|
-
const filePath =
|
|
1132
|
+
const filePath = path3.join(this.basePath, `${id}.json`);
|
|
1161
1133
|
try {
|
|
1162
1134
|
await fs3.unlink(filePath);
|
|
1163
1135
|
return true;
|
|
@@ -1196,7 +1168,7 @@ var SessionStore = class {
|
|
|
1196
1168
|
|
|
1197
1169
|
// src/storage/ConfigStore.ts
|
|
1198
1170
|
import { promises as fs4 } from "fs";
|
|
1199
|
-
import
|
|
1171
|
+
import path4 from "path";
|
|
1200
1172
|
import { homedir as homedir2 } from "os";
|
|
1201
1173
|
import { v4 as uuidv4 } from "uuid";
|
|
1202
1174
|
import { z } from "zod";
|
|
@@ -1270,13 +1242,13 @@ var DEFAULT_CONFIG = {
|
|
|
1270
1242
|
var ConfigStore = class {
|
|
1271
1243
|
constructor(configPath) {
|
|
1272
1244
|
this.config = null;
|
|
1273
|
-
this.configPath = configPath ||
|
|
1245
|
+
this.configPath = configPath || path4.join(homedir2(), ".bike4mind", "config.json");
|
|
1274
1246
|
}
|
|
1275
1247
|
/**
|
|
1276
1248
|
* Initialize config directory
|
|
1277
1249
|
*/
|
|
1278
1250
|
async init() {
|
|
1279
|
-
const dir =
|
|
1251
|
+
const dir = path4.dirname(this.configPath);
|
|
1280
1252
|
try {
|
|
1281
1253
|
await fs4.mkdir(dir, { recursive: true });
|
|
1282
1254
|
} catch (error) {
|
|
@@ -1523,19 +1495,19 @@ var ConfigStore = class {
|
|
|
1523
1495
|
|
|
1524
1496
|
// src/storage/CommandHistoryStore.ts
|
|
1525
1497
|
import { promises as fs5 } from "fs";
|
|
1526
|
-
import
|
|
1498
|
+
import path5 from "path";
|
|
1527
1499
|
import { homedir as homedir3 } from "os";
|
|
1528
1500
|
var MAX_HISTORY_ENTRIES = 1e3;
|
|
1529
1501
|
var CommandHistoryStore = class {
|
|
1530
1502
|
constructor(historyPath) {
|
|
1531
1503
|
this.history = null;
|
|
1532
|
-
this.historyPath = historyPath ||
|
|
1504
|
+
this.historyPath = historyPath || path5.join(homedir3(), ".bike4mind", "history.jsonl");
|
|
1533
1505
|
}
|
|
1534
1506
|
/**
|
|
1535
1507
|
* Initialize history directory
|
|
1536
1508
|
*/
|
|
1537
1509
|
async init() {
|
|
1538
|
-
const dir =
|
|
1510
|
+
const dir = path5.dirname(this.historyPath);
|
|
1539
1511
|
try {
|
|
1540
1512
|
await fs5.mkdir(dir, { recursive: true });
|
|
1541
1513
|
} catch (error) {
|
|
@@ -4080,8 +4052,8 @@ async function processAndStoreImages(images, context) {
|
|
|
4080
4052
|
const buffer = await downloadImage(image);
|
|
4081
4053
|
const fileType = await fileTypeFromBuffer2(buffer);
|
|
4082
4054
|
const filename = `${uuidv45()}.${fileType?.ext}`;
|
|
4083
|
-
const
|
|
4084
|
-
return
|
|
4055
|
+
const path13 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
4056
|
+
return path13;
|
|
4085
4057
|
}));
|
|
4086
4058
|
}
|
|
4087
4059
|
async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
|
|
@@ -5265,8 +5237,8 @@ async function processAndStoreImage(imageUrl, context) {
|
|
|
5265
5237
|
const buffer = await downloadImage2(imageUrl);
|
|
5266
5238
|
const fileType = await fileTypeFromBuffer3(buffer);
|
|
5267
5239
|
const filename = `${uuidv46()}.${fileType?.ext}`;
|
|
5268
|
-
const
|
|
5269
|
-
return
|
|
5240
|
+
const path13 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
5241
|
+
return path13;
|
|
5270
5242
|
}
|
|
5271
5243
|
async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
|
|
5272
5244
|
await context.onFinish?.("edit_image", storedImagePath);
|
|
@@ -7105,13 +7077,13 @@ var planetVisibilityTool = {
|
|
|
7105
7077
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/fileRead/index.js
|
|
7106
7078
|
import { promises as fs7 } from "fs";
|
|
7107
7079
|
import { existsSync as existsSync2, statSync as statSync3 } from "fs";
|
|
7108
|
-
import
|
|
7080
|
+
import path6 from "path";
|
|
7109
7081
|
var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
|
|
7110
7082
|
async function readFileContent(params) {
|
|
7111
7083
|
const { path: filePath, encoding = "utf-8", maxLines } = params;
|
|
7112
|
-
const normalizedPath =
|
|
7113
|
-
const resolvedPath =
|
|
7114
|
-
const cwd =
|
|
7084
|
+
const normalizedPath = path6.normalize(filePath);
|
|
7085
|
+
const resolvedPath = path6.resolve(process.cwd(), normalizedPath);
|
|
7086
|
+
const cwd = path6.resolve(process.cwd());
|
|
7115
7087
|
if (!resolvedPath.startsWith(cwd)) {
|
|
7116
7088
|
throw new Error(`Access denied: Cannot read files outside of current working directory`);
|
|
7117
7089
|
}
|
|
@@ -7161,7 +7133,7 @@ var fileReadTool = {
|
|
|
7161
7133
|
context.logger.info("\u{1F4C4} FileRead: Reading file", { path: params.path });
|
|
7162
7134
|
try {
|
|
7163
7135
|
const content = await readFileContent(params);
|
|
7164
|
-
const stats = statSync3(
|
|
7136
|
+
const stats = statSync3(path6.resolve(process.cwd(), path6.normalize(params.path)));
|
|
7165
7137
|
context.logger.info("\u2705 FileRead: Success", {
|
|
7166
7138
|
path: params.path,
|
|
7167
7139
|
size: stats.size,
|
|
@@ -7202,19 +7174,19 @@ var fileReadTool = {
|
|
|
7202
7174
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/createFile/index.js
|
|
7203
7175
|
import { promises as fs8 } from "fs";
|
|
7204
7176
|
import { existsSync as existsSync3 } from "fs";
|
|
7205
|
-
import
|
|
7177
|
+
import path7 from "path";
|
|
7206
7178
|
async function createFile(params) {
|
|
7207
7179
|
const { path: filePath, content, createDirectories = true } = params;
|
|
7208
|
-
const normalizedPath =
|
|
7209
|
-
const resolvedPath =
|
|
7210
|
-
const cwd =
|
|
7180
|
+
const normalizedPath = path7.normalize(filePath);
|
|
7181
|
+
const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
|
|
7182
|
+
const cwd = path7.resolve(process.cwd());
|
|
7211
7183
|
if (!resolvedPath.startsWith(cwd)) {
|
|
7212
7184
|
throw new Error(`Access denied: Cannot create files outside of current working directory`);
|
|
7213
7185
|
}
|
|
7214
7186
|
const fileExists = existsSync3(resolvedPath);
|
|
7215
7187
|
const action = fileExists ? "overwritten" : "created";
|
|
7216
7188
|
if (createDirectories) {
|
|
7217
|
-
const dir =
|
|
7189
|
+
const dir = path7.dirname(resolvedPath);
|
|
7218
7190
|
await fs8.mkdir(dir, { recursive: true });
|
|
7219
7191
|
}
|
|
7220
7192
|
await fs8.writeFile(resolvedPath, content, "utf-8");
|
|
@@ -7229,7 +7201,7 @@ var createFileTool = {
|
|
|
7229
7201
|
implementation: (context) => ({
|
|
7230
7202
|
toolFn: async (value) => {
|
|
7231
7203
|
const params = value;
|
|
7232
|
-
const fileExists = existsSync3(
|
|
7204
|
+
const fileExists = existsSync3(path7.resolve(process.cwd(), path7.normalize(params.path)));
|
|
7233
7205
|
context.logger.info(`\u{1F4DD} CreateFile: ${fileExists ? "Overwriting" : "Creating"} file`, {
|
|
7234
7206
|
path: params.path,
|
|
7235
7207
|
size: params.content.length
|
|
@@ -7271,7 +7243,7 @@ var createFileTool = {
|
|
|
7271
7243
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/globFiles/index.js
|
|
7272
7244
|
import { readdir } from "fs/promises";
|
|
7273
7245
|
import { statSync as statSync4 } from "fs";
|
|
7274
|
-
import
|
|
7246
|
+
import path8 from "path";
|
|
7275
7247
|
function matchGlob(filePath, pattern) {
|
|
7276
7248
|
let regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
|
|
7277
7249
|
regexPattern = regexPattern.replace(/\{\{GLOBSTAR\}\}\//g, "(.*/)?").replace(/\/\{\{GLOBSTAR\}\}/g, "(/.*)?").replace(/\{\{GLOBSTAR\}\}/g, ".*");
|
|
@@ -7289,8 +7261,8 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
|
|
|
7289
7261
|
if (!includeHidden && entry.name.startsWith(".")) {
|
|
7290
7262
|
continue;
|
|
7291
7263
|
}
|
|
7292
|
-
const relativePath = basePath ?
|
|
7293
|
-
const fullPath =
|
|
7264
|
+
const relativePath = basePath ? path8.join(basePath, entry.name) : entry.name;
|
|
7265
|
+
const fullPath = path8.join(dir, entry.name);
|
|
7294
7266
|
if (matchGlob(relativePath, pattern)) {
|
|
7295
7267
|
matches.push(relativePath);
|
|
7296
7268
|
}
|
|
@@ -7306,7 +7278,7 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
|
|
|
7306
7278
|
async function listFiles(params) {
|
|
7307
7279
|
const { pattern, cwd: relativeCwd, includeHidden = false, maxResults = 1e3 } = params;
|
|
7308
7280
|
const baseCwd = process.cwd();
|
|
7309
|
-
const targetCwd = relativeCwd ?
|
|
7281
|
+
const targetCwd = relativeCwd ? path8.resolve(baseCwd, path8.normalize(relativeCwd)) : baseCwd;
|
|
7310
7282
|
if (!targetCwd.startsWith(baseCwd)) {
|
|
7311
7283
|
throw new Error(`Access denied: Cannot list files outside of current working directory`);
|
|
7312
7284
|
}
|
|
@@ -7317,7 +7289,7 @@ async function listFiles(params) {
|
|
|
7317
7289
|
const filesInfo = [];
|
|
7318
7290
|
for (const match of matches) {
|
|
7319
7291
|
try {
|
|
7320
|
-
const fullPath =
|
|
7292
|
+
const fullPath = path8.join(targetCwd, match);
|
|
7321
7293
|
const stats = statSync4(fullPath);
|
|
7322
7294
|
filesInfo.push({
|
|
7323
7295
|
path: match,
|
|
@@ -7400,7 +7372,7 @@ var globFilesTool = {
|
|
|
7400
7372
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
|
|
7401
7373
|
import { readdir as readdir2 } from "fs/promises";
|
|
7402
7374
|
import { readFileSync as readFileSync2, statSync as statSync5 } from "fs";
|
|
7403
|
-
import
|
|
7375
|
+
import path9 from "path";
|
|
7404
7376
|
var MAX_FILE_SIZE3 = 10 * 1024 * 1024;
|
|
7405
7377
|
function matchGlob2(filePath, pattern) {
|
|
7406
7378
|
const regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\{\{GLOBSTAR\}\}/g, ".*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
|
|
@@ -7418,8 +7390,8 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
|
|
|
7418
7390
|
if (entry.name.startsWith(".")) {
|
|
7419
7391
|
continue;
|
|
7420
7392
|
}
|
|
7421
|
-
const relativePath = basePath ?
|
|
7422
|
-
const fullPath =
|
|
7393
|
+
const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
|
|
7394
|
+
const fullPath = path9.join(dir, entry.name);
|
|
7423
7395
|
if (matchGlob2(relativePath, pattern)) {
|
|
7424
7396
|
matches.push(relativePath);
|
|
7425
7397
|
}
|
|
@@ -7435,7 +7407,7 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
|
|
|
7435
7407
|
async function searchFiles2(params) {
|
|
7436
7408
|
const { pattern, filePattern = "**/*", cwd: relativeCwd, caseSensitive = false, maxResults = 100, contextLines = 0 } = params;
|
|
7437
7409
|
const baseCwd = process.cwd();
|
|
7438
|
-
const targetCwd = relativeCwd ?
|
|
7410
|
+
const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
|
|
7439
7411
|
if (!targetCwd.startsWith(baseCwd)) {
|
|
7440
7412
|
throw new Error(`Access denied: Cannot search files outside of current working directory`);
|
|
7441
7413
|
}
|
|
@@ -7449,7 +7421,7 @@ async function searchFiles2(params) {
|
|
|
7449
7421
|
const filesToSearch = await walkDir2(targetCwd, filePattern, 1e4);
|
|
7450
7422
|
const filteredFiles = [];
|
|
7451
7423
|
for (const match of filesToSearch) {
|
|
7452
|
-
const fullPath =
|
|
7424
|
+
const fullPath = path9.join(targetCwd, match);
|
|
7453
7425
|
try {
|
|
7454
7426
|
const stats = statSync5(fullPath);
|
|
7455
7427
|
if (stats.isDirectory() || stats.size > MAX_FILE_SIZE3) {
|
|
@@ -7473,7 +7445,7 @@ async function searchFiles2(params) {
|
|
|
7473
7445
|
break;
|
|
7474
7446
|
}
|
|
7475
7447
|
filesSearched++;
|
|
7476
|
-
const fullPath =
|
|
7448
|
+
const fullPath = path9.join(targetCwd, file);
|
|
7477
7449
|
try {
|
|
7478
7450
|
const content = readFileSync2(fullPath, "utf-8");
|
|
7479
7451
|
const lines = content.split("\n");
|
|
@@ -7610,12 +7582,12 @@ var grepSearchTool = {
|
|
|
7610
7582
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/deleteFile/index.js
|
|
7611
7583
|
import { promises as fs9 } from "fs";
|
|
7612
7584
|
import { existsSync as existsSync4, statSync as statSync6 } from "fs";
|
|
7613
|
-
import
|
|
7585
|
+
import path10 from "path";
|
|
7614
7586
|
async function deleteFile(params) {
|
|
7615
7587
|
const { path: filePath, recursive = false } = params;
|
|
7616
|
-
const normalizedPath =
|
|
7617
|
-
const resolvedPath =
|
|
7618
|
-
const cwd =
|
|
7588
|
+
const normalizedPath = path10.normalize(filePath);
|
|
7589
|
+
const resolvedPath = path10.resolve(process.cwd(), normalizedPath);
|
|
7590
|
+
const cwd = path10.resolve(process.cwd());
|
|
7619
7591
|
if (!resolvedPath.startsWith(cwd)) {
|
|
7620
7592
|
throw new Error(`Access denied: Cannot delete files outside of current working directory`);
|
|
7621
7593
|
}
|
|
@@ -7642,7 +7614,7 @@ var deleteFileTool = {
|
|
|
7642
7614
|
implementation: (context) => ({
|
|
7643
7615
|
toolFn: async (value) => {
|
|
7644
7616
|
const params = value;
|
|
7645
|
-
const resolvedPath =
|
|
7617
|
+
const resolvedPath = path10.resolve(process.cwd(), path10.normalize(params.path));
|
|
7646
7618
|
const isDirectory = existsSync4(resolvedPath) && statSync6(resolvedPath).isDirectory();
|
|
7647
7619
|
context.logger.info(`\u{1F5D1}\uFE0F DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
|
|
7648
7620
|
path: params.path,
|
|
@@ -7985,21 +7957,21 @@ var NoOpStorage = class extends BaseStorage {
|
|
|
7985
7957
|
async upload(input, destination, options) {
|
|
7986
7958
|
return `/tmp/${destination}`;
|
|
7987
7959
|
}
|
|
7988
|
-
async download(
|
|
7960
|
+
async download(path13) {
|
|
7989
7961
|
throw new Error("Download not supported in CLI");
|
|
7990
7962
|
}
|
|
7991
|
-
async delete(
|
|
7963
|
+
async delete(path13) {
|
|
7992
7964
|
}
|
|
7993
|
-
async getSignedUrl(
|
|
7994
|
-
return `/tmp/${
|
|
7965
|
+
async getSignedUrl(path13) {
|
|
7966
|
+
return `/tmp/${path13}`;
|
|
7995
7967
|
}
|
|
7996
|
-
getPublicUrl(
|
|
7997
|
-
return `/tmp/${
|
|
7968
|
+
getPublicUrl(path13) {
|
|
7969
|
+
return `/tmp/${path13}`;
|
|
7998
7970
|
}
|
|
7999
|
-
async getPreview(
|
|
8000
|
-
return `/tmp/${
|
|
7971
|
+
async getPreview(path13) {
|
|
7972
|
+
return `/tmp/${path13}`;
|
|
8001
7973
|
}
|
|
8002
|
-
async getMetadata(
|
|
7974
|
+
async getMetadata(path13) {
|
|
8003
7975
|
return { size: 0, contentType: "application/octet-stream" };
|
|
8004
7976
|
}
|
|
8005
7977
|
};
|
|
@@ -8326,7 +8298,7 @@ function getEnvironmentName(configApiConfig) {
|
|
|
8326
8298
|
|
|
8327
8299
|
// src/utils/Logger.ts
|
|
8328
8300
|
import fs10 from "fs/promises";
|
|
8329
|
-
import
|
|
8301
|
+
import path11 from "path";
|
|
8330
8302
|
import os from "os";
|
|
8331
8303
|
var Logger2 = class _Logger {
|
|
8332
8304
|
constructor() {
|
|
@@ -8349,9 +8321,9 @@ var Logger2 = class _Logger {
|
|
|
8349
8321
|
*/
|
|
8350
8322
|
async initialize(sessionId) {
|
|
8351
8323
|
this.sessionId = sessionId;
|
|
8352
|
-
const debugDir =
|
|
8324
|
+
const debugDir = path11.join(os.homedir(), ".bike4mind", "debug");
|
|
8353
8325
|
await fs10.mkdir(debugDir, { recursive: true });
|
|
8354
|
-
this.logFilePath =
|
|
8326
|
+
this.logFilePath = path11.join(debugDir, `${sessionId}.txt`);
|
|
8355
8327
|
await this.writeToFile("INFO", "=== CLI SESSION START ===");
|
|
8356
8328
|
}
|
|
8357
8329
|
/**
|
|
@@ -8561,12 +8533,12 @@ var Logger2 = class _Logger {
|
|
|
8561
8533
|
async cleanupOldLogs() {
|
|
8562
8534
|
if (!this.fileLoggingEnabled) return;
|
|
8563
8535
|
try {
|
|
8564
|
-
const debugDir =
|
|
8536
|
+
const debugDir = path11.join(os.homedir(), ".bike4mind", "debug");
|
|
8565
8537
|
const files = await fs10.readdir(debugDir);
|
|
8566
8538
|
const now = Date.now();
|
|
8567
8539
|
const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
|
|
8568
8540
|
for (const file of files) {
|
|
8569
|
-
const filePath =
|
|
8541
|
+
const filePath = path11.join(debugDir, file);
|
|
8570
8542
|
const stats = await fs10.stat(filePath);
|
|
8571
8543
|
if (stats.mtime.getTime() < thirtyDaysAgo) {
|
|
8572
8544
|
await fs10.unlink(filePath);
|
|
@@ -8582,7 +8554,7 @@ var logger = Logger2.getInstance();
|
|
|
8582
8554
|
// ../../b4m-core/packages/mcp/dist/src/client.js
|
|
8583
8555
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
8584
8556
|
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8585
|
-
import
|
|
8557
|
+
import path12 from "path";
|
|
8586
8558
|
import { existsSync as existsSync6, readdirSync as readdirSync3 } from "fs";
|
|
8587
8559
|
var MCPClient = class {
|
|
8588
8560
|
// Note: This class handles MCP server communication with repository filtering
|
|
@@ -8608,16 +8580,16 @@ var MCPClient = class {
|
|
|
8608
8580
|
const root = process.env.INIT_CWD || process.cwd();
|
|
8609
8581
|
const candidatePaths = [
|
|
8610
8582
|
// When running from SST Lambda with node_modules structure (copyFiles)
|
|
8611
|
-
|
|
8583
|
+
path12.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
|
|
8612
8584
|
// When running from SST Lambda deployed environment (/var/task)
|
|
8613
|
-
|
|
8585
|
+
path12.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8614
8586
|
// When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
|
|
8615
|
-
|
|
8587
|
+
path12.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8616
8588
|
// When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
|
|
8617
|
-
|
|
8589
|
+
path12.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8618
8590
|
// Original paths (backward compatibility)
|
|
8619
|
-
|
|
8620
|
-
|
|
8591
|
+
path12.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8592
|
+
path12.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
|
|
8621
8593
|
];
|
|
8622
8594
|
const serverScriptPath = candidatePaths.find((p) => existsSync6(p));
|
|
8623
8595
|
if (!serverScriptPath) {
|
|
@@ -9198,7 +9170,7 @@ var ApiClient = class {
|
|
|
9198
9170
|
// package.json
|
|
9199
9171
|
var package_default = {
|
|
9200
9172
|
name: "@bike4mind/cli",
|
|
9201
|
-
version: "0.2.1-feat-cli-file-reference.
|
|
9173
|
+
version: "0.2.1-feat-cli-file-reference.17024+3bc00b63c",
|
|
9202
9174
|
type: "module",
|
|
9203
9175
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
9204
9176
|
license: "UNLICENSED",
|
|
@@ -9300,10 +9272,10 @@ var package_default = {
|
|
|
9300
9272
|
},
|
|
9301
9273
|
devDependencies: {
|
|
9302
9274
|
"@bike4mind/agents": "0.1.0",
|
|
9303
|
-
"@bike4mind/common": "2.36.1-feat-cli-file-reference.
|
|
9304
|
-
"@bike4mind/mcp": "1.19.4-feat-cli-file-reference.
|
|
9305
|
-
"@bike4mind/services": "2.29.1-feat-cli-file-reference.
|
|
9306
|
-
"@bike4mind/utils": "2.0.3-feat-cli-file-reference.
|
|
9275
|
+
"@bike4mind/common": "2.36.1-feat-cli-file-reference.17024+3bc00b63c",
|
|
9276
|
+
"@bike4mind/mcp": "1.19.4-feat-cli-file-reference.17024+3bc00b63c",
|
|
9277
|
+
"@bike4mind/services": "2.29.1-feat-cli-file-reference.17024+3bc00b63c",
|
|
9278
|
+
"@bike4mind/utils": "2.0.3-feat-cli-file-reference.17024+3bc00b63c",
|
|
9307
9279
|
"@types/diff": "^5.0.9",
|
|
9308
9280
|
"@types/jsonwebtoken": "^9.0.4",
|
|
9309
9281
|
"@types/node": "^22.9.0",
|
|
@@ -9315,7 +9287,7 @@ var package_default = {
|
|
|
9315
9287
|
typescript: "^5.9.3",
|
|
9316
9288
|
vitest: "^3.2.4"
|
|
9317
9289
|
},
|
|
9318
|
-
gitHead: "
|
|
9290
|
+
gitHead: "3bc00b63c23e8153e62c6f7f28671702dfc0deba"
|
|
9319
9291
|
};
|
|
9320
9292
|
|
|
9321
9293
|
// src/index.tsx
|
|
@@ -9577,7 +9549,7 @@ Remember: Use context from previous messages to understand follow-up questions.`
|
|
|
9577
9549
|
llm,
|
|
9578
9550
|
model: modelInfo.id,
|
|
9579
9551
|
tools: allTools,
|
|
9580
|
-
maxIterations:
|
|
9552
|
+
maxIterations: 10,
|
|
9581
9553
|
maxTokens: config.preferences.maxTokens,
|
|
9582
9554
|
temperature: config.preferences.temperature,
|
|
9583
9555
|
systemPrompt: cliSystemPrompt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bike4mind/cli",
|
|
3
|
-
"version": "0.2.1-feat-cli-file-reference.
|
|
3
|
+
"version": "0.2.1-feat-cli-file-reference.17024+3bc00b63c",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -102,10 +102,10 @@
|
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@bike4mind/agents": "0.1.0",
|
|
105
|
-
"@bike4mind/common": "2.36.1-feat-cli-file-reference.
|
|
106
|
-
"@bike4mind/mcp": "1.19.4-feat-cli-file-reference.
|
|
107
|
-
"@bike4mind/services": "2.29.1-feat-cli-file-reference.
|
|
108
|
-
"@bike4mind/utils": "2.0.3-feat-cli-file-reference.
|
|
105
|
+
"@bike4mind/common": "2.36.1-feat-cli-file-reference.17024+3bc00b63c",
|
|
106
|
+
"@bike4mind/mcp": "1.19.4-feat-cli-file-reference.17024+3bc00b63c",
|
|
107
|
+
"@bike4mind/services": "2.29.1-feat-cli-file-reference.17024+3bc00b63c",
|
|
108
|
+
"@bike4mind/utils": "2.0.3-feat-cli-file-reference.17024+3bc00b63c",
|
|
109
109
|
"@types/diff": "^5.0.9",
|
|
110
110
|
"@types/jsonwebtoken": "^9.0.4",
|
|
111
111
|
"@types/node": "^22.9.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"typescript": "^5.9.3",
|
|
118
118
|
"vitest": "^3.2.4"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "3bc00b63c23e8153e62c6f7f28671702dfc0deba"
|
|
121
121
|
}
|