@trkbt10/sier-llm-skills 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.
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2025 trkbt10
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,295 @@
1
+ # @trkbt10/sier-llm-skills
2
+
3
+ LLM (大規模言語モデル) によるブラウザ操作のスクリーンショット証跡を XLSX ファイルとして自動生成するライブラリ。MCP (Model Context Protocol) サーバーとしても動作し、Claude Desktop などの AI アシスタントから直接利用できる。
4
+
5
+ ## 特徴
6
+
7
+ - **3 つのキャプチャ戦略** - Playwright ヘッドレス / Chrome DevTools Protocol (CDP) / chrome-devtools-mcp (Google 公式 MCP)
8
+ - **操作の記録と再生** - ブラウザ操作を JSON として記録し、後から再生して証跡を再生成
9
+ - **スキーマ駆動の証跡生成** - テスト仕様書の構造を `EvidenceSheetSchema` で定義し、カスタムレイアウトの XLSX を出力
10
+ - **XLSX 読み書き** - 既存の XLSX テスト仕様書を読み取り、テスト結果やスクリーンショットを書き戻し
11
+ - **MCP サーバー** - 16 のツールを公開し、AI アシスタントがブラウザ操作・証跡生成を自律的に実行
12
+
13
+ ## インストール
14
+
15
+ ```bash
16
+ npm install @trkbt10/sier-llm-skills
17
+ ```
18
+
19
+ Playwright をキャプチャ戦略として使う場合は、peer dependency としてインストールする:
20
+
21
+ ```bash
22
+ npm install playwright
23
+ ```
24
+
25
+ ## クイックスタート
26
+
27
+ ### スクリーンショット撮影
28
+
29
+ ```typescript
30
+ import { writeFile } from "node:fs/promises";
31
+ import { createHeadlessCaptureStrategy } from "@trkbt10/sier-llm-skills";
32
+
33
+ const strategy = createHeadlessCaptureStrategy(async (opts) => {
34
+ const pw = await import("playwright");
35
+ return pw.chromium.launch({ headless: opts.headless });
36
+ });
37
+
38
+ const session = await strategy.launch({
39
+ headless: true,
40
+ viewport: { width: 1280, height: 800 },
41
+ });
42
+
43
+ try {
44
+ await session.navigate("https://example.com");
45
+ const screenshot = await session.screenshot({ fullPage: true });
46
+ await writeFile("screenshot.png", screenshot);
47
+ } finally {
48
+ await session.close();
49
+ }
50
+ ```
51
+
52
+ ### 操作記録 & 証跡 XLSX 生成
53
+
54
+ ```typescript
55
+ import { writeFile } from "node:fs/promises";
56
+ import {
57
+ createHeadlessCaptureStrategy,
58
+ createRecordingSession,
59
+ historyToEvidence,
60
+ buildEvidenceXlsx,
61
+ } from "@trkbt10/sier-llm-skills";
62
+
63
+ const strategy = createHeadlessCaptureStrategy(async (opts) => {
64
+ const pw = await import("playwright");
65
+ return pw.chromium.launch({ headless: opts.headless });
66
+ });
67
+
68
+ const viewport = { width: 1280, height: 800 };
69
+ const session = await strategy.launch({ headless: true, viewport });
70
+ const recording = createRecordingSession({ inner: session, viewport });
71
+
72
+ await recording.navigateWithStep("https://example.com", {
73
+ action: "トップページにアクセスする",
74
+ expected: "トップページが正常に表示されること",
75
+ });
76
+
77
+ await recording.screenshotWithStep({
78
+ action: "画面全体を確認する",
79
+ expected: "正常に表示されていること",
80
+ });
81
+
82
+ const history = recording.finalizeHistory("テスト名");
83
+ await recording.close();
84
+
85
+ const report = historyToEvidence(history, {
86
+ testCaseName: "テスト名",
87
+ testCaseUrl: "https://example.com",
88
+ });
89
+
90
+ const xlsx = await buildEvidenceXlsx(report);
91
+ await writeFile("evidence.xlsx", xlsx);
92
+ ```
93
+
94
+ ## サンプルの実行
95
+
96
+ `examples/` 内のサンプルはリポジトリから直接実行できる:
97
+
98
+ ```bash
99
+ # 操作記録 → 再生 → 証跡 XLSX 生成
100
+ bun run examples/record-and-replay.ts
101
+
102
+ # 既存 XLSX の読み取り・更新
103
+ bun run examples/xlsx-read-write.ts examples/fixtures/minimal.xlsx
104
+ ```
105
+
106
+ 出力は `output/` ディレクトリに保存される。生成された XLSX を Excel 等で開くと、操作手順・期待結果・確認結果とスクリーンショットが確認できる。
107
+
108
+ ### テスト仕様書フィクスチャ
109
+
110
+ [`examples/fixtures/`](./examples/fixtures/) に様々なレイアウトのテスト仕様書 XLSX を用意している。MCP サーバーの `read_test_spec` でこれらを読み取り、`generate_schema` で構造を登録することで、どんなレイアウトでも証跡ワークフローを実行できることを示す。
111
+
112
+ | ファイル | 特徴 |
113
+ |----------|------|
114
+ | `minimal.xlsx` | 証跡シートのみ、基本 4 列の最小構成 |
115
+ | `with-metadata-columns.xlsx` | 表紙 + テストケースID・実施日時・URL 列を追加した構成 |
116
+ | `header-offset.xlsx` | 上部にメタ情報があり、ヘッダーが 4 行目から始まる |
117
+ | `multi-sheet.xlsx` | 機能別に複数シートにテストケースが分散 |
118
+ | `irregular.xlsx` | 英語ヘッダー、スクリーンショット列が中間、列順が非標準 |
119
+
120
+ フィクスチャの再生成: `bun run examples/generate-fixtures.ts`
121
+
122
+
123
+ ## MCP サーバー
124
+
125
+ ### Claude Desktop での設定
126
+
127
+ `claude_desktop_config.json` に以下を追加:
128
+
129
+ ```json
130
+ {
131
+ "mcpServers": {
132
+ "evidence": {
133
+ "command": "npx",
134
+ "args": ["@trkbt10/sier-llm-skills"],
135
+ "env": {
136
+ "OUTPUT_DIR": "./evidence-output"
137
+ }
138
+ }
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### 提供ツール一覧
144
+
145
+ | ツール | 説明 |
146
+ |--------|------|
147
+ | `session_start` | ブラウザを起動し、操作記録セッションを開始する |
148
+ | `session_navigate` | 指定 URL に遷移する (自動スクリーンショット) |
149
+ | `session_click` | 要素をクリックする (自動スクリーンショット) |
150
+ | `session_type` | 要素にテキストを入力する (自動スクリーンショット) |
151
+ | `session_evaluate` | JavaScript 式を評価し、結果を返す |
152
+ | `session_screenshot` | スクリーンショットを取得する |
153
+ | `session_end` | セッションを終了し、操作履歴 JSON と XLSX 証跡を出力する |
154
+ | `recording_start` | CDP 傍受による手動操作レコーディングを開始する |
155
+ | `recording_stop` | レコーディングを停止し、操作履歴 JSON を出力する |
156
+ | `replay` | 操作履歴ファイルを再生し、XLSX 証跡を出力する |
157
+ | `build_evidence` | 操作履歴 JSON から XLSX 証跡ファイルを生成する |
158
+ | `capture_screenshot` | 指定 URL のスクリーンショットを単発撮影する |
159
+ | `read_test_spec` | XLSX テスト仕様書を読み取り、テキストとして返す |
160
+ | `write_test_result` | XLSX ファイルの指定セルに値を書き込む |
161
+ | `generate_schema` | テスト仕様書のマッピングスキーマを登録する |
162
+ | `patch_screenshots` | 既存 XLSX にスクリーンショット画像を注入する |
163
+
164
+ ### MCP ワークフロー例
165
+
166
+ AI アシスタントとの対話で以下のようなワークフローが可能:
167
+
168
+ 1. `read_test_spec` でテスト仕様書 (XLSX) を読み取る
169
+ 2. `generate_schema` で仕様書の構造をスキーマとして登録する
170
+ 3. `session_start` でブラウザセッションを開始する
171
+ 4. `session_navigate` / `session_click` / `session_type` でテスト手順を実行する
172
+ 5. `session_end` で証跡 XLSX を生成する
173
+ 6. `write_test_result` でテスト結果を仕様書に書き戻す
174
+ 7. `patch_screenshots` でスクリーンショットを仕様書に注入する
175
+
176
+ ## ライブラリ API
177
+
178
+ ### キャプチャ戦略
179
+
180
+ | 戦略 | 説明 | ユースケース |
181
+ |------|------|-------------|
182
+ | `createHeadlessCaptureStrategy` | Playwright ベースのヘッドレスブラウザ | CI/CD、自動テスト |
183
+ | `createCdpCaptureStrategy` | CDP 直接接続 | Electron アプリ、既存ブラウザ |
184
+ | `createChromeMcpCaptureStrategy` | chrome-devtools-mcp 経由 | Google 公式 MCP 連携 |
185
+
186
+ ### BrowserSession
187
+
188
+ ```typescript
189
+ type BrowserSession = {
190
+ navigate(url: string): Promise<void>;
191
+ screenshot(options?: ScreenshotOptions): Promise<Uint8Array>;
192
+ click(selector: string): Promise<void>;
193
+ type(selector: string, text: string): Promise<void>;
194
+ evaluate<T>(fn: string): Promise<T>;
195
+ close(): Promise<void>;
196
+ };
197
+ ```
198
+
199
+ ### RecordingSession
200
+
201
+ `BrowserSession` を拡張し、全操作をスクリーンショット付きで記録する:
202
+
203
+ ```typescript
204
+ const recording = createRecordingSession({ inner: session, viewport });
205
+
206
+ // テスト仕様書の操作手順・期待結果を付与して操作
207
+ await recording.navigateWithStep(url, { action: "...", expected: "..." });
208
+ await recording.clickWithStep(selector, { action: "...", expected: "..." });
209
+ await recording.typeWithStep(selector, text, { action: "...", expected: "..." });
210
+
211
+ // 操作履歴を確定
212
+ const history = recording.finalizeHistory("テスト名");
213
+ ```
214
+
215
+ ### 証跡生成
216
+
217
+ ```typescript
218
+ import { historyToEvidence, buildEvidenceXlsx } from "@trkbt10/sier-llm-skills";
219
+
220
+ const report = historyToEvidence(history, {
221
+ testCaseName: "テスト名",
222
+ testCaseUrl: "https://example.com",
223
+ });
224
+
225
+ // デフォルトレイアウトで XLSX 生成
226
+ const xlsx = await buildEvidenceXlsx(report);
227
+
228
+ // カスタムスキーマで XLSX 生成
229
+ const xlsxCustom = await buildEvidenceXlsx(report, { schema: mySchema });
230
+ ```
231
+
232
+ ### XLSX 操作
233
+
234
+ ```typescript
235
+ import {
236
+ readXlsxAsText,
237
+ formatXlsxForLlm,
238
+ updateXlsxCells,
239
+ patchXlsxWithImages,
240
+ } from "@trkbt10/sier-llm-skills";
241
+
242
+ // 読み取り
243
+ const result = await readXlsxAsText("test-spec.xlsx");
244
+ console.log(formatXlsxForLlm(result));
245
+
246
+ // セル更新
247
+ await updateXlsxCells("input.xlsx", "output.xlsx", [
248
+ { sheetName: "Sheet1", cells: [{ col: "A", row: 1, value: "OK" }] },
249
+ ]);
250
+
251
+ // 画像注入
252
+ await patchXlsxWithImages("input.xlsx", "output.xlsx", [
253
+ {
254
+ sheetName: "Evidence",
255
+ images: [{ data: pngData, contentType: "image/png", fromCol: 0, fromRow: 0, toCol: 1, toRow: 10 }],
256
+ },
257
+ ]);
258
+ ```
259
+
260
+ ### EvidenceSheetSchema
261
+
262
+ LLM がテスト仕様書の構造を解釈し、カスタムレイアウトで証跡を生成するためのスキーマ:
263
+
264
+ ```typescript
265
+ import type { EvidenceSheetSchema } from "@trkbt10/sier-llm-skills";
266
+
267
+ const schema: EvidenceSheetSchema = {
268
+ version: 1,
269
+ coverSheet: {
270
+ sheetName: "表紙",
271
+ fields: [
272
+ { label: "プロジェクト名", valuePosition: { sheet: "表紙", col: "B", row: 2 } },
273
+ ],
274
+ summary: {
275
+ okCount: { sheet: "表紙", col: "B", row: 7 },
276
+ ngCount: { sheet: "表紙", col: "B", row: 8 },
277
+ },
278
+ },
279
+ evidenceSheet: {
280
+ sheetName: "証跡",
281
+ headerRow: 1,
282
+ columns: [
283
+ { columnIndex: 1, field: "stepNumber", header: "No.", width: 6 },
284
+ { columnIndex: 2, field: "action", header: "操作手順", width: 40 },
285
+ { columnIndex: 3, field: "expected", header: "期待結果", width: 40 },
286
+ { columnIndex: 4, field: "actual", header: "確認結果", width: 40 },
287
+ ],
288
+ screenshot: { columnIndex: 5, imageRowSpan: 20 },
289
+ },
290
+ };
291
+ ```
292
+
293
+ ## ライセンス
294
+
295
+ [Apache License 2.0](./LICENSE)
@@ -0,0 +1,3 @@
1
+ import { CaptureStrategy } from '../types';
2
+ /** CDP キャプチャ戦略を生成する。 */
3
+ export declare function createCdpCaptureStrategy(): CaptureStrategy;
@@ -0,0 +1,3 @@
1
+ import { CaptureStrategy } from '../types';
2
+ /** Chrome DevTools MCP キャプチャ戦略を生成する。 */
3
+ export declare function createChromeMcpCaptureStrategy(): CaptureStrategy;
@@ -0,0 +1,45 @@
1
+ import { CaptureStrategy } from '../types';
2
+ type PlaywrightBrowser = {
3
+ newContext: (options?: {
4
+ viewport?: {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ }) => Promise<PlaywrightBrowserContext>;
9
+ close: () => Promise<void>;
10
+ };
11
+ type PlaywrightBrowserContext = {
12
+ newPage: () => Promise<PlaywrightPage>;
13
+ close: () => Promise<void>;
14
+ };
15
+ type PlaywrightPage = {
16
+ goto: (url: string, options?: {
17
+ waitUntil?: string;
18
+ timeout?: number;
19
+ }) => Promise<unknown>;
20
+ setViewportSize: (size: {
21
+ width: number;
22
+ height: number;
23
+ }) => Promise<void>;
24
+ screenshot: (options?: {
25
+ type?: string;
26
+ quality?: number;
27
+ fullPage?: boolean;
28
+ clip?: {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ };
34
+ }) => Promise<Buffer>;
35
+ evaluate: <T>(fn: string | (() => T)) => Promise<T>;
36
+ click: (selector: string) => Promise<void>;
37
+ fill: (selector: string, value: string) => Promise<void>;
38
+ close: () => Promise<void>;
39
+ };
40
+ type BrowserLauncher = (options: {
41
+ headless: boolean;
42
+ }) => Promise<PlaywrightBrowser>;
43
+ /** Headless Playwright キャプチャ戦略を生成する。 */
44
+ export declare function createHeadlessCaptureStrategy(launcher: BrowserLauncher): CaptureStrategy;
45
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file ブラウザーキャプチャの共通型定義。
3
+ * 3つの戦略 (headless, chrome-mcp, cdp) が共通して実装する。
4
+ */
5
+ export type LaunchOptions = {
6
+ readonly headless?: boolean;
7
+ readonly viewport?: Viewport;
8
+ readonly debugPort?: number;
9
+ };
10
+ export type Viewport = {
11
+ readonly width: number;
12
+ readonly height: number;
13
+ };
14
+ export type ScreenshotOptions = {
15
+ readonly format?: "png" | "jpeg" | "webp";
16
+ readonly fullPage?: boolean;
17
+ readonly clip?: ClipRegion;
18
+ readonly quality?: number;
19
+ };
20
+ export type ClipRegion = {
21
+ readonly x: number;
22
+ readonly y: number;
23
+ readonly width: number;
24
+ readonly height: number;
25
+ };
26
+ export type BrowserSession = {
27
+ navigate(url: string): Promise<void>;
28
+ screenshot(options?: ScreenshotOptions): Promise<Uint8Array>;
29
+ click(selector: string): Promise<void>;
30
+ type(selector: string, text: string): Promise<void>;
31
+ evaluate<T>(fn: string): Promise<T>;
32
+ close(): Promise<void>;
33
+ };
34
+ export type CaptureStrategy = {
35
+ readonly name: string;
36
+ launch(options?: LaunchOptions): Promise<BrowserSession>;
37
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file XLSX への画像注入。
3
+ *
4
+ * aurochs の patchWorkbook + ImagePlacement API を使って
5
+ * 既存 XLSX に画像を埋め込む。
6
+ *
7
+ * 画像のセル位置と行スパンだけ指定すれば、
8
+ * 行高さ・列幅・セル結合・DrawingML アンカーを自動算出する。
9
+ */
10
+ /** 画像挿入指定。セル位置と行スパンだけで配置を決定する。 */
11
+ export type ImageInsert = {
12
+ /** 画像データ。 */
13
+ readonly data: Uint8Array;
14
+ /** OPC content type (必須)。@see ECMA-376 Part 2, Section 10.1.2.2.1 */
15
+ readonly contentType: string;
16
+ /** 配置先の列番号 (1-based)。 */
17
+ readonly col: number;
18
+ /** 配置先の開始行番号 (1-based)。 */
19
+ readonly row: number;
20
+ /** 画像が占める行数。 */
21
+ readonly rowSpan: number;
22
+ };
23
+ /** シートへの画像挿入指定。 */
24
+ export type SheetImagePatch = {
25
+ /** シート名。 */
26
+ readonly sheetName: string;
27
+ /** 挿入する画像群。 */
28
+ readonly images: readonly ImageInsert[];
29
+ /** スクリーンショット行の高さ (pt)。省略時はデフォルト (20pt)。 */
30
+ readonly rowHeight?: number;
31
+ /** スクリーンショット列の幅 (文字数単位)。省略時はデフォルト (70)。 */
32
+ readonly colWidth?: number;
33
+ };
34
+ /** XLSX ファイルに画像を注入する。 */
35
+ export declare function patchXlsxWithImages(inputPath: string, outputPath: string, patches: readonly SheetImagePatch[]): Promise<void>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file XLSX ファイルのセル値読み取り。
3
+ *
4
+ * aurochs の parseWorkbook (簡易 API) を使って XLSX のシート内容を
5
+ * テキスト形式に変換し、LLM がテスト仕様書の構造を動的に解釈できるようにする。
6
+ */
7
+ /** シート内容のテキスト表現。 */
8
+ export type SheetText = {
9
+ readonly name: string;
10
+ readonly rows: readonly SheetRow[];
11
+ readonly maxRow: number;
12
+ readonly maxCol: string;
13
+ };
14
+ export type SheetRow = {
15
+ readonly rowNumber: number;
16
+ readonly cells: readonly SheetCell[];
17
+ };
18
+ export type SheetCell = {
19
+ readonly col: string;
20
+ readonly row: number;
21
+ readonly value: string;
22
+ };
23
+ /** XLSX 読み取り結果。 */
24
+ export type XlsxReadResult = {
25
+ readonly sheetNames: readonly string[];
26
+ readonly sheets: readonly SheetText[];
27
+ };
28
+ /** XLSX ファイルを読み取り、全シートのセル値をテキスト化する。 */
29
+ export declare function readXlsxAsText(filePath: string): Promise<XlsxReadResult>;
30
+ /** 特定シートの特定セル値を取得する。 */
31
+ export declare function readCellValue(filePath: string, sheetName: string, col: string, row: number): Promise<string | number | boolean | undefined>;
32
+ /** シート内容を LLM 向けテキストにフォーマットする。 */
33
+ export declare function formatSheetForLlm(sheet: SheetText): string;
34
+ /** 全シートを LLM 向けテキストにフォーマットする。 */
35
+ export declare function formatXlsxForLlm(result: XlsxReadResult): string;
@@ -0,0 +1,4 @@
1
+ import { CellUpdate, SheetUpdate } from 'aurochs/xlsx/builder';
2
+ export type { CellUpdate, SheetUpdate };
3
+ /** XLSX ファイルのセルを更新して保存する。 */
4
+ export declare function updateXlsxCells(inputPath: string, outputPath: string, updates: readonly SheetUpdate[]): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { EvidenceSheetSchema } from './types';
2
+ /** EvidenceSheetSchema のランタイムバリデーション。 */
3
+ export declare function validateEvidenceSheetSchema(input: unknown): EvidenceSheetSchema;