agent-enderun 0.5.9 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.enderun/PROJECT_MEMORY.md +23 -32
  2. package/.enderun/STATUS.md +19 -10
  3. package/.enderun/agents/analyst.md +10 -4
  4. package/.enderun/agents/backend.md +23 -12
  5. package/.enderun/agents/explorer.md +2 -2
  6. package/.enderun/agents/frontend.md +21 -10
  7. package/.enderun/agents/git.md +1 -1
  8. package/.enderun/agents/manager.md +10 -2
  9. package/.enderun/agents/mobile.md +2 -2
  10. package/.enderun/agents/native.md +2 -2
  11. package/.enderun/blueprints/backend/errors/domain-error.ts +1 -1
  12. package/.enderun/blueprints/backend/types/index.ts +49 -0
  13. package/{packages/shared-types/src → .enderun/blueprints/backend/types}/models.ts +0 -1
  14. package/.enderun/docs/api/README.md +7 -12
  15. package/.enderun/docs/project-docs.md +17 -7
  16. package/.enderun/docs/tech-stack.md +7 -8
  17. package/.enderun/knowledge/blueprint_driven_construction.md +22 -0
  18. package/.enderun/knowledge/code_review_checklist.md +1 -1
  19. package/.enderun/knowledge/contract_versioning.md +5 -5
  20. package/ENDERUN.md +8 -7
  21. package/README.md +51 -35
  22. package/bin/cli.js +217 -29
  23. package/bin/update-contract.js +2 -2
  24. package/{packages/framework-mcp → framework-mcp}/dist/index.js +0 -0
  25. package/{packages/framework-mcp → framework-mcp}/dist/schemas.js +12 -0
  26. package/{packages/framework-mcp → framework-mcp}/dist/tools/contract.js +5 -5
  27. package/{packages/framework-mcp → framework-mcp}/dist/tools/framework.js +3 -2
  28. package/{packages/framework-mcp → framework-mcp}/dist/tools/git.js +2 -4
  29. package/{packages/framework-mcp → framework-mcp}/dist/tools/index.js +3 -0
  30. package/{packages/framework-mcp → framework-mcp}/dist/tools/repository.js +1 -1
  31. package/framework-mcp/dist/tools/scaffold.js +129 -0
  32. package/{packages/framework-mcp → framework-mcp}/dist/utils.js +1 -1
  33. package/{packages/framework-mcp → framework-mcp}/package.json +1 -1
  34. package/{packages/framework-mcp → framework-mcp}/src/schemas.ts +15 -0
  35. package/{packages/framework-mcp → framework-mcp}/src/tools/contract.ts +5 -5
  36. package/{packages/framework-mcp → framework-mcp}/src/tools/framework.ts +3 -2
  37. package/{packages/framework-mcp → framework-mcp}/src/tools/git.ts +2 -3
  38. package/{packages/framework-mcp → framework-mcp}/src/tools/index.ts +3 -0
  39. package/{packages/framework-mcp → framework-mcp}/src/tools/repository.ts +1 -1
  40. package/framework-mcp/src/tools/scaffold.ts +147 -0
  41. package/{packages/framework-mcp → framework-mcp}/src/utils.ts +1 -1
  42. package/gemini-extension.json +1 -1
  43. package/package.json +7 -11
  44. package/.enderun/logs/manager.json +0 -1
  45. package/packages/shared-types/README.md +0 -61
  46. package/packages/shared-types/contract.version.json +0 -12
  47. package/packages/shared-types/dist/api.d.ts +0 -18
  48. package/packages/shared-types/dist/api.js +0 -2
  49. package/packages/shared-types/dist/api.js.map +0 -1
  50. package/packages/shared-types/dist/brands.d.ts +0 -13
  51. package/packages/shared-types/dist/brands.js +0 -2
  52. package/packages/shared-types/dist/brands.js.map +0 -1
  53. package/packages/shared-types/dist/constants.d.ts +0 -27
  54. package/packages/shared-types/dist/constants.js +0 -22
  55. package/packages/shared-types/dist/constants.js.map +0 -1
  56. package/packages/shared-types/dist/index.d.ts +0 -11
  57. package/packages/shared-types/dist/index.js +0 -12
  58. package/packages/shared-types/dist/index.js.map +0 -1
  59. package/packages/shared-types/dist/logs.d.ts +0 -15
  60. package/packages/shared-types/dist/logs.js +0 -2
  61. package/packages/shared-types/dist/logs.js.map +0 -1
  62. package/packages/shared-types/dist/models.d.ts +0 -60
  63. package/packages/shared-types/dist/models.js +0 -2
  64. package/packages/shared-types/dist/models.js.map +0 -1
  65. package/packages/shared-types/package.json +0 -36
  66. package/packages/shared-types/src/index.ts +0 -12
  67. package/packages/shared-types/tsconfig.json +0 -9
  68. /package/{packages/shared-types/src → .enderun/blueprints/backend/types}/api.ts +0 -0
  69. /package/{packages/shared-types/src → .enderun/blueprints/backend/types}/brands.ts +0 -0
  70. /package/{packages/shared-types/src → .enderun/blueprints/backend/types}/constants.ts +0 -0
  71. /package/{packages/shared-types/src → .enderun/blueprints/backend/types}/logs.ts +0 -0
  72. /package/{packages/framework-mcp → framework-mcp}/README.md +0 -0
  73. /package/{packages/framework-mcp → framework-mcp}/dist/tools/academy.js +0 -0
  74. /package/{packages/framework-mcp → framework-mcp}/dist/tools/codebase.js +0 -0
  75. /package/{packages/framework-mcp → framework-mcp}/dist/tools/database.js +0 -0
  76. /package/{packages/framework-mcp → framework-mcp}/dist/tools/knowledge.js +0 -0
  77. /package/{packages/framework-mcp → framework-mcp}/dist/tools/memory.js +0 -0
  78. /package/{packages/framework-mcp → framework-mcp}/dist/tools/messages.js +0 -0
  79. /package/{packages/framework-mcp → framework-mcp}/dist/tools/security.js +0 -0
  80. /package/{packages/framework-mcp → framework-mcp}/src/index.ts +0 -0
  81. /package/{packages/framework-mcp → framework-mcp}/src/tools/academy.ts +0 -0
  82. /package/{packages/framework-mcp → framework-mcp}/src/tools/codebase.ts +0 -0
  83. /package/{packages/framework-mcp → framework-mcp}/src/tools/database.ts +0 -0
  84. /package/{packages/framework-mcp → framework-mcp}/src/tools/knowledge.ts +0 -0
  85. /package/{packages/framework-mcp → framework-mcp}/src/tools/memory.ts +0 -0
  86. /package/{packages/framework-mcp → framework-mcp}/src/tools/messages.ts +0 -0
  87. /package/{packages/framework-mcp → framework-mcp}/src/tools/security.ts +0 -0
  88. /package/{packages/framework-mcp → framework-mcp}/tsconfig.json +0 -0
