aiwcli 0.9.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 +1248 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +16 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +19 -0
- package/dist/commands/branch.d.ts +45 -0
- package/dist/commands/branch.js +488 -0
- package/dist/commands/clean.d.ts +34 -0
- package/dist/commands/clean.js +186 -0
- package/dist/commands/clear.d.ts +51 -0
- package/dist/commands/clear.js +835 -0
- package/dist/commands/init/index.d.ts +107 -0
- package/dist/commands/init/index.js +565 -0
- package/dist/commands/launch.d.ts +21 -0
- package/dist/commands/launch.js +108 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/base-command.d.ts +114 -0
- package/dist/lib/base-command.js +153 -0
- package/dist/lib/bmad-installer.d.ts +38 -0
- package/dist/lib/bmad-installer.js +145 -0
- package/dist/lib/claude-settings-types.d.ts +102 -0
- package/dist/lib/claude-settings-types.js +5 -0
- package/dist/lib/config.d.ts +25 -0
- package/dist/lib/config.js +46 -0
- package/dist/lib/debug.d.ts +39 -0
- package/dist/lib/debug.js +74 -0
- package/dist/lib/env-compat.d.ts +26 -0
- package/dist/lib/env-compat.js +35 -0
- package/dist/lib/errors.d.ts +126 -0
- package/dist/lib/errors.js +145 -0
- package/dist/lib/generic-merge.d.ts +74 -0
- package/dist/lib/generic-merge.js +105 -0
- package/dist/lib/git/branch.d.ts +67 -0
- package/dist/lib/git/branch.js +155 -0
- package/dist/lib/git/index.d.ts +11 -0
- package/dist/lib/git/index.js +13 -0
- package/dist/lib/git/safety-checks.d.ts +44 -0
- package/dist/lib/git/safety-checks.js +102 -0
- package/dist/lib/git/types.d.ts +31 -0
- package/dist/lib/git/types.js +6 -0
- package/dist/lib/git/worktree.d.ts +67 -0
- package/dist/lib/git/worktree.js +220 -0
- package/dist/lib/gitignore-manager.d.ts +10 -0
- package/dist/lib/gitignore-manager.js +60 -0
- package/dist/lib/hooks-merger.d.ts +28 -0
- package/dist/lib/hooks-merger.js +94 -0
- package/dist/lib/ide-path-resolver.d.ts +102 -0
- package/dist/lib/ide-path-resolver.js +129 -0
- package/dist/lib/index.d.ts +13 -0
- package/dist/lib/index.js +22 -0
- package/dist/lib/output.d.ts +51 -0
- package/dist/lib/output.js +76 -0
- package/dist/lib/paths.d.ts +66 -0
- package/dist/lib/paths.js +136 -0
- package/dist/lib/quiet.d.ts +12 -0
- package/dist/lib/quiet.js +17 -0
- package/dist/lib/settings-hierarchy.d.ts +42 -0
- package/dist/lib/settings-hierarchy.js +105 -0
- package/dist/lib/spawn.d.ts +105 -0
- package/dist/lib/spawn.js +157 -0
- package/dist/lib/spinner.d.ts +19 -0
- package/dist/lib/spinner.js +34 -0
- package/dist/lib/stdin.d.ts +48 -0
- package/dist/lib/stdin.js +60 -0
- package/dist/lib/template-installer.d.ts +92 -0
- package/dist/lib/template-installer.js +375 -0
- package/dist/lib/template-linter.d.ts +49 -0
- package/dist/lib/template-linter.js +173 -0
- package/dist/lib/template-merger.d.ts +47 -0
- package/dist/lib/template-merger.js +173 -0
- package/dist/lib/template-resolver.d.ts +20 -0
- package/dist/lib/template-resolver.js +60 -0
- package/dist/lib/terminal.d.ts +102 -0
- package/dist/lib/terminal.js +245 -0
- package/dist/lib/tty-detection.d.ts +62 -0
- package/dist/lib/tty-detection.js +83 -0
- package/dist/lib/user-utils.d.ts +5 -0
- package/dist/lib/user-utils.js +23 -0
- package/dist/lib/version.d.ts +99 -0
- package/dist/lib/version.js +144 -0
- package/dist/lib/watch-templates.d.ts +6 -0
- package/dist/lib/watch-templates.js +73 -0
- package/dist/lib/windsurf-hooks-hierarchy.d.ts +30 -0
- package/dist/lib/windsurf-hooks-hierarchy.js +66 -0
- package/dist/lib/windsurf-hooks-merger.d.ts +26 -0
- package/dist/lib/windsurf-hooks-merger.js +53 -0
- package/dist/lib/windsurf-hooks-types.d.ts +33 -0
- package/dist/lib/windsurf-hooks-types.js +5 -0
- package/dist/templates/CLAUDE.md +174 -0
- package/dist/templates/_shared/.claude/commands/handoff.md +14 -0
- package/dist/templates/_shared/.claude/settings.json +61 -0
- package/dist/templates/_shared/.codex/workflows/handoff.md +14 -0
- package/dist/templates/_shared/.windsurf/workflows/handoff.md +14 -0
- package/dist/templates/_shared/hooks/__init__.py +16 -0
- package/dist/templates/_shared/hooks/archive_plan.py +270 -0
- package/dist/templates/_shared/hooks/context_enforcer.py +621 -0
- package/dist/templates/_shared/hooks/context_monitor.py +322 -0
- package/dist/templates/_shared/hooks/file-suggestion.py +188 -0
- package/dist/templates/_shared/hooks/task_create_capture.py +194 -0
- package/dist/templates/_shared/hooks/task_update_capture.py +254 -0
- package/dist/templates/_shared/hooks/user_prompt_submit.py +157 -0
- package/dist/templates/_shared/lib/__init__.py +1 -0
- package/dist/templates/_shared/lib/base/__init__.py +49 -0
- package/dist/templates/_shared/lib/base/__pycache__/constants.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/base/atomic_write.py +180 -0
- package/dist/templates/_shared/lib/base/constants.py +299 -0
- package/dist/templates/_shared/lib/base/inference.py +189 -0
- package/dist/templates/_shared/lib/base/utils.py +216 -0
- package/dist/templates/_shared/lib/context/__init__.py +119 -0
- package/dist/templates/_shared/lib/context/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/cache.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/context_manager.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/__pycache__/event_log.cpython-313.pyc +0 -0
- package/dist/templates/_shared/lib/context/cache.py +446 -0
- package/dist/templates/_shared/lib/context/context_manager.py +1171 -0
- package/dist/templates/_shared/lib/context/discovery.py +486 -0
- package/dist/templates/_shared/lib/context/event_log.py +308 -0
- package/dist/templates/_shared/lib/context/plan_archive.py +247 -0
- package/dist/templates/_shared/lib/context/task_sync.py +367 -0
- package/dist/templates/_shared/lib/handoff/__init__.py +22 -0
- package/dist/templates/_shared/lib/handoff/document_generator.py +307 -0
- package/dist/templates/_shared/lib/templates/README.md +215 -0
- package/dist/templates/_shared/lib/templates/__init__.py +40 -0
- package/dist/templates/_shared/lib/templates/formatters.py +147 -0
- package/dist/templates/_shared/lib/templates/plan_context.py +119 -0
- package/dist/templates/_shared/scripts/save_handoff.py +99 -0
- package/dist/templates/_shared/workflows/handoff.md +212 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/ACCESSIBILITY-TESTER.md +80 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/ARCHITECT-REVIEWER.md +75 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/ASSUMPTION-CHAIN-TRACER.md +239 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/CLARITY-AUDITOR.md +109 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/CODE-REVIEWER.md +71 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/COMPLETENESS-CHECKER.md +104 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/CONTEXT-EXTRACTOR.md +93 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/DEVILS-ADVOCATE.md +223 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/DOCUMENTATION-REVIEWER.md +73 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/FEASIBILITY-ANALYST.md +93 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/FRESH-PERSPECTIVE.md +103 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/HANDOFF-READINESS.md +145 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/HIDDEN-COMPLEXITY-DETECTOR.md +248 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/INCENTIVE-MAPPER.md +235 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/PENETRATION-TESTER.md +80 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/PERFORMANCE-ENGINEER.md +76 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/PLAN-ORCHESTRATOR.md +141 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/PRECEDENT-FINDER.md +240 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/REVERSIBILITY-ANALYST.md +211 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/RISK-ASSESSOR.md +101 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/SECOND-ORDER-ANALYST.md +197 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/SIMPLICITY-GUARDIAN.md +97 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/SKEPTIC.md +349 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/STAKEHOLDER-ADVOCATE.md +106 -0
- package/dist/templates/cc-native/.claude/agents/cc-native/TRADE-OFF-ILLUMINATOR.md +205 -0
- package/dist/templates/cc-native/.claude/commands/cc-native/fresh-perspective.md +8 -0
- package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +10 -0
- package/dist/templates/cc-native/.claude/settings.json +119 -0
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/fix.md +8 -0
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/fresh-perspective.md +8 -0
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/implement.md +8 -0
- package/dist/templates/cc-native/.windsurf/workflows/cc-native/research.md +8 -0
- package/dist/templates/cc-native/CC-NATIVE-README.md +192 -0
- package/dist/templates/cc-native/MIGRATION.md +86 -0
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +331 -0
- package/dist/templates/cc-native/_cc-native/docs/PERMISSION_REQUEST_VERIFICATION.md +147 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/add_plan_context.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/archive_plan.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-agent-review.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/cc-native-plan-review.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/__pycache__/test_permission_request.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/hooks/add_plan_context.py +150 -0
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.py +746 -0
- package/dist/templates/cc-native/_cc-native/hooks/suggest-fresh-perspective.py +339 -0
- package/dist/templates/cc-native/_cc-native/lib/__init__.py +57 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/orchestrator.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/state.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/__pycache__/utils.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/async_archive.py +68 -0
- package/dist/templates/cc-native/_cc-native/lib/atomic_write.py +98 -0
- package/dist/templates/cc-native/_cc-native/lib/constants.py +45 -0
- package/dist/templates/cc-native/_cc-native/lib/orchestrator.py +273 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__init__.py +28 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/agent.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/base.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/codex.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/__pycache__/gemini.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/agent.py +164 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/base.py +89 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/codex.py +119 -0
- package/dist/templates/cc-native/_cc-native/lib/reviewers/gemini.py +103 -0
- package/dist/templates/cc-native/_cc-native/lib/state.py +251 -0
- package/dist/templates/cc-native/_cc-native/lib/utils.py +830 -0
- package/dist/templates/cc-native/_cc-native/plan-review.config.json +76 -0
- package/dist/templates/cc-native/_cc-native/scripts/__pycache__/aggregate_agents.cpython-313.pyc +0 -0
- package/dist/templates/cc-native/_cc-native/scripts/aggregate_agents.py +151 -0
- package/dist/templates/cc-native/_cc-native/workflows/fresh-perspective.md +134 -0
- package/dist/templates/cc-native/_cc-native/workflows/specdev.md +9 -0
- package/dist/types/exit-codes.d.ts +11 -0
- package/dist/types/exit-codes.js +10 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +7 -0
- package/oclif.manifest.json +405 -0
- package/package.json +109 -0
package/README.md
ADDED
|
@@ -0,0 +1,1248 @@
|
|
|
1
|
+
AIW CLI - AI Workflow CLI
|
|
2
|
+
=========================================
|
|
3
|
+
|
|
4
|
+
Command-line interface for launching and managing Claude Code with AI Workflow (AIW) configuration. Provides seamless integration with AIW hooks, automatic sandbox permissions, and scriptable automation support.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
[](https://oclif.io)
|
|
8
|
+
[](https://npmjs.org/package/aiwcli)
|
|
9
|
+
[](https://npmjs.org/package/aiwcli)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
### Install Globally (Recommended)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Navigate to the aiwcli directory
|
|
17
|
+
cd ~/.aiw/aiwcli # or C:\Users\YOUR_USERNAME\.aiw\aiwcli on Windows
|
|
18
|
+
|
|
19
|
+
# Install dependencies
|
|
20
|
+
npm install
|
|
21
|
+
|
|
22
|
+
# Build the CLI
|
|
23
|
+
npm run build
|
|
24
|
+
|
|
25
|
+
# Install globally
|
|
26
|
+
npm install -g .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Verify installation:**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
aiw --version
|
|
33
|
+
aiw --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Run Without Global Install
|
|
37
|
+
|
|
38
|
+
If you prefer not to install globally, you can run commands directly from the aiwcli directory:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cd ~/.aiw/aiwcli
|
|
42
|
+
./bin/run.js <command> # Unix/Mac
|
|
43
|
+
.\bin\run.cmd <command> # Windows
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Example:**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
./bin/run.js launch # Unix/Mac
|
|
50
|
+
.\bin\run.cmd launch # Windows
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
AIW CLI provides the following commands:
|
|
56
|
+
|
|
57
|
+
### `aiw launch`
|
|
58
|
+
Launch Claude Code with AIW configuration (sandbox disabled, supports parallel sessions).
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
aiw launch
|
|
62
|
+
aiw launch --debug # Enable verbose logging
|
|
63
|
+
aiw launch --quiet # Suppress informational output
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `aiw init`
|
|
67
|
+
Initialize AIW tools and integrations with specified template method.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
aiw init --interactive # Run interactive setup wizard
|
|
71
|
+
aiw init --method bmad # Initialize BMAD template
|
|
72
|
+
aiw init --method gsd # Initialize GSD template
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `aiw branch <branchName>`
|
|
76
|
+
Create git worktree in sibling folder and auto-launch Claude Code.
|
|
77
|
+
|
|
78
|
+
Reduces friction in branch-based development workflows by:
|
|
79
|
+
1. Creating a new git worktree with the specified branch name
|
|
80
|
+
2. Creating a sibling folder with suffix pattern (e.g., `aiwcli` → `aiwcli-feature-name`)
|
|
81
|
+
3. Opening a new terminal window at the worktree path
|
|
82
|
+
4. Automatically running `aiw launch` in that terminal
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
aiw branch feature-name # Creates ../aiwcli-feature-name worktree
|
|
86
|
+
aiw branch fix-bug-123 # Creates ../aiwcli-fix-bug-123 worktree
|
|
87
|
+
aiw branch experiment # Creates ../aiwcli-experiment worktree
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Requirements:**
|
|
91
|
+
- Must be run from a git repository root
|
|
92
|
+
- Target folder must not already exist
|
|
93
|
+
- Branch name must not already exist
|
|
94
|
+
|
|
95
|
+
**Exit codes:**
|
|
96
|
+
- `0` - Success: Worktree created and terminal launched
|
|
97
|
+
- `1` - General error: Unexpected failure
|
|
98
|
+
- `2` - Invalid usage: Invalid branch name, folder exists, or not in git repo
|
|
99
|
+
- `3` - Environment error: Git not available
|
|
100
|
+
|
|
101
|
+
## Requirements
|
|
102
|
+
|
|
103
|
+
**Minimum Claude Code Version:** 0.1.0 or later
|
|
104
|
+
|
|
105
|
+
AIW CLI automatically detects your Claude Code version and warns if incompatibilities are detected. The CLI will continue to launch even with version warnings (graceful degradation).
|
|
106
|
+
|
|
107
|
+
### Known Incompatible Versions
|
|
108
|
+
|
|
109
|
+
- **0.0.9** - Has known issues with AIW CLI integration
|
|
110
|
+
|
|
111
|
+
If you encounter version compatibility warnings, upgrade Claude Code to the latest version:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Upgrade Claude Code to latest version
|
|
115
|
+
npm install -g @anthropic-ai/claude-code@latest
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Troubleshooting
|
|
119
|
+
|
|
120
|
+
### Windows Setup: Symlink Permission Denied
|
|
121
|
+
|
|
122
|
+
**Symptom:** `aiw init` fails with "Permission denied creating symlink" or "EPERM: operation not permitted"
|
|
123
|
+
|
|
124
|
+
**Solution (choose one):**
|
|
125
|
+
|
|
126
|
+
**Option 1: Enable Developer Mode (Recommended)**
|
|
127
|
+
1. Open Windows Settings
|
|
128
|
+
2. Go to "Privacy & Security" → "For developers"
|
|
129
|
+
3. Enable "Developer Mode"
|
|
130
|
+
4. Run `aiw init` again
|
|
131
|
+
|
|
132
|
+
**Option 2: Run as Administrator**
|
|
133
|
+
1. Open PowerShell or Command Prompt as Administrator
|
|
134
|
+
2. Run `aiw init`
|
|
135
|
+
|
|
136
|
+
Developer Mode is recommended as it allows symlink creation without elevated privileges for all future operations.
|
|
137
|
+
|
|
138
|
+
### Version Compatibility Issues
|
|
139
|
+
|
|
140
|
+
**Symptom:** Warning message about Claude Code version incompatibility
|
|
141
|
+
|
|
142
|
+
**Solution:**
|
|
143
|
+
1. Check your current Claude Code version: `claude --version`
|
|
144
|
+
2. Upgrade to version 0.1.0 or later (see above)
|
|
145
|
+
3. If version cannot be detected, ensure Claude Code is installed and in your PATH
|
|
146
|
+
|
|
147
|
+
**Debug Mode:**
|
|
148
|
+
|
|
149
|
+
Use `--debug` flag to see detailed version information:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
aiw launch --debug
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Debug output includes:
|
|
156
|
+
- Resolved AIW_DIR path
|
|
157
|
+
- Claude Code version detection
|
|
158
|
+
- Compatibility check results
|
|
159
|
+
- Spawn arguments and configuration
|
|
160
|
+
|
|
161
|
+
### Version Check Failed
|
|
162
|
+
|
|
163
|
+
If `claude --version` fails or hangs:
|
|
164
|
+
- Verify Claude Code is installed: `which claude` (Unix) or `where claude` (Windows)
|
|
165
|
+
- Check PATH includes Claude Code installation directory
|
|
166
|
+
- Reinstall Claude Code if necessary
|
|
167
|
+
|
|
168
|
+
AIW CLI assumes compatibility if version cannot be determined and will proceed with launch.
|
|
169
|
+
|
|
170
|
+
## Environment Variables
|
|
171
|
+
|
|
172
|
+
AIW CLI respects standard environment variables for controlling output behavior:
|
|
173
|
+
|
|
174
|
+
### NO_COLOR
|
|
175
|
+
|
|
176
|
+
Disables colored output. Useful for scripts or when colors interfere with output processing.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Disable all colors
|
|
180
|
+
NO_COLOR=1 aiw launch
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### FORCE_COLOR
|
|
184
|
+
|
|
185
|
+
Forces colored output even when not in a TTY (terminal). Useful for CI environments that support colors.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Force colors (level 1 = basic 16 colors)
|
|
189
|
+
FORCE_COLOR=1 aiw launch | less -R
|
|
190
|
+
|
|
191
|
+
# Force 256 colors
|
|
192
|
+
FORCE_COLOR=2 aiw launch
|
|
193
|
+
|
|
194
|
+
# Force truecolor (16 million colors)
|
|
195
|
+
FORCE_COLOR=3 aiw launch
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### AIW_DIR
|
|
199
|
+
|
|
200
|
+
Customize the AIW configuration directory (default: `~/.aiw`):
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
AIW_DIR=/custom/path aiw launch
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Output Behavior
|
|
207
|
+
|
|
208
|
+
AIW CLI automatically adapts its output based on the execution context:
|
|
209
|
+
|
|
210
|
+
### Interactive Terminal (TTY)
|
|
211
|
+
- Colors enabled
|
|
212
|
+
- Progress spinners shown
|
|
213
|
+
- Rich formatting
|
|
214
|
+
|
|
215
|
+
### Piped or Redirected Output
|
|
216
|
+
- Colors automatically disabled
|
|
217
|
+
- Spinners suppressed
|
|
218
|
+
- Clean, parseable text output
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Example: Piping to other commands
|
|
222
|
+
aiw launch --help | grep "OPTIONS"
|
|
223
|
+
|
|
224
|
+
# Example: Redirecting to file
|
|
225
|
+
aiw launch --help > help.txt
|
|
226
|
+
|
|
227
|
+
# Example: Processing with tools
|
|
228
|
+
aiw launch 2>&1 | tee output.log
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
This automatic behavior ensures AIW CLI works seamlessly in both interactive use and automation scripts without requiring manual configuration.
|
|
232
|
+
|
|
233
|
+
### Quiet Mode
|
|
234
|
+
|
|
235
|
+
For scripting and automation where you want minimal output, use the `--quiet` (or `-q`) flag to suppress informational messages while preserving errors:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Suppress informational output
|
|
239
|
+
aiw launch --quiet
|
|
240
|
+
|
|
241
|
+
# Short form
|
|
242
|
+
aiw launch -q
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**What Gets Suppressed:**
|
|
246
|
+
- Informational messages (`logInfo`)
|
|
247
|
+
- Success messages (`logSuccess`)
|
|
248
|
+
- Warning messages (`logWarning`)
|
|
249
|
+
- Progress spinners
|
|
250
|
+
|
|
251
|
+
**What's Always Shown:**
|
|
252
|
+
- Error messages (stderr) - critical for debugging failures
|
|
253
|
+
- Essential data output (stdout) - for parsing in scripts
|
|
254
|
+
|
|
255
|
+
**Example Usage:**
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# Silent execution in scripts
|
|
259
|
+
aiw launch --quiet
|
|
260
|
+
EXIT_CODE=$?
|
|
261
|
+
if [ $EXIT_CODE -ne 0 ]; then
|
|
262
|
+
echo "Launch failed with code $EXIT_CODE"
|
|
263
|
+
fi
|
|
264
|
+
|
|
265
|
+
# Combine with piping
|
|
266
|
+
aiw launch --quiet 2>&1 | tee log.txt
|
|
267
|
+
|
|
268
|
+
# CI/CD pipelines
|
|
269
|
+
aiw launch --quiet || exit 1
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Quiet Mode vs. Piping:**
|
|
273
|
+
- **Piping**: Automatically disables colors and spinners
|
|
274
|
+
- **Quiet Mode**: Explicitly suppresses informational text
|
|
275
|
+
- **Combined**: Minimal clean output for scripting
|
|
276
|
+
|
|
277
|
+
## Command Chaining
|
|
278
|
+
|
|
279
|
+
AIW CLI is designed for seamless integration into command chains and pipelines, enabling complex automation workflows.
|
|
280
|
+
|
|
281
|
+
### Chaining with && (Success Chains)
|
|
282
|
+
|
|
283
|
+
Commands can be chained using `&&` to execute multiple operations sequentially, stopping at the first failure:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Execute multiple commands - stops if any fails
|
|
287
|
+
aiw launch --help && aiw init --help
|
|
288
|
+
|
|
289
|
+
# Chain with other tools
|
|
290
|
+
aiw launch --help && echo "Launch command is available"
|
|
291
|
+
|
|
292
|
+
# Complex chains
|
|
293
|
+
aiw init && aiw launch --quiet && echo "Setup and launch complete"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**How It Works:**
|
|
297
|
+
- Exit code `0` (success) → chain continues to next command
|
|
298
|
+
- Exit code `1/2/3` (error) → chain stops, subsequent commands don't run
|
|
299
|
+
- Errors always output to stderr for visibility
|
|
300
|
+
|
|
301
|
+
### Piping Output
|
|
302
|
+
|
|
303
|
+
AIW CLI produces clean stdout that works seamlessly with standard Unix tools:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Pipe to grep, awk, jq, etc.
|
|
307
|
+
aiw launch --help | grep "Launch"
|
|
308
|
+
|
|
309
|
+
# Combine quiet mode for cleanest output
|
|
310
|
+
aiw launch --help --quiet | wc -l
|
|
311
|
+
|
|
312
|
+
# Multi-stage pipelines
|
|
313
|
+
aiw launch --help | grep "flags" | sort
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Output Separation:**
|
|
317
|
+
- **stdout**: Data only (help text, command output)
|
|
318
|
+
- **stderr**: Errors and warnings only
|
|
319
|
+
- **Status messages**: Automatically suppressed when piped
|
|
320
|
+
|
|
321
|
+
### Cross-Platform Compatibility
|
|
322
|
+
|
|
323
|
+
**Windows PowerShell:**
|
|
324
|
+
```powershell
|
|
325
|
+
# && chains work in PowerShell 7+
|
|
326
|
+
aiw launch --help && echo "Success"
|
|
327
|
+
|
|
328
|
+
# Pipes work universally
|
|
329
|
+
aiw launch --help | Select-String "Launch"
|
|
330
|
+
|
|
331
|
+
# Legacy CMD/PowerShell 5.1 uses semicolon for sequential execution
|
|
332
|
+
aiw launch --help; echo "Runs regardless of success"
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Unix/macOS (Bash/Zsh):**
|
|
336
|
+
```bash
|
|
337
|
+
# Standard && chaining
|
|
338
|
+
aiw launch --help && echo "Success"
|
|
339
|
+
|
|
340
|
+
# Standard piping
|
|
341
|
+
aiw launch --help | grep "Launch"
|
|
342
|
+
|
|
343
|
+
# Complex pipelines
|
|
344
|
+
aiw launch --help | grep "flags" | awk '{print $1}'
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Practical Examples
|
|
348
|
+
|
|
349
|
+
**CI/CD Pipelines:**
|
|
350
|
+
```bash
|
|
351
|
+
# Stop pipeline on first failure
|
|
352
|
+
aiw init && aiw launch --quiet && other-command || exit 1
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Scripting with Error Handling:**
|
|
356
|
+
```bash
|
|
357
|
+
#!/bin/bash
|
|
358
|
+
if aiw launch --quiet; then
|
|
359
|
+
echo "Launch succeeded"
|
|
360
|
+
else
|
|
361
|
+
echo "Launch failed with code $?" >&2
|
|
362
|
+
exit 1
|
|
363
|
+
fi
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Data Processing:**
|
|
367
|
+
```bash
|
|
368
|
+
# Extract and process help text
|
|
369
|
+
aiw launch --help --quiet | grep -E "^ -" | sort
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Exit Codes
|
|
373
|
+
|
|
374
|
+
AIW CLI uses standardized exit codes to enable reliable error handling in scripts and automation pipelines.
|
|
375
|
+
|
|
376
|
+
### Exit Code Reference
|
|
377
|
+
|
|
378
|
+
| Code | Meaning | When It Occurs |
|
|
379
|
+
|------|---------|----------------|
|
|
380
|
+
| `0` | Success | Command completed successfully without errors |
|
|
381
|
+
| `1` | General Error | Unexpected runtime failures, system errors, unhandled exceptions |
|
|
382
|
+
| `2` | Invalid Usage | Invalid arguments, unknown flags, missing required parameters |
|
|
383
|
+
| `3` | Environment Error | Missing prerequisites (Claude Code not installed, AIW_DIR not found, permission denied) |
|
|
384
|
+
|
|
385
|
+
### Checking Exit Codes
|
|
386
|
+
|
|
387
|
+
**Bash / Zsh (Unix, macOS, Linux, Git Bash, WSL):**
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# Check last command's exit code
|
|
391
|
+
aiw launch
|
|
392
|
+
echo $? # 0 = success, non-zero = error
|
|
393
|
+
|
|
394
|
+
# Conditional execution with &&
|
|
395
|
+
aiw launch && echo "Success!"
|
|
396
|
+
|
|
397
|
+
# Fallback with ||
|
|
398
|
+
aiw launch || echo "Failed with code $?"
|
|
399
|
+
|
|
400
|
+
# Store and check exit code
|
|
401
|
+
aiw launch
|
|
402
|
+
EXIT_CODE=$?
|
|
403
|
+
if [ $EXIT_CODE -eq 0 ]; then
|
|
404
|
+
echo "Launch succeeded"
|
|
405
|
+
elif [ $EXIT_CODE -eq 3 ]; then
|
|
406
|
+
echo "Environment error - run 'aiw init' or install Claude Code"
|
|
407
|
+
else
|
|
408
|
+
echo "Command failed with exit code $EXIT_CODE"
|
|
409
|
+
fi
|
|
410
|
+
|
|
411
|
+
# Chain commands (stops on first failure)
|
|
412
|
+
aiw init && aiw launch && echo "All commands succeeded"
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**PowerShell (Windows):**
|
|
416
|
+
|
|
417
|
+
```powershell
|
|
418
|
+
# Check last command's exit code
|
|
419
|
+
aiw launch
|
|
420
|
+
echo $LASTEXITCODE # 0 = success, non-zero = error
|
|
421
|
+
|
|
422
|
+
# Conditional execution
|
|
423
|
+
aiw launch
|
|
424
|
+
if ($LASTEXITCODE -eq 0) {
|
|
425
|
+
Write-Host "Success!"
|
|
426
|
+
} elseif ($LASTEXITCODE -eq 3) {
|
|
427
|
+
Write-Host "Environment error - run 'aiw init' or install Claude Code"
|
|
428
|
+
} else {
|
|
429
|
+
Write-Host "Failed with exit code $LASTEXITCODE"
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
# Throw on error
|
|
433
|
+
$ErrorActionPreference = "Stop"
|
|
434
|
+
aiw launch # Will throw exception if exit code is non-zero
|
|
435
|
+
|
|
436
|
+
# Continue on error but check result
|
|
437
|
+
$ErrorActionPreference = "Continue"
|
|
438
|
+
aiw launch
|
|
439
|
+
if ($LASTEXITCODE -ne 0) {
|
|
440
|
+
Write-Error "Launch failed"
|
|
441
|
+
exit $LASTEXITCODE
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**CMD (Windows):**
|
|
446
|
+
|
|
447
|
+
```cmd
|
|
448
|
+
REM Check exit code with %ERRORLEVEL%
|
|
449
|
+
aiw launch
|
|
450
|
+
echo %ERRORLEVEL%
|
|
451
|
+
|
|
452
|
+
REM Conditional execution with &&
|
|
453
|
+
aiw init && aiw launch && echo Success!
|
|
454
|
+
|
|
455
|
+
REM Check exit code in batch script
|
|
456
|
+
aiw launch
|
|
457
|
+
if %ERRORLEVEL% EQU 0 (
|
|
458
|
+
echo Success
|
|
459
|
+
) else if %ERRORLEVEL% EQU 3 (
|
|
460
|
+
echo Environment error
|
|
461
|
+
) else (
|
|
462
|
+
echo Failed with code %ERRORLEVEL%
|
|
463
|
+
)
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Common Exit Code Scenarios
|
|
467
|
+
|
|
468
|
+
**Success (0):**
|
|
469
|
+
- Help displayed: `aiwlaunch --help`
|
|
470
|
+
- Setup completed successfully: `aiw init`
|
|
471
|
+
- Claude Code launched and exited normally: `aiwlaunch`
|
|
472
|
+
|
|
473
|
+
**General Error (1):**
|
|
474
|
+
- Unexpected runtime failures
|
|
475
|
+
- Network errors during operation
|
|
476
|
+
- File system errors (other than missing prerequisites)
|
|
477
|
+
- Unknown/unhandled exceptions
|
|
478
|
+
|
|
479
|
+
**Invalid Usage (2):**
|
|
480
|
+
- Unknown flag: `aiwlaunch --invalid-flag`
|
|
481
|
+
- Unknown command: `aiwinvalid-command`
|
|
482
|
+
- Missing required argument: `aiw init` (without --method arg)
|
|
483
|
+
- Conflicting options
|
|
484
|
+
|
|
485
|
+
**Environment Error (3):**
|
|
486
|
+
- Claude Code not installed: `aiwlaunch` (when `claude` not in PATH)
|
|
487
|
+
- AIW_DIR not found: `aiw init` (when ~/.aiw doesn't exist and AIW_DIR not set)
|
|
488
|
+
- Permission denied: `aiw init` (on Windows without Developer Mode or admin rights)
|
|
489
|
+
- Version incompatibility blocking operation
|
|
490
|
+
|
|
491
|
+
### Exit Codes in CI/CD
|
|
492
|
+
|
|
493
|
+
Exit codes enable reliable automation in continuous integration and deployment pipelines:
|
|
494
|
+
|
|
495
|
+
```yaml
|
|
496
|
+
# GitHub Actions example
|
|
497
|
+
- name: Launch AIW
|
|
498
|
+
run: aiw launch
|
|
499
|
+
# Automatically fails workflow on non-zero exit
|
|
500
|
+
|
|
501
|
+
# With custom error handling
|
|
502
|
+
- name: Launch AIW with fallback
|
|
503
|
+
run: |
|
|
504
|
+
aiw launch || {
|
|
505
|
+
EXIT_CODE=$?
|
|
506
|
+
if [ $EXIT_CODE -eq 3 ]; then
|
|
507
|
+
echo "Environment setup needed"
|
|
508
|
+
exit 1
|
|
509
|
+
fi
|
|
510
|
+
exit $EXIT_CODE
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### Getting Help on Exit Codes
|
|
515
|
+
|
|
516
|
+
Every command documents its exit codes in help text:
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
aiw launch --help # See EXIT CODES section
|
|
520
|
+
aiw init --help # See EXIT CODES section
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
## Shell Completion
|
|
524
|
+
|
|
525
|
+
AIW CLI supports tab completion for commands, subcommands, and flags in Bash, Zsh, and PowerShell.
|
|
526
|
+
|
|
527
|
+
### Installation
|
|
528
|
+
|
|
529
|
+
**Bash**
|
|
530
|
+
|
|
531
|
+
Add to your `~/.bashrc`:
|
|
532
|
+
|
|
533
|
+
```bash
|
|
534
|
+
eval "$(aiw autocomplete:script bash)"
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
Or run this one-liner:
|
|
538
|
+
|
|
539
|
+
```bash
|
|
540
|
+
printf "eval \"\$(aiw autocomplete:script bash)\"" >> ~/.bashrc && source ~/.bashrc
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
**Note:** If your terminal starts as a login shell, modify `~/.bash_profile` or `~/.profile` instead:
|
|
544
|
+
|
|
545
|
+
```bash
|
|
546
|
+
printf "eval \"\$(aiw autocomplete:script bash)\"" >> ~/.bash_profile && source ~/.bash_profile
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
**Zsh**
|
|
550
|
+
|
|
551
|
+
Add to your `~/.zshrc`:
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
eval "$(aiw autocomplete:script zsh)"
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
Or run this one-liner:
|
|
558
|
+
|
|
559
|
+
```bash
|
|
560
|
+
printf "eval \"\$(aiw autocomplete:script zsh)\"" >> ~/.zshrc && source ~/.zshrc
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
**PowerShell**
|
|
564
|
+
|
|
565
|
+
Run the autocomplete command and follow the instructions:
|
|
566
|
+
|
|
567
|
+
```powershell
|
|
568
|
+
aiw autocomplete powershell
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
The command will provide platform-specific setup instructions. Typically:
|
|
572
|
+
|
|
573
|
+
```powershell
|
|
574
|
+
# Create profile directory if it doesn't exist
|
|
575
|
+
New-Item -Type Directory -Path (Split-Path -Parent $PROFILE) -ErrorAction SilentlyContinue
|
|
576
|
+
|
|
577
|
+
# Add autocomplete to profile and reload
|
|
578
|
+
Add-Content -Path $PROFILE -Value (Invoke-Expression -Command "aiw autocomplete script powershell"); .$PROFILE
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
**Optional**: Enable menu-style completion in PowerShell:
|
|
582
|
+
|
|
583
|
+
```powershell
|
|
584
|
+
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### Usage
|
|
588
|
+
|
|
589
|
+
After installation, you can use tab completion:
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
# Command completion
|
|
593
|
+
aiw la<TAB> # Completes to "aiw launch"
|
|
594
|
+
|
|
595
|
+
# Subcommand completion (when available)
|
|
596
|
+
aiw init <TAB> # Shows available subcommands
|
|
597
|
+
|
|
598
|
+
# Flag completion
|
|
599
|
+
aiw launch --<TAB> # Shows available flags
|
|
600
|
+
|
|
601
|
+
# Command listing
|
|
602
|
+
aiw <TAB> # Shows all available commands
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### Troubleshooting
|
|
606
|
+
|
|
607
|
+
**Bash**
|
|
608
|
+
|
|
609
|
+
If completion doesn't work:
|
|
610
|
+
- Check if `~/.bashrc` is sourced (may need `~/.bash_profile` for login shells)
|
|
611
|
+
- Verify completion script loaded: `type _aiw_completion`
|
|
612
|
+
- Restart your shell: `exec bash`
|
|
613
|
+
|
|
614
|
+
**Zsh**
|
|
615
|
+
|
|
616
|
+
If completion doesn't work:
|
|
617
|
+
- Check permissions: `compaudit -D`
|
|
618
|
+
- Rebuild completion cache: `rm ~/.zcompdump* && compinit`
|
|
619
|
+
- Restart your shell: `exec zsh`
|
|
620
|
+
|
|
621
|
+
**PowerShell**
|
|
622
|
+
|
|
623
|
+
If completion doesn't work:
|
|
624
|
+
- Check execution policy: `Get-ExecutionPolicy`
|
|
625
|
+
- May need: `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser`
|
|
626
|
+
- Restart PowerShell
|
|
627
|
+
|
|
628
|
+
**Refresh Completion Cache**
|
|
629
|
+
|
|
630
|
+
If commands or flags change after updates:
|
|
631
|
+
|
|
632
|
+
```bash
|
|
633
|
+
aiw autocomplete --refresh-cache
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
Or use the short form:
|
|
637
|
+
|
|
638
|
+
```bash
|
|
639
|
+
aiw autocomplete -r
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
## Scripting Examples
|
|
643
|
+
|
|
644
|
+
AIW CLI is designed for seamless integration into automation scripts, shell pipelines, and CI/CD workflows. All examples work on Windows (PowerShell/CMD/Git Bash), macOS, and Linux.
|
|
645
|
+
|
|
646
|
+
### Basic Piping
|
|
647
|
+
|
|
648
|
+
Pipe AIW CLI output to standard Unix tools for filtering and processing:
|
|
649
|
+
|
|
650
|
+
```bash
|
|
651
|
+
# Search help for specific command
|
|
652
|
+
aiw --help | grep "launch"
|
|
653
|
+
|
|
654
|
+
# Find all available flags
|
|
655
|
+
aiw launch --help | grep -E "^ -"
|
|
656
|
+
|
|
657
|
+
# Extract version number
|
|
658
|
+
aiw --version | cut -d' ' -f2
|
|
659
|
+
|
|
660
|
+
# Count lines of output
|
|
661
|
+
aiw --help | wc -l
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
**PowerShell equivalent:**
|
|
665
|
+
```powershell
|
|
666
|
+
# Search help
|
|
667
|
+
aiw --help | Select-String "launch"
|
|
668
|
+
|
|
669
|
+
# Find flags
|
|
670
|
+
aiw launch --help | Select-String "^ -"
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### Command Chaining
|
|
674
|
+
|
|
675
|
+
Chain multiple commands together with proper error handling:
|
|
676
|
+
|
|
677
|
+
**Bash/Zsh (Unix, macOS, Linux, Git Bash):**
|
|
678
|
+
```bash
|
|
679
|
+
# Sequential execution - stops on first failure
|
|
680
|
+
aiw init && aiw launch
|
|
681
|
+
|
|
682
|
+
# Multiple commands
|
|
683
|
+
aiw --version && aiw init && aiw launch
|
|
684
|
+
|
|
685
|
+
# Continue on error
|
|
686
|
+
aiw init || echo "Setup failed"
|
|
687
|
+
|
|
688
|
+
# Error handling with exit codes
|
|
689
|
+
if aiw launch; then
|
|
690
|
+
echo "Launch succeeded"
|
|
691
|
+
else
|
|
692
|
+
EXIT_CODE=$?
|
|
693
|
+
echo "Launch failed with exit code $EXIT_CODE"
|
|
694
|
+
fi
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
**PowerShell (Windows):**
|
|
698
|
+
```powershell
|
|
699
|
+
# Sequential execution (PowerShell 7+)
|
|
700
|
+
aiw init && aiw launch
|
|
701
|
+
|
|
702
|
+
# Error handling
|
|
703
|
+
aiw launch
|
|
704
|
+
if ($LASTEXITCODE -eq 0) {
|
|
705
|
+
Write-Host "Success"
|
|
706
|
+
} else {
|
|
707
|
+
Write-Host "Failed with exit code $LASTEXITCODE"
|
|
708
|
+
}
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
**CMD (Windows):**
|
|
712
|
+
```cmd
|
|
713
|
+
REM Sequential execution
|
|
714
|
+
aiw init && aiw launch && echo Success
|
|
715
|
+
|
|
716
|
+
REM Error handling
|
|
717
|
+
aiw launch
|
|
718
|
+
if %ERRORLEVEL% EQU 0 (
|
|
719
|
+
echo Success
|
|
720
|
+
) else (
|
|
721
|
+
echo Failed with code %ERRORLEVEL%
|
|
722
|
+
)
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
### Quiet Mode for Scripts
|
|
726
|
+
|
|
727
|
+
Suppress informational output while preserving errors:
|
|
728
|
+
|
|
729
|
+
```bash
|
|
730
|
+
# Silent execution in automation
|
|
731
|
+
aiw launch --quiet
|
|
732
|
+
|
|
733
|
+
# Short form
|
|
734
|
+
aiw launch -q
|
|
735
|
+
|
|
736
|
+
# Capture exit code
|
|
737
|
+
aiw launch --quiet
|
|
738
|
+
EXIT_CODE=$?
|
|
739
|
+
|
|
740
|
+
# Only errors shown (goes to stderr)
|
|
741
|
+
aiw launch --quiet 2>errors.log
|
|
742
|
+
|
|
743
|
+
# Combine with piping for cleanest output
|
|
744
|
+
aiw launch --help --quiet | wc -l
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
**Use cases for `--quiet`:**
|
|
748
|
+
- CI/CD pipelines where minimal output is desired
|
|
749
|
+
- Automated scripts that parse command output
|
|
750
|
+
- Reducing noise in log files
|
|
751
|
+
- Background processes
|
|
752
|
+
|
|
753
|
+
### Exit Code Handling
|
|
754
|
+
|
|
755
|
+
AIW CLI uses standardized exit codes for reliable automation:
|
|
756
|
+
|
|
757
|
+
| Code | Meaning | Example Scenarios |
|
|
758
|
+
|------|---------|-------------------|
|
|
759
|
+
| `0` | Success | Command completed, help displayed, setup successful |
|
|
760
|
+
| `1` | General Error | Runtime failures, unexpected errors |
|
|
761
|
+
| `2` | Invalid Usage | Unknown flags, invalid arguments |
|
|
762
|
+
| `3` | Environment Error | Claude Code not installed, permissions denied |
|
|
763
|
+
|
|
764
|
+
**Bash/Zsh examples:**
|
|
765
|
+
```bash
|
|
766
|
+
# Basic exit code check
|
|
767
|
+
aiw launch
|
|
768
|
+
if [ $? -eq 0 ]; then
|
|
769
|
+
echo "Success"
|
|
770
|
+
fi
|
|
771
|
+
|
|
772
|
+
# Handle specific exit codes
|
|
773
|
+
aiw launch
|
|
774
|
+
EXIT_CODE=$?
|
|
775
|
+
case $EXIT_CODE in
|
|
776
|
+
0)
|
|
777
|
+
echo "Launch successful"
|
|
778
|
+
;;
|
|
779
|
+
2)
|
|
780
|
+
echo "Invalid usage - check arguments"
|
|
781
|
+
;;
|
|
782
|
+
3)
|
|
783
|
+
echo "Environment issue - is Claude Code installed?"
|
|
784
|
+
aiw init # Try setup
|
|
785
|
+
;;
|
|
786
|
+
*)
|
|
787
|
+
echo "Unexpected error: $EXIT_CODE"
|
|
788
|
+
;;
|
|
789
|
+
esac
|
|
790
|
+
|
|
791
|
+
# Use exit codes in pipelines
|
|
792
|
+
aiw init && aiw launch || {
|
|
793
|
+
echo "Failed at exit code $?"
|
|
794
|
+
exit 1
|
|
795
|
+
}
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
**PowerShell examples:**
|
|
799
|
+
```powershell
|
|
800
|
+
# Check last exit code
|
|
801
|
+
aiw launch
|
|
802
|
+
if ($LASTEXITCODE -eq 0) {
|
|
803
|
+
Write-Host "Success"
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
# Handle specific codes
|
|
807
|
+
aiw launch
|
|
808
|
+
switch ($LASTEXITCODE) {
|
|
809
|
+
0 { Write-Host "Success" }
|
|
810
|
+
2 { Write-Host "Invalid usage" }
|
|
811
|
+
3 { Write-Host "Environment issue"; aiw init }
|
|
812
|
+
default { Write-Host "Error: $LASTEXITCODE" }
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
# Fail on error
|
|
816
|
+
$ErrorActionPreference = "Stop"
|
|
817
|
+
aiw launch # Will throw if non-zero exit code
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
### Shell Completion Usage
|
|
821
|
+
|
|
822
|
+
After installing shell completion (see [Shell Completion](#shell-completion) section):
|
|
823
|
+
|
|
824
|
+
```bash
|
|
825
|
+
# Command completion
|
|
826
|
+
aiw la<TAB> # Completes to "aiw launch"
|
|
827
|
+
|
|
828
|
+
# Show all commands
|
|
829
|
+
aiw <TAB> # Lists: autocomplete, help, init, launch
|
|
830
|
+
|
|
831
|
+
# Flag completion
|
|
832
|
+
aiw launch --<TAB> # Shows: --debug, --help, --quiet
|
|
833
|
+
|
|
834
|
+
# Short flag completion
|
|
835
|
+
aiw launch -<TAB> # Shows: -d, -h, -q
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
**Benefits:**
|
|
839
|
+
- Faster command entry
|
|
840
|
+
- Discover available commands without `--help`
|
|
841
|
+
- Reduce typos
|
|
842
|
+
- Learn flag names interactively
|
|
843
|
+
|
|
844
|
+
### CI/CD Pipeline Examples
|
|
845
|
+
|
|
846
|
+
**GitHub Actions:**
|
|
847
|
+
```yaml
|
|
848
|
+
name: Deploy with AIW
|
|
849
|
+
|
|
850
|
+
on: [push]
|
|
851
|
+
|
|
852
|
+
jobs:
|
|
853
|
+
deploy:
|
|
854
|
+
runs-on: ubuntu-latest
|
|
855
|
+
steps:
|
|
856
|
+
- uses: actions/checkout@v2
|
|
857
|
+
|
|
858
|
+
- name: Setup AIW
|
|
859
|
+
run: |
|
|
860
|
+
npm install -g aiwcli
|
|
861
|
+
aiw init
|
|
862
|
+
|
|
863
|
+
- name: Launch Claude Code
|
|
864
|
+
run: aiw launch --quiet || exit $?
|
|
865
|
+
|
|
866
|
+
- name: Check exit code
|
|
867
|
+
if: failure()
|
|
868
|
+
run: |
|
|
869
|
+
echo "AIW launch failed"
|
|
870
|
+
echo "Exit code: $?"
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
**GitLab CI:**
|
|
874
|
+
```yaml
|
|
875
|
+
deploy:
|
|
876
|
+
script:
|
|
877
|
+
- aiw init
|
|
878
|
+
- aiw launch --quiet
|
|
879
|
+
only:
|
|
880
|
+
- main
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
**Jenkins:**
|
|
884
|
+
```groovy
|
|
885
|
+
pipeline {
|
|
886
|
+
agent any
|
|
887
|
+
stages {
|
|
888
|
+
stage('Setup') {
|
|
889
|
+
steps {
|
|
890
|
+
sh 'aiw init'
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
stage('Launch') {
|
|
894
|
+
steps {
|
|
895
|
+
sh 'aiw launch --quiet || exit $?'
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
### Automation Script Examples
|
|
903
|
+
|
|
904
|
+
**Deployment script (Bash):**
|
|
905
|
+
```bash
|
|
906
|
+
#!/bin/bash
|
|
907
|
+
set -e # Exit on error
|
|
908
|
+
|
|
909
|
+
echo "Starting deployment..."
|
|
910
|
+
|
|
911
|
+
# Setup AIW if not configured
|
|
912
|
+
if ! aiw --version > /dev/null 2>&1; then
|
|
913
|
+
echo "AIW CLI not found"
|
|
914
|
+
exit 3
|
|
915
|
+
fi
|
|
916
|
+
|
|
917
|
+
# Run setup
|
|
918
|
+
aiw init || {
|
|
919
|
+
echo "Setup failed with code $?"
|
|
920
|
+
exit 1
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
# Launch with quiet mode
|
|
924
|
+
aiw launch --quiet
|
|
925
|
+
|
|
926
|
+
echo "Deployment complete"
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
**Monitoring script (Bash):**
|
|
930
|
+
```bash
|
|
931
|
+
#!/bin/bash
|
|
932
|
+
|
|
933
|
+
# Check AIW status every 5 minutes
|
|
934
|
+
while true; do
|
|
935
|
+
if aiw --version --quiet; then
|
|
936
|
+
echo "[$(date)] AIW CLI operational"
|
|
937
|
+
else
|
|
938
|
+
echo "[$(date)] AIW CLI check failed: exit code $?"
|
|
939
|
+
fi
|
|
940
|
+
sleep 300
|
|
941
|
+
done
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
**Batch processing (PowerShell):**
|
|
945
|
+
```powershell
|
|
946
|
+
# Process multiple operations with AIW
|
|
947
|
+
$operations = @("setup", "launch")
|
|
948
|
+
|
|
949
|
+
foreach ($op in $operations) {
|
|
950
|
+
Write-Host "Running: aiw $op"
|
|
951
|
+
|
|
952
|
+
& aiw $op --quiet
|
|
953
|
+
|
|
954
|
+
if ($LASTEXITCODE -ne 0) {
|
|
955
|
+
Write-Error "Operation $op failed with code $LASTEXITCODE"
|
|
956
|
+
exit $LASTEXITCODE
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
Write-Host "All operations completed successfully"
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
### Tips for Scripting
|
|
964
|
+
|
|
965
|
+
**1. Always use `--quiet` in scripts:**
|
|
966
|
+
```bash
|
|
967
|
+
# Good: Clean output
|
|
968
|
+
aiw launch --quiet
|
|
969
|
+
|
|
970
|
+
# Avoid: Verbose output pollutes logs
|
|
971
|
+
aiw launch
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
**2. Check exit codes explicitly:**
|
|
975
|
+
```bash
|
|
976
|
+
# Good: Explicit error handling
|
|
977
|
+
aiw launch
|
|
978
|
+
if [ $? -ne 0 ]; then
|
|
979
|
+
handle_error
|
|
980
|
+
fi
|
|
981
|
+
|
|
982
|
+
# Risky: Assumes success
|
|
983
|
+
aiw launch
|
|
984
|
+
continue_anyway
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
**3. Pipe stderr to log files:**
|
|
988
|
+
```bash
|
|
989
|
+
# Capture errors for debugging
|
|
990
|
+
aiw launch 2>errors.log
|
|
991
|
+
|
|
992
|
+
# Capture both stdout and stderr
|
|
993
|
+
aiw launch >output.log 2>&1
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
**4. Use timeout for long operations:**
|
|
997
|
+
```bash
|
|
998
|
+
# Bash: timeout after 60 seconds
|
|
999
|
+
timeout 60 aiw launch || echo "Timeout or error"
|
|
1000
|
+
|
|
1001
|
+
# PowerShell: timeout after 60 seconds
|
|
1002
|
+
Start-Process -Wait -Timeout 60 -NoNewWindow aiw -ArgumentList "launch"
|
|
1003
|
+
```
|
|
1004
|
+
|
|
1005
|
+
**5. Combine with other CLI tools:**
|
|
1006
|
+
```bash
|
|
1007
|
+
# Log with timestamp
|
|
1008
|
+
aiw launch --quiet 2>&1 | while read line; do
|
|
1009
|
+
echo "$(date -Is) $line"
|
|
1010
|
+
done
|
|
1011
|
+
|
|
1012
|
+
# Notify on completion (Linux/macOS)
|
|
1013
|
+
aiw launch --quiet && notify-send "AIW launch complete"
|
|
1014
|
+
|
|
1015
|
+
# Email on failure (with sendmail)
|
|
1016
|
+
aiw launch --quiet || echo "AIW launch failed" | mail -s "Alert" admin@example.com
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
## Command Development Guide
|
|
1020
|
+
|
|
1021
|
+
This section explains how to add new commands to AIW CLI following Oclif best practices and our established patterns.
|
|
1022
|
+
|
|
1023
|
+
### Command Architecture
|
|
1024
|
+
|
|
1025
|
+
AIW CLI uses [Oclif](https://oclif.io) which provides automatic command registration based on file structure:
|
|
1026
|
+
|
|
1027
|
+
- **File path = Command name**: `src/commands/launch.ts` → `aiw launch`
|
|
1028
|
+
- **Subdirectories = Topics**: `src/commands/init/index.ts` → `aiw init`
|
|
1029
|
+
- **Class names**: PascalCase version of command name (`Launch`, `InitBmad`)
|
|
1030
|
+
|
|
1031
|
+
### Adding a New Top-Level Command
|
|
1032
|
+
|
|
1033
|
+
1. **Create the command file** in `src/commands/`:
|
|
1034
|
+
```bash
|
|
1035
|
+
# Example: Adding a "status" command
|
|
1036
|
+
touch src/commands/status.ts
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
2. **Implement the command**:
|
|
1040
|
+
```typescript
|
|
1041
|
+
import {Flags} from '@oclif/core'
|
|
1042
|
+
|
|
1043
|
+
import BaseCommand from '../lib/base-command.js'
|
|
1044
|
+
|
|
1045
|
+
export default class Status extends BaseCommand {
|
|
1046
|
+
static override description = 'Show AIW status'
|
|
1047
|
+
|
|
1048
|
+
static override examples = [
|
|
1049
|
+
'<%= config.bin %> <%= command.id %>',
|
|
1050
|
+
'<%= config.bin %> <%= command.id %> --debug',
|
|
1051
|
+
]
|
|
1052
|
+
|
|
1053
|
+
static override flags = {
|
|
1054
|
+
...BaseCommand.baseFlags, // Inherit global flags
|
|
1055
|
+
// Add command-specific flags here
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
async run(): Promise<void> {
|
|
1059
|
+
const {flags} = await this.parse(Status)
|
|
1060
|
+
// Implementation here
|
|
1061
|
+
this.log('Status output')
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
3. **Add tests** in `test/commands/`:
|
|
1067
|
+
```typescript
|
|
1068
|
+
// test/commands/status.test.ts
|
|
1069
|
+
import {expect, test} from '@oclif/test'
|
|
1070
|
+
|
|
1071
|
+
describe('status', () => {
|
|
1072
|
+
test
|
|
1073
|
+
.stdout()
|
|
1074
|
+
.command(['status'])
|
|
1075
|
+
.it('shows status', ctx => {
|
|
1076
|
+
expect(ctx.stdout).to.contain('Status output')
|
|
1077
|
+
})
|
|
1078
|
+
})
|
|
1079
|
+
```
|
|
1080
|
+
|
|
1081
|
+
### Adding a Topic (Command Group)
|
|
1082
|
+
|
|
1083
|
+
Topics organize related commands under a common namespace:
|
|
1084
|
+
|
|
1085
|
+
1. **Create directory** in `src/commands/`:
|
|
1086
|
+
```bash
|
|
1087
|
+
mkdir src/commands/config
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
2. **Add topic commands**:
|
|
1091
|
+
```typescript
|
|
1092
|
+
// src/commands/config/show.ts → aiw config show
|
|
1093
|
+
// src/commands/config/edit.ts → aiw config edit
|
|
1094
|
+
```
|
|
1095
|
+
|
|
1096
|
+
### Standard Flag Patterns
|
|
1097
|
+
|
|
1098
|
+
All commands should inherit base flags from `BaseCommand`:
|
|
1099
|
+
|
|
1100
|
+
| Flag | Long Form | Short Form | Purpose |
|
|
1101
|
+
|------|-----------|------------|---------|
|
|
1102
|
+
| Debug | `--debug` | `-d` | Enable verbose logging |
|
|
1103
|
+
| Help | `--help` | `-h` | Show command help |
|
|
1104
|
+
| Quiet | `--quiet` | `-q` | Suppress informational output (errors still shown) |
|
|
1105
|
+
|
|
1106
|
+
**Pattern:**
|
|
1107
|
+
```typescript
|
|
1108
|
+
static override flags = {
|
|
1109
|
+
...BaseCommand.baseFlags, // Always inherit base flags
|
|
1110
|
+
myFlag: Flags.string({
|
|
1111
|
+
char: 'm', // Short form
|
|
1112
|
+
description: 'My flag description',
|
|
1113
|
+
required: false,
|
|
1114
|
+
}),
|
|
1115
|
+
}
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
### Naming Conventions
|
|
1119
|
+
|
|
1120
|
+
| Element | Convention | Example |
|
|
1121
|
+
|---------|------------|---------|
|
|
1122
|
+
| Command files | kebab-case | `launch.ts`, `init/bmad.ts` |
|
|
1123
|
+
| Command classes | PascalCase | `Launch`, `InitBmad` |
|
|
1124
|
+
| Flags | camelCase | `debug`, `aiwDir`, `quiet` |
|
|
1125
|
+
| Constants | UPPER_SNAKE_CASE | `EXIT_CODES.SUCCESS` |
|
|
1126
|
+
|
|
1127
|
+
### Import Organization
|
|
1128
|
+
|
|
1129
|
+
Follow strict import order (enforced by ESLint):
|
|
1130
|
+
|
|
1131
|
+
```typescript
|
|
1132
|
+
// 1. Node builtins (with node: prefix)
|
|
1133
|
+
import {spawn} from 'node:child_process'
|
|
1134
|
+
|
|
1135
|
+
// 2. External packages
|
|
1136
|
+
import {Flags} from '@oclif/core'
|
|
1137
|
+
|
|
1138
|
+
// 3. Internal imports
|
|
1139
|
+
import BaseCommand from '../lib/base-command.js'
|
|
1140
|
+
import {getAiwDir} from '../lib/config.js'
|
|
1141
|
+
|
|
1142
|
+
// 4. Type imports
|
|
1143
|
+
import type {LaunchOptions} from '../types/index.js'
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
### Error Handling
|
|
1147
|
+
|
|
1148
|
+
Use categorized exit codes and actionable error messages:
|
|
1149
|
+
|
|
1150
|
+
```typescript
|
|
1151
|
+
import {EXIT_CODES} from '../types/index.js'
|
|
1152
|
+
|
|
1153
|
+
// Actionable error format: {what_wrong}. {how_to_fix}
|
|
1154
|
+
this.error(
|
|
1155
|
+
'Configuration file not found. Run `aiw init` to initialize.',
|
|
1156
|
+
{exit: EXIT_CODES.ENVIRONMENT_ERROR}
|
|
1157
|
+
)
|
|
1158
|
+
```
|
|
1159
|
+
|
|
1160
|
+
**Exit codes:**
|
|
1161
|
+
- `EXIT_CODES.SUCCESS` (0) - Successful execution
|
|
1162
|
+
- `EXIT_CODES.GENERAL_ERROR` (1) - General error
|
|
1163
|
+
- `EXIT_CODES.INVALID_USAGE` (2) - Invalid arguments
|
|
1164
|
+
- `EXIT_CODES.ENVIRONMENT_ERROR` (3) - Environment/prerequisite error
|
|
1165
|
+
|
|
1166
|
+
### Help System
|
|
1167
|
+
|
|
1168
|
+
Oclif provides built-in help:
|
|
1169
|
+
|
|
1170
|
+
- `aiw <command> --help` - Show command help
|
|
1171
|
+
- `aiw help <command>` - Alternative help format (same output)
|
|
1172
|
+
- `aiw help` - List all commands
|
|
1173
|
+
|
|
1174
|
+
Help is automatically generated from command metadata (description, examples, flags).
|
|
1175
|
+
|
|
1176
|
+
### Testing Commands
|
|
1177
|
+
|
|
1178
|
+
1. **Unit tests** (`test/commands/<command>.test.ts`):
|
|
1179
|
+
- Test command logic in isolation
|
|
1180
|
+
- Mock external dependencies
|
|
1181
|
+
|
|
1182
|
+
2. **Integration tests** (`test/integration/<feature>.test.ts`):
|
|
1183
|
+
- Test actual CLI invocation
|
|
1184
|
+
- Use `execSync()` to run commands
|
|
1185
|
+
- Cross-platform compatibility
|
|
1186
|
+
|
|
1187
|
+
**Example:**
|
|
1188
|
+
```typescript
|
|
1189
|
+
import {execSync} from 'node:child_process'
|
|
1190
|
+
import {platform} from 'node:os'
|
|
1191
|
+
|
|
1192
|
+
const bin = platform() === 'win32' ? String.raw`.\bin\dev.cmd` : './bin/dev.js'
|
|
1193
|
+
|
|
1194
|
+
it('executes command', () => {
|
|
1195
|
+
const result = execSync(`${bin} status`, {encoding: 'utf8'})
|
|
1196
|
+
expect(result).to.include('expected output')
|
|
1197
|
+
})
|
|
1198
|
+
```
|
|
1199
|
+
|
|
1200
|
+
### Project Structure
|
|
1201
|
+
|
|
1202
|
+
```
|
|
1203
|
+
aiwcli/
|
|
1204
|
+
├── src/
|
|
1205
|
+
│ ├── commands/
|
|
1206
|
+
│ │ ├── branch.ts # aiw branch <branchName>
|
|
1207
|
+
│ │ ├── launch.ts # aiw launch
|
|
1208
|
+
│ │ └── init/ # Topic: aiw init
|
|
1209
|
+
│ │ └── index.ts # aiw init --method <template>
|
|
1210
|
+
│ ├── lib/ # Internal libraries
|
|
1211
|
+
│ │ ├── base-command.ts # BaseCommand (extend this)
|
|
1212
|
+
│ │ ├── config.ts
|
|
1213
|
+
│ │ ├── debug.ts
|
|
1214
|
+
│ │ ├── errors.ts
|
|
1215
|
+
│ │ └── spawn.ts
|
|
1216
|
+
│ └── types/ # Type definitions
|
|
1217
|
+
│ └── index.ts
|
|
1218
|
+
├── test/
|
|
1219
|
+
│ ├── commands/ # Unit tests
|
|
1220
|
+
│ ├── lib/ # Library tests
|
|
1221
|
+
│ └── integration/ # Integration tests
|
|
1222
|
+
└── README.md
|
|
1223
|
+
```
|
|
1224
|
+
|
|
1225
|
+
### Critical Rules
|
|
1226
|
+
|
|
1227
|
+
**MUST:**
|
|
1228
|
+
- Extend `BaseCommand` for all commands
|
|
1229
|
+
- Inherit `BaseCommand.baseFlags` in flag definitions
|
|
1230
|
+
- Use `.js` extension in all imports (ESM requirement)
|
|
1231
|
+
- Add `node:` prefix for Node builtins
|
|
1232
|
+
- Use `this.error()` instead of `process.exit()`
|
|
1233
|
+
- Provide both short (`-f`) and long (`--flag`) flag forms
|
|
1234
|
+
- Follow kebab-case for command file names
|
|
1235
|
+
|
|
1236
|
+
**MUST NOT:**
|
|
1237
|
+
- Call `process.exit()` directly
|
|
1238
|
+
- Create utilities in `src/utils/` or `src/helpers/` (use `src/lib/`)
|
|
1239
|
+
- Use `I` prefix on interfaces (`Config` not `IConfig`)
|
|
1240
|
+
- Skip the `.js` extension in imports
|
|
1241
|
+
- Use Promise chains (use async/await)
|
|
1242
|
+
|
|
1243
|
+
### Resources
|
|
1244
|
+
|
|
1245
|
+
- [Oclif Documentation](https://oclif.io/docs)
|
|
1246
|
+
- [Oclif Commands](https://oclif.io/docs/commands)
|
|
1247
|
+
- [Oclif Flags](https://oclif.io/docs/flags)
|
|
1248
|
+
- [Oclif Topics](https://oclif.io/docs/topics)
|