@fugood/bricks-project 2.25.0-beta.41 → 2.25.0-beta.43
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/config-diff.ts +108 -0
- package/compile/index.ts +23 -1
- package/package.json +6 -2
- package/package.json.bak +6 -2
- package/skills/bricks-ctor/SKILL.md +2 -0
- package/skills/bricks-ctor/references/architecture-patterns.md +6 -0
- package/skills/bricks-ctor/references/source-editing-tools.md +81 -0
- package/skills/bricks-design/SKILL.md +14 -24
- package/skills/bricks-ux/SKILL.md +14 -20
- package/tools/mcp-env.ts +13 -0
- package/tools/mcp-server.ts +8 -0
- package/tools/mcp-tools/_verify.ts +45 -0
- package/tools/mcp-tools/compile.ts +2 -0
- package/tools/mcp-tools/data-calc-editing.ts +1425 -0
- package/tools/mcp-tools/entry-editing.ts +2398 -0
- package/tools/postinstall.ts +80 -3
- package/utils/data.ts +3 -5
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
// The compiled config artifact written by `bun compile` (see the generated
|
|
5
|
+
// project's `compile.ts`; bricks-project-generator/index.js:762).
|
|
6
|
+
export const BUILD_CONFIG_RELATIVE = '.bricks/build/application-config.json'
|
|
7
|
+
|
|
8
|
+
// `compile()` derives these top-level fields from `Date.now()`
|
|
9
|
+
// (compile/index.ts `title: \`${app.name}(${timestamp})\`` and `update_timestamp`),
|
|
10
|
+
// so they differ on every run regardless of source. Excluded from the comparison —
|
|
11
|
+
// only the *top-level* keys are dropped, so nested subspace/brick `title`s still diff.
|
|
12
|
+
const VOLATILE_TOP_LEVEL_FIELDS = ['title', 'update_timestamp']
|
|
13
|
+
|
|
14
|
+
// A minimal, path-keyed config change (Option A): a generic patch, not coupled to
|
|
15
|
+
// bricks-config-editor's action vocabulary. `path` is an array of object keys /
|
|
16
|
+
// array indices, ready for the editor's `setYValueAtPath` (or a delete) so applying
|
|
17
|
+
// the patch is a single Yjs `'local'` transaction == one undo/redo entry.
|
|
18
|
+
export type ConfigPatchOp =
|
|
19
|
+
| { op: 'set'; path: Array<string | number>; value: unknown }
|
|
20
|
+
| { op: 'unset'; path: Array<string | number> }
|
|
21
|
+
|
|
22
|
+
export type ConfigChange =
|
|
23
|
+
| { status: 'ok'; ops: ConfigPatchOp[]; opCount: number }
|
|
24
|
+
| { status: 'no_baseline' }
|
|
25
|
+
| { status: 'unavailable' }
|
|
26
|
+
|
|
27
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
28
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
29
|
+
|
|
30
|
+
const deepEqual = (a: unknown, b: unknown): boolean => {
|
|
31
|
+
if (a === b) return true
|
|
32
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
33
|
+
return a.length === b.length && a.every((item, index) => deepEqual(item, b[index]))
|
|
34
|
+
}
|
|
35
|
+
if (isRecord(a) && isRecord(b)) {
|
|
36
|
+
const aKeys = Object.keys(a)
|
|
37
|
+
return (
|
|
38
|
+
aKeys.length === Object.keys(b).length &&
|
|
39
|
+
aKeys.every((key) => key in b && deepEqual(a[key], b[key]))
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const normalizeConfig = (config: unknown) => {
|
|
46
|
+
if (!isRecord(config)) return config
|
|
47
|
+
const normalized = { ...config }
|
|
48
|
+
for (const field of VOLATILE_TOP_LEVEL_FIELDS) delete normalized[field]
|
|
49
|
+
return normalized
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Objects recurse key-wise; equal-length arrays recurse element-wise; everything else
|
|
53
|
+
// (scalars, type changes, length-changed arrays) emits one whole-value `set` at that
|
|
54
|
+
// path. The editor's `applyJsonDiffToYType` minimizes the actual Yjs ops downstream,
|
|
55
|
+
// so a whole-array `set` on insert/remove still yields a minimal CRDT mutation.
|
|
56
|
+
const diffInto = (
|
|
57
|
+
before: unknown,
|
|
58
|
+
after: unknown,
|
|
59
|
+
currentPath: Array<string | number>,
|
|
60
|
+
ops: ConfigPatchOp[],
|
|
61
|
+
) => {
|
|
62
|
+
if (deepEqual(before, after)) return
|
|
63
|
+
|
|
64
|
+
if (isRecord(before) && isRecord(after)) {
|
|
65
|
+
const keys = new Set([...Object.keys(before), ...Object.keys(after)])
|
|
66
|
+
for (const key of keys) {
|
|
67
|
+
const nextPath = [...currentPath, key]
|
|
68
|
+
if (!(key in after)) ops.push({ op: 'unset', path: nextPath })
|
|
69
|
+
else if (!(key in before)) ops.push({ op: 'set', path: nextPath, value: after[key] })
|
|
70
|
+
else diffInto(before[key], after[key], nextPath, ops)
|
|
71
|
+
}
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (Array.isArray(before) && Array.isArray(after) && before.length === after.length) {
|
|
76
|
+
for (let index = 0; index < after.length; index += 1) {
|
|
77
|
+
diffInto(before[index], after[index], [...currentPath, index], ops)
|
|
78
|
+
}
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ops.push({ op: 'set', path: currentPath, value: after })
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Diff two compiled configs. `before == null` means there was no prior build to compare
|
|
86
|
+
// (first compile); `after == null` means the fresh artifact could not be read.
|
|
87
|
+
export const computeConfigChange = (before: unknown, after: unknown): ConfigChange => {
|
|
88
|
+
if (before == null) return { status: 'no_baseline' }
|
|
89
|
+
if (after == null) return { status: 'unavailable' }
|
|
90
|
+
const ops: ConfigPatchOp[] = []
|
|
91
|
+
diffInto(normalizeConfig(before), normalizeConfig(after), [], ops)
|
|
92
|
+
return { status: 'ok', ops, opCount: ops.length }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Read the last-compiled config artifact. Returns null when it is absent or unreadable.
|
|
96
|
+
export const readBuildConfig = async (projectDir: string): Promise<unknown> => {
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(await readFile(path.join(projectDir, BUILD_CONFIG_RELATIVE), 'utf8'))
|
|
99
|
+
} catch {
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const summarizeConfigChange = (change: ConfigChange): string => {
|
|
105
|
+
if (change.status === 'no_baseline') return 'config change: no prior build to compare'
|
|
106
|
+
if (change.status === 'unavailable') return 'config change: build artifact unavailable'
|
|
107
|
+
return change.opCount === 0 ? 'config change: none' : `config change: ${change.opCount} op(s)`
|
|
108
|
+
}
|
package/compile/index.ts
CHANGED
|
@@ -8,8 +8,10 @@ import type { ExportNamedDeclaration, FunctionDeclaration } from 'acorn'
|
|
|
8
8
|
import escodegen from 'escodegen'
|
|
9
9
|
import { makeId } from '../utils/id'
|
|
10
10
|
import { generateCalulationMap } from './util'
|
|
11
|
+
import { computeConfigChange, readBuildConfig, summarizeConfigChange } from './config-diff'
|
|
11
12
|
import { templateActionNameMap } from './action-name-map'
|
|
12
13
|
import { templateEventPropsMap } from '../utils/event-props'
|
|
14
|
+
import { sh } from '../tools/_shell'
|
|
13
15
|
import type {
|
|
14
16
|
Application,
|
|
15
17
|
Data,
|
|
@@ -700,8 +702,25 @@ const compileAutomation = (automationMap: AutomationMap) =>
|
|
|
700
702
|
}),
|
|
701
703
|
)
|
|
702
704
|
|
|
705
|
+
// Print the minimal config delta vs the previous `bun compile` artifact (volatile
|
|
706
|
+
// timestamp fields excluded). Silent when there is no prior build to compare, so
|
|
707
|
+
// direct compile() callers (tests, tooling outside a project) emit nothing.
|
|
708
|
+
const reportConfigChange = (previousConfig: unknown, config: unknown) => {
|
|
709
|
+
if (previousConfig == null) return
|
|
710
|
+
// The baseline was parsed from JSON; round-trip the fresh config the same way so
|
|
711
|
+
// keys holding undefined (dropped by the artifact's JSON.stringify) don't diff
|
|
712
|
+
// as phantom sets.
|
|
713
|
+
const change = computeConfigChange(previousConfig, JSON.parse(JSON.stringify(config)))
|
|
714
|
+
if (change.status !== 'ok') return
|
|
715
|
+
console.log(summarizeConfigChange(change))
|
|
716
|
+
if (change.opCount > 0) console.log(JSON.stringify(change.ops, null, 2))
|
|
717
|
+
}
|
|
718
|
+
|
|
703
719
|
export const compile = async (app: Application) => {
|
|
704
720
|
await new Promise((resolve) => setImmediate(resolve, 0))
|
|
721
|
+
// Snapshot the previous build artifact before the caller's compile.ts overwrites it,
|
|
722
|
+
// so the config change introduced by this compile can be reported on return.
|
|
723
|
+
const previousConfig = await readBuildConfig(process.cwd())
|
|
705
724
|
const timestamp = Date.now()
|
|
706
725
|
// Pre-index subspace ids so the canvas-item validation below stays O(1).
|
|
707
726
|
const subspaceIdSet = new Set(app.subspaces.map((s) => s.id))
|
|
@@ -1456,12 +1475,15 @@ export const compile = async (app: Application) => {
|
|
|
1456
1475
|
automation_map: compiledAutomationMap || app.metadata?.TEMP_automation_map || {},
|
|
1457
1476
|
update_timestamp: timestamp,
|
|
1458
1477
|
}
|
|
1478
|
+
reportConfigChange(previousConfig, config)
|
|
1459
1479
|
return config
|
|
1460
1480
|
}
|
|
1461
1481
|
|
|
1462
1482
|
export const checkConfig = async (configPath: string) => {
|
|
1463
|
-
const { sh } = await import('../tools/_shell')
|
|
1464
1483
|
// --validate-automation surfaces broken automation_map / test_map refs early,
|
|
1465
1484
|
// which catches agent-authored automations that reference deleted bricks.
|
|
1466
1485
|
await sh`bricks app check-config --validate-automation ${configPath}`
|
|
1486
|
+
// Doctor adds semantic lint checks after structural validation. Warnings are
|
|
1487
|
+
// surfaced in the compile log, but only errors fail by default.
|
|
1488
|
+
await sh`bricks app doctor --validate-automation ${configPath}`
|
|
1467
1489
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-project",
|
|
3
|
-
"version": "2.25.0-beta.
|
|
3
|
+
"version": "2.25.0-beta.43",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"typecheck": "tsc --noEmit",
|
|
7
7
|
"build": "bun scripts/build.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
10
|
+
"@babel/generator": "7.28.5",
|
|
11
|
+
"@babel/parser": "7.28.5",
|
|
12
|
+
"@babel/traverse": "7.28.5",
|
|
13
|
+
"@babel/types": "7.28.5",
|
|
14
|
+
"@fugood/bricks-cli": "^2.25.0-beta.43",
|
|
11
15
|
"@huggingface/gguf": "^0.3.2",
|
|
12
16
|
"@iarna/toml": "^3.0.0",
|
|
13
17
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
package/package.json.bak
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-ctor",
|
|
3
|
-
"version": "2.25.0-beta.
|
|
3
|
+
"version": "2.25.0-beta.43",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"typecheck": "tsc --noEmit",
|
|
7
7
|
"build": "bun scripts/build.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
10
|
+
"@babel/generator": "7.28.5",
|
|
11
|
+
"@babel/parser": "7.28.5",
|
|
12
|
+
"@babel/traverse": "7.28.5",
|
|
13
|
+
"@babel/types": "7.28.5",
|
|
14
|
+
"@fugood/bricks-cli": "^2.25.0-beta.43",
|
|
11
15
|
"@huggingface/gguf": "^0.3.2",
|
|
12
16
|
"@iarna/toml": "^3.0.0",
|
|
13
17
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
@@ -12,6 +12,7 @@ This skill covers advanced BRICKS features not in the main project instructions.
|
|
|
12
12
|
| Rule | Description |
|
|
13
13
|
|------|-------------|
|
|
14
14
|
| [Architecture Patterns](references/architecture-patterns.md) | **Read first** — decompose flows and select patterns |
|
|
15
|
+
| [Source-Editing Tools](references/source-editing-tools.md) | MCP tools for editing entries and data-calcs by AST (new/edit/remove, value grammar, verify) |
|
|
15
16
|
| [Animation](references/animation.md) | Animation system for brick transforms and opacity |
|
|
16
17
|
| [Standby Transition](references/standby-transition.md) | Canvas enter/exit animations |
|
|
17
18
|
| [Automations](references/automations.md) | E2E testing and scheduled tasks |
|
|
@@ -26,6 +27,7 @@ This skill covers advanced BRICKS features not in the main project instructions.
|
|
|
26
27
|
## Quick Reference
|
|
27
28
|
|
|
28
29
|
- **Complex flows**: See [Architecture Patterns](references/architecture-patterns.md) for decomposing multi-step workflows
|
|
30
|
+
- **Editing entries/data-calcs**: See [Source-Editing Tools](references/source-editing-tools.md) — prefer the MCP editing tools over hand-editing `subspaces/**`
|
|
29
31
|
- **Multi-device**: See [Local Sync](references/local-sync.md) for LAN coordination
|
|
30
32
|
- **Cloud data**: See [Remote Data Bank](references/remote-data-bank.md) for sync and API access
|
|
31
33
|
- **Media assets**: See [Media Flow](references/media-flow.md) for centralized asset management
|
|
@@ -32,6 +32,12 @@ Sequential `PROPERTY_BANK` / `PROPERTY_BANK_EXPRESSION` actions in one chain rea
|
|
|
32
32
|
Built-in commands for direct state and UI changes.
|
|
33
33
|
- **PROPERTY_BANK**: set data value
|
|
34
34
|
- **PROPERTY_BANK_EXPRESSION**: inline JS expression for simple compute
|
|
35
|
+
- The expression engine folds statements into a single expression: only expression
|
|
36
|
+
statements, simple `const`/`let` declarations, and a final return/expression are
|
|
37
|
+
supported — **no `if`/`for`/`while`/`switch`** (use ternaries). The same limit
|
|
38
|
+
applies inside a zero-arg IIFE body. Unsupported statements fail at runtime with
|
|
39
|
+
the error visible only in a DevTools session, so prefer ternary chains or move the
|
|
40
|
+
logic to a DataCalculationScript.
|
|
35
41
|
- **CHANGE_CANVAS**: navigate to another canvas
|
|
36
42
|
- **DYNAMIC_ANIMATION**: trigger animation
|
|
37
43
|
- **ALERT / MESSAGE**: system feedback
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# MCP Source-Editing Tools
|
|
2
|
+
|
|
3
|
+
The project-local `bricks-ctor` MCP server exposes tools that edit `subspaces/**` via
|
|
4
|
+
surgical AST edits, keeping files in the standard generated style. Prefer them over
|
|
5
|
+
hand-editing entry files; they validate references, manage imports, compile-verify, and
|
|
6
|
+
record every operation in `.bricks/edits.jsonl`.
|
|
7
|
+
|
|
8
|
+
## Entry tools (bricks.ts / generators.ts / canvases.ts / data.ts / animations.ts)
|
|
9
|
+
|
|
10
|
+
| Tool | Purpose |
|
|
11
|
+
|------|---------|
|
|
12
|
+
| `new_entry` | Create a standard entry skeleton (`file`, `type`, `templateKey`, `alias`, optional initial `set`/`events`) |
|
|
13
|
+
| `edit_entry` | Set/unset dotted paths on an entry: `title`, `property.url`, `outlets.response`, `value`, `switches[0].property.text`, … |
|
|
14
|
+
| `edit_events` | Add/remove/replace/move/clear EventAction items in `events.<eventKey>` |
|
|
15
|
+
| `edit_canvas_items` | Add/replace/remove/move brick items on a Canvas `items` array (frames need numeric x/y/width/height) |
|
|
16
|
+
| `edit_switches` | Add/replace/remove/move switches (id, title, conds, override, disabled, break) |
|
|
17
|
+
| `remove_entry` | Delete an entry; cascades same-subspace references by default, `strict: true` refuses and lists sites |
|
|
18
|
+
|
|
19
|
+
Addressing: `{ file, entry }` (export const name) is primary; `id` works as a global
|
|
20
|
+
fallback (omit `file`). `edit_entry`/`edit_events` accept a `switch` parameter (switch id
|
|
21
|
+
or index) to edit the facets inside one switch — `edit_switches` owns only the array and
|
|
22
|
+
the conds/override shell.
|
|
23
|
+
|
|
24
|
+
### Event actions
|
|
25
|
+
|
|
26
|
+
```jsonc
|
|
27
|
+
{
|
|
28
|
+
"handler": "system", // or { "ref": "brickOrGeneratorRef" } or { "subspace": "SUBSPACE_id" }
|
|
29
|
+
"name": "CHANGE_CANVAS",
|
|
30
|
+
"params": { "canvasId": { "ref": "mainCanvas" } }, // template params, OR:
|
|
31
|
+
"dataParams": { "someData": 5 }, // PROPERTY_BANK-style params
|
|
32
|
+
"waitAsync": false
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
System actions derive their `as SystemAction...` cast automatically; entity-action casts
|
|
37
|
+
are added only when passed via `cast`. The compiled source form
|
|
38
|
+
`{ handler, action: { name, params: [...], dataParams: [...] }, waitAsync }` is also
|
|
39
|
+
accepted, and `{ "expr": "<raw EventAction>" }` is the escape hatch for shapes the
|
|
40
|
+
structured form cannot express. Handler refs must resolve to a brick or generator.
|
|
41
|
+
`PROPERTY_BANK_EXPRESSION` expressions are validated against the runtime fold rules at
|
|
42
|
+
edit time: only expression statements, simple `const`/`let` declarations, and a final
|
|
43
|
+
return inside a zero-arg IIFE evaluate — no `if`/`for`/`while` (use ternaries, or a
|
|
44
|
+
DataCalculationScript for branching logic).
|
|
45
|
+
|
|
46
|
+
## Data-calc tools (DataCalculationScript only)
|
|
47
|
+
|
|
48
|
+
| Tool | Purpose |
|
|
49
|
+
|------|---------|
|
|
50
|
+
| `new_data_calc` | Create `data-calc/data-calculation-{slug}.ts` + `.sandbox.js`, regenerate `data-calc/index.ts`, wire a minimal subspace root |
|
|
51
|
+
| `edit_data_calc` | Set/unset scalar fields, `output`/`error` refs, replace whole `inputs`/`outputs`, or rewrite the sandbox `code` |
|
|
52
|
+
| `edit_data_calc_io` | Add/remove/replace/clear single `inputs`/`outputs` items (input keys unique; output keys may repeat for fan-out) |
|
|
53
|
+
| `remove_data_calc` | Delete the calc `.ts` + its sandbox file and regenerate the index |
|
|
54
|
+
|
|
55
|
+
Addressing: `{ file }` or `{ subspace, calc }` where `calc` is alias, id, or filename
|
|
56
|
+
slug (subspace defaults to `subspace-0`). Code is canonicalized to the sandbox file form
|
|
57
|
+
(`export function main() { ... }` — wrapped automatically, `async` added when the body
|
|
58
|
+
uses top-level `await`). `DataCalculationMap` (visual node graph) is out of scope and
|
|
59
|
+
returns `fallback_recommended`.
|
|
60
|
+
|
|
61
|
+
## Value grammar (everywhere a value appears)
|
|
62
|
+
|
|
63
|
+
| You pass | Emits |
|
|
64
|
+
|----------|-------|
|
|
65
|
+
| JSON scalar/array/object | literal |
|
|
66
|
+
| `{ "link": "dataRefOrAlias" }` | `linkData(() => data.dX)` (property data-links) |
|
|
67
|
+
| `{ "ref": "idOrAliasOrVarName", "subspace"?: 1 }` | `() => namespace.varName` getter |
|
|
68
|
+
| `{ "expr": "raw TypeScript" }` | spliced verbatim |
|
|
69
|
+
|
|
70
|
+
References resolve by var name, id, or alias within the target subspace and fail loudly
|
|
71
|
+
when missing or ambiguous — this doubles as reference validation.
|
|
72
|
+
|
|
73
|
+
## Verification and audit
|
|
74
|
+
|
|
75
|
+
- Every call compile-verifies by default and returns `verify.configChange` — the minimal
|
|
76
|
+
compiled-config delta (path-keyed set/unset ops). Skip with per-call `verify: false`
|
|
77
|
+
or `BRICKS_CTOR_MCP_EDIT_VERIFY=0` when batching, then finish with the `compile` tool.
|
|
78
|
+
- All operations append to `.bricks/edits.jsonl` (gitignored) with inputs, outcomes, and
|
|
79
|
+
touched sites.
|
|
80
|
+
- Non-standard files or entries (hand-written shapes the AST editor cannot safely
|
|
81
|
+
rewrite) return `fallback_recommended` — use plain file edits for those cases only.
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bricks-design
|
|
3
3
|
description: >-
|
|
4
|
-
Visual design discipline for Applications and Subspaces — type,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
pure usability / flow / journey / affordance / feedback / recovery
|
|
19
|
-
/ accessibility / multilingual audits — those go to bricks-ux. SKIP
|
|
20
|
-
for single-Brick or Generator template work
|
|
21
|
-
(create-brick-or-generator), debugging or refactoring with no
|
|
22
|
-
design intent, or non-display deliverables (CLI, server, tooling).
|
|
23
|
-
Encodes architecture truths, performance and complexity guardrails,
|
|
24
|
-
input-translation rules, visual languages library, Direction
|
|
25
|
-
Advisor for vague briefs, Media Flow protocol for branded work.
|
|
26
|
-
Verification toolchain (compile, preview tool selection, on-device DevTools,
|
|
27
|
-
Path 1/2/3) lives in the bricks-ctor skill.
|
|
4
|
+
Visual design discipline for Applications and Subspaces — type, palette, asset
|
|
5
|
+
acquisition, design language, system commitment, visual rhythm, brand. TRIGGER
|
|
6
|
+
for visual / aesthetic / system / style / brand-asset work even when named in
|
|
7
|
+
product terms — slideshow, pitch deck, explainer, kiosk, signage, menu board,
|
|
8
|
+
lobby, wayfinding, retail, museum, transit; translate or rebuild from Figma /
|
|
9
|
+
HTML / screenshot / website / PDF / brand book; vague creative briefs; branded
|
|
10
|
+
scenes; rework or audit of an existing Subspace's type / palette / motion /
|
|
11
|
+
rhythm. For end-to-end briefs invoke in parallel with bricks-ux (interaction /
|
|
12
|
+
flow layer). SKIP for pure usability / flow / accessibility audits (bricks-
|
|
13
|
+
ux), single-Brick or Generator template work (create-brick-or-generator),
|
|
14
|
+
debugging without design intent, or non-display deliverables. Encodes
|
|
15
|
+
architecture truths, performance guardrails, input-translation rules, visual
|
|
16
|
+
languages, Direction Advisor, Media Flow protocol; verification toolchain
|
|
17
|
+
lives in bricks-ctor.
|
|
28
18
|
---
|
|
29
19
|
|
|
30
20
|
# BRICKS Design
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bricks-ux
|
|
3
3
|
description: >-
|
|
4
|
-
Interaction design and end-user experience for any Application or
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
are visual design, not interaction design. Encodes a universal
|
|
19
|
-
user-journey spine, interaction archetypes, pressable composition,
|
|
20
|
-
monitoring-screen discipline, designed flow states, accessibility,
|
|
21
|
-
and a tiered UX critique. Hardware floors are deployment-relative;
|
|
22
|
-
web habits (hover affordances, modal-as-default, scroll, page-submit
|
|
23
|
-
forms) do not transfer.
|
|
4
|
+
Interaction design and end-user experience for any Application or Subspace
|
|
5
|
+
built on Canvases, Bricks, Generators, Data, DataCalculation. TRIGGER on
|
|
6
|
+
usability / flow / interaction / journey / state / affordance / feedback /
|
|
7
|
+
recovery / accessibility audits and design work — "audit this flow", "improve
|
|
8
|
+
usability", "design the wait state", "make the kiosk usable", "design the
|
|
9
|
+
payment flow", "design idle and attractor states", "design for multilingual /
|
|
10
|
+
low vision". Also triggers in parallel with visual-design work for end-to-end
|
|
11
|
+
deliverables (kiosk, signage, dashboard, interactive screen, pitch deck) where
|
|
12
|
+
interaction shape matters as much as look. SKIP for purely visual / aesthetic
|
|
13
|
+
/ style / brand-asset / typography / palette work — that is bricks-design.
|
|
14
|
+
Encodes a universal user-journey spine, interaction archetypes, pressable
|
|
15
|
+
composition, monitoring-screen discipline, designed flow states,
|
|
16
|
+
accessibility, tiered UX critique; hardware floors are deployment-relative and
|
|
17
|
+
web habits do not transfer.
|
|
24
18
|
---
|
|
25
19
|
|
|
26
20
|
# BRICKS UX
|
package/tools/mcp-env.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const truthyEnvValues = new Set(['1', 'true', 'yes', 'on'])
|
|
2
|
+
|
|
3
|
+
export function isTruthyEnv(value: string | undefined) {
|
|
4
|
+
return truthyEnvValues.has(
|
|
5
|
+
String(value || '')
|
|
6
|
+
.trim()
|
|
7
|
+
.toLowerCase(),
|
|
8
|
+
)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function shouldRegisterEditingTools(env: Record<string, string | undefined> = process.env) {
|
|
12
|
+
return isTruthyEnv(env.BRICKS_CTOR_MCP_ENABLE_EDITING_TOOLS)
|
|
13
|
+
}
|
package/tools/mcp-server.ts
CHANGED
|
@@ -6,6 +6,9 @@ import { register as registerLottie } from './mcp-tools/lottie'
|
|
|
6
6
|
import { register as registerIcons } from './mcp-tools/icons'
|
|
7
7
|
import { register as registerHuggingface } from './mcp-tools/huggingface'
|
|
8
8
|
import { register as registerMedia } from './mcp-tools/media'
|
|
9
|
+
import { register as registerEntryEditing } from './mcp-tools/entry-editing'
|
|
10
|
+
import { register as registerDataCalcEditing } from './mcp-tools/data-calc-editing'
|
|
11
|
+
import { shouldRegisterEditingTools } from './mcp-env'
|
|
9
12
|
|
|
10
13
|
const server = new McpServer({
|
|
11
14
|
name: 'bricks-ctor',
|
|
@@ -24,5 +27,10 @@ registerIcons(server)
|
|
|
24
27
|
registerHuggingface(server)
|
|
25
28
|
registerMedia(server, projectDir)
|
|
26
29
|
|
|
30
|
+
if (shouldRegisterEditingTools()) {
|
|
31
|
+
registerEntryEditing(server, projectDir)
|
|
32
|
+
registerDataCalcEditing(server, projectDir)
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
const transport = new StdioServerTransport()
|
|
28
36
|
await server.connect(transport)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { sh } from '../_shell'
|
|
2
|
+
import { computeConfigChange, readBuildConfig, type ConfigChange } from '../../compile/config-diff'
|
|
3
|
+
|
|
4
|
+
// Result of an editing tool's compile verification, carrying the config delta the
|
|
5
|
+
// compile produced. Shared by entry-editing and data-calc-editing.
|
|
6
|
+
export type VerificationResult = {
|
|
7
|
+
status: 'skipped' | 'compile:ok' | 'compile:failed'
|
|
8
|
+
errors: string[]
|
|
9
|
+
configChange?: ConfigChange
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Strip ANSI colors from the spawned compile so the captured output stays plain text.
|
|
13
|
+
const noColorEnv = { FORCE_COLOR: '0', NO_COLOR: '1' }
|
|
14
|
+
|
|
15
|
+
// Recompile the project and diff the result against the prior build artifact.
|
|
16
|
+
export const compileAndDiff = async (projectDir: string): Promise<VerificationResult> => {
|
|
17
|
+
// Snapshot the prior compiled config before recompiling (the new artifact overwrites it).
|
|
18
|
+
const before = await readBuildConfig(projectDir)
|
|
19
|
+
try {
|
|
20
|
+
await sh`bun compile`.cwd(projectDir).env(noColorEnv).text()
|
|
21
|
+
} catch (err: any) {
|
|
22
|
+
const stdout = err.stdout?.toString() ?? ''
|
|
23
|
+
const stderr = err.stderr?.toString() ?? ''
|
|
24
|
+
const output = [stdout, stderr, err.message].filter(Boolean).join('\n').trim()
|
|
25
|
+
return { status: 'compile:failed', errors: output ? [output] : ['bun compile failed'] }
|
|
26
|
+
}
|
|
27
|
+
const after = await readBuildConfig(projectDir)
|
|
28
|
+
return { status: 'compile:ok', errors: [], configChange: computeConfigChange(before, after) }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const shouldVerify = (inputVerify?: boolean) => {
|
|
32
|
+
if (inputVerify !== undefined) return inputVerify
|
|
33
|
+
const value = process.env.BRICKS_CTOR_MCP_EDIT_VERIFY ?? 'true'
|
|
34
|
+
return !['0', 'false', 'no', 'off'].includes(value.toLowerCase())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Compile verification shared by the source-editing tools: per-call `verify` wins,
|
|
38
|
+
// then the BRICKS_CTOR_MCP_EDIT_VERIFY env toggle, defaulting to on.
|
|
39
|
+
export const verifyProject = async (
|
|
40
|
+
projectDir: string,
|
|
41
|
+
verify?: boolean,
|
|
42
|
+
): Promise<VerificationResult> => {
|
|
43
|
+
if (!shouldVerify(verify)) return { status: 'skipped', errors: [] }
|
|
44
|
+
return compileAndDiff(projectDir)
|
|
45
|
+
}
|
|
@@ -11,6 +11,8 @@ export function register(server: McpServer, projectDir: string) {
|
|
|
11
11
|
const { dirname } = import.meta
|
|
12
12
|
|
|
13
13
|
server.tool('compile', {}, async () => {
|
|
14
|
+
// The config-change report is printed by compile() itself (compile/config-diff.ts),
|
|
15
|
+
// so the spawned `bun compile` output below already carries it.
|
|
14
16
|
let log = 'Type checking & Compiling...\n'
|
|
15
17
|
try {
|
|
16
18
|
log += await sh`bun compile`.cwd(projectDir).env(noColorEnv).text()
|