forgeos 0.1.0-alpha.1 → 0.1.0-alpha.11

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 (245) hide show
  1. package/AGENTS.md +38 -3
  2. package/CHANGELOG.md +105 -0
  3. package/README.md +75 -13
  4. package/adapters/go/README.md +23 -0
  5. package/adapters/go/go.mod +3 -0
  6. package/adapters/go/http.go +149 -0
  7. package/adapters/go/registry.go +234 -0
  8. package/adapters/go/types.go +136 -0
  9. package/bin/forge.mjs +22 -3
  10. package/docs/changelog.md +127 -0
  11. package/docs/forge-protocol.md +156 -0
  12. package/examples/go-billing/go.mod +7 -0
  13. package/examples/go-billing/main.go +120 -0
  14. package/package.json +16 -7
  15. package/schemas/forge-manifest.schema.json +57 -0
  16. package/src/forge/_generated/actionSubscriptions.json +1 -2
  17. package/src/forge/_generated/actionSubscriptions.ts +3 -3
  18. package/src/forge/_generated/agentAdapterManifest.json +1 -2
  19. package/src/forge/_generated/agentAdapterManifest.ts +3 -3
  20. package/src/forge/_generated/agentContract.json +1 -2
  21. package/src/forge/_generated/agentContract.ts +186 -50
  22. package/src/forge/_generated/agentQuickstart.md +3 -1
  23. package/src/forge/_generated/agentTools.json +1 -0
  24. package/src/forge/_generated/agentTools.md +16 -0
  25. package/src/forge/_generated/agentTools.ts +12 -0
  26. package/src/forge/_generated/aiContext.ts +67 -1
  27. package/src/forge/_generated/aiModels.json +1 -2
  28. package/src/forge/_generated/aiModels.ts +17 -1
  29. package/src/forge/_generated/aiProviders.json +0 -1
  30. package/src/forge/_generated/aiProviders.ts +1 -1
  31. package/src/forge/_generated/aiRegistry.json +1 -2
  32. package/src/forge/_generated/aiRegistry.ts +7 -5
  33. package/src/forge/_generated/api.json +1 -2
  34. package/src/forge/_generated/api.ts +7 -2
  35. package/src/forge/_generated/appGraph.json +1 -2
  36. package/src/forge/_generated/appGraph.ts +1327 -643
  37. package/src/forge/_generated/appMap.md +21 -1
  38. package/src/forge/_generated/artifactManifest.json +1 -2
  39. package/src/forge/_generated/artifactManifest.ts +2 -2
  40. package/src/forge/_generated/authClaims.json +0 -1
  41. package/src/forge/_generated/authClaims.ts +1 -1
  42. package/src/forge/_generated/authConfig.json +0 -1
  43. package/src/forge/_generated/authConfig.ts +1 -1
  44. package/src/forge/_generated/authContext.ts +1 -1
  45. package/src/forge/_generated/authRegistry.json +0 -1
  46. package/src/forge/_generated/authRegistry.ts +1 -1
  47. package/src/forge/_generated/buildInfo.json +1 -2
  48. package/src/forge/_generated/buildInfo.ts +4 -4
  49. package/src/forge/_generated/capabilityMap.json +1 -2
  50. package/src/forge/_generated/capabilityMap.md +1 -1
  51. package/src/forge/_generated/capabilityMap.ts +2 -2
  52. package/src/forge/_generated/client.ts +88 -1
  53. package/src/forge/_generated/clientApi.ts +2 -1
  54. package/src/forge/_generated/clientManifest.json +1 -2
  55. package/src/forge/_generated/clientManifest.ts +6 -4
  56. package/src/forge/_generated/clientTypes.ts +19 -1
  57. package/src/forge/_generated/configRegistry.json +0 -1
  58. package/src/forge/_generated/configRegistry.ts +1 -1
  59. package/src/forge/_generated/dataGraph.json +1 -2
  60. package/src/forge/_generated/dataGraph.ts +3 -3
  61. package/src/forge/_generated/db.json +0 -1
  62. package/src/forge/_generated/db.ts +1 -1
  63. package/src/forge/_generated/dbSecurityManifest.json +0 -1
  64. package/src/forge/_generated/dbSecurityManifest.ts +1 -1
  65. package/src/forge/_generated/dbSessionContext.json +0 -1
  66. package/src/forge/_generated/dbSessionContext.ts +1 -1
  67. package/src/forge/_generated/deployManifest.json +1 -2
  68. package/src/forge/_generated/deployManifest.ts +7 -7
  69. package/src/forge/_generated/devManifest.json +1 -2
  70. package/src/forge/_generated/devManifest.ts +18 -3
  71. package/src/forge/_generated/envSchema.json +0 -1
  72. package/src/forge/_generated/envSchema.ts +1 -1
  73. package/src/forge/_generated/externalServices.json +1 -0
  74. package/src/forge/_generated/externalServices.ts +9 -0
  75. package/src/forge/_generated/frontendGraph.json +0 -1
  76. package/src/forge/_generated/frontendGraph.ts +1 -1
  77. package/src/forge/_generated/importGuards.json +0 -1
  78. package/src/forge/_generated/importGuards.ts +1 -1
  79. package/src/forge/_generated/index.ts +3 -1
  80. package/src/forge/_generated/liveProductionManifest.json +0 -1
  81. package/src/forge/_generated/liveProductionManifest.ts +1 -1
  82. package/src/forge/_generated/liveProtocol.json +0 -1
  83. package/src/forge/_generated/liveProtocol.ts +1 -1
  84. package/src/forge/_generated/liveQueryRegistry.json +1 -2
  85. package/src/forge/_generated/liveQueryRegistry.ts +3 -3
  86. package/src/forge/_generated/liveTransportConfig.json +0 -1
  87. package/src/forge/_generated/liveTransportConfig.ts +1 -1
  88. package/src/forge/_generated/makeRegistry.json +1 -2
  89. package/src/forge/_generated/makeRegistry.ts +16 -2
  90. package/src/forge/_generated/makeTemplates.json +1 -2
  91. package/src/forge/_generated/makeTemplates.ts +6 -1
  92. package/src/forge/_generated/mockMap.json +0 -1
  93. package/src/forge/_generated/mockMap.ts +1 -1
  94. package/src/forge/_generated/operationPlaybooks.md +34 -14
  95. package/src/forge/_generated/packageGraph.json +1 -2
  96. package/src/forge/_generated/packageGraph.ts +8808 -4723
  97. package/src/forge/_generated/packageUpgradeRegistry.json +1 -2
  98. package/src/forge/_generated/packageUpgradeRegistry.ts +2 -2
  99. package/src/forge/_generated/permissionMatrix.json +1 -2
  100. package/src/forge/_generated/permissionMatrix.ts +3 -3
  101. package/src/forge/_generated/policyRegistry.json +1 -2
  102. package/src/forge/_generated/policyRegistry.ts +3 -3
  103. package/src/forge/_generated/queryRegistry.json +1 -2
  104. package/src/forge/_generated/queryRegistry.ts +3 -3
  105. package/src/forge/_generated/react.d.ts +1 -1
  106. package/src/forge/_generated/react.ts +1 -1
  107. package/src/forge/_generated/reactManifest.json +1 -2
  108. package/src/forge/_generated/reactManifest.ts +3 -3
  109. package/src/forge/_generated/releaseManifest.json +1 -2
  110. package/src/forge/_generated/releaseManifest.ts +3 -3
  111. package/src/forge/_generated/rlsPolicies.json +0 -1
  112. package/src/forge/_generated/rlsPolicies.sql +1 -1
  113. package/src/forge/_generated/rlsPolicies.ts +1 -1
  114. package/src/forge/_generated/runtimeGraph.json +1 -2
  115. package/src/forge/_generated/runtimeGraph.ts +3 -3
  116. package/src/forge/_generated/runtimeMatrix.json +1 -2
  117. package/src/forge/_generated/runtimeMatrix.ts +8684 -1939
  118. package/src/forge/_generated/runtimeRegistry.ts +1 -1
  119. package/src/forge/_generated/runtimeRules.md +13 -1
  120. package/src/forge/_generated/secretRegistry.json +0 -1
  121. package/src/forge/_generated/secretRegistry.ts +1 -1
  122. package/src/forge/_generated/secretsContext.ts +1 -1
  123. package/src/forge/_generated/serverApi.ts +2 -1
  124. package/src/forge/_generated/sourceMapManifest.json +1 -2
  125. package/src/forge/_generated/sourceMapManifest.ts +2 -2
  126. package/src/forge/_generated/sqlPlan.json +0 -1
  127. package/src/forge/_generated/sqlPlan.ts +1 -1
  128. package/src/forge/_generated/subscriptionManifest.json +1 -2
  129. package/src/forge/_generated/subscriptionManifest.ts +3 -3
  130. package/src/forge/_generated/symbolicationManifest.json +1 -2
  131. package/src/forge/_generated/symbolicationManifest.ts +2 -2
  132. package/src/forge/_generated/telemetryRegistry.json +1 -2
  133. package/src/forge/_generated/telemetryRegistry.ts +3 -3
  134. package/src/forge/_generated/telemetrySinks.json +1 -2
  135. package/src/forge/_generated/telemetrySinks.ts +2 -2
  136. package/src/forge/_generated/tenantScope.json +1 -2
  137. package/src/forge/_generated/tenantScope.ts +3 -3
  138. package/src/forge/_generated/testGraph.json +1 -2
  139. package/src/forge/_generated/testGraph.ts +789 -65
  140. package/src/forge/_generated/testPlanRegistry.json +1 -2
  141. package/src/forge/_generated/testPlanRegistry.ts +2 -2
  142. package/src/forge/_generated/uiRoutes.json +0 -1
  143. package/src/forge/_generated/uiRoutes.ts +1 -1
  144. package/src/forge/_generated/uiScenarios.json +0 -1
  145. package/src/forge/_generated/uiScenarios.ts +1 -1
  146. package/src/forge/_generated/uiTestManifest.json +1 -2
  147. package/src/forge/_generated/uiTestManifest.ts +2 -2
  148. package/src/forge/_generated/workflowRegistry.json +1 -2
  149. package/src/forge/_generated/workflowRegistry.ts +3 -3
  150. package/src/forge/_generated/workflowSubscriptions.json +1 -2
  151. package/src/forge/_generated/workflowSubscriptions.ts +3 -3
  152. package/src/forge/bench.ts +248 -0
  153. package/src/forge/cli/ai.ts +671 -3
  154. package/src/forge/cli/auth.ts +36 -1
  155. package/src/forge/cli/build.ts +1 -1
  156. package/src/forge/cli/commands.ts +153 -0
  157. package/src/forge/cli/dev.ts +46 -16
  158. package/src/forge/cli/main.ts +4 -1
  159. package/src/forge/cli/new.ts +29 -1
  160. package/src/forge/cli/output.ts +14 -0
  161. package/src/forge/cli/parse.ts +213 -13
  162. package/src/forge/cli/query.ts +32 -0
  163. package/src/forge/cli/rls.ts +568 -17
  164. package/src/forge/cli/run.ts +41 -0
  165. package/src/forge/cli/secrets.ts +46 -1
  166. package/src/forge/cli/security.ts +381 -0
  167. package/src/forge/cli/verify.ts +893 -27
  168. package/src/forge/compiler/agent-contract/build.ts +407 -12
  169. package/src/forge/compiler/agent-contract/types.ts +72 -0
  170. package/src/forge/compiler/ai-registry/build.ts +62 -1
  171. package/src/forge/compiler/ai-registry/constants.ts +1 -1
  172. package/src/forge/compiler/ai-registry/parse.ts +98 -4
  173. package/src/forge/compiler/api-surface/build.ts +47 -0
  174. package/src/forge/compiler/app-graph/build.ts +33 -5
  175. package/src/forge/compiler/app-graph/forge-apis.ts +1 -0
  176. package/src/forge/compiler/app-graph/module-graph.ts +73 -78
  177. package/src/forge/compiler/app-graph/parser.ts +24 -24
  178. package/src/forge/compiler/app-graph/profile.ts +26 -0
  179. package/src/forge/compiler/classifier/capabilities.ts +3 -2
  180. package/src/forge/compiler/classifier/classify.ts +32 -8
  181. package/src/forge/compiler/classifier/secrets.ts +3 -2
  182. package/src/forge/compiler/classifier/signals.ts +91 -1
  183. package/src/forge/compiler/client-sdk/build-manifest.ts +4 -0
  184. package/src/forge/compiler/client-sdk/render-client.ts +105 -0
  185. package/src/forge/compiler/dev-manifest/build.ts +3 -0
  186. package/src/forge/compiler/diagnostics/codes.ts +27 -0
  187. package/src/forge/compiler/diagnostics/create.ts +1 -1
  188. package/src/forge/compiler/emitter/render.ts +5 -0
  189. package/src/forge/compiler/external-manifest/registry.ts +204 -0
  190. package/src/forge/compiler/external-manifest/types.ts +89 -0
  191. package/src/forge/compiler/external-manifest/validate.ts +335 -0
  192. package/src/forge/compiler/make-registry/build.ts +13 -0
  193. package/src/forge/compiler/orchestrator/plan-profile.ts +23 -0
  194. package/src/forge/compiler/orchestrator/plan.ts +63 -11
  195. package/src/forge/compiler/orchestrator/profile.ts +65 -0
  196. package/src/forge/compiler/orchestrator/run.ts +97 -31
  197. package/src/forge/compiler/orchestrator/serialize.ts +81 -6
  198. package/src/forge/compiler/package-graph/compiler.ts +13 -3
  199. package/src/forge/compiler/policy-registry/build.ts +44 -1
  200. package/src/forge/compiler/test-graph/build.ts +11 -3
  201. package/src/forge/compiler/types/ai-registry.ts +25 -1
  202. package/src/forge/compiler/types/app-graph.ts +1 -0
  203. package/src/forge/compiler/types/cli.ts +46 -0
  204. package/src/forge/compiler/types/dev-manifest.ts +3 -0
  205. package/src/forge/dev/server.ts +592 -3
  206. package/src/forge/dev/types.ts +1 -1
  207. package/src/forge/make/index.ts +126 -3
  208. package/src/forge/make/templates.ts +190 -2
  209. package/src/forge/make/types.ts +1 -0
  210. package/src/forge/refactor/index.ts +1 -0
  211. package/src/forge/runtime/ai/context.ts +210 -5
  212. package/src/forge/runtime/ai/types.ts +70 -0
  213. package/src/forge/runtime/auth/claims.ts +32 -0
  214. package/src/forge/runtime/auth/errors.ts +2 -0
  215. package/src/forge/runtime/context/create-context.ts +30 -6
  216. package/src/forge/runtime/db/memory-adapter.ts +2 -2
  217. package/src/forge/runtime/db/postgres-adapter.ts +6 -3
  218. package/src/forge/runtime/executor.ts +3 -2
  219. package/src/forge/runtime/external/bridge.ts +553 -0
  220. package/src/forge/runtime/live/live-query-runner.ts +2 -1
  221. package/src/forge/runtime/outbox/process.ts +2 -1
  222. package/src/forge/runtime/query/run-query.ts +2 -1
  223. package/src/forge/runtime/runner/run-entry.ts +2 -1
  224. package/src/forge/runtime/telemetry/scrubber.ts +56 -5
  225. package/src/forge/runtime/telemetry/sinks/posthog.ts +4 -5
  226. package/src/forge/runtime/telemetry/sinks/sentry.ts +4 -5
  227. package/src/forge/runtime/webhooks/security.ts +184 -0
  228. package/src/forge/runtime/workflows/resolve-step.ts +2 -1
  229. package/src/forge/server.ts +93 -0
  230. package/src/forge/version.ts +1 -1
  231. package/templates/b2b-support-web/package.json +2 -0
  232. package/templates/b2b-support-web/src/actions/captureTicketCreated.ts +7 -2
  233. package/templates/b2b-support-web/src/commands/closeTicket.ts +6 -1
  234. package/templates/b2b-support-web/src/commands/createTicket.ts +8 -2
  235. package/templates/b2b-support-web/src/queries/getTicket.ts +8 -1
  236. package/templates/b2b-support-web/tsconfig.json +4 -1
  237. package/templates/b2b-support-web/web/components/CreateTicketForm.tsx +1 -2
  238. package/templates/b2b-support-web/web/components/PolicyDeniedDemo.tsx +1 -2
  239. package/templates/b2b-support-web/web/components/TicketList.tsx +1 -2
  240. package/templates/b2b-support-web/web/components/TraceDetails.tsx +1 -1
  241. package/templates/b2b-support-web/web/lib/forge.ts +1 -0
  242. package/templates/b2b-support-web/web/package.json +1 -1
  243. package/templates/minimal-web/package.json +2 -1
  244. package/templates/minimal-web/tsconfig.json +3 -1
  245. package/templates/minimal-web/web/package.json +2 -2
