sapper-iq 1.0.6 ā 1.0.7
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/package.json +1 -1
- package/sapper.mjs +246 -2
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -93,6 +93,241 @@ function recreateReadline() {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// Specialized prompt profiles for different tasks
|
|
97
|
+
const PROMPT_PROFILES = {
|
|
98
|
+
documentation: `
|
|
99
|
+
šÆ DOCUMENTATION MODE ACTIVATED
|
|
100
|
+
Write comprehensive technical documentation. Execute tools to analyze codebase first.
|
|
101
|
+
|
|
102
|
+
Documentation Types & Formats:
|
|
103
|
+
|
|
104
|
+
**Use Cases:**
|
|
105
|
+
Title: [Action User Wants to Perform]
|
|
106
|
+
- Actor: [Who performs the action]
|
|
107
|
+
- Preconditions: [What must be true before]
|
|
108
|
+
- Main Flow:
|
|
109
|
+
1. User does X
|
|
110
|
+
2. System responds with Y
|
|
111
|
+
3. User confirms Z
|
|
112
|
+
- Postconditions: [Result after completion]
|
|
113
|
+
- Alternative Flows: [Error cases, edge cases]
|
|
114
|
+
|
|
115
|
+
**User Stories:**
|
|
116
|
+
"As a [role], I want [feature] so that [benefit]"
|
|
117
|
+
- Acceptance Criteria:
|
|
118
|
+
- Given [context]
|
|
119
|
+
- When [action]
|
|
120
|
+
- Then [result]
|
|
121
|
+
|
|
122
|
+
**BRD (Business Requirements Document):**
|
|
123
|
+
## Background
|
|
124
|
+
## Problem Statement
|
|
125
|
+
## Objectives
|
|
126
|
+
## Functional Requirements (numbered list)
|
|
127
|
+
## Non-Functional Requirements (performance, security, scalability)
|
|
128
|
+
## Success Metrics
|
|
129
|
+
## Timeline & Milestones
|
|
130
|
+
|
|
131
|
+
**Technical Documentation:**
|
|
132
|
+
- API endpoints with request/response examples
|
|
133
|
+
- Architecture diagrams (use mermaid)
|
|
134
|
+
- Setup instructions
|
|
135
|
+
- Environment variables
|
|
136
|
+
|
|
137
|
+
Execute [TOOL:LIST] and [TOOL:READ] to understand project before documenting.`,
|
|
138
|
+
|
|
139
|
+
backend: `
|
|
140
|
+
šÆ BACKEND MODE ACTIVATED - Node.js Specialist
|
|
141
|
+
Build server-side APIs, business logic, and integrations using Node.js/Express.
|
|
142
|
+
|
|
143
|
+
Tech Stack & Standards:
|
|
144
|
+
- Framework: Express.js or Fastify
|
|
145
|
+
- Runtime: Node.js (ES6+ with async/await)
|
|
146
|
+
- Architecture: MVC, Clean Architecture, or layered approach
|
|
147
|
+
|
|
148
|
+
Implementation Checklist:
|
|
149
|
+
ā RESTful API Design:
|
|
150
|
+
- GET /api/resource (list/read)
|
|
151
|
+
- POST /api/resource (create)
|
|
152
|
+
- PUT /PATCH /api/resource/:id (update)
|
|
153
|
+
- DELETE /api/resource/:id (delete)
|
|
154
|
+
- Return proper status codes: 200, 201, 400, 401, 404, 500
|
|
155
|
+
|
|
156
|
+
ā Request Handling:
|
|
157
|
+
- Use express.json() for body parsing
|
|
158
|
+
- Validate inputs with joi or zod
|
|
159
|
+
- Implement error middleware
|
|
160
|
+
- Add request logging (morgan/winston)
|
|
161
|
+
|
|
162
|
+
ā Security:
|
|
163
|
+
- Use helmet for security headers
|
|
164
|
+
- Implement CORS properly
|
|
165
|
+
- JWT authentication with bcrypt password hashing
|
|
166
|
+
- Rate limiting with express-rate-limit
|
|
167
|
+
- Input sanitization
|
|
168
|
+
|
|
169
|
+
ā Project Structure:
|
|
170
|
+
/src
|
|
171
|
+
/routes - API endpoints
|
|
172
|
+
/controllers - Request handlers
|
|
173
|
+
/services - Business logic
|
|
174
|
+
/models - Data models
|
|
175
|
+
/middleware - Auth, validation, errors
|
|
176
|
+
/config - Environment configs
|
|
177
|
+
/utils - Helper functions
|
|
178
|
+
|
|
179
|
+
ā Best Practices:
|
|
180
|
+
- Use environment variables (.env with dotenv)
|
|
181
|
+
- Implement graceful shutdown
|
|
182
|
+
- Add health check endpoint: GET /health
|
|
183
|
+
- Use async/await with try-catch
|
|
184
|
+
- Create separate router files
|
|
185
|
+
|
|
186
|
+
Execute tools to create Express server structure immediately.`,
|
|
187
|
+
|
|
188
|
+
frontend: `
|
|
189
|
+
šÆ FRONTEND MODE ACTIVATED
|
|
190
|
+
Focus on UI components, styling, and user interactions.
|
|
191
|
+
|
|
192
|
+
Implementation Rules:
|
|
193
|
+
- Component-based architecture (React/Vue/Svelte)
|
|
194
|
+
- Responsive design with mobile-first approach
|
|
195
|
+
- Use Tailwind CSS or styled-components
|
|
196
|
+
- Implement proper state management
|
|
197
|
+
- Add loading states and error boundaries
|
|
198
|
+
- Handle forms with validation
|
|
199
|
+
- Optimize for performance (lazy loading, memoization)
|
|
200
|
+
|
|
201
|
+
Execute tools to create component structure immediately.`,
|
|
202
|
+
|
|
203
|
+
testing: `
|
|
204
|
+
šÆ TESTING MODE ACTIVATED
|
|
205
|
+
Write comprehensive test suites with high coverage.
|
|
206
|
+
|
|
207
|
+
Test Requirements:
|
|
208
|
+
- Unit tests: Test individual functions/components
|
|
209
|
+
- Integration tests: Test feature workflows
|
|
210
|
+
- Use describe/it blocks with clear names
|
|
211
|
+
- Add assertions: expect().toBe(), toEqual(), toHaveBeenCalled()
|
|
212
|
+
- Mock external dependencies
|
|
213
|
+
- Test edge cases and error scenarios
|
|
214
|
+
- Aim for 80%+ coverage
|
|
215
|
+
|
|
216
|
+
Execute tools to create test files immediately.`,
|
|
217
|
+
|
|
218
|
+
database: `
|
|
219
|
+
šÆ DATABASE MODE ACTIVATED - PostgreSQL Specialist
|
|
220
|
+
Design schemas, write migrations, and optimize queries for PostgreSQL.
|
|
221
|
+
|
|
222
|
+
Tech Stack:
|
|
223
|
+
- Database: PostgreSQL 14+
|
|
224
|
+
- ORM Options: Prisma (recommended), Sequelize, or TypeORM
|
|
225
|
+
- Query Builder: Knex.js
|
|
226
|
+
- Migrations: Prisma Migrate or Knex migrations
|
|
227
|
+
|
|
228
|
+
Schema Design Best Practices:
|
|
229
|
+
ā Data Types:
|
|
230
|
+
- Use SERIAL or UUID for primary keys
|
|
231
|
+
- TEXT for variable strings (not VARCHAR)
|
|
232
|
+
- TIMESTAMP WITH TIME ZONE for dates
|
|
233
|
+
- JSONB for flexible data (indexed)
|
|
234
|
+
- ENUM types for fixed choices
|
|
235
|
+
|
|
236
|
+
ā Table Structure:
|
|
237
|
+
CREATE TABLE users (
|
|
238
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
239
|
+
email TEXT UNIQUE NOT NULL,
|
|
240
|
+
password_hash TEXT NOT NULL,
|
|
241
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
242
|
+
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
ā Relationships:
|
|
246
|
+
- Foreign Keys: REFERENCES other_table(id) ON DELETE CASCADE
|
|
247
|
+
- Indexes on FK columns: CREATE INDEX idx_user_id ON posts(user_id)
|
|
248
|
+
- Join tables for many-to-many
|
|
249
|
+
|
|
250
|
+
ā Performance:
|
|
251
|
+
- Add indexes on frequently queried columns
|
|
252
|
+
- Use partial indexes for conditional queries
|
|
253
|
+
- Create composite indexes for multi-column queries
|
|
254
|
+
- Analyze query plans: EXPLAIN ANALYZE
|
|
255
|
+
|
|
256
|
+
ā Migrations Pattern:
|
|
257
|
+
- Up: Create/alter tables and indexes
|
|
258
|
+
- Down: Rollback changes safely
|
|
259
|
+
- Version control all migrations
|
|
260
|
+
- Never edit existing migrations
|
|
261
|
+
|
|
262
|
+
ā Prisma Schema Example:
|
|
263
|
+
model User {
|
|
264
|
+
id String @id @default(uuid())
|
|
265
|
+
email String @unique
|
|
266
|
+
posts Post[]
|
|
267
|
+
createdAt DateTime @default(now())
|
|
268
|
+
updatedAt DateTime @updatedAt
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
ā Connection:
|
|
272
|
+
- Use connection pooling (pg.Pool)
|
|
273
|
+
- Set max connections: 20-50
|
|
274
|
+
- Use prepared statements
|
|
275
|
+
- Handle connection errors gracefully
|
|
276
|
+
|
|
277
|
+
ā Seed Data:
|
|
278
|
+
- Create seed files for development
|
|
279
|
+
- Use transactions for bulk inserts
|
|
280
|
+
- Make seeds idempotent
|
|
281
|
+
|
|
282
|
+
Execute tools to create schema files and migrations immediately.`,
|
|
283
|
+
|
|
284
|
+
devops: `
|
|
285
|
+
šÆ DEVOPS MODE ACTIVATED
|
|
286
|
+
Setup CI/CD, containerization, deployment automation.
|
|
287
|
+
|
|
288
|
+
DevOps Tasks:
|
|
289
|
+
- Write Dockerfile with multi-stage builds
|
|
290
|
+
- Create docker-compose.yml for local dev
|
|
291
|
+
- Setup GitHub Actions or GitLab CI
|
|
292
|
+
- Add environment-specific configs
|
|
293
|
+
- Implement health checks and monitoring
|
|
294
|
+
- Use secrets management
|
|
295
|
+
- Optimize build times
|
|
296
|
+
|
|
297
|
+
Execute tools to create config files immediately.`
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// Auto-detect task profile from user input
|
|
301
|
+
function detectTaskProfile(input) {
|
|
302
|
+
const text = input.toLowerCase();
|
|
303
|
+
|
|
304
|
+
// Documentation keywords
|
|
305
|
+
if (text.match(/\b(document|documentation|readme|brd|prd|user stor(y|ies)|use case|spec|wiki|guide)\b/))
|
|
306
|
+
return 'documentation';
|
|
307
|
+
|
|
308
|
+
// Backend keywords
|
|
309
|
+
if (text.match(/\b(api|endpoint|backend|server|route|controller|middleware|rest|graphql|service)\b/))
|
|
310
|
+
return 'backend';
|
|
311
|
+
|
|
312
|
+
// Frontend keywords
|
|
313
|
+
if (text.match(/\b(ui|frontend|component|page|design|style|css|tailwind|react|vue|svelte|button|form|navbar)\b/))
|
|
314
|
+
return 'frontend';
|
|
315
|
+
|
|
316
|
+
// Testing keywords
|
|
317
|
+
if (text.match(/\b(test|testing|spec|jest|vitest|cypress|unit test|integration|e2e|coverage)\b/))
|
|
318
|
+
return 'testing';
|
|
319
|
+
|
|
320
|
+
// Database keywords
|
|
321
|
+
if (text.match(/\b(database|schema|migration|model|orm|sql|postgres|mysql|mongo|prisma|sequelize)\b/))
|
|
322
|
+
return 'database';
|
|
323
|
+
|
|
324
|
+
// DevOps keywords
|
|
325
|
+
if (text.match(/\b(docker|container|ci\/cd|deploy|pipeline|kubernetes|k8s|helm|terraform|ansible)\b/))
|
|
326
|
+
return 'devops';
|
|
327
|
+
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
|
|
96
331
|
// --- Tool Logic ---
|
|
97
332
|
const tools = {
|
|
98
333
|
read: (path) => {
|
|
@@ -352,16 +587,25 @@ Working directory: ${process.cwd()}`
|
|
|
352
587
|
return ask();
|
|
353
588
|
}
|
|
354
589
|
|
|
590
|
+
// Auto-detect task profile and inject specialized instructions
|
|
591
|
+
const profile = detectTaskProfile(input);
|
|
592
|
+
let contextMsg = input;
|
|
593
|
+
|
|
594
|
+
// Inject profile if detected
|
|
595
|
+
if (profile) {
|
|
596
|
+
console.log(chalk.magenta(`\nšÆ ${profile.toUpperCase()} MODE DETECTED\n`));
|
|
597
|
+
contextMsg = `${input}\n\n${PROMPT_PROFILES[profile]}`;
|
|
598
|
+
}
|
|
599
|
+
|
|
355
600
|
// Check if user mentioned a directory and provide context
|
|
356
601
|
const dirMatch = input.match(/\/Users\/[^\s]+|\/[a-zA-Z0-9_\/-]+/g);
|
|
357
|
-
let contextMsg = input;
|
|
358
602
|
|
|
359
603
|
if (dirMatch && dirMatch[0]) {
|
|
360
604
|
const mentionedDir = dirMatch[0];
|
|
361
605
|
try {
|
|
362
606
|
if (fs.existsSync(mentionedDir) && fs.statSync(mentionedDir).isDirectory()) {
|
|
363
607
|
const files = fs.readdirSync(mentionedDir).slice(0, 10).join(', ');
|
|
364
|
-
contextMsg
|
|
608
|
+
contextMsg += `\n\n[CONTEXT: Directory "${mentionedDir}" contains: ${files}${fs.readdirSync(mentionedDir).length > 10 ? '...' : ''}]`;
|
|
365
609
|
}
|
|
366
610
|
} catch (e) {
|
|
367
611
|
// Silently ignore if directory doesn't exist
|