telos-framework 0.9.2 → 0.10.1

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,609 @@
1
+ # Telos Initialization
2
+
3
+ You are initializing the **Telos Framework** - a 4-level spec-driven development
4
+ system for AI-assisted software development. Your role is to analyze this
5
+ codebase, set up the spec hierarchy, and guide the user through defining their
6
+ project specs.
7
+
8
+ ## The 4-Level Hierarchy
9
+
10
+ | Level | Name | Description |
11
+ | ----- | ---------- | ----------------------------------------------- |
12
+ | L4 | Purpose | Why the project exists + success metrics |
13
+ | L3 | Experience | User journeys, UX requirements, analytics needs |
14
+ | L2 | Contract | API contracts, component interfaces, boundaries |
15
+ | L1 | Function | Individual functions with TDD scenarios |
16
+
17
+ ## CRITICAL: One Question at a Time
18
+
19
+ **Throughout this initialization:**
20
+
21
+ - Ask ONLY ONE question at a time
22
+ - NEVER preview the next question or step
23
+ - STOP and WAIT for user response before proceeding
24
+
25
+ ## Important Note
26
+
27
+ Platform setup (config files) was already completed by running
28
+ `npx telos-framework init`. The `telos/` directory structure also exists. Your
29
+ job is to help the user define their specs at all 4 levels.
30
+
31
+ ---
32
+
33
+ ## Step 1: Analyze Codebase
34
+
35
+ Read and analyze the following to understand this project:
36
+
37
+ ### 1.1 Project Documentation
38
+
39
+ - **README.md** - Extract:
40
+ - Project purpose and description
41
+ - Target users/beneficiaries
42
+ - Goals and success metrics
43
+ - Technology stack
44
+
45
+ ### 1.2 Package Configuration
46
+
47
+ Check for and read (if exists):
48
+
49
+ - **package.json** (Node.js)
50
+ - **pyproject.toml** or **requirements.txt** (Python)
51
+ - **Cargo.toml** (Rust)
52
+ - **go.mod** (Go)
53
+
54
+ ### 1.3 Source Code Structure
55
+
56
+ Scan the primary source directory (src/, lib/, app/) to identify:
57
+
58
+ - Component patterns
59
+ - API structure
60
+ - Architectural patterns
61
+ - Database integration
62
+
63
+ ### 1.4 Existing Specs
64
+
65
+ Check if `telos/specs/L4-purpose/purpose.md` exists and read it.
66
+
67
+ ---
68
+
69
+ ## Step 2: Propose Purpose (L4)
70
+
71
+ Based on your analysis, propose the L4 Purpose spec:
72
+
73
+ ```
74
+ ═══════════════════════════════════════════════════════════════════════════
75
+ PROPOSED L4: PURPOSE
76
+ ═══════════════════════════════════════════════════════════════════════════
77
+
78
+ Project: [Project name from package.json or directory]
79
+
80
+ Purpose: [One sentence - why this project exists]
81
+
82
+ Beneficiaries: [Who benefits from this project]
83
+
84
+ Success Metrics:
85
+ - [Metric 1]
86
+ - [Metric 2]
87
+ - [Metric 3]
88
+
89
+ Constraints:
90
+ - [Any ethical or technical constraints]
91
+
92
+ ═══════════════════════════════════════════════════════════════════════════
93
+ ```
94
+
95
+ Then ask:
96
+
97
+ **Does this capture your project's purpose? Would you like to refine it?**
98
+
99
+ Options:
100
+
101
+ - "Accept" - Proceed with this purpose
102
+ - "Refine" - Let's adjust the purpose statement
103
+ - "Start over" - Re-analyze with different focus
104
+
105
+ **STOP and WAIT for user response.**
106
+
107
+ ---
108
+
109
+ ## Step 3: Update L4 Purpose Spec
110
+
111
+ Once the user accepts (or after refinements), update
112
+ `telos/specs/L4-purpose/purpose.md`:
113
+
114
+ ```markdown
115
+ <!-- telos-metadata
116
+ id: L4:purpose
117
+ level: 4
118
+ title: [Project Name]
119
+ -->
120
+
121
+ # L4: Purpose
122
+
123
+ ## Why This Project Exists
124
+
125
+ [Purpose statement]
126
+
127
+ ## Beneficiaries
128
+
129
+ [Who benefits]
130
+
131
+ ## Success Metrics
132
+
133
+ - [Metric 1]
134
+ - [Metric 2]
135
+ - [Metric 3]
136
+
137
+ ## Constraints
138
+
139
+ - [Constraint 1]
140
+ - [Constraint 2]
141
+
142
+ ## Technology Stack
143
+
144
+ - **Languages**: [Detected]
145
+ - **Frameworks**: [Detected]
146
+ - **Testing**: [Detected]
147
+ - **Linting**: [Detected]
148
+
149
+ ## Initialization
150
+
151
+ - **Date**: [Current date]
152
+ - **Method**: telos init
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Step 4: Define L3 Experiences (User Journeys)
158
+
159
+ Now ask about key user experiences. These are the main things users DO with the
160
+ application.
161
+
162
+ Ask:
163
+
164
+ **What are the key user journeys in your application?**
165
+
166
+ Examples of user journeys:
167
+
168
+ - "User signs up and creates their first project"
169
+ - "User searches for products and completes checkout"
170
+ - "Admin reviews and approves pending submissions"
171
+
172
+ List 2-5 key journeys (or say "skip" if you want to define these later):
173
+
174
+ **STOP and WAIT for user response.**
175
+
176
+ ### 4.1 Create L3 Experience Specs
177
+
178
+ For each journey the user provides, create a spec file in
179
+ `telos/specs/L3-experience/`:
180
+
181
+ **Filename**: Convert journey to kebab-case (e.g., `user-signup-flow.md`)
182
+
183
+ ```markdown
184
+ <!-- telos-metadata
185
+ id: L3:experience:[filename-without-extension]
186
+ level: 3
187
+ title: [Journey Title]
188
+ parent: L4:purpose
189
+ -->
190
+
191
+ # L3: [Journey Title]
192
+
193
+ ## Overview
194
+
195
+ [Brief description of this user journey]
196
+
197
+ ## User Story
198
+
199
+ As a [user type], I want to [action] so that [benefit].
200
+
201
+ ## Journey Steps
202
+
203
+ 1. **[Step 1 name]**
204
+ - User action: [What the user does]
205
+ - System response: [What happens]
206
+ - Success criteria: [How we know it worked]
207
+
208
+ 2. **[Step 2 name]**
209
+ - User action: [What the user does]
210
+ - System response: [What happens]
211
+ - Success criteria: [How we know it worked]
212
+
213
+ [Continue for each step...]
214
+
215
+ ## Edge Cases
216
+
217
+ - [Edge case 1]: [How it's handled]
218
+ - [Edge case 2]: [How it's handled]
219
+
220
+ ## Analytics Events
221
+
222
+ - `[event_name]`: [When it fires, what it tracks]
223
+
224
+ ## Related Specs
225
+
226
+ - L2: [Related contracts - to be defined]
227
+ - L1: [Related functions - to be defined]
228
+ ```
229
+
230
+ ### 4.2 Confirm Experiences
231
+
232
+ After creating the L3 specs, summarize:
233
+
234
+ ```
235
+ ═══════════════════════════════════════════════════════════════════════════
236
+ L3 EXPERIENCES CREATED
237
+ ═══════════════════════════════════════════════════════════════════════════
238
+
239
+ Created [N] user journey specs:
240
+
241
+ 1. telos/specs/L3-experience/[journey-1].md
242
+ "[Journey 1 title]"
243
+
244
+ 2. telos/specs/L3-experience/[journey-2].md
245
+ "[Journey 2 title]"
246
+
247
+ [etc...]
248
+
249
+ These journeys will guide your L2 contracts and L1 functions.
250
+ ═══════════════════════════════════════════════════════════════════════════
251
+ ```
252
+
253
+ ---
254
+
255
+ ## Step 5: Define L2 Contracts (APIs & Components)
256
+
257
+ Now analyze the codebase for existing contracts OR ask the user about them.
258
+
259
+ ### 5.1 Check for Existing Code
260
+
261
+ Scan for:
262
+
263
+ - API routes/endpoints (Express, FastAPI, Next.js API routes, etc.)
264
+ - React/Vue/Svelte components
265
+ - Service classes
266
+ - Database models/schemas
267
+
268
+ ### 5.2 If Code Exists → Propose Contracts
269
+
270
+ If you found existing APIs/components, propose L2 specs:
271
+
272
+ ```
273
+ ═══════════════════════════════════════════════════════════════════════════
274
+ DETECTED L2 CONTRACTS
275
+ ═══════════════════════════════════════════════════════════════════════════
276
+
277
+ Based on your codebase, I found these contracts:
278
+
279
+ APIs:
280
+ - POST /api/auth/login → api-auth-login
281
+ - GET /api/users/:id → api-users-get
282
+ [etc...]
283
+
284
+ Components:
285
+ - LoginForm → component-login-form
286
+ - UserProfile → component-user-profile
287
+ [etc...]
288
+
289
+ Should I create L2 specs for these? (yes/no/select specific ones)
290
+ ═══════════════════════════════════════════════════════════════════════════
291
+ ```
292
+
293
+ **STOP and WAIT for user response.**
294
+
295
+ ### 5.3 If No Code OR Greenfield → Ask User
296
+
297
+ If no existing code found, ask:
298
+
299
+ **What are the main APIs or components you plan to build?**
300
+
301
+ Examples:
302
+
303
+ - "Authentication API (login, logout, register)"
304
+ - "Product listing component"
305
+ - "Payment processing service"
306
+
307
+ List your key contracts (or say "skip" to define later):
308
+
309
+ **STOP and WAIT for user response.**
310
+
311
+ ### 5.4 Create L2 Contract Specs
312
+
313
+ For each contract, create a spec file in `telos/specs/L2-contract/`:
314
+
315
+ **Filename**: `api-[name].md` or `component-[name].md`
316
+
317
+ ````markdown
318
+ <!-- telos-metadata
319
+ id: L2:contract:[filename-without-extension]
320
+ level: 2
321
+ title: [Contract Title]
322
+ parent: L3:experience:[related-journey]
323
+ -->
324
+
325
+ # L2: [Contract Title]
326
+
327
+ ## Overview
328
+
329
+ [What this API/component does]
330
+
331
+ ## Interface
332
+
333
+ ### [For APIs]
334
+
335
+ **Endpoint:** `[METHOD] /api/[path]`
336
+
337
+ **Request:**
338
+
339
+ ```json
340
+ {
341
+ "field": "type"
342
+ }
343
+ ```
344
+ ````
345
+
346
+ **Response:**
347
+
348
+ ```json
349
+ {
350
+ "field": "type"
351
+ }
352
+ ```
353
+
354
+ **Errors:**
355
+
356
+ - 400: [When/why]
357
+ - 401: [When/why]
358
+ - 404: [When/why]
359
+
360
+ ### [For Components]
361
+
362
+ **Props:**
363
+
364
+ ```typescript
365
+ interface [ComponentName]Props {
366
+ prop1: type;
367
+ prop2: type;
368
+ onEvent?: (data: type) => void;
369
+ }
370
+ ```
371
+
372
+ ## Behavior
373
+
374
+ - [Behavior 1]
375
+ - [Behavior 2]
376
+
377
+ ## Related Specs
378
+
379
+ - L3: [Parent experience]
380
+ - L1: [Functions needed - to be defined]
381
+
382
+ ```
383
+ ### 5.5 Confirm Contracts
384
+
385
+ After creating the L2 specs, summarize:
386
+ ```
387
+
388
+ ═══════════════════════════════════════════════════════════════════════════ L2
389
+ CONTRACTS CREATED
390
+ ═══════════════════════════════════════════════════════════════════════════
391
+
392
+ Created [N] contract specs:
393
+
394
+ 1. telos/specs/L2-contract/[contract-1].md "[Contract 1 title]"
395
+
396
+ 2. telos/specs/L2-contract/[contract-2].md "[Contract 2 title]"
397
+
398
+ [etc...]
399
+ ═══════════════════════════════════════════════════════════════════════════
400
+
401
+ ```
402
+ ---
403
+
404
+ ## Step 6: Define L1 Functions
405
+
406
+ Now identify the key functions needed to implement the L2 contracts.
407
+
408
+ ### 6.1 Check for Existing Functions
409
+
410
+ Scan for functions/methods in:
411
+
412
+ - `src/`, `lib/`, `app/` directories
413
+ - Look for exported functions, class methods
414
+ - Focus on business logic, not utility functions
415
+
416
+ ### 6.2 If Functions Exist → Propose L1 Specs
417
+ ```
418
+
419
+ ═══════════════════════════════════════════════════════════════════════════
420
+ DETECTED L1 FUNCTIONS
421
+ ═══════════════════════════════════════════════════════════════════════════
422
+
423
+ Found key functions that need specs:
424
+
425
+ From src/auth/:
426
+
427
+ - validateToken() → L1:function:src/auth:validateToken
428
+ - hashPassword() → L1:function:src/auth:hashPassword
429
+
430
+ From src/users/:
431
+
432
+ - createUser() → L1:function:src/users:createUser
433
+ - getUserById() → L1:function:src/users:getUserById
434
+
435
+ [etc...]
436
+
437
+ Should I create L1 specs for these? (yes/no/select specific ones)
438
+ ═══════════════════════════════════════════════════════════════════════════
439
+
440
+ ````
441
+ **STOP and WAIT for user response.**
442
+
443
+ ### 6.3 If No Functions OR Greenfield → Ask User
444
+
445
+ If no existing functions found, ask:
446
+
447
+ **What are the core functions your application needs?**
448
+
449
+ Think about the L2 contracts you defined. What functions implement them?
450
+
451
+ Examples:
452
+
453
+ - "validateToken - checks if JWT is valid"
454
+ - "processPayment - handles Stripe charges"
455
+ - "sendNotification - sends push/email notifications"
456
+
457
+ List key functions (or say "skip" to define later):
458
+
459
+ **STOP and WAIT for user response.**
460
+
461
+ ### 6.4 Create L1 Function Specs
462
+
463
+ For each function, create a spec file in `telos/specs/L1-function/`:
464
+
465
+ **Filename**: `[module]-[function-name].md`
466
+
467
+ ```markdown
468
+ <!-- telos-metadata
469
+ id: L1:function:[path]:[functionName]
470
+ level: 1
471
+ title: [functionName]
472
+ parent: L2:contract:[related-contract]
473
+ -->
474
+
475
+ # L1: [functionName]
476
+
477
+ ## Purpose
478
+
479
+ [What this function does and why]
480
+
481
+ ## Signature
482
+
483
+ ```typescript
484
+ function [functionName](
485
+ param1: Type,
486
+ param2: Type
487
+ ): ReturnType
488
+ ````
489
+
490
+ ## Parameters
491
+
492
+ | Name | Type | Description |
493
+ | ------ | ---- | ----------- |
494
+ | param1 | Type | Description |
495
+ | param2 | Type | Description |
496
+
497
+ ## Returns
498
+
499
+ | Type | Description |
500
+ | ---------- | --------------- |
501
+ | ReturnType | What it returns |
502
+
503
+ ## TDD Scenarios
504
+
505
+ ### Scenario: [Happy path name]
506
+
507
+ ```gherkin
508
+ Given [precondition]
509
+ When [action]
510
+ Then [expected result]
511
+ ```
512
+
513
+ ### Scenario: [Error case name]
514
+
515
+ ```gherkin
516
+ Given [precondition]
517
+ When [action]
518
+ Then [expected error]
519
+ ```
520
+
521
+ ### Scenario: [Edge case name]
522
+
523
+ ```gherkin
524
+ Given [edge condition]
525
+ When [action]
526
+ Then [expected behavior]
527
+ ```
528
+
529
+ ## Related Specs
530
+
531
+ - L2: [Parent contract]
532
+
533
+ ```
534
+ ### 6.5 Confirm Functions
535
+
536
+ After creating the L1 specs, summarize:
537
+ ```
538
+
539
+ ═══════════════════════════════════════════════════════════════════════════ L1
540
+ FUNCTIONS CREATED
541
+ ═══════════════════════════════════════════════════════════════════════════
542
+
543
+ Created [N] function specs:
544
+
545
+ 1. telos/specs/L1-function/[function-1].md "[function1Name]" - [brief
546
+ description]
547
+
548
+ 2. telos/specs/L1-function/[function-2].md "[function2Name]" - [brief
549
+ description]
550
+
551
+ [etc...]
552
+ ═══════════════════════════════════════════════════════════════════════════
553
+
554
+ ```
555
+ ---
556
+
557
+ ## Step 7: Update TELOS.md
558
+
559
+ Update `telos/TELOS.md` with all the specs created:
560
+
561
+ - **User Experiences** section listing all L3 journeys
562
+ - **Spec Levels** table with correct counts for all levels
563
+ - Verify all parent-child relationships are correct
564
+
565
+ ---
566
+
567
+ ## Step 8: Final Summary
568
+
569
+ After saving all specs, provide the final summary:
570
+
571
+ ---
572
+
573
+ ✅ **Telos initialization complete!**
574
+
575
+ **Your project now has:**
576
+
577
+ - `telos/specs/L4-purpose/purpose.md` - Your project purpose
578
+ - `telos/specs/L3-experience/*.md` - [N] user journey specs
579
+ - `telos/specs/L2-contract/*.md` - [N] API/component contracts
580
+ - `telos/specs/L1-function/*.md` - [N] function specs with TDD scenarios
581
+ - `telos/TELOS.md` - Entry point with workflow guidance
582
+
583
+ **Spec Summary:**
584
+
585
+ | Level | Count | Description |
586
+ | ----- | ----- | ----------- |
587
+ | L4 | 1 | Purpose |
588
+ | L3 | [N] | Experiences |
589
+ | L2 | [N] | Contracts |
590
+ | L1 | [N] | Functions |
591
+
592
+ **Next steps:**
593
+
594
+ 1. Generate tests from L1 specs
595
+ 2. Implement code with `@telos` annotations
596
+ 3. Validate before commits
597
+ 4. For new features: Follow the workflow in `telos/TELOS.md`
598
+
599
+ ---
600
+
601
+ ## Tips
602
+
603
+ - If README is missing or vague, ask user for clarification
604
+ - For empty/greenfield projects, focus on defining clear specs before coding
605
+ - For brownfield projects, propose specs based on detected code
606
+ - Be conversational - this is a dialogue, not a survey
607
+ - Users can say "skip" at any level to define specs later
608
+ - Remind users that specs come before code
609
+ ```