Skip to content

insightflo/edu-deck-skills / edu-deck

edu-deck

Flagged

Entry skill for education deck requests. Use FIRST when the user wants 교육자료, 강의 자료, 교육용 슬라이드, 직원 교육 덱, or a training series (예: "○○ 교육자료 만들어줘", "사내 교육 시리즈 만들어", "여러 편으로 나눠 교육 자료"). 판별 후 단일 발행(주제 하나, 파일 하나)이면 edu-deck-solo 경로를, 여러 편 시리즈·진도 관리·허브가 필요하면 edu-deck-series 경로를 탄다. 애매하면 사용자에게 한 번 묻는다. 덱 제작 절차는 이 스킬에 없고 각 하위 스킬에 있다.

FileKindSize
SKILL.mdskill md14.1 KB
distribution/NOTICES.mdmarkdown1.5 KB
distribution/README.mdmarkdown3.4 KB
distribution/USAGE.mdmarkdown5.5 KB
shared/assets/css/components.cssother23.2 KB
shared/assets/css/core.cssother15.1 KB
shared/assets/css/pack-runtime.cssother9.4 KB
shared/assets/css/responsive.cssother10.6 KB
shared/assets/css/theme-switch.cssother3.4 KB
shared/assets/css/themes.cssother11.2 KB
shared/assets/css/tokens.cssother2.5 KB
shared/assets/css/viewer.cssother17.5 KB
shared/assets/css/visual-motion.cssother19.3 KB
shared/assets/fonts/GowunBatang-Regular.woff2binary523.3 KB
shared/assets/fonts/GowunDodum-Regular.woff2binary435.5 KB
shared/assets/fonts/OFL-GowunBatang.txtmarkdown4.3 KB
shared/assets/fonts/OFL-GowunDodum.txtmarkdown4.3 KB
shared/assets/fonts/OFL.txtmarkdown4.3 KB
shared/assets/fonts/PretendardVariable.woff2binary2.0 MB
shared/assets/icons/base.svgother9.3 KB
shared/assets/icons/extra.svgother18.4 KB
shared/assets/icons/si.svgother7.6 KB
shared/assets/js/cover-art.jsscript82.9 KB
shared/assets/js/motion.jsscript84.4 KB
shared/assets/js/patterns.jsscript7.2 KB
shared/assets/js/responsive.jsscript21.6 KB
shared/assets/js/sheet.jsscript1.5 KB
shared/assets/js/study.jsscript33.6 KB
shared/assets/js/talk.jsscript9.2 KB
shared/assets/js/themes.jsscript7.8 KB
shared/assets/js/viewer.jsscript29.1 KB
shared/assets/kit/patterns.cssother5.4 KB
shared/assets/kit/stack.jsscript15.8 KB
shared/assets/pack-shell.htmlother2.9 MB
shared/assets/packs/atlas/style.cssother1.7 KB
shared/assets/packs/atlas/template.htmlother2.1 KB
shared/assets/packs/base.cssother2.2 KB
shared/assets/packs/briefing/style.cssother1.4 KB
shared/assets/packs/briefing/template.htmlother1.7 KB
shared/assets/packs/casebook/style.cssother1.4 KB
shared/assets/packs/casebook/template.htmlother1.5 KB
shared/assets/packs/catalog.jsonconfig10.3 KB
shared/assets/packs/editorial/style.cssother1.2 KB
shared/assets/packs/editorial/template.htmlother2.0 KB
shared/assets/packs/field/style.cssother1.5 KB
shared/assets/packs/field/template.htmlother1.6 KB
shared/assets/packs/flows.jsonconfig21.8 KB
shared/assets/packs/lab/style.cssother1.4 KB
shared/assets/packs/lab/template.htmlother1.6 KB
shared/assets/packs/seminar/style.cssother1.4 KB
shared/assets/packs/seminar/template.htmlother1.7 KB
shared/assets/packs/workbook/style.cssother1.6 KB
shared/assets/packs/workbook/template.htmlother1.7 KB
shared/assets/shell.htmlother2.9 MB
shared/assets/snippets/01-cover-bauhaus.htmlother3.3 KB
shared/assets/snippets/01-cover-bento.htmlother6.7 KB
shared/assets/snippets/01-cover-bigstat.htmlother2.3 KB
shared/assets/snippets/01-cover-blueprint.htmlother4.3 KB
shared/assets/snippets/01-cover-bold-poster.htmlother3.4 KB
shared/assets/snippets/01-cover-center.htmlother2.5 KB
shared/assets/snippets/01-cover-diagram.htmlother2.4 KB
shared/assets/snippets/01-cover-editorial-lab.htmlother3.6 KB
shared/assets/snippets/01-cover-future-portal.htmlother3.6 KB
shared/assets/snippets/01-cover-learning-path.htmlother3.7 KB
shared/assets/snippets/01-cover-modular-cards.htmlother3.9 KB
shared/assets/snippets/01-cover-monograph.htmlother3.1 KB
shared/assets/snippets/01-cover-mosaic.htmlother2.4 KB
shared/assets/snippets/01-cover-paper-collage.htmlother3.1 KB
shared/assets/snippets/01-cover-split.htmlother2.8 KB
shared/assets/snippets/01-cover-stripes.htmlother2.4 KB
shared/assets/snippets/01-cover-workbook-notes.htmlother3.8 KB
shared/assets/snippets/02-agenda.htmlother21.2 KB
shared/assets/snippets/03-timeline.htmlother14.2 KB
shared/assets/snippets/04-map.htmlother16.3 KB
shared/assets/snippets/05-mechanism.htmlother14.5 KB
shared/assets/snippets/06-traits-grid.htmlother16.9 KB
shared/assets/snippets/07-meter.htmlother17.1 KB
shared/assets/snippets/08-compare-2.htmlother18.2 KB
shared/assets/snippets/09-compare-table.htmlother16.0 KB
shared/assets/snippets/10-hub.htmlother15.1 KB
shared/assets/snippets/11-levels.htmlother15.1 KB
shared/assets/snippets/12-tile-grid.htmlother12.3 KB
shared/assets/snippets/13-sequence.htmlother15.0 KB
shared/assets/snippets/14-mapping.htmlother13.7 KB
shared/assets/snippets/15-mock-legend.htmlother11.2 KB
shared/assets/snippets/16-mock-options.htmlother10.5 KB
shared/assets/snippets/17-statement.htmlother7.5 KB
shared/assets/snippets/18-build-up.htmlother14.0 KB
shared/assets/snippets/19-frame-form.htmlother9.2 KB
shared/assets/snippets/20-before-after.htmlother13.6 KB
shared/assets/snippets/21-worked-example.htmlother16.5 KB
shared/assets/snippets/22-worked-artifact.htmlother9.2 KB
shared/assets/snippets/23-quiz-ab.htmlother7.1 KB
shared/assets/snippets/24-quiz-sort.htmlother8.0 KB
shared/assets/snippets/25-quiz-ox.htmlother6.9 KB
shared/assets/snippets/26-rules-dark.htmlother13.7 KB
shared/assets/snippets/27-checklist.htmlother8.3 KB
shared/assets/snippets/28-sources.htmlother9.8 KB
shared/assets/snippets/29-closing.htmlother6.0 KB
shared/assets/snippets/30-check.htmlother10.3 KB
shared/assets/snippets/31-stat-strip.htmlother11.4 KB
shared/assets/snippets/32-screen-cite.htmlother14.1 KB
shared/assets/snippets/33-chart-bar.htmlother17.0 KB
shared/assets/snippets/34-chart-line.htmlother17.9 KB
shared/assets/snippets/35-explore.htmlother9.6 KB
shared/assets/snippets/36-detail-sheet.htmlother9.9 KB
shared/assets/snippets/37-arch-flow.htmlother17.2 KB
shared/assets/snippets/38-part-divider.htmlother7.0 KB
shared/assets/snippets/39-quadrant.htmlother10.0 KB
shared/assets/snippets/40-flashcards.htmlother12.4 KB
shared/assets/snippets/41-ops-report.htmlother22.8 KB
shared/assets/snippets/42-sankey-flow.htmlother9.7 KB
shared/assets/snippets/43-decision-tree.htmlother8.7 KB
shared/assets/snippets/44-kanban-board.htmlother9.4 KB
shared/assets/snippets/45-version-graph.htmlother8.9 KB
shared/assets/snippets/46-event-fanout.htmlother8.1 KB
shared/assets/snippets/47-route-tour.htmlother9.3 KB
shared/assets/snippets/48-waterfall.htmlother7.9 KB
shared/assets/snippets/49-mesh-network.htmlother7.8 KB
shared/assets/snippets/50-heatmap-grid.htmlother11.9 KB
shared/assets/snippets/51-swimlane.htmlother8.2 KB
shared/assets/snippets/52-cycle-ring.htmlother7.1 KB
shared/assets/snippets/53-verdict.htmlother6.9 KB
shared/assets/snippets/54-diagnose.htmlother3.0 KB
shared/assets/snippets/55-window-frame.htmlother3.3 KB
shared/assets/snippets/56-gate-chain.htmlother5.6 KB
shared/assets/snippets/patterns/code.htmlother1.2 KB
shared/assets/snippets/patterns/faq.htmlother839 B
shared/assets/snippets/patterns/fx.htmlother2.8 KB
shared/assets/snippets/patterns/pin-shot.htmlother1.5 KB
shared/assets/snippets/patterns/tabs.htmlother1.1 KB
shared/assets/style-sheets/README.mdmarkdown1.7 KB
shared/assets/style-sheets/previews/clean-professional.pngbinary1.4 MB
shared/assets/style-sheets/previews/creative-magazine.pngbinary2.1 MB
shared/assets/style-sheets/previews/data-dashboard.pngbinary1.3 MB
shared/assets/style-sheets/previews/e-ink-magazine.pngbinary2.4 MB
shared/assets/style-sheets/previews/handdrawn-technical.pngbinary2.0 MB
shared/assets/style-sheets/previews/handdrawn-whiteboard.pngbinary1.9 MB
shared/assets/style-sheets/previews/mckinsey-style.pngbinary1.7 MB
shared/assets/style-sheets/previews/party-government-red.pngbinary1.5 MB
shared/assets/style-sheets/previews/retro-flat-illustration.pngbinary2.3 MB
shared/assets/style-sheets/previews/scientific-defense.pngbinary1.4 MB
shared/assets/style-sheets/previews/teaching-courseware.pngbinary1.4 MB
shared/assets/style-sheets/previews/warm-handmade.pngbinary2.3 MB
shared/assets/style-sheets/党政红风格.mdmarkdown8.5 KB
shared/assets/style-sheets/创意杂志风.mdmarkdown3.3 KB
shared/assets/style-sheets/复古扁平插画风.mdmarkdown3.3 KB
shared/assets/style-sheets/手绘技术解释风.mdmarkdown4.7 KB
shared/assets/style-sheets/手绘白板风.mdmarkdown3.3 KB
shared/assets/style-sheets/教学课件风.mdmarkdown9.7 KB
shared/assets/style-sheets/数据仪表盘风.mdmarkdown3.4 KB
shared/assets/style-sheets/清爽专业风.mdmarkdown4.4 KB
shared/assets/style-sheets/温暖手工风.mdmarkdown3.3 KB
shared/assets/style-sheets/电子墨水杂志风.mdmarkdown4.6 KB
shared/assets/style-sheets/科研答辩风.mdmarkdown9.1 KB
shared/assets/style-sheets/麦肯锡风格.mdmarkdown14.8 KB
shared/dev/README.mdmarkdown12.7 KB
shared/dev/crayon-reference.htmlother19.1 KB
shared/dev/defect_test.pyscript5.7 KB
shared/dev/fill_test.pyscript3.4 KB
shared/dev/make_icons.pyscript10.0 KB
shared/dev/make_snippets.pyscript16.0 KB
shared/dev/pack_shell_template.htmlother35.7 KB
shared/dev/port.pyscript1.5 KB
shared/dev/shell_template.htmlother61.0 KB
shared/dev/test_absorb_snippets.pyscript5.5 KB
shared/dev/test_arch_lanes.pyscript12.0 KB
shared/dev/test_arch_si.pyscript17.5 KB
shared/dev/test_arch_trace.pyscript5.6 KB
shared/dev/test_check_talk_est.pyscript4.1 KB
shared/dev/test_chrome_menu.pyscript13.2 KB
shared/dev/test_consult_chart.pyscript35.9 KB
shared/dev/test_consult_regen.pyscript3.5 KB
shared/dev/test_consulting_check.pyscript7.4 KB
shared/dev/test_contrast_backdrop.pyscript8.6 KB
shared/dev/test_contrast_matrix.pyscript9.2 KB
shared/dev/test_cover_art.pyscript10.7 KB
shared/dev/test_cover_custom.pyscript10.8 KB
shared/dev/test_cover_rework.pyscript8.3 KB
shared/dev/test_dblclick_finish.pyscript6.5 KB
shared/dev/test_diagram_variants.pyscript13.8 KB
shared/dev/test_extract_copy.pyscript7.3 KB
shared/dev/test_extract_style.pyscript13.8 KB
shared/dev/test_figslot.pyscript14.0 KB
shared/dev/test_final_gate.pyscript2.5 KB
shared/dev/test_flint_model.pyscript5.5 KB
shared/dev/test_flint_theme.pyscript4.6 KB
shared/dev/test_free_mode.pyscript10.7 KB
shared/dev/test_fx_absorb.pyscript13.8 KB
shared/dev/test_fx_draft.pyscript38.0 KB
shared/dev/test_fx_patterns.pyscript16.8 KB
shared/dev/test_key_motion.pyscript9.3 KB
shared/dev/test_koboyo_icons.pyscript8.6 KB
shared/dev/test_miniflow.pyscript11.7 KB
shared/dev/test_motion_techniques.pyscript11.9 KB
shared/dev/test_ops_report.pyscript11.4 KB
shared/dev/test_pack_browser.pyscript15.7 KB
shared/dev/test_pack_checker.pyscript10.1 KB
shared/dev/test_pack_icons.pyscript6.5 KB
shared/dev/test_pack_router.pyscript5.1 KB

