@defai.digital/automatosx 5.6.35 → 5.7.2

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 (106) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/README.md +44 -2
  3. package/dist/index.js +1129 -345
  4. package/examples/agents/.automatosx/abilities/accessibility.md +115 -0
  5. package/examples/agents/.automatosx/abilities/api-design.md +159 -0
  6. package/examples/agents/.automatosx/abilities/best-practices.md +102 -0
  7. package/examples/agents/.automatosx/abilities/caching-strategy.md +165 -0
  8. package/examples/agents/.automatosx/abilities/ci-cd.md +61 -0
  9. package/examples/agents/.automatosx/abilities/clean-code.md +398 -0
  10. package/examples/agents/.automatosx/abilities/code-generation.md +95 -0
  11. package/examples/agents/.automatosx/abilities/code-review.md +42 -0
  12. package/examples/agents/.automatosx/abilities/component-architecture.md +112 -0
  13. package/examples/agents/.automatosx/abilities/content-creation.md +97 -0
  14. package/examples/agents/.automatosx/abilities/data-modeling.md +171 -0
  15. package/examples/agents/.automatosx/abilities/data-validation.md +50 -0
  16. package/examples/agents/.automatosx/abilities/db-modeling.md +158 -0
  17. package/examples/agents/.automatosx/abilities/debugging.md +43 -0
  18. package/examples/agents/.automatosx/abilities/dependency-audit.md +60 -0
  19. package/examples/agents/.automatosx/abilities/design-patterns.md +437 -0
  20. package/examples/agents/.automatosx/abilities/design-system-implementation.md +126 -0
  21. package/examples/agents/.automatosx/abilities/documentation.md +54 -0
  22. package/examples/agents/.automatosx/abilities/error-analysis.md +107 -0
  23. package/examples/agents/.automatosx/abilities/etl-pipelines.md +44 -0
  24. package/examples/agents/.automatosx/abilities/feasibility-study.md +20 -0
  25. package/examples/agents/.automatosx/abilities/general-assistance.md +26 -0
  26. package/examples/agents/.automatosx/abilities/idea-evaluation.md +21 -0
  27. package/examples/agents/.automatosx/abilities/infra-as-code.md +57 -0
  28. package/examples/agents/.automatosx/abilities/job-orchestration.md +44 -0
  29. package/examples/agents/.automatosx/abilities/literature-review.md +19 -0
  30. package/examples/agents/.automatosx/abilities/logical-analysis.md +21 -0
  31. package/examples/agents/.automatosx/abilities/longform-report.md +25 -0
  32. package/examples/agents/.automatosx/abilities/mathematical-reasoning.md +170 -0
  33. package/examples/agents/.automatosx/abilities/mission-analysis.md +49 -0
  34. package/examples/agents/.automatosx/abilities/observability.md +61 -0
  35. package/examples/agents/.automatosx/abilities/orbital-mechanics.md +50 -0
  36. package/examples/agents/.automatosx/abilities/our-architecture-decisions.md +180 -0
  37. package/examples/agents/.automatosx/abilities/our-code-review-checklist.md +149 -0
  38. package/examples/agents/.automatosx/abilities/our-coding-standards.md +270 -0
  39. package/examples/agents/.automatosx/abilities/our-project-structure.md +183 -0
  40. package/examples/agents/.automatosx/abilities/performance-analysis.md +56 -0
  41. package/examples/agents/.automatosx/abilities/performance.md +80 -0
  42. package/examples/agents/.automatosx/abilities/problem-solving.md +50 -0
  43. package/examples/agents/.automatosx/abilities/propulsion-systems.md +50 -0
  44. package/examples/agents/.automatosx/abilities/quantum-algorithm-design.md +54 -0
  45. package/examples/agents/.automatosx/abilities/quantum-error-correction.md +56 -0
  46. package/examples/agents/.automatosx/abilities/quantum-frameworks-transpilation.md +53 -0
  47. package/examples/agents/.automatosx/abilities/quantum-noise-modeling.md +58 -0
  48. package/examples/agents/.automatosx/abilities/refactoring.md +223 -0
  49. package/examples/agents/.automatosx/abilities/release-strategy.md +58 -0
  50. package/examples/agents/.automatosx/abilities/risk-assessment.md +19 -0
  51. package/examples/agents/.automatosx/abilities/secrets-policy.md +61 -0
  52. package/examples/agents/.automatosx/abilities/secure-coding-review.md +51 -0
  53. package/examples/agents/.automatosx/abilities/security-audit.md +65 -0
  54. package/examples/agents/.automatosx/abilities/software-architecture.md +394 -0
  55. package/examples/agents/.automatosx/abilities/solid-principles.md +341 -0
  56. package/examples/agents/.automatosx/abilities/sql-optimization.md +84 -0
  57. package/examples/agents/.automatosx/abilities/state-management.md +96 -0
  58. package/examples/agents/.automatosx/abilities/task-planning.md +65 -0
  59. package/examples/agents/.automatosx/abilities/technical-writing.md +77 -0
  60. package/examples/agents/.automatosx/abilities/telemetry-diagnostics.md +51 -0
  61. package/examples/agents/.automatosx/abilities/testing.md +47 -0
  62. package/examples/agents/.automatosx/abilities/threat-modeling.md +49 -0
  63. package/examples/agents/.automatosx/abilities/troubleshooting.md +80 -0
  64. package/examples/agents/.automatosx/agents/aerospace-scientist.yaml +75 -0
  65. package/examples/agents/.automatosx/agents/backend.yaml +152 -0
  66. package/examples/agents/.automatosx/agents/ceo.yaml +63 -0
  67. package/examples/agents/.automatosx/agents/creative-marketer.yaml +121 -0
  68. package/examples/agents/.automatosx/agents/cto.yaml +72 -0
  69. package/examples/agents/.automatosx/agents/data-scientist.yaml +124 -0
  70. package/examples/agents/.automatosx/agents/data.yaml +77 -0
  71. package/examples/agents/.automatosx/agents/design.yaml +74 -0
  72. package/examples/agents/.automatosx/agents/devops.yaml +89 -0
  73. package/examples/agents/.automatosx/agents/frontend.yaml +139 -0
  74. package/examples/agents/.automatosx/agents/fullstack.yaml +151 -0
  75. package/examples/agents/.automatosx/agents/mobile.yaml +161 -0
  76. package/examples/agents/.automatosx/agents/product.yaml +72 -0
  77. package/examples/agents/.automatosx/agents/quality.yaml +79 -0
  78. package/examples/agents/.automatosx/agents/quantum-engineer.yaml +75 -0
  79. package/examples/agents/.automatosx/agents/researcher.yaml +71 -0
  80. package/examples/agents/.automatosx/agents/security.yaml +86 -0
  81. package/examples/agents/.automatosx/agents/stan.yaml +189 -0
  82. package/examples/agents/.automatosx/agents/writer.yaml +78 -0
  83. package/examples/agents/.automatosx/teams/business.yaml +56 -0
  84. package/examples/agents/.automatosx/teams/core.yaml +60 -0
  85. package/examples/agents/.automatosx/teams/design.yaml +58 -0
  86. package/examples/agents/.automatosx/teams/engineering.yaml +69 -0
  87. package/examples/agents/.automatosx/teams/research.yaml +56 -0
  88. package/examples/agents/.automatosx/templates/analyst.yaml +60 -0
  89. package/examples/agents/.automatosx/templates/assistant.yaml +48 -0
  90. package/examples/agents/.automatosx/templates/basic-agent.yaml +28 -0
  91. package/examples/agents/.automatosx/templates/code-reviewer.yaml +52 -0
  92. package/examples/agents/.automatosx/templates/debugger.yaml +63 -0
  93. package/examples/agents/.automatosx/templates/designer.yaml +69 -0
  94. package/examples/agents/.automatosx/templates/developer.yaml +60 -0
  95. package/examples/agents/.automatosx/templates/fullstack-developer.yaml +395 -0
  96. package/examples/agents/.automatosx/templates/qa-specialist.yaml +71 -0
  97. package/examples/agents/.claude/commands/ax-agent.md +37 -0
  98. package/examples/agents/.claude/commands/ax-clear.md +22 -0
  99. package/examples/agents/.claude/commands/ax-init.md +25 -0
  100. package/examples/agents/.claude/commands/ax-list.md +19 -0
  101. package/examples/agents/.claude/commands/ax-memory.md +25 -0
  102. package/examples/agents/.claude/commands/ax-status.md +24 -0
  103. package/examples/agents/.claude/commands/ax-update.md +28 -0
  104. package/examples/agents/.claude/mcp/automatosx.json +244 -0
  105. package/examples/agents/CLAUDE.md +262 -0
  106. package/package.json +1 -1
