@sammons/code-outline-cli 2.0.3 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -9
- package/dist/cli-argument-parser.d.ts +4 -0
- package/dist/cli-argument-parser.d.ts.map +1 -1
- package/dist/cli-argument-parser.js +56 -22
- package/dist/cli-argument-parser.js.map +1 -1
- package/dist/cli-orchestrator.d.ts +10 -3
- package/dist/cli-orchestrator.d.ts.map +1 -1
- package/dist/cli-orchestrator.js +20 -18
- package/dist/cli-orchestrator.js.map +1 -1
- package/dist/cli-output-handler.d.ts +4 -3
- package/dist/cli-output-handler.d.ts.map +1 -1
- package/dist/cli-output-handler.js +7 -9
- package/dist/cli-output-handler.js.map +1 -1
- package/dist/cli.js +2 -4
- package/dist/cli.js.map +1 -1
- package/dist/file-processor.d.ts +5 -2
- package/dist/file-processor.d.ts.map +1 -1
- package/dist/file-processor.js +12 -18
- package/dist/file-processor.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +19 -11
- package/dist/cli-orchestrator.unit.test.d.ts +0 -2
- package/dist/cli-orchestrator.unit.test.d.ts.map +0 -1
- package/dist/cli-orchestrator.unit.test.js +0 -139
- package/dist/cli-orchestrator.unit.test.js.map +0 -1
- package/dist/cli.integration.test.d.ts +0 -2
- package/dist/cli.integration.test.d.ts.map +0 -1
- package/dist/cli.integration.test.js +0 -308
- package/dist/cli.integration.test.js.map +0 -1
- package/dist/cli.unit.test.d.ts +0 -2
- package/dist/cli.unit.test.d.ts.map +0 -1
- package/dist/cli.unit.test.js +0 -349
- package/dist/cli.unit.test.js.map +0 -1
- package/dist/test.d.ts +0 -25
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -41
- package/dist/test.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ A CLI tool that parses JavaScript/TypeScript files using tree-sitter and provide
|
|
|
15
15
|
## 📦 Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install -g @sammons/code-outline-cli
|
|
18
|
+
npm install -g @sammons/code-outline-cli@2.1.0
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Or use directly with npx:
|
|
@@ -74,14 +74,15 @@ code-outline src/index.ts --all
|
|
|
74
74
|
|
|
75
75
|
## 📋 Command Line Options
|
|
76
76
|
|
|
77
|
-
| Option | Alias | Description
|
|
78
|
-
| ------------------ | ----- |
|
|
79
|
-
| `--format <type>` | `-f` | Output format: `json
|
|
80
|
-
| `--depth <number>` | `-d` | Maximum depth to traverse
|
|
81
|
-
| `--named-only` | | Show only named nodes
|
|
82
|
-
| `--all` | `-a` | Show all nodes (including anonymous)
|
|
83
|
-
| `--
|
|
84
|
-
| `--
|
|
77
|
+
| Option | Alias | Description | Default |
|
|
78
|
+
| ------------------ | ----- | ---------------------------------------- | ---------- | ---- | -------- | ------- |
|
|
79
|
+
| `--format <type>` | `-f` | Output format: `ascii | json | yaml | llmtext` | `ascii` |
|
|
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
|
+
| `--llmtext` | | Generate LLM-optimized compressed output | `false` |
|
|
84
|
+
| `--help` | `-h` | Show help message | |
|
|
85
|
+
| `--version` | `-v` | Show version number | |
|
|
85
86
|
|
|
86
87
|
## 📖 Examples
|
|
87
88
|
|
|
@@ -180,6 +181,9 @@ code-outline src/index.ts --format ascii | pbcopy
|
|
|
180
181
|
|
|
181
182
|
# Save outline to a file
|
|
182
183
|
code-outline "src/**/*.ts" --format yaml > codebase-outline.yaml
|
|
184
|
+
|
|
185
|
+
# Generate LLM-optimized compressed output
|
|
186
|
+
code-outline "src/**/*.ts" --format llmtext
|
|
183
187
|
```
|
|
184
188
|
|
|
185
189
|
## 🛠️ Advanced Usage
|
|
@@ -209,6 +213,53 @@ code-outline "**/*.ts" | jq '[.[] | .outline.children[] | select(.type == "funct
|
|
|
209
213
|
- Node.js >= 20.0.0
|
|
210
214
|
- npm or pnpm
|
|
211
215
|
|
|
216
|
+
## 📚 Programmatic Usage
|
|
217
|
+
|
|
218
|
+
You can also use this package programmatically in your Node.js applications:
|
|
219
|
+
|
|
220
|
+
```javascript
|
|
221
|
+
const { parseFiles } = require('@sammons/code-outline-cli');
|
|
222
|
+
|
|
223
|
+
// Parse files and get results as a string
|
|
224
|
+
const result = await parseFiles('src/**/*.ts', {
|
|
225
|
+
format: 'json',
|
|
226
|
+
depth: 3,
|
|
227
|
+
namedOnly: true,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
console.log(result);
|
|
231
|
+
|
|
232
|
+
// Save to file
|
|
233
|
+
await parseFiles('src/**/*.ts', {
|
|
234
|
+
format: 'yaml',
|
|
235
|
+
output: 'codebase-outline.yaml',
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### TypeScript
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import {
|
|
243
|
+
parseFiles,
|
|
244
|
+
FileProcessor,
|
|
245
|
+
CLIOutputHandler,
|
|
246
|
+
} from '@sammons/code-outline-cli';
|
|
247
|
+
|
|
248
|
+
// Simple usage
|
|
249
|
+
const outline = await parseFiles(['src/index.ts', 'src/utils.ts'], {
|
|
250
|
+
format: 'ascii',
|
|
251
|
+
depth: 2,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Advanced usage with individual components
|
|
255
|
+
const processor = new FileProcessor();
|
|
256
|
+
const files = await processor.findFiles('src/**/*.ts');
|
|
257
|
+
const results = await processor.processFiles(files, 3, true);
|
|
258
|
+
|
|
259
|
+
const outputHandler = new CLIOutputHandler('json');
|
|
260
|
+
outputHandler.formatAndOutput(results);
|
|
261
|
+
```
|
|
262
|
+
|
|
212
263
|
## 📚 Related Packages
|
|
213
264
|
|
|
214
265
|
- [`@sammons/code-outline-parser`](https://www.npmjs.com/package/@sammons/code-outline-parser) - Core parsing functionality
|
|
@@ -3,6 +3,7 @@ export interface CliOptions {
|
|
|
3
3
|
format: OutputFormat;
|
|
4
4
|
depth: number;
|
|
5
5
|
namedOnly: boolean;
|
|
6
|
+
llmtext: boolean;
|
|
6
7
|
help: boolean;
|
|
7
8
|
version: boolean;
|
|
8
9
|
}
|
|
@@ -14,6 +15,9 @@ export declare class CLIArgumentError extends Error {
|
|
|
14
15
|
constructor(message: string);
|
|
15
16
|
}
|
|
16
17
|
export declare class CLIArgumentParser {
|
|
18
|
+
private readonly argv;
|
|
19
|
+
private readonly log;
|
|
20
|
+
constructor(argv?: () => string[], log?: (message: string) => void);
|
|
17
21
|
private safeExtractValue;
|
|
18
22
|
private validateAndThrow;
|
|
19
23
|
printHelp(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-argument-parser.d.ts","sourceRoot":"","sources":["../src/cli-argument-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-argument-parser.d.ts","sourceRoot":"","sources":["../src/cli-argument-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AA8BjE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;gBAG9C,IAAI,GAAE,MAAM,MAAM,EAAuB,EACzC,GAAG,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAwC;IAOpE,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,gBAAgB;IAajB,SAAS,IAAI,IAAI;IA+CjB,YAAY,IAAI,IAAI;IAIpB,KAAK,IAAI,UAAU;CA4H3B"}
|
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { isAbsolute } from 'node:path';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { validateFormat, validateDepthValue, } from '@sammons/code-outline-parser';
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
// Read the version at runtime rather than importing package.json. A JSON import
|
|
8
|
+
// needs an import attribute under ESM (raw .ts run by Node) but that attribute
|
|
9
|
+
// is illegal in the CommonJS output tsc emits to dist/. Reading the file works
|
|
10
|
+
// unchanged in both.
|
|
11
|
+
const readVersion = () => {
|
|
12
|
+
const here = import.meta.dirname;
|
|
13
|
+
for (const candidate of [
|
|
14
|
+
join(here, '..', 'package.json'),
|
|
15
|
+
join(here, '..', '..', 'package.json'),
|
|
16
|
+
]) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(readFileSync(candidate, 'utf8')).version;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Try the next candidate: the file sits one level up from src/ and two
|
|
22
|
+
// levels up from dist/ depending on whether we run sources or the build.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return '0.0.0';
|
|
26
|
+
};
|
|
27
|
+
const version = readVersion();
|
|
28
|
+
export class CLIArgumentError extends Error {
|
|
10
29
|
constructor(message) {
|
|
11
30
|
super(message);
|
|
12
31
|
this.name = 'CLIArgumentError';
|
|
13
32
|
}
|
|
14
33
|
}
|
|
15
|
-
|
|
16
|
-
|
|
34
|
+
export class CLIArgumentParser {
|
|
35
|
+
argv;
|
|
36
|
+
log;
|
|
37
|
+
constructor(argv = () => process.argv, log = (message) => console.log(message)) {
|
|
38
|
+
this.argv = argv;
|
|
39
|
+
this.log = log;
|
|
40
|
+
}
|
|
17
41
|
// Type guard to safely extract unknown values from parseArgs result
|
|
18
42
|
safeExtractValue(value, defaultValue) {
|
|
19
43
|
// Use proper type narrowing instead of type assertions
|
|
@@ -35,7 +59,7 @@ class CLIArgumentParser {
|
|
|
35
59
|
return validation.value;
|
|
36
60
|
}
|
|
37
61
|
printHelp() {
|
|
38
|
-
|
|
62
|
+
this.log(`
|
|
39
63
|
🌳 Code Outline CLI - Parse and analyze JavaScript/TypeScript files
|
|
40
64
|
|
|
41
65
|
Usage:
|
|
@@ -45,10 +69,11 @@ Arguments:
|
|
|
45
69
|
<pattern> Glob pattern to match files (e.g., "src/**/*.ts", "*.js")
|
|
46
70
|
|
|
47
71
|
Options:
|
|
48
|
-
-f, --format <type> Output format: ascii, json, or
|
|
72
|
+
-f, --format <type> Output format: ascii, json, yaml, or llmtext (default: ascii)
|
|
49
73
|
-d, --depth <n> Maximum AST depth to traverse (default: Infinity)
|
|
50
74
|
-a, --all Show all nodes, including unnamed ones
|
|
51
75
|
--named-only Show only named entities (default: true)
|
|
76
|
+
--llmtext Use LLM-optimized compressed text format
|
|
52
77
|
-h, --help Show this help message
|
|
53
78
|
-v, --version Show version number
|
|
54
79
|
|
|
@@ -56,6 +81,7 @@ Output Formats:
|
|
|
56
81
|
ascii Tree-like visualization with color-coded syntax (default)
|
|
57
82
|
json Structured JSON output for programmatic processing
|
|
58
83
|
yaml Human-readable YAML format
|
|
84
|
+
llmtext Compressed text format optimized for LLM consumption
|
|
59
85
|
|
|
60
86
|
Examples:
|
|
61
87
|
# Parse all TypeScript files in src directory
|
|
@@ -72,17 +98,18 @@ Examples:
|
|
|
72
98
|
|
|
73
99
|
Supported Files:
|
|
74
100
|
.js JavaScript files
|
|
75
|
-
.ts TypeScript files
|
|
101
|
+
.ts TypeScript files
|
|
76
102
|
.tsx TypeScript JSX files
|
|
77
103
|
|
|
78
104
|
For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
79
105
|
`);
|
|
80
106
|
}
|
|
81
107
|
printVersion() {
|
|
82
|
-
|
|
108
|
+
this.log(version);
|
|
83
109
|
}
|
|
84
110
|
parse() {
|
|
85
|
-
const { values, positionals } =
|
|
111
|
+
const { values, positionals } = parseArgs({
|
|
112
|
+
args: this.argv().slice(2),
|
|
86
113
|
options: {
|
|
87
114
|
format: {
|
|
88
115
|
type: 'string',
|
|
@@ -100,6 +127,10 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
100
127
|
type: 'boolean',
|
|
101
128
|
default: false,
|
|
102
129
|
},
|
|
130
|
+
llmtext: {
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
default: false,
|
|
133
|
+
},
|
|
103
134
|
help: {
|
|
104
135
|
type: 'boolean',
|
|
105
136
|
short: 'h',
|
|
@@ -125,14 +156,17 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
125
156
|
throw new CLIArgumentError('No file pattern provided');
|
|
126
157
|
}
|
|
127
158
|
// Safely validate format using type guard
|
|
128
|
-
const formatValidation =
|
|
159
|
+
const formatValidation = validateFormat(values.format);
|
|
129
160
|
const format = this.validateAndThrow(formatValidation, 'Invalid format');
|
|
130
161
|
// Safely validate depth using validator
|
|
131
|
-
const depthValidation =
|
|
162
|
+
const depthValidation = validateDepthValue(values.depth);
|
|
132
163
|
const depth = this.validateAndThrow(depthValidation, 'Invalid depth');
|
|
133
164
|
const namedOnly = values.all
|
|
134
165
|
? false
|
|
135
166
|
: this.safeExtractValue(values['named-only'], true);
|
|
167
|
+
const llmtext = this.safeExtractValue(values.llmtext, false);
|
|
168
|
+
// If --llmtext flag is provided, override format to 'llmtext'
|
|
169
|
+
const finalFormat = llmtext ? 'llmtext' : format;
|
|
136
170
|
const pattern = positionals[0];
|
|
137
171
|
// Warn if the pattern doesn't contain glob characters but looks like it should
|
|
138
172
|
if (!pattern.includes('*') &&
|
|
@@ -146,8 +180,8 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
146
180
|
const endsWithCommonExtension = /\.(ts|js|tsx|jsx)$/.test(pattern);
|
|
147
181
|
// Only warn if it's not an absolute path AND not an existing file
|
|
148
182
|
// (relative paths with many segments are likely intended as globs, but existing files should not warn)
|
|
149
|
-
const isAbsolutePath =
|
|
150
|
-
const fileExists =
|
|
183
|
+
const isAbsolutePath = isAbsolute(pattern);
|
|
184
|
+
const fileExists = existsSync(pattern);
|
|
151
185
|
// Debug: Show the evaluation
|
|
152
186
|
const shouldWarn = hasMultipleSegments &&
|
|
153
187
|
endsWithCommonExtension &&
|
|
@@ -162,9 +196,10 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
162
196
|
}
|
|
163
197
|
return {
|
|
164
198
|
options: {
|
|
165
|
-
format,
|
|
199
|
+
format: finalFormat,
|
|
166
200
|
depth,
|
|
167
201
|
namedOnly,
|
|
202
|
+
llmtext,
|
|
168
203
|
help: false,
|
|
169
204
|
version: false,
|
|
170
205
|
},
|
|
@@ -172,5 +207,4 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
172
207
|
};
|
|
173
208
|
}
|
|
174
209
|
}
|
|
175
|
-
exports.CLIArgumentParser = CLIArgumentParser;
|
|
176
210
|
//# sourceMappingURL=cli-argument-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-argument-parser.js","sourceRoot":"","sources":["../src/cli-argument-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-argument-parser.js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mBAAmB;gBACnB,uBAAuB;gBACvB,CAAC,cAAc;gBACf,CAAC,UAAU,CAAC;YAEd,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CACX,yBAAyB,OAAO,6CAA6C,CAC9E,CAAC;gBACF,OAAO,CAAC,KAAK,CACX,6DAA6D,CAC9D,CAAC;gBACF,OAAO,CAAC,KAAK,CACX,OAAO,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE,UAAU,CAAC,GAAG,CAC5D,CAAC;gBACF,OAAO,CAAC,KAAK,CACX,gEAAgE,CACjE,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM,EAAE,WAAW;gBACnB,KAAK;gBACL,SAAS;gBACT,OAAO;gBACP,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,KAAK;aACf;YACD,OAAO;SACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { CLIArgumentParser } from './cli-argument-parser.ts';
|
|
2
|
+
import { FileProcessor } from './file-processor.ts';
|
|
3
|
+
import { CLIOutputHandler } from './cli-output-handler.ts';
|
|
4
|
+
import type { OutputFormat } from '@sammons/code-outline-parser';
|
|
1
5
|
export declare class CLIOrchestrator {
|
|
2
|
-
private argumentParser;
|
|
3
|
-
private fileProcessor;
|
|
4
|
-
|
|
6
|
+
private readonly argumentParser;
|
|
7
|
+
private readonly fileProcessor;
|
|
8
|
+
private readonly outputHandlerFactory;
|
|
9
|
+
private readonly exit;
|
|
10
|
+
private readonly logError;
|
|
11
|
+
constructor(argumentParser?: CLIArgumentParser, fileProcessor?: FileProcessor, outputHandlerFactory?: (format: OutputFormat, llmtext?: boolean) => CLIOutputHandler, exit?: (code: number) => never, logError?: (message: string) => void);
|
|
5
12
|
run(): Promise<void>;
|
|
6
13
|
}
|
|
7
14
|
//# sourceMappingURL=cli-orchestrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-orchestrator.d.ts","sourceRoot":"","sources":["../src/cli-orchestrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-orchestrator.d.ts","sourceRoot":"","sources":["../src/cli-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAoB;IACnD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAGf;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;gBAGnD,cAAc,GAAE,iBAA2C,EAC3D,aAAa,GAAE,aAAmC,EAClD,oBAAoB,GAAE,CACpB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,OAAO,KACd,gBACkC,EACvC,IAAI,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAoC,EAC5D,QAAQ,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAA0C;IAS9D,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkClC"}
|
package/dist/cli-orchestrator.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const file_processor_js_1 = require("./file-processor.js");
|
|
6
|
-
const cli_output_handler_js_1 = require("./cli-output-handler.js");
|
|
7
|
-
class CLIOrchestrator {
|
|
1
|
+
import { CLIArgumentParser, CLIArgumentError } from "./cli-argument-parser.js";
|
|
2
|
+
import { FileProcessor, FileProcessorError } from "./file-processor.js";
|
|
3
|
+
import { CLIOutputHandler } from "./cli-output-handler.js";
|
|
4
|
+
export class CLIOrchestrator {
|
|
8
5
|
argumentParser;
|
|
9
6
|
fileProcessor;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
outputHandlerFactory;
|
|
8
|
+
exit;
|
|
9
|
+
logError;
|
|
10
|
+
constructor(argumentParser = new CLIArgumentParser(), fileProcessor = new FileProcessor(), outputHandlerFactory = (format, llmtext) => new CLIOutputHandler(format, llmtext), exit = (code) => process.exit(code), logError = (message) => console.error(message)) {
|
|
11
|
+
this.argumentParser = argumentParser;
|
|
12
|
+
this.fileProcessor = fileProcessor;
|
|
13
|
+
this.outputHandlerFactory = outputHandlerFactory;
|
|
14
|
+
this.exit = exit;
|
|
15
|
+
this.logError = logError;
|
|
13
16
|
}
|
|
14
17
|
async run() {
|
|
15
18
|
try {
|
|
@@ -20,18 +23,18 @@ class CLIOrchestrator {
|
|
|
20
23
|
// Process files in parallel
|
|
21
24
|
const results = await this.fileProcessor.processFiles(files, options.depth, options.namedOnly);
|
|
22
25
|
// Format and output results
|
|
23
|
-
const outputHandler =
|
|
26
|
+
const outputHandler = this.outputHandlerFactory(options.format, options.llmtext);
|
|
24
27
|
outputHandler.formatAndOutput(results);
|
|
25
28
|
}
|
|
26
29
|
catch (error) {
|
|
27
|
-
if (error instanceof
|
|
28
|
-
|
|
30
|
+
if (error instanceof CLIArgumentError) {
|
|
31
|
+
this.logError(`Error: ${error.message}`);
|
|
29
32
|
this.argumentParser.printHelp();
|
|
30
|
-
|
|
33
|
+
this.exit(1);
|
|
31
34
|
}
|
|
32
|
-
else if (error instanceof
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
else if (error instanceof FileProcessorError) {
|
|
36
|
+
this.logError(error.message);
|
|
37
|
+
this.exit(1);
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
40
|
throw error; // Re-throw unexpected errors
|
|
@@ -39,5 +42,4 @@ class CLIOrchestrator {
|
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
|
-
exports.CLIOrchestrator = CLIOrchestrator;
|
|
43
45
|
//# sourceMappingURL=cli-orchestrator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-orchestrator.js","sourceRoot":"","sources":["../src/cli-orchestrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-orchestrator.js","sourceRoot":"","sources":["../src/cli-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,MAAM,OAAO,eAAe;IACT,cAAc,CAAoB;IAClC,aAAa,CAAgB;IAC7B,oBAAoB,CAGf;IACL,IAAI,CAA0B;IAC9B,QAAQ,CAA4B;IAErD,YACE,iBAAoC,IAAI,iBAAiB,EAAE,EAC3D,gBAA+B,IAAI,aAAa,EAAE,EAClD,uBAGwB,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAC1C,IAAI,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,OAAgC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5D,WAAsC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;QAEzE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,GAAG;QACd,IAAI,CAAC;YACH,+BAA+B;YAC/B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;YAEzD,sBAAsB;YACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAE1D,4BAA4B;YAC5B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CACnD,KAAK,EACL,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,SAAS,CAClB,CAAC;YAEF,4BAA4B;YAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,CAC7C,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,OAAO,CAChB,CAAC;YACF,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;gBACtC,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBACzC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,CAAC;iBAAM,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;gBAC/C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC7B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,CAAC,CAAC,6BAA6B;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { OutputFormat } from '@sammons/code-outline-parser';
|
|
2
|
-
import type { ProcessedFile } from './file-processor.
|
|
2
|
+
import type { ProcessedFile } from './file-processor.ts';
|
|
3
3
|
export declare class CLIOutputHandler {
|
|
4
|
-
private formatter;
|
|
5
|
-
|
|
4
|
+
private readonly formatter;
|
|
5
|
+
private readonly log;
|
|
6
|
+
constructor(format: OutputFormat, llmtext?: boolean, log?: (message: string) => void);
|
|
6
7
|
formatAndOutput(results: ProcessedFile[]): void;
|
|
7
8
|
}
|
|
8
9
|
//# sourceMappingURL=cli-output-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-output-handler.d.ts","sourceRoot":"","sources":["../src/cli-output-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAY;
|
|
1
|
+
{"version":3,"file":"cli-output-handler.d.ts","sourceRoot":"","sources":["../src/cli-output-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA4B;gBAG9C,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,OAAO,EACjB,GAAG,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAwC;IAM7D,eAAe,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,IAAI;CAIvD"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.CLIOutputHandler = void 0;
|
|
4
|
-
const code_outline_formatter_1 = require("@sammons/code-outline-formatter");
|
|
5
|
-
class CLIOutputHandler {
|
|
1
|
+
import { Formatter } from '@sammons/code-outline-formatter';
|
|
2
|
+
export class CLIOutputHandler {
|
|
6
3
|
formatter;
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
log;
|
|
5
|
+
constructor(format, llmtext, log = (message) => console.log(message)) {
|
|
6
|
+
this.formatter = new Formatter(format, llmtext);
|
|
7
|
+
this.log = log;
|
|
9
8
|
}
|
|
10
9
|
formatAndOutput(results) {
|
|
11
10
|
const output = this.formatter.format(results);
|
|
12
|
-
|
|
11
|
+
this.log(output);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
exports.CLIOutputHandler = CLIOutputHandler;
|
|
16
14
|
//# sourceMappingURL=cli-output-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-output-handler.js","sourceRoot":"","sources":["../src/cli-output-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-output-handler.js","sourceRoot":"","sources":["../src/cli-output-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,MAAM,OAAO,gBAAgB;IACV,SAAS,CAAY;IACrB,GAAG,CAA4B;IAEhD,YACE,MAAoB,EACpB,OAAiB,EACjB,MAAiC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;QAElE,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEM,eAAe,CAAC,OAAwB;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC;CACF"}
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const cli_orchestrator_js_1 = require("./cli-orchestrator.js");
|
|
2
|
+
import { CLIOrchestrator } from "./cli-orchestrator.js";
|
|
5
3
|
async function main() {
|
|
6
|
-
const orchestrator = new
|
|
4
|
+
const orchestrator = new CLIOrchestrator();
|
|
7
5
|
await orchestrator.run();
|
|
8
6
|
}
|
|
9
7
|
main().catch((error) => {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,KAAK,UAAU,IAAI;IACjB,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAC;IAC3C,MAAM,YAAY,CAAC,GAAG,EAAE,CAAC;AAC3B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/file-processor.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import fg from 'fast-glob';
|
|
1
2
|
import type { NodeInfo } from '@sammons/code-outline-parser';
|
|
3
|
+
import { Parser } from '@sammons/code-outline-parser';
|
|
2
4
|
export interface ProcessedFile {
|
|
3
5
|
file: string;
|
|
4
6
|
outline: NodeInfo | null;
|
|
@@ -7,8 +9,9 @@ export declare class FileProcessorError extends Error {
|
|
|
7
9
|
constructor(message: string);
|
|
8
10
|
}
|
|
9
11
|
export declare class FileProcessor {
|
|
10
|
-
private parser;
|
|
11
|
-
|
|
12
|
+
private readonly parser;
|
|
13
|
+
private readonly glob;
|
|
14
|
+
constructor(parser?: Parser, glob?: typeof fg);
|
|
12
15
|
findFiles(pattern: string): Promise<string[]>;
|
|
13
16
|
private parseFile;
|
|
14
17
|
processFiles(files: string[], depth: number, namedOnly: boolean): Promise<ProcessedFile[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-processor.d.ts","sourceRoot":"","sources":["../src/file-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-processor.d.ts","sourceRoot":"","sources":["../src/file-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC1B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;gBAErB,MAAM,GAAE,MAAqB,EAAE,IAAI,GAAE,OAAO,EAAO;IAKlD,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAe5C,SAAS;IAsBV,YAAY,CACvB,KAAK,EAAE,MAAM,EAAE,EACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,aAAa,EAAE,CAAC;CAQ5B"}
|
package/dist/file-processor.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FileProcessor = exports.FileProcessorError = void 0;
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
9
|
-
const code_outline_parser_1 = require("@sammons/code-outline-parser");
|
|
10
|
-
class FileProcessorError extends Error {
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import fg from 'fast-glob';
|
|
3
|
+
import { Parser } from '@sammons/code-outline-parser';
|
|
4
|
+
export class FileProcessorError extends Error {
|
|
11
5
|
constructor(message) {
|
|
12
6
|
super(message);
|
|
13
7
|
this.name = 'FileProcessorError';
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
class FileProcessor {
|
|
10
|
+
export class FileProcessor {
|
|
18
11
|
parser;
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
glob;
|
|
13
|
+
constructor(parser = new Parser(), glob = fg) {
|
|
14
|
+
this.parser = parser;
|
|
15
|
+
this.glob = glob;
|
|
21
16
|
}
|
|
22
17
|
async findFiles(pattern) {
|
|
23
|
-
const files = await
|
|
18
|
+
const files = await this.glob(pattern, {
|
|
24
19
|
absolute: true,
|
|
25
20
|
ignore: ['**/node_modules/**', '**/dist/**', '**/build/**'],
|
|
26
21
|
});
|
|
@@ -33,7 +28,7 @@ class FileProcessor {
|
|
|
33
28
|
try {
|
|
34
29
|
const outline = await this.parser.parseFile(file, depth, namedOnly);
|
|
35
30
|
return {
|
|
36
|
-
file:
|
|
31
|
+
file: resolve(file),
|
|
37
32
|
outline,
|
|
38
33
|
};
|
|
39
34
|
}
|
|
@@ -41,7 +36,7 @@ class FileProcessor {
|
|
|
41
36
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
42
37
|
console.error(`Error parsing ${file}:`, errorMessage);
|
|
43
38
|
return {
|
|
44
|
-
file:
|
|
39
|
+
file: resolve(file),
|
|
45
40
|
outline: null,
|
|
46
41
|
};
|
|
47
42
|
}
|
|
@@ -52,5 +47,4 @@ class FileProcessor {
|
|
|
52
47
|
return await Promise.all(parsePromises);
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
|
-
exports.FileProcessor = FileProcessor;
|
|
56
50
|
//# sourceMappingURL=file-processor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-processor.js","sourceRoot":"","sources":["../src/file-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-processor.js","sourceRoot":"","sources":["../src/file-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,WAAW,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAOtD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IACP,MAAM,CAAS;IACf,IAAI,CAAY;IAEjC,YAAY,SAAiB,IAAI,MAAM,EAAE,EAAE,OAAkB,EAAE;QAC7D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,OAAe;QACpC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACrC,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,CAAC,oBAAoB,EAAE,YAAY,EAAE,aAAa,CAAC;SAC5D,CAAC,CAAC;QAEH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,kBAAkB,CAC1B,oCAAoC,OAAO,EAAE,CAC9C,CAAC;QACJ,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,KAAK,CAAC,SAAS,CACrB,IAAY,EACZ,KAAa,EACb,SAAkB;QAElB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;YACpE,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;gBACnB,OAAO;aACR,CAAC;QACJ,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACpE,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,GAAG,EAAE,YAAY,CAAC,CAAC;YACtD,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;gBACnB,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAAe,EACf,KAAa,EACb,SAAkB;QAElB,8CAA8C;QAC9C,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACvC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CACvC,CAAC;QAEF,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { CLIOrchestrator } from './cli-orchestrator.ts';
|
|
2
|
+
export { CLIArgumentParser } from './cli-argument-parser.ts';
|
|
3
|
+
export { FileProcessor } from './file-processor.ts';
|
|
4
|
+
export { CLIOutputHandler } from './cli-output-handler.ts';
|
|
5
|
+
export declare function parseFiles(patterns: string | string[], options?: {
|
|
6
|
+
format?: 'ascii' | 'json' | 'yaml';
|
|
7
|
+
depth?: number;
|
|
8
|
+
namedOnly?: boolean;
|
|
9
|
+
output?: string;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE;IACR,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAAC,MAAM,CAAC,CAoCjB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Main orchestrator for programmatic usage
|
|
2
|
+
export { CLIOrchestrator } from "./cli-orchestrator.js";
|
|
3
|
+
// Individual components
|
|
4
|
+
export { CLIArgumentParser } from "./cli-argument-parser.js";
|
|
5
|
+
export { FileProcessor } from "./file-processor.js";
|
|
6
|
+
export { CLIOutputHandler } from "./cli-output-handler.js";
|
|
7
|
+
// Convenience function for simple usage
|
|
8
|
+
export async function parseFiles(patterns, options) {
|
|
9
|
+
const { FileProcessor } = await import("./file-processor.js");
|
|
10
|
+
const fileProcessor = new FileProcessor();
|
|
11
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
12
|
+
// Find matching files for all patterns
|
|
13
|
+
const allFiles = [];
|
|
14
|
+
for (const pattern of patternArray) {
|
|
15
|
+
const files = await fileProcessor.findFiles(pattern);
|
|
16
|
+
allFiles.push(...files);
|
|
17
|
+
}
|
|
18
|
+
// Remove duplicates
|
|
19
|
+
const uniqueFiles = [...new Set(allFiles)];
|
|
20
|
+
// Process files
|
|
21
|
+
const results = await fileProcessor.processFiles(uniqueFiles, options?.depth ?? 10, // Default depth
|
|
22
|
+
options?.namedOnly ?? false);
|
|
23
|
+
// Format output
|
|
24
|
+
const { Formatter } = await import('@sammons/code-outline-formatter');
|
|
25
|
+
const formatter = new Formatter(options?.format ?? 'ascii');
|
|
26
|
+
const output = formatter.format(results);
|
|
27
|
+
if (options?.output) {
|
|
28
|
+
const fs = await import('fs');
|
|
29
|
+
await fs.promises.writeFile(options.output, output, 'utf-8');
|
|
30
|
+
return `Results written to ${options.output}`;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return output;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,wBAAwB;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,wCAAwC;AACxC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,QAA2B,EAC3B,OAKC;IAED,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAE9D,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,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