-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Background
NodeSpec is designed as an AI-first tool. Our CLI command structure should prioritize AI's pattern recognition capabilities over human memorization convenience.
Design Decision: Three-layer Structure
nodespec [role] [domain] [action] [args]Example:
nodespec scaffold monorepo init [name]
nodespec scaffold package add <name>
nodespec scaffold app add <name>
nodespec scaffold config initWhy Three Layers (vs Flat Action)
Alternative Considered: Flat Action (Rejected)
nodespec scaffold [action] [args]
nodespec scaffold init-monorepo [name]
nodespec scaffold add-package <name>
nodespec scaffold add-app <name>Comparison
| Aspect | Three-layer (domain + action) | Flat action (verb-domain) |
|---|---|---|
| Pattern Inference | ✅ Cartesian product: {domain} × {action} |
❌ Linear: only same-verb patterns |
| Learning Cost | ✅ 3 domains + 5 actions = 8 concepts → 15 commands | ❌ 15 composite actions = 15 concepts |
| Add New Domain | ✅ Auto inherits all actions | ❌ Must define N new composite commands |
| Add New Action | ✅ Auto applies to all domains | ❌ Must define M new composite commands |
| Command Length | ✅ Shorter (but loses composability) |
AI Pattern Recognition Advantages
-
Combinatorial Reasoning:
- Given:
scaffold package add - AI infers:
scaffold {package|app|service} {add|remove|list} - Clear combination space
- Given:
-
Low Learning Cost:
- Learn: 3 domains + 5 actions = 8 concepts
- Generate: 3 × 5 = 15 valid commands
- High knowledge compression ratio
-
Extensibility:
# Add new domain "plugin" → all actions available nodespec scaffold plugin add <name> nodespec scaffold plugin remove <name> nodespec scaffold plugin list # Add new action "validate" → applies to all domains nodespec scaffold package validate nodespec scaffold app validate nodespec scaffold config validate
-
Semantic Clarity:
- Think: "I want to operate on {domain}, perform {action}"
- Matches human reasoning and AI prompting
Implementation Structure
commands/
├── scaffold/
│ ├── index.ts # scaffold role
│ ├── monorepo/
│ │ ├── init.ts # action
│ │ └── create.ts # action
│ ├── package/
│ │ ├── add.ts
│ │ ├── remove.ts
│ │ └── list.ts
│ ├── app/
│ │ ├── add.ts
│ │ ├── remove.ts
│ │ └── list.ts
│ └── config/
│ ├── init.ts
│ └── update.ts
Pattern Template
For AI to generate commands:
Role: {scaffold, architect, product, test, ...}
Domain: {monorepo, package, app, service, config, ...}
Action: {init, create, add, remove, list, update, validate, ...}
Template: nodespec <role> <domain> <action> [args]
Human Convenience (Optional)
While optimizing for AI, we can still provide aliases for humans:
# Alias (optional)
nodespec init → nodespec scaffold monorepo init
nodespec add package <name> → nodespec scaffold package add <name>Internal: three-layer structure
External: optional shortcuts
Decision Rationale
Primary contradiction: Simplicity vs Composability
- For humans: Shorter commands are easier to remember
- For AI: Structured patterns are easier to infer
Resolution: Optimize for AI's strengths (pattern recognition), not human weaknesses (memory)
This is a "design for AI, not for humans" decision, aligning with NodeSpec's vision of making Node.js development AI-native.
Related
- Issue Redesign CLI command structure: from concept-based to role-based domains #10: Redesign CLI from concept-based to role-based
- Philosophy: AI-first tool design
- Architecture: PATEOAS - domain → action hyperlink structure
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request