bmad-method 4.27.0 → 4.27.2

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 (99) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/bmad-core/agent-teams/team-all.yaml +6 -6
  3. package/bmad-core/agent-teams/team-fullstack.yaml +6 -6
  4. package/bmad-core/agent-teams/team-no-ui.yaml +2 -2
  5. package/bmad-core/agents/analyst.md +17 -20
  6. package/bmad-core/agents/architect.md +15 -18
  7. package/bmad-core/agents/bmad-master.md +55 -56
  8. package/bmad-core/agents/bmad-orchestrator.md +24 -23
  9. package/bmad-core/agents/dev.md +10 -10
  10. package/bmad-core/agents/pm.md +17 -20
  11. package/bmad-core/agents/po.md +12 -15
  12. package/bmad-core/agents/qa.md +7 -8
  13. package/bmad-core/agents/sm.md +8 -13
  14. package/bmad-core/agents/ux-expert.md +7 -11
  15. package/bmad-core/core-config.yaml +1 -1
  16. package/bmad-core/templates/architecture-tmpl.yaml +650 -0
  17. package/bmad-core/templates/brainstorming-output-tmpl.yaml +156 -0
  18. package/bmad-core/templates/brownfield-architecture-tmpl.yaml +476 -0
  19. package/bmad-core/templates/brownfield-prd-tmpl.yaml +280 -0
  20. package/bmad-core/templates/competitor-analysis-tmpl.yaml +293 -0
  21. package/bmad-core/templates/front-end-architecture-tmpl.yaml +206 -0
  22. package/bmad-core/templates/front-end-spec-tmpl.yaml +349 -0
  23. package/bmad-core/templates/fullstack-architecture-tmpl.yaml +805 -0
  24. package/bmad-core/templates/market-research-tmpl.yaml +252 -0
  25. package/bmad-core/templates/{prd-tmpl2.yaml → prd-tmpl.yaml} +3 -3
  26. package/bmad-core/templates/project-brief-tmpl.yaml +221 -0
  27. package/bmad-core/templates/story-tmpl.yaml +137 -0
  28. package/common/tasks/create-doc.md +55 -67
  29. package/common/utils/bmad-doc-template.md +29 -0
  30. package/dist/agents/analyst.txt +1004 -1061
  31. package/dist/agents/architect.txt +2460 -2872
  32. package/dist/agents/bmad-master.txt +3842 -4354
  33. package/dist/agents/bmad-orchestrator.txt +211 -87
  34. package/dist/agents/dev.txt +4 -8
  35. package/dist/agents/pm.txt +557 -587
  36. package/dist/agents/po.txt +149 -102
  37. package/dist/agents/qa.txt +145 -35
  38. package/dist/agents/sm.txt +145 -100
  39. package/dist/agents/ux-expert.txt +413 -522
  40. package/dist/expansion-packs/bmad-2d-phaser-game-dev/agents/game-designer.txt +1258 -1236
  41. package/dist/expansion-packs/bmad-2d-phaser-game-dev/agents/game-developer.txt +623 -573
  42. package/dist/expansion-packs/bmad-2d-phaser-game-dev/agents/game-sm.txt +263 -248
  43. package/dist/expansion-packs/bmad-2d-phaser-game-dev/teams/phaser-2d-nodejs-game-team.txt +9135 -4942
  44. package/dist/expansion-packs/bmad-creator-tools/agents/bmad-the-creator.txt +288 -251
  45. package/dist/expansion-packs/bmad-infrastructure-devops/agents/infra-devops-platform.txt +1123 -1145
  46. package/dist/teams/team-all.txt +4583 -4837
  47. package/dist/teams/team-fullstack.txt +5276 -5520
  48. package/dist/teams/team-ide-minimal.txt +375 -185
  49. package/dist/teams/team-no-ui.txt +4875 -5051
  50. package/expansion-packs/bmad-2d-phaser-game-dev/agent-teams/phaser-2d-nodejs-game-team.yaml +2 -2
  51. package/expansion-packs/bmad-2d-phaser-game-dev/agents/game-designer.md +17 -15
  52. package/expansion-packs/bmad-2d-phaser-game-dev/agents/game-developer.md +13 -11
  53. package/expansion-packs/bmad-2d-phaser-game-dev/agents/game-sm.md +13 -11
  54. package/expansion-packs/bmad-2d-phaser-game-dev/config.yaml +1 -1
  55. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-architecture-tmpl.yaml +613 -0
  56. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-brief-tmpl.yaml +356 -0
  57. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-design-doc-tmpl.yaml +343 -0
  58. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-story-tmpl.yaml +253 -0
  59. package/expansion-packs/bmad-2d-phaser-game-dev/templates/level-design-doc-tmpl.yaml +484 -0
  60. package/expansion-packs/bmad-creator-tools/agents/bmad-the-creator.md +14 -12
  61. package/expansion-packs/bmad-creator-tools/config.yaml +1 -1
  62. package/expansion-packs/bmad-creator-tools/templates/agent-teams-tmpl.yaml +178 -0
  63. package/expansion-packs/bmad-creator-tools/templates/agent-tmpl.yaml +154 -0
  64. package/expansion-packs/bmad-creator-tools/templates/expansion-pack-plan-tmpl.yaml +120 -0
  65. package/expansion-packs/bmad-infrastructure-devops/agents/infra-devops-platform.md +14 -14
  66. package/expansion-packs/bmad-infrastructure-devops/config.yaml +1 -1
  67. package/expansion-packs/bmad-infrastructure-devops/templates/infrastructure-architecture-tmpl.yaml +424 -0
  68. package/expansion-packs/bmad-infrastructure-devops/templates/infrastructure-platform-from-arch-tmpl.yaml +629 -0
  69. package/package.json +1 -1
  70. package/tools/builders/web-builder.js +65 -85
  71. package/tools/installer/package.json +1 -1
  72. package/tools/lib/dependency-resolver.js +8 -19
  73. package/zoo/docs/architecture.md +812 -0
  74. package/zoo/docs/brief.md +253 -0
  75. package/zoo/docs/prd.md +500 -0
  76. package/zoo/docs/stories/1.1.story.md +278 -0
  77. package/bmad-core/templates/architecture-tmpl.md +0 -776
  78. package/bmad-core/templates/brainstorming-output-tmpl.md +0 -149
  79. package/bmad-core/templates/brownfield-architecture-tmpl.md +0 -544
  80. package/bmad-core/templates/brownfield-prd-tmpl.md +0 -266
  81. package/bmad-core/templates/competitor-analysis-tmpl.md +0 -291
  82. package/bmad-core/templates/front-end-architecture-tmpl.md +0 -175
  83. package/bmad-core/templates/front-end-spec-tmpl.md +0 -413
  84. package/bmad-core/templates/fullstack-architecture-tmpl.md +0 -1018
  85. package/bmad-core/templates/market-research-tmpl.md +0 -263
  86. package/bmad-core/templates/prd-tmpl.md +0 -202
  87. package/bmad-core/templates/project-brief-tmpl.md +0 -232
  88. package/bmad-core/templates/story-tmpl.md +0 -58
  89. package/common/tasks/create-doc2.md +0 -65
  90. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-architecture-tmpl.md +0 -560
  91. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-brief-tmpl.md +0 -345
  92. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-design-doc-tmpl.md +0 -331
  93. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-story-tmpl.md +0 -235
  94. package/expansion-packs/bmad-2d-phaser-game-dev/templates/level-design-doc-tmpl.md +0 -470
  95. package/expansion-packs/bmad-creator-tools/templates/agent-teams-tmpl.md +0 -154
  96. package/expansion-packs/bmad-creator-tools/templates/agent-tmpl.md +0 -143
  97. package/expansion-packs/bmad-creator-tools/templates/expansion-pack-plan-tmpl.md +0 -91
  98. package/expansion-packs/bmad-infrastructure-devops/templates/infrastructure-architecture-tmpl.md +0 -415
  99. package/expansion-packs/bmad-infrastructure-devops/templates/infrastructure-platform-from-arch-tmpl.md +0 -0
@@ -0,0 +1,812 @@
1
+ # TermTodo Architecture Document
2
+
3
+ ## Introduction
4
+
5
+ This document outlines the overall project architecture for TermTodo, including backend systems, shared services, and non-UI specific concerns. Its primary goal is to serve as the guiding architectural blueprint for AI-driven development, ensuring consistency and adherence to chosen patterns and technologies.
6
+
7
+ **Relationship to Frontend Architecture:**
8
+ If the project includes a significant user interface, a separate Frontend Architecture Document will detail the frontend-specific design and MUST be used in conjunction with this document. Core technology stack choices documented herein (see "Tech Stack") are definitive for the entire project, including any frontend components.
9
+
10
+ ### Starter Template or Existing Project
11
+
12
+ N/A - This is a greenfield Rust CLI project with no starter template.
13
+
14
+ ### Change Log
15
+
16
+ | Date | Version | Description | Author |
17
+ | ---------- | ------- | ------------------------------------------ | ------------------- |
18
+ | 2025-07-07 | 1.0 | Initial architecture based on TermTodo PRD | Winston (Architect) |
19
+
20
+ ## High Level Architecture
21
+
22
+ ### Technical Summary
23
+
24
+ TermTodo is a monolithic, single-binary CLI application built with Rust, utilizing embedded SQLite for ACID-compliant local storage. The architecture employs clean architecture principles with clear separation between CLI parsing, business logic, and data persistence layers. Performance-critical design choices including synchronous execution, prepared statement caching, and minimal dependencies ensure sub-100ms command execution. The system implements repository and command patterns to maintain testability while delivering a zero-configuration tool that integrates seamlessly into developer workflows.
25
+
26
+ ### High Level Overview
27
+
28
+ **Architectural Style:** Monolithic Single Binary
29
+
30
+ - All functionality compiled into one executable for instant startup
31
+ - No network dependencies or service discovery overhead
32
+ - Embedded SQLite database with local file storage
33
+
34
+ **Repository Structure:** Monorepo
35
+
36
+ - Single repository containing all code, tests, and documentation
37
+ - Simplified dependency management and atomic commits
38
+ - Unified CI/CD pipeline for all components
39
+
40
+ **Service Architecture:** Monolith
41
+
42
+ - Single process handling all operations
43
+ - Synchronous execution model (no async runtime needed)
44
+ - Direct database access without network layers
45
+
46
+ **Primary Data Flow:**
47
+
48
+ 1. User invokes `todo` command with arguments
49
+ 2. CLI parser validates and routes to appropriate command handler
50
+ 3. Command handler orchestrates business logic operations
51
+ 4. Repository layer manages SQLite transactions
52
+ 5. Formatted output returned to terminal
53
+
54
+ **Key Architectural Decisions:**
55
+
56
+ - **Synchronous Model**: Eliminates async runtime overhead for faster cold starts
57
+ - **Embedded Database**: Zero configuration, portable data storage
58
+ - **Static Linking**: Single binary distribution with no runtime dependencies
59
+ - **Clean Architecture**: Testable layers despite monolithic structure
60
+
61
+ ### High Level Project Diagram
62
+
63
+ ```mermaid
64
+ graph TB
65
+ User[Terminal User]
66
+
67
+ subgraph "TermTodo Binary"
68
+ CLI[CLI Parser<br/>clap v4]
69
+ CMD[Command Handlers]
70
+ BL[Business Logic]
71
+ REPO[Repository Layer]
72
+ DB[(SQLite DB)]
73
+ CONFIG[Config Manager<br/>TOML]
74
+ end
75
+
76
+ subgraph "File System"
77
+ DBFILE[todo.db]
78
+ CFGFILE[config.toml]
79
+ end
80
+
81
+ User -->|todo add/list/etc| CLI
82
+ CLI -->|Parsed Commands| CMD
83
+ CMD -->|Operations| BL
84
+ BL -->|Data Access| REPO
85
+ REPO -->|SQL| DB
86
+ DB -.->|File I/O| DBFILE
87
+ CONFIG -.->|Read/Write| CFGFILE
88
+
89
+ style User fill:#e1f5fe
90
+ style CLI fill:#fff3e0
91
+ style CMD fill:#fff3e0
92
+ style BL fill:#f3e5f5
93
+ style REPO fill:#e8f5e9
94
+ style DB fill:#e8f5e9
95
+ ```
96
+
97
+ ### Architectural and Design Patterns
98
+
99
+ - **Clean Architecture:** Separation of concerns with CLI, Application, Domain, and Infrastructure layers - _Rationale:_ Enables 80%+ test coverage requirement by isolating business logic from I/O operations
100
+
101
+ - **Repository Pattern:** Abstract SQLite operations behind trait-based interfaces - _Rationale:_ Allows in-memory repositories for unit tests and potential future database migrations
102
+
103
+ - **Command Pattern:** Each CLI subcommand as a discrete handler with execute method - _Rationale:_ Simplifies testing and follows clap's natural structure for maintainable command routing
104
+
105
+ - **Builder Pattern:** Fluent interfaces for constructing complex queries and task filters - _Rationale:_ Provides readable API for combining multiple filter criteria while maintaining performance
106
+
107
+ - **Result/Option Monads:** Explicit error handling using Rust's type system - _Rationale:_ Prevents runtime panics and enables graceful error messages as required by NFR13
108
+
109
+ ## Tech Stack
110
+
111
+ This is the DEFINITIVE technology selection for TermTodo. All implementation must use these exact versions and technologies.
112
+
113
+ ### Cloud Infrastructure
114
+
115
+ - **Provider:** Local-only (No cloud requirements)
116
+ - **Key Services:** N/A
117
+ - **Deployment Regions:** N/A
118
+
119
+ ### Technology Stack Table
120
+
121
+ | Category | Technology | Version | Purpose | Rationale |
122
+ | ---------------------- | -------------- | ------- | ----------------------------- | ------------------------------------------------------------------------- |
123
+ | **Language** | Rust | 1.78.0 | Primary development language | Zero-cost abstractions, memory safety, single binary output |
124
+ | **Database** | SQLite | 3.45.0 | Embedded database | ACID compliance, zero configuration, excellent performance |
125
+ | **CLI Framework** | clap | 4.5.4 | Command-line argument parsing | Automatic help generation, shell completion, strong typing |
126
+ | **ORM/Query Builder** | sqlx | 0.7.4 | Database operations | Compile-time checked queries, async support (if needed later), migrations |
127
+ | **Date Parsing** | chrono | 0.4.38 | Date/time handling | Comprehensive timezone support, widely adopted |
128
+ | **Human Date Parsing** | chrono-english | 0.1.7 | Natural language dates | Parses "tomorrow", "next friday" as required |
129
+ | **Serialization** | serde | 1.0.197 | JSON/CSV export | De facto standard, excellent performance |
130
+ | **Configuration** | toml | 0.8.12 | Config file parsing | Human-readable, simple for users |
131
+ | **Terminal Colors** | termcolor | 1.4.1 | Colored output | Respects NO_COLOR, cross-platform |
132
+ | **Error Handling** | anyhow | 1.0.82 | Application errors | Simplified error handling with context |
133
+ | **Error Types** | thiserror | 1.0.58 | Custom error types | Derive macro for error enums |
134
+ | **Testing** | built-in | std | Unit/integration tests | Rust's excellent built-in test framework |
135
+ | **Benchmarking** | criterion | 0.5.1 | Performance testing | Statistical benchmarking for CI regression detection |
136
+ | **Logging** | env_logger | 0.11.3 | Debug logging | Simple, runtime-configurable via RUST_LOG |
137
+
138
+ ## Data Models
139
+
140
+ ### Task
141
+
142
+ **Purpose:** Core entity representing a single todo item with all associated metadata
143
+
144
+ **Key Attributes:**
145
+
146
+ - `id`: i64 - Unique identifier (SQLite ROWID)
147
+ - `description`: String - Task description (up to 1000 chars)
148
+ - `status`: TaskStatus - Enum (Incomplete/Complete)
149
+ - `project`: Option<String> - Optional project grouping
150
+ - `priority`: Priority - Enum (High/Medium/Low), defaults to Medium
151
+ - `due_date`: Option<DateTime> - Optional due date with timezone
152
+ - `created_at`: DateTime - Creation timestamp
153
+ - `updated_at`: DateTime - Last modification timestamp
154
+ - `completed_at`: Option<DateTime> - Completion timestamp
155
+
156
+ **Relationships:**
157
+
158
+ - Has many Tags (many-to-many via task_tags table)
159
+ - Belongs to one Project (denormalized for performance)
160
+
161
+ ### Tag
162
+
163
+ **Purpose:** Flexible categorization system for tasks
164
+
165
+ **Key Attributes:**
166
+
167
+ - `id`: i64 - Unique identifier
168
+ - `name`: String - Tag name (alphanumeric + dash/underscore)
169
+ - `created_at`: DateTime - First use timestamp
170
+
171
+ **Relationships:**
172
+
173
+ - Has many Tasks (many-to-many via task_tags table)
174
+ - Cascade delete orphaned tags
175
+
176
+ ### TaskTag
177
+
178
+ **Purpose:** Junction table for many-to-many task-tag relationship
179
+
180
+ **Key Attributes:**
181
+
182
+ - `task_id`: i64 - Foreign key to tasks
183
+ - `tag_id`: i64 - Foreign key to tags
184
+
185
+ **Relationships:**
186
+
187
+ - Composite primary key (task_id, tag_id)
188
+ - ON DELETE CASCADE for both foreign keys
189
+
190
+ ## Components
191
+
192
+ ### CLI Parser
193
+
194
+ **Responsibility:** Parse command-line arguments, validate inputs, and route to appropriate command handlers
195
+
196
+ **Key Interfaces:**
197
+
198
+ - `parse_args()` - Main entry point parsing std::env::args()
199
+ - `generate_completions()` - Shell completion script generation
200
+ - Subcommand routing to handlers
201
+
202
+ **Dependencies:** clap v4 for parsing, command handlers for execution
203
+
204
+ **Technology Stack:** Pure Rust with clap derive macros for type-safe parsing
205
+
206
+ ### Command Handlers
207
+
208
+ **Responsibility:** Orchestrate business logic for each CLI subcommand (add, list, complete, etc.)
209
+
210
+ **Key Interfaces:**
211
+
212
+ - `execute(&self, app: &Application) -> Result<()>` - Common trait for all commands
213
+ - Command-specific structs with validated parameters
214
+ - Output formatting for terminal display
215
+
216
+ **Dependencies:** Application service layer, terminal output formatters
217
+
218
+ **Technology Stack:** Rust structs implementing Command trait, termcolor for output
219
+
220
+ ### Application Service
221
+
222
+ **Responsibility:** Core business logic and workflow orchestration independent of I/O concerns
223
+
224
+ **Key Interfaces:**
225
+
226
+ - `add_task(desc: &str, opts: AddOptions) -> Result<Task>`
227
+ - `list_tasks(filters: FilterOptions) -> Result<Vec<Task>>`
228
+ - `complete_tasks(ids: &[i64]) -> Result<usize>`
229
+ - `search_tasks(query: &str) -> Result<Vec<Task>>`
230
+
231
+ **Dependencies:** Repository interfaces (traits), domain models
232
+
233
+ **Technology Stack:** Pure Rust business logic with Result-based error handling
234
+
235
+ ### Repository Layer
236
+
237
+ **Responsibility:** Abstract data persistence operations with SQLite implementation
238
+
239
+ **Key Interfaces:**
240
+
241
+ - `TaskRepository` trait with CRUD operations
242
+ - `TagRepository` trait for tag management
243
+ - `Transaction` support for atomic operations
244
+ - Migration runner for schema updates
245
+
246
+ **Dependencies:** sqlx for database access, domain models
247
+
248
+ **Technology Stack:** sqlx with compile-time checked queries, connection pooling
249
+
250
+ ### Configuration Manager
251
+
252
+ **Responsibility:** Load, validate, and provide access to user configuration
253
+
254
+ **Key Interfaces:**
255
+
256
+ - `load_config() -> Result<Config>` - Load from XDG directory
257
+ - `save_config(&Config) -> Result<()>` - Persist changes
258
+ - `get_default_project()` - Typed config access
259
+
260
+ **Dependencies:** toml for parsing, serde for serialization
261
+
262
+ **Technology Stack:** TOML files with serde deserialization
263
+
264
+ ### Database Manager
265
+
266
+ **Responsibility:** SQLite connection lifecycle, migrations, and performance optimization
267
+
268
+ **Key Interfaces:**
269
+
270
+ - `connect() -> Result<SqlitePool>` - Initialize connection pool
271
+ - `run_migrations() -> Result<()>` - Apply schema updates
272
+ - Prepared statement caching
273
+ - PRAGMA optimizations
274
+
275
+ **Dependencies:** sqlx SQLite driver, migration files
276
+
277
+ **Technology Stack:** SQLite with WAL mode, connection pool size of 1
278
+
279
+ ### Component Diagram
280
+
281
+ ```mermaid
282
+ graph LR
283
+ subgraph "Presentation Layer"
284
+ CLI[CLI Parser]
285
+ FMT[Output Formatter]
286
+ end
287
+
288
+ subgraph "Application Layer"
289
+ CMD[Command Handlers]
290
+ APP[Application Service]
291
+ end
292
+
293
+ subgraph "Domain Layer"
294
+ MODELS[Domain Models]
295
+ TRAITS[Repository Traits]
296
+ end
297
+
298
+ subgraph "Infrastructure Layer"
299
+ REPO[SQLite Repository]
300
+ CONFIG[Config Manager]
301
+ DB[Database Manager]
302
+ end
303
+
304
+ CLI --> CMD
305
+ CMD --> APP
306
+ CMD --> FMT
307
+ APP --> TRAITS
308
+ TRAITS --> REPO
309
+ REPO --> DB
310
+ APP --> MODELS
311
+ CONFIG --> APP
312
+
313
+ style CLI fill:#fff3e0
314
+ style CMD fill:#fff3e0
315
+ style APP fill:#f3e5f5
316
+ style REPO fill:#e8f5e9
317
+ style DB fill:#e8f5e9
318
+ ```
319
+
320
+ ## External APIs
321
+
322
+ This project does not require any external API integrations. All operations are performed locally with no network dependencies.
323
+
324
+ ## Core Workflows
325
+
326
+ ### Add Task Workflow
327
+
328
+ ```mermaid
329
+ sequenceDiagram
330
+ participant User
331
+ participant CLI
332
+ participant CMD as AddCommand
333
+ participant APP as Application
334
+ participant REPO as Repository
335
+ participant DB as SQLite
336
+
337
+ User->>CLI: todo add "Review PR" -p work -P high +review
338
+ CLI->>CMD: parse_add_command()
339
+ CMD->>CMD: validate_description_length()
340
+ CMD->>APP: add_task(desc, options)
341
+ APP->>APP: parse_tags_from_description()
342
+ APP->>REPO: begin_transaction()
343
+ REPO->>DB: BEGIN TRANSACTION
344
+ APP->>REPO: insert_task(task)
345
+ REPO->>DB: INSERT INTO tasks...
346
+ DB-->>REPO: task_id = 42
347
+ APP->>REPO: insert_tags(task_id, tags)
348
+ REPO->>DB: INSERT INTO tags...
349
+ REPO->>DB: INSERT INTO task_tags...
350
+ APP->>REPO: commit()
351
+ REPO->>DB: COMMIT
352
+ APP-->>CMD: Task { id: 42, ... }
353
+ CMD->>User: ✓ Added task #42
354
+ ```
355
+
356
+ ### List Tasks with Filters Workflow
357
+
358
+ ```mermaid
359
+ sequenceDiagram
360
+ participant User
361
+ participant CLI
362
+ participant CMD as ListCommand
363
+ participant APP as Application
364
+ participant REPO as Repository
365
+ participant DB as SQLite
366
+ participant FMT as Formatter
367
+
368
+ User->>CLI: todo list -p work -P high --due
369
+ CLI->>CMD: parse_list_command()
370
+ CMD->>APP: list_tasks(filters)
371
+ APP->>REPO: find_tasks_with_filters(filters)
372
+ REPO->>REPO: build_query_with_filters()
373
+ REPO->>DB: SELECT ... WHERE project=? AND priority=? AND due_date IS NOT NULL
374
+ DB-->>REPO: Vec<TaskRow>
375
+ REPO->>REPO: load_tags_for_tasks(task_ids)
376
+ REPO->>DB: SELECT ... FROM task_tags WHERE task_id IN (...)
377
+ DB-->>REPO: Vec<TagRow>
378
+ REPO-->>APP: Vec<Task>
379
+ APP-->>CMD: Vec<Task>
380
+ CMD->>FMT: format_task_list(tasks)
381
+ FMT->>User: ID Description Project Priority Due Tags<br/>42 Review PR work !!! tomorrow #review
382
+ ```
383
+
384
+ ### Complete Task with Toggle Workflow
385
+
386
+ ```mermaid
387
+ sequenceDiagram
388
+ participant User
389
+ participant CLI
390
+ participant CMD as CompleteCommand
391
+ participant APP as Application
392
+ participant REPO as Repository
393
+ participant DB as SQLite
394
+
395
+ User->>CLI: todo complete 42 43
396
+ CLI->>CMD: parse_complete_command()
397
+ CMD->>APP: complete_tasks([42, 43])
398
+
399
+ loop For each task_id
400
+ APP->>REPO: find_task_by_id(task_id)
401
+ REPO->>DB: SELECT ... WHERE id = ?
402
+ DB-->>REPO: Task
403
+
404
+ alt Task exists
405
+ APP->>APP: toggle_status(task)
406
+ APP->>REPO: update_task_status(id, new_status)
407
+ REPO->>DB: UPDATE tasks SET status=?, completed_at=?
408
+ DB-->>REPO: 1 row affected
409
+ else Task not found
410
+ APP->>APP: record_error(task_id)
411
+ end
412
+ end
413
+
414
+ APP-->>CMD: CompletionResult { success: 2, failed: 0 }
415
+ CMD->>User: ✓ Completed tasks: #42, #43
416
+ ```
417
+
418
+ ## Database Schema
419
+
420
+ ```sql
421
+ -- Enable foreign key constraints
422
+ PRAGMA foreign_keys = ON;
423
+
424
+ -- Enable Write-Ahead Logging for better concurrency
425
+ PRAGMA journal_mode = WAL;
426
+
427
+ -- Optimize for fast reads
428
+ PRAGMA synchronous = NORMAL;
429
+ PRAGMA temp_store = MEMORY;
430
+ PRAGMA mmap_size = 30000000000;
431
+
432
+ -- Tasks table: Core entity
433
+ CREATE TABLE tasks (
434
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
435
+ description TEXT NOT NULL CHECK(length(description) <= 1000),
436
+ status TEXT NOT NULL DEFAULT 'incomplete' CHECK(status IN ('incomplete', 'complete')),
437
+ project TEXT,
438
+ priority TEXT NOT NULL DEFAULT 'medium' CHECK(priority IN ('high', 'medium', 'low')),
439
+ due_date DATETIME,
440
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
441
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
442
+ completed_at DATETIME
443
+ );
444
+
445
+ -- Indexes for common query patterns
446
+ CREATE INDEX idx_tasks_status ON tasks(status);
447
+ CREATE INDEX idx_tasks_project ON tasks(project) WHERE project IS NOT NULL;
448
+ CREATE INDEX idx_tasks_priority ON tasks(priority);
449
+ CREATE INDEX idx_tasks_due_date ON tasks(due_date) WHERE due_date IS NOT NULL;
450
+ CREATE INDEX idx_tasks_created_at ON tasks(created_at);
451
+
452
+ -- Composite index for common filter combinations
453
+ CREATE INDEX idx_tasks_filters ON tasks(status, project, priority);
454
+
455
+ -- Tags table
456
+ CREATE TABLE tags (
457
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
458
+ name TEXT NOT NULL UNIQUE CHECK(name REGEXP '^[a-zA-Z0-9][a-zA-Z0-9_-]*$'),
459
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
460
+ );
461
+
462
+ -- Junction table for many-to-many relationship
463
+ CREATE TABLE task_tags (
464
+ task_id INTEGER NOT NULL,
465
+ tag_id INTEGER NOT NULL,
466
+ PRIMARY KEY (task_id, tag_id),
467
+ FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE,
468
+ FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
469
+ );
470
+
471
+ -- Index for tag lookups
472
+ CREATE INDEX idx_task_tags_tag_id ON task_tags(tag_id);
473
+
474
+ -- Full-text search virtual table
475
+ CREATE VIRTUAL TABLE tasks_fts USING fts5(
476
+ description,
477
+ project,
478
+ content=tasks,
479
+ content_rowid=id
480
+ );
481
+
482
+ -- Triggers to keep FTS index in sync
483
+ CREATE TRIGGER tasks_fts_insert AFTER INSERT ON tasks
484
+ BEGIN
485
+ INSERT INTO tasks_fts(rowid, description, project)
486
+ VALUES (new.id, new.description, new.project);
487
+ END;
488
+
489
+ CREATE TRIGGER tasks_fts_update AFTER UPDATE ON tasks
490
+ BEGIN
491
+ UPDATE tasks_fts
492
+ SET description = new.description, project = new.project
493
+ WHERE rowid = old.id;
494
+ END;
495
+
496
+ CREATE TRIGGER tasks_fts_delete AFTER DELETE ON tasks
497
+ BEGIN
498
+ DELETE FROM tasks_fts WHERE rowid = old.id;
499
+ END;
500
+
501
+ -- Update trigger for updated_at timestamp
502
+ CREATE TRIGGER tasks_update_timestamp AFTER UPDATE ON tasks
503
+ BEGIN
504
+ UPDATE tasks SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
505
+ END;
506
+
507
+ -- Migration tracking table
508
+ CREATE TABLE IF NOT EXISTS schema_migrations (
509
+ version INTEGER PRIMARY KEY,
510
+ applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
511
+ );
512
+ ```
513
+
514
+ ## Source Tree
515
+
516
+ ```plaintext
517
+ termtodo/
518
+ ├── Cargo.toml # Project manifest with dependencies
519
+ ├── Cargo.lock # Locked dependency versions
520
+ ├── build.rs # Build script for embedding resources
521
+ ├── .github/
522
+ │ └── workflows/
523
+ │ ├── ci.yml # Test, lint, build on all platforms
524
+ │ └── release.yml # Build and publish binaries on tag
525
+ ├── src/
526
+ │ ├── main.rs # Entry point, CLI setup
527
+ │ ├── cli/
528
+ │ │ ├── mod.rs # CLI module exports
529
+ │ │ ├── parser.rs # Clap command definitions
530
+ │ │ ├── commands/ # Command handlers
531
+ │ │ │ ├── mod.rs
532
+ │ │ │ ├── add.rs # Add command implementation
533
+ │ │ │ ├── list.rs # List command with formatting
534
+ │ │ │ ├── complete.rs # Complete/uncomplete logic
535
+ │ │ │ ├── delete.rs # Delete command
536
+ │ │ │ ├── search.rs # Full-text search
537
+ │ │ │ └── config.rs # Config management commands
538
+ │ │ └── output.rs # Terminal output formatting
539
+ │ ├── app/
540
+ │ │ ├── mod.rs # Application layer exports
541
+ │ │ ├── service.rs # Main application service
542
+ │ │ ├── filters.rs # Filter builder and logic
543
+ │ │ └── errors.rs # Application error types
544
+ │ ├── domain/
545
+ │ │ ├── mod.rs # Domain model exports
546
+ │ │ ├── task.rs # Task entity and value objects
547
+ │ │ ├── tag.rs # Tag entity
548
+ │ │ └── types.rs # Enums (Status, Priority)
549
+ │ ├── infra/
550
+ │ │ ├── mod.rs # Infrastructure exports
551
+ │ │ ├── db/
552
+ │ │ │ ├── mod.rs # Database module
553
+ │ │ │ ├── connection.rs # Connection pool setup
554
+ │ │ │ ├── migrations.rs # Migration runner
555
+ │ │ │ └── queries.rs # SQL query constants
556
+ │ │ ├── repos/
557
+ │ │ │ ├── mod.rs # Repository traits
558
+ │ │ │ ├── task_repo.rs # Task repository impl
559
+ │ │ │ └── tag_repo.rs # Tag repository impl
560
+ │ │ └── config/
561
+ │ │ ├── mod.rs # Config module
562
+ │ │ └── manager.rs # Config file handling
563
+ │ └── utils/
564
+ │ ├── mod.rs # Utility exports
565
+ │ ├── dates.rs # Date parsing helpers
566
+ │ └── result.rs # Result extensions
567
+ ├── tests/
568
+ │ ├── integration/ # Integration tests
569
+ │ │ ├── cli_tests.rs # End-to-end CLI tests
570
+ │ │ ├── db_tests.rs # Database integration
571
+ │ │ └── helpers/ # Test utilities
572
+ │ └── fixtures/ # Test data files
573
+ ├── benches/
574
+ │ └── performance.rs # Criterion benchmarks
575
+ ├── migrations/ # SQL migration files
576
+ │ ├── 001_initial.sql
577
+ │ └── 002_add_fts.sql
578
+ └── docs/
579
+ ├── architecture.md # This document
580
+ ├── prd.md # Product requirements
581
+ └── README.md # User documentation
582
+ ```
583
+
584
+ ## Infrastructure and Deployment
585
+
586
+ ### Infrastructure as Code
587
+
588
+ - **Tool:** Not applicable (local application)
589
+ - **Location:** N/A
590
+ - **Approach:** Single binary deployment
591
+
592
+ ### Deployment Strategy
593
+
594
+ - **Strategy:** Direct binary distribution
595
+ - **CI/CD Platform:** GitHub Actions
596
+ - **Pipeline Configuration:** `.github/workflows/release.yml`
597
+
598
+ ### Environments
599
+
600
+ - **Development:** Local developer machine with debug builds
601
+ - **Testing:** CI environment with all platforms (Linux, macOS, Windows)
602
+ - **Production:** User's local machine with release binary
603
+
604
+ ### Environment Promotion Flow
605
+
606
+ ```text
607
+ Development (local) -> CI Testing -> GitHub Release -> User Installation
608
+
609
+ Failed tests
610
+
611
+ Fix & retry
612
+ ```
613
+
614
+ ### Rollback Strategy
615
+
616
+ - **Primary Method:** Previous version binary installation
617
+ - **Trigger Conditions:** User-reported critical bugs, data corruption
618
+ - **Recovery Time Objective:** < 5 minutes (download previous release)
619
+
620
+ ## Error Handling Strategy
621
+
622
+ ### General Approach
623
+
624
+ - **Error Model:** Result<T, Error> for all fallible operations
625
+ - **Exception Hierarchy:** anyhow::Error for applications, custom types for libraries
626
+ - **Error Propagation:** ? operator with context via .context()
627
+
628
+ ### Logging Standards
629
+
630
+ - **Library:** env_logger 0.11.3
631
+ - **Format:** `[TIMESTAMP] [LEVEL] [MODULE] Message`
632
+ - **Levels:** ERROR, WARN, INFO, DEBUG, TRACE
633
+ - **Required Context:**
634
+ - Correlation ID: Not needed (single-user CLI)
635
+ - Service Context: Module path automatically included
636
+ - User Context: Never log user data or task content
637
+
638
+ ### Error Handling Patterns
639
+
640
+ #### External API Errors
641
+
642
+ - **Retry Policy:** No external APIs
643
+ - **Circuit Breaker:** Not applicable
644
+ - **Timeout Configuration:** Not applicable
645
+ - **Error Translation:** Not applicable
646
+
647
+ #### Business Logic Errors
648
+
649
+ - **Custom Exceptions:**
650
+ - `TaskNotFound(id)`
651
+ - `InvalidTaskDescription(reason)`
652
+ - `DuplicateTag(name)`
653
+ - `ConfigError(path, reason)`
654
+ - **User-Facing Errors:** Clear, actionable messages via Display trait
655
+ - **Error Codes:** Not used - descriptive messages preferred
656
+
657
+ #### Data Consistency
658
+
659
+ - **Transaction Strategy:** Explicit transactions for multi-table operations
660
+ - **Compensation Logic:** Not needed with ACID SQLite
661
+ - **Idempotency:** Complete/uncomplete operations are naturally idempotent
662
+
663
+ ## Coding Standards
664
+
665
+ These standards are MANDATORY for AI agents and define project-specific conventions.
666
+
667
+ ### Core Standards
668
+
669
+ - **Languages & Runtimes:** Rust 1.78.0 (edition 2021)
670
+ - **Style & Linting:** rustfmt with default config, clippy with pedantic lints
671
+ - **Test Organization:** Unit tests in `#[cfg(test)]` modules, integration tests in tests/
672
+
673
+ ### Naming Conventions
674
+
675
+ | Element | Convention | Example |
676
+ | --------- | --------------- | --------------------- |
677
+ | Structs | PascalCase | `TaskFilter` |
678
+ | Functions | snake_case | `parse_due_date` |
679
+ | Constants | SCREAMING_SNAKE | `MAX_DESCRIPTION_LEN` |
680
+ | Modules | snake_case | `task_repo` |
681
+
682
+ ### Critical Rules
683
+
684
+ - **No unwrap() in production code:** Use expect() with clear message or proper error handling
685
+ - **All public functions must have doc comments:** Include examples for complex APIs
686
+ - **SQL queries must use parameterized statements:** Never concatenate user input
687
+ - **Benchmark new features:** Add criterion benchmarks for any performance-critical code
688
+ - **Check Task description length:** Enforce 1000 character limit at CLI parsing layer
689
+
690
+ ## Test Strategy and Standards
691
+
692
+ ### Testing Philosophy
693
+
694
+ - **Approach:** Test-after development with comprehensive coverage
695
+ - **Coverage Goals:** 80% overall, 90% for business logic
696
+ - **Test Pyramid:** 70% unit, 25% integration, 5% e2e
697
+
698
+ ### Test Types and Organization
699
+
700
+ #### Unit Tests
701
+
702
+ - **Framework:** Rust built-in testing
703
+ - **File Convention:** Tests in same file as code under `#[cfg(test)]` module
704
+ - **Location:** Bottom of each source file
705
+ - **Mocking Library:** Manual test doubles (traits make this easy)
706
+ - **Coverage Requirement:** 90% for domain and app layers
707
+
708
+ **AI Agent Requirements:**
709
+
710
+ - Generate tests for all public methods
711
+ - Cover edge cases and error conditions
712
+ - Follow AAA pattern (Arrange, Act, Assert)
713
+ - Mock all external dependencies
714
+
715
+ #### Integration Tests
716
+
717
+ - **Scope:** Database operations, CLI parsing, file I/O
718
+ - **Location:** `tests/integration/`
719
+ - **Test Infrastructure:**
720
+ - **Database:** In-memory SQLite for speed
721
+ - **File System:** tempfile crate for isolated testing
722
+ - **CLI:** assert_cmd for command execution tests
723
+
724
+ #### End-to-End Tests
725
+
726
+ - **Framework:** assert_cmd 2.0.14
727
+ - **Scope:** Full command execution with real database
728
+ - **Environment:** Isolated temp directory per test
729
+ - **Test Data:** Fixtures in tests/fixtures/
730
+
731
+ ### Test Data Management
732
+
733
+ - **Strategy:** Builder pattern for test objects
734
+ - **Fixtures:** `tests/fixtures/` for import/export tests
735
+ - **Factories:** TaskBuilder, TagBuilder in test modules
736
+ - **Cleanup:** Automatic via tempfile cleanup
737
+
738
+ ### Continuous Testing
739
+
740
+ - **CI Integration:** Run on every push (test, clippy, fmt)
741
+ - **Performance Tests:** Criterion benchmarks with 5% regression threshold
742
+ - **Security Tests:** cargo audit in CI pipeline
743
+
744
+ ## Security
745
+
746
+ ### Input Validation
747
+
748
+ - **Validation Library:** Built-in Rust type system + manual checks
749
+ - **Validation Location:** CLI parsing layer before any processing
750
+ - **Required Rules:**
751
+ - All external inputs MUST be validated
752
+ - Validation at API boundary before processing
753
+ - Whitelist approach preferred over blacklist
754
+
755
+ ### Authentication & Authorization
756
+
757
+ - **Auth Method:** Not applicable (local single-user application)
758
+ - **Session Management:** Not applicable
759
+ - **Required Patterns:**
760
+ - File permissions rely on OS user permissions
761
+ - XDG directory compliance for proper isolation
762
+
763
+ ### Secrets Management
764
+
765
+ - **Development:** No secrets required
766
+ - **Production:** No secrets required
767
+ - **Code Requirements:**
768
+ - NEVER hardcode secrets
769
+ - Access via configuration service only
770
+ - No secrets in logs or error messages
771
+
772
+ ### API Security
773
+
774
+ Not applicable - no network APIs exposed
775
+
776
+ ### Data Protection
777
+
778
+ - **Encryption at Rest:** Relies on OS disk encryption
779
+ - **Encryption in Transit:** Not applicable (local only)
780
+ - **PII Handling:** Task descriptions may contain PII - never log
781
+ - **Logging Restrictions:** Never log task content, only IDs and metadata
782
+
783
+ ### Dependency Security
784
+
785
+ - **Scanning Tool:** cargo audit
786
+ - **Update Policy:** Monthly dependency updates
787
+ - **Approval Process:** Review changelog for breaking changes
788
+
789
+ ### Security Testing
790
+
791
+ - **SAST Tool:** cargo clippy with security lints
792
+ - **DAST Tool:** Not applicable
793
+ - **Penetration Testing:** Not required for local CLI
794
+
795
+ ## Checklist Results Report
796
+
797
+ To be completed after architecture review.
798
+
799
+ ## Next Steps
800
+
801
+ ### Developer Handoff
802
+
803
+ Begin implementation with the following:
804
+
805
+ - Reference this architecture document and coding standards throughout development
806
+ - Start with Epic 1, Story 1.1: Project Setup and Infrastructure
807
+ - Key technical decisions to follow:
808
+ - Use Rust 1.78.0 with 2021 edition
809
+ - Implement clean architecture layers as specified
810
+ - All commands must complete in < 100ms
811
+ - Use synchronous code (no async/await)
812
+ - Follow the defined error handling patterns