@bernierllc/braingrid-cli-wrapper 0.1.1

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 (74) hide show
  1. package/.eslintrc.cjs +29 -0
  2. package/README.md +401 -0
  3. package/coverage/base.css +224 -0
  4. package/coverage/block-navigation.js +87 -0
  5. package/coverage/favicon.png +0 -0
  6. package/coverage/index.html +131 -0
  7. package/coverage/lcov-report/base.css +224 -0
  8. package/coverage/lcov-report/block-navigation.js +87 -0
  9. package/coverage/lcov-report/favicon.png +0 -0
  10. package/coverage/lcov-report/index.html +131 -0
  11. package/coverage/lcov-report/prettify.css +1 -0
  12. package/coverage/lcov-report/prettify.js +2 -0
  13. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  14. package/coverage/lcov-report/sorter.js +210 -0
  15. package/coverage/lcov-report/src/cli.ts.html +298 -0
  16. package/coverage/lcov-report/src/commands/createIdea.ts.html +193 -0
  17. package/coverage/lcov-report/src/commands/createTask.ts.html +235 -0
  18. package/coverage/lcov-report/src/commands/index.html +176 -0
  19. package/coverage/lcov-report/src/commands/listProjects.ts.html +160 -0
  20. package/coverage/lcov-report/src/commands/listTasks.ts.html +226 -0
  21. package/coverage/lcov-report/src/commands/updateTaskStatus.ts.html +205 -0
  22. package/coverage/lcov-report/src/index.html +146 -0
  23. package/coverage/lcov-report/src/index.ts.html +172 -0
  24. package/coverage/lcov-report/src/models.ts.html +364 -0
  25. package/coverage/lcov.info +240 -0
  26. package/coverage/prettify.css +1 -0
  27. package/coverage/prettify.js +2 -0
  28. package/coverage/sort-arrow-sprite.png +0 -0
  29. package/coverage/sorter.js +210 -0
  30. package/coverage/src/cli.ts.html +298 -0
  31. package/coverage/src/commands/createIdea.ts.html +193 -0
  32. package/coverage/src/commands/createTask.ts.html +235 -0
  33. package/coverage/src/commands/index.html +176 -0
  34. package/coverage/src/commands/listProjects.ts.html +160 -0
  35. package/coverage/src/commands/listTasks.ts.html +226 -0
  36. package/coverage/src/commands/updateTaskStatus.ts.html +205 -0
  37. package/coverage/src/index.html +146 -0
  38. package/coverage/src/index.ts.html +172 -0
  39. package/coverage/src/models.ts.html +364 -0
  40. package/dist/cli.d.ts +7 -0
  41. package/dist/cli.js +53 -0
  42. package/dist/commands/createIdea.d.ts +5 -0
  43. package/dist/commands/createIdea.js +29 -0
  44. package/dist/commands/createTask.d.ts +11 -0
  45. package/dist/commands/createTask.js +34 -0
  46. package/dist/commands/listProjects.d.ts +5 -0
  47. package/dist/commands/listProjects.js +24 -0
  48. package/dist/commands/listTasks.d.ts +10 -0
  49. package/dist/commands/listTasks.js +35 -0
  50. package/dist/commands/updateTaskStatus.d.ts +10 -0
  51. package/dist/commands/updateTaskStatus.js +27 -0
  52. package/dist/index.d.ts +6 -0
  53. package/dist/index.js +28 -0
  54. package/dist/models.d.ts +89 -0
  55. package/dist/models.js +74 -0
  56. package/jest.config.cjs +22 -0
  57. package/package.json +46 -0
  58. package/src/__tests__/execa-mock-validation.test.ts +34 -0
  59. package/src/cli.test.ts +86 -0
  60. package/src/cli.ts +71 -0
  61. package/src/commands/createIdea.test.ts +77 -0
  62. package/src/commands/createIdea.ts +36 -0
  63. package/src/commands/createTask.test.ts +100 -0
  64. package/src/commands/createTask.ts +50 -0
  65. package/src/commands/listProjects.test.ts +72 -0
  66. package/src/commands/listProjects.ts +25 -0
  67. package/src/commands/listTasks.test.ts +183 -0
  68. package/src/commands/listTasks.ts +47 -0
  69. package/src/commands/updateTaskStatus.test.ts +96 -0
  70. package/src/commands/updateTaskStatus.ts +40 -0
  71. package/src/index.ts +29 -0
  72. package/src/models.test.ts +197 -0
  73. package/src/models.ts +93 -0
  74. package/tsconfig.json +18 -0
