mcp-test-timebox 0.1.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -0
  3. package/dist/executor/index.d.ts +8 -0
  4. package/dist/executor/index.d.ts.map +1 -0
  5. package/dist/executor/index.js +8 -0
  6. package/dist/executor/index.js.map +1 -0
  7. package/dist/executor/process-executor.d.ts +93 -0
  8. package/dist/executor/process-executor.d.ts.map +1 -0
  9. package/dist/executor/process-executor.js +161 -0
  10. package/dist/executor/process-executor.js.map +1 -0
  11. package/dist/executor/timebox-controller.d.ts +109 -0
  12. package/dist/executor/timebox-controller.d.ts.map +1 -0
  13. package/dist/executor/timebox-controller.js +140 -0
  14. package/dist/executor/timebox-controller.js.map +1 -0
  15. package/dist/report/index.d.ts +8 -0
  16. package/dist/report/index.d.ts.map +1 -0
  17. package/dist/report/index.js +12 -0
  18. package/dist/report/index.js.map +1 -0
  19. package/dist/report/log-extractor.d.ts +125 -0
  20. package/dist/report/log-extractor.d.ts.map +1 -0
  21. package/dist/report/log-extractor.js +213 -0
  22. package/dist/report/log-extractor.js.map +1 -0
  23. package/dist/report/report-generator.d.ts +148 -0
  24. package/dist/report/report-generator.d.ts.map +1 -0
  25. package/dist/report/report-generator.js +261 -0
  26. package/dist/report/report-generator.js.map +1 -0
  27. package/dist/server.d.ts +27 -0
  28. package/dist/server.d.ts.map +1 -0
  29. package/dist/server.js +150 -0
  30. package/dist/server.js.map +1 -0
  31. package/dist/tools/index.d.ts +7 -0
  32. package/dist/tools/index.d.ts.map +1 -0
  33. package/dist/tools/index.js +7 -0
  34. package/dist/tools/index.js.map +1 -0
  35. package/dist/tools/run-test.d.ts +80 -0
  36. package/dist/tools/run-test.d.ts.map +1 -0
  37. package/dist/tools/run-test.js +178 -0
  38. package/dist/tools/run-test.js.map +1 -0
  39. package/dist/utils/path-validator.d.ts +52 -0
  40. package/dist/utils/path-validator.d.ts.map +1 -0
  41. package/dist/utils/path-validator.js +128 -0
  42. package/dist/utils/path-validator.js.map +1 -0
  43. package/dist/validation/command-builder.d.ts +52 -0
  44. package/dist/validation/command-builder.d.ts.map +1 -0
  45. package/dist/validation/command-builder.js +143 -0
  46. package/dist/validation/command-builder.js.map +1 -0
  47. package/dist/validation/index.d.ts +8 -0
  48. package/dist/validation/index.d.ts.map +1 -0
  49. package/dist/validation/index.js +12 -0
  50. package/dist/validation/index.js.map +1 -0
  51. package/dist/validation/input-schema.d.ts +85 -0
  52. package/dist/validation/input-schema.d.ts.map +1 -0
  53. package/dist/validation/input-schema.js +113 -0
  54. package/dist/validation/input-schema.js.map +1 -0
  55. package/package.json +57 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 入力バリデーションスキーマ(Zod)
