specrails-core 5.0.0 → 5.1.0

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.
Files changed (48) hide show
  1. package/README.md +103 -310
  2. package/bin/specrails-core.mjs +3 -1
  3. package/dist/installer/cli.js +4 -0
  4. package/dist/installer/cli.js.map +1 -1
  5. package/dist/installer/commands/framework.js +64 -49
  6. package/dist/installer/commands/framework.js.map +1 -1
  7. package/dist/installer/commands/init.js +102 -66
  8. package/dist/installer/commands/init.js.map +1 -1
  9. package/dist/installer/commands/update.js +80 -74
  10. package/dist/installer/commands/update.js.map +1 -1
  11. package/dist/installer/commands/v5-migration.js +14 -0
  12. package/dist/installer/commands/v5-migration.js.map +1 -1
  13. package/dist/installer/phases/framework-lifecycle.js +2 -0
  14. package/dist/installer/phases/framework-lifecycle.js.map +1 -1
  15. package/dist/installer/phases/scaffold.js +191 -258
  16. package/dist/installer/phases/scaffold.js.map +1 -1
  17. package/dist/installer/runtime/pipeline-state.js +801 -0
  18. package/dist/installer/runtime/pipeline-state.js.map +1 -0
  19. package/dist/installer/util/exec.js +6 -1
  20. package/dist/installer/util/exec.js.map +1 -1
  21. package/dist/installer/util/fs.js +11 -2
  22. package/dist/installer/util/fs.js.map +1 -1
  23. package/dist/installer/util/install-transaction.js +246 -0
  24. package/dist/installer/util/install-transaction.js.map +1 -0
  25. package/dist/installer/util/registry.js +20 -0
  26. package/dist/installer/util/registry.js.map +1 -1
  27. package/docs/ci-cd.md +57 -0
  28. package/docs/user-docs/codex-vs-claude-code.md +23 -151
  29. package/docs/user-docs/core-updates.md +70 -0
  30. package/docs/user-docs/provider-pipelines.md +53 -0
  31. package/integration-contract.json +179 -66
  32. package/package.json +5 -2
  33. package/templates/agents/sr-developer.md +9 -11
  34. package/templates/agents/sr-reviewer.md +26 -33
  35. package/templates/codex-skills/batch-implement/SKILL.md +58 -244
  36. package/templates/codex-skills/implement/SKILL.md +136 -338
  37. package/templates/codex-skills/rails/sr-architect/SKILL.md +7 -0
  38. package/templates/codex-skills/rails/sr-developer/SKILL.md +13 -0
  39. package/templates/codex-skills/rails/sr-reviewer/SKILL.md +39 -5
  40. package/templates/codex-skills/retry/SKILL.md +37 -117
  41. package/templates/commands/specrails/batch-implement.md +16 -288
  42. package/templates/commands/specrails/implement.md +62 -1057
  43. package/templates/commands/specrails/retry.md +22 -314
  44. package/templates/gemini-commands/batch-implement.toml +28 -40
  45. package/templates/gemini-commands/implement.toml +55 -114
  46. package/templates/gemini-commands/retry.toml +21 -0
  47. package/templates/kimi/specrails/run-skill.mjs +51 -2
  48. package/templates/runtime/provider-pipeline.md +55 -0
package/docs/ci-cd.md ADDED
@@ -0,0 +1,57 @@
1
+ # Core CI and publishing
2
+
3
+ Core's release workflow publishes the **same npm tarball that passed CI**. It does not rebuild a replacement package inside the publish step. These workflows do not run provider models or publish from pull requests.
4
+
5
+ ## Quality gates
6
+
7
+ `CI` runs for branch pushes, pull requests to `main`, and manual dispatches. It has read-only repository permissions, cancels superseded runs on the same branch/PR, and has bounded job timeouts.
8
+
9
+ - Typecheck/build on the exact supported Node minimum, **20.19.0**.
10
+ - Full Vitest and release-guard tests on **Linux, macOS and Windows**, with **Node 20.19.0, 22 and 24**.
11
+ - Coverage on Node 24 with the existing configured thresholds (not lowered).
12
+ - A checksum-verified actionlint binary validates workflow syntax, expressions and action inputs (shellcheck is not included).
13
+ - A checksum-verified Gitleaks binary scans Git history with redacted output.
14
+ - On Node 24 on each OS, `scripts/verify-package.mjs` packs the built package, checks its file inventory, installs the tarball into an isolated temporary consumer with lifecycle scripts disabled, and executes both published CLI entry points. It materializes/assembles all four providers and runs the assembled pipeline helper against four frozen fixture scopes. No global install, real project registry, provider login or model call is used.
15
+
16
+ The Linux package smoke uploads `core-package` for 14 days, containing the `.tgz` and `release-manifest.json` (package/version, Git SHA and SHA-512 integrity). The manifest is only written after the consumer smoke succeeds.
17
+
18
+ Local checks, after installing dependencies:
19
+
20
+ ```sh
21
+ npm run ci # typecheck, guard regressions, coverage, packaged-consumer smoke
22
+ npm run test:scripts # hermetic release regressions only
23
+ npm run check:package # build and consumer smoke; prints its temporary artifact directory
24
+ # To choose where the verified tarball is kept:
25
+ node scripts/verify-package.mjs /absolute/path/to/temporary-package-output
26
+ ```
27
+
28
+ The package check may download the tarball's production dependencies from npm. Its generated output directory should be outside the checkout. Release-guard unit tests are hermetic and do not access npm or GitHub.
29
+
30
+ ## Automatic release
31
+
32
+ 1. A push to `main` starts `Release`. It waits for a successful `CI` **push run on the exact same main commit**, including the entire matrix, coverage, secret scan and package check. A success on an older commit or a PR does not qualify. Failed/cancelled CI fails the gate; waiting is bounded to 30 minutes.
33
+ 2. An additional current-main check skips obsolete pushes before changing release metadata. Release Please opens/updates the release PR, or creates the release/tag after that PR was merged. It has only the repository/PR write permissions it needs. The CI jobs do not receive those permissions.
34
+ 3. Before publishing, the workflow verifies that the stable `vX.Y.Z` tag points at the tested commit, that this commit is in `origin/main`, and that the tag, package.json, both root lockfile version fields and Release Please manifest agree. If main advanced while Release Please was working and it tagged a different SHA, publication fails closed.
35
+ 4. It downloads the tarball from that successful CI run and verifies its identity and integrity. It refuses to move npm `latest` backwards. An existing version is accepted only when its published integrity matches the verified artifact exactly.
36
+ 5. It publishes the `.tgz` with `--ignore-scripts --provenance --access public`, then sends downstream notifications. Only the publication job has `id-token: write`; the npm token is exposed only to the final publish step.
37
+
38
+ All automatic and manual releases share one non-cancelling concurrency group, so simultaneous runs cannot race the stable dist-tag.
39
+
40
+ ## Credentials and notifications
41
+
42
+ - `RELEASE_PAT` (recommended): a repository-scoped token with permission to maintain release branches, PRs and releases (Contents and Pull requests write). Release Please prefers this secret, allowing its generated PR events to start the normal required CI. A GitHub App installation token with equivalent permissions is also suitable if the workflow is configured to mint one; this workflow does not create an App or credentials.
43
+ - `GITHUB_TOKEN` fallback: retained so existing installations can maintain release metadata without a new secret. GitHub currently creates runs for token-generated PR `opened`, `synchronize` and `reopened` events **in an approval-required state**. The workflow warns when using this fallback: a maintainer with write access must select **Approve workflows to run** on the release PR after bot updates. Configure `RELEASE_PAT` for automatic CI without that approval prompt; do not bypass required checks or branch protection. Other token-generated events, including tag pushes, remain suppressed. Repository settings must permit Actions to create PRs. Publication is in this same workflow and does not depend on a new tag-triggered run. See [GitHub's current event-triggering rules](https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow). [Release Please also recommends a separate CI-capable credential](https://github.com/googleapis/release-please-action#other-actions-on-release-please-prs).
44
+ - `NPM_TOKEN`: existing token authentication remains supported; use a narrowly scoped token that can publish `specrails-core`. Do not remove it until npm trusted publishing has been configured for this repository and **`release.yml`**. Publishing runs on Node 24 and enforces npm >=11.5.1. The workflow requests OIDC and provenance but does not change npm account settings. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).
45
+ - `CROSS_REPO_TOKEN`: must permit repository dispatch to `fjpulidop/specrails-desktop` and `fjpulidop/specrails-web`. It is available only to the notification job.
46
+
47
+ Both consumers receive `repository_dispatch` event `specrails-core-released`. Desktop receives `{"core_version":"X.Y.Z"}` and validates the exact released integration contract; the website retains its historical `{"core_version":"vX.Y.Z"}` convention. Notification failure leaves a visible failed workflow, even when npm publication already succeeded.
48
+
49
+ ## Recover a failed publication or notification
50
+
51
+ Use **Actions → Release → Run workflow**, from the trusted main workflow, and provide an **existing** stable tag (`vX.Y.Z`). This path does not create a tag or bump versions. It checks main ancestry/version agreement, runs typecheck, release-guard tests and the full suite with coverage, then rebuilds, packs and consumer-tests that exact tag on Linux/Node 24 in a read-only preparation job. A separate publication job downloads those verified bytes; dependency installs and tests never have OIDC or npm credentials.
52
+
53
+ Manual recovery deliberately works without an old CI artifact. It does not rerun the full historical OS/Node matrix; normal automatic releases require that matrix. Tags predating these validation scripts cannot use this recovery path. If an identical version is already on npm, publication is skipped and both notifications are retried. Different bytes at that version, an older version than `latest`, missing tags or incompatible versions stop the run. npm versions are immutable; do not force around a mismatch.
54
+
55
+ For a failed initial CI gate, first repair/rerun CI for that commit, then rerun Release. Expired artifacts or a tag created at another main SHA can be recovered with the existing-tag manual path. If downstream notification failed, rerunning only its job is also sufficient and does not touch npm.
56
+
57
+ The workflows and hermetic fixtures validate the release machinery locally; successful native Windows/macOS CI, token permissions, OIDC configuration and a real publication can only be confirmed by their respective hosted runs.
@@ -1,151 +1,23 @@
1
- # Codex vs Claude Code
2
-
3
- SpecRails supports both **Anthropic Claude Code** and **OpenAI Codex** as AI
4
- agent runtimes. Gemini CLI and Kimi Code are also supported; this page focuses
5
- only on the Claude/Codex comparison.
6
-
7
- ---
8
-
9
- ## Summary
10
-
11
- | | Claude Code | Codex |
12
- |--|-------------|-------|
13
- | **Support status** | Supported | Supported |
14
- | **CLI** | `claude` | `codex` |
15
- | **Config directory** | `.claude/` | `.codex/` |
16
- | **Agent instructions** | `CLAUDE.md` | `AGENTS.md` |
17
- | **Skills (`/specrails:*`, `/opsx:*`)** | Full support | ✅ Full support |
18
- | **OpenSpec workflow** | Full support | Full support |
19
- | **Parallel worktrees** | Native | ⚠️ Limited |
20
- | **Agent definitions** | Markdown frontmatter | TOML |
21
- | **Permissions config** | `settings.json` | `config.toml` |
22
- | **Agent memory** | File-based | File-based (MEMORY.md) |
23
- | **MCP** | First-class | ✅ First-class |
24
- | **Codex Cloud (web)** | ✗ | ✅ |
25
-
26
- ---
27
-
28
- ## What works the same
29
-
30
- ### Skills
31
-
32
- SpecRails Skills use `SKILL.md` format, which is shared between Codex and Claude Code. All `/specrails:*` and `/opsx:*` skills run identically on both platforms:
33
-
34
- - `/specrails:implement` — full pipeline (design → code → review → PR)
35
- - `/specrails:get-backlog-specs` — VPC-ranked backlog view
36
- - `/opsx:ff` — OpenSpec fast-forward
37
- - All other workflow skills
38
-
39
- ### OpenSpec
40
-
41
- The full OpenSpec design-to-code workflow works on both platforms. Artifacts (proposals, designs, task lists, context bundles) are plain Markdown files — no platform dependency.
42
-
43
- ### Git and GitHub
44
-
45
- Both platforms use standard `git` and the `gh` CLI. PR creation, branch management, and issue integration work identically.
46
-
47
- ### Agent memory
48
-
49
- Both platforms use file-based memory. Claude Code uses `.claude/agent-memory/`. Codex uses `.codex/agent-memory/`. The format is the same — only the location changes.
50
-
51
- ---
52
-
53
- ## What is different
54
-
55
- ### Parallel execution and worktrees
56
-
57
- `/specrails:batch-implement` (multiple issues in parallel) uses git worktree isolation. On Claude Code this runs locally with full isolation. On Codex:
58
-
59
- - **Codex CLI**: Parallel execution is supported but worktree isolation is limited in the current beta. Multiple issues may share a working directory.
60
- - **Codex Cloud**: Native async parallelism — each task gets an isolated cloud environment. Well-suited for batch work.
61
-
62
- ### Agent definitions
63
-
64
- SpecRails generates agent definitions in the format required by each platform:
65
-
66
- | Platform | Format | Location |
67
- |----------|--------|----------|
68
- | Claude Code | Markdown with YAML frontmatter | `.claude/agents/sr-*.md` |
69
- | Codex | TOML | `.codex/agents/sr-*.toml` |
70
-
71
- The behavior of each agent (Architect, Developer, Reviewer, etc.) is identical — only the definition format differs.
72
-
73
- ### Configuration and permissions
74
-
75
- | Platform | Format | Location |
76
- |----------|--------|----------|
77
- | Claude Code | JSON | `.claude/settings.json` |
78
- | Codex | TOML | `.codex/config.toml` |
79
-
80
- The installer generates the correct format automatically.
81
-
82
- ### Non-interactive invocation
83
-
84
- Claude Code and Codex have different non-interactive modes:
85
-
86
- ```bash
87
- # Claude Code
88
- claude --print "run /specrails:implement #42"
89
-
90
- # Codex
91
- codex exec "run /specrails:implement #42"
92
- ```
93
-
94
- Skills themselves are the same — only the CLI invocation differs.
95
-
96
- ---
97
-
98
- ## Choosing a platform
99
-
100
- **Choose Claude Code if:**
101
- - You want the most stable and fully tested SpecRails experience
102
- - You need reliable parallel worktree isolation for batch feature work
103
- - Your team is already in the Anthropic ecosystem
104
-
105
- **Choose Codex if:**
106
- - Your team is in the OpenAI ecosystem and prefers Codex
107
- - You want to use Codex Cloud for async, web-based agent runs
108
- - You are evaluating SpecRails and already have Codex installed
109
-
110
- **Use both if:**
111
- - Different team members use different tools
112
- - You want to benchmark agents across platforms
113
-
114
- When several CLIs are installed, pass `--provider` to choose explicitly:
115
-
116
- ```bash
117
- npx specrails-core@latest init --provider codex
118
- ```
119
-
120
- ---
121
-
122
- ## Platform detection
123
-
124
- The installer detects your platform automatically:
125
-
126
- ```
127
- Detected CLI: codex (1.2.0)
128
- Generating config in .codex/
129
- ```
130
-
131
- To override:
132
-
133
- ```bash
134
- npx specrails-core@latest init --provider codex --root-dir .
135
- npx specrails-core@latest init --provider claude --root-dir .
136
- ```
137
-
138
- ---
139
-
140
- ## Known limitations (Codex beta)
141
-
142
- | Limitation | Status |
143
- |-----------|--------|
144
- | Parallel worktree isolation | Partial — being improved |
145
- | Windows support | Experimental in Codex CLI |
146
- | Agent memory system maturity | Less mature than Claude Code; use MEMORY.md patterns |
147
- | Codex CLI version stability | Frequent updates; pin your version if needed |
148
-
149
- ---
150
-
151
- [← Getting Started (Codex)](getting-started-codex.md) · [← Installation](installation.md) · [CLI Reference →](cli-reference.md)
1
+ # Codex and Claude Code execution
2
+
3
+ Both providers support the SpecRails design, implementation, review and archive
4
+ workflow. Their adapters differ; native role APIs and conversation memory are not
5
+ interchangeable.
6
+
7
+ | Concern | Claude Code | Codex |
8
+ |---|---|---|
9
+ | Role definitions | `.claude/agents/sr-*.md` | `.codex/skills/rails/sr-*/SKILL.md` |
10
+ | Workflow entry | `/specrails:implement` | `$implement` |
11
+ | Multiple tickets | Aggregate change and shared journal | Routes directly to `$batch-implement` |
12
+ | Retry | Durable pipeline journal | Same journal, direct role calls; no nested coordinator |
13
+ | Role models | Configured role/profile model | Inherited model on full-history forks; overrides require a compatible native transport |
14
+ | Verification | Scoped development checks and candidate-bound full gate | Same evidence contract |
15
+ | Hosted worktrees/delivery | Owned by the host | Owned by the host |
16
+
17
+ The installed `.specrails/runtime/pipeline.mjs` helper coordinates both providers.
18
+ Its execution context identifies the frozen specs, repositories, shared backlog,
19
+ OpenSpec artifact root and ownership. Skills must not infer those roots from cwd.
20
+
21
+ A completed process is not an implementation verdict. Design confidence, checked
22
+ tasks, semantic review, fresh verification and an authorized archive are required
23
+ before success. See [provider pipeline contracts](provider-pipelines.md).
@@ -0,0 +1,70 @@
1
+ # Core installation and update consistency
2
+
3
+ `specrails-core init` and `specrails-core update` use the version of the package
4
+ that actually provides the CLI. Updating an npm package and updating a workspace
5
+ are separate operations: run the selected CLI's `update --root-dir <repository>`
6
+ to refresh that project's managed artifacts. `--provider` selects the additional
7
+ provider to include; existing managed provider selections are preserved and
8
+ reassembled, including in-repository copies and Windows copy fallbacks. Provider
9
+ inventory is checked against installed Core artifacts; an unrelated directory
10
+ containing only user files is not enrolled automatically.
11
+
12
+ Core 5 installation is deterministic. It installs the baseline roles, commands,
13
+ OpenSpec integration and declared local execution helper without an AI enrichment
14
+ phase. `integration-contract.json` describes the supported lifecycle and providers.
15
+
16
+ ## Version and rollback rules
17
+
18
+ A CLI older than the workspace marker or shared active framework refuses ordinary
19
+ init/update. This protects an updated installation from an old global executable.
20
+ Use the intended Core package rather than editing a version marker to bypass the
21
+ check. Low-level explicit pointer changes are administrative rollback operations;
22
+ they do not imply that project copies have been restored.
23
+
24
+ Managed framework bytes are generated in an isolated staging directory, validated
25
+ and stamped before publication. The content/source hashes include the compiled
26
+ pipeline helper, so a same-version development rebuild is repaired when runtime
27
+ bytes change. The previous framework directory is retained as
28
+ `.previous-<version>-<id>` for recovery. A failed generation leaves the active
29
+ framework untouched.
30
+
31
+ Init/update snapshot the managed workspace surfaces and framework pointer. Failure
32
+ restores those snapshots, including symlinks, and does not publish a successful
33
+ workspace version or Core-owned registry version. If restoration itself fails,
34
+ the error identifies the retained backup for recovery. Reserved custom agents
35
+ stay in place during rollback: edits, new custom files and deliberate deletions
36
+ made while OpenSpec runs are preserved. Profiles remain outside the snapshot
37
+ surfaces; provider configuration is restored with the managed workspace snapshot.
38
+
39
+ A separate framework lifecycle lock covers admission, version revalidation,
40
+ snapshots, asynchronous OpenSpec provisioning and final commit or rollback. The
41
+ same lock protects Desktop's low-level install-framework, swap-current and
42
+ assemble commands. A concurrent operation fails immediately with a retry message
43
+ instead of waiting while holding another lock. This prevents a failed installer
44
+ from rolling back a framework that a second installer already reported as ready.
45
+ A positively dead process owner can be recovered; concurrent recovery attempts
46
+ are serialized, and an unidentified or live owner is never taken over.
47
+
48
+ `update --dry-run` reports the intended change without allocating or rewriting
49
+ registry entries. Partial `--only rules` or `--only agents` refreshes do not claim
50
+ that the entire framework has moved to the executing CLI's version. The returned
51
+ `installedVersion` describes the actual workspace marker.
52
+
53
+ The low-level `install-framework --version` command requires the requested label
54
+ to match the package version supplying its bytes. `assemble --version` requires
55
+ the matching complete active framework before recording that version in a project.
56
+
57
+ ## Desktop
58
+
59
+ Desktop keeps the selected package and its dependencies after an update. Its
60
+ Settings page reports runtime, framework, bundled and latest-known versions
61
+ separately. Partial workspace migration remains pending across restart and can be
62
+ retried using the retained package offline. A CLI installed outside Desktop can
63
+ also be discovered through PATH; an explicit `SPECRAILS_CORE_BIN` takes precedence.
64
+
65
+ Changes in this branch require a Core package build and distribution before an
66
+ already installed Desktop can consume them. The source changes alone do not
67
+ upgrade any user installation or publish a new package.
68
+
69
+ See [Provider pipeline contracts](provider-pipelines.md) for the resumable
70
+ implementation journal and verification behavior.
@@ -0,0 +1,53 @@
1
+ # Provider pipeline contracts
2
+
3
+ Core installs a local, self-contained Node helper at
4
+ `.specrails/runtime/pipeline.mjs`. It uses no global Core lookup or network download.
5
+ The shared contract is embedded in the installed Claude, Codex, Gemini and Kimi workflows.
6
+ `SPECRAILS_PIPELINE_RUNTIME` can explicitly identify that helper for a child process.
7
+
8
+ An absolute `SPECRAILS_EXECUTION_CONTEXT` JSON file supplies immutable specs, selected
9
+ repositories, OpenSpec artifactRoot, backlogRoot (the workspace containing
10
+ `.specrails/local-tickets.json`), optional backlogPath, and host/core ownership.
11
+ Batch uses one aggregate OpenSpec change and journal; task groups retain ticket and
12
+ repository identity. Final verification and semantic review cover the whole batch.
13
+
14
+ Standalone invocation admits ticket IDs with `init --tickets "17,18"` or a structured
15
+ `--scope-request` for free-form specs. Reuse the generated context on retry; explicit
16
+ host context always takes precedence. Core-owned delivery requires explicit ownership.
17
+
18
+ Use the helper's init/status/phase/verify/archive-check operations. Status identifies
19
+ the first invalid phase. Retry reuses valid earlier work; blocked remains retriable.
20
+ Explicit role handoffs contain frozen criteria and exact paths, not a promise that
21
+ another provider conversation retained memory. Archive-only execution preserves the
22
+ reviewed confidence file; the gate binds its exact bytes and the candidate.
23
+
24
+ ## Gemini
25
+
26
+ OpenSpec is installed with an isolated complete workflow profile, then Gemini skills
27
+ are placed in the actual execution workspace. Updates preserve custom skill folders.
28
+ The adapter requires invoke_agent and role activate_skill availability. Turn limits
29
+ are capability-dependent: older loaders reject optional metadata. By default Core
30
+ omits it and uses progress-bound continuation handoffs. After verifying loader
31
+ support, an installer may set SPECRAILS_GEMINI_AGENT_LIMITS=supported and
32
+ SPECRAILS_GEMINI_MAX_TURNS (1–200, default 60). This does not confer native session
33
+ continuity; every reinvocation still receives an explicit checkpoint.
34
+
35
+ ## Kimi
36
+
37
+ The managed runner preserves the absolute execution context, shared backlog path,
38
+ helper path and selected repository access across private role working directories.
39
+ SPECRAILS_BACKLOG_PATH is the exact ticket-file path; SPECRAILS_BACKLOG_ROOT is its
40
+ logical workspace. Host-owned contexts reject sibling worktree requests before any
41
+ role process starts. Role models remain exact profile values. Standalone managed
42
+ worktree manifests and their guarded merge/cleanup mechanism remain available.
43
+
44
+ ## Validation limits
45
+
46
+ Local regression fixtures install the real provider artifacts and run the real
47
+ helper against temporary repositories, including failed gates, review retry,
48
+ archive authorization and unchanged frozen scope. Kimi process fixtures additionally
49
+ exercise private cwd, shared-backlog access and host worktree rejection. They do not
50
+ make paid model calls or claim identical behavior across every native CLI release.
51
+
52
+ See [Core installation and update consistency](core-updates.md) for version
53
+ selection, rollback and Desktop integration.