sdtk-spec-kit 0.9.2 → 0.11.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 (88) hide show
  1. package/README.md +1 -1
  2. package/assets/manifest/toolkit-bundle.manifest.json +370 -35
  3. package/assets/manifest/toolkit-bundle.sha256.txt +84 -17
  4. package/assets/toolkit/toolkit/AGENTS.md +2 -1
  5. package/assets/toolkit/toolkit/SDTK_TOOLKIT.md +11 -3
  6. package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +7 -0
  7. package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +46 -0
  8. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +19 -0
  9. package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +1 -1
  10. package/assets/toolkit/toolkit/skills/sdtk-ba/SKILL.md +1 -1
  11. package/assets/toolkit/toolkit/skills/sdtk-customer-qa-sheet/SKILL.md +117 -0
  12. package/assets/toolkit/toolkit/skills/sdtk-customer-qa-sheet/references/PROFILE_TEMPLATE.md +60 -0
  13. package/assets/toolkit/toolkit/skills/sdtk-customer-qa-sheet/scripts/oq_sync.py +349 -0
  14. package/assets/toolkit/toolkit/skills/sdtk-customer-qa-sheet/scripts/test_oq_sync.py +175 -0
  15. package/assets/toolkit/toolkit/skills/sdtk-db-design/SKILL.md +130 -0
  16. package/assets/toolkit/toolkit/skills/sdtk-db-design/references/REVIEW_PROCESS.md +82 -0
  17. package/assets/toolkit/toolkit/skills/sdtk-orchestrator/SKILL.md +2 -0
  18. package/assets/toolkit/toolkit/skills/sdtk-qa/SKILL.md +1 -1
  19. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/SKILL.md +104 -0
  20. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/REVIEW_AND_MISTAKES.md +63 -0
  21. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/SCR01.json +46 -0
  22. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/SCR01.png +0 -0
  23. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/SPEC_SCHEMA.md +208 -0
  24. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/example_spec.yaml +115 -0
  25. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/build_design_xlsx.py +550 -0
  26. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/design_spec.py +305 -0
  27. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/export_preview.py +111 -0
  28. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/export_spec_md.py +181 -0
  29. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/make_template.py +113 -0
  30. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/test_screen_design.py +198 -0
  31. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/uia_dump.py +64 -0
  32. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/validate_spec.py +260 -0
  33. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/SKILL.md +76 -0
  34. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/references/HANDOFF_TEMPLATE.md +63 -0
  35. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/references/MOVING_A_PROJECT.md +18 -0
  36. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/scripts/dirty_files.py +133 -0
  37. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/scripts/test_dirty_files.py +94 -0
  38. package/assets/toolkit/toolkit/skills/sdtk-smoke-test-spec/SKILL.md +69 -0
  39. package/assets/toolkit/toolkit/skills/sdtk-smoke-test-spec/scripts/test_validate_smoke_test.py +58 -0
  40. package/assets/toolkit/toolkit/skills/sdtk-smoke-test-spec/scripts/validate_smoke_test.py +152 -0
  41. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/SKILL.md +297 -0
  42. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/prompts/agent_brief_template.md +59 -0
  43. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/check_coverage.py +50 -0
  44. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/extract_sources.py +224 -0
  45. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/merge_parts.py +78 -0
  46. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/render_testcase.py +421 -0
  47. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/template_set.py +57 -0
  48. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/test_write_results.py +89 -0
  49. package/assets/toolkit/toolkit/skills/sdtk-test-case-xlsx/scripts/write_results.py +126 -0
  50. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/SKILL.md +149 -0
  51. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/pictures.py +68 -0
  52. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/test_metadata.py +76 -0
  53. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/test_pictures.py +55 -0
  54. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/xlsafe.py +137 -0
  55. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/xlsx_xml_edit.py +217 -0
  56. package/assets/toolkit/toolkit/skills/skills.catalog.yaml +172 -0
  57. package/assets/toolkit/toolkit/skills-claude/arch/SKILL.md +1 -1
  58. package/assets/toolkit/toolkit/skills-claude/ba/SKILL.md +1 -1
  59. package/assets/toolkit/toolkit/skills-claude/customer-qa-sheet/SKILL.md +115 -0
  60. package/assets/toolkit/toolkit/skills-claude/db-design/SKILL.md +128 -0
  61. package/assets/toolkit/toolkit/skills-claude/orchestrator/SKILL.md +1 -1
  62. package/assets/toolkit/toolkit/skills-claude/qa/SKILL.md +1 -1
  63. package/assets/toolkit/toolkit/skills-claude/screen-design-xlsx/SKILL.md +101 -0
  64. package/assets/toolkit/toolkit/skills-claude/session-handoff/SKILL.md +74 -0
  65. package/assets/toolkit/toolkit/skills-claude/smoke-test-spec/SKILL.md +66 -0
  66. package/assets/toolkit/toolkit/skills-claude/test-case-xlsx/SKILL.md +294 -0
  67. package/assets/toolkit/toolkit/skills-claude/xlsx-safe-edit/SKILL.md +146 -0
  68. package/assets/toolkit/toolkit/templates/README.md +11 -1
  69. package/assets/toolkit/toolkit/templates/docs/database/DATABASE_SPEC_TEMPLATE.md +14 -0
  70. package/assets/toolkit/toolkit/templates/screen-design-xlsx/ja-default/TEMPLATE.md +247 -0
  71. package/assets/toolkit/toolkit/templates/screen-design-xlsx/ja-default/template.xlsx +0 -0
  72. package/assets/toolkit/toolkit/templates/smoke-test/PROFILE_TEMPLATE.md +36 -0
  73. package/assets/toolkit/toolkit/templates/smoke-test/vi-default/AUTHORING_RULES.md +32 -0
  74. package/assets/toolkit/toolkit/templates/smoke-test/vi-default/SMOKE_TEST_TEMPLATE.md +147 -0
  75. package/assets/toolkit/toolkit/templates/smoke-test/vi-default/TEMPLATE.md +25 -0
  76. package/assets/toolkit/toolkit/templates/test-case-xlsx/PROFILE_TEMPLATE.md +78 -0
  77. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/TEMPLATE.md +28 -0
  78. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/README.md +73 -0
  79. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/_template.xlsx +0 -0
  80. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/common/common.xlsx +0 -0
  81. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/mobile_app.xlsx +0 -0
  82. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/smartphone_web.xlsx +0 -0
  83. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/web.xlsx +0 -0
  84. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default/viewpoints/platform/windows_app.xlsx +0 -0
  85. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default//343/203/206/343/202/271/343/203/210/344/273/225/346/247/230/346/233/270/344/275/234/346/210/220/343/203/253/343/203/274/343/203/253.md +514 -0
  86. package/assets/toolkit/toolkit/templates/test-case-xlsx/ja-default//343/203/206/343/202/271/343/203/210/344/273/225/346/247/230/346/233/270/351/233/233/345/236/213.xlsx +0 -0
  87. package/package.json +1 -1
  88. package/src/lib/scope.js +6 -4
