M1: script-first (v0.3.0) #4

Merged
akib merged 13 commits from akib/m1-script-first into main 2026-11-06 04:11:35 +00:00 AGit
Owner

M1 of the plan (docs/IMPLEMENTATION.md): make BlockFlow writable and repairable from scripts, for people and LLMs. Version 0.3.0.

What's in it

  • M1.1 Strict import checking (src/core/check.ts, suggest.ts): every import is checked first. Each problem gets a stable code, a JSON path into the file as written, and a did-you-mean hint. Errors refuse the file and are listed in a dialog with a Copy button; warnings import with a toast. Blocks can declare validate rules, which the editor shows too. The schemas reject unknown keys.
  • M1.2 Script format (src/core/script.ts, layout.ts): a workflow as a list of steps, with branches as nested lists, aliases and shorthands. Compiled scripts are auto-laid out and get the same strict check, with paths pointing at the author's steps (/steps/2/click/locater). The editor adds Tidy up and Export as script. script.schema.json is generated, and every guide example also ships as a script.
  • M1.3 Page snapshot: a new page op and page-snapshot block return the accessibility tree with a ready-made locator per element, covering frames and shadow DOM. Open Tab gets a "📸 Snapshot page" button that copies the outline.
  • M1.4 Coded results (src/core/errors.ts): failed steps record code, locator, url, matches and sourceId (the author's step id). The JSON report is versioned and has a generated report.schema.json.
  • M1.5 Schema v2: Read Element, Watch Element and Paginate use locator (was selector/next). Stored workflows are migrated on load and rewritten once, and old keys are still accepted on import.
  • M1.6 Docs for models: the guide and llms.txt lead with the script format, Repair and error-code tables. There is an eval set of ten authoring tasks (tests/evals), each with a reference solution that an e2e spec imports, runs and scores.
  • e2e now prefers the system Chromium over Brave.

Test plan

  • npm run check: 544 unit/DOM tests; guide, learning examples and wiki links in sync
  • npm run build, npm run build:firefox
  • npm run e2e in Chromium: 14 specs, 154 checks, including the new import-check, scripts, snapshot-codes and evals specs (10/10 reference solutions pass)
  • npm run e2e:firefox: 14 checks pass (Firefox 159). "Read Element with a URL" failed once during development with a missing host permission, then passed on a rerun; it may be flaky.
  • Not measured yet: whether a model passes the evals in ≤ 2 tries. That needs the CLI (M4.3).

After merge: npm run wiki:publish.

🤖 Generated with Claude Code

M1 of the plan (docs/IMPLEMENTATION.md): make BlockFlow writable and repairable from scripts, for people and LLMs. Version 0.3.0. ## What's in it - **M1.1 Strict import checking** (`src/core/check.ts`, `suggest.ts`): every import is checked first. Each problem gets a stable code, a JSON path into the file as written, and a did-you-mean hint. Errors refuse the file and are listed in a dialog with a Copy button; warnings import with a toast. Blocks can declare `validate` rules, which the editor shows too. The schemas reject unknown keys. - **M1.2 Script format** (`src/core/script.ts`, `layout.ts`): a workflow as a list of steps, with branches as nested lists, aliases and shorthands. Compiled scripts are auto-laid out and get the same strict check, with paths pointing at the author's steps (`/steps/2/click/locater`). The editor adds Tidy up and Export as script. `script.schema.json` is generated, and every guide example also ships as a script. - **M1.3 Page snapshot:** a new page op and `page-snapshot` block return the accessibility tree with a ready-made locator per element, covering frames and shadow DOM. Open Tab gets a "📸 Snapshot page" button that copies the outline. - **M1.4 Coded results** (`src/core/errors.ts`): failed steps record `code`, `locator`, `url`, `matches` and `sourceId` (the author's step id). The JSON report is versioned and has a generated `report.schema.json`. - **M1.5 Schema v2:** Read Element, Watch Element and Paginate use `locator` (was `selector`/`next`). Stored workflows are migrated on load and rewritten once, and old keys are still accepted on import. - **M1.6 Docs for models:** the guide and `llms.txt` lead with the script format, Repair and error-code tables. There is an eval set of ten authoring tasks (`tests/evals`), each with a reference solution that an e2e spec imports, runs and scores. - e2e now prefers the system Chromium over Brave. ## Test plan - [x] `npm run check`: 544 unit/DOM tests; guide, learning examples and wiki links in sync - [x] `npm run build`, `npm run build:firefox` - [x] `npm run e2e` in Chromium: 14 specs, 154 checks, including the new `import-check`, `scripts`, `snapshot-codes` and `evals` specs (10/10 reference solutions pass) - [x] `npm run e2e:firefox`: 14 checks pass (Firefox 159). "Read Element with a URL" failed once during development with a missing host permission, then passed on a rerun; it may be flaky. - [x] Not measured yet: whether a model passes the evals in ≤ 2 tries. That needs the CLI (M4.3). After merge: `npm run wiki:publish`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
akib added 13 commits 2026-11-06 04:03:24 +00:00
Read Element and Watch Element take `locator` instead of `selector`, Paginate takes `locator`
instead of `next`. src/core/migrate.ts moves the old keys on load (loadWorkflows), rewrites the
stored list once after an update, and on import (any file version). Nodes keep the author's id as
`origin`. Shared Issue type for the M1 checkers in src/core/issues.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
src/core/script.ts compiles { format: blockflow-script, steps } into a graph
(aliases, shorthands, If rejoin, each/onError branches, ids kept as origin,
issues with JSON Pointers and nodePaths) and decompiles tree-shaped graphs
back, verified by recompiling. src/core/layout.ts lays graphs out in layers.
Import accepts scripts (one branch in parseImport) and lays out graph files
without positions; the editor gets Tidy up and Export as script.
docs/guide/script.schema.json is generated; every guide example also ships
as a .script.json and round-trips. Wiki, guide and lesson 07 updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- src/core/check.ts: checkFile(raw, registry, options) on the raw file, before ids are
  replaced: file shape, unknown types/keys (with aliases and Damerau-Levenshtein hints),
  value types, enums, ranges, locators, URLs, templates, step settings, edges and ports,
  start/unreachable/cycles, page.no-tab (must-analysis of open tabs), Run Workflow targets,
  unknown secrets. src/core/suggest.ts for did-you-mean.
- BlockDefinition.validate(config) for rules between settings (Assert, Wait For, Upload
  File, Download, Read Element, Navigate, Schedule, Extract List/Table), used by import and
  the editor; BlockDefinition.legacyKeys (Open Tab newTab).
- parseImport runs checkFile first; ImportResult carries issues on both outcomes and any
  error refuses the file. Options: registry, secrets.
- Editor: refused imports list every issue in an issues dialog (code, path, message, hint,
  Copy); warnings import with a toast whose Details opens them.
- Schema: additionalProperties false for block configs, rows and step; realInput in step.
- Tests: tests/core/check.test.ts (one fixture per code), README examples checked, e2e
  import-check spec. Docs: wiki Core Modules, Workflows as Scripts, Troubleshooting,
  Editor, Editor Components, Block Internals, Adding a Block, Testing; guide Repair table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	docs/guide/README.md
#	docs/wiki/Core-Modules.md
#	docs/wiki/Testing.md
#	docs/wiki/Workflows-as-Scripts.md
#	src/core/library.ts
#	tests/core/guideExamples.test.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
M1.3: new page op 'snapshot' (src/dom/snapshot.ts): an outline of the accessibility
tree, one line per element with flags, a ref and a ready-made locator (firstLocator,
frame= prefixed in frames), shadow roots and frames marked, hidden elements skipped,
capped at 1,500 lines. Block Page Snapshot (read) outputs snapshot and elements;
Playwright export uses ariaSnapshot(). Editor: 📸 Snapshot page on Open Tab
(bf:snapshot-page / bf:snapshot-result) copies the outline. aria.ts gains
withAriaMemo and slot-aware names; role= checks the hidden state last.

M1.4: src/core/errors.ts (ERROR_CODES, CodedError, errorDetails). The agent answers
pending/error with a code, the page URL and strict-mode matches; pageDriver, host,
navigation and blocks throw CodedError; the engine records code, locator, url,
matches and sourceId (node.origin) on StepRecord and errorCode on the error port.
The editor shows the code in Last run and Reports. JSON export is versioned
(toJsonReport, schemaVersion 1) with docs/guide/report.schema.json generated by
scripts/reportSchema.ts.

Tests: jsdom snapshot and error-code tests, engine/report tests, e2e spec
snapshot-codes. Docs: wiki pages, usage guide (snapshot workflow, error-code table),
Troubleshooting, lesson 07.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	docs/guide/README.md
#	docs/wiki/Adding-a-Block.md
#	scripts/guide.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
akib merged commit 56ac9e945a into main 2026-11-06 04:11:35 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
akib/blockflow!4
No description provided.