@pen.dev/cli 0.3.2 → 0.3.4
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/README.md +18 -12
- package/dist/anthropic-messages-COZrsSdY.mjs +40 -0
- package/dist/azure-openai-responses-Dmf1EaVz.mjs +2 -0
- package/dist/browserAll-BZYrVO32.mjs +2 -0
- package/dist/{dist-BEo0Z8Vf.mjs → dist-D9ROAuw3.mjs} +348 -319
- package/dist/{dist-BY6vOcMF.mjs → dist-DGrygXHh.mjs} +2 -2
- package/dist/{error-body-D2Mrqb4g.mjs → error-body-BBlqjbe7.mjs} +1 -1
- package/dist/google-generative-ai-BMEzR_34.mjs +2 -0
- package/dist/google-shared-DXgnvvDU.mjs +318 -0
- package/dist/google-vertex-In7qdx36.mjs +2 -0
- package/dist/index.mjs +2 -2
- package/dist/mistral-conversations-DdYjdrRy.mjs +5 -0
- package/dist/models-BBd5zwn6.mjs +2 -0
- package/dist/{multipart-parser-DX5ZDxQv.mjs → multipart-parser-BdmM0fdd.mjs} +1 -1
- package/dist/node_modules/@highagency/pencil-wasm/package.json +1 -1
- package/dist/node_modules/@highagency/pencil-wasm/pencil.d.ts +3 -0
- package/dist/node_modules/@highagency/pencil-wasm/pencil.js +1 -1
- package/dist/node_modules/@highagency/pencil-wasm/pencil.wasm +0 -0
- package/dist/openai-CbFQ5q5I.mjs +18 -0
- package/dist/openai-codex-responses-CD-2hfWB.mjs +8 -0
- package/dist/openai-completions-DamtYjy7.mjs +6 -0
- package/dist/openai-responses-DgeWdtm-.mjs +2 -0
- package/dist/openai-responses-shared-DKseiGAg.mjs +11 -0
- package/dist/{openrouter-images-BbBWg9zF.mjs → openrouter-images-gArAwqnL.mjs} +1 -1
- package/dist/out/mcp-server-darwin-arm64 +0 -0
- package/dist/out/mcp-server-darwin-x64 +0 -0
- package/dist/out/mcp-server-linux-arm64 +0 -0
- package/dist/out/mcp-server-linux-x64 +0 -0
- package/dist/out/mcp-server-windows-arm64.exe +0 -0
- package/dist/out/mcp-server-windows-x64.exe +0 -0
- package/dist/out/skills/pen-dev/SKILL.md +204 -0
- package/dist/out/skills/pen-dev/execute.md +364 -0
- package/dist/out/skills/pen-dev/guide/code.md +198 -0
- package/dist/out/skills/pen-dev/guide/components.md +45 -0
- package/dist/out/skills/pen-dev/guide/design-system.md +556 -0
- package/dist/out/skills/pen-dev/guide/landing-page.md +31 -0
- package/dist/out/skills/pen-dev/guide/mobile-app.md +31 -0
- package/dist/out/skills/pen-dev/guide/slides.md +222 -0
- package/dist/out/skills/pen-dev/guide/table.md +37 -0
- package/dist/out/skills/pen-dev/guide/tailwind.md +328 -0
- package/dist/out/skills/pen-dev/guide/web-app.md +245 -0
- package/dist/out/skills/pen-dev/pen-schema.md +202 -0
- package/dist/out/skills/pen-dev/scripts-and-shaders.md +94 -0
- package/dist/pi-user-agent-m9a4CjJo.mjs +2 -0
- package/dist/{src-B_lvnEtX.mjs → src-KoDMTA_Q.mjs} +1 -1
- package/dist/transform-messages-BHnJzowk.mjs +2 -0
- package/dist/webworkerAll-CB00nbs9.mjs +2 -0
- package/package.json +5 -4
- package/dist/anthropic-messages-Bf-fvkNu.mjs +0 -40
- package/dist/azure-openai-responses-CzgVqECr.mjs +0 -2
- package/dist/browserAll-8jKh1NRi.mjs +0 -2
- package/dist/completionchunk-BQtPqA8U.mjs +0 -28
- package/dist/google-generative-ai-DSOqI0LF.mjs +0 -2
- package/dist/google-shared-CetPT_Vt.mjs +0 -318
- package/dist/google-vertex-CPtOc5oU.mjs +0 -2
- package/dist/mistral-conversations-CUsdbDQ8.mjs +0 -10
- package/dist/models-CwK5xZH9.mjs +0 -2
- package/dist/openai-Brr_V-tF.mjs +0 -17
- package/dist/openai-codex-responses-Cb5pfH5S.mjs +0 -8
- package/dist/openai-completions-BvTlcCeP.mjs +0 -6
- package/dist/openai-responses-IuaLTEHh.mjs +0 -2
- package/dist/openai-responses-shared-D4d0NbBE.mjs +0 -11
- package/dist/otel-CaADOqYZ.mjs +0 -4
- package/dist/transform-messages-CSBQpmXO.mjs +0 -2
- package/dist/webworkerAll-BD-7VH16.mjs +0 -2
- /package/dist/{dist-BnoSGZKP.mjs → dist-D8tvRm1b.mjs} +0 -0
- /package/dist/{emscripten-module.browser-F76W5DM6-CNibWX-6.mjs → emscripten-module.browser-F76W5DM6-DWhj_jYh.mjs} +0 -0
- /package/dist/{emscripten-module.browser-XIKQQPVU-BNfdGnMe.mjs → emscripten-module.browser-XIKQQPVU-Dmh4no3c.mjs} +0 -0
- /package/dist/{ffi-C5tLdQO9.mjs → ffi-BroAqW9B.mjs} +0 -0
- /package/dist/{ffi-BuJ13coi.mjs → ffi-DwdyvnFx.mjs} +0 -0
- /package/dist/{from-py2TfO8m.mjs → from-Choxbpmr.mjs} +0 -0
- /package/dist/{github-copilot-headers-DZOfokGy.mjs → github-copilot-headers-DCj7hJoC.mjs} +0 -0
- /package/dist/{hash-Kp92CI9R.mjs → hash-DNYCELl4.mjs} +0 -0
- /package/dist/{html-GGJ1fTRB.mjs → html-DEPARSNH.mjs} +0 -0
- /package/dist/{init-B9LSomNH.mjs → init-DwIpBeuP.mjs} +0 -0
- /package/dist/{module-ES6BEMUI-DwQ9nTMF.mjs → module-ES6BEMUI-DUGQwtIb.mjs} +0 -0
- /package/dist/{module-asyncify-2EFITU5U-B54Mkt6K.mjs → module-asyncify-2EFITU5U-U7fqmMTF.mjs} +0 -0
- /package/dist/{openai-prompt-cache-t4kk9puG.mjs → openai-prompt-cache-tVHrB8oW.mjs} +0 -0
- /package/dist/{photon_rs-BySSRmP5.mjs → photon_rs-o0nbTM4F.mjs} +0 -0
- /package/dist/{provider-retry-BM3ArvaW.mjs → provider-retry-wOYAq0sa.mjs} +0 -0
- /package/dist/{sanitize-unicode-CHjuq5rK.mjs → sanitize-unicode-Byz9nlLd.mjs} +0 -0
- /package/dist/{standalone-DYT2Zg6I.mjs → standalone-DwaYVpTH.mjs} +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Instructions when generating code from .pen files
|
|
2
|
+
|
|
3
|
+
- IMPORTANT: Make sure to use the frontend frameworks that are already used in the project. For example, if the project is using React, always generate compliant React code.
|
|
4
|
+
- IMPORTANT: After generating code, DO NOT output Markdown files of the changes. Just stick to generating code and nothing else.
|
|
5
|
+
- IMPORTANT: Make sure to use and leverage the CSS libraries, design systems and other UI coding utilities that are already used in the project. For example, if the project is using Tailwind, make sure to style your code using Tailwind.
|
|
6
|
+
- IMPORTANT: Make sure when using CSS libraries and frameworks that you identify the installed version and always use the correct APIs that are supported by the installed versions.
|
|
7
|
+
- IMPORTANT: When generating code from .pen designs, always make sure to use the same text labels, icons ans spacing as what is in the design.
|
|
8
|
+
- DO NOT create documentations for the changes when generating code from design.
|
|
9
|
+
- Explore the workspace to find if the design elements you are translating to code are already exist in the code base.
|
|
10
|
+
- Make sure to awlays use the correct font, icons, and UI details like border radius when generating the code from a design.
|
|
11
|
+
- If you are not sure what frontend frameworks and UI libraries are used in the project, explore it in the workspace.
|
|
12
|
+
- If the UI design element you are turning code into already exist in the codebase, update it, not generate a new one.
|
|
13
|
+
- When changing existing components and UI elements in the code, make sure to not break the functionality.
|
|
14
|
+
|
|
15
|
+
## Initial Setup
|
|
16
|
+
|
|
17
|
+
### Project Initialization
|
|
18
|
+
|
|
19
|
+
- Identify the frontend framework and language used in the project (e.g., React, Vue, Angular, Svelte, etc.)
|
|
20
|
+
- Use the same framework, language, and conventions as the existing project
|
|
21
|
+
- Identify the styling approach (e.g., Tailwind, CSS Modules, styled-components, etc.)
|
|
22
|
+
- If using Tailwind, refer to 'tailwind' topic for implementation details
|
|
23
|
+
|
|
24
|
+
### Pre-Implementation Verification
|
|
25
|
+
|
|
26
|
+
- Ensure CSS/styles compile without errors
|
|
27
|
+
- Verify all CSS variables are accessible (if using CSS custom properties)
|
|
28
|
+
- Confirm styling system is properly configured and loaded
|
|
29
|
+
|
|
30
|
+
## Component Implementation Workflow
|
|
31
|
+
|
|
32
|
+
### Step 1: Component Analysis and Extraction
|
|
33
|
+
|
|
34
|
+
#### 1A. Identify Required Components
|
|
35
|
+
|
|
36
|
+
- Read the target frame/design
|
|
37
|
+
- Identify which reusable components (refs) are used in this specific frame
|
|
38
|
+
- **IMPORTANT**: Only process components that appear in the current frame
|
|
39
|
+
- Count instances of each component (helps catch missing instances later)
|
|
40
|
+
- Document: "Component X used N times"
|
|
41
|
+
|
|
42
|
+
#### 1B. Extract Component Definitions
|
|
43
|
+
|
|
44
|
+
- Use `Print(Get(componentId, {depth: 5}))` in `execute` to get component structure
|
|
45
|
+
- Extract full component tree with all nested children
|
|
46
|
+
- Process components ONE AT A TIME:
|
|
47
|
+
1. Extract component with full depth
|
|
48
|
+
2. Recreate in React (Step 2)
|
|
49
|
+
3. Validate (Step 3)
|
|
50
|
+
4. Move to next component only after validation passes
|
|
51
|
+
|
|
52
|
+
#### 1C. Map Component Instances
|
|
53
|
+
|
|
54
|
+
- Read the target frame structure
|
|
55
|
+
- For each component, identify ALL instances
|
|
56
|
+
- Document for each instance:
|
|
57
|
+
* Instance ID and location
|
|
58
|
+
* Nested component overrides (`descendants` map)
|
|
59
|
+
* Props/values being passed
|
|
60
|
+
- **Nested Component Analysis**:
|
|
61
|
+
* Check base component definition: Does it always include nested components?
|
|
62
|
+
* Check all instances: Do any override/hide nested components?
|
|
63
|
+
* **Decision Rule**:
|
|
64
|
+
- If NO instances override away → Nested component is REQUIRED (always render)
|
|
65
|
+
- If ANY instances override away → Nested component is OPTIONAL (conditional render)
|
|
66
|
+
* Verify each nested component ref in base definition against all instances
|
|
67
|
+
- **Visual Verification**:
|
|
68
|
+
* Use `TakeScreenshot` on instances in context (not just base definition)
|
|
69
|
+
* Verify visible elements (borders, backgrounds, shadows)
|
|
70
|
+
* Check if styling should be on outer container or nested elements
|
|
71
|
+
* Match visual appearance in frame context
|
|
72
|
+
|
|
73
|
+
### Step 2: React Component Creation
|
|
74
|
+
|
|
75
|
+
#### Component Structure
|
|
76
|
+
|
|
77
|
+
- Create `.tsx` file in `src/components/` with component name
|
|
78
|
+
- Use named exports
|
|
79
|
+
- Define TypeScript interfaces for all props
|
|
80
|
+
|
|
81
|
+
#### Props Interface Design
|
|
82
|
+
|
|
83
|
+
- Review ALL instances from Step 1C mapping
|
|
84
|
+
- Support all properties used by any instance (including optional ones)
|
|
85
|
+
- **Nested Component Rendering**:
|
|
86
|
+
* Apply decision rule from Step 1C:
|
|
87
|
+
- NO instances override away → Always render (required)
|
|
88
|
+
- ANY instances override away → Conditional render (optional)
|
|
89
|
+
* Verify against instance mapping before making props optional
|
|
90
|
+
- Document required vs optional props based on actual usage
|
|
91
|
+
- Cross-reference with instance mapping to ensure completeness
|
|
92
|
+
|
|
93
|
+
#### Style Implementation
|
|
94
|
+
|
|
95
|
+
- Use Tailwind classes exclusively (NO inline styles)
|
|
96
|
+
- Refer to tailwind.md sections: "Layout Conversion", "Style Implementation", "CSS Custom Properties and Font Stacks"
|
|
97
|
+
- Match design values exactly (use arbitrary values when needed)
|
|
98
|
+
- Use CSS variables for colors (no hardcoded values)
|
|
99
|
+
|
|
100
|
+
#### SVG Path Implementation
|
|
101
|
+
|
|
102
|
+
When implementing SVG elements from the design:
|
|
103
|
+
|
|
104
|
+
**1. Extract Exact Geometry**
|
|
105
|
+
- Use `Print(Get(nodeId, {includePathGeometry: true}))` in `execute`
|
|
106
|
+
- NEVER approximate paths - extract exact `geometry` property from design
|
|
107
|
+
|
|
108
|
+
**2. Properties to Extract**
|
|
109
|
+
- `geometry` - use as `d` attribute in `<path>`
|
|
110
|
+
- `fill` - convert design variables to CSS variables (e.g., `$primary` → `var(--primary)`)
|
|
111
|
+
- `stroke` properties if present (`strokeColor`, `strokeThickness`)
|
|
112
|
+
- `width` and `height` for viewBox calculation
|
|
113
|
+
|
|
114
|
+
**3. Implementation**
|
|
115
|
+
- Use exact geometry string in `d` attribute
|
|
116
|
+
- Set `viewBox="0 0 {width} {height}"`
|
|
117
|
+
- Preserve all stroke properties
|
|
118
|
+
- For styling, see tailwind.md "SVG Styling" section for Tailwind-specific syntax
|
|
119
|
+
|
|
120
|
+
**4. Logos and Complex Icons**
|
|
121
|
+
- Extract complete geometry even if very long
|
|
122
|
+
- Don't simplify or approximate
|
|
123
|
+
- Maintain precision for brand assets
|
|
124
|
+
|
|
125
|
+
### Step 3: Component Validation
|
|
126
|
+
|
|
127
|
+
1. **Visual Verification**:
|
|
128
|
+
- Use `TakeScreenshot` on design component
|
|
129
|
+
- Compare with rendered React component
|
|
130
|
+
- Verify pixel-perfect match
|
|
131
|
+
|
|
132
|
+
2. **Style Verification**:
|
|
133
|
+
- Inspect computed CSS properties
|
|
134
|
+
- Verify dimensions, spacing, colors, typography match design
|
|
135
|
+
- Ensure CSS variables resolve correctly
|
|
136
|
+
|
|
137
|
+
3. **Behavior Verification**:
|
|
138
|
+
- Test fill_container elements expand properly
|
|
139
|
+
- Test fit_content elements size to content
|
|
140
|
+
- Verify no overflow issues
|
|
141
|
+
|
|
142
|
+
4. **Iterative Fixing**:
|
|
143
|
+
- Fix discrepancies immediately
|
|
144
|
+
- Re-validate after each fix
|
|
145
|
+
- Only proceed to next component when current is perfect
|
|
146
|
+
|
|
147
|
+
### Step 4: Frame Integration
|
|
148
|
+
|
|
149
|
+
#### Pre-Integration Analysis
|
|
150
|
+
|
|
151
|
+
- Read complete target frame with `maxDepth: 10`
|
|
152
|
+
- Map component tree structure
|
|
153
|
+
- Identify all component instances
|
|
154
|
+
|
|
155
|
+
#### Instance Configuration
|
|
156
|
+
|
|
157
|
+
- Document all property overrides for each instance
|
|
158
|
+
- Verify nested component overrides
|
|
159
|
+
- Create instance mapping with exact props
|
|
160
|
+
- **Layout Context**:
|
|
161
|
+
* Check parent container layout mode
|
|
162
|
+
* If flex container with multiple `fill_container` children → each needs `flex-1`
|
|
163
|
+
* Document which components need `flex-1` based on parent layout
|
|
164
|
+
|
|
165
|
+
#### Completeness Verification
|
|
166
|
+
|
|
167
|
+
- Count component instances in design vs implementation
|
|
168
|
+
- Verify all props match design overrides
|
|
169
|
+
- Confirm nested components follow required/optional decision from Step 1C
|
|
170
|
+
- Use checklist:
|
|
171
|
+
* [ ] All instances accounted for
|
|
172
|
+
* [ ] All props match overrides
|
|
173
|
+
* [ ] Nested components render correctly (always vs conditional)
|
|
174
|
+
* [ ] Layout classes applied correctly (`flex-1`, etc.)
|
|
175
|
+
|
|
176
|
+
### Step 5: Final Validation
|
|
177
|
+
|
|
178
|
+
- Verify component positions and spacing match design
|
|
179
|
+
- Verify colors resolve correctly
|
|
180
|
+
- Verify typography matches
|
|
181
|
+
- Verify responsive behavior:
|
|
182
|
+
* Layout adapts to different viewport sizes
|
|
183
|
+
* Scrollable areas work when content exceeds space
|
|
184
|
+
* No horizontal overflow
|
|
185
|
+
* `fill_container` elements expand properly
|
|
186
|
+
* `fit_content` elements size to content
|
|
187
|
+
- Verify no console errors
|
|
188
|
+
- Verify all interactive elements function correctly
|
|
189
|
+
|
|
190
|
+
## Key Principles
|
|
191
|
+
|
|
192
|
+
- Use the project's styling system consistently (avoid inline styles when possible)
|
|
193
|
+
- If using Tailwind, see tailwind.md for Tailwind-specific implementation details
|
|
194
|
+
- Match design values exactly
|
|
195
|
+
- Use the project's color system (CSS variables, design tokens, theme files, etc.) - avoid hardcoded values
|
|
196
|
+
- Process components one at a time with validation
|
|
197
|
+
- Verify nested component rendering requirements
|
|
198
|
+
- Ensure proper styling and layout based on parent context
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Components and Instances
|
|
2
|
+
|
|
3
|
+
- Object that has `reusable` property `true` can be also called a "component" or a "symbol"
|
|
4
|
+
- Components will always have a random generated ID. It's not possible to set the ID of a component.
|
|
5
|
+
- Components can be used to replicate the same object tree in multiple places, to avoid repetition. This is ideal for common widgets in a design, like buttons, form fields, toggles, cards, etc.
|
|
6
|
+
- To reuse a component, use the `ref` object type that points to a reusable component. `ref` objects are also called "instances".
|
|
7
|
+
- Instances have a `ref` property, which identifies the mother component.
|
|
8
|
+
- The `ref` property of the instance must be set to the reused component's `id`.
|
|
9
|
+
- Instances can be customized by overriding objects' properties in their subtree:
|
|
10
|
+
- To override properties of the component's root object, just put the overridden properties in the `ref` object.
|
|
11
|
+
- To override properties of an object inside the component's subtree, use the `descendants` property of the `ref`. Put the overridden properties under the customized object's `id`, path, or unique name inside the `descendants` map. If a name is not unique, use the node ID/path instead. When accessing multi-level descendant nodes in the component, use paths in the `descendants` object keys to access it, DO NOT create multiple levels of `descendants` objects.
|
|
12
|
+
- To override properties of an object inside a nested instance, the object's `id` must be prefixed by the instance's `id` followed by a slash (/). This works for arbitrarily nested component instances, e.g. consider an icon component; and a button component that contains an instance of this icon; and a menu component that contains multiple instances of the button component; and a sidebar component that contains an instance of the menu component!
|
|
13
|
+
- Parts of an instance's object tree can also be replaced with completely new objects: if the `type` property is present for a particular descendant, it means that the whole subtree will be swapped out with the override. In this case, the override must be a complete object tree, not just properties! This mechanism is useful for reusable container-type objects, such as windows, tables, grids, cards, etc.
|
|
14
|
+
- An instance can emulate the deletion of a nested object from its subtree by overriding its `enabled` property with `false`.
|
|
15
|
+
- You cannot reference components across files. If you want to use a component from a different file you must copy it over.
|
|
16
|
+
- Try to use existing components in the document instead of always making new ones.
|
|
17
|
+
- Instead of duplicating the same component multiple times with small tweaks. Try to find a way to make them more generic so the instances can use them in more places.
|
|
18
|
+
- Overrides will be only applied to the object it's overriding. The changes will not be inherited to all children.
|
|
19
|
+
- When parsing designs, treat "component" word broadly - some components are formally defined symbols that can be references, others are ad-hoc groupings that visually or functionally behave like components, sometimes their node name is prefixed "component/"
|
|
20
|
+
- When copying nodes and modifying descendants, use the `descendants` property in the Copy operation. Never use separate Update operations for descendants of copied nodes, as this will fail due to ID mismatches.
|
|
21
|
+
- An instance (`ref` node) has no `children` of its own - its subtree comes from the component. Do NOT `Get` an instance to discover its children: use the component's child ids you already have (from creating it or from the response mapping) in `instanceId + "/" + componentChildId` paths, or `Get(instanceId, {resolveInstances: true})` if you truly need to read the expanded subtree.
|
|
22
|
+
- When modifying component instance descendants:
|
|
23
|
+
- Use `Update(instanceId+"/childId", {...})` to change properties
|
|
24
|
+
- Use `newNodeId=Replace(instanceId+"/childId", {...})` to replace with a new node
|
|
25
|
+
- Use `newNodeId=Insert()` when the parent is a regular frame
|
|
26
|
+
- IMPORTANT: DO NOT try to Update a node's descendant that you just copied (Copy), since copying will recreate the descendant nodes and it will assign new IDs to those children nodes.
|
|
27
|
+
- Prefer using `fit_content` or `fill_container` size instance override to resize the component instance into the new location.
|
|
28
|
+
- When an instance is not inside an object using `layout`, it must be positioned by overriding its `x` and `y` properties. Do this even if the position is (0, 0). Never override just a single position axis. Always override both if you need to specify the position.
|
|
29
|
+
- An object must have a specified position, or be a child of an object using horizontal or vertical layout.
|
|
30
|
+
|
|
31
|
+
**Pattern: Insert instance, then Update descendants**
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
cardId=Insert("Casf3fX",{type:"ref",ref:"abc",name:"Account Card"})
|
|
35
|
+
Update(cardId+"/childTitleId",{content:"Account Details"})
|
|
36
|
+
Update(cardId+"/childDescriptionId",{content:"Manage your settings"})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Pattern: Insert instance, then Replace a slot**
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
cardId=Insert("Casf3fX",{type:"ref",ref:"abc",name:"Account Card"})
|
|
43
|
+
customContentId=Replace(cardId+"/contentSlotId",{type:"frame",name:"Content",layout:"vertical"})
|
|
44
|
+
item1Id=Insert(customContentId,{type:"text",name:"Item 1",fontFamily:"Inter",content:"Item 1",fill:"#000000"})
|
|
45
|
+
```
|