prjct-cli 0.4.9 → 0.5.1

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 (49) hide show
  1. package/CHANGELOG.md +332 -0
  2. package/CLAUDE.md +109 -3
  3. package/README.md +231 -96
  4. package/core/agent-detector.js +55 -122
  5. package/core/agent-generator.js +516 -0
  6. package/core/command-installer.js +104 -890
  7. package/core/commands.js +74 -76
  8. package/core/editors-config.js +9 -57
  9. package/core/git-integration.js +401 -0
  10. package/package.json +12 -9
  11. package/scripts/install.sh +0 -1
  12. package/templates/agents/be.template.md +42 -0
  13. package/templates/agents/data.template.md +41 -0
  14. package/templates/agents/devops.template.md +41 -0
  15. package/templates/agents/fe.template.md +42 -0
  16. package/templates/agents/mobile.template.md +41 -0
  17. package/templates/agents/pm.template.md +84 -0
  18. package/templates/agents/qa.template.md +54 -0
  19. package/templates/agents/scribe.template.md +95 -0
  20. package/templates/agents/security.template.md +41 -0
  21. package/templates/agents/ux.template.md +49 -0
  22. package/templates/commands/analyze.md +137 -3
  23. package/templates/commands/done.md +154 -5
  24. package/templates/commands/init.md +61 -3
  25. package/templates/commands/ship.md +146 -6
  26. package/templates/commands/sync.md +220 -0
  27. package/templates/examples/natural-language-examples.md +234 -22
  28. package/core/agents/codex-agent.js +0 -256
  29. package/core/agents/terminal-agent.js +0 -465
  30. package/templates/workflows/analyze.md +0 -159
  31. package/templates/workflows/cleanup.md +0 -73
  32. package/templates/workflows/context.md +0 -72
  33. package/templates/workflows/design.md +0 -88
  34. package/templates/workflows/done.md +0 -20
  35. package/templates/workflows/fix.md +0 -201
  36. package/templates/workflows/git.md +0 -192
  37. package/templates/workflows/help.md +0 -13
  38. package/templates/workflows/idea.md +0 -22
  39. package/templates/workflows/init.md +0 -80
  40. package/templates/workflows/natural-language-handler.md +0 -183
  41. package/templates/workflows/next.md +0 -44
  42. package/templates/workflows/now.md +0 -19
  43. package/templates/workflows/progress.md +0 -113
  44. package/templates/workflows/recap.md +0 -66
  45. package/templates/workflows/roadmap.md +0 -95
  46. package/templates/workflows/ship.md +0 -18
  47. package/templates/workflows/stuck.md +0 -25
  48. package/templates/workflows/task.md +0 -109
  49. package/templates/workflows/test.md +0 -243
@@ -1,8 +1,10 @@
1
1
  # Natural Language Examples
2
2
 
3
- Real-world examples showing how the **semantic intent detection** works.
3
+ Real-world examples showing how **Claude Code** handles natural language with context validation.
4
4
 
5
- > **Important**: These are examples, not the only valid phrases! The LLM understands intent semantically, so users can express themselves in countless ways.
5
+ > **Important**: These are examples, not the only valid phrases! Claude understands intent semantically, so users can express themselves in countless ways.
6
+
7
+ > **Note**: All examples show how **Claude Code automatically validates context** and provides conversational responses when context is missing.
6
8
 
7
9
  ## Example 1: Starting a Task
8
10
 
@@ -34,7 +36,9 @@ Need help? Say "I'm stuck" or use /p:stuck
34
36
 
35
37
  ---
36
38
 
37
- ## Example 2: Completing a Task
39
+ ## Example 2: Completing a Task (WITH Active Task)
40
+
41
+ **Context:** User has an active task in `core/now.md`
38
42
 
39
43
  **User says (any of these work):**
40
44
  - "I'm done"
@@ -43,9 +47,10 @@ Need help? Say "I'm stuck" or use /p:stuck
43
47
  - "all done with this"
44
48
  - "completed it"
45
49
 
46
- **Claude Code understands:**
47
- - Intent: User finished their current work
48
- - Command: `/p:done`
50
+ **Claude Code checks:**
51
+ - Project exists:
52
+ - Active task exists:
53
+ - Context valid: Execute command
49
54
 
50
55
  **Claude Code response:**