package/AGENTS.md CHANGED
@@ -1,4 +1,4 @@
1
- // @forge-generated generator=0.1.0-alpha.1 input=d50515ea2f22c012d06e8794c2031206c9478d732b15ce6592aa8bf74bdaa665 content=e0bf36433d915daf5ad06ac6265b3ac6f2cd1706269c69618bbbc1cb1f44e465
1
+ // @forge-generated generator=0.1.0-alpha.11 input=dc56d0c4319efa7c4d9ba9f2661ff05cb9fb78e956666f8032cc01e4aca54367 content=1611635edf59c122b013ba76c85bd333ab3b30b289aaea04a9074f9438782a50
2
2
  # AGENTS.md
3
3
 
4
4
  <!-- forge-generated:start -->
@@ -69,6 +69,7 @@ forge inspect app --json
69
69
  forge inspect all --json
70
70
  forge inspect frontend --json
71
71
  forge inspect capabilities --json
72
+ forge inspect agent-tools --json
72
73
  forge deps inspect <package> --json
73
74
  forge deps api <package> <symbol> --json
74
75
  forge deps trace <package> --json
@@ -82,6 +83,9 @@ forge doctor
82
83
  forge doctor windows --json
83
84
  forge setup windows --json
84
85
  forge agent print-context --json
86
+ forge ai tools --json
87
+ forge ai agents --json
88
+ forge ai trace <traceId> --json
85
89
  forge verify --smoke
86
90
  forge verify --standard
87
91
  forge verify --strict
@@ -103,6 +107,21 @@ Tenant-scoped tables:
103
107
  - ANTHROPIC_API_KEY (required)
104
108
  - OPENAI_API_KEY (required)
105
109
 
110
+ ## AI Tools And Agents
111
+
112
+ - AI SDK engine: Vercel AI SDK v6.
113
+ - Forge layer: generated registry, runtime rules, telemetry, secrets, tenant/auth context, and agent contract.
114
+ - Use `ctx.agent.run` or `ctx.ai.runAgent` only in actions, workflows, endpoints, and server code.
115
+ - Do not create custom tool loops; use Forge tools and AI SDK `ToolLoopAgent` through the Forge runtime.
116
+
117
+ Tools:
118
+
119
+ - none
120
+
121
+ Agents:
122
+
123
+ - none
124
+
106
125
  ## Auth
107
126
 
108
127
  - Modes: dev-headers, jwt, oidc, disabled
@@ -158,6 +177,7 @@ Use:
158
177
  forge make resource <name> --fields title:text,status:enum(open,closed) --dry-run --json
159
178
  forge make resource <name> --fields title:text,status:enum(open,closed) --with-ui --yes