package/ENDERUN.md CHANGED
@@ -1,10 +1,10 @@
1
- # Agent Enderun (v0.5.9)
1
+ # Agent Enderun (v0.6.1)
2
2
  # Place in project root. This file is the single source of truth for Base Project AI Extensions.
3
3
 
4
4
  ## 🎖️ AGENT CHECKLIST (MANDATORY BEFORE RESPONSE)
5
5
  > Check this list at the end of every response:
6
6
  > - [ ] **Zero Mock:** Did you use fake data or placeholders? (Strictly Forbidden)
7
- > - [ ] **Contract First:** Are `shared-types` and `contract.version.json` up to date?
7
+ > - [ ] **Contract First:** Are the app's types and apps/backend/contract.version.json up to date?
8
8
  > - [ ] **Audit Log:** Did you log this action in `{{FRAMEWORK_DIR}}/logs/[agent].json`?
9
9
  > - [ ] **CLI Orchestration:** Does the action comply with `{{ADAPTER}} cli` rules?
10
10
  > - [ ] **No "..." allowed:** Did you write the code completely without omitting parts?
@@ -67,7 +67,7 @@ This file (`./{{ADAPTER}}.md`) and the `{{FRAMEWORK_DIR}}/docs/` folder represen
67
67
  - **Zero Temporary Storage & Single Source of Truth:** Storing, caching, or writing project details, logs, tasks, files, or agent planning documents (including implementation plans, scratch scripts, or intermediate tasks) in the operating system's temporary directory (`/tmp`, `/var/tmp`, `temp`, etc.) is strictly forbidden. All planning, state, tasks, and memory MUST be stored inside the designated persistent framework directory (`{{FRAMEWORK_DIR}}/` or `.{{ADAPTER}}/` etc.) or the project workspace. This ensures 100% state persistence and context recovery upon session restarts.
68
68
  - **Contract-First Agent Evolution:** Tools and SOPs used by agents must be defined via schemas and contracts first.
69
69
  - **Zero Mock Policy:** The use of fake (mock) data or placeholders is strictly forbidden. Every line of code must connect to a real endpoint or a typed contract. (Exception: Controlled mock usage is allowed for external 3rd party services like Stripe, Twilio).
70
- - **Branded Types Law:** All IDs (UserID, ProjectID, etc.) must be in the "Branded Types" format defined under `packages/shared-types`. Using plain strings or numbers is forbidden.
70
+ - **Branded Types Law:** All IDs (UserID, ProjectID, etc.) must be in the "Branded Types" format defined in the app-local types (e.g., `apps/backend/src/types`). Using plain strings or numbers is forbidden.
71
71
  - **CLI-First Policy:** Due to the AI CLI Assistant focus, all outputs must be user-friendly (using Chalk, Clack, etc.) and stream-based. All commands must support the `--output json` flag and produce machine-readable output.
72
72
  - **Audit Logging Necessity:** Every critical action must be logged traceably under the `{{FRAMEWORK_DIR}}/logs/` folder.
73
73
  - **Design Continuity & Response Policy:** All UI changes MUST be responsive (Mobile-First + Fluid) and surgical. Unnecessary overhauls of existing layouts are strictly forbidden.
@@ -182,12 +182,12 @@ This file is the single source of truth for API stability. `@backend-architect`
182
182
  The development process follows a strict State Machine. Transition to the next phase is prohibited until the "Success Criteria" of the current phase is met.
183
183
 
184
184
  - **[STATE: PHASE_0] Discovery & Setup:** Profile selection (Lightweight/Full), requirement analysis, and validating `{{FRAMEWORK_DIR}}/docs/tech-stack.md`.
185
- - **[STATE: PHASE_1] Architecture & Contracts:** Setup of data models, API schemas, and `packages/shared-types`. Cannot proceed until Frontend and Backend approve these schemas.
185
+ - **[STATE: PHASE_1] Architecture & Contracts:** Setup of data models, API schemas, and backend-defined types (e.g., apps/backend/src/types). Cannot proceed until Frontend and Backend approve these schemas.
186
186
  - **[STATE: PHASE_2] Core Development:** Active agents build core features in parallel based on the selected profile. (Under the apps/ folder)
187
187
  - **[STATE: PHASE_3] Integration & Testing:** System integration.
188
188
  - **[STATE: PHASE_4] Optimization & Deployment:** Performance audit and deployment.
189
189
 
