agent-enderun 1.1.5 → 1.1.7
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/ENDERUN.md +13 -10
- package/README.md +14 -31
- package/bin/run-multi-test.js +77 -0
- package/dist/framework-mcp/src/tools/dashboard/start_dashboard.d.ts +5 -0
- package/dist/framework-mcp/src/tools/dashboard/start_dashboard.js +30 -0
- package/dist/framework-mcp/src/tools/dashboard/start_dashboard.js.map +1 -0
- package/dist/framework-mcp/src/tools/definitions.js +118 -0
- package/dist/framework-mcp/src/tools/definitions.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.d.ts +5 -0
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +51 -0
- package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js.map +1 -0
- package/dist/framework-mcp/src/tools/file_system/replace_text.js +8 -4
- package/dist/framework-mcp/src/tools/file_system/replace_text.js.map +1 -1
- package/dist/framework-mcp/src/tools/file_system/write_file.js +3 -0
- package/dist/framework-mcp/src/tools/file_system/write_file.js.map +1 -1
- package/dist/framework-mcp/src/tools/framework/audit_deps.d.ts +6 -0
- package/dist/framework-mcp/src/tools/framework/audit_deps.js +42 -0
- package/dist/framework-mcp/src/tools/framework/audit_deps.js.map +1 -0
- package/dist/framework-mcp/src/tools/framework/run_tests.d.ts +5 -0
- package/dist/framework-mcp/src/tools/framework/run_tests.js +26 -0
- package/dist/framework-mcp/src/tools/framework/run_tests.js.map +1 -0
- package/dist/framework-mcp/src/tools/index.js +24 -0
- package/dist/framework-mcp/src/tools/index.js.map +1 -1
- package/dist/framework-mcp/src/tools/memory/get_insights.d.ts +6 -0
- package/dist/framework-mcp/src/tools/memory/get_insights.js +35 -0
- package/dist/framework-mcp/src/tools/memory/get_insights.js.map +1 -0
- package/dist/framework-mcp/src/tools/memory/read_memory.d.ts +6 -0
- package/dist/framework-mcp/src/tools/memory/read_memory.js +29 -0
- package/dist/framework-mcp/src/tools/memory/read_memory.js.map +1 -0
- package/dist/framework-mcp/src/tools/messaging/send_message.js +1 -1
- package/dist/framework-mcp/src/tools/messaging/send_message.js.map +1 -1
- package/dist/framework-mcp/src/tools/observability/check_ports.d.ts +5 -0
- package/dist/framework-mcp/src/tools/observability/check_ports.js +27 -0
- package/dist/framework-mcp/src/tools/observability/check_ports.js.map +1 -0
- package/dist/framework-mcp/src/tools/observability/get_health.d.ts +5 -0
- package/dist/framework-mcp/src/tools/observability/get_health.js +21 -0
- package/dist/framework-mcp/src/tools/observability/get_health.js.map +1 -0
- package/dist/framework-mcp/src/tools/search/get_gaps.d.ts +6 -0
- package/dist/framework-mcp/src/tools/search/get_gaps.js +49 -0
- package/dist/framework-mcp/src/tools/search/get_gaps.js.map +1 -0
- package/dist/framework-mcp/src/tools/search/get_map.d.ts +6 -0
- package/dist/framework-mcp/src/tools/search/get_map.js +45 -0
- package/dist/framework-mcp/src/tools/search/get_map.js.map +1 -0
- package/dist/framework-mcp/src/tools/search/grep_search.d.ts +5 -0
- package/dist/framework-mcp/src/tools/search/grep_search.js +60 -0
- package/dist/framework-mcp/src/tools/search/grep_search.js.map +1 -0
- package/dist/framework-mcp/src/tools/search/list_dir.d.ts +5 -0
- package/dist/framework-mcp/src/tools/search/list_dir.js +29 -0
- package/dist/framework-mcp/src/tools/search/list_dir.js.map +1 -0
- package/dist/framework-mcp/src/tools/types.d.ts +10 -5
- package/dist/framework-mcp/src/utils/compliance.d.ts +5 -0
- package/dist/framework-mcp/src/utils/compliance.js +30 -0
- package/dist/framework-mcp/src/utils/compliance.js.map +1 -0
- package/dist/framework-mcp/tests/tools/messaging/send_message.test.js +5 -5
- package/dist/framework-mcp/tests/tools/messaging/send_message.test.js.map +1 -1
- package/dist/src/cli/adapters/types.d.ts +2 -2
- package/dist/src/cli/adapters.d.ts +1 -1
- package/dist/src/cli/adapters.js +45 -77
- package/dist/src/cli/adapters.js.map +1 -1
- package/dist/src/cli/commands/check.js +52 -6
- package/dist/src/cli/commands/check.js.map +1 -1
- package/dist/src/cli/commands/init.d.ts +5 -1
- package/dist/src/cli/commands/init.js +184 -106
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/orchestrate.d.ts +3 -3
- package/dist/src/cli/commands/orchestrate.js +14 -8
- package/dist/src/cli/commands/orchestrate.js.map +1 -1
- package/dist/src/cli/commands/status.js +3 -2
- package/dist/src/cli/commands/status.js.map +1 -1
- package/dist/src/cli/index.js +4 -3
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/shims.js +6 -6
- package/dist/src/cli/utils/app-backend.d.ts +2 -0
- package/dist/src/cli/utils/app-backend.js +236 -0
- package/dist/src/cli/utils/app-backend.js.map +1 -0
- package/dist/src/cli/utils/app-docs.d.ts +3 -0
- package/dist/src/cli/utils/app-docs.js +59 -0
- package/dist/src/cli/utils/app-docs.js.map +1 -0
- package/dist/src/cli/utils/app-frontend.d.ts +2 -0
- package/dist/src/cli/utils/app-frontend.js +248 -0
- package/dist/src/cli/utils/app-frontend.js.map +1 -0
- package/dist/src/cli/utils/app-inferrer.d.ts +14 -0
- package/dist/src/cli/utils/app-inferrer.js +39 -0
- package/dist/src/cli/utils/app-inferrer.js.map +1 -0
- package/dist/src/cli/utils/app-types.d.ts +3 -0
- package/dist/src/cli/utils/app-types.js +233 -0
- package/dist/src/cli/utils/app-types.js.map +1 -0
- package/dist/src/cli/utils/app.d.ts +5 -32
- package/dist/src/cli/utils/app.js +5 -794
- package/dist/src/cli/utils/app.js.map +1 -1
- package/dist/src/cli/utils/memory.js +8 -4
- package/dist/src/cli/utils/memory.js.map +1 -1
- package/dist/src/modules/adapters/antigravity-cli.js +3 -3
- package/dist/src/modules/adapters/antigravity-cli.js.map +1 -1
- package/dist/src/modules/adapters/claude.js +1 -1
- package/dist/src/modules/adapters/claude.js.map +1 -1
- package/dist/src/modules/adapters/codex.js +2 -2
- package/dist/src/modules/adapters/codex.js.map +1 -1
- package/dist/src/modules/adapters/cursor.js +1 -1
- package/dist/src/modules/adapters/cursor.js.map +1 -1
- package/dist/src/modules/adapters/definitions.d.ts +9 -0
- package/dist/src/modules/adapters/definitions.js +124 -0
- package/dist/src/modules/adapters/definitions.js.map +1 -0
- package/dist/src/modules/adapters/gemini.js +2 -2
- package/dist/src/modules/adapters/gemini.js.map +1 -1
- package/dist/src/modules/adapters/grok.js +1 -1
- package/dist/src/modules/adapters/grok.js.map +1 -1
- package/dist/src/modules/agents/definitions.js +26 -27
- package/dist/src/modules/agents/definitions.js.map +1 -1
- package/dist/src/shared/config.d.ts +3 -3
- package/dist/src/shared/logger.js +8 -5
- package/dist/src/shared/logger.js.map +1 -1
- package/dist/tests/adapter.test.d.ts +1 -0
- package/dist/tests/adapter.test.js +129 -0
- package/dist/tests/adapter.test.js.map +1 -0
- package/dist/tests/agents-definitions.test.d.ts +1 -0
- package/dist/tests/agents-definitions.test.js +54 -0
- package/dist/tests/agents-definitions.test.js.map +1 -0
- package/dist/tests/approve.test.d.ts +1 -0
- package/dist/tests/approve.test.js +88 -0
- package/dist/tests/approve.test.js.map +1 -0
- package/dist/tests/config.test.d.ts +1 -0
- package/dist/tests/config.test.js +58 -0
- package/dist/tests/config.test.js.map +1 -0
- package/dist/tests/container.runner.d.ts +1 -0
- package/dist/tests/container.runner.js +68 -0
- package/dist/tests/container.runner.js.map +1 -0
- package/dist/tests/container.test.d.ts +1 -0
- package/dist/tests/container.test.js +73 -0
- package/dist/tests/container.test.js.map +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/errors.test.js +64 -0
- package/dist/tests/errors.test.js.map +1 -0
- package/dist/tests/fs-utils.test.d.ts +1 -0
- package/dist/tests/fs-utils.test.js +101 -0
- package/dist/tests/fs-utils.test.js.map +1 -0
- package/dist/tests/logger.test.d.ts +1 -0
- package/dist/tests/logger.test.js +81 -0
- package/dist/tests/logger.test.js.map +1 -0
- package/dist/tests/memory-utils.test.d.ts +1 -0
- package/dist/tests/memory-utils.test.js +173 -0
- package/dist/tests/memory-utils.test.js.map +1 -0
- package/dist/tests/orchestrate.test.d.ts +1 -0
- package/dist/tests/orchestrate.test.js +131 -0
- package/dist/tests/orchestrate.test.js.map +1 -0
- package/dist/tests/skills-definitions.test.d.ts +1 -0
- package/dist/tests/skills-definitions.test.js +34 -0
- package/dist/tests/skills-definitions.test.js.map +1 -0
- package/dist/tests/status.test.d.ts +1 -0
- package/dist/tests/status.test.js +105 -0
- package/dist/tests/status.test.js.map +1 -0
- package/dist/tests/string.test.d.ts +1 -0
- package/dist/tests/string.test.js +89 -0
- package/dist/tests/string.test.js.map +1 -0
- package/dist/tests/time.test.d.ts +1 -0
- package/dist/tests/time.test.js +48 -0
- package/dist/tests/time.test.js.map +1 -0
- package/dist/tests/trace.test.d.ts +1 -0
- package/dist/tests/trace.test.js +61 -0
- package/dist/tests/trace.test.js.map +1 -0
- package/dist/vitest.config.js +1 -0
- package/dist/vitest.config.js.map +1 -1
- package/docs/getting-started.md +4 -0
- package/docs/user/corporate-governance.md +25 -0
- package/framework-mcp/dist/tools/dashboard/start_dashboard.js +29 -0
- package/framework-mcp/dist/tools/definitions.js +118 -0
- package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +50 -0
- package/framework-mcp/dist/tools/file_system/replace_text.js +8 -4
- package/framework-mcp/dist/tools/file_system/write_file.js +3 -0
- package/framework-mcp/dist/tools/framework/audit_deps.js +41 -0
- package/framework-mcp/dist/tools/framework/run_tests.js +25 -0
- package/framework-mcp/dist/tools/index.js +24 -0
- package/framework-mcp/dist/tools/memory/get_insights.js +34 -0
- package/framework-mcp/dist/tools/memory/read_memory.js +28 -0
- package/framework-mcp/dist/tools/messaging/send_message.js +1 -1
- package/framework-mcp/dist/tools/observability/check_ports.js +26 -0
- package/framework-mcp/dist/tools/observability/get_health.js +20 -0
- package/framework-mcp/dist/tools/search/get_gaps.js +48 -0
- package/framework-mcp/dist/tools/search/get_map.js +44 -0
- package/framework-mcp/dist/tools/search/grep_search.js +59 -0
- package/framework-mcp/dist/tools/search/list_dir.js +28 -0
- package/framework-mcp/dist/utils/compliance.js +29 -0
- package/framework-mcp/package.json +1 -1
- package/framework-mcp/src/tools/dashboard/start_dashboard.ts +33 -0
- package/framework-mcp/src/tools/definitions.ts +118 -0
- package/framework-mcp/src/tools/file_system/batch_surgical_edit.ts +70 -0
- package/framework-mcp/src/tools/file_system/replace_text.ts +10 -4
- package/framework-mcp/src/tools/file_system/write_file.ts +5 -0
- package/framework-mcp/src/tools/framework/audit_deps.ts +49 -0
- package/framework-mcp/src/tools/framework/run_tests.ts +28 -0
- package/framework-mcp/src/tools/index.ts +24 -0
- package/framework-mcp/src/tools/memory/get_insights.ts +41 -0
- package/framework-mcp/src/tools/memory/read_memory.ts +31 -0
- package/framework-mcp/src/tools/messaging/send_message.ts +1 -1
- package/framework-mcp/src/tools/observability/check_ports.ts +30 -0
- package/framework-mcp/src/tools/observability/get_health.ts +25 -0
- package/framework-mcp/src/tools/search/get_gaps.ts +54 -0
- package/framework-mcp/src/tools/search/get_map.ts +50 -0
- package/framework-mcp/src/tools/search/grep_search.ts +66 -0
- package/framework-mcp/src/tools/search/list_dir.ts +34 -0
- package/framework-mcp/src/tools/types.ts +11 -1
- package/framework-mcp/src/utils/compliance.ts +37 -0
- package/framework-mcp/tests/tools/messaging/send_message.test.ts +5 -5
- package/package.json +3 -3
- package/src/cli/adapters/types.ts +2 -2
- package/src/cli/adapters.ts +45 -80
- package/src/cli/commands/check.ts +52 -6
- package/src/cli/commands/init.ts +193 -114
- package/src/cli/commands/orchestrate.ts +14 -8
- package/src/cli/commands/status.ts +3 -2
- package/src/cli/index.ts +4 -3
- package/src/cli/shims.ts +6 -6
- package/src/cli/utils/app-backend.ts +249 -0
- package/src/cli/utils/app-docs.ts +65 -0
- package/src/cli/utils/app-frontend.ts +257 -0
- package/src/cli/utils/app-inferrer.ts +53 -0
- package/src/cli/utils/app-types.ts +243 -0
- package/src/cli/utils/app.ts +5 -849
- package/src/cli/utils/memory.ts +8 -4
- package/src/modules/adapters/definitions.ts +125 -0
- package/src/modules/agents/definitions.ts +26 -27
- package/src/shared/logger.ts +8 -5
- package/templates/prompts/bug-fix-recipe.md +20 -0
- package/templates/prompts/new-feature-recipe.md +19 -0
- package/templates/prompts/refactoring-recipe.md +21 -0
- package/templates/standards/architecture-standards.md +23 -0
- package/templates/standards/crud-governance.md +21 -0
- package/templates/standards/frontend-standards.md +38 -0
- package/templates/standards/i18n-standards.md +17 -0
- package/templates/standards/logging-and-secrets.md +29 -0
- package/templates/standards/mobile-standards.md +24 -0
- package/templates/standards/quality-standards.md +31 -0
- package/templates/standards/security-standards.md +21 -0
- package/templates/standards/tailwind-standards.md +20 -0
- package/templates/standards/testing-standards.md +31 -0
- package/src/modules/adapters/antigravity-cli.ts +0 -25
- package/src/modules/adapters/claude.ts +0 -36
- package/src/modules/adapters/codex.ts +0 -22
- package/src/modules/adapters/cursor.ts +0 -22
- package/src/modules/adapters/gemini.ts +0 -27
- package/src/modules/adapters/grok.ts +0 -20
- package/templates/architecture/agents-manifest.md +0 -79
- package/templates/architecture/approval-flows.md +0 -61
- package/templates/architecture/enterprise-architecture.md +0 -69
- package/templates/architecture/standards/crud-governance.md +0 -46
- package/templates/architecture/standards/data-fetching-patterns.md +0 -13
- package/templates/architecture/standards/design-system.md +0 -31
- package/templates/architecture/standards/documentation-ownership.md +0 -21
- package/templates/architecture/standards/logging.md +0 -7
- package/templates/architecture/standards/mobile-standards.md +0 -48
- package/templates/architecture/standards/tech-stack.md +0 -9
- package/templates/backend/error-handling.md +0 -74
- package/templates/frontend/component-patterns.md +0 -91
package/src/cli/utils/app.ts
CHANGED
|
@@ -1,849 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { getConfiguredPaths, getMemoryPath } from "./memory.js";
|
|
7
|
-
import { getDependencyVersions } from "./pkg.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const targetDir = process.cwd(); // Assuming targetDir is process.cwd() in the CLI context
|
|
11
|
-
|
|
12
|
-
export function inferAppSpec(description: string) {
|
|
13
|
-
const normalized = String(description || "").toLowerCase();
|
|
14
|
-
const isCrm = /\bcrm\b|customer|musteri|müşteri/.test(normalized);
|
|
15
|
-
const hasAuth = /auth|login|giris|giriş|signin|sign in|user|kullanici|kullanıcı|role|rol/.test(normalized);
|
|
16
|
-
const hasRoles = /role|rol|permission|yetki|admin/.test(normalized);
|
|
17
|
-
const hasReports = /report|rapor|analytics|dashboard|chart|metric/.test(normalized);
|
|
18
|
-
const appName = isCrm ? "crm-dashboard" : slugifyName(description).split("-").slice(0, 4).join("-");
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
rawDescription: description,
|
|
22
|
-
appName,
|
|
23
|
-
title: isCrm ? "CRM Dashboard" : titleCase(appName),
|
|
24
|
-
domain: isCrm ? "CRM" : "Business",
|
|
25
|
-
modules: {
|
|
26
|
-
auth: hasAuth || isCrm,
|
|
27
|
-
users: hasAuth || hasRoles || isCrm,
|
|
28
|
-
roles: hasRoles || isCrm,
|
|
29
|
-
reports: hasReports || isCrm,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function buildSharedTypesContent(existingContent: string) {
|
|
35
|
-
const marker = "// --- Generated Application Contract ---";
|
|
36
|
-
const generated = [
|
|
37
|
-
marker,
|
|
38
|
-
"export type RoleID = Brand<string, \"RoleID\">;",
|
|
39
|
-
"export type ReportID = Brand<string, \"ReportID\">;",
|
|
40
|
-
"export type CustomerID = Brand<string, \"CustomerID\">;",
|
|
41
|
-
"",
|
|
42
|
-
"export interface AuthSession {",
|
|
43
|
-
" user: User;",
|
|
44
|
-
" token: string;",
|
|
45
|
-
" expiresAt: string;",
|
|
46
|
-
"}",
|
|
47
|
-
"",
|
|
48
|
-
"export interface Role {",
|
|
49
|
-
" id: RoleID;",
|
|
50
|
-
" name: string;",
|
|
51
|
-
" permissions: string[];",
|
|
52
|
-
"}",
|
|
53
|
-
"",
|
|
54
|
-
"export interface Customer {",
|
|
55
|
-
" id: CustomerID;",
|
|
56
|
-
" name: string;",
|
|
57
|
-
" ownerId: UserID;",
|
|
58
|
-
" status: \"LEAD\" | \"ACTIVE\" | \"AT_RISK\";", // Using backticks for inner double quotes
|
|
59
|
-
" annualValue: number;",
|
|
60
|
-
" createdAt: string;",
|
|
61
|
-
"}",
|
|
62
|
-
"",
|
|
63
|
-
"export interface ReportMetric {",
|
|
64
|
-
" id: ReportID;",
|
|
65
|
-
" label: string;",
|
|
66
|
-
" value: number;",
|
|
67
|
-
" trend: \"UP\" | \"DOWN\" | \"FLAT\";", // Using backticks for inner double quotes
|
|
68
|
-
"}",
|
|
69
|
-
"",
|
|
70
|
-
"export interface DashboardSummary {",
|
|
71
|
-
" customers: Customer[];",
|
|
72
|
-
" users: User[];",
|
|
73
|
-
" roles: Role[];",
|
|
74
|
-
" reports: ReportMetric[];",
|
|
75
|
-
"}",
|
|
76
|
-
].join("\n");
|
|
77
|
-
|
|
78
|
-
if (existingContent.includes(marker)) return existingContent;
|
|
79
|
-
return `${existingContent.trim()}\n\n${generated}\n`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function updateContractHashFile() {
|
|
83
|
-
const pathsMap = getConfiguredPaths();
|
|
84
|
-
const sharedDir = path.join(targetDir, pathsMap.backend, "src/types");
|
|
85
|
-
const contractPath = path.join(targetDir, pathsMap.backend, "contract.version.json");
|
|
86
|
-
if (!fs.existsSync(sharedDir) || !fs.existsSync(contractPath)) return;
|
|
87
|
-
|
|
88
|
-
const currentHash = computeTypesHash(targetDir, sharedDir);
|
|
89
|
-
|
|
90
|
-
const contract = JSON.parse(fs.readFileSync(contractPath, "utf8"));
|
|
91
|
-
contract.contract_hash = currentHash;
|
|
92
|
-
contract.last_updated = new Date().toISOString();
|
|
93
|
-
fs.writeFileSync(contractPath, JSON.stringify(contract, null, 2));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function createBaseTypeFiles(baseDir: string) {
|
|
97
|
-
const typesDir = path.join(baseDir, "types");
|
|
98
|
-
ensureDir(typesDir);
|
|
99
|
-
|
|
100
|
-
writeTextFile(path.join(typesDir, "api.ts"), `import { TraceID } from "./brands.js";
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* API Response Wrappers
|
|
104
|
-
*/
|
|
105
|
-
export interface ApiResponse<T> {
|
|
106
|
-
data: T;
|
|
107
|
-
meta?: {
|
|
108
|
-
requestId: TraceID;
|
|
109
|
-
timestamp: string;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface ApiError {
|
|
114
|
-
error: {
|
|
115
|
-
code: string;
|
|
116
|
-
message: string;
|
|
117
|
-
details?: unknown;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
`);
|
|
121
|
-
|
|
122
|
-
writeTextFile(path.join(typesDir, "brands.ts"), `/**
|
|
123
|
-
* Branded Type Utility
|
|
124
|
-
*/
|
|
125
|
-
export type Brand<K, T> = K & { __brand: T };
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Entity IDs (Branded)
|
|
129
|
-
*/
|
|
130
|
-
export type TraceID = Brand<string, "TraceID">;
|
|
131
|
-
export type AgentID = Brand<string, "AgentID">;
|
|
132
|
-
export type ProjectID = Brand<string, "ProjectID">;
|
|
133
|
-
export type UserID = Brand<string, "UserID">;
|
|
134
|
-
`);
|
|
135
|
-
|
|
136
|
-
writeTextFile(path.join(typesDir, "constants.ts"), `import { TraceID } from "./brands.js";
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Project Phases
|
|
140
|
-
*/
|
|
141
|
-
export const PROJECT_PHASES = ["PHASE_0", "PHASE_1", "PHASE_2", "PHASE_3", "PHASE_4"] as const;
|
|
142
|
-
export type ProjectPhase = (typeof PROJECT_PHASES)[number];
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Execution Profiles
|
|
146
|
-
*/
|
|
147
|
-
export const EXECUTION_PROFILES = ["Lightweight", "Full"] as const;
|
|
148
|
-
export type ExecutionProfile = (typeof EXECUTION_PROFILES)[number];
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Task Priorities
|
|
152
|
-
*/
|
|
153
|
-
export const TASK_PRIORITIES = ["P0", "P1", "P2", "P3"] as const;
|
|
154
|
-
export type TaskPriority = (typeof TASK_PRIORITIES)[number];
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Task Statuses
|
|
158
|
-
*/
|
|
159
|
-
export const TASK_STATUSES = ["PENDING", "IN_PROGRESS", "BLOCKED", "COMPLETED", "FAILED"] as const;
|
|
160
|
-
export type TaskStatus = (typeof TASK_STATUSES)[number];
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Action Types & Status
|
|
164
|
-
*/
|
|
165
|
-
export const ACTION_TYPES = ["CREATE", "MODIFY", "DELETE", "RESEARCH", "ORCHESTRATE"] as const;
|
|
166
|
-
export type ActionType = (typeof ACTION_TYPES)[number];
|
|
167
|
-
|
|
168
|
-
export const ACTION_STATUSES = ["SUCCESS", "FAILURE", "WAITING"] as const;
|
|
169
|
-
export type ActionStatus = (typeof ACTION_STATUSES)[number];
|
|
170
|
-
`);
|
|
171
|
-
|
|
172
|
-
writeTextFile(path.join(typesDir, "index.ts"), `/**
|
|
173
|
-
* Agent Enderun — App-Local Types (Modular)
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
export * from "./brands.js";
|
|
177
|
-
export * from "./constants.js";
|
|
178
|
-
export * from "./models.js";
|
|
179
|
-
export * from "./api.js";
|
|
180
|
-
export * from "./logs.js";
|
|
181
|
-
`);
|
|
182
|
-
|
|
183
|
-
writeTextFile(path.join(typesDir, "logs.ts"), `import { TraceID, AgentID } from "./brands.js";
|
|
184
|
-
import { ActionType, ActionStatus } from "./constants.js";
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Audit & Agent Logging Types
|
|
188
|
-
*/
|
|
189
|
-
export interface AgentActionLog {
|
|
190
|
-
timestamp: string;
|
|
191
|
-
agent: AgentID;
|
|
192
|
-
action: ActionType;
|
|
193
|
-
requestId: TraceID | "—";
|
|
194
|
-
status: ActionStatus;
|
|
195
|
-
summary: string;
|
|
196
|
-
files?: string[];
|
|
197
|
-
details?: Record<string, unknown>;
|
|
198
|
-
}
|
|
199
|
-
`);
|
|
200
|
-
|
|
201
|
-
writeTextFile(path.join(typesDir, "models.ts"), `import { UserID, TraceID, AgentID } from "./brands.js";
|
|
202
|
-
import { ProjectPhase, ExecutionProfile, TaskPriority, TaskStatus } from "./constants.js";
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Base Entity Fields
|
|
206
|
-
*/
|
|
207
|
-
export interface BaseEntity {
|
|
208
|
-
id: string; // Usually ULID
|
|
209
|
-
createdAt: string;
|
|
210
|
-
updatedAt: string;
|
|
211
|
-
deletedAt?: string | null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Audit Log Model
|
|
216
|
-
*/
|
|
217
|
-
export interface AuditLog extends BaseEntity {
|
|
218
|
-
entityName: string;
|
|
219
|
-
entityId: string;
|
|
220
|
-
action: "CREATE" | "UPDATE" | "DELETE" | "RESTORE";
|
|
221
|
-
userId: UserID;
|
|
222
|
-
previousState?: Record<string, unknown> | null;
|
|
223
|
-
newState?: Record<string, unknown> | null;
|
|
224
|
-
traceId: TraceID;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* User Model
|
|
229
|
-
*/
|
|
230
|
-
export interface User extends BaseEntity {
|
|
231
|
-
id: UserID;
|
|
232
|
-
email: string;
|
|
233
|
-
fullName: string;
|
|
234
|
-
role: "ADMIN" | "DEVELOPER" | "VIEWER";
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export interface UserProfile extends User {
|
|
238
|
-
avatarUrl?: string;
|
|
239
|
-
bio?: string;
|
|
240
|
-
preferences: Record<string, unknown>;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Project Status
|
|
245
|
-
*/
|
|
246
|
-
export interface ProjectStatus {
|
|
247
|
-
phase: ProjectPhase;
|
|
248
|
-
profile: ExecutionProfile;
|
|
249
|
-
lastUpdate: string;
|
|
250
|
-
activeTraceId: TraceID | null;
|
|
251
|
-
blockers: string[];
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Task Model
|
|
256
|
-
*/
|
|
257
|
-
export interface Task {
|
|
258
|
-
id: TraceID;
|
|
259
|
-
description: string;
|
|
260
|
-
agent: AgentID;
|
|
261
|
-
priority: TaskPriority;
|
|
262
|
-
status: TaskStatus;
|
|
263
|
-
createdAt: string;
|
|
264
|
-
updatedAt: string;
|
|
265
|
-
}
|
|
266
|
-
`);
|
|
267
|
-
console.warn(`✅ Base types created in ${path.relative(targetDir, typesDir)}`);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export interface AppSpec {
|
|
271
|
-
rawDescription: string;
|
|
272
|
-
appName: string;
|
|
273
|
-
title: string;
|
|
274
|
-
domain: string;
|
|
275
|
-
modules: {
|
|
276
|
-
auth: boolean;
|
|
277
|
-
users: boolean;
|
|
278
|
-
roles: boolean;
|
|
279
|
-
reports: boolean;
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export function createBackendFiles(spec: AppSpec) {
|
|
284
|
-
const pathsMap = getConfiguredPaths();
|
|
285
|
-
const backendDir = pathsMap.backend;
|
|
286
|
-
const { fastify, "@fastify/cors": fastifyCors, zod, "@types/node": typesNode, tsx, typescript, "vitest-backend": vitest } = getDependencyVersions();
|
|
287
|
-
|
|
288
|
-
createBaseTypeFiles(path.join(targetDir, backendDir, "src"));
|
|
289
|
-
writeJsonFile(path.join(targetDir, backendDir, "contract.version.json"), {
|
|
290
|
-
"contract_hash": "initial_hash_placeholder",
|
|
291
|
-
"last_updated": new Date().toISOString()
|
|
292
|
-
});
|
|
293
|
-
writeJsonFile(path.join(targetDir, backendDir, "package.json"), {
|
|
294
|
-
name: "@agent-enderun/backend",
|
|
295
|
-
version: "0.1.0",
|
|
296
|
-
private: true,
|
|
297
|
-
type: "module",
|
|
298
|
-
scripts: {
|
|
299
|
-
dev: "tsx src/server.ts",
|
|
300
|
-
build: "tsc -p tsconfig.json",
|
|
301
|
-
start: "node dist/server.js",
|
|
302
|
-
test: "vitest run",
|
|
303
|
-
},
|
|
304
|
-
dependencies: {
|
|
305
|
-
"@fastify/cors": fastifyCors,
|
|
306
|
-
fastify: fastify,
|
|
307
|
-
zod: zod,
|
|
308
|
-
},
|
|
309
|
-
devDependencies: {
|
|
310
|
-
"@types/node": typesNode,
|
|
311
|
-
tsx: tsx,
|
|
312
|
-
typescript: typescript,
|
|
313
|
-
vitest: vitest,
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
writeJsonFile(path.join(targetDir, backendDir, "tsconfig.json"), {
|
|
318
|
-
extends: "../../tsconfig.json",
|
|
319
|
-
compilerOptions: {
|
|
320
|
-
outDir: "dist",
|
|
321
|
-
rootDir: "src",
|
|
322
|
-
module: "NodeNext",
|
|
323
|
-
moduleResolution: "NodeNext",
|
|
324
|
-
target: "ES2022",
|
|
325
|
-
strict: true,
|
|
326
|
-
skipLibCheck: true,
|
|
327
|
-
},
|
|
328
|
-
include: ["src/**/*.ts"],
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
const srcDir = path.join(targetDir, backendDir, "src");
|
|
332
|
-
ensureDir(path.join(srcDir, "database"));
|
|
333
|
-
ensureDir(path.join(srcDir, "repositories"));
|
|
334
|
-
ensureDir(path.join(srcDir, "services"));
|
|
335
|
-
|
|
336
|
-
writeTextFile(path.join(srcDir, "database/memoryDb.ts"), [
|
|
337
|
-
"import type { Customer, ReportMetric, Role, User } from \"../types/index.js\";",
|
|
338
|
-
"",
|
|
339
|
-
"const now = new Date().toISOString();",
|
|
340
|
-
"",
|
|
341
|
-
"export const rolesDb: Role[] = [",
|
|
342
|
-
" { id: \"role_admin\" as Role[\"id\"], name: \"Admin\", permissions: [\"users:manage\", \"reports:view\", \"customers:manage\"] },",
|
|
343
|
-
" { id: \"role_manager\" as Role[\"id\"], name: \"Manager\", permissions: [\"reports:view\", \"customers:manage\"] },",
|
|
344
|
-
" { id: \"role_viewer\" as Role[\"id\"], name: \"Viewer\", permissions: [\"reports:view\"] },",
|
|
345
|
-
"];",
|
|
346
|
-
"",
|
|
347
|
-
"export const usersDb: User[] = [",
|
|
348
|
-
" { id: \"user_1\" as User[\"id\"], email: \"admin@example.com\", fullName: \"Admin User\", role: \"ADMIN\", createdAt: now, updatedAt: now },",
|
|
349
|
-
" { id: \"user_2\" as User[\"id\"], email: \"manager@example.com\", fullName: \"Sales Manager\", role: \"DEVELOPER\", createdAt: now, updatedAt: now },",
|
|
350
|
-
"];",
|
|
351
|
-
"",
|
|
352
|
-
"export const customersDb: Customer[] = [",
|
|
353
|
-
" { id: \"customer_1\" as Customer[\"id\"], name: \"Northwind\", ownerId: usersDb[1].id, status: \"ACTIVE\", annualValue: 125000, createdAt: now, updatedAt: now },",
|
|
354
|
-
" { id: \"customer_2\" as Customer[\"id\"], name: \"Acme Corp\", ownerId: usersDb[1].id, status: \"LEAD\", annualValue: 82000, createdAt: now, updatedAt: now },",
|
|
355
|
-
" { id: \"customer_3\" as Customer[\"id\"], name: \"Globex\", ownerId: usersDb[0].id, status: \"AT_RISK\", annualValue: 54000, createdAt: now, updatedAt: now },",
|
|
356
|
-
"];",
|
|
357
|
-
"",
|
|
358
|
-
"export const reportsDb: ReportMetric[] = [",
|
|
359
|
-
" { id: \"report_pipeline\" as ReportMetric[\"id\"], label: \"Pipeline\", value: 261000, trend: \"UP\" },",
|
|
360
|
-
" { id: \"report_active_customers\" as ReportMetric[\"id\"], label: \"Active Customers\", value: 1, trend: \"FLAT\" },",
|
|
361
|
-
" { id: \"report_risk\" as ReportMetric[\"id\"], label: \"At Risk\", value: 1, trend: \"DOWN\" },",
|
|
362
|
-
"];",
|
|
363
|
-
].join("\n"));
|
|
364
|
-
|
|
365
|
-
writeTextFile(path.join(srcDir, "repositories/user.repository.ts"), [
|
|
366
|
-
"import { usersDb } from \"../database/memoryDb.js\";",
|
|
367
|
-
"import type { User } from \"../types/index.js\";",
|
|
368
|
-
"",
|
|
369
|
-
"export class UserRepository {",
|
|
370
|
-
" async findAll(): Promise<User[]> {",
|
|
371
|
-
" return usersDb.filter(u => !u.deletedAt);",
|
|
372
|
-
" }",
|
|
373
|
-
"",
|
|
374
|
-
" async findByEmail(email: string): Promise<User | null> {",
|
|
375
|
-
" return usersDb.find(u => u.email === email && !u.deletedAt) || null;",
|
|
376
|
-
" }",
|
|
377
|
-
"}",
|
|
378
|
-
].join("\n"));
|
|
379
|
-
|
|
380
|
-
writeTextFile(path.join(srcDir, "repositories/customer.repository.ts"), [
|
|
381
|
-
"import { customersDb } from \"../database/memoryDb.js\";",
|
|
382
|
-
"import type { Customer } from \"../types/index.js\";",
|
|
383
|
-
"",
|
|
384
|
-
"export class CustomerRepository {",
|
|
385
|
-
" async findAll(): Promise<Customer[]> {",
|
|
386
|
-
" return customersDb.filter(c => !c.deletedAt);",
|
|
387
|
-
" }",
|
|
388
|
-
"}",
|
|
389
|
-
].join("\n"));
|
|
390
|
-
|
|
391
|
-
writeTextFile(path.join(srcDir, "repositories/role.repository.ts"), [
|
|
392
|
-
"import { rolesDb } from \"../database/memoryDb.js\";",
|
|
393
|
-
"import type { Role } from \"../types/index.js\";",
|
|
394
|
-
"",
|
|
395
|
-
"export class RoleRepository {",
|
|
396
|
-
" async findAll(): Promise<Role[]> {",
|
|
397
|
-
" return rolesDb;",
|
|
398
|
-
" }",
|
|
399
|
-
"}",
|
|
400
|
-
].join("\n"));
|
|
401
|
-
|
|
402
|
-
writeTextFile(path.join(srcDir, "repositories/report.repository.ts"), [
|
|
403
|
-
"import { reportsDb } from \"../database/memoryDb.js\";",
|
|
404
|
-
"import type { ReportMetric } from \"../types/index.js\";",
|
|
405
|
-
"",
|
|
406
|
-
"export class ReportRepository {",
|
|
407
|
-
" async findAll(): Promise<ReportMetric[]> {",
|
|
408
|
-
" return reportsDb;",
|
|
409
|
-
" }",
|
|
410
|
-
"}",
|
|
411
|
-
].join("\n"));
|
|
412
|
-
|
|
413
|
-
writeTextFile(path.join(srcDir, "services/dashboard.service.ts"), [
|
|
414
|
-
"import { UserRepository } from \"../repositories/user.repository.js\";",
|
|
415
|
-
"import { CustomerRepository } from \"../repositories/customer.repository.js\";",
|
|
416
|
-
"import { RoleRepository } from \"../repositories/role.repository.js\";",
|
|
417
|
-
"import { ReportRepository } from \"../repositories/report.repository.js\";",
|
|
418
|
-
"import type { DashboardSummary } from \"../types/index.js\";",
|
|
419
|
-
"",
|
|
420
|
-
"export class DashboardService {",
|
|
421
|
-
" private userRepo = new UserRepository();",
|
|
422
|
-
" private customerRepo = new CustomerRepository();",
|
|
423
|
-
" private roleRepo = new RoleRepository();",
|
|
424
|
-
" private reportRepo = new ReportRepository();",
|
|
425
|
-
"",
|
|
426
|
-
" async getSummary(): Promise<DashboardSummary> {",
|
|
427
|
-
" const [users, customers, roles, reports] = await Promise.all([",
|
|
428
|
-
" this.userRepo.findAll(),",
|
|
429
|
-
" this.customerRepo.findAll(),",
|
|
430
|
-
" this.roleRepo.findAll(),",
|
|
431
|
-
" this.reportRepo.findAll(),",
|
|
432
|
-
" ]);",
|
|
433
|
-
"",
|
|
434
|
-
" return { users, customers, roles, reports };",
|
|
435
|
-
" }",
|
|
436
|
-
"}",
|
|
437
|
-
].join("\n"));
|
|
438
|
-
|
|
439
|
-
writeTextFile(path.join(targetDir, backendDir, "src/server.ts"), [
|
|
440
|
-
"import Fastify from \"fastify\";",
|
|
441
|
-
"import cors from \"@fastify/cors\";",
|
|
442
|
-
"import { z } from \"zod\";",
|
|
443
|
-
"import { UserRepository } from \"./repositories/user.repository.js\";",
|
|
444
|
-
"import { CustomerRepository } from \"./repositories/customer.repository.js\";",
|
|
445
|
-
"import { RoleRepository } from \"./repositories/role.repository.js\";",
|
|
446
|
-
"import { ReportRepository } from \"./repositories/report.repository.js\";",
|
|
447
|
-
"import { DashboardService } from \"./services/dashboard.service.js\";",
|
|
448
|
-
"",
|
|
449
|
-
"const app = Fastify({ logger: true });",
|
|
450
|
-
"await app.register(cors, { origin: true });",
|
|
451
|
-
"",
|
|
452
|
-
"const userRepo = new UserRepository();",
|
|
453
|
-
"const customerRepo = new CustomerRepository();",
|
|
454
|
-
"const roleRepo = new RoleRepository();",
|
|
455
|
-
"const reportRepo = new ReportRepository();",
|
|
456
|
-
"const dashboardService = new DashboardService();",
|
|
457
|
-
"",
|
|
458
|
-
"app.get(\"/health\", async () => ({ ok: true, service: \"agent-enderun-backend\" }));",
|
|
459
|
-
"app.get(\"/api/v1/dashboard\", async () => {",
|
|
460
|
-
" const summary = await dashboardService.getSummary();",
|
|
461
|
-
" return { data: summary };",
|
|
462
|
-
"});",
|
|
463
|
-
"app.get(\"/api/v1/users\", async () => {",
|
|
464
|
-
" const users = await userRepo.findAll();",
|
|
465
|
-
" return { data: users };",
|
|
466
|
-
"});",
|
|
467
|
-
"app.get(\"/api/v1/roles\", async () => {",
|
|
468
|
-
" const roles = await roleRepo.findAll();",
|
|
469
|
-
" return { data: roles };",
|
|
470
|
-
"});",
|
|
471
|
-
"app.get(\"/api/v1/customers\", async () => {",
|
|
472
|
-
" const customers = await customerRepo.findAll();",
|
|
473
|
-
" return { data: customers };",
|
|
474
|
-
"});",
|
|
475
|
-
"app.get(\"/api/v1/reports\", async (request, reply) => {",
|
|
476
|
-
" interface QueryParams {",
|
|
477
|
-
" page?: number;",
|
|
478
|
-
" limit?: number;",
|
|
479
|
-
" }",
|
|
480
|
-
" const { page = 1, limit = 10 } = request.query as QueryParams;",
|
|
481
|
-
" const reports = await reportRepo.findAll();",
|
|
482
|
-
" const startIndex = (Number(page) - 1) * Number(limit);",
|
|
483
|
-
" const endIndex = startIndex + Number(limit);",
|
|
484
|
-
" const paginatedReports = reports.slice(startIndex, endIndex);",
|
|
485
|
-
" reply.send({",
|
|
486
|
-
" data: paginatedReports,",
|
|
487
|
-
" meta: {",
|
|
488
|
-
" total: reports.length,",
|
|
489
|
-
" page: Number(page),",
|
|
490
|
-
" limit: Number(limit),",
|
|
491
|
-
" },",
|
|
492
|
-
" });",
|
|
493
|
-
"});",
|
|
494
|
-
"",
|
|
495
|
-
"app.post(\"/api/v1/auth/login\", async (request, reply) => {",
|
|
496
|
-
" const body = z.object({ email: z.string().email(), password: z.string().min(1) }).safeParse(request.body);",
|
|
497
|
-
" if (!body.success) return reply.code(400).send({ error: { code: \"VALIDATION_ERROR\", message: \"Invalid login payload\" } });",
|
|
498
|
-
"",
|
|
499
|
-
" const user = await userRepo.findByEmail(body.data.email);",
|
|
500
|
-
" if (!user) {",
|
|
501
|
-
" const allUsers = await userRepo.findAll();",
|
|
502
|
-
" return { data: { user: allUsers[0], token: \"demo-token\", expiresAt: new Date(Date.now() + 3600000).toISOString() } };",
|
|
503
|
-
" }",
|
|
504
|
-
" return { data: { user, token: \"demo-token\", expiresAt: new Date(Date.now() + 3600000).toISOString() } };",
|
|
505
|
-
"});",
|
|
506
|
-
"",
|
|
507
|
-
"const port = Number(process.env.PORT || 4000);",
|
|
508
|
-
"await app.listen({ port, host: \"0.0.0.0\" });",
|
|
509
|
-
].join("\n"));
|
|
510
|
-
|
|
511
|
-
writeTextFile(path.join(targetDir, backendDir, "README.md"), [
|
|
512
|
-
`# ${spec.title} Backend`,
|
|
513
|
-
"",
|
|
514
|
-
"Fastify API generated by Agent Enderun.",
|
|
515
|
-
"",
|
|
516
|
-
"## Commands",
|
|
517
|
-
"",
|
|
518
|
-
"- `npm run dev` strings",
|
|
519
|
-
"- `npm run build` strings",
|
|
520
|
-
"- `npm run test` strings",
|
|
521
|
-
].join("\n"));
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
export function createWebFiles(spec: AppSpec) {
|
|
525
|
-
const pathsMap = getConfiguredPaths();
|
|
526
|
-
const frontendDir = pathsMap.frontend;
|
|
527
|
-
const { "@vitejs/plugin-react": vitePluginReact, vite, react, "react-dom": reactDom, "lucide-react": lucideReact, "@types/react": typesReact, "@types/react-dom": typesReactDom, typescript, "vitest-frontend": vitest } = getDependencyVersions();
|
|
528
|
-
|
|
529
|
-
createBaseTypeFiles(path.join(targetDir, frontendDir, "src"));
|
|
530
|
-
writeJsonFile(path.join(targetDir, frontendDir, "package.json"), {
|
|
531
|
-
name: "@agent-enderun/web",
|
|
532
|
-
version: "0.1.0",
|
|
533
|
-
private: true,
|
|
534
|
-
type: "module",
|
|
535
|
-
scripts: {
|
|
536
|
-
dev: "vite --host 0.0.0.0",
|
|
537
|
-
build: "tsc -p tsconfig.json && vite build",
|
|
538
|
-
preview: "vite preview",
|
|
539
|
-
test: "vitest run",
|
|
540
|
-
},
|
|
541
|
-
dependencies: {
|
|
542
|
-
"@vitejs/plugin-react": vitePluginReact,
|
|
543
|
-
vite: vite,
|
|
544
|
-
react: react,
|
|
545
|
-
"react-dom": reactDom,
|
|
546
|
-
"lucide-react": lucideReact,
|
|
547
|
-
},
|
|
548
|
-
devDependencies: {
|
|
549
|
-
"@types/react": typesReact,
|
|
550
|
-
"@types/react-dom": typesReactDom,
|
|
551
|
-
typescript: typescript,
|
|
552
|
-
vitest: vitest,
|
|
553
|
-
},
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
writeJsonFile(path.join(targetDir, frontendDir, "tsconfig.json"), {
|
|
557
|
-
extends: "../../tsconfig.json",
|
|
558
|
-
compilerOptions: {
|
|
559
|
-
jsx: "react-jsx",
|
|
560
|
-
module: "NodeNext",
|
|
561
|
-
moduleResolution: "NodeNext",
|
|
562
|
-
target: "ES2022",
|
|
563
|
-
strict: true,
|
|
564
|
-
skipLibCheck: true,
|
|
565
|
-
},
|
|
566
|
-
include: ["src/**/*.ts", "src/**/*.tsx"],
|
|
567
|
-
});
|
|
568
|
-
|
|
569
|
-
writeTextFile(path.join(targetDir, frontendDir, "index.html"), [
|
|
570
|
-
"<div id=\"root\"></div>",
|
|
571
|
-
"<script type=\"module\" src=\"/src/main.tsx\"></script>",
|
|
572
|
-
].join("\n"));
|
|
573
|
-
|
|
574
|
-
writeTextFile(path.join(targetDir, frontendDir, "src/main.tsx"), [
|
|
575
|
-
"import React from \"react\";",
|
|
576
|
-
"import { createRoot } from \"react-dom/client\";",
|
|
577
|
-
"import { App } from \"./App.js\";",
|
|
578
|
-
"import \"./styles.css\";",
|
|
579
|
-
"",
|
|
580
|
-
"createRoot(document.getElementById(\"root\") as HTMLElement).render(",
|
|
581
|
-
" <React.StrictMode>",
|
|
582
|
-
" <App />",
|
|
583
|
-
" </React.StrictMode>,",
|
|
584
|
-
");",
|
|
585
|
-
].join("\n"));
|
|
586
|
-
|
|
587
|
-
writeTextFile(path.join(targetDir, frontendDir, "src/App.tsx"), [
|
|
588
|
-
"import { BarChart3, ShieldCheck, UsersRound } from \"lucide-react\";",
|
|
589
|
-
"",
|
|
590
|
-
"const metrics = [",
|
|
591
|
-
" { label: \"Pipeline\", value: \"$261K\", tone: \"green\" },",
|
|
592
|
-
" { label: \"Active customers\", value: \"18\", tone: \"blue\" },",
|
|
593
|
-
" { label: \"At risk\", value: \"3\", tone: \"red\" },",
|
|
594
|
-
"];",
|
|
595
|
-
"",
|
|
596
|
-
"const customers = [",
|
|
597
|
-
" { name: \"Northwind\", status: \"Active\", owner: \"Sales Manager\", value: \"$125K\" },",
|
|
598
|
-
" { name: \"Acme Corp\", status: \"Lead\", owner: \"Sales Manager\", value: \"$82K\" },",
|
|
599
|
-
" { name: \"Globex\", status: \"At risk\", owner: \"Admin User\", value: \"$54K\" },",
|
|
600
|
-
"];",
|
|
601
|
-
"",
|
|
602
|
-
"export function App() {",
|
|
603
|
-
" return (",
|
|
604
|
-
" <main className=\"shell\">",
|
|
605
|
-
" <aside className=\"sidebar\" aria-label=\"Primary navigation\">",
|
|
606
|
-
" <div className=\"brand\">AE</div>",
|
|
607
|
-
" <nav>",
|
|
608
|
-
" <a className=\"active\" href=\"#dashboard\"><BarChart3 size={18} /> Dashboard</a>",
|
|
609
|
-
" <a href=\"#users\"><UsersRound size={18} /> Users</a>",
|
|
610
|
-
" <a href=\"#roles\"><ShieldCheck size={18} /> Roles</a>",
|
|
611
|
-
" </nav>",
|
|
612
|
-
" </aside>",
|
|
613
|
-
"",
|
|
614
|
-
" <section className=\"workspace\">",
|
|
615
|
-
" <header className=\"topbar\">",
|
|
616
|
-
" <div>",
|
|
617
|
-
` <p>${spec.domain}</p>`,
|
|
618
|
-
` <h1>${spec.title}</h1>`,
|
|
619
|
-
" </div>",
|
|
620
|
-
" <button type=\"button\">New customer</button>",
|
|
621
|
-
" </header>",
|
|
622
|
-
"",
|
|
623
|
-
" <section className=\"metrics\" aria-label=\"Report metrics\">",
|
|
624
|
-
" {metrics.map((metric) => (",
|
|
625
|
-
" <article className={`metric ${metric.tone}`} key={metric.label}>",
|
|
626
|
-
" <span>{metric.label}</span>",
|
|
627
|
-
" <strong>{metric.value}</strong>",
|
|
628
|
-
" </article>",
|
|
629
|
-
" ))}",
|
|
630
|
-
" </section>",
|
|
631
|
-
"",
|
|
632
|
-
" <section className=\"panel\">",
|
|
633
|
-
" <div>",
|
|
634
|
-
" <h2>Customers</h2>",
|
|
635
|
-
" <p>Ownership, value and status at a glance.</p>",
|
|
636
|
-
" </div>",
|
|
637
|
-
" <div className=\"table\">",
|
|
638
|
-
" {customers.map((customer) => (",
|
|
639
|
-
" <div className=\"row\" key={customer.name}>",
|
|
640
|
-
" <strong>{customer.name}</strong>",
|
|
641
|
-
" <span>{customer.status}</span>",
|
|
642
|
-
" <span>{customer.owner}</span>",
|
|
643
|
-
" <b>{customer.value}</b>",
|
|
644
|
-
" </div>",
|
|
645
|
-
" ))}",
|
|
646
|
-
" </div>",
|
|
647
|
-
" </section>",
|
|
648
|
-
" </section>",
|
|
649
|
-
" </main>",
|
|
650
|
-
" );",
|
|
651
|
-
"}",
|
|
652
|
-
].join("\n"));
|
|
653
|
-
|
|
654
|
-
writeTextFile(path.join(targetDir, frontendDir, "src/styles.css"), [
|
|
655
|
-
":root {",
|
|
656
|
-
" color: #172026;",
|
|
657
|
-
" background: #f4f7f6;",
|
|
658
|
-
" font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif;",
|
|
659
|
-
"}",
|
|
660
|
-
"",
|
|
661
|
-
"* { box-sizing: border-box; }",
|
|
662
|
-
"body { margin: 0; }",
|
|
663
|
-
"button { font: inherit; }",
|
|
664
|
-
"",
|
|
665
|
-
".shell {",
|
|
666
|
-
" min-height: 100vh;",
|
|
667
|
-
" display: grid;",
|
|
668
|
-
" grid-template-columns: 240px 1fr;",
|
|
669
|
-
"}",
|
|
670
|
-
"",
|
|
671
|
-
".sidebar {",
|
|
672
|
-
" background: #102022;",
|
|
673
|
-
" color: #eef6f2;",
|
|
674
|
-
" padding: 24px;",
|
|
675
|
-
"}",
|
|
676
|
-
"",
|
|
677
|
-
".brand {",
|
|
678
|
-
" width: 40px;",
|
|
679
|
-
" height: 40px;",
|
|
680
|
-
" display: grid;",
|
|
681
|
-
" place-items: center;",
|
|
682
|
-
" background: #d8f36a;",
|
|
683
|
-
" color: #102022;",
|
|
684
|
-
" font-weight: 800;",
|
|
685
|
-
" border-radius: 8px;",
|
|
686
|
-
" margin-bottom: 32px;",
|
|
687
|
-
"}",
|
|
688
|
-
"",
|
|
689
|
-
"nav { display: grid; gap: 8px; }",
|
|
690
|
-
"nav a {",
|
|
691
|
-
" color: inherit;",
|
|
692
|
-
" text-decoration: none;",
|
|
693
|
-
" display: flex;",
|
|
694
|
-
" gap: 10px;",
|
|
695
|
-
" align-items: center;",
|
|
696
|
-
" padding: 10px 12px;",
|
|
697
|
-
" border-radius: 8px;",
|
|
698
|
-
"}",
|
|
699
|
-
"nav a.active, nav a:hover { background: rgba(255,255,255,0.12); }",
|
|
700
|
-
"",
|
|
701
|
-
".workspace { padding: 32px; }",
|
|
702
|
-
".topbar {",
|
|
703
|
-
" display: flex;",
|
|
704
|
-
" justify-content: space-between;",
|
|
705
|
-
" align-items: center;",
|
|
706
|
-
" gap: 24px;",
|
|
707
|
-
" margin-bottom: 24px;",
|
|
708
|
-
"}",
|
|
709
|
-
".topbar p { margin: 0 0 4px; color: #58666a; font-size: 14px; }",
|
|
710
|
-
".topbar h1 { margin: 0; font-size: 32px; letter-spacing: 0; }",
|
|
711
|
-
".topbar button {",
|
|
712
|
-
" border: 0;",
|
|
713
|
-
" border-radius: 8px;",
|
|
714
|
-
" background: #176b5d;",
|
|
715
|
-
" color: white;",
|
|
716
|
-
" padding: 10px 14px;",
|
|
717
|
-
"}",
|
|
718
|
-
"",
|
|
719
|
-
".metrics {",
|
|
720
|
-
" display: grid;",
|
|
721
|
-
" grid-template-columns: repeat(3, minmax(0, 1fr));",
|
|
722
|
-
" gap: 16px;",
|
|
723
|
-
" margin-bottom: 24px;",
|
|
724
|
-
"}",
|
|
725
|
-
".metric, .panel {",
|
|
726
|
-
" background: white;",
|
|
727
|
-
" border: 1px solid #d9e3e0;",
|
|
728
|
-
" border-radius: 8px;",
|
|
729
|
-
"}",
|
|
730
|
-
".metric { padding: 18px; }",
|
|
731
|
-
".metric span { display: block; color: #58666a; margin-bottom: 8px; }",
|
|
732
|
-
".metric strong { font-size: 28px; }",
|
|
733
|
-
".metric.green { border-top: 4px solid #49a078; }",
|
|
734
|
-
".metric.blue { border-top: 4px solid #3f7cac; }",
|
|
735
|
-
".metric.red { border-top: 4px solid #d95d39; }",
|
|
736
|
-
"",
|
|
737
|
-
".panel { padding: 20px; }",
|
|
738
|
-
".panel h2 { margin: 0 0 4px; font-size: 20px; }",
|
|
739
|
-
".panel p { margin: 0 0 18px; color: #58666a; }",
|
|
740
|
-
".table { display: grid; gap: 8px; }",
|
|
741
|
-
".row {",
|
|
742
|
-
" display: grid;",
|
|
743
|
-
" grid-template-columns: 1.4fr 0.8fr 1fr 0.6fr;",
|
|
744
|
-
" gap: 16px;",
|
|
745
|
-
" align-items: center;",
|
|
746
|
-
" padding: 12px;",
|
|
747
|
-
" border-radius: 8px;",
|
|
748
|
-
" background: #f7faf9;",
|
|
749
|
-
"}",
|
|
750
|
-
"",
|
|
751
|
-
"@media (max-width: 760px) {",
|
|
752
|
-
" .shell { grid-template-columns: 1fr; }",
|
|
753
|
-
" .sidebar { position: static; }",
|
|
754
|
-
" .metrics { grid-template-columns: 1fr; }",
|
|
755
|
-
" .topbar { align-items: flex-start; flex-direction: column; }",
|
|
756
|
-
" .row { grid-template-columns: 1fr; }",
|
|
757
|
-
"}",
|
|
758
|
-
].join("\n"));
|
|
759
|
-
|
|
760
|
-
writeTextFile(path.join(targetDir, frontendDir, "README.md"), [
|
|
761
|
-
`# ${spec.title} Web`,
|
|
762
|
-
"",
|
|
763
|
-
"React dashboard generated by Agent Enderun.",
|
|
764
|
-
"",
|
|
765
|
-
"## Commands",
|
|
766
|
-
"",
|
|
767
|
-
"- `npm run dev` strings",
|
|
768
|
-
"- `npm run build` strings",
|
|
769
|
-
"- `npm run test` strings",
|
|
770
|
-
|
|
771
|
-
].join("\n"));
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
export function updateProjectDocs(spec: AppSpec) {
|
|
775
|
-
const pathsMap = getConfiguredPaths();
|
|
776
|
-
const docsDir = path.join(targetDir, pathsMap.docs);
|
|
777
|
-
const apiDir = path.join(docsDir, "api");
|
|
778
|
-
ensureDir(apiDir);
|
|
779
|
-
|
|
780
|
-
writeTextFile(path.join(docsDir, "project-docs.md"), [
|
|
781
|
-
`# ${spec.title} Requirements`,
|
|
782
|
-
"",
|
|
783
|
-
"## Request",
|
|
784
|
-
"",
|
|
785
|
-
spec.rawDescription,
|
|
786
|
-
"",
|
|
787
|
-
"## Generated Scope",
|
|
788
|
-
"",
|
|
789
|
-
`- Domain: ${spec.domain}`,
|
|
790
|
-
`- Auth: ${spec.modules.auth ? "yes" : "no"}`,
|
|
791
|
-
`- Users: ${spec.modules.users ? "yes" : "no"}`,
|
|
792
|
-
`- Roles: ${spec.modules.roles ? "yes" : "no"}`,
|
|
793
|
-
`- Reports: ${spec.modules.reports ? "yes" : "no"}`,
|
|
794
|
-
"",
|
|
795
|
-
"## Architecture",
|
|
796
|
-
"",
|
|
797
|
-
`- \`${pathsMap.backend}\`: Fastify API`,
|
|
798
|
-
`- \`${pathsMap.frontend}\`: React dashboard`,
|
|
799
|
-
`- \`${pathsMap.backend}/src/types\`: Contract-first backend TypeScript types`,
|
|
800
|
-
].join("\n"));
|
|
801
|
-
|
|
802
|
-
writeTextFile(path.join(apiDir, "README.md"), [
|
|
803
|
-
"# API Registry",
|
|
804
|
-
"",
|
|
805
|
-
"- `POST /api/v1/auth/login`",
|
|
806
|
-
"- `GET /api/v1/dashboard`",
|
|
807
|
-
"- `GET /api/v1/users`",
|
|
808
|
-
"- `GET /api/v1/roles`",
|
|
809
|
-
"- `GET /api/v1/customers`",
|
|
810
|
-
"- `GET /api/v1/reports`",
|
|
811
|
-
].join("\n"));
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
export function updateMemoryForGeneratedApp(spec: AppSpec, traceId: string) {
|
|
815
|
-
const memoryPath = getMemoryPath();
|
|
816
|
-
if (!fs.existsSync(memoryPath)) return;
|
|
817
|
-
|
|
818
|
-
const pathsMap = getConfiguredPaths();
|
|
819
|
-
const today = new Date().toISOString().split("T")[0];
|
|
820
|
-
const history = [
|
|
821
|
-
`### ${today} — Generated ${spec.title}`,
|
|
822
|
-
"",
|
|
823
|
-
"- **Agent:** @manager",
|
|
824
|
-
`- **Trace ID:** ${traceId}`,
|
|
825
|
-
"- **Action:** Created full-stack starter from natural language request.",
|
|
826
|
-
`- **Files:** ${pathsMap.backend}, ${pathsMap.frontend}, project docs`,
|
|
827
|
-
].join("\n");
|
|
828
|
-
|
|
829
|
-
updateProjectMemory("HISTORY", history);
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
export async function collectCreateAppDescription(args: string[]) {
|
|
833
|
-
const initial = args.join(" ").trim();
|
|
834
|
-
if (initial) return initial;
|
|
835
|
-
|
|
836
|
-
const readline = await import("readline/promises");
|
|
837
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
838
|
-
try {
|
|
839
|
-
const idea = await rl.question("What do you want to build? ");
|
|
840
|
-
const platform = await rl.question("Platform? (full-stack/web/backend) ");
|
|
841
|
-
const auth = await rl.question("Auth and roles? (yes/no) ");
|
|
842
|
-
const reports = await rl.question("Reports/dashboard? (yes/no) ");
|
|
843
|
-
return [idea, platform, auth.includes("y") ? "with auth and roles" : "", reports.includes("y") ? "with reports dashboard" : ""].filter(Boolean).join(" ");
|
|
844
|
-
} finally {
|
|
845
|
-
rl.close();
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
|
|
1
|
+
export * from "./app-inferrer.js";
|
|
2
|
+
export * from "./app-types.js";
|
|
3
|
+
export * from "./app-backend.js";
|
|
4
|
+
export * from "./app-frontend.js";
|
|
5
|
+
export * from "./app-docs.js";
|