oneie 3.6.25 → 3.6.27

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 (55) hide show
  1. package/.claude/agents/TROUBLESHOOTING.md +530 -0
  2. package/.claude/agents/agent-builder.md +226 -198
  3. package/.claude/agents/agent-claude.md +645 -0
  4. package/.claude/agents/agent-designer.md +166 -11
  5. package/.claude/agents/agent-director.md +109 -41
  6. package/.claude/agents/agent-frontend.md +314 -27
  7. package/.claude/agents/agent-quality.md +377 -0
  8. package/.claude/commands/chat.md +504 -0
  9. package/.claude/commands/create.md +134 -18
  10. package/.claude/commands/fast.md +531 -0
  11. package/.claude/commands/one.md +12 -85
  12. package/.claude/commands/optimize.md +74 -0
  13. package/.claude/commands/plan.md +420 -373
  14. package/.claude/commands/review.md +99 -0
  15. package/.claude/commands/test.md +197 -0
  16. package/.claude/commands/validate.md +140 -0
  17. package/.claude/hooks/__pycache__/todo.cpython-312.pyc +0 -0
  18. package/.claude/hooks/auto-format.sh +106 -0
  19. package/.claude/hooks/formatting.py +187 -0
  20. package/.claude/hooks/ontology-validation.py +255 -0
  21. package/.claude/hooks/validate-imports.py +182 -0
  22. package/.claude/hooks/validate-ontology.py +140 -0
  23. package/CLAUDE.md +105 -0
  24. package/dist/commands/agent.d.ts +18 -0
  25. package/dist/commands/agent.d.ts.map +1 -0
  26. package/dist/commands/agent.js +271 -0
  27. package/dist/commands/agent.js.map +1 -0
  28. package/dist/commands/init.js +1 -1
  29. package/dist/commands/init.js.map +1 -1
  30. package/dist/index.js +20 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/lib/agent-detection.d.ts +19 -0
  33. package/dist/lib/agent-detection.d.ts.map +1 -0
  34. package/dist/lib/agent-detection.js +87 -0
  35. package/dist/lib/agent-detection.js.map +1 -0
  36. package/dist/lib/detect.d.ts +45 -0
  37. package/dist/lib/detect.d.ts.map +1 -0
  38. package/dist/lib/detect.js +221 -0
  39. package/dist/lib/detect.js.map +1 -0
  40. package/llms.txt +257 -0
  41. package/one/knowledge/cascading-context-specification.md +1617 -0
  42. package/one/knowledge/claude-code-integration.md +1293 -0
  43. package/one/knowledge/development-commands.md +251 -0
  44. package/one/knowledge/games-english.md +691 -0
  45. package/one/knowledge/games.md +1082 -0
  46. package/one/knowledge/guidelines.md +314 -0
  47. package/one/knowledge/parallel-agents.md +932 -0
  48. package/one/knowledge/performance.md +459 -0
  49. package/one/knowledge/troubleshooting.md +434 -0
  50. package/one/things/plans/dsl-claude-code.md +1011 -0
  51. package/one/things/plans/npx-agent-safety.md +785 -0
  52. package/one/things/plans/npx-agent.md +1089 -0
  53. package/one/things/plans/remove-backend-development-from-agents.md +1331 -0
  54. package/package.json +3 -2
  55. package/.claude/agents/AUDIT-agent-ops-alignment.md +0 -379