51
56
  ```markdown
@@ -64,6 +69,36 @@ Or use: /p:now | /p:ship | /p:idea
64
69
 
65
70
  ---
66
71
 
72
+ ## Example 2b: Completing a Task (NO Active Task)
73
+
74
+ **Context:** User has NO active task (empty `core/now.md`)
75
+
76
+ **User says:**
77
+ - "I'm done"
78
+ - "finished"
79
+ - "terminé"
80
+
81
+ **Claude Code checks:**
82
+ - Project exists: ✅
83
+ - Active task exists: ❌
84
+ - Context invalid: Return conversational response
85
+
86
+ **Claude Code response (NO command execution):**
87
+ ```markdown
88
+ ✨ You're not working on anything right now!
89
+
90
+ Want to start something?
91
+ • Tell me what you want to build
92
+ • Say "show me what's next"
93
+ • Or use: /p:now | /p:next
94
+
95
+ Let's ship something!
96
+ ```
97
+
98
+ **Why this is better:** Instead of showing a technical error like "⏺ No hay tarea activa en este momento...", Claude provides a friendly, actionable response that guides the user forward.
99
+
100
+ ---
101
+
67
102
  ## Example 3: Shipping a Feature
68
103
 
69
104
  **User says:**
@@ -91,6 +126,36 @@ Or use: /p:now | /p:recap | /p:roadmap
91
126
 
92
127
  ---
93
128
 
129
+ ## Example 3b: Shipping a Feature (NO Work Done Yet)
130
+
131
+ **Context:** User has NO active task and NO shipped features
132
+
133
+ **User says:**
134
+ - "ship this"
135
+ - "deploy it"
136
+ - "let's launch"
137
+
138
+ **Claude Code checks:**
139
+ - Project exists: ✅
140
+ - Has work to ship (active task OR shipped features): ❌
141
+ - Context invalid: Return conversational response
142
+
143
+ **Claude Code response (NO command execution):**
144
+ ```markdown
145
+ 🚀 Nothing to ship yet!
146
+
147
+ First, let's build something:
148
+ • Tell me what feature you want to create
149
+ • Say "start building [feature]"
150
+ • Or use: /p:now "feature name"
151
+
152
+ Then we'll celebrate when you ship it!
153
+ ```
154
+
155
+ **Why this is better:** Instead of confusing the user with an error, Claude guides them toward the correct workflow: build first, ship later.
156
+
157
+ ---
158
+
94
159
  ## Example 4: Capturing an Idea
95
160
 
96
161
  **User says:**
@@ -267,31 +332,178 @@ Which one?
267
332
 
268
333
  ---
269
334
 
335
+ ## Example 11: p. Trigger (NEW - Zero Memorization)
336
+
337
+ **Context:** User doesn't want to memorize `/p:*` commands
338
+
339
+ **User says:**
340
+ ```
341
+ p. analiza todo este documento y dame el roadmap
342
+ ```
343
+
344
+ **Claude Code detects:**
345
+ - Trigger: `p.` detected
346
+ - Validates: `.prjct/prjct.config.json` exists ✅
347
+ - Intent: "analysis" + "roadmap"
348
+ - Command: `/p:analyze`
349
+
350
+ **Claude Code response:**
351
+ ```markdown
352
+ 💬 I understood: "analyze document and create roadmap" (prjct context)
353
+ ⚡ Executing: /p:analyze
354
+
355
+ [Performs repository analysis]
356
+
357
+ 📊 Analysis complete. Creating roadmap...
358
+
359
+ [Shows roadmap suggestions]
360
+
361
+ Ready to plan?
362
+ • Say "p. add to roadmap" or use /p:roadmap
363
+ • Or continue working on current task
364
+ ```
365
+
366
+ ---
367
+
368
+ ## Example 12: p. Trigger Multi-Language
369
+
370
+ **User says (Spanish):**
371
+ ```
372
+ p. estoy listo para shipear esta feature
373
+ ```
374
+
375
+ **Claude Code detects:**
376
+ - Trigger: `p.` detected
377
+ - Validates: Project exists ✅
378
+ - Intent: "ship" (detected from "shipear")
379
+ - Command: `/p:ship`
380
+
381
+ **Claude Code response:**
382
+ ```markdown
383
+ 💬 I understood: "ready to ship this feature" (prjct context)
384
+ ⚡ Executing: /p:ship
385
+
386
+ What feature did you ship?
387
+ • Tell me the feature name
388
+ • Or use: /p:ship "feature name"
389
+ ```
390
+
391
+ ---
392
+
393
+ ## Example 13: p. Trigger Without Project
394
+
395
+ **Context:** User tries p. trigger in non-prjct directory
396
+
397
+ **User says:**
398
+ ```
399
+ p. muéstrame mi progreso
400
+ ```
401
+
402
+ **Claude Code checks:**
403
+ - Trigger: `p.` detected
404
+ - Validates: `.prjct/prjct.config.json` NOT found ❌
405
+
406
+ **Claude Code response (NO command execution):**
407
+ ```markdown
408
+ 🎯 No prjct project here!
409
+
410
+ This doesn't look like a prjct directory.
411
+
412
+ Want to initialize?
413
+ • Say "initialize prjct" or "set up project"
414
+ • Or use: /p:init
415
+
416
+ Then you can track progress with p. commands!
417
+ ```
418
+
419
+ **Why this is better:** The `p.` trigger is **context-aware** - it only works in prjct directories, preventing accidental execution.
420
+
421
+ ---
422
+
423
+ ## Example 14: All Three Ways Work
424
+
425
+ **Scenario:** User can choose their preferred style
426
+
427
+ **Option 1 - p. Trigger (easiest):**
428
+ ```
429
+ User: "p. terminé"
430
+ Claude: Detects completion intent → /p:done
431
+ ```
432
+
433
+ **Option 2 - Direct slash command:**
434
+ ```
435
+ User: "/p:done"
436
+ Claude: Executes directly
437
+ ```
438
+
439
+ **Option 3 - Natural language:**
440
+ ```
441
+ User: "I'm done"
442
+ Claude: Detects intent → /p:done
443
+ ```
444
+
445
+ **All three execute the same command!** Users pick what feels natural to them.
446
+
447
+ ---
448
+
270
449
  ## Implementation Notes
271
450
 
272
- ### Semantic Understanding (Not Pattern Matching!)
451
+ ### How Claude Code Handles Natural Language
452
+
453
+ **Key Principle**: Claude Code (and Claude Desktop) automatically handle intent detection, context validation, and conversational responses through **CLAUDE.md instructions**. No SDK needed!
454
+
455
+ **How it works:**
273
456
 
274
- **Key Principle**: The LLM understands intent semantically, not through regex or hardcoded phrases.
457
+ 1. **CLAUDE.md is automatically read** - Both Claude Code and Desktop read this file for context
458
+ 2. **Claude understands intent naturally** - As an LLM, Claude semantically understands what users want
459
+ 3. **Simple file checks validate context** - Read `core/now.md`, check if `.prjct/prjct.config.json` exists
460
+ 4. **Conversational responses when context missing** - Friendly guidance instead of errors
461
+ 5. **Multi-language support** - Works in any language Claude understands
462
+
463
+ **Implementation:**
275
464
 
276
465
  ```javascript
