From cb13e162d422efd4eca4380bd35c5164679be7c8 Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Fri, 20 Nov 2026 08:04:32 -0600 Subject: [PATCH] Preserve existing specs in Full SDD specify Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- spec-kit-presets/README.md | 2 +- spec-kit-presets/copilot-full-sdd/README.md | 23 ++++--- .../commands/speckit.specify.md | 65 ++++++++++--------- spec-kit-presets/tests/test_full_sdd.py | 30 ++++++--- 4 files changed, 70 insertions(+), 50 deletions(-) diff --git a/spec-kit-presets/README.md b/spec-kit-presets/README.md index 5b0f5a51..d0f01149 100644 --- a/spec-kit-presets/README.md +++ b/spec-kit-presets/README.md @@ -24,7 +24,7 @@ for maintainer guidance on which packages belong here. | Preset | Requires | Copilot purpose | | --- | --- | --- | | [`copilot-extension-hooks`](copilot-extension-hooks) | Specify `==1.2.3`, one Copilot Lean/Full SDD baseline | Opt-in lifecycle dispatch through installed Copilot command skills; preserves the selected baseline and does not control native hooks. See its explicit activation/regeneration flow. | -| [`copilot-full-sdd`](copilot-full-sdd) | Spec Kit `== 1.2.3`, Copilot skills mode | Full core workflow registered as Copilot skills; nine commands identical to pinned core except for extension lifecycle-hook deletions. Initial release pending. | +| [`copilot-full-sdd`](copilot-full-sdd) | Spec Kit `== 1.2.3`, Copilot skills mode | Full core workflow registered as Copilot skills, without extension lifecycle hooks and with safeguards for creating and updating specs. Initial release pending. | | [`copilot-lean-sdd`](copilot-lean-sdd) | Spec Kit `>= 1.0.8`, Copilot skills mode | Upstream Lean's minimal artifacts with Copilot skill invocation and `ask_user`; replaces all nine core SDD commands without extension lifecycle-hook dispatch. Initial release pending. | | [`copilot-sub-agents`](copilot-sub-agents) | Spec Kit `>= 0.8.0` | Built around Copilot delegation mechanisms — VS Code's `runSubagent` tool, Copilot CLI sub-agent processes, and custom agents in `.github/agents/` / `~/.copilot/agents/`. | | [`copilot-assess-ask-questions`](copilot-assess-ask-questions) | Spec Kit `>= 0.9.0`, the `assess` extension | Drives the assess pipeline through Copilot's interactive `ask_user` tool (App, CLI, VS Code). No plain-text fallback — not meant for agents without an interactive question tool. | diff --git a/spec-kit-presets/copilot-full-sdd/README.md b/spec-kit-presets/copilot-full-sdd/README.md index 1af9b31f..53ef8696 100644 --- a/spec-kit-presets/copilot-full-sdd/README.md +++ b/spec-kit-presets/copilot-full-sdd/README.md @@ -7,11 +7,14 @@ Source: [GitHub Spec Kit core commands](https://github.com/github/spec-kit/tree/ at revision `27d14e20c187c1f2916540ea201ecbdc9f8ed588`. Copyright GitHub, Inc.; [MIT licensed](LICENSE). -The upstream commands are imported with only extension lifecycle-hook dispatch, -its separators, and dependent branch/report/checklist references deleted. No -instructions are added or rewritten; questioning, execution, and validation -instructions otherwise remain identical to the pinned core sources. Script metadata -and portable command references remain for Specify to render for the project. +The upstream commands omit extension lifecycle-hook dispatch, +its separators, and dependent branch/report/checklist references. The only other +deviation is in `specify`: it rejects missing or whitespace-only descriptions +before writing files, uses the resolved template only for new specs, preserves +unrelated content in an explicitly selected existing spec, and sets the active +feature only after saving the spec. Its quality checklist and validation flow +remain unchanged. Script metadata and portable command references remain for +Specify to render for the project. This is a Specify preset, not a `copilot plugin` package. ## Installation and prerequisites @@ -49,7 +52,7 @@ prerequisites. They are supplied by `specify init`, not bundled again here. | Command | Required context | Output / safeguards | | --- | --- | --- | | `constitution` | Resolved constitution template, project context, principles | `.specify/memory/constitution.md`; governance-only scope, version/date/placeholder validation, Sync Impact Report | -| `specify` | Feature description, resolved spec template; constitution if present | `/spec.md`, `feature.json`, `checklists/requirements.md`; testable requirements, measurable success criteria, bounded clarification and validation iterations | +| `specify` | Nonblank feature description; resolved spec template for a new spec or `SPECIFY_FEATURE_DIRECTORY` for an existing spec; constitution if present | Creates or edits `/spec.md` before setting `.specify/feature.json`; retains unrelated authored content on updates; writes `checklists/requirements.md` with bounded clarification and validation iterations | | `clarify` | Active `spec.md`; constitution if present | Up to five targeted questions; incremental spec updates, coverage report, built-in quality checklist revalidation | | `plan` | `spec.md`, constitution, resolved plan template | `plan.md`, `research.md`, `data-model.md`, `quickstart.md`, interface `contracts/` where applicable; resolve unknowns and evaluate constitution gates before/after design | | `tasks` | `spec.md`, `plan.md`, resolved tasks template; available design artifacts | `tasks.md`; user-story phases, dependency graph, file paths, task IDs, parallel markers and independent test criteria; test tasks only when requested | @@ -91,9 +94,11 @@ each preset with its own compatible CLI. Leaving `FULL_SPECIFY_BIN` unset skips only Full's real-CLI checks, even when `SPECIFY_BIN` is set for Lean. Set `FULL_PRESET_ARCHIVE` to a local release zip for archive verification. Set `FULL_CORE_SOURCE` to a checkout of the pinned Spec Kit source for -authenticated source comparison: every command must exactly match core with -only the enumerated hook-related deletions, with no added bytes after normalizing -CRLF line endings to LF. Digest, source, and archive comparisons use the same +source comparison against pinned Git blob IDs. Eight commands must exactly match +core with only the enumerated hook-related deletions and no added bytes. For +`specify`, the tests verify both the hook-stripped upstream baseline and the +reviewed downstream version, including an exact match for the quality workflow. +Digest, source, and archive comparisons use the same CRLF-to-LF normalization so checkout line-ending conversion does not change their results. These checks cover package and instruction contracts, not model compliance or runtime guarantees. diff --git a/spec-kit-presets/copilot-full-sdd/commands/speckit.specify.md b/spec-kit-presets/copilot-full-sdd/commands/speckit.specify.md index 126633ad..1656282f 100644 --- a/spec-kit-presets/copilot-full-sdd/commands/speckit.specify.md +++ b/spec-kit-presets/copilot-full-sdd/commands/speckit.specify.md @@ -22,6 +22,8 @@ You **MUST** consider the user input before proceeding (if not empty). The text the user typed after `__SPECKIT_COMMAND_SPECIFY__` in the triggering message **is** the feature description. Assume you always have it available in this conversation even if `{ARGS}` appears literally below. Do not ask the user to repeat it unless they provided an empty command. +Trim whitespace from the feature description. If it is absent or whitespace-only, report ERROR "No feature description provided" and stop before creating directories or writing any files, including `.specify/feature.json`. + Given that feature description, do this: 1. **Generate a concise short name** (2-4 words) for the feature: @@ -36,7 +38,7 @@ Given that feature description, do this: - "Create a dashboard for analytics" → "analytics-dashboard" - "Fix payment processing timeout bug" → "fix-payment-timeout" -3. **Create the spec feature directory**: +2. **Resolve the spec feature directory**: Specs live under the default `specs/` directory unless the user explicitly provides `SPECIFY_FEATURE_DIRECTORY`. @@ -50,35 +52,22 @@ Given that feature description, do this: - Set `SPECIFY_FEATURE_DIRECTORY` to `specs/` - If `branch_numbering` was used (and `feature_numbering` was absent), emit a one-line warning: "⚠️ `branch_numbering` in init-options.json is deprecated. Rename to `feature_numbering`." - **Create the directory and spec file**: - - `mkdir -p SPECIFY_FEATURE_DIRECTORY` - - Resolve the active `spec-template` through the Spec Kit preset/template resolution stack (equivalent to `specify preset resolve spec-template`) - - Copy the resolved `spec-template` file to `SPECIFY_FEATURE_DIRECTORY/spec.md` as the starting point - - Set `SPEC_FILE` to `SPECIFY_FEATURE_DIRECTORY/spec.md` - - Persist the resolved path to `.specify/feature.json`: - ```json - { - "feature_directory": "" - } - ``` - Write the actual resolved directory path value (for example, `specs/003-user-auth`), not the literal string `SPECIFY_FEATURE_DIRECTORY`. - This allows downstream commands (`__SPECKIT_COMMAND_PLAN__`, `__SPECKIT_COMMAND_TASKS__`, etc.) to locate the feature directory without relying on git branch name conventions. - **IMPORTANT**: - You must only create one feature per `__SPECKIT_COMMAND_SPECIFY__` invocation - The spec directory name and the git branch name are independent — they may be the same but that is the user's choice - - The spec directory and file are always created by this command -4. Load the resolved active `spec-template` file to understand required sections. +3. **Choose the specification's starting content**: + - Set `SPEC_FILE` to `SPECIFY_FEATURE_DIRECTORY/spec.md`. + - If the directory was explicitly selected and `SPEC_FILE` exists, read it and use it as the starting point. Apply targeted edits for the requested change, preserving unrelated authored sections, requirements, identifiers, and decisions. Do not resolve or copy a template for an existing spec. + - If an auto-generated directory already exists, report the collision and stop without changing it or the active feature pointer. An existing spec may only be updated by explicitly selecting its directory. + - If `SPEC_FILE` does not exist, resolve the active `spec-template` through the Spec Kit preset/template resolution stack (equivalent to `specify preset resolve spec-template`) and use its contents as the draft structure. Do not write the template to `SPEC_FILE` as an intermediate step. -5. **IF EXISTS**: Load `/memory/constitution.md` for project principles and governance constraints. +4. **IF EXISTS**: Load `/memory/constitution.md` for project principles and governance constraints. -6. Follow this execution flow: - 1. Parse user description from arguments - If empty: ERROR "No feature description provided" - 2. Extract key concepts from description +5. Follow this execution flow for the new specification or the sections affected by the requested change: + 1. Extract key concepts from description Identify: actors, actions, data, constraints - 3. For unclear aspects: + 2. For unclear aspects: - Make informed guesses based on context and industry standards - Only mark with [NEEDS CLARIFICATION: specific question] if: - The choice significantly impacts feature scope or user experience @@ -86,19 +75,32 @@ Given that feature description, do this: - No reasonable default exists - **LIMIT: Maximum 3 [NEEDS CLARIFICATION] markers total** - Prioritize clarifications by impact: scope > security/privacy > user experience > technical details - 4. Fill User Scenarios & Testing section + 3. Fill User Scenarios & Testing section If no clear user flow: ERROR "Cannot determine user scenarios" - 5. Generate Functional Requirements + 4. Generate Functional Requirements Each requirement must be testable Use reasonable defaults for unspecified details (document assumptions in Assumptions section) - 6. Define Success Criteria + 5. Define Success Criteria Create measurable, technology-agnostic outcomes Include both quantitative metrics (time, performance, volume) and qualitative measures (user satisfaction, task completion) Each criterion must be verifiable without implementation details - 7. Identify Key Entities (if data involved) - 8. Return: SUCCESS (spec ready for planning) + 6. Identify Key Entities (if data involved) -7. Write the specification to SPEC_FILE using the template structure, replacing placeholders with concrete details derived from the feature description (arguments) while preserving section order and headings. +6. **Save the specification**: + - For a new spec, create the feature directory if needed and write the completed draft to `SPEC_FILE`, replacing template placeholders with concrete details while preserving template section order and headings. Do not overwrite a spec that appeared after the initial check. + - For an existing spec, save only the targeted edits to `SPEC_FILE`. Keep unrelated authored content intact, including during checklist-driven revisions and clarification. + - If drafting or saving the spec fails, report the error and stop without changing `.specify/feature.json`. + +7. **Set the active feature only after successfully saving `SPEC_FILE`**: + - Persist the resolved path to `.specify/feature.json`: + ```json + { + "feature_directory": "" + } + ``` + Write the actual resolved directory path value (for example, `specs/003-user-auth`), not the literal string `SPECIFY_FEATURE_DIRECTORY`. + This allows downstream commands (`__SPECKIT_COMMAND_PLAN__`, `__SPECKIT_COMMAND_TASKS__`, etc.) to locate the feature directory without relying on git branch name conventions. + - If saving the pointer fails, report that `SPEC_FILE` was saved but the active feature could not be set. Do not report the feature as ready for downstream commands. 8. **Specification Quality Validation**: After writing the initial spec, validate it against quality criteria: @@ -200,8 +202,6 @@ Report completion to the user with: - Checklist results summary - Readiness for the next phase (`__SPECKIT_COMMAND_CLARIFY__` or `__SPECKIT_COMMAND_PLAN__`) -**NOTE:** Spec directory and file creation are always handled by this core command. - ## Quick Guidelines - Focus on **WHAT** users need and **WHY**. @@ -213,7 +213,7 @@ Report completion to the user with: - **Mandatory sections**: Must be completed for every feature - **Optional sections**: Include only when relevant to the feature -- When a section doesn't apply, remove it entirely (don't leave as "N/A") +- For new specs, omit sections that don't apply (don't leave them as "N/A"). When editing an existing spec, keep unrelated authored sections. ### For AI Generation @@ -266,4 +266,5 @@ Success criteria must be: ## Done When - [ ] Specification written to `SPEC_FILE` and validated against quality checklist +- [ ] `.specify/feature.json` points to the saved feature directory - [ ] Completion reported to user with feature directory, spec file path, and checklist results diff --git a/spec-kit-presets/tests/test_full_sdd.py b/spec-kit-presets/tests/test_full_sdd.py index 389ba590..9dec8d2c 100644 --- a/spec-kit-presets/tests/test_full_sdd.py +++ b/spec-kit-presets/tests/test_full_sdd.py @@ -27,10 +27,10 @@ "hooks.before_", "hooks.after_", "Extension Hooks", "Mandatory Post-Execution Hooks", "before_specify", ) -# Pinned core imports with only hook-related deletions. -IMPORT_SHA256 = { +# Reviewed command bodies: hook-stripped core, plus the specify write safeguards. +REVIEWED_SHA256 = { "constitution": "775a220b62d7d59b8740df9f01b36465478cea511e619d21ae3d558599946143", - "specify": "090c4af532316e6529373e722d7957bec2f27cd74b3f18d525fdbeeaa1aae320", + "specify": "bb1543d4527e9edf336fca129277eeb40c76a52ee2980a5ce0366ae131cb76ce", "clarify": "dcae481e2a2934576ee9ba8278c37b6d911d423b2087fbd456b48d8619ba21c6", "plan": "018293a3440991384ff13b7c5b1bc328d652296fa6304db8c5ad93f9df31605f", "tasks": "acd75ba6d4a46704cd2fea7a05bb7578533a9e0b283b14c6140a28c8cd0a22a6", @@ -39,6 +39,7 @@ "implement": "7658bcbfff7a78bfb8f6e3ae29b50b7f327f9e6da1e0cf1f57fcc27c5d4e1b55", "converge": "2a3cbec425ccf205e7d048f0629584f0d3242d2b92402da196a0c3022198c79e", } +HOOK_STRIPPED_SPECIFY_SHA256 = "090c4af532316e6529373e722d7957bec2f27cd74b3f18d525fdbeeaa1aae320" CORE_GIT_BLOBS = { "analyze": "7de2d28f0da797998e5e30d6323b7316a74e60ff", "checklist": "6e33f5d4225c539fa1c3860e5409f098a6a8d827", @@ -106,8 +107,9 @@ def test_files_license_and_source(self): self.assertIn("27d14e20c187c1f2916540ea201ecbdc9f8ed588/templates/commands", readme) self.assertIn(f"**{self.manifest['preset']['version']}**", readme) - def test_reviewed_full_imports_remain_intact(self): - for name, digest in IMPORT_SHA256.items(): + def test_reviewed_full_commands_remain_intact(self): + self.assertEqual(REVIEWED_SHA256.keys(), COMMANDS) + for name, digest in REVIEWED_SHA256.items(): with self.subTest(command=name): content = lf_bytes((PACKAGE / f"commands/speckit.{name}.md").read_bytes()) for ending in (b"\n", b"\r\n"): @@ -122,7 +124,7 @@ def test_line_ending_normalization_preserves_other_bytes(self): self.assertNotEqual(lf_bytes(content + b" "), content) @unittest.skipUnless(os.environ.get("FULL_CORE_SOURCE"), "Set FULL_CORE_SOURCE for authenticated core comparison") - def test_only_hook_deletions_from_authenticated_core(self): + def test_authenticated_core_comparison(self): source = Path(os.environ["FULL_CORE_SOURCE"]) / "templates/commands" for name in sorted(COMMANDS): with self.subTest(command=name): @@ -154,9 +156,21 @@ def test_only_hook_deletions_from_authenticated_core(self): ) expected = expected.rstrip("\n") + "\n" actual = lf_bytes((PACKAGE / f"commands/speckit.{name}.md").read_bytes()) - self.assertEqual(actual, expected.encode(), "Non-hook instructions must match after LF normalization") + if name == "specify": + self.assertEqual(hashlib.sha256(expected.encode()).hexdigest(), HOOK_STRIPPED_SPECIFY_SHA256) + self.assertEqual(hashlib.sha256(actual).hexdigest(), REVIEWED_SHA256[name]) + quality_blocks = [] + for text in (expected, actual.decode()): + _, start, rest = text.partition("\n8. **Specification Quality Validation**") + quality, end, _ = rest.partition("\n## Completion Report") + self.assertTrue(start and end, "Quality workflow must be present") + quality_blocks.append(quality) + self.assertEqual(*quality_blocks, "Specify quality workflow must match core exactly") + else: + self.assertEqual(actual, expected.encode(), "Non-hook instructions must match after LF normalization") source_iterator = iter(original) - self.assertTrue(all(byte in source_iterator for byte in actual), "No added bytes allowed") + hook_stripped = expected.encode() if name == "specify" else actual + self.assertTrue(all(byte in source_iterator for byte in hook_stripped), "No added bytes allowed") def test_no_lifecycle_dispatch_and_preserved_script_metadata(self): for name, text in self.commands.items():