Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:37:27 +08:00
commit 37774aa937
131 changed files with 31137 additions and 0 deletions

View File

@@ -0,0 +1,260 @@
---
name: ln-222-story-creator
description: Creates Stories from IDEAL plan (CREATE) or appends user-requested Stories (ADD). Generates 8-section documents, validates INVEST, creates in Linear. Invoked by ln-220.
---
# Story Creator
Universal factory worker for creating Stories. Supports two modes:
- **CREATE MODE**: Epic has no Stories → create from IDEAL plan (5-10 Stories)
- **ADD MODE**: Epic has Stories → append new Story(s) from user request
Invoked by ln-220-story-coordinator (Phase 5a for CREATE, Phase 5c for ADD).
## When Invoked
**1. ln-220-story-coordinator CREATE MODE (Phase 5a):**
- Epic has NO existing Stories (Linear query count = 0)
- IDEAL plan generated (Phase 3)
- Standards Research completed by ln-221 (Phase 2)
- Parameters: `epicData`, `idealPlan`, `standardsResearch`, `teamId`, `autoApprove`
**2. ln-220-story-coordinator ADD MODE (Phase 5c):**
- Epic HAS existing Stories, user wants to ADD more (not replan)
- Single Story or few Stories from user request
- Parameters: `epicData`, `appendMode: true`, `newStoryDescription`, `standardsResearch`, `teamId`
## Input Parameters
**For CREATE MODE (from ln-220-story-coordinator Phase 5a):**
```javascript
{
epicData: {id, title, description},
idealPlan: [
{
number: "US004",
title: "Register OAuth client",
statement: {persona, capability, value},
ac: [GWT scenarios],
technicalNotes: {architecture, integrations, performance},
estimatedHours: 12,
testCounts: {e2e: 2, integration: 5, unit: 11}
}
],
standardsResearch: "OAuth 2.0 (RFC 6749)...",
teamId: "team-id",
autoApprove: true
}
```
**For ADD MODE (from ln-220-story-coordinator Phase 5c with appendMode):**
```javascript
{
epicData: {id, title, description},
appendMode: true, // Signals ADD MODE - append to existing
newStoryDescription: "User's request for new Story",
standardsResearch: "Focused research for new Story only",
teamId: "team-id",
autoApprove: false // User confirmation recommended
}
```
- **appendMode**: `true` signals ADD MODE - append to existing Stories
- **newStoryDescription**: User's request for new Story(s) to add
- **NO idealPlan** - creates only what user requested (single Story or few)
## Workflow
> [!NOTE]
> **ADD MODE (appendMode: true)**: When adding Stories to existing Epic, workflow is simplified:
> - Phase 1: Generate only requested Story(s) from `newStoryDescription`
> - Skip full IDEAL plan comparison
> - Standards Research is focused only on new Story topics
> - Other phases proceed normally (INVEST, Preview, Create)
### Phase 1: Generate Story Documents
Read `references/story_template_universal.md` (8 sections).
For EACH Story in IDEAL plan:
| Section | Content |
|---------|---------|
| **1. Story Statement** | As a [persona] / I want [capability] / So that [value] |
| **2. Context** | Current Situation (from Epic Scope Out) / Desired Outcome (from Epic Success Criteria) |
| **3. AC** | Copy AC from idealPlan (3-5 GWT scenarios) |
| **4. Tasks** | Placeholder: "Tasks created via ln-310-story-decomposer after ln-320-story-validator" |
| **5. Test Strategy** | Copy test counts from idealPlan, Risk-Based Testing note |
| **6. Technical Notes** | **INSERT Standards Research** in Library Research subsection |
| **7. DoD** | Standard checklist from template |
| **8. Dependencies** | Empty OR "Depends On: US00X" if ordering implies dependency |
**Output:** Array of N complete Story documents (5-10) with Standards Research inserted.
### Phase 2: Validate INVEST
For EACH Story, check:
| Criterion | Check | Pass | Fail |
|-----------|-------|------|------|
| **Independent** | No circular dependencies | ✅ | ❌ STOP |
| **Negotiable** | AC focus on WHAT not HOW | ✅ | ❌ STOP |
| **Valuable** | Clear "So that" value | ✅ | ❌ STOP |
| **Estimable** | 6-20 hours | ✅ | ❌ STOP |
| **Small** | 3-5 AC, 10-28 tests | ✅ | ❌ STOP |
| **Testable** | Measurable AC (GWT format) | ✅ | ❌ STOP |
**Error if ANY Story fails** → Report to orchestrator, stop execution.
### Phase 3: Show Preview
```
STORY CREATION PREVIEW for Epic 7: OAuth Authentication
Will create 5 Stories:
1. US004: Register OAuth client
Persona: Third-party developer | Capability: Register app, get credentials
Value: Can integrate with API | AC: 4 | Estimate: 12h | Tests: 18
2. US005: Request access token
Persona: API client | Capability: Exchange credentials for token
Value: Authenticate to API | AC: 5 | Estimate: 18h | Tests: 24
... (3 more)
Total: 5 Stories, 62h, 90 tests
Standards Research: OAuth 2.0 (RFC 6749), RFC 7636 (PKCE), RFC 7009 (Revocation)
Story ordering: Dependency-aware (US004 → US005 → US006)
INVEST validation: ✓
Type "confirm" to create.
```
### Phase 4: User Confirmation
**If autoApprove=true:** Skip confirmation → Phase 5
**Otherwise:** Wait for "confirm"
### Phase 5: Create in Linear + Update Kanban
**Create Linear Issues:**
```javascript
for each Story:
create_issue({
title: Story.number + ": " + Story.title,
description: Story.generated_document,
project: epicData.id,
team: teamId,
labels: ["user-story"],
state: "Backlog"
})
```
**Update kanban_board.md:**
**Epic Grouping Algorithm:**
1. Find `### Backlog`
2. Search `**Epic {epicNumber}: {epicTitle}**`
- Found: use existing Epic group
- NOT found: create `**Epic N: Epic Title**`
3. Add Stories under Epic (2-space indent, 📖 emoji)
**Format:**
```markdown
**Epic 7: OAuth Authentication**
📖 [ID: US004 Register OAuth client](url)
_(tasks not created yet)_
📖 [ID: US005 Request access token](url)
_(tasks not created yet)_
```
**Update Epic Story Counters table:**
- Last Story: US008
- Next Story: US009
**Return:**
```
STORIES CREATED for Epic 7: OAuth Authentication
✓ Created 5 Stories in Linear:
1. [ID: US004 Register OAuth client](url)
2. [ID: US005 Request access token](url)
3. [ID: US006 Validate access token](url)
4. [ID: US007 Refresh expired token](url)
5. [ID: US008 Revoke token](url)
✓ kanban_board.md updated (Backlog + Epic Story Counters)
✓ Standards Research included: OAuth 2.0, RFC 7636 PKCE, RFC 7009 Revocation
Total: 5 Stories, 62h, 90 tests
NEXT STEPS:
1. Run ln-320-story-validator to validate Stories (Backlog → Todo)
2. Use ln-310-story-decomposer to create tasks
```
## Critical Rules
| Rule | Description |
|------|-------------|
| **Standards Research Insertion** | MUST insert in EVERY Story Technical Notes → Library Research |
| **INVEST Validation** | All Stories must pass before creation (stop if ANY fails) |
| **Template Ownership** | This skill owns story_template_universal.md in references/ |
| **Epic Grouping** | Reuse Epic header if exists (search by Epic number), don't duplicate |
| **Story Numbering** | Sequential across ALL Epics (read Next Story from kanban_board.md) |
| **No Code** | Descriptions contain approach ONLY, not code |
## Definition of Done
**✅ Phase 1:**
- [ ] All N Stories have 8 sections
- [ ] Standards Research inserted in Technical Notes → Library Research
**✅ Phase 2:**
- [ ] All Stories pass INVEST validation
**✅ Phase 3:**
- [ ] Preview shown (summaries, totals, Standards Research, ordering)
**✅ Phase 4:**
- [ ] autoApprove=true OR user confirmed
**✅ Phase 5:**
- [ ] All N Stories created in Linear (project=Epic, labels=user-story, state=Backlog)
- [ ] kanban_board.md updated (Backlog + Epic Story Counters)
- [ ] Summary returned (URLs + next steps)
## Reference Files
### story_template_universal.md
**Location:** `references/` (owned by this skill)
**Purpose:** Universal Story template (8 sections)
**Version:** 7.0.0
**Usage:** ln-223-story-replanner reads from ln-222/references/ for UPDATE/CREATE operations
## Integration
**Called by:** ln-220-story-coordinator
- Phase 5a (CREATE MODE, count = 0) - full IDEAL plan
- Phase 5c (ADD MODE, count ≥ 1, appendMode) - user-requested Story(s)
**Returns:**
- Success: Story URLs + summary + next steps
- Error: "Story USXXX violates INVEST: [details]"
**Worker does NOT:**
- Query Linear for Epic (already in context)
- Analyze Epic complexity (orchestrator Phase 3)
- Research standards (orchestrator Phase 2 delegates to ln-221)
- Build IDEAL plan (receives from orchestrator)
---
**Version:** 1.0.0
**Last Updated:** 2025-11-20

