@bernierllc/braingrid-cli-wrapper 0.3.2 → 0.6.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/dist/errors.d.ts +11 -0
- package/dist/errors.js +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/models.d.ts +9 -1
- package/dist/models.js +9 -3
- package/package.json +5 -1
- package/.eslintrc.cjs +0 -29
- package/CHANGELOG.md +0 -51
- package/jest.config.cjs +0 -21
- package/src/__tests__/execa-mock-validation.test.ts +0 -34
- package/src/__tests__/index.test.ts +0 -77
- package/src/cli.test.ts +0 -86
- package/src/cli.ts +0 -71
- package/src/commands/createIdea.test.ts +0 -77
- package/src/commands/createIdea.ts +0 -36
- package/src/commands/createProject.test.ts +0 -75
- package/src/commands/createProject.ts +0 -37
- package/src/commands/createTask.test.ts +0 -100
- package/src/commands/createTask.ts +0 -50
- package/src/commands/listProjects.test.ts +0 -72
- package/src/commands/listProjects.ts +0 -25
- package/src/commands/listRequirements.test.ts +0 -89
- package/src/commands/listRequirements.ts +0 -37
- package/src/commands/listTasks.test.ts +0 -183
- package/src/commands/listTasks.ts +0 -47
- package/src/commands/updateRequirementStatus.test.ts +0 -85
- package/src/commands/updateRequirementStatus.ts +0 -33
- package/src/commands/updateTaskStatus.test.ts +0 -96
- package/src/commands/updateTaskStatus.ts +0 -40
- package/src/index.ts +0 -32
- package/src/models.test.ts +0 -197
- package/src/models.ts +0 -93
- package/tsconfig.json +0 -18
|
@@ -1,47 +0,0 @@
|
|
|
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 { runBrainGridCommand } from '../cli';
|
|
10
|
-
import { BrainGridTask, BrainGridTaskSchema, TaskStatus } from '../models';
|
|
11
|
-
import { z } from 'zod';
|
|
12
|
-
|
|
13
|
-
export interface ListTasksOptions {
|
|
14
|
-
reqId?: string;
|
|
15
|
-
status?: TaskStatus[];
|
|
16
|
-
tags?: string[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* List tasks in BrainGrid with optional filters
|
|
21
|
-
*/
|
|
22
|
-
export async function listTasks(options: ListTasksOptions = {}): Promise<BrainGridTask[]> {
|
|
23
|
-
const args = ['task', 'list'];
|
|
24
|
-
|
|
25
|
-
if (options.reqId) {
|
|
26
|
-
args.push('--req', options.reqId);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (options.status && options.status.length > 0) {
|
|
30
|
-
args.push('--status', options.status.join(','));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (options.tags && options.tags.length > 0) {
|
|
34
|
-
args.push('--tags', options.tags.join(','));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
args.push('--format', 'json');
|
|
38
|
-
|
|
39
|
-
const result = await runBrainGridCommand(args);
|
|
40
|
-
|
|
41
|
-
const parsed = z.array(BrainGridTaskSchema).safeParse(result);
|
|
42
|
-
if (!parsed.success) {
|
|
43
|
-
throw new Error(`Invalid BrainGrid response: ${parsed.error.message}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return parsed.data;
|
|
47
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
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 { updateRequirementStatus } from './updateRequirementStatus';
|
|
10
|
-
|
|
11
|
-
jest.mock('../cli', () => ({
|
|
12
|
-
runBrainGridCommand: jest.fn()
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
import { runBrainGridCommand } from '../cli';
|
|
16
|
-
|
|
17
|
-
describe('updateRequirementStatus', () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
jest.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should update requirement status to PLANNED', async () => {
|
|
23
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue({});
|
|
24
|
-
|
|
25
|
-
await updateRequirementStatus('req-123', 'PLANNED');
|
|
26
|
-
|
|
27
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
28
|
-
'requirement',
|
|
29
|
-
'update',
|
|
30
|
-
'req-123',
|
|
31
|
-
'--status',
|
|
32
|
-
'PLANNED',
|
|
33
|
-
'--format',
|
|
34
|
-
'json'
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should update requirement status to IN_PROGRESS', async () => {
|
|
39
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue({});
|
|
40
|
-
|
|
41
|
-
await updateRequirementStatus('req-456', 'IN_PROGRESS');
|
|
42
|
-
|
|
43
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
44
|
-
'requirement',
|
|
45
|
-
'update',
|
|
46
|
-
'req-456',
|
|
47
|
-
'--status',
|
|
48
|
-
'IN_PROGRESS',
|
|
49
|
-
'--format',
|
|
50
|
-
'json'
|
|
51
|
-
]);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should update requirement status to COMPLETED', async () => {
|
|
55
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue({});
|
|
56
|
-
|
|
57
|
-
await updateRequirementStatus('req-789', 'COMPLETED');
|
|
58
|
-
|
|
59
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
60
|
-
'requirement',
|
|
61
|
-
'update',
|
|
62
|
-
'req-789',
|
|
63
|
-
'--status',
|
|
64
|
-
'COMPLETED',
|
|
65
|
-
'--format',
|
|
66
|
-
'json'
|
|
67
|
-
]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('should update requirement status to CANCELLED', async () => {
|
|
71
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue({});
|
|
72
|
-
|
|
73
|
-
await updateRequirementStatus('req-999', 'CANCELLED');
|
|
74
|
-
|
|
75
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
76
|
-
'requirement',
|
|
77
|
-
'update',
|
|
78
|
-
'req-999',
|
|
79
|
-
'--status',
|
|
80
|
-
'CANCELLED',
|
|
81
|
-
'--format',
|
|
82
|
-
'json'
|
|
83
|
-
]);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
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 { runBrainGridCommand } from '../cli';
|
|
10
|
-
import { RequirementStatus } from '../models';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Updates a requirement's status
|
|
14
|
-
* @param requirementId - Requirement ID to update
|
|
15
|
-
* @param status - New status to set
|
|
16
|
-
* @returns Promise resolving when update is complete
|
|
17
|
-
*/
|
|
18
|
-
export async function updateRequirementStatus(
|
|
19
|
-
requirementId: string,
|
|
20
|
-
status: RequirementStatus
|
|
21
|
-
): Promise<void> {
|
|
22
|
-
const args = [
|
|
23
|
-
'requirement',
|
|
24
|
-
'update',
|
|
25
|
-
requirementId,
|
|
26
|
-
'--status',
|
|
27
|
-
status,
|
|
28
|
-
'--format',
|
|
29
|
-
'json'
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
await runBrainGridCommand(args);
|
|
33
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
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 { updateTaskStatus } from './updateTaskStatus';
|
|
10
|
-
|
|
11
|
-
jest.mock('../cli', () => ({
|
|
12
|
-
runBrainGridCommand: jest.fn()
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
import { runBrainGridCommand } from '../cli';
|
|
16
|
-
|
|
17
|
-
describe('updateTaskStatus', () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
jest.clearAllMocks();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should update task status', async () => {
|
|
23
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue(null);
|
|
24
|
-
|
|
25
|
-
await updateTaskStatus('task-123', {
|
|
26
|
-
status: 'IN_PROGRESS'
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
30
|
-
'task',
|
|
31
|
-
'update',
|
|
32
|
-
'task-123',
|
|
33
|
-
'--status',
|
|
34
|
-
'IN_PROGRESS'
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should update task with assigned user', async () => {
|
|
39
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue(null);
|
|
40
|
-
|
|
41
|
-
await updateTaskStatus('task-123', {
|
|
42
|
-
status: 'IN_PROGRESS',
|
|
43
|
-
assignedTo: 'user-456'
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
47
|
-
'task',
|
|
48
|
-
'update',
|
|
49
|
-
'task-123',
|
|
50
|
-
'--status',
|
|
51
|
-
'IN_PROGRESS',
|
|
52
|
-
'--assigned-to',
|
|
53
|
-
'user-456'
|
|
54
|
-
]);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should update task with metadata', async () => {
|
|
58
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue(null);
|
|
59
|
-
|
|
60
|
-
const metadata = {
|
|
61
|
-
progress: 50,
|
|
62
|
-
notes: 'Half done'
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
await updateTaskStatus('task-123', {
|
|
66
|
-
status: 'IN_PROGRESS',
|
|
67
|
-
metadata
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
71
|
-
'task',
|
|
72
|
-
'update',
|
|
73
|
-
'task-123',
|
|
74
|
-
'--status',
|
|
75
|
-
'IN_PROGRESS',
|
|
76
|
-
'--metadata',
|
|
77
|
-
JSON.stringify(metadata)
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should update without status (metadata only)', async () => {
|
|
82
|
-
(runBrainGridCommand as jest.MockedFunction<typeof runBrainGridCommand>).mockResolvedValue(null);
|
|
83
|
-
|
|
84
|
-
await updateTaskStatus('task-123', {
|
|
85
|
-
assignedTo: 'user-456'
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
expect(runBrainGridCommand).toHaveBeenCalledWith([
|
|
89
|
-
'task',
|
|
90
|
-
'update',
|
|
91
|
-
'task-123',
|
|
92
|
-
'--assigned-to',
|
|
93
|
-
'user-456'
|
|
94
|
-
]);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
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 { runBrainGridCommand } from '../cli';
|
|
10
|
-
import { TaskStatus } from '../models';
|
|
11
|
-
|
|
12
|
-
export interface UpdateTaskOptions {
|
|
13
|
-
status?: TaskStatus;
|
|
14
|
-
assignedTo?: string;
|
|
15
|
-
metadata?: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Update task status and metadata in BrainGrid
|
|
20
|
-
*/
|
|
21
|
-
export async function updateTaskStatus(
|
|
22
|
-
taskId: string,
|
|
23
|
-
options: UpdateTaskOptions
|
|
24
|
-
): Promise<void> {
|
|
25
|
-
const args = ['task', 'update', taskId];
|
|
26
|
-
|
|
27
|
-
if (options.status) {
|
|
28
|
-
args.push('--status', options.status);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (options.assignedTo) {
|
|
32
|
-
args.push('--assigned-to', options.assignedTo);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (options.metadata) {
|
|
36
|
-
args.push('--metadata', JSON.stringify(options.metadata));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
await runBrainGridCommand(args);
|
|
40
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
// BrainGrid CLI Wrapper - Type-safe wrapper for BrainGrid CLI
|
|
10
|
-
|
|
11
|
-
// Export types and schemas
|
|
12
|
-
export {
|
|
13
|
-
BrainGridProject,
|
|
14
|
-
BrainGridRequirement,
|
|
15
|
-
BrainGridTask,
|
|
16
|
-
RequirementStatus,
|
|
17
|
-
TaskStatus,
|
|
18
|
-
BrainGridProjectSchema,
|
|
19
|
-
BrainGridRequirementSchema,
|
|
20
|
-
BrainGridTaskSchema,
|
|
21
|
-
BrainGridCliError
|
|
22
|
-
} from './models';
|
|
23
|
-
|
|
24
|
-
// Export commands
|
|
25
|
-
export { createIdea } from './commands/createIdea';
|
|
26
|
-
export { listProjects } from './commands/listProjects';
|
|
27
|
-
export { createProject } from './commands/createProject';
|
|
28
|
-
export { listRequirements } from './commands/listRequirements';
|
|
29
|
-
export { updateRequirementStatus } from './commands/updateRequirementStatus';
|
|
30
|
-
export { createTask, CreateTaskOptions } from './commands/createTask';
|
|
31
|
-
export { updateTaskStatus, UpdateTaskOptions } from './commands/updateTaskStatus';
|
|
32
|
-
export { listTasks, ListTasksOptions } from './commands/listTasks';
|
package/src/models.test.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|