@idea1/cli 1.2.2 → 1.3.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 +19 -152
- package/dist/cli/parser.d.ts +20 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +105 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/resolver.d.ts +16 -0
- package/dist/cli/resolver.d.ts.map +1 -0
- package/dist/cli/resolver.js +72 -0
- package/dist/cli/resolver.js.map +1 -0
- package/dist/cli.d.ts +0 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +38 -357
- package/dist/cli.js.map +1 -1
- package/dist/commands/approve-pr.d.ts.map +1 -1
- package/dist/commands/approve-pr.js +13 -28
- package/dist/commands/approve-pr.js.map +1 -1
- package/dist/commands/close-worktree.d.ts.map +1 -1
- package/dist/commands/close-worktree.js +29 -42
- package/dist/commands/close-worktree.js.map +1 -1
- package/dist/commands/create-worktree.d.ts.map +1 -1
- package/dist/commands/create-worktree.js +34 -55
- package/dist/commands/create-worktree.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +107 -68
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/index.d.ts +2 -2
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +10 -8
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/next-workflow-step.js +4 -4
- package/dist/commands/next-workflow-step.js.map +1 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +45 -54
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/ready-for-approval.d.ts.map +1 -1
- package/dist/commands/ready-for-approval.js +25 -62
- package/dist/commands/ready-for-approval.js.map +1 -1
- package/dist/commands/release.d.ts.map +1 -1
- package/dist/commands/release.js +47 -98
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/start-dev-implementation.d.ts.map +1 -1
- package/dist/commands/start-dev-implementation.js +41 -43
- package/dist/commands/start-dev-implementation.js.map +1 -1
- package/dist/commands/start-project-item.d.ts.map +1 -1
- package/dist/commands/start-project-item.js +214 -150
- package/dist/commands/start-project-item.js.map +1 -1
- package/dist/commands/update-branch.d.ts +3 -0
- package/dist/commands/update-branch.d.ts.map +1 -0
- package/dist/commands/update-branch.js +191 -0
- package/dist/commands/update-branch.js.map +1 -0
- package/dist/commands/update-docs.js +1 -1
- package/dist/commands/update-docs.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/interactive.d.ts +19 -0
- package/dist/interactive.d.ts.map +1 -1
- package/dist/interactive.js +14 -56
- package/dist/interactive.js.map +1 -1
- package/dist/lib/settings.d.ts +18 -0
- package/dist/lib/settings.d.ts.map +1 -1
- package/dist/lib/settings.js +30 -0
- package/dist/lib/settings.js.map +1 -1
- package/dist/services/claude.d.ts +5 -0
- package/dist/services/claude.d.ts.map +1 -1
- package/dist/services/claude.js +16 -0
- package/dist/services/claude.js.map +1 -1
- package/dist/services/config.d.ts +8 -0
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +14 -1
- package/dist/services/config.js.map +1 -1
- package/dist/services/git.d.ts +49 -0
- package/dist/services/git.d.ts.map +1 -1
- package/dist/services/git.js +129 -2
- package/dist/services/git.js.map +1 -1
- package/dist/services/worktree.d.ts +36 -2
- package/dist/services/worktree.d.ts.map +1 -1
- package/dist/services/worktree.js +164 -7
- package/dist/services/worktree.js.map +1 -1
- package/dist/types/index.d.ts +31 -93
- package/dist/types/index.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -25,66 +25,23 @@ idea1 ready-for-approval john # or: idea1 rfa john
|
|
|
25
25
|
idea1 approve-pr # or: idea1 approve
|
|
26
26
|
idea1 next-workflow-step # or: idea1 next
|
|
27
27
|
|
|
28
|
-
# Create a new worktree (without a project item)
|
|
29
|
-
idea1 create-worktree my-feature
|
|
30
|
-
idea1 -w my-feature -d main
|
|
31
|
-
|
|
32
|
-
# Commit, push, and create PR
|
|
33
|
-
idea1 push
|
|
34
|
-
idea1 -p --no-tests
|
|
35
|
-
|
|
36
|
-
# Close worktree and create PR
|
|
37
|
-
idea1 close-worktree
|
|
38
|
-
idea1 -c --prompt-pr
|
|
39
|
-
|
|
40
|
-
# Update documentation
|
|
41
|
-
idea1 update-docs
|
|
42
|
-
|
|
43
28
|
# Show help
|
|
44
29
|
idea1 --help
|
|
45
30
|
```
|
|
46
31
|
|
|
47
32
|
### Interactive Mode
|
|
48
33
|
|
|
49
|
-
Run `idea1` without arguments to enter interactive mode with a searchable command interface
|
|
34
|
+
Run `idea1` without arguments to enter interactive mode with a searchable command interface.
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
╭──────────────────────────────────────────────────╮
|
|
55
|
-
│ │
|
|
56
|
-
│ Idea1 CLI v1.1.1 │
|
|
57
|
-
│ ~/src/my-repo-name │
|
|
58
|
-
│ │
|
|
59
|
-
│ Branch: working/agent/my-feature │
|
|
60
|
-
│ Base: working/release │
|
|
61
|
-
│ Workflow: Agent implementation │
|
|
62
|
-
│ Item: https://app.idea1.ai/project/items/123 │
|
|
63
|
-
│ │
|
|
64
|
-
╰──────────────────────────────────────────────────╯
|
|
65
|
-
|
|
66
|
-
Available commands:
|
|
67
|
-
/start-project-item (s, start) - Start implementing a project item
|
|
68
|
-
/start-dev-implementation (dev) - Transition to dev implementation
|
|
69
|
-
/ready-for-approval (rfa) - Mark PR ready for approval
|
|
70
|
-
/approve-pr (approve) - Approve and merge PR
|
|
71
|
-
/next-workflow-step (next, n) - Auto-perform next transition
|
|
72
|
-
/close-worktree (c, close) - Close current worktree and create PR
|
|
73
|
-
/push (p, push-changes) - Commit, push changes, and create PR
|
|
74
|
-
/update-docs (docs) - Update README.md for changed folders
|
|
75
|
-
/help (h) - Show help information
|
|
76
|
-
/exit (q, quit) - Exit the CLI
|
|
77
|
-
|
|
78
|
-
> [Type "/" to see commands, use arrow keys and tab to navigate, Enter to select]
|
|
79
|
-
```
|
|
36
|
+
## Commands
|
|
37
|
+
|
|
38
|
+
## Workflow Commands
|
|
80
39
|
|
|
81
|
-
|
|
82
|
-
- **Branch**: Current branch name
|
|
83
|
-
- **Base**: Base branch for PRs
|
|
84
|
-
- **Workflow**: Current workflow state (color-coded)
|
|
85
|
-
- **Item**: Associated Idea1.ai project item URL
|
|
40
|
+
The CLI provides a complete workflow automation system with state tracking. The workflow progresses through these states:
|
|
86
41
|
|
|
87
|
-
|
|
42
|
+
```
|
|
43
|
+
Agent Implementation → Dev Implementation → PR needs Approval → Complete
|
|
44
|
+
```
|
|
88
45
|
|
|
89
46
|
### start-project-item
|
|
90
47
|
|
|
@@ -100,12 +57,10 @@ idea1 -s <url> [branch-name] [options]
|
|
|
100
57
|
- `[branch-name]` - Custom branch name (optional, auto-generated from item description if not provided)
|
|
101
58
|
|
|
102
59
|
**Options:**
|
|
103
|
-
- `-m, --isolation-mode <mode>` - Isolation mode: `worktree` (default) or `container` (not yet implemented)
|
|
104
60
|
- `-p, --source-path <path>` - Path to source directory
|
|
105
61
|
- `-b, --base-branch <branch>` - Base branch (default: `working/release`). Use `prompt` to interactively select.
|
|
106
62
|
- `-pm, --permission-mode <mode>` - Claude permission mode (default: `plan`). Valid values: `acceptEdits`, `bypassPermissions`, `default`, `delegate`, `dontAsk`, `plan`
|
|
107
|
-
- `--
|
|
108
|
-
- `--disable-firewall` - Disable network firewall (container mode only, not yet implemented)
|
|
63
|
+
- `--claude-entry-point <mode>` - How Claude is invoked after setup (default: `launch`). Valid values: `launch` (start a new Claude session), `inline` (output structured prompt for an already-running Claude session), `none` (do not invoke Claude)
|
|
109
64
|
|
|
110
65
|
**What it does:**
|
|
111
66
|
1. Sets the item's workflow status to "Agent implementation"
|
|
@@ -115,98 +70,9 @@ idea1 -s <url> [branch-name] [options]
|
|
|
115
70
|
5. Runs any setup hooks defined in `.idea1/settings.json`
|
|
116
71
|
6. Launches Claude Code with the implementation prompt
|
|
117
72
|
|
|
118
|
-
### create-worktree
|
|
119
|
-
|
|
120
|
-
Create a new branch and git worktree for development (without a project item).
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
idea1 create-worktree <branch-name> [options]
|
|
124
|
-
idea1 -w <branch-name> [options]
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Arguments:**
|
|
128
|
-
- `<branch-name>` - Name for the new branch (required)
|
|
129
|
-
|
|
130
|
-
**Options:**
|
|
131
|
-
- `-d, --dest-branch <branch>` - Base branch to branch from (default: from settings or `working/release`)
|
|
132
|
-
- `-p, --branch-prefix <prefix>` - Prefix for new branch (default: from settings or `working/agent`)
|
|
133
|
-
- `-s, --source-path <path>` - Path to source directory
|
|
134
|
-
|
|
135
|
-
**What it does:**
|
|
136
|
-
1. Creates a new branch from the base branch
|
|
137
|
-
2. Creates a git worktree for isolated development
|
|
138
|
-
3. Runs any setup hooks defined in `.idea1/settings.json`
|
|
139
|
-
|
|
140
|
-
### push
|
|
141
|
-
|
|
142
|
-
Commit and push changes, optionally creating a PR.
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
idea1 push [options]
|
|
146
|
-
idea1 -p [options]
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
**Options:**
|
|
150
|
-
- `-i, --project-item-url <url>` - Project item URL for commit message
|
|
151
|
-
- `--no-project-item` - Skip project item URL
|
|
152
|
-
- `--no-tests` - Skip running tests before PR creation
|
|
153
|
-
- `--create-pr <true|false>` - Whether to create PR (default: true)
|
|
154
|
-
- `-d, --dest-branch <branch>` - PR target branch
|
|
155
|
-
|
|
156
|
-
**What it does:**
|
|
157
|
-
1. Commits all changes with a descriptive message
|
|
158
|
-
2. Pushes to remote
|
|
159
|
-
3. Runs tests if configured (skippable with `--no-tests`)
|
|
160
|
-
4. Creates a PR if requested
|
|
161
|
-
|
|
162
|
-
### close-worktree
|
|
163
|
-
|
|
164
|
-
Close the current worktree, commit changes, and create a PR.
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
idea1 close-worktree [options]
|
|
168
|
-
idea1 -c [options]
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**Options:**
|
|
172
|
-
- `-p, --source-path <path>` - Path to worktree directory
|
|
173
|
-
- `-b, --base-branch <branch>` - Base branch for PR (uses stored preference by default)
|
|
174
|
-
- `--prompt-pr` - Prompt before creating PR
|
|
175
|
-
|
|
176
|
-
**What it does:**
|
|
177
|
-
1. Detects uncommitted changes and prompts for project item URL if needed
|
|
178
|
-
2. Commits and pushes changes
|
|
179
|
-
3. Creates a PR (or confirms existing PR)
|
|
180
|
-
4. Updates the item's workflow status to "Dev implementation"
|
|
181
|
-
5. Removes the git worktree
|
|
182
|
-
6. Cleans up orphaned branch configs
|
|
183
|
-
|
|
184
|
-
### update-docs
|
|
185
|
-
|
|
186
|
-
Update README.md files for folders with code changes.
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
idea1 update-docs
|
|
190
|
-
idea1 docs
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
**What it does:**
|
|
194
|
-
1. Finds all folders with staged, unstaged, or PR file changes
|
|
195
|
-
2. Classifies changes as "small" or "large" to determine update strategy
|
|
196
|
-
3. Uses Claude to update or create README.md files
|
|
197
|
-
4. Respects `.contextignore` patterns to skip folders
|
|
198
|
-
|
|
199
|
-
## Workflow Commands
|
|
200
|
-
|
|
201
|
-
The CLI provides a complete workflow automation system with state tracking. The workflow progresses through these states:
|
|
202
|
-
|
|
203
|
-
```
|
|
204
|
-
Agent Implementation → Dev Implementation → PR needs Approval → Complete
|
|
205
|
-
```
|
|
206
|
-
|
|
207
73
|
### start-dev-implementation
|
|
208
74
|
|
|
209
|
-
Transition from agent implementation to dev implementation -
|
|
75
|
+
Transition from agent implementation to dev implementation - commits, pushes, and creates PR.
|
|
210
76
|
|
|
211
77
|
```bash
|
|
212
78
|
idea1 start-dev-implementation [options]
|
|
@@ -220,7 +86,7 @@ idea1 dev [options]
|
|
|
220
86
|
1. Validates current state is "Agent implementation"
|
|
221
87
|
2. Commits and pushes all changes in the branch
|
|
222
88
|
3. Creates a PR of the branch into its base branch
|
|
223
|
-
4. If in a worktree
|
|
89
|
+
4. If in a worktree and `removeWorktreeOnDevTransition` is enabled in `.idea1/settings.json`, removes the worktree
|
|
224
90
|
5. Updates workflow state to "Dev implementation"
|
|
225
91
|
6. Updates Idea1.ai workflow status
|
|
226
92
|
|
|
@@ -245,6 +111,7 @@ idea1 rfa [reviewer] [options]
|
|
|
245
111
|
3. Assigns reviewer to the PR (if provided)
|
|
246
112
|
4. Updates workflow state to "PR needs Approval"
|
|
247
113
|
5. Updates Idea1.ai workflow status
|
|
114
|
+
6. If in a worktree, removes the worktree
|
|
248
115
|
|
|
249
116
|
### approve-pr
|
|
250
117
|
|
|
@@ -317,6 +184,7 @@ Create `.idea1/settings.json` in your repository root to configure repo-specific
|
|
|
317
184
|
- `branchPrefix` - Prefix for new branches (default: `working/agent`)
|
|
318
185
|
- `baseBranch` - Default base branch for branching (default: `working/release`)
|
|
319
186
|
- `testCommand` - Command to run tests before PR creation (e.g., `npm run test`)
|
|
187
|
+
- `removeWorktreeOnDevTransition` - Whether to remove the worktree when transitioning to dev implementation (default: `false`). The `ready-for-approval` transition always removes the worktree if running inside one.
|
|
320
188
|
|
|
321
189
|
### User Settings
|
|
322
190
|
|
|
@@ -343,16 +211,15 @@ Settings include:
|
|
|
343
211
|
# Build the CLI
|
|
344
212
|
npm run build
|
|
345
213
|
|
|
346
|
-
# Run
|
|
347
|
-
npm run
|
|
214
|
+
# Run directly from the local source code
|
|
215
|
+
npm run start
|
|
348
216
|
|
|
349
217
|
# Link globally for testing
|
|
350
218
|
npm link
|
|
351
219
|
|
|
352
|
-
#
|
|
220
|
+
# Install the CLI from the latest published idea1 command package
|
|
221
|
+
npm install -g @idea1/cli
|
|
222
|
+
|
|
223
|
+
# Run the CLI from the current installed idea1 command package
|
|
353
224
|
idea1 --help
|
|
354
225
|
```
|
|
355
|
-
|
|
356
|
-
## License
|
|
357
|
-
|
|
358
|
-
MIT
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Command, CommandOption } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the default value of an option (handles static and dynamic defaults)
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveDefault(option: CommandOption): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Parse command line arguments for a given command.
|
|
8
|
+
* All arguments must be named: --longName value or -shortName value.
|
|
9
|
+
* Flags set their value to "true".
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseCommandLine(args: string[], command: Command): Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Print global usage listing all commands
|
|
14
|
+
*/
|
|
15
|
+
export declare function printUsage(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Print per-command usage with all options
|
|
18
|
+
*/
|
|
19
|
+
export declare function printCommandUsage(command: Command): void;
|
|
20
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/cli/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGhE;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAGxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkCzF;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAsBjC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyCxD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getAllCommands } from '../commands/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the default value of an option (handles static and dynamic defaults)
|
|
5
|
+
*/
|
|
6
|
+
export function resolveDefault(option) {
|
|
7
|
+
if (option.defaultValue === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
return typeof option.defaultValue === 'function' ? option.defaultValue() : option.defaultValue;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse command line arguments for a given command.
|
|
13
|
+
* All arguments must be named: --longName value or -shortName value.
|
|
14
|
+
* Flags set their value to "true".
|
|
15
|
+
*/
|
|
16
|
+
export function parseCommandLine(args, command) {
|
|
17
|
+
const options = command.options ?? [];
|
|
18
|
+
const parsed = {};
|
|
19
|
+
let i = 0;
|
|
20
|
+
while (i < args.length) {
|
|
21
|
+
const arg = args[i];
|
|
22
|
+
if (!arg.startsWith('-')) {
|
|
23
|
+
throw new Error(`Unexpected argument: ${arg}. All arguments must be named (--option value or -o value).`);
|
|
24
|
+
}
|
|
25
|
+
const matchedOption = options.find(o => arg === `--${o.longName}` || (o.shortName && arg === `-${o.shortName}`));
|
|
26
|
+
if (!matchedOption) {
|
|
27
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
28
|
+
}
|
|
29
|
+
if (matchedOption.isFlag) {
|
|
30
|
+
parsed[matchedOption.longName] = 'true';
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
i++;
|
|
34
|
+
if (i >= args.length) {
|
|
35
|
+
throw new Error(`Option ${arg} requires a value`);
|
|
36
|
+
}
|
|
37
|
+
parsed[matchedOption.longName] = args[i];
|
|
38
|
+
}
|
|
39
|
+
i++;
|
|
40
|
+
}
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Print global usage listing all commands
|
|
45
|
+
*/
|
|
46
|
+
export function printUsage() {
|
|
47
|
+
const commands = getAllCommands();
|
|
48
|
+
console.log(chalk.bold('Idea1 CLI - AI-assisted development workflow automation'));
|
|
49
|
+
console.log();
|
|
50
|
+
console.log(chalk.bold('USAGE:'));
|
|
51
|
+
console.log(' idea1 <command> [options]');
|
|
52
|
+
console.log(' idea1 Launch interactive mode');
|
|
53
|
+
console.log();
|
|
54
|
+
console.log(chalk.bold('COMMANDS:'));
|
|
55
|
+
const maxWidth = Math.max(...commands.map(c => c.name.length));
|
|
56
|
+
for (const cmd of commands) {
|
|
57
|
+
const aliases = cmd.aliases.length > 0 ? chalk.dim(` (${cmd.aliases.join(', ')})`) : '';
|
|
58
|
+
const padding = ' '.repeat(maxWidth - cmd.name.length + 2);
|
|
59
|
+
console.log(` ${cmd.name}${padding}${cmd.description}${aliases}`);
|
|
60
|
+
}
|
|
61
|
+
console.log();
|
|
62
|
+
console.log("Run 'idea1 <command> --help' for command-specific options.");
|
|
63
|
+
console.log();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Print per-command usage with all options
|
|
67
|
+
*/
|
|
68
|
+
export function printCommandUsage(command) {
|
|
69
|
+
const options = command.options ?? [];
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(`Usage: idea1 ${command.name} [options]`);
|
|
72
|
+
console.log();
|
|
73
|
+
console.log(` ${command.description}`);
|
|
74
|
+
if (options.length > 0) {
|
|
75
|
+
console.log();
|
|
76
|
+
console.log('Options:');
|
|
77
|
+
for (const option of options) {
|
|
78
|
+
const forms = option.shortName
|
|
79
|
+
? `-${option.shortName}, --${option.longName}`
|
|
80
|
+
: ` --${option.longName}`;
|
|
81
|
+
let defaultText = '';
|
|
82
|
+
if (option.isFlag) {
|
|
83
|
+
defaultText = '';
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const resolved = resolveDefault(option);
|
|
87
|
+
if (resolved !== undefined) {
|
|
88
|
+
defaultText = resolved ? ` (default: ${resolved})` : '';
|
|
89
|
+
}
|
|
90
|
+
else if (option.validate) {
|
|
91
|
+
// Only mark as required when a validator exists to enforce it
|
|
92
|
+
defaultText = ' (required)';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const padding = Math.max(0, 30 - forms.length);
|
|
96
|
+
console.log(` ${forms}${' '.repeat(padding)} ${option.description}${defaultText}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (command.aliases.length > 0) {
|
|
100
|
+
console.log();
|
|
101
|
+
console.log(`Aliases: ${command.aliases.join(', ')}`);
|
|
102
|
+
}
|
|
103
|
+
console.log();
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/cli/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAqB;IAClD,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxD,OAAO,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;AACjG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAc,EAAE,OAAgB;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IACtC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEpB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,6DAA6D,CAAC,CAAC;QAC5G,CAAC;QAED,MAAM,aA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C;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Command } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve all options for a command.
|
|
4
|
+
* Fills in missing values by prompting interactively or using defaults.
|
|
5
|
+
*
|
|
6
|
+
* For each option in command.options (in order):
|
|
7
|
+
* 1. Skip if isFlag — flags are never prompted
|
|
8
|
+
* 2. Skip if already in parsed — value was provided on CLI
|
|
9
|
+
* 3. If has default and promptWhenDefaultExists is not true: silently use default
|
|
10
|
+
* 4. If no default: prompt (required — re-prompt until valid value given)
|
|
11
|
+
* 5. If has default and promptWhenDefaultExists is true: prompt showing default as hint
|
|
12
|
+
* 6. Use promptSelection if option has choices, else promptTextInput
|
|
13
|
+
* 7. If validate exists, check the value; re-prompt on error
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveOptions(command: Command, parsed: Record<string, string>): Promise<Record<string, string>>;
|
|
16
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/cli/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAoEjC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { promptTextInput, promptSelection } from '../interactive.js';
|
|
2
|
+
import { resolveDefault } from './parser.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve all options for a command.
|
|
5
|
+
* Fills in missing values by prompting interactively or using defaults.
|
|
6
|
+
*
|
|
7
|
+
* For each option in command.options (in order):
|
|
8
|
+
* 1. Skip if isFlag — flags are never prompted
|
|
9
|
+
* 2. Skip if already in parsed — value was provided on CLI
|
|
10
|
+
* 3. If has default and promptWhenDefaultExists is not true: silently use default
|
|
11
|
+
* 4. If no default: prompt (required — re-prompt until valid value given)
|
|
12
|
+
* 5. If has default and promptWhenDefaultExists is true: prompt showing default as hint
|
|
13
|
+
* 6. Use promptSelection if option has choices, else promptTextInput
|
|
14
|
+
* 7. If validate exists, check the value; re-prompt on error
|
|
15
|
+
*/
|
|
16
|
+
export async function resolveOptions(command, parsed) {
|
|
17
|
+
const resolved = { ...parsed };
|
|
18
|
+
const options = command.options ?? [];
|
|
19
|
+
for (const option of options) {
|
|
20
|
+
// Skip flags — they're never prompted
|
|
21
|
+
if (option.isFlag) {
|
|
22
|
+
if (!(option.longName in resolved)) {
|
|
23
|
+
resolved[option.longName] = 'false';
|
|
24
|
+
}
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
// Skip if already provided on CLI
|
|
28
|
+
if (option.longName in resolved) {
|
|
29
|
+
// Validate if validator exists
|
|
30
|
+
if (option.validate) {
|
|
31
|
+
const error = option.validate(resolved[option.longName]);
|
|
32
|
+
if (error) {
|
|
33
|
+
throw new Error(`Invalid value for --${option.longName}: ${error}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const defaultVal = resolveDefault(option);
|
|
39
|
+
const hasDefault = defaultVal !== undefined;
|
|
40
|
+
const promptWhenDefault = option.promptWhenDefaultExists !== false; // default true
|
|
41
|
+
// Has default and should NOT prompt: silently use default
|
|
42
|
+
if (hasDefault && !promptWhenDefault) {
|
|
43
|
+
resolved[option.longName] = defaultVal;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// Need to prompt — either required (no default) or has default with promptWhenDefaultExists
|
|
47
|
+
let value;
|
|
48
|
+
// eslint-disable-next-line no-constant-condition
|
|
49
|
+
while (true) {
|
|
50
|
+
if (option.choices && option.choices.length > 0) {
|
|
51
|
+
value = await promptSelection(option.description, option.choices, defaultVal);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
value = await promptTextInput(option.description, defaultVal);
|
|
55
|
+
}
|
|
56
|
+
// Validate — this is the sole mechanism for enforcing required/non-empty.
|
|
57
|
+
// Options that need non-empty values should declare a validate function.
|
|
58
|
+
if (option.validate) {
|
|
59
|
+
const error = option.validate(value);
|
|
60
|
+
if (error) {
|
|
61
|
+
const { logger } = await import('../lib/logger.js');
|
|
62
|
+
logger.error(error);
|
|
63
|
+
continue; // Re-prompt
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
resolved[option.longName] = value ?? '';
|
|
69
|
+
}
|
|
70
|
+
return resolved;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/cli/resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAgB,EAChB,MAA8B;IAE9B,MAAM,QAAQ,GAA2B,EAAE,GAAG,MAAM,EAAE,CAAC;IACvD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;IAEtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,sCAAsC;QACtC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE,CAAC;gBACnC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;YACtC,CAAC;YACD,SAAS;QACX,CAAC;QAED,kCAAkC;QAClC,IAAI,MA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C;gBACrC,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;oBACpD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACpB,SAAS,CAAC,YAAY;gBACxB,CAAC;YACH,CAAC;YAED,MAAM;QACR,CAAC;QAED,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmE1D"}
|