@picassohq/cli 0.0.0-stage → 1.0.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 (230) hide show
  1. package/agents/browser_agent.yaml +53 -0
  2. package/agents/code_reviewer.yaml +49 -0
  3. package/agents/codebase_investigator.yaml +70 -0
  4. package/agents/design_auditor.yaml +50 -0
  5. package/agents/devex_auditor.yaml +50 -0
  6. package/agents/doc_writer.yaml +54 -0
  7. package/agents/engineering_architect.yaml +51 -0
  8. package/agents/generalist.yaml +55 -0
  9. package/agents/migration_planner.yaml +51 -0
  10. package/agents/product_reviewer.yaml +48 -0
  11. package/agents/qa_operator.yaml +52 -0
  12. package/agents/release_engineer.yaml +50 -0
  13. package/agents/security_auditor.yaml +62 -0
  14. package/agents/test_writer.yaml +52 -0
  15. package/assets/first-light-lockup.png +0 -0
  16. package/assets/first-light-tagline.png +0 -0
  17. package/assets/house/README.md +26 -0
  18. package/assets/house/auraone-banner.png +0 -0
  19. package/assets/house/auraone-logo.png +0 -0
  20. package/assets/house/kiro-prism-banner.png +0 -0
  21. package/assets/house/kiro-prism-logo.png +0 -0
  22. package/assets/house/picasso-banner.png +0 -0
  23. package/assets/house/picasso-logo.png +0 -0
  24. package/assets/wordmark-app.png +0 -0
  25. package/assets/wordmark-tight.png +0 -0
  26. package/assets/wordmark.png +0 -0
  27. package/design/styles.css +1042 -0
  28. package/dist/build-info.json +37 -0
  29. package/dist/index.js +3028 -0
  30. package/goals/cli-hardening.yaml +40 -0
  31. package/goals/repo-maintenance.yaml +40 -0
  32. package/package.json +49 -4
  33. package/runtime/dsh/picasso-ecosystem.community.amendments.yml +24 -0
  34. package/runtime/dsh/picasso-ecosystem.community.json +185 -0
  35. package/runtime/dsh/picasso-ecosystem.community.patch.yml +40 -0
  36. package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +143 -0
  37. package/runtime/dsh/picasso-isolation.patch.yml +25 -0
  38. package/runtime/dsh/picasso-providers.patch.yml +373 -0
  39. package/runtime/dsh/picasso-runtime.cordis.yml +738 -0
  40. package/runtime/dsh/picasso-sdk.patch.yml +204 -0
  41. package/runtime/engine-manifest.json +214 -0
  42. package/runtime/package.json +6 -0
  43. package/runtime/packages/picasso-cache-probe/cordis.patch.yml +5 -0
  44. package/runtime/packages/picasso-cache-probe/index.js +477 -0
  45. package/runtime/packages/picasso-cache-probe/package.json +38 -0
  46. package/runtime/packages/picasso-commands/cordis.patch.yml +4 -0
  47. package/runtime/packages/picasso-commands/fresh-review.js +573 -0
  48. package/runtime/packages/picasso-commands/index.js +497 -0
  49. package/runtime/packages/picasso-commands/package.json +28 -0
  50. package/runtime/packages/picasso-instructions/conflicts.js +115 -0
  51. package/runtime/packages/picasso-instructions/formats.js +145 -0
  52. package/runtime/packages/picasso-instructions/frontmatter.js +175 -0
  53. package/runtime/packages/picasso-instructions/glob.js +114 -0
  54. package/runtime/packages/picasso-instructions/globals.js +90 -0
  55. package/runtime/packages/picasso-instructions/imports.js +123 -0
  56. package/runtime/packages/picasso-instructions/index.js +326 -0
  57. package/runtime/packages/picasso-instructions/modes.js +64 -0
  58. package/runtime/packages/picasso-instructions/package.json +30 -0
  59. package/runtime/packages/picasso-instructions/parse.js +134 -0
  60. package/runtime/packages/picasso-instructions/report.js +161 -0
  61. package/runtime/packages/picasso-instructions/resolve.js +939 -0
  62. package/runtime/packages/picasso-instructions/scan.js +181 -0
  63. package/runtime/packages/picasso-instructions/settings.js +150 -0
  64. package/runtime/packages/picasso-instructions/skills.js +345 -0
  65. package/runtime/packages/picasso-lean-context/cordis.patch.yml +13 -0
  66. package/runtime/packages/picasso-lean-context/index.js +6049 -0
  67. package/runtime/packages/picasso-lean-context/package.json +26 -0
  68. package/runtime/packages/picasso-lean-context/timeline.js +417 -0
  69. package/runtime/packages/picasso-librarian/classify.js +146 -0
  70. package/runtime/packages/picasso-librarian/cordis.patch.yml +10 -0
  71. package/runtime/packages/picasso-librarian/index.js +878 -0
  72. package/runtime/packages/picasso-librarian/notes.js +159 -0
  73. package/runtime/packages/picasso-librarian/package.json +34 -0
  74. package/runtime/packages/picasso-librarian/state.js +478 -0
  75. package/runtime/packages/picasso-memory/index.js +1184 -0
  76. package/runtime/packages/picasso-memory/package.json +21 -0
  77. package/runtime/packages/picasso-model-router/connections.js +895 -0
  78. package/runtime/packages/picasso-model-router/cordis.patch.yml +17 -0
  79. package/runtime/packages/picasso-model-router/index.js +1081 -0
  80. package/runtime/packages/picasso-model-router/package.json +30 -0
  81. package/runtime/packages/picasso-options/cordis.patch.yml +4 -0
  82. package/runtime/packages/picasso-options/index.js +263 -0
  83. package/runtime/packages/picasso-options/package.json +28 -0
  84. package/runtime/packages/picasso-progress-reports/cordis.patch.yml +10 -0
  85. package/runtime/packages/picasso-progress-reports/index.js +267 -0
  86. package/runtime/packages/picasso-progress-reports/package.json +30 -0
  87. package/runtime/packages/picasso-progress-reports/report.js +235 -0
  88. package/runtime/packages/picasso-sdk-server/aside.js +128 -0
  89. package/runtime/packages/picasso-sdk-server/connections.js +38 -0
  90. package/runtime/packages/picasso-sdk-server/context-timeline.js +27 -0
  91. package/runtime/packages/picasso-sdk-server/egress-gate.js +520 -0
  92. package/runtime/packages/picasso-sdk-server/failure-policy.js +246 -0
  93. package/runtime/packages/picasso-sdk-server/file-input.js +169 -0
  94. package/runtime/packages/picasso-sdk-server/goal.js +131 -0
  95. package/runtime/packages/picasso-sdk-server/ignore-file.js +458 -0
  96. package/runtime/packages/picasso-sdk-server/ignore-plugin.js +12 -0
  97. package/runtime/packages/picasso-sdk-server/ignore-sandbox.js +122 -0
  98. package/runtime/packages/picasso-sdk-server/ignore-snapshot.js +131 -0
  99. package/runtime/packages/picasso-sdk-server/image-input.js +44 -0
  100. package/runtime/packages/picasso-sdk-server/index.js +886 -0
  101. package/runtime/packages/picasso-sdk-server/instructions.js +34 -0
  102. package/runtime/packages/picasso-sdk-server/jobs.js +113 -0
  103. package/runtime/packages/picasso-sdk-server/mcp-gate.js +51 -0
  104. package/runtime/packages/picasso-sdk-server/model-selection.js +162 -0
  105. package/runtime/packages/picasso-sdk-server/package.json +50 -0
  106. package/runtime/packages/picasso-sdk-server/picasso-records.js +50 -0
  107. package/runtime/packages/picasso-sdk-server/provider-reload.js +84 -0
  108. package/runtime/packages/picasso-sdk-server/queue.js +322 -0
  109. package/runtime/packages/picasso-sdk-server/requester.js +43 -0
  110. package/runtime/packages/picasso-sdk-server/rewind.js +108 -0
  111. package/runtime/packages/picasso-sdk-server/schedule.js +187 -0
  112. package/runtime/packages/picasso-sdk-server/session-grants.js +35 -0
  113. package/runtime/packages/picasso-sdk-server/session-state.js +118 -0
  114. package/runtime/packages/picasso-sdk-server/shell-paths.js +869 -0
  115. package/runtime/packages/picasso-sdk-server/stream-deltas.js +211 -0
  116. package/runtime/packages/picasso-sdk-server/team-tasks.js +451 -0
  117. package/runtime/packages/picasso-sdk-server/tool-output.js +128 -0
  118. package/runtime/packages/picasso-sdk-server/tools-list.js +51 -0
  119. package/runtime/packages/picasso-sdk-server/wave2-hooks.js +612 -0
  120. package/runtime/packages/picasso-sdk-server/workspace-archive.js +170 -0
  121. package/runtime/packages/picasso-sdk-server/workspace-restore.js +180 -0
  122. package/runtime/packages/picasso-web-search/backends.js +350 -0
  123. package/runtime/packages/picasso-web-search/config.js +121 -0
  124. package/runtime/packages/picasso-web-search/cordis.patch.yml +7 -0
  125. package/runtime/packages/picasso-web-search/failure.js +111 -0
  126. package/runtime/packages/picasso-web-search/format.js +35 -0
  127. package/runtime/packages/picasso-web-search/index.js +66 -0
  128. package/runtime/packages/picasso-web-search/package.json +38 -0
  129. package/runtime/packages/picasso-web-search/router.js +155 -0
  130. package/runtime/packages/picasso-x-reader/circle.js +324 -0
  131. package/runtime/packages/picasso-x-reader/command.js +169 -0
  132. package/runtime/packages/picasso-x-reader/cordis.patch.yml +8 -0
  133. package/runtime/packages/picasso-x-reader/index.js +170 -0
  134. package/runtime/packages/picasso-x-reader/package.json +39 -0
  135. package/runtime/packages/picasso-x-reader/read.js +370 -0
  136. package/runtime/packages/picasso-x-reader/rewrite.js +38 -0
  137. package/runtime/packages/picasso-x-reader/settings.js +131 -0
  138. package/runtime/packages/picasso-x-reader/urls.js +154 -0
  139. package/runtime/packages/picasso-x-reader/xmd.js +512 -0
  140. package/runtime/plugins/picasso-auth-bridge/index.js +380 -0
  141. package/runtime/plugins/picasso-auth-bridge/package.json +28 -0
  142. package/runtime/plugins/picasso-auto-approve/index.js +1003 -0
  143. package/runtime/plugins/picasso-auto-approve/package.json +28 -0
  144. package/runtime/plugins/picasso-browser/index.js +424 -0
  145. package/runtime/plugins/picasso-browser/package.json +28 -0
  146. package/runtime/plugins/picasso-checkpoints/evidence.js +210 -0
  147. package/runtime/plugins/picasso-checkpoints/index.js +885 -0
  148. package/runtime/plugins/picasso-checkpoints/package.json +29 -0
  149. package/runtime/plugins/picasso-commands/fresh-review.js +573 -0
  150. package/runtime/plugins/picasso-commands/index.js +497 -0
  151. package/runtime/plugins/picasso-commands/package.json +28 -0
  152. package/runtime/plugins/picasso-instructions/conflicts.js +115 -0
  153. package/runtime/plugins/picasso-instructions/formats.js +145 -0
  154. package/runtime/plugins/picasso-instructions/frontmatter.js +175 -0
  155. package/runtime/plugins/picasso-instructions/glob.js +114 -0
  156. package/runtime/plugins/picasso-instructions/globals.js +90 -0
  157. package/runtime/plugins/picasso-instructions/imports.js +123 -0
  158. package/runtime/plugins/picasso-instructions/index.js +326 -0
  159. package/runtime/plugins/picasso-instructions/modes.js +64 -0
  160. package/runtime/plugins/picasso-instructions/package.json +30 -0
  161. package/runtime/plugins/picasso-instructions/parse.js +134 -0
  162. package/runtime/plugins/picasso-instructions/report.js +161 -0
  163. package/runtime/plugins/picasso-instructions/resolve.js +939 -0
  164. package/runtime/plugins/picasso-instructions/scan.js +181 -0
  165. package/runtime/plugins/picasso-instructions/settings.js +150 -0
  166. package/runtime/plugins/picasso-instructions/skills.js +345 -0
  167. package/runtime/plugins/picasso-lean-context/index.js +6049 -0
  168. package/runtime/plugins/picasso-lean-context/package.json +26 -0
  169. package/runtime/plugins/picasso-lean-context/timeline.js +417 -0
  170. package/runtime/plugins/picasso-librarian/classify.js +146 -0
  171. package/runtime/plugins/picasso-librarian/index.js +878 -0
  172. package/runtime/plugins/picasso-librarian/notes.js +159 -0
  173. package/runtime/plugins/picasso-librarian/package.json +34 -0
  174. package/runtime/plugins/picasso-librarian/state.js +478 -0
  175. package/runtime/plugins/picasso-lifecycle-hooks/index.js +186 -0
  176. package/runtime/plugins/picasso-lifecycle-hooks/package.json +25 -0
  177. package/runtime/plugins/picasso-mail/inbox.js +207 -0
  178. package/runtime/plugins/picasso-mail/index.js +293 -0
  179. package/runtime/plugins/picasso-mail/package.json +22 -0
  180. package/runtime/plugins/picasso-memory/index.js +1184 -0
  181. package/runtime/plugins/picasso-memory/package.json +21 -0
  182. package/runtime/plugins/picasso-model-router/connections.js +895 -0
  183. package/runtime/plugins/picasso-model-router/index.js +1081 -0
  184. package/runtime/plugins/picasso-model-router/package.json +30 -0
  185. package/runtime/plugins/picasso-options/index.js +263 -0
  186. package/runtime/plugins/picasso-options/package.json +28 -0
  187. package/runtime/plugins/picasso-progress-reports/index.js +267 -0
  188. package/runtime/plugins/picasso-progress-reports/package.json +30 -0
  189. package/runtime/plugins/picasso-progress-reports/report.js +235 -0
  190. package/runtime/plugins/picasso-provider-models/index.js +436 -0
  191. package/runtime/plugins/picasso-provider-models/package.json +28 -0
  192. package/runtime/plugins/picasso-repo-index/index.js +1850 -0
  193. package/runtime/plugins/picasso-repo-index/package.json +28 -0
  194. package/runtime/plugins/picasso-schedule-pause/index.js +344 -0
  195. package/runtime/plugins/picasso-schedule-pause/package.json +28 -0
  196. package/runtime/plugins/picasso-session-lifecycle/index.js +796 -0
  197. package/runtime/plugins/picasso-session-lifecycle/package.json +28 -0
  198. package/runtime/plugins/picasso-trackers/index.js +895 -0
  199. package/runtime/plugins/picasso-trackers/package.json +28 -0
  200. package/runtime/plugins/picasso-web-search/backends.js +350 -0
  201. package/runtime/plugins/picasso-web-search/config.js +121 -0
  202. package/runtime/plugins/picasso-web-search/failure.js +111 -0
  203. package/runtime/plugins/picasso-web-search/format.js +35 -0
  204. package/runtime/plugins/picasso-web-search/index.js +66 -0
  205. package/runtime/plugins/picasso-web-search/package.json +38 -0
  206. package/runtime/plugins/picasso-web-search/router.js +155 -0
  207. package/runtime/plugins/picasso-x-reader/circle.js +324 -0
  208. package/runtime/plugins/picasso-x-reader/command.js +169 -0
  209. package/runtime/plugins/picasso-x-reader/index.js +170 -0
  210. package/runtime/plugins/picasso-x-reader/package.json +39 -0
  211. package/runtime/plugins/picasso-x-reader/read.js +370 -0
  212. package/runtime/plugins/picasso-x-reader/rewrite.js +38 -0
  213. package/runtime/plugins/picasso-x-reader/settings.js +131 -0
  214. package/runtime/plugins/picasso-x-reader/urls.js +154 -0
  215. package/runtime/plugins/picasso-x-reader/xmd.js +512 -0
  216. package/runtime/relay/attachment-text.mjs +737 -0
  217. package/runtime/relay/companion/companion.css +126 -0
  218. package/runtime/relay/companion/companion.js +648 -0
  219. package/runtime/relay/companion/icon.svg +5 -0
  220. package/runtime/relay/companion/index.html +25 -0
  221. package/runtime/relay/companion/manifest.json +13 -0
  222. package/runtime/relay/companion/sw.js +41 -0
  223. package/runtime/relay/main.mjs +37252 -0
  224. package/runtime/relay/model-listing.mjs +614 -0
  225. package/runtime/relay/versions-routes.mjs +1198 -0
  226. package/runtime/verify-plugins.mjs +205 -0
  227. package/runtime-lock/package-lock.json +10779 -0
  228. package/runtime-lock/package.json +7 -0
  229. package/scripts/install-runtime.mjs +400 -0
  230. package/README.md +0 -3
