specrails-core 5.2.2 → 5.3.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 (102) hide show
  1. package/README.md +3 -0
  2. package/bin/specrails-core.mjs +5 -0
  3. package/dist/agent-runtime/cli-executor.d.ts +34 -0
  4. package/dist/agent-runtime/cli-executor.js +335 -0
  5. package/dist/agent-runtime/cli-executor.js.map +1 -0
  6. package/dist/agent-runtime/cli-process.d.ts +32 -0
  7. package/dist/agent-runtime/cli-process.js +159 -0
  8. package/dist/agent-runtime/cli-process.js.map +1 -0
  9. package/dist/agent-runtime/cli.d.ts +38 -0
  10. package/dist/agent-runtime/cli.js +168 -0
  11. package/dist/agent-runtime/cli.js.map +1 -0
  12. package/dist/agent-runtime/config.d.ts +7 -0
  13. package/dist/agent-runtime/config.js +162 -0
  14. package/dist/agent-runtime/config.js.map +1 -0
  15. package/dist/agent-runtime/core-host.d.ts +33 -0
  16. package/dist/agent-runtime/core-host.js +97 -0
  17. package/dist/agent-runtime/core-host.js.map +1 -0
  18. package/dist/agent-runtime/durable-store.d.ts +22 -0
  19. package/dist/agent-runtime/durable-store.js +205 -0
  20. package/dist/agent-runtime/durable-store.js.map +1 -0
  21. package/dist/agent-runtime/executor-types.d.ts +92 -0
  22. package/dist/agent-runtime/executor-types.js +29 -0
  23. package/dist/agent-runtime/executor-types.js.map +1 -0
  24. package/dist/agent-runtime/executors.d.ts +22 -0
  25. package/dist/agent-runtime/executors.js +44 -0
  26. package/dist/agent-runtime/executors.js.map +1 -0
  27. package/dist/agent-runtime/gemini-policy.d.ts +8 -0
  28. package/dist/agent-runtime/gemini-policy.js +36 -0
  29. package/dist/agent-runtime/gemini-policy.js.map +1 -0
  30. package/dist/agent-runtime/graph/artifacts.d.ts +40 -0
  31. package/dist/agent-runtime/graph/artifacts.js +179 -0
  32. package/dist/agent-runtime/graph/artifacts.js.map +1 -0
  33. package/dist/agent-runtime/graph/nodes.d.ts +36 -0
  34. package/dist/agent-runtime/graph/nodes.js +274 -0
  35. package/dist/agent-runtime/graph/nodes.js.map +1 -0
  36. package/dist/agent-runtime/graph/review-policy.d.ts +18 -0
  37. package/dist/agent-runtime/graph/review-policy.js +32 -0
  38. package/dist/agent-runtime/graph/review-policy.js.map +1 -0
  39. package/dist/agent-runtime/graph/roles.d.ts +44 -0
  40. package/dist/agent-runtime/graph/roles.js +126 -0
  41. package/dist/agent-runtime/graph/roles.js.map +1 -0
  42. package/dist/agent-runtime/graph/state.d.ts +75 -0
  43. package/dist/agent-runtime/graph/state.js +23 -0
  44. package/dist/agent-runtime/graph/state.js.map +1 -0
  45. package/dist/agent-runtime/graph-checkpointer.d.ts +61 -0
  46. package/dist/agent-runtime/graph-checkpointer.js +137 -0
  47. package/dist/agent-runtime/graph-checkpointer.js.map +1 -0
  48. package/dist/agent-runtime/index.d.ts +14 -0
  49. package/dist/agent-runtime/index.js +15 -0
  50. package/dist/agent-runtime/index.js.map +1 -0
  51. package/dist/agent-runtime/kimi-acp.d.ts +7 -0
  52. package/dist/agent-runtime/kimi-acp.js +179 -0
  53. package/dist/agent-runtime/kimi-acp.js.map +1 -0
  54. package/dist/agent-runtime/openai-executor.d.ts +18 -0
  55. package/dist/agent-runtime/openai-executor.js +174 -0
  56. package/dist/agent-runtime/openai-executor.js.map +1 -0
  57. package/dist/agent-runtime/prompts.d.ts +40 -0
  58. package/dist/agent-runtime/prompts.js +291 -0
  59. package/dist/agent-runtime/prompts.js.map +1 -0
  60. package/dist/agent-runtime/workflow-types.d.ts +210 -0
  61. package/dist/agent-runtime/workflow-types.js +2 -0
  62. package/dist/agent-runtime/workflow-types.js.map +1 -0
  63. package/dist/agent-runtime/workflow.d.ts +17 -0
  64. package/dist/agent-runtime/workflow.js +609 -0
  65. package/dist/agent-runtime/workflow.js.map +1 -0
  66. package/dist/agent-runtime/workspace-tools.d.ts +25 -0
  67. package/dist/agent-runtime/workspace-tools.js +120 -0
  68. package/dist/agent-runtime/workspace-tools.js.map +1 -0
  69. package/dist/installer/cli.d.ts +35 -0
  70. package/dist/installer/cli.js +3 -0
  71. package/dist/installer/cli.js.map +1 -1
  72. package/dist/installer/commands/doctor.d.ts +27 -0
  73. package/dist/installer/commands/framework.d.ts +85 -0
  74. package/dist/installer/commands/init.d.ts +147 -0
  75. package/dist/installer/commands/update.d.ts +56 -0
  76. package/dist/installer/commands/v5-migration.d.ts +32 -0
  77. package/dist/installer/phases/framework-lifecycle.d.ts +53 -0
  78. package/dist/installer/phases/install-config.d.ts +64 -0
  79. package/dist/installer/phases/manifest.d.ts +45 -0
  80. package/dist/installer/phases/prereqs.d.ts +51 -0
  81. package/dist/installer/phases/provider-detect.d.ts +89 -0
  82. package/dist/installer/phases/scaffold.d.ts +211 -0
  83. package/dist/installer/runtime/kimi.d.ts +84 -0
  84. package/dist/installer/runtime/pipeline-state.d.ts +210 -0
  85. package/dist/installer/runtime/pipeline-state.js +107 -38
  86. package/dist/installer/runtime/pipeline-state.js.map +1 -1
  87. package/dist/installer/util/errors.d.ts +46 -0
  88. package/dist/installer/util/exec.d.ts +41 -0
  89. package/dist/installer/util/fs.d.ts +153 -0
  90. package/dist/installer/util/git.d.ts +44 -0
  91. package/dist/installer/util/install-transaction.d.ts +29 -0
  92. package/dist/installer/util/logger.d.ts +31 -0
  93. package/dist/installer/util/paths.d.ts +34 -0
  94. package/dist/installer/util/prompts.d.ts +23 -0
  95. package/dist/installer/util/registry.d.ts +174 -0
  96. package/dist/installer/util/template.d.ts +23 -0
  97. package/docs/README.md +1 -0
  98. package/docs/agent-runtime.md +268 -0
  99. package/integration-contract.json +79 -7
  100. package/package.json +16 -1
  101. package/schemas/agent-runtime.schema.json +55 -0
  102. package/templates/runtime/provider-pipeline.md +16 -0