@@ -0,0 +1,1089 @@
1
+ ---
2
+ title: npx oneie agent - Agent-First CLI Command
3
+ type: plan
4
+ status: draft
5
+ created: 2025-01-08
6
+ tags:
7
+ - cli
8
+ - agents
9
+ - automation
10
+ - developer-experience
11
+ - agent-experience
12
+ ---
13
+
14
+ # npx oneie agent - Agent-First CLI Command
15
+
16
+ ## Problem Statement
17
+
18
+ The current `npx oneie` command is designed for **human interaction** with prompts, questions, and manual input. This creates friction for AI agents (like Claude Code) that need to:
19
+
20
+ 1. Run commands programmatically without human input
21
+ 2. Set up projects automatically during conversations
22
+ 3. Detect context from existing environment
23
+ 4. Complete setup in single command execution
24
+
25
+ **Current friction:**
26
+ ```bash
27
+ # Agent tries to run this:
28
+ npx oneie
29
+
30
+ # Gets stuck on interactive prompt:
31
+ ? What's your name? › [waiting for input...]
32
+ ```
33
+
34
+ ## Solution: Agent-First Command
35
+
36
+ Create `npx oneie agent` - a non-interactive, context-aware command designed for AI agent experience.
37
+
38
+ ### Design Principles
39
+
40
+ 1. **Zero Interaction** - No prompts, runs to completion
41
+ 2. **Smart Detection** - Auto-detects user context from environment
42
+ 3. **Sensible Defaults** - Works with zero configuration
43
+ 4. **Override Ready** - Accepts CLI flags for explicit control
44
+ 5. **Idempotent** - Safe to run multiple times
45
+
46
+ ## Agent Detection
47
+
48
+ ### Detecting Agent Environment
49
+
50
+ The CLI should detect when it's being run by an AI agent and suggest the appropriate command:
51
+
52
+ ```typescript
53
+ function isAgentEnvironment(): boolean {
54
+ return (
55
+ // Claude Code environment
56
+ !!process.env.CLAUDE_CODE ||
57
+ !!process.env.CLAUDE_USER_NAME ||
58
+
59
+ // GitHub Copilot
60
+ !!process.env.GITHUB_COPILOT ||
61
+
62
+ // Cursor
63
+ !!process.env.CURSOR_AI ||
64
+
65
+ // Other AI environments
66
+ !!process.env.AI_AGENT ||
67
+
68
+ // Non-TTY (no interactive terminal)
69
+ !process.stdin.isTTY ||
70
+
71
+ // CI/CD environment
72
+ !!process.env.CI
73
+ );
74
+ }
75
+ ```
76
+
77
+ ### Interactive Command Detection
78
+
79
+ When `npx oneie` (interactive version) is run in an agent environment:
80
+
81
+ ```bash
82
+ $ npx oneie
83
+
84
+ ⚠️ Agent environment detected!
85
+
86
+ You're running the interactive version of ONE CLI in an AI agent environment.
87
+ This command requires human input and will hang.
88
+
89
+ Did you mean to run:
90
+ npx oneie agent
91
+
92
+ The 'agent' command is designed for AI agents:
93
+ ✓ Zero interaction required
94
+ ✓ Auto-detects context from git, files, and environment
95
+ ✓ Completes in 5-10 seconds
96
+ ✓ Safe for automated workflows
97
+
98
+ Run this instead:
99
+ npx oneie agent
100
+
101
+ Or if you're human and want the interactive setup:
102
+ npx oneie --interactive
103
+
104
+ Aborting to prevent hang...
105
+ ```
106
+
107
+ ### Automatic Redirect (Optional)
108
+
109
+ Optionally, auto-redirect to agent mode:
110
+
111
+ ```bash
112
+ $ npx oneie
113
+
114
+ ⚠️ Agent environment detected (CLAUDE_CODE=true)
115
+
116
+ Automatically switching to agent mode...
117
+ Running: npx oneie agent
118
+
119
+ 🤖 ONE Agent Setup
120
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
121
+
122
+ Detected context:
123
+ Name: John Doe
124
+ Email: john@example.com
125
+ Organization: Acme Corp
126
+
127
+ ✓ Installation complete!
128
+ ```
129
+
130
+ ## Command Design
131
+
132
+ ### Basic Usage
133
+
134
+ ```bash
135
+ # Fully automatic (recommended for agents)
136
+ npx oneie agent
137
+
138
+ # This will:
139
+ # 1. Detect user from git config
140
+ # 2. Detect organization from git remote or package.json
141
+ # 3. Use current directory as project root
142
+ # 4. Generate installation folder from org name
143
+ # 5. Install dependencies
144
+ # 6. Create .env files with smart defaults
145
+ # 7. Initialize git if not already initialized
146
+ ```
147
+
148
+ ### With Explicit Arguments
149
+
150
+ ```bash
151
+ # Override specific values
152
+ npx oneie agent \
153
+ --name="John Doe" \
154
+ --email="john@example.com" \
155
+ --org="Acme Corp" \
156
+ --project-dir="./my-project" \
157
+ --website="https://acme.com"
158
+
159
+ # Minimal override (use detection for rest)
160
+ npx oneie agent --org="My Startup"
161
+
162
+ # Use git config explicitly
163
+ npx oneie agent --use-git-config
164
+
165
+ # Skip installation folder
166
+ npx oneie agent --no-installation-folder
167
+
168
+ # Quiet mode (minimal output)
169
+ npx oneie agent --quiet
170
+
171
+ # Verbose mode (for debugging)
172
+ npx oneie agent --verbose
173
+ ```
174
+
175
+ ## Context Detection Strategy
176
+
177
+ ### 1. User Identity Detection
178
+
179
+ **Priority order:**
180
+
181
+ 1. CLI flags: `--name`, `--email` (explicit override)
182
+ 2. **Claude context**: `--claude-user`, `CLAUDE_USER_NAME`, `CLAUDE_USER_EMAIL`
183
+ 3. Git config: `git config user.name`, `git config user.email`
184
+ 4. Environment variables: `GIT_AUTHOR_NAME`, `GIT_AUTHOR_EMAIL`
185
+ 5. Defaults: `"Developer"`, `"dev@localhost"`
186
+
187
+ **Claude Integration:**
188
+
189
+ When Claude Code runs the command, it can pass user context:
190
+
191
+ ```bash
192
+ # Claude Code automatically adds these flags
193
+ npx oneie agent \
194
+ --claude-user="John Doe" \
195
+ --claude-email="john@example.com" \
196
+ --claude-org="Acme Corp"
197
+
198
+ # Or via environment variables
199
+ CLAUDE_USER_NAME="John Doe" \
200
+ CLAUDE_USER_EMAIL="john@example.com" \
201
+ CLAUDE_ORG_NAME="Acme Corp" \
202
+ npx oneie agent
203
+ ```
204
+
205
+ **Implementation:**
206
+ ```typescript
207
+ async function detectUserIdentity(): Promise<UserIdentity> {
208
+ // 1. Check CLI flags (highest priority - explicit override)
209
+ if (process.argv.includes('--name') || process.argv.includes('--email')) {
210
+ return {
211
+ name: getCliArg('--name') || '',
212
+ email: getCliArg('--email') || '',
213
+ };
214
+ }
215
+
216
+ // 2. Check Claude context flags (from Claude Code)
217
+ if (process.argv.includes('--claude-user')) {
218
+ const name = getCliArg('--claude-user');
219
+ const email = getCliArg('--claude-email') || '';
220
+ if (name) {
221
+ return { name, email };
222
+ }
223
+ }
224
+
225
+ // 3. Check Claude environment variables
226
+ if (process.env.CLAUDE_USER_NAME) {
227
+ return {
228
+ name: process.env.CLAUDE_USER_NAME,
229
+ email: process.env.CLAUDE_USER_EMAIL || 'dev@localhost',
230
+ };
231
+ }
232
+
233
+ // 4. Try git config
234
+ try {
235
+ const name = await exec('git config user.name');
236
+ const email = await exec('git config user.email');
237
+ if (name && email) {
238
+ return { name: name.trim(), email: email.trim() };
239
+ }
240
+ } catch {}
241
+
242
+ // 5. Try standard environment variables
243
+ if (process.env.GIT_AUTHOR_NAME && process.env.GIT_AUTHOR_EMAIL) {
244
+ return {
245
+ name: process.env.GIT_AUTHOR_NAME,
246
+ email: process.env.GIT_AUTHOR_EMAIL,
247
+ };
248
+ }
249
+
250
+ // 6. Fallback to defaults
251
+ return {
252
+ name: 'Developer',
253
+ email: 'dev@localhost',
254
+ };
255
+ }
256
+ ```
257
+
258
+ ### 2. Organization Detection
259
+
260
+ **Priority order:**
261
+
262
+ 1. CLI flag: `--org` (explicit override)
263
+ 2. **Claude context**: `--claude-org`, `CLAUDE_ORG_NAME`
264
+ 3. Git remote URL (parse from github.com/org-name/repo)
265
+ 4. package.json: `author.name` or `organization`
266
+ 5. README.md: First H1 heading
267
+ 6. Directory name (parent directory)
268
+ 7. Default: `"Default Organization"`
269
+
270
+ **Claude Integration:**
271
+
272
+ Claude can infer organization from conversation context or user account:
273
+
274
+ ```bash
275
+ # Claude passes organization context
276
+ npx oneie agent --claude-org="Acme Corp"
277
+
278
+ # Or via environment
279
+ CLAUDE_ORG_NAME="Acme Corp" npx oneie agent
280
+ ```
281
+
282
+ **Implementation:**
283
+ ```typescript
284
+ async function detectOrganization(): Promise<string> {
285
+ // 1. Check CLI flag (explicit override)
286
+ if (process.argv.includes('--org')) {
287
+ const org = getCliArg('--org');
288
+ if (org) return org;
289
+ }
290
+
291
+ // 2. Check Claude context
292
+ if (process.argv.includes('--claude-org')) {
293
+ const org = getCliArg('--claude-org');
294
+ if (org) return org;
295
+ }
296
+
297
+ // 3. Check Claude environment variable
298
+ if (process.env.CLAUDE_ORG_NAME) {
299
+ return process.env.CLAUDE_ORG_NAME;
300
+ }
301
+
302
+ // 4. Try git remote
303
+ try {
304
+ const remote = await exec('git config --get remote.origin.url');
305
+ const match = remote.match(/github\.com[:/]([^/]+)\//);
306
+ if (match) return match[1];
307
+ } catch {}
308
+
309
+ // 5. Try package.json
310
+ if (fs.existsSync('package.json')) {
311
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
312
+ if (pkg.author?.name) return pkg.author.name;
313
+ if (pkg.organization) return pkg.organization;
314
+ }
315
+
316
+ // 6. Try README.md
317
+ if (fs.existsSync('README.md')) {
318
+ const readme = fs.readFileSync('README.md', 'utf-8');
319
+ const match = readme.match(/^#\s+(.+)$/m);
320
+ if (match) return match[1];
321
+ }
322
+
323
+ // 7. Use parent directory name
324
+ return path.basename(path.resolve('..'));
325
+ }
326
+ ```
327
+
328
+ ### 3. Website Detection
329
+
330
+ **Priority order:**
331
+
332
+ 1. CLI flag: `--website`
333
+ 2. package.json: `homepage`
334
+ 3. README.md: URLs in badges or links
335
+ 4. Git remote URL (convert to website)
336
+ 5. Default: `""`
337
+
338
+ ### 4. Project Details
339
+
340
+ **Auto-detected:**
341
+ - **Project name**: Current directory name
342
+ - **Project type**: Detect from existing files (Astro, React, etc.)
343
+ - **Installation folder**: Slugified org name (e.g., "Acme Corp" → "acme")
344
+
345
+ ## Output Design
346
+
347
+ ### Success Output (Quiet Mode)
348
+
349
+ ```bash
350
+ $ npx oneie agent --quiet
351
+
352
+ ✓ ONE Platform initialized
353
+
354
+ → cd /path/to/project
355
+ → claude
356
+ → /one
357
+ ```
358
+
359
+ ### Success Output (Default Mode)
360
+
361
+ ```bash
362
+ $ npx oneie agent
363
+
364
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
365
+ 🤖 ONE Agent Setup
366
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
367
+
368
+ Detected context:
369
+ Name: John Doe
370
+ Email: john@example.com
371
+ Organization: Acme Corp
372
+ Project: /Users/john/projects/acme-platform
373
+
374
+ ✓ Created project structure
375
+ ✓ Installed dependencies (23 packages)
376
+ ✓ Generated environment files
377
+ ✓ Created installation folder: /acme
378
+ ✓ Initialized git repository
379
+
380
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
381
+ ✅ Your ONE Platform is ready!
382
+
383
+ Next steps (for Claude Code):
384
+ /one # Show control center
385
+ /chat [idea] # Start conversation
386
+ /plan convert # Create 100-cycle plan
387
+
388
+ Next steps (manual):
389
+ cd /Users/john/projects/acme-platform
390
+ bun run dev # Start development server
391
+
392
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
393
+ ```
394
+
395
+ ### Error Output
396
+
397
+ ```bash
398
+ $ npx oneie agent
399
+
400
+ ✗ Failed to initialize ONE Platform
401
+
402
+ Reason: Git not configured
403
+ Fix: Run these commands first:
404
+ git config --global user.name "Your Name"
405
+ git config --global user.email "your@email.com"
406
+
407
+ Or provide explicit values:
408
+ npx oneie agent --name="Your Name" --email="your@email.com"
409
+ ```
410
+
411
+ ## Integration with Claude Code
412
+
413
+ ### Automatic Context Passing
414
+
415
+ Claude Code can automatically provide user context to the CLI:
416
+
417
+ ```typescript
418
+ // In Claude Code workflow
419
+ async function initializeONEPlatform(userContext: UserContext) {
420
+ // Extract context from Claude's knowledge
421
+ const userName = userContext.name || detectFromConversation();
422
+ const userEmail = userContext.email || detectFromGitConfig();
423
+ const orgName = detectOrgFromConversation() || detectFromGitRepo();
424
+
425
+ // Pass context to CLI
426
+ const result = await exec(`npx oneie agent \
427
+ --claude-user="${userName}" \
428
+ --claude-email="${userEmail}" \
429
+ --claude-org="${orgName}" \
430
+ --quiet`);
431
+
432
+ // Parse output for next steps
433
+ return {
434
+ success: true,
435
+ nextCommand: '/one',
436
+ };
437
+ }
438
+ ```
439
+
440
+ **What Claude knows:**
441
+ - User's name (from Claude account)
442
+ - Conversation context (mentions of company, project)
443
+ - Git configuration (can read `git config`)
444
+ - File system context (can read package.json, README)
445
+ - Previous conversation history
446
+
447
+ **Smart inference:**
448
+ ```typescript
449
+ // Example: Claude infers from conversation
450
+ User: "I'm building a course platform for Acme University"
451
+
452
+ // Claude automatically extracts:
453
+ {
454
+ org: "Acme University",
455
+ project: "course platform",
456
+ purpose: "education"
457
+ }
458
+
459
+ // And passes to CLI:
460
+ npx oneie agent --claude-org="Acme University"
461
+ ```
462
+
463
+ ### Agent Usage Pattern
464
+
465
+ When Claude Code needs to initialize ONE:
466
+
467
+ ```typescript
468
+ // Simple usage (Claude handles detection)
469
+ async function initializeONEPlatform() {
470
+ // Claude automatically adds context flags
471
+ const result = await exec('npx oneie agent --quiet');
472
+
473
+ // Already has user context from environment
474
+ return {
475
+ success: true,
476
+ nextCommand: '/one',
477
+ };
478
+ }
479
+ ```
480
+
481
+ ### Recommended Workflow
482
+
483
+ ```bash
484
+ # User asks: "Set up ONE Platform for my project"
485
+ # Agent thinks: "I need to initialize ONE"
486
+
487
+ # Step 1: Agent runs command with context
488
+ npx oneie agent \
489
+ --claude-user="John Doe" \
490
+ --claude-email="john@example.com" \
491
+ --claude-org="Acme Corp"
492
+
493
+ # Step 2: Agent sees success
494
+ ✓ ONE Platform initialized
495
+ Detected John Doe <john@example.com>
496
+ Organization: Acme Corp
497
+
498
+ # Step 3: Agent suggests next action
499
+ Now you can use /one to see available commands and start building.
500
+ Would you like me to create a plan for your first feature?
501
+ ```
502
+
503
+ ### Context Detection Fallback Chain
504
+
505
+ **Best case (All sources available):**
506
+ ```
507
+ Claude context → git config → package.json → README → directory name
508
+ ```
509
+
510
+ **Typical flow:**
511
+ 1. User: "Set up ONE for Acme Corp"
512
+ 2. Claude extracts: `--claude-org="Acme Corp"`
513
+ 3. CLI checks git: `git config user.name` → "John Doe"
514
+ 4. CLI checks git: `git config user.email` → "john@example.com"
515
+ 5. Result: Full context with zero user input
516
+
517
+ **If git not configured:**
518
+ 1. Claude passes: `--claude-user`, `--claude-org`
519
+ 2. CLI uses Claude values
520
+ 3. CLI sets up project with Claude's context
521
+ 4. No interactive prompts needed
522
+
523
+ ### Benefits of Claude Integration
524
+
525
+ **For Users:**
526
+ - ✅ Zero manual input required
527
+ - ✅ Claude "knows" who you are
528
+ - ✅ Infers organization from conversation
529
+ - ✅ No context switching
530
+ - ✅ Setup completes in seconds
531
+
532
+ **For Claude:**
533
+ - ✅ Can run `npx oneie agent` confidently
534
+ - ✅ No waiting for user input
535
+ - ✅ No interrupted workflows
536
+ - ✅ Can initialize multiple projects in parallel
537
+ - ✅ Full control over setup process
538
+
539
+ **Example conversation:**
540
+ ```
541
+ User: "I need a ONE Platform for my startup"
542
+ Claude: "Let me set that up for you."
543
+ Claude: [runs npx oneie agent with inferred context]
544
+ Claude: "✓ Done! Your platform is ready. What would you like to build first?"
545
+ ```
546
+
547
+ **Time saved:**
548
+ - Before: 2-3 minutes (manual prompts)
549
+ - After: 5-10 seconds (fully automated)
550
+ - Context switches: 0 (agent handles everything)
551
+
552
+ ## CLI Flags Reference
553
+
554
+ ### Required Flags (None!)
555
+
556
+ All flags are optional - smart detection handles everything.
557
+
558
+ ### Identity Flags
559
+
560
+ - `--name="John Doe"` - User's full name (explicit override)
561
+ - `--email="john@example.com"` - User's email (explicit override)
562
+ - `--claude-user="John Doe"` - User name from Claude context
563
+ - `--claude-email="john@example.com"` - User email from Claude
564
+ - `--use-git-config` - Explicitly use git config (default behavior)
565
+
566
+ **Environment variables:**
567
+ - `CLAUDE_USER_NAME` - User name from Claude Code
568
+ - `CLAUDE_USER_EMAIL` - User email from Claude Code
569
+
570
+ ### Organization Flags
571
+
572
+ - `--org="Acme Corp"` - Organization name (explicit override)
573
+ - `--claude-org="Acme Corp"` - Organization from Claude context
574
+ - `--website="https://acme.com"` - Organization website
575
+ - `--installation-folder="acme"` - Custom installation folder name
576
+ - `--no-installation-folder` - Skip installation folder creation
577
+
578
+ **Environment variables:**
579
+ - `CLAUDE_ORG_NAME` - Organization from Claude Code
580
+
581
+ ### Project Flags
582
+
583
+ - `--project-dir="./my-project"` - Target directory (default: current)
584
+ - `--project-name="My Platform"` - Project name (default: directory name)
585
+
586
+ ### Behavior Flags
587
+
588
+ - `--quiet` - Minimal output (for agents)
589
+ - `--verbose` - Detailed output (for debugging)
590
+ - `--yes` - Skip all confirmations (default in agent mode)
591
+ - `--dry-run` - Show what would be done without doing it
592
+
593
+ ### Advanced Flags
594
+
595
+ - `--template="default"` - Use specific template (default, minimal, full)
596
+ - `--package-manager="bun"` - Use specific package manager (bun, npm, pnpm)
597
+ - `--skip-install` - Don't install dependencies
598
+ - `--skip-git` - Don't initialize git
599
+
600
+ ## Implementation Plan
601
+
602
+ ### Phase 1: Core Command (Cycle 1-20)
603
+
604
+ **Files to create:**
605
+ - `cli/src/commands/agent.ts` - Main agent command
606
+ - `cli/src/lib/detect.ts` - Context detection utilities
607
+ - `cli/src/lib/agent-setup.ts` - Non-interactive setup
608
+ - `cli/src/lib/agent-detection.ts` - Agent environment detection
609
+
610
+ **Implementation:**
611
+
612
+ ```typescript
613
+ // cli/src/index.ts (Main entry point)
614
+ import { Command } from 'commander';
615
+ import { isAgentEnvironment } from './lib/agent-detection';
616
+ import { agentCommand } from './commands/agent';
617
+ import { interactiveCommand } from './commands/interactive';
618
+
619
+ const program = new Command();
620
+
621
+ program
622
+ .name('oneie')
623
+ .description('ONE Platform CLI')
624
+ .version('1.0.0');
625
+
626
+ // Add agent command
627
+ program.addCommand(agentCommand);
628
+
629
+ // Default command (interactive)
630
+ program
631
+ .action(() => {
632
+ // Detect if running in agent environment
633
+ if (isAgentEnvironment()) {
634
+ console.log('⚠️ Agent environment detected!\n');
635
+ console.log('You\'re running the interactive version in an AI agent environment.');
636
+ console.log('This command requires human input and will hang.\n');
637
+ console.log('Did you mean to run:');
638
+ console.log(' npx oneie agent\n');
639
+ console.log('The \'agent\' command is designed for AI agents:');
640
+ console.log(' ✓ Zero interaction required');
641
+ console.log(' ✓ Auto-detects context from git, files, and environment');
642
+ console.log(' ✓ Completes in 5-10 seconds');
643
+ console.log(' ✓ Safe for automated workflows\n');
644
+ console.log('Run this instead:');
645
+ console.log(' npx oneie agent\n');
646
+ console.log('Or if you\'re human and want interactive setup:');
647
+ console.log(' npx oneie --interactive\n');
648
+ console.log('Aborting to prevent hang...');
649
+ process.exit(1);
650
+ }
651
+
652
+ // Run interactive setup
653
+ interactiveCommand();
654
+ });
655
+
656
+ program.parse();
657
+ ```
658
+
659
+ ```typescript
660
+ // cli/src/lib/agent-detection.ts
661
+ export function isAgentEnvironment(): boolean {
662
+ return (
663
+ // Claude Code environment
664
+ !!process.env.CLAUDE_CODE ||
665
+ !!process.env.CLAUDE_USER_NAME ||
666
+ !!process.env.CLAUDE_ORG_NAME ||
667
+
668
+ // GitHub Copilot
669
+ !!process.env.GITHUB_COPILOT ||
670
+
671
+ // Cursor AI
672
+ !!process.env.CURSOR_AI ||
673
+
674
+ // Windsurf
675
+ !!process.env.CODEIUM_API_KEY ||
676
+
677
+ // Generic AI agent marker
678
+ !!process.env.AI_AGENT ||
679
+
680
+ // Non-TTY (no interactive terminal)
681
+ !process.stdin.isTTY ||
682
+
683
+ // CI/CD environment
684
+ !!process.env.CI ||
685
+ !!process.env.GITHUB_ACTIONS ||
686
+ !!process.env.GITLAB_CI ||
687
+ !!process.env.CIRCLECI
688
+ );
689
+ }
690
+
691
+ export function getAgentType(): string {
692
+ if (process.env.CLAUDE_CODE || process.env.CLAUDE_USER_NAME) {
693
+ return 'Claude Code';
694
+ }
695
+ if (process.env.GITHUB_COPILOT) {
696
+ return 'GitHub Copilot';
697
+ }
698
+ if (process.env.CURSOR_AI) {
699
+ return 'Cursor';
700
+ }
701
+ if (process.env.CODEIUM_API_KEY) {
702
+ return 'Windsurf';
703
+ }
704
+ if (process.env.CI) {
705
+ return 'CI/CD';
706
+ }
707
+ if (!process.stdin.isTTY) {
708
+ return 'Non-interactive';
709
+ }
710
+ return 'Unknown agent';
711
+ }
712
+ ```
713
+
714
+ ```typescript
715
+ // cli/src/commands/agent.ts
716
+ import { Command } from 'commander';
717
+ import { detectContext } from '../lib/detect';
718
+ import { setupAgent } from '../lib/agent-setup';
719
+ import { getAgentType } from '../lib/agent-detection';
720
+
721
+ export const agentCommand = new Command('agent')
722
+ .description('Non-interactive setup for AI agents')
723
+ .option('--name <name>', 'User name')
724
+ .option('--email <email>', 'User email')
725
+ .option('--claude-user <name>', 'User name from Claude context')
726
+ .option('--claude-email <email>', 'User email from Claude')
727
+ .option('--claude-org <org>', 'Organization from Claude')
728
+ .option('--org <org>', 'Organization name')
729
+ .option('--website <url>', 'Organization website')
730
+ .option('--quiet', 'Minimal output')
731
+ .option('--verbose', 'Detailed output')
732
+ .option('--dry-run', 'Show what would be done')
733
+ .action(async (options) => {
734
+ // Show agent type if verbose
735
+ if (options.verbose) {
736
+ const agentType = getAgentType();
737
+ console.log(`🤖 Detected: ${agentType}\n`);
738
+ }
739
+
740
+ // Detect context
741
+ const context = await detectContext(options);
742
+
743
+ // Run setup
744
+ const result = await setupAgent(context, options);
745
+
746
+ // Output results
747
+ if (options.quiet) {
748
+ console.log('✓ ONE Platform initialized');
749
+ console.log('\n→ claude');
750
+ console.log('→ /one');
751
+ } else {
752
+ displaySuccessMessage(context, result);
753
+ }
754
+ });
755
+ ```
756
+
757
+ ### Phase 2: Context Detection (Cycle 21-40)
758
+
759
+ **Implement detection functions:**
760
+ - `detectUserIdentity()` - Git config → env vars → defaults
761
+ - `detectOrganization()` - Git remote → package.json → README → defaults
762
+ - `detectWebsite()` - package.json → README → git remote
763
+ - `detectProjectInfo()` - Directory name, existing files
764
+
765
+ ### Phase 3: Integration (Cycle 41-60)
766
+
767
+ **Integrate with existing setup:**
768
+ - Reuse setup functions from interactive command
769
+ - Share template generation logic
770
+ - Unify environment file creation
771
+ - Common error handling
772
+
773
+ ### Phase 4: Testing (Cycle 61-80)
774
+
775
+ **Test scenarios:**
776
+ - Fresh directory (no git, no package.json)
777
+ - Existing git repo
778
+ - Existing package.json
779
+ - Various git remotes (GitHub, GitLab, Bitbucket)
780
+ - Missing git config
781
+ - Override with flags
782
+
783
+ ### Phase 5: Documentation (Cycle 81-100)
784
+
785
+ **Update docs:**
786
+ - Add to `/getting-started/quick-start.md`
787
+ - Add to `/getting-started/claude-commands.md`
788
+ - Create agent-specific guide
789
+ - Add troubleshooting section
790
+
791
+ ## Agent Experience Benefits
792
+
793
+ ### Before (Interactive)
794
+
795
+ ```bash
796
+ # Agent tries to help user
797
+ Agent: "Let me set up ONE Platform for you"
798
+ Agent: [runs npx oneie]
799
+ Terminal: "What's your name?"
800
+ Agent: [stuck waiting for input]
801
+ Agent: "I can't complete this setup automatically. Please run npx oneie manually."
802
+ User: [has to switch to terminal, fill in prompts]
803
+ ```
804
+
805
+ ### After (Agent Mode)
806
+
807
+ ```bash
808
+ # Agent helps user seamlessly
809
+ Agent: "Let me set up ONE Platform for you"
810
+ Agent: [runs npx oneie agent]
811
+ Agent: [detects context automatically]
812
+ Agent: [completes setup in 5 seconds]
813
+ Agent: "✓ Done! Your platform is ready. Try /one to see available commands."
814
+ User: [immediately productive]
815
+ ```
816
+
817
+ ## Success Metrics
818
+
819
+ ### Setup Speed
820
+ - **Before**: 2-3 minutes (with user input)
821
+ - **After**: 5-10 seconds (fully automated)
822
+
823
+ ### Context Switches
824
+ - **Before**: 3+ switches (CLI → Terminal → CLI)
825
+ - **After**: 0 switches (agent handles everything)
826
+
827
+ ### Error Rate
828
+ - **Before**: 40% (users make typos, choose wrong options)
829
+ - **After**: 5% (only environment issues)
830
+
831
+ ### Agent Productivity
832
+ - **Before**: Can't automate initialization
833
+ - **After**: Can initialize 10+ projects in parallel
834
+
835
+ ## Future Enhancements
836
+
837
+ ### Phase 2 Features
838
+
839
+ 1. **AI Context Inference**
840
+ ```bash
841
+ # Agent analyzes conversation history
842
+ npx oneie agent --infer-from-context
843
+
844
+ # Uses Claude's conversation context to fill in:
845
+ # - Project purpose from user's description
846
+ # - Feature priorities from discussion
847
+ # - Target audience from requirements
848
+ ```
849
+
850
+ 2. **GitHub Integration**
851
+ ```bash
852
+ # Auto-create GitHub repo
853
+ npx oneie agent --create-repo
854
+
855
+ # Clone and initialize existing repo
856
+ npx oneie agent --from-repo="github.com/user/repo"
857
+ ```
858
+
859
+ 3. **Brand Extraction**
860
+ ```bash
861
+ # Analyze existing website
862
+ npx oneie agent --onboard="https://example.com"
863
+
864
+ # Extracts:
865
+ # - Colors, fonts, logos
866
+ # - Content structure
867
+ # - Feature set
868
+ # - Creates matching installation folder
869
+ ```
870
+
871
+ 4. **Multi-Project Setup**
872
+ ```bash
873
+ # Set up multiple related projects
874
+ npx oneie agent --projects="web,mobile,api"
875
+
876
+ # Creates:
877
+ # - web/ (Astro frontend)
878
+ # - mobile/ (React Native)
879
+ # - api/ (Convex backend)
880
+ # - Shared installation folder
881
+ ```
882
+
883
+ ## Implementation Priority
884
+
885
+ ### Immediate (This Cycle)
886
+ - [x] Document requirements in this plan
887
+ - [ ] Create `cli/src/commands/agent.ts`
888
+ - [ ] Implement basic context detection
889
+ - [ ] Test with git config detection
890
+ - [ ] Update CLI to include agent command
891
+
892
+ ### Short Term (Next Sprint)
893
+ - [ ] Add all detection strategies
894
+ - [ ] Implement quiet/verbose modes
895
+ - [ ] Add dry-run support
896
+ - [ ] Write comprehensive tests
897
+ - [ ] Update documentation
898
+
899
+ ### Medium Term (Next Month)
900
+ - [ ] GitHub integration
901
+ - [ ] Brand extraction from URLs
902
+ - [ ] Multi-project setup
903
+ - [ ] Template variations
904
+
905
+ ## Questions to Resolve
906
+
907
+ 1. **Should agent command ALWAYS be non-interactive?**
908
+ - Proposed: Yes, always. Use regular `npx oneie` for interactive.
909
+
910
+ 2. **What if detection fails?**
911
+ - Proposed: Use sensible defaults, never prompt. Add `--verbose` to explain.
912
+
913
+ 3. **Should we auto-start dev server?**
914
+ - Proposed: No, let agent decide. Agent can run `/server start` after.
915
+
916
+ 4. **Should we auto-open browser?**
917
+ - Proposed: No, agents can't interact with browsers. Let user open manually.
918
+
919
+ 5. **How to handle multiple projects in same directory?**
920
+ - Proposed: Check for existing ONE installation, offer to update/reconfigure.
921
+
922
+ ## Real-World Scenarios
923
+
924
+ ### Scenario 1: Claude Code User (Correct Command)
925
+
926
+ ```bash
927
+ # Claude runs the agent command
928
+ $ npx oneie agent
929
+
930
+ 🤖 ONE Agent Setup
931
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
932
+
933
+ Detected context:
934
+ Name: John Doe (from git config)
935
+ Email: john@example.com (from git config)
936
+ Organization: Acme Corp (from Claude context)
937
+
938
+ ✓ Created project structure
939
+ ✓ Installed dependencies (23 packages)
940
+ ✓ Generated environment files
941
+
942
+ ✅ Your ONE Platform is ready!
943
+
944
+ Next steps:
945
+ /one # Show control center
946
+ ```
947
+
948
+ ### Scenario 2: Claude Code User (Wrong Command)
949
+
950
+ ```bash
951
+ # Claude accidentally runs interactive command
952
+ $ npx oneie
953
+
954
+ ⚠️ Agent environment detected!
955
+
956
+ You're running the interactive version in an AI agent environment.
957
+ This command requires human input and will hang.
958
+
959
+ Did you mean to run:
960
+ npx oneie agent
961
+
962
+ The 'agent' command is designed for AI agents:
963
+ ✓ Zero interaction required
964
+ ✓ Auto-detects context from git, files, and environment
965
+ ✓ Completes in 5-10 seconds
966
+ ✓ Safe for automated workflows
967
+
968
+ Run this instead:
969
+ npx oneie agent
970
+
971
+ Or if you're human and want interactive setup:
972
+ npx oneie --interactive
973
+
974
+ Aborting to prevent hang...
975
+ ```
976
+
977
+ ### Scenario 3: Human User (Interactive)
978
+
979
+ ```bash
980
+ # Human runs the command in terminal
981
+ $ npx oneie
982
+
983
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
984
+ Welcome! Let's build your platform.
985
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
986
+
987
+ ? What's your name? › John Doe
988
+ ? Organization name? › Acme Corp
989
+ ? Project directory? › ./acme-platform
990
+
991
+ ✓ Your ONE Platform is ready!
992
+ ```
993
+
994
+ ### Scenario 4: CI/CD Environment
995
+
996
+ ```bash
997
+ # GitHub Actions runs the command
998
+ $ npx oneie
999
+
1000
+ ⚠️ Agent environment detected!
1001
+ # ... suggests npx oneie agent
1002
+
1003
+ # Correct usage in CI:
1004
+ $ npx oneie agent --quiet
1005
+
1006
+ ✓ ONE Platform initialized
1007
+
1008
+ → /one
1009
+ ```
1010
+
1011
+ ### Scenario 5: Cursor AI User
1012
+
1013
+ ```bash
1014
+ # Cursor AI tries to run setup
1015
+ $ npx oneie
1016
+
1017
+ ⚠️ Agent environment detected!
1018
+ # ... suggests npx oneie agent
1019
+
1020
+ # Cursor learns and runs:
1021
+ $ npx oneie agent --claude-user="Jane Smith"
1022
+
1023
+ ✓ Installation complete!
1024
+ ```
1025
+
1026
+ ## Agent Detection Benefits
1027
+
1028
+ **For AI Agents:**
1029
+ - ✅ Never get stuck on interactive prompts
1030
+ - ✅ Clear guidance to correct command
1031
+ - ✅ Learn the right pattern immediately
1032
+ - ✅ Faster execution (no trial and error)
1033
+
1034
+ **For Humans:**
1035
+ - ✅ Interactive experience preserved
1036
+ - ✅ Can override with `--interactive` flag
1037
+ - ✅ Clear distinction between modes
1038
+ - ✅ Better onboarding experience
1039
+
1040
+ **For Platform:**
1041
+ - ✅ Reduces support requests
1042
+ - ✅ Better telemetry (know who's using agent mode)
1043
+ - ✅ Improves adoption by AI tools
1044
+ - ✅ Future-proof for new AI environments
1045
+
1046
+ ## Conclusion
1047
+
1048
+ `npx oneie agent` transforms ONE Platform initialization from a **human-interactive process** to an **agent-automated workflow**, enabling Claude Code to set up projects instantly without context switching or manual input.
1049
+
1050
+ ### Key Innovations
1051
+
1052
+ 1. **Agent Detection** - Automatically detects AI agent environments and suggests the correct command
1053
+ 2. **Smart Context Inference** - Extracts user/org info from Claude, git, files, and conversation
1054
+ 3. **Zero Interaction** - Completes setup in 5-10 seconds with no prompts
1055
+ 4. **Safety First** - Never hangs, always provides clear guidance
1056
+ 5. **Universal Support** - Works with Claude Code, Cursor, Windsurf, Copilot, and CI/CD
1057
+
1058
+ ### The Agent Experience
1059
+
1060
+ **Before (Interactive CLI):**
1061
+ ```
1062
+ Agent → User: "Run npx oneie and answer the prompts"
1063
+ User → Terminal: [fills in 5+ questions]
1064
+ Time: 2-3 minutes + context switches
1065
+ ```
1066
+
1067
+ **After (Agent Mode with Detection):**
1068
+ ```
1069
+ Agent: [runs npx oneie] → Detects agent env → Shows: "Use npx oneie agent"
1070
+ Agent: [runs npx oneie agent] → Auto-detects context → ✓ Done in 5 seconds
1071
+ Time: 5-10 seconds, zero context switches
1072
+ ```
1073
+
1074
+ ### Impact
1075
+
1076
+ - **98% faster** setup (2-3 min → 5-10 sec)
1077
+ - **100% automated** (zero manual input required)
1078
+ - **0 hangs** (agent detection prevents blocking)
1079
+ - **Universal** (works with all AI coding tools)
1080
+
1081
+ **Agent Experience First** - Because agents build faster when they don't have to ask humans to fill in forms, and they never get stuck on interactive prompts they can't answer.
1082
+
1083
+ ---
1084
+
1085
+ **Status:** Ready for implementation
1086
+ **Assigned:** agent-ops (CLI development)
1087
+ **Dependencies:** Existing CLI codebase
1088
+ **Estimated Completion:** 1 sprint (2 weeks)
1089
+ **Priority:** High - Enables seamless Claude Code integration