autokap 1.3.31 → 1.4.2
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/assets/skill/SKILL.md +9 -0
- package/assets/skill/references/STANDARDS.md +236 -0
- package/dist/cli-contract.d.ts +1 -0
- package/dist/cli-contract.js +12 -1
- package/dist/cli-runner-local.d.ts +1 -0
- package/dist/cli-runner-local.js +4 -0
- package/dist/cli-runner.d.ts +2 -0
- package/dist/cli-runner.js +5 -0
- package/dist/cli.js +55 -2
- package/dist/crm/email-fallback.d.ts +16 -0
- package/dist/crm/email-fallback.js +217 -0
- package/dist/crm/run-campaign.d.ts +28 -0
- package/dist/crm/run-campaign.js +405 -0
- package/dist/crm/scrape-betalist.d.ts +20 -0
- package/dist/crm/scrape-betalist.js +194 -0
- package/dist/crm/scrape-landing.d.ts +24 -0
- package/dist/crm/scrape-landing.js +240 -0
- package/dist/crm/storage-upload.d.ts +14 -0
- package/dist/crm/storage-upload.js +40 -0
- package/dist/mockup.d.ts +7 -0
- package/dist/mockup.js +52 -6
- package/dist/opcode-runner.d.ts +2 -0
- package/dist/opcode-runner.js +4 -0
- package/dist/openrouter-tts.d.ts +6 -0
- package/dist/openrouter-tts.js +6 -2
- package/dist/types.d.ts +1 -1
- package/package.json +3 -2
- package/dist/server-capture-runtime.d.ts +0 -124
- package/dist/server-capture-runtime.js +0 -582
package/assets/skill/SKILL.md
CHANGED
|
@@ -19,6 +19,8 @@ Normal navigation and interaction stay deterministic. Runtime AI is limited to n
|
|
|
19
19
|
|
|
20
20
|
This installed skill is the **source of truth** for the AutoKap contract: opcode schema, login rules, variant handling, persistence, and validation. The copied prompt from the AutoKap dashboard is only the **preset-specific brief** (project URL, variants, template goal, mock data guidance, etc.).
|
|
21
21
|
|
|
22
|
+
> **Compatibility note.** The dashboard prompts now embed a mini AutoKap mental-model so they remain useful for assistants that don't have this skill installed (Cursor without the bundle, Codex, Copilot, plain Claude Code). When this skill IS installed, **the rules below override anything that contradicts them in the inline mental-model** — the inline version is necessarily a summary.
|
|
23
|
+
|
|
22
24
|
## When To Use This Skill
|
|
23
25
|
|
|
24
26
|
- User wants to capture screenshots or clips of their web app
|
|
@@ -54,6 +56,7 @@ Load these only when the request actually needs them:
|
|
|
54
56
|
- **Opcode parameters** — [OPCODE-REFERENCE.md](OPCODE-REFERENCE.md)
|
|
55
57
|
- **Mock data** — [references/mock-data.md](references/mock-data.md)
|
|
56
58
|
- **Complete examples** — [references/examples.md](references/examples.md)
|
|
59
|
+
- **Prompt charter** — [references/STANDARDS.md](references/STANDARDS.md) — defines the structure every dashboard-generated prompt now follows. Use it when authoring new prompts, when extending existing builders, or to understand why a copied prompt is shaped the way it is.
|
|
57
60
|
|
|
58
61
|
Keep the core `SKILL.md` for the non-negotiable contract. Reach for the
|
|
59
62
|
references only after you know which mode or advanced feature the user needs.
|
|
@@ -565,6 +568,12 @@ autokap run <preset-id> --headed
|
|
|
565
568
|
|
|
566
569
|
# Save the artifacts to a local directory in addition to uploading them:
|
|
567
570
|
autokap run <preset-id> --output ./screenshots
|
|
571
|
+
|
|
572
|
+
# Dry run: validate the opcode program end-to-end without capturing or
|
|
573
|
+
# uploading anything (0 credits charged). Use this right after generating
|
|
574
|
+
# or updating a preset to confirm navigation, clicks, and postconditions
|
|
575
|
+
# work before spending credits on a real capture.
|
|
576
|
+
autokap run <preset-id> --dry
|
|
568
577
|
```
|
|
569
578
|
|
|
570
579
|
## Complete Examples
|
|
@@ -0,0 +1,236 @@
|
|
|
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.
|
package/dist/cli-contract.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const CLI_FALLBACK_PROGRAM_COMMAND = "autokap run <preset-id> --p
|
|
|
15
15
|
export declare function buildCliRunCommand(presetId: string, options?: {
|
|
16
16
|
local?: boolean;
|
|
17
17
|
env?: string;
|
|
18
|
+
dry?: boolean;
|
|
18
19
|
}): string;
|
|
19
20
|
export declare function buildCliInstalledSetupCommand(cliKey: string): string;
|
|
20
21
|
export declare const CLI_PUBLIC_COMMANDS: CliPublicCommandDescriptor[];
|
package/dist/cli-contract.js
CHANGED
|
@@ -7,7 +7,12 @@ export const CLI_DEFAULT_SETUP_COMMAND = "npx autokap@latest init --cli-key <you
|
|
|
7
7
|
export const CLI_ADVANCED_SKILL_COMMAND = "autokap skill --agent <agent>";
|
|
8
8
|
export const CLI_FALLBACK_PROGRAM_COMMAND = "autokap run <preset-id> --program <file>";
|
|
9
9
|
export function buildCliRunCommand(presetId, options = {}) {
|
|
10
|
-
|
|
10
|
+
const flags = [
|
|
11
|
+
options.local ? " --local" : "",
|
|
12
|
+
options.env ? ` --env ${options.env}` : "",
|
|
13
|
+
options.dry ? " --dry" : "",
|
|
14
|
+
].join("");
|
|
15
|
+
return `autokap run${flags} ${presetId}`;
|
|
11
16
|
}
|
|
12
17
|
export function buildCliInstalledSetupCommand(cliKey) {
|
|
13
18
|
return `autokap init --cli-key ${cliKey}`;
|
|
@@ -61,6 +66,12 @@ export const CLI_PUBLIC_COMMANDS = [
|
|
|
61
66
|
summary: "Show the browser window for debugging",
|
|
62
67
|
docsDescriptionKey: "cliCmdHeaded",
|
|
63
68
|
},
|
|
69
|
+
{
|
|
70
|
+
id: "run-dry",
|
|
71
|
+
command: "autokap run <preset-id> --dry",
|
|
72
|
+
summary: "Dry run: execute the opcode program without capturing or uploading (0 credits charged)",
|
|
73
|
+
docsDescriptionKey: "cliCmdRunDry",
|
|
74
|
+
},
|
|
64
75
|
{
|
|
65
76
|
id: "project-list",
|
|
66
77
|
command: "autokap project list",
|
package/dist/cli-runner-local.js
CHANGED
|
@@ -22,11 +22,15 @@ export async function runLocal(presetId, opts) {
|
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
if (opts.dry) {
|
|
26
|
+
logger.info('[capture] DRY RUN — opcodes will execute but no captures or uploads');
|
|
27
|
+
}
|
|
25
28
|
const run = await runCapture({
|
|
26
29
|
presetId,
|
|
27
30
|
env: opts.env,
|
|
28
31
|
program,
|
|
29
32
|
allowUploadFailure: opts.allowUploadFailure,
|
|
33
|
+
dryRun: opts.dry,
|
|
30
34
|
headed: opts.headed,
|
|
31
35
|
onProgress: (event) => {
|
|
32
36
|
const prefix = `[capture][${event.variantId}]`;
|
package/dist/cli-runner.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface CLIRunnerOptions {
|
|
|
29
29
|
program?: ExecutionProgram;
|
|
30
30
|
/** Keep the legacy success result when upload/telemetry persistence fails */
|
|
31
31
|
allowUploadFailure?: boolean;
|
|
32
|
+
/** Dry run: skip capture opcodes (CAPTURE_SCREENSHOT/BEGIN_CLIP/END_CLIP) and upload. 0 credits charged. */
|
|
33
|
+
dryRun?: boolean;
|
|
32
34
|
/** Selector memory map (fetched from server or cached locally) */
|
|
33
35
|
selectorMemory?: Record<string, string[]>;
|
|
34
36
|
/** Show browser window. Default: false (headless) */
|
package/dist/cli-runner.js
CHANGED
|
@@ -195,6 +195,7 @@ export async function runCapture(options) {
|
|
|
195
195
|
maxParallelVariants,
|
|
196
196
|
llmConfig,
|
|
197
197
|
presetName: program.presetId,
|
|
198
|
+
dryRun: options.dryRun,
|
|
198
199
|
onProgress: (event) => {
|
|
199
200
|
if (!options.onProgress) {
|
|
200
201
|
logProgress(event);
|
|
@@ -262,6 +263,10 @@ export async function runCapture(options) {
|
|
|
262
263
|
else {
|
|
263
264
|
logger.error(`[capture] Run failed: ${runResult.error}`);
|
|
264
265
|
}
|
|
266
|
+
if (options.dryRun) {
|
|
267
|
+
logger.info(`[capture] DRY RUN complete — ${runResult.telemetry.totalOpcodes} opcodes executed, 0 captures, 0 credits charged`);
|
|
268
|
+
return { success: runResult.success, runId, runResult };
|
|
269
|
+
}
|
|
265
270
|
try {
|
|
266
271
|
logger.info('[capture] Saving captures, might take a few seconds...');
|
|
267
272
|
options.onProgress?.({
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import fs from 'node:fs/promises';
|
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
7
|
const { version } = require('../package.json');
|
|
8
8
|
import { logger } from './logger.js';
|
|
9
|
-
import { writeConfig, deleteConfig, requireConfig, getConfigPath, DEFAULT_API_BASE_URL, getDefaultApiBaseUrl, getDefaultWsUrl, LOCAL_API_BASE_URL, LOCAL_WS_URL, API_KEY_ENV_VAR, API_BASE_URL_ENV_VAR, WS_URL_ENV_VAR, } from './cli-config.js';
|
|
9
|
+
import { writeConfig, readConfig, deleteConfig, requireConfig, getConfigPath, DEFAULT_API_BASE_URL, getDefaultApiBaseUrl, getDefaultWsUrl, LOCAL_API_BASE_URL, LOCAL_WS_URL, API_KEY_ENV_VAR, API_BASE_URL_ENV_VAR, WS_URL_ENV_VAR, } from './cli-config.js';
|
|
10
10
|
import { renderSkillSingleFile, writeSkillExport } from './skill-packaging.js';
|
|
11
11
|
// ── Program definition ──────────────────────────────────────────────
|
|
12
12
|
export const program = new Command();
|
|
@@ -249,6 +249,7 @@ program
|
|
|
249
249
|
.option('--allow-upload-failure', 'Keep a successful capture exit code even if artifact upload fails', false)
|
|
250
250
|
.option('--output <dir>', 'Optional output directory for local artifact copies')
|
|
251
251
|
.option('--program <file>', 'Path to a program JSON file')
|
|
252
|
+
.option('--dry', 'Dry run: execute all opcodes without capturing or uploading artifacts (0 credits charged)', false)
|
|
252
253
|
.option('--debug', 'Verbose logging: per-substep timing, opcode dumps, recovery strategy traces', false)
|
|
253
254
|
.action(async (presetId, opts) => {
|
|
254
255
|
if (opts.debug) {
|
|
@@ -275,6 +276,7 @@ program
|
|
|
275
276
|
.option('--allow-upload-failure', 'Keep a successful capture exit code even if artifact upload fails', false)
|
|
276
277
|
.option('--debug', 'Verbose logging: per-substep timing, opcode dumps, recovery strategy traces', false)
|
|
277
278
|
.option('--cloud', 'Cloud runner mode: signals 4+ vCPU available, unblocks the conservative Linux FPS default (8 → 30)', false)
|
|
279
|
+
.option('--preset-ids <ids>', 'Comma-separated preset IDs to capture. When omitted, captures all presets with auto_recapture_enabled=true.')
|
|
278
280
|
.action(async (opts) => {
|
|
279
281
|
if (opts.debug) {
|
|
280
282
|
const { setDebugEnabled } = await import('./logger.js');
|
|
@@ -386,7 +388,12 @@ program
|
|
|
386
388
|
// Fetch the presets list with a hard timeout. Without this, a slow or
|
|
387
389
|
// unreachable dashboard would leave the CLI hanging forever — the
|
|
388
390
|
// dashboard would stay stuck at "machine started" with no error surfaced.
|
|
389
|
-
|
|
391
|
+
// When `--preset-ids` is provided, restrict the run to that subset
|
|
392
|
+
// (per-preset recapture launched from the dashboard).
|
|
393
|
+
const presetIdsArg = opts.presetIds?.trim();
|
|
394
|
+
const presetsPath = presetIdsArg
|
|
395
|
+
? `/api/cli/projects/${opts.project}/auto-recapture-presets?preset_ids=${encodeURIComponent(presetIdsArg)}`
|
|
396
|
+
: `/api/cli/projects/${opts.project}/auto-recapture-presets`;
|
|
390
397
|
let data;
|
|
391
398
|
try {
|
|
392
399
|
const response = await fetch(buildApiUrl(config, presetsPath), {
|
|
@@ -542,6 +549,52 @@ program
|
|
|
542
549
|
});
|
|
543
550
|
process.exit(0);
|
|
544
551
|
});
|
|
552
|
+
// ── crm-run command ────────────────────────────────────────────────
|
|
553
|
+
program
|
|
554
|
+
.command('crm-run')
|
|
555
|
+
.description('Scrape BetaList launches and feed the CRM (AUT-109 Phase B)')
|
|
556
|
+
.option('--runId <id>', 'CRM run id (defaults to AUTOKAP_RUN_ID env)')
|
|
557
|
+
.option('--lookback-days <n>', 'How far back to look for launches', '1')
|
|
558
|
+
.option('--debug', 'Verbose logging', false)
|
|
559
|
+
.action(async (opts) => {
|
|
560
|
+
if (opts.debug) {
|
|
561
|
+
const { setDebugEnabled } = await import('./logger.js');
|
|
562
|
+
setDebugEnabled(true);
|
|
563
|
+
logger.info('[crm-run] Debug mode enabled — verbose logging on');
|
|
564
|
+
}
|
|
565
|
+
const runToken = process.env.AUTOKAP_RUN_TOKEN?.trim();
|
|
566
|
+
const runId = opts.runId?.trim() || process.env.AUTOKAP_RUN_ID?.trim();
|
|
567
|
+
const config = await readConfig();
|
|
568
|
+
const apiBaseUrl = process.env.AUTOKAP_API_BASE_URL?.trim().replace(/\/+$/, '') || config?.apiBaseUrl;
|
|
569
|
+
if (!runToken) {
|
|
570
|
+
fatal('[crm-run] Missing AUTOKAP_RUN_TOKEN');
|
|
571
|
+
}
|
|
572
|
+
if (!runId) {
|
|
573
|
+
fatal('[crm-run] Missing CRM run id. Set AUTOKAP_RUN_ID or pass --runId <id>.');
|
|
574
|
+
}
|
|
575
|
+
if (!apiBaseUrl) {
|
|
576
|
+
fatal('[crm-run] Missing API base URL. Set AUTOKAP_API_BASE_URL or run autokap init.');
|
|
577
|
+
}
|
|
578
|
+
const parsedLookback = Number.parseInt(opts.lookbackDays, 10);
|
|
579
|
+
const lookbackDays = Math.max(1, Math.min(7, Number.isFinite(parsedLookback) ? parsedLookback : 1));
|
|
580
|
+
try {
|
|
581
|
+
const { runCampaign } = await import('./crm/run-campaign.js');
|
|
582
|
+
const result = await runCampaign({
|
|
583
|
+
runId,
|
|
584
|
+
lookbackDays,
|
|
585
|
+
apiBaseUrl,
|
|
586
|
+
runToken,
|
|
587
|
+
logger,
|
|
588
|
+
});
|
|
589
|
+
logger.success(`[crm-run] Done — scraped=${result.scraped} inserted=${result.inserted} ` +
|
|
590
|
+
`disqualified=${result.disqualified} skipped=${result.skipped}`);
|
|
591
|
+
process.exit(0);
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
logger.error(`[crm-run] Failed: ${error.message}`);
|
|
595
|
+
process.exit(1);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
545
598
|
// ── project commands ───────────────────────────────────────────────
|
|
546
599
|
const projectCmd = program
|
|
547
600
|
.command('project')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface EmailFallbackOptions {
|
|
2
|
+
betaListLaunchUrl: string;
|
|
3
|
+
productUrl: string | null;
|
|
4
|
+
logger: {
|
|
5
|
+
info(msg: string): void;
|
|
6
|
+
warn(msg: string): void;
|
|
7
|
+
error(msg: string): void;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function findEmail(opts: EmailFallbackOptions): Promise<{
|
|
11
|
+
email: string | null;
|
|
12
|
+
handle: string | null;
|
|
13
|
+
lang: string | null;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function extractEmailsFromText(text: string): string[];
|
|
16
|
+
export declare function pickBestEmail(emails: string[], productHostname: string | null): string | null;
|