@kosuke-ai/cli 0.0.38 โ 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +109 -51
- package/dist/index.js.map +1 -1
- package/dist/kosuke/commands/build.d.ts.map +1 -1
- package/dist/kosuke/commands/build.js +171 -54
- package/dist/kosuke/commands/build.js.map +1 -1
- package/dist/kosuke/commands/migrate.d.ts +33 -0
- package/dist/kosuke/commands/migrate.d.ts.map +1 -0
- package/dist/kosuke/commands/migrate.js +196 -0
- package/dist/kosuke/commands/migrate.js.map +1 -0
- package/dist/kosuke/commands/ship.d.ts.map +1 -1
- package/dist/kosuke/commands/ship.js +4 -9
- package/dist/kosuke/commands/ship.js.map +1 -1
- package/dist/kosuke/commands/test.d.ts +18 -9
- package/dist/kosuke/commands/test.d.ts.map +1 -1
- package/dist/kosuke/commands/test.js +48 -68
- package/dist/kosuke/commands/test.js.map +1 -1
- package/dist/kosuke/commands/tickets.d.ts +24 -13
- package/dist/kosuke/commands/tickets.d.ts.map +1 -1
- package/dist/kosuke/commands/tickets.js +339 -353
- package/dist/kosuke/commands/tickets.js.map +1 -1
- package/dist/kosuke/types.d.ts +35 -5
- package/dist/kosuke/types.d.ts.map +1 -1
- package/dist/kosuke/utils/logger.d.ts +1 -1
- package/dist/kosuke/utils/logger.d.ts.map +1 -1
- package/dist/kosuke/utils/prompt-generator.d.ts +2 -2
- package/dist/kosuke/utils/prompt-generator.d.ts.map +1 -1
- package/dist/kosuke/utils/prompt-generator.js +2 -2
- package/dist/kosuke/utils/prompt-generator.js.map +1 -1
- package/dist/kosuke/utils/test-runner.d.ts.map +1 -1
- package/dist/kosuke/utils/test-runner.js +9 -2
- package/dist/kosuke/utils/test-runner.js.map +1 -1
- package/dist/kosuke/utils/tickets-manager.d.ts +0 -4
- package/dist/kosuke/utils/tickets-manager.d.ts.map +1 -1
- package/dist/kosuke/utils/tickets-manager.js +1 -1
- package/dist/kosuke/utils/tickets-manager.js.map +1 -1
- package/dist/lib.d.ts +2 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +1 -0
- package/dist/lib.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,256 +1,271 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tickets command - Generate tickets from requirements document
|
|
3
3
|
*
|
|
4
|
-
* This command analyzes a requirements document
|
|
5
|
-
* structured tickets in three phases:
|
|
6
|
-
* 1. Schema tickets (database design)
|
|
7
|
-
* 2. Backend tickets (API, services, business logic)
|
|
8
|
-
* 3. Frontend tickets (pages, components, UI)
|
|
4
|
+
* This command analyzes a requirements document and generates structured tickets:
|
|
9
5
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* SCAFFOLD MODE (--scaffold flag):
|
|
7
|
+
* SCAFFOLD BATCH (template adaptation):
|
|
8
|
+
* 1. SCAFFOLD-SCHEMA-1 (database infrastructure changes, auto-validated)
|
|
9
|
+
* 2. SCAFFOLD-BACKEND-X (API infrastructure changes)
|
|
10
|
+
* 3. SCAFFOLD-FRONTEND-X (UI infrastructure changes)
|
|
11
|
+
* 4. SCAFFOLD-WEB-TEST-X (validate scaffold E2E)
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* LOGIC BATCH (business functionality):
|
|
14
|
+
* 1. LOGIC-SCHEMA-1 (business entities, auto-validated)
|
|
15
|
+
* 2. LOGIC-BACKEND-1 (business API)
|
|
16
|
+
* 3. LOGIC-FRONTEND-1 (business UI)
|
|
17
|
+
* 4. LOGIC-WEB-TEST-1 (validate logic E2E)
|
|
18
|
+
* ... (multiple logic batches per feature)
|
|
19
|
+
*
|
|
20
|
+
* LOGIC-ONLY MODE (default):
|
|
21
|
+
* Only generates LOGIC tickets for new features
|
|
22
|
+
*
|
|
23
|
+
* Claude Code Agent explores the codebase to understand the tech stack and
|
|
24
|
+
* generates contextual tickets in a single comprehensive analysis.
|
|
14
25
|
*
|
|
15
26
|
* Usage:
|
|
16
|
-
* kosuke tickets #
|
|
27
|
+
* kosuke tickets # Logic-only mode, use docs.md
|
|
28
|
+
* kosuke tickets --scaffold # Scaffold + logic mode
|
|
17
29
|
* kosuke tickets --path=custom.md # Custom requirements file
|
|
18
|
-
* kosuke tickets --
|
|
19
|
-
* kosuke tickets --directory=./
|
|
20
|
-
* kosuke tickets --dir=./my-app --path=docs/spec.md # Custom directory and requirements path
|
|
30
|
+
* kosuke tickets --prompt="Add dark mode" # Inline requirements
|
|
31
|
+
* kosuke tickets --directory=./my-app # Analyze specific directory
|
|
21
32
|
*/
|
|
22
33
|
import { existsSync, readFileSync, statSync, writeFileSync } from 'fs';
|
|
23
34
|
import { join, resolve } from 'path';
|
|
24
35
|
import { formatCostBreakdown, runAgent } from '../utils/claude-agent.js';
|
|
25
36
|
import { logger, setupCancellationHandler } from '../utils/logger.js';
|
|
26
37
|
/**
|
|
27
|
-
* Build system prompt for ticket generation
|
|
38
|
+
* Build unified system prompt for comprehensive ticket generation
|
|
28
39
|
*/
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
const phaseInstructions = {
|
|
32
|
-
schema_scaffold: `
|
|
33
|
-
**GENERATE: ONE DATABASE SCHEMA SCAFFOLD TICKET**
|
|
34
|
-
|
|
35
|
-
This ticket should handle infrastructure/setup database changes based on the analysis:
|
|
36
|
-
- Modifications to auth tables (if organizations needed or removed)
|
|
37
|
-
- Billing/subscription tables (if changed or removed)
|
|
38
|
-
- Email verification/notification tables
|
|
39
|
-
- Any template baseline schema adjustments
|
|
40
|
-
|
|
41
|
-
**Key Focus:**
|
|
42
|
-
- What needs to be REMOVED from template (e.g., organization tables if not needed)
|
|
43
|
-
- What needs to be ADDED for infrastructure (e.g., organization support if needed)
|
|
44
|
-
- Updates to existing template tables for new requirements
|
|
45
|
-
|
|
46
|
-
Ticket ID: SCHEMA-SCAFFOLD-1
|
|
47
|
-
`,
|
|
48
|
-
schema_logic: `
|
|
49
|
-
**GENERATE: ONE DATABASE SCHEMA BUSINESS LOGIC TICKET**
|
|
50
|
-
|
|
51
|
-
This ticket should handle core business domain tables based on the analysis:
|
|
52
|
-
- Main application entities (e.g., tasks, projects, posts, campaigns)
|
|
53
|
-
- Business-specific relationships
|
|
54
|
-
- Domain-specific fields and constraints
|
|
55
|
-
- Application data models
|
|
56
|
-
|
|
57
|
-
**Key Focus:**
|
|
58
|
-
- Core business entities unique to this application
|
|
59
|
-
- Relationships between business entities
|
|
60
|
-
- NOT infrastructure tables (auth, billing, etc.)
|
|
61
|
-
|
|
62
|
-
Ticket ID: SCHEMA-LOGIC-1
|
|
63
|
-
`,
|
|
64
|
-
backend_scaffold: `
|
|
65
|
-
**GENERATE: BACKEND SCAFFOLD TICKETS**
|
|
66
|
-
|
|
67
|
-
Generate tickets for infrastructure/setup backend changes:
|
|
68
|
-
- Auth modifications (add/remove organization support, change providers)
|
|
69
|
-
- Billing API changes (remove Stripe, add different tiers, etc.)
|
|
70
|
-
- Email template setup (create transactional email templates)
|
|
71
|
-
- Landing page API routes (if needed)
|
|
72
|
-
- Third-party integrations setup
|
|
73
|
-
|
|
74
|
-
**Granularity:**
|
|
75
|
-
- ONE ticket per infrastructure area (auth, billing, email, landing)
|
|
76
|
-
- Let Claude decide granularity based on complexity
|
|
77
|
-
- Each ticket should be independently implementable
|
|
78
|
-
|
|
79
|
-
Ticket IDs: BACKEND-SCAFFOLD-1, BACKEND-SCAFFOLD-2, etc. (sequential)
|
|
80
|
-
`,
|
|
81
|
-
backend_logic: `
|
|
82
|
-
**GENERATE: BACKEND BUSINESS LOGIC TICKETS**
|
|
83
|
-
|
|
84
|
-
Generate tickets for core application backend features:
|
|
85
|
-
- API endpoints for business entities
|
|
86
|
-
- Service layer logic
|
|
87
|
-
- Business rules and validation
|
|
88
|
-
- Application-specific data processing
|
|
89
|
-
- Feature-specific integrations
|
|
90
|
-
|
|
91
|
-
**Granularity:**
|
|
92
|
-
- ONE ticket per feature/module
|
|
93
|
-
- Let Claude decide granularity based on complexity
|
|
94
|
-
- Each ticket should be independently implementable
|
|
95
|
-
|
|
96
|
-
Ticket IDs: BACKEND-LOGIC-1, BACKEND-LOGIC-2, etc. (sequential)
|
|
97
|
-
`,
|
|
98
|
-
frontend_scaffold: `
|
|
99
|
-
**GENERATE: FRONTEND SCAFFOLD TICKETS**
|
|
100
|
-
|
|
101
|
-
Generate tickets for infrastructure/setup frontend changes:
|
|
102
|
-
- Auth UI modifications (add/remove organization switcher, change auth flow)
|
|
103
|
-
- Billing UI changes (subscription management, pricing page updates)
|
|
104
|
-
- Landing page customization
|
|
105
|
-
- Email template previews
|
|
106
|
-
- Navigation/layout updates for infrastructure changes
|
|
107
|
-
|
|
108
|
-
**Granularity:**
|
|
109
|
-
- ONE ticket per infrastructure area
|
|
110
|
-
- Let Claude decide granularity based on complexity
|
|
111
|
-
- Each ticket should be independently implementable
|
|
112
|
-
|
|
113
|
-
Ticket IDs: FRONTEND-SCAFFOLD-1, FRONTEND-SCAFFOLD-2, etc. (sequential)
|
|
114
|
-
`,
|
|
115
|
-
frontend_logic: `
|
|
116
|
-
**GENERATE: FRONTEND BUSINESS LOGIC TICKETS**
|
|
117
|
-
|
|
118
|
-
Generate tickets for core application frontend features:
|
|
119
|
-
- Application-specific pages
|
|
120
|
-
- Feature-specific UI components
|
|
121
|
-
- Business logic forms
|
|
122
|
-
- User workflows
|
|
123
|
-
- Application state management
|
|
124
|
-
|
|
125
|
-
**Granularity:**
|
|
126
|
-
- ONE ticket per PAGE or major feature
|
|
127
|
-
- Let Claude decide granularity based on complexity
|
|
128
|
-
- Each ticket should cover all components and functionality for that area
|
|
129
|
-
|
|
130
|
-
Ticket IDs: FRONTEND-LOGIC-1, FRONTEND-LOGIC-2, etc. (sequential)
|
|
131
|
-
`,
|
|
132
|
-
};
|
|
133
|
-
const categoryGuidance = ticketType === 'scaffold'
|
|
40
|
+
function buildTicketPrompt(requirementsContent, projectPath, isScaffoldMode) {
|
|
41
|
+
const scaffoldGuidance = isScaffoldMode
|
|
134
42
|
? `
|
|
135
|
-
**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
43
|
+
**SCAFFOLD TICKETS - Template Adaptation ONLY:**
|
|
44
|
+
|
|
45
|
+
These tickets focus on removing, changing, or customizing the Kosuke Template baseline.
|
|
46
|
+
DO NOT add new business logic or features from requirements here.
|
|
47
|
+
|
|
48
|
+
Scaffold tickets should:
|
|
49
|
+
- โ REMOVE unused template features (e.g., organizations, billing, multi-tenancy)
|
|
50
|
+
- ๐ CHANGE existing features (e.g., swap Better Auth for Clerk, simplify billing)
|
|
51
|
+
- ๐จ CUSTOMIZE infrastructure (landing page, email templates, branding, navigation)
|
|
52
|
+
|
|
53
|
+
Examples of SCAFFOLD tickets:
|
|
54
|
+
- "Remove organization/multi-tenancy support from auth"
|
|
55
|
+
- "Simplify billing to single tier (remove pro/business tiers)"
|
|
56
|
+
- "Customize landing page for [specific use case]"
|
|
57
|
+
- "Remove landing page entirely (internal tool)"
|
|
58
|
+
- "Update email templates for [brand name]"
|
|
59
|
+
|
|
60
|
+
**SCAFFOLD Ticket Ordering:**
|
|
61
|
+
1. SCAFFOLD-SCHEMA-1 (one ticket for all database infrastructure changes, auto-validated)
|
|
62
|
+
2. SCAFFOLD-BACKEND-1, SCAFFOLD-BACKEND-2, ... (backend infrastructure tickets)
|
|
63
|
+
3. SCAFFOLD-FRONTEND-1, SCAFFOLD-FRONTEND-2, ... (frontend infrastructure tickets)
|
|
64
|
+
4. SCAFFOLD-WEB-TEST-1, SCAFFOLD-WEB-TEST-2, ... (E2E tests for scaffold)
|
|
142
65
|
`
|
|
143
|
-
:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
- Use the main entity name (e.g., "tasks", "projects", "campaigns")
|
|
147
|
-
- Or use feature name (e.g., "user-management", "notifications", "analytics")
|
|
148
|
-
- Keep categories consistent across related tickets
|
|
149
|
-
`;
|
|
150
|
-
const templateBaseline = `
|
|
151
|
-
**Kosuke Template Baseline (what the template already includes):**
|
|
152
|
-
- **Authentication**: Better Auth with Email OTP
|
|
153
|
-
- **User Model**: Individual users (no organizations/multi-tenancy by default)
|
|
154
|
-
- **Billing**: Stripe with subscription tiers (free, pro, business)
|
|
155
|
-
- **Email**: Resend for transactional emails
|
|
156
|
-
- **Landing Page**: Basic marketing site with pricing
|
|
157
|
-
- **Database**: PostgreSQL with Drizzle ORM
|
|
158
|
-
- **Stack**: Next.js 15, React 19, TypeScript, Tailwind, Shadcn UI
|
|
159
|
-
|
|
160
|
-
**Analysis Instructions:**
|
|
161
|
-
Before generating tickets, analyze the requirements to understand:
|
|
162
|
-
1. **Auth**: Does it need organizations/multi-tenancy? Different auth provider?
|
|
163
|
-
2. **Billing**: Keep Stripe? Remove billing entirely? Different tiers?
|
|
164
|
-
3. **Email**: What transactional emails are needed? Custom templates?
|
|
165
|
-
4. **Landing**: Customize marketing pages? Remove landing page?
|
|
166
|
-
5. **Core Domain**: What are the main business entities and workflows?
|
|
167
|
-
|
|
168
|
-
For SCAFFOLD tickets:
|
|
169
|
-
- Identify what needs to be REMOVED from template (if not needed)
|
|
170
|
-
- Identify what needs to be ADDED to template (if needed)
|
|
171
|
-
- Identify what needs to be CUSTOMIZED (landing page, email templates, etc.)
|
|
172
|
-
|
|
173
|
-
For LOGIC tickets:
|
|
174
|
-
- Focus on core business functionality
|
|
175
|
-
- Implement application-specific features
|
|
176
|
-
- Build domain models and workflows
|
|
177
|
-
`;
|
|
178
|
-
return `You are an expert software architect generating implementation tickets for a Kosuke Template project.
|
|
66
|
+
: '';
|
|
67
|
+
const webTestGuidance = `
|
|
68
|
+
**WEB TEST TICKETS - Stagehand Agent E2E Tests:**
|
|
179
69
|
|
|
180
|
-
|
|
181
|
-
|
|
70
|
+
Web test tickets are executed by Stagehand agent and must follow these guidelines:
|
|
71
|
+
|
|
72
|
+
**Test User Discovery:**
|
|
73
|
+
1. **ALWAYS read seed files** to find test user credentials:
|
|
74
|
+
- Look for files: lib/db/seed.ts, src/lib/db/seed.ts
|
|
75
|
+
- Pattern: Any email ending with "+kosuke_test@example.com" uses OTP code "424242"
|
|
76
|
+
- Example: john+kosuke_test@example.com โ OTP: 424242
|
|
77
|
+
- Include all discovered test users in ticket description
|
|
78
|
+
|
|
79
|
+
**Ticket Structure Requirements:**
|
|
80
|
+
Each web test ticket MUST include:
|
|
81
|
+
|
|
82
|
+
1. **Test User Credentials** (at the top)
|
|
83
|
+
- List all test users with their emails
|
|
84
|
+
- Document OTP code (424242)
|
|
85
|
+
- Specify user roles if applicable (admin, regular user, etc.)
|
|
86
|
+
|
|
87
|
+
2. **Test Steps** (numbered, detailed natural language)
|
|
88
|
+
- Navigation instructions ("Navigate to /sign-in")
|
|
89
|
+
- User interactions ("Click button labeled 'New Task'")
|
|
90
|
+
- Input actions ("Enter 'Test Task' in title field")
|
|
91
|
+
- Expected outcomes after each step ("Expected: Task appears in list")
|
|
92
|
+
- Use CLEAR element descriptions (button text, labels, placeholders)
|
|
93
|
+
- Use relative paths only (e.g., /sign-in, /tasks) - base URL provided as test argument
|
|
94
|
+
|
|
95
|
+
3. **Acceptance Criteria**
|
|
96
|
+
- Final expected state
|
|
97
|
+
- Data validation points
|
|
98
|
+
- User feedback confirmation
|
|
99
|
+
|
|
100
|
+
**Stagehand Best Practices:**
|
|
101
|
+
- Use natural language, NOT code
|
|
102
|
+
- Be SPECIFIC about element identification (button text, input labels, exact URLs)
|
|
103
|
+
- Include EXPECTED OUTCOMES after each major action
|
|
104
|
+
- Combine related flows into ONE ticket (signup โ create โ invite = 1 ticket)
|
|
105
|
+
- Authentication steps MUST be explicit:
|
|
106
|
+
1. Navigate to /sign-in
|
|
107
|
+
2. Enter email: {test_user}+kosuke_test@example.com
|
|
108
|
+
3. Click "Send Code" button
|
|
109
|
+
4. Enter OTP: 424242
|
|
110
|
+
5. Click "Verify" button
|
|
111
|
+
6. Expected: Redirected to dashboard/main app
|
|
112
|
+
|
|
113
|
+
**Example Web Test Ticket:**
|
|
114
|
+
|
|
115
|
+
{
|
|
116
|
+
"id": "LOGIC-WEB-TEST-1",
|
|
117
|
+
"title": "E2E: User signup and create first task",
|
|
118
|
+
"description": "**Test User Credentials:**\\n- Email: john+kosuke_test@example.com\\n- OTP Code: 424242\\n\\n**Test Steps:**\\n\\n1. **Sign in with test user**\\n - Navigate to /sign-in\\n - Enter email: john+kosuke_test@example.com\\n - Click button labeled 'Send Code'\\n - Enter OTP code: 424242\\n - Click button labeled 'Verify'\\n - Expected: Redirected to /tasks\\n\\n2. **Create new task**\\n - Click button with text 'New Task'\\n - Enter 'My First Task' in the Title field\\n - Select 'High' from Priority dropdown\\n - Click 'Create Task' button\\n - Expected: Task appears in task list\\n - Expected: Success message shown\\n\\n3. **Verify task persistence**\\n - Refresh the page\\n - Expected: Task 'My First Task' still visible\\n - Expected: Priority shows 'High'\\n\\n**Acceptance Criteria:**\\n- User successfully authenticates with OTP\\n- Task is created and visible\\n- Task persists after page refresh\\n- UI shows appropriate feedback",
|
|
119
|
+
"type": "test",
|
|
120
|
+
"estimatedEffort": 4,
|
|
121
|
+
"status": "Todo",
|
|
122
|
+
"category": "tasks"
|
|
123
|
+
}`;
|
|
124
|
+
return `You are an expert software architect generating implementation tickets.
|
|
182
125
|
|
|
183
126
|
**Requirements Document:**
|
|
184
127
|
${requirementsContent}
|
|
185
128
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
**Context:**
|
|
129
|
+
**Project Context:**
|
|
189
130
|
You have access to the project directory at: ${projectPath}
|
|
190
|
-
|
|
191
|
-
|
|
131
|
+
|
|
132
|
+
${scaffoldGuidance}
|
|
133
|
+
${webTestGuidance}
|
|
134
|
+
|
|
135
|
+
**LOGIC TICKETS - Business Functionality:**
|
|
136
|
+
|
|
137
|
+
These tickets implement the actual features and requirements from the document.
|
|
138
|
+
|
|
139
|
+
Logic tickets should:
|
|
140
|
+
- ๐๏ธ Create schema for business entities (tasks, projects, posts, etc.)
|
|
141
|
+
- โ๏ธ Build backend APIs for business features
|
|
142
|
+
- ๐จ Create frontend UI for business features
|
|
143
|
+
|
|
144
|
+
**LOGIC Ticket Ordering:**
|
|
145
|
+
Each feature can have its own batch of tickets:
|
|
146
|
+
|
|
147
|
+
Feature 1:
|
|
148
|
+
1. LOGIC-SCHEMA-1 (schema for feature 1, auto-validated)
|
|
149
|
+
2. LOGIC-BACKEND-1 (backend for feature 1)
|
|
150
|
+
3. LOGIC-FRONTEND-1 (frontend for feature 1)
|
|
151
|
+
4. LOGIC-WEB-TEST-1 (E2E test for feature 1)
|
|
152
|
+
|
|
153
|
+
Feature 2:
|
|
154
|
+
5. LOGIC-BACKEND-2 (backend for feature 2, if no schema needed)
|
|
155
|
+
6. LOGIC-FRONTEND-2 (frontend for feature 2)
|
|
156
|
+
7. LOGIC-WEB-TEST-2 (E2E test for feature 2)
|
|
157
|
+
|
|
158
|
+
**Ticket Granularity:**
|
|
159
|
+
- Schema: Usually ONE ticket per batch (scaffold or logic), automatically validated during build
|
|
160
|
+
- Backend: Let complexity decide (could be 1-5 tickets per batch)
|
|
161
|
+
- Frontend: Let complexity decide (could be 1-5 tickets per batch)
|
|
162
|
+
- Web Tests: Let complexity decide (1 test per major user flow)
|
|
163
|
+
|
|
164
|
+
**Your Task:**
|
|
165
|
+
1. **Explore the codebase** using read_file, grep, codebase_search to understand:
|
|
166
|
+
- Current tech stack and framework versions
|
|
167
|
+
- Existing architecture patterns
|
|
168
|
+
- Database schema structure
|
|
169
|
+
- API route patterns
|
|
170
|
+
- UI component library and styling
|
|
171
|
+
${isScaffoldMode ? ' - What template features are currently present\n - What needs to be removed, changed, or customized' : ''}
|
|
172
|
+
|
|
173
|
+
2. **Discover test users** for web testing:
|
|
174
|
+
- Read seed files: lib/db/seed.ts, src/lib/db/seed.ts (use read_file or grep)
|
|
175
|
+
- Look for test user pattern: {name}+kosuke_test@example.com
|
|
176
|
+
- Document all test users found (email addresses)
|
|
177
|
+
- Note: All test users use OTP code 424242 for Better Auth
|
|
178
|
+
- Include test user credentials in ALL web test tickets
|
|
179
|
+
|
|
180
|
+
3. **Analyze requirements** to determine:
|
|
181
|
+
- Which layers are needed (schema/backend/frontend)
|
|
182
|
+
- How to break down features into logical batches
|
|
183
|
+
- What user flows need E2E web tests
|
|
184
|
+
|
|
185
|
+
4. **Generate ALL tickets** in the correct order:
|
|
186
|
+
${isScaffoldMode ? ' - SCAFFOLD batch first (template adaptation)\n - LOGIC batches second (business features)' : ' - LOGIC batches only (business features)'}
|
|
187
|
+
- Follow the ticket ordering structure above
|
|
188
|
+
- Schema tickets are automatically validated during build (no separate test tickets needed)
|
|
189
|
+
- For web tests: Include test user credentials, detailed steps, and expected outcomes
|
|
192
190
|
|
|
193
191
|
**Ticket Structure:**
|
|
194
192
|
Each ticket must be a JSON object with:
|
|
195
|
-
- id: string (e.g., "SCHEMA-
|
|
193
|
+
- id: string (e.g., "SCAFFOLD-SCHEMA-1", "LOGIC-BACKEND-2", "SCAFFOLD-WEB-TEST-1")
|
|
196
194
|
- title: string (clear, concise title)
|
|
197
195
|
- description: string (detailed description with acceptance criteria)
|
|
198
|
-
- type: "
|
|
196
|
+
- type: "schema" | "backend" | "frontend" | "test"
|
|
199
197
|
- estimatedEffort: number (1-10, where 1=very easy, 10=very complex)
|
|
200
|
-
- status: "Todo"
|
|
201
|
-
- category: string (
|
|
202
|
-
${categoryGuidance}
|
|
198
|
+
- status: "Todo"
|
|
199
|
+
- category: string (e.g., "auth", "billing", "user-management", "tasks")
|
|
203
200
|
|
|
204
201
|
**Output Format:**
|
|
205
|
-
Return ONLY a valid JSON array of tickets. No markdown, no code blocks, just raw JSON.
|
|
202
|
+
Return ONLY a valid JSON array of ALL tickets in the correct order. No markdown, no code blocks, just raw JSON.
|
|
206
203
|
|
|
207
204
|
Example:
|
|
208
205
|
[
|
|
209
206
|
{
|
|
210
|
-
"id": "
|
|
211
|
-
"title": "Remove
|
|
212
|
-
"description": "Remove multi-tenancy/organization features from
|
|
213
|
-
"type": "
|
|
214
|
-
"estimatedEffort":
|
|
207
|
+
"id": "SCAFFOLD-SCHEMA-1",
|
|
208
|
+
"title": "Remove organizations and simplify auth schema",
|
|
209
|
+
"description": "Remove multi-tenancy/organization features from database:\\n- Drop organization tables\\n- Remove org foreign keys from users table\\n- Simplify schema to individual users only\\n\\nAcceptance Criteria:\\n- Organization tables removed\\n- User table simplified\\n- Migrations created and validated automatically\\n- No schema errors",
|
|
210
|
+
"type": "schema",
|
|
211
|
+
"estimatedEffort": 5,
|
|
215
212
|
"status": "Todo",
|
|
216
213
|
"category": "auth"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"id": "LOGIC-WEB-TEST-1",
|
|
217
|
+
"title": "E2E: User creates and manages a task",
|
|
218
|
+
"description": "**Test User Credentials:**\\n- Email: john+kosuke_test@example.com\\n- OTP Code: 424242\\n\\n**Test Steps:**\\n\\n1. **Authenticate as test user**\\n - Navigate to /sign-in\\n - Enter email: john+kosuke_test@example.com\\n - Click 'Send Code' button\\n - Enter OTP: 424242\\n - Click 'Verify' button\\n - Expected: Redirected to /tasks dashboard\\n\\n2. **Create new task**\\n - Click 'New Task' button\\n - Enter title: 'Test Task'\\n - Select priority: 'High'\\n - Click 'Create' button\\n - Expected: Task appears in task list\\n - Expected: Success toast notification shown\\n\\n3. **Edit task**\\n - Click on the created task\\n - Change title to: 'Updated Task'\\n - Expected: Task title updates immediately\\n\\n4. **Delete task**\\n - Click delete icon on task\\n - Confirm deletion in dialog\\n - Expected: Task removed from list\\n\\n**Acceptance Criteria:**\\n- User successfully authenticates\\n- Task creation, editing, and deletion work\\n- UI provides appropriate feedback\\n- Changes persist correctly",
|
|
219
|
+
"type": "test",
|
|
220
|
+
"estimatedEffort": 5,
|
|
221
|
+
"status": "Todo",
|
|
222
|
+
"category": "tasks"
|
|
217
223
|
}
|
|
218
224
|
]
|
|
219
225
|
|
|
220
226
|
**Critical Instructions:**
|
|
221
|
-
1.
|
|
222
|
-
2.
|
|
223
|
-
3.
|
|
224
|
-
4.
|
|
225
|
-
5.
|
|
226
|
-
6.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
1. Explore the project directory thoroughly before generating tickets
|
|
228
|
+
2. ${isScaffoldMode ? 'For SCAFFOLD: Focus on template adaptation ONLY (remove/change/customize)' : ''}
|
|
229
|
+
3. For LOGIC: Focus on business features from requirements
|
|
230
|
+
4. **IMPORTANT**: Read seed files (lib/db/seed.ts or src/lib/db/seed.ts) to discover test users
|
|
231
|
+
5. **SCHEMA TICKETS**: No separate test tickets needed - validation happens automatically during build
|
|
232
|
+
6. **WEB TESTS MUST INCLUDE**:
|
|
233
|
+
- Test user credentials at the top
|
|
234
|
+
- Clear numbered steps with natural language
|
|
235
|
+
- Expected outcomes after each step
|
|
236
|
+
- Specific element descriptions (button text, labels, URLs)
|
|
237
|
+
- Complete user flows in one ticket (signup โ create โ invite = 1 ticket)
|
|
238
|
+
7. Follow the exact ticket ordering structure
|
|
239
|
+
8. Make descriptions detailed with clear acceptance criteria
|
|
240
|
+
9. Return ONLY valid JSON - no explanations, no markdown
|
|
241
|
+
10. Ensure sequential ticket IDs match the ordering structure
|
|
242
|
+
|
|
243
|
+
Begin by:
|
|
244
|
+
1. Reading seed files to discover test users
|
|
245
|
+
2. Exploring the project directory structure
|
|
246
|
+
3. Generating ALL tickets in the correct order with test user info in web tests.`;
|
|
233
247
|
}
|
|
234
248
|
/**
|
|
235
|
-
* Parse tickets from Claude's response
|
|
249
|
+
* Parse all tickets from Claude's response
|
|
236
250
|
*/
|
|
237
|
-
function
|
|
251
|
+
function parseAllTickets(response) {
|
|
238
252
|
try {
|
|
239
253
|
// Extract JSON from response (in case Claude includes extra text)
|
|
240
254
|
const jsonMatch = response.match(/\[[\s\S]*\]/);
|
|
241
255
|
if (!jsonMatch) {
|
|
242
|
-
throw new Error(
|
|
256
|
+
throw new Error('No JSON array found in response');
|
|
243
257
|
}
|
|
244
258
|
const tickets = JSON.parse(jsonMatch[0]);
|
|
245
259
|
// Validate tickets
|
|
246
260
|
if (!Array.isArray(tickets)) {
|
|
247
261
|
throw new Error(`Expected array of tickets, got ${typeof tickets}`);
|
|
248
262
|
}
|
|
263
|
+
const validTypes = ['schema', 'backend', 'frontend', 'test'];
|
|
249
264
|
for (const ticket of tickets) {
|
|
250
265
|
if (!ticket.id || !ticket.title || !ticket.description) {
|
|
251
266
|
throw new Error(`Invalid ticket structure: ${JSON.stringify(ticket)}`);
|
|
252
267
|
}
|
|
253
|
-
if (!ticket.type || (ticket.type
|
|
268
|
+
if (!ticket.type || !validTypes.includes(ticket.type)) {
|
|
254
269
|
throw new Error(`Invalid or missing type for ticket ${ticket.id}: ${ticket.type}`);
|
|
255
270
|
}
|
|
256
271
|
if (typeof ticket.estimatedEffort !== 'number' ||
|
|
@@ -265,13 +280,13 @@ function parseTicketsFromResponse(response, phase, ticketType) {
|
|
|
265
280
|
return tickets;
|
|
266
281
|
}
|
|
267
282
|
catch (error) {
|
|
268
|
-
console.error(
|
|
283
|
+
console.error('\nโ Failed to parse tickets from response:');
|
|
269
284
|
console.error(`Raw response:\n${response.substring(0, 500)}...\n`);
|
|
270
|
-
throw new Error(`Failed to parse
|
|
285
|
+
throw new Error(`Failed to parse tickets: ${error instanceof Error ? error.message : String(error)}`);
|
|
271
286
|
}
|
|
272
287
|
}
|
|
273
288
|
/**
|
|
274
|
-
* Write tickets to file
|
|
289
|
+
* Write tickets to output file
|
|
275
290
|
*/
|
|
276
291
|
function writeTicketsToFile(outputPath, tickets) {
|
|
277
292
|
const outputData = {
|
|
@@ -282,60 +297,11 @@ function writeTicketsToFile(outputPath, tickets) {
|
|
|
282
297
|
writeFileSync(outputPath, JSON.stringify(outputData, null, 2), 'utf-8');
|
|
283
298
|
}
|
|
284
299
|
/**
|
|
285
|
-
*
|
|
286
|
-
*/
|
|
287
|
-
async function generatePhaseTickets(phase, ticketType, requirementsContent, projectPath, outputPath, existingTickets) {
|
|
288
|
-
const phaseEmoji = {
|
|
289
|
-
schema: '๐๏ธ',
|
|
290
|
-
backend: 'โ๏ธ',
|
|
291
|
-
frontend: '๐จ',
|
|
292
|
-
};
|
|
293
|
-
const typeEmoji = {
|
|
294
|
-
scaffold: '๐๏ธ',
|
|
295
|
-
logic: '๐ก',
|
|
296
|
-
};
|
|
297
|
-
const phaseName = {
|
|
298
|
-
schema: 'Schema',
|
|
299
|
-
backend: 'Backend',
|
|
300
|
-
frontend: 'Frontend',
|
|
301
|
-
};
|
|
302
|
-
const typeName = {
|
|
303
|
-
scaffold: 'Scaffold',
|
|
304
|
-
logic: 'Logic',
|
|
305
|
-
};
|
|
306
|
-
console.log(`\n${'='.repeat(60)}`);
|
|
307
|
-
console.log(`${phaseEmoji[phase]} ${typeEmoji[ticketType]} ${phaseName[phase]} ${typeName[ticketType]} Tickets`);
|
|
308
|
-
console.log(`${'='.repeat(60)}\n`);
|
|
309
|
-
const systemPrompt = buildTicketGenerationPrompt(phase, ticketType, requirementsContent, projectPath);
|
|
310
|
-
const agentResult = await runAgent(`Generate ${phaseName[phase]} ${typeName[ticketType]} tickets from the requirements.`, {
|
|
311
|
-
systemPrompt,
|
|
312
|
-
cwd: projectPath,
|
|
313
|
-
maxTurns: 25,
|
|
314
|
-
verbosity: 'normal',
|
|
315
|
-
captureConversation: true,
|
|
316
|
-
});
|
|
317
|
-
// Parse tickets from response
|
|
318
|
-
const tickets = parseTicketsFromResponse(agentResult.response, phase, ticketType);
|
|
319
|
-
console.log(`\nโ
Generated ${tickets.length} ${phaseName[phase]} ${typeName[ticketType]} ticket${tickets.length === 1 ? '' : 's'}`);
|
|
320
|
-
tickets.forEach((ticket) => {
|
|
321
|
-
console.log(` ${phaseEmoji[phase]} ${ticket.id}: ${ticket.title} (Effort: ${ticket.estimatedEffort}/10${ticket.category ? `, Category: ${ticket.category}` : ''})`);
|
|
322
|
-
});
|
|
323
|
-
// Write tickets incrementally after each phase
|
|
324
|
-
const allTickets = [...existingTickets, ...tickets];
|
|
325
|
-
writeTicketsToFile(outputPath, allTickets);
|
|
326
|
-
console.log(` ๐พ Progress saved to: ${outputPath}\n`);
|
|
327
|
-
return {
|
|
328
|
-
tickets,
|
|
329
|
-
tokensUsed: agentResult.tokensUsed,
|
|
330
|
-
cost: agentResult.cost,
|
|
331
|
-
conversationMessages: agentResult.conversationMessages || [],
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Core tickets logic
|
|
300
|
+
* Core tickets logic - Simplified to single agent call
|
|
336
301
|
*/
|
|
337
302
|
export async function ticketsCore(options) {
|
|
338
|
-
const {
|
|
303
|
+
const { directory, scaffold = false } = options;
|
|
304
|
+
const isScaffoldMode = scaffold;
|
|
339
305
|
// 1. Validate and resolve project directory
|
|
340
306
|
const projectPath = directory ? resolve(directory) : process.cwd();
|
|
341
307
|
if (!existsSync(projectPath)) {
|
|
@@ -347,104 +313,117 @@ export async function ticketsCore(options) {
|
|
|
347
313
|
if (!stats.isDirectory()) {
|
|
348
314
|
throw new Error(`Path is not a directory: ${projectPath}\n` + `Please provide a valid directory path.`);
|
|
349
315
|
}
|
|
350
|
-
console.log(`๐ Using project directory: ${projectPath}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (
|
|
355
|
-
throw new Error(
|
|
356
|
-
|
|
357
|
-
|
|
316
|
+
console.log(`๐ Using project directory: ${projectPath}`);
|
|
317
|
+
console.log(`๐๏ธ Mode: ${isScaffoldMode ? 'Scaffold (template adaptation + business logic)' : 'Logic-only (business features)'}\n`);
|
|
318
|
+
// 2. Get requirements content (from prompt or file)
|
|
319
|
+
let requirementsContent;
|
|
320
|
+
if (options.prompt && options.path) {
|
|
321
|
+
throw new Error('Cannot use both --prompt and --path. Please provide only one:\n' +
|
|
322
|
+
' kosuke tickets --prompt="Add dark mode"\n' +
|
|
323
|
+
' kosuke tickets --path=docs.md');
|
|
358
324
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
325
|
+
if (options.prompt) {
|
|
326
|
+
requirementsContent = options.prompt;
|
|
327
|
+
console.log(`๐ Using inline prompt (${requirementsContent.length} characters)\n`);
|
|
328
|
+
}
|
|
329
|
+
else if (options.path) {
|
|
330
|
+
const requirementsPath = join(projectPath, options.path);
|
|
331
|
+
if (!existsSync(requirementsPath)) {
|
|
332
|
+
throw new Error(`Requirements document not found: ${options.path}\n` +
|
|
333
|
+
`Please provide a valid path using --path=<file>\n` +
|
|
334
|
+
`Example: kosuke tickets --path=requirements.md`);
|
|
335
|
+
}
|
|
336
|
+
requirementsContent = readFileSync(requirementsPath, 'utf-8');
|
|
337
|
+
console.log(`๐ Loaded ${options.path} (${requirementsContent.length} characters)\n`);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
// Default to docs.md if neither prompt nor path provided
|
|
341
|
+
const defaultPath = 'docs.md';
|
|
342
|
+
const requirementsPath = join(projectPath, defaultPath);
|
|
343
|
+
if (!existsSync(requirementsPath)) {
|
|
344
|
+
throw new Error('Requirements not provided. Use either:\n' +
|
|
345
|
+
' --prompt="Your requirements here"\n' +
|
|
346
|
+
' --path=requirements.md\n' +
|
|
347
|
+
' Or create a docs.md file in the project directory');
|
|
348
|
+
}
|
|
349
|
+
requirementsContent = readFileSync(requirementsPath, 'utf-8');
|
|
350
|
+
console.log(`๐ Loaded ${defaultPath} (${requirementsContent.length} characters)\n`);
|
|
351
|
+
}
|
|
352
|
+
// 3. Determine output path
|
|
362
353
|
const outputFilename = options.output || 'tickets.json';
|
|
363
354
|
const outputPath = join(projectPath, outputFilename);
|
|
364
|
-
// 4. Generate tickets in
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
allTickets =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
//
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
totalCacheCreationTokens += frontendLogicResult.tokensUsed.cacheCreation;
|
|
427
|
-
totalCacheReadTokens += frontendLogicResult.tokensUsed.cacheRead;
|
|
428
|
-
totalCost += frontendLogicResult.cost;
|
|
429
|
-
allConversationMessages.push(...frontendLogicResult.conversationMessages);
|
|
430
|
-
// Separate tickets by phase for result
|
|
431
|
-
const schemaTickets = allTickets.filter((t) => t.id.startsWith('SCHEMA-'));
|
|
432
|
-
const backendTickets = allTickets.filter((t) => t.id.startsWith('BACKEND-'));
|
|
433
|
-
const frontendTickets = allTickets.filter((t) => t.id.startsWith('FRONTEND-'));
|
|
355
|
+
// 4. Generate ALL tickets in a single comprehensive agent call
|
|
356
|
+
console.log(`\n${'='.repeat(80)}`);
|
|
357
|
+
console.log('๐ฏ Generating Tickets with Claude Code Agent');
|
|
358
|
+
console.log(`${'='.repeat(80)}\n`);
|
|
359
|
+
const systemPrompt = buildTicketPrompt(requirementsContent, projectPath, isScaffoldMode);
|
|
360
|
+
const agentResult = await runAgent('Generate all tickets from requirements', {
|
|
361
|
+
systemPrompt,
|
|
362
|
+
cwd: projectPath,
|
|
363
|
+
maxTurns: 40, // Give Claude enough turns to explore codebase and generate all tickets
|
|
364
|
+
verbosity: 'normal',
|
|
365
|
+
captureConversation: true,
|
|
366
|
+
});
|
|
367
|
+
// 5. Parse all tickets from single response
|
|
368
|
+
const allTickets = parseAllTickets(agentResult.response);
|
|
369
|
+
// 6. Display tickets by batch (scaffold vs logic based on ID) and by type
|
|
370
|
+
const scaffoldTickets = allTickets.filter((t) => t.id.toUpperCase().startsWith('SCAFFOLD-'));
|
|
371
|
+
const logicTickets = allTickets.filter((t) => t.id.toUpperCase().startsWith('LOGIC-'));
|
|
372
|
+
const testTickets = allTickets.filter((t) => t.type === 'test');
|
|
373
|
+
if (scaffoldTickets.length > 0) {
|
|
374
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
375
|
+
console.log('๐๏ธ SCAFFOLD Tickets (Template Adaptation)');
|
|
376
|
+
console.log(`${'='.repeat(60)}`);
|
|
377
|
+
scaffoldTickets.forEach((ticket) => {
|
|
378
|
+
const emoji = ticket.id.includes('SCHEMA')
|
|
379
|
+
? '๐๏ธ'
|
|
380
|
+
: ticket.id.includes('BACKEND')
|
|
381
|
+
? 'โ๏ธ'
|
|
382
|
+
: ticket.id.includes('FRONTEND')
|
|
383
|
+
? '๐จ'
|
|
384
|
+
: '๐';
|
|
385
|
+
console.log(` ${emoji} ${ticket.id}: ${ticket.title} (Effort: ${ticket.estimatedEffort}/10${ticket.category ? `, Category: ${ticket.category}` : ''})`);
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
if (logicTickets.length > 0) {
|
|
389
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
390
|
+
console.log('๐ก LOGIC Tickets (Business Functionality)');
|
|
391
|
+
console.log(`${'='.repeat(60)}`);
|
|
392
|
+
logicTickets.forEach((ticket) => {
|
|
393
|
+
const emoji = ticket.id.includes('SCHEMA')
|
|
394
|
+
? '๐๏ธ'
|
|
395
|
+
: ticket.id.includes('BACKEND')
|
|
396
|
+
? 'โ๏ธ'
|
|
397
|
+
: '๐จ';
|
|
398
|
+
console.log(` ${emoji} ${ticket.id}: ${ticket.title} (Effort: ${ticket.estimatedEffort}/10${ticket.category ? `, Category: ${ticket.category}` : ''})`);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
if (testTickets.length > 0) {
|
|
402
|
+
console.log(`\n${'='.repeat(60)}`);
|
|
403
|
+
console.log('๐งช TEST Tickets (E2E Validation)');
|
|
404
|
+
console.log(`${'='.repeat(60)}`);
|
|
405
|
+
testTickets.forEach((ticket) => {
|
|
406
|
+
console.log(` ๐ ${ticket.id}: ${ticket.title} (Effort: ${ticket.estimatedEffort}/10)`);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
// 7. Write tickets to file
|
|
410
|
+
writeTicketsToFile(outputPath, allTickets);
|
|
411
|
+
console.log(`\n๐พ Tickets saved to: ${outputPath}`);
|
|
412
|
+
// 8. Separate tickets by phase for compatibility with existing result structure
|
|
413
|
+
const schemaTickets = allTickets.filter((t) => t.type === 'schema');
|
|
414
|
+
const backendTickets = allTickets.filter((t) => t.type === 'backend');
|
|
415
|
+
const frontendTickets = allTickets.filter((t) => t.type === 'frontend');
|
|
416
|
+
// testTickets already declared above for display
|
|
434
417
|
return {
|
|
435
418
|
schemaTickets,
|
|
436
419
|
backendTickets,
|
|
437
420
|
frontendTickets,
|
|
421
|
+
testTickets,
|
|
438
422
|
totalTickets: allTickets.length,
|
|
439
423
|
projectPath,
|
|
440
|
-
tokensUsed:
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
cacheCreation: totalCacheCreationTokens,
|
|
444
|
-
cacheRead: totalCacheReadTokens,
|
|
445
|
-
},
|
|
446
|
-
cost: totalCost,
|
|
447
|
-
conversationMessages: allConversationMessages,
|
|
424
|
+
tokensUsed: agentResult.tokensUsed,
|
|
425
|
+
cost: agentResult.cost,
|
|
426
|
+
conversationMessages: agentResult.conversationMessages || [],
|
|
448
427
|
};
|
|
449
428
|
}
|
|
450
429
|
/**
|
|
@@ -466,30 +445,37 @@ export async function ticketsCommand(options) {
|
|
|
466
445
|
// Track metrics
|
|
467
446
|
logger.trackTokens(logContext, result.tokensUsed);
|
|
468
447
|
logContext.conversationMessages = result.conversationMessages;
|
|
469
|
-
//
|
|
448
|
+
// Get all tickets by batch (scaffold vs logic)
|
|
470
449
|
const scaffoldTickets = [
|
|
471
450
|
...result.schemaTickets,
|
|
472
451
|
...result.backendTickets,
|
|
473
452
|
...result.frontendTickets,
|
|
474
|
-
|
|
453
|
+
...result.testTickets,
|
|
454
|
+
].filter((t) => t.id.toUpperCase().startsWith('SCAFFOLD-'));
|
|
475
455
|
const logicTickets = [
|
|
476
456
|
...result.schemaTickets,
|
|
477
457
|
...result.backendTickets,
|
|
478
458
|
...result.frontendTickets,
|
|
479
|
-
|
|
480
|
-
|
|
459
|
+
...result.testTickets,
|
|
460
|
+
].filter((t) => t.id.toUpperCase().startsWith('LOGIC-'));
|
|
461
|
+
// Display summary
|
|
462
|
+
console.log(`\n${'='.repeat(80)}`);
|
|
481
463
|
console.log('๐ Ticket Generation Summary');
|
|
482
|
-
console.log(`${'='.repeat(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
464
|
+
console.log(`${'='.repeat(80)}`);
|
|
465
|
+
if (scaffoldTickets.length > 0) {
|
|
466
|
+
console.log(`\n๐๏ธ Scaffold Tickets (Template Adaptation): ${scaffoldTickets.length}`);
|
|
467
|
+
console.log(` ๐๏ธ Schema: ${result.schemaTickets.filter((t) => t.id.toUpperCase().startsWith('SCAFFOLD-')).length} (auto-validated)`);
|
|
468
|
+
console.log(` โ๏ธ Backend: ${result.backendTickets.filter((t) => t.id.toUpperCase().startsWith('SCAFFOLD-')).length}`);
|
|
469
|
+
console.log(` ๐จ Frontend: ${result.frontendTickets.filter((t) => t.id.toUpperCase().startsWith('SCAFFOLD-')).length}`);
|
|
470
|
+
console.log(` ๐งช Tests: ${result.testTickets.filter((t) => t.id.toUpperCase().startsWith('SCAFFOLD-')).length}`);
|
|
471
|
+
}
|
|
487
472
|
console.log(`\n๐ก Logic Tickets (Business Functionality): ${logicTickets.length}`);
|
|
488
|
-
console.log(` ๐๏ธ Schema: ${result.schemaTickets.filter((t) => t.
|
|
489
|
-
console.log(` โ๏ธ Backend: ${result.backendTickets.filter((t) => t.
|
|
490
|
-
console.log(` ๐จ Frontend: ${result.frontendTickets.filter((t) => t.
|
|
473
|
+
console.log(` ๐๏ธ Schema: ${result.schemaTickets.filter((t) => t.id.toUpperCase().startsWith('LOGIC-')).length} (auto-validated)`);
|
|
474
|
+
console.log(` โ๏ธ Backend: ${result.backendTickets.filter((t) => t.id.toUpperCase().startsWith('LOGIC-')).length}`);
|
|
475
|
+
console.log(` ๐จ Frontend: ${result.frontendTickets.filter((t) => t.id.toUpperCase().startsWith('LOGIC-')).length}`);
|
|
476
|
+
console.log(` ๐งช Tests: ${result.testTickets.filter((t) => t.id.toUpperCase().startsWith('LOGIC-')).length}`);
|
|
491
477
|
console.log(`\n๐ Total Tickets: ${result.totalTickets}`);
|
|
492
|
-
console.log(`${'='.repeat(
|
|
478
|
+
console.log(`${'='.repeat(80)}\n`);
|
|
493
479
|
// Display cost breakdown
|
|
494
480
|
const costBreakdown = formatCostBreakdown({
|
|
495
481
|
cost: result.cost,
|
|
@@ -499,7 +485,7 @@ export async function ticketsCommand(options) {
|
|
|
499
485
|
filesReferenced: new Set(),
|
|
500
486
|
});
|
|
501
487
|
console.log(`๐ฐ Total Cost: ${costBreakdown}\n`);
|
|
502
|
-
// Final confirmation
|
|
488
|
+
// Final confirmation
|
|
503
489
|
const outputFilename = options.output || 'tickets.json';
|
|
504
490
|
const outputPath = join(result.projectPath, outputFilename);
|
|
505
491
|
console.log(`โ
All tickets saved to: ${outputPath}\n`);
|