3
+ *
4
+ * run_testツールの入力パラメータを検証する。
5
+ *
6
+ * Requirements:
7
+ * - 7.1: runnerが未指定または許可されていない値の場合エラー
8
+ * - 7.2: scopeが未指定または許可されていない値の場合エラー
9
+ * - 7.3: scope が file/pattern で target が未指定の場合エラー
10
+ * - 7.4: timeout_ms が未指定または正の整数でない場合エラー
11
+ * - 7.5: no_output_timeout_ms が未指定または正の整数でない場合エラー
12
+ * - 7.6: max_output_bytes が未指定または正の整数でない場合エラー
13
+ */
14
+ import { z } from 'zod';
15
+ /**
16
+ * 許可されたテストランナー
17
+ * MVPでは flutter のみサポート
18
+ */
19
+ export declare const ALLOWED_RUNNERS: readonly ["flutter"];
20
+ export type Runner = typeof ALLOWED_RUNNERS[number];
21
+ /**
22
+ * テスト実行スコープ
23
+ * - all: 全テスト実行
24
+ * - file: 特定ファイルのテスト実行
25
+ * - pattern: パターンマッチでテスト実行
26
+ */
27
+ export declare const ALLOWED_SCOPES: readonly ["all", "file", "pattern"];
28
+ export type Scope = typeof ALLOWED_SCOPES[number];
29
+ /**
30
+ * run_test入力スキーマ(条件付きバリデーション付き)
31
+ *
32
+ * scope が 'file' または 'pattern' の場合、target は必須
33
+ */
34
+ export declare const runTestInputSchema: z.ZodObject<{
35
+ runner: z.ZodEnum<{
36
+ flutter: "flutter";
37
+ }>;
38
+ scope: z.ZodEnum<{
39
+ all: "all";
40
+ file: "file";
41
+ pattern: "pattern";
42
+ }>;
43
+ target: z.ZodOptional<z.ZodString>;
44
+ timeout_ms: z.ZodNumber;
45
+ no_output_timeout_ms: z.ZodNumber;
46
+ max_output_bytes: z.ZodNumber;
47
+ report_dir: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>;
49
+ /**
50
+ * run_test入力の型定義
51
+ */
52
+ export type RunTestInput = z.infer<typeof runTestInputSchema>;
53
+ /**
54
+ * バリデーション結果
55
+ */
56
+ export interface ValidationResult<T> {
57
+ /** バリデーション成功かどうか */
58
+ success: boolean;
59
+ /** パース済みデータ(成功時のみ) */
60
+ data?: T;
61
+ /** エラーメッセージ(失敗時のみ) */
62
+ errors?: string[];
63
+ }
64
+ /**
65
+ * run_test入力をバリデートする
66
+ *
67
+ * @param input - 検証対象の入力
68
+ * @returns バリデーション結果
69
+ */
70
+ export declare function validateRunTestInput(input: unknown): ValidationResult<RunTestInput>;
71
+ /**
72
+ * ランナーが許可されているかチェック
73
+ *
74
+ * @param runner - チェック対象のランナー
75
+ * @returns 許可されている場合 true
76
+ */
77
+ export declare function isAllowedRunner(runner: string): runner is Runner;
78
+ /**
79
+ * スコープが許可されているかチェック
80
+ *
81
+ * @param scope - チェック対象のスコープ
82
+ * @returns 許可されている場合 true
83
+ */
84
+ export declare function isAllowedScope(scope: string): scope is Scope;
85
+ //# sourceMappingURL=input-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-schema.d.ts","sourceRoot":"","sources":["../../src/validation/input-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,eAAe,sBAAuB,CAAC;AACpD,MAAM,MAAM,MAAM,GAAG,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,qCAAsC,CAAC;AAClE,MAAM,MAAM,KAAK,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAuClD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;iBAS7B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,oBAAoB;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,sBAAsB;IACtB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAoBnF;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,MAAM,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,CAE5D"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * 入力バリデーションスキーマ(Zod)
3
+ *
4
+ * run_testツールの入力パラメータを検証する。
5
+ *
6
+ * Requirements:
7
+ * - 7.1: runnerが未指定または許可されていない値の場合エラー
8
+ * - 7.2: scopeが未指定または許可されていない値の場合エラー
9
+ * - 7.3: scope が file/pattern で target が未指定の場合エラー
10
+ * - 7.4: timeout_ms が未指定または正の整数でない場合エラー
11
+ * - 7.5: no_output_timeout_ms が未指定または正の整数でない場合エラー
12
+ * - 7.6: max_output_bytes が未指定または正の整数でない場合エラー
13
+ */
14
+ import { z } from 'zod';
15
+ /**
16
+ * 許可されたテストランナー
17
+ * MVPでは flutter のみサポート
18
+ */
19
+ export const ALLOWED_RUNNERS = ['flutter'];
20
+ /**
21
+ * テスト実行スコープ
22
+ * - all: 全テスト実行
23
+ * - file: 特定ファイルのテスト実行
24
+ * - pattern: パターンマッチでテスト実行
25
+ */
26
+ export const ALLOWED_SCOPES = ['all', 'file', 'pattern'];
27
+ /**
28
+ * 正の整数スキーマ(共通)
29
+ */
30
+ const positiveIntSchema = z.number().int().positive({
31
+ message: '正の整数である必要があります',
32
+ });
33
+ /**
34
+ * run_test入力スキーマ(基本)
35
+ */
36
+ const baseRunTestInputSchema = z.object({
37
+ /** テストランナー(MVPでは flutter のみ) */
38
+ runner: z.enum(ALLOWED_RUNNERS, {
39
+ error: `runnerは ${ALLOWED_RUNNERS.join(', ')} のいずれかである必要があります`,
40
+ }),
41
+ /** テスト実行スコープ */
42
+ scope: z.enum(ALLOWED_SCOPES, {
43
+ error: `scopeは ${ALLOWED_SCOPES.join(', ')} のいずれかである必要があります`,
44
+ }),
45
+ /** テスト対象(scope が file/pattern の場合必須) */
46
+ target: z.string().optional(),
47
+ /** ハードタイムアウト(ミリ秒) */
48
+ timeout_ms: positiveIntSchema,
49
+ /** 無出力タイムアウト(ミリ秒) */
50
+ no_output_timeout_ms: positiveIntSchema,
51
+ /** 要約対象の末尾バイト数 */
52
+ max_output_bytes: positiveIntSchema,
53
+ /** レポート出力ディレクトリ(相対パス、オプション) */
54
+ report_dir: z.string().optional(),
55
+ });
56
+ /**
57
+ * run_test入力スキーマ(条件付きバリデーション付き)
58
+ *
59
+ * scope が 'file' または 'pattern' の場合、target は必須
60
+ */
61
+ export const runTestInputSchema = baseRunTestInputSchema.superRefine((data, ctx) => {
62
+ // scope が file または pattern の場合、target は必須
63
+ if ((data.scope === 'file' || data.scope === 'pattern') && !data.target) {
64
+ ctx.addIssue({
65
+ code: z.ZodIssueCode.custom,
66
+ message: `scope が '${data.scope}' の場合、target は必須です`,
67
+ path: ['target'],
68
+ });
69
+ }
70
+ });
71
+ /**
72
+ * run_test入力をバリデートする
73
+ *
74
+ * @param input - 検証対象の入力
75
+ * @returns バリデーション結果
76
+ */
77
+ export function validateRunTestInput(input) {
78
+ const result = runTestInputSchema.safeParse(input);
79
+ if (result.success) {
80
+ return {
81
+ success: true,
82
+ data: result.data,
83
+ };
84
+ }
85
+ // エラーメッセージを抽出
86
+ const errors = result.error.issues.map((issue) => {
87
+ const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : '';
88
+ return `${path}${issue.message}`;
89
+ });
90
+ return {
91
+ success: false,
92
+ errors,
93
+ };
94
+ }
95
+ /**
96
+ * ランナーが許可されているかチェック
97
+ *
98
+ * @param runner - チェック対象のランナー
99
+ * @returns 許可されている場合 true
100
+ */
101
+ export function isAllowedRunner(runner) {
102
+ return ALLOWED_RUNNERS.includes(runner);
103
+ }
104
+ /**
105
+ * スコープが許可されているかチェック
106
+ *
107
+ * @param scope - チェック対象のスコープ
108
+ * @returns 許可されている場合 true
109
+ */
110
+ export function isAllowedScope(scope) {
111
+ return ALLOWED_SCOPES.includes(scope);
112
+ }
113
+ //# sourceMappingURL=input-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-schema.js","sourceRoot":"","sources":["../../src/validation/input-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,CAAU,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAU,CAAC;AAGlE;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;IAClD,OAAO,EAAE,gBAAgB;CAC1B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAA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I,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;IACJ,CAAC;IAED,cAAc;IACd,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACtE,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,KAAK;QACd,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAgB,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,cAAc,CAAC,QAAQ,CAAC,KAAc,CAAC,CAAC;AACjD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "mcp-test-timebox",
3
+ "version": "0.1.0",
4
+ "description": "タイムボックス付きテスト専用MCPサーバ - テスト実行が終わらない問題を防ぐ",
5
+ "type": "module",
6
+ "main": "dist/server.js",
7
+ "bin": {
8
+ "mcp-test-timebox": "dist/server.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "start": "node dist/server.js",
13
+ "dev": "tsc --watch",
14
+ "test": "vitest run",
15
+ "test:watch": "vitest",
16
+ "test:coverage": "vitest run --coverage",
17
+ "prepublishOnly": "npm run build && npm test"
18
+ },
19
+ "keywords": [
20
+ "mcp",
21
+ "model-context-protocol",
22
+ "test",
23
+ "timebox",
24
+ "flutter",
25
+ "timeout",
26
+ "test-runner"
27
+ ],
28
+ "author": "kawanishi0117",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/kawanishi0117/mcp-test-timebox.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/kawanishi0117/mcp-test-timebox/issues"
36
+ },
37
+ "homepage": "https://github.com/kawanishi0117/mcp-test-timebox#readme",
38
+ "files": [
39
+ "dist",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "engines": {
44
+ "node": ">=18.0.0"
45
+ },
46
+ "dependencies": {
47
+ "@modelcontextprotocol/sdk": "^1.25.2",
48
+ "tree-kill": "^1.2.2",
49
+ "zod": "^4.3.5"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^25.0.6",
53
+ "fast-check": "^4.5.3",
54
+ "typescript": "^5.9.3",
55
+ "vitest": "^4.0.16"
56
+ }
57
+ }