1ls 0.0.2 → 0.0.3

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,6 +1,6 @@
1
1
  # 1ls - One Line Script
2
2
 
3
- A 0 dependency, lightweight, fast data processor with family JavaScript syntax.
3
+ A 0 dependency, lightweight, fast data processor with familiar JavaScript syntax.
4
4
 
5
5
  ## Why 1ls?
6
6
 
@@ -14,12 +14,12 @@ A 0 dependency, lightweight, fast data processor with family JavaScript syntax.
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- # Using Bun
18
- bun install -g 1ls
19
-
20
- # Using npm
17
+ # Using npm (or bun)
21
18
  npm install -g 1ls
22
19
 
20
+ # Using Homebrew (macOS/Linux)
21
+ brew install yowainwright/tap/1ls
22
+
23
23
  # Using curl
24
24
  curl -fsSL https://raw.githubusercontent.com/yowainwright/1ls/main/install.sh | bash
25
25
  ```
@@ -42,10 +42,94 @@ echo '[1, 2, 3]' | 1ls '.map(x => x * 2)'
42
42
  # Chain operations
43
43
  echo '[{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]' | 1ls '.filter(x => x.age > 26).map(x => x.name)'
44
44
  # Output: ["Alice"]
45
+
46
+ # Interactive mode - explore JSON with fuzzy search
47
+ 1ls readFile data.json
48
+ # Opens interactive explorer with fuzzy search, arrow key navigation, and live preview
45
49
  ```
46
50
 
47
51
  ## Examples
48
52
 
53
+ ### Interactive Mode
54
+
55
+ Explore JSON interactively with fuzzy search and build expressions with method discovery:
56
+
57
+ ```bash
58
+ # Open interactive explorer from a file (automatic when no expression)
59
+ 1ls readFile data.json
60
+
61
+ # Works with all supported formats
62
+ 1ls readFile config.yaml
63
+ 1ls readFile config.toml
64
+
65
+ # For remote data, save to a file first
66
+ curl https://api.github.com/users/github > /tmp/user.json
67
+ 1ls readFile /tmp/user.json
68
+
69
+ # Or use an expression directly (non-interactive)
70
+ 1ls readFile data.json '.users.filter(x => x.active)'
71
+ ```
72
+
73
+ #### Mode 1: Path Explorer
74
+
75
+ Navigate and search JSON paths:
76
+
77
+ - **Fuzzy search**: Type to filter paths (e.g., "user.name" matches `.users[0].name`, `.user.username`, etc.)
78
+ - **Live preview**: See values as you navigate
79
+ - **Type information**: Shows String, Number, Array, Object, Boolean, or null
80
+ - **↑/↓**: Navigate, **Enter**: Select, **Tab**: Build expression, **Esc/q**: Quit
81
+
82
+ #### Mode 2: Expression Builder
83
+
84
+ Build complex expressions with guided method selection:
85
+
86
+ **Workflow:**
87
+ 1. Navigate to a path in Explorer mode → Press **Tab**
88
+ 2. Type to fuzzy search methods → **→** to accept
89
+ 3. Type to fuzzy search properties → **→** to complete
90
+ 4. Repeat to chain methods
91
+ 5. Press **Enter** to execute
92
+
93
+ **Example Session:**
94
+ ```
95
+ 1. Navigate to .users (Array) → Tab
96
+ 2. Type "fil" → → (accepts .filter(x => ...))
97
+ 3. Type "act" → → (completes with x.active, back to method selection)
98
+ 4. Type "map" → → (accepts .map(x => ...))
99
+ 5. Type "name" → → (completes with x.name)
100
+ 6. Enter → executes: .users.filter(x => x.active).map(x => x.name)
101
+ ```
102
+
103
+ **Undo mistakes:**
104
+ - Press **←** at any time to undo the last segment
105
+ - Example: `.users.filter(x => x.active).map(x => x.name)` → **←** → `.users.filter(x => x.active)`
106
+
107
+ **Available Methods by Type:**
108
+
109
+ **Array**: map, filter, reduce, find, findIndex, some, every, sort, reverse, slice, concat, join, flat, flatMap, length
110
+
111
+ **String**: toUpperCase, toLowerCase, trim, trimStart, trimEnd, split, replace, replaceAll, substring, slice, startsWith, endsWith, includes, match, length
112
+
113
+ **Object**: {keys}, {values}, {entries}, {length}
114
+
115
+ **Number**: toFixed, toString
116
+
117
+ **Keyboard Shortcuts:**
118
+ - **↑/↓**: Navigate methods/properties
119
+ - **→ or Tab**: Accept/complete method or property (autocomplete-style)
120
+ - **←**: Undo last segment (remove to previous dot)
121
+ - **Enter**: Execute expression
122
+ - **Type**: Fuzzy search methods/properties
123
+ - **Esc**: Go back to Explorer / Quit
124
+ - **q**: Quit (from Explorer)
125
+
126
+ **Use cases:**
127
+ - Exploring unfamiliar API responses
128
+ - Building filter/map chains interactively
129
+ - Discovering available methods for each type
130
+ - Learning JavaScript array/string methods
131
+ - Prototyping complex data transformations
132
+
49
133
  ### Working with JSON
50
134
 
