@braingrid/cli 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE.md +15 -0
  3. package/README.md +2 -5
  4. package/dist/cli.js +265 -317
  5. package/dist/cli.js.map +1 -1
  6. package/dist/handlers/auth.handlers.d.ts +1 -7
  7. package/dist/handlers/auth.handlers.d.ts.map +1 -1
  8. package/dist/handlers/auth.handlers.js +29 -79
  9. package/dist/handlers/auth.handlers.js.map +1 -1
  10. package/dist/handlers/index.d.ts +0 -1
  11. package/dist/handlers/index.d.ts.map +1 -1
  12. package/dist/handlers/index.js +0 -1
  13. package/dist/handlers/index.js.map +1 -1
  14. package/package.json +27 -7
  15. package/dist/handlers/agent.handlers.d.ts +0 -12
  16. package/dist/handlers/agent.handlers.d.ts.map +0 -1
  17. package/dist/handlers/agent.handlers.js +0 -130
  18. package/dist/handlers/agent.handlers.js.map +0 -1
  19. package/dist/rpc/registry.d.ts +0 -97
  20. package/dist/rpc/registry.d.ts.map +0 -1
  21. package/dist/rpc/registry.js +0 -119
  22. package/dist/rpc/registry.js.map +0 -1
  23. package/dist/rpc/server.d.ts +0 -78
  24. package/dist/rpc/server.d.ts.map +0 -1
  25. package/dist/rpc/server.js +0 -437
  26. package/dist/rpc/server.js.map +0 -1
  27. package/dist/rpc/transport.d.ts +0 -84
  28. package/dist/rpc/transport.d.ts.map +0 -1
  29. package/dist/rpc/transport.js +0 -296
  30. package/dist/rpc/transport.js.map +0 -1
  31. package/dist/services/__mocks__/utils.d.ts +0 -16
  32. package/dist/services/__mocks__/utils.d.ts.map +0 -1
  33. package/dist/services/__mocks__/utils.js +0 -21
  34. package/dist/services/__mocks__/utils.js.map +0 -1
  35. package/dist/services/agent-service.d.ts +0 -29
  36. package/dist/services/agent-service.d.ts.map +0 -1
  37. package/dist/services/agent-service.js +0 -273
  38. package/dist/services/agent-service.js.map +0 -1
package/dist/cli.js CHANGED
@@ -2,324 +2,272 @@
2
2
  import { Command } from 'commander';
3
3
  import { createRequire } from 'module';
4
4
  import * as handlers from './handlers/index.js';
5
- import { JsonRpcServer } from './rpc/server.js';
6
5
  const require = createRequire(import.meta.url);
7
6
  const packageJson = require('../package.json');
8
7
  const program = new Command();
