@nexus-ai-nexoralabs/cli 0.1.3 → 0.1.4

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 (133) hide show
  1. package/.env.example +16 -16
  2. package/LICENSE +21 -21
  3. package/README.md +135 -106
  4. package/dist/api/index.d.ts +4 -0
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api/index.js +9 -3
  7. package/dist/api/index.js.map +1 -1
  8. package/dist/chat/chatService.d.ts.map +1 -1
  9. package/dist/chat/chatService.js +22 -3
  10. package/dist/chat/chatService.js.map +1 -1
  11. package/dist/chat/conversationService.d.ts +7 -1
  12. package/dist/chat/conversationService.d.ts.map +1 -1
  13. package/dist/chat/conversationService.js +48 -15
  14. package/dist/chat/conversationService.js.map +1 -1
  15. package/dist/cli/agentRunner.d.ts.map +1 -1
  16. package/dist/cli/agentRunner.js +88 -8
  17. package/dist/cli/agentRunner.js.map +1 -1
  18. package/dist/cli/chatRunner.d.ts +65 -0
  19. package/dist/cli/chatRunner.d.ts.map +1 -0
  20. package/dist/cli/chatRunner.js +289 -0
  21. package/dist/cli/chatRunner.js.map +1 -0
  22. package/dist/cli/index.d.ts +2 -0
  23. package/dist/cli/index.d.ts.map +1 -1
  24. package/dist/cli/index.js +2 -0
  25. package/dist/cli/index.js.map +1 -1
  26. package/dist/cli/inputEngine.d.ts +10 -0
  27. package/dist/cli/inputEngine.d.ts.map +1 -1
  28. package/dist/cli/inputEngine.js +28 -1
  29. package/dist/cli/inputEngine.js.map +1 -1
  30. package/dist/cli/main.d.ts +4 -0
  31. package/dist/cli/main.d.ts.map +1 -1
  32. package/dist/cli/main.js +89 -25
  33. package/dist/cli/main.js.map +1 -1
  34. package/dist/cli/uiFormatters.d.ts +11 -1
  35. package/dist/cli/uiFormatters.d.ts.map +1 -1
  36. package/dist/cli/uiFormatters.js +253 -15
  37. package/dist/cli/uiFormatters.js.map +1 -1
  38. package/dist/intelligence/modelGateway.d.ts +1 -0
  39. package/dist/intelligence/modelGateway.d.ts.map +1 -1
  40. package/dist/intelligence/modelGateway.js +63 -6
  41. package/dist/intelligence/modelGateway.js.map +1 -1
  42. package/dist/intelligence/modelRegistry.d.ts +2 -2
  43. package/dist/intelligence/modelRegistry.d.ts.map +1 -1
  44. package/dist/intelligence/modelRegistry.js +72 -31
  45. package/dist/intelligence/modelRegistry.js.map +1 -1
  46. package/dist/intelligence/modelRouter.d.ts.map +1 -1
  47. package/dist/intelligence/modelRouter.js +62 -16
  48. package/dist/intelligence/modelRouter.js.map +1 -1
  49. package/dist/intelligence/providers/embeddedInferenceProvider.d.ts.map +1 -1
  50. package/dist/intelligence/providers/embeddedInferenceProvider.js +2224 -6
  51. package/dist/intelligence/providers/embeddedInferenceProvider.js.map +1 -1
  52. package/dist/intelligence/runtime/runtimeManager.d.ts +5 -0
  53. package/dist/intelligence/runtime/runtimeManager.d.ts.map +1 -1
  54. package/dist/intelligence/runtime/runtimeManager.js +64 -4
  55. package/dist/intelligence/runtime/runtimeManager.js.map +1 -1
  56. package/dist/orchestration/agentExecutionService.d.ts.map +1 -1
  57. package/dist/orchestration/agentExecutionService.js +22 -0
  58. package/dist/orchestration/agentExecutionService.js.map +1 -1
  59. package/dist/orchestration/agentTaskService.d.ts +24 -10
  60. package/dist/orchestration/agentTaskService.d.ts.map +1 -1
  61. package/dist/orchestration/agentTaskService.js +76 -13
  62. package/dist/orchestration/agentTaskService.js.map +1 -1
  63. package/dist/orchestration/codingAgentService.d.ts.map +1 -1
  64. package/dist/orchestration/codingAgentService.js +2 -0
  65. package/dist/orchestration/codingAgentService.js.map +1 -1
  66. package/dist/orchestration/goalCompletionVerifier.d.ts +9 -0
  67. package/dist/orchestration/goalCompletionVerifier.d.ts.map +1 -1
  68. package/dist/orchestration/goalCompletionVerifier.js +131 -9
  69. package/dist/orchestration/goalCompletionVerifier.js.map +1 -1
  70. package/dist/orchestration/index.d.ts +16 -2
  71. package/dist/orchestration/index.d.ts.map +1 -1
  72. package/dist/orchestration/index.js +20 -4
  73. package/dist/orchestration/index.js.map +1 -1
  74. package/dist/orchestration/placeholderDetector.d.ts +74 -0
  75. package/dist/orchestration/placeholderDetector.d.ts.map +1 -0
  76. package/dist/orchestration/placeholderDetector.js +741 -0
  77. package/dist/orchestration/placeholderDetector.js.map +1 -0
  78. package/dist/orchestration/planner.d.ts.map +1 -1
  79. package/dist/orchestration/planner.js +94 -55
  80. package/dist/orchestration/planner.js.map +1 -1
  81. package/dist/orchestration/projectOrchestrator.d.ts +63 -0
  82. package/dist/orchestration/projectOrchestrator.d.ts.map +1 -0
  83. package/dist/orchestration/projectOrchestrator.js +555 -0
  84. package/dist/orchestration/projectOrchestrator.js.map +1 -0
  85. package/dist/orchestration/taskDecompositionService.d.ts +36 -0
  86. package/dist/orchestration/taskDecompositionService.d.ts.map +1 -0
  87. package/dist/orchestration/taskDecompositionService.js +367 -0
  88. package/dist/orchestration/taskDecompositionService.js.map +1 -0
  89. package/dist/orchestration/taskDecompositionTypes.d.ts +62 -0
  90. package/dist/orchestration/taskDecompositionTypes.d.ts.map +1 -0
  91. package/dist/orchestration/taskDecompositionTypes.js +5 -0
  92. package/dist/orchestration/taskDecompositionTypes.js.map +1 -0
  93. package/dist/preview/previewServer.d.ts.map +1 -1
  94. package/dist/preview/previewServer.js +28 -7
  95. package/dist/preview/previewServer.js.map +1 -1
  96. package/dist/preview/previewService.d.ts +32 -3
  97. package/dist/preview/previewService.d.ts.map +1 -1
  98. package/dist/preview/previewService.js +370 -108
  99. package/dist/preview/previewService.js.map +1 -1
  100. package/dist/preview/previewTypes.d.ts +1 -1
  101. package/dist/preview/previewTypes.d.ts.map +1 -1
  102. package/dist/storage/index.d.ts +2 -0
  103. package/dist/storage/index.d.ts.map +1 -1
  104. package/dist/storage/index.js +3 -0
  105. package/dist/storage/index.js.map +1 -1
  106. package/dist/storage/migration.d.ts.map +1 -1
  107. package/dist/storage/migration.js +79 -0
  108. package/dist/storage/migration.js.map +1 -1
  109. package/dist/storage/repositories/agentTaskRepository.d.ts +13 -0
  110. package/dist/storage/repositories/agentTaskRepository.d.ts.map +1 -1
  111. package/dist/storage/repositories/agentTaskRepository.js +87 -25
  112. package/dist/storage/repositories/agentTaskRepository.js.map +1 -1
  113. package/dist/storage/repositories/conversationRepository.d.ts +5 -1
  114. package/dist/storage/repositories/conversationRepository.d.ts.map +1 -1
  115. package/dist/storage/repositories/conversationRepository.js +69 -0
  116. package/dist/storage/repositories/conversationRepository.js.map +1 -1
  117. package/dist/storage/repositories/messageRepository.d.ts +3 -0
  118. package/dist/storage/repositories/messageRepository.d.ts.map +1 -1
  119. package/dist/storage/repositories/messageRepository.js +29 -0
  120. package/dist/storage/repositories/messageRepository.js.map +1 -1
  121. package/dist/storage/repositories/taskArtifactRepository.d.ts +19 -0
  122. package/dist/storage/repositories/taskArtifactRepository.d.ts.map +1 -0
  123. package/dist/storage/repositories/taskArtifactRepository.js +82 -0
  124. package/dist/storage/repositories/taskArtifactRepository.js.map +1 -0
  125. package/dist/storage/repositories/types.d.ts +32 -0
  126. package/dist/storage/repositories/types.d.ts.map +1 -1
  127. package/dist/tools/adapters/filesystemAdapter.d.ts.map +1 -1
  128. package/dist/tools/adapters/filesystemAdapter.js +8 -1
  129. package/dist/tools/adapters/filesystemAdapter.js.map +1 -1
  130. package/dist/ui/public/app.js +777 -777
  131. package/dist/ui/public/index.html +117 -117
  132. package/dist/ui/public/styles.css +413 -413
  133. package/package.json +64 -63
