agent-enderun 0.9.4 → 1.0.0
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/ENDERUN.md +1 -1
- package/.enderun/PROJECT_MEMORY.md +2 -21
- package/.enderun/STATUS.md +11 -7
- package/.enderun/agents/analyst.md +28 -0
- package/.enderun/agents/backend.md +33 -367
- package/.enderun/agents/database.md +27 -45
- package/.enderun/agents/devops.md +27 -187
- package/.enderun/agents/explorer.md +23 -124
- package/.enderun/agents/frontend.md +32 -345
- package/.enderun/agents/git.md +26 -110
- package/.enderun/agents/manager.md +30 -299
- package/.enderun/agents/mobile.md +28 -91
- package/.enderun/agents/native.md +27 -96
- package/.enderun/agents/quality.md +26 -114
- package/.enderun/agents/security.md +28 -0
- package/.enderun/config.json +1 -1
- package/.enderun/knowledge/analyst_reference_guide.md +31 -0
- package/.enderun/knowledge/backend_reference_guide.md +165 -0
- package/.enderun/knowledge/database_reference_guide.md +38 -0
- package/.enderun/knowledge/devops_reference_guide.md +43 -0
- package/.enderun/knowledge/explorer_reference_guide.md +34 -0
- package/.enderun/knowledge/frontend_reference_guide.md +64 -0
- package/.enderun/knowledge/git_reference_guide.md +51 -0
- package/.enderun/knowledge/manager_reference_guide.md +55 -0
- package/.enderun/knowledge/mobile_reference_guide.md +35 -0
- package/.enderun/knowledge/native_reference_guide.md +34 -0
- package/.enderun/knowledge/quality_reference_guide.md +42 -0
- package/.enderun/knowledge/security_reference_guide.md +35 -0
- package/.enderun/logs/manager.json +1 -17
- package/.enderun/memory-graph/agent-contexts/analyst.json +1 -0
- package/.enderun/memory-graph/agent-contexts/backend.json +1 -1
- package/.enderun/memory-graph/agent-contexts/devops.json +1 -1
- package/.enderun/memory-graph/agent-contexts/explorer.json +1 -1
- package/.enderun/memory-graph/agent-contexts/frontend.json +1 -1
- package/.enderun/memory-graph/agent-contexts/git.json +1 -1
- package/.enderun/memory-graph/agent-contexts/manager.json +1 -1
- package/.enderun/memory-graph/agent-contexts/mobile.json +1 -1
- package/.enderun/memory-graph/agent-contexts/native.json +1 -1
- package/.enderun/memory-graph/agent-contexts/quality.json +1 -1
- package/.enderun/memory-graph/agent-contexts/security.json +1 -0
- package/.enderun/memory-graph/shared-facts.json +1 -1
- package/README.md +95 -21
- package/agent.md +1 -1
- package/bin/cli.js +2 -1
- package/bin/init-check.js +1 -1
- package/bin/update-contract.js +1 -1
- package/claude.md +1 -1
- package/dist/.keep +1 -0
- package/docs/README.md +11 -1
- package/docs/getting-started.md +1 -1
- package/eslint.config.js +1 -1
- package/framework-mcp/dist/index.js +44 -242
- package/framework-mcp/dist/tools/definitions.js +109 -0
- package/framework-mcp/dist/tools/file_system/patch_file.js +18 -0
- package/framework-mcp/dist/tools/file_system/read_file.js +7 -0
- package/framework-mcp/dist/tools/file_system/replace_text.js +14 -0
- package/framework-mcp/dist/tools/file_system/write_file.js +9 -0
- package/framework-mcp/dist/tools/framework/get_status.js +5 -0
- package/framework-mcp/dist/tools/framework/orchestrate.js +5 -0
- package/framework-mcp/dist/tools/framework/update_contract_hash.js +5 -0
- package/framework-mcp/dist/tools/framework/update_memory.js +8 -0
- package/framework-mcp/dist/tools/index.js +25 -0
- package/framework-mcp/dist/tools/messaging/log_action.js +22 -0
- package/framework-mcp/dist/tools/messaging/send_message.js +21 -0
- package/framework-mcp/dist/tools/types.js +1 -0
- package/framework-mcp/dist/utils/cli.js +20 -0
- package/framework-mcp/dist/utils/security.js +35 -0
- package/framework-mcp/package.json +1 -1
- package/framework-mcp/src/declarations.d.ts +17 -3
- package/framework-mcp/src/index.ts +51 -279
- package/framework-mcp/src/tools/definitions.ts +111 -0
- package/framework-mcp/src/tools/file_system/patch_file.ts +23 -0
- package/framework-mcp/src/tools/file_system/read_file.ts +9 -0
- package/framework-mcp/src/tools/file_system/replace_text.ts +18 -0
- package/framework-mcp/src/tools/file_system/write_file.ts +11 -0
- package/framework-mcp/src/tools/framework/get_status.ts +7 -0
- package/framework-mcp/src/tools/framework/orchestrate.ts +7 -0
- package/framework-mcp/src/tools/framework/update_contract_hash.ts +7 -0
- package/framework-mcp/src/tools/framework/update_memory.ts +10 -0
- package/framework-mcp/src/tools/index.ts +31 -0
- package/framework-mcp/src/tools/messaging/log_action.ts +28 -0
- package/framework-mcp/src/tools/messaging/send_message.ts +26 -0
- package/framework-mcp/src/tools/types.ts +40 -0
- package/framework-mcp/src/utils/cli.ts +20 -0
- package/framework-mcp/src/utils/security.ts +41 -0
- package/gemini.md +7 -1
- package/grok.md +1 -1
- package/package.json +6 -5
- package/src/cli/adapters.ts +29 -8
- package/src/cli/commands/check.ts +7 -1
- package/src/cli/commands/init.ts +80 -27
- package/src/cli/commands/orchestrate.ts +98 -92
- package/src/cli/index.ts +5 -2
- package/src/cli/utils/app.ts +1 -1
- package/src/cli/utils/fs.ts +47 -13
- package/src/cli/utils/memory.ts +11 -4
- package/src/cli/utils/pkg.ts +5 -4
- package/docs/architecture/README.md +0 -9
- package/docs/user/README.md +0 -35
|
@@ -1,124 +1,36 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: quality
|
|
2
|
+
name: "@quality"
|
|
3
|
+
capability: 9
|
|
4
|
+
role: "Automated Testing & Quality Specialist"
|
|
5
|
+
specialization: "Verifies test coverage, audits compliance with the constitution, conducts AST scanning, and verifies CI/CD status."
|
|
6
|
+
rules: ["80% Coverage Threshold", "No Placeholders", "Zero Mock Policy", "Strict ESlint Compliance", "Surgical Edits"]
|
|
7
|
+
permittedDirectories: ["tests", "apps", ".enderun", "docs"]
|
|
8
|
+
hermesChannels: ["@quality->*", "@quality->@manager"]
|
|
3
9
|
description: "Unified Quality, Security, and Analysis Authority for Agent Enderun"
|
|
4
10
|
---
|
|
5
11
|
|
|
6
|
-
# @quality —
|
|
12
|
+
# @quality — Quality & Security (STRICT_RULES)
|
|
7
13
|
|
|
8
|
-
- **
|
|
9
|
-
- **
|
|
10
|
-
- **QA:** Vitest, regression suite management, deployment gate validation, TDD design patterns.
|
|
11
|
-
- **Security:** AST vulnerability scanning, OWASP compliance, hardcoded secret detection.
|
|
12
|
-
- **Analysis:** Memory discipline, contract drift detection, procedural continuity auditing, technical debt reporting.
|
|
13
|
-
- **Permitted Directories:**
|
|
14
|
-
- `.enderun/`
|
|
15
|
-
- `apps/backend/src/`
|
|
16
|
-
- `apps/web/src/`
|
|
17
|
-
- `framework-mcp/src/`
|
|
18
|
-
- `docs/`
|
|
19
|
-
- **Hermes Channels:**
|
|
20
|
-
- `@quality->@manager`
|
|
21
|
-
- `@quality->@backend`
|
|
22
|
-
- `@quality->@frontend`
|
|
23
|
-
- `@quality->@git`
|
|
24
|
-
- `@quality->@devops`
|
|
25
|
-
- **Tags:** specialist, quality, security, governance
|
|
14
|
+
- **Identity:** Final Gatekeeper for Quality, Security, and Compliance.
|
|
15
|
+
- **Goal:** Ensure no code is merged or deployed without meeting standards.
|
|
26
16
|
|
|
27
|
-
##
|
|
28
|
-
- **
|
|
29
|
-
- **Verification
|
|
30
|
-
- **Never Implement:**
|
|
31
|
-
- **Zero Mock Policy:** Integration tests must use real
|
|
32
|
-
- **
|
|
17
|
+
## 🛑 NON-NEGOTIABLE CORE RULES
|
|
18
|
+
- **Final Gate:** No code merges or deploys proceed without @quality sign-off.
|
|
19
|
+
- **Verification-First:** Audit lint, typecheck, contract drift, and branded types before sign-off.
|
|
20
|
+
- **Never Implement:** Audit and assess only. Never write application features.
|
|
21
|
+
- **Zero Mock Policy:** Integration tests must use real/service-compatible backends.
|
|
22
|
+
- **Coverage Gate:** Reject approvals if coverage falls below >80% threshold in core.
|
|
23
|
+
- **No console.log:** Strictly reject `console.log` and native `alert()/confirm()`.
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### 1. API Contract Audit (Mandatory Gate)
|
|
39
|
-
- Run `verify_contract_integrity` on phase transitions.
|
|
40
|
-
- Check `contract.version.json` for hash mismatches.
|
|
41
|
-
- Verify modular type imports in `shared-types`.
|
|
42
|
-
|
|
43
|
-
### 2. Procedural Continuity Audit
|
|
44
|
-
- Use `analyze_procedural_continuity` to compare agent changes against "Gold Standard" files.
|
|
45
|
-
- Enforce: Branded Types, Domain Errors, Audit Logging for mutations.
|
|
46
|
-
|
|
47
|
-
### 3. Security Auditing (OWASP & Constitution)
|
|
48
|
-
- Run `security_audit_scan` (secrets, raw SQL, unsafe patterns).
|
|
49
|
-
- Run `analyze_constitution_compliance` (No `any`, Zero Mock, File ownership).
|
|
50
|
-
- **Logging Audit:** Scan for and reject `console.log` usage; verify `AuditService.log()` calls in mutation handlers.
|
|
51
|
-
- **Responsive/Breakpoint Audit:** Verify all UI components against defined Panda CSS breakpoints and Mobile-First mandates.
|
|
52
|
-
- **Native Dialog Audit:** Scan for and reject usage of `alert()` and `confirm()` in frontend code.
|
|
53
|
-
- **Post-Mortem Procedure:** If a task fails or is rejected, perform root-cause analysis and append to `.enderun/knowledge/lessons-learned.md`.
|
|
54
|
-
- Findings must be categorized: CRITICAL, HIGH, MEDIUM, LOW.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## Log Schema (Mandatory)
|
|
61
|
-
Every action must be logged using `log_agent_action` to `.enderun/logs/quality.json`.
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"timestamp": "ISO-8601",
|
|
66
|
-
"agent": "@quality",
|
|
67
|
-
"action": "QA | SECURITY | ANALYST",
|
|
68
|
-
"requestId": "TRACE-ID",
|
|
69
|
-
"status": "SUCCESS | FAILURE",
|
|
70
|
-
"summary": "English summary",
|
|
71
|
-
"findings": []
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
# Operational Protocols (Combined)
|
|
78
|
-
|
|
79
|
-
## 🎯 Memory Management (Analyst)
|
|
80
|
-
- Read `PROJECT_MEMORY.md` at session start.
|
|
81
|
-
- Enforce Lock Protocol for writing to memory.
|
|
82
|
-
|
|
83
|
-
## 🧪 Deployment Gate (QA)
|
|
84
|
-
- Unit tests pass, Integration tests pass against real test DB.
|
|
85
|
-
- Coverage meets project threshold.
|
|
86
|
-
- No skipped tests without manager approval.
|
|
87
|
-
- **CI/CD Coverage Gate:** Strictly reject PR gate approval if the automated coverage report falls below the mandatory >80% threshold in core packages and domain logic.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## 🛡️ Security Audit Gate (Security)
|
|
91
|
-
- Zero CRITICAL/HIGH findings for deploy/merge.
|
|
92
|
-
- No hardcoded secrets.
|
|
93
|
-
- Redact all sensitive values in reports.
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 📋 Code Review Checklist (Mandatory)
|
|
98
|
-
|
|
99
|
-
When conducting or auditing code reviews, the following verification checklist must be completely satisfied:
|
|
100
|
-
- [ ] **Constitution:** Does the code strictly follow `ENDERUN.md` and all core mandates?
|
|
101
|
-
- [ ] **Contract Compliance:** Are all types imported from the app's local types directory? No inline drift?
|
|
102
|
-
- [ ] **Database Integrity:** Is there any Raw SQL usage? (Kysely queries only, raw SQL is forbidden).
|
|
103
|
-
- [ ] **Test Integrity:** Are corresponding unit/integration tests included for all new changes?
|
|
104
|
-
- [ ] **UI Standards:** Is the code strictly mobile-first with zero native dialogs (if UI)?
|
|
25
|
+
## 🔌 SESSION PROTOCOL
|
|
26
|
+
1. **Restore:** Read `PROJECT_MEMORY.md`.
|
|
27
|
+
2. **Reference:** During audits or phase transitions, READ `.enderun/knowledge/quality_reference_guide.md` once.
|
|
28
|
+
3. **Log:** Update `PROJECT_MEMORY.md` and log action at the end of every turn.
|
|
105
29
|
|
|
106
30
|
---
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
2. **Integration Tests:** Required for API endpoints using a real database or service-compatible test backend (Zero Mock Policy).
|
|
113
|
-
3. **Naming Standard:** Test files must end in `.test.ts` (or `.test.tsx`).
|
|
114
|
-
4. **Coverage Target:** Aim for >80% coverage in core packages and domain logic.
|
|
115
|
-
|
|
31
|
+
**Agent Completion Report**
|
|
32
|
+
- Reference Guide read? [ ] No / [ ] Yes
|
|
33
|
+
- Contract integrity verified? [ ] No / [ ] Yes
|
|
34
|
+
- Security scan performed? [ ] No / [ ] Yes
|
|
35
|
+
- PROJECT_MEMORY updated? [ ] No / [ ] Yes
|
|
116
36
|
---
|
|
117
|
-
|
|
118
|
-
## 🛡️ Security Scanning Standards (Mandatory)
|
|
119
|
-
|
|
120
|
-
All packages and source code must meet the following threat vectors and automated checks:
|
|
121
|
-
1. **No Raw SQL:** Always use Kysely query builder to prevent SQL injection.
|
|
122
|
-
2. **Secrets Management:** Never hardcode API keys, credentials, tokens, or passwords. Strictly use `.env` files.
|
|
123
|
-
3. **Automated Audit:** Run `agent-enderun check:security` before every Pull Request is finalized.
|
|
124
|
-
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "@security"
|
|
3
|
+
capability: 9
|
|
4
|
+
role: "Security & Cryptography Specialist"
|
|
5
|
+
specialization: "Enforces authentication flows, CSP policies, credential rotation, RLS constraints, and cryptographic safety."
|
|
6
|
+
rules: ["Strict Authentication Enforcement", "Zero Hardcoded Secrets", "RLS Verification Mandatory", "Surgical Edits"]
|
|
7
|
+
permittedDirectories: ["*", ".enderun", "docs"]
|
|
8
|
+
hermesChannels: ["@security->*", "@security->@manager"]
|
|
9
|
+
description: "Security & Cryptography Specialist Agent for Agent Enderun"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# @security — Security & Cryptography (STRICT_RULES)
|
|
13
|
+
|
|
14
|
+
- **Identity:** Security, Authorization & Cryptography Specialist.
|
|
15
|
+
- **Goal:** Ensure all endpoints, database connections, and authentication flows satisfy strict enterprise compliance policies.
|
|
16
|
+
|
|
17
|
+
## 🛑 NON-NEGOTIABLE CORE RULES
|
|
18
|
+
- **Sandboxed Security First:** Enforce Row Level Security (RLS) on all database tables.
|
|
19
|
+
- **Credential Rotation Policy:** Credentials, keys, and tokens must never be hardcoded. Use vault/env variables.
|
|
20
|
+
- **CSP & CORS Strictness:** Never open wildcards (`*`) for CORS or CSP policies.
|
|
21
|
+
- **Surgical Edits:** Use `replace_text` for all security patches.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
**Agent Completion Report**
|
|
25
|
+
- Cryptographic keys audited? [ ] No / [ ] Yes
|
|
26
|
+
- CSP policies scanned? [ ] No / [ ] Yes
|
|
27
|
+
- PROJECT_MEMORY updated? [ ] No / [ ] Yes
|
|
28
|
+
---
|
package/.enderun/config.json
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @analyst — Contract Verification & Business Analyst Reference Guide
|
|
2
|
+
|
|
3
|
+
Detailed instructions on checking contract drift, validating business requirements, and verifying architectural compliance with the Enderun Constitution. Reference this file during phase gates, type synchronization, and spec audits.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🕵️ Contract Integrity Protocols
|
|
8
|
+
|
|
9
|
+
### 1. Contract Drift Validation
|
|
10
|
+
- Audit the synchronization between backend type specifications and frontend copy layers.
|
|
11
|
+
- Check `contract.version.json` signatures against actual type exports.
|
|
12
|
+
|
|
13
|
+
### 2. Business Spec Verification
|
|
14
|
+
- Map user business requirements directly to implemented route types.
|
|
15
|
+
- Reject any spec deviation or incomplete endpoint parameters.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 📋 Analyst Auditing Checklist (Mandatory)
|
|
20
|
+
- [ ] **Types Sync:** Do backend types and frontend interfaces match perfectly?
|
|
21
|
+
- [ ] **Contract Signature:** Is the SHA-256 contract hash inside `contract.version.json` up to date?
|
|
22
|
+
- [ ] **Domain Error Usage:** Are all custom errors extending `DomainError` instead of generic `Error`?
|
|
23
|
+
- [ ] **Branded Types:** Are IDs formatted as branded types (e.g., `UserID`) rather than plain strings?
|
|
24
|
+
- [ ] **Constitutional Alignment:** Do all agent-assigned features respect the Zero Mock and Zero UI Library policies?
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📈 Quality Gate Verification
|
|
29
|
+
1. **Verification Reports:** Log every audit session under the Trace ID.
|
|
30
|
+
2. **Handoff Clearance:** Provide explicit sign-off to `@manager` before moving to the next Phase.
|
|
31
|
+
3. **Audit Trail Logs:** Ensure that contract verification logs are preserved in `memory-graph/`.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @backend — Reference & Implementation Guide
|
|
2
|
+
|
|
3
|
+
This guide contains detailed architectural patterns, implementation standards, and reusable code structures for Agent Enderun projects. Reference this file via `read_file` only when implementing new features or debugging complex logic.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🏗️ Standard Backend Patterns (Mandatory)
|
|
8
|
+
|
|
9
|
+
The agent builds the project's backend infrastructure according to standardized patterns.
|
|
10
|
+
|
|
11
|
+
### 1. Error System (DomainError Hierarchy)
|
|
12
|
+
All errors must be based on `DomainError`. Standard hierarchy:
|
|
13
|
+
|
|
14
|
+
- `DomainError` (base)
|
|
15
|
+
- `NotFoundError`
|
|
16
|
+
- `ValidationError`
|
|
17
|
+
- `UnauthorizedError`
|
|
18
|
+
- `ForbiddenError`
|
|
19
|
+
- `ConflictError`
|
|
20
|
+
- `InternalServerError`
|
|
21
|
+
|
|
22
|
+
Each error class must follow this structure:
|
|
23
|
+
```ts
|
|
24
|
+
export class NotFoundError extends DomainError {
|
|
25
|
+
constructor(resource: string) {
|
|
26
|
+
super(`${resource} not found`, 404);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Rule:** Never use `throw new Error()`. Always use one of the DomainError subclasses.
|
|
32
|
+
|
|
33
|
+
### 2. Branded Types (Mandatory)
|
|
34
|
+
All IDs must be branded types to ensure complete type safety and prevent runtime errors.
|
|
35
|
+
Example:
|
|
36
|
+
```ts
|
|
37
|
+
export type UserID = string & { __brand: 'UserID' };
|
|
38
|
+
export type OrderID = string & { __brand: 'OrderID' };
|
|
39
|
+
// Alternative Brand utility
|
|
40
|
+
export type Brand<T, B> = T & { __brand: B };
|
|
41
|
+
export type ProjectID = Brand<string, 'ProjectID'>;
|
|
42
|
+
```
|
|
43
|
+
Using plain `string` or `number` IDs is strictly forbidden where a specific ID is expected.
|
|
44
|
+
|
|
45
|
+
### 3. Types Structure (Standard)
|
|
46
|
+
The `apps/backend/src/types/` directory must be organized as follows:
|
|
47
|
+
- `brands.ts` → Branded ID types
|
|
48
|
+
- `models.ts` → Domain models
|
|
49
|
+
- `api.ts` → Request/Response types
|
|
50
|
+
- `constants.ts` → Constant values
|
|
51
|
+
- `logs.ts` → Log types
|
|
52
|
+
|
|
53
|
+
### 4. Error Handler Middleware
|
|
54
|
+
All routes must use a global error handler. Errors must be returned in the standard JSON format:
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"error": {
|
|
58
|
+
"message": "User not found",
|
|
59
|
+
"code": 404,
|
|
60
|
+
"details": {}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 5. API Design Rules
|
|
66
|
+
1. **Versioned Routes**: All APIs must start with `/api/v1/`.
|
|
67
|
+
2. **Kebab-Case**: Use kebab-case for URL paths.
|
|
68
|
+
3. **Standard Responses**: Always wrap data in `{ data, traceId, timestamp }`.
|
|
69
|
+
4. **Method Discipline**: GET (read), POST (create), PUT (update), DELETE (remove).
|
|
70
|
+
|
|
71
|
+
### 6. Repository Pattern Standards
|
|
72
|
+
- **Purpose**: Decouple the data access logic from the business logic. This ensures that changes in the database schema or ORM do not break the entire application.
|
|
73
|
+
- **Principles**:
|
|
74
|
+
1. **Abstraction**: Use interfaces to define the repository contract.
|
|
75
|
+
2. **Implementation**: Use Kysely or preferred ORM for actual DB calls.
|
|
76
|
+
3. **Single Responsibility**: One repository per domain entity.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Architecture Thinking (At the Beginning of Every Task)
|
|
81
|
+
|
|
82
|
+
Clarify the following before writing code:
|
|
83
|
+
|
|
84
|
+
- **Domain:** What business concept does this feature represent?
|
|
85
|
+
- **Contract:** Are the app's types in `apps/backend/src/types` up to date? Is there a type for this entity?
|
|
86
|
+
- **Layer:** Which layer is affected — Route → Controller → Service → Repository → DB?
|
|
87
|
+
- **Side Effects:** Does it trigger an event, send an email, or update another table?
|
|
88
|
+
- **Security:** Is authentication required? Which role/permission?
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Mandatory Layered Architecture
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Route (Fastify)
|
|
96
|
+
└─ Controller ← Input validation, response shaping
|
|
97
|
+
└─ Service ← Business logic, orchestration
|
|
98
|
+
└─ Repository ← ONLY Kysely queries (raw SQL forbidden)
|
|
99
|
+
└─ Database (PostgreSQL)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 🏗️ Base Architecture & Code Reuse (Standard)
|
|
105
|
+
|
|
106
|
+
To eliminate code repetition, all backend development MUST follow the **Base Pattern**. Agents are not allowed to write redundant CRUD logic.
|
|
107
|
+
|
|
108
|
+
**Standard Patterns:**
|
|
109
|
+
1. **Base Repository:** Use a centralized repository logic for common Kysely operations (findById, findMany, create, update, softDelete).
|
|
110
|
+
2. **Base Service:** Orchestrate business logic using reusable services.
|
|
111
|
+
3. **Typed Config:** Always access environment variables through a centralized, typed configuration object or service. Never use `process.env` directly in domain logic.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 🕵️ Automatic Audit Logging (Mandatory)
|
|
116
|
+
|
|
117
|
+
Every "mutation" (CREATE, UPDATE, DELETE) MUST trigger an audit log entry.
|
|
118
|
+
- **Traceability:** Link every audit log to the active **Trace ID**.
|
|
119
|
+
- **State Capture:** For updates, capture both `previousState` and `newState`.
|
|
120
|
+
- **User Context:** Identify the `UserID` performing the action.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Kysely Standards & Migration Template
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// ✅ Correct: Type-safe query
|
|
128
|
+
const user = await db.selectFrom('users').where('id', '=', userId)
|
|
129
|
+
.select(['id', 'email', 'name']).executeTakeFirstOrThrow();
|
|
130
|
+
|
|
131
|
+
// Kysely Migration Template
|
|
132
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
133
|
+
await db.schema
|
|
134
|
+
.createTable("table_name")
|
|
135
|
+
.addColumn("id", "char(26)", (col) => col.primaryKey()) // ULID standard (26 characters)
|
|
136
|
+
.addColumn("created_at", "timestamptz", (col) =>
|
|
137
|
+
col.defaultTo(sql`now()`).notNull(),
|
|
138
|
+
)
|
|
139
|
+
.execute();
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 🚨 API CONTRACT WRITING REQUIREMENT (CRITICAL)
|
|
146
|
+
|
|
147
|
+
**`.enderun/docs/api/` MUST be updated after every new endpoint or change.**
|
|
148
|
+
|
|
149
|
+
### Document Template:
|
|
150
|
+
```markdown
|
|
151
|
+
### [METHOD] /api/[path]
|
|
152
|
+
|
|
153
|
+
- Description: What does this endpoint do?
|
|
154
|
+
- Auth: Required? Which role?
|
|
155
|
+
- Request Body / Query Params:
|
|
156
|
+
```typescript
|
|
157
|
+
// Type definition or example
|
|
158
|
+
```
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 🧩 Backend Capability Expansion
|
|
164
|
+
- **Contract-First Growth:** Each backend task should ask if it can also improve contract coverage, documentation, or validation logic.
|
|
165
|
+
- **Reusable Services:** When building business logic, define services that can be reused by future endpoints.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @database — Reference & Implementation Guide
|
|
2
|
+
|
|
3
|
+
This guide contains detailed database architectural patterns, engine-specific tuning, and seeding standards for Agent Enderun projects. Reference this file via `read_file` only when designing schemas, tuning performance, or managing complex migrations.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🏗️ Database Migration Standards (Mandatory)
|
|
8
|
+
- **Tooling:** Kysely migrations only.
|
|
9
|
+
- **Immutability:** Never modify an existing migration. Create a new one.
|
|
10
|
+
- **Rollback:** Always include a `down` function.
|
|
11
|
+
- **Naming:** `YYYYMMDD_action_description.ts`.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## ⚙️ Performance Tuning & Multi-Engine Guidelines
|
|
16
|
+
|
|
17
|
+
### 1. PostgreSQL Optimization
|
|
18
|
+
- Use **BRIN** indexes for large time-series data.
|
|
19
|
+
- Use **GIN** for JSONB and full-text search.
|
|
20
|
+
- Configure `shared_buffers` and `effective_cache_size` based on system RAM.
|
|
21
|
+
|
|
22
|
+
### 2. MySQL / MariaDB Optimization
|
|
23
|
+
- Tune `innodb_buffer_pool_size`.
|
|
24
|
+
- Use `EXPLAIN FORMAT=JSON` for detailed query plan analysis.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📊 Seeding Standards
|
|
29
|
+
- **Contract-Aware:** Seeds must match the Branded Types in the application.
|
|
30
|
+
- **Realistic Data:** Use Faker or similar libraries to generate non-mock, production-quality data.
|
|
31
|
+
- **Idempotency:** Seeding scripts should be runnable multiple times without duplication.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔍 Performance Audit
|
|
36
|
+
- Analyze `EXPLAIN ANALYZE` reports.
|
|
37
|
+
- Identify "Sequential Scans" on large tables and propose index coverage.
|
|
38
|
+
- Monitor connection pool saturation.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @devops — Infrastructure & Deployment Reference Guide
|
|
2
|
+
|
|
3
|
+
Detailed CI/CD pipeline designs, deployment strategies, and rollback protocols. Reference this file when designing workflows or troubleshooting deployments.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🏗️ CI/CD Pipeline Design (Standard)
|
|
8
|
+
|
|
9
|
+
Standard stages for every project:
|
|
10
|
+
1. **Lint & Type Check** — ESLint + TypeScript compiler.
|
|
11
|
+
2. **Unit Tests** — Vitest.
|
|
12
|
+
3. **Security Scan** — `security_audit_scan` tool.
|
|
13
|
+
4. **Build** — `tsc` + bundler.
|
|
14
|
+
5. **Health Check** — Post-deploy verification.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 🚀 Deployment Strategies
|
|
19
|
+
|
|
20
|
+
### 1. Blue-Green Deployment
|
|
21
|
+
- Preferred for stateful services.
|
|
22
|
+
- Keep old version on standby for 30 minutes.
|
|
23
|
+
|
|
24
|
+
### 2. Rolling Deployment
|
|
25
|
+
- Preferred for stateless services.
|
|
26
|
+
- Replace instances one by one with health checks.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🛡️ Monitoring & Telemetry (Standard)
|
|
31
|
+
- **Log Level:** `info/warn` in prod, `debug` in dev.
|
|
32
|
+
- **Alerting:** Trigger alerts on 5xx errors or >85% memory usage.
|
|
33
|
+
- **Key Metrics:** API latency, DB connection pool, CPU/Memory profiles.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🔄 Rollback Protocol (Mandatory)
|
|
38
|
+
Every deploy must have a documented rollback plan in `docs/`:
|
|
39
|
+
```markdown
|
|
40
|
+
- **Trigger:** Health failure or error spike.
|
|
41
|
+
- **Steps:** [numbered steps]
|
|
42
|
+
- **Time:** {N} minutes.
|
|
43
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @explorer — Research & Discovery Reference Guide
|
|
2
|
+
|
|
3
|
+
Standard procedures for codebase mapping, legacy system conversion, and architecture intelligence. Reference this file when performing deep research or onboarding new projects.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🔄 Legacy Conversion Algorithm (Standard)
|
|
8
|
+
|
|
9
|
+
1. **Architecture Mapping:** Use `analyze_dependencies` for coupling analysis.
|
|
10
|
+
2. **Gap Analysis:** Document structural deviations from `ENDERUN.md`.
|
|
11
|
+
3. **Bridge Building:** Map existing DTOs to a new app-local `types` directory.
|
|
12
|
+
4. **Refactor Blueprint:** Provide a plan for "Hot Spot" modules using Branded Types.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🔍 Research & Intelligence Standards
|
|
17
|
+
|
|
18
|
+
### 1. Common UI Mapping (CRITICAL)
|
|
19
|
+
Before frontend tasks, scan `apps/web/src/components/ui/` and list available components for @frontend.
|
|
20
|
+
|
|
21
|
+
### 2. Architecture Discovery
|
|
22
|
+
- Use `generate_dependency_graph` for module relationships.
|
|
23
|
+
- Use `analyze_database_schema` for Mermaid ER diagrams.
|
|
24
|
+
- Use `analyze_codebase_intelligence` for complexity analysis.
|
|
25
|
+
|
|
26
|
+
### 3. Impact Zone Analysis
|
|
27
|
+
Always identify the "Impact Zone" before suggesting modifications to avoid side effects.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 🧭 Agent Skill Development
|
|
32
|
+
- Capture recurring patterns and store them as actionable guidance.
|
|
33
|
+
- Track decisions that worked vs regressions to improve heuristics.
|
|
34
|
+
- Propose coaching notes for other agents when gaps are found.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @frontend — Reference & Implementation Guide
|
|
2
|
+
|
|
3
|
+
This guide contains detailed architectural patterns, UI standards, and code structures for Agent Enderun projects. Reference this file via `read_file` only when building new components, pages, or complex UI logic.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 📐 Responsive & Fluid Design Standards
|
|
8
|
+
|
|
9
|
+
- **Mobile-First (320px):** Always write base styles for mobile and use `stack` (vertical) as default.
|
|
10
|
+
- **Breakpoint Hygiene:** Use Panda CSS responsive objects (e.g., `sm`, `md`, `lg`).
|
|
11
|
+
- **Fluidity via Tokens:** Use `clamp()` or fluid spacing tokens for typography and gaps.
|
|
12
|
+
- **Grid Stability:** Prefer `grid` for complex layouts.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🏗️ Standard UI Component Patterns (Mandatory)
|
|
17
|
+
|
|
18
|
+
### 1. Button
|
|
19
|
+
- Variants: primary, secondary, danger, ghost.
|
|
20
|
+
- focus-ring and transition are mandatory.
|
|
21
|
+
|
|
22
|
+
### 2. Input
|
|
23
|
+
- Red focus ring for error state.
|
|
24
|
+
- Gray background when disabled.
|
|
25
|
+
|
|
26
|
+
### 3. Card
|
|
27
|
+
- Border + shadow-sm combination.
|
|
28
|
+
- Responsive internal spacing.
|
|
29
|
+
|
|
30
|
+
### 4. Modal
|
|
31
|
+
- Overlay + centered content.
|
|
32
|
+
- Standard close button.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## ⚡ Proactive Engineering (Mandatory)
|
|
37
|
+
- **Loading States:** Skeletons or spinners for all async operations.
|
|
38
|
+
- **Empty States:** Clear messaging for no data.
|
|
39
|
+
- **Error UI:** Graceful handling of backend errors.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 🔗 Hook-Based API Architecture (Mandatory)
|
|
44
|
+
|
|
45
|
+
### 1. useListPage
|
|
46
|
+
For list pages with pagination and search.
|
|
47
|
+
|
|
48
|
+
### 2. useDetailPage
|
|
49
|
+
For detail pages with fetch/update/delete.
|
|
50
|
+
|
|
51
|
+
### 3. useFormPage
|
|
52
|
+
For form state management and validation.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🎨 Theme & Semantic Design System
|
|
57
|
+
- Radius: `md (6px)`, `lg (8px)`, `xl (12px)`.
|
|
58
|
+
- Typography: Inter (default font), Outfit (for titles).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🧩 Frontend Capability Expansion
|
|
63
|
+
- **Design System Coverage:** Identify missing tokens.
|
|
64
|
+
- **A11y Growth:** Add keyboard support and contrast checks.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @git — Version Control Reference Guide
|
|
2
|
+
|
|
3
|
+
Detailed commit strategies, branching models, and repository health check procedures. Reference this file when performing major merges, releases, or cleaning up history.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛠️ Git Discipline Protocol
|
|
8
|
+
|
|
9
|
+
### 1. Commit Message Format
|
|
10
|
+
Every message MUST follow this pattern:
|
|
11
|
+
`[{{TRACE_ID}}] <type>(<scope>): <description>`
|
|
12
|
+
|
|
13
|
+
- **Types:**
|
|
14
|
+
- `feat`: New feature.
|
|
15
|
+
- `fix`: Bug fix.
|
|
16
|
+
- `docs`: Documentation only.
|
|
17
|
+
- `refactor`: Code change that neither fixes a bug nor adds a feature.
|
|
18
|
+
- `test`: Adding missing tests or correcting existing tests.
|
|
19
|
+
- `chore`: Updates to build process, dependencies, etc.
|
|
20
|
+
- `arch`: Architectural changes or contract updates.
|
|
21
|
+
|
|
22
|
+
### 2. Branching Strategy
|
|
23
|
+
- **Main/Master:** Production-ready code only.
|
|
24
|
+
- **Feature Branches:** `feat/{{TRACE_ID}}-description`
|
|
25
|
+
- **Fix Branches:** `fix/{{TRACE_ID}}-description`
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🚀 Standard Operating Procedure (SOP)
|
|
30
|
+
|
|
31
|
+
### Step 1: Repository Status & Health Audit
|
|
32
|
+
1. Run `git status`.
|
|
33
|
+
2. **Health Check (Mandatory):** Run `npx agent-enderun check` to verify compilation.
|
|
34
|
+
3. **Constitution Compliance:** Run `analyze_constitution_compliance` on staged files.
|
|
35
|
+
|
|
36
|
+
### Step 2: Atomic Committing
|
|
37
|
+
1. Stage files: `git add <files>`.
|
|
38
|
+
2. Verify Trace ID.
|
|
39
|
+
3. Use `generate_semantic_commit_message` for a structured message.
|
|
40
|
+
4. Commit: `git commit -m "[message]"`.
|
|
41
|
+
|
|
42
|
+
### Step 3: Phase Snapshots
|
|
43
|
+
At the end of a Phase:
|
|
44
|
+
1. Tag: `git tag -a v{{VERSION}}-phase{{X}} -m "Phase Completion Snapshot"`.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🧭 Git Skill Growth
|
|
49
|
+
- Identify missing release documentation or tags.
|
|
50
|
+
- Suggest precise commit scopes (`arch`, `docs`, `test`).
|
|
51
|
+
- Recommend cleanup for stale feature branches.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @manager — Governance & Orchestration Reference Guide
|
|
2
|
+
|
|
3
|
+
This guide contains detailed governance protocols, phase transition requirements, and conflict resolution strategies for Agent Enderun projects. Reference this file when planning architectures, managing multi-agent workflows, or auditing project progress.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 👑 BRAIN ORCHESTRATION (Memory-First)
|
|
8
|
+
- **Master SSOT:** Refer to `PROJECT_MEMORY.md` in every session.
|
|
9
|
+
- **Critical Decisions:** Check the `CRITICAL DECISIONS` table before any orchestration.
|
|
10
|
+
- **Procedural Continuity:** Ensure all assigned tasks mandate agents to follow existing code patterns.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🪖 v1.0 AGENT ARMY ORCHESTRATION HANDOFF PROTOCOL
|
|
15
|
+
1. Write the high-level plan + Trace ID into `PROJECT_MEMORY.md`.
|
|
16
|
+
2. Call `create_task_dag` with breakdown, domain tags, and priorities.
|
|
17
|
+
3. Use `assign_agent_to_task` (capability-aware assignment).
|
|
18
|
+
4. Send formal Hermes briefing: "Execute DAG for Trace {{traceId}}."
|
|
19
|
+
5. Monitor via `get_army_health_dashboard` and `read_agent_messages`.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🔁 AUTONOMOUS CONFLICT RESOLUTION PROTOCOL
|
|
24
|
+
1. **Intercept:** @manager intercepts failures (e.g., @quality rejection).
|
|
25
|
+
2. **Negotiate:** Instruct agents to negotiate via `send_agent_message`.
|
|
26
|
+
3. **Review:** @quality evaluates justifications.
|
|
27
|
+
4. **Escalate:** If negotiation fails 3 times, log "QA Deadlock" and ask the User.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Phase Gate Checklist (Summary)
|
|
32
|
+
|
|
33
|
+
### PHASE_0 → PHASE_1 (Scaffolding)
|
|
34
|
+
- [ ] `tech-stack.md` approved.
|
|
35
|
+
- [ ] Profile selected (Lightweight vs Full).
|
|
36
|
+
|
|
37
|
+
### PHASE_1 → PHASE_2 (Architecture)
|
|
38
|
+
- [ ] `shared-types` approved.
|
|
39
|
+
- [ ] `contract.version.json` created and hash verified.
|
|
40
|
+
|
|
41
|
+
### PHASE_2 → PHASE_3 (Implementation)
|
|
42
|
+
- [ ] Core features delivered with unit tests.
|
|
43
|
+
- [ ] Procedural Continuity verified.
|
|
44
|
+
|
|
45
|
+
### PHASE_3 → PHASE_4 (Quality)
|
|
46
|
+
- [ ] Integration tests passed with real DB.
|
|
47
|
+
- [ ] Zero Mock and Zero UI Library policies verified.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 🕵️ Governance & Audit Oversight
|
|
52
|
+
- **Branded Types Law:** Strictly enforce across all domain logic.
|
|
53
|
+
- **Domain Error Standard:** Ensure all agents use the standardized hierarchy.
|
|
54
|
+
- **Memory Audit:** Verify all agents performed end-of-turn memory updates.
|
|
55
|
+
- **Root Cause Analysis:** For rejections, update `lessons-learned.md`.
|