fluxflow-cli 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/dist/fluxflow.js +43 -38
  2. package/package.json +1 -1
package/dist/fluxflow.js CHANGED
@@ -581,6 +581,7 @@ var getTruncatedHistory = (history, exchangesToRemove = 4) => {
581
581
 
582
582
  // src/utils/usage.js
583
583
  import fs4 from "fs-extra";
584
+ import path5 from "path";
584
585
  var getDailyUsage = async () => {
585
586
  const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
586
587
  try {
@@ -594,6 +595,7 @@ var getDailyUsage = async () => {
594
595
  console.error("Failed to read usage:", err);
595
596
  }
596
597
  const defaultStats = { agent: 0, background: 0, search: 0 };
598
+ await fs4.ensureDir(path5.dirname(USAGE_FILE));
597
599
  await fs4.writeJson(USAGE_FILE, { date: today, stats: defaultStats }, { spaces: 2 });
598
600
  return defaultStats;
599
601
  };
@@ -606,6 +608,7 @@ var incrementUsage = async (key) => {
606
608
  }
607
609
  if (data.stats[key] !== void 0) {
608
610
  data.stats[key]++;
611
+ await fs4.ensureDir(path5.dirname(USAGE_FILE));
609
612
  await fs4.writeJson(USAGE_FILE, data, { spaces: 2 });
610
613
  }
611
614
  };
@@ -656,7 +659,7 @@ var parseArgs = (argsString) => {
656
659
 
657
660
  // src/tools/web_search.js
658
661
  import fs5 from "fs";
659
- import path5 from "path";
662
+ import path6 from "path";
660
663
  var web_search = async (argsString) => {
661
664
  const { query, limit = 10 } = parseArgs(argsString);
662
665
  if (!query) return 'ERROR: Missing "query" argument for web_search.';
@@ -684,11 +687,11 @@ Source: ${url}
684
687
  Snippet: ${snippet}`);
685
688
  count++;
686
689
  }
687
- const toolLogDir = path5.join(LOGS_DIR, "tools");
690
+ const toolLogDir = path6.join(LOGS_DIR, "tools");
688
691
  if (!fs5.existsSync(toolLogDir)) {
689
692
  fs5.mkdirSync(toolLogDir, { recursive: true });
690
693
  }
691
- fs5.appendFileSync(path5.join(toolLogDir, "search-results.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
694
+ fs5.appendFileSync(path6.join(toolLogDir, "search-results.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
692
695
  Query: [${query}]. Results Count: ${results.length}.
693
696
  Results: ${results}
694
697
 
@@ -696,11 +699,11 @@ Results: ${results}
696
699
  `);
697
700
  if (results.length === 0) {
698
701
  if (html.includes("anomaly")) {
699
- const toolErrDir = path5.join(LOGS_DIR, "tools");
702
+ const toolErrDir = path6.join(LOGS_DIR, "tools");
700
703
  if (!fs5.existsSync(toolErrDir)) {
701
704
  fs5.mkdirSync(toolErrDir, { recursive: true });
702
705
  }
703
- fs5.appendFileSync(path5.join(toolErrDir, "error.log"), `ERROR ${(/* @__PURE__ */ new Date()).toISOString()} - DDG detected unusual activity. Cuimp impersonation might need adjustment.
706
+ fs5.appendFileSync(path6.join(toolErrDir, "error.log"), `ERROR ${(/* @__PURE__ */ new Date()).toISOString()} - DDG detected unusual activity. Cuimp impersonation might need adjustment.
704
707
  `);
705
708
  throw new Error("DDG detected unusual activity. Cuimp impersonation might need adjustment.");
706
709
  }
@@ -717,7 +720,7 @@ ${finalResults}`;
717
720
 
718
721
  // src/tools/web_scrape.js
719
722
  import fs6 from "fs";
720
- import path6 from "path";
723
+ import path7 from "path";
721
724
  import * as cuimp2 from "cuimp";
722
725
  var web_scrape = async (args) => {
723
726
  const urlMatch = args.match(/url\s*=\s*["'](.*)["']/);
@@ -739,11 +742,11 @@ var web_scrape = async (args) => {
739
742
  html = html.replace(/<header\b[^<]*(?:(?!<\/header>)<[^<]*)*<\/header>/gi, "");
740
743
  let text = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
741
744
  const finalContent = text.substring(0, 2e4);
742
- const toolLogDir = path6.join(LOGS_DIR, "tools");
745
+ const toolLogDir = path7.join(LOGS_DIR, "tools");
743
746
  if (!fs6.existsSync(toolLogDir)) {
744
747
  fs6.mkdirSync(toolLogDir, { recursive: true });
745
748
  }
746
- fs6.appendFileSync(path6.join(toolLogDir, "search-scraped.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
749
+ fs6.appendFileSync(path7.join(toolLogDir, "search-scraped.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
747
750
  Query: [${url}].
748
751
  Results: ${finalContent}
749
752
 
@@ -879,10 +882,10 @@ var summary = async (rawArgs, context = {}) => {
879
882
 
880
883
  // src/tools/list_files.js
881
884
  import fs7 from "fs";
882
- import path7 from "path";
885
+ import path8 from "path";
883
886
  var list_files = async (args) => {
884
887
  const { path: targetPath = "." } = parseArgs(args);
885
- const absolutePath = path7.resolve(process.cwd(), targetPath);
888
+ const absolutePath = path8.resolve(process.cwd(), targetPath);
886
889
  try {
887
890
  if (!fs7.existsSync(absolutePath)) {
888
891
  return `ERROR: Path [${targetPath}] does not exist.`;
@@ -899,7 +902,7 @@ var list_files = async (args) => {
899
902
  const maxDisplay = 100;
900
903
  const displayFiles = files2.slice(0, maxDisplay);
901
904
  const list = displayFiles.map((file) => {
902
- const fPath = path7.join(absolutePath, file);
905
+ const fPath = path8.join(absolutePath, file);
903
906
  let indicator = "\u{1F4C4}";
904
907
  let metaPart = "";
905
908
  try {
@@ -934,11 +937,11 @@ ${list}${footer}`;
934
937
 
935
938
  // src/tools/view_file.js
936
939
  import fs8 from "fs";
937
- import path8 from "path";
940
+ import path9 from "path";
938
941
  var view_file = async (args) => {
939
942
  const { path: targetPath, start_line = 1, end_line = 500 } = parseArgs(args);
940
943
  if (!targetPath) return 'ERROR: Missing "path" argument for view_file.';
941
- const absolutePath = path8.resolve(process.cwd(), targetPath);
944
+ const absolutePath = path9.resolve(process.cwd(), targetPath);
942
945
  try {
943
946
  if (!fs8.existsSync(absolutePath)) {
944
947
  return `ERROR: File [${targetPath}] does not exist.`;
@@ -965,14 +968,14 @@ ${code}`;
965
968
 
966
969
  // src/tools/write_file.js
967
970
  import fs9 from "fs";
968
- import path9 from "path";
971
+ import path10 from "path";
969
972
  var write_file = async (args) => {
970
973
  let { path: targetPath, content } = parseArgs(args);
971
974
  if (!targetPath) return 'ERROR: Missing "path" argument for write_file.';
972
975
  if (content === void 0) return 'ERROR: Missing "content" argument for write_file.';
973
976
  content = content.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").trim();
974
- const absolutePath = path9.resolve(process.cwd(), targetPath);
975
- const parentDir = path9.dirname(absolutePath);
977
+ const absolutePath = path10.resolve(process.cwd(), targetPath);
978
+ const parentDir = path10.dirname(absolutePath);
976
979
  try {
977
980
  if (!fs9.existsSync(parentDir)) {
978
981
  fs9.mkdirSync(parentDir, { recursive: true });
@@ -1013,7 +1016,7 @@ ${snippet}`;
1013
1016
 
1014
1017
  // src/tools/update_file.js
1015
1018
  import fs10 from "fs";
1016
- import path10 from "path";
1019
+ import path11 from "path";
1017
1020
  var update_file = async (args) => {
1018
1021
  let { path: targetPath, content_to_replace, content_to_add } = parseArgs(args);
1019
1022
  if (!targetPath) return 'ERROR: Missing "path" argument for update_file.';
@@ -1022,7 +1025,7 @@ var update_file = async (args) => {
1022
1025
  const strip = (t) => t.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").trim();
1023
1026
  content_to_replace = strip(content_to_replace);
1024
1027
  content_to_add = strip(content_to_add);
1025
- const absolutePath = path10.resolve(process.cwd(), targetPath);
1028
+ const absolutePath = path11.resolve(process.cwd(), targetPath);
1026
1029
  try {
1027
1030
  if (!fs10.existsSync(absolutePath)) {
1028
1031
  return `ERROR: File [${targetPath}] does not exist. Use write_file instead.`;
@@ -1115,10 +1118,10 @@ ${finalOutput}`);
1115
1118
 
1116
1119
  // src/tools/read_folder.js
1117
1120
  import fs11 from "fs";
1118
- import path11 from "path";
1121
+ import path12 from "path";
1119
1122
  var read_folder = async (args) => {
1120
1123
  const { path: targetPath = "." } = parseArgs(args);
1121
- const absolutePath = path11.resolve(process.cwd(), targetPath);
1124
+ const absolutePath = path12.resolve(process.cwd(), targetPath);
1122
1125
  try {
1123
1126
  if (!fs11.existsSync(absolutePath)) {
1124
1127
  return `ERROR: Path [${targetPath}] does not exist.`;
@@ -1132,7 +1135,7 @@ var read_folder = async (args) => {
1132
1135
  const displayItems = files.slice(0, maxDisplay);
1133
1136
  const folderData = [];
1134
1137
  for (const file of displayItems) {
1135
- const fPath = path11.join(absolutePath, file);
1138
+ const fPath = path12.join(absolutePath, file);
1136
1139
  let indicator = "\u{1F4C4}";
1137
1140
  let info = { name: file, type: "unknown", size: "N/A", mtime: "N/A" };
1138
1141
  try {
@@ -1202,7 +1205,7 @@ var dispatchTool = async (toolName, args, context = {}) => {
1202
1205
  };
1203
1206
 
1204
1207
  // src/utils/ai.js
1205
- import path12 from "path";
1208
+ import path13 from "path";
1206
1209
  import fs12 from "fs";
1207
1210
  var client = null;
1208
1211
  var TERMINATION_SIGNAL = false;
@@ -1317,11 +1320,11 @@ USER_PROMPT: ${agentText}`.trim();
1317
1320
  } catch (err) {
1318
1321
  const errMsg = err.message || String(err);
1319
1322
  const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
1320
- const agentErrDir = path12.join(LOGS_DIR, "agent");
1323
+ const agentErrDir = path13.join(LOGS_DIR, "agent");
1321
1324
  if (!fs12.existsSync(agentErrDir)) {
1322
1325
  fs12.mkdirSync(agentErrDir, { recursive: true });
1323
1326
  }
1324
- fs12.appendFileSync(path12.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errMsg}
1327
+ fs12.appendFileSync(path13.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errMsg}
1325
1328
  `);
1326
1329
  const isRetryable = errMsg.includes("429") || errMsg.includes("503") || errMsg.includes("overloaded") || errMsg.includes("deadline");
1327
1330
  if (isRetryable && retryCount < MAX_RETRIES) {
@@ -1370,7 +1373,7 @@ USER_PROMPT: ${agentText}`.trim();
1370
1373
  const { path: targetPath2, start_line = 1, end_line = 500 } = parseArgs(toolCall.args);
1371
1374
  let totalLines = "...";
1372
1375
  try {
1373
- const absPath = path12.resolve(process.cwd(), targetPath2);
1376
+ const absPath = path13.resolve(process.cwd(), targetPath2);
1374
1377
  if (fs12.existsSync(absPath)) {
1375
1378
  const content = fs12.readFileSync(absPath, "utf8");
1376
1379
  totalLines = content.split("\n").length;
@@ -1418,7 +1421,7 @@ ${boxBottom}
1418
1421
  /\/usr\//
1419
1422
  // Sensitive Linux paths
1420
1423
  ];
1421
- const currentDrive = path12.resolve(process.cwd()).substring(0, 3).toLowerCase();
1424
+ const currentDrive = path13.resolve(process.cwd()).substring(0, 3).toLowerCase();
1422
1425
  const isViolating = riskyPatterns.some((pattern) => {
1423
1426
  if (pattern.source === "[a-zA-Z]:[\\\\\\/]") {
1424
1427
  const driveMatch = command.match(/[a-zA-Z]:[\\\/]/i);
@@ -1440,8 +1443,8 @@ ${boxBottom}
1440
1443
  const targetPath = parsedArgs.path || parsedArgs.targetPath || null;
1441
1444
  if (targetPath) {
1442
1445
  const isExternalOff = settings.systemSettings && settings.systemSettings.allowExternalAccess === false;
1443
- const absoluteTarget = path12.resolve(targetPath);
1444
- const absoluteCwd = path12.resolve(process.cwd());
1446
+ const absoluteTarget = path13.resolve(targetPath);
1447
+ const absoluteCwd = path13.resolve(process.cwd());
1445
1448
  if (isExternalOff && !absoluteTarget.startsWith(absoluteCwd)) {
1446
1449
  const denyMsg = `Access Denied. You are not allowed to access files outside the current workspace. To enable this, ask the user to turn on "External Workspace Access" in /settings.`;
1447
1450
  toolResults.push(`[TOOL_RESULT]: ERROR: ${denyMsg}`);
@@ -1480,11 +1483,11 @@ ${boxBottom}
1480
1483
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
1481
1484
  const isErr = result.startsWith("ERROR:");
1482
1485
  const logStatus = isErr ? result.trim() : "SUCCESS";
1483
- const toolHistDir = path12.join(LOGS_DIR, "tools");
1486
+ const toolHistDir = path13.join(LOGS_DIR, "tools");
1484
1487
  if (!fs12.existsSync(toolHistDir)) {
1485
1488
  fs12.mkdirSync(toolHistDir, { recursive: true });
1486
1489
  }
1487
- fs12.appendFileSync(path12.join(toolHistDir, "history.log"), `HISTORY [${timestamp}]: ${toolCall.toolName} [${logStatus}]
1490
+ fs12.appendFileSync(path13.join(toolHistDir, "history.log"), `HISTORY [${timestamp}]: ${toolCall.toolName} [${logStatus}]
1488
1491
  `);
1489
1492
  } catch (logErr) {
1490
1493
  }
@@ -1538,11 +1541,11 @@ ${boxBottom}
1538
1541
  if (parts && parts[1]?.text) {
1539
1542
  finalSynthesis = parts[1].text;
1540
1543
  const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
1541
- const janitorLogDir = path12.join(LOGS_DIR, "janitor");
1544
+ const janitorLogDir = path13.join(LOGS_DIR, "janitor");
1542
1545
  if (!fs12.existsSync(janitorLogDir)) {
1543
1546
  fs12.mkdirSync(janitorLogDir, { recursive: true });
1544
1547
  }
1545
- fs12.appendFileSync(path12.join(janitorLogDir, "debug.log"), `DEBUG [${date}]: ${finalSynthesis}
1548
+ fs12.appendFileSync(path13.join(janitorLogDir, "debug.log"), `DEBUG [${date}]: ${finalSynthesis}
1546
1549
  `);
1547
1550
  } else if (parts && parts[0]?.text) finalSynthesis = parts[0].text;
1548
1551
  else if (janitorResult.response && janitorResult.response.text) finalSynthesis = janitorResult.response.text();
@@ -1554,8 +1557,8 @@ ${boxBottom}
1554
1557
  const toolContext = { chatId, sessionId: chatId, history };
1555
1558
  const result = await dispatchTool(janitorToolCall.toolName, janitorToolCall.args, toolContext);
1556
1559
  const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
1557
- const janitorLogDir = path12.join(LOGS_DIR, "janitor");
1558
- fs12.appendFileSync(path12.join(janitorLogDir, "debug.log"), `DEBUG [${date}]: RESULT [${janitorToolCall.toolName}]: ${result}
1560
+ const janitorLogDir = path13.join(LOGS_DIR, "janitor");
1561
+ fs12.appendFileSync(path13.join(janitorLogDir, "debug.log"), `DEBUG [${date}]: RESULT [${janitorToolCall.toolName}]: ${result}
1559
1562
  `);
1560
1563
  if (janitorToolCall.toolName === "memory" && !janitorToolCall.args.includes("action='temp'")) {
1561
1564
  yield { type: "memory_updated" };
@@ -1563,11 +1566,11 @@ ${boxBottom}
1563
1566
  }
1564
1567
  } catch (janitorErr) {
1565
1568
  const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
1566
- const janitorErrDir = path12.join(LOGS_DIR, "janitor");
1569
+ const janitorErrDir = path13.join(LOGS_DIR, "janitor");
1567
1570
  if (!fs12.existsSync(janitorErrDir)) {
1568
1571
  fs12.mkdirSync(janitorErrDir, { recursive: true });
1569
1572
  }
1570
- fs12.appendFileSync(path12.join(janitorErrDir, "error.log"), `ERROR [${date}]: ${janitorErr.message}
1573
+ fs12.appendFileSync(path13.join(janitorErrDir, "error.log"), `ERROR [${date}]: ${janitorErr.message}
1571
1574
  `);
1572
1575
  console.error("Janitor Background Tasks Failed:", janitorErr.message);
1573
1576
  }
@@ -1595,6 +1598,7 @@ ${timestamp}`;
1595
1598
 
1596
1599
  // src/utils/settings.js
1597
1600
  import fs13 from "fs-extra";
1601
+ import path14 from "path";
1598
1602
  var DEFAULT_SETTINGS = {
1599
1603
  mode: "Flux",
1600
1604
  thinkingLevel: "Medium",
@@ -1642,6 +1646,7 @@ var saveSettings = async (settings) => {
1642
1646
  try {
1643
1647
  const current = await loadSettings();
1644
1648
  const updated = { ...current, ...settings };
1649
+ await fs13.ensureDir(path14.dirname(SETTINGS_FILE));
1645
1650
  await fs13.writeJson(SETTINGS_FILE, updated, { spaces: 2 });
1646
1651
  return true;
1647
1652
  } catch (err) {
@@ -1691,8 +1696,8 @@ function ResumeModal({ onSelect, onDelete, onClose }) {
1691
1696
  // src/components/MemoryModal.jsx
1692
1697
  import React7, { useState as useState3, useEffect as useEffect2 } from "react";
1693
1698
  import { Box as Box7, Text as Text7, useInput as useInput2 } from "ink";
1694
- import path13 from "path";
1695
- var MEMORIES_PATH = path13.join(process.cwd(), "secret", "memories.json");
1699
+ import path15 from "path";
1700
+ var MEMORIES_PATH = path15.join(process.cwd(), "secret", "memories.json");
1696
1701
  function MemoryModal({ onClose }) {
1697
1702
  const [memories, setMemories] = useState3([]);
1698
1703
  const [selectedIndex, setSelectedIndex] = useState3(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A high-fidelity agentic terminal assistant for the Flux Era.",
5
5
  "keywords": [
6
6
  "ai",