@haposoft/cafekit 0.8.15 → 0.8.17

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.
@@ -1,156 +0,0 @@
1
- ---
2
- description: Generate implementation tasks for a specification
3
- allowed-tools: Glob, Grep, Read, Write, Edit, WebSearch, WebFetch
4
- argument-hint: <feature-name> [-y] [--sequential]
5
- ---
6
-
7
- # Implementation Tasks Generator
8
-
9
- <background_information>
10
- - **Mission**: Generate detailed, actionable implementation tasks that translate technical design into executable work items
11
- - **Success Criteria**:
12
- - All requirements mapped to specific tasks
13
- - Tasks properly sized (1-3 hours each)
14
- - Clear task progression with proper hierarchy
15
- - Natural language descriptions focused on capabilities
16
- </background_information>
17
-
18
- <instructions>
19
- ## Core Task
20
- Generate implementation tasks for feature **$ARGUMENTS** based on approved requirements and design.
21
-
22
- ## Execution Steps
23
-
24
- ### Step 0: Validate Phase State (Plan-Style Gate)
25
-
26
- - Read `.specs/$ARGUMENTS/spec.json` first
27
- - If feature directory or `spec.json` is missing: stop and instruct user to run `/spec-init <project-description>`, `/spec-requirements <feature-name>`, and `/spec-design <feature-name>` first
28
- - If design has not been generated yet (phase before design): stop and instruct user to run `/spec-design $ARGUMENTS`
29
- - If `phase` is already `tasks-generated`: explain tasks phase already exists and only continue for explicit regeneration/merge intent
30
-
31
- ### Step 1: Load Context
32
-
33
- **Read all necessary context**:
34
- - `.specs/$ARGUMENTS/spec.json`, `requirements.md`, `design.md`
35
- - `.specs/$ARGUMENTS/tasks.md` (if exists, for merge mode)
36
- - `.specs/$ARGUMENTS/research.md` (if exists, includes validation log)
37
- - **Entire `.specs/steering/` directory** for complete project memory (if exists)
38
- - **Load project docs context (Plan-style quality gate)** when available:
39
- - `docs/codebase-summary.md`
40
- - `docs/code-standards.md`
41
- - `docs/system-architecture.md`
42
- - `docs/project-overview-pdr.md`
43
- - If any docs file is missing, continue and mention missing context in execution output (do not block generation)
44
-
45
- **Validate approvals**:
46
- - If `-y` flag provided: Auto-approve requirements and design in spec.json
47
- - Otherwise: Verify both approved (stop if not, see Safety & Fallback)
48
- - **Backward compatibility fallback (older specs):**
49
- - If `validation` object is missing, treat validation status as `not-run`
50
- - If `design_context` object is missing, treat `validation_recommended` as `false`
51
- - If `spec.json.validation.status == "completed"`, treat validation as satisfied
52
- - If validation is missing and `design_context.validation_recommended == true`, warn user to run `/spec-validate $ARGUMENTS` before continuing (do not hard-block)
53
- - Determine sequential mode based on presence of `--sequential`
54
-
55
- ### Step 2: Generate Implementation Tasks
56
-
57
- **Load generation rules and template**:
58
- - Read `{{SKILLS_DIR}}/specs/rules/tasks-generation.md` for principles
59
- - If `sequential` is **false**: Read `{{SKILLS_DIR}}/specs/rules/tasks-parallel-analysis.md` for parallel judgement criteria
60
- - Read `{{SKILLS_DIR}}/specs/templates/tasks.md` for format (supports `(P)` markers)
61
-
62
- **Generate task list following all rules**:
63
- - Use language specified in spec.json
64
- - Map all requirements to tasks
65
- - When documenting requirement coverage, list numeric requirement IDs only (comma-separated) without descriptive suffixes, parentheses, translations, or free-form labels
66
- - Ensure all design components included
67
- - Verify task progression is logical and incremental
68
- - Collapse single-subtask structures by promoting them to major tasks and avoid duplicating details on container-only major tasks (use template patterns accordingly)
69
- - Apply `(P)` markers to tasks that satisfy parallel criteria (omit markers in sequential mode)
70
- - Mark optional test coverage subtasks with `- [ ]*` only when they strictly cover acceptance criteria already satisfied by core implementation and can be deferred post-MVP
71
- - If existing tasks.md found, merge with new content
72
-
73
- ### Step 3: Finalize
74
-
75
- **Write and update**:
76
- - Create/update `.specs/$ARGUMENTS/tasks.md`
77
- - Update spec.json metadata:
78
- - Set `phase: "tasks-generated"`
79
- - Set `approvals.tasks.generated: true, approved: false`
80
- - Set `approvals.requirements.approved: true`
81
- - Set `approvals.design.approved: true`
82
- - Update `updated_at` timestamp
83
-
84
- ## Critical Constraints
85
- - **Follow rules strictly**: All principles in tasks-generation.md are mandatory
86
- - **Natural Language**: Describe what to do, not code structure details
87
- - **Complete Coverage**: ALL requirements must map to tasks
88
- - **Maximum 2 Levels**: Major tasks and sub-tasks only (no deeper nesting)
89
- - **Sequential Numbering**: Major tasks increment (1, 2, 3...), never repeat
90
- - **Task Integration**: Every task must connect to the system (no orphaned work)
91
- </instructions>
92
-
93
- ## Tool Guidance
94
- - **Read first**: Load all context, rules, and templates before generation
95
- - **Write last**: Generate tasks.md only after complete analysis and verification
96
-
97
- ## Output Description
98
-
99
- Provide brief summary in the language specified in spec.json:
100
-
101
- 1. **Status**: Confirm tasks generated at `.specs/$ARGUMENTS/tasks.md`
102
- 2. **Task Summary**:
103
- - Total: X major tasks, Y sub-tasks
104
- - All Z requirements covered
105
- - Average task size: 1-3 hours per sub-task
106
- 3. **Quality Validation**:
107
- - ✅ All requirements mapped to tasks
108
- - ✅ Task dependencies verified
109
- - ✅ Testing tasks included
110
- 4. **Next Action**: Review tasks and proceed when ready
111
-
112
- **Format**: Concise (under 200 words)
113
-
114
- ## Safety & Fallback
115
-
116
- ### Error Scenarios
117
-
118
- **Requirements or Design Not Approved**:
119
- - **Stop Execution**: Cannot proceed without approved requirements and design
120
- - **User Message**: "Requirements and design must be approved before task generation"
121
- - **Suggested Action**: "Run `/spec-tasks $ARGUMENTS -y` to auto-approve both and proceed"
122
-
123
- **Missing Requirements or Design**:
124
- - **Stop Execution**: Both documents must exist
125
- - **User Message**: "Missing requirements.md or design.md at `.specs/$ARGUMENTS/`"
126
- - **Suggested Action**: "Complete requirements and design phases first"
127
-
128
- **Incomplete Requirements Coverage**:
129
- - **Warning**: "Not all requirements mapped to tasks. Review coverage."
130
- - **User Action Required**: Confirm intentional gaps or regenerate tasks
131
-
132
- **Template/Rules Missing**:
133
- - **User Message**: "Template or rules files missing in `{{SKILLS_DIR}}/specs/`"
134
- - **Fallback**: Use inline basic structure with warning
135
- - **Suggested Action**: "Check repository setup or restore template files"
136
-
137
- **Missing Numeric Requirement IDs**:
138
- - **Stop Execution**: All requirements in requirements.md MUST have numeric IDs. If any requirement lacks a numeric ID, stop and request that requirements.md be fixed before generating tasks.
139
-
140
- ### Next Phase: Implementation
141
-
142
- **Before Starting Implementation**:
143
- - **IMPORTANT**: Clear conversation history and free up context before running `/code`
144
- - This applies when starting first task OR switching between tasks
145
- - Fresh context ensures clean state and proper task focus
146
-
147
- **If Tasks Approved**:
148
- - Execute coding pass from approved spec tasks: `/code $ARGUMENTS`
149
- - After coding, run `/test` then `/review`
150
- - Repeat in small passes and clear context between iterations when needed
151
-
152
- **If Modifications Needed**:
153
- - Provide feedback and re-run `/spec-tasks $ARGUMENTS`
154
- - Existing tasks used as reference (merge mode)
155
-
156
- **Note**: Continue with `/test` then `/review` after `/code` to complete the workflow.
@@ -1,106 +0,0 @@
1
- ---
2
- description: Validate design decisions with interview questions before task generation
3
- allowed-tools: Read, Write, Edit, Glob, AskUserQuestion
4
- argument-hint: <feature-name>
5
- ---
6
-
7
- # Specification Validation Interview
8
-
9
- <background_information>
10
- - **Mission**: Validate critical design decisions, assumptions, and trade-offs before generating implementation tasks.
11
- - **Success Criteria**:
12
- - Ask targeted, concrete questions about high-impact decisions
13
- - Record answers in spec artifacts for future traceability
14
- - Update spec metadata to reflect validation status
15
- </background_information>
16
-
17
- <instructions>
18
- ## Core Task
19
- Run a structured interview for feature **$ARGUMENTS** and persist decisions.
20
-
21
- ## Execution Steps
22
-
23
- ### Step 0: Resolve & Validate State
24
- - Require `$ARGUMENTS` as feature name
25
- - Read `.specs/$ARGUMENTS/spec.json`
26
- - Stop with guidance if spec does not exist
27
- - Ensure `requirements.md` and `design.md` exist before validation
28
-
29
- ### Step 1: Load Validation Context
30
- Read:
31
- - `.specs/$ARGUMENTS/spec.json`
32
- - `.specs/$ARGUMENTS/requirements.md`
33
- - `.specs/$ARGUMENTS/design.md`
34
- - `.specs/$ARGUMENTS/research.md` (if exists)
35
-
36
- Extract decision points around:
37
- - architecture and boundaries
38
- - assumptions and defaults
39
- - integration risks
40
- - scope and sequencing
41
- - testing/security/performance trade-offs
42
-
43
- ### Step 2: Determine Question Budget
44
- Use injected session validation settings when available (`Validation: mode=X, questions=MIN-MAX`).
45
- - If unavailable, use 3-6 questions
46
- - Ask only meaningful questions that can change implementation
47
- - Each question must have 2-4 concrete options
48
-
49
- ### Step 3: Interview User
50
- Use `AskUserQuestion` in batches (max 4 questions per call).
51
- Rules:
52
- - Include one recommended option when a safe default exists
53
- - Keep options mutually exclusive
54
- - Do not ask redundant questions
55
-
56
- ### Step 4: Persist Validation Log
57
- Append to `.specs/$ARGUMENTS/research.md` under `## Validation Log`.
58
- If section missing, create it.
59
-
60
- Session format:
61
- ```markdown
62
- ## Validation Log
63
-
64
- ### Session N — YYYY-MM-DD
65
- - Questions asked: X
66
-
67
- 1. [Category] Question text
68
- - Options: A | B | C
69
- - Answer: ...
70
- - Rationale: why this decision matters
71
-
72
- #### Confirmed Decisions
73
- - ...
74
-
75
- #### Follow-up Actions
76
- - [ ] ...
77
- ```
78
-
79
- ### Step 5: Update Metadata
80
- Update `.specs/$ARGUMENTS/spec.json`:
81
- - `approvals.requirements.approved: true`
82
- - `approvals.design.approved: true`
83
- - `validation.last_validated_at: <ISO timestamp>`
84
- - `validation.questions_asked: <number>`
85
- - `validation.status: "completed"`
86
- - increment `validation.session_count` (initialize to 1 if absent)
87
- - update `updated_at`
88
-
89
- ## Constraints
90
- - Keep input/output contract of existing `spec-*` commands unchanged
91
- - Validation must be traceable and append-only (never overwrite old sessions)
92
- - Ask fewer questions when artifact is simple; quality over quantity
93
- </instructions>
94
-
95
- ## Output Description
96
- Provide concise summary:
97
- 1. Validation status and files updated
98
- 2. Number of questions asked
99
- 3. Top confirmed decisions
100
- 4. Recommended next command:
101
- - `/spec-tasks $ARGUMENTS` when ready
102
-
103
- ## Safety & Fallback
104
- - Missing spec/design artifacts: stop and instruct the exact preceding command
105
- - Empty decision surface: ask only 1-2 high-value confirmation questions
106
- - Write failure: report exact path and retry guidance
@@ -1,13 +0,0 @@
1
- ---
2
- description: Run project tests and report failures concisely.
3
- allowed-tools: Bash, Read, Grep
4
- argument-hint: [scope]
5
- ---
6
-
7
- # /test
8
-
9
- Run the project's test command and report:
10
- - total passed/failed
11
- - failing test names
12
- - root cause hints
13
- - next fix action
@@ -1,196 +0,0 @@
1
- const MIN_SCORE = 4;
2
- const WEIGHTS = { strong: 6, medium: 3, weak: 1, negative: -5 };
3
-
4
- const ROUTES = [
5
- route('hapo:hotfix', 'urgent fix or production regression', 100, {
6
- strong: ['hotfix', 'fix bug', 'fix lỗi', 'fix loi', 'sửa lỗi', 'sua loi', 'production bug', 'prod bug', 'regression', 'lỗi production', 'loi production', 'sửa gấp', 'sua gap', 'バグ修正', '不具合修正', '本番障害', '本番バグ', '緊急修正', '至急修正', 'リグレッション'],
7
- medium: ['khẩn cấp', 'khan cap', 'production', 'critical bug', 'rollback', '修正して', '直して', '緊急', '本番', '重大バグ', 'ロールバック', '障害対応'],
8
- weak: ['fix', 'fixing', 'sửa', 'sua', 'urgent', 'emergency', 'release is broken', '修正', '直す', '至急', 'リリースが壊れた'],
9
- negative: ['slide', 'pptx', 'spec', 'brainstorm'],
10
- }),
11
- route('hapo:debug', 'bug investigation or failure diagnosis', 90, {
12
- strong: ['debug', 'root cause', 'diagnose', 'stack trace', 'không chạy', 'khong chay', 'デバッグ', '原因調査', '根本原因', 'スタックトレース', '動かない'],
13
- medium: ['bug', 'error', 'exception', 'failing', 'failed', 'failure', 'broken', 'lỗi', 'loi', 'tại sao', 'tai sao', 'vì sao', 'vi sao', 'nguyên nhân', 'nguyen nhan', 'ci fail', 'build fail', 'バグ', 'エラー', '例外', '失敗', '壊れている', 'なぜ', '原因', 'ci失敗', 'ビルド失敗'],
14
- weak: ['sai', 'fail', 'issue', 'problem', '問題', '不具合'],
15
- negative: ['commit', 'push', 'slide', 'pptx'],
16
- }),
17
- route('hapo:specs', 'specification, requirements, design, tasks, or spec validation', 80, {
18
- strong: ['spec', 'specs', 'requirements', 'acceptance criteria', 'task breakdown', 'đặc tả', 'dac ta', '仕様', '仕様書', '要件', '受け入れ条件', 'タスク分解', '仕様を作って', '仕様を作成'],
19
- medium: ['requirement', 'ears', 'design doc', 'scope', '--validate', 'yêu cầu', 'yeu cau', 'phạm vi', 'pham vi', 'validate spec', 'kiểm tra spec', 'kiem tra spec', '要求', '設計書', 'スコープ', '検証', '仕様を確認'],
20
- weak: ['tính năng mới', 'tinh nang moi', 'feature idea', 'user story', 'criteria', 'task list', '新機能', 'ユーザーストーリー', '基準', 'タスクリスト'],
21
- negative: ['commit', 'push', 'bug', 'error', 'production', 'pptx', 'pdf', 'reconstruct requirements', 'as-is requirements', 'legacy system documentation', 'documentation from source code', 'docs from source code', 'ソースコードから'],
22
- }),
23
- route('hapo:develop', 'implementation from an approved spec or task list', 75, {
24
- strong: ['develop', 'implement', 'implementation', 'theo spec', 'theo specs', 'approved spec', 'làm theo spec', 'lam theo spec', '実装', '開発', '仕様に沿って', '仕様どおり', '承認済み仕様'],
25
- medium: ['build this', 'code this', 'start task', 'run task', 'thực hiện task', 'thuc hien task', 'phát triển', 'phat trien', 'bắt đầu implement', 'bat dau implement', 'vào code', 'vao code', '作って', 'コードを書いて', 'タスクを開始', 'タスクを実行', '開発して', '実装して'],
26
- weak: ['triển khai', 'trien khai', 'đưa vào code', 'dua vao code', 'code feature', 'コード化', '機能を作る'],
27
- negative: ['bug', 'debug', 'review', 'test only', 'commit'],
28
- }),
29
- route('hapo:test', 'test, verification, QA, or runtime validation', 70, {
30
- strong: ['unit test', 'integration test', 'e2e', 'playwright', 'coverage', 'test all', 'run all tests', 'test toàn bộ', 'test toan bo', 'kiểm thử', 'kiem thu', 'kiểm tra toàn bộ', 'kiem tra toan bo', '単体テスト', '結合テスト', '全体テスト', 'カバレッジ', 'テストして'],
31
- medium: ['test', 'tests', 'testing', 'qa', 'verify', 'verification', 'kiểm tra chạy', 'kiem tra chay', 'xác minh', 'xac minh', 'テスト', '検証', '確認', '動作確認', '全体確認'],
32
- weak: ['assert', 'runtime proof', 'manual qa', 'end to end', 'smoke test', 'アサート', 'スモークテスト'],
33
- negative: ['spec', 'requirements', 'commit', 'push'],
34
- }),
35
- route('hapo:code-review', 'code review, audit, security, or quality assessment', 68, {
36
- strong: ['code review', 'security review', 'performance review', 'đánh giá code', 'danh gia code', 'コードレビュー', 'セキュリティレビュー', '性能レビュー'],
37
- medium: ['review', 'audit', 'quality', 'đánh giá', 'danh gia', 'kiểm tra chất lượng', 'kiem tra chat luong', 'レビュー', '監査', '品質', '品質確認'],
38
- weak: ['risk', 'maintainability', 'readability', 'vulnerability', 'lỗ hổng', 'lo hong', 'リスク', '保守性', '可読性', '脆弱性'],
39
- negative: ['slide', 'pptx', 'commit and push'],
40
- }),
41
- route('hapo:git', 'git, commit, push, branch, tag, or pull request workflow', 65, {
42
- strong: ['commit', 'push', 'pull request', 'git', 'đẩy lên', 'day len', 'コミット', 'プッシュ', 'プルリク', 'リリースして'],
43
- medium: ['pr ', 'branch', 'tag', 'release', 'publish', 'merge', 'rebase', 'ブランチ', 'タグ', 'リリース', '公開', 'マージ', 'リベース'],
44
- weak: ['origin', 'remote', 'checkout', 'stash', 'version bump', 'リモート', 'チェックアウト', 'スタッシュ', 'バージョン更新'],
45
- negative: ['deploy', 'test', 'review only'],
46
- }),
47
- route('hapo:inspect', 'codebase discovery, file search, structure scan, or locating implementation areas', 64, {
48
- strong: ['inspect', 'codebase scan', 'scan codebase', 'scan source', 'file discovery', 'find files', 'locate files', 'xem source', 'xem codebase', 'kiểm tra source', 'kiem tra source', 'kiểm tra source code', 'kiem tra source code', 'quét source', 'quet source', 'quét codebase', 'quet codebase', 'kiểm tra cấu trúc', 'kiem tra cau truc', 'コード構造', 'ソース確認', 'コードベース確認', 'ファイル探索', '構造を確認'],
49
- medium: ['search files', 'find where', 'where is', 'project structure', 'code structure', 'repo structure', 'source code', 'tìm file', 'tim file', 'tìm trong source', 'tim trong source', 'cấu trúc project', 'cau truc project', 'ở đâu', 'o dau', 'nằm đâu', 'nam dau', '関連ファイル', 'どこにある', 'プロジェクト構造', 'リポジトリ構造', '探して'],
50
- weak: ['scan', 'inspect code', 'explore code', 'xem qua', 'xem giúp', '調べて', '確認して'],
51
- negative: ['bug', 'error', 'lỗi', 'loi', 'fail', 'failure', 'production', 'hotfix', 'fix', 'sửa', 'sua', 'debug', 'develop', 'implement', 'test', 'commit', 'push', 'slide', 'pptx'],
52
- }),
53
- route('hapo:impact-analysis', 'impact analysis before changing existing behavior', 64, {
54
- strong: ['impact analysis', 'blast radius', 'ảnh hưởng', 'anh huong', 'tác động', 'tac dong', '影響分析', '影響範囲', '影響', '副作用'],
55
- medium: ['impact', 'liên quan những đâu', 'lien quan nhung dau', 'affected files', 'dependency impact', '関連箇所', '影響ファイル', '依存関係'],
56
- weak: ['before changing', 'risk area', 'downstream', 'upstream', 'side effect', '変更前', 'リスク範囲', '下流', '上流'],
57
- negative: ['slide', 'pptx'],
58
- }),
59
- route('hapo:frontend-design', 'UI/UX design, visual style, layout, or color system', 62, {
60
- strong: ['ui design', 'visual style', 'color system', 'thiết kế giao diện', 'thiet ke giao dien', 'màu sắc', 'mau sac', 'uiデザイン', '画面デザイン', 'ビジュアルスタイル', '配色'],
61
- medium: ['ux', 'layout', 'style', 'theme', 'responsive design', 'giao diện', 'giao dien', 'wireframe', 'レイアウト', 'スタイル', 'テーマ', 'レスポンシブデザイン', '画面', 'ワイヤーフレーム', '色'],
62
- weak: ['palette', 'typography', 'spacing', 'polish ui', 'mockup', 'prototype', 'パレット', 'タイポグラフィ', '余白', 'モックアップ', 'プロトタイプ'],
63
- negative: ['backend', 'api', 'database'],
64
- }),
65
- route('hapo:react-best-practices', 'React and Next.js performance patterns, rerender optimization, and Vercel best practices', 60, {
66
- strong: ['react best practices', 'next.js best practices', 'vercel react best practices', 'react performance', 'next.js performance', 'optimize react', 'optimize next.js', 'rerender nhiều', 'rerender nhieu', 'nhiều rerender', 'nhieu rerender', 'tối ưu react', 'toi uu react', 'tối ưu next.js', 'toi uu next.js', 'reactベストプラクティス', 'next.jsベストプラクティス', 'react最適化', 'next.js最適化', 'react性能'],
67
- medium: ['bundle optimization', 'bundle size', 'rerender optimization', 're-render optimization', 'data fetching', 'server component', 'client component', 'suspense', 'hydration', 'waterfall', 'usememo', 'usecallback', 'react cache', 'optimize', 'optimization', 'tối ưu', 'toi uu', 'tối ưu rerender', 'toi uu rerender', 'tối ưu bundle', 'toi uu bundle', 'バンドル最適化', '再レンダー最適化', '最適化', 'データ取得', 'サーバーコンポーネント', 'クライアントコンポーネント', 'ハイドレーション'],
68
- weak: ['react', 'next.js', 'memo', 'rerender', 're-render', 'render performance', 'component performance', 'waterfalls', 'lazy state', 'dynamic import', 'react pattern', 'next.js pattern', 'レンダー性能', 'コンポーネント性能', '動的インポート'],
69
- negative: ['backend', 'api', 'database', 'slide', 'pptx', 'commit', 'push'],
70
- }),
71
- route('hapo:frontend-development', 'frontend implementation work', 58, {
72
- strong: ['react', 'next.js', 'vite', 'frontend', 'tailwind', 'web app', 'フロントエンド', 'webアプリ'],
73
- medium: ['component', 'css', 'html', 'browser ui', 'client side', 'giao diện react', 'コンポーネント', 'ブラウザui', 'クライアント側', 'react画面'],
74
- weak: ['state management', 'hook', 'form', 'table', 'dashboard ui', '状態管理', 'フック', 'フォーム', 'テーブル', 'ダッシュボードui'],
75
- negative: ['best practices', 'performance', 'optimize', 'optimization', 'rerender', 're-render', 'tối ưu', 'toi uu', '再レンダー', '最適化', '性能', 'backend only', 'database only', 'slide', 'pptx'],
76
- }),
77
- route('hapo:backend-development', 'backend, API, database, or service implementation', 58, {
78
- strong: ['backend', 'api', 'database', 'endpoint', 'server', 'service', 'バックエンド', 'データベース', 'エンドポイント', 'サーバー', 'サービス'],
79
- medium: ['db', 'sql', 'postgres', 'mysql', 'migration', 'schema', 'worker', 'queue', 'マイグレーション', 'スキーマ', 'ワーカー', 'キュー'],
80
- weak: ['controller', 'route handler', 'repository', 'model', 'auth service', 'コントローラ', 'ルートハンドラ', 'リポジトリ', 'モデル', '認証サービス'],
81
- negative: ['frontend only', 'slide', 'pptx'],
82
- }),
83
- route('hapo:mobile-development', 'mobile app implementation', 56, {
84
- strong: ['mobile', 'ios', 'android', 'react native', 'flutter', 'モバイル'],
85
- medium: ['app store', 'play store', 'native app', 'mobile screen', 'アプリストア', 'playストア', 'ネイティブアプリ', 'モバイル画面'],
86
- weak: ['gesture', 'push notification', 'offline sync', 'ジェスチャー', 'プッシュ通知', 'オフライン同期'],
87
- negative: ['web only', 'desktop only'],
88
- }),
89
- route('hapo:devops', 'deployment, infrastructure, CI/CD, or operations work', 54, {
90
- strong: ['deploy', 'deployment', 'docker', 'kubernetes', 'ci/cd', 'github actions', 'デプロイ', 'デプロイメント'],
91
- medium: ['vercel', 'infra', 'infrastructure', 'devops', 'pipeline', 'environment variable', 'インフラ', 'パイプライン', '環境変数'],
92
- weak: ['build server', 'container', 'helm', 'terraform', 'monitoring', 'ビルドサーバー', 'コンテナ', '監視'],
93
- negative: ['slide', 'pptx', 'spec only'],
94
- }),
95
- route('hapo:generate-graph', 'diagram, graph, architecture map, or flow visualization', 52, {
96
- strong: ['diagram', 'graph', 'mermaid', 'flowchart', 'architecture diagram', 'sơ đồ', 'so do', '図', '図解', 'ダイアグラム', 'グラフ', 'フローチャート', '構成図'],
97
- medium: ['biểu đồ', 'bieu do', 'visualize', 'sequence diagram', 'data flow', '可視化', 'シーケンス図', 'データフロー'],
98
- weak: ['mind map', 'dependency map', 'system map', 'マインドマップ', '依存関係図', 'システム図'],
99
- negative: ['pptx', 'slide deck'],
100
- }),
101
- route('hapo:docs', 'project documentation, codebase docs, or source-backed as-is reconstruction', 51, {
102
- strong: ['hapo:docs', 'project docs', 'system docs', 'codebase docs', 'codebase documentation', 'documentation from source code', 'docs from source code', 'generate docs from codebase', 'dựng tài liệu từ source code', 'dung tai lieu tu source code', 'tài liệu hệ thống', 'tai lieu he thong', 'tài liệu hiện trạng', 'tai lieu hien trang', 'tạo tài liệu project', 'tao tai lieu project', 'legacy documentation', 'legacy system documentation', 'as-is documentation', 'as-is requirements', 'requirement reconstruction', 'reconstruct requirements', 'reconstruct requirements from legacy system', 'ソースコードから仕様書', 'ソースコードから仕様書を作成', 'ソースコードからドキュメント', '既存システムのドキュメント', '現行仕様書', 'as-isドキュメント'],
103
- medium: ['create docs', 'update docs', 'refresh docs', 'summarize codebase', 'system documentation', 'source to docs', 'reverse documentation', 'current-state docs', 'existing system docs', 'legacy docs', 'legacy system', 'dựng docs', 'dung docs', 'tạo docs', 'tao docs', 'cập nhật docs', 'cap nhat docs', 'tóm tắt codebase', 'tom tat codebase', 'dựng lại tài liệu', 'dung lai tai lieu', '仕様書を作成', 'ドキュメント作成', 'ドキュメント更新', 'コードベース要約', '既存システム', 'レガシーシステム'],
104
- weak: ['docs', 'documentation', 'document project', 'document codebase', 'as-is', 'reconstruct', 'hiện trạng', 'hien trang', 'tài liệu', 'tai lieu', 'ドキュメント', '資料化', '仕様化', '現状'],
105
- negative: ['official docs', 'latest docs', 'library docs', 'framework docs', 'api docs lookup', 'context7', 'best practice', 'research', 'pptx', 'slide'],
106
- }),
107
- route('hapo:brainstorm', 'early ideation or unclear solution direction', 50, {
108
- strong: ['brainstorm', 'ý tưởng', 'y tuong', 'phương án', 'phuong an', 'gợi ý', 'goi y', 'ブレスト', 'アイデア', '案', '提案して', '相談'],
109
- medium: ['idea', 'ideas', 'approach', 'options', 'tradeoff', 'chủ đề', 'chu de', 'cần làm gì', 'can lam gi', 'アプローチ', '選択肢', 'トレードオフ', 'テーマ', '何をすれば'],
110
- weak: ['proposal', 'strategy', 'plan options', 'explore', 'direction', 'seminar topic', '提案', '戦略', '方向性', '検討'],
111
- negative: ['commit', 'push', 'bug', 'error'],
112
- }),
113
- route('hapo:research', 'technical research or best-practice lookup', 48, {
114
- strong: ['research', 'best practice', 'tìm hiểu', 'tim hieu', 'nghiên cứu', 'nghien cuu', '調査', 'リサーチ', 'ベストプラクティス'],
115
- medium: ['documentation', 'docs', 'compare tools', 'latest docs', 'official docs', 'ドキュメント', '比較', '最新ドキュメント', '公式ドキュメント'],
116
- weak: ['investigate options', 'market scan', 'reference', 'source material', '選択肢を調べる', '参考資料', '資料'],
117
- negative: ['commit', 'push'],
118
- }),
119
- route('hapo:pptx', 'presentation or PowerPoint work', 46, {
120
- strong: ['pptx', 'powerpoint', 'slide deck', 'presentation deck', 'スライド資料', 'プレゼン資料'],
121
- medium: ['slide', 'slides', 'deck', 'presentation', 'seminar slides', 'スライド', 'プレゼン', 'セミナー資料'],
122
- weak: ['speaker notes', 'appendix', 'mục lục slide', 'muc luc slide', '発表ノート', '付録', '目次'],
123
- negative: ['source code', 'api', 'database'],
124
- }),
125
- route('hapo:agent-browser', 'browser automation with snapshot refs, web interaction, recording, or Browserbase cloud browser workflows', 45, {
126
- strong: ['agent-browser', 'browser automation', 'web automation', 'browserbase', 'cloud browser', 'snapshot refs', 'browser snapshot', 'automate browser', 'tự động trình duyệt', 'tu dong trinh duyet', 'tự động thao tác trình duyệt', 'tu dong thao tac trinh duyet', 'ブラウザ自動化', 'クラウドブラウザ', 'ブラウザ操作', 'ブラウザスナップショット'],
127
- medium: ['open url', 'navigate site', 'click in browser', 'fill form in browser', 'record browser', 'browser session', 'multi tab', 'browser test session', 'mở website', 'mo website', 'truy cập website', 'truy cap website', 'click trên web', 'click tren web', 'điền form web', 'dien form web', 'サイトを開く', 'ブラウザで開く', 'ブラウザで', 'フォーム入力', 'フォーム入力を自動化', '自動化して', 'クリック操作', '録画'],
128
- weak: ['click button', 'fill form', 'open site', 'web session', 'browser ref', 'viewport', 'cookies', 'localstorage', 'ボタンをクリック', 'ビューポート', 'クッキー'],
129
- negative: ['attached screenshot', 'ảnh đính kèm', 'anh dinh kem', '画像添付', 'source code', 'codebase', 'commit', 'push', 'pptx', 'pdf'],
130
- }),
131
- route('hapo:pdf', 'PDF reading, extraction, or generation', 44, {
132
- strong: ['pdf'], medium: ['export pdf', 'read pdf', 'extract pdf', 'pdf出力', 'pdfを読む', 'pdf抽出'], weak: ['page render', 'ページレンダー'], negative: [],
133
- }),
134
- route('hapo:docx', 'Word document work', 42, {
135
- strong: ['docx', 'word document', 'word file', 'word文書', 'wordファイル'], medium: ['word'], weak: ['tracked changes', 'document file', '変更履歴', '文書ファイル'], negative: [],
136
- }),
137
- route('hapo:xlsx', 'spreadsheet or Excel work', 42, {
138
- strong: ['xlsx', 'excel', 'spreadsheet', 'スプレッドシート'], medium: ['csv', 'sheet', 'workbook', 'シート', 'ワークブック'], weak: ['formula', 'pivot table', '数式', 'ピボットテーブル'], negative: [],
139
- }),
140
- route('hapo:ai-multimodal', 'image, video, audio, or multimodal artifact analysis', 40, {
141
- strong: ['screenshot', 'video', 'audio', 'multimodal', 'ảnh', 'anh', 'hình', 'hinh', 'スクリーンショット', '動画', '音声', '画像', '写真'],
142
- medium: ['image', 'screen capture', 'recording', 'file attached', 'イメージ', '画面キャプチャ', '録画', '添付ファイル'],
143
- weak: ['visual', 'describe image', 'ocr', 'ビジュアル', '画像説明'],
144
- negative: ['pptx', 'pdf export'],
145
- }),
146
- ];
147
-
148
- function route(skill, reason, priority, signals) {
149
- return { skill, reason, priority, signals };
150
- }
151
-
152
- function normalize(value) {
153
- return String(value || '')
154
- .normalize('NFKC')
155
- .normalize('NFD')
156
- .replace(/[\u0300-\u036f]/g, '')
157
- .normalize('NFC')
158
- .toLowerCase();
159
- }
160
-
161
- function scoreRoute(prompt, routeItem) {
162
- const normalized = normalize(prompt);
163
- const matched = [];
164
- let score = 0;
165
- for (const [bucket, weight] of Object.entries(WEIGHTS)) {
166
- for (const term of routeItem.signals[bucket] || []) {
167
- if (!normalized.includes(normalize(term))) continue;
168
- score += weight;
169
- matched.push({ bucket, term, weight });
170
- }
171
- }
172
- return { ...routeItem, score, matched, confidence: confidence(score) };
173
- }
174
-
175
- function confidence(score) {
176
- if (score >= 12) return 'high';
177
- if (score >= 7) return 'medium';
178
- if (score >= MIN_SCORE) return 'low';
179
- return 'none';
180
- }
181
-
182
- function findRoute(prompt) {
183
- const candidates = ROUTES
184
- .map((routeItem, index) => ({ ...scoreRoute(prompt, routeItem), index }))
185
- .filter((routeItem) => routeItem.score >= MIN_SCORE)
186
- .sort((a, b) => b.score - a.score || b.priority - a.priority || a.index - b.index);
187
- return candidates[0] || null;
188
- }
189
-
190
- module.exports = {
191
- MIN_SCORE,
192
- ROUTES,
193
- findRoute,
194
- normalize,
195
- scoreRoute,
196
- };
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Copyright (c) 2026 Haposoft. MIT License.
4
- *
5
- * UserPromptSubmit Hook - skill-router.cjs
6
- *
7
- * Adds a deterministic CafeKit skill suggestion for natural-language prompts.
8
- * It never overrides explicit slash commands; it only injects a short routing hint.
9
- *
10
- * Exit: 0 always (fail-open)
11
- */
12
-
13
- const fs = require('fs');
14
- const path = require('path');
15
-
16
- function logCrash(error) {
17
- try {
18
- const dir = path.join(__dirname, '.logs');
19
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
20
- fs.appendFileSync(
21
- path.join(dir, 'hook-log.jsonl'),
22
- JSON.stringify({
23
- ts: new Date().toISOString(),
24
- hook: 'skill-router',
25
- status: 'crash',
26
- error: error.message,
27
- }) + '\n'
28
- );
29
- } catch (_) {}
30
- }
31
-
32
- try {
33
- const { isHookEnabled } = require('./lib/config.cjs');
34
- const { findRoute } = require('./lib/skill-router-routes.cjs');
35
-
36
- function isExplicitCommand(prompt) {
37
- const trimmed = prompt.trim();
38
- return trimmed.startsWith('/') || /^hapo:[a-z-]+/i.test(trimmed);
39
- }
40
-
41
- const stdin = fs.readFileSync(0, 'utf8').trim();
42
- if (!stdin) process.exit(0);
43
-
44
- const payload = JSON.parse(stdin);
45
- const cwd = payload.cwd || process.cwd();
46
- const prompt = payload.prompt || '';
47
- if (!isHookEnabled('skill-router', { cwd })) process.exit(0);
48
- if (!prompt || isExplicitCommand(prompt)) process.exit(0);
49
-
50
- const route = findRoute(prompt);
51
- if (!route) process.exit(0);
52
-
53
- const skillDir = route.skill.replace(/^hapo:/, '');
54
- const lines = [
55
- '## CafeKit Skill Router',
56
- `- Suggested skill: \`${route.skill}\``,
57
- `- Why: ${route.reason}.`,
58
- `- Confidence: ${route.confidence} (score ${route.score}).`,
59
- `- Action: before acting, read \`.claude/skills/${skillDir}/SKILL.md\` and follow that workflow.`,
60
- '- If the user explicitly names another workflow or asks for direct answering only, follow the user request.',
61
- ];
62
-
63
- console.log(lines.join('\n'));
64
- process.exit(0);
65
- } catch (error) {
66
- try { logCrash(error); } catch (_) {}
67
- process.exit(0);
68
- }