Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

step-01-preflight-and-context.md 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. ---
  2. name: 'step-01-preflight-and-context'
  3. description: 'Verify prerequisites and load story, framework, and knowledge base'
  4. outputFile: '{test_artifacts}/atdd-checklist-{story_key}.md'
  5. nextStepFile: '{skill-root}/steps-c/step-02-generation-mode.md'
  6. knowledgeIndex: './resources/tea-index.csv'
  7. ---
  8. # Step 1: Preflight & Context Loading
  9. ## STEP GOAL
  10. Verify prerequisites and load all required inputs before generating red-phase acceptance test scaffolds.
  11. ## MANDATORY EXECUTION RULES
  12. - 📖 Read the entire step file before acting
  13. - ✅ Speak in `{communication_language}`
  14. - 🚫 Halt if requirements are missing
  15. ---
  16. ## EXECUTION PROTOCOLS:
  17. - 🎯 Follow the MANDATORY SEQUENCE exactly
  18. - 💾 Record outputs before proceeding
  19. - 📖 Load the next step only when instructed
  20. ## CONTEXT BOUNDARIES:
  21. - Available context: config, loaded artifacts, and knowledge fragments
  22. - Focus: this step's goal only
  23. - Limits: do not execute future steps
  24. - Dependencies: prior steps' outputs (if any)
  25. ## MANDATORY SEQUENCE
  26. **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
  27. ## 1. Stack Detection
  28. **Read `config.test_stack_type`** from `{config_source}`.
  29. **Auto-Detection Algorithm** (when `test_stack_type` is `"auto"` or not configured):
  30. - Scan `{project-root}` for project manifests:
  31. - **Frontend indicators**: `package.json` with react/vue/angular/next dependencies, `playwright.config.*`, `vite.config.*`, `webpack.config.*`
  32. - **Backend indicators**: `pyproject.toml`, `pom.xml`/`build.gradle`, `go.mod`, `*.csproj`/`*.sln`, `Gemfile`, `Cargo.toml`
  33. - **Both present** = `fullstack`; only frontend = `frontend`; only backend = `backend`
  34. - Explicit `test_stack_type` config value overrides auto-detection
  35. - **Backward compatibility**: if `test_stack_type` is not in config, treat as `"auto"` (preserves current frontend behavior for existing installs)
  36. Store result as `{detected_stack}` = `frontend` | `backend` | `fullstack`
  37. ---
  38. ## 2. Prerequisites (Hard Requirements)
  39. - Story approved with **clear acceptance criteria**
  40. - Test framework configured:
  41. - **If {detected_stack} is `frontend` or `fullstack`:** `playwright.config.ts` or `cypress.config.ts`
  42. - **If {detected_stack} is `backend`:** relevant test config exists (e.g., `conftest.py`, `src/test/`, `*_test.go`, `.rspec`)
  43. - Development environment available
  44. If any are missing: **HALT** and notify the user.
  45. ---
  46. ## 3. Load Story Context
  47. - Read story markdown from `{story_file}` (or ask user if not provided)
  48. - Extract acceptance criteria and constraints
  49. - Identify affected components and integrations
  50. - Derive and store `story_key` from the story filename when available (for BMM stories, this is the filename without `.md`, e.g. `1-2-user-authentication`)
  51. - Derive and store `story_id` from story metadata, the H1 heading, or the filename when available (for BMM stories, this is typically `{epic_num}.{story_num}`)
  52. - If a filename-based `story_key` is not available, create and persist a stable slug from the story title:
  53. - lowercase the title
  54. - collapse runs of whitespace to single `-`
  55. - strip all non-alphanumeric and non-hyphen characters
  56. - trim leading/trailing hyphens
  57. - truncate to a safe max length (64 chars)
  58. - Use that slug as `story_key` and for `{outputFile}` basename so all checklist and handoff paths stay consistent
  59. - If `story_id` is still unavailable after metadata/H1/filename parsing, set it to the final `story_key` so `story_id` is never empty
  60. - Preserve `{story_file}` as a tracked artifact path for later handoff into BMM `dev-story`
  61. ---
  62. ## 4. Load Framework & Existing Patterns
  63. - Read framework config
  64. - Inspect `{test_dir}` for existing test patterns, fixtures, helpers
  65. ## 4.5 Read TEA Config Flags
  66. From `{config_source}`:
  67. - `tea_use_playwright_utils`
  68. - `tea_use_pactjs_utils`
  69. - `tea_pact_mcp`
  70. - `tea_browser_automation`
  71. - `test_stack_type`
  72. ---
  73. ### Tiered Knowledge Loading
  74. Load fragments based on their `tier` classification in `tea-index.csv`:
  75. 1. **Core tier** (always load): Foundational fragments required for this workflow
  76. 2. **Extended tier** (load on-demand): Load when deeper analysis is needed or when the user's context requires it
  77. 3. **Specialized tier** (load only when relevant): Load only when the specific use case matches (e.g., contract-testing only for microservices, email-auth only for email flows)
  78. > **Context Efficiency**: Loading only core fragments reduces context usage by 40-50% compared to loading all fragments.
  79. ### Playwright Utils Loading Profiles
  80. **If `tea_use_playwright_utils` is enabled**, select the appropriate loading profile:
  81. - **API-only profile** (when `{detected_stack}` is `backend` or no `page.goto`/`page.locator` found in test files):
  82. Load: `overview`, `api-request`, `auth-session`, `recurse` (~1,800 lines)
  83. - **Full UI+API profile** (when `{detected_stack}` is `frontend`/`fullstack` or browser tests detected):
  84. Load: all Playwright Utils core fragments (~4,500 lines)
  85. **Detection**: Scan `{test_dir}` for files containing `page.goto` or `page.locator`. If none found, use API-only profile.
  86. ### Pact.js Utils Loading
  87. **If `tea_use_pactjs_utils` is enabled** (and `{detected_stack}` is `backend` or `fullstack`, or microservices indicators detected):
  88. Load: `pactjs-utils-overview.md`, `pactjs-utils-consumer-helpers.md`, `pactjs-utils-provider-verifier.md`, `pactjs-utils-request-filter.md`, `pact-consumer-di.md`, `pact-consumer-framework-setup.md`, `pact-broker-webhooks.md`
  89. **If `tea_use_pactjs_utils` is disabled** but contract testing is relevant:
  90. Load: `contract-testing.md`
  91. ### Pact MCP Loading
  92. **If `tea_pact_mcp` is `"mcp"`:**
  93. Load: `pact-mcp.md`
  94. ## 5. Load Knowledge Base Fragments
  95. Use `{knowledgeIndex}` to load:
  96. **Core (always):**
  97. - `data-factories.md`
  98. - `component-tdd.md`
  99. - `test-quality.md`
  100. - `test-healing-patterns.md`
  101. **If {detected_stack} is `frontend` or `fullstack`:**
  102. - `selector-resilience.md`
  103. - `timing-debugging.md`
  104. **Playwright Utils (if enabled and {detected_stack} is `frontend` or `fullstack`):**
  105. - `overview.md`, `api-request.md`, `network-recorder.md`, `auth-session.md`, `intercept-network-call.md`, `recurse.md`, `log.md`, `file-utils.md`, `network-error-monitor.md`, `fixtures-composition.md`
  106. **Playwright CLI (if tea_browser_automation is "cli" or "auto" and {detected_stack} is `frontend` or `fullstack`):**
  107. - `playwright-cli.md`
  108. **MCP Patterns (if tea_browser_automation is "mcp" or "auto" and {detected_stack} is `frontend` or `fullstack`):**
  109. - (existing MCP-related fragments, if any are added in future)
  110. **Traditional Patterns (if utils disabled and {detected_stack} is `frontend` or `fullstack`):**
  111. - `fixture-architecture.md`
  112. - `network-first.md`
  113. **Backend Patterns (if {detected_stack} is `backend` or `fullstack`):**
  114. - `test-levels-framework.md`
  115. - `test-priorities-matrix.md`
  116. - `ci-burn-in.md`
  117. **Pact.js Utils (if enabled):**
  118. - `pactjs-utils-overview.md`, `pactjs-utils-consumer-helpers.md`, `pactjs-utils-provider-verifier.md`, `pactjs-utils-request-filter.md`, `pact-consumer-di.md`, `pact-consumer-framework-setup.md`, `pact-broker-webhooks.md`
  119. **Contract Testing (if pactjs-utils disabled but relevant):**
  120. - `contract-testing.md`
  121. **Pact MCP (if tea_pact_mcp is "mcp"):**
  122. - `pact-mcp.md`
  123. ---
  124. ## 6. Confirm Inputs
  125. Summarize loaded inputs and confirm with the user. Then proceed.
  126. ---
  127. ## 7. Save Progress
  128. **Save this step's accumulated work to `{outputFile}`.**
  129. - **If `{outputFile}` does not exist** (first save), create it with YAML frontmatter:
  130. ```yaml
  131. ---
  132. stepsCompleted: ['step-01-preflight-and-context']
  133. lastStep: 'step-01-preflight-and-context'
  134. lastSaved: '{date}'
  135. ---
  136. ```
  137. Then write this step's output below the frontmatter.
  138. - **If `{outputFile}` already exists**, update:
  139. - Add `'step-01-preflight-and-context'` to `stepsCompleted` array (only if not already present)
  140. - Set `lastStep: 'step-01-preflight-and-context'`
  141. - Set `lastSaved: '{date}'`
  142. - Append this step's output to the appropriate section.
  143. **Update frontmatter fields**:
  144. - Set `storyId` to `{story_id}`
  145. - Set `storyKey` to `{story_key}`
  146. - Set `storyFile` to `{story_file}`
  147. - Set `atddChecklistPath` to `{outputFile}`
  148. - Initialize `generatedTestFiles` to `[]`
  149. - Set `inputDocuments` to the list of artifact paths loaded in this step (e.g., knowledge fragments, test design documents, configuration files)
  150. Load next step: `{nextStepFile}`
  151. ## 🚨 SYSTEM SUCCESS/FAILURE METRICS:
  152. ### ✅ SUCCESS:
  153. - Step completed in full with required outputs
  154. ### ❌ SYSTEM FAILURE:
  155. - Skipped sequence steps or missing outputs
  156. **Master Rule:** Skipping steps is FORBIDDEN.