@@ -0,0 +1,555 @@
1
+ /**
2
+ * NEXUS AI — Project Task Orchestrator
3
+ *
4
+ * Coordinates execution of decomposed project tasks with:
5
+ * 1. Minimal context per task unit
6
+ * 2. Strict dependency resolution
7
+ * 3. Incremental file generation
8
+ * 4. Per-task artifact registration and content-aware verification
9
+ * 5. Bounded retries with focused failure context
10
+ * 6. Final end-to-end integration verification
11
+ * 7. Clean restart recovery
12
+ */
13
+ import * as fs from 'fs';
14
+ import * as path from 'path';
15
+ import { verifyHtmlContentSubstance, verifyChildUnitContentSubstance, extractBrandCandidates, } from './placeholderDetector.js';
16
+ import { Logger } from '../common/logger.js';
17
+ export class ProjectTaskOrchestrator {
18
+ taskService;
19
+ planner;
20
+ executionService;
21
+ goalVerifier;
22
+ workspaceRoot;
23
+ artifactRepo;
24
+ approvalService;
25
+ logger;
26
+ constructor(taskService, planner, executionService, goalVerifier, workspaceRoot, artifactRepo, approvalService, logLevel = 'info') {
27
+ this.taskService = taskService;
28
+ this.planner = planner;
29
+ this.executionService = executionService;
30
+ this.goalVerifier = goalVerifier;
31
+ this.workspaceRoot = workspaceRoot;
32
+ this.artifactRepo = artifactRepo;
33
+ this.approvalService = approvalService;
34
+ this.logger = new Logger('ProjectTaskOrchestrator', logLevel);
35
+ }
36
+ /**
37
+ * Orchestrates execution of a decomposed project plan.
38
+ */
39
+ async orchestrate(parentTaskId, plan, options = {}) {
40
+ const startTime = Date.now();
41
+ const maxRetries = options.maxRetriesPerUnit ?? 2;
42
+ const parentTask = this.taskService.getTask(parentTaskId);
43
+ this.logger.info(`Starting project orchestration`, {
44
+ parentTaskId,
45
+ totalUnits: plan.units.length,
46
+ goal: plan.parentGoal,
47
+ });
48
+ // 1. Transition parent task to planning -> executing
49
+ if (parentTask.state === 'created') {
50
+ this.taskService.transitionTask(parentTaskId, { targetState: 'planning' });
51
+ }
52
+ this.taskService.transitionTask(parentTaskId, {
53
+ targetState: 'executing',
54
+ plan: JSON.stringify(plan),
55
+ });
56
+ // 2. Persist child tasks in database if not already created (supports restart recovery)
57
+ const existingChildren = this.taskService.getChildTasks(parentTaskId);
58
+ const childTaskMap = new Map();
59
+ if (existingChildren.length === 0) {
60
+ for (let i = 0; i < plan.units.length; i++) {
61
+ const unit = plan.units[i];
62
+ const childTask = this.taskService.createTask({
63
+ title: unit.title,
64
+ parentTaskId,
65
+ taskType: 'child_unit',
66
+ sequence: i + 1,
67
+ dependencies: unit.dependencies,
68
+ expectedOutput: unit.expectedOutput,
69
+ verificationCriteria: unit.verificationCriteria.join('; '),
70
+ });
71
+ childTaskMap.set(unit.id, childTask);
72
+ }
73
+ }
74
+ else {
75
+ // Resume from existing tasks in database
76
+ for (const child of existingChildren) {
77
+ // Match sequence or ID
78
+ const matchedUnit = (child.sequence !== undefined && child.sequence !== null
79
+ ? plan.units[child.sequence - 1]
80
+ : undefined) || plan.units.find((u) => u.title === child.title);
81
+ if (matchedUnit) {
82
+ childTaskMap.set(matchedUnit.id, child);
83
+ }
84
+ }
85
+ }
86
+ const childResults = [];
87
+ const completedUnitSummaries = {};
88
+ let projectRootPath = this.workspaceRoot;
89
+ // 3. Sequential Execution Queue with Dependency Enforcement
90
+ for (let i = 0; i < plan.units.length; i++) {
91
+ const unit = plan.units[i];
92
+ let childTask = childTaskMap.get(unit.id) || this.taskService.getChildTasks(parentTaskId).find((c) => c.sequence === i + 1);
93
+ if (!childTask) {
94
+ childTask = this.taskService.createTask({
95
+ title: unit.title,
96
+ parentTaskId,
97
+ taskType: 'child_unit',
98
+ sequence: i + 1,
99
+ dependencies: unit.dependencies,
100
+ expectedOutput: unit.expectedOutput,
101
+ verificationCriteria: unit.verificationCriteria.join('; '),
102
+ });
103
+ childTaskMap.set(unit.id, childTask);
104
+ }
105
+ // Check if already completed from previous run
106
+ if (childTask.state === 'completed') {
107
+ this.logger.info(`Skipping already completed child unit: '${unit.title}'`, { unitId: unit.id, taskId: childTask.id });
108
+ completedUnitSummaries[unit.id] = childTask.summary || `Completed ${unit.title}`;
109
+ childResults.push({
110
+ unitId: unit.id,
111
+ taskId: childTask.id,
112
+ title: unit.title,
113
+ success: true,
114
+ status: 'completed',
115
+ summary: childTask.summary || `Completed ${unit.title}`,
116
+ artifacts: unit.targetFiles,
117
+ attemptCount: childTask.attemptCount || 1,
118
+ });
119
+ continue;
120
+ }
121
+ // ── A. Check Dependencies ──────────────────────────────────────────────
122
+ const missingOrFailedDeps = unit.dependencies.filter((depId) => {
123
+ const depResult = childResults.find((r) => r.unitId === depId);
124
+ return !depResult || !depResult.success;
125
+ });
126
+ if (missingOrFailedDeps.length > 0) {
127
+ const reason = `Blocked: Prerequisite units not satisfied (${missingOrFailedDeps.join(', ')})`;
128
+ this.logger.warn(`Child unit execution blocked: ${reason}`, { unitId: unit.id });
129
+ this.taskService.failTask(childTask.id, {
130
+ errorCategory: 'DEPENDENCY_FAILED',
131
+ summary: reason,
132
+ });
133
+ childResults.push({
134
+ unitId: unit.id,
135
+ taskId: childTask.id,
136
+ title: unit.title,
137
+ success: false,
138
+ status: 'blocked',
139
+ summary: reason,
140
+ artifacts: [],
141
+ error: reason,
142
+ attemptCount: 0,
143
+ });
144
+ // Fail parent task
145
+ this.taskService.failTask(parentTaskId, {
146
+ errorCategory: 'DEPENDENCY_FAILED',
147
+ summary: `Project orchestration halted: Unit '${unit.title}' blocked by failed prerequisites.`,
148
+ });
149
+ return {
150
+ parentTaskId,
151
+ success: false,
152
+ status: 'failed',
153
+ totalUnits: plan.units.length,
154
+ completedUnits: childResults.filter((r) => r.success).length,
155
+ failedUnits: childResults.filter((r) => !r.success).length,
156
+ childResults,
157
+ finalVerificationPassed: false,
158
+ summary: `Orchestration halted: '${unit.title}' blocked by prerequisite failure.`,
159
+ error: reason,
160
+ durationMs: Date.now() - startTime,
161
+ };
162
+ }
163
+ // ── B. Execute Unit with Retries ────────────────────────────────────────
164
+ if (options.onProgress) {
165
+ options.onProgress({
166
+ unitIndex: i + 1,
167
+ totalUnits: plan.units.length,
168
+ unit,
169
+ status: 'starting',
170
+ });
171
+ }
172
+ let attempt = 0;
173
+ let unitSuccess = false;
174
+ let lastError = '';
175
+ let unitSummary = '';
176
+ while (attempt <= maxRetries && !unitSuccess) {
177
+ attempt++;
178
+ this.logger.info(`Executing unit '${unit.title}' (Attempt ${attempt}/${maxRetries + 1})`, { unitId: unit.id });
179
+ if (attempt > 1) {
180
+ this.taskService.resetTaskForRetry(childTask.id, 'planning');
181
+ }
182
+ try {
183
+ // 1. Build Minimal Focused Context
184
+ const prompt = this.buildFocusedPrompt(plan.parentGoal, unit, completedUnitSummaries, lastError);
185
+ // 2. Synthesize Plan Steps for this unit
186
+ const planResult = await this.planner.synthesize(childTask.id, {
187
+ taskGoal: prompt,
188
+ temperature: 0.2,
189
+ });
190
+ if (!planResult.success || !planResult.plan || planResult.plan.steps.length === 0) {
191
+ lastError = planResult.errorMessage || 'Failed to synthesize implementation steps for unit.';
192
+ this.logger.warn(`Plan synthesis failed for unit '${unit.title}'`, { attempt, error: lastError });
193
+ continue;
194
+ }
195
+ // 3. Run Execution Loop for this unit with approval auto-resolution
196
+ let execTask = await this.executionService.runExecutionLoop(childTask.id, planResult.plan.steps, {
197
+ autoComplete: false,
198
+ });
199
+ // If execution paused due to pending approvals, resolve safe approvals and resume
200
+ while (this.approvalService &&
201
+ (execTask.state === 'awaiting_approval' ||
202
+ this.approvalService.getApprovalsForTask(childTask.id).some((a) => a.status === 'pending'))) {
203
+ const pending = this.approvalService
204
+ .getApprovalsForTask(childTask.id)
205
+ .filter((a) => a.status === 'pending');
206
+ if (pending.length === 0)
207
+ break;
208
+ let approvedAny = false;
209
+ for (const appr of pending) {
210
+ if (appr.riskLevel !== 'high') {
211
+ this.approvalService.resolveApproval(appr.approvalId, 'approved', 'Auto-approved child unit authoring operation');
212
+ approvedAny = true;
213
+ }
214
+ }
215
+ if (!approvedAny)
216
+ break;
217
+ execTask = await this.executionService.runExecutionLoop(childTask.id, planResult.plan.steps, {
218
+ autoComplete: false,
219
+ });
220
+ }
221
+ if (execTask.state === 'failed' || execTask.state === 'awaiting_approval') {
222
+ lastError = execTask.errorCategory || 'Execution step failed';
223
+ this.logger.warn(`Execution loop failed for unit '${unit.title}'`, { attempt, error: lastError });
224
+ continue;
225
+ }
226
+ // 4. Verify Content & Substance for this unit
227
+ const verif = await this.verifyUnitImplementation(unit, plan.parentGoal);
228
+ if (!verif.valid) {
229
+ lastError = `Content verification failed: ${verif.reason || 'Skeleton or placeholder detected.'}`;
230
+ this.logger.warn(`Unit content verification failed for '${unit.title}'`, { attempt, error: lastError });
231
+ continue;
232
+ }
233
+ // 5. Success: Register unit artifact & update state
234
+ unitSuccess = true;
235
+ unitSummary = `Implemented ${unit.title} (${unit.targetFiles.join(', ')}). Output verified.`;
236
+ // Discover and register artifact
237
+ const discoveredDir = this.findProjectDir(unit.targetFiles);
238
+ if (discoveredDir) {
239
+ projectRootPath = discoveredDir;
240
+ if (this.artifactRepo) {
241
+ this.artifactRepo.create({
242
+ id: `art-${childTask.id}`,
243
+ taskId: childTask.id,
244
+ projectId: null,
245
+ projectRoot: discoveredDir,
246
+ relativeProjectRoot: path.relative(this.workspaceRoot, discoveredDir) || '.',
247
+ entryPoint: 'index.html',
248
+ artifactType: 'web_project',
249
+ workspacePath: this.workspaceRoot,
250
+ files: unit.targetFiles,
251
+ isVerified: true,
252
+ });
253
+ }
254
+ }
255
+ this.taskService.updateTaskSummary(childTask.id, unitSummary);
256
+ this.taskService.completeTask(childTask.id);
257
+ completedUnitSummaries[unit.id] = unitSummary;
258
+ if (options.onProgress) {
259
+ options.onProgress({
260
+ unitIndex: i + 1,
261
+ totalUnits: plan.units.length,
262
+ unit,
263
+ status: 'completed',
264
+ message: unitSummary,
265
+ });
266
+ }
267
+ }
268
+ catch (err) {
269
+ lastError = err instanceof Error ? err.message : String(err);
270
+ this.logger.error(`Exception during unit execution '${unit.title}'`, { attempt, error: lastError });
271
+ }
272
+ }
273
+ if (!unitSuccess) {
274
+ // Child unit failed after retries
275
+ const curChild = this.taskService.getTask(childTask.id);
276
+ if (curChild.state !== 'failed') {
277
+ this.taskService.failTask(childTask.id, {
278
+ errorCategory: 'UNIT_EXECUTION_FAILED',
279
+ summary: `Failed after ${attempt} attempt(s): ${lastError}`,
280
+ });
281
+ }
282
+ else {
283
+ this.taskService.updateTaskSummary(childTask.id, `Failed after ${attempt} attempt(s): ${lastError}`);
284
+ }
285
+ childResults.push({
286
+ unitId: unit.id,
287
+ taskId: childTask.id,
288
+ title: unit.title,
289
+ success: false,
290
+ status: 'failed',
291
+ summary: `Failed after ${attempt} attempts: ${lastError}`,
292
+ artifacts: [],
293
+ error: lastError,
294
+ attemptCount: attempt,
295
+ });
296
+ if (options.onProgress) {
297
+ options.onProgress({
298
+ unitIndex: i + 1,
299
+ totalUnits: plan.units.length,
300
+ unit,
301
+ status: 'failed',
302
+ message: lastError,
303
+ });
304
+ }
305
+ // Fail parent task
306
+ this.taskService.failTask(parentTaskId, {
307
+ errorCategory: 'CHILD_TASK_FAILED',
308
+ summary: `Project failed at unit '${unit.title}': ${lastError}`,
309
+ });
310
+ return {
311
+ parentTaskId,
312
+ success: false,
313
+ status: 'failed',
314
+ totalUnits: plan.units.length,
315
+ completedUnits: childResults.filter((r) => r.success).length,
316
+ failedUnits: childResults.filter((r) => !r.success).length,
317
+ childResults,
318
+ finalVerificationPassed: false,
319
+ summary: `Project orchestration failed at unit '${unit.title}'.`,
320
+ error: lastError,
321
+ durationMs: Date.now() - startTime,
322
+ };
323
+ }
324
+ childResults.push({
325
+ unitId: unit.id,
326
+ taskId: childTask.id,
327
+ title: unit.title,
328
+ success: true,
329
+ status: 'completed',
330
+ summary: unitSummary,
331
+ artifacts: unit.targetFiles,
332
+ attemptCount: attempt,
333
+ });
334
+ }
335
+ // ── 4. Final Integration & Global Verification ───────────────────────────
336
+ this.logger.info(`All ${plan.units.length} units completed. Running final integration verification.`);
337
+ const finalVerif = await this.verifyFinalIntegration(plan.parentGoal, projectRootPath, plan);
338
+ if (!finalVerif.valid) {
339
+ this.logger.error(`Final integration verification failed`, { reason: finalVerif.reason });
340
+ this.taskService.failTask(parentTaskId, {
341
+ errorCategory: 'INTEGRATION_VERIFICATION_FAILED',
342
+ summary: `Final integration failed: ${finalVerif.reason}`,
343
+ });
344
+ return {
345
+ parentTaskId,
346
+ success: false,
347
+ status: 'failed',
348
+ totalUnits: plan.units.length,
349
+ completedUnits: childResults.filter((r) => r.success).length,
350
+ failedUnits: 1,
351
+ childResults,
352
+ finalVerificationPassed: false,
353
+ summary: `Final integration verification failed: ${finalVerif.reason}`,
354
+ error: finalVerif.reason,
355
+ durationMs: Date.now() - startTime,
356
+ };
357
+ }
358
+ // ── 5. Register Final Verified Parent Artifact ────────────────────────────
359
+ const allFiles = Array.from(new Set(plan.units.flatMap((u) => u.targetFiles)));
360
+ if (this.artifactRepo) {
361
+ this.artifactRepo.create({
362
+ id: `art-${parentTaskId}`,
363
+ taskId: parentTaskId,
364
+ projectId: null,
365
+ projectRoot: projectRootPath,
366
+ relativeProjectRoot: path.relative(this.workspaceRoot, projectRootPath) || '.',
367
+ entryPoint: 'index.html',
368
+ artifactType: 'web_project',
369
+ workspacePath: this.workspaceRoot,
370
+ files: allFiles,
371
+ isVerified: true,
372
+ });
373
+ }
374
+ const finalSummary = `Completed all ${plan.units.length} project units with verified integration.`;
375
+ this.taskService.updateTaskSummary(parentTaskId, finalSummary);
376
+ this.taskService.transitionTask(parentTaskId, { targetState: 'observing' });
377
+ this.taskService.transitionTask(parentTaskId, { targetState: 'verifying' });
378
+ this.taskService.completeTask(parentTaskId);
379
+ this.logger.info(`Project orchestration successfully completed!`, {
380
+ parentTaskId,
381
+ totalUnits: plan.units.length,
382
+ durationMs: Date.now() - startTime,
383
+ });
384
+ return {
385
+ parentTaskId,
386
+ success: true,
387
+ status: 'completed',
388
+ totalUnits: plan.units.length,
389
+ completedUnits: plan.units.length,
390
+ failedUnits: 0,
391
+ childResults,
392
+ finalVerificationPassed: true,
393
+ summary: finalSummary,
394
+ durationMs: Date.now() - startTime,
395
+ };
396
+ }
397
+ /**
398
+ * Build minimal, highly-focused prompt for a single child task unit.
399
+ */
400
+ buildFocusedPrompt(parentGoal, unit, completedSummaries, retryError) {
401
+ const lines = [];
402
+ const brandCandidates = extractBrandCandidates(parentGoal);
403
+ const brand = brandCandidates.length > 0 ? brandCandidates[0] : null;
404
+ if (brand) {
405
+ lines.push(`Project Brand / Identity: ${brand}`);
406
+ }
407
+ lines.push(`Overall Project: ${parentGoal}`);
408
+ lines.push(`Current Unit (${unit.category.toUpperCase()}): ${unit.title}`);
409
+ lines.push(`Unit Instructions: ${unit.description}`);
410
+ lines.push(`Target Files: ${unit.targetFiles.join(', ')}`);
411
+ lines.push(`Expected Output: ${unit.expectedOutput}`);
412
+ lines.push(`Verification Criteria: ${unit.verificationCriteria.join('; ')}`);
413
+ if (brand) {
414
+ lines.push(`Brand Directive: You must explicitly incorporate the project brand '${brand}' into the code/markup (in <title>, headings, navbar, or body text as appropriate).`);
415
+ }
416
+ // Add concise summaries of prerequisite units
417
+ if (unit.dependencies.length > 0) {
418
+ lines.push('Completed Prerequisites:');
419
+ for (const depId of unit.dependencies) {
420
+ if (completedSummaries[depId]) {
421
+ lines.push(`- ${completedSummaries[depId]}`);
422
+ }
423
+ }
424
+ }
425
+ // Add relevant existing files snippet context
426
+ const existingSnippet = this.getRelevantFilesSnippet(unit.targetFiles);
427
+ if (existingSnippet) {
428
+ lines.push('\nExisting Files State:');
429
+ lines.push(existingSnippet);
430
+ }
431
+ if (retryError) {
432
+ lines.push(`\nIMPORTANT: Previous attempt failed with: "${retryError}". Fix this specific issue and ensure complete, substantive implementation with no empty skeletons or placeholders.`);
433
+ }
434
+ return lines.join('\n');
435
+ }
436
+ /**
437
+ * Reads existing workspace files up to a small bounded snippet for context.
438
+ */
439
+ getRelevantFilesSnippet(targetFiles) {
440
+ const snippets = [];
441
+ for (const relFile of targetFiles) {
442
+ const fullPath = path.resolve(this.workspaceRoot, relFile);
443
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
444
+ try {
445
+ const content = fs.readFileSync(fullPath, 'utf8');
446
+ // Limit to max 50 lines to keep context tight
447
+ const lines = content.split('\n');
448
+ const preview = lines.slice(0, 50).join('\n');
449
+ snippets.push(`--- ${relFile} (${lines.length} lines) ---\n${preview}${lines.length > 50 ? '\n... (remaining lines omitted)' : ''}`);
450
+ }
451
+ catch {
452
+ /* ignore read error */
453
+ }
454
+ }
455
+ }
456
+ return snippets.join('\n\n');
457
+ }
458
+ /**
459
+ * Verify implementation of a single child unit.
460
+ */
461
+ async verifyUnitImplementation(unit, parentGoal) {
462
+ for (const file of unit.targetFiles) {
463
+ const targetAbs = path.resolve(this.workspaceRoot, file);
464
+ const dir = path.dirname(targetAbs);
465
+ const base = path.basename(file);
466
+ const nameVariants = [base];
467
+ if (base === 'styles.css')
468
+ nameVariants.push('style.css');
469
+ if (base === 'style.css')
470
+ nameVariants.push('styles.css');
471
+ if (base === 'scripts.js')
472
+ nameVariants.push('script.js');
473
+ if (base === 'script.js')
474
+ nameVariants.push('scripts.js');
475
+ const candidates = nameVariants.map((v) => path.join(dir, v));
476
+ const existingFile = candidates.find((p) => fs.existsSync(p) && fs.statSync(p).isFile());
477
+ if (!existingFile) {
478
+ return { valid: false, reason: `Target file '${file}' was not created.` };
479
+ }
480
+ if (file.endsWith('.html')) {
481
+ const content = fs.readFileSync(existingFile, 'utf8');
482
+ const verif = verifyChildUnitContentSubstance(content, {
483
+ unit,
484
+ parentGoal: parentGoal || unit.title,
485
+ });
486
+ if (!verif.valid) {
487
+ return { valid: false, reason: verif.reason };
488
+ }
489
+ }
490
+ else if (file.endsWith('.css')) {
491
+ const cssContent = fs.readFileSync(existingFile, 'utf8');
492
+ if (cssContent.length > 0 && !/\{[^}]*:[^}]*\}/.test(cssContent)) {
493
+ return { valid: false, reason: `CSS artifact '${file}' does not contain valid CSS style rules.` };
494
+ }
495
+ }
496
+ else if (file.endsWith('.js')) {
497
+ const jsContent = fs.readFileSync(existingFile, 'utf8');
498
+ if (unit.category === 'logic' && jsContent.trim().length === 0) {
499
+ return { valid: false, reason: `JS artifact '${file}' is empty (0 bytes).` };
500
+ }
501
+ }
502
+ }
503
+ return { valid: true };
504
+ }
505
+ /**
506
+ * Verify final end-to-end integration across all project files.
507
+ */
508
+ async verifyFinalIntegration(parentGoal, projectRoot, plan) {
509
+ const indexPath = path.join(projectRoot, 'index.html');
510
+ if (!fs.existsSync(indexPath)) {
511
+ return { valid: false, reason: 'index.html does not exist in project directory.' };
512
+ }
513
+ const htmlContent = fs.readFileSync(indexPath, 'utf8');
514
+ const substanceCheck = verifyHtmlContentSubstance(htmlContent, parentGoal);
515
+ if (!substanceCheck.valid) {
516
+ return { valid: false, reason: substanceCheck.reason };
517
+ }
518
+ // Check goal completion verifier with ONLY this project's target files
519
+ const targetFiles = plan
520
+ ? Array.from(new Set(plan.units.flatMap((u) => u.targetFiles)))
521
+ : ['index.html', 'styles.css', 'scripts.js'];
522
+ const nowIso = new Date().toISOString();
523
+ const syntheticSteps = targetFiles.map((f, idx) => ({
524
+ stepId: `integration-step-${idx}`,
525
+ taskId: 'integration-check',
526
+ sequence: idx + 1,
527
+ stepType: 'tool_execution',
528
+ toolId: 'filesystem_write',
529
+ requestedCapabilities: ['filesystem.write'],
530
+ status: 'completed',
531
+ attemptCount: 1,
532
+ maxAttempts: 3,
533
+ params: { relativePath: path.isAbsolute(f) ? path.relative(projectRoot, f) : f },
534
+ createdAt: nowIso,
535
+ updatedAt: nowIso,
536
+ }));
537
+ const goalVerif = this.goalVerifier.verifyGoal(parentGoal, syntheticSteps, projectRoot);
538
+ if (!goalVerif.verified) {
539
+ return { valid: false, reason: goalVerif.errorMessage || 'Goal verification failed' };
540
+ }
541
+ return { valid: true };
542
+ }
543
+ findProjectDir(targetFiles) {
544
+ for (const f of targetFiles) {
545
+ if (f.includes('/') || f.includes('\\')) {
546
+ const dirPart = path.dirname(f);
547
+ if (dirPart && dirPart !== '.') {
548
+ return path.resolve(this.workspaceRoot, dirPart);
549
+ }
550
+ }
551
+ }
552
+ return this.workspaceRoot;
553
+ }
554
+ }
555
+ //# sourceMappingURL=projectOrchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectOrchestrator.js","sourceRoot":"","sources":["../../src/orchestration/projectOrchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAe7B,OAAO,EACL,0BAA0B,EA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CAAC,EAAE,CAAC;gBACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,OAAO,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;oBAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * NEXUS AI — Task Decomposition Service
3
+ *
4
+ * Intelligently analyzes user goals and derives coherent, bounded,
5
+ * dependency-linked child tasks for medium and large projects.
6
+ * Keeps small requests small (1-3 units) and breaks large composite
7
+ * requests into structured units with explicit verification criteria.
8
+ */
9
+ import type { ModelGateway } from '../intelligence/modelGateway.js';
10
+ import type { DecompositionPlan, DecomposeOptions } from './taskDecompositionTypes.js';
11
+ import { LogLevel } from '../common/logger.js';
12
+ export declare class TaskDecompositionService {
13
+ private modelGateway?;
14
+ private logger;
15
+ constructor(modelGateway?: ModelGateway | undefined, logLevel?: LogLevel);
16
+ /**
17
+ * Analyze goal and produce a decomposition plan.
18
+ */
19
+ decompose(options: DecomposeOptions): Promise<DecompositionPlan>;
20
+ /**
21
+ * Estimate complexity based on linguistic structure, section keywords, and project scope.
22
+ */
23
+ estimateComplexity(goal: string): 'low' | 'medium' | 'high';
24
+ /**
25
+ * Generate structured decomposition plan with dependencies.
26
+ */
27
+ private generateDecompositionPlan;
28
+ /**
29
+ * Extract brand name from prompt text (e.g. 'NOVARA AI', 'NEXORA', 'Bean & Brew', 'DevForge').
30
+ */
31
+ private extractBrandName;
32
+ private inferTargetFiles;
33
+ private extractRequestedFolder;
34
+ private inferProjectFolder;
35
+ }
36
+ //# sourceMappingURL=taskDecompositionService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taskDecompositionService.d.ts","sourceRoot":"","sources":["../../src/orchestration/taskDecompositionService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAU,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEvD,qBAAa,wBAAwB;IAIjC,OAAO,CAAC,YAAY,CAAC;IAHvB,OAAO,CAAC,MAAM,CAAS;gBAGb,YAAY,CAAC,EAAE,YAAY,YAAA,EACnC,QAAQ,GAAE,QAAiB;IAK7B;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuCtE;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM;IAqC3D;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAgQjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,kBAAkB;CAa3B"}