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,76 @@
1
+ ---
2
+ name: sdtk-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
+ # SDTK Session Handoff
7
+
8
+ A new session knows only what it can read. This skill writes it down in the right places, and makes sure no
9
+ uncommitted file is lost or swept into a commit on the way.
10
+
11
+ <!-- neutral-only -->
12
+ > **Installed as a runtime skill** (for example under `.codex/skills/`): read `toolkit/skills/sdtk-session-handoff/`
13
+ > in the paths below as this skill's installed folder.
14
+ <!-- /neutral-only -->
15
+
16
+ ## Critical Constraints
17
+
18
+ 1. **Every uncommitted file gets a class before the session ends** — `PR`, `LOCAL`, `STASH` or `DROP` — in every
19
+ worktree. `dirty_files.py check` exits 0 before you say the handoff is done.
20
+ 2. **Never `git add -A` / `git add .` / `git commit -a`.** A `PR` file is staged by its own path; a `LOCAL` file is never
21
+ staged. `DROP` happens only after the person said so, and is their command to run.
22
+ 3. **The handoff document stays out of the repository** (`.sdtk/handoff/`, git-ignored). Check with
23
+ `git check-ignore` first; if it is not ignored, add it to `.git/info/exclude` — never edit the project's
24
+ `.gitignore` for this.
25
+ 4. **Memory holds durable facts only** (decisions, conventions, where things are, traps). Work in progress goes in the
26
+ handoff document; facts the repository already records (code, git history, docs) go nowhere.
27
+ 5. **Exact facts come from the source, not from a summary.** After a compaction, a summary has lost detail: copy ids,
28
+ versions, paths and commands from files, git or the transcript, and say which you could not check.
29
+ 6. **The next session starts in the same folder.** Runtime memory is keyed by the working-directory path; a different
30
+ folder (or a moved project) starts with no memory — see
31
+ `toolkit/skills/sdtk-session-handoff/references/MOVING_A_PROJECT.md`.
32
+
33
+ ## Process
34
+
35
+ 1. **State.** `git worktree list`; per worktree: branch, upstream, ahead / behind, open PRs if a forge CLI is signed
36
+ in. Released or published versions, running processes the next session must know about (servers, background jobs).
37
+ 2. **Uncommitted files.**
38
+ `python toolkit/skills/sdtk-session-handoff/scripts/dirty_files.py inventory --out .sdtk/handoff/<handoff>/FILES.md`,
39
+ fill the `class` and `note` columns (ask the person for anything you cannot place), carry out PR / STASH rows the
40
+ person agreed to, then `dirty_files.py check .sdtk/handoff/<handoff>/FILES.md` until it exits 0.
41
+ 3. **Memory.** One durable fact per entry, in the runtime's memory (for Claude Code: one file per fact plus its index
42
+ line); update an entry that exists rather than adding a second one; delete entries proven wrong. When the project
43
+ uses `sdtk-wiki` memory, promote there as well.
44
+ 4. **Handoff document** `.sdtk/handoff/<handoff>/HANDOFF.md` + `STATUS.md` from
45
+ `toolkit/skills/sdtk-session-handoff/references/HANDOFF_TEMPLATE.md`: worktrees, what was released, open work with
46
+ its next step, decisions waiting for the person, traps, where the evidence is.
47
+ 5. **Local instructions.** Claude Code: `CLAUDE.local.md` at the project root (git-excluded) with the "read first" list
48
+ pointing at the handoff. Other runtimes: the `.sdtk/handoff/` `STATUS.md` is what their bootstrap surfaces.
49
+ 6. **First prompt** for the new session (template §4): it makes the session summarize state from the handoff before
50
+ doing anything. When the person pastes that summary back, check it against the handoff and correct every
51
+ difference.
52
+ 7. **Keep it current.** When the state changes before the session ends, update the handoff and `FILES.md`, not only
53
+ the chat.
54
+
55
+ ## Outputs
56
+
57
+ | File | In git? | For |
58
+ |---|---|---|
59
+ | `.sdtk/handoff/<handoff>/HANDOFF.md`, `STATUS.md`, `FILES.md` | no | the next session / person |
60
+ | `CLAUDE.local.md` (Claude Code) | no (`.git/info/exclude`) | what a new session reads first |
61
+ | runtime memory entries | outside the repository | durable facts |
62
+
63
+ `<handoff>` = `session-<YYYYMMDD>-<topic>`.
64
+
65
+ ## When To Stop Or Ask
66
+
67
+ - A dirty file you cannot classify, or one that looks like someone else's work → ask; never guess `DROP`.
68
+ - A `PR` file on the wrong branch → say so; moving it is the person's call.
69
+ - Secrets in a dirty file (`.env`, keys) → class `LOCAL`, never quoted in the handoff.
70
+
71
+ ## Scripts
72
+
73
+ | Script | Does |
74
+ |---|---|
75
+ | `dirty_files.py inventory [--repo] [--out]` | table of every dirty path in every worktree, `class` empty |
76
+ | `dirty_files.py check <table> [--repo]` | exit 0 only when every path dirty now has a class (+ note for PR / STASH / DROP) |
@@ -0,0 +1,63 @@
1
+ # Handoff templates
2
+
3
+ ## 1. STATUS.md
4
+
5
+ First line is the state; the body says what the next session does first.
6
+
7
+ ```
8
+ WAITING_NEXT_SESSION
9
+ Read HANDOFF.md, then FILES.md. First action: <one line>. Waiting on the person for: <decision or none>.
10
+ ```
11
+
12
+ States: `WAITING_NEXT_SESSION` (open), `ON_HOLD` (person paused it), `DONE` (picked up and closed).
13
+
14
+ ## 2. HANDOFF.md
15
+
16
+ ```markdown
17
+ # Handoff — <topic> (<YYYY-MM-DD>)
18
+
19
+ ## Where things are
20
+ | Worktree | Branch | Upstream / PR | State |
21
+ |---|---|---|---|
22
+ | /path/app | main | origin/main, clean | — |
23
+ | /path/app-feat | feat/x | PR #12 open, 2 ahead | waiting for review |
24
+
25
+ ## Released / published
26
+ - <package / deploy> <version> on <date> — verified by <command>.
27
+
28
+ ## Open work (next step first)
29
+ 1. <item> — next: <command or action>; done when: <observable result>.
30
+
31
+ ## Waiting for the person
32
+ - <decision> — options, your recommendation.
33
+
34
+ ## Traps
35
+ - <thing that cost time and how to avoid it>.
36
+
37
+ ## Evidence
38
+ - <reports, logs, test output paths>. Facts not re-checked after compaction: <list or none>.
39
+
40
+ ## Uncommitted files
41
+ See FILES.md (`dirty_files.py check` exit 0 at <time>).
42
+ ```
43
+
44
+ ## 3. CLAUDE.local.md (Claude Code, git-excluded)
45
+
46
+ ```markdown
47
+ # Local notes (this machine only)
48
+ Read first: `.sdtk/handoff/<handoff>/STATUS.md`, then `HANDOFF.md`.
49
+ Open sessions in <project path> (memory is keyed by this path).
50
+ ```
51
+
52
+ Exclude it: `echo CLAUDE.local.md >> .git/info/exclude` (check `git check-ignore -v CLAUDE.local.md` first).
53
+
54
+ ## 4. First prompt for the new session
55
+
56
+ ```
57
+ Read .sdtk/handoff/<handoff>/STATUS.md and HANDOFF.md, then FILES.md. Before doing anything else, reply with:
58
+ 1. each worktree, its branch and state; 2. what was released; 3. the open work in order with the next step;
59
+ 4. what waits for me; 5. the uncommitted files that are LOCAL or STASH. Do not change anything until I confirm.
60
+ ```
61
+
62
+ Checking the answer: every worktree, version and next step must match HANDOFF.md word for word where it names ids,
63
+ versions or paths. A missing or different item → point at the line in HANDOFF.md and ask for a corrected summary.
@@ -0,0 +1,18 @@
1
+ # Moving a project folder (resuming old sessions)
2
+
3
+ Agent runtimes key their session history and memory by the project path. After the project moves (new machine, new
4
+ drive, renamed folder), a new session in the new folder sees none of it. The runtime's store is its own private
5
+ format, so this is a manual, careful procedure — not something to script blindly.
6
+
7
+ 1. **Back up** the runtime's session folder for the old path (Claude Code: `~/.claude/projects/<encoded old path>/`,
8
+ where the path is encoded by replacing path separators and other non-alphanumeric characters with `-`).
9
+ 2. **Dry run.** List every occurrence of the old path in the session logs (`grep -c`), separating fields that *are*
10
+ the working directory (`"cwd"` and similar) from text inside tool results or messages that merely mention it.
11
+ 3. **Rewrite only the working-directory fields** in a copy, never the content of tool results or messages. Prefer the
12
+ simplest form: if the person only needs memory, copy the memory folder and leave the logs alone.
13
+ 4. **Rename** the copied folder to the encoded new path; keep the backup until a resumed session works.
14
+ 5. **Resume** from the new folder (Claude Code: `claude --resume` there) and check one past session opens with the
15
+ right working directory.
16
+
17
+ The backup location is the person's choice — ask; never assume a personal folder. When in doubt, start a new session
18
+ with a handoff (this skill) instead of moving history.
@@ -0,0 +1,133 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Inventory and classification check of uncommitted files, for a session handoff.
3
+
4
+ python dirty_files.py inventory [--repo .] [--out HANDOFF_FILES.md] # every worktree, every dirty path
5
+ python dirty_files.py check HANDOFF_FILES.md [--repo .] # every dirty path classified, nothing extra
6
+
7
+ `inventory` writes a Markdown table with an empty `class` column, one row per dirty path of every worktree of the
8
+ repository (`git worktree list`). The session fills `class` with one of:
9
+
10
+ PR goes into a commit / pull request (name the branch in `note`)
11
+ LOCAL stays on this machine, never committed (put it in .git/info/exclude if it keeps showing up)
12
+ STASH parked with `git stash push -- <path>` (name the stash message in `note`)
13
+ DROP to be discarded — only after the person said so (`note`: who / when)
14
+
15
+ `check` exits 0 only when every path that is dirty *now* has a class from that list, and lists paths that became
16
+ dirty or clean since the inventory. It never stages, stashes or deletes anything: the commands stay the person's.
17
+ No `git add -A` — a PR row is staged by its own path.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import os
23
+ import re
24
+ import subprocess
25
+ import sys
26
+
27
+ CLASSES = ("PR", "LOCAL", "STASH", "DROP")
28
+ ROW_RE = re.compile(r"^\|\s*`(?P<wt>[^`]*)`\s*\|\s*`(?P<path>[^`]+)`\s*\|\s*(?P<st>[^|]*)\|\s*(?P<cls>[^|]*)\|(?P<note>.*)\|\s*$")
29
+
30
+
31
+ def git(repo: str, *args: str) -> str:
32
+ env = {**os.environ, "GIT_TERMINAL_PROMPT": "0", "GIT_OPTIONAL_LOCKS": "0"}
33
+ r = subprocess.run(["git", "-C", repo, *args], capture_output=True, text=True, encoding="utf-8", env=env,
34
+ timeout=60, check=False)
35
+ if r.returncode != 0:
36
+ raise SystemExit("git %s failed in %s: %s" % (" ".join(args), repo, r.stderr.strip()))
37
+ return r.stdout
38
+
39
+
40
+ def worktrees(repo: str) -> list:
41
+ out, paths = git(repo, "worktree", "list", "--porcelain"), []
42
+ for line in out.splitlines():
43
+ if line.startswith("worktree "):
44
+ paths.append(line[len("worktree "):])
45
+ return [p for p in paths if os.path.isdir(p)]
46
+
47
+
48
+ def dirty(wt: str) -> list:
49
+ """(status, path) for every changed, staged or untracked path; ignored files are not listed."""
50
+ out = git(wt, "status", "--porcelain=v1", "-z", "--untracked-files=all")
51
+ items, parts, i = [], out.split("\0"), 0
52
+ while i < len(parts):
53
+ entry = parts[i]
54
+ i += 1
55
+ if not entry:
56
+ continue
57
+ status, path = entry[:2], entry[3:]
58
+ if status[0] in "RC": # rename / copy: the next field is the source path
59
+ path = "%s (from %s)" % (path, parts[i])
60
+ i += 1
61
+ items.append((status.replace(" ", "."), path))
62
+ return items
63
+
64
+
65
+ def snapshot(repo: str) -> dict:
66
+ main = os.path.realpath(worktrees(repo)[0]) if worktrees(repo) else os.path.realpath(repo)
67
+ snap = {}
68
+ for wt in worktrees(repo):
69
+ label = "." if os.path.realpath(wt) == main else os.path.relpath(os.path.realpath(wt), os.path.dirname(main))
70
+ for status, path in dirty(wt):
71
+ snap[(label, path)] = status
72
+ return snap
73
+
74
+
75
+ def inventory(repo: str) -> str:
76
+ snap = snapshot(repo)
77
+ branch = {}
78
+ for wt in worktrees(repo):
79
+ branch[wt] = git(wt, "branch", "--show-current").strip() or "(detached)"
80
+ lines = ["# Uncommitted files", "",
81
+ "Worktrees: " + "; ".join("`%s` on `%s`" % (w, b) for w, b in branch.items()), "",
82
+ "Fill `class` with PR / LOCAL / STASH / DROP (see dirty_files.py). Then `dirty_files.py check` this file.", "",
83
+ "| worktree | path | status | class | note |", "|---|---|---|---|---|"]
84
+ for (wt, path), status in sorted(snap.items()):
85
+ lines.append("| `%s` | `%s` | %s | | |" % (wt, path, status))
86
+ if not snap:
87
+ lines.append("| | | | | nothing uncommitted |")
88
+ return "\n".join(lines) + "\n"
89
+
90
+
91
+ def check(repo: str, table: str) -> tuple[int, list]:
92
+ rows = {}
93
+ with open(table, encoding="utf-8") as f:
94
+ for line in f:
95
+ m = ROW_RE.match(line.strip())
96
+ if m:
97
+ rows[(m["wt"], m["path"])] = (m["cls"].strip().upper(), m["note"].strip())
98
+ now = snapshot(repo)
99
+ problems = []
100
+ for key in sorted(now):
101
+ if key not in rows:
102
+ problems.append("not in the table (became dirty after the inventory): %s %s" % key)
103
+ elif rows[key][0] not in CLASSES:
104
+ problems.append("no class: %s %s" % key)
105
+ elif rows[key][0] in ("PR", "STASH", "DROP") and not rows[key][1]:
106
+ problems.append("%s needs a note (branch / stash message / who said so): %s %s" % ((rows[key][0],) + key))
107
+ for key in sorted(set(rows) - set(now)):
108
+ problems.append("in the table but no longer dirty (committed, stashed or reverted?): %s %s" % key)
109
+ return (0 if not problems else 1), problems
110
+
111
+
112
+ def main(argv=None) -> int:
113
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
114
+ sub = ap.add_subparsers(dest="cmd", required=True)
115
+ p = sub.add_parser("inventory"); p.add_argument("--repo", default="."); p.add_argument("--out")
116
+ p = sub.add_parser("check"); p.add_argument("table"); p.add_argument("--repo", default=".")
117
+ args = ap.parse_args(argv)
118
+ if args.cmd == "inventory":
119
+ text = inventory(args.repo)
120
+ if args.out:
121
+ with open(args.out, "w", encoding="utf-8") as f:
122
+ f.write(text)
123
+ print("%s (%d dirty paths)" % (args.out, text.count("\n| `")))
124
+ else:
125
+ sys.stdout.write(text)
126
+ return 0
127
+ code, problems = check(args.repo, args.table)
128
+ print("\n".join(problems) if problems else "every dirty path is classified")
129
+ return code
130
+
131
+
132
+ if __name__ == "__main__":
133
+ sys.exit(main())
@@ -0,0 +1,94 @@
1
+ # -*- coding: utf-8 -*-
2
+ """dirty_files.py against a throw-away repository with a second worktree."""
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ import unittest
11
+
12
+ HERE = os.path.dirname(os.path.abspath(__file__))
13
+ sys.path.insert(0, HERE)
14
+ import dirty_files # noqa: E402
15
+
16
+
17
+ def sh(cwd, *args):
18
+ subprocess.run(args, cwd=cwd, check=True, capture_output=True)
19
+
20
+
21
+ class DirtyFilesTests(unittest.TestCase):
22
+ def setUp(self):
23
+ self.tmp = tempfile.mkdtemp()
24
+ self.repo = os.path.join(self.tmp, "app")
25
+ os.makedirs(self.repo)
26
+ sh(self.repo, "git", "init", "-q", "-b", "main")
27
+ sh(self.repo, "git", "config", "user.email", "a@example.invalid")
28
+ sh(self.repo, "git", "config", "user.name", "A")
29
+ for name in ("a.py", "b.py", ".gitignore"):
30
+ with open(os.path.join(self.repo, name), "w") as f:
31
+ f.write("x\n" if name != ".gitignore" else "*.log\n")
32
+ sh(self.repo, "git", "add", "-A")
33
+ sh(self.repo, "git", "commit", "-qm", "init")
34
+ sh(self.repo, "git", "worktree", "add", "-q", "-b", "feat", os.path.join(self.tmp, "app-feat"))
35
+ with open(os.path.join(self.repo, "a.py"), "a") as f:
36
+ f.write("change\n")
37
+ with open(os.path.join(self.repo, "notes.md"), "w") as f:
38
+ f.write("mine\n")
39
+ with open(os.path.join(self.repo, "run.log"), "w") as f:
40
+ f.write("ignored\n")
41
+ with open(os.path.join(self.tmp, "app-feat", "b.py"), "a") as f:
42
+ f.write("wip\n")
43
+ self.table = os.path.join(self.tmp, "FILES.md")
44
+
45
+ def tearDown(self):
46
+ shutil.rmtree(self.tmp, ignore_errors=True)
47
+
48
+ def fill(self, mapping):
49
+ with open(self.table, encoding="utf-8") as f:
50
+ text = f.read()
51
+ for path, (cls, note) in mapping.items():
52
+ text = text.replace("| `%s` | .M | | |" % path, "| `%s` | .M | %s | %s |" % (path, cls, note))
53
+ text = text.replace("| `%s` | ?? | | |" % path, "| `%s` | ?? | %s | %s |" % (path, cls, note))
54
+ with open(self.table, "w", encoding="utf-8") as f:
55
+ f.write(text)
56
+
57
+ def test_inventory_covers_every_worktree_and_skips_ignored_files(self):
58
+ dirty_files.main(["inventory", "--repo", self.repo, "--out", self.table])
59
+ with open(self.table, encoding="utf-8") as f:
60
+ text = f.read()
61
+ self.assertIn("| `.` | `a.py` | .M |", text)
62
+ self.assertIn("| `.` | `notes.md` | ?? |", text)
63
+ self.assertIn("| `app-feat` | `b.py` | .M |", text)
64
+ self.assertNotIn("run.log", text)
65
+ self.assertIn("on `feat`", text)
66
+
67
+ def test_check_needs_a_class_for_every_path_and_notes_where_they_matter(self):
68
+ dirty_files.main(["inventory", "--repo", self.repo, "--out", self.table])
69
+ code, problems = dirty_files.check(self.repo, self.table)
70
+ self.assertEqual(code, 1)
71
+ self.assertEqual(len([p for p in problems if p.startswith("no class")]), 3)
72
+ self.fill({"a.py": ("PR", ""), "notes.md": ("LOCAL", ""), "b.py": ("STASH", "wip on feat")})
73
+ code, problems = dirty_files.check(self.repo, self.table)
74
+ self.assertEqual(problems, ["PR needs a note (branch / stash message / who said so): . a.py"])
75
+ with open(self.table, encoding="utf-8") as f:
76
+ text = f.read().replace("| `a.py` | .M | PR | |", "| `a.py` | .M | PR | branch fix/a |")
77
+ with open(self.table, "w", encoding="utf-8") as f:
78
+ f.write(text)
79
+ self.assertEqual(dirty_files.check(self.repo, self.table), (0, []))
80
+
81
+ def test_check_sees_paths_that_changed_since_the_inventory(self):
82
+ dirty_files.main(["inventory", "--repo", self.repo, "--out", self.table])
83
+ self.fill({"a.py": ("PR", "fix/a"), "notes.md": ("LOCAL", ""), "b.py": ("STASH", "wip")})
84
+ with open(os.path.join(self.repo, "new.py"), "w") as f:
85
+ f.write("late\n")
86
+ sh(self.repo, "git", "checkout", "--", "a.py")
87
+ code, problems = dirty_files.check(self.repo, self.table)
88
+ self.assertEqual(code, 1)
89
+ self.assertIn("not in the table (became dirty after the inventory): . new.py", problems)
90
+ self.assertIn("in the table but no longer dirty (committed, stashed or reverted?): . a.py", problems)
91
+
92
+
93
+ if __name__ == "__main__":
94
+ unittest.main()
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: sdtk-smoke-test-spec
3
+ description: Use when writing or updating a manual smoke-test / acceptance-test document (kịch bản kiểm thử, スモークテスト) for one feature or task, before the feature is fully implemented or after a spec change, when the cases must trace to the customer's spec and later be run by testers or by an automation runner keyed by case id.
4
+ ---
5
+
6
+ # SDTK-SPEC Smoke Test Spec
7
+
8
+ One markdown file per feature/task, cases grouped UI / FN / ER / BV / RG, every case traceable to a spec source,
9
+ expected results limited to what a tester can see. The file is also the input of automation runners (they read the
10
+ case ids of section 4), so its structure is checked by a script, not by eye.
11
+
12
+ <!-- neutral-only -->
13
+ > **Installed as a runtime skill** (for example under `.codex/skills/`): read `toolkit/skills/sdtk-<name>/` in the
14
+ > paths below as the installed skill folder of that name (this one or a sibling) and `toolkit/templates/` as
15
+ > `references/templates/` inside this skill's folder.
16
+ <!-- /neutral-only -->
17
+
18
+ ## Critical Constraints
19
+
20
+ 1. **Never guess behaviour that is not decided.** Write what the spec says, put the open point in §7, mark the case
21
+ ("record actual behaviour" or `保留`).
22
+ 2. **On-screen strings verbatim** from the spec / mockup / running app; a missing one is the template's placeholder.
23
+ 3. **Expected results are what a tester can see.** Logs, DB, registry and code go to Appendix A.
24
+ 4. **Only section 4 holds cases.** Ids of older suites listed elsewhere (e.g. §1 "impact on older suites") are not
25
+ cases of this suite.
26
+ 5. **Never renumber delivered cases.** Append new ids; mark removed ones.
27
+ 6. **The validator must exit 0 before hand-over**, and the §8 totals are its counts, never typed by hand.
28
+
29
+ ## Process
30
+
31
+ ### 1. Read the inputs in full
32
+
33
+ 1. The project profile `docs/qa/smoke_test_profile.md` (copy `toolkit/templates/smoke-test/PROFILE_TEMPLATE.md` if
34
+ missing and fill it with the person). It names the template set, the spec sources and their codes, the task list,
35
+ the existing smoke suites, devices and accounts.
36
+ 2. The template set, resolved in this order: the profile's `template_set` path → `docs/templates/smoke-test/<set>/`
37
+ in the project → `toolkit/templates/smoke-test/<set>/` (default set `vi-default`). Read its `TEMPLATE.md`,
38
+ `AUTHORING_RULES.md` and `SMOKE_TEST_TEMPLATE.md`.
39
+ 3. Every spec source the profile lists for the feature, the decisions log, and the existing smoke suites that cover
40
+ the same screens (for the "impact on older suites" list and for regression cases).
41
+
42
+ ### 2. Write
43
+
44
+ - Copy `SMOKE_TEST_TEMPLATE.md`, keep its sections and column names, follow `AUTHORING_RULES.md`.
45
+ - Undecided behaviour, missing strings: rules 1–2 above.
46
+
47
+ ### 3. Check before handing over
48
+
49
+ ```
50
+ python toolkit/skills/sdtk-smoke-test-spec/scripts/validate_smoke_test.py <file> --template-dir <set dir>
51
+ ```
52
+
53
+ Exit 0 is required. It checks sections, columns, ids (pattern, uniqueness, subsection), Spec / severity / result
54
+ cells and that the §8 totals equal the counted cases and 🔴 cases; it counts placeholders left for developers.
55
+ Asked how many cases a file has, run the validator and give its section-4 count.
56
+
57
+ ## Common mistakes
58
+
59
+ | Mistake | Effect | Instead |
60
+ |---|---|---|
61
+ | Counting ids anywhere in the file | Old suites' ids listed in §1 inflate the count | Only section 4 holds cases (the validator does this) |
62
+ | Typing the §8 totals by hand | Totals drift from the table | Copy the validator's counts |
63
+ | `|` inside a cell (forbidden characters, commands) | Row splits into an extra cell | Escape it as `\|` |
64
+ | Expected result names a log line or DB column | Tester cannot see it | Visible result in the table, the rest in Appendix A |
65
+ | Renumbering cases after delivery | Results and automation lose their case | Append new ids; mark removed ones |
66
+
67
+ ## Report
68
+
69
+ File name, cases / 🔴 per group (from the validator), open points (§7), what the PM must decide.
@@ -0,0 +1,58 @@
1
+ # -*- coding: utf-8 -*-
2
+ """validate_smoke_test.py — python -m unittest test_validate_smoke_test (from this folder)."""
3
+ import os
4
+ import sys
5
+ import unittest
6
+
7
+ HERE = os.path.dirname(os.path.abspath(__file__))
8
+ sys.path.insert(0, HERE)
9
+ import validate_smoke_test as v # noqa: E402
10
+
11
+ TEMPLATE_DIR = os.path.normpath(os.path.join(HERE, "..", "..", "..", "templates", "smoke-test", "vi-default"))
12
+
13
+
14
+ def filled_template():
15
+ with open(os.path.join(TEMPLATE_DIR, "SMOKE_TEST_TEMPLATE.md"), encoding="utf-8") as f:
16
+ return f.read().replace("<SUITE>", "DEMO").replace("<mã spec>", "S-1")
17
+
18
+
19
+ class TemplateAndValidator(unittest.TestCase):
20
+ def setUp(self):
21
+ self.cfg = v.load_config(TEMPLATE_DIR)
22
+ self.text = filled_template()
23
+
24
+ def test_the_template_itself_validates(self):
25
+ r = v.validate(self.text, self.cfg)
26
+ self.assertEqual((r["suite"], r["cases"], r["red"], r["errors"]), ("DEMO", 5, 1, []))
27
+ self.assertTrue(r["warnings"]) # the 〔dev điền〕 note is still there
28
+
29
+ def test_totals_mismatch(self):
30
+ r = v.validate(self.text.replace("| **Tổng** | **5** | **1** |", "| **Tổng** | **6** | **1** |"), self.cfg)
31
+ self.assertIn("section 8 says 6 cases / 1 🔴, section 4 has 5 / 1", r["errors"])
32
+
33
+ def test_duplicate_and_wrong_subsection(self):
34
+ r = v.validate(self.text.replace("**DEMO-UI-01**", "**DEMO-FN-01**"), self.cfg)
35
+ self.assertTrue(any("duplicate ids" in e for e in r["errors"]))
36
+ self.assertTrue(any("is under the UI subsection" in e for e in r["errors"]))
37
+
38
+ def test_escaped_pipe_stays_in_its_cell(self):
39
+ r = v.validate(self.text.replace("<bước>", r"Đặt tên A\|B", 1), self.cfg)
40
+ self.assertEqual(r["errors"], [])
41
+
42
+ def test_old_suite_ids_outside_section_4_are_not_cases(self):
43
+ r = v.validate(self.text.replace("<OLD-FN-01>", "**OLD-FN-01**"), self.cfg)
44
+ self.assertEqual((r["cases"], r["errors"]), (5, []))
45
+
46
+ def test_empty_spec_and_unknown_result(self):
47
+ text = self.text.replace("| <thứ nhìn thấy được> | S-1 | ☐ |", "| <thứ nhìn thấy được> | | XX |", 1)
48
+ r = v.validate(text, self.cfg)
49
+ self.assertTrue(any("empty Spec cell" in e for e in r["errors"]))
50
+ self.assertTrue(any("result 'XX'" in e for e in r["errors"]))
51
+
52
+ def test_missing_section(self):
53
+ r = v.validate(self.text.replace("## 6. Hạn chế", "## Hạn chế"), self.cfg)
54
+ self.assertIn("section '## 6.' missing", r["errors"])
55
+
56
+
57
+ if __name__ == "__main__":
58
+ unittest.main()