51
135
  ```bash
@@ -180,6 +264,7 @@ echo '["a", "b"]' | 1ls '.jn(",")' # Short for .join()
180
264
  |--------|-------|-------------|
181
265
  | `--help` | `-h` | Show help |
182
266
  | `--version` | `-v` | Show version |
267
+ | `--interactive` | | Interactive fuzzy search explorer |
183
268
  | `--raw` | `-r` | Output raw strings, not JSON |
184
269
  | `--pretty` | `-p` | Pretty print output |
185
270
  | `--compact` | `-c` | Compact output |
@@ -317,6 +402,26 @@ done
317
402
  - Efficient streaming for large files
318
403
  - Native binary compilation
319
404
 
405
+ ## Development
406
+
407
+ ```bash
408
+ # Clone the repository
409
+ git clone https://github.com/yowainwright/1ls.git
410
+ cd 1ls
411
+
412
+ # Install dependencies
413
+ bun install
414
+
415
+ # Run tests
416
+ bun test
417
+
418
+ # Build
419
+ bun run build
420
+
421
+ # Build binaries
422
+ bun run build:binary:all
423
+ ```
424
+
320
425
  ## Contributing
321
426
 
322
427
  Contributions are welcome! Please check out the [Contributing Guide](CONTRIBUTING.md).
@@ -332,10 +437,11 @@ MIT © Jeff Wainwright
332
437
  | Syntax | JavaScript | DSL | JavaScript |
333
438
  | Performance | ⚡ Fast (Bun) | ⚡ Fast | 🚀 Good |
334
439
  | Learning Curve | Easy | Steep | Easy |
335
- | Multi-format | | | |
336
- | Shortcuts | | | |
337
- | Arrow Functions | | | |
338
- | File Operations | | | |
440
+ | Multi-format | | x | x |
441
+ | Interactive Mode | | x | |
442
+ | Shortcuts | | x | x |
443
+ | Arrow Functions | | x | |
444
+ | File Operations | ✓ | x | x |
339
445
 
340
446
  ## Troubleshooting
341
447
 
@@ -0,0 +1,63 @@
1
+ #!/bin/bash
2
+ # Bash completion for 1ls
3
+
4
+ _1ls_complete() {
5
+ local cur prev opts
6
+ COMPREPLY=()
7
+ cur="${COMP_WORDS[COMP_CWORD]}"
8
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
9
+
10
+ # Main options
11
+ opts="--help --version --raw --pretty --compact --type --format --list --grep --find --recursive --ignore-case --line-numbers --ext --max-depth --shortcuts --shorten --expand readFile"
12
+
13
+ # Format options
14
+ format_opts="json yaml csv table"
15
+
16
+ # Common JSON path starters
17
+ json_paths=". .[] .{keys} .{values} .{entries}"
18
+
19
+ # Common shorthand methods
20
+ shortcuts=".mp .flt .rd .fnd .sm .evr .srt .rvs .jn .kys .vls .ents .lc .uc .trm"
21
+
22
+ case "${prev}" in
23
+ --format)
24
+ COMPREPLY=( $(compgen -W "${format_opts}" -- ${cur}) )
25
+ return 0
26
+ ;;
27
+ --list|--find|readFile)
28
+ # File/directory completion
29
+ COMPREPLY=( $(compgen -f -- ${cur}) )
30
+ return 0
31
+ ;;
32
+ --ext)
33
+ # Common extensions
34
+ COMPREPLY=( $(compgen -W "js ts tsx jsx json md txt yml yaml xml html css" -- ${cur}) )
35
+ return 0
36
+ ;;
37
+ --shorten|--expand)
38
+ # JSON expressions
39
+ COMPREPLY=( $(compgen -W "${json_paths}" -- ${cur}) )
40
+ return 0
41
+ ;;
42
+ *)
43
+ ;;
44
+ esac
45
+
46
+ # If current word starts with -, show options
47
+ if [[ ${cur} == -* ]]; then
48
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
49
+ return 0
50
+ fi
51
+
52
+ # If current word starts with ., suggest JSON paths and shortcuts
53
+ if [[ ${cur} == .* ]]; then
54
+ all_paths="${json_paths} ${shortcuts}"
55
+ COMPREPLY=( $(compgen -W "${all_paths}" -- ${cur}) )
56
+ return 0
57
+ fi
58
+
59
+ # Default to options
60
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
61
+ }
62
+
63
+ complete -F _1ls_complete 1ls
@@ -0,0 +1,79 @@
1
+ #compdef 1ls
2
+ # Zsh completion for 1ls
3
+
4
+ _1ls() {
5
+ local -a opts format_opts shortcuts json_paths
6
+
7
+ # Main options
8
+ opts=(
9
+ '--help[Show help]'
10
+ '--version[Show version]'
11
+ '--raw[Raw output (no formatting)]'
12
+ '--pretty[Pretty print JSON]'
13
+ '--compact[Compact JSON]'
14
+ '--type[Show value type info]'
15
+ '--format[Output format]:format:(json yaml csv table)'
16
+ '--list[List files in directory]:directory:_files -/'
17
+ '--grep[Search for pattern]:pattern:'
18
+ '--find[Path to search in]:path:_files'
19
+ '--recursive[Recursive search]'
20
+ '--ignore-case[Case insensitive search]'
21
+ '--line-numbers[Show line numbers]'
22
+ '--ext[Filter by extensions]:extensions:'
23
+ '--max-depth[Maximum recursion depth]:depth:'
24
+ '--shortcuts[Show all available shortcuts]'
25
+ '--shorten[Convert expression to shorthand]:expression:'
26
+ '--expand[Convert shorthand to full form]:expression:'
27
+ 'readFile[Read from file]:file:_files'
28
+ )
29
+
30
+ # Common shorthand methods
31
+ shortcuts=(
32
+ '.mp:map - Transform each element'
33
+ '.flt:filter - Filter elements'
34
+ '.rd:reduce - Reduce to single value'
35
+ '.fnd:find - Find first match'
36
+ '.sm:some - Test if any match'
37
+ '.evr:every - Test if all match'
38
+ '.srt:sort - Sort elements'
39
+ '.rvs:reverse - Reverse order'
40
+ '.jn:join - Join to string'
41
+ '.kys:keys - Get object keys'
42
+ '.vls:values - Get object values'
43
+ '.ents:entries - Get object entries'
44
+ '.lc:toLowerCase - Convert to lowercase'
45
+ '.uc:toUpperCase - Convert to uppercase'
46
+ '.trm:trim - Remove whitespace'
47
+ )
48
+
49
+ # JSON path examples
50
+ json_paths=(
51
+ '.:Root object'
52
+ '.[]:All array elements'
53
+ '.{keys}:Object keys'
54
+ '.{values}:Object values'
55
+ '.{entries}:Object entries'
56
+ )
57
+
58
+ # Check context and provide appropriate completions
59
+ local curcontext="$curcontext" state line
60
+ typeset -A opt_args
61
+
62
+ _arguments -C \
63
+ "${opts[@]}" \
64
+ '*:: :->args'
65
+
66
+ case $state in
67
+ args)
68
+ # If typing starts with ., offer shortcuts and paths
69
+ if [[ $words[$CURRENT] == .* ]]; then
70
+ _describe -t shortcuts 'shortcuts' shortcuts
71
+ _describe -t paths 'json paths' json_paths
72
+ else
73
+ _arguments "${opts[@]}"
74
+ fi
75
+ ;;
76
+ esac
77
+ }
78
+
79
+ _1ls "$@"
@@ -0,0 +1,52 @@
1
+ #!/bin/bash
2
+
3
+ echo "Installing 1ls shell completions..."
4
+
5
+ # Detect shell
6
+ if [ -n "$BASH_VERSION" ]; then
7
+ SHELL_NAME="bash"
8
+ elif [ -n "$ZSH_VERSION" ]; then
9
+ SHELL_NAME="zsh"
10
+ else
11
+ echo "Unsupported shell. Only bash and zsh are supported."
12
+ exit 1
13
+ fi
14
+
15
+ # Get the directory of this script
16
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
17
+
18
+ if [ "$SHELL_NAME" = "bash" ]; then
19
+ # Bash installation
20
+ if [ -d "$HOME/.bash_completion.d" ]; then
21
+ cp "$SCRIPT_DIR/1ls.bash" "$HOME/.bash_completion.d/"
22
+ echo "Installed to ~/.bash_completion.d/"
23
+ echo "Add this to your ~/.bashrc if not already present:"
24
+ echo " source ~/.bash_completion.d/1ls.bash"
25
+ elif [ -f "$HOME/.bashrc" ]; then
26
+ echo "" >> "$HOME/.bashrc"
27
+ echo "# 1ls completions" >> "$HOME/.bashrc"
28
+ echo "source $SCRIPT_DIR/1ls.bash" >> "$HOME/.bashrc"
29
+ echo "Added to ~/.bashrc"
30
+ else
31
+ echo "Could not find suitable location for bash completions"
32
+ echo "Please manually source: $SCRIPT_DIR/1ls.bash"
33
+ fi
34
+ elif [ "$SHELL_NAME" = "zsh" ]; then
35
+ # Zsh installation
36
+ if [ -d "$HOME/.zsh/completions" ]; then
37
+ cp "$SCRIPT_DIR/1ls.zsh" "$HOME/.zsh/completions/_1ls"
38
+ echo "Installed to ~/.zsh/completions/"
39
+ elif [ -d "/usr/local/share/zsh/site-functions" ]; then
40
+ cp "$SCRIPT_DIR/1ls.zsh" "/usr/local/share/zsh/site-functions/_1ls"
41
+ echo "Installed to /usr/local/share/zsh/site-functions/"
42
+ else
43
+ mkdir -p "$HOME/.zsh/completions"
44
+ cp "$SCRIPT_DIR/1ls.zsh" "$HOME/.zsh/completions/_1ls"
45
+ echo "Installed to ~/.zsh/completions/"
46
+ echo "Add this to your ~/.zshrc if not already present:"
47
+ echo " fpath=(~/.zsh/completions \$fpath)"
48
+ echo " autoload -U compinit && compinit"
49
+ fi
50
+ fi
51
+
52
+ echo "Reload your shell or run 'source ~/.${SHELL_NAME}rc' to enable completions"
@@ -1,4 +1,5 @@
1
1
  import { LiteralNode } from "../types";
2
- export declare const isBooleanLiteral: (value: string) => boolean;
2
+ import { BOOLEAN_LITERALS } from "./constants";
3
+ export declare const isBooleanLiteral: (value: string) => value is (typeof BOOLEAN_LITERALS)[number];
3
4
  export declare const createLiteralNode: (value: string | number | boolean | null) => LiteralNode;
4
5
  export declare const tryParseLiteralIdentifier: (identifier: string) => LiteralNode | undefined;
@@ -1,9 +1,9 @@
1
1
  export declare const TRUTHY_VALUES: readonly ["true", "yes", "on"];
2
2
  export declare const FALSY_VALUES: readonly ["false", "no", "off"];
3
3
  export declare const NULL_VALUES: readonly ["null", "~", ""];
4
- export declare const isTruthyValue: (value: string) => boolean;
5
- export declare const isFalsyValue: (value: string) => boolean;
6
- export declare const isNullValue: (value: string) => boolean;
4
+ export declare const isTruthyValue: (value: string) => value is (typeof TRUTHY_VALUES)[number];
5
+ export declare const isFalsyValue: (value: string) => value is (typeof FALSY_VALUES)[number];
6
+ export declare const isNullValue: (value: string) => value is (typeof NULL_VALUES)[number];
7
7
  export declare const parseBooleanValue: (value: string) => boolean | undefined;
8
8
  export declare const parseNullValue: (value: string) => null | undefined;
9
9
  export declare const tryParseNumber: (value: string) => number | undefined;
@@ -2,7 +2,7 @@ import { CliOptions } from "../types";
2
2
  export declare class Formatter {
3
3
  private options;
4
4
  constructor(options: CliOptions);
5
- format(data: any): string;
5
+ format(data: unknown): string;
6
6
  private formatRaw;
7
7
  private formatJson;
8
8
  private formatWithType;
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var ft=Object.defineProperty;var N=(e,t)=>{for(var n in t)ft(e,n,{get:t[n],enumerable:!0,configurable:!0,set:(r)=>t[n]=()=>r})};var A=(e,t)=>()=>(e&&(t=e(e=0)),t);var dt,gt,xt,Nt,Pe,Et,At,Ot,St,bt,yt,Tt,wt,vt,It,Rt,Ct,Ft,Lt,Y,q,S,Me,z,kt,_t,Pt,Mt,Dt,jt,h;var v=A(()=>{dt=/^-?\d+$/,gt=/^[+-]?\d+$/,xt=/^-?\d+\.\d+$/,Nt=/^[+-]?\d+\.\d+$/,Pe=/^-?\d+(\.\d+)?$/,Et=/(\w+)=["']([^"']+)["']/g,At=/^<(\w+)([^>]*?)\/>/,Ot=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,St=/<\w+/,bt=/<\/\w+>$/,yt=/^<\?xml[^>]+\?>\s*/,Tt=/,(\s*[}\]])/g,wt=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,vt=/\/\/|\/\*|,\s*[}\]]/,It=/^\[[\w.\s]+\]$/m,Rt=/^\[[\w.]+\]$/m,Ct=/^\w+\s*=\s*"[^"]*"$/m,Ft=/=\s*["[{]/m,Lt=/^\w+\s*=\s*.+$/m,Y={INTEGER:dt,FLOAT:xt},q={INTEGER:gt,FLOAT:Nt},S={NUMBER:Pe,ATTRIBUTES:Et,SELF_CLOSING:At,OPEN_TAG:Ot,NESTED_TAGS:St,COMPLETE_TAGS:bt,XML_DECLARATION:yt},Me={NUMBER:Pe},z={TRAILING_COMMA:Tt,UNQUOTED_KEY:wt},kt=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,_t=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,Pt=/^\s*interface\s+\w+/m,Mt=/^\s*type\s+\w+\s*=/m,Dt=/^[A-Z_][A-Z0-9_]*\s*=/m,jt=/^\{.*\}\s*$/m,h={JSON5_FEATURES:vt,SECTION_HEADER:It,TOML_SECTION:Rt,TOML_QUOTED_VALUES:Ct,TOML_SYNTAX:Ft,INI_SYNTAX:Lt,JS_EXPORT:kt,TS_TYPE_ANNOTATION:_t,TS_INTERFACE:Pt,TS_TYPE_ALIAS:Mt,ENV_FEATURES:Dt,NDJSON_FEATURES:jt}});var Z={};N(Z,{stripJSON5Comments:()=>De,parseJSON5:()=>Ut,normalizeJSON5:()=>je});function $t(e){return e==='"'||e==="'"}function Bt(e,t,n){let i=e.slice(t).findIndex((o)=>o===n);return i===-1?e.length-t:i}function Vt(e,t){let n=2,r=e.length-t;while(n<r){let i=e[t+n],s=e[t+n+1];if(i==="*"&&s==="/")return n+1;n++}return n}function Gt(e,t,n){if(e.result.push(t),t==="\\"&&n)return e.result.push(n),{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:1};if(t===e.delimiter)return{result:e.result,inString:!1,delimiter:"",skip:0};return e}function Wt(e,t,n,r,i){if($t(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let c=Bt(r,i,`
4
- `);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:c}}if(t==="/"&&n==="*"){let c=Vt(r,i);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:c}}return e.result.push(t),e}function De(e){let t=e.split("");return t.reduce((n,r,i)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let o=t[i+1];return n.inString?Gt(n,r,o):Wt(n,r,o,t,i)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function je(e){let t=De(e);return t=t.replace(z.TRAILING_COMMA,"$1"),t=t.replace(z.UNQUOTED_KEY,'"$2":'),t=t.replace(/'/g,'"'),t}function Ut(e){let t=je(e);return JSON.parse(t)}var ee=A(()=>{v()});var Jt,Qt,Ht,Xt=(e)=>Jt.includes(e),Kt=(e)=>Qt.includes(e),Yt=(e)=>Ht.includes(e),F=(e)=>{if(Xt(e))return!0;if(Kt(e))return!1;return},L=(e)=>{if(Yt(e))return null;return},V=(e)=>{if(e==="")return;let t=Number(e);return isNaN(t)?void 0:t};var G=A(()=>{Jt=["true","yes","on"],Qt=["false","no","off"],Ht=["null","~",""]});var te={};N(te,{parseYAMLValue:()=>k,parseYAML:()=>qt,findPreviousKey:()=>$e});function k(e){let t=e.startsWith('"')&&e.endsWith('"'),n=e.startsWith("'")&&e.endsWith("'");if(t||n)return e.slice(1,-1);let i=F(e);if(i!==void 0)return i;let s=L(e);if(s!==void 0)return s;if(Y.INTEGER.test(e))return parseInt(e,10);if(Y.FLOAT.test(e))return parseFloat(e);if(e.startsWith("[")&&e.endsWith("]"))return e.slice(1,-1).split(",").map((p)=>k(p.trim()));if(e.startsWith("{")&&e.endsWith("}")){let p={};return e.slice(1,-1).split(",").forEach((m)=>{let[f,E]=m.split(":").map((w)=>w.trim());if(f&&E)p[f]=k(E)}),p}return e}function $e(e,t){return Array.from({length:t},(r,i)=>t-1-i).reduce((r,i)=>{if(r!==null)return r;let s=e[i],o=s.indexOf("#");if(o>=0){let p=s.substring(0,o);if((p.match(/["']/g)||[]).length%2===0)s=p}let c=s.trim();if(c&&!c.startsWith("-")&&c.includes(":")){let p=c.indexOf(":"),l=c.substring(0,p).trim();if(!c.substring(p+1).trim())return l}return null},null)}function qt(e){let t=e.trim().split(`
5
- `),n={},r=[n],i=[0],s=null,o=-1;return t.forEach((u,c)=>{let a=u,p=a.indexOf("#");if(p>=0){let g=a.substring(0,p);if((g.match(/["']/g)||[]).length%2===0)a=g}if(!a.trim())return;if(a.trim()==="---"||a.trim()==="...")return;let m=a.length-a.trimStart().length,f=a.trim();if(f.startsWith("- ")){let g=f.substring(2).trim();if(s!==null&&m===o){s.push(k(g));return}s=[k(g)],o=m;while(i.length>1&&i[i.length-1]>=m)r.pop(),i.pop();let x=r[r.length-1];if(typeof x==="object"&&!Array.isArray(x)){let P=$e(t,c);if(P)x[P]=s}return}if(!f.startsWith("- "))s=null,o=-1;let T=f.indexOf(":");if(T>0){let g=f.substring(0,T).trim(),_=f.substring(T+1).trim();while(i.length>1&&i[i.length-1]>=m)r.pop(),i.pop();let x=r[r.length-1];if(!_){let X=c+1;if(X<t.length){if(t[X].trim().startsWith("- "))return}let P={};x[g]=P,r.push(P),i.push(m)}else x[g]=k(_)}}),n}var ne=A(()=>{v();G()});var re={};N(re,{parseTOMLValue:()=>W,parseTOML:()=>zt});function W(e){if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\"/g,'"');if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(q.INTEGER.test(e))return parseInt(e,10);if(q.FLOAT.test(e))return parseFloat(e);if(e.startsWith("[")&&e.endsWith("]"))return e.slice(1,-1).split(",").map((c)=>W(c.trim()));if(e.startsWith("{")&&e.endsWith("}")){let u={};return e.slice(1,-1).split(",").forEach((a)=>{let[p,l]=a.split("=").map((m)=>m.trim());if(p&&l)u[p]=W(l)}),u}return e}function zt(e){let t=e.trim().split(`
6
- `),n={},r=n,i=[];return t.forEach((s)=>{let o=s,u=o.indexOf("#");if(u>=0){let m=o.substring(0,u);if((m.match(/["']/g)||[]).length%2===0)o=m}let c=o.trim();if(!c)return;if(c.startsWith("[")&&c.endsWith("]")){let m=c.slice(1,-1).split(".");r=n,i=[],m.forEach((f)=>{if(!r[f])r[f]={};r=r[f],i.push(f)});return}let p=c.indexOf("=");if(p>0){let m=c.substring(0,p).trim(),f=c.substring(p+1).trim();r[m]=W(f)}}),n}var se=A(()=>{v()});var oe={};N(oe,{parseXMLValue:()=>M,parseXMLElement:()=>ie,parseXMLChildren:()=>Be,parseXMLAttributes:()=>U,parseXML:()=>tn});function M(e){let t=e.trim();if(t==="true")return!0;if(t==="false")return!1;if(S.NUMBER.test(t))return parseFloat(t);return t}function U(e){return Array.from(e.matchAll(S.ATTRIBUTES)).reduce((n,r)=>{let[,i,s]=r;return n[i]=M(s),n},{})}function ie(e){let t=e.trim(),n=t.match(S.SELF_CLOSING);if(n){let[,l,m]=n;if(m.trim().length>0)return{[l]:{_attributes:U(m)}};return{[l]:null}}let r=t.match(S.OPEN_TAG);if(!r)return M(t);let[,i,s,o]=r,u=o.trim();if(!S.NESTED_TAGS.test(u)){if(s.trim().length>0)return{[i]:{_attributes:U(s),_text:M(u)}};return{[i]:M(u)}}let a=Be(u);if(s.trim().length>0)return{[i]:{_attributes:U(s),...a}};return{[i]:a}}function Zt(e){let t=e.split(""),n=t.reduce((s,o,u)=>{if(s.skip>0)return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:s.skip-1};if(o==="<"){let E=t[u+1]==="/",w=e.slice(u).match(/^<[^>]+\/>/);if(E)return s.buffer.push(o),{elements:s.elements,buffer:s.buffer,depth:s.depth-1,skip:0};if(w){let g=w[0];if(g.split("").forEach((x)=>s.buffer.push(x)),s.depth===0){let x=s.buffer.join("").trim();s.elements.push(x),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:g.length-1}}return s.buffer.push(o),{elements:s.elements,buffer:s.buffer,depth:s.depth+1,skip:0}}s.buffer.push(o);let p=s.depth===0,l=s.buffer.join("").trim(),m=l.length>0,f=!o.match(/\s/);if(p&&m&&f){if(l.match(S.COMPLETE_TAGS))s.elements.push(l),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:0}},{elements:[],buffer:[],depth:0,skip:0}),r=n.buffer.join("").trim();return r.length>0?[...n.elements,r]:n.elements}function en(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n);return}e[t]=[r,n]}function Be(e){return Zt(e).reduce((n,r)=>{let i=ie(r);if(typeof i==="object"&&i!==null)Object.entries(i).forEach(([o,u])=>{en(n,o,u)});return n},{})}function tn(e){let t=e.trim(),n=t.match(S.XML_DECLARATION),r=n?t.slice(n[0].length):t;return ie(r)}var ce=A(()=>{v()});var ae={};N(ae,{parseINIValue:()=>ue,parseINI:()=>sn});function ue(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(Me.NUMBER.test(t))return parseFloat(t);return t}function nn(e){let t=e.indexOf(";"),n=e.indexOf("#");if(!(t>=0||n>=0))return e;let i=t>=0&&n>=0?Math.min(t,n):Math.max(t,n);return e.substring(0,i)}function rn(e,t){let r=nn(t).trim();if(!r)return e;if(r.startsWith("[")&&r.endsWith("]")){let c=r.slice(1,-1).trim();if(!e.result[c])e.result[c]={};return{result:e.result,currentSection:c}}let o=r.indexOf("=");if(o>0){let c=r.substring(0,o).trim(),a=r.substring(o+1).trim();if(e.currentSection.length>0){let l=e.result[e.currentSection];l[c]=ue(a)}else e.result[c]=ue(a)}return e}function sn(e){return e.trim().split(`
7
- `).reduce((r,i)=>rn(r,i),{result:{},currentSection:""}).result}var pe=A(()=>{v()});var D={};N(D,{parseTSV:()=>on,parseCSVValue:()=>Ve,parseCSVLine:()=>le,parseCSV:()=>Ge});function le(e,t){let n=[],r="",i=!1,s=e.split("");return s.forEach((o,u)=>{let c=s[u+1];if(o==='"'){if(i&&c==='"'){r+='"',s.splice(u+1,1);return}i=!i;return}if(o===t&&!i){n.push(r),r="";return}r+=o}),n.push(r),n.map((o)=>o.trim())}function Ve(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/""/g,'"');let r=V(t);if(r!==void 0)return r;let i=t.toLowerCase(),s=F(i);if(s!==void 0)return s;let o=L(i);if(o!==void 0)return o;return t}function Ge(e,t=","){let n=e.trim().split(`
8
- `);if(n.length===0)return[];let r=le(n[0],t);if(n.length===1)return[];return n.slice(1).reduce((i,s)=>{let o=le(s,t);if(o.length===0)return i;let u=Object.fromEntries(r.map((c,a)=>[c,Ve(o[a]||"")]));return[...i,u]},[])}function on(e){return Ge(e,"\t")}var j=A(()=>{G()});var me={};N(me,{parseProtobufJSON:()=>un,parseProtobuf:()=>cn});function cn(e){throw Error("Protobuf parsing requires a .proto schema file. Please convert your protobuf to JSON first using protoc: protoc --decode_raw < file.pb | 1ls")}function un(e){return JSON.parse(e)}var fe={};N(fe,{stripJSComments:()=>J,parseJavaScript:()=>hn});function an(e){return e==='"'||e==="'"||e==="`"}function pn(e,t,n){let i=e.slice(t).findIndex((o)=>o===n);return i===-1?e.length-t:i}function ln(e,t){let n=2,r=e.length-t;while(n<r){let i=e[t+n],s=e[t+n+1];if(i==="*"&&s==="/")return n+1;n++}return n}function mn(e,t,n){if(e.result.push(t),t==="\\"&&n)return e.result.push(n),{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:1};if(t===e.delimiter)return{result:e.result,inString:!1,delimiter:"",skip:0};return e}function fn(e,t,n,r,i){if(an(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let c=pn(r,i,`
9
- `);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:c}}if(t==="/"&&n==="*"){let c=ln(r,i);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:c}}return e.result.push(t),e}function J(e){let t=e.split("");return t.reduce((n,r,i)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let o=t[i+1];return n.inString?mn(n,r,o):fn(n,r,o,t,i)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function hn(input){let withoutComments=J(input),exportMatch=withoutComments.match(/export\s+default\s+([\s\S]+)/),code=exportMatch?exportMatch[1]:withoutComments,trimmed=code.trim().replace(/;$/,"");return eval(`(${trimmed})`)}var he={};N(he,{parseTypeScript:()=>gn});function dn(){if(Q!==null)return Q;return Q=new Bun.Transpiler({loader:"ts"}),Q}function gn(input){let withoutComments=J(input),transpiler=dn(),transpiled=transpiler.transformSync(withoutComments),exportMatch=transpiled.match(/export\s+default\s+(.+?)(?:;|\n|$)/),exportedValue=exportMatch?exportMatch[1]:null,hasExport=exportedValue!==null;if(!hasExport)return null;let exportIndex=transpiled.indexOf("export default"),codeBeforeExport=transpiled.substring(0,exportIndex),fullCode=`${codeBeforeExport}
10
- (${exportedValue})`;return eval(fullCode)}var Q=null;var de=()=>{};var ge={};N(ge,{parseENVValue:()=>We,parseENV:()=>En});function We(e){let t=e.trim(),n=t.startsWith('"')&&t.endsWith('"'),r=t.startsWith("'")&&t.endsWith("'");if(n||r)return t.slice(1,-1);let s=F(t);if(s!==void 0)return s;let o=L(t);if(o!==void 0)return o;let u=V(t);if(u!==void 0)return u;return t}function xn(e){let t=e.indexOf("#");if(!(t>=0))return e;let r=e.substring(0,t);if(r.match(/["'].*["']/)!==null){if((r.match(/["']/g)||[]).length%2!==0)return e}return r}function Nn(e,t){let r=xn(t).trim();if(!r)return e;let o=r.startsWith("export ")?r.substring(7).trim():r,u=o.indexOf("=");if(u>0){let a=o.substring(0,u).trim(),p=o.substring(u+1).trim();e.result[a]=We(p)}return e}function En(e){return e.trim().split(`
11
- `).reduce((r,i)=>Nn(r,i),{result:{}}).result}var xe=A(()=>{G()});var Ne={};N(Ne,{parseNDJSON:()=>An});function An(e){return e.trim().split(`
12
- `).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}var Le=["json","yaml","csv","table"],ke=["json","yaml","toml","csv","tsv","lines","text"];var ht={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0};function _e(e){let t={...ht},n=0;while(n<e.length){let r=e[n];switch(r){case"--help":case"-h":t.help=!0;break;case"--version":case"-v":t.version=!0;break;case"--raw":case"-r":t.raw=!0;break;case"--pretty":case"-p":t.pretty=!0;break;case"--compact":case"-c":t.compact=!0;break;case"--type":case"-t":t.type=!0;break;case"--format":if(n++,n<e.length){let s=e[n],o=Le.includes(s);if(s&&o)t.format=s}break;case"--input-format":case"-if":if(n++,n<e.length){let s=e[n];if(ke.includes(s))t.inputFormat=s}break;case"readFile":t.readFile=!0,n+=2;break;case"--find":case"-f":if(n++,n<e.length)t.find=e[n];break;case"--grep":case"-g":if(n++,n<e.length)t.grep=e[n];break;case"--list":case"-l":if(n++,n<e.length)t.list=e[n];break;case"--recursive":case"-R":t.recursive=!0;break;case"--ignore-case":case"-i":t.ignoreCase=!0;break;case"--line-numbers":case"-n":t.showLineNumbers=!0;break;case"--ext":if(n++,n<e.length){let s=e[n].split(",");t.extensions=s.map((o)=>o.startsWith(".")?o:`.${o}`)}break;case"--max-depth":if(n++,n<e.length)t.maxDepth=parseInt(e[n],10);break;case"--shorten":if(n++,n<e.length)t.shorten=e[n];break;case"--expand":if(n++,n<e.length)t.expand=e[n];break;case"--shortcuts":t.shortcuts=!0;break;default:if(r.startsWith(".")||r.startsWith("["))t.expression=r;break}n++}return t}function K(){console.log(`
3
+ var mn=Object.defineProperty;var N=(e,t)=>{for(var n in t)mn(e,n,{get:t[n],enumerable:!0,configurable:!0,set:(r)=>t[n]=()=>r})};var O=(e,t)=>()=>(e&&(t=e(e=0)),t);var fn,gn,xn,bn,Xe,Sn,yn,wn,En,Nn,An,Tn,On,vn,In,Cn,Rn,Mn,Fn,ge,xe,I,qe,be,Ln,Pn,kn,_n,Bn,jn,S;var k=O(()=>{fn=/^-?\d+$/,gn=/^[+-]?\d+$/,xn=/^-?\d+\.\d+$/,bn=/^[+-]?\d+\.\d+$/,Xe=/^-?\d+(\.\d+)?$/,Sn=/(\w+)=["']([^"']+)["']/g,yn=/^<(\w+)([^>]*?)\/>/,wn=/^<(\w+)([^>]*)>([\s\S]*)<\/\1>$/,En=/<\w+/,Nn=/<\/\w+>$/,An=/^<\?xml[^>]+\?>\s*/,Tn=/,(\s*[}\]])/g,On=/(['"])?([a-zA-Z_$][a-zA-Z0-9_$]*)\1?\s*:/g,vn=/\/\/|\/\*|,\s*[}\]]/,In=/^\[[\w.\s]+\]$/m,Cn=/^\[[\w.]+\]$/m,Rn=/^\w+\s*=\s*"[^"]*"$/m,Mn=/=\s*["[{]/m,Fn=/^\w+\s*=\s*.+$/m,ge={INTEGER:fn,FLOAT:xn},xe={INTEGER:gn,FLOAT:bn},I={NUMBER:Xe,ATTRIBUTES:Sn,SELF_CLOSING:yn,OPEN_TAG:wn,NESTED_TAGS:En,COMPLETE_TAGS:Nn,XML_DECLARATION:An},qe={NUMBER:Xe},be={TRAILING_COMMA:Tn,UNQUOTED_KEY:On},Ln=/^\s*export\s+(const|let|var|function|class|default|type|interface|enum)/m,Pn=/:\s*(string|number|boolean|any|unknown|void|never|object|Array|Promise)/,kn=/^\s*interface\s+\w+/m,_n=/^\s*type\s+\w+\s*=/m,Bn=/^[A-Z_][A-Z0-9_]*\s*=/m,jn=/^\{.*\}\s*$/m,S={JSON5_FEATURES:vn,SECTION_HEADER:In,TOML_SECTION:Cn,TOML_QUOTED_VALUES:Rn,TOML_SYNTAX:Mn,INI_SYNTAX:Fn,JS_EXPORT:Ln,TS_TYPE_ANNOTATION:Pn,TS_INTERFACE:kn,TS_TYPE_ALIAS:_n,ENV_FEATURES:Bn,NDJSON_FEATURES:jn}});var et={};N(et,{stripJSON5Comments:()=>Ye,parseJSON5:()=>Jn,normalizeJSON5:()=>Ze});function Dn(e){return e==='"'||e==="'"}function Vn(e,t,n){let o=e.slice(t).findIndex((i)=>i===n);return o===-1?e.length-t:o}function $n(e,t){let n=2,r=e.length-t;while(n<r){let o=e[t+n],s=e[t+n+1];if(o==="*"&&s==="/")return n+1;n++}return n}function Gn(e,t,n){if(e.result.push(t),t==="\\"&&n)return e.result.push(n),{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:1};if(t===e.delimiter)return{result:e.result,inString:!1,delimiter:"",skip:0};return e}function Wn(e,t,n,r,o){if(Dn(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let a=Vn(r,o,`
4
+ `);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}if(t==="/"&&n==="*"){let a=$n(r,o);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}return e.result.push(t),e}function Ye(e){let t=e.split("");return t.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=t[o+1];return n.inString?Gn(n,r,i):Wn(n,r,i,t,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function Ze(e){let t=Ye(e);return t=t.replace(be.TRAILING_COMMA,"$1"),t=t.replace(be.UNQUOTED_KEY,'"$2":'),t=t.replace(/'/g,'"'),t}function Jn(e){let t=Ze(e);return JSON.parse(t)}var tt=O(()=>{k()});var Un,zn,Qn,Hn=(e)=>Un.includes(e),Kn=(e)=>zn.includes(e),Xn=(e)=>Qn.includes(e),$=(e)=>{if(Hn(e))return!0;if(Kn(e))return!1;return},G=(e)=>{if(Xn(e))return null;return},se=(e)=>{if(e==="")return;let t=Number(e);return isNaN(t)?void 0:t};var oe=O(()=>{Un=["true","yes","on"],zn=["false","no","off"],Qn=["null","~",""]});var rt={};N(rt,{parseYAMLValue:()=>W,parseYAML:()=>qn,findPreviousKey:()=>nt});function W(e){let t=e.startsWith('"')&&e.endsWith('"'),n=e.startsWith("'")&&e.endsWith("'");if(t||n)return e.slice(1,-1);let o=$(e);if(o!==void 0)return o;let s=G(e);if(s!==void 0)return s;if(ge.INTEGER.test(e))return parseInt(e,10);if(ge.FLOAT.test(e))return parseFloat(e);if(e.startsWith("[")&&e.endsWith("]"))return e.slice(1,-1).split(",").map((l)=>W(l.trim()));if(e.startsWith("{")&&e.endsWith("}")){let l={};return e.slice(1,-1).split(",").forEach((d)=>{let[h,g]=d.split(":").map((x)=>x.trim());if(h&&g)l[h]=W(g)}),l}return e}function nt(e,t){return Array.from({length:t},(r,o)=>t-1-o).reduce((r,o)=>{if(r!==null)return r;let s=e[o],i=s.indexOf("#");if(i>=0){let l=s.substring(0,i);if((l.match(/["']/g)||[]).length%2===0)s=l}let a=s.trim();if(a&&!a.startsWith("-")&&a.includes(":")){let l=a.indexOf(":"),p=a.substring(0,l).trim();if(!a.substring(l+1).trim())return p}return null},null)}function qn(e){let t=e.trim().split(`
5
+ `),n={},r=[n],o=[0],s=null,i=-1;return t.forEach((c,a)=>{let u=c,l=u.indexOf("#");if(l>=0){let w=u.substring(0,l);if((w.match(/["']/g)||[]).length%2===0)u=w}if(!u.trim())return;if(u.trim()==="---"||u.trim()==="...")return;let d=u.length-u.trimStart().length,h=u.trim();if(h.startsWith("- ")){let w=h.substring(2).trim();if(s!==null&&d===i){s.push(W(w));return}s=[W(w)],i=d;while(o.length>1&&o[o.length-1]>=d)r.pop(),o.pop();let E=r[r.length-1];if(typeof E==="object"&&!Array.isArray(E)){let P=nt(t,a);if(P)E[P]=s}return}if(!h.startsWith("- "))s=null,i=-1;let y=h.indexOf(":");if(y>0){let w=h.substring(0,y).trim(),L=h.substring(y+1).trim();while(o.length>1&&o[o.length-1]>=d)r.pop(),o.pop();let E=r[r.length-1];if(!L){let re=a+1;if(re<t.length){if(t[re].trim().startsWith("- "))return}let P={};E[w]=P,r.push(P),o.push(d)}else E[w]=W(L)}}),n}var st=O(()=>{k();oe()});var ot={};N(ot,{parseTOMLValue:()=>ie,parseTOML:()=>Yn});function ie(e){if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/\\"/g,'"');if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;if(xe.INTEGER.test(e))return parseInt(e,10);if(xe.FLOAT.test(e))return parseFloat(e);if(e.startsWith("[")&&e.endsWith("]"))return e.slice(1,-1).split(",").map((a)=>ie(a.trim()));if(e.startsWith("{")&&e.endsWith("}")){let c={};return e.slice(1,-1).split(",").forEach((u)=>{let[l,p]=u.split("=").map((d)=>d.trim());if(l&&p)c[l]=ie(p)}),c}return e}function Yn(e){let t=e.trim().split(`
6
+ `),n={},r=n,o=[];return t.forEach((s)=>{let i=s,c=i.indexOf("#");if(c>=0){let d=i.substring(0,c);if((d.match(/["']/g)||[]).length%2===0)i=d}let a=i.trim();if(!a)return;if(a.startsWith("[")&&a.endsWith("]")){let d=a.slice(1,-1).split(".");r=n,o=[],d.forEach((h)=>{if(!r[h])r[h]={};r=r[h],o.push(h)});return}let l=a.indexOf("=");if(l>0){let d=a.substring(0,l).trim(),h=a.substring(l+1).trim();r[d]=ie(h)}}),n}var it=O(()=>{k()});var at={};N(at,{parseXMLValue:()=>z,parseXMLElement:()=>Se,parseXMLChildren:()=>ct,parseXMLAttributes:()=>ce,parseXML:()=>tr});function z(e){let t=e.trim();if(t==="true")return!0;if(t==="false")return!1;if(I.NUMBER.test(t))return parseFloat(t);return t}function ce(e){return Array.from(e.matchAll(I.ATTRIBUTES)).reduce((n,r)=>{let[,o,s]=r;return n[o]=z(s),n},{})}function Se(e){let t=e.trim(),n=t.match(I.SELF_CLOSING);if(n){let[,p,d]=n;if(d.trim().length>0)return{[p]:{_attributes:ce(d)}};return{[p]:null}}let r=t.match(I.OPEN_TAG);if(!r)return z(t);let[,o,s,i]=r,c=i.trim();if(!I.NESTED_TAGS.test(c)){if(s.trim().length>0)return{[o]:{_attributes:ce(s),_text:z(c)}};return{[o]:z(c)}}let u=ct(c);if(s.trim().length>0)return{[o]:{_attributes:ce(s),...u}};return{[o]:u}}function Zn(e){let t=e.split(""),n=t.reduce((s,i,c)=>{if(s.skip>0)return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:s.skip-1};if(i==="<"){let g=t[c+1]==="/",x=e.slice(c).match(/^<[^>]+\/>/);if(g)return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth-1,skip:0};if(x){let w=x[0];if(w.split("").forEach((E)=>s.buffer.push(E)),s.depth===0){let E=s.buffer.join("").trim();s.elements.push(E),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:w.length-1}}return s.buffer.push(i),{elements:s.elements,buffer:s.buffer,depth:s.depth+1,skip:0}}s.buffer.push(i);let l=s.depth===0,p=s.buffer.join("").trim(),d=p.length>0,h=!i.match(/\s/);if(l&&d&&h){if(p.match(I.COMPLETE_TAGS))s.elements.push(p),s.buffer.length=0}return{elements:s.elements,buffer:s.buffer,depth:s.depth,skip:0}},{elements:[],buffer:[],depth:0,skip:0}),r=n.buffer.join("").trim();return r.length>0?[...n.elements,r]:n.elements}function er(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n);return}e[t]=[r,n]}function ct(e){return Zn(e).reduce((n,r)=>{let o=Se(r);if(typeof o==="object"&&o!==null)Object.entries(o).forEach(([i,c])=>{er(n,i,c)});return n},{})}function tr(e){let t=e.trim(),n=t.match(I.XML_DECLARATION),r=n?t.slice(n[0].length):t;return Se(r)}var ut=O(()=>{k()});var lt={};N(lt,{parseINIValue:()=>ye,parseINI:()=>sr});function ye(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(qe.NUMBER.test(t))return parseFloat(t);return t}function nr(e){let t=e.indexOf(";"),n=e.indexOf("#");if(!(t>=0||n>=0))return e;let o=t>=0&&n>=0?Math.min(t,n):Math.max(t,n);return e.substring(0,o)}function rr(e,t){let r=nr(t).trim();if(!r)return e;if(r.startsWith("[")&&r.endsWith("]")){let a=r.slice(1,-1).trim();if(!e.result[a])e.result[a]={};return{result:e.result,currentSection:a}}let i=r.indexOf("=");if(i>0){let a=r.substring(0,i).trim(),u=r.substring(i+1).trim();if(e.currentSection.length>0){let p=e.result[e.currentSection];p[a]=ye(u)}else e.result[a]=ye(u)}return e}function sr(e){return e.trim().split(`
7
+ `).reduce((r,o)=>rr(r,o),{result:{},currentSection:""}).result}var pt=O(()=>{k()});var Ee={};N(Ee,{parseTSV:()=>or,parseCSVValue:()=>ht,parseCSVLine:()=>we,parseCSV:()=>mt});function we(e,t){let n=[],r="",o=!1,s=e.split("");return s.forEach((i,c)=>{let a=s[c+1];if(i==='"'){if(o&&a==='"'){r+='"',s.splice(c+1,1);return}o=!o;return}if(i===t&&!o){n.push(r),r="";return}r+=i}),n.push(r),n.map((i)=>i.trim())}function ht(e){let t=e.trim();if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/""/g,'"');let r=se(t);if(r!==void 0)return r;let o=t.toLowerCase(),s=$(o);if(s!==void 0)return s;let i=G(o);if(i!==void 0)return i;return t}function mt(e,t=","){let n=e.trim().split(`
8
+ `);if(n.length===0)return[];let r=we(n[0],t);if(n.length===1)return[];return n.slice(1).reduce((o,s)=>{let i=we(s,t);if(i.length===0)return o;let c=Object.fromEntries(r.map((a,u)=>[a,ht(i[u]||"")]));return[...o,c]},[])}function or(e){return mt(e,"\t")}var Ne=O(()=>{oe()});var dt={};N(dt,{parseProtobufJSON:()=>cr,parseProtobuf:()=>ir});function ir(e){throw Error("Protobuf parsing requires a .proto schema file. Please convert your protobuf to JSON first using protoc: protoc --decode_raw < file.pb | 1ls")}function cr(e){return JSON.parse(e)}var ft={};N(ft,{stripJSComments:()=>ae,parseJavaScript:()=>mr});function ar(e){return e==='"'||e==="'"||e==="`"}function ur(e,t,n){let o=e.slice(t).findIndex((i)=>i===n);return o===-1?e.length-t:o}function lr(e,t){let n=2,r=e.length-t;while(n<r){let o=e[t+n],s=e[t+n+1];if(o==="*"&&s==="/")return n+1;n++}return n}function pr(e,t,n){if(e.result.push(t),t==="\\"&&n)return e.result.push(n),{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:1};if(t===e.delimiter)return{result:e.result,inString:!1,delimiter:"",skip:0};return e}function hr(e,t,n,r,o){if(ar(t))return e.result.push(t),{result:e.result,inString:!0,delimiter:t,skip:0};if(t==="/"&&n==="/"){let a=ur(r,o,`
9
+ `);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}if(t==="/"&&n==="*"){let a=lr(r,o);return{result:e.result,inString:e.inString,delimiter:e.delimiter,skip:a}}return e.result.push(t),e}function ae(e){let t=e.split("");return t.reduce((n,r,o)=>{if(n.skip>0)return{result:n.result,inString:n.inString,delimiter:n.delimiter,skip:n.skip-1};let i=t[o+1];return n.inString?pr(n,r,i):hr(n,r,i,t,o)},{result:[],inString:!1,delimiter:"",skip:0}).result.join("")}function mr(input){let withoutComments=ae(input),exportMatch=withoutComments.match(/export\s+default\s+([\s\S]+)/),code=exportMatch?exportMatch[1]:withoutComments,trimmed=code.trim().replace(/;$/,"");return eval(`(${trimmed})`)}var gt={};N(gt,{parseTypeScript:()=>fr});function dr(){if(ue!==null)return ue;return ue=new Bun.Transpiler({loader:"ts"}),ue}function fr(input){let withoutComments=ae(input),transpiler=dr(),transpiled=transpiler.transformSync(withoutComments),exportMatch=transpiled.match(/export\s+default\s+(.+?)(?:;|\n|$)/),exportedValue=exportMatch?exportMatch[1]:null,hasExport=exportedValue!==null;if(!hasExport)return null;let exportIndex=transpiled.indexOf("export default"),codeBeforeExport=transpiled.substring(0,exportIndex),fullCode=`${codeBeforeExport}
10
+ (${exportedValue})`;return eval(fullCode)}var ue=null;var xt=()=>{};var St={};N(St,{parseENVValue:()=>bt,parseENV:()=>br});function bt(e){let t=e.trim(),n=t.startsWith('"')&&t.endsWith('"'),r=t.startsWith("'")&&t.endsWith("'");if(n||r)return t.slice(1,-1);let s=$(t);if(s!==void 0)return s;let i=G(t);if(i!==void 0)return i;let c=se(t);if(c!==void 0)return c;return t}function gr(e){let t=e.indexOf("#");if(!(t>=0))return e;let r=e.substring(0,t);if(r.match(/["'].*["']/)!==null){if((r.match(/["']/g)||[]).length%2!==0)return e}return r}function xr(e,t){let r=gr(t).trim();if(!r)return e;let i=r.startsWith("export ")?r.substring(7).trim():r,c=i.indexOf("=");if(c>0){let u=i.substring(0,c).trim(),l=i.substring(c+1).trim();e.result[u]=bt(l)}return e}function br(e){return e.trim().split(`
11
+ `).reduce((r,o)=>xr(r,o),{result:{}}).result}var yt=O(()=>{oe()});var wt={};N(wt,{parseNDJSON:()=>Sr});function Sr(e){return e.trim().split(`
12
+ `).map((n)=>n.trim()).filter((n)=>n.length>0).map((n)=>{try{return JSON.parse(n)}catch{return n}})}var Qe=["json","yaml","csv","table"],He=["json","yaml","toml","csv","tsv","lines","text"];var dn={format:"json",pretty:!1,raw:!1,compact:!1,type:!1,recursive:!1,ignoreCase:!1,showLineNumbers:!1,inputFormat:void 0};function Ke(e){let t={...dn},n=0;while(n<e.length){let r=e[n];switch(r){case"--help":case"-h":t.help=!0;break;case"--version":case"-v":t.version=!0;break;case"--raw":case"-r":t.raw=!0;break;case"--pretty":case"-p":t.pretty=!0;break;case"--compact":case"-c":t.compact=!0;break;case"--type":case"-t":t.type=!0;break;case"--format":if(n++,n<e.length){let s=e[n],i=Qe.includes(s);if(s&&i)t.format=s}break;case"--input-format":case"-if":if(n++,n<e.length){let s=e[n];if(He.includes(s))t.inputFormat=s}break;case"readFile":t.readFile=!0,n+=2;break;case"--find":case"-f":if(n++,n<e.length)t.find=e[n];break;case"--grep":case"-g":if(n++,n<e.length)t.grep=e[n];break;case"--list":case"-l":if(n++,n<e.length)t.list=e[n];break;case"--recursive":case"-R":t.recursive=!0;break;case"--interactive":t.interactive=!0;break;case"--ignore-case":case"-i":t.ignoreCase=!0;break;case"--line-numbers":case"-n":t.showLineNumbers=!0;break;case"--ext":if(n++,n<e.length){let s=e[n].split(",");t.extensions=s.map((i)=>i.startsWith(".")?i:`.${i}`)}break;case"--max-depth":if(n++,n<e.length)t.maxDepth=parseInt(e[n],10);break;case"--shorten":if(n++,n<e.length)t.shorten=e[n];break;case"--expand":if(n++,n<e.length)t.expand=e[n];break;case"--shortcuts":t.shortcuts=!0;break;default:if(r.startsWith(".")||r.startsWith("["))t.expression=r;break}n++}return t}function fe(){console.log(`
13
13
  1ls - 1 line script for JSON manipulation and file operations
14
14
 
15
15
  Usage:
@@ -82,30 +82,30 @@ Examples:
82
82
  1ls --shorten ".map(x => x * 2)" # Convert to shorthand
83
83
  1ls --expand ".mp(x => x * 2)" # Convert to full form
84
84
  1ls --shortcuts # Show all shortcuts
85
- `)}v();function Ue(e){return e.trim().split(`
86
- `).filter((t)=>t.length>0)}async function H(e,t){if(t)switch(t){case"json":return JSON.parse(e);case"json5":{let{parseJSON5:r}=await Promise.resolve().then(() => (ee(),Z));return r(e)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (ne(),te));return r(e)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => (se(),re));return r(e)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (ce(),oe));return r(e)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (pe(),ae));return r(e)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => (j(),D));return r(e)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (j(),D));return r(e)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => me);return r(e)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => fe);return r(e)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (de(),he));return r(e)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (xe(),ge));return r(e)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => Ne);return r(e)}case"lines":return Ue(e);case"text":return e}switch(On(e)){case"json":return JSON.parse(e);case"json5":{let{parseJSON5:r}=await Promise.resolve().then(() => (ee(),Z));return r(e)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (ne(),te));return r(e)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => (se(),re));return r(e)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (ce(),oe));return r(e)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (pe(),ae));return r(e)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => (j(),D));return r(e)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (j(),D));return r(e)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => me);return r(e)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => fe);return r(e)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (de(),he));return r(e)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (xe(),ge));return r(e)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => Ne);return r(e)}case"lines":return Ue(e);case"text":default:return e}}function On(e){let t=e.trim();if(h.TS_INTERFACE.test(t)||h.TS_TYPE_ALIAS.test(t)||h.TS_TYPE_ANNOTATION.test(t))return"typescript";if(h.JS_EXPORT.test(t))return"javascript";if(t.startsWith("<")&&t.includes(">")){let p=t.startsWith("<?xml"),l=/<\/\w+>/.test(t);if(p||l)return"xml"}if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),"json"}catch{if(h.JSON5_FEATURES.test(t))return"json5"}if(t.includes("=")){if(h.ENV_FEATURES.test(t))return"env";if(t.match(h.TOML_QUOTED_VALUES))return"toml";if(t.match(h.SECTION_HEADER)){if(t.match(h.TOML_SECTION)&&t.match(h.TOML_SYNTAX))return"toml";if(t.match(h.INI_SYNTAX))return"ini"}if(t.match(h.INI_SYNTAX))return"ini"}if(t.includes("---")||t.includes(": ")||t.match(/^[\s]*-\s+/m))return"yaml";let c=t.split(`
87
- `);if(c.length>1){let p=h.NDJSON_FEATURES.test(t),l=c.every((w)=>{let g=w.trim();if(!g)return!0;try{return JSON.parse(g),!0}catch{return!1}});if(p&&l)return"ndjson";let m=c[0],f=(m.match(/,/g)||[]).length,E=(m.match(/\t/g)||[]).length;if(E>0&&E>=f)return"tsv";if(f>0)return"csv";return"lines"}return"text"}async function Je(e){let t=[];for await(let r of process.stdin)t.push(r);let n=Buffer.concat(t).toString("utf-8").trim();if(!n)return null;return H(n,e)}import{readdir as Tn,stat as Xe}from"fs/promises";import{join as wn,extname as vn,basename as In}from"path";var Sn=[".ts",".js",".tsx",".jsx"],bn=[".json",".yml",".yaml"],yn=[".md",".txt"],Qe=[...Sn,...bn,...yn];var He=/[.*+?^${}()|[\]\\]/g;async function Ee(e,t=!0){let r=await Bun.file(e).text();if(!t)return r;return H(r)}function Rn(e,t){return{path:e,name:In(e),ext:vn(e),size:Number(t.size),isDirectory:t.isDirectory(),isFile:t.isFile(),modified:t.mtime,created:t.birthtime}}async function Cn(e){let t=await Xe(e);return Rn(e,t)}function Fn(e){return e.startsWith(".")}function Ln(e,t){return t||!Fn(e)}function kn(e,t){if(t===void 0)return!0;return t.includes(e)}function _n(e,t){if(t===void 0)return!0;return t.test(e)}function Pn(e,t,n){let r=kn(e.ext,t),i=_n(e.name,n);return r&&i}function Mn(e,t){return e<=(t??1/0)}async function Dn(e,t,n,r){if(!Ln(t,r.includeHidden??!1))return[];let s=wn(e,t),o=await Cn(s);if(o.isFile)return Pn(o,r.extensions,r.pattern)?[o]:[];if(!o.isDirectory)return[];let c=r.recursive===!0?await Ke(s,n+1,r):[];return[o,...c]}async function Ke(e,t,n){if(!Mn(t,n.maxDepth))return[];let i=await Tn(e);return(await Promise.all(i.map((o)=>Dn(e,o,t,n)))).flat()}async function Ae(e,t={}){return Ke(e,0,t)}function jn(e,t){if(typeof e!=="string")return e;return new RegExp(e,t?"gi":"g")}function $n(e,t,n,r,i,s){let o={file:e,line:t+1,column:n+1,match:r};if(s===void 0)return o;let c=Math.max(0,t-s),a=Math.min(i.length,t+s+1);return{...o,context:i.slice(c,a)}}function Bn(e,t,n){if(!n)return;let r=t instanceof Error?t.message:String(t);console.error(`Failed to search ${e}: ${r}`)}function Vn(e,t,n,r,i,s){return[...e.matchAll(n)].map((u)=>$n(r,t,u.index,e,i,s))}async function Ye(e,t,n){try{let r=await Ee(e,!1);if(typeof r!=="string")return[];let s=r.split(`
88
- `),o=s.flatMap((c,a)=>Vn(c,a,t,e,s,n.context)),u=n.maxMatches??1/0;return o.slice(0,u)}catch(r){return Bn(e,r,n.verbose??!1),[]}}async function Gn(e,t,n){let r=await Ae(e,{recursive:!0,extensions:[...Qe]});return(await Promise.all(r.filter((s)=>s.isFile).map((s)=>Ye(s.path,t,n)))).flat()}async function qe(e,t,n={}){let r=jn(e,n.ignoreCase??!1),i=await Xe(t);if(i.isFile())return Ye(t,r,n);if(i.isDirectory()&&n.recursive)return Gn(t,r,n);return[]}var Ze={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},et="+-*/%<>!&|=",tt=[" ","\t",`
89
- `,"\r"];function I(e,t,n){return{type:e,value:t,position:n}}class Oe{input;position=0;current;constructor(e){this.input=e,this.current=this.input[0]||""}tokenize(){let e=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let t=this.nextToken();if(t)e.push(t)}return e.push(I("EOF","",this.position)),e}nextToken(){let e=this.position,t=Ze[this.current];if(t){let a=this.current;return this.advance(),I(t,a,e)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),I("ARROW","=>",e);if(this.current==='"'||this.current==="'")return this.readString();let i=this.isDigit(this.current),s=this.current==="-"&&this.isDigit(this.peek());if(i||s)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let e=this.position,t=this.current,n=[];this.advance();while(this.current!==t&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===t)this.advance();return I("STRING",n.join(""),e)}readNumber(){let e=this.position,t="";if(this.current==="-")t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance()}return I("NUMBER",t,e)}readIdentifier(){let e=this.position,t="";while(this.isIdentifierChar(this.current))t+=this.current,this.advance();return I("IDENTIFIER",t,e)}readOperator(){let e=this.position,t="";while(this.isOperator(this.current))t+=this.current,this.advance();return I("OPERATOR",t,e)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(e){return tt.includes(e)}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){let t=e>="a"&&e<="z",n=e>="A"&&e<="Z";return t||n||e==="_"||e==="$"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}isOperator(e){return et.includes(e)}}var O=(e)=>{return{type:"Literal",value:e}},Se=(e)=>{if(e==="true")return O(!0);if(e==="false")return O(!1);if(e==="null")return O(null);return};function b(e,t){return`${t} at position ${e.position} (got ${e.type}: "${e.value}")`}function R(e,t){return{type:"PropertyAccess",property:e,object:t}}function Wn(e,t){return{type:"IndexAccess",index:e,object:t}}function Un(e,t,n){return{type:"SliceAccess",start:e,end:t,object:n}}function nt(e,t,n){return{type:"MethodCall",method:e,args:t,object:n}}function Jn(e,t){return{type:"ObjectOperation",operation:e,object:t}}function Qn(e){return{type:"ArraySpread",object:e}}function Hn(e,t){return{type:"ArrowFunction",params:e,body:t}}function be(e){return{type:"Root",expression:e}}var rt=["keys","values","entries","length"];function Xn(e){return rt.includes(e)}class ye{tokens;position=0;current;constructor(e){this.tokens=e,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return be();let t=this.parseExpression();return be(t)}parseExpression(){return this.parsePrimary()}parsePrimary(){let e=this.parsePrimaryNode();return this.parsePostfix(e)}parsePrimaryNode(){let e=this.current.type;if(e==="DOT")return this.advance(),this.parseAccessChain();if(e==="LEFT_BRACKET")return this.parseArrayAccess();if(e==="IDENTIFIER")return this.parseIdentifierOrFunction();if(e==="STRING"){let t=this.current.value;return this.advance(),O(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),O(t)}if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}throw Error(b(this.current,"Unexpected token"))}parseAccessChain(e){let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;return this.advance(),R(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(b(this.current,"Expected property name after dot"))}parseBracketAccess(e){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),Qn(e);if(this.current.type==="STRING"){let u=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),R(u,e)}let r=this.current.type==="NUMBER",i=this.current.type==="OPERATOR"&&this.current.value==="-",s=this.current.type==="COLON";if(r||i||s)return this.parseNumericIndexOrSlice(e);throw Error(b(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(e){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,e);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,e);return this.expect("RIGHT_BRACKET"),Wn(n,e)}parseSliceFromColon(e,t){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",i=n||r,s=i?this.parseNumber():void 0;if(i)this.advance();return this.expect("RIGHT_BRACKET"),Un(e,s,t)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(e){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(b(this.current,"Expected operation name after {"));let n=this.current.value;if(!Xn(n)){let r=rt.join(", ");throw Error(b(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),Jn(n,e)}parseIdentifierOrFunction(){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);let n=Se(e);if(n)return n;return R(e)}parseArrowFunction(e){this.expect("ARROW");let t=this.parseFunctionBody();return Hn(e,t)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),t}return this.parseBinaryExpression()}parseBinaryExpression(){let e=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let t=this.current.value;this.advance();let n=this.parseFunctionTerm();e=nt(`__operator_${t}__`,[n],e)}return e}parseFunctionTerm(){let e=this.current.type;if(e==="IDENTIFIER")return this.parseIdentifierChain();if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),O(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),O(t)}if(e==="LEFT_PAREN"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),t}throw Error(b(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let e=this.current.value;this.advance();let t=Se(e);if(t)return t;let n=R(e),r=()=>this.current.type==="DOT",i=()=>this.current.type==="IDENTIFIER";while(r()){if(this.advance(),!i())break;let s=this.current.value;this.advance(),n=R(s,n)}return n}parseMethodCall(e,t){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),nt(t,n,e)}parseMethodArguments(){let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let t=this.parseMethodArgument();if(e.push(t),this.current.type==="COMMA")this.advance()}return e}parseMethodArgument(){let e=this.current.type;if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}if(e==="IDENTIFIER"){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);return R(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),O(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),O(t)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")e.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),e}parsePostfix(e){let t=e;while(!0){let n=this.current.type;if(n==="DOT"){t=this.parsePostfixDot(t);continue}if(n==="LEFT_BRACKET"){t=this.parseBracketAccess(t);continue}if(n==="LEFT_PAREN"){if(t.type==="PropertyAccess"&&!t.object){let s=t.property;t=this.parseMethodCall(be(),s);continue}}break}return t}parsePostfixDot(e){this.advance();let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(e,n);return R(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(b(this.current,"Expected property name after dot"))}parseNumber(){let e=this.current.value==="-";if(e)this.advance();if(this.current.type!=="NUMBER")throw Error(b(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return e?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(e){if(this.current.type!==e)throw Error(b(this.current,`Expected ${e} but got ${this.current.type}`));this.advance()}}var Kn={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,"&&":(e,t)=>e&&t,"||":(e,t)=>e||t};function st(e){return e.startsWith("__operator_")&&e.endsWith("__")}function it(e){return e.slice(11,-2)}function ot(e,t,n){let r=Kn[t];if(!r)throw Error(`Unknown operator: ${t}`);return r(e,n)}function Yn(e,t){return Object.fromEntries(e.map((n,r)=>[n,t[r]]))}function Te(e){return Object.values(e)[0]}function ut(e){return e!==null&&typeof e==="object"}function we(e,t){if(!ut(e))return;return e[t]}function ve(e,t){return e<0?t+e:e}function qn(e,t){if(!Array.isArray(e))return;let n=ve(t,e.length);return e[n]}function zn(e,t,n){if(!Array.isArray(e))return;let r=e.length,i=t!==void 0?ve(t,r):0,s=n!==void 0?ve(n,r):r;return e.slice(i,s)}function Zn(e,t){if(!ut(e))return;switch(t){case"keys":return Object.keys(e);case"values":return Object.values(e);case"entries":return Object.entries(e);case"length":return Array.isArray(e)?e.length:Object.keys(e).length}}function ct(e,t,n){if(!(e!==null&&e!==void 0&&typeof e[t]==="function"))throw Error(`Method ${t} does not exist on ${typeof e}`);try{return e[t].call(e,...n)}catch(i){let s=i instanceof Error?i.message:String(i);throw Error(`Error executing method ${t}: ${s}`)}}class Ie{evaluate(e,t){switch(e.type){case"Root":return e.expression?this.evaluate(e.expression,t):t;case"PropertyAccess":return this.evaluatePropertyAccess(e,t);case"IndexAccess":return qn(e.object?this.evaluate(e.object,t):t,e.index);case"SliceAccess":return zn(e.object?this.evaluate(e.object,t):t,e.start,e.end);case"ArraySpread":return e.object?this.evaluate(e.object,t):t;case"MethodCall":return this.evaluateMethodCall(e,t);case"ObjectOperation":return Zn(e.object?this.evaluate(e.object,t):t,e.operation);case"Literal":return e.value;case"ArrowFunction":return this.createFunction(e);default:throw Error(`Unknown AST node type: ${e.type}`)}}evaluatePropertyAccess(e,t){let n=e.object?this.evaluate(e.object,t):t;return we(n,e.property)}evaluateMethodCall(e,t){let n=e.object?this.evaluate(e.object,t):t;if(st(e.method)){let s=it(e.method),o=this.evaluate(e.args[0],t);return ot(n,s,o)}let i=e.args.map((s)=>{return s.type==="ArrowFunction"?this.createFunction(s):this.evaluate(s,t)});return ct(n,e.method,i)}createFunction(e){return(...t)=>{let n=Yn(e.params,t);return this.evaluateFunctionBody(e.body,n)}}evaluateFunctionBody(e,t){switch(e.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(e,t);case"MethodCall":return this.evaluateMethodCallInFunction(e,t);case"Literal":return e.value;case"Root":return e.expression?this.evaluateFunctionBody(e.expression,t):t;default:return this.evaluate(e,Te(t))}}evaluatePropertyAccessInFunction(e,t){if(e.object!==void 0){let s=this.evaluateFunctionBody(e.object,t);return we(s,e.property)}if(Object.prototype.hasOwnProperty.call(t,e.property))return t[e.property];let i=Te(t);return we(i,e.property)}evaluateMethodCallInFunction(e,t){let n=e.object?this.evaluateFunctionBody(e.object,t):Te(t);if(st(e.method)){let s=it(e.method),o=this.evaluateFunctionBody(e.args[0],t);return ot(n,s,o)}let i=e.args.map((s)=>this.evaluateFunctionBody(s,t));return ct(n,e.method,i)}}var d={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"},er=[{regex:/"([^"]+)":/g,replacement:`${d.cyan}"$1"${d.reset}:`},{regex:/: "([^"]*)"/g,replacement:`: ${d.green}"$1"${d.reset}`},{regex:/: (-?\d+\.?\d*)/g,replacement:`: ${d.yellow}$1${d.reset}`},{regex:/: (true|false)/g,replacement:`: ${d.magenta}$1${d.reset}`},{regex:/: (null)/g,replacement:`: ${d.gray}$1${d.reset}`},{regex:/([{[])/g,replacement:`${d.gray}$1${d.reset}`},{regex:/([}\]])/g,replacement:`${d.gray}$1${d.reset}`}];function at(e){if(process.env.NO_COLOR)return e;return er.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function pt(e){if(process.env.NO_COLOR)return e;return`${d.yellow}${e}${d.reset}`}function Re(e){if(process.env.NO_COLOR)return e;return`${d.cyan}${e}${d.reset}`}class B{options;constructor(e){this.options=e}format(e){if(this.options.raw)return this.formatRaw(e);if(this.options.type)return this.formatWithType(e);switch(this.options.format){case"yaml":return this.formatYaml(e);case"csv":return this.formatCsv(e);case"table":return this.formatTable(e);default:return this.formatJson(e)}}formatRaw(e){if(typeof e==="string")return e;if(e===void 0)return"";if(e===null)return"null";if(typeof e==="object")return JSON.stringify(e);return String(e)}formatJson(e){if(e===void 0)return"undefined";if(this.options.compact)return JSON.stringify(e);if(this.options.pretty){let t=JSON.stringify(e,null,2);return at(t)}return JSON.stringify(e,null,2)}formatWithType(e){let t=Array.isArray(e)?"array":typeof e,n=this.formatJson(e);return`[${t}] ${n}`}formatYaml(e){return this.toYaml(e,0)}toYaml(e,t){let n=" ".repeat(t);if(e===null||e===void 0)return"null";if(typeof e==="string")return e.includes(`
85
+ `)}k();function yr(e){return e.trim().split(`
86
+ `).filter((t)=>t.length>0)}async function le(e,t){switch(t??wr(e)){case"json":return JSON.parse(e);case"json5":{let{parseJSON5:r}=await Promise.resolve().then(() => (tt(),et));return r(e)}case"yaml":{let{parseYAML:r}=await Promise.resolve().then(() => (st(),rt));return r(e)}case"toml":{let{parseTOML:r}=await Promise.resolve().then(() => (it(),ot));return r(e)}case"xml":{let{parseXML:r}=await Promise.resolve().then(() => (ut(),at));return r(e)}case"ini":{let{parseINI:r}=await Promise.resolve().then(() => (pt(),lt));return r(e)}case"csv":{let{parseCSV:r}=await Promise.resolve().then(() => (Ne(),Ee));return r(e)}case"tsv":{let{parseTSV:r}=await Promise.resolve().then(() => (Ne(),Ee));return r(e)}case"protobuf":{let{parseProtobuf:r}=await Promise.resolve().then(() => dt);return r(e)}case"javascript":{let{parseJavaScript:r}=await Promise.resolve().then(() => ft);return r(e)}case"typescript":{let{parseTypeScript:r}=await Promise.resolve().then(() => (xt(),gt));return r(e)}case"env":{let{parseENV:r}=await Promise.resolve().then(() => (yt(),St));return r(e)}case"ndjson":{let{parseNDJSON:r}=await Promise.resolve().then(() => wt);return r(e)}case"lines":return yr(e);case"text":default:return e}}function wr(e){let t=e.trim();if(S.TS_INTERFACE.test(t)||S.TS_TYPE_ALIAS.test(t)||S.TS_TYPE_ANNOTATION.test(t))return"typescript";if(S.JS_EXPORT.test(t))return"javascript";if(t.startsWith("<")&&t.includes(">")){let u=t.startsWith("<?xml"),l=/<\/\w+>/.test(t);if(u||l)return"xml"}if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),"json"}catch{if(S.JSON5_FEATURES.test(t))return"json5"}if(t.includes("=")){if(S.ENV_FEATURES.test(t))return"env";if(t.match(S.TOML_QUOTED_VALUES))return"toml";if(t.match(S.SECTION_HEADER)){if(t.match(S.TOML_SECTION)&&t.match(S.TOML_SYNTAX))return"toml";if(t.match(S.INI_SYNTAX))return"ini"}if(t.match(S.INI_SYNTAX))return"ini"}if(t.includes("---")||t.includes(": ")||t.match(/^[\s]*-\s+/m))return"yaml";let c=t.split(`
87
+ `);if(c.length>1){let u=S.NDJSON_FEATURES.test(t),l=c.every((y)=>{let x=y.trim();if(!x)return!0;try{return JSON.parse(x),!0}catch{return!1}});if(u&&l)return"ndjson";let p=c[0],d=(p.match(/,/g)||[]).length,h=(p.match(/\t/g)||[]).length;if(h>0&&h>=d)return"tsv";if(d>0)return"csv";return"lines"}return"text"}async function Et(e){let t=[];for await(let r of process.stdin)t.push(r);let n=Buffer.concat(t).toString("utf-8").trim();if(!n)return null;return le(n,e)}import{readdir as Tr,stat as Tt}from"fs/promises";import{join as Or,extname as vr,basename as Ir}from"path";var Er=[".ts",".js",".tsx",".jsx"],Nr=[".json",".yml",".yaml"],Ar=[".md",".txt"],Nt=[...Er,...Nr,...Ar];var At=/[.*+?^${}()|[\]\\]/g;async function pe(e,t=!0){let r=await Bun.file(e).text();if(!t)return r;return le(r)}function Cr(e,t){return{path:e,name:Ir(e),ext:vr(e),size:Number(t.size),isDirectory:t.isDirectory(),isFile:t.isFile(),modified:t.mtime,created:t.birthtime}}async function Rr(e){let t=await Tt(e);return Cr(e,t)}function Mr(e){return e.startsWith(".")}function Fr(e,t){return t||!Mr(e)}function Lr(e,t){if(t===void 0)return!0;return t.includes(e)}function Pr(e,t){if(t===void 0)return!0;return t.test(e)}function kr(e,t,n){let r=Lr(e.ext,t),o=Pr(e.name,n);return r&&o}function _r(e,t){return e<=(t??1/0)}async function Br(e,t,n,r){if(!Fr(t,r.includeHidden??!1))return[];let s=Or(e,t),i=await Rr(s);if(i.isFile)return kr(i,r.extensions,r.pattern)?[i]:[];if(!i.isDirectory)return[];let a=r.recursive===!0?await Ot(s,n+1,r):[];return[i,...a]}async function Ot(e,t,n){if(!_r(t,n.maxDepth))return[];let o=await Tr(e);return(await Promise.all(o.map((i)=>Br(e,i,t,n)))).flat()}async function Ae(e,t={}){return Ot(e,0,t)}function jr(e,t){if(typeof e!=="string")return e;return new RegExp(e,t?"gi":"g")}function Dr(e,t,n,r,o,s){let i={file:e,line:t+1,column:n+1,match:r};if(s===void 0)return i;let a=Math.max(0,t-s),u=Math.min(o.length,t+s+1);return{...i,context:o.slice(a,u)}}function Vr(e,t,n){if(!n)return;let r=t instanceof Error?t.message:String(t);console.error(`Failed to search ${e}: ${r}`)}function $r(e,t,n,r,o,s){return[...e.matchAll(n)].map((c)=>Dr(r,t,c.index,e,o,s))}async function vt(e,t,n){try{let r=await pe(e,!1);if(typeof r!=="string")return[];let s=r.split(`
88
+ `),i=s.flatMap((a,u)=>$r(a,u,t,e,s,n.context)),c=n.maxMatches??1/0;return i.slice(0,c)}catch(r){return Vr(e,r,n.verbose??!1),[]}}async function Gr(e,t,n){let r=await Ae(e,{recursive:!0,extensions:[...Nt]});return(await Promise.all(r.filter((s)=>s.isFile).map((s)=>vt(s.path,t,n)))).flat()}async function It(e,t,n={}){let r=jr(e,n.ignoreCase??!1),o=await Tt(t);if(o.isFile())return vt(t,r,n);if(o.isDirectory()&&n.recursive)return Gr(t,r,n);return[]}var Rt={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},Mt="+-*/%<>!&|=",Ft=[" ","\t",`
89
+ `,"\r"];function _(e,t,n){return{type:e,value:t,position:n}}class H{input;position=0;current;constructor(e){this.input=e,this.current=this.input[0]||""}tokenize(){let e=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let t=this.nextToken();if(t)e.push(t)}return e.push(_("EOF","",this.position)),e}nextToken(){let e=this.position,t=Rt[this.current];if(t){let u=this.current;return this.advance(),_(t,u,e)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),_("ARROW","=>",e);if(this.current==='"'||this.current==="'")return this.readString();let o=this.isDigit(this.current),s=this.current==="-"&&this.isDigit(this.peek());if(o||s)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let e=this.position,t=this.current,n=[];this.advance();while(this.current!==t&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===t)this.advance();return _("STRING",n.join(""),e)}readNumber(){let e=this.position,t="";if(this.current==="-")t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){t+=this.current,this.advance();while(this.isDigit(this.current))t+=this.current,this.advance()}return _("NUMBER",t,e)}readIdentifier(){let e=this.position,t="";while(this.isIdentifierChar(this.current))t+=this.current,this.advance();return _("IDENTIFIER",t,e)}readOperator(){let e=this.position,t="";while(this.isOperator(this.current))t+=this.current,this.advance();return _("OPERATOR",t,e)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(e){return Ft.includes(e)}isDigit(e){return e>="0"&&e<="9"}isIdentifierStart(e){let t=e>="a"&&e<="z",n=e>="A"&&e<="Z";return t||n||e==="_"||e==="$"}isIdentifierChar(e){return this.isIdentifierStart(e)||this.isDigit(e)}isOperator(e){return Mt.includes(e)}}var v=(e)=>{return{type:"Literal",value:e}},Te=(e)=>{if(e==="true")return v(!0);if(e==="false")return v(!1);if(e==="null")return v(null);return};function C(e,t){return`${t} at position ${e.position} (got ${e.type}: "${e.value}")`}function B(e,t){return{type:"PropertyAccess",property:e,object:t}}function Wr(e,t){return{type:"IndexAccess",index:e,object:t}}function Jr(e,t,n){return{type:"SliceAccess",start:e,end:t,object:n}}function Lt(e,t,n){return{type:"MethodCall",method:e,args:t,object:n}}function Ur(e,t){return{type:"ObjectOperation",operation:e,object:t}}function zr(e){return{type:"ArraySpread",object:e}}function Qr(e,t){return{type:"ArrowFunction",params:e,body:t}}function Oe(e){return{type:"Root",expression:e}}var Pt=["keys","values","entries","length"];function Hr(e){return Pt.includes(e)}class K{tokens;position=0;current;constructor(e){this.tokens=e,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return Oe();let t=this.parseExpression();return Oe(t)}parseExpression(){return this.parsePrimary()}parsePrimary(){let e=this.parsePrimaryNode();return this.parsePostfix(e)}parsePrimaryNode(){let e=this.current.type;if(e==="DOT")return this.advance(),this.parseAccessChain();if(e==="LEFT_BRACKET")return this.parseArrayAccess();if(e==="IDENTIFIER")return this.parseIdentifierOrFunction();if(e==="STRING"){let t=this.current.value;return this.advance(),v(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),v(t)}if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}throw Error(C(this.current,"Unexpected token"))}parseAccessChain(e){let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;return this.advance(),B(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(C(this.current,"Expected property name after dot"))}parseBracketAccess(e){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),zr(e);if(this.current.type==="STRING"){let c=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),B(c,e)}let r=this.current.type==="NUMBER",o=this.current.type==="OPERATOR"&&this.current.value==="-",s=this.current.type==="COLON";if(r||o||s)return this.parseNumericIndexOrSlice(e);throw Error(C(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(e){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,e);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,e);return this.expect("RIGHT_BRACKET"),Wr(n,e)}parseSliceFromColon(e,t){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",o=n||r,s=o?this.parseNumber():void 0;if(o)this.advance();return this.expect("RIGHT_BRACKET"),Jr(e,s,t)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(e){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(C(this.current,"Expected operation name after {"));let n=this.current.value;if(!Hr(n)){let r=Pt.join(", ");throw Error(C(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),Ur(n,e)}parseIdentifierOrFunction(){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);let n=Te(e);if(n)return n;return B(e)}parseArrowFunction(e){this.expect("ARROW");let t=this.parseFunctionBody();return Qr(e,t)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),t}return this.parseBinaryExpression()}parseBinaryExpression(){let e=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let t=this.current.value;this.advance();let n=this.parseFunctionTerm();e=Lt(`__operator_${t}__`,[n],e)}return e}parseFunctionTerm(){let e=this.current.type;if(e==="IDENTIFIER")return this.parseIdentifierChain();if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),v(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),v(t)}if(e==="LEFT_PAREN"){this.advance();let t=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),t}throw Error(C(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let e=this.current.value;this.advance();let t=Te(e);if(t)return t;let n=B(e),r=()=>this.current.type==="DOT",o=()=>this.current.type==="IDENTIFIER";while(r()){if(this.advance(),!o())break;let s=this.current.value;this.advance(),n=B(s,n)}return n}parseMethodCall(e,t){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),Lt(t,n,e)}parseMethodArguments(){let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let t=this.parseMethodArgument();if(e.push(t),this.current.type==="COMMA")this.advance()}return e}parseMethodArgument(){let e=this.current.type;if(e==="LEFT_PAREN"){let t=this.parseFunctionParams();return this.parseArrowFunction(t)}if(e==="IDENTIFIER"){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);return B(t)}if(e==="NUMBER"){let t=Number(this.current.value);return this.advance(),v(t)}if(e==="STRING"){let t=this.current.value;return this.advance(),v(t)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let e=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")e.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),e}parsePostfix(e){let t=e;while(!0){let n=this.current.type;if(n==="DOT"){t=this.parsePostfixDot(t);continue}if(n==="LEFT_BRACKET"){t=this.parseBracketAccess(t);continue}if(n==="LEFT_PAREN"){if(t.type==="PropertyAccess"&&!t.object){let s=t.property;t=this.parseMethodCall(Oe(),s);continue}}break}return t}parsePostfixDot(e){this.advance();let t=this.current.type;if(t==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(e,n);return B(n,e)}if(t==="LEFT_BRACKET")return this.parseBracketAccess(e);if(t==="LEFT_BRACE")return this.parseObjectOperation(e);throw Error(C(this.current,"Expected property name after dot"))}parseNumber(){let e=this.current.value==="-";if(e)this.advance();if(this.current.type!=="NUMBER")throw Error(C(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return e?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(e){if(this.current.type!==e)throw Error(C(this.current,`Expected ${e} but got ${this.current.type}`));this.advance()}}var Kr={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,"&&":(e,t)=>e&&t,"||":(e,t)=>e||t};function kt(e){return e.startsWith("__operator_")&&e.endsWith("__")}function _t(e){return e.slice(11,-2)}function Bt(e,t,n){let r=Kr[t];if(!r)throw Error(`Unknown operator: ${t}`);return r(e,n)}function Xr(e,t){return Object.fromEntries(e.map((n,r)=>[n,t[r]]))}function ve(e){return Object.values(e)[0]}function Dt(e){return e!==null&&typeof e==="object"}function Ie(e,t){if(!Dt(e))return;return e[t]}function Ce(e,t){return e<0?t+e:e}function qr(e,t){if(!Array.isArray(e))return;let n=Ce(t,e.length);return e[n]}function Yr(e,t,n){if(!Array.isArray(e))return;let r=e.length,o=t!==void 0?Ce(t,r):0,s=n!==void 0?Ce(n,r):r;return e.slice(o,s)}function Zr(e,t){if(!Dt(e))return;switch(t){case"keys":return Object.keys(e);case"values":return Object.values(e);case"entries":return Object.entries(e);case"length":return Array.isArray(e)?e.length:Object.keys(e).length}}function jt(e,t,n){let r=e;if(!(e!==null&&e!==void 0&&typeof r[t]==="function"))throw Error(`Method ${t} does not exist on ${typeof e}`);try{return r[t].call(e,...n)}catch(s){let i=s instanceof Error?s.message:String(s);throw Error(`Error executing method ${t}: ${i}`)}}class X{evaluate(e,t){switch(e.type){case"Root":return e.expression?this.evaluate(e.expression,t):t;case"PropertyAccess":return this.evaluatePropertyAccess(e,t);case"IndexAccess":return qr(e.object?this.evaluate(e.object,t):t,e.index);case"SliceAccess":return Yr(e.object?this.evaluate(e.object,t):t,e.start,e.end);case"ArraySpread":return e.object?this.evaluate(e.object,t):t;case"MethodCall":return this.evaluateMethodCall(e,t);case"ObjectOperation":return Zr(e.object?this.evaluate(e.object,t):t,e.operation);case"Literal":return e.value;case"ArrowFunction":return this.createFunction(e);default:throw Error(`Unknown AST node type: ${e.type}`)}}evaluatePropertyAccess(e,t){let n=e.object?this.evaluate(e.object,t):t;return Ie(n,e.property)}evaluateMethodCall(e,t){let n=e.object?this.evaluate(e.object,t):t;if(kt(e.method)){let s=_t(e.method),i=this.evaluate(e.args[0],t);return Bt(n,s,i)}let o=e.args.map((s)=>{return s.type==="ArrowFunction"?this.createFunction(s):this.evaluate(s,t)});return jt(n,e.method,o)}createFunction(e){return(...t)=>{let n=Xr(e.params,t);return this.evaluateFunctionBody(e.body,n)}}evaluateFunctionBody(e,t){switch(e.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(e,t);case"MethodCall":return this.evaluateMethodCallInFunction(e,t);case"Literal":return e.value;case"Root":return e.expression?this.evaluateFunctionBody(e.expression,t):t;default:return this.evaluate(e,ve(t))}}evaluatePropertyAccessInFunction(e,t){if(e.object!==void 0){let s=this.evaluateFunctionBody(e.object,t);return Ie(s,e.property)}if(Object.prototype.hasOwnProperty.call(t,e.property))return t[e.property];let o=ve(t);return Ie(o,e.property)}evaluateMethodCallInFunction(e,t){let n=e.object?this.evaluateFunctionBody(e.object,t):ve(t);if(kt(e.method)){let s=_t(e.method),i=this.evaluateFunctionBody(e.args[0],t);return Bt(n,s,i)}let o=e.args.map((s)=>this.evaluateFunctionBody(s,t));return jt(n,e.method,o)}}var b={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"},es=[{regex:/"([^"]+)":/g,replacement:`${b.cyan}"$1"${b.reset}:`},{regex:/: "([^"]*)"/g,replacement:`: ${b.green}"$1"${b.reset}`},{regex:/: (-?\d+\.?\d*)/g,replacement:`: ${b.yellow}$1${b.reset}`},{regex:/: (true|false)/g,replacement:`: ${b.magenta}$1${b.reset}`},{regex:/: (null)/g,replacement:`: ${b.gray}$1${b.reset}`},{regex:/([{[])/g,replacement:`${b.gray}$1${b.reset}`},{regex:/([}\]])/g,replacement:`${b.gray}$1${b.reset}`}];function Vt(e){if(process.env.NO_COLOR)return e;return es.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function $t(e){if(process.env.NO_COLOR)return e;return`${b.yellow}${e}${b.reset}`}function Re(e){if(process.env.NO_COLOR)return e;return`${b.cyan}${e}${b.reset}`}class q{options;constructor(e){this.options=e}format(e){if(this.options.raw)return this.formatRaw(e);if(this.options.type)return this.formatWithType(e);switch(this.options.format){case"yaml":return this.formatYaml(e);case"csv":return this.formatCsv(e);case"table":return this.formatTable(e);default:return this.formatJson(e)}}formatRaw(e){if(typeof e==="string")return e;if(e===void 0)return"";if(e===null)return"null";if(typeof e==="object")return JSON.stringify(e);return String(e)}formatJson(e){if(e===void 0)return"undefined";if(this.options.compact)return JSON.stringify(e);if(this.options.pretty){let t=JSON.stringify(e,null,2);return Vt(t)}return JSON.stringify(e,null,2)}formatWithType(e){let t=Array.isArray(e)?"array":typeof e,n=this.formatJson(e);return`[${t}] ${n}`}formatYaml(e){return this.toYaml(e,0)}toYaml(e,t){let n=" ".repeat(t);if(e===null||e===void 0)return"null";if(typeof e==="string")return e.includes(`
90
90
  `)||e.includes('"')||e.includes("'")?`|
91
91
  ${n} ${e.replace(/\n/g,`
92
92
  `+n+" ")}`:e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"[]";return e.map((r)=>`${n}- ${this.toYaml(r,t+2).trim()}`).join(`
93
- `)}if(typeof e==="object"){let r=Object.entries(e);if(r.length===0)return"{}";return r.map(([i,s])=>{let o=this.toYaml(s,t+2);if(typeof s==="object"&&s!==null)return`${n}${i}:
94
- ${o}`;return`${n}${i}: ${o}`}).join(`
95
- `)}return String(e)}formatCsv(e){if(!Array.isArray(e))return this.formatJson(e);if(e.length===0)return"";if(typeof e[0]==="object"&&e[0]!==null&&!Array.isArray(e[0])){let t=Object.keys(e[0]),n=t.join(","),r=e.map((i)=>t.map((s)=>this.escapeCsvValue(i[s])).join(","));return[n,...r].join(`
93
+ `)}if(typeof e==="object"){let r=Object.entries(e);if(r.length===0)return"{}";return r.map(([o,s])=>{let i=this.toYaml(s,t+2);if(typeof s==="object"&&s!==null)return`${n}${o}:
94
+ ${i}`;return`${n}${o}: ${i}`}).join(`
95
+ `)}return String(e)}formatCsv(e){if(!Array.isArray(e))return this.formatJson(e);if(e.length===0)return"";if(typeof e[0]==="object"&&e[0]!==null&&!Array.isArray(e[0])){let t=Object.keys(e[0]),n=t.join(","),r=e.map((o)=>t.map((s)=>this.escapeCsvValue(o[s])).join(","));return[n,...r].join(`
96
96
  `)}return e.map((t)=>this.escapeCsvValue(t)).join(`
97
97
  `)}escapeCsvValue(e){if(e===null||e===void 0)return"";let t=String(e);if(t.includes(",")||t.includes('"')||t.includes(`
98
98
  `))return`"${t.replace(/"/g,'""')}"`;return t}formatTable(e){if(!Array.isArray(e))return this.formatJson(e);if(e.length===0)return"(empty array)";if(typeof e[0]==="object"&&e[0]!==null&&!Array.isArray(e[0]))return this.formatObjectTable(e);return e.map((t,n)=>`${n}: ${this.formatRaw(t)}`).join(`