View File

@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ln-222-story-creator Workflow</title>
<link rel="stylesheet" href="../shared/css/diagram.css">
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<script>
mermaid.initialize({
startOnLoad: true,
theme: 'base',
themeVariables: {
primaryColor: '#4A90E2',
primaryTextColor: '#fff',
primaryBorderColor: '#2E5C8A',
lineColor: '#5C6BC0',
secondaryColor: '#7E57C2',
tertiaryColor: '#26A69A'
}
});
</script>
</head>
<body>
<div class="container">
<h1>ln-222-story-creator: Story Creator</h1>
<div class="diagram-section">
<h2>Workflow Diagram</h2>
<div class="mermaid">
graph TD
Start([Input: epicData, idealPlan, standardsResearch]) --> Phase1[Phase 1: Generate Story Documents]
Phase1 --> ReadTemplate[Read story_template_universal.md]
ReadTemplate --> GenerateDocs[For EACH Story in idealPlan:<br/>Generate 8 sections<br/>INSERT Standards Research]
GenerateDocs --> Phase2[Phase 2: Validate INVEST]
Phase2 --> ValidateAll[For EACH Story:<br/>Check I-N-V-E-S-T criteria]
ValidateAll --> CheckInvest{All pass?}
CheckInvest -->|No| Error[❌ STOP<br/>Report to orchestrator]
CheckInvest -->|Yes| Phase3[Phase 3: Show Preview]
Phase3 --> ShowPreview[Display:<br/>Story summaries<br/>Totals<br/>Standards Research<br/>INVEST: ✓]
ShowPreview --> Phase4[Phase 4: User Confirmation]
Phase4 --> CheckApprove{autoApprove?}
CheckApprove -->|true| Phase5
CheckApprove -->|false| WaitConfirm[Wait for 'confirm']
WaitConfirm --> Phase5[Phase 5: Create in Linear + Update Kanban]
Phase5 --> CreateLinear[For EACH Story:<br/>create_issue<br/>project=Epic, labels=user-story]
CreateLinear --> UpdateKanban[Update kanban_board.md:<br/>Epic Grouping Algorithm<br/>Update Epic Story Counters]
UpdateKanban --> Summary[Display Summary:<br/>URLs, Standards Research, Next Steps]
Summary --> End([Done])
style Start fill:#4A90E2,stroke:#2E5C8A,color:#fff
style End fill:#26A69A,stroke:#1B5E20,color:#fff
style Phase1 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase2 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase3 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase4 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase5 fill:#26A69A,stroke:#1B5E20,color:#fff
style Error fill:#F44336,stroke:#B71C1C,color:#fff
style CheckInvest fill:#FF9800,stroke:#E65100,color:#fff
style CheckApprove fill:#FF9800,stroke:#E65100,color:#fff
</div>
</div>
<div class="info-section">
<h2>Key Information</h2>
<ul>
<li><strong>Type:</strong> Worker (L3)</li>
<li><strong>Phases:</strong> 5 (Generate → Validate → Preview → Confirm → Create)</li>
<li><strong>Invoked by:</strong> ln-220-story-coordinator (Phase 5a, CREATE MODE)</li>
<li><strong>Input:</strong> epicData, idealPlan (5-10 Stories), standardsResearch, teamId, autoApprove</li>
<li><strong>Output:</strong> N Story URLs in Linear + kanban_board.md updated</li>
<li><strong>Validation:</strong> INVEST criteria (stop if ANY fails)</li>
<li><strong>Version:</strong> 1.0.0</li>
</ul>
</div>
<div class="notes-section">
<h2>Important Notes</h2>
<ul>
<li><strong>Phase 1:</strong> Generate 8-section Story documents for ALL Stories, INSERT Standards Research in Technical Notes → Library Research</li>
<li><strong>Phase 2:</strong> Validate INVEST (Independent, Negotiable, Valuable, Estimable, Small, Testable) for ALL Stories before creation</li>
<li><strong>Phase 3:</strong> Show preview with story summaries, totals (hours, tests), Standards Research included, INVEST validation passed</li>
<li><strong>Phase 4:</strong> autoApprove=true (automation mode) skips user confirmation, otherwise wait for "confirm"</li>
<li><strong>Phase 5:</strong> Create ALL Stories in Linear (project=Epic, labels=user-story, state=Backlog), update kanban_board.md with Epic Grouping Algorithm</li>
<li><strong>Standards Research:</strong> Inserted in EVERY Story (from ln-221-standards-researcher via ln-220 Phase 2), reused for consistency</li>
<li><strong>Epic Grouping:</strong> Reuse Epic header if exists (search by Epic number), don't duplicate</li>
<li><strong>Story Numbering:</strong> Sequential across ALL Epics (read Next Story from kanban_board.md Epic Story Counters)</li>
</ul>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,195 @@
# US00N: Story Title
**Epic:** [Epic N - Epic Name](link-to-epic)
**Priority:** High | Medium | Low
---
## Story
**As a** [role/persona - e.g., API client, developer, end user]
**I want** [feature/capability - what they want to do]
**So that** [business value/benefit - why it matters]
---
## Context
### Current Situation
- What exists now?
- What's the pain point?
- Why is this needed?
### Desired Outcome
- What should exist after completion?
- How will this improve user experience?
- What business value delivered?
---
## Acceptance Criteria
Use **Given-When-Then** format:
### Main Scenarios
- **Given** [initial context/state]
**When** [action/event occurs]
**Then** [expected outcome/result]
- **Given** [context]
**When** [action]
**Then** [outcome]
- **Given** [context]
**When** [action]
**Then** [outcome]
### Edge Cases
- **Given** [edge case context]
**When** [edge case action]
**Then** [expected handling]
### Error Handling
- **Given** [error condition]
**When** [action attempted]
**Then** [expected error response]
---
## Implementation Tasks
Tasks created separately (parentId → this Story):
- [API-XX: Task Name](link) - Brief description
- [API-YY: Task Name](link) - Brief description
- [API-ZZ: Tests for Story](link) - **Final Task:** All tests (Unit/Integration/E2E)
> [!NOTE]
> Order tasks Consumer → Service → Provider (API endpoint → Service → Repository → Database). Consumer Tasks may mock provider layers until implemented.
---
## Test Strategy
> [!NOTE]
> All tests implemented in final Task of this Story (created by ln-350-story-test-planner after manual testing).
**Approach:** Risk-Based Testing with enforced limits (2-5 E2E, 3-8 Integration, 5-15 Unit per Story)
**Reference:** See `ln-350-story-test-planner/references/risk_based_testing_guide.md` for complete Risk-Based Testing methodology.
### E2E Tests (2-5 max)
Test complete user journeys. **ONLY Priority ≥15 scenarios** (money, security, core flows):
- [Critical AC or Edge Case]: [Priority score] - [Full business flow]
- [Critical AC or Edge Case]: [Priority score] - [Full business flow]
**Type:** API E2E / UI E2E (depending on application type)
**Based on:** ACTUAL manual testing results from ln-343-manual-tester (delegated by ln-340-story-quality-gate Pass 1)
### Integration Tests (3-8 max)
Test layer interactions with real dependencies. **ONLY Priority ≥15 interactions NOT covered by E2E:**
- [Integration Point]: [Priority score] - [What E2E doesn't cover: rollback/error/concurrency]
- [Integration Point]: [Priority score] - [What data flow to verify]
**Use Real:** Database (test), filesystem, internal services
**Use Mocks:** External APIs, payment systems, email services
### Unit Tests (5-15 max)
Test complex business logic in isolation. **ONLY Priority ≥15 logic NOT covered by E2E:**
- [Complex Function]: [Priority score] - [Financial calculation / Security logic / Algorithm]
- [Complex Function]: [Priority score] - [Edge cases from manual testing]
**SKIP:** Simple CRUD, framework code, trivial conditionals, getters/setters
**Test Limits:** 10-28 tests total per Story (enforced by ln-350-story-test-planner)
**Focus:** Critical path coverage (all Priority ≥15 scenarios), NOT coverage percentage
---
## Technical Notes
### Architecture Considerations
- Which layers affected? (API, Service, Repository, Client)
- What patterns apply?
- Any constraints?
### Library Research
**Primary libraries:**
| Library | Version | Purpose | Docs |
|---------|---------|---------|------|
| [name] | v[X.Y.Z] | [use case for Story domain] | [official docs URL] |
**Key APIs:**
- `[method_signature]` - [purpose and when to use]
- `[method_signature]` - [purpose and when to use]
**Key constraints:**
- [Constraint 1: e.g., no async support, memory limitations, multi-process caveats]
- [Constraint 2: e.g., compatibility requirements, deprecated features]
**Standards compliance:**
- [Standard/RFC]: [how Story complies - brief description, e.g., "RFC 6749 OAuth 2.0 - uses authorization code flow"]
> [!NOTE]
> This section populated by ln-220-story-coordinator Phase 0 (Library & Standards Research). Tasks reference these specifications in their Technical Approach sections.
### Integration Points
- **External Systems**: Which external APIs/services?
- **Internal Services**: Which app services interact?
- **Database**: Which tables/models involved?
### Performance & Security
- Response time targets
- Throughput requirements
- Security considerations
### Related Guides
- [Guide XX: Pattern Name](../guides/guide_XXX_pattern_name.md) - [when to use this pattern]
- [Guide YY: Pattern Name](../guides/guide_YYY_pattern_name.md) - [when to use this pattern]
> [!NOTE]
> Guide links inserted by ln-320-story-validator Phase 3 (auto-creates missing guides via ln-321-guide-creator, then links them here).
---
## Definition of Done
### Functionality
- [ ] All acceptance criteria met (main + edge cases + errors)
- [ ] Logging added appropriately
### Testing
- [ ] All implementation tasks completed (including final test task)
- [ ] All tests passing (E2E 2-5, Integration 3-8, Unit 5-15, total 10-28)
- [ ] All Priority ≥15 scenarios tested
### Code Quality
- [ ] Code reviewed and approved
- [ ] Follows project patterns
- [ ] Performance meets requirements
- [ ] Documentation updated
- [ ] All affected existing code refactored (no backward compatibility / legacy code left)
- [ ] All existing tests updated and passing
- [ ] All affected existing documentation updated
---
## Dependencies
### Depends On
- **User Story:** [USXXX](link) - Description
- **External:** Third-party requirement
### Blocks
- **User Story:** [USXXX](link) - Description
---
**Template Version:** 7.0.0 (Added Library Research + Related Guides subsections in Technical Notes)
**Last Updated:** 2025-11-12