@@ -0,0 +1,197 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+ import {
9
+ BrainGridProjectSchema,
10
+ BrainGridRequirementSchema,
11
+ BrainGridTaskSchema,
12
+ RequirementStatus,
13
+ TaskStatus,
14
+ BrainGridCliError
15
+ } from './models';
16
+
17
+ describe('BrainGrid Schemas', () => {
18
+ describe('BrainGridProjectSchema', () => {
19
+ it('should validate a valid project', () => {
20
+ const validProject = {
21
+ id: 'proj-123',
22
+ name: 'Test Project',
23
+ description: 'A test project'
24
+ };
25
+
26
+ const result = BrainGridProjectSchema.safeParse(validProject);
27
+ expect(result.success).toBe(true);
28
+ if (result.success) {
29
+ expect(result.data.id).toBe('proj-123');
30
+ expect(result.data.name).toBe('Test Project');
31
+ }
32
+ });
33
+
34
+ it('should reject invalid project', () => {
35
+ const invalidProject = {
36
+ id: 123, // Should be string
37
+ name: 'Test'
38
+ };
39
+
40
+ const result = BrainGridProjectSchema.safeParse(invalidProject);
41
+ expect(result.success).toBe(false);
42
+ });
43
+ });
44
+
45
+ describe('BrainGridRequirementSchema', () => {
46
+ it('should validate a valid requirement', () => {
47
+ const validReq = {
48
+ id: 'req-456',
49
+ projectId: 'proj-123',
50
+ title: 'Add authentication',
51
+ status: 'IDEA' as RequirementStatus,
52
+ description: 'Add OAuth2 auth'
53
+ };
54
+
55
+ const result = BrainGridRequirementSchema.safeParse(validReq);
56
+ expect(result.success).toBe(true);
57
+ });
58
+
59
+ it('should accept all valid statuses', () => {
60
+ const statuses: RequirementStatus[] = ['IDEA', 'PLANNED', 'IN_PROGRESS', 'COMPLETED', 'CANCELLED', 'PAUSED'];
61
+
62
+ statuses.forEach(status => {
63
+ const req = {
64
+ id: 'req-456',
65
+ projectId: 'proj-123',
66
+ title: 'Test',
67
+ status
68
+ };
69
+ const result = BrainGridRequirementSchema.safeParse(req);
70
+ expect(result.success).toBe(true);
71
+ });
72
+ });
73
+
74
+ it('should reject invalid requirement status', () => {
75
+ const invalidReq = {
76
+ id: 'req-456',
77
+ projectId: 'proj-123',
78
+ title: 'Test',
79
+ status: 'INVALID_STATUS'
80
+ };
81
+
82
+ const result = BrainGridRequirementSchema.safeParse(invalidReq);
83
+ expect(result.success).toBe(false);
84
+ });
85
+ });
86
+
87
+ describe('BrainGridTaskSchema', () => {
88
+ it('should validate a valid task', () => {
89
+ const validTask = {
90
+ id: 'task-789',
91
+ reqId: 'req-456',
92
+ title: 'Build login UI',
93
+ status: 'TODO' as TaskStatus,
94
+ tags: ['DEV', 'frontend'],
95
+ dependencies: ['task-123', 'task-456']
96
+ };
97
+
98
+ const result = BrainGridTaskSchema.safeParse(validTask);
99
+ expect(result.success).toBe(true);
100
+ if (result.success) {
101
+ expect(result.data.tags).toHaveLength(2);
102
+ expect(result.data.dependencies).toHaveLength(2);
103
+ }
104
+ });
105
+
106
+ it('should allow optional fields to be undefined', () => {
107
+ const minimalTask = {
108
+ id: 'task-789',
109
+ reqId: 'req-456',
110
+ title: 'Build login UI',
111
+ status: 'TODO' as TaskStatus
112
+ };
113
+
114
+ const result = BrainGridTaskSchema.safeParse(minimalTask);
115
+ expect(result.success).toBe(true);
116
+ if (result.success) {
117
+ expect(result.data.tags).toBeUndefined();
118
+ expect(result.data.dependencies).toBeUndefined();
119
+ }
120
+ });
121
+
122
+ it('should reject invalid task status', () => {
123
+ const invalidTask = {
124
+ id: 'task-789',
125
+ reqId: 'req-456',
126
+ title: 'Build login UI',
127
+ status: 'INVALID_STATUS'
128
+ };
129
+
130
+ const result = BrainGridTaskSchema.safeParse(invalidTask);
131
+ expect(result.success).toBe(false);
132
+ });
133
+ });
134
+
135
+ describe('BrainGridCliError', () => {
136
+ it('should create error with all properties', () => {
137
+ const error = new BrainGridCliError(
138
+ 'Command failed',
139
+ 'braingrid test-command',
140
+ 1,
141
+ 'Error output from stderr'
142
+ );
143
+
144
+ expect(error).toBeInstanceOf(Error);
145
+ expect(error.name).toBe('BrainGridCliError');
146
+ expect(error.message).toBe('Command failed');
147
+ expect(error.command).toBe('braingrid test-command');
148
+ expect(error.exitCode).toBe(1);
149
+ expect(error.stderr).toBe('Error output from stderr');
150
+ });
151
+
152
+ it('should preserve error properties when thrown', () => {
153
+ try {
154
+ throw new BrainGridCliError(
155
+ 'Test error',
156
+ 'braingrid fail',
157
+ 2,
158
+ 'stderr content'
159
+ );
160
+ } catch (err) {
161
+ expect(err).toBeInstanceOf(BrainGridCliError);
162
+ if (err instanceof BrainGridCliError) {
163
+ expect(err.message).toBe('Test error');
164
+ expect(err.command).toBe('braingrid fail');
165
+ expect(err.exitCode).toBe(2);
166
+ expect(err.stderr).toBe('stderr content');
167
+ }
168
+ }
169
+ });
170
+
171
+ it('should handle empty stderr', () => {
172
+ const error = new BrainGridCliError(
173
+ 'Command failed',
174
+ 'braingrid cmd',
175
+ 1,
176
+ ''
177
+ );
178
+
179
+ expect(error.stderr).toBe('');
180
+ expect(error.exitCode).toBe(1);
181
+ });
182
+
183
+ it('should handle different exit codes', () => {
184
+ const exitCodes = [0, 1, 2, 127, 255];
185
+
186
+ exitCodes.forEach(code => {
187
+ const error = new BrainGridCliError(
188
+ 'Test',
189
+ 'cmd',
190
+ code,
191
+ 'stderr'
192
+ );
193
+ expect(error.exitCode).toBe(code);
194
+ });
195
+ });
196
+ });
197
+ });
package/src/models.ts ADDED
@@ -0,0 +1,93 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ import { z } from 'zod';
10
+
11
+ // Requirement statuses
12
+ export const RequirementStatusSchema = z.enum([
13
+ 'IDEA',
14
+ 'PLANNED',
15
+ 'IN_PROGRESS',
16
+ 'COMPLETED',
17
+ 'CANCELLED',
18
+ 'PAUSED'
19
+ ]);
20
+
21
+ export type RequirementStatus = z.infer<typeof RequirementStatusSchema>;
22
+
23
+ // Task statuses
24
+ export const TaskStatusSchema = z.enum([
25
+ 'TODO',
26
+ 'READY',
27
+ 'BLOCKED',
28
+ 'IN_PROGRESS',
29
+ 'COMPLETED',
30
+ 'FAILED',
31
+ 'PAUSED'
32
+ ]);
33
+
34
+ export type TaskStatus = z.infer<typeof TaskStatusSchema>;
35
+
36
+ // BrainGrid Project
37
+ export const BrainGridProjectSchema = z.object({
38
+ id: z.string(),
39
+ name: z.string(),
40
+ description: z.string().optional()
41
+ });
42
+
43
+ export type BrainGridProject = z.infer<typeof BrainGridProjectSchema>;
44
+
45
+ // BrainGrid Requirement
46
+ export const BrainGridRequirementSchema = z.object({
47
+ id: z.string(),
48
+ projectId: z.string(),
49
+ title: z.string(),
50
+ status: RequirementStatusSchema,
51
+ description: z.string().optional(),
52
+ createdAt: z.string().optional(),
53
+ updatedAt: z.string().optional()
54
+ });
55
+
56
+ export type BrainGridRequirement = z.infer<typeof BrainGridRequirementSchema>;
57
+
58
+ // BrainGrid Task
59
+ export const BrainGridTaskSchema = z.object({
60
+ id: z.string(),
61
+ reqId: z.string(),
62
+ title: z.string(),
63
+ status: TaskStatusSchema,
64
+ description: z.string().optional(),
65
+ tags: z.array(z.string()).optional(),
66
+ dependencies: z.array(z.string()).optional(),
67
+ assignedTo: z.string().optional(),
68
+ createdAt: z.string().optional(),
69
+ updatedAt: z.string().optional(),
70
+ metadata: z.record(z.unknown()).optional()
71
+ });
72
+
73
+ export type BrainGridTask = z.infer<typeof BrainGridTaskSchema>;
74
+
75
+ // CLI Error
76
+ export class BrainGridCliError extends Error {
77
+ public command: string;
78
+ public exitCode: number;
79
+ public stderr: string;
80
+
81
+ constructor(
82
+ message: string,
83
+ command: string,
84
+ exitCode: number,
85
+ stderr: string
86
+ ) {
87
+ super(message);
88
+ this.name = 'BrainGridCliError';
89
+ this.command = command;
90
+ this.exitCode = exitCode;
91
+ this.stderr = stderr;
92
+ }
93
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "lib": ["ES2022"],
6
+ "declaration": true,
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "moduleResolution": "node",
14
+ "resolveJsonModule": true
15
+ },
16
+ "include": ["src/**/*"],
17
+ "exclude": ["node_modules", "dist", "**/*.test.ts"]
18
+ }