zrb-sdlc-skill 1.0.0__tar.gz
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.
- zrb_sdlc_skill-1.0.0/PKG-INFO +115 -0
- zrb_sdlc_skill-1.0.0/README.md +105 -0
- zrb_sdlc_skill-1.0.0/pyproject.toml +31 -0
- zrb_sdlc_skill-1.0.0/setup.cfg +4 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/__init__.py +7 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/__main__.py +11 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/agents/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/agents/any_runner.py +64 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/agents/cli_runner.py +115 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/keys.py +94 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/layout.py +119 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/promote.py +154 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/rules.py +85 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/__init__.py +9 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/braces.py +33 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/dispatch.py +51 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/go.py +91 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/java_cs.py +81 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/javascript.py +119 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/python.py +150 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/rust.py +63 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/treesitter/__init__.py +18 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/treesitter/extract.py +266 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/treesitter/loader.py +78 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/treesitter/nodes.py +187 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/artifacts/symbols/types.py +47 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/ANNOTATION.md +172 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/CONVENTIONS.md +139 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/config.json +53 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/MAP.md +70 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/map.json +34 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/scripts/check_references.py +250 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/scripts/check_structure.py +194 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/scripts/check_symbols.py +117 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/scripts/collect_unknowns.py +193 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/scripts/map_config.py +277 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/scripts/run_checkers.py +112 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/templates/map-page.md +53 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/map/templates/story-page.md +56 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/adr.md +27 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/agents.md +36 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/architecture.md +72 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/drift-report.md +24 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/entity-dictionary.md +26 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/problem-brief.md +25 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/product.md +38 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/quickfix.md +51 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/review-report.md +36 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/rules.md +36 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/spec.md +42 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/tech.md +27 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/assets/templates/test-strategy.md +32 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/comments.py +285 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/external/__init__.py +21 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/external/lizard.py +124 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/external/runner.py +55 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/external/semgrep.py +206 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/finding.py +96 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/glossary.py +152 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/layers.py +221 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/naming.py +251 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/order.py +149 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/ratchet.py +161 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/rules_audit.py +53 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/runner.py +230 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/__init__.py +16 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/documents.py +68 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/exempt.py +20 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/fanout.py +55 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/files.py +50 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/gate.py +45 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/layout.py +82 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/report.py +16 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/shape/size.py +150 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/checks/traceability.py +109 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/app.py +296 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/formatters.py +79 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/install_commands.py +111 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/map_commands.py +80 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/show_commands.py +55 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/cli/weed_commands.py +88 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/loader.py +46 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/schema/__init__.py +38 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/schema/coerce.py +101 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/schema/gates.py +124 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/schema/parse.py +190 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/schema/types.py +85 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/schema/words.py +43 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/config/tooling.py +199 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/garden/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/garden/weeds.py +200 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/installer/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/installer/install.py +259 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/installer/registry.py +103 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/installer/skills.py +33 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/map/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/map/installer.py +80 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-adopt/SKILL.md +49 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-implement/SKILL.md +31 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-init/SKILL.md +59 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-map/SKILL.md +29 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-plan/SKILL.md +21 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-quickfix/SKILL.md +21 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-review/SKILL.md +33 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-spec/SKILL.md +21 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/skills/sdlc-tend/SKILL.md +34 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/__init__.py +51 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/base.py +297 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/config.py +293 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/coverage.py +221 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/ears.py +148 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/engine.py +227 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/files.py +250 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/patterns.py +232 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/spec_key.py +173 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/spec_parse.py +272 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/traceability/tags.py +177 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/workflow/__init__.py +1 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/workflow/implement.py +271 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/workflow/init_project.py +82 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/workflow/isolation.py +55 -0
- zrb_sdlc_skill-1.0.0/src/sdlc/workflow/review.py +287 -0
- zrb_sdlc_skill-1.0.0/src/zrb_sdlc_skill.egg-info/PKG-INFO +115 -0
- zrb_sdlc_skill-1.0.0/src/zrb_sdlc_skill.egg-info/SOURCES.txt +148 -0
- zrb_sdlc_skill-1.0.0/src/zrb_sdlc_skill.egg-info/dependency_links.txt +1 -0
- zrb_sdlc_skill-1.0.0/src/zrb_sdlc_skill.egg-info/entry_points.txt +2 -0
- zrb_sdlc_skill-1.0.0/src/zrb_sdlc_skill.egg-info/requires.txt +4 -0
- zrb_sdlc_skill-1.0.0/src/zrb_sdlc_skill.egg-info/top_level.txt +1 -0
- zrb_sdlc_skill-1.0.0/tests/test_eval_runner.py +170 -0
- zrb_sdlc_skill-1.0.0/tests/test_map_checker_runner.py +107 -0
- zrb_sdlc_skill-1.0.0/tests/test_map_checkers.py +151 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_assets.py +55 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_ast.py +251 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_ast_loader.py +104 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_checks.py +299 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_cli.py +233 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_external_gates.py +271 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_garden.py +192 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_glossary.py +145 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_install.py +137 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_map.py +146 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_scan_scope.py +68 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_tooling.py +95 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_validate.py +54 -0
- zrb_sdlc_skill-1.0.0/tests/test_sdlc_workflow.py +287 -0
- zrb_sdlc_skill-1.0.0/tests/test_skill_prompts.py +246 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zrb-sdlc-skill
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Deterministic SDLC CLI engine and thin AI coding skills
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Provides-Extra: ast
|
|
8
|
+
Requires-Dist: tree-sitter>=0.23; extra == "ast"
|
|
9
|
+
Requires-Dist: tree-sitter-language-pack>=0.7; extra == "ast"
|
|
10
|
+
|
|
11
|
+
# SDLC AI Plugin
|
|
12
|
+
|
|
13
|
+
A standalone, stdlib-only `sdlc` CLI (`src/sdlc/`) paired with thin chat skills (`src/sdlc/skills/sdlc-*/SKILL.md`, shipped inside the package) for spec-driven development and codebase maintenance. Deterministic mechanics run in Python; chat skills handle human interviews and semantic judgement.
|
|
14
|
+
|
|
15
|
+
- **Works everywhere:** humans, CI, `zrb`, `agy`, Claude Code, Codex, Gemini, Copilot, OpenCode, and ~30 `SKILL.md`-compatible tools all call the same zero-dependency `sdlc` CLI.
|
|
16
|
+
- **Project-owned templates:** `.sdlc/templates/` lives in your repo; edit them to change generated shapes without forking.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 1. Install the CLI — the package carries the skills
|
|
22
|
+
pipx install zrb-sdlc-skill # or: pip install zrb-sdlc-skill
|
|
23
|
+
# Optional: Tree-sitter AST parsing for JS/TS, Go, Rust, Java, C#, Kotlin
|
|
24
|
+
pip install 'zrb-sdlc-skill[ast]' # or: pipx inject zrb-sdlc-skill tree-sitter tree-sitter-language-pack
|
|
25
|
+
|
|
26
|
+
# 2. Install the chat skills into AI coding harnesses
|
|
27
|
+
sdlc install # every harness whose home exists
|
|
28
|
+
sdlc install --harness claude,codex # specific harnesses (repeatable)
|
|
29
|
+
sdlc install --harness all # every known harness
|
|
30
|
+
sdlc install --dir .claude/skills # project-scoped install
|
|
31
|
+
sdlc install --list # the ids --harness accepts
|
|
32
|
+
sdlc install --uninstall --harness all # remove only the skills this package owns
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**From a checkout:** `bin/install.sh` runs the same command against `src/`, so a
|
|
36
|
+
machine with no `sdlc` yet can install the skills that will call it.
|
|
37
|
+
|
|
38
|
+
**Upgrade:** `pipx upgrade zrb-sdlc-skill && sdlc install`, then run `sdlc init` (or `/sdlc-init`) in each project. `sdlc init` only adds missing files: your templates and `config.json` stay yours, and the engine was never copied into the project to begin with.
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Once per project
|
|
44
|
+
/sdlc-init # scaffolding (`sdlc init`) + steering docs + rules.md
|
|
45
|
+
/sdlc-plan # problem brief + entity dictionary + ADRs + architecture
|
|
46
|
+
|
|
47
|
+
# Per feature
|
|
48
|
+
/sdlc-spec <feature> # EARS spec + Code Layout + test plan (`sdlc key claim`)
|
|
49
|
+
sdlc implement <slug> # bounded coding loop + `.sdlc/` guard + `sdlc check --strict`
|
|
50
|
+
sdlc review <slug> # deterministic gates + fresh isolated review + Python verdict
|
|
51
|
+
|
|
52
|
+
# Maintenance & brownfield
|
|
53
|
+
/sdlc-quickfix <slug> # 1–3 REQ delta + `sdlc promote <delta> --yes`
|
|
54
|
+
/sdlc-adopt # relocate legacy `.sdlc/`, reverse-engineer specs, annotate
|
|
55
|
+
/sdlc-map # map unfamiliar code + install drift checkers
|
|
56
|
+
/sdlc-tend # re-run checkers, triage drift, write at most 1 PLANT checker
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Deterministic CLI (`sdlc`)
|
|
60
|
+
|
|
61
|
+
Every command supports `--json` for outer AI agents (`zrb chat`, `agy`, `claude`) and exits `0` clean, `1` warnings under `--strict`, `2` errors, `3` recursion blocked (`SDLC_DEPTH`):
|
|
62
|
+
|
|
63
|
+
| Command | What it enforces |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `sdlc --version` | Prints the package version, or says the tree is an uninstalled checkout. |
|
|
66
|
+
| `sdlc init [--dry-run] [--json]` | Copies missing `.sdlc/` scaffolding from the package, never overwrites an existing file, and detects stack/linters. |
|
|
67
|
+
| `sdlc key claim <KEY> <slug>` | Atomically creates `.sdlc/keys/<KEY>` and rejects collisions. |
|
|
68
|
+
| `sdlc validate [--feature <slug>] [--strict] [--json] [--verbose] [--relax-tag-roles]` | Traceability, EARS, ID hygiene, and AC citations only — the fast, dependency-free gate. |
|
|
69
|
+
| `sdlc check [--feature <slug>] [--strict] [--with-tests] [--no-external] [--json] [--verbose]` | Traceability, EARS, AC citations, configurable multi-language code-shape (`file-length`, `function-length`, `dir-fanout`, `doc-length`), S-I-D + A/HC/LC naming (`naming-*`), declaration order (`decl-order`), `Code Layout` + `Depends on` layering, import cycles, over-commenting, optional `semgrep` (`.sdlc/semgrep/` + `--test`) and `lizard` complexity gates, `.sdlc/ratchet.json`, and map/project gates. |
|
|
70
|
+
| `sdlc weed add <symptom> --evidence <file:line> --gate <check>` | Records one correction and the gate that prevents it in `.sdlc/weeds.json`. |
|
|
71
|
+
| `sdlc weed list [--status open\|pruned] [--json]` | Shows the weed register; `sdlc weed close <id>` marks one pruned. |
|
|
72
|
+
| `sdlc map init [--dry-run] [--json]` | Installs the map bundle under `.sdlc/map/`, never overwriting a file. |
|
|
73
|
+
| `sdlc map check [--json]` | Runs the map checker suite and its `--self-test` pass. |
|
|
74
|
+
| `sdlc show <asset> [--json]` | Prints a shipped asset (`CONVENTIONS.md`, `ANNOTATION.md`, `templates/spec.md`, `map/MAP.md`) before the project has a copy. |
|
|
75
|
+
| `sdlc ratchet update [--json]` | Pins brownfield shape warning counts in `.sdlc/ratchet.json` so violations may only decrease; refuses while errors remain. |
|
|
76
|
+
| `sdlc promote <delta> --yes` | Rewrites `ADDED`/`MODIFIED`/`REMOVED` requirements into `spec.md` without renumbering IDs and archives the delta. |
|
|
77
|
+
| `sdlc implement <slug> [--runner auto\|zrb\|claude\|codex\|agy] [--plan-only]` | Runs headless coder with `.sdlc/` auto-revert guard, `sdlc check --strict` retry loop (cap 2), and `SDLC_DEPTH` recursion limit. |
|
|
78
|
+
| `sdlc review <slug> [--runner auto\|...] [--deterministic-only]` | Runs `sdlc check --strict` + tests/lint first, invokes an isolated fresh-context reviewer, maps `APPROVE`/`COMMENT`/`REQUEST CHANGES` in Python, and writes `report-<ts>.md` with `## Verification Evidence` and `Gate candidate`. |
|
|
79
|
+
|
|
80
|
+
## Traceability & code shape
|
|
81
|
+
|
|
82
|
+
Specs declare `**Feature Key:** <KEY>`, and code carries one-line comment headers (see [CONVENTIONS.md](src/sdlc/assets/CONVENTIONS.md) and [ANNOTATION.md](src/sdlc/assets/ANNOTATION.md)):
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
# SPEC: .sdlc/specs/user-auth/spec.md
|
|
86
|
+
# IMPLEMENTS: AUTH:REQ-001, AUTH:NFR-002 # source file header
|
|
87
|
+
# COVERS: AUTH:REQ-001, AUTH:UT-001 # test file header
|
|
88
|
+
# @sdlc AUTH:REQ-001 # inline above the implementing unit
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
A correction becomes state, not a note: record it with `sdlc weed add`, let `sdlc check` report the open debt, and close it only when its gate is green. Comments that excuse the code (`for now`, `temporary`, `workaround`) are flagged as `comment-excuse`, and a name that uses a word the entity dictionary avoids is `naming-glossary`.
|
|
92
|
+
|
|
93
|
+
Wire CI with one blocking step: `sdlc check --strict` (add `--with-tests` once `commands.test` is wired; or `sdlc validate --strict` for traceability alone). The gate lives in the installed package; the project keeps only its own artifacts.
|
|
94
|
+
|
|
95
|
+
## Repository layout & verification
|
|
96
|
+
|
|
97
|
+
| Path | Role |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `src/sdlc/` | Modular stdlib Python CLI and the one copy of its assets (`assets/`, `traceability/`, `config/`, `artifacts/`, `checks/`, `garden/`, `map/`, `agents/`, `workflow/`, `cli/`) |
|
|
100
|
+
| `src/sdlc/skills/sdlc-*/SKILL.md` | Thin chat skills (interviews, synthesis, CLI routing), shipped inside the package |
|
|
101
|
+
| `src/sdlc/assets/` | The one copy of templates, `CONVENTIONS.md`, `ANNOTATION.md`, `config.json`; installed by `sdlc init` |
|
|
102
|
+
| `src/sdlc/assets/map/` | Map contract (`MAP.md`), `map.json`, templates, and the four checkers + `run_checkers.py` |
|
|
103
|
+
| `tests/`, `evals/`, `bin/test.sh` | Regression suites, deterministic golden evals, and full CI gate (including dogfood `sdlc check --strict`) |
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
bin/test.sh
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Limitations
|
|
110
|
+
|
|
111
|
+
- **Interactive approvals stay prompt-level** when invoked via chat skills; CLI mutations require explicit `--yes`.
|
|
112
|
+
- **`--with-tests` needs a test command.** A project with no `commands.test` gets a `tests-missing` warning, `sdlc implement` stops, and `sdlc review` can reach only `COMMENT`.
|
|
113
|
+
- **Reviewer isolation is proven, not assumed.** `sdlc review` fingerprints the worktree before and after the reviewer; an edit is a `Reviewer Isolation` FAIL and `REQUEST CHANGES`, and a project without git caps the verdict at `COMMENT`.
|
|
114
|
+
- **Semantic edge cases remain review-level:** configurable `naming.*` and `shape.*` gates catch structural/lexical S-I-D, A/HC/LC, the entity dictionary's avoided words (`naming-glossary`), declaration order, restating comments, layering, and cycles across Python, Go, JS/TS, Rust, and Java/C#/Kotlin; nuanced domain naming and subtle comment accuracy stay in `sdlc review`.
|
|
115
|
+
- **Specs are snapshots** updated explicitly via `/sdlc-quickfix` or `/sdlc-adopt`.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# SDLC AI Plugin
|
|
2
|
+
|
|
3
|
+
A standalone, stdlib-only `sdlc` CLI (`src/sdlc/`) paired with thin chat skills (`src/sdlc/skills/sdlc-*/SKILL.md`, shipped inside the package) for spec-driven development and codebase maintenance. Deterministic mechanics run in Python; chat skills handle human interviews and semantic judgement.
|
|
4
|
+
|
|
5
|
+
- **Works everywhere:** humans, CI, `zrb`, `agy`, Claude Code, Codex, Gemini, Copilot, OpenCode, and ~30 `SKILL.md`-compatible tools all call the same zero-dependency `sdlc` CLI.
|
|
6
|
+
- **Project-owned templates:** `.sdlc/templates/` lives in your repo; edit them to change generated shapes without forking.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
# 1. Install the CLI — the package carries the skills
|
|
12
|
+
pipx install zrb-sdlc-skill # or: pip install zrb-sdlc-skill
|
|
13
|
+
# Optional: Tree-sitter AST parsing for JS/TS, Go, Rust, Java, C#, Kotlin
|
|
14
|
+
pip install 'zrb-sdlc-skill[ast]' # or: pipx inject zrb-sdlc-skill tree-sitter tree-sitter-language-pack
|
|
15
|
+
|
|
16
|
+
# 2. Install the chat skills into AI coding harnesses
|
|
17
|
+
sdlc install # every harness whose home exists
|
|
18
|
+
sdlc install --harness claude,codex # specific harnesses (repeatable)
|
|
19
|
+
sdlc install --harness all # every known harness
|
|
20
|
+
sdlc install --dir .claude/skills # project-scoped install
|
|
21
|
+
sdlc install --list # the ids --harness accepts
|
|
22
|
+
sdlc install --uninstall --harness all # remove only the skills this package owns
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**From a checkout:** `bin/install.sh` runs the same command against `src/`, so a
|
|
26
|
+
machine with no `sdlc` yet can install the skills that will call it.
|
|
27
|
+
|
|
28
|
+
**Upgrade:** `pipx upgrade zrb-sdlc-skill && sdlc install`, then run `sdlc init` (or `/sdlc-init`) in each project. `sdlc init` only adds missing files: your templates and `config.json` stay yours, and the engine was never copied into the project to begin with.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Once per project
|
|
34
|
+
/sdlc-init # scaffolding (`sdlc init`) + steering docs + rules.md
|
|
35
|
+
/sdlc-plan # problem brief + entity dictionary + ADRs + architecture
|
|
36
|
+
|
|
37
|
+
# Per feature
|
|
38
|
+
/sdlc-spec <feature> # EARS spec + Code Layout + test plan (`sdlc key claim`)
|
|
39
|
+
sdlc implement <slug> # bounded coding loop + `.sdlc/` guard + `sdlc check --strict`
|
|
40
|
+
sdlc review <slug> # deterministic gates + fresh isolated review + Python verdict
|
|
41
|
+
|
|
42
|
+
# Maintenance & brownfield
|
|
43
|
+
/sdlc-quickfix <slug> # 1–3 REQ delta + `sdlc promote <delta> --yes`
|
|
44
|
+
/sdlc-adopt # relocate legacy `.sdlc/`, reverse-engineer specs, annotate
|
|
45
|
+
/sdlc-map # map unfamiliar code + install drift checkers
|
|
46
|
+
/sdlc-tend # re-run checkers, triage drift, write at most 1 PLANT checker
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Deterministic CLI (`sdlc`)
|
|
50
|
+
|
|
51
|
+
Every command supports `--json` for outer AI agents (`zrb chat`, `agy`, `claude`) and exits `0` clean, `1` warnings under `--strict`, `2` errors, `3` recursion blocked (`SDLC_DEPTH`):
|
|
52
|
+
|
|
53
|
+
| Command | What it enforces |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `sdlc --version` | Prints the package version, or says the tree is an uninstalled checkout. |
|
|
56
|
+
| `sdlc init [--dry-run] [--json]` | Copies missing `.sdlc/` scaffolding from the package, never overwrites an existing file, and detects stack/linters. |
|
|
57
|
+
| `sdlc key claim <KEY> <slug>` | Atomically creates `.sdlc/keys/<KEY>` and rejects collisions. |
|
|
58
|
+
| `sdlc validate [--feature <slug>] [--strict] [--json] [--verbose] [--relax-tag-roles]` | Traceability, EARS, ID hygiene, and AC citations only — the fast, dependency-free gate. |
|
|
59
|
+
| `sdlc check [--feature <slug>] [--strict] [--with-tests] [--no-external] [--json] [--verbose]` | Traceability, EARS, AC citations, configurable multi-language code-shape (`file-length`, `function-length`, `dir-fanout`, `doc-length`), S-I-D + A/HC/LC naming (`naming-*`), declaration order (`decl-order`), `Code Layout` + `Depends on` layering, import cycles, over-commenting, optional `semgrep` (`.sdlc/semgrep/` + `--test`) and `lizard` complexity gates, `.sdlc/ratchet.json`, and map/project gates. |
|
|
60
|
+
| `sdlc weed add <symptom> --evidence <file:line> --gate <check>` | Records one correction and the gate that prevents it in `.sdlc/weeds.json`. |
|
|
61
|
+
| `sdlc weed list [--status open\|pruned] [--json]` | Shows the weed register; `sdlc weed close <id>` marks one pruned. |
|
|
62
|
+
| `sdlc map init [--dry-run] [--json]` | Installs the map bundle under `.sdlc/map/`, never overwriting a file. |
|
|
63
|
+
| `sdlc map check [--json]` | Runs the map checker suite and its `--self-test` pass. |
|
|
64
|
+
| `sdlc show <asset> [--json]` | Prints a shipped asset (`CONVENTIONS.md`, `ANNOTATION.md`, `templates/spec.md`, `map/MAP.md`) before the project has a copy. |
|
|
65
|
+
| `sdlc ratchet update [--json]` | Pins brownfield shape warning counts in `.sdlc/ratchet.json` so violations may only decrease; refuses while errors remain. |
|
|
66
|
+
| `sdlc promote <delta> --yes` | Rewrites `ADDED`/`MODIFIED`/`REMOVED` requirements into `spec.md` without renumbering IDs and archives the delta. |
|
|
67
|
+
| `sdlc implement <slug> [--runner auto\|zrb\|claude\|codex\|agy] [--plan-only]` | Runs headless coder with `.sdlc/` auto-revert guard, `sdlc check --strict` retry loop (cap 2), and `SDLC_DEPTH` recursion limit. |
|
|
68
|
+
| `sdlc review <slug> [--runner auto\|...] [--deterministic-only]` | Runs `sdlc check --strict` + tests/lint first, invokes an isolated fresh-context reviewer, maps `APPROVE`/`COMMENT`/`REQUEST CHANGES` in Python, and writes `report-<ts>.md` with `## Verification Evidence` and `Gate candidate`. |
|
|
69
|
+
|
|
70
|
+
## Traceability & code shape
|
|
71
|
+
|
|
72
|
+
Specs declare `**Feature Key:** <KEY>`, and code carries one-line comment headers (see [CONVENTIONS.md](src/sdlc/assets/CONVENTIONS.md) and [ANNOTATION.md](src/sdlc/assets/ANNOTATION.md)):
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
# SPEC: .sdlc/specs/user-auth/spec.md
|
|
76
|
+
# IMPLEMENTS: AUTH:REQ-001, AUTH:NFR-002 # source file header
|
|
77
|
+
# COVERS: AUTH:REQ-001, AUTH:UT-001 # test file header
|
|
78
|
+
# @sdlc AUTH:REQ-001 # inline above the implementing unit
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
A correction becomes state, not a note: record it with `sdlc weed add`, let `sdlc check` report the open debt, and close it only when its gate is green. Comments that excuse the code (`for now`, `temporary`, `workaround`) are flagged as `comment-excuse`, and a name that uses a word the entity dictionary avoids is `naming-glossary`.
|
|
82
|
+
|
|
83
|
+
Wire CI with one blocking step: `sdlc check --strict` (add `--with-tests` once `commands.test` is wired; or `sdlc validate --strict` for traceability alone). The gate lives in the installed package; the project keeps only its own artifacts.
|
|
84
|
+
|
|
85
|
+
## Repository layout & verification
|
|
86
|
+
|
|
87
|
+
| Path | Role |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `src/sdlc/` | Modular stdlib Python CLI and the one copy of its assets (`assets/`, `traceability/`, `config/`, `artifacts/`, `checks/`, `garden/`, `map/`, `agents/`, `workflow/`, `cli/`) |
|
|
90
|
+
| `src/sdlc/skills/sdlc-*/SKILL.md` | Thin chat skills (interviews, synthesis, CLI routing), shipped inside the package |
|
|
91
|
+
| `src/sdlc/assets/` | The one copy of templates, `CONVENTIONS.md`, `ANNOTATION.md`, `config.json`; installed by `sdlc init` |
|
|
92
|
+
| `src/sdlc/assets/map/` | Map contract (`MAP.md`), `map.json`, templates, and the four checkers + `run_checkers.py` |
|
|
93
|
+
| `tests/`, `evals/`, `bin/test.sh` | Regression suites, deterministic golden evals, and full CI gate (including dogfood `sdlc check --strict`) |
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
bin/test.sh
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Limitations
|
|
100
|
+
|
|
101
|
+
- **Interactive approvals stay prompt-level** when invoked via chat skills; CLI mutations require explicit `--yes`.
|
|
102
|
+
- **`--with-tests` needs a test command.** A project with no `commands.test` gets a `tests-missing` warning, `sdlc implement` stops, and `sdlc review` can reach only `COMMENT`.
|
|
103
|
+
- **Reviewer isolation is proven, not assumed.** `sdlc review` fingerprints the worktree before and after the reviewer; an edit is a `Reviewer Isolation` FAIL and `REQUEST CHANGES`, and a project without git caps the verdict at `COMMENT`.
|
|
104
|
+
- **Semantic edge cases remain review-level:** configurable `naming.*` and `shape.*` gates catch structural/lexical S-I-D, A/HC/LC, the entity dictionary's avoided words (`naming-glossary`), declaration order, restating comments, layering, and cycles across Python, Go, JS/TS, Rust, and Java/C#/Kotlin; nuanced domain naming and subtle comment accuracy stay in `sdlc review`.
|
|
105
|
+
- **Specs are snapshots** updated explicitly via `/sdlc-quickfix` or `/sdlc-adopt`.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zrb-sdlc-skill"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Deterministic SDLC CLI engine and thin AI coding skills"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
dependencies = []
|
|
12
|
+
|
|
13
|
+
[project.optional-dependencies]
|
|
14
|
+
ast = ["tree-sitter>=0.23", "tree-sitter-language-pack>=0.7"]
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
sdlc = "sdlc.cli.app:main"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.packages.find]
|
|
20
|
+
where = ["src"]
|
|
21
|
+
[tool.setuptools.package-data]
|
|
22
|
+
sdlc = [
|
|
23
|
+
"assets/*.md",
|
|
24
|
+
"assets/*.json",
|
|
25
|
+
"assets/templates/*.md",
|
|
26
|
+
"assets/map/*.md",
|
|
27
|
+
"assets/map/*.json",
|
|
28
|
+
"assets/map/templates/*.md",
|
|
29
|
+
"assets/map/scripts/*.py",
|
|
30
|
+
"skills/*/SKILL.md",
|
|
31
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Module entry point for `python3 -m sdlc` and `.pyz` zipapp execution."""
|
|
2
|
+
|
|
3
|
+
# SPEC: .sdlc/specs/cli-engine/spec.md
|
|
4
|
+
# IMPLEMENTS: CLI:REQ-010, CLI:NFR-001
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from sdlc.cli.app import main
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
sys.exit(main())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Pluggable headless agent runner contracts and adapters."""
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""`AnyAgentRunner` contract, recursion guard, and runner selection."""
|
|
2
|
+
|
|
3
|
+
# SPEC: .sdlc/specs/cli-engine/spec.md
|
|
4
|
+
# IMPLEMENTS: CLI:REQ-008, CLI:REQ-009, CLI:NFR-001
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import abc
|
|
9
|
+
import os
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Optional
|
|
13
|
+
|
|
14
|
+
SDLC_DEPTH_ENV = "SDLC_DEPTH"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(frozen=True)
|
|
18
|
+
class AgentRequest:
|
|
19
|
+
prompt: str
|
|
20
|
+
working_dir: Path
|
|
21
|
+
fresh_session: bool = True
|
|
22
|
+
read_only: bool = False
|
|
23
|
+
model: Optional[str] = None
|
|
24
|
+
session_label: str = "sdlc"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclass(frozen=True)
|
|
28
|
+
class AgentResult:
|
|
29
|
+
exit_code: int
|
|
30
|
+
output: str
|
|
31
|
+
runner_name: str
|
|
32
|
+
provenance: str
|
|
33
|
+
|
|
34
|
+
def is_ok(self) -> bool:
|
|
35
|
+
return self.exit_code == 0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class AnyAgentRunner(abc.ABC):
|
|
39
|
+
"""Abstract interface for invoking a coding or review agent headlessly."""
|
|
40
|
+
|
|
41
|
+
@abc.abstractmethod
|
|
42
|
+
def get_name(self) -> str:
|
|
43
|
+
"""Return the stable runner identifier."""
|
|
44
|
+
|
|
45
|
+
@abc.abstractmethod
|
|
46
|
+
def run(self, request: AgentRequest) -> AgentResult:
|
|
47
|
+
"""Execute `request` and return structured output and provenance."""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def get_recursion_depth() -> int:
|
|
51
|
+
"""Return current nested agent invocation depth from `SDLC_DEPTH`."""
|
|
52
|
+
raw = os.environ.get(SDLC_DEPTH_ENV, "0").strip()
|
|
53
|
+
try:
|
|
54
|
+
value = int(raw)
|
|
55
|
+
return max(0, value)
|
|
56
|
+
except ValueError:
|
|
57
|
+
return 0
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def is_recursion_blocked(max_depth: int, allow_nested: bool = False) -> bool:
|
|
61
|
+
"""Whether spawning another agent would exceed `max_depth`."""
|
|
62
|
+
if allow_nested:
|
|
63
|
+
return False
|
|
64
|
+
return get_recursion_depth() >= max_depth
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Subprocess headless runner for `claude -p`, `codex exec`, `zrb chat`, and `agy`."""
|
|
2
|
+
|
|
3
|
+
# SPEC: .sdlc/specs/cli-engine/spec.md
|
|
4
|
+
# IMPLEMENTS: CLI:REQ-008, CLI:REQ-009, CLI:NFR-001
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess
|
|
11
|
+
import uuid
|
|
12
|
+
from typing import List
|
|
13
|
+
|
|
14
|
+
from sdlc.agents.any_runner import (
|
|
15
|
+
AgentRequest,
|
|
16
|
+
AgentResult,
|
|
17
|
+
AnyAgentRunner,
|
|
18
|
+
SDLC_DEPTH_ENV,
|
|
19
|
+
get_recursion_depth,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def create_agent_runner(preference: str = "auto") -> AnyAgentRunner:
|
|
24
|
+
"""Resolve `preference` (`auto`, `zrb`, `claude`, `codex`, `agy`) to a subprocess runner."""
|
|
25
|
+
if preference in ("zrb", "claude", "codex", "agy"):
|
|
26
|
+
return SubprocessAgentRunner(preference)
|
|
27
|
+
if preference == "auto":
|
|
28
|
+
for candidate in ("zrb", "claude", "codex", "agy"):
|
|
29
|
+
if shutil.which(candidate):
|
|
30
|
+
return SubprocessAgentRunner(candidate)
|
|
31
|
+
return SubprocessAgentRunner("claude")
|
|
32
|
+
raise ValueError(
|
|
33
|
+
"Unknown agent runner '%s'; expected auto, zrb, claude, codex, or agy."
|
|
34
|
+
% preference
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SubprocessAgentRunner(AnyAgentRunner):
|
|
39
|
+
"""Invoke an external headless coding-agent CLI with `SDLC_DEPTH` tracking."""
|
|
40
|
+
|
|
41
|
+
def __init__(self, binary: str = "claude") -> None:
|
|
42
|
+
self._binary = binary
|
|
43
|
+
|
|
44
|
+
def get_name(self) -> str:
|
|
45
|
+
return self._binary
|
|
46
|
+
|
|
47
|
+
def run(self, request: AgentRequest) -> AgentResult:
|
|
48
|
+
resolved = shutil.which(self._binary)
|
|
49
|
+
if not resolved:
|
|
50
|
+
return AgentResult(
|
|
51
|
+
exit_code=2,
|
|
52
|
+
output="Agent CLI '%s' not found on PATH." % self._binary,
|
|
53
|
+
runner_name=self._binary,
|
|
54
|
+
provenance="unavailable",
|
|
55
|
+
)
|
|
56
|
+
cmd = _build_cli_command(self._binary, resolved, request)
|
|
57
|
+
env = dict(os.environ)
|
|
58
|
+
env[SDLC_DEPTH_ENV] = str(get_recursion_depth() + 1)
|
|
59
|
+
completed = subprocess.run(
|
|
60
|
+
cmd,
|
|
61
|
+
cwd=str(request.working_dir),
|
|
62
|
+
env=env,
|
|
63
|
+
capture_output=True,
|
|
64
|
+
text=True,
|
|
65
|
+
)
|
|
66
|
+
combined = (completed.stdout or "").strip()
|
|
67
|
+
if completed.stderr:
|
|
68
|
+
stderr_clean = completed.stderr.strip()
|
|
69
|
+
combined = (combined + "\n" + stderr_clean).strip() if combined else stderr_clean
|
|
70
|
+
provenance = (
|
|
71
|
+
"fresh-isolated-%s" % self._binary
|
|
72
|
+
if request.fresh_session
|
|
73
|
+
else self._binary
|
|
74
|
+
)
|
|
75
|
+
return AgentResult(
|
|
76
|
+
exit_code=completed.returncode,
|
|
77
|
+
output=combined,
|
|
78
|
+
runner_name=self._binary,
|
|
79
|
+
provenance=provenance,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _build_cli_command(
|
|
84
|
+
binary: str, resolved_path: str, request: AgentRequest
|
|
85
|
+
) -> List[str]:
|
|
86
|
+
if binary == "claude":
|
|
87
|
+
cmd = [resolved_path, "-p", request.prompt]
|
|
88
|
+
if request.fresh_session:
|
|
89
|
+
cmd.append("--no-session-persistence")
|
|
90
|
+
if request.model:
|
|
91
|
+
cmd.extend(["--model", request.model])
|
|
92
|
+
return cmd
|
|
93
|
+
if binary == "codex":
|
|
94
|
+
cmd = [resolved_path, "exec", request.prompt]
|
|
95
|
+
if request.read_only:
|
|
96
|
+
cmd.extend(["--sandbox", "read-only"])
|
|
97
|
+
return cmd
|
|
98
|
+
if binary == "zrb":
|
|
99
|
+
session_name = "%s-%s" % (request.session_label, uuid.uuid4().hex[:8])
|
|
100
|
+
cmd = [
|
|
101
|
+
resolved_path,
|
|
102
|
+
"chat",
|
|
103
|
+
"--message",
|
|
104
|
+
request.prompt,
|
|
105
|
+
"--interactive",
|
|
106
|
+
"false",
|
|
107
|
+
"--sandbox",
|
|
108
|
+
"true",
|
|
109
|
+
"--session",
|
|
110
|
+
session_name,
|
|
111
|
+
]
|
|
112
|
+
if request.model:
|
|
113
|
+
cmd.extend(["--model", request.model])
|
|
114
|
+
return cmd
|
|
115
|
+
return [resolved_path, request.prompt]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Parsers and deterministic mutations for `.sdlc/` artifacts."""
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Slugification and atomic Feature Key claims under `.sdlc/keys/`."""
|
|
2
|
+
|
|
3
|
+
# SPEC: .sdlc/specs/cli-engine/spec.md
|
|
4
|
+
# IMPLEMENTS: CLI:REQ-007, CLI:NFR-001
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Dict, Tuple
|
|
12
|
+
|
|
13
|
+
SLUG_DROP_PATTERN = re.compile(r"[^a-z0-9-]+")
|
|
14
|
+
SLUG_DASH_PATTERN = re.compile(r"-+")
|
|
15
|
+
FEATURE_KEY_PATTERN = re.compile(r"^[A-Z][A-Z0-9_-]*$")
|
|
16
|
+
SPEC_KEY_PATTERN = re.compile(
|
|
17
|
+
r"^\*{0,2}Feature Key:\*{0,2}\s*`?([A-Za-z0-9_-]+)`?", re.MULTILINE
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def create_feature_slug(raw_name: str) -> str:
|
|
22
|
+
"""Convert free-text feature name to canonical kebab-case slug."""
|
|
23
|
+
normalized = raw_name.strip().lower().replace("_", "-").replace(" ", "-")
|
|
24
|
+
cleaned = SLUG_DROP_PATTERN.sub("", normalized)
|
|
25
|
+
return SLUG_DASH_PATTERN.sub("-", cleaned).strip("-")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def is_valid_feature_key(feature_key: str) -> bool:
|
|
29
|
+
"""Whether `feature_key` matches `[A-Z][A-Z0-9_-]*`."""
|
|
30
|
+
return bool(FEATURE_KEY_PATTERN.match(feature_key))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def get_claimed_keys(root: Path) -> Dict[str, str]:
|
|
34
|
+
"""Return mapping of Feature Key -> feature slug from keys/ and specs/."""
|
|
35
|
+
claims: Dict[str, str] = {}
|
|
36
|
+
keys_dir = root / ".sdlc" / "keys"
|
|
37
|
+
if keys_dir.is_dir():
|
|
38
|
+
for entry in sorted(keys_dir.iterdir()):
|
|
39
|
+
if entry.is_file():
|
|
40
|
+
claims[entry.name] = entry.read_text(encoding="utf-8").strip()
|
|
41
|
+
specs_dir = root / ".sdlc" / "specs"
|
|
42
|
+
if specs_dir.is_dir():
|
|
43
|
+
for spec_file in sorted(specs_dir.glob("*/spec.md")):
|
|
44
|
+
key = _extract_spec_key(spec_file)
|
|
45
|
+
if key and key not in claims:
|
|
46
|
+
claims[key] = spec_file.parent.name
|
|
47
|
+
return claims
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def claim_feature_key(root: Path, feature_key: str, raw_slug: str) -> Tuple[bool, str]:
|
|
51
|
+
"""Atomically create `.sdlc/keys/<KEY>` for `slug`, failing on collision."""
|
|
52
|
+
slug = create_feature_slug(raw_slug)
|
|
53
|
+
if not slug:
|
|
54
|
+
return False, "Feature slug cannot be empty."
|
|
55
|
+
if not is_valid_feature_key(feature_key):
|
|
56
|
+
return (
|
|
57
|
+
False,
|
|
58
|
+
"Invalid Feature Key '%s'; must match [A-Z][A-Z0-9_-]*." % feature_key,
|
|
59
|
+
)
|
|
60
|
+
existing = get_claimed_keys(root)
|
|
61
|
+
if feature_key in existing:
|
|
62
|
+
owner = existing[feature_key]
|
|
63
|
+
if owner == slug:
|
|
64
|
+
return True, "Feature Key '%s' already claimed for '%s'." % (
|
|
65
|
+
feature_key,
|
|
66
|
+
slug,
|
|
67
|
+
)
|
|
68
|
+
return (
|
|
69
|
+
False,
|
|
70
|
+
"Feature Key '%s' is already claimed by '%s'." % (feature_key, owner),
|
|
71
|
+
)
|
|
72
|
+
keys_dir = root / ".sdlc" / "keys"
|
|
73
|
+
keys_dir.mkdir(parents=True, exist_ok=True)
|
|
74
|
+
claim_path = keys_dir / feature_key
|
|
75
|
+
try:
|
|
76
|
+
fd = os.open(str(claim_path), os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)
|
|
77
|
+
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
78
|
+
handle.write(slug + "\n")
|
|
79
|
+
except FileExistsError:
|
|
80
|
+
return False, "Feature Key '%s' was claimed concurrently." % feature_key
|
|
81
|
+
return True, "Claimed Feature Key '%s' for '%s' at .sdlc/keys/%s." % (
|
|
82
|
+
feature_key,
|
|
83
|
+
slug,
|
|
84
|
+
feature_key,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _extract_spec_key(spec_path: Path) -> str:
|
|
89
|
+
try:
|
|
90
|
+
text = spec_path.read_text(encoding="utf-8")
|
|
91
|
+
except OSError:
|
|
92
|
+
return ""
|
|
93
|
+
match = SPEC_KEY_PATTERN.search(text)
|
|
94
|
+
return match.group(1) if match else ""
|