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,112 @@
1
+ const chalk = require('chalk');
2
+ const ora = require('ora');
3
+ const path = require('path');
4
+ const { discoverTelos } = require('../discovery/telos-discovery');
5
+ const { buildHierarchy } = require('../discovery/hierarchy-builder');
6
+ const { generateTelosMd } = require('../generators/telos-md-generator');
7
+ const { generateL9Agent, generateL1Agent, generateL2Agent } = require('../generators/agent-generator');
8
+ const { generateAllAgents } = require('../generators/all-agents-generator');
9
+ const { scanProject } = require('../discovery/code-scanner');
10
+ const { discoverMcpServers, mapMcpToCapabilities } = require('../discovery/mcp-discovery');
11
+ const { mapToolsToLevels, getToolRecommendations } = require('../discovery/tool-mapper');
12
+ const { generateToolsMd } = require('../generators/tools-md-generator');
13
+ const { generateLogosMd } = require('../generators/logos-md-generator');
14
+ const { consolidateAgents } = require('../generators/agents-md-generator');
15
+ const { detectPlatforms, getPlatformConfig } = require('../platform/platform-detector');
16
+ const { createSymlinks } = require('../platform/symlink-creator');
17
+
18
+ async function initCommand(options) {
19
+ console.log(chalk.bold.cyan('\n╔════════════════════════════════════════╗'));
20
+ console.log(chalk.bold.cyan('║ Telos Multi-Agent Initialization ║'));
21
+ console.log(chalk.bold.cyan('╚════════════════════════════════════════╝\n'));
22
+
23
+ try {
24
+ const telosData = await discoverTelos(options);
25
+
26
+ const spinner = ora('Building purpose hierarchy...').start();
27
+ const hierarchy = await buildHierarchy(telosData, options);
28
+ spinner.succeed('Purpose hierarchy built');
29
+
30
+ spinner.start('Generating TELOS.md...');
31
+ const telosPath = path.join(process.cwd(), 'telos', 'content', 'TELOS.md');
32
+ await generateTelosMd(hierarchy, telosPath);
33
+ spinner.succeed(`Generated ${telosPath}`);
34
+
35
+ spinner.start('Generating L9 Telos-Guardian agent...');
36
+ const l9AgentPath = path.join(process.cwd(), 'telos', 'agents', 'l9-telos-guardian.md');
37
+ await generateL9Agent(hierarchy, l9AgentPath);
38
+ spinner.succeed(`Generated ${l9AgentPath}`);
39
+
40
+ console.log(chalk.green('\n✓ Phase 1: Telos Discovery Complete\n'));
41
+
42
+ spinner.start('Scanning project for tools and frameworks...');
43
+ const projectScan = await scanProject(process.cwd());
44
+ spinner.succeed('Project scan complete');
45
+
46
+ spinner.start('Discovering MCP servers...');
47
+ const mcpServers = await discoverMcpServers();
48
+ const mcpCapabilities = mapMcpToCapabilities(mcpServers);
49
+ spinner.succeed(`Found ${mcpServers.length} MCP server(s)`);
50
+
51
+ spinner.start('Mapping tools to agent levels...');
52
+ const levelTools = mapToolsToLevels(projectScan, mcpCapabilities);
53
+ const recommendations = getToolRecommendations(levelTools);
54
+ spinner.succeed('Tool mapping complete');
55
+
56
+ spinner.start('Generating TOOLS.md...');
57
+ const toolsPath = path.join(process.cwd(), 'telos', 'content', 'TOOLS.md');
58
+ await generateToolsMd(levelTools, projectScan, mcpServers, recommendations, toolsPath);
59
+ spinner.succeed(`Generated ${toolsPath}`);
60
+
61
+ console.log(chalk.green('\n✓ Phase 2: Tool Discovery Complete\n'));
62
+
63
+ spinner.start('Generating all agent definitions...');
64
+ const agentsDir = path.join(process.cwd(), 'telos', 'agents');
65
+
66
+ await generateL1Agent(hierarchy, levelTools.L1.tools, path.join(agentsDir, 'l1-syntax-linter.md'));
67
+ await generateL2Agent(hierarchy, levelTools.L2.tools, path.join(agentsDir, 'l2-function-author.md'));
68
+ await generateAllAgents(hierarchy, levelTools, agentsDir);
69
+
70
+ spinner.succeed('Generated all 9 agent definitions');
71
+
72
+ console.log(chalk.green('\n✓ Phase 3: Agent Generation Complete\n'));
73
+
74
+ spinner.start('Generating Logos orchestrator documentation...');
75
+ const logosPath = path.join(process.cwd(), 'telos', 'content', 'LOGOS.md');
76
+ await generateLogosMd(logosPath);
77
+ spinner.succeed(`Generated ${logosPath}`);
78
+
79
+ console.log(chalk.green('\n✓ Phase 4: Logos Orchestrator Complete\n'));
80
+
81
+ spinner.start('Consolidating agents into AGENTS.md...');
82
+ const agentsMdPath = path.join(process.cwd(), 'telos', 'content', 'AGENTS.md');
83
+ await consolidateAgents(agentsDir, agentsMdPath);
84
+ spinner.succeed(`Generated ${agentsMdPath}`);
85
+
86
+ spinner.start('Detecting platforms and creating symlinks...');
87
+ const platforms = await detectPlatforms(process.cwd());
88
+ let symlinkCount = 0;
89
+
90
+ for (const platform of platforms) {
91
+ const config = getPlatformConfig(platform.name);
92
+ const results = await createSymlinks(process.cwd(), config);
93
+ symlinkCount += results.filter(r => r.success).length;
94
+ }
95
+
96
+ spinner.succeed(`Created ${symlinkCount} platform symlink(s) for ${platforms.map(p => p.name).join(', ')}`);
97
+
98
+ console.log(chalk.green('\n✓ Phase 5: Platform Configuration Complete\n'));
99
+
100
+ console.log(chalk.cyan('Your Telos has been captured in:'));
101
+ console.log(chalk.bold(` ${telosPath}\n`));
102
+
103
+ } catch (error) {
104
+ console.error(chalk.red('\n✗ Initialization failed:'), error.message);
105
+ if (options.verbose) {
106
+ console.error(error);
107
+ }
108
+ process.exit(1);
109
+ }
110
+ }
111
+
112
+ module.exports = { initCommand };
@@ -0,0 +1,48 @@
1
+ const chalk = require('chalk');
2
+ const ora = require('ora');
3
+ const path = require('path');
4
+ const { scanProject } = require('../discovery/code-scanner');
5
+ const { discoverMcpServers, mapMcpToCapabilities } = require('../discovery/mcp-discovery');
6
+ const { mapToolsToLevels, getToolRecommendations } = require('../discovery/tool-mapper');
7
+ const { generateToolsMd } = require('../generators/tools-md-generator');
8
+
9
+ async function rediscoverCommand(options) {
10
+ console.log(chalk.cyan('\n=== Tool Rediscovery ===\n'));
11
+
12
+ try {
13
+ const spinner = ora('Re-scanning project...').start();
14
+ const projectScan = await scanProject(process.cwd());
15
+ spinner.succeed('Project scan complete');
16
+
17
+ spinner.start('Re-discovering MCP servers...');
18
+ const mcpServers = await discoverMcpServers();
19
+ const mcpCapabilities = mapMcpToCapabilities(mcpServers);
20
+ spinner.succeed(`Found ${mcpServers.length} MCP server(s)`);
21
+
22
+ spinner.start('Re-mapping tools to agent levels...');
23
+ const levelTools = mapToolsToLevels(projectScan, mcpCapabilities);
24
+ const recommendations = getToolRecommendations(levelTools);
25
+ spinner.succeed('Tool mapping complete');
26
+
27
+ spinner.start('Updating TOOLS.md...');
28
+ const toolsPath = path.join(process.cwd(), 'telos', 'content', 'TOOLS.md');
29
+ await generateToolsMd(levelTools, projectScan, mcpServers, recommendations, toolsPath);
30
+ spinner.succeed(`Updated ${toolsPath}`);
31
+
32
+ console.log(chalk.green('\n✓ Tool rediscovery complete\n'));
33
+
34
+ if (recommendations.length > 0) {
35
+ console.log(chalk.yellow('Recommendations:'));
36
+ for (const rec of recommendations) {
37
+ console.log(chalk.dim(` [${rec.level}] ${rec.message}`));
38
+ }
39
+ console.log();
40
+ }
41
+
42
+ } catch (error) {
43
+ console.error(chalk.red('\n✗ Rediscovery failed:'), error.message);
44
+ process.exit(1);
45
+ }
46
+ }
47
+
48
+ module.exports = { rediscoverCommand };
@@ -0,0 +1,77 @@
1
+ const chalk = require('chalk');
2
+ const fs = require('fs').promises;
3
+ const path = require('path');
4
+
5
+ async function statusCommand(options) {
6
+ console.log(chalk.cyan('\n=== Telos Status ===\n'));
7
+
8
+ try {
9
+ const telosPath = path.join(process.cwd(), 'telos', 'content', 'TELOS.md');
10
+ const toolsPath = path.join(process.cwd(), 'telos', 'content', 'TOOLS.md');
11
+ const agentsPath = path.join(process.cwd(), 'telos', 'content', 'AGENTS.md');
12
+ const configPath = path.join(process.cwd(), '.telos', 'config.json');
13
+
14
+ let initialized = false;
15
+ let config = null;
16
+
17
+ try {
18
+ await fs.access(telosPath);
19
+ initialized = true;
20
+ console.log(chalk.green('✓ Telos initialized'));
21
+ console.log(chalk.dim(` Location: ${telosPath}\n`));
22
+ } catch {
23
+ console.log(chalk.yellow('✗ Telos not initialized'));
24
+ console.log(chalk.dim(' Run: telos init\n'));
25
+ return;
26
+ }
27
+
28
+ try {
29
+ const configContent = await fs.readFile(configPath, 'utf8');
30
+ config = JSON.parse(configContent);
31
+ } catch {
32
+ }
33
+
34
+ console.log(chalk.cyan('Components:'));
35
+
36
+ try {
37
+ await fs.access(agentsPath);
38
+ const agentFiles = await fs.readdir(path.join(process.cwd(), 'telos', 'agents'));
39
+ console.log(chalk.green(` ✓ Agents: ${agentFiles.length} configured`));
40
+ } catch {
41
+ console.log(chalk.yellow(' ✗ Agents: Not configured'));
42
+ }
43
+
44
+ try {
45
+ await fs.access(toolsPath);
46
+ const toolsContent = await fs.readFile(toolsPath, 'utf8');
47
+ const toolCount = (toolsContent.match(/^- \*\*/gm) || []).length;
48
+ console.log(chalk.green(` ✓ Tools: ${toolCount} discovered`));
49
+ } catch {
50
+ console.log(chalk.yellow(' ✗ Tools: Not discovered'));
51
+ }
52
+
53
+ if (config) {
54
+ console.log(chalk.green(` ✓ Platform: ${config.platform || 'generic'}`));
55
+ console.log(chalk.green(` ✓ Initialized: ${new Date(config.timestamp).toLocaleString()}\n`));
56
+ } else {
57
+ console.log(chalk.yellow(' ✗ Configuration: Not found\n'));
58
+ }
59
+
60
+ if (options.verbose) {
61
+ console.log(chalk.cyan('Telos Hierarchy:'));
62
+ try {
63
+ const telosContent = await fs.readFile(telosPath, 'utf8');
64
+ const lines = telosContent.split('\n').slice(0, 20);
65
+ console.log(chalk.dim(lines.join('\n')));
66
+ } catch (error) {
67
+ console.log(chalk.red(' Error reading Telos content'));
68
+ }
69
+ }
70
+
71
+ } catch (error) {
72
+ console.error(chalk.red('Error checking status:'), error.message);
73
+ process.exit(1);
74
+ }
75
+ }
76
+
77
+ module.exports = { statusCommand };
@@ -0,0 +1,148 @@
1
+ const chalk = require('chalk');
2
+ const fs = require('fs').promises;
3
+ const path = require('path');
4
+
5
+ async function validateCommand(options) {
6
+ console.log(chalk.cyan('\n=== Telos Validation ===\n'));
7
+
8
+ try {
9
+ const telosPath = path.join(process.cwd(), 'telos', 'content', 'TELOS.md');
10
+
11
+ try {
12
+ await fs.access(telosPath);
13
+ } catch {
14
+ console.log(chalk.red('✗ Telos not initialized'));
15
+ console.log(chalk.dim(' Run: telos init first\n'));
16
+ return;
17
+ }
18
+
19
+ const checks = [
20
+ { name: 'Telos Hierarchy', fn: validateTelosHierarchy },
21
+ { name: 'Agent Definitions', fn: validateAgents },
22
+ { name: 'Tool Configuration', fn: validateTools },
23
+ { name: 'Platform Setup', fn: validatePlatform }
24
+ ];
25
+
26
+ let passed = 0;
27
+ let failed = 0;
28
+
29
+ for (const check of checks) {
30
+ try {
31
+ const result = await check.fn(process.cwd());
32
+ if (result.valid) {
33
+ console.log(chalk.green(`✓ ${check.name}`));
34
+ if (result.details && options.verbose) {
35
+ console.log(chalk.dim(` ${result.details}`));
36
+ }
37
+ passed++;
38
+ } else {
39
+ console.log(chalk.yellow(`✗ ${check.name}`));
40
+ if (result.message) {
41
+ console.log(chalk.dim(` ${result.message}`));
42
+ }
43
+ failed++;
44
+ }
45
+ } catch (error) {
46
+ console.log(chalk.red(`✗ ${check.name}`));
47
+ console.log(chalk.dim(` Error: ${error.message}`));
48
+ failed++;
49
+ }
50
+ }
51
+
52
+ console.log(chalk.cyan(`\nResults: ${passed} passed, ${failed} failed\n`));
53
+
54
+ if (failed > 0) {
55
+ process.exit(1);
56
+ }
57
+
58
+ } catch (error) {
59
+ console.error(chalk.red('Error during validation:'), error.message);
60
+ process.exit(1);
61
+ }
62
+ }
63
+
64
+ async function validateTelosHierarchy(projectRoot) {
65
+ const telosPath = path.join(projectRoot, 'telos', 'content', 'TELOS.md');
66
+
67
+ try {
68
+ const content = await fs.readFile(telosPath, 'utf8');
69
+
70
+ const hasL9 = content.includes('## L9:');
71
+ const hasL1 = content.includes('## L1:');
72
+
73
+ if (hasL9 && hasL1) {
74
+ const levelCount = (content.match(/## L\d:/g) || []).length;
75
+ return {
76
+ valid: levelCount >= 5,
77
+ details: `${levelCount} levels defined`
78
+ };
79
+ }
80
+
81
+ return {
82
+ valid: false,
83
+ message: 'Missing level definitions'
84
+ };
85
+ } catch (error) {
86
+ return {
87
+ valid: false,
88
+ message: 'Could not read TELOS.md'
89
+ };
90
+ }
91
+ }
92
+
93
+ async function validateAgents(projectRoot) {
94
+ const agentsPath = path.join(projectRoot, 'telos', 'agents');
95
+
96
+ try {
97
+ const files = await fs.readdir(agentsPath);
98
+ const agentFiles = files.filter(f => f.endsWith('.md'));
99
+
100
+ return {
101
+ valid: agentFiles.length >= 9,
102
+ details: `${agentFiles.length} agent files found`
103
+ };
104
+ } catch (error) {
105
+ return {
106
+ valid: false,
107
+ message: 'Agents directory not found'
108
+ };
109
+ }
110
+ }
111
+
112
+ async function validateTools(projectRoot) {
113
+ const toolsPath = path.join(projectRoot, 'telos', 'content', 'TOOLS.md');
114
+
115
+ try {
116
+ const content = await fs.readFile(toolsPath, 'utf8');
117
+ const hasToolSection = content.includes('## Tools by Agent Level');
118
+
119
+ return {
120
+ valid: hasToolSection,
121
+ details: 'Tool inventory present'
122
+ };
123
+ } catch (error) {
124
+ return {
125
+ valid: false,
126
+ message: 'TOOLS.md not found'
127
+ };
128
+ }
129
+ }
130
+
131
+ async function validatePlatform(projectRoot) {
132
+ const agentsPath = path.join(projectRoot, 'telos', 'content', 'AGENTS.md');
133
+
134
+ try {
135
+ await fs.access(agentsPath);
136
+ return {
137
+ valid: true,
138
+ details: 'AGENTS.md exists'
139
+ };
140
+ } catch (error) {
141
+ return {
142
+ valid: false,
143
+ message: 'AGENTS.md not found - run platform setup'
144
+ };
145
+ }
146
+ }
147
+
148
+ module.exports = { validateCommand };
@@ -0,0 +1,129 @@
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+
4
+ async function scanProject(projectRoot) {
5
+ const results = {
6
+ languages: new Set(),
7
+ frameworks: new Set(),
8
+ testFrameworks: new Set(),
9
+ linters: new Set(),
10
+ buildTools: new Set(),
11
+ packageManagers: new Set()
12
+ };
13
+
14
+ try {
15
+ const files = await fs.readdir(projectRoot);
16
+
17
+ for (const file of files) {
18
+ if (file.startsWith('.')) continue;
19
+
20
+ const filePath = path.join(projectRoot, file);
21
+ const stat = await fs.stat(filePath);
22
+
23
+ if (stat.isFile()) {
24
+ await detectFromFile(file, filePath, results);
25
+ }
26
+ }
27
+
28
+ await detectFromPackageJson(projectRoot, results);
29
+
30
+ } catch (error) {
31
+ console.error('Error scanning project:', error.message);
32
+ }
33
+
34
+ return {
35
+ languages: Array.from(results.languages),
36
+ frameworks: Array.from(results.frameworks),
37
+ testFrameworks: Array.from(results.testFrameworks),
38
+ linters: Array.from(results.linters),
39
+ buildTools: Array.from(results.buildTools),
40
+ packageManagers: Array.from(results.packageManagers)
41
+ };
42
+ }
43
+
44
+ async function detectFromFile(filename, filePath, results) {
45
+ if (filename === 'package.json') {
46
+ results.packageManagers.add('npm');
47
+ results.languages.add('JavaScript/TypeScript');
48
+ } else if (filename === 'package-lock.json') {
49
+ results.packageManagers.add('npm');
50
+ } else if (filename === 'yarn.lock') {
51
+ results.packageManagers.add('yarn');
52
+ } else if (filename === 'pnpm-lock.yaml') {
53
+ results.packageManagers.add('pnpm');
54
+ } else if (filename === 'Cargo.toml') {
55
+ results.languages.add('Rust');
56
+ results.packageManagers.add('cargo');
57
+ } else if (filename === 'go.mod') {
58
+ results.languages.add('Go');
59
+ results.packageManagers.add('go modules');
60
+ } else if (filename === 'requirements.txt' || filename === 'pyproject.toml') {
61
+ results.languages.add('Python');
62
+ results.packageManagers.add('pip');
63
+ } else if (filename === 'Gemfile') {
64
+ results.languages.add('Ruby');
65
+ results.packageManagers.add('bundler');
66
+ } else if (filename === 'pubspec.yaml') {
67
+ results.languages.add('Dart');
68
+ results.frameworks.add('Flutter');
69
+ results.packageManagers.add('pub');
70
+ } else if (filename === '.eslintrc.js' || filename === '.eslintrc.json' || filename === 'eslint.config.js') {
71
+ results.linters.add('ESLint');
72
+ } else if (filename === '.prettierrc' || filename === '.prettierrc.json') {
73
+ results.linters.add('Prettier');
74
+ } else if (filename === 'ruff.toml' || filename === '.ruff.toml') {
75
+ results.linters.add('Ruff');
76
+ } else if (filename === 'vite.config.js' || filename === 'vite.config.ts') {
77
+ results.buildTools.add('Vite');
78
+ } else if (filename === 'webpack.config.js') {
79
+ results.buildTools.add('Webpack');
80
+ } else if (filename === 'vitest.config.js' || filename === 'vitest.config.ts') {
81
+ results.testFrameworks.add('Vitest');
82
+ } else if (filename === 'jest.config.js' || filename === 'jest.config.json') {
83
+ results.testFrameworks.add('Jest');
84
+ } else if (filename === 'playwright.config.js' || filename === 'playwright.config.ts') {
85
+ results.testFrameworks.add('Playwright');
86
+ } else if (filename === 'cypress.config.js' || filename === 'cypress.config.ts') {
87
+ results.testFrameworks.add('Cypress');
88
+ }
89
+ }
90
+
91
+ async function detectFromPackageJson(projectRoot, results) {
92
+ try {
93
+ const pkgPath = path.join(projectRoot, 'package.json');
94
+ const content = await fs.readFile(pkgPath, 'utf8');
95
+ const pkg = JSON.parse(content);
96
+
97
+ const allDeps = {
98
+ ...pkg.dependencies,
99
+ ...pkg.devDependencies
100
+ };
101
+
102
+ if (allDeps.react) results.frameworks.add('React');
103
+ if (allDeps.vue) results.frameworks.add('Vue');
104
+ if (allDeps.next) results.frameworks.add('Next.js');
105
+ if (allDeps.nuxt) results.frameworks.add('Nuxt');
106
+ if (allDeps.svelte) results.frameworks.add('Svelte');
107
+ if (allDeps['@angular/core']) results.frameworks.add('Angular');
108
+ if (allDeps.express) results.frameworks.add('Express');
109
+ if (allDeps.fastify) results.frameworks.add('Fastify');
110
+ if (allDeps.nest) results.frameworks.add('NestJS');
111
+
112
+ if (allDeps.vitest) results.testFrameworks.add('Vitest');
113
+ if (allDeps.jest) results.testFrameworks.add('Jest');
114
+ if (allDeps.mocha) results.testFrameworks.add('Mocha');
115
+ if (allDeps.playwright) results.testFrameworks.add('Playwright');
116
+ if (allDeps.cypress) results.testFrameworks.add('Cypress');
117
+
118
+ if (allDeps.eslint) results.linters.add('ESLint');
119
+ if (allDeps.prettier) results.linters.add('Prettier');
120
+ if (allDeps.typescript) {
121
+ results.languages.add('TypeScript');
122
+ results.linters.add('TypeScript Compiler');
123
+ }
124
+
125
+ } catch (error) {
126
+ }
127
+ }
128
+
129
+ module.exports = { scanProject };
@@ -0,0 +1,147 @@
1
+ const inquirer = require('inquirer');
2
+ const chalk = require('chalk');
3
+
4
+ const LEVEL_DESCRIPTIONS = {
5
+ L9: 'Transcendent Purpose - The ultimate "why" that gives meaning to all else',
6
+ L8: 'Business/Social Value - Measurable outcomes and societal impact',
7
+ L7: 'User Insight - Understanding user behavior, needs, and feedback',
8
+ L6: 'User Experience - Interface, accessibility, and user journey design',
9
+ L5: 'System Integration - End-to-end workflows and service coordination',
10
+ L4: 'API Contracts - Service boundaries and integration points',
11
+ L3: 'Component Design - Modular architecture and composition',
12
+ L2: 'Function Logic - Individual units of behavior and computation',
13
+ L1: 'Code Structure - Syntax, formatting, and basic integrity'
14
+ };
15
+
16
+ async function buildHierarchy(telosData, options = {}) {
17
+ console.log(chalk.cyan('\n=== Building Purpose Hierarchy ===\n'));
18
+ console.log('We\'ll decompose your Telos into 9 levels (L9 → L1).\n');
19
+
20
+ const hierarchy = {
21
+ L9: {
22
+ level: 'L9',
23
+ name: 'Telos-Guardian',
24
+ description: LEVEL_DESCRIPTIONS.L9,
25
+ purpose: telosData.telos,
26
+ beneficiaries: telosData.beneficiaries,
27
+ impact: telosData.impact,
28
+ constraints: telosData.constraints
29
+ }
30
+ };
31
+
32
+ if (options.quick) {
33
+ return buildQuickHierarchy(telosData, hierarchy);
34
+ }
35
+
36
+ hierarchy.L8 = await promptLevel('L8', 'Business/Social Value',
37
+ 'What measurable business or social outcomes serve your Telos?',
38
+ `Support: ${telosData.telos}`);
39
+
40
+ hierarchy.L7 = await promptLevel('L7', 'User Insight',
41
+ 'What user insights and behaviors must you understand?',
42
+ `Support: ${hierarchy.L8.purpose}`);
43
+
44
+ hierarchy.L6 = await promptLevel('L6', 'User Experience',
45
+ 'What user experience qualities are essential?',
46
+ `Support: ${hierarchy.L7.purpose}`);
47
+
48
+ hierarchy.L5 = await promptLevel('L5', 'System Integration',
49
+ 'What system-level integrations and workflows enable this?',
50
+ `Support: ${hierarchy.L6.purpose}`);
51
+
52
+ hierarchy.L4 = await promptLevel('L4', 'API Contracts',
53
+ 'What API contracts and service boundaries are required?',
54
+ `Support: ${hierarchy.L5.purpose}`);
55
+
56
+ hierarchy.L3 = await promptLevel('L3', 'Component Design',
57
+ 'What component architecture supports these contracts?',
58
+ `Support: ${hierarchy.L4.purpose}`);
59
+
60
+ hierarchy.L2 = await promptLevel('L2', 'Function Logic',
61
+ 'What core functions and logic units are needed?',
62
+ `Support: ${hierarchy.L3.purpose}`);
63
+
64
+ hierarchy.L1 = await promptLevel('L1', 'Code Structure',
65
+ 'What code quality standards ensure reliability?',
66
+ `Support: ${hierarchy.L2.purpose}`);
67
+
68
+ return hierarchy;
69
+ }
70
+
71
+ async function promptLevel(level, name, question, context) {
72
+ console.log(chalk.dim(`\n${context}\n`));
73
+
74
+ const { purpose } = await inquirer.prompt([
75
+ {
76
+ type: 'input',
77
+ name: 'purpose',
78
+ message: `${chalk.bold(level)} - ${name}:\n ${question}`,
79
+ validate: (input) => input.trim().length > 0 || 'Purpose cannot be empty'
80
+ }
81
+ ]);
82
+
83
+ return {
84
+ level,
85
+ name,
86
+ description: LEVEL_DESCRIPTIONS[level],
87
+ purpose: purpose.trim()
88
+ };
89
+ }
90
+
91
+ function buildQuickHierarchy(telosData, baseHierarchy) {
92
+ const telos = telosData.telos;
93
+
94
+ return {
95
+ ...baseHierarchy,
96
+ L8: {
97
+ level: 'L8',
98
+ name: 'Market-Analyst',
99
+ description: LEVEL_DESCRIPTIONS.L8,
100
+ purpose: `Achieve measurable business outcomes that realize: ${telos}`
101
+ },
102
+ L7: {
103
+ level: 'L7',
104
+ name: 'Insight-Synthesizer',
105
+ description: LEVEL_DESCRIPTIONS.L7,
106
+ purpose: 'Understand user behavior and feedback to inform experience design'
107
+ },
108
+ L6: {
109
+ level: 'L6',
110
+ name: 'UX-Simulator',
111
+ description: LEVEL_DESCRIPTIONS.L6,
112
+ purpose: 'Deliver accessible, intuitive user experiences across all touchpoints'
113
+ },
114
+ L5: {
115
+ level: 'L5',
116
+ name: 'Journey-Validator',
117
+ description: LEVEL_DESCRIPTIONS.L5,
118
+ purpose: 'Ensure end-to-end workflows function cohesively'
119
+ },
120
+ L4: {
121
+ level: 'L4',
122
+ name: 'Integration-Contractor',
123
+ description: LEVEL_DESCRIPTIONS.L4,
124
+ purpose: 'Maintain clear API contracts and service boundaries'
125
+ },
126
+ L3: {
127
+ level: 'L3',
128
+ name: 'Component-Architect',
129
+ description: LEVEL_DESCRIPTIONS.L3,
130
+ purpose: 'Design modular, composable components'
131
+ },
132
+ L2: {
133
+ level: 'L2',
134
+ name: 'Function-Author',
135
+ description: LEVEL_DESCRIPTIONS.L2,
136
+ purpose: 'Write tested, reliable function implementations'
137
+ },
138
+ L1: {
139
+ level: 'L1',
140
+ name: 'Syntax-Linter',
141
+ description: LEVEL_DESCRIPTIONS.L1,
142
+ purpose: 'Ensure code structural integrity and formatting'
143
+ }
144
+ };
145
+ }
146
+
147
+ module.exports = { buildHierarchy };