telos-framework 0.1.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.
@@ -0,0 +1,73 @@
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+
4
+ async function consolidateAgents(agentsDir, outputPath) {
5
+ let content = `# Telos Multi-Agent Collective
6
+
7
+ **Generated**: ${new Date().toISOString()}
8
+
9
+ This document consolidates all 9 agent definitions for the Telos framework. Each agent operates at a specific ontological level in Boulding's hierarchy.
10
+
11
+ ---
12
+
13
+ `;
14
+
15
+ const agentFiles = [
16
+ 'l9-telos-guardian.md',
17
+ 'l8-market-analyst.md',
18
+ 'l7-insight-synthesizer.md',
19
+ 'l6-ux-simulator.md',
20
+ 'l5-journey-validator.md',
21
+ 'l4-integration-contractor.md',
22
+ 'l3-component-architect.md',
23
+ 'l2-function-author.md',
24
+ 'l1-syntax-linter.md'
25
+ ];
26
+
27
+ for (const filename of agentFiles) {
28
+ const filePath = path.join(agentsDir, filename);
29
+
30
+ try {
31
+ const agentContent = await fs.readFile(filePath, 'utf8');
32
+ content += agentContent + '\n\n---\n\n';
33
+ } catch (error) {
34
+ content += `# ${filename}\n\n*Agent definition not yet generated*\n\n---\n\n`;
35
+ }
36
+ }
37
+
38
+ content += `## Using the Agents
39
+
40
+ These agents work together as an orchestrated collective managed by Logos. You typically won't invoke individual agents directly—instead, Logos routes work to the appropriate level based on the task.
41
+
42
+ ### Agent Hierarchy
43
+
44
+ \`\`\`
45
+ L9 (Strategic) ← Telos-Guardian
46
+ L8 (Business) ← Market-Analyst
47
+ L7 (Insight) ← Insight-Synthesizer
48
+ L6 (UX) ← UX-Simulator
49
+ L5 (Journey) ← Journey-Validator
50
+ L4 (API) ← Integration-Contractor
51
+ L3 (Component) ← Component-Architect
52
+ L2 (Function) ← Function-Author
53
+ L1 (Syntax) ← Syntax-Linter
54
+ \`\`\`
55
+
56
+ ### Workflow
57
+
58
+ 1. **Request** enters at L9 (Telos validation)
59
+ 2. **Decomposition** cascades L9→L1
60
+ 3. **Implementation** occurs at appropriate levels
61
+ 4. **Validation** cascades L1→L9
62
+ 5. **Approval** from L9 Telos-Guardian
63
+
64
+ See LOGOS.md for orchestration details.
65
+ `;
66
+
67
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
68
+ await fs.writeFile(outputPath, content, 'utf8');
69
+
70
+ return outputPath;
71
+ }
72
+
73
+ module.exports = { consolidateAgents };
@@ -0,0 +1,196 @@
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+
4
+ async function generateAllAgents(hierarchy, levelTools, outputDir) {
5
+ const agents = [];
6
+
7
+ agents.push(await generateAgent('L3', hierarchy.L3, levelTools.L3.tools, outputDir, {
8
+ role: 'Component Architect',
9
+ focus: 'Component design and composition'
10
+ }));
11
+
12
+ agents.push(await generateAgent('L4', hierarchy.L4, levelTools.L4.tools, outputDir, {
13
+ role: 'Integration Contractor',
14
+ focus: 'API contracts and service boundaries'
15
+ }));
16
+
17
+ agents.push(await generateAgent('L5', hierarchy.L5, levelTools.L5.tools, outputDir, {
18
+ role: 'Journey Validator',
19
+ focus: 'End-to-end workflows and integration testing'
20
+ }));
21
+
22
+ agents.push(await generateAgent('L6', hierarchy.L6, levelTools.L6.tools, outputDir, {
23
+ role: 'UX Simulator',
24
+ focus: 'User experience and accessibility'
25
+ }));
26
+
27
+ agents.push(await generateAgent('L7', hierarchy.L7, levelTools.L7.tools, outputDir, {
28
+ role: 'Insight Synthesizer',
29
+ focus: 'User behavior and feedback analysis'
30
+ }));
31
+
32
+ agents.push(await generateAgent('L8', hierarchy.L8, levelTools.L8.tools, outputDir, {
33
+ role: 'Market Analyst',
34
+ focus: 'Business metrics and KPIs'
35
+ }));
36
+
37
+ return agents;
38
+ }
39
+
40
+ async function generateAgent(level, hierarchyData, tools, outputDir, meta) {
41
+ const toolsList = tools.length > 0
42
+ ? tools.map(t => `- **${t.name}** (${t.category}): ${t.capability}`).join('\n')
43
+ : `- *No specific tools detected for ${level}*`;
44
+
45
+ const content = `# ${level}: ${hierarchyData.name}
46
+
47
+ **Role**: ${meta.role}
48
+
49
+ ## Your Mandate
50
+
51
+ You are the ${hierarchyData.name}, responsible for ${meta.focus}. Your purpose:
52
+
53
+ > **${hierarchyData.purpose}**
54
+
55
+ This serves the ultimate Telos through its contribution to the overall system hierarchy.
56
+
57
+ ## Your Responsibilities
58
+
59
+ ${getResponsibilities(level)}
60
+
61
+ ## Available Tools
62
+
63
+ ${toolsList}
64
+
65
+ ## When You Are Invoked
66
+
67
+ ${getInvocationTriggers(level)}
68
+
69
+ ## Communication Protocol
70
+
71
+ ### Input Format
72
+ \`\`\`
73
+ ${level.toUpperCase()} REQUEST
74
+ Context: [what needs to be done]
75
+ Serves: [higher-level purpose]
76
+ REQUEST: [specific action]
77
+ \`\`\`
78
+
79
+ ### Output Format
80
+ \`\`\`
81
+ ${level.toUpperCase()} RESPONSE
82
+ Result: [what was accomplished]
83
+ Validation: [how it was verified]
84
+ Status: [PASS | FAIL]
85
+ Serves: [confirms higher-level contribution]
86
+ \`\`\`
87
+
88
+ ## Integration with Other Levels
89
+
90
+ ${getIntegration(level)}
91
+
92
+ ## Remember
93
+
94
+ Your work at ${level} is essential to the hierarchy. Maintain quality and alignment with the purpose: "${hierarchyData.purpose}"
95
+ `;
96
+
97
+ const filename = `${level.toLowerCase()}-${hierarchyData.name.toLowerCase().replace(/\s+/g, '-')}.md`;
98
+ const outputPath = path.join(outputDir, filename);
99
+
100
+ await fs.mkdir(outputDir, { recursive: true });
101
+ await fs.writeFile(outputPath, content, 'utf8');
102
+
103
+ return outputPath;
104
+ }
105
+
106
+ function getResponsibilities(level) {
107
+ const responsibilities = {
108
+ L3: `1. **Component Design**: Create modular, reusable components
109
+ 2. **Composition Patterns**: Establish how components interact
110
+ 3. **State Management**: Define component-level state
111
+ 4. **Component Testing**: Test components in isolation`,
112
+ L4: `1. **API Contract Definition**: Specify service interfaces
113
+ 2. **Integration Points**: Define system boundaries
114
+ 3. **Contract Testing**: Validate API contracts
115
+ 4. **Dependency Management**: Manage service dependencies`,
116
+ L5: `1. **End-to-End Testing**: Validate complete user journeys
117
+ 2. **Integration Validation**: Ensure services work together
118
+ 3. **Workflow Testing**: Test multi-step processes
119
+ 4. **Performance Testing**: Validate system-wide performance`,
120
+ L6: `1. **UX Design Validation**: Ensure usability standards
121
+ 2. **Accessibility**: WCAG compliance and keyboard navigation
122
+ 3. **User Journey Mapping**: Optimize user flows
123
+ 4. **Visual Consistency**: Maintain design system coherence`,
124
+ L7: `1. **Behavior Analysis**: Understand user patterns
125
+ 2. **Feedback Synthesis**: Process user feedback
126
+ 3. **A/B Testing**: Experiment with variations
127
+ 4. **Insight Reporting**: Communicate findings to L8`,
128
+ L8: `1. **Metrics Definition**: Establish KPIs and success criteria
129
+ 2. **Business Analysis**: Evaluate business impact
130
+ 3. **ROI Tracking**: Monitor return on investment
131
+ 4. **Strategic Reporting**: Communicate to L9 Telos-Guardian`
132
+ };
133
+ return responsibilities[level] || '';
134
+ }
135
+
136
+ function getInvocationTriggers(level) {
137
+ const triggers = {
138
+ L3: `- Implementing new UI/business components
139
+ - Refactoring component architecture
140
+ - Component integration issues
141
+ - State management decisions`,
142
+ L4: `- Defining new service contracts
143
+ - API versioning decisions
144
+ - Service integration points
145
+ - Contract breaking changes`,
146
+ L5: `- New feature complete flows
147
+ - Integration testing needs
148
+ - Performance validation
149
+ - Release readiness checks`,
150
+ L6: `- New user interfaces
151
+ - Accessibility audits
152
+ - User journey optimization
153
+ - Design system updates`,
154
+ L7: `- Analyzing user behavior data
155
+ - Processing user feedback
156
+ - A/B test evaluation
157
+ - Feature usage analysis`,
158
+ L8: `- Quarterly business reviews
159
+ - Feature prioritization
160
+ - ROI analysis
161
+ - Strategic planning sessions`
162
+ };
163
+ return triggers[level] || '';
164
+ }
165
+
166
+ function getIntegration(level) {
167
+ const integration = {
168
+ L3: `- Receives specs from **L4 Integration-Contractor**
169
+ - Uses functions from **L2 Function-Author**
170
+ - Validated by **L1 Syntax-Linter**
171
+ - Feeds into **L4** contracts`,
172
+ L4: `- Receives requirements from **L5 Journey-Validator**
173
+ - Composed of **L3** components
174
+ - Defines contracts for **L3**
175
+ - Reports to **L5** on integration status`,
176
+ L5: `- Receives journeys from **L6 UX-Simulator**
177
+ - Validates **L4** integrations
178
+ - Tests **L3** component interactions
179
+ - Reports to **L6** on workflow quality`,
180
+ L6: `- Receives insights from **L7 Insight-Synthesizer**
181
+ - Defines journeys for **L5**
182
+ - Guides **L3** component design
183
+ - Reports to **L7** on UX metrics`,
184
+ L7: `- Receives goals from **L8 Market-Analyst**
185
+ - Analyzes **L6** user interactions
186
+ - Informs **L6** design decisions
187
+ - Reports to **L8** on user insights`,
188
+ L8: `- Receives strategy from **L9 Telos-Guardian**
189
+ - Defines success metrics for **L7**
190
+ - Evaluates **L7** insights against business goals
191
+ - Reports to **L9** on business alignment`
192
+ };
193
+ return integration[level] || '';
194
+ }
195
+
196
+ module.exports = { generateAllAgents };
@@ -0,0 +1,192 @@
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+
4
+ async function generateLogosMd(outputPath) {
5
+ const content = `# Logos: Rational Orchestrator
6
+
7
+ **Role**: Central orchestration engine for the Telos multi-agent collective
8
+
9
+ ## What is Logos?
10
+
11
+ Logos (Greek: λόγος) means "reason," "discourse," or "rational principle." In the Telos framework, Logos is the orchestrator that maintains coherence across all 9 agent levels through rational dialogue and systematic decomposition.
12
+
13
+ ## Core Responsibilities
14
+
15
+ 1. **Top-Down Decomposition**: Break strategic goals (L9) into tactical implementations (L1)
16
+ 2. **Bottom-Up Validation**: Verify implementations (L1) align with strategic purpose (L9)
17
+ 3. **Middle-Out Reconciliation**: Resolve conflicts between levels by appealing to higher purpose
18
+ 4. **State Management**: Track development state, active agents, and validation cascades
19
+
20
+ ## Orchestration Flows
21
+
22
+ ### Flow 1: Top-Down Decomposition
23
+
24
+ \`\`\`
25
+ User Request → L9 Telos-Guardian
26
+ ↓ (Does this serve our Telos?)
27
+ L8 Market-Analyst (What business value?)
28
+
29
+ L7 Insight-Synthesizer (What user insights needed?)
30
+
31
+ L6 UX-Simulator (What UX required?)
32
+
33
+ L5 Journey-Validator (What workflows?)
34
+
35
+ L4 Integration-Contractor (What APIs?)
36
+
37
+ L3 Component-Architect (What components?)
38
+
39
+ L2 Function-Author (What functions?)
40
+
41
+ L1 Syntax-Linter (Code quality check)
42
+
43
+ Implementation
44
+ \`\`\`
45
+
46
+ ### Flow 2: Bottom-Up Validation
47
+
48
+ \`\`\`
49
+ Implementation Complete
50
+
51
+ L1 Syntax-Linter validates structure
52
+ ↓ (PASS → continue)
53
+ L2 Function-Author validates logic & tests
54
+ ↓ (PASS → continue)
55
+ L3 Component-Architect validates composition
56
+ ↓ (PASS → continue)
57
+ L4 Integration-Contractor validates contracts
58
+ ↓ (PASS → continue)
59
+ L5 Journey-Validator validates workflows
60
+ ↓ (PASS → continue)
61
+ L6 UX-Simulator validates UX
62
+ ↓ (PASS → continue)
63
+ L7 Insight-Synthesizer validates insights
64
+ ↓ (PASS → continue)
65
+ L8 Market-Analyst validates business value
66
+ ↓ (PASS → continue)
67
+ L9 Telos-Guardian validates Telos alignment
68
+
69
+ APPROVED ✓
70
+ \`\`\`
71
+
72
+ ### Flow 3: Middle-Out Reconciliation
73
+
74
+ When conflicts arise between levels:
75
+
76
+ \`\`\`
77
+ Conflict Detected (e.g., L3 vs L5)
78
+
79
+ Logos identifies higher authority (L4)
80
+
81
+ L4 Integration-Contractor reconciles
82
+
83
+ If unresolved, escalate to L6
84
+
85
+ Continue up hierarchy until resolved
86
+
87
+ Resolution cascades back down
88
+ \`\`\`
89
+
90
+ ## State Management
91
+
92
+ Logos maintains state in \`.telos/state.json\`:
93
+
94
+ \`\`\`json
95
+ {
96
+ "activeAgents": [
97
+ { "level": "L2", "task": "implement-auth", "status": "in-progress" }
98
+ ],
99
+ "decompositionStack": [
100
+ { "level": "L9", "spec": "...", "children": [...] }
101
+ ],
102
+ "validationQueue": [
103
+ { "level": "L1", "validation": {...}, "status": "pending" }
104
+ ],
105
+ "conflicts": [
106
+ { "levelA": "L3", "levelB": "L5", "resolved": false }
107
+ ]
108
+ }
109
+ \`\`\`
110
+
111
+ ## Agent Delegation Protocol
112
+
113
+ Logos delegates to agents using structured messages:
114
+
115
+ ### Request Format
116
+ \`\`\`
117
+ AGENT REQUEST
118
+ Level: [L1-L9]
119
+ Type: [decompose | validate | reconcile | implement]
120
+ Context: [relevant information]
121
+ Parent Purpose: [higher-level goal this serves]
122
+ REQUEST: [specific action]
123
+ \`\`\`
124
+
125
+ ### Response Format
126
+ \`\`\`
127
+ AGENT RESPONSE
128
+ Level: [L1-L9]
129
+ Status: [PASS | FAIL | CONDITIONAL]
130
+ Result: [what was accomplished]
131
+ Validation: [how it was verified]
132
+ Serves: [confirms contribution to higher purpose]
133
+ Issues: [if any]
134
+ \`\`\`
135
+
136
+ ## Integration with OpenSpec
137
+
138
+ Logos creates and manages OpenSpec proposals for all changes:
139
+
140
+ 1. **Proposal Creation**: L9 validates alignment, creates OpenSpec proposal
141
+ 2. **Task Generation**: Logos decomposes into tasks (L9→L1)
142
+ 3. **Implementation**: Agents work through tasks
143
+ 4. **Validation**: Bottom-up verification
144
+ 5. **Archive**: Completed proposals archived with lineage
145
+
146
+ ## Session Management
147
+
148
+ Each development session:
149
+ - Gets unique session ID
150
+ - Tracks all agent invocations
151
+ - Maintains decomposition history
152
+ - Preserves validation results
153
+ - Enables resumption after interruption
154
+
155
+ ## Usage
156
+
157
+ Logos is invoked automatically by the Telos system when:
158
+ - User creates new feature request
159
+ - Code changes are proposed
160
+ - Conflicts arise between agents
161
+ - Validation is required
162
+
163
+ You typically don't invoke Logos directly—agents and the system do this for you.
164
+
165
+ ## Philosophy
166
+
167
+ Logos embodies the principle that **rational discourse** maintains coherence in complex systems. By enforcing:
168
+
169
+ - Top-down purpose alignment
170
+ - Bottom-up integrity verification
171
+ - Middle-out conflict resolution
172
+
173
+ ...Logos ensures every line of code serves the ultimate Telos while maintaining implementation quality at every level.
174
+
175
+ ## Remember
176
+
177
+ Logos is not a command-and-control system. It's a **dialogue facilitator** that:
178
+ - Asks the right questions at the right levels
179
+ - Routes information to appropriate agents
180
+ - Maintains traceability from Telos to implementation
181
+ - Enables emergence through structured interaction
182
+
183
+ Trust the process. Trust the hierarchy. Trust Logos.
184
+ `;
185
+
186
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
187
+ await fs.writeFile(outputPath, content, 'utf8');
188
+
189
+ return outputPath;
190
+ }
191
+
192
+ module.exports = { generateLogosMd };
@@ -0,0 +1,121 @@
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+
4
+ async function generateTelosMd(hierarchy, outputPath) {
5
+ const content = `# Project Telos
6
+
7
+ **Generated**: ${new Date().toISOString()}
8
+
9
+ ## Ultimate Purpose (L9)
10
+
11
+ ${hierarchy.L9.purpose}
12
+
13
+ **Beneficiaries**: ${hierarchy.L9.beneficiaries}
14
+
15
+ **Success Impact**: ${hierarchy.L9.impact}
16
+
17
+ **Constraints**: ${hierarchy.L9.constraints}
18
+
19
+ ---
20
+
21
+ ## Purpose Hierarchy
22
+
23
+ The 9-level decomposition from ultimate purpose to implementation:
24
+
25
+ ### L9: ${hierarchy.L9.name} - Transcendent Purpose
26
+
27
+ **Purpose**: ${hierarchy.L9.purpose}
28
+
29
+ ${hierarchy.L9.description}
30
+
31
+ ### L8: ${hierarchy.L8.name} - Business/Social Value
32
+
33
+ **Purpose**: ${hierarchy.L8.purpose}
34
+
35
+ ${hierarchy.L8.description}
36
+
37
+ **Serves**: L9 Telos
38
+
39
+ ### L7: ${hierarchy.L7.name} - User Insight
40
+
41
+ **Purpose**: ${hierarchy.L7.purpose}
42
+
43
+ ${hierarchy.L7.description}
44
+
45
+ **Serves**: L8 Business Value
46
+
47
+ ### L6: ${hierarchy.L6.name} - User Experience
48
+
49
+ **Purpose**: ${hierarchy.L6.purpose}
50
+
51
+ ${hierarchy.L6.description}
52
+
53
+ **Serves**: L7 User Insight
54
+
55
+ ### L5: ${hierarchy.L5.name} - System Integration
56
+
57
+ **Purpose**: ${hierarchy.L5.purpose}
58
+
59
+ ${hierarchy.L5.description}
60
+
61
+ **Serves**: L6 User Experience
62
+
63
+ ### L4: ${hierarchy.L4.name} - API Contracts
64
+
65
+ **Purpose**: ${hierarchy.L4.purpose}
66
+
67
+ ${hierarchy.L4.description}
68
+
69
+ **Serves**: L5 System Integration
70
+
71
+ ### L3: ${hierarchy.L3.name} - Component Design
72
+
73
+ **Purpose**: ${hierarchy.L3.purpose}
74
+
75
+ ${hierarchy.L3.description}
76
+
77
+ **Serves**: L4 API Contracts
78
+
79
+ ### L2: ${hierarchy.L2.name} - Function Logic
80
+
81
+ **Purpose**: ${hierarchy.L2.purpose}
82
+
83
+ ${hierarchy.L2.description}
84
+
85
+ **Serves**: L3 Component Design
86
+
87
+ ### L1: ${hierarchy.L1.name} - Code Structure
88
+
89
+ **Purpose**: ${hierarchy.L1.purpose}
90
+
91
+ ${hierarchy.L1.description}
92
+
93
+ **Serves**: L2 Function Logic
94
+
95
+ ---
96
+
97
+ ## Validation
98
+
99
+ Every change must trace upward through this hierarchy to the ultimate Telos.
100
+
101
+ Ask at each level:
102
+ - **L1**: Does this meet code quality standards?
103
+ - **L2**: Does this function serve the component correctly?
104
+ - **L3**: Does this component fit the architecture?
105
+ - **L4**: Does this respect API contracts?
106
+ - **L5**: Does this integrate into workflows properly?
107
+ - **L6**: Does this enhance user experience?
108
+ - **L7**: Does this respond to user insights?
109
+ - **L8**: Does this advance business objectives?
110
+ - **L9**: Does this serve the ultimate Telos?
111
+
112
+ If the answer is "no" at any level, the change requires revision.
113
+ `;
114
+
115
+ await fs.mkdir(path.dirname(outputPath), { recursive: true });
116
+ await fs.writeFile(outputPath, content, 'utf8');
117
+
118
+ return outputPath;
119
+ }
120
+
121
+ module.exports = { generateTelosMd };