shared/dev/test_arch_si.py

View on GitHub
#!/usr/bin/env python3
"""arch_layout.mjs SI 확장 옵션 계약 시험 (SI 실무형 구성도 Step 5).

[목적] 생성기 확장 7종을 잠근다 —
   ① edges[].kind:'r'  → k-ln-g + stroke-dasharray 8 8 + marker-end ah-open
   ② zones[].kind      → member 는 k-paper 면색 띠 / trust·미지정은 k-frame 점선
   ③ zones[].between   → 두 존 사이 점선 polyline 경계 + 라벨
   ④ zones[].labelPos  → top|bottom 라벨 방향
   ⑤ 범례 자동 유도    → legend 생략 + 사용 kind 2종 이상이면 자동 생성
   ⑥ edges[].aux:true  → data-step 없는 정적 보조선, draw 예산(12) 밖
   ⑦ layout.chipAvoid  → 옵트인 라벨 칩 상호 충돌 회피
   + ah-open 마커가 assets/icons/extra.svg 에 존재
   + 결정성: 같은 모델 두 번 생성은 바이트 동일
[입력] 인라인 모델 JSON을 /tmp 에 생성 → node 로 생성기 실행 → svg 문자열 검사.
[출력] 없음(단정문).
"""
import json
import re
import subprocess
import tempfile
import unittest
from pathlib import Path

