specrails-core 5.3.0 → 5.4.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 (117) hide show
  1. package/dist/agent-runtime/capabilities.d.ts +27 -0
  2. package/dist/agent-runtime/capabilities.js +73 -0
  3. package/dist/agent-runtime/capabilities.js.map +1 -0
  4. package/dist/agent-runtime/cli-executor.d.ts +9 -0
  5. package/dist/agent-runtime/cli-executor.js +100 -30
  6. package/dist/agent-runtime/cli-executor.js.map +1 -1
  7. package/dist/agent-runtime/cli.d.ts +1 -0
  8. package/dist/agent-runtime/cli.js +59 -11
  9. package/dist/agent-runtime/cli.js.map +1 -1
  10. package/dist/agent-runtime/codex-schema.d.ts +4 -0
  11. package/dist/agent-runtime/codex-schema.js +31 -0
  12. package/dist/agent-runtime/codex-schema.js.map +1 -0
  13. package/dist/agent-runtime/config.d.ts +4 -0
  14. package/dist/agent-runtime/config.js +110 -9
  15. package/dist/agent-runtime/config.js.map +1 -1
  16. package/dist/agent-runtime/core-host.d.ts +9 -1
  17. package/dist/agent-runtime/core-host.js +55 -20
  18. package/dist/agent-runtime/core-host.js.map +1 -1
  19. package/dist/agent-runtime/efficiency-summary.d.ts +67 -0
  20. package/dist/agent-runtime/efficiency-summary.js +52 -0
  21. package/dist/agent-runtime/efficiency-summary.js.map +1 -0
  22. package/dist/agent-runtime/efficiency-types.d.ts +60 -0
  23. package/dist/agent-runtime/efficiency-types.js +8 -0
  24. package/dist/agent-runtime/efficiency-types.js.map +1 -0
  25. package/dist/agent-runtime/efficiency.d.ts +5 -0
  26. package/dist/agent-runtime/efficiency.js +35 -0
  27. package/dist/agent-runtime/efficiency.js.map +1 -0
  28. package/dist/agent-runtime/evaluation-corpus.d.ts +13 -0
  29. package/dist/agent-runtime/evaluation-corpus.js +8 -0
  30. package/dist/agent-runtime/evaluation-corpus.js.map +1 -0
  31. package/dist/agent-runtime/evaluation.d.ts +43 -0
  32. package/dist/agent-runtime/evaluation.js +171 -0
  33. package/dist/agent-runtime/evaluation.js.map +1 -0
  34. package/dist/agent-runtime/executor-types.d.ts +35 -2
  35. package/dist/agent-runtime/executor-types.js.map +1 -1
  36. package/dist/agent-runtime/executors.d.ts +1 -0
  37. package/dist/agent-runtime/executors.js +4 -0
  38. package/dist/agent-runtime/executors.js.map +1 -1
  39. package/dist/agent-runtime/graph/artifacts.d.ts +8 -22
  40. package/dist/agent-runtime/graph/artifacts.js +99 -73
  41. package/dist/agent-runtime/graph/artifacts.js.map +1 -1
  42. package/dist/agent-runtime/graph/nodes.d.ts +3 -0
  43. package/dist/agent-runtime/graph/nodes.js +73 -26
  44. package/dist/agent-runtime/graph/nodes.js.map +1 -1
  45. package/dist/agent-runtime/graph/roles.d.ts +4 -1
  46. package/dist/agent-runtime/graph/roles.js +100 -36
  47. package/dist/agent-runtime/graph/roles.js.map +1 -1
  48. package/dist/agent-runtime/graph/state.d.ts +8 -0
  49. package/dist/agent-runtime/graph/state.js.map +1 -1
  50. package/dist/agent-runtime/index.d.ts +7 -1
  51. package/dist/agent-runtime/index.js +7 -1
  52. package/dist/agent-runtime/index.js.map +1 -1
  53. package/dist/agent-runtime/kimi-acp.d.ts +4 -0
  54. package/dist/agent-runtime/kimi-acp.js +20 -9
  55. package/dist/agent-runtime/kimi-acp.js.map +1 -1
  56. package/dist/agent-runtime/openai-executor.d.ts +8 -0
  57. package/dist/agent-runtime/openai-executor.js +28 -10
  58. package/dist/agent-runtime/openai-executor.js.map +1 -1
  59. package/dist/agent-runtime/openspec-tool-server.d.ts +1 -0
  60. package/dist/agent-runtime/openspec-tool-server.js +37 -0
  61. package/dist/agent-runtime/openspec-tool-server.js.map +1 -0
  62. package/dist/agent-runtime/openspec.d.ts +123 -0
  63. package/dist/agent-runtime/openspec.js +263 -0
  64. package/dist/agent-runtime/openspec.js.map +1 -0
  65. package/dist/agent-runtime/prompts.d.ts +5 -1
  66. package/dist/agent-runtime/prompts.js +59 -40
  67. package/dist/agent-runtime/prompts.js.map +1 -1
  68. package/dist/agent-runtime/provider-diagnostic.d.ts +2 -0
  69. package/dist/agent-runtime/provider-diagnostic.js +25 -0
  70. package/dist/agent-runtime/provider-diagnostic.js.map +1 -0
  71. package/dist/agent-runtime/repository-context.d.ts +25 -0
  72. package/dist/agent-runtime/repository-context.js +100 -0
  73. package/dist/agent-runtime/repository-context.js.map +1 -0
  74. package/dist/agent-runtime/review-context.d.ts +14 -0
  75. package/dist/agent-runtime/review-context.js +41 -0
  76. package/dist/agent-runtime/review-context.js.map +1 -0
  77. package/dist/agent-runtime/role-routing.d.ts +10 -0
  78. package/dist/agent-runtime/role-routing.js +29 -0
  79. package/dist/agent-runtime/role-routing.js.map +1 -0
  80. package/dist/agent-runtime/role-state.d.ts +19 -0
  81. package/dist/agent-runtime/role-state.js +24 -0
  82. package/dist/agent-runtime/role-state.js.map +1 -0
  83. package/dist/agent-runtime/runtime-identity.d.ts +11 -0
  84. package/dist/agent-runtime/runtime-identity.js +33 -0
  85. package/dist/agent-runtime/runtime-identity.js.map +1 -0
  86. package/dist/agent-runtime/tool-event.d.ts +3 -0
  87. package/dist/agent-runtime/tool-event.js +24 -0
  88. package/dist/agent-runtime/tool-event.js.map +1 -0
  89. package/dist/agent-runtime/verification-plan.d.ts +55 -0
  90. package/dist/agent-runtime/verification-plan.js +206 -0
  91. package/dist/agent-runtime/verification-plan.js.map +1 -0
  92. package/dist/agent-runtime/workflow-types.d.ts +17 -1
  93. package/dist/agent-runtime/workflow.js +28 -1
  94. package/dist/agent-runtime/workflow.js.map +1 -1
  95. package/dist/agent-runtime/workspace-tools.d.ts +4 -0
  96. package/dist/agent-runtime/workspace-tools.js +182 -20
  97. package/dist/agent-runtime/workspace-tools.js.map +1 -1
  98. package/dist/installer/phases/scaffold.js +39 -109
  99. package/dist/installer/phases/scaffold.js.map +1 -1
  100. package/dist/installer/runtime/pipeline-state.d.ts +142 -1
  101. package/dist/installer/runtime/pipeline-state.js +477 -28
  102. package/dist/installer/runtime/pipeline-state.js.map +1 -1
  103. package/docs/agent-runtime-efficiency.md +65 -0
  104. package/docs/agent-runtime.md +86 -15
  105. package/integration-contract.json +2 -1
  106. package/package.json +5 -2
  107. package/schemas/agent-runtime.schema.json +25 -3
  108. package/schemas/fixtures/runtime-efficiency-summary.v1.json +790 -0
  109. package/templates/codex-skills/batch-implement/SKILL.md +33 -58
  110. package/templates/codex-skills/implement/SKILL.md +21 -124
  111. package/templates/codex-skills/retry/SKILL.md +8 -34
  112. package/templates/commands/specrails/batch-implement.md +21 -16
  113. package/templates/commands/specrails/implement.md +17 -276
  114. package/templates/commands/specrails/retry.md +6 -34
  115. package/templates/gemini-commands/batch-implement.toml +34 -28
  116. package/templates/gemini-commands/implement.toml +34 -55
  117. package/templates/gemini-commands/retry.toml +10 -16
@@ -1,63 +1,38 @@
1
1
  ---
2
2
  name: batch-implement
3
- description: "Implement the frozen batch in one OpenSpec change and journal, with aggregate verification, review and archive gates."
3
+ description: "Run or resume implementation through the installed programmatic agent runtime."
4
4
  license: MIT
5
- compatibility: "Codex-native root-level role delegation. One aggregate change per run; hosted worktrees stay under host ownership."
6
5
  ---
7
6
 
8
- You coordinate one batch run. Explicit #IDs retain their order; filters resolve
9
- against the shared backlog. Freeze the full ticket descriptions, acceptance criteria
10
- and repository IDs once. With host context use its complete specs unchanged.
11
-
12
- Initialize ONE stable aggregate change slug and journal for the batch. Do not
13
- initialize another change with the same runId or create child per-ticket journals.
14
- Resolve source via context.repositories, OpenSpec via context.artifactRoot, and
15
- backlog via context.backlogPath/backlogRoot; cwd can be an external workspace.
16
-
17
- Read the single implement role instructions, but execute the following aggregate
18
- pipeline DIRECTLY from this root. Do NOT spawn `$implement` as a sub-agent.
19
- Each role receives the explicit bounded handoff including ALL frozen specs and
20
- repository paths, aggregate change slug and already completed task groups.
21
-
22
- 1. Architect: one `$sr-architect` creates and validates one change covering every
23
- ticket, grouping tasks by ticket and repository and recording dependency order.
24
- Record architect running/done via the helper. Require high/medium design
25
- confidence. Missing or low confidence blocks development; never infer a pass.
26
- 2. Developer: one `$sr-developer` applies the task groups sequentially, preserving
27
- preceding groups and all repositories. Persist per-group progress in tasks.md
28
- before yielding. Scoped checks run per group; the full verification gate runs
29
- once for the aggregate candidate through the helper. Only then record developer
30
- done. Incomplete groups block downstream review and remain retriable.
31
- 3. Reviewer: one `$sr-reviewer` semantically checks every ticket/criterion and
32
- cross-ticket interaction. Include the full receipt and changed-file inventory.
33
- Ordinary review does NOT archive. If recoverable findings need changes, invoke
34
- developer once with the exact findings and re-review. Missing/ambiguous verdicts
35
- and stale receipts never become done; record blocked/failed with a next action.
36
- 4. Archive: after semantic reviewer done and canonical confidence thresholds from
37
- implement pass (including security), run `archive-check`. Only success permits
38
- `$sr-reviewer` with ARCHIVE_ONLY=true and ARCHIVE_AUTHORIZED=true. Validate the
39
- archive exists and active change is absent; record archive done. Failure leaves
40
- EVERY batch ticket open.
41
- 5. Delivery/CI: follow implement ownership exactly. Host-owned Git records ship/ci
42
- skipped and returns evidence; Core-owned authorized delivery records each selected
43
- repository outcome and required CI. Partial delivery keeps the batch incomplete.
44
- 6. Backlog: only Core-owned backlog may close participating tickets at
45
- context.backlogPath after required delivery and live-vs-frozen requirements match.
46
- Preserve unrelated data and revisions. Host-owned backlog stays untouched.
47
-
48
- Before any role, inspect status.resumePhase; reuse every still-valid phase without
49
- respawning. Use available worker capabilities and capability-aware cleanup from
50
- implement; never invent close_agent or native model override support.
51
-
52
- On a provider turn limit, continue the same role from explicit saved progress;
53
- never launch a nested coordinator or repeat valid earlier stages. Retry resumes
54
- this same aggregate change/journal. Two continuations without progress block.
55
-
56
- `--parallel` is a preference, not permission to create unmanaged worktrees or
57
- assume ten available agent slots. The aggregate pipeline is sequential by default;
58
- keep hosted worktrees in the supplied repositories. Do not claim parallel work
59
- when it did not run. Do not override models on a full-history fork.
60
-
61
- Report one table with every ticket and actual implemented/reviewed outcome, the
62
- aggregate verification receipt, archive result and outstanding groups. No ticket
63
- is done until the whole aggregate close succeeds.
7
+ # Programmatic implementation
8
+
9
+ Implement the requested spec or batch through the installed agent runtime. The runtime owns architecture, development, verification, review and archive; do not delegate these phases yourself or launch a second coordinator.
10
+
11
+ ## Freeze the requested scope
12
+
13
+ Use the supplied absolute `SPECRAILS_EXECUTION_CONTEXT` unchanged. It defines runId, specs and acceptance criteria, artifactRoot, selected repositories and ownership. For standalone use, admit the exact requested tickets once with:
14
+
15
+ ```sh
16
+ node .specrails/runtime/pipeline.mjs init --change <stable-change> --tickets "<requested-ids>"
17
+ ```
18
+
19
+ For a free-form request use `--scope-request <absolute-json>` with the user's specs and criteria. Use the returned absolute context path. Never select a different run by modification time or replace scope from mutable backlog. Multiple tickets share one aggregate context and one runtime invocation.
20
+
21
+ ## Execute
22
+
23
+ ```sh
24
+ node .specrails/runtime/agent-runtime.mjs run --context <absolute-context> --config .specrails/agent-runtime.json --change <stable-change>
25
+ ```
26
+
27
+ Desktop launches this runtime directly and freezes its resolved global connections and project settings. Standalone installations provide a local configuration. If required runtime/configuration files are missing, repair the Core installation; do not fall back to a prompt-orchestrated implementation.
28
+
29
+ Wait for the foreground process. Report its structured status, acceptance and verification evidence. A process failure or pause preserves progress; it does not authorize a replacement run. Resume only the exact saved execution:
30
+
31
+ ```sh
32
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
33
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
34
+ ```
35
+
36
+ Answers, approvals and recovery flags must correspond to the pending request and user authorization. Resume keeps the saved models, scope and configuration. Never manually rewrite phase receipts, bypass review, or treat provider prose as completion.
37
+
38
+ Honor the context's ownership throughout: Desktop owns worktrees, commits, PRs and backlog delivery. Runtime success prepares a reviewed candidate; host delivery remains a separate action. Preview requests must not invoke mutating execution.
@@ -1,141 +1,38 @@
1
1
  ---
2
2
  name: implement
3
- description: "Implement one frozen spec or route multiple specs to an aggregate pipeline, with resumable design, implementation, verification, review, archive and ownership-aware delivery."
3
+ description: "Run or resume implementation through the installed programmatic agent runtime."
4
4
  license: MIT
5
- compatibility: "Codex-native role delegation with explicit handoffs and the installed SpecRails pipeline runtime. Use only capabilities exposed by the host."
6
5
  ---
7
6
 
8
- You coordinate the implementation. Role skills supply design, coding and review
9
- instructions; the installed runtime supplies immutable scope, phase status and
10
- actual verification evidence. A completed valid phase needs no new model call.
7
+ # Programmatic implementation
11
8
 
12
- **Input:** `$implement #N`, `$implement #N --yes`, a free-form description, or
13
- multiple `#N` references. More than one ID routes directly to
14
- `.codex/skills/batch-implement/SKILL.md` with the original arguments and complete
15
- frozen context. Do not ask the user to resend or spawn a nested implement.
9
+ Implement the requested spec or batch through the installed agent runtime. The runtime owns architecture, development, verification, review and archive; do not delegate these phases yourself or launch a second coordinator.
16
10
 
17
- ## Admission and capabilities
11
+ ## Freeze the requested scope
18
12
 
19
- Follow the executable pipeline contract above. Initialize the one stable change
20
- with supplied context, explicit ticket IDs, or a free-form scope request; then
21
- read `status`. Do not initialize another run on retry or replace frozen requirements
22
- with live ticket text. OpenSpec lives under `context.artifactRoot`; the compatibility
23
- path `${SPECRAILS_REPO_DIR:-.}/openspec/changes/<slug>/` applies only after resolving
24
- that variable to artifactRoot. Source/tests use the selected repository ID/path;
25
- backlog uses `context.backlogPath`, independent of cwd.
13
+ Use the supplied absolute `SPECRAILS_EXECUTION_CONTEXT` unchanged. It defines runId, specs and acceptance criteria, artifactRoot, selected repositories and ownership. For standalone use, admit the exact requested tickets once with:
26
14
 
27
- Discover `.codex/skills/rails/` and require sr-architect, sr-developer and
28
- sr-reviewer. Validate any explicit profile (`SPECRAILS_PROFILE_PATH`, otherwise the
29
- project's configured default): schemaVersion 1, baseline trio, routing/default and
30
- referenced installed roles. Only installed custom-* roles may supplement or fulfill
31
- a routed task group; they do not bypass the canonical phase gates.
15
+ ```sh
16
+ node .specrails/runtime/pipeline.mjs init --change <stable-change> --tickets "<requested-ids>"
17
+ ```
32
18
 
33
- Use the host's actual `spawn_agent`, `send_message` and `wait_agent` signatures.
34
- Invoke required architect/developer/reviewer roles as real workers and collect their
35
- terminal outcomes. Full-history forks inherit the current model; do not pass model
36
- or reasoning overrides unsupported by that fork mode. Report unsupported profile
37
- model overrides honestly. Use `close_agent` only when that capability exists and
38
- only after the worker finished; never invent a cleanup tool or interrupt running
39
- work to simulate completion. Avoid parallel writers in shared candidate roots.
19
+ For a free-form request use `--scope-request <absolute-json>` with the user's specs and criteria. Use the returned absolute context path. Never select a different run by modification time or replace scope from mutable backlog. Multiple tickets share one aggregate context and one runtime invocation.
40
20
 
41
- Every worker receives its `$sr-*` skill and the explicit bounded handoff: runId,
42
- phase, absolute runtime/context paths, all frozen criteria, repository ownership,
43
- change/plan/tasks paths, prior outcome and next action. Do not rely on inherited
44
- conversation memory. A task start, turn limit or process exit alone is not success.
45
- Continue from durable progress; two continuations without progress become blocked.
21
+ ## Execute
46
22
 
47
- ## Durable phases
23
+ ```sh
24
+ node .specrails/runtime/agent-runtime.mjs run --context <absolute-context> --config .specrails/agent-runtime.json --change <stable-change>
25
+ ```
48
26
 
49
- `architect developer reviewer archive ship ci`
27
+ Desktop launches this runtime directly and freezes its resolved global connections and project settings. Standalone installations provide a local configuration. If required runtime/configuration files are missing, repair the Core installation; do not fall back to a prompt-orchestrated implementation.
50
28
 
51
- Follow `status.resumePhase`. Start required work with the helper's
52
- `phase --phase <phase> --status running`. Record done only after validating actual
53
- outcomes and runtime gates. Record blocked/failed with a concrete reason; dependent
54
- phases remain incomplete. Reopening a phase invalidates dependent completion.
55
- If every phase is valid, report existing completion without new worker calls.
29
+ Wait for the foreground process. Report its structured status, acceptance and verification evidence. A process failure or pause preserves progress; it does not authorize a replacement run. Resume only the exact saved execution:
56
30
 
57
- ### Architect
31
+ ```sh
32
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
33
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
34
+ ```
58
35
 
59
- Invoke `$sr-architect` with the exact slug and aggregate frozen scope. Use the
60
- installed official OpenSpec fast-forward workflow. Require proposal, design, specs,
61
- tasks and medium/high design-confidence.json. Missing/malformed/low confidence
62
- blocks development; record the unresolved issue and retain artifacts for retry.
63
- Do not edit a ticket and silently substitute the new description into this run.
64
- Changed requirements need a newly admitted scope.
36
+ Answers, approvals and recovery flags must correspond to the pending request and user authorization. Resume keeps the saved models, scope and configuration. Never manually rewrite phase receipts, bypass review, or treat provider prose as completion.
65
37
 
66
- ### Developer
67
-
68
- Invoke `$sr-developer` or the validated profile role for each task group. Keep
69
- source writes in its selected repositories, serialize dependencies/shared files,
70
- and persist real task progress. A BLOCKED outcome stops downstream phases.
71
- Scoped checks support development; once all groups are implemented, execute one
72
- full CI-equivalent check request through the installed helper. Derive actual checks
73
- from each selected repository and include required cross-repository integration.
74
- All tasks and current full evidence must pass before recording developer done.
75
-
76
- ### Reviewer and bounded repair
77
-
78
- Invoke `$sr-reviewer` with complete criteria, candidate inventory and current
79
- verification receipt. Ordinary review does not archive. Require explicit semantic
80
- acceptance, safe behavior and required regression coverage; green baseline tests
81
- with missing implementation are incomplete. Reuse unchanged full verification;
82
- review edits require one fresh final full request on the resulting candidate.
83
-
84
- Read canonical `<context.artifactRoot>/openspec/changes/<slug>/confidence-score.json`.
85
- Require overall ≥70, security ≥75 and every other aspect ≥60 (or stricter configured
86
- thresholds), all tasks complete and no unresolved explicit blocker. Missing or
87
- ambiguous verdicts/scores fail closed. A numeric score never converts a blocked
88
- security or design finding into clean acceptance.
89
-
90
- For concrete recoverable findings, reopen developer and invoke it once with those
91
- exact findings, then re-review and refresh evidence. An architectural blocker
92
- returns to architect; do not infer its category from a score range. If the one
93
- repair round does not resolve acceptance, preserve work and record blocked.
94
- Only then may the runtime record reviewer done.
95
-
96
- ### Archive
97
-
98
- Run `archive-check` immediately before archiving. Nonzero means stop. After success,
99
- invoke `$sr-reviewer` with ARCHIVE_ONLY=true and ARCHIVE_AUTHORIZED=true and the
100
- same explicit handoff, or run the installed official archive workflow directly
101
- as coordinator. Preserve approved confidence bytes; no rescoring or code changes.
102
- Confirm the exact active change is gone, its archive exists under
103
- `<context.artifactRoot>/openspec/changes/archive/<date>-<slug>/` and canonical specs
104
- synced before `phase --phase archive --status done`. Do not emulate an official
105
- archive with file moves or accept incomplete-task prompts. A failed archive remains
106
- resumable; it never closes specs or restarts valid development automatically.
107
-
108
- ### Delivery and CI
109
-
110
- For `context.ownership.git === "host"`, record ship and ci skipped with the ownership
111
- reason and return evidence to the host. Do not stage, commit, push or open PRs.
112
- For Core-owned git, perform only the delivery already authorized by user/settings,
113
- in each selected repository. `GIT_AUTO=false` and preview disable shipping even if
114
- Core owns git. Preserve unrelated changes; stage only the reviewed candidate.
115
- Record actual per-repository commits/PRs and required CI results before phase done.
116
- Partial delivery stays incomplete. CI retry checks existing delivery, without
117
- creating duplicate commits or PRs. No authorized delivery means a concrete blocker,
118
- not a fabricated successful ship phase.
119
-
120
- ### Backlog and report
121
-
122
- Host-owned backlog remains untouched. Core-owned backlog may close only after all
123
- required delivery succeeds, current evidence remains valid, and live participating
124
- ticket requirements still match frozen IDs/descriptions/criteria/repository scope.
125
- A mismatch leaves that ticket open and reports the conflict. Read/write only
126
- `context.backlogPath` (fallback context.backlogRoot/.specrails/local-tickets.json),
127
- preserve unrelated tickets/fields, and apply the store's revision protocol. Workers
128
- never close tickets. A free-form scope without a real ticket has no ticket mutation.
129
-
130
- Report run/change, frozen tickets/roots, reused and newly completed phases,
131
- verification commands, confidence, archive and each repository's actual delivery.
132
- Distinguish ready-for-host-delivery from delivered. Include concrete remaining
133
- blockers; no complete/done claim while a required gate or repository is incomplete.
134
-
135
- ## Preview and apply
136
-
137
- `--dry-run`/`--preview` uses the runtime preview contract and reports UNVERIFIED
138
- PREVIEW. Tests on untouched source are baseline evidence only. `--apply` resumes the
139
- exact existing preview journal, verifies unchanged base/cache and runs checks on
140
- actual applied source through `apply-preview`; continue the ordinary review,
141
- confidence and archive gates. Preview never grants shipping/backlog ownership.
38
+ Honor the context's ownership throughout: Desktop owns worktrees, commits, PRs and backlog delivery. Runtime success prepares a reviewed candidate; host delivery remains a separate action. Preview requests must not invoke mutating execution.
@@ -1,42 +1,16 @@
1
1
  ---
2
2
  name: retry
3
- description: "Resume the first invalid implement phase using the durable pipeline journal and explicit role handoffs."
3
+ description: "Run or resume implementation through the installed programmatic agent runtime."
4
4
  license: MIT
5
- compatibility: "Codex-native root-level role delegation; no nested implement or assumed provider conversation memory."
6
5
  ---
7
6
 
8
- You are the retry orchestrator. Accept `$retry #N`, `$retry <change>`, and `--yes`.
9
- Resolve `${SPECRAILS_REPO_DIR:-.}` only as the legacy source default; the installed
10
- pipeline helper and SPECRAILS_EXECUTION_CONTEXT provide the authoritative roots.
11
- Call `status` for the existing run/change. Report its completed phases and
12
- `resumePhase`. Do not search other projects or guess a change from a matching title.
13
- When there is no journal, report the missing run/context and require explicit new
14
- admission; do not silently initialize a replacement retry scope. Never erase existing
15
- code or use a checked task alone as proof of implementation.
7
+ # Resume a programmatic implementation
16
8
 
17
- Read `.codex/skills/implement/SKILL.md` as the phase definition; execute its remaining
18
- roles DIRECTLY from this root agent. Do not spawn `$implement` as a sub-agent.
19
- Use `spawn_agent`, `send_message` and `wait_agent` only for `$sr-architect`,
20
- `$sr-developer`, `$sr-reviewer` or explicitly configured installed custom roles.
21
- Preserve the configured provider model; do not pass model/reasoning_effort on
22
- full-history forks. Give every role the bounded explicit handoff from the shared
23
- contract, including unchanged frozen acceptance criteria and exact prior findings.
9
+ Resolve the exact saved context for the requested run. Do not initialize a replacement, guess the latest change, or discard work.
24
10
 
25
- - Architect resumes only if status says design is invalid/missing/blocked.
26
- - Developer resumes the first incomplete or stale task; do not repeat valid design.
27
- - Reviewer resumes semantic review with the actual candidate and verification
28
- receipts. If findings require code changes, record developer running and invoke
29
- developer with those exact findings, then reviewer again (at most one fix round).
30
- - Never assume a `MAX_TURNS` or successful process exit completed a phase. Save the
31
- checkpoint and invoke the same role with the pending work; two continuations
32
- without file/task/evidence progress stop as blocked with the outstanding action.
33
- - Archive uses `archive-check`, followed by reviewer archive-only authorization;
34
- missing/low confidence or stale checks never become success through retry.
35
- - Ship resumes only missing authorized Core-owned delivery; CI checks existing
36
- delivery without shipping again. Host-owned ship/ci record skipped; backlog and
37
- worktrees remain with their owner. Backlog closure also compares live requirements
38
- with frozen scope at context.backlogPath, as implement requires.
11
+ ```sh
12
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
13
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
14
+ ```
39
15
 
40
- Record each outcome with the helper. A blocked phase is resumable, never an
41
- intentionally skipped phase. Report the run, change, resumed roles, verification,
42
- archive outcome and any remaining blocker. No recursive retry loops.
16
+ Use the saved scope and configuration. Pass an answer, approval or recovery flag only for the corresponding pending request with user authorization. The runtime selects the next phase and preserves valid completed work; never invoke roles directly or edit phase receipts. Preserve host ownership of Git, worktrees and backlog. Report the structured result and outstanding delivery actions.
@@ -1,27 +1,32 @@
1
- # Batch Implement
1
+ # Programmatic implementation
2
2
 
3
- **Input:** $ARGUMENTS selected ticket references, dependency hints, --dry-run/--preview or existing aggregate change for retry.
3
+ Implement the requested spec or batch through the installed agent runtime. The runtime owns architecture, development, verification, review and archive; do not delegate these phases yourself or launch a second coordinator.
4
4
 
5
- ## One scope and one candidate
5
+ ## Freeze the requested scope
6
6
 
7
- Use implement's installed runtime and immutable execution context. Host context.specs[] is the batch; never replace it from another repository's backlog. Standalone init --change <aggregate-change> --tickets "17,18" freezes local entries once; freeform/multi-repo uses explicit scope request/context.
7
+ Use the supplied absolute `SPECRAILS_EXECUTION_CONTEXT` unchanged. It defines runId, specs and acceptance criteria, artifactRoot, selected repositories and ownership. For standalone use, admit the exact requested tickets once with:
8
8
 
9
- There is **one aggregate OpenSpec change and one journal**, not a full pipeline per ticket. Delegate to implement once with all frozen specs and selected roots. Architect, developer, reviewer, confidence, archive and delivery gates are mandatory and resumable.
9
+ ```sh
10
+ node .specrails/runtime/pipeline.mjs init --change <stable-change> --tickets "<requested-ids>"
11
+ ```
10
12
 
11
- ## Dependency plan
13
+ For a free-form request use `--scope-request <absolute-json>` with the user's specs and criteria. Use the returned absolute context path. Never select a different run by modification time or replace scope from mutable backlog. Multiple tickets share one aggregate context and one runtime invocation.
12
14
 
13
- 1. Validate dependency IDs against selected specs/completed external prerequisites; reject cycles or missing prerequisites.
14
- 2. One architect designs shared contracts and task groups labeled with ticket/repository ID. Cross-repository behavior belongs to the same acceptance matrix.
15
- 3. Execute dependency-ordered groups in supplied roots; serialize shared-file/contract changes. Profile routing selects appropriate roles; each handoff includes exact context/runtime paths.
16
- 4. Collect foreground terminal results. Task start or unsupported PASS is not completion.
17
- 5. Scoped tests support development; one full receipt covers the aggregate candidate and cross-repository integration. Reviewer reuses it unchanged; edits need a fresh final full pass.
15
+ ## Execute
18
16
 
19
- Never recursively launch implement for each wave, change the run identity, allocate nested worktrees, guess a main branch, merge copied file lists or delete supplied roots. Respect host/Core ownership from entry.
17
+ ```sh
18
+ node .specrails/runtime/agent-runtime.mjs run --context <absolute-context> --config .specrails/agent-runtime.json --change <stable-change>
19
+ ```
20
20
 
21
- ## Acceptance and completion
21
+ Desktop launches this runtime directly and freezes its resolved global connections and project settings. Standalone installations provide a local configuration. If required runtime/configuration files are missing, repair the Core installation; do not fall back to a prompt-orchestrated implementation.
22
22
 
23
- Review every ticket's criteria before canonical confidence. Runtime reviewer and archive approval gates precede official archive. Missing implementation/regressions, low confidence or one required failed repo keeps the batch incomplete; preserve per-ticket/repository retry progress.
23
+ Wait for the foreground process. Report its structured status, acceptance and verification evidence. A process failure or pause preserves progress; it does not authorize a replacement run. Resume only the exact saved execution:
24
24
 
25
- Preview remains unverified until runtime apply checks an unchanged base and executes checks on applied candidate. Retry resumes earliest invalid phase, preserving valid design and successful delivery.
25
+ ```sh
26
+ node .specrails/runtime/agent-runtime.mjs status --context <absolute-context>
27
+ node .specrails/runtime/agent-runtime.mjs resume --context <absolute-context>
28
+ ```
26
29
 
27
- Core-owned backlog may close only after complete delivery and matching current/frozen requirements. Host-owned backlog remains for host acceptance. Report partial outcomes and preserve reviewable work.
30
+ Answers, approvals and recovery flags must correspond to the pending request and user authorization. Resume keeps the saved models, scope and configuration. Never manually rewrite phase receipts, bypass review, or treat provider prose as completion.
31
+
32
+ Honor the context's ownership throughout: Desktop owns worktrees, commits, PRs and backlog delivery. Runtime success prepares a reviewed candidate; host delivery remains a separate action. Preview requests must not invoke mutating execution.