aw-spec-cli 0.1.1 → 0.1.3

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 (71) hide show
  1. package/assets/.agents/skills/aw-spec-addcomponent/SKILL.md +18 -5
  2. package/assets/.agents/skills/aw-spec-analyze/SKILL.md +4 -0
  3. package/assets/.agents/skills/aw-spec-clarify/SKILL.md +4 -0
  4. package/assets/.agents/skills/aw-spec-constitution/SKILL.md +4 -0
  5. package/assets/.agents/skills/aw-spec-fast-implement/SKILL.md +268 -0
  6. package/assets/.agents/skills/aw-spec-foundation/SKILL.md +219 -49
  7. package/assets/.agents/skills/aw-spec-implement/SKILL.md +11 -0
  8. package/assets/.agents/skills/aw-spec-minimal-implementation/SKILL.md +209 -0
  9. package/assets/.agents/skills/aw-spec-plan/SKILL.md +4 -0
  10. package/assets/.agents/skills/aw-spec-specify/SKILL.md +4 -0
  11. package/assets/.agents/skills/aw-spec-tasks/SKILL.md +4 -0
  12. package/assets/.claude/skills/aw-spec-addcomponent/SKILL.md +18 -5
  13. package/assets/.claude/skills/aw-spec-analyze/SKILL.md +4 -0
  14. package/assets/.claude/skills/aw-spec-clarify/SKILL.md +4 -0
  15. package/assets/.claude/skills/aw-spec-constitution/SKILL.md +4 -0
  16. package/assets/.claude/skills/aw-spec-fast-implement/SKILL.md +268 -0
  17. package/assets/.claude/skills/aw-spec-foundation/SKILL.md +219 -49
  18. package/assets/.claude/skills/aw-spec-implement/SKILL.md +11 -0
  19. package/assets/.claude/skills/aw-spec-minimal-implementation/SKILL.md +209 -0
  20. package/assets/.claude/skills/aw-spec-plan/SKILL.md +4 -0
  21. package/assets/.claude/skills/aw-spec-specify/SKILL.md +4 -0
  22. package/assets/.claude/skills/aw-spec-tasks/SKILL.md +4 -0
  23. package/assets/.kilocode/rules/specify-rules.md +4 -0
  24. package/assets/.kilocode/workflows/aw-spec-addcomponent.md +129 -0
  25. package/assets/.kilocode/workflows/aw-spec-agent-context.update.md +31 -0
  26. package/assets/.kilocode/workflows/aw-spec-analyze.md +296 -0
  27. package/assets/.kilocode/workflows/aw-spec-checklist.md +374 -0
  28. package/assets/.kilocode/workflows/aw-spec-clarify.md +320 -0
  29. package/assets/.kilocode/workflows/aw-spec-constitution.md +194 -0
  30. package/assets/.kilocode/workflows/aw-spec-fast-implement.md +263 -0
  31. package/assets/.kilocode/workflows/aw-spec-foundation.md +358 -0
  32. package/assets/.kilocode/workflows/aw-spec-implement.md +279 -0
  33. package/assets/.kilocode/workflows/aw-spec-minimal-implementation.md +204 -0
  34. package/assets/.kilocode/workflows/aw-spec-plan.md +221 -0
  35. package/assets/.kilocode/workflows/aw-spec-select-domain.md +73 -0
  36. package/assets/.kilocode/workflows/aw-spec-specify.md +382 -0
  37. package/assets/.kilocode/workflows/aw-spec-tasks.md +259 -0
  38. package/assets/.kilocode/workflows/aw-spec-taskstoissues.md +107 -0
  39. package/assets/docs/ModularMonolith/ModularMonolith.Reference.pack.txt +25248 -0
  40. package/assets/docs/ModularMonolith/ModularMonolith.pack.txt +5726 -0
  41. package/assets/docs/ModularMonolith/pack-foundation.ps1 +145 -0
  42. package/assets/docs/ModularMonolith/pack-foundation.sh +196 -0
  43. package/assets/docs/ModularMonolith/pack-reference-foundation.ps1 +157 -0
  44. package/assets/docs/ModularMonolith/pack-reference-foundation.sh +209 -0
  45. package/assets/docs/ModularMonolith/unpack-foundation.ps1 +126 -0
  46. package/assets/docs/ModularMonolith/unpack-foundation.sh +217 -0
  47. package/assets/docs/ModularMonolith/unpack-reference-foundation.ps1 +129 -0
  48. package/assets/docs/ModularMonolith/unpack-reference-foundation.sh +218 -0
  49. package/assets/docs/VerticalSlice/VerticalSlice.Reference.pack.txt +19318 -0
  50. package/assets/docs/VerticalSlice/pack-reference-foundation.ps1 +157 -0
  51. package/assets/docs/VerticalSlice/pack-reference-foundation.sh +209 -0
  52. package/assets/docs/VerticalSlice/unpack-reference-foundation.ps1 +129 -0
  53. package/assets/docs/VerticalSlice/unpack-reference-foundation.sh +218 -0
  54. package/assets/docs/components/Email/README.md +7 -0
  55. package/assets/docs/components/Email/ReferenceEndpoints/SendEmailEndpoint.cs +84 -0
  56. package/assets/docs/components/Email/integration.md +57 -17
  57. package/assets/docs/components/Jobs/integration.md +29 -15
  58. package/assets/docs/components/QrGenerator/README.md +7 -0
  59. package/assets/docs/components/QrGenerator/ReferenceEndpoints/GenerateQrEndpoint.cs +57 -0
  60. package/assets/docs/components/QrGenerator/integration.md +51 -6
  61. package/assets/docs/components/README.md +19 -2
  62. package/assets/docs/domainspecs/healthcare/comandrulemap.md +47 -0
  63. package/assets/docs/domainspecs/pharma/comandrulemap.md +50 -0
  64. package/dist/commands/init.d.ts.map +1 -1
  65. package/dist/commands/init.js +3 -2
  66. package/dist/commands/init.js.map +1 -1
  67. package/dist/utils/copy-assets.d.ts +8 -1
  68. package/dist/utils/copy-assets.d.ts.map +1 -1
  69. package/dist/utils/copy-assets.js +1 -0
  70. package/dist/utils/copy-assets.js.map +1 -1
  71. package/package.json +5 -2
@@ -0,0 +1,263 @@
1
+ ---
2
+ name: "aw-spec-fast-implement"
3
+ description: "Token-efficient fast path that collapses /aw-spec-plan + /aw-spec-tasks + /aw-spec-analyze + /aw-spec-implement into a single pass: load engineering and domain standards once, derive a compact design, self-check it, and implement the spec directly following both technological and domain patterns. Run after /aw-spec-specify (and optionally /aw-spec-clarify or a verify step)."
4
+ argument-hint: "Optional implementation guidance, scope filter (e.g. backend-only), or design hints"
5
+ compatibility: "Requires aw-spec project structure with .aw-spec/ directory and an existing spec.md (produced by /aw-spec-specify)"
6
+ ---
7
+
8
+
9
+ ## User Input
10
+
11
+ ```text
12
+ $ARGUMENTS
13
+ ```
14
+
15
+ You **MUST** consider the user input before proceeding (if not empty).
16
+
17
+ ## Context Reuse (cross-command dedup)
18
+
19
+ **Skip Read-ing any file already in this conversation.** Before loading a standards/domain/template/spec file this command names, check whether it is already in context (loaded earlier here or by a prior `/aw-spec-*` command). If present and unchanged, reuse it and **skip the Read** — only Read files not yet loaded. A file already in context still counts as loaded; this just avoids the redundant re-read.
20
+
21
+ ## What this command does
22
+
23
+ Collapses `/aw-spec-plan` → `/aw-spec-tasks` → `/aw-spec-analyze` → `/aw-spec-implement` into one pass: load the deduplicated union of standards + domain rules **once**, fold the design into a single compact `plan.md` + `tasks.md` (no separate research/data-model/contracts/quickstart), inline the analyze consistency check as an in-memory gate, then implement. Same end result as the full sequence; non-negotiables (constitution, standards, domain rules, spec checklist, constitution/coverage gates, architecture patterns, extension hooks) are all honored — only the intermediate documents and repeated context loads are dropped.
24
+
25
+ ## Project Structure Gate (run before loading standards)
26
+
27
+ **Before loading standards or writing code, confirm a scaffolded app exists** — the output of `/aw-spec-foundation`, not just `.aw-spec/`/`docs/`/`specs/` framework files. Check the repo root (Glob/Bash) for a real build entrypoint, ignoring matches only inside `.aw-spec/`/`docs/`/`specs/`: `*.sln` or `*.csproj` under `src/` (.NET/AppWeaver), else `package.json`/`pom.xml`/`build.gradle`/`go.mod`/`Cargo.toml`/`pyproject.toml` etc.
28
+
29
+ - **None found → STOP, no side effects** (don't load standards, run hooks, or write anything): tell the developer *"No scaffolded project found — run `/aw-spec-foundation ModularMonolith <AppName>` (or `VerticalSlice <AppName>`) first, then re-run."*
30
+ - **Found →** use its solution/host-project path as the implementation target and continue.
31
+
32
+ ## Auto-Loaded Engineering Standards (Required Context)
33
+
34
+ **Before doing anything else in this command, load the project engineering-standards files listed below into context using the Read tool — ONCE.** These were previously supplied manually as `@docs/...` mentions; they are now loaded automatically so the user does not need to pass them. Rules:
35
+
36
+ - Read each file below **before** starting the Pre-Execution Checks / Outline. Treat their contents as authoritative engineering standards for this command, second only to `.aw-spec/memory/constitution.md`.
37
+ - This list is the **deduplicated union** of the standards that `/aw-spec-plan`, `/aw-spec-tasks`, `/aw-spec-analyze`, and `/aw-spec-implement` each load. Load every file **exactly once**; do not re-read a file you have already loaded in this pass.
38
+ - If a listed file does not exist, skip it silently and continue — do **not** error and do **not** ask the user to provide it.
39
+ - This is the **domain-agnostic technical** set, so the framework is reusable across domains. Domain-specific rule files (e.g. healthcare FHIR/HL7/PHI) are **not** part of this set — they are offered separately in the **Domain Rule-File Selection** section below (sourced from `comandrulemap.md`). You can also add any extra file directly with an `@` mention.
40
+
41
+ Standards for `/aw-spec-fast-implement` (union of the collapsed commands):
42
+ - docs/architecture/clean-architecture.md
43
+ - docs/architecture/modular-monolith.md
44
+ - docs/architecture/folder-structure.md
45
+ - docs/architecture/cqrs.md
46
+ - docs/architecture/vertical-slices.md
47
+ - docs/architecture/persistence.md
48
+ - docs/architecture/testing.md
49
+ - docs/architecture/eventing.md
50
+ - docs/domain/domain-driven-design.md
51
+ - docs/security/zero-trust.md
52
+ - docs/security/authorization.md
53
+ - docs/security/auditing.md
54
+ - docs/security/data-classification.md
55
+ - docs/governance/coding-standards.md
56
+ - docs/governance/dependency-policy.md
57
+ - docs/governance/api-versioning.md
58
+ - docs/glossary/ai-rules.md
59
+
60
+ ## Domain Rule-File Selection (interactive, once)
61
+
62
+ After the technical standards above are loaded, and **before** the Pre-Execution Checks, resolve the active domain and ask the user — **once for the whole pass** — which **domain** rule files to load:
63
+
64
+ 1. **Resolve the active domain.** Read `.aw-spec/domain.json` and take its `domain` value — the active domain-specs folder name. The candidate domain rule files are the bullet list under the **`## /aw-spec-fast-implement`** heading in `docs/domainspecs/<domain>/comandrulemap.md` — this command has its own canonical entry, exactly like every other `/aw-spec-*` command.
65
+ - **Fallback (older domain maps).** If `comandrulemap.md` exists but has **no** `## /aw-spec-fast-implement` heading, derive the candidate set as the **deduplicated union** of the bullet lists under the `## /aw-spec-plan`, `## /aw-spec-tasks`, `## /aw-spec-analyze`, and `## /aw-spec-implement` headings (in practice `/aw-spec-plan` is the superset). A missing fast-implement heading is **not** an error.
66
+ 2. **Domain gate (missing domain or rules).** If `.aw-spec/domain.json` is absent or its `domain` is empty, **or** `docs/domainspecs/<domain>/comandrulemap.md` does not exist:
67
+ - Ask one single-select question with the AskUserQuestion tool — *"Domain is not set or its rule files are missing (state which: no domain set / domain '<domain>' has no comandrulemap.md). Continue without domain rules?"* — with options **"Continue (technical only)"** and **"Exit"**.
68
+ - **Continue (technical only)** → skip steps 3-5 and proceed with only the auto-loaded technical standards (plus any `@`-mentioned files).
69
+ - **Exit** → stop the command **immediately** with no side effects: do **not** run the Pre-Execution Checks, hooks, Outline, or any later step, and create/modify nothing. Tell the user to run `/aw-spec-select-domain` (or fix the domain folder) and re-run.
70
+ - If interactive questions cannot be asked (non-interactive/automated run), default to **Continue (technical only)**.
71
+ - Exception: if `comandrulemap.md` exists but yields no candidate files (no `## /aw-spec-fast-implement` heading **and** none of the four fallback headings have entries), this is **not** a gate trigger — load no domain files and continue normally to the Pre-Execution Checks.
72
+ 3. **Show a selection box** using the AskUserQuestion tool:
73
+ - Ask one single-select question — *"Domain rule files for /aw-spec-fast-implement:"* — with options **"Select all (recommended)"**, **"Pick a subset"**, and **"None (technical only)"**.
74
+ - If the user chooses **"Pick a subset"**, follow up with **multi-select** questions whose options are the individual candidate files so the user can tick the ones they want. AskUserQuestion allows ≤4 options per question and ≤4 questions per call, so split the candidates into groups of ≤4 (by category: architecture overlays, clinical/domain, security overlays, governance overlays, glossary) across as many calls as needed.
75
+ - If interactive questions cannot be asked (non-interactive or automated run), skip the prompt and default to **Select all**.
76
+ 4. **Load the selection.** Read every file the user selected **exactly once** (the full deduplicated list for "Select all"; nothing extra for "None"). If any selected file does not exist on disk, skip it silently and continue — do not error.
77
+ 5. **Final context set** = the always-loaded technical standards (section above) **+** the domain files selected here **+** any files the user passed via `@` mention in their command. The `@`-mentioned files are always loaded in addition, whether or not they appear in the candidate list, and are never removed by a "None"/subset choice.
78
+ 6. Proceed to the Pre-Execution Checks only after the selected files are loaded.
79
+
80
+ ## Pre-Execution Checks
81
+
82
+ **Check for collapsed pre-hooks (before fast implementation)**:
83
+ - Check if `.aw-spec/extensions.yml` exists in the project root.
84
+ - If it exists, read it and collect hook entries from the `hooks.before_plan`, `hooks.before_tasks`, and `hooks.before_implement` keys (the pre-hook points of the commands this fast path collapses).
85
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally.
86
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
87
+ - **De-duplicate by command**: if the same hook `command` appears under more than one of those keys, execute it **only once** for this pass.
88
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
89
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
90
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
91
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `aw-spec.git.commit` → `/aw-spec-git-commit`.
92
+ - For each executable hook, output the following based on its `optional` flag:
93
+ - **Optional hook** (`optional: true`):
94
+ ```
95
+ ## Extension Hooks
96
+
97
+ **Optional Pre-Hook**: {extension}
98
+ Command: `/{command}`
99
+ Description: {description}
100
+
101
+ Prompt: {prompt}
102
+ To execute: `/{command}`
103
+ ```
104
+ - **Mandatory hook** (`optional: false`):
105
+ ```
106
+ ## Extension Hooks
107
+
108
+ **Automatic Pre-Hook**: {extension}
109
+ Executing: `/{command}`
110
+ EXECUTE_COMMAND: {command}
111
+
112
+ Wait for the result of the hook command before proceeding to the Outline.
113
+ ```
114
+ - If no hooks are registered or `.aw-spec/extensions.yml` does not exist, skip silently.
115
+
116
+ ## Outline
117
+
118
+ ### 1. Resolve paths and seed artifacts (reuses the standard scripts)
119
+
120
+ 1. Run `.aw-spec/scripts/bash/setup-plan.sh --json` from repo root and parse JSON for `FEATURE_SPEC`, `IMPL_PLAN`, `SPECS_DIR`, `BRANCH`. All paths must be absolute. This step also copies the resolved `plan-template` to `IMPL_PLAN` if no plan exists yet (so the next script can resolve the tasks template). For single quotes in args like "I'm Groot", use escape syntax: e.g 'I'\''m Groot' (or double-quote if possible: "I'm Groot").
121
+ 2. **Spec gate**: Read `FEATURE_SPEC` (`spec.md`). If it does not exist or is empty, **STOP** and tell the user to run `/aw-spec-specify` first — this fast path requires a written spec. Do not invent a spec.
122
+ 3. Run `.aw-spec/scripts/bash/setup-tasks.sh --json` from repo root and parse `FEATURE_DIR`, `TASKS_TEMPLATE`, and `AVAILABLE_DOCS`. `TASKS_TEMPLATE` is the resolved tasks template to use when writing `tasks.md`. If `TASKS_TEMPLATE` is empty, fall back to `.aw-spec/templates/tasks-template.md`.
123
+
124
+ ### 2. Load the minimal authoritative context
125
+
126
+ - **REQUIRED**: `spec.md` — user stories with priorities (P1, P2, P3…), Functional Requirements (FR-###), Success Criteria (SC-###), Key Entities, edge cases.
127
+ - **IF EXISTS**: `.aw-spec/memory/constitution.md` — governance constraints (authoritative; MUST principles are non-negotiable).
128
+ - **IF EXISTS**: `FEATURE_DIR/checklists/requirements.md` — the spec quality checklist produced by `/aw-spec-specify`.
129
+ - **IF EXISTS**: any of `research.md`, `data-model.md`, `contracts/`, `quickstart.md` already present in `FEATURE_DIR` (from a prior partial run) — reuse them instead of regenerating.
130
+ - The engineering standards and domain rule files were already loaded above; **do not re-read them**.
131
+
132
+ ### 3. Spec-readiness gate (folds in checklist + clarification status)
133
+
134
+ - If `checklists/requirements.md` exists, scan it. Count total / completed / incomplete items.
135
+ - If any item is incomplete, display a short status line and **ask once**: "The spec quality checklist has incomplete items. Proceed with fast implementation anyway? (yes/no)". Halt on "no"/"stop"/"wait"; continue on "yes"/"proceed"/"continue". In a non-interactive run, default to proceed but record the gap in the Completion Report.
136
+ - If the spec still contains unresolved `[NEEDS CLARIFICATION]` markers, list them and either (a) make a documented reasonable assumption (preferred for the fast path, recorded under Assumptions in `plan.md`), or (b) if a marker is high-impact on scope/security, ask the user a single targeted question before proceeding.
137
+
138
+ ### 4. Derive the design — write a single compact `plan.md`
139
+
140
+ Fill `IMPL_PLAN` (`plan.md`) from the resolved plan template, then **append a "Design Detail" section** so this one file carries everything the separate `research.md` + `data-model.md` + `contracts/` + `quickstart.md` would have carried. Keep it compact — decisions and structure, not prose.
141
+
142
+ Populate:
143
+ - **Summary**: primary requirement + chosen technical approach.
144
+ - **Technical Context**: language/version, primary dependencies, storage, testing, target platform, project type, performance goals, constraints, scale/scope. Resolve unknowns with documented assumptions (do **not** leave `NEEDS CLARIFICATION` for the fast path unless genuinely blocking).
145
+ - **Constitution Check**: evaluate the gates from `.aw-spec/memory/constitution.md`. If a MUST principle is violated and unjustified, **STOP** and report — do not implement around a constitution violation.
146
+ - **Project Structure**: the concrete source layout for this feature, following `docs/architecture/folder-structure.md`, `vertical-slices.md`, and the active domain's `folder-structure.domain.md`. Remove unused template options.
147
+ - **Design Detail** (folded artifacts):
148
+ - *Data Model*: entities, fields, relationships, validation rules, and state transitions (replaces `data-model.md`).
149
+ - *Contracts*: the interfaces this feature exposes — endpoints / commands / queries / events with their request-response shapes, mapped to the user story they serve (replaces `contracts/`). Follow `cqrs.md`, `api-versioning.md`, and the domain interop rules (e.g. FHIR/HL7) where applicable.
150
+ - *Decisions & Rationale*: key technical decisions, why chosen, and notable alternatives rejected (replaces `research.md`).
151
+ - *Validation Quickstart*: the runnable steps that prove the feature works end-to-end (replaces `quickstart.md`).
152
+ - Re-check the Constitution gate after the design is fleshed out.
153
+
154
+ ### 5. Derive the task plan — write `tasks.md`
155
+
156
+ Using `TASKS_TEMPLATE` as the structure, write `tasks.md` organized **by user story** so each story is independently implementable and testable. Follow the strict checklist format from the template:
157
+
158
+ ```text
159
+ - [ ] [TaskID] [P?] [Story?] Description with exact file path
160
+ ```
161
+
162
+ - **Phase 1: Setup** (project initialization) — no story label.
163
+ - **Phase 2: Foundational** (blocking prerequisites for all stories) — no story label.
164
+ - **Phase 3+: one phase per user story** in priority order (P1, P2, P3…), each with a goal and independent-test criterion, each carrying its `[US#]` label.
165
+ - **Final Phase: Polish & cross-cutting concerns** — no story label.
166
+ - **Tests are OPTIONAL** — only generate test tasks if the spec explicitly requests tests or TDD. When generated, tests precede their implementation tasks (write-fail-implement) per `docs/architecture/testing.md`.
167
+ - Mark `[P]` only for tasks on different files with no incomplete dependencies. Give every task an exact file path.
168
+
169
+ ### 6. Inline consistency self-check (replaces `/aw-spec-analyze`)
170
+
171
+ Before writing any code, run a quick **in-memory** gate across `spec.md`, the `plan.md` you just wrote, and `tasks.md`. Do **not** write a report file. Check:
172
+ - **Coverage**: every Functional Requirement and every user story maps to ≥1 task; every buildable Success Criterion (performance/security/availability tooling) has a task. Flag any requirement with zero coverage.
173
+ - **Constitution alignment**: no requirement, design element, or task conflicts with a MUST principle (CRITICAL if it does).
174
+ - **Consistency**: no terminology drift, no conflicting tech choices, no task-ordering contradictions (e.g. integration before its foundational setup).
175
+ - **Ambiguity / underspecification**: vague attributes lacking measurable criteria; tasks referencing undefined components.
176
+
177
+ Resolution:
178
+ - **CRITICAL issues** (constitution MUST violation, zero-coverage of baseline functionality, conflicting requirements): **STOP**, summarize them, and ask the user how to proceed — adjust `plan.md`/`tasks.md` rather than implementing on a broken foundation.
179
+ - **HIGH/MEDIUM/LOW issues**: fix them in `plan.md`/`tasks.md` in place when cheap, otherwise note them and continue.
180
+
181
+ ### 7. Project setup verification
182
+
183
+ Create/verify ignore files based on the actual stack from `plan.md` (this is a .NET/C# AppWeaver project by default — `bin/`, `obj/`, `*.user`, `*.suo` for `.gitignore`; add Docker/other patterns only if detected). Use `git rev-parse --git-dir` to confirm a git repo before creating `.gitignore`. Append only missing critical patterns to existing ignore files; do not overwrite them.
184
+
185
+ ### 8. Implement directly
186
+
187
+ Execute the tasks in `tasks.md`, phase by phase, applying the loaded standards and domain patterns:
188
+ - **Setup → Foundational → User Stories (priority order) → Polish.** Complete each phase before the next; respect dependencies; `[P]` tasks may proceed together; tasks on the same file run sequentially.
189
+ - **Follow the patterns**: vertical slices, CQRS command/query separation, DDD aggregates/value objects, the prescribed folder structure, persistence/eventing conventions, authorization/auditing/data-classification/zero-trust requirements, and the active domain's overlays (e.g. FHIR/HL7 mapping, consent, HIPAA, audit) — all already in context.
190
+ - **TDD when requested**: write the story's tests first and see them fail before implementing.
191
+ - **Mark every completed task `[X]` in `tasks.md`** as you finish it.
192
+ - Report progress per phase. Halt on a failing non-parallel task with a clear, actionable error; for `[P]` tasks, continue the successful ones and report the failures.
193
+
194
+ ### 9. Completion validation
195
+
196
+ - All required tasks completed and marked `[X]`.
197
+ - Implementation matches `spec.md` (requirements + user stories) and the `plan.md` design.
198
+ - The project builds; if tests were requested, they pass.
199
+ - The validation quickstart steps in `plan.md` succeed (or are clearly documented as pending).
200
+
201
+ ## Mandatory Post-Execution Hooks
202
+
203
+ **You MUST complete this section before reporting completion to the user.**
204
+
205
+ Check if `.aw-spec/extensions.yml` exists in the project root.
206
+ - If it does not exist, skip to the Completion Report.
207
+ - If it exists, read it and collect hook entries from the `hooks.after_plan`, `hooks.after_tasks`, and `hooks.after_implement` keys (the post-hook points of the commands this fast path collapses).
208
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue to the Completion Report.
209
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
210
+ - **De-duplicate by command**: if the same hook `command` (e.g. `aw-spec.agent-context.update`, which is registered for both `after_plan` and elsewhere) appears under more than one of those keys, execute it **only once** for this pass.
211
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
212
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
213
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
214
+ - When constructing slash commands from hook command names, replace dots (`.`) with hyphens (`-`). For example, `aw-spec.git.commit` → `/aw-spec-git-commit`.
215
+ - For each executable hook, output the following based on its `optional` flag:
216
+ - **Mandatory hook** (`optional: false`) — **You MUST emit `EXECUTE_COMMAND:` for each mandatory hook**:
217
+ ```
218
+ ## Extension Hooks
219
+
220
+ **Automatic Hook**: {extension}
221
+ Executing: `/{command}`
222
+ EXECUTE_COMMAND: {command}
223
+ ```
224
+ - **Optional hook** (`optional: true`):
225
+ ```
226
+ ## Extension Hooks
227
+
228
+ **Optional Hook**: {extension}
229
+ Command: `/{command}`
230
+ Description: {description}
231
+
232
+ Prompt: {prompt}
233
+ To execute: `/{command}`
234
+ ```
235
+
236
+ ## Completion Report
237
+
238
+ Report final status with:
239
+ - `FEATURE_DIR`, `plan.md`, and `tasks.md` paths.
240
+ - Task summary: total tasks, tasks per user story, how many are now `[X]`.
241
+ - Standards and domain rule files applied (domain name + count, or "technical only").
242
+ - Any consistency-gate findings that were noted but not blocking.
243
+ - Build/test status and whether the validation quickstart passed.
244
+ - Any documented assumptions or deferred items.
245
+
246
+ ## Key rules
247
+
248
+ - Use absolute paths for filesystem operations; use project-relative paths for references in `plan.md`/`tasks.md` and agent-context files.
249
+ - Load each standards/domain/spec file **once** per pass — never re-read context you already hold. This single-load discipline is the primary token saving over the four-command sequence.
250
+ - The constitution and the loaded standards are authoritative. **ERROR/STOP on unjustified constitution-gate failures or zero-coverage of baseline functionality** rather than implementing around them.
251
+ - This command assumes `spec.md` exists. If it is missing, suggest `/aw-spec-specify`. If the user wants the full, audited artifact set (separate research/data-model/contracts/quickstart + analysis report), suggest the standard `/aw-spec-plan → /aw-spec-tasks → /aw-spec-analyze → /aw-spec-implement` sequence instead.
252
+
253
+ ## Done When
254
+
255
+ - [ ] Engineering standards and domain rule files loaded **once** (deduplicated union)
256
+ - [ ] `spec.md` present and read; spec-readiness gate cleared or its gaps documented
257
+ - [ ] Compact `plan.md` written (with folded data-model / contracts / decisions / quickstart) and constitution gate passed
258
+ - [ ] `tasks.md` generated by user story in strict checklist format
259
+ - [ ] Inline consistency self-check passed (no unresolved CRITICAL issues)
260
+ - [ ] All tasks implemented following technological and domain standards, and marked `[X]`
261
+ - [ ] Implementation validated against spec, plan, and (if requested) tests
262
+ - [ ] Extension hooks dispatched or skipped per the rules above
263
+ - [ ] Completion reported with artifact paths, task summary, standards applied, and build/test status
@@ -0,0 +1,358 @@
1
+ ---
2
+ name: "aw-spec-foundation"
3
+ description: "Scaffold a complete, compiling project by unpacking a verified foundation bundle (docs/<FoundationName>/<FoundationName>.pack.txt) and renaming its sentinel app name to your app name."
4
+ argument-hint: "FoundationName AppName [OutputDirectory] — e.g. VerticalSlice AppWeaver.Health"
5
+ compatibility: "Requires docs/<FoundationName>/<FoundationName>.pack.txt and an unpacker (unpack-foundation.ps1 preferred via pwsh; unpack-foundation.sh fallback when pwsh is absent)"
6
+ metadata:
7
+ author: "github-aw-spec"
8
+ user-invocable: true
9
+ disable-model-invocation: false
10
+ ---
11
+
12
+ ## User Input
13
+
14
+ ```text
15
+ $ARGUMENTS
16
+ ```
17
+
18
+ Parse the arguments (positional, in order):
19
+
20
+ - `FOUNDATION_NAME` — first token (e.g. `VerticalSlice`).
21
+ - `APP_NAME` — second token; the root namespace / solution name (e.g. `AppWeaver.Health`, `MyCompany.Orders`).
22
+ - `OUTPUT_DIR` — third token (optional); where to write the solution. **Default: the repo root (`.`).**
23
+
24
+ If `FOUNDATION_NAME` or `APP_NAME` is missing, stop and tell the user:
25
+
26
+ ```
27
+ Usage: /aw-spec-foundation <FoundationName> <AppName> [OutputDirectory]
28
+ Example: /aw-spec-foundation VerticalSlice AppWeaver.Health
29
+ ```
30
+
31
+ ---
32
+
33
+ ## How this works
34
+
35
+ Unpack a **byte-for-byte bundle of a verified solution**
36
+ (`docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt`) via its unpack script, which rewrites the
37
+ pack's **sentinel** app name to `APP_NAME` (in dotted / underscored / lower-hyphen / lower-dot
38
+ forms) across file contents and names. The sample domain folder `Projects` and `AppWeaver.*`
39
+ framework packages are **left unchanged**.
40
+
41
+ > ⚠️ **Never open a `.pack.txt` with Read/`cat`/`head`/`tail`** — it is ~700 KB (≈180K tokens).
42
+ > The script parses and writes everything to disk; the only thing you read from the pack is its
43
+ > `#` header, via a bounded `grep` (Step 1).
44
+
45
+ ---
46
+
47
+ ## Step 1 — Locate the bundle
48
+
49
+ Resolve these paths relative to the repo root:
50
+
51
+ - `PACK_FILE` = `docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt`
52
+ - `UNPACK_PS1` = `docs/<FOUNDATION_NAME>/unpack-foundation.ps1`
53
+
54
+ Check both exist.
55
+
56
+ - If the folder `docs/<FOUNDATION_NAME>/` does not exist:
57
+ ```
58
+ Foundation '<FOUNDATION_NAME>' not found. Expected: docs/<FOUNDATION_NAME>/
59
+ Available foundations: <list the subdirectories under docs/ that contain a *.pack.txt>
60
+ ```
61
+ Then stop.
62
+
63
+ - If the folder exists but `PACK_FILE` is missing:
64
+ ```
65
+ Foundation '<FOUNDATION_NAME>' has no bundle yet (expected <PACK_FILE>).
66
+ Build it first — see docs/<FOUNDATION_NAME>/PACKAGING.md:
67
+ 1. Create the sample solution under the sentinel name in a scratch folder.
68
+ 2. Run docs/<FOUNDATION_NAME>/pack-foundation.ps1 to produce the .pack.txt.
69
+ ```
70
+ Then stop.
71
+
72
+ Read **only** the `#` header lines of `PACK_FILE` to obtain `SENTINEL` and the declared
73
+ file count. Use a bounded command — **do not** open the pack with the Read tool, `cat`,
74
+ `head`, or `tail` (it would load ~20K tokens of pack body into context):
75
+
76
+ ```bash
77
+ grep -m 30 '^#' "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt"
78
+ ```
79
+
80
+ This returns just the sentinel, file count, and replacement contract.
81
+
82
+ ---
83
+
84
+ ## Step 2 — Confirm the scaffold plan
85
+
86
+ Show this summary and wait for `yes`:
87
+
88
+ ```
89
+ Foundation : <FOUNDATION_NAME>
90
+ Bundle : <PACK_FILE> (<N> files, sentinel: <SENTINEL>)
91
+ App Name : <APP_NAME>
92
+ Output : <OUTPUT_DIR or repo root>
93
+
94
+ Rename (from bundle sentinel -> your app name):
95
+ <SENTINEL> -> <APP_NAME>
96
+ <SENTINEL _-form> -> <APP_NAME _-form>
97
+ <sentinel --form> -> <appname --form>
98
+ <sentinel .-form> -> <appname lower-dot>
99
+
100
+ Unchanged: 'Projects' sample domain, all AppWeaver.* framework packages.
101
+
102
+ Proceed? (yes/no)
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Step 3 — Dry run, then unpack
108
+
109
+ ### Choosing the runner (do this first)
110
+
111
+ Each foundation ships two equivalent unpackers. **Prefer PowerShell** (`unpack-foundation.ps1`,
112
+ ~50× faster); fall back to bash (`unpack-foundation.sh`) only when `pwsh` is absent. Detect once
113
+ and reuse the choice for every unpack call (Steps 3 and 4c):
114
+
115
+ ```bash
116
+ command -v pwsh >/dev/null 2>&1 && echo "pwsh" || echo "sh"
117
+ ```
118
+
119
+ The bash port takes the same flags in kebab-case (`--pack-file`, `--target-app-name`,
120
+ `--out-dir`, `--dry-run`, `--force`); positional args also work.
121
+
122
+ ### Dry run
123
+
124
+ First do a **dry run** to surface any path collisions without writing anything.
125
+
126
+ PowerShell (preferred):
127
+ ```bash
128
+ pwsh -NoProfile -File "docs/<FOUNDATION_NAME>/unpack-foundation.ps1" \
129
+ -PackFile "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt" \
130
+ -TargetAppName "<APP_NAME>" \
131
+ -OutDir "<OUTPUT_DIR>" \
132
+ -DryRun
133
+ ```
134
+
135
+ bash fallback (only if `pwsh` is missing):
136
+ ```bash
137
+ bash "docs/<FOUNDATION_NAME>/unpack-foundation.sh" \
138
+ --pack-file "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt" \
139
+ --target-app-name "<APP_NAME>" \
140
+ --out-dir "<OUTPUT_DIR>" \
141
+ --dry-run
142
+ ```
143
+
144
+ - If it reports files that **already exist** (the script throws on conflict unless `-Force`
145
+ / `--force`), show the conflict list and ask whether to overwrite. Only add the force flag
146
+ if the user agrees.
147
+ - Otherwise run it for real (drop `-DryRun`/`--dry-run`; add the force flag only if the user
148
+ approved overwrite). PowerShell (preferred):
149
+
150
+ ```bash
151
+ pwsh -NoProfile -File "docs/<FOUNDATION_NAME>/unpack-foundation.ps1" \
152
+ -PackFile "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt" \
153
+ -TargetAppName "<APP_NAME>" \
154
+ -OutDir "<OUTPUT_DIR>"
155
+ ```
156
+
157
+ bash fallback:
158
+ ```bash
159
+ bash "docs/<FOUNDATION_NAME>/unpack-foundation.sh" \
160
+ --pack-file "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.pack.txt" \
161
+ --target-app-name "<APP_NAME>" \
162
+ --out-dir "<OUTPUT_DIR>"
163
+ ```
164
+
165
+ Capture the script's stdout (it reports the number of files written). Do **not**
166
+ hand-edit or regenerate any unpacked file.
167
+
168
+ ---
169
+
170
+ ## Step 4 — Offer reference project
171
+
172
+ After the foundation unpack succeeds, ask the user whether to also unpack the bundled
173
+ reference sample:
174
+
175
+ ```
176
+ AskUserQuestion — single-select:
177
+ "Would you like to include the reference sample project?"
178
+ • "Yes — include reference sample" (description: "Unpacks sample domain slices — Projects, Users, Reports — and merges them into the scaffolded project")
179
+ • "No — skip reference sample" (description: "Leave the project as a clean, empty foundation")
180
+ ```
181
+
182
+ - If the user chooses **No**, proceed directly to Step 5 (Verify).
183
+ - If the user chooses **Yes**, continue with the steps below **before** verifying.
184
+
185
+ ### Step 4a — Locate the reference pack
186
+
187
+ `REFERENCE_PACK_FILE` = `docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.Reference.pack.txt`
188
+ `UNPACK_REF` = `docs/<FOUNDATION_NAME>/unpack-reference-foundation.ps1` (preferred)
189
+ or `…/unpack-reference-foundation.sh` (fallback when `pwsh` is absent)
190
+
191
+ If the pack or the matching unpacker for your chosen runner is missing:
192
+ ```
193
+ Reference pack not found: <REFERENCE_PACK_FILE>
194
+ Run pack-reference-foundation.ps1 first (see docs/<FOUNDATION_NAME>/).
195
+ Skipping reference sample.
196
+ ```
197
+ Then proceed to Step 5 without unpacking reference files.
198
+
199
+ Read the header of `REFERENCE_PACK_FILE` to obtain `REF_SENTINEL` and `REF_FILE_COUNT` —
200
+ again with a bounded `grep -m 30 '^#' "<REFERENCE_PACK_FILE>"`, **never** a full Read/`cat`
201
+ of the reference pack (it is just as large as the foundation pack).
202
+
203
+ ### Step 4b — Save the foundation DbContext before overwrite
204
+
205
+ The reference unpack will conflict with (and overwrite) `ApplicationDbContext.cs` because
206
+ both packs rename their sentinel's project structure to the same output path. Before running
207
+ the reference unpack, **read and save** the full content of the existing foundation DbContext:
208
+
209
+ ```powershell
210
+ # Locate it — do NOT assume a fixed path; search the output tree:
211
+ $dbCtxPath = Get-ChildItem -Path "<OUTPUT_DIR>/src" -Recurse -Filter "ApplicationDbContext.cs" |
212
+ Select-Object -First 1 -ExpandProperty FullName
213
+ $foundationDbCtx = [System.IO.File]::ReadAllText($dbCtxPath)
214
+ ```
215
+
216
+ Store `$foundationDbCtx` in memory; you will need it in Step 4d.
217
+
218
+ ### Step 4c — Unpack the reference pack
219
+
220
+ Run with `-Force` / `--force` (the DbContext and any other overlapping files will be
221
+ overwritten — the DbContext will be restored via merge in Step 4d). Use the **same runner**
222
+ you selected in Step 3 (`pwsh` preferred, `.sh` only if `pwsh` is missing).
223
+
224
+ PowerShell (preferred):
225
+ ```bash
226
+ pwsh -NoProfile -File "docs/<FOUNDATION_NAME>/unpack-reference-foundation.ps1" \
227
+ -PackFile "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.Reference.pack.txt" \
228
+ -TargetAppName "<APP_NAME>" \
229
+ -OutDir "<OUTPUT_DIR>" \
230
+ -Force
231
+ ```
232
+
233
+ bash fallback:
234
+ ```bash
235
+ bash "docs/<FOUNDATION_NAME>/unpack-reference-foundation.sh" \
236
+ --pack-file "docs/<FOUNDATION_NAME>/<FOUNDATION_NAME>.Reference.pack.txt" \
237
+ --target-app-name "<APP_NAME>" \
238
+ --out-dir "<OUTPUT_DIR>" \
239
+ --force
240
+ ```
241
+
242
+ Capture the count of files written.
243
+
244
+ ### Step 4d — Merge ApplicationDbContext.cs
245
+
246
+ After the reference unpack the DbContext file now contains the **reference version**
247
+ (sample DbSet<> properties only, no `OnModelCreating`). Merge it with the saved
248
+ **foundation version** (full `OnModelCreating`, no DbSet<>) to produce a single
249
+ complete DbContext.
250
+
251
+ **Merge rules — apply in order:**
252
+
253
+ 1. **Base = foundation file.** Start with `$foundationDbCtx` as the text to edit.
254
+
255
+ 2. **Add missing `using` directives.** Read the reference DbContext's `using` lines.
256
+ For each one not already present in the foundation file, insert it at the top of the
257
+ using block (before the namespace declaration or the class declaration).
258
+
259
+ 3. **Add `DbSet<>` properties.** Extract every `public DbSet<…>` property line from the
260
+ reference DbContext. Insert them as a block inside the foundation class body, directly
261
+ after the opening brace `{` of the class and before `OnModelCreating` (or before the
262
+ closing `}` if there is no `OnModelCreating`). Preserve the comment above the DbSets
263
+ (e.g. `// TaskContext`) if present.
264
+
265
+ 4. **Preserve everything else in the foundation file unchanged.** Do not touch the class
266
+ header, constructor, interface list, `OnModelCreating`, or any existing using statements.
267
+
268
+ 5. **Write the merged result** back to `$dbCtxPath` (overwrite the reference version that
269
+ the unpack left there).
270
+
271
+ **Example — VerticalSlice result after merge:**
272
+ ```csharp
273
+ using Microsoft.EntityFrameworkCore;
274
+ using AppWeaver.Repository.EfCore;
275
+ using AppWeaver.Contexts;
276
+ using AppWeaver.DomainAbstraction.Entities;
277
+ // ← reference usings inserted here, e.g.:
278
+ using AppWeaver.Pharma.Service.Projects.Domain;
279
+ using AppWeaver.Pharma.Service.Users.Domain;
280
+ using AppWeaver.Pharma.Service.Reports.Domain;
281
+
282
+ namespace AppWeaver.Pharma.Service.Infrastructure;
283
+
284
+ public class ApplicationDbContext(
285
+ DbContextOptions<ApplicationDbContext> options,
286
+ ICurrentTenant? tenant = null
287
+ ) : ContextAwareDbContext<ApplicationDbContext>(options, tenant)
288
+ {
289
+ // TaskContext ← DbSet block from reference, inserted here
290
+ public DbSet<Project> Projects => Set<Project>();
291
+ public DbSet<ProjectTask> ProjectTasks => Set<ProjectTask>();
292
+ public DbSet<TaskUser> TaskUsers => Set<TaskUser>();
293
+ public DbSet<ReportRequest> ReportRequests => Set<ReportRequest>();
294
+
295
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
296
+ {
297
+ // ... full foundation OnModelCreating preserved unchanged ...
298
+ }
299
+ }
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Step 5 — Verify
305
+
306
+ After unpacking (and merging, if reference was included):
307
+
308
+ 1. **File count** — confirm the written count(s) match the bundle's declared file count(s).
309
+ 2. **Sentinel residue** — search the output tree for any leftover sentinel token
310
+ (dotted/underscored/lower forms). There should be **none**. If any remain, report the
311
+ files (it indicates a case form the bundle used that the rename list missed).
312
+ 3. **Framework packages intact** — confirm `AppWeaver.*` package references in the
313
+ generated `.csproj`/`Directory.Packages.props` are unchanged.
314
+ 4. **DbContext integrity (if reference included)** — confirm the merged `ApplicationDbContext.cs`
315
+ contains both `DbSet<>` properties (from reference) **and** `OnModelCreating` (from foundation).
316
+ If either section is missing, report it as a warning.
317
+ 5. **Build (optional, recommended)** — if the .NET SDK is available, offer to build.
318
+ The solution file is whatever the bundle shipped (e.g. `api.sln`) and is **not**
319
+ renamed unless its name contains the sentinel — so discover it rather than assuming
320
+ `<APP_NAME>.sln`:
321
+ ```powershell
322
+ $sln = Get-ChildItem "<OUTPUT_DIR>" -Filter *.sln | Select-Object -First 1
323
+ dotnet build $sln.FullName -c Debug
324
+ ```
325
+ Report results; do not auto-fix — a build failure means the **bundle** needs fixing
326
+ and repacking (see PACKAGING.md), not a per-scaffold patch.
327
+
328
+ Report check failures as warnings; do not silently continue past a sentinel-residue finding.
329
+
330
+ ---
331
+
332
+ ## Step 6 — Completion report
333
+
334
+ ```
335
+ ✅ Foundation scaffold complete
336
+
337
+ Foundation : <FOUNDATION_NAME>
338
+ App Name : <APP_NAME>
339
+ Output : <OUTPUT_DIR or repo root>
340
+ Files : <N> written [+ <M> reference files] (omit reference line if skipped)
341
+ Reference : included / skipped
342
+
343
+ Next steps:
344
+ 1. [If reference skipped] Rename the sample 'Projects' domain to your bounded context.
345
+ 2. Ensure your NuGet feed for AppWeaver.* packages is configured.
346
+ 3. Run the AppHost: dotnet run --project <OUTPUT_DIR>/src/<APP_NAME>.AppHost
347
+ 4. Use /aw-spec-specify to create your first feature spec.
348
+ ```
349
+
350
+ ---
351
+
352
+ ## Notes
353
+
354
+ - **The bundle is the source of truth** — if a scaffold comes out wrong, fix the foundation
355
+ solution and re-pack (`PACKAGING.md`); never patch generated output as a workaround.
356
+ - To add a new foundation, create `docs/<Name>/` with its own `pack-foundation.ps1`,
357
+ `unpack-foundation.ps1`, `PACKAGING.md`, and built `<Name>.pack.txt`.
358
+ ```