telos-framework 0.3.2 → 0.4.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/.claude/commands/telos/init.md +199 -15
- package/lib/commands/init.js +80 -32
- package/lib/installers/memory-files.js +52 -4
- package/lib/installers/slash-commands.js +30 -24
- package/package.json +1 -1
|
@@ -9,6 +9,40 @@ architecture for AI-assisted software development. Your role is to analyze this
|
|
|
9
9
|
codebase, propose a complete hierarchy from ultimate purpose (L9) to code
|
|
10
10
|
structure (L1), and generate all necessary files.
|
|
11
11
|
|
|
12
|
+
## Step 0: Detect AI Platform & Create Config
|
|
13
|
+
|
|
14
|
+
**IMPORTANT**: Before proceeding, detect which AI coding assistant is running:
|
|
15
|
+
|
|
16
|
+
1. **Check environment indicators**:
|
|
17
|
+
- Claude Code: Check if `.claude/` directory exists or if running from Claude
|
|
18
|
+
slash command
|
|
19
|
+
- Opencode: Check if `.opencode/` directory exists or `OPENCODE_SESSION` env
|
|
20
|
+
var
|
|
21
|
+
- Other: Neither detected
|
|
22
|
+
|
|
23
|
+
2. **If running from Claude Code AND no `CLAUDE.md` exists**:
|
|
24
|
+
- Create `CLAUDE.md` with the Telos reference template (see section 4.3 for
|
|
25
|
+
template)
|
|
26
|
+
- Include note: "Auto-generated by Telos initialization"
|
|
27
|
+
|
|
28
|
+
3. **If `CLAUDE.md` exists but doesn't mention Telos**:
|
|
29
|
+
- Prepend the Telos reference section (see section 4.3)
|
|
30
|
+
|
|
31
|
+
4. **Ask user which platform they want to initialize for**:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Which AI coding platform would you like to initialize Telos for?
|
|
35
|
+
|
|
36
|
+
1. Claude Code (slash commands in `.claude/commands/telos/`)
|
|
37
|
+
2. Opencode (commands in `.opencode/command/telos/`)
|
|
38
|
+
3. Both
|
|
39
|
+
4. Skip command installation (manual setup)
|
|
40
|
+
|
|
41
|
+
Your choice [1-4]:
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Store their response for Step 4.4.
|
|
45
|
+
|
|
12
46
|
## Step 1: Analyze Codebase
|
|
13
47
|
|
|
14
48
|
Read and analyze the following to understand this project:
|
|
@@ -148,7 +182,7 @@ Reasoning: [Based on detected linters, formatters, and quality standards]
|
|
|
148
182
|
═══════════════════════════════════════════════════════════════════════════
|
|
149
183
|
```
|
|
150
184
|
|
|
151
|
-
### Auto-generation Guidelines for L1-L4
|
|
185
|
+
### Auto-generation Guidelines for L1-L4
|
|
152
186
|
|
|
153
187
|
**L1 (Syntax-Linter)** - Based on detected tools:
|
|
154
188
|
|
|
@@ -185,6 +219,7 @@ After presenting the table, say:
|
|
|
185
219
|
**Strategic layers (L9-L5) define your project's purpose and require your input.**
|
|
186
220
|
|
|
187
221
|
**Technical layers (L1-L4) are auto-generated based on your detected tooling:**
|
|
222
|
+
|
|
188
223
|
- L1: [List detected linters]
|
|
189
224
|
- L2: [List detected test frameworks]
|
|
190
225
|
- L3: [List detected component frameworks]
|
|
@@ -193,6 +228,7 @@ After presenting the table, say:
|
|
|
193
228
|
**Please review the strategic layers (L9-L5). Would you like to refine any of these?**
|
|
194
229
|
|
|
195
230
|
Options:
|
|
231
|
+
|
|
196
232
|
- "Accept all" - Proceed with generation
|
|
197
233
|
- "Refine L9" - Edit ultimate purpose layer
|
|
198
234
|
- "Refine L8" - Edit business value layer
|
|
@@ -254,13 +290,13 @@ Tools**: [Build systems]
|
|
|
254
290
|
## Initialization Metadata
|
|
255
291
|
|
|
256
292
|
- **Initialized**: [Current date]
|
|
257
|
-
- **AI Assistant**: Claude via Telos `/telos
|
|
293
|
+
- **AI Assistant**: Claude via Telos `/telos:init`
|
|
258
294
|
- **Project Type**: [Inferred project type]
|
|
259
295
|
```
|
|
260
296
|
|
|
261
297
|
### 4.2 Create Agent Files
|
|
262
298
|
|
|
263
|
-
For each level (L9 → L1), create
|
|
299
|
+
For each level (L9 → L1), create `.telos/agents/l[N]-[agent-name].md`:
|
|
264
300
|
|
|
265
301
|
**Template structure:**
|
|
266
302
|
|
|
@@ -346,15 +382,25 @@ Check for and update existing AI assistant configuration files to reference
|
|
|
346
382
|
|
|
347
383
|
**Files to check:**
|
|
348
384
|
|
|
349
|
-
- `AGENTS.md` - Unified standard (
|
|
350
|
-
- `CLAUDE.md` - Claude Code (if
|
|
385
|
+
- `AGENTS.md` - Unified standard (always create/update if doesn't exist)
|
|
386
|
+
- `CLAUDE.md` - Claude Code (always create if running from Claude and doesn't
|
|
387
|
+
exist)
|
|
351
388
|
- `.cursorrules` - Cursor IDE (if exists, prepend Telos reference)
|
|
352
389
|
- `.clinerules` - Cline/VS Code (if exists, prepend Telos reference)
|
|
353
390
|
- `.windsurfrules` - Windsurf IDE (if exists, prepend Telos reference)
|
|
354
391
|
- `.roo/config` or `.roocode` - Roo Code (if exists, prepend Telos reference)
|
|
355
392
|
- `GEMINI.md` - Google Gemini (if exists, prepend Telos reference)
|
|
356
393
|
|
|
357
|
-
**
|
|
394
|
+
**CLAUDE.md Creation Rule**:
|
|
395
|
+
|
|
396
|
+
- If running from Claude Code (detected via `.claude/` directory or slash
|
|
397
|
+
command context)
|
|
398
|
+
- AND `CLAUDE.md` does not exist
|
|
399
|
+
- Create `CLAUDE.md` with Telos reference template below
|
|
400
|
+
- Add comment: `<!-- Auto-generated by Telos initialization -->`
|
|
401
|
+
|
|
402
|
+
**For each existing file (or newly created CLAUDE.md), prepend this
|
|
403
|
+
instruction:**
|
|
358
404
|
|
|
359
405
|
```markdown
|
|
360
406
|
## Telos Purpose Hierarchy
|
|
@@ -383,7 +429,7 @@ all development decisions.
|
|
|
383
429
|
- L2 (Function-Author): Functions - is this testable and maintainable?
|
|
384
430
|
- L1 (Syntax-Linter): Code quality - does this pass linting/formatting?
|
|
385
431
|
|
|
386
|
-
See `.telos/TELOS.md` for complete hierarchy and
|
|
432
|
+
See `.telos/TELOS.md` for complete hierarchy and `.telos/agents/` for detailed
|
|
387
433
|
agent definitions.
|
|
388
434
|
|
|
389
435
|
---
|
|
@@ -392,7 +438,104 @@ agent definitions.
|
|
|
392
438
|
**If no AI assistant config files exist**, create `AGENTS.md` with Telos
|
|
393
439
|
content.
|
|
394
440
|
|
|
395
|
-
### 4.4
|
|
441
|
+
### 4.4 Install Platform-Specific Commands
|
|
442
|
+
|
|
443
|
+
Based on user's choice from Step 0:
|
|
444
|
+
|
|
445
|
+
#### Option 1: Claude Code Commands
|
|
446
|
+
|
|
447
|
+
Create slash commands in `.claude/commands/telos/`:
|
|
448
|
+
|
|
449
|
+
**Files to create:**
|
|
450
|
+
|
|
451
|
+
- `init.md` - This initialization command
|
|
452
|
+
- `quick.md` - Quick initialization with auto-accept
|
|
453
|
+
- `validate.md` - Validate code against Telos hierarchy
|
|
454
|
+
- `status.md` - Show current Telos configuration
|
|
455
|
+
- `reset.md` - Clear and reinitialize
|
|
456
|
+
|
|
457
|
+
All use standard markdown format (already created by `telos init` CLI).
|
|
458
|
+
|
|
459
|
+
#### Option 2: Opencode Commands
|
|
460
|
+
|
|
461
|
+
Create commands in `.opencode/command/telos/` using frontmatter format:
|
|
462
|
+
|
|
463
|
+
**Template structure for Opencode:**
|
|
464
|
+
|
|
465
|
+
```markdown
|
|
466
|
+
---
|
|
467
|
+
description: [Command description]
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
[Command template/prompt here]
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
**Files to create:**
|
|
474
|
+
|
|
475
|
+
1. `.opencode/command/telos/init.md`:
|
|
476
|
+
|
|
477
|
+
```markdown
|
|
478
|
+
---
|
|
479
|
+
description: Initialize Telos multi-agent system for this project
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
[Copy full content from .claude/commands/telos/init.md]
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
2. `.opencode/command/telos/quick.md`:
|
|
486
|
+
|
|
487
|
+
```markdown
|
|
488
|
+
---
|
|
489
|
+
description: Quick Telos initialization with auto-accepted AI proposals
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
[Copy full content from .claude/commands/telos/quick.md]
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
3. `.opencode/command/telos/validate.md`:
|
|
496
|
+
|
|
497
|
+
```markdown
|
|
498
|
+
---
|
|
499
|
+
description: Validate current code against Telos purpose hierarchy
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
[Copy full content from .claude/commands/telos/validate.md]
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
4. `.opencode/command/telos/status.md`:
|
|
506
|
+
|
|
507
|
+
```markdown
|
|
508
|
+
---
|
|
509
|
+
description: Show current Telos configuration and hierarchy
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
[Copy full content from .claude/commands/telos/status.md]
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
5. `.opencode/command/telos/reset.md`:
|
|
516
|
+
|
|
517
|
+
```markdown
|
|
518
|
+
---
|
|
519
|
+
description: Clear existing Telos installation and reinitialize
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
[Copy full content from .claude/commands/telos/reset.md]
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
**Note**: Opencode commands use the same prompt content as Claude Code commands,
|
|
526
|
+
just with added YAML frontmatter for the `description` field.
|
|
527
|
+
|
|
528
|
+
#### Option 3: Both Platforms
|
|
529
|
+
|
|
530
|
+
Create command files in both `.claude/commands/telos/` AND
|
|
531
|
+
`.opencode/command/telos/`.
|
|
532
|
+
|
|
533
|
+
#### Option 4: Skip Command Installation
|
|
534
|
+
|
|
535
|
+
Only create `.telos/` directory structure and config file integrations. User
|
|
536
|
+
will manually install commands later via `telos init` CLI.
|
|
537
|
+
|
|
538
|
+
### 4.5 Create Orchestrator (Optional)
|
|
396
539
|
|
|
397
540
|
If JavaScript/Node.js project, create `logos/orchestrator.js`:
|
|
398
541
|
|
|
@@ -417,25 +560,66 @@ Once all files are generated, display:
|
|
|
417
560
|
✅ **Telos initialization complete!**
|
|
418
561
|
|
|
419
562
|
**Generated files:**
|
|
563
|
+
|
|
420
564
|
- `.telos/TELOS.md` - Ultimate purpose and hierarchy
|
|
421
|
-
-
|
|
565
|
+
- `.telos/agents/l9-telos-guardian.md` through `l1-syntax-linter.md`
|
|
422
566
|
- Updated AI assistant config files (AGENTS.md, CLAUDE.md, .cursorrules, etc.)
|
|
567
|
+
- Platform commands: [List based on Step 0 choice]
|
|
568
|
+
- Claude Code: `.claude/commands/telos/*.md` (5 commands)
|
|
569
|
+
- Opencode: `.opencode/command/telos/*.md` (5 commands)
|
|
423
570
|
- `logos/orchestrator.js` - Request router (if applicable)
|
|
424
571
|
|
|
425
572
|
**Next steps:**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
573
|
+
|
|
574
|
+
1. Review the generated agent definitions in `.telos/agents/`
|
|
575
|
+
2. Run validation command to check alignment with current codebase
|
|
576
|
+
3. Run status command to see current configuration
|
|
429
577
|
4. Start developing with purpose-driven AI assistance!
|
|
430
578
|
|
|
431
579
|
**Your AI assistant now knows about Telos!** All existing config files (AGENTS.md,
|
|
432
580
|
CLAUDE.md, .cursorrules, etc.) have been updated to reference `.telos/TELOS.md`
|
|
433
581
|
before making changes.
|
|
434
582
|
|
|
583
|
+
**Commands available:**
|
|
584
|
+
|
|
585
|
+
**Claude Code:**
|
|
586
|
+
- `/telos:validate` - Check if current code aligns with Telos
|
|
587
|
+
- `/telos:status` - Show current Telos configuration
|
|
588
|
+
- `/telos:reset` - Clear and reinitialize
|
|
589
|
+
|
|
590
|
+
**Opencode:**
|
|
591
|
+
- `/telos/init` - Initialize Telos (this command)
|
|
592
|
+
- `/telos/validate` - Check if current code aligns with Telos
|
|
593
|
+
- `/telos/status` - Show current Telos configuration
|
|
594
|
+
- `/telos/reset` - Clear and reinitialize
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
✅ **Telos initialization complete!**
|
|
598
|
+
|
|
599
|
+
**Generated files:**
|
|
600
|
+
|
|
601
|
+
- `.telos/TELOS.md` - Ultimate purpose and hierarchy
|
|
602
|
+
- `.telos/agents/l9-telos-guardian.md` through `l1-syntax-linter.md`
|
|
603
|
+
- Updated AI assistant config files (AGENTS.md, CLAUDE.md, .cursorrules, etc.)
|
|
604
|
+
- `logos/orchestrator.js` - Request router (if applicable)
|
|
605
|
+
|
|
606
|
+
**Next steps:**
|
|
607
|
+
|
|
608
|
+
1. Review the generated agent definitions in `.telos/agents/`
|
|
609
|
+
2. Run `/telos:validate` to check alignment with current codebase
|
|
610
|
+
3. Run `/telos:status` to see current configuration
|
|
611
|
+
4. Start developing with purpose-driven AI assistance!
|
|
612
|
+
|
|
613
|
+
**Your AI assistant now knows about Telos!** All existing config files
|
|
614
|
+
(AGENTS.md, CLAUDE.md, .cursorrules, etc.) have been updated to reference
|
|
615
|
+
`.telos/TELOS.md` before making changes.
|
|
616
|
+
|
|
435
617
|
**Slash commands available:**
|
|
436
|
-
|
|
437
|
-
- `/telos
|
|
438
|
-
- `/telos
|
|
618
|
+
|
|
619
|
+
- `/telos:validate` - Check if current code aligns with Telos
|
|
620
|
+
- `/telos:status` - Show current Telos configuration
|
|
621
|
+
- `/telos:reset` - Clear and reinitialize
|
|
622
|
+
|
|
439
623
|
---
|
|
440
624
|
|
|
441
625
|
## Tips
|
package/lib/commands/init.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const { default: inquirer } = require('inquirer');
|
|
3
4
|
const { installSlashCommands } = require('../installers/slash-commands');
|
|
4
5
|
const { setupMemoryFiles } = require('../installers/memory-files');
|
|
5
6
|
|
|
@@ -11,16 +12,48 @@ async function initCommand(options) {
|
|
|
11
12
|
try {
|
|
12
13
|
const projectRoot = process.cwd();
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const answers = await inquirer.prompt([
|
|
16
|
+
{
|
|
17
|
+
type: 'checkbox',
|
|
18
|
+
name: 'platforms',
|
|
19
|
+
message: 'Which AI coding platforms do you want to initialize Telos for?',
|
|
20
|
+
choices: [
|
|
21
|
+
{ name: 'Claude Code', value: 'claude', checked: true },
|
|
22
|
+
{ name: 'Opencode', value: 'opencode' },
|
|
23
|
+
{ name: 'Cursor', value: 'cursor' },
|
|
24
|
+
{ name: 'Cline', value: 'cline' },
|
|
25
|
+
{ name: 'Windsurf', value: 'windsurf' },
|
|
26
|
+
{ name: 'Roo', value: 'roo' },
|
|
27
|
+
{ name: 'Gemini', value: 'gemini' },
|
|
28
|
+
{ name: 'Other (AGENTS.md only)', value: 'other' }
|
|
29
|
+
],
|
|
30
|
+
validate: (answer) => {
|
|
31
|
+
if (answer.length === 0) {
|
|
32
|
+
return 'You must choose at least one platform or press Ctrl+C to cancel.';
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const platforms = answers.platforms;
|
|
15
40
|
|
|
16
|
-
|
|
41
|
+
console.log(chalk.cyan('\nInstalling Telos commands...\n'));
|
|
42
|
+
|
|
43
|
+
const commandResults = await installSlashCommands(projectRoot, platforms);
|
|
17
44
|
|
|
18
|
-
for (const { platform, results } of commandResults) {
|
|
45
|
+
for (const { platform: platformName, results } of commandResults) {
|
|
19
46
|
const successful = results.filter(r => r.success);
|
|
20
47
|
if (successful.length > 0) {
|
|
21
|
-
console.log(chalk.green(`✓ Installed ${successful.length} command(s) for ${
|
|
48
|
+
console.log(chalk.green(`✓ Installed ${successful.length} command(s) for ${platformName}:`));
|
|
22
49
|
successful.forEach(r => {
|
|
23
|
-
|
|
50
|
+
const cmdPrefix = platformName === 'claude' ? '/telos:' :
|
|
51
|
+
platformName === 'opencode' ? '/telos/' : '';
|
|
52
|
+
if (cmdPrefix) {
|
|
53
|
+
console.log(chalk.dim(` - ${cmdPrefix}${r.file.replace('.md', '')}`));
|
|
54
|
+
} else {
|
|
55
|
+
console.log(chalk.dim(` - ${r.file}`));
|
|
56
|
+
}
|
|
24
57
|
});
|
|
25
58
|
}
|
|
26
59
|
|
|
@@ -33,24 +66,26 @@ async function initCommand(options) {
|
|
|
33
66
|
}
|
|
34
67
|
}
|
|
35
68
|
|
|
36
|
-
console.log(chalk.cyan('\nSetting up
|
|
69
|
+
console.log(chalk.cyan('\nSetting up configuration files...\n'));
|
|
37
70
|
|
|
38
|
-
const memoryResults = await setupMemoryFiles(projectRoot);
|
|
71
|
+
const memoryResults = await setupMemoryFiles(projectRoot, platforms);
|
|
39
72
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
73
|
+
for (const [fileType, result] of Object.entries(memoryResults)) {
|
|
74
|
+
const fileName = fileType === 'agents' ? 'AGENTS.md' :
|
|
75
|
+
fileType === 'claude' ? 'CLAUDE.md' :
|
|
76
|
+
fileType === 'cursor' ? '.cursorrules' :
|
|
77
|
+
fileType === 'cline' ? '.clinerules' :
|
|
78
|
+
fileType === 'windsurf' ? '.windsurfrules' :
|
|
79
|
+
fileType === 'roo' ? '.roocode' :
|
|
80
|
+
fileType === 'gemini' ? 'GEMINI.md' : fileType;
|
|
81
|
+
|
|
82
|
+
if (result.created) {
|
|
83
|
+
console.log(chalk.green(`✓ Created ${fileName}`));
|
|
84
|
+
} else if (result.updated) {
|
|
85
|
+
console.log(chalk.green(`✓ Updated ${fileName} with Telos content`));
|
|
86
|
+
} else if (result.reason === 'already-exists') {
|
|
87
|
+
console.log(chalk.dim(`✓ ${fileName} already contains Telos content`));
|
|
88
|
+
}
|
|
54
89
|
}
|
|
55
90
|
|
|
56
91
|
console.log(chalk.bold.cyan('\n╔══════════════════════════════════════════╗'));
|
|
@@ -58,18 +93,31 @@ async function initCommand(options) {
|
|
|
58
93
|
console.log(chalk.bold.cyan('╚══════════════════════════════════════════╝\n'));
|
|
59
94
|
|
|
60
95
|
console.log(chalk.bold.white('Next steps:\n'));
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
96
|
+
|
|
97
|
+
const hasClaudeOrOpencode = platforms.includes('claude') || platforms.includes('opencode');
|
|
98
|
+
|
|
99
|
+
if (hasClaudeOrOpencode) {
|
|
100
|
+
const primaryPlatform = platforms.includes('claude') ? 'claude' : 'opencode';
|
|
101
|
+
const cmdPrefix = primaryPlatform === 'claude' ? '/telos:' : '/telos/';
|
|
102
|
+
const platformName = primaryPlatform === 'claude' ? 'Claude Code' : 'Opencode';
|
|
103
|
+
|
|
104
|
+
console.log(chalk.white(`1. Open this project in ${platformName} (or your chosen AI assistant)`));
|
|
105
|
+
console.log(chalk.white('2. Run the command: ') + chalk.bold.green(`${cmdPrefix}init`));
|
|
106
|
+
console.log(chalk.white('3. AI will analyze your codebase and propose a 9-level purpose hierarchy'));
|
|
107
|
+
console.log(chalk.white('4. Review strategic layers (L9-L5) and provide refinements'));
|
|
108
|
+
console.log(chalk.white('5. AI generates .telos/TELOS.md and integrates with your config files\n'));
|
|
66
109
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
110
|
+
console.log(chalk.dim('Available commands:'));
|
|
111
|
+
console.log(chalk.dim(` ${cmdPrefix}init - Initialize Telos with interactive review`));
|
|
112
|
+
console.log(chalk.dim(` ${cmdPrefix}quick - Quick initialization (auto-accept AI proposals)`));
|
|
113
|
+
console.log(chalk.dim(` ${cmdPrefix}validate - Check code alignment with purpose`));
|
|
114
|
+
console.log(chalk.dim(` ${cmdPrefix}status - Show current Telos configuration`));
|
|
115
|
+
console.log(chalk.dim(` ${cmdPrefix}reset - Clear and reinitialize\n`));
|
|
116
|
+
} else {
|
|
117
|
+
console.log(chalk.white('1. Open this project in your AI coding assistant'));
|
|
118
|
+
console.log(chalk.white('2. Your AI assistant will reference the updated config files'));
|
|
119
|
+
console.log(chalk.white('3. Ask your AI to run Telos initialization\n'));
|
|
120
|
+
}
|
|
73
121
|
|
|
74
122
|
} catch (error) {
|
|
75
123
|
console.error(chalk.red('\n✗ Installation failed:'), error.message);
|
|
@@ -61,17 +61,65 @@ async function createClaudeMd(projectRoot) {
|
|
|
61
61
|
return { created: true, updated: false, path: claudeMdPath };
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
async function
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
async function createConfigFile(projectRoot, platform) {
|
|
65
|
+
const configFiles = {
|
|
66
|
+
'cursor': '.cursorrules',
|
|
67
|
+
'cline': '.clinerules',
|
|
68
|
+
'windsurf': '.windsurfrules',
|
|
69
|
+
'roo': '.roocode',
|
|
70
|
+
'gemini': 'GEMINI.md'
|
|
68
71
|
};
|
|
69
72
|
|
|
73
|
+
const fileName = configFiles[platform];
|
|
74
|
+
if (!fileName) return null;
|
|
75
|
+
|
|
76
|
+
const filePath = path.join(projectRoot, fileName);
|
|
77
|
+
const template = await readTemplate('CLAUDE.md');
|
|
78
|
+
|
|
79
|
+
if (await fileExists(filePath)) {
|
|
80
|
+
const existingContent = await fs.readFile(filePath, 'utf-8');
|
|
81
|
+
|
|
82
|
+
if (existingContent.includes('Telos Framework')) {
|
|
83
|
+
return { created: false, updated: false, path: filePath, reason: 'already-exists' };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const updatedContent = template + '\n\n' + existingContent;
|
|
87
|
+
await fs.writeFile(filePath, updatedContent);
|
|
88
|
+
|
|
89
|
+
return { created: false, updated: true, path: filePath };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
await fs.writeFile(filePath, template);
|
|
93
|
+
return { created: true, updated: false, path: filePath };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function setupMemoryFiles(projectRoot, platforms = []) {
|
|
97
|
+
const results = {};
|
|
98
|
+
|
|
99
|
+
const platformsArray = Array.isArray(platforms) ? platforms : [platforms];
|
|
100
|
+
|
|
101
|
+
if (platformsArray.includes('other') || platformsArray.length === 0 || !platformsArray.some(p => ['claude', 'opencode', 'cursor', 'cline', 'windsurf', 'roo', 'gemini'].includes(p))) {
|
|
102
|
+
results.agents = await createAgentsMd(projectRoot);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
for (const platform of platformsArray) {
|
|
106
|
+
if (platform === 'claude') {
|
|
107
|
+
results.claude = await createClaudeMd(projectRoot);
|
|
108
|
+
} else if (platform === 'cursor' || platform === 'cline' || platform === 'windsurf' || platform === 'roo' || platform === 'gemini') {
|
|
109
|
+
results[platform] = await createConfigFile(projectRoot, platform);
|
|
110
|
+
} else if (platform === 'other') {
|
|
111
|
+
if (!results.agents) {
|
|
112
|
+
results.agents = await createAgentsMd(projectRoot);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
70
117
|
return results;
|
|
71
118
|
}
|
|
72
119
|
|
|
73
120
|
module.exports = {
|
|
74
121
|
createAgentsMd,
|
|
75
122
|
createClaudeMd,
|
|
123
|
+
createConfigFile,
|
|
76
124
|
setupMemoryFiles
|
|
77
125
|
};
|
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
const fs = require('fs').promises;
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
async function detectPlatform(projectRoot) {
|
|
6
|
-
const claudeDir = path.join(projectRoot, '.claude');
|
|
7
|
-
const opencodeDir = path.join(projectRoot, '.opencode');
|
|
8
|
-
|
|
9
|
-
const hasClaudeDir = await fs.access(claudeDir).then(() => true).catch(() => false);
|
|
10
|
-
const hasOpencodeDir = await fs.access(opencodeDir).then(() => true).catch(() => false);
|
|
11
|
-
|
|
12
|
-
const platforms = [];
|
|
13
|
-
if (hasClaudeDir) platforms.push('claude');
|
|
14
|
-
if (hasOpencodeDir) platforms.push('opencode');
|
|
15
|
-
|
|
16
|
-
if (platforms.length === 0) {
|
|
17
|
-
platforms.push('claude');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return platforms;
|
|
21
|
-
}
|
|
22
3
|
|
|
23
4
|
async function ensureDirectories(projectRoot, platform) {
|
|
24
5
|
const commandsDir = platform === 'claude'
|
|
@@ -29,6 +10,24 @@ async function ensureDirectories(projectRoot, platform) {
|
|
|
29
10
|
return commandsDir;
|
|
30
11
|
}
|
|
31
12
|
|
|
13
|
+
async function addFrontmatterToContent(content, filename) {
|
|
14
|
+
const descriptions = {
|
|
15
|
+
'init.md': 'Initialize Telos multi-agent system for this project',
|
|
16
|
+
'quick.md': 'Quick Telos initialization with auto-accepted AI proposals',
|
|
17
|
+
'validate.md': 'Validate current code against Telos purpose hierarchy',
|
|
18
|
+
'status.md': 'Show current Telos configuration and hierarchy',
|
|
19
|
+
'reset.md': 'Clear existing Telos installation and reinitialize'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const description = descriptions[filename] || 'Telos command';
|
|
23
|
+
|
|
24
|
+
if (content.startsWith('---')) {
|
|
25
|
+
return content;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return `---\ndescription: ${description}\n---\n\n${content}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
32
31
|
async function copyCommandFiles(projectRoot, platform) {
|
|
33
32
|
const sourceDir = path.join(__dirname, '../../.claude/commands/telos');
|
|
34
33
|
const targetDir = await ensureDirectories(projectRoot, platform);
|
|
@@ -47,7 +46,13 @@ async function copyCommandFiles(projectRoot, platform) {
|
|
|
47
46
|
const targetPath = path.join(targetDir, file);
|
|
48
47
|
|
|
49
48
|
try {
|
|
50
|
-
await fs.
|
|
49
|
+
let content = await fs.readFile(sourcePath, 'utf-8');
|
|
50
|
+
|
|
51
|
+
if (platform === 'opencode') {
|
|
52
|
+
content = await addFrontmatterToContent(content, file);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await fs.writeFile(targetPath, content);
|
|
51
56
|
results.push({ file, success: true, path: targetPath });
|
|
52
57
|
} catch (error) {
|
|
53
58
|
results.push({ file, success: false, error: error.message });
|
|
@@ -57,11 +62,13 @@ async function copyCommandFiles(projectRoot, platform) {
|
|
|
57
62
|
return results;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
async function installSlashCommands(projectRoot) {
|
|
61
|
-
const platforms =
|
|
65
|
+
async function installSlashCommands(projectRoot, selectedPlatforms = ['claude']) {
|
|
66
|
+
const platforms = Array.isArray(selectedPlatforms) ? selectedPlatforms : [selectedPlatforms];
|
|
67
|
+
|
|
68
|
+
const commandPlatforms = platforms.filter(p => p === 'claude' || p === 'opencode');
|
|
62
69
|
|
|
63
70
|
const allResults = [];
|
|
64
|
-
for (const platform of
|
|
71
|
+
for (const platform of commandPlatforms) {
|
|
65
72
|
const results = await copyCommandFiles(projectRoot, platform);
|
|
66
73
|
allResults.push({ platform, results });
|
|
67
74
|
}
|
|
@@ -70,7 +77,6 @@ async function installSlashCommands(projectRoot) {
|
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
module.exports = {
|
|
73
|
-
detectPlatform,
|
|
74
80
|
ensureDirectories,
|
|
75
81
|
copyCommandFiles,
|
|
76
82
|
installSlashCommands
|
package/package.json
CHANGED