[Feature]: Preset strategy to replace one section of a template
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 28/100
調査の方向性
Start in PresetResolver.resolve_content (the composition loop) and VALID_PRESET_STRATEGIES, then read manifest validation for the template strategies. The issue also touches the bash, PowerShell and Python runtime scripts and the preset docs (developing.md, api.md). Agree the design with maintainers before coding, since the author's fork is not a PR yet. Done means the acceptance criteria pass: heading-scoped replacement, exactly-one-match failure, fence-aware matching, and validation errors for commands and scripts.
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
A preset can change a template in four ways today: replace, prepend, append and wrap. None of them can change one section in the middle of a template. To change only ## User Scenarios & Testing in spec-template.md, a preset has to replace the whole file. That copy then stops picking up upstream changes to every other section, and it stops composing with other presets that touch the same template.
Follow-up to discussion #5326, where @mnriem asked for the cases and a fuller write-up.
Proposed Solution
A fifth template strategy, replace-section, with a section field naming the heading:
provides:
templates:
- type: "template"
name: "spec-template"
file: "templates/outcomes.md"
strategy: "replace-section"
section: "User Scenarios & Testing *(mandatory)*"
The file holds the new body of that section. The rules:
- Find the section by its heading text. Match the text after the
#marks exactly, ignoring surrounding whitespace. Any heading level counts. - Keep the heading line. Replace only the body, from after the heading to the next heading of the same or higher level, or the end of the file.
- Exactly one match, or fail. If no heading matches, or more than one does, the preset fails with an error that lists the template's headings. A renamed or duplicated section fails loudly instead of being appended or guessed at.
- Ignore headings inside fenced code blocks.
- Compose like the other strategies. It runs on the resolved lower-priority content, the same base
wrapuses, so two presets can each replace a different section of the same template. Likeappend,prependandwrap, it needs a lowerreplacebase. - Templates only at first. Commands and scripts keep the strategies they have.
In the code, this looks like one more branch in the composition loop of PresetResolver.resolve_content, replace-section added to VALID_PRESET_STRATEGIES, and manifest validation requiring section when the strategy is replace-section.
Alternatives Considered
replacethe whole template. This works today, but the copy drifts from upstream and blocks other presets from composing on that template.- Marker comments in the core templates (
<!-- section:stories -->). They're more precise, but every core template would need markers, and a project's hand-edited template would lose them. Headings already exist, and they're what people and models use to find their way around a template. wrapwith a hand-written copy of the other sections. Same drift problem asreplace.
Component
Spec templates (BDD, Testing Strategy, etc.)
Use Cases
These come from SpecKit Companion, which uses this rule in its own template renderer:
- Spec: replace
## User Scenarios & Testingwith observable outcomes (no P1/P2/P3 stories) for small changes, or with EARS-style numbered requirements (WHEN/THEN/SHALL) that tasks can cite by ID. - Plan: a team's own
## Technical Contextblock with its stack's fields, and every other section stock. - Tasks: replace
## Notesto rule out tasks an agent can't do (UAT, deploy, comms), or the format section so every task says how to verify itself.
Acceptance Criteria
- A preset with
strategy: "replace-section"andsection: "<heading>"replaces only that section's body in the resolved template, and keeps the heading line. - Every other section of the template comes out the same as without the preset.
- The section ends at the next heading of the same or higher level, so its subsections are replaced with it.
- Zero or more than one matching heading fails with an error that names the section and lists the template's headings.
- Headings inside fenced code blocks are not matched.
- Two presets replacing different sections of one template both apply, in priority order.
- Manifest validation rejects
replace-sectionwithoutsection, and rejects it on commands and scripts. - The preset docs (
developing.md,api.md) describe the strategy.
Additional Context
A working version is on my fork, not opened as a PR: full diff against main (branch feat/replace-section-strategy). It covers the CLI resolver, manifest validation, the bash/PowerShell/Python runtime scripts (so feature creation gives the same output as the CLI), the artifact listings, docs and tests. I'm happy to open it as a PR if this direction is agreed.
SpecKit Companion's version of this is replace_section in apps/speckit-extension/scripts/template_render.py in alfredoperez/speckit-companion, with tests. It currently takes the first of two matching headings. The "exactly one match" rule above is stricter, and I'd change ours to match.
AI Disclosure
- Issue text: drafted with Claude Code (Claude Opus 5.5, default settings, interactive under my supervision) after reading the spec-kit preset resolver and docs. I reviewed and edited it before posting.
- Linked branch: implemented with Claude Code (Claude Opus 5.5, default settings) in agent mode running autonomously, following a spec I wrote and reviewed. Covers code generation, tests and docs. It's a proof of concept for this discussion, not a PR.
- 主要言語
- Python
- スター
- 149k
- フォーク
- 13.4k
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 223
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/spec-kit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
triage-must-have
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Workflow-step verifier test fixture breaks when the checkout path contains whitespace (4 failures on macOS)対応中かも @mehdikarimi55 が 3 日前に担当しました。 オープンtriage-can-wait
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
Parity tests fail under the documented direct pytest invocation when the ambient python3 lacks PyYAML (11 failures)対応中かも @mehdikarimi55 が 3 日前に担当しました。 オープンtriage-must-have
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug triage-out-of-scope
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
github/spec-kit の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
glossyio/traffic-monitor#312 ·
メンテナーはふだん 1 日以内に返信
-
local devenv exampleオープンdocumentation enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
es-ude/elastic-ai.creator#1046 ·
メンテナーはふだん 3 日以内に返信
-
feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
confident-ai/deepteam#306 ·
メンテナーはふだん 1 日以内に返信
-
SslLibrary crashes with unhandled OSError: port/proto not found on non-standard SSL ports対応中かも @himanchalkaushale が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
OWASP/Nettacker#1884 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信