99
- `)}formatObjectTable(e){let t=[...new Set(e.flatMap((o)=>Object.keys(o)))],n={};t.forEach((o)=>{n[o]=Math.max(o.length,...e.map((u)=>String(u[o]??"").length))});let r=t.map((o)=>o.padEnd(n[o])).join(" | "),i=t.map((o)=>"-".repeat(n[o])).join("-+-"),s=e.map((o)=>t.map((u)=>String(o[u]??"").padEnd(n[u])).join(" | "));return[r,i,...s].join(`
100
- `)}}var C={ERROR:0,WARN:1,INFO:2,DEBUG:3};var tr={ERROR:C.ERROR,WARN:C.WARN,INFO:C.INFO,DEBUG:C.DEBUG},xs=process.env.LOG_LEVEL?tr[process.env.LOG_LEVEL]||C.INFO:C.INFO;function Ce(e){return e.replace(He,"\\$&")}var y=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".fndIdx",full:".findIndex",description:"Find index of first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".psh",full:".push",description:"Add to end",type:"array"},{short:".pp",full:".pop",description:"Remove from end",type:"array"},{short:".shft",full:".shift",description:"Remove from start",type:"array"},{short:".unshft",full:".unshift",description:"Add to start",type:"array"},{short:".fltMap",full:".flatMap",description:"Map and flatten",type:"array"},{short:".flt1",full:".flat",description:"Flatten array",type:"array"},{short:".incl",full:".includes",description:"Check if includes",type:"array"},{short:".idxOf",full:".indexOf",description:"Find index",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".trmSt",full:".trimStart",description:"Remove leading whitespace",type:"string"},{short:".trmEnd",full:".trimEnd",description:"Remove trailing whitespace",type:"string"},{short:".rpl",full:".replace",description:"Replace text",type:"string"},{short:".rplAll",full:".replaceAll",description:"Replace all occurrences",type:"string"},{short:".pdSt",full:".padStart",description:"Pad start",type:"string"},{short:".pdEnd",full:".padEnd",description:"Pad end",type:"string"},{short:".stsWith",full:".startsWith",description:"Check if starts with",type:"string"},{short:".endsWith",full:".endsWith",description:"Check if ends with",type:"string"},{short:".sbstr",full:".substring",description:"Extract substring",type:"string"},{short:".chr",full:".charAt",description:"Get character at index",type:"string"},{short:".chrCd",full:".charCodeAt",description:"Get character code",type:"string"},{short:".mtch",full:".match",description:"Match pattern",type:"string"},{short:".str",full:".toString",description:"Convert to string",type:"any"},{short:".json",full:".toJSON",description:"Convert to JSON",type:"any"},{short:".val",full:".valueOf",description:"Get primitive value",type:"any"}],Is=new Map(y.map((e)=>[e.short,e.full])),Rs=new Map(y.map((e)=>[e.full,e.short])),nr=y.map((e)=>({regex:new RegExp(`${Ce(e.short)}(?![a-zA-Z])`,"g"),replacement:e.full})).sort((e,t)=>t.replacement.length-e.replacement.length),rr=y.map((e)=>({regex:new RegExp(`${Ce(e.full)}(?![a-zA-Z])`,"g"),replacement:e.short})).sort((e,t)=>t.regex.source.length-e.regex.source.length);function Fe(e){return nr.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function lt(e){return rr.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function mt(){let e=y.filter((s)=>s.type==="array"),t=y.filter((s)=>s.type==="object"),n=y.filter((s)=>s.type==="string"),r=y.filter((s)=>s.type==="any"),i=(s,o)=>{let u=Math.max(...o.map((l)=>l.short.length)),c=Math.max(...o.map((l)=>l.full.length)),a=`
99
+ `)}formatObjectTable(e){let t=[...new Set(e.flatMap((i)=>Object.keys(i)))],n={};t.forEach((i)=>{n[i]=Math.max(i.length,...e.map((c)=>String(c[i]??"").length))});let r=t.map((i)=>i.padEnd(n[i])).join(" | "),o=t.map((i)=>"-".repeat(n[i])).join("-+-"),s=e.map((i)=>t.map((c)=>String(i[c]??"").padEnd(n[c])).join(" | "));return[r,o,...s].join(`
100
+ `)}}var j={ERROR:0,WARN:1,INFO:2,DEBUG:3};var ts={ERROR:j.ERROR,WARN:j.WARN,INFO:j.INFO,DEBUG:j.DEBUG},Yo=process.env.LOG_LEVEL?ts[process.env.LOG_LEVEL]||j.INFO:j.INFO;function Me(e){return e.replace(At,"\\$&")}var M=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".fndIdx",full:".findIndex",description:"Find index of first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".psh",full:".push",description:"Add to end",type:"array"},{short:".pp",full:".pop",description:"Remove from end",type:"array"},{short:".shft",full:".shift",description:"Remove from start",type:"array"},{short:".unshft",full:".unshift",description:"Add to start",type:"array"},{short:".fltMap",full:".flatMap",description:"Map and flatten",type:"array"},{short:".flt1",full:".flat",description:"Flatten array",type:"array"},{short:".incl",full:".includes",description:"Check if includes",type:"array"},{short:".idxOf",full:".indexOf",description:"Find index",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".trmSt",full:".trimStart",description:"Remove leading whitespace",type:"string"},{short:".trmEnd",full:".trimEnd",description:"Remove trailing whitespace",type:"string"},{short:".rpl",full:".replace",description:"Replace text",type:"string"},{short:".rplAll",full:".replaceAll",description:"Replace all occurrences",type:"string"},{short:".pdSt",full:".padStart",description:"Pad start",type:"string"},{short:".pdEnd",full:".padEnd",description:"Pad end",type:"string"},{short:".stsWith",full:".startsWith",description:"Check if starts with",type:"string"},{short:".endsWith",full:".endsWith",description:"Check if ends with",type:"string"},{short:".sbstr",full:".substring",description:"Extract substring",type:"string"},{short:".chr",full:".charAt",description:"Get character at index",type:"string"},{short:".chrCd",full:".charCodeAt",description:"Get character code",type:"string"},{short:".mtch",full:".match",description:"Match pattern",type:"string"},{short:".str",full:".toString",description:"Convert to string",type:"any"},{short:".json",full:".toJSON",description:"Convert to JSON",type:"any"},{short:".val",full:".valueOf",description:"Get primitive value",type:"any"}],ui=new Map(M.map((e)=>[e.short,e.full])),li=new Map(M.map((e)=>[e.full,e.short])),ns=M.map((e)=>({regex:new RegExp(`${Me(e.short)}(?![a-zA-Z])`,"g"),replacement:e.full})).sort((e,t)=>t.replacement.length-e.replacement.length),rs=M.map((e)=>({regex:new RegExp(`${Me(e.full)}(?![a-zA-Z])`,"g"),replacement:e.short})).sort((e,t)=>t.regex.source.length-e.regex.source.length);function Y(e){return ns.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function Gt(e){return rs.reduce((t,{regex:n,replacement:r})=>t.replace(n,r),e)}function Wt(){let e=M.filter((s)=>s.type==="array"),t=M.filter((s)=>s.type==="object"),n=M.filter((s)=>s.type==="string"),r=M.filter((s)=>s.type==="any"),o=(s,i)=>{let c=Math.max(...i.map((p)=>p.short.length)),a=Math.max(...i.map((p)=>p.full.length)),u=`
101
101
  ${s}:
102
- `,p=o.map((l)=>` ${l.short.padEnd(u+2)} \u2192 ${l.full.padEnd(c+2)} # ${l.description}`).join(`
103
- `);return a+p};return`
102
+ `,l=i.map((p)=>` ${p.short.padEnd(c+2)} \u2192 ${p.full.padEnd(a+2)} # ${p.description}`).join(`
103
+ `);return u+l};return`
104
104
  Shorthand Reference:
105
- ${i("Array Methods",e)}
106
- ${i("Object Methods",t)}
107
- ${i("String Methods",n)}
108
- ${i("Universal Methods",r)}
105
+ ${o("Array Methods",e)}
106
+ ${o("Object Methods",t)}
107
+ ${o("String Methods",n)}
108
+ ${o("Universal Methods",r)}
109
109
 
110
110
  Examples:
111
111
  echo '[1,2,3]' | 1ls '.mp(x => x * 2)' # Short form
@@ -113,4 +113,43 @@ Examples:
113
113
 
114
114
  1ls --shorten ".map(x => x * 2)" # Returns: .mp(x => x * 2)
115
115
  1ls --expand ".mp(x => x * 2)" # Returns: .map(x => x * 2)
116
- `}async function sr(e){if(e.help)K(),process.exit(0);if(e.version){let t=await Bun.file("package.json").json();console.log(`1ls version ${t.version}`),process.exit(0)}return!1}async function ir(e){if(e.shortcuts)console.log(mt()),process.exit(0);if(e.shorten){let t=lt(e.shorten);console.log(t),process.exit(0)}if(e.expand){let t=Fe(e.expand);console.log(t),process.exit(0)}return!1}async function or(e){if(e.list){let n=await Ae(e.list,{recursive:e.recursive,extensions:e.extensions,maxDepth:e.maxDepth}),r=new B(e);return console.log(r.format(n)),!0}if(e.grep&&e.find)return await cr(e),!0;return!1}async function cr(e){let t=await qe(e.grep,e.find,{recursive:e.recursive,ignoreCase:e.ignoreCase,showLineNumbers:e.showLineNumbers});if(t.length===0){console.log(pt("No matches found"));return}for(let n of t){let r=`${Re(n.file)}:${n.line}:${n.column}`,i=e.showLineNumbers?`${r}: ${n.match}`:`${Re(n.file)}: ${n.match}`;console.log(i)}}async function ur(e,t){if(e.readFile){let s=t[t.indexOf("readFile")+1],o=await Ee(s);return e.expression=t[t.indexOf("readFile")+2]||".",o}let n=!process.stdin.isTTY,r=e.list||e.grep;if(!n&&!r)K(),process.exit(1);if(n)return await Je(e.inputFormat);return null}async function ar(e,t){if(!e.expression){let n=new B(e);console.log(n.format(t));return}try{let n=Fe(e.expression),i=new Oe(n).tokenize(),o=new ye(i).parse(),c=new Ie().evaluate(o,t),a=new B(e);console.log(a.format(c))}catch(n){console.error("Error:",n.message),process.exit(1)}}async function pr(e){let t=_e(e);if(await sr(t),await ir(t),await or(t))return;let r=await ur(t,e);await ar(t,r)}if(import.meta.main)pr(process.argv.slice(2)).catch((e)=>{console.error("Error:",e.message),process.exit(1)});export{pr as main};
116
+ `}import{stdin as Ue,stdout as ne,exit as ze}from"process";var he=(e)=>{if(e===null)return"null";if(Array.isArray(e))return"Array";let t=typeof e;return t.charAt(0).toUpperCase()+t.slice(1)},me=(e,t)=>{if(t==="null")return"null";if(t==="String")return`"${e}"`;if(t==="Array")return`[${e.length} items]`;if(t==="Object")return`{${Object.keys(e).length} keys}`;return String(e)},Fe=(e,t="",n=[])=>{if(e===null||e===void 0){let i=he(e),c=me(e,i);return n.push({path:t||".",value:e,type:i,displayValue:c}),n}if(Array.isArray(e)){let i=he(e),c=me(e,i),a=t||".";return n.push({path:a,value:e,type:i,displayValue:c}),e.forEach((u,l)=>{let p=t?`${t}[${l}]`:`.[${l}]`;Fe(u,p,n)}),n}if(typeof e==="object"){let i=he(e),c=me(e,i),a=t||".";if(t)n.push({path:a,value:e,type:i,displayValue:c});return Object.entries(e).forEach(([l,p])=>{let d=/[^a-zA-Z0-9_$]/.test(l),h=t?d?`${t}["${l}"]`:`${t}.${l}`:d?`.["${l}"]`:`.${l}`;Fe(p,h,n)}),n}let r=he(e),o=me(e,r),s=t||".";return n.push({path:s,value:e,type:r,displayValue:o}),n},de=(e)=>{return Fe(e)};var ss=(e,t,n)=>{let r=n.length*100,o=(p,d,h)=>{if(h===0)return p;let w=n[h-1]===d-1?5:0;return p+w},s=n.reduce(o,0),a=n[0]===0?10:0,u=e.length-t.length;return r+s+a-u},os=(e,t)=>{let n=e.toLowerCase(),r=t.toLowerCase(),o=[],s=0,i=0,c=()=>{let u=s<n.length,l=i<r.length;return u&&l};while(c()){let u=n[s],l=r[i];if(u===l)o.push(s),i=i+1;s=s+1}return i===r.length?o:null},is=(e,t,n)=>{let r=os(t,n);if(!r)return null;let s=ss(t,n,r);return Object.assign({},{item:e,score:s,matches:r})},cs=(e,t)=>t.score-e.score,R=(e,t,n)=>{if(!t){let u=(l)=>{return Object.assign({},{item:l,score:0,matches:[]})};return e.map(u)}let o=(u)=>{let l=n(u);return is(u,l,t)},s=e.map(o),i=(u)=>u!==null;return s.filter(i).sort(cs)};var Jt=(e,t)=>{let n=R(e,"",(o)=>o.path);return Object.assign({},{mode:"explore",paths:e,matches:n,query:"",selectedIndex:0,builder:null,originalData:t,methodMatches:[],propertyMatches:[]})},Le=(e,t)=>{let n=R(e.paths,t,(s)=>s.path),r=n.length>0?0:e.selectedIndex;return Object.assign({},e,{query:t,matches:n,selectedIndex:r})},D=(e,t)=>{let n=e.mode==="explore",r=e.mode==="build",o=n?e.matches.length:r?e.methodMatches.length:e.propertyMatches.length;if(o===0)return e;let c=e.selectedIndex+t;if(c<0)c=o-1;else if(c>=o)c=0;return Object.assign({},e,{selectedIndex:c})},Ut=(e)=>{let t=e.matches.length>0,n=e.selectedIndex>=0&&e.selectedIndex<e.matches.length;if(t&&n)return e.matches[e.selectedIndex].item;return null};import{stdout as ee}from"process";import{stdout as Pe}from"process";var V=()=>{Pe.write("\x1B[2J\x1B[H")};var zt=()=>{Pe.write("\x1B[?25l")},Qt=()=>{Pe.write("\x1B[?25h")},Ht=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!0);process.stdin.resume()},Kt=()=>{if(process.stdin.setRawMode!==void 0)process.stdin.setRawMode(!1);process.stdin.pause()},m=Object.assign({},{reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",cyan:"\x1B[36m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",gray:"\x1B[90m"}),f=(e,t)=>{let n=m.reset;return t.concat(e,n)},Z=(e,t)=>{let n=e.split(""),r=m.bright.concat(m.cyan),o=(c,a)=>{return t.includes(a)?f(c,r):c};return n.map(o).join("")};import{stdout as F}from"process";var A=10,as=(e,t)=>Z(e,t),us=(e)=>{let t=`[${e}]`;return f(t,m.dim)},ls=(e)=>f(e,m.gray),Xt=(e)=>{let t=f("\u276F",m.green),n=" ";return e?t:" "},ps=(e,t,n)=>{let r=Xt(t),o=as(e.signature,n),s=e.category?us(e.category):"",i=ls(e.description);return r.concat(" ",o).concat(s?" "+s:"").concat(" - ",i)},hs=(e,t)=>{let{item:n,matches:r}=e,o=Xt(t),s=Z(n.path,r),i=f(`[${n.type}]`,m.dim),c=f(n.displayValue,m.gray);return o.concat(" ",s).concat(" ",i).concat(" ",c)},ms=(e)=>{if(e.builder===null)return"";let n="Expression Builder",r=m.bright.concat(m.cyan),o=f(n,r),s=e.builder.expression,i=`
117
+
118
+ Building: `,c=f(s,m.bright.concat(m.yellow)),a=`
119
+
120
+ Search methods for `,u=f(e.builder.baseType,m.bright),l=": ",p=e.query;return o.concat(i,c).concat(a,u,l,p,`
121
+
122
+ `)},ds=(e)=>{let t=e.builder!==null,n=e.builder?.arrowFnContext!==null;if(!t||!n)return"";let r="Expression Builder - Arrow Function",o=m.bright.concat(m.cyan),s=f(r,o),i=e.builder.expression,c=`
123
+
124
+ Building: `,a=f(i,m.bright.concat(m.yellow)),u=e.builder.arrowFnContext,l=`
125
+
126
+ Search properties for '${u.paramName}' (${u.paramType}): `,p=e.query;return s.concat(c,a).concat(l,p,`
127
+
128
+ `)},fs=(e)=>{if(e.builder===null)return"";let{methodMatches:n,selectedIndex:r}=e;if(n.length===0)return f("No methods found",m.dim);let o=Math.floor(A/2),s=Math.max(0,r-o),i=Math.min(n.length,s+A);if(i-s<A&&n.length>=A)s=Math.max(0,i-A);let a=n.slice(s,i),u=(d,h)=>{let y=s+h===r;return ps(d.item,y,d.matches)};return a.map(u).join(`
129
+ `)},gs=(e)=>{let t=e.builder===null,n=e.builder?.arrowFnContext===null;if(t||n)return"";let{propertyMatches:r,selectedIndex:o}=e;if(r.length===0)return f("No properties found",m.dim);let s=Math.floor(A/2),i=Math.max(0,o-s),c=Math.min(r.length,i+A);if(c-i<A&&r.length>=A)i=Math.max(0,c-A);let u=r.slice(i,c),l=(h,g)=>{let x=i+g===o;return hs(h,x)};return u.map(l).join(`
130
+ `)},qt=(e)=>{let t=e-A;if(t>0){let r=`
131
+
132
+ ... `.concat(String(t)," more");return f(r,m.dim)}return""},Yt=()=>{let e=`
133
+
134
+ `.concat(f("\u2191/\u2193",m.bright)," navigate ",f("\u2192/Tab",m.bright)," accept ",f("\u2190",m.bright)," undo ",f("Enter",m.bright)," execute ",f("Esc",m.bright)," quit");return f(e,m.dim)},Zt=(e)=>{V();let t=ms(e);F.write(t);let n=fs(e);F.write(n);let r=e.methodMatches.length,o=qt(r);F.write(o);let s=Yt();F.write(s)},en=(e)=>{V();let t=ds(e);F.write(t);let n=gs(e);F.write(n);let r=e.propertyMatches.length,o=qt(r);F.write(o);let s=Yt();F.write(s)};var J=10,xs=(e,t)=>Z(e,t),bs=(e)=>{let r="[".concat(e,"]");return f(r,m.dim)},Ss=(e)=>f(e,m.gray),ys=(e)=>{let t=f("\u276F",m.green),n=" ";return e?t:" "},ws=(e,t)=>{let{item:n,matches:r}=e,o=ys(t),s=xs(n.path,r),i=bs(n.type),c=Ss(n.displayValue);return o.concat(" ",s).concat(" ",i).concat(" ",c)},Es=()=>{let t=m.bright.concat(m.cyan);return f("1ls Interactive Explorer",t)},Ns=(e)=>{let t=Es(),n=`
135
+
136
+ Search: `;return t.concat(`
137
+
138
+ Search: `,e,`
139
+
140
+ `)},As=(e)=>{let t=e.selectedIndex,n=e.matches.length;if(n===0)return f("No matches found",m.dim);let r=Math.floor(J/2),o=Math.max(0,t-r),s=Math.min(n,o+J);if(s-o<J&&n>=J)o=Math.max(0,s-J);let c=e.matches.slice(o,s),a=(p,d)=>{let g=o+d===t;return ws(p,g)};return c.map(a).join(`
141
+ `)},Ts=(e)=>{let t=e.matches.length>0,n=e.selectedIndex>=0&&e.selectedIndex<e.matches.length;if(!t||!n)return"";let r=e.matches[e.selectedIndex].item,o=f(`
142
+
143
+ Preview:
144
+ `,m.bright),s="",i=r.type;if(i==="String"||i==="Number"||i==="Boolean"||i==="null")s=f(String(r.displayValue),m.cyan);else if(i==="Array"||i==="Object"){let a=JSON.stringify(r.value,null,2).split(`
145
+ `),u=a.slice(0,5),l=a.length>5;if(s=f(u.join(`
146
+ `),m.cyan),l)s=s.concat(f(`
147
+ ... (truncated)`,m.dim))}else s=f(String(r.value),m.cyan);return o.concat(s)},Os=(e)=>{let t=e-J;if(t>0){let r=`
148
+
149
+ ... `.concat(String(t)," more");return f(r,m.dim)}return""},vs=()=>{let e=`
150
+
151
+ `.concat(f("\u2191/\u2193",m.bright)," navigate ",f("Enter",m.bright)," select ",f("Tab",m.bright)," build ",f("Esc/q",m.bright)," quit");return f(e,m.dim)},Is=(e)=>{V();let t=Ns(e.query);ee.write(t);let n=As(e);ee.write(n);let r=Os(e.matches.length);ee.write(r);let o=Ts(e);ee.write(o);let s=vs();ee.write(s)},Cs={explore:Is,build:Zt,"build-arrow-fn":en},ke=(e)=>{let t=Cs[e.mode];t(e)};var Rs=[{name:"map",signature:".map(x => ...)",description:"Transform each item",template:".map(x => x)",category:"Transform"},{name:"filter",signature:".filter(x => ...)",description:"Filter by condition",template:".filter(x => x)",category:"Filter"},{name:"reduce",signature:".reduce((acc, x) => ..., initial)",description:"Reduce to single value",template:".reduce((acc, x) => acc, 0)",category:"Aggregate"},{name:"find",signature:".find(x => ...)",description:"Find first match",template:".find(x => x)",category:"Search"},{name:"findIndex",signature:".findIndex(x => ...)",description:"Find first match index",template:".findIndex(x => x)",category:"Search"},{name:"some",signature:".some(x => ...)",description:"Check if any match",template:".some(x => x)",category:"Test"},{name:"every",signature:".every(x => ...)",description:"Check if all match",template:".every(x => x)",category:"Test"},{name:"sort",signature:".sort((a, b) => ...)",description:"Sort items",template:".sort((a, b) => a - b)",category:"Transform"},{name:"reverse",signature:".reverse()",description:"Reverse order",template:".reverse()",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Get subset",template:".slice(0, 10)",category:"Transform"},{name:"concat",signature:".concat(arr)",description:"Combine arrays",template:".concat([])",category:"Transform"},{name:"join",signature:".join(separator)",description:"Join to string",template:".join(', ')",category:"Convert"},{name:"flat",signature:".flat(depth)",description:"Flatten nested arrays",template:".flat(1)",category:"Transform"},{name:"flatMap",signature:".flatMap(x => ...)",description:"Map then flatten",template:".flatMap(x => x)",category:"Transform"},{name:"length",signature:".length",description:"Get array length",template:".length",category:"Property"}],Ms=[{name:"toUpperCase",signature:".toUpperCase()",description:"Convert to uppercase",template:".toUpperCase()",category:"Transform"},{name:"toLowerCase",signature:".toLowerCase()",description:"Convert to lowercase",template:".toLowerCase()",category:"Transform"},{name:"trim",signature:".trim()",description:"Remove whitespace",template:".trim()",category:"Transform"},{name:"trimStart",signature:".trimStart()",description:"Remove leading whitespace",template:".trimStart()",category:"Transform"},{name:"trimEnd",signature:".trimEnd()",description:"Remove trailing whitespace",template:".trimEnd()",category:"Transform"},{name:"split",signature:".split(separator)",description:"Split into array",template:".split(',')",category:"Convert"},{name:"replace",signature:".replace(search, replace)",description:"Replace first match",template:".replace('old', 'new')",category:"Transform"},{name:"replaceAll",signature:".replaceAll(search, replace)",description:"Replace all matches",template:".replaceAll('old', 'new')",category:"Transform"},{name:"substring",signature:".substring(start, end)",description:"Extract substring",template:".substring(0, 10)",category:"Transform"},{name:"slice",signature:".slice(start, end)",description:"Extract slice",template:".slice(0, 10)",category:"Transform"},{name:"startsWith",signature:".startsWith(str)",description:"Check if starts with",template:".startsWith('prefix')",category:"Test"},{name:"endsWith",signature:".endsWith(str)",description:"Check if ends with",template:".endsWith('suffix')",category:"Test"},{name:"includes",signature:".includes(str)",description:"Check if contains",template:".includes('text')",category:"Test"},{name:"match",signature:".match(regex)",description:"Match regex pattern",template:".match(/pattern/)",category:"Search"},{name:"length",signature:".length",description:"Get string length",template:".length",category:"Property"}],Fs=[{name:"keys",signature:".{keys}",description:"Get object keys",template:".{keys}",category:"Convert"},{name:"values",signature:".{values}",description:"Get object values",template:".{values}",category:"Convert"},{name:"entries",signature:".{entries}",description:"Get key-value pairs",template:".{entries}",category:"Convert"},{name:"length",signature:".{length}",description:"Get property count",template:".{length}",category:"Property"}],Ls=[{name:"toFixed",signature:".toFixed(decimals)",description:"Format with decimals",template:".toFixed(2)",category:"Format"},{name:"toString",signature:".toString()",description:"Convert to string",template:".toString()",category:"Convert"}],U=(e)=>{switch(e){case"Array":return Rs;case"String":return Ms;case"Object":return Fs;case"Number":return Ls;default:return[]}};var tn=(e)=>{let t=e.matches.length>0,n=e.selectedIndex>=0&&e.selectedIndex<e.matches.length;if(!t||!n)return e;let r=e.matches[e.selectedIndex].item,o={basePath:r.path,baseValue:r.value,baseType:r.type,expression:r.path,currentMethodIndex:0,arrowFnContext:null},s=U(r.type),i=R(s,"",(a)=>a.signature);return Object.assign({},e,{mode:"build",builder:o,query:"",selectedIndex:0,methodMatches:i})},te=(e)=>{return Object.assign({},e,{mode:"explore",builder:null,selectedIndex:0})},_e=(e,t)=>{if(!e.builder)return e;let r=e.builder,o=U(r.baseType),s=R(o,t,(c)=>c.signature);return Object.assign({},e,{query:t,methodMatches:s,selectedIndex:0})},Be=(e,t)=>{let n=!e.builder,r=!e.builder?.arrowFnContext;if(n||r)return e;let o=e.builder.arrowFnContext,s=R(o.paramPaths,t,(c)=>c.path);return Object.assign({},e,{query:t,propertyMatches:s,selectedIndex:0})},nn=(e,t)=>{if(!e.builder)return e;let r=e.builder;if(t<0||t>=e.methodMatches.length)return e;let i=e.methodMatches[t].item.template||"";if(i.includes("x =>")||i.includes("(a, b)")||i.includes("(acc, x)")){let h=r.baseType==="Array"?(()=>{if(!Array.isArray(r.baseValue))return{};if(r.baseValue.length===0)return{};return r.baseValue[0]})():r.baseValue,g=Array.isArray(h)?"Array":h===null?"null":typeof h==="object"?"Object":typeof h==="string"?"String":typeof h==="number"?"Number":typeof h==="boolean"?"Boolean":"unknown",y=i.includes("(a, b)")?"a":"x",x=de(h),w={paramName:y,paramType:g,paramValue:h,paramPaths:x,expression:""},L=R(x,"",(P)=>P.path),E=Object.assign({},r,{currentMethodIndex:t,arrowFnContext:w,expression:r.expression+i});return Object.assign({},e,{mode:"build-arrow-fn",builder:E,query:"",selectedIndex:0,propertyMatches:L})}let a=r.expression+i,u=Object.assign({},r,{expression:a,currentMethodIndex:t});return Object.assign({},e,{builder:u})},rn=(e,t)=>{let n=!e.builder,r=!e.builder?.arrowFnContext;if(n||r)return e;if(t<0||t>=e.propertyMatches.length)return e;let s=e.builder,i=s.arrowFnContext,c=e.propertyMatches[t].item,a=i.paramName,u=c.path==="."?a:`${a}${c.path}`,l=Object.assign({},i,{expression:u}),p=Object.assign({},s,{arrowFnContext:l});return Object.assign({},e,{builder:p})},sn=(e)=>{let t=!e.builder,n=!e.builder?.arrowFnContext;if(t||n)return e;let r=e.builder,o=r.arrowFnContext;if(!o.expression)return e;let a=U(r.baseType)[r.currentMethodIndex].template||"",u=(h,g,y)=>{let x=h.lastIndexOf(g);if(x===-1)return h;return h.substring(0,x)+y+h.substring(x+g.length)},l=r.expression;if(a.includes("x => x"))l=u(l,"x => x",`x => ${o.expression}`);else if(a.includes("(a, b) => a - b"))l=u(l,"(a, b) => a - b",`(a, b) => ${o.expression}`);else if(a.includes("(acc, x) => acc"))l=u(l,"(acc, x) => acc",`(acc, x) => ${o.expression}`);let p=Object.assign({},r,{expression:l,arrowFnContext:null});return Object.assign({},e,{mode:"build",builder:p,query:"",selectedIndex:0})},je=(e)=>{if(!e.builder)return e;let n=e.builder,s=U(n.baseType)[n.currentMethodIndex].template||"",i=n.expression.replace(s,""),c=Object.assign({},n,{expression:i,arrowFnContext:null});return Object.assign({},e,{mode:"build",builder:c})},on=(e)=>{if(!e.builder)return e;let n=e.builder,r=n.expression,o=r.lastIndexOf(".");if(o===-1)return te(e);let c=r.lastIndexOf("(")>o?r.substring(0,o):r;if(c===n.basePath)return te(e);let a=Object.assign({},n,{expression:c}),u=U(n.baseType),l=R(u,"",(d)=>d.signature);return Object.assign({},e,{builder:a,methodMatches:l,query:"",selectedIndex:0})};var T=Object.assign({},{CTRL_C:"\x03",ESCAPE:"\x1B",ENTER:"\r",TAB:"\t",UP:"\x1B[A",DOWN:"\x1B[B",LEFT:"\x1B[D",RIGHT:"\x1B[C",BACKSPACE:"\x7F"}),Ps=(e)=>{let t=e===T.CTRL_C,n=e===T.ESCAPE;return t||n||e==="q"},De=(e)=>e===T.ENTER,Ve=(e)=>e===T.TAB,$e=(e)=>e===T.UP,Ge=(e)=>e===T.DOWN,cn=(e)=>e===T.LEFT,an=(e)=>e===T.RIGHT,We=(e)=>e===T.BACKSPACE,Je=(e)=>{let t=e>=" ",n=e<="~";return t&&n},ks=(e,t)=>{if(Ve(t))return{state:tn(e),output:null};if(De(t)){let n=Ut(e);if(!n)return{state:null,output:null};return{state:null,output:JSON.stringify(n.value,null,2)}}if($e(t))return{state:D(e,-1),output:null};if(Ge(t))return{state:D(e,1),output:null};if(We(t)){let n=e.query.slice(0,-1);return{state:Le(e,n),output:null}}if(Je(t)){let n=e.query.concat(t);return{state:Le(e,n),output:null}}return{state:e,output:null}},_s=(e,t)=>{if(t===T.ESCAPE)return{state:te(e),output:null};if(De(t)){if(!e.builder)return{state:e,output:null};return{state:null,output:e.builder.expression}}if(an(t)||Ve(t)){if(!e.builder)return{state:e,output:null};return{state:nn(e,e.selectedIndex),output:null}}if(cn(t))return{state:on(e),output:null};if($e(t))return{state:D(e,-1),output:null};if(Ge(t))return{state:D(e,1),output:null};if(We(t)){let n=e.query.slice(0,-1);return{state:_e(e,n),output:null}}if(Je(t)){let n=e.query.concat(t);return{state:_e(e,n),output:null}}return{state:e,output:null}},Bs=(e,t)=>{if(t===T.ESCAPE)return{state:je(e),output:null};if(De(t)){if(!e.builder)return{state:e,output:null};return{state:null,output:e.builder.expression}}if(an(t)||Ve(t)){let n=rn(e,e.selectedIndex);return{state:sn(n),output:null}}if(cn(t))return{state:je(e),output:null};if($e(t))return{state:D(e,-1),output:null};if(Ge(t))return{state:D(e,1),output:null};if(We(t)){let n=e.query.slice(0,-1);return{state:Be(e,n),output:null}}if(Je(t)){let n=e.query.concat(t);return{state:Be(e,n),output:null}}return{state:e,output:null}},js={explore:ks,build:_s,"build-arrow-fn":Bs},un=(e,t)=>{let n=t.toString();if(Ps(n)){if(e.mode==="build"||e.mode==="build-arrow-fn")return{state:te(e),output:null};return{state:null,output:null}}let r=js[e.mode];return r(e,n)};var ln=()=>{Qt(),Kt(),V()},Ds=(e)=>{ln();let t=f("Error: ",m.yellow),n=e.message,r=`
152
+ `,o=t.concat(n,r);ne.write(o),ze(1)},Vs=(e,t)=>{return un(e,t)},$s=async(e)=>{let t=e;return new Promise((n)=>{let r=(o)=>{let{state:s,output:i}=Vs(t,o);if(i!==null){Ue.off("data",r),n(i);return}if(s===null){Ue.off("data",r),n(null);return}t=s,ke(t)};Ue.on("data",r)})},pn=async(e)=>{let t=de(e);if(!(t.length>0)){let o=f(`No paths found in data
153
+ `,m.yellow);ne.write(o),ze(1)}let r=Jt(t,e);Ht(),zt(),ke(r);try{let o=await $s(r);if(ln(),o!==null)try{let i=Y(o),a=new H(i).tokenize(),l=new K(a).parse(),d=new X().evaluate(l,e),h=JSON.stringify(d,null,2);ne.write(h),ne.write(`
154
+ `)}catch(i){let c=i instanceof Error?i.message:String(i);ne.write(f("Error: "+c+`
155
+ `,m.yellow))}ze(0)}catch(o){Ds(o)}};async function Gs(e){let t=await It(e.grep,e.find,{recursive:e.recursive,ignoreCase:e.ignoreCase,showLineNumbers:e.showLineNumbers});if(t.length===0){console.log($t("No matches found"));return}for(let n of t){let r=`${Re(n.file)}:${n.line}:${n.column}`,o=e.showLineNumbers?`${r}: ${n.match}`:`${Re(n.file)}: ${n.match}`;console.log(o)}}async function Ws(e,t){if(e.readFile){let s=t[t.indexOf("readFile")+1],i=await pe(s);return e.expression=t[t.indexOf("readFile")+2]||".",i}let n=!process.stdin.isTTY,r=e.list||e.grep;if(!n&&!r)fe(),process.exit(1);if(n)return await Et(e.inputFormat);return null}async function hn(e,t){if(!e.expression){let n=new q(e);console.log(n.format(t));return}try{let n=Y(e.expression),o=new H(n).tokenize(),i=new K(o).parse(),a=new X().evaluate(i,t),u=new q(e);console.log(u.format(a))}catch(n){let r=n instanceof Error?n.message:String(n);console.error("Error:",r),process.exit(1)}}async function Js(e){let t=Ke(e);if(t.help)fe(),process.exit(0);if(t.version){let r=await Bun.file("package.json").json();console.log(`1ls version ${r.version}`),process.exit(0)}if(t.shortcuts)console.log(Wt()),process.exit(0);if(t.shorten)console.log(Gt(t.shorten)),process.exit(0);if(t.expand)console.log(Y(t.expand)),process.exit(0);if(t.list){let r=await Ae(t.list,{recursive:t.recursive,extensions:t.extensions,maxDepth:t.maxDepth});console.log(new q(t).format(r));return}if(t.grep&&t.find){await Gs(t);return}if(t.readFile){let r=e[e.indexOf("readFile")+1],o=await pe(r),s=e[e.indexOf("readFile")+2]||".",i=s===".";if(t.interactive||i){await pn(o);return}t.expression=s,await hn(t,o);return}if(t.interactive)console.error("Error: Interactive mode requires a file path. Use: 1ls readFile <path>"),process.exit(1);let n=await Ws(t,e);await hn(t,n)}if(import.meta.main)Js(process.argv.slice(2)).catch((e)=>{console.error("Error:",e.message),process.exit(1)});export{Js as main};
@@ -0,0 +1 @@
1
+ export declare const runInteractive: (data: unknown) => Promise<void>;
@@ -0,0 +1,10 @@
1
+ import type { State } from "./types";
2
+ export declare const enterBuildMode: (state: State) => State;
3
+ export declare const exitBuildMode: (state: State) => State;
4
+ export declare const updateBuildQuery: (state: State, query: string) => State;
5
+ export declare const updateArrowFnQuery: (state: State, query: string) => State;
6
+ export declare const selectMethod: (state: State, methodIndex: number) => State;
7
+ export declare const updateArrowFnExpression: (state: State, pathIndex: number) => State;
8
+ export declare const completeArrowFn: (state: State) => State;
9
+ export declare const cancelArrowFn: (state: State) => State;
10
+ export declare const undoLastSegment: (state: State) => State;
@@ -0,0 +1,6 @@
1
+ export interface FuzzyMatch<T> {
2
+ item: T;
3
+ score: number;
4
+ matches: number[];
5
+ }
6
+ export declare const fuzzySearch: <T>(items: T[], pattern: string, getText: (item: T) => string) => FuzzyMatch<T>[];
@@ -0,0 +1,7 @@
1
+ import type { State } from "./types";
2
+ type InputResult = {
3
+ state: State | null;
4
+ output: string | null;
5
+ };
6
+ export declare const handleInput: (state: State, data: Buffer) => InputResult;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ export interface Method {
2
+ name: string;
3
+ signature: string;
4
+ description: string;
5
+ template?: string;
6
+ category?: string;
7
+ }
8
+ export declare const ARRAY_METHODS: Method[];
9
+ export declare const STRING_METHODS: Method[];
10
+ export declare const OBJECT_OPERATIONS: Method[];
11
+ export declare const NUMBER_METHODS: Method[];
12
+ export declare const getMethodsForType: (type: string) => Method[];
@@ -0,0 +1,2 @@
1
+ import type { JsonPath } from "./types";
2
+ export declare const navigateJson: (data: unknown) => JsonPath[];
@@ -0,0 +1,3 @@
1
+ import type { State } from "./types";
2
+ export declare const renderBuildMode: (state: State) => void;
3
+ export declare const renderArrowFnMode: (state: State) => void;
@@ -0,0 +1,2 @@
1
+ import type { State } from "./types";
2
+ export declare const render: (state: State) => void;
@@ -0,0 +1,5 @@
1
+ import type { State, JsonPath } from "./types";
2
+ export declare const createInitialState: (paths: JsonPath[], originalData: unknown) => State;
3
+ export declare const updateQuery: (state: State, newQuery: string) => State;
4
+ export declare const updateSelection: (state: State, delta: number) => State;
5
+ export declare const getSelectedPath: (state: State) => JsonPath | null;
@@ -0,0 +1,19 @@
1
+ export declare const clearScreen: () => void;
2
+ export declare const moveCursor: (x: number, y: number) => void;
3
+ export declare const hideCursor: () => void;
4
+ export declare const showCursor: () => void;
5
+ export declare const enableRawMode: () => void;
6
+ export declare const disableRawMode: () => void;
7
+ export declare const colors: {
8
+ reset: string;
9
+ bright: string;
10
+ dim: string;
11
+ cyan: string;
12
+ green: string;
13
+ yellow: string;
14
+ blue: string;
15
+ magenta: string;
16
+ gray: string;
17
+ };
18
+ export declare const colorize: (text: string, color: string) => string;
19
+ export declare const highlightMatches: (text: string, matches: number[]) => string;
@@ -0,0 +1,45 @@
1
+ export interface JsonPath {
2
+ path: string;
3
+ value: unknown;
4
+ type: string;
5
+ displayValue: string;
6
+ }
7
+ export type InteractiveMode = "explore" | "build" | "build-arrow-fn";
8
+ export interface ExpressionBuilder {
9
+ basePath: string;
10
+ baseValue: unknown;
11
+ baseType: string;
12
+ expression: string;
13
+ currentMethodIndex: number;
14
+ arrowFnContext: ArrowFnContext | null;
15
+ }
16
+ export interface ArrowFnContext {
17
+ paramName: string;
18
+ paramType: string;
19
+ paramValue: unknown;
20
+ paramPaths: JsonPath[];
21
+ expression: string;
22
+ }
23
+ export interface Method {
24
+ name: string;
25
+ signature: string;
26
+ description: string;
27
+ template?: string;
28
+ category?: string;
29
+ }
30
+ export interface State {
31
+ mode: InteractiveMode;
32
+ paths: JsonPath[];
33
+ matches: FuzzyMatch<JsonPath>[];
34
+ query: string;
35
+ selectedIndex: number;
36
+ builder: ExpressionBuilder | null;
37
+ originalData: unknown;
38
+ methodMatches: FuzzyMatch<Method>[];
39
+ propertyMatches: FuzzyMatch<JsonPath>[];
40
+ }
41
+ export interface FuzzyMatch<T> {
42
+ item: T;
43
+ score: number;
44
+ matches: number[];
45
+ }
package/dist/types.d.ts CHANGED
@@ -28,6 +28,7 @@ export interface CliOptions extends FileOperationOptions, ShorthandOptions, Form
28
28
  readFile?: boolean;
29
29
  help?: boolean;
30
30
  version?: boolean;
31
+ interactive?: boolean;
31
32
  }
32
33
  export declare enum TokenType {
33
34
  DOT = "DOT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "1ls",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "1 line script - Lightweight JSON CLI with JavaScript syntax",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,21 +19,22 @@
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
+ "workspaces": [
23
+ "app"
24
+ ],
22
25
  "scripts": {
23
- "build": "bun run clean && bun build ./src/cli/index.ts --outdir dist --target bun --minify && tsc --emitDeclarationOnly --outDir dist",
24
- "clean": "rm -rf dist",
25
26
  "dev": "bun run ./src/cli/index.ts",
26
- "prepublishOnly": "bun run test && bun run build",
27
+ "build": "rm -rf dist bin && bun build ./src/cli/index.ts --outdir dist --target bun --minify && tsc --emitDeclarationOnly --outDir dist && cp -r src/completions dist/",
28
+ "build:binary:all": "rm -rf dist bin && mkdir -p bin && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/1ls-darwin-arm64 && bun build ./src/cli/index.ts --compile --minify --target=bun-darwin-x64 --outfile bin/1ls-darwin-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-x64 --outfile bin/1ls-linux-x64 && bun build ./src/cli/index.ts --compile --minify --target=bun-linux-arm64 --outfile bin/1ls-linux-arm64",
29
+ "clean": "rm -rf dist bin",
30
+ "prepublishOnly": "bun run build && bun run lint && bun test",
27
31
  "test": "bun test",
28
- "test:unit": "bun test test/unit/",
32
+ "test:coverage": "bun test --coverage --coverage-reporter=lcov",
29
33
  "test:integration": "bun test test/integration/",
30
- "test:integration:docker": "cd test/integration && docker-compose up --build --abort-on-container-exit",
31
- "test:integration:docker:clean": "cd test/integration && docker-compose down -v",
32
- "typecheck": "tsc --noEmit",
33
34
  "lint": "bunx oxlint src/",
34
- "lint:fix": "bunx oxlint src/ --fix",
35
- "format": "bunx prettier --check 'src/**/*.{ts,tsx,js,jsx,json}'",
36
- "format:fix": "bunx prettier --write 'src/**/*.{ts,tsx,js,jsx,json}'"
35
+ "typecheck": "tsc --noEmit",
36
+ "release": "release-it",
37
+ "prepare": "bash scripts/setup-hooks.sh"
37
38
  },
38
39
  "keywords": [
39
40
  "json",
@@ -55,6 +56,7 @@
55
56
  "homepage": "https://github.com/yowainwright/1ls",
56
57
  "devDependencies": {
57
58
  "@types/bun": "latest",
59
+ "release-it": "^19.0.5",
58
60
  "turbo": "^2.3.3",
59
61
  "typescript": "5.9.2"
60
62
  },