@@ -0,0 +1,497 @@
1
+ // @picasso/commands — dsh runtime bridge: advertises picasso slash commands
2
+ // in the dsh command registry (ctx.commands). Handlers acknowledge the command;
3
+ // execution stays on the picasso surface (TUI/CLI/Mac app).
4
+ // Generated from packages/commands/src/manifest.ts (dsh's own goal/plan excluded).
5
+ // The `init` and `worktree` registrations below are hand-maintained: unlike the
6
+ // generated rows their handlers do the work in-dsh (`init` writes AGENTS.md into
7
+ // the session workspace; `worktree` drives the engine's `worktrees` service).
8
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
9
+ import { homedir } from 'node:os'
10
+ import { join } from 'node:path'
11
+ import { parseReviewArgs, runFreshReview } from './fresh-review.js'
12
+
13
+ export const name = 'picasso-commands'
14
+ // `worktrees` is the dsh-experimental-worktree service (mounted as `worktree` by the
15
+ // generated engine patch); the /worktree handler below calls `ctx.worktrees.create`.
16
+ export const inject = ['commands', 'worktrees']
17
+
18
+ const COMMANDS = [
19
+ {
20
+ "name": "run",
21
+ "description": "Run a one-shot prompt in the current conversation."
22
+ },
23
+ {
24
+ "name": "model",
25
+ "description": "Switch the active model for this session."
26
+ },
27
+ {
28
+ "name": "auth",
29
+ "description": "Open local auth context."
30
+ },
31
+ {
32
+ "name": "provider",
33
+ "description": "Bring-your-own-key provider management: list routes, store or remove your own API key for any provider (deepseek, openai, anthropic, ...)."
34
+ },
35
+ {
36
+ "name": "context",
37
+ "description": "Show context-window usage and compaction options."
38
+ },
39
+ {
40
+ "name": "memory",
41
+ "description": "Inspect, initialize, sync, add, update, delete, pin, or unpin shared runtime memory entries."
42
+ },
43
+ {
44
+ "name": "replay",
45
+ "description": "Open a previous session replay."
46
+ },
47
+ {
48
+ "name": "subagent",
49
+ "description": "Open the helper fleet or run a bounded local subagent task."
50
+ },
51
+ {
52
+ "name": "skills",
53
+ "description": "List, add, enable, disable, or validate Picasso-curated skills."
54
+ },
55
+ {
56
+ "name": "hooks",
57
+ "description": "List, add, enable, disable, or validate Picasso-curated hooks."
58
+ },
59
+ {
60
+ "name": "mcp",
61
+ "description": "List, install, enable, disable, or validate MCP servers."
62
+ },
63
+ {
64
+ "name": "agents",
65
+ "description": "List, enable, disable, or validate Picasso-curated agents."
66
+ },
67
+ {
68
+ "name": "extensions",
69
+ "description": "List, install, enable, disable, or validate Picasso-curated extensions."
70
+ },
71
+ {
72
+ "name": "approval",
73
+ "description": "Open command search."
74
+ },
75
+ {
76
+ "name": "share",
77
+ "description": "Create or revoke a local redacted replay share."
78
+ },
79
+ {
80
+ "name": "mode",
81
+ "description": "Change persisted permission mode or set an explicit session-only override."
82
+ },
83
+ {
84
+ "name": "help",
85
+ "description": "Show help."
86
+ },
87
+ {
88
+ "name": "guide",
89
+ "description": "Open local setup checks and production prerequisites."
90
+ },
91
+ {
92
+ "name": "quit",
93
+ "description": "Exit Picasso."
94
+ },
95
+ {
96
+ "name": "cost",
97
+ "description": "Show session cost and remaining budget."
98
+ },
99
+ {
100
+ "name": "catalog",
101
+ "description": "Open Picasso skills, agents, MCP profiles, hooks, and workflows catalog."
102
+ },
103
+ {
104
+ "name": "project",
105
+ "description": "Open, select, and inspect local projects."
106
+ },
107
+ {
108
+ "name": "helper",
109
+ "description": "Check helper health and review approvals or browser evidence."
110
+ },
111
+ {
112
+ "name": "browser",
113
+ "description": "Review helper browser previews, screenshots, comments, console logs, and network evidence."
114
+ },
115
+ {
116
+ "name": "runs",
117
+ "description": "List helper-owned runs and inspect artifacts, diffs, tests, and evidence."
118
+ },
119
+ {
120
+ "name": "ship",
121
+ "description": "Show Ship Room readiness, launch blockers, next actions, and evidence freshness."
122
+ },
123
+ {
124
+ "name": "desktop",
125
+ "description": "Inspect admin-projected provider, budget, and sponsor policy."
126
+ },
127
+ {
128
+ "name": "settings",
129
+ "description": "Show or update local desktop settings."
130
+ },
131
+ {
132
+ "name": "voice",
133
+ "description": "Review voice transcripts before explicit submit."
134
+ },
135
+ {
136
+ "name": "schedules",
137
+ "description": "Schedules that message a thread or start a new one, once or repeating, with missed runs."
138
+ },
139
+ {
140
+ "name": "ads",
141
+ "description": "Show sponsored terminal ad controls and opt-out state."
142
+ },
143
+ {
144
+ "name": "studio",
145
+ "description": "Open the Studio layout."
146
+ },
147
+ {
148
+ "name": "paper",
149
+ "description": "Switch to the paper theme."
150
+ },
151
+ {
152
+ "name": "dark",
153
+ "description": "Switch to the dark theme."
154
+ },
155
+ {
156
+ "name": "colorblind",
157
+ "description": "Switch to the blue/orange diff palette."
158
+ }
159
+ ];
160
+
161
+ // ---- hand-maintained: /init ------------------------------------------------
162
+ // Writes/updates AGENTS.md in the session workspace. The scaffold lands inside a
163
+ // managed marker block so re-runs replace only what Picasso owns and never touch
164
+ // operator-authored text around it. Scaffolds a lean Tier-1 routing index (< 2.5 KB)
165
+ // with commands, workspace layout, on-demand docs/ routing table, and gateway triggers.
166
+
167
+ const AGENTS_FILE = 'AGENTS.md'
168
+ const BLOCK_START = '<!-- picasso:init:start -->'
169
+ const BLOCK_END = '<!-- picasso:init:end -->'
170
+
171
+ const exists = (path) => { try { return existsSync(path) } catch { return false } }
172
+ const readJson = (path) => { try { return JSON.parse(readFileSync(path, 'utf8')) } catch { return undefined } }
173
+
174
+ const GATEWAY_TRIGGERS = [
175
+ '- Deferred tools are callable via tool_call(name, arguments); search with tool_search(query) or read ~/.picasso/tool-catalog/INDEX.md.',
176
+ '- MCP servers are enabled via <server>_call(tool, arguments); read ~/.picasso/mcp-catalog/<server>.md (or pass tool="__list__") before the first call.',
177
+ '- Memories not inlined in Tier 1 are listed by id/title; call recall(ids | query) to load full bodies on demand.',
178
+ ]
179
+
180
+ // Skill triggers name only skills installed for this person (project or home skill roots): a line pointing at a
181
+ // skill someone doesn't have is noise, and a personal skill's name must never ride into everyone's AGENTS.md.
182
+ const SKILL_TRIGGERS = [
183
+ { scope: 'UI/design', skills: ['design', 'design-review'] },
184
+ { scope: 'LLM/AI routing', skills: ['kiro-prism-integration'] },
185
+ { scope: 'reverse engineering', skills: ['reverse-engineer-anything'] },
186
+ ]
187
+
188
+ // The skill roots `picasso skills` reads, in precedence order. A copy of PROJECT_SKILL_ROOTS / USER_SKILL_ROOTS in
189
+ // packages/picasso-instructions/skills.js (this plugin ships alone, so it cannot import that file); the parity test
190
+ // in packages/picasso-instructions/test/skills.test.mjs fails when the two drift.
191
+ export const SKILL_PROJECT_ROOTS = Object.freeze(['.picasso/skills', '.dsh/skills', '.agents/skills', '.claude/skills', '.github/skills', '.cursor/skills', '.qwen/skills', '.kiro/skills', '.devin/skills'])
192
+ export const SKILL_USER_ROOTS = Object.freeze([
193
+ Object.freeze({ base: '.dsh', env: 'DSH_HOME' }),
194
+ Object.freeze({ base: '.agents', env: 'AGENTS_HOME' }),
195
+ Object.freeze({ base: '.picasso', env: 'PICASSO_HOME' }),
196
+ Object.freeze({ base: '.claude' }),
197
+ ])
198
+
199
+ /** The skill roots `picasso skills` reads (project first, then the user's). */
200
+ export function skillRootsFor(cwd, env = process.env) {
201
+ const home = env.HOME ?? homedir()
202
+ return [
203
+ ...SKILL_PROJECT_ROOTS.map((path) => join(cwd, ...path.split('/'))),
204
+ ...SKILL_USER_ROOTS.map(({ base, env: name }) => {
205
+ const fromEnv = name === undefined ? undefined : env[name]
206
+ return join(typeof fromEnv === 'string' && fromEnv.trim() !== '' ? fromEnv : join(home, base), 'skills')
207
+ }),
208
+ ]
209
+ }
210
+
211
+ /** "- When working on UI/design, load skill design or design-review first. …", from installed skills only. */
212
+ export function skillTriggerLine(roots) {
213
+ const installed = (name) => roots.some((root) => exists(join(root, name, 'SKILL.md')))
214
+ const clauses = SKILL_TRIGGERS.flatMap(({ scope, skills }) => {
215
+ const found = skills.filter(installed)
216
+ return found.length === 0 ? [] : [`When working on ${scope}, load skill ${found.join(' or ')} first.`]
217
+ })
218
+ return clauses.length === 0 ? [] : [`- ${clauses.join(' ')}`]
219
+ }
220
+
221
+ /** The package-manager invocation for a JS workspace, from its lockfile or `packageManager`. */
222
+ function jsRunner(cwd, pkg) {
223
+ const field = typeof pkg?.packageManager === 'string' ? pkg.packageManager : ''
224
+ if (field.startsWith('pnpm') || exists(join(cwd, 'pnpm-lock.yaml')) || exists(join(cwd, 'pnpm-workspace.yaml'))) return 'pnpm'
225
+ if (field.startsWith('yarn') || exists(join(cwd, 'yarn.lock'))) return 'yarn'
226
+ if (field.startsWith('bun') || exists(join(cwd, 'bun.lockb')) || exists(join(cwd, 'bun.lock'))) return 'bun'
227
+ return 'npm'
228
+ }
229
+
230
+ /** Detect workspace commands, layout, and routing rules from the project's manifests. */
231
+ function detectStack(cwd) {
232
+ const pkg = readJson(join(cwd, 'package.json'))
233
+ const isPicassoRepo = pkg?.name === 'picasso' && exists(join(cwd, 'dsh', 'picasso-sdk.patch.yml'))
234
+ if (isPicassoRepo) {
235
+ return {
236
+ summary: '**Picasso** — CLI/TUI & macOS agent on `@deepseek-ai/dsh` ≥`0.2.2-rc.3`.',
237
+ commands: [
238
+ '- **Commands:** `pnpm build` · `pnpm typecheck` · `pnpm test` · `node --test` · `swift test`',
239
+ '- **C1 zero-fallback relay:** Never synthesize mock turns or stub outputs if `dsh` fails.',
240
+ '- **Tier-1 cache stability:** Keep `tools -> system -> Tier 1` byte-identical across turns/modes/surfaces; append Tier 2 in history.',
241
+ '- **DSH ≥`0.2.2-rc.3`:** Never edit `@deepseek-ai/*`; use `dsh/*.patch.yml` & `packages/picasso-*`.',
242
+ '- **Fonts & dense UI:** `/Users/gurbakshchahal/fonts/README.md` (13–14px body, 12px meta, 34px rows, 32px controls).',
243
+ ],
244
+ layout: [
245
+ ['`apps/cli`', 'CLI (`picasso`, `run`, `mcp`, `memory`, `cache`, `skills`)'],
246
+ ['`apps/mac`', 'Swift/SwiftUI macOS app & `PicassoTests`'],
247
+ ['`apps/desktop-helper`', 'HTTP+SSE relay (`dsh-host.ts`, `relay.ts`, `dsh-remote.ts`)'],
248
+ ['`packages/core`', 'DSH stdio session (`runtime-session.ts`), contract, projector'],
249
+ ['`packages/tui`', 'Terminal UI & slash commands'],
250
+ ['`packages/mcp`', 'On-demand MCP gateway, catalog & lazy transport'],
251
+ ['`packages/picasso-*`', 'Shared plugins (`sdk-server`, `commands`, `memory`, `cache-probe`)'],
252
+ ],
253
+ routes: [
254
+ ['Lean context', 'Read `docs/lean-context-architecture.md` when working on Tier 1/Tier 2 disclosure.'],
255
+ ['DSH ecosystem', 'Read `docs/dsh-ecosystem.md` when working on `dsh/*.patch.yml` or `packages/picasso-*`.'],
256
+ ['Mac relay', 'Read `docs/mac-relay.md` when working on `apps/mac` or `apps/desktop-helper`.'],
257
+ ['CLI & TUI', 'Read `docs/tui-architecture.md` when working on `apps/cli`, `packages/tui`, or `runtime-session.ts`.'],
258
+ ['Cache harness', 'Read `docs/cache-harness.md` when working on `picasso-cache-probe` or `cache-harness`.'],
259
+ ],
260
+ }
261
+ }
262
+
263
+ const cmds = []
264
+ if (pkg) {
265
+ const run = jsRunner(cwd, pkg)
266
+ const runPrefix = run === 'npm' ? 'npm run' : run
267
+ const scripts = pkg.scripts && typeof pkg.scripts === 'object' ? pkg.scripts : {}
268
+ if (scripts.build) cmds.push(`\`${runPrefix} build\``)
269
+ if (scripts.typecheck) cmds.push(`\`${runPrefix} typecheck\``)
270
+ if (scripts.lint) cmds.push(`\`${runPrefix} lint\``)
271
+ if (scripts.test) cmds.push(`\`${run} test\``)
272
+ else if (scripts['test:unit']) cmds.push(`\`${runPrefix} test:unit\``)
273
+ }
274
+ if (exists(join(cwd, 'Package.swift'))) cmds.push('`swift build`', '`swift test`')
275
+ if (exists(join(cwd, 'Cargo.toml'))) cmds.push('`cargo build`', '`cargo test`')
276
+ if (exists(join(cwd, 'go.mod'))) cmds.push('`go build ./...`', '`go test ./...`')
277
+ if (exists(join(cwd, 'pyproject.toml')) || exists(join(cwd, 'requirements.txt')) || exists(join(cwd, 'pytest.ini'))) {
278
+ cmds.push('`python -m pytest`')
279
+ }
280
+ if (!cmds.length) cmds.push('`node --test`')
281
+
282
+ const layout = []
283
+ for (const [dir, desc] of [
284
+ ['apps', 'Application entrypoints and deployable surfaces'],
285
+ ['packages', 'Shared workspace libraries and plugins'],
286
+ ['src', 'Primary source modules'],
287
+ ['test', 'Automated unit and integration test suites'],
288
+ ['docs', 'On-demand architecture and operational reference docs'],
289
+ ]) {
290
+ if (exists(join(cwd, dir))) layout.push([`\`${dir}/\``, desc])
291
+ }
292
+ if (!layout.length) layout.push(['`.`', 'Repository root workspace'])
293
+
294
+ // A route row names only a doc this project has: another project's file names (and engine names) never ride in.
295
+ const routes = [
296
+ ...[
297
+ ['Architecture & context rules', 'docs/architecture.md', 'when changing core boundaries.'],
298
+ ['Architecture & context rules', 'docs/lean-context-architecture.md', 'when changing core boundaries.'],
299
+ ].filter(([, doc]) => exists(join(cwd, doc))).slice(0, 1).map(([scope, doc, when]) => [scope, `Read \`${doc}\` ${when}`]),
300
+ ['Surface & verification guides', 'Read `docs/<topic>.md` when working on a domain with a dedicated runbook in `docs/`.'],
301
+ ]
302
+
303
+ const name = typeof pkg?.name === 'string' && pkg.name ? pkg.name : 'Workspace'
304
+ const desc = typeof pkg?.description === 'string' && pkg.description ? ` — ${pkg.description}` : ' — Lean-context agent routing index.'
305
+ return {
306
+ summary: `**${name}**${desc}`,
307
+ commands: [
308
+ `- **Commands:** ${cmds.join(' · ')}`,
309
+ '- **Tier-1 cache stability:** Keep static instructions concise and byte-stable; move long runbooks to `docs/<topic>.md` and load on demand.',
310
+ '- **Scoped validation:** Keep edits inside the owning module and run targeted tests before broadening.',
311
+ ],
312
+ layout,
313
+ routes,
314
+ }
315
+ }
316
+
317
+ /** The managed routing-index block `/init` (re)writes (< 2.5 KB). `roots`: where installed skills are looked up. */
318
+ export function scaffoldBlock(cwd, roots = skillRootsFor(cwd)) {
319
+ const stack = detectStack(cwd)
320
+ const layoutRows = stack.layout.map(([p, s]) => `| ${p} | ${s} |`).join('\n')
321
+ const routeRows = stack.routes.map(([s, r]) => `| ${s} | ${r} |`).join('\n')
322
+ return [
323
+ BLOCK_START,
324
+ stack.summary,
325
+ '',
326
+ '## Commands & Invariants',
327
+ ...stack.commands,
328
+ '',
329
+ '## Workspace Layout',
330
+ '| Path | Scope |',
331
+ '|---|---|',
332
+ layoutRows,
333
+ '',
334
+ '## Routing Table',
335
+ '| Scope | Trigger Rule |',
336
+ '|---|---|',
337
+ routeRows,
338
+ '',
339
+ '## Gateways & Skill Triggers',
340
+ ...GATEWAY_TRIGGERS,
341
+ ...skillTriggerLine(roots),
342
+ BLOCK_END,
343
+ ].join('\n')
344
+ }
345
+
346
+ export const agentsBlock = scaffoldBlock
347
+
348
+ /**
349
+ * Write or update `AGENTS.md` at `cwd`: absent → create with a title plus the managed block;
350
+ * present → replace an existing managed block in place, or append one at the end.
351
+ * Returns `{path, outcome}` (`created` | `replaced` | `appended` | `unchanged`) for the reply text.
352
+ */
353
+ export function writeAgentsMd(cwd) {
354
+ const path = join(cwd, AGENTS_FILE)
355
+ const block = scaffoldBlock(cwd)
356
+ const prior = exists(path) ? readFileSync(path, 'utf8') : undefined
357
+ if (prior === undefined) {
358
+ writeFileSync(path, `# AGENTS.md\n\n${block}\n`)
359
+ return { path, outcome: 'created' }
360
+ }
361
+ const start = prior.indexOf(BLOCK_START)
362
+ const end = prior.indexOf(BLOCK_END)
363
+ if (start >= 0 && end > start) {
364
+ const next = `${prior.slice(0, start)}${block}${prior.slice(end + BLOCK_END.length)}`
365
+ if (next === prior) return { path, outcome: 'unchanged' }
366
+ writeFileSync(path, next)
367
+ return { path, outcome: 'replaced' }
368
+ }
369
+ writeFileSync(path, `${prior.replace(/\s+$/, '')}\n\n${block}\n`)
370
+ return { path, outcome: 'appended' }
371
+ }
372
+
373
+ /** The `/init` handler: resolves the session workspace, writes the scaffold, reports the outcome. */
374
+ function initHandler(invocation) {
375
+ const cwd = invocation?.agent?.session?.header?.cwd
376
+ if (typeof cwd !== 'string' || cwd.length === 0) {
377
+ return { kind: 'error', text: '/init needs a session workspace — this session has no working directory.' }
378
+ }
379
+ try {
380
+ const outcome = writeAgentsMd(cwd)
381
+ const text = {
382
+ created: `Wrote ${outcome.path} with a lean routing index and trigger table.`,
383
+ replaced: `Updated the managed section of ${outcome.path}.`,
384
+ appended: `Appended a managed routing index section to ${outcome.path} (existing text kept).`,
385
+ unchanged: `${outcome.path} is already up to date.`,
386
+ }[outcome.outcome]
387
+ return { kind: 'success', text }
388
+ } catch (error) {
389
+ return { kind: 'error', text: `/init could not write ${join(cwd, AGENTS_FILE)}: ${error instanceof Error ? error.message : String(error)}` }
390
+ }
391
+ }
392
+
393
+ // ---- hand-maintained: /worktree (B01) ----------------------------------------
394
+ // The engine-side `/worktree`: `ctx.worktrees.create` (dsh-experimental-worktree,
395
+ // mounted as `worktree` with `directory: ".picasso/worktrees"`) branches
396
+ // `picasso/<name>` off HEAD, checks it out under the repo's `.picasso/worktrees/`
397
+ // pool, and republishes the session cwd into it (`workingDirectory.set` inside the
398
+ // service) — the sidebar folder and the Inspector Worktree badge follow on their
399
+ // own. The service keeps partial artifacts on failure (no silent rollback); leaving
400
+ // a worktree is `cd` back — nothing auto-deletes.
401
+
402
+ const WORKTREE_BRANCH_PREFIX = 'picasso/'
403
+
404
+ /**
405
+ * The `request` for `ctx.worktrees.create(agent, request, signal)` from `/worktree [name]`
406
+ * raw input. Picasso's convention names the branch `picasso/<slug>` — the same slug rule the
407
+ * TUI applies (an existing `picasso/` prefix is stripped, runs of non `[a-zA-Z0-9._-]`
408
+ * fold to `-`, edge `-`s trim). An empty or sanitized-away name passes `{}` so the service
409
+ * generates its `worktree-<uuid>` name. The service still validates the result
410
+ * (`check-ref-format`, `.`/`..` segments); its error text reaches the caller verbatim.
411
+ */
412
+ export function worktreeRequest(rawInput) {
413
+ const trimmed = String(rawInput ?? '').trim().replace(/^picasso\//i, '')
414
+ const slug = trimmed.replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '')
415
+ return slug.length === 0 ? {} : { name: `${WORKTREE_BRANCH_PREFIX}${slug}` }
416
+ }
417
+
418
+ /**
419
+ * `/worktree [name]` — creates the branch + checkout through the mounted worktree service
420
+ * and moves the session into it. Success names the checkout path and branch; failures map
421
+ * the service's message verbatim (`{kind:'error'}`), including the retained-artifacts note
422
+ * a partial create carries.
423
+ */
424
+ async function worktreeHandler(ctx, invocation) {
425
+ const worktrees = ctx?.worktrees
426
+ if (worktrees === undefined || worktrees === null || typeof worktrees.create !== 'function') {
427
+ return { kind: 'error', text: '/worktree needs the engine worktree service — this engine does not mount it.' }
428
+ }
429
+ const agent = invocation?.agent
430
+ if (agent === undefined || agent === null) {
431
+ return { kind: 'error', text: '/worktree needs a session — there is no calling agent.' }
432
+ }
433
+ try {
434
+ const created = await worktrees.create(agent, worktreeRequest(invocation.rawInput), invocation.signal)
435
+ return {
436
+ kind: 'success',
437
+ text: `Worktree ${created.branch} created at ${created.path} (base ${created.baseCommit}). `
438
+ + `This session now runs inside it — cd back to ${created.repositoryRoot} to leave; `
439
+ + 'the checkout and branch are kept until you remove them.',
440
+ }
441
+ } catch (error) {
442
+ return { kind: 'error', text: error instanceof Error ? error.message : String(error) }
443
+ }
444
+ }
445
+
446
+ // ---- hand-maintained: /review --fresh | --drift --------------------------------
447
+ // Fresh-context document review (fresh-review.js): reviewer subagents that see only the document
448
+ // and the files it references. Plain `/review` (a code review of workspace changes) is a Picasso
449
+ // surface command; in the engine registry only the document modes run.
450
+
451
+ export const REVIEW_DESCRIPTION = 'Review a document with fresh reviewers that see only it and the files it references.'
452
+
453
+ async function reviewHandler(ctx, invocation) {
454
+ const parsed = parseReviewArgs(invocation?.rawInput)
455
+ if (parsed === undefined) {
456
+ return { kind: 'error', text: 'Use /review --fresh <path> to review a document, or /review --drift <path> to check it against the current source.' }
457
+ }
458
+ if (parsed.error !== undefined) return { kind: 'error', text: parsed.error }
459
+ try {
460
+ return await runFreshReview(ctx, invocation, parsed)
461
+ } catch (error) {
462
+ return { kind: 'error', text: `Review failed: ${error instanceof Error ? error.message : String(error)}` }
463
+ }
464
+ }
465
+
466
+ export function apply(ctx) {
467
+ for (const cmd of COMMANDS) {
468
+ ctx.commands.register({
469
+ name: cmd.name,
470
+ description: cmd.description,
471
+ handler: () => ({
472
+ kind: 'success',
473
+ text: `picasso command '/${cmd.name}' — handled by the Picasso app.`,
474
+ }),
475
+ });
476
+ }
477
+ ctx.commands.register({
478
+ name: 'init',
479
+ description: 'Create or update AGENTS.md in the session workspace (build, test, conventions).',
480
+ handler: initHandler,
481
+ });
482
+ // Real engine-side handler (B01) — not an ack: creates the `picasso/<name>` worktree through
483
+ // `ctx.worktrees` and the service republishes the session's cwd into the checkout.
484
+ ctx.commands.register({
485
+ name: 'worktree',
486
+ description: 'Create or open a git worktree for this session.',
487
+ input: { hint: '[<name>]' },
488
+ handler: (invocation) => worktreeHandler(ctx, invocation),
489
+ });
490
+ // Real engine-side handler: starts the reviewer subagents and returns the merged findings.
491
+ ctx.commands.register({
492
+ name: 'review',
493
+ description: REVIEW_DESCRIPTION,
494
+ input: { hint: '--fresh <path> [--drift]' },
495
+ handler: (invocation) => reviewHandler(ctx, invocation),
496
+ });
497
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@picasso/commands-bridge",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "description": "Phase 2 bridge: advertises picasso slash commands in the dsh runtime command registry (ctx.commands). Handlers acknowledge; execution stays on the picasso surface.",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "scripts": {
9
+ "test": "node --import ../../test/setup/hermetic-preload.mjs --test test/*.test.js"
10
+ },
11
+ "exports": {
12
+ ".": "./index.js",
13
+ "./cordis.patch.yml": "./cordis.patch.yml",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "dsh": {
17
+ "bundle": {
18
+ "patch": "./cordis.patch.yml"
19
+ }
20
+ },
21
+ "files": [
22
+ "index.js",
23
+ "fresh-review.js",
24
+ "cordis.patch.yml",
25
+ "README.md"
26
+ ],
27
+ "license": "UNLICENSED"
28
+ }
@@ -0,0 +1,115 @@
1
+ // A lightweight contradiction check between active always-on rules. No model call: a fixed set of topic detectors
2
+ // (package manager, indentation, quotes, semicolons, test runner, language) plus an exact "always X" / "never X"
3
+ // pair check. It flags; it never decides. The note says the more specific source wins and to ask when unsure.
4
+
5
+ /** @typedef {{ topic: string, values: { value: string, source: string }[], note: string }} Conflict */
6
+
7
+ const TOPICS = [
8
+ {
9
+ topic: 'package manager',
10
+ values: [
11
+ ['pnpm', /\b(?:use|run|with|prefer|always use)\s+`?pnpm\b|\bpnpm (?:install|test|run|add|build)\b/iu],
12
+ ['npm', /\b(?:use|run|with|prefer|always use)\s+`?npm\b|\bnpm (?:install|test|run|ci)\b/iu],
13
+ ['yarn', /\b(?:use|run|with|prefer|always use)\s+`?yarn\b|\byarn (?:install|test|run|add)\b/iu],
14
+ ['bun', /\b(?:use|run|with|prefer|always use)\s+`?bun\b|\bbun (?:install|test|run|add)\b/iu],
15
+ ],
16
+ },
17
+ {
18
+ topic: 'indentation',
19
+ values: [
20
+ ['tabs', /\b(?:indent(?:ation)?\s+(?:with|using)\s+tabs|use tabs\b)/iu],
21
+ ['2 spaces', /\b(?:2|two)[- ]spaces?\b/iu],
22
+ ['4 spaces', /\b(?:4|four)[- ]spaces?\b/iu],
23
+ ],
24
+ },
25
+ {
26
+ topic: 'string quotes',
27
+ values: [
28
+ ['single quotes', /\bsingle quotes?\b/iu],
29
+ ['double quotes', /\bdouble quotes?\b/iu],
30
+ ],
31
+ },
32
+ {
33
+ topic: 'semicolons',
34
+ values: [
35
+ ['no semicolons', /\b(?:no|never use|without|avoid)\s+semicolons\b/iu],
36
+ ['semicolons', /\b(?:always use|use|require|with)\s+semicolons\b/iu],
37
+ ],
38
+ },
39
+ {
40
+ topic: 'test runner',
41
+ values: [
42
+ ['vitest', /\b(?:use|with|tests? (?:use|run with))\s+vitest\b/iu],
43
+ ['jest', /\b(?:use|with|tests? (?:use|run with))\s+jest\b/iu],
44
+ ['mocha', /\b(?:use|with|tests? (?:use|run with))\s+mocha\b/iu],
45
+ ['node:test', /\b(?:use|with)\s+(?:node:test|node --test)\b/iu],
46
+ ],
47
+ },
48
+ ];
49
+
50
+ const ALWAYS_NEVER = /\b(always|never|do not|don't)\s+([a-z][a-z0-9 _-]{3,40}?)(?=[.,;:!\n]|$)/giu;
51
+
52
+ function claimsOf(text) {
53
+ /** @type {Map<string, Set<string>>} */
54
+ const claims = new Map();
55
+ for (const { topic, values } of TOPICS) {
56
+ for (const [value, pattern] of values) {
57
+ if (pattern.test(text)) {
58
+ const set = claims.get(topic) ?? new Set();
59
+ set.add(value);
60
+ claims.set(topic, set);
61
+ }
62
+ }
63
+ }
64
+ return claims;
65
+ }
66
+
67
+ function polarities(text) {
68
+ /** @type {Map<string, 'always' | 'never'>} */
69
+ const map = new Map();
70
+ for (const match of text.matchAll(ALWAYS_NEVER)) {
71
+ const word = (match[1] ?? '').toLowerCase();
72
+ const phrase = (match[2] ?? '').toLowerCase().replace(/\s+/gu, ' ').trim();
73
+ map.set(phrase, word === 'always' ? 'always' : 'never');
74
+ }
75
+ return map;
76
+ }
77
+
78
+ /**
79
+ * Contradictions between always-on sources. Within one source, several values on a topic are not a conflict (a file
80
+ * may mention npm while saying "use pnpm"); only a source that names exactly one value counts as a claim.
81
+ * @param {readonly { path: string, text: string }[]} sources in precedence order (broad -> specific)
82
+ * @returns {Conflict[]}
83
+ */
84
+ export function detectConflicts(sources) {
85
+ /** @type {Conflict[]} */
86
+ const conflicts = [];
87
+ /** @type {Map<string, { value: string, source: string }[]>} */
88
+ const byTopic = new Map();
89
+ for (const source of sources) {
90
+ for (const [topic, values] of claimsOf(source.text)) {
91
+ if (values.size !== 1) continue;
92
+ const [value] = [...values];
93
+ byTopic.set(topic, [...(byTopic.get(topic) ?? []), { value: value ?? '', source: source.path }]);
94
+ }
95
+ }
96
+ for (const [topic, claims] of byTopic) {
97
+ const distinct = [...new Set(claims.map((claim) => claim.value))];
98
+ if (distinct.length < 2) continue;
99
+ conflicts.push({ topic, values: claims, note: `Sources disagree on ${topic} (${distinct.join(' vs ')}). The more specific source wins; ask the user if it matters.` });
100
+ }
101
+ /** @type {Map<string, { value: string, source: string }[]>} */
102
+ const byPhrase = new Map();
103
+ for (const source of sources) {
104
+ for (const [phrase, polarity] of polarities(source.text)) {
105
+ byPhrase.set(phrase, [...(byPhrase.get(phrase) ?? []), { value: polarity, source: source.path }]);
106
+ }
107
+ }
108
+ for (const [phrase, claims] of byPhrase) {
109
+ const distinct = new Set(claims.map((claim) => claim.value));
110
+ const bySource = new Set(claims.map((claim) => claim.source));
111
+ if (distinct.size < 2 || bySource.size < 2) continue;
112
+ conflicts.push({ topic: `"${phrase}"`, values: claims, note: `One source says always "${phrase}", another says never. The more specific source wins; ask the user if it matters.` });
113
+ }
114
+ return conflicts;
115
+ }