Anything-as-API 是一个面向浏览器场景的最小闭环原型:先录制一次明确的网页操作场景,再从录制结果里提取业务 API,最终基于显式 skill_spec_source.json 生成一个可交付的原生 skill_package。当前主线交付形态是带 SKILL.md、scripts/、lib/ 和 assets/ 的 skill package。
当前已经打通这条最小链路:
capture:录制场景并输出结构化session_bundleextract:从 bundle 提取业务 API artifactsspec:把 extract 产物编译成generated_skill_spec.jsonbuilder:基于 spec 生成原生skill_packageverify:对阶段产物和生成的 skill package 做 smoke 验证
当前已经完成的阶段:
- Plan A:采集入口、事件模型、
session_bundle基础契约 - Plan B:
manifest、分级 network evidence、storage snapshot、action trace - Plan C:API 提取、endpoint catalog、OpenAPI 基线
- Plan D:闭环验证与阶段归因报告
- Plan E:
generated_skill_spec.json契约与 spec 编译 - Plan F:原生 skill package 生成器
- Plan G:生成脚本的 runtime/session loop 基线
- Plan H:原生 skill package smoke verify
当前不是生产可用版本,而是一个已经可运行、可验证的最小技术闭环。generic_items_api 只是当前回归 fixture,用来验证生成框架的端到端能力,不是框架内置目标;真正的浏览器登录刷新和长期 cookie 持久化仍在后续阶段。
capture/ Browser capture and session bundle generation
extract/ Bundle-to-API extraction and artifact generation
spec/ Extract artifacts to generated skill spec
builder/ Native skill package generation
verify/ End-to-end verification and stage attribution
tests/ Tests for capture, extract, spec, builder, and verify
docs/ Design notes and implementation plans
output/ Sample outputs generated during local verification
- Python 3.11+
- Poetry
- Chromium for Playwright
Install dependencies into a project-local virtualenv:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry installInstall the Playwright Chromium browser:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run playwright install chromiumFor local verification, run the full extract, refine, build, and verify chain with one command:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m workflow.cli \
--bundle-dir tests/fixtures/session_bundles/plan_b_with_bodies \
--output-dir output/workflow-sample \
--refine-provider fakeExpected output includes:
output/workflow-sample/extract/
output/workflow-sample/refined/
output/workflow-sample/build/skill_package/
output/workflow-sample/verify/verification_report.json
output/workflow-sample/workflow_report.json
workflow_report.json records each stage status, exit code, and compact nested reports from refine, build smoke, and verification stages so failures are diagnosable without opening every output directory.
The capture CLI records one browser entry URL and writes a structured session_bundle.
Example:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m capture.cli \
--url https://example.com/login \
--output-dir output/plan-b-sample \
--manifest tests/fixtures/manifests/login_submit.json \
--capture-mode guided \
--headlessExpected output includes:
output/plan-b-sample/session_meta.json
output/plan-b-sample/network/requests.ndjson
output/plan-b-sample/network/responses.ndjson
output/plan-b-sample/browser/navigation_trace.json
output/plan-b-sample/browser/cookies_timeline.json
output/plan-b-sample/browser/storage_snapshots.json
output/plan-b-sample/user_actions/action_trace.json
output/plan-b-sample/labels/scenario_manifest.json
The extraction CLI consumes a captured bundle and emits API artifacts.
Example:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m extract.cli \
--bundle-dir tests/fixtures/session_bundles/plan_b_minimal \
--output-dir output/plan-c-sampleExpected output includes:
output/plan-c-sample/api_calls.json
output/plan-c-sample/api_catalog.json
output/plan-c-sample/openapi_spec.yaml
output/plan-c-sample/replay_context.json
output/plan-c-sample/skill_spec_source.json
If captured response bodies are available for the selected endpoint, extract also emits:
output/plan-c-sample/recorded_sample.json
The refine CLI rewrites the baseline skill_spec_source.json through a provider and copies the required runtime assets into a builder-ready output directory. The default fake provider is deterministic and offline-only. The openai provider calls the OpenAI Responses API when OPENAI_API_KEY is set.
Refinement is contract-guarded: providers may improve names, summaries, descriptions, schemas, and parser hints, but they cannot change tool names, tool kinds, execution request templates, runtime asset paths, or build script filenames.
Example:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m spec.refine \
--extract-dir tests/fixtures/extracted_scenarios/generic_items_api \
--output-dir output/refined-skill-source \
--provider fakeOpenAI-backed refinement:
OPENAI_API_KEY=... POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m spec.refine \
--extract-dir output/plan-c-sample \
--output-dir output/refined-skill-source \
--provider openai \
--model gpt-5.4Expected output includes:
output/refined-skill-source/skill_spec_source.json
output/refined-skill-source/replay_context.json
output/refined-skill-source/recorded_sample.json
output/refined-skill-source/refine_report.json
The builder CLI compiles an explicit skill_spec_source.json, assembles the package, and smoke-verifies it in one command. The Example directory below is a fixture that contains a spec source; it is not a framework special case.
Example:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m builder.cli \
--extract-dir output/refined-skill-source \
--output-dir output/native-skill-sample \
--verifyExpected output includes:
output/native-skill-sample/generated_skill_spec.json
output/native-skill-sample/skill_package/SKILL.md
output/native-skill-sample/skill_package/scripts/
output/native-skill-sample/skill_package/lib/
output/native-skill-sample/skill_package/assets/
output/native-skill-sample/skill_smoke_report.json
SKILL.md includes skill loader frontmatter (name and description), and agents/openai.yaml includes UI-facing interface metadata so the package can be handed to another agent as a native skill artifact.
The smoke report should include:
{
"status": "pass",
"package_type": "native_skill",
"checks": [
"assets_complete",
"scripts_importable",
"recorded_tool_runs",
"live_tool_auth_required",
"refresh_session_runs",
"live_tool_session_ready",
"live_tool_request_context"
],
"failures": []
}The older two-step builder flow still works if a spec has already been generated:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m spec.cli \
--extract-dir output/plan-c-sample \
--output-dir output/spec-sample
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m builder.cli \
--spec-file output/spec-sample/generated_skill_spec.json \
--output-dir output/native-skill-sample \
--verifyThe verification CLI checks whether the expected artifacts exist and reports which stage failed if the flow is incomplete.
Example:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m verify.cli \
--bundle-dir tests/fixtures/session_bundles/plan_b_minimal \
--artifact-dir output/plan-c-sample \
--refined-artifact-dir output/refined-skill-source \
--package-dir output/native-skill-sample \
--output-dir output/plan-d-sampleExpected output:
output/plan-d-sample/verification_report.json
The current report shape is:
{
"overall_status": "pass",
"stages": {
"capture": {"status": "pass"},
"extraction": {"status": "pass"},
"generation": {"status": "pass"}
}
}The skill smoke CLI validates native skill packages.
Example:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m verify.skill_smoke_cli \
--package-dir output/native-skill-sample/skill_package \
--output-dir output/plan-e-sampleExpected output:
output/plan-e-sample/skill_smoke_report.json
Run all current project tests:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/capture tests/extract tests/spec tests/builder tests/verify tests/workflows -vCurrent expected result:
all tests pass
Run by area:
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/capture -v
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/extract -v
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/spec -v
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/builder -v
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/verify -v
POETRY_VIRTUALENVS_IN_PROJECT=true poetry run python -m pytest tests/workflows -vCurrent bundled fixtures:
tests/fixtures/manifests/login_submit.jsontests/fixtures/session_bundles/plan_b_minimal/
Current generated sample outputs:
output/plan-b-sample/output/plan-c-sample/output/plan-d-sample/output/native-skill-sample/
Implemented now:
- manifest-aware browser capture
- graded request / response evidence capture
- storage snapshots and action traces
- bundle-to-API extraction baseline
- endpoint catalog baseline
- baseline OpenAPI generation
- response-body-aware recorded sample extraction when body evidence is available
- baseline input schema inference from captured request body and query values
- optional fake-provider and OpenAI-provider skill spec refinement stage with builder-ready artifact output
refine_report.jsonsuccess/failure reporting for spec refinement- refinement contract guards for runtime assets, request templates, tool identity, and generated script filenames
- end-to-end verification with stage attribution
- generated native
skill_packageoutput - native skill smoke verification
- recorded sample and session-state runtime script baseline
- one-command
extract-dir -> skill_package -> smoke reportbuilder flow - generated session guidance docs and
refresh_session.pyJSON instructions - generated live scripts can build authenticated HTTP request context from replay and session assets
- generated live scripts can apply simple input overrides to captured request body or query values
- generated live scripts support dry-run request inspection plus injected/default HTTP execution and baseline response parsing
Not implemented yet:
- robust schema inference from multiple observations
- dependency graph generation
- stronger LLM-assisted field mapping and workflow generation across arbitrary sites
- browser-driven auth refresh and long-lived session recovery
- production-ready multi-site skill packaging
- support for complex real-world multi-step authenticated apps
Project design and plan docs live in docs/:
- docs/anything-as-api-design.md
- docs/superpowers/specs/2026-04-15-anything-as-api-decomposition-design.md
- docs/superpowers/plans/2026-04-16-anything-as-api-plan-a-capture-foundation.md
- docs/superpowers/plans/2026-04-16-anything-as-api-plan-b-scenario-aware-capture.md
- docs/superpowers/plans/2026-04-16-anything-as-api-plan-c-api-extraction-and-generation-baseline.md
- docs/superpowers/plans/2026-04-17-anything-as-api-plan-d-end-to-end-verification.md