@goonnguyen/human-mcp 1.2.0 → 1.3.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/.claude/agents/project-manager.md +2 -2
- package/.env.example +28 -1
- package/.github/workflows/publish.yml +43 -6
- package/.opencode/agent/code-reviewer.md +142 -0
- package/.opencode/agent/debugger.md +74 -0
- package/.opencode/agent/docs-manager.md +119 -0
- package/.opencode/agent/git-manager.md +60 -0
- package/.opencode/agent/planner-researcher.md +100 -0
- package/.opencode/agent/project-manager.md +113 -0
- package/.opencode/agent/system-architecture.md +200 -0
- package/.opencode/agent/tester.md +96 -0
- package/.opencode/agent/ui-ux-developer.md +97 -0
- package/.opencode/command/cook.md +7 -0
- package/.opencode/command/debug.md +10 -0
- package/.opencode/command/fix/ci.md +8 -0
- package/.opencode/command/fix/fast.md +5 -0
- package/.opencode/command/fix/hard.md +7 -0
- package/.opencode/command/fix/test.md +16 -0
- package/.opencode/command/git/cm.md +5 -0
- package/.opencode/command/git/cp.md +4 -0
- package/.opencode/command/plan/ci.md +12 -0
- package/.opencode/command/plan/two.md +13 -0
- package/.opencode/command/plan.md +10 -0
- package/.opencode/command/test.md +7 -0
- package/.opencode/command/watzup.md +8 -0
- package/CHANGELOG.md +21 -0
- package/CLAUDE.md +5 -3
- package/QUICKSTART.md +3 -3
- package/README.md +551 -20
- package/bun.lock +275 -3
- package/dist/index.js +71091 -17256
- package/docs/README.md +51 -0
- package/docs/codebase-structure-architecture-code-standards.md +17 -5
- package/docs/project-overview-pdr.md +37 -21
- package/docs/project-roadmap.md +494 -0
- package/human-mcp.png +0 -0
- package/package.json +9 -1
- package/plans/002-sse-fallback-http-transport-plan.md +161 -0
- package/plans/003-fix-test-infrastructure-and-ci-plan.md +699 -0
- package/plans/003-http-transport-local-file-access-plan.md +880 -0
- package/plans/004-fix-typescript-compilation-errors-plan.md +388 -0
- package/plans/005-comprehensive-test-infrastructure-fix-plan.md +854 -0
- package/src/index.ts +2 -0
- package/src/tools/eyes/index.ts +7 -7
- package/src/tools/eyes/processors/image.ts +90 -0
- package/src/transports/http/file-interceptor.ts +134 -0
- package/src/transports/http/routes.ts +165 -4
- package/src/transports/http/server.ts +64 -14
- package/src/transports/http/session.ts +11 -3
- package/src/transports/http/sse-routes.ts +210 -0
- package/src/transports/index.ts +11 -6
- package/src/transports/types.ts +13 -0
- package/src/utils/cloudflare-r2.ts +107 -0
- package/src/utils/config.ts +26 -0
- package/tests/integration/http-transport-files.test.ts +190 -0
- package/tests/integration/server.test.ts +4 -1
- package/tests/integration/sse-transport.test.ts +142 -0
- package/tests/setup.ts +45 -1
- package/tests/types/api-responses.ts +35 -0
- package/tests/types/test-types.ts +105 -0
- package/tests/unit/cloudflare-r2.test.ts +118 -0
- package/tests/unit/eyes-analyze.test.ts +150 -0
- package/tests/unit/formatters.test.ts +1 -1
- package/tests/unit/sse-routes.test.ts +92 -0
- package/tests/utils/error-scenarios.ts +198 -0
- package/tests/utils/index.ts +3 -0
- package/tests/utils/mock-helpers.ts +99 -0
- package/tests/utils/test-data-generators.ts +217 -0
- package/tests/utils/test-server-manager.ts +172 -0
- package/tsconfig.json +1 -1
- package/plans/reports/001-from-qa-engineer-to-development-team-test-suite-report.md +0 -188
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
# Plan 004: Fix TypeScript Compilation Errors in CI/CD Pipeline
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
This plan addresses critical TypeScript compilation errors that are causing the CI/CD pipeline to fail. The main issues are:
|
|
6
|
+
1. Type assertions on `unknown` types in test files (18046 errors)
|
|
7
|
+
2. Incorrect import statement for type-only imports when `verbatimModuleSyntax` is enabled (1484 error)
|
|
8
|
+
|
|
9
|
+
These errors prevent the test suite from running and block the release pipeline.
|
|
10
|
+
|
|
11
|
+
## Problem Analysis
|
|
12
|
+
|
|
13
|
+
### 1. Root Causes Identified
|
|
14
|
+
|
|
15
|
+
#### A. Unknown Type Assertions (TS18046)
|
|
16
|
+
- **Location**: Multiple test files (sse-transport.test.ts, test-server-manager.ts)
|
|
17
|
+
- **Problem**: Variables of type `unknown` are being accessed without proper type guards
|
|
18
|
+
- **Impact**: TypeScript compilation fails with error TS18046
|
|
19
|
+
- **Evidence**:
|
|
20
|
+
```
|
|
21
|
+
tests/integration/sse-transport.test.ts(41,14): error TS18046: 'health' is of type 'unknown'.
|
|
22
|
+
tests/integration/sse-transport.test.ts(78,14): error TS18046: 'error' is of type 'unknown'.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### B. Incorrect Type Import (TS1484)
|
|
26
|
+
- **Location**: tests/unit/formatters.test.ts
|
|
27
|
+
- **Problem**: `AnalysisOptions` is imported as a value when it should be a type-only import
|
|
28
|
+
- **Impact**: Violates `verbatimModuleSyntax` TypeScript setting
|
|
29
|
+
- **Evidence**:
|
|
30
|
+
```
|
|
31
|
+
tests/unit/formatters.test.ts(3,10): error TS1484: 'AnalysisOptions' is a type and must be imported using a type-only import
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Secondary Issues
|
|
35
|
+
|
|
36
|
+
- CI/CD pipeline blocks on TypeScript errors before tests can run
|
|
37
|
+
- No type safety in test assertions
|
|
38
|
+
- Missing proper type definitions for API responses
|
|
39
|
+
|
|
40
|
+
## Technical Solution
|
|
41
|
+
|
|
42
|
+
### 1. Fix Type-Only Import in Formatters Test
|
|
43
|
+
|
|
44
|
+
#### File: `tests/unit/formatters.test.ts`
|
|
45
|
+
|
|
46
|
+
**Current Code (Line 3):**
|
|
47
|
+
```typescript
|
|
48
|
+
import { AnalysisOptions } from "../../src/types/index.js";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Fixed Code:**
|
|
52
|
+
```typescript
|
|
53
|
+
import type { AnalysisOptions } from "../../src/types/index.js";
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Rationale**: When `verbatimModuleSyntax` is enabled in tsconfig.json, TypeScript requires explicit `type` imports for type-only symbols.
|
|
57
|
+
|
|
58
|
+
### 2. Fix Unknown Type Assertions in SSE Transport Tests
|
|
59
|
+
|
|
60
|
+
#### File: `tests/integration/sse-transport.test.ts`
|
|
61
|
+
|
|
62
|
+
**Lines 36-48 - Health Check Test:**
|
|
63
|
+
|
|
64
|
+
**Current Code:**
|
|
65
|
+
```typescript
|
|
66
|
+
it("should include SSE fallback status in health check", async () => {
|
|
67
|
+
const response = await fetch(`${baseUrl}/health`);
|
|
68
|
+
const health = await response.json();
|
|
69
|
+
|
|
70
|
+
expect(health.status).toBe("healthy");
|
|
71
|
+
expect(health.transport).toBe("streamable-http");
|
|
72
|
+
expect(health.sseFallback).toBe("enabled");
|
|
73
|
+
expect(health.ssePaths).toEqual({
|
|
74
|
+
stream: "/sse",
|
|
75
|
+
message: "/messages"
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Fixed Code:**
|
|
81
|
+
```typescript
|
|
82
|
+
it("should include SSE fallback status in health check", async () => {
|
|
83
|
+
const response = await fetch(`${baseUrl}/health`);
|
|
84
|
+
const health = await response.json() as {
|
|
85
|
+
status: string;
|
|
86
|
+
transport: string;
|
|
87
|
+
sseFallback: string;
|
|
88
|
+
ssePaths: {
|
|
89
|
+
stream: string;
|
|
90
|
+
message: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
expect(health.status).toBe("healthy");
|
|
95
|
+
expect(health.transport).toBe("streamable-http");
|
|
96
|
+
expect(health.sseFallback).toBe("enabled");
|
|
97
|
+
expect(health.ssePaths).toEqual({
|
|
98
|
+
stream: "/sse",
|
|
99
|
+
message: "/messages"
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Lines 73-79 - Error Response Test:**
|
|
105
|
+
|
|
106
|
+
**Current Code:**
|
|
107
|
+
```typescript
|
|
108
|
+
expect(response.status).toBe(400);
|
|
109
|
+
const error = await response.json();
|
|
110
|
+
expect(error.error.message).toContain("Missing sessionId");
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Fixed Code:**
|
|
114
|
+
```typescript
|
|
115
|
+
expect(response.status).toBe(400);
|
|
116
|
+
const error = await response.json() as { error: { message: string } };
|
|
117
|
+
expect(error.error.message).toContain("Missing sessionId");
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Lines 93-97 - Invalid Session Test:**
|
|
121
|
+
|
|
122
|
+
**Current Code:**
|
|
123
|
+
```typescript
|
|
124
|
+
expect(response.status).toBe(400);
|
|
125
|
+
const error = await response.json();
|
|
126
|
+
expect(error.error.message).toContain("No active SSE session");
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Fixed Code:**
|
|
130
|
+
```typescript
|
|
131
|
+
expect(response.status).toBe(400);
|
|
132
|
+
const error = await response.json() as { error: { message: string } };
|
|
133
|
+
expect(error.error.message).toContain("No active SSE session");
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Lines 135-139 - Transport Mixing Test:**
|
|
137
|
+
|
|
138
|
+
**Current Code:**
|
|
139
|
+
```typescript
|
|
140
|
+
expect(response.status).toBe(400);
|
|
141
|
+
const error = await response.json();
|
|
142
|
+
expect(error.error.message).toContain("streamable HTTP transport");
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Fixed Code:**
|
|
146
|
+
```typescript
|
|
147
|
+
expect(response.status).toBe(400);
|
|
148
|
+
const error = await response.json() as { error: { message: string } };
|
|
149
|
+
expect(error.error.message).toContain("streamable HTTP transport");
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3. Fix Unknown Type Assertions in Test Server Manager
|
|
153
|
+
|
|
154
|
+
#### File: `tests/utils/test-server-manager.ts`
|
|
155
|
+
|
|
156
|
+
**Lines 113-117 - Server Ready Check:**
|
|
157
|
+
|
|
158
|
+
**Current Code:**
|
|
159
|
+
```typescript
|
|
160
|
+
if (response.ok) {
|
|
161
|
+
const health = await response.json();
|
|
162
|
+
if (health.status === 'healthy') {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Fixed Code:**
|
|
169
|
+
```typescript
|
|
170
|
+
if (response.ok) {
|
|
171
|
+
const health = await response.json() as { status: string };
|
|
172
|
+
if (health.status === 'healthy') {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 4. Create Type Definitions for Test Responses
|
|
179
|
+
|
|
180
|
+
To improve type safety and avoid inline type assertions, create proper type definitions:
|
|
181
|
+
|
|
182
|
+
#### New File: `tests/types/api-responses.ts`
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// Type definitions for API responses used in tests
|
|
186
|
+
|
|
187
|
+
export interface HealthCheckResponse {
|
|
188
|
+
status: 'healthy' | 'unhealthy';
|
|
189
|
+
transport: string;
|
|
190
|
+
sseFallback?: string;
|
|
191
|
+
ssePaths?: {
|
|
192
|
+
stream: string;
|
|
193
|
+
message: string;
|
|
194
|
+
};
|
|
195
|
+
version?: string;
|
|
196
|
+
timestamp?: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface ErrorResponse {
|
|
200
|
+
error: {
|
|
201
|
+
code?: string;
|
|
202
|
+
message: string;
|
|
203
|
+
details?: any;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface MCPResponse {
|
|
208
|
+
jsonrpc: '2.0';
|
|
209
|
+
id?: number | string;
|
|
210
|
+
result?: any;
|
|
211
|
+
error?: {
|
|
212
|
+
code: number;
|
|
213
|
+
message: string;
|
|
214
|
+
data?: any;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface SessionResponse {
|
|
219
|
+
sessionId: string;
|
|
220
|
+
createdAt: number;
|
|
221
|
+
expiresAt?: number;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 5. Update Tests to Use Type Definitions
|
|
226
|
+
|
|
227
|
+
#### Updated File: `tests/integration/sse-transport.test.ts`
|
|
228
|
+
|
|
229
|
+
Add import at the top:
|
|
230
|
+
```typescript
|
|
231
|
+
import type { HealthCheckResponse, ErrorResponse } from "../types/api-responses.js";
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Update test assertions:
|
|
235
|
+
```typescript
|
|
236
|
+
it("should include SSE fallback status in health check", async () => {
|
|
237
|
+
const response = await fetch(`${baseUrl}/health`);
|
|
238
|
+
const health = await response.json() as HealthCheckResponse;
|
|
239
|
+
|
|
240
|
+
expect(health.status).toBe("healthy");
|
|
241
|
+
expect(health.transport).toBe("streamable-http");
|
|
242
|
+
expect(health.sseFallback).toBe("enabled");
|
|
243
|
+
expect(health.ssePaths).toEqual({
|
|
244
|
+
stream: "/sse",
|
|
245
|
+
message: "/messages"
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### Updated File: `tests/utils/test-server-manager.ts`
|
|
251
|
+
|
|
252
|
+
Add import at the top:
|
|
253
|
+
```typescript
|
|
254
|
+
import type { HealthCheckResponse } from "../types/api-responses.js";
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Update server ready check:
|
|
258
|
+
```typescript
|
|
259
|
+
if (response.ok) {
|
|
260
|
+
const health = await response.json() as HealthCheckResponse;
|
|
261
|
+
if (health.status === 'healthy') {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Implementation Steps
|
|
268
|
+
|
|
269
|
+
### Phase 1: Immediate Fixes (Priority: CRITICAL)
|
|
270
|
+
1. **Fix type-only import in formatters.test.ts**
|
|
271
|
+
- Add `type` keyword to AnalysisOptions import
|
|
272
|
+
- Verify no other type-only imports are missing
|
|
273
|
+
|
|
274
|
+
2. **Fix unknown type assertions in test files**
|
|
275
|
+
- Add type assertions to all `response.json()` calls
|
|
276
|
+
- Ensure proper typing for all test assertions
|
|
277
|
+
|
|
278
|
+
### Phase 2: Type Safety Improvements (Priority: HIGH)
|
|
279
|
+
3. **Create type definitions file**
|
|
280
|
+
- Define interfaces for all API responses
|
|
281
|
+
- Export types for use across test files
|
|
282
|
+
|
|
283
|
+
4. **Update all test files to use type definitions**
|
|
284
|
+
- Import response types
|
|
285
|
+
- Replace inline type assertions with defined types
|
|
286
|
+
|
|
287
|
+
### Phase 3: Validation (Priority: HIGH)
|
|
288
|
+
5. **Run TypeScript compilation locally**
|
|
289
|
+
- Execute `bun run typecheck`
|
|
290
|
+
- Verify no compilation errors
|
|
291
|
+
|
|
292
|
+
6. **Run test suite**
|
|
293
|
+
- Execute `bun test`
|
|
294
|
+
- Ensure all tests pass with proper types
|
|
295
|
+
|
|
296
|
+
## Testing Strategy
|
|
297
|
+
|
|
298
|
+
### Local Validation
|
|
299
|
+
```bash
|
|
300
|
+
# Check TypeScript compilation
|
|
301
|
+
bun run typecheck
|
|
302
|
+
|
|
303
|
+
# Run unit tests
|
|
304
|
+
bun test tests/unit/
|
|
305
|
+
|
|
306
|
+
# Run integration tests
|
|
307
|
+
bun test tests/integration/
|
|
308
|
+
|
|
309
|
+
# Run all tests
|
|
310
|
+
bun test
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### CI/CD Validation
|
|
314
|
+
- Push changes to trigger GitHub Actions
|
|
315
|
+
- Verify TypeScript compilation passes
|
|
316
|
+
- Confirm all tests execute successfully
|
|
317
|
+
- Check that release pipeline completes
|
|
318
|
+
|
|
319
|
+
## Risk Mitigation
|
|
320
|
+
|
|
321
|
+
### Risks and Mitigations
|
|
322
|
+
|
|
323
|
+
1. **Risk**: Type assertions might hide runtime errors
|
|
324
|
+
- **Mitigation**: Use proper type guards where possible, validate API responses
|
|
325
|
+
|
|
326
|
+
2. **Risk**: Breaking existing test functionality
|
|
327
|
+
- **Mitigation**: Only add type information, don't change test logic
|
|
328
|
+
|
|
329
|
+
3. **Risk**: Future TypeScript updates might introduce new errors
|
|
330
|
+
- **Mitigation**: Pin TypeScript version, document type requirements
|
|
331
|
+
|
|
332
|
+
## Success Criteria
|
|
333
|
+
|
|
334
|
+
- [ ] TypeScript compilation passes without errors
|
|
335
|
+
- [ ] All unit tests pass
|
|
336
|
+
- [ ] All integration tests pass
|
|
337
|
+
- [ ] CI/CD pipeline completes successfully
|
|
338
|
+
- [ ] No runtime type errors in tests
|
|
339
|
+
|
|
340
|
+
## Timeline
|
|
341
|
+
|
|
342
|
+
- **Immediate**: Fix compilation errors (30 minutes)
|
|
343
|
+
- **Short-term**: Add type definitions (1 hour)
|
|
344
|
+
- **Validation**: Test and verify (30 minutes)
|
|
345
|
+
|
|
346
|
+
## TODO Checklist
|
|
347
|
+
|
|
348
|
+
### Immediate Actions
|
|
349
|
+
- [ ] Fix type-only import in `tests/unit/formatters.test.ts`
|
|
350
|
+
- [ ] Add type assertions in `tests/integration/sse-transport.test.ts`
|
|
351
|
+
- [ ] Add type assertion in `tests/utils/test-server-manager.ts`
|
|
352
|
+
|
|
353
|
+
### Type Safety Improvements
|
|
354
|
+
- [ ] Create `tests/types/api-responses.ts`
|
|
355
|
+
- [ ] Update test files to use type definitions
|
|
356
|
+
- [ ] Add JSDoc comments for complex types
|
|
357
|
+
|
|
358
|
+
### Validation
|
|
359
|
+
- [ ] Run `bun run typecheck` locally
|
|
360
|
+
- [ ] Run full test suite
|
|
361
|
+
- [ ] Verify CI/CD pipeline passes
|
|
362
|
+
|
|
363
|
+
## Files to Modify
|
|
364
|
+
|
|
365
|
+
1. `tests/unit/formatters.test.ts` - Fix type-only import
|
|
366
|
+
2. `tests/integration/sse-transport.test.ts` - Add type assertions
|
|
367
|
+
3. `tests/utils/test-server-manager.ts` - Add type assertion
|
|
368
|
+
4. `tests/types/api-responses.ts` - Create new file with type definitions
|
|
369
|
+
|
|
370
|
+
## Dependencies
|
|
371
|
+
|
|
372
|
+
- No new package dependencies required
|
|
373
|
+
- Uses existing TypeScript configuration
|
|
374
|
+
- Leverages Bun's built-in TypeScript support
|
|
375
|
+
|
|
376
|
+
## Notes
|
|
377
|
+
|
|
378
|
+
- The `verbatimModuleSyntax` setting in tsconfig.json enforces stricter import/export syntax
|
|
379
|
+
- Type assertions should be used judiciously and replaced with proper type guards where possible
|
|
380
|
+
- Consider adding runtime validation for API responses in production code
|
|
381
|
+
- Future improvement: Add JSON schema validation for API responses
|
|
382
|
+
|
|
383
|
+
## References
|
|
384
|
+
|
|
385
|
+
- [TypeScript verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax)
|
|
386
|
+
- [TypeScript Type Assertions](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions)
|
|
387
|
+
- [TypeScript Unknown Type](https://www.typescriptlang.org/docs/handbook/2/functions.html#unknown)
|
|
388
|
+
- [Bun TypeScript Support](https://bun.sh/docs/runtime/typescript)
|