@hasna/terminal 2.0.4 → 2.2.0

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 (64) hide show
  1. package/dist/cli.js +24 -10
  2. package/package.json +1 -1
  3. package/src/ai.ts +46 -113
  4. package/src/cli.tsx +23 -10
  5. package/src/command-validator.ts +11 -0
  6. package/src/context-hints.ts +202 -0
  7. package/src/output-processor.ts +7 -18
  8. package/src/providers/base.ts +3 -1
  9. package/src/providers/groq.ts +108 -0
  10. package/src/providers/index.ts +26 -2
  11. package/src/providers/providers.test.ts +4 -2
  12. package/src/providers/xai.ts +108 -0
  13. package/dist/App.js +0 -404
  14. package/dist/Browse.js +0 -79
  15. package/dist/FuzzyPicker.js +0 -47
  16. package/dist/Onboarding.js +0 -51
  17. package/dist/Spinner.js +0 -12
  18. package/dist/StatusBar.js +0 -49
  19. package/dist/ai.js +0 -368
  20. package/dist/cache.js +0 -41
  21. package/dist/command-rewriter.js +0 -64
  22. package/dist/command-validator.js +0 -77
  23. package/dist/compression.js +0 -107
  24. package/dist/diff-cache.js +0 -107
  25. package/dist/economy.js +0 -79
  26. package/dist/expand-store.js +0 -38
  27. package/dist/file-cache.js +0 -72
  28. package/dist/file-index.js +0 -62
  29. package/dist/history.js +0 -62
  30. package/dist/lazy-executor.js +0 -54
  31. package/dist/line-dedup.js +0 -59
  32. package/dist/loop-detector.js +0 -75
  33. package/dist/mcp/install.js +0 -98
  34. package/dist/mcp/server.js +0 -569
  35. package/dist/noise-filter.js +0 -86
  36. package/dist/output-processor.js +0 -136
  37. package/dist/output-router.js +0 -41
  38. package/dist/parsers/base.js +0 -2
  39. package/dist/parsers/build.js +0 -64
  40. package/dist/parsers/errors.js +0 -101
  41. package/dist/parsers/files.js +0 -78
  42. package/dist/parsers/git.js +0 -99
  43. package/dist/parsers/index.js +0 -48
  44. package/dist/parsers/tests.js +0 -89
  45. package/dist/providers/anthropic.js +0 -39
  46. package/dist/providers/base.js +0 -4
  47. package/dist/providers/cerebras.js +0 -95
  48. package/dist/providers/index.js +0 -49
  49. package/dist/recipes/model.js +0 -20
  50. package/dist/recipes/storage.js +0 -136
  51. package/dist/search/content-search.js +0 -68
  52. package/dist/search/file-search.js +0 -61
  53. package/dist/search/filters.js +0 -34
  54. package/dist/search/index.js +0 -5
  55. package/dist/search/semantic.js +0 -320
  56. package/dist/session-boot.js +0 -59
  57. package/dist/session-context.js +0 -55
  58. package/dist/sessions-db.js +0 -120
  59. package/dist/smart-display.js +0 -286
  60. package/dist/snapshots.js +0 -51
  61. package/dist/supervisor.js +0 -112
  62. package/dist/test-watchlist.js +0 -131
  63. package/dist/tree.js +0 -94
  64. package/dist/usage-cache.js +0 -65
@@ -1,65 +0,0 @@
1
- // Usage learning cache — zero-cost repeated queries
2
- // After 3 identical prompt→command mappings, cache locally
3
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
4
- import { homedir } from "os";
5
- import { join } from "path";
6
- import { createHash } from "crypto";
7
- const DIR = join(homedir(), ".terminal");
8
- const CACHE_FILE = join(DIR, "learned.json");
9
- function ensureDir() {
10
- if (!existsSync(DIR))
11
- mkdirSync(DIR, { recursive: true });
12
- }
13
- function hash(s) {
14
- return createHash("md5").update(s).digest("hex").slice(0, 12);
15
- }
16
- function cacheKey(prompt) {
17
- const projectHash = hash(process.cwd());
18
- const promptHash = hash(prompt.toLowerCase().trim());
19
- return `${projectHash}:${promptHash}`;
20
- }
21
- function loadCache() {
22
- ensureDir();
23
- if (!existsSync(CACHE_FILE))
24
- return {};
25
- try {
26
- return JSON.parse(readFileSync(CACHE_FILE, "utf8"));
27
- }
28
- catch {
29
- return {};
30
- }
31
- }
32
- function saveCache(cache) {
33
- ensureDir();
34
- writeFileSync(CACHE_FILE, JSON.stringify(cache));
35
- }
36
- /** Check if we have a learned command for this prompt (3+ identical mappings) */
37
- export function getLearned(prompt) {
38
- const key = cacheKey(prompt);
39
- const cache = loadCache();
40
- const entry = cache[key];
41
- if (entry && entry.count >= 3)
42
- return entry.command;
43
- return null;
44
- }
45
- /** Record a prompt→command mapping */
46
- export function recordMapping(prompt, command) {
47
- const key = cacheKey(prompt);
48
- const cache = loadCache();
49
- const existing = cache[key];
50
- if (existing && existing.command === command) {
51
- existing.count++;
52
- existing.lastUsed = Date.now();
53
- }
54
- else {
55
- cache[key] = { command, count: 1, lastUsed: Date.now() };
56
- }
57
- saveCache(cache);
58
- }
59
- /** Get cache stats */
60
- export function learnedStats() {
61
- const cache = loadCache();
62
- const entries = Object.keys(cache).length;
63
- const cached = Object.values(cache).filter(e => e.count >= 3).length;
64
- return { entries, cached };
65
- }