@fugood/bricks-ctor 2.25.0-beta.6 → 2.25.0-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compile/__tests__/config-diff.test.js +100 -0
- package/compile/__tests__/index.test.js +461 -0
- package/compile/__tests__/util.test.js +450 -0
- package/compile/action-name-map.ts +64 -0
- package/compile/config-diff.ts +155 -0
- package/compile/index.ts +668 -352
- package/compile/util.ts +134 -10
- package/package.json +7 -3
- package/skills/bricks-ctor/SKILL.md +23 -17
- package/skills/bricks-ctor/{rules → references}/animation.md +3 -2
- package/skills/bricks-ctor/{rules → references}/architecture-patterns.md +19 -0
- package/skills/bricks-ctor/{rules → references}/automations.md +11 -0
- package/skills/bricks-ctor/references/buttress.md +245 -0
- package/skills/bricks-ctor/references/data-calculation.md +252 -0
- package/skills/bricks-ctor/{rules → references}/media-flow.md +7 -0
- package/skills/bricks-ctor/references/simulator.md +132 -0
- package/skills/bricks-ctor/references/source-editing-tools.md +81 -0
- package/skills/bricks-ctor/references/verification-toolchain.md +200 -0
- package/skills/bricks-design/SKILL.md +150 -45
- package/skills/bricks-design/references/architecture-truths.md +132 -0
- package/skills/bricks-design/references/avoiding-complexity.md +91 -0
- package/skills/bricks-design/references/design-critique.md +195 -0
- package/skills/bricks-design/references/design-languages.md +265 -0
- package/skills/bricks-design/references/performance.md +116 -0
- package/skills/bricks-design/references/presentation-and-slideshow.md +137 -0
- package/skills/bricks-design/references/translating-inputs.md +152 -0
- package/skills/bricks-design/references/variations-and-tweaks.md +124 -0
- package/skills/bricks-design/references/when-the-brief-is-branded.md +284 -0
- package/skills/bricks-design/references/when-the-brief-is-vague.md +85 -0
- package/skills/bricks-design/references/workflow.md +134 -0
- package/skills/bricks-ux/SKILL.md +114 -0
- package/skills/bricks-ux/references/accessibility.md +162 -0
- package/skills/bricks-ux/references/flow-states.md +175 -0
- package/skills/bricks-ux/references/interaction-archetypes.md +189 -0
- package/skills/bricks-ux/references/monitoring-screens.md +153 -0
- package/skills/bricks-ux/references/pressable-composition.md +126 -0
- package/skills/bricks-ux/references/user-journey.md +168 -0
- package/skills/bricks-ux/references/ux-critique.md +256 -0
- package/tools/__tests__/_cli-error.test.ts +35 -0
- package/tools/__tests__/_mcp-config.test.ts +67 -0
- package/tools/__tests__/pull.test.ts +108 -0
- package/tools/_cli-error.ts +17 -0
- package/tools/_edits-log.ts +41 -0
- package/tools/_git-author.ts +10 -2
- package/tools/_last-pushed-commit.ts +28 -0
- package/tools/_mcp-config.ts +42 -0
- package/tools/_shell.ts +8 -1
- package/tools/deploy.ts +17 -6
- package/tools/mcp-env.ts +13 -0
- package/tools/mcp-server.ts +8 -0
- package/tools/mcp-tools/__tests__/data-calc-editing.test.js +516 -0
- package/tools/mcp-tools/__tests__/entry-editing.test.js +866 -0
- package/tools/mcp-tools/__tests__/huggingface.test.ts +49 -0
- package/tools/mcp-tools/__tests__/icons.test.ts +21 -0
- package/tools/mcp-tools/__tests__/mcp-env.test.js +19 -0
- package/tools/mcp-tools/_editing-helpers.ts +98 -0
- package/tools/mcp-tools/_verify.ts +50 -0
- package/tools/mcp-tools/compile.ts +21 -9
- package/tools/mcp-tools/data-calc-editing.ts +1311 -0
- package/tools/mcp-tools/entry-editing.ts +2297 -0
- package/tools/mcp-tools/huggingface.ts +23 -13
- package/tools/mcp-tools/icons.ts +23 -7
- package/tools/mcp-tools/media.ts +4 -1
- package/tools/postinstall.ts +95 -38
- package/tools/pull.ts +100 -23
- package/tools/push-config.ts +114 -0
- package/tools/{preview-main.mjs → simulator-main.mjs} +207 -12
- package/tools/simulator-preload.cjs +16 -0
- package/tools/{preview.ts → simulator.ts} +4 -4
- package/types/{animation.ts → animation.d.ts} +24 -8
- package/types/{automation.ts → automation.d.ts} +16 -20
- package/types/{brick-base.ts → brick-base.d.ts} +1 -1
- package/types/bricks/{Camera.ts → Camera.d.ts} +8 -8
- package/types/bricks/{Chart.ts → Chart.d.ts} +4 -4
- package/types/bricks/{GenerativeMedia.ts → GenerativeMedia.d.ts} +15 -15
- package/types/bricks/{Icon.ts → Icon.d.ts} +7 -7
- package/types/bricks/{Image.ts → Image.d.ts} +21 -9
- package/types/bricks/{Items.ts → Items.d.ts} +11 -7
- package/types/bricks/{Lottie.ts → Lottie.d.ts} +10 -10
- package/types/bricks/{Maps.ts → Maps.d.ts} +11 -11
- package/types/bricks/{QrCode.ts → QrCode.d.ts} +7 -7
- package/types/bricks/{Rect.ts → Rect.d.ts} +7 -7
- package/types/bricks/{RichText.ts → RichText.d.ts} +12 -9
- package/types/bricks/{Rive.ts → Rive.d.ts} +9 -9
- package/types/bricks/Scene3D.d.ts +676 -0
- package/types/bricks/{Sketch.ts → Sketch.d.ts} +10 -8
- package/types/bricks/{Slideshow.ts → Slideshow.d.ts} +7 -7
- package/types/bricks/{Svg.ts → Svg.d.ts} +7 -7
- package/types/bricks/{Text.ts → Text.d.ts} +9 -9
- package/types/bricks/{TextInput.ts → TextInput.d.ts} +10 -10
- package/types/bricks/{Video.ts → Video.d.ts} +80 -13
- package/types/bricks/{VideoStreaming.ts → VideoStreaming.d.ts} +10 -10
- package/types/bricks/{WebRtcStream.ts → WebRtcStream.d.ts} +1 -1
- package/types/bricks/{WebView.ts → WebView.d.ts} +4 -4
- package/types/bricks/{index.ts → index.d.ts} +1 -0
- package/types/{common.ts → common.d.ts} +3 -6
- package/types/data-calc-command/base.d.ts +57 -0
- package/types/data-calc-command/collection.d.ts +418 -0
- package/types/data-calc-command/color.d.ts +432 -0
- package/types/data-calc-command/constant.d.ts +50 -0
- package/types/data-calc-command/datetime.d.ts +147 -0
- package/types/data-calc-command/file.d.ts +129 -0
- package/types/data-calc-command/index.d.ts +13 -0
- package/types/data-calc-command/iteratee.d.ts +23 -0
- package/types/data-calc-command/logictype.d.ts +190 -0
- package/types/data-calc-command/math.d.ts +275 -0
- package/types/data-calc-command/object.d.ts +119 -0
- package/types/data-calc-command/sandbox.d.ts +66 -0
- package/types/data-calc-command/string.d.ts +407 -0
- package/types/{data-calc.ts → data-calc.d.ts} +1 -0
- package/types/{data.ts → data.d.ts} +4 -2
- package/types/generators/{Assistant.ts → Assistant.d.ts} +19 -0
- package/types/generators/{HttpServer.ts → HttpServer.d.ts} +56 -2
- package/types/generators/{LlmGgml.ts → LlmGgml.d.ts} +43 -1
- package/types/generators/{LlmMlx.ts → LlmMlx.d.ts} +1 -0
- package/types/generators/{RerankerGgml.ts → RerankerGgml.d.ts} +5 -1
- package/types/generators/{SoundRecorder.ts → SoundRecorder.d.ts} +10 -1
- package/types/generators/{SpeechToTextGgml.ts → SpeechToTextGgml.d.ts} +6 -1
- package/types/generators/{SttAppleBuiltin.ts → SttAppleBuiltin.d.ts} +27 -4
- package/types/generators/{ThermalPrinter.ts → ThermalPrinter.d.ts} +9 -7
- package/types/generators/{Tick.ts → Tick.d.ts} +1 -1
- package/types/generators/{VadGgml.ts → VadGgml.d.ts} +12 -2
- package/types/{subspace.ts → subspace.d.ts} +1 -1
- package/utils/__tests__/calc.test.js +25 -0
- package/utils/__tests__/id.test.js +154 -0
- package/utils/calc.ts +5 -1
- package/utils/data.ts +5 -7
- package/utils/event-props.ts +27 -1
- package/utils/id.ts +109 -56
- package/skills/bricks-ctor/rules/buttress.md +0 -156
- package/skills/bricks-ctor/rules/data-calculation.md +0 -209
- package/skills/bricks-design/LICENSE.txt +0 -180
- package/types/data-calc-command.ts +0 -7005
- /package/skills/bricks-ctor/{rules → references}/local-sync.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/remote-data-bank.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/standby-transition.md +0 -0
- /package/types/{canvas.ts → canvas.d.ts} +0 -0
- /package/types/{data-calc-script.ts → data-calc-script.d.ts} +0 -0
- /package/types/generators/{AlarmClock.ts → AlarmClock.d.ts} +0 -0
- /package/types/generators/{BleCentral.ts → BleCentral.d.ts} +0 -0
- /package/types/generators/{BlePeripheral.ts → BlePeripheral.d.ts} +0 -0
- /package/types/generators/{CanvasMap.ts → CanvasMap.d.ts} +0 -0
- /package/types/generators/{CastlesPay.ts → CastlesPay.d.ts} +0 -0
- /package/types/generators/{DataBank.ts → DataBank.d.ts} +0 -0
- /package/types/generators/{File.ts → File.d.ts} +0 -0
- /package/types/generators/{GraphQl.ts → GraphQl.d.ts} +0 -0
- /package/types/generators/{Http.ts → Http.d.ts} +0 -0
- /package/types/generators/{Information.ts → Information.d.ts} +0 -0
- /package/types/generators/{Intent.ts → Intent.d.ts} +0 -0
- /package/types/generators/{Iterator.ts → Iterator.d.ts} +0 -0
- /package/types/generators/{Keyboard.ts → Keyboard.d.ts} +0 -0
- /package/types/generators/{LlmAnthropicCompat.ts → LlmAnthropicCompat.d.ts} +0 -0
- /package/types/generators/{LlmAppleBuiltin.ts → LlmAppleBuiltin.d.ts} +0 -0
- /package/types/generators/{LlmMediaTekNeuroPilot.ts → LlmMediaTekNeuroPilot.d.ts} +0 -0
- /package/types/generators/{LlmOnnx.ts → LlmOnnx.d.ts} +0 -0
- /package/types/generators/{LlmOpenAiCompat.ts → LlmOpenAiCompat.d.ts} +0 -0
- /package/types/generators/{LlmQualcommAiEngine.ts → LlmQualcommAiEngine.d.ts} +0 -0
- /package/types/generators/{Mcp.ts → Mcp.d.ts} +0 -0
- /package/types/generators/{McpServer.ts → McpServer.d.ts} +0 -0
- /package/types/generators/{MediaFlow.ts → MediaFlow.d.ts} +0 -0
- /package/types/generators/{MqttBroker.ts → MqttBroker.d.ts} +0 -0
- /package/types/generators/{MqttClient.ts → MqttClient.d.ts} +0 -0
- /package/types/generators/{Question.ts → Question.d.ts} +0 -0
- /package/types/generators/{RealtimeTranscription.ts → RealtimeTranscription.d.ts} +0 -0
- /package/types/generators/{SerialPort.ts → SerialPort.d.ts} +0 -0
- /package/types/generators/{SoundPlayer.ts → SoundPlayer.d.ts} +0 -0
- /package/types/generators/{SpeechToTextOnnx.ts → SpeechToTextOnnx.d.ts} +0 -0
- /package/types/generators/{SpeechToTextPlatform.ts → SpeechToTextPlatform.d.ts} +0 -0
- /package/types/generators/{SqLite.ts → SqLite.d.ts} +0 -0
- /package/types/generators/{Step.ts → Step.d.ts} +0 -0
- /package/types/generators/{Tcp.ts → Tcp.d.ts} +0 -0
- /package/types/generators/{TcpServer.ts → TcpServer.d.ts} +0 -0
- /package/types/generators/{TextToSpeechAppleBuiltin.ts → TextToSpeechAppleBuiltin.d.ts} +0 -0
- /package/types/generators/{TextToSpeechGgml.ts → TextToSpeechGgml.d.ts} +0 -0
- /package/types/generators/{TextToSpeechOnnx.ts → TextToSpeechOnnx.d.ts} +0 -0
- /package/types/generators/{TextToSpeechOpenAiLike.ts → TextToSpeechOpenAiLike.d.ts} +0 -0
- /package/types/generators/{Udp.ts → Udp.d.ts} +0 -0
- /package/types/generators/{VadOnnx.ts → VadOnnx.d.ts} +0 -0
- /package/types/generators/{VadTraditional.ts → VadTraditional.d.ts} +0 -0
- /package/types/generators/{VectorStore.ts → VectorStore.d.ts} +0 -0
- /package/types/generators/{Watchdog.ts → Watchdog.d.ts} +0 -0
- /package/types/generators/{WebCrawler.ts → WebCrawler.d.ts} +0 -0
- /package/types/generators/{WebRtc.ts → WebRtc.d.ts} +0 -0
- /package/types/generators/{WebSocket.ts → WebSocket.d.ts} +0 -0
- /package/types/generators/{index.ts → index.d.ts} +0 -0
- /package/types/{index.ts → index.d.ts} +0 -0
- /package/types/{switch.ts → switch.d.ts} +0 -0
- /package/types/{system.ts → system.d.ts} +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# UX Critique
|
|
2
|
+
|
|
3
|
+
Verification proves the flow *runs*. UX critique proves the flow is *usable*. Both are required before declaring done; neither substitutes for the other.
|
|
4
|
+
|
|
5
|
+
UX critique runs in parallel with visual-design critique (`bricks-design/design-critique.md`). A Canvas can fail one and pass the other; both block ship.
|
|
6
|
+
|
|
7
|
+
This file is tiered. The same UX problem (e.g., closure missing) is **CRITICAL** on a payment kiosk and **MEDIUM** on a museum signage loop. Critique fails ship when CRITICAL or HIGH items go unaddressed in their applicable tiers.
|
|
8
|
+
|
|
9
|
+
## How to run the pass
|
|
10
|
+
|
|
11
|
+
1. **Open the journey.** Walk every interaction step-by-step using `user-journey.md` as the spine.
|
|
12
|
+
2. **For each Canvas / Brick group, classify by deployment risk** (table below). The classification determines which tier of checks apply.
|
|
13
|
+
3. **Run the checks in the applicable tier(s).** CRITICAL items always run; HIGH applies broadly; MEDIUM and LOW depend on classification.
|
|
14
|
+
4. **Fix every CRITICAL miss and every HIGH miss.** Surface MEDIUM and LOW misses in the trade-off note if not addressed.
|
|
15
|
+
5. **Re-verify after fixes.** Don't accumulate fix debt.
|
|
16
|
+
|
|
17
|
+
## Risk classification by deployment shape
|
|
18
|
+
|
|
19
|
+
| Deployment shape | Risk profile | Tier weighting |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| Payment / identity capture / safety-critical | CRITICAL-dense — every transact discipline must pass | CRITICAL + HIGH + MEDIUM all apply |
|
|
22
|
+
| Self-service interactive (ordering, check-in, configuration) | HIGH-dense — journey completeness, idle reset, recovery paths | CRITICAL + HIGH apply; MEDIUM where relevant |
|
|
23
|
+
| Monitoring / dashboard / control room | HIGH-dense — alarm hierarchy, stale-data trust, calm/detect/demand | CRITICAL + HIGH apply for alarm states |
|
|
24
|
+
| Browse / wayfinding / menu board | MEDIUM-dense — legibility, comparison clarity, sparse states | HIGH legibility, MEDIUM elsewhere |
|
|
25
|
+
| Glanceable signage / dwell / ambient loop | LOW-dense — main checks are legibility and rhythm | HIGH legibility, LOW elsewhere |
|
|
26
|
+
|
|
27
|
+
## CRITICAL — blocks ship
|
|
28
|
+
|
|
29
|
+
Failure on any of these is sufficient grounds to declare the work mid-iteration.
|
|
30
|
+
|
|
31
|
+
### CR-1. The user-journey spine is whole
|
|
32
|
+
|
|
33
|
+
Every interaction must have all seven steps present (or deliberately compressed; see `user-journey.md` § "When the seven steps compress"). Most-common holes:
|
|
34
|
+
|
|
35
|
+
- **Immediate feedback missing** (step 3). User taps, nothing visible, taps again.
|
|
36
|
+
- **In-flight visibility missing** (step 4). Action triggered, screen frozen, user re-triggers.
|
|
37
|
+
- **Recovery as dead-end** (step 6). Error Canvas with no path forward.
|
|
38
|
+
- **Closure ambiguous or missing** (step 7). Success state transient or unclear.
|
|
39
|
+
|
|
40
|
+
**Must Have:** every interaction has a designed and verified affordance, instruction, feedback, in-flight state, continuation, recovery, closure — or deliberate documented collapse.
|
|
41
|
+
**Anti-Pattern:** journey skipping any step on the assumption "it's fast enough not to need".
|
|
42
|
+
|
|
43
|
+
### CR-2. Transact has its intensification
|
|
44
|
+
|
|
45
|
+
For payment / identity / safety-critical flows, the seven steps must be tightened (`user-journey.md` § "When the seven steps intensify"):
|
|
46
|
+
|
|
47
|
+
- Confirmation step before commit.
|
|
48
|
+
- In-flight visibility non-skippable.
|
|
49
|
+
- Recovery categorised (declined / network / cancelled / timeout).
|
|
50
|
+
- Closure with weight and hold time.
|
|
51
|
+
|
|
52
|
+
**Must Have:** transact closure holds ≥ 5 seconds, success unmistakable, peripheral state visible.
|
|
53
|
+
**Anti-Pattern:** "Process payment in one tap" with no confirmation; closure that auto-advances in < 2s.
|
|
54
|
+
|
|
55
|
+
### CR-3. Monitoring has demand discipline
|
|
56
|
+
|
|
57
|
+
For dashboards / monitor screens with alarm capability:
|
|
58
|
+
|
|
59
|
+
- Calm / detect / demand are three distinct designed states.
|
|
60
|
+
- Demand state stands out unambiguously; not a slight colour change.
|
|
61
|
+
- Multiple concurrent demand states have priority ordering already designed.
|
|
62
|
+
- Stale-data is visibly declared per source.
|
|
63
|
+
- Color is never the only encoding of severity.
|
|
64
|
+
|
|
65
|
+
**Must Have:** alarm-state preview captured and reviewed; squint-test passes (alarm visible from peripheral vision); monochrome preview still distinguishes severity tiers.
|
|
66
|
+
**Anti-Pattern:** alarm styled identically to detect-state; "stale" indicator at 8pt in corner; severity by colour alone.
|
|
67
|
+
|
|
68
|
+
### CR-4. Accessibility floors met for the audience
|
|
69
|
+
|
|
70
|
+
The seven accessibility disciplines (`accessibility.md`) apply at deployment-relative floors. CRITICAL when the audience includes:
|
|
71
|
+
|
|
72
|
+
- Reduced-vision users (contrast, scale, color-not-only).
|
|
73
|
+
- Reduced-motor users (touch targets, no precise gestures, no time-pressure auto-cancels).
|
|
74
|
+
- Sensitive-to-motion users (reduced-motion path available).
|
|
75
|
+
- Multilingual audience (strings via Data; type scale accommodates longest translation).
|
|
76
|
+
|
|
77
|
+
**Must Have:** contrast verified under deployment-actual lighting; touch targets verified with real-finger / real-hardware testing; severity / status encoded by shape + color + label.
|
|
78
|
+
**Anti-Pattern:** WCAG-compliance-on-desktop-monitor as the audit (deployment is sunlit signage at 4m); time-pressure UI on a venue that includes slow / hesitant users.
|
|
79
|
+
|
|
80
|
+
### CR-5. Idle reset is clean
|
|
81
|
+
|
|
82
|
+
For self-service interactive deployments:
|
|
83
|
+
|
|
84
|
+
- Idle timeout exists and is calibrated to the use pattern.
|
|
85
|
+
- Idle reset clears flow state — no half-built order persists; no name on screen; no half-confirmed action.
|
|
86
|
+
- Reset returns to a designed idle / attractor state, not to "whatever Canvas was loaded".
|
|
87
|
+
|
|
88
|
+
**Must Have:** verified idle reset behaviour via Automation or live test; verified that no leaked state persists to next session.
|
|
89
|
+
**Anti-Pattern:** idle = last interact Canvas; idle that requires operator to manually reset.
|
|
90
|
+
|
|
91
|
+
## HIGH — must fix before launch
|
|
92
|
+
|
|
93
|
+
### H-1. Affordance is unambiguous
|
|
94
|
+
|
|
95
|
+
Every pressable Brick declares "press me" visually — contrast, weight, motion, or icon. Affordance vocabulary is consistent across the deployment.
|
|
96
|
+
|
|
97
|
+
**Must Have:** pressable tiles visually distinct from non-pressable; squint test confirms which Bricks are interactive.
|
|
98
|
+
**Anti-Pattern:** identical-looking tiles where some are pressable and some aren't; pressable Bricks with no visual distinction from background.
|
|
99
|
+
|
|
100
|
+
### H-2. Press feedback at registration
|
|
101
|
+
|
|
102
|
+
Every `on_press` produces a visible state change at the moment of registration — scale, opacity, color, or new Brick entry via Standby Transition. Not a fade-in.
|
|
103
|
+
|
|
104
|
+
**Must Have:** Brick under press visibly responds within 100ms (effectively snap, not fade).
|
|
105
|
+
**Anti-Pattern:** press registers, no visible change; press relies on Canvas-change-only feedback (user perceives lag).
|
|
106
|
+
|
|
107
|
+
### H-3. Flow states designed, not skipped
|
|
108
|
+
|
|
109
|
+
Idle / loading / empty / error / boot / maintenance (as applicable to the deployment) are designed states, each with verified preview.
|
|
110
|
+
|
|
111
|
+
**Must Have:** every applicable state's preview captured and reviewed; failure modes per state checked against `flow-states.md`.
|
|
112
|
+
**Anti-Pattern:** "empty state is fine, the list is always populated" without testing the empty case; error state in 8pt corner text; boot = loading spinner.
|
|
113
|
+
|
|
114
|
+
### H-4. Hero continuity across journey Canvases
|
|
115
|
+
|
|
116
|
+
For multi-Canvas flows, hero Bricks share ids across Canvases — chrome (logo, progress indicator, time, back action) carries via Truth #3 auto-tween.
|
|
117
|
+
|
|
118
|
+
**Must Have:** primary chrome elements identifiable in the same screen positions across the flow's Canvases.
|
|
119
|
+
**Anti-Pattern:** every Canvas remounts its full Brick set; user loses spatial mental model between steps.
|
|
120
|
+
|
|
121
|
+
### H-5. Error recovery has a path
|
|
122
|
+
|
|
123
|
+
Every error state offers retry, alternate method, abandon, or help — never a dead-end. Different error categories get distinguishable recovery treatments.
|
|
124
|
+
|
|
125
|
+
**Must Have:** each error path verified end-to-end via Automation or live test.
|
|
126
|
+
**Anti-Pattern:** "Error. Please try again." with no retry mechanism; generic recovery for all error types.
|
|
127
|
+
|
|
128
|
+
### H-6. Stale-data trust
|
|
129
|
+
|
|
130
|
+
For monitoring / live-data screens, every dynamic source has a visibly declared staleness state or a visible "last update" relative-time indicator.
|
|
131
|
+
|
|
132
|
+
**Must Have:** staleness visible in peripheral vision; stale value distinguishable from current value.
|
|
133
|
+
**Anti-Pattern:** dynamic value with no age indication; "last update" in 8pt absolute timestamp.
|
|
134
|
+
|
|
135
|
+
### H-7. Predictable navigation
|
|
136
|
+
|
|
137
|
+
Navigation affordances (back, next, home) sit consistently across Canvases. Idle returns to the same idle Canvas every time.
|
|
138
|
+
|
|
139
|
+
**Must Have:** back / next affordance positions verified across Canvases; idle reset produces identical idle Canvas every time.
|
|
140
|
+
**Anti-Pattern:** back button at top-left on Canvas 2, bottom-right on Canvas 3; idle rotates such that the "anchor" element moves.
|
|
141
|
+
|
|
142
|
+
## MEDIUM — impacts polish; prioritize by user impact
|
|
143
|
+
|
|
144
|
+
### M-1. Instruction matches user mental model
|
|
145
|
+
|
|
146
|
+
Action instructions ("Scan your code", "Tap to start", "Pay now") match the user's likely understanding; jargon avoided; language locale-matched.
|
|
147
|
+
|
|
148
|
+
**Must Have:** wording reviewed for the actual audience; jargon removed.
|
|
149
|
+
**Anti-Pattern:** "Initiate authentication sequence" on a public kiosk; English-only instruction on a multilingual venue.
|
|
150
|
+
|
|
151
|
+
### M-2. Continuation is non-surprising
|
|
152
|
+
|
|
153
|
+
The Canvas the user lands on after an action matches their expectation. Big jumps in journey context happen only with explicit transition.
|
|
154
|
+
|
|
155
|
+
**Must Have:** continuation Canvas reviewed for context preservation; hero continuity in place.
|
|
156
|
+
**Anti-Pattern:** success on Canvas A jumps to Canvas D mid-flow; user loses context.
|
|
157
|
+
|
|
158
|
+
### M-3. Closure proportional to stakes
|
|
159
|
+
|
|
160
|
+
Success closure hold time and visual weight match the action's stakes. Routine completions get brief acknowledgement; transact completions get held visible.
|
|
161
|
+
|
|
162
|
+
**Must Have:** closure hold time tuned to action stakes; auto-advance only after enough time for the user to read.
|
|
163
|
+
**Anti-Pattern:** 1.5s closure for a transact flow; 8s closure for a "saved to favorites" toast.
|
|
164
|
+
|
|
165
|
+
### M-4. Density rhythm in browse / dwell
|
|
166
|
+
|
|
167
|
+
For browse / dwell deployments, content rotation has variation in density / framing / colour rhythm across Canvases or slides. Three identical-rhythm Canvases in a row is a tell. (Cross-reference: `bricks-design/design-critique.md` density-rhythm collapse.)
|
|
168
|
+
|
|
169
|
+
**Must Have:** rhythm variation across the sequence; no three identical-archetype Canvases in a row.
|
|
170
|
+
**Anti-Pattern:** ten Canvases that all read as "headline + bullet list".
|
|
171
|
+
|
|
172
|
+
### M-5. Audio cues calibrated (when hardware allows)
|
|
173
|
+
|
|
174
|
+
If the deployment uses audio, volume / timing / time-of-day awareness is intentional.
|
|
175
|
+
|
|
176
|
+
**Must Have:** audio volume / scheduling reviewed; success / alarm cues distinguishable from ambient.
|
|
177
|
+
**Anti-Pattern:** constant-volume cues regardless of time; audio-only confirmation (no visual pair).
|
|
178
|
+
|
|
179
|
+
### M-6. Reduced-motion path available (if relevant)
|
|
180
|
+
|
|
181
|
+
For deployments in clinical / safety / motion-sensitive contexts, a reduced-motion path exists.
|
|
182
|
+
|
|
183
|
+
**Must Have:** `reduceMotion` Data flag wired where applicable; verified reduced-motion preview.
|
|
184
|
+
**Anti-Pattern:** continuous-motion design with no reduction path for a clinical deployment.
|
|
185
|
+
|
|
186
|
+
## LOW — context-dependent
|
|
187
|
+
|
|
188
|
+
### L-1. Polish on idle / attractor presence
|
|
189
|
+
|
|
190
|
+
For deployments where idle dominates: idle is *inviting*, not just *running*.
|
|
191
|
+
|
|
192
|
+
**Must Have for high-traffic public deployments:** attractor sequence engages from peripheral vision.
|
|
193
|
+
**Anti-Pattern:** logo-only idle on a deployment whose purpose is to invite interaction.
|
|
194
|
+
|
|
195
|
+
### L-2. Maintenance state designed
|
|
196
|
+
|
|
197
|
+
If the deployment has scheduled downtime, a maintenance Canvas exists and distinguishes itself from error.
|
|
198
|
+
|
|
199
|
+
**Must Have for deployments with maintenance windows:** maintenance Canvas with return path.
|
|
200
|
+
**Anti-Pattern:** maintenance = black screen.
|
|
201
|
+
|
|
202
|
+
### L-3. Empty-state composition
|
|
203
|
+
|
|
204
|
+
Empty states explain the absence and suggest what populates.
|
|
205
|
+
|
|
206
|
+
**Must Have:** empty state designed rather than collapsed-whitespace.
|
|
207
|
+
**Anti-Pattern:** "—" or blank where content would be.
|
|
208
|
+
|
|
209
|
+
## Tier-by-tier checklist (running order)
|
|
210
|
+
|
|
211
|
+
Use this when running the pass:
|
|
212
|
+
|
|
213
|
+
**CRITICAL (always run):**
|
|
214
|
+
|
|
215
|
+
- [ ] User-journey spine whole (CR-1)
|
|
216
|
+
- [ ] Transact intensified if applicable (CR-2)
|
|
217
|
+
- [ ] Monitoring demand discipline if applicable (CR-3)
|
|
218
|
+
- [ ] Accessibility floors met (CR-4)
|
|
219
|
+
- [ ] Idle reset clean if applicable (CR-5)
|
|
220
|
+
|
|
221
|
+
**HIGH (always run except for glance / dwell loops):**
|
|
222
|
+
|
|
223
|
+
- [ ] Affordance unambiguous (H-1)
|
|
224
|
+
- [ ] Press feedback at registration (H-2)
|
|
225
|
+
- [ ] Flow states designed (H-3)
|
|
226
|
+
- [ ] Hero continuity across Canvases (H-4)
|
|
227
|
+
- [ ] Error recovery has a path (H-5)
|
|
228
|
+
- [ ] Stale-data trust if applicable (H-6)
|
|
229
|
+
- [ ] Predictable navigation (H-7)
|
|
230
|
+
|
|
231
|
+
**MEDIUM (run for interact / transact / browse):**
|
|
232
|
+
|
|
233
|
+
- [ ] Instruction matches mental model (M-1)
|
|
234
|
+
- [ ] Continuation non-surprising (M-2)
|
|
235
|
+
- [ ] Closure proportional (M-3)
|
|
236
|
+
- [ ] Density rhythm (M-4)
|
|
237
|
+
- [ ] Audio cues calibrated (M-5)
|
|
238
|
+
- [ ] Reduced-motion path (M-6)
|
|
239
|
+
|
|
240
|
+
**LOW (run for public-facing / high-dwell):**
|
|
241
|
+
|
|
242
|
+
- [ ] Idle / attractor polish (L-1)
|
|
243
|
+
- [ ] Maintenance state (L-2)
|
|
244
|
+
- [ ] Empty-state composition (L-3)
|
|
245
|
+
|
|
246
|
+
## Definition of UX done
|
|
247
|
+
|
|
248
|
+
A flow is UX-done when:
|
|
249
|
+
|
|
250
|
+
1. The CRITICAL tier passes — zero unaddressed CRITICAL items.
|
|
251
|
+
2. The HIGH tier passes — zero unaddressed HIGH items (or surfaced as accepted trade-off with rationale).
|
|
252
|
+
3. Applicable MEDIUM / LOW items either pass or are surfaced.
|
|
253
|
+
4. Every state (golden path + error categories + idle + empty if relevant) has been verified via preview screenshot or Automation, and reviewed.
|
|
254
|
+
5. Accessibility floors are met at the deployment-relative threshold, not at a desktop default.
|
|
255
|
+
|
|
256
|
+
If any item is unmet, the work is mid-iteration. Say so explicitly to the user; offer a precise list of what remains.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { extractCliErrorMessage } from '../_cli-error'
|
|
2
|
+
|
|
3
|
+
// bricks-project's tsconfig has no @types/jest, so declare the globals this test
|
|
4
|
+
// uses (mirrors tools/mcp-tools/__tests__/huggingface.test.ts).
|
|
5
|
+
declare const describe: (name: string, fn: () => void) => void
|
|
6
|
+
declare const it: (name: string, fn: () => void) => void
|
|
7
|
+
declare const expect: (actual: unknown) => { toBe: (expected: unknown) => void }
|
|
8
|
+
|
|
9
|
+
describe('extractCliErrorMessage', () => {
|
|
10
|
+
// Regression: the tools used to build this message inside the same try that
|
|
11
|
+
// wrapped JSON.parse, so the throw was caught by its own catch and replaced
|
|
12
|
+
// with the raw JSON blob. The human-readable message must survive.
|
|
13
|
+
it('extracts error.message from a JSON error body', () => {
|
|
14
|
+
const output = JSON.stringify({ error: { message: 'Conflict: config was modified' } })
|
|
15
|
+
expect(extractCliErrorMessage(output, 'Update failed')).toBe('Conflict: config was modified')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('extracts a string error from a JSON error body', () => {
|
|
19
|
+
expect(extractCliErrorMessage('{"error":"Boom"}', 'Pull failed')).toBe('Boom')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('returns the raw output when it is not JSON', () => {
|
|
23
|
+
expect(extractCliErrorMessage('plain text failure', 'Release failed')).toBe(
|
|
24
|
+
'plain text failure',
|
|
25
|
+
)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('falls back to the raw output when the JSON has no error field', () => {
|
|
29
|
+
expect(extractCliErrorMessage('{"ok":true}', 'Update failed')).toBe('{"ok":true}')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('falls back to the generic message when output is empty', () => {
|
|
33
|
+
expect(extractCliErrorMessage('', 'Update failed')).toBe('Update failed')
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { mkdtemp, readFile, writeFile, rm } from 'fs/promises'
|
|
2
|
+
import { tmpdir } from 'os'
|
|
3
|
+
import * as path from 'path'
|
|
4
|
+
import { handleMcpConfigOverride } from '../_mcp-config'
|
|
5
|
+
|
|
6
|
+
// bricks-project's tsconfig has no @types/jest, so declare the globals this test uses
|
|
7
|
+
// (mirrors tools/__tests__/_cli-error.test.ts).
|
|
8
|
+
declare const describe: (name: string, fn: () => void) => void
|
|
9
|
+
declare const it: (name: string, fn: () => void | Promise<void>) => void
|
|
10
|
+
declare const expect: (actual: unknown) => {
|
|
11
|
+
toBe: (expected: unknown) => void
|
|
12
|
+
toEqual: (expected: unknown) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const projectMcpServer = { command: 'bun', args: ['mcp-server.ts'] }
|
|
16
|
+
|
|
17
|
+
const withTempMcp = async (contents: string | null, fn: (p: string) => Promise<void>) => {
|
|
18
|
+
const dir = await mkdtemp(path.join(tmpdir(), 'bf-mcp-'))
|
|
19
|
+
const mcpPath = path.join(dir, '.mcp.json')
|
|
20
|
+
if (contents !== null) await writeFile(mcpPath, contents)
|
|
21
|
+
try {
|
|
22
|
+
await fn(mcpPath)
|
|
23
|
+
} finally {
|
|
24
|
+
await rm(dir, { recursive: true, force: true })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('handleMcpConfigOverride', () => {
|
|
29
|
+
it('injects bricks-ctor while preserving the user other servers', async () => {
|
|
30
|
+
await withTempMcp(
|
|
31
|
+
JSON.stringify({ mcpServers: { smartbear: { command: 'npx' } } }),
|
|
32
|
+
async (p) => {
|
|
33
|
+
await handleMcpConfigOverride(p, projectMcpServer)
|
|
34
|
+
const result = JSON.parse(await readFile(p, 'utf-8'))
|
|
35
|
+
expect(result.mcpServers.smartbear).toEqual({ command: 'npx' })
|
|
36
|
+
expect(result.mcpServers['bricks-ctor']).toEqual(projectMcpServer)
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('does not clobber a malformed .mcp.json (regression: user servers were wiped)', async () => {
|
|
42
|
+
// trailing comma -> JSON.parse throws; the whole file used to be overwritten with the
|
|
43
|
+
// default, silently deleting every other configured server.
|
|
44
|
+
const malformed = '{ "mcpServers": { "smartbear": { "command": "npx" }, } }'
|
|
45
|
+
await withTempMcp(malformed, async (p) => {
|
|
46
|
+
await handleMcpConfigOverride(p, projectMcpServer)
|
|
47
|
+
expect(await readFile(p, 'utf-8')).toBe(malformed)
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('backfills mcpServers when missing without dropping other top-level keys', async () => {
|
|
52
|
+
await withTempMcp(JSON.stringify({ otherKey: 'keep-me' }), async (p) => {
|
|
53
|
+
await handleMcpConfigOverride(p, projectMcpServer)
|
|
54
|
+
const result = JSON.parse(await readFile(p, 'utf-8'))
|
|
55
|
+
expect(result.otherKey).toBe('keep-me')
|
|
56
|
+
expect(result.mcpServers['bricks-ctor']).toEqual(projectMcpServer)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('writes a default config when no .mcp.json exists', async () => {
|
|
61
|
+
await withTempMcp(null, async (p) => {
|
|
62
|
+
await handleMcpConfigOverride(p, projectMcpServer)
|
|
63
|
+
const result = JSON.parse(await readFile(p, 'utf-8'))
|
|
64
|
+
expect(result.mcpServers['bricks-ctor']).toEqual(projectMcpServer)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { execFile as execFileCallback } from 'node:child_process'
|
|
2
|
+
import { chmod, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { join, resolve } from 'node:path'
|
|
5
|
+
import { promisify } from 'node:util'
|
|
6
|
+
|
|
7
|
+
// bricks-project's tsconfig has no @types/jest, so declare the globals this test uses
|
|
8
|
+
// (mirrors tools/__tests__/_mcp-config.test.ts).
|
|
9
|
+
declare const describe: (name: string, fn: () => void) => void
|
|
10
|
+
declare const it: (name: string, fn: () => void | Promise<void>, timeout?: number) => void
|
|
11
|
+
declare const expect: (actual: unknown) => {
|
|
12
|
+
toBe: (expected: unknown) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const execFile = promisify(execFileCallback)
|
|
16
|
+
|
|
17
|
+
async function run(cmd: string, args: string[], cwd: string, env?: NodeJS.ProcessEnv) {
|
|
18
|
+
return execFile(cmd, args, {
|
|
19
|
+
cwd,
|
|
20
|
+
env: { ...process.env, ...env },
|
|
21
|
+
maxBuffer: 1024 * 1024,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function initGitProject(projectDir: string) {
|
|
26
|
+
await run('git', ['init', '--initial-branch=master'], projectDir)
|
|
27
|
+
await run('git', ['config', 'user.email', 'test@example.com'], projectDir)
|
|
28
|
+
await run('git', ['config', 'user.name', 'Test User'], projectDir)
|
|
29
|
+
await writeFile(join(projectDir, 'application.json'), JSON.stringify({ id: 'app-1' }))
|
|
30
|
+
await run('git', ['add', '.'], projectDir)
|
|
31
|
+
await run('git', ['commit', '-m', 'init'], projectDir)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function writeFakeBricks(binDir: string) {
|
|
35
|
+
const payload = {
|
|
36
|
+
files: [
|
|
37
|
+
{
|
|
38
|
+
name: 'subspaces/subspace-13/data-calc/data-calculation-0.sandbox.js',
|
|
39
|
+
input: 'export const value = 1\n',
|
|
40
|
+
formatable: false,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
lastCommitId: 'server-commit',
|
|
44
|
+
}
|
|
45
|
+
const bricksPath = join(binDir, 'bricks')
|
|
46
|
+
await writeFile(
|
|
47
|
+
bricksPath,
|
|
48
|
+
`#!/usr/bin/env node\nprocess.stdout.write(${JSON.stringify(JSON.stringify(payload))})\n`,
|
|
49
|
+
)
|
|
50
|
+
await chmod(bricksPath, 0o755)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe('pull.ts', () => {
|
|
54
|
+
it('creates parent directories before writing pulled project files', async () => {
|
|
55
|
+
const root = await mkdtemp(join(tmpdir(), 'bricks-project-pull-'))
|
|
56
|
+
const projectDir = join(root, 'project')
|
|
57
|
+
const binDir = join(root, 'bin')
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
await mkdir(projectDir)
|
|
61
|
+
await mkdir(binDir)
|
|
62
|
+
await initGitProject(projectDir)
|
|
63
|
+
await writeFakeBricks(binDir)
|
|
64
|
+
|
|
65
|
+
const pullScript = resolve(__dirname, '../pull.ts')
|
|
66
|
+
await run('bun', [pullScript, '--force'], projectDir, {
|
|
67
|
+
PATH: `${binDir}:${process.env.PATH || ''}`,
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const pulledFile = join(
|
|
71
|
+
projectDir,
|
|
72
|
+
'subspaces/subspace-13/data-calc/data-calculation-0.sandbox.js',
|
|
73
|
+
)
|
|
74
|
+
expect(await readFile(pulledFile, 'utf8')).toBe('export const value = 1\n')
|
|
75
|
+
} finally {
|
|
76
|
+
await rm(root, { recursive: true, force: true })
|
|
77
|
+
}
|
|
78
|
+
}, 30000)
|
|
79
|
+
|
|
80
|
+
it('merges pulled project files back into the starting branch', async () => {
|
|
81
|
+
const root = await mkdtemp(join(tmpdir(), 'bricks-project-pull-'))
|
|
82
|
+
const projectDir = join(root, 'project')
|
|
83
|
+
const binDir = join(root, 'bin')
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
await mkdir(projectDir)
|
|
87
|
+
await mkdir(binDir)
|
|
88
|
+
await initGitProject(projectDir)
|
|
89
|
+
await writeFakeBricks(binDir)
|
|
90
|
+
|
|
91
|
+
const pullScript = resolve(__dirname, '../pull.ts')
|
|
92
|
+
await run('bun', [pullScript], projectDir, {
|
|
93
|
+
PATH: `${binDir}:${process.env.PATH || ''}`,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const { stdout: branch } = await run('git', ['branch', '--show-current'], projectDir)
|
|
97
|
+
const pulledFile = join(
|
|
98
|
+
projectDir,
|
|
99
|
+
'subspaces/subspace-13/data-calc/data-calculation-0.sandbox.js',
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
expect(branch.trim()).toBe('master')
|
|
103
|
+
expect(await readFile(pulledFile, 'utf8')).toBe('export const value = 1\n')
|
|
104
|
+
} finally {
|
|
105
|
+
await rm(root, { recursive: true, force: true })
|
|
106
|
+
}
|
|
107
|
+
}, 30000)
|
|
108
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Extract a human-readable message from a `bricks ... --json` failure payload.
|
|
2
|
+
//
|
|
3
|
+
// On failure the CLI prints `{ "error": { "message": "..." } }` (or the older
|
|
4
|
+
// `{ "error": "..." }`) to stdout/stderr. Earlier call sites built that message
|
|
5
|
+
// inside the same `try` that wrapped `JSON.parse`, so the `throw` was caught by
|
|
6
|
+
// its own `catch` and replaced with the raw JSON blob — the human-readable
|
|
7
|
+
// message never surfaced. Parsing here, outside any throw, avoids that trap.
|
|
8
|
+
export function extractCliErrorMessage(output: string, fallback: string): string {
|
|
9
|
+
try {
|
|
10
|
+
const { error } = JSON.parse(output)
|
|
11
|
+
const message = error?.message ?? error
|
|
12
|
+
if (typeof message === 'string' && message) return message
|
|
13
|
+
} catch {
|
|
14
|
+
// output is not JSON — fall through to the raw output below
|
|
15
|
+
}
|
|
16
|
+
return output || fallback
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
const auditLogIgnoreEntry = '.bricks/edits.jsonl'
|
|
5
|
+
|
|
6
|
+
// Ensure the project's .gitignore excludes the audit log. No-op when it is already
|
|
7
|
+
// ignored directly or via a broader `.bricks` rule.
|
|
8
|
+
const ensureAuditLogIgnored = async (projectDir: string) => {
|
|
9
|
+
const gitignorePath = path.join(projectDir, '.gitignore')
|
|
10
|
+
const content = await readFile(gitignorePath, 'utf8').catch((err: any) => {
|
|
11
|
+
if (err?.code === 'ENOENT') return ''
|
|
12
|
+
throw err
|
|
13
|
+
})
|
|
14
|
+
const ignored = content
|
|
15
|
+
.split(/\r?\n/)
|
|
16
|
+
.map((line) => line.trim())
|
|
17
|
+
.some((line) => line === auditLogIgnoreEntry || line === '.bricks/' || line === '.bricks')
|
|
18
|
+
if (ignored) return
|
|
19
|
+
|
|
20
|
+
const prefix = content && !content.endsWith('\n') ? '\n' : ''
|
|
21
|
+
await writeFile(
|
|
22
|
+
gitignorePath,
|
|
23
|
+
`${content}${prefix}\n# MCP entry-editing audit log\n${auditLogIgnoreEntry}\n`,
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Append one JSON record to `.bricks/edits.jsonl`, creating the directory and the
|
|
28
|
+
// gitignore entry as needed. Shared by the source-editing tools and `compile()` so
|
|
29
|
+
// every project mutation lands in the same audit log.
|
|
30
|
+
export const appendEditRecord = async (projectDir: string, record: Record<string, unknown>) => {
|
|
31
|
+
const bricksDir = path.join(projectDir, '.bricks')
|
|
32
|
+
await mkdir(bricksDir, { recursive: true })
|
|
33
|
+
await ensureAuditLogIgnored(projectDir)
|
|
34
|
+
await appendFile(path.join(bricksDir, 'edits.jsonl'), `${JSON.stringify(record)}\n`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Provenance stamped on every audit record: which agent/session produced the change.
|
|
38
|
+
export const editProvenance = () => ({
|
|
39
|
+
session: process.env.BRICKS_CTOR_SESSION_ID || process.env.CODEX_SESSION_ID,
|
|
40
|
+
agent: process.env.BRICKS_CTOR_AGENT_ID || process.env.USER,
|
|
41
|
+
})
|
package/tools/_git-author.ts
CHANGED
|
@@ -15,7 +15,15 @@ async function hasGitIdentity(cwd: string): Promise<boolean> {
|
|
|
15
15
|
// If no identity is configured (typical for non-tech users), CTOR becomes the
|
|
16
16
|
// main author via per-command `-c user.name/-c user.email` overrides so the
|
|
17
17
|
// user's git config is left untouched.
|
|
18
|
-
|
|
18
|
+
//
|
|
19
|
+
// `extraFlags` are inserted between `commit` and the `-m` args (e.g.
|
|
20
|
+
// `['--no-verify']` to bypass pre-commit hooks for controlled cases like
|
|
21
|
+
// committing merge-conflict markers).
|
|
22
|
+
export async function buildCommitArgs(
|
|
23
|
+
cwd: string,
|
|
24
|
+
messages: string[],
|
|
25
|
+
extraFlags: string[] = [],
|
|
26
|
+
): Promise<string[]> {
|
|
19
27
|
const hasIdentity = await hasGitIdentity(cwd)
|
|
20
28
|
const prefix = hasIdentity
|
|
21
29
|
? []
|
|
@@ -23,7 +31,7 @@ export async function buildCommitArgs(cwd: string, messages: string[]): Promise<
|
|
|
23
31
|
const msgArgs: string[] = []
|
|
24
32
|
for (const m of messages) msgArgs.push('-m', m)
|
|
25
33
|
if (hasIdentity) msgArgs.push('-m', CTOR_COAUTHOR_TRAILER)
|
|
26
|
-
return [...prefix, 'commit', ...msgArgs]
|
|
34
|
+
return [...prefix, 'commit', ...extraFlags, ...msgArgs]
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
export { CTOR_NAME, CTOR_EMAIL, CTOR_COAUTHOR_TRAILER }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
|
|
3
|
+
// Local sync marker: the git commit hash that was on HEAD when we last
|
|
4
|
+
// successfully pushed to the server (deploy or push-config) or pulled
|
|
5
|
+
// from it. Stored at the `.bricks/` top level (gitignored explicitly) — it's
|
|
6
|
+
// per-clone state, not a build artifact, so it doesn't belong under
|
|
7
|
+
// `.bricks/build/`.
|
|
8
|
+
//
|
|
9
|
+
// Why this exists: server's `bricks_project_last_commit_id` can be an opaque
|
|
10
|
+
// nanoid for content-only edits (config-editor saves), so it isn't a
|
|
11
|
+
// reliable git anchor for `git checkout` during pull. The local marker is
|
|
12
|
+
// always a real reachable commit hash from THIS clone.
|
|
13
|
+
const REL_PATH = '.bricks/.last-pushed-commit'
|
|
14
|
+
|
|
15
|
+
export async function readLastPushedCommit(cwd: string): Promise<string | null> {
|
|
16
|
+
try {
|
|
17
|
+
const content = await readFile(`${cwd}/${REL_PATH}`, 'utf8')
|
|
18
|
+
return content.trim() || null
|
|
19
|
+
} catch {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function writeLastPushedCommit(cwd: string, commitId: string): Promise<void> {
|
|
25
|
+
if (!commitId) return
|
|
26
|
+
await mkdir(`${cwd}/.bricks`, { recursive: true })
|
|
27
|
+
await writeFile(`${cwd}/${REL_PATH}`, commitId)
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFile, writeFile, stat } from 'fs/promises'
|
|
2
|
+
|
|
3
|
+
const exists = async (f: string) => {
|
|
4
|
+
try {
|
|
5
|
+
await stat(f)
|
|
6
|
+
return true
|
|
7
|
+
} catch {
|
|
8
|
+
return false
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Refresh the `bricks-ctor` entry in a project's `.mcp.json` while preserving every other MCP
|
|
13
|
+
// server the user configured. A malformed `.mcp.json` is left untouched (with a warning)
|
|
14
|
+
// rather than overwritten with the default — clobbering it would silently delete the user's
|
|
15
|
+
// other server entries. This mirrors `setupClaudeAutoMode`'s handling of a malformed
|
|
16
|
+
// `settings.local.json` in postinstall.ts.
|
|
17
|
+
export const handleMcpConfigOverride = async (mcpConfigPath: string, projectMcpServer: object) => {
|
|
18
|
+
let mcpConfig: { mcpServers: Record<string, unknown> }
|
|
19
|
+
if (await exists(mcpConfigPath)) {
|
|
20
|
+
let parsed: unknown
|
|
21
|
+
try {
|
|
22
|
+
parsed = JSON.parse(await readFile(mcpConfigPath, 'utf-8'))
|
|
23
|
+
} catch {
|
|
24
|
+
console.warn(`Skipping .mcp.json update; ${mcpConfigPath} is not valid JSON`)
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
mcpConfig =
|
|
28
|
+
parsed && typeof parsed === 'object'
|
|
29
|
+
? (parsed as { mcpServers: Record<string, unknown> })
|
|
30
|
+
: { mcpServers: {} }
|
|
31
|
+
if (!mcpConfig.mcpServers || typeof mcpConfig.mcpServers !== 'object') {
|
|
32
|
+
mcpConfig.mcpServers = {}
|
|
33
|
+
}
|
|
34
|
+
mcpConfig.mcpServers['bricks-ctor'] = projectMcpServer
|
|
35
|
+
delete mcpConfig.mcpServers['bricks-project']
|
|
36
|
+
} else {
|
|
37
|
+
mcpConfig = { mcpServers: { 'bricks-ctor': projectMcpServer } }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await writeFile(mcpConfigPath, `${JSON.stringify(mcpConfig, null, 2)}\n`)
|
|
41
|
+
console.log(`Updated ${mcpConfigPath}`)
|
|
42
|
+
}
|
package/tools/_shell.ts
CHANGED
|
@@ -29,6 +29,7 @@ class Sh implements PromiseLike<ShResult> {
|
|
|
29
29
|
private _cwd: string | undefined
|
|
30
30
|
private _mode: Mode = 'default'
|
|
31
31
|
private _throw = true
|
|
32
|
+
private _env: NodeJS.ProcessEnv | undefined
|
|
32
33
|
private _promise: Promise<ShResult> | null = null
|
|
33
34
|
|
|
34
35
|
constructor(private readonly args: string[]) {}
|
|
@@ -48,6 +49,11 @@ class Sh implements PromiseLike<ShResult> {
|
|
|
48
49
|
return this
|
|
49
50
|
}
|
|
50
51
|
|
|
52
|
+
env(extra: NodeJS.ProcessEnv): this {
|
|
53
|
+
this._env = { ...this._env, ...extra }
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
async text(): Promise<string> {
|
|
52
58
|
// If no explicit quiet was requested, capture stdout/stderr without
|
|
53
59
|
// forwarding them to the parent's streams (matches Bun's `.text()`).
|
|
@@ -79,7 +85,8 @@ class Sh implements PromiseLike<ShResult> {
|
|
|
79
85
|
? ['ignore', 'pipe', 'pipe']
|
|
80
86
|
: ['inherit', 'pipe', 'pipe']
|
|
81
87
|
|
|
82
|
-
const
|
|
88
|
+
const env = this._env ? { ...process.env, ...this._env } : undefined
|
|
89
|
+
const proc = spawn(cmd, rest, { cwd: this._cwd, stdio, env })
|
|
83
90
|
|
|
84
91
|
const outChunks: Buffer[] = []
|
|
85
92
|
const errChunks: Buffer[] = []
|