luna-agents 2.0.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.
- package/.claude-plugin/LICENSE +21 -0
- package/.claude-plugin/README.md +285 -0
- package/.claude-plugin/claude-plugin.json +106 -0
- package/.claude-plugin/index.js +318 -0
- package/.claude-plugin/lib/api-client.js +504 -0
- package/.claude-plugin/lib/rag-utils.js +442 -0
- package/.claude-plugin/package.json +418 -0
- package/LICENSE +21 -0
- package/README.md +350 -0
- package/agents/json/design-architect.json +57 -0
- package/agents/json/luna-auth.json +71 -0
- package/agents/json/luna-brand.json +66 -0
- package/agents/json/luna-cloudflare.json +261 -0
- package/agents/json/luna-code-review.json +63 -0
- package/agents/json/luna-deployment.json +68 -0
- package/agents/json/luna-documentation.json +85 -0
- package/agents/json/luna-hig.json +128 -0
- package/agents/json/luna-layout-designer.json +178 -0
- package/agents/json/luna-monitoring-observability.json +64 -0
- package/agents/json/luna-post-launch-review.json +68 -0
- package/agents/json/luna-requirements-analyzer.json +53 -0
- package/agents/json/luna-task-executor.json +63 -0
- package/agents/json/luna-task-planner.json +62 -0
- package/agents/json/luna-testing-validation.json +66 -0
- package/agents/luna-365-security.md +96 -0
- package/agents/luna-analytics.md +318 -0
- package/agents/luna-api-generator.md +654 -0
- package/agents/luna-auth.md +396 -0
- package/agents/luna-brand.md +248 -0
- package/agents/luna-cloudflare.md +728 -0
- package/agents/luna-code-review.md +487 -0
- package/agents/luna-database.md +453 -0
- package/agents/luna-deployment.md +202 -0
- package/agents/luna-design-architect.md +353 -0
- package/agents/luna-docker.md +615 -0
- package/agents/luna-documentation.md +177 -0
- package/agents/luna-full-test.md +910 -0
- package/agents/luna-glm-vision.md +211 -0
- package/agents/luna-hig.md +430 -0
- package/agents/luna-lemonsqueezy.md +441 -0
- package/agents/luna-monitoring-observability.md +199 -0
- package/agents/luna-openai-app.md +499 -0
- package/agents/luna-post-launch-review.md +191 -0
- package/agents/luna-rag-enhanced.md +1619 -0
- package/agents/luna-rag.md +1733 -0
- package/agents/luna-requirements-analyzer.md +189 -0
- package/agents/luna-run.md +620 -0
- package/agents/luna-seo.md +338 -0
- package/agents/luna-task-executor.md +371 -0
- package/agents/luna-task-planner.md +275 -0
- package/agents/luna-testing-validation.md +681 -0
- package/agents/luna-ui-fix.md +591 -0
- package/agents/luna-ui-test.md +600 -0
- package/agents/luna-user-guide.md +409 -0
- package/agents/site-auditor.md +83 -0
- package/commands/3d-mesh.md +12 -0
- package/commands/3d.md +12 -0
- package/commands/agent-boost.md +13 -0
- package/commands/ai-index.md +16 -0
- package/commands/api.md +12 -0
- package/commands/assert.md +17 -0
- package/commands/audience.md +12 -0
- package/commands/auth.md +17 -0
- package/commands/autopilot.md +12 -0
- package/commands/boost-finsavvy.md +10 -0
- package/commands/boost-org.md +10 -0
- package/commands/boost-project.md +12 -0
- package/commands/brand.md +17 -0
- package/commands/browser-test.md +18 -0
- package/commands/cf.md +26 -0
- package/commands/cfg.md +33 -0
- package/commands/chain.md +12 -0
- package/commands/challenge.md +13 -0
- package/commands/clone.md +12 -0
- package/commands/cmds.md +243 -0
- package/commands/collab.md +12 -0
- package/commands/compete.md +12 -0
- package/commands/config-rules.md +21 -0
- package/commands/connect-infra.md +10 -0
- package/commands/context-pack.md +13 -0
- package/commands/curb.md +12 -0
- package/commands/des.md +38 -0
- package/commands/devto.md +20 -0
- package/commands/dock.md +26 -0
- package/commands/docs.md +33 -0
- package/commands/e2e-flow.md +18 -0
- package/commands/email-routing.md +10 -0
- package/commands/feature.md +12 -0
- package/commands/figma.md +12 -0
- package/commands/fix.md +12 -0
- package/commands/flaky.md +12 -0
- package/commands/flow-record.md +12 -0
- package/commands/gamify.md +12 -0
- package/commands/ghost.md +12 -0
- package/commands/git-insights.md +12 -0
- package/commands/go-viral.md +16 -0
- package/commands/go.md +42 -0
- package/commands/graph-rag.md +13 -0
- package/commands/guard.md +12 -0
- package/commands/heal.md +17 -0
- package/commands/heygen.md +12 -0
- package/commands/hig.md +33 -0
- package/commands/idea.md +12 -0
- package/commands/imagine.md +12 -0
- package/commands/inbox.md +12 -0
- package/commands/lam.md +12 -0
- package/commands/landing.md +12 -0
- package/commands/launch.md +12 -0
- package/commands/learn.md +12 -0
- package/commands/leverage.md +12 -0
- package/commands/ll-365-secure.md +179 -0
- package/commands/ll-3d-mesh.md +94 -0
- package/commands/ll-3d.md +123 -0
- package/commands/ll-a11y-scan.md +143 -0
- package/commands/ll-a11y.md +71 -0
- package/commands/ll-agent-boost.md +92 -0
- package/commands/ll-agent-chain.md +104 -0
- package/commands/ll-ai-index.md +120 -0
- package/commands/ll-api-client.md +77 -0
- package/commands/ll-api.md +99 -0
- package/commands/ll-assert.md +73 -0
- package/commands/ll-audience.md +308 -0
- package/commands/ll-auth.md +145 -0
- package/commands/ll-autopilot.md +113 -0
- package/commands/ll-boost-finsavvy.md +106 -0
- package/commands/ll-boost-org.md +161 -0
- package/commands/ll-boost-project.md +118 -0
- package/commands/ll-brand.md +150 -0
- package/commands/ll-browser-test.md +203 -0
- package/commands/ll-challenge.md +124 -0
- package/commands/ll-changelog.md +80 -0
- package/commands/ll-ci.md +78 -0
- package/commands/ll-claude-instructions.md +80 -0
- package/commands/ll-clone.md +82 -0
- package/commands/ll-cloudflare.md +580 -0
- package/commands/ll-codemap.md +78 -0
- package/commands/ll-collab.md +87 -0
- package/commands/ll-compete.md +67 -0
- package/commands/ll-config-rules.md +255 -0
- package/commands/ll-config.md +434 -0
- package/commands/ll-connect-infra.md +123 -0
- package/commands/ll-context-pack.md +100 -0
- package/commands/ll-curb.md +164 -0
- package/commands/ll-debug.md +76 -0
- package/commands/ll-deploy.md +101 -0
- package/commands/ll-deps.md +70 -0
- package/commands/ll-design.md +86 -0
- package/commands/ll-devto-publish.md +172 -0
- package/commands/ll-dockerize.md +273 -0
- package/commands/ll-docs.md +123 -0
- package/commands/ll-e2e-flow.md +132 -0
- package/commands/ll-e2e-test.md +231 -0
- package/commands/ll-email-routing.md +130 -0
- package/commands/ll-env.md +70 -0
- package/commands/ll-execute.md +98 -0
- package/commands/ll-feature.md +80 -0
- package/commands/ll-figma.md +82 -0
- package/commands/ll-fix.md +76 -0
- package/commands/ll-flaky.md +151 -0
- package/commands/ll-flow-record.md +180 -0
- package/commands/ll-flowdocs.md +83 -0
- package/commands/ll-gamify.md +131 -0
- package/commands/ll-gemma4.md +84 -0
- package/commands/ll-ghost.md +79 -0
- package/commands/ll-git-insights.md +152 -0
- package/commands/ll-go-viral.md +171 -0
- package/commands/ll-graph-rag.md +113 -0
- package/commands/ll-guard.md +92 -0
- package/commands/ll-heal.md +135 -0
- package/commands/ll-heygen.md +203 -0
- package/commands/ll-hig.md +578 -0
- package/commands/ll-hld.md +84 -0
- package/commands/ll-i18n.md +74 -0
- package/commands/ll-idea.md +101 -0
- package/commands/ll-imagine.md +72 -0
- package/commands/ll-inbox.md +116 -0
- package/commands/ll-lam.md +93 -0
- package/commands/ll-landing.md +171 -0
- package/commands/ll-launch.md +100 -0
- package/commands/ll-learn.md +87 -0
- package/commands/ll-leverage.md +137 -0
- package/commands/ll-local-llm.md +131 -0
- package/commands/ll-ls-products.md +160 -0
- package/commands/ll-marketplace.md +130 -0
- package/commands/ll-mcp-publish.md +104 -0
- package/commands/ll-migrate.md +68 -0
- package/commands/ll-mock.md +79 -0
- package/commands/ll-money.md +87 -0
- package/commands/ll-monitor.md +120 -0
- package/commands/ll-morph.md +117 -0
- package/commands/ll-multi-agent.md +170 -0
- package/commands/ll-native.md +93 -0
- package/commands/ll-nexa.md +79 -0
- package/commands/ll-onboarding.md +84 -0
- package/commands/ll-openhands.md +78 -0
- package/commands/ll-organic-promote.md +260 -0
- package/commands/ll-parallel.md +74 -0
- package/commands/ll-payments.md +83 -0
- package/commands/ll-perf-trace.md +147 -0
- package/commands/ll-perf.md +65 -0
- package/commands/ll-persona.md +280 -0
- package/commands/ll-pipe.md +296 -0
- package/commands/ll-plan-impl.js +570 -0
- package/commands/ll-plan-v2.md +297 -0
- package/commands/ll-plan.md +87 -0
- package/commands/ll-postlaunch.md +109 -0
- package/commands/ll-pr.md +84 -0
- package/commands/ll-present.md +110 -0
- package/commands/ll-product-map.md +152 -0
- package/commands/ll-promote.md +352 -0
- package/commands/ll-publish.md +124 -0
- package/commands/ll-pulse.md +96 -0
- package/commands/ll-rag-guided.md +345 -0
- package/commands/ll-rag-upgrade.md +504 -0
- package/commands/ll-rag.md +343 -0
- package/commands/ll-record.md +114 -0
- package/commands/ll-refactor.md +71 -0
- package/commands/ll-requirements.md +71 -0
- package/commands/ll-review.md +92 -0
- package/commands/ll-rollback.md +66 -0
- package/commands/ll-routemap.md +79 -0
- package/commands/ll-rules.md +90 -0
- package/commands/ll-shortcuts.md +229 -0
- package/commands/ll-sing.md +99 -0
- package/commands/ll-site-audit.md +228 -0
- package/commands/ll-smart-route.md +92 -0
- package/commands/ll-smart-search.md +58 -0
- package/commands/ll-storybook.md +86 -0
- package/commands/ll-swarm.md +101 -0
- package/commands/ll-test.md +97 -0
- package/commands/ll-time-machine.md +72 -0
- package/commands/ll-ui-convert.md +433 -0
- package/commands/ll-video.md +108 -0
- package/commands/ll-vision-pipeline.md +247 -0
- package/commands/ll-vision.md +74 -0
- package/commands/ll-visual-diff.md +118 -0
- package/commands/ll-visual-qa.md +204 -0
- package/commands/ll-visual-regression.md +96 -0
- package/commands/ll-voice.md +138 -0
- package/commands/ll-watch.md +65 -0
- package/commands/ll-workflow.md +108 -0
- package/commands/ll-zen.md +98 -0
- package/commands/local-llm.md +12 -0
- package/commands/marketplace.md +13 -0
- package/commands/mcp-publish.md +16 -0
- package/commands/migrate.md +12 -0
- package/commands/money.md +12 -0
- package/commands/morph.md +12 -0
- package/commands/multi-agent.md +12 -0
- package/commands/native.md +12 -0
- package/commands/nexa.md +12 -0
- package/commands/oh.md +12 -0
- package/commands/organic-promote.md +16 -0
- package/commands/perf-trace.md +12 -0
- package/commands/perf.md +12 -0
- package/commands/persona.md +12 -0
- package/commands/pipe.md +21 -0
- package/commands/plan.md +38 -0
- package/commands/pr.md +12 -0
- package/commands/present.md +12 -0
- package/commands/product-map.md +13 -0
- package/commands/promote.md +16 -0
- package/commands/publish.md +12 -0
- package/commands/pulse.md +12 -0
- package/commands/q.md +35 -0
- package/commands/record.md +12 -0
- package/commands/refactor.md +12 -0
- package/commands/req.md +40 -0
- package/commands/retro.md +33 -0
- package/commands/rev.md +39 -0
- package/commands/rules.md +19 -0
- package/commands/search.md +12 -0
- package/commands/sec.md +34 -0
- package/commands/ship.md +39 -0
- package/commands/sing.md +12 -0
- package/commands/site-audit.md +12 -0
- package/commands/smart-route.md +13 -0
- package/commands/swarm.md +12 -0
- package/commands/test.md +39 -0
- package/commands/time-machine.md +12 -0
- package/commands/ui.md +33 -0
- package/commands/video.md +12 -0
- package/commands/vision.md +12 -0
- package/commands/voice.md +12 -0
- package/commands/vr.md +18 -0
- package/commands/watch.md +39 -0
- package/commands/workflow.md +19 -0
- package/commands/zen.md +12 -0
- package/package.json +76 -0
- package/setup.sh +382 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Luna Plan Command Implementation (API Enhanced v2.0)
|
|
3
|
+
*
|
|
4
|
+
* Enhanced task planning with backend integration, RAG context, and real-time tracking
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
class LunaPlanCommand {
|
|
11
|
+
constructor(apiClient) {
|
|
12
|
+
this.apiClient = apiClient;
|
|
13
|
+
this.config = {
|
|
14
|
+
useRAG: true,
|
|
15
|
+
syncWithBackend: true,
|
|
16
|
+
priority: 'normal',
|
|
17
|
+
createTasks: true,
|
|
18
|
+
enableWebSocket: true
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Execute the luna-plan command
|
|
24
|
+
*/
|
|
25
|
+
async execute(options = {}) {
|
|
26
|
+
try {
|
|
27
|
+
console.log('🌙 Luna Task Planning v2.0 (API Enhanced)');
|
|
28
|
+
console.log('=====================================');
|
|
29
|
+
|
|
30
|
+
// Parse options
|
|
31
|
+
this.parseOptions(options);
|
|
32
|
+
|
|
33
|
+
// Check prerequisites
|
|
34
|
+
await this.checkPrerequisites();
|
|
35
|
+
|
|
36
|
+
// Execute workflow
|
|
37
|
+
const plan = await this.executeWorkflow();
|
|
38
|
+
|
|
39
|
+
// Display results
|
|
40
|
+
this.displayResults(plan);
|
|
41
|
+
|
|
42
|
+
return plan;
|
|
43
|
+
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('❌ Planning failed:', error.message);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parse command options
|
|
52
|
+
*/
|
|
53
|
+
parseOptions(options) {
|
|
54
|
+
if (options.useRAG !== undefined) this.config.useRAG = options.useRAG;
|
|
55
|
+
if (options.syncWithBackend !== undefined) this.config.syncWithBackend = options.syncWithBackend;
|
|
56
|
+
if (options.priority) this.config.priority = options.priority;
|
|
57
|
+
if (options.createTasks !== undefined) this.config.createTasks = options.createTasks;
|
|
58
|
+
if (options.enableWebSocket !== undefined) this.config.enableWebSocket = options.enableWebSocket;
|
|
59
|
+
|
|
60
|
+
console.log(`📋 Configuration:`);
|
|
61
|
+
console.log(` RAG Context: ${this.config.useRAG ? '✅ Enabled' : '❌ Disabled'}`);
|
|
62
|
+
console.log(` Backend Sync: ${this.config.syncWithBackend ? '✅ Enabled' : '❌ Disabled'}`);
|
|
63
|
+
console.log(` Priority: ${this.config.priority}`);
|
|
64
|
+
console.log('');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Check prerequisites
|
|
69
|
+
*/
|
|
70
|
+
async checkPrerequisites() {
|
|
71
|
+
console.log('🔍 Checking prerequisites...');
|
|
72
|
+
|
|
73
|
+
// Check API connection
|
|
74
|
+
if (this.config.syncWithBackend || this.config.useRAG) {
|
|
75
|
+
const status = await this.apiClient.getStatus();
|
|
76
|
+
if (!status.connected) {
|
|
77
|
+
throw new Error('API connection required. Run /luna-status to configure.');
|
|
78
|
+
}
|
|
79
|
+
console.log(' ✅ API connection established');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Check required files
|
|
83
|
+
const currentDir = process.cwd();
|
|
84
|
+
const projectName = this.detectProjectName(currentDir);
|
|
85
|
+
|
|
86
|
+
const designFile = path.join(currentDir, '.luna', projectName, 'design.md');
|
|
87
|
+
const requirementsFile = path.join(currentDir, '.luna', projectName, 'requirements.md');
|
|
88
|
+
|
|
89
|
+
if (!fs.existsSync(designFile)) {
|
|
90
|
+
console.log(` ⚠️ Design file not found: ${designFile}`);
|
|
91
|
+
console.log(' 💡 Run /luna-design first to create design document');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!fs.existsSync(requirementsFile)) {
|
|
95
|
+
console.log(` ⚠️ Requirements file not found: ${requirementsFile}`);
|
|
96
|
+
console.log(' 💡 Run /luna-requirements first to create requirements document');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
console.log(' ✅ Prerequisites checked');
|
|
100
|
+
console.log('');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Execute the planning workflow
|
|
105
|
+
*/
|
|
106
|
+
async executeWorkflow() {
|
|
107
|
+
const currentDir = process.cwd();
|
|
108
|
+
const projectName = this.detectProjectName(currentDir);
|
|
109
|
+
|
|
110
|
+
console.log('📖 Analyzing project documents...');
|
|
111
|
+
|
|
112
|
+
// Step 1: Read local documents
|
|
113
|
+
const localData = await this.readLocalDocuments(projectName);
|
|
114
|
+
|
|
115
|
+
// Step 2: Fetch RAG context if enabled
|
|
116
|
+
let ragContext = null;
|
|
117
|
+
if (this.config.useRAG) {
|
|
118
|
+
console.log('🧠 Fetching RAG context...');
|
|
119
|
+
ragContext = await this.fetchRAGContext(localData);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Step 3: Generate AI-enhanced plan
|
|
123
|
+
console.log('🤖 Generating AI-enhanced implementation plan...');
|
|
124
|
+
const plan = await this.generateImplementationPlan(localData, ragContext);
|
|
125
|
+
|
|
126
|
+
// Step 4: Sync with backend if enabled
|
|
127
|
+
let backendTasks = [];
|
|
128
|
+
if (this.config.syncWithBackend) {
|
|
129
|
+
console.log('🔄 Syncing with backend platform...');
|
|
130
|
+
backendTasks = await this.syncWithBackend(plan);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Step 5: Save local plan
|
|
134
|
+
await this.saveLocalPlan(plan, projectName, backendTasks);
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
...plan,
|
|
138
|
+
ragContext,
|
|
139
|
+
backendTasks,
|
|
140
|
+
projectName,
|
|
141
|
+
synced: this.config.syncWithBackend
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Read local documents
|
|
147
|
+
*/
|
|
148
|
+
async readLocalDocuments(projectName) {
|
|
149
|
+
const currentDir = process.cwd();
|
|
150
|
+
const designFile = path.join(currentDir, '.luna', projectName, 'design.md');
|
|
151
|
+
const requirementsFile = path.join(currentDir, '.luna', projectName, 'requirements.md');
|
|
152
|
+
|
|
153
|
+
const data = {
|
|
154
|
+
design: null,
|
|
155
|
+
requirements: null,
|
|
156
|
+
projectName,
|
|
157
|
+
projectPath: currentDir
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
if (fs.existsSync(designFile)) {
|
|
161
|
+
data.design = fs.readFileSync(designFile, 'utf8');
|
|
162
|
+
console.log(' ✅ Design document loaded');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (fs.existsSync(requirementsFile)) {
|
|
166
|
+
data.requirements = fs.readFileSync(requirementsFile, 'utf8');
|
|
167
|
+
console.log(' ✅ Requirements document loaded');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return data;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Fetch RAG context
|
|
175
|
+
*/
|
|
176
|
+
async fetchRAGContext(localData) {
|
|
177
|
+
try {
|
|
178
|
+
// Create context query based on local documents
|
|
179
|
+
const contextQuery = this.buildRAGQuery(localData);
|
|
180
|
+
|
|
181
|
+
const ragResponse = await this.apiClient.queryRAG(contextQuery, {
|
|
182
|
+
maxResults: 5,
|
|
183
|
+
minScore: 0.7,
|
|
184
|
+
includeMetadata: true
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
console.log(` ✅ Found ${ragResponse.contexts.length} relevant context items`);
|
|
188
|
+
|
|
189
|
+
return ragResponse;
|
|
190
|
+
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.log(` ⚠️ RAG context fetch failed: ${error.message}`);
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Build RAG query from local documents
|
|
199
|
+
*/
|
|
200
|
+
buildRAGQuery(localData) {
|
|
201
|
+
let query = "Current project implementation requirements and design patterns";
|
|
202
|
+
|
|
203
|
+
if (localData.requirements) {
|
|
204
|
+
const requirements = localData.requirements.substring(0, 500);
|
|
205
|
+
query += `. Requirements: ${requirements}`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (localData.design) {
|
|
209
|
+
const design = localData.design.substring(0, 500);
|
|
210
|
+
query += `. Design: ${design}`;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return query;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Generate implementation plan using AI
|
|
218
|
+
*/
|
|
219
|
+
async generateImplementationPlan(localData, ragContext) {
|
|
220
|
+
const prompt = this.buildPlanningPrompt(localData, ragContext);
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
const aiResponse = await this.apiClient.generateText(prompt, {
|
|
224
|
+
systemPrompt: this.getSystemPrompt(),
|
|
225
|
+
maxTokens: 4000,
|
|
226
|
+
temperature: 0.7,
|
|
227
|
+
context: {
|
|
228
|
+
taskType: 'planning',
|
|
229
|
+
projectName: localData.projectName
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Parse AI response into structured plan
|
|
234
|
+
const plan = this.parseAIResponse(aiResponse.content);
|
|
235
|
+
|
|
236
|
+
console.log(' ✅ Implementation plan generated');
|
|
237
|
+
|
|
238
|
+
return plan;
|
|
239
|
+
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.log(` ⚠️ AI generation failed: ${error.message}`);
|
|
242
|
+
// Fallback to basic plan generation
|
|
243
|
+
return this.generateBasicPlan(localData);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Build AI planning prompt
|
|
249
|
+
*/
|
|
250
|
+
buildPlanningPrompt(localData, ragContext) {
|
|
251
|
+
let prompt = `Generate a comprehensive implementation plan for the following project:\n\n`;
|
|
252
|
+
|
|
253
|
+
prompt += `PROJECT: ${localData.projectName}\n\n`;
|
|
254
|
+
|
|
255
|
+
if (localData.requirements) {
|
|
256
|
+
prompt += `REQUIREMENTS:\n${localData.requirements.substring(0, 2000)}\n\n`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (localData.design) {
|
|
260
|
+
prompt += `DESIGN:\n${localData.design.substring(0, 2000)}\n\n`;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (ragContext && ragContext.contexts.length > 0) {
|
|
264
|
+
prompt += `CONTEXT FROM CODEBASE:\n`;
|
|
265
|
+
ragContext.contexts.forEach((ctx, i) => {
|
|
266
|
+
prompt += `${i + 1}. ${ctx.content.substring(0, 300)}...\n`;
|
|
267
|
+
});
|
|
268
|
+
prompt += '\n';
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
prompt += `Generate a detailed implementation plan with:\n`;
|
|
272
|
+
prompt += `1. Ordered tasks with dependencies\n`;
|
|
273
|
+
prompt += `2. Each task with clear acceptance criteria\n`;
|
|
274
|
+
prompt += `3. Estimated complexity (Low/Medium/High)\n`;
|
|
275
|
+
prompt += `4. Recommended agent for each task\n`;
|
|
276
|
+
prompt += `5. Checkboxes for tracking: [ ] incomplete, [x] complete\n\n`;
|
|
277
|
+
prompt += `Format as markdown with proper task numbering.`;
|
|
278
|
+
|
|
279
|
+
return prompt;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Get system prompt for AI
|
|
284
|
+
*/
|
|
285
|
+
getSystemPrompt() {
|
|
286
|
+
return `You are an expert software architect and project manager. Create detailed, actionable implementation plans that break down complex projects into manageable tasks. Consider dependencies, priorities, and best practices. Always include clear acceptance criteria and checkboxes for progress tracking.`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Parse AI response into structured plan
|
|
291
|
+
*/
|
|
292
|
+
parseAIResponse(aiContent) {
|
|
293
|
+
// Parse the markdown response into structured data
|
|
294
|
+
const tasks = [];
|
|
295
|
+
const lines = aiContent.split('\n');
|
|
296
|
+
|
|
297
|
+
let currentTask = null;
|
|
298
|
+
let taskNumber = 1;
|
|
299
|
+
|
|
300
|
+
for (const line of lines) {
|
|
301
|
+
// Match task headers (##, ###, or numbered lists)
|
|
302
|
+
const taskMatch = line.match(/^#{1,3}\s*\[([ x])\]\s*(.+)$/);
|
|
303
|
+
if (taskMatch) {
|
|
304
|
+
if (currentTask) {
|
|
305
|
+
tasks.push(currentTask);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
currentTask = {
|
|
309
|
+
id: `task-${taskNumber}`,
|
|
310
|
+
number: taskNumber++,
|
|
311
|
+
completed: taskMatch[1] === 'x',
|
|
312
|
+
title: taskMatch[2].trim(),
|
|
313
|
+
description: '',
|
|
314
|
+
acceptanceCriteria: [],
|
|
315
|
+
complexity: 'Medium',
|
|
316
|
+
agent: 'task-executor',
|
|
317
|
+
dependencies: []
|
|
318
|
+
};
|
|
319
|
+
} else if (currentTask && line.trim()) {
|
|
320
|
+
// Add to current task description or criteria
|
|
321
|
+
if (line.includes('Acceptance Criteria:') || line.includes('Requirements:')) {
|
|
322
|
+
currentTask.acceptanceCriteria = [];
|
|
323
|
+
} else if (line.includes('Complexity:')) {
|
|
324
|
+
const complexity = line.match(/Complexity:\s*(Low|Medium|High)/);
|
|
325
|
+
if (complexity) currentTask.complexity = complexity[1];
|
|
326
|
+
} else if (line.includes('Agent:')) {
|
|
327
|
+
const agent = line.match(/Agent:\s*(.+)/);
|
|
328
|
+
if (agent) currentTask.agent = agent[1].trim();
|
|
329
|
+
} else if (line.includes('Depends on:')) {
|
|
330
|
+
const deps = line.match(/Depends on:\s*(.+)/);
|
|
331
|
+
if (deps) {
|
|
332
|
+
currentTask.dependencies = deps[1].split(',').map(d => d.trim());
|
|
333
|
+
}
|
|
334
|
+
} else if (line.match(/^\s*-\s*\[([ x])\]\s*(.+)/)) {
|
|
335
|
+
// Acceptance criteria item
|
|
336
|
+
const criteriaMatch = line.match(/^\s*-\s*\[([ x])\]\s*(.+)/);
|
|
337
|
+
if (criteriaMatch) {
|
|
338
|
+
currentTask.acceptanceCriteria.push({
|
|
339
|
+
completed: criteriaMatch[1] === 'x',
|
|
340
|
+
text: criteriaMatch[2].trim()
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
// Regular description line
|
|
345
|
+
currentTask.description += line + '\n';
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (currentTask) {
|
|
351
|
+
tasks.push(currentTask);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return {
|
|
355
|
+
title: `Implementation Plan for ${this.detectProjectName(process.cwd())}`,
|
|
356
|
+
tasks,
|
|
357
|
+
generatedAt: new Date().toISOString(),
|
|
358
|
+
totalTasks: tasks.length,
|
|
359
|
+
completedTasks: tasks.filter(t => t.completed).length
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Generate basic plan as fallback
|
|
365
|
+
*/
|
|
366
|
+
generateBasicPlan(localData) {
|
|
367
|
+
const tasks = [
|
|
368
|
+
{
|
|
369
|
+
id: 'task-1',
|
|
370
|
+
number: 1,
|
|
371
|
+
completed: false,
|
|
372
|
+
title: 'Project Setup and Configuration',
|
|
373
|
+
description: 'Initialize project structure and configure development environment.',
|
|
374
|
+
acceptanceCriteria: [
|
|
375
|
+
{ completed: false, text: 'Project structure created' },
|
|
376
|
+
{ completed: false, text: 'Development environment configured' }
|
|
377
|
+
],
|
|
378
|
+
complexity: 'Low',
|
|
379
|
+
agent: 'task-executor',
|
|
380
|
+
dependencies: []
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
id: 'task-2',
|
|
384
|
+
number: 2,
|
|
385
|
+
completed: false,
|
|
386
|
+
title: 'Core Implementation',
|
|
387
|
+
description: 'Implement core functionality based on requirements.',
|
|
388
|
+
acceptanceCriteria: [
|
|
389
|
+
{ completed: false, text: 'Core features implemented' },
|
|
390
|
+
{ completed: false, text: 'Basic testing completed' }
|
|
391
|
+
],
|
|
392
|
+
complexity: 'High',
|
|
393
|
+
agent: 'task-executor',
|
|
394
|
+
dependencies: ['task-1']
|
|
395
|
+
}
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
title: `Implementation Plan for ${localData.projectName}`,
|
|
400
|
+
tasks,
|
|
401
|
+
generatedAt: new Date().toISOString(),
|
|
402
|
+
totalTasks: tasks.length,
|
|
403
|
+
completedTasks: 0,
|
|
404
|
+
note: 'Basic plan generated due to AI service unavailability'
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Sync plan with backend
|
|
410
|
+
*/
|
|
411
|
+
async syncWithBackend(plan) {
|
|
412
|
+
try {
|
|
413
|
+
// Create tasks in backend
|
|
414
|
+
const taskPayloads = plan.tasks.map(task => ({
|
|
415
|
+
type: 'planning',
|
|
416
|
+
priority: this.mapPriority(task.complexity),
|
|
417
|
+
payload: {
|
|
418
|
+
title: task.title,
|
|
419
|
+
description: task.description,
|
|
420
|
+
acceptanceCriteria: task.acceptanceCriteria,
|
|
421
|
+
complexity: task.complexity
|
|
422
|
+
},
|
|
423
|
+
dependencies: task.dependencies,
|
|
424
|
+
metadata: {
|
|
425
|
+
source: 'luna-plan',
|
|
426
|
+
generatedAt: plan.generatedAt,
|
|
427
|
+
agentType: task.agent
|
|
428
|
+
}
|
|
429
|
+
}));
|
|
430
|
+
|
|
431
|
+
const response = await this.apiClient.createTask(taskPayloads);
|
|
432
|
+
|
|
433
|
+
console.log(` ✅ Created ${response.tasks.length} tasks in backend`);
|
|
434
|
+
|
|
435
|
+
return response.tasks;
|
|
436
|
+
|
|
437
|
+
} catch (error) {
|
|
438
|
+
console.log(` ⚠️ Backend sync failed: ${error.message}`);
|
|
439
|
+
return [];
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Map complexity to priority
|
|
445
|
+
*/
|
|
446
|
+
mapPriority(complexity) {
|
|
447
|
+
const mapping = {
|
|
448
|
+
'Low': 'low',
|
|
449
|
+
'Medium': 'normal',
|
|
450
|
+
'High': 'high'
|
|
451
|
+
};
|
|
452
|
+
return mapping[complexity] || 'normal';
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Save local plan file
|
|
457
|
+
*/
|
|
458
|
+
async saveLocalPlan(plan, projectName, backendTasks) {
|
|
459
|
+
const currentDir = process.cwd();
|
|
460
|
+
const planDir = path.join(currentDir, '.luna', projectName);
|
|
461
|
+
|
|
462
|
+
// Ensure directory exists
|
|
463
|
+
if (!fs.existsSync(planDir)) {
|
|
464
|
+
fs.mkdirSync(planDir, { recursive: true });
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const planFile = path.join(planDir, 'implementation-plan.md');
|
|
468
|
+
|
|
469
|
+
let content = `# ${plan.title}\n\n`;
|
|
470
|
+
content += `Generated: ${plan.generatedAt}\n`;
|
|
471
|
+
content += `Total Tasks: ${plan.totalTasks}\n`;
|
|
472
|
+
content += `Completed: ${plan.completedTasks}\n\n`;
|
|
473
|
+
|
|
474
|
+
if (backendTasks.length > 0) {
|
|
475
|
+
content += `## Backend Integration\n\n`;
|
|
476
|
+
content += `✅ Synced ${backendTasks.length} tasks to backend platform\n`;
|
|
477
|
+
content += `🔗 Task IDs available for tracking\n\n`;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
content += `## Implementation Tasks\n\n`;
|
|
481
|
+
|
|
482
|
+
plan.tasks.forEach(task => {
|
|
483
|
+
const checkbox = task.completed ? '[x]' : '[ ]';
|
|
484
|
+
content += `### ${checkbox} ${task.number}. ${task.title}\n\n`;
|
|
485
|
+
|
|
486
|
+
if (task.description) {
|
|
487
|
+
content += `${task.description}\n\n`;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (task.acceptanceCriteria.length > 0) {
|
|
491
|
+
content += `**Acceptance Criteria:**\n`;
|
|
492
|
+
task.acceptanceCriteria.forEach(criteria => {
|
|
493
|
+
const critCheckbox = criteria.completed ? '[x]' : '[ ]';
|
|
494
|
+
content += `- ${critCheckbox} ${criteria.text}\n`;
|
|
495
|
+
});
|
|
496
|
+
content += '\n';
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const meta = [];
|
|
500
|
+
if (task.complexity !== 'Medium') meta.push(`Complexity: ${task.complexity}`);
|
|
501
|
+
if (task.agent !== 'task-executor') meta.push(`Agent: ${task.agent}`);
|
|
502
|
+
if (task.dependencies.length > 0) meta.push(`Dependencies: ${task.dependencies.join(', ')}`);
|
|
503
|
+
|
|
504
|
+
if (meta.length > 0) {
|
|
505
|
+
content += `**Meta:** ${meta.join(' | ')}\n\n`;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Add backend task ID if available
|
|
509
|
+
const backendTask = backendTasks.find(bt => bt.title === task.title);
|
|
510
|
+
if (backendTask) {
|
|
511
|
+
content += `**Backend Task ID:** \`${backendTask.id}\`\n\n`;
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
content += `---\n`;
|
|
516
|
+
content += `*Generated by Luna Task Planning v2.0 with API integration*\n`;
|
|
517
|
+
|
|
518
|
+
fs.writeFileSync(planFile, content);
|
|
519
|
+
console.log(` ✅ Plan saved to: ${planFile}`);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Display results
|
|
524
|
+
*/
|
|
525
|
+
displayResults(plan) {
|
|
526
|
+
console.log('📊 Planning Results:');
|
|
527
|
+
console.log('==================');
|
|
528
|
+
console.log(`📋 Total Tasks: ${plan.totalTasks}`);
|
|
529
|
+
console.log(`✅ Completed: ${plan.completedTasks}`);
|
|
530
|
+
console.log(`⏳ Remaining: ${plan.totalTasks - plan.completedTasks}`);
|
|
531
|
+
|
|
532
|
+
if (plan.backendTasks && plan.backendTasks.length > 0) {
|
|
533
|
+
console.log(`🔄 Backend Tasks: ${plan.backendTasks.length}`);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
if (plan.ragContext) {
|
|
537
|
+
console.log(`🧠 RAG Context: ${plan.ragContext.contexts.length} items`);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
console.log('');
|
|
541
|
+
console.log('📁 Local plan saved to .luna/{project}/implementation-plan.md');
|
|
542
|
+
|
|
543
|
+
if (plan.synced) {
|
|
544
|
+
console.log('🔄 Tasks synced to backend platform');
|
|
545
|
+
console.log('💡 Track progress with: /luna-tasks');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
console.log('');
|
|
549
|
+
console.log('🚀 Next Steps:');
|
|
550
|
+
console.log(' Start execution: /luna-execute');
|
|
551
|
+
console.log(' Track progress: /luna-tasks --status=running');
|
|
552
|
+
console.log(' View analytics: /luna-analytics');
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Detect project name from current directory
|
|
557
|
+
*/
|
|
558
|
+
detectProjectName(currentDir) {
|
|
559
|
+
const baseName = path.basename(currentDir);
|
|
560
|
+
|
|
561
|
+
// Common project name patterns
|
|
562
|
+
if (baseName === 'src' || baseName === 'lib') {
|
|
563
|
+
return path.basename(path.dirname(currentDir));
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return baseName;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
module.exports = LunaPlanCommand;
|