@giladbarnea/pi-pretty-bash 1.0.12 → 1.0.13

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- last_updated: 2026-11-14T11-33
2
+ last_updated: 2026-11-22T11-40
3
3
  ---
4
4
 
5
5
  <div align="center">
@@ -29,9 +29,9 @@ Alternatively, install from Git with `pi install git:github.com/giladbarnea/pi-p
29
29
 
30
30
  Dense Bash gets readable spacing and indentation from [shfmt](https://github.com/mvdan/sh), bundled through dprint with no system binary needed. Only the display is formatted. Execution and model context keep the original command. Unparseable input stays as written.
31
31
 
32
- Short commands get syntax colors in the header. Multiline formatted commands get numbered boxes, and long commands wrap without losing their end. Inputs have a black background; output keeps the terminal background so the two stay distinct. Result boxes show status, elapsed time and line counts. Pi's tool expansion toggle governs both boxes. Collapsed, a command box over ten rows shows its first and last five, and results show ten visual tail rows; expansion shows the complete command and returned text.
32
+ Short commands get syntax colors in the header. Multiline formatted commands get numbered boxes, and long commands wrap without losing their end. Boxes paint no background, so the terminal background shows through. Result boxes show status, elapsed time and line counts. Pi's tool expansion toggle governs both boxes. Collapsed, a command box over ten rows shows its first and last five, and results show ten visual tail rows; expansion shows the complete command and returned text.
33
33
 
34
- The Bash palette preserves the former personal `bash-rich-highlight` choices, including function colors for built-ins. It uses `cli-highlight` with Pi theme colors, not the former HTML parser or hardcoded installation paths.
34
+ Commands are parsed with [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) and colored with Pi theme colors: command names, subcommands, flags, strings, variables, operators and redirections each get their own color. A quoted heredoc delimiter names its body's language, like a Markdown fence: `'PY'`, `'JS'`, `'TS'`, `'JSON'`, `'DIFF'`, `'RUBY'` and a few aliases get that language's colors from Pi's own highlighter, even while the command is still streaming. Other delimiters such as `'EOF'` keep string colors. Commands over 16 KiB, or too expensive to parse, stay complete in plain text; heredoc bodies beyond 4 KiB per command keep string colors.
35
35
 
36
36
  Complete valid JSON up to 200 KiB gets Pi's JSON colors without reformatting. Larger JSON, partial output and unrecognized formats stay plain. Rendering never cuts or changes the result sent to the model. Failure captions use Pi's error flag, not text that merely resembles an exit-status message.
37
37
 
@@ -0,0 +1,11 @@
1
+ ---
2
+ last_updated: 2026-11-02T23-18
3
+ ---
4
+
5
+ # Bundled highlighting assets
6
+
7
+ `assets/tree-sitter-bash.wasm` comes from `tree-sitter-bash` 0.25.1, licensed under MIT. Its SHA-256 is `8292919c88a0f7d3fb31d0cd0253ca5a9531bc1ede82b0537f2c63dd8abe6a7a`. The complete license is in `licenses/tree-sitter-bash.txt`.
8
+
9
+ `assets/bash.scm` derives from the [nvim-treesitter Bash highlights query](https://github.com/nvim-treesitter/nvim-treesitter/blob/f47f549f74cea5d5f25a5205c9e127cd882f1d20/runtime/queries/bash/highlights.scm), licensed under Apache-2.0. The November 2, 2026 source snapshot has SHA-256 `a4e5e1afa7656c3275629467170362997a7b36f51405b0fc0e6c0be080693acd`. Changes replace Lua-match predicates with JavaScript-match predicates and add flags, subcommands, launchers, assignment targets, globs and redirection captures. The complete license is in `licenses/nvim-treesitter.txt`.
10
+
11
+ The separately installed `web-tree-sitter` 0.27.1 runtime is MIT-licensed. There is no native compilation or install script for the bundled grammar.
@@ -0,0 +1,319 @@
1
+ ; Derived from nvim-treesitter's Bash query (Apache-2.0); see THIRD_PARTY_NOTICES.md.
2
+ [
3
+ "("
4
+ ")"
5
+ "{"
6
+ "}"
7
+ "["
8
+ "]"
9
+ "[["
10
+ "]]"
11
+ "(("
12
+ "))"
13
+ ] @punctuation.bracket
14
+
15
+ [
16
+ ";"
17
+ ";;"
18
+ ";&"
19
+ ";;&"
20
+ "&"
21
+ ] @punctuation.delimiter
22
+
23
+ [
24
+ ">"
25
+ ">>"
26
+ "<"
27
+ "<<"
28
+ "&&"
29
+ "|"
30
+ "|&"
31
+ "||"
32
+ "="
33
+ "+="
34
+ "=~"
35
+ "=="
36
+ "!="
37
+ "&>"
38
+ "&>>"
39
+ "<&"
40
+ ">&"
41
+ ">|"
42
+ "<&-"
43
+ ">&-"
44
+ "<<-"
45
+ "<<<"
46
+ ".."
47
+ "!"
48
+ ] @operator
49
+
50
+ ; Do *not* spell check strings since they typically have some sort of
51
+ ; interpolation in them, or, are typically used for things like filenames, URLs,
52
+ ; flags and file content.
53
+ [
54
+ (string)
55
+ (raw_string)
56
+ (ansi_c_string)
57
+ (heredoc_body)
58
+ ] @string
59
+
60
+ [
61
+ (heredoc_start)
62
+ (heredoc_end)
63
+ ] @label
64
+
65
+ (variable_assignment
66
+ (word) @string)
67
+
68
+ (command
69
+ argument: "$" @string) ; bare dollar
70
+
71
+ (concatenation
72
+ (word) @string)
73
+
74
+ [
75
+ "if"
76
+ "then"
77
+ "else"
78
+ "elif"
79
+ "fi"
80
+ "case"
81
+ "in"
82
+ "esac"
83
+ ] @keyword.conditional
84
+
85
+ [
86
+ "for"
87
+ "do"
88
+ "done"
89
+ "select"
90
+ "until"
91
+ "while"
92
+ ] @keyword.repeat
93
+
94
+ [
95
+ "declare"
96
+ "typeset"
97
+ "readonly"
98
+ "local"
99
+ "unset"
100
+ "unsetenv"
101
+ ] @keyword
102
+
103
+ "export" @keyword.import
104
+
105
+ "function" @keyword.function
106
+
107
+ (special_variable_name) @constant
108
+
109
+ (comment) @comment @spell
110
+
111
+ (test_operator) @operator
112
+
113
+ (command_substitution
114
+ "$(" @punctuation.special
115
+ ")" @punctuation.special)
116
+
117
+ (process_substitution
118
+ [
119
+ "<("
120
+ ">("
121
+ ] @punctuation.special
122
+ ")" @punctuation.special)
123
+
124
+ (arithmetic_expansion
125
+ [
126
+ "$(("
127
+ "(("
128
+ ] @punctuation.special
129
+ "))" @punctuation.special)
130
+
131
+ (arithmetic_expansion
132
+ "," @punctuation.delimiter)
133
+
134
+ (ternary_expression
135
+ [
136
+ "?"
137
+ ":"
138
+ ] @keyword.conditional.ternary)
139
+
140
+ (binary_expression
141
+ operator: _ @operator)
142
+
143
+ (unary_expression
144
+ operator: _ @operator)
145
+
146
+ (postfix_expression
147
+ operator: _ @operator)
148
+
149
+ (function_definition
150
+ name: (word) @function)
151
+
152
+ (command_name
153
+ (word) @function.call)
154
+
155
+ (command_name
156
+ (word) @function.builtin
157
+ (#any-of? @function.builtin
158
+ "." ":" "alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete"
159
+ "compopt" "continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "false" "fc"
160
+ "fg" "getopts" "hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf"
161
+ "pushd" "pwd" "read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time"
162
+ "times" "trap" "true" "type" "typeset" "ulimit" "umask" "unalias" "wait"))
163
+
164
+ (command
165
+ argument: [
166
+ (word) @variable.parameter
167
+ (concatenation
168
+ (word) @variable.parameter)
169
+ ])
170
+
171
+ ; help trap
172
+ (command
173
+ name: (command_name
174
+ (word) @_command)
175
+ argument: (word) @string.special
176
+ (#eq? @_command "trap")
177
+ (#any-of? @string.special "EXIT" "DEBUG" "RETURN" "ERR"))
178
+
179
+ ; trap -l
180
+ (command
181
+ name: (command_name
182
+ (word) @_command)
183
+ argument: (word) @string.special
184
+ (#any-of? @_command "trap" "kill")
185
+ (#any-of? @string.special
186
+ "SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1"
187
+ "SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP"
188
+ "SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH"
189
+ "SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4"
190
+ "SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11"
191
+ "SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13"
192
+ "SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6"
193
+ "SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX"))
194
+
195
+ (declaration_command
196
+ (word) @variable.parameter)
197
+
198
+ (unset_command
199
+ (word) @variable.parameter)
200
+
201
+ (number) @number
202
+
203
+ (file_redirect
204
+ (word) @string.special.path)
205
+
206
+ (herestring_redirect
207
+ (word) @string)
208
+
209
+ (file_descriptor) @operator
210
+
211
+ (simple_expansion
212
+ "$" @punctuation.special) @none
213
+
214
+ (expansion
215
+ "${" @punctuation.special
216
+ "}" @punctuation.special) @none
217
+
218
+ (expansion
219
+ operator: _ @punctuation.special)
220
+
221
+ (expansion
222
+ "@"
223
+ .
224
+ operator: _ @character.special)
225
+
226
+ ((expansion
227
+ (subscript
228
+ index: (word) @character.special))
229
+ (#any-of? @character.special "@" "*"))
230
+
231
+ "``" @punctuation.special
232
+
233
+ (variable_name) @variable
234
+
235
+ ((variable_name) @constant
236
+ (#match? @constant "^[A-Z][A-Z_0-9]*$"))
237
+
238
+ ((variable_name) @variable.builtin
239
+ (#any-of? @variable.builtin
240
+ ; https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Variables.html
241
+ "CDPATH" "HOME" "IFS" "MAIL" "MAILPATH" "OPTARG" "OPTIND" "PATH" "PS1" "PS2"
242
+ ; https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html
243
+ "_" "BASH" "BASHOPTS" "BASHPID" "BASH_ALIASES" "BASH_ARGC" "BASH_ARGV" "BASH_ARGV0" "BASH_CMDS"
244
+ "BASH_COMMAND" "BASH_COMPAT" "BASH_ENV" "BASH_EXECUTION_STRING" "BASH_LINENO"
245
+ "BASH_LOADABLES_PATH" "BASH_REMATCH" "BASH_SOURCE" "BASH_SUBSHELL" "BASH_VERSINFO"
246
+ "BASH_VERSION" "BASH_XTRACEFD" "CHILD_MAX" "COLUMNS" "COMP_CWORD" "COMP_LINE" "COMP_POINT"
247
+ "COMP_TYPE" "COMP_KEY" "COMP_WORDBREAKS" "COMP_WORDS" "COMPREPLY" "COPROC" "DIRSTACK" "EMACS"
248
+ "ENV" "EPOCHREALTIME" "EPOCHSECONDS" "EUID" "EXECIGNORE" "FCEDIT" "FIGNORE" "FUNCNAME"
249
+ "FUNCNEST" "GLOBIGNORE" "GROUPS" "histchars" "HISTCMD" "HISTCONTROL" "HISTFILE" "HISTFILESIZE"
250
+ "HISTIGNORE" "HISTSIZE" "HISTTIMEFORMAT" "HOSTFILE" "HOSTNAME" "HOSTTYPE" "IGNOREEOF" "INPUTRC"
251
+ "INSIDE_EMACS" "LANG" "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" "LC_NUMERIC" "LC_TIME"
252
+ "LINENO" "LINES" "MACHTYPE" "MAILCHECK" "MAPFILE" "OLDPWD" "OPTERR" "OSTYPE" "PIPESTATUS"
253
+ "POSIXLY_CORRECT" "PPID" "PROMPT_COMMAND" "PROMPT_DIRTRIM" "PS0" "PS3" "PS4" "PWD" "RANDOM"
254
+ "READLINE_ARGUMENT" "READLINE_LINE" "READLINE_MARK" "READLINE_POINT" "REPLY" "SECONDS" "SHELL"
255
+ "SHELLOPTS" "SHLVL" "SRANDOM" "TIMEFORMAT" "TMOUT" "TMPDIR" "UID"))
256
+
257
+ ((command
258
+ name: (command_name
259
+ (word) @_printf)
260
+ .
261
+ argument: (word) @_v
262
+ .
263
+ argument: (word) @variable)
264
+ (#eq? @_printf "printf")
265
+ (#eq? @_v "-v")
266
+ (#match? @variable "^[a-zA-Z_][a-zA-Z0-9_]*$"))
267
+
268
+ (case_item
269
+ value: (word) @variable.parameter)
270
+
271
+ [
272
+ (regex)
273
+ (extglob_pattern)
274
+ ] @string.regexp
275
+
276
+ ((program
277
+ .
278
+ (comment) @keyword.directive @nospell)
279
+ (#match? @keyword.directive "^#![ \t]*/"))
280
+
281
+ ; Appended to nvim-treesitter's bash highlights.scm. Later patterns win on equal ranges.
282
+
283
+ ; Flags: `-n`, `--session`, `--format=...` (the flag head of a concatenation), and `--`.
284
+ (command argument: (word) @option (#match? @option "^-"))
285
+ (command argument: (concatenation . (word) @option (#match? @option "^-")))
286
+ (command argument: (number) @option (#match? @option "^-"))
287
+
288
+ ; Unquoted globs.
289
+ ((word) @glob (#match? @glob "[*?]"))
290
+
291
+ ; F-Sy-H's generic subcommand rule for verb-first tools: the first operand, when no option precedes it.
292
+ (command
293
+ name: (command_name (word) @_tool)
294
+ .
295
+ argument: (word) @subcommand
296
+ (#any-of? @_tool "git" "gh" "docker" "kubectl" "cargo" "uv" "npm" "pnpm" "yarn" "bun" "brew" "go" "terraform" "systemctl" "herdr" "gcloud" "aws" "pip" "apt" "memo" "agent-browser")
297
+ (#match? @subcommand "^[a-z][a-z0-9-]*$"))
298
+
299
+ ; Assignment targets read as names, not values.
300
+ (variable_assignment name: (variable_name) @assign)
301
+
302
+ ; Redirections are one category: operator, descriptor and `&1`-style targets.
303
+ (file_redirect [">" ">>" "<" "&>" "&>>" ">&" "<&" ">|" "<&-" ">&-"] @redirect)
304
+ (file_redirect descriptor: (file_descriptor) @redirect)
305
+ (file_redirect destination: (number) @redirect)
306
+ (heredoc_redirect ["<<" "<<-"] @redirect)
307
+ (herestring_redirect "<<<" @redirect)
308
+
309
+ ; Heredoc bodies are data, not Bash. Expansions inside unquoted bodies keep their own captures.
310
+ (heredoc_body) @heredoc
311
+
312
+ ; F-Sy-H's precommand rule: the first operand of a launcher is the launched command,
313
+ ; but only when no option precedes it (an option might consume the next word).
314
+ (command
315
+ name: (command_name (word) @_launcher)
316
+ .
317
+ argument: (word) @function.call
318
+ (#any-of? @_launcher "sudo" "nohup" "exec" "command" "builtin" "time" "nice" "xargs" "env" "doas")
319
+ (#not-match? @function.call "^-|="))
Binary file
@@ -0,0 +1,16 @@
1
+ export type BashTheme = {
2
+ fg(color: "syntaxFunction" | "syntaxKeyword" | "syntaxType" | "syntaxString" | "syntaxVariable" | "syntaxOperator" | "syntaxComment" | "syntaxNumber" | "syntaxPunctuation", text: string): string;
3
+ bold(text: string): string;
4
+ italic(text: string): string;
5
+ };
6
+
7
+ export type BashHighlighter = {
8
+ highlight(source: string, theme: BashTheme): string;
9
+ dispose(): void;
10
+ };
11
+
12
+ export type HighlightCode = (source: string, language: string) => string[];
13
+
14
+ export const MAX_SOURCE_LENGTH: number;
15
+
16
+ export function createBashHighlighter(highlightCode: HighlightCode): Promise<BashHighlighter>;
@@ -0,0 +1,194 @@
1
+ // @ts-check
2
+ import { readFileSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ import { Language, Parser, Query } from "web-tree-sitter";
5
+
6
+ /** @typedef {import('./highlighting.d.ts').BashTheme} Theme */
7
+ /** @typedef {import('./highlighting.d.ts').BashHighlighter} BashHighlighter */
8
+ /** @typedef {import('./highlighting.d.ts').HighlightCode} HighlightCode */
9
+ /** @typedef {{start: number, end: number, pattern: number, style: number}} Span */
10
+
11
+ // Cooperative work limits, not a wall-clock deadline. Past the source or work limit the source is returned uncolored;
12
+ // labelled heredoc bodies past the embedded limit keep their Bash string colors.
13
+ export const MAX_SOURCE_LENGTH = 16_384;
14
+ const MAX_WORK_CHECKS = 256;
15
+ const MAX_EMBEDDED_LENGTH = 4096;
16
+
17
+ // A quoted heredoc delimiter declares its body's language, like a Markdown fence; the command is never consulted.
18
+ /** @type {ReadonlyMap<string, string>} */
19
+ const HEREDOC_LANGUAGES = new Map([
20
+ ['PY', 'python'], ['PYTHON', 'python'], ['PYEOF', 'python'],
21
+ ['JS', 'javascript'], ['JAVASCRIPT', 'javascript'], ['NODE', 'javascript'], ['JXA', 'javascript'],
22
+ ['TS', 'typescript'], ['JSON', 'json'], ['PATCH', 'diff'], ['DIFF', 'diff'], ['RUBY', 'ruby'],
23
+ ]);
24
+
25
+ /** @type {Record<string, number>} */
26
+ const CAPTURE_STYLES = {
27
+ function: 1, subcommand: 2, keyword: 3, label: 3, option: 4,
28
+ string: 5, heredoc: 5, variable: 6, constant: 6, assign: 6,
29
+ operator: 7, redirect: 7, comment: 8, number: 9, glob: 9,
30
+ 'variable.parameter': 0, 'string.special': 0, 'string.special.path': 0,
31
+ 'punctuation.bracket': 10, 'punctuation.delimiter': 7,
32
+ 'punctuation.special': 6, 'character.special': 6, 'keyword.directive': 8,
33
+ none: 0,
34
+ };
35
+ /** @type {ReadonlyArray<{color: Parameters<Theme['fg']>[0], bold?: boolean, italic?: boolean} | null>} */
36
+ const STYLES = [
37
+ null, { color: 'syntaxFunction', bold: true }, { color: 'syntaxFunction' },
38
+ { color: 'syntaxKeyword' }, { color: 'syntaxType' }, { color: 'syntaxString' },
39
+ { color: 'syntaxVariable' }, { color: 'syntaxOperator', bold: true },
40
+ { color: 'syntaxComment', italic: true }, { color: 'syntaxNumber' },
41
+ { color: 'syntaxPunctuation' },
42
+ ];
43
+
44
+ // WASM grammars cannot be unloaded, and Pi re-evaluates extension modules on every /reload.
45
+ // One grammar per web-tree-sitter runtime (keyed by its Language class) keeps reloads from leaking.
46
+ /** @type {WeakMap<typeof Language, Promise<Language>>} */
47
+ const grammars = /** @type {Record<symbol, WeakMap<typeof Language, Promise<Language>> | undefined>} */ (/** @type {unknown} */ (globalThis))[Symbol.for('pi-pretty-bash.grammars')] ??= new WeakMap();
48
+
49
+ /** Load the Bash grammar once per web-tree-sitter runtime.
50
+ * @returns {Promise<Language>}
51
+ * @example await loadGrammar() === await loadGrammar()
52
+ */
53
+ function loadGrammar() {
54
+ const cached = grammars.get(Language) ?? Parser.init().then(() => Language.load(fileURLToPath(new URL('./assets/tree-sitter-bash.wasm', import.meta.url))));
55
+ grammars.set(Language, cached);
56
+ return cached;
57
+ }
58
+
59
+ /** Read an explicitly quoted language label.
60
+ * @param {string} delimiter
61
+ * @returns {string | undefined}
62
+ * @example heredocLabel("'PY'") === 'PY'
63
+ */
64
+ function heredocLabel(delimiter) {
65
+ return /^(['"])([A-Z]+)\1$/.exec(delimiter)?.[2];
66
+ }
67
+
68
+ /** Whether a line ends a heredoc: Bash requires the whole line to be the delimiter; `<<-` first strips leading tabs, never spaces.
69
+ * @param {string} line
70
+ * @param {string} delimiter
71
+ * @param {boolean} stripsTabs
72
+ * @returns {boolean}
73
+ * @example isTerminator('\tPY', 'PY', true) === true && isTerminator(' PY', 'PY', true) === false && isTerminator('\tPY', 'PY', false) === false
74
+ */
75
+ function isTerminator(line, delimiter, stripsTabs) {
76
+ return (stripsTabs ? line.replace(/^\t+/, '') : line) === delimiter;
77
+ }
78
+
79
+ /** Map a query capture to a style index; unknown authored captures fail at startup.
80
+ * @param {string} name
81
+ * @returns {number | undefined}
82
+ * @example captureStyle('variable.parameter') === 0
83
+ */
84
+ function captureStyle(name) {
85
+ if (name.startsWith('_') || name === 'spell' || name === 'nospell') return undefined;
86
+ const style = CAPTURE_STYLES[name] ?? CAPTURE_STYLES[name.split('.')[0]];
87
+ if (style === undefined) throw new Error(`Unknown Bash highlight capture: ${name}`);
88
+ return style;
89
+ }
90
+
91
+ /** Paint runs of equal style without changing visible text or carrying styles across lines.
92
+ * @param {string} source
93
+ * @param {Uint8Array} owners
94
+ * @param {Theme} theme
95
+ * @returns {string}
96
+ * @example paint('echo', new Uint8Array(4), theme) === 'echo'
97
+ */
98
+ function paint(source, owners, theme) {
99
+ let output = '';
100
+ for (let start = 0; start < source.length;) {
101
+ let end = start + 1;
102
+ while (end < source.length && owners[end] === owners[start] && source[end] !== '\n' && source[start] !== '\n') end++;
103
+ const text = source.slice(start, end);
104
+ const style = STYLES[owners[start]];
105
+ const colored = style && text !== '\n' ? theme.fg(style.color, text) : text;
106
+ output += style?.bold ? theme.bold(colored) : style?.italic ? theme.italic(colored) : colored;
107
+ start = end;
108
+ }
109
+ return output;
110
+ }
111
+
112
+ /** Initialize a synchronous, theme-aware Bash highlighter. Callers supply already-sanitized display text
113
+ * and the host's code highlighter for labelled heredoc bodies, so no second Pi runtime is imported.
114
+ * @param {HighlightCode} highlightCode
115
+ * @returns {Promise<BashHighlighter>}
116
+ * @example const highlighter = await createBashHighlighter(highlightCode); highlighter.highlight('git status', theme);
117
+ */
118
+ export async function createBashHighlighter(highlightCode) {
119
+ const language = await loadGrammar();
120
+ const query = new Query(language, readFileSync(new URL('./assets/bash.scm', import.meta.url), 'utf8'));
121
+ const captureStyles = new Map(query.captureNames.map(name => [name, captureStyle(name)]));
122
+ const parser = new Parser().setLanguage(language);
123
+ let disposed = false;
124
+ return {
125
+ highlight(source, theme) {
126
+ if (disposed || source.length > MAX_SOURCE_LENGTH) return source;
127
+ let remaining = MAX_WORK_CHECKS;
128
+ const options = { progressCallback: () => --remaining <= 0 };
129
+ // Only the tree uses the parsed text; painting reads the original source at the same offsets.
130
+ let text = source;
131
+ let closed = false;
132
+ let tree = parser.parse(text, null, options);
133
+ try {
134
+ for (;;) {
135
+ if (!tree) return source;
136
+ // tree-sitter-bash ends a heredoc at any line that starts with its delimiter, even indented (JSON under 'JS', ' PY');
137
+ // a terminator must be the whole line, so mask the false one, same length, and parse again.
138
+ const falseEnd = tree.rootNode.descendantsOfType('heredoc_end').find(node => {
139
+ const lineEnd = text.indexOf('\n', node.endIndex);
140
+ const line = text.slice(text.lastIndexOf('\n', node.startIndex - 1) + 1, lineEnd < 0 ? text.length : lineEnd);
141
+ return !isTerminator(line, node.text, node.parent?.children.some(child => child?.type === '<<-') ?? false);
142
+ });
143
+ // A streaming heredoc has no terminator yet; close it synthetically so its body parses as it will when complete.
144
+ const open = closed ? undefined : tree.rootNode.descendantsOfType('heredoc_start').find(node => node.parent?.type !== 'heredoc_redirect');
145
+ const openLabel = open && heredocLabel(open.text);
146
+ if (!falseEnd && !(openLabel && HEREDOC_LANGUAGES.has(openLabel))) break;
147
+ const masked = falseEnd && falseEnd.endIndex - falseEnd.text.trimStart().length;
148
+ text = masked === undefined ? `${text}\n${openLabel}\n` : `${text.slice(0, masked)}\x7f${text.slice(masked + 1)}`;
149
+ closed ||= masked === undefined;
150
+ tree.delete();
151
+ tree = parser.parse(text, null, options);
152
+ }
153
+ const captures = query.captures(tree.rootNode, options);
154
+ if (remaining <= 0) return source;
155
+ /** @type {Span[]} */
156
+ const spans = [];
157
+ for (const capture of captures) {
158
+ const style = captureStyles.get(capture.name);
159
+ if (style === undefined) continue;
160
+ spans.push({ start: capture.node.startIndex, end: capture.node.endIndex, pattern: capture.patternIndex, style });
161
+ }
162
+ spans.sort((left, right) => (right.end - right.start) - (left.end - left.start) || left.pattern - right.pattern);
163
+ const owners = new Uint8Array(source.length);
164
+ for (const span of spans) owners.fill(span.style, span.start, span.end);
165
+ let output = '';
166
+ let position = 0;
167
+ let embeddedLength = 0;
168
+ for (const redirect of tree.rootNode.descendantsOfType('heredoc_redirect')) {
169
+ const start = redirect.namedChildren.find(node => node?.type === 'heredoc_start');
170
+ const body = redirect.namedChildren.find(node => node?.type === 'heredoc_body');
171
+ const label = start && heredocLabel(start.text);
172
+ const language = label && HEREDOC_LANGUAGES.get(label);
173
+ if (!body || !language || body.startIndex < position || body.startIndex >= source.length) continue;
174
+ const end = Math.min(body.endIndex, source.length);
175
+ if (embeddedLength + end - body.startIndex > MAX_EMBEDDED_LENGTH) continue;
176
+ embeddedLength += end - body.startIndex;
177
+ output += paint(source.slice(position, body.startIndex), owners.subarray(position, body.startIndex), theme);
178
+ output += highlightCode(source.slice(body.startIndex, end), language).join('\n');
179
+ position = end;
180
+ }
181
+ return output + paint(source.slice(position), owners.subarray(position), theme);
182
+ } finally {
183
+ tree?.delete();
184
+ parser.reset();
185
+ }
186
+ },
187
+ dispose() {
188
+ if (disposed) return;
189
+ disposed = true;
190
+ query.delete();
191
+ parser.delete();
192
+ },
193
+ };
194
+ }
package/index.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  type ToolRenderers,
10
10
  } from "@earendil-works/pi-coding-agent";
11
11
  import { truncateToWidth, visibleWidth, wrapTextWithAnsi, type Component } from "@earendil-works/pi-tui";
12
- import { highlight } from "cli-highlight";
12
+ import { createBashHighlighter, MAX_SOURCE_LENGTH, type BashHighlighter } from "./highlighting.js";
13
13
  import { createFromBuffer } from "@dprint/formatter";
14
14
  import { getBuffer } from "@dprint/shfmt";
15
15
 
@@ -19,8 +19,6 @@ formatter.setConfig({}, { dialect: "bash", useTabs: false, indentWidth: 2, binar
19
19
  const JSON_HIGHLIGHT_MAX_BYTES = 200 * 1024;
20
20
  const PREVIEW_ROWS = 10;
21
21
  const RESET = "\x1b[0m";
22
- const BLACK_BACKGROUND = "\x1b[48;5;16m";
23
- const SURFACE_TEXT = "\x1b[38;5;252m";
24
22
 
25
23
  type BashArguments = { command?: string; timeout?: number };
26
24
  type Result = Parameters<NonNullable<ToolRenderers["renderResult"]>>[0];
@@ -32,11 +30,9 @@ class BashDisplay implements Component {
32
30
  private width?: number;
33
31
  private lines?: string[];
34
32
  private draw: (width: number) => string[];
35
- private background: boolean;
36
33
 
37
- constructor(draw: (width: number) => string[], background = false) {
34
+ constructor(draw: (width: number) => string[]) {
38
35
  this.draw = draw;
39
- this.background = background;
40
36
  }
41
37
 
42
38
  invalidate(): void {
@@ -46,37 +42,11 @@ class BashDisplay implements Component {
46
42
  render(width: number): string[] {
47
43
  if (this.lines && this.width === width) return this.lines;
48
44
  this.width = width;
49
- this.lines = this.draw(Math.max(1, width - 1)).map(line => this.background ? blackBackground(line, width) : truncateToWidth(line, width));
45
+ this.lines = this.draw(Math.max(1, width - 1)).map(line => truncateToWidth(line, width));
50
46
  return this.lines;
51
47
  }
52
48
  }
53
49
 
54
- /** Fill a terminal row with black, restoring its surface colors after nested styling resets.
55
- * @example stripVTControlCharacters(blackBackground("git status", 12)) // "git status "
56
- */
57
- function blackBackground(line: string, width: number): string {
58
- const padded = truncateToWidth(line, width, "...", true);
59
- const styled = padded.replace(/\x1b\[(?:0)?m/g, `$&${SURFACE_TEXT}${BLACK_BACKGROUND}`)
60
- .replace(/\x1b\[(?:22;)?39m/g, `$&${SURFACE_TEXT}`).replaceAll("\x1b[49m", BLACK_BACKGROUND);
61
- return `${SURFACE_TEXT}${BLACK_BACKGROUND}${styled}${RESET}`;
62
- }
63
-
64
- /** Apply the old Bash token palette without its hand-written HTML parser.
65
- * @example bashColors('echo "$HOME"', theme) // Built-ins use syntaxFunction; variables use syntaxVariable.
66
- */
67
- function bashColors(command: string, theme: Theme): string {
68
- const colors = {
69
- attr: "syntaxVariable", built_in: "syntaxFunction", comment: "syntaxComment",
70
- function: "syntaxFunction", keyword: "syntaxKeyword", literal: "syntaxNumber",
71
- meta: "muted", number: "syntaxNumber", operator: "syntaxOperator",
72
- params: "syntaxVariable", property: "syntaxVariable", punctuation: "syntaxPunctuation",
73
- string: "syntaxString", subst: "syntaxOperator", symbol: "syntaxVariable",
74
- title: "syntaxFunction", type: "syntaxType", variable: "syntaxVariable",
75
- } as const;
76
- const formatters = Object.fromEntries(Object.entries(colors).map(([scope, token]) => [scope, (text: string) => theme.fg(token, text)]));
77
- return highlight(command, { language: "bash", ignoreIllegals: true, theme: { ...formatters, default: (text: string) => text } });
78
- }
79
-
80
50
  /** Name the command after environment assignments and common launch prefixes.
81
51
  * @example commandName('MODE=test env bash script.sh') // "bash"
82
52
  */
@@ -128,14 +98,17 @@ function formatCommand(command: string): string {
128
98
  }
129
99
 
130
100
  /** Draw the command, using a numbered box for multiline formatted input; collapsed boxes hide their middle rows.
131
- * @example commandRows({command: "echo hi"}, theme, false, false).render(80) // A syntax-colored Bash header.
101
+ * @example commandRows({command: "echo hi"}, theme, false, false, highlighter.highlight).render(80) // A syntax-colored Bash header.
132
102
  */
133
- function commandRows(args: BashArguments, theme: Theme, pending: boolean, expanded: boolean): Component {
134
- const command = displayText(formatCommand(args.command ?? ""));
103
+ function commandRows(args: BashArguments, theme: Theme, pending: boolean, expanded: boolean, highlightBash: BashHighlighter["highlight"]): Component {
104
+ // The highlighter sees tabs, because only leading tabs may precede a <<- terminator;
105
+ // the size cutoff still measures the displayed text.
106
+ const source = sanitizedText(formatCommand(args.command ?? ""));
107
+ const command = expandTabs(source);
135
108
  const sourceLines = command.split("\n");
136
- const highlighted = bashColors(command, theme).split("\n");
109
+ const highlighted = (command.length > MAX_SOURCE_LENGTH ? command : expandTabs(highlightBash(source, theme))).split("\n");
137
110
  const firstLine = sourceLines[0].trim() || "…";
138
- const firstLineColored = bashColors(firstLine, theme);
111
+ const firstLineColored = highlightBash(firstLine, theme);
139
112
  const prefix = `${theme.fg(pending ? "warning" : "accent", "● ")}${theme.bold("Bash ")}`;
140
113
  const facts = commandFacts(command, args.timeout);
141
114
  const suffix = facts.length ? theme.fg("dim", ` · ${facts.join(" · ")}`) : "";
@@ -158,14 +131,26 @@ function commandRows(args: BashArguments, theme: Theme, pending: boolean, expand
158
131
  if (expanded || rows.length <= PREVIEW_ROWS) return [header, ...box(rows, width, theme)];
159
132
  const hint = wrapTextWithAnsi(`${theme.fg("muted", `… ${rows.length - PREVIEW_ROWS} more lines · `)}${keyHint("app.tools.expand", "to expand")}`, Math.max(1, width - 4));
160
133
  return [header, ...box([...rows.slice(0, PREVIEW_ROWS / 2), ...hint, ...rows.slice(-PREVIEW_ROWS / 2)], width, theme)];
161
- }, true);
134
+ });
162
135
  }
163
136
 
164
137
  /** Remove untrusted terminal instructions before applying renderer-owned styling.
165
138
  * @example displayText('\x1b[31mhello\x1b[0m\x07') // "hello"
166
139
  */
167
140
  function displayText(text: string): string {
168
- return stripVTControlCharacters(text).replace(/\r\n|\r/g, "\n").replace(/\t/g, " ").replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
141
+ return expandTabs(sanitizedText(text));
142
+ }
143
+
144
+ /** Remove untrusted terminal instructions, keeping tabs.
145
+ * @example sanitizedText('\x1b[31m\tok\x07') // "\tok"
146
+ */
147
+ function sanitizedText(text: string): string {
148
+ return stripVTControlCharacters(text).replace(/\r\n|\r/g, "\n").replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, "");
149
+ }
150
+
151
+ /** @example expandTabs('\tok') // " ok" */
152
+ function expandTabs(text: string): string {
153
+ return text.replace(/\t/g, " ");
169
154
  }
170
155
 
171
156
  /** Interpret Pi's error footer only when Pi marks the call as failed.
@@ -201,7 +186,8 @@ function isJson(output: string): boolean {
201
186
  }
202
187
  }
203
188
 
204
- export default function prettyBash(pi: ExtensionAPI): void {
189
+ export default async function prettyBash(pi: ExtensionAPI): Promise<void> {
190
+ const highlighter = await createBashHighlighter(highlightCode);
205
191
  const active = new Set<RenderState>();
206
192
  const finish = (state: RenderState): void => {
207
193
  if (state.timer) clearInterval(state.timer);
@@ -211,7 +197,7 @@ export default function prettyBash(pi: ExtensionAPI): void {
211
197
  };
212
198
  const stopTimers = (): void => { for (const state of active) finish(state); };
213
199
  pi.on("agent_end", stopTimers);
214
- pi.on("session_shutdown", stopTimers);
200
+ pi.on("session_shutdown", () => { stopTimers(); highlighter.dispose(); });
215
201
 
216
202
  const renderers: ToolRenderers = {
217
203
  renderShell: "self",
@@ -224,7 +210,7 @@ export default function prettyBash(pi: ExtensionAPI): void {
224
210
  active.add(state);
225
211
  }
226
212
  if (!context.isPartial) finish(state);
227
- return commandRows((args ?? {}) as BashArguments, theme, context.executionStarted && context.isPartial && state.endedAt === undefined, context.expanded);
213
+ return commandRows((args ?? {}) as BashArguments, theme, context.executionStarted && context.isPartial && state.endedAt === undefined, context.expanded, highlighter.highlight);
228
214
  },
229
215
  renderResult(result: Result, options, theme: Theme, context: Context) {
230
216
  const output = result.content.filter(part => part.type === "text").map(part => part.text).join("\n");
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Max Brunsfeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giladbarnea/pi-pretty-bash",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "description": "Rich Bash command and result displays with syntax-colored commands and JSON output.",
6
6
  "keywords": [
@@ -23,6 +23,11 @@
23
23
  },
24
24
  "files": [
25
25
  "index.ts",
26
+ "highlighting.js",
27
+ "highlighting.d.ts",
28
+ "assets/",
29
+ "licenses/",
30
+ "THIRD_PARTY_NOTICES.md",
26
31
  "README.md",
27
32
  "LICENSE",
28
33
  "screenshots/1.png"
@@ -48,6 +53,6 @@
48
53
  "dependencies": {
49
54
  "@dprint/formatter": "0.6.0",
50
55
  "@dprint/shfmt": "0.2.0",
51
- "cli-highlight": "2.1.11"
56
+ "web-tree-sitter": "0.27.1"
52
57
  }
53
58
  }