@tecet/ollm 0.1.4-b → 0.1.5

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 (66) hide show
  1. package/docs/README.md +3 -410
  2. package/package.json +2 -2
  3. package/docs/Context/CheckpointFlowDiagram.md +0 -673
  4. package/docs/Context/ContextArchitecture.md +0 -898
  5. package/docs/Context/ContextCompression.md +0 -1102
  6. package/docs/Context/ContextManagment.md +0 -750
  7. package/docs/Context/Index.md +0 -209
  8. package/docs/Context/README.md +0 -390
  9. package/docs/DevelopmentRoadmap/Index.md +0 -238
  10. package/docs/DevelopmentRoadmap/OLLM-CLI_Releases.md +0 -419
  11. package/docs/DevelopmentRoadmap/PlanedFeatures.md +0 -448
  12. package/docs/DevelopmentRoadmap/README.md +0 -174
  13. package/docs/DevelopmentRoadmap/Roadmap.md +0 -572
  14. package/docs/DevelopmentRoadmap/RoadmapVisual.md +0 -372
  15. package/docs/Hooks/Architecture.md +0 -885
  16. package/docs/Hooks/Index.md +0 -244
  17. package/docs/Hooks/KeyboardShortcuts.md +0 -248
  18. package/docs/Hooks/Protocol.md +0 -817
  19. package/docs/Hooks/README.md +0 -403
  20. package/docs/Hooks/UserGuide.md +0 -1483
  21. package/docs/Hooks/VisualGuide.md +0 -598
  22. package/docs/Index.md +0 -506
  23. package/docs/Installation.md +0 -586
  24. package/docs/Introduction.md +0 -367
  25. package/docs/LLM Models/Index.md +0 -239
  26. package/docs/LLM Models/LLM_GettingStarted.md +0 -748
  27. package/docs/LLM Models/LLM_Index.md +0 -701
  28. package/docs/LLM Models/LLM_MemorySystem.md +0 -337
  29. package/docs/LLM Models/LLM_ModelCompatibility.md +0 -499
  30. package/docs/LLM Models/LLM_ModelsArchitecture.md +0 -933
  31. package/docs/LLM Models/LLM_ModelsCommands.md +0 -839
  32. package/docs/LLM Models/LLM_ModelsConfiguration.md +0 -1094
  33. package/docs/LLM Models/LLM_ModelsList.md +0 -1071
  34. package/docs/LLM Models/LLM_ModelsList.md.backup +0 -400
  35. package/docs/LLM Models/README.md +0 -355
  36. package/docs/MCP/MCP_Architecture.md +0 -1086
  37. package/docs/MCP/MCP_Commands.md +0 -1111
  38. package/docs/MCP/MCP_GettingStarted.md +0 -590
  39. package/docs/MCP/MCP_Index.md +0 -524
  40. package/docs/MCP/MCP_Integration.md +0 -866
  41. package/docs/MCP/MCP_Marketplace.md +0 -160
  42. package/docs/MCP/README.md +0 -415
  43. package/docs/Prompts System/Architecture.md +0 -760
  44. package/docs/Prompts System/Index.md +0 -223
  45. package/docs/Prompts System/PromptsRouting.md +0 -1047
  46. package/docs/Prompts System/PromptsTemplates.md +0 -1102
  47. package/docs/Prompts System/README.md +0 -389
  48. package/docs/Prompts System/SystemPrompts.md +0 -856
  49. package/docs/Quickstart.md +0 -535
  50. package/docs/Tools/Architecture.md +0 -884
  51. package/docs/Tools/GettingStarted.md +0 -624
  52. package/docs/Tools/Index.md +0 -216
  53. package/docs/Tools/ManifestReference.md +0 -141
  54. package/docs/Tools/README.md +0 -440
  55. package/docs/Tools/UserGuide.md +0 -773
  56. package/docs/Troubleshooting.md +0 -1265
  57. package/docs/UI&Settings/Architecture.md +0 -729
  58. package/docs/UI&Settings/ColorASCII.md +0 -34
  59. package/docs/UI&Settings/Commands.md +0 -755
  60. package/docs/UI&Settings/Configuration.md +0 -872
  61. package/docs/UI&Settings/Index.md +0 -293
  62. package/docs/UI&Settings/Keybinds.md +0 -372
  63. package/docs/UI&Settings/README.md +0 -278
  64. package/docs/UI&Settings/Terminal.md +0 -637
  65. package/docs/UI&Settings/Themes.md +0 -604
  66. package/docs/UI&Settings/UIGuide.md +0 -550
@@ -1,760 +0,0 @@
1
- # Prompts System Architecture
2
-
3
- **Last Updated:** January 26, 2026
4
-
5
- This document provides complete technical documentation of the Prompts System architecture, including system prompt construction, template engine, routing logic, and goal management.
6
-
7
- ---
8
-
9
- ## Table of Contents
10
-
11
- - [System Overview](#system-overview)
12
- - [Component Architecture](#component-architecture)
13
- - [System Prompt Construction](#system-prompt-construction)
14
- - [Template System](#template-system)
15
- - [Goal Management](#goal-management)
16
- - [Operational Modes](#operational-modes)
17
- - [Prompt Registry](#prompt-registry)
18
- - [Data Flow](#data-flow)
19
- - [Configuration](#configuration)
20
- - [Events](#events)
21
- - [Best Practices](#best-practices)
22
-
23
- ---
24
-
25
- ## System Overview
26
-
27
- The Prompts System manages system prompts that guide LLM behavior. It provides tier-specific prompts for different context sizes and mode-specific prompts for different operational modes.
28
-
29
- ### Core Responsibility
30
-
31
- Build and maintain the system prompt that defines LLM behavior.
32
-
33
- ### Key Principles
34
-
35
- 1. **ContextManager Ownership** - ContextManager is the ONLY owner of system prompts
36
- 2. **Tier-Based Scaling** - Prompts scale with context size
37
- 3. **Mode-Specific Behavior** - Different modes have different prompts
38
- 4. **Goal-Oriented** - Goals guide LLM focus and behavior
39
- 5. **Never Compress Goals** - Goals always remain in system prompt
40
-
41
- ---
42
-
43
- ## Component Architecture
44
-
45
- ### Component Hierarchy
46
-
47
- ```
48
- ContextManager (Owner)
49
-
50
- PromptOrchestrator (Coordinator)
51
- ├─ TieredPromptStore (Mode+Tier Templates)
52
- ├─ PromptRegistry (Core Prompts)
53
- ├─ SystemPromptBuilder (Assembly)
54
- └─ GoalManager (Goal Tracking)
55
- ```
56
-
57
- ### Component Diagram
58
-
59
- ```mermaid
60
- graph TB
61
- CM[ContextManager]
62
- PO[PromptOrchestrator]
63
- TPS[TieredPromptStore]
64
- PR[PromptRegistry]
65
- SPB[SystemPromptBuilder]
66
- GM[GoalManager]
67
-
68
- CM -->|owns| PO
69
- PO -->|loads templates| TPS
70
- PO -->|gets core prompts| PR
71
- PO -->|builds prompt| SPB
72
- PO -->|gets active goal| GM
73
-
74
- SPB -->|queries| PR
75
- SPB -->|formats| GM
76
-
77
- style CM fill:#e1f5ff
78
- style PO fill:#fff4e1
79
- style TPS fill:#f0f0f0
80
- style PR fill:#f0f0f0
81
- style SPB fill:#f0f0f0
82
- style GM fill:#f0f0f0
83
- ```
84
-
85
- ---
86
-
87
- ## Component Details
88
-
89
- ### 1. PromptOrchestrator
90
-
91
- **Location:** `packages/core/src/context/promptOrchestrator.ts`
92
-
93
- **Role:** Coordinates prompt loading and system prompt construction
94
-
95
- **Responsibilities:**
96
-
97
- - Loads tiered prompt templates from filesystem
98
- - Resolves mode+tier combinations
99
- - Calculates token budgets per tier
100
- - Orchestrates SystemPromptBuilder
101
- - Updates system prompt in conversation context
102
-
103
- **Key Methods:**
104
-
105
- ```typescript
106
- class PromptOrchestrator {
107
- // Get system prompt for mode and tier
108
- getSystemPromptForTierAndMode(mode: OperationalMode, tier: ContextTier): string;
109
-
110
- // Get token budget for tier
111
- getSystemPromptTokenBudget(tier: ContextTier): number;
112
-
113
- // Update system prompt in context
114
- updateSystemPrompt(options: {
115
- mode: OperationalMode;
116
- tier: ContextTier;
117
- activeSkills: string[];
118
- activeGoal: Goal | null;
119
- currentContext: ConversationContext;
120
- contextPool: ContextPool;
121
- }): void;
122
- }
123
- ```
124
-
125
- ### 2. TieredPromptStore
126
-
127
- **Location:** `packages/core/src/prompts/tieredPromptStore.ts`
128
-
129
- **Role:** Loads and stores mode+tier prompt templates from filesystem
130
-
131
- **Key Methods:**
132
-
133
- ```typescript
134
- class TieredPromptStore {
135
- // Load all templates from filesystem
136
- load(): void;
137
-
138
- // Get template for mode and tier
139
- get(mode: OperationalMode, tier: ContextTier): string | undefined;
140
- }
141
- ```
142
-
143
- **Template Loading:**
144
-
145
- ```
146
- 1. Scan templates/ directory
147
- 2. Load all mode+tier combinations
148
- 3. Store in memory map
149
- 4. Fallback to Developer Tier 3 if not found
150
- ```
151
-
152
- ### 3. PromptRegistry
153
-
154
- **Location:** `packages/core/src/prompts/PromptRegistry.ts`
155
-
156
- **Role:** Registry for core prompts (mandates, sanity checks, skills)
157
-
158
- **Key Methods:**
159
-
160
- ```typescript
161
- class PromptRegistry {
162
- // Register a prompt
163
- register(definition: PromptDefinition): void;
164
-
165
- // Get prompt by ID
166
- get(id: string): RegisteredPrompt | undefined;
167
-
168
- // Get prompts by tag
169
- getByTag(tag: string): RegisteredPrompt[];
170
-
171
- // Get prompts by source
172
- getBySource(source: 'static' | 'mcp' | 'config'): RegisteredPrompt[];
173
-
174
- // Clear MCP prompts when server disconnects
175
- clearMcpPrompts(serverName: string): void;
176
- }
177
- ```
178
-
179
- **Registered Prompt Structure:**
180
-
181
- ```typescript
182
- interface RegisteredPrompt {
183
- id: string;
184
- name: string;
185
- content: string;
186
- description?: string;
187
- requiredTools?: string[];
188
- tags?: string[];
189
- source: 'static' | 'mcp' | 'config';
190
- serverName?: string; // If from MCP
191
- registeredAt: number;
192
- }
193
- ```
194
-
195
- ### 4. SystemPromptBuilder
196
-
197
- **Location:** `packages/core/src/context/SystemPromptBuilder.ts`
198
-
199
- **Role:** Assembles final system prompt from registry components
200
-
201
- **Assembly Order:**
202
-
203
- ```
204
- 1. Core Mandates (from registry: 'core-mandates')
205
- 2. Active Goals (from goal manager - never compressed)
206
- 3. Active Skills (from registry by skill IDs)
207
- 4. Sanity Checks (optional, from registry: 'sanity-reality-check')
208
- 5. Additional Instructions (custom user instructions)
209
- ```
210
-
211
- **Key Methods:**
212
-
213
- ```typescript
214
- class SystemPromptBuilder {
215
- // Build complete system prompt
216
- build(options: {
217
- skills: string[];
218
- goal: Goal | null;
219
- useSanityChecks: boolean;
220
- additionalInstructions?: string;
221
- }): string;
222
- }
223
- ```
224
-
225
- ### 5. GoalManager
226
-
227
- **Location:** `packages/core/src/context/goalManager.ts`
228
-
229
- **Role:** Manages goals, checkpoints, decisions, and artifacts
230
-
231
- **Key Methods:**
232
-
233
- ```typescript
234
- class GoalManager {
235
- // Goal lifecycle
236
- createGoal(description: string, priority: 'high' | 'medium' | 'low'): Goal;
237
- getActiveGoal(): Goal | null;
238
- pauseGoal(goalId: string): void;
239
- completeGoal(goalId: string, summary: string): void;
240
-
241
- // Checkpoints
242
- createCheckpoint(goalId: string, description: string): Checkpoint;
243
- updateCheckpoint(goalId: string, checkpointId: string, status: CheckpointStatus): void;
244
-
245
- // Decisions
246
- recordDecision(goalId: string, description: string, rationale: string): Decision;
247
- lockDecision(goalId: string, decisionId: string): void;
248
-
249
- // Artifacts
250
- recordArtifact(goalId: string, type: ArtifactType, path: string, action: ArtifactAction): void;
251
-
252
- // Query
253
- getGoalProgress(goalId: string): { completed: number; total: number; percentage: number };
254
- getGoalHistory(): Goal[];
255
- }
256
- ```
257
-
258
- ---
259
-
260
- ## System Prompt Construction
261
-
262
- ### Prompt Tiers
263
-
264
- Prompt tiers correspond to context tiers and determine the detail level of system prompts.
265
-
266
- | Tier | Context Size | Prompt Budget | % of Context |
267
- | --------------------- | ------------ | ------------- | ------------ |
268
- | **Tier 1 (Minimal)** | 2K, 4K | 200 tokens | 5-10% |
269
- | **Tier 2 (Basic)** | 8K | 500 tokens | 6.3% |
270
- | **Tier 3 (Standard)** | 16K | 1000 tokens | 6.3% |
271
- | **Tier 4 (Premium)** | 32K | 1500 tokens | 4.7% |
272
- | **Tier 5 (Ultra)** | 64K, 128K | 1500 tokens | 1.2-2.3% |
273
-
274
- **Principle:** Larger contexts can afford more detailed prompts without sacrificing user content space.
275
-
276
- ### Why Scale Prompts by Tier?
277
-
278
- **Tier 1 (2-4K):** Minimal context
279
-
280
- - ~200 tokens (5% of 4K)
281
- - Essential behavior only
282
- - No verbose instructions
283
- - Focus on core capabilities
284
-
285
- **Tier 2 (8K):** Basic context
286
-
287
- - ~500 tokens (6.3% of 8K)
288
- - Detailed guidance
289
- - Basic tool instructions
290
- - Mode-specific behavior
291
-
292
- **Tier 3 (16K):** Standard context ⭐
293
-
294
- - ~1000 tokens (6.3% of 16K)
295
- - Comprehensive instructions
296
- - Full tool documentation
297
- - Mode-specific strategies
298
-
299
- **Tier 4 (32K):** Premium context
300
-
301
- - ~1500 tokens (4.7% of 32K)
302
- - Expert-level guidance
303
- - Advanced patterns
304
- - Optimization strategies
305
-
306
- **Tier 5 (64-128K):** Ultra context
307
-
308
- - ~1500 tokens (1.2% of 131K)
309
- - Maximum sophistication
310
- - Complex reasoning patterns
311
- - Multi-step workflows
312
-
313
- ### Prompt Construction Flow
314
-
315
- ```mermaid
316
- sequenceDiagram
317
- participant CM as ContextManager
318
- participant PO as PromptOrchestrator
319
- participant TPS as TieredPromptStore
320
- participant GM as GoalManager
321
- participant SPB as SystemPromptBuilder
322
- participant PR as PromptRegistry
323
-
324
- CM->>PO: updateSystemPrompt(mode, tier, skills, goal)
325
- PO->>TPS: get(mode, tier)
326
- TPS-->>PO: tierPrompt
327
- PO->>GM: getActiveGoal()
328
- GM-->>PO: activeGoal
329
- PO->>SPB: build(skills, goal)
330
- SPB->>PR: get('core-mandates')
331
- PR-->>SPB: mandates
332
- SPB->>SPB: format goal
333
- SPB->>PR: get(skillId) for each skill
334
- PR-->>SPB: skills
335
- SPB->>PR: get('sanity-reality-check')
336
- PR-->>SPB: sanityChecks
337
- SPB-->>PO: corePrompt
338
- PO->>PO: combine tierPrompt + corePrompt
339
- PO->>CM: systemPrompt
340
- CM->>CM: inject into context.messages[0]
341
- ```
342
-
343
- ---
344
-
345
- ## Template System
346
-
347
- ### Filesystem Structure
348
-
349
- ```
350
- packages/core/src/prompts/templates/
351
- ├── assistant/
352
- │ ├── tier1.txt
353
- │ ├── tier2.txt
354
- │ ├── tier3.txt
355
- │ ├── tier4.txt
356
- │ └── tier5.txt
357
- ├── developer/
358
- │ ├── tier1.txt
359
- │ ├── tier2.txt
360
- │ ├── tier3.txt
361
- │ ├── tier4.txt
362
- │ └── tier5.txt
363
- ├── planning/
364
- │ ├── tier1.txt
365
- │ ├── tier2.txt
366
- │ ├── tier3.txt
367
- │ ├── tier4.txt
368
- │ └── tier5.txt
369
- ├── debugger/
370
- │ ├── tier1.txt
371
- │ ├── tier2.txt
372
- │ ├── tier3.txt
373
- │ ├── tier4.txt
374
- │ └── tier5.txt
375
- ├── user/
376
- │ ├── tier1.txt
377
- │ ├── tier2.txt
378
- │ ├── tier3.txt
379
- │ ├── tier4.txt
380
- │ └── tier5.txt
381
- ├── mandates.ts (Core behavior)
382
- ├── sanity.ts (Reality checks)
383
- ├── identity.ts (Agent identity)
384
- └── stateSnapshot.ts (State tracking)
385
- ```
386
-
387
- ### Fallback Strategy
388
-
389
- ```
390
- 1. Try: packages/core/dist/prompts/templates/
391
- 2. Fallback: packages/core/src/prompts/templates/
392
- 3. Use: Developer Tier 3 as last resort
393
- ```
394
-
395
- ### Template Loading
396
-
397
- ```typescript
398
- // TieredPromptStore loads templates at startup
399
- class TieredPromptStore {
400
- private templates: Map<string, string> = new Map();
401
-
402
- load(): void {
403
- const modes = ['assistant', 'developer', 'planning', 'debugger', 'user'];
404
- const tiers = [1, 2, 3, 4, 5];
405
-
406
- for (const mode of modes) {
407
- for (const tier of tiers) {
408
- const key = `${mode}-tier${tier}`;
409
- const content = this.loadTemplate(mode, tier);
410
- this.templates.set(key, content);
411
- }
412
- }
413
- }
414
-
415
- get(mode: string, tier: number): string | undefined {
416
- const key = `${mode}-tier${tier}`;
417
- return this.templates.get(key);
418
- }
419
- }
420
- ```
421
-
422
- ---
423
-
424
- ## Goal Management
425
-
426
- ### Goal Structure
427
-
428
- ```typescript
429
- interface Goal {
430
- id: string;
431
- description: string;
432
- priority: 'high' | 'medium' | 'low';
433
- status: 'active' | 'paused' | 'completed';
434
- createdAt: Date;
435
- completedAt?: Date;
436
- checkpoints: Checkpoint[];
437
- decisions: Decision[];
438
- artifacts: Artifact[];
439
- }
440
-
441
- interface Checkpoint {
442
- id: string;
443
- description: string;
444
- status: 'pending' | 'in-progress' | 'completed';
445
- completedAt?: Date;
446
- }
447
-
448
- interface Decision {
449
- id: string;
450
- description: string;
451
- rationale: string;
452
- locked: boolean; // Locked decisions cannot be changed
453
- }
454
-
455
- interface Artifact {
456
- type: 'file' | 'test' | 'documentation';
457
- path: string;
458
- action: 'created' | 'modified' | 'deleted';
459
- }
460
- ```
461
-
462
- ### Goal Lifecycle
463
-
464
- ```mermaid
465
- stateDiagram-v2
466
- [*] --> Active: createGoal()
467
- Active --> InProgress: work on checkpoints
468
- InProgress --> Active: checkpoint completed
469
- Active --> Paused: pauseGoal()
470
- Paused --> Active: resumeGoal()
471
- Active --> Completed: completeGoal()
472
- Completed --> [*]
473
- ```
474
-
475
- ### Goal in System Prompt
476
-
477
- Goals are injected into the system prompt between mandates and skills:
478
-
479
- ```
480
- [Core Mandates]
481
-
482
- [Active Goal]
483
- CURRENT GOAL: Implement user authentication system
484
- Priority: High
485
- Status: Active
486
-
487
- Checkpoints:
488
- ✅ 1. Design authentication flow
489
- ✅ 2. Implement login endpoint
490
- 🔄 3. Add JWT token generation (IN PROGRESS)
491
- ⏳ 4. Create user registration
492
- ⏳ 5. Add password hashing
493
-
494
- Key Decisions:
495
- 🔒 Use JWT for authentication (locked)
496
- 🔒 Store tokens in httpOnly cookies (locked)
497
- - Use bcrypt for password hashing
498
-
499
- Artifacts:
500
- - Created: src/auth/login.ts
501
- - Created: src/auth/jwt.ts
502
- - Modified: src/routes/api.ts
503
-
504
- [Active Skills]
505
- [Sanity Checks]
506
- [Additional Instructions]
507
- ```
508
-
509
- ### Goal Markers
510
-
511
- The LLM can use special markers to update goals:
512
-
513
- ```
514
- [GOAL] Implement user authentication system
515
- [CHECKPOINT] Design authentication flow - COMPLETED
516
- [DECISION] Use JWT for authentication - LOCKED
517
- [ARTIFACT] Created src/auth/login.ts
518
- [NEXT] Implement JWT token generation
519
- ```
520
-
521
- These markers are parsed and used to update the goal structure automatically.
522
-
523
- ---
524
-
525
- ## Operational Modes
526
-
527
- ### Mode Profiles
528
-
529
- **Assistant Mode** (Default)
530
-
531
- - General-purpose conversational AI
532
- - Balanced between helpfulness and safety
533
- - Moderate tool usage
534
- - Template: `templates/assistant/tier{1-5}.txt`
535
-
536
- **Developer Mode**
537
-
538
- - Code-focused assistance
539
- - Aggressive tool usage
540
- - Technical language
541
- - Template: `templates/developer/tier{1-5}.txt`
542
-
543
- **Planning Mode**
544
-
545
- - Project planning and architecture
546
- - Goal-oriented thinking
547
- - Strategic recommendations
548
- - Template: `templates/planning/tier{1-5}.txt`
549
-
550
- **Debugger Mode**
551
-
552
- - Error analysis and troubleshooting
553
- - Systematic debugging approach
554
- - Root cause analysis
555
- - Template: `templates/debugger/tier{1-5}.txt`
556
-
557
- **User Mode** (Custom)
558
-
559
- - User-defined behavior
560
- - Customizable prompt templates
561
- - Same structure as Assistant mode (default copy)
562
- - Template: `templates/user/tier{1-5}.txt`
563
-
564
- ### Mode Switching
565
-
566
- ```typescript
567
- // ContextManager handles mode switching
568
- class ContextManager {
569
- setMode(newMode: OperationalMode): void {
570
- this.currentMode = newMode;
571
-
572
- // Update system prompt with new mode
573
- this.promptOrchestrator.updateSystemPrompt({
574
- mode: newMode,
575
- tier: this.effectivePromptTier,
576
- activeSkills: this.activeSkills,
577
- activeGoal: this.goalManager.getActiveGoal(),
578
- currentContext: this.currentContext,
579
- contextPool: this.contextPool,
580
- });
581
-
582
- this.emit('mode-changed', newMode);
583
- }
584
- }
585
- ```
586
-
587
- ---
588
-
589
- ## Prompt Registry
590
-
591
- ### Prompt Sources
592
-
593
- - **static:** Built-in prompts (mandates, sanity)
594
- - **mcp:** Prompts from MCP servers
595
- - **config:** User-defined prompts
596
-
597
- ### MCP Integration
598
-
599
- MCP servers can register prompts dynamically:
600
-
601
- ```typescript
602
- // MCP server registers prompt
603
- promptRegistry.register({
604
- id: 'github-workflow',
605
- name: 'GitHub Workflow',
606
- content: 'Instructions for GitHub operations...',
607
- source: 'mcp',
608
- serverName: 'github-mcp',
609
- tags: ['skill', 'github'],
610
- });
611
-
612
- // When server disconnects, clear its prompts
613
- promptRegistry.clearMcpPrompts('github-mcp');
614
- ```
615
-
616
- ---
617
-
618
- ## Data Flow
619
-
620
- ### Startup Flow
621
-
622
- ```mermaid
623
- sequenceDiagram
624
- participant App as Application
625
- participant CM as ContextManager
626
- participant PO as PromptOrchestrator
627
- participant TPS as TieredPromptStore
628
-
629
- App->>CM: start()
630
- CM->>CM: detect VRAM
631
- CM->>CM: determine context tier
632
- CM->>PO: updateSystemPrompt()
633
- PO->>TPS: load templates
634
- TPS-->>PO: templates loaded
635
- PO->>PO: build system prompt
636
- PO-->>CM: system prompt ready
637
- CM->>CM: inject into context
638
- CM-->>App: ready
639
- ```
640
-
641
- ### Mode Change Flow
642
-
643
- ```mermaid
644
- sequenceDiagram
645
- participant User
646
- participant CM as ContextManager
647
- participant PO as PromptOrchestrator
648
- participant TPS as TieredPromptStore
649
-
650
- User->>CM: /mode developer
651
- CM->>CM: update currentMode
652
- CM->>PO: updateSystemPrompt(developer, tier)
653
- PO->>TPS: get(developer, tier)
654
- TPS-->>PO: developer template
655
- PO->>PO: rebuild system prompt
656
- PO-->>CM: new system prompt
657
- CM->>CM: replace in context
658
- CM-->>User: mode changed
659
- ```
660
-
661
- ---
662
-
663
- ## Configuration
664
-
665
- ### System Prompt Config
666
-
667
- ```typescript
668
- interface SystemPromptConfig {
669
- interactive: boolean;
670
- useSanityChecks?: boolean;
671
- agentName?: string;
672
- additionalInstructions?: string;
673
- skills?: string[]; // Skill IDs to include
674
- goal?: Goal; // Active goal to include
675
- }
676
- ```
677
-
678
- ### Default Values
679
-
680
- ```typescript
681
- const DEFAULT_CONFIG = {
682
- interactive: true,
683
- useSanityChecks: true,
684
- agentName: 'Assistant',
685
- additionalInstructions: '',
686
- skills: [],
687
- };
688
- ```
689
-
690
- ---
691
-
692
- ## Events
693
-
694
- ### Prompt Events
695
-
696
- - `system-prompt-updated` - System prompt changed
697
- - `mode-changed` - Operational mode changed
698
- - `active-skills-updated` - Active skills changed
699
- - `active-tools-updated` - Active tools changed
700
- - `active-hooks-updated` - Active hooks changed
701
- - `active-mcp-updated` - Active MCP servers changed
702
-
703
- ---
704
-
705
- ## Best Practices
706
-
707
- ### 1. Prompt Design
708
-
709
- - Keep Tier 1 prompts minimal (200 tokens max)
710
- - Scale detail with tier size
711
- - Use clear, concise language
712
- - Focus on behavior, not implementation
713
-
714
- ### 2. Mode Selection
715
-
716
- - Use Assistant mode for general tasks
717
- - Use Developer mode for coding tasks
718
- - Use Planning mode for architecture
719
- - Use Debugger mode for troubleshooting
720
-
721
- ### 3. Skills
722
-
723
- - Register skills in PromptRegistry
724
- - Tag skills appropriately
725
- - Keep skill prompts focused
726
- - Test skills in isolation
727
-
728
- ### 4. MCP Prompts
729
-
730
- - Clear prompts when server disconnects
731
- - Version prompts for compatibility
732
- - Document required tools
733
- - Test prompt integration
734
-
735
- ### 5. User Mode Customization
736
-
737
- - User mode templates are located in `templates/user/`
738
- - By default, they are copies of Assistant mode
739
- - Edit the tier files to customize behavior
740
- - Changes take effect on next mode switch
741
- - Keep tier token budgets in mind when editing
742
-
743
- ---
744
-
745
- ## File Locations
746
-
747
- | File | Purpose |
748
- | -------------------------------------------------- | -------------------- |
749
- | `packages/core/src/context/promptOrchestrator.ts` | Coordinator |
750
- | `packages/core/src/prompts/tieredPromptStore.ts` | Template loader |
751
- | `packages/core/src/prompts/PromptRegistry.ts` | Core prompt registry |
752
- | `packages/core/src/context/SystemPromptBuilder.ts` | Prompt assembly |
753
- | `packages/core/src/context/goalManager.ts` | Goal management |
754
- | `packages/core/src/prompts/templates/` | All prompt templates |
755
-
756
- ---
757
-
758
- **Last Updated:** January 26, 2026
759
- **Version:** 0.1.0
760
- **Status:** Active Development