markdown_exec 3.5.1 → 3.5.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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/.ai-agent-instructions +54 -0
  3. data/.cursorrules +198 -0
  4. data/.rubocop.wide.yml +5 -0
  5. data/.rubocop.yml +7 -2
  6. data/CHANGELOG.md +12 -1
  7. data/Gemfile.lock +1 -1
  8. data/Rakefile +2 -0
  9. data/ai-principles.md +516 -0
  10. data/architecture-decisions.md +190 -0
  11. data/bats/block-hide.bats +1 -1
  12. data/bats/block-type-bash.bats +5 -5
  13. data/bats/block-type-link.bats +1 -1
  14. data/bats/block-type-opts.bats +3 -3
  15. data/bats/block-type-port.bats +2 -2
  16. data/bats/block-type-shell-require-ux.bats +2 -2
  17. data/bats/block-type-ux-allowed.bats +4 -4
  18. data/bats/block-type-ux-auto.bats +1 -1
  19. data/bats/block-type-ux-chained.bats +1 -1
  20. data/bats/block-type-ux-default.bats +1 -1
  21. data/bats/block-type-ux-echo-hash-transform.bats +1 -1
  22. data/bats/block-type-ux-echo-hash.bats +2 -2
  23. data/bats/block-type-ux-echo.bats +3 -3
  24. data/bats/block-type-ux-exec-hash-transform.bats +1 -1
  25. data/bats/block-type-ux-exec-hash.bats +2 -2
  26. data/bats/block-type-ux-exec.bats +1 -1
  27. data/bats/block-type-ux-force.bats +1 -1
  28. data/bats/block-type-ux-formats.bats +1 -1
  29. data/bats/block-type-ux-hidden.bats +1 -1
  30. data/bats/block-type-ux-invalid.bats +1 -1
  31. data/bats/block-type-ux-readonly.bats +1 -1
  32. data/bats/block-type-ux-require-chained.bats +2 -2
  33. data/bats/block-type-ux-require-context.bats +2 -2
  34. data/bats/block-type-ux-require.bats +2 -2
  35. data/bats/block-type-ux-required-variables.bats +1 -1
  36. data/bats/block-type-ux-row-format.bats +1 -1
  37. data/bats/block-type-ux-sources.bats +4 -4
  38. data/bats/block-type-ux-transform.bats +1 -1
  39. data/bats/block-type-vars.bats +3 -3
  40. data/bats/border.bats +1 -1
  41. data/bats/cli.bats +11 -11
  42. data/bats/command-substitution-options.bats +2 -2
  43. data/bats/command-substitution.bats +1 -1
  44. data/bats/document-shell.bats +1 -1
  45. data/bats/history.bats +5 -5
  46. data/bats/import-conflict.bats +1 -1
  47. data/bats/import-directive-line-continuation.bats +1 -1
  48. data/bats/import-directive-parameter-symbols.bats +1 -1
  49. data/bats/import-duplicates.bats +6 -6
  50. data/bats/import-parameter-symbols.bats +1 -1
  51. data/bats/import-with-text-substitution.bats +1 -1
  52. data/bats/import.bats +3 -3
  53. data/bats/indented-block-type-vars.bats +1 -1
  54. data/bats/indented-multi-line-output.bats +1 -1
  55. data/bats/line-decor-dynamic.bats +1 -1
  56. data/bats/line-wrapping.bats +1 -1
  57. data/bats/load-vars-state-demo.bats +4 -4
  58. data/bats/markup.bats +4 -4
  59. data/bats/mde.bats +4 -4
  60. data/bats/option-expansion.bats +1 -1
  61. data/bats/options-collapse.bats +4 -4
  62. data/bats/options.bats +47 -17
  63. data/bats/plain.bats +1 -1
  64. data/bats/publish.bats +2 -2
  65. data/bats/table-column-truncate.bats +1 -1
  66. data/bats/table.bats +2 -2
  67. data/bats/variable-expansion-multiline.bats +1 -1
  68. data/bats/variable-expansion.bats +6 -6
  69. data/conversation-template.md +611 -0
  70. data/docs/block-execution-modes.md +177 -0
  71. data/docs/block-filtering.md +252 -0
  72. data/docs/block-naming-patterns.md +210 -0
  73. data/docs/block-scanning-patterns.md +248 -0
  74. data/docs/cli-reference.md +370 -0
  75. data/docs/dev/block-hide.md +1 -1
  76. data/docs/dev/block-type-ux-transform.md +5 -4
  77. data/docs/dev/print_bytes.md +3 -0
  78. data/docs/dev/shebang.md +6 -0
  79. data/docs/docker-testing.md +5 -0
  80. data/docs/execution-control.md +384 -0
  81. data/docs/getting-started.md +209 -0
  82. data/docs/import-options.md +391 -0
  83. data/docs/tab-completion.md +7 -0
  84. data/docs/ux-blocks.md +376 -0
  85. data/examples/linked1.md +8 -1
  86. data/implementation-decisions.md +212 -0
  87. data/lib/cached_nested_file_reader.rb +138 -1
  88. data/lib/command_result.rb +27 -6
  89. data/lib/executed_shell_command.rb +512 -0
  90. data/lib/filter.rb +7 -7
  91. data/lib/hash_delegator.rb +403 -350
  92. data/lib/link_history.rb +22 -11
  93. data/lib/markdown_exec/version.rb +1 -1
  94. data/lib/mdoc.rb +103 -44
  95. data/lib/menu.src.yml +110 -83
  96. data/lib/menu.yml +149 -83
  97. data/lib/transformed_shell_command.rb +449 -0
  98. data/lib/wl.rb +15 -0
  99. data/lib/ww.rb +16 -5
  100. data/requirements.md +111 -0
  101. data/semantic-tokens.md +132 -0
  102. data/tasks.md +69 -0
  103. metadata +26 -4
  104. data/docs/ux-blocks-examples.md +0 -120
  105. data/docs/ux-blocks-init-act.md +0 -100
data/ai-principles.md ADDED
@@ -0,0 +1,516 @@
1
+ # AI-First Principles & Process Guide
2
+
3
+ **Purpose**: This document defines the principles, processes, and conventions that AI agents must follow when working on this project. It should be referenced at the start of every AI agent interaction.
4
+
5
+ ## 🎯 Semantic Token-Driven Development (STDD)
6
+
7
+ This project follows **Semantic Token-Driven Development (STDD)**, a methodology where semantic tokens (`[REQ:*]`, `[ARCH:*]`, `[IMPL:*]`) are the central mechanism for preserving intent throughout the entire development lifecycle.
8
+
9
+ ### How Semantic Tokens Preserve Intent
10
+
11
+ Semantic tokens create a **traceable chain of intent** that ensures the original purpose and reasoning are never lost:
12
+
13
+ 1. **Requirements** (`[REQ:*]`) define the "what" and "why" - the original intent
14
+ 2. **Architecture** decisions (`[ARCH:*]`) explain the "how" at a high level and link back to requirements via cross-references
15
+ 3. **Implementation** decisions (`[IMPL:*]`) explain the "how" at a low level and link back to both architecture and requirements
16
+ 4. **Tests** validate requirements are met, referencing the same tokens in test names and comments
17
+ 5. **Code** comments include tokens, maintaining the connection to original intent
18
+
19
+ This creates a **living documentation system** where:
20
+ - Every decision can be traced back to its requirement
21
+ - The reasoning behind architectural choices is preserved
22
+ - Implementation details remain connected to their purpose
23
+ - Tests explicitly validate the original intent
24
+ - Code comments maintain context even as the codebase evolves
25
+
26
+ **Semantic tokens are not just labels—they are the mechanism that preserves intent from requirements through architecture, implementation, tests, and code.**
27
+
28
+ ## ⚠️ MANDATORY ACKNOWLEDGMENT
29
+
30
+ **AI AGENTS MUST** acknowledge adherence to these principles at the start of EVERY response by prefacing with:
31
+
32
+ **"Observing AI principles!"**
33
+
34
+ This acknowledgment confirms that the AI agent has:
35
+ - Read and understood this document
36
+ - Will follow all documented processes
37
+ - Will use semantic tokens consistently
38
+ - Will prioritize tasks correctly
39
+
40
+ ---
41
+
42
+ ## 📋 Table of Contents
43
+
44
+ 1. [Semantic Token-Driven Development (STDD)](#-semantic-token-driven-development-stdd)
45
+ 2. [AI-First Principles](#ai-first-principles)
46
+ 3. [Documentation Structure](#documentation-structure)
47
+ 4. [Semantic Token System](#semantic-token-system)
48
+ 5. [Development Process](#development-process)
49
+ 6. [Task Tracking System](#task-tracking-system)
50
+ 7. [How to Present This to AI Agents](#how-to-present-this-to-ai-agents)
51
+
52
+ ---
53
+
54
+ ## 🤖 AI-First Principles
55
+
56
+ ### Core Principles
57
+
58
+ 1. **Semantic Token Cross-Referencing**
59
+ - All code, tests, requirements, architecture decisions, and implementation decisions MUST be cross-referenced using semantic tokens (e.g., `[REQ:FEATURE]`, `[IMPL:IMPLEMENTATION]`).
60
+ - Semantic tokens provide traceability from requirements → architecture → implementation → tests.
61
+
62
+ 2. **Documentation-First Development**
63
+ - Requirements MUST be expanded into pseudo-code and architectural decisions before implementation.
64
+ - No code changes until requirements are fully specified with semantic tokens.
65
+
66
+ 3. **Test-Driven Documentation**
67
+ - Tests MUST reference the requirements they validate using semantic tokens.
68
+ - Test names should include semantic tokens (e.g., `TestDuplicatePrevention_REQ_DUPLICATE_PREVENTION`).
69
+
70
+ 4. **Incremental Task Tracking**
71
+ - Every requirement implementation MUST be broken down into trackable tasks and subtasks.
72
+ - Tasks have explicit priorities: **P0 (Critical)** > **P1 (Important)** > **P2 (Nice-to-have)** > **P3 (Future)**.
73
+
74
+ 5. **Priority-Based Implementation**
75
+ - **Most Important**: Tests, Code, Basic Functions
76
+ - **Least Important**: Environment Orchestration, Enhanced Security, Automated Deployment
77
+
78
+ 6. **Complete Task Completion**
79
+ - When all subtasks for a task are complete, remove subtasks and mark the parent task complete.
80
+ - Maintain a clean task list showing only active work.
81
+
82
+ ---
83
+
84
+ ## 📚 Documentation Structure
85
+
86
+ ### Required Documentation Sections
87
+
88
+ All project documentation MUST include these sections with semantic token cross-references:
89
+
90
+ #### 1. Requirements Section
91
+ - Lists all functional and non-functional requirements
92
+ - Each requirement has a unique semantic token: `[REQ:IDENTIFIER]`
93
+ - Each requirement includes:
94
+ - **Description**: What the requirement specifies
95
+ - **Rationale**: Why the requirement exists
96
+ - **Satisfaction Criteria**: How we know the requirement is satisfied (acceptance criteria, success conditions)
97
+ - **Validation Criteria**: How we verify/validate the requirement is met (testing approach, verification methods, success metrics)
98
+ - Example: `[REQ:FEATURE] Description of the feature requirement`
99
+ - Implementation status: ✅ (Implemented) or ⏳ (Planned)
100
+ - **Note**: Validation criteria defined in requirements inform the testing strategy in `architecture-decisions.md` and specific test implementations in `implementation-decisions.md`
101
+
102
+ #### 2. Architecture Decisions Section
103
+ - Documents high-level design choices
104
+ - **Location**: `architecture-decisions.md` - dedicated file for architecture decisions
105
+ - **MANDATORY**: Must be updated IMMEDIATELY when architectural decisions are made
106
+ - **DO NOT** defer architecture documentation - record decisions as they are made
107
+ - Links to requirements via semantic tokens
108
+ - Each decision MUST include semantic token `[ARCH:IDENTIFIER]` and cross-reference to `[REQ:*]` tokens
109
+ - Example: `[ARCH:CONCURRENCY_MODEL] Uses goroutines with WaitGroup for async execution [REQ:ASYNC_EXECUTION]`
110
+ - **Dependency**: Architecture decisions depend on requirements and should reference `[REQ:*]` tokens
111
+ - **Update Timing**: Record in `architecture-decisions.md` during Phase 1 (Requirements → Pseudo-Code) and update as decisions evolve
112
+
113
+ #### 3. Implementation Decisions Section
114
+ - Documents low-level implementation choices
115
+ - **Location**: `implementation-decisions.md` - dedicated file for implementation decisions
116
+ - **MANDATORY**: Must be updated IMMEDIATELY when implementation decisions are made
117
+ - **DO NOT** defer implementation documentation - record decisions as they are made
118
+ - Links to requirements and architecture via semantic tokens
119
+ - Each decision MUST include semantic token `[IMPL:IDENTIFIER]` and cross-reference to `[ARCH:*]` and `[REQ:*]` tokens
120
+ - Example: `[IMPL:DUPLICATE_PREVENTION] Track lastText string [ARCH:STATE_TRACKING] [REQ:DUPLICATE_PREVENTION]`
121
+ - **Dependency**: Implementation decisions depend on both architecture decisions and requirements
122
+ - **Update Timing**: Record in `implementation-decisions.md` during Phase 1 (Requirements → Pseudo-Code) and update during Phase 3 (Implementation) as decisions are refined
123
+
124
+ #### 4. Semantic Token Registry
125
+ - Central registry of all semantic tokens used in the project
126
+ - Maps tokens to their definitions and cross-references
127
+
128
+ #### 5. Code References
129
+ - Code comments MUST include semantic tokens
130
+ - Example: `// [REQ:DUPLICATE_PREVENTION] Skip if text matches lastText`
131
+
132
+ #### 6. Test References
133
+ - Test names and comments MUST include semantic tokens
134
+ - Example: `func TestDuplicatePrevention_REQ_DUPLICATE_PREVENTION(t *testing.T)`
135
+
136
+ ---
137
+
138
+ ## 🏷️ Semantic Token System
139
+
140
+ **Semantic tokens are the foundation of STDD** - they are the mechanism that preserves intent throughout the development lifecycle.
141
+
142
+ ### Token Format
143
+
144
+ ```
145
+ [TYPE:IDENTIFIER]
146
+ ```
147
+
148
+ ### Token Types
149
+
150
+ - `[REQ:*]` - Requirements (functional/non-functional) - **The source of intent**
151
+ - `[ARCH:*]` - Architecture decisions - **High-level design choices that preserve intent**
152
+ - `[IMPL:*]` - Implementation decisions - **Low-level choices that preserve intent**
153
+ - `[TEST:*]` - Test specifications - **Validation of intent**
154
+ - `[CLI/Config]` - Configuration/CLI related
155
+ - `[OS Integration]` - OS-specific integration
156
+ - `[Logging]` - Logging related
157
+ - `[Testability]` - Testability concerns
158
+ - `[Security]` - Security considerations
159
+
160
+ ### Intent Preservation Through Tokens
161
+
162
+ Each token type serves a specific role in preserving intent:
163
+
164
+ - **`[REQ:*]` tokens** capture the original "what" and "why" - the fundamental intent
165
+ - **`[ARCH:*]` tokens** document how high-level design choices fulfill requirements, maintaining the connection to intent
166
+ - **`[IMPL:*]` tokens** document how low-level implementation choices fulfill architecture and requirements, preserving the reasoning
167
+ - **Cross-references** (`[ARCH:X] [REQ:Y]`) create explicit links that maintain traceability
168
+ - **Test names** (`TestFeature_REQ_FEATURE`) explicitly validate that intent is preserved
169
+ - **Code comments** (`// [REQ:FEATURE] Implementation`) maintain context even as code evolves
170
+
171
+ ### Token Naming Convention
172
+
173
+ - Use UPPER_SNAKE_CASE for identifiers
174
+ - Be descriptive but concise
175
+ - Example: `[REQ:DUPLICATE_PREVENTION]` not `[REQ:DP]`
176
+
177
+ ### Cross-Reference Format
178
+
179
+ When referencing other tokens:
180
+
181
+ ```markdown
182
+ [IMPL:DUPLICATE_PREVENTION] Track lastText string [REQ:DUPLICATE_PREVENTION]
183
+ ```
184
+
185
+ ### Token Registry Location
186
+
187
+ Create and maintain `semantic-tokens.md` with:
188
+ - All tokens used in the project
189
+ - Definitions
190
+ - Cross-reference mappings
191
+ - Status (Implemented/Planned)
192
+
193
+ ---
194
+
195
+ ## 🔄 Development Process
196
+
197
+ ### Phase 1: Requirements → Pseudo-Code
198
+
199
+ **MANDATORY**: Before any code changes, expand requirements into pseudo-code and decisions.
200
+
201
+ 1. **Identify Requirement**
202
+ - Extract requirement from documentation
203
+ - Note semantic token: `[REQ:IDENTIFIER]`
204
+
205
+ 2. **Architectural Decisions** (MANDATORY - Record IMMEDIATELY)
206
+ - **IMMEDIATELY** document high-level approach in `architecture-decisions.md`
207
+ - **IMMEDIATELY** create `[ARCH:IDENTIFIER]` tokens
208
+ - **IMMEDIATELY** cross-reference: `[ARCH:IDENTIFIER] [REQ:IDENTIFIER]`
209
+ - Each architecture decision MUST be recorded in `architecture-decisions.md` with semantic token links
210
+ - Architecture decisions are dependent on requirements and must reference `[REQ:*]` tokens
211
+ - **DO NOT** defer - record decisions as they are made, not at the end
212
+
213
+ 3. **Implementation Decisions** (MANDATORY - Record IMMEDIATELY)
214
+ - **IMMEDIATELY** document low-level approach in `implementation-decisions.md`
215
+ - **IMMEDIATELY** create `[IMPL:IDENTIFIER]` tokens
216
+ - **IMMEDIATELY** cross-reference: `[IMPL:IDENTIFIER] [ARCH:IDENTIFIER] [REQ:IDENTIFIER]`
217
+ - Each implementation decision MUST be recorded in `implementation-decisions.md` with semantic token links
218
+ - Implementation decisions are dependent on both architecture decisions and requirements
219
+ - **DO NOT** defer - record decisions as they are made, not at the end
220
+
221
+ 4. **Pseudo-Code**
222
+ - Write pseudo-code with semantic token comments
223
+ - Example:
224
+ ```text
225
+ // [REQ:DUPLICATE_PREVENTION]
226
+ if text == lastText:
227
+ skip()
228
+ ```
229
+
230
+ 5. **Update Documentation** (MANDATORY - Do IMMEDIATELY)
231
+ - **IMMEDIATELY** add architecture decisions to `architecture-decisions.md` with `[ARCH:*]` tokens and `[REQ:*]` cross-references
232
+ - **IMMEDIATELY** add implementation decisions to `implementation-decisions.md` with `[IMPL:*]` tokens and `[ARCH:*]` and `[REQ:*]` cross-references
233
+ - **IMMEDIATELY** update `semantic-tokens.md` with any new tokens created
234
+ - **IMMEDIATELY** create tasks in `tasks.md` with priorities and semantic token references
235
+ - Cross-reference all tokens consistently
236
+ - **DO NOT** defer documentation updates - they are part of the planning phase
237
+
238
+ ### Phase 2: Pseudo-Code → Tasks (MANDATORY - Plan BEFORE Implementation)
239
+
240
+ 1. **Generate Tasks** (MANDATORY - Record in `tasks.md`)
241
+ - **IMMEDIATELY** break down into discrete tasks in `tasks.md`
242
+ - Each task MUST reference semantic tokens
243
+ - Example: `Task: Implement duplicate prevention [REQ:DUPLICATE_PREVENTION]`
244
+ - **DO NOT** start implementation until tasks are documented
245
+
246
+ 2. **Generate Subtasks** (MANDATORY - Record in `tasks.md`)
247
+ - **IMMEDIATELY** break tasks into implementable subtasks in `tasks.md`
248
+ - Each subtask is a single, complete unit of work
249
+ - Example:
250
+ - Subtask: Add field to data structure
251
+ - Subtask: Implement `isDuplicate()` function
252
+ - Subtask: Call `isDuplicate()` in polling loop
253
+ - Subtask: Write test `TestDuplicatePrevention_REQ_DUPLICATE_PREVENTION`
254
+ - **DO NOT** start implementation until subtasks are documented
255
+
256
+ 3. **Assign Priorities** (MANDATORY - Required for all tasks)
257
+ - P0: Critical (blocks core functionality)
258
+ - P1: Important (enhances functionality)
259
+ - P2: Nice-to-have (improves UX/developer experience)
260
+ - P3: Future (deferred)
261
+ - **ALL tasks MUST have priorities assigned**
262
+
263
+ ### Phase 3: Tasks → Implementation
264
+
265
+ 1. **Work on Highest Priority Tasks First**
266
+ - P0 tasks before P1, P1 before P2, etc.
267
+
268
+ 2. **Complete Subtasks**
269
+ - Mark subtasks complete as they're done
270
+ - Remove completed subtasks
271
+ - When all subtasks complete, mark parent task complete
272
+
273
+ 3. **Update Documentation** (MANDATORY - Update AS YOU WORK)
274
+ - **DURING implementation**: Update `architecture-decisions.md` if decisions are refined
275
+ - **DURING implementation**: Update `implementation-decisions.md` if decisions are refined
276
+ - **DURING implementation**: Update `tasks.md` as subtasks are completed
277
+ - **AFTER completion**: Mark requirements as ✅ Implemented
278
+ - **AFTER completion**: Update code with semantic token comments
279
+ - **AFTER completion**: Update tests with semantic token references
280
+ - **AFTER completion**: Verify all documentation is current and accurate
281
+
282
+ ---
283
+
284
+ ## 📝 Task Tracking System
285
+
286
+ ### Task Format
287
+
288
+ ```markdown
289
+ ## P0: Task Name [REQ:IDENTIFIER] [ARCH:IDENTIFIER] [IMPL:IDENTIFIER]
290
+
291
+ **Status**: 🟡 In Progress | ✅ Complete | ⏸️ Blocked | ⏳ Pending
292
+
293
+ **Description**: Brief description of what this task accomplishes.
294
+
295
+ **Dependencies**: List of other tasks/tokens this depends on.
296
+
297
+ **Subtasks**:
298
+ - [ ] Subtask 1 [REQ:X] [IMPL:Y]
299
+ - [ ] Subtask 2 [REQ:X] [IMPL:Z]
300
+ - [ ] Subtask 3 [TEST:X]
301
+
302
+ **Completion Criteria**:
303
+ - [ ] All subtasks complete
304
+ - [ ] Code implements requirement
305
+ - [ ] Tests pass with semantic token references
306
+ - [ ] Documentation updated
307
+
308
+ **Priority Rationale**: Why this is P0/P1/P2/P3
309
+ ```
310
+
311
+ ### Task Management Rules
312
+
313
+ 1. **Subtasks are Temporary**
314
+ - Subtasks exist only while the parent task is in progress
315
+ - Remove subtasks when parent task completes
316
+
317
+ 2. **Priority Must Be Justified**
318
+ - Each task must have a priority rationale
319
+ - Priorities follow: Tests/Code/Functions > DX > Infrastructure > Security
320
+
321
+ 3. **Semantic Token References Required**
322
+ - Every task MUST reference at least one semantic token
323
+ - Cross-reference to related tokens
324
+
325
+ 4. **Completion Criteria Must Be Met**
326
+ - All criteria must be checked before marking complete
327
+ - Documentation must be updated
328
+
329
+ ### Task Status Icons
330
+
331
+ - 🟡 **In Progress**: Actively being worked on
332
+ - ✅ **Complete**: All criteria met, subtasks removed
333
+ - ⏸️ **Blocked**: Waiting on dependency
334
+ - ⏳ **Pending**: Not yet started
335
+
336
+ ### Priority Levels
337
+
338
+ #### P0: Critical (Must Have)
339
+ - Core functionality
340
+ - Tests that validate requirements
341
+ - Basic working features
342
+ - Blocks other work
343
+
344
+ #### P1: Important (Should Have)
345
+ - Enhanced functionality
346
+ - Better error handling
347
+ - Performance improvements
348
+ - Developer experience
349
+
350
+ #### P2: Nice-to-Have (Could Have)
351
+ - UI/UX improvements
352
+ - Documentation enhancements
353
+ - Convenience features
354
+ - Non-critical optimizations
355
+
356
+ #### P3: Future (Won't Have Now)
357
+ - Deferred features
358
+ - Experimental ideas
359
+ - Future enhancements
360
+ - Infrastructure improvements
361
+
362
+ ---
363
+
364
+ ## 📖 How to Present This to AI Agents
365
+
366
+ ### Method 1: Include in System Prompt
367
+
368
+ When starting a new AI agent session, include:
369
+
370
+ ```
371
+ MANDATORY: At the start of EVERY response, you MUST preface with:
372
+ "Observing AI principles!"
373
+
374
+ Then proceed to:
375
+ 1. Read and follow the AI-First Principles document (ai-principles.md)
376
+ 2. Use semantic tokens [REQ:*], [ARCH:*], [IMPL:*] throughout
377
+ 3. Expand requirements into pseudo-code before coding
378
+ 4. Break work into trackable tasks with priorities
379
+ 5. Cross-reference everything using semantic tokens
380
+ 6. Prioritize: Tests > Code > Basic Functions > Infrastructure
381
+ ```
382
+
383
+ ### Method 2: Include in .cursorrules (Already Configured)
384
+
385
+ The `.cursorrules` file in the project root is automatically loaded by Cursor IDE and contains these instructions. The acknowledgment requirement is already embedded.
386
+
387
+ ### Method 3: Reference in User Query
388
+
389
+ Start requests with:
390
+
391
+ ```
392
+ Following ai-principles.md, please:
393
+ [your request here]
394
+ ```
395
+
396
+ The AI agent should acknowledge with "Observing AI principles!" and then proceed.
397
+
398
+ ### Method 4: .cursorrules File (Already Configured)
399
+
400
+ The `.cursorrules` file in the project root is automatically loaded by Cursor IDE. It includes:
401
+ - Mandatory acknowledgment requirement
402
+ - Complete rules and principles
403
+ - Workflow examples
404
+
405
+ **Already configured in this project!**
406
+
407
+ ### Method 5: Include in README.md
408
+
409
+ Add section to README.md:
410
+
411
+ ```markdown
412
+ ## For AI Agents
413
+
414
+ This project follows AI-First Principles. Before making changes:
415
+
416
+ 1. Read `ai-principles.md`
417
+ 2. Use semantic tokens for cross-referencing
418
+ 3. Expand requirements into pseudo-code before implementation
419
+ 4. Create tasks with priorities
420
+ 5. Follow priority order: Tests > Code > Functions > Infrastructure
421
+ ```
422
+
423
+ ---
424
+
425
+ ## ✅ Checklist for AI Agents
426
+
427
+ **AT THE START OF EVERY RESPONSE:**
428
+
429
+ - [ ] **MANDATORY**: Preface response with "Observing AI principles!"
430
+ - [ ] Read `ai-principles.md` (if not already read in this session)
431
+ - [ ] Check `semantic-tokens.md` for existing tokens
432
+ - [ ] Review `tasks.md` for active tasks
433
+ - [ ] Understand semantic token system
434
+ - [ ] Know the development process
435
+ - [ ] Understand priority levels
436
+
437
+ **BEFORE STARTING ANY WORK:**
438
+
439
+ - [ ] Verify all prerequisites above
440
+ - [ ] Have access to semantic token registry
441
+ - [ ] Understand current task priorities
442
+ - [ ] **MANDATORY**: Review `architecture-decisions.md` for existing architecture decisions
443
+ - [ ] **MANDATORY**: Review `implementation-decisions.md` for existing implementation decisions
444
+ - [ ] **MANDATORY**: Plan work in `tasks.md` BEFORE writing any code
445
+
446
+ **DURING WORK:**
447
+
448
+ - [ ] Use semantic tokens in all code comments
449
+ - [ ] Use semantic tokens in test names/comments
450
+ - [ ] Cross-reference requirements → architecture → implementation
451
+ - [ ] **MANDATORY**: Record architecture decisions in `architecture-decisions.md` IMMEDIATELY when made (with `[ARCH:*]` tokens and `[REQ:*]` cross-references)
452
+ - [ ] **MANDATORY**: Record implementation decisions in `implementation-decisions.md` IMMEDIATELY when made (with `[IMPL:*]` tokens and `[ARCH:*]` and `[REQ:*]` cross-references)
453
+ - [ ] **MANDATORY**: Break work into trackable tasks in `tasks.md` BEFORE starting implementation
454
+ - [ ] **MANDATORY**: Assign appropriate priorities to all tasks
455
+ - [ ] **MANDATORY**: Update `tasks.md` as subtasks are completed
456
+ - [ ] **MANDATORY**: Update `semantic-tokens.md` when creating new tokens
457
+ - [ ] **MANDATORY**: Update documentation AS YOU WORK - do not defer until the end
458
+
459
+ **AFTER COMPLETING WORK:**
460
+
461
+ - [ ] **MANDATORY**: All semantic tokens documented in `semantic-tokens.md`
462
+ - [ ] **MANDATORY**: Documentation updated with implementation status:
463
+ - `architecture-decisions.md` reflects all architectural decisions made
464
+ - `implementation-decisions.md` reflects all implementation decisions made
465
+ - Both cross-reference `[REQ:*]` tokens correctly
466
+ - [ ] **MANDATORY**: Tests reference semantic tokens
467
+ - [ ] **MANDATORY**: Tasks marked complete in `tasks.md`
468
+ - [ ] **MANDATORY**: Subtasks removed from completed tasks
469
+ - [ ] **MANDATORY**: All documentation is current and accurate (no stale information)
470
+ - [ ] **MANDATORY**: Verify documentation completeness before marking work complete
471
+
472
+ ---
473
+
474
+ ## 📚 Related Documents
475
+
476
+ - `requirements.md` - Main design document with requirements (copy from `requirements.template.md` in STDD repository)
477
+ - `architecture-decisions.md` - **Semantic-token-linked record of architecture decisions dependent on requirements** (copy from `architecture-decisions.template.md`)
478
+ - All `[ARCH:*]` tokens must be documented here
479
+ - Must cross-reference `[REQ:*]` tokens from requirements
480
+ - `implementation-decisions.md` - **Semantic-token-linked record of implementation decisions dependent on architecture and requirements** (copy from `implementation-decisions.template.md`)
481
+ - All `[IMPL:*]` tokens must be documented here
482
+ - Must cross-reference both `[ARCH:*]` and `[REQ:*]` tokens
483
+ - `semantic-tokens.md` - Central registry of all semantic tokens (copy from `semantic-tokens.template.md`)
484
+ - `tasks.md` - Active task tracking document (copy from `tasks.template.md`)
485
+ - `README.md` - Project overview and getting started guide
486
+
487
+ ---
488
+
489
+ ## 🔄 Maintenance
490
+
491
+ This document should be:
492
+ - Reviewed when adding new requirements
493
+ - Updated when adding new semantic token types
494
+ - Referenced at the start of every AI agent session
495
+ - Used as a checklist for all development work
496
+
497
+ ## ⚠️ CRITICAL REMINDERS
498
+
499
+ ### Documentation is MANDATORY, Not Optional
500
+
501
+ 1. **Architecture Decisions**: Record IMMEDIATELY in `architecture-decisions.md` when made
502
+ 2. **Implementation Decisions**: Record IMMEDIATELY in `implementation-decisions.md` when made
503
+ 3. **Task Planning**: Plan in `tasks.md` BEFORE starting implementation
504
+ 4. **Semantic Tokens**: Update `semantic-tokens.md` when creating new tokens
505
+ 5. **DO NOT DEFER**: Documentation updates are part of the work, not something to do "later"
506
+
507
+ ### Documentation Update Timing
508
+
509
+ - **Planning Phase**: Document architecture and implementation decisions
510
+ - **Implementation Phase**: Update documentation as decisions are refined
511
+ - **Completion Phase**: Verify all documentation is current and complete
512
+
513
+ **Last Updated**: 2025-11-08
514
+ **Version**: 1.0.0
515
+ **STDD Methodology Version**: 1.0.0
516
+