@@ -147,14 +147,14 @@
147
147
  "file": ".specrails/install-config.yaml",
148
148
  "version": 1,
149
149
  "fields": {
150
- "version": "number \u2014 schema version, currently 1",
151
- "provider": "string \u2014 claude | codex | gemini | kimi",
150
+ "version": "number schema version, currently 1",
151
+ "provider": "string claude | codex | gemini | kimi",
152
152
  "tier": "Deprecated legacy string, tolerated and ignored; all installs use deterministic placement.",
153
- "agents.selected": "string[] \u2014 unique lowercase kebab-case agent ids to install (1-64 characters)",
154
- "agents.excluded": "string[] \u2014 unique lowercase kebab-case agent ids to skip; must not overlap agents.selected",
155
- "models.preset": "string \u2014 balanced | budget | max; resolved within the selected provider catalog",
156
- "models.defaults.model": "string \u2014 exact provider model id or configured alias (overrides preset; Kimi: 1-128 characters matching [A-Za-z0-9][A-Za-z0-9._/:-]*; default: k3)",
157
- "models.overrides": "Record<safe-agent-id, string> \u2014 exact per-agent provider model ids or configured aliases with the same provider-specific validation (highest priority)"
153
+ "agents.selected": "string[] unique lowercase kebab-case agent ids to install (1-64 characters)",
154
+ "agents.excluded": "string[] unique lowercase kebab-case agent ids to skip; must not overlap agents.selected",
155
+ "models.preset": "string balanced | budget | max; resolved within the selected provider catalog",
156
+ "models.defaults.model": "string exact provider model id or configured alias (overrides preset; Kimi: 1-128 characters matching [A-Za-z0-9][A-Za-z0-9._/:-]*; default: k3)",
157
+ "models.overrides": "Record<safe-agent-id, string> exact per-agent provider model ids or configured aliases with the same provider-specific validation (highest priority)"
158
158
  }
