@monoes/monomindcli 2.16.1 → 2.16.2

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 (214) hide show
  1. package/.claude/helpers/handlers/edit-handler.cjs +14 -12
  2. package/.claude/helpers/handlers/route-handler.cjs +6 -0
  3. package/.claude/helpers/monograph-freshen.cjs +31 -113
  4. package/.claude/helpers/utils/monograph-resolve.cjs +497 -0
  5. package/.claude/helpers/utils/monograph.cjs +8 -51
  6. package/README.md +1 -1
  7. package/dist/src/commands/doctor-hook-monograph-checks.d.ts +8 -0
  8. package/dist/src/commands/doctor-hook-monograph-checks.d.ts.map +1 -0
  9. package/dist/src/commands/doctor-hook-monograph-checks.js +79 -0
  10. package/dist/src/commands/doctor-hook-monograph-checks.js.map +1 -0
  11. package/dist/src/commands/doctor.d.ts.map +1 -1
  12. package/dist/src/commands/doctor.js +4 -1
  13. package/dist/src/commands/doctor.js.map +1 -1
  14. package/dist/src/commands/monograph.d.ts.map +1 -1
  15. package/dist/src/commands/monograph.js +16 -1
  16. package/dist/src/commands/monograph.js.map +1 -1
  17. package/dist/src/orgrt/bash-timeout.d.ts +14 -0
  18. package/dist/src/orgrt/bash-timeout.d.ts.map +1 -0
  19. package/dist/src/orgrt/bash-timeout.js +18 -0
  20. package/dist/src/orgrt/bash-timeout.js.map +1 -0
  21. package/dist/src/orgrt/block-recheck.d.ts +30 -0
  22. package/dist/src/orgrt/block-recheck.d.ts.map +1 -0
  23. package/dist/src/orgrt/block-recheck.js +81 -0
  24. package/dist/src/orgrt/block-recheck.js.map +1 -0
  25. package/dist/src/orgrt/completion-gate.d.ts +4 -0
  26. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  27. package/dist/src/orgrt/completion-gate.js +22 -2
  28. package/dist/src/orgrt/completion-gate.js.map +1 -1
  29. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  30. package/dist/src/orgrt/daemon.js +6 -4
  31. package/dist/src/orgrt/daemon.js.map +1 -1
  32. package/dist/src/orgrt/decisions.d.ts +1 -1
  33. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  34. package/dist/src/orgrt/decisions.js +14 -6
  35. package/dist/src/orgrt/decisions.js.map +1 -1
  36. package/dist/src/orgrt/mailbox.d.ts +14 -0
  37. package/dist/src/orgrt/mailbox.d.ts.map +1 -1
  38. package/dist/src/orgrt/mailbox.js +31 -1
  39. package/dist/src/orgrt/mailbox.js.map +1 -1
  40. package/dist/src/orgrt/sandbox-fault.d.ts +16 -6
  41. package/dist/src/orgrt/sandbox-fault.d.ts.map +1 -1
  42. package/dist/src/orgrt/sandbox-fault.js +78 -33
  43. package/dist/src/orgrt/sandbox-fault.js.map +1 -1
  44. package/dist/src/orgrt/session.d.ts +4 -3
  45. package/dist/src/orgrt/session.d.ts.map +1 -1
  46. package/dist/src/orgrt/session.js +24 -13
  47. package/dist/src/orgrt/session.js.map +1 -1
  48. package/dist/src/orgrt/task-dag.d.ts +8 -2
  49. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  50. package/dist/src/orgrt/task-dag.js +10 -4
  51. package/dist/src/orgrt/task-dag.js.map +1 -1
  52. package/dist/src/orgrt/types.d.ts +11 -0
  53. package/dist/src/orgrt/types.d.ts.map +1 -1
  54. package/dist/src/orgrt/types.js +18 -0
  55. package/dist/src/orgrt/types.js.map +1 -1
  56. package/dist/src/utils/resource-governor.d.ts.map +1 -1
  57. package/dist/src/utils/resource-governor.js +35 -2
  58. package/dist/src/utils/resource-governor.js.map +1 -1
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +6 -6
  61. package/.claude/skills/monodesign/SKILL.md +0 -257
  62. package/.claude/skills/monodesign/adapt.md +0 -53
  63. package/.claude/skills/monodesign/agents/monodesign-asset-producer.md +0 -100
  64. package/.claude/skills/monodesign/agents/monodesign-manual-edit-applier.md +0 -103
  65. package/.claude/skills/monodesign/animate.md +0 -65
  66. package/.claude/skills/monodesign/audit.md +0 -89
  67. package/.claude/skills/monodesign/bolder.md +0 -50
  68. package/.claude/skills/monodesign/clarify.md +0 -64
  69. package/.claude/skills/monodesign/colorize.md +0 -68
  70. package/.claude/skills/monodesign/craft.md +0 -51
  71. package/.claude/skills/monodesign/critique.md +0 -66
  72. package/.claude/skills/monodesign/delight.md +0 -47
  73. package/.claude/skills/monodesign/distill.md +0 -56
  74. package/.claude/skills/monodesign/document.md +0 -83
  75. package/.claude/skills/monodesign/extract.md +0 -74
  76. package/.claude/skills/monodesign/harden.md +0 -65
  77. package/.claude/skills/monodesign/init.md +0 -30
  78. package/.claude/skills/monodesign/layout.md +0 -36
  79. package/.claude/skills/monodesign/live.md +0 -34
  80. package/.claude/skills/monodesign/onboard.md +0 -50
  81. package/.claude/skills/monodesign/optimize.md +0 -64
  82. package/.claude/skills/monodesign/overdrive.md +0 -56
  83. package/.claude/skills/monodesign/polish.md +0 -68
  84. package/.claude/skills/monodesign/quieter.md +0 -57
  85. package/.claude/skills/monodesign/reference/adapt.md +0 -312
  86. package/.claude/skills/monodesign/reference/adapt.native.md +0 -58
  87. package/.claude/skills/monodesign/reference/android.md +0 -40
  88. package/.claude/skills/monodesign/reference/animate.md +0 -203
  89. package/.claude/skills/monodesign/reference/antipatterns-catalog.md +0 -410
  90. package/.claude/skills/monodesign/reference/audit.md +0 -135
  91. package/.claude/skills/monodesign/reference/audit.native.md +0 -139
  92. package/.claude/skills/monodesign/reference/bolder.md +0 -120
  93. package/.claude/skills/monodesign/reference/brand-workflow.md +0 -180
  94. package/.claude/skills/monodesign/reference/brand.md +0 -108
  95. package/.claude/skills/monodesign/reference/clarify.md +0 -288
  96. package/.claude/skills/monodesign/reference/codex.md +0 -105
  97. package/.claude/skills/monodesign/reference/cognitive-load.md +0 -106
  98. package/.claude/skills/monodesign/reference/color-and-contrast.md +0 -105
  99. package/.claude/skills/monodesign/reference/colorize.md +0 -257
  100. package/.claude/skills/monodesign/reference/component-specs.md +0 -260
  101. package/.claude/skills/monodesign/reference/component-states.md +0 -274
  102. package/.claude/skills/monodesign/reference/component-system.md +0 -358
  103. package/.claude/skills/monodesign/reference/copy-formulas.md +0 -160
  104. package/.claude/skills/monodesign/reference/craft.md +0 -123
  105. package/.claude/skills/monodesign/reference/critique.md +0 -780
  106. package/.claude/skills/monodesign/reference/delight.md +0 -302
  107. package/.claude/skills/monodesign/reference/design-principles.md +0 -246
  108. package/.claude/skills/monodesign/reference/distill.md +0 -111
  109. package/.claude/skills/monodesign/reference/document.md +0 -429
  110. package/.claude/skills/monodesign/reference/extract.md +0 -69
  111. package/.claude/skills/monodesign/reference/harden.md +0 -347
  112. package/.claude/skills/monodesign/reference/heuristics-scoring.md +0 -234
  113. package/.claude/skills/monodesign/reference/hooks.md +0 -92
  114. package/.claude/skills/monodesign/reference/image-prompts.md +0 -130
  115. package/.claude/skills/monodesign/reference/init.md +0 -221
  116. package/.claude/skills/monodesign/reference/interaction-design.md +0 -189
  117. package/.claude/skills/monodesign/reference/ios.md +0 -45
  118. package/.claude/skills/monodesign/reference/layout.md +0 -185
  119. package/.claude/skills/monodesign/reference/live.md +0 -710
  120. package/.claude/skills/monodesign/reference/motion-design.md +0 -109
  121. package/.claude/skills/monodesign/reference/onboard.md +0 -234
  122. package/.claude/skills/monodesign/reference/optimize.md +0 -258
  123. package/.claude/skills/monodesign/reference/overdrive.md +0 -130
  124. package/.claude/skills/monodesign/reference/personas.md +0 -179
  125. package/.claude/skills/monodesign/reference/polish.md +0 -241
  126. package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +0 -108
  127. package/.claude/skills/monodesign/reference/product.md +0 -60
  128. package/.claude/skills/monodesign/reference/quieter.md +0 -99
  129. package/.claude/skills/monodesign/reference/responsive-design.md +0 -114
  130. package/.claude/skills/monodesign/reference/shape.md +0 -165
  131. package/.claude/skills/monodesign/reference/spatial-design.md +0 -100
  132. package/.claude/skills/monodesign/reference/teach.md +0 -10
  133. package/.claude/skills/monodesign/reference/token-architecture.md +0 -222
  134. package/.claude/skills/monodesign/reference/typeset.md +0 -301
  135. package/.claude/skills/monodesign/reference/typography.md +0 -159
  136. package/.claude/skills/monodesign/reference/ux-research.md +0 -143
  137. package/.claude/skills/monodesign/reference/ux-rules.md +0 -211
  138. package/.claude/skills/monodesign/reference/ux-writing.md +0 -107
  139. package/.claude/skills/monodesign/scripts/command-metadata.json +0 -94
  140. package/.claude/skills/monodesign/scripts/context-signals.mjs +0 -260
  141. package/.claude/skills/monodesign/scripts/context.mjs +0 -1065
  142. package/.claude/skills/monodesign/scripts/critique-storage.mjs +0 -416
  143. package/.claude/skills/monodesign/scripts/detect-csp.mjs +0 -193
  144. package/.claude/skills/monodesign/scripts/detect.mjs +0 -33
  145. package/.claude/skills/monodesign/scripts/detector/browser/injected/index.mjs +0 -1960
  146. package/.claude/skills/monodesign/scripts/detector/cli/main.mjs +0 -321
  147. package/.claude/skills/monodesign/scripts/detector/design-system.mjs +0 -814
  148. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +0 -5628
  149. package/.claude/skills/monodesign/scripts/detector/detect-antipatterns.mjs +0 -50
  150. package/.claude/skills/monodesign/scripts/detector/engines/browser/detect-url.mjs +0 -259
  151. package/.claude/skills/monodesign/scripts/detector/engines/browser/drivers.mjs +0 -339
  152. package/.claude/skills/monodesign/scripts/detector/engines/regex/detect-text.mjs +0 -636
  153. package/.claude/skills/monodesign/scripts/detector/engines/static-html/css-cascade.mjs +0 -1016
  154. package/.claude/skills/monodesign/scripts/detector/engines/static-html/detect-html.mjs +0 -253
  155. package/.claude/skills/monodesign/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -198
  156. package/.claude/skills/monodesign/scripts/detector/findings.mjs +0 -12
  157. package/.claude/skills/monodesign/scripts/detector/fix/css-regions.mjs +0 -181
  158. package/.claude/skills/monodesign/scripts/detector/fix/fixers.mjs +0 -373
  159. package/.claude/skills/monodesign/scripts/detector/fix/index.mjs +0 -426
  160. package/.claude/skills/monodesign/scripts/detector/node/file-system.mjs +0 -198
  161. package/.claude/skills/monodesign/scripts/detector/profile/profiler.mjs +0 -166
  162. package/.claude/skills/monodesign/scripts/detector/registry/antipatterns.mjs +0 -563
  163. package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +0 -3024
  164. package/.claude/skills/monodesign/scripts/detector/shared/color.mjs +0 -124
  165. package/.claude/skills/monodesign/scripts/detector/shared/constants.mjs +0 -101
  166. package/.claude/skills/monodesign/scripts/detector/shared/fonts.mjs +0 -30
  167. package/.claude/skills/monodesign/scripts/detector/shared/inline-ignores.mjs +0 -148
  168. package/.claude/skills/monodesign/scripts/detector/shared/page.mjs +0 -7
  169. package/.claude/skills/monodesign/scripts/hook-admin.mjs +0 -694
  170. package/.claude/skills/monodesign/scripts/hook-before-edit.mjs +0 -516
  171. package/.claude/skills/monodesign/scripts/hook-lib.mjs +0 -1785
  172. package/.claude/skills/monodesign/scripts/hook.mjs +0 -61
  173. package/.claude/skills/monodesign/scripts/lib/design-parser.mjs +0 -809
  174. package/.claude/skills/monodesign/scripts/lib/is-generated.mjs +0 -69
  175. package/.claude/skills/monodesign/scripts/lib/monodesign-config.mjs +0 -640
  176. package/.claude/skills/monodesign/scripts/lib/monodesign-paths.mjs +0 -129
  177. package/.claude/skills/monodesign/scripts/lib/provider.mjs +0 -4
  178. package/.claude/skills/monodesign/scripts/lib/target-args.mjs +0 -42
  179. package/.claude/skills/monodesign/scripts/live/browser-script-parts.mjs +0 -50
  180. package/.claude/skills/monodesign/scripts/live/completion.mjs +0 -19
  181. package/.claude/skills/monodesign/scripts/live/event-validation.mjs +0 -137
  182. package/.claude/skills/monodesign/scripts/live/insert-ui.mjs +0 -458
  183. package/.claude/skills/monodesign/scripts/live/manual-apply.mjs +0 -939
  184. package/.claude/skills/monodesign/scripts/live/manual-edit-routes.mjs +0 -357
  185. package/.claude/skills/monodesign/scripts/live/manual-edits-buffer.mjs +0 -152
  186. package/.claude/skills/monodesign/scripts/live/session-store.mjs +0 -293
  187. package/.claude/skills/monodesign/scripts/live/svelte-component.mjs +0 -826
  188. package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +0 -279
  189. package/.claude/skills/monodesign/scripts/live/ui-core.mjs +0 -180
  190. package/.claude/skills/monodesign/scripts/live/vocabulary.mjs +0 -36
  191. package/.claude/skills/monodesign/scripts/live-accept.mjs +0 -812
  192. package/.claude/skills/monodesign/scripts/live-browser-dom.js +0 -147
  193. package/.claude/skills/monodesign/scripts/live-browser-session.js +0 -124
  194. package/.claude/skills/monodesign/scripts/live-browser.js +0 -11213
  195. package/.claude/skills/monodesign/scripts/live-commit-manual-edits.mjs +0 -1241
  196. package/.claude/skills/monodesign/scripts/live-complete.mjs +0 -75
  197. package/.claude/skills/monodesign/scripts/live-copy-edit-agent.mjs +0 -683
  198. package/.claude/skills/monodesign/scripts/live-discard-manual-edits.mjs +0 -51
  199. package/.claude/skills/monodesign/scripts/live-inject.mjs +0 -596
  200. package/.claude/skills/monodesign/scripts/live-insert.mjs +0 -272
  201. package/.claude/skills/monodesign/scripts/live-manual-edit-evidence.mjs +0 -363
  202. package/.claude/skills/monodesign/scripts/live-poll.mjs +0 -384
  203. package/.claude/skills/monodesign/scripts/live-resume.mjs +0 -94
  204. package/.claude/skills/monodesign/scripts/live-server.mjs +0 -1210
  205. package/.claude/skills/monodesign/scripts/live-status.mjs +0 -61
  206. package/.claude/skills/monodesign/scripts/live-target.mjs +0 -30
  207. package/.claude/skills/monodesign/scripts/live-wrap.mjs +0 -884
  208. package/.claude/skills/monodesign/scripts/live.mjs +0 -297
  209. package/.claude/skills/monodesign/scripts/modern-screenshot.umd.js +0 -14
  210. package/.claude/skills/monodesign/scripts/palette.mjs +0 -635
  211. package/.claude/skills/monodesign/scripts/pin.mjs +0 -221
  212. package/.claude/skills/monodesign/shape.md +0 -71
  213. package/.claude/skills/monodesign/teach.md +0 -18
  214. package/.claude/skills/monodesign/typeset.md +0 -59
