@ddtcorex/dsh-maestro-review 0.12.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +37 -58
  2. package/cordis.patch.yml +13 -18
  3. package/lib/config-store.d.ts +9 -1
  4. package/lib/config-store.d.ts.map +1 -1
  5. package/lib/config-store.js +1 -1
  6. package/lib/config-store.js.map +1 -1
  7. package/lib/events.d.ts +8 -45
  8. package/lib/events.d.ts.map +1 -1
  9. package/lib/host-orchestrator.d.ts +128 -0
  10. package/lib/host-orchestrator.d.ts.map +1 -0
  11. package/lib/host-orchestrator.js +500 -0
  12. package/lib/host-orchestrator.js.map +1 -0
  13. package/lib/index.d.ts +7 -2
  14. package/lib/index.d.ts.map +1 -1
  15. package/lib/index.js +7 -43
  16. package/lib/index.js.map +1 -1
  17. package/lib/providers/gitlab.d.ts.map +1 -1
  18. package/lib/providers/gitlab.js +8 -1
  19. package/lib/providers/gitlab.js.map +1 -1
  20. package/lib/review-intake.d.ts +8 -1
  21. package/lib/review-intake.d.ts.map +1 -1
  22. package/lib/review-intake.js +22 -0
  23. package/lib/review-intake.js.map +1 -1
  24. package/lib/settings-rpc.js +1 -1
  25. package/lib/settings-rpc.js.map +1 -1
  26. package/package.json +19 -36
  27. package/src/client/index.tsx +1 -1
  28. package/src/host/augment.d.ts +3 -1
  29. package/src/host/config-store.ts +2 -2
  30. package/src/host/events.ts +8 -45
  31. package/src/host/host-orchestrator.ts +549 -0
  32. package/src/host/index.ts +7 -35
  33. package/src/host/providers/gitlab.ts +8 -2
  34. package/src/host/review-intake.ts +20 -1
  35. package/src/host/settings-rpc.ts +1 -1
  36. package/lib/ci-clone.d.ts +0 -21
  37. package/lib/ci-clone.d.ts.map +0 -1
  38. package/lib/ci-clone.js +0 -35
  39. package/lib/ci-clone.js.map +0 -1
  40. package/lib/ci-coexist.d.ts +0 -11
  41. package/lib/ci-coexist.d.ts.map +0 -1
  42. package/lib/ci-coexist.js +0 -38
  43. package/lib/ci-coexist.js.map +0 -1
  44. package/lib/gitlab-auth.d.ts +0 -11
  45. package/lib/gitlab-auth.d.ts.map +0 -1
  46. package/lib/gitlab-auth.js +0 -15
  47. package/lib/gitlab-auth.js.map +0 -1
  48. package/lib/gitlab-client.d.ts +0 -78
  49. package/lib/gitlab-client.d.ts.map +0 -1
  50. package/lib/gitlab-client.js +0 -270
  51. package/lib/gitlab-client.js.map +0 -1
  52. package/lib/govard-lint-detection.d.ts +0 -20
  53. package/lib/govard-lint-detection.d.ts.map +0 -1
  54. package/lib/govard-lint-detection.js +0 -48
  55. package/lib/govard-lint-detection.js.map +0 -1
  56. package/lib/hyva-csp-scan-tool.d.ts +0 -11
  57. package/lib/hyva-csp-scan-tool.d.ts.map +0 -1
  58. package/lib/hyva-csp-scan-tool.js +0 -193
  59. package/lib/hyva-csp-scan-tool.js.map +0 -1
  60. package/lib/hyva-theme-inspect-tool.d.ts +0 -10
  61. package/lib/hyva-theme-inspect-tool.d.ts.map +0 -1
  62. package/lib/hyva-theme-inspect-tool.js +0 -299
  63. package/lib/hyva-theme-inspect-tool.js.map +0 -1
  64. package/lib/incremental.d.ts +0 -28
  65. package/lib/incremental.d.ts.map +0 -1
  66. package/lib/incremental.js +0 -62
  67. package/lib/incremental.js.map +0 -1
  68. package/lib/layout-xml-tool.d.ts +0 -11
  69. package/lib/layout-xml-tool.d.ts.map +0 -1
  70. package/lib/layout-xml-tool.js +0 -239
  71. package/lib/layout-xml-tool.js.map +0 -1
  72. package/lib/module-check-tool.d.ts +0 -11
  73. package/lib/module-check-tool.d.ts.map +0 -1
  74. package/lib/module-check-tool.js +0 -303
  75. package/lib/module-check-tool.js.map +0 -1
  76. package/lib/orchestrator.d.ts +0 -357
  77. package/lib/orchestrator.d.ts.map +0 -1
  78. package/lib/orchestrator.js +0 -1497
  79. package/lib/orchestrator.js.map +0 -1
  80. package/lib/perf-log-stats-tool.d.ts +0 -13
  81. package/lib/perf-log-stats-tool.d.ts.map +0 -1
  82. package/lib/perf-log-stats-tool.js +0 -245
  83. package/lib/perf-log-stats-tool.js.map +0 -1
  84. package/lib/phtml-escape-scan-tool.d.ts +0 -11
  85. package/lib/phtml-escape-scan-tool.d.ts.map +0 -1
  86. package/lib/phtml-escape-scan-tool.js +0 -166
  87. package/lib/phtml-escape-scan-tool.js.map +0 -1
  88. package/lib/providers/ci-trigger.d.ts +0 -44
  89. package/lib/providers/ci-trigger.d.ts.map +0 -1
  90. package/lib/providers/ci-trigger.js +0 -150
  91. package/lib/providers/ci-trigger.js.map +0 -1
  92. package/lib/review-findings-tool.d.ts +0 -20
  93. package/lib/review-findings-tool.d.ts.map +0 -1
  94. package/lib/review-findings-tool.js +0 -39
  95. package/lib/review-findings-tool.js.map +0 -1
  96. package/lib/review-history.d.ts +0 -40
  97. package/lib/review-history.d.ts.map +0 -1
  98. package/lib/review-history.js +0 -136
  99. package/lib/review-history.js.map +0 -1
  100. package/lib/review-marker.d.ts +0 -17
  101. package/lib/review-marker.d.ts.map +0 -1
  102. package/lib/review-marker.js +0 -23
  103. package/lib/review-marker.js.map +0 -1
  104. package/lib/review-signals.d.ts +0 -17
  105. package/lib/review-signals.d.ts.map +0 -1
  106. package/lib/review-signals.js +0 -79
  107. package/lib/review-signals.js.map +0 -1
  108. package/lib/scope-split-tool.d.ts +0 -42
  109. package/lib/scope-split-tool.d.ts.map +0 -1
  110. package/lib/scope-split-tool.js +0 -108
  111. package/lib/scope-split-tool.js.map +0 -1
  112. package/lib/search-tool.d.ts +0 -15
  113. package/lib/search-tool.d.ts.map +0 -1
  114. package/lib/search-tool.js +0 -144
  115. package/lib/search-tool.js.map +0 -1
  116. package/lib/skill-provider.d.ts +0 -19
  117. package/lib/skill-provider.d.ts.map +0 -1
  118. package/lib/skill-provider.js +0 -101
  119. package/lib/skill-provider.js.map +0 -1
  120. package/lib/skills-tool.d.ts +0 -29
  121. package/lib/skills-tool.d.ts.map +0 -1
  122. package/lib/skills-tool.js +0 -185
  123. package/lib/skills-tool.js.map +0 -1
  124. package/lib/source.d.ts +0 -23
  125. package/lib/source.d.ts.map +0 -1
  126. package/lib/source.js +0 -16
  127. package/lib/source.js.map +0 -1
  128. package/lib/tool-policy.d.ts +0 -20
  129. package/lib/tool-policy.d.ts.map +0 -1
  130. package/lib/tool-policy.js +0 -42
  131. package/lib/tool-policy.js.map +0 -1
  132. package/presets/maestro-auditor.patch.yml +0 -54
  133. package/presets/maestro-coder/agent.cordis.yml +0 -223
  134. package/presets/maestro-coder/preset.yml +0 -2
  135. package/presets/maestro-reviewer.patch.yml +0 -55
  136. package/profiles/reviewer-ci/cordis.patch.yml +0 -78
  137. package/profiles/reviewer-ci/package.json +0 -19
  138. package/profiles/reviewer-ci/pnpm-lock.yaml +0 -8201
  139. package/profiles/reviewer-ci/pnpm-workspace.yaml +0 -36
  140. package/skills/dsh-native-tools/SKILL.md +0 -80
  141. package/src/host/ci-clone.ts +0 -54
  142. package/src/host/ci-coexist.ts +0 -45
  143. package/src/host/dsh-skill.d.ts +0 -72
  144. package/src/host/gitlab-auth.ts +0 -13
  145. package/src/host/gitlab-client.ts +0 -332
  146. package/src/host/govard-lint-detection.ts +0 -47
  147. package/src/host/hyva-csp-scan-tool.ts +0 -165
  148. package/src/host/hyva-theme-inspect-tool.ts +0 -258
  149. package/src/host/incremental.ts +0 -86
  150. package/src/host/layout-xml-tool.ts +0 -190
  151. package/src/host/module-check-tool.ts +0 -187
  152. package/src/host/orchestrator.ts +0 -1641
  153. package/src/host/perf-log-stats-tool.ts +0 -224
  154. package/src/host/phtml-escape-scan-tool.ts +0 -112
  155. package/src/host/providers/ci-trigger.ts +0 -168
  156. package/src/host/review-findings-tool.ts +0 -59
  157. package/src/host/review-history.ts +0 -168
  158. package/src/host/review-marker.ts +0 -25
  159. package/src/host/review-signals.ts +0 -83
  160. package/src/host/scope-split-tool.ts +0 -109
  161. package/src/host/search-tool.ts +0 -152
  162. package/src/host/skill-provider.ts +0 -94
  163. package/src/host/skills-tool.ts +0 -218
  164. package/src/host/source.ts +0 -26
  165. package/src/host/tool-policy.ts +0 -49
  166. package/templates/reviewer-project.gitlab-ci.yml +0 -93
  167. package/templates/source-project.gitlab-ci.yml +0 -48
