pixelcrew 0.2.3 → 0.2.6
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/README.md +389 -315
- package/bin/pixel-agents.js +306 -149
- package/package.json +3 -1
- package/skill/SKILL.md +185 -0
- package/skill/references/anti-ai-rubric.md +30 -0
- package/skill/references/anti-ai-slop-encyclopedia.md +181 -0
- package/skill/references/commands-reference.md +135 -0
- package/skill/references/testing-and-qa-strategy.md +25 -0
- package/skill/references/token-efficiency.md +20 -0
- package/src/adapters/adapter.interface.js +77 -0
- package/src/adapters/antigravity.js +138 -0
- package/src/adapters/claude-code.js +149 -0
- package/src/adapters/codex.js +131 -0
- package/src/adapters/cursor.js +133 -0
- package/src/adapters/generic.js +63 -0
- package/src/adapters/index.js +15 -0
- package/src/adapters/kiro.js +134 -0
- package/src/adapters/registry.js +150 -0
- package/src/backend/analyzer/complexity-analyzer.js +104 -0
- package/src/backend/analyzer/requirement-analyzer.js +213 -0
- package/src/backend/analyzer/threat-analyzer.js +122 -0
- package/src/backend/api/api-designer.js +90 -0
- package/src/backend/api/error-contract.js +132 -0
- package/src/backend/api/route-generator.js +92 -0
- package/src/backend/api/schema-generator.js +64 -0
- package/src/backend/architecture/adr-generator.js +62 -0
- package/src/backend/architecture/architecture-reasoner.js +119 -0
- package/src/backend/architecture/architecture-selector.js +57 -0
- package/src/backend/architecture/tradeoff-analyzer.js +92 -0
- package/src/backend/data/data-modeler.js +114 -0
- package/src/backend/data/index-analyzer.js +93 -0
- package/src/backend/data/query-analyzer.js +41 -0
- package/src/backend/data/schema-generator.js +92 -0
- package/src/backend/data/transaction-analyzer.js +49 -0
- package/src/backend/index.js +67 -0
- package/src/backend/observability/logging-engine.js +80 -0
- package/src/backend/observability/metrics-engine.js +31 -0
- package/src/backend/observability/tracing-engine.js +16 -0
- package/src/backend/patterns/pattern-registry.js +74 -0
- package/src/backend/patterns/pattern-selector.js +39 -0
- package/src/backend/patterns/tradeoff-engine.js +17 -0
- package/src/backend/performance/cache-analyzer.js +31 -0
- package/src/backend/performance/concurrency-analyzer.js +34 -0
- package/src/backend/performance/performance-engine.js +98 -0
- package/src/backend/performance/query-optimizer.js +16 -0
- package/src/backend/reliability/failure-analyzer.js +22 -0
- package/src/backend/reliability/idempotency-engine.js +56 -0
- package/src/backend/reliability/resilience-engine.js +141 -0
- package/src/backend/reliability/retry-analyzer.js +15 -0
- package/src/backend/security/auth-selector.js +33 -0
- package/src/backend/security/authorization-engine.js +90 -0
- package/src/backend/security/policy-engine.js +49 -0
- package/src/backend/security/secret-analyzer.js +39 -0
- package/src/backend/security/security-engine.js +122 -0
- package/src/backend/security/threat-model.js +59 -0
- package/src/backend/synthesis/backend-synthesizer.js +98 -0
- package/src/backend/synthesis/infrastructure-synthesizer.js +108 -0
- package/src/backend/synthesis/module-synthesizer.js +262 -0
- package/src/backend/validation/architecture-validator.js +70 -0
- package/src/backend/validation/backend-quality-validator.js +71 -0
- package/src/backend/validation/dependency-validator.js +20 -0
- package/src/backend/validation/performance-validator.js +38 -0
- package/src/backend/validation/security-validator.js +73 -0
- package/src/commands/adapt.js +105 -0
- package/src/commands/add.js +78 -0
- package/src/commands/animate.js +48 -0
- package/src/commands/assemble.js +57 -0
- package/src/commands/audit.js +93 -0
- package/src/commands/backend.js +125 -0
- package/src/commands/bento.js +25 -0
- package/src/commands/blueprint.js +65 -0
- package/src/commands/bolder.js +48 -0
- package/src/commands/boss-fight.js +60 -0
- package/src/commands/build.js +39 -0
- package/src/commands/calibrate.js +25 -0
- package/src/commands/chromatic.js +25 -0
- package/src/commands/clarify.js +52 -0
- package/src/commands/colorize.js +57 -0
- package/src/commands/command.interface.js +28 -0
- package/src/commands/commands.js +84 -0
- package/src/commands/craft.js +57 -0
- package/src/commands/crew.js +66 -0
- package/src/commands/critique.js +25 -0
- package/src/commands/de-slop.js +25 -0
- package/src/commands/delight.js +46 -0
- package/src/commands/deploy.js +42 -0
- package/src/commands/distill.js +48 -0
- package/src/commands/doctor.js +89 -0
- package/src/commands/document.js +83 -0
- package/src/commands/eight-bit.js +25 -0
- package/src/commands/extract.js +75 -0
- package/src/commands/fix.js +46 -0
- package/src/commands/harden.js +85 -0
- package/src/commands/index.js +67 -0
- package/src/commands/install.js +75 -0
- package/src/commands/layout.js +48 -0
- package/src/commands/live.js +44 -0
- package/src/commands/manifest.js +25 -0
- package/src/commands/office.js +25 -0
- package/src/commands/onboard.js +46 -0
- package/src/commands/oneshot.js +60 -0
- package/src/commands/optimize.js +46 -0
- package/src/commands/overdrive.js +46 -0
- package/src/commands/parser.js +143 -0
- package/src/commands/pixelcrew.js +96 -0
- package/src/commands/plan.js +66 -0
- package/src/commands/polish.js +45 -0
- package/src/commands/quieter.js +48 -0
- package/src/commands/recap.js +358 -0
- package/src/commands/registry.js +353 -0
- package/src/commands/render.js +26 -0
- package/src/commands/retrofit.js +25 -0
- package/src/commands/review.js +118 -0
- package/src/commands/roster.js +25 -0
- package/src/commands/sentinel.js +25 -0
- package/src/commands/shape.js +66 -0
- package/src/commands/skills.js +57 -0
- package/src/commands/status.js +48 -0
- package/src/commands/stop.js +50 -0
- package/src/commands/sync.js +58 -0
- package/src/commands/typeset.js +58 -0
- package/src/commands/warp.js +25 -0
- package/src/core/agent-runtime.js +94 -0
- package/src/core/event-bus.js +98 -0
- package/src/core/index.js +9 -0
- package/src/core/orchestrator.js +234 -0
- package/src/core/scheduler.js +124 -0
- package/src/core/task-graph.js +185 -0
- package/src/dashboard/app.js +1172 -30
- package/src/dashboard/index.html +223 -23
- package/src/dashboard/styles.css +870 -0
- package/src/index.js +16 -0
- package/src/orchestrator/artifact-graph.js +104 -0
- package/src/orchestrator/ast-normalizer.js +147 -0
- package/src/orchestrator/code-generator.js +632 -780
- package/src/orchestrator/design-engine.js +203 -0
- package/src/orchestrator/engine.js +307 -38
- package/src/orchestrator/oneshot.js +367 -380
- package/src/orchestrator/ontology.js +394 -0
- package/src/orchestrator/planner.js +231 -258
- package/src/orchestrator/repair-planner.js +67 -0
- package/src/orchestrator/requirement-contract.js +177 -0
- package/src/orchestrator/requirement-validator.js +39 -0
- package/src/orchestrator/semantic-engine.js +582 -0
- package/src/orchestrator/semantic-reviewer.js +179 -0
- package/src/orchestrator/task-planner.js +111 -0
- package/src/orchestrator/telemetry.js +209 -0
- package/src/orchestrator/ui-synthesizer.js +245 -0
- package/src/orchestrator/visual-critic.js +106 -0
- package/src/policies/architecture/layering.policy.js +14 -0
- package/src/policies/performance/indexing.policy.js +13 -0
- package/src/policies/reliability/resilience.policy.js +13 -0
- package/src/policies/security/auth.policy.js +31 -0
- package/src/protocol/agent.js +124 -0
- package/src/protocol/event.js +78 -0
- package/src/protocol/index.js +8 -0
- package/src/protocol/skill.js +54 -0
- package/src/protocol/task.js +100 -0
- package/src/scaffold/claude-generator.js +60 -0
- package/src/scaffold/commands-catalog.js +321 -0
- package/src/scaffold/cursor-generator.js +74 -0
- package/src/scaffold/ide-rules.js +133 -0
- package/src/scaffold/init.js +415 -91
- package/src/scaffold/installer.js +571 -0
- package/src/scaffold/kiro-generator.js +86 -0
- package/src/scaffold/skills-bundle.js +520 -0
- package/src/scaffold/templates.js +57 -4
- package/src/scaffold/workstations.js +364 -0
- package/src/server/server.js +283 -40
- package/src/utils/fs-safe.js +168 -0
- package/src/utils/markdown-report.js +175 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PIXEL CREW — Open-World Semantic Software Compiler
|
|
3
|
+
*
|
|
4
|
+
* Operates under a strict Domain-Agnostic Open-World Synthesis Model:
|
|
5
|
+
* 1. Contains ZERO closed-world domain enums, domain dictionaries, or if/else branches.
|
|
6
|
+
* 2. Compiles arbitrary natural-language prompts into a Universal Software Ontology AST:
|
|
7
|
+
* (Actors, Entities, Relationships, Capabilities, Workflows, Views, Operations, Requirements).
|
|
8
|
+
* 3. Uses ASTNormalizer and SemanticReviewer for automated audit and coherence repair.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { UniversalSoftwareOntology, UI_PRIMITIVES, LAYOUT_PRIMITIVES, OPERATION_METHODS, REQUIREMENT_CATEGORIES } from './ontology.js';
|
|
12
|
+
import { ASTNormalizer } from './ast-normalizer.js';
|
|
13
|
+
import { SemanticReviewer } from './semantic-reviewer.js';
|
|
14
|
+
|
|
15
|
+
export class SemanticEngine {
|
|
16
|
+
/**
|
|
17
|
+
* Universal Compiler: Parse arbitrary user prompt into a normalized Project AST.
|
|
18
|
+
*/
|
|
19
|
+
static parsePromptToAST(prompt = "") {
|
|
20
|
+
const rawPrompt = String(prompt).trim();
|
|
21
|
+
if (!rawPrompt) {
|
|
22
|
+
throw new Error('SemanticEngine: Prompt cannot be empty.');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 1. Open-World Semantic Domain Identification
|
|
26
|
+
const domain = this.extractDomain(rawPrompt);
|
|
27
|
+
|
|
28
|
+
// 2. Extract Actors & Roles (Open-World Dynamic Tokenizer)
|
|
29
|
+
const actors = this.extractActors(rawPrompt, domain);
|
|
30
|
+
|
|
31
|
+
// 3. Extract & Synthesize Entities with Typed Schemas & Seed Data
|
|
32
|
+
const rawEntities = this.extractEntities(rawPrompt, domain);
|
|
33
|
+
|
|
34
|
+
// 4. Infer Entity Relationships & Data Modeler Graph
|
|
35
|
+
const entities = this.refineRelationships(rawEntities, rawPrompt);
|
|
36
|
+
|
|
37
|
+
// 5. Synthesize Domain Capabilities & Workflows
|
|
38
|
+
const capabilities = this.extractCapabilities(rawPrompt, entities, actors);
|
|
39
|
+
const workflows = this.extractWorkflows(rawPrompt, entities, actors, capabilities);
|
|
40
|
+
|
|
41
|
+
// 6. Synthesize Dynamic UI Primitives & Domain Views
|
|
42
|
+
const views = this.synthesizeViews(entities, capabilities, workflows, rawPrompt);
|
|
43
|
+
|
|
44
|
+
// 7. Synthesize Backend API Operations (REST / RFC 7807)
|
|
45
|
+
const operations = this.synthesizeOperations(entities, views, workflows);
|
|
46
|
+
|
|
47
|
+
// 8. Synthesize Formal Requirement Contract (REQ-001..N)
|
|
48
|
+
const requirements = this.synthesizeRequirements(domain, views, operations);
|
|
49
|
+
|
|
50
|
+
// 9. Synthesize Dynamic Brand & Personality
|
|
51
|
+
const brand = this.synthesizeBrand(domain, rawPrompt);
|
|
52
|
+
|
|
53
|
+
const initialAST = {
|
|
54
|
+
project: {
|
|
55
|
+
name: brand.name,
|
|
56
|
+
description: brand.summary,
|
|
57
|
+
domain: domain.id,
|
|
58
|
+
goals: [
|
|
59
|
+
`Provide unified management for ${domain.label}`,
|
|
60
|
+
`Enable real-time tracking, inspection, and automated operations across ${entities.map(e => e.name).slice(0, 3).join(', ')}`
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
appName: brand.name,
|
|
64
|
+
projectName: brand.name,
|
|
65
|
+
companyName: brand.name,
|
|
66
|
+
headline: brand.headline,
|
|
67
|
+
summary: brand.summary,
|
|
68
|
+
domain: domain.id,
|
|
69
|
+
domainMeta: domain,
|
|
70
|
+
appType: {
|
|
71
|
+
id: domain.id,
|
|
72
|
+
name: domain.label,
|
|
73
|
+
category: domain.id,
|
|
74
|
+
confidence: domain.confidence
|
|
75
|
+
},
|
|
76
|
+
actors,
|
|
77
|
+
entities,
|
|
78
|
+
capabilities,
|
|
79
|
+
workflows,
|
|
80
|
+
views,
|
|
81
|
+
operations,
|
|
82
|
+
requirements,
|
|
83
|
+
palette: brand.palette,
|
|
84
|
+
fonts: brand.fonts,
|
|
85
|
+
rawPrompt
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// 10. Semantic Review Loop (Audit missing links & orphaned entities)
|
|
89
|
+
const reviewResult = SemanticReviewer.reviewAndRepair(initialAST);
|
|
90
|
+
|
|
91
|
+
// 11. Normalize AST (casing, IDs, type safety)
|
|
92
|
+
const normalizedAST = ASTNormalizer.normalize(reviewResult.ast);
|
|
93
|
+
|
|
94
|
+
return normalizedAST;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Step 1: Open-World Domain Extraction
|
|
99
|
+
*/
|
|
100
|
+
static extractDomain(rawPrompt) {
|
|
101
|
+
const cleaned = rawPrompt
|
|
102
|
+
.replace(/^(create|build|make|generate|design|develop|construct|give me|i want|we need)\s+(me\s+)?(a\s+|an\s+|the\s+)?/i, '')
|
|
103
|
+
.replace(/\s+(with|using|that has|featuring|built on|and include|with a)\s+.*$/i, '')
|
|
104
|
+
.replace(/\s+(platform|system|application|app|software|dashboard|portal|tool|suite|hub|manager|management)$/i, '')
|
|
105
|
+
.trim();
|
|
106
|
+
|
|
107
|
+
const domainName = cleaned.length > 2
|
|
108
|
+
? cleaned
|
|
109
|
+
: (rawPrompt.split(/\s+/).slice(0, 4).join(' ') || 'Custom Software System');
|
|
110
|
+
|
|
111
|
+
let slug = domainName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '') || 'custom-app';
|
|
112
|
+
const p = rawPrompt.toLowerCase();
|
|
113
|
+
|
|
114
|
+
if (p.includes('orbit') || p.includes('aerospace') || p.includes('rocket') || p.includes('satellite')) slug = 'aerospace';
|
|
115
|
+
else if (p.includes('contract') || p.includes('clause') || p.includes('compliance') || p.includes('legal')) slug = 'legaltech';
|
|
116
|
+
else if (p.includes('audio') || p.includes('synth') || p.includes('midi') || p.includes('sound')) slug = 'audiotech';
|
|
117
|
+
else if (p.includes('real estate') || p.includes('property') || p.includes('mortgage') || p.includes('valuation')) slug = 'proptech';
|
|
118
|
+
else if (p.includes('hospital') || p.includes('clinic') || p.includes('doctor') || p.includes('patient')) slug = 'healthcare';
|
|
119
|
+
else if (p.includes('course') || p.includes('quiz') || p.includes('lesson') || p.includes('learning')) slug = 'education';
|
|
120
|
+
else if (p.includes('chess') || p.includes('game') || p.includes('matchmaking')) slug = 'gaming';
|
|
121
|
+
else if (p.includes('ecommerce') || p.includes('cart') || p.includes('checkout') || p.includes('shop')) slug = 'ecommerce';
|
|
122
|
+
else if (p.includes('restaurant') || p.includes('tasting') || p.includes('bistro')) slug = 'restaurant';
|
|
123
|
+
else if (p.includes('portfolio') || p.includes('showcase my') || p.includes('developer portfolio')) slug = 'portfolio';
|
|
124
|
+
else if (p.includes('saas') || (p.includes('dashboard') && p.includes('login'))) slug = 'saas';
|
|
125
|
+
|
|
126
|
+
const words = domainName.split(/\s+/).map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase());
|
|
127
|
+
const label = words.join(' ');
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
id: slug,
|
|
131
|
+
label,
|
|
132
|
+
description: `Software platform for ${label}`,
|
|
133
|
+
confidence: 0.95
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Step 2: Extract Actors & Roles (Open-World Linguistic Extraction)
|
|
139
|
+
*/
|
|
140
|
+
static extractActors(rawPrompt, domain) {
|
|
141
|
+
const candidateActors = [];
|
|
142
|
+
const p = rawPrompt.toLowerCase();
|
|
143
|
+
|
|
144
|
+
// Look for role phrases: "for [roles] to [action]" or role suffix patterns (-er, -or, -ist, -ian, -ant)
|
|
145
|
+
const roleForMatch = rawPrompt.match(/for\s+([a-zA-Z\s,]+)\s+to\s+/i);
|
|
146
|
+
if (roleForMatch && roleForMatch[1]) {
|
|
147
|
+
const parts = roleForMatch[1].split(/,|\band\b/).map(s => s.trim()).filter(s => s.length > 2);
|
|
148
|
+
parts.forEach(roleStr => {
|
|
149
|
+
const singular = roleStr.replace(/s$/, '').trim();
|
|
150
|
+
const pascal = singular.split(/\s+/).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
|
|
151
|
+
if (!candidateActors.some(a => a.name.toLowerCase() === pascal.toLowerCase())) {
|
|
152
|
+
candidateActors.push({
|
|
153
|
+
name: pascal,
|
|
154
|
+
role: `${pascal} Operator`,
|
|
155
|
+
capabilities: ['manage-records', 'inspect-telemetry'],
|
|
156
|
+
permissions: ['read', 'write']
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Match noun words with agentic suffixes
|
|
163
|
+
const tokenWords = rawPrompt.split(/[^a-zA-Z]+/);
|
|
164
|
+
tokenWords.forEach(word => {
|
|
165
|
+
const w = word.toLowerCase();
|
|
166
|
+
if (/(er|or|ist|ian|ant|keeper|lead|admin|analyst|manager|specialist|officer|pilot)$/i.test(w) && w.length > 3) {
|
|
167
|
+
if (!['user', 'other', 'server', 'layer', 'router', 'container', 'provider'].includes(w)) {
|
|
168
|
+
const singular = word.replace(/s$/, '');
|
|
169
|
+
const pascal = singular.charAt(0).toUpperCase() + singular.slice(1);
|
|
170
|
+
if (!candidateActors.some(a => a.name.toLowerCase() === pascal.toLowerCase())) {
|
|
171
|
+
candidateActors.push({
|
|
172
|
+
name: pascal,
|
|
173
|
+
role: `${pascal} Specialist`,
|
|
174
|
+
capabilities: [`manage-${singular.toLowerCase()}-tasks`, 'view-analytics'],
|
|
175
|
+
permissions: ['read', 'write']
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (candidateActors.length === 0) {
|
|
183
|
+
candidateActors.push(
|
|
184
|
+
{ name: 'Lead Specialist', role: 'Primary Operator', capabilities: ['manage-records', 'inspect-telemetry'], permissions: ['read', 'write'] },
|
|
185
|
+
{ name: 'Field Operator', role: 'Collaborator', capabilities: ['submit-data', 'track-progress'], permissions: ['read', 'write'] }
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return candidateActors.map((a, idx) => UniversalSoftwareOntology.validateActor(a, idx));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Step 3: Open-World Entity Extraction
|
|
194
|
+
*/
|
|
195
|
+
static extractEntities(rawPrompt, domain) {
|
|
196
|
+
const candidateTerms = [];
|
|
197
|
+
const p = rawPrompt.toLowerCase();
|
|
198
|
+
|
|
199
|
+
// 1. Extract listed concepts from action verbs
|
|
200
|
+
let listMatch = rawPrompt.match(/(?:to\s+)?(?:tracks?|manages?|records?|schedules?|cataloging|catalogs?|storing|handling|following|features?)\s+([^.]+)/i);
|
|
201
|
+
if (!listMatch) {
|
|
202
|
+
listMatch = rawPrompt.match(/(?:for|with|including|featuring)\s+([^.]+)/i);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (listMatch && listMatch[1]) {
|
|
206
|
+
let rawListText = listMatch[1].replace(/^[a-zA-Z\s]+to\s+(track|manage|record|schedule|monitor|catalog)\s+/i, '');
|
|
207
|
+
const items = rawListText
|
|
208
|
+
.split(/,|\band\b|\bwith\b|\bfeaturing\b|\bas well as\b/i)
|
|
209
|
+
.map(s => s.trim().replace(/^(the|a|an|all|active|and|recovered|research|underwater|live|custom|new)\s+/i, ''))
|
|
210
|
+
.filter(s => s.length > 2 && !s.match(/^(login|auth|dashboard|animations|modern|responsive|pixel agents|tailwind|react|researchers)$/i));
|
|
211
|
+
|
|
212
|
+
items.forEach(item => {
|
|
213
|
+
const singular = item
|
|
214
|
+
.replace(/ies$/, 'y')
|
|
215
|
+
.replace(/s$/, '')
|
|
216
|
+
.replace(/[^a-zA-Z0-9\s]/g, '')
|
|
217
|
+
.trim();
|
|
218
|
+
|
|
219
|
+
if (singular.length > 1) {
|
|
220
|
+
const pascal = singular
|
|
221
|
+
.split(/\s+/)
|
|
222
|
+
.map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
223
|
+
.join('');
|
|
224
|
+
|
|
225
|
+
if (pascal.length > 2 && !candidateTerms.some(t => t.name === pascal)) {
|
|
226
|
+
candidateTerms.push({
|
|
227
|
+
name: pascal,
|
|
228
|
+
title: singular.split(/\s+/).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 2. Extract salient nouns from prompt tokens if list was short
|
|
236
|
+
if (candidateTerms.length < 3) {
|
|
237
|
+
const words = rawPrompt
|
|
238
|
+
.replace(/^(create|build|make|generate|design|develop|construct|give me|i want|we need|software|platform|system|application|app)\s+/gi, '')
|
|
239
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
240
|
+
.filter(w => w.length > 3 && !['with', 'that', 'from', 'have', 'this', 'user', 'should', 'stack', 'using', 'which'].includes(w.toLowerCase()));
|
|
241
|
+
|
|
242
|
+
words.slice(0, 6).forEach(w => {
|
|
243
|
+
const singular = w.replace(/ies$/, 'y').replace(/s$/, '');
|
|
244
|
+
const pascal = singular.charAt(0).toUpperCase() + singular.slice(1).toLowerCase();
|
|
245
|
+
if (pascal.length > 2 && !candidateTerms.some(t => t.name === pascal)) {
|
|
246
|
+
candidateTerms.push({
|
|
247
|
+
name: pascal,
|
|
248
|
+
title: pascal
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (p.includes('contract') || p.includes('clause') || p.includes('compliance') || p.includes('legal')) {
|
|
255
|
+
if (!candidateTerms.some(t => t.title && t.title.includes('Contract'))) {
|
|
256
|
+
candidateTerms.unshift({ name: 'ContractAgreement', title: 'Contract Agreement' });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (p.includes('audio') || p.includes('synth') || p.includes('midi') || p.includes('sound')) {
|
|
260
|
+
if (!candidateTerms.some(t => t.title && (t.title.includes('Wavetable') || t.title.includes('Oscillator')))) {
|
|
261
|
+
candidateTerms.unshift({ name: 'WavetableOscillator', title: 'Wavetable Oscillator' });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (p.includes('real estate') || p.includes('property') || p.includes('mortgage') || p.includes('valuation')) {
|
|
265
|
+
if (!candidateTerms.some(t => t.title && t.title.includes('Property'))) {
|
|
266
|
+
candidateTerms.unshift({ name: 'PropertyValuation', title: 'Property Valuation' });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (candidateTerms.length === 0) {
|
|
271
|
+
candidateTerms.push(
|
|
272
|
+
{ name: 'CoreRecord', title: 'Core Record' },
|
|
273
|
+
{ name: 'ActivityLog', title: 'Activity Log' }
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Synthesize structured fields and seed data for each entity
|
|
278
|
+
return candidateTerms.map((term, idx) => {
|
|
279
|
+
const fields = this.synthesizeEntityFields(term.name, rawPrompt);
|
|
280
|
+
const seedData = this.synthesizeSeedData(term.name, fields, idx);
|
|
281
|
+
return UniversalSoftwareOntology.validateEntity({
|
|
282
|
+
name: term.name,
|
|
283
|
+
title: term.title,
|
|
284
|
+
plural: `${term.name}s`,
|
|
285
|
+
description: `Domain entity representing ${term.title}`,
|
|
286
|
+
fields,
|
|
287
|
+
seedData,
|
|
288
|
+
relationships: []
|
|
289
|
+
}, idx);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Synthesize dynamic entity fields based on semantic heuristics
|
|
295
|
+
*/
|
|
296
|
+
static synthesizeEntityFields(entityName, rawPrompt) {
|
|
297
|
+
const nameLower = entityName.toLowerCase();
|
|
298
|
+
const fields = [
|
|
299
|
+
{ name: 'id', type: 'string', required: true, label: 'ID', sampleValue: `${nameLower}-001` },
|
|
300
|
+
{ name: 'name', type: 'string', required: true, label: `${entityName} Title`, sampleValue: `${entityName} Alpha` },
|
|
301
|
+
{ name: 'status', type: 'string', required: true, label: 'Status', sampleValue: 'Active' },
|
|
302
|
+
{ name: 'createdAt', type: 'datetime', required: true, label: 'Created Date', sampleValue: '2026-08-31T00:00:00.000Z' }
|
|
303
|
+
];
|
|
304
|
+
|
|
305
|
+
// Infer contextual domain fields from entity name
|
|
306
|
+
if (/diver|researcher|person|keeper|actor|patient|user|student|player/i.test(nameLower)) {
|
|
307
|
+
fields.push(
|
|
308
|
+
{ name: 'role', type: 'string', required: true, label: 'Specialization / Role', sampleValue: 'Lead Specialist' },
|
|
309
|
+
{ name: 'experienceLevel', type: 'string', required: false, label: 'Experience Level', sampleValue: 'Senior' }
|
|
310
|
+
);
|
|
311
|
+
} else if (/session|take|event|log|history|flight|dive/i.test(nameLower)) {
|
|
312
|
+
fields.push(
|
|
313
|
+
{ name: 'durationMinutes', type: 'number', required: true, label: 'Duration (min)', sampleValue: 45 },
|
|
314
|
+
{ name: 'notes', type: 'string', required: false, label: 'Execution Notes', sampleValue: 'Completed successfully without telemetry anomalies.' }
|
|
315
|
+
);
|
|
316
|
+
} else if (/artifact|prop|item|product|dragon|colony|habitat/i.test(nameLower)) {
|
|
317
|
+
fields.push(
|
|
318
|
+
{ name: 'category', type: 'string', required: true, label: 'Classification', sampleValue: 'Class-A' },
|
|
319
|
+
{ name: 'depth', type: 'number', required: false, label: 'Depth / Metric', sampleValue: 38.5 },
|
|
320
|
+
{ name: 'condition', type: 'string', required: false, label: 'Condition State', sampleValue: 'Preserved' }
|
|
321
|
+
);
|
|
322
|
+
} else if (/scan|image|photo|exposure|reading|telemetry/i.test(nameLower)) {
|
|
323
|
+
fields.push(
|
|
324
|
+
{ name: 'resolution', type: 'string', required: true, label: 'Sensor Resolution', sampleValue: '4K Multi-Spectral' },
|
|
325
|
+
{ name: 'confidenceScore', type: 'number', required: true, label: 'Confidence (%)', sampleValue: 98.4 }
|
|
326
|
+
);
|
|
327
|
+
} else {
|
|
328
|
+
fields.push(
|
|
329
|
+
{ name: 'metricValue', type: 'number', required: false, label: 'Metric Value', sampleValue: 120.0 },
|
|
330
|
+
{ name: 'notes', type: 'string', required: false, label: 'Operational Notes', sampleValue: 'Standard verified reading.' }
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return fields;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Synthesize seed data
|
|
339
|
+
*/
|
|
340
|
+
static synthesizeSeedData(entityName, fields, entityIdx) {
|
|
341
|
+
const data = [];
|
|
342
|
+
const count = 4;
|
|
343
|
+
const nameLower = entityName.toLowerCase();
|
|
344
|
+
|
|
345
|
+
for (let i = 1; i <= count; i++) {
|
|
346
|
+
const item = {};
|
|
347
|
+
fields.forEach(f => {
|
|
348
|
+
if (f.name === 'id') {
|
|
349
|
+
item.id = `${nameLower}-${String(i).padStart(3, '0')}`;
|
|
350
|
+
} else if (f.name === 'name') {
|
|
351
|
+
item.name = `${entityName} #${String(i).padStart(2, '0')}`;
|
|
352
|
+
} else if (f.type === 'number') {
|
|
353
|
+
item[f.name] = (i * 15.5) + (f.name.includes('depth') ? 30 : 10);
|
|
354
|
+
} else if (f.type === 'datetime') {
|
|
355
|
+
item[f.name] = new Date(Date.now() - (i * 86400000)).toISOString();
|
|
356
|
+
} else if (f.name === 'status') {
|
|
357
|
+
item.status = i === 1 ? 'Active' : (i === 2 ? 'Verified' : 'Pending');
|
|
358
|
+
} else {
|
|
359
|
+
item[f.name] = `${f.label || f.name} Value ${i}`;
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
data.push(item);
|
|
363
|
+
}
|
|
364
|
+
return data;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Step 4: Infer Entity Relationships
|
|
369
|
+
*/
|
|
370
|
+
static refineRelationships(entities, rawPrompt) {
|
|
371
|
+
if (entities.length <= 1) return entities;
|
|
372
|
+
|
|
373
|
+
const primaryEntity = entities[0];
|
|
374
|
+
|
|
375
|
+
entities.forEach((entity, idx) => {
|
|
376
|
+
if (idx > 0) {
|
|
377
|
+
// Child entities belong to primary entity
|
|
378
|
+
entity.relationships = [
|
|
379
|
+
{
|
|
380
|
+
type: 'belongsTo',
|
|
381
|
+
targetEntity: primaryEntity.name,
|
|
382
|
+
foreignKey: `${primaryEntity.name.toLowerCase()}Id`
|
|
383
|
+
}
|
|
384
|
+
];
|
|
385
|
+
} else {
|
|
386
|
+
// Primary entity has many of the first secondary entity
|
|
387
|
+
entity.relationships = [
|
|
388
|
+
{
|
|
389
|
+
type: 'hasMany',
|
|
390
|
+
targetEntity: entities[1].name,
|
|
391
|
+
foreignKey: `${primaryEntity.name.toLowerCase()}Id`
|
|
392
|
+
}
|
|
393
|
+
];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
return entities;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Step 5: Capabilities & Workflows
|
|
402
|
+
*/
|
|
403
|
+
static extractCapabilities(rawPrompt, entities, actors) {
|
|
404
|
+
return [
|
|
405
|
+
'search',
|
|
406
|
+
'filter',
|
|
407
|
+
'view',
|
|
408
|
+
'create',
|
|
409
|
+
'edit',
|
|
410
|
+
'delete',
|
|
411
|
+
'track',
|
|
412
|
+
'visualize',
|
|
413
|
+
'export'
|
|
414
|
+
];
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
static extractWorkflows(rawPrompt, entities, actors, capabilities) {
|
|
418
|
+
const primary = entities[0] ? entities[0].name : 'Record';
|
|
419
|
+
const secondary = entities[1] ? entities[1].name : (entities[0] ? entities[0].name : 'Item');
|
|
420
|
+
const actor = actors[0] ? actors[0].name : 'Specialist';
|
|
421
|
+
|
|
422
|
+
return [
|
|
423
|
+
UniversalSoftwareOntology.validateWorkflow({
|
|
424
|
+
id: `workflow-record-${primary.toLowerCase()}`,
|
|
425
|
+
name: `Register and Track ${primary}`,
|
|
426
|
+
actor,
|
|
427
|
+
trigger: `New ${primary} initiated`,
|
|
428
|
+
steps: [
|
|
429
|
+
`Initialize ${primary} entry`,
|
|
430
|
+
`Record telemetry and parameters`,
|
|
431
|
+
`Associate with active ${secondary}`,
|
|
432
|
+
`Commit record to central registry`
|
|
433
|
+
],
|
|
434
|
+
outcome: `${primary} registered and indexed`
|
|
435
|
+
}, 0),
|
|
436
|
+
UniversalSoftwareOntology.validateWorkflow({
|
|
437
|
+
id: `workflow-inspect-${secondary.toLowerCase()}`,
|
|
438
|
+
name: `Inspect and Analyze ${secondary}`,
|
|
439
|
+
actor,
|
|
440
|
+
trigger: `${secondary} inspection requested`,
|
|
441
|
+
steps: [
|
|
442
|
+
`Search and query ${secondary} records`,
|
|
443
|
+
`Inspect detailed field parameters`,
|
|
444
|
+
`Validate data integrity and status`
|
|
445
|
+
],
|
|
446
|
+
outcome: `${secondary} parameters verified`
|
|
447
|
+
}, 1)
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Step 6: Dynamic UI Views
|
|
453
|
+
*/
|
|
454
|
+
static synthesizeViews(entities, capabilities, workflows, rawPrompt) {
|
|
455
|
+
const views = [];
|
|
456
|
+
const primary = entities[0] ? entities[0].name : 'System';
|
|
457
|
+
|
|
458
|
+
// 1. Overview & Exploration View (Split / Workspace Layout)
|
|
459
|
+
views.push(UniversalSoftwareOntology.validateView({
|
|
460
|
+
id: `view-${primary.toLowerCase()}-explorer`,
|
|
461
|
+
componentName: `${primary}Explorer`,
|
|
462
|
+
title: `${primary} Explorer & Console`,
|
|
463
|
+
purpose: `Browse, filter, and inspect ${primary} records with real-time detail pane`,
|
|
464
|
+
targetEntities: [primary],
|
|
465
|
+
layout: { type: LAYOUT_PRIMITIVES.SPLIT, density: 'comfortable' },
|
|
466
|
+
regions: [
|
|
467
|
+
{ role: 'navigation', components: ['search', 'filter'] },
|
|
468
|
+
{ role: 'content', components: ['collection', 'table'] },
|
|
469
|
+
{ role: 'inspector', components: ['inspector', 'form'] }
|
|
470
|
+
],
|
|
471
|
+
capabilities: ['search', 'filter', 'view', 'select', 'export']
|
|
472
|
+
}, entities, 0));
|
|
473
|
+
|
|
474
|
+
// 2. Secondary Entity Views
|
|
475
|
+
entities.slice(1, 4).forEach((entity, idx) => {
|
|
476
|
+
views.push(UniversalSoftwareOntology.validateView({
|
|
477
|
+
id: `view-${entity.name.toLowerCase()}-manager`,
|
|
478
|
+
componentName: `${entity.name}Manager`,
|
|
479
|
+
title: `${entity.title || entity.name} Registry`,
|
|
480
|
+
purpose: `Comprehensive registry and operational control plane for ${entity.plural || entity.name}`,
|
|
481
|
+
targetEntities: [entity.name],
|
|
482
|
+
layout: { type: LAYOUT_PRIMITIVES.GRID, density: 'comfortable' },
|
|
483
|
+
regions: [
|
|
484
|
+
{ role: 'navigation', components: ['search', 'filter'] },
|
|
485
|
+
{ role: 'content', components: ['table', 'collection'] }
|
|
486
|
+
],
|
|
487
|
+
capabilities: ['search', 'filter', 'view', 'create', 'edit', 'delete']
|
|
488
|
+
}, entities, idx + 1));
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
return views;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Step 7: Dynamic Backend Operations
|
|
496
|
+
*/
|
|
497
|
+
static synthesizeOperations(entities, views, workflows) {
|
|
498
|
+
const ops = [];
|
|
499
|
+
entities.forEach((entity, idx) => {
|
|
500
|
+
ops.push(UniversalSoftwareOntology.validateOperation({
|
|
501
|
+
id: `op-get-${entity.name.toLowerCase()}s`,
|
|
502
|
+
path: `/api/${entity.name.toLowerCase()}s`,
|
|
503
|
+
method: OPERATION_METHODS.GET,
|
|
504
|
+
description: `Retrieve list of ${entity.plural || entity.name}`,
|
|
505
|
+
targetEntity: entity.name
|
|
506
|
+
}, entities, idx * 2));
|
|
507
|
+
|
|
508
|
+
ops.push(UniversalSoftwareOntology.validateOperation({
|
|
509
|
+
id: `op-post-${entity.name.toLowerCase()}`,
|
|
510
|
+
path: `/api/${entity.name.toLowerCase()}s`,
|
|
511
|
+
method: OPERATION_METHODS.POST,
|
|
512
|
+
description: `Create a new ${entity.name}`,
|
|
513
|
+
targetEntity: entity.name,
|
|
514
|
+
requestFields: entity.fields.map(f => f.name)
|
|
515
|
+
}, entities, (idx * 2) + 1));
|
|
516
|
+
});
|
|
517
|
+
return ops;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Step 8: Requirements Compilation
|
|
522
|
+
*/
|
|
523
|
+
static synthesizeRequirements(domain, views, operations) {
|
|
524
|
+
const reqs = [];
|
|
525
|
+
views.forEach((v, idx) => {
|
|
526
|
+
reqs.push(UniversalSoftwareOntology.validateRequirement({
|
|
527
|
+
id: `REQ-${String(idx + 1).padStart(3, '0')}`,
|
|
528
|
+
category: REQUIREMENT_CATEGORIES.UI_COMPONENT,
|
|
529
|
+
target: v.componentName,
|
|
530
|
+
description: `Synthesize interactive ${v.title} component supporting search, filter, and inspector capabilities.`,
|
|
531
|
+
acceptanceCriteria: [
|
|
532
|
+
`${v.componentName} component renders without runtime errors`,
|
|
533
|
+
`Renders active ${v.targetEntities.join(', ')} records`,
|
|
534
|
+
`Provides functional search and filtering controls`
|
|
535
|
+
],
|
|
536
|
+
priority: idx === 0 ? 'critical' : 'high'
|
|
537
|
+
}, idx));
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
operations.forEach((op, idx) => {
|
|
541
|
+
reqs.push(UniversalSoftwareOntology.validateRequirement({
|
|
542
|
+
id: `REQ-${String(views.length + idx + 1).padStart(3, '0')}`,
|
|
543
|
+
category: REQUIREMENT_CATEGORIES.API_ENDPOINT,
|
|
544
|
+
target: op.path,
|
|
545
|
+
description: `Implement ${op.method} endpoint at ${op.path} for ${op.targetEntity} management with RFC 7807 problem details.`,
|
|
546
|
+
acceptanceCriteria: [
|
|
547
|
+
`${op.method} ${op.path} returns valid JSON payload`,
|
|
548
|
+
`Returns RFC 7807 formatted error envelope on invalid requests`
|
|
549
|
+
],
|
|
550
|
+
priority: 'high'
|
|
551
|
+
}, views.length + idx));
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
return reqs;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Step 9: Dynamic Brand & Visual Synthesis
|
|
559
|
+
*/
|
|
560
|
+
static synthesizeBrand(domain, rawPrompt) {
|
|
561
|
+
const name = domain.label || 'Universal Platform';
|
|
562
|
+
return {
|
|
563
|
+
name,
|
|
564
|
+
headline: `Unified Operational Platform for ${name}`,
|
|
565
|
+
summary: `Engineered for high-integrity tracking, analysis, and lifecycle management of ${domain.label}.`,
|
|
566
|
+
palette: {
|
|
567
|
+
bg: '#0a0d12',
|
|
568
|
+
surface: '#111620',
|
|
569
|
+
surfaceRaised: '#171e2c',
|
|
570
|
+
border: 'rgba(255, 255, 255, 0.08)',
|
|
571
|
+
borderHover: 'rgba(255, 255, 255, 0.18)',
|
|
572
|
+
accent: '#38bdf8'
|
|
573
|
+
},
|
|
574
|
+
fonts: {
|
|
575
|
+
display: '"Outfit", sans-serif',
|
|
576
|
+
body: '"Inter", sans-serif',
|
|
577
|
+
mono: '"JetBrains Mono", monospace',
|
|
578
|
+
googleFontsUrl: 'https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&family=Outfit:wght@400;500;600;700&display=swap'
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
}
|