Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support regex selectors for preset commands, templates, and scripts

未关闭
#4,659 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
cli, tooling

调研方向

Start with preset manifest validation, the resolver, and command registration, composition, reconciliation, and cleanup paths described in the issue. Run the existing preset tests and inspect specify preset info; done means exact-name behavior remains intact, regex selectors validate and match concrete resources correctly, diagnostics show matches, and reconciliation covers integration and preset changes.

由索引模型根据 Issue 内容生成。

描述

triage-can-wait

Description

Preset manifests currently require a separate provides.templates entry for every command, template, or script that a preset augments. This creates substantial repetition when the same cross-cutting guidance should apply to several resources.

For example, applying the same implementation guidance to speckit.plan, speckit.tasks, and speckit.implement currently requires three entries that differ only by name.

Add support for regex selectors by allowing the existing name field to use a regex: prefix.

Proposed syntax

provides:
  templates:
    - type: command
      name: 'regex:^speckit\.(plan|tasks|implement)$'
      file: commands/workflow-guidance.md
      strategy: append

    - type: template
      name: 'regex:.*-template$'
      file: templates/common-policy.md
      strategy: prepend

    - type: script
      name: 'regex:^check-.*$'
      file: scripts/check-wrapper.sh
      strategy: wrap

Existing exact-name declarations remain unchanged:

provides:
  templates:
    - type: command
      name: speckit.plan
      file: commands/plan-guidance.md
      strategy: append

Matching semantics

  • A name beginning with regex: is interpreted as a regular expression.
  • Matching uses full-name matching semantics rather than substring search.
  • The expression operates on the logical resource name, not its path, filename, or extension.
  • Regex declarations match only concrete resource names available from lower layers in the resolution stack:
    • lower-priority presets
    • installed and enabled extensions
    • Spec Kit core
  • Regex declarations do not match other regex declarations.
  • Matching is recalculated whenever the relevant preset, extension, or integration state changes.
  • A regex that currently matches no resources produces a warning rather than failing installation.
  • Invalid regular expressions fail preset validation with a clear error.

Supported strategies

Existing composition restrictions continue to apply:

Resource type Supported strategies
Command replace, prepend, append, wrap
Template replace, prepend, append, wrap
Script replace, wrap

Each matched resource behaves as though the preset contained a separate exact-name entry using the same file and strategy.

Resolution behavior

For templates and scripts, the resolver can test regex declarations while resolving a requested concrete resource name.

Commands require expansion into concrete command names before registration because commands are materialized into the active integration's command or skill directory. Expanded command names should then use the existing registration, composition, reconciliation, and cleanup paths.

Preset diagnostics should display both the selector and its concrete matches. For example:

regex:^speckit\.(plan|tasks|implement)$
  - speckit.plan
  - speckit.tasks
  - speckit.implement

Acceptance criteria

  • Exact-name preset entries retain their current behavior.
  • regex: selectors are supported for commands, templates, and scripts.
  • Regex matching uses logical resource names and full-match semantics.
  • Invalid expressions are rejected during manifest validation.
  • An unmatched expression produces an actionable warning.
  • Command selectors are expanded and materialized for the active integration.
  • Command matches are reconciled when presets or extensions are added, removed, enabled, disabled, or reprioritized.
  • Command matches are reconciled when the active integration changes.
  • Template and script selectors participate in normal runtime resolution.
  • Existing strategy restrictions remain enforced.
  • Regex declarations cannot recursively match other regex declarations.
  • specify preset info and resolution diagnostics show the concrete resources matched by each selector.
  • Tests cover matching against core, extension, and lower-priority preset resources.
  • Tests cover invalid, unmatched, and overlapping selectors.
  • Existing preset tests and collection count are preserved.

Motivation

This enables concise cross-cutting presets for concerns such as:

  • security and compliance guidance
  • language or framework conventions
  • organization-wide workflow policy
  • shared command instructions
  • common template sections
  • script wrappers

The feature preserves the existing preset composition model while removing the need to enumerate every affected resource separately.

Out of scope

  • Matching filesystem paths or extensions
  • Structural Markdown section merging
  • Capturing groups or substitutions in output filenames
  • Regex selectors that create new resource names
  • Regex declarations matching other regex declarations
主要语言
Python
星标
138k
派生
12.4k
平均合并
3 天 4 小时
30 天内合并 PR
154

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/spec-kit 的其他 Issue

查看 github/spec-kit 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。