@@ -1,260 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Context-signals gatherer for the bare Monodesign invocation
4
- * (no-argument) path. Collects cheap, deterministic signals about the current
5
- * project and emits them as JSON.
6
- *
7
- * It does NOT score or rank. The agent reasons over the raw signals using its
8
- * knowledge of the command catalog (see SKILL.md routing rule 1). Deliberately
9
- * light: no LLM calls, no detector run (`monomind design detect` is heavier and
10
- * opt-in), no file writes. Every probe is best-effort and never throws; the
11
- * output is always valid JSON.
12
- *
13
- * Signals:
14
- * - setup: PRODUCT.md / DESIGN.md presence, register, whether code exists
15
- * - critique: the latest cached critique score (.monodesign/critique)
16
- * - git: branch + files changed vs the default branch (a scope hint)
17
- * - devServer: whether a local dev server answers on a common port (gates live)
18
- */
19
- import fs from 'node:fs';
20
- import net from 'node:net';
21
- import path from 'node:path';
22
- import { fileURLToPath } from 'node:url';
23
- import { execFileSync } from 'node:child_process';
24
- import { loadContext, extractRegister, extractPlatform } from './context.mjs';
25
- import { getCritiqueDir } from './lib/monodesign-paths.mjs';
26
- import { readTrend, extractIssueLines, trendDirection } from './critique-storage.mjs';
27
-
28
- /** Is there code here at all, or just context files / an empty repo? */
29
- function hasCode(cwd) {
30
- if (fs.existsSync(path.join(cwd, 'package.json'))) return true;
31
- for (const d of ['src', 'app', 'pages', 'site', 'public', 'components', 'lib']) {
32
- if (fs.existsSync(path.join(cwd, d))) return true;
33
- }
34
- return false;
35
- }
36
-
37
- /**
38
- * The most recent critique snapshot across all targets. Filenames are
39
- * timestamp-prefixed (`<iso>__<slug>.md`), so a lexical sort is chronological.
40
- * Parses the small frontmatter for score + P0/P1 counts, plus two "design
41
- * health" extras: the score trend for the same slug (last 3 runs, with a
42
- * direction) and the open [P0] issue titles from the snapshot body — enough
43
- * for a session to start design-health-aware without an LLM pass.
44
- */
45
- function latestCritique(cwd) {
46
- try {
47
- const dir = getCritiqueDir(cwd);
48
- if (!fs.existsSync(dir)) return null;
49
- const files = fs.readdirSync(dir).filter((f) => f.endsWith('.md')).sort();
50
- if (!files.length) return null;
51
- const newest = files[files.length - 1];
52
- const text = fs.readFileSync(path.join(dir, newest), 'utf-8');
53
- const front = text.split('---')[1] || '';
54
- const get = (k) => {
55
- const m = front.match(new RegExp(`^${k}:\\s*(.+)$`, 'm'));
56
- return m ? m[1].trim() : null;
57
- };
58
- const num = (v) => {
59
- const n = Number(v);
60
- return Number.isFinite(n) ? n : null;
61
- };
62
- const slug = get('slug');
63
- // Trend across the last 3 runs for the same slug. Frontmatter written by
64
- // critique-storage carries `total_score`; older/hand-written snapshots may
65
- // carry `score` — accept either. Best-effort: never let this probe throw.
66
- let trend = null;
67
- try {
68
- if (slug) {
69
- const rows = readTrend(slug, { limit: 3, cwd });
70
- const scores = rows
71
- .map((r) => num(r.total_score ?? r.score))
72
- .filter((n) => n !== null);
73
- if (scores.length) trend = { scores, direction: trendDirection(scores) };
74
- }
75
- } catch { /* trend stays null */ }
76
- let openP0 = [];
77
- try {
78
- openP0 = extractIssueLines(text).p0;
79
- } catch { /* openP0 stays empty */ }
80
- // Frontmatter key fallbacks: context fixtures use score/p0/p1, the
81
- // critique flow's MONODESIGN_CRITIQUE_META uses total_score/p0_count/
82
- // p1_count. `get` returns null for missing keys; keep null (not 0).
83
- const numKey = (...keys) => {
84
- for (const k of keys) {
85
- const v = get(k);
86
- if (v !== null) return num(v);
87
- }
88
- return null;
89
- };
90
- return {
91
- slug,
92
- score: numKey('score', 'total_score'),
93
- p0: numKey('p0', 'p0_count'),
94
- p1: numKey('p1', 'p1_count'),
95
- timestamp: get('timestamp'),
96
- file: path.relative(cwd, path.join(dir, newest)).split(path.sep).join('/'),
97
- trend,
98
- openP0,
99
- };
100
- } catch {
101
- return null;
102
- }
103
- }
104
-
105
- /** Branch + a scope hint: files changed vs the default branch, else working tree. */
106
- function gitSignals(cwd) {
107
- const run = (args, { trim = true } = {}) => {
108
- try {
109
- const out = execFileSync('git', args, {
110
- cwd,
111
- encoding: 'utf-8',
112
- stdio: ['ignore', 'pipe', 'ignore'],
113
- });
114
- return trim ? out.trim() : out;
115
- } catch {
116
- return null;
117
- }
118
- };
119
- if (run(['rev-parse', '--is-inside-work-tree']) !== 'true') {
120
- return { isRepo: false, branch: null, base: null, changedFiles: [], changedCount: 0 };
121
- }
122
- const branch = run(['rev-parse', '--abbrev-ref', 'HEAD']);
123
- let base = null;
124
- for (const b of ['main', 'master']) {
125
- if (run(['rev-parse', '--verify', '--quiet', b]) !== null) {
126
- base = b;
127
- break;
128
- }
129
- }
130
- const diffBase = base && branch && branch !== base ? base : null;
131
- const fromDiff = diffBase ? run(['diff', '--name-only', `${diffBase}...HEAD`]) : null;
132
- // porcelain lines are `XY PATH`: a 2-char status + a space, then the path.
133
- // Don't trim the combined output — an unstaged-modified line starts with a
134
- // leading space (` M path`), and a global trim would eat the first line's
135
- // status column and shift the slice. Renames render as `old -> new`.
136
- const fromStatus = run(['-c', 'core.quotepath=false', 'status', '--porcelain'], { trim: false });
137
- let changed = [];
138
- if (fromDiff) {
139
- changed = fromDiff.split('\n').filter(Boolean);
140
- } else if (fromStatus) {
141
- changed = fromStatus.split(/\r?\n/).filter(Boolean).map((l) => {
142
- const p = l.slice(3);
143
- const arrow = p.indexOf(' -> ');
144
- return arrow === -1 ? p : p.slice(arrow + 4);
145
- });
146
- }
147
- return {
148
- isRepo: true,
149
- branch,
150
- base: diffBase,
151
- changedFiles: changed.slice(0, 50),
152
- changedCount: changed.length,
153
- };
154
- }
155
-
156
- const COMMON_DEV_PORTS = [4321, 3000, 5173, 5174, 8080, 8000, 4200];
157
-
158
- function probePort(port, timeout = 250) {
159
- return new Promise((resolve) => {
160
- const sock = new net.Socket();
161
- let settled = false;
162
- const finish = (ok) => {
163
- if (settled) return;
164
- settled = true;
165
- try { sock.destroy(); } catch { /* ignore */ }
166
- resolve(ok);
167
- };
168
- sock.setTimeout(timeout);
169
- sock.once('connect', () => finish(true));
170
- sock.once('timeout', () => finish(false));
171
- sock.once('error', () => finish(false));
172
- sock.connect(port, '127.0.0.1');
173
- });
174
- }
175
-
176
- async function devServerSignals() {
177
- const open = [];
178
- await Promise.all(
179
- COMMON_DEV_PORTS.map(async (p) => {
180
- if (await probePort(p)) open.push(p);
181
- }),
182
- );
183
- open.sort((a, b) => a - b);
184
- return { running: open.length > 0, ports: open };
185
- }
186
-
187
- // Extensions the detector scans (mirrors the engine's walkDir set + HTML).
188
- const SCANNABLE_EXT = new Set([
189
- '.html', '.htm', '.css', '.scss',
190
- '.jsx', '.tsx', '.js', '.ts', '.vue', '.svelte', '.astro',
191
- ]);
192
- // Where UI source typically lives. The detector walks these and skips
193
- // node_modules / dist / build / .next / .nuxt automatically.
194
- const SOURCE_DIRS = ['src', 'app', 'components', 'pages', 'public'];
195
-
196
- /**
197
- * Local paths the agent should point the bundled detector at — never a URL.
198
- * A URL means a costly Puppeteer browser render, and a probed dev-server port
199
- * may not even belong to this project. An HTML *file* or a source tree is
200
- * scanned by the cheap, jsdom-free static engine. This script does NOT run the
201
- * detector; it just surfaces the target(s) so the agent can run
202
- * `node <scripts>/detect.mjs --json <targets>` and fold the hits in.
203
- */
204
- function scanTargets(cwd, git) {
205
- // 1. Dirty tree wins: scan exactly the markup/style files in flight. It's
206
- // what the user is working on, it's a small set, and it's local.
207
- if (git.isRepo && git.changedFiles.length) {
208
- const changed = git.changedFiles
209
- .filter((f) => SCANNABLE_EXT.has(path.extname(f).toLowerCase()))
210
- .filter((f) => fs.existsSync(path.join(cwd, f)));
211
- if (changed.length) return { targets: changed.slice(0, 50), via: 'git-changes' };
212
- }
213
- // 2. Otherwise scan the local source dirs that exist.
214
- const dirs = SOURCE_DIRS.filter((d) => fs.existsSync(path.join(cwd, d)));
215
- if (dirs.length) return { targets: dirs, via: 'source-dir' };
216
- // 3. A root HTML entry, or the project root as a last resort when there's
217
- // code but no conventional source dir (walkDir still skips heavy dirs).
218
- if (fs.existsSync(path.join(cwd, 'index.html'))) return { targets: ['index.html'], via: 'html' };
219
- if (hasCode(cwd)) return { targets: ['.'], via: 'root' };
220
- return { targets: [], via: null };
221
- }
222
-
223
- export async function gatherSignals(cwd = process.cwd()) {
224
- const ctx = loadContext(cwd);
225
- const git = gitSignals(cwd);
226
- return {
227
- setup: {
228
- hasProduct: ctx.hasProduct,
229
- productPath: ctx.productPath,
230
- hasDesign: ctx.hasDesign,
231
- designPath: ctx.designPath,
232
- hasCode: hasCode(cwd),
233
- register: extractRegister(ctx.product),
234
- platform: extractPlatform(ctx.product),
235
- },
236
- critique: { latest: latestCritique(cwd) },
237
- git,
238
- devServer: await devServerSignals(),
239
- scan: scanTargets(cwd, git),
240
- };
241
- }
242
-
243
- async function cli() {
244
- const signals = await gatherSignals(process.cwd());
245
- process.stdout.write(`${JSON.stringify(signals, null, 2)}\n`);
246
- }
247
-
248
- function invokedAsScript() {
249
- const arg = process.argv[1];
250
- if (!arg) return false;
251
- try {
252
- return fs.realpathSync(arg) === fs.realpathSync(fileURLToPath(import.meta.url));
253
- } catch {
254
- return false;
255
- }
256
- }
257
-
258
- if (invokedAsScript()) {
259
- cli();
260
- }