190
- **Rollback Rule:** If a missing field or error is detected in the API schema (`shared-types`) during Phase 2 or later, the system immediately transitions to `[STATE: ROLLBACK_PHASE_1]`. All relevant agents stop their processes, switch to `WAITING` state, and cannot return to Phase 2 until the `backend-architect` resolves the issues.
190
+ **Rollback Rule:** If a missing field or error is detected in the API schema (app types) during Phase 2 or later, the system immediately transitions to `[STATE: ROLLBACK_PHASE_1]`. All relevant agents stop their processes, switch to `WAITING` state, and cannot return to Phase 2 until the `backend-architect` resolves the issues.
191
191
 
192
192
  ---
193
193
 
@@ -217,13 +217,13 @@ CLI behaviors (logLevel, outputFormat, defaultProfile) are managed through this
217
217
 
218
218
  ## API VERSIONING STRATEGY
219
219
 
220
- All APIs are versioned via the URL path (`/api/v1/...`). The `packages/shared-types/contract.version.json` file uses the MAJOR.MINOR format, and must be updated with every change. The `@backend-architect` is responsible for its accuracy. The MAJOR version is incremented for every breaking change. Old versions continue to be supported for at least 1 MAJOR release.
220
+ All APIs are versioned via the URL path (`/api/v1/...`). The `apps/backend/contract.version.json` file uses the MAJOR.MINOR format, and must be updated with every change. The `@backend-architect` is responsible for its accuracy. The MAJOR version is incremented for every breaking change. Old versions continue to be supported for at least 1 MAJOR release.
221
221
 
222
222
  ---
223
223
 
224
224
  ## PARALLEL EXECUTION & COORDINATION RULES
225
225
 
226
- 1. **Shared-Types as Source of Truth:** All agents reference `packages/shared-types` and the `contract.version.json` file.
226
+ 1. **Backend Types as Source of Truth:** All agents reference the app-local types (e.g., `apps/backend/src/types`) and the `apps/backend/contract.version.json` file.
227
227
  2. **Commit-Level Logging:** Every agent must log every atomic change to the `{{FRAMEWORK_DIR}}/logs/[agent-name].json` file.
228
228
  3. **Implicit Dependency Lock:** If an agent's required output is not ready, it switches to `WAITING` state.
229
229
  4. **Ownership Enforcement:** Changes to files outside an agent's scope cannot be made without `@team-lead` approval.
@@ -236,3 +236,4 @@ All APIs are versioned via the URL path (`/api/v1/...`). The `packages/shared-ty
236
236
  7. **Phase Rollback Protocol:** If contracts are insufficient, return to Phase 1. All agents become `WAITING` and write `CONTRACT_CHANGED` to their log.
237
237
  8. **Next.js Ownership Rule:** `apps/web/api/` and `server/actions/` -> @backend-architect. `apps/web/(routes)/` and `components/` -> @frontend-specialist.
238
238
  9. **Zero Mock Test Policy:** Integration tests must use a real database or service-compatible test backend; do not rely on mocks for persistence behavior.
239
+ .
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # 🏛️ Agent Enderun (v0.5.9) — The Supreme AI Governance Framework
1
+ # 🏛️ Agent Enderun (v0.6.1) — The Supreme AI Governance Framework
2
2
 
3
3
  **The Supreme AI Governance & Orchestration Framework for Enterprise Development**
4
4
 
@@ -164,12 +164,10 @@ Agent Enderun consists of **4 integrated layers**:
164
164
  └── docs/api/ ← API contract specifications
165
165
  ```
166
166
 
167
- ### Layer 2: Framework Core (bin/ + packages/)
167
+ ### Layer 2: Framework Core (bin/ + framework-mcp/)
168
168
  ```
169
169
  bin/cli.js ← CLI bootstrapper
170
- packages/
171
- ├── framework-mcp/ ← 40+ MCP tools (12 categories)
172
- └── shared-types/ ← Branded types (single source of truth)
170
+ framework-mcp/ ← 40+ MCP tools (13 categories) including Scaffolding
173
171
  ```
174
172
 
175
173
  ### Layer 3: Documentation (docs/)
@@ -317,28 +315,18 @@ agent-enderun/
317
315
  ├── bin/
318
316
  │ └── cli.js ← CLI entry point
319
317
  ├── docs/ ← Your project docs (agents read these)
320
- ├── tech-stack.md
321
- │ └── project-docs.md
322
- ├── packages/
323
- ├── shared-types/ ← Branded types (contract)
324
- ├── src/index.ts
325
- └── contract.version.json ← SHA-256 integrity hash
326
- │ └── framework-mcp/ ← MCP server (40+ tools)
327
- │ └── src/tools/
328
- │ ├── academy.ts
329
- │ ├── codebase.ts
330
- │ ├── security.ts
331
- │ ├── contract.ts
332
- │ ├── git.ts
333
- │ ├── knowledge.ts
334
- │ ├── database.ts
335
- │ ├── memory.ts
336
- │ ├── messages.ts
337
- │ ├── repository.ts
338
- │ └── framework.ts
318
+ ├── framework-mcp/ ← MCP server (40+ tools)
319
+ │ └── src/tools/
320
+ ├── scaffold.ts ← Blueprint construction
321
+ ├── academy.ts
322
+ ├── codebase.ts
323
+ └── [10 more...]
339
324
  ├── apps/ ← Your applications (start here)
340
- │ ├── backend/ ← (you create this)
341
- └── web/ (you create this)
325
+ │ ├── backend/
326
+ │ ├── src/types/ App-local contract types
327
+ │ │ └── contract.version.json ← SHA-256 integrity hash
328
+ │ └── web/
329
+ │ └── src/types/ ← Frontend mirrors of backend types
342
330
  └── {{FRAMEWORK_DIR}}/ ← Framework governance
343
331
  ├── ENDERUN.md ← Constitution (MANDATORY READ)
344
332
  ├── PROJECT_MEMORY.md ← State machine
