grok-cli-hurry-mode 1.0.31 → 1.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import * as fs from 'fs';
3
- import { existsSync } from 'fs';
3
+ import fs__default, { existsSync } from 'fs';
4
4
  import * as path7 from 'path';
5
5
  import path7__default from 'path';
6
6
  import * as os from 'os';
@@ -7027,10 +7027,10 @@ var DependencyAnalyzerTool = class {
7027
7027
  const circularDeps = [];
7028
7028
  const visited = /* @__PURE__ */ new Set();
7029
7029
  const visiting = /* @__PURE__ */ new Set();
7030
- const dfs = (filePath, path24) => {
7030
+ const dfs = (filePath, path25) => {
7031
7031
  if (visiting.has(filePath)) {
7032
- const cycleStart = path24.indexOf(filePath);
7033
- const cycle = path24.slice(cycleStart).concat([filePath]);
7032
+ const cycleStart = path25.indexOf(filePath);
7033
+ const cycle = path25.slice(cycleStart).concat([filePath]);
7034
7034
  circularDeps.push({
7035
7035
  cycle: cycle.map((fp) => graph.nodes.get(fp)?.filePath || fp),
7036
7036
  severity: cycle.length <= 2 ? "error" : "warning",
@@ -7046,7 +7046,7 @@ var DependencyAnalyzerTool = class {
7046
7046
  if (node) {
7047
7047
  for (const dependency of node.dependencies) {
7048
7048
  if (graph.nodes.has(dependency)) {
7049
- dfs(dependency, [...path24, filePath]);
7049
+ dfs(dependency, [...path25, filePath]);
7050
7050
  }
7051
7051
  }
7052
7052
  }
@@ -9012,10 +9012,10 @@ Current working directory: ${process.cwd()}`
9012
9012
  return await this.textEditor.view(args.path, range);
9013
9013
  } catch (error) {
9014
9014
  console.warn(`view_file tool failed, falling back to bash: ${error.message}`);
9015
- const path24 = args.path;
9016
- let command = `cat "${path24}"`;
9015
+ const path25 = args.path;
9016
+ let command = `cat "${path25}"`;
9017
9017
  if (args.start_line && args.end_line) {
9018
- command = `sed -n '${args.start_line},${args.end_line}p' "${path24}"`;
9018
+ command = `sed -n '${args.start_line},${args.end_line}p' "${path25}"`;
9019
9019
  }
9020
9020
  return await this.bash.execute(command);
9021
9021
  }
@@ -9240,10 +9240,6 @@ EOF`;
9240
9240
  }
9241
9241
  };
9242
9242
 
9243
- // package.json
9244
- var package_default = {
9245
- version: "1.0.31"};
9246
-
9247
9243
  // src/utils/text-utils.ts
9248
9244
  function isWordBoundary(char) {
9249
9245
  if (!char) return true;
@@ -10648,13 +10644,13 @@ var ReadmeGenerator = class {
10648
10644
  }
10649
10645
  }
10650
10646
  generateReadmeContent(analysis) {
10651
- const pkg = analysis.packageJson;
10652
- const projectName = this.config.projectName || pkg?.name || "Project";
10647
+ const pkg2 = analysis.packageJson;
10648
+ const projectName = this.config.projectName || pkg2?.name || "Project";
10653
10649
  let content = `# ${projectName}
10654
10650
 
10655
10651
  `;
10656
- if (pkg?.description) {
10657
- content += `${pkg.description}
10652
+ if (pkg2?.description) {
10653
+ content += `${pkg2.description}
10658
10654
 
10659
10655
  `;
10660
10656
  } else {
@@ -10662,7 +10658,7 @@ var ReadmeGenerator = class {
10662
10658
 
10663
10659
  `;
10664
10660
  }
10665
- if (pkg) {
10661
+ if (pkg2) {
10666
10662
  content += this.generateBadges(analysis);
10667
10663
  }
10668
10664
  content += `## \u{1F4CB} Table of Contents
@@ -10676,7 +10672,7 @@ var ReadmeGenerator = class {
10676
10672
  `;
10677
10673
  if (analysis.hasTests) content += `- [Testing](#testing)
10678
10674
  `;
10679
- if (pkg?.scripts?.build) content += `- [Building](#building)
10675
+ if (pkg2?.scripts?.build) content += `- [Building](#building)
10680
10676
  `;
10681
10677
  content += `- [Configuration](#configuration)
10682
10678
  `;
@@ -10688,10 +10684,10 @@ var ReadmeGenerator = class {
10688
10684
  content += `## \u{1F680} Installation
10689
10685
 
10690
10686
  `;
10691
- if (pkg?.bin) {
10687
+ if (pkg2?.bin) {
10692
10688
  content += `### Global Installation
10693
10689
  \`\`\`bash
10694
- npm install -g ${pkg.name}
10690
+ npm install -g ${pkg2.name}
10695
10691
  \`\`\`
10696
10692
 
10697
10693
  `;
@@ -10702,7 +10698,7 @@ npm install -g ${pkg.name}
10702
10698
  content += `# Clone the repository
10703
10699
  git clone <repository-url>
10704
10700
  `;
10705
- content += `cd ${pkg?.name || projectName.toLowerCase()}
10701
+ content += `cd ${pkg2?.name || projectName.toLowerCase()}
10706
10702
 
10707
10703
  `;
10708
10704
  content += `# Install dependencies
@@ -10713,8 +10709,8 @@ npm install
10713
10709
  content += `## \u{1F4BB} Usage
10714
10710
 
10715
10711
  `;
10716
- if (pkg?.bin) {
10717
- const binName = Object.keys(pkg.bin)[0];
10712
+ if (pkg2?.bin) {
10713
+ const binName = Object.keys(pkg2.bin)[0];
10718
10714
  content += `### Command Line
10719
10715
  \`\`\`bash
10720
10716
  ${binName} [options]
@@ -10773,7 +10769,7 @@ npm run test:watch
10773
10769
  `;
10774
10770
  }
10775
10771
  }
10776
- if (pkg?.scripts?.build) {
10772
+ if (pkg2?.scripts?.build) {
10777
10773
  content += `## \u{1F4E6} Building
10778
10774
 
10779
10775
  `;
@@ -10824,7 +10820,7 @@ TypeScript is configured via \`tsconfig.json\`.
10824
10820
 
10825
10821
  `;
10826
10822
  }
10827
- if (analysis.framework === "Express.js" || pkg?.main?.includes("api")) {
10823
+ if (analysis.framework === "Express.js" || pkg2?.main?.includes("api")) {
10828
10824
  content += `## \u{1F4D6} API Documentation
10829
10825
 
10830
10826
  `;
@@ -10849,8 +10845,8 @@ TypeScript is configured via \`tsconfig.json\`.
10849
10845
  content += `## \u{1F4C4} License
10850
10846
 
10851
10847
  `;
10852
- if (pkg?.license) {
10853
- content += `This project is licensed under the ${pkg.license} License.
10848
+ if (pkg2?.license) {
10849
+ content += `This project is licensed under the ${pkg2.license} License.
10854
10850
 
10855
10851
  `;
10856
10852
  } else {
@@ -12901,6 +12897,63 @@ function useInputHandler({
12901
12897
  process.exit(0);
12902
12898
  return;
12903
12899
  }
12900
+ const AUTO_COMPRESS_THRESHOLD = 20;
12901
+ const MIN_HISTORY_SIZE = 10;
12902
+ const PRESERVE_RECENT = 5;
12903
+ if (chatHistory.length > AUTO_COMPRESS_THRESHOLD) {
12904
+ const currentHistoryLength = chatHistory.length;
12905
+ const canCompress = currentHistoryLength >= MIN_HISTORY_SIZE;
12906
+ if (canCompress) {
12907
+ try {
12908
+ setIsProcessing(true);
12909
+ const autoCompressEntry = {
12910
+ type: "assistant",
12911
+ content: `\u{1F916} **Automatic Compression Triggered**
12912
+
12913
+ History has ${currentHistoryLength} entries (threshold: ${AUTO_COMPRESS_THRESHOLD}). Compressing to maintain performance...`,
12914
+ timestamp: /* @__PURE__ */ new Date()
12915
+ };
12916
+ setChatHistory((prev) => [...prev, autoCompressEntry]);
12917
+ const olderEntries = chatHistory.slice(0, -PRESERVE_RECENT);
12918
+ const contentToCompress = olderEntries.map((entry) => entry.content).join("\n");
12919
+ const subagentFramework = new SubagentFramework();
12920
+ const taskId = await subagentFramework.spawnSubagent({
12921
+ type: "summarizer",
12922
+ input: {
12923
+ content: contentToCompress,
12924
+ compressionTarget: 0.3
12925
+ },
12926
+ priority: "medium"
12927
+ });
12928
+ const result = await subagentFramework.waitForResult(taskId, 1e4);
12929
+ if (result.success) {
12930
+ const compressedEntry = {
12931
+ type: "assistant",
12932
+ content: `\u{1F4DD} **Auto-Compressed History Summary**
12933
+
12934
+ ${result.summary}
12935
+
12936
+ *Auto-compressed ${currentHistoryLength - PRESERVE_RECENT} entries at ${(/* @__PURE__ */ new Date()).toLocaleString()}*`,
12937
+ timestamp: /* @__PURE__ */ new Date()
12938
+ };
12939
+ const recentEntries = chatHistory.slice(-PRESERVE_RECENT);
12940
+ const newHistory = [compressedEntry, ...recentEntries];
12941
+ setChatHistory(newHistory);
12942
+ const successEntry = {
12943
+ type: "assistant",
12944
+ content: `\u2705 **Auto-Compression Complete**
12945
+
12946
+ Reduced from ${currentHistoryLength} to ${PRESERVE_RECENT + 1} entries.`,
12947
+ timestamp: /* @__PURE__ */ new Date()
12948
+ };
12949
+ setChatHistory((prev) => [...prev, successEntry]);
12950
+ }
12951
+ setIsProcessing(false);
12952
+ } catch (error) {
12953
+ setIsProcessing(false);
12954
+ }
12955
+ }
12956
+ }
12904
12957
  if (userInput.trim()) {
12905
12958
  const directCommandResult = await handleDirectCommand(userInput);
12906
12959
  if (!directCommandResult) {
@@ -13611,11 +13664,16 @@ ${result.suggestions.map((s) => `- ${s}`).join("\n")}
13611
13664
  const args = trimmedInput.split(" ").slice(1);
13612
13665
  const force = args.includes("--force");
13613
13666
  const dryRun = args.includes("--dry-run");
13667
+ const MIN_HISTORY_SIZE = 10;
13668
+ const PRESERVE_RECENT = 5;
13669
+ const currentHistoryLength = chatHistory.length;
13670
+ const olderEntries = chatHistory.slice(0, -PRESERVE_RECENT);
13671
+ const contentToCompress = olderEntries.map((entry) => entry.content).join("\n");
13614
13672
  const subagentFramework = new SubagentFramework();
13615
13673
  const taskId = await subagentFramework.spawnSubagent({
13616
13674
  type: "summarizer",
13617
13675
  input: {
13618
- content: chatHistory.map((entry) => entry.content).join("\n"),
13676
+ content: contentToCompress,
13619
13677
  compressionTarget: 0.3
13620
13678
  // 70% reduction
13621
13679
  },
@@ -13624,31 +13682,62 @@ ${result.suggestions.map((s) => `- ${s}`).join("\n")}
13624
13682
  const result = await subagentFramework.waitForResult(taskId, 1e4);
13625
13683
  if (result.success) {
13626
13684
  const metrics = subagentFramework.getPerformanceMetrics();
13685
+ const canCompress = currentHistoryLength >= MIN_HISTORY_SIZE || force;
13686
+ const wouldCompressCount = Math.max(0, currentHistoryLength - PRESERVE_RECENT);
13627
13687
  const resultEntry = {
13628
13688
  type: "assistant",
13629
13689
  content: dryRun ? `\u{1F4CA} **Compression Preview (Dry Run)**
13630
13690
 
13691
+ **Current history:** ${currentHistoryLength} entries
13692
+ **Would compress:** ${wouldCompressCount} older entries into 1 summary
13693
+ **Would preserve:** Last ${PRESERVE_RECENT} recent entries
13694
+ **Estimated reduction:** ~70%
13695
+
13696
+ **Compressed summary:**
13631
13697
  ${result.summary}
13632
13698
 
13633
- \u{1F4A1} Use \`/compact\` to apply compression` : `\u{1F9F9} **Context Compressed Successfully**
13699
+ \u{1F4A1} Use \`/compact\` to apply compression${!canCompress ? ` (requires ${MIN_HISTORY_SIZE}+ entries or --force)` : ""}` : canCompress ? `\u{1F9F9} **Context Compressed Successfully**
13634
13700
 
13635
13701
  ${result.summary}
13636
13702
 
13637
13703
  \u{1F4C8} **Performance:**
13704
+ - Original entries: ${currentHistoryLength}
13705
+ - Compressed to: ${PRESERVE_RECENT + 1} entries
13638
13706
  - Tokens saved: ~${result.output.compressionRatio * 100}%
13639
13707
  - Processing time: ${result.executionTime}ms
13640
- - Subagent tokens used: ${result.tokensUsed}`,
13708
+ - Subagent tokens used: ${result.tokensUsed}` : `\u26A0\uFE0F **Compression Skipped**
13709
+
13710
+ History too small for compression (${currentHistoryLength} < ${MIN_HISTORY_SIZE} entries).
13711
+
13712
+ **Preview:**
13713
+ ${result.summary}
13714
+
13715
+ \u{1F4A1} Use \`/compact --force\` to compress anyway`,
13641
13716
  timestamp: /* @__PURE__ */ new Date()
13642
13717
  };
13718
+ if (!dryRun && canCompress) {
13719
+ const compressedEntry = {
13720
+ type: "assistant",
13721
+ content: `\u{1F4DD} **Compressed History Summary**
13722
+
13723
+ ${result.summary}
13724
+
13725
+ *Compressed ${wouldCompressCount} entries at ${(/* @__PURE__ */ new Date()).toLocaleString()}*`,
13726
+ timestamp: /* @__PURE__ */ new Date()
13727
+ };
13728
+ const recentEntries = chatHistory.slice(-PRESERVE_RECENT);
13729
+ const newHistory = [compressedEntry, ...recentEntries];
13730
+ setChatHistory(newHistory);
13731
+ }
13643
13732
  setChatHistory((prev) => [...prev, resultEntry]);
13644
- if (!dryRun && result.success) {
13733
+ if (!dryRun && canCompress) {
13645
13734
  const tipsEntry = {
13646
13735
  type: "assistant",
13647
13736
  content: `\u2728 **Context Optimization Complete**
13648
13737
 
13649
13738
  **What happened:**
13650
- - Older conversations summarized
13651
- - Recent context preserved
13739
+ - ${wouldCompressCount} older conversations summarized
13740
+ - Last ${PRESERVE_RECENT} recent entries preserved
13652
13741
  - Key decisions and TODOs maintained
13653
13742
 
13654
13743
  **Options:**
@@ -14606,6 +14695,10 @@ function ApiKeyInput({ onApiKeySet }) {
14606
14695
  }
14607
14696
 
14608
14697
  // src/ui/components/chat-interface.tsx
14698
+ var pkgPath = path7__default.resolve(process.cwd(), "package.json");
14699
+ console.log("Reading package.json from:", pkgPath);
14700
+ var pkg = JSON.parse(fs__default.readFileSync(pkgPath, "utf8"));
14701
+ console.log("Version:", pkg.version);
14609
14702
  function ChatInterfaceWithAgent({
14610
14703
  agent,
14611
14704
  initialMessage
@@ -14652,7 +14745,7 @@ function ChatInterfaceWithAgent({
14652
14745
  const grokLogo = {
14653
14746
  string: "\x1B[33m ##### ##### ##### # #\n# # # # # # #\n# ### # # # # # #\n# # ##### # # # #\n# ### # # # # # #\n# # # # # # #\n ##### # # ##### # #\x1B[0m"
14654
14747
  };
14655
- const logoOutput = (typeof grokLogo === "object" && "string" in grokLogo ? grokLogo.string : String(grokLogo)) + "\nHURRY MODE\n" + package_default.version;
14748
+ const logoOutput = (typeof grokLogo === "object" && "string" in grokLogo ? grokLogo.string : String(grokLogo)) + "\nHURRY MODE\n" + pkg.version;
14656
14749
  const logoLines = logoOutput.split("\n");
14657
14750
  logoLines.forEach((line) => {
14658
14751
  if (line.trim()) {
@@ -15079,6 +15172,10 @@ function createMCPCommand() {
15079
15172
  return mcpCommand;
15080
15173
  }
15081
15174
 
15175
+ // package.json
15176
+ var package_default = {
15177
+ version: "1.0.32"};
15178
+
15082
15179
  // src/index.ts
15083
15180
  dotenv.config();
15084
15181
  process.on("SIGTERM", () => {