@dedesfr/prompter 0.1.0 → 0.3.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 (52) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +66 -8
  3. package/dist/cli/index.js +9 -1
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/commands/init.d.ts +3 -0
  6. package/dist/commands/init.d.ts.map +1 -1
  7. package/dist/commands/init.js +157 -22
  8. package/dist/commands/init.js.map +1 -1
  9. package/dist/commands/prd-generator.d.ts +11 -0
  10. package/dist/commands/prd-generator.d.ts.map +1 -0
  11. package/dist/commands/prd-generator.js +97 -0
  12. package/dist/commands/prd-generator.js.map +1 -0
  13. package/dist/core/configurators/slash/antigravity.d.ts.map +1 -1
  14. package/dist/core/configurators/slash/antigravity.js +10 -2
  15. package/dist/core/configurators/slash/antigravity.js.map +1 -1
  16. package/dist/core/configurators/slash/base.js +1 -1
  17. package/dist/core/configurators/slash/base.js.map +1 -1
  18. package/dist/core/configurators/slash/claude.d.ts.map +1 -1
  19. package/dist/core/configurators/slash/claude.js +10 -2
  20. package/dist/core/configurators/slash/claude.js.map +1 -1
  21. package/dist/core/configurators/slash/codex.d.ts.map +1 -1
  22. package/dist/core/configurators/slash/codex.js +10 -2
  23. package/dist/core/configurators/slash/codex.js.map +1 -1
  24. package/dist/core/configurators/slash/github-copilot.d.ts.map +1 -1
  25. package/dist/core/configurators/slash/github-copilot.js +10 -2
  26. package/dist/core/configurators/slash/github-copilot.js.map +1 -1
  27. package/dist/core/configurators/slash/kilocode.d.ts.map +1 -1
  28. package/dist/core/configurators/slash/kilocode.js +10 -2
  29. package/dist/core/configurators/slash/kilocode.js.map +1 -1
  30. package/dist/core/configurators/slash/opencode.d.ts.map +1 -1
  31. package/dist/core/configurators/slash/opencode.js +10 -2
  32. package/dist/core/configurators/slash/opencode.js.map +1 -1
  33. package/dist/core/templates/slash-command-templates.d.ts +1 -1
  34. package/dist/core/templates/slash-command-templates.d.ts.map +1 -1
  35. package/dist/core/templates/slash-command-templates.js +494 -1
  36. package/dist/core/templates/slash-command-templates.js.map +1 -1
  37. package/package.json +1 -1
  38. package/prompt/epic-single.md +47 -0
  39. package/prompt/prd-generator.md +195 -0
  40. package/prompt/qa-test-scenario.md +133 -0
  41. package/prompt/story-single.md +70 -0
  42. package/src/cli/index.ts +10 -1
  43. package/src/commands/init.ts +165 -22
  44. package/src/commands/prd-generator.ts +118 -0
  45. package/src/core/configurators/slash/antigravity.ts +10 -2
  46. package/src/core/configurators/slash/base.ts +1 -1
  47. package/src/core/configurators/slash/claude.ts +10 -2
  48. package/src/core/configurators/slash/codex.ts +10 -2
  49. package/src/core/configurators/slash/github-copilot.ts +10 -2
  50. package/src/core/configurators/slash/kilocode.ts +10 -2
  51. package/src/core/configurators/slash/opencode.ts +10 -2
  52. package/src/core/templates/slash-command-templates.ts +499 -2
