duaer-spec 0.1.0

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 (75) hide show
  1. package/.cursor/rules/agents-workflow.mdc +50 -0
  2. package/.cursor/rules/ai-ui-copy.mdc +12 -0
  3. package/.cursor/rules/duaer-spec.mdc +33 -0
  4. package/.cursor/skills/duaer-analyze/SKILL.md +259 -0
  5. package/.cursor/skills/duaer-checklist/SKILL.md +383 -0
  6. package/.cursor/skills/duaer-clarify/SKILL.md +291 -0
  7. package/.cursor/skills/duaer-constitution/SKILL.md +177 -0
  8. package/.cursor/skills/duaer-converge/SKILL.md +277 -0
  9. package/.cursor/skills/duaer-git-commit/SKILL.md +68 -0
  10. package/.cursor/skills/duaer-git-feature/SKILL.md +94 -0
  11. package/.cursor/skills/duaer-git-initialize/SKILL.md +54 -0
  12. package/.cursor/skills/duaer-git-remote/SKILL.md +50 -0
  13. package/.cursor/skills/duaer-git-validate/SKILL.md +54 -0
  14. package/.cursor/skills/duaer-implement/SKILL.md +226 -0
  15. package/.cursor/skills/duaer-plan/SKILL.md +166 -0
  16. package/.cursor/skills/duaer-specify/SKILL.md +345 -0
  17. package/.cursor/skills/duaer-tasks/SKILL.md +214 -0
  18. package/.cursor/skills/duaer-taskstoissues/SKILL.md +109 -0
  19. package/.duaer/extensions/.registry +23 -0
  20. package/.duaer/extensions/git/README.md +119 -0
  21. package/.duaer/extensions/git/commands/duaer.git.commit.md +63 -0
  22. package/.duaer/extensions/git/commands/duaer.git.feature.md +82 -0
  23. package/.duaer/extensions/git/commands/duaer.git.initialize.md +49 -0
  24. package/.duaer/extensions/git/commands/duaer.git.remote.md +45 -0
  25. package/.duaer/extensions/git/commands/duaer.git.validate.md +49 -0
  26. package/.duaer/extensions/git/config-template.yml +79 -0
  27. package/.duaer/extensions/git/extension.yml +142 -0
  28. package/.duaer/extensions/git/git-config.yml +79 -0
  29. package/.duaer/extensions/git/scripts/bash/auto-commit.sh +211 -0
  30. package/.duaer/extensions/git/scripts/bash/create-new-feature-branch.sh +626 -0
  31. package/.duaer/extensions/git/scripts/bash/git-common.sh +56 -0
  32. package/.duaer/extensions/git/scripts/bash/initialize-repo.sh +54 -0
  33. package/.duaer/extensions/git/scripts/powershell/auto-commit.ps1 +230 -0
  34. package/.duaer/extensions/git/scripts/powershell/create-new-feature-branch.ps1 +592 -0
  35. package/.duaer/extensions/git/scripts/powershell/git-common.ps1 +52 -0
  36. package/.duaer/extensions/git/scripts/powershell/initialize-repo.ps1 +69 -0
  37. package/.duaer/extensions/git/scripts/python/auto_commit.py +195 -0
  38. package/.duaer/extensions/git/scripts/python/create_new_feature_branch.py +634 -0
  39. package/.duaer/extensions/git/scripts/python/git_common.py +81 -0
  40. package/.duaer/extensions/git/scripts/python/initialize_repo.py +89 -0
  41. package/.duaer/extensions.yml +167 -0
  42. package/.duaer/init-options.json +9 -0
  43. package/.duaer/integration.json +15 -0
  44. package/.duaer/integrations/cursor-agent.manifest.json +17 -0
  45. package/.duaer/integrations/duaer.manifest.json +19 -0
  46. package/.duaer/memory/.constitution-template.json +4 -0
  47. package/.duaer/memory/constitution.md +37 -0
  48. package/.duaer/memory/project-context.md +24 -0
  49. package/.duaer/memory/testing.md +14 -0
  50. package/.duaer/scripts/bash/check-prerequisites.sh +243 -0
  51. package/.duaer/scripts/bash/common.sh +926 -0
  52. package/.duaer/scripts/bash/create-new-feature.sh +407 -0
  53. package/.duaer/scripts/bash/resolve-template.sh +57 -0
  54. package/.duaer/scripts/bash/setup-plan.sh +85 -0
  55. package/.duaer/scripts/bash/setup-tasks.sh +94 -0
  56. package/.duaer/templates/checklist-template.md +45 -0
  57. package/.duaer/templates/constitution-template.md +50 -0
  58. package/.duaer/templates/plan-template.md +113 -0
  59. package/.duaer/templates/spec-template.md +131 -0
  60. package/.duaer/templates/tasks-template.md +252 -0
  61. package/.duaer/workflows/duaer/workflow.yml +78 -0
  62. package/.duaer/workflows/workflow-registry.json +13 -0
  63. package/ADOPT.md +75 -0
  64. package/AGENTS.md +290 -0
  65. package/CHANGELOG.md +28 -0
  66. package/DUADER.md +57 -0
  67. package/LICENSE +21 -0
  68. package/README.md +74 -0
  69. package/bin/duaer.mjs +298 -0
  70. package/docs/agent/README.md +12 -0
  71. package/docs/agent/change-checklist.md +130 -0
  72. package/docs/agent/e2e-test-plan.md +33 -0
  73. package/docs/agent/workflow.md +127 -0
  74. package/docs/baseline.md +10 -0
  75. package/package.json +49 -0
@@ -0,0 +1,291 @@
1
+ ---
2
+ name: "duaer-clarify"
3
+ description: "Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec."
4
+ compatibility: "Requires duaer-spec project structure with .duaer/ directory"
5
+ metadata:
6
+ author: "duaer-spec"
7
+ source: "duaer-spec"
8
+ ---
9
+
10
+
11
+ ## User Input
12
+
13
+ ```text
14
+ $ARGUMENTS
15
+ ```
16
+
17
+ You **MUST** consider the user input before proceeding (if not empty).
18
+
19
+ ## Pre-Execution Checks
20
+
21
+ **Check for extension hooks (before clarification)**:
22
+ - Check if `.duaer/extensions.yml` exists in the project root.
23
+ - If it exists, read it and look for entries under the `hooks.before_clarify` key
24
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
25
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
26
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
27
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
28
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
29
+ - When constructing command invocations from hook command names, replace dots (`.`) with hyphens (`-`). For example, `duaer.git.commit` → `/duaer-git-commit`.
30
+ - For each executable hook, output the following based on its `optional` flag:
31
+ - **Optional hook** (`optional: true`):
32
+ ```
33
+ ## Extension Hooks
34
+
35
+ **Optional Pre-Hook**: {extension}
36
+ Command: `/{command}`
37
+ Description: {description}
38
+
39
+ Prompt: {prompt}
40
+ To execute: `/{command}`
41
+ ```
42
+ - **Mandatory hook** (`optional: false`):
43
+ ```
44
+ ## Extension Hooks
45
+
46
+ **Automatic Pre-Hook**: {extension}
47
+ Executing: `/{command}`
48
+ EXECUTE_COMMAND: {command}
49
+
50
+ Wait for the result of the hook command before proceeding to the Outline.
51
+ ```
52
+ After emitting the block above you MUST actually invoke the hook and wait for it to finish before continuing. Run it the same way you would run the command yourself in this agent/session (the invocation may differ from the literal `{command}` id shown above, e.g. a skills-mode agent runs it as `/skill:duaer-...` or `$duaer-...`). Emitting the block alone does not run the hook.
53
+ - If no hooks are registered or `.duaer/extensions.yml` does not exist, skip silently
54
+
55
+ ## Outline
56
+
57
+ Goal: Detect and reduce ambiguity or missing decision points in the active feature specification and record the clarifications directly in the spec file.
58
+
59
+ Note: This clarification workflow is expected to run (and be completed) BEFORE invoking `/duaer-plan`. If the user explicitly states they are skipping clarification (e.g., exploratory spike), you may proceed, but must warn that downstream rework risk increases.
60
+
61
+ Execution steps:
62
+
63
+ 1. Run `.duaer/scripts/bash/check-prerequisites.sh --json --paths-only` from repo root **once** (combined `--json --paths-only` mode / `-Json -PathsOnly`). Parse minimal JSON payload fields:
64
+ - `FEATURE_DIR`
65
+ - `FEATURE_SPEC`
66
+ - (Optionally capture `IMPL_PLAN`, `TASKS` for future chained flows.)
67
+ - If JSON parsing fails, abort and instruct user to re-run `/duaer-specify` or verify feature branch environment.
68
+ - 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").
69
+
70
+ 2. **IF EXISTS**: Load `.duaer/memory/constitution.md` for project principles and governance constraints.
71
+
72
+ 3. Load the current spec file. Perform a structured ambiguity & coverage scan using this taxonomy. For each category, mark status: Clear / Partial / Missing. Produce an internal coverage map used for prioritization (do not output raw map unless no questions will be asked).
73
+
74
+ Functional Scope & Behavior:
75
+ - Core user goals & success criteria
76
+ - Explicit out-of-scope declarations
77
+ - User roles / personas differentiation
78
+
79
+ Domain & Data Model:
80
+ - Entities, attributes, relationships
81
+ - Identity & uniqueness rules
82
+ - Lifecycle/state transitions
83
+ - Data volume / scale assumptions
84
+
85
+ Interaction & UX Flow:
86
+ - Critical user journeys / sequences
87
+ - Error/empty/loading states
88
+ - Accessibility or localization notes
89
+
90
+ Non-Functional Quality Attributes:
91
+ - Performance (latency, throughput targets)
92
+ - Scalability (horizontal/vertical, limits)
93
+ - Reliability & availability (uptime, recovery expectations)
94
+ - Observability (logging, metrics, tracing signals)
95
+ - Security & privacy (authN/Z, data protection, threat assumptions)
96
+ - Compliance / regulatory constraints (if any)
97
+
98
+ Integration & External Dependencies:
99
+ - External services/APIs and failure modes
100
+ - Data import/export formats
101
+ - Protocol/versioning assumptions
102
+
103
+ Edge Cases & Failure Handling:
104
+ - Negative scenarios
105
+ - Rate limiting / throttling
106
+ - Conflict resolution (e.g., concurrent edits)
107
+
108
+ Constraints & Tradeoffs:
109
+ - Technical constraints (language, storage, hosting)
110
+ - Explicit tradeoffs or rejected alternatives
111
+
112
+ Terminology & Consistency:
113
+ - Canonical glossary terms
114
+ - Avoided synonyms / deprecated terms
115
+
116
+ Completion Signals:
117
+ - Acceptance criteria testability
118
+ - Measurable Definition of Done style indicators
119
+
120
+ Misc / Placeholders:
121
+ - TODO markers / unresolved decisions
122
+ - Ambiguous adjectives ("robust", "intuitive") lacking quantification
123
+
124
+ For each category with Partial or Missing status, add a candidate question opportunity unless:
125
+ - Clarification would not materially change implementation or validation strategy
126
+ - Information is better deferred to planning phase (note internally)
127
+
128
+ 4. Generate (internally) a prioritized queue of candidate clarification questions (maximum 5). Do NOT output them all at once. Apply these constraints:
129
+ - Maximum of 5 total questions across the whole session.
130
+ - Each question must be answerable with EITHER:
131
+ - A short multiple‑choice selection (2–5 distinct, mutually exclusive options), OR
132
+ - A one-word / short‑phrase answer (explicitly constrain: "Answer in <=5 words").
133
+ - Only include questions whose answers materially impact architecture, data modeling, task decomposition, test design, UX behavior, operational readiness, or compliance validation.
134
+ - Ensure category coverage balance: attempt to cover the highest impact unresolved categories first; avoid asking two low-impact questions when a single high-impact area (e.g., security posture) is unresolved.
135
+ - Exclude questions already answered, trivial stylistic preferences, or plan-level execution details (unless blocking correctness).
136
+ - Favor clarifications that reduce downstream rework risk or prevent misaligned acceptance tests.
137
+ - If more than 5 categories remain unresolved, select the top 5 by (Impact * Uncertainty) heuristic.
138
+
139
+ 5. Sequential questioning loop (interactive):
140
+ - Present EXACTLY ONE question at a time.
141
+ - **Question writing quality (applies to every question, MC or short-answer):**
142
+ - Lead with `**Question:**` followed by a full interrogative that ends with `?`. The question text before the `?` must make sense on its own.
143
+ - NEVER use a topic label, section heading, or requirement id as the question itself. For example, `Acceptance device/runtime matrix (FR-023)` is INVALID — it is a label, not a question.
144
+ - After the `?`, the only permitted suffix is an optional parenthesized requirement/question id. Exact format: `**Question:** <interrogative>?` or `**Question:** <interrogative>? (FR-023)`. Never put the id before the `?`, and never use the id (alone or with a topic label) as the whole prompt.
145
+ - Immediately after the question line, add one plain-language "Why it matters" sentence (the stake for acceptance or shipping) before the recommendation/options.
146
+ - Use everyday wording; introduce jargon only if defined in the same sentence. Self-check: a reader who does not know Duaer must be able to answer from the Question line alone. Terse is fine; cryptic labels are not.
147
+ - For multiple‑choice questions:
148
+ - **Analyze all options** and determine the **most suitable option** based on:
149
+ - Best practices for the project type
150
+ - Common patterns in similar implementations
151
+ - Risk reduction (security, performance, maintainability)
152
+ - Alignment with any explicit project goals or constraints visible in the spec
153
+ - Present your **recommended option prominently** at the top with clear reasoning (1-2 sentences explaining why this is the best choice).
154
+ - Format as: `**Recommended:** Option [X] - <reasoning>`
155
+ - Then render all options as a Markdown table:
156
+
157
+ | Option | Description |
158
+ |--------|-------------|
159
+ | A | <Option A description> |
160
+ | B | <Option B description> |
161
+ | C | <Option C description> (add D/E as needed up to 5) |
162
+ | Short | Provide a different short answer (<=5 words) (Include only if free-form alternative is appropriate) |
163
+
164
+ - After the table, add: `You can reply with the option letter (e.g., "A"), accept the recommendation by saying "yes" or "recommended", or provide your own short answer.`
165
+ - For short‑answer style (no meaningful discrete options):
166
+ - Provide your **suggested answer** based on best practices and context.
167
+ - Format as: `**Suggested:** <your proposed answer> - <brief reasoning>`
168
+ - Then output: `Format: Short answer (<=5 words). You can accept the suggestion by saying "yes" or "suggested", or provide your own answer.`
169
+ - After the user answers:
170
+ - If the user replies with "yes", "recommended", or "suggested", use your previously stated recommendation/suggestion as the answer.
171
+ - Otherwise, validate the answer maps to one option or fits the <=5 word constraint.
172
+ - If ambiguous, ask for a quick disambiguation (count still belongs to same question; do not advance).
173
+ - Once satisfactory, record it in working memory (do not yet write to disk) and move to the next queued question.
174
+ - Stop asking further questions when:
175
+ - All critical ambiguities resolved early (remaining queued items become unnecessary), OR
176
+ - User signals completion ("done", "good", "no more"), OR
177
+ - You reach 5 asked questions.
178
+ - Never reveal future queued questions in advance.
179
+ - If no valid questions exist at start, immediately report no critical ambiguities.
180
+
181
+ 6. Integration after EACH accepted answer (incremental update approach):
182
+ - Maintain in-memory representation of the spec (loaded once at start) plus the raw file contents.
183
+ - For the first integrated answer in this session:
184
+ - Ensure a `## Clarifications` section exists (create it just after the highest-level contextual/overview section per the spec template if missing).
185
+ - Under it, create (if not present) a `### Session YYYY-MM-DD` subheading for today.
186
+ - Append a bullet line immediately after acceptance: `- Q: <question> → A: <final answer>`.
187
+ - Then immediately apply the clarification to the most appropriate section(s):
188
+ - Functional ambiguity → Update or add a bullet in Functional Requirements.
189
+ - User interaction / actor distinction → Update User Stories or Actors subsection (if present) with clarified role, constraint, or scenario.
190
+ - Data shape / entities → Update Data Model (add fields, types, relationships) preserving ordering; note added constraints succinctly.
191
+ - Non-functional constraint → Add/modify measurable criteria in Success Criteria > Measurable Outcomes (convert vague adjective to metric or explicit target).
192
+ - Edge case / negative flow → Add a new bullet under Edge Cases / Error Handling (or create such subsection if template provides placeholder for it).
193
+ - Terminology conflict → Normalize term across spec; retain original only if necessary by adding `(formerly referred to as "X")` once.
194
+ - If the clarification invalidates an earlier ambiguous statement, replace that statement instead of duplicating; leave no obsolete contradictory text.
195
+ - Save the spec file AFTER each integration to minimize risk of context loss (atomic overwrite).
196
+ - Preserve formatting: do not reorder unrelated sections; keep heading hierarchy intact.
197
+ - Keep each inserted clarification minimal and testable (avoid narrative drift).
198
+
199
+ 7. Validation (performed after EACH write plus final pass):
200
+ - Clarifications session contains exactly one bullet per accepted answer (no duplicates).
201
+ - Total asked (accepted) questions ≤ 5.
202
+ - Updated sections contain no lingering vague placeholders the new answer was meant to resolve.
203
+ - No contradictory earlier statement remains (scan for now-invalid alternative choices removed).
204
+ - Markdown structure valid; only allowed new headings: `## Clarifications`, `### Session YYYY-MM-DD`.
205
+ - Terminology consistency: same canonical term used across all updated sections.
206
+
207
+ 8. Write the updated spec back to `FEATURE_SPEC`.
208
+
209
+ 9. **Re-validate Spec Quality Checklist** (if it exists):
210
+ - Check if `FEATURE_DIR/checklists/requirements.md` exists.
211
+ - If it does NOT exist, skip this step silently.
212
+ - If it exists:
213
+ 1. Read the checklist file.
214
+ 2. Identify all GitHub task-list checkbox lines — lines matching `- [ ]`, `- [x]`, or `- [X]` (case-insensitive, tolerant of leading whitespace for nested items) outside of code fences. Ignore all other content (headings, notes, non-checkbox bullets, metadata).
215
+ 3. For each checkbox line, record its current marker state (checked or unchecked) and item text into a before-snapshot list.
216
+ 4. Re-evaluate each checkbox item against the **updated** spec (the version just saved in step 7).
217
+ 5. For each checkbox item, update only if the checked/unchecked state actually changes:
218
+ - If the item now passes and was unchecked: change `[ ]` to `[x]`.
219
+ - If the item now fails and was checked: change `[x]`/`[X]` to `[ ]`.
220
+ - If the state is unchanged: leave the marker as-is (preserve existing case to avoid cosmetic diffs).
221
+ 6. Save the updated checklist file. **Only toggle the `[ ]`/`[x]` marker portion of checkbox lines whose state changed.** All other file content — headings, metadata, notes, line ordering, whitespace — must remain unchanged to avoid noisy diffs.
222
+ 7. Compare the before-snapshot with the current state to compute three lists for the Completion Report:
223
+ - **Newly passing**: items that changed from unchecked to checked.
224
+ - **Regressions**: items that changed from checked to unchecked.
225
+ - **Still unchecked**: items that remain unchecked.
226
+ 8. Record the before/after pass counts as checked/total checkbox items (e.g., "12/16 → 15/16 items passing").
227
+
228
+ Behavior rules:
229
+
230
+ - If no meaningful ambiguities found (or all potential questions would be low-impact), respond: "No critical ambiguities detected worth formal clarification." and suggest proceeding.
231
+ - If spec file missing, instruct user to run `/duaer-specify` first (do not create a new spec here).
232
+ - Never exceed 5 total asked questions (clarification retries for a single question do not count as new questions).
233
+ - Avoid speculative tech stack questions unless the absence blocks functional clarity.
234
+ - Respect user early termination signals ("stop", "done", "proceed").
235
+ - If no questions asked due to full coverage, output a compact coverage summary (all categories Clear) then suggest advancing.
236
+ - If quota reached with unresolved high-impact categories remaining, explicitly flag them under Deferred with rationale.
237
+
238
+ Context for prioritization: $ARGUMENTS
239
+
240
+ ## Mandatory Post-Execution Hooks
241
+
242
+ **You MUST complete this section before reporting completion to the user.**
243
+
244
+ Check if `.duaer/extensions.yml` exists in the project root.
245
+ - If it does not exist, or no hooks are registered under `hooks.after_clarify`, skip to the Completion Report.
246
+ - If it exists, read it and look for entries under the `hooks.after_clarify` key.
247
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue to the Completion Report.
248
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
249
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
250
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
251
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
252
+ - When constructing command invocations from hook command names, replace dots (`.`) with hyphens (`-`). For example, `duaer.git.commit` → `/duaer-git-commit`.
253
+ - For each executable hook, output the following based on its `optional` flag:
254
+ - **Mandatory hook** (`optional: false`) — **You MUST emit `EXECUTE_COMMAND:` for each mandatory hook**:
255
+ ```
256
+ ## Extension Hooks
257
+
258
+ **Automatic Hook**: {extension}
259
+ Executing: `/{command}`
260
+ EXECUTE_COMMAND: {command}
261
+ ```
262
+ After emitting the block above you MUST actually invoke the hook and wait for it to finish before continuing. Run it the same way you would run the command yourself in this agent/session (the invocation may differ from the literal `{command}` id shown above, e.g. a skills-mode agent runs it as `/skill:duaer-...` or `$duaer-...`). Emitting the block alone does not run the hook.
263
+ - **Optional hook** (`optional: true`):
264
+ ```
265
+ ## Extension Hooks
266
+
267
+ **Optional Hook**: {extension}
268
+ Command: `/{command}`
269
+ Description: {description}
270
+
271
+ Prompt: {prompt}
272
+ To execute: `/{command}`
273
+ ```
274
+
275
+ ## Completion Report
276
+
277
+ Report completion (after questioning loop ends or early termination):
278
+ - Number of questions asked & answered.
279
+ - Path to updated spec.
280
+ - Sections touched (list names).
281
+ - Spec quality checklist status (if `FEATURE_DIR/checklists/requirements.md` was re-validated): show before/after pass counts (e.g., "Spec Quality Checklist: 12/16 → 15/16 items passing") and list any items that changed state — both newly checked (unchecked → checked) and any regressions (checked → unchecked). If any items remain unchecked, list them as areas needing attention.
282
+ - Coverage summary table listing each taxonomy category with Status: Resolved (was Partial/Missing and addressed), Deferred (exceeds question quota or better suited for planning), Clear (already sufficient), Outstanding (still Partial/Missing but low impact).
283
+ - If any Outstanding or Deferred remain, recommend whether to proceed to `/duaer-plan` or run `/duaer-clarify` again later post-plan.
284
+ - Suggested next command.
285
+
286
+ ## Done When
287
+
288
+ - [ ] Spec ambiguities identified and clarifications integrated into spec file
289
+ - [ ] Spec quality checklist re-validated against updated spec (if `FEATURE_DIR/checklists/requirements.md` exists)
290
+ - [ ] Extension hooks dispatched or skipped according to the rules in Mandatory Post-Execution Hooks above
291
+ - [ ] Completion reported to user with questions answered, sections touched, checklist status, and coverage summary
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: "duaer-constitution"
3
+ description: "Create or update the project constitution from interactive or provided principle inputs."
4
+ compatibility: "Requires duaer-spec project structure with .duaer/ directory"
5
+ metadata:
6
+ author: "duaer-spec"
7
+ source: "duaer-spec"
8
+ ---
9
+
10
+
11
+ ## User Input
12
+
13
+ ```text
14
+ $ARGUMENTS
15
+ ```
16
+
17
+ You **MUST** consider the user input before proceeding (if not empty).
18
+
19
+ ## Scope Guard
20
+
21
+ This command's own work is limited to updating the project constitution itself. Dependent templates
22
+ and commands read the constitution at runtime and are not modified here.
23
+
24
+ - Classify every part of the user input as either constitution content or a separate,
25
+ non-governance intent.
26
+ - If the input includes feature implementation, code generation, refactoring, building, or
27
+ deployment requests, you **MUST NOT** execute them. Extract them as deferred intents instead.
28
+ - You **MUST NOT** create, modify, or delete application source files, feature routes,
29
+ components, tests, deployment files, or other artifacts unrelated to the constitution
30
+ workflow.
31
+ - If it is unclear whether an instruction is constitution content, ask for clarification before
32
+ making changes.
33
+ - After completing the constitution update, include a `Next Actions` section for each deferred
34
+ intent. List the original intent and suggest the appropriate follow-up Duaer command, such
35
+ as `/duaer-specify`, without invoking it.
36
+ - If there are no non-governance intents, omit the `Next Actions` section.
37
+
38
+ ## Pre-Execution Checks
39
+
40
+ **Check for extension hooks (before constitution update)**:
41
+ - Check if `.duaer/extensions.yml` exists in the project root.
42
+ - If it exists, read it and look for entries under the `hooks.before_constitution` key
43
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
44
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
45
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
46
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
47
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
48
+ - When constructing command invocations from hook command names, replace dots (`.`) with hyphens (`-`). For example, `duaer.git.commit` → `/duaer-git-commit`.
49
+ - For each executable hook, output the following based on its `optional` flag:
50
+ - **Optional hook** (`optional: true`):
51
+ ```
52
+ ## Extension Hooks
53
+
54
+ **Optional Pre-Hook**: {extension}
55
+ Command: `/{command}`
56
+ Description: {description}
57
+
58
+ Prompt: {prompt}
59
+ To execute: `/{command}`
60
+ ```
61
+ - **Mandatory hook** (`optional: false`):
62
+ ```
63
+ ## Extension Hooks
64
+
65
+ **Automatic Pre-Hook**: {extension}
66
+ Executing: `/{command}`
67
+ EXECUTE_COMMAND: {command}
68
+
69
+ Wait for the result of the hook command before proceeding to the Outline.
70
+ ```
71
+ After emitting the block above you MUST actually invoke the hook and wait for it to finish before continuing. Run it the same way you would run the command yourself in this agent/session (the invocation may differ from the literal `{command}` id shown above, e.g. a skills-mode agent runs it as `/skill:duaer-...` or `$duaer-...`). Emitting the block alone does not run the hook.
72
+ - If no hooks are registered or `.duaer/extensions.yml` does not exist, skip silently
73
+
74
+ ## Outline
75
+
76
+ You are updating the project constitution at `.duaer/memory/constitution.md`. The active
77
+ constitution scaffold is resolved at command time from `constitution-template` through the Duaer
78
+ preset/template resolution stack.
79
+
80
+ Follow this execution flow:
81
+
82
+ 1. Run `.duaer/scripts/bash/resolve-template.sh constitution-template --json` from the repository root and parse `TEMPLATE_CONTENT` as the active template.
83
+ - The shared resolver applies project overrides, composing preset layers, and extension layers
84
+ before the core template fallback. It MUST succeed before continuing.
85
+ - If it fails, stop and report the resolution error; do not continue with only one contributing
86
+ template layer.
87
+ - If `.duaer/memory/constitution.md` exists, load it as the source of current project-specific
88
+ values and amendments. Preserve information that is still applicable when applying the newly
89
+ resolved scaffold.
90
+ - If it does not exist, use the resolved template as the initial document.
91
+ - Do not write back to any versioned template layer.
92
+ - Identify every placeholder token of the form `[ALL_CAPS_IDENTIFIER]`.
93
+ **IMPORTANT**: The user might require less or more principles than the ones used in the template. If a number is specified, respect that - follow the general template. You will update the doc accordingly.
94
+
95
+ 2. Collect/derive values for placeholders:
96
+ - If user input (conversation) supplies a value, use it.
97
+ - Otherwise infer from existing repo context (README, docs, prior constitution versions if embedded).
98
+ - For governance dates: `RATIFICATION_DATE` is the original adoption date (if unknown ask or mark TODO), `LAST_AMENDED_DATE` is today if changes are made, otherwise keep previous.
99
+ - `CONSTITUTION_VERSION` must increment according to semantic versioning rules:
100
+ - MAJOR: Backward incompatible governance/principle removals or redefinitions.
101
+ - MINOR: New principle/section added or materially expanded guidance.
102
+ - PATCH: Clarifications, wording, typo fixes, non-semantic refinements.
103
+ - If version bump type ambiguous, propose reasoning before finalizing.
104
+
105
+ 3. Draft the updated constitution content using the resolved template as the required structure:
106
+ - Replace every placeholder with concrete text (no bracketed tokens left except intentionally retained template slots that the project has chosen not to define yet—explicitly justify any left).
107
+ - Preserve heading hierarchy and comments can be removed once replaced unless they still add clarifying guidance.
108
+ - Ensure each Principle section: succinct name line, paragraph (or bullet list) capturing non‑negotiable rules, explicit rationale if not obvious.
109
+ - Ensure Governance section lists amendment procedure, versioning policy, and compliance review expectations.
110
+
111
+ 4. Produce a Sync Impact Report (prepend as an HTML comment at top of the constitution file after update):
112
+ - Version change: old → new
113
+ - List of modified principles (old title → new title if renamed)
114
+ - Added sections
115
+ - Removed sections
116
+ - Follow-up TODOs if any placeholders intentionally deferred.
117
+
118
+ 5. Validation before final output:
119
+ - No remaining unexplained bracket tokens.
120
+ - Version line matches report.
121
+ - Dates ISO format YYYY-MM-DD.
122
+ - Principles are declarative, testable, and free of vague language ("should" → replace with MUST/SHOULD rationale where appropriate).
123
+
124
+ 6. Write the completed constitution back to `.duaer/memory/constitution.md` (overwrite).
125
+
126
+ 7. Output a final summary to the user with:
127
+ - New version and bump rationale.
128
+ - Any TODO placeholders or deferred items requiring manual follow-up.
129
+ - Suggested commit message (e.g., `docs: amend constitution to vX.Y.Z (principle additions + governance update)`).
130
+ - A `Next Actions` section for any deferred non-governance intents.
131
+
132
+ Formatting & Style Requirements:
133
+
134
+ - Use Markdown headings exactly as in the template (do not demote/promote levels).
135
+ - Wrap long rationale lines to keep readability (<100 chars ideally) but do not hard enforce with awkward breaks.
136
+ - Keep a single blank line between sections.
137
+ - Avoid trailing whitespace.
138
+
139
+ If the user supplies partial updates (e.g., only one principle revision), still perform validation and version decision steps.
140
+
141
+ If critical info missing (e.g., ratification date truly unknown), insert `TODO(<FIELD_NAME>): explanation` and include in the Sync Impact Report under deferred items.
142
+
143
+ Write only `.duaer/memory/constitution.md`; do not create or modify template source files.
144
+
145
+ ## Post-Execution Checks
146
+
147
+ **Check for extension hooks (after constitution update)**:
148
+ Check if `.duaer/extensions.yml` exists in the project root.
149
+ - If it exists, read it and look for entries under the `hooks.after_constitution` key
150
+ - If the YAML cannot be parsed or is invalid, skip hook checking silently and continue normally
151
+ - Filter out hooks where `enabled` is explicitly `false`. Treat hooks without an `enabled` field as enabled by default.
152
+ - For each remaining hook, do **not** attempt to interpret or evaluate hook `condition` expressions:
153
+ - If the hook has no `condition` field, or it is null/empty, treat the hook as executable
154
+ - If the hook defines a non-empty `condition`, skip the hook and leave condition evaluation to the HookExecutor implementation
155
+ - When constructing command invocations from hook command names, replace dots (`.`) with hyphens (`-`). For example, `duaer.git.commit` → `/duaer-git-commit`.
156
+ - For each executable hook, output the following based on its `optional` flag:
157
+ - **Optional hook** (`optional: true`):
158
+ ```
159
+ ## Extension Hooks
160
+
161
+ **Optional Hook**: {extension}
162
+ Command: `/{command}`
163
+ Description: {description}
164
+
165
+ Prompt: {prompt}
166
+ To execute: `/{command}`
167
+ ```
168
+ - **Mandatory hook** (`optional: false`):
169
+ ```
170
+ ## Extension Hooks
171
+
172
+ **Automatic Hook**: {extension}
173
+ Executing: `/{command}`
174
+ EXECUTE_COMMAND: {command}
175
+ ```
176
+ After emitting the block above you MUST actually invoke the hook and wait for it to finish before continuing. Run it the same way you would run the command yourself in this agent/session (the invocation may differ from the literal `{command}` id shown above, e.g. a skills-mode agent runs it as `/skill:duaer-...` or `$duaer-...`). Emitting the block alone does not run the hook.
177
+ - If no hooks are registered or `.duaer/extensions.yml` does not exist, skip silently