@hasna/terminal 0.6.0 → 0.6.1
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 +11 -4
- package/package.json +1 -1
- package/src/cli.tsx +11 -4
package/dist/cli.js
CHANGED
|
@@ -34,11 +34,13 @@ else if (args[0] === "hook") {
|
|
|
34
34
|
const destDir = dirname(hookDest);
|
|
35
35
|
if (!existsSync(destDir))
|
|
36
36
|
mkdirSync(destDir, { recursive: true });
|
|
37
|
-
// Generate hook with
|
|
38
|
-
const
|
|
37
|
+
// Generate hook with stable paths (resolve npm global root, not fnm temp shell)
|
|
38
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
39
|
+
const distPath = join(npmRoot, "@hasna/terminal/dist");
|
|
39
40
|
const hookScript = `#!/usr/bin/env bash
|
|
40
41
|
# open-terminal PostToolUse hook — compresses Bash output
|
|
41
42
|
# Installed by: t hook install --claude
|
|
43
|
+
# Docs: https://github.com/hasna/terminal
|
|
42
44
|
|
|
43
45
|
if [ "$TOOL_NAME" != "Bash" ]; then exit 0; fi
|
|
44
46
|
OUTPUT=$(cat)
|
|
@@ -46,9 +48,14 @@ if [ \${#OUTPUT} -lt 500 ]; then echo "$OUTPUT"; exit 0; fi
|
|
|
46
48
|
|
|
47
49
|
LINE_COUNT=$(echo "$OUTPUT" | wc -l | tr -d ' ')
|
|
48
50
|
if [ "$LINE_COUNT" -gt 15 ]; then
|
|
51
|
+
# Find the dist path (stable, not fnm temp shell)
|
|
52
|
+
DIST="${distPath}"
|
|
53
|
+
if [ ! -d "$DIST" ]; then
|
|
54
|
+
DIST="$(npm root -g 2>/dev/null)/@hasna/terminal/dist"
|
|
55
|
+
fi
|
|
49
56
|
COMPRESSED=$(echo "$OUTPUT" | bun -e "
|
|
50
|
-
import{compress,stripAnsi}from'$
|
|
51
|
-
import{stripNoise}from'$
|
|
57
|
+
import{compress,stripAnsi}from'$DIST/compression.js';
|
|
58
|
+
import{stripNoise}from'$DIST/noise-filter.js';
|
|
52
59
|
let i='';process.stdin.on('data',d=>i+=d);process.stdin.on('end',()=>{
|
|
53
60
|
const c=stripNoise(stripAnsi(i)).cleaned;
|
|
54
61
|
const r=compress('bash',c,{maxTokens:500});
|
package/package.json
CHANGED
package/src/cli.tsx
CHANGED
|
@@ -40,11 +40,13 @@ else if (args[0] === "hook") {
|
|
|
40
40
|
const destDir = dirname(hookDest);
|
|
41
41
|
if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
|
|
42
42
|
|
|
43
|
-
// Generate hook with
|
|
44
|
-
const
|
|
43
|
+
// Generate hook with stable paths (resolve npm global root, not fnm temp shell)
|
|
44
|
+
const npmRoot = execSync("npm root -g", { encoding: "utf8" }).trim();
|
|
45
|
+
const distPath = join(npmRoot, "@hasna/terminal/dist");
|
|
45
46
|
const hookScript = `#!/usr/bin/env bash
|
|
46
47
|
# open-terminal PostToolUse hook — compresses Bash output
|
|
47
48
|
# Installed by: t hook install --claude
|
|
49
|
+
# Docs: https://github.com/hasna/terminal
|
|
48
50
|
|
|
49
51
|
if [ "$TOOL_NAME" != "Bash" ]; then exit 0; fi
|
|
50
52
|
OUTPUT=$(cat)
|
|
@@ -52,9 +54,14 @@ if [ \${#OUTPUT} -lt 500 ]; then echo "$OUTPUT"; exit 0; fi
|
|
|
52
54
|
|
|
53
55
|
LINE_COUNT=$(echo "$OUTPUT" | wc -l | tr -d ' ')
|
|
54
56
|
if [ "$LINE_COUNT" -gt 15 ]; then
|
|
57
|
+
# Find the dist path (stable, not fnm temp shell)
|
|
58
|
+
DIST="${distPath}"
|
|
59
|
+
if [ ! -d "$DIST" ]; then
|
|
60
|
+
DIST="$(npm root -g 2>/dev/null)/@hasna/terminal/dist"
|
|
61
|
+
fi
|
|
55
62
|
COMPRESSED=$(echo "$OUTPUT" | bun -e "
|
|
56
|
-
import{compress,stripAnsi}from'$
|
|
57
|
-
import{stripNoise}from'$
|
|
63
|
+
import{compress,stripAnsi}from'$DIST/compression.js';
|
|
64
|
+
import{stripNoise}from'$DIST/noise-filter.js';
|
|
58
65
|
let i='';process.stdin.on('data',d=>i+=d);process.stdin.on('end',()=>{
|
|
59
66
|
const c=stripNoise(stripAnsi(i)).cleaned;
|
|
60
67
|
const r=compress('bash',c,{maxTokens:500});
|