dsh-plugin-dev-kb 1.6.0 → 1.8.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.
Files changed (622) hide show
  1. package/CHANGELOG.md +186 -141
  2. package/README.en.md +172 -155
  3. package/README.md +183 -163
  4. package/kb/INDEX.md +236 -234
  5. package/kb/README.md +88 -83
  6. package/kb/extra/AGENTS.md +77 -77
  7. package/kb/extra/cli-help.md +15 -7
  8. package/kb/extra/cli-help.zh.md +15 -7
  9. package/kb/extra/cookbook/adding-a-plugin-preview.md +18 -25
  10. package/kb/extra/cookbook/adding-a-plugin-preview.zh.md +18 -25
  11. package/kb/extra/cookbook/reviewing-persistence-type-changes.md +1 -1
  12. package/kb/extra/cookbook/reviewing-persistence-type-changes.zh.md +1 -1
  13. package/kb/extra/cookbook/reviewing-ui-design.md +166 -0
  14. package/kb/extra/cookbook/reviewing-ui-design.zh.md +166 -0
  15. package/kb/extra/deepseek-llm-api-wire-extensions.md +162 -162
  16. package/kb/extra/deepseek-llm-api-wire-extensions.zh.md +162 -162
  17. package/kb/extra/defensive-patterns/conversation-and-session.md +2 -2
  18. package/kb/extra/defensive-patterns/conversation-and-session.zh.md +2 -2
  19. package/kb/extra/defensive-patterns/general.md +2 -0
  20. package/kb/extra/defensive-patterns/general.zh.md +2 -0
  21. package/kb/extra/defensive-patterns/package-surface.md +233 -231
  22. package/kb/extra/defensive-patterns/package-surface.zh.md +233 -231
  23. package/kb/extra/defensive-patterns/remote-and-api.md +117 -115
  24. package/kb/extra/defensive-patterns/remote-and-api.zh.md +117 -115
  25. package/kb/extra/development.md +221 -214
  26. package/kb/extra/development.zh.md +228 -221
  27. package/kb/extra/event-producer-consumer.md +133 -110
  28. package/kb/extra/event-producer-consumer.zh.md +135 -112
  29. package/kb/extra/i18n/README.md +2 -0
  30. package/kb/extra/i18n/README.zh.md +2 -0
  31. package/kb/extra/module-graph.md +1961 -1776
  32. package/kb/extra/module-graph.zh.md +1963 -1778
  33. package/kb/extra/persistence-changes/2026-10-13-liveshare-share-viewer-principal.md +60 -0
  34. package/kb/extra/persistence-changes/2026-10-13-liveshare-share-viewer-principal.zh.md +60 -0
  35. package/kb/extra/persistence-changes/2026-10-19-session-team-mode.md +48 -0
  36. package/kb/extra/persistence-changes/2026-10-19-session-team-mode.zh.md +48 -0
  37. package/kb/extra/persistence-changes/2026-10-22-action-card-status.md +60 -0
  38. package/kb/extra/persistence-changes/2026-10-22-action-card-status.zh.md +60 -0
  39. package/kb/extra/persistence-changes/2026-10-25-skill-catalog-incomplete.md +60 -0
  40. package/kb/extra/persistence-changes/2026-10-25-skill-catalog-incomplete.zh.md +60 -0
  41. package/kb/extra/persistence-changes/2026-10-27-retry-control-input.md +60 -0
  42. package/kb/extra/persistence-changes/2026-10-27-retry-control-input.zh.md +60 -0
  43. package/kb/extra/persistence-changes/2026-10-27-subagent-settlement-attribution.md +60 -0
  44. package/kb/extra/persistence-changes/2026-10-27-subagent-settlement-attribution.zh.md +60 -0
  45. package/kb/extra/persistence-changes/2026-11-02-subagent-catalog-names.md +48 -0
  46. package/kb/extra/persistence-changes/2026-11-02-subagent-catalog-names.zh.md +48 -0
  47. package/kb/extra/persistence-changes/2026-11-02-team-task-owner-names.md +48 -0
  48. package/kb/extra/persistence-changes/2026-11-02-team-task-owner-names.zh.md +48 -0
  49. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.md +60 -0
  50. package/kb/extra/persistence-changes/2026-11-05-timeline-priority-notice.zh.md +60 -0
  51. package/kb/extra/persistence-changes/README.md +92 -90
  52. package/kb/extra/persistence-changes/README.zh.md +92 -90
  53. package/kb/extra/persistence-changes/historical-formats/README.md +75 -75
  54. package/kb/extra/persistence-changes/historical-formats/README.zh.md +75 -75
  55. package/kb/extra/persistence-changes/releases/README.md +103 -103
  56. package/kb/extra/persistence-changes/releases/README.zh.md +103 -103
  57. package/kb/extra/rescope.md +55 -53
  58. package/kb/extra/rescope.zh.md +55 -53
  59. package/kb/extra/subsystems/agent-team.md +38 -75
  60. package/kb/extra/subsystems/agent-team.zh.md +38 -75
  61. package/kb/extra/subsystems/attachment.md +36 -13
  62. package/kb/extra/subsystems/attachment.zh.md +36 -13
  63. package/kb/extra/subsystems/boot.md +631 -447
  64. package/kb/extra/subsystems/boot.zh.md +631 -447
  65. package/kb/extra/subsystems/computer-use.md +179 -59
  66. package/kb/extra/subsystems/computer-use.zh.md +179 -59
  67. package/kb/extra/subsystems/deliverables.md +2 -0
  68. package/kb/extra/subsystems/deliverables.zh.md +2 -0
  69. package/kb/extra/subsystems/extensions.md +387 -384
  70. package/kb/extra/subsystems/extensions.zh.md +387 -384
  71. package/kb/extra/subsystems/feedback.md +418 -400
  72. package/kb/extra/subsystems/feedback.zh.md +418 -400
  73. package/kb/extra/subsystems/forge.md +2169 -0
  74. package/kb/extra/subsystems/forge.zh.md +2171 -0
  75. package/kb/extra/subsystems/liveshare.md +167 -0
  76. package/kb/extra/subsystems/liveshare.zh.md +167 -0
  77. package/kb/extra/subsystems/mcp.md +237 -139
  78. package/kb/extra/subsystems/mcp.zh.md +237 -139
  79. package/kb/extra/subsystems/office-kit.md +122 -0
  80. package/kb/extra/subsystems/office-kit.zh.md +122 -0
  81. package/kb/extra/subsystems/working-directory.md +95 -64
  82. package/kb/extra/subsystems/working-directory.zh.md +95 -64
  83. package/kb/extra/subsystems/worktrees.md +187 -76
  84. package/kb/extra/subsystems/worktrees.zh.md +187 -76
  85. package/kb/extra/testing.md +1 -1
  86. package/kb/extra/testing.zh.md +1 -1
  87. package/kb/extra/ui-design-review-cases.md +445 -0
  88. package/kb/extra/ui-design-review-cases.zh.md +445 -0
  89. package/kb/extra/ui-radius.md +3 -1
  90. package/kb/extra/ui-radius.zh.md +3 -1
  91. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.md +21 -21
  92. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/python-ptc-sandbox/guide.zh.md +21 -21
  93. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/team-direct-inbox/guide.md +1 -1
  94. package/kb/extra/upgrade-guide/v0.2.1-alpha.1/team-direct-inbox/guide.zh.md +1 -1
  95. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.md +24 -0
  96. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md +24 -0
  97. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/plugin-manager-view-fields/guide.md +25 -0
  98. package/kb/extra/upgrade-guide/v0.2.1-alpha.2/plugin-manager-view-fields/guide.zh.md +25 -0
  99. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/model-switch-compaction/guide.md +30 -0
  100. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/model-switch-compaction/guide.zh.md +30 -0
  101. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/session-model-selection/guide.md +28 -0
  102. package/kb/extra/upgrade-guide/v0.2.1-alpha.4/session-model-selection/guide.zh.md +28 -0
  103. package/kb/extra/upgrade-guide/v0.2.1-rc.1/agent-instructions-chain-budgets/guide.md +24 -0
  104. package/kb/extra/upgrade-guide/v0.2.1-rc.1/agent-instructions-chain-budgets/guide.zh.md +24 -0
  105. package/kb/extra/upgrade-guide/v0.2.1-rc.1/subagent-control-tools/guide.md +23 -0
  106. package/kb/extra/upgrade-guide/v0.2.1-rc.1/subagent-control-tools/guide.zh.md +23 -0
  107. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-runtime-owner/guide.md +20 -0
  108. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-runtime-owner/guide.zh.md +20 -0
  109. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-team-subagents/guide.md +31 -0
  110. package/kb/extra/upgrade-guide/v0.2.1-rc.2/agent-team-subagents/guide.zh.md +31 -0
  111. package/kb/extra/upgrade-guide/v0.2.1-rc.2/approval-projection-dependency/guide.md +34 -0
  112. package/kb/extra/upgrade-guide/v0.2.1-rc.2/approval-projection-dependency/guide.zh.md +34 -0
  113. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-shutdown/guide.md +20 -0
  114. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-shutdown/guide.zh.md +20 -0
  115. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-user-sources/guide.md +18 -0
  116. package/kb/extra/upgrade-guide/v0.2.1-rc.2/auto-review-user-sources/guide.zh.md +18 -0
  117. package/kb/extra/upgrade-guide/v0.2.1-rc.2/built-in-japanese/guide.md +18 -0
  118. package/kb/extra/upgrade-guide/v0.2.1-rc.2/built-in-japanese/guide.zh.md +18 -0
  119. package/kb/extra/upgrade-guide/v0.2.1-rc.2/conditional-tools/guide.md +25 -0
  120. package/kb/extra/upgrade-guide/v0.2.1-rc.2/conditional-tools/guide.zh.md +25 -0
  121. package/kb/extra/upgrade-guide/v0.2.1-rc.2/context-menu-services/guide.md +23 -0
  122. package/kb/extra/upgrade-guide/v0.2.1-rc.2/context-menu-services/guide.zh.md +23 -0
  123. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-consent-storage/guide.md +22 -0
  124. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-consent-storage/guide.zh.md +22 -0
  125. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-preset-scope/guide.md +18 -0
  126. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-preset-scope/guide.zh.md +18 -0
  127. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-relative-coordinates/guide.md +17 -0
  128. package/kb/extra/upgrade-guide/v0.2.1-rc.2/cua-relative-coordinates/guide.zh.md +17 -0
  129. package/kb/extra/upgrade-guide/v0.2.1-rc.2/file-drag-callbacks/guide.md +19 -0
  130. package/kb/extra/upgrade-guide/v0.2.1-rc.2/file-drag-callbacks/guide.zh.md +19 -0
  131. package/kb/extra/upgrade-guide/v0.2.1-rc.2/headless-policy-composition/guide.md +27 -0
  132. package/kb/extra/upgrade-guide/v0.2.1-rc.2/headless-policy-composition/guide.zh.md +27 -0
  133. package/kb/extra/upgrade-guide/v0.2.1-rc.2/model-badge-package-removal/guide.md +18 -0
  134. package/kb/extra/upgrade-guide/v0.2.1-rc.2/model-badge-package-removal/guide.zh.md +18 -0
  135. package/kb/extra/upgrade-guide/v0.2.1-rc.2/new-session-blank-reuse/guide.md +22 -0
  136. package/kb/extra/upgrade-guide/v0.2.1-rc.2/new-session-blank-reuse/guide.zh.md +22 -0
  137. package/kb/extra/upgrade-guide/v0.2.1-rc.2/node-24/guide.md +17 -0
  138. package/kb/extra/upgrade-guide/v0.2.1-rc.2/node-24/guide.zh.md +17 -0
  139. package/kb/extra/upgrade-guide/v0.2.1-rc.2/official-bundle-lists/guide.md +18 -0
  140. package/kb/extra/upgrade-guide/v0.2.1-rc.2/official-bundle-lists/guide.zh.md +18 -0
  141. package/kb/extra/upgrade-guide/v0.2.1-rc.2/persistent-terminal-controls/guide.md +18 -0
  142. package/kb/extra/upgrade-guide/v0.2.1-rc.2/persistent-terminal-controls/guide.zh.md +18 -0
  143. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-default-capacities/guide.md +18 -0
  144. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-default-capacities/guide.zh.md +18 -0
  145. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-model-catalog/guide.md +53 -0
  146. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-model-catalog/guide.zh.md +53 -0
  147. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-protocol-replay/guide.md +30 -0
  148. package/kb/extra/upgrade-guide/v0.2.1-rc.2/pi-ai-protocol-replay/guide.zh.md +30 -0
  149. package/kb/extra/upgrade-guide/v0.2.1-rc.2/ptc-script-format/guide.md +20 -0
  150. package/kb/extra/upgrade-guide/v0.2.1-rc.2/ptc-script-format/guide.zh.md +20 -0
  151. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-desktop-context/guide.md +18 -0
  152. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-desktop-context/guide.zh.md +18 -0
  153. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-minimal-checkpoints/guide.md +18 -0
  154. package/kb/extra/upgrade-guide/v0.2.1-rc.2/sdk-minimal-checkpoints/guide.zh.md +18 -0
  155. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-projection-handles/guide.md +24 -0
  156. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-projection-handles/guide.zh.md +24 -0
  157. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-store-writes/guide.md +25 -0
  158. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-store-writes/guide.zh.md +25 -0
  159. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-team-mode/guide.md +22 -0
  160. package/kb/extra/upgrade-guide/v0.2.1-rc.2/session-team-mode/guide.zh.md +22 -0
  161. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-activation-options/guide.md +18 -0
  162. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-activation-options/guide.zh.md +18 -0
  163. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-service-methods/guide.md +19 -0
  164. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-service-methods/guide.zh.md +19 -0
  165. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-user-controls/guide.md +26 -0
  166. package/kb/extra/upgrade-guide/v0.2.1-rc.2/subagent-user-controls/guide.zh.md +26 -0
  167. package/kb/extra/upgrade-guide/v0.2.1-rc.2/tool-executor-plugins/guide.md +35 -0
  168. package/kb/extra/upgrade-guide/v0.2.1-rc.2/tool-executor-plugins/guide.zh.md +35 -0
  169. package/kb/extra/upgrade-guide/v0.2.1-rc.2/web-fetch-private-destinations/guide.md +21 -0
  170. package/kb/extra/upgrade-guide/v0.2.1-rc.2/web-fetch-private-destinations/guide.zh.md +21 -0
  171. package/kb/extra/upgrade-guide/v0.2.1-rc.2/webserver-index-peer/guide.md +17 -0
  172. package/kb/extra/upgrade-guide/v0.2.1-rc.2/webserver-index-peer/guide.zh.md +17 -0
  173. package/kb/extra/upgrade-guide/v0.2.1-rc.3/attachment-read-access/guide.md +23 -0
  174. package/kb/extra/upgrade-guide/v0.2.1-rc.3/attachment-read-access/guide.zh.md +23 -0
  175. package/kb/extra/upgrade-guide/v0.2.1-rc.3/computer-use-helper-permissions/guide.md +21 -0
  176. package/kb/extra/upgrade-guide/v0.2.1-rc.3/computer-use-helper-permissions/guide.zh.md +21 -0
  177. package/kb/extra/upgrade-guide/v0.2.1-rc.3/cua-bundle-id-consent/guide.md +20 -0
  178. package/kb/extra/upgrade-guide/v0.2.1-rc.3/cua-bundle-id-consent/guide.zh.md +20 -0
  179. package/kb/extra/upgrade-guide/v0.2.1-rc.3/generated-worktree-names/guide.md +20 -0
  180. package/kb/extra/upgrade-guide/v0.2.1-rc.3/generated-worktree-names/guide.zh.md +20 -0
  181. package/kb/extra/upgrade-guide/v0.2.1-rc.3/inbox-only-agent-wait/guide.md +19 -0
  182. package/kb/extra/upgrade-guide/v0.2.1-rc.3/inbox-only-agent-wait/guide.zh.md +19 -0
  183. package/kb/extra/upgrade-guide/v0.2.1-rc.3/independent-session-forks/guide.md +23 -0
  184. package/kb/extra/upgrade-guide/v0.2.1-rc.3/independent-session-forks/guide.zh.md +23 -0
  185. package/kb/extra/upgrade-guide/v0.2.1-rc.3/ptc-caller-cancellation/guide.md +20 -0
  186. package/kb/extra/upgrade-guide/v0.2.1-rc.3/ptc-caller-cancellation/guide.zh.md +20 -0
  187. package/kb/extra/upgrade-guide/v0.2.1-rc.3/session-follow-activation/guide.md +21 -0
  188. package/kb/extra/upgrade-guide/v0.2.1-rc.3/session-follow-activation/guide.zh.md +21 -0
  189. package/kb/extra/upgrade-guide/v0.2.1-rc.3/subagent-runtime-ownership/guide.md +21 -0
  190. package/kb/extra/upgrade-guide/v0.2.1-rc.3/subagent-runtime-ownership/guide.zh.md +21 -0
  191. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-mode-menu/guide.md +18 -0
  192. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-mode-menu/guide.zh.md +18 -0
  193. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-projection/guide.md +20 -0
  194. package/kb/extra/upgrade-guide/v0.2.1-rc.3/team-projection/guide.zh.md +20 -0
  195. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-file-downloads/guide.md +19 -0
  196. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-file-downloads/guide.zh.md +19 -0
  197. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-search-defaults/guide.md +18 -0
  198. package/kb/extra/upgrade-guide/v0.2.1-rc.3/web-search-defaults/guide.zh.md +18 -0
  199. package/kb/extra/upgrade-guide/v0.2.1-rc.4/model-listing-refresh/guide.md +22 -0
  200. package/kb/extra/upgrade-guide/v0.2.1-rc.4/model-listing-refresh/guide.zh.md +22 -0
  201. package/kb/extra/upgrade-guide/v0.2.1-rc.4/reasoning-body-props/guide.md +20 -0
  202. package/kb/extra/upgrade-guide/v0.2.1-rc.4/reasoning-body-props/guide.zh.md +20 -0
  203. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.md +18 -0
  204. package/kb/extra/upgrade-guide/v0.2.1-rc.4/sandbox-unsupported-policy-error/guide.zh.md +18 -0
  205. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/context-menu-target/guide.md +19 -0
  206. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/context-menu-target/guide.zh.md +19 -0
  207. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cordis-loader-entry-trees/guide.md +24 -0
  208. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cordis-loader-entry-trees/guide.zh.md +24 -0
  209. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/css-anchored-menus/guide.md +21 -0
  210. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/css-anchored-menus/guide.zh.md +21 -0
  211. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cua-source-dev-helper/guide.md +19 -0
  212. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/cua-source-dev-helper/guide.zh.md +19 -0
  213. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/desktop-stable-channel/guide.md +18 -0
  214. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/desktop-stable-channel/guide.zh.md +18 -0
  215. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-git-permissions/guide.md +21 -0
  216. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-git-permissions/guide.zh.md +21 -0
  217. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-worktree-entry/guide.md +29 -0
  218. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/forge-worktree-entry/guide.zh.md +29 -0
  219. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/fs-observation-policy-default-off/guide.md +29 -0
  220. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/fs-observation-policy-default-off/guide.zh.md +29 -0
  221. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.md +18 -0
  222. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-error-builtin-codes/guide.zh.md +18 -0
  223. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-request-purpose-declarations/guide.md +29 -0
  224. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/llm-request-purpose-declarations/guide.zh.md +29 -0
  225. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/pi-ai-request-image-count/guide.md +18 -0
  226. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/pi-ai-request-image-count/guide.zh.md +18 -0
  227. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-event-frames/guide.md +32 -0
  228. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-event-frames/guide.zh.md +32 -0
  229. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-released-checkpoint/guide.md +30 -0
  230. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-released-checkpoint/guide.zh.md +30 -0
  231. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-snapshot-scope/guide.md +19 -0
  232. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/projection-snapshot-scope/guide.zh.md +19 -0
  233. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/retained-ptc-timeout/guide.md +21 -0
  234. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/retained-ptc-timeout/guide.zh.md +21 -0
  235. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-agent-tools/guide.md +37 -0
  236. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-agent-tools/guide.zh.md +37 -0
  237. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-remote-host-tasks/guide.md +22 -0
  238. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/schedule-remote-host-tasks/guide.zh.md +22 -0
  239. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/sdk-run-commands/guide.md +24 -0
  240. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/sdk-run-commands/guide.zh.md +24 -0
  241. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/session-header-menu/guide.md +20 -0
  242. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/session-header-menu/guide.zh.md +20 -0
  243. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/subagent-explicit-reasoning/guide.md +20 -0
  244. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/subagent-explicit-reasoning/guide.zh.md +20 -0
  245. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.md +17 -0
  246. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-credential-modes/guide.zh.md +17 -0
  247. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-default-provider/guide.md +19 -0
  248. package/kb/extra/upgrade-guide/v0.2.2-alpha.2/web-search-default-provider/guide.zh.md +19 -0
  249. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/chat-process-activity-context/guide.md +18 -0
  250. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/chat-process-activity-context/guide.zh.md +18 -0
  251. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.md +34 -0
  252. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-kit-package/guide.zh.md +34 -0
  253. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.md +49 -0
  254. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-operation-tools/guide.zh.md +49 -0
  255. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.md +36 -0
  256. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/office-skill-resources/guide.zh.md +36 -0
  257. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/subagent-names/guide.md +29 -0
  258. package/kb/extra/upgrade-guide/v0.2.2-alpha.3/subagent-names/guide.zh.md +29 -0
  259. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.md +26 -0
  260. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-notification-fields/guide.zh.md +26 -0
  261. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.md +22 -0
  262. package/kb/extra/upgrade-guide/v0.2.2-rc.1/account-remote-provider/guide.zh.md +22 -0
  263. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.md +21 -0
  264. package/kb/extra/upgrade-guide/v0.2.2-rc.1/archive-worktrees/guide.zh.md +21 -0
  265. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.md +23 -0
  266. package/kb/extra/upgrade-guide/v0.2.2-rc.1/attachment-error-codes/guide.zh.md +23 -0
  267. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.md +20 -0
  268. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-ax-read-limits/guide.zh.md +20 -0
  269. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.md +18 -0
  270. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-hover-ax-only/guide.zh.md +18 -0
  271. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.md +23 -0
  272. package/kb/extra/upgrade-guide/v0.2.2-rc.1/cua-native-platform/guide.zh.md +23 -0
  273. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.md +35 -0
  274. package/kb/extra/upgrade-guide/v0.2.2-rc.1/dsh-doc-skill/guide.zh.md +35 -0
  275. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.md +26 -0
  276. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-change-request-overview/guide.zh.md +26 -0
  277. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.md +26 -0
  278. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-pinned-diff/guide.zh.md +26 -0
  279. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.md +19 -0
  280. package/kb/extra/upgrade-guide/v0.2.2-rc.1/forge-review-reads/guide.zh.md +19 -0
  281. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.md +26 -0
  282. package/kb/extra/upgrade-guide/v0.2.2-rc.1/package-export-cleanup/guide.zh.md +26 -0
  283. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.md +22 -0
  284. package/kb/extra/upgrade-guide/v0.2.2-rc.1/plugin-update-method/guide.zh.md +22 -0
  285. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.md +25 -0
  286. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-bootstrap-protocol/guide.zh.md +25 -0
  287. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.md +48 -0
  288. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-inspect-output/guide.zh.md +48 -0
  289. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.md +45 -0
  290. package/kb/extra/upgrade-guide/v0.2.2-rc.1/ptc-scoped-repl-default/guide.zh.md +45 -0
  291. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.md +19 -0
  292. package/kb/extra/upgrade-guide/v0.2.2-rc.1/runtime-context-reminders/guide.zh.md +19 -0
  293. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.md +17 -0
  294. package/kb/extra/upgrade-guide/v0.2.2-rc.1/session-append-overloads/guide.zh.md +17 -0
  295. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.md +27 -0
  296. package/kb/extra/upgrade-guide/v0.2.2-rc.1/subagent-interrupt-default/guide.zh.md +27 -0
  297. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.md +20 -0
  298. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-backend-cleanup-error/guide.zh.md +20 -0
  299. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.md +19 -0
  300. package/kb/extra/upgrade-guide/v0.2.2-rc.1/terminal-bundle-sidebar-backend/guide.zh.md +19 -0
  301. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.md +18 -0
  302. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-fetch-transport-error-codes/guide.zh.md +18 -0
  303. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.md +41 -0
  304. package/kb/extra/upgrade-guide/v0.2.2-rc.1/web-search-billing/guide.zh.md +41 -0
  305. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.md +21 -0
  306. package/kb/extra/upgrade-guide/v0.2.2-rc.1/window-drag-regions/guide.zh.md +21 -0
  307. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.md +29 -0
  308. package/kb/extra/upgrade-guide/v0.2.2-rc.2/client-module-metadata/guide.zh.md +29 -0
  309. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.md +25 -0
  310. package/kb/extra/upgrade-guide/v0.2.2-rc.2/connection-page-peer/guide.zh.md +25 -0
  311. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.md +31 -0
  312. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cordis-root-and-intercept-metadata/guide.zh.md +31 -0
  313. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.md +24 -0
  314. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-agents-without-preset/guide.zh.md +24 -0
  315. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.md +24 -0
  316. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-macos-provider/guide.zh.md +24 -0
  317. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.md +19 -0
  318. package/kb/extra/upgrade-guide/v0.2.2-rc.2/cua-partial-observations/guide.zh.md +19 -0
  319. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.md +15 -0
  320. package/kb/extra/upgrade-guide/v0.2.2-rc.2/deepseek-files-timeout/guide.zh.md +15 -0
  321. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.md +28 -0
  322. package/kb/extra/upgrade-guide/v0.2.2-rc.2/experimental-tool-error-codes/guide.zh.md +28 -0
  323. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.md +36 -0
  324. package/kb/extra/upgrade-guide/v0.2.2-rc.2/package-export-cleanup/guide.zh.md +36 -0
  325. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.md +22 -0
  326. package/kb/extra/upgrade-guide/v0.2.2-rc.2/python-ptc-removal/guide.zh.md +22 -0
  327. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.md +31 -0
  328. package/kb/extra/upgrade-guide/v0.2.2-rc.2/session-status-package/guide.zh.md +31 -0
  329. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.md +18 -0
  330. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shared-search-filter/guide.zh.md +18 -0
  331. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.md +30 -0
  332. package/kb/extra/upgrade-guide/v0.2.2-rc.2/shell-fs-tool-error-codes/guide.zh.md +30 -0
  333. package/kb/extra/web-styling.md +57 -39
  334. package/kb/extra/web-styling.zh.md +57 -39
  335. package/kb/meta/search-index.json +4508 -3806
  336. package/kb/meta/source.json +18 -14
  337. package/kb/site/develop/cordis-tutorial/04-events.md +1 -1
  338. package/kb/site/develop/cordis-tutorial/07-into-the-harness.md +5 -4
  339. package/kb/site/develop/framework/events.md +1 -1
  340. package/kb/site/develop/practice/dynamic-cordis.md +1 -1
  341. package/kb/site/develop/practice/llm-adapter.md +192 -192
  342. package/kb/site/en/develop/cordis-tutorial/04-events.md +1 -1
  343. package/kb/site/en/develop/cordis-tutorial/07-into-the-harness.md +5 -4
  344. package/kb/site/en/develop/framework/events.md +1 -1
  345. package/kb/site/en/develop/practice/dynamic-cordis.md +1 -1
  346. package/kb/site/en/develop/practice/llm-adapter.md +192 -192
  347. package/kb/site/en/guide/desktop-uninstall-cleanup.md +63 -0
  348. package/kb/site/en/guide/network-proxy.md +1 -1
  349. package/kb/site/en/guide/plugin-market.md +153 -151
  350. package/kb/site/en/guide/providers.md +234 -230
  351. package/kb/site/en/guide/python-sdk.md +17 -2
  352. package/kb/site/en/guide/quickstart.md +35 -34
  353. package/kb/site/en/guide/schedule.md +45 -26
  354. package/kb/site/en/reference/agent-lifecycle.md +3 -1
  355. package/kb/site/en/reference/api-gateway.md +4 -4
  356. package/kb/site/en/reference/capability-seams.md +789 -719
  357. package/kb/site/en/reference/config-catalog.md +5432 -4806
  358. package/kb/site/en/reference/cookbook/adding-a-package.md +175 -173
  359. package/kb/site/en/reference/cookbook/adding-a-tool.md +105 -104
  360. package/kb/site/en/reference/cookbook/extension-cookbook.md +178 -135
  361. package/kb/site/en/reference/cordis-api/context.md +373 -369
  362. package/kb/site/en/reference/cordis-api/events.md +9 -9
  363. package/kb/site/en/reference/cordis-api/fiber.md +457 -380
  364. package/kb/site/en/reference/cordis-api/inherited.md +44 -43
  365. package/kb/site/en/reference/cordis-api/service.md +118 -107
  366. package/kb/site/en/reference/experimental-persistence-catalog.md +36 -20
  367. package/kb/site/en/reference/index.md +174 -168
  368. package/kb/site/en/reference/persistence-catalog.md +9453 -9146
  369. package/kb/site/en/reference/subsystems/client-modules.md +19 -11
  370. package/kb/site/en/reference/subsystems/compaction.md +288 -288
  371. package/kb/site/en/reference/subsystems/conversation.md +2 -0
  372. package/kb/site/en/reference/subsystems/core.md +1172 -1117
  373. package/kb/site/en/reference/subsystems/credentials.md +526 -497
  374. package/kb/site/en/reference/subsystems/filesystem.md +708 -534
  375. package/kb/site/en/reference/subsystems/index.md +82 -80
  376. package/kb/site/en/reference/subsystems/llm-streaming.md +1290 -1200
  377. package/kb/site/en/reference/subsystems/lsp.md +230 -206
  378. package/kb/site/en/reference/subsystems/persistence.md +451 -422
  379. package/kb/site/en/reference/subsystems/plan.md +91 -91
  380. package/kb/site/en/reference/subsystems/ptc-runtime.md +295 -254
  381. package/kb/site/en/reference/subsystems/sandbox.md +250 -225
  382. package/kb/site/en/reference/subsystems/schedule.md +194 -430
  383. package/kb/site/en/reference/subsystems/session-projection.md +186 -44
  384. package/kb/site/en/reference/subsystems/session-query.md +525 -515
  385. package/kb/site/en/reference/subsystems/session-reference.md +231 -228
  386. package/kb/site/en/reference/subsystems/session.md +1478 -1343
  387. package/kb/site/en/reference/subsystems/sidebar-right.md +165 -164
  388. package/kb/site/en/reference/subsystems/skills.md +356 -356
  389. package/kb/site/en/reference/subsystems/slots.md +235 -204
  390. package/kb/site/en/reference/subsystems/storage.md +26 -9
  391. package/kb/site/en/reference/subsystems/subagent.md +119 -102
  392. package/kb/site/en/reference/subsystems/system-prompt.md +13 -11
  393. package/kb/site/en/reference/subsystems/terminal.md +188 -188
  394. package/kb/site/en/reference/subsystems/token-meter.md +45 -0
  395. package/kb/site/en/reference/subsystems/tools.md +902 -751
  396. package/kb/site/en/reference/subsystems/typert.md +21 -11
  397. package/kb/site/en/reference/subsystems/user-questions.md +330 -311
  398. package/kb/site/en/reference/subsystems/web-client.md +161 -104
  399. package/kb/site/en/reference/subsystems/web-server.md +434 -306
  400. package/kb/site/en/reference/subsystems/web.md +268 -210
  401. package/kb/site/en/reference/subsystems/workflow.md +287 -282
  402. package/kb/site/en/reference/subsystems/workspace.md +743 -651
  403. package/kb/site/en/reference/tool-catalog.md +2867 -2829
  404. package/kb/site/en/reference/tool-execution-pipeline.md +5 -4
  405. package/kb/site/guide/desktop-uninstall-cleanup.md +63 -0
  406. package/kb/site/guide/network-proxy.md +1 -1
  407. package/kb/site/guide/plugin-market.md +153 -151
  408. package/kb/site/guide/providers.md +234 -230
  409. package/kb/site/guide/python-sdk.md +17 -2
  410. package/kb/site/guide/quickstart.md +35 -34
  411. package/kb/site/guide/schedule.md +45 -26
  412. package/kb/site/reference/agent-lifecycle.md +3 -1
  413. package/kb/site/reference/api-gateway.md +4 -4
  414. package/kb/site/reference/capability-seams.md +789 -719
  415. package/kb/site/reference/config-catalog.md +5432 -4806
  416. package/kb/site/reference/cookbook/adding-a-package.md +175 -173
  417. package/kb/site/reference/cookbook/adding-a-tool.md +107 -106
  418. package/kb/site/reference/cookbook/extension-cookbook.md +182 -139
  419. package/kb/site/reference/cordis-api/context.md +373 -369
  420. package/kb/site/reference/cordis-api/events.md +9 -9
  421. package/kb/site/reference/cordis-api/fiber.md +459 -380
  422. package/kb/site/reference/cordis-api/inherited.md +44 -43
  423. package/kb/site/reference/cordis-api/service.md +118 -107
  424. package/kb/site/reference/experimental-persistence-catalog.md +36 -20
  425. package/kb/site/reference/index.md +178 -172
  426. package/kb/site/reference/persistence-catalog.md +9453 -9146
  427. package/kb/site/reference/subsystems/client-modules.md +19 -11
  428. package/kb/site/reference/subsystems/compaction.md +288 -288
  429. package/kb/site/reference/subsystems/conversation.md +4 -0
  430. package/kb/site/reference/subsystems/core.md +1184 -1129
  431. package/kb/site/reference/subsystems/credentials.md +526 -497
  432. package/kb/site/reference/subsystems/filesystem.md +708 -534
  433. package/kb/site/reference/subsystems/index.md +82 -80
  434. package/kb/site/reference/subsystems/llm-streaming.md +1296 -1206
  435. package/kb/site/reference/subsystems/lsp.md +230 -206
  436. package/kb/site/reference/subsystems/persistence.md +451 -422
  437. package/kb/site/reference/subsystems/plan.md +91 -91
  438. package/kb/site/reference/subsystems/ptc-runtime.md +295 -254
  439. package/kb/site/reference/subsystems/sandbox.md +250 -225
  440. package/kb/site/reference/subsystems/schedule.md +197 -433
  441. package/kb/site/reference/subsystems/session-projection.md +186 -44
  442. package/kb/site/reference/subsystems/session-query.md +525 -515
  443. package/kb/site/reference/subsystems/session-reference.md +231 -228
  444. package/kb/site/reference/subsystems/session.md +1482 -1347
  445. package/kb/site/reference/subsystems/sidebar-right.md +165 -164
  446. package/kb/site/reference/subsystems/skills.md +356 -356
  447. package/kb/site/reference/subsystems/slots.md +239 -208
  448. package/kb/site/reference/subsystems/storage.md +26 -9
  449. package/kb/site/reference/subsystems/subagent.md +119 -102
  450. package/kb/site/reference/subsystems/system-prompt.md +13 -11
  451. package/kb/site/reference/subsystems/terminal.md +188 -188
  452. package/kb/site/reference/subsystems/token-meter.md +45 -0
  453. package/kb/site/reference/subsystems/tools.md +902 -751
  454. package/kb/site/reference/subsystems/typert.md +21 -11
  455. package/kb/site/reference/subsystems/user-questions.md +330 -311
  456. package/kb/site/reference/subsystems/web-client.md +161 -104
  457. package/kb/site/reference/subsystems/web-server.md +434 -306
  458. package/kb/site/reference/subsystems/web.md +268 -210
  459. package/kb/site/reference/subsystems/workflow.md +287 -282
  460. package/kb/site/reference/subsystems/workspace.md +743 -651
  461. package/kb/site/reference/tool-catalog.md +2872 -2835
  462. package/kb/site/reference/tool-execution-pipeline.md +4 -3
  463. package/lib/index.js +359 -244
  464. package/lib/kb-version.js +118 -0
  465. package/package.json +68 -66
  466. package/scripts/refresh-kb.mjs +153 -0
  467. package/scripts/selfcheck.mjs +18 -0
  468. package/scripts/smoke.mjs +77 -0
  469. package/skills/dsh-plugin-dev-kb.md +71 -69
  470. package/skills/dsh-plugin-starter.md +65 -0
  471. package/skills/dsh-upgrade-assistant.md +62 -0
  472. package/kb/extra/agent-lifecycle.md +0 -91
  473. package/kb/extra/agent-lifecycle.zh.md +0 -93
  474. package/kb/extra/api-gateway.md +0 -172
  475. package/kb/extra/api-gateway.zh.md +0 -178
  476. package/kb/extra/architecture.md +0 -165
  477. package/kb/extra/architecture.zh.md +0 -169
  478. package/kb/extra/capability-seams.md +0 -714
  479. package/kb/extra/capability-seams.zh.md +0 -716
  480. package/kb/extra/config-catalog.md +0 -4801
  481. package/kb/extra/config-catalog.zh.md +0 -4803
  482. package/kb/extra/cookbook/adding-a-package.md +0 -170
  483. package/kb/extra/cookbook/adding-a-package.zh.md +0 -170
  484. package/kb/extra/cookbook/adding-a-settings-card.md +0 -72
  485. package/kb/extra/cookbook/adding-a-settings-card.zh.md +0 -72
  486. package/kb/extra/cookbook/adding-a-tool.md +0 -101
  487. package/kb/extra/cookbook/adding-a-tool.zh.md +0 -103
  488. package/kb/extra/cookbook/adding-an-llm-adapter.md +0 -43
  489. package/kb/extra/cookbook/adding-an-llm-adapter.zh.md +0 -43
  490. package/kb/extra/cookbook/extension-cookbook.md +0 -132
  491. package/kb/extra/cookbook/extension-cookbook.zh.md +0 -136
  492. package/kb/extra/cordis-api/context.md +0 -364
  493. package/kb/extra/cordis-api/context.zh.md +0 -366
  494. package/kb/extra/cordis-api/events.md +0 -207
  495. package/kb/extra/cordis-api/events.zh.md +0 -209
  496. package/kb/extra/cordis-api/fiber.md +0 -375
  497. package/kb/extra/cordis-api/fiber.zh.md +0 -377
  498. package/kb/extra/cordis-api/inherited.md +0 -38
  499. package/kb/extra/cordis-api/registry.md +0 -152
  500. package/kb/extra/cordis-api/registry.zh.md +0 -154
  501. package/kb/extra/cordis-api/service.md +0 -102
  502. package/kb/extra/cordis-api/service.zh.md +0 -104
  503. package/kb/extra/cordis-tutorial/01-first-plugin.md +0 -95
  504. package/kb/extra/cordis-tutorial/01-first-plugin.zh.md +0 -95
  505. package/kb/extra/cordis-tutorial/02-lifecycle-and-effects.md +0 -98
  506. package/kb/extra/cordis-tutorial/02-lifecycle-and-effects.zh.md +0 -98
  507. package/kb/extra/cordis-tutorial/03-services.md +0 -98
  508. package/kb/extra/cordis-tutorial/03-services.zh.md +0 -98
  509. package/kb/extra/cordis-tutorial/04-events.md +0 -144
  510. package/kb/extra/cordis-tutorial/04-events.zh.md +0 -144
  511. package/kb/extra/cordis-tutorial/05-config.md +0 -111
  512. package/kb/extra/cordis-tutorial/05-config.zh.md +0 -111
  513. package/kb/extra/cordis-tutorial/06-composition-and-hmr.md +0 -113
  514. package/kb/extra/cordis-tutorial/06-composition-and-hmr.zh.md +0 -113
  515. package/kb/extra/cordis-tutorial/07-into-the-harness.md +0 -108
  516. package/kb/extra/cordis-tutorial/07-into-the-harness.zh.md +0 -108
  517. package/kb/extra/cordis-tutorial/index.md +0 -60
  518. package/kb/extra/cordis-tutorial/index.zh.md +0 -62
  519. package/kb/extra/experimental-persistence-catalog.md +0 -17
  520. package/kb/extra/experimental-persistence-catalog.zh.md +0 -17
  521. package/kb/extra/persistence-catalog.md +0 -9140
  522. package/kb/extra/persistence-catalog.zh.md +0 -9142
  523. package/kb/extra/subsystems/README.md +0 -76
  524. package/kb/extra/subsystems/README.zh.md +0 -76
  525. package/kb/extra/subsystems/approval.md +0 -170
  526. package/kb/extra/subsystems/approval.zh.md +0 -170
  527. package/kb/extra/subsystems/client-modules.md +0 -198
  528. package/kb/extra/subsystems/client-modules.zh.md +0 -198
  529. package/kb/extra/subsystems/client-resources.md +0 -92
  530. package/kb/extra/subsystems/client-resources.zh.md +0 -92
  531. package/kb/extra/subsystems/commands.md +0 -223
  532. package/kb/extra/subsystems/commands.zh.md +0 -223
  533. package/kb/extra/subsystems/compaction.md +0 -284
  534. package/kb/extra/subsystems/compaction.zh.md +0 -284
  535. package/kb/extra/subsystems/conversation.md +0 -301
  536. package/kb/extra/subsystems/conversation.zh.md +0 -303
  537. package/kb/extra/subsystems/core.md +0 -1113
  538. package/kb/extra/subsystems/core.zh.md +0 -1125
  539. package/kb/extra/subsystems/credentials.md +0 -493
  540. package/kb/extra/subsystems/credentials.zh.md +0 -493
  541. package/kb/extra/subsystems/filesystem.md +0 -530
  542. package/kb/extra/subsystems/filesystem.zh.md +0 -530
  543. package/kb/extra/subsystems/goal.md +0 -313
  544. package/kb/extra/subsystems/goal.zh.md +0 -313
  545. package/kb/extra/subsystems/jobs.md +0 -554
  546. package/kb/extra/subsystems/jobs.zh.md +0 -554
  547. package/kb/extra/subsystems/llm-streaming.md +0 -1196
  548. package/kb/extra/subsystems/llm-streaming.zh.md +0 -1202
  549. package/kb/extra/subsystems/lsp.md +0 -202
  550. package/kb/extra/subsystems/lsp.zh.md +0 -202
  551. package/kb/extra/subsystems/office-to-pdf.md +0 -87
  552. package/kb/extra/subsystems/office-to-pdf.zh.md +0 -87
  553. package/kb/extra/subsystems/permission-presets.md +0 -167
  554. package/kb/extra/subsystems/permission-presets.zh.md +0 -167
  555. package/kb/extra/subsystems/persistence.md +0 -418
  556. package/kb/extra/subsystems/persistence.zh.md +0 -418
  557. package/kb/extra/subsystems/plan.md +0 -87
  558. package/kb/extra/subsystems/plan.zh.md +0 -87
  559. package/kb/extra/subsystems/ptc-runtime.md +0 -250
  560. package/kb/extra/subsystems/ptc-runtime.zh.md +0 -250
  561. package/kb/extra/subsystems/sandbox.md +0 -221
  562. package/kb/extra/subsystems/sandbox.zh.md +0 -221
  563. package/kb/extra/subsystems/schedule.md +0 -550
  564. package/kb/extra/subsystems/schedule.zh.md +0 -550
  565. package/kb/extra/subsystems/scope.md +0 -59
  566. package/kb/extra/subsystems/scope.zh.md +0 -61
  567. package/kb/extra/subsystems/session-projection.md +0 -356
  568. package/kb/extra/subsystems/session-projection.zh.md +0 -356
  569. package/kb/extra/subsystems/session-query.md +0 -511
  570. package/kb/extra/subsystems/session-query.zh.md +0 -511
  571. package/kb/extra/subsystems/session-reference.md +0 -224
  572. package/kb/extra/subsystems/session-reference.zh.md +0 -224
  573. package/kb/extra/subsystems/session-telemetry.md +0 -212
  574. package/kb/extra/subsystems/session-telemetry.zh.md +0 -212
  575. package/kb/extra/subsystems/session-title.md +0 -213
  576. package/kb/extra/subsystems/session-title.zh.md +0 -213
  577. package/kb/extra/subsystems/session.md +0 -1339
  578. package/kb/extra/subsystems/session.zh.md +0 -1343
  579. package/kb/extra/subsystems/settings.md +0 -155
  580. package/kb/extra/subsystems/settings.zh.md +0 -155
  581. package/kb/extra/subsystems/shell.md +0 -314
  582. package/kb/extra/subsystems/shell.zh.md +0 -314
  583. package/kb/extra/subsystems/sidebar-right.md +0 -160
  584. package/kb/extra/subsystems/sidebar-right.zh.md +0 -160
  585. package/kb/extra/subsystems/skills.md +0 -352
  586. package/kb/extra/subsystems/skills.zh.md +0 -352
  587. package/kb/extra/subsystems/slots.md +0 -200
  588. package/kb/extra/subsystems/slots.zh.md +0 -204
  589. package/kb/extra/subsystems/spill.md +0 -124
  590. package/kb/extra/subsystems/spill.zh.md +0 -124
  591. package/kb/extra/subsystems/storage.md +0 -259
  592. package/kb/extra/subsystems/storage.zh.md +0 -259
  593. package/kb/extra/subsystems/subagent.md +0 -686
  594. package/kb/extra/subsystems/subagent.zh.md +0 -688
  595. package/kb/extra/subsystems/subprocess.md +0 -321
  596. package/kb/extra/subsystems/subprocess.zh.md +0 -321
  597. package/kb/extra/subsystems/system-prompt.md +0 -254
  598. package/kb/extra/subsystems/system-prompt.zh.md +0 -254
  599. package/kb/extra/subsystems/terminal.md +0 -184
  600. package/kb/extra/subsystems/terminal.zh.md +0 -184
  601. package/kb/extra/subsystems/token-meter.md +0 -106
  602. package/kb/extra/subsystems/token-meter.zh.md +0 -106
  603. package/kb/extra/subsystems/tools.md +0 -747
  604. package/kb/extra/subsystems/tools.zh.md +0 -747
  605. package/kb/extra/subsystems/typert.md +0 -690
  606. package/kb/extra/subsystems/typert.zh.md +0 -690
  607. package/kb/extra/subsystems/user-questions.md +0 -307
  608. package/kb/extra/subsystems/user-questions.zh.md +0 -307
  609. package/kb/extra/subsystems/web-client.md +0 -100
  610. package/kb/extra/subsystems/web-client.zh.md +0 -100
  611. package/kb/extra/subsystems/web-server.md +0 -302
  612. package/kb/extra/subsystems/web-server.zh.md +0 -302
  613. package/kb/extra/subsystems/web.md +0 -206
  614. package/kb/extra/subsystems/web.zh.md +0 -206
  615. package/kb/extra/subsystems/workflow.md +0 -278
  616. package/kb/extra/subsystems/workflow.zh.md +0 -278
  617. package/kb/extra/subsystems/workspace.md +0 -647
  618. package/kb/extra/subsystems/workspace.zh.md +0 -647
  619. package/kb/extra/tool-catalog.md +0 -2824
  620. package/kb/extra/tool-catalog.zh.md +0 -2832
  621. package/kb/extra/tool-execution-pipeline.md +0 -65
  622. package/kb/extra/tool-execution-pipeline.zh.md +0 -67
