sdtk-spec-kit 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +369 -376
- package/assets/atlas/build_atlas.py +880 -873
- package/assets/atlas/doc_atlas_viewer_template.html +3796 -3722
- package/assets/atlas/vendor/mermaid.min.js +2029 -2029
- package/assets/keys/spec-entitlement-public.pem +11 -11
- package/assets/manifest/toolkit-bundle.manifest.json +178 -178
- package/assets/manifest/toolkit-bundle.sha256.txt +83 -83
- package/assets/toolkit/toolkit/AGENTS.md +247 -245
- package/assets/toolkit/toolkit/README.md +50 -50
- package/assets/toolkit/toolkit/SDTK_TOOLKIT.md +207 -208
- package/assets/toolkit/toolkit/install.ps1 +21 -21
- package/assets/toolkit/toolkit/runtimes/claude/CLAUDE_TEMPLATE.md +92 -92
- package/assets/toolkit/toolkit/runtimes/codex/CODEX_TEMPLATE.md +70 -70
- package/assets/toolkit/toolkit/scripts/agents/run-claude-task.ps1 +332 -332
- package/assets/toolkit/toolkit/scripts/agents/run-codex-task.ps1 +618 -618
- package/assets/toolkit/toolkit/scripts/agents/validate-mailbox-formal-artifact.py +86 -86
- package/assets/toolkit/toolkit/scripts/init-feature.ps1 +262 -262
- package/assets/toolkit/toolkit/scripts/install-codex-skills.ps1 +209 -209
- package/assets/toolkit/toolkit/scripts/uninstall-claude-skills.ps1 +139 -139
- package/assets/toolkit/toolkit/scripts/uninstall-codex-skills.ps1 +143 -143
- package/assets/toolkit/toolkit/sdtk-spec.config.json +27 -27
- package/assets/toolkit/toolkit/sdtk-spec.config.profiles.example.json +49 -49
- package/assets/toolkit/toolkit/session/SDTK_ACTIVE_BOOTSTRAP.md +47 -47
- package/assets/toolkit/toolkit/session/SDTK_AGENT_WORKING_RULES.md +49 -49
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/SKILL.md +111 -111
- package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/scripts/generate_api_design_detail.py +732 -732
- package/assets/toolkit/toolkit/skills/sdtk-api-doc/SKILL.md +79 -79
- package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +85 -85
- package/assets/toolkit/toolkit/skills/sdtk-ba/SKILL.md +46 -46
- package/assets/toolkit/toolkit/skills/sdtk-design-layout/SKILL.md +91 -91
- package/assets/toolkit/toolkit/skills/sdtk-design-layout/scripts/render_design_layout_images.py +246 -246
- package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/code-quality-reviewer.md +34 -34
- package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/implementer.md +60 -60
- package/assets/toolkit/toolkit/skills/sdtk-dev/prompts/spec-reviewer.md +41 -41
- package/assets/toolkit/toolkit/skills/sdtk-dev-backend/SKILL.md +80 -80
- package/assets/toolkit/toolkit/skills/sdtk-dev-frontend/SKILL.md +80 -80
- package/assets/toolkit/toolkit/skills/sdtk-mailbox-dispatch/SKILL.md +2 -2
- package/assets/toolkit/toolkit/skills/sdtk-orchestrator/SKILL.md +17 -17
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/SKILL.md +106 -106
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/excel-image-export.md +50 -50
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/figma-mcp.md +53 -53
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/references/numbering-rules.md +28 -28
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/scripts/renumber_flow_action_spec_global.py +136 -136
- package/assets/toolkit/toolkit/skills/sdtk-screen-design-spec/scripts/validate_flow_action_spec_numbering.py +414 -414
- package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/SKILL.md +110 -110
- package/assets/toolkit/toolkit/skills/sdtk-test-case-spec/scripts/validate_test_case_spec.py +97 -97
- package/assets/toolkit/toolkit/skills/skills.catalog.yaml +330 -330
- package/assets/toolkit/toolkit/skills-claude/api-design-spec/SKILL.md +116 -116
- package/assets/toolkit/toolkit/skills-claude/api-doc/SKILL.md +87 -87
- package/assets/toolkit/toolkit/skills-claude/arch/SKILL.md +59 -59
- package/assets/toolkit/toolkit/skills-claude/ba/SKILL.md +67 -67
- package/assets/toolkit/toolkit/skills-claude/design-layout/SKILL.md +91 -91
- package/assets/toolkit/toolkit/skills-claude/dev-backend/SKILL.md +73 -73
- package/assets/toolkit/toolkit/skills-claude/dev-frontend/SKILL.md +73 -73
- package/assets/toolkit/toolkit/skills-claude/mailbox-dispatch/SKILL.md +2 -2
- package/assets/toolkit/toolkit/skills-claude/orchestrator/SKILL.md +40 -40
- package/assets/toolkit/toolkit/skills-claude/pm/SKILL.md +88 -88
- package/assets/toolkit/toolkit/skills-claude/qa/SKILL.md +58 -58
- package/assets/toolkit/toolkit/skills-claude/screen-design-spec/SKILL.md +112 -112
- package/assets/toolkit/toolkit/skills-claude/test-case-spec/SKILL.md +115 -115
- package/assets/toolkit/toolkit/templates/README.md +68 -68
- package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md +21 -21
- package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_DETAIL_TEMPLATE.md +67 -67
- package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md +468 -468
- package/assets/toolkit/toolkit/templates/docs/api/API_ENDPOINTS_TEMPLATE.md +228 -228
- package/assets/toolkit/toolkit/templates/docs/api/FEATURE_API_TEMPLATE.yaml +20 -20
- package/assets/toolkit/toolkit/templates/docs/api/FLOWCHART_CREATION_RULES.md +20 -20
- package/assets/toolkit/toolkit/templates/docs/api/YAML_CREATION_RULES.md +128 -128
- package/assets/toolkit/toolkit/templates/docs/api/feature_api_flow_list_TEMPLATE.txt +12 -12
- package/assets/toolkit/toolkit/templates/docs/architecture/ARCH_DESIGN_TEMPLATE.md +107 -107
- package/assets/toolkit/toolkit/templates/docs/design/DESIGN_LAYOUT_TEMPLATE.md +60 -60
- package/assets/toolkit/toolkit/templates/docs/dev/OPS_HANDOFF_CREATION_RULES.md +369 -369
- package/assets/toolkit/toolkit/templates/docs/discovery/REQUIREMENT_TEMPLATE.md +155 -155
- package/assets/toolkit/toolkit/templates/docs/product/BACKLOG_TEMPLATE.md +50 -50
- package/assets/toolkit/toolkit/templates/docs/product/CONDENSED_UPSTREAM_INPUT_TEMPLATE.md +276 -276
- package/assets/toolkit/toolkit/templates/docs/product/PRD_TEMPLATE.md +66 -66
- package/assets/toolkit/toolkit/templates/docs/product/PROJECT_INITIATION_TEMPLATE.md +98 -98
- package/assets/toolkit/toolkit/templates/docs/qa/TEST_CASE_CREATION_RULES.md +129 -129
- package/assets/toolkit/toolkit/templates/docs/qa/TEST_CASE_TEMPLATE.md +104 -104
- package/assets/toolkit/toolkit/templates/docs/specs/BA_SPEC_TEMPLATE.md +139 -139
- package/assets/toolkit/toolkit/templates/docs/specs/FLOW_ACTION_SPEC_TEMPLATE.md +197 -197
- package/assets/toolkit/toolkit/templates/handoffs/ARCH_TO_DEV.md +31 -31
- package/assets/toolkit/toolkit/templates/handoffs/BA_TO_ARCH.md +28 -28
- package/assets/toolkit/toolkit/templates/handoffs/DEV_STAGE1_SPEC_REVIEW.md +26 -26
- package/assets/toolkit/toolkit/templates/handoffs/DEV_STAGE2_CODE_QUALITY_REVIEW.md +20 -20
- package/assets/toolkit/toolkit/templates/handoffs/DEV_TO_QA.md +33 -33
- package/assets/toolkit/toolkit/templates/handoffs/PM_TO_BA.md +29 -29
- package/assets/toolkit/toolkit/templates/handoffs/QA_RELEASE_DECISION.md +26 -26
- package/assets/toolkit/toolkit/templates/mailbox/AGENT_TASK_TEMPLATE.md +76 -76
- package/bin/sdtk.js +15 -15
- package/package.json +48 -48
- package/src/commands/activate.js +90 -90
- package/src/commands/analyze.js +11 -0
- package/src/commands/atlas.js +341 -352
- package/src/commands/auth.js +85 -85
- package/src/commands/entitlement.js +163 -163
- package/src/commands/generate.js +209 -147
- package/src/commands/help.js +41 -33
- package/src/commands/init.js +15 -15
- package/src/commands/project.js +51 -51
- package/src/commands/runtime.js +239 -239
- package/src/index.js +9 -6
- package/src/lib/activation-state.js +68 -68
- package/src/lib/args.js +116 -116
- package/src/lib/atlas-config.js +200 -200
- package/src/lib/atlas-runner.js +435 -355
- package/src/lib/browser-open.js +39 -39
- package/src/lib/capabilities.js +92 -92
- package/src/lib/entitlements.js +238 -238
- package/src/lib/errors.js +41 -41
- package/src/lib/github-access.js +143 -143
- package/src/lib/legacy-auth-migration.js +55 -55
- package/src/lib/license-activation.js +375 -351
- package/src/lib/powershell.js +85 -85
- package/src/lib/premium-loader.js +126 -126
- package/src/lib/premium-packs.js +331 -331
- package/src/lib/premium-sync.js +235 -235
- package/src/lib/project-audit.js +332 -332
- package/src/lib/project-config.js +108 -108
- package/src/lib/project-ingest.js +450 -450
- package/src/lib/project-refresh.js +666 -666
- package/src/lib/requirement-analysis.js +396 -0
- package/src/lib/scope.js +83 -83
- package/src/lib/state.js +73 -73
- package/src/lib/suite-state.js +70 -70
- package/src/lib/toolkit-payload.js +99 -99
- package/src/lib/atlas-ask.js +0 -170
package/assets/toolkit/toolkit/skills/sdtk-design-layout/scripts/render_design_layout_images.py
CHANGED
|
@@ -1,246 +1,246 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Render screen preview SVGs from DESIGN_LAYOUT PlantUML SALT wireframes.
|
|
4
|
-
|
|
5
|
-
Extracts @startsalt blocks from a DESIGN_LAYOUT_[FEATURE_KEY].md file,
|
|
6
|
-
renders each to .svg using a local plantuml.jar, and writes the images
|
|
7
|
-
to docs/specs/assets/<feature_snake>/screens/.
|
|
8
|
-
|
|
9
|
-
Graceful failure: if PlantUML is unavailable or a block fails to render,
|
|
10
|
-
the script warns but does not exit with an error code.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from __future__ import annotations
|
|
14
|
-
|
|
15
|
-
import argparse
|
|
16
|
-
import re
|
|
17
|
-
import shutil
|
|
18
|
-
import subprocess
|
|
19
|
-
import sys
|
|
20
|
-
from pathlib import Path
|
|
21
|
-
from typing import List, Optional, Tuple
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
CIRCLED_ITEM_MARKER_RE = re.compile(r"[\u2460-\u2473\u3251-\u325F\u32B1-\u32BF]")
|
|
25
|
-
LEGACY_ITEM_MARKER_RE = re.compile(r"\(\d+\)")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def parse_args() -> argparse.Namespace:
|
|
29
|
-
parser = argparse.ArgumentParser(
|
|
30
|
-
description="Render screen images from DESIGN_LAYOUT PlantUML SALT blocks."
|
|
31
|
-
)
|
|
32
|
-
parser.add_argument(
|
|
33
|
-
"--design-layout",
|
|
34
|
-
required=True,
|
|
35
|
-
help="Path to DESIGN_LAYOUT_[FEATURE_KEY].md",
|
|
36
|
-
)
|
|
37
|
-
parser.add_argument(
|
|
38
|
-
"--feature-key",
|
|
39
|
-
required=True,
|
|
40
|
-
help="Feature key, e.g. CRM_LITE",
|
|
41
|
-
)
|
|
42
|
-
parser.add_argument(
|
|
43
|
-
"--output-dir",
|
|
44
|
-
default="",
|
|
45
|
-
help="Output directory for SVGs. Default: docs/specs/assets/<feature_snake>/screens/",
|
|
46
|
-
)
|
|
47
|
-
parser.add_argument(
|
|
48
|
-
"--plantuml-jar",
|
|
49
|
-
default="",
|
|
50
|
-
help="Explicit path to plantuml.jar. Auto-detected if omitted.",
|
|
51
|
-
)
|
|
52
|
-
parser.add_argument(
|
|
53
|
-
"--skip-render",
|
|
54
|
-
action="store_true",
|
|
55
|
-
help="Extract .puml files only, skip SVG rendering.",
|
|
56
|
-
)
|
|
57
|
-
return parser.parse_args()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
def normalize_feature_snake(feature_key: str) -> str:
|
|
61
|
-
return re.sub(r"[^a-z0-9]+", "_", feature_key.lower()).strip("_")
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def find_plantuml_jar(explicit: str) -> Optional[Path]:
|
|
65
|
-
if explicit:
|
|
66
|
-
p = Path(explicit).expanduser().resolve()
|
|
67
|
-
return p if p.exists() else None
|
|
68
|
-
user_home = Path.home()
|
|
69
|
-
candidates = sorted(
|
|
70
|
-
(user_home / ".vscode" / "extensions").glob("jebbs.plantuml-*/plantuml.jar")
|
|
71
|
-
)
|
|
72
|
-
if candidates:
|
|
73
|
-
return candidates[-1]
|
|
74
|
-
return None
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def extract_screens(text: str) -> List[Tuple[str, str]]:
|
|
78
|
-
"""Extract (screen_id, plantuml_block) pairs from DESIGN_LAYOUT markdown.
|
|
79
|
-
|
|
80
|
-
Looks for heading patterns like '## A-1. Screen Name' or '## SCR-01 Screen Name'
|
|
81
|
-
followed by a fenced plantuml block containing @startsalt.
|
|
82
|
-
"""
|
|
83
|
-
screens: List[Tuple[str, str]] = []
|
|
84
|
-
heading_pattern = re.compile(
|
|
85
|
-
r"^##\s+([A-Z]+-?\d+|SCR-?\d+)[.\s]",
|
|
86
|
-
re.MULTILINE,
|
|
87
|
-
)
|
|
88
|
-
salt_pattern = re.compile(
|
|
89
|
-
r"```plantuml\s*\n(@startsalt[\s\S]*?@endsalt)\s*\n```",
|
|
90
|
-
re.MULTILINE,
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
headings = list(heading_pattern.finditer(text))
|
|
94
|
-
for i, match in enumerate(headings):
|
|
95
|
-
screen_id = match.group(1).strip().lower().replace("-", "_")
|
|
96
|
-
start = match.start()
|
|
97
|
-
end = headings[i + 1].start() if i + 1 < len(headings) else len(text)
|
|
98
|
-
section = text[start:end]
|
|
99
|
-
|
|
100
|
-
salt_match = salt_pattern.search(section)
|
|
101
|
-
if salt_match:
|
|
102
|
-
screens.append((screen_id, salt_match.group(1)))
|
|
103
|
-
|
|
104
|
-
return screens
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
def count_visible_item_markers(salt_block: str) -> int:
|
|
108
|
-
return len(CIRCLED_ITEM_MARKER_RE.findall(salt_block))
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def count_legacy_item_markers(salt_block: str) -> int:
|
|
112
|
-
return len(LEGACY_ITEM_MARKER_RE.findall(salt_block))
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def render_svg(
|
|
116
|
-
plantuml_jar: Path, puml_path: Path, output_dir: Path
|
|
117
|
-
) -> Optional[str]:
|
|
118
|
-
"""Render a single .puml to .svg. Returns error string or None on success."""
|
|
119
|
-
proc = subprocess.run(
|
|
120
|
-
["java", "-Dfile.encoding=UTF-8", "-jar", str(plantuml_jar), "-charset", "UTF-8", "-tsvg", str(puml_path)],
|
|
121
|
-
stdout=subprocess.PIPE,
|
|
122
|
-
stderr=subprocess.STDOUT,
|
|
123
|
-
text=True,
|
|
124
|
-
check=False,
|
|
125
|
-
)
|
|
126
|
-
# PlantUML writes .svg next to the .puml file.
|
|
127
|
-
svg_path = puml_path.with_suffix(".svg")
|
|
128
|
-
if not svg_path.exists():
|
|
129
|
-
return f"Render failed (no svg produced): {puml_path.name}"
|
|
130
|
-
|
|
131
|
-
# If .puml is already in the output dir, no copy needed.
|
|
132
|
-
# Otherwise move the svg to the output dir.
|
|
133
|
-
svg_dst = output_dir / svg_path.name
|
|
134
|
-
if svg_path.resolve() != svg_dst.resolve():
|
|
135
|
-
shutil.copy2(svg_path, svg_dst)
|
|
136
|
-
svg_path.unlink(missing_ok=True)
|
|
137
|
-
svg_path = svg_dst
|
|
138
|
-
|
|
139
|
-
svg_text = svg_path.read_text(encoding="utf-8", errors="ignore")
|
|
140
|
-
if any(
|
|
141
|
-
x in svg_text
|
|
142
|
-
for x in ("Cannot find group", "Syntax Error", "contains errors")
|
|
143
|
-
):
|
|
144
|
-
return f"Rendered with error content: {svg_path.name}"
|
|
145
|
-
if proc.returncode != 0:
|
|
146
|
-
return f"PlantUML exit={proc.returncode} for {puml_path.name}"
|
|
147
|
-
return None
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
def main() -> int:
|
|
151
|
-
args = parse_args()
|
|
152
|
-
|
|
153
|
-
feature_key = args.feature_key.strip()
|
|
154
|
-
if not feature_key:
|
|
155
|
-
print("[ERROR] --feature-key is empty", file=sys.stderr)
|
|
156
|
-
return 1
|
|
157
|
-
|
|
158
|
-
feature_snake = normalize_feature_snake(feature_key)
|
|
159
|
-
layout_path = Path(args.design_layout)
|
|
160
|
-
if not layout_path.exists():
|
|
161
|
-
print(f"[ERROR] Design layout not found: {layout_path}", file=sys.stderr)
|
|
162
|
-
return 1
|
|
163
|
-
|
|
164
|
-
if args.output_dir:
|
|
165
|
-
output_dir = Path(args.output_dir)
|
|
166
|
-
else:
|
|
167
|
-
output_dir = Path(f"docs/specs/assets/{feature_snake}/screens")
|
|
168
|
-
|
|
169
|
-
output_dir.mkdir(parents=True, exist_ok=True)
|
|
170
|
-
|
|
171
|
-
text = layout_path.read_text(encoding="utf-8")
|
|
172
|
-
screens = extract_screens(text)
|
|
173
|
-
|
|
174
|
-
if not screens:
|
|
175
|
-
print("[WARN] No screen sections with @startsalt blocks found.")
|
|
176
|
-
print("[OK] Nothing to render.")
|
|
177
|
-
return 0
|
|
178
|
-
|
|
179
|
-
print(f"[OK] Found {len(screens)} screen(s) with SALT wireframes.")
|
|
180
|
-
|
|
181
|
-
numbering_warnings: List[str] = []
|
|
182
|
-
for screen_id, salt_block in screens:
|
|
183
|
-
marker_count = count_visible_item_markers(salt_block)
|
|
184
|
-
legacy_marker_count = count_legacy_item_markers(salt_block)
|
|
185
|
-
if legacy_marker_count > 0:
|
|
186
|
-
numbering_warnings.append(
|
|
187
|
-
f"{screen_id}: legacy `(N)` markers detected; prefer circled-number markers to avoid SALT ambiguity."
|
|
188
|
-
)
|
|
189
|
-
elif marker_count == 0:
|
|
190
|
-
numbering_warnings.append(
|
|
191
|
-
f"{screen_id}: no visible wireframe item markers found."
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
# Write .puml files
|
|
195
|
-
puml_files: List[Path] = []
|
|
196
|
-
for screen_id, salt_block in screens:
|
|
197
|
-
puml_name = f"{screen_id}.puml"
|
|
198
|
-
puml_path = output_dir / puml_name
|
|
199
|
-
puml_path.write_text(salt_block + "\n", encoding="utf-8")
|
|
200
|
-
puml_files.append(puml_path)
|
|
201
|
-
|
|
202
|
-
if args.skip_render:
|
|
203
|
-
print(f"[OK] Wrote {len(puml_files)} .puml file(s). Render skipped (--skip-render).")
|
|
204
|
-
if numbering_warnings:
|
|
205
|
-
print("[WARN] Wireframe numbering issues:")
|
|
206
|
-
for item in numbering_warnings:
|
|
207
|
-
print(f" - {item}")
|
|
208
|
-
return 0
|
|
209
|
-
|
|
210
|
-
# Find PlantUML
|
|
211
|
-
jar = find_plantuml_jar(args.plantuml_jar)
|
|
212
|
-
if not jar:
|
|
213
|
-
print("[WARN] PlantUML jar not found. SVG rendering skipped.")
|
|
214
|
-
print(" Use --plantuml-jar or install VSCode PlantUML extension.")
|
|
215
|
-
print(f"[OK] Wrote {len(puml_files)} .puml file(s) without SVG rendering.")
|
|
216
|
-
return 0
|
|
217
|
-
|
|
218
|
-
# Render SVGs
|
|
219
|
-
errors: List[str] = []
|
|
220
|
-
rendered = 0
|
|
221
|
-
for puml_path in puml_files:
|
|
222
|
-
err = render_svg(jar, puml_path, output_dir)
|
|
223
|
-
if err:
|
|
224
|
-
errors.append(err)
|
|
225
|
-
else:
|
|
226
|
-
rendered += 1
|
|
227
|
-
|
|
228
|
-
print(f"[OK] Rendered {rendered}/{len(puml_files)} screen image(s) to: {output_dir}")
|
|
229
|
-
if errors:
|
|
230
|
-
print("[WARN] Render issues:")
|
|
231
|
-
for item in errors:
|
|
232
|
-
print(f" - {item}")
|
|
233
|
-
if numbering_warnings:
|
|
234
|
-
print("[WARN] Wireframe numbering issues:")
|
|
235
|
-
for item in numbering_warnings:
|
|
236
|
-
print(f" - {item}")
|
|
237
|
-
|
|
238
|
-
return 0
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if __name__ == "__main__":
|
|
242
|
-
try:
|
|
243
|
-
raise SystemExit(main())
|
|
244
|
-
except Exception as exc:
|
|
245
|
-
print(f"[ERROR] {exc}", file=sys.stderr)
|
|
246
|
-
raise
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Render screen preview SVGs from DESIGN_LAYOUT PlantUML SALT wireframes.
|
|
4
|
+
|
|
5
|
+
Extracts @startsalt blocks from a DESIGN_LAYOUT_[FEATURE_KEY].md file,
|
|
6
|
+
renders each to .svg using a local plantuml.jar, and writes the images
|
|
7
|
+
to docs/specs/assets/<feature_snake>/screens/.
|
|
8
|
+
|
|
9
|
+
Graceful failure: if PlantUML is unavailable or a block fails to render,
|
|
10
|
+
the script warns but does not exit with an error code.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import re
|
|
17
|
+
import shutil
|
|
18
|
+
import subprocess
|
|
19
|
+
import sys
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import List, Optional, Tuple
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
CIRCLED_ITEM_MARKER_RE = re.compile(r"[\u2460-\u2473\u3251-\u325F\u32B1-\u32BF]")
|
|
25
|
+
LEGACY_ITEM_MARKER_RE = re.compile(r"\(\d+\)")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def parse_args() -> argparse.Namespace:
|
|
29
|
+
parser = argparse.ArgumentParser(
|
|
30
|
+
description="Render screen images from DESIGN_LAYOUT PlantUML SALT blocks."
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"--design-layout",
|
|
34
|
+
required=True,
|
|
35
|
+
help="Path to DESIGN_LAYOUT_[FEATURE_KEY].md",
|
|
36
|
+
)
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"--feature-key",
|
|
39
|
+
required=True,
|
|
40
|
+
help="Feature key, e.g. CRM_LITE",
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"--output-dir",
|
|
44
|
+
default="",
|
|
45
|
+
help="Output directory for SVGs. Default: docs/specs/assets/<feature_snake>/screens/",
|
|
46
|
+
)
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"--plantuml-jar",
|
|
49
|
+
default="",
|
|
50
|
+
help="Explicit path to plantuml.jar. Auto-detected if omitted.",
|
|
51
|
+
)
|
|
52
|
+
parser.add_argument(
|
|
53
|
+
"--skip-render",
|
|
54
|
+
action="store_true",
|
|
55
|
+
help="Extract .puml files only, skip SVG rendering.",
|
|
56
|
+
)
|
|
57
|
+
return parser.parse_args()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def normalize_feature_snake(feature_key: str) -> str:
|
|
61
|
+
return re.sub(r"[^a-z0-9]+", "_", feature_key.lower()).strip("_")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def find_plantuml_jar(explicit: str) -> Optional[Path]:
|
|
65
|
+
if explicit:
|
|
66
|
+
p = Path(explicit).expanduser().resolve()
|
|
67
|
+
return p if p.exists() else None
|
|
68
|
+
user_home = Path.home()
|
|
69
|
+
candidates = sorted(
|
|
70
|
+
(user_home / ".vscode" / "extensions").glob("jebbs.plantuml-*/plantuml.jar")
|
|
71
|
+
)
|
|
72
|
+
if candidates:
|
|
73
|
+
return candidates[-1]
|
|
74
|
+
return None
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def extract_screens(text: str) -> List[Tuple[str, str]]:
|
|
78
|
+
"""Extract (screen_id, plantuml_block) pairs from DESIGN_LAYOUT markdown.
|
|
79
|
+
|
|
80
|
+
Looks for heading patterns like '## A-1. Screen Name' or '## SCR-01 Screen Name'
|
|
81
|
+
followed by a fenced plantuml block containing @startsalt.
|
|
82
|
+
"""
|
|
83
|
+
screens: List[Tuple[str, str]] = []
|
|
84
|
+
heading_pattern = re.compile(
|
|
85
|
+
r"^##\s+([A-Z]+-?\d+|SCR-?\d+)[.\s]",
|
|
86
|
+
re.MULTILINE,
|
|
87
|
+
)
|
|
88
|
+
salt_pattern = re.compile(
|
|
89
|
+
r"```plantuml\s*\n(@startsalt[\s\S]*?@endsalt)\s*\n```",
|
|
90
|
+
re.MULTILINE,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
headings = list(heading_pattern.finditer(text))
|
|
94
|
+
for i, match in enumerate(headings):
|
|
95
|
+
screen_id = match.group(1).strip().lower().replace("-", "_")
|
|
96
|
+
start = match.start()
|
|
97
|
+
end = headings[i + 1].start() if i + 1 < len(headings) else len(text)
|
|
98
|
+
section = text[start:end]
|
|
99
|
+
|
|
100
|
+
salt_match = salt_pattern.search(section)
|
|
101
|
+
if salt_match:
|
|
102
|
+
screens.append((screen_id, salt_match.group(1)))
|
|
103
|
+
|
|
104
|
+
return screens
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def count_visible_item_markers(salt_block: str) -> int:
|
|
108
|
+
return len(CIRCLED_ITEM_MARKER_RE.findall(salt_block))
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def count_legacy_item_markers(salt_block: str) -> int:
|
|
112
|
+
return len(LEGACY_ITEM_MARKER_RE.findall(salt_block))
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def render_svg(
|
|
116
|
+
plantuml_jar: Path, puml_path: Path, output_dir: Path
|
|
117
|
+
) -> Optional[str]:
|
|
118
|
+
"""Render a single .puml to .svg. Returns error string or None on success."""
|
|
119
|
+
proc = subprocess.run(
|
|
120
|
+
["java", "-Dfile.encoding=UTF-8", "-jar", str(plantuml_jar), "-charset", "UTF-8", "-tsvg", str(puml_path)],
|
|
121
|
+
stdout=subprocess.PIPE,
|
|
122
|
+
stderr=subprocess.STDOUT,
|
|
123
|
+
text=True,
|
|
124
|
+
check=False,
|
|
125
|
+
)
|
|
126
|
+
# PlantUML writes .svg next to the .puml file.
|
|
127
|
+
svg_path = puml_path.with_suffix(".svg")
|
|
128
|
+
if not svg_path.exists():
|
|
129
|
+
return f"Render failed (no svg produced): {puml_path.name}"
|
|
130
|
+
|
|
131
|
+
# If .puml is already in the output dir, no copy needed.
|
|
132
|
+
# Otherwise move the svg to the output dir.
|
|
133
|
+
svg_dst = output_dir / svg_path.name
|
|
134
|
+
if svg_path.resolve() != svg_dst.resolve():
|
|
135
|
+
shutil.copy2(svg_path, svg_dst)
|
|
136
|
+
svg_path.unlink(missing_ok=True)
|
|
137
|
+
svg_path = svg_dst
|
|
138
|
+
|
|
139
|
+
svg_text = svg_path.read_text(encoding="utf-8", errors="ignore")
|
|
140
|
+
if any(
|
|
141
|
+
x in svg_text
|
|
142
|
+
for x in ("Cannot find group", "Syntax Error", "contains errors")
|
|
143
|
+
):
|
|
144
|
+
return f"Rendered with error content: {svg_path.name}"
|
|
145
|
+
if proc.returncode != 0:
|
|
146
|
+
return f"PlantUML exit={proc.returncode} for {puml_path.name}"
|
|
147
|
+
return None
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def main() -> int:
|
|
151
|
+
args = parse_args()
|
|
152
|
+
|
|
153
|
+
feature_key = args.feature_key.strip()
|
|
154
|
+
if not feature_key:
|
|
155
|
+
print("[ERROR] --feature-key is empty", file=sys.stderr)
|
|
156
|
+
return 1
|
|
157
|
+
|
|
158
|
+
feature_snake = normalize_feature_snake(feature_key)
|
|
159
|
+
layout_path = Path(args.design_layout)
|
|
160
|
+
if not layout_path.exists():
|
|
161
|
+
print(f"[ERROR] Design layout not found: {layout_path}", file=sys.stderr)
|
|
162
|
+
return 1
|
|
163
|
+
|
|
164
|
+
if args.output_dir:
|
|
165
|
+
output_dir = Path(args.output_dir)
|
|
166
|
+
else:
|
|
167
|
+
output_dir = Path(f"docs/specs/assets/{feature_snake}/screens")
|
|
168
|
+
|
|
169
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
|
170
|
+
|
|
171
|
+
text = layout_path.read_text(encoding="utf-8")
|
|
172
|
+
screens = extract_screens(text)
|
|
173
|
+
|
|
174
|
+
if not screens:
|
|
175
|
+
print("[WARN] No screen sections with @startsalt blocks found.")
|
|
176
|
+
print("[OK] Nothing to render.")
|
|
177
|
+
return 0
|
|
178
|
+
|
|
179
|
+
print(f"[OK] Found {len(screens)} screen(s) with SALT wireframes.")
|
|
180
|
+
|
|
181
|
+
numbering_warnings: List[str] = []
|
|
182
|
+
for screen_id, salt_block in screens:
|
|
183
|
+
marker_count = count_visible_item_markers(salt_block)
|
|
184
|
+
legacy_marker_count = count_legacy_item_markers(salt_block)
|
|
185
|
+
if legacy_marker_count > 0:
|
|
186
|
+
numbering_warnings.append(
|
|
187
|
+
f"{screen_id}: legacy `(N)` markers detected; prefer circled-number markers to avoid SALT ambiguity."
|
|
188
|
+
)
|
|
189
|
+
elif marker_count == 0:
|
|
190
|
+
numbering_warnings.append(
|
|
191
|
+
f"{screen_id}: no visible wireframe item markers found."
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# Write .puml files
|
|
195
|
+
puml_files: List[Path] = []
|
|
196
|
+
for screen_id, salt_block in screens:
|
|
197
|
+
puml_name = f"{screen_id}.puml"
|
|
198
|
+
puml_path = output_dir / puml_name
|
|
199
|
+
puml_path.write_text(salt_block + "\n", encoding="utf-8")
|
|
200
|
+
puml_files.append(puml_path)
|
|
201
|
+
|
|
202
|
+
if args.skip_render:
|
|
203
|
+
print(f"[OK] Wrote {len(puml_files)} .puml file(s). Render skipped (--skip-render).")
|
|
204
|
+
if numbering_warnings:
|
|
205
|
+
print("[WARN] Wireframe numbering issues:")
|
|
206
|
+
for item in numbering_warnings:
|
|
207
|
+
print(f" - {item}")
|
|
208
|
+
return 0
|
|
209
|
+
|
|
210
|
+
# Find PlantUML
|
|
211
|
+
jar = find_plantuml_jar(args.plantuml_jar)
|
|
212
|
+
if not jar:
|
|
213
|
+
print("[WARN] PlantUML jar not found. SVG rendering skipped.")
|
|
214
|
+
print(" Use --plantuml-jar or install VSCode PlantUML extension.")
|
|
215
|
+
print(f"[OK] Wrote {len(puml_files)} .puml file(s) without SVG rendering.")
|
|
216
|
+
return 0
|
|
217
|
+
|
|
218
|
+
# Render SVGs
|
|
219
|
+
errors: List[str] = []
|
|
220
|
+
rendered = 0
|
|
221
|
+
for puml_path in puml_files:
|
|
222
|
+
err = render_svg(jar, puml_path, output_dir)
|
|
223
|
+
if err:
|
|
224
|
+
errors.append(err)
|
|
225
|
+
else:
|
|
226
|
+
rendered += 1
|
|
227
|
+
|
|
228
|
+
print(f"[OK] Rendered {rendered}/{len(puml_files)} screen image(s) to: {output_dir}")
|
|
229
|
+
if errors:
|
|
230
|
+
print("[WARN] Render issues:")
|
|
231
|
+
for item in errors:
|
|
232
|
+
print(f" - {item}")
|
|
233
|
+
if numbering_warnings:
|
|
234
|
+
print("[WARN] Wireframe numbering issues:")
|
|
235
|
+
for item in numbering_warnings:
|
|
236
|
+
print(f" - {item}")
|
|
237
|
+
|
|
238
|
+
return 0
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if __name__ == "__main__":
|
|
242
|
+
try:
|
|
243
|
+
raise SystemExit(main())
|
|
244
|
+
except Exception as exc:
|
|
245
|
+
print(f"[ERROR] {exc}", file=sys.stderr)
|
|
246
|
+
raise
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
# SDTK-SPEC DEV Code Quality Reviewer Prompt Template
|
|
2
|
-
|
|
3
|
-
You are the Stage 2 code-quality reviewer for a completed SDTK-SPEC development task.
|
|
4
|
-
|
|
5
|
-
## Gate Position
|
|
6
|
-
Run this prompt only after the spec reviewer has passed Stage 1 artifact/spec compliance.
|
|
7
|
-
|
|
8
|
-
## Inputs From Controller
|
|
9
|
-
- Task ID: `{{TASK_ID}}`
|
|
10
|
-
- Feature key: `{{FEATURE_KEY}}`
|
|
11
|
-
- Stage 1 PASS evidence: `{{SPEC_REVIEW_PASS_EVIDENCE}}`
|
|
12
|
-
- Files to review:
|
|
13
|
-
|
|
14
|
-
```text
|
|
15
|
-
{{FILES_TO_REVIEW}}
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
- Relevant coding standards or repo conventions:
|
|
19
|
-
|
|
20
|
-
```text
|
|
21
|
-
{{CODE_QUALITY_RULES}}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Review Rules
|
|
25
|
-
- Confirm Stage 1 PASS before reviewing code quality.
|
|
26
|
-
- Review structure, naming, maintainability, boundary clarity, and test quality.
|
|
27
|
-
- Flag issues that make the implementation fragile even if it is spec-compliant.
|
|
28
|
-
- Do not reopen Stage 1 scope unless you find a direct contradiction in the shipped code.
|
|
29
|
-
|
|
30
|
-
## Response Format
|
|
31
|
-
- Gate result: `{{GATE_RESULT}}`
|
|
32
|
-
- Code quality findings: `{{QUALITY_FINDINGS}}`
|
|
33
|
-
- Test quality findings: `{{TEST_FINDINGS}}`
|
|
34
|
-
- Required improvements: `{{REQUIRED_IMPROVEMENTS}}`
|
|
1
|
+
# SDTK-SPEC DEV Code Quality Reviewer Prompt Template
|
|
2
|
+
|
|
3
|
+
You are the Stage 2 code-quality reviewer for a completed SDTK-SPEC development task.
|
|
4
|
+
|
|
5
|
+
## Gate Position
|
|
6
|
+
Run this prompt only after the spec reviewer has passed Stage 1 artifact/spec compliance.
|
|
7
|
+
|
|
8
|
+
## Inputs From Controller
|
|
9
|
+
- Task ID: `{{TASK_ID}}`
|
|
10
|
+
- Feature key: `{{FEATURE_KEY}}`
|
|
11
|
+
- Stage 1 PASS evidence: `{{SPEC_REVIEW_PASS_EVIDENCE}}`
|
|
12
|
+
- Files to review:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
{{FILES_TO_REVIEW}}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Relevant coding standards or repo conventions:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
{{CODE_QUALITY_RULES}}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Review Rules
|
|
25
|
+
- Confirm Stage 1 PASS before reviewing code quality.
|
|
26
|
+
- Review structure, naming, maintainability, boundary clarity, and test quality.
|
|
27
|
+
- Flag issues that make the implementation fragile even if it is spec-compliant.
|
|
28
|
+
- Do not reopen Stage 1 scope unless you find a direct contradiction in the shipped code.
|
|
29
|
+
|
|
30
|
+
## Response Format
|
|
31
|
+
- Gate result: `{{GATE_RESULT}}`
|
|
32
|
+
- Code quality findings: `{{QUALITY_FINDINGS}}`
|
|
33
|
+
- Test quality findings: `{{TEST_FINDINGS}}`
|
|
34
|
+
- Required improvements: `{{REQUIRED_IMPROVEMENTS}}`
|
|
35
35
|
- Final recommendation: `{{FINAL_RECOMMENDATION}}`
|