9
- // Check for --rpc flag early
10
- const isRpcMode = process.argv.includes('--rpc');
11
- // If in RPC mode, start the JSON-RPC server
12
- if (isRpcMode) {
13
- const server = new JsonRpcServer();
14
- server.start();
15
- // Keep the process running
16
- process.on('SIGINT', async () => {
17
- await server.stop();
18
- process.exit(0);
19
- });
20
- process.on('SIGTERM', async () => {
21
- await server.stop();
22
- process.exit(0);
23
- });
24
- }
25
- else {
26
- // Traditional CLI mode
27
- program
28
- .name('braingrid')
29
- .description('BrainGrid CLI - Manage projects, requirements, and tasks')
30
- .version(packageJson.version, '-v, --version', 'output the current version')
31
- .option('--rpc', 'Start in JSON-RPC server mode')
32
- .showHelpAfterError('(use --help for usage)');
33
- // ============================================
34
- // AUTH COMMANDS
35
- // ============================================
36
- program
37
- .command('login')
38
- .description('Authenticate with BrainGrid')
39
- .action(async () => {
40
- const result = await handlers.handleLogin();
41
- console.log(result.message);
42
- if (!result.success) {
43
- process.exit(1);
44
- }
45
- });
46
- program
47
- .command('logout')
48
- .description('Sign out from BrainGrid')
49
- .action(async () => {
50
- const result = await handlers.handleLogout();
51
- console.log(result.message);
52
- if (!result.success) {
53
- process.exit(1);
54
- }
55
- });
56
- program
57
- .command('whoami')
58
- .description('Show current user information')
59
- .action(async () => {
60
- const result = await handlers.handleWhoami();
61
- console.log(result.message);
62
- if (!result.success) {
63
- process.exit(1);
64
- }
65
- });
66
- program
67
- .command('status')
68
- .description('Show CLI status (authentication, git, config)')
69
- .action(async () => {
70
- const result = await handlers.handleStatus();
71
- console.log(result.message);
72
- if (!result.success) {
73
- process.exit(1);
74
- }
75
- });
76
- program
77
- .command('init')
78
- .description('Initialize BrainGrid project in current repository')
79
- .option('--project <id>', 'project ID to initialize with (auto-detects if not provided)')
80
- .option('--force', 'skip confirmation and force reinitialization if already initialized')
81
- .action(async (opts) => {
82
- const result = await handlers.handleInit(opts);
83
- console.log(result.message);
84
- if (!result.success) {
85
- process.exit(1);
86
- }
87
- });
88
- program
89
- .command('update')
90
- .description('Update BrainGrid CLI to the latest version')
91
- .option('--check', 'check for updates without installing')
92
- .action(async (opts) => {
93
- const result = await handlers.handleUpdate(opts);
94
- console.log(result.message);
95
- if (!result.success) {
96
- process.exit(1);
97
- }
98
- });
99
- // ============================================
100
- // PROJECT RESOURCE COMMANDS
101
- // ============================================
102
- const project = program.command('project').description('Manage projects');
103
- project
104
- .command('list')
105
- .description('List all projects')
106
- .option('--format <format>', 'output format (table or json)', 'table')
107
- .option('--page <page>', 'page number for pagination', '1')
108
- .option('--limit <limit>', 'number of projects per page', '20')
109
- .action(async (opts) => {
110
- const result = await handlers.handleProjectList(opts);
111
- console.log(result.message);
112
- if (!result.success) {
113
- process.exit(1);
114
- }
115
- });
116
- project
117
- .command('show [id]')
118
- .description('Show current or specified project (or use --repository to list by repo)')
119
- .option('--repository, --repo <owner/name>', 'list projects for repository (e.g., microsoft/vscode)')
120
- .option('--format <format>', 'output format (table or json)', 'table')
121
- .option('--page <page>', 'page number for pagination', '1')
122
- .option('--limit <limit>', 'number of projects per page', '20')
123
- .action(async (id, opts) => {
124
- const result = await handlers.handleProjectShow({ id, ...opts });
125
- console.log(result.message);
126
- if (!result.success) {
127
- process.exit(1);
128
- }
129
- });
130
- project
131
- .command('create')
132
- .description('Create a new project')
133
- .requiredOption('--name <name>', 'project name')
134
- .option('--description <description>', 'project description')
135
- .action(async (opts) => {
136
- const result = await handlers.handleProjectCreate(opts);
137
- console.log(result.message);
138
- if (!result.success) {
139
- process.exit(1);
140
- }
141
- });
142
- project
143
- .command('update <id>')
144
- .description('Update project information')
145
- .option('--name <name>', 'new project name')
146
- .option('--description <description>', 'new project description')
147
- .action(async (id, opts) => {
148
- const result = await handlers.handleProjectUpdate(id, opts);
149
- console.log(result.message);
150
- if (!result.success) {
151
- process.exit(1);
152
- }
153
- });
154
- project
155
- .command('delete <id>')
156
- .description('Delete a project')
157
- .option('--force', 'force deletion without confirmation')
158
- .action(async (id, opts) => {
159
- const result = await handlers.handleProjectDelete(id, opts);
160
- console.log(result.message);
161
- if (!result.success) {
162
- process.exit(1);
163
- }
164
- });
165
- // ============================================
166
- // REQUIREMENT RESOURCE COMMANDS
167
- // ============================================
168
- const requirement = program.command('requirement').description('Manage requirements');
169
- requirement
170
- .command('list')
171
- .description('List requirements for a project')
172
- .option('-p, --project <id>', 'project ID (auto-detects from .braingrid/project.json if not provided)')
173
- .option('--status <status>', 'filter by status (IDEA, PLANNED, IN_PROGRESS, REVIEW, COMPLETED, CANCELLED)')
174
- .option('--format <format>', 'output format (table or json)', 'table')
175
- .option('--page <page>', 'page number for pagination', '1')
176
- .option('--limit <limit>', 'number of requirements per page', '20')
177
- .action(async (opts) => {
178
- const result = await handlers.handleRequirementList(opts);
179
- console.log(result.message);
180
- if (!result.success) {
181
- process.exit(1);
182
- }
183
- });
184
- requirement
185
- .command('show <id>')
186
- .description('Show requirement details')
187
- .action(async (id) => {
188
- const result = await handlers.handleRequirementShow(id);
189
- console.log(result.message);
190
- if (!result.success) {
191
- process.exit(1);
192
- }
193
- });
194
- requirement
195
- .command('create')
196
- .description('Create a new requirement')
197
- .option('-p, --project <id>', 'project ID (auto-detects from .braingrid/project.json if not provided)')
198
- .requiredOption('--prompt <prompt>', 'requirement prompt/description')
199
- .option('--repositories <repos>', 'comma-separated list of repositories (owner/repo)')
200
- .action(async (opts) => {
201
- const result = await handlers.handleRequirementCreate(opts);
202
- console.log(result.message);
203
- if (!result.success) {
204
- process.exit(1);
205
- }
206
- });
207
- requirement
208
- .command('update <id>')
209
- .description('Update requirement information')
210
- .option('--status <status>', 'new status (IDEA, PLANNED, IN_PROGRESS, REVIEW, COMPLETED, CANCELLED)')
211
- .option('--name <name>', 'new requirement name')
212
- .action(async (id, opts) => {
213
- const result = await handlers.handleRequirementUpdate(id, opts);
214
- console.log(result.message);
215
- if (!result.success) {
216
- process.exit(1);
217
- }
218
- });
219
- requirement
220
- .command('delete <id>')
221
- .description('Delete a requirement')
222
- .option('--force', 'force deletion without confirmation')
223
- .action(async (id, opts) => {
224
- const result = await handlers.handleRequirementDelete(id, opts);
225
- console.log(result.message);
226
- if (!result.success) {
227
- process.exit(1);
228
- }
229
- });
230
- // ============================================
231
- // TASK RESOURCE COMMANDS
232
- // ============================================
233
- const task = program.command('task').description('Manage tasks');
234
- task
235
- .command('list')
236
- .description('List tasks for a requirement')
237
- .option('-r, --requirement <id>', 'requirement ID (REQ-456 or PROJ-123/REQ-456, auto-detects project if initialized)')
238
- .option('--format <format>', 'output format (table or json)', 'table')
239
- .action(async (opts) => {
240
- const result = await handlers.handleTaskList(opts);
241
- console.log(result.message);
242
- if (!result.success) {
243
- process.exit(1);
244
- }
245
- });
246
- task
247
- .command('show <id>')
248
- .description('Show task details')
249
- .action(async (id) => {
250
- const result = await handlers.handleTaskShow(id);
251
- console.log(result.message);
252
- if (!result.success) {
253
- process.exit(1);
254
- }
255
- });
256
- task
257
- .command('create')
258
- .description('Create a new task')
259
- .option('-r, --requirement <id>', 'requirement ID (REQ-456 or PROJ-123/REQ-456, auto-detects project if initialized)')
260
- .requiredOption('--title <title>', 'task title')
261
- .option('--content <content>', 'task content/description')
262
- .action(async (opts) => {
263
- const result = await handlers.handleTaskCreate(opts);
264
- console.log(result.message);
265
- if (!result.success) {
266
- process.exit(1);
267
- }
268
- });
269
- task
270
- .command('update <id>')
271
- .description('Update task information')
272
- .option('--status <status>', 'new status (PLANNED, IN_PROGRESS, COMPLETED, CANCELLED)')
273
- .option('--title <title>', 'new task title')
274
- .action(async (id, opts) => {
275
- const result = await handlers.handleTaskUpdate(id, opts);
276
- console.log(result.message);
277
- if (!result.success) {
278
- process.exit(1);
279
- }
280
- });
281
- task
282
- .command('delete <id>')
283
- .description('Delete a task')
284
- .option('--force', 'force deletion without confirmation')
285
- .action(async (id, opts) => {
286
- const result = await handlers.handleTaskDelete(id, opts);
287
- console.log(result.message);
288
- if (!result.success) {
289
- process.exit(1);
290
- }
291
- });
292
- // ============================================
293
- // AGENT COMMANDS
294
- // ============================================
295
- const agent = program.command('agent').description('Interact with AI agent');
296
- agent
297
- .command('chat <message>')
298
- .description('Start or continue a conversation with the AI agent')
299
- .option('-p, --project <id>', 'project ID (auto-detects from .braingrid/project.json if not provided)')
300
- .option('--conversation-id <id>', 'conversation ID to continue existing conversation')
301
- .option('--requirement <id>', 'requirement ID for context (overrides active context)')
302
- .option('--repositories <repos>', 'comma-separated list of repositories (owner/repo)')
303
- .action(async (message, opts) => {
304
- const result = await handlers.handleAgentConversationStream({
305
- project: opts.project || '',
306
- message,
307
- conversationId: opts.conversationId,
308
- context: {
309
- requirementId: opts.requirement,
310
- repositories: opts.repositories
311
- ? opts.repositories
312
- .split(',')
313
- .map((r) => r.trim())
314
- .filter(Boolean)
315
- : undefined,
316
- },
317
- });
318
- console.log(result.message);
319
- if (!result.success) {
320
- process.exit(1);
321
- }
322
- });
323
- program.parse();
324
- }
8
+ program
9
+ .name('braingrid')
10
+ .description('BrainGrid CLI - Manage projects, requirements, and tasks')
11
+ .version(packageJson.version, '-v, --version', 'output the current version')
12
+ .showHelpAfterError('(use --help for usage)');
13
+ // ============================================
14
+ // AUTH COMMANDS
15
+ // ============================================
16
+ program
17
+ .command('login')
18
+ .description('Authenticate with BrainGrid')
19
+ .action(async () => {
20
+ const result = await handlers.handleLogin();
21
+ console.log(result.message);
22
+ if (!result.success) {
23
+ process.exit(1);
24
+ }
25
+ });
26
+ program
27
+ .command('logout')
28
+ .description('Sign out from BrainGrid')
29
+ .action(async () => {
30
+ const result = await handlers.handleLogout();
31
+ console.log(result.message);
32
+ if (!result.success) {
33
+ process.exit(1);
34
+ }
35
+ });
36
+ program
37
+ .command('whoami')
38
+ .description('Show current user information')
39
+ .action(async () => {
40
+ const result = await handlers.handleWhoami();
41
+ console.log(result.message);
42
+ if (!result.success) {
43
+ process.exit(1);
44
+ }
45
+ });
46
+ program
47
+ .command('status')
48
+ .description('Show CLI status (authentication, git, config)')
49
+ .action(async () => {
50
+ const result = await handlers.handleStatus();
51
+ console.log(result.message);
52
+ if (!result.success) {
53
+ process.exit(1);
54
+ }
55
+ });
56
+ program
57
+ .command('init')
58
+ .description('Initialize BrainGrid project in current repository')
59
+ .option('--project <id>', 'project ID to initialize with (auto-detects if not provided)')
60
+ .option('--force', 'skip confirmation and force reinitialization if already initialized')
61
+ .action(async (opts) => {
62
+ const result = await handlers.handleInit(opts);
63
+ console.log(result.message);
64
+ if (!result.success) {
65
+ process.exit(1);
66
+ }
67
+ });
68
+ program
69
+ .command('update')
70
+ .description('Update BrainGrid CLI to the latest version')
71
+ .option('--check', 'check for updates without installing')
72
+ .action(async (opts) => {
73
+ const result = await handlers.handleUpdate(opts);
74
+ console.log(result.message);
75
+ if (!result.success) {
76
+ process.exit(1);
77
+ }
78
+ });
79
+ // ============================================
80
+ // PROJECT RESOURCE COMMANDS
81
+ // ============================================
82
+ const project = program.command('project').description('Manage projects');
83
+ project
84
+ .command('list')
85
+ .description('List all projects')
86
+ .option('--format <format>', 'output format (table or json)', 'table')
87
+ .option('--page <page>', 'page number for pagination', '1')
88
+ .option('--limit <limit>', 'number of projects per page', '20')
89
+ .action(async (opts) => {
90
+ const result = await handlers.handleProjectList(opts);
91
+ console.log(result.message);
92
+ if (!result.success) {
93
+ process.exit(1);
94
+ }
95
+ });
96
+ project
97
+ .command('show [id]')
98
+ .description('Show current or specified project (or use --repository to list by repo)')
99
+ .option('--repository, --repo <owner/name>', 'list projects for repository (e.g., microsoft/vscode)')
100
+ .option('--format <format>', 'output format (table or json)', 'table')
101
+ .option('--page <page>', 'page number for pagination', '1')
102
+ .option('--limit <limit>', 'number of projects per page', '20')
103
+ .action(async (id, opts) => {
104
+ const result = await handlers.handleProjectShow({ id, ...opts });
105
+ console.log(result.message);
106
+ if (!result.success) {
107
+ process.exit(1);
108
+ }
109
+ });
110
+ project
111
+ .command('create')
112
+ .description('Create a new project')
113
+ .requiredOption('--name <name>', 'project name')
114
+ .option('--description <description>', 'project description')
115
+ .action(async (opts) => {
116
+ const result = await handlers.handleProjectCreate(opts);
117
+ console.log(result.message);
118
+ if (!result.success) {
119
+ process.exit(1);
120
+ }
121
+ });
122
+ project
123
+ .command('update <id>')
124
+ .description('Update project information')
125
+ .option('--name <name>', 'new project name')
126
+ .option('--description <description>', 'new project description')
127
+ .action(async (id, opts) => {
128
+ const result = await handlers.handleProjectUpdate(id, opts);
129
+ console.log(result.message);
130
+ if (!result.success) {
131
+ process.exit(1);
132
+ }
133
+ });
134
+ project
135
+ .command('delete <id>')
136
+ .description('Delete a project')
137
+ .option('--force', 'force deletion without confirmation')
138
+ .action(async (id, opts) => {
139
+ const result = await handlers.handleProjectDelete(id, opts);
140
+ console.log(result.message);
141
+ if (!result.success) {
142
+ process.exit(1);
143
+ }
144
+ });
145
+ // ============================================
146
+ // REQUIREMENT RESOURCE COMMANDS
147
+ // ============================================
148
+ const requirement = program.command('requirement').description('Manage requirements');
149
+ requirement
150
+ .command('list')
151
+ .description('List requirements for a project')
152
+ .option('-p, --project <id>', 'project ID (auto-detects from .braingrid/project.json if not provided)')
153
+ .option('--status <status>', 'filter by status (IDEA, PLANNED, IN_PROGRESS, REVIEW, COMPLETED, CANCELLED)')
154
+ .option('--format <format>', 'output format (table or json)', 'table')
155
+ .option('--page <page>', 'page number for pagination', '1')
156
+ .option('--limit <limit>', 'number of requirements per page', '20')
157
+ .action(async (opts) => {
158
+ const result = await handlers.handleRequirementList(opts);
159
+ console.log(result.message);
160
+ if (!result.success) {
161
+ process.exit(1);
162
+ }
163
+ });
164
+ requirement
165
+ .command('show <id>')
166
+ .description('Show requirement details')
167
+ .action(async (id) => {
168
+ const result = await handlers.handleRequirementShow(id);
169
+ console.log(result.message);
170
+ if (!result.success) {
171
+ process.exit(1);
172
+ }
173
+ });
174
+ requirement
175
+ .command('create')
176
+ .description('Create a new requirement')
177
+ .option('-p, --project <id>', 'project ID (auto-detects from .braingrid/project.json if not provided)')
178
+ .requiredOption('--prompt <prompt>', 'requirement prompt/description')
179
+ .option('--repositories <repos>', 'comma-separated list of repositories (owner/repo)')
180
+ .action(async (opts) => {
181
+ const result = await handlers.handleRequirementCreate(opts);
182
+ console.log(result.message);
183
+ if (!result.success) {
184
+ process.exit(1);
185
+ }
186
+ });
187
+ requirement
188
+ .command('update <id>')
189
+ .description('Update requirement information')
190
+ .option('--status <status>', 'new status (IDEA, PLANNED, IN_PROGRESS, REVIEW, COMPLETED, CANCELLED)')
191
+ .option('--name <name>', 'new requirement name')
192
+ .action(async (id, opts) => {
193
+ const result = await handlers.handleRequirementUpdate(id, opts);
194
+ console.log(result.message);
195
+ if (!result.success) {
196
+ process.exit(1);
197
+ }
198
+ });
199
+ requirement
200
+ .command('delete <id>')
201
+ .description('Delete a requirement')
202
+ .option('--force', 'force deletion without confirmation')
203
+ .action(async (id, opts) => {
204
+ const result = await handlers.handleRequirementDelete(id, opts);
205
+ console.log(result.message);
206
+ if (!result.success) {
207
+ process.exit(1);
208
+ }
209
+ });
210
+ // ============================================
211
+ // TASK RESOURCE COMMANDS
212
+ // ============================================
213
+ const task = program.command('task').description('Manage tasks');
214
+ task
215
+ .command('list')
216
+ .description('List tasks for a requirement')
217
+ .option('-r, --requirement <id>', 'requirement ID (REQ-456 or PROJ-123/REQ-456, auto-detects project if initialized)')
218
+ .option('--format <format>', 'output format (table or json)', 'table')
219
+ .action(async (opts) => {
220
+ const result = await handlers.handleTaskList(opts);
221
+ console.log(result.message);
222
+ if (!result.success) {
223
+ process.exit(1);
224
+ }
225
+ });
226
+ task
227
+ .command('show <id>')
228
+ .description('Show task details')
229
+ .action(async (id) => {
230
+ const result = await handlers.handleTaskShow(id);
231
+ console.log(result.message);
232
+ if (!result.success) {
233
+ process.exit(1);
234
+ }
235
+ });
236
+ task
237
+ .command('create')
238
+ .description('Create a new task')
239
+ .option('-r, --requirement <id>', 'requirement ID (REQ-456 or PROJ-123/REQ-456, auto-detects project if initialized)')
240
+ .requiredOption('--title <title>', 'task title')
241
+ .option('--content <content>', 'task content/description')
242
+ .action(async (opts) => {
243
+ const result = await handlers.handleTaskCreate(opts);
244
+ console.log(result.message);
245
+ if (!result.success) {
246
+ process.exit(1);
247
+ }
248
+ });
249
+ task
250
+ .command('update <id>')
251
+ .description('Update task information')
252
+ .option('--status <status>', 'new status (PLANNED, IN_PROGRESS, COMPLETED, CANCELLED)')
253
+ .option('--title <title>', 'new task title')
254
+ .action(async (id, opts) => {
255
+ const result = await handlers.handleTaskUpdate(id, opts);
256
+ console.log(result.message);
257
+ if (!result.success) {
258
+ process.exit(1);
259
+ }
260
+ });
261
+ task
262
+ .command('delete <id>')
263
+ .description('Delete a task')
264
+ .option('--force', 'force deletion without confirmation')
265
+ .action(async (id, opts) => {
266
+ const result = await handlers.handleTaskDelete(id, opts);
267
+ console.log(result.message);
268
+ if (!result.success) {
269
+ process.exit(1);
270
+ }
271
+ });
272
+ program.parse();
325
273
  //# sourceMappingURL=cli.js.map