@sammons/code-outline-cli 2.1.0 → 2.2.0
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 +47 -13
- package/dist/cli-argument-parser.d.ts +4 -1
- package/dist/cli-argument-parser.d.ts.map +1 -1
- package/dist/cli-argument-parser.js +186 -69
- 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 +96 -24
- 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 +70 -3
- package/dist/file-processor.d.ts.map +1 -1
- package/dist/file-processor.js +134 -25
- package/dist/file-processor.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -51
- package/dist/index.js.map +1 -1
- package/package.json +12 -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 -140
- 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 -342
- 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 -411
- 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
|
@@ -39,17 +39,25 @@ code-outline "src/**/*.ts"
|
|
|
39
39
|
code-outline "**/*.{js,ts,tsx}"
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
### Multiple Patterns
|
|
43
|
+
|
|
44
|
+
Pass more than one pattern in a single run. The CLI unions the matches from every pattern and dedupes them by absolute path.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
code-outline "src/**/*.ts" "test/**/*.ts"
|
|
48
|
+
```
|
|
49
|
+
|
|
42
50
|
### Output Formats
|
|
43
51
|
|
|
44
52
|
```bash
|
|
45
|
-
#
|
|
53
|
+
# ASCII tree output (default, great for documentation)
|
|
54
|
+
code-outline src/index.ts --format ascii
|
|
55
|
+
|
|
56
|
+
# JSON output
|
|
46
57
|
code-outline src/index.ts --format json
|
|
47
58
|
|
|
48
59
|
# YAML output
|
|
49
60
|
code-outline src/index.ts --format yaml
|
|
50
|
-
|
|
51
|
-
# ASCII tree output (great for documentation)
|
|
52
|
-
code-outline src/index.ts --format ascii
|
|
53
61
|
```
|
|
54
62
|
|
|
55
63
|
### Depth Control
|
|
@@ -70,18 +78,41 @@ code-outline src/index.ts --named-only
|
|
|
70
78
|
|
|
71
79
|
# Show all nodes including anonymous ones
|
|
72
80
|
code-outline src/index.ts --all
|
|
81
|
+
|
|
82
|
+
# Disable named-only filtering without --all
|
|
83
|
+
code-outline src/index.ts --no-named-only
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### LLM-Optimized Output
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Generate LLM-optimized compressed output
|
|
90
|
+
code-outline src/index.ts --llmtext
|
|
91
|
+
|
|
92
|
+
# Errors: --llmtext conflicts with an explicit --format other than llmtext
|
|
93
|
+
code-outline src/index.ts --llmtext --format json
|
|
73
94
|
```
|
|
74
95
|
|
|
75
96
|
## 📋 Command Line Options
|
|
76
97
|
|
|
77
|
-
| Option | Alias | Description
|
|
78
|
-
| ------------------ | ----- |
|
|
79
|
-
| `--format <type>` | `-f` | Output format: `json`, `yaml`, or `
|
|
80
|
-
| `--depth <number>` | `-d` | Maximum depth to traverse
|
|
81
|
-
| `--named-only` | | Show only named nodes
|
|
82
|
-
| `--all` | `-a` | Show all nodes
|
|
83
|
-
| `--
|
|
84
|
-
| `--
|
|
98
|
+
| Option | Alias | Description | Default |
|
|
99
|
+
| ------------------ | ----- | ----------------------------------------------------------------------------------------------------------------------------- | ---------- |
|
|
100
|
+
| `--format <type>` | `-f` | Output format: `ascii`, `json`, `yaml`, or `llmtext`. Errors if combined with an explicit `--llmtext` for a different format. | `ascii` |
|
|
101
|
+
| `--depth <number>` | `-d` | Maximum AST depth to traverse. A non-negative integer, or `Infinity`. `0` means top-level only. Non-integers are rejected. | `Infinity` |
|
|
102
|
+
| `--named-only` | | Show only named AST nodes. Disable with `--no-named-only` or `--named-only=false`. | `true` |
|
|
103
|
+
| `--all` | `-a` | Show all nodes, including unnamed ones. Always wins over `--named-only`. | `false` |
|
|
104
|
+
| `--llmtext` | | Generate LLM-optimized compressed output. Errors if combined with an explicit `--format` other than `llmtext`. | `false` |
|
|
105
|
+
| `--help` | `-h` | Show help message | - |
|
|
106
|
+
| `--version` | `-v` | Show version number | - |
|
|
107
|
+
|
|
108
|
+
## 🚦 Exit Codes
|
|
109
|
+
|
|
110
|
+
| Code | Meaning |
|
|
111
|
+
| ---- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
112
|
+
| `0` | Success, or `-h`/`--help`/`-v`/`--version` requested |
|
|
113
|
+
| `1` | Any error: unknown option, invalid flag value, no pattern given, no files matched, a file that failed to parse, or conflicting flags |
|
|
114
|
+
|
|
115
|
+
Errors print one diagnostic line per failure to stderr, then a one-line usage hint (`Run with --help for usage.`). Most errors (an unknown option, no files matched) print exactly one diagnostic line; a batch with multiple files that failed to parse prints one `Error parsing <file>: ...` line per failed file. The help banner prints to stdout only on `-h`/`--help`.
|
|
85
116
|
|
|
86
117
|
## 📖 Examples
|
|
87
118
|
|
|
@@ -180,6 +211,9 @@ code-outline src/index.ts --format ascii | pbcopy
|
|
|
180
211
|
|
|
181
212
|
# Save outline to a file
|
|
182
213
|
code-outline "src/**/*.ts" --format yaml > codebase-outline.yaml
|
|
214
|
+
|
|
215
|
+
# Generate LLM-optimized compressed output
|
|
216
|
+
code-outline "src/**/*.ts" --format llmtext
|
|
183
217
|
```
|
|
184
218
|
|
|
185
219
|
## 🛠️ Advanced Usage
|
|
@@ -206,7 +240,7 @@ code-outline "**/*.ts" | jq '[.[] | .outline.children[] | select(.type == "funct
|
|
|
206
240
|
|
|
207
241
|
## 🔧 Requirements
|
|
208
242
|
|
|
209
|
-
- Node.js >=
|
|
243
|
+
- Node.js >= 26.0.0
|
|
210
244
|
- npm or pnpm
|
|
211
245
|
|
|
212
246
|
## 📚 Programmatic Usage
|
|
@@ -9,12 +9,15 @@ export interface CliOptions {
|
|
|
9
9
|
}
|
|
10
10
|
export interface ParsedArgs {
|
|
11
11
|
options: CliOptions;
|
|
12
|
-
|
|
12
|
+
patterns: string[];
|
|
13
13
|
}
|
|
14
14
|
export declare class CLIArgumentError extends Error {
|
|
15
15
|
constructor(message: string);
|
|
16
16
|
}
|
|
17
17
|
export declare class CLIArgumentParser {
|
|
18
|
+
private readonly argv;
|
|
19
|
+
private readonly log;
|
|
20
|
+
constructor(argv?: () => string[], log?: (message: string) => void);
|
|
18
21
|
private safeExtractValue;
|
|
19
22
|
private validateAndThrow;
|
|
20
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;AA2BjE,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,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAsED,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;IAmEjB,YAAY,IAAI,IAAI;IAIpB,KAAK,IAAI,UAAU;CAuK3B"}
|
|
@@ -1,19 +1,82 @@
|
|
|
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 } 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
|
+
const extractNamedOnlyOverride = (args) => {
|
|
35
|
+
const remainingArgs = [];
|
|
36
|
+
let namedOnlyOverride;
|
|
37
|
+
for (const arg of args) {
|
|
38
|
+
if (arg === '--no-named-only') {
|
|
39
|
+
namedOnlyOverride = false;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (arg === '--named-only=true') {
|
|
43
|
+
namedOnlyOverride = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (arg === '--named-only=false') {
|
|
47
|
+
namedOnlyOverride = false;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
remainingArgs.push(arg);
|
|
51
|
+
}
|
|
52
|
+
return { remainingArgs, namedOnlyOverride };
|
|
53
|
+
};
|
|
54
|
+
const validateDepthFlag = (raw) => {
|
|
55
|
+
if (raw === 'Infinity') {
|
|
56
|
+
return { success: true, value: Infinity };
|
|
57
|
+
}
|
|
58
|
+
if (!/^-?\d+$/.test(raw)) {
|
|
59
|
+
return {
|
|
60
|
+
success: false,
|
|
61
|
+
error: `Depth must be a non-negative integer or "Infinity", got "${raw}"`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const parsed = Number.parseInt(raw, 10);
|
|
65
|
+
if (parsed < 0) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: `Depth must be a non-negative integer or "Infinity", got "${raw}"`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return { success: true, value: parsed };
|
|
72
|
+
};
|
|
73
|
+
export class CLIArgumentParser {
|
|
74
|
+
argv;
|
|
75
|
+
log;
|
|
76
|
+
constructor(argv = () => process.argv, log = (message) => console.log(message)) {
|
|
77
|
+
this.argv = argv;
|
|
78
|
+
this.log = log;
|
|
79
|
+
}
|
|
17
80
|
// Type guard to safely extract unknown values from parseArgs result
|
|
18
81
|
safeExtractValue(value, defaultValue) {
|
|
19
82
|
// Use proper type narrowing instead of type assertions
|
|
@@ -35,34 +98,54 @@ class CLIArgumentParser {
|
|
|
35
98
|
return validation.value;
|
|
36
99
|
}
|
|
37
100
|
printHelp() {
|
|
38
|
-
|
|
101
|
+
this.log(`
|
|
39
102
|
🌳 Code Outline CLI - Parse and analyze JavaScript/TypeScript files
|
|
40
103
|
|
|
41
104
|
Usage:
|
|
42
|
-
code-outline <pattern
|
|
105
|
+
code-outline <pattern>... [options]
|
|
43
106
|
|
|
44
107
|
Arguments:
|
|
45
|
-
<pattern
|
|
108
|
+
<pattern>... One or more glob patterns to match files (e.g., "src/**/*.ts", "*.js").
|
|
109
|
+
Matches from every pattern are unioned and deduped by absolute path.
|
|
46
110
|
|
|
47
111
|
Options:
|
|
48
112
|
-f, --format <type> Output format: ascii, json, yaml, or llmtext (default: ascii)
|
|
49
|
-
-d, --depth <n> Maximum AST depth to traverse
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
--
|
|
113
|
+
-d, --depth <n> Maximum AST depth to traverse: a non-negative integer, or
|
|
114
|
+
"Infinity" (default: Infinity). 0 means top-level only.
|
|
115
|
+
-a, --all Show all nodes, including unnamed ones. Implies --no-named-only.
|
|
116
|
+
--named-only Show only named entities (default: true). Accepts
|
|
117
|
+
--no-named-only or --named-only=false to disable; --all
|
|
118
|
+
disables it too. Mutually exclusive with --all in the
|
|
119
|
+
"widen" direction: --all always wins.
|
|
120
|
+
--llmtext Use LLM-optimized compressed text format. Errors if combined
|
|
121
|
+
with an explicit --format other than llmtext.
|
|
53
122
|
-h, --help Show this help message
|
|
54
123
|
-v, --version Show version number
|
|
55
124
|
|
|
125
|
+
Exit Codes:
|
|
126
|
+
0 Success, or -h/--help/-v/--version requested
|
|
127
|
+
1 Any error: unknown option, invalid flag value, no pattern given, no files
|
|
128
|
+
matched, a file that failed to parse, or conflicting flags
|
|
129
|
+
|
|
56
130
|
Output Formats:
|
|
57
131
|
ascii Tree-like visualization with color-coded syntax (default)
|
|
58
132
|
json Structured JSON output for programmatic processing
|
|
59
133
|
yaml Human-readable YAML format
|
|
60
134
|
llmtext Compressed text format optimized for LLM consumption
|
|
61
135
|
|
|
136
|
+
Position Numbering:
|
|
137
|
+
ascii and llmtext print [line:col] using 1-based line and 1-based column.
|
|
138
|
+
json and yaml keep tree-sitter's native start/end row and column, which
|
|
139
|
+
are 0-based, so a node at row 0, column 0 prints as [1:1] in ascii and
|
|
140
|
+
llmtext but as {"row": 0, "column": 0} in json and yaml.
|
|
141
|
+
|
|
62
142
|
Examples:
|
|
63
143
|
# Parse all TypeScript files in src directory
|
|
64
144
|
code-outline "src/**/*.ts"
|
|
65
145
|
|
|
146
|
+
# Parse multiple patterns at once; matches are unioned and deduped
|
|
147
|
+
code-outline "src/**/*.ts" "test/**/*.ts"
|
|
148
|
+
|
|
66
149
|
# Output JSON with depth limit
|
|
67
150
|
code-outline "*.js" --format json --depth 3
|
|
68
151
|
|
|
@@ -74,51 +157,66 @@ Examples:
|
|
|
74
157
|
|
|
75
158
|
Supported Files:
|
|
76
159
|
.js JavaScript files
|
|
77
|
-
.ts TypeScript files
|
|
160
|
+
.ts TypeScript files
|
|
78
161
|
.tsx TypeScript JSX files
|
|
79
162
|
|
|
80
163
|
For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
81
164
|
`);
|
|
82
165
|
}
|
|
83
166
|
printVersion() {
|
|
84
|
-
|
|
167
|
+
this.log(version);
|
|
85
168
|
}
|
|
86
169
|
parse() {
|
|
87
|
-
const {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
170
|
+
const { remainingArgs, namedOnlyOverride } = extractNamedOnlyOverride(this.argv().slice(2));
|
|
171
|
+
let values;
|
|
172
|
+
let positionals;
|
|
173
|
+
let tokens;
|
|
174
|
+
try {
|
|
175
|
+
({ values, positionals, tokens } = parseArgs({
|
|
176
|
+
args: remainingArgs,
|
|
177
|
+
tokens: true,
|
|
178
|
+
options: {
|
|
179
|
+
format: {
|
|
180
|
+
type: 'string',
|
|
181
|
+
short: 'f',
|
|
182
|
+
default: 'ascii',
|
|
183
|
+
},
|
|
184
|
+
depth: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
short: 'd',
|
|
187
|
+
default: 'Infinity',
|
|
188
|
+
},
|
|
189
|
+
'named-only': {
|
|
190
|
+
type: 'boolean',
|
|
191
|
+
default: true,
|
|
192
|
+
},
|
|
193
|
+
all: {
|
|
194
|
+
type: 'boolean',
|
|
195
|
+
short: 'a',
|
|
196
|
+
default: false,
|
|
197
|
+
},
|
|
198
|
+
llmtext: {
|
|
199
|
+
type: 'boolean',
|
|
200
|
+
default: false,
|
|
201
|
+
},
|
|
202
|
+
help: {
|
|
203
|
+
type: 'boolean',
|
|
204
|
+
short: 'h',
|
|
205
|
+
default: false,
|
|
206
|
+
},
|
|
207
|
+
version: {
|
|
208
|
+
type: 'boolean',
|
|
209
|
+
short: 'v',
|
|
210
|
+
default: false,
|
|
211
|
+
},
|
|
113
212
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
213
|
+
allowPositionals: true,
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
const message = error instanceof Error ? error.message : 'Unknown option';
|
|
218
|
+
throw new CLIArgumentError(message);
|
|
219
|
+
}
|
|
122
220
|
if (values.help) {
|
|
123
221
|
this.printHelp();
|
|
124
222
|
process.exit(0);
|
|
@@ -130,23 +228,44 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
130
228
|
if (positionals.length === 0) {
|
|
131
229
|
throw new CLIArgumentError('No file pattern provided');
|
|
132
230
|
}
|
|
231
|
+
// Whether --format was explicitly passed, before we apply the --llmtext
|
|
232
|
+
// override below. parseArgs fills `values.format` with its default even
|
|
233
|
+
// when the flag was never on the command line, so `typeof` alone cannot
|
|
234
|
+
// tell "user asked for json" apart from "format defaulted to ascii" --
|
|
235
|
+
// only the token stream can. This is what makes conflicting-flag
|
|
236
|
+
// detection (issue #20) possible.
|
|
237
|
+
const formatExplicitlyProvided = tokens.some((token) => token.kind === 'option' && token.name === 'format');
|
|
133
238
|
// Safely validate format using type guard
|
|
134
|
-
const formatValidation =
|
|
239
|
+
const formatValidation = validateFormat(values.format);
|
|
135
240
|
const format = this.validateAndThrow(formatValidation, 'Invalid format');
|
|
136
|
-
// Safely validate depth using validator
|
|
137
|
-
|
|
241
|
+
// Safely validate depth using the local validator (issue #21: 0 is valid,
|
|
242
|
+
// non-integers are rejected outright rather than silently floored)
|
|
243
|
+
const depthRaw = this.safeExtractValue(values.depth, 'Infinity');
|
|
244
|
+
const depthValidation = validateDepthFlag(depthRaw);
|
|
138
245
|
const depth = this.validateAndThrow(depthValidation, 'Invalid depth');
|
|
139
|
-
const
|
|
140
|
-
? false
|
|
141
|
-
: this.safeExtractValue(values['named-only'], true);
|
|
246
|
+
const allFlag = this.safeExtractValue(values.all, false);
|
|
142
247
|
const llmtext = this.safeExtractValue(values.llmtext, false);
|
|
248
|
+
if (llmtext && formatExplicitlyProvided && format !== 'llmtext') {
|
|
249
|
+
throw new CLIArgumentError(`--llmtext conflicts with --format ${format}. Pass only one, or set --format llmtext.`);
|
|
250
|
+
}
|
|
251
|
+
// --all always widens output regardless of --named-only/--no-named-only.
|
|
252
|
+
// Otherwise an explicit --no-named-only/--named-only=false wins over the
|
|
253
|
+
// boolean flag's default; absent any override, the boolean flag's own
|
|
254
|
+
// value (default true) applies.
|
|
255
|
+
const namedOnly = allFlag
|
|
256
|
+
? false
|
|
257
|
+
: (namedOnlyOverride ??
|
|
258
|
+
this.safeExtractValue(values['named-only'], true));
|
|
143
259
|
// If --llmtext flag is provided, override format to 'llmtext'
|
|
144
260
|
const finalFormat = llmtext ? 'llmtext' : format;
|
|
145
|
-
const
|
|
261
|
+
const patterns = [...new Set(positionals)];
|
|
146
262
|
// Warn if the pattern doesn't contain glob characters but looks like it should
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
263
|
+
for (const pattern of patterns) {
|
|
264
|
+
if (pattern.includes('*') ||
|
|
265
|
+
pattern.includes('?') ||
|
|
266
|
+
pattern.includes('[')) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
150
269
|
// Check if it's likely intended to be a glob pattern (directory-like structure)
|
|
151
270
|
const pathSegments = pattern
|
|
152
271
|
.split('/')
|
|
@@ -155,9 +274,8 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
155
274
|
const endsWithCommonExtension = /\.(ts|js|tsx|jsx)$/.test(pattern);
|
|
156
275
|
// Only warn if it's not an absolute path AND not an existing file
|
|
157
276
|
// (relative paths with many segments are likely intended as globs, but existing files should not warn)
|
|
158
|
-
const isAbsolutePath =
|
|
159
|
-
const fileExists =
|
|
160
|
-
// Debug: Show the evaluation
|
|
277
|
+
const isAbsolutePath = isAbsolute(pattern);
|
|
278
|
+
const fileExists = existsSync(pattern);
|
|
161
279
|
const shouldWarn = hasMultipleSegments &&
|
|
162
280
|
endsWithCommonExtension &&
|
|
163
281
|
!isAbsolutePath &&
|
|
@@ -178,9 +296,8 @@ For more information, visit: https://github.com/sammons2/code-outline-cli
|
|
|
178
296
|
help: false,
|
|
179
297
|
version: false,
|
|
180
298
|
},
|
|
181
|
-
|
|
299
|
+
patterns,
|
|
182
300
|
};
|
|
183
301
|
}
|
|
184
302
|
}
|
|
185
|
-
exports.CLIArgumentParser = CLIArgumentParser;
|
|
186
303
|
//# 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","sourceRoot":"","sources":["../src/cli-argument-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,qBAAqB;AACrB,MAAM,WAAW,GAAG,GAAW,EAAE;IAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;IACjC,KAAK,MAAM,SAAS,IAAI;QACtB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC;QAChC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC;KACvC,EAAE,CAAC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-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;AAExE,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;CAkHlC"}
|