@kosuke-ai/cli 0.0.56 → 1.0.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 +31 -448
- package/dist/commands/auth.js +117 -0
- package/dist/generated/commands/deploy/cancel.js +17 -0
- package/dist/generated/commands/deploy/messages.js +17 -0
- package/dist/generated/commands/deploy/run.js +60 -0
- package/dist/generated/commands/index.js +132 -0
- package/dist/generated/commands/preview/get.js +25 -0
- package/dist/generated/commands/preview/health.js +25 -0
- package/dist/generated/commands/preview/reset.js +27 -0
- package/dist/generated/commands/preview/share-create.js +36 -0
- package/dist/generated/commands/preview/share-delete.js +26 -0
- package/dist/generated/commands/preview/share-get.js +26 -0
- package/dist/generated/commands/preview/shared.js +17 -0
- package/dist/generated/commands/projects/create.js +37 -0
- package/dist/generated/commands/projects/delete.js +17 -0
- package/dist/generated/commands/projects/env-vars-add.js +21 -0
- package/dist/generated/commands/projects/env-vars-remove.js +21 -0
- package/dist/generated/commands/projects/get.js +17 -0
- package/dist/generated/commands/projects/list.js +15 -0
- package/dist/generated/commands/projects/services-add.js +87 -0
- package/dist/generated/commands/projects/services-list.js +18 -0
- package/dist/generated/commands/projects/services-remove.js +19 -0
- package/dist/generated/commands/projects/services-update.js +81 -0
- package/dist/generated/commands/projects/settings-get.js +18 -0
- package/dist/generated/commands/projects/settings-import.js +91 -0
- package/dist/generated/commands/projects/settings-update.js +77 -0
- package/dist/generated/commands/projects/skills.js +35 -0
- package/dist/generated/commands/projects/update.js +27 -0
- package/dist/generated/commands/sessions/activate.js +18 -0
- package/dist/generated/commands/sessions/checklist-generate.js +19 -0
- package/dist/generated/commands/sessions/checklist-get.js +19 -0
- package/dist/generated/commands/sessions/comments-add.js +63 -0
- package/dist/generated/commands/sessions/comments-delete.js +20 -0
- package/dist/generated/commands/sessions/comments-list.js +19 -0
- package/dist/generated/commands/sessions/comments-update.js +23 -0
- package/dist/generated/commands/sessions/create.js +126 -0
- package/dist/generated/commands/sessions/delete.js +18 -0
- package/dist/generated/commands/sessions/diff-files.js +19 -0
- package/dist/generated/commands/sessions/diff-patch.js +86 -0
- package/dist/generated/commands/sessions/edit-prompt.js +59 -0
- package/dist/generated/commands/sessions/files-get.js +27 -0
- package/dist/generated/commands/sessions/files-list.js +19 -0
- package/dist/generated/commands/sessions/files-write.js +41 -0
- package/dist/generated/commands/sessions/get.js +18 -0
- package/dist/generated/commands/sessions/git-commit-message.js +19 -0
- package/dist/generated/commands/sessions/git-commit.js +29 -0
- package/dist/generated/commands/sessions/git-push.js +19 -0
- package/dist/generated/commands/sessions/git-state.js +19 -0
- package/dist/generated/commands/sessions/jobs-cancel.js +20 -0
- package/dist/generated/commands/sessions/jobs-get.js +20 -0
- package/dist/generated/commands/sessions/list.js +81 -0
- package/dist/generated/commands/sessions/messages.js +18 -0
- package/dist/generated/commands/sessions/search.js +23 -0
- package/dist/generated/commands/sessions/send.js +98 -0
- package/dist/generated/commands/sessions/update.js +72 -0
- package/dist/generated/commands/workspaces/access-status.js +29 -0
- package/dist/generated/commands/workspaces/ai-provider-get.js +18 -0
- package/dist/generated/commands/workspaces/ai-provider-remove.js +42 -0
- package/dist/generated/commands/workspaces/ai-provider-set.js +21 -0
- package/dist/generated/commands/workspaces/credits.js +17 -0
- package/dist/generated/commands/workspaces/get.js +17 -0
- package/dist/generated/commands/workspaces/getting-started-get.js +18 -0
- package/dist/generated/commands/workspaces/getting-started-update.js +32 -0
- package/dist/generated/commands/workspaces/list.js +15 -0
- package/dist/generated/commands/workspaces/members.js +25 -0
- package/dist/generated/commands/workspaces/sandbox-limit.js +17 -0
- package/dist/generated/commands/workspaces/stop-sandboxes.js +27 -0
- package/dist/generated/commands/workspaces/usage.js +32 -0
- package/dist/index.js +5 -516
- package/dist/program.js +46 -0
- package/dist/runtime/attach.js +139 -0
- package/dist/runtime/attachments.js +58 -0
- package/dist/runtime/client.js +12 -0
- package/dist/runtime/config.js +49 -0
- package/dist/runtime/credentials.js +24 -0
- package/dist/runtime/descriptor.js +7 -0
- package/dist/runtime/invoke.js +152 -0
- package/dist/runtime/runtime.js +41 -0
- package/dist/runtime/version.js +5 -0
- package/openapi.json +5222 -0
- package/package.json +21 -79
- package/LICENSE +0 -21
- package/claude.costs.json +0 -34
- package/dist/__tests__/utils/file-discovery.test.d.ts +0 -5
- package/dist/__tests__/utils/file-discovery.test.d.ts.map +0 -1
- package/dist/__tests__/utils/file-discovery.test.js +0 -51
- package/dist/__tests__/utils/file-discovery.test.js.map +0 -1
- package/dist/__tests__/utils/logger-nologs.test.d.ts +0 -5
- package/dist/__tests__/utils/logger-nologs.test.d.ts.map +0 -1
- package/dist/__tests__/utils/logger-nologs.test.js +0 -34
- package/dist/__tests__/utils/logger-nologs.test.js.map +0 -1
- package/dist/__tests__/utils/logger.test.d.ts +0 -5
- package/dist/__tests__/utils/logger.test.d.ts.map +0 -1
- package/dist/__tests__/utils/logger.test.js +0 -243
- package/dist/__tests__/utils/logger.test.js.map +0 -1
- package/dist/__tests__/utils/validator.test.d.ts +0 -5
- package/dist/__tests__/utils/validator.test.d.ts.map +0 -1
- package/dist/__tests__/utils/validator.test.js +0 -206
- package/dist/__tests__/utils/validator.test.js.map +0 -1
- package/dist/index.d.ts +0 -35
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kosuke/commands/analyse.d.ts +0 -15
- package/dist/kosuke/commands/analyse.d.ts.map +0 -1
- package/dist/kosuke/commands/analyse.js +0 -273
- package/dist/kosuke/commands/analyse.js.map +0 -1
- package/dist/kosuke/commands/build.d.ts +0 -35
- package/dist/kosuke/commands/build.d.ts.map +0 -1
- package/dist/kosuke/commands/build.js +0 -659
- package/dist/kosuke/commands/build.js.map +0 -1
- package/dist/kosuke/commands/getcode.d.ts +0 -29
- package/dist/kosuke/commands/getcode.d.ts.map +0 -1
- package/dist/kosuke/commands/getcode.js +0 -221
- package/dist/kosuke/commands/getcode.js.map +0 -1
- package/dist/kosuke/commands/lint.d.ts +0 -21
- package/dist/kosuke/commands/lint.d.ts.map +0 -1
- package/dist/kosuke/commands/lint.js +0 -321
- package/dist/kosuke/commands/lint.js.map +0 -1
- package/dist/kosuke/commands/migrate.d.ts +0 -38
- package/dist/kosuke/commands/migrate.d.ts.map +0 -1
- package/dist/kosuke/commands/migrate.js +0 -284
- package/dist/kosuke/commands/migrate.js.map +0 -1
- package/dist/kosuke/commands/plan.d.ts +0 -28
- package/dist/kosuke/commands/plan.d.ts.map +0 -1
- package/dist/kosuke/commands/plan.js +0 -630
- package/dist/kosuke/commands/plan.js.map +0 -1
- package/dist/kosuke/commands/requirements.d.ts +0 -52
- package/dist/kosuke/commands/requirements.d.ts.map +0 -1
- package/dist/kosuke/commands/requirements.js +0 -615
- package/dist/kosuke/commands/requirements.js.map +0 -1
- package/dist/kosuke/commands/review.d.ts +0 -26
- package/dist/kosuke/commands/review.d.ts.map +0 -1
- package/dist/kosuke/commands/review.js +0 -303
- package/dist/kosuke/commands/review.js.map +0 -1
- package/dist/kosuke/commands/serve.d.ts +0 -9
- package/dist/kosuke/commands/serve.d.ts.map +0 -1
- package/dist/kosuke/commands/serve.js +0 -17
- package/dist/kosuke/commands/serve.js.map +0 -1
- package/dist/kosuke/commands/ship.d.ts +0 -37
- package/dist/kosuke/commands/ship.d.ts.map +0 -1
- package/dist/kosuke/commands/ship.js +0 -375
- package/dist/kosuke/commands/ship.js.map +0 -1
- package/dist/kosuke/commands/sync-rules.d.ts +0 -9
- package/dist/kosuke/commands/sync-rules.d.ts.map +0 -1
- package/dist/kosuke/commands/sync-rules.js +0 -379
- package/dist/kosuke/commands/sync-rules.js.map +0 -1
- package/dist/kosuke/commands/test.d.ts +0 -42
- package/dist/kosuke/commands/test.d.ts.map +0 -1
- package/dist/kosuke/commands/test.js +0 -540
- package/dist/kosuke/commands/test.js.map +0 -1
- package/dist/kosuke/commands/tickets.d.ts +0 -43
- package/dist/kosuke/commands/tickets.d.ts.map +0 -1
- package/dist/kosuke/commands/tickets.js +0 -499
- package/dist/kosuke/commands/tickets.js.map +0 -1
- package/dist/kosuke/serve/middleware/error-handler.d.ts +0 -14
- package/dist/kosuke/serve/middleware/error-handler.d.ts.map +0 -1
- package/dist/kosuke/serve/middleware/error-handler.js +0 -42
- package/dist/kosuke/serve/middleware/error-handler.js.map +0 -1
- package/dist/kosuke/serve/middleware/validation.d.ts +0 -13
- package/dist/kosuke/serve/middleware/validation.d.ts.map +0 -1
- package/dist/kosuke/serve/middleware/validation.js +0 -38
- package/dist/kosuke/serve/middleware/validation.js.map +0 -1
- package/dist/kosuke/serve/routes/build.d.ts +0 -6
- package/dist/kosuke/serve/routes/build.d.ts.map +0 -1
- package/dist/kosuke/serve/routes/build.js +0 -226
- package/dist/kosuke/serve/routes/build.js.map +0 -1
- package/dist/kosuke/serve/routes/health.d.ts +0 -6
- package/dist/kosuke/serve/routes/health.d.ts.map +0 -1
- package/dist/kosuke/serve/routes/health.js +0 -11
- package/dist/kosuke/serve/routes/health.js.map +0 -1
- package/dist/kosuke/serve/routes/plan.d.ts +0 -6
- package/dist/kosuke/serve/routes/plan.d.ts.map +0 -1
- package/dist/kosuke/serve/routes/plan.js +0 -106
- package/dist/kosuke/serve/routes/plan.js.map +0 -1
- package/dist/kosuke/serve/server.d.ts +0 -16
- package/dist/kosuke/serve/server.d.ts.map +0 -1
- package/dist/kosuke/serve/server.js +0 -67
- package/dist/kosuke/serve/server.js.map +0 -1
- package/dist/kosuke/serve/validation/build.d.ts +0 -41
- package/dist/kosuke/serve/validation/build.d.ts.map +0 -1
- package/dist/kosuke/serve/validation/build.js +0 -20
- package/dist/kosuke/serve/validation/build.js.map +0 -1
- package/dist/kosuke/serve/validation/plan.d.ts +0 -26
- package/dist/kosuke/serve/validation/plan.d.ts.map +0 -1
- package/dist/kosuke/serve/validation/plan.js +0 -15
- package/dist/kosuke/serve/validation/plan.js.map +0 -1
- package/dist/kosuke/types.d.ts +0 -469
- package/dist/kosuke/types.d.ts.map +0 -1
- package/dist/kosuke/types.js +0 -5
- package/dist/kosuke/types.js.map +0 -1
- package/dist/kosuke/utils/batch-creator.d.ts +0 -14
- package/dist/kosuke/utils/batch-creator.d.ts.map +0 -1
- package/dist/kosuke/utils/batch-creator.js +0 -76
- package/dist/kosuke/utils/batch-creator.js.map +0 -1
- package/dist/kosuke/utils/claude-agent.d.ts +0 -145
- package/dist/kosuke/utils/claude-agent.d.ts.map +0 -1
- package/dist/kosuke/utils/claude-agent.js +0 -504
- package/dist/kosuke/utils/claude-agent.js.map +0 -1
- package/dist/kosuke/utils/constants.d.ts +0 -40
- package/dist/kosuke/utils/constants.d.ts.map +0 -1
- package/dist/kosuke/utils/constants.js +0 -54
- package/dist/kosuke/utils/constants.js.map +0 -1
- package/dist/kosuke/utils/file-discovery.d.ts +0 -15
- package/dist/kosuke/utils/file-discovery.d.ts.map +0 -1
- package/dist/kosuke/utils/file-discovery.js +0 -80
- package/dist/kosuke/utils/file-discovery.js.map +0 -1
- package/dist/kosuke/utils/git.d.ts +0 -41
- package/dist/kosuke/utils/git.d.ts.map +0 -1
- package/dist/kosuke/utils/git.js +0 -145
- package/dist/kosuke/utils/git.js.map +0 -1
- package/dist/kosuke/utils/github.d.ts +0 -17
- package/dist/kosuke/utils/github.d.ts.map +0 -1
- package/dist/kosuke/utils/github.js +0 -22
- package/dist/kosuke/utils/github.js.map +0 -1
- package/dist/kosuke/utils/interactive-input.d.ts +0 -22
- package/dist/kosuke/utils/interactive-input.d.ts.map +0 -1
- package/dist/kosuke/utils/interactive-input.js +0 -124
- package/dist/kosuke/utils/interactive-input.js.map +0 -1
- package/dist/kosuke/utils/logger.d.ts +0 -161
- package/dist/kosuke/utils/logger.d.ts.map +0 -1
- package/dist/kosuke/utils/logger.js +0 -234
- package/dist/kosuke/utils/logger.js.map +0 -1
- package/dist/kosuke/utils/playwright-mcp-client.d.ts +0 -46
- package/dist/kosuke/utils/playwright-mcp-client.d.ts.map +0 -1
- package/dist/kosuke/utils/playwright-mcp-client.js +0 -135
- package/dist/kosuke/utils/playwright-mcp-client.js.map +0 -1
- package/dist/kosuke/utils/pr-orchestrator.d.ts +0 -49
- package/dist/kosuke/utils/pr-orchestrator.d.ts.map +0 -1
- package/dist/kosuke/utils/pr-orchestrator.js +0 -154
- package/dist/kosuke/utils/pr-orchestrator.js.map +0 -1
- package/dist/kosuke/utils/repository-manager.d.ts +0 -13
- package/dist/kosuke/utils/repository-manager.d.ts.map +0 -1
- package/dist/kosuke/utils/repository-manager.js +0 -94
- package/dist/kosuke/utils/repository-manager.js.map +0 -1
- package/dist/kosuke/utils/repository-resolver.d.ts +0 -12
- package/dist/kosuke/utils/repository-resolver.d.ts.map +0 -1
- package/dist/kosuke/utils/repository-resolver.js +0 -186
- package/dist/kosuke/utils/repository-resolver.js.map +0 -1
- package/dist/kosuke/utils/tickets-manager.d.ts +0 -64
- package/dist/kosuke/utils/tickets-manager.d.ts.map +0 -1
- package/dist/kosuke/utils/tickets-manager.js +0 -331
- package/dist/kosuke/utils/tickets-manager.js.map +0 -1
- package/dist/kosuke/utils/validator.d.ts +0 -45
- package/dist/kosuke/utils/validator.d.ts.map +0 -1
- package/dist/kosuke/utils/validator.js +0 -248
- package/dist/kosuke/utils/validator.js.map +0 -1
- package/dist/lib.d.ts +0 -96
- package/dist/lib.d.ts.map +0 -1
- package/dist/lib.js +0 -95
- package/dist/lib.js.map +0 -1
- package/dist/package.json +0 -99
package/dist/index.js
CHANGED
|
@@ -1,518 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* analyse Analyze and fix code quality issues
|
|
8
|
-
* lint Fix linting errors with Claude AI
|
|
9
|
-
* requirements Interactive requirements gathering
|
|
10
|
-
* plan AI-driven ticket planning from feature/bug descriptions
|
|
11
|
-
* getcode Explore GitHub repositories and fetch code
|
|
12
|
-
* tickets Generate implementation tickets from requirements
|
|
13
|
-
* build Batch process all tickets from tickets.json
|
|
14
|
-
* migrate Apply database migrations and validate schema
|
|
15
|
-
* review Review codebase against CLAUDE.md rules
|
|
16
|
-
* test Run atomic web E2E tests
|
|
17
|
-
*
|
|
18
|
-
* Usage:
|
|
19
|
-
* bun run kosuke sync-rules
|
|
20
|
-
* bun run kosuke analyse
|
|
21
|
-
* bun run kosuke lint
|
|
22
|
-
* bun run kosuke requirements
|
|
23
|
-
* bun run kosuke getcode "query"
|
|
24
|
-
* bun run kosuke tickets
|
|
25
|
-
* bun run kosuke build
|
|
26
|
-
* bun run kosuke migrate
|
|
27
|
-
* bun run kosuke review
|
|
28
|
-
* bun run kosuke test --prompt="Test user login flow"
|
|
29
|
-
*
|
|
30
|
-
* Environment Variables:
|
|
31
|
-
* ANTHROPIC_API_KEY - Required for Claude API
|
|
32
|
-
* GITHUB_TOKEN - Required for creating PRs
|
|
33
|
-
*/
|
|
34
|
-
import 'dotenv/config';
|
|
35
|
-
import { analyseCommand } from './kosuke/commands/analyse.js';
|
|
36
|
-
import { buildCommand } from './kosuke/commands/build.js';
|
|
37
|
-
import { getCodeCommand, parseGetCodeArgs } from './kosuke/commands/getcode.js';
|
|
38
|
-
import { lintCommand } from './kosuke/commands/lint.js';
|
|
39
|
-
import { migrateCommand } from './kosuke/commands/migrate.js';
|
|
40
|
-
import { planCommand } from './kosuke/commands/plan.js';
|
|
41
|
-
import { requirementsCommand } from './kosuke/commands/requirements.js';
|
|
42
|
-
import { reviewCommand } from './kosuke/commands/review.js';
|
|
43
|
-
import { serveCommand } from './kosuke/commands/serve.js';
|
|
44
|
-
import { syncRulesCommand } from './kosuke/commands/sync-rules.js';
|
|
45
|
-
import { testCommand } from './kosuke/commands/test.js';
|
|
46
|
-
import { ticketsCommand } from './kosuke/commands/tickets.js';
|
|
47
|
-
import { TRACES_DIR } from './kosuke/utils/constants.js';
|
|
48
|
-
async function main() {
|
|
49
|
-
const args = process.argv.slice(2);
|
|
50
|
-
const command = args[0];
|
|
51
|
-
if (!command || command === '--help' || command === '-h' || command === 'help') {
|
|
52
|
-
showHelp();
|
|
53
|
-
process.exit(0);
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
switch (command) {
|
|
57
|
-
case 'sync-rules': {
|
|
58
|
-
const options = {
|
|
59
|
-
force: args.includes('--force'),
|
|
60
|
-
pr: args.includes('--pr'),
|
|
61
|
-
baseBranch: args.find((arg) => arg.startsWith('--base-branch='))?.split('=')[1],
|
|
62
|
-
noLogs: args.includes('--no-logs'),
|
|
63
|
-
};
|
|
64
|
-
await syncRulesCommand(options);
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
case 'analyse': {
|
|
68
|
-
const options = {
|
|
69
|
-
pr: args.includes('--pr'),
|
|
70
|
-
baseBranch: args.find((arg) => arg.startsWith('--base-branch='))?.split('=')[1],
|
|
71
|
-
scope: args.find((arg) => arg.startsWith('--scope='))?.split('=')[1],
|
|
72
|
-
types: args
|
|
73
|
-
.find((arg) => arg.startsWith('--types='))
|
|
74
|
-
?.split('=')[1]
|
|
75
|
-
?.split(','),
|
|
76
|
-
noLogs: args.includes('--no-logs'),
|
|
77
|
-
};
|
|
78
|
-
await analyseCommand(options);
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
case 'lint': {
|
|
82
|
-
const options = {
|
|
83
|
-
pr: args.includes('--pr'),
|
|
84
|
-
baseBranch: args.find((arg) => arg.startsWith('--base-branch='))?.split('=')[1],
|
|
85
|
-
directory: args.find((arg) => arg.startsWith('--directory='))?.split('=')[1],
|
|
86
|
-
noLogs: args.includes('--no-logs'),
|
|
87
|
-
};
|
|
88
|
-
await lintCommand(options);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case 'requirements': {
|
|
92
|
-
await requirementsCommand();
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case 'plan': {
|
|
96
|
-
const options = {
|
|
97
|
-
prompt: args.find((arg) => arg.startsWith('--prompt='))?.split('=')[1] || '',
|
|
98
|
-
directory: args.find((arg) => arg.startsWith('--directory='))?.split('=')[1] ||
|
|
99
|
-
args.find((arg) => arg.startsWith('--dir='))?.split('=')[1],
|
|
100
|
-
noTest: args.includes('--no-test'),
|
|
101
|
-
noLogs: args.includes('--no-logs'),
|
|
102
|
-
resume: args.find((arg) => arg.startsWith('--resume='))?.split('=')[1],
|
|
103
|
-
};
|
|
104
|
-
if (!options.prompt) {
|
|
105
|
-
console.error('❌ The --prompt flag is required\n');
|
|
106
|
-
console.log('Usage: kosuke plan --prompt="..." [OPTIONS]');
|
|
107
|
-
console.log('\nOptions:');
|
|
108
|
-
console.log(' --prompt="..." Feature or bug description (required)');
|
|
109
|
-
console.log(' --directory=PATH Directory with existing code (default: cwd)');
|
|
110
|
-
console.log(' --resume=SESSION_ID Resume a previous planning session');
|
|
111
|
-
console.log(' --no-test Skip WEB-TEST ticket creation');
|
|
112
|
-
console.log('\nOutput:');
|
|
113
|
-
console.log(' Tickets are saved to tickets/{timestamp}.ticket.json');
|
|
114
|
-
console.log('\nExamples:');
|
|
115
|
-
console.log(' kosuke plan --prompt="Add dark mode toggle"');
|
|
116
|
-
console.log(' kosuke plan --prompt="Fix login timeout bug" --directory=./my-app');
|
|
117
|
-
console.log(' kosuke plan --prompt="Add user notifications" --no-test');
|
|
118
|
-
console.log(' kosuke plan --prompt="continue" --resume=<session-id>');
|
|
119
|
-
process.exit(1);
|
|
120
|
-
}
|
|
121
|
-
await planCommand(options);
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
case 'getcode': {
|
|
125
|
-
const options = parseGetCodeArgs(args);
|
|
126
|
-
await getCodeCommand(options);
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case 'tickets': {
|
|
130
|
-
const options = {
|
|
131
|
-
path: args.find((arg) => arg.startsWith('--path='))?.split('=')[1],
|
|
132
|
-
output: args.find((arg) => arg.startsWith('--output='))?.split('=')[1],
|
|
133
|
-
directory: args.find((arg) => arg.startsWith('--directory='))?.split('=')[1] ||
|
|
134
|
-
args.find((arg) => arg.startsWith('--dir='))?.split('=')[1],
|
|
135
|
-
scaffold: args.includes('--scaffold'),
|
|
136
|
-
prompt: args.find((arg) => arg.startsWith('--prompt='))?.split('=')[1],
|
|
137
|
-
noTest: args.includes('--no-test'),
|
|
138
|
-
noLogs: args.includes('--no-logs'),
|
|
139
|
-
};
|
|
140
|
-
await ticketsCommand(options);
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
case 'build': {
|
|
144
|
-
const options = {
|
|
145
|
-
directory: args.find((arg) => arg.startsWith('--directory='))?.split('=')[1] ||
|
|
146
|
-
args.find((arg) => arg.startsWith('--dir='))?.split('=')[1],
|
|
147
|
-
ticketsFile: args.find((arg) => arg.startsWith('--tickets='))?.split('=')[1],
|
|
148
|
-
dbUrl: args.find((arg) => arg.startsWith('--db-url='))?.split('=')[1],
|
|
149
|
-
reset: args.includes('--reset'),
|
|
150
|
-
askConfirm: args.includes('--ask-confirm'),
|
|
151
|
-
askCommit: args.includes('--ask-commit'),
|
|
152
|
-
review: !args.includes('--no-review'), // Default true, disabled with --no-review
|
|
153
|
-
test: !args.includes('--no-test'), // Default true, disabled with --no-test
|
|
154
|
-
url: args.find((arg) => arg.startsWith('--url='))?.split('=')[1],
|
|
155
|
-
headless: args.includes('--headless'),
|
|
156
|
-
verbose: args.includes('--verbose'),
|
|
157
|
-
playwright: args.includes('--playwright'),
|
|
158
|
-
trace: args.includes('--trace'),
|
|
159
|
-
noLogs: args.includes('--no-logs'),
|
|
160
|
-
};
|
|
161
|
-
await buildCommand(options);
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case 'migrate': {
|
|
165
|
-
const options = {
|
|
166
|
-
directory: args.find((arg) => arg.startsWith('--directory='))?.split('=')[1] ||
|
|
167
|
-
args.find((arg) => arg.startsWith('--dir='))?.split('=')[1],
|
|
168
|
-
dbUrl: args.find((arg) => arg.startsWith('--db-url='))?.split('=')[1],
|
|
169
|
-
noLogs: args.includes('--no-logs'),
|
|
170
|
-
};
|
|
171
|
-
await migrateCommand(options);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
case 'review': {
|
|
175
|
-
const options = {
|
|
176
|
-
noLogs: args.includes('--no-logs'),
|
|
177
|
-
};
|
|
178
|
-
await reviewCommand(options);
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
case 'test': {
|
|
182
|
-
const promptArg = args.find((arg) => arg.startsWith('--prompt='))?.split('=')[1];
|
|
183
|
-
if (!promptArg) {
|
|
184
|
-
console.error('❌ The --prompt flag is required\n');
|
|
185
|
-
console.log('Usage: kosuke test --prompt="..." [OPTIONS]');
|
|
186
|
-
console.log('\nOptions:');
|
|
187
|
-
console.log(' --prompt="..." Test instructions (required)');
|
|
188
|
-
console.log(' --url=URL Base URL for web tests (default: http://localhost:3000)');
|
|
189
|
-
console.log(' --headless Run in headless mode (invisible browser)');
|
|
190
|
-
console.log(' --verbose Enable verbose output');
|
|
191
|
-
console.log(' --trace Enable trace recording (saves video/screenshots)');
|
|
192
|
-
console.log('\nExamples:');
|
|
193
|
-
console.log(' kosuke test --prompt="Test user login flow"');
|
|
194
|
-
console.log(' kosuke test --prompt="Test task creation" --verbose --headless');
|
|
195
|
-
console.log(' kosuke test --prompt="Test checkout" --trace # With video/screenshots');
|
|
196
|
-
console.log(` npx playwright show-trace ${TRACES_DIR}/.../trace.trace`);
|
|
197
|
-
console.log('\nNote: This command is mainly used programmatically from kosuke build.');
|
|
198
|
-
console.log(' For ticket-based testing with retries, use: kosuke build');
|
|
199
|
-
process.exit(1);
|
|
200
|
-
}
|
|
201
|
-
const options = {
|
|
202
|
-
prompt: promptArg,
|
|
203
|
-
url: args.find((arg) => arg.startsWith('--url='))?.split('=')[1],
|
|
204
|
-
headless: args.includes('--headless'),
|
|
205
|
-
verbose: args.includes('--verbose'),
|
|
206
|
-
granular: args.includes('--granular'),
|
|
207
|
-
playwright: args.includes('--playwright'),
|
|
208
|
-
trace: args.includes('--trace'),
|
|
209
|
-
directory: args.find((arg) => arg.startsWith('--directory='))?.split('=')[1] ||
|
|
210
|
-
args.find((arg) => arg.startsWith('--dir='))?.split('=')[1],
|
|
211
|
-
noLogs: args.includes('--no-logs'),
|
|
212
|
-
};
|
|
213
|
-
await testCommand(options);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
case 'serve': {
|
|
217
|
-
const options = {
|
|
218
|
-
port: parseInt(args.find((arg) => arg.startsWith('--port='))?.split('=')[1] || '3000'),
|
|
219
|
-
};
|
|
220
|
-
await serveCommand(options);
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
default:
|
|
224
|
-
console.error(`❌ Unknown command: ${command}\n`);
|
|
225
|
-
showHelp();
|
|
226
|
-
process.exit(1);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
console.error('\n❌ Fatal error:', error);
|
|
231
|
-
process.exit(1);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function showHelp() {
|
|
235
|
-
console.log(`
|
|
236
|
-
╔═══════════════════════════════════════════════════════════╗
|
|
237
|
-
║ Kosuke CLI - Development Tools ║
|
|
238
|
-
╚═══════════════════════════════════════════════════════════╝
|
|
239
|
-
|
|
240
|
-
COMMANDS:
|
|
241
|
-
|
|
242
|
-
serve [options]
|
|
243
|
-
Start HTTP server for Kosuke CLI commands
|
|
244
|
-
Provides SSE endpoints for real-time command execution
|
|
245
|
-
|
|
246
|
-
Options:
|
|
247
|
-
--port=<number> Port to listen on (default: 3000)
|
|
248
|
-
|
|
249
|
-
Examples:
|
|
250
|
-
kosuke serve # Start on port 3000
|
|
251
|
-
kosuke serve --port=8080 # Start on custom port
|
|
252
|
-
|
|
253
|
-
Endpoints:
|
|
254
|
-
GET /health # Health check
|
|
255
|
-
POST /api/plan # Plan command with SSE
|
|
256
|
-
|
|
257
|
-
sync-rules [options]
|
|
258
|
-
Sync rules and documentation from kosuke-template
|
|
259
|
-
|
|
260
|
-
Options:
|
|
261
|
-
--force Compare files regardless of recent commit history
|
|
262
|
-
--pr Create a pull request with changes
|
|
263
|
-
--base-branch=<name> Base branch for PR (default: current branch)
|
|
264
|
-
|
|
265
|
-
Examples:
|
|
266
|
-
kosuke sync-rules # Local changes only
|
|
267
|
-
kosuke sync-rules --force # Force comparison
|
|
268
|
-
kosuke sync-rules --pr # Create PR
|
|
269
|
-
kosuke sync-rules --pr --base-branch=develop
|
|
270
|
-
|
|
271
|
-
analyse [options]
|
|
272
|
-
Analyze and fix code quality issues against CLAUDE.md rules
|
|
273
|
-
Applies fixes locally by default
|
|
274
|
-
|
|
275
|
-
Options:
|
|
276
|
-
--pr Create a pull request with fixes
|
|
277
|
-
--base-branch=<name> Base branch for PR (default: current branch)
|
|
278
|
-
--scope=<dirs> Analyze specific directories (comma-separated)
|
|
279
|
-
--types=<exts> Analyze specific file types (comma-separated)
|
|
280
|
-
|
|
281
|
-
Examples:
|
|
282
|
-
kosuke analyse # Local fixes only
|
|
283
|
-
kosuke analyse --pr # Create PR with fixes
|
|
284
|
-
kosuke analyse --scope=hooks,lib/trpc
|
|
285
|
-
kosuke analyse --types=ts,tsx
|
|
286
|
-
kosuke analyse --pr --base-branch=main
|
|
287
|
-
|
|
288
|
-
lint [options]
|
|
289
|
-
Use Claude AI to automatically fix linting errors
|
|
290
|
-
Applies fixes locally by default
|
|
291
|
-
|
|
292
|
-
Options:
|
|
293
|
-
--pr Create a pull request with fixes
|
|
294
|
-
--base-branch=<name> Base branch for PR (default: current branch)
|
|
295
|
-
--directory=<path> Directory to run linting in (default: current directory)
|
|
296
|
-
|
|
297
|
-
Examples:
|
|
298
|
-
kosuke lint # Local fixes only
|
|
299
|
-
kosuke lint --pr # Create PR with fixes
|
|
300
|
-
kosuke lint --pr --base-branch=main
|
|
301
|
-
kosuke lint --directory=./my-project # Run lint in specific directory
|
|
302
|
-
|
|
303
|
-
requirements
|
|
304
|
-
Interactive requirements gathering with Claude AI
|
|
305
|
-
Generates a comprehensive docs.md file
|
|
306
|
-
|
|
307
|
-
Examples:
|
|
308
|
-
kosuke requirements
|
|
309
|
-
|
|
310
|
-
plan --prompt="..." [options]
|
|
311
|
-
AI-driven ticket planning from feature/bug descriptions
|
|
312
|
-
Analyzes existing codebase and asks clarification questions
|
|
313
|
-
Generates tickets in tickets/{timestamp}.ticket.json
|
|
314
|
-
|
|
315
|
-
Options:
|
|
316
|
-
--prompt="..." Feature or bug description (required)
|
|
317
|
-
--directory=<path> Directory with existing code (default: current directory)
|
|
318
|
-
--dir=<path> Alias for --directory
|
|
319
|
-
--no-test Skip WEB-TEST ticket creation
|
|
320
|
-
|
|
321
|
-
Output:
|
|
322
|
-
Creates tickets/{timestamp}.ticket.json in project directory
|
|
323
|
-
|
|
324
|
-
Examples:
|
|
325
|
-
kosuke plan --prompt="Add dark mode toggle"
|
|
326
|
-
kosuke plan --prompt="Fix login timeout bug" --directory=./my-app
|
|
327
|
-
kosuke plan --prompt="Add user notifications" --no-test
|
|
328
|
-
kosuke plan --prompt="continue" --resume=<session-id>
|
|
329
|
-
|
|
330
|
-
Features:
|
|
331
|
-
- Analyzes codebase to understand existing patterns
|
|
332
|
-
- Asks non-technical clarification questions
|
|
333
|
-
- Auto-detects ticket types (SCHEMA, BACKEND, FRONTEND, WEB-TEST)
|
|
334
|
-
- Reply "go with recommendations" to accept all defaults
|
|
335
|
-
|
|
336
|
-
getcode [repo] "<query>" [options]
|
|
337
|
-
Explore GitHub repositories and fetch code implementations
|
|
338
|
-
Uses Claude Code Agent to find and explain code
|
|
339
|
-
|
|
340
|
-
Options:
|
|
341
|
-
--template, -t Use kosuke-template repository
|
|
342
|
-
--output=<file> Save output to file
|
|
343
|
-
|
|
344
|
-
Examples:
|
|
345
|
-
kosuke getcode "facebook/react" "How does reconciliation work?"
|
|
346
|
-
kosuke getcode "How is routing implemented in Next.js?"
|
|
347
|
-
kosuke getcode --template "What authentication system is used?"
|
|
348
|
-
kosuke getcode -t "Show me pagination examples"
|
|
349
|
-
|
|
350
|
-
tickets [options]
|
|
351
|
-
Generate implementation tickets from requirements document or prompt
|
|
352
|
-
|
|
353
|
-
Two modes of operation:
|
|
354
|
-
|
|
355
|
-
PROMPT MODE (--prompt flag):
|
|
356
|
-
Uses 'plan' command internally for INTERACTIVE ticket creation.
|
|
357
|
-
Claude asks clarification questions before generating tickets.
|
|
358
|
-
Best for: Adding features or fixing bugs in existing projects.
|
|
359
|
-
|
|
360
|
-
DOCUMENT MODE (--path or docs.md):
|
|
361
|
-
Generates tickets directly from requirements document.
|
|
362
|
-
No clarification questions - assumes requirements are complete.
|
|
363
|
-
Best for: New projects with docs.md from 'kosuke requirements'.
|
|
364
|
-
|
|
365
|
-
SCAFFOLD MODE (--scaffold, document mode only):
|
|
366
|
-
Generates infrastructure adaptation + business logic tickets.
|
|
367
|
-
|
|
368
|
-
Options:
|
|
369
|
-
--prompt="..." Feature/bug description (triggers interactive mode)
|
|
370
|
-
--path=<file> Path to requirements document (default: docs.md)
|
|
371
|
-
--scaffold Enable scaffold mode (document mode only)
|
|
372
|
-
--output=<file> Output file for tickets (default: tickets.json)
|
|
373
|
-
--directory=<path> Directory for Claude to explore (default: current directory)
|
|
374
|
-
--dir=<path> Alias for --directory
|
|
375
|
-
|
|
376
|
-
Examples:
|
|
377
|
-
# Interactive mode (with clarification questions)
|
|
378
|
-
kosuke tickets --prompt="Add dark mode toggle" --dir=./my-app
|
|
379
|
-
kosuke tickets --prompt="Fix login timeout bug"
|
|
380
|
-
|
|
381
|
-
# Document mode (no questions, from docs.md)
|
|
382
|
-
kosuke tickets # Uses docs.md
|
|
383
|
-
kosuke tickets --path=feature.md # Custom file
|
|
384
|
-
kosuke tickets --scaffold # Scaffold + logic from docs.md
|
|
385
|
-
|
|
386
|
-
build [options]
|
|
387
|
-
Batch process all "Todo" and "Error" tickets from tickets.json
|
|
388
|
-
Implements tickets and runs tests with automatic fixing
|
|
389
|
-
Processes tickets in order: Schema (auto-validated) → Backend → Frontend → Web Test
|
|
390
|
-
Commits in batches after each web-test completion
|
|
391
|
-
Frontend tickets automatically include E2E testing (unless --no-test)
|
|
392
|
-
All tickets include code review by default (unless --no-review)
|
|
393
|
-
|
|
394
|
-
Options:
|
|
395
|
-
--directory=<path> Directory to run build in (default: current directory)
|
|
396
|
-
--dir=<path> Alias for --directory
|
|
397
|
-
--tickets=<file> Path to tickets file (default: tickets.json, relative to directory)
|
|
398
|
-
--db-url=<url> Database URL for migrations (default: postgres://postgres:postgres@postgres:5432/postgres)
|
|
399
|
-
--reset Reset all tickets to "Todo" status before processing (start from scratch)
|
|
400
|
-
--ask-confirm Ask for confirmation before proceeding to next ticket (useful for review)
|
|
401
|
-
--ask-commit Ask before committing each ticket (default: auto-commit after each ticket)
|
|
402
|
-
--no-review Skip code review phase (enabled by default)
|
|
403
|
-
--no-test Skip testing phase for frontend tickets (enabled by default)
|
|
404
|
-
--url=<URL> Base URL for testing (default: http://localhost:3000)
|
|
405
|
-
--headless Run tests in headless mode (invisible browser)
|
|
406
|
-
--verbose Enable verbose output for tests
|
|
407
|
-
--playwright Use Playwright MCP for tests (requires MCP server running)
|
|
408
|
-
--trace Enable trace recording for Playwright MCP tests
|
|
409
|
-
|
|
410
|
-
Examples:
|
|
411
|
-
git checkout -b feat/implement-tickets # Create feature branch first
|
|
412
|
-
kosuke build # Process and auto-commit all tickets
|
|
413
|
-
gh pr create # Create PR manually
|
|
414
|
-
|
|
415
|
-
kosuke build --ask-commit # Ask before committing each ticket
|
|
416
|
-
kosuke build --ask-confirm # Ask before processing each ticket
|
|
417
|
-
kosuke build --ask-commit --ask-confirm # Fully interactive mode
|
|
418
|
-
kosuke build --reset # Reset all tickets and start from scratch
|
|
419
|
-
kosuke build --no-review --no-test # Skip review and testing (fastest)
|
|
420
|
-
kosuke build --headless # Run tests in headless mode
|
|
421
|
-
kosuke build --verbose # Enable verbose test output
|
|
422
|
-
kosuke build --playwright # Use Playwright MCP for tests
|
|
423
|
-
kosuke build --playwright --trace # Use Playwright MCP with video/screenshots
|
|
424
|
-
kosuke build --tickets=custom.json # Use custom tickets file
|
|
425
|
-
kosuke build --directory=./my-project # Run build in specific directory
|
|
426
|
-
kosuke build --db-url=postgres://user:pass@host:5432/db # Custom DB
|
|
427
|
-
|
|
428
|
-
Note: If a ticket fails, fix the issue and run build again to resume
|
|
429
|
-
|
|
430
|
-
migrate [options]
|
|
431
|
-
Apply database migrations and validate schema changes
|
|
432
|
-
Uses Claude Code Agent to run migrations, seed database, and validate
|
|
433
|
-
|
|
434
|
-
Note: This command does NOT generate migrations (ship handles that)
|
|
435
|
-
Automatically called by build command after SCHEMA tickets
|
|
436
|
-
|
|
437
|
-
Options:
|
|
438
|
-
--directory=<path> Directory to run migrations in (default: current directory)
|
|
439
|
-
--dir=<path> Alias for --directory
|
|
440
|
-
--db-url=<url> Database URL (default: postgres://postgres:postgres@localhost:5432/postgres)
|
|
441
|
-
|
|
442
|
-
Examples:
|
|
443
|
-
kosuke migrate # Apply migrations in current directory
|
|
444
|
-
kosuke migrate --directory=./my-app # Apply in specific project
|
|
445
|
-
kosuke migrate --db-url=postgres://... # Custom database URL
|
|
446
|
-
|
|
447
|
-
review
|
|
448
|
-
Review current git diff against CLAUDE.md rules
|
|
449
|
-
Identifies and fixes compliance issues in uncommitted changes
|
|
450
|
-
Note: Changes applied locally only (no --pr support)
|
|
451
|
-
|
|
452
|
-
Examples:
|
|
453
|
-
kosuke review # Review uncommitted changes
|
|
454
|
-
|
|
455
|
-
test --prompt="..." [options]
|
|
456
|
-
Run atomic web E2E tests (no fixing, no retries)
|
|
457
|
-
|
|
458
|
-
Test modes:
|
|
459
|
-
Uses Playwright MCP with Claude AI for browser automation.
|
|
460
|
-
|
|
461
|
-
For iterative test+fix workflow, use: kosuke build
|
|
462
|
-
|
|
463
|
-
Options:
|
|
464
|
-
--prompt="..." Test instructions (required)
|
|
465
|
-
--url=<URL> Base URL for web tests (default: http://localhost:3000)
|
|
466
|
-
--headless Run browser in headless mode (invisible)
|
|
467
|
-
--verbose Enable verbose output (shows Claude reasoning and tool usage)
|
|
468
|
-
--trace Enable trace recording (saves video/screenshots for debugging)
|
|
469
|
-
|
|
470
|
-
Examples:
|
|
471
|
-
kosuke test --prompt="Test user login flow"
|
|
472
|
-
kosuke test --prompt="Test task creation" --url=http://localhost:4000
|
|
473
|
-
kosuke test --prompt="Test checkout flow" --verbose --headless
|
|
474
|
-
kosuke test --prompt="..." --trace # Save video/screenshots
|
|
475
|
-
npx playwright show-trace ${TRACES_DIR}/.../trace.trace
|
|
476
|
-
|
|
477
|
-
Playwright MCP:
|
|
478
|
-
- Uses Claude SDK with Playwright MCP tools
|
|
479
|
-
- Always uses chromium browser
|
|
480
|
-
- Single atomic execution (no automatic retries)
|
|
481
|
-
- Detailed tool usage tracking (navigations, clicks, types, extracts)
|
|
482
|
-
- Separate cost breakdown for text generation vs. tool calls
|
|
483
|
-
- Optional trace recording with embedded video playback
|
|
484
|
-
|
|
485
|
-
Note: This command is mainly used programmatically from kosuke build.
|
|
486
|
-
For ticket-based testing with retries, use: kosuke build
|
|
487
|
-
|
|
488
|
-
GLOBAL OPTIONS:
|
|
489
|
-
|
|
490
|
-
--no-logs Disable logging to Kosuke API (useful when kosuke-cli is used as library)
|
|
491
|
-
By default, logging is enabled if KOSUKE_BASE_URL, KOSUKE_API_KEY,
|
|
492
|
-
and KOSUKE_PROJECT_ID environment variables are set.
|
|
493
|
-
This flag can be used with any command to prevent API logging calls.
|
|
494
|
-
|
|
495
|
-
WORKFLOW:
|
|
496
|
-
|
|
497
|
-
By default, all commands apply changes locally without git operations.
|
|
498
|
-
Use the --pr flag to create a pull request with the changes.
|
|
499
|
-
|
|
500
|
-
ENVIRONMENT VARIABLES:
|
|
501
|
-
|
|
502
|
-
ANTHROPIC_API_KEY Required for Claude API access
|
|
503
|
-
GITHUB_TOKEN Required when using --pr flag
|
|
504
|
-
KOSUKE_BASE_URL Optional: Base URL for Kosuke API logging
|
|
505
|
-
KOSUKE_API_KEY Optional: API key for Kosuke API logging
|
|
506
|
-
KOSUKE_PROJECT_ID Optional: Project ID for Kosuke API logging
|
|
507
|
-
|
|
508
|
-
CONFIGURATION:
|
|
509
|
-
|
|
510
|
-
.kosukeignore Exclude files/directories from analysis
|
|
511
|
-
(same syntax as .gitignore)
|
|
512
|
-
`);
|
|
513
|
-
}
|
|
514
|
-
main().catch((error) => {
|
|
515
|
-
console.error('Fatal error:', error);
|
|
516
|
-
process.exit(1);
|
|
2
|
+
import { run } from './program.js';
|
|
3
|
+
run(process.argv).catch((error) => {
|
|
4
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5
|
+
process.stderr.write(`kosuke: ${message}\n`);
|
|
6
|
+
process.exitCode = 1;
|
|
517
7
|
});
|
|
518
|
-
//# sourceMappingURL=index.js.map
|
package/dist/program.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { attachAuthCommands } from './commands/auth.js';
|
|
3
|
+
import { operations } from './generated/commands/index.js';
|
|
4
|
+
import { attachOperation } from './runtime/attach.js';
|
|
5
|
+
import { createRuntime, ExitSignal } from './runtime/runtime.js';
|
|
6
|
+
import { version } from './runtime/version.js';
|
|
7
|
+
/**
|
|
8
|
+
* The command tree: `auth` by hand, everything else from the generated
|
|
9
|
+
* descriptors. Global flags are read before any subcommand runs, so the
|
|
10
|
+
* runtime the subcommands share is built once, from them.
|
|
11
|
+
*/
|
|
12
|
+
export function createProgram(options = {}) {
|
|
13
|
+
const program = new Command('kosuke')
|
|
14
|
+
.description('Drive the Kosuke platform from your own machine.')
|
|
15
|
+
.version(version)
|
|
16
|
+
.option('--api-key <token>', 'Auth token; overrides KOSUKE_API_KEY and the stored one.')
|
|
17
|
+
.option('--api-url <url>', 'Platform URL; overrides KOSUKE_API_URL. Default https://app.kosuke.ai.')
|
|
18
|
+
// commander's default is kept: a program option is read wherever it
|
|
19
|
+
// appears, so `kosuke projects list --api-key X` works as the README shows.
|
|
20
|
+
.showHelpAfterError('(add --help for usage)')
|
|
21
|
+
.configureHelp({ sortSubcommands: true });
|
|
22
|
+
// Built lazily, on the first use, so `--help` and `--version` never touch
|
|
23
|
+
// the credentials file.
|
|
24
|
+
let runtime = null;
|
|
25
|
+
const runtimeFor = () => (runtime ??= (options.runtime ?? ((flags) => createRuntime({ ...options.process, flags })))(program.opts()));
|
|
26
|
+
const lazy = {
|
|
27
|
+
credentials: () => runtimeFor().credentials(),
|
|
28
|
+
client: (o) => runtimeFor().client(o),
|
|
29
|
+
output: (outcome) => runtimeFor().output(outcome),
|
|
30
|
+
};
|
|
31
|
+
attachAuthCommands(program, lazy, options.auth);
|
|
32
|
+
for (const operation of operations)
|
|
33
|
+
attachOperation(program, operation, lazy);
|
|
34
|
+
return program;
|
|
35
|
+
}
|
|
36
|
+
/** Run to completion; an ExitSignal has already reported and set the exit code. */
|
|
37
|
+
export async function run(argv, options) {
|
|
38
|
+
try {
|
|
39
|
+
await createProgram(options).parseAsync([...argv]);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof ExitSignal)
|
|
43
|
+
return;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|