@bike4mind/cli 0.2.1-feat-cli-file-reference.17022 → 0.2.1-feat-cli-file-reference.17023
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 +86 -108
- 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,38 +403,9 @@ 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
|
|
415
|
-
|
|
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;
|
|
407
|
+
function shouldShowFileAutocomplete(_query) {
|
|
408
|
+
return true;
|
|
439
409
|
}
|
|
440
410
|
function findAtTrigger(value) {
|
|
441
411
|
for (let i = value.length - 1; i >= 0; i--) {
|
|
@@ -446,7 +416,7 @@ function findAtTrigger(value) {
|
|
|
446
416
|
if (query.includes(" ")) {
|
|
447
417
|
return null;
|
|
448
418
|
}
|
|
449
|
-
if (!
|
|
419
|
+
if (!shouldShowFileAutocomplete(query)) {
|
|
450
420
|
return null;
|
|
451
421
|
}
|
|
452
422
|
return { startIndex: i, query };
|
|
@@ -691,10 +661,18 @@ function PermissionPrompt({
|
|
|
691
661
|
|
|
692
662
|
// src/utils/processFileReferences.ts
|
|
693
663
|
import * as fs2 from "fs";
|
|
694
|
-
import * as
|
|
664
|
+
import * as path2 from "path";
|
|
665
|
+
|
|
666
|
+
// src/utils/constants.ts
|
|
667
|
+
var NAME_SUFFIXES = ["jr", "sr", "ii", "iii", "iv", "v", "phd", "md", "esq"];
|
|
668
|
+
function isNameSuffix(value) {
|
|
669
|
+
return NAME_SUFFIXES.includes(value);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// src/utils/processFileReferences.ts
|
|
695
673
|
var FILE_REFERENCE_REGEX = /(?:^|\s)@([^\s@]+)/g;
|
|
696
|
-
function
|
|
697
|
-
if (ref.includes("/") || ref.includes(
|
|
674
|
+
function looksLikeFilePath(ref) {
|
|
675
|
+
if (ref.includes("/") || ref.includes(path2.sep)) {
|
|
698
676
|
return true;
|
|
699
677
|
}
|
|
700
678
|
const extensionMatch = /\.(\w+)$/.exec(ref);
|
|
@@ -716,7 +694,7 @@ function extractFileReferences(message) {
|
|
|
716
694
|
let match;
|
|
717
695
|
while ((match = regex.exec(message)) !== null) {
|
|
718
696
|
const ref = match[1];
|
|
719
|
-
if (
|
|
697
|
+
if (looksLikeFilePath(ref)) {
|
|
720
698
|
references.push(ref);
|
|
721
699
|
}
|
|
722
700
|
}
|
|
@@ -724,7 +702,7 @@ function extractFileReferences(message) {
|
|
|
724
702
|
}
|
|
725
703
|
function readFileContents(filePath) {
|
|
726
704
|
const cwd = process.cwd();
|
|
727
|
-
const absolutePath =
|
|
705
|
+
const absolutePath = path2.resolve(cwd, filePath);
|
|
728
706
|
if (!isPathWithinCwd(filePath)) {
|
|
729
707
|
return { error: `Security: Path "${filePath}" is outside the current working directory` };
|
|
730
708
|
}
|
|
@@ -1078,11 +1056,11 @@ function LoginFlow({ apiUrl = "http://localhost:3000", configStore, onSuccess, o
|
|
|
1078
1056
|
|
|
1079
1057
|
// src/storage/SessionStore.ts
|
|
1080
1058
|
import { promises as fs3 } from "fs";
|
|
1081
|
-
import
|
|
1059
|
+
import path3 from "path";
|
|
1082
1060
|
import { homedir } from "os";
|
|
1083
1061
|
var SessionStore = class {
|
|
1084
1062
|
constructor(basePath) {
|
|
1085
|
-
this.basePath = basePath ||
|
|
1063
|
+
this.basePath = basePath || path3.join(homedir(), ".bike4mind", "sessions");
|
|
1086
1064
|
}
|
|
1087
1065
|
/**
|
|
1088
1066
|
* Initialize storage directory
|
|
@@ -1100,7 +1078,7 @@ var SessionStore = class {
|
|
|
1100
1078
|
*/
|
|
1101
1079
|
async save(session) {
|
|
1102
1080
|
await this.init();
|
|
1103
|
-
const filePath =
|
|
1081
|
+
const filePath = path3.join(this.basePath, `${session.id}.json`);
|
|
1104
1082
|
try {
|
|
1105
1083
|
await fs3.writeFile(filePath, JSON.stringify(session, null, 2), "utf-8");
|
|
1106
1084
|
} catch (error) {
|
|
@@ -1112,7 +1090,7 @@ var SessionStore = class {
|
|
|
1112
1090
|
* Load a session from disk by ID
|
|
1113
1091
|
*/
|
|
1114
1092
|
async load(id) {
|
|
1115
|
-
const filePath =
|
|
1093
|
+
const filePath = path3.join(this.basePath, `${id}.json`);
|
|
1116
1094
|
try {
|
|
1117
1095
|
const data = await fs3.readFile(filePath, "utf-8");
|
|
1118
1096
|
return JSON.parse(data);
|
|
@@ -1142,7 +1120,7 @@ var SessionStore = class {
|
|
|
1142
1120
|
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
|
1143
1121
|
const sessions = await Promise.all(
|
|
1144
1122
|
jsonFiles.map(async (file) => {
|
|
1145
|
-
const filePath =
|
|
1123
|
+
const filePath = path3.join(this.basePath, file);
|
|
1146
1124
|
const data = await fs3.readFile(filePath, "utf-8");
|
|
1147
1125
|
return JSON.parse(data);
|
|
1148
1126
|
})
|
|
@@ -1157,7 +1135,7 @@ var SessionStore = class {
|
|
|
1157
1135
|
* Delete a session
|
|
1158
1136
|
*/
|
|
1159
1137
|
async delete(id) {
|
|
1160
|
-
const filePath =
|
|
1138
|
+
const filePath = path3.join(this.basePath, `${id}.json`);
|
|
1161
1139
|
try {
|
|
1162
1140
|
await fs3.unlink(filePath);
|
|
1163
1141
|
return true;
|
|
@@ -1196,7 +1174,7 @@ var SessionStore = class {
|
|
|
1196
1174
|
|
|
1197
1175
|
// src/storage/ConfigStore.ts
|
|
1198
1176
|
import { promises as fs4 } from "fs";
|
|
1199
|
-
import
|
|
1177
|
+
import path4 from "path";
|
|
1200
1178
|
import { homedir as homedir2 } from "os";
|
|
1201
1179
|
import { v4 as uuidv4 } from "uuid";
|
|
1202
1180
|
import { z } from "zod";
|
|
@@ -1270,13 +1248,13 @@ var DEFAULT_CONFIG = {
|
|
|
1270
1248
|
var ConfigStore = class {
|
|
1271
1249
|
constructor(configPath) {
|
|
1272
1250
|
this.config = null;
|
|
1273
|
-
this.configPath = configPath ||
|
|
1251
|
+
this.configPath = configPath || path4.join(homedir2(), ".bike4mind", "config.json");
|
|
1274
1252
|
}
|
|
1275
1253
|
/**
|
|
1276
1254
|
* Initialize config directory
|
|
1277
1255
|
*/
|
|
1278
1256
|
async init() {
|
|
1279
|
-
const dir =
|
|
1257
|
+
const dir = path4.dirname(this.configPath);
|
|
1280
1258
|
try {
|
|
1281
1259
|
await fs4.mkdir(dir, { recursive: true });
|
|
1282
1260
|
} catch (error) {
|
|
@@ -1523,19 +1501,19 @@ var ConfigStore = class {
|
|
|
1523
1501
|
|
|
1524
1502
|
// src/storage/CommandHistoryStore.ts
|
|
1525
1503
|
import { promises as fs5 } from "fs";
|
|
1526
|
-
import
|
|
1504
|
+
import path5 from "path";
|
|
1527
1505
|
import { homedir as homedir3 } from "os";
|
|
1528
1506
|
var MAX_HISTORY_ENTRIES = 1e3;
|
|
1529
1507
|
var CommandHistoryStore = class {
|
|
1530
1508
|
constructor(historyPath) {
|
|
1531
1509
|
this.history = null;
|
|
1532
|
-
this.historyPath = historyPath ||
|
|
1510
|
+
this.historyPath = historyPath || path5.join(homedir3(), ".bike4mind", "history.jsonl");
|
|
1533
1511
|
}
|
|
1534
1512
|
/**
|
|
1535
1513
|
* Initialize history directory
|
|
1536
1514
|
*/
|
|
1537
1515
|
async init() {
|
|
1538
|
-
const dir =
|
|
1516
|
+
const dir = path5.dirname(this.historyPath);
|
|
1539
1517
|
try {
|
|
1540
1518
|
await fs5.mkdir(dir, { recursive: true });
|
|
1541
1519
|
} catch (error) {
|
|
@@ -4080,8 +4058,8 @@ async function processAndStoreImages(images, context) {
|
|
|
4080
4058
|
const buffer = await downloadImage(image);
|
|
4081
4059
|
const fileType = await fileTypeFromBuffer2(buffer);
|
|
4082
4060
|
const filename = `${uuidv45()}.${fileType?.ext}`;
|
|
4083
|
-
const
|
|
4084
|
-
return
|
|
4061
|
+
const path13 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
4062
|
+
return path13;
|
|
4085
4063
|
}));
|
|
4086
4064
|
}
|
|
4087
4065
|
async function updateQuestAndReturnMarkdown(storedImageUrls, context) {
|
|
@@ -5265,8 +5243,8 @@ async function processAndStoreImage(imageUrl, context) {
|
|
|
5265
5243
|
const buffer = await downloadImage2(imageUrl);
|
|
5266
5244
|
const fileType = await fileTypeFromBuffer3(buffer);
|
|
5267
5245
|
const filename = `${uuidv46()}.${fileType?.ext}`;
|
|
5268
|
-
const
|
|
5269
|
-
return
|
|
5246
|
+
const path13 = await context.imageGenerateStorage.upload(buffer, filename, {});
|
|
5247
|
+
return path13;
|
|
5270
5248
|
}
|
|
5271
5249
|
async function updateQuestAndReturnMarkdown2(storedImagePath, context) {
|
|
5272
5250
|
await context.onFinish?.("edit_image", storedImagePath);
|
|
@@ -7105,13 +7083,13 @@ var planetVisibilityTool = {
|
|
|
7105
7083
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/fileRead/index.js
|
|
7106
7084
|
import { promises as fs7 } from "fs";
|
|
7107
7085
|
import { existsSync as existsSync2, statSync as statSync3 } from "fs";
|
|
7108
|
-
import
|
|
7086
|
+
import path6 from "path";
|
|
7109
7087
|
var MAX_FILE_SIZE2 = 10 * 1024 * 1024;
|
|
7110
7088
|
async function readFileContent(params) {
|
|
7111
7089
|
const { path: filePath, encoding = "utf-8", maxLines } = params;
|
|
7112
|
-
const normalizedPath =
|
|
7113
|
-
const resolvedPath =
|
|
7114
|
-
const cwd =
|
|
7090
|
+
const normalizedPath = path6.normalize(filePath);
|
|
7091
|
+
const resolvedPath = path6.resolve(process.cwd(), normalizedPath);
|
|
7092
|
+
const cwd = path6.resolve(process.cwd());
|
|
7115
7093
|
if (!resolvedPath.startsWith(cwd)) {
|
|
7116
7094
|
throw new Error(`Access denied: Cannot read files outside of current working directory`);
|
|
7117
7095
|
}
|
|
@@ -7161,7 +7139,7 @@ var fileReadTool = {
|
|
|
7161
7139
|
context.logger.info("\u{1F4C4} FileRead: Reading file", { path: params.path });
|
|
7162
7140
|
try {
|
|
7163
7141
|
const content = await readFileContent(params);
|
|
7164
|
-
const stats = statSync3(
|
|
7142
|
+
const stats = statSync3(path6.resolve(process.cwd(), path6.normalize(params.path)));
|
|
7165
7143
|
context.logger.info("\u2705 FileRead: Success", {
|
|
7166
7144
|
path: params.path,
|
|
7167
7145
|
size: stats.size,
|
|
@@ -7202,19 +7180,19 @@ var fileReadTool = {
|
|
|
7202
7180
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/createFile/index.js
|
|
7203
7181
|
import { promises as fs8 } from "fs";
|
|
7204
7182
|
import { existsSync as existsSync3 } from "fs";
|
|
7205
|
-
import
|
|
7183
|
+
import path7 from "path";
|
|
7206
7184
|
async function createFile(params) {
|
|
7207
7185
|
const { path: filePath, content, createDirectories = true } = params;
|
|
7208
|
-
const normalizedPath =
|
|
7209
|
-
const resolvedPath =
|
|
7210
|
-
const cwd =
|
|
7186
|
+
const normalizedPath = path7.normalize(filePath);
|
|
7187
|
+
const resolvedPath = path7.resolve(process.cwd(), normalizedPath);
|
|
7188
|
+
const cwd = path7.resolve(process.cwd());
|
|
7211
7189
|
if (!resolvedPath.startsWith(cwd)) {
|
|
7212
7190
|
throw new Error(`Access denied: Cannot create files outside of current working directory`);
|
|
7213
7191
|
}
|
|
7214
7192
|
const fileExists = existsSync3(resolvedPath);
|
|
7215
7193
|
const action = fileExists ? "overwritten" : "created";
|
|
7216
7194
|
if (createDirectories) {
|
|
7217
|
-
const dir =
|
|
7195
|
+
const dir = path7.dirname(resolvedPath);
|
|
7218
7196
|
await fs8.mkdir(dir, { recursive: true });
|
|
7219
7197
|
}
|
|
7220
7198
|
await fs8.writeFile(resolvedPath, content, "utf-8");
|
|
@@ -7229,7 +7207,7 @@ var createFileTool = {
|
|
|
7229
7207
|
implementation: (context) => ({
|
|
7230
7208
|
toolFn: async (value) => {
|
|
7231
7209
|
const params = value;
|
|
7232
|
-
const fileExists = existsSync3(
|
|
7210
|
+
const fileExists = existsSync3(path7.resolve(process.cwd(), path7.normalize(params.path)));
|
|
7233
7211
|
context.logger.info(`\u{1F4DD} CreateFile: ${fileExists ? "Overwriting" : "Creating"} file`, {
|
|
7234
7212
|
path: params.path,
|
|
7235
7213
|
size: params.content.length
|
|
@@ -7271,7 +7249,7 @@ var createFileTool = {
|
|
|
7271
7249
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/globFiles/index.js
|
|
7272
7250
|
import { readdir } from "fs/promises";
|
|
7273
7251
|
import { statSync as statSync4 } from "fs";
|
|
7274
|
-
import
|
|
7252
|
+
import path8 from "path";
|
|
7275
7253
|
function matchGlob(filePath, pattern) {
|
|
7276
7254
|
let regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/\?/g, ".").replace(/\{([^}]+)\}/g, (_, options) => `(${options.split(",").join("|")})`).replace(/\[([^\]]+)\]/g, "[$1]");
|
|
7277
7255
|
regexPattern = regexPattern.replace(/\{\{GLOBSTAR\}\}\//g, "(.*/)?").replace(/\/\{\{GLOBSTAR\}\}/g, "(/.*)?").replace(/\{\{GLOBSTAR\}\}/g, ".*");
|
|
@@ -7289,8 +7267,8 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
|
|
|
7289
7267
|
if (!includeHidden && entry.name.startsWith(".")) {
|
|
7290
7268
|
continue;
|
|
7291
7269
|
}
|
|
7292
|
-
const relativePath = basePath ?
|
|
7293
|
-
const fullPath =
|
|
7270
|
+
const relativePath = basePath ? path8.join(basePath, entry.name) : entry.name;
|
|
7271
|
+
const fullPath = path8.join(dir, entry.name);
|
|
7294
7272
|
if (matchGlob(relativePath, pattern)) {
|
|
7295
7273
|
matches.push(relativePath);
|
|
7296
7274
|
}
|
|
@@ -7306,7 +7284,7 @@ async function walkDir(dir, pattern, includeHidden, maxResults, basePath = "") {
|
|
|
7306
7284
|
async function listFiles(params) {
|
|
7307
7285
|
const { pattern, cwd: relativeCwd, includeHidden = false, maxResults = 1e3 } = params;
|
|
7308
7286
|
const baseCwd = process.cwd();
|
|
7309
|
-
const targetCwd = relativeCwd ?
|
|
7287
|
+
const targetCwd = relativeCwd ? path8.resolve(baseCwd, path8.normalize(relativeCwd)) : baseCwd;
|
|
7310
7288
|
if (!targetCwd.startsWith(baseCwd)) {
|
|
7311
7289
|
throw new Error(`Access denied: Cannot list files outside of current working directory`);
|
|
7312
7290
|
}
|
|
@@ -7317,7 +7295,7 @@ async function listFiles(params) {
|
|
|
7317
7295
|
const filesInfo = [];
|
|
7318
7296
|
for (const match of matches) {
|
|
7319
7297
|
try {
|
|
7320
|
-
const fullPath =
|
|
7298
|
+
const fullPath = path8.join(targetCwd, match);
|
|
7321
7299
|
const stats = statSync4(fullPath);
|
|
7322
7300
|
filesInfo.push({
|
|
7323
7301
|
path: match,
|
|
@@ -7400,7 +7378,7 @@ var globFilesTool = {
|
|
|
7400
7378
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/grepSearch/index.js
|
|
7401
7379
|
import { readdir as readdir2 } from "fs/promises";
|
|
7402
7380
|
import { readFileSync as readFileSync2, statSync as statSync5 } from "fs";
|
|
7403
|
-
import
|
|
7381
|
+
import path9 from "path";
|
|
7404
7382
|
var MAX_FILE_SIZE3 = 10 * 1024 * 1024;
|
|
7405
7383
|
function matchGlob2(filePath, pattern) {
|
|
7406
7384
|
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 +7396,8 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
|
|
|
7418
7396
|
if (entry.name.startsWith(".")) {
|
|
7419
7397
|
continue;
|
|
7420
7398
|
}
|
|
7421
|
-
const relativePath = basePath ?
|
|
7422
|
-
const fullPath =
|
|
7399
|
+
const relativePath = basePath ? path9.join(basePath, entry.name) : entry.name;
|
|
7400
|
+
const fullPath = path9.join(dir, entry.name);
|
|
7423
7401
|
if (matchGlob2(relativePath, pattern)) {
|
|
7424
7402
|
matches.push(relativePath);
|
|
7425
7403
|
}
|
|
@@ -7435,7 +7413,7 @@ async function walkDir2(dir, pattern, maxResults, basePath = "") {
|
|
|
7435
7413
|
async function searchFiles2(params) {
|
|
7436
7414
|
const { pattern, filePattern = "**/*", cwd: relativeCwd, caseSensitive = false, maxResults = 100, contextLines = 0 } = params;
|
|
7437
7415
|
const baseCwd = process.cwd();
|
|
7438
|
-
const targetCwd = relativeCwd ?
|
|
7416
|
+
const targetCwd = relativeCwd ? path9.resolve(baseCwd, path9.normalize(relativeCwd)) : baseCwd;
|
|
7439
7417
|
if (!targetCwd.startsWith(baseCwd)) {
|
|
7440
7418
|
throw new Error(`Access denied: Cannot search files outside of current working directory`);
|
|
7441
7419
|
}
|
|
@@ -7449,7 +7427,7 @@ async function searchFiles2(params) {
|
|
|
7449
7427
|
const filesToSearch = await walkDir2(targetCwd, filePattern, 1e4);
|
|
7450
7428
|
const filteredFiles = [];
|
|
7451
7429
|
for (const match of filesToSearch) {
|
|
7452
|
-
const fullPath =
|
|
7430
|
+
const fullPath = path9.join(targetCwd, match);
|
|
7453
7431
|
try {
|
|
7454
7432
|
const stats = statSync5(fullPath);
|
|
7455
7433
|
if (stats.isDirectory() || stats.size > MAX_FILE_SIZE3) {
|
|
@@ -7473,7 +7451,7 @@ async function searchFiles2(params) {
|
|
|
7473
7451
|
break;
|
|
7474
7452
|
}
|
|
7475
7453
|
filesSearched++;
|
|
7476
|
-
const fullPath =
|
|
7454
|
+
const fullPath = path9.join(targetCwd, file);
|
|
7477
7455
|
try {
|
|
7478
7456
|
const content = readFileSync2(fullPath, "utf-8");
|
|
7479
7457
|
const lines = content.split("\n");
|
|
@@ -7610,12 +7588,12 @@ var grepSearchTool = {
|
|
|
7610
7588
|
// ../../b4m-core/packages/services/dist/src/llm/tools/implementation/deleteFile/index.js
|
|
7611
7589
|
import { promises as fs9 } from "fs";
|
|
7612
7590
|
import { existsSync as existsSync4, statSync as statSync6 } from "fs";
|
|
7613
|
-
import
|
|
7591
|
+
import path10 from "path";
|
|
7614
7592
|
async function deleteFile(params) {
|
|
7615
7593
|
const { path: filePath, recursive = false } = params;
|
|
7616
|
-
const normalizedPath =
|
|
7617
|
-
const resolvedPath =
|
|
7618
|
-
const cwd =
|
|
7594
|
+
const normalizedPath = path10.normalize(filePath);
|
|
7595
|
+
const resolvedPath = path10.resolve(process.cwd(), normalizedPath);
|
|
7596
|
+
const cwd = path10.resolve(process.cwd());
|
|
7619
7597
|
if (!resolvedPath.startsWith(cwd)) {
|
|
7620
7598
|
throw new Error(`Access denied: Cannot delete files outside of current working directory`);
|
|
7621
7599
|
}
|
|
@@ -7642,7 +7620,7 @@ var deleteFileTool = {
|
|
|
7642
7620
|
implementation: (context) => ({
|
|
7643
7621
|
toolFn: async (value) => {
|
|
7644
7622
|
const params = value;
|
|
7645
|
-
const resolvedPath =
|
|
7623
|
+
const resolvedPath = path10.resolve(process.cwd(), path10.normalize(params.path));
|
|
7646
7624
|
const isDirectory = existsSync4(resolvedPath) && statSync6(resolvedPath).isDirectory();
|
|
7647
7625
|
context.logger.info(`\u{1F5D1}\uFE0F DeleteFile: Deleting ${isDirectory ? "directory" : "file"}`, {
|
|
7648
7626
|
path: params.path,
|
|
@@ -7985,21 +7963,21 @@ var NoOpStorage = class extends BaseStorage {
|
|
|
7985
7963
|
async upload(input, destination, options) {
|
|
7986
7964
|
return `/tmp/${destination}`;
|
|
7987
7965
|
}
|
|
7988
|
-
async download(
|
|
7966
|
+
async download(path13) {
|
|
7989
7967
|
throw new Error("Download not supported in CLI");
|
|
7990
7968
|
}
|
|
7991
|
-
async delete(
|
|
7969
|
+
async delete(path13) {
|
|
7992
7970
|
}
|
|
7993
|
-
async getSignedUrl(
|
|
7994
|
-
return `/tmp/${
|
|
7971
|
+
async getSignedUrl(path13) {
|
|
7972
|
+
return `/tmp/${path13}`;
|
|
7995
7973
|
}
|
|
7996
|
-
getPublicUrl(
|
|
7997
|
-
return `/tmp/${
|
|
7974
|
+
getPublicUrl(path13) {
|
|
7975
|
+
return `/tmp/${path13}`;
|
|
7998
7976
|
}
|
|
7999
|
-
async getPreview(
|
|
8000
|
-
return `/tmp/${
|
|
7977
|
+
async getPreview(path13) {
|
|
7978
|
+
return `/tmp/${path13}`;
|
|
8001
7979
|
}
|
|
8002
|
-
async getMetadata(
|
|
7980
|
+
async getMetadata(path13) {
|
|
8003
7981
|
return { size: 0, contentType: "application/octet-stream" };
|
|
8004
7982
|
}
|
|
8005
7983
|
};
|
|
@@ -8326,7 +8304,7 @@ function getEnvironmentName(configApiConfig) {
|
|
|
8326
8304
|
|
|
8327
8305
|
// src/utils/Logger.ts
|
|
8328
8306
|
import fs10 from "fs/promises";
|
|
8329
|
-
import
|
|
8307
|
+
import path11 from "path";
|
|
8330
8308
|
import os from "os";
|
|
8331
8309
|
var Logger2 = class _Logger {
|
|
8332
8310
|
constructor() {
|
|
@@ -8349,9 +8327,9 @@ var Logger2 = class _Logger {
|
|
|
8349
8327
|
*/
|
|
8350
8328
|
async initialize(sessionId) {
|
|
8351
8329
|
this.sessionId = sessionId;
|
|
8352
|
-
const debugDir =
|
|
8330
|
+
const debugDir = path11.join(os.homedir(), ".bike4mind", "debug");
|
|
8353
8331
|
await fs10.mkdir(debugDir, { recursive: true });
|
|
8354
|
-
this.logFilePath =
|
|
8332
|
+
this.logFilePath = path11.join(debugDir, `${sessionId}.txt`);
|
|
8355
8333
|
await this.writeToFile("INFO", "=== CLI SESSION START ===");
|
|
8356
8334
|
}
|
|
8357
8335
|
/**
|
|
@@ -8561,12 +8539,12 @@ var Logger2 = class _Logger {
|
|
|
8561
8539
|
async cleanupOldLogs() {
|
|
8562
8540
|
if (!this.fileLoggingEnabled) return;
|
|
8563
8541
|
try {
|
|
8564
|
-
const debugDir =
|
|
8542
|
+
const debugDir = path11.join(os.homedir(), ".bike4mind", "debug");
|
|
8565
8543
|
const files = await fs10.readdir(debugDir);
|
|
8566
8544
|
const now = Date.now();
|
|
8567
8545
|
const thirtyDaysAgo = now - 30 * 24 * 60 * 60 * 1e3;
|
|
8568
8546
|
for (const file of files) {
|
|
8569
|
-
const filePath =
|
|
8547
|
+
const filePath = path11.join(debugDir, file);
|
|
8570
8548
|
const stats = await fs10.stat(filePath);
|
|
8571
8549
|
if (stats.mtime.getTime() < thirtyDaysAgo) {
|
|
8572
8550
|
await fs10.unlink(filePath);
|
|
@@ -8582,7 +8560,7 @@ var logger = Logger2.getInstance();
|
|
|
8582
8560
|
// ../../b4m-core/packages/mcp/dist/src/client.js
|
|
8583
8561
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
8584
8562
|
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8585
|
-
import
|
|
8563
|
+
import path12 from "path";
|
|
8586
8564
|
import { existsSync as existsSync6, readdirSync as readdirSync3 } from "fs";
|
|
8587
8565
|
var MCPClient = class {
|
|
8588
8566
|
// Note: This class handles MCP server communication with repository filtering
|
|
@@ -8608,16 +8586,16 @@ var MCPClient = class {
|
|
|
8608
8586
|
const root = process.env.INIT_CWD || process.cwd();
|
|
8609
8587
|
const candidatePaths = [
|
|
8610
8588
|
// When running from SST Lambda with node_modules structure (copyFiles)
|
|
8611
|
-
|
|
8589
|
+
path12.join(root, `node_modules/@bike4mind/mcp/dist/src/${this.serverName}/index.js`),
|
|
8612
8590
|
// When running from SST Lambda deployed environment (/var/task)
|
|
8613
|
-
|
|
8591
|
+
path12.join(root, `b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8614
8592
|
// When running from SST Lambda (.sst/artifacts/mcpHandler-dev), navigate to monorepo root (3 levels up)
|
|
8615
|
-
|
|
8593
|
+
path12.join(root, `../../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8616
8594
|
// When running from packages/client (Next.js app), navigate to monorepo root (2 levels up)
|
|
8617
|
-
|
|
8595
|
+
path12.join(root, `../../b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8618
8596
|
// Original paths (backward compatibility)
|
|
8619
|
-
|
|
8620
|
-
|
|
8597
|
+
path12.join(root, `/b4m-core/packages/mcp/dist/src/${this.serverName}/index.js`),
|
|
8598
|
+
path12.join(root, "core", "mcp", "servers", this.serverName, "dist", "index.js")
|
|
8621
8599
|
];
|
|
8622
8600
|
const serverScriptPath = candidatePaths.find((p) => existsSync6(p));
|
|
8623
8601
|
if (!serverScriptPath) {
|
|
@@ -9198,7 +9176,7 @@ var ApiClient = class {
|
|
|
9198
9176
|
// package.json
|
|
9199
9177
|
var package_default = {
|
|
9200
9178
|
name: "@bike4mind/cli",
|
|
9201
|
-
version: "0.2.1-feat-cli-file-reference.
|
|
9179
|
+
version: "0.2.1-feat-cli-file-reference.17023+cf6767ead",
|
|
9202
9180
|
type: "module",
|
|
9203
9181
|
description: "Interactive CLI tool for Bike4Mind with ReAct agents",
|
|
9204
9182
|
license: "UNLICENSED",
|
|
@@ -9300,10 +9278,10 @@ var package_default = {
|
|
|
9300
9278
|
},
|
|
9301
9279
|
devDependencies: {
|
|
9302
9280
|
"@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.
|
|
9281
|
+
"@bike4mind/common": "2.36.1-feat-cli-file-reference.17023+cf6767ead",
|
|
9282
|
+
"@bike4mind/mcp": "1.19.4-feat-cli-file-reference.17023+cf6767ead",
|
|
9283
|
+
"@bike4mind/services": "2.29.1-feat-cli-file-reference.17023+cf6767ead",
|
|
9284
|
+
"@bike4mind/utils": "2.0.3-feat-cli-file-reference.17023+cf6767ead",
|
|
9307
9285
|
"@types/diff": "^5.0.9",
|
|
9308
9286
|
"@types/jsonwebtoken": "^9.0.4",
|
|
9309
9287
|
"@types/node": "^22.9.0",
|
|
@@ -9315,7 +9293,7 @@ var package_default = {
|
|
|
9315
9293
|
typescript: "^5.9.3",
|
|
9316
9294
|
vitest: "^3.2.4"
|
|
9317
9295
|
},
|
|
9318
|
-
gitHead: "
|
|
9296
|
+
gitHead: "cf6767ead9e1a222e56d4b8114dfe9f9a8c2229b"
|
|
9319
9297
|
};
|
|
9320
9298
|
|
|
9321
9299
|
// src/index.tsx
|
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.17023+cf6767ead",
|
|
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.17023+cf6767ead",
|
|
106
|
+
"@bike4mind/mcp": "1.19.4-feat-cli-file-reference.17023+cf6767ead",
|
|
107
|
+
"@bike4mind/services": "2.29.1-feat-cli-file-reference.17023+cf6767ead",
|
|
108
|
+
"@bike4mind/utils": "2.0.3-feat-cli-file-reference.17023+cf6767ead",
|
|
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": "cf6767ead9e1a222e56d4b8114dfe9f9a8c2229b"
|
|
121
121
|
}
|