@@ -629,17 +617,9 @@ agent-enderun trace:new "Auth Modülü Uygula" backend P1
629
617
  ```
630
618
  agent-enderun/
631
619
  ├── docs/ ← Ajanların okuyacağı dokümantasyon
632
- ├── packages/
633
- │ ├── shared-types/ ← Paylaşılan türler (sözleşme)
634
- │ └── framework-mcp/ ← MCP sunucusu (40+ araç)
620
+ ├── framework-mcp/ ← MCP sunucusu (40+ araç)
635
621
  ├── apps/ ← Uygulamalarınız (siz oluşturun)
636
622
  ├── {{FRAMEWORK_DIR}}/ ← Yönetişim dosyaları
637
- │ ├── ENDERUN.md ← Anayasa (OKUNMALI)
638
- │ ├── PROJECT_MEMORY.md ← Proje durumu
639
- │ ├── agents/ ← 8 ajan tanımı
640
- │ ├── logs/ ← Denetim kaydı
641
- │ ├── knowledge/ ← 16+ rehber
642
- │ └── docs/api/ ← API sözleşmeleri
643
623
  └── bin/
644
624
  └── cli.js ← CLI giriş noktası
645
625
  ```
@@ -748,3 +728,39 @@ All governance and engineering assets are consolidated under the framework direc
748
728
 
749
729
  ## 📜 License
750
730
  MIT © 2026 Yusuf BEKAR — **Agent Enderun: The Future of AI Governance.**
