sdtk-spec-kit 0.10.0 → 0.12.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 (65) hide show
  1. package/README.md +1 -1
  2. package/assets/manifest/toolkit-bundle.manifest.json +207 -47
  3. package/assets/manifest/toolkit-bundle.sha256.txt +54 -22
  4. package/assets/toolkit/toolkit/AGENTS.md +2 -1
  5. package/assets/toolkit/toolkit/SDTK_TOOLKIT.md +5 -1
  6. package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +4 -0
  7. package/assets/toolkit/toolkit/scripts/install-claude-skills.ps1 +18 -0
  8. package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +1 -0
  9. package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +2 -2
  10. package/assets/toolkit/toolkit/skills/sdtk-ba/SKILL.md +2 -2
  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-pm/SKILL.md +1 -1
  18. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/SKILL.md +104 -0
  19. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/REVIEW_AND_MISTAKES.md +63 -0
  20. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/SCR01.json +46 -0
  21. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/SCR01.png +0 -0
  22. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/SPEC_SCHEMA.md +208 -0
  23. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/references/example_spec.yaml +115 -0
  24. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/build_design_xlsx.py +550 -0
  25. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/design_spec.py +305 -0
  26. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/export_preview.py +111 -0
  27. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/export_spec_md.py +181 -0
  28. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/make_template.py +113 -0
  29. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/test_screen_design.py +198 -0
  30. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/uia_dump.py +64 -0
  31. package/assets/toolkit/toolkit/skills/sdtk-screen-design-xlsx/scripts/validate_spec.py +260 -0
  32. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/SKILL.md +76 -0
  33. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/references/HANDOFF_TEMPLATE.md +63 -0
  34. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/references/MOVING_A_PROJECT.md +18 -0
  35. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/scripts/dirty_files.py +133 -0
  36. package/assets/toolkit/toolkit/skills/sdtk-session-handoff/scripts/test_dirty_files.py +94 -0
  37. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/SKILL.md +4 -1
  38. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/test_metadata.py +76 -0
  39. package/assets/toolkit/toolkit/skills/sdtk-xlsx-safe-edit/scripts/xlsx_xml_edit.py +65 -1
  40. package/assets/toolkit/toolkit/skills/skills.catalog.yaml +96 -0
  41. package/assets/toolkit/toolkit/skills-claude/arch/SKILL.md +15 -2
  42. package/assets/toolkit/toolkit/skills-claude/ba/SKILL.md +8 -4
  43. package/assets/toolkit/toolkit/skills-claude/customer-qa-sheet/SKILL.md +115 -0
  44. package/assets/toolkit/toolkit/skills-claude/db-design/SKILL.md +128 -0
  45. package/assets/toolkit/toolkit/skills-claude/dev/SKILL.md +33 -2
  46. package/assets/toolkit/toolkit/skills-claude/dev-backend/SKILL.md +10 -0
  47. package/assets/toolkit/toolkit/skills-claude/dev-frontend/SKILL.md +10 -0
  48. package/assets/toolkit/toolkit/skills-claude/pm/SKILL.md +14 -3
  49. package/assets/toolkit/toolkit/skills-claude/qa/SKILL.md +40 -2
  50. package/assets/toolkit/toolkit/skills-claude/screen-design-xlsx/SKILL.md +101 -0
  51. package/assets/toolkit/toolkit/skills-claude/session-handoff/SKILL.md +74 -0
  52. package/assets/toolkit/toolkit/skills-claude/test-case-spec/SKILL.md +6 -0
  53. package/assets/toolkit/toolkit/skills-claude/xlsx-safe-edit/SKILL.md +4 -1
  54. package/assets/toolkit/toolkit/templates/README.md +3 -0
  55. package/assets/toolkit/toolkit/templates/docs/database/DATABASE_SPEC_TEMPLATE.md +14 -0
  56. package/assets/toolkit/toolkit/templates/screen-design-xlsx/ja-default/TEMPLATE.md +247 -0
  57. package/assets/toolkit/toolkit/templates/screen-design-xlsx/ja-default/template.xlsx +0 -0
  58. package/package.json +1 -1
  59. package/src/commands/help.js +7 -2
  60. package/src/lib/args.js +5 -2
  61. package/src/lib/design-handoff-provenance.js +30 -5
  62. package/src/lib/office-ingest.js +376 -0
  63. package/src/lib/requirement-analysis.js +77 -41
  64. package/src/lib/requirement-sources.js +259 -0
  65. package/src/lib/scope.js +4 -4
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: screen-design-xlsx
3
+ description: Use when a Japanese 画面設計書 Excel workbook (表紙 / 改訂記事 / 機能概要 / 画面流れ / 処理) must be built, updated or reviewed from the screen flow-action spec and other sources, via a reviewable YAML spec rendered by Excel COM; also for read-only coverage audits of such a workbook. Windows + Excel + pywin32 to render.
4
+ ---
5
+
6
+ ## Input
7
+ $ARGUMENTS
8
+
9
+ # SDTK-SPEC Screen Design Workbook (画面設計書 .xlsx)
10
+
11
+ `sdtk-screen-design-spec` owns the content (screens, UI items, actions, APIs). This skill renders it into a
12
+ customer's 画面設計書 house format, through a YAML spec that is reviewed, diffed and re-rendered:
13
+
14
+ ```
15
+ flow-action spec + sources ──(you)──▶ design_spec.yaml ──(build_design_xlsx.py)──▶ .xlsx
16
+ ```
17
+
18
+ Never hand-write Excel-building code for this format; the YAML is the artifact.
19
+
20
+ **REQUIRED SUB-SKILL:** `sdtk-xlsx-safe-edit` — preflight, backup, final mode, metadata scan.
21
+
22
+ ## Critical Constraints
23
+
24
+ 1. **Rendering wipes and rebuilds each named sheet.** On an existing workbook `--sheets` is mandatory and names
25
+ only the sheets you changed; the renderer refuses otherwise.
26
+ 2. **A workbook the person finalized by hand is never re-rendered.** Mark it `workbook.final: true`; changes go
27
+ through `sdtk-xlsx-safe-edit` final mode (surgical edit + change table). A workbook that changed after this
28
+ skill's last render (render stamp beside the spec) is rendered only with `--accept-hand-edits`, after the person
29
+ confirmed the named sheets hold nothing to keep.
30
+ 3. **Never save it with `openpyxl`** (drawings vanish) and **never attach to the person's Excel** — the scripts use
31
+ a private instance (`DispatchEx`); preflight stops when the workbook or one of the same name is open.
32
+ 4. **Validate before rendering and look after it.** `validate_spec.py` exits 0; then export PNGs and read every page —
33
+ clipped shape text and overlaps are only visible in the render.
34
+ 5. **Cite real identifiers only** (API numbers, tables, columns, screen ids from the sources). Never invent one: it
35
+ survives into the customer's issue log.
36
+ 6. **Before the workbook leaves the team**, `xlsx_xml_edit.py scan-metadata <file> --name <customer> …` exits 0
37
+ (author, saved path, external links, old defined names, names in any part).
38
+
39
+ ## Inputs
40
+
41
+ - the screen flow-action spec (`sdtk-screen-design-spec`), design layout, API list, DB spec; the implementation when
42
+ the document must describe real behaviour;
43
+ - the template set: `./references/templates/screen-design-xlsx/<set>/` (`ja-default` shipped; a customer's own set in
44
+ `docs/templates/screen-design-xlsx/<set>/` of the project wins) — `TEMPLATE.md` is the format the renderer assumes;
45
+ - screenshots, and for markers either measured fractions or a UI Automation dump (`scripts/uia_dump.py`).
46
+
47
+ ## Process
48
+
49
+ 1. Read the template set's `TEMPLATE.md` and `.claude/skills/screen-design-xlsx/references/SPEC_SCHEMA.md`
50
+ (a complete fictional spec: `.claude/skills/screen-design-xlsx/references/example_spec.yaml`).
51
+ 2. Write or extend the spec YAML (default `docs/screen_design/design_spec.yaml`). Map the flow-action spec's UI item
52
+ table onto `screens[].items` (項目名 / 部品の種類 / 属性 / DBカラム / 桁数 / 初期値 / 必須 / 特記事項); one flow
53
+ block per process, detail pages for API calls and rules. Count flowchart nodes before adding one (max 6, a
54
+ decision spends two markers).
55
+ 3. `python .claude/skills/screen-design-xlsx/scripts/validate_spec.py --spec <spec>` — fix every error. It checks
56
+ shape text, annotation widths, page overflow (flow end, terminating branches, screenshot + <備考>), sub-process
57
+ and `…を参照` targets, marker ↔ item counts, UI Automation markers.
58
+ 4. **Read-only requests stop here** (audit, "is it complete?"): see
59
+ `.claude/skills/screen-design-xlsx/references/REVIEW_AND_MISTAKES.md` §1. No Excel, no render.
60
+ 5. `build_design_xlsx.py --spec <spec> --sheets <changed sheets> --check` (no Excel needed) says what would be
61
+ rendered or why not. Render — Windows + Excel:
62
+ `python .claude/skills/screen-design-xlsx/scripts/build_design_xlsx.py --spec <spec> --sheets <changed sheets>`.
63
+ It preflights, backs up to `_backup/`, renders in a private Excel, closes without saving on any error, and writes
64
+ the render stamp. A refusal names the reason (final, hand edits, missing `--sheets`): report it, do not work
65
+ around it. `--out <copy.xlsx>` renders a preview copy without touching the workbook.
66
+ 6. `python .claude/skills/screen-design-xlsx/scripts/export_preview.py --spec <spec> --sheets <same>` and read
67
+ every PNG. Iterate on the YAML until the pages are clean.
68
+ 7. Add a `改訂記事` entry for the change and render that sheet.
69
+ 8. Optional: `export_spec_md.py --spec <spec>` writes the process sheets as Markdown (Mermaid + notes) for the
70
+ architecture docs — generated, never edited by hand.
71
+
72
+ ## Numbering conventions
73
+
74
+ - `画面ID`: `<PREFIX><nn>` per screen (`SCR01`), stable forever; new screens append.
75
+ - `処理番号`: screen-driven processes reuse the screen id (`SCR03-1`); background processes get their own series
76
+ (`PRC01-1`) with the trigger in `画面名`; sub-processes append a level (`PRC01-1-1`). Never renumber a series.
77
+ - Step markers `①②③…` match the right-hand explanation list one-for-one.
78
+
79
+ ## Content conventions
80
+
81
+ - Confirmed-but-unimplemented design is still documented, prefixed `【現行未実装】…(〜の確定後)` on every sheet
82
+ that mentions it (`機能概要` included).
83
+ - Sources that disagree with each other or with the code are decisions for the person, not text to copy across.
84
+
85
+ ## When To Stop Or Escalate
86
+
87
+ - Not Windows, or no desktop Excel: stop before rendering and say so (validate / audit / Markdown still work).
88
+ - The workbook is open, final, or changed since the last render: stop and report (constraint 2).
89
+ - A flow needs more than 6 main-column nodes: split it into a parent flow + a sub-process page — ask if unsure.
90
+ - Marker positions cannot be derived from markdown: ask for a screenshot + UI Automation dump, or coordinates.
91
+
92
+ ## Scripts
93
+
94
+ | Script | Needs | Does |
95
+ |---|---|---|
96
+ | `validate_spec.py --spec` | PyYAML | schema, layout budgets, overflow, references, UIA markers |
97
+ | `build_design_xlsx.py --spec --sheets [--out] [--accept-hand-edits] [--check]` | Windows, Excel, pywin32 | render (safe-edit preflight / backup, stamp) |
98
+ | `export_preview.py --spec [--sheets] [--outdir]` | Windows, Excel | one PNG per printed page |
99
+ | `export_spec_md.py --spec [--sheet]` | PyYAML | process sheets as Markdown |
100
+ | `uia_dump.py --title --out [--inset]` | Windows, pywinauto, Pillow | screenshot + element rectangles of one window |
101
+ | `make_template.py --from --out` | Windows, Excel | blank template.xlsx for a (customer's) template set |
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: session-handoff
3
+ description: Use when a session is about to end, be compacted or hand over to a new session or another person ("wrap up", "prepare a handoff", "new phase tomorrow"), or when a project folder moved and old sessions must find it; packages memory, local instructions, a handoff document, a classification of every uncommitted file and a first prompt.
4
+ ---
5
+
6
+ ## Input
7
+ $ARGUMENTS
8
+
9
+ # SDTK Session Handoff
10
+
11
+ A new session knows only what it can read. This skill writes it down in the right places, and makes sure no
12
+ uncommitted file is lost or swept into a commit on the way.
13
+
14
+ ## Critical Constraints
15
+
16
+ 1. **Every uncommitted file gets a class before the session ends** — `PR`, `LOCAL`, `STASH` or `DROP` — in every
17
+ worktree. `dirty_files.py check` exits 0 before you say the handoff is done.
18
+ 2. **Never `git add -A` / `git add .` / `git commit -a`.** A `PR` file is staged by its own path; a `LOCAL` file is never
19
+ staged. `DROP` happens only after the person said so, and is their command to run.
20
+ 3. **The handoff document stays out of the repository** (`.sdtk/handoff/`, git-ignored). Check with
21
+ `git check-ignore` first; if it is not ignored, add it to `.git/info/exclude` — never edit the project's
22
+ `.gitignore` for this.
23
+ 4. **Memory holds durable facts only** (decisions, conventions, where things are, traps). Work in progress goes in the
24
+ handoff document; facts the repository already records (code, git history, docs) go nowhere.
25
+ 5. **Exact facts come from the source, not from a summary.** After a compaction, a summary has lost detail: copy ids,
26
+ versions, paths and commands from files, git or the transcript, and say which you could not check.
27
+ 6. **The next session starts in the same folder.** Runtime memory is keyed by the working-directory path; a different
28
+ folder (or a moved project) starts with no memory — see
29
+ `.claude/skills/session-handoff/references/MOVING_A_PROJECT.md`.
30
+
31
+ ## Process
32
+
33
+ 1. **State.** `git worktree list`; per worktree: branch, upstream, ahead / behind, open PRs if a forge CLI is signed
34
+ in. Released or published versions, running processes the next session must know about (servers, background jobs).
35
+ 2. **Uncommitted files.**
36
+ `python .claude/skills/session-handoff/scripts/dirty_files.py inventory --out .sdtk/handoff/<handoff>/FILES.md`,
37
+ fill the `class` and `note` columns (ask the person for anything you cannot place), carry out PR / STASH rows the
38
+ person agreed to, then `dirty_files.py check .sdtk/handoff/<handoff>/FILES.md` until it exits 0.
39
+ 3. **Memory.** One durable fact per entry, in the runtime's memory (for Claude Code: one file per fact plus its index
40
+ line); update an entry that exists rather than adding a second one; delete entries proven wrong. When the project
41
+ uses `sdtk-wiki` memory, promote there as well.
42
+ 4. **Handoff document** `.sdtk/handoff/<handoff>/HANDOFF.md` + `STATUS.md` from
43
+ `.claude/skills/session-handoff/references/HANDOFF_TEMPLATE.md`: worktrees, what was released, open work with
44
+ its next step, decisions waiting for the person, traps, where the evidence is.
45
+ 5. **Local instructions.** Claude Code: `CLAUDE.local.md` at the project root (git-excluded) with the "read first" list
46
+ pointing at the handoff. Other runtimes: the `.sdtk/handoff/` `STATUS.md` is what their bootstrap surfaces.
47
+ 6. **First prompt** for the new session (template §4): it makes the session summarize state from the handoff before
48
+ doing anything. When the person pastes that summary back, check it against the handoff and correct every
49
+ difference.
50
+ 7. **Keep it current.** When the state changes before the session ends, update the handoff and `FILES.md`, not only
51
+ the chat.
52
+
53
+ ## Outputs
54
+
55
+ | File | In git? | For |
56
+ |---|---|---|
57
+ | `.sdtk/handoff/<handoff>/HANDOFF.md`, `STATUS.md`, `FILES.md` | no | the next session / person |
58
+ | `CLAUDE.local.md` (Claude Code) | no (`.git/info/exclude`) | what a new session reads first |
59
+ | runtime memory entries | outside the repository | durable facts |
60
+
61
+ `<handoff>` = `session-<YYYYMMDD>-<topic>`.
62
+
63
+ ## When To Stop Or Ask
64
+
65
+ - A dirty file you cannot classify, or one that looks like someone else's work → ask; never guess `DROP`.
66
+ - A `PR` file on the wrong branch → say so; moving it is the person's call.
67
+ - Secrets in a dirty file (`.env`, keys) → class `LOCAL`, never quoted in the handoff.
68
+
69
+ ## Scripts
70
+
71
+ | Script | Does |
72
+ |---|---|
73
+ | `dirty_files.py inventory [--repo] [--out]` | table of every dirty path in every worktree, `class` empty |
74
+ | `dirty_files.py check <table> [--repo]` | exit 0 only when every path dirty now has a class (+ note for PR / STASH / DROP) |
@@ -113,3 +113,9 @@ Read at slice start:
113
113
  Read on demand:
114
114
  - `docs/specs/Q&A.md` or `docs/en/specs/Q&A.md` (when clarification is needed)
115
115
  - `governance/ai/core/SDTK_BENCHMARK_OQ_POLICY.md` (when OQ-xx items need policy guidance)
116
+
117
+ ## Specification Quoting
118
+ When a testcase, coverage note, or defect check depends on a requirement, quote the exact source text before stating coverage or mismatch.
119
+
120
+ Use this format:
121
+ - `Spec says: "[exact quote]" -> Evidence: [covered/not covered + file reference]`
@@ -122,6 +122,9 @@ of truth. Do **not** re-render it, not even one sheet, unless the person says so
122
122
  - Layout: `layout_diff(backup, result, skip_sheets=[...])` is empty for untouched sheets.
123
123
  - Content: read the written cells back; picture counts per sheet unchanged elsewhere.
124
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.
125
128
 
126
129
  ## Pitfalls seen in practice
127
130
 
@@ -135,7 +138,7 @@ of truth. Do **not** re-render it, not even one sheet, unless the person says so
135
138
  | Reading page breaks through COM (`HPageBreaks`) | Throws on some sheets | Read `row_breaks` with openpyxl (read-only) |
136
139
  | Windows paths in a heredoc script | `\` sequences mangled | Write scripts with a file tool; raw strings |
137
140
  | Screenshots for the document | Desktop corners, personal data (e-mail, tokens, user names) | Trim ~8 px; point out personal data before publishing |
138
- | Metadata of a shared template (`docProps`) | Author / company names travel with the file | Clear `dc:creator`, `cp:lastModifiedBy`, `Company` |
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 |
139
142
 
140
143
  ## Reporting
141
144
 
@@ -69,6 +69,9 @@ The script renders templates into `docs/**` and updates:
69
69
  `testcase_profile.base.json` (`"template_set"`):
70
70
  - `templates/test-case-xlsx/PROFILE_TEMPLATE.md`
71
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`)
72
75
  - Skill-specific local helper refs retained outside `templates/docs/**`:
73
76
  - `toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md`
74
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 |
@@ -0,0 +1,247 @@
1
+ # Template set `screen-design-xlsx/ja-default` — 画面設計書 workbook format
2
+
3
+ A Japanese 画面設計書 house format (表紙 / 改訂記事 / 機能概要 / 画面流れ / 処理), as reverse-engineered from a
4
+ delivered design document and its process-sheet reference page. `sdtk-screen-design-xlsx` renders into
5
+ `template.xlsx` of this folder when the target workbook does not exist yet; the renderer assumes every rule below.
6
+ A customer's own variant goes to `docs/templates/screen-design-xlsx/<set>/` in the project (same files), with
7
+ `workbook.template_set: <set>` in the spec.
8
+
9
+ ```json config
10
+ {"output_template": "template.xlsx"}
11
+ ```
12
+
13
+ ---
14
+
15
+ ## 1. The grid
16
+
17
+ `画面流れ` and `処理` are drawn on graph-paper columns, not on a normal spreadsheet:
18
+
19
+ | Property | Value |
20
+ |---|---|
21
+ | Column width, A–BI (1–61) | `2.26953125` chars ≈ 12.6 pt ≈ 0.175 in |
22
+ | Column BJ (62) | `0.26953125`, **hidden** — acts as the vertical page split |
23
+ | Column BK+ (63…) | `処理`: same 2.27 grid. `画面流れ`: named widths for the UI item table |
24
+ | Default row height | `13.5` pt, `customHeight="1"` |
25
+ | Page setup | A4 (`paperSize=9`), landscape, `pageOrder="overThenDown"` |
26
+ | Margins | l 0.591 / r 0.394 / t 0.630 / b 0.472 in, header 0, footer 0 |
27
+ | Footer | `&C&P /` (centred page number) |
28
+
29
+ Consequences you must design around:
30
+
31
+ - **One printed page = 40 rows × columns A–BI.** Anything past column BI is cut off.
32
+ - `pageOrder=overThenDown` + the hidden column break at BJ means each 40-row band prints as
33
+ *left page, then right page*. `画面流れ` uses this deliberately: screenshot page, then UI table
34
+ page. `処理` has no content past BI, so it prints one page per band.
35
+ - Row breaks are set manually at 42, 82, 122, … (i.e. **before** each block start).
36
+
37
+ ## 2. Block layout
38
+
39
+ Every block sheet repeats a fixed 40-row block. Block *k* (0-based) starts at row `3 + 40k`.
40
+
41
+ ```
42
+ row 1–2 document header (see §3) — sheet-global, not per block
43
+ row S block header: 処理番号/画面ID | value | 画面名 | value | 機能概要 | value
44
+ row S+1 (header cells are merged over S..S+1)
45
+ row S+2 … S+39 block body
46
+ ```
47
+
48
+ Header cells, with merges:
49
+
50
+ | Cell | Merge | Content |
51
+ |---|---|---|
52
+ | `A{S}` | `A{S}:C{S+1}` | label — `処理番号` (処理) or `画面ID` (画面流れ) |
53
+ | `E{S}` | `E{S}:H{S+1}` | the id, e.g. `PRC01-1` / `SCR01` |
54
+ | `I{S}` | — | label `画面名` |
55
+ | `M{S}` | `M{S}:V{S+1}` | screen / trigger context |
56
+ | `W{S}` | — | label `機能概要` |
57
+ | `AA{S}` | — | one-line summary (overflows right, unmerged) |
58
+
59
+ `A1` holds the document title `画面設計書` merged over `A1:V2`.
60
+
61
+ ## 3. Document header (rows 1–2)
62
+
63
+ | Cell | Merge | Content |
64
+ |---|---|---|
65
+ | `W1` / `W2` | `W1:Y1` / `W2:Y2` | labels `ユーザ` / `業務名` |
66
+ | `Z1` / `Z2` | `Z1:AN1` / `Z2:AN2` | customer name / business name |
67
+ | `AO1` / `AO2` | `AO1:AQ1` / `AO2:AQ2` | label `版数` / the version number |
68
+ | `AR1` / `AR2` | `AR1:AT1` / `AR2:AT2` | labels `作成者` / `作成日` |
69
+ | `AU1` / `AU2` | `AU1:AZ1` / `AU2:AZ2` | author / creation date |
70
+ | `BA1` / `BA2` | `BA1:BC1` / `BA2:BC2` | labels `更新者` / `更新日` |
71
+ | `BD1` / `BD2` | `BD1:BI1` / `BD2:BI2` | updater / update date |
72
+
73
+ `画面流れ` repeats a second copy of this header at `BK1…BW2`, because its right half is a
74
+ separate printed page.
75
+
76
+ ## 4. 処理 — flowchart pages
77
+
78
+ ### 4.1 Shapes
79
+
80
+ All native Excel autoshapes, white fill, black line, `Placement = xlMove (2)`.
81
+
82
+ | Element | Shape | Size (pt) | Column anchor |
83
+ |---|---|---|---|
84
+ | Start | `msoShapeOval` (9) | 24.75 × 28.50 | centred on the main line |
85
+ | Process | `msoShapeRectangle` (1) | **146.25 × 42.75** | left edge at column **D** |
86
+ | Decision | `msoShapeFlowchartDecision` (63) | **104 × 54** | centred on the main line |
87
+ | End | two concentric ovals (◎) | 25.50 × 28.50, inner 58% | centred on the main line |
88
+ | Arrow | `AddConnector(msoConnectorStraight=1)` | line 1.0 pt, `EndArrowheadStyle=2` | — |
89
+ | Merge | `AddConnector(msoConnectorElbow=2)` | same | branch box bottom → main line |
90
+
91
+ Main line x = `Cells(1,'D').Left + 146.25/2`. Box line weight 1.25 pt (terminators 1.5).
92
+
93
+ Text: `MS Pゴシック`, **8 pt** in boxes (left-aligned), **7 pt** in decisions (centred),
94
+ `VerticalAnchor = msoAnchorMiddle`, `WordWrap = True`, `AutoSize = none`.
95
+
96
+ **Capacity — this is the constraint that bites:**
97
+
98
+ - Process box: usable ≈ 140 pt × 42.75 pt → **≤ 4 lines × ≤ 17 full-width chars**.
99
+ - Decision diamond: a diamond paints text only in its **inscribed 50 % × 50 % rectangle**
100
+ (52 × 27 pt here) → **≤ 2 lines × ≤ 7 full-width chars**. A third line is clipped silently.
101
+ Margins are set to 0 on decisions to buy back what little room there is.
102
+
103
+ ### 4.2 Vertical rhythm
104
+
105
+ With `S` = block start row, and node index `i` counting only main-column nodes:
106
+
107
+ ```
108
+ trigger label rows S+3, S+4 (column L)
109
+ start terminator top of row S+5 (drawing row S+4)
110
+ node i marker row M = S + 7 + 5i (columns D / E)
111
+ node i shape top top of row M+1
112
+ end terminator top of row S + 7 + 5·n
113
+ "処理終了" label row S + 7 + 5·n, column L
114
+ ```
115
+
116
+ Pitch is **5 rows per node**. A 40-row block therefore holds **at most 6 main-column nodes**
117
+ (`S+7+5·6 = S+37`, terminator ends at ≈ S+39). Put the 7th step on a side branch or split the
118
+ flow into a sub-process page.
119
+
120
+ ### 4.3 Markers and labels
121
+
122
+ - Step marker `①` goes in column **D** at row `M` (one row above the box) — i.e. above-left of
123
+ the shape, never inside it (a white-filled shape hides the cell).
124
+ - A sub-process reference goes next to it in column **E**: `② PRC01-1-1`.
125
+ - For a decision the marker sits in column **E** instead (the diamond is narrower than a box).
126
+ - A decision therefore consumes **two** markers in the explanation list — the taken branch and
127
+ the fall-through — so the marker count of a block is not its node count. Budget nodes with
128
+ §4.2 (5 rows each, 6 max) and markers with §4.4 separately. Before adding a step to an
129
+ existing block, read its `nodes` list out of the spec: a block already at 5 nodes has room
130
+ for one more and nothing else.
131
+ - Branch label (taken side) → row `M+1`, column **M**, above the horizontal arrow.
132
+ - Fall-through label → row `M+4`, column **E**, left of the vertical line. Keep it short; the
133
+ merge elbow runs through the space to the right.
134
+ - Side branch box: left edge at `main_x + DEC_W/2 + 72` pt, its marker in column **S**.
135
+
136
+ ### 4.4 Right-hand explanation list
137
+
138
+ A numbered list mirroring the flowchart, starting at row `S+6`:
139
+
140
+ ```
141
+ column ac : ① ② ③ … ※
142
+ column ac + 1 : one row per line of explanation
143
+ blank row between entries
144
+ ```
145
+
146
+ Choose `ac` by how far right the flowchart reaches:
147
+
148
+ | Flow shape | `ann_col` | Text budget to column BI |
149
+ |---|---|---|
150
+ | Linear (no side branch) | `X` (24) | ≈ 52 full-width chars |
151
+ | Has a side branch | `AH` (34) | ≈ 38 full-width chars |
152
+
153
+ Exceeding the budget does not wrap — it is simply cut off at the page edge.
154
+
155
+ ## 5. 処理 — detail pages
156
+
157
+ Same header, then:
158
+
159
+ ```
160
+ row S+2 column D = sub id (PRC01-1-1), column I = sub name
161
+ row S+4 column D = "■", column E = section heading
162
+ then a bordered table and/or "・" note lines
163
+ ```
164
+
165
+ Tables: header row filled `0xD9D9D9`, thin borders on all edges and insides
166
+ (`Borders(7..12).LineStyle = xlContinuous, .Weight = xlThin`). Each logical column is a merged
167
+ run of grid columns, declared as `(title, start column, span in grid columns)`.
168
+
169
+ Note lines sit in column `F` prefixed with `・`.
170
+
171
+ A detail page holds roughly **34 usable rows** — count `1 + rows + 1` per section plus a blank
172
+ row between sections.
173
+
174
+ ## 6. 画面流れ — screen pages
175
+
176
+ Left page (A–BI):
177
+
178
+ | Row | Content |
179
+ |---|---|
180
+ | `S` | header (§2) |
181
+ | `S+2` | `A` = `Figma` (source label) |
182
+ | `S+2` | screenshot picture anchored at column A/B, width ≈ 7 258 050 EMU (≈ 571 pt) |
183
+ | overlay | markers: `msoShapeOval` **15 × 15 pt**, white fill, **red 1 pt border**, red **bold 9 pt** number, `WordWrap = False` |
184
+ | `S+30` | `A` = `<備考>` |
185
+ | `S+31…` | column `C`: `・` note (JP); optionally the next row holds a translation |
186
+
187
+ Right page (BK–BW), a bordered table pre-drawn in the template for the whole 40 rows:
188
+
189
+ | Column | Header |
190
+ |---|---|
191
+ | BK | `項目名` |
192
+ | BL | `部品の種類` |
193
+ | BM | `属性` |
194
+ | BN | `DBカラム` |
195
+ | BO | `桁数` |
196
+ | BP | `初期値` |
197
+ | BQ | `必須` |
198
+ | BR | `特記事項` |
199
+
200
+ Column `BZ` (78) is outside the styled grid and outside the printed range — the existing
201
+ document uses it for working-language translations of the `特記事項` column.
202
+
203
+ Marker coordinates cannot be derived from markdown. The spec expresses them as fractions of the
204
+ screenshot's bounding box (`x`, `y` in `0..1`), which the renderer converts to points.
205
+
206
+ ## 7. 改訂記事 / 機能概要 / 表紙
207
+
208
+ No grid, no blocks.
209
+
210
+ `改訂記事` — one entry per revision, 2 blank rows between entries:
211
+
212
+ ```
213
+ B{r} 2026年9月7日
214
+ C{r+1} ■0.03版
215
+ C{r+2} | D{r+2} ・first bullet
216
+ C{r+3} | D{r+3} ・second bullet
217
+ ```
218
+
219
+ Fonts: `MS Pゴシック` 10 pt for the date / `■版` / `|` cells, 9 pt for the bullet text in
220
+ column `D`. The renderer sets these explicitly because clearing the sheet also drops them.
221
+
222
+ `機能概要` — plain outline: heading in column `A` (`[機能概要]`), bullets in column `B`
223
+ (`・…`), continuation/detail in column `C`. No special formatting — the sheet default is used.
224
+
225
+ `表紙` — different grid (column width 2.54), scale 90 %. `H9:AQ22` merged holds the multi-line
226
+ title, `U37:AD38` holds the date.
227
+
228
+ ## 8. Round-trip hazards
229
+
230
+ - `openpyxl` **destroys all drawings** on save. Read-only inspection is fine; writing is not.
231
+ - Excel renumbers `xl/drawings/drawingN.xml` on save — never hard-code drawing part names.
232
+ - The template grid mixes 8 pt (A–AA, BD–BI) and 11 pt (AB–BC) column fonts. The renderer
233
+ forces the whole block body to 8 pt after stamping, otherwise annotation text at column AH
234
+ comes out visibly larger than the rest.
235
+ - After `.Clear()` on rows below the last block, delete those rows so the used range does not
236
+ grow every render.
237
+ - Stamping a block = `Range(A3:BX42).Copy(Cells(S,1))`, which carries values, formats and
238
+ merges. So **row 3–42 of each block sheet must always remain a clean, correct block header**;
239
+ the renderer treats it as the in-file template.
240
+ - Because the stamp carries *values* too, the first block's own content must be blanked before
241
+ stamping, otherwise re-rendering an already-populated workbook copies block 1's leftover text
242
+ into every following block. `clear_block_values()` does this: it blanks rows 4..42 plus the
243
+ three value cells on row 3 (`E3`/`M3`/`AA3`), and deliberately keeps row 3's static labels —
244
+ on `画面流れ` that row also carries the `BK3:BR3` UI item table header.
245
+ - `Range.ClearContents` refuses to act on a range that only partly covers a merged cell. Clear
246
+ through `cell.MergeArea.Cells(1,1)` instead, and select the cells with
247
+ `SpecialCells(xlCellTypeConstants)` so formats survive.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdtk-spec-kit",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "SDTK-SPEC CLI toolkit for deterministic software documentation workflows via the sdtk-spec command",
5
5
  "bin": {
6
6
  "sdtk-spec": "bin/sdtk.js"
@@ -104,7 +104,8 @@ function cmdHelp() {
104
104
  " --verbose Show detailed PowerShell script output",
105
105
  "",
106
106
  "Analyze options:",
107
- " --source <file> Customer requirement Markdown/text file (required)",
107
+ " --source <file|dir> Requirement source: text/Markdown or .docx/.xlsx/.pptx file, or a",
108
+ " directory (recursive). Repeatable; at least one required",
108
109
  " --key <KEY> Identifier, UPPER_SNAKE_CASE (required; alias: --feature-key)",
109
110
  " --name \"<text>\" Human-readable name (required; alias: --feature-name)",
110
111
  " --project-path <path> Target project directory (default: cwd)",
@@ -209,7 +210,11 @@ function cmdHelp() {
209
210
  " Output is written to docs/ subdirectories under the project path.",
210
211
  "",
211
212
  "Analyze behavior:",
212
- " The analyze command preserves a requirement source under .sdtk/spec/requirements/.",
213
+ " The analyze command preserves every requirement source under .sdtk/spec/requirements/.",
214
+ " Office files (.docx/.xlsx/.pptx) are extracted once to Markdown under extracted/<KEY>/.",
215
+ " It writes SOURCE_INDEX_<KEY>.md: each source's readable path, size and heading outline",
216
+ " with line numbers, so agents open only what a phase needs. PDF and legacy .doc/.xls/.ppt",
217
+ " are refused when named explicitly and skipped (listed in the index) inside a directory.",
213
218
  " It bootstraps the standard 17-file scaffold when missing by reusing generate behavior.",
214
219
  " It creates .sdtk/spec/tasks/<KEY>/ task packets for PM/BA/ARCH/DEV/QA agent analysis.",
215
220
  " It reports likely mojibake/encoding risk and source hash traceability.",
package/src/lib/args.js CHANGED
@@ -7,7 +7,8 @@ const { ValidationError } = require("./errors");
7
7
  * Supports: --flag value, --flag=value, --bool-flag (no value).
8
8
  *
9
9
  * @param {string[]} argv - Raw arguments (after command is stripped).
10
- * @param {Object<string, {type: 'string'|'boolean', required?: boolean, alias?: string}>} defs - Flag definitions.
10
+ * @param {Object<string, {type: 'string'|'boolean', required?: boolean, alias?: string, multiple?: boolean}>} defs - Flag definitions.
11
+ * `multiple: true` (string flags) collects every occurrence into an array (default []).
11
12
  * @returns {{ flags: Object, positional: string[] }}
12
13
  */
