autokap 1.6.2 → 1.6.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.
@@ -1,236 +0,0 @@
1
- # AutoKap Prompt Standards
2
-
3
- This document defines the contract every user-facing prompt produced by AutoKap must follow. It is the single source of truth referenced by `web/lib/prompts/blocks/*` and the prompt builders that compose them.
4
-
5
- ---
6
-
7
- ## Why this charter exists
8
-
9
- AutoKap generates prompts that the user copy-pastes into their IDE so an AI assistant can:
10
-
11
- - inspect the user's codebase and add `data-ak` attributes
12
- - generate or edit a deterministic `ExecutionProgram`
13
- - scaffold a proxy, embed assets, or build a video demo
14
-
15
- The recipient assistant is rarely "AutoKap-aware":
16
-
17
- - it may be Cursor, Codex, GitHub Copilot, or Claude Code without the `autokap-preset` skill installed
18
- - it has no prior context about AutoKap's runtime model, opcode contract, or CLI
19
-
20
- When prompts are inconsistent, the assistant invents selectors, generates programs before inspecting the codebase, drops the CLI, and ignores the user's brief. We fix that by enforcing a **single, predictable structure across every prompt**.
21
-
22
- Two design principles flow from this:
23
-
24
- 1. **Self-sufficient** — every prompt embeds a mini mental-model so the assistant can succeed even without the skill installed.
25
- 2. **Predictable** — every prompt uses the same nine blocks in the same order. The assistant learns the shape once and applies it everywhere.
26
-
27
- ---
28
-
29
- ## The nine blocks
30
-
31
- Every user-facing prompt is composed from the following blocks, in this order. Blocks are skipped only when explicitly marked optional.
32
-
33
- ### 1. Header (required)
34
-
35
- 3-5 lines. Names the product, the runtime model in one sentence, the task. Mentions the optional skill.
36
-
37
- ```
38
- You are working on AutoKap, a screenshot-and-video automation tool. AutoKap presets
39
- are deterministic JSON programs (opcodes for Playwright) that the AutoKap CLI runs
40
- locally — there is no LLM at capture runtime. Your job here is to <one-line task>.
41
- If a skill named `autokap-preset` is installed in your environment, treat it as the
42
- source of truth — the rules below override anything that contradicts it.
43
- ```
44
-
45
- The header replaces the implicit assumption that the assistant already knows AutoKap. It is the same in every prompt; only the `<one-line task>` changes.
46
-
47
- ### 2. Before you write anything (required for any prompt that touches code)
48
-
49
- A numbered checklist of 3-5 actions the assistant must perform before generating the artifact. Always includes:
50
-
51
- - inspect the codebase
52
- - plan
53
- - ask the user when ambiguous
54
- - never invent UI details, selectors, or copy
55
- - search for existing `data-ak` before adding new ones (when applicable)
56
-
57
- ```
58
- ## Before you write anything
59
-
60
- 1. Inspect the codebase: routes, auth, theme/locale system, components you may need to tag.
61
- 2. Plan in your head (or in your planning tool if you have one) before generating.
62
- 3. If anything is ambiguous (auth flow, target route, data shape), STOP and ask the user.
63
- Do not invent UI details, selectors, or copy.
64
- 4. Search for existing `data-ak` attributes first; only add new ones if none exist.
65
- 5. If your environment supports parallel subagents, you may run codebase inspection
66
- and program drafting in parallel — but do not skip step 3.
67
- ```
68
-
69
- This block sits **immediately after the header**, before any technical detail. The assistant must read it before being tempted by the project context or the brief.
70
-
71
- ### 3. User guidance (required and visible)
72
-
73
- The user's brief, isolated in its own section. The section name varies by task: `## User guidance`, `## What the user wants`, `## Preset brief`, `## What the demo should show`. The content is always the user's free-form input.
74
-
75
- When the user provided no guidance:
76
-
77
- ```
78
- ## User guidance
79
-
80
- _The user has not provided specific guidance for this task. Use sensible defaults
81
- based on the project context above._
82
- ```
83
-
84
- When the user provided partial guidance (e.g. mock data guidance only), each piece appears in its own clearly-labelled subsection.
85
-
86
- This block sits **immediately after "Before you write anything"**, before any constraint. The assistant has just been told to inspect; the brief is the next thing it sees so it shapes inspection.
87
-
88
- ### 4. Project context (required when applicable)
89
-
90
- Compact key/value list. Project name, project ID, base URL, credentials account ID, locale defaults. No prose.
91
-
92
- ```
93
- ## Project context
94
-
95
- - **Name**: Acme Dashboard
96
- - **ID**: `proj_abc123`
97
- - **Base URL**: `https://acme.example.com`
98
- - **Credentials account ID**: `cred_xyz789`
99
- ```
100
-
101
- ### 5. Hard constraints (required)
102
-
103
- Non-negotiable values: viewport variants, capture mode, mediaMode, baseUrl rules, etc. The "Variants (use these EXACTLY)" pattern is the canonical example. Use **bold** for emphasis on critical numbers and `code` for identifiers.
104
-
105
- ### 6. Specific reminders (required when applicable)
106
-
107
- Auth, mock data, locale/theme handling, etc. — only the reminders that apply to the current mode. Anti-patterns are presented as `Don't / Do instead` tables, never bullets:
108
-
109
- ```
110
- | Don't | Do instead |
111
- |---|---|
112
- | Use a CSS selector you guessed (`.btn-primary`) | Add a `data-ak="login-btn"` attribute and target `[data-ak="login-btn"]` |
113
- | Hardcode the auth cookie | Use `credentialsId` and let the runtime inject the right session |
114
- ```
115
-
116
- ### 7. How to persist (required for prompts that produce an artifact)
117
-
118
- CLI commands first. Useful flags listed (`--dry`, `--headed`, `--output`). Fallbacks (JSON file, dashboard import) explicitly labelled "fallback only".
119
-
120
- ### 8. If you get stuck (required for any prompt that touches code)
121
-
122
- 3 concrete scenarios minimum. Tells the assistant what to do at the failure points where it would otherwise improvise:
123
-
124
- ```
125
- ## If you get stuck
126
-
127
- - If you can't find a stable selector → ask the user before guessing.
128
- - If a CLI command fails → run with `--dry` first to validate, then re-run without `--dry`.
129
- - If the program runs but captures the wrong screen → report back with the AutoKap run log;
130
- don't try to patch by adding more opcodes blindly.
131
- ```
132
-
133
- ### 9. Subagents hint (optional, multi-phase prompts only)
134
-
135
- A suggestion (never a requirement) for assistants that support parallel subagents. Always qualified with "if your environment supports..." so single-agent assistants are not derailed.
136
-
137
- ```
138
- ## If you have parallel subagents available
139
-
140
- This prompt has multiple phases (inspect → tag → generate → persist → integrate). If
141
- your environment supports subagents (Claude Code, multi-agent Cursor, etc.), consider
142
- parallelizing: agent 1 inspects the codebase and tags `data-ak`; agent 2 drafts the
143
- `ExecutionProgram` from the tagged components; you merge their outputs.
144
- ```
145
-
146
- ---
147
-
148
- ## Cross-cutting rules
149
-
150
- ### Tone
151
-
152
- Direct imperative: `Do`, `Use`, `Never`, `Ask`. Never "you may want to consider", "perhaps", "if you wish". The assistant should know exactly what the prompt expects.
153
-
154
- ### Markdown
155
-
156
- - `**bold**` for emphasis on critical values
157
- - `` `code` `` for identifiers, file paths, CLI flags
158
- - Tables for matrices and anti-patterns
159
- - Fenced code blocks (with language tag) for examples
160
- - `## Section` / `### Subsection` for hierarchy — the assistant should be able to refer to sections by name
161
-
162
- ### No emojis
163
-
164
- Anywhere in any prompt. They look unprofessional and clutter terminal output when the prompt is shown verbatim.
165
-
166
- ### Examples are concrete
167
-
168
- Every prompt that asks the assistant to produce an artifact contains at least one fully-formed example: a JSON snippet for opcodes, a bash one-liner for CLI commands, a JSX block for `data-ak` placement.
169
-
170
- ### Anti-patterns are tables, not bullets
171
-
172
- ```
173
- | Don't | Why / Do instead |
174
- |---|---|
175
- | ... | ... |
176
- ```
177
-
178
- ### Section names are stable
179
-
180
- The assistant should be able to refer to "the User guidance section" or "the Hard constraints section" and have it mean the same thing across all prompts.
181
-
182
- ---
183
-
184
- ## Block composition pattern
185
-
186
- Each block exposes a `make*` function returning `string[]` (lines). Builders compose blocks by concatenating arrays and joining with `"\n"` at the end:
187
-
188
- ```typescript
189
- import { joinBlocks } from "@/lib/prompts";
190
- import { makeHeader } from "@/lib/prompts/blocks/header";
191
- import { makeBeforeAnythingChecklist } from "@/lib/prompts/blocks/before-anything";
192
- import { makeUserGuidanceSection } from "@/lib/prompts/blocks/user-guidance";
193
-
194
- export function buildPresetPrompt(input: PresetPromptInput): string {
195
- return joinBlocks([
196
- makeHeader({ task: "generate an ExecutionProgram for this preset" }),
197
- makeBeforeAnythingChecklist({ touchesCode: true, supportsSubagents: true }),
198
- makeUserGuidanceSection({ brief: input.userBrief, label: "Preset brief" }),
199
- // ... other blocks
200
- ]);
201
- }
202
- ```
203
-
204
- Blocks must:
205
-
206
- - accept typed parameters; never read environment variables or globals
207
- - be deterministic (same input → same output)
208
- - handle all "missing optional" cases internally (empty guidance, no credentials, etc.)
209
- - never add a trailing newline (the joiner handles spacing)
210
-
211
- ---
212
-
213
- ## When the prompt does NOT touch code
214
-
215
- Some prompts do not produce code (e.g. an image-generation prompt for the Studio composition flow). For those:
216
-
217
- - Header is still required
218
- - Block 2 ("Before you write anything") is skipped
219
- - Block 8 ("If you get stuck") is skipped
220
- - Block 9 ("Subagents hint") is skipped
221
- - The remaining blocks apply if relevant
222
-
223
- These prompts are out of scope for the current refactor and follow a lighter contract.
224
-
225
- ---
226
-
227
- ## Versioning and divergence
228
-
229
- This document is mirrored in `assets/skill/references/STANDARDS.md` so the installed skill has access to the same charter. When the charter changes:
230
-
231
- 1. Update `web/lib/prompts/STANDARDS.md` first.
232
- 2. Mirror the change to `assets/skill/references/STANDARDS.md`.
233
- 3. Update the affected blocks in `web/lib/prompts/blocks/`.
234
- 4. Re-run the snapshot tests on the builders to surface any drift.
235
-
236
- The blocks are the source of truth for what the prompts emit. This document is the source of truth for what the blocks should look like.
@@ -1,88 +0,0 @@
1
- # Complete Examples Reference
2
-
3
- Use these examples as structural templates only. Adapt routes, selectors,
4
- variants, auth handling, and persistence to the user's actual codebase.
5
-
6
- ## Example 1 — Anonymous screenshot preset
7
-
8
- Good for:
9
-
10
- - marketing homepage
11
- - pricing page
12
- - public docs landing page
13
-
14
- Pattern:
15
-
16
- 1. `NAVIGATE`
17
- 2. `DISMISS_OVERLAYS`
18
- 3. optional `SET_LOCALE`
19
- 4. optional `SET_THEME`
20
- 5. `WAIT_FOR`
21
- 6. `CAPTURE_SCREENSHOT`
22
-
23
- ## Example 2 — Authenticated screenshot preset
24
-
25
- Good for:
26
-
27
- - dashboards
28
- - settings pages
29
- - project lists behind auth
30
-
31
- Pattern:
32
-
33
- 1. hardcode the real login URL
34
- 2. `NAVIGATE` to login
35
- 3. `DISMISS_OVERLAYS`
36
- 4. `WAIT_FOR` login fields
37
- 5. `TYPE` `{{email}}`
38
- 6. `TYPE` `{{password}}`
39
- 7. `CLICK` submit
40
- 8. `WAIT_FOR` the protected surface
41
- 9. capture the full page or an `elementSelector`
42
-
43
- Never use `{{loginUrl}}`.
44
-
45
- ## Example 3 — Clip preset
46
-
47
- Good for:
48
-
49
- - short product walkthroughs
50
- - showing a lightweight interaction
51
- - demo GIFs / MP4s
52
-
53
- Pattern:
54
-
55
- 1. perform setup before recording
56
- 2. `BEGIN_CLIP`
57
- 3. run only the user-visible interaction sequence
58
- 4. `END_CLIP`
59
-
60
- Prefer short, deterministic flows.
61
-
62
- ## Example 4 — Mock data preset
63
-
64
- Good for:
65
-
66
- - empty dashboards
67
- - empty card grids
68
- - empty tables
69
- - charts that need seeded values for a compelling screenshot
70
-
71
- Pattern:
72
-
73
- 1. add `data-ak` markers to the template and every variable child
74
- 2. add hidden trigger/input receivers when the app can re-render the widget
75
- 3. declare `mockDataInjection.groups`
76
- 4. emit `INJECT_MOCK_DATA` before the screenshot
77
-
78
- ## Final reminder
79
-
80
- These examples are reference shapes, not recipes to copy blindly.
81
-
82
- Before using one:
83
-
84
- - inspect the codebase
85
- - verify auth requirements
86
- - verify locale/theme handling
87
- - add authored selectors
88
- - persist the preset via API so the user can run `autokap run <preset-id>`
@@ -1,178 +0,0 @@
1
- # Mock Data Injection Reference
2
-
3
- Use this reference when the user enables mock data generation or when a target
4
- capture would otherwise show empty tables, empty lists, empty charts, or other
5
- unhelpful placeholder states.
6
-
7
- ## When to use it
8
-
9
- Use mock data when:
10
-
11
- - the page would otherwise render an empty state
12
- - the marketing value depends on populated cards, rows, charts, or metrics
13
- - the user explicitly enabled "Generate mock data"
14
-
15
- Do not use it just because the feature exists. If the real page already renders
16
- stable, attractive data, prefer the real state.
17
-
18
- ## Core model
19
-
20
- Mock data injection has two complementary delivery mechanisms and the runtime
21
- applies both when they are wired:
22
-
23
- ### Clone
24
-
25
- Clone a DOM template element, then write slot values into the cloned
26
- descendants.
27
-
28
- Best for:
29
-
30
- - tables
31
- - card grids
32
- - simple lists
33
- - badge rows
34
-
35
- ### Trigger
36
-
37
- Write JSON into a hidden input and click a hidden button the app exposes. The
38
- component reads the payload and re-renders through normal app state.
39
-
40
- Best for:
41
-
42
- - charts
43
- - calendars
44
- - maps
45
- - library-owned DOM
46
- - anything likely to re-render and overwrite a clone
47
-
48
- ## Default rule
49
-
50
- For modern React/Vue/Svelte apps, wire **both** clone and trigger whenever
51
- possible.
52
-
53
- Use only one mechanism when:
54
-
55
- - the page is pure server-rendered HTML with no client-side state: clone-only
56
- - the widget has no useful DOM template to clone: trigger-only
57
-
58
- ## Critical slot rule
59
-
60
- Every variable UI element must be represented as a slot.
61
-
62
- Commonly missed slots:
63
-
64
- - dates
65
- - counts
66
- - status badges
67
- - labels that look static
68
- - type icons or icon variants
69
- - prices
70
- - ratings
71
- - role / owner / modified-at metadata
72
- - chart legends and series labels
73
-
74
- Rule of thumb:
75
-
76
- Walk through each JSX expression, ternary, and conditional class. If that value
77
- could differ across items, it should be a slot.
78
-
79
- ## Step 1 — add authored markers
80
-
81
- Tag:
82
-
83
- - the clone template
84
- - the clone container
85
- - every variable child node
86
- - the hidden trigger input/button pair
87
-
88
- Example:
89
-
90
- ```tsx
91
- <div data-ak="preset-card-grid">
92
- {cards.map((card) => (
93
- <article key={card.id} data-ak="preset-card">
94
- <h3 data-ak="preset-card-title">{card.name}</h3>
95
- <span data-ak="preset-card-type">{card.mediaMode}</span>
96
- <span data-ak="preset-card-variant-count">{card.variantCount}</span>
97
- </article>
98
- ))}
99
- </div>
100
-
101
- <input type="hidden" data-ak-fill-input="preset-cards" />
102
- <button
103
- type="button"
104
- style={{ display: "none" }}
105
- data-ak-fill-trigger="preset-cards"
106
- onClick={(e) => {
107
- const input = e.currentTarget.previousElementSibling as HTMLInputElement;
108
- try {
109
- const parsed = JSON.parse(input.value);
110
- if (Array.isArray(parsed)) setCards(parsed);
111
- } catch {
112
- // ignore malformed payloads
113
- }
114
- }}
115
- />
116
- ```
117
-
118
- ## Step 2 — declare `mockDataInjection.groups`
119
-
120
- Declare groups at the top level of the preset config, not inside `program`.
121
-
122
- Each group needs:
123
-
124
- - `name`
125
- - `description`
126
- - `slots[]`
127
- - `defaultValues[]`
128
-
129
- Keep values realistic for the user's domain. Seed 5-10 rows when that makes
130
- sense.
131
-
132
- ## Step 3 — emit `INJECT_MOCK_DATA`
133
-
134
- Place each `INJECT_MOCK_DATA` opcode:
135
-
136
- - after the relevant `WAIT_FOR`
137
- - before the relevant `CAPTURE_SCREENSHOT`
138
-
139
- Wire both clone and trigger fields whenever possible:
140
-
141
- - `containerSelector`
142
- - `templateSelector`
143
- - `slotMappings[]`
144
- - `inputSelector`
145
- - `triggerSelector`
146
-
147
- Always keep the opcode non-blocking:
148
-
149
- ```json
150
- {
151
- "postcondition": { "type": "always" },
152
- "recovery": {
153
- "retries": 0,
154
- "useSelectorMemory": false,
155
- "useAltInteraction": false,
156
- "allowReload": false,
157
- "allowHealer": false
158
- }
159
- }
160
- ```
161
-
162
- ## Implementation rules
163
-
164
- - `slotMappings[].selector` is relative to the cloned template item
165
- - `removeTemplate: true` when the original template should disappear
166
- - `replaceExisting: true` on the group when placeholder content should be wiped
167
- - use `attribute` only when the value belongs in an attribute such as `src`
168
- - a group counts as applied if at least one delivery mechanism succeeds
169
-
170
- ## When not to use `INJECT_MOCK_DATA`
171
-
172
- Use lower-level DOM mutation opcodes instead when the change is narrow:
173
-
174
- - `CLONE_ELEMENT`
175
- - `REMOVE_ELEMENT`
176
- - `SET_ATTRIBUTE`
177
-
178
- Reserve `INJECT_MOCK_DATA` for real structured seed-data scenarios.
@@ -1,17 +0,0 @@
1
- export interface AuthCaptureOptions {
2
- apiBaseUrl: string;
3
- apiKey: string;
4
- projectId: string;
5
- accountId: string;
6
- startUrl: string;
7
- }
8
- /**
9
- * Opens a headed Chromium window, lets the user log in, and uploads the
10
- * resulting storageState (cookies + localStorage, HttpOnly included) to the
11
- * given project credentials account.
12
- *
13
- * The session is captured continuously via polling so we don't depend on the
14
- * user explicitly clicking a button — closing the window after login is
15
- * enough. A "Save & close" button is also rendered for explicit confirmation.
16
- */
17
- export declare function captureAuthSession(options: AuthCaptureOptions): Promise<void>;