@@ -0,0 +1,180 @@
1
+ # Our Architecture Decisions - AutomatosX v5
2
+
3
+ > Key architectural decisions and rationale for AutomatosX
4
+
5
+ ## ADR-001: SQLite FTS5 Over Milvus
6
+
7
+ **Decision:** Use SQLite with FTS5 full-text search instead of Milvus
8
+
9
+ **Rationale:**
10
+
11
+ - v3.1 used Milvus (340MB bundle, complex setup)
12
+ - SQLite FTS5 offers < 1ms search performance
13
+ - Simple setup, no external services
14
+
15
+ **Impact:**
16
+
17
+ - ✅ Bundle: 340MB → 381KB (99.9% reduction)
18
+ - ✅ Fast text search (45ms → <1ms, 45x faster)
19
+ - ✅ No embedding costs (v4.11.0: removed vector search)
20
+ - ❌ Limited to single-node (acceptable for CLI tool)
21
+
22
+ ## ADR-002: ESM Over CommonJS
23
+
24
+ **Decision:** Use ES Modules (ESM) for entire codebase
25
+
26
+ **Rationale:**
27
+
28
+ - Node.js 20+ has first-class ESM support
29
+ - Better tree-shaking and bundle optimization
30
+ - Modern standards compliance
31
+
32
+ **Impact:**
33
+
34
+ - ✅ Better tree-shaking (smaller bundle)
35
+ - ✅ Future-proof
36
+ - ⚠️ Requires `.js` in imports (minor inconvenience)
37
+
38
+ ## ADR-003: TypeScript Strict Mode
39
+
40
+ **Decision:** Enable all strict TypeScript checks
41
+
42
+ **Configuration:**
43
+
44
+ ```json
45
+ {
46
+ "strict": true,
47
+ "noUncheckedIndexedAccess": true,
48
+ "noImplicitOverride": true,
49
+ "noFallthroughCasesInSwitch": true
50
+ }
51
+ ```
52
+
53
+ **Impact:**
54
+
55
+ - ✅ Fewer runtime errors
56
+ - ✅ Better IDE support
57
+ - ✅ Safer refactoring
58
+ - ⚠️ More initial development time (worth it)
59
+
60
+ ## ADR-004: Three-Layer Security Model
61
+
62
+ **Decision:** Implement path validation, workspace access control, and input sanitization
63
+
64
+ **Layers:**
65
+
66
+ 1. **Path Resolution:** All file access through PathResolver
67
+ 2. **Workspace Access Control:** Shared workspaces with path validation (v5.2+)
68
+ 3. **Input Validation:** Sanitize all user inputs
69
+
70
+ **Impact:**
71
+
72
+ - ✅ Prevents path traversal attacks
73
+ - ✅ Controlled workspace access with validation
74
+ - ✅ No privilege escalation
75
+ - ⚠️ Slightly more complex file operations
76
+
77
+ ## ADR-005: Profile + Abilities = Agent
78
+
79
+ **Decision:** Separate agent profile (YAML) from abilities (Markdown)
80
+
81
+ **Structure:**
82
+
83
+ - Profile: YAML with metadata, systemPrompt, abilities references
84
+ - Abilities: Markdown files with domain knowledge
85
+ - Agent = Profile + loaded Abilities
86
+
87
+ **Impact:**
88
+
89
+ - ✅ Reusable abilities across agents
90
+ - ✅ Easy to add new knowledge
91
+ - ✅ Clear separation of concerns
92
+ - ✅ User can customize both independently
93
+
94
+ ## ADR-006: Team-Based Configuration (v4.10.0+)
95
+
96
+ **Decision:** Agents inherit configuration from their team
97
+
98
+ **4 Built-in Teams:**
99
+
100
+ - **core:** Quality assurance (primary: claude)
101
+ - **engineering:** Software development (primary: codex)
102
+ - **business:** Product & planning (primary: gemini)
103
+ - **design:** Design & content (primary: gemini)
104
+
105
+ **Impact:**
106
+
107
+ - ✅ No configuration duplication
108
+ - ✅ Change provider for entire team at once
109
+ - ✅ Shared abilities automatically included
110
+ - ✅ Centralized orchestration settings
111
+
112
+ ## ADR-007: Lazy Loading for Performance
113
+
114
+ **Decision:** Defer expensive imports until needed
115
+
116
+ **Implementation:**
117
+
118
+ - Heavy modules use dynamic import: `await import('module')`
119
+ - Core modules use static imports
120
+ - LazyLoader utility for caching
121
+
122
+ **Impact:**
123
+
124
+ - ✅ Faster CLI startup (~200ms)
125
+ - ✅ Smaller initial memory footprint
126
+ - ✅ Pay for what you use
127
+
128
+ ## ADR-008: Vitest Over Jest
129
+
130
+ **Decision:** Use Vitest as testing framework
131
+
132
+ **Rationale:**
133
+
134
+ - Modern test runner with native ESM support
135
+ - Fast execution with watch mode
136
+ - Compatible with Vite ecosystem
137
+
138
+ **Impact:**
139
+
140
+ - ✅ Fast test execution (1,149 tests in ~10s)
141
+ - ✅ Native ESM support (no transform)
142
+ - ✅ Great developer experience
143
+
144
+ ## ADR-009: TTL Cache for Profiles
145
+
146
+ **Decision:** Cache loaded profiles with 5-minute TTL
147
+
148
+ **Configuration:**
149
+
150
+ - TTLCache with 5-minute TTL
151
+ - Max 20 entries (LRU eviction)
152
+ - Cleanup every 60 seconds
153
+
154
+ **Impact:**
155
+
156
+ - ✅ Faster repeated executions
157
+ - ✅ Reduced file I/O
158
+ - ✅ Automatic cache invalidation
159
+ - ⚠️ 5-minute delay for profile updates (acceptable)
160
+
161
+ ## ADR-010: Provider Router Pattern
162
+
163
+ **Decision:** Use Router to abstract provider selection
164
+
165
+ **Features:**
166
+
167
+ - Router manages provider selection
168
+ - Retry with exponential backoff
169
+ - Fallback to alternative providers
170
+
171
+ **Impact:**
172
+
173
+ - ✅ Provider flexibility
174
+ - ✅ Resilience to provider failures
175
+ - ✅ Easy to add new providers
176
+
177
+ ---
178
+
179
+ **Last Updated:** 2025-10-10
180
+ **For:** AutomatosX v5.0+
@@ -0,0 +1,149 @@
1
+ # Our Code Review Checklist - AutomatosX v5
2
+
3
+ > Code review checklist for AutomatosX team
4
+
5
+ ## Before Submitting PR
6
+
7
+ ### Code Quality
8
+
9
+ - [ ] **No `any` types** - All types explicit, use `unknown` if truly unknown
10
+ - [ ] **ESM imports** - All imports have `.js` extension
11
+ - [ ] **Function size** - Functions <50 lines, extract helpers if needed
12
+ - [ ] **Naming** - Clear, descriptive names (no abbreviations)
13
+ - [ ] **Comments** - JSDoc for public APIs, inline for complex logic
14
+
15
+ ### Error Handling
16
+
17
+ - [ ] **Custom errors** - Use AgentValidationError, PathError, etc.
18
+ - [ ] **Error context** - Include relevant context in error messages
19
+ - [ ] **Try-catch blocks** - Catch and re-throw with context
20
+ - [ ] **No silent failures** - All errors logged or thrown
21
+
22
+ ### Security
23
+
24
+ - [ ] **Path validation** - All file access through PathResolver or WorkspaceManager
25
+ - [ ] **Input sanitization** - User inputs sanitized before use
26
+ - [ ] **Workspace boundaries** - Writes only to automatosx/PRD or automatosx/tmp (v5.2+)
27
+ - [ ] **File size limits** - Check file sizes to prevent DoS
28
+ - [ ] **No hardcoded secrets** - Use environment variables
29
+
30
+ ### Testing
31
+
32
+ - [ ] **Tests added** - New features have tests (unit + integration)
33
+ - [ ] **Coverage maintained** - Overall ≥70%, core modules ≥85%
34
+ - [ ] **Tests pass** - All 1,149 tests passing
35
+ - [ ] **Edge cases** - Test edge cases and error scenarios
36
+
37
+ ### Performance
38
+
39
+ - [ ] **No bottlenecks** - Profile if adding expensive operations
40
+ - [ ] **Lazy loading** - Heavy deps use dynamic import
41
+ - [ ] **Caching** - Use TTLCache for expensive operations
42
+ - [ ] **Bundle size** - Check `dist/index.js` stays <250KB
43
+
44
+ ### Logging
45
+
46
+ - [ ] **Structured logging** - Use `logger.info/warn/error` with context
47
+ - [ ] **Log levels** - Appropriate log levels (debug/info/warn/error)
48
+ - [ ] **No console.log** - Use logger, not console.log
49
+
50
+ ### Git
51
+
52
+ - [ ] **Conventional commits** - Format: `type(scope): message`
53
+ - [ ] **Descriptive message** - Clear what and why
54
+ - [ ] **No large files** - No binaries or large files
55
+ - [ ] **No sensitive data** - No API keys, passwords, etc.
56
+
57
+ ## Reviewer Checklist
58
+
59
+ ### Code Review
60
+
61
+ - [ ] **Logic correctness** - Does the code do what it's supposed to?
62
+ - [ ] **Type safety** - Are all types correct and complete?
63
+ - [ ] **Error handling** - Are errors handled appropriately?
64
+ - [ ] **Security** - No security vulnerabilities introduced?
65
+
66
+ ### Architecture
67
+
68
+ - [ ] **Import hierarchy** - Follows layer architecture (types → utils → core → agents → cli)
69
+ - [ ] **Module boundaries** - No circular dependencies
70
+ - [ ] **Separation of concerns** - Each module has single responsibility
71
+
72
+ ### Testing
73
+
74
+ - [ ] **Test quality** - Tests are meaningful and comprehensive
75
+ - [ ] **Test coverage** - Coverage meets targets
76
+ - [ ] **Mock providers** - Tests use AUTOMATOSX_MOCK_PROVIDERS=true
77
+
78
+ ### Documentation
79
+
80
+ - [ ] **JSDoc complete** - Public APIs have JSDoc
81
+ - [ ] **README updated** - If adding features, update README
82
+ - [ ] **CHANGELOG updated** - Add entry to CHANGELOG.md
83
+
84
+ ### Performance & Size
85
+
86
+ - [ ] **No new large deps** - Check package.json for new dependencies
87
+ - [ ] **Bundle size** - Run `npm run build` and check dist/index.js size
88
+ - [ ] **Startup time** - CLI startup time reasonable
89
+
90
+ ## Common Patterns
91
+
92
+ ### Type Safety
93
+
94
+ ```typescript
95
+ // ❌ Avoid
96
+ const data: any = loadData();
97
+
98
+ // ✅ Prefer
99
+ const data: ProfileData = loadProfile(name);
100
+ ```
101
+
102
+ ### Error Handling
103
+
104
+ ```typescript
105
+ // ❌ Avoid: Silent failure
106
+ try {
107
+ await task();
108
+ } catch (e) { }
109
+
110
+ // ✅ Prefer: Log and re-throw
111
+ try {
112
+ await task();
113
+ } catch (error) {
114
+ logger.error('Task failed', {
115
+ task: taskName,
116
+ error: (error as Error).message
117
+ });
118
+ throw error;
119
+ }
120
+ ```
121
+
122
+ ### Security
123
+
124
+ ```typescript
125
+ // ❌ Avoid: Path traversal risk
126
+ const path = join(root, userInput);
127
+
128
+ // ✅ Prefer: Validated path
129
+ const resolver = new PathResolver({ projectRoot: root });
130
+ const path = await resolver.resolve(userInput);
131
+ ```
132
+
133
+ ### Logging
134
+
135
+ ```typescript
136
+ // ❌ Avoid
137
+ console.log('Profile loaded');
138
+
139
+ // ✅ Prefer
140
+ logger.info('Profile loaded', {
141
+ name: profileName,
142
+ path: profilePath
143
+ });
144
+ ```
145
+
146
+ ---
147
+
148
+ **Last Updated:** 2025-10-11
149
+ **For:** AutomatosX v5.2+
@@ -0,0 +1,270 @@
1
+ # Our Coding Standards - AutomatosX v5
2
+
3
+ > Project-specific coding standards for AutomatosX
4
+
5
+ ## TypeScript Standards
6
+
7
+ **Strict mode enabled:**
8
+
9
+ ```json
10
+ {
11
+ "strict": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "noImplicitOverride": true,
14
+ "noFallthroughCasesInSwitch": true
15
+ }
16
+ ```
17
+
18
+ **Type annotations:**
19
+
20
+ ```typescript
21
+ // ✅ Good: Explicit types for public APIs
22
+ export function loadProfile(name: string): Promise<AgentProfile> { }
23
+
24
+ // ❌ Bad: Any types
25
+ function process(data: any) { } // Never use any!
26
+ ```
27
+
28
+ **Error handling:**
29
+
30
+ ```typescript
31
+ // ✅ Good: Typed errors from utils/errors.ts
32
+ import { AgentValidationError, PathError } from '../utils/errors.js';
33
+
34
+ if (!profile.name) {
35
+ throw new AgentValidationError('Missing required field: name');
36
+ }
37
+
38
+ // Include error context
39
+ try {
40
+ await executeTask();
41
+ } catch (error) {
42
+ logger.error('Task execution failed', {
43
+ task: taskName,
44
+ agent: agentName,
45
+ error: (error as Error).message
46
+ });
47
+ throw error;
48
+ }
49
+ ```
50
+
51
+ **Module system (ESM with .js extensions):**
52
+
53
+ ```typescript
54
+ // ✅ Good: .js extension in imports (required for ESM)
55
+ import { PathResolver } from '../core/path-resolver.js';
56
+ import type { AgentProfile } from '../types/agent.js';
57
+
58
+ // ❌ Bad: No extension
59
+ import { PathResolver } from '../core/path-resolver';
60
+ ```
61
+
62
+ ## Code Quality Standards
63
+
64
+ **Function size (<50 lines):**
65
+
66
+ ```typescript
67
+ // ✅ Good: Small, focused function
68
+ private buildPrompt(context: ExecutionContext): string {
69
+ let prompt = '';
70
+ if (context.abilities) {
71
+ prompt += `# Your Abilities\n\n${context.abilities}\n\n`;
72
+ }
73
+ if (context.agent.stages) {
74
+ prompt += this.buildStagesSection(context.agent.stages);
75
+ }
76
+ prompt += `# Task\n\n${context.task}`;
77
+ return prompt;
78
+ }
79
+ ```
80
+
81
+ **Naming conventions:**
82
+
83
+ ```typescript
84
+ // ✅ Good: Descriptive names
85
+ const profilePath = join(profilesDir, `${name}.yaml`);
86
+ async function resolveAgentName(input: string): Promise<string> { }
87
+
88
+ // ✅ Good: PascalCase for classes
89
+ export class PathResolver { }
90
+ export class MemoryManager { }
91
+
92
+ // ❌ Bad: Abbreviations or vague names
93
+ const p = join(dir, `${n}.yaml`);
94
+ export class PM { }
95
+ ```
96
+
97
+ **JSDoc for public APIs:**
98
+
99
+ ```typescript
100
+ /**
101
+ * Load agent profile from YAML file
102
+ *
103
+ * @param name - Agent name (e.g., "backend", "quality")
104
+ * @returns Validated AgentProfile
105
+ * @throws AgentNotFoundError if profile doesn't exist
106
+ * @throws AgentValidationError if profile is invalid
107
+ */
108
+ async loadProfile(name: string): Promise<AgentProfile> { }
109
+ ```
110
+
111
+ ## Security Standards
112
+
113
+ **Always use PathResolver:**
114
+
115
+ ```typescript
116
+ // ✅ Good: Use PathResolver for all file access
117
+ import { PathResolver } from '../core/path-resolver.js';
118
+
119
+ const resolver = new PathResolver({ projectRoot });
120
+ const safePath = await resolver.resolve(userInput);
121
+
122
+ // ❌ Bad: Direct path manipulation
123
+ const path = join(projectRoot, userInput); // Unsafe!
124
+ ```
125
+
126
+ **Input sanitization:**
127
+
128
+ ```typescript
129
+ // ✅ Good: Sanitize before using in file system
130
+ const agentDirName = agentName
131
+ .replace(/[^a-zA-Z0-9-]/g, '-')
132
+ .toLowerCase();
133
+
134
+ // ✅ Good: File size limits to prevent DoS
135
+ if (content.length > 100 * 1024) {
136
+ throw new AgentValidationError('Profile file too large (max 100KB)');
137
+ }
138
+ ```
139
+
140
+ **Restrictive permissions:**
141
+
142
+ ```typescript
143
+ // ✅ Good: Restrict workspace permissions (Unix)
144
+ if (process.platform !== 'win32') {
145
+ await chmod(agentWorkspace, 0o700); // Owner only
146
+ }
147
+ ```
148
+
149
+ ## Testing Standards
150
+
151
+ **Structure with Vitest:**
152
+
153
+ ```typescript
154
+ import { describe, it, expect, beforeEach } from 'vitest';
155
+
156
+ describe('PathResolver', () => {
157
+ let resolver: PathResolver;
158
+
159
+ beforeEach(() => {
160
+ resolver = new PathResolver({ projectRoot: '/test' });
161
+ });
162
+
163
+ it('should resolve relative paths', async () => {
164
+ const result = await resolver.resolve('./file.txt');
165
+ expect(result).toBe('/test/file.txt');
166
+ });
167
+
168
+ it('should reject path traversal', async () => {
169
+ await expect(
170
+ resolver.resolve('../../../etc/passwd')
171
+ ).rejects.toThrow(PathError);
172
+ });
173
+ });
174
+ ```
175
+
176
+ **Coverage targets:**
177
+
178
+ - Overall: 70%+ (currently 85%)
179
+ - Core modules: 85%+
180
+ - CLI commands: 70%+
181
+ - Utils: 90%+
182
+
183
+ ## Logging Standards
184
+
185
+ **Use structured logging:**
186
+
187
+ ```typescript
188
+ import { logger } from '../utils/logger.js';
189
+
190
+ // ✅ Good: Structured logging with context
191
+ logger.info('Profile loaded', {
192
+ name: profileName,
193
+ path: profilePath
194
+ });
195
+
196
+ logger.error('Execution failed', {
197
+ agent: agentName,
198
+ task: taskSummary,
199
+ error: (error as Error).message
200
+ });
201
+
202
+ // ❌ Bad: Console.log
203
+ console.log('Profile loaded');
204
+ ```
205
+
206
+ **Log levels:**
207
+
208
+ - **debug:** Development details
209
+ - **info:** Normal operations
210
+ - **warn:** Recoverable issues
211
+ - **error:** Failures requiring attention
212
+
213
+ ## Performance Standards
214
+
215
+ **Lazy loading:**
216
+
217
+ ```typescript
218
+ // ✅ Good: Lazy load heavy dependencies
219
+ async executeTask() {
220
+ const { spawn } = await import('child_process');
221
+ // ...
222
+ }
223
+ ```
224
+
225
+ **Caching:**
226
+
227
+ ```typescript
228
+ // ✅ Good: Cache profiles with TTL
229
+ this.cache = new TTLCache<AgentProfile>({
230
+ maxEntries: 20,
231
+ ttl: 300000, // 5 minutes
232
+ cleanupInterval: 60000
233
+ });
234
+ ```
235
+
236
+ **Bundle size target:** <250KB (currently 381KB)
237
+
238
+ ## Git Commit Standards
239
+
240
+ **Conventional Commits format:** `type(scope): message`
241
+
242
+ ```bash
243
+ # Types
244
+ feat(agents): add stage injection to executor
245
+ fix(memory): resolve vector search timeout
246
+ docs(readme): update installation instructions
247
+ test(router): add retry logic tests
248
+ refactor(cli): simplify command parsing
249
+ perf(cache): optimize TTL cleanup interval
250
+ ```
251
+
252
+ **Commit message structure:**
253
+
254
+ ```bash
255
+ # ✅ Good: Clear, specific
256
+ feat(stages): inject workflow stages into prompt
257
+
258
+ - Add Stage and Personality interfaces to types
259
+ - Update ProfileLoader to parse stages from YAML
260
+ - Modify Executor to include stages in prompt
261
+
262
+ # ❌ Bad: Vague
263
+ fix: bug fix
264
+ update: changes
265
+ ```
266
+
267
+ ---
268
+
269
+ **Last Updated:** 2025-10-10
270
+ **For:** AutomatosX v5.0+