@akira-tl/forgerelay 0.3.0 → 0.3.1

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable ForgeRelay changes are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.3.1] - 2026-08-10
8
+
9
+ ### Changed
10
+
11
+ - Release-tag Hooks now treat `commandRegex` as a command extractor as well as a filter: a matching substring becomes Hook `payload.command`, while a different full shell request is preserved as `payload.originalCommand`. This lets stable tag pushes trigger local release gates even when an Agent wraps them in a compound shell command.
12
+ - GitHub Release pages now use the matching `CHANGELOG.md` version section as their release notes instead of relying only on generated compare notes.
13
+
14
+ ### Fixed
15
+
16
+ - MCP App resources now advertise a unique `_meta.ui.domain` derived from the resolved public deployment origin while preserving existing CSP, content-hashed template identity, and legacy/historical compatibility resources.
17
+ - `forgerelay doctor` now reports the resolved MCP runtime shape, including public base URL, tool/widget modes, proxy trust, and optional artifact/subagent/Skill capability switches.
18
+
7
19
  ## [0.3.0] - 2026-08-10
8
20
 
9
21
  ### Added
@@ -53,7 +53,7 @@ ForgeRelay 正常会广告 content-hashed:
53
53
  ui://forgerelay/workspace-app-<hash>.html
54
54
  ```
55
55
 
56
- `resources/read` 应返回 `text/html;profile=mcp-app`,并且 HTML 引用的 `/mcp-app-assets/` 资源必须可达。ForgeRelay 还保留 legacy `ui://forgerelay/workspace-app.html` 和历史 `workspace-app-*.html` 兼容指针,以容忍 Host 暂时持有旧 metadata snapshot。
56
+ `resources/list` 与 `resources/read` 的 MCP App metadata 都应包含唯一 `_meta.ui.domain`,其值来自 resolved `publicBaseUrl` 的 origin;CSP 仍使用完整 public base URL 约束资源与连接域。`resources/read` 应返回 `text/html;profile=mcp-app`,并且 HTML 引用的 `/mcp-app-assets/` 资源必须可达。ForgeRelay 还保留 legacy `ui://forgerelay/workspace-app.html` 和历史 `workspace-app-*.html` 兼容指针,以容忍 Host 暂时持有旧 metadata snapshot。
57
57
 
58
58
  需要 live trace 时,可用:
59
59
 