@@ -0,0 +1,2171 @@
1
+ # Forges
2
+
3
+ [English](forge.md) | 中文
4
+
5
+ 实验性的 forge 能力 seam 从代码托管平台读取变更请求(change request,即 pull request 与 merge request)。[`dsh-experimental-forge`](../../packages/experimental/forge/README.zh.md) 是 Service Definition,提供 `ctx.forge`;[`dsh-experimental-forge-github`](../../packages/experimental/forge-github/README.zh.md) 是服务 GitHub 主机的 Service Provider;[`dsh-experimental-forge-session`](../../packages/experimental/forge-session/README.zh.md) 是把变更请求绑定到 Session 的 Consumer,提供 `ctx.forgeSession`;[`dsh-experimental-client-ui-forge`](../../packages/experimental/client-ui-forge/README.zh.md) 是提供 `ctx.forgePanel` 的 GUI Consumer。默认禁用的 [forge Bundle](../../packages/experimental/forge-bundle/README.zh.md) 可从插件页面组合这四个包,同时加载[工作树模型工具](../../packages/experimental/tool-worktree/README.zh.md),并为面板附带一个隔离的 [worktree 服务](../../packages/experimental/worktree/README.zh.md);除此之外,它们只能通过显式组合加载。
6
+
7
+ ## 提供方与变更请求
8
+
9
+ 一个提供方服务一个 forge 家族,例如 `github`。它把 Git 远端 URL 映射为仓库,把变更请求 URL 映射为引用,构造规范的变更请求 URL,按 head 分支查找打开状态的变更请求,并批量读取状态。`changeRequestKey` 从引用派生一个不区分大小写的键,因此 URL 拼写不同的监听方共享同一个轮询循环。
10
+
11
+ ```ts type-equiv
12
+ /** One repository on a code host, identified the way its provider addresses it. */
13
+ interface ForgeRepository {
14
+ /** Provider family that serves the repository, such as `github`. */
15
+ readonly forge: string
16
+ /** Lowercase host name, such as `github.com`. */
17
+ readonly host: string
18
+ /** Owner or namespace path as the host spells it. */
19
+ readonly owner: string
20
+ /** Repository name as the host spells it. */
21
+ readonly name: string
22
+ }
23
+ ```
24
+
25
+ ```ts type-equiv
26
+ /** One change request (pull request or merge request) in a repository. */
27
+ interface ChangeRequestRef {
28
+ /** Repository that holds the change request. */
29
+ readonly repository: ForgeRepository
30
+ /** Host-assigned change request number. */
31
+ readonly number: number
32
+ }
33
+ ```
34
+
35
+ ```ts type-equiv
36
+ /** Canonical identity of a change request across providers; built by `changeRequestKey`. */
37
+ type ChangeRequestKey = Branded<'ChangeRequestKey'>
38
+ ```
39
+
40
+ ```ts type-equiv
41
+ /**
42
+ * Host-specific access registered with `ctx.forge`. One provider serves one
43
+ * forge family; methods that take a signal must stop work when it aborts.
44
+ */
45
+ interface ForgeProvider {
46
+ /** Forge family name stored in every repository this provider returns. */
47
+ readonly forge: string
48
+ /** Publish a comment or completed review. Omission declares that this provider cannot write reviews. */
49
+ submitReview?(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
50
+ /**
51
+ * Read the review threads of a change request at head commit `headSha`. The threads are returned only when the
52
+ * read names `headSha` as the head; once the head is another commit, the read resolves to a `stale` failure.
53
+ * Omission declares that this provider cannot read reviews.
54
+ */
55
+ readReview?(ref: ChangeRequestRef, headSha: string, signal: AbortSignal): Promise<ForgeReviewData | ForgeFailure>
56
+ /**
57
+ * Write to the review threads or the pending review of a change request while its head is `write.headSha`; once the
58
+ * head is another commit, the write resolves to `stale` without writing. A write is never retried. Omission declares
59
+ * that this provider cannot write reviews, and its `readReview` then reports no viewer permission.
60
+ */
61
+ writeReview?(ref: ChangeRequestRef, write: ForgeReviewWrite, signal: AbortSignal): Promise<ForgeReviewWriteResult>
62
+ /** Map a Git remote URL to its repository, or undefined when this provider does not serve it. */
63
+ repositoryFromRemote(url: string): ForgeRepository | undefined
64
+ /** Map a change request web URL to its reference, or undefined when this provider does not serve it. */
65
+ changeRequestFromUrl(url: string): ChangeRequestRef | undefined
66
+ /** Build the canonical web URL of a change request this provider serves. */
67
+ changeRequestUrl(ref: ChangeRequestRef): string
68
+ /** Read the status of several change requests, returning one result per requested key. */
69
+ fetch(
70
+ refs: readonly ChangeRequestRef[],
71
+ signal: AbortSignal,
72
+ ): Promise<ReadonlyMap<ChangeRequestKey, ChangeRequestSnapshot | ForgeFailure>>
73
+ /** Read all checks for one change request on demand; omission declares that only the polling preview is available. */
74
+ fetchChecks?(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestSnapshot | ForgeFailure>
75
+ /** Find open change requests whose head is `branch` in `repository`, excluding the default branch and forks. */
76
+ findByHead(repository: ForgeRepository, branch: string, signal: AbortSignal): Promise<readonly ChangeRequestRef[]>
77
+ /** Report whether the provider can reach `host` with current credentials. */
78
+ readiness(host: string, signal: AbortSignal): Promise<ForgeReadiness>
79
+ /** Mark a draft change request ready for review, resolving to undefined once the host accepted it. */
80
+ markReady(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
81
+ /** Merge a change request while its head is still `request.headSha`, resolving to undefined once merged. */
82
+ merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
83
+ /**
84
+ * Read the changes of a change request at head commit `headSha` as the host computes them, as one unified
85
+ * patch with `a/` and `b/` path prefixes. A patch is returned only when it describes `headSha`; once the
86
+ * head is another commit, the read resolves to a `stale` failure. `base`, when given, is the `baseSha` the
87
+ * latest status recorded with `headSha`; a provider may start reading from it before it confirms the head.
88
+ */
89
+ diff(ref: ChangeRequestRef, headSha: string, signal: AbortSignal, base?: string): Promise<string | ForgeFailure>
90
+ /** Read the text of `path` at `commit` in the change request's repository. */
91
+ fileText(ref: ChangeRequestRef, commit: string, path: string, signal: AbortSignal): Promise<string | ForgeFailure>
92
+ /** Build the web page of `path` at `commit` in the change request's repository. */
93
+ fileUrl(ref: ChangeRequestRef, commit: string, path: string): string
94
+ /**
95
+ * List the commits of a change request at its current head. A provider implements `commits` and `compare`
96
+ * together; omitting either declares that the change request can be read only as a whole.
97
+ */
98
+ commits?(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeCommitList | ForgeFailure>
99
+ /**
100
+ * Read the changes from commit `base` to commit `head` in the change request's repository, as one unified patch
101
+ * with `a/` and `b/` path prefixes. Both are full object names; `head` descends from `base`.
102
+ */
103
+ compare?(ref: ChangeRequestRef, base: string, head: string, signal: AbortSignal): Promise<string | ForgeFailure>
104
+ /**
105
+ * Find the merge base of commits `base` and `head` in the change request's repository, as a full object name: the
106
+ * commit whose files the old side of a change request's diff shows. Omission declares that the provider cannot name
107
+ * it, so readers of the old side get `unsupported`.
108
+ */
109
+ mergeBase?(ref: ChangeRequestRef, base: string, head: string, signal: AbortSignal): Promise<string | ForgeFailure>
110
+ /**
111
+ * Read the signed-in user's viewed marks on the change request's files at head commit `headSha`. The marks are
112
+ * returned only when the read names `headSha` as the head; once the head is another commit, the read resolves to a
113
+ * `stale` failure. A provider implements `viewedFiles` and `setViewed` together; omitting either declares that the
114
+ * host keeps no viewed marks.
115
+ */
116
+ viewedFiles?(ref: ChangeRequestRef, headSha: string, signal: AbortSignal): Promise<ForgeViewedFiles | ForgeFailure>
117
+ /**
118
+ * Set or clear the signed-in user's viewed mark on one file while the head is still `request.headSha`, resolving to
119
+ * undefined once the host saved it.
120
+ */
121
+ setViewed?(ref: ChangeRequestRef, request: ForgeViewedRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
122
+ /**
123
+ * Rerun the failed checks of the head commit that name a `rerun` none of whose checks is pending, while the head is
124
+ * still `request.headSha`, resolving to undefined once the host accepted every rerun. Omission declares that the
125
+ * provider reruns no checks, and its snapshots then name none.
126
+ */
127
+ rerunChecks?(ref: ChangeRequestRef, request: ForgeRerunRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
128
+ /**
129
+ * Request reviews from more reviewers, resolving to undefined once the host accepted the request. A provider implements
130
+ * `requestReviews` and `reviewerCandidates` together; omitting either declares that it requests no reviews, and its
131
+ * snapshots then deny `canRequestReviews`.
132
+ */
133
+ requestReviews?(ref: ChangeRequestRef, request: ForgeReviewersRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
134
+ /** List accounts whose login or name matches `query`, the host's suggestions first, for a review request. */
135
+ reviewerCandidates?(ref: ChangeRequestRef, query: string, signal: AbortSignal): Promise<readonly ForgeReviewerCandidate[] | ForgeFailure>
136
+ /**
137
+ * Bring the base branch's new commits into the head branch while its head is still `request.headSha`, resolving to
138
+ * undefined once the host accepted the update. Omission declares that the provider updates no branches, and its
139
+ * snapshots then offer no `branchUpdates`.
140
+ */
141
+ updateBranch?(ref: ChangeRequestRef, request: BranchUpdateRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
142
+ }
143
+ ```
144
+
145
+ ```ts type-equiv
146
+ /** One commit of a change request. */
147
+ interface ForgeCommit {
148
+ /** Full commit object name. */
149
+ readonly sha: string
150
+ /** Full object name of the first parent, or null for a root commit. */
151
+ readonly parent: string | null
152
+ /** First line of the commit message. */
153
+ readonly title: string
154
+ /** Author name or login as the host reports it, or null when it reports none. */
155
+ readonly author: string | null
156
+ /** ISO 8601 time the commit was authored. */
157
+ readonly authoredAt: string
158
+ }
159
+ ```
160
+
161
+ ```ts type-equiv
162
+ /** The commits of a change request at one head commit. */
163
+ interface ForgeCommitList {
164
+ /** Head commit the list was read at. */
165
+ readonly headSha: string
166
+ /** Commits oldest first, ending with the head commit unless `truncated`. */
167
+ readonly commits: readonly ForgeCommit[]
168
+ /** Whether the change request has more commits than the provider lists; the listed ones are the oldest. */
169
+ readonly truncated: boolean
170
+ }
171
+ ```
172
+
173
+ `ctx.forge.commits` 与 `ctx.forge.compare` 委托给同时实现两者的提供方;否则 `commits` 返回 undefined,`compare` 返回 `unavailable` 失败,因此 forge 面板只在提供方能读取提交时提供提交选择器。
174
+
175
+ ```ts type-equiv
176
+ /** Whether a provider can reach one host with the current credentials. */
177
+ interface ForgeReadiness {
178
+ /** `ready`, `unauthenticated` (sign-in needed), or `unavailable` (tool missing or host unreachable). */
179
+ readonly state: 'ready' | 'unauthenticated' | 'unavailable'
180
+ /** Human-readable detail, or null when ready. */
181
+ readonly message: string | null
182
+ }
183
+ ```
184
+
185
+ ## 状态轮询
186
+
187
+ `ctx.forge.watch` 让同一变更请求的所有监听方共享一个轮询循环,并把每次结果作为更新送达。每个 forge 同时最多只有一次读取在进行。轮询节奏、退避与超时规则见[注册表 README](../../packages/experimental/forge/README.zh.md#use-this-package)。
188
+
189
+ ```ts type-equiv
190
+ /** Lifecycle state of a change request. */
191
+ type ChangeRequestState = 'open' | 'closed' | 'merged'
192
+ ```
193
+
194
+ ```ts type-equiv
195
+ /** Normalized outcome of one status check. */
196
+ type CheckState = 'pending' | 'success' | 'failure' | 'neutral' | 'skipped' | 'cancelled'
197
+ ```
198
+
199
+ ```ts type-equiv
200
+ /** One status check reported for the head commit of a change request. */
201
+ interface ChangeRequestCheck {
202
+ /** Check name as the host displays it. */
203
+ readonly name: string
204
+ /** Normalized check outcome. */
205
+ readonly state: CheckState
206
+ /** Web page for the check, or null when the host reports none. */
207
+ readonly url: string | null
208
+ /** Workflow that produced the check, or null when the host reports none. */
209
+ readonly workflow: string | null
210
+ /** ISO 8601 time the check started, or null before it starts and when the host reports none. */
211
+ readonly startedAt: string | null
212
+ /** ISO 8601 time the check completed, or null while it runs and when the host reports none. */
213
+ readonly completedAt: string | null
214
+ /**
215
+ * Identity a rerun of this check names, or null when the provider cannot rerun it, as for a commit status. Checks that
216
+ * name one identity rerun together, and their failed checks can be rerun once none of them is pending.
217
+ */
218
+ readonly rerun: ForgeCheckId | null
219
+ }
220
+ ```
221
+
222
+ ```ts type-equiv
223
+ /** Combined outcome of all checks on the head commit. */
224
+ type ChecksRollup = 'none' | 'pending' | 'success' | 'failure'
225
+ ```
226
+
227
+ ```ts type-equiv
228
+ /** Whether the change request can merge into its base without conflicts. */
229
+ type Mergeability = 'mergeable' | 'conflicting' | 'unknown'
230
+ ```
231
+
232
+ ```ts type-equiv
233
+ /** Aggregate review outcome required by the host's merge rules. */
234
+ type ReviewDecision = 'approved' | 'changes-requested' | 'review-required' | 'none'
235
+ ```
236
+
237
+ ```ts type-equiv
238
+ /** Status of one change request at the time its provider read it. */
239
+ interface ChangeRequestSnapshot {
240
+ /** Change request the snapshot describes. */
241
+ readonly ref: ChangeRequestRef
242
+ /** Web page of the change request. */
243
+ readonly url: string
244
+ /** Title as the author wrote it. */
245
+ readonly title: string
246
+ /** Lifecycle state. */
247
+ readonly state: ChangeRequestState
248
+ /** Whether the author marked the change request as a draft. */
249
+ readonly draft: boolean
250
+ /** Author login, or null when the host hides it. */
251
+ readonly author: string | null
252
+ /** Branch that carries the proposed commits. */
253
+ readonly headBranch: string
254
+ /** Commit object name at the head of the change request. */
255
+ readonly headSha: string
256
+ /** Branch the change request merges into. */
257
+ readonly baseBranch: string
258
+ /**
259
+ * Base commit the host recorded with `headSha`, whose merge base with the head starts the change request's diff;
260
+ * omitted when the provider does not report it.
261
+ */
262
+ readonly baseSha?: string
263
+ /** Lines the change request adds. */
264
+ readonly additions: number
265
+ /** Lines the change request deletes. */
266
+ readonly deletions: number
267
+ /** Merge conflict status; `unknown` while the host computes it. */
268
+ readonly mergeability: Mergeability
269
+ /**
270
+ * Whether the host would merge the change request now for the signed-in
271
+ * user: open, not a draft, and meeting the base branch's merge rules.
272
+ */
273
+ readonly mergeReady: boolean
274
+ /** Merge methods the repository accepts, the signed-in user's usual one first. */
275
+ readonly mergeMethods: readonly MergeMethod[]
276
+ /**
277
+ * Ways the signed-in user can bring the base branch's new commits into the head branch now; empty while the head is
278
+ * up to date, while the branches conflict, when the user cannot update the head branch, or when the provider cannot,
279
+ * so a head behind its base cannot be told apart from a current one for a user without the right to update it.
280
+ */
281
+ readonly branchUpdates: readonly BranchUpdateMethod[]
282
+ /** Aggregate review outcome. */
283
+ readonly reviewDecision: ReviewDecision
284
+ /** Reviewers whose review is requested, in host order, then other accounts that reviewed, each once; the author is never listed. */
285
+ readonly reviewers: readonly ChangeRequestReviewer[]
286
+ /** Whether the host reported more review requests or reviews than the provider read, so `reviewers` may be incomplete. */
287
+ readonly reviewersTruncated: boolean
288
+ /** Whether the signed-in user may request reviews of the change request through its provider. */
289
+ readonly canRequestReviews: boolean
290
+ /** Checks on the head commit in host order. */
291
+ readonly checks: readonly ChangeRequestCheck[]
292
+ /** Combined check outcome. */
293
+ readonly checksRollup: ChecksRollup
294
+ /** Whether the host reported more checks than `checks` contains. */
295
+ readonly checksTruncated: boolean
296
+ /** Whether the signed-in user may rerun the failed checks that name a `rerun`. */
297
+ readonly canRerunChecks: boolean
298
+ /** Number of counted review threads that are not resolved. */
299
+ readonly unresolvedThreads: number
300
+ /** Whether the change request has more review threads than the provider counted, so `unresolvedThreads` is a lower bound. */
301
+ readonly threadsTruncated: boolean
302
+ /** Issues linked to the change request, which the host closes once it merges, in host order. */
303
+ readonly closingIssues: readonly ChangeRequestIssue[]
304
+ /** Whether the host reported more closing issues than `closingIssues` holds. */
305
+ readonly closingIssuesTruncated: boolean
306
+ /** ISO 8601 time of the host's last update to the change request. */
307
+ readonly updatedAt: string
308
+ /** ISO 8601 time the change request was merged or closed, or null while it is open. */
309
+ readonly closedAt: string | null
310
+ }
311
+ ```
312
+
313
+ ```ts type-equiv
314
+ /** Why a provider could not read a change request. */
315
+ interface ForgeFailure {
316
+ /**
317
+ * `not-found`: the host does not expose it; `unauthenticated`: credentials are missing or rejected;
318
+ * `too-large`: the host or the provider refuses an answer over its size limit, so reading again fails
319
+ * the same way; `stale`: the head is no longer the commit the read named, so reading again at the head of
320
+ * a later status can succeed; `unsupported`: the provider does not offer the read; `unavailable`: any other failure.
321
+ */
322
+ readonly code: 'not-found' | 'unauthenticated' | 'too-large' | 'stale' | 'unsupported' | 'unavailable'
323
+ /** Human-readable cause. */
324
+ readonly message: string
325
+ }
326
+ ```
327
+
328
+ ```ts type-equiv
329
+ /** Latest polling result delivered to watchers of one change request. */
330
+ type ChangeRequestUpdate = {
331
+ /** Canonical identity of the watched change request. */
332
+ readonly key: ChangeRequestKey
333
+ /** Epoch milliseconds when the result settled. */
334
+ readonly fetchedAt: number
335
+ } & ({
336
+ /** Status read from the host. */
337
+ readonly snapshot: ChangeRequestSnapshot
338
+ } | {
339
+ /** Reason the status could not be read. */
340
+ readonly failure: ForgeFailure
341
+ })
342
+ ```
343
+
344
+ ```ts type-equiv
345
+ /**
346
+ * Receives every polling result for one watched change request.
347
+ * @param update - the settled result.
348
+ */
349
+ type ChangeRequestListener = (update: ChangeRequestUpdate) => void
350
+ ```
351
+
352
+ ## 变更请求操作
353
+
354
+ `ctx.forge.markReady` 把草稿标记为可评审,`ctx.forge.merge` 只在 head 仍是用户确认的提交时合并变更请求。主机拒绝时,两者都 resolve 为 `ForgeActionFailure` 而不是抛错,并在结束后立即轮询被监听的变更请求。快照的 `mergeReady` 与 `mergeMethods` 告诉消费方何时提供合并、可用哪些合并方式;GitHub 如何给出这两项由 [GitHub 提供方 README](../../packages/experimental/forge-github/README.zh.md#use-this-package) 说明。
355
+
356
+ ```ts type-equiv
357
+ /** A merge the user confirmed for the head commit they saw. */
358
+ interface MergeRequest {
359
+ /** How the commits enter the base branch. */
360
+ readonly method: MergeMethod
361
+ /** Commit object name the head must still have; the merge is refused once the head moves. */
362
+ readonly headSha: string
363
+ }
364
+ ```
365
+
366
+ ```ts type-equiv
367
+ /** Why a provider could not change a change request, or could not confirm that it did. */
368
+ interface ForgeActionFailure {
369
+ /**
370
+ * `unauthenticated`: credentials are missing or rejected; `stale`: the head
371
+ * moved past the confirmed commit; `failed`: the host refused or could not be reached, so nothing changed;
372
+ * `unknown`: the request reached the host but its answer did not confirm the outcome, so the change may have been
373
+ * applied and must be checked on the host before it is tried again.
374
+ */
375
+ readonly code: 'unauthenticated' | 'stale' | 'failed' | 'unknown'
376
+ /** Human-readable cause, usually the host's own message. */
377
+ readonly message: string
378
+ }
379
+ ```
380
+
381
+ `ctx.forge.submitReview` 将明确指定的评论或完整评审交给 provider;未实现此能力的 provider 返回不支持。消费者在再次提交前核对结果不明的写操作;留待之后一起提交的评论通过 `ctx.forge.writeReview` 写入代码托管平台的待提交评审。
382
+
383
+ ```ts type-equiv
384
+ /** One inline comment addressed to the old or new side of a pull request diff. */
385
+ interface ForgeLineComment {
386
+ readonly path: string
387
+ readonly side: 'L' | 'R'
388
+ readonly startLine: number
389
+ readonly endLine: number
390
+ readonly body: string
391
+ }
392
+ ```
393
+
394
+ ```ts type-equiv
395
+ /** A single published comment or one completed review containing all pending comments. */
396
+ type ForgeReviewRequest = {
397
+ /** Commit the user reviewed; providers must check it before writing and address that commit explicitly. */
398
+ readonly headSha: string
399
+ } & (
400
+ | { readonly kind: 'comment'; readonly comment: ForgeLineComment }
401
+ | { readonly kind: 'review'; readonly event: ForgeReviewEvent; readonly body: string; readonly comments: readonly ForgeLineComment[] }
402
+ )
403
+ ```
404
+
405
+ ```ts type-equiv
406
+ /** Result of a review submission; unknown outcomes must be checked on the host before another submission. */
407
+ type ForgeReviewResult =
408
+ | { readonly ok: true; readonly url: string }
409
+ | { readonly ok: false; readonly code: 'unsupported' | 'stale' | 'failed' | 'unknown'; readonly message: string }
410
+ ```
411
+
412
+ ## 评审讨论
413
+
414
+ `ctx.forge.readReview(ref, headSha, signal)` 读取变更请求在某个 head 提交处的评审讨论。只有当读取时的 head 就是 `headSha` 时,提供方才返回 `ForgeReviewData`;否则返回 `stale`,并像 diff 读取遇到 `stale` 时一样,立即重新轮询被关注的变更请求。提供方没有实现 `readReview` 时,服务返回 `unsupported`,使用方据此不显示讨论,也不报错。行级讨论有两套位置:`original` 是写下讨论时所在提交上的行,`current` 是本次读取的 head 上的行;托管平台不再把讨论放在该提交上时,`current` 为 null。显示 head diff 的使用方把讨论放在 `current` 位置,其余讨论用 `diffHunk` 展示;用 `fileText` 读取 `original.commit` 上的文件,可以看到写下讨论时的完整文件。GitHub 各字段如何映射到这两套位置,由 [GitHub 提供方 README](../../packages/experimental/forge-github/README.zh.md#use-this-package) 说明。
415
+
416
+ ```ts type-equiv
417
+ /** Opaque host identity of one review thread. */
418
+ type ForgeThreadId = Branded<'ForgeThreadId'>
419
+ ```
420
+
421
+ ```ts type-equiv
422
+ /** Opaque host identity of one review comment. */
423
+ type ForgeCommentId = Branded<'ForgeCommentId'>
424
+ ```
425
+
426
+ ```ts type-equiv
427
+ /** Consecutive lines on one side of a diff whose new side is one commit. */
428
+ interface ForgeAnchor {
429
+ /**
430
+ * Full object name of the commit the diff's new side shows: new-side (`R`) lines number this commit's file, and
431
+ * old-side (`L`) lines number the file at the diff's base.
432
+ */
433
+ readonly commit: string
434
+ /** First line, inclusive. */
435
+ readonly startLine: number
436
+ /** Last line, inclusive. */
437
+ readonly endLine: number
438
+ }
439
+ ```
440
+
441
+ ```ts type-equiv
442
+ /** Account that wrote a review comment. */
443
+ interface ForgeCommentAuthor {
444
+ /** Login as the host spells it. */
445
+ readonly login: string
446
+ /** Avatar image URL, or null when the host reports none. */
447
+ readonly avatarUrl: string | null
448
+ /** Whether the account is an app or bot rather than a person. */
449
+ readonly bot: boolean
450
+ }
451
+ ```
452
+
453
+ ```ts type-equiv
454
+ /** One comment of a review thread. */
455
+ interface ForgeReviewComment {
456
+ /** Host identity of the comment. */
457
+ readonly id: ForgeCommentId
458
+ /** Author, or null when the account no longer exists. */
459
+ readonly author: ForgeCommentAuthor | null
460
+ /** Markdown source as the author wrote it; it may contain raw HTML, which readers must not render as HTML. */
461
+ readonly body: string
462
+ /** ISO 8601 time the comment was created. */
463
+ readonly createdAt: string
464
+ /** Whether the comment belongs to the signed-in user's review that is not submitted yet, which only that user sees. */
465
+ readonly pending: boolean
466
+ /** Web page of the comment, or null when the host reports none. */
467
+ readonly url: string | null
468
+ /** Whether the signed-in user can replace the comment's text through `writeReview`; false for a provider without it. */
469
+ readonly viewerCanEdit: boolean
470
+ /** Whether the signed-in user can delete the comment through `writeReview`; false for a provider without it. */
471
+ readonly viewerCanDelete: boolean
472
+ }
473
+ ```
474
+
475
+ ```ts type-equiv
476
+ /**
477
+ * One review thread on a file of a change request. A line thread has two positions: `original` on the commit it was
478
+ * written on, and `current` on the head commit of the read. `current` is null once the host no longer places the
479
+ * thread on the head commit, as after later commits changed its lines.
480
+ */
481
+ interface ForgeReviewThread {
482
+ /** Host identity of the thread. */
483
+ readonly id: ForgeThreadId
484
+ /** Repository-relative path the thread is on. */
485
+ readonly path: string
486
+ /** Old (`L`) or new (`R`) side of the diff the lines number. */
487
+ readonly side: 'L' | 'R'
488
+ /** Whether the thread is on lines or on the whole file. */
489
+ readonly subject: 'line' | 'file'
490
+ /** Lines in the diff that ends at the head commit of the read, whose `commit` is that head; null for an outdated or file thread. */
491
+ readonly current: ForgeAnchor | null
492
+ /** Lines in the diff that ended at the commit the thread was written on; null for a file thread. */
493
+ readonly original: ForgeAnchor | null
494
+ /** Diff hunk the host recorded when the thread was written, ending at its last line; null when it recorded none. */
495
+ readonly diffHunk: string | null
496
+ /** Whether the thread is marked resolved. */
497
+ readonly resolved: boolean
498
+ /** Whether the signed-in user can reply to the thread through `writeReview`; false for a provider without it. */
499
+ readonly viewerCanReply: boolean
500
+ /**
501
+ * Whether the signed-in user can mark the thread resolved, or unresolved when `resolved`, through `writeReview`; false
502
+ * for a provider without it.
503
+ */
504
+ readonly viewerCanResolve: boolean
505
+ /** Comments oldest first; the first starts the thread. */
506
+ readonly comments: readonly ForgeReviewComment[]
507
+ }
508
+ ```
509
+
510
+ ```ts type-equiv
511
+ /** Review threads of a change request read at one head commit. */
512
+ interface ForgeReviewData {
513
+ /** Head commit the threads were read at; `current` positions number its files. */
514
+ readonly headSha: string
515
+ /** Login of the signed-in user the provider read as, or null when the host does not name one. */
516
+ readonly viewer: string | null
517
+ /** Threads in host order, at most the provider's limit. */
518
+ readonly threads: readonly ForgeReviewThread[]
519
+ /** Whether the change request has more threads than `threads` holds. */
520
+ readonly truncated: boolean
521
+ /** The signed-in user's pending review, or null without one. */
522
+ readonly pendingReview: ForgePendingReview | null
523
+ /**
524
+ * Whether the signed-in user can add comments to a pending review and submit or discard it through `writeReview`;
525
+ * false for a provider without it.
526
+ */
527
+ readonly viewerCanReview: boolean
528
+ }
529
+ ```
530
+
531
+ `ctx.forge.writeReview(ref, write, signal)` 写入评审讨论和当前登录用户的待提交评审:回复讨论,立即发布,或在 `pending` 时加入待提交评审;把讨论标记为已解决或取消解决;编辑或删除评论;在 head 上添加一条行内评论到待提交评审;以及提交或丢弃待提交评审。用户还没有待提交评审时,待提交的回复或评论会先开始一个评审。每个写操作都带有用户看到的 head 提交;提供方先检查它,head 已变化时不写入,直接返回 `stale`,并像读取遇到 `stale` 时那样重新轮询被关注的变更请求;其他结果之后,服务都会立即重新轮询被关注的变更请求。写操作从不重试;结果为 `unknown` 时,必须先在托管平台上核对,再重试。提供方没有实现 `writeReview` 时,服务返回 `unsupported`。`ForgeReviewData` 带有待提交评审,以及用户对每个讨论、每条评论和待提交评审的权限;未实现 `writeReview` 的提供方把这些权限报告为没有,使用方据此只提供能够成功的写操作。GraphQL mutation 以及它们的结果如何对应到这些返回值,由 [GitHub 提供方 README](../../packages/experimental/forge-github/README.zh.md#use-this-package) 说明。
532
+
533
+ ```ts type-equiv
534
+ /** Opaque host identity of one review. */
535
+ type ForgeReviewId = Branded<'ForgeReviewId'>
536
+ ```
537
+
538
+ ```ts type-equiv
539
+ /** The signed-in user's review of a change request that is not submitted yet, which only that user sees. */
540
+ interface ForgePendingReview {
541
+ /** Host identity of the review. */
542
+ readonly id: ForgeReviewId
543
+ /** Comments the review holds. */
544
+ readonly comments: number
545
+ }
546
+ ```
547
+
548
+ ```ts type-equiv
549
+ /** Decision a submitted review records. */
550
+ type ForgeReviewEvent = 'comment' | 'approve' | 'request-changes'
551
+ ```
552
+
553
+ ```ts type-equiv
554
+ /**
555
+ * One write to the review threads and the pending review of a change request. `pending` replies and `add-pending`
556
+ * comments join the signed-in user's pending review, which is started when the user has none. A host that adds every
557
+ * reply to an existing pending review, as GitHub does, refuses a reply with `pending: false` while one exists.
558
+ */
559
+ type ForgeReviewWrite = {
560
+ /** Head commit the user saw; providers check it before writing and refuse with `stale` once the head is another commit. */
561
+ readonly headSha: string
562
+ } & (
563
+ | { readonly kind: 'reply'; readonly thread: ForgeThreadId; readonly body: string; readonly pending: boolean }
564
+ | { readonly kind: 'resolve'; readonly thread: ForgeThreadId; readonly resolved: boolean }
565
+ | { readonly kind: 'edit-comment'; readonly comment: ForgeCommentId; readonly body: string }
566
+ /** Deleting the only comment of a thread deletes the thread. */
567
+ | { readonly kind: 'delete-comment'; readonly comment: ForgeCommentId }
568
+ /** A comment on lines of `headSha`. */
569
+ | { readonly kind: 'add-pending'; readonly comment: ForgeLineComment }
570
+ | { readonly kind: 'submit-pending'; readonly review: ForgeReviewId; readonly event: ForgeReviewEvent; readonly body: string }
571
+ /** Delete the pending review with every comment it holds. */
572
+ | { readonly kind: 'discard-pending'; readonly review: ForgeReviewId }
573
+ )
574
+ ```
575
+
576
+ ```ts type-equiv
577
+ /** Result of a review write; an `unknown` outcome must be checked on the host before the write is tried again. */
578
+ type ForgeReviewWriteResult =
579
+ | { readonly ok: true }
580
+ | { readonly ok: false; readonly code: 'unsupported' | 'stale' | 'failed' | 'unknown'; readonly message: string }
581
+ ```
582
+
583
+ <a id="overview-and-viewed-marks"></a>
584
+
585
+ ## 概览与已审阅标记
586
+
587
+ 快照还携带变更请求的概览:`reviewers` 及每位评审者最近的结论、合并后托管平台会关闭的 `closingIssues`、能让落后于基线的 head 更新到最新的 `branchUpdates`、当前登录用户能否请求评审或重跑检查,以及每个检查指出的 `rerun`。`ctx.forge.rerunChecks`、`ctx.forge.requestReviews` 与 `ctx.forge.updateBranch` 据此操作,并像上文的操作一样返回 `ForgeActionFailure`,主机的答复无法确认结果时为 `unknown`,提供方答复后立即轮询被监听的变更请求;重跑与更新指明用户看到的 head 提交,head 移动后以 `stale` 拒绝。提供方同时实现 `requestReviews` 与 `reviewerCandidates`,`ctx.forge.reviewerCandidates` 借后者列出可以请求评审的账号;提供方缺少的操作以 `failed` 失败,`reviewerCandidates` 则返回 `unsupported`。GitHub 如何填写各字段并执行这些操作见 [GitHub 提供方 README](../../packages/experimental/forge-github/README.zh.md#use-this-package)。
588
+
589
+ ```ts type-equiv
590
+ /** Opaque host identity of a status check that a rerun names. */
591
+ type ForgeCheckId = Branded<'ForgeCheckId'>
592
+ ```
593
+
594
+ ```ts type-equiv
595
+ /** How an update brings the base branch's new commits into the head branch: a merge commit, or a rebase of the head's commits. */
596
+ type BranchUpdateMethod = 'merge' | 'rebase'
597
+ ```
598
+
599
+ ```ts type-equiv
600
+ /** Outcome of a reviewer's latest submitted review. */
601
+ type ReviewVerdict = 'approved' | 'changes-requested' | 'commented' | 'dismissed'
602
+ ```
603
+
604
+ ```ts type-equiv
605
+ /** An account or team asked to review a change request, or an account that reviewed it. */
606
+ interface ChangeRequestReviewer {
607
+ /** Whether the reviewer is a person's account, an app or bot account, or a team. */
608
+ readonly kind: 'user' | 'bot' | 'team'
609
+ /** Login, or `organization/slug` for a team. */
610
+ readonly login: string
611
+ /** Avatar image URL, or null when the host reports none. */
612
+ readonly avatarUrl: string | null
613
+ /** Whether a review from the reviewer is requested now. */
614
+ readonly requested: boolean
615
+ /** Whether the host requested the review because the reviewer owns changed paths. */
616
+ readonly codeOwner: boolean
617
+ /** Outcome of the reviewer's latest submitted review, or null before the first. */
618
+ readonly verdict: ReviewVerdict | null
619
+ /** Commit the latest submitted review was on, or null before the first or when the host reports none. */
620
+ readonly reviewedSha: string | null
621
+ }
622
+ ```
623
+
624
+ ```ts type-equiv
625
+ /** One issue linked to a change request, which the host closes once the change request merges. */
626
+ interface ChangeRequestIssue {
627
+ /** Repository that holds the issue. */
628
+ readonly repository: ForgeRepository
629
+ /** Host-assigned issue number. */
630
+ readonly number: number
631
+ /** Title as the author wrote it. */
632
+ readonly title: string
633
+ /** Whether the issue is still open. */
634
+ readonly state: 'open' | 'closed'
635
+ /** Web page of the issue. */
636
+ readonly url: string
637
+ }
638
+ ```
639
+
640
+ ```ts type-equiv
641
+ /** A rerun of the failed checks of the head commit whose checks the user saw. */
642
+ interface ForgeRerunRequest {
643
+ /** Head commit whose checks the user saw; the provider refuses with `stale` once the head is another commit. */
644
+ readonly headSha: string
645
+ }
646
+ ```
647
+
648
+ ```ts type-equiv
649
+ /** Reviewers to ask in addition to those whose review is requested now; one who already reviewed is asked again. */
650
+ interface ForgeReviewersRequest {
651
+ /** The reviewers by kind and login, a team by `organization/slug`. */
652
+ readonly reviewers: readonly Pick<ChangeRequestReviewer, 'kind' | 'login'>[]
653
+ }
654
+ ```
655
+
656
+ ```ts type-equiv
657
+ /** An account a review of the change request can be requested from. */
658
+ interface ForgeReviewerCandidate {
659
+ /** Login as the host spells it. */
660
+ readonly login: string
661
+ /** Display name, or null when the account shows none. */
662
+ readonly name: string | null
663
+ /** Avatar image URL, or null when the host reports none. */
664
+ readonly avatarUrl: string | null
665
+ /** Whether the host suggests the account for this change request, as from the history of its changed files. */
666
+ readonly suggested: boolean
667
+ }
668
+ ```
669
+
670
+ ```ts type-equiv
671
+ /** A branch update the user confirmed for the head commit they saw. */
672
+ interface BranchUpdateRequest {
673
+ /** How the base branch's new commits enter the head branch. */
674
+ readonly method: BranchUpdateMethod
675
+ /** Commit object name the head must still have; the update is refused once the head moves. */
676
+ readonly headSha: string
677
+ }
678
+ ```
679
+
680
+ `ctx.forge.viewedFiles` 与 `ctx.forge.setViewed` 在一个 head 提交上读取和修改当前登录用户对变更请求各文件的已审阅标记。只有同时实现两个方法的提供方保存已审阅标记;否则 `viewedFiles` 返回 undefined,`setViewed` 失败,由使用方自行保存标记。`stale` 答复会像过期的 diff 读取一样立即轮询被监听的变更请求。
681
+
682
+ ```ts type-equiv
683
+ /**
684
+ * The signed-in user's review progress on one changed file: `viewed`, `unviewed`, or `dismissed` once the file
685
+ * changed after the user marked it viewed.
686
+ */
687
+ type ForgeViewedState = 'viewed' | 'unviewed' | 'dismissed'
688
+ ```
689
+
690
+ ```ts type-equiv
691
+ /** The signed-in user's viewed marks on the files of a change request, read at one head commit. */
692
+ interface ForgeViewedFiles {
693
+ /** Head commit the marks were read at. */
694
+ readonly headSha: string
695
+ /** State of each changed file the host listed, by repository-relative path. */
696
+ readonly files: Readonly<Record<string, ForgeViewedState>>
697
+ /** Whether the change request has more files than `files` lists. */
698
+ readonly truncated: boolean
699
+ }
700
+ ```
701
+
702
+ ```ts type-equiv
703
+ /** A viewed mark the user set or cleared on a file of the head commit they saw. */
704
+ interface ForgeViewedRequest {
705
+ /** Repository-relative path of the changed file. */
706
+ readonly path: string
707
+ /** Whether the file is viewed. */
708
+ readonly viewed: boolean
709
+ /** Head commit whose changes the user saw; the provider refuses with `stale` once the head is another commit. */
710
+ readonly headSha: string
711
+ }
712
+ ```
713
+
714
+ ## Session 绑定
715
+
716
+ `ctx.forgeSession` 从每个 Session 自己的日志派生其绑定:`gh pr create` 的结果绑定其输出的 URL,`gh pr view`、`gh pr edit` 与 `gh pr checkout` 调用绑定它们所操作的变更请求,`git push` 的结果通过 `ctx.forge` 触发按 head 分支的发现;面板也会报告其检出所跟踪的分支,触发同样的发现。track、dismiss 与发现操作都是 `plugin:forge-session/binding` 插件记录,位于模型可见对话之外。`forgeChangeRequests` 投影的客户端视图随 Session 摘要下发,列出绑定但不含其状态。识别与发现规则见 [Session 绑定 README](../../packages/experimental/forge-session/README.zh.md#use-this-package)。
717
+
718
+ ```ts type-equiv
719
+ /**
720
+ * How a change request became bound to a Session: `created` when a
721
+ * `gh pr create` result printed its URL, `referenced` when a `gh pr view`,
722
+ * `gh pr edit`, or `gh pr checkout` call named it or its result printed its
723
+ * own URL, `discovered` when a lookup found it for a branch the Session pushed
724
+ * or works on, `tracked` when a caller bound it by URL.
725
+ */
726
+ type BindingOrigin = 'created' | 'referenced' | 'discovered' | 'tracked'
727
+ ```
728
+
729
+ ```ts type-equiv
730
+ /** Payload of the `plugin:forge-session/binding` record. */
731
+ interface BindingRecord {
732
+ /**
733
+ * `track` binds or restores, `dismiss` hides, `discover` binds a branch lookup,
734
+ * and `reference` binds a CLI selector lookup without restoring dismissed entries.
735
+ */
736
+ readonly action: 'track' | 'dismiss' | 'discover' | 'reference'
737
+ /** Web URL of the change request. */
738
+ readonly url: string
739
+ }
740
+ ```
741
+
742
+ ```ts type-equiv
743
+ /** One change request bound to a Session and not dismissed, with its latest polling result. */
744
+ interface SessionChangeRequest {
745
+ /** Web URL as first recorded. */
746
+ readonly url: string
747
+ /** How the change request became bound. */
748
+ readonly origin: BindingOrigin
749
+ /** Parsed reference, or null when no registered provider serves the URL. */
750
+ readonly ref: ChangeRequestRef | null
751
+ /** Latest polling result, or null before the first poll and without a provider. */
752
+ readonly update: ChangeRequestUpdate | null
753
+ }
754
+ ```
755
+
756
+ ```ts type-equiv
757
+ /**
758
+ * Receives the complete visible list after a binding or provider change, or a polling result.
759
+ * @param changeRequests - every visible binding of the watched Session, in first-recorded order.
760
+ */
761
+ type SessionChangeRequestsListener = (changeRequests: readonly SessionChangeRequest[]) => void
762
+ ```
763
+
764
+ ## 面板
765
+
766
+ `ctx.forgePanel` 是 [forge 面板](../../packages/experimental/client-ui-forge/README.zh.md#use-this-package)的宿主 Remote。跟随一个 Session 时,它以流的形式推送 `ForgePanelState`:在 Session 执行环境中对其当前目录进行的只读 Git 检查、从上游远端或 `origin` 识别出的代码托管平台、该平台的登录状态、Session 的绑定及其轮询状态与最近的快照,以及它的 worktree 请求。它的操作可以列出基准分支、绑定和隐藏 URL、刷新、把已绑定的草稿标记为可评审或合并已绑定的变更请求、请求或撤回 worktree、停止正在进行的创建,以及恢复已删除的 worktree 或离开它回到源检出。请求是一条 `plugin:client-ui-forge/worktree` 记录。消息在 Session 的 Agent 空闲时进入其收件箱,面板会在这次投递唤醒 [Agent](../../packages/core/agent/README.zh.md) 之前启动它的维护任务,暂留这条消息的这一轮:对未完成的请求,它通过 `ctx.worktrees` 创建 worktree,尝试失败或被停止后等待下一次尝试或请求被撤回;对在所创建 worktree 中工作的 Session,它检查该 worktree,已被删除时等待它被恢复或离开。面板状态说明消息在等待什么,以及最近一次失败的尝试。对于没有被暂留的消息,由第一个步骤提议创建 worktree。第一轮开始之后的请求会被忽略。对 Session 检出的改动以其 Agent 的维护任务运行,因此其他客户端发来的消息会等它们完成。
767
+
768
+ ```ts type-equiv
769
+ /** Git facts for the checkout that contains the Session's current directory. */
770
+ interface ForgeCheckout {
771
+ /** Top-level directory of the checkout. */
772
+ readonly root: string
773
+ /** Checked-out branch, or null when HEAD is detached. */
774
+ readonly branch: string | null
775
+ /** Whether the checkout is a linked worktree of another checkout's repository. */
776
+ readonly linked: boolean
777
+ /** Abbreviated commit HEAD names, or null while the checked-out branch has no commit. */
778
+ readonly commit: string | null
779
+ }
780
+ ```
781
+
782
+ ```ts type-equiv
783
+ /** Inspection result for the Session's current directory. */
784
+ type ForgeCheckoutState =
785
+ /** The first inspection has not finished. */
786
+ | { readonly state: 'pending' }
787
+ /** The current directory is not inside a Git checkout. */
788
+ | { readonly state: 'none' }
789
+ /** Git could not run or reported an error. */
790
+ | { readonly state: 'failed'; readonly message: string }
791
+ /** The checkout facts. */
792
+ | { readonly state: 'ready'; readonly checkout: ForgeCheckout }
793
+ ```
794
+
795
+ ```ts type-equiv
796
+ /** The worktree the panel created and entered for a Session before its first step. */
797
+ interface ForgeSessionWorktree {
798
+ /** Canonical checkout directory. */
799
+ readonly path: string
800
+ /** Branch created for the checkout. */
801
+ readonly branch: string
802
+ /** Requested base branch, or null when the checkout started from HEAD of the source checkout. */
803
+ readonly from: string | null
804
+ /** Commit object name the branch started from. */
805
+ readonly baseCommit: string
806
+ /** Canonical root of the source checkout. */
807
+ readonly repositoryRoot: string
808
+ }
809
+ ```
810
+
811
+
812
+ ```ts type-equiv
813
+ /** Payload of the `plugin:client-ui-forge/worktree` record. */
814
+ type WorktreeRecord =
815
+ /** Create a worktree before the Session's first step, starting from `from`, or from HEAD when it is null. */
816
+ | { readonly action: 'request'; readonly from: string | null }
817
+ /** Withdraw the open request. */
818
+ | { readonly action: 'cancel' }
819
+ /** The requested worktree was created and became the Session's working directory. */
820
+ | { readonly action: 'created'; readonly worktree: ForgeSessionWorktree }
821
+ /** Restoration started; the checkout stays unavailable until restoration completes. */
822
+ | { readonly action: 'restoring' }
823
+ /** The recorded worktree was completely restored. */
824
+ | { readonly action: 'restored' }
825
+ ```
826
+
827
+ ```ts type-equiv
828
+ /** One open worktree request. */
829
+ interface ForgeWorktreeRequest {
830
+ /** Base branch, or null for HEAD of the source checkout. */
831
+ readonly from: string | null
832
+ }
833
+ ```
834
+
835
+ ```ts type-equiv
836
+ /** Why the Session's checkout cannot host a new worktree. */
837
+ type ForgeWorktreeBlocker =
838
+ /** The current directory is not inside a Git checkout. */
839
+ | 'not-git'
840
+ /** The Session's sandbox cannot write the checkout or its Git directory, as for a linked worktree outside the writable root. */
841
+ | 'outside-writable-root'
842
+ /** The Session runs read-only. */
843
+ | 'read-only'
844
+ ```
845
+
846
+ ```ts type-equiv
847
+ /** One running worktree creation. */
848
+ interface ForgeWorktreeCreation {
849
+ /** Running step: `prepare` validates and creates the branch, then `checkout` writes the files. */
850
+ readonly phase: 'prepare' | 'checkout'
851
+ /** Branch the attempt creates. */
852
+ readonly branch: string
853
+ /** Base branch, or null for HEAD. */
854
+ readonly from: string | null
855
+ /**
856
+ * Whether a message waits for the creation before its turn starts. Only
857
+ * such a creation can be stopped, after which the message keeps waiting; a
858
+ * creation at the first step serves a message the Session already holds.
859
+ */
860
+ readonly held: boolean
861
+ }
862
+ ```
863
+
864
+ ```ts type-equiv
865
+ /** One running restoration of the removed worktree a Session works in. */
866
+ interface ForgeWorktreeRestoration {
867
+ /** Running step: `prepare` registers the checkout again, creating a missing branch, then `checkout` writes the files. */
868
+ readonly phase: 'prepare' | 'checkout'
869
+ }
870
+ ```
871
+
872
+ ```ts type-equiv
873
+ /** The last attempt to create the requested worktree for a message, which failed. */
874
+ interface ForgeWorktreeFailure {
875
+ /** Branch the attempt created, or null when it failed before naming one. */
876
+ readonly branch: string | null
877
+ /** Base branch of the attempt, or null for HEAD. */
878
+ readonly from: string | null
879
+ /** Step that failed. */
880
+ readonly phase: 'prepare' | 'checkout'
881
+ /** Failure text. */
882
+ readonly message: string
883
+ }
884
+ ```
885
+
886
+ ```ts type-equiv
887
+ /**
888
+ * What a message waits for before its turn starts: the creation of the
889
+ * requested worktree, or the restoration or leaving of the removed worktree
890
+ * the Session works in.
891
+ */
892
+ type ForgeWorktreeWaiting = 'creation' | 'restoration'
893
+ ```
894
+
895
+ ```ts type-equiv
896
+ /** The recorded worktree whose directory is missing, invalid, or incompletely restored. */
897
+ interface ForgeMissingWorktree {
898
+ /** Whether its branch exists, or null when an incomplete restoration cannot inspect it. */
899
+ readonly branchExists: boolean | null
900
+ }
901
+ ```
902
+
903
+ ```ts type-equiv
904
+ /** Worktree facts of one Session in the panel state. */
905
+ interface ForgePanelWorktree {
906
+ /**
907
+ * Whether the Session can still request or withdraw a worktree: a worktree
908
+ * service is mounted, no turn has started, and none was created.
909
+ */
910
+ readonly editable: boolean
911
+ /** Why the checkout cannot host a worktree, or null when it can, before the first inspection, and after a failed one. */
912
+ readonly blocker: ForgeWorktreeBlocker | null
913
+ /** Open request, or null without one. */
914
+ readonly request: ForgeWorktreeRequest | null
915
+ /** Created worktree, or null before creation. */
916
+ readonly created: ForgeSessionWorktree | null
917
+ /** Running creation, or null. */
918
+ readonly creation: ForgeWorktreeCreation | null
919
+ /**
920
+ * The last failed attempt of the creation a message waits for, or null. It
921
+ * clears when another attempt starts, when the request changes or is
922
+ * withdrawn, and when the wait ends.
923
+ */
924
+ readonly failure: ForgeWorktreeFailure | null
925
+ /** The created worktree the Session works in when its directory is gone, or null. */
926
+ readonly missing: ForgeMissingWorktree | null
927
+ /** Running restoration of the removed worktree, or null. */
928
+ readonly restoration: ForgeWorktreeRestoration | null
929
+ /** What a message of the Session waits for before its turn starts, or null while none waits. */
930
+ readonly waiting: ForgeWorktreeWaiting | null
931
+ }
932
+ ```
933
+
934
+ ```ts type-equiv
935
+ /** One bound change request in the panel state. */
936
+ interface ForgePanelChangeRequest extends SessionChangeRequest {
937
+ /** Latest snapshot a poll returned, kept while later polls fail, or null before the first successful poll. */
938
+ readonly snapshot: ChangeRequestSnapshot | null
939
+ /**
940
+ * Number of review changes `forge/review-changed` announced for the change request since the panel host started; it
941
+ * grows when any plugin's write is accepted, so a reader shows threads and viewed marks read after it.
942
+ */
943
+ readonly reviewRevision: number
944
+ }
945
+ ```
946
+
947
+ ```ts type-equiv
948
+ /** Everything the panel shows for one Session. */
949
+ interface ForgePanelState {
950
+ /** Current working directory of the Session. */
951
+ readonly directory: string
952
+ /** Inspection result for `directory`. */
953
+ readonly checkout: ForgeCheckoutState
954
+ /** Code host repository of the checkout's upstream remote or `origin`, or null when no provider serves them. */
955
+ readonly repository: ForgeRepository | null
956
+ /** Sign-in state for the repository's host, or null before the first probe and without a repository. */
957
+ readonly readiness: ForgeReadiness | null
958
+ /** Visible change request bindings with their latest polling results, in first-recorded order. */
959
+ readonly changeRequests: readonly ForgePanelChangeRequest[]
960
+ /** Worktree request and creation state. */
961
+ readonly worktree: ForgePanelWorktree
962
+ /**
963
+ * Files the `branch` scope changes, or null before the first inspection,
964
+ * outside a checkout, and without a fork point.
965
+ */
966
+ readonly local: ForgeLocalChanges | null
967
+ }
968
+ ```
969
+
970
+ ```ts type-equiv
971
+ /** Local branches offered as the base of a new worktree. */
972
+ interface ForgeBranches {
973
+ /** Checked-out branch, or null when HEAD is detached. */
974
+ readonly current: string | null
975
+ /** Local branch names, `current` first and then most recently committed first, at most `maxBranches`. */
976
+ readonly branches: readonly string[]
977
+ }
978
+ ```
979
+
980
+ 会话列表经同一个 Remote 读取。`changeRequestStates` 以流的形式推送 `ForgeChangeRequestStatesFrame`:先是一个 `baseline`,包含调用方可读的已列出 Session 所绑定的每个变更请求最近一次已知的 `ForgeChangeRequestListState`,之后是发生变化的状态。宿主用一次运行服务所有流:已加载 Session 的绑定取自 `ctx.forgeSession`,其他 Session 的绑定取自缓存的 Session 摘要而不加载它们;每个已绑定的变更请求保持订阅,已关闭的按空闲间隔轮询以检测重新打开,每次变化都会存储,因此重启后在下次轮询之前就能显示最近已知的状态。Session 摘要还带有 `forgeWorktree` 投影的客户端视图:Session 的目录就是所创建的 worktree 或位于其下时为该 worktree,否则为 null。
981
+
982
+ ```ts type-equiv
983
+ /**
984
+ * The last polled state of one change request that a listed Session binds, as
985
+ * the Session list shows it.
986
+ */
987
+ type ForgeChangeRequestListState = Pick<
988
+ ChangeRequestSnapshot, 'url' | 'title' | 'state' | 'draft' | 'checksRollup' | 'reviewDecision' | 'mergeability'
989
+ > & {
990
+ /** Change request number on its code host. */
991
+ readonly number: number
992
+ }
993
+ ```
994
+
995
+ ```ts type-equiv
996
+ /**
997
+ * One frame of `forgePanel.changeRequestStates`: the known state of every
998
+ * change request the reader may see first, then the states that changed or
999
+ * became visible since the previous frame.
1000
+ */
1001
+ type ForgeChangeRequestStatesFrame =
1002
+ | { readonly type: 'baseline'; readonly states: readonly ForgeChangeRequestListState[] }
1003
+ | { readonly type: 'changed'; readonly states: readonly ForgeChangeRequestListState[] }
1004
+ ```
1005
+
1006
+ 变更视图经同一个 Remote 读取。`localDiff` 读取 Session 检出的某个 `ForgeLocalScope`;`changeRequestDiff` 经提供方的 `diff` 读取已绑定变更请求在其最新状态 head 处的变更(提供方只返回描述该 head 提交的补丁),或经提供方的 `compare` 读取它指定的 `ForgeCommitRange`;两者返回的文件都已在宿主上解析为 `ForgeDiffFile` 的 hunk,并带有分层与改动摘要。`localCommits` 与 `changeRequestCommits` 列出范围可以指定的提交,提供方不读取提交时后者返回 null。`localText` 与 `changeRequestText` 读取一个文件的新版本,用来补出 hunk 之间未变更的行。每次检查还会把 `branch` 范围的规模统计为 `ForgePanelState.local`,供面板的变更卡片使用,始终以自动分叉点为准。`base` 指定了引用的 `branch` 范围改为与 HEAD 和该分支的合并基准比较;`diffBases` 列出视图可选的分支以及自动分叉点。head 已越过最新状态时,提供方返回 `stale`,`ctx.forge.diff` 立即重新轮询该变更请求(每个 head 提交一次);`changeRequestDiff` 以 `forgePanel/stale-head` 拒绝且不缓存任何内容,变更视图保持加载,直到更新的状态到达后按该状态的 head 重新读取。因此评审评论始终指向视图所显示行的那个提交。
1007
+
1008
+ `changeRequestReview(session, url, headSha, fresh)` 在视图所显示 diff 的 head 处读取已绑定变更请求的讨论;head 不同时以 `forgePanel/stale-head` 拒绝,提供方不支持读取讨论时返回 `forgePanel/review-unsupported`,其他失败返回 `forgePanel/review-failed`。每个变更请求在内存里保留一次读取结果,以 head 提交和状态的更新时间为键、受 `maxCachedReviewBytes` 约束,保留时间达到 `reviewRefreshMs` 后,或 `fresh` 要求时(读者刷新视图后的第一次读取就是这样)重新读取:在 GitHub 上,新评论和回复会改变 PR 的更新时间,解决讨论则不会。变更视图可见时,每收到一次状态就重新请求一次,并按[面板 README](../../packages/experimental/client-ui-forge/README.zh.md#use-this-package) 所述把讨论叠加到文件上。
1009
+
1010
+ `changeRequestViewed(session, url, headSha)` 在视图所示 diff 的 head 上读取已绑定变更请求的已审阅标记,提供方不保存标记时返回 null,head 不同时以 `forgePanel/stale-head` 拒绝,其他失败以 `forgePanel/viewed-failed` 拒绝;`setFileViewed` 在该 head 上保存一个文件的标记。`rerunChecks`、`requestReviews` 与 `updateBranch` 作用于已绑定的变更请求,托管平台未确认的结果以 `forgePanel/action-unknown` 拒绝,`reviewerCandidates` 列出可请求评审的账号,托管平台未列出时以 `forgePanel/reviewers-failed` 拒绝。变更视图随 diff 一起读取整个变更请求的标记,本地变更与所选提交的标记保存在浏览器中;两者以及提供这些操作的卡片行见[面板 README](../../packages/experimental/client-ui-forge/README.zh.md#use-this-package)。
1011
+
1012
+ `changeRequestReviewWrite(session, url, write)` 检查已绑定变更请求的一个 `ForgeReviewWrite` 的 head 提交、id、文字和行范围后,交给 `ctx.forge.writeReview`,并返回 `ForgeReviewWriteResult`。提供方给出答复后,无论结果如何,都会丢弃该变更请求保留的讨论,以及在此之前开始的所有读取,使下一次 `changeRequestReview` 从托管平台读取;`submitReview` 同样如此。变更视图一次只发送一个写操作,每个可能改变讨论的写操作之后都会重新读取讨论。
1013
+
1014
+ ```ts type-equiv
1015
+ /**
1016
+ * Consecutive commits a changes view shows instead of its whole comparison, named by full object names in the order
1017
+ * the commit list shows them, oldest first; the view shows the changes from the first commit's first parent to the last.
1018
+ */
1019
+ interface ForgeCommitRange {
1020
+ /** First, oldest commit shown. */
1021
+ readonly from: string
1022
+ /** Last, newest commit shown; equal to `from` for one commit. */
1023
+ readonly to: string
1024
+ }
1025
+ ```
1026
+
1027
+ ```ts type-equiv
1028
+ /** Which local changes a diff covers; each reads the Session's checkout through Git. */
1029
+ type ForgeLocalScope =
1030
+ /**
1031
+ * The working tree and untracked files against a fork point: the merge base of HEAD with the
1032
+ * `base` ref, or while `base` is null, the base commit of the worktree the Session created,
1033
+ * else the merge base of HEAD with the default branch of the code host remote. With `commits`, only the changes
1034
+ * of those commits between the fork point and HEAD, without uncommitted or untracked files.
1035
+ */
1036
+ | { readonly kind: 'branch'; readonly base: string | null; readonly commits: ForgeCommitRange | null }
1037
+ /** The working tree and untracked files against HEAD. */
1038
+ | { readonly kind: 'uncommitted' }
1039
+ /** The working tree and untracked files against the index. */
1040
+ | { readonly kind: 'unstaged' }
1041
+ /** The index against HEAD. */
1042
+ | { readonly kind: 'staged' }
1043
+ ```
1044
+
1045
+ ```ts type-equiv
1046
+ /** A branch the `branch` scope can compare with. */
1047
+ interface ForgeBaseBranch {
1048
+ /** Full ref name: `refs/heads/<branch>` or `refs/remotes/<remote>/<branch>`. */
1049
+ readonly ref: string
1050
+ /** The ref without `refs/heads/` or `refs/remotes/`, such as `master` or `origin/master`. */
1051
+ readonly name: string
1052
+ }
1053
+ ```
1054
+
1055
+ ```ts type-equiv
1056
+ /** What the `branch` scope compares with while no base branch is chosen. */
1057
+ interface ForgeAutomaticBase {
1058
+ /** The created worktree's base branch or abbreviated base commit, or the default branch of the code host remote. */
1059
+ readonly name: string
1060
+ /** Whether the fork point is the base commit of the worktree the Session created rather than a merge base. */
1061
+ readonly worktree: boolean
1062
+ }
1063
+ ```
1064
+
1065
+ ```ts type-equiv
1066
+ /** Branches the `branch` scope can compare with, whose names contain a query. */
1067
+ interface ForgeBaseBranches {
1068
+ /** The fork point used while no base branch is chosen, whatever the query; null without one. */
1069
+ readonly automatic: ForgeAutomaticBase | null
1070
+ /** Remote-tracking branches without symbolic refs such as `origin/HEAD`, most recently committed first, at most `maxBranches`. */
1071
+ readonly remote: readonly ForgeBaseBranch[]
1072
+ /** Local branches other than the checked-out one, most recently committed first, at most `maxBranches`. */
1073
+ readonly local: readonly ForgeBaseBranch[]
1074
+ }
1075
+ ```
1076
+
1077
+ ```ts type-equiv
1078
+ /** One hunk of a file diff. */
1079
+ interface ForgeDiffHunk {
1080
+ /** First old line the hunk covers, or the old line it comes before when it covers none. */
1081
+ readonly oldStart: number
1082
+ /** Old lines the hunk covers. */
1083
+ readonly oldLines: number
1084
+ /** First new line the hunk covers, or the new line it comes before when it covers none. */
1085
+ readonly newStart: number
1086
+ /** New lines the hunk covers. */
1087
+ readonly newLines: number
1088
+ /** Lines in patch form: a leading space for context, `+` for added, `-` for deleted, and `\` for a missing final newline. */
1089
+ readonly lines: readonly string[]
1090
+ }
1091
+ ```
1092
+
1093
+ ```ts type-equiv
1094
+ /** How one file changed. */
1095
+ type ForgeDiffStatus = 'added' | 'deleted' | 'modified' | 'renamed'
1096
+ ```
1097
+
1098
+ ```ts type-equiv
1099
+ /**
1100
+ * Review layer of a changed file: the layer the repository's root `.gitattributes` names with `dsh-review-layer`, else
1101
+ * `test` for a file it marks `linguist-generated`, else the first of `testPaths`, `interfacePaths`, and the built-in
1102
+ * test and interface rules that the path matches, else `implementation`.
1103
+ */
1104
+ type ForgeFileLayer = 'interface' | 'implementation' | 'test'
1105
+ ```
1106
+
1107
+ ```ts type-equiv
1108
+ /** One changed file of a diff. */
1109
+ interface ForgeDiffFile {
1110
+ /** Path relative to the repository root after the change, or before it for a deleted file. */
1111
+ readonly path: string
1112
+ /** Path before a rename, else null. */
1113
+ readonly previousPath: string | null
1114
+ /** How the file changed. */
1115
+ readonly status: ForgeDiffStatus
1116
+ /** Whether the content is binary, which carries no hunks. */
1117
+ readonly binary: boolean
1118
+ /** Whether an untracked file exceeds `maxDiffBytes`, so it carries no hunks. */
1119
+ readonly oversized: boolean
1120
+ /** Whether Git does not track the file yet; only local diffs list such files. */
1121
+ readonly untracked: boolean
1122
+ /** Lines added. */
1123
+ readonly additions: number
1124
+ /** Lines deleted. */
1125
+ readonly deletions: number
1126
+ /** Hunks in file order; none for a binary file or a change of mode or name only. */
1127
+ readonly hunks: readonly ForgeDiffHunk[]
1128
+ /** Review layer the path falls in. */
1129
+ readonly layer: ForgeFileLayer
1130
+ /**
1131
+ * Digest of the file's change: its paths, status, and hunks, plus the blob names of a binary change, or the content
1132
+ * of an untracked binary file. Equal digests describe the same change; reading the same comparison again keeps it.
1133
+ */
1134
+ readonly digest: string
1135
+ }
1136
+ ```
1137
+
1138
+ ```ts type-equiv
1139
+ /** Local changes of the Session's checkout in one scope. */
1140
+ interface ForgeLocalDiff {
1141
+ /** Ref or abbreviated commit the `branch` scope compares with, such as `origin/master`; null for other scopes. */
1142
+ readonly base: string | null
1143
+ /** Changed files in Git's path order, untracked files last. */
1144
+ readonly files: readonly ForgeDiffFile[]
1145
+ /** Untracked files left out beyond `maxUntrackedFiles`. */
1146
+ readonly omitted: number
1147
+ }
1148
+ ```
1149
+
1150
+ ```ts type-equiv
1151
+ /** Changes of a change request, or of consecutive commits of it, as its code host computes them. */
1152
+ interface ForgeChangeRequestDiff {
1153
+ /** Commit whose new side the diff describes: the head, or the last chosen commit. */
1154
+ readonly headSha: string
1155
+ /** Changed files in the host's order. */
1156
+ readonly files: readonly ForgeDiffFile[]
1157
+ /**
1158
+ * Commits the checkout's branch has beyond the head when that branch is the change request's head
1159
+ * branch and the head commit is present locally; null otherwise and for chosen commits.
1160
+ */
1161
+ readonly localAhead: number | null
1162
+ /** Web page of each changed file at `headSha`, by path. */
1163
+ readonly fileUrls: Readonly<Record<string, string>>
1164
+ }
1165
+ ```
1166
+
1167
+ ```ts type-equiv
1168
+ /** Commits of the `branch` scope at one HEAD commit, which the changes view can show one or several of. */
1169
+ interface ForgeLocalCommits {
1170
+ /** HEAD commit the list was read at. */
1171
+ readonly headSha: string
1172
+ /** Commits oldest first, ending with HEAD's commit. */
1173
+ readonly commits: readonly ForgeCommit[]
1174
+ /** Whether the branch has more commits than `maxCommits`; the listed ones are the newest. */
1175
+ readonly truncated: boolean
1176
+ }
1177
+ ```
1178
+
1179
+ ```ts type-equiv
1180
+ /** One file the `branch` scope changes, without its hunks. */
1181
+ interface ForgeChangedFile {
1182
+ /** Path relative to the repository root after the change. */
1183
+ readonly path: string
1184
+ /** Lines added, or 0 for a binary file. */
1185
+ readonly additions: number
1186
+ /** Lines deleted, or 0 for a binary file. */
1187
+ readonly deletions: number
1188
+ /** Whether the content is binary. */
1189
+ readonly binary: boolean
1190
+ }
1191
+ ```
1192
+
1193
+ ```ts type-equiv
1194
+ /** Size of the `branch` scope, which the panel's local changes card shows. */
1195
+ interface ForgeLocalChanges {
1196
+ /** Ref or abbreviated commit the scope compares with. */
1197
+ readonly base: string
1198
+ /** Changed files in Git's path order, untracked files last, at most `maxUntrackedFiles` of those. */
1199
+ readonly files: readonly ForgeChangedFile[]
1200
+ }
1201
+ ```
1202
+
1203
+ <a id="extension-api"></a>
1204
+
1205
+ ## 扩展 API
1206
+
1207
+ 其他插件通过上面的服务和另外五个扩展点扩展变更请求评审;每次注册都返回 disposer,并随做出注册的插件一起结束。与这一能力的其余部分一样,这些接口处于实验阶段,尚未稳定。新增可选字段、方法、slot、事件、错误码或带默认值的 Config 键是兼容的;删除或改名类型、方法、slot、owner props、事件、Config 键或 `dsh-resource://forge-changes/` 地址,或收窄其含义,需要写[升级指南](../../.agents/skills/dsh-create-upgrade-guide/SKILL.md)。这些扩展点都不向模型发送任何内容:插件要让模型看到 forge 数据、透镜结果或注解,须经由它自己的工具结果或 `agent.inject()`,Session log 会记录它们。
1208
+
1209
+ | 扩展点 | Service Definition | Service Provider | Consumer |
1210
+ |---|---|---|---|
1211
+ | 评审数据 | `ctx.forge` 与 `forge/review-changed` 事件 | 各 forge 提供方 | 面板 Host 与其他 Host 插件 |
1212
+ | 筛选透镜 | `ctx.forgePanel.registerLens` | Host 插件 | 经 `changesLens` 使用它的变更视图 |
1213
+ | 变更视图接口 | `ctx.forgeChanges` | forge 面板的 Client 插件 | 打开视图、给透镜起名、添加注解的 Client 插件 |
1214
+ | Slot | `forge.changes.toolbar`、`forge.changes.file.menu`、`forge.diff.line.annotation`、`forge.diff.comment.actions`、`forge.change-request.card.actions` | Client 插件 | 变更视图与变更请求卡片 |
1215
+ | Session 数据 | `forgeChangeRequests` 与 `forgeWorktree` 投影 | forge-session 与 forge 面板 | Client 插件经 `useProjection` 读取,Host 插件经 `ctx.forgeSession.changeRequests` 或 `ctx.sessionProjections.snapshot` 读取 |
1216
+
1217
+ 托管平台接受一次评审写入、一次评审提交或一个已审阅标记后,`ctx.forge` 发出 `forge/review-changed`,无论是哪个插件做的;结果未知、被拒绝、已过时或不支持时不发出。面板 Host 随后丢弃为该变更请求保留的讨论,并让对应条目的 `reviewRevision` 加一,因此已打开的变更视图无需刷新就会重新读取讨论和已审阅标记。
1218
+
1219
+ ```ts type-equiv
1220
+ /**
1221
+ * One review change the host accepted, which `forge/review-changed` announces: a write to the threads or the pending
1222
+ * review, a submitted review, or a viewed mark. Each names the head commit the change was made against.
1223
+ */
1224
+ type ForgeReviewChange =
1225
+ | { readonly kind: 'write'; readonly write: ForgeReviewWrite['kind']; readonly headSha: string }
1226
+ | { readonly kind: 'submit'; readonly headSha: string }
1227
+ | { readonly kind: 'viewed'; readonly path: string; readonly viewed: boolean; readonly headSha: string }
1228
+ ```
1229
+
1230
+ Host 插件用 `ctx.forgePanel.registerLens(lens)` 注册筛选透镜,Client 插件用 `ctx.forgeChanges.describeLens({ id, title })` 给它起名;没有名字的透镜显示其身份。透镜筛选显示的文件,不给文件分层:变更视图显示所选分层与所选透镜都保留的文件,测试文件开关仍然隐藏测试文件,透镜也不能把文件移到另一层。被保留文件中与 `ranges` 都不相交的 hunk 折叠成一行,读者可以展开。视图只请求所选的透镜,经流式 Remote `changesLens` 进行:它读取与视图相同的文件,文件不同时以 `forgePanel/lens-stale` 拒绝,并在 `lensTimeoutMs` 与 `maxLensReadBytes` 之内运行 `classify`;结果最多保留 `maxCachedLensBytes`。`text` 在分叉点、HEAD、暂存区或第一个所选提交的父提交上读取本地变更的旧侧,在所选提交的父提交上,或在提供方经可选的 `mergeBase` 给出的合并基准上读取变更请求的旧侧。
1231
+
1232
+ ```ts type-equiv
1233
+ /** A filter over the files of a changes view, which a plugin registers with `ctx.forgePanel.registerLens()`. */
1234
+ interface ForgeLens {
1235
+ /** Identity the plugin chooses; one registration holds an id at a time. */
1236
+ readonly id: ForgeLensId
1237
+ /** Changes whenever `classify` may answer differently for the same input, which drops results kept under another version. */
1238
+ readonly version: string
1239
+ /**
1240
+ * Decide which files the lens keeps and which lines it is about. The signal aborts when the reader stops waiting, the
1241
+ * registration ends, or `lensTimeoutMs` passes; a rejection fails the request without a partial result.
1242
+ */
1243
+ classify(input: ForgeLensInput, signal: AbortSignal): Promise<ForgeLensResult>
1244
+ }
1245
+ ```
1246
+
1247
+ ```ts type-equiv
1248
+ /** What one `classify` call receives. */
1249
+ interface ForgeLensInput {
1250
+ /** What the view shows. */
1251
+ readonly source: ForgeLensSource
1252
+ /** Every file of the diff in display order, with the layer the panel gave it. */
1253
+ readonly files: readonly ForgeLensFile[]
1254
+ /**
1255
+ * Read one side of a file of `files`, by its `path`: the old side reads `previousPath` for a renamed file. Resolves to
1256
+ * null when the side does not exist, as the old side of an added file, or holds binary content. Rejects for a path not
1257
+ * in `files`, once the reads of one call exceed the panel's `maxLensReadBytes`, for an old side the provider cannot
1258
+ * locate, and when the read fails.
1259
+ */
1260
+ text(side: 'old' | 'new', path: string, signal: AbortSignal): Promise<string | null>
1261
+ /** Report how many of `total` units the lens finished; the changes view shows it while the lens runs. */
1262
+ progress(done: number, total: number): void
1263
+ }
1264
+ ```
1265
+
1266
+ ```ts type-equiv
1267
+ /** The files a lens keeps, by path; a file the result does not name is filtered out. */
1268
+ interface ForgeLensResult {
1269
+ readonly files: Readonly<Record<string, ForgeLensKeep>>
1270
+ }
1271
+ ```
1272
+
1273
+ ```ts type-equiv
1274
+ /** What a lens keeps of one file. */
1275
+ interface ForgeLensKeep {
1276
+ /**
1277
+ * Lines the lens is about on each side; hunks that touch none of them fold into one row the reader can expand.
1278
+ * Omitted: every hunk of the file shows.
1279
+ */
1280
+ readonly ranges?: { readonly old: readonly ForgeLineRange[]; readonly new: readonly ForgeLineRange[] }
1281
+ }
1282
+ ```
1283
+
1284
+ `ctx.forgeChanges` 还可以生成和解析变更视图地址,给出标签的 `kinds`,并用 `open(target, { path, lens })` 在侧栏所显示的 Session 中打开视图。`registerAnnotations(source)` 添加行注解:数据源按路径观察每个视图的注解,它在 `forge.diff.line.annotation` 中按数据源身份登记的条目,负责绘制视图所画外框里的内容。注解放在其最后一行之后,位于评论框、浏览器草稿和托管平台讨论之后,落在所在一侧的那一栏;整个文件的注解排在最前,写在另一个 `digest` 上的注解在文件之后单独成段。每个文件最多显示 `maxAnnotationsPerFile` 条;逐行绘制的文件在文件段进入可视区附近之前不绘制注解。所有 slot 的 owner props 见 [`src/client/slots.ts`](../../packages/experimental/client-ui-forge/src/client/slots.ts)。
1285
+
1286
+ ```ts type-equiv
1287
+ /** Where one line annotation sits in a file of a changes view. */
1288
+ interface ForgeLineAnnotation {
1289
+ /** Identity within its source, stable across updates; it keys the drawn entry. */
1290
+ readonly key: string
1291
+ /** Inclusive 1-based lines on the old (`L`) or new (`R`) side, or `file` for the whole file. */
1292
+ readonly place: { readonly side: 'L' | 'R'; readonly startLine: number; readonly endLine: number } | 'file'
1293
+ /** Digest of the file change it was written on; a file whose `digest` differs shows it in its outdated section. */
1294
+ readonly digest?: string
1295
+ /** Changes whenever the entry should draw again; equal keys and versions keep the drawn entry's props. */
1296
+ readonly version: string | number
1297
+ }
1298
+ ```
1299
+
1300
+ ```ts type-equiv
1301
+ /** A Client plugin's line annotations, drawn through its `forge.diff.line.annotation` entry. */
1302
+ interface ForgeAnnotationSource {
1303
+ /** Unique source identity, also the key of its `forge.diff.line.annotation` entry. */
1304
+ readonly id: string
1305
+ /** Position among sources in one stack, lower first; equal positions keep registration order. Default 0. */
1306
+ readonly order?: number
1307
+ /**
1308
+ * Observe the annotations of one view, by path. The changes view calls it once per view and source registration;
1309
+ * the source republishes through the same observable whenever the annotations change.
1310
+ * @param target - the view's Session and source.
1311
+ * @returns annotations by repository-relative path.
1312
+ */
1313
+ observe(target: ChangesTarget): HostObservable<ReadonlyMap<string, readonly ForgeLineAnnotation[]>>
1314
+ }
1315
+ ```
1316
+
1317
+ <!-- BEGIN GENERATED cordis-surface (gen-cordis-catalog.ts) — do not edit between markers -->
1318
+
1319
+ <a id="cordis-surface"></a>
1320
+
1321
+ ## Cordis API
1322
+
1323
+ Generated from source by `scripts/gen-cordis-catalog.ts` (verified fresh by `pnpm run verify-cordis-catalog` in doc-sync; regenerate with `pnpm run gen-cordis-catalog`) — the language sides differ only in locale-specific paired document paths. Signature blocks use a `ts cordis-catalog` fence and keep the original source JSDoc; dispatch modes are defined in the [primer](../cordis-primer.zh.md#dispatch-modes), and the framework-inherited `ctx` API lives in [cordis-api/inherited.md](../cordis-api/inherited.md).
1324
+
1325
+ <a id="ctxforge--forgeservice"></a>
1326
+
1327
+ ### `ctx.forge` — `ForgeService`
1328
+
1329
+ Registry of forge providers. Watchers of one change request share a single polling loop; each forge has at most one fetch in flight, which batches every due change request of that forge.
1330
+
1331
+ ```ts cordis-catalog
1332
+ /**
1333
+ * Register the provider of one forge family as an effect on the calling
1334
+ * fiber. Watches of that forge receive an `unavailable` failure when the
1335
+ * registration ends. Unregistering cancels and awaits its in-flight calls;
1336
+ * results from the withdrawn registration are discarded.
1337
+ * @param provider - provider to serve `provider.forge`.
1338
+ * @returns the disposer that unregisters the provider and waits for its calls to finish.
1339
+ * @throws when another provider already serves the same forge.
1340
+ */
1341
+ register(provider: ForgeProvider): () => Promise<void>
1342
+
1343
+ /**
1344
+ * Map a Git remote URL to a repository through the first provider that serves it.
1345
+ * @param url - fetch or push URL as Git reports it.
1346
+ * @returns the repository, or undefined when no provider serves the URL.
1347
+ */
1348
+ repositoryFromRemote(url: string): ForgeRepository | undefined
1349
+
1350
+ /**
1351
+ * Map a change request web URL through the first provider that serves it.
1352
+ * @param url - web URL of a pull or merge request.
1353
+ * @returns the change request, or undefined when no provider serves the URL.
1354
+ */
1355
+ changeRequestFromUrl(url: string): ChangeRequestRef | undefined
1356
+
1357
+ /**
1358
+ * Build the canonical web URL of a change request.
1359
+ * @param ref - change request served by a registered provider.
1360
+ * @returns the provider's canonical URL.
1361
+ * @throws when no provider serves the change request's forge.
1362
+ */
1363
+ changeRequestUrl(ref: ChangeRequestRef): string
1364
+
1365
+ /**
1366
+ * Find open change requests whose head is `branch`, excluding the default branch and forks.
1367
+ * @param repository - repository served by a registered provider.
1368
+ * @param branch - head branch name on the host.
1369
+ * @param signal - cancellation for the lookup.
1370
+ * @returns matching change requests, newest first as the provider reports them.
1371
+ * @throws when no provider serves the repository's forge or the lookup fails.
1372
+ */
1373
+ async findByHead(repository: ForgeRepository, branch: string, signal: AbortSignal): Promise<readonly ChangeRequestRef[]>
1374
+
1375
+ /**
1376
+ * Report whether the provider can reach the repository's host with current credentials.
1377
+ * @param repository - repository served by a registered provider.
1378
+ * @param signal - cancellation for the probe.
1379
+ * @returns the provider's readiness for the host.
1380
+ * @throws when no provider serves the repository's forge.
1381
+ */
1382
+ async readiness(repository: ForgeRepository, signal: AbortSignal): Promise<ForgeReadiness>
1383
+
1384
+ /**
1385
+ * Mark a draft change request ready for review, then poll it at once when it is watched.
1386
+ * @param ref - change request served by a registered provider.
1387
+ * @param signal - cancellation of the request.
1388
+ * @returns undefined once the host accepted the change, or why it did not.
1389
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1390
+ */
1391
+ async markReady(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
1392
+
1393
+ /**
1394
+ * Merge a change request while its head is still `request.headSha`, then
1395
+ * poll it at once when it is watched.
1396
+ * @param ref - change request served by a registered provider.
1397
+ * @param request - merge method and the head commit the user confirmed.
1398
+ * @param signal - cancellation of the request.
1399
+ * @returns undefined once the host merged it, or why it did not.
1400
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1401
+ */
1402
+ async merge(ref: ChangeRequestRef, request: MergeRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
1403
+
1404
+ /**
1405
+ * Rerun the failed checks of a change request's head commit while the head is still `request.headSha`, then poll it
1406
+ * at once when it is watched.
1407
+ * @param ref - change request served by a registered provider.
1408
+ * @param request - the head commit whose checks the user saw.
1409
+ * @param signal - cancellation of the request.
1410
+ * @returns undefined once the host accepted the rerun, or why it did not; a provider that reruns no checks fails.
1411
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1412
+ */
1413
+ async rerunChecks(ref: ChangeRequestRef, request: ForgeRerunRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
1414
+
1415
+ /**
1416
+ * Request reviews of a change request from more reviewers, then poll it at once when it is watched.
1417
+ * @param ref - change request served by a registered provider.
1418
+ * @param request - the reviewers to ask.
1419
+ * @param signal - cancellation of the request.
1420
+ * @returns undefined once the host accepted the request, or why it did not; a provider that requests no reviews fails.
1421
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1422
+ */
1423
+ async requestReviews( ref: ChangeRequestRef, request: ForgeReviewersRequest, signal: AbortSignal, ): Promise<ForgeActionFailure | undefined>
1424
+
1425
+ /**
1426
+ * List accounts a review of a change request can be requested from.
1427
+ * @param ref - change request served by a registered provider.
1428
+ * @param query - text the login or name contains; empty for the host's suggestions and first accounts.
1429
+ * @param signal - cancellation of the read.
1430
+ * @returns the accounts, the host's suggestions first, or why the host did not list them; a provider that requests no
1431
+ * reviews returns `unsupported`.
1432
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1433
+ */
1434
+ async reviewerCandidates( ref: ChangeRequestRef, query: string, signal: AbortSignal, ): Promise<readonly ForgeReviewerCandidate[] | ForgeFailure>
1435
+
1436
+ /**
1437
+ * Bring the base branch's new commits into a change request's head branch while its head is still
1438
+ * `request.headSha`, then poll it at once when it is watched.
1439
+ * @param ref - change request served by a registered provider.
1440
+ * @param request - update method and the head commit the user confirmed.
1441
+ * @param signal - cancellation of the request.
1442
+ * @returns undefined once the host accepted the update, or why it did not; a provider that updates no branches fails.
1443
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1444
+ */
1445
+ async updateBranch(ref: ChangeRequestRef, request: BranchUpdateRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
1446
+
1447
+ /**
1448
+ * Read complete check details independently of periodic polling.
1449
+ * @param ref - change request served by a registered provider.
1450
+ * @param signal - cancellation of the detail view.
1451
+ * @returns a complete snapshot or the provider's failure; unsupported providers return unavailable.
1452
+ * @throws on cancellation, provider disposal, or expiry of this read's own `fetchTimeoutMs` deadline.
1453
+ */
1454
+ async fetchChecks(ref: ChangeRequestRef, signal: AbortSignal): Promise<ChangeRequestSnapshot | ForgeFailure>
1455
+
1456
+ /**
1457
+ * Read the changes of a change request at one head commit as its host
1458
+ * computes them. The first `stale` failure at a head commit polls a watched
1459
+ * change request again at once, so its next status names the current head;
1460
+ * later stale reads at the same commit wait for the regular poll, which
1461
+ * bounds the reads while the host's answers disagree. When the latest status of a watched change request names
1462
+ * `headSha`, its `baseSha` goes to the provider, which may then read the patch while it confirms the head.
1463
+ * @param ref - change request served by a registered provider.
1464
+ * @param headSha - head commit the patch must describe, usually the head of the latest status.
1465
+ * @param signal - cancellation of the read.
1466
+ * @returns one unified patch with `a/` and `b/` path prefixes, or why the host did not provide it at `headSha`.
1467
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1468
+ */
1469
+ async diff(ref: ChangeRequestRef, headSha: string, signal: AbortSignal): Promise<string | ForgeFailure>
1470
+
1471
+ /**
1472
+ * Read the review threads of a change request at one head commit. A
1473
+ * `stale` failure polls a watched change request again as {@link ForgeService.diff} does.
1474
+ * @param ref - change request served by a registered provider.
1475
+ * @param headSha - head commit the threads must be read at, usually the head of the displayed diff.
1476
+ * @param signal - cancellation of the read.
1477
+ * @returns the threads read at `headSha`, or why the host did not provide them; `unsupported` when the provider cannot read reviews.
1478
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1479
+ */
1480
+ async readReview(ref: ChangeRequestRef, headSha: string, signal: AbortSignal): Promise<ForgeReviewData | ForgeFailure>
1481
+
1482
+ /**
1483
+ * Write to the review threads or the pending review of a change request while its head is still `write.headSha`, then
1484
+ * poll the change request at once when it is watched, unless the provider cannot write reviews. A `stale` result polls
1485
+ * it as a stale read does; a write the host took is announced with `forge/review-changed`.
1486
+ * @param ref - change request served by a registered provider.
1487
+ * @param write - the write and the head commit the user saw.
1488
+ * @param signal - cancellation of the write.
1489
+ * @returns whether the host took the write; `unsupported` when the provider cannot write reviews, and `unknown` when the
1490
+ * outcome must be checked on the host before the write is tried again.
1491
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1492
+ */
1493
+ async writeReview(ref: ChangeRequestRef, write: ForgeReviewWrite, signal: AbortSignal): Promise<ForgeReviewWriteResult>
1494
+
1495
+ /**
1496
+ * Read the signed-in user's viewed marks on the files of a change request at one head commit. A `stale` failure
1497
+ * polls a watched change request again as {@link ForgeService.diff} does.
1498
+ * @param ref - change request served by a registered provider.
1499
+ * @param headSha - head commit the marks must be read at, usually the head of the displayed diff.
1500
+ * @param signal - cancellation of the read.
1501
+ * @returns the marks read at `headSha`, why the host did not provide them, or undefined when the provider keeps no
1502
+ * viewed marks.
1503
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1504
+ */
1505
+ async viewedFiles(ref: ChangeRequestRef, headSha: string, signal: AbortSignal): Promise<ForgeViewedFiles | ForgeFailure | undefined>
1506
+
1507
+ /**
1508
+ * Set or clear the signed-in user's viewed mark on one file of a change request while its head is still
1509
+ * `request.headSha`. A `stale` failure polls a watched change request again as {@link ForgeService.diff} does; a saved
1510
+ * mark is announced with `forge/review-changed`.
1511
+ * @param ref - change request served by a registered provider.
1512
+ * @param request - the file, its mark, and the head commit the user saw.
1513
+ * @param signal - cancellation of the request.
1514
+ * @returns undefined once the host saved the mark, or why it did not; a provider that keeps no viewed marks fails.
1515
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1516
+ */
1517
+ async setViewed(ref: ChangeRequestRef, request: ForgeViewedRequest, signal: AbortSignal): Promise<ForgeActionFailure | undefined>
1518
+
1519
+ /**
1520
+ * List the commits of a change request at its current head.
1521
+ * @param ref - change request served by a registered provider.
1522
+ * @param signal - cancellation of the read.
1523
+ * @returns the commits, why the host did not provide them, or undefined when the provider does not read commits.
1524
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1525
+ */
1526
+ async commits(ref: ChangeRequestRef, signal: AbortSignal): Promise<ForgeCommitList | ForgeFailure | undefined>
1527
+
1528
+ /**
1529
+ * Read the changes between two commits of a change request's repository.
1530
+ * @param ref - change request served by a registered provider.
1531
+ * @param base - full object name of the commit compared from.
1532
+ * @param head - full object name of a commit that descends from `base`.
1533
+ * @param signal - cancellation of the read.
1534
+ * @returns one unified patch with `a/` and `b/` path prefixes, or why the host did not provide it; a provider that
1535
+ * does not read commits returns `unavailable`.
1536
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1537
+ */
1538
+ async compare(ref: ChangeRequestRef, base: string, head: string, signal: AbortSignal): Promise<string | ForgeFailure>
1539
+
1540
+ /**
1541
+ * Find the merge base of two commits of a change request's repository: the commit whose files the old side of the
1542
+ * change request's diff shows when `base` is the snapshot's `baseSha` and `head` its `headSha`.
1543
+ * @param ref - change request served by a registered provider.
1544
+ * @param base - full object name of the base commit.
1545
+ * @param head - full object name of the head commit.
1546
+ * @param signal - cancellation of the read.
1547
+ * @returns the merge base's full object name, or why the host did not provide it; `unsupported` when the provider
1548
+ * cannot name merge bases.
1549
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1550
+ */
1551
+ async mergeBase(ref: ChangeRequestRef, base: string, head: string, signal: AbortSignal): Promise<string | ForgeFailure>
1552
+
1553
+ /**
1554
+ * Publish one comment or a completed review, then refresh the watched status; a publication the host took is announced
1555
+ * with `forge/review-changed`.
1556
+ * @param ref - change request served by a registered provider.
1557
+ * @param request - explicitly selected commit, comments, and review decision.
1558
+ * @param signal - request cancellation.
1559
+ * @returns a publication URL or a failure, including an unknown write outcome.
1560
+ */
1561
+ async submitReview(ref: ChangeRequestRef, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
1562
+
1563
+ /**
1564
+ * Read the text of one file at a commit of a change request's repository.
1565
+ * @param ref - change request served by a registered provider.
1566
+ * @param commit - commit object name.
1567
+ * @param path - path relative to the repository root.
1568
+ * @param signal - cancellation of the read.
1569
+ * @returns the text, or why the host did not provide it.
1570
+ * @throws when no provider serves the change request's forge, or with `signal.reason` when it aborts.
1571
+ */
1572
+ async fileText(ref: ChangeRequestRef, commit: string, path: string, signal: AbortSignal): Promise<string | ForgeFailure>
1573
+
1574
+ /**
1575
+ * Build the web page of one file at a commit of a change request's repository.
1576
+ * @param ref - change request served by a registered provider.
1577
+ * @param commit - commit object name.
1578
+ * @param path - path relative to the repository root.
1579
+ * @returns the provider's URL.
1580
+ * @throws when no provider serves the change request's forge.
1581
+ */
1582
+ fileUrl(ref: ChangeRequestRef, commit: string, path: string): string
1583
+
1584
+ /**
1585
+ * Watch one change request as an effect on the calling fiber. The first
1586
+ * watcher starts polling at once; listeners receive every later result,
1587
+ * and `latest` returns the current one. Polling stops when the last watcher
1588
+ * leaves. Listeners must not throw; a thrown error is logged and skipped.
1589
+ * @param ref - change request to poll.
1590
+ * @param listener - receives each polling result.
1591
+ * @returns the disposer that stops this watch.
1592
+ */
1593
+ watch(ref: ChangeRequestRef, listener: ChangeRequestListener): () => void
1594
+
1595
+ /**
1596
+ * Poll a watched change request at once, including after a terminal state.
1597
+ * A fetch already in flight is followed immediately by another fetch; an
1598
+ * unwatched change request is unchanged.
1599
+ * @param ref - change request to poll.
1600
+ */
1601
+ refresh(ref: ChangeRequestRef): void
1602
+
1603
+ /**
1604
+ * Read the latest polling result of a watched change request.
1605
+ * @param ref - change request to read.
1606
+ * @returns the latest result, or undefined before the first result or without a watch.
1607
+ */
1608
+ latest(ref: ChangeRequestRef): ChangeRequestUpdate | undefined
1609
+ ```
1610
+
1611
+ Source: [`packages/experimental/forge/src/index.ts`](../../packages/experimental/forge/src/index.ts)
1612
+
1613
+ <a id="ctxforgepanel--forgepanelcontroller"></a>
1614
+
1615
+ ### `ctx.forgePanel` — `ForgePanelController`
1616
+
1617
+ Serves the forge panel. Following a Session inspects the checkout of its current directory using the Session's permissions and execution world, recognizes the code host of the upstream remote or `origin`, probes sign-in for that host, and polls the Session's bound change requests through `ctx.forge` until the last follower of that Session leaves. A worktree request makes the panel create a branch and checkout through an optional `ctx.worktrees` and enter it while the Session's first message waits in the inbox, or at the first step proposal of a message no wait took. After a failed or stopped attempt the message keeps waiting for another attempt or for the request to be withdrawn. A message also waits while the worktree the Session works in is gone, until that worktree is checked out again or left for the source checkout. Changes to a Session's checkout run as Agent maintenance, so a message that arrives meanwhile waits for them.
1618
+
1619
+ ```ts cordis-catalog
1620
+ /**
1621
+ * Stream the panel state of a Session: the current state first, then each
1622
+ * later state. Intermediate states may be skipped when the reader is slower
1623
+ * than the updates. The stream ends when `signal` aborts or the Remote stops.
1624
+ * @param session - Session to follow.
1625
+ * @param signal - ends the stream.
1626
+ * @returns panel states in publication order.
1627
+ */
1628
+ @Remote({ mode: 'stream' }) async *follow(session: Session, signal: AbortSignal): AsyncIterable<ForgePanelState>
1629
+
1630
+ /**
1631
+ * Stream the last known state of every change request that a listed
1632
+ * Session the caller may read binds: the stored states first, then each
1633
+ * state a poll changes or a new binding reveals. Listing reads no Session
1634
+ * log: loaded Sessions report their bindings, others the cached Session
1635
+ * summary, and a Session without one shows nothing until it is opened.
1636
+ * Closed requests are polled at the idle cadence so reopening is observed. The
1637
+ * stream ends when `signal` aborts or the Remote stops.
1638
+ * @param signal - ends the stream.
1639
+ * @returns frames in publication order.
1640
+ * @throws when the Host lacks the Session query, projection cache, storage, or Session store service.
1641
+ */
1642
+ @Remote({ mode: 'stream' }) async *changeRequestStates(signal: AbortSignal): AsyncIterable<ForgeChangeRequestStatesFrame>
1643
+
1644
+ /**
1645
+ * Read or await the worktree service's archive cleanup of the Session's checkout.
1646
+ * @param session - Session whose cleanup is visible to the caller.
1647
+ * @param revision - null reads now; a matching revision waits for completion.
1648
+ * @returns the cleanup state, or null without a worktree service, an attempt, or a current revision.
1649
+ */
1650
+ @Remote async worktreeCleanup(session: Session, revision: number | null): Promise<WorktreeCleanup | null>
1651
+
1652
+ /**
1653
+ * List the local branches that can start a worktree of the Session's current checkout.
1654
+ * @param session - Session whose current directory is listed.
1655
+ * @param signal - request cancellation.
1656
+ * @returns the checked-out branch and at most `maxBranches` local branches, the checked-out one first.
1657
+ * @throws when the current directory is not inside a checkout or Git fails.
1658
+ */
1659
+ @Remote async branches(session: Session, signal: AbortSignal): Promise<ForgeBranches>
1660
+
1661
+ /**
1662
+ * List the branches the `branch` scope of the Session's current checkout can compare with.
1663
+ * @param session - Session whose checkout is read.
1664
+ * @param query - text the branch names must contain, ignoring case; empty for every branch.
1665
+ * @param signal - request cancellation.
1666
+ * @returns the automatic fork point and at most `maxBranches` remote-tracking and local branches each,
1667
+ * most recently committed first, without the checked-out branch.
1668
+ * @throws `forgePanel/not-a-checkout` outside a checkout; the Git error when Git fails or the listed refs exceed `maxDiffBytes`.
1669
+ */
1670
+ @Remote async diffBases(session: Session, query: string, signal: AbortSignal): Promise<ForgeBaseBranches>
1671
+
1672
+ /**
1673
+ * Bind a change request to a Session by URL, or restore a dismissed binding.
1674
+ * @param session - Session that receives the binding.
1675
+ * @param url - web URL of the change request.
1676
+ * @param signal - request cancellation.
1677
+ * @throws `forgePanel/unrecognized-url` when no registered provider serves the URL.
1678
+ */
1679
+ @Remote async track(session: Session, url: string, signal: AbortSignal): Promise<void>
1680
+
1681
+ /**
1682
+ * Hide a visible binding of a Session; other URLs leave the Session unchanged.
1683
+ * @param session - Session that owns the binding.
1684
+ * @param url - web URL of the change request.
1685
+ * @param signal - request cancellation.
1686
+ */
1687
+ @Remote async dismiss(session: Session, url: string, signal: AbortSignal): Promise<void>
1688
+
1689
+ /**
1690
+ * Reinspect a followed Session's checkout, probe sign-in again, and poll its
1691
+ * change requests at once; an unfollowed Session is unchanged.
1692
+ * @param session - Session whose panel refreshes.
1693
+ * @param signal - request cancellation.
1694
+ * @returns settles once the inspection and the sign-in probe have ended; poll results reach the panel stream later.
1695
+ */
1696
+ @Remote async refresh(session: Session, signal: AbortSignal): Promise<void>
1697
+
1698
+ /**
1699
+ * Read the changes one scope covers in the checkout of the Session's
1700
+ * current directory, with Git using the Session's sandbox policy.
1701
+ * @param session - Session whose checkout is read.
1702
+ * @param scope - which changes to read.
1703
+ * @param signal - request cancellation.
1704
+ * @returns the files, the base of the `branch` scope, and the untracked files left out.
1705
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/base-missing` when the base branch
1706
+ * chosen for the `branch` scope does not exist; `forgePanel/no-fork-point` for the `branch` scope without
1707
+ * a fork point; `forgePanel/commits-missing` when chosen commits are not between the fork point and HEAD in order;
1708
+ * `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
1709
+ * `forgePanel/filter-config-failed` when filter configuration cannot be read completely, before
1710
+ * any comparison; `forgePanel/diff-too-large` over `maxDiffBytes`; the Git error when Git fails.
1711
+ */
1712
+ @Remote async localDiff(session: Session, scope: ForgeLocalScope, signal: AbortSignal): Promise<ForgeLocalDiff>
1713
+
1714
+ /**
1715
+ * List the commits of the `branch` scope of the Session's current checkout, which the changes view can show one or
1716
+ * several of instead of the whole scope.
1717
+ * @param session - Session whose checkout is read.
1718
+ * @param base - the base ref of the `branch` scope, or null for its automatic fork point.
1719
+ * @param signal - request cancellation.
1720
+ * @returns the newest `maxCommits` commits between the fork point and HEAD, oldest first, and HEAD's commit.
1721
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/base-missing` when the base branch does not
1722
+ * exist; `forgePanel/no-fork-point` without a fork point; the Git error when Git fails or the listing exceeds `maxDiffBytes`.
1723
+ */
1724
+ @Remote async localCommits(session: Session, base: string | null, signal: AbortSignal): Promise<ForgeLocalCommits>
1725
+
1726
+ /**
1727
+ * Read the new side of one changed file in a scope, which supplies the
1728
+ * unchanged lines between its hunks: the index for `staged`, the last chosen commit for chosen commits of
1729
+ * the `branch` scope, else the working tree.
1730
+ * @param session - Session whose checkout is read.
1731
+ * @param scope - the scope the diff was read in.
1732
+ * @param path - path relative to the checkout's top-level directory, as the diff names it.
1733
+ * @param signal - request cancellation.
1734
+ * @returns the text.
1735
+ * @throws `forgePanel/not-a-checkout` outside a checkout; `forgePanel/diff-too-large` over `maxDiffBytes`;
1736
+ * `forgePanel/commits-missing` for a chosen commit that is not a full object name; an error for a path outside
1737
+ * the checkout, binary content, or a failed read.
1738
+ */
1739
+ @Remote async localText(session: Session, scope: ForgeLocalScope, path: string, signal: AbortSignal): Promise<string>
1740
+
1741
+ /**
1742
+ * Load complete checks for the change request whose list the user opened.
1743
+ * @param session - Session retaining the visible binding.
1744
+ * @param url - binding URL.
1745
+ * @param headSha - commit displayed by the card; a different head rejects the result.
1746
+ * @param signal - cancellation when the list closes.
1747
+ * @returns the complete snapshot at the displayed head.
1748
+ * @throws `forgePanel/not-bound` for an invisible binding, `forgePanel/stale-head` for a moved head,
1749
+ * or `forgePanel/checks-failed` when the provider cannot complete the read.
1750
+ */
1751
+ @Remote async changeRequestChecks(session: Session, url: string, headSha: string, signal: AbortSignal): Promise<ChangeRequestSnapshot>
1752
+
1753
+ /**
1754
+ * List the commits of a change request of a Session at its current head, which the changes view can show one or
1755
+ * several of instead of the whole change request.
1756
+ * @param session - Session the change request is bound to.
1757
+ * @param url - binding URL of the change request.
1758
+ * @param signal - request cancellation.
1759
+ * @returns the commits oldest first with the head they were read at, or null when the provider does not read commits.
1760
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1761
+ * `forgePanel/diff-failed` when the host does not list them.
1762
+ */
1763
+ @Remote async changeRequestCommits(session: Session, url: string, signal: AbortSignal): Promise<ForgeCommitList | null>
1764
+
1765
+ /**
1766
+ * Read the changes of a change request of a Session as its code host
1767
+ * computes them, with each file's layer following the root `.gitattributes`
1768
+ * of the commit the diff ends at. Without `commits` the diff covers the change
1769
+ * request at the head commit of its latest status; a patch already read at the
1770
+ * same head commit and base branch is reused from memory with its attributes, for
1771
+ * any Session, until `maxCachedDiffBytes` evicts it. With `commits`, it covers those
1772
+ * commits, from the first one's first parent to the last, and is read every time.
1773
+ * @param session - Session the change request is bound to.
1774
+ * @param url - binding URL of the change request.
1775
+ * @param commits - consecutive commits of the change request, or null for all of it.
1776
+ * @param signal - request cancellation.
1777
+ * @returns the files, the commit they end at, each file's web page, and the commits the checkout has beyond the head.
1778
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1779
+ * `forgePanel/commits-missing` when chosen commits are not among the change request's commits in order;
1780
+ * `forgePanel/commits-not-linear` when a chosen commit's first parent is not the commit listed before it;
1781
+ * `forgePanel/stale-head` without `commits` when the head moved past the latest status, which is then polled again;
1782
+ * `forgePanel/diff-too-large` when the host or its provider refuses the diff over a size limit;
1783
+ * `forgePanel/diff-failed` before its status was read, for a first chosen commit without a parent, and when the host
1784
+ * does not provide the commits, the diff, or an existing `.gitattributes` otherwise.
1785
+ */
1786
+ @Remote async changeRequestDiff( session: Session, url: string, commits: ForgeCommitRange | null, signal: AbortSignal, ): Promise<ForgeChangeRequestDiff>
1787
+
1788
+ /**
1789
+ * Read one file of a change request's repository at a commit, which
1790
+ * supplies the unchanged lines between the hunks of its diff.
1791
+ * @param session - Session the change request is bound to.
1792
+ * @param url - binding URL of the change request.
1793
+ * @param commit - commit object name, the head commit of the diff.
1794
+ * @param path - path relative to the repository root.
1795
+ * @param signal - request cancellation.
1796
+ * @returns the text.
1797
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1798
+ * `forgePanel/diff-too-large` when the host or its provider refuses the file over a size limit;
1799
+ * `forgePanel/diff-failed` when the host does not provide the file otherwise.
1800
+ */
1801
+ @Remote async changeRequestText(session: Session, url: string, commit: string, path: string, signal: AbortSignal): Promise<string>
1802
+
1803
+ /**
1804
+ * Register a filter lens as an effect on the calling fiber. The changes views list it while it is registered; ending
1805
+ * the registration aborts its running classifications and waits for them.
1806
+ * @param lens - the lens.
1807
+ * @returns the disposer that unregisters the lens and waits for its classifications to stop.
1808
+ * @throws when another registration holds `lens.id`.
1809
+ */
1810
+ registerLens(lens: ForgeLens): () => Promise<void>
1811
+
1812
+ /**
1813
+ * Stream the facts every changes view reads about the panel's extensions: the current facts first, then the facts
1814
+ * after each lens registration or withdrawal. The stream ends when `signal` aborts or the Remote stops.
1815
+ * @param signal - ends the stream.
1816
+ * @returns the registered lenses and the annotation limit, in publication order.
1817
+ */
1818
+ @Remote({ mode: 'stream' }) async *extensions(signal: AbortSignal): AsyncIterable<ForgeExtensionState>
1819
+
1820
+ /**
1821
+ * Classify the files a changes view of a Session shows with one registered lens: progress frames while the lens
1822
+ * runs, then the files it keeps. Results for the same files, lens, and lens version are reused from memory until
1823
+ * `maxCachedLensBytes` evicts them. Local changes are read with the Session's permissions; a change request's files
1824
+ * are those `changeRequestDiff` reads.
1825
+ * @param session - Session whose checkout or binding the view shows.
1826
+ * @param request - the view's source, the version of the files it shows, and the lens.
1827
+ * @param signal - ends the classification.
1828
+ * @returns progress frames, then one result frame.
1829
+ * @throws `forgePanel/lens-missing` while no lens holds the identity or once its registration ends;
1830
+ * `forgePanel/lens-stale` before a change request's status was read, when the files differ from `request.version`, and
1831
+ * when local files changed while the lens ran;
1832
+ * `forgePanel/lens-failed` when the lens fails, runs past `lensTimeoutMs`, reads past `maxLensReadBytes`, or answers
1833
+ * over `maxCachedLensBytes`; the errors of `localDiff` and `changeRequestDiff` for the files.
1834
+ */
1835
+ @Remote({ mode: 'stream' }) async *changesLens(session: Session, request: ForgeLensRequest, signal: AbortSignal): AsyncIterable<ForgeLensFrame>
1836
+
1837
+ /**
1838
+ * Read the signed-in user's viewed marks on the files of a change request of a Session, which the host keeps for the
1839
+ * whole change request.
1840
+ * @param session - Session the change request is bound to.
1841
+ * @param url - binding URL of the change request.
1842
+ * @param headSha - head commit of the shown diff; marks read at another head are refused.
1843
+ * @param signal - request cancellation.
1844
+ * @returns the marks at `headSha`, or null when the provider keeps no viewed marks.
1845
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1846
+ * `forgePanel/stale-head` when the head moved past `headSha`, which is then polled again; `forgePanel/viewed-failed`
1847
+ * when the host does not provide the marks otherwise.
1848
+ */
1849
+ @Remote async changeRequestViewed(session: Session, url: string, headSha: string, signal: AbortSignal): Promise<ForgeViewedFiles | null>
1850
+
1851
+ /**
1852
+ * Set or clear the signed-in user's viewed mark on one file of a change request of a Session.
1853
+ * @param session - Session the change request is bound to.
1854
+ * @param url - binding URL of the change request.
1855
+ * @param request - the file, its mark, and the head commit of the shown diff.
1856
+ * @param signal - request cancellation.
1857
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1858
+ * `forgePanel/stale-head` when the head moved past `request.headSha`; `forgePanel/action-failed` with the host's
1859
+ * reason when the host refuses, cannot be reached, or keeps no viewed marks; `forgePanel/action-unknown` when the host
1860
+ * did not confirm whether it saved the mark.
1861
+ */
1862
+ @Remote async setFileViewed(session: Session, url: string, request: ForgeViewedRequest, signal: AbortSignal): Promise<void>
1863
+
1864
+ /**
1865
+ * Read the review threads of a change request of a Session at the head commit of its displayed diff. Threads read
1866
+ * at the same head commit and update time are reused from memory, for any Session, until they are
1867
+ * `reviewRefreshMs` old, `maxCachedReviewBytes` evicts them, or a review write through this panel drops them; a read
1868
+ * again after that age, or a `fresh` read, shows threads resolved elsewhere since, which do not change a GitHub pull
1869
+ * request's update time.
1870
+ * @param session - Session the change request is bound to.
1871
+ * @param url - binding URL of the change request.
1872
+ * @param headSha - head commit of the displayed diff.
1873
+ * @param fresh - whether to read from the host even when threads at this head and update time are kept, as after the
1874
+ * reader refreshes the view; the result replaces the kept threads.
1875
+ * @param signal - request cancellation.
1876
+ * @returns the threads at `headSha`, with `current` positions numbering the files of that diff.
1877
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1878
+ * `forgePanel/stale-head` when the latest status or the host names another head, which a host answer polls again;
1879
+ * `forgePanel/review-unsupported` when the provider cannot read reviews; `forgePanel/review-failed` before the
1880
+ * status was read and when the host does not provide the threads otherwise.
1881
+ */
1882
+ @Remote async changeRequestReview(session: Session, url: string, headSha: string, fresh: boolean, signal: AbortSignal): Promise<ForgeReviewData>
1883
+
1884
+ /**
1885
+ * Publish a line comment or completed review for a visible Session binding. The threads kept for the change request
1886
+ * are dropped once the host answers, so the next read shows the comments.
1887
+ * @param session - Session retaining the change request.
1888
+ * @param url - visible binding URL.
1889
+ * @param request - reviewed head, ranges, plain text, and explicit review decision.
1890
+ * @param signal - request cancellation.
1891
+ * @returns confirmed publication or a typed failure; unknown outcomes require reconciliation on the host.
1892
+ */
1893
+ @Remote async submitReview(session: Session, url: string, request: ForgeReviewRequest, signal: AbortSignal): Promise<ForgeReviewResult>
1894
+
1895
+ /**
1896
+ * Write to the review threads or the pending review of a change request of a Session while its head is still the
1897
+ * head the user saw. The threads kept for the change request are dropped once the host answers, so the next read
1898
+ * shows the write, which a resolve does not show through a GitHub pull request's update time.
1899
+ * @param session - Session the change request is bound to.
1900
+ * @param url - binding URL of the change request.
1901
+ * @param write - the write and the head commit of the threads the user saw.
1902
+ * @param signal - request cancellation.
1903
+ * @returns whether the host took the write; `stale` once the head moved, which polls the change request again, and
1904
+ * `unknown` when the outcome must be checked on the host before the write is tried again.
1905
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves; an error
1906
+ * for a write without text, a head that is not a commit object name, or an invalid line range.
1907
+ */
1908
+ @Remote async changeRequestReviewWrite( session: Session, url: string, write: ForgeReviewWrite, signal: AbortSignal, ): Promise<ForgeReviewWriteResult>
1909
+
1910
+ /**
1911
+ * Mark a draft change request of a Session ready for review; the change
1912
+ * request is polled again once the host answers.
1913
+ * @param session - Session the change request is bound to.
1914
+ * @param url - binding URL of the change request.
1915
+ * @param signal - request cancellation.
1916
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1917
+ * `forgePanel/action-failed` with the host's reason when the host refuses or cannot be reached.
1918
+ */
1919
+ @Remote async markReady(session: Session, url: string, signal: AbortSignal): Promise<void>
1920
+
1921
+ /**
1922
+ * Merge a change request of a Session while its head is still `headSha`;
1923
+ * the change request is polled again once the host answers.
1924
+ * @param session - Session the change request is bound to.
1925
+ * @param url - binding URL of the change request.
1926
+ * @param method - how the commits enter the base branch.
1927
+ * @param headSha - head commit the user confirmed.
1928
+ * @param signal - request cancellation.
1929
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1930
+ * `forgePanel/stale-head` when the head moved past `headSha`; `forgePanel/action-failed` with the host's
1931
+ * reason when the host refuses otherwise or cannot be reached.
1932
+ */
1933
+ @Remote async merge(session: Session, url: string, method: MergeMethod, headSha: string, signal: AbortSignal): Promise<void>
1934
+
1935
+ /**
1936
+ * Rerun the failed checks of a change request of a Session while its head is still the commit whose checks the user
1937
+ * saw; the change request is polled again once the host answers.
1938
+ * @param session - Session the change request is bound to.
1939
+ * @param url - binding URL of the change request.
1940
+ * @param request - the head commit whose checks the user saw.
1941
+ * @param signal - request cancellation.
1942
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1943
+ * `forgePanel/stale-head` when the head moved past `request.headSha`; `forgePanel/action-failed` with the host's
1944
+ * reason when the host refuses, cannot be reached, or reruns no checks; `forgePanel/action-unknown` when the host did
1945
+ * not confirm whether it started the rerun.
1946
+ */
1947
+ @Remote async rerunChecks(session: Session, url: string, request: ForgeRerunRequest, signal: AbortSignal): Promise<void>
1948
+
1949
+ /**
1950
+ * Request reviews of a change request of a Session from more reviewers; the change request is polled again once the
1951
+ * host answers.
1952
+ * @param session - Session the change request is bound to.
1953
+ * @param url - binding URL of the change request.
1954
+ * @param reviewers - the reviewers to ask, by kind and login.
1955
+ * @param signal - request cancellation.
1956
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1957
+ * `forgePanel/action-failed` with the host's reason when the host refuses, cannot be reached, or requests no reviews;
1958
+ * `forgePanel/action-unknown` when the host did not confirm whether it requested the reviews.
1959
+ */
1960
+ @Remote async requestReviews( session: Session, url: string, reviewers: readonly Pick<ChangeRequestReviewer, 'kind' | 'login'>[], signal: AbortSignal, ): Promise<void>
1961
+
1962
+ /**
1963
+ * List accounts a review of a change request of a Session can be requested from.
1964
+ * @param session - Session the change request is bound to.
1965
+ * @param url - binding URL of the change request.
1966
+ * @param query - text the login or name contains; empty for the host's suggestions and first accounts.
1967
+ * @param signal - request cancellation.
1968
+ * @returns the accounts, the host's suggestions first.
1969
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1970
+ * `forgePanel/reviewers-failed` when the host does not list them.
1971
+ */
1972
+ @Remote async reviewerCandidates(session: Session, url: string, query: string, signal: AbortSignal): Promise<readonly ForgeReviewerCandidate[]>
1973
+
1974
+ /**
1975
+ * Bring the base branch's new commits into the head branch of a change request of a Session while its head is still
1976
+ * `headSha`; the change request is polled again once the host answers.
1977
+ * @param session - Session the change request is bound to.
1978
+ * @param url - binding URL of the change request.
1979
+ * @param method - merge commit or rebase.
1980
+ * @param headSha - head commit the user confirmed.
1981
+ * @param signal - request cancellation.
1982
+ * @throws `forgePanel/not-bound` unless the URL is a visible binding of the Session that a provider serves;
1983
+ * `forgePanel/stale-head` when the head moved past `headSha`; `forgePanel/action-failed` with the host's reason when
1984
+ * the host refuses, cannot be reached, or updates no branches; `forgePanel/action-unknown` when the host did not
1985
+ * confirm whether it started the update.
1986
+ */
1987
+ @Remote async updateBranch(session: Session, url: string, method: BranchUpdateMethod, headSha: string, signal: AbortSignal): Promise<void>
1988
+
1989
+ /**
1990
+ * Ask for a new worktree before the Session's first turn, replacing an open
1991
+ * request and forgetting a failed attempt. While the next message waits in
1992
+ * the inbox, or else at the first step proposal, the panel creates a branch
1993
+ * from `from`, or from HEAD of the current checkout when it is null, and
1994
+ * enters its checkout. A message that already waits after a failed or
1995
+ * stopped attempt keeps waiting for {@link ForgePanelController.retryWorktree}.
1996
+ * @param session - Session without a started turn.
1997
+ * @param from - local base branch, or null for HEAD.
1998
+ * @param signal - request cancellation.
1999
+ * @throws `forgePanel/invalid-branch` when `from` is empty; `forgePanel/worktrees-unavailable`
2000
+ * without a worktree service; `forgePanel/session-started` after a turn started or the worktree was
2001
+ * created; `forgePanel/session-busy` while the worktree is being created.
2002
+ */
2003
+ @Remote async requestWorktree(session: Session, from: string | null, signal: AbortSignal): Promise<void>
2004
+
2005
+ /**
2006
+ * Withdraw the open worktree request of a Session with its failed attempt,
2007
+ * which lets a waiting message go on in the current checkout; without a
2008
+ * request the Session is unchanged. Withdrawing needs no worktree service.
2009
+ * @param session - Session without a started turn.
2010
+ * @param signal - request cancellation.
2011
+ * @throws `forgePanel/session-started` after a turn started or the worktree was created;
2012
+ * `forgePanel/session-busy` while the worktree is being created.
2013
+ */
2014
+ @Remote async cancelWorktree(session: Session, signal: AbortSignal): Promise<void>
2015
+
2016
+ /**
2017
+ * Stop the creation a message of the Session waits for; the message keeps
2018
+ * waiting with the request still open. Without such a creation the Session
2019
+ * is unchanged.
2020
+ * @param session - Session whose creation stops.
2021
+ * @param signal - request cancellation.
2022
+ */
2023
+ @Remote async stopCreation(session: Session, signal: AbortSignal): Promise<void>
2024
+
2025
+ /**
2026
+ * Make another attempt, with a new branch name, at the worktree a message
2027
+ * of the Session waits for after a failed or stopped attempt.
2028
+ * @param session - Session whose message waits.
2029
+ * @param signal - request cancellation.
2030
+ * @throws `forgePanel/not-waiting` when no message waits or an attempt is running.
2031
+ */
2032
+ @Remote async retryWorktree(session: Session, signal: AbortSignal): Promise<void>
2033
+
2034
+ /**
2035
+ * Check out the created worktree of a Session again at its recorded
2036
+ * directory when that directory is gone: its branch when the branch still
2037
+ * exists, otherwise a new branch of the same name at the base commit. Changes
2038
+ * that were never committed are not recovered. Runs as Agent maintenance,
2039
+ * inside the wait of a message that waits for the restoration, which then
2040
+ * goes on; without a missing directory the Session is unchanged.
2041
+ * @param session - Session whose worktree directory is gone.
2042
+ * @param signal - request cancellation, which aborts the restoration.
2043
+ * @throws `forgePanel/no-worktree` without a created worktree; `forgePanel/worktrees-unavailable`
2044
+ * without a worktree service; `forgePanel/session-busy` while the Session's Agent is not loaded or
2045
+ * has other work; `forgePanel/restore-failed` when Git fails.
2046
+ */
2047
+ @Remote async restoreWorktree(session: Session, signal: AbortSignal): Promise<void>
2048
+
2049
+ /**
2050
+ * Move a Session from its created worktree to the source checkout the
2051
+ * worktree came from; the Session no longer works in the worktree. Runs as
2052
+ * Agent maintenance, inside the wait of a message that waits for the removed
2053
+ * worktree, which then goes on.
2054
+ * @param session - Session with a created worktree.
2055
+ * @param signal - request cancellation.
2056
+ * @throws `forgePanel/no-worktree` without a created worktree; `forgePanel/session-busy` while the
2057
+ * Session's Agent is not loaded or has other work; the working-directory service's error when the
2058
+ * source checkout no longer exists.
2059
+ */
2060
+ @Remote async continueInProject(session: Session, signal: AbortSignal): Promise<void>
2061
+ ```
2062
+
2063
+ Types: [Session](session.zh.md) · [WorktreeCleanup](worktrees.zh.md)
2064
+
2065
+ Source: [`packages/experimental/client-ui-forge/src/index.ts`](../../packages/experimental/client-ui-forge/src/index.ts)
2066
+
2067
+ <a id="ctxforgesession--forgesessionservice"></a>
2068
+
2069
+ ### `ctx.forgeSession` — `ForgeSessionService`
2070
+
2071
+ Session-scoped change request bindings. The `forgeChangeRequests` projection derives them from `gh pr create`, `gh pr view`, `gh pr edit`, `gh pr checkout`, and `git push` results, including those of shell calls inside PTC programs, and from `plugin:forge-session/binding` records. After each push result, and when a caller reports the branch a Session works on, the service looks up open change requests whose head is that branch and records the unbound ones as discovered. Watching a Session polls its visible change requests through `ctx.forge`.
2072
+
2073
+ ```ts cordis-catalog
2074
+ /**
2075
+ * List the change requests bound to a Session and not dismissed.
2076
+ * @param session - Session whose bindings are read.
2077
+ * @returns visible bindings in first-recorded order, each with its latest polling result.
2078
+ */
2079
+ changeRequests(session: Session): SessionChangeRequest[]
2080
+
2081
+ /**
2082
+ * Bind a change request to a Session by URL, or restore a dismissed binding.
2083
+ * Appends a `track` record with the provider's canonical URL unless the
2084
+ * change request is already visible.
2085
+ * @param session - Session that receives the binding.
2086
+ * @param url - web URL of the change request.
2087
+ * @throws when no registered provider recognizes the URL.
2088
+ */
2089
+ track(session: Session, url: string): void
2090
+
2091
+ /**
2092
+ * Look up open change requests whose head is a branch the Session works on,
2093
+ * and record the unbound ones as discovered, as after a push of that branch.
2094
+ * A remote that no provider recognizes changes nothing; a failed lookup is
2095
+ * logged and changes nothing.
2096
+ * @param session - Session that receives the bindings.
2097
+ * @param remote - URL of the remote that holds the branch.
2098
+ * @param branch - branch name on that remote.
2099
+ * @returns resolves once the lookup has recorded its bindings or failed.
2100
+ */
2101
+ discoverBranch(session: Session, remote: string, branch: string): Promise<void>
2102
+
2103
+ /**
2104
+ * Hide a visible binding. Appends a `dismiss` record; a URL that is not
2105
+ * visibly bound leaves the log unchanged. Discovery never restores a
2106
+ * dismissed binding; `track` does.
2107
+ * @param session - Session that owns the binding.
2108
+ * @param url - web URL of the change request.
2109
+ */
2110
+ dismiss(session: Session, url: string): void
2111
+
2112
+ /**
2113
+ * Watch a Session's visible change requests as an effect on the calling
2114
+ * fiber. Every visible change request that a provider recognizes is polled
2115
+ * through `ctx.forge` while the Session has a watcher. Listeners receive the
2116
+ * complete list after each later binding or provider change, or polling result; read the
2117
+ * current list with {@link changeRequests}. Listeners must not throw; a
2118
+ * thrown error is logged and skipped.
2119
+ * @param session - Session to watch.
2120
+ * @param listener - receives the complete visible list.
2121
+ * @returns the disposer that stops this watch.
2122
+ */
2123
+ watch(session: Session, listener: SessionChangeRequestsListener): () => void
2124
+ ```
2125
+
2126
+ Types: [Session](session.zh.md)
2127
+
2128
+ Source: [`packages/experimental/forge-session/src/index.ts`](../../packages/experimental/forge-session/src/index.ts)
2129
+
2130
+ <a id="forge-events"></a>
2131
+
2132
+ ### `forge/*` events
2133
+
2134
+ <a id="forgeproviders-changed--parallel"></a>
2135
+
2136
+ #### `forge/providers-changed` — parallel
2137
+
2138
+ Announces a provider registration or withdrawal after the registry changes. Listener failures are logged without preventing other listeners from running.
2139
+
2140
+ ```ts cordis-catalog
2141
+ /**
2142
+ * Announces a provider registration or withdrawal after the registry changes.
2143
+ * Listener failures are logged without preventing other listeners from running.
2144
+ * @param forge - family whose provider changed.
2145
+ * @mode parallel
2146
+ */
2147
+ 'forge/providers-changed'(forge: string): void | Promise<void>
2148
+ ```
2149
+
2150
+ Source: [`packages/experimental/forge/src/index.ts`](../../packages/experimental/forge/src/index.ts)
2151
+
2152
+ <a id="forgereview-changed--parallel"></a>
2153
+
2154
+ #### `forge/review-changed` — parallel
2155
+
2156
+ Announces a review change the host accepted through this service: a thread or pending-review write, a submitted review, or a viewed mark. Changes whose outcome is unknown, refused, stale, or unsupported are not announced. Listener failures are logged without preventing other listeners from running.
2157
+
2158
+ ```ts cordis-catalog
2159
+ /**
2160
+ * Announces a review change the host accepted through this service: a thread or pending-review write, a submitted
2161
+ * review, or a viewed mark. Changes whose outcome is unknown, refused, stale, or unsupported are not announced.
2162
+ * Listener failures are logged without preventing other listeners from running.
2163
+ * @param ref - change request the change went to.
2164
+ * @param change - what changed and the head commit it was made against.
2165
+ * @mode parallel
2166
+ */
2167
+ 'forge/review-changed'(ref: ChangeRequestRef, change: ForgeReviewChange): void | Promise<void>
2168
+ ```
2169
+
2170
+ Source: [`packages/experimental/forge/src/index.ts`](../../packages/experimental/forge/src/index.ts)
2171
+ <!-- END GENERATED cordis-surface -->