dist / utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MAX_OUTPUT_CHARS = void 0;
exports.truncateOutput = truncateOutput;
exports.getWorkspaceDir = getWorkspaceDir;
exports.resolvePath = resolvePath;
const path_1 = require("path");
const os_1 = require("os");
// LĂmite estricto para ahorro máximo de tokens y VRAM
exports.MAX_OUTPUT_CHARS = 1200;
function truncateOutput(text, maxChars = exports.MAX_OUTPUT_CHARS) {
if (!text)
return "";
if (text.length <= maxChars)
return text;
return text.substring(0, maxChars) + "\n...[truncado para ahorrar contexto]";
}
function getWorkspaceDir() {
const home = (0, os_1.homedir)();
if (process.env.NANO_FS_WORKSPACE && process.env.NANO_FS_WORKSPACE.trim()) {
return resolvePath(process.env.NANO_FS_WORKSPACE.trim(), home);
}
if (process.env.WORKSPACE_DIR && process.env.WORKSPACE_DIR.trim()) {
return resolvePath(process.env.WORKSPACE_DIR.trim(), home);
}
return (0, path_1.resolve)(home, "workspace");
}
function resolvePath(filepath, baseDir = getWorkspaceDir()) {
const home = (0, os_1.homedir)();
const normalized = (filepath || "").trim();
if (!normalized)
return baseDir;
if (normalized === "~")
return home;
if (normalized.startsWith("~/") || normalized.startsWith("~\\")) {
return (0, path_1.resolve)(home, normalized.slice(2));
}
if (normalized.startsWith("~"))
return (0, path_1.resolve)(home, normalized.slice(1));
if ((0, path_1.isAbsolute)(normalized))
return (0, path_1.resolve)(normalized);
return (0, path_1.resolve)(baseDir, normalized);
}
dist / utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MAX_OUTPUT_CHARS = void 0;
exports.truncateOutput = truncateOutput;
exports.getWorkspaceDir = getWorkspaceDir;
exports.resolvePath = resolvePath;
const path_1 = require("path");
const os_1 = require("os");
// LĂmite estricto para ahorro máximo de tokens y VRAM
exports.MAX_OUTPUT_CHARS = 1200;
function truncateOutput(text, maxChars = exports.MAX_OUTPUT_CHARS) {
if (!text)
return "";
if (text.length <= maxChars)
return text;
return text.substring(0, maxChars) + "\n...[truncado para ahorrar contexto]";
}
function getWorkspaceDir() {
const home = (0, os_1.homedir)();
if (process.env.NANO_FS_WORKSPACE && process.env.NANO_FS_WORKSPACE.trim()) {
return resolvePath(process.env.NANO_FS_WORKSPACE.trim(), home);
}
if (process.env.WORKSPACE_DIR && process.env.WORKSPACE_DIR.trim()) {
return resolvePath(process.env.WORKSPACE_DIR.trim(), home);
}
return (0, path_1.resolve)(home, "workspace");
}
function resolvePath(filepath, baseDir = getWorkspaceDir()) {
const home = (0, os_1.homedir)();
const normalized = (filepath || "").trim();
if (!normalized)
return baseDir;
if (normalized === "~")
return home;
if (normalized.startsWith("~/") || normalized.startsWith("~\\")) {
return (0, path_1.resolve)(home, normalized.slice(2));
}
if (normalized.startsWith("~"))
return (0, path_1.resolve)(home, normalized.slice(1));
if ((0, path_1.isAbsolute)(normalized))
return (0, path_1.resolve)(normalized);
return (0, path_1.resolve)(baseDir, normalized);
}