@@ -0,0 +1,549 @@
1
+ import { mkdir, writeFile, symlink, stat, lstat } from 'node:fs/promises'
2
+ import { execFile } from 'node:child_process'
3
+ import { promisify } from 'node:util'
4
+ import { join } from 'node:path'
5
+ import type { Context } from '@deepseek-ai/cordis'
6
+ import z from '@deepseek-ai/schemastery'
7
+ import type { ReviewRequest, ReviewResult } from '@ddtcorex/maestro-reviewer/lib/events.js'
8
+ import type { ReviewSkillProfile } from '@ddtcorex/maestro-reviewer/lib/skills-tool.js'
9
+ import { govardOnPath } from '@ddtcorex/maestro-reviewer/lib/govard-lint-detection.js'
10
+ import { hasCompletedReview, pruneHistory, recordReviewFinish, recordReviewStart } from '@ddtcorex/maestro-reviewer/lib/review-history.js'
11
+ import { gitlabForge } from '@ddtcorex/maestro-reviewer/lib/forge/gitlab/index.js'
12
+ import { assertSafeBranchName, declineUnmappedDeepReview, isBranchNotFoundError, type ReviewCommentDeps } from '@ddtcorex/maestro-reviewer/lib/orchestrator.js'
13
+ import { DEDUPED_SUMMARY, removeWorktree, toModelSelection, writeFailedReport, type CodeAccess, type EngineGitlab, type EngineRunOptions } from '@ddtcorex/maestro-reviewer/lib/engine.js'
14
+
15
+ /** The engine's model selection type (its own dsh-agent copy). */
16
+ type ModelSelection = EngineRunOptions['model']
17
+ import { loadUserConfig, type MaestroUserConfig, type ProjectMapping, type ReviewModelSelection } from './config-store.js'
18
+ import { reviewDigestText, type NotifierLike } from './notify.js'
19
+ import { loadRepoSettings } from '@ddtcorex/maestro-reviewer/lib/ci-repo-settings.js'
20
+ import { effectiveConfig } from '@ddtcorex/maestro-reviewer/lib/repo-config.js'
21
+ import { answerCommands, commandMarker, findPendingCommands, replyToCommand } from '@ddtcorex/maestro-reviewer/lib/ci-commands.js'
22
+ import { fetchBotUserId, latestCompletedReview } from '@ddtcorex/maestro-reviewer/lib/ci-coexist.js'
23
+ import { timedFetcher } from '@ddtcorex/maestro-reviewer/lib/forge/gitlab/gitlab-client.js'
24
+ import type { MrOpenedPayload } from '@ddtcorex/maestro-reviewer/lib/events.js'
25
+ import './events.js'
26
+
27
+ /**
28
+ * Row `maestro-review-host-orchestrator`: the DSH host side of a review. It
29
+ * listens for `maestro/review-request` (webhook intake), resolves user
30
+ * settings and project mappings, applies the trigger gates, prepares worktrees
31
+ * (vendor and govard environment linking) and calls the engine.
32
+ */
33
+ export const name = 'maestro-review-host-orchestrator'
34
+ export const inject = ['reviewEngine', 'agentDefaultModel']
35
+
36
+ const execFileAsync = promisify(execFile)
37
+ const GIT_TIMEOUT_MS = 60_000
38
+
39
+ /**
40
+ * Resolve the model to use for an automated review. Priority: per-project
41
+ * override > global reviewModel (Maestro Settings) > row-config reviewModel
42
+ * (lets a headless profile such as reviewer-ci pin a model from env vars,
43
+ * where there is no Settings UI) > DSH default (`fallback`).
44
+ */
45
+ export function resolveReviewModel(
46
+ userConfig: MaestroUserConfig,
47
+ mapping: { reviewModel?: ReviewModelSelection | null; projectPath?: string } | undefined,
48
+ fallback: ModelSelection,
49
+ rowSelection?: ReviewModelSelection | null,
50
+ ): ModelSelection {
51
+ const raw = (mapping?.reviewModel as ReviewModelSelection | null | undefined) ?? userConfig.reviewModel ?? rowSelection
52
+ if (raw === undefined || raw === null) return fallback
53
+ return toModelSelection(raw)
54
+ }
55
+
56
+ /** Effective auto-trigger flags: per-project row overrides global, unset inherits (design §4). */
57
+ export function resolveReviewTriggers(
58
+ userConfig: MaestroUserConfig,
59
+ mapping?: ProjectMapping,
60
+ ): { onPush: boolean; onAssign: boolean } {
61
+ return {
62
+ onPush: mapping?.rereviewOnPush ?? userConfig.autoRereviewOnPush ?? false,
63
+ onAssign: mapping?.reviewOnAssign ?? userConfig.autoReviewOnAssign ?? true,
64
+ }
65
+ }
66
+
67
+ export interface Config {
68
+ projectMappings: Array<{ projectPath: string; localRepoPath: string; reviewProfile: ReviewSkillProfile }>
69
+ gitlabBaseUrl: string
70
+ /**
71
+ * Fallback when Maestro Settings has no token; optional so a deployment that
72
+ * configures everything through Settings boots without env vars.
73
+ */
74
+ gitlabToken?: string
75
+ botUsername: string
76
+ /** Hard ceiling on one automated agent's turn. */
77
+ agentTimeoutMs: number
78
+ /**
79
+ * Deployment-level model pin, below Maestro Settings in precedence. Lets a
80
+ * headless profile (reviewer-ci) select the review model from env vars —
81
+ * e.g. REVIEW_MODEL_PROVIDER/REVIEW_MODEL — where no Settings UI exists.
82
+ *
83
+ * Deliberately absent from the zod schema below: schemastery object schemas
84
+ * always descend into inner fields (probed — even `.required(false)` still
85
+ * throws on undefined), so declaring it would fail every boot without the
86
+ * vars. Unknown keys pass validation through (same precedent as mapping-level
87
+ * reviewModel, which the projectMappings schema doesn't declare either),
88
+ * and resolveReviewModel reads it at review time.
89
+ */
90
+ reviewModel?: ReviewModelSelection | null
91
+ }
92
+
93
+ export const DEFAULT_AGENT_TIMEOUT_MS = 20 * 60_000
94
+
95
+ export const Config: z<Config> = z.object({
96
+ projectMappings: z.array(z.object({
97
+ projectPath: z.string().required(),
98
+ localRepoPath: z.string().required(),
99
+ reviewProfile: z.union([z.const('magento2'), z.const('laravel'), z.const('symfony'), z.const('wordpress'), z.const('generic')]).default('magento2'),
100
+ })).required(),
101
+ gitlabBaseUrl: z.string().required(),
102
+ gitlabToken: z.string().role('secret'),
103
+ botUsername: z.string().required(),
104
+ agentTimeoutMs: z.number().min(1000).default(DEFAULT_AGENT_TIMEOUT_MS),
105
+ })
106
+
107
+ /** Upper bound for the best-effort `govard env down -v` run by the orchestrator. */
108
+ export const GOVARD_TEARDOWN_TIMEOUT_MS = 120_000
109
+
110
+ type TeardownRun = (file: string, args: string[], opts: { cwd: string; timeout: number }) => Promise<unknown>
111
+
112
+ /**
113
+ * Tear down the review worktree's govard environment (`govard env down -v`,
114
+ * cwd = the worktree, whose `.govard.local.yml` names the per-MR project).
115
+ * Never throws: it runs in cleanup paths where a failure must not mask the
116
+ * review result, so a failure is logged as a warning instead.
117
+ */
118
+ export async function teardownGovardEnvironment(worktreePath: string, run: TeardownRun = execFileAsync): Promise<void> {
119
+ try {
120
+ await run('govard', ['env', 'down', '-v'], { cwd: worktreePath, timeout: GOVARD_TEARDOWN_TIMEOUT_MS })
121
+ } catch (err) {
122
+ console.warn(`maestro-orchestrator: govard env down -v failed in ${worktreePath}: ${err instanceof Error ? err.message : String(err)}`)
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Keep a Govard audit worktree isolated from the developer's primary checkout.
128
+ * Without this local override, both checkouts inherit the same `project_name`
129
+ * and Govard may either reject the worktree or run commands in the wrong stack.
130
+ */
131
+ export function govardWorktreeOverride(projectId: number, mrIid: number, keySuffix?: string): string {
132
+ const name = `maestro-mr-${projectId}-${mrIid}${keySuffix === undefined ? '' : `-${keySuffix}`}`
133
+ // Xdebug stays off in review envs: the auditor runs no coverage, and an
134
+ // enabled Xdebug trips govard's lint perf-tax guard (exit 1, 0 findings).
135
+ return `project_name: ${name}\ndomain: ${name}.test\nstack:\n features:\n xdebug: false\n`
136
+ }
137
+
138
+
139
+ async function pathExists(path: string): Promise<boolean> {
140
+ try {
141
+ await stat(path)
142
+ return true
143
+ } catch {
144
+ return false
145
+ }
146
+ }
147
+
148
+ export async function ensureWorktree(localRepoPath: string, sourceBranch: string, projectId: number, mrIid: number, keySuffix?: string): Promise<string> {
149
+ assertSafeBranchName(sourceBranch)
150
+ const worktreePath = join('/tmp', `maestro-mr-${projectId}-${mrIid}${keySuffix === undefined ? '' : `-${keySuffix}`}`)
151
+ try {
152
+ await execFileAsync('git', ['fetch', '--', 'origin', sourceBranch], { cwd: localRepoPath, timeout: GIT_TIMEOUT_MS })
153
+ } catch (err) {
154
+ if (isBranchNotFoundError(err)) {
155
+ const e = new Error(`branch not found on origin: ${sourceBranch}`)
156
+ ;(e as unknown as { code: string }).code = 'BRANCH_NOT_FOUND'
157
+ ;(e as unknown as { cause: unknown }).cause = err
158
+ throw e
159
+ }
160
+ throw err
161
+ }
162
+ // A host restart can interrupt an active review before its `finally` cleanup.
163
+ // Recover only this deterministic Maestro-owned path so the next delivery can
164
+ // retry; an unrelated worktree is never targeted. An interrupted deep audit
165
+ // may also have left its govard containers up, so the stale worktree's
166
+ // environment goes down first (only when it carries the per-MR override that
167
+ // names the project, and best effort).
168
+ if (govardOnPath() && await pathExists(join(worktreePath, '.govard.local.yml'))) await teardownGovardEnvironment(worktreePath)
169
+ await execFileAsync('git', ['worktree', 'remove', '--force', worktreePath], { cwd: localRepoPath, timeout: GIT_TIMEOUT_MS })
170
+ .catch(() => {})
171
+ await execFileAsync('git', ['worktree', 'add', '--', worktreePath, `origin/${sourceBranch}`], { cwd: localRepoPath, timeout: GIT_TIMEOUT_MS })
172
+ await writeFile(join(worktreePath, '.govard.local.yml'), govardWorktreeOverride(projectId, mrIid, keySuffix), 'utf-8')
173
+ await linkVendorIntoWorktree(localRepoPath, worktreePath)
174
+ await writeContainerVendorOverride(localRepoPath, worktreePath)
175
+ return worktreePath
176
+ }
177
+
178
+ /**
179
+ * A vendor dir only counts as installed dependencies when the composer
180
+ * autoloader is a real file. Magento tracks `vendor/.htaccess`, so every
181
+ * worktree has a vendor/ stub — that stub must not pass for real deps, and
182
+ * must not block the container bind that provides them.
183
+ */
184
+ export async function vendorHasAutoload(dir: string): Promise<boolean> {
185
+ try {
186
+ return (await stat(join(dir, 'vendor', 'autoload.php'))).isFile()
187
+ } catch {
188
+ return false
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Share the primary checkout's `vendor/` (and `app/etc/env.php` when the
194
+ * auditor needs a database) into the review worktree via symlinks, so
195
+ * phpunit/static analysis run against real dependencies instead of falling
196
+ * back to static-only. Links point INTO the worktree only — the primary
197
+ * checkout is never written to — and `git worktree remove --force` deletes
198
+ * the links along with the worktree. Missing sources, or targets that
199
+ * already exist (e.g. Magento's tracked `vendor/.htaccess` stub), are
200
+ * skipped quietly: the review still runs, the auditor discloses it.
201
+ */
202
+ export async function linkVendorIntoWorktree(localRepoPath: string, worktreePath: string): Promise<string[]> {
203
+ const linked: string[] = []
204
+ const candidates: Array<{ source: string; target: string; dir: boolean; needsAutoload: boolean }> = [
205
+ { source: join(localRepoPath, 'vendor'), target: join(worktreePath, 'vendor'), dir: true, needsAutoload: true },
206
+ { source: join(localRepoPath, 'app', 'etc', 'env.php'), target: join(worktreePath, 'app', 'etc', 'env.php'), dir: false, needsAutoload: false },
207
+ ]
208
+ let advertised = false
209
+ for (const { source, target, dir, needsAutoload } of candidates) {
210
+ let isDir = false
211
+ try {
212
+ isDir = (await stat(source)).isDirectory()
213
+ if (dir !== isDir) continue
214
+ } catch {
215
+ continue
216
+ }
217
+ if (needsAutoload && !(await vendorHasAutoload(localRepoPath))) continue
218
+ if ((await lstat(target).catch(() => undefined)) !== undefined) {
219
+ console.error(`maestro-orchestrator: link target exists, skipping ${target}`)
220
+ continue
221
+ }
222
+ try {
223
+ if (!advertised) {
224
+ const sha = await execFileAsync('git', ['rev-parse', 'HEAD'], { cwd: localRepoPath, timeout: GIT_TIMEOUT_MS })
225
+ .then(({ stdout }) => stdout.trim()).catch(() => 'unknown')
226
+ console.error(`maestro-orchestrator: linking vendor from ${localRepoPath} @ ${sha} into ${worktreePath}`)
227
+ advertised = true
228
+ }
229
+ if (!dir) await mkdir(join(worktreePath, 'app', 'etc'), { recursive: true })
230
+ await symlink(source, target, dir ? 'dir' : 'file')
231
+ linked.push(target)
232
+ } catch (err) {
233
+ console.error(`maestro-orchestrator: failed to link ${source} into worktree:`, err)
234
+ }
235
+ }
236
+ if (!advertised) {
237
+ console.error(`maestro-orchestrator: no vendor/ in ${localRepoPath} — worktree ${worktreePath} runs without shared dependencies`)
238
+ }
239
+ return linked
240
+ }
241
+
242
+ /** Container path of the project root inside govard services. */
243
+ const GOVARD_CONTAINER_WORKDIR = '/var/www/html'
244
+
245
+ /**
246
+ * Render a compose override that bind-mounts the primary checkout's vendor/
247
+ * read-only into the php service. A host-side symlink alone dangles inside
248
+ * containers (absolute host path), so container tools (phpunit) need this
249
+ * bind to see real dependencies.
250
+ *
251
+ * The project mount (`.`) MUST be repeated first: govard merges overrides
252
+ * with MergeMap, which REPLACES lists instead of appending — an override
253
+ * carrying only the vendor bind would wipe `.:<workdir>` and leave the
254
+ * container docroot holding nothing but vendor/. Relative `.` resolves
255
+ * against the project root because govard passes --project-directory.
256
+ *
257
+ * Only the always-present `php` service is targeted: `php-debug` drops out
258
+ * of the rendered base when xdebug is off, and a volumes-only override
259
+ * entry would recreate it as a hollow service that fails compose validation.
260
+ */
261
+ export function buildVendorOverrideYaml(vendorHostPath: string, envHostPath?: string, containerWorkDir: string = GOVARD_CONTAINER_WORKDIR): string {
262
+ const volumes = [
263
+ `.:${containerWorkDir}`,
264
+ `${vendorHostPath}:${containerWorkDir}/vendor:ro`,
265
+ ...(envHostPath !== undefined ? [`${envHostPath}:${containerWorkDir}/app/etc/env.php:ro`] : []),
266
+ ]
267
+ const service = ` volumes:\n${volumes.map((v) => ` - ${v}\n`).join('')}`
268
+ return `services:\n php:\n${service}`
269
+ }
270
+
271
+ /**
272
+ * Drop the vendor bind override into the worktree (merged by govard via
273
+ * `.govard/docker-compose.override.yml`). Binds only when the primary
274
+ * checkout carries installed deps and the worktree does not — never shadow
275
+ * real deps with a possibly stale bind. Returns the written path, or
276
+ * undefined when skipped.
277
+ */
278
+ export async function writeContainerVendorOverride(localRepoPath: string, worktreePath: string): Promise<string | undefined> {
279
+ const vendorHostPath = join(localRepoPath, 'vendor')
280
+ if (!(await vendorHasAutoload(localRepoPath))) return undefined
281
+ // Our own host-side symlink still needs the bind (it dangles in-container);
282
+ // only a real installed worktree vendor makes the bind redundant.
283
+ const wtLink = await lstat(join(worktreePath, 'vendor')).catch(() => undefined)
284
+ if (wtLink?.isSymbolicLink() !== true && await vendorHasAutoload(worktreePath)) return undefined
285
+ const overridePath = join(worktreePath, '.govard', 'docker-compose.override.yml')
286
+ await mkdir(join(worktreePath, '.govard'), { recursive: true })
287
+ // A linked env.php dangles in-container like the vendor symlink did — bind
288
+ // the real file over it when the primary checkout carries one.
289
+ const envHostPath = join(localRepoPath, 'app', 'etc', 'env.php')
290
+ let envBind: string | undefined
291
+ try {
292
+ if ((await stat(envHostPath)).isFile()) envBind = envHostPath
293
+ } catch {
294
+ envBind = undefined
295
+ }
296
+ await writeFile(overridePath, buildVendorOverrideYaml(vendorHostPath, envBind), 'utf-8')
297
+ console.error(`maestro-orchestrator: container vendor bind ${vendorHostPath} -> ${GOVARD_CONTAINER_WORKDIR}/vendor (ro) for ${worktreePath}`)
298
+ return overridePath
299
+ }
300
+
301
+ export function apply(ctx: Context, config: Config): void {
302
+ async function runReview(payload: ReviewRequest, more: Partial<EngineRunOptions> = {}): Promise<ReviewResult> {
303
+ const t0 = Date.now()
304
+ try {
305
+ const userConfig = await loadUserConfig()
306
+ const effective = {
307
+ gitlabBaseUrl: userConfig.gitlabBaseUrl ?? config.gitlabBaseUrl,
308
+ gitlabToken: userConfig.gitlabToken ?? config.gitlabToken,
309
+ botUsername: userConfig.botUsername ?? config.botUsername,
310
+ projectMappings: userConfig.projectMappings ?? config.projectMappings,
311
+ }
312
+ // Resolved per review run from Settings so an agentTimeoutMs change takes
313
+ // effect without a plugin restart.
314
+ const agentTimeoutMs = typeof userConfig.agentTimeoutMs === 'number' && userConfig.agentTimeoutMs >= 1000
315
+ ? userConfig.agentTimeoutMs
316
+ : config.agentTimeoutMs
317
+ // Best-effort housekeeping; a prune failure must never block a review.
318
+ if (typeof userConfig.reviewSessionRetentionDays === 'number' && userConfig.reviewSessionRetentionDays > 0) {
319
+ void pruneHistory(userConfig.reviewSessionRetentionDays).catch((err: unknown) => {
320
+ console.error('maestro-orchestrator: review history prune failed:', err)
321
+ })
322
+ }
323
+ const mapping = effective.projectMappings.find(m => m.projectPath === payload.projectPath)
324
+ // Unmapped reviewer assignments remain no-ops. Only an explicit mention
325
+ // may opt into the intentionally limited, diff-only fallback below.
326
+ if (mapping === undefined && payload.trigger !== 'mention') {
327
+ console.error(`maestro-orchestrator: drop unmapped project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`)
328
+ return { ok: true, failures: [], durationMs: Date.now() - t0 }
329
+ }
330
+ const triggers = resolveReviewTriggers(userConfig, mapping)
331
+ // Gated-off auto-triggers stay fully silent: no history, no signals, no comment (host log only).
332
+ if (payload.trigger === 'reviewer-assignment' && !triggers.onAssign) {
333
+ console.error(`maestro-orchestrator: drop assign-gate-off project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`)
334
+ return { ok: true, failures: [], durationMs: Date.now() - t0 }
335
+ }
336
+ if (payload.trigger === 'push' && !triggers.onPush) {
337
+ console.error(`maestro-orchestrator: drop push-gate-off project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`)
338
+ return { ok: true, failures: [], durationMs: Date.now() - t0 }
339
+ }
340
+ // A push only re-reviews an MR that already has a completed review;
341
+ // otherwise every newly opened MR would be reviewed twice.
342
+ if (payload.trigger === 'push' && !(await hasCompletedReview(payload.projectId, payload.mrIid))) {
343
+ console.error(`maestro-orchestrator: drop push-no-completed-history project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`)
344
+ return { ok: true, failures: [], durationMs: Date.now() - t0 }
345
+ }
346
+ const { gitlabToken } = effective
347
+ if (gitlabToken === undefined) {
348
+ const message = `MR !${String(payload.mrIid)} for project ${payload.projectPath} has no GitLab token — set one in Maestro Settings or MAESTRO_GITLAB_TOKEN`
349
+ console.error(`maestro-orchestrator: drop missing-token project=${payload.projectPath} mr=!${String(payload.mrIid)} trigger=${payload.trigger} — ${message}`)
350
+ return { ok: false, failures: [message], durationMs: Date.now() - t0 }
351
+ }
352
+ const gitlab = { baseUrl: effective.gitlabBaseUrl, token: gitlabToken, botUsername: effective.botUsername }
353
+ const fallbackSelection: ModelSelection = (ctx.get?.('agentDefaultModel') as { currentSelection(): ModelSelection } | undefined)?.currentSelection()
354
+ ?? (ctx as unknown as { agentDefaultModel?: { currentSelection(): ModelSelection } }).agentDefaultModel?.currentSelection()
355
+ ?? { provider: 'fallback', model: 'fallback' }
356
+ const model = resolveReviewModel(userConfig, mapping, fallbackSelection, config.reviewModel)
357
+ // Opt-in Telegram digest; a delivery failure is logged and dropped.
358
+ const reviewStartMsOuter = Date.now()
359
+ const notifyTelegram = (status: 'completed' | 'failed', summary?: string, durationMs?: number): void => {
360
+ if (userConfig.telegramReviewNotifications !== true) return
361
+ const notifier = ctx.get?.('maestroNotifier') as NotifierLike | undefined
362
+ if (notifier === undefined) return
363
+ void notifier.send(
364
+ 'telegram',
365
+ { botToken: userConfig.telegramBotToken, chatId: userConfig.telegramChatId },
366
+ {
367
+ text: reviewDigestText({
368
+ projectPath: payload.projectPath,
369
+ mrIid: payload.mrIid,
370
+ status,
371
+ summary,
372
+ mode: payload.mode,
373
+ profile: mapping?.reviewProfile,
374
+ gitlabBaseUrl: gitlab.baseUrl,
375
+ // The engine measures from the MR signals start; the decline has no engine run.
376
+ durationMs: durationMs ?? Date.now() - reviewStartMsOuter,
377
+ }),
378
+ },
379
+ ).then((result) => {
380
+ if (!result.sent && result.reason === 'request-failed') {
381
+ console.error(`maestro-orchestrator: Telegram review notification for MR !${String(payload.mrIid)} failed to deliver`)
382
+ }
383
+ }).catch((err) => {
384
+ // Delivery is fire-and-forget: a rejection must not escape into the
385
+ // host's unhandled-rejection path, which exits the whole process.
386
+ console.error(
387
+ `maestro-orchestrator: Telegram review notification for MR !${String(payload.mrIid)} threw:`,
388
+ err instanceof Error ? err.message : err,
389
+ )
390
+ })
391
+ }
392
+ if (mapping === undefined && payload.mode === 'deep') {
393
+ return await declineUnmappedDeep(payload, gitlab, notifyTelegram, t0)
394
+ }
395
+ let access: CodeAccess
396
+ let reviewProfile: ReviewSkillProfile | undefined
397
+ if (mapping !== undefined) {
398
+ access = {
399
+ kind: 'workspace',
400
+ localRepoPath: mapping.localRepoPath,
401
+ ensureWorktree,
402
+ removeWorktree,
403
+ ...(govardOnPath() ? { teardownEnvironment: teardownGovardEnvironment } : {}),
404
+ auditor: 'runtime',
405
+ }
406
+ reviewProfile = mapping.reviewProfile
407
+ } else {
408
+ access = { kind: 'diff' }
409
+ }
410
+ // The project's .maestro-review.yml (default branch): ignore globs, rules, minimum severity,
411
+ // language; fan-out only when the file asks for it (the host keeps one reviewer otherwise).
412
+ const { file, warnings } = await loadRepoSettings(timedFetcher(fetch), { baseUrl: gitlab.baseUrl, token: gitlab.token, projectId: payload.projectId })
413
+ const eff = effectiveConfig({ ignoreGlobs: [], fanout: {} }, file)
414
+ const repo = { rules: eff.rules, warnings, ...(eff.minSeverity !== undefined ? { minSeverity: eff.minSeverity } : {}), ...(eff.language !== undefined ? { language: eff.language } : {}) }
415
+ return await ctx.reviewEngine.run(payload, {
416
+ gitlab, access, reviewProfile, model, agentTimeoutMs, notify: notifyTelegram,
417
+ ignoreGlobs: eff.ignoreGlobs, repo, ...(eff.fanout !== undefined ? { fanout: eff.fanout } : {}),
418
+ ...more,
419
+ })
420
+ } catch (err) {
421
+ const message = err instanceof Error ? err.message : String(err)
422
+ console.error(`maestro-orchestrator: review run failed for MR !${String(payload.mrIid)}:`, err)
423
+ return { ok: false, summary: undefined, failures: [message], durationMs: Date.now() - t0 }
424
+ }
425
+ }
426
+
427
+ /**
428
+ * Answers the MR's pending /maestro commands with the engine's helpers (the
429
+ * same access rules and answer markers as CI); a rereview runs a review
430
+ * limited to its path. Failures are logged, never thrown.
431
+ */
432
+ /** Per MR: whether a command pass is running, and whether notes arrived during it. */
433
+ const commandPasses = new Map<string, { again: boolean }>()
434
+
435
+ /**
436
+ * One command pass per MR at a time: two notes landing together would
437
+ * otherwise both read the same pending command and answer it twice. Notes
438
+ * that arrive during a pass get exactly one trailing pass.
439
+ */
440
+ async function runCommands(mr: MrOpenedPayload): Promise<void> {
441
+ const key = `${mr.projectId}!${mr.mrIid}`
442
+ const running = commandPasses.get(key)
443
+ if (running !== undefined) { running.again = true; return }
444
+ const state = { again: false }
445
+ commandPasses.set(key, state)
446
+ try {
447
+ do {
448
+ state.again = false
449
+ await commandPass(mr)
450
+ } while (state.again)
451
+ } finally {
452
+ commandPasses.delete(key)
453
+ }
454
+ }
455
+
456
+ async function commandPass(mr: MrOpenedPayload): Promise<void> {
457
+ try {
458
+ const userConfig = await loadUserConfig()
459
+ const token = userConfig.gitlabToken ?? config.gitlabToken
460
+ if (token === undefined) { console.error(`maestro-orchestrator: drop command, no GitLab token for ${mr.projectPath}`); return }
461
+ const gitlab = { baseUrl: userConfig.gitlabBaseUrl ?? config.gitlabBaseUrl, token, botUsername: userConfig.botUsername ?? config.botUsername }
462
+ const mapping = (userConfig.projectMappings ?? config.projectMappings).find(m => m.projectPath === mr.projectPath)
463
+ const fallbackSelection: ModelSelection = (ctx.get?.('agentDefaultModel') as { currentSelection(): ModelSelection } | undefined)?.currentSelection()
464
+ ?? { provider: 'fallback', model: 'fallback' }
465
+ const model = resolveReviewModel(userConfig, mapping, fallbackSelection, config.reviewModel)
466
+ const agentTimeoutMs = typeof userConfig.agentTimeoutMs === 'number' && userConfig.agentTimeoutMs >= 1000 ? userConfig.agentTimeoutMs : config.agentTimeoutMs
467
+ const fetcher = timedFetcher(fetch)
468
+ const target = { baseUrl: gitlab.baseUrl, token: gitlab.token, projectId: mr.projectId, mrIid: mr.mrIid }
469
+ const botUserId = await fetchBotUserId(fetcher, gitlab.baseUrl, gitlab.token)
470
+ const pending = await findPendingCommands(fetcher, { ...target, botUserId })
471
+ const request: ReviewRequest = { ...mr, trigger: 'mention', mode: 'quick', scope: { kind: 'mr' } }
472
+ const options = { gitlab, access: { kind: 'diff' } as CodeAccess, model, agentTimeoutMs }
473
+ const reply = (discussionId: string, body: string) => replyToCommand(fetcher, target, discussionId, body)
474
+ await answerCommands(pending, {
475
+ answer: (prompt) => ctx.reviewEngine.answer !== undefined ? ctx.reviewEngine.answer(request, options, prompt) : Promise.reject(new Error('this engine cannot answer commands')),
476
+ reply,
477
+ })
478
+ const rereview = pending.find((c) => c.command.kind === 'rereview')
479
+ if (rereview !== undefined && rereview.command.kind === 'rereview') {
480
+ // Unlike CI, a host review carries no head SHA, so it posts no metadata and no
481
+ // gate reads it: the rereview stays limited to its path. A full review of the
482
+ // current head (a CI one) still has its findings carried into this one.
483
+ const path = rereview.command.path
484
+ const [head, prior] = path === undefined ? [undefined, undefined] : await Promise.all([
485
+ gitlabForge(gitlab, request).mrHeadSha().catch(() => undefined),
486
+ latestCompletedReview(fetcher, { ...target, botUserId }).catch(() => undefined),
487
+ ])
488
+ const carry = head !== undefined && prior?.headSha === head ? prior.findings : undefined
489
+ const result = await runReview({ ...request, ...(path !== undefined ? { pathPrefix: path } : {}) }, carry !== undefined ? { carryFindings: carry } : {})
490
+ const note = result.ok ? `Re-reviewed ${path === undefined ? 'the whole MR' : `\`${path}\``}; see the review comment.` : `The re-review failed: ${result.failures[0] ?? 'unknown error'}`
491
+ await reply(rereview.discussionId, `${note}\n\n${commandMarker(rereview.noteId)}`)
492
+ }
493
+ } catch (err) {
494
+ console.error(`maestro-orchestrator: MR commands on ${mr.projectPath} !${mr.mrIid} failed:`, err instanceof Error ? err.message : err)
495
+ }
496
+ }
497
+
498
+ ctx.on('maestro/review-request', (payload) => { void runReview(payload) })
499
+ ctx.on('maestro/review-command', (payload) => { void runCommands(payload) })
500
+ ctx.provide('reviewRunner', runReview)
501
+ ctx.provide('reviewCommandRunner', runCommands)
502
+ }
503
+
504
+ /** Host-only: a deep request on an unmapped project gets a "not started" note, recorded like a run. */
505
+ async function declineUnmappedDeep(
506
+ payload: ReviewRequest,
507
+ gitlab: EngineGitlab,
508
+ notify: (status: 'completed' | 'failed', summary?: string) => void,
509
+ t0: number,
510
+ ): Promise<ReviewResult> {
511
+ const historyId = `${payload.projectId}-${payload.mrIid}-${Date.now()}`
512
+ const forge = gitlabForge(gitlab, payload)
513
+ const currentHeadSha = await forge.mrHeadSha().catch(() => undefined)
514
+ await recordReviewStart({
515
+ id: historyId,
516
+ projectId: payload.projectId,
517
+ projectPath: payload.projectPath,
518
+ mrIid: payload.mrIid,
519
+ mode: payload.mode,
520
+ scope: payload.scope.kind,
521
+ trigger: payload.trigger,
522
+ startedAt: Date.now(),
523
+ headSha: currentHeadSha,
524
+ })
525
+ const signals = payload.scope.kind === 'mr' ? forge.signals() : undefined
526
+ await signals?.start()
527
+ const postComment = (body: string) => forge.postNote(body)
528
+ const replyToDiscussion = (discussionId: string, body: string) => forge.replyToDiscussion(discussionId, body)
529
+ try {
530
+ const declined = await declineUnmappedDeepReview(payload, { postComment, replyToDiscussion, writeFailedReport, gitlabBaseUrl: gitlab.baseUrl } as unknown as ReviewCommentDeps)
531
+ if (!declined) {
532
+ console.error(`maestro-orchestrator: deduped duplicate in-flight review project=${payload.projectPath} mr=!${payload.mrIid} trigger=${payload.trigger}`)
533
+ await recordReviewFinish(historyId, { status: 'completed', summary: DEDUPED_SUMMARY })
534
+ await signals?.finish('completed')
535
+ return { ok: true, summary: DEDUPED_SUMMARY, failures: [], durationMs: Date.now() - t0 }
536
+ }
537
+ const summary = 'Deep review declined (unmapped project)'
538
+ await recordReviewFinish(historyId, { status: 'completed', summary })
539
+ notify('completed', summary)
540
+ await signals?.finish('completed')
541
+ return { ok: true, summary, failures: [], durationMs: Date.now() - t0 }
542
+ } catch (err) {
543
+ const message = err instanceof Error ? err.message : String(err)
544
+ await recordReviewFinish(historyId, { status: 'failed', error: message }).catch(() => {})
545
+ notify('failed', message)
546
+ await signals?.finish('failed')
547
+ return { ok: false, summary: undefined, failures: [message], durationMs: Date.now() - t0 }
548
+ }
549
+ }
package/src/host/index.ts CHANGED
@@ -1,37 +1,9 @@
1
- import type { Context } from '@deepseek-ai/cordis'
2
- import { makeSkillProvider, resolveSkillsDir } from './skill-provider.js'
3
-
1
+ /**
2
+ * Package entry of @ddtcorex/dsh-maestro-review (row `maestro-review-plugin`).
3
+ * Every capability is its own row in cordis.patch.yml (webhook, host
4
+ * orchestrator, settings RPC); the root row exists so DSH serves the client
5
+ * bundle, and apply() itself registers nothing.
6
+ */
4
7
  export const name = '@ddtcorex/dsh-maestro-review'
5
8
 
6
- export function apply(ctx: Context): void {
7
- // The bundled DSH tool map is served from here, not from the public
8
- // `maestro-skills` plugin: that repo's catalog test requires its skill content
9
- // to stay tool-neutral, and this map names harness tools. Wrapped like the
10
- // rest of apply(): a missing service or a throwing registration must never
11
- // take down the whole plugin tree.
12
- try {
13
- const skills = (ctx as unknown as { get?: (key: string) => any }).get?.('skills')
14
- if (skills?.registerProvider) {
15
- ctx.effect(() => {
16
- let unregister: (() => void) | undefined
17
- try {
18
- // Package-root skills/ is resolved at runtime by walking to the
19
- // nearest package.json (robust to lib/ vs src/host/ layouts).
20
- unregister = skills.registerProvider(() => makeSkillProvider(resolveSkillsDir(__dirname)))
21
- } catch (e: any) {
22
- try { (ctx as any).logger?.warn?.(`[review] skill provider failed: ${e?.message ?? String(e)}`) } catch {}
23
- }
24
- return () => { try { unregister?.() } catch {} }
25
- }, 'maestro-review:skill')
26
- }
27
- } catch (e: any) {
28
- try { (ctx as any).logger?.warn?.(`[review] skill provider effect failed: ${e?.message ?? String(e)}`) } catch {}
29
- }
30
-
31
- // No RPC registration here on purpose. The channel belongs to settings-rpc.ts
32
- // (row `maestro-review-settings-rpc`), which implements the real endpoints. A
33
- // stub in this file used to claim the same channel; that stayed invisible only
34
- // because apply() was never mounted. Once the `maestro-review-host` row made
35
- // apply() run, both registrations collided and the Settings card died with:
36
- // webserver: duplicate prefix route "/dsh-maestro-review"
37
- }
9
+ export function apply(): void {}
@@ -3,8 +3,8 @@ import type { Context } from '@deepseek-ai/cordis'
3
3
  import z from '@deepseek-ai/schemastery'
4
4
  import { loadUserConfig } from '../config-store.js'
5
5
  import { secretsMatch } from '../secure-compare.js'
6
- import type { MrOpenedPayload, ReviewRequest as OrchestratorReviewRequest } from '../events.js'
7
- import { describeDrop, routeGitlabReviewRequest } from '../review-intake.js'
6
+ import type { MrOpenedPayload, ReviewRequest as OrchestratorReviewRequest } from '@ddtcorex/maestro-reviewer/lib/events.js'
7
+ import { describeDrop, routeGitlabCommand, routeGitlabReviewRequest } from '../review-intake.js'
8
8
 
9
9
  export const name = 'maestro-review-webhook'
10
10
  export const inject = ['webServer'] as const
@@ -97,6 +97,12 @@ export function apply(ctx: Context, config: Config): void {
97
97
  console.error(`maestro-review-webhook: drop invalid-identity object_kind=${(body as { object_kind?: unknown }).object_kind ?? 'unknown'}`)
98
98
  res.writeHead(400).end(); return
99
99
  }
100
+ // A /maestro command note: answered by the command runner, never routed as a mention too.
101
+ const command = routeGitlabCommand(body, botUsername)
102
+ if (command !== undefined) {
103
+ ctx.emit('maestro/review-command', command)
104
+ res.writeHead(200).end(); return
105
+ }
100
106
  // The orchestrator is the sole push gate (resolveReviewTriggers);
101
107
  // intake always emits so per-project overrides keep working.
102
108
  const request = routeGitlabReviewRequest(body, botUsername, { pushEnabled: true })
@@ -1,4 +1,5 @@
1
- import type { MrOpenedPayload, ReviewMode, ReviewRequest, ReviewScope } from './events.js'
1
+ import type { MrOpenedPayload, ReviewMode, ReviewRequest, ReviewScope } from '@ddtcorex/maestro-reviewer/lib/events.js'
2
+ import { parseCommand } from '@ddtcorex/maestro-reviewer/lib/commands.js'
2
3
 
3
4
  type JsonRecord = Record<string, unknown>
4
5
 
@@ -123,3 +124,21 @@ export function routeGitlabReviewRequest(body: unknown, botUsername: string, opt
123
124
  const mode: ReviewMode = /(?:^|\s)\/maestro\s+deep(?:\s|$)/i.test(note) || /\bdeep\s+review\b/i.test(note) ? 'deep' : 'quick'
124
125
  return { ...payload, trigger: 'mention', mode, scope }
125
126
  }
127
+
128
+ /**
129
+ * A note whose first line is `/maestro explain|fix|rereview` (no mention
130
+ * needed): the MR to answer commands on. The engine then reads every pending
131
+ * command of the MR from GitLab and checks each author's access, so this only
132
+ * routes. The bot's own notes never count.
133
+ */
134
+ export function routeGitlabCommand(body: unknown, botUsername: string): MrOpenedPayload | undefined {
135
+ const value = record(body)
136
+ if (value === undefined || value.object_kind !== 'note' || botUsername.trim() === '') return undefined
137
+ const user = record(value.user)
138
+ if (typeof user?.username === 'string' && user.username.toLowerCase() === botUsername.toLowerCase()) return undefined
139
+ const attributes = record(value.object_attributes)
140
+ if (attributes === undefined || typeof attributes.note !== 'string') return undefined
141
+ const command = parseCommand(attributes.note)
142
+ if (command === undefined || command.kind === 'dismiss') return undefined
143
+ return mrPayload(value)
144
+ }
@@ -3,7 +3,7 @@ import type {} from '@deepseek-ai/dsh-client-connection'
3
3
  import type { RpcErrorDetailsMap, RpcResult } from '@deepseek-ai/dsh-client-connection'
4
4
  import { existsSync, statSync } from 'node:fs'
5
5
  import { loadUserConfig, saveUserConfig, type MaestroUserConfig } from './config-store.js'
6
- import { listReviews } from './review-history.js'
6
+ import { listReviews } from '@ddtcorex/maestro-reviewer/lib/review-history.js'
7
7
 
8
8
  export const name = 'maestro-settings-rpc'
9
9
  /**