package/dist/cli.js CHANGED
@@ -222,7 +222,14 @@ async function runDoctor() {
222
222
  try {
223
223
  const config = loadConfig();
224
224
  console.log(`Local MCP URL: http://${config.host}:${config.port}/mcp`);
225
+ console.log(`Public base URL: ${config.publicBaseUrl}`);
225
226
  console.log(`Public MCP URL: ${new URL("/mcp", config.publicBaseUrl).toString()}`);
227
+ console.log(`Tool mode: ${config.toolMode}`);
228
+ console.log(`Widgets: ${config.widgets}`);
229
+ console.log(`Trust proxy: ${config.logging.trustProxy ? "one hop" : "off"}`);
230
+ console.log(`Artifacts: ${config.artifactsEnabled ? "enabled" : "disabled"}`);
231
+ console.log(`Subagents: ${config.subagents ? "enabled" : "disabled"}`);
232
+ console.log(`Skills: ${config.skillsEnabled ? "enabled" : "disabled"}`);
226
233
  console.log(`Allowed roots: ${config.allowedRoots.join(", ")}`);
227
234
  console.log(`Allowed hosts: ${config.allowedHosts.join(", ")}`);
228
235
  }
package/dist/hooks.js CHANGED
@@ -215,9 +215,12 @@ export class HookRunner {
215
215
  const handlers = [
216
216
  ...(this.hooks[event] ?? []).map((rule) => ({ scope: "global", rule })),
217
217
  ...(project.hooks[event] ?? []).map((rule) => ({ scope: "project", rule })),
218
- ]
219
- .filter(({ rule }) => hookRuleMatches(rule.matcher, invocation))
220
- .flatMap(({ scope, rule }) => rule.handlers.map((handler) => ({ scope, handler })));
218
+ ].flatMap(({ scope, rule }) => {
219
+ const matchedInvocation = matchHookRule(rule.matcher, invocation);
220
+ if (!matchedInvocation)
221
+ return [];
222
+ return rule.handlers.map((handler) => ({ scope, handler, invocation: matchedInvocation }));
223
+ });
221
224
  const blocking = BLOCKING_EVENTS.has(event);
222
225
  const executions = project.diagnostic
223
226
  ? [{
@@ -230,8 +233,8 @@ export class HookRunner {
230
233
  error: project.diagnostic,
231
234
  }]
232
235
  : [];
233
- for (const [index, { scope, handler }] of handlers.entries()) {
234
- const execution = await this.runHandler(event, handler, index, invocation, scope);
236
+ for (const [index, { scope, handler, invocation: matchedInvocation }] of handlers.entries()) {
237
+ const execution = await this.runHandler(event, handler, index, matchedInvocation, scope);
235
238
  executions.push(execution);
236
239
  logEvent(this.logging, execution.status === "passed" ? "info" : "warn", "hook_call", {
237
240
  hookEvent: event,
@@ -447,20 +450,33 @@ export async function loadProjectHookConfig(workspaceRoot) {
447
450
  ...(diagnostics.length > 0 ? { diagnostic: diagnostics.join(" | ") } : {}),
448
451
  };
449
452
  }
450
- function hookRuleMatches(matcher, invocation) {
453
+ function matchHookRule(matcher, invocation) {
451
454
  if (!matcher)
452
- return true;
455
+ return invocation;
453
456
  if (matcher.workspaceMode && invocation.workspaceMode !== matcher.workspaceMode)
454
- return false;
457
+ return undefined;
455
458
  if (matcher.tool) {
456
459
  if (typeof invocation.payload?.tool !== "string" || invocation.payload.tool !== matcher.tool) {
457
- return false;
460
+ return undefined;
458
461
  }
459
462
  }
463
+ let matchedInvocation = invocation;
460
464
  if (matcher.commandRegex) {
461
465
  const command = invocation.payload?.command;
462
- if (typeof command !== "string" || !new RegExp(matcher.commandRegex).test(command)) {
463
- return false;
466
+ if (typeof command !== "string")
467
+ return undefined;
468
+ const commandMatch = new RegExp(matcher.commandRegex).exec(command);
469
+ if (!commandMatch)
470
+ return undefined;
471
+ if (commandMatch[0] !== command) {
472
+ matchedInvocation = {
473
+ ...invocation,
474
+ payload: {
475
+ ...invocation.payload,
476
+ command: commandMatch[0],
477
+ originalCommand: command,
478
+ },
479
+ };
464
480
  }
465
481
  }
466
482
  if (matcher.pathRegex) {
@@ -471,15 +487,15 @@ function hookRuleMatches(matcher, invocation) {
471
487
  const matchesPath = typeof path === "string" && pathPattern.test(path);
472
488
  const matchesPaths = Array.isArray(paths) && paths.some((entry) => typeof entry === "string" && new RegExp(pathRegex).test(entry));
473
489
  if (!matchesPath && !matchesPaths)
474
- return false;
490
+ return undefined;
475
491
  }
476
492
  if (matcher.provider) {
477
493
  if (typeof invocation.payload?.provider !== "string" ||
478
494
  invocation.payload.provider !== matcher.provider) {
479
- return false;
495
+ return undefined;
480
496
  }
481
497
  }
482
- return true;
498
+ return matchedInvocation;
483
499
  }
484
500
  function hookEnvironment(baseEnv, event, invocation) {
485
501
  return {
package/dist/server.js CHANGED
@@ -317,6 +317,9 @@ ${stylesheets}
317
317
  </body>
318
318
  </html>`;
319
319
  }
320
+ function appDomain(config) {
321
+ return new URL(config.publicBaseUrl).origin;
322
+ }
320
323
  function appCsp(config) {
321
324
  const publicBaseUrl = config.publicBaseUrl.replace(/\/+$/, "");
322
325
  return {
@@ -360,6 +363,7 @@ async function readWorkspaceAppResource(config, requestedUri, transportSessionId
360
363
  text: workspaceAppHtml(config),
361
364
  _meta: {
362
365
  ui: {
366
+ domain: appDomain(config),
363
367
  csp: appCsp(config),
364
368
  },
365
369
  },
@@ -658,6 +662,7 @@ export function createMcpServer(config, workspaces, reviewCheckpoints, processSe
658
662
  description: "Interactive card for viewing ForgeRelay file diffs.",
659
663
  _meta: {
660
664
  ui: {
665
+ domain: appDomain(config),
661
666
  csp: appCsp(config),
662
667
  },
663
668
  },
@@ -211,7 +211,7 @@ Hooks v1 是自动生命周期规则。规则由用户或 Agent 主动写入;
211
211
  "event": "BeforeTool",
212
212
  "matcher": {
213
213
  "tool": "bash",
214
- "commandRegex": "^git\\s+push\\s+origin\\s+v\\d+\\.\\d+\\.\\d+$"
214
+ "commandRegex": "git\\s+push\\s+origin\\s+v\\d+\\.\\d+\\.\\d+"
215
215
  },
216
216
  "command": "npm run release:verify",
217
217
  "timeoutSeconds": 300,
@@ -255,7 +255,7 @@ forgerelay hooks check --project /path/to/project
255
255
  | 字段 | 匹配方式 |
256
256
  | --- | --- |
257
257
  | `tool` | 精确匹配 MCP tool 名称。 |
258
- | `commandRegex` | 对 tool payload 中的 `command` 做 JavaScript 正则匹配。 |
258
+ | `commandRegex` | 对 tool payload 中的 `command` 做 JavaScript 正则匹配;命中后 Hook 收到的 `payload.command` 是实际匹配片段,完整原命令在片段不等于整串命令时保留为 `payload.originalCommand`。 |
259
259
  | `pathRegex` | 对 payload 中的 `path` 或 `paths` 做正则匹配。 |
260
260
  | `provider` | 精确匹配 subagent provider。 |
261
261
  | `workspaceMode` | `checkout` 或 `worktree`。 |
package/docs/debugging.md CHANGED
@@ -60,7 +60,7 @@ The acceptance checks:
60
60
  4. dynamic OAuth client registration, PKCE Owner-password approval, and access-token exchange;
61
61
  5. MCP `initialize`, including package/server version consistency and the shell mutation safety contract;
62
62
  6. `tools/list` for the full debug tool surface, including `close_workspace`, `write_stdin`, canonical `processId` plus the deprecated `sessionId` compatibility alias, the non-blanket `bash` mutation policy, no kill-timeout input, the 300-second foreground-wait contract, workspace resume/stale-workspace schema, and MCP App tool metadata;
63
- 7. the full MCP App template chain: `resources/list`, `resources/templates/list`, current content-hashed `resources/read`, legacy/historical template compatibility reads, `text/html;profile=mcp-app`, CSP resource domains, and an HTTP fetch of the JavaScript asset referenced by the template;
63
+ 7. the full MCP App template chain: `resources/list`, `resources/templates/list`, current content-hashed `resources/read`, legacy/historical template compatibility reads, `text/html;profile=mcp-app`, the unique app domain plus CSP resource domains, and an HTTP fetch of the JavaScript asset referenced by the template;
64
64
  8. a real checkout workspace with `write`, `read`, `rename`, `delete`, foreground `bash` through `ProcessManager`, and a deliberate failed `edit`;
65
65
  9. OS temp-directory `write` → `read` → `edit` → `rename` → `delete` over the same real MCP transport session, plus rejection of an arbitrary path outside the workspace/temp roots;
66
66
  10. a temporary Git repository with managed worktree creation, file modification, and `close_worktree`;
package/docs/roadmap.md CHANGED
@@ -104,29 +104,75 @@ Hooks v1 的目标是给用户和 Agent 一个很小、自动、可组合的生
104
104
 
105
105
  ## 0.3 — MCP loading 与渐进式能力披露
106
106
 
107
- 0.3 的目标是缩小 MCP 首次加载时注入给 Agent 的上下文,同时保持工具可调用性、安全边界和 Host 编排权不变。ForgeRelay 不再把所有低频能力说明都塞进 server instructions 或工具 description,而是把模型接口拆成三层:
107
+ 0.3 的目标是把 ForgeRelay 的 MCP interface 做成一个深而稳定的模型接口:普通编码 primitive 始终直接可见,低频知识与低频 action 都按需披露,新增 ForgeRelay 能力不再线性扩大 Host 首次加载的 `tools/list` 与 instructions。
108
108
 
109
- - `tools/list` 继续暴露真实可调用 primitive,并只携带调用该工具所必需的简洁语义;
110
- - `open_workspace` 返回紧凑的 server/capability 摘要与版本指纹,帮助 Agent 发现能力,并识别 Host 持有旧 tool schema snapshot 的情况;
111
- - ForgeRelay-owned capability guide 提供低频能力的完整说明,由 Agent 在任务相关时显式 `read`,而不是首次连接时自动注入。
109
+ 0.3.0 已完成第一阶段:压缩 server instructions、由 `open_workspace` 返回 version/capability fingerprint、通过 advertised path + `read` 按需加载 ForgeRelay-owned capability guide,并用 fingerprint 与 Host `tools/list` 的差异诊断 stale Host metadata。Capability guide 与 Skill 的语义所有权保持区分:Skill 描述用户、项目或生态工作流;Capability guide 描述 ForgeRelay 自身、与版本绑定的产品能力。
112
110
 
113
- 首版优先复用现有 Skill-style advertised path / `read` 授权机制,而不是新增第二套文档加载协议。Capability guide 与 Skill 的语义所有权保持区分:Skill 描述用户、项目或生态工作流;capability guide 描述 ForgeRelay 自身、与版本绑定的产品能力。
111
+ 0.3 后续阶段采用 ADR-0002 的接口形状。Canonical Core tool surface 最终固定为:
114
112
 
115
- Core Capability Contract 必须始终内联保留至少这些信息:
113
+ ```text
114
+ open_workspace
115
+ close_workspace
116
+ read
117
+ write
118
+ edit
119
+ rename
120
+ delete
121
+ bash
122
+ capability
123
+ ```
124
+
125
+ 其中 `open_workspace` 负责 Workspace 生命周期入口与轻量 Capability catalog;`capability` 是唯一低频 Capability gateway;`bash` 同时承担命令启动与后续 process interaction;Managed worktree 是 Workspace 的 backing mode,由 `close_workspace` 统一完成关闭/finalize lifecycle。Capability registry 只能暴露显式注册、带输入约束、可用性和 guide metadata 的 ForgeRelay capability,不能退化成任意 RPC、URL dispatcher 或 shell 后门。
126
+
127
+ ### 0.3.1 — MCP App 与诊断补丁
128
+
129
+ 在不改变主 tool surface 的前提下先修 0.3.0 发布后真实 Host 暴露的问题:
130
+
131
+ - 为 MCP App resource 补齐 Host submission 所需的 widget/app domain metadata,并保持现有 CSP、content-hash URI 与 compatibility resource contract;
132
+ - `forgerelay doctor` 显示解析后的 MCP 运行形态,例如 tool mode、widgets、public URL、proxy trust 与可选 capability 开关,避免“功能代码存在但当前实例未启用”只能靠源码排查;
133
+ - 补齐 release/Host integration 的诊断与验收用例,但不在这一版重塑 tool schema。
134
+
135
+ ### 0.3.2 — Capability Registry 与 Gateway
136
+
137
+ 建立新的低频 action seam,但保留现有公开工具作为迁移兼容:
138
+
139
+ - 新建 ForgeRelay-owned Capability registry,每项至少声明稳定 name、简短 description、availability、input contract、guide metadata 与 handler;
140
+ - 新增唯一 MCP tool `capability`,提供紧凑的 `describe` / `run` 语义;
141
+ - `open_workspace` 返回轻量 Capability catalog,只做发现,不复制完整 schema、示例或 guide 正文;
142
+ - Agent 已熟悉某项 capability 时可以直接执行;不熟悉时先 `describe`,再按返回的 guide path 使用 `read` 获取详细说明;
143
+ - 选择一组低风险、当前主要依赖 CLI 的检查型能力作为 tracer bullet,验证 registry、Hooks、日志、错误和 Host card contract,而不是一开始迁移所有功能。
144
+
145
+ ### 0.3.3 — 低频 Action 迁入 Gateway
146
+
147
+ 用真实现有能力验证 Gateway 能承载持续扩展,而不是只做一层转发:
148
+
149
+ - 将 change review 收口为如 `review.changes` 的 registered capability;
150
+ - 将 native artifact ingress 收口为如 `artifact.download` 的 registered capability;
151
+ - 适合 Agent 主动调用的 Hook inspection/check 等低频操作进入同一 namespace model;
152
+ - Capability guide 与 catalog/registry 建立一一可追踪关系,availability 由运行时条件决定;
153
+ - `show_changes`、`download_artifact` 等旧 dedicated MCP tools 在迁移窗口内只作为兼容入口,不再作为长期接口设计。
116
154
 
117
- - `workspaceId` 生命周期与 workspace 复用规则;
118
- - 常用文件读写改、`rename` 同时承担 move/rename、删除的核心语义;
119
- - shell 以本地用户权限执行且不是 OS sandbox;
120
- - `processId` / `write_stdin` 的基本长进程语义;
121
- - Hook 阻断结果必须对 Agent 可见;
122
- - 关键 mutation/safety invariant;
123
- - `close_workspace` 与 `close_worktree` 的区别。
155
+ ### 0.3.4 Workspace 与 Process 生命周期收敛
124
156
 
125
- 适合按需读取的首批领域包括:生命周期 Hooks、managed worktree 高级流程、subagents、artifact/review 工作流、debug/MCP App、OAuth/deployment,以及 shell/PTTY/process 的低频边界情况。首个实现切片迁移 Hooks 与 managed worktree 高级说明;第二切片继续覆盖 subagents、artifact/review、Host/OAuth/MCP App integration 与 shell/PTTY/process,并把历史 bundled `subagent-delegation` Skill 的默认自动发现迁回 ForgeRelay-owned capability guide。必要安全语义始终保留在 core contract 或真实 tool schema/description 中。
157
+ 移除两个泄漏内部实现的 public lifecycle tool
126
158
 
127
- Capability/version fingerprint 必须是轻量、语义化、稳定的摘要,不复制完整 `tools/list`。当 server 报告的能力与 Host 当前暴露的 tool snapshot 明显不一致时,Agent 应能判断为 Host metadata stale,并建议刷新 MCP 或开启新会话,而不是错误断言 ForgeRelay 缺少能力。
159
+ - `bash` 成为 Process Manager 的唯一公开 interface;`action="run"` 启动命令,`action="process"` 使用 `processId` 查看、等待、输入、调整 PTY 或中断已有进程;内部 ProcessManager 可以继续保留更细的方法,但 Host 不再需要学习 `write_stdin`;
160
+ - `close_workspace` 成为唯一 workspace 关闭入口;checkout 直接释放,managed-worktree-backed Workspace 在同一接口内执行 BeforeWorktreeClose、commit/integrate/cleanup、AfterWorktreeClose 并关闭 Workspace;
161
+ - 从 canonical MCP surface 删除 `write_stdin` 与 `close_worktree`,同时清理对应 server instructions、fingerprint 和 capability guide 中的旧心智模型;
162
+ - 保留 `processId` 作为运行中进程的 opaque handle,保留 worktree 作为 Workspace 的可观察 backing metadata,而不是第二套 Host lifecycle。
128
163
 
129
- 0.3 不隐藏 callable tool,不增加隐式 autonomous workflow,也不把 Host Refresh/session 行为归到 ForgeRelay。`rename` 继续作为文件和目录 move/rename 的统一 primitive。
164
+ ### 0.3.5 Canonical MCP Surface 收口
165
+
166
+ 完成 0.3 的接口稳定化与真实 Host 验收:
167
+
168
+ - regular ForgeRelay MCP surface 收口为 9 个 canonical tools;`minimal/full` 不再通过增减 `grep/glob/ls` 改变主产品心智模型,搜索与目录检查可由 `bash` 承担;
169
+ - 评估并隔离 `codex` compatibility surface,使其作为明确 adapter 存在,而不是反向定义 ForgeRelay canonical interface;
170
+ - 删除已经完成迁移的 dedicated low-frequency tool aliases,确保新增 Capability 不再扩大常驻 tool count;
171
+ - 简化 fingerprint,使其用于版本/运行时能力摘要与 stale-Host 诊断,而不是重新枚举 tool implementation;
172
+ - 对 `open_workspace → catalog → capability describe/read/run`、managed worktree close、长进程 interaction、review/artifact capability、MCP App 与 stale-schema 情况做 7677 acceptance 和新 Host 会话验收;
173
+ - 0.3.5 通过后,0.3 的 MCP progressive-disclosure 主题视为完成,0.4 回到原定 LSP code intelligence v1。
174
+
175
+ 必要安全语义始终留在 Core tool interface、Capability contract 或自动 Hook report 中;渐进式披露不能成为隐藏权限、隐式 autonomous workflow 或绕过 allowed roots/auth 的机制。`rename` 继续作为文件和目录 move/rename 的统一 primitive。
130
176
 
131
177
  ## 0.4 — LSP code intelligence v1
132
178
 
@@ -151,20 +197,7 @@ Initial operations:
151
197
  - workspace symbols;
152
198
  - hover/type information.
153
199
 
154
- Prefer one deep MCP capability such as:
155
-
156
- ```text
157
- code_intelligence({
158
- workspaceId,
159
- operation,
160
- path,
161
- line,
162
- column,
163
- query
164
- })
165
- ```
166
-
167
- rather than one MCP tool per language or language-server method.
200
+ Expose code intelligence through the Capability Gateway established in 0.3 rather than adding another top-level MCP tool. A representative registered capability may look like `code.intelligence`, with its language-server operation/path/position/query fields carried inside the capability arguments. The exact LSP contract remains 0.4 work; the stable Core tool surface does not change per language or language-server method.
168
201
 
169
202
  Candidate servers include `typescript-language-server`/tsserver, Pyright,
170
203
  `rust-analyzer`, `gopls`, and `clangd`, but ForgeRelay should treat server
@@ -176,22 +209,7 @@ ForgeRelay already owns provider adapters and resumable local agent sessions.
176
209
  The next step is to remove the current `bash -> forgerelay agents ...` indirection
177
210
  for MCP hosts.
178
211
 
179
- A compact interface should reuse the existing provider adapter registry:
180
-
181
- ```text
182
- subagent({
183
- action: "run" | "list" | "show" | "cancel",
184
- workspaceId,
185
- profile,
186
- provider,
187
- prompt,
188
- agentId
189
- })
190
- ```
191
-
192
- The parent agent chooses an available provider/profile such as Codex or Claude.
193
- ForgeRelay launches, tracks, resumes, and cancels the provider-backed worker when
194
- the underlying provider supports those operations.
212
+ First-class subagent operations should reuse the Capability Gateway established in 0.3 rather than add another top-level MCP tool. The exact registered names, action semantics and provider/session contract remain 0.5 design work. The parent agent will continue choosing from available provider/profile metadata while ForgeRelay owns provider-backed worker lifecycle state.
195
213
 
196
214
  This is intentionally provider-backed delegation, not an attempt to emulate a
197
215
  host-native subagent implementation.
package/docs/setup.md CHANGED
@@ -120,7 +120,9 @@ npx @akira-tl/forgerelay doctor
120
120
  ```
121
121
 
122
122
  The doctor command reports the resolved config, Node runtime, platform, Git,
123
- Bash, public URL, allowed hosts, and native SQLite dependency status.
123
+ Bash, public URL, allowed hosts, native SQLite dependency status, and the MCP
124
+ shape ForgeRelay will expose: tool mode, widget mode, one-hop proxy trust, and
125
+ whether optional artifact, subagent, and Skill capabilities are enabled.
124
126
 
125
127
  ## Running from a local checkout
126
128
 
@@ -168,7 +168,9 @@ npm publishing token.
168
168
  git push origin v0.2.0
169
169
  ```
170
170
 
171
- The tag push is the publication action.
171
+ The tag push is the publication action. The release workflow publishes npm only after cloud CI passes, then extracts the matching `CHANGELOG.md` release section as the GitHub Release body. Keep `Unreleased` user-facing and structured (`Added`, `Changed`, `Fixed`, `Security`) because those notes are what users see on the Release page.
172
+
173
+ Project release Hooks match the stable tag-push command as a substring of the ForgeRelay shell request. A compound command is allowed: when `commandRegex` matches `git push origin vX.Y.Z`, the Hook receives that matched command as `FORGERELAY_HOOK_PAYLOAD.command` and retains the complete shell request as `originalCommand` when they differ.
172
174
 
173
175
  ## Attribution guardrails
174
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akira-tl/forgerelay",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Local development control plane for MCP coding agents.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/Akira-TL/forgerelay#readme",
@@ -45,6 +45,18 @@ const { env } = createDebugEnvironment({
45
45
  hookLog,
46
46
  widgets: "full",
47
47
  });
48
+ const doctor = spawnSync(process.execPath, ["--import", "tsx", "src/cli.ts", "doctor"], {
49
+ cwd: repoRoot,
50
+ env,
51
+ encoding: "utf8",
52
+ });
53
+ assert.equal(doctor.status, 0, doctor.stderr);
54
+ assert.match(doctor.stdout, /Public base URL: http:\/\/127\.0\.0\.1:7677/);
55
+ assert.match(doctor.stdout, /Tool mode: full/);
56
+ assert.match(doctor.stdout, /Widgets: full/);
57
+ assert.match(doctor.stdout, /Trust proxy: off/);
58
+ pass("doctor resolved MCP shape", "public URL + tool/widgets/proxy state");
59
+
48
60
  const server = spawn(process.execPath, ["--import", "tsx", "src/cli.ts", "serve"], {
49
61
  cwd: repoRoot,
50
62
  env,
@@ -161,7 +173,9 @@ try {
161
173
  method: "resources/list",
162
174
  params: {},
163
175
  }).message.result.resources;
164
- assert.ok(resources.some((resource) => resource.uri === templateUri));
176
+ const currentResource = resources.find((resource) => resource.uri === templateUri);
177
+ assert.ok(currentResource);
178
+ assert.equal(currentResource._meta?.ui?.domain, debugBaseUrl);
165
179
  assert.ok(resources.some((resource) => resource.uri === "ui://forgerelay/workspace-app.html"));
166
180
 
167
181
  const resourceTemplates = mcpRequest(oauth.accessToken, sessionId, {
@@ -185,6 +199,7 @@ try {
185
199
  assert.equal(template.uri, templateUri);
186
200
  assert.equal(template.mimeType, "text/html;profile=mcp-app");
187
201
  assert.match(template.text ?? "", /<script type="module" crossorigin src="[^"]+\/mcp-app-assets\//);
202
+ assert.equal(template._meta?.ui?.domain, debugBaseUrl);
188
203
  assert.ok(template._meta?.ui?.csp?.resourceDomains?.includes(debugBaseUrl));
189
204
  const scriptUrl = template.text?.match(/<script type="module" crossorigin src="([^"]+)"/)?.[1];
190
205
  assert.ok(scriptUrl);
@@ -655,8 +670,9 @@ function exerciseReleaseTagHooks(accessToken, sessionId) {
655
670
  [
656
671
  'import { writeFileSync } from "node:fs";',
657
672
  'const payload = process.env.FORGERELAY_HOOK_PAYLOAD ?? "{}";',
673
+ 'const parsed = JSON.parse(payload);',
658
674
  'writeFileSync("release-ci-ran.txt", payload);',
659
- 'if (JSON.parse(payload).command === "git push origin v0.2.1") process.exit(17);',
675
+ 'if (parsed.command === "git push origin v0.2.1") process.exit(17);',
660
676
  "",
661
677
  ].join("\n"),
662
678
  );
@@ -664,7 +680,7 @@ function exerciseReleaseTagHooks(accessToken, sessionId) {
664
680
  join(releaseProject, ".forgerelay", "hooks", "release-tag-local-ci.json"),
665
681
  JSON.stringify({
666
682
  event: "BeforeTool",
667
- matcher: { tool: "bash", commandRegex: "^git push origin v0\\.2\\.[01]$" },
683
+ matcher: { tool: "bash", commandRegex: "git push origin v0\\.2\\.[01]" },
668
684
  command: "node .forgerelay/release-check.mjs",
669
685
  timeoutSeconds: 30,
670
686
  report: true,
@@ -682,11 +698,17 @@ function exerciseReleaseTagHooks(accessToken, sessionId) {
682
698
 
683
699
  const pushed = callTool(accessToken, sessionId, 12, "bash", {
684
700
  workspaceId: releaseWorkspaceId,
685
- command: "git push origin v0.2.0",
701
+ command: "git status --short && git push origin v0.2.0 && echo release-pushed",
686
702
  });
687
703
  assert.equal(pushed.isError, undefined);
688
704
  assert.match(toolText(pushed), /release-tag-local-ci \(BeforeTool, project\) passed/);
689
705
  assert.ok(existsSync(join(releaseProject, "release-ci-ran.txt")));
706
+ assert.deepEqual(JSON.parse(readFileSync(join(releaseProject, "release-ci-ran.txt"), "utf8")), {
707
+ tool: "bash",
708
+ command: "git push origin v0.2.0",
709
+ workingDirectory: ".",
710
+ originalCommand: "git status --short && git push origin v0.2.0 && echo release-pushed",
711
+ });
690
712
  assert.equal(
691
713
  gitOutput(releaseRemote, ["rev-parse", "refs/tags/v0.2.0"], { gitDir: true }),
692
714
  gitOutput(releaseProject, ["rev-parse", "v0.2.0"]),
@@ -694,7 +716,7 @@ function exerciseReleaseTagHooks(accessToken, sessionId) {
694
716
 
695
717
  const blocked = callTool(accessToken, sessionId, 13, "bash", {
696
718
  workspaceId: releaseWorkspaceId,
697
- command: "git push origin v0.2.1",
719
+ command: "git status --short && git push origin v0.2.1 && echo should-not-run",
698
720
  });
699
721
  assert.equal(blocked.isError, true);
700
722
  assert.match(toolText(blocked), /release-tag-local-ci.*failed/);
@@ -46,8 +46,20 @@ switch (command) {
46
46
  await prepareRelease(state, incrementVersion(state.pkg.version, bump), dryRun);
47
47
  break;
48
48
  }
49
+ case "notes": {
50
+ checkState(state);
51
+ if (!value) fail("usage: node scripts/release-version.mjs notes vX.Y.Z");
52
+ const version = value.startsWith("v") ? value.slice(1) : value;
53
+ if (!stableVersionPattern.test(version)) {
54
+ fail(`release notes version ${JSON.stringify(value)} must be vX.Y.Z or X.Y.Z`);
55
+ }
56
+ const body = getReleaseBody(state.changelog, version);
57
+ if (!body) fail(`CHANGELOG.md has no release notes for ${version}`);
58
+ process.stdout.write(`${body}\n`);
59
+ break;
60
+ }
49
61
  default:
50
- fail(`unknown release command ${JSON.stringify(command)}; expected check, tag, or next`);
62
+ fail(`unknown release command ${JSON.stringify(command)}; expected check, tag, next, or notes`);
51
63
  }
52
64
 
53
65
  async function readState() {
@@ -182,6 +194,17 @@ function getUnreleasedBody(changelog) {
182
194
  return changelog.slice(bodyStart, bodyEnd).trim();
183
195
  }
184
196
 
197
+ function getReleaseBody(changelog, version) {
198
+ const heading = `## [${version}]`;
199
+ const headingIndex = changelog.indexOf(heading);
200
+ if (headingIndex < 0) return "";
201
+ const headingEnd = changelog.indexOf("\n", headingIndex);
202
+ const bodyStart = headingEnd < 0 ? changelog.length : headingEnd + 1;
203
+ const nextHeadingIndex = changelog.indexOf("\n## [", bodyStart);
204
+ const bodyEnd = nextHeadingIndex < 0 ? changelog.length : nextHeadingIndex;
205
+ return changelog.slice(bodyStart, bodyEnd).trim();
206
+ }
207
+
185
208
  function incrementVersion(version, bump) {
186
209
  const match = version.match(stableVersionPattern);
187
210
  if (!match) fail(`cannot increment invalid stable version ${JSON.stringify(version)}`);