@nomad-e/bluma-cli 0.1.83 → 0.1.84
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/main.js +321 -456
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3,12 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
7
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
8
|
-
}) : x)(function(x) {
|
|
9
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
10
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
11
|
-
});
|
|
12
6
|
var __esm = (fn, res) => function __init() {
|
|
13
7
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
14
8
|
};
|
|
@@ -35,7 +29,7 @@ __export(runtime_config_exports, {
|
|
|
35
29
|
});
|
|
36
30
|
import fs4 from "fs";
|
|
37
31
|
import os4 from "os";
|
|
38
|
-
import
|
|
32
|
+
import path6 from "path";
|
|
39
33
|
function parseFeatures(raw) {
|
|
40
34
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
41
35
|
const out = {};
|
|
@@ -46,55 +40,23 @@ function parseFeatures(raw) {
|
|
|
46
40
|
}
|
|
47
41
|
return out;
|
|
48
42
|
}
|
|
49
|
-
function detectProjectRoot() {
|
|
50
|
-
const cwd = process.cwd();
|
|
51
|
-
try {
|
|
52
|
-
const { execSync: execSync5 } = __require("child_process");
|
|
53
|
-
const gitRoot = execSync5("git rev-parse --show-toplevel", {
|
|
54
|
-
cwd,
|
|
55
|
-
encoding: "utf8",
|
|
56
|
-
timeout: 5e3,
|
|
57
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
58
|
-
}).trim();
|
|
59
|
-
if (gitRoot && gitRoot !== cwd) {
|
|
60
|
-
return gitRoot;
|
|
61
|
-
}
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
if (fs4.existsSync(path5.join(cwd, "package.json")) || fs4.existsSync(path5.join(cwd, "pyproject.toml"))) {
|
|
65
|
-
return cwd;
|
|
66
|
-
}
|
|
67
|
-
let current = cwd;
|
|
68
|
-
for (let i = 0; i < 3; i++) {
|
|
69
|
-
const parent = path5.dirname(current);
|
|
70
|
-
if (parent === current) break;
|
|
71
|
-
if (fs4.existsSync(path5.join(parent, "package.json")) || fs4.existsSync(path5.join(parent, "pyproject.toml"))) {
|
|
72
|
-
return parent;
|
|
73
|
-
}
|
|
74
|
-
current = parent;
|
|
75
|
-
}
|
|
76
|
-
return cwd;
|
|
77
|
-
}
|
|
78
43
|
function createDefaultConfig() {
|
|
79
|
-
const projectRoot = detectProjectRoot();
|
|
80
44
|
return {
|
|
81
45
|
model: "auto",
|
|
82
46
|
reasoningEffort: "low",
|
|
83
47
|
outputStyle: "default",
|
|
84
48
|
permissionMode: "default",
|
|
85
49
|
sandboxEnabled: false,
|
|
86
|
-
workspaceRoot: process.cwd(),
|
|
87
|
-
projectRoot,
|
|
88
50
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
89
51
|
agentMode: "default",
|
|
90
52
|
features: {}
|
|
91
53
|
};
|
|
92
54
|
}
|
|
93
55
|
function getConfigPath() {
|
|
94
|
-
return
|
|
56
|
+
return path6.join(process.env.HOME || os4.homedir(), ".bluma", "settings.json");
|
|
95
57
|
}
|
|
96
58
|
function ensureConfigDir() {
|
|
97
|
-
fs4.mkdirSync(
|
|
59
|
+
fs4.mkdirSync(path6.dirname(getConfigPath()), { recursive: true });
|
|
98
60
|
}
|
|
99
61
|
function getRuntimeConfig() {
|
|
100
62
|
try {
|
|
@@ -115,8 +77,6 @@ function getRuntimeConfig() {
|
|
|
115
77
|
outputStyle: parsed.outputStyle === "compact" || parsed.outputStyle === "brief" || parsed.outputStyle === "default" ? parsed.outputStyle : defaults.outputStyle,
|
|
116
78
|
permissionMode,
|
|
117
79
|
sandboxEnabled: typeof parsed.sandboxEnabled === "boolean" ? parsed.sandboxEnabled : defaults.sandboxEnabled,
|
|
118
|
-
workspaceRoot: typeof parsed.workspaceRoot === "string" && parsed.workspaceRoot.trim() ? path5.resolve(parsed.workspaceRoot.trim()) : defaults.workspaceRoot,
|
|
119
|
-
projectRoot: typeof parsed.projectRoot === "string" && parsed.projectRoot.trim() ? path5.resolve(parsed.projectRoot.trim()) : defaults.projectRoot,
|
|
120
80
|
updatedAt: typeof parsed.updatedAt === "string" && parsed.updatedAt.trim() ? parsed.updatedAt : defaults.updatedAt,
|
|
121
81
|
agentMode,
|
|
122
82
|
features: mergedFeatures
|
|
@@ -133,12 +93,20 @@ function setRuntimeConfig(patch) {
|
|
|
133
93
|
...cur,
|
|
134
94
|
...restPatch,
|
|
135
95
|
features: nextFeatures,
|
|
136
|
-
workspaceRoot: patch.workspaceRoot ? path5.resolve(patch.workspaceRoot) : cur.workspaceRoot,
|
|
137
|
-
projectRoot: patch.projectRoot ? path5.resolve(patch.projectRoot) : cur.projectRoot,
|
|
138
96
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
139
97
|
};
|
|
140
98
|
ensureConfigDir();
|
|
141
|
-
|
|
99
|
+
const persisted = {
|
|
100
|
+
model: next.model,
|
|
101
|
+
reasoningEffort: next.reasoningEffort,
|
|
102
|
+
outputStyle: next.outputStyle,
|
|
103
|
+
permissionMode: next.permissionMode,
|
|
104
|
+
sandboxEnabled: next.sandboxEnabled,
|
|
105
|
+
updatedAt: next.updatedAt,
|
|
106
|
+
agentMode: next.agentMode,
|
|
107
|
+
features: next.features
|
|
108
|
+
};
|
|
109
|
+
fs4.writeFileSync(getConfigPath(), JSON.stringify(persisted, null, 2), "utf-8");
|
|
142
110
|
return next;
|
|
143
111
|
}
|
|
144
112
|
function getRuntimeConfigPath() {
|
|
@@ -153,7 +121,7 @@ var init_runtime_config = __esm({
|
|
|
153
121
|
// src/app/agent/runtime/permission_rules.ts
|
|
154
122
|
import fs5 from "fs";
|
|
155
123
|
import os5 from "os";
|
|
156
|
-
import
|
|
124
|
+
import path7 from "path";
|
|
157
125
|
import { v4 as uuidv4 } from "uuid";
|
|
158
126
|
var PermissionRulesEngine, permissionRulesEngine;
|
|
159
127
|
var init_permission_rules = __esm({
|
|
@@ -163,7 +131,7 @@ var init_permission_rules = __esm({
|
|
|
163
131
|
rules = [];
|
|
164
132
|
rulesFile;
|
|
165
133
|
constructor(rulesFile) {
|
|
166
|
-
this.rulesFile = rulesFile ||
|
|
134
|
+
this.rulesFile = rulesFile || path7.join(os5.homedir(), ".bluma", "permission_rules.json");
|
|
167
135
|
this.loadRules();
|
|
168
136
|
}
|
|
169
137
|
/**
|
|
@@ -274,19 +242,11 @@ var init_permission_rules = __esm({
|
|
|
274
242
|
});
|
|
275
243
|
|
|
276
244
|
// src/app/agent/runtime/sandbox_policy.ts
|
|
277
|
-
import
|
|
278
|
-
function getProjectRoot() {
|
|
279
|
-
if (cachedProjectRoot) return cachedProjectRoot;
|
|
280
|
-
const runtimeConfig = getRuntimeConfig();
|
|
281
|
-
cachedProjectRoot = runtimeConfig.projectRoot || process.cwd();
|
|
282
|
-
return cachedProjectRoot;
|
|
283
|
-
}
|
|
245
|
+
import path8 from "path";
|
|
284
246
|
function getSandboxPolicy() {
|
|
285
247
|
const runtimeConfig = getRuntimeConfig();
|
|
286
248
|
const isSandbox = process.env.BLUMA_SANDBOX === "true" || runtimeConfig.sandboxEnabled === true;
|
|
287
|
-
const workspaceRoot =
|
|
288
|
-
process.env.BLUMA_SANDBOX_WORKSPACE || runtimeConfig.workspaceRoot || getProjectRoot()
|
|
289
|
-
);
|
|
249
|
+
const workspaceRoot = isSandbox ? path8.resolve(process.env.BLUMA_SANDBOX_WORKSPACE || process.cwd()) : path8.resolve(process.cwd());
|
|
290
250
|
return {
|
|
291
251
|
mode: isSandbox ? "workspace" : "local",
|
|
292
252
|
isSandbox,
|
|
@@ -294,26 +254,26 @@ function getSandboxPolicy() {
|
|
|
294
254
|
};
|
|
295
255
|
}
|
|
296
256
|
function isPathInsideWorkspace(targetPath, policy = getSandboxPolicy()) {
|
|
297
|
-
const resolved =
|
|
298
|
-
const relative =
|
|
299
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
257
|
+
const resolved = path8.resolve(targetPath);
|
|
258
|
+
const relative = path8.relative(policy.workspaceRoot, resolved);
|
|
259
|
+
return relative === "" || !relative.startsWith("..") && !path8.isAbsolute(relative);
|
|
300
260
|
}
|
|
301
261
|
function redirectTopLevelArtifactsPath(resolvedAbsolute, workspaceRoot) {
|
|
302
|
-
const wr =
|
|
303
|
-
const abs =
|
|
304
|
-
const rel =
|
|
305
|
-
if (rel.startsWith("..") ||
|
|
262
|
+
const wr = path8.resolve(workspaceRoot);
|
|
263
|
+
const abs = path8.resolve(resolvedAbsolute);
|
|
264
|
+
const rel = path8.relative(wr, abs);
|
|
265
|
+
if (rel.startsWith("..") || path8.isAbsolute(rel)) {
|
|
306
266
|
return abs;
|
|
307
267
|
}
|
|
308
|
-
const segments = rel.split(
|
|
268
|
+
const segments = rel.split(path8.sep).filter((s) => s.length > 0);
|
|
309
269
|
if (segments.length === 0 || segments[0] !== "artifacts") {
|
|
310
270
|
return abs;
|
|
311
271
|
}
|
|
312
272
|
const tail = segments.slice(1);
|
|
313
|
-
return tail.length > 0 ?
|
|
273
|
+
return tail.length > 0 ? path8.join(wr, ".bluma", "artifacts", ...tail) : path8.join(wr, ".bluma", "artifacts");
|
|
314
274
|
}
|
|
315
275
|
function resolveWorkspacePath(inputPath, policy = getSandboxPolicy()) {
|
|
316
|
-
const candidate =
|
|
276
|
+
const candidate = path8.isAbsolute(inputPath) ? path8.resolve(inputPath) : path8.resolve(policy.workspaceRoot, inputPath);
|
|
317
277
|
if (policy.isSandbox && !isPathInsideWorkspace(candidate, policy)) {
|
|
318
278
|
throw new Error(
|
|
319
279
|
`Path "${inputPath}" escapes the sandbox workspace root ${policy.workspaceRoot}`
|
|
@@ -322,7 +282,7 @@ function resolveWorkspacePath(inputPath, policy = getSandboxPolicy()) {
|
|
|
322
282
|
return redirectTopLevelArtifactsPath(candidate, policy.workspaceRoot);
|
|
323
283
|
}
|
|
324
284
|
function resolveCommandCwd(cwd, policy = getSandboxPolicy()) {
|
|
325
|
-
const base = cwd ?
|
|
285
|
+
const base = cwd ? path8.resolve(cwd) : policy.workspaceRoot;
|
|
326
286
|
if (policy.isSandbox && !isPathInsideWorkspace(base, policy)) {
|
|
327
287
|
throw new Error(
|
|
328
288
|
`Command cwd "${base}" escapes the sandbox workspace root ${policy.workspaceRoot}`
|
|
@@ -364,13 +324,12 @@ function assessCommandSafety(command, policy = getSandboxPolicy()) {
|
|
|
364
324
|
}
|
|
365
325
|
return { allowed: true, risk: "safe" };
|
|
366
326
|
}
|
|
367
|
-
var
|
|
327
|
+
var BLOCKED_COMMAND_PATTERNS, HIGH_RISK_COMMAND_PATTERNS, MODERATE_RISK_COMMAND_PATTERNS;
|
|
368
328
|
var init_sandbox_policy = __esm({
|
|
369
329
|
"src/app/agent/runtime/sandbox_policy.ts"() {
|
|
370
330
|
"use strict";
|
|
371
331
|
init_runtime_config();
|
|
372
332
|
init_permission_rules();
|
|
373
|
-
cachedProjectRoot = null;
|
|
374
333
|
BLOCKED_COMMAND_PATTERNS = [
|
|
375
334
|
{ pattern: /\bsudo\b/, reason: "Privilege escalation is not allowed." },
|
|
376
335
|
{ pattern: /\bsu\b\s/, reason: "User switching is not allowed." },
|
|
@@ -720,12 +679,12 @@ __export(session_registry_exports, {
|
|
|
720
679
|
});
|
|
721
680
|
import fs16 from "fs";
|
|
722
681
|
import os9 from "os";
|
|
723
|
-
import
|
|
682
|
+
import path19 from "path";
|
|
724
683
|
function getRegistryDir() {
|
|
725
|
-
return
|
|
684
|
+
return path19.join(process.env.HOME || os9.homedir(), ".bluma", "registry");
|
|
726
685
|
}
|
|
727
686
|
function getRegistryFile() {
|
|
728
|
-
return
|
|
687
|
+
return path19.join(getRegistryDir(), "sessions.json");
|
|
729
688
|
}
|
|
730
689
|
function ensureRegistryDir() {
|
|
731
690
|
fs16.mkdirSync(getRegistryDir(), { recursive: true });
|
|
@@ -748,7 +707,7 @@ function writeRegistry(state) {
|
|
|
748
707
|
}
|
|
749
708
|
function getSessionLogPath(sessionId) {
|
|
750
709
|
ensureRegistryDir();
|
|
751
|
-
return
|
|
710
|
+
return path19.join(getRegistryDir(), `${sessionId}.jsonl`);
|
|
752
711
|
}
|
|
753
712
|
function registerSession(entry) {
|
|
754
713
|
const state = readRegistry();
|
|
@@ -800,15 +759,15 @@ var init_session_registry = __esm({
|
|
|
800
759
|
// src/app/agent/utils/logger.ts
|
|
801
760
|
import fs17 from "fs";
|
|
802
761
|
import os10 from "os";
|
|
803
|
-
import
|
|
762
|
+
import path20 from "path";
|
|
804
763
|
function getLogDir() {
|
|
805
|
-
const dir =
|
|
764
|
+
const dir = path20.join(process.env.HOME || os10.homedir(), ".bluma", "logs");
|
|
806
765
|
fs17.mkdirSync(dir, { recursive: true });
|
|
807
766
|
return dir;
|
|
808
767
|
}
|
|
809
768
|
function getLogFilePath() {
|
|
810
769
|
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
811
|
-
return
|
|
770
|
+
return path20.join(getLogDir(), `bluma-${today}.log`);
|
|
812
771
|
}
|
|
813
772
|
var BluMaLogger, logger;
|
|
814
773
|
var init_logger = __esm({
|
|
@@ -941,17 +900,17 @@ __export(mailbox_registry_exports, {
|
|
|
941
900
|
});
|
|
942
901
|
import fs18 from "fs";
|
|
943
902
|
import os11 from "os";
|
|
944
|
-
import
|
|
903
|
+
import path21 from "path";
|
|
945
904
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
946
905
|
import { v4 as uuidv45 } from "uuid";
|
|
947
906
|
function getMailboxesDir() {
|
|
948
907
|
if (mailboxesDir) return mailboxesDir;
|
|
949
|
-
mailboxesDir =
|
|
908
|
+
mailboxesDir = path21.join(process.env.HOME || os11.homedir(), ".bluma", "mailboxes");
|
|
950
909
|
fs18.mkdirSync(mailboxesDir, { recursive: true });
|
|
951
910
|
return mailboxesDir;
|
|
952
911
|
}
|
|
953
912
|
function getMailboxPath(sessionId, type) {
|
|
954
|
-
return
|
|
913
|
+
return path21.join(getMailboxesDir(), `${sessionId}.${type}`);
|
|
955
914
|
}
|
|
956
915
|
function sendToMailbox(sessionId, type, message2) {
|
|
957
916
|
return mailbox.sendToMailbox(sessionId, type, message2);
|
|
@@ -1048,7 +1007,7 @@ var init_mailbox_registry = __esm({
|
|
|
1048
1007
|
}
|
|
1049
1008
|
const type = file.split(".").pop();
|
|
1050
1009
|
const sessionId = file.slice(0, -(type.length + 1));
|
|
1051
|
-
const filePath =
|
|
1010
|
+
const filePath = path21.join(dir, file);
|
|
1052
1011
|
try {
|
|
1053
1012
|
const content = fs18.readFileSync(filePath, "utf-8");
|
|
1054
1013
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
@@ -1150,7 +1109,7 @@ var init_mailbox_registry = __esm({
|
|
|
1150
1109
|
ensureMailbox(sessionId) {
|
|
1151
1110
|
const dir = getMailboxesDir();
|
|
1152
1111
|
for (const type of ["in", "out", "sig"]) {
|
|
1153
|
-
const filePath =
|
|
1112
|
+
const filePath = path21.join(dir, `${sessionId}.${type}`);
|
|
1154
1113
|
if (!fs18.existsSync(filePath)) {
|
|
1155
1114
|
fs18.writeFileSync(filePath, "", "utf-8");
|
|
1156
1115
|
}
|
|
@@ -1162,7 +1121,7 @@ var init_mailbox_registry = __esm({
|
|
|
1162
1121
|
removeMailbox(sessionId) {
|
|
1163
1122
|
const dir = getMailboxesDir();
|
|
1164
1123
|
for (const type of ["in", "out", "sig"]) {
|
|
1165
|
-
const filePath =
|
|
1124
|
+
const filePath = path21.join(dir, `${sessionId}.${type}`);
|
|
1166
1125
|
if (fs18.existsSync(filePath)) fs18.unlinkSync(filePath);
|
|
1167
1126
|
}
|
|
1168
1127
|
this.queues.delete(sessionId);
|
|
@@ -1184,7 +1143,7 @@ __export(agent_coordination_exports, {
|
|
|
1184
1143
|
});
|
|
1185
1144
|
import fs19 from "fs";
|
|
1186
1145
|
import os12 from "os";
|
|
1187
|
-
import
|
|
1146
|
+
import path22 from "path";
|
|
1188
1147
|
import { spawn as spawn4 } from "child_process";
|
|
1189
1148
|
import { v4 as uuidv46 } from "uuid";
|
|
1190
1149
|
function readUserContextFromEnv() {
|
|
@@ -1298,8 +1257,8 @@ async function spawnAgent(args) {
|
|
|
1298
1257
|
spawnLog.error("Payload NOT serializable", { error: e.message });
|
|
1299
1258
|
throw new BluMaError("WORKER_CONTEXT_NOT_SERIALIZABLE" /* WORKER_CONTEXT_NOT_SERIALIZABLE */, `Worker context is not JSON-serializable: ${e.message}`);
|
|
1300
1259
|
}
|
|
1301
|
-
const payloadDir = fs19.mkdtempSync(
|
|
1302
|
-
const payloadPath =
|
|
1260
|
+
const payloadDir = fs19.mkdtempSync(path22.join(os12.tmpdir(), "bluma-worker-"));
|
|
1261
|
+
const payloadPath = path22.join(payloadDir, `${sessionId}.json`);
|
|
1303
1262
|
try {
|
|
1304
1263
|
fs19.writeFileSync(payloadPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
1305
1264
|
spawnLog.debug("Payload written", { payloadPath });
|
|
@@ -1670,7 +1629,7 @@ import React22 from "react";
|
|
|
1670
1629
|
import { render } from "ink";
|
|
1671
1630
|
import { EventEmitter as EventEmitter4 } from "events";
|
|
1672
1631
|
import fs39 from "fs";
|
|
1673
|
-
import
|
|
1632
|
+
import path45 from "path";
|
|
1674
1633
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
1675
1634
|
import { spawn as spawn6 } from "child_process";
|
|
1676
1635
|
import { v4 as uuidv412 } from "uuid";
|
|
@@ -1841,58 +1800,19 @@ var BLUMA_TERMINAL = {
|
|
|
1841
1800
|
};
|
|
1842
1801
|
|
|
1843
1802
|
// src/app/ui/components/StatusLine.tsx
|
|
1803
|
+
import path from "path";
|
|
1844
1804
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1845
|
-
var formatTokens = (tokens) => {
|
|
1846
|
-
if (tokens >= 1e6) return `${(tokens / 1e6).toFixed(1)}M`;
|
|
1847
|
-
if (tokens >= 1e3) return `${(tokens / 1e3).toFixed(1)}k`;
|
|
1848
|
-
return tokens.toString();
|
|
1849
|
-
};
|
|
1850
|
-
var formatCost = (cost) => {
|
|
1851
|
-
if (cost >= 1) return `$${cost.toFixed(2)}`;
|
|
1852
|
-
if (cost > 0) return `$${(cost * 100).toFixed(1)}\xA2`;
|
|
1853
|
-
return "$0.00";
|
|
1854
|
-
};
|
|
1855
|
-
var formatTime = (ms) => {
|
|
1856
|
-
if (ms < 1e3) return `${ms}ms`;
|
|
1857
|
-
if (ms < 6e4) return `${(ms / 1e3).toFixed(1)}s`;
|
|
1858
|
-
return `${Math.floor(ms / 6e4)}m${Math.floor(ms % 6e4 / 1e3)}s`;
|
|
1859
|
-
};
|
|
1860
1805
|
var StatusLineComponent = ({
|
|
1861
1806
|
model = "auto",
|
|
1862
|
-
inputTokens = 0,
|
|
1863
|
-
outputTokens = 0,
|
|
1864
|
-
contextWindowSize = 128e3,
|
|
1865
|
-
totalCost = 0,
|
|
1866
1807
|
cwd = "",
|
|
1867
|
-
permissionMode = "auto",
|
|
1868
|
-
processingTime = 0,
|
|
1869
|
-
toolsCount = 0,
|
|
1870
1808
|
activeWorkers = 0,
|
|
1871
|
-
|
|
1809
|
+
visible = true
|
|
1872
1810
|
}) => {
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1875
|
-
return
|
|
1876
|
-
}, [
|
|
1877
|
-
|
|
1878
|
-
if (contextUsage > 90) return BLUMA_TERMINAL.err;
|
|
1879
|
-
if (contextUsage > 75) return BLUMA_TERMINAL.warn;
|
|
1880
|
-
return BLUMA_TERMINAL.success;
|
|
1881
|
-
}, [contextUsage]);
|
|
1882
|
-
const permissionIcon = useMemo(() => {
|
|
1883
|
-
switch (permissionMode) {
|
|
1884
|
-
case "auto":
|
|
1885
|
-
return "\u{1F916}";
|
|
1886
|
-
case "accept-edits":
|
|
1887
|
-
return "\u270F\uFE0F";
|
|
1888
|
-
case "bypass":
|
|
1889
|
-
return "\u26A1";
|
|
1890
|
-
case "always":
|
|
1891
|
-
return "\u{1F513}";
|
|
1892
|
-
default:
|
|
1893
|
-
return "\u{1F916}";
|
|
1894
|
-
}
|
|
1895
|
-
}, [permissionMode]);
|
|
1811
|
+
const dirName = useMemo(() => {
|
|
1812
|
+
if (!cwd) return "";
|
|
1813
|
+
return path.basename(cwd);
|
|
1814
|
+
}, [cwd]);
|
|
1815
|
+
if (!visible) return null;
|
|
1896
1816
|
return /* @__PURE__ */ jsxs(
|
|
1897
1817
|
Box,
|
|
1898
1818
|
{
|
|
@@ -1900,57 +1820,12 @@ var StatusLineComponent = ({
|
|
|
1900
1820
|
paddingX: 1,
|
|
1901
1821
|
paddingTop: 1,
|
|
1902
1822
|
children: [
|
|
1903
|
-
/* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsx2(Text, { color: BLUMA_TERMINAL.
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
|
|
1906
|
-
formatTokens(inputTokens),
|
|
1907
|
-
"\u2191"
|
|
1908
|
-
] }),
|
|
1909
|
-
/* @__PURE__ */ jsx2(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: "/" }),
|
|
1910
|
-
/* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: [
|
|
1911
|
-
formatTokens(outputTokens),
|
|
1912
|
-
"\u2193"
|
|
1913
|
-
] }),
|
|
1914
|
-
/* @__PURE__ */ jsxs(Text, { color: contextColor, bold: true, children: [
|
|
1915
|
-
" ",
|
|
1916
|
-
"(",
|
|
1917
|
-
contextUsage,
|
|
1918
|
-
"%)"
|
|
1919
|
-
] })
|
|
1920
|
-
] }),
|
|
1921
|
-
/* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: [
|
|
1922
|
-
"\u{1F4B0} ",
|
|
1923
|
-
formatCost(totalCost)
|
|
1924
|
-
] }) }),
|
|
1925
|
-
processingTime > 0 && /* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: [
|
|
1926
|
-
"\u23F1\uFE0F ",
|
|
1927
|
-
formatTime(processingTime)
|
|
1928
|
-
] }) }),
|
|
1929
|
-
/* @__PURE__ */ jsx2(Text, { color: BLUMA_TERMINAL.outline, children: "\u2502" }),
|
|
1930
|
-
/* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: [
|
|
1931
|
-
permissionIcon,
|
|
1823
|
+
dirName && /* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsx2(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, dimColor: true, children: dirName }) }),
|
|
1824
|
+
model !== "auto" && /* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsx2(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, dimColor: true, children: model }) }),
|
|
1825
|
+
activeWorkers > 0 && /* @__PURE__ */ jsx2(Box, { children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.accent, children: [
|
|
1932
1826
|
" ",
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
/* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: [
|
|
1936
|
-
"\u{1F6E1}\uFE0F ",
|
|
1937
|
-
sandboxMode
|
|
1938
|
-
] }) }),
|
|
1939
|
-
/* @__PURE__ */ jsx2(Text, { color: BLUMA_TERMINAL.outline, children: "\u2502" }),
|
|
1940
|
-
activeWorkers > 0 && /* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.accent, children: [
|
|
1941
|
-
"\u{1F9D1}\u200D\u{1F4BB} ",
|
|
1942
|
-
activeWorkers,
|
|
1943
|
-
" worker",
|
|
1944
|
-
activeWorkers > 1 ? "s" : ""
|
|
1945
|
-
] }) }),
|
|
1946
|
-
toolsCount > 0 && /* @__PURE__ */ jsx2(Box, { marginRight: 2, children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, children: [
|
|
1947
|
-
"\u{1F527} ",
|
|
1948
|
-
toolsCount
|
|
1949
|
-
] }) }),
|
|
1950
|
-
/* @__PURE__ */ jsx2(Box, { flexGrow: 1 }),
|
|
1951
|
-
cwd && /* @__PURE__ */ jsx2(Box, { children: /* @__PURE__ */ jsxs(Text, { color: BLUMA_TERMINAL.onSurfaceVariant, dimColor: true, children: [
|
|
1952
|
-
"\u{1F4C1} ",
|
|
1953
|
-
cwd
|
|
1827
|
+
"\u25CF ",
|
|
1828
|
+
activeWorkers
|
|
1954
1829
|
] }) })
|
|
1955
1830
|
]
|
|
1956
1831
|
}
|
|
@@ -3075,7 +2950,7 @@ var filterSlashCommands = (query) => {
|
|
|
3075
2950
|
// src/app/ui/hooks/useAtCompletion.ts
|
|
3076
2951
|
import { useEffect as useEffect3, useRef as useRef3, useState as useState2 } from "react";
|
|
3077
2952
|
import fs from "fs";
|
|
3078
|
-
import
|
|
2953
|
+
import path2 from "path";
|
|
3079
2954
|
var MAX_RESULTS = 50;
|
|
3080
2955
|
var DEFAULT_RECURSIVE_DEPTH = 2;
|
|
3081
2956
|
function listPathSuggestions(baseDir, pattern) {
|
|
@@ -3083,7 +2958,7 @@ function listPathSuggestions(baseDir, pattern) {
|
|
|
3083
2958
|
const patternEndsWithSlash = raw.endsWith("/");
|
|
3084
2959
|
const relDir = raw.replace(/^\/+|\/+$/g, "");
|
|
3085
2960
|
const filterPrefix = patternEndsWithSlash ? "" : relDir.split("/").slice(-1)[0] || "";
|
|
3086
|
-
const listDir =
|
|
2961
|
+
const listDir = path2.resolve(baseDir, relDir || ".");
|
|
3087
2962
|
const results = [];
|
|
3088
2963
|
const IGNORED_DIRS = ["node_modules", ".git", ".venv", "dist", "build"];
|
|
3089
2964
|
const IGNORED_EXTS = [".pyc", ".class", ".o", ".map", ".log", ".tmp"];
|
|
@@ -3100,7 +2975,7 @@ function listPathSuggestions(baseDir, pattern) {
|
|
|
3100
2975
|
}
|
|
3101
2976
|
function pushEntry(entryPath, label, isDir) {
|
|
3102
2977
|
if (results.length >= MAX_RESULTS) return;
|
|
3103
|
-
const clean = label.split(
|
|
2978
|
+
const clean = label.split(path2.sep).join("/").replace(/[]+/g, "");
|
|
3104
2979
|
results.push({ label: clean + (isDir ? "/" : ""), fullPath: entryPath, isDir });
|
|
3105
2980
|
}
|
|
3106
2981
|
try {
|
|
@@ -3112,8 +2987,8 @@ function listPathSuggestions(baseDir, pattern) {
|
|
|
3112
2987
|
const entries = fs.readdirSync(node.dir, { withFileTypes: true });
|
|
3113
2988
|
for (const entry of entries) {
|
|
3114
2989
|
if (isIgnoredName(entry.name)) continue;
|
|
3115
|
-
const entryAbs =
|
|
3116
|
-
const entryRel = node.rel ?
|
|
2990
|
+
const entryAbs = path2.join(node.dir, entry.name);
|
|
2991
|
+
const entryRel = node.rel ? path2.posix.join(node.rel, entry.name) : entry.name;
|
|
3117
2992
|
if (entryRel.split("/").includes("node_modules")) continue;
|
|
3118
2993
|
if (!entry.isDirectory() && isIgnoredFile(entry.name)) continue;
|
|
3119
2994
|
pushEntry(entryAbs, entryRel, entry.isDirectory());
|
|
@@ -3131,8 +3006,8 @@ function listPathSuggestions(baseDir, pattern) {
|
|
|
3131
3006
|
if (filterPrefix && !entry.name.startsWith(filterPrefix)) continue;
|
|
3132
3007
|
if (isIgnoredName(entry.name)) continue;
|
|
3133
3008
|
if (!entry.isDirectory() && isIgnoredFile(entry.name)) continue;
|
|
3134
|
-
const entryAbs =
|
|
3135
|
-
const label = relDir ?
|
|
3009
|
+
const entryAbs = path2.join(listDir, entry.name);
|
|
3010
|
+
const label = relDir ? path2.posix.join(relDir, entry.name) : entry.name;
|
|
3136
3011
|
pushEntry(entryAbs, label, entry.isDirectory());
|
|
3137
3012
|
if (results.length >= MAX_RESULTS) break;
|
|
3138
3013
|
}
|
|
@@ -3226,7 +3101,7 @@ function useAtCompletion({
|
|
|
3226
3101
|
// src/app/ui/utils/clipboardImage.ts
|
|
3227
3102
|
import fs2 from "fs";
|
|
3228
3103
|
import os from "os";
|
|
3229
|
-
import
|
|
3104
|
+
import path3 from "path";
|
|
3230
3105
|
import { spawn, execFile as execFileCb, execSync } from "child_process";
|
|
3231
3106
|
import { promisify } from "util";
|
|
3232
3107
|
var execFile = promisify(execFileCb);
|
|
@@ -3279,8 +3154,8 @@ function commandOnPath(cmd) {
|
|
|
3279
3154
|
function unixClipboardHelperDirs() {
|
|
3280
3155
|
const h = os.homedir();
|
|
3281
3156
|
return [
|
|
3282
|
-
|
|
3283
|
-
|
|
3157
|
+
path3.join(h, ".local", "bin"),
|
|
3158
|
+
path3.join(h, "bin"),
|
|
3284
3159
|
"/usr/bin",
|
|
3285
3160
|
"/usr/local/bin",
|
|
3286
3161
|
"/bin",
|
|
@@ -3298,7 +3173,7 @@ function resolveHelperBinary(cmd) {
|
|
|
3298
3173
|
return cmd;
|
|
3299
3174
|
}
|
|
3300
3175
|
for (const dir of unixClipboardHelperDirs()) {
|
|
3301
|
-
const full =
|
|
3176
|
+
const full = path3.join(dir, cmd);
|
|
3302
3177
|
try {
|
|
3303
3178
|
fs2.accessSync(full, fs2.constants.X_OK);
|
|
3304
3179
|
return full;
|
|
@@ -3306,7 +3181,7 @@ function resolveHelperBinary(cmd) {
|
|
|
3306
3181
|
}
|
|
3307
3182
|
}
|
|
3308
3183
|
for (const dir of unixClipboardHelperDirs()) {
|
|
3309
|
-
const full =
|
|
3184
|
+
const full = path3.join(dir, cmd);
|
|
3310
3185
|
if (fs2.existsSync(full)) {
|
|
3311
3186
|
return full;
|
|
3312
3187
|
}
|
|
@@ -3348,7 +3223,7 @@ function writeBufferIfImage(baseDir, buf) {
|
|
|
3348
3223
|
if (!ext) {
|
|
3349
3224
|
return null;
|
|
3350
3225
|
}
|
|
3351
|
-
const out =
|
|
3226
|
+
const out = path3.join(
|
|
3352
3227
|
baseDir,
|
|
3353
3228
|
`clip-${Date.now()}-${Math.random().toString(36).slice(2, 8)}${ext}`
|
|
3354
3229
|
);
|
|
@@ -3387,9 +3262,9 @@ async function tryDarwinClipboardy(baseDir) {
|
|
|
3387
3262
|
if (st.size < 80 || st.size > CLIPBOARD_MAX_BYTES) {
|
|
3388
3263
|
continue;
|
|
3389
3264
|
}
|
|
3390
|
-
const ext =
|
|
3265
|
+
const ext = path3.extname(src).toLowerCase();
|
|
3391
3266
|
const safeExt = ext && /^\.(png|jpe?g|gif|webp)$/i.test(ext) ? ext : ".png";
|
|
3392
|
-
const out =
|
|
3267
|
+
const out = path3.join(
|
|
3393
3268
|
baseDir,
|
|
3394
3269
|
`clip-${Date.now()}-${Math.random().toString(36).slice(2, 8)}${safeExt}`
|
|
3395
3270
|
);
|
|
@@ -3407,7 +3282,7 @@ async function tryDarwinClipboardy(baseDir) {
|
|
|
3407
3282
|
return null;
|
|
3408
3283
|
}
|
|
3409
3284
|
async function tryWindowsPowerShell(outFile) {
|
|
3410
|
-
const ps = process.env.SystemRoot != null ?
|
|
3285
|
+
const ps = process.env.SystemRoot != null ? path3.join(
|
|
3411
3286
|
process.env.SystemRoot,
|
|
3412
3287
|
"System32",
|
|
3413
3288
|
"WindowsPowerShell",
|
|
@@ -3508,8 +3383,8 @@ function parseClipboardTextAsImagePath(raw) {
|
|
|
3508
3383
|
s = s.slice(1, -1);
|
|
3509
3384
|
}
|
|
3510
3385
|
s = s.trim();
|
|
3511
|
-
if (!CLIPBOARD_PATH_IMAGE_EXT.test(
|
|
3512
|
-
const abs =
|
|
3386
|
+
if (!CLIPBOARD_PATH_IMAGE_EXT.test(path3.extname(s))) return null;
|
|
3387
|
+
const abs = path3.isAbsolute(s) ? path3.normalize(s) : path3.resolve(process.cwd(), s);
|
|
3513
3388
|
return abs;
|
|
3514
3389
|
}
|
|
3515
3390
|
async function tryClipboardTextAsImageFile(baseDir) {
|
|
@@ -3529,8 +3404,8 @@ async function tryClipboardTextAsImageFile(baseDir) {
|
|
|
3529
3404
|
} catch {
|
|
3530
3405
|
return null;
|
|
3531
3406
|
}
|
|
3532
|
-
const ext =
|
|
3533
|
-
const out =
|
|
3407
|
+
const ext = path3.extname(abs).toLowerCase();
|
|
3408
|
+
const out = path3.join(
|
|
3534
3409
|
baseDir,
|
|
3535
3410
|
`clip-${Date.now()}-${Math.random().toString(36).slice(2, 8)}${ext}`
|
|
3536
3411
|
);
|
|
@@ -3545,7 +3420,7 @@ async function tryLinuxShellPipelineSave(baseDir) {
|
|
|
3545
3420
|
if (process.platform !== "linux" && process.platform !== "freebsd") {
|
|
3546
3421
|
return null;
|
|
3547
3422
|
}
|
|
3548
|
-
const outPath =
|
|
3423
|
+
const outPath = path3.join(
|
|
3549
3424
|
baseDir,
|
|
3550
3425
|
`clip-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.tmp`
|
|
3551
3426
|
);
|
|
@@ -3587,7 +3462,7 @@ async function readUnixLikeClipboardImage(baseDir) {
|
|
|
3587
3462
|
return tryClipboardTextAsImageFile(baseDir);
|
|
3588
3463
|
}
|
|
3589
3464
|
async function readClipboardImageToTempFile() {
|
|
3590
|
-
const baseDir =
|
|
3465
|
+
const baseDir = path3.join(os.homedir(), ".cache", "bluma", "clipboard");
|
|
3591
3466
|
fs2.mkdirSync(baseDir, { recursive: true });
|
|
3592
3467
|
if (process.platform === "darwin") {
|
|
3593
3468
|
const fromCb = await tryDarwinClipboardy(baseDir);
|
|
@@ -3602,7 +3477,7 @@ async function readClipboardImageToTempFile() {
|
|
|
3602
3477
|
}
|
|
3603
3478
|
}
|
|
3604
3479
|
if (process.platform === "win32") {
|
|
3605
|
-
const outFile =
|
|
3480
|
+
const outFile = path3.join(
|
|
3606
3481
|
baseDir,
|
|
3607
3482
|
`clip-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.png`
|
|
3608
3483
|
);
|
|
@@ -3662,7 +3537,7 @@ function resolveInlineImageLabels(raw, idToPath) {
|
|
|
3662
3537
|
// src/app/agent/utils/user_message_images.ts
|
|
3663
3538
|
import fs3 from "fs";
|
|
3664
3539
|
import os2 from "os";
|
|
3665
|
-
import
|
|
3540
|
+
import path4 from "path";
|
|
3666
3541
|
import { fileURLToPath } from "url";
|
|
3667
3542
|
var IMAGE_EXT = /\.(png|jpe?g|gif|webp|bmp)$/i;
|
|
3668
3543
|
var MAX_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
@@ -3678,20 +3553,20 @@ var MIME = {
|
|
|
3678
3553
|
function expandUserPath(p) {
|
|
3679
3554
|
const t = p.trim();
|
|
3680
3555
|
if (t.startsWith("~")) {
|
|
3681
|
-
return
|
|
3556
|
+
return path4.join(os2.homedir(), t.slice(1).replace(/^\//, ""));
|
|
3682
3557
|
}
|
|
3683
3558
|
return t;
|
|
3684
3559
|
}
|
|
3685
3560
|
function isPathAllowed(absResolved, cwd) {
|
|
3686
|
-
const resolved =
|
|
3687
|
-
const cwdR =
|
|
3688
|
-
const homeR =
|
|
3689
|
-
const underCwd = resolved === cwdR || resolved.startsWith(cwdR +
|
|
3690
|
-
const underHome = resolved === homeR || resolved.startsWith(homeR +
|
|
3561
|
+
const resolved = path4.normalize(path4.resolve(absResolved));
|
|
3562
|
+
const cwdR = path4.normalize(path4.resolve(cwd));
|
|
3563
|
+
const homeR = path4.normalize(path4.resolve(os2.homedir()));
|
|
3564
|
+
const underCwd = resolved === cwdR || resolved.startsWith(cwdR + path4.sep);
|
|
3565
|
+
const underHome = resolved === homeR || resolved.startsWith(homeR + path4.sep);
|
|
3691
3566
|
return underCwd || underHome;
|
|
3692
3567
|
}
|
|
3693
3568
|
function mimeFor(abs) {
|
|
3694
|
-
const ext =
|
|
3569
|
+
const ext = path4.extname(abs).toLowerCase();
|
|
3695
3570
|
return MIME[ext] || "application/octet-stream";
|
|
3696
3571
|
}
|
|
3697
3572
|
var IMAGE_EXT_SRC = String.raw`(?:png|jpe?g|gif|webp|bmp)`;
|
|
@@ -3735,7 +3610,7 @@ function collectImagePathStrings(raw) {
|
|
|
3735
3610
|
}
|
|
3736
3611
|
function resolveImagePath(candidate, cwd) {
|
|
3737
3612
|
const expanded = expandUserPath(candidate);
|
|
3738
|
-
const abs =
|
|
3613
|
+
const abs = path4.isAbsolute(expanded) ? path4.normalize(expanded) : path4.normalize(path4.resolve(cwd, expanded));
|
|
3739
3614
|
if (!isPathAllowed(abs, cwd)) return null;
|
|
3740
3615
|
try {
|
|
3741
3616
|
if (!fs3.existsSync(abs) || !fs3.statSync(abs).isFile()) return null;
|
|
@@ -3758,7 +3633,7 @@ function trySingleLineFileUriOrBareImagePath(line, cwd) {
|
|
|
3758
3633
|
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) {
|
|
3759
3634
|
s = s.slice(1, -1).trim();
|
|
3760
3635
|
}
|
|
3761
|
-
if (!IMAGE_EXT.test(
|
|
3636
|
+
if (!IMAGE_EXT.test(path4.extname(s))) return null;
|
|
3762
3637
|
const abs = resolveImagePath(s, cwd);
|
|
3763
3638
|
if (!abs) return null;
|
|
3764
3639
|
try {
|
|
@@ -4340,7 +4215,7 @@ var InteractiveMenu = memo4(InteractiveMenuComponent);
|
|
|
4340
4215
|
import { Box as Box10, Text as Text10 } from "ink";
|
|
4341
4216
|
|
|
4342
4217
|
// src/app/ui/utils/pathDisplay.ts
|
|
4343
|
-
import
|
|
4218
|
+
import path5 from "node:path";
|
|
4344
4219
|
import os3 from "node:os";
|
|
4345
4220
|
function formatPathForDisplay(pathInput, cwd = process.cwd()) {
|
|
4346
4221
|
let s = String(pathInput ?? "").trim();
|
|
@@ -4348,17 +4223,17 @@ function formatPathForDisplay(pathInput, cwd = process.cwd()) {
|
|
|
4348
4223
|
s = s.replace(/[/\\]+$/, "");
|
|
4349
4224
|
}
|
|
4350
4225
|
if (!s) return "";
|
|
4351
|
-
const abs =
|
|
4352
|
-
const resolvedCwd =
|
|
4353
|
-
const rel =
|
|
4354
|
-
if (rel === "" || !rel.startsWith("..") && !
|
|
4226
|
+
const abs = path5.isAbsolute(s) ? path5.normalize(s) : path5.resolve(cwd, s);
|
|
4227
|
+
const resolvedCwd = path5.resolve(cwd);
|
|
4228
|
+
const rel = path5.relative(resolvedCwd, abs);
|
|
4229
|
+
if (rel === "" || !rel.startsWith("..") && !path5.isAbsolute(rel)) {
|
|
4355
4230
|
return rel === "" ? "." : rel;
|
|
4356
4231
|
}
|
|
4357
|
-
const home =
|
|
4358
|
-
if (abs === home || abs.startsWith(home +
|
|
4232
|
+
const home = path5.normalize(os3.homedir());
|
|
4233
|
+
if (abs === home || abs.startsWith(home + path5.sep)) {
|
|
4359
4234
|
return "~" + abs.slice(home.length);
|
|
4360
4235
|
}
|
|
4361
|
-
return
|
|
4236
|
+
return path5.basename(abs);
|
|
4362
4237
|
}
|
|
4363
4238
|
|
|
4364
4239
|
// src/app/ui/components/EditToolDiffPanel.tsx
|
|
@@ -4785,12 +4660,12 @@ function EditToolDiffPanel({
|
|
|
4785
4660
|
maxHeight = EDIT_DIFF_PREVIEW_MAX_LINES,
|
|
4786
4661
|
fallbackSnippet
|
|
4787
4662
|
}) {
|
|
4788
|
-
const
|
|
4663
|
+
const path46 = filePath.trim() || "unknown file";
|
|
4789
4664
|
const diff = diffText?.trim() ?? "";
|
|
4790
4665
|
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
|
|
4791
4666
|
/* @__PURE__ */ jsx8(Box7, { flexDirection: "row", flexWrap: "wrap", children: /* @__PURE__ */ jsxs7(Text7, { color: isNewFile ? BLUMA_TERMINAL.success : void 0, children: [
|
|
4792
4667
|
isNewFile ? "Created " : "Wrote to ",
|
|
4793
|
-
/* @__PURE__ */ jsx8(Text7, { bold: true, children:
|
|
4668
|
+
/* @__PURE__ */ jsx8(Text7, { bold: true, children: path46 })
|
|
4794
4669
|
] }) }),
|
|
4795
4670
|
description ? /* @__PURE__ */ jsx8(Text7, { dimColor: true, wrap: "wrap", children: description }) : null,
|
|
4796
4671
|
diff.length > 0 ? /* @__PURE__ */ jsx8(Box7, { marginTop: 0, children: /* @__PURE__ */ jsx8(SimpleDiff, { text: diff, maxHeight, frame: true }) }) : fallbackSnippet ? /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", marginTop: 0, children: [
|
|
@@ -5119,7 +4994,7 @@ var renderFindByName = ({ args }) => {
|
|
|
5119
4994
|
var renderGrepSearch = ({ args }) => {
|
|
5120
4995
|
const parsed = parseArgs(args);
|
|
5121
4996
|
const query = parsed.query || "";
|
|
5122
|
-
const
|
|
4997
|
+
const path46 = parsed.path || ".";
|
|
5123
4998
|
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "row", flexWrap: "wrap", children: [
|
|
5124
4999
|
/* @__PURE__ */ jsxs10(Text10, { color: BLUMA_TERMINAL.muted, children: [
|
|
5125
5000
|
'"',
|
|
@@ -5128,7 +5003,7 @@ var renderGrepSearch = ({ args }) => {
|
|
|
5128
5003
|
] }),
|
|
5129
5004
|
/* @__PURE__ */ jsxs10(Text10, { color: BLUMA_TERMINAL.m3OnSurface, bold: true, children: [
|
|
5130
5005
|
" ",
|
|
5131
|
-
|
|
5006
|
+
path46
|
|
5132
5007
|
] })
|
|
5133
5008
|
] });
|
|
5134
5009
|
};
|
|
@@ -5558,17 +5433,17 @@ var ConfirmationPrompt = memo5(ConfirmationPromptComponent);
|
|
|
5558
5433
|
|
|
5559
5434
|
// src/app/agent/agent.ts
|
|
5560
5435
|
import * as dotenv from "dotenv";
|
|
5561
|
-
import
|
|
5436
|
+
import path43 from "path";
|
|
5562
5437
|
import os28 from "os";
|
|
5563
5438
|
|
|
5564
5439
|
// src/app/agent/tool_invoker.ts
|
|
5565
5440
|
import { promises as fs26 } from "fs";
|
|
5566
|
-
import
|
|
5441
|
+
import path29 from "path";
|
|
5567
5442
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5568
5443
|
|
|
5569
5444
|
// src/app/agent/tools/natives/edit.ts
|
|
5570
5445
|
init_sandbox_policy();
|
|
5571
|
-
import
|
|
5446
|
+
import path9 from "path";
|
|
5572
5447
|
import os6 from "os";
|
|
5573
5448
|
import { promises as fs6 } from "fs";
|
|
5574
5449
|
import { diffLines } from "diff";
|
|
@@ -5587,7 +5462,7 @@ function normalizePath(filePath) {
|
|
|
5587
5462
|
}
|
|
5588
5463
|
filePath = filePath.replace(/\//g, "\\");
|
|
5589
5464
|
}
|
|
5590
|
-
return
|
|
5465
|
+
return path9.normalize(resolveWorkspacePath(filePath));
|
|
5591
5466
|
} catch (e) {
|
|
5592
5467
|
throw new Error(`Failed to normalize path "${filePath}": ${e.message}`);
|
|
5593
5468
|
}
|
|
@@ -5880,7 +5755,7 @@ async function applyBatchEditsInMemory(edits) {
|
|
|
5880
5755
|
}
|
|
5881
5756
|
};
|
|
5882
5757
|
}
|
|
5883
|
-
if (!norm.startsWith(workspaceRoot) && !
|
|
5758
|
+
if (!norm.startsWith(workspaceRoot) && !path9.isAbsolute(e.file_path)) {
|
|
5884
5759
|
return {
|
|
5885
5760
|
ok: false,
|
|
5886
5761
|
failed: {
|
|
@@ -5918,7 +5793,7 @@ async function applyBatchEditsInMemory(edits) {
|
|
|
5918
5793
|
};
|
|
5919
5794
|
}
|
|
5920
5795
|
}
|
|
5921
|
-
const rel =
|
|
5796
|
+
const rel = path9.relative(workspaceRoot, norm);
|
|
5922
5797
|
slots.set(norm, {
|
|
5923
5798
|
norm,
|
|
5924
5799
|
content,
|
|
@@ -5957,7 +5832,7 @@ function buildBatchDiffAndPaths(slots) {
|
|
|
5957
5832
|
touchedRel.push(slot.rel);
|
|
5958
5833
|
const base = slot.snapshotForDiff ?? "";
|
|
5959
5834
|
const finalC = slot.content ?? "";
|
|
5960
|
-
const fn =
|
|
5835
|
+
const fn = path9.basename(slot.norm);
|
|
5961
5836
|
if (base === finalC) continue;
|
|
5962
5837
|
diffChunks.push(createDiff(fn, base, finalC));
|
|
5963
5838
|
}
|
|
@@ -5974,7 +5849,7 @@ async function runEditBatch(edits) {
|
|
|
5974
5849
|
}
|
|
5975
5850
|
const { slots, totalOcc, editsCount } = r;
|
|
5976
5851
|
for (const slot of slots.values()) {
|
|
5977
|
-
await fs6.mkdir(
|
|
5852
|
+
await fs6.mkdir(path9.dirname(slot.norm), { recursive: true });
|
|
5978
5853
|
await fs6.writeFile(slot.norm, slot.content ?? "", "utf-8");
|
|
5979
5854
|
}
|
|
5980
5855
|
const { combinedDiff, relList, primaryNorm } = buildBatchDiffAndPaths(slots);
|
|
@@ -6034,7 +5909,7 @@ async function editTool(args) {
|
|
|
6034
5909
|
};
|
|
6035
5910
|
}
|
|
6036
5911
|
const workspaceRoot = resolveWorkspacePath(".");
|
|
6037
|
-
if (!normalizedFilePath.startsWith(workspaceRoot) && !
|
|
5912
|
+
if (!normalizedFilePath.startsWith(workspaceRoot) && !path9.isAbsolute(file_path)) {
|
|
6038
5913
|
return {
|
|
6039
5914
|
success: false,
|
|
6040
5915
|
error: `Invalid parameters: file_path must be within the current working directory or be an absolute path.`,
|
|
@@ -6055,11 +5930,11 @@ async function editTool(args) {
|
|
|
6055
5930
|
file_path: normalizedFilePath
|
|
6056
5931
|
};
|
|
6057
5932
|
}
|
|
6058
|
-
const dirPath =
|
|
5933
|
+
const dirPath = path9.dirname(normalizedFilePath);
|
|
6059
5934
|
await fs6.mkdir(dirPath, { recursive: true });
|
|
6060
5935
|
await fs6.writeFile(normalizedFilePath, editData.newContent, "utf-8");
|
|
6061
|
-
const relativePath =
|
|
6062
|
-
const filename =
|
|
5936
|
+
const relativePath = path9.relative(workspaceRoot, normalizedFilePath);
|
|
5937
|
+
const filename = path9.basename(normalizedFilePath);
|
|
6063
5938
|
if (editData.isNewFile) {
|
|
6064
5939
|
return {
|
|
6065
5940
|
success: true,
|
|
@@ -6114,7 +5989,7 @@ function message(args) {
|
|
|
6114
5989
|
|
|
6115
5990
|
// src/app/agent/tools/natives/ls.ts
|
|
6116
5991
|
import { promises as fs7 } from "fs";
|
|
6117
|
-
import
|
|
5992
|
+
import path10 from "path";
|
|
6118
5993
|
var DEFAULT_IGNORE = /* @__PURE__ */ new Set([
|
|
6119
5994
|
".git",
|
|
6120
5995
|
".gitignore",
|
|
@@ -6142,7 +6017,7 @@ async function ls(args) {
|
|
|
6142
6017
|
max_depth
|
|
6143
6018
|
} = args;
|
|
6144
6019
|
try {
|
|
6145
|
-
const basePath =
|
|
6020
|
+
const basePath = path10.resolve(directory_path);
|
|
6146
6021
|
if (!(await fs7.stat(basePath)).isDirectory()) {
|
|
6147
6022
|
throw new Error(`Directory '${directory_path}' not found.`);
|
|
6148
6023
|
}
|
|
@@ -6155,8 +6030,8 @@ async function ls(args) {
|
|
|
6155
6030
|
const entries = await fs7.readdir(currentDir, { withFileTypes: true });
|
|
6156
6031
|
for (const entry of entries) {
|
|
6157
6032
|
const entryName = entry.name;
|
|
6158
|
-
const fullPath =
|
|
6159
|
-
const posixPath = fullPath.split(
|
|
6033
|
+
const fullPath = path10.join(currentDir, entryName);
|
|
6034
|
+
const posixPath = fullPath.split(path10.sep).join("/");
|
|
6160
6035
|
const isHidden = entryName.startsWith(".");
|
|
6161
6036
|
if (allIgnorePatterns.has(entryName) || isHidden && !show_hidden) {
|
|
6162
6037
|
continue;
|
|
@@ -6167,7 +6042,7 @@ async function ls(args) {
|
|
|
6167
6042
|
await walk(fullPath, currentDepth + 1);
|
|
6168
6043
|
}
|
|
6169
6044
|
} else if (entry.isFile()) {
|
|
6170
|
-
if (!normalizedExtensions || normalizedExtensions.includes(
|
|
6045
|
+
if (!normalizedExtensions || normalizedExtensions.includes(path10.extname(entryName).toLowerCase())) {
|
|
6171
6046
|
allFiles.push(posixPath);
|
|
6172
6047
|
}
|
|
6173
6048
|
}
|
|
@@ -6178,7 +6053,7 @@ async function ls(args) {
|
|
|
6178
6053
|
allDirs.sort();
|
|
6179
6054
|
return {
|
|
6180
6055
|
success: true,
|
|
6181
|
-
path: basePath.split(
|
|
6056
|
+
path: basePath.split(path10.sep).join("/"),
|
|
6182
6057
|
recursive,
|
|
6183
6058
|
total_files: allFiles.length,
|
|
6184
6059
|
total_directories: allDirs.length,
|
|
@@ -6276,12 +6151,12 @@ async function countLines(args) {
|
|
|
6276
6151
|
// src/app/agent/runtime/task_store.ts
|
|
6277
6152
|
init_sandbox_policy();
|
|
6278
6153
|
import fs10 from "fs";
|
|
6279
|
-
import
|
|
6154
|
+
import path11 from "path";
|
|
6280
6155
|
var cache = null;
|
|
6281
6156
|
var cachePath = null;
|
|
6282
6157
|
function getStorePath() {
|
|
6283
6158
|
const policy = getSandboxPolicy();
|
|
6284
|
-
return
|
|
6159
|
+
return path11.join(policy.workspaceRoot, ".bluma", "task_state.json");
|
|
6285
6160
|
}
|
|
6286
6161
|
function getDefaultState() {
|
|
6287
6162
|
return {
|
|
@@ -6317,7 +6192,7 @@ function ensureLoaded() {
|
|
|
6317
6192
|
}
|
|
6318
6193
|
function persist(state) {
|
|
6319
6194
|
const storePath = getStorePath();
|
|
6320
|
-
fs10.mkdirSync(
|
|
6195
|
+
fs10.mkdirSync(path11.dirname(storePath), { recursive: true });
|
|
6321
6196
|
state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6322
6197
|
fs10.writeFileSync(storePath, JSON.stringify(state, null, 2), "utf-8");
|
|
6323
6198
|
cache = state;
|
|
@@ -6524,7 +6399,7 @@ function formatTodoResult(result) {
|
|
|
6524
6399
|
|
|
6525
6400
|
// src/app/agent/tools/natives/find_by_name.ts
|
|
6526
6401
|
init_sandbox_policy();
|
|
6527
|
-
import
|
|
6402
|
+
import path12 from "path";
|
|
6528
6403
|
import { promises as fsPromises } from "fs";
|
|
6529
6404
|
var DEFAULT_IGNORE_PATTERNS = [
|
|
6530
6405
|
"node_modules",
|
|
@@ -6564,7 +6439,7 @@ function shouldIgnore(name, ignorePatterns, includeHidden) {
|
|
|
6564
6439
|
}
|
|
6565
6440
|
function matchesExtensions(filename, extensions) {
|
|
6566
6441
|
if (!extensions || extensions.length === 0) return true;
|
|
6567
|
-
const ext =
|
|
6442
|
+
const ext = path12.extname(filename).toLowerCase();
|
|
6568
6443
|
return extensions.some((e) => {
|
|
6569
6444
|
const normalizedExt = e.startsWith(".") ? e.toLowerCase() : `.${e.toLowerCase()}`;
|
|
6570
6445
|
return ext === normalizedExt;
|
|
@@ -6586,8 +6461,8 @@ async function searchDirectory(dir, pattern, baseDir, options, results) {
|
|
|
6586
6461
|
if (shouldIgnore(name, options.ignorePatterns, options.includeHidden)) {
|
|
6587
6462
|
continue;
|
|
6588
6463
|
}
|
|
6589
|
-
const fullPath =
|
|
6590
|
-
const relativePath =
|
|
6464
|
+
const fullPath = path12.join(dir, name);
|
|
6465
|
+
const relativePath = path12.relative(baseDir, fullPath);
|
|
6591
6466
|
if (entry.isDirectory()) {
|
|
6592
6467
|
if (pattern.test(name)) {
|
|
6593
6468
|
results.push({
|
|
@@ -6643,7 +6518,7 @@ async function findByName(args) {
|
|
|
6643
6518
|
error: "Pattern is required and must be a string"
|
|
6644
6519
|
};
|
|
6645
6520
|
}
|
|
6646
|
-
const resolvedDir =
|
|
6521
|
+
const resolvedDir = path12.resolve(directory);
|
|
6647
6522
|
try {
|
|
6648
6523
|
const stats = await fsPromises.stat(resolvedDir);
|
|
6649
6524
|
if (!stats.isDirectory()) {
|
|
@@ -6704,7 +6579,7 @@ async function findByName(args) {
|
|
|
6704
6579
|
}
|
|
6705
6580
|
|
|
6706
6581
|
// src/app/agent/tools/natives/grep_search.ts
|
|
6707
|
-
import
|
|
6582
|
+
import path13 from "path";
|
|
6708
6583
|
import { promises as fsPromises2 } from "fs";
|
|
6709
6584
|
var MAX_RESULTS3 = 100;
|
|
6710
6585
|
var MAX_FILE_SIZE2 = 1024 * 1024;
|
|
@@ -6787,8 +6662,8 @@ var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
6787
6662
|
"Rakefile"
|
|
6788
6663
|
]);
|
|
6789
6664
|
function isTextFile(filepath) {
|
|
6790
|
-
const ext =
|
|
6791
|
-
const basename =
|
|
6665
|
+
const ext = path13.extname(filepath).toLowerCase();
|
|
6666
|
+
const basename = path13.basename(filepath);
|
|
6792
6667
|
if (TEXT_EXTENSIONS.has(ext)) return true;
|
|
6793
6668
|
if (TEXT_EXTENSIONS.has(basename)) return true;
|
|
6794
6669
|
if (basename.startsWith(".") && !ext) return true;
|
|
@@ -6833,7 +6708,7 @@ async function searchFile(filepath, baseDir, pattern, contextLines, matches, max
|
|
|
6833
6708
|
if (stats.size > MAX_FILE_SIZE2) return 0;
|
|
6834
6709
|
const content = await fsPromises2.readFile(filepath, "utf-8");
|
|
6835
6710
|
const lines = content.split("\n");
|
|
6836
|
-
const relativePath =
|
|
6711
|
+
const relativePath = path13.relative(baseDir, filepath);
|
|
6837
6712
|
for (let i = 0; i < lines.length && matches.length < maxResults; i++) {
|
|
6838
6713
|
const line = lines[i];
|
|
6839
6714
|
pattern.lastIndex = 0;
|
|
@@ -6873,7 +6748,7 @@ async function searchDirectory2(dir, baseDir, pattern, includePatterns, contextL
|
|
|
6873
6748
|
if (matches.length >= maxResults) break;
|
|
6874
6749
|
const name = entry.name;
|
|
6875
6750
|
if (shouldIgnore2(name)) continue;
|
|
6876
|
-
const fullPath =
|
|
6751
|
+
const fullPath = path13.join(dir, name);
|
|
6877
6752
|
if (entry.isDirectory()) {
|
|
6878
6753
|
await searchDirectory2(fullPath, baseDir, pattern, includePatterns, contextLines, matches, maxResults, stats);
|
|
6879
6754
|
} else if (entry.isFile()) {
|
|
@@ -6922,7 +6797,7 @@ async function grepSearch(args) {
|
|
|
6922
6797
|
error: "Search path is required"
|
|
6923
6798
|
};
|
|
6924
6799
|
}
|
|
6925
|
-
const resolvedPath =
|
|
6800
|
+
const resolvedPath = path13.resolve(searchPath);
|
|
6926
6801
|
let stats;
|
|
6927
6802
|
try {
|
|
6928
6803
|
stats = await fsPromises2.stat(resolvedPath);
|
|
@@ -6970,7 +6845,7 @@ async function grepSearch(args) {
|
|
|
6970
6845
|
);
|
|
6971
6846
|
} else if (stats.isFile()) {
|
|
6972
6847
|
searchStats.filesSearched = 1;
|
|
6973
|
-
const found = await searchFile(resolvedPath,
|
|
6848
|
+
const found = await searchFile(resolvedPath, path13.dirname(resolvedPath), pattern, context_lines, matches, max_results);
|
|
6974
6849
|
if (found > 0) searchStats.filesWithMatches = 1;
|
|
6975
6850
|
}
|
|
6976
6851
|
return {
|
|
@@ -6999,7 +6874,7 @@ async function grepSearch(args) {
|
|
|
6999
6874
|
}
|
|
7000
6875
|
|
|
7001
6876
|
// src/app/agent/tools/natives/view_file_outline.ts
|
|
7002
|
-
import
|
|
6877
|
+
import path14 from "path";
|
|
7003
6878
|
import { promises as fsPromises3 } from "fs";
|
|
7004
6879
|
var LANGUAGE_MAP = {
|
|
7005
6880
|
".ts": "typescript",
|
|
@@ -7113,7 +6988,7 @@ var PATTERNS = {
|
|
|
7113
6988
|
]
|
|
7114
6989
|
};
|
|
7115
6990
|
function detectLanguage(filepath) {
|
|
7116
|
-
const ext =
|
|
6991
|
+
const ext = path14.extname(filepath).toLowerCase();
|
|
7117
6992
|
return LANGUAGE_MAP[ext] || "unknown";
|
|
7118
6993
|
}
|
|
7119
6994
|
function determineItemType(line, language) {
|
|
@@ -7209,7 +7084,7 @@ async function viewFileOutline(args) {
|
|
|
7209
7084
|
error: "file_path is required and must be a string"
|
|
7210
7085
|
};
|
|
7211
7086
|
}
|
|
7212
|
-
const resolvedPath =
|
|
7087
|
+
const resolvedPath = path14.resolve(file_path);
|
|
7213
7088
|
let content;
|
|
7214
7089
|
try {
|
|
7215
7090
|
content = await fsPromises3.readFile(resolvedPath, "utf-8");
|
|
@@ -7254,21 +7129,21 @@ init_async_command();
|
|
|
7254
7129
|
|
|
7255
7130
|
// src/app/agent/tools/natives/task_boundary.ts
|
|
7256
7131
|
init_sandbox_policy();
|
|
7257
|
-
import
|
|
7132
|
+
import path15 from "path";
|
|
7258
7133
|
import { promises as fs11 } from "fs";
|
|
7259
7134
|
var artifactsDir = null;
|
|
7260
7135
|
async function getArtifactsDir() {
|
|
7261
7136
|
if (artifactsDir) return artifactsDir;
|
|
7262
7137
|
const policy = getSandboxPolicy();
|
|
7263
|
-
const baseDir =
|
|
7138
|
+
const baseDir = path15.join(policy.workspaceRoot, ".bluma", "artifacts");
|
|
7264
7139
|
const sessionId = Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
|
|
7265
|
-
artifactsDir =
|
|
7140
|
+
artifactsDir = path15.join(baseDir, sessionId);
|
|
7266
7141
|
await fs11.mkdir(artifactsDir, { recursive: true });
|
|
7267
7142
|
return artifactsDir;
|
|
7268
7143
|
}
|
|
7269
7144
|
async function updateTaskFile(task) {
|
|
7270
7145
|
const dir = await getArtifactsDir();
|
|
7271
|
-
const taskFile =
|
|
7146
|
+
const taskFile = path15.join(dir, "task.md");
|
|
7272
7147
|
const content = `# ${task.taskName}
|
|
7273
7148
|
|
|
7274
7149
|
**Mode:** ${task.mode}
|
|
@@ -7404,7 +7279,7 @@ async function createArtifact(args) {
|
|
|
7404
7279
|
return { success: false, error: "content is required" };
|
|
7405
7280
|
}
|
|
7406
7281
|
const dir = await getArtifactsDir();
|
|
7407
|
-
const filepath =
|
|
7282
|
+
const filepath = path15.join(dir, filename);
|
|
7408
7283
|
await fs11.writeFile(filepath, content, "utf-8");
|
|
7409
7284
|
return {
|
|
7410
7285
|
success: true,
|
|
@@ -7424,7 +7299,7 @@ async function readArtifact(args) {
|
|
|
7424
7299
|
return { success: false, error: "filename is required" };
|
|
7425
7300
|
}
|
|
7426
7301
|
const dir = await getArtifactsDir();
|
|
7427
|
-
const filepath =
|
|
7302
|
+
const filepath = path15.join(dir, filename);
|
|
7428
7303
|
const content = await fs11.readFile(filepath, "utf-8");
|
|
7429
7304
|
return {
|
|
7430
7305
|
success: true,
|
|
@@ -7970,7 +7845,7 @@ ${skill.content}`;
|
|
|
7970
7845
|
|
|
7971
7846
|
// src/app/agent/tools/natives/coding_memory.ts
|
|
7972
7847
|
import * as fs12 from "fs";
|
|
7973
|
-
import * as
|
|
7848
|
+
import * as path16 from "path";
|
|
7974
7849
|
import os8 from "os";
|
|
7975
7850
|
var PROMPT_DEFAULT_MAX_TOTAL = 1e4;
|
|
7976
7851
|
var PROMPT_DEFAULT_MAX_NOTES = 25;
|
|
@@ -7979,13 +7854,13 @@ function readCodingMemoryForPrompt(options) {
|
|
|
7979
7854
|
const maxTotal = options?.maxTotalChars ?? PROMPT_DEFAULT_MAX_TOTAL;
|
|
7980
7855
|
const maxNotes = options?.maxNotes ?? PROMPT_DEFAULT_MAX_NOTES;
|
|
7981
7856
|
const preview = options?.previewCharsPerNote ?? PROMPT_DEFAULT_PREVIEW;
|
|
7982
|
-
const globalPath =
|
|
7983
|
-
const legacyPath =
|
|
7857
|
+
const globalPath = path16.join(os8.homedir(), ".bluma", "coding_memory.json");
|
|
7858
|
+
const legacyPath = path16.join(process.cwd(), ".bluma", "coding_memory.json");
|
|
7984
7859
|
let raw = null;
|
|
7985
7860
|
try {
|
|
7986
7861
|
if (fs12.existsSync(globalPath)) {
|
|
7987
7862
|
raw = fs12.readFileSync(globalPath, "utf-8");
|
|
7988
|
-
} else if (
|
|
7863
|
+
} else if (path16.resolve(globalPath) !== path16.resolve(legacyPath) && fs12.existsSync(legacyPath)) {
|
|
7989
7864
|
raw = fs12.readFileSync(legacyPath, "utf-8");
|
|
7990
7865
|
}
|
|
7991
7866
|
} catch {
|
|
@@ -8024,10 +7899,10 @@ var memoryStore = [];
|
|
|
8024
7899
|
var nextId = 1;
|
|
8025
7900
|
var loaded = false;
|
|
8026
7901
|
function getMemoryFilePath() {
|
|
8027
|
-
return
|
|
7902
|
+
return path16.join(os8.homedir(), ".bluma", "coding_memory.json");
|
|
8028
7903
|
}
|
|
8029
7904
|
function getLegacyMemoryFilePath() {
|
|
8030
|
-
return
|
|
7905
|
+
return path16.join(process.cwd(), ".bluma", "coding_memory.json");
|
|
8031
7906
|
}
|
|
8032
7907
|
function loadMemoryFromFile() {
|
|
8033
7908
|
if (loaded) return;
|
|
@@ -8037,7 +7912,7 @@ function loadMemoryFromFile() {
|
|
|
8037
7912
|
try {
|
|
8038
7913
|
const filePath = getMemoryFilePath();
|
|
8039
7914
|
const legacy = getLegacyMemoryFilePath();
|
|
8040
|
-
const legacyDistinct =
|
|
7915
|
+
const legacyDistinct = path16.resolve(legacy) !== path16.resolve(filePath);
|
|
8041
7916
|
const readIntoStore = (p) => {
|
|
8042
7917
|
const raw = fs12.readFileSync(p, "utf-8");
|
|
8043
7918
|
const parsed = JSON.parse(raw);
|
|
@@ -8063,7 +7938,7 @@ function loadMemoryFromFile() {
|
|
|
8063
7938
|
function saveMemoryToFile() {
|
|
8064
7939
|
try {
|
|
8065
7940
|
const filePath = getMemoryFilePath();
|
|
8066
|
-
const dir =
|
|
7941
|
+
const dir = path16.dirname(filePath);
|
|
8067
7942
|
if (!fs12.existsSync(dir)) {
|
|
8068
7943
|
fs12.mkdirSync(dir, { recursive: true });
|
|
8069
7944
|
}
|
|
@@ -8683,7 +8558,7 @@ async function notebook_edit(args) {
|
|
|
8683
8558
|
init_sandbox_policy();
|
|
8684
8559
|
import { spawn as spawn3 } from "child_process";
|
|
8685
8560
|
import * as fs14 from "fs";
|
|
8686
|
-
import * as
|
|
8561
|
+
import * as path17 from "path";
|
|
8687
8562
|
import { pathToFileURL } from "url";
|
|
8688
8563
|
var RpcBuffer = class {
|
|
8689
8564
|
buf = Buffer.alloc(0);
|
|
@@ -8738,7 +8613,7 @@ async function lsp_query(args) {
|
|
|
8738
8613
|
}
|
|
8739
8614
|
const content = fs14.readFileSync(resolved, "utf-8");
|
|
8740
8615
|
const uri = pathToFileURL(resolved).href;
|
|
8741
|
-
const root =
|
|
8616
|
+
const root = path17.dirname(resolved);
|
|
8742
8617
|
const line0 = Math.max(0, Math.floor(Number(args.line) || 1) - 1);
|
|
8743
8618
|
const character = Math.max(0, Math.floor(Number(args.character ?? 0)));
|
|
8744
8619
|
const operation = args.operation === "references" ? "references" : "definition";
|
|
@@ -8859,7 +8734,7 @@ async function lsp_query(args) {
|
|
|
8859
8734
|
// src/app/agent/tools/natives/file_write.ts
|
|
8860
8735
|
init_sandbox_policy();
|
|
8861
8736
|
import { promises as fs15 } from "fs";
|
|
8862
|
-
import
|
|
8737
|
+
import path18 from "path";
|
|
8863
8738
|
async function fileWrite(args) {
|
|
8864
8739
|
const {
|
|
8865
8740
|
filepath,
|
|
@@ -8875,7 +8750,7 @@ async function fileWrite(args) {
|
|
|
8875
8750
|
return { success: false, error: "content is required" };
|
|
8876
8751
|
}
|
|
8877
8752
|
const resolvedPath = resolveWorkspacePath(filepath);
|
|
8878
|
-
const dir =
|
|
8753
|
+
const dir = path18.dirname(resolvedPath);
|
|
8879
8754
|
let existed = false;
|
|
8880
8755
|
try {
|
|
8881
8756
|
const st = await fs15.stat(resolvedPath);
|
|
@@ -9137,7 +9012,7 @@ async function signalMailbox(args) {
|
|
|
9137
9012
|
// src/app/agent/tools/natives/repl.ts
|
|
9138
9013
|
import fs20 from "fs";
|
|
9139
9014
|
import os13 from "os";
|
|
9140
|
-
import
|
|
9015
|
+
import path23 from "path";
|
|
9141
9016
|
import { exec } from "child_process";
|
|
9142
9017
|
import { v4 as uuidv47 } from "uuid";
|
|
9143
9018
|
import { promisify as promisify2 } from "util";
|
|
@@ -9149,19 +9024,19 @@ async function repl(params) {
|
|
|
9149
9024
|
let tempFile;
|
|
9150
9025
|
switch (language) {
|
|
9151
9026
|
case "python": {
|
|
9152
|
-
tempFile =
|
|
9027
|
+
tempFile = path23.join(os13.tmpdir(), `bluma_repl_${uuidv47()}.py`);
|
|
9153
9028
|
fs20.writeFileSync(tempFile, code, "utf-8");
|
|
9154
9029
|
command = `python3 "${tempFile}"`;
|
|
9155
9030
|
break;
|
|
9156
9031
|
}
|
|
9157
9032
|
case "node": {
|
|
9158
|
-
tempFile =
|
|
9033
|
+
tempFile = path23.join(os13.tmpdir(), `bluma_repl_${uuidv47()}.mjs`);
|
|
9159
9034
|
fs20.writeFileSync(tempFile, code, "utf-8");
|
|
9160
9035
|
command = `node "${tempFile}"`;
|
|
9161
9036
|
break;
|
|
9162
9037
|
}
|
|
9163
9038
|
case "bash": {
|
|
9164
|
-
tempFile =
|
|
9039
|
+
tempFile = path23.join(os13.tmpdir(), `bluma_repl_${uuidv47()}.sh`);
|
|
9165
9040
|
fs20.writeFileSync(tempFile, `#!/bin/bash
|
|
9166
9041
|
set -e
|
|
9167
9042
|
${code}`, "utf-8");
|
|
@@ -9537,7 +9412,7 @@ ${preview}${toRemove.length > 5 ? `
|
|
|
9537
9412
|
// src/app/agent/tools/natives/brief.ts
|
|
9538
9413
|
init_sandbox_policy();
|
|
9539
9414
|
import * as fs21 from "fs";
|
|
9540
|
-
import * as
|
|
9415
|
+
import * as path24 from "path";
|
|
9541
9416
|
async function brief(args) {
|
|
9542
9417
|
const sentAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
9543
9418
|
if (!args.message || !args.message.trim()) {
|
|
@@ -9556,7 +9431,7 @@ async function brief(args) {
|
|
|
9556
9431
|
const resolved = [];
|
|
9557
9432
|
for (const filePath of args.attachments) {
|
|
9558
9433
|
try {
|
|
9559
|
-
const absolutePath =
|
|
9434
|
+
const absolutePath = path24.isAbsolute(filePath) ? filePath : path24.join(resolveWorkspacePath("."), filePath);
|
|
9560
9435
|
if (fs21.existsSync(absolutePath)) {
|
|
9561
9436
|
const stat = fs21.statSync(absolutePath);
|
|
9562
9437
|
resolved.push({
|
|
@@ -9598,13 +9473,13 @@ async function brief(args) {
|
|
|
9598
9473
|
|
|
9599
9474
|
// src/app/agent/tools/natives/dream_engine.ts
|
|
9600
9475
|
import * as fs22 from "fs";
|
|
9601
|
-
import * as
|
|
9476
|
+
import * as path25 from "path";
|
|
9602
9477
|
import os14 from "os";
|
|
9603
9478
|
function memoryPath() {
|
|
9604
|
-
return
|
|
9479
|
+
return path25.join(process.env.HOME || os14.homedir(), ".bluma", "coding_memory.json");
|
|
9605
9480
|
}
|
|
9606
9481
|
function sessionsDir() {
|
|
9607
|
-
return
|
|
9482
|
+
return path25.join(process.env.HOME || os14.homedir(), ".bluma", "sessions");
|
|
9608
9483
|
}
|
|
9609
9484
|
function normalizeNote(note) {
|
|
9610
9485
|
return note.trim().toLowerCase().replace(/\s+/g, " ");
|
|
@@ -9713,7 +9588,7 @@ async function dream(args = {}) {
|
|
|
9713
9588
|
const sessionFiles = fs22.readdirSync(sessDir).filter((f) => f.endsWith(".json")).slice(-5);
|
|
9714
9589
|
for (const sf of sessionFiles) {
|
|
9715
9590
|
try {
|
|
9716
|
-
const sessionData = JSON.parse(fs22.readFileSync(
|
|
9591
|
+
const sessionData = JSON.parse(fs22.readFileSync(path25.join(sessDir, sf), "utf-8"));
|
|
9717
9592
|
if (sessionData?.summary) {
|
|
9718
9593
|
consolidatedMemories.push(`Session ${sf}: ${sessionData.summary}`);
|
|
9719
9594
|
}
|
|
@@ -9925,7 +9800,7 @@ init_agent_coordination();
|
|
|
9925
9800
|
// src/app/agent/tools/natives/create-next-app.ts
|
|
9926
9801
|
init_sandbox_policy();
|
|
9927
9802
|
import { promises as fs23 } from "fs";
|
|
9928
|
-
import
|
|
9803
|
+
import path26 from "path";
|
|
9929
9804
|
|
|
9930
9805
|
// src/app/agent/tools/natives/shell_command.ts
|
|
9931
9806
|
init_sandbox_policy();
|
|
@@ -10687,7 +10562,7 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
10687
10562
|
`
|
|
10688
10563
|
};
|
|
10689
10564
|
async function createFile(filePath, content, projectName) {
|
|
10690
|
-
const dir =
|
|
10565
|
+
const dir = path26.dirname(filePath);
|
|
10691
10566
|
await fs23.mkdir(dir, { recursive: true });
|
|
10692
10567
|
const replacedContent = content.replace(/{{NAME}}/g, projectName);
|
|
10693
10568
|
await fs23.writeFile(filePath, replacedContent, "utf-8");
|
|
@@ -10709,7 +10584,7 @@ async function createNextApp(args) {
|
|
|
10709
10584
|
};
|
|
10710
10585
|
}
|
|
10711
10586
|
const baseDir = directory ? resolveWorkspacePath(directory) : resolveWorkspacePath(".");
|
|
10712
|
-
const projectPath =
|
|
10587
|
+
const projectPath = path26.join(baseDir, name);
|
|
10713
10588
|
try {
|
|
10714
10589
|
await fs23.access(projectPath);
|
|
10715
10590
|
return {
|
|
@@ -10723,12 +10598,12 @@ async function createNextApp(args) {
|
|
|
10723
10598
|
const filesCreated = [];
|
|
10724
10599
|
for (const [relativePath, content] of Object.entries(filesToCreate)) {
|
|
10725
10600
|
if (relativePath === "package.json.full") continue;
|
|
10726
|
-
const fullPath =
|
|
10601
|
+
const fullPath = path26.join(projectPath, relativePath);
|
|
10727
10602
|
await createFile(fullPath, content, name);
|
|
10728
10603
|
filesCreated.push(relativePath);
|
|
10729
10604
|
}
|
|
10730
10605
|
if (template === "full") {
|
|
10731
|
-
const packageJsonPath =
|
|
10606
|
+
const packageJsonPath = path26.join(projectPath, "package.json");
|
|
10732
10607
|
const fullPackageJson = FULL_FILES["package.json.full"];
|
|
10733
10608
|
if (fullPackageJson) {
|
|
10734
10609
|
await createFile(packageJsonPath, fullPackageJson, name);
|
|
@@ -10771,7 +10646,7 @@ async function createNextApp(args) {
|
|
|
10771
10646
|
// src/app/agent/tools/natives/deploy-app.ts
|
|
10772
10647
|
init_sandbox_policy();
|
|
10773
10648
|
import { promises as fs24 } from "fs";
|
|
10774
|
-
import
|
|
10649
|
+
import path27 from "path";
|
|
10775
10650
|
var EXCLUDE_PATTERNS = [
|
|
10776
10651
|
"node_modules",
|
|
10777
10652
|
".next",
|
|
@@ -10921,7 +10796,7 @@ function buildFactorAiManifest(appContext, deployResult, appName) {
|
|
|
10921
10796
|
}
|
|
10922
10797
|
async function writeFactorAiManifest(projectDir, appContext, deployResult, appName) {
|
|
10923
10798
|
const manifest = buildFactorAiManifest(appContext, deployResult, appName);
|
|
10924
|
-
const manifestPath =
|
|
10799
|
+
const manifestPath = path27.join(projectDir, "factorai.sh.json");
|
|
10925
10800
|
await fs24.writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
10926
10801
|
`, "utf-8");
|
|
10927
10802
|
return manifest;
|
|
@@ -10949,7 +10824,7 @@ async function deployApp(args) {
|
|
|
10949
10824
|
error: `Project directory not found: ${resolvedProjectDir}`
|
|
10950
10825
|
};
|
|
10951
10826
|
}
|
|
10952
|
-
const packageJsonPath =
|
|
10827
|
+
const packageJsonPath = path27.join(resolvedProjectDir, "package.json");
|
|
10953
10828
|
try {
|
|
10954
10829
|
await fs24.access(packageJsonPath);
|
|
10955
10830
|
} catch {
|
|
@@ -10967,10 +10842,10 @@ async function deployApp(args) {
|
|
|
10967
10842
|
error: "Not a Next.js project: next not found in dependencies"
|
|
10968
10843
|
};
|
|
10969
10844
|
}
|
|
10970
|
-
const appName = name || packageJson.name ||
|
|
10971
|
-
const tempDir =
|
|
10845
|
+
const appName = name || packageJson.name || path27.basename(resolvedProjectDir);
|
|
10846
|
+
const tempDir = path27.join(resolvedProjectDir, ".tmp");
|
|
10972
10847
|
await fs24.mkdir(tempDir, { recursive: true });
|
|
10973
|
-
const zipPath =
|
|
10848
|
+
const zipPath = path27.join(tempDir, `${appName}-${Date.now()}.zip`);
|
|
10974
10849
|
console.log(`[deploy-app] Creating ZIP: ${zipPath}`);
|
|
10975
10850
|
await createProjectZip(resolvedProjectDir, zipPath);
|
|
10976
10851
|
const zipStats = await fs24.stat(zipPath);
|
|
@@ -11003,7 +10878,7 @@ async function deployApp(args) {
|
|
|
11003
10878
|
appName
|
|
11004
10879
|
);
|
|
11005
10880
|
deployResult.factoraiManifest = manifest;
|
|
11006
|
-
deployResult.factoraiManifestPath =
|
|
10881
|
+
deployResult.factoraiManifestPath = path27.join(resolvedProjectDir, "factorai.sh.json");
|
|
11007
10882
|
}
|
|
11008
10883
|
console.log(`[deploy-app] Deploy iniciado: ${deployResult.appId}`);
|
|
11009
10884
|
}
|
|
@@ -11019,7 +10894,7 @@ async function deployApp(args) {
|
|
|
11019
10894
|
|
|
11020
10895
|
// src/app/agent/runtime/factorai_context.ts
|
|
11021
10896
|
import fs25 from "fs";
|
|
11022
|
-
import
|
|
10897
|
+
import path28 from "path";
|
|
11023
10898
|
function normalizeContext(raw) {
|
|
11024
10899
|
if (!raw || typeof raw.appId !== "string" || !raw.appId.trim()) {
|
|
11025
10900
|
return null;
|
|
@@ -11053,7 +10928,7 @@ function readJsonFile(filePath) {
|
|
|
11053
10928
|
return null;
|
|
11054
10929
|
}
|
|
11055
10930
|
function readFactorAiWorkspaceManifest(projectDir = process.cwd()) {
|
|
11056
|
-
const manifestPath =
|
|
10931
|
+
const manifestPath = path28.join(projectDir, "factorai.sh.json");
|
|
11057
10932
|
try {
|
|
11058
10933
|
if (!fs25.existsSync(manifestPath)) {
|
|
11059
10934
|
return null;
|
|
@@ -11065,7 +10940,7 @@ function readFactorAiWorkspaceManifest(projectDir = process.cwd()) {
|
|
|
11065
10940
|
}
|
|
11066
10941
|
}
|
|
11067
10942
|
function readContextFromWorkspace() {
|
|
11068
|
-
const candidate =
|
|
10943
|
+
const candidate = path28.join(process.cwd(), "factorai.sh.json");
|
|
11069
10944
|
const parsed = readJsonFile(candidate);
|
|
11070
10945
|
if (!parsed) {
|
|
11071
10946
|
return null;
|
|
@@ -11152,7 +11027,7 @@ function buildFactorAiWorkspaceManifest(input) {
|
|
|
11152
11027
|
async function writeFactorAiWorkspaceManifest(input) {
|
|
11153
11028
|
const projectDir = input.projectDir || process.cwd();
|
|
11154
11029
|
const manifest = buildFactorAiWorkspaceManifest({ ...input, projectDir });
|
|
11155
|
-
const manifestPath =
|
|
11030
|
+
const manifestPath = path28.join(projectDir, "factorai.sh.json");
|
|
11156
11031
|
fs25.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
11157
11032
|
`, "utf8");
|
|
11158
11033
|
return { manifestPath, manifest };
|
|
@@ -12066,8 +11941,8 @@ var ToolInvoker = class {
|
|
|
12066
11941
|
async initialize() {
|
|
12067
11942
|
try {
|
|
12068
11943
|
const currentFilePath = fileURLToPath2(import.meta.url);
|
|
12069
|
-
const currentDirPath =
|
|
12070
|
-
const configPath =
|
|
11944
|
+
const currentDirPath = path29.dirname(currentFilePath);
|
|
11945
|
+
const configPath = path29.resolve(currentDirPath, "config", "native_tools.json");
|
|
12071
11946
|
const fileContent = await fs26.readFile(configPath, "utf-8");
|
|
12072
11947
|
const config2 = JSON.parse(fileContent);
|
|
12073
11948
|
this.toolDefinitions = applyMetadataToToolDefinitions(config2.nativeTools);
|
|
@@ -12113,7 +11988,7 @@ var ToolInvoker = class {
|
|
|
12113
11988
|
|
|
12114
11989
|
// src/app/agent/tools/mcp/mcp_client.ts
|
|
12115
11990
|
import { promises as fs27 } from "fs";
|
|
12116
|
-
import
|
|
11991
|
+
import path30 from "path";
|
|
12117
11992
|
import os16 from "os";
|
|
12118
11993
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
12119
11994
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
@@ -12141,9 +12016,9 @@ var MCPClient = class {
|
|
|
12141
12016
|
});
|
|
12142
12017
|
}
|
|
12143
12018
|
const __filename = fileURLToPath3(import.meta.url);
|
|
12144
|
-
const __dirname =
|
|
12145
|
-
const defaultConfigPath =
|
|
12146
|
-
const userConfigPath =
|
|
12019
|
+
const __dirname = path30.dirname(__filename);
|
|
12020
|
+
const defaultConfigPath = path30.resolve(__dirname, "config", "bluma-mcp.json");
|
|
12021
|
+
const userConfigPath = path30.join(os16.homedir(), ".bluma", "bluma-mcp.json");
|
|
12147
12022
|
const defaultConfig = await this.loadMcpConfig(defaultConfigPath, "Default");
|
|
12148
12023
|
const userConfig = await this.loadMcpConfig(userConfigPath, "User");
|
|
12149
12024
|
const mergedConfig = {
|
|
@@ -12354,11 +12229,11 @@ PENALTY APPLIED: ${penalty.toFixed(1)} points deducted.
|
|
|
12354
12229
|
};
|
|
12355
12230
|
|
|
12356
12231
|
// src/app/agent/bluma/core/bluma.ts
|
|
12357
|
-
import
|
|
12232
|
+
import path40 from "path";
|
|
12358
12233
|
import { v4 as uuidv48 } from "uuid";
|
|
12359
12234
|
|
|
12360
12235
|
// src/app/agent/session_manager/session_manager.ts
|
|
12361
|
-
import
|
|
12236
|
+
import path31 from "path";
|
|
12362
12237
|
import os17 from "os";
|
|
12363
12238
|
import { promises as fs28 } from "fs";
|
|
12364
12239
|
var fileLocks = /* @__PURE__ */ new Map();
|
|
@@ -12396,13 +12271,13 @@ function debouncedSave(sessionFile, history, memory) {
|
|
|
12396
12271
|
function expandHome(p) {
|
|
12397
12272
|
if (!p) return p;
|
|
12398
12273
|
if (p.startsWith("~")) {
|
|
12399
|
-
return
|
|
12274
|
+
return path31.join(os17.homedir(), p.slice(1));
|
|
12400
12275
|
}
|
|
12401
12276
|
return p;
|
|
12402
12277
|
}
|
|
12403
12278
|
function getPreferredAppDir() {
|
|
12404
|
-
const fixed =
|
|
12405
|
-
return
|
|
12279
|
+
const fixed = path31.join(os17.homedir(), ".bluma");
|
|
12280
|
+
return path31.resolve(expandHome(fixed));
|
|
12406
12281
|
}
|
|
12407
12282
|
async function safeRenameWithRetry(src, dest, maxRetries = 6) {
|
|
12408
12283
|
let attempt = 0;
|
|
@@ -12410,7 +12285,7 @@ async function safeRenameWithRetry(src, dest, maxRetries = 6) {
|
|
|
12410
12285
|
const isWin = process.platform === "win32";
|
|
12411
12286
|
while (attempt <= maxRetries) {
|
|
12412
12287
|
try {
|
|
12413
|
-
const dir =
|
|
12288
|
+
const dir = path31.dirname(dest);
|
|
12414
12289
|
await fs28.mkdir(dir, { recursive: true }).catch(() => {
|
|
12415
12290
|
});
|
|
12416
12291
|
await fs28.rename(src, dest);
|
|
@@ -12428,7 +12303,7 @@ async function safeRenameWithRetry(src, dest, maxRetries = 6) {
|
|
|
12428
12303
|
try {
|
|
12429
12304
|
await fs28.access(src);
|
|
12430
12305
|
const data = await fs28.readFile(src);
|
|
12431
|
-
const dir =
|
|
12306
|
+
const dir = path31.dirname(dest);
|
|
12432
12307
|
await fs28.mkdir(dir, { recursive: true }).catch(() => {
|
|
12433
12308
|
});
|
|
12434
12309
|
await fs28.writeFile(dest, data);
|
|
@@ -12445,13 +12320,13 @@ async function safeRenameWithRetry(src, dest, maxRetries = 6) {
|
|
|
12445
12320
|
}
|
|
12446
12321
|
async function ensureSessionDir() {
|
|
12447
12322
|
const appDir = getPreferredAppDir();
|
|
12448
|
-
const sessionDir =
|
|
12323
|
+
const sessionDir = path31.join(appDir, "sessions");
|
|
12449
12324
|
await fs28.mkdir(sessionDir, { recursive: true });
|
|
12450
12325
|
return sessionDir;
|
|
12451
12326
|
}
|
|
12452
12327
|
async function loadOrcreateSession(sessionId) {
|
|
12453
12328
|
const sessionDir = await ensureSessionDir();
|
|
12454
|
-
const sessionFile =
|
|
12329
|
+
const sessionFile = path31.join(sessionDir, `${sessionId}.json`);
|
|
12455
12330
|
try {
|
|
12456
12331
|
await fs28.access(sessionFile);
|
|
12457
12332
|
const fileContent = await fs28.readFile(sessionFile, "utf-8");
|
|
@@ -12479,7 +12354,7 @@ async function doSaveSessionHistory(sessionFile, history, memory) {
|
|
|
12479
12354
|
await withFileLock(sessionFile, async () => {
|
|
12480
12355
|
let sessionData;
|
|
12481
12356
|
try {
|
|
12482
|
-
const dir =
|
|
12357
|
+
const dir = path31.dirname(sessionFile);
|
|
12483
12358
|
await fs28.mkdir(dir, { recursive: true });
|
|
12484
12359
|
} catch {
|
|
12485
12360
|
}
|
|
@@ -12495,7 +12370,7 @@ async function doSaveSessionHistory(sessionFile, history, memory) {
|
|
|
12495
12370
|
console.warn(`An unknown error occurred while reading ${sessionFile}. Re-initializing.`, error);
|
|
12496
12371
|
}
|
|
12497
12372
|
}
|
|
12498
|
-
const sessionId =
|
|
12373
|
+
const sessionId = path31.basename(sessionFile, ".json");
|
|
12499
12374
|
sessionData = {
|
|
12500
12375
|
session_id: sessionId,
|
|
12501
12376
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -12546,12 +12421,12 @@ async function saveSessionHistory(sessionFile, history, memory) {
|
|
|
12546
12421
|
// src/app/agent/core/prompt/prompt_builder.ts
|
|
12547
12422
|
import os22 from "os";
|
|
12548
12423
|
import fs35 from "fs";
|
|
12549
|
-
import
|
|
12424
|
+
import path38 from "path";
|
|
12550
12425
|
import { execSync as execSync4 } from "child_process";
|
|
12551
12426
|
|
|
12552
12427
|
// src/app/agent/skills/skill_loader.ts
|
|
12553
12428
|
import fs29 from "fs";
|
|
12554
|
-
import
|
|
12429
|
+
import path32 from "path";
|
|
12555
12430
|
import os18 from "os";
|
|
12556
12431
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
12557
12432
|
var SkillLoader = class _SkillLoader {
|
|
@@ -12561,8 +12436,8 @@ var SkillLoader = class _SkillLoader {
|
|
|
12561
12436
|
cache = /* @__PURE__ */ new Map();
|
|
12562
12437
|
conflicts = [];
|
|
12563
12438
|
constructor(projectRoot, bundledDir) {
|
|
12564
|
-
this.projectSkillsDir =
|
|
12565
|
-
this.globalSkillsDir =
|
|
12439
|
+
this.projectSkillsDir = path32.join(projectRoot, ".bluma", "skills");
|
|
12440
|
+
this.globalSkillsDir = path32.join(os18.homedir(), ".bluma", "skills");
|
|
12566
12441
|
this.bundledSkillsDir = bundledDir || _SkillLoader.resolveBundledDir();
|
|
12567
12442
|
}
|
|
12568
12443
|
/**
|
|
@@ -12571,32 +12446,32 @@ var SkillLoader = class _SkillLoader {
|
|
|
12571
12446
|
*/
|
|
12572
12447
|
static resolveBundledDir() {
|
|
12573
12448
|
if (process.env.JEST_WORKER_ID !== void 0 || process.env.NODE_ENV === "test") {
|
|
12574
|
-
return
|
|
12449
|
+
return path32.join(process.cwd(), "dist", "config", "skills");
|
|
12575
12450
|
}
|
|
12576
12451
|
const candidates = [];
|
|
12577
12452
|
const push = (p) => {
|
|
12578
|
-
const abs =
|
|
12453
|
+
const abs = path32.resolve(p);
|
|
12579
12454
|
if (!candidates.includes(abs)) {
|
|
12580
12455
|
candidates.push(abs);
|
|
12581
12456
|
}
|
|
12582
12457
|
};
|
|
12583
12458
|
let argvBundled = null;
|
|
12584
12459
|
try {
|
|
12585
|
-
const bundleDir =
|
|
12586
|
-
push(
|
|
12460
|
+
const bundleDir = path32.dirname(fileURLToPath4(import.meta.url));
|
|
12461
|
+
push(path32.join(bundleDir, "config", "skills"));
|
|
12587
12462
|
} catch {
|
|
12588
12463
|
}
|
|
12589
12464
|
const argv1 = process.argv[1];
|
|
12590
12465
|
if (argv1 && !argv1.startsWith("-")) {
|
|
12591
12466
|
try {
|
|
12592
12467
|
let resolved = argv1;
|
|
12593
|
-
if (
|
|
12468
|
+
if (path32.isAbsolute(argv1) && fs29.existsSync(argv1)) {
|
|
12594
12469
|
resolved = fs29.realpathSync(argv1);
|
|
12595
|
-
} else if (!
|
|
12596
|
-
resolved =
|
|
12470
|
+
} else if (!path32.isAbsolute(argv1)) {
|
|
12471
|
+
resolved = path32.resolve(process.cwd(), argv1);
|
|
12597
12472
|
}
|
|
12598
|
-
const scriptDir =
|
|
12599
|
-
argvBundled =
|
|
12473
|
+
const scriptDir = path32.dirname(resolved);
|
|
12474
|
+
argvBundled = path32.join(scriptDir, "config", "skills");
|
|
12600
12475
|
push(argvBundled);
|
|
12601
12476
|
} catch {
|
|
12602
12477
|
}
|
|
@@ -12607,12 +12482,12 @@ var SkillLoader = class _SkillLoader {
|
|
|
12607
12482
|
}
|
|
12608
12483
|
}
|
|
12609
12484
|
try {
|
|
12610
|
-
return
|
|
12485
|
+
return path32.join(path32.dirname(fileURLToPath4(import.meta.url)), "config", "skills");
|
|
12611
12486
|
} catch {
|
|
12612
12487
|
if (argvBundled) {
|
|
12613
12488
|
return argvBundled;
|
|
12614
12489
|
}
|
|
12615
|
-
return
|
|
12490
|
+
return path32.join(os18.homedir(), ".bluma", "__bundled_skills_unresolved__");
|
|
12616
12491
|
}
|
|
12617
12492
|
}
|
|
12618
12493
|
/**
|
|
@@ -12641,8 +12516,8 @@ var SkillLoader = class _SkillLoader {
|
|
|
12641
12516
|
this.conflicts.push({
|
|
12642
12517
|
name: skill.name,
|
|
12643
12518
|
userSource: source,
|
|
12644
|
-
userPath:
|
|
12645
|
-
bundledPath:
|
|
12519
|
+
userPath: path32.join(dir, skill.name, "SKILL.md"),
|
|
12520
|
+
bundledPath: path32.join(this.bundledSkillsDir, skill.name, "SKILL.md")
|
|
12646
12521
|
});
|
|
12647
12522
|
continue;
|
|
12648
12523
|
}
|
|
@@ -12653,9 +12528,9 @@ var SkillLoader = class _SkillLoader {
|
|
|
12653
12528
|
if (!fs29.existsSync(dir)) return [];
|
|
12654
12529
|
try {
|
|
12655
12530
|
return fs29.readdirSync(dir).filter((d) => {
|
|
12656
|
-
const fullPath =
|
|
12657
|
-
return fs29.statSync(fullPath).isDirectory() && fs29.existsSync(
|
|
12658
|
-
}).map((d) => this.loadMetadataFromPath(
|
|
12531
|
+
const fullPath = path32.join(dir, d);
|
|
12532
|
+
return fs29.statSync(fullPath).isDirectory() && fs29.existsSync(path32.join(fullPath, "SKILL.md"));
|
|
12533
|
+
}).map((d) => this.loadMetadataFromPath(path32.join(dir, d, "SKILL.md"), d, source)).filter((m) => m !== null);
|
|
12659
12534
|
} catch {
|
|
12660
12535
|
return [];
|
|
12661
12536
|
}
|
|
@@ -12685,9 +12560,9 @@ var SkillLoader = class _SkillLoader {
|
|
|
12685
12560
|
*/
|
|
12686
12561
|
load(name) {
|
|
12687
12562
|
if (this.cache.has(name)) return this.cache.get(name);
|
|
12688
|
-
const bundledPath =
|
|
12689
|
-
const projectPath =
|
|
12690
|
-
const globalPath =
|
|
12563
|
+
const bundledPath = path32.join(this.bundledSkillsDir, name, "SKILL.md");
|
|
12564
|
+
const projectPath = path32.join(this.projectSkillsDir, name, "SKILL.md");
|
|
12565
|
+
const globalPath = path32.join(this.globalSkillsDir, name, "SKILL.md");
|
|
12691
12566
|
const existsBundled = fs29.existsSync(bundledPath);
|
|
12692
12567
|
const existsProject = fs29.existsSync(projectPath);
|
|
12693
12568
|
const existsGlobal = fs29.existsSync(globalPath);
|
|
@@ -12731,7 +12606,7 @@ var SkillLoader = class _SkillLoader {
|
|
|
12731
12606
|
try {
|
|
12732
12607
|
const raw = fs29.readFileSync(skillPath, "utf-8");
|
|
12733
12608
|
const parsed = this.parseFrontmatter(raw);
|
|
12734
|
-
const skillDir =
|
|
12609
|
+
const skillDir = path32.dirname(skillPath);
|
|
12735
12610
|
return {
|
|
12736
12611
|
name: parsed.name || name,
|
|
12737
12612
|
description: parsed.description || "",
|
|
@@ -12740,8 +12615,8 @@ var SkillLoader = class _SkillLoader {
|
|
|
12740
12615
|
version: parsed.version,
|
|
12741
12616
|
author: parsed.author,
|
|
12742
12617
|
license: parsed.license,
|
|
12743
|
-
references: this.scanAssets(
|
|
12744
|
-
scripts: this.scanAssets(
|
|
12618
|
+
references: this.scanAssets(path32.join(skillDir, "references")),
|
|
12619
|
+
scripts: this.scanAssets(path32.join(skillDir, "scripts"))
|
|
12745
12620
|
};
|
|
12746
12621
|
} catch {
|
|
12747
12622
|
return null;
|
|
@@ -12751,11 +12626,11 @@ var SkillLoader = class _SkillLoader {
|
|
|
12751
12626
|
if (!fs29.existsSync(dir)) return [];
|
|
12752
12627
|
try {
|
|
12753
12628
|
return fs29.readdirSync(dir).filter((f) => {
|
|
12754
|
-
const fp =
|
|
12629
|
+
const fp = path32.join(dir, f);
|
|
12755
12630
|
return fs29.statSync(fp).isFile();
|
|
12756
12631
|
}).map((f) => ({
|
|
12757
12632
|
name: f,
|
|
12758
|
-
path:
|
|
12633
|
+
path: path32.resolve(dir, f)
|
|
12759
12634
|
}));
|
|
12760
12635
|
} catch {
|
|
12761
12636
|
return [];
|
|
@@ -12812,9 +12687,9 @@ var SkillLoader = class _SkillLoader {
|
|
|
12812
12687
|
this.cache.clear();
|
|
12813
12688
|
}
|
|
12814
12689
|
exists(name) {
|
|
12815
|
-
const bundledPath =
|
|
12816
|
-
const projectPath =
|
|
12817
|
-
const globalPath =
|
|
12690
|
+
const bundledPath = path32.join(this.bundledSkillsDir, name, "SKILL.md");
|
|
12691
|
+
const projectPath = path32.join(this.projectSkillsDir, name, "SKILL.md");
|
|
12692
|
+
const globalPath = path32.join(this.globalSkillsDir, name, "SKILL.md");
|
|
12818
12693
|
return fs29.existsSync(bundledPath) || fs29.existsSync(projectPath) || fs29.existsSync(globalPath);
|
|
12819
12694
|
}
|
|
12820
12695
|
/**
|
|
@@ -12848,12 +12723,12 @@ var SkillLoader = class _SkillLoader {
|
|
|
12848
12723
|
|
|
12849
12724
|
// src/app/agent/core/prompt/workspace_snapshot.ts
|
|
12850
12725
|
import fs31 from "fs";
|
|
12851
|
-
import
|
|
12726
|
+
import path34 from "path";
|
|
12852
12727
|
import { execSync as execSync3 } from "child_process";
|
|
12853
12728
|
|
|
12854
12729
|
// src/app/agent/utils/blumamd.ts
|
|
12855
12730
|
import fs30 from "fs";
|
|
12856
|
-
import
|
|
12731
|
+
import path33 from "path";
|
|
12857
12732
|
import os19 from "os";
|
|
12858
12733
|
import { execSync as execSync2 } from "child_process";
|
|
12859
12734
|
var MEMORY_INSTRUCTION_PROMPT = "Instru\xE7\xF5es de mem\xF3ria do BluMa (BLUMA.md) est\xE3o abaixo. Siga estas instru\xE7\xF5es exatamente como escritas. Estas instru\xE7\xF5es OVERRIDE qualquer comportamento padr\xE3o.";
|
|
@@ -12983,12 +12858,12 @@ var TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
12983
12858
|
function expandIncludePath(includePath, baseDir) {
|
|
12984
12859
|
const cleanPath = includePath.startsWith("@") ? includePath.slice(1) : includePath;
|
|
12985
12860
|
if (cleanPath.startsWith("~")) {
|
|
12986
|
-
return
|
|
12861
|
+
return path33.join(os19.homedir(), cleanPath.slice(1));
|
|
12987
12862
|
}
|
|
12988
|
-
if (
|
|
12863
|
+
if (path33.isAbsolute(cleanPath)) {
|
|
12989
12864
|
return cleanPath;
|
|
12990
12865
|
}
|
|
12991
|
-
return
|
|
12866
|
+
return path33.resolve(baseDir, cleanPath);
|
|
12992
12867
|
}
|
|
12993
12868
|
function processIncludes(content, baseDir, processedFiles) {
|
|
12994
12869
|
const lines = content.split("\n");
|
|
@@ -12997,12 +12872,12 @@ function processIncludes(content, baseDir, processedFiles) {
|
|
|
12997
12872
|
const includeMatch = line.match(/^@\s*([^\s]+)/);
|
|
12998
12873
|
if (includeMatch) {
|
|
12999
12874
|
const includePath = expandIncludePath(includeMatch[1], baseDir);
|
|
13000
|
-
const normalizedPath =
|
|
12875
|
+
const normalizedPath = path33.normalize(includePath);
|
|
13001
12876
|
if (processedFiles.has(normalizedPath)) {
|
|
13002
12877
|
result.push(`<!-- Circular include prevented: ${includeMatch[1]} -->`);
|
|
13003
12878
|
continue;
|
|
13004
12879
|
}
|
|
13005
|
-
const ext =
|
|
12880
|
+
const ext = path33.extname(includePath).toLowerCase();
|
|
13006
12881
|
if (!TEXT_FILE_EXTENSIONS.has(ext)) {
|
|
13007
12882
|
result.push(`<!-- Include skipped (unsupported extension): ${includeMatch[1]} -->`);
|
|
13008
12883
|
continue;
|
|
@@ -13010,7 +12885,7 @@ function processIncludes(content, baseDir, processedFiles) {
|
|
|
13010
12885
|
try {
|
|
13011
12886
|
const includedContent = fs30.readFileSync(includePath, "utf-8");
|
|
13012
12887
|
processedFiles.add(normalizedPath);
|
|
13013
|
-
const processedContent = processIncludes(includedContent,
|
|
12888
|
+
const processedContent = processIncludes(includedContent, path33.dirname(includePath), processedFiles);
|
|
13014
12889
|
result.push(`
|
|
13015
12890
|
<!-- BEGIN INCLUDE ${includeMatch[1]} -->
|
|
13016
12891
|
`);
|
|
@@ -13057,8 +12932,8 @@ function parseFrontmatterPaths(paths) {
|
|
|
13057
12932
|
function readMemoryFile(filePath, type, includeBasePath) {
|
|
13058
12933
|
try {
|
|
13059
12934
|
const rawContent = fs30.readFileSync(filePath, "utf-8");
|
|
13060
|
-
const baseDir = includeBasePath ||
|
|
13061
|
-
const processedFiles = /* @__PURE__ */ new Set([
|
|
12935
|
+
const baseDir = includeBasePath || path33.dirname(filePath);
|
|
12936
|
+
const processedFiles = /* @__PURE__ */ new Set([path33.normalize(filePath)]);
|
|
13062
12937
|
const { frontmatter, content: withoutFrontmatter } = parseFrontmatter(rawContent);
|
|
13063
12938
|
const globs = parseFrontmatterPaths(frontmatter.paths);
|
|
13064
12939
|
const processedContent = processIncludes(withoutFrontmatter, baseDir, processedFiles);
|
|
@@ -13080,15 +12955,15 @@ function readMemoryFile(filePath, type, includeBasePath) {
|
|
|
13080
12955
|
}
|
|
13081
12956
|
function findGitRoot(startDir) {
|
|
13082
12957
|
let current = startDir;
|
|
13083
|
-
while (current !==
|
|
13084
|
-
const gitPath =
|
|
12958
|
+
while (current !== path33.dirname(current)) {
|
|
12959
|
+
const gitPath = path33.join(current, ".git");
|
|
13085
12960
|
try {
|
|
13086
12961
|
if (fs30.existsSync(gitPath)) {
|
|
13087
12962
|
return current;
|
|
13088
12963
|
}
|
|
13089
12964
|
} catch {
|
|
13090
12965
|
}
|
|
13091
|
-
current =
|
|
12966
|
+
current = path33.dirname(current);
|
|
13092
12967
|
}
|
|
13093
12968
|
return null;
|
|
13094
12969
|
}
|
|
@@ -13119,11 +12994,11 @@ function processRulesDirectory(rulesDir, type, processedPaths, conditionalRule =
|
|
|
13119
12994
|
try {
|
|
13120
12995
|
const entries = fs30.readdirSync(rulesDir, { withFileTypes: true });
|
|
13121
12996
|
for (const entry of entries) {
|
|
13122
|
-
const entryPath =
|
|
12997
|
+
const entryPath = path33.join(rulesDir, entry.name);
|
|
13123
12998
|
if (entry.isDirectory()) {
|
|
13124
12999
|
result.push(...processRulesDirectory(entryPath, type, processedPaths, conditionalRule));
|
|
13125
13000
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
13126
|
-
const normalizedPath =
|
|
13001
|
+
const normalizedPath = path33.normalize(entryPath);
|
|
13127
13002
|
if (processedPaths.has(normalizedPath)) {
|
|
13128
13003
|
continue;
|
|
13129
13004
|
}
|
|
@@ -13159,13 +13034,13 @@ function loadManagedMemory() {
|
|
|
13159
13034
|
function loadUserMemory() {
|
|
13160
13035
|
const files = [];
|
|
13161
13036
|
const homeDir = os19.homedir();
|
|
13162
|
-
const userBlumaDir =
|
|
13163
|
-
const userBlumaMd =
|
|
13037
|
+
const userBlumaDir = path33.join(homeDir, ".bluma");
|
|
13038
|
+
const userBlumaMd = path33.join(userBlumaDir, "BLUMA.md");
|
|
13164
13039
|
const userFile = readMemoryFile(userBlumaMd, "User");
|
|
13165
13040
|
if (userFile && userFile.content.trim()) {
|
|
13166
13041
|
files.push(userFile);
|
|
13167
13042
|
}
|
|
13168
|
-
const userRulesDir =
|
|
13043
|
+
const userRulesDir = path33.join(userBlumaDir, "rules");
|
|
13169
13044
|
const processedPaths = /* @__PURE__ */ new Set();
|
|
13170
13045
|
files.push(...processRulesDirectory(userRulesDir, "User", processedPaths, false));
|
|
13171
13046
|
return files;
|
|
@@ -13177,10 +13052,10 @@ function loadProjectMemory(cwd) {
|
|
|
13177
13052
|
let currentDir = cwd;
|
|
13178
13053
|
const MAX_TRAVERSAL_DEPTH = 20;
|
|
13179
13054
|
let depth = 0;
|
|
13180
|
-
const normalizedGitRoot =
|
|
13181
|
-
while (currentDir !==
|
|
13055
|
+
const normalizedGitRoot = path33.resolve(gitRoot);
|
|
13056
|
+
while (currentDir !== path33.dirname(currentDir) && path33.resolve(currentDir).startsWith(normalizedGitRoot) && depth < MAX_TRAVERSAL_DEPTH) {
|
|
13182
13057
|
dirs.push(currentDir);
|
|
13183
|
-
currentDir =
|
|
13058
|
+
currentDir = path33.dirname(currentDir);
|
|
13184
13059
|
depth++;
|
|
13185
13060
|
}
|
|
13186
13061
|
if (!dirs.includes(gitRoot)) {
|
|
@@ -13188,7 +13063,7 @@ function loadProjectMemory(cwd) {
|
|
|
13188
13063
|
}
|
|
13189
13064
|
const processedPaths = /* @__PURE__ */ new Set();
|
|
13190
13065
|
for (const dir of dirs.reverse()) {
|
|
13191
|
-
const projectBlumaMd =
|
|
13066
|
+
const projectBlumaMd = path33.join(dir, "BLUMA.md");
|
|
13192
13067
|
if (!processedPaths.has(projectBlumaMd)) {
|
|
13193
13068
|
processedPaths.add(projectBlumaMd);
|
|
13194
13069
|
const projectFile = readMemoryFile(projectBlumaMd, "Project");
|
|
@@ -13196,7 +13071,7 @@ function loadProjectMemory(cwd) {
|
|
|
13196
13071
|
files.push(projectFile);
|
|
13197
13072
|
}
|
|
13198
13073
|
}
|
|
13199
|
-
const blumaDirBlumaMd =
|
|
13074
|
+
const blumaDirBlumaMd = path33.join(dir, ".bluma", "BLUMA.md");
|
|
13200
13075
|
if (!processedPaths.has(blumaDirBlumaMd)) {
|
|
13201
13076
|
processedPaths.add(blumaDirBlumaMd);
|
|
13202
13077
|
const blumaDirFile = readMemoryFile(blumaDirBlumaMd, "Project");
|
|
@@ -13204,10 +13079,10 @@ function loadProjectMemory(cwd) {
|
|
|
13204
13079
|
files.push(blumaDirFile);
|
|
13205
13080
|
}
|
|
13206
13081
|
}
|
|
13207
|
-
const rulesDir =
|
|
13082
|
+
const rulesDir = path33.join(dir, ".bluma", "rules");
|
|
13208
13083
|
files.push(...processRulesDirectory(rulesDir, "Project", processedPaths, false));
|
|
13209
13084
|
}
|
|
13210
|
-
const localBlumaMd =
|
|
13085
|
+
const localBlumaMd = path33.join(cwd, "BLUMA.local.md");
|
|
13211
13086
|
if (!processedPaths.has(localBlumaMd)) {
|
|
13212
13087
|
processedPaths.add(localBlumaMd);
|
|
13213
13088
|
const localFile = readMemoryFile(localBlumaMd, "Local");
|
|
@@ -13308,7 +13183,7 @@ function safeReadFile(filePath, maxChars) {
|
|
|
13308
13183
|
}
|
|
13309
13184
|
function tryReadReadme(cwd) {
|
|
13310
13185
|
for (const name of ["README.md", "README.MD", "readme.md", "Readme.md"]) {
|
|
13311
|
-
const c = safeReadFile(
|
|
13186
|
+
const c = safeReadFile(path34.join(cwd, name), LIMITS.readme);
|
|
13312
13187
|
if (c) return `(${name})
|
|
13313
13188
|
${c}`;
|
|
13314
13189
|
}
|
|
@@ -13316,14 +13191,14 @@ ${c}`;
|
|
|
13316
13191
|
}
|
|
13317
13192
|
function tryReadBluMaMd(cwd) {
|
|
13318
13193
|
const paths = [
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13194
|
+
path34.join(cwd, "BluMa.md"),
|
|
13195
|
+
path34.join(cwd, "BLUMA.md"),
|
|
13196
|
+
path34.join(cwd, ".bluma", "BluMa.md")
|
|
13322
13197
|
];
|
|
13323
13198
|
for (const p of paths) {
|
|
13324
13199
|
const c = safeReadFile(p, LIMITS.blumaMd);
|
|
13325
13200
|
if (c) {
|
|
13326
|
-
const rel =
|
|
13201
|
+
const rel = path34.relative(cwd, p) || p;
|
|
13327
13202
|
return `(${rel})
|
|
13328
13203
|
${c}`;
|
|
13329
13204
|
}
|
|
@@ -13331,7 +13206,7 @@ ${c}`;
|
|
|
13331
13206
|
return null;
|
|
13332
13207
|
}
|
|
13333
13208
|
function summarizePackageJson(cwd) {
|
|
13334
|
-
const p =
|
|
13209
|
+
const p = path34.join(cwd, "package.json");
|
|
13335
13210
|
try {
|
|
13336
13211
|
if (!fs31.existsSync(p)) return null;
|
|
13337
13212
|
const pkg = JSON.parse(fs31.readFileSync(p, "utf8"));
|
|
@@ -13425,7 +13300,7 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13425
13300
|
parts.push(pkg);
|
|
13426
13301
|
parts.push("```\n");
|
|
13427
13302
|
}
|
|
13428
|
-
const py = safeReadFile(
|
|
13303
|
+
const py = safeReadFile(path34.join(cwd, "pyproject.toml"), LIMITS.pyproject);
|
|
13429
13304
|
if (py) {
|
|
13430
13305
|
parts.push("### pyproject.toml (excerpt)\n```toml");
|
|
13431
13306
|
parts.push(py);
|
|
@@ -13443,15 +13318,15 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13443
13318
|
parts.push(bluma);
|
|
13444
13319
|
parts.push("```\n");
|
|
13445
13320
|
}
|
|
13446
|
-
const contrib = safeReadFile(
|
|
13321
|
+
const contrib = safeReadFile(path34.join(cwd, "CONTRIBUTING.md"), LIMITS.contributing);
|
|
13447
13322
|
if (contrib) {
|
|
13448
13323
|
parts.push("### CONTRIBUTING.md (excerpt)\n```markdown");
|
|
13449
13324
|
parts.push(contrib);
|
|
13450
13325
|
parts.push("```\n");
|
|
13451
13326
|
}
|
|
13452
|
-
const chlog = safeReadFile(
|
|
13327
|
+
const chlog = safeReadFile(path34.join(cwd, "CHANGELOG.md"), LIMITS.changelog);
|
|
13453
13328
|
if (!chlog) {
|
|
13454
|
-
const alt = safeReadFile(
|
|
13329
|
+
const alt = safeReadFile(path34.join(cwd, "CHANGES.md"), LIMITS.changelog);
|
|
13455
13330
|
if (alt) {
|
|
13456
13331
|
parts.push("### CHANGES.md (excerpt)\n```markdown");
|
|
13457
13332
|
parts.push(alt);
|
|
@@ -13487,14 +13362,14 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13487
13362
|
} else {
|
|
13488
13363
|
parts.push("### Git\n(not a git work tree, or `git` unavailable)\n");
|
|
13489
13364
|
}
|
|
13490
|
-
const tsconfig = safeReadFile(
|
|
13365
|
+
const tsconfig = safeReadFile(path34.join(cwd, "tsconfig.json"), LIMITS.tsconfig);
|
|
13491
13366
|
if (tsconfig) {
|
|
13492
13367
|
parts.push("### tsconfig.json (excerpt)\n```json");
|
|
13493
13368
|
parts.push(tsconfig);
|
|
13494
13369
|
parts.push("```\n");
|
|
13495
13370
|
}
|
|
13496
13371
|
for (const name of ["Dockerfile", "dockerfile", "Dockerfile.prod", "Dockerfile.dev"]) {
|
|
13497
|
-
const df = safeReadFile(
|
|
13372
|
+
const df = safeReadFile(path34.join(cwd, name), LIMITS.dockerfile);
|
|
13498
13373
|
if (df) {
|
|
13499
13374
|
parts.push(`### ${name} (excerpt)
|
|
13500
13375
|
`);
|
|
@@ -13504,7 +13379,7 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13504
13379
|
}
|
|
13505
13380
|
}
|
|
13506
13381
|
for (const name of ["docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml"]) {
|
|
13507
|
-
const dc = safeReadFile(
|
|
13382
|
+
const dc = safeReadFile(path34.join(cwd, name), LIMITS.dockerfile);
|
|
13508
13383
|
if (dc) {
|
|
13509
13384
|
parts.push(`### ${name} (excerpt)
|
|
13510
13385
|
`);
|
|
@@ -13519,7 +13394,7 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13519
13394
|
".circleci/config.yml",
|
|
13520
13395
|
"Jenkinsfile"
|
|
13521
13396
|
]) {
|
|
13522
|
-
const ciFile =
|
|
13397
|
+
const ciFile = path34.join(cwd, ciPath);
|
|
13523
13398
|
if (fs31.existsSync(ciFile)) {
|
|
13524
13399
|
const st = fs31.statSync(ciFile);
|
|
13525
13400
|
if (st.isDirectory()) {
|
|
@@ -13535,7 +13410,7 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13535
13410
|
} else {
|
|
13536
13411
|
const ci = safeReadFile(ciFile, LIMITS.ciConfig);
|
|
13537
13412
|
if (ci) {
|
|
13538
|
-
parts.push(`### CI config (${
|
|
13413
|
+
parts.push(`### CI config (${path34.basename(ciPath)})
|
|
13539
13414
|
`);
|
|
13540
13415
|
parts.push(ci);
|
|
13541
13416
|
parts.push("\n");
|
|
@@ -13544,7 +13419,7 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13544
13419
|
}
|
|
13545
13420
|
}
|
|
13546
13421
|
for (const depFile of ["requirements.txt", "Pipfile", "poetry.lock", "Gemfile", "go.sum", "Cargo.lock"]) {
|
|
13547
|
-
const depPath =
|
|
13422
|
+
const depPath = path34.join(cwd, depFile);
|
|
13548
13423
|
if (fs31.existsSync(depPath)) {
|
|
13549
13424
|
const depContent = safeReadFile(depPath, 1500);
|
|
13550
13425
|
if (depContent) {
|
|
@@ -13558,7 +13433,7 @@ function buildWorkspaceSnapshot(cwd) {
|
|
|
13558
13433
|
}
|
|
13559
13434
|
}
|
|
13560
13435
|
for (const envFile of [".env.example", ".env.sample", ".env.template"]) {
|
|
13561
|
-
const envPath =
|
|
13436
|
+
const envPath = path34.join(cwd, envFile);
|
|
13562
13437
|
if (fs31.existsSync(envPath)) {
|
|
13563
13438
|
try {
|
|
13564
13439
|
const raw = fs31.readFileSync(envPath, "utf-8");
|
|
@@ -13586,13 +13461,13 @@ init_runtime_config();
|
|
|
13586
13461
|
init_sandbox_policy();
|
|
13587
13462
|
import fs32 from "fs";
|
|
13588
13463
|
import os20 from "os";
|
|
13589
|
-
import
|
|
13464
|
+
import path35 from "path";
|
|
13590
13465
|
function getProjectPluginsDir() {
|
|
13591
13466
|
const policy = getSandboxPolicy();
|
|
13592
|
-
return
|
|
13467
|
+
return path35.join(policy.workspaceRoot, ".bluma", "plugins");
|
|
13593
13468
|
}
|
|
13594
13469
|
function getGlobalPluginsDir() {
|
|
13595
|
-
return
|
|
13470
|
+
return path35.join(process.env.HOME || os20.homedir(), ".bluma", "plugins");
|
|
13596
13471
|
}
|
|
13597
13472
|
function getPluginDirs() {
|
|
13598
13473
|
return {
|
|
@@ -13618,8 +13493,8 @@ function readManifest(manifestPath, fallbackName) {
|
|
|
13618
13493
|
}
|
|
13619
13494
|
function findManifestPath(pluginDir) {
|
|
13620
13495
|
const candidates = [
|
|
13621
|
-
|
|
13622
|
-
|
|
13496
|
+
path35.join(pluginDir, ".codex-plugin", "plugin.json"),
|
|
13497
|
+
path35.join(pluginDir, "plugin.json")
|
|
13623
13498
|
];
|
|
13624
13499
|
for (const candidate of candidates) {
|
|
13625
13500
|
if (fs32.existsSync(candidate)) {
|
|
@@ -13633,7 +13508,7 @@ function listFromDir(baseDir, source) {
|
|
|
13633
13508
|
return [];
|
|
13634
13509
|
}
|
|
13635
13510
|
return fs32.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).flatMap((entry) => {
|
|
13636
|
-
const pluginDir =
|
|
13511
|
+
const pluginDir = path35.join(baseDir, entry.name);
|
|
13637
13512
|
const manifestPath = findManifestPath(pluginDir);
|
|
13638
13513
|
if (!manifestPath) {
|
|
13639
13514
|
return [];
|
|
@@ -14547,7 +14422,7 @@ function buildModelInfoSection(modelId) {
|
|
|
14547
14422
|
// src/app/agent/runtime/hook_registry.ts
|
|
14548
14423
|
init_sandbox_policy();
|
|
14549
14424
|
import fs33 from "fs";
|
|
14550
|
-
import
|
|
14425
|
+
import path36 from "path";
|
|
14551
14426
|
var DEFAULT_STATE = {
|
|
14552
14427
|
enabled: true,
|
|
14553
14428
|
maxEvents: 120,
|
|
@@ -14558,7 +14433,7 @@ var cache2 = null;
|
|
|
14558
14433
|
var cachePath2 = null;
|
|
14559
14434
|
function getStatePath() {
|
|
14560
14435
|
const policy = getSandboxPolicy();
|
|
14561
|
-
return
|
|
14436
|
+
return path36.join(policy.workspaceRoot, ".bluma", "hooks.json");
|
|
14562
14437
|
}
|
|
14563
14438
|
function getHookStatePath() {
|
|
14564
14439
|
return getStatePath();
|
|
@@ -14604,7 +14479,7 @@ function ensureLoaded2() {
|
|
|
14604
14479
|
}
|
|
14605
14480
|
function persist2(state) {
|
|
14606
14481
|
const statePath = getStatePath();
|
|
14607
|
-
fs33.mkdirSync(
|
|
14482
|
+
fs33.mkdirSync(path36.dirname(statePath), { recursive: true });
|
|
14608
14483
|
state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
14609
14484
|
fs33.writeFileSync(statePath, JSON.stringify(state, null, 2), "utf-8");
|
|
14610
14485
|
cache2 = state;
|
|
@@ -14676,9 +14551,9 @@ function buildSystemRemindersSection() {
|
|
|
14676
14551
|
|
|
14677
14552
|
// src/app/agent/core/prompt/auto_memory.ts
|
|
14678
14553
|
import fs34 from "fs";
|
|
14679
|
-
import
|
|
14554
|
+
import path37 from "path";
|
|
14680
14555
|
import os21 from "os";
|
|
14681
|
-
var AUTO_MEMORY_FILE =
|
|
14556
|
+
var AUTO_MEMORY_FILE = path37.join(os21.homedir(), ".bluma", "auto_memory.md");
|
|
14682
14557
|
var MAX_AUTO_MEMORY_CHARS = 25e3;
|
|
14683
14558
|
var MAX_AUTO_MEMORY_LINES = 200;
|
|
14684
14559
|
function getAutoMemoryForPrompt() {
|
|
@@ -14745,10 +14620,10 @@ function getGitBranch(dir) {
|
|
|
14745
14620
|
}
|
|
14746
14621
|
function getPackageManager(dir) {
|
|
14747
14622
|
try {
|
|
14748
|
-
if (fs35.existsSync(
|
|
14749
|
-
if (fs35.existsSync(
|
|
14750
|
-
if (fs35.existsSync(
|
|
14751
|
-
if (fs35.existsSync(
|
|
14623
|
+
if (fs35.existsSync(path38.join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
14624
|
+
if (fs35.existsSync(path38.join(dir, "yarn.lock"))) return "yarn";
|
|
14625
|
+
if (fs35.existsSync(path38.join(dir, "bun.lockb"))) return "bun";
|
|
14626
|
+
if (fs35.existsSync(path38.join(dir, "package-lock.json"))) return "npm";
|
|
14752
14627
|
return "unknown";
|
|
14753
14628
|
} catch {
|
|
14754
14629
|
return "unknown";
|
|
@@ -14758,7 +14633,7 @@ function getProjectType(dir) {
|
|
|
14758
14633
|
try {
|
|
14759
14634
|
const files = fs35.readdirSync(dir);
|
|
14760
14635
|
if (files.includes("package.json")) {
|
|
14761
|
-
const pkg = JSON.parse(fs35.readFileSync(
|
|
14636
|
+
const pkg = JSON.parse(fs35.readFileSync(path38.join(dir, "package.json"), "utf-8"));
|
|
14762
14637
|
if (pkg.dependencies?.next || pkg.devDependencies?.next) return "Next.js";
|
|
14763
14638
|
if (pkg.dependencies?.react || pkg.devDependencies?.react) return "React";
|
|
14764
14639
|
if (pkg.dependencies?.express || pkg.devDependencies?.express) return "Express";
|
|
@@ -14777,7 +14652,7 @@ function getProjectType(dir) {
|
|
|
14777
14652
|
}
|
|
14778
14653
|
function getTestFramework(dir) {
|
|
14779
14654
|
try {
|
|
14780
|
-
const pkgPath =
|
|
14655
|
+
const pkgPath = path38.join(dir, "package.json");
|
|
14781
14656
|
if (fs35.existsSync(pkgPath)) {
|
|
14782
14657
|
const pkg = JSON.parse(fs35.readFileSync(pkgPath, "utf-8"));
|
|
14783
14658
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -14788,7 +14663,7 @@ function getTestFramework(dir) {
|
|
|
14788
14663
|
if (deps["@playwright/test"]) return "playwright";
|
|
14789
14664
|
if (deps.cypress) return "cypress";
|
|
14790
14665
|
}
|
|
14791
|
-
if (fs35.existsSync(
|
|
14666
|
+
if (fs35.existsSync(path38.join(dir, "pytest.ini")) || fs35.existsSync(path38.join(dir, "conftest.py"))) return "pytest";
|
|
14792
14667
|
return "unknown";
|
|
14793
14668
|
} catch {
|
|
14794
14669
|
return "unknown";
|
|
@@ -14796,7 +14671,7 @@ function getTestFramework(dir) {
|
|
|
14796
14671
|
}
|
|
14797
14672
|
function getTestCommand(dir) {
|
|
14798
14673
|
try {
|
|
14799
|
-
const pkgPath =
|
|
14674
|
+
const pkgPath = path38.join(dir, "package.json");
|
|
14800
14675
|
if (fs35.existsSync(pkgPath)) {
|
|
14801
14676
|
const pkg = JSON.parse(fs35.readFileSync(pkgPath, "utf-8"));
|
|
14802
14677
|
if (pkg.scripts?.test) return `npm test`;
|
|
@@ -14959,14 +14834,14 @@ Prefer clear, typed code; run \`{test_command}\` when logic changes; run lint/bu
|
|
|
14959
14834
|
`;
|
|
14960
14835
|
async function getUnifiedSystemPrompt(availableSkills, options) {
|
|
14961
14836
|
const runtimeConfig = getRuntimeConfig();
|
|
14962
|
-
const cwd =
|
|
14837
|
+
const cwd = process.cwd();
|
|
14963
14838
|
const availablePlugins = listPlugins();
|
|
14964
14839
|
const env = {
|
|
14965
14840
|
os_type: os22.type(),
|
|
14966
14841
|
os_version: os22.release(),
|
|
14967
14842
|
architecture: os22.arch(),
|
|
14968
14843
|
workdir: cwd,
|
|
14969
|
-
projectRoot:
|
|
14844
|
+
projectRoot: cwd,
|
|
14970
14845
|
shell_type: process.env.SHELL || process.env.COMSPEC || "unknown",
|
|
14971
14846
|
username: os22.userInfo().username,
|
|
14972
14847
|
current_date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
@@ -15099,7 +14974,7 @@ ${blumaMdContent}
|
|
|
15099
14974
|
}
|
|
15100
14975
|
function isGitRepo(dir) {
|
|
15101
14976
|
try {
|
|
15102
|
-
const gitPath =
|
|
14977
|
+
const gitPath = path38.join(dir, ".git");
|
|
15103
14978
|
return fs35.existsSync(gitPath) && fs35.lstatSync(gitPath).isDirectory();
|
|
15104
14979
|
} catch {
|
|
15105
14980
|
return false;
|
|
@@ -16018,10 +15893,10 @@ function effectiveToolAutoApprove(toolCall, sessionId, options) {
|
|
|
16018
15893
|
|
|
16019
15894
|
// src/app/agent/tools/natives/coding_memory_consolidate.ts
|
|
16020
15895
|
import * as fs36 from "fs";
|
|
16021
|
-
import * as
|
|
15896
|
+
import * as path39 from "path";
|
|
16022
15897
|
import os24 from "os";
|
|
16023
15898
|
function memoryPath2() {
|
|
16024
|
-
return
|
|
15899
|
+
return path39.join(process.env.HOME || os24.homedir(), ".bluma", "coding_memory.json");
|
|
16025
15900
|
}
|
|
16026
15901
|
function normalizeNote2(note) {
|
|
16027
15902
|
return note.trim().toLowerCase().replace(/\s+/g, " ");
|
|
@@ -16716,7 +16591,7 @@ var BluMaAgent = class _BluMaAgent {
|
|
|
16716
16591
|
|
|
16717
16592
|
${editData.error.display}`;
|
|
16718
16593
|
}
|
|
16719
|
-
const filename =
|
|
16594
|
+
const filename = path40.basename(toolArgs.file_path);
|
|
16720
16595
|
return createDiff(filename, editData.currentContent || "", editData.newContent);
|
|
16721
16596
|
} catch (e) {
|
|
16722
16597
|
return `An unexpected error occurred while generating the edit preview: ${e.message}`;
|
|
@@ -17674,14 +17549,14 @@ async function fullCompact(messages, targetTokens, summarizer, llmClient) {
|
|
|
17674
17549
|
// src/app/agent/core/memory/session_memory.ts
|
|
17675
17550
|
import fs37 from "fs";
|
|
17676
17551
|
import os27 from "os";
|
|
17677
|
-
import
|
|
17552
|
+
import path41 from "path";
|
|
17678
17553
|
import { v4 as uuidv49 } from "uuid";
|
|
17679
17554
|
var SessionMemoryExtractor = class {
|
|
17680
17555
|
llmClient;
|
|
17681
17556
|
memoryFile;
|
|
17682
17557
|
constructor(options = {}) {
|
|
17683
17558
|
this.llmClient = options.llmClient;
|
|
17684
|
-
this.memoryFile = options.memoryFile ||
|
|
17559
|
+
this.memoryFile = options.memoryFile || path41.join(os27.homedir(), ".bluma", "session_memory.json");
|
|
17685
17560
|
}
|
|
17686
17561
|
/**
|
|
17687
17562
|
* Extract memories from conversation using LLM
|
|
@@ -18295,14 +18170,14 @@ var RouteManager = class {
|
|
|
18295
18170
|
this.subAgents = subAgents;
|
|
18296
18171
|
this.core = core;
|
|
18297
18172
|
}
|
|
18298
|
-
registerRoute(
|
|
18299
|
-
this.routeHandlers.set(
|
|
18173
|
+
registerRoute(path46, handler) {
|
|
18174
|
+
this.routeHandlers.set(path46, handler);
|
|
18300
18175
|
}
|
|
18301
18176
|
async handleRoute(payload) {
|
|
18302
18177
|
const inputText = String(payload.content || "").trim();
|
|
18303
18178
|
const { userContext } = payload;
|
|
18304
|
-
for (const [
|
|
18305
|
-
if (inputText ===
|
|
18179
|
+
for (const [path46, handler] of this.routeHandlers) {
|
|
18180
|
+
if (inputText === path46 || inputText.startsWith(`${path46} `)) {
|
|
18306
18181
|
return handler({ content: inputText, userContext });
|
|
18307
18182
|
}
|
|
18308
18183
|
}
|
|
@@ -18311,13 +18186,13 @@ var RouteManager = class {
|
|
|
18311
18186
|
};
|
|
18312
18187
|
|
|
18313
18188
|
// src/app/agent/runtime/plugin_runtime.ts
|
|
18314
|
-
import
|
|
18189
|
+
import path42 from "path";
|
|
18315
18190
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
18316
18191
|
async function loadPluginsAtStartup() {
|
|
18317
18192
|
for (const p of listPlugins()) {
|
|
18318
18193
|
const entry = p.manifest.entry?.trim();
|
|
18319
18194
|
if (!entry) continue;
|
|
18320
|
-
const abs =
|
|
18195
|
+
const abs = path42.resolve(p.root, entry);
|
|
18321
18196
|
try {
|
|
18322
18197
|
const href = pathToFileURL2(abs).href;
|
|
18323
18198
|
const mod = await import(href);
|
|
@@ -18338,7 +18213,7 @@ async function loadPluginsAtStartup() {
|
|
|
18338
18213
|
}
|
|
18339
18214
|
|
|
18340
18215
|
// src/app/agent/agent.ts
|
|
18341
|
-
var globalEnvPath =
|
|
18216
|
+
var globalEnvPath = path43.join(os28.homedir(), ".bluma", ".env");
|
|
18342
18217
|
dotenv.config({ path: globalEnvPath });
|
|
18343
18218
|
var Agent = class {
|
|
18344
18219
|
sessionId;
|
|
@@ -20155,9 +20030,8 @@ var runSandboxSet = (_agentRef, enabled, _setIsProcessing, _markTurnStarted) =>
|
|
|
20155
20030
|
setRuntimeConfig({ sandboxEnabled: enabled });
|
|
20156
20031
|
return usageBox("Sandbox", `Sandbox ${enabled ? "enabled" : "disabled"}`);
|
|
20157
20032
|
};
|
|
20158
|
-
var runWorktreeSet = (_agentRef,
|
|
20159
|
-
|
|
20160
|
-
return usageBox("Worktree", `Set worktree to: ${path45}`);
|
|
20033
|
+
var runWorktreeSet = (_agentRef, _path, _setIsProcessing, _markTurnStarted) => {
|
|
20034
|
+
return usageBox("Worktree", `Ignored. BluMa now always uses current session directory: ${process.cwd()}`);
|
|
20161
20035
|
};
|
|
20162
20036
|
var runPermissionSet = (_agentRef, mode, _setIsProcessing, _markTurnStarted) => {
|
|
20163
20037
|
setRuntimeConfig({ permissionMode: mode });
|
|
@@ -22686,13 +22560,13 @@ import latestVersion from "latest-version";
|
|
|
22686
22560
|
import semverGt from "semver/functions/gt.js";
|
|
22687
22561
|
import semverValid from "semver/functions/valid.js";
|
|
22688
22562
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
22689
|
-
import
|
|
22563
|
+
import path44 from "path";
|
|
22690
22564
|
import fs38 from "fs";
|
|
22691
22565
|
var BLUMA_PACKAGE_NAME = "@nomad-e/bluma-cli";
|
|
22692
22566
|
function findBlumaPackageJson(startDir) {
|
|
22693
22567
|
let dir = startDir;
|
|
22694
22568
|
for (let i = 0; i < 12; i++) {
|
|
22695
|
-
const candidate =
|
|
22569
|
+
const candidate = path44.join(dir, "package.json");
|
|
22696
22570
|
if (fs38.existsSync(candidate)) {
|
|
22697
22571
|
try {
|
|
22698
22572
|
const raw = fs38.readFileSync(candidate, "utf8");
|
|
@@ -22703,7 +22577,7 @@ function findBlumaPackageJson(startDir) {
|
|
|
22703
22577
|
} catch {
|
|
22704
22578
|
}
|
|
22705
22579
|
}
|
|
22706
|
-
const parent =
|
|
22580
|
+
const parent = path44.dirname(dir);
|
|
22707
22581
|
if (parent === dir) break;
|
|
22708
22582
|
dir = parent;
|
|
22709
22583
|
}
|
|
@@ -22712,13 +22586,13 @@ function findBlumaPackageJson(startDir) {
|
|
|
22712
22586
|
function resolveInstalledBlumaPackage() {
|
|
22713
22587
|
const tried = /* @__PURE__ */ new Set();
|
|
22714
22588
|
const tryFrom = (dir) => {
|
|
22715
|
-
const abs =
|
|
22589
|
+
const abs = path44.resolve(dir);
|
|
22716
22590
|
if (tried.has(abs)) return null;
|
|
22717
22591
|
tried.add(abs);
|
|
22718
22592
|
return findBlumaPackageJson(abs);
|
|
22719
22593
|
};
|
|
22720
22594
|
try {
|
|
22721
|
-
const fromBundle = tryFrom(
|
|
22595
|
+
const fromBundle = tryFrom(path44.dirname(fileURLToPath5(import.meta.url)));
|
|
22722
22596
|
if (fromBundle) return fromBundle;
|
|
22723
22597
|
} catch {
|
|
22724
22598
|
}
|
|
@@ -22726,12 +22600,12 @@ function resolveInstalledBlumaPackage() {
|
|
|
22726
22600
|
if (argv1 && !argv1.startsWith("-")) {
|
|
22727
22601
|
try {
|
|
22728
22602
|
let resolved = argv1;
|
|
22729
|
-
if (
|
|
22603
|
+
if (path44.isAbsolute(argv1) && fs38.existsSync(argv1)) {
|
|
22730
22604
|
resolved = fs38.realpathSync(argv1);
|
|
22731
22605
|
} else {
|
|
22732
|
-
resolved =
|
|
22606
|
+
resolved = path44.resolve(process.cwd(), argv1);
|
|
22733
22607
|
}
|
|
22734
|
-
const fromArgv = tryFrom(
|
|
22608
|
+
const fromArgv = tryFrom(path44.dirname(resolved));
|
|
22735
22609
|
if (fromArgv) return fromArgv;
|
|
22736
22610
|
} catch {
|
|
22737
22611
|
}
|
|
@@ -24411,17 +24285,8 @@ Please use command_status to check the result and report back to the user.`;
|
|
|
24411
24285
|
/* @__PURE__ */ jsx39(
|
|
24412
24286
|
StatusLine,
|
|
24413
24287
|
{
|
|
24414
|
-
model: "auto",
|
|
24415
|
-
inputTokens: 0,
|
|
24416
|
-
outputTokens: 0,
|
|
24417
|
-
contextWindowSize: 128e3,
|
|
24418
|
-
totalCost: 0,
|
|
24419
24288
|
cwd: workdir,
|
|
24420
|
-
|
|
24421
|
-
processingTime: processingStartMs ? Date.now() - processingStartMs : 0,
|
|
24422
|
-
toolsCount: toolsCount || 0,
|
|
24423
|
-
activeWorkers: showWorkers ? 1 : 0,
|
|
24424
|
-
sandboxMode: "confirm"
|
|
24289
|
+
activeWorkers: showWorkers ? 1 : 0
|
|
24425
24290
|
}
|
|
24426
24291
|
)
|
|
24427
24292
|
] });
|
|
@@ -24789,8 +24654,8 @@ async function runAgentMode() {
|
|
|
24789
24654
|
}
|
|
24790
24655
|
function readCliPackageVersion() {
|
|
24791
24656
|
try {
|
|
24792
|
-
const base =
|
|
24793
|
-
const pkgPath =
|
|
24657
|
+
const base = path45.dirname(fileURLToPath6(import.meta.url));
|
|
24658
|
+
const pkgPath = path45.join(base, "..", "package.json");
|
|
24794
24659
|
const j = JSON.parse(fs39.readFileSync(pkgPath, "utf8"));
|
|
24795
24660
|
return String(j.version || "0.0.0");
|
|
24796
24661
|
} catch {
|