@hasna/terminal 0.6.0 → 0.6.2
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 +60 -4
- package/package.json +1 -1
- package/src/cli.tsx +63 -4
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,55 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { render } from "ink";
|
|
4
4
|
const args = process.argv.slice(2);
|
|
5
|
+
// ── Help / Version ───────────────────────────────────────────────────────────
|
|
6
|
+
if (args[0] === "--help" || args[0] === "-h" || args[0] === "help") {
|
|
7
|
+
console.log(`open-terminal v0.6.1 — Smart terminal for AI agents and humans
|
|
8
|
+
|
|
9
|
+
USAGE:
|
|
10
|
+
terminal Launch interactive NL terminal (TUI)
|
|
11
|
+
terminal <subcommand> Run a specific command
|
|
12
|
+
|
|
13
|
+
SUBCOMMANDS:
|
|
14
|
+
mcp serve Start MCP server (stdio transport)
|
|
15
|
+
mcp install --claude|--codex|--gemini|--all
|
|
16
|
+
Install as MCP server for AI agents
|
|
17
|
+
hook install --claude Install Claude Code PostToolUse hook
|
|
18
|
+
hook uninstall Remove hooks
|
|
19
|
+
recipe add <name> <cmd> Save a reusable command recipe
|
|
20
|
+
recipe list List saved recipes
|
|
21
|
+
recipe run <name> [--var=X] Run a recipe with variable substitution
|
|
22
|
+
recipe delete <name> Delete a recipe
|
|
23
|
+
collection create <name> Create a recipe collection
|
|
24
|
+
collection list List collections
|
|
25
|
+
project init Initialize project-scoped recipes
|
|
26
|
+
repo Show git repo state (branch + status + log)
|
|
27
|
+
symbols <file> Show file outline (functions, classes, exports)
|
|
28
|
+
stats Show token economy dashboard
|
|
29
|
+
sessions List recent terminal sessions
|
|
30
|
+
sessions stats Show session analytics
|
|
31
|
+
sessions <id> Show session details
|
|
32
|
+
snapshot Capture terminal state as JSON
|
|
33
|
+
--help Show this help
|
|
34
|
+
--version Show version
|
|
35
|
+
|
|
36
|
+
MCP TOOLS (20+):
|
|
37
|
+
execute, execute_smart, execute_diff, expand, browse,
|
|
38
|
+
search_files, search_content, search_semantic, read_file,
|
|
39
|
+
read_symbol, symbols, repo_state, explain_error, status,
|
|
40
|
+
bg_start, bg_stop, bg_status, bg_logs, bg_wait_port,
|
|
41
|
+
list_recipes, run_recipe, save_recipe, list_collections,
|
|
42
|
+
snapshot, token_stats, session_history
|
|
43
|
+
|
|
44
|
+
ENVIRONMENT:
|
|
45
|
+
CEREBRAS_API_KEY Cerebras API key (free, open-source default)
|
|
46
|
+
ANTHROPIC_API_KEY Anthropic API key (Claude models)
|
|
47
|
+
`);
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
if (args[0] === "--version" || args[0] === "-v") {
|
|
51
|
+
console.log("0.6.1");
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
5
54
|
// ── MCP commands ─────────────────────────────────────────────────────────────
|
|
6
55
|
if (args[0] === "mcp") {
|
|
7
56
|
if (args[1] === "serve" || args.length === 1) {
|
|
@@ -34,11 +83,13 @@ else if (args[0] === "hook") {
|
|
|
34
83
|
const destDir = dirname(hookDest);
|
|
35
84
|
if (!existsSync(destDir))
|
|
36
85
|
mkdirSync(destDir, { recursive: true });
|
|
37
|
-
// Generate hook with
|
|
38
|
-
const
|
|
86
|
+
// Generate hook with stable paths (resolve npm global root, not fnm temp shell)
|
|
87
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
88
|
+
const distPath = join(npmRoot, "@hasna/terminal/dist");
|
|
39
89
|
const hookScript = `#!/usr/bin/env bash
|
|
40
90
|
# open-terminal PostToolUse hook — compresses Bash output
|
|
41
91
|
# Installed by: t hook install --claude
|
|
92
|
+
# Docs: https://github.com/hasna/terminal
|
|
42
93
|
|
|
43
94
|
if [ "$TOOL_NAME" != "Bash" ]; then exit 0; fi
|
|
44
95
|
OUTPUT=$(cat)
|
|
@@ -46,9 +97,14 @@ if [ \${#OUTPUT} -lt 500 ]; then echo "$OUTPUT"; exit 0; fi
|
|
|
46
97
|
|
|
47
98
|
LINE_COUNT=$(echo "$OUTPUT" | wc -l | tr -d ' ')
|
|
48
99
|
if [ "$LINE_COUNT" -gt 15 ]; then
|
|
100
|
+
# Find the dist path (stable, not fnm temp shell)
|
|
101
|
+
DIST="${distPath}"
|
|
102
|
+
if [ ! -d "$DIST" ]; then
|
|
103
|
+
DIST="$(npm root -g 2>/dev/null)/@hasna/terminal/dist"
|
|
104
|
+
fi
|
|
49
105
|
COMPRESSED=$(echo "$OUTPUT" | bun -e "
|
|
50
|
-
import{compress,stripAnsi}from'$
|
|
51
|
-
import{stripNoise}from'$
|
|
106
|
+
import{compress,stripAnsi}from'$DIST/compression.js';
|
|
107
|
+
import{stripNoise}from'$DIST/noise-filter.js';
|
|
52
108
|
let i='';process.stdin.on('data',d=>i+=d);process.stdin.on('end',()=>{
|
|
53
109
|
const c=stripNoise(stripAnsi(i)).cleaned;
|
|
54
110
|
const r=compress('bash',c,{maxTokens:500});
|
package/package.json
CHANGED
package/src/cli.tsx
CHANGED
|
@@ -4,6 +4,58 @@ import { render } from "ink";
|
|
|
4
4
|
|
|
5
5
|
const args = process.argv.slice(2);
|
|
6
6
|
|
|
7
|
+
// ── Help / Version ───────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
if (args[0] === "--help" || args[0] === "-h" || args[0] === "help") {
|
|
10
|
+
console.log(`open-terminal v0.6.1 — Smart terminal for AI agents and humans
|
|
11
|
+
|
|
12
|
+
USAGE:
|
|
13
|
+
terminal Launch interactive NL terminal (TUI)
|
|
14
|
+
terminal <subcommand> Run a specific command
|
|
15
|
+
|
|
16
|
+
SUBCOMMANDS:
|
|
17
|
+
mcp serve Start MCP server (stdio transport)
|
|
18
|
+
mcp install --claude|--codex|--gemini|--all
|
|
19
|
+
Install as MCP server for AI agents
|
|
20
|
+
hook install --claude Install Claude Code PostToolUse hook
|
|
21
|
+
hook uninstall Remove hooks
|
|
22
|
+
recipe add <name> <cmd> Save a reusable command recipe
|
|
23
|
+
recipe list List saved recipes
|
|
24
|
+
recipe run <name> [--var=X] Run a recipe with variable substitution
|
|
25
|
+
recipe delete <name> Delete a recipe
|
|
26
|
+
collection create <name> Create a recipe collection
|
|
27
|
+
collection list List collections
|
|
28
|
+
project init Initialize project-scoped recipes
|
|
29
|
+
repo Show git repo state (branch + status + log)
|
|
30
|
+
symbols <file> Show file outline (functions, classes, exports)
|
|
31
|
+
stats Show token economy dashboard
|
|
32
|
+
sessions List recent terminal sessions
|
|
33
|
+
sessions stats Show session analytics
|
|
34
|
+
sessions <id> Show session details
|
|
35
|
+
snapshot Capture terminal state as JSON
|
|
36
|
+
--help Show this help
|
|
37
|
+
--version Show version
|
|
38
|
+
|
|
39
|
+
MCP TOOLS (20+):
|
|
40
|
+
execute, execute_smart, execute_diff, expand, browse,
|
|
41
|
+
search_files, search_content, search_semantic, read_file,
|
|
42
|
+
read_symbol, symbols, repo_state, explain_error, status,
|
|
43
|
+
bg_start, bg_stop, bg_status, bg_logs, bg_wait_port,
|
|
44
|
+
list_recipes, run_recipe, save_recipe, list_collections,
|
|
45
|
+
snapshot, token_stats, session_history
|
|
46
|
+
|
|
47
|
+
ENVIRONMENT:
|
|
48
|
+
CEREBRAS_API_KEY Cerebras API key (free, open-source default)
|
|
49
|
+
ANTHROPIC_API_KEY Anthropic API key (Claude models)
|
|
50
|
+
`);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (args[0] === "--version" || args[0] === "-v") {
|
|
55
|
+
console.log("0.6.1");
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
|
|
7
59
|
// ── MCP commands ─────────────────────────────────────────────────────────────
|
|
8
60
|
|
|
9
61
|
if (args[0] === "mcp") {
|
|
@@ -40,11 +92,13 @@ else if (args[0] === "hook") {
|
|
|
40
92
|
const destDir = dirname(hookDest);
|
|
41
93
|
if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
|
|
42
94
|
|
|
43
|
-
// Generate hook with
|
|
44
|
-
const
|
|
95
|
+
// Generate hook with stable paths (resolve npm global root, not fnm temp shell)
|
|
96
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
97
|
+
const distPath = join(npmRoot, "@hasna/terminal/dist");
|
|
45
98
|
const hookScript = `#!/usr/bin/env bash
|
|
46
99
|
# open-terminal PostToolUse hook — compresses Bash output
|
|
47
100
|
# Installed by: t hook install --claude
|
|
101
|
+
# Docs: https://github.com/hasna/terminal
|
|
48
102
|
|
|
49
103
|
if [ "$TOOL_NAME" != "Bash" ]; then exit 0; fi
|
|
50
104
|
OUTPUT=$(cat)
|
|
@@ -52,9 +106,14 @@ if [ \${#OUTPUT} -lt 500 ]; then echo "$OUTPUT"; exit 0; fi
|
|
|
52
106
|
|
|
53
107
|
LINE_COUNT=$(echo "$OUTPUT" | wc -l | tr -d ' ')
|
|
54
108
|
if [ "$LINE_COUNT" -gt 15 ]; then
|
|
109
|
+
# Find the dist path (stable, not fnm temp shell)
|
|
110
|
+
DIST="${distPath}"
|
|
111
|
+
if [ ! -d "$DIST" ]; then
|
|
112
|
+
DIST="$(npm root -g 2>/dev/null)/@hasna/terminal/dist"
|
|
113
|
+
fi
|
|
55
114
|
COMPRESSED=$(echo "$OUTPUT" | bun -e "
|
|
56
|
-
import{compress,stripAnsi}from'$
|
|
57
|
-
import{stripNoise}from'$
|
|
115
|
+
import{compress,stripAnsi}from'$DIST/compression.js';
|
|
116
|
+
import{stripNoise}from'$DIST/noise-filter.js';
|
|
58
117
|
let i='';process.stdin.on('data',d=>i+=d);process.stdin.on('end',()=>{
|
|
59
118
|
const c=stripNoise(stripAnsi(i)).cleaned;
|
|
60
119
|
const r=compress('bash',c,{maxTokens:500});
|