@lamsa/cli 0.0.0-stage → 0.1.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@lamsa/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1-rc.1",
4
+ "description": "Local-first design files for apps, driven by your own coding agent",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "keywords": [
10
+ "design",
11
+ "design-tool",
12
+ "ui",
13
+ "agents",
14
+ "claude-code",
15
+ "shadcn",
16
+ "tailwind",
17
+ "cli"
18
+ ],
19
+ "homepage": "https://github.com/Shunseii/lamsa#readme",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/Shunseii/lamsa.git",
23
+ "directory": "packages/cli"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/Shunseii/lamsa/issues"
27
+ },
28
+ "type": "module",
29
+ "engines": {
30
+ "node": ">=22"
31
+ },
32
+ "bin": {
33
+ "lamsa": "dist/cli.js"
34
+ },
35
+ "main": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "skill"
46
+ ],
47
+ "scripts": {
48
+ "build": "tsdown",
49
+ "typecheck": "tsc --noEmit -p ."
50
+ },
51
+ "dependencies": {
52
+ "commander": "^14.0.0",
53
+ "fractional-indexing": "^3.2.0",
54
+ "lucide-static": "^1.71.0",
55
+ "nanoid": "^5.1.0",
56
+ "picomatch": "^4.0.7",
57
+ "playwright-core": "^1.65.0",
58
+ "postcss": "^8.5.0",
59
+ "tailwindcss": "4.3.5",
60
+ "tinyglobby": "^0.2.10",
61
+ "zod": "^4.1.0"
62
+ }
63
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: lamsa
3
+ description: Design app screens and components as lamsa design files (*.lamsa.json) in this repo, render them to PNG, and implement them in code. Use when asked to design, mock up, or change a screen, page, or component, when a task mentions lamsa or .lamsa.json files, or before implementing UI that has a lamsa design.
4
+ ---
5
+
6
+ # lamsa
7
+
8
+ lamsa designs are plain JSON files in this repo (`*.lamsa.json`, see `lamsa.config.json` for where). You edit them directly or with the `lamsa` CLI, check them with `lamsa validate`, and look at them with `lamsa render`. Nothing needs a person to open an app: every step below runs headless.
9
+
10
+ A design is a **spec**, not code. To build a designed screen, read its JSON and its PNG, then implement it with this repo's own framework, components, and tokens.
11
+
12
+ ## The loop
13
+
14
+ 1. `lamsa tokens` and `lamsa components` to see what exists. Use tokens and components instead of raw values.
15
+ 2. Make the change: `lamsa add --tree` for new subtrees, `lamsa move` / `lamsa delete` for structure, direct JSON edits for property tweaks.
16
+ 3. `lamsa validate` (exit 1 on errors; each error names the node ID and a fix).
17
+ 4. `lamsa render <id|name|file>` and look at the PNG(s) it prints (`.lamsa/render/`). Fix what looks wrong and render again.
18
+ 5. Optional: `lamsa open <file> --select <id>[,<id>…]` shows the result to the user in the desktop editor with those layers selected (any files they're in open too). Never required.
19
+
20
+ Before starting, and whenever the user says "the comments" or "my notes": `lamsa comments --open --json` lists comment threads people pinned to layers in the editor (each has `nodeId`, `text`, `replies` and `node`, which is null when the layer was deleted). Treat open comments as requests: make the change, validate and render as usual, then resolve each one with a one-line reply saying what you did: `lamsa comments resolve <id> --reply "Pay button is now full width"`. If a comment is unclear or you disagree, reply instead of resolving (`lamsa comments reply <id> "…"`) and leave it open for the user. Never edit or delete comment files by hand.
21
+
22
+ Add `--json` to any command for machine-readable output. If the user has the editor open, `lamsa selection --json` tells you what they have selected; "this", "the selected button" etc. usually mean that. It also lists the design files open in the editor (`open`); the editor only shows those. A file you create while the editor runs opens by itself; to show the user an existing file, run `lamsa open <file>`.
23
+
24
+ While the editor is open, the user watches you work: layers you add or change are highlighted for a moment, and a labelled cursor follows the layers your commands write (`add`, `move`, `delete`) and, faintly, the ones you read (`tree <id>`, `render <id>`). The CLI names you from `LAMSA_AGENT_NAME` (else "Claude" under Claude Code, else "Agent"). Nothing to do for this; prefer targeted reads (`lamsa tree <id>`) so the cursor shows where you are.
25
+
26
+ ## File format
27
+
28
+ ```json
29
+ {
30
+ "$schema": "https://lamsa.dev/schema/v1.json",
31
+ "version": 1,
32
+ "nodes": {
33
+ "k3Xq9aZ1": { "type": "frame", "name": "Checkout · Default", "x": 0, "y": 0,
34
+ "style": { "width": 390, "height": 844, "display": "flex", "flex-direction": "column",
35
+ "gap": "{spacing.4}", "padding": "{spacing.6}", "background": "{color.background}" } },
36
+ "Tt0aB12c": { "type": "text", "parentId": "k3Xq9aZ1", "index": "a0", "content": "Checkout",
37
+ "style": { "font-size": 24, "font-weight": 600 } }
38
+ }
39
+ }
40
+ ```
41
+
42
+ - `nodes` is a **flat map** keyed by ID. Children point at their parent with `parentId` and are ordered by `index` (a fractional string; `lamsa fmt` fills it in). Top-level nodes (no `parentId`) are screens or components on the canvas and carry `x`/`y`.
43
+ - IDs are random 8-char strings, global across the repo. Never derive them from names. Omit `id` in `add --tree` input and the CLI assigns them.
44
+ - Node types: `frame` (container; only frames have children), `text` (`content`), `image` (`src`, a repo-relative path), `icon` (`"set": "lucide"`, `"icon": "<lucide name>"`), `instance` (`componentId`, `props`, `overrides`).
45
+ - `style` is CSS with kebab-case property names. Unitless numbers are px. No selectors here; hover, press and motion go in `css` (below). If CSS can't express it, lamsa can't either.
46
+ - Token references go in style values: `"{color.primary}"`, `"1px solid {color.border}"`. Tokens come from the app's own CSS, plus Tailwind's built-in theme when the CSS imports Tailwind (`{color.blue-500}`, `{text.sm}`, `{font-weight.semibold}`, `{shadow.md}`); `lamsa tokens` lists them. Prefer the project's own tokens (e.g. `{color.primary}`) over Tailwind's palette. Don't invent tokens and don't copy raw hex values that a token already covers (validate warns).
47
+ - A frame can set `"mode": "dark"` to render in dark mode; `lamsa render --mode dark` forces it.
48
+ - `"hidden": true` hides a node and everything inside it. `"locked": true` means the user locked it in the editor: don't move, restyle or delete a locked node (or anything inside it) unless the user asks you to.
49
+ - Layout uses normal CSS: `display: flex|grid`, `gap`, `padding`, `width: "100%"`, `flex: 1`, `position: absolute` with `top`/`left` inside a `position: relative` frame.
50
+
51
+ ## Motion and states
52
+
53
+ A node's `css` is plain CSS for that node: declarations plus nested rules where `&` is the node. Use it for transitions, animations and interaction states; keep static layout in `style`.
54
+
55
+ ```json
56
+ "css": "transition: translate 150ms var(--ease-out), box-shadow 150ms var(--ease-out);\n&:hover { translate: 0 -2px; box-shadow: {shadow.md}; }\n&:active { scale: 0.97; }\n&[data-state=\"loading\"] { width: 44px; border-radius: 999px; }"
57
+ ```
58
+
59
+ - `css` wins over `style` for the same property, and its nested rules (`&:hover`, `&[data-state="…"]`) override `style` values.
60
+ - States beyond hover/press/focus are `data-state` values styled on the node itself: `&[data-state="open"] { … }`. A child reacts to its parent's state with `[data-state="open"] & { … }`.
61
+ - `@keyframes` go in the file's top-level `"css"` string (not inside a node). Keyframes from the app's stylesheet (including Tailwind's `spin`, `ping`, `pulse`, `bounce`) are available everywhere.
62
+ - Enter and exit (dialogs, popovers, toasts): keep the layer in the tree and drive it with a state, not `"hidden": true` (that renders as inline `display: none`, which CSS can't animate). `@starting-style` is the entrance; a state with `display: none` plus `display … allow-discrete` in the transition is the exit:
63
+ `"css": "transition: opacity 200ms var(--ease-out), scale 200ms var(--ease-out), display 200ms allow-discrete;\n@starting-style { opacity: 0; scale: 0.95; }\n&[data-state=\"closed\"] { display: none; opacity: 0; scale: 0.95; transition-duration: 150ms; }"`. Give the backdrop its own `closed` rule. Play in the preview replays the entrance; the `closed` state plays the exit.
64
+ - Page transitions between screens use View Transitions: put `view-transition-name: <name>` in the `css` of the matching layer on each screen (unique per screen), and `::view-transition-group(<name>)`, `::view-transition-old/new(root)` rules in the file's `"css"`. Steps are typed `forward` or `back`, so `:active-view-transition-type(back)::view-transition-new(root) { … }` can reverse a slide. The user plays them in the preview's Flow mode (two or more top-level frames, in order), and edits them there too.
65
+ - Put timing on the group, not on old/new: `::view-transition-group(<name>) { animation-duration: 320ms; animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1); }`. The old and new snapshots inherit both, and that's the rule the editor shows as controls.
66
+ - Write each rule with a single selector, one per target and direction; the editor shows grouped selectors (`a, b { }`) and the `animation` shorthand as custom CSS instead of controls.
67
+ - For something that repeats in a list (order cards, rows), use `view-transition-class: <class>` on the layer and target `*.<class>` (`::view-transition-group(*.order)`), so the same CSS works when the app gives each item its own name.
68
+ - Shipping page transitions in the app: the CSS (names on components, `::view-transition-*` rules and their `@keyframes` in the global stylesheet) copies over as is. The app still has to:
69
+ - start one on navigation: `document.startViewTransition({ update, types: ["forward"] })` around a route change, or the router's switch (React Router `viewTransition`, SvelteKit `onNavigate`, Astro `<ClientRouter />`); a multi-page site adds `@view-transition { navigation: auto; }`;
70
+ - pass the same `forward`/`back` types the design uses, or the direction rules never apply;
71
+ - make names unique: a list item gets `view-transition-name: order-${id}` plus `view-transition-class: order`.
72
+ Browsers without view transitions change pages instantly, so no fallback code is needed.
73
+ - To compare variants, put several layers side by side, each with different `css`; the user previews them together in the editor.
74
+ - See motion with `lamsa render <frame> --animate [frames]` (one image: the frame at evenly spaced moments) and states with `--state hover|press|focus|<data-state>` (combine both to watch a state change). Static renders show animations at their end.
75
+
76
+ ## Components
77
+
78
+ A component is a top-level frame with a `component` block:
79
+
80
+ ```json
81
+ "Bt9xQ2mL": { "type": "frame", "name": "Button", "x": 0, "y": 0,
82
+ "style": { "display": "inline-flex", "padding": "{spacing.2} {spacing.4}", "border-radius": "{radius.md}",
83
+ "background": "{color.primary}", "color": "{color.primary-foreground}" },
84
+ "component": { "props": {
85
+ "variant": { "type": "enum", "options": ["default", "outline"], "default": "default",
86
+ "overrides": { "outline": { "Bt9xQ2mL": { "style": { "background": "transparent", "border": "1px solid {color.border}", "color": "{color.foreground}" } } } } },
87
+ "label": { "type": "text", "default": "Button", "target": "Lb1Lb1Lb" } } } },
88
+ "Lb1Lb1Lb": { "type": "text", "parentId": "Bt9xQ2mL", "index": "a0", "content": "Button" }
89
+ ```
90
+
91
+ Use it with `{ "type": "instance", "componentId": "Bt9xQ2mL", "props": { "variant": "outline", "label": "Cancel" } }`. `overrides` patch inner nodes by their ID: `{ "<innerId>": { "style": {...}, "content": "...", "hidden": true } }`. Every component in the repo is usable in every file; `"internal": true` hides helpers from `lamsa components`.
92
+
93
+ ## Commands
94
+
95
+ | Command | Use |
96
+ |---|---|
97
+ | `lamsa tree [id\|file\|name] [--depth n]` | Structure with IDs |
98
+ | `lamsa tokens [--kind color]` | Available tokens |
99
+ | `lamsa components [--all]` | Components and their props |
100
+ | `lamsa add --tree <json\|file\|-> (--parent <frame> \| --file <path>) [--before\|--after <sibling>]` | Insert nested JSON (`children` arrays allowed); refuses input that would not validate |
101
+ | `lamsa move <id> (--parent <frame> \| --file <path> \| --before\|--after <sibling>)` | Reparent or reorder, keeping the subtree together |
102
+ | `lamsa delete <id...>` | Remove nodes and their subtrees |
103
+ | `lamsa split <id> --to <file>` | Move a top-level node into another file |
104
+ | `lamsa validate` / `lamsa fmt [--fix]` | Check; normalise (flatten nested input, fill indexes, sort keys; `--fix` drops orphans) |
105
+ | `lamsa render [targets] [--mode dark] [--scale 2] [--out dir] [--animate [n]] [--state s]` | PNGs of top-level frames; `--animate` captures motion as a strip, `--state` forces hover/press/focus/a data-state |
106
+ | `lamsa diff [base] [head] [--text] [--open] [--file <path>]` | What changed since a git ref (default HEAD), value by value, and before/after renders of each changed screen with changed layers outlined (`.lamsa/diff/index.html`, plus `report.md` for PRs). `--text` skips rendering |
107
+ | `lamsa selection` | What the user has selected in the editor |
108
+ | `lamsa comments [--open\|--resolved] [--node <id>]` | Comment threads pinned to layers (`node: null` = the layer was deleted) |
109
+ | `lamsa comments add --node <id> [--offset x,y] "<text>"` | Pin a new comment to a layer |
110
+ | `lamsa comments reply <id> "<text>"` | Reply to a thread |
111
+ | `lamsa comments resolve <id> [--reply "<text>"]` / `reopen <id>` | Close a thread, saying what you did; reopen it |
112
+ | `lamsa open [file] [--select id,id…]` | Show the user, with layers selected (optional) |
113
+
114
+ ## Rules
115
+
116
+ - Prefer editing over recreating: keep IDs stable so diffs and references stay meaningful.
117
+ - One file per page or board; put shared components in their own file.
118
+ - After every change: `lamsa validate`, then `lamsa render` and look at the image before saying you're done. Before handing back a larger change, run `lamsa diff --text` to check you changed only what you meant to.
119
+ - Never write to `.lamsa/` (editor session state) except via the CLI.
120
+ - Comments live in `designs/comments/` (`commentsDir` in config), one file per thread, committed with the designs. Change them only with `lamsa comments`; replies and resolves show up live in the editor. Replies are signed as you when lamsa can tell you're an agent (Claude Code, or `LAMSA_AGENT_NAME` set); otherwise pass `--author <your name>` so they aren't signed as the user.