13
14
  function parseFlags(argv, defs) {
@@ -18,6 +19,7 @@ function parseFlags(argv, defs) {
18
19
  for (const [name, def] of Object.entries(defs)) {
19
20
  if (def.alias) aliasMap[def.alias] = name;
20
21
  if (def.type === "boolean") flags[name] = false;
22
+ else if (def.multiple) flags[name] = [];
21
23
  else flags[name] = undefined;
22
24
  }
23
25
 
@@ -65,7 +67,8 @@ function parseFlags(argv, defs) {
65
67
  }
66
68
  value = argv[i];
67
69
  }
68
- flags[resolved] = value;
70
+ if (def.multiple) flags[resolved].push(value);
71
+ else flags[resolved] = value;
69
72
  i++;
70
73
  }
71
74
  }
@@ -84,13 +84,16 @@ function validateDesignHandoffProvenance(options) {
84
84
  const handoffPath = options && options.handoffPath;
85
85
  const sourcePath = options && options.sourcePath;
86
86
  const sampleNames = options && Array.isArray(options.sampleNames) ? options.sampleNames : [];
87
+ // BK-465: with several indexed sources a screen names its readable file in
88
+ // `source_path` (project-relative, from SOURCE_INDEX); projectPath resolves it.
89
+ const projectPath = options && options.projectPath ? path.resolve(options.projectPath) : null;
87
90
 
88
91
  const violations = [];
89
92
  if (!handoffPath || !fs.existsSync(handoffPath)) {
90
93
  addViolation(violations, "(handoff)", "handoffPath", `Handoff JSON does not exist: ${handoffPath || ""}`);
91
94
  return { ok: false, code: PROVENANCE_VIOLATION, violations };
92
95
  }
93
- if (!sourcePath || !fs.existsSync(sourcePath)) {
96
+ if ((sourcePath && !fs.existsSync(sourcePath)) || (!sourcePath && !projectPath)) {
94
97
  addViolation(violations, "(source)", "sourcePath", `Requirement source does not exist: ${sourcePath || ""}`);
95
98
  return { ok: false, code: PROVENANCE_VIOLATION, violations };
96
99
  }
@@ -103,8 +106,25 @@ function validateDesignHandoffProvenance(options) {
103
106
  return { ok: false, code: PROVENANCE_VIOLATION, violations };
104
107
  }
105
108
 
106
- const sourceText = readSourceText(sourcePath);
107
- const sourceLines = sourceText.split("\n");
109
+ const defaultText = sourcePath ? readSourceText(sourcePath) : null;
110
+ const textCache = new Map();
111
+ // Returns { text } or { error } for one screen's source.
112
+ function sourceFor(screen) {
113
+ const rel = screen && typeof screen.source_path === "string" ? screen.source_path.trim() : "";
114
+ if (!rel) {
115
+ return defaultText === null
116
+ ? { error: "source_path is required when no single requirement source is given." }
117
+ : { text: defaultText };
118
+ }
119
+ if (!projectPath) return { error: "source_path needs projectPath to resolve it." };
120
+ const abs = path.resolve(projectPath, rel);
121
+ if (abs !== projectPath && !abs.startsWith(projectPath + path.sep)) {
122
+ return { error: `source_path escapes the project: ${rel}` };
123
+ }
124
+ if (!textCache.has(abs)) textCache.set(abs, fs.existsSync(abs) ? readSourceText(abs) : null);
125
+ const text = textCache.get(abs);
126
+ return text === null ? { error: `source_path does not exist: ${rel}` } : { text };
127
+ }
108
128
  const screens = extractScreens(handoff);
109
129
  const normalizedSamples = new Set(sampleNames.map(normalizedSampleName).filter(Boolean));
110
130
 
@@ -125,7 +145,12 @@ function validateDesignHandoffProvenance(options) {
125
145
  if (!title) {
126
146
  addViolation(violations, screenRef, "title", "Screen title is required.");
127
147
  }
128
- if (!quote) {
148
+ const source = sourceFor(screen);
149
+ const sourceText = source.text || "";
150
+ const sourceLines = sourceText.split("\n");
151
+ if (source.error) {
152
+ addViolation(violations, screenRef, "source_path", source.error);
153
+ } else if (!quote) {
129
154
  addViolation(violations, screenRef, "source_quote", "source_quote is required.");
130
155
  } else {
131
156
  if (codePointLength(quote) < MIN_SOURCE_QUOTE_CODE_POINTS) {
@@ -162,7 +187,7 @@ function validateDesignHandoffProvenance(options) {
162
187
  ok: violations.length === 0,
163
188
  code: violations.length === 0 ? "OK" : PROVENANCE_VIOLATION,
164
189
  handoffPath: path.resolve(handoffPath),
165
- sourcePath: path.resolve(sourcePath),
190
+ sourcePath: sourcePath ? path.resolve(sourcePath) : null,
166
191
  screenCount: screens.length,
167
192
  violations,
168
193
  };