@hasna/terminal 3.6.0 → 3.7.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/mcp/server.js +3 -3
- package/dist/recipes/storage.js +20 -3
- package/package.json +1 -1
- package/src/mcp/server.ts +3 -3
- package/src/recipes/storage.ts +25 -3
package/dist/mcp/server.js
CHANGED
|
@@ -153,7 +153,7 @@ export function createServer() {
|
|
|
153
153
|
return { content: [{ type: "text", text: output }] };
|
|
154
154
|
});
|
|
155
155
|
// ── execute_smart: AI-powered output processing ────────────────────────────
|
|
156
|
-
server.tool("execute_smart", "Run a command and get AI-summarized output
|
|
156
|
+
server.tool("execute_smart", "Run a command and get AI-summarized output (80-95% token savings). Use this for: test runs, builds, git operations, process management, system info. Do NOT use for file read/write — use your native Read/Write/Edit tools instead (they're faster, no shell overhead).", {
|
|
157
157
|
command: z.string().describe("Shell command to execute"),
|
|
158
158
|
cwd: z.string().optional().describe("Working directory"),
|
|
159
159
|
timeout: z.number().optional().describe("Timeout in ms (default: 30000)"),
|
|
@@ -478,7 +478,7 @@ export function createServer() {
|
|
|
478
478
|
};
|
|
479
479
|
});
|
|
480
480
|
// ── read_file: cached file reading ─────────────────────────────────────────
|
|
481
|
-
server.tool("read_file", "Read a file with
|
|
481
|
+
server.tool("read_file", "Read a file with summarize=true for AI outline (~90% fewer tokens). For full file reads without summarization, prefer your native Read tool (faster, no MCP overhead). Use this when you want cached reads or AI summaries.", {
|
|
482
482
|
path: z.string().describe("File path"),
|
|
483
483
|
offset: z.number().optional().describe("Start line (0-indexed)"),
|
|
484
484
|
limit: z.number().optional().describe("Max lines to return"),
|
|
@@ -694,7 +694,7 @@ Match by function name, class name, method name (including ClassName.method), in
|
|
|
694
694
|
tokensSaved: processed.tokensSaved,
|
|
695
695
|
}) }] };
|
|
696
696
|
});
|
|
697
|
-
server.tool("edit", "Find and replace
|
|
697
|
+
server.tool("edit", "Find and replace in a file. For simple edits, prefer your native Edit tool (faster). Use this for batch replacements (all=true) or when you don't have a native Edit tool available.", {
|
|
698
698
|
file: z.string().describe("File path"),
|
|
699
699
|
find: z.string().describe("Text to find (exact match)"),
|
|
700
700
|
replace: z.string().describe("Replacement text"),
|
package/dist/recipes/storage.js
CHANGED
|
@@ -24,14 +24,31 @@ function saveStore(filePath, store) {
|
|
|
24
24
|
mkdirSync(dir, { recursive: true });
|
|
25
25
|
writeFileSync(filePath, JSON.stringify(store, null, 2));
|
|
26
26
|
}
|
|
27
|
+
// ── Built-in system recipes (always available, zero config) ─────────────────
|
|
28
|
+
const SYSTEM_RECIPES = [
|
|
29
|
+
// Git workflows
|
|
30
|
+
{ id: "sys-commit-push", name: "commit-push", description: "Stage all, commit, push to origin", command: "git add -A && git commit -m \"{message}\" && git push", tags: ["git"], collection: "git", variables: [{ name: "message", required: true }], createdAt: 0, updatedAt: 0 },
|
|
31
|
+
{ id: "sys-pr", name: "create-pr", description: "Create GitHub PR from current branch", command: "gh pr create --title \"{title}\" --body \"{body}\"", tags: ["git", "github"], collection: "git", variables: [{ name: "title", required: true }, { name: "body", default: "" }], createdAt: 0, updatedAt: 0 },
|
|
32
|
+
{ id: "sys-stash", name: "stash-switch", description: "Stash changes, switch branch, pop", command: "git stash && git checkout {branch} && git stash pop", tags: ["git"], collection: "git", variables: [{ name: "branch", required: true }], createdAt: 0, updatedAt: 0 },
|
|
33
|
+
// Quality checks
|
|
34
|
+
{ id: "sys-todos", name: "find-todos", description: "Find all TODO/FIXME/HACK in source code", command: "grep -rn 'TODO\\|FIXME\\|HACK\\|XXX' {path} --include='*.ts' --include='*.tsx' --include='*.js' --include='*.py' --include='*.go' --include='*.rs' --include='*.java' --include='*.rb'", tags: ["quality"], collection: "quality", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
35
|
+
{ id: "sys-deadcode", name: "find-unused-exports", description: "Find exported symbols that may be unused", command: "grep -rn 'export ' {path} --include='*.ts' | sed 's/.*export //' | sed 's/[(<:].*//' | sort -u", tags: ["quality"], collection: "quality", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
36
|
+
{ id: "sys-security", name: "security-scan", description: "Scan for common security anti-patterns", command: "grep -rn 'eval\\|exec\\|spawn\\|innerHTML\\|dangerouslySetInnerHTML\\|password.*=.*[\"'\\']' {path} --include='*.ts' --include='*.js' --include='*.py'", tags: ["security"], collection: "quality", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
37
|
+
// Project info
|
|
38
|
+
{ id: "sys-deps", name: "list-deps", description: "Show project dependencies", command: "cat package.json 2>/dev/null | grep -A 100 '\"dependencies\"' | head -30 || cat requirements.txt 2>/dev/null || cat Cargo.toml 2>/dev/null | grep -A 50 'dependencies'", tags: ["deps"], collection: "project", variables: [], createdAt: 0, updatedAt: 0 },
|
|
39
|
+
{ id: "sys-size", name: "project-size", description: "Count lines of code by file type", command: "find {path} -not -path '*/node_modules/*' -not -path '*/dist/*' -not -path '*/.git/*' -type f | xargs wc -l 2>/dev/null | sort -rn | head -20", tags: ["stats"], collection: "project", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
40
|
+
// Process management
|
|
41
|
+
{ id: "sys-port", name: "kill-port", description: "Kill whatever is running on a port", command: "lsof -ti :{port} | xargs kill -9 2>/dev/null || echo 'Port {port} is free'", tags: ["process"], collection: "system", variables: [{ name: "port", required: true }], createdAt: 0, updatedAt: 0 },
|
|
42
|
+
{ id: "sys-disk", name: "disk-usage", description: "Show disk usage of current directory", command: "du -sh {path}/* 2>/dev/null | sort -rh | head -15", tags: ["system"], collection: "system", variables: [{ name: "path", default: "." }], createdAt: 0, updatedAt: 0 },
|
|
43
|
+
];
|
|
27
44
|
// ── CRUD operations ──────────────────────────────────────────────────────────
|
|
28
|
-
/** Get all recipes (merged: global + project-scoped) */
|
|
45
|
+
/** Get all recipes (merged: system + global + project-scoped) */
|
|
29
46
|
export function listRecipes(projectPath) {
|
|
30
47
|
const global = loadStore(GLOBAL_FILE).recipes;
|
|
31
48
|
if (!projectPath)
|
|
32
|
-
return global;
|
|
49
|
+
return [...global, ...SYSTEM_RECIPES];
|
|
33
50
|
const project = loadStore(projectFile(projectPath)).recipes;
|
|
34
|
-
return [...project, ...global]; // project
|
|
51
|
+
return [...project, ...global, ...SYSTEM_RECIPES]; // project > global > system priority
|
|
35
52
|
}
|
|
36
53
|
/** Get recipes filtered by collection */
|
|
37
54
|
export function listByCollection(collection, projectPath) {
|
package/package.json
CHANGED
package/src/mcp/server.ts
CHANGED
|
@@ -181,7 +181,7 @@ export function createServer(): McpServer {
|
|
|
181
181
|
|
|
182
182
|
server.tool(
|
|
183
183
|
"execute_smart",
|
|
184
|
-
"Run a command and get AI-summarized output
|
|
184
|
+
"Run a command and get AI-summarized output (80-95% token savings). Use this for: test runs, builds, git operations, process management, system info. Do NOT use for file read/write — use your native Read/Write/Edit tools instead (they're faster, no shell overhead).",
|
|
185
185
|
{
|
|
186
186
|
command: z.string().describe("Shell command to execute"),
|
|
187
187
|
cwd: z.string().optional().describe("Working directory"),
|
|
@@ -678,7 +678,7 @@ export function createServer(): McpServer {
|
|
|
678
678
|
|
|
679
679
|
server.tool(
|
|
680
680
|
"read_file",
|
|
681
|
-
"Read a file with
|
|
681
|
+
"Read a file with summarize=true for AI outline (~90% fewer tokens). For full file reads without summarization, prefer your native Read tool (faster, no MCP overhead). Use this when you want cached reads or AI summaries.",
|
|
682
682
|
{
|
|
683
683
|
path: z.string().describe("File path"),
|
|
684
684
|
offset: z.number().optional().describe("Start line (0-indexed)"),
|
|
@@ -944,7 +944,7 @@ Match by function name, class name, method name (including ClassName.method), in
|
|
|
944
944
|
|
|
945
945
|
server.tool(
|
|
946
946
|
"edit",
|
|
947
|
-
"Find and replace
|
|
947
|
+
"Find and replace in a file. For simple edits, prefer your native Edit tool (faster). Use this for batch replacements (all=true) or when you don't have a native Edit tool available.",
|
|
948
948
|
{
|
|
949
949
|
file: z.string().describe("File path"),
|
|
950
950
|
find: z.string().describe("Text to find (exact match)"),
|
package/src/recipes/storage.ts
CHANGED
|
@@ -28,14 +28,36 @@ function saveStore(filePath: string, store: RecipeStore): void {
|
|
|
28
28
|
writeFileSync(filePath, JSON.stringify(store, null, 2));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// ── Built-in system recipes (always available, zero config) ─────────────────
|
|
32
|
+
|
|
33
|
+
const SYSTEM_RECIPES: Recipe[] = [
|
|
34
|
+
// Git workflows
|
|
35
|
+
{ id: "sys-commit-push", name: "commit-push", description: "Stage all, commit, push to origin", command: "git add -A && git commit -m \"{message}\" && git push", tags: ["git"], collection: "git", variables: [{ name: "message", required: true }], createdAt: 0, updatedAt: 0 },
|
|
36
|
+
{ id: "sys-pr", name: "create-pr", description: "Create GitHub PR from current branch", command: "gh pr create --title \"{title}\" --body \"{body}\"", tags: ["git", "github"], collection: "git", variables: [{ name: "title", required: true }, { name: "body", default: "" }], createdAt: 0, updatedAt: 0 },
|
|
37
|
+
{ id: "sys-stash", name: "stash-switch", description: "Stash changes, switch branch, pop", command: "git stash && git checkout {branch} && git stash pop", tags: ["git"], collection: "git", variables: [{ name: "branch", required: true }], createdAt: 0, updatedAt: 0 },
|
|
38
|
+
|
|
39
|
+
// Quality checks
|
|
40
|
+
{ id: "sys-todos", name: "find-todos", description: "Find all TODO/FIXME/HACK in source code", command: "grep -rn 'TODO\\|FIXME\\|HACK\\|XXX' {path} --include='*.ts' --include='*.tsx' --include='*.js' --include='*.py' --include='*.go' --include='*.rs' --include='*.java' --include='*.rb'", tags: ["quality"], collection: "quality", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
41
|
+
{ id: "sys-deadcode", name: "find-unused-exports", description: "Find exported symbols that may be unused", command: "grep -rn 'export ' {path} --include='*.ts' | sed 's/.*export //' | sed 's/[(<:].*//' | sort -u", tags: ["quality"], collection: "quality", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
42
|
+
{ id: "sys-security", name: "security-scan", description: "Scan for common security anti-patterns", command: "grep -rn 'eval\\|exec\\|spawn\\|innerHTML\\|dangerouslySetInnerHTML\\|password.*=.*[\"'\\']' {path} --include='*.ts' --include='*.js' --include='*.py'", tags: ["security"], collection: "quality", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
43
|
+
|
|
44
|
+
// Project info
|
|
45
|
+
{ id: "sys-deps", name: "list-deps", description: "Show project dependencies", command: "cat package.json 2>/dev/null | grep -A 100 '\"dependencies\"' | head -30 || cat requirements.txt 2>/dev/null || cat Cargo.toml 2>/dev/null | grep -A 50 'dependencies'", tags: ["deps"], collection: "project", variables: [], createdAt: 0, updatedAt: 0 },
|
|
46
|
+
{ id: "sys-size", name: "project-size", description: "Count lines of code by file type", command: "find {path} -not -path '*/node_modules/*' -not -path '*/dist/*' -not -path '*/.git/*' -type f | xargs wc -l 2>/dev/null | sort -rn | head -20", tags: ["stats"], collection: "project", variables: [{ name: "path", default: "src/" }], createdAt: 0, updatedAt: 0 },
|
|
47
|
+
|
|
48
|
+
// Process management
|
|
49
|
+
{ id: "sys-port", name: "kill-port", description: "Kill whatever is running on a port", command: "lsof -ti :{port} | xargs kill -9 2>/dev/null || echo 'Port {port} is free'", tags: ["process"], collection: "system", variables: [{ name: "port", required: true }], createdAt: 0, updatedAt: 0 },
|
|
50
|
+
{ id: "sys-disk", name: "disk-usage", description: "Show disk usage of current directory", command: "du -sh {path}/* 2>/dev/null | sort -rh | head -15", tags: ["system"], collection: "system", variables: [{ name: "path", default: "." }], createdAt: 0, updatedAt: 0 },
|
|
51
|
+
];
|
|
52
|
+
|
|
31
53
|
// ── CRUD operations ──────────────────────────────────────────────────────────
|
|
32
54
|
|
|
33
|
-
/** Get all recipes (merged: global + project-scoped) */
|
|
55
|
+
/** Get all recipes (merged: system + global + project-scoped) */
|
|
34
56
|
export function listRecipes(projectPath?: string): Recipe[] {
|
|
35
57
|
const global = loadStore(GLOBAL_FILE).recipes;
|
|
36
|
-
if (!projectPath) return global;
|
|
58
|
+
if (!projectPath) return [...global, ...SYSTEM_RECIPES];
|
|
37
59
|
const project = loadStore(projectFile(projectPath)).recipes;
|
|
38
|
-
return [...project, ...global]; // project
|
|
60
|
+
return [...project, ...global, ...SYSTEM_RECIPES]; // project > global > system priority
|
|
39
61
|
}
|
|
40
62
|
|
|
41
63
|
/** Get recipes filtered by collection */
|