@hasna/terminal 3.7.2 → 3.7.3

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.
@@ -578,12 +578,14 @@ export function createServer() {
578
578
  return { content: [{ type: "text", text: JSON.stringify({ error: `Cannot read ${filePath}` }) }] };
579
579
  }
580
580
  // AI extracts symbols — works for ANY language
581
- const provider = getOutputProvider();
582
- const outputModel = provider.name === "groq" ? "llama-3.1-8b-instant" : undefined;
583
- const content = result.content.length > 6000 ? result.content.slice(0, 6000) : result.content;
584
- const summary = await provider.complete(`File: ${filePath}\n\n${content}`, {
585
- model: outputModel,
586
- system: `Extract all symbols from this source file. Return ONLY a JSON array, no explanation.
581
+ let symbols = [];
582
+ try {
583
+ const provider = getOutputProvider();
584
+ const outputModel = provider.name === "groq" ? "llama-3.1-8b-instant" : undefined;
585
+ const content = result.content.length > 8000 ? result.content.slice(0, 8000) : result.content;
586
+ const summary = await provider.complete(`File: ${filePath}\n\n${content}`, {
587
+ model: outputModel,
588
+ system: `Extract all symbols from this source file. Return ONLY a JSON array, no explanation.
587
589
 
588
590
  Each symbol: {"name": "symbolName", "kind": "function|class|method|interface|type|variable|export", "line": lineNumber, "signature": "brief signature"}
589
591
 
@@ -591,17 +593,17 @@ For class methods, use "ClassName.methodName" as name with kind "method".
591
593
  Include: functions, classes, methods, interfaces, types, exported constants.
592
594
  Exclude: imports, local variables, comments.
593
595
  Line numbers must be accurate (count from 1).`,
594
- maxTokens: 1000,
595
- temperature: 0,
596
- });
597
- // Parse AI response
598
- let symbols = [];
599
- try {
596
+ maxTokens: 2000,
597
+ temperature: 0,
598
+ });
600
599
  const jsonMatch = summary.match(/\[[\s\S]*\]/);
601
600
  if (jsonMatch)
602
601
  symbols = JSON.parse(jsonMatch[0]);
603
602
  }
604
- catch { }
603
+ catch (err) {
604
+ // Surface the error instead of silently returning []
605
+ return { content: [{ type: "text", text: JSON.stringify({ error: `AI symbol extraction failed: ${err.message?.slice(0, 200)}`, file: filePath }) }] };
606
+ }
605
607
  const outputTokens = estimateTokens(result.content);
606
608
  const symbolTokens = estimateTokens(JSON.stringify(symbols));
607
609
  logCall("symbols", { command: filePath, outputTokens, tokensSaved: Math.max(0, outputTokens - symbolTokens), durationMs: Date.now() - start, aiProcessed: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/terminal",
3
- "version": "3.7.2",
3
+ "version": "3.7.3",
4
4
  "description": "Smart terminal wrapper for AI agents and humans — structured output, token compression, MCP server, natural language",
5
5
  "type": "module",
6
6
  "files": [
package/src/mcp/server.ts CHANGED
@@ -800,14 +800,16 @@ export function createServer(): McpServer {
800
800
  }
801
801
 
802
802
  // AI extracts symbols — works for ANY language
803
- const provider = getOutputProvider();
804
- const outputModel = provider.name === "groq" ? "llama-3.1-8b-instant" : undefined;
805
- const content = result.content.length > 6000 ? result.content.slice(0, 6000) : result.content;
806
- const summary = await provider.complete(
807
- `File: ${filePath}\n\n${content}`,
808
- {
809
- model: outputModel,
810
- system: `Extract all symbols from this source file. Return ONLY a JSON array, no explanation.
803
+ let symbols: any[] = [];
804
+ try {
805
+ const provider = getOutputProvider();
806
+ const outputModel = provider.name === "groq" ? "llama-3.1-8b-instant" : undefined;
807
+ const content = result.content.length > 8000 ? result.content.slice(0, 8000) : result.content;
808
+ const summary = await provider.complete(
809
+ `File: ${filePath}\n\n${content}`,
810
+ {
811
+ model: outputModel,
812
+ system: `Extract all symbols from this source file. Return ONLY a JSON array, no explanation.
811
813
 
812
814
  Each symbol: {"name": "symbolName", "kind": "function|class|method|interface|type|variable|export", "line": lineNumber, "signature": "brief signature"}
813
815
 
@@ -815,17 +817,17 @@ For class methods, use "ClassName.methodName" as name with kind "method".
815
817
  Include: functions, classes, methods, interfaces, types, exported constants.
816
818
  Exclude: imports, local variables, comments.
817
819
  Line numbers must be accurate (count from 1).`,
818
- maxTokens: 1000,
819
- temperature: 0,
820
- }
821
- );
820
+ maxTokens: 2000,
821
+ temperature: 0,
822
+ }
823
+ );
822
824
 
823
- // Parse AI response
824
- let symbols: any[] = [];
825
- try {
826
825
  const jsonMatch = summary.match(/\[[\s\S]*\]/);
827
826
  if (jsonMatch) symbols = JSON.parse(jsonMatch[0]);
828
- } catch {}
827
+ } catch (err: any) {
828
+ // Surface the error instead of silently returning []
829
+ return { content: [{ type: "text" as const, text: JSON.stringify({ error: `AI symbol extraction failed: ${err.message?.slice(0, 200)}`, file: filePath }) }] };
830
+ }
829
831
 
830
832
  const outputTokens = estimateTokens(result.content);
831
833
  const symbolTokens = estimateTokens(JSON.stringify(symbols));