@@ -0,0 +1,294 @@
1
+ ---
2
+ name: test-case-xlsx
3
+ description: Use when test cases / テストケース / テスト仕様書 must be an Excel workbook from a customer's template: create or update them, convert existing smoke-test / test-case markdown into one, or write executed results (OK / NG / 保留) back. Selected by orchestration.testCaseSpecMode = xlsx; the markdown form is sdtk-test-case-spec.
4
+ ---
5
+
6
+ ## Input
7
+ $ARGUMENTS
8
+
9
+ # SDTK-SPEC Test Case Spec (Excel workbook)
10
+
11
+ Three parts, kept apart so each customer can have its own format:
12
+
13
+ ```
14
+ .claude/skills/test-case-xlsx/ (core — workflow and scripts, no project or customer content)
15
+ SKILL.md, prompts/agent_brief_template.md
16
+ scripts/template_set.py <- finds the template set (below)
17
+ scripts/extract_sources.py <- collect the viewpoints of each output sheet + dump the output template
18
+ scripts/merge_parts.py <- merge sub-agent part_*.json files into spec.json
19
+ scripts/render_testcase.py <- validate the JSON + render .md (+ --xlsx)
20
+ scripts/check_coverage.py <- check that every existing test-case ID was converted
21
+ scripts/write_results.py <- write executed results into the workbook (XML route, nothing else changes)
22
+
23
+ ./references/templates/test-case-xlsx/<set>/ (template set — replaceable per customer; default ja-default)
24
+ TEMPLATE.md <- manifest + ```json config``` (output template, columns of the results)
25
+ テスト仕様書作成ルール.md <- MANDATORY authoring rules (§1–§11) of this set
26
+ テスト仕様書雛型.xlsx <- output template
27
+ viewpoints/common | platform/<platform>.xlsx | customer/<customer>/ <- test viewpoints, see viewpoints/README.md
28
+ ./references/templates/test-case-xlsx/PROFILE_TEMPLATE.md <- template for a new project profile
29
+
30
+ <project repo>/…/testcase_profile.md (project — sources, sheets, conventions, test data)
31
+ <project repo>/…/testcase_profile.base.json (project — "template_set", cover, viewpoints selection, sheets, db_prefixes)
32
+ <project repo>/docs/templates/test-case-xlsx/<customer>/ (optional — a customer's own template set; wins over the toolkit's)
33
+ ```
34
+
35
+ Template set resolution (`scripts/template_set.py`): `--template-dir` / base.json `"template_set"` (name or path) →
36
+ `docs/templates/test-case-xlsx/<name>/` in the project → `./references/templates/test-case-xlsx/<name>/` → `$SDTK_TEMPLATES_DIR`.
37
+ A customer's own format = copy `ja-default` into the project, change the workbook / rules / viewpoints, set its name.
38
+
39
+ You **never write the markdown or Excel tables by hand**: write the test cases as JSON (green columns only);
40
+ the scripts sort by band / minor category, number the rows, fill 中分類, run the §11 self-check and render.
41
+ Run every command from the **repo root**; use `python` (Windows) or `python3` (Linux/macOS).
42
+ `S=.claude/skills/test-case-xlsx`; `T` = the resolved template set folder (printed by extract_sources.py).
43
+ `W` = a temporary working directory (the session scratchpad) for part_*.json, the brief and generator scripts —
44
+ never committed. `P` = the directory holding the project profile.
45
+
46
+ Terminology: 観点 (kanten) = test viewpoint; 大分類 / 中分類 / 小分類 = major / middle / minor category;
47
+ 帯 = band (§4-B of the rules); 正常系 / 異常系 / 境界値 = normal / abnormal / boundary.
48
+
49
+ ## Critical Constraints
50
+
51
+ 1. **Never guess.** Scope, output location, column-H check locations and authoritative test files come from the
52
+ project profile or the person; open / unconfirmed spec points become report items §11-3 / §11-4, not cases.
53
+ 2. **Never write the markdown or Excel tables by hand** and never edit the rendered `.md` / `.xlsx`: edit the JSON and
54
+ render again. `render_testcase.py` must exit 0.
55
+ 3. **Every existing case is converted** (original ID kept in column E) and checked with `check_coverage.py`.
56
+ 4. **Never save a workbook with openpyxl.** Results go in with `write_results.py` (XML route of sdtk-xlsx-safe-edit)
57
+ into the tester's latest copy only.
58
+ 5. **Cases are identified by sheet + No**, never by position; delivered cases are never renumbered.
59
+ 6. **The template set's rules file is mandatory** (`テスト仕様書作成ルール.md`); this skill only adds to it.
60
+
61
+ ## Process
62
+
63
+ 0. Locate (or create) the project profile.
64
+ 1. Read the spec sources in full.
65
+ 2. Read the existing test cases the profile lists.
66
+ 3. Read the viewpoints, rules and template (`extract_sources.py`).
67
+ 4. Write the JSON source (split across sub-agents when large).
68
+ 5. Validate and render (`render_testcase.py`, `check_coverage.py`).
69
+ 6. Report to the person (§11).
70
+ 7. Later rounds: write executed results into the workbook (`write_results.py`).
71
+
72
+ The steps in detail:
73
+
74
+ ---
75
+
76
+ ## Step 0 — Locate the project profile
77
+
78
+ Search the repo for `testcase_profile.md` (Glob `**/testcase_profile.md`). If found, read it in full; every
79
+ project-specific decision comes from it. If the user names a profile path, use that.
80
+
81
+ If none exists: copy `./references/templates/test-case-xlsx/PROFILE_TEMPLATE.md` to `<dir>/testcase_profile.md` (ask the user for `<dir>`; suggest the
82
+ folder where the test specification will be written) and create `<dir>/testcase_profile.base.json`. Fill each section
83
+ by reading the project's docs. Anything that cannot be derived from the docs (scope, output location, how results are
84
+ checked in column H, which existing test files are authoritative …) → **ask the user before writing any case**; never guess.
85
+
86
+ If the output already exists (`<output>.spec.json` in the profile) and the user only asks for an update: edit that
87
+ spec.json directly (add / remove / change cases for the changed spec or source test cases), then run Step 5 again.
88
+ Do not regenerate from scratch.
89
+
90
+ ## Step 1 — Read the spec sources (mandatory, in full)
91
+
92
+ Read every file listed under **Spec sources** in the profile (files > 25k tokens: read with `offset`/`limit`).
93
+ Always take the latest decision; ignore struck-through or "replaced by" content. Open / unconfirmed points → do not
94
+ write cases based on guesses; record them in report items §11-3 / §11-4.
95
+
96
+ ## Step 2 — Read the existing test cases (when the profile lists them)
97
+
98
+ The profile section **Existing test cases** lists existing test-case / smoke-test files and their target sheets.
99
+ They are a **mandatory source**: the team has already verified them against the real system.
100
+
101
+ - Every existing case → at least one case in the spec. Keep its original ID in column E, in the profile's format
102
+ (e.g. `REQ-7 / SCR-02 / SYNC-NF-01`), so it can be traced both ways.
103
+ - Keep the meaning of the operation and the expected result; rewrite them to the rules (§4-F numbered steps with
104
+ concrete values; §4-G verifiable results) and write them in Japanese (main) + Vietnamese.
105
+ - An existing case that the rules require to be split (one row checking things of different 大分類) → several cases
106
+ with the same original ID plus a suffix `-a`, `-b`.
107
+ - **Never** write a case that contradicts the source file's "known limitations / not a bug" section. Cases in an
108
+ "already covered by automated tests" section → follow the profile (default: leave them out, list them in §11-3).
109
+ - An existing case that contradicts the latest spec → follow the latest spec, record it in §11-4 (with the original ID).
110
+ - Rule §7.2 (use only viewpoints of the reference viewpoint set) restricts **adding cases from viewpoints**, not existing
111
+ cases — existing cases are always included.
112
+ - Two existing cases with the same content → merge into one case; column E lists both original IDs.
113
+ - An existing case that is not an operation of the system (only an environment check or tool preparation) → turn it
114
+ into `data_prep`, put its ID into `--exclude` of the coverage check, and record it in §11-3.
115
+ - A result that is neither on the screen nor in a column-H check location (e.g. a process exit code) → write it in
116
+ column G as an observable fact (e.g. 「PowerShell に `2` が表示される」).
117
+ - The source defines no message wording → column G states the observable result (dialog title, resulting screen
118
+ state); never invent wording; record it in §11-3.
119
+ - **The spec and the existing cases define the expected results.** Reading the code is allowed to get table/column
120
+ names and to detect differences; if the code differs from the spec, still write to the spec and record it in §11-4
121
+ (name the code file and quote both wordings).
122
+
123
+ ## Step 3 — Read the viewpoints, rules and template
124
+
125
+ ```bash
126
+ python $S/scripts/extract_sources.py $P/testcase_profile.base.json $W/src
127
+ ```
128
+
129
+ Using `viewpoints` (platforms, customer, customer_tags) and each sheet's `screen_types` from the base JSON, this writes
130
+ `$W/src/viewpoints/<output sheet>.tsv` — the **reference viewpoint set** of that sheet (rules §7.2), customer rows
131
+ first, then platform, then common; the first column names the source. Also `_index.tsv` (every viewpoint sheet found
132
+ and whether it was used), `_meta.txt` (non-viewpoint sheets such as the customer's rules / open questions — read them)
133
+ and `$W/src/template.txt`. Read `$T/テスト仕様書作成ルール.md` (the rules file of the template set) **in full** — the rules are mandatory; this SKILL.md
134
+ and the profile only add to them, never replace them. Check the WARN lines (screen type without viewpoints, customer
135
+ sheet not used by any output sheet) before going on.
136
+
137
+ For each output sheet, go through **every row** of its `.tsv`:
138
+ - Same check in several layers → use the most specific row only (customer > platform > common).
139
+ - Viewpoint already covered by an existing case → do not duplicate.
140
+ - Viewpoint applicable but not yet covered → create a new case (column E has the spec / screen ID, no original ID).
141
+ - Viewpoint not applicable (control does not exist, the 備考 condition 「〜のみ」 is not met) → skip.
142
+ - Viewpoint under §7.1 (px / #RRGGBB / font, hover, 過去障害あり …) → must become a case, or be reported as
143
+ "mandatory viewpoint not implemented" (未実施の必須観点).
144
+
145
+ ## Step 4 — Write the JSON source
146
+
147
+ `$W/spec.json` = `$P/testcase_profile.base.json` (cover, sheets, db_prefixes, common report_notes) + cases.
148
+
149
+ ```json
150
+ {
151
+ "cover": {"system_name": {"ja": "…", "vi": "…"}, "subsystem_name": {…}, "function_name": {…}, "related_specs": {…}},
152
+ "extra_majors": [],
153
+ "db_prefixes": ["[DB]", "[API]"],
154
+ "viewpoints": {"platforms": ["web"], "customer": "<folder under viewpoints/customer> or null", "customer_tags": ["PC"]},
155
+ "data_prep": [
156
+ {"target_screen": "共通", "category": {"ja","vi"}, "target": {"ja","vi"}, "state": {"ja","vi"}, "count": {"ja","vi"}, "method": {"ja","vi"}}
157
+ ],
158
+ "sheets": [
159
+ {"name": "01_ログイン画面", "screen_name": "ログイン画面", "screen_name_vi": "Màn hình đăng nhập",
160
+ "screen_types": ["登録・編集画面", "ダイアログ"],
161
+ "cases": [
162
+ {"major": "登録", "minor": "正常系", "spec": "REQ-1 / SCR-01 / LOGIN-NL-01",
163
+ "steps": {"ja": ["…", "…"], "vi": ["…", "…"]},
164
+ "screen": {"ja": "…", "vi": "…"},
165
+ "db": {"ja": "[DB] users.last_login_dt = 実行日時", "vi": "…"}}
166
+ ]}
167
+ ],
168
+ "report": [{"title_ja": "3. …", "title_vi": "…", "items": [{"ja": "…", "vi": "…"}]}]
169
+ }
170
+ ```
171
+
172
+ - `screen_types` (per sheet) and `viewpoints` (per project) select the reference viewpoint set (§7.2); they come from
173
+ the base JSON — change them there, not in spec.json only.
174
+ - `major` ∈ the 大分類 of §4-B (or `extra_majors: [{"ja","vi","band"}]` — placed at the end of that band; must be
175
+ reported in §11-5). `minor` ∈ `正常系 / 異常系 / 境界値`.
176
+ - `steps.*` are lists of strings, **not** numbered by you. A case-specific precondition → step 1; shared
177
+ preconditions → `data_prep`.
178
+ - No check needed in column H → `db.ja` is exactly `-(画面表示のみのため確認不要)` and `db.vi` is `""`.
179
+ If the profile defines `db_prefixes`, every line of `db.ja` must start with one prefix (one line = one check location).
180
+ - `report` = all 10 items of §11 (merge_parts.py builds it from `report_notes`). Every note starts with
181
+ 「<sheet name>:」 or 「全シート:」 so reviewers know which sheet it belongs to.
182
+ - Bilingual: `ja` is the main text, `vi` has the same meaning and the same number of steps. Never translate: UI labels
183
+ in 「」, table/column names, spec / case IDs, messages, input values. Input values must be concrete (§4-F).
184
+
185
+ **Split across sub-agents** when the total is large (> ~150 cases): follow the profile's **Work split** table, one
186
+ part per agent, run in parallel (Agent tool, `general-purpose`, background):
187
+
188
+ ```bash
189
+ sed "s#<W>#$W#g; s#<S>#$S#g; s#<T>#$T#g; s#<PROFILE>#$P/testcase_profile.md#g" $S/prompts/agent_brief_template.md > $W/AGENT_BRIEF.md
190
+ cp $P/testcase_profile.base.json $W/base.json
191
+ ```
192
+
193
+ Prompt for each agent: "read `$W/AGENT_BRIEF.md`, do part <N>: <scope from the profile>, write `$W/part_<N>.json`".
194
+ Each part: `{"sheet", "cases", "data_prep", "report_notes": [{"item": 3..10, "ja", "vi"}]}`
195
+ (several sheets: `{"parts": [...]}`). Merge:
196
+
197
+ ```bash
198
+ python $S/scripts/merge_parts.py $W/base.json $W/spec.json $W/part_*.json
199
+ ```
200
+
201
+ ## Step 5 — Validate and render
202
+
203
+ ```bash
204
+ python $S/scripts/render_testcase.py $W/spec.json --check-only
205
+ python $S/scripts/render_testcase.py $W/spec.json --md <output>.md --xlsx <output>.xlsx
206
+ cp $W/spec.json <output>.spec.json # source for later in-place updates
207
+ ```
208
+
209
+ The script prints case counts per sheet × 大分類 × 小分類 and exits non-zero on any `ERROR`: valid 大分類 / 小分類,
210
+ columns E/F/G/H not empty, column H uses the exact "no check" string or a valid prefix, same number of JA / VI steps,
211
+ banned vague phrases (`正しく` / `適切に` / `問題なく` / `任意の文字列` / `仕様どおり` … — text inside 「」 is ignored
212
+ because it is verbatim UI text), sheet names (`NN_画面名`, ≤ 31 characters), `data_prep.target_screen`.
213
+ A `WARN` about missing 異常系 / 境界値 → re-check, never ignore.
214
+
215
+ Check yourself (the script cannot): every existing case was converted — run the coverage command from the profile
216
+ (`scripts/check_coverage.py`); content matches the latest spec; G / H are concrete; no undefined numeric values
217
+ were guessed (§7.3); data_prep matches the steps.
218
+
219
+ ## Step 6 — Report to the user
220
+
221
+ Per §11: cases per sheet (大分類 × 小分類 — copy from the script output), number of data_prep items, existing
222
+ cases converted / total, then items 3–10. For an update: state which cases were added / removed / changed and why.
223
+
224
+ ---
225
+
226
+ ## Step 7 — Write executed results into the workbook
227
+
228
+ ```
229
+ python $S/scripts/write_results.py <workbook.xlsx> "<sheet>" $W/results.json [--template-dir $T]
230
+ ```
231
+
232
+ `results.json` = `{"tester", "date": "YYYY-MM-DD", "cases": {"<No>": {"result", "note", "shots", "reviewer", "reviewer_comment"}}}`.
233
+ Columns and labels come from the template set. Only that sheet's XML part changes (pictures, styles and other sheets
234
+ stay byte-identical); a `要目視` result or an unknown case No stops the write. Never save the workbook with openpyxl.
235
+ **REQUIRED BACKGROUND:** sdtk-xlsx-safe-edit (preflight, backup, "check" = read-only).
236
+
237
+ Before writing into a workbook a tester also maintains: confirm it is their latest copy (modified time, row count,
238
+ the case No column), read their comments in it, and keep cases marked for deletion as they are (status `delete`)
239
+ unless the person says to remove them.
240
+
241
+ ## Case identity
242
+
243
+ A case is identified by its sheet + No (column A) for the whole life of the workbook. Matching cases between the
244
+ workbook, spec.json, the markdown and any results file is done **by that id, never by position**: after a row is
245
+ deleted or the sheet renumbered, positional matching silently pairs the wrong cases. Do not renumber delivered cases;
246
+ append new ones and mark removed ones.
247
+ `render_testcase.py` numbers the cases from 1 on every render. Once a workbook is delivered, do not re-render it
248
+ after a deletion: change the tester's workbook only through `write_results.py` / the XML route, keep spec.json in
249
+ step, and tell the person that a re-rendered `.md` would carry different numbers than the workbook.
250
+
251
+ ## 対象外 / 未実施 analysis
252
+
253
+ When cases end as 対象外 (not applicable) or 未実施 (not run), classify each before proposing anything:
254
+ (a) the precondition cannot be set up in the real environment → describe another way to set it up (on the PC,
255
+ through the API, by a database change with the SQL attached) or propose dropping the case; (b) the expected result
256
+ does not match the product's real behaviour → propose the corrected expectation with evidence; (c) the spec is not
257
+ decided → raise it as an open question. An NG verdict names the expected item that failed.
258
+
259
+ ---
260
+
261
+ ## Adding viewpoints (customer files, new platforms)
262
+
263
+ See `$T/viewpoints/README.md`. In short: drop a customer's files into `viewpoints/customer/<name>/` of the project's copy of the template set, unchanged, run
264
+ `python $S/scripts/extract_sources.py --list` to check that every sheet was recognized (screen type + tag), add
265
+ `sheet_map.tsv` only if one was not, then set `viewpoints.customer` / `customer_tags` in the project's base JSON.
266
+ A new platform is a new `viewpoints/platform/<name>.xlsx` (start from `viewpoints/_template.xlsx`). Common and
267
+ platform files must stay project-independent (no product / customer names, no design values of a specific system).
268
+
269
+ ## Gotchas
270
+
271
+ - **report_notes end up in a document delivered to the customer / QA** → never mention "brief", "part" or "agent";
272
+ `merge_parts.py` warns when it sees those words.
273
+ - **A sub-agent stopped midway** (usage limit): do NOT spawn a new one from scratch — resume the same agent with
274
+ `SendMessage`. Have agents generate their JSON with a script `$W/gen_part<N>.py` so finished work is not lost.
275
+ - **Never edit the output `.md` / `.xlsx` by hand** — edit spec.json and render again.
276
+ - Output `.xlsx`: columns I–M, columns H–I of テストデータ準備 and the yellow cells of 表紙 stay empty for the testers (§6, §10).
277
+ - `|` inside a markdown cell is escaped by the script; a line break inside a cell becomes `<br>`. View with a Markdown preview.
278
+ - Windows: the cp1252 console cannot print Japanese → all scripts call `reconfigure(utf-8)`; any script you write
279
+ must do the same and open files with `encoding="utf-8"`.
280
+ - Never put real credentials, server URLs, IP addresses or personal e-mail addresses into the spec; use the
281
+ placeholder test data defined in the profile.
282
+
283
+ ## Troubleshooting
284
+
285
+ | Symptom | Fix |
286
+ |---|---|
287
+ | `ERROR … db.vi is empty` | Fill `db.vi`, unless `db.ja` is exactly `-(画面表示のみのため確認不要)` |
288
+ | `ERROR … 期待結果(DB) must be '-(画面表示のみのため確認不要)'` | You wrote `-` / `-` / `なし` — replace with the full string |
289
+ | `ERROR … 期待結果(DB) line '…' must start with one of […]` | Add a check-location prefix (profile `db_prefixes`) at the start of every line |
290
+ | `ERROR … banned vague phrase '正しく'` | Rewrite as a verifiable result (concrete label, value, position) |
291
+ | `ERROR … steps.ja and steps.vi have different number of steps` | The VI version must have the same number of steps as JA |
292
+ | `ERROR data_prep target_screen …` | Use `共通` or an exact sheet name |
293
+ | `UnicodeEncodeError: 'charmap'` | In your own script: `sys.stdout.reconfigure(encoding="utf-8")`, open files with `encoding="utf-8"` |
294
+ | Read tool says "exceeds maximum allowed tokens" | Continue with `offset` / `limit`, ~200–250 lines per read |
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: xlsx-safe-edit
3
+ description: Use when reading or modifying a hand-maintained .xlsx/.xlsm (manuals, specs, test-case sheets, Q&A logs, design documents) — adding sheets or rows, changing cells, inserting pictures, or updating a generated workbook the person has since edited; also when a save changed fonts, row heights or widths elsewhere. Windows + Excel + pywin32.
4
+ ---
5
+
6
+ ## Input
7
+ $ARGUMENTS
8
+
9
+ # SDTK-SPEC Safe Edits to Hand-Maintained Workbooks
10
+
11
+ People's workbooks carry pictures, shapes, hand-tuned formatting and edits made after your last
12
+ look. The failure modes are silent: the save succeeds and something the person made is gone, or
13
+ their own Excel window is disturbed. Every rule below comes from a real incident. Other SDTK skills
14
+ that write Excel (`sdtk-test-case-xlsx`, `sdtk-screen-design-xlsx`, document and Q&A sheets) write
15
+ through this skill's scripts.
16
+
17
+ ## Critical Constraints
18
+
19
+ 1. **Never save with `openpyxl`.** It drops every picture/shape/drawing on sheets it does not
20
+ rewrite. `openpyxl.load_workbook(...)` for *reading* is fine.
21
+ 2. **Never `win32com.client.Dispatch("Excel.Application")`.** When the person has Excel open,
22
+ `Dispatch` attaches to *their* instance: setting `Visible=False` hides their window and
23
+ `Quit()` closes their work. Always `DispatchEx` (a private, new instance). To merely *look*
24
+ at the person's instance use `GetActiveObject` and change nothing on it.
25
+ 3. **Never kill `EXCEL.EXE`** or close the person's workbooks. If the target is open, stop and ask
26
+ them to save and close it.
27
+ 4. **Preflight before every write:** no `~$<name>` lock file next to the target, and neither the
28
+ target nor any workbook with the same file name is open in a running Excel (Excel cannot open
29
+ two workbooks of the same name, even from different folders). A same-name workbook in another
30
+ folder is a *different file*: never switch the target to it and never edit it in the person's
31
+ open Excel — the target stays the path the person named; ask them to save and close the other one.
32
+ 5. **Back up first**, to a scratch location (`<name>.before-<change>.xlsx`).
33
+ 6. **Touch only what was asked** — and that includes layout. An Excel save rewrites the *whole
34
+ package*: a hidden instance re-resolves theme fonts (on thousands of cells), renames the Normal
35
+ style, re-measures auto-height rows and column widths on **every** sheet, rewrites comment
36
+ headers and recompresses images. Comparing values and shapes does not see this.
37
+ 7. **"Check" / "review" requests are read-only.** Open with `ReadOnly=True` or openpyxl; do not save.
38
+ 8. **Re-read the current file before each edit round.** The person edits between your rounds. Keep
39
+ the sha256 of the file you last read (`xlsafe.fingerprint`); if it changed, re-read before
40
+ editing. Locate anchors by content (a heading's text), never by remembered row numbers, and abort
41
+ if the anchor text is not where you expect.
42
+
43
+ ## Process
44
+
45
+ 1. **Classify the request.** "Check" / "review" / "is it OK" → read-only: report, save nothing, stop.
46
+ 2. **Re-read** the current file and record `xlsafe.fingerprint(path)`; locate anchors by content.
47
+ 3. **Preflight**: lock file and same-name workbook (rule 4). If it fails, say why and stop — never
48
+ close or kill anything to make it pass.
49
+ 4. **Back up** to a scratch location.
50
+ 5. **Choose the route** (table below) and write to a scratch copy first.
51
+ 6. **Verify** (section below), then copy over the target (preflight again) and compare sha256.
52
+ 7. **Report** (section at the end).
53
+
54
+ ## Choose the route
55
+
56
+ | Change | Route |
57
+ |---|---|
58
+ | Cell values, new/filled rows, row heights, extending data-validation / conditional-format ranges — in one sheet | **XML route** `.claude/skills/xlsx-safe-edit/scripts/xlsx_xml_edit.py`: rewrites only that sheet's part; every other part stays byte-identical |
59
+ | Pictures, shapes, inserted sheets, anything Excel must lay out | **COM route** `.claude/skills/xlsx-safe-edit/scripts/xlsafe.py`. After the save it diffs layout against the backup; on drift it restores the backup and raises. Accept drift only after the person agrees (`accept_layout_drift=True`) |
60
+ | A generated workbook the person has finalized by hand | **Final mode** (below): no re-render |
61
+
62
+ ### XML route
63
+
64
+ ```python
65
+ import sys
66
+ sys.path.insert(0, r".claude/skills/xlsx-safe-edit/scripts")
67
+ from xlsx_xml_edit import SheetXml, package_diff, excel_open_check
68
+
69
+ sx = SheetXml(BACKUP, "Sheet name") # read from the backup copy
70
+ sx.set_row(46, {"D": 43, "N": "line 1\nline 2"}, template_row=48, height=120)
71
+ sx.extend_ranges(old_last_row=48, new_last_row=58) # only if rows were added past the old end
72
+ sx.save(OUT) # write to scratch first
73
+ assert package_diff(BACKUP, OUT) == [sx.part]
74
+ excel_open_check(OUT, "Sheet name", ["N46"]) # private instance, read-only; fails if repaired
75
+ # then copy OUT over the target (preflight again) and compare sha256
76
+ ```
77
+
78
+ Row heights: Excel does not auto-fit on open. Measure with a COM `--dry` run (`Rows(r).AutoFit()`,
79
+ nothing saved) or copy a height of an existing row with the same line count; add a few points.
80
+
81
+ ### COM route
82
+
83
+ `open_for_edit` runs the preflight, the backup, the untouched-sheet check and the layout diff
84
+ itself — call it rather than re-implementing them (`xlsafe.preflight(path)` alone for a check).
85
+
86
+ ```python
87
+ from xlsafe import open_for_edit
88
+ with open_for_edit(PATH, touch=["New sheet"], backup_dir=SCRATCH, dry="--dry" in sys.argv) as (xl, wb):
89
+ ws = wb.Worksheets("New sheet")
90
+ ...
91
+ ```
92
+
93
+ ### Pictures under a heading (COM)
94
+
95
+ Screenshots go into the empty rows between a step's text and the next heading. A fixed gap overflows
96
+ as soon as a picture is taller than it, and the picture covers the next heading.
97
+
98
+ ```python
99
+ from pictures import rows_needed, insert_pictures_below
100
+ # pictures: [(path, width_pt), ...]; first_row: one empty row under the step text
101
+ insert_pictures_below(ws, first_row=11, next_heading_text="② …", pictures=pictures)
102
+ ```
103
+
104
+ `insert_pictures_below` finds the next heading by its text, inserts the missing rows before it,
105
+ places the pictures (`Placement = xlMove`, as hand-inserted ones), and fails if any picture's
106
+ `BottomRightCell.Row` reaches the heading. Pictures already below keep their place relative to their
107
+ own step because they move with the inserted rows.
108
+
109
+ ### Final mode — a generated workbook the person finalized by hand
110
+
111
+ When a workbook was generated (by a skill) and then edited by hand, the person's file is the source
112
+ of truth. Do **not** re-render it, not even one sheet, unless the person says so.
113
+ 1. Make the change in the generator's source (spec / YAML) so the next generation is right.
114
+ 2. Apply the same change to the person's file with the XML or COM route — only the cells / shapes
115
+ it touches.
116
+ 3. Report a change table: `sheet | cell or shape | before | after`, so the person can review or merge
117
+ by hand. If you cannot apply a change surgically, give the table and stop.
118
+
119
+ ## Verify (both routes)
120
+
121
+ - Package: `package_diff(backup, result)` lists exactly the parts you meant to change.
122
+ - Layout: `layout_diff(backup, result, skip_sheets=[...])` is empty for untouched sheets.
123
+ - Content: read the written cells back; picture counts per sheet unchanged elsewhere.
124
+ - Pictures: every picture ends above the next heading (`insert_pictures_below` checks it).
125
+ - Leaving the team (a template, a deliverable, a shared copy): `python .claude/skills/xlsx-safe-edit/scripts/xlsx_xml_edit.py
126
+ scan-metadata <file> --name <customer> --name <product> …` exits 0 — author / company fields, the saved absolute
127
+ path and the names are checked in **every** part (sharedStrings, comments, drawings, docProps), not only cell values.
128
+
129
+ ## Pitfalls seen in practice
130
+
131
+ | Situation | What goes wrong | Do instead |
132
+ |---|---|---|
133
+ | Rows added after the last formatted row | Data validation / conditional formatting stop at the old last row | `extend_ranges` (XML) or copy the template row (COM) |
134
+ | Text starting with `=`, `@`, `$`, `-` (commands, formulas shown as text) | Excel parses it as a formula | XML: inline string; COM: `NumberFormat = "@"` first |
135
+ | Adding pictures to a fixed gap of empty rows | Picture covers the next heading | `insert_pictures_below` |
136
+ | Inserting rows above existing pictures | Free-floating pictures do not move | Read `Shape.Placement`; new pictures `Placement = 2` |
137
+ | Re-rendering a generated sheet edited by hand | Their edits disappear | Final mode |
138
+ | Reading page breaks through COM (`HPageBreaks`) | Throws on some sheets | Read `row_breaks` with openpyxl (read-only) |
139
+ | Windows paths in a heredoc script | `\` sequences mangled | Write scripts with a file tool; raw strings |
140
+ | Screenshots for the document | Desktop corners, personal data (e-mail, tokens, user names) | Trim ~8 px; point out personal data before publishing |
141
+ | Metadata of a shared template or deliverable | Author / company names (`docProps`), the saved folder (`xl/workbook.xml` `x15ac:absPath`) and names in sharedStrings / comments travel with the file | Clear `dc:creator`, `cp:lastModifiedBy`, `Company`, the `absPath` element; `scan-metadata` on the result |
142
+
143
+ ## Reporting
144
+
145
+ Say which sheets/cells changed, the route used, the backup path, the package and layout diff
146
+ results, and anything you saw but did not change. If preflight failed, say why and stop.
@@ -48,7 +48,7 @@ The script renders templates into `docs/**` and updates:
48
48
 
49
49
  ## QA Orchestration Mapping
50
50
  - QA release decision/report scope: use `sdtk-qa`.
51
- - QA detailed test-case spec scope: use `sdtk-test-case-spec` (mode `testCaseSpecMode: auto|on|off`).
51
+ - QA detailed test-case spec scope: use `sdtk-test-case-spec` (mode `testCaseSpecMode: auto|on|off`); with `testCaseSpecMode: xlsx` use `sdtk-test-case-xlsx` (Excel workbook).
52
52
 
53
53
  ## Rules Used by Toolkit
54
54
  - API design/flowchart rules:
@@ -62,6 +62,16 @@ The script renders templates into `docs/**` and updates:
62
62
  - Numbering mode is fixed: global numbering across full document (no screen-level reset).
63
63
  - QA test-case spec rules:
64
64
  - `templates/docs/qa/TEST_CASE_CREATION_RULES.md`
65
+ - Smoke-test template sets (`sdtk-smoke-test-spec`), one folder per set; a project picks one in `docs/qa/smoke_test_profile.md`:
66
+ - `templates/smoke-test/PROFILE_TEMPLATE.md`
67
+ - `templates/smoke-test/vi-default/` (`TEMPLATE.md`, `AUTHORING_RULES.md`, `SMOKE_TEST_TEMPLATE.md`)
68
+ - Test-case workbook template sets (`sdtk-test-case-xlsx`), one folder per set; a project picks one in its
69
+ `testcase_profile.base.json` (`"template_set"`):
70
+ - `templates/test-case-xlsx/PROFILE_TEMPLATE.md`
71
+ - `templates/test-case-xlsx/ja-default/` (`TEMPLATE.md` manifest naming the Japanese rules file and output workbook, `viewpoints/`)
72
+ - Screen design workbook template sets (`sdtk-screen-design-xlsx`), one folder per set; a spec picks one with
73
+ `workbook.template_set` (a project's own set under `docs/templates/screen-design-xlsx/<set>/` wins):
74
+ - `templates/screen-design-xlsx/ja-default/` (`TEMPLATE.md` = the Japanese screen design format the renderer assumes, `template.xlsx`)
65
75
  - Skill-specific local helper refs retained outside `templates/docs/**`:
66
76
  - `toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md`
67
77
  - `toolkit/skills/sdtk-screen-design-spec/references/figma-mcp.md`
@@ -168,6 +168,20 @@ TABLE(app_data_example_info) {
168
168
 
169
169
  ---
170
170
 
171
+ ## 8. Fact Inventory (optional - filled by `sdtk-db-design`)
172
+
173
+ One row per current or proposed column. An empty Writer means the field is dead or planned: say which.
174
+
175
+ | Table.column | Type / example | Writer | Reader | Crash / recovery purpose | Requirement | Verdict (keep / derive / fold / defer / cut) |
176
+ | --- | --- | --- | --- | --- | --- | --- |
177
+ | app_data_example_info.example_cd | VARCHAR(20) / `EX-001` | TBD | TBD | TBD | TBD | TBD |
178
+
179
+ ### 8.1 Migration Policy
180
+ - Can any machine running this build hold data that exists nowhere else? (yes / no + precondition and expiry)
181
+ - Upgrade steps, backup through the database engine, downgrade protection.
182
+
183
+ ---
184
+
171
185
  ## Document History
172
186
 
173
187
  | No | Version | Date | Author | Changes |