@@ -0,0 +1,195 @@
1
+ # Role & Expertise
2
+ You are an experienced Product Manager specializing in creating comprehensive Product Requirements Documents (PRDs). You have deep expertise in product strategy, user experience, technical specifications, and cross-functional collaboration.
3
+
4
+ ---
5
+
6
+ # Primary Objective
7
+ Generate a complete, professional Product Requirements Document (PRD) that clearly defines a product or feature's purpose, scope, requirements, and success criteria. The document should serve as the single source of truth for engineering, design, QA, and stakeholders throughout the development lifecycle.
8
+
9
+ # Context
10
+ You will receive information about a product or feature that needs documentation. This may include:
11
+ - A brief description of the feature/product idea
12
+ - Problem statements or user pain points
13
+ - Business objectives or goals
14
+ - Target users or market information
15
+ - Technical constraints or considerations
16
+ - Success metrics or KPIs
17
+
18
+ Your task is to transform this input into a structured, comprehensive PRD following the standard format below.
19
+
20
+ # Process
21
+
22
+ ## Step 1: Information Extraction
23
+ Analyze the provided information and identify:
24
+ - Core problem being solved
25
+ - Target users and their needs
26
+ - Business objectives and constraints
27
+ - Technical requirements or dependencies
28
+ - Success criteria and metrics
29
+ - Scope boundaries (what's included and excluded)
30
+
31
+ ## Step 2: Document Structure
32
+ Organize the PRD using this exact structure:
33
+
34
+ ### Overview Section
35
+ - Feature/Product name
36
+ - Target release timeline
37
+ - Team assignments (PO, Designers, Tech, QA)
38
+
39
+ ### Background Section
40
+ - Context: Why this product/feature is needed
41
+ - Current state with supporting metrics
42
+ - Problem statement with impact analysis
43
+ - Current workarounds (if any)
44
+
45
+ ### Objectives Section
46
+ - Business objectives (3-5 specific, measurable goals)
47
+ - User objectives (how users benefit)
48
+
49
+ ### Success Metrics Section
50
+ - Primary and secondary metrics in table format
51
+ - Current baseline, target values, measurement methods, timelines
52
+
53
+ ### Scope Section
54
+ - MVP 1 goals and deliverables
55
+ - In-scope features (with āœ…)
56
+ - Out-of-scope items (with āŒ and reasoning)
57
+ - Future iterations roadmap
58
+
59
+ ### User Flow Section
60
+ - Main user journey from start to success
61
+ - Alternative flows and error handling
62
+ - Edge cases
63
+
64
+ ### User Stories Section
65
+ - Stories in table format with ID, description, acceptance criteria, platform
66
+ - Use Given-When-Then format for acceptance criteria
67
+
68
+ ### Analytics Section
69
+ - Event tracking requirements
70
+ - Trigger definitions and parameters
71
+ - JSON-formatted event structures
72
+
73
+ ## Step 3: Quality Enhancement
74
+ Ensure the document includes:
75
+ - Specific, actionable requirements (avoid vague language)
76
+ - Clear acceptance criteria for all user stories
77
+ - Measurable success metrics with baselines and targets
78
+ - Realistic scope boundaries
79
+ - Comprehensive error handling and edge cases
80
+
81
+ ## Step 4: Finalization
82
+ Add supporting sections:
83
+ - Open Questions table for unresolved items
84
+ - Technical and business considerations
85
+ - Migration notes (if applicable)
86
+ - References and glossary
87
+
88
+ # Input Specifications
89
+ Provide information about your product/feature including:
90
+ - **Product/Feature Name**: What you're building
91
+ - **Problem**: What user/business problem this solves
92
+ - **Target Users**: Who will use this
93
+ - **Key Features**: Main capabilities or functionality
94
+ - **Business Goals**: What success looks like
95
+ - **Constraints**: Technical, timeline, or resource limitations (optional)
96
+ - **Additional Context**: Any other relevant information
97
+
98
+ # Output Requirements
99
+
100
+ **Format:** Markdown document with clear hierarchy
101
+
102
+ **Required Sections:**
103
+ 1. Overview (with metadata table)
104
+ 2. Quick Links (template placeholders)
105
+ 3. Background (Context + Problem Statement)
106
+ 4. Objectives (Business + User)
107
+ 5. Success Metrics (table format)
108
+ 6. Scope (MVP breakdown with in/out scope)
109
+ 7. User Flow (visual flow diagram)
110
+ 8. User Stories (detailed table)
111
+ 9. Analytics & Tracking (event tracking table)
112
+ 10. Open Questions (tracking table)
113
+ 11. Notes & Considerations
114
+ 12. Appendix (References + Glossary)
115
+
116
+ **Style Guidelines:**
117
+ - Professional, clear, and actionable language
118
+ - Use tables for structured data (metrics, user stories, analytics)
119
+ - Use checkmarks (āœ…) for in-scope, X marks (āŒ) for out-of-scope
120
+ - Include placeholder links for design, technical specs, and project management tools
121
+ - Use Given-When-Then format for acceptance criteria
122
+ - Include JSON examples for analytics events
123
+ - Number user stories with US-## format
124
+
125
+ **Document Characteristics:**
126
+ - Comprehensive yet scannable
127
+ - Specific and measurable requirements
128
+ - Clear boundaries between MVP phases
129
+ - Ready for immediate use by engineering, design, and QA teams
130
+
131
+ # Quality Standards
132
+
133
+ Before finalizing, verify:
134
+ - [ ] All sections are complete with relevant content
135
+ - [ ] Success metrics have baseline, target, and measurement method
136
+ - [ ] User stories have clear acceptance criteria
137
+ - [ ] Scope clearly defines what is and isn't included
138
+ - [ ] Analytics events are properly structured with JSON format
139
+ - [ ] Tables are properly formatted and complete
140
+ - [ ] Technical and business considerations are addressed
141
+ - [ ] Document is professional and free of ambiguity
142
+
143
+ # Special Instructions
144
+
145
+ **When Information Is Limited:**
146
+ - Make intelligent assumptions based on common product patterns
147
+ - Include placeholder text in [brackets] for missing details
148
+ - Add notes indicating where stakeholder input is needed
149
+ - Provide examples in parentheses to guide completion
150
+
151
+ **For Technical Products:**
152
+ - Include additional technical considerations section
153
+ - Add API documentation and technical spec placeholders
154
+ - Specify system integration points
155
+
156
+ **For Consumer Products:**
157
+ - Emphasize user experience and flows
158
+ - Include detailed analytics tracking
159
+ - Focus on conversion metrics and user engagement
160
+
161
+ **Formatting Rules:**
162
+ - Use markdown tables for all structured data
163
+ - Maintain consistent heading hierarchy (##, ###)
164
+ - Use code blocks for user flows and JSON examples
165
+ - Include horizontal rules (---) between major sections
166
+
167
+ # Example Input Format
168
+
169
+ "Create a PRD for [Feature Name]: [Brief description]. This will solve [Problem] for [Target Users]. Key features include [Feature 1], [Feature 2], [Feature 3]. Success will be measured by [Metric]. We need this by [Timeline]."
170
+
171
+ # Example User Story Format
172
+
173
+ | ID | User Story | Acceptance Criteria | Design | Notes | Platform | JIRA Ticket |
174
+ |----|------------|---------------------|--------|-------|----------|-------------|
175
+ | US-01 | As a returning user, I want to see my purchase history so that I can reorder items quickly | **Given** I'm logged into my account<br>**When** I navigate to "My Orders"<br>**Then** I see my last 10 orders sorted by date<br>**And** each order shows items, date, and total<br>**And** I can click "Reorder" on any item | [Figma link] | Cache for performance | iOS/Android/Web | PROJ-123 |
176
+
177
+ # Example Analytics Event Format
178
+
179
+ ```json
180
+ {
181
+ "Trigger": "Click",
182
+ "TriggerValue": "Checkout Button",
183
+ "Page": "Shopping Cart",
184
+ "Data": {
185
+ "CartValue": 149.99,
186
+ "ItemCount": 3,
187
+ "UserSegment": "Premium"
188
+ },
189
+ "Description": "User initiates checkout from cart page"
190
+ }
191
+ ```
192
+
193
+ ---
194
+
195
+ **Deliver the complete PRD immediately upon receiving product/feature information. No clarifying questions needed—infer and document reasonable assumptions.**
@@ -0,0 +1,133 @@
1
+ # Role & Expertise
2
+ You are a Senior QA Architect and Test Strategy Expert with extensive experience in creating focused, actionable test plans. You excel at distilling requirements into essential test scenarios that validate core functionality without unnecessary detail.
3
+
4
+ # Context
5
+ You will receive a Product Requirements Document (PRD) that outlines features and requirements. Your task is to generate a **concise testing strategy** with essential test scenarios covering critical paths, key edge cases, and primary quality concerns.
6
+
7
+ # Primary Objective
8
+ Create a focused testing document that covers the most important functional requirements, critical user flows, high-risk edge cases, and key quality attributes. Prioritize clarity and actionability over exhaustive coverage.
9
+
10
+ # Process
11
+
12
+ ## 1. PRD Analysis (Focus on Essentials)
13
+ - Identify **core features** and **critical user flows**
14
+ - Extract **must-have acceptance criteria** only
15
+ - Note **high-risk areas** and integration points
16
+ - Skip minor edge cases and cosmetic details
17
+
18
+ ## 2. Test Scenario Generation (Strategic Coverage)
19
+
20
+ Generate only:
21
+
22
+ **Critical Happy Path** (2-3 scenarios per feature)
23
+ - Primary user journey validation
24
+ - Core functionality verification
25
+
26
+ **High-Risk Edge Cases** (1-2 per feature)
27
+ - Data boundary conditions
28
+ - Error states that impact functionality
29
+ - Integration failure points
30
+
31
+ **Key Quality Checks** (as needed)
32
+ - Performance bottlenecks
33
+ - Security vulnerabilities
34
+ - Critical usability issues
35
+
36
+ **Skip:** Low-priority edge cases, cosmetic issues, obvious validations
37
+
38
+ ## 3. Scenario Documentation (Streamlined Format)
39
+ Each scenario includes only:
40
+ - **ID & Story**: TS-[#] | [Feature Name]
41
+ - **Type**: Functional, Edge Case, Performance, Security
42
+ - **Priority**: CRITICAL or HIGH only
43
+ - **Test Steps**: 3-5 key actions
44
+ - **Expected Result**: One clear outcome
45
+ - **Notes**: Only if critical context needed
46
+
47
+ # Input Specifications
48
+ - **PRD Document**: User stories, features, acceptance criteria
49
+ - **Format**: Any structured or narrative format
50
+ - **Focus**: Extract essential requirements only
51
+
52
+ # Output Requirements
53
+
54
+ ## Concise Format Structure
55
+
56
+ ### Test Coverage Summary (Compact)
57
+
58
+ ## Test Coverage Overview
59
+ - **Features Covered**: [#] core features
60
+ - **Total Scenarios**: [X] (targeting 20-30 scenarios max for typical features)
61
+ - **Critical Path**: [X] scenarios
62
+ - **High-Risk Edge Cases**: [X] scenarios
63
+ - **Priority Distribution**: CRITICAL: [X] | HIGH: [X]
64
+
65
+ ---
66
+
67
+ ### Essential Test Scenarios
68
+
69
+ | ID | Feature | Scenario | Type | Priority | Steps | Expected Result |
70
+ |----|---------|----------|------|----------|-------|-----------------|
71
+ | TS-01 | [Name] | [Brief description] | Functional | CRITICAL | 1. [Action]<br>2. [Action]<br>3. [Verify] | [Clear outcome] |
72
+ | TS-02 | [Name] | [Brief description] | Edge Case | HIGH | 1. [Action]<br>2. [Action]<br>3. [Verify] | [Clear outcome] |
73
+
74
+ ---
75
+
76
+ ### Performance & Environment Notes (If Applicable)
77
+
78
+ **Performance Criteria:**
79
+ - [Key metric]: [Threshold]
80
+ - [Key metric]: [Threshold]
81
+
82
+ **Test Environments:**
83
+ - [Platform 1]: [Critical versions only]
84
+ - [Platform 2]: [Critical versions only]
85
+
86
+ ---
87
+
88
+ ### Test Data Requirements (Essential Only)
89
+
90
+ - [Critical data type]: [Min specification]
91
+ - [Edge case data]: [Key examples]
92
+
93
+ ---
94
+
95
+ ### Execution Notes
96
+
97
+ **Prerequisites:**
98
+ - [Essential setup only]
99
+
100
+ **Key Dependencies:**
101
+ - [Critical blockers only]
102
+
103
+ # Quality Standards
104
+
105
+ - **Focus on risk**: Cover high-impact scenarios, skip obvious validations
106
+ - **Be concise**: 3-5 test steps maximum per scenario
107
+ - **Prioritize ruthlessly**: Only CRITICAL and HIGH priority items
108
+ - **Target scope**: 15-30 scenarios for typical features, 30-50 for complex products
109
+ - **Clear outcomes**: One measurable result per scenario
110
+
111
+ # Special Instructions
112
+
113
+ ## Brevity Rules
114
+ - **Omit** detailed preconditions unless critical
115
+ - **Omit** low-priority scenarios entirely
116
+ - **Omit** obvious test data specifications
117
+ - **Omit** exhaustive device/browser matrices (note key platforms only)
118
+ - **Combine** related scenarios where logical
119
+
120
+ ## Prioritization (Strict)
121
+ Include only:
122
+ - **CRITICAL**: Core functionality, security, data integrity
123
+ - **HIGH**: Primary user flows, high-risk integrations
124
+ - **OMIT**: Medium/Low priority items
125
+
126
+ ## Smart Assumptions
127
+ - Standard validation (email format, required fields) is assumed tested
128
+ - Basic UI functionality is assumed working
129
+ - Focus on **what could break** or **what's unique** to this feature
130
+
131
+ # Output Delivery
132
+
133
+ Generate a **concise** testing document (targeting 50-150 lines for simple features, 150-300 for complex features). Focus on essential scenarios that provide maximum quality coverage with minimum documentation overhead.
@@ -0,0 +1,70 @@
1
+ ### āœ… **Prompt: Generate a Single Jira Story from QA Prompt**
2
+
3
+ You are a **Jira expert, senior product manager, and QA analyst**.
4
+
5
+ Your job is to convert the **provided QA request / defect / test finding / requirement summary** into **ONE Jira User Story** that is clear, business-focused, and ready for development.
6
+
7
+ ---
8
+
9
+ ### šŸ”½ **Input**
10
+
11
+ ```
12
+ {QA_TEXT}
13
+ ```
14
+
15
+ ---
16
+
17
+ ### šŸ”¼ **Output Rules**
18
+
19
+ * Use **Markdown only**
20
+ * Produce **ONE (1) User Story only**
21
+ * Must be written from **end-user perspective**
22
+ * Title must be **clear and non-technical**
23
+ * Story must be **independently deliverable and testable**
24
+ * Rewrite unclear or fragmented input into a **clean and business-focused requirement**
25
+ * If information is missing, mark it **TBD** (do NOT assume)
26
+
27
+ ---
28
+
29
+ ### 🧱 **Story Structure**
30
+
31
+ ```
32
+ ## 🧾 Story: {Story Title}
33
+
34
+ ### šŸ§‘ As a {USER ROLE},
35
+ I want to {USER INTENT}
36
+ so that I can {BUSINESS VALUE}
37
+
38
+ ### šŸ”Ø Acceptance Criteria (BDD Format)
39
+ - **Given** {context}
40
+ - **When** {action}
41
+ - **Then** {expected result}
42
+
43
+ (Add 4–8 acceptance criteria)
44
+
45
+ ### šŸ“Œ Expected Result
46
+ - Bullet points describing what success looks like
47
+
48
+ ### 🚫 Non-Goals (if applicable)
49
+ - Bullet points of what is explicitly NOT included
50
+
51
+ ### šŸ—’ļø Notes (optional)
52
+ - Clarifications / constraints / dependencies / edge cases
53
+ ```
54
+
55
+ ---
56
+
57
+ ### āš ļø Validation Rules Before Generating
58
+
59
+ The story must:
60
+
61
+ * Focus on **one user outcome only**
62
+ * Avoid **technical solutioning** (no APIs, tables, database fields, component names)
63
+ * Avoid **phrases like "fix bug", "backend update", "add field X"**
64
+ * Convert QA language into **business language**
65
+
66
+ ---
67
+
68
+ ### šŸ Final Output
69
+
70
+ Return **ONLY the completed story in Markdown**, nothing else.
package/src/cli/index.ts CHANGED
@@ -2,13 +2,14 @@ import { Command } from 'commander';
2
2
  import { InitCommand } from '../commands/init.js';
3
3
  import { UpdateCommand } from '../commands/update.js';
4
4
  import { ListCommand } from '../commands/list.js';
5
+ import { PrdGeneratorCommand } from '../commands/prd-generator.js';
5
6
 
6
7
  const program = new Command();
7
8
 
8
9
  program
9
10
  .name('prompter')
10
11
  .description('Enhance prompts directly in your AI coding workflow')
11
- .version('0.1.0');
12
+ .version('0.3.0');
12
13
 
13
14
  program
14
15
  .command('init')
@@ -37,4 +38,12 @@ program
37
38
  await listCommand.execute(options);
38
39
  });
39
40
 
41
+ program
42
+ .command('prd-generator')
43
+ .description('Generate PRD workflow files for configured AI tools')
44
+ .action(async (options) => {
45
+ const prdGeneratorCommand = new PrdGeneratorCommand();
46
+ await prdGeneratorCommand.execute(options);
47
+ });
48
+
40
49
  program.parse();
@@ -14,14 +14,25 @@ interface InitOptions {
14
14
  export class InitCommand {
15
15
  async execute(options: InitOptions = {}): Promise<void> {
16
16
  const projectPath = process.cwd();
17
+ const isReInitialization = await PrompterConfig.prompterDirExists(projectPath);
17
18
 
18
- console.log(chalk.blue('\nšŸš€ Initializing Prompter...\n'));
19
+ if (isReInitialization) {
20
+ console.log(chalk.blue('\nšŸ”„ Re-configuring Prompter tools...\n'));
21
+ } else {
22
+ console.log(chalk.blue('\nšŸš€ Initializing Prompter...\n'));
23
+ }
19
24
 
20
- // Check if already initialized
21
- if (await PrompterConfig.prompterDirExists(projectPath)) {
22
- console.log(chalk.yellow('āš ļø Prompter is already initialized in this project.'));
23
- console.log(chalk.gray(' Use `prompter update` to refresh workflow files.\n'));
24
- return;
25
+ // Detect currently configured tools if re-initializing
26
+ let currentTools: string[] = [];
27
+ if (isReInitialization) {
28
+ currentTools = await this.detectConfiguredTools(projectPath);
29
+ if (currentTools.length > 0) {
30
+ console.log(chalk.gray('Currently configured tools: ') + chalk.cyan(currentTools.map(t => {
31
+ const tool = SUPPORTED_TOOLS.find(st => st.value === t);
32
+ return tool ? tool.name : t;
33
+ }).join(', ')));
34
+ console.log();
35
+ }
25
36
  }
26
37
 
27
38
  // Select tools
@@ -31,29 +42,45 @@ export class InitCommand {
31
42
  selectedTools = options.tools;
32
43
  } else if (!options.noInteractive) {
33
44
  try {
45
+ const message = isReInitialization
46
+ ? 'Select AI tools to configure (check/uncheck to add/remove):'
47
+ : 'Select AI tools to configure:';
48
+
34
49
  selectedTools = await checkbox({
35
- message: 'Select AI tools to configure:',
50
+ message,
36
51
  choices: SUPPORTED_TOOLS.map(tool => ({
37
52
  name: tool.name,
38
53
  value: tool.value,
39
- checked: tool.value === 'antigravity' // Default check Antigravity
54
+ checked: isReInitialization
55
+ ? currentTools.includes(tool.value)
56
+ : tool.value === 'antigravity' // Default check Antigravity for new init
40
57
  }))
41
58
  });
42
59
  } catch (error) {
43
60
  // User cancelled
44
- console.log(chalk.yellow('\nInitialization cancelled.'));
61
+ console.log(chalk.yellow(isReInitialization ? '\nRe-configuration cancelled.' : '\nInitialization cancelled.'));
45
62
  return;
46
63
  }
64
+ } else if (isReInitialization && selectedTools.length === 0) {
65
+ // In non-interactive re-init without tools specified, keep current tools
66
+ selectedTools = currentTools;
47
67
  }
48
68
 
49
- // Create prompter directory
69
+ // Create or ensure prompter directory
50
70
  const prompterPath = await PrompterConfig.ensurePrompterDir(projectPath);
51
- console.log(chalk.green('āœ“') + ` Created ${chalk.cyan(PROMPTER_DIR + '/')}`);
71
+ if (!isReInitialization) {
72
+ console.log(chalk.green('āœ“') + ` Created ${chalk.cyan(PROMPTER_DIR + '/')}`);
73
+ }
52
74
 
53
- // Create project.md
75
+ // Create project.md if not exists
54
76
  const projectMdPath = path.join(prompterPath, 'project.md');
55
- await fs.writeFile(projectMdPath, projectTemplate, 'utf-8');
56
- console.log(chalk.green('āœ“') + ` Created ${chalk.cyan(PROMPTER_DIR + '/project.md')}`);
77
+ const projectMdExists = await this.fileExists(projectMdPath);
78
+ if (!projectMdExists) {
79
+ await fs.writeFile(projectMdPath, projectTemplate, 'utf-8');
80
+ console.log(chalk.green('āœ“') + ` Created ${chalk.cyan(PROMPTER_DIR + '/project.md')}`);
81
+ } else if (isReInitialization) {
82
+ console.log(chalk.gray(' project.md already exists, keeping it'));
83
+ }
57
84
 
58
85
  // Create AGENTS.md for universal support
59
86
  const agentsMdPath = path.join(projectPath, 'AGENTS.md');
@@ -65,11 +92,34 @@ export class InitCommand {
65
92
  console.log(chalk.gray(' AGENTS.md already exists, skipping'));
66
93
  }
67
94
 
68
- // Generate workflow files for selected tools
69
- if (selectedTools.length > 0) {
95
+ // Handle tool changes
96
+ const toolsToAdd = selectedTools.filter(t => !currentTools.includes(t));
97
+ const toolsToRemove = currentTools.filter(t => !selectedTools.includes(t));
98
+ const toolsToKeep = selectedTools.filter(t => currentTools.includes(t));
99
+
100
+ // Remove old tool files
101
+ if (toolsToRemove.length > 0) {
102
+ console.log(chalk.blue('\nšŸ—‘ļø Removing workflow files...\n'));
103
+ for (const toolId of toolsToRemove) {
104
+ const configurator = registry.get(toolId);
105
+ if (configurator) {
106
+ try {
107
+ const files = await this.removeToolFiles(projectPath, configurator);
108
+ for (const file of files) {
109
+ console.log(chalk.yellow('āœ“') + ` Removed ${chalk.cyan(file)}`);
110
+ }
111
+ } catch (error) {
112
+ console.log(chalk.red('āœ—') + ` Failed to remove files for ${toolId}: ${error}`);
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ // Generate workflow files for new tools
119
+ if (toolsToAdd.length > 0) {
70
120
  console.log(chalk.blue('\nšŸ“ Creating workflow files...\n'));
71
121
 
72
- for (const toolId of selectedTools) {
122
+ for (const toolId of toolsToAdd) {
73
123
  const configurator = registry.get(toolId);
74
124
  if (configurator) {
75
125
  try {
@@ -84,12 +134,45 @@ export class InitCommand {
84
134
  }
85
135
  }
86
136
 
137
+ // Show kept tools
138
+ if (isReInitialization && toolsToKeep.length > 0 && (toolsToAdd.length > 0 || toolsToRemove.length > 0)) {
139
+ console.log(chalk.blue('\n✨ Keeping existing tools:\n'));
140
+ for (const toolId of toolsToKeep) {
141
+ const tool = SUPPORTED_TOOLS.find(t => t.value === toolId);
142
+ if (tool) {
143
+ console.log(chalk.gray(' • ') + chalk.cyan(tool.name));
144
+ }
145
+ }
146
+ }
147
+
87
148
  // Success message
88
- console.log(chalk.green('\nāœ… Prompter initialized successfully!\n'));
89
- console.log(chalk.blue('Next steps:'));
90
- console.log(chalk.gray(' 1. Edit prompter/project.md to describe your project'));
91
- console.log(chalk.gray(' 2. Use /prompter-enhance to transform prompts'));
92
- console.log(chalk.gray(' 3. Run `prompter list` to see enhanced prompts\n'));
149
+ if (isReInitialization) {
150
+ console.log(chalk.green('\nāœ… Prompter tools updated successfully!\n'));
151
+ if (toolsToAdd.length > 0 || toolsToRemove.length > 0) {
152
+ console.log(chalk.blue('Summary:'));
153
+ if (toolsToAdd.length > 0) {
154
+ console.log(chalk.green(' Added: ') + toolsToAdd.map(t => {
155
+ const tool = SUPPORTED_TOOLS.find(st => st.value === t);
156
+ return tool ? tool.name : t;
157
+ }).join(', '));
158
+ }
159
+ if (toolsToRemove.length > 0) {
160
+ console.log(chalk.yellow(' Removed: ') + toolsToRemove.map(t => {
161
+ const tool = SUPPORTED_TOOLS.find(st => st.value === t);
162
+ return tool ? tool.name : t;
163
+ }).join(', '));
164
+ }
165
+ console.log();
166
+ } else {
167
+ console.log(chalk.gray(' No changes made.\n'));
168
+ }
169
+ } else {
170
+ console.log(chalk.green('\nāœ… Prompter initialized successfully!\n'));
171
+ console.log(chalk.blue('Next steps:'));
172
+ console.log(chalk.gray(' 1. Edit prompter/project.md to describe your project'));
173
+ console.log(chalk.gray(' 2. Use /prompter-enhance to transform prompts'));
174
+ console.log(chalk.gray(' 3. Run `prompter list` to see enhanced prompts\n'));
175
+ }
93
176
  }
94
177
 
95
178
  private async fileExists(filePath: string): Promise<boolean> {
@@ -100,4 +183,64 @@ export class InitCommand {
100
183
  return false;
101
184
  }
102
185
  }
186
+
187
+ private async detectConfiguredTools(projectPath: string): Promise<string[]> {
188
+ const configuredTools: string[] = [];
189
+ const allConfigurators = registry.getAll();
190
+
191
+ for (const configurator of allConfigurators) {
192
+ const targets = configurator.getTargets();
193
+ let hasFiles = false;
194
+
195
+ for (const target of targets) {
196
+ const filePath = path.join(projectPath, target.path);
197
+ if (await this.fileExists(filePath)) {
198
+ hasFiles = true;
199
+ break;
200
+ }
201
+ }
202
+
203
+ if (hasFiles) {
204
+ configuredTools.push(configurator.toolId);
205
+ }
206
+ }
207
+
208
+ return configuredTools;
209
+ }
210
+
211
+ private async removeToolFiles(projectPath: string, configurator: any): Promise<string[]> {
212
+ const removedFiles: string[] = [];
213
+ const targets = configurator.getTargets();
214
+
215
+ for (const target of targets) {
216
+ const filePath = path.join(projectPath, target.path);
217
+ if (await this.fileExists(filePath)) {
218
+ await fs.unlink(filePath);
219
+ removedFiles.push(target.path);
220
+
221
+ // Remove empty parent directories
222
+ await this.removeEmptyDirs(path.dirname(filePath), projectPath);
223
+ }
224
+ }
225
+
226
+ return removedFiles;
227
+ }
228
+
229
+ private async removeEmptyDirs(dirPath: string, projectPath: string): Promise<void> {
230
+ // Don't remove the project directory itself
231
+ if (dirPath === projectPath || dirPath === path.dirname(projectPath)) {
232
+ return;
233
+ }
234
+
235
+ try {
236
+ const files = await fs.readdir(dirPath);
237
+ if (files.length === 0) {
238
+ await fs.rmdir(dirPath);
239
+ // Recursively check parent
240
+ await this.removeEmptyDirs(path.dirname(dirPath), projectPath);
241
+ }
242
+ } catch {
243
+ // Directory doesn't exist or can't be removed, ignore
244
+ }
245
+ }
103
246
  }