731
+ unctional.
732
+ - **Branded Types:** IDs must be type-safe (e.g., `UserID` vs `string`).
733
+ - **Panda CSS Only:** Zero-runtime CSS-in-JS for high-performance UI.
734
+ - **Contract-First:** Schemas are defined in `shared-types` BEFORE implementation.
735
+
736
+ ---
737
+
738
+ ## 📜 License
739
+ MIT © 2026 Yusuf BEKAR — **Agent Enderun: The Future of AI Governance.**
740
+ / # CLI Entry Point
741
+ ├── packages/ # Shared Types & MCP Engine
742
+ └── apps/ # Production Modules (Backend, Web, Mobile)
743
+ ```
744
+
745
+ ---
746
+
747
+ ## 🛡️ Engineering Standards
748
+
749
+ - **Zero Mock Policy:** Placeholders are forbidden. Every line of code must be functional.
750
+ - **Branded Types:** IDs must be type-safe (e.g., `UserID` vs `string`).
751
+ - **Panda CSS Only:** Zero-runtime CSS-in-JS for high-performance UI.
752
+ - **Contract-First:** Schemas are defined in `shared-types` BEFORE implementation.
753
+
754
+ ---
755
+
756
+ ## 📜 License
757
+ MIT © 2026 Yusuf BEKAR — **Agent Enderun: The Future of AI Governance.**
758
+ lders are forbidden. Every line of code must be functional.
759
+ - **Branded Types:** IDs must be type-safe (e.g., `UserID` vs `string`).
760
+ - **Panda CSS Only:** Zero-runtime CSS-in-JS for high-performance UI.
761
+ - **Contract-First:** Schemas are defined in `shared-types` BEFORE implementation.
762
+
763
+ ---
764
+
765
+ ## 📜 License
766
+ MIT © 2026 Yusuf BEKAR — **Agent Enderun: The Future of AI Governance.**
package/bin/cli.js CHANGED
@@ -159,7 +159,7 @@ function mergePackageJson(targetPath, sourcePath) {
159
159
  "enderun:check": "agent-enderun check",
160
160
  "enderun:test": "vitest run",
161
161
  "enderun:test:watch": "vitest",
162
- "enderun:build": `${runCmd} build --prefix packages/shared-types && ${runCmd} build --prefix packages/framework-mcp`,
162
+ "enderun:build": `${runCmd} build --prefix framework-mcp`,
163
163
  };
164
164
 
165
165
  const sourceDevDeps = sourcePkg.devDependencies || {};
@@ -183,7 +183,7 @@ function mergePackageJson(targetPath, sourcePath) {
183
183
  if (!targetPkg.name) targetPkg.name = path.basename(process.cwd());
184
184
  if (!targetPkg.version) targetPkg.version = "0.1.0";
185
185
  if (!targetPkg.type) targetPkg.type = "module";
186
- if (!targetPkg.workspaces) targetPkg.workspaces = ["packages/*"];
186
+ if (!targetPkg.workspaces) targetPkg.workspaces = ["apps/*", "framework-mcp"];
187
187
 
188
188
  // Add metadata
189
189
  targetPkg.enderun = {
@@ -337,8 +337,7 @@ async function initCommand(selectedAdapter) {
337
337
  "package.json",
338
338
  "tsconfig.json",
339
339
  "panda.config.ts",
340
- "packages/framework-mcp",
341
- "packages/shared-types",
340
+ "framework-mcp",
342
341
  ];
343
342
 
344
343
  const DIRS_TO_CREATE = [
@@ -353,8 +352,7 @@ async function initCommand(selectedAdapter) {
353
352
  "apps/web",
354
353
  "apps/backend",
355
354
  "docs",
356
- "packages/shared-types",
357
- "packages/framework-mcp",
355
+ "framework-mcp",
358
356
  ];
359
357
 
360
358
  console.log(`🚀 Installing Agent Enderun (Adapter: ${selectedAdapter || "all"})...`);
@@ -384,6 +382,16 @@ async function initCommand(selectedAdapter) {
384
382
  Object.values(ADAPTERS).forEach(list => filesToProcess.push(...list));
385
383
  }
386
384
 
385
+ // Ensure apps/backend structure for contract file
386
+ ensureDir(path.join(targetDir, "apps/backend"));
387
+ const initContractPath = path.join(targetDir, "apps/backend/contract.version.json");
388
+ if (!fs.existsSync(initContractPath)) {
389
+ writeJsonFile(initContractPath, {
390
+ "contract_hash": "initial_hash_placeholder",
391
+ "last_updated": new Date().toISOString()
392
+ });
393
+ }
394
+
387
395
  // Detect target project scope
388
396
  let targetPkg = {};
389
397
  try {
@@ -407,7 +415,7 @@ async function initCommand(selectedAdapter) {
407
415
  let dest = path.join(targetDir, item);
408
416
 
409
417
  // FORCED CLEANUP: Delete existing framework engine directory to ensure clean update
410
- if (["packages/framework-mcp"].includes(item)) {
418
+ if (["framework-mcp"].includes(item)) {
411
419
  if (fs.existsSync(dest)) {
412
420
  try {
413
421
  fs.rmSync(dest, { recursive: true, force: true });
@@ -432,7 +440,7 @@ async function initCommand(selectedAdapter) {
432
440
  if (fs.existsSync(src)) {
433
441
  if (fs.lstatSync(src).isDirectory()) {
434
442
  const skipFiles = (item === ".enderun") ? ["logs", "PROJECT_MEMORY.md", "PROJECT_MEMORY.lock"] : [];
435
- const nonDestructive = ["packages/shared-types", "docs", ".enderun"].includes(item);
443
+ const nonDestructive = ["docs", ".enderun"].includes(item);
436
444
  copyDir(src, dest, new Set(skipFiles), nonDestructive, targetBase, targetScope);
437
445
  } else {
438
446
  if (item === "package.json") continue; // We merge it later
@@ -507,7 +515,7 @@ async function initCommand(selectedAdapter) {
507
515
  ext.mcpServers = {
508
516
  "agent-enderun": {
509
517
  command: "node",
510
- args: ["packages/framework-mcp/dist/index.js"]
518
+ args: ["framework-mcp/dist/index.js"]
511
519
  }
512
520
  };
513
521
  fs.writeFileSync(geminiExtPath, JSON.stringify(ext, null, 2) + "\n");
@@ -519,7 +527,7 @@ async function initCommand(selectedAdapter) {
519
527
  }
520
528
 
521
529
  if (selectedAdapter === "claude") {
522
- const mcpPath = path.join(targetDir, "packages/framework-mcp/src/index.ts");
530
+ const mcpPath = path.join(targetDir, "framework-mcp/src/index.ts");
523
531
  console.log("\n📝 Claude Code Setup:");
524
532
  console.log("To enable Agent Enderun tools in Claude Code, run this command:");
525
533
  console.log(`\x1b[36mclaude config add framework-mcp npx tsx ${mcpPath}\x1b[0m`);
@@ -612,8 +620,8 @@ function checkCommand() {
612
620
  { name: "Framework Config (config.json)", path: path.join(frameworkDir, "config.json") },
613
621
  { name: "Agent Status (STATUS.md)", path: path.join(frameworkDir, "STATUS.md") },
614
622
  { name: "MCP Config (mcp.json)", path: "mcp.json" },
615
- { name: "Shared Types", path: "packages/shared-types/package.json" },
616
- { name: "MCP Server", path: "packages/framework-mcp/package.json" },
623
+ { name: "Backend Contract", path: "apps/backend/contract.version.json" },
624
+ { name: "MCP Server", path: "framework-mcp/package.json" },
617
625
  { name: "Tech Stack", path: path.join(frameworkDir, "docs/tech-stack.md") },
618
626
  { name: "Panda CSS Config", path: "panda.config.ts" },
619
627
  { name: "Requirements", path: path.join(frameworkDir, "docs/project-docs.md") },
@@ -633,7 +641,7 @@ function checkCommand() {
633
641
  }
634
642
 
635
643
  // Dependency Check
636
- const mcpNodeModules = path.join(process.cwd(), "packages/framework-mcp/node_modules");
644
+ const mcpNodeModules = path.join(process.cwd(), "framework-mcp/node_modules");
637
645
  const rootNodeModules = path.join(process.cwd(), "node_modules");
638
646
  if (!fs.existsSync(mcpNodeModules) && !fs.existsSync(rootNodeModules)) {
639
647
  console.log("❌ Dependencies MISSING! (Run 'npm install')");
@@ -643,7 +651,7 @@ function checkCommand() {
643
651
  }
644
652
 
645
653
  // MCP Build Check
646
- const mcpPath = path.join(process.cwd(), "packages/framework-mcp/dist/index.js");
654
+ const mcpPath = path.join(process.cwd(), "framework-mcp/dist/index.js");
647
655
  if (!fs.existsSync(mcpPath)) {
648
656
  console.log("❌ MCP Build MISSING! (Run 'npm run enderun:build')");
649
657
  issues++;
@@ -857,11 +865,11 @@ function traceNewCommand(description, agent = "manager", priority = "P2") {
857
865
  * Verify the shared-types contract hash.
858
866
  */
859
867
  function verifyContractCommand() {
860
- const sharedDir = path.join(targetDir, "packages/shared-types/src");
861
- const contractPath = path.join(targetDir, "packages/shared-types/contract.version.json");
868
+ const sharedDir = path.join(targetDir, "apps/backend/src/types");
869
+ const contractPath = path.join(targetDir, "apps/backend/contract.version.json");
862
870
 
863
871
  if (!fs.existsSync(sharedDir) || !fs.existsSync(contractPath)) {
864
- console.error("❌ Error: Shared types or contract.version.json not found.");
872
+ console.error("❌ Error: Backend types or contract.version.json not found.");
865
873
  return;
866
874
  }
867
875
 
@@ -953,7 +961,7 @@ function gitCommitCommand(traceId) {
953
961
  const files = cp.execSync("git diff --staged --name-only", { encoding: "utf8" }).split("\n").filter(Boolean);
954
962
  let type = "feat", scope = "code";
955
963
  if (files.some(f => f.includes(".md"))) type = "docs";
956
- else if (files.some(f => f.includes("shared-types"))) type = "arch";
964
+ else if (files.some(f => f.includes("apps/backend/src/types"))) type = "arch";
957
965
  else if (files.some(f => f.includes("bin/cli.js"))) type = "fix";
958
966
 
959
967
  const summary = files.length === 1 ? `update ${path.basename(files[0])}` : `update ${files.length} files`;
@@ -1227,8 +1235,8 @@ function buildSharedTypesContent(existingContent) {
1227
1235
  }
1228
1236
 
1229
1237
  function updateContractHashFile() {
1230
- const sharedDir = path.join(targetDir, "packages/shared-types/src");
1231
- const contractPath = path.join(targetDir, "packages/shared-types/contract.version.json");
1238
+ const sharedDir = path.join(targetDir, "apps/backend/src/types");
1239
+ const contractPath = path.join(targetDir, "apps/backend/contract.version.json");
1232
1240
  if (!fs.existsSync(sharedDir) || !fs.existsSync(contractPath)) return;
1233
1241
 
1234
1242
  const walk = (dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
@@ -1250,7 +1258,186 @@ function updateContractHashFile() {
1250
1258
  fs.writeFileSync(contractPath, JSON.stringify(contract, null, 2));
1251
1259
  }
1252
1260
 
1261
+ function createBaseTypeFiles(baseDir) {
1262
+ const typesDir = path.join(baseDir, "types");
1263
+ ensureDir(typesDir);
1264
+
1265
+ writeTextFile(path.join(typesDir, "api.ts"), `import { TraceID } from "./brands.js";
1266
+
1267
+ /**
1268
+ * API Response Wrappers
1269
+ */
1270
+ export interface ApiResponse<T> {
1271
+ data: T;
1272
+ meta?: {
1273
+ requestId: TraceID;
1274
+ timestamp: string;
1275
+ };
1276
+ }
1277
+
1278
+ export interface ApiError {
1279
+ error: {
1280
+ code: string;
1281
+ message: string;
1282
+ details?: unknown;
1283
+ };
1284
+ }
1285
+ `);
1286
+
1287
+ writeTextFile(path.join(typesDir, "brands.ts"), `/**
1288
+ * Branded Type Utility
1289
+ */
1290
+ export type Brand<K, T> = K & { __brand: T };
1291
+
1292
+ /**
1293
+ * Entity IDs (Branded)
1294
+ */
1295
+ export type TraceID = Brand<string, "TraceID">;
1296
+ export type AgentID = Brand<string, "AgentID">;
1297
+ export type ProjectID = Brand<string, "ProjectID">;
1298
+ export type UserID = Brand<string, "UserID">;
1299
+ `);
1300
+
1301
+ writeTextFile(path.join(typesDir, "constants.ts"), `import { TraceID } from "./brands.js";
1302
+
1303
+ /**
1304
+ * Project Phases
1305
+ */
1306
+ export const PROJECT_PHASES = ["PHASE_0", "PHASE_1", "PHASE_2", "PHASE_3", "PHASE_4"] as const;
1307
+ export type ProjectPhase = (typeof PROJECT_PHASES)[number];
1308
+
1309
+ /**
1310
+ * Execution Profiles
1311
+ */
1312
+ export const EXECUTION_PROFILES = ["Lightweight", "Full"] as const;
1313
+ export type ExecutionProfile = (typeof EXECUTION_PROFILES)[number];
1314
+
1315
+ /**
1316
+ * Task Priorities
1317
+ */
1318
+ export const TASK_PRIORITIES = ["P0", "P1", "P2", "P3"] as const;
1319
+ export type TaskPriority = (typeof TASK_PRIORITIES)[number];
1320
+
1321
+ /**
1322
+ * Task Statuses
1323
+ */
1324
+ export const TASK_STATUSES = ["PENDING", "IN_PROGRESS", "BLOCKED", "COMPLETED", "FAILED"] as const;
1325
+ export type TaskStatus = (typeof TASK_STATUSES)[number];
1326
+
1327
+ /**
1328
+ * Action Types & Status
1329
+ */
1330
+ export const ACTION_TYPES = ["CREATE", "MODIFY", "DELETE", "RESEARCH", "ORCHESTRATE"] as const;
1331
+ export type ActionType = (typeof ACTION_TYPES)[number];
1332
+
1333
+ export const ACTION_STATUSES = ["SUCCESS", "FAILURE", "WAITING"] as const;
1334
+ export type ActionStatus = (typeof ACTION_STATUSES)[number];
1335
+ `);
1336
+
1337
+ writeTextFile(path.join(typesDir, "index.ts"), `/**
1338
+ * Agent Enderun — App-Local Types (Modular)
1339
+ */
1340
+
1341
+ export * from "./brands.js";
1342
+ export * from "./constants.js";
1343
+ export * from "./models.js";
1344
+ export * from "./api.js";
1345
+ export * from "./logs.js";
1346
+ `);
1347
+
1348
+ writeTextFile(path.join(typesDir, "logs.ts"), `import { TraceID, AgentID } from "./brands.js";
1349
+ import { ActionType, ActionStatus } from "./constants.js";
1350
+
1351
+ /**
1352
+ * Audit & Agent Logging Types
1353
+ */
1354
+ export interface AgentActionLog {
1355
+ timestamp: string;
1356
+ agent: AgentID;
1357
+ action: ActionType;
1358
+ requestId: TraceID | "—";
1359
+ status: ActionStatus;
1360
+ summary: string;
1361
+ files?: string[];
1362
+ details?: Record<string, unknown>;
1363
+ }
1364
+ `);
1365
+
1366
+ writeTextFile(path.join(typesDir, "models.ts"), `import { UserID, TraceID, AgentID } from "./brands.js";
1367
+ import { ProjectPhase, ExecutionProfile, TaskPriority, TaskStatus } from "./constants.js";
1368
+
1369
+ /**
1370
+ * Base Entity Fields
1371
+ */
1372
+ export interface BaseEntity {
1373
+ id: string; // Usually ULID
1374
+ createdAt: string;
1375
+ updatedAt: string;
1376
+ deletedAt?: string | null;
1377
+ }
1378
+
1379
+ /**
1380
+ * Audit Log Model
1381
+ */
1382
+ export interface AuditLog extends BaseEntity {
1383
+ entityName: string;
1384
+ entityId: string;
1385
+ action: "CREATE" | "UPDATE" | "DELETE" | "RESTORE";
1386
+ userId: UserID;
1387
+ previousState?: Record<string, unknown> | null;
1388
+ newState?: Record<string, unknown> | null;
1389
+ traceId: TraceID;
1390
+ }
1391
+
1392
+ /**
1393
+ * User Model
1394
+ */
1395
+ export interface User extends BaseEntity {
1396
+ id: UserID;
1397
+ email: string;
1398
+ fullName: string;
1399
+ role: "ADMIN" | "DEVELOPER" | "VIEWER";
1400
+ }
1401
+
1402
+ export interface UserProfile extends User {
1403
+ avatarUrl?: string;
1404
+ bio?: string;
1405
+ preferences: Record<string, unknown>;
1406
+ }
1407
+
1408
+ /**
1409
+ * Project Status
1410
+ */
1411
+ export interface ProjectStatus {
1412
+ phase: ProjectPhase;
1413
+ profile: ExecutionProfile;
1414
+ lastUpdate: string;
1415
+ activeTraceId: TraceID | null;
1416
+ blockers: string[];
1417
+ }
1418
+
1419
+ /**
1420
+ * Task Model
1421
+ */
1422
+ export interface Task {
1423
+ id: TraceID;
1424
+ description: string;
1425
+ agent: AgentID;
1426
+ priority: TaskPriority;
1427
+ status: TaskStatus;
1428
+ createdAt: string;
1429
+ updatedAt: string;
1430
+ }
1431
+ `);
1432
+ console.log(`✅ Base types created in ${path.relative(targetDir, typesDir)}`);
1433
+ }
1434
+
1253
1435
  function createBackendFiles(spec) {
1436
+ createBaseTypeFiles(path.join(targetDir, "apps/backend/src"));
1437
+ writeJsonFile(path.join(targetDir, "apps/backend/contract.version.json"), {
1438
+ "contract_hash": "initial_hash_placeholder",
1439
+ "last_updated": new Date().toISOString()
1440
+ });
1254
1441
  writeJsonFile(path.join(targetDir, "apps/backend/package.json"), {
1255
1442
  name: "@agent-enderun/backend",
1256
1443
  version: "0.1.0",
@@ -1290,7 +1477,7 @@ function createBackendFiles(spec) {
1290
1477
  });
1291
1478
 
1292
1479
  writeTextFile(path.join(targetDir, "apps/backend/src/data.ts"), [
1293
- 'import type { Customer, DashboardSummary, ReportMetric, Role, User } from "../../../packages/shared-types/src/index.js";',
1480
+ 'import type { Customer, DashboardSummary, ReportMetric, Role, User } from "./types/index.js";',
1294
1481
  "",
1295
1482
  'const now = new Date().toISOString();',
1296
1483
  "",
@@ -1364,6 +1551,7 @@ function createBackendFiles(spec) {
1364
1551
  }
1365
1552
 
1366
1553
  function createWebFiles(spec) {
1554
+ createBaseTypeFiles(path.join(targetDir, "apps/web/src"));
1367
1555
  writeJsonFile(path.join(targetDir, "apps/web/package.json"), {
1368
1556
  name: "@agent-enderun/web",
1369
1557
  version: "0.1.0",
@@ -1632,7 +1820,7 @@ function updateProjectDocs(spec) {
1632
1820
  "",
1633
1821
  "- `apps/backend`: Fastify API",
1634
1822
  "- `apps/web`: React dashboard",
1635
- "- `packages/shared-types`: Contract-first shared TypeScript types",
1823
+ "- `apps/backend/src/types`: Contract-first backend TypeScript types",
1636
1824
  ].join("\n"));
1637
1825
 
1638
1826
  writeTextFile(path.join(apiDir, "README.md"), [
@@ -1658,7 +1846,7 @@ function updateMemoryForGeneratedApp(spec, traceId) {
1658
1846
  "- **Agent:** @manager",
1659
1847
  `- **Trace ID:** ${traceId}`,
1660
1848
  "- **Action:** Created full-stack starter from natural language request.",
1661
- "- **Files:** apps/backend, apps/web, shared-types, project docs",
1849
+ "- **Files:** apps/backend, apps/web, project docs",
1662
1850
  ].join("\n");
1663
1851
 
1664
1852
  updateProjectMemoryCommand("HISTORY", history);
@@ -1693,10 +1881,10 @@ async function createAppCommand(args) {
1693
1881
  createWebFiles(spec);
1694
1882
  updateProjectDocs(spec);
1695
1883
 
1696
- const sharedTypesPath = path.join(targetDir, "packages/shared-types/src/index.ts");
1697
- if (fs.existsSync(sharedTypesPath)) {
1698
- const existing = fs.readFileSync(sharedTypesPath, "utf8");
1699
- fs.writeFileSync(sharedTypesPath, buildSharedTypesContent(existing));
1884
+ const backendTypesPath = path.join(targetDir, "apps/backend/src/types/index.ts");
1885
+ if (fs.existsSync(backendTypesPath)) {
1886
+ const existing = fs.readFileSync(backendTypesPath, "utf8");
1887
+ fs.writeFileSync(backendTypesPath, buildSharedTypesContent(existing));
1700
1888
  updateContractHashFile();
1701
1889
  }
1702
1890
 
@@ -1705,7 +1893,7 @@ async function createAppCommand(args) {
1705
1893
 
1706
1894
  console.log(`\n✅ Created ${spec.title}`);
1707
1895
  console.log("📁 Generated apps/backend and apps/web");
1708
- console.log("📜 Updated project docs and shared-types contract");
1896
+ console.log("📜 Updated project docs and app-local types contract");
1709
1897
  console.log("\nNext commands:");
1710
1898
  console.log(" npm install");
1711
1899
  console.log(" npm run enderun:build");
@@ -1746,7 +1934,7 @@ async function main() {
1746
1934
  verifyContractCommand();
1747
1935
  break;
1748
1936
  case "mcp": {
1749
- const mcpServerPath = path.join(sourceDir, "packages/framework-mcp/dist/index.js");
1937
+ const mcpServerPath = path.join(sourceDir, "framework-mcp/dist/index.js");
1750
1938
  if (fs.existsSync(mcpServerPath)) {
1751
1939
  const { spawn } = await import("child_process");
1752
1940
  // Use node to execute the built MCP server
@@ -12,8 +12,8 @@ const __filename = fileURLToPath(import.meta.url);
12
12
  const __dirname = path.dirname(__filename);
13
13
  const projectRoot = path.join(__dirname, "..");
14
14
 
15
- const contractPath = path.join(projectRoot, "packages/shared-types/contract.version.json");
16
- const sharedTypesDir = path.join(projectRoot, "packages/shared-types/src");
15
+ const contractPath = path.join(projectRoot, "apps/backend/contract.version.json");
16
+ const sharedTypesDir = path.join(projectRoot, "apps/backend/src/types");
17
17
 
18
18
  function collectTypeFiles(dir) {
19
19
  const entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -98,3 +98,15 @@ export const SYNC_CONTRACT_HASH_ARGS_SCHEMA = z.object({
98
98
  export const VERIFY_FRAMEWORK_HEALTH_ARGS_SCHEMA = z.object({
99
99
  detailed: z.boolean().default(false),
100
100
  });
101
+ export const INSTANTIATE_BLUEPRINT_ARGS_SCHEMA = z.object({
102
+ blueprintPath: z.string().min(1),
103
+ targetPath: z.string().min(1),
104
+ });
105
+ export const LIST_BLUEPRINTS_ARGS_SCHEMA = z.object({
106
+ category: z.enum(["backend", "frontend"]).optional(),
107
+ });
108
+ export const SAVE_AS_BLUEPRINT_ARGS_SCHEMA = z.object({
109
+ blueprintPath: z.string().min(1),
110
+ content: z.string().min(1),
111
+ description: z.string().optional(),
112
+ });
@@ -44,8 +44,8 @@ export const contractTools = [
44
44
  export const contractHandlers = {
45
45
  verify_api_contract: async (args, projectRoot) => {
46
46
  try {
47
- const sharedTypesDir = path.join(projectRoot, "packages/shared-types/src");
48
- const contractJsonPath = path.join(projectRoot, "packages/shared-types/contract.version.json");
47
+ const sharedTypesDir = path.join(projectRoot, "apps/backend/src/types");
48
+ const contractJsonPath = path.join(projectRoot, "apps/backend/contract.version.json");
49
49
  if (!fs.existsSync(sharedTypesDir) || !fs.existsSync(contractJsonPath))
50
50
  return { content: [{ type: "text", text: "Missing shared-types directory or contract.version.json" }] };
51
51
  const currentHash = calculateContractHash(sharedTypesDir, projectRoot);
@@ -58,8 +58,8 @@ export const contractHandlers = {
58
58
  },
59
59
  update_contract_hash: async (args, projectRoot) => {
60
60
  try {
61
- const sharedTypesDir = path.join(projectRoot, "packages/shared-types/src");
62
- const contractJsonPath = path.join(projectRoot, "packages/shared-types/contract.version.json");
61
+ const sharedTypesDir = path.join(projectRoot, "apps/backend/src/types");
62
+ const contractJsonPath = path.join(projectRoot, "apps/backend/contract.version.json");
63
63
  if (!fs.existsSync(sharedTypesDir))
64
64
  return { content: [{ type: "text", text: "Missing shared-types directory" }] };
65
65
  const files = collectFilesRecursively(sharedTypesDir, new Set(["ts"])).sort();
@@ -83,7 +83,7 @@ export const contractHandlers = {
83
83
  try {
84
84
  const frameworkDir = getFrameworkDir(projectRoot);
85
85
  const apiDocPath = path.join(projectRoot, frameworkDir, "docs/api", `${parsed.data.domain}.md`);
86
- const sharedTypesDir = path.join(projectRoot, "packages/shared-types/src");
86
+ const sharedTypesDir = path.join(projectRoot, "apps/backend/src/types");
87
87
  if (!fs.existsSync(apiDocPath))
88
88
  return { content: [{ type: "text", text: `API documentation not found for domain: ${parsed.data.domain}` }] };
89
89
  if (!fs.existsSync(sharedTypesDir))
@@ -103,8 +103,9 @@ export const frameworkHandlers = {
103
103
  const missing = [];
104
104
  const frameworkDir = getFrameworkDir(projectRoot);
105
105
  const checkPaths = [
106
- { path: "apps", type: "folder", optional: true },
107
- { path: "packages/shared-types/src", type: "folder" },
106
+ { path: "apps/backend/src/types", type: "folder" },
107
+ { path: "apps/web/src/types", type: "folder" },
108
+ { path: "framework-mcp/src", type: "folder" },
108
109
  { path: path.join(frameworkDir, "docs/api"), type: "folder", optional: true },
109
110
  { path: ".env", type: "file", optional: true },
110
111
  { path: ".env.example", type: "file" },