@hasna/terminal 2.0.5 → 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.
- package/dist/cli.js +23 -9
- package/package.json +1 -1
- package/src/ai.ts +46 -113
- package/src/cli.tsx +22 -9
- package/src/command-validator.ts +11 -0
- package/src/context-hints.ts +202 -0
- package/src/output-processor.ts +7 -18
- package/src/providers/base.ts +3 -1
- package/src/providers/groq.ts +108 -0
- package/src/providers/index.ts +26 -2
- package/src/providers/providers.test.ts +4 -2
- package/src/providers/xai.ts +108 -0
- package/dist/App.js +0 -404
- package/dist/Browse.js +0 -79
- package/dist/FuzzyPicker.js +0 -47
- package/dist/Onboarding.js +0 -51
- package/dist/Spinner.js +0 -12
- package/dist/StatusBar.js +0 -49
- package/dist/ai.js +0 -368
- package/dist/cache.js +0 -41
- package/dist/command-rewriter.js +0 -64
- package/dist/command-validator.js +0 -77
- package/dist/compression.js +0 -107
- package/dist/diff-cache.js +0 -107
- package/dist/economy.js +0 -79
- package/dist/expand-store.js +0 -38
- package/dist/file-cache.js +0 -72
- package/dist/file-index.js +0 -62
- package/dist/history.js +0 -62
- package/dist/lazy-executor.js +0 -54
- package/dist/line-dedup.js +0 -59
- package/dist/loop-detector.js +0 -75
- package/dist/mcp/install.js +0 -98
- package/dist/mcp/server.js +0 -569
- package/dist/noise-filter.js +0 -86
- package/dist/output-processor.js +0 -136
- package/dist/output-router.js +0 -41
- package/dist/parsers/base.js +0 -2
- package/dist/parsers/build.js +0 -64
- package/dist/parsers/errors.js +0 -101
- package/dist/parsers/files.js +0 -78
- package/dist/parsers/git.js +0 -99
- package/dist/parsers/index.js +0 -48
- package/dist/parsers/tests.js +0 -89
- package/dist/providers/anthropic.js +0 -39
- package/dist/providers/base.js +0 -4
- package/dist/providers/cerebras.js +0 -95
- package/dist/providers/index.js +0 -49
- package/dist/recipes/model.js +0 -20
- package/dist/recipes/storage.js +0 -136
- package/dist/search/content-search.js +0 -68
- package/dist/search/file-search.js +0 -61
- package/dist/search/filters.js +0 -34
- package/dist/search/index.js +0 -5
- package/dist/search/semantic.js +0 -320
- package/dist/session-boot.js +0 -59
- package/dist/session-context.js +0 -55
- package/dist/sessions-db.js +0 -120
- package/dist/smart-display.js +0 -286
- package/dist/snapshots.js +0 -51
- package/dist/supervisor.js +0 -112
- package/dist/test-watchlist.js +0 -131
- package/dist/tree.js +0 -94
- package/dist/usage-cache.js +0 -65
package/dist/usage-cache.js
DELETED
|
@@ -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
|
-
}
|