277
- // DON'T DO THIS
278
- if (message.includes("I want to start")) {
279
- // Too rigid!
466
+ // NO SDK NEEDED - Just use Claude Code's native capabilities:
467
+
468
+ // 1. Detect p. trigger or natural language intent
469
+ if (message.startsWith('p. ')) {
470
+ // Check if prjct project exists
471
+ const configExists = await Read('.prjct/prjct.config.json')
472
+ if (!configExists) {
473
+ return "🎯 No prjct project here! Run /p:init first."
474
+ }
475
+ // Extract intent from rest of message
476
+ const intent = message.slice(3).trim()
477
+ // Continue with semantic understanding...
478
+ }
479
+
480
+ // 2. Validate context before execution
481
+ if (command === 'done') {
482
+ const nowContent = await Read('core/now.md')
483
+ if (!nowContent || nowContent.trim() === '') {
484
+ return conversationalResponse() // Friendly guidance
485
+ }
280
486
  }
281
487
 
282
- // DO THIS
283
- // Use your LLM understanding:
284
- // "What is the user trying to accomplish?"
285
- const intent = semanticallyUnderstand(message)
488
+ // 3. Execute command with transparency
489
+ console.log(`💬 I understood: "${intent}"`)
490
+ console.log(`⚡ Executing: /p:${command} ${params}`)
286
491
  ```
287
492
 
288
- ### Detection Flow
289
- 1. **Check for `/p:` commands** - Execute directly if present
290
- 2. **Understand user intent** - What are they trying to do?
291
- 3. **Map to appropriate command** - Based on semantic meaning
292
- 4. **Extract parameters** - Pull relevant information
293
- 5. **Show transparency** - Communicate what you understood
294
- 6. **Execute and respond** - Run command and guide next steps
493
+ ### Detection Flow (Natural)
494
+ 1. **Check for p. trigger** - Highest priority
495
+ - If starts with `p.` Check if `.prjct/prjct.config.json` exists
496
+ - If exists Extract intent from rest of message
497
+ - If not exists Return "No prjct project" message
498
+ 2. **Parse user input** - Direct slash command or natural language?
499
+ 3. **Understand intent semantically** - What does the user want to do?
500
+ 4. **Validate context** - Simple file reads to check prerequisites
501
+ 5. **Respond**:
502
+ - Context missing → Provide conversational guidance
503
+ - Context valid → Execute command with transparency
504
+ - No command intent → Normal conversation
505
+ 6. **Show transparency** - Always communicate what you understood
506
+ 7. **Execute and guide** - Run command and suggest next steps
295
507
 
296
508
  ### Transparency Format
297
509
  Always show what you understood:
@@ -1,256 +0,0 @@
1
- /**
2
- * OpenAI Codex Agent Adapter
3
- * Implements prjct commands for OpenAI Codex environment
4
- */
5
-
6
- const fs = require('fs').promises
7
-
8
- class CodexAgent {
9
- constructor() {
10
- this.name = 'OpenAI Codex'
11
- this.type = 'codex'
12
- }
13
-
14
- /**
15
- * Format response for Codex with structured output
16
- * Codex runs in sandboxed environments, so we use clear text formatting
17
- */
18
- formatResponse(message, type = 'info') {
19
- const prefixes = {
20
- success: '[SUCCESS]',
21
- error: '[ERROR]',
22
- warning: '[WARNING]',
23
- info: '[INFO]',
24
- celebrate: '[SHIPPED]',
25
- ship: '[FEATURE]',
26
- focus: '[FOCUS]',
27
- idea: '[IDEA]',
28
- progress: '[PROGRESS]',
29
- task: '[TASK]',
30
- }
31
-
32
- const prefix = prefixes[type] || prefixes.info
33
-
34
- return `${prefix} ${message}`
35
- }
36
-
37
- /**
38
- * Read file using native fs (Codex doesn't have MCP)
39
- */
40
- async readFile(filePath) {
41
- try {
42
- return await fs.readFile(filePath, 'utf8')
43
- } catch (error) {
44
- throw new Error(`Failed to read file ${filePath}: ${error.message}`)
45
- }
46
- }
47
-
48
- /**
49
- * Write file using native fs
50
- */
51
- async writeFile(filePath, content) {
52
- try {
53
- await fs.writeFile(filePath, content, 'utf8')
54
- } catch (error) {
55
- throw new Error(`Failed to write file ${filePath}: ${error.message}`)
56
- }
57
- }
58
-
59
- /**
60
- * List directory contents
61
- */
62
- async listDirectory(dirPath) {
63
- try {
64
- return await fs.readdir(dirPath)
65
- } catch (error) {
66
- throw new Error(`Failed to list directory ${dirPath}: ${error.message}`)
67
- }
68
- }
69
-
70
- /**
71
- * Check if file exists
72
- */
73
- async fileExists(filePath) {
74
- try {
75
- await fs.access(filePath)
76
- return true
77
- } catch {
78
- return false
79
- }
80
- }
81
-
82
- /**
83
- * Create directory
84
- */
85
- async createDirectory(dirPath) {
86
- try {
87
- await fs.mkdir(dirPath, { recursive: true })
88
- } catch (error) {
89
- throw new Error(`Failed to create directory ${dirPath}: ${error.message}`)
90
- }
91
- }
92
-
93
- /**
94
- * Get current timestamp in ISO format
95
- */
96
- getTimestamp() {
97
- return new Date().toISOString()
98
- }
99
-
100
- /**
101
- * Format task list with structured output
102
- */
103
- formatTaskList(tasks) {
104
- if (!tasks || tasks.length === 0) {
105
- return this.formatResponse('No tasks in queue', 'info')
106
- }
107
-
108
- let output = 'TASK QUEUE:\n'
109
- output += '===========\n'
110
- tasks.forEach((task, index) => {
111
- output += ` ${index + 1}. ${task}\n`
112
- })
113
-
114
- return output
115
- }
116
-
117
- /**
118
- * Format recap with structured output
119
- */
120
- formatRecap(data) {
121
- const output = `
122
- PROJECT RECAP
123
- =============
124
-
125
- Current Task: ${data.currentTask || 'None'}
126
- Shipped Features: ${data.shippedCount} total
127
- Queued Tasks: ${data.queuedCount}
128
- Ideas Captured: ${data.ideasCount}
129
-
130
- ${data.recentActivity ? 'Recent Activity:\n' + data.recentActivity : ''}
131
-
132
- Status: ${data.shippedCount > 0 ? 'Productive' : 'Getting Started'}
133
- `.trim()
134
-
135
- return output
136
- }
137
-
138
- /**
139
- * Format progress report
140
- */
141
- formatProgress(data) {
142
- const trend =
143
- data.velocity > data.previousVelocity
144
- ? 'UP'
145
- : data.velocity < data.previousVelocity
146
- ? 'DOWN'
147
- : 'STEADY'
148
-
149
- const output = `
150
- PROGRESS REPORT (${data.period.toUpperCase()})
151
- =====================================
152
-
153
- Features Shipped: ${data.count}
154
- Velocity: ${data.velocity.toFixed(1)} features/day
155
- Trend: ${trend}
156
-
157
- ${data.recentFeatures ? 'Recent Features:\n' + data.recentFeatures : ''}
158
-
159
- ${data.motivationalMessage}
160
- `.trim()
161
-
162
- return output
163
- }
164
-
165
- /**
166
- * Get help content based on issue type
167
- * Structured format for Codex readability
168
- */
169
- getHelpContent(issue) {
170
- const helps = {
171
- debugging: `
172
- DEBUGGING STRATEGY:
173
- ===================
174
- 1. ISOLATE - Comment out code until error disappears
175
- 2. LOG - Add console.log at key points
176
- 3. SIMPLIFY - Create minimal reproduction
177
- 4. RESEARCH - Search for exact error message
178
- 5. BREAK - Take a walk, fresh perspective helps
179
- `,
180
- design: `
181
- DESIGN APPROACH:
182
- ================
183
- 1. START SIMPLE - Basic version first
184
- 2. USER FIRST - What problem does this solve?
185
- 3. ITERATE - Ship v1, improve based on feedback
186
- 4. PATTERNS - Look for similar solutions
187
- 5. VALIDATE - Show mockup before building
188
- `,
189
- performance: `
190
- PERFORMANCE STRATEGY:
191
- ====================
192
- 1. MEASURE FIRST - Profile before optimizing
193
- 2. BIGGEST WINS - Focus on slowest parts
194
- 3. CACHE - Store expensive computations
195
- 4. LAZY LOAD - Defer non-critical work
196
- 5. MONITOR - Track improvements
197
- `,
198
- default: `
199
- GENERAL STRATEGY:
200
- ================
201
- 1. BREAK IT DOWN - Divide into smaller tasks
202
- 2. START SMALL - Implement simplest part first
203
- 3. TEST OFTEN - Verify each step works
204
- 4. DOCUMENT - Write down what you learn
205
- 5. SHIP IT - Perfect is the enemy of done
206
- `,
207
- }
208
-
209
- const helpType =
210
- Object.keys(helps).find((key) => issue.toLowerCase().includes(key)) || 'default'
211
-
212
- return helps[helpType]
213
- }
214
-
215
- /**
216
- * Suggest next action based on context
217
- * Clear, actionable suggestions for Codex
218
- */
219
- suggestNextAction(context) {
220
- const suggestions = {
221
- taskCompleted: 'NEXT: Check task queue with /p:next',
222
- featureShipped: 'NEXT: Set new focus with /p:now [task]',
223
- ideaCaptured: 'NEXT: Start working with /p:now [task]',
224
- initialized: 'NEXT: Set first task with /p:now "your first task"',
225
- stuck: 'NEXT: Break down problem with /p:idea for each step',
226
- }
227
-
228
- return suggestions[context] || 'NEXT: What would you like to work on?'
229
- }
230
-
231
- /**
232
- * Handle sandboxed environment limitations
233
- */
234
- async ensureSandboxCompatibility() {
235
- const isSandboxed =
236
- process.cwd().includes('/sandbox/') ||
237
- process.cwd().includes('/tmp/') ||
238
- process.env.CODEX_SANDBOX
239
-
240
- if (isSandboxed) {
241
- return {
242
- sandboxed: true,
243
- basePath: process.cwd(),
244
- restrictions: ['no-network', 'limited-filesystem'],
245
- }
246
- }
247
-
248
- return {
249
- sandboxed: false,
250
- basePath: process.cwd(),
251
- restrictions: [],
252
- }
253
- }
254
- }
255
-
256
- module.exports = CodexAgent