160
179
  forge make ui --framework vite --dry-run --json
180
+ forge make ai-chat support --dry-run --json
161
181
  ```
162
182
 
163
183
  Review the plan before applying when the resource touches schema or policies.
@@ -194,11 +214,13 @@ Use:
194
214
  ```bash
195
215
  forge refactor rename field tickets.priority tickets.urgency --dry-run --json
196
216
  forge refactor rename field tickets.priority tickets.urgency --yes
217
+ forge refactor rename command createTicket openTicket --dry-run --json
218
+ forge refactor rename command createTicket openTicket --yes
197
219
  ```
198
220
 
199
- These codemods are AST-aware for `extract-action`, `rename field`, and `rename table`. Field renames are scoped to the target table, so `tickets.priority` only rewrites references linked to `tickets`.
221
+ These codemods are AST-aware for `extract-action`, `rename command`, `rename field`, and `rename table`. Command renames update runtime registries, generated client references, frontend hooks, tests, and string references where safe. Field renames are scoped to the target table, so `tickets.priority` only rewrites references linked to `tickets`.
200
222
 
201
- Never edit `src/forge/_generated/**` directly. Review migration hints before applying field or table renames.
223
+ Never edit `src/forge/_generated/**` directly. Review migration hints before applying command, field, or table renames.
202
224
 
203
225
  ### Plan impact-based tests
204
226
 
@@ -224,6 +246,19 @@ forge repair plan --from-last-test-run --write
224
246
 
225
247
  Apply only high-confidence deterministic repairs automatically. Review medium or low confidence repairs before changing code.
226
248
 
249
+ ### Add AI tools or agents
250
+
251
+ Use:
252
+
253
+ ```bash
254
+ forge generate
255
+ forge inspect all --json
256
+ forge ai check --json
257
+ forge ai trace <traceId> --json
258
+ ```
259
+
260
+ Define tools with `aiTool({ inputSchema, outputSchema, risk, needsApproval, handler })` and agents with `agent({ provider, model, instructions, tools, stopWhen })`. Execute agents with `ctx.agent.run` or `ctx.ai.runAgent` only from actions, workflows, endpoints, or server code. In dev, POST `/ai/agents/run` returns JSON for automation and POST `/ai/agents/chat` returns an AI SDK UIMessage stream for React `useChat`; both accept `agent: "<exportedAgentName>"` and use generated auto-tools from `agentTools.json`.
261
+
227
262
  ### Export agent adapters
228
263
 
229
264
  Use:
package/CHANGELOG.md CHANGED
@@ -1,5 +1,110 @@
1
1
  # forgeos
2
2
 
3
+ ## 0.1.0-alpha.11
4
+
5
+ Strict verify performance:
6
+
7
+ - Reduced the validated `forge verify --strict` wall time from roughly 358-454s to about 116s on the current Windows test machine.
8
+ - Added stable repo-local `tsx` CLI caching under `node_modules/.cache/forge-tsx-cli` so spawned CLI tests reuse the warm compiler path.
9
+ - Balanced TestGraph strict execution across shared and isolated lanes, bringing the slowest files down from roughly 50s to under 10s in the updated profile.
10
+ - Moved heavy refactor/impact/external runtime suites onto faster shared paths where safe and kept isolation for process-sensitive tests.
11
+ - Documented and guarded the cache behavior so future test helpers preserve the speedup without checking cache contents into git.
12
+ - Aligned the alpha release workflow so the public `latest` dist-tag is promoted with the published ForgeOS alpha package.
13
+
14
+ ## 0.1.0-alpha.10
15
+
16
+ Launch polish:
17
+
18
+ - Fixed `forge run <external-command> --args ...` so CLI arguments reach the external runtime bridge.
19
+ - Added direct external query CLI support through `forge query <service.query> --args ...`.
20
+ - Emit generated `.json` artifacts as pure JSON while keeping deterministic headers on code/text artifacts.
21
+ - Relaxed the `minimal-web` template verify script to `forge verify --smoke` and added the missing `check` script to `b2b-support-web`.
22
+ - Updated public protocol/changelog docs for the external runtime and Go adapter alpha line.
23
+ - Bumped the create-app wrapper package line to `create-forgeos-app@0.1.0-alpha.4`.
24
+
25
+ ## 0.1.0-alpha.9
26
+
27
+ ### Patch Changes
28
+
29
+ - Added the Forge external runtime protocol bridge for manifest-backed commands and queries.
30
+ - Added the Go adapter MVP with a real `go-billing` conformance example.
31
+ - Emitted external service metadata into inspect/API/agent artifacts, including `needsApproval` for agent tools.
32
+ - Reuse compiler classifier package signals across export classification, dropping repeated package signal scans.
33
+ - Reuse serialized graph JSON when rendering the largest generated TypeScript graph artifacts.
34
+ - Keep generated Forge artifacts aligned with the `0.1.0-alpha.9` compiler/runtime version.
35
+
36
+ ## 0.1.0-alpha.8
37
+
38
+ ### Patch Changes
39
+
40
+ - [`7568756`](https://github.com/Stahldavid/forge/commit/756875688873dd60d3d6cf700a7bb7c211968c69) Thanks [@Stahldavid](https://github.com/Stahldavid)! - Publish prerelease packages through the ForgeOS alpha publisher so npm dist-tags stay aligned.
41
+
42
+ ## 0.1.0-alpha.7
43
+
44
+ ### Patch Changes
45
+
46
+ - [`4ace311`](https://github.com/Stahldavid/forge/commit/4ace3113e3298b5c306000870922fcfbae9c1861) Thanks [@Stahldavid](https://github.com/Stahldavid)! - Keep npm prerelease publishing on the public alpha dist-tag.
47
+
48
+ ## 0.1.0-alpha.6
49
+
50
+ ### Patch Changes
51
+
52
+ - [`c30f906`](https://github.com/Stahldavid/forge/commit/c30f9069c99ac747ce143ab5fbcbf13912ed8760) Thanks [@Stahldavid](https://github.com/Stahldavid)! - Add CLI version output, align create-app help with package metadata, and add release dependency audit evidence.
53
+
54
+ ## 0.1.0-alpha.5
55
+
56
+ Release alignment for the public alpha channel:
57
+
58
+ - Added `forge ai redteam --model-level --json` with deterministic prompt-injection, secret-exfiltration, approval-bypass, cross-tenant, and indirect tool-injection probes.
59
+ - Added `forge security prove --full --json` support for source checkouts, with graceful structural-proof fallback when packaged apps do not include ForgeOS test fixtures.
60
+ - Strengthened npm publish workflows to run `security prove --db postgres --full --json`.
61
+ - Added public registry smoke coverage for `forgeos@alpha` and `create-forgeos-app@alpha`.
62
+ - Bumped the create-app wrapper package line to `create-forgeos-app@0.1.0-alpha.1`.
63
+
64
+ ## 0.1.0-alpha.4
65
+
66
+ Security assurance and release evidence hardening:
67
+
68
+ - Added value-aware telemetry redaction for known secret values in safe-looking fields, messages, details, outputs, and stack traces.
69
+ - Added webhook signature, timestamp, and replay protection helpers with Stripe/GitHub/generic HMAC coverage.
70
+ - Added HTTP tenant-isolation tests that exercise the dev server/API boundary, not only the internal runtime executor.
71
+ - Added `forge rls mutate-test --json` to kill dangerous generated RLS mutations such as missing FORCE RLS, missing policies, unconditional predicates, and `BYPASSRLS`.
72
+ - Extended `forge security prove --json` with RLS mutation proof and invariant-level evidence metadata.
73
+ - Added scripts to split security evidence by invariant and emit basic release supply-chain evidence plus CycloneDX SBOM.
74
+ - Strengthened publish/security workflows so release gates use Postgres-backed security proof, RLS mutation proof, release evidence, and SBOM generation.
75
+
76
+ ## 0.1.0-alpha.3
77
+
78
+ Native Forge AI agents on top of Vercel AI SDK v6:
79
+
80
+ - Added `aiTool` and `agent` primitives with generated `agentTools.json` / `agentTools.md`.
81
+ - Added `ctx.agent.run` and `ctx.ai.runAgent` using AI SDK `ToolLoopAgent`.
82
+ - Added auto-tools for commands, queries, and liveQueries with read-only vs approval-required writes.
83
+ - Added dev agent endpoints: `POST /ai/agents/run` and `POST /ai/agents/chat`.
84
+ - Extended `forge ai` CLI with `tools`, `agents`, and `trace` subcommands.
85
+ - Added `forge inspect agent-tools` and agent tool metadata in `agentContract.json`.
86
+ - Upgraded runtime dependency to AI SDK v6 for tool calling, streaming UI, and MCP compatibility.
87
+
88
+ Documentation:
89
+
90
+ - Added public [AI](https://forgeos.readthedocs.io/en/latest/ai/) page and AST-aware `rename command` codemod docs.
91
+ - Expanded ReadTheDocs to full agent-native coverage: agent workflow (`forge do`), frontend/liveQuery, security/data, authoring, testing/repair, self-host, templates, Material theme, and changelog page.
92
+
93
+ ## 0.1.0-alpha.2
94
+
95
+ Windows and generated-app hardening:
96
+
97
+ - Fixed Node ESM handler loading on Windows by importing generated app modules
98
+ through `file://` URLs across commands, queries, liveQueries, outbox actions,
99
+ workflow steps, mocks, and telemetry adapters.
100
+ - Fixed `forge dev` SSE streaming on the Node HTTP fallback so liveQuery
101
+ snapshots are flushed immediately instead of buffering forever.
102
+ - Hardened generated app scaffolding and web dev spawning on Windows.
103
+ - Updated the B2B support template to route frontend imports through
104
+ `web/lib/forge.ts` and use safer handler input validation.
105
+ - Added focused tests for Node compatibility, template scaffolding, runtime
106
+ imports, and streaming responses.
107
+
3
108
  ## 0.1.0-alpha.1
4
109
 
5
110
  Republish alpha with the dependency/API oracle improvements:
package/README.md CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  Agent-native application framework and compiler for building Forge apps without a mandatory dashboard. ForgeOS turns application source into deterministic runtime contracts, generated clients, safety checks, and machine-readable context that humans and AI coding agents can use safely.
4
4
 
5
- **Status:** private/public alpha MVP, implemented through H42. The core compiler, local runtime, frontend SDK, production auth, RLS compiler, repair/review loops, UI test bridge, guided intent router, full-stack capability map, clean templates, faster generated checks, showcase app, Windows-safe Bun resolution, native Windows diagnostics/setup, Node-compatible CLI/runtime paths, observable verify timeouts, multi-OS Node CI smoke, release packaging smoke, npm alpha publishing, Trusted Publisher/OIDC release wiring, ReadTheDocs-ready public docs, package/version-aligned generator metadata, AST-aware codemods for `extract-action`, `rename field`, and `rename table`, broader field-test automation, and quieter template workspaces are present. Public release hardening is still focused on deeper semantic codemods and more real-project field reports.
5
+ **Status:** private/public alpha MVP, implemented through H43. ForgeOS already includes the compiler, local runtime, frontend SDK, production auth, RLS compiler, liveQuery, self-host artifacts, generated agent contract, guided dev loop, repair/review/test tooling, AST-aware codemods, package intelligence, native AI tools/agents, npm alpha publishing, and Read the Docs public docs. Public release hardening is still focused on deeper semantic codemods, broader field reports, and more production mileage.
6
6
 
7
- Public docs are configured for ReadTheDocs with `.readthedocs.yaml` and `mkdocs.yml`. The local docs entrypoint is `docs/index.md`.
7
+ Public docs live at [forgeos.readthedocs.io](https://forgeos.readthedocs.io/). The repo builds them with `.readthedocs.yaml`, `mkdocs.yml`, and `docs/index.md`.
8
+
9
+ Start with [Why ForgeOS](https://forgeos.readthedocs.io/en/latest/why-forgeos/) to understand the agent-native design.
8
10
 
9
11
  ## Agent-First Quickstart
10
12
 
@@ -44,6 +46,22 @@ These files describe the app surface, runtime rules, generated files, policies,
44
46
 
45
47
  ## Create a Test App
46
48
 
49
+ Public one-command app creation:
50
+
51
+ ```bash
52
+ npm create forgeos-app@alpha notes-app -- --template minimal-web
53
+ cd notes-app
54
+ npm run dev
55
+ ```
56
+
57
+ Equivalent lower-level command without installing ForgeOS globally:
58
+
59
+ ```bash
60
+ npm exec --package forgeos@alpha -- forge new notes-app --template minimal-web --package-manager npm
61
+ ```
62
+
63
+ If ForgeOS is already installed or you are inside this repository:
64
+
47
65
  ```bash
48
66
  forge new notes-app --template minimal-web --package-manager npm
49
67
  cd notes-app
@@ -58,11 +76,11 @@ Templates also include workspace editor excludes for generated/runtime directori
58
76
  For release or external smoke testing, choose the Forge package source explicitly:
59
77
 
60
78
  ```bash
61
- forge new smoke-app --template minimal-web --package-manager npm --forge-spec "npm:forgeos@^0.1.0-alpha.0"
79
+ forge new smoke-app --template minimal-web --package-manager npm --forge-spec "npm:forgeos@alpha"
62
80
  forge new local-app --template minimal-web --package-manager npm --local-forge
63
81
  ```
64
82
 
65
- `--forge-spec` writes that dependency spec into the generated app, while `--local-forge` keeps the monorepo/local package workflow. The npm package is published as `forgeos`, but generated apps keep the dependency key, CLI binary, and import surface as `forge` (`forge`, `forge/server`, `forge/react`) by using npm alias specs such as `"forge": "npm:forgeos@^0.1.0-alpha.0"`. CI uses both `--forge-spec "file:$GITHUB_WORKSPACE"` and a packed tarball smoke to prove freshly created apps can install ForgeOS and run outside the framework workspace.
83
+ `--forge-spec` writes that dependency spec into the generated app, while `--local-forge` keeps the monorepo/local package workflow. The npm package is published as `forgeos`, but generated apps keep the dependency key, CLI binary, and import surface as `forge` (`forge`, `forge/server`, `forge/react`) by using npm alias specs such as `"forge": "npm:forgeos@alpha"`. CI uses both `--forge-spec "file:$GITHUB_WORKSPACE"` and a packed tarball smoke to prove freshly created apps can install ForgeOS and run outside the framework workspace.
66
84
 
67
85
  For broader field testing:
68
86
 
@@ -73,6 +91,35 @@ npm run field:test -- --package-managers npm --templates minimal-web --forge-spe
73
91
 
74
92
  The scheduled/manual `Field Tests` workflow expands that coverage across Linux, macOS, Windows, Node 22, Node 24, and npm/pnpm/yarn/bun.
75
93
 
94
+ ## External Runtimes And Go Adapter
95
+
96
+ ForgeOS can import services written outside TypeScript through the Forge Protocol.
97
+ External runtimes publish a `forge.manifest.json` that describes commands, queries,
98
+ transport, policies, risk metadata, tenant scope, and schemas. Forge then emits
99
+ the same machine-readable app/API/agent artifacts and exposes runtime bridge
100
+ endpoints for those entries.
101
+
102
+ The first adapter MVP is Go:
103
+
104
+ ```bash
105
+ cd examples/go-billing
106
+ go run . --manifest --base-url http://127.0.0.1:8787 > forge.manifest.json
107
+ go run . --addr 127.0.0.1:8787 --base-url http://127.0.0.1:8787
108
+ ```
109
+
110
+ In a Forge app:
111
+
112
+ ```bash
113
+ forge manifest validate ./forge.manifest.json --json
114
+ forge manifest import ./forge.manifest.json --json
115
+ forge generate
116
+ forge run billing.createInvoice --args '{"title":"Invoice"}' --user-id u1 --tenant-id tenant-a --role admin
117
+ forge query billing.listInvoices --args '{}' --user-id u1 --tenant-id tenant-a --role admin
118
+ ```
119
+
120
+ See [`docs/forge-protocol.md`](docs/forge-protocol.md), [`schemas/forge-manifest.schema.json`](schemas/forge-manifest.schema.json),
121
+ and [`adapters/go`](adapters/go/README.md).
122
+
76
123
  ## What ForgeOS Generates
77
124
 
78
125
  ```txt
@@ -122,7 +169,7 @@ forge.lock
122
169
  | Auth | dev headers, JWT, OIDC discovery/JWKS verification via `jose`, production-mode guardrails |
123
170
  | RLS | Postgres RLS SQL compiler/checks for DB-enforced tenant isolation |
124
171
  | Secrets/env | secret registry, env schema, redaction, strict `process.env` checks |
125
- | AI | provider registry, `ctx.ai`, mock mode, telemetry without prompt/output retention by default |
172
+ | AI | Vercel AI SDK v6 engine, provider registry, `ctx.ai`, `ctx.agent.run`, `aiTool`, `agent`, `/ai/agents/run` JSON automation, `/ai/agents/chat` UIMessage streaming, `forge ai trace`, structural and model-level redteam probes, mock mode, telemetry without prompt/output retention by default |
126
173
  | Frontend | generated client SDK, React/Next hooks, template app, liveQuery client support |
127
174
  | LiveQuery | durable invalidation log, reconnect/resume semantics, production hardening checks |
128
175
  | Self-host | compose/deploy artifacts and self-host checks |
@@ -171,8 +218,10 @@ Common command groups:
171
218
  | `forge check --json` | Validate guardrails and emit diagnostics with fix hints |
172
219
  | `forge verify --smoke` | Fast local gate: generated drift, Forge checks, typecheck when present, no tests/lint |
173
220
  | `forge verify --standard` | Agent development gate: generated drift, Forge/security checks, typecheck, and impact-selected tests |
174
- | `forge verify --strict` | Full handoff/CI gate: generated drift, Forge/security checks, typecheck, full test script, lint |
221
+ | `forge verify --strict` | Full handoff/CI gate: generated drift, Forge/security checks, typecheck, full TestGraph in bounded parallel/isolated chunks, lint |
175
222
  | `forge verify --script-timeout-ms <ms>` | Run package scripts with a predictable timeout and machine-readable timeout diagnostics |
223
+ | `forge verify --test-jobs <n>` | Tune strict TestGraph chunk parallelism; `FORGE_VERIFY_TEST_JOBS` is also supported |
224
+ | `forge verify --strict --test-plan --json` | Print the strict TestGraph scheduler plan without running tests |
176
225
  | `forge do "<objective>" --json` | Guided intent router: choose the right workflow, files, risks, and next action |
177
226
  | `forge inspect <target> --json` | Inspect generated app/data/runtime/policy/client/agent/UI surfaces |
178
227
  | `forge inspect framework --json` | Inspect ForgeOS framework modules, CLI commands, templates, examples, tests, and preferred entrypoints |
@@ -198,6 +247,7 @@ Common command groups:
198
247
  Refactor codemods are AST-aware where safety matters most:
199
248
 
200
249
  - `forge refactor extract-action` is binding-aware and preserves unrelated imports, type-only imports, and shadowed locals.
250
+ - `forge refactor rename command <oldName> <newName>` rewrites command declarations, generated client references, React hook usage, tests, and safe string references while preserving unrelated symbols.
201
251
  - `forge refactor rename field <table.field> <table.field>` rewrites structured TS/JS/JSX/TSX and JSON references, preserves locals, and scopes the field change to files/objects linked to the target table. For example, `tickets.priority -> tickets.urgency` does not rewrite a generic `priority` prop in a component with no `tickets` binding.
202
252
  - `forge refactor rename table <from> <to>` rewrites table definitions, `ctx.db.<table>` access, policy strings, JSON/blueprints, and import/export specifiers while preserving unrelated locals with the same name.
203
253
 
@@ -226,12 +276,23 @@ See [`examples/showcase-forge-app`](examples/showcase-forge-app/README.md).
226
276
 
227
277
  ```bash
228
278
  cd examples/showcase-forge-app
229
- bun install
230
- bun run generate
231
- bun run dev
279
+ npm install
280
+ npm run generate
281
+ npm run dev
232
282
  ```
233
283
 
234
- Examples are source-only where practical: generated artifacts, `forge.lock`, package lockfiles, and operational `.forge/**` state are recreated locally. The showcase demonstrates tenant-scoped data, policies, commands, queries, liveQueries, outbox actions, workflows, mock AI, telemetry trace IDs, generated React hooks, `agentContract`, `frontendGraph`, and `capabilityMap`.
284
+ For the reproducible public proof path:
285
+
286
+ ```bash
287
+ npm run proof:inspect
288
+ npm run proof:dev
289
+ npm run proof:capabilities
290
+ npm run proof:verify
291
+ ```
292
+
293
+ Read [`examples/showcase-forge-app/PUBLIC_PROOF.md`](examples/showcase-forge-app/PUBLIC_PROOF.md) for the full walkthrough.
294
+
295
+ Examples are source-only where practical: generated artifacts, `forge.lock`, package lockfiles, and operational `.forge/**` state are recreated locally. The showcase demonstrates tenant-scoped data, policies, commands, queries, liveQueries, outbox actions, workflows, mock AI, telemetry trace IDs, generated React hooks, `agentContract`, `frontendGraph`, `capabilityMap`, and the standard agent handoff loop.
235
296
 
236
297
  ## Platform Support
237
298
 
@@ -307,7 +368,7 @@ For the first prerelease publish, use the alpha dist-tag explicitly:
307
368
 
308
369
  ```bash
309
370
  npm run release:publish-local-alpha -- --dry-run
310
- npm run release:publish-local-alpha -- --yes
371
+ npm run release:publish-alpha
311
372
  ```
312
373
 
313
374
  The normal path is:
@@ -330,7 +391,7 @@ Configure npm Trusted Publisher for package `forgeos`:
330
391
  | Environment | blank |
331
392
  | Allowed action | `npm publish` |
332
393
 
333
- Do not add `NPM_TOKEN` for normal releases. Alpha releases publish with the `alpha` dist-tag so prerelease builds do not become `latest` accidentally. The first manual package creation uses `release:publish-local-alpha`, which publishes from a temporary hardlink-free staging copy and disables provenance because local shells do not have a GitHub OIDC provider. The workflow uses `id-token: write`, Node 24/npm 11+, and provenance for subsequent releases. `npm run release:smoke` runs `npm pack`, creates a fresh app with the packed tarball, installs dependencies, runs `forge dev --once --json`, and verifies the app smoke path.
394
+ Do not add `NPM_TOKEN` for normal releases. Alpha releases publish with the `alpha` dist-tag so prerelease builds do not become `latest` accidentally. Use `release:publish-local-alpha -- --dry-run` only to validate the staged tarball locally; real npm publishing should go through `release:publish-alpha`, which dispatches `publish.yml` and uses npm OIDC Trusted Publisher. The workflow checks whether the package version already exists before installing dependencies or running tests, then uses `id-token: write`, Node 24/npm 11+, and provenance for the actual publish. `npm run release:smoke` runs `npm pack`, creates a fresh app with the packed tarball, installs dependencies, runs `forge dev --once --json`, and verifies the app smoke path.
334
395
 
335
396
  ## Milestone History
336
397
 
@@ -377,11 +438,12 @@ H39 Showcase app
377
438
  H40 Windows/runtime hardening
378
439
  H41 Node-compatible CLI/runtime
379
440
  H42 Verify observability and quieter app workspaces
441
+ H43 Native AI tools and agent loop
380
442
  ```
381
443
 
382
444
  ## Remaining Hardening Before Public Release
383
445
 
384
- - Keep expanding semantic codemods beyond the current AST-aware `extract-action`, `rename field`, and `rename table` paths.
446
+ - Keep expanding semantic codemods beyond the current AST-aware `extract-action`, `rename command`, `rename field`, and `rename table` paths.
385
447
  - Reduce command-selection risk with more task routers and richer inline diagnostics.
386
448
  - Keep hardening native Windows setup beyond diagnostics and safe automatic environment fixes.
387
449
  - Keep broadening package manager CI from template smoke toward install/build smoke for pnpm and yarn apps.
@@ -0,0 +1,23 @@
1
+ # Forge Go Adapter
2
+
3
+ `adapters/go` is the minimal Go SDK for external Forge runtimes. It registers
4
+ commands and queries, emits `forge.manifest.json`, and exposes a Forge-compatible
5
+ HTTP handler.
6
+
7
+ ```go
8
+ app := forge.New("billing", forge.BaseURL("http://127.0.0.1:8787"))
9
+
10
+ app.Command("createInvoice", forge.Handle(createInvoice),
11
+ forge.Policy("billing.manage"),
12
+ forge.TenantScoped(true),
13
+ forge.NeedsApproval(true),
14
+ )
15
+
16
+ app.Query("listInvoices", forge.Handle(listInvoices),
17
+ forge.Policy("billing.manage"),
18
+ forge.TenantScoped(true),
19
+ )
20
+ ```
21
+
22
+ The HTTP handler accepts Forge runtime envelopes on `/commands/:name` and
23
+ `/queries/:name`, then returns `{ "ok": true, "result": ... }` envelopes.
@@ -0,0 +1,3 @@
1
+ module github.com/Stahldavid/forge/adapters/go
2
+
3
+ go 1.22
@@ -0,0 +1,149 @@
1
+ package forge
2
+
3
+ import (
4
+ "encoding/json"
5
+ "errors"
6
+ "net/http"
7
+ "strings"
8
+ )
9
+
10
+ func (registry *Registry) HTTPHandler() http.Handler {
11
+ mux := http.NewServeMux()
12
+ mux.HandleFunc(registry.service.Health, registry.handleHealth)
13
+ mux.HandleFunc("/manifest", registry.handleManifest)
14
+ mux.HandleFunc("/commands/", registry.handleRuntime(KindCommand, "/commands/"))
15
+ mux.HandleFunc("/queries/", registry.handleRuntime(KindQuery, "/queries/"))
16
+ return mux
17
+ }
18
+
19
+ func (registry *Registry) handleHealth(response http.ResponseWriter, request *http.Request) {
20
+ writeJSON(response, http.StatusOK, map[string]any{
21
+ "ok": true,
22
+ "service": registry.service.Name,
23
+ })
24
+ }
25
+
26
+ func (registry *Registry) handleManifest(response http.ResponseWriter, request *http.Request) {
27
+ baseURL := request.URL.Query().Get("baseUrl")
28
+ if baseURL == "" {
29
+ baseURL = registry.service.BaseURL
30
+ }
31
+ writeJSON(response, http.StatusOK, registry.Manifest(baseURL))
32
+ }
33
+
34
+ func (registry *Registry) handleRuntime(kind EntryKind, prefix string) http.HandlerFunc {
35
+ return func(response http.ResponseWriter, request *http.Request) {
36
+ name := strings.TrimPrefix(request.URL.Path, prefix)
37
+ registered, ok := registry.lookup[lookupKey(kind, name)]
38
+ if !ok {
39
+ writeError(response, http.StatusNotFound, "", "FORGE_GO_ENTRY_NOT_FOUND", "external entry not found")
40
+ return
41
+ }
42
+ if request.Method != http.MethodPost && request.Method != http.MethodGet {
43
+ writeError(response, http.StatusMethodNotAllowed, "", "FORGE_GO_METHOD_NOT_ALLOWED", "external entry only accepts GET or POST")
44
+ return
45
+ }
46
+
47
+ envelope, err := readRequestEnvelope(request)
48
+ traceID := traceIDFrom(request, envelope)
49
+ if err != nil {
50
+ writeError(response, http.StatusBadRequest, traceID, "FORGE_GO_BAD_REQUEST", err.Error())
51
+ return
52
+ }
53
+ if envelope.Forge.Service == "" {
54
+ envelope.Forge.Service = registry.service.Name
55
+ }
56
+ if envelope.Forge.Entry == "" {
57
+ envelope.Forge.Entry = name
58
+ }
59
+ if envelope.Forge.Kind == "" {
60
+ envelope.Forge.Kind = string(kind)
61
+ }
62
+ if envelope.Forge.TraceID == "" {
63
+ envelope.Forge.TraceID = traceID
64
+ }
65
+ if envelope.Auth.Kind == "" {
66
+ envelope.Auth = authFromHeaders(request.Header)
67
+ }
68
+
69
+ call := &Context{
70
+ Auth: envelope.Auth,
71
+ Forge: envelope.Forge,
72
+ Headers: request.Header,
73
+ }
74
+ result, err := registered.handler(request.Context(), call, envelope.Args)
75
+ if err != nil {
76
+ writeError(response, http.StatusInternalServerError, envelope.Forge.TraceID, "FORGE_GO_HANDLER_FAILED", err.Error())
77
+ return
78
+ }
79
+ writeJSON(response, http.StatusOK, ResponseEnvelope{
80
+ OK: true,
81
+ Result: result,
82
+ TraceID: envelope.Forge.TraceID,
83
+ })
84
+ }
85
+ }
86
+
87
+ func readRequestEnvelope(request *http.Request) (RequestEnvelope, error) {
88
+ if request.Method == http.MethodGet {
89
+ args := request.URL.Query().Get("args")
90
+ if args == "" {
91
+ args = "{}"
92
+ }
93
+ return RequestEnvelope{Args: json.RawMessage(args)}, nil
94
+ }
95
+ defer request.Body.Close()
96
+ var envelope RequestEnvelope
97
+ decoder := json.NewDecoder(request.Body)
98
+ if err := decoder.Decode(&envelope); err != nil {
99
+ return envelope, err
100
+ }
101
+ if len(envelope.Args) == 0 {
102
+ envelope.Args = json.RawMessage("{}")
103
+ }
104
+ if !json.Valid(envelope.Args) {
105
+ return envelope, errors.New("request args must be valid JSON")
106
+ }
107
+ return envelope, nil
108
+ }
109
+
110
+ func authFromHeaders(headers http.Header) Auth {
111
+ auth := Auth{Kind: headers.Get("x-forge-auth-kind")}
112
+ if auth.Kind == "" {
113
+ auth.Kind = "anonymous"
114
+ }
115
+ auth.UserID = headers.Get("x-forge-user-id")
116
+ auth.TenantID = headers.Get("x-forge-tenant-id")
117
+ auth.Role = headers.Get("x-forge-role")
118
+ return auth
119
+ }
120
+
121
+ func traceIDFrom(request *http.Request, envelope RequestEnvelope) string {
122
+ if envelope.Forge.TraceID != "" {
123
+ return envelope.Forge.TraceID
124
+ }
125
+ return request.Header.Get("x-forge-trace-id")
126
+ }
127
+
128
+ func writeError(response http.ResponseWriter, status int, traceID string, code string, message string) {
129
+ writeJSON(response, status, ResponseEnvelope{
130
+ OK: false,
131
+ Diagnostics: []Diagnostic{{
132
+ Severity: "error",
133
+ Code: code,
134
+ Message: message,
135
+ Docs: []string{"docs/forge-protocol.md"},
136
+ }},
137
+ Error: &ErrorInfo{
138
+ Code: code,
139
+ Message: message,
140
+ },
141
+ TraceID: traceID,
142
+ })
143
+ }
144
+
145
+ func writeJSON(response http.ResponseWriter, status int, body any) {
146
+ response.Header().Set("content-type", "application/json")
147
+ response.WriteHeader(status)
148
+ _ = json.NewEncoder(response).Encode(body)
149
+ }