159
159
  },
160
160
  "checkpoints": {
@@ -249,6 +249,78 @@
249
249
  "--lite"
250
250
  ]
251
251
  },
252
+ "agentRuntime": {
253
+ "apiVersion": 1,
254
+ "configSchemaVersion": 1,
255
+ "workflowStateSchemaVersion": 2,
256
+ "checkpointEnvelopeFormat": 2,
257
+ "checkpointEnvelope": "checkpoint.json holds {format: 2, checksum, state, graph}: the host ledger (state) and the LangGraph checkpoint history (graph) written atomically together",
258
+ "moduleExport": "specrails-core/agent-runtime",
259
+ "modulePath": "dist/agent-runtime/index.js",
260
+ "typesPath": "dist/agent-runtime/index.d.ts",
261
+ "cliPath": "dist/agent-runtime/cli.js",
262
+ "cliCommand": "runtime",
263
+ "cliOperations": [
264
+ "api",
265
+ "validate",
266
+ "run",
267
+ "status",
268
+ "resume"
269
+ ],
270
+ "apiOperation": "runtime api emits {type: runtime-api, apiVersion, coreVersion}; does not invoke providers",
271
+ "validationTransport": "runtime validate --stdin accepts UTF-8 configuration JSON up to 2 MiB, mutually exclusive with --config",
272
+ "compactStatus": "runtime status --compact omits workflow history, events and outputs, frozen pipeline context and verification command output; retains identities (runId, traceId), phase statuses and visits, pendingApproval, pendingQuestion, usage, completion, acceptance summary and verification metadata",
273
+ "interrupts": "A paused run (exit 2) carries pendingApproval (resume --approve <step>) or pendingQuestion (resume --answer <text>, nonempty, at most 20000 characters); the architect asks only after one autonomous investigation pass unless architect.onLowConfidence is proceed",
274
+ "eventStream": "run/resume emit JSON lines typed workflow-event, agent-event, verification-output, span ({traceId, spanId, name, stepId, attempt, visit, startedAt, endedAt, status, usage?, error?}) and a final runtime-result",
275
+ "reviewGate": "review.minScore and review.aspects may only tighten Core's own gate (minScore 70, security 75, other aspects 60); the pipeline journal enforces the floor",
276
+ "acceptance": "The reviewer certifies every frozen acceptance criterion by specId and criterionIndex; Core records the verification commands it ran as required checks and binds the report to the exact candidate before the reviewer verdict",
277
+ "configSchemaPath": "schemas/agent-runtime.schema.json",
278
+ "configSchemaExport": "specrails-core/schemas/agent-runtime.schema.json",
279
+ "projectConfigPath": ".specrails/agent-runtime.json",
280
+ "minimumNode": "20.19.0",
281
+ "platforms": [
282
+ "darwin",
283
+ "win32"
284
+ ],
285
+ "cliProviders": [
286
+ "claude",
287
+ "codex",
288
+ "gemini",
289
+ "kimi"
290
+ ],
291
+ "providerKinds": [
292
+ "cli",
293
+ "openai-compatible"
294
+ ],
295
+ "programmaticRegistration": "ExecutorRegistry.register(id, executor); custom executors implement AgentExecutor.execute(request)",
296
+ "phases": [
297
+ "architect",
298
+ "developer",
299
+ "verify",
300
+ "reviewer",
301
+ "archive"
302
+ ],
303
+ "contextSchema": "execution.context; ownership.git must be host",
304
+ "statePath": "<backlogRoot>/.specrails/pipeline/<runId>/agent-workflow/<runId>/checkpoint.json",
305
+ "requestPath": "<backlogRoot>/.specrails/pipeline/<runId>/agent-runtime-request.json",
306
+ "exitCodes": {
307
+ "succeeded": 0,
308
+ "paused": 2,
309
+ "failedBlockedOrCancelled": 1
310
+ },
311
+ "recovery": "Explicit resume uses frozen configuration and revalidates Core evidence; interrupted writes require named recovery; grants persist until evidence invalidation.",
312
+ "delivery": "Core implements through archive; the host owns worktrees, commits, pushes, PRs and backlog delivery. A standalone continuation does not restart Desktop delivery.",
313
+ "specificationFormat": "Architect specs contain complete main-spec replacements, including unchanged requirements; archive does not merge partial delta snippets.",
314
+ "compatibility": "Additive to integration schema 4 and execution context schema 1. Legacy workflows and profile v1 remain supported. Hosts must check RUNTIME_API_VERSION, not infer runtime support from Core major version.",
315
+ "documentation": "docs/agent-runtime.md",
316
+ "instructionsVersion": "3",
317
+ "workflowVersion": "3",
318
+ "developerTools": "The developer role runs with each CLI's autonomous edit+shell mode (claude --tools default --dangerously-skip-permissions with Agent/Task/Skill disallowed; codex workspace-write; gemini --yolo; kimi print mode). Architect and reviewer stay read-only. Claude roles load project settings only (--setting-sources project,local).",
319
+ "verificationPolicy": "Configured commands are optional. The architect proposes commands for repositories without one; repositories with no automated check are admitted and recorded in the receipt as unverifiedRepositories. Unchecked tasks return to the developer as feedback instead of failing the run.",
320
+ "sessionReuse": "Developer correction passes resume the previous provider session (claude --resume, codex exec resume, gemini --resume, kimi --session) with a short correction prompt; an unavailable session falls back to a fresh full turn. Structured roles get one repair turn in-session when their JSON is unusable.",
321
+ "structuredOutput": "Claude receives --json-schema and Codex --output-schema for architect/reviewer replies; other providers are parsed leniently.",
322
+ "resumeBudget": "An explicit resume resets the transition ceiling and grants the developer a fresh maxAttempts budget."
323
+ },
252
324
  "execution": {
253
325
  "schemaVersion": 1,
254
326
  "contextEnv": "SPECRAILS_EXECUTION_CONTEXT",
package/package.json CHANGED
@@ -1,8 +1,18 @@
1
1
  {
2
2
  "name": "specrails-core",
3
- "version": "5.2.2",
3
+ "version": "5.3.0",
4
4
  "description": "Provider-independent AI agent workflow system for Claude Code, Codex, Gemini CLI, and Kimi Code",
5
5
  "type": "module",
6
+ "exports": {
7
+ "./agent-runtime": {
8
+ "types": "./dist/agent-runtime/index.d.ts",
9
+ "import": "./dist/agent-runtime/index.js",
10
+ "default": "./dist/agent-runtime/index.js"
11
+ },
12
+ "./package.json": "./package.json",
13
+ "./integration-contract.json": "./integration-contract.json",
14
+ "./schemas/agent-runtime.schema.json": "./schemas/agent-runtime.schema.json"
15
+ },
6
16
  "bin": {
7
17
  "specrails-core": "bin/specrails-core.mjs"
8
18
  },
@@ -68,11 +78,16 @@
68
78
  },
69
79
  "dependencies": {
70
80
  "@inquirer/prompts": "^7.0.0",
81
+ "@langchain/core": "1.2.10",
82
+ "@langchain/langgraph": "1.4.14",
83
+ "@langchain/langgraph-checkpoint": "1.1.5",
71
84
  "ajv": "^8.18.0",
85
+ "cross-spawn": "7.0.6",
72
86
  "js-yaml": "^4.1.0",
73
87
  "picocolors": "^1.1.1"
74
88
  },
75
89
  "devDependencies": {
90
+ "@types/cross-spawn": "6.0.6",
76
91
  "@types/js-yaml": "^4.0.9",
77
92
  "@types/node": "^22.10.2",
78
93
  "@vitest/coverage-v8": "^4.1.5",
@@ -0,0 +1,55 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://specrails.dev/schemas/agent-runtime.schema.json",
4
+ "title": "Specrails programmatic agent runtime",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "enabled", "providers", "agents", "verification"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 1 },
10
+ "enabled": { "type": "boolean" },
11
+ "providers": { "type": "array", "items": { "oneOf": [
12
+ { "type": "object", "additionalProperties": false, "required": ["id", "kind", "cli"], "properties": {
13
+ "id": { "$ref": "#/definitions/id" }, "kind": { "const": "cli" }, "cli": { "enum": ["claude", "codex", "gemini", "kimi"] }
14
+ } },
15
+ { "type": "object", "additionalProperties": false, "required": ["id", "kind", "baseUrl"], "properties": {
16
+ "id": { "$ref": "#/definitions/id" }, "kind": { "const": "openai-compatible" },
17
+ "baseUrl": { "type": "string", "pattern": "^https?://[^/?#@]+(?:/[^?#]*)?$" },
18
+ "apiKeyEnv": { "type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" }
19
+ } }
20
+ ] } },
21
+ "agents": { "type": "object", "additionalProperties": false, "required": ["architect", "developer", "reviewer"], "properties": {
22
+ "architect": { "$ref": "#/definitions/agent" }, "developer": { "$ref": "#/definitions/agent" }, "reviewer": { "$ref": "#/definitions/agent" }
23
+ } },
24
+ "limits": { "type": "object", "additionalProperties": false, "properties": {
25
+ "maxAttempts": { "$ref": "#/definitions/positiveInteger" }, "maxTokens": { "$ref": "#/definitions/positiveInteger" },
26
+ "maxCostUsd": { "type": "number", "exclusiveMinimum": 0 }, "timeoutMs": { "$ref": "#/definitions/positiveInteger" }
27
+ } },
28
+ "verification": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["repositoryId", "command", "args"], "properties": {
29
+ "repositoryId": { "$ref": "#/definitions/id" }, "command": { "type": "string", "minLength": 1 },
30
+ "args": { "type": "array", "items": { "type": "string" } }, "cwd": { "type": "string", "minLength": 1 },
31
+ "env": { "type": "object", "propertyNames": { "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" }, "additionalProperties": { "type": "string" } },
32
+ "timeoutMs": { "$ref": "#/definitions/positiveInteger" }
33
+ } } },
34
+ "approvalBeforeArchive": { "type": "boolean" },
35
+ "review": { "type": "object", "additionalProperties": false, "description": "Review gate thresholds; unset fields keep Core's defaults (score 70, security 75, other aspects 60).", "properties": {
36
+ "minScore": { "$ref": "#/definitions/score" },
37
+ "aspects": { "type": "object", "additionalProperties": false, "properties": {
38
+ "type_correctness": { "$ref": "#/definitions/score" }, "pattern_adherence": { "$ref": "#/definitions/score" }, "test_coverage": { "$ref": "#/definitions/score" },
39
+ "security": { "$ref": "#/definitions/score" }, "architectural_alignment": { "$ref": "#/definitions/score" }
40
+ } }
41
+ } },
42
+ "architect": { "type": "object", "additionalProperties": false, "properties": {
43
+ "onLowConfidence": { "enum": ["ask", "proceed"], "description": "After one autonomous investigation pass, a still-low design either pauses with its question (ask, default) or proceeds on stated assumptions (proceed)." }
44
+ } }
45
+ },
46
+ "definitions": {
47
+ "id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$" },
48
+ "positiveInteger": { "type": "integer", "minimum": 1 },
49
+ "score": { "type": "number", "minimum": 0, "maximum": 100 },
50
+ "agent": { "type": "object", "additionalProperties": false, "required": ["provider"], "properties": {
51
+ "provider": { "$ref": "#/definitions/id" }, "model": { "type": "string", "minLength": 1, "maxLength": 256, "pattern": "^[^-\\r\\n\\u0000][^\\r\\n\\u0000]*$" },
52
+ "maxTurns": { "$ref": "#/definitions/positiveInteger" }
53
+ } }
54
+ }
55
+ }
@@ -48,6 +48,22 @@ Run verification through `verify --request <absolute-json-file>` with
48
48
  `{kind:"full"|"scoped",commands:[{repositoryId,command,args,cwd?,env?}]}`. The helper
49
49
  records actual exits and candidate fingerprints. Reuse only a current valid full
50
50
  receipt reported by `status`; semantic acceptance review remains mandatory.
51
+ Checks run without the runtime's known agent session/launcher metadata. Changing
52
+ that metadata between developer, reviewer and host does not invalidate a receipt.
53
+ Application inputs (including PATH, NODE_OPTIONS, npm configuration and custom
54
+ variables) remain verified. If a check needs session metadata as an input, declare
55
+ it explicitly in the command's `env`; the override is bound without storing its
56
+ value. Older environment-policy receipts require one fresh full verification;
57
+ never edit a receipt to make it current. Keep notes and temporary verification
58
+ requests under `stateDir`, outside the candidate source tree.
59
+ For an environment mismatch, retain the runtime's added/removed key names in
60
+ the failure report; values are deliberately not printed. When only recorded
61
+ values differ, the aggregate hash cannot identify the individual variable.
62
+ Do not work around recurring handoff failures by repeatedly refreshing the same
63
+ checks until one process accepts them; report the mismatch for diagnosis.
64
+ Automatic untracked files under known provider `agent-memory/` directories are
65
+ runtime notes, not candidate inputs. Tracked memory, provider settings and skills
66
+ remain candidate inputs and changing them requires fresh verification.
51
67
  Missing/low design confidence, unchecked tasks, missing/failed review and stale
52
68
  verification block success. Record reviewer done after semantic review, then run
53
69
  `archive-check`. ONLY a successful gate authorizes reviewer archive-only execution.