S = Path(__file__).resolve().parents[1]
GEN = S / 'scripts' / 'arch_layout.mjs'
EXTRA = S / 'assets/icons' / 'extra.svg'

BASE = {
    'title': '시험', 'small': 's', 'ariaLabel': '시험용',
    'layout': {'dir': 'LR', 'ranksep': 40, 'nodesep': 30},
    'steps': {'zones': 1, 'nodes': 2, 'edges': 3},
    'nodes': [
        {'id': 'a', 'name': 'A', 'icon': 'i-globe', 'w': 120, 'h': 96},
        {'id': 'b', 'name': 'B', 'icon': 'i-server', 'w': 120, 'h': 96},
        {'id': 'c', 'name': 'C', 'icon': 'i-db', 'w': 120, 'h': 96},
        {'id': 'd', 'name': 'D', 'icon': 'i-doc', 'w': 120, 'h': 96},
    ],
    'edges': [],
    'zones': [],
    'notes': '시험용 장입니다. 생성기 확장 옵션만 검증하며 실제 시스템과 무관합니다.',
}


def gen(model):
    with tempfile.NamedTemporaryFile('w', suffix='.json', delete=False, encoding='utf-8') as f:
        json.dump(model, f, ensure_ascii=False)
        mpath = f.name
    out = Path(mpath).with_suffix('.html')
    r = subprocess.run(['node', str(GEN), mpath, '-o', str(out), '--quiet'],
                       capture_output=True, text=True)
    if r.returncode != 0:
        raise AssertionError(f'생성 실패: {r.stderr.strip() or r.stdout.strip()}')
    return out.read_text(encoding='utf-8')


def m(**kw):
    d = json.loads(json.dumps(BASE))
    d.update(kw)
    return d


class MarkerTest(unittest.TestCase):
    def test_extra_svg_has_open_marker(self):
        svg = EXTRA.read_text(encoding='utf-8')
        self.assertIn('id="ah-open"', svg)


class KindRTest(unittest.TestCase):
    def test_response_edge_dashed_open_head(self):
        svg = gen(m(edges=[{'from': 'a', 'to': 'b', 'label': '응답', 'kind': 'r'}]))
        self.assertIn('stroke-dasharray="8 8"', svg)
        self.assertIn('marker-end="url(#ah-open)"', svg)
        self.assertIn('k-ln-g', svg)


class ZoneKindTest(unittest.TestCase):
    def test_member_paper_trust_frame(self):
        svg = gen(m(zones=[
            {'id': 'z1', 'label': '소속', 'members': ['a', 'b'], 'kind': 'member'},
            {'id': 'z2', 'label': '경계', 'members': ['c', 'd']},
        ]))
        self.assertIn('k-paper', svg.split('소속')[0])
        self.assertIn('k-frame', svg.split('경계')[0])


class BetweenTest(unittest.TestCase):
    def test_boundary_polyline_and_label(self):
        svg = gen(m(zones=[
            {'id': 'z1', 'label': '내부', 'members': ['a', 'b'], 'kind': 'member'},
            {'id': 'z2', 'label': '외부', 'members': ['c', 'd'], 'kind': 'member'},
            {'id': 'bt', 'label': '신뢰 경계', 'between': ['z1', 'z2']},
        ]))
        self.assertIn('stroke-dasharray="11 9"', svg)
        self.assertIn('신뢰 경계', svg)


class LabelPosTest(unittest.TestCase):
    def test_bottom_label_moves_down(self):
        # franja inferior libre → labelPos bottom se respeta
        nodes2 = [n for n in BASE['nodes'] if n['id'] in ('a', 'b')]
        def ly(pos):
            svg = gen(m(nodes=nodes2,
                        zones=[{'id': 'z', 'label': 'L', 'members': ['a', 'b'],
                                'kind': 'member', 'labelPos': pos}]))
            for seg in svg.split('<text'):
                if 'L</text>' in seg:
                    return float(seg.split('y="')[1].split('"')[0])
            raise AssertionError('존 라벨 없음')
        self.assertGreater(ly('bottom'), ly('top'))

    def test_blocked_bottom_falls_back_to_top_strip(self):
        # nodos ajenos invaden la franja inferior → la etiqueta cae en la franja libre
        def ly(pos):
            svg = gen(m(zones=[{'id': 'z', 'label': 'L', 'members': ['a', 'b'],
                                'kind': 'member', 'labelPos': pos}]))
            for seg in svg.split('<text'):
                if 'L</text>' in seg:
                    return float(seg.split('y="')[1].split('"')[0])
            raise AssertionError('존 라벨 없음')
        self.assertEqual(ly('bottom'), ly('top'))


class AutoLegendTest(unittest.TestCase):
    def test_legend_synthesized_from_used_kinds(self):
        svg = gen(m(edges=[
            {'from': 'a', 'to': 'b', 'label': '1', 'kind': 'b'},
            {'from': 'a', 'to': 'c', 'label': '2', 'kind': 'r'},
        ]))
        self.assertIn('동기 호출', svg)
        self.assertIn('응답', svg)

    def test_explicit_legend_wins(self):
        svg = gen(m(edges=[{'from': 'a', 'to': 'b', 'label': '1', 'kind': 'b'}],
                    legend=[{'kind': 'b', 'label': '커스텀'}]))
        self.assertIn('커스텀', svg)
        self.assertNotIn('동기 호출', svg)


class AuxTest(unittest.TestCase):
    def test_aux_edge_has_no_step_and_skips_budget(self):
        edges = [{'from': 'a', 'to': 'b', 'label': f'e{i}', 'kind': 'b'} for i in range(12)]
        edges.append({'from': 'b', 'to': 'a', 'label': '보조', 'kind': 'g', 'aux': True})
        svg = gen(m(edges=edges))                      # 13개여도 aux 는 예산 밖 → 통과
        aux_seg = svg.split('보조')[0].rsplit('<g', 1)[1]
        self.assertNotIn('data-step', aux_seg.split('>', 1)[0])


SI_MODELS = S.parents[1] / 'examples' / 'arch-si' / 'models'


def gen_with_coords(model_path):
    """실제 모델 파일로 생성기 실행 — (svg, coords dict)."""
    out = Path(tempfile.mkdtemp(prefix='edudeck-si-')) / 'out.html'
    cpath = out.with_suffix('.coords.json')
    r = subprocess.run(['node', str(GEN), str(model_path), '-o', str(out),
                        '--coords', str(cpath), '--quiet'],
                       capture_output=True, text=True)
    if r.returncode != 0:
        raise AssertionError(f'생성 실패: {r.stderr.strip() or r.stdout.strip()}')
    return out.read_text(encoding='utf-8'), json.loads(cpath.read_text(encoding='utf-8'))


def seg_rect(p, q, r):
    """선분 p→q 가 사각형 r 과 교차하면 True(내부 포함 또는 변 교차)."""
    def inside(v):
        return r['x0'] < v['x'] < r['x1'] and r['y0'] < v['y'] < r['y1']
    if inside(p) or inside(q):
        return True
    def ccw(a, b, c):
        return (b['x'] - a['x']) * (c['y'] - a['y']) - (b['y'] - a['y']) * (c['x'] - a['x'])
    def crosses(a, b, c, d):
        return ccw(a, b, c) * ccw(a, b, d) < 0 and ccw(c, d, a) * ccw(c, d, b) < 0
    cs = [{'x': r['x0'], 'y': r['y0']}, {'x': r['x1'], 'y': r['y0']},
          {'x': r['x1'], 'y': r['y1']}, {'x': r['x0'], 'y': r['y1']}]
    return any(crosses(p, q, cs[i], cs[(i + 1) % 4]) for i in range(4))


class AuxRouteTest(unittest.TestCase):
    """aux 보조선 직교 우회 — 전 구간이 노드 사각형과 무교차여야 한다."""

    def _aux_pts(self, name):
        mp = SI_MODELS / f'{name}.json'
        if not mp.exists():
            self.skipTest(f'{name} 모델 없음')
        model = json.loads(mp.read_text(encoding='utf-8'))
        auxs = [(e['from'], e['to']) for e in model['edges'] if e.get('aux')]
        if not auxs:
            self.skipTest(f'{name}: aux 엣지 없음')
        _, coords = gen_with_coords(mp)
        return model, coords, auxs

    def test_aux_segments_clear_node_rects(self):
        for name in ('a1b-detail', 'c3-dr'):
            _, coords, auxs = self._aux_pts(name)
            rects = {nid: {'x0': nn['x'] - nn['w'] / 2, 'x1': nn['x'] + nn['w'] / 2,
                           'y0': nn['y'] - nn['h'] / 2, 'y1': nn['y'] + nn['h'] / 2}
                     for nid, nn in coords['nodes'].items()}
            for a, b in auxs:
                pts = next(e['pts'] for e in coords['edges'] if e['a'] == a and e['b'] == b)
                for i in range(1, len(pts)):
                    for nid, r in rects.items():
                        if nid in (a, b):
                            continue
                        self.assertFalse(
                            seg_rect(pts[i - 1], pts[i], r),
                            f'{name}: aux {a}->{b} 세그먼트 {i}이 노드 {nid} 와 교차')

    def test_aux_models_deterministic(self):
        for name in ('a1b-detail', 'c3-dr'):
            mp = SI_MODELS / f'{name}.json'
            if not mp.exists():
                self.skipTest(f'{name} 모델 없음')
            a = gen_with_coords(mp)[0]
            b = gen_with_coords(mp)[0]
            self.assertEqual(a, b, f'{name}: 두 실행 결과가 다르다')


class BoundaryLabelTest(unittest.TestCase):
    """경계 라벨 기본값(bottom) — 정규화 좌표로 존 사각형 하단 밖에 놓여야 한다."""

    def test_bottom_label_below_zone(self):
        mp = SI_MODELS / 'a1a-overview.json'
        if not mp.exists():
            self.skipTest('a1a 모델 없음')
        svg, coords = gen_with_coords(mp)
        model = json.loads(mp.read_text(encoding='utf-8'))
        bounds = [z for z in model['zones'] if z.get('between')]
        if not bounds:
            self.skipTest('a1a: 경계 존 없음')
        # 경계 라벨(신뢰 경계)의 정규화 y 추출
        label = bounds[0].get('label', '신뢰 경계')
        m2 = re.search(r'<text[^>]*y="([\d.]+)"[^>]*>' + re.escape(label) + r'</text>', svg)
        self.assertIsNotNone(m2, f'경계 라벨 "{label}" 텍스트를 찾지 못했다')
        y_label = float(m2.group(1))
        zrs = [next(z['r'] for z in coords['zones'] if z['id'] == zid) for zid in bounds[0]['between']]
        # 경계선 방향 판별 — 수직선(좌우 분리)이면 라벨은 두 존 위(선 상단)에,
        # 수평선(상하 분리)이면 첫 존 하단 밖에 놓인다. 둘 다 존 사각형 밖이 계약이다.
        pline = re.search(r'<polyline points="([^"]+)"[^>]*stroke-dasharray="11 9"', svg)
        self.assertIsNotNone(pline, '경계 polyline 없음')
        pts = [tuple(map(float, p.split(','))) for p in pline.group(1).split()]
        vertical = abs(pts[-1][0] - pts[0][0]) < 2
        if vertical:
            self.assertLess(y_label, min(z['y0'] for z in zrs),
                            f'수직 경계 라벨 y={y_label} 가 존 상단 안쪽에 있다')
        else:
            self.assertGreater(y_label, zrs[0]['y1'],
                               f'경계 라벨 y={y_label} 가 존 하단 {zrs[0]["y1"]} 안에 있다(정규화 미적용 버그 회귀)')


class FallbackChipTest(unittest.TestCase):
    """labelPos fallback 도 placedChips 등록 — 이후 칩이 fallback 칩과 겹치면 안 된다."""

    def test_chips_pairwise_disjoint_on_fallback_models(self):
        # fallback 이 실제 발생하는 chipAvoid 모델(a1b:1, c3:2)의 라벨 칩 무겹침 회귀 가드.
        # (b3-batch 는 HEAD 시점부터 칩 겹침 1건이 선재 — 별도 과제라 여기선 제외)
        import itertools
        for name in ('a1b-detail', 'c3-dr'):
            mp = SI_MODELS / f'{name}.json'
            if not mp.exists():
                self.skipTest(f'{name} 모델 없음')
            svg, _ = gen_with_coords(mp)
            chips = [tuple(map(float, g)) for g in
                     re.findall(r'<rect class="k-paper" x="([\d.]+)" y="([\d.]+)" width="([\d.]+)" height="36"', svg)]
            def ov(a, b):
                return a[0] < b[0] + b[2] and a[0] + a[2] > b[0] and a[1] < b[1] + 36 and a[1] + 36 > b[1]
            bad = [(a, b) for a, b in itertools.combinations(chips, 2) if ov(a, b)]
            self.assertFalse(bad, f'{name}: 라벨 칩 겹침 {len(bad)}건')


class ChipAvoidTest(unittest.TestCase):
    def test_avoid_keeps_demo_chips_separated(self):
        # 회피가 상시 동작 — 기존 데모 모델에서 칩 겹침이 없어야 한다
        demo = S.parents[1] / 'examples' / 'arch-demo' / 'models' / '01-microservices.json'
        if not demo.exists():
            self.skipTest('기존 데모 모델 없음')
        svg = gen(json.loads(demo.read_text(encoding='utf-8')))
        chips = [tuple(map(float, g)) for g in
                 re.findall(r'<rect class="k-paper" x="([\d.]+)" y="([\d.]+)" width="([\d.]+)" height="36"', svg)]
        import itertools
        def ov(a, b):
            return a[0] < b[0] + b[2] and a[0] + a[2] > b[0] and a[1] < b[1] + 36 and a[1] + 36 > b[1]
        bad = [(a, b) for a, b in itertools.combinations(chips, 2) if ov(a, b)]
        self.assertFalse(bad, f'라벨 칩 겹침 {len(bad)}건')


class OrthoRouteTest(unittest.TestCase):
    """직교 배선 계약 — 방출된 path·line·polyline 세그먼트에 사선이 없어야 한다."""

    def test_no_diagonal_segments(self):
        svg = gen(m(edges=[
            {'from': 'a', 'to': 'b'}, {'from': 'a', 'to': 'c'},
            {'from': 'b', 'to': 'd'}, {'from': 'd', 'to': 'a', 'aux': True},
        ]))
        body = svg[svg.find('<svg'):svg.find('</svg>')]
        diag = 0
        for d in re.findall(r'<path[^>]*d="([^"]+)"', body):
            pts = [(float(a), float(b)) for a, b in re.findall(r'[MLQ]\s*([\d.\-]+)\s+([\d.\-]+)', d)]
            diag += sum(1 for i in range(1, len(pts))
                        if abs(pts[i][0] - pts[i-1][0]) > 0.5 and abs(pts[i][1] - pts[i-1][1]) > 0.5)
        self.assertEqual(diag, 0, '사선 세그먼트 발견')


class NestedZoneTest(unittest.TestCase):
    """존 중첩은 parent 체인으로 3단계까지 — 4단계는 FAIL."""

    def _zones(self):
        return [
            {'id': 'l1', 'label': 'L1', 'members': [], 'headerStyle': 'solid-navy'},
            {'id': 'l2', 'label': 'L2', 'members': ['a', 'b'], 'parent': 'l1'},
            {'id': 'l3', 'label': 'L3', 'members': ['c'], 'parent': 'l2'},
            {'id': 'l4', 'label': 'L4', 'members': ['d'], 'parent': 'l3'},
        ]

    def test_three_levels_emit(self):
        svg = gen(m(zones=self._zones()[:3]))
        self.assertIn('k-zface', svg)
        self.assertIn('L3', svg)

    def test_fourth_level_fails(self):
        r = subprocess.run(['node', str(GEN), self._tmp(self._zones()), '-o', '/dev/null'],
                           capture_output=True, text=True)
        self.assertNotEqual(r.returncode, 0)
        self.assertIn('중첩', r.stderr)

    @staticmethod
    def _tmp(zones):
        import tempfile, os
        f = tempfile.NamedTemporaryFile('w', suffix='.json', delete=False, encoding='utf-8')
        json.dump(m(zones=zones), f, ensure_ascii=False)
        f.close()
        return f.name


class BusHATest(unittest.TestCase):
    """버스 = 백본 + T-드롭(draw 예산 밖)·from×to 점대점 자동 제거 / HA쌍 = 이중선."""

    def test_bus_trunk_drops_and_dedupe(self):
        svg = gen(m(edges=[{'from': 'a', 'to': 'c'}, {'from': 'b', 'to': 'c'}],
                    buses=[{'id': 'bs', 'from': ['a'], 'to': ['c', 'd']}]))
        self.assertIn('k-bus-trunk', svg)
        body = svg[svg.find('<svg'):svg.find('</svg>')]
        # 백본 1 + from 1개·to 2개 T-드롭 = 4개 polyline
        self.assertEqual(len(re.findall(r'<polyline class="k-bus-', body)), 4)

    def test_ha_pair_double_line(self):
        svg = gen(m(haPairs=[['a', 'b']]))
        self.assertIn('k-hab', svg)
        self.assertGreaterEqual(svg.count('class="k-ha"'), 2)


class MicroTypoTest(unittest.TestCase):
    """마이크로 타이포 계약 — k-t-spec/eq/qty 는 svg.dg 안에서만 12px+ 허용.
    계약 근거는 architecture.md 문서 + check_deck 스코프 규칙 + CSS 크기다."""

    def test_checker_keeps_scoped_rule(self):
        src = (S / 'scripts' / 'check_deck.py').read_text(encoding='utf-8')
        self.assertIn('k-t-(spec|eq|qty)', src)
        self.assertIn('svg.dg', src)

    def test_css_sizes_within_contract(self):
        css = (S / 'assets' / 'css' / 'visual-motion.css').read_text(encoding='utf-8')
        for cls in ('k-t-spec', 'k-t-eq', 'k-t-qty'):
            mt = re.search(rf'\.{cls}\{{[^}}]*font-size:(\d+)px', css)
            self.assertIsNotNone(mt, f'{cls} 크기 정의 없음')
            self.assertTrue(12 <= int(mt.group(1)) <= 16, f'{cls} {mt.group(1)}px — 12~16px 계약 밖')


class IconA11yTest(unittest.TestCase):
    def test_use_icons_aria_hidden(self):
        nodes = [dict(n) for n in BASE['nodes']]
        nodes[0].update(template='equip', icon='i-si-fw')
        svg = gen(m(nodes=nodes, edges=[{'from': 'a', 'to': 'b'}]))
        body = svg[svg.find('<svg'):svg.find('</svg>')]
        uses = re.findall(r'<use\b[^>]*>', body)
        self.assertTrue(uses)
        self.assertTrue(all('aria-hidden="true"' in u for u in uses),
                        'aria-hidden 없는 아이콘 use 발견')


class DeterminismTest(unittest.TestCase):
    def test_same_model_same_bytes(self):
        model = m(edges=[{'from': 'a', 'to': 'b', 'label': '1', 'kind': 'r'}],
                  zones=[{'id': 'z', 'label': 'Z', 'members': ['a', 'b'], 'kind': 'member'}])
        self.assertEqual(gen(model), gen(model))


if __name__ == '__main__':
    unittest.main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall