@seanyao/roll 0.5.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 (50) hide show
  1. package/README.md +201 -0
  2. package/bin/roll +1375 -0
  3. package/conventions/config.yaml +15 -0
  4. package/conventions/global/.cursor-rules +31 -0
  5. package/conventions/global/AGENTS.md +100 -0
  6. package/conventions/global/CLAUDE.md +32 -0
  7. package/conventions/global/GEMINI.md +28 -0
  8. package/conventions/templates/backend-service/.cursor-rules +17 -0
  9. package/conventions/templates/backend-service/AGENTS.md +88 -0
  10. package/conventions/templates/backend-service/CLAUDE.md +18 -0
  11. package/conventions/templates/backend-service/GEMINI.md +16 -0
  12. package/conventions/templates/cli/.cursor-rules +17 -0
  13. package/conventions/templates/cli/AGENTS.md +66 -0
  14. package/conventions/templates/cli/CLAUDE.md +18 -0
  15. package/conventions/templates/cli/GEMINI.md +16 -0
  16. package/conventions/templates/frontend-only/.cursor-rules +16 -0
  17. package/conventions/templates/frontend-only/AGENTS.md +71 -0
  18. package/conventions/templates/frontend-only/CLAUDE.md +16 -0
  19. package/conventions/templates/frontend-only/GEMINI.md +14 -0
  20. package/conventions/templates/fullstack/.cursor-rules +17 -0
  21. package/conventions/templates/fullstack/AGENTS.md +87 -0
  22. package/conventions/templates/fullstack/CLAUDE.md +17 -0
  23. package/conventions/templates/fullstack/GEMINI.md +15 -0
  24. package/package.json +33 -0
  25. package/skills/roll-.changelog/SKILL.md +79 -0
  26. package/skills/roll-.clarify/SKILL.md +59 -0
  27. package/skills/roll-.echo/SKILL.md +113 -0
  28. package/skills/roll-.qa/SKILL.md +204 -0
  29. package/skills/roll-.review/SKILL.md +105 -0
  30. package/skills/roll-build/SKILL.md +559 -0
  31. package/skills/roll-debug/SKILL.md +428 -0
  32. package/skills/roll-design/ENGINEERING_CHECKLIST.md +256 -0
  33. package/skills/roll-design/SKILL.md +276 -0
  34. package/skills/roll-fix/SKILL.md +442 -0
  35. package/skills/roll-jot/SKILL.md +50 -0
  36. package/skills/roll-research/SKILL.md +307 -0
  37. package/skills/roll-research/references/schema.json +162 -0
  38. package/skills/roll-research/scripts/md_to_pdf.py +289 -0
  39. package/skills/roll-sentinel/SKILL.md +355 -0
  40. package/skills/roll-spar/SKILL.md +287 -0
  41. package/template/.env.example +47 -0
  42. package/template/.github/workflows/ci.yml +32 -0
  43. package/template/.github/workflows/sentinel.yml +26 -0
  44. package/template/AGENTS.md +80 -0
  45. package/template/BACKLOG.md +42 -0
  46. package/template/package.json +43 -0
  47. package/tools/roll-fetch/SKILL.md +182 -0
  48. package/tools/roll-fetch/package.json +15 -0
  49. package/tools/roll-fetch/smart-web-fetch.js +558 -0
  50. package/tools/roll-probe/SKILL.md +84 -0
@@ -0,0 +1,287 @@
1
+ ---
2
+ name: roll-spar
3
+ description: Adversarial TDD mode with Attacker/Defender agents. Attacker writes tests to break the system, Defender writes minimal code to pass. Use for high-risk logic like auth, payments, data integrity, or complex state machines.
4
+ ---
5
+
6
+ # Spar
7
+
8
+ Adversarial TDD: two agents collaborate in attack-and-defend mode to build a more robust system.
9
+
10
+ ## When to Use
11
+
12
+ **Manual trigger:**
13
+ - User explicitly requests `$roll-spar`
14
+ - Involves core business logic requiring higher quality assurance
15
+
16
+ **Auto trigger (agent judgment):** Recommend enabling when any of these conditions are met
17
+ - Involves authentication / authorization / security
18
+ - Involves money / payments / billing
19
+ - Involves data integrity (writes are irreversible)
20
+ - Complex state machines / concurrency logic
21
+ - Module has had previous bugs (BACKLOG has related FIX records)
22
+
23
+ **Do not use for:**
24
+ - UI styling adjustments, copy changes
25
+ - Simple CRUD
26
+ - Configuration changes
27
+ - Small tasks not worth the overhead of two-agent collaboration
28
+
29
+ ## Roles
30
+
31
+ ### Attacker (Red Agent)
32
+
33
+ **Goal: Find weaknesses in the code and write tests that break the system.**
34
+
35
+ - Think about boundary conditions, invalid inputs, concurrency scenarios, state inconsistencies
36
+ - Write the trickiest test cases possible
37
+ - Don't care about implementation difficulty — only care about "can the system handle this scenario"
38
+ - Write at least 1 RED test per round, can write multiple
39
+
40
+ ### Defender (Green Agent)
41
+
42
+ **Goal: Make all tests pass with the simplest, most robust code possible.**
43
+
44
+ - Cannot modify tests written by the Attacker (unless the test itself has a bug)
45
+ - Aim for minimal implementation, avoid over-engineering
46
+ - Make all tests GREEN each round, then commit
47
+ - May refactor, but must stay GREEN
48
+
49
+ ## Workflow
50
+
51
+ ```
52
+ User: "$roll-spar implement transfer logic" or agent auto-triggers
53
+
54
+
55
+ ┌─────────────────────────────────────┐
56
+ │ 0. Setup │
57
+ │ - Define feature scope and AC │
58
+ │ - Create test file skeleton │
59
+ │ - Context brief for Attacker │
60
+ │ and Defender │
61
+ └─────────────┬───────────────────────┘
62
+
63
+
64
+ ┌─────────────────────────────────────┐
65
+ │ Spar Loop (repeat until converged) │
66
+ │ │
67
+ │ ┌───────────────────────────────┐ │
68
+ │ │ 🔴 Attacker Turn │ │
69
+ │ │ - Analyze current code/API │ │
70
+ │ │ - Write 1+ RED tests │ │
71
+ │ │ - State attack intent: │ │
72
+ │ │ "Test balance consistency│ │
73
+ │ │ during concurrent │ │
74
+ │ │ transfers" │ │
75
+ │ └──────────────┬────────────────┘ │
76
+ │ │ │
77
+ │ ▼ │
78
+ │ ┌───────────────────────────────┐ │
79
+ │ │ 🟢 Defender Turn │ │
80
+ │ │ - Read Attacker's tests │ │
81
+ │ │ - Write minimal code to │ │
82
+ │ │ make tests pass │ │
83
+ │ │ - Run all tests → GREEN │ │
84
+ │ │ - git commit │ │
85
+ │ └──────────────┬────────────────┘ │
86
+ │ │ │
87
+ │ ▼ │
88
+ │ ┌───────────────────────────────┐ │
89
+ │ │ 🔴 Attacker Turn (again) │ │
90
+ │ │ - Review Defender's impl │ │
91
+ │ │ - Find new weaknesses, │ │
92
+ │ │ write new RED tests │ │
93
+ │ │ - Or: "No new weaknesses │ │
94
+ │ │ found" │ │
95
+ │ └──────────────┬────────────────┘ │
96
+ │ │ │
97
+ │ ┌────────┴────────┐ │
98
+ │ │ │ │
99
+ │ Has new tests No new tests │
100
+ │ → Continue loop → Exit Spar │
101
+ │ │
102
+ └─────────────────────────────────────┘
103
+
104
+
105
+ ┌─────────────────────────────────────┐
106
+ │ Wrap-up │
107
+ │ - Attacker summarizes attack │
108
+ │ coverage │
109
+ │ - Defender summarizes defense │
110
+ │ strategy │
111
+ │ - Merged report │
112
+ │ - Continue normal story-build │
113
+ │ flow │
114
+ │ (push → CI → deploy → verify) │
115
+ └─────────────────────────────────────┘
116
+ ```
117
+
118
+ ## Spar Convergence Conditions
119
+
120
+ Attacker declares completion when any of these are met:
121
+ - Cannot write a new RED test for 2 consecutive rounds
122
+ - Already covered: happy path + boundary values + invalid inputs + concurrency/race conditions + state consistency
123
+ - Reached the agreed maximum number of rounds (default: 5 rounds)
124
+
125
+ ## Agent Context Brief
126
+
127
+ ### Attacker Brief Template
128
+
129
+ ```markdown
130
+ ## Role: Attacker (Red Agent)
131
+
132
+ Your goal is to find weaknesses in this code.
133
+
134
+ ### Feature Description
135
+ {Feature AC and interface definition}
136
+
137
+ ### Current Implementation
138
+ {Defender's latest code, or "not yet implemented"}
139
+
140
+ ### Existing Tests
141
+ {Currently existing test cases}
142
+
143
+ ### Your Task
144
+ Write 1+ new test cases that make the current implementation fail (RED).
145
+ Directions to explore:
146
+ - Boundary values (0, -1, MAX_INT, empty string, null)
147
+ - Exception flows (network disconnect, timeout, duplicate requests)
148
+ - Concurrency (two requests arriving simultaneously)
149
+ - State consistency (is system state clean after mid-process failure)
150
+
151
+ ### Output Format
152
+ For each test, state the attack intent:
153
+ "Attack: {scenario description} — expected system behavior: {expected behavior}"
154
+ ```
155
+
156
+ ### Defender Brief Template
157
+
158
+ ```markdown
159
+ ## Role: Defender (Green Agent)
160
+
161
+ Your goal is to make all tests pass with the simplest implementation.
162
+
163
+ ### Feature Description
164
+ {Feature AC and interface definition}
165
+
166
+ ### Current Code
167
+ {Your previously written code, or empty}
168
+
169
+ ### New RED Tests
170
+ {Tests written by the Attacker this round}
171
+
172
+ ### Your Task
173
+ Modify/add code to make all tests (including previous ones) pass.
174
+ Rules:
175
+ - Cannot modify tests written by the Attacker
176
+ - Aim for minimal changes
177
+ - Keep the code clear
178
+ - Commit after all tests are GREEN
179
+ ```
180
+
181
+ ## Status Report
182
+
183
+ Report to the user after each round:
184
+
185
+ ```
186
+ ⚔️ Spar Round {N}
187
+
188
+ 🔴 Attacker:
189
+ Attack: {scenario 1} — {result}
190
+ Attack: {scenario 2} — {result}
191
+
192
+ 🟢 Defender:
193
+ Defense strategy: {brief description of how it was defended}
194
+ Test status: {passed}/{total} ✅
195
+
196
+ 📊 Cumulative: {total tests} tests, {total rounds} rounds
197
+ 🔄 Next round: Attacker continues looking for weaknesses...
198
+ ```
199
+
200
+ ## Hard Rules
201
+
202
+ 1. **Attacker does not write implementation code** — only writes tests and attack analysis
203
+ 2. **Defender does not modify tests** — unless the test itself has a bug (must explain the reason)
204
+ 3. **Must commit each round** — Defender commits immediately after making tests GREEN, keeping the repo clean
205
+ 4. **Attack intent must be explained** — cannot just write tests without explaining "why this scenario matters"
206
+ 5. **Maximum round limit** — default 5 rounds, prevents infinite loops
207
+
208
+ ## Integration with story-build
209
+
210
+ Spar replaces steps 4-5 in story-build (Test Design + TCR Implementation):
211
+
212
+ ```
213
+ story-build normal flow:
214
+ 1. Clarify Story
215
+ 2. Split Actions
216
+ 3. Define verification
217
+ ──────────────────────
218
+ 4. Test Design Review ← Spar replaces this step
219
+ 5. TCR Implementation ← and this step
220
+ ──────────────────────
221
+ 6. Local CI check ← Back to normal flow
222
+ 7. Quality Review
223
+ ...
224
+ ```
225
+
226
+ **Auto-switching from story-build to Spar:**
227
+
228
+ When the agent assesses an Action as high-risk at step 3:
229
+ ```
230
+ ⚔️ High-risk Action detected: {description}
231
+ Risk factors: {auth/payment/data integrity/...}
232
+ Recommend enabling Spar mode — confirm? [Y/n]
233
+ ```
234
+
235
+ After user confirms, enter Spar. Once complete, return to story-build step 6 to continue.
236
+
237
+ ## Example
238
+
239
+ ```
240
+ User: "$roll-spar implement user balance transfer"
241
+
242
+ ⚔️ Spar: User Balance Transfer
243
+
244
+ ── Round 1 ──
245
+
246
+ 🔴 Attacker:
247
+ Attack 1: Transfer amount is 0 — should reject
248
+ Attack 2: Transfer amount is negative — should reject
249
+ Attack 3: Transfer amount exceeds balance — should reject and keep balance unchanged
250
+
251
+ 🟢 Defender:
252
+ Implementation: transfer(from, to, amount) basic validation
253
+ Tests: 3/3 ✅
254
+ commit: "tcr: transfer basic validation"
255
+
256
+ ── Round 2 ──
257
+
258
+ 🔴 Attacker:
259
+ Attack 4: Transfer to self — should reject
260
+ Attack 5: Two concurrent transfers whose total exceeds balance — only one should succeed
261
+
262
+ 🟢 Defender:
263
+ Implementation: add self-transfer check + optimistic lock
264
+ Tests: 5/5 ✅
265
+ commit: "tcr: transfer self-check and concurrency lock"
266
+
267
+ ── Round 3 ──
268
+
269
+ 🔴 Attacker:
270
+ Attack 6: Database error mid-transfer — both balances should remain unchanged (atomicity)
271
+ Attack 7: Recipient account does not exist — should reject and keep sender's balance
272
+
273
+ 🟢 Defender:
274
+ Implementation: database transaction wrapper + recipient existence check
275
+ Tests: 7/7 ✅
276
+ commit: "tcr: transfer atomicity and recipient validation"
277
+
278
+ ── Round 4 ──
279
+
280
+ 🔴 Attacker:
281
+ No new weaknesses found. Covered: input validation, self-transfer, concurrency, atomicity, related accounts.
282
+
283
+ ⚔️ Spar Complete!
284
+ 📊 4 rounds, 7 tests, 3 commits
285
+ 🔴 Attack coverage: input boundaries + business rules + concurrency + atomicity
286
+ 🟢 Defense strategy: upfront validation + optimistic lock + transactions
287
+ ```
@@ -0,0 +1,47 @@
1
+ # ============================================
2
+ # AI Services
3
+ # ============================================
4
+ # Moonshot AI (Kimi) - content generation
5
+ KIMI_API_KEY=sk-your-kimi-api-key
6
+ KIMI_BASE_URL=https://api.moonshot.cn/v1
7
+
8
+ # OpenAI (fallback)
9
+ OPENAI_API_KEY=sk-your-openai-key
10
+
11
+ # Alibaba DashScope - image/voice generation
12
+ DASHSCOPE_API_KEY=sk-your-dashscope-key
13
+
14
+ # ============================================
15
+ # Cloud Storage (OSS)
16
+ # ============================================
17
+ # Aliyun OSS
18
+ OSS_ACCESS_KEY_ID=your-access-key
19
+ OSS_ACCESS_KEY_SECRET=your-secret
20
+ OSS_BUCKET=your-bucket
21
+ OSS_REGION=oss-cn-hangzhou
22
+ OSS_ENDPOINT=https://your-bucket.oss-cn-hangzhou.aliyuncs.com
23
+
24
+ # ============================================
25
+ # Deployment
26
+ # ============================================
27
+ # Vercel (auto-injected, not needed for local dev)
28
+ # VERCEL_URL=https://your-app.vercel.app
29
+
30
+ # ============================================
31
+ # Database (if needed)
32
+ # ============================================
33
+ # Supabase / PostgreSQL
34
+ DATABASE_URL=postgresql://user:pass@host:5432/db
35
+
36
+ # Redis (cache)
37
+ REDIS_URL=redis://localhost:6379
38
+
39
+ # ============================================
40
+ # Auth (if needed)
41
+ # ============================================
42
+ # Google OAuth
43
+ GOOGLE_CLIENT_ID=your-client-id
44
+ GOOGLE_CLIENT_SECRET=your-secret
45
+
46
+ # JWT Secret
47
+ JWT_SECRET=your-jwt-secret-key
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Setup Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '20'
20
+ cache: 'npm'
21
+
22
+ - name: Install dependencies
23
+ run: npm ci
24
+
25
+ - name: Lint
26
+ run: npm run lint
27
+
28
+ - name: Build
29
+ run: npm run build
30
+
31
+ - name: Test
32
+ run: npm run test -- --run
@@ -0,0 +1,26 @@
1
+ name: Sentinel Patrol
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '0 */6 * * *' # patrol every 6 hours
6
+ workflow_dispatch: # support manual trigger
7
+
8
+ jobs:
9
+ patrol:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Setup Node.js
16
+ uses: actions/setup-node@v4
17
+ with:
18
+ node-version: '20'
19
+
20
+ - name: Run Sentinel Patrol
21
+ run: |
22
+ echo "🔍 Running sentinel patrol..."
23
+ # Integrate actual sentinel check scripts here
24
+ npm run test:e2e:smoke || true
25
+ env:
26
+ APP_URL: ${{ secrets.APP_URL }}
@@ -0,0 +1,80 @@
1
+ # Project Agents Configuration
2
+
3
+ ## Workspace Configuration
4
+
5
+ ### Plan Documents Location
6
+ **All Plan documents must be stored under the project directory. Writing to the `.kimi/` directory is prohibited.**
7
+
8
+ ```yaml
9
+ # Plan file storage configuration
10
+ plans:
11
+ base_dir: docs/plans/ # Relative to the project root
12
+ auto_create: true # Auto-create directory if it doesn't exist
13
+ naming_convention: "{topic}.md" # Naming convention
14
+ ```
15
+
16
+ **Rules:**
17
+ 1. **Preferred location**: `{project_root}/docs/plans/`
18
+ 2. **Auto-create**: If `docs/plans/` doesn't exist, create the directory automatically
19
+ 3. **Prohibited location**: Absolutely no writing to `~/.kimi/` or any global config directory
20
+ 4. **Non-project Plans**: Only allowed to use a temporary location when there is no project context
21
+
22
+ **Examples:**
23
+ - ✅ `my-project/docs/plans/auth-system.md`
24
+ - ✅ `my-project/docs/plans/api-redesign.md`
25
+ - ❌ `~/.kimi/skills/some-plan.md`
26
+ - ❌ Any global location outside the project
27
+
28
+ ## Workflow
29
+
30
+ ### Design → $roll-design
31
+ - Solution exploration, architecture design
32
+ - Split into Stories
33
+ - Write to BACKLOG.md
34
+
35
+ ### Build → $roll-build / $roll-fix
36
+ - Read BACKLOG and execute
37
+ - TCR development (independent Actions auto-parallelized + Worktree isolation)
38
+ - CI/CD deployment
39
+
40
+ ### Check → $roll-sentinel / $roll-debug
41
+ - Sentinel: Scheduled patrol
42
+ - $roll-debug: Deep diagnosis
43
+
44
+ ### Fix → $roll-fix / $roll-design
45
+ - Fix issues
46
+ - Or re-plan
47
+
48
+ ## Architecture Constraints
49
+
50
+ ### Agent First
51
+ - System designed for AI Agents
52
+ - Agent is the primary user
53
+ - UI is only a supplementary interface
54
+
55
+ ### Data Schema
56
+ - Clear data structure definitions
57
+ - Type/Schema is the contract between humans and Agents
58
+ - Define Schema first, then write business logic
59
+
60
+ ### Domain Driven
61
+ - Model by business domain
62
+ - Not database table design
63
+ - Help Agents understand the business
64
+
65
+ ### Decoupling Rules
66
+ - UI layer only handles rendering; logic lives in Hooks
67
+ - API calls encapsulated in services/
68
+ - Shared types placed in shared/types/
69
+
70
+ ### Testing Requirements
71
+ - All business logic must have unit tests
72
+ - APIs have integration tests
73
+ - Critical flows have E2E tests
74
+ - Sentinel runs periodic regression tests
75
+
76
+ ## Conventions
77
+
78
+ - All work tracked in BACKLOG.md
79
+ - Sentinel patrols every 6 hours
80
+ - TCR required for all changes
@@ -0,0 +1,42 @@
1
+ # Project Backlog
2
+
3
+ > Task index - all work is tracked here
4
+
5
+ ## 🎯 Active
6
+
7
+ Stories in the current iteration
8
+
9
+ | ID | Title | Status | Priority | Est |
10
+ |----|-------|--------|----------|-----|
11
+ | INIT-001 | Project initialization | ✅ | P0 | 1d |
12
+
13
+ ## 📋 Todo
14
+
15
+ Ready for development, already planned
16
+
17
+ <!-- $roll-design will create new Stories here -->
18
+
19
+ ## 🔄 In Progress
20
+
21
+ <!-- $roll-build will update here -->
22
+
23
+ ## ✅ Completed
24
+
25
+ - **INIT-001** Project initialization - {date}
26
+
27
+ ## 🐛 Bug Fixes
28
+
29
+ | ID | Problem | Status | Source |
30
+ |----|---------|--------|--------|
31
+
32
+ ## 🔍 Sentinel Findings
33
+
34
+ | ID | Issue | Severity | Status |
35
+ |----|-------|----------|--------|
36
+
37
+ ## 📈 Stats
38
+
39
+ - Total Stories: 1
40
+ - Completed: 1
41
+ - Active: 0
42
+ - Sentinel Coverage: 0%
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "my-project",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "tsc && vite build",
8
+ "preview": "vite preview",
9
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
11
+ "test": "vitest",
12
+ "test:e2e": "playwright test",
13
+ "test:e2e:smoke": "playwright test smoke.spec.ts",
14
+ "ci:local": "npm run lint && npm run build && npm run test -- --run"
15
+ },
16
+ "dependencies": {
17
+ "react": "^18.2.0",
18
+ "react-dom": "^18.2.0",
19
+ "react-router-dom": "^6.20.0",
20
+ "class-variance-authority": "^0.7.0",
21
+ "clsx": "^2.0.0",
22
+ "tailwind-merge": "^2.0.0",
23
+ "lucide-react": "^0.294.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/react": "^18.2.37",
27
+ "@types/react-dom": "^18.2.15",
28
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
29
+ "@typescript-eslint/parser": "^6.10.0",
30
+ "@vitejs/plugin-react": "^4.2.0",
31
+ "@playwright/test": "^1.40.0",
32
+ "autoprefixer": "^10.4.16",
33
+ "eslint": "^8.53.0",
34
+ "eslint-plugin-react-hooks": "^4.6.0",
35
+ "eslint-plugin-react-refresh": "^0.4.4",
36
+ "postcss": "^8.4.31",
37
+ "prettier": "^3.1.0",
38
+ "tailwindcss": "^3.3.5",
39
+ "typescript": "^5.2.2",
40
+ "vite": "^5.0.0",
41
+ "vitest": "^0.34.6"
42
+ }
43
+ }