|
| 1 | +# MetaSpec Metadata in pyproject.toml |
| 2 | + |
| 3 | +> **Purpose**: Enable community tools to discover speckit capabilities |
| 4 | +
|
| 5 | +生成的 speckit 的 `pyproject.toml` 会包含 `[tool.metaspec]` 部分,记录 speckit 的元数据。 |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 📋 Metadata Fields |
| 10 | + |
| 11 | +### Core Fields (Always Present) |
| 12 | + |
| 13 | +| Field | Type | Description | |
| 14 | +|-------|------|-------------| |
| 15 | +| `generated_by` | string | MetaSpec version used to generate this speckit | |
| 16 | +| `domain` | string | Domain area (e.g., "mcp", "testing", "marketing") | |
| 17 | + |
| 18 | +### Optional Fields |
| 19 | + |
| 20 | +| Field | Type | Description | |
| 21 | +|-------|------|-------------| |
| 22 | +| `lifecycle` | string | Development phase: "greenfield" (0→1) \| "brownfield" (1→n) \| custom | |
| 23 | +| `sd_type` | string \| array | Command system type(s): "generic" \| "sds" \| "sdd" \| mixed | |
| 24 | +| `slash_commands` | array | Deployed AI slash commands | |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## 📝 Example Outputs |
| 29 | + |
| 30 | +### Example 1: Generic Speckit (No Slash Commands) |
| 31 | + |
| 32 | +```toml |
| 33 | +[tool.metaspec] |
| 34 | +generated_by = "0.9.5" |
| 35 | +domain = "generic" |
| 36 | +lifecycle = "greenfield" |
| 37 | + |
| 38 | +# No slash commands deployed |
| 39 | +sd_type = "none" |
| 40 | +``` |
| 41 | + |
| 42 | +**Scenario**: Simple speckit without AI commands (just CLI) |
| 43 | + |
| 44 | +--- |
| 45 | + |
| 46 | +### Example 2: SDD Toolkit (Greenfield Development) |
| 47 | + |
| 48 | +```toml |
| 49 | +[tool.metaspec] |
| 50 | +generated_by = "0.9.5" |
| 51 | +domain = "mcp" |
| 52 | +lifecycle = "greenfield" |
| 53 | + |
| 54 | +# Command system type (auto-detected) |
| 55 | +sd_type = "sdd" |
| 56 | + |
| 57 | +# Deployed slash commands |
| 58 | +[[tool.metaspec.slash_commands]] |
| 59 | +name = "specify" |
| 60 | +description = "Create feature specification" |
| 61 | +source = "sdd/spec-kit" |
| 62 | + |
| 63 | +[[tool.metaspec.slash_commands]] |
| 64 | +name = "plan" |
| 65 | +description = "Plan implementation architecture" |
| 66 | +source = "sdd/spec-kit" |
| 67 | + |
| 68 | +[[tool.metaspec.slash_commands]] |
| 69 | +name = "implement" |
| 70 | +description = "Execute implementation" |
| 71 | +source = "sdd/spec-kit" |
| 72 | +``` |
| 73 | + |
| 74 | +**Scenario**: Toolkit using GitHub spec-kit workflow (0→1 development) |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +### Example 3: Mixed SDS + SDD (MetaSpec Itself) |
| 79 | + |
| 80 | +```toml |
| 81 | +[tool.metaspec] |
| 82 | +generated_by = "0.9.5" |
| 83 | +domain = "meta-specification" |
| 84 | +lifecycle = "greenfield" |
| 85 | + |
| 86 | +# Command system type (auto-detected) |
| 87 | +sd_type = ["sds", "sdd"] |
| 88 | + |
| 89 | +# Deployed slash commands (19 total) |
| 90 | +[[tool.metaspec.slash_commands]] |
| 91 | +name = "sds.specify" |
| 92 | +description = "Define domain specification" |
| 93 | +source = "sds" |
| 94 | + |
| 95 | +[[tool.metaspec.slash_commands]] |
| 96 | +name = "sds.plan" |
| 97 | +description = "Plan specification architecture" |
| 98 | +source = "sds" |
| 99 | + |
| 100 | +[[tool.metaspec.slash_commands]] |
| 101 | +name = "sdd.specify" |
| 102 | +description = "Define toolkit specification" |
| 103 | +source = "sdd" |
| 104 | + |
| 105 | +[[tool.metaspec.slash_commands]] |
| 106 | +name = "sdd.implement" |
| 107 | +description = "Build toolkit code" |
| 108 | +source = "sdd" |
| 109 | + |
| 110 | +# ... (15 more commands) |
| 111 | +``` |
| 112 | + |
| 113 | +**Scenario**: MetaSpec itself - generates both specifications and toolkits |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +### Example 4: SD-Marketing (Custom Domain, No Lifecycle) |
| 118 | + |
| 119 | +```toml |
| 120 | +[tool.metaspec] |
| 121 | +generated_by = "0.9.5" |
| 122 | +domain = "marketing" |
| 123 | + |
| 124 | +# Command system type (auto-detected) |
| 125 | +sd_type = "generic" |
| 126 | + |
| 127 | +# Deployed slash commands |
| 128 | +[[tool.metaspec.slash_commands]] |
| 129 | +name = "campaign.create" |
| 130 | +description = "Create marketing campaign specification" |
| 131 | +source = "generic" |
| 132 | + |
| 133 | +[[tool.metaspec.slash_commands]] |
| 134 | +name = "campaign.validate" |
| 135 | +description = "Validate campaign against rules" |
| 136 | +source = "generic" |
| 137 | +``` |
| 138 | + |
| 139 | +**Scenario**: Marketing toolkit - "lifecycle" doesn't apply to this domain |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +### Example 5: Generic + SDD (Mixed Sources) |
| 144 | + |
| 145 | +```toml |
| 146 | +[tool.metaspec] |
| 147 | +generated_by = "0.9.5" |
| 148 | +domain = "api" |
| 149 | +lifecycle = "greenfield" |
| 150 | + |
| 151 | +# Command system type (auto-detected) |
| 152 | +sd_type = ["generic", "sdd"] |
| 153 | + |
| 154 | +# Deployed slash commands |
| 155 | +[[tool.metaspec.slash_commands]] |
| 156 | +name = "discover" |
| 157 | +description = "Discover API structure" |
| 158 | +source = "generic" |
| 159 | + |
| 160 | +[[tool.metaspec.slash_commands]] |
| 161 | +name = "specify" |
| 162 | +description = "Define API specification" |
| 163 | +source = "sdd/spec-kit" |
| 164 | + |
| 165 | +[[tool.metaspec.slash_commands]] |
| 166 | +name = "generate" |
| 167 | +description = "Generate API client code" |
| 168 | +source = "generic" |
| 169 | +``` |
| 170 | + |
| 171 | +**Scenario**: API toolkit combining generic discovery with spec-kit workflow |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +## 🔍 Auto-Detection Rules |
| 176 | + |
| 177 | +### `sd_type` Detection |
| 178 | + |
| 179 | +Based on `slash_commands[].source`: |
| 180 | + |
| 181 | +| Source Pattern | Detected Type | |
| 182 | +|----------------|---------------| |
| 183 | +| `sdd/spec-kit` | `"sdd"` | |
| 184 | +| `sdd/openspec` | `"sdd"` | |
| 185 | +| `sds/*` | `"sds"` | |
| 186 | +| `generic` | `"generic"` | |
| 187 | +| Mixed | `["sds", "sdd"]` or `["generic", "sdd"]` etc. | |
| 188 | + |
| 189 | +### `lifecycle` Usage |
| 190 | + |
| 191 | +- ✅ **Applicable**: Software development domains (API, testing, frameworks) |
| 192 | + - `greenfield`: Creating new features/projects (0→1) |
| 193 | + - `brownfield`: Evolving existing systems (1→n) |
| 194 | + |
| 195 | +- ⚠️ **Not Applicable**: Non-development domains (marketing, design, operations) |
| 196 | + - Leave `lifecycle` undefined (optional field) |
| 197 | + - Focus on `sd_type` and `domain` instead |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## 🎯 Community Use Cases |
| 202 | + |
| 203 | +### Use Case 1: Speckit Registry |
| 204 | + |
| 205 | +```python |
| 206 | +# Read speckit metadata |
| 207 | +import toml |
| 208 | + |
| 209 | +config = toml.load("pyproject.toml") |
| 210 | +metadata = config["tool"]["metaspec"] |
| 211 | + |
| 212 | +print(f"Domain: {metadata['domain']}") |
| 213 | +print(f"Command System: {metadata['sd_type']}") |
| 214 | +print(f"Slash Commands: {len(metadata.get('slash_commands', []))}") |
| 215 | +``` |
| 216 | + |
| 217 | +### Use Case 2: Search by Command Type |
| 218 | + |
| 219 | +```bash |
| 220 | +# Find all SDD toolkits |
| 221 | +rg -A 5 'sd_type = "sdd"' **/pyproject.toml |
| 222 | + |
| 223 | +# Find toolkits with specific commands |
| 224 | +rg -A 10 'name = "specify"' **/pyproject.toml |
| 225 | +``` |
| 226 | + |
| 227 | +### Use Case 3: Compatibility Check |
| 228 | + |
| 229 | +```python |
| 230 | +# Check if speckit has required commands |
| 231 | +required_commands = {"specify", "plan", "implement"} |
| 232 | +deployed = {cmd["name"] for cmd in metadata["slash_commands"]} |
| 233 | + |
| 234 | +if required_commands.issubset(deployed): |
| 235 | + print("✅ Compatible") |
| 236 | +``` |
| 237 | + |
| 238 | +--- |
| 239 | + |
| 240 | +## 📌 Design Principles |
| 241 | + |
| 242 | +1. **Auto-Detection**: `sd_type` automatically inferred from `slash_commands` |
| 243 | +2. **Optional Fields**: `lifecycle` only for applicable domains |
| 244 | +3. **Community Discovery**: Standardized format for registry tools |
| 245 | +4. **Backward Compatibility**: Minimal required fields |
| 246 | +5. **Flexibility**: Supports mixed command systems and custom domains |
| 247 | + |
| 248 | +--- |
| 249 | + |
| 250 | +## 🔗 Related |
| 251 | + |
| 252 | +- [Slash Commands Library](../src/metaspec/templates/library/README.md) |
| 253 | +- [Generator Implementation](../src/metaspec/generator.py) |
| 254 | +- [Models Definition](../src/metaspec/models.py) |
| 255 | + |
0 commit comments