@sammons/code-outline-cli 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +227 -0
  2. package/package.json +5 -4
package/README.md ADDED
@@ -0,0 +1,227 @@
1
+ # @sammons/code-outline-cli
2
+
3
+ A powerful CLI tool that parses JavaScript/TypeScript files using tree-sitter and provides a concise outline of the code structure. Perfect for understanding codebases quickly and generating LLM-friendly code summaries.
4
+
5
+ ## ✨ Features
6
+
7
+ - 🚀 **Fast parsing** using tree-sitter for JavaScript, TypeScript, and TSX files
8
+ - 📊 **Multiple output formats**: JSON, YAML, and ASCII tree
9
+ - 🎯 **Configurable depth** limiting for AST traversal
10
+ - 🔍 **Named-only mode** to show only named entities (functions, classes, etc.)
11
+ - ⚡ **Parallel processing** for multiple files
12
+ - 🎨 **Colored output** for better readability in ASCII mode
13
+ - 📁 **Glob pattern support** for file selection
14
+
15
+ ## 📦 Installation
16
+
17
+ ```bash
18
+ npm install -g @sammons/code-outline-cli
19
+ ```
20
+
21
+ Or use directly with npx:
22
+
23
+ ```bash
24
+ npx @sammons/code-outline-cli <file-pattern> [options]
25
+ ```
26
+
27
+ ## 🚀 Usage
28
+
29
+ ### Basic Usage
30
+
31
+ ```bash
32
+ # Parse a single file
33
+ code-outline src/index.ts
34
+
35
+ # Parse multiple files with glob pattern
36
+ code-outline "src/**/*.ts"
37
+
38
+ # Parse all JavaScript/TypeScript files recursively
39
+ code-outline "**/*.{js,ts,tsx}"
40
+ ```
41
+
42
+ ### Output Formats
43
+
44
+ ```bash
45
+ # JSON output (default)
46
+ code-outline src/index.ts --format json
47
+
48
+ # YAML output
49
+ code-outline src/index.ts --format yaml
50
+
51
+ # ASCII tree output (great for documentation)
52
+ code-outline src/index.ts --format ascii
53
+ ```
54
+
55
+ ### Depth Control
56
+
57
+ ```bash
58
+ # Limit depth to 2 levels
59
+ code-outline src/index.ts --depth 2
60
+
61
+ # Show all levels (default)
62
+ code-outline src/index.ts --depth Infinity
63
+ ```
64
+
65
+ ### Filtering Options
66
+
67
+ ```bash
68
+ # Show only named entities (default)
69
+ code-outline src/index.ts --named-only
70
+
71
+ # Show all nodes including anonymous ones
72
+ code-outline src/index.ts --all
73
+ ```
74
+
75
+ ## 📋 Command Line Options
76
+
77
+ | Option | Alias | Description | Default |
78
+ | ------------------ | ----- | ----------------------------------------- | ---------- |
79
+ | `--format <type>` | `-f` | Output format: `json`, `yaml`, or `ascii` | `json` |
80
+ | `--depth <number>` | `-d` | Maximum depth to traverse | `Infinity` |
81
+ | `--named-only` | | Show only named nodes | `true` |
82
+ | `--all` | `-a` | Show all nodes (including anonymous) | `false` |
83
+ | `--help` | `-h` | Show help message | |
84
+ | `--version` | `-v` | Show version number | |
85
+
86
+ ## 📖 Examples
87
+
88
+ ### Example TypeScript File
89
+
90
+ ```typescript
91
+ // example.ts
92
+ export class UserService {
93
+ constructor(private db: Database) {}
94
+
95
+ async getUser(id: string): Promise<User> {
96
+ return this.db.users.findById(id);
97
+ }
98
+
99
+ async createUser(data: UserData): Promise<User> {
100
+ return this.db.users.create(data);
101
+ }
102
+ }
103
+
104
+ export function validateEmail(email: string): boolean {
105
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
106
+ }
107
+ ```
108
+
109
+ ### ASCII Tree Output
110
+
111
+ ```bash
112
+ code-outline example.ts --format ascii
113
+ ```
114
+
115
+ ```
116
+ 📁 example.ts
117
+ ├─ class_declaration: UserService [1:0] :1
118
+ │ ├─ method_definition: constructor [2:2] :2
119
+ │ ├─ method_definition: getUser [4:2] :4
120
+ │ └─ method_definition: createUser [8:2] :8
121
+ └─ function_declaration: validateEmail [13:0] :13
122
+ ```
123
+
124
+ ### JSON Output
125
+
126
+ ```bash
127
+ code-outline example.ts --format json
128
+ ```
129
+
130
+ ```json
131
+ [
132
+ {
133
+ "file": "example.ts",
134
+ "outline": {
135
+ "type": "program",
136
+ "children": [
137
+ {
138
+ "type": "class_declaration",
139
+ "name": "UserService",
140
+ "start": { "row": 0, "column": 0 },
141
+ "children": [
142
+ {
143
+ "type": "method_definition",
144
+ "name": "constructor",
145
+ "start": { "row": 1, "column": 2 }
146
+ },
147
+ {
148
+ "type": "method_definition",
149
+ "name": "getUser",
150
+ "start": { "row": 3, "column": 2 }
151
+ },
152
+ {
153
+ "type": "method_definition",
154
+ "name": "createUser",
155
+ "start": { "row": 7, "column": 2 }
156
+ }
157
+ ]
158
+ },
159
+ {
160
+ "type": "function_declaration",
161
+ "name": "validateEmail",
162
+ "start": { "row": 12, "column": 0 }
163
+ }
164
+ ]
165
+ }
166
+ }
167
+ ]
168
+ ```
169
+
170
+ ## 🤖 LLM Integration
171
+
172
+ This tool is perfect for providing code context to Large Language Models:
173
+
174
+ ```bash
175
+ # Generate a code outline and pipe to your LLM tool
176
+ code-outline "src/**/*.ts" --format json | llm-tool
177
+
178
+ # Copy outline to clipboard (on macOS)
179
+ code-outline src/index.ts --format ascii | pbcopy
180
+
181
+ # Save outline to a file
182
+ code-outline "src/**/*.ts" --format yaml > codebase-outline.yaml
183
+ ```
184
+
185
+ ## 🛠️ Advanced Usage
186
+
187
+ ### Processing Large Codebases
188
+
189
+ ```bash
190
+ # Process all TypeScript files in a project
191
+ code-outline "**/*.ts" --depth 2 --format json > project-outline.json
192
+
193
+ # Exclude node_modules and dist folders (use quotes to prevent shell expansion)
194
+ code-outline "src/**/*.{ts,tsx}" --format ascii
195
+ ```
196
+
197
+ ### Integration with Other Tools
198
+
199
+ ```bash
200
+ # Use with jq for JSON processing
201
+ code-outline src/index.ts | jq '.[] | .outline.children[] | .name'
202
+
203
+ # Count functions in your codebase
204
+ code-outline "**/*.ts" | jq '[.[] | .outline.children[] | select(.type == "function_declaration")] | length'
205
+ ```
206
+
207
+ ## 🔧 Requirements
208
+
209
+ - Node.js >= 20.0.0
210
+ - npm or pnpm
211
+
212
+ ## 📚 Related Packages
213
+
214
+ - [`@sammons/code-outline-parser`](https://www.npmjs.com/package/@sammons/code-outline-parser) - Core parsing functionality
215
+ - [`@sammons/code-outline-formatter`](https://www.npmjs.com/package/@sammons/code-outline-formatter) - Output formatting utilities
216
+
217
+ ## 🤝 Contributing
218
+
219
+ Contributions are welcome! Please visit our [GitHub repository](https://github.com/sammons2/code-outline-cli) for more information.
220
+
221
+ ## 📄 License
222
+
223
+ MIT © Sammons Software LLC
224
+
225
+ ---
226
+
227
+ Made with ❤️ by [Sammons](https://github.com/sammons2) | This is a [Sammons Software LLC](https://github.com/sammons2) Production
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sammons/code-outline-cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "CLI tool to parse and provide concise output for JavaScript/TypeScript files",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -20,13 +20,14 @@
20
20
  "author": "",
21
21
  "license": "MIT",
22
22
  "files": [
23
- "dist"
23
+ "dist",
24
+ "README.md"
24
25
  ],
25
26
  "dependencies": {
26
27
  "fast-glob": "3.3.3",
27
28
  "glob": "11.0.3",
28
- "@sammons/code-outline-formatter": "2.0.1",
29
- "@sammons/code-outline-parser": "2.0.1"
29
+ "@sammons/code-outline-parser": "2.0.1",
30
+ "@sammons/code-outline-formatter": "2.0.1"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@types/node": "24.3.1",