From 45250c27cc61e115352ae508c79e5c0e7e4c7490 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Thu, 3 Dec 2026 02:26:33 +1300 Subject: [PATCH 1/2] =?UTF-8?q?app/:=20the=20CI=20API's=20builds=20(sc-890?= =?UTF-8?q?0):=20POST=20/api/v1/builds=20(numbering,=20nonces,=20environme?= =?UTF-8?q?nts,=20visualci.yml,=20warnings),=20GET=20/api/v1/builds/{id},?= =?UTF-8?q?=20POST=20=E2=80=A6/snapshots=20(validation,=20the=20409=20for?= =?UTF-8?q?=20other=20content,=20render=20reuse,=20presigned=20uploads,=20?= =?UTF-8?q?group=20keys),=20POST=20=E2=80=A6/finalize=20(shards,=20allow?= =?UTF-8?q?=5Fempty,=20empty=5Freason);=20today's=20error=20JSON;=20per-bu?= =?UTF-8?q?ild=20settings,=20blob=20records=20and=20the=20credit=20ledger?= =?UTF-8?q?=20ported;=20tests=20against=20today's=20answers=20(tests/golde?= =?UTF-8?q?n,=20recorded=20from=20the=20Loco=20server's=20request=20tests)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Cargo.lock | 3 + app/Cargo.toml | 3 + app/src/domain/blobs.rs | 100 ++ app/src/domain/build_settings.rs | 248 +++ app/src/domain/builds.rs | 349 ++++ app/src/domain/credits.rs | 56 + app/src/domain/environments.rs | 36 + app/src/domain/groups.rs | 13 + app/src/domain/lenient.rs | 78 + app/src/domain/mod.rs | 12 + app/src/domain/projects.rs | 41 + app/src/domain/snapshots.rs | 242 +++ app/src/http/api.rs | 12 - app/src/http/api/builds.rs | 227 +++ app/src/http/api/mod.rs | 164 ++ app/src/lib.rs | 1 + app/src/models/builds.rs | 6 +- app/src/models/reviews.rs | 3 +- app/src/testing.rs | 1 + app/tests/api_builds.rs | 126 ++ app/tests/credits.rs | 19 + .../get-snapshots.json | 49 + .../post-snapshots-invalid-kind.json | 4 + .../post-snapshots.json | 10 + .../post-builds.json | 26 + .../create_build-2.json | 68 + .../create_build-3.json | 55 + .../create_build-4.json | 50 + .../create_build.json | 24 + .../get_build.json | 69 + .../update_project-2.json | 353 ++++ .../update_project-3.json | 197 ++ .../update_project.json | 56 + .../create_build-2.json | 50 + .../create_build.json | 66 + .../finalize_build-2.json | 50 + .../finalize_build.json | 65 + .../get_build.json | 56 + .../whoami-2.json | 19 + .../whoami.json | 35 + .../create_build-2.json | 52 + .../create_build.json | 52 + .../list_builds-2.json | 54 + .../list_builds-3.json | 53 + .../list_builds-4.json | 54 + .../list_builds.json | 89 + .../whoami-2.json | 66 + .../whoami-3.json | 27 + .../whoami-4.json | 66 + .../whoami.json | 73 + .../create_organization.json | 20 + .../create_project.json | 43 + .../create_project_token.json | 20 + .../delete_project_token.json | 18 + .../get_organization-2.json | 14 + .../get_organization.json | 111 ++ .../get_project.json | 67 + .../update_project-2.json | 15 + .../update_project-3.json | 15 + .../update_project-4.json | 62 + .../update_project-5.json | 22 + .../update_project-6.json | 22 + .../update_project-7.json | 22 + .../update_project-8.json | 21 + .../update_project.json | 41 + .../whoami.json | 58 + .../review-2.json | 15 + .../review.json | 15 + .../review_page.json | 17 + .../update_project.json | 41 + .../create_project_token-2.json | 20 + .../create_project_token.json | 14 + .../get_organization.json | 93 + .../list_organizations.json | 60 + .../update_project.json | 14 + .../create_organization.json | 15 + .../get_project.json | 55 + .../list_builds-2.json | 14 + .../list_builds.json | 15 + .../create_build.json | 50 + .../delete_comment.json | 18 + .../get_build.json | 114 ++ .../list_comments-2.json | 18 + .../list_comments-3.json | 60 + .../list_comments.json | 48 + .../post_comment-2.json | 21 + .../post_comment-3.json | 20 + .../post_comment.json | 27 + .../resolve_comment.json | 18 + .../review-2.json | 16 + .../review.json | 16 + .../update_comment.json | 19 + .../upload_snapshots.json | 31 + .../whoami.json | 25 + .../review.json | 16 + .../create_build.json | 50 + .../get_build-2.json | 290 +++ .../get_build-3.json | 613 +++++++ .../get_build.json | 613 +++++++ .../get_snapshot-2.json | 16 + .../get_snapshot-3.json | 15 + .../get_snapshot-4.json | 15 + .../get_snapshot-5.json | 15 + .../get_snapshot.json | 15 + .../get_skill-2.json | 14 + .../get_skill-3.json | 14 + .../get_skill.json | 116 ++ .../tools-list-project-token.json | 1579 +++++++++++++++++ .../tools-list-user-token.json | 1579 +++++++++++++++++ .../list_builds-2.json | 14 + .../list_builds.json | 17 + .../get_project-2.json | 57 + .../projects_can_be_renamed/get_project.json | 14 + .../update_project-2.json | 15 + .../update_project-3.json | 15 + .../update_project.json | 41 + .../create_build.json | 50 + .../finalize_build.json | 49 + .../get_build.json | 76 + .../get_organization.json | 152 ++ .../upload_snapshots-2.json | 20 + .../upload_snapshots.json | 31 + .../create_build.json | 50 + .../finalize_build.json | 50 + .../support_send-2.json | 27 + .../support_send-3.json | 16 + .../support_send.json | 27 + .../create_build.json | 71 + .../finalize_build.json | 70 + .../create_build.json | 50 + .../finalize_build.json | 50 + .../get_build-2.json | 52 + .../get_build-3.json | 52 + .../get_build-4.json | 52 + .../get_build.json | 52 + .../get_snapshot-2.json | 15 + .../get_snapshot-3.json | 15 + .../get_snapshot-4.json | 15 + .../get_snapshot-5.json | 14 + .../get_snapshot-6.json | 12 + .../get_snapshot.json | 15 + .../review-2.json | 15 + .../review-3.json | 15 + .../review-4.json | 15 + .../review-5.json | 15 + .../review.json | 15 + .../review_page-2.json | 17 + .../review_page-3.json | 17 + .../review_page-4.json | 17 + .../review_page.json | 17 + app/tests/golden/mod.rs | 85 + 151 files changed, 11517 insertions(+), 15 deletions(-) create mode 100644 app/src/domain/blobs.rs create mode 100644 app/src/domain/build_settings.rs create mode 100644 app/src/domain/builds.rs create mode 100644 app/src/domain/credits.rs create mode 100644 app/src/domain/environments.rs create mode 100644 app/src/domain/groups.rs create mode 100644 app/src/domain/lenient.rs create mode 100644 app/src/domain/mod.rs create mode 100644 app/src/domain/projects.rs create mode 100644 app/src/domain/snapshots.rs delete mode 100644 app/src/http/api.rs create mode 100644 app/src/http/api/builds.rs create mode 100644 app/src/http/api/mod.rs create mode 100644 app/tests/api_builds.rs create mode 100644 app/tests/credits.rs create mode 100644 app/tests/golden/api/registers_snapshots_and_asks_for_new_files/get-snapshots.json create mode 100644 app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots-invalid-kind.json create mode 100644 app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots.json create mode 100644 app/tests/golden/api/shards_with_the_same_nonce_share_a_build/post-builds.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-2.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-3.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-4.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/get_build.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-2.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-3.json create mode 100644 app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build-2.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build-2.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/get_build.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami-2.json create mode 100644 app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build-2.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-2.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-3.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-4.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-2.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-3.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-4.json create mode 100644 app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_organization.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project_token.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/delete_project_token.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization-2.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_project.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-2.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-3.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-4.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-5.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-6.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-7.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-8.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project.json create mode 100644 app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/whoami.json create mode 100644 app/tests/golden/mcp/a_project_can_keep_approving_with_people/review-2.json create mode 100644 app/tests/golden/mcp/a_project_can_keep_approving_with_people/review.json create mode 100644 app/tests/golden/mcp/a_project_can_keep_approving_with_people/review_page.json create mode 100644 app/tests/golden/mcp/a_project_can_keep_approving_with_people/update_project.json create mode 100644 app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token-2.json create mode 100644 app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token.json create mode 100644 app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/get_organization.json create mode 100644 app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/list_organizations.json create mode 100644 app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/update_project.json create mode 100644 app/tests/golden/mcp/a_project_token_reaches_only_its_project/create_organization.json create mode 100644 app/tests/golden/mcp/a_project_token_reaches_only_its_project/get_project.json create mode 100644 app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds-2.json create mode 100644 app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/create_build.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/delete_comment.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/get_build.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-2.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-3.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-2.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-3.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/resolve_comment.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review-2.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/update_comment.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/upload_snapshots.json create mode 100644 app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/whoami.json create mode 100644 app/tests/golden/mcp/every_tool_refuses_arguments_it_does_not_take/review.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/create_build.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-2.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-3.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-2.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-3.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-4.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-5.json create mode 100644 app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot.json create mode 100644 app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json create mode 100644 app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-3.json create mode 100644 app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill.json create mode 100644 app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-project-token.json create mode 100644 app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-user-token.json create mode 100644 app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds-2.json create mode 100644 app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds.json create mode 100644 app/tests/golden/mcp/projects_can_be_renamed/get_project-2.json create mode 100644 app/tests/golden/mcp/projects_can_be_renamed/get_project.json create mode 100644 app/tests/golden/mcp/projects_can_be_renamed/update_project-2.json create mode 100644 app/tests/golden/mcp/projects_can_be_renamed/update_project-3.json create mode 100644 app/tests/golden/mcp/projects_can_be_renamed/update_project.json create mode 100644 app/tests/golden/mcp/runs_a_build_from_uploaded_files/create_build.json create mode 100644 app/tests/golden/mcp/runs_a_build_from_uploaded_files/finalize_build.json create mode 100644 app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_build.json create mode 100644 app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_organization.json create mode 100644 app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots-2.json create mode 100644 app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots.json create mode 100644 app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/create_build.json create mode 100644 app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/finalize_build.json create mode 100644 app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-2.json create mode 100644 app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-3.json create mode 100644 app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send.json create mode 100644 app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/create_build.json create mode 100644 app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/finalize_build.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/create_build.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/finalize_build.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-2.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-3.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-4.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-2.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-3.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-4.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-5.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-6.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-2.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-3.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-4.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-5.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-2.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-3.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-4.json create mode 100644 app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page.json create mode 100644 app/tests/golden/mod.rs diff --git a/app/Cargo.lock b/app/Cargo.lock index 6ed23918..24ede2fe 100644 --- a/app/Cargo.lock +++ b/app/Cargo.lock @@ -4534,10 +4534,12 @@ name = "visualci-app" version = "0.0.0" dependencies = [ "axum", + "globset", "hex", "image", "laravel-rust", "oauth-provider-laravel", + "regex", "reqwest 0.12.28", "rusty-s3", "serde", @@ -4545,6 +4547,7 @@ dependencies = [ "sha2 0.10.9", "snapshot-diff", "tokio", + "tracing", "visualci-core", ] diff --git a/app/Cargo.toml b/app/Cargo.toml index 67d58e3d..78aea0b0 100644 --- a/app/Cargo.toml +++ b/app/Cargo.toml @@ -35,11 +35,14 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] } image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp"] } reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] } rusty-s3 = "0.12" +globset = "0.4" +tracing = "0.1" # VisualCI's own crates, shared with the CLI. visualci-core = { path = "../crates/visualci-core" } snapshot-diff = { path = "../crates/snapshot-diff" } [dev-dependencies] +regex = "1" [profile.dev] debug = "line-tables-only" diff --git a/app/src/domain/blobs.rs b/app/src/domain/blobs.rs new file mode 100644 index 00000000..c35324d7 --- /dev/null +++ b/app/src/domain/blobs.rs @@ -0,0 +1,100 @@ +//! Blob records: what's stored under each SHA-256, whether its bytes have arrived, and an image's size and pixel +//! fingerprint (cached on first use). + +use laravel::db; +use laravel::model::update; + +use crate::models::Blob; +use crate::storage::BlobStore; + +/// Record a blob a client or renderer is about to upload (or already has). Returns it. +/// +/// # Errors +/// On a database error. +pub async fn register(sha256: &str, size: i64, content_type: &str) -> laravel::Result { + db::query!( + "INSERT INTO blobs (sha256, size, content_type) VALUES ({sha256}, {size}, {content_type}) \ + ON CONFLICT (sha256) DO NOTHING" + ) + .insert() + .await?; + Blob::find_or_fail(sha256.to_string()).await +} + +#[must_use] +pub fn is_uploaded(blob: &Blob) -> bool { + blob.uploaded_at.is_some() +} + +/// Which of these blobs exist (retention deletes old ones). +/// +/// # Errors +/// On a database error. +pub async fn existing(shas: &[String]) -> laravel::Result> { + let mut out = std::collections::HashSet::new(); + for chunk in shas.chunks(10_000) { + out.extend(Blob::query().filter(Blob::sha256.is_in(chunk.to_vec())).get().await?.into_iter().map(|b| b.sha256)); + } + Ok(out) +} + +/// Check the store for blobs not yet confirmed, and mark the ones that arrived with bytes matching their hash (one +/// that doesn't match is deleted, to be uploaded again). Returns the hashes still missing. +/// +/// # Errors +/// On a database or storage error. +pub async fn confirm_uploads(store: &BlobStore, hashes: &[String]) -> laravel::Result> { + let mut missing = Vec::new(); + for sha256 in hashes { + let Some(mut blob) = Blob::find(sha256.clone()).await? else { + missing.push(sha256.clone()); + continue; + }; + if is_uploaded(&blob) { + continue; + } + if let Some(size) = store.verify(sha256).await? { + let uploaded_at = Some(laravel::now().timestamp()); + let size = i64::try_from(size).unwrap_or(i64::MAX); + update!(blob { uploaded_at, size }).await?; + } else { + missing.push(sha256.clone()); + } + } + Ok(missing) +} + +/// Store bytes the server produced itself (diff overlays) and record them. +/// +/// # Errors +/// On a database or storage error. +pub async fn put(store: &BlobStore, bytes: Vec, content_type: &str) -> laravel::Result { + let size = i64::try_from(bytes.len()).unwrap_or(i64::MAX); + let sha256 = store.put(bytes, content_type).await?; + let mut blob = register(&sha256, size, content_type).await?; + if !is_uploaded(&blob) { + let uploaded_at = Some(laravel::now().timestamp()); + update!(blob { uploaded_at }).await?; + } + Ok(blob) +} + +/// The image's pixel fingerprint and size, computed (and cached on the row) on first use. +/// +/// # Errors +/// When the blob is missing or isn't an image. +pub async fn image_info(mut blob: Blob, store: &BlobStore) -> laravel::Result<(String, u32, u32)> { + if let (Some(fp), Some(w), Some(h)) = (&blob.pixel_fingerprint, blob.width, blob.height) { + return Ok((fp.clone(), u32::try_from(w).unwrap_or(0), u32::try_from(h).unwrap_or(0))); + } + let bytes = store.get(&blob.sha256).await?; + let image = visualci_core::image_hash::decode(&bytes) + .map_err(|e| laravel::Error::msg(format!("{}: {e}", blob.sha256)))? + .to_rgba8(); + let fp = visualci_core::image_hash::fingerprint_rgba(&image); + let (w, h) = image.dimensions(); + let pixel_fingerprint = Some(fp.clone()); + let (width, height) = (Some(i32::try_from(w).unwrap_or(i32::MAX)), Some(i32::try_from(h).unwrap_or(i32::MAX))); + update!(blob { pixel_fingerprint, width, height }).await?; + Ok((fp, w, h)) +} diff --git a/app/src/domain/build_settings.rs b/app/src/domain/build_settings.rs new file mode 100644 index 00000000..12e85c3d --- /dev/null +++ b/app/src/domain/build_settings.rs @@ -0,0 +1,248 @@ +//! The settings one build runs with: its `visualci.yml` where the file sets a field, the project's settings +//! otherwise, and a snapshot's own overrides (from the test or the upload) on top. +//! +//! The file may change settings, but not quietly loosen review: its `ci_mode` can only tighten the project's, and a +//! file that hides more than its base build's did (new or wider ignore rules, a higher threshold) makes the build +//! show a "visualci.yml" change that has to be approved (see `hides_more_than`). + +use globset::GlobMatcher; +use serde::Serialize; +use visualci_core::config::{self, Config, ScopedIgnoreRule, Threshold}; +use visualci_core::snapshot_text::{CompiledRules, IgnoreRules}; + +use crate::models::{Build, Project, Snapshot}; + +pub struct BuildSettings<'a> { + pub project: &'a Project, + /// The build's `visualci.yml`, when it was sent one. + pub config: Option, + /// Where the ignore rules come from, and each with its glob compiled once. + source: Source, + rules: Vec<(Option, ScopedIgnoreRule)>, + /// The file's thresholds by glob (one number is the glob `**`). + thresholds: Vec<(GlobMatcher, String, f64)>, +} + +/// Where a setting or rule came from. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum Source { + /// The build's `visualci.yml`. + File, + /// Set next to the assertion, in the test (the upload's `ignore`). + Test, + /// The project's settings. + Project, +} + +/// An ignore rule that applies to a snapshot, and where it came from. +#[derive(Clone, Debug, Serialize)] +pub struct AppliedRule { + pub source: Source, + /// The rule's glob; `None` for rules set in the test, which apply to that snapshot only. + pub snapshots: Option, + pub json_paths: Vec, + pub text_patterns: Vec, +} + +const MODES: &[&str] = &["review", "wait", "strict"]; + +fn strictness(mode: &str) -> usize { + MODES.iter().position(|m| *m == mode).unwrap_or(0) +} + +impl<'a> BuildSettings<'a> { + pub fn new(project: &'a Project, build: &Build) -> Self { + // The config was validated when the build was created; one that no longer parses (a later, stricter version) + // is treated as absent rather than failing the build. + let config = build.config.as_ref().and_then(|v| { + Config::from_json(v) + .inspect_err(|e| tracing::warn!(build = build.id, error = %e, "stored config no longer validates")) + .ok() + }); + let (source, scoped) = match config.as_ref().and_then(|c| c.ignore.clone()) { + Some(rules) => (Source::File, rules), + None => (Source::Project, super::projects::ignore_rules(project)), + }; + let rules = scoped.into_iter().map(|r| (config::glob(&r.snapshots).ok(), r)).collect(); + let thresholds = match config.as_ref().and_then(|c| c.threshold.clone()) { + Some(Threshold::All(t)) => vec![("**".to_string(), t)], + Some(Threshold::ByGlob(map)) => map.into_iter().collect(), + None => vec![], + } + .into_iter() + .filter_map(|(g, t)| config::glob(&g).ok().map(|m| (m, g, t))) + .collect(); + Self { project, config, source, rules, thresholds } + } + + /// The scoped ignore rules in force: the file's when it has `ignore`, else the project's. + pub fn scoped_rules(&self) -> (Source, Vec) { + (self.source, self.rules.iter().map(|(_, r)| r.clone()).collect()) + } + + /// Every ignore rule that applies to a snapshot, with its source. + pub fn applied_rules(&self, snapshot: &Snapshot) -> Vec { + let mut out: Vec = self + .rules + .iter() + .filter(|(m, _)| m.as_ref().is_some_and(|m| m.is_match(&snapshot.name))) + .map(|(_, r)| AppliedRule { + source: self.source, + snapshots: Some(r.snapshots.clone()), + json_paths: r.json_paths.clone(), + text_patterns: r.text_patterns.clone(), + }) + .collect(); + let own: IgnoreRules = serde_json::from_value(snapshot.ignore_rules.clone()).unwrap_or_default(); + if !own.is_empty() { + out.push(AppliedRule { + source: Source::Test, + snapshots: None, + json_paths: own.json_paths, + text_patterns: own.text_patterns, + }); + } + out + } + + /// The ignore rules for a snapshot, parsed. They're applied to both sides of the comparison, so a newly ignored + /// value stops showing as a change without approving the baseline again. Each rule is parsed on its own, so a + /// rule that no longer parses is skipped (and logged) without dropping the others. + pub fn compiled_rules(&self, snapshot: &Snapshot) -> CompiledRules { + let mut out = CompiledRules::default(); + for r in self.applied_rules(snapshot) { + let rules = IgnoreRules { json_paths: r.json_paths, text_patterns: r.text_patterns }; + match rules.compile() { + Ok(c) => out.extend(c), + Err(e) => { + tracing::warn!(snapshot = snapshot.id, rule = ?r.snapshots, error = %e, "skipping an invalid ignore rule") + } + } + } + out + } + + /// The file's threshold for a snapshot name: the longest matching glob's. + fn file_threshold(&self, name: &str) -> Option { + self.thresholds.iter().filter(|(m, _, _)| m.is_match(name)).max_by_key(|(_, g, _)| g.len()).map(|(_, _, t)| *t) + } + + /// Diff options for a snapshot: its own threshold, else the file's for its name, else the project's. + pub fn diff_options(&self, snapshot: &Snapshot) -> visualci_core::diff::DiffOptions { + let threshold = snapshot.threshold.or_else(|| self.file_threshold(&snapshot.name)); + super::projects::diff_options(self.project, threshold, snapshot.ignore_anti_aliasing) + } + + /// The render cache key for a document: the snapshot's engine, else the file's, else the project's, at the file's + /// DPI or the project's. + pub fn renderer_key(&self, engine: Option<&str>, renderer_version: &str) -> String { + let pdf = self.config.as_ref().and_then(|c| c.pdf.as_ref()); + let engine = engine + .map(str::to_string) + .or_else(|| pdf.and_then(|p| p.engine).map(|e| e.as_str().to_string())) + .unwrap_or_else(|| self.project.renderer.clone()); + let dpi = pdf.and_then(|p| p.dpi).unwrap_or(self.project.dpi); + super::projects::renderer_key(&engine, dpi, renderer_version) + } + + /// The CI mode: the file's when it's stricter than the project's (review, then wait, then strict), else the + /// project's. The file can't loosen it. + pub fn ci_mode(&self) -> &str { + match self.config.as_ref().and_then(|c| c.ci_mode) { + Some(m) if strictness(m.as_str()) >= strictness(&self.project.ci_mode) => m.as_str(), + _ => self.project.ci_mode.as_str(), + } + } + + /// Warnings about the file that don't stop the build. + pub fn config_warnings(&self) -> Vec { + let mut out = Vec::new(); + if let Some(m) = self.config.as_ref().and_then(|c| c.ci_mode) + && strictness(m.as_str()) < strictness(&self.project.ci_mode) + { + out.push(format!( + "visualci.yml sets ci_mode: {}, but the project's mode is {}. The file can only make the mode \ + stricter, so {} applies.", + m.as_str(), + self.project.ci_mode, + self.project.ci_mode + )); + } + out + } + + /// The scoped ignore rules whose globs matched none of these snapshot names. + pub fn unmatched_rules<'n>(&self, names: impl IntoIterator + Clone) -> Vec<&ScopedIgnoreRule> { + self.rules + .iter() + .filter(|(m, _)| !names.clone().into_iter().any(|n| m.as_ref().is_some_and(|m| m.is_match(n)))) + .map(|(_, r)| r) + .collect() + } + + /// The settings that decide what counts as a change, as JSON: the ignore rules and thresholds in force. Shown as + /// the "visualci.yml" item when they hide more than the base build's. + pub fn review_settings(&self) -> serde_json::Value { + let threshold: serde_json::Value = if self.thresholds.is_empty() { + serde_json::json!(self.project.threshold) + } else { + self.thresholds + .iter() + .map(|(_, g, t)| (g.clone(), serde_json::json!(t))) + .collect::>() + .into() + }; + serde_json::json!({ + "ignore": self.rules.iter().map(|(_, r)| r).collect::>(), + "ignore_from": self.source, + "threshold": threshold, + }) + } + + /// Whether these settings could hide a change the base build's settings would show: an ignore rule (glob and path + /// or pattern) the base didn't have, or a higher threshold for some glob. + pub fn hides_more_than(&self, base: &BuildSettings<'_>) -> bool { + let pairs = |s: &BuildSettings<'_>| -> std::collections::HashSet<(String, String)> { + s.rules + .iter() + .flat_map(|(_, r)| { + r.json_paths + .iter() + .map(|p| (r.snapshots.clone(), format!("json:{p}"))) + .chain(r.text_patterns.iter().map(|p| (r.snapshots.clone(), format!("text:{p}")))) + .collect::>() + }) + .collect() + }; + let base_pairs = pairs(base); + if pairs(self).iter().any(|p| !base_pairs.contains(p)) { + return true; + } + let base_threshold = |glob: &str| { + base.thresholds + .iter() + .find(|(_, g, _)| g == glob) + .or_else(|| base.thresholds.iter().find(|(_, g, _)| g == "**")) + .map_or(base.project.threshold, |(_, _, t)| *t) + }; + self.thresholds.iter().any(|(_, g, t)| *t > base_threshold(g) + f64::EPSILON) + } +} + +/// Validate a config a client sent with a new build. +/// +/// # Errors +/// A message that starts with `visualci.yml:`. +pub fn validate_config(value: &serde_json::Value) -> Result { + let config = Config::from_json(value).map_err(|e| format!("visualci.yml: {e}"))?; + serde_json::to_value(config).map_err(|e| format!("visualci.yml: {e}")) +} + +/// Validate a test's own ignore rules (unscoped: they apply to the one snapshot). +/// +/// # Errors +/// A message naming the invalid path or pattern. +pub fn validate_own_rules(rules: &IgnoreRules) -> Result<(), String> { + rules.compile().map(|_| ()) +} diff --git a/app/src/domain/builds.rs b/app/src/domain/builds.rs new file mode 100644 index 00000000..8fdc2696 --- /dev/null +++ b/app/src/domain/builds.rs @@ -0,0 +1,349 @@ +//! Builds: one CI (or local) run of a project. A build receives snapshots, waits for their renders, compares them with +//! its baselines and concludes `unchanged`, `changes` or `failed`. + +use laravel::db::{self, Json}; +use laravel::model::{create, update}; +use serde::{Deserialize, Serialize}; + +use super::build_settings::BuildSettings; +use crate::models::{Build, Project}; + +/// Credits, by what each thing costs to run. A snapshot check (the fingerprint lookup for every snapshot a build +/// sends, changed or not) is the unit. A text diff is cheap, an image diff costs more, drawing a PDF page the most. +pub const CREDITS_PER_SNAPSHOT_CHECK: i64 = 1; +/// A group whose hash matched its baseline's, or a whole build whose manifest matched. +pub const CREDITS_PER_GROUP_CHECK: i64 = 1; +pub const CREDITS_PER_TEXT_DIFF: i64 = 5; +pub const CREDITS_PER_IMAGE_DIFF: i64 = 10; +pub const CREDITS_PER_RENDERED_PAGE: i64 = 20; + +/// The most ancestor commits a build keeps. +pub const MAX_PARENT_COMMITS: usize = 200; + +#[derive(Clone, Debug, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct CreateParams { + pub commit: String, + pub branch: String, + #[serde(default, deserialize_with = "super::lenient::optional")] + pub pr_number: Option, + /// Ancestor commits, nearest first, for finding the baseline. + #[serde(default)] + pub parent_commits: Vec, + #[serde(default = "default_mode")] + pub mode: String, + #[serde(default = "default_name")] + pub name: String, + #[serde(default = "default_shards", deserialize_with = "super::lenient::number")] + pub shard_total: i32, + /// The build only has some of the project's snapshots: missing ones aren't "removed". + #[serde(default)] + pub subset: bool, + /// Parallel shards that each create the build pass the same nonce (the CI workflow's id, say) and all get the + /// same build back. + pub nonce: Option, + /// The repository's `visualci.yml`, as JSON. Its fields override the project's settings for this build. + #[serde(default)] + pub config: Option, + /// Where the build ran: `ci`, `local-mac`, `local-linux`. Screenshots keep a baseline set per environment. + /// Default: `ci` for CI builds, `local` for local ones. + #[serde(default)] + pub environment: Option, + /// Details for the UI: `{provider, job_url}` in CI, `{user, machine, dirty}` on a laptop. + #[serde(default)] + pub environment_info: Option, +} + +fn default_mode() -> String { + "ci".to_string() +} +fn default_name() -> String { + "default".to_string() +} +const fn default_shards() -> i32 { + 1 +} + +/// The longest reason a build may give for having no snapshots on purpose. +pub const EMPTY_REASON_MAX: usize = 200; + +/// Why a build that was sent no snapshots failed. +pub const EMPTY_BUILD: &str = "No snapshots were sent, so nothing was compared. Check the paths the upload was given \ + (or visualci.yml's uploads), or finalize with --allow-empty when an empty build is on \ + purpose."; + +#[derive(Clone, Debug, Default, Serialize, Deserialize)] +pub struct Stats { + pub total: usize, + pub unchanged: usize, + pub changed: usize, + pub added: usize, + pub removed: usize, + pub ignored: usize, + pub failed: usize, + pub pending: usize, + /// The "visualci.yml" item, when the build's settings hide more than its base's. Not counted in `total`. + #[serde(default)] + pub config: usize, +} + +impl Stats { + /// Everything that needs review: changed, added and removed snapshots, and a config change. + #[must_use] + pub fn changes(&self) -> usize { + self.changed + self.added + self.removed + self.config + } +} + +/// A request a client got wrong: the API answers 422 (or 409 for [`Invalid::Conflict`]) with the message. +#[derive(Debug)] +pub enum Invalid { + Message(String), + Conflict(String), +} + +impl std::fmt::Display for Invalid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::Message(m) | Self::Conflict(m) => f.write_str(m), + } + } +} + +/// The outcome of a domain call: `Err(Ok(invalid))` for the client's mistake, `Err(Err(e))` for the server's. +pub type Outcome = Result>; + +fn invalid(message: impl Into) -> Outcome { + Err(Ok(Invalid::Message(message.into()))) +} + +fn server(e: laravel::Error) -> Outcome { + Err(Err(e)) +} + +/// Make a build (or, for a nonce that already made one, return that build). +/// +/// # Errors +/// `Invalid` for bad parameters; else on a database error. +pub async fn create(project: &Project, params: &CreateParams, creator: Option) -> Outcome { + if !["ci", "local"].contains(¶ms.mode.as_str()) { + return invalid("mode must be ci or local"); + } + if params.commit.is_empty() || params.branch.is_empty() { + return invalid("commit and branch are required"); + } + if !(1..=1000).contains(¶ms.shard_total) { + return invalid("shard_total must be 1 to 1000"); + } + let environment = params + .environment + .clone() + .filter(|e| !e.is_empty()) + .unwrap_or_else(|| if params.mode == "ci" { "ci".into() } else { "local".into() }); + // A CI build's environment is ci and a local build's isn't, so a laptop's screenshots never land in CI's set. + let local_env = environment == "local" || environment.starts_with("local-"); + if (params.mode == "local" && environment == "ci") || (params.mode == "ci" && local_env) { + return invalid(format!( + "a {} build can't have environment {environment:?}: local builds can't use ci, and CI builds can't use a \ + local environment", + params.mode + )); + } + if !super::environments::valid(&environment) { + return invalid("environment must be lowercase letters, digits and dashes (ci, local-mac, local-linux)"); + } + let environment_info = match ¶ms.environment_info { + Some(v @ serde_json::Value::Object(_)) if v.to_string().len() <= 4096 => v.clone(), + Some(serde_json::Value::Null) | None => serde_json::json!({}), + Some(_) => return invalid("environment_info must be an object under 4 KB"), + }; + let config = match ¶ms.config { + Some(v) if !v.is_null() => match super::build_settings::validate_config(v) { + Ok(c) => Some(c), + Err(m) => return invalid(m), + }, + _ => None, + }; + let parents: Vec = params.parent_commits.iter().take(MAX_PARENT_COMMITS).cloned().collect(); + let project_id = project.id; + let made = db::transaction(async |_| { + // Numbering (and nonce lookups) one at a time per project. + db::query!("SELECT id FROM projects WHERE id = {project_id} FOR UPDATE").select().await?; + if let Some(nonce) = ¶ms.nonce { + let existing = Build::query() + .filter(Build::project_id.eq(project_id) & Build::nonce.eq(nonce.as_str())) + .first() + .await?; + if let Some(existing) = existing { + return Ok((existing, false)); + } + } + let next: i32 = + db::query!("SELECT (COALESCE(MAX(number), 0) + 1)::INT FROM builds WHERE project_id = {project_id}") + .scalar() + .await? + .unwrap_or(1); + let build = create!(Build { + pid: laravel::str::uuid7(), + project_id: project_id, + number: next, + name: params.name.as_str(), + nonce: params.nonce.clone(), + commit_sha: params.commit.as_str(), + branch: params.branch.as_str(), + pr_number: params.pr_number, + parent_commits: Json(parents.clone()), + mode: params.mode.as_str(), + subset: params.subset, + shard_total: params.shard_total, + config: config.clone(), + environment: environment.as_str(), + environment_info: environment_info.clone(), + created_by_user_id: creator, + base_build_id: None, + conclusion: None, + error: None, + finalized_at: None, + completed_at: None, + superseded_by_build_id: None, + forge_check_id: None, + error_code: None, + group_depth: None, + manifest_same_as_build_id: None, + empty_reason: None, + }) + .await?; + Ok((build, true)) + }) + .await; + let (mut build, new) = match made { + Ok(made) => made, + Err(e) => return server(e), + }; + if !new { + return Ok(build); + } + // Warnings the CLI prints when the build is created: a ci_mode the file can't loosen, a build from another + // repository than the project's. + let mut warnings = BuildSettings::new(project, &build).config_warnings(); + if let Some(w) = repository_warning(project, &build) { + warnings.push(w); + } + if !warnings.is_empty() { + let warnings = serde_json::json!(warnings); + if let Err(e) = update!(build { warnings }).await { + return server(e); + } + } + Ok(build) +} + +/// A CI build whose repository (as its CI named it) isn't the one the project links to: usually a project token copied +/// into another repository's CI. +fn repository_warning(project: &Project, build: &Build) -> Option { + let linked = crate::forge::Repository::parse(project.repository_url.as_deref()?)?; + let seen = crate::forge::Repository::parse(build.environment_info.get("repository_url")?.as_str()?)?; + (!seen.url.eq_ignore_ascii_case(&linked.url)).then(|| { + format!( + "this build came from {} but the project is linked to {}: check that the token belongs to this repository's project", + seen.url, linked.url + ) + }) +} + +/// Whether CI should treat the build as passing under the project's CI mode. `None` while it's still running or (in +/// `wait` mode) waiting for review. +#[must_use] +pub fn passed(build: &Build, ci_mode: &str) -> Option { + if build.state == "failed" { + return Some(false); + } + if build.state != "completed" { + return None; + } + match build.conclusion.as_deref() { + Some("failed") => Some(false), + Some("unchanged") | None => Some(true), + _ => match (ci_mode, build.review_state.as_str()) { + (_, "approved" | "auto_approved") => Some(true), + (_, "rejected") => Some(false), + ("strict", _) => Some(false), + ("wait", _) => None, + _ => Some(true), + }, + } +} + +/// Whether the build can be reviewed now (it has finished comparing). +#[must_use] +pub fn reviewable(build: &Build) -> bool { + build.state == "completed" +} + +#[must_use] +pub fn stats(build: &Build) -> Stats { + serde_json::from_value(build.stats.clone()).unwrap_or_default() +} + +/// Whether this build waits for a review in a person's waiting lists: a CI build's pending changes wait for everyone, +/// a local build's only for the person whose run it was (never for a project token, `user` None). +#[must_use] +pub fn waits_for(build: &Build, user: Option) -> bool { + build.review_state == "pending" && (build.mode != "local" || (user.is_some() && build.created_by_user_id == user)) +} + +/// Let the build finish with no snapshots of its own, and say why ("inputs unchanged"). Only while it's receiving. +/// +/// # Errors +/// `Invalid` for a reason that's empty or longer than [`EMPTY_REASON_MAX`] characters. +pub async fn allow_empty_because(mut build: Build, reason: &str) -> Outcome { + let reason = reason.trim(); + if reason.is_empty() || reason.chars().count() > EMPTY_REASON_MAX { + return invalid(format!("empty_reason must be 1 to {EMPTY_REASON_MAX} characters, like \"inputs unchanged\"")); + } + if build.state != "receiving" { + return Ok(build); + } + let empty_reason = Some(reason.to_string()); + if let Err(e) = update!(build { allow_empty: true, empty_reason }).await { + return server(e); + } + Ok(build) +} + +/// Mark a shard finished. Returns the build, now `processing` when every shard has finished. +/// +/// # Errors +/// `Invalid` for a shard outside the build. +pub async fn finalize_shard(build: Build, shard: Option, allow_empty: bool) -> Outcome { + if build.state != "receiving" { + return Ok(build); + } + let shard = shard.unwrap_or(0); + if shard < 0 || shard >= build.shard_total { + return invalid(format!("shard {shard} is outside 0..{}", build.shard_total)); + } + let id = build.id; + let result = async { + // Any shard can say the build may be empty. + if allow_empty && !build.allow_empty { + db::query!("UPDATE builds SET allow_empty = true WHERE id = {id}").update().await?; + } + let shard_json = serde_json::json!([shard]); + db::query!( + "UPDATE builds SET shards_finalized = shards_finalized || {shard_json}, updated_at = now() \ + WHERE id = {id} AND NOT (shards_finalized @> {shard_json})" + ) + .update() + .await?; + db::query!( + "UPDATE builds SET state = 'processing', finalized_at = now(), updated_at = now() \ + WHERE id = {id} AND state = 'receiving' AND jsonb_array_length(shards_finalized) >= shard_total" + ) + .update() + .await?; + Build::find_or_fail(id).await + } + .await; + result.or_else(server) +} diff --git a/app/src/domain/credits.rs b/app/src/domain/credits.rs new file mode 100644 index 00000000..1fe803c5 --- /dev/null +++ b/app/src/domain/credits.rs @@ -0,0 +1,56 @@ +//! The credit ledger: pack credits on `organizations.credits_balance`, and one `credit_transactions` row per change. + +use laravel::db; + +/// Add (or, with a negative amount, take away) pack credits, recording the transaction. Returns the new balance. +/// +/// # Errors +/// When there's no such organization, or on a database error. +pub async fn add_credits( + organization_id: i64, + amount: i64, + kind: &str, + reference: Option<&str>, +) -> laravel::Result { + db::transaction(async |_| { + let balance: i64 = db::query!( + "UPDATE organizations SET credits_balance = credits_balance + {amount}, updated_at = now() \ + WHERE id = {organization_id} RETURNING credits_balance" + ) + .scalar() + .await? + .ok_or_else(|| laravel::Error::msg(format!("no organization {organization_id}")))?; + db::query!( + "INSERT INTO credit_transactions (organization_id, amount, balance_after, kind, reference) \ + VALUES ({organization_id}, {amount}, {balance}, {kind}, {reference})" + ) + .insert() + .await?; + Ok(balance) + }) + .await +} + +/// Credit a purchased pack once per reference (a Stripe invoice or checkout session). Returns whether it was added: +/// false when that reference was credited already. +/// +/// # Errors +/// On a database error. +pub async fn add_purchased_credits(organization_id: i64, credits: i64, reference: &str) -> laravel::Result { + let seen: Option = db::query!( + "SELECT id FROM credit_transactions WHERE organization_id = {organization_id} AND kind = 'purchase' \ + AND reference = {reference} LIMIT 1" + ) + .scalar() + .await?; + if seen.is_some() { + return Ok(false); + } + // Two callers that both checked before either inserted (a reload and its `invoice.paid` webhook): the unique index + // (`credit_transactions_purchase_once`) refuses the second, and its transaction adds nothing. + match add_credits(organization_id, credits, "purchase", Some(reference)).await { + Ok(_) => Ok(true), + Err(e) if e.to_string().contains("credit_transactions_purchase_once") => Ok(false), + Err(e) => Err(e), + } +} diff --git a/app/src/domain/environments.rs b/app/src/domain/environments.rs new file mode 100644 index 00000000..f6a1cd04 --- /dev/null +++ b/app/src/domain/environments.rs @@ -0,0 +1,36 @@ +//! Environments: where a build ran. Documents and text are the same everywhere and keep one shared baseline set +//! (environment `""`); screenshots keep a set per environment. + +/// The environment of the shared set (documents and text). +pub const SHARED: &str = ""; + +/// The environments the CLI detects. +pub const KNOWN: &[&str] = &["ci", "local-mac", "local-linux"]; + +/// Whether an environment name is acceptable: lowercase letters, digits and dashes, at most 40. +#[must_use] +pub fn valid(env: &str) -> bool { + !env.is_empty() + && env.len() <= 40 + && env.bytes().all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-') + && !env.starts_with('-') +} + +/// A snapshot's environment: the build's for screenshots, the shared set for documents and text. +#[must_use] +pub fn for_kind(kind: &str, build_environment: &str) -> String { + if kind == "image" { build_environment.to_string() } else { SHARED.to_string() } +} + +/// The environments a screenshot's baseline is looked for in, in order: its own, then the closest others. +#[must_use] +pub fn search_order(environment: &str) -> Vec { + let rest: &[&str] = match environment { + SHARED => return vec![SHARED.to_string()], + "local-linux" => &["ci", "local-mac"], + "local-mac" => &["ci", "local-linux"], + "ci" => &["local-linux", "local-mac"], + _ => &["ci", "local-linux", "local-mac"], + }; + std::iter::once(environment).chain(rest.iter().copied()).map(str::to_string).collect() +} diff --git a/app/src/domain/groups.rs b/app/src/domain/groups.rs new file mode 100644 index 00000000..9e0c075b --- /dev/null +++ b/app/src/domain/groups.rs @@ -0,0 +1,13 @@ +//! Build groups (sc-8868, docs/design-storage.md): a large suite's snapshot names in groups, each checked by hash +//! against its baseline, and read from the build that holds it when unchanged. + +use visualci_core::manifest::Grouping; + +/// The grouping a build used: the client's `group_depth`, else all but the last two path segments. +#[must_use] +pub fn grouping(depth: Option) -> Grouping { + match depth { + Some(n) if n > 0 => Grouping::Depth(usize::try_from(n).unwrap_or(1)), + _ => Grouping::AllButLastTwo, + } +} diff --git a/app/src/domain/lenient.rs b/app/src/domain/lenient.rs new file mode 100644 index 00000000..168af7d2 --- /dev/null +++ b/app/src/domain/lenient.rs @@ -0,0 +1,78 @@ +//! Numbers that may arrive as strings (`"12"` for 12) in the REST API's bodies: a client that quotes everything, or +//! builds its JSON from environment variables, gets the number it meant instead of "invalid type: string". A string +//! that isn't a number is still an error naming the field. MCP tools get the same from `mcp::coerce_numbers`. + +use std::{fmt::Display, str::FromStr}; + +use serde::{Deserialize, Deserializer, de::Error}; + +#[derive(Deserialize)] +#[serde(untagged)] +enum NumberOrString { + Number(T), + String(String), +} + +fn read(v: NumberOrString) -> Result +where + T::Err: Display, +{ + match v { + NumberOrString::Number(n) => Ok(n), + NumberOrString::String(s) => s.trim().parse().map_err(|e| format!("{s:?} isn't a number: {e}")), + } +} + +/// A number, or a string holding one. +/// +/// # Errors +/// When it's neither. +pub fn number<'de, D, T>(d: D) -> Result +where + D: Deserializer<'de>, + T: Deserialize<'de> + FromStr, + T::Err: Display, +{ + read(NumberOrString::::deserialize(d)?).map_err(D::Error::custom) +} + +/// An optional number, or a string holding one (`null` and a missing field are `None`). +/// +/// # Errors +/// When it's neither. +pub fn optional<'de, D, T>(d: D) -> Result, D::Error> +where + D: Deserializer<'de>, + T: Deserialize<'de> + FromStr, + T::Err: Display, +{ + match Option::>::deserialize(d)? { + None => Ok(None), + Some(v) => read(v).map(Some).map_err(D::Error::custom), + } +} + +#[cfg(test)] +mod tests { + #[derive(serde::Deserialize, Debug)] + struct Body { + #[serde(deserialize_with = "super::number")] + size: i64, + #[serde(default, deserialize_with = "super::optional")] + shard: Option, + #[serde(default, deserialize_with = "super::optional")] + threshold: Option, + } + + #[test] + fn reads_numbers_and_numeric_strings() { + let b: Body = serde_json::from_str(r#"{"size": "12", "shard": 3, "threshold": "0.1"}"#).unwrap(); + assert_eq!((b.size, b.shard, b.threshold), (12, Some(3), Some(0.1))); + let b: Body = serde_json::from_str(r#"{"size": 7}"#).unwrap(); + assert_eq!((b.size, b.shard, b.threshold), (7, None, None)); + let b: Body = serde_json::from_str(r#"{"size": 7, "shard": null}"#).unwrap(); + assert_eq!(b.shard, None); + let e = serde_json::from_str::(r#"{"size": "lots"}"#).unwrap_err(); + assert!(e.to_string().contains("\"lots\" isn't a number"), "{e}"); + } +} diff --git a/app/src/domain/mod.rs b/app/src/domain/mod.rs new file mode 100644 index 00000000..9a84771a --- /dev/null +++ b/app/src/domain/mod.rs @@ -0,0 +1,12 @@ +//! VisualCI's domain: builds, snapshots, baselines and the rules between them (sc-8900, the data side), on the +//! models in `crate::models`. + +pub mod blobs; +pub mod build_settings; +pub mod builds; +pub mod credits; +pub mod environments; +pub mod groups; +pub mod lenient; +pub mod projects; +pub mod snapshots; diff --git a/app/src/domain/projects.rs b/app/src/domain/projects.rs new file mode 100644 index 00000000..51397382 --- /dev/null +++ b/app/src/domain/projects.rs @@ -0,0 +1,41 @@ +//! Project settings the domain reads. + +use visualci_core::config::ScopedIgnoreRule; + +use crate::models::Project; + +/// The project's default ignore rules for text snapshots, each scoped to a snapshot glob. A build's `visualci.yml` +/// replaces them when it has `ignore`. A stored rule that no longer reads is skipped on its own. +#[must_use] +pub fn ignore_rules(project: &Project) -> Vec { + let serde_json::Value::Array(items) = &project.ignore_rules else { return vec![] }; + items + .iter() + .filter_map(|v| { + serde_json::from_value::(v.clone()) + .inspect_err( + |e| tracing::warn!(project = project.id, rule = %v, error = %e, "skipping a stored ignore rule"), + ) + .ok() + }) + .collect() +} + +/// Diff options for a snapshot, from its own overrides or the project's defaults. +#[must_use] +pub fn diff_options( + project: &Project, + threshold: Option, + ignore_anti_aliasing: Option, +) -> visualci_core::diff::DiffOptions { + visualci_core::diff::DiffOptions { + threshold: threshold.unwrap_or(project.threshold), + ignore_anti_aliasing: ignore_anti_aliasing.unwrap_or(project.ignore_anti_aliasing), + } +} + +/// The render cache key: engine, DPI and renderer version. +#[must_use] +pub fn renderer_key(engine: &str, dpi: i32, renderer_version: &str) -> String { + format!("{engine}/{dpi}dpi/{renderer_version}") +} diff --git a/app/src/domain/snapshots.rs b/app/src/domain/snapshots.rs new file mode 100644 index 00000000..2dd57ac2 --- /dev/null +++ b/app/src/domain/snapshots.rs @@ -0,0 +1,242 @@ +//! Snapshots: one named item in a build (a document, an image or a text), and how it compares with its baseline. + +use laravel::db; +use serde::Deserialize; +use visualci_core::snapshot_text::{Format, IgnoreRules}; + +use crate::models::{Build, Render, Snapshot}; + +pub const KINDS: &[&str] = &["document", "image", "text"]; + +/// The content types an image snapshot may have. +pub const IMAGE_TYPES: &[&str] = &["image/png", "image/jpeg", "image/webp"]; + +/// The platform of the "visualci.yml" item a build gets when its settings hide more than its base build's. Clients +/// can't use it. +pub const CONFIG_PLATFORM: &str = "visualci"; +pub const CONFIG_NAME: &str = "visualci.yml"; + +/// A snapshot as a client registers it. +#[derive(Clone, Debug, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct SnapshotParams { + pub name: String, + #[serde(default)] + pub platform: String, + pub kind: String, + /// Documents: the PDF fingerprint. Images: the pixel fingerprint. Text: the SHA-256 of the text. + pub fingerprint: String, + /// SHA-256 of the file's bytes. + pub sha256: String, + #[serde(deserialize_with = "super::lenient::number")] + pub size: i64, + pub content_type: String, + #[serde(default, deserialize_with = "super::lenient::optional")] + pub threshold: Option, + pub ignore_anti_aliasing: Option, + /// Documents: the render engine (`pdfbox` or `mutool`), overriding the project's. + pub engine: Option, + /// Text: `text`, `json` or `html`. Without it, the content type decides (`application/json`, `text/html`). + #[serde(default)] + pub format: Option, + #[serde(default)] + pub meta: serde_json::Value, + /// Ignore rules set in the test, for this snapshot only: `{json_paths, text_patterns}`. + #[serde(default)] + pub ignore: Option, +} + +/// Part of the error for a snapshot name sent twice to one build with different content (the API answers 409). +pub const ALREADY_UPLOADED: &str = "already uploaded to this build"; + +impl SnapshotParams { + /// # Errors + /// A message for the client when a field is invalid. + pub fn validate(&self) -> std::result::Result<(), String> { + let hex64 = |s: &str| s.len() == 64 && s.bytes().all(|b| b.is_ascii_hexdigit()); + if self.name.trim().is_empty() || self.name.len() > 500 { + return Err(format!("snapshot name must be 1 to 500 characters: {:?}", self.name)); + } + if self.platform.len() > 200 { + return Err(format!("{}: platform is too long", self.name)); + } + if self.platform == CONFIG_PLATFORM { + return Err(format!("{}: the platform {CONFIG_PLATFORM:?} is reserved", self.name)); + } + if !KINDS.contains(&self.kind.as_str()) { + return Err(format!("{}: kind must be one of {KINDS:?}", self.name)); + } + // Images are served back (the gallery, on the app's own origin): only image types, never one a browser would + // run. + if self.kind == "image" && !IMAGE_TYPES.contains(&self.content_type.as_str()) { + return Err(format!("{}: an image's content_type must be one of {IMAGE_TYPES:?}", self.name)); + } + if self.size <= 0 || u64::try_from(self.size).is_ok_and(|s| s > crate::storage::blobs::MAX_BLOB_BYTES) { + return Err(format!( + "{}: size must be between 1 and {} bytes", + self.name, + crate::storage::blobs::MAX_BLOB_BYTES + )); + } + if !hex64(&self.sha256) || !hex64(&self.fingerprint) { + return Err(format!("{}: sha256 and fingerprint must be hex SHA-256 digests", self.name)); + } + if let Some(e) = &self.engine + && !["pdfbox", "mutool"].contains(&e.as_str()) + { + return Err(format!("{}: engine must be pdfbox or mutool", self.name)); + } + if let Some(t) = self.threshold + && !(0.0..=1.0).contains(&t) + { + return Err(format!("{}: threshold must be between 0 and 1", self.name)); + } + if let Some(f) = &self.format + && Format::parse(f).is_none() + { + return Err(format!("{}: format must be one of {:?}", self.name, Format::ALL)); + } + if let Some(rules) = &self.ignore { + super::build_settings::validate_own_rules(rules).map_err(|e| format!("{}: ignore: {e}", self.name))?; + } + Ok(()) + } + + /// A text snapshot's format: the explicit one, else from the content type, else from the name's extension. + pub fn text_format(&self) -> Option { + (self.kind == "text") + .then(|| Format::detect(self.format.as_deref(), Some(&self.content_type), Some(&self.name))) + } +} + +/// What a client must do for a registered snapshot. +pub struct Registration { + pub snapshot: Snapshot, + /// Upload the file: its blob isn't stored yet and no render of it exists. + pub needs_upload: bool, +} + +/// A usable render of this source with these settings, if one exists: done, queued or rendering. +/// +/// # Errors +/// On a database error. +pub async fn usable_render(project_id: i64, fingerprint: &str, renderer: &str) -> laravel::Result> { + Render::query() + .filter( + Render::project_id.eq(project_id) + & Render::source_fingerprint.eq(fingerprint) + & Render::renderer.eq(renderer) + & Render::state.ne("failed"), + ) + .first() + .await +} + +/// Record a snapshot in a build (replacing one with the same name and platform), and say whether its file must be +/// uploaded. The same name twice with the same file is a retry and fine; other content is a naming bug in the suite +/// (two jobs or shards sending one name), refused with [`ALREADY_UPLOADED`] in the message. +/// +/// # Errors +/// `Ok(Err(message))` for a conflict; `Err` on a database error. +pub async fn register( + build: &Build, + settings: &super::build_settings::BuildSettings<'_>, + renderer_version: &str, + params: &SnapshotParams, +) -> laravel::Result> { + let earlier = Snapshot::query() + .filter( + Snapshot::build_id.eq(build.id) + & Snapshot::name.eq(params.name.as_str()) + & Snapshot::platform.eq(params.platform.as_str()), + ) + .first() + .await?; + if let Some(e) = earlier + && !e.carried_forward + && e.source_blob.as_deref() != Some(params.sha256.as_str()) + { + let platform = if params.platform.is_empty() { String::new() } else { format!(" ({})", params.platform) }; + return Ok(Err(format!( + "{}{platform} was {ALREADY_UPLOADED} with other content: snapshot names must be unique across a build's \ + jobs and shards", + params.name + ))); + } + let renderer_key = settings.renderer_key(params.engine.as_deref(), renderer_version); + let render = if params.kind == "document" { + usable_render(build.project_id, ¶ms.fingerprint, &renderer_key).await? + } else { + None + }; + let blob = super::blobs::register(¶ms.sha256, params.size, ¶ms.content_type).await?; + let needs_upload = render.is_none() && !super::blobs::is_uploaded(&blob); + + let pid = laravel::str::uuid7(); + let build_id = build.id; + let group_key = super::groups::grouping(build.group_depth).key(¶ms.name); + let format = params.text_format().map(|f| f.as_str().to_string()); + let render_id = render.as_ref().map(|r| r.id); + let meta = if params.meta.is_null() { serde_json::json!({}) } else { params.meta.clone() }; + let ignore_rules = serde_json::to_value(params.ignore.clone().unwrap_or_default()).unwrap_or_default(); + let environment = super::environments::for_kind(¶ms.kind, &build.environment); + let (name, platform, kind, fingerprint, sha256, engine, threshold, aa) = ( + ¶ms.name, + ¶ms.platform, + ¶ms.kind, + ¶ms.fingerprint, + ¶ms.sha256, + ¶ms.engine, + params.threshold, + params.ignore_anti_aliasing, + ); + db::query!( + "INSERT INTO snapshots (pid, build_id, group_key, name, platform, kind, format, source_fingerprint, source_blob, \ + render_id, engine, threshold, ignore_anti_aliasing, meta, ignore_rules, environment, state, \ + matched_environment, baseline_id) \ + VALUES ({pid}, {build_id}, {group_key}, {name}, {platform}, {kind}, {format}, {fingerprint}, {sha256}, \ + {render_id}, {engine}, {threshold}, {aa}, {meta}, {ignore_rules}, {environment}, 'pending', NULL, NULL) \ + ON CONFLICT (build_id, name, platform) DO UPDATE SET kind = EXCLUDED.kind, format = EXCLUDED.format, \ + source_fingerprint = EXCLUDED.source_fingerprint, source_blob = EXCLUDED.source_blob, \ + render_id = EXCLUDED.render_id, engine = EXCLUDED.engine, threshold = EXCLUDED.threshold, \ + ignore_anti_aliasing = EXCLUDED.ignore_anti_aliasing, meta = EXCLUDED.meta, \ + ignore_rules = EXCLUDED.ignore_rules, environment = EXCLUDED.environment, state = EXCLUDED.state, \ + matched_environment = NULL, baseline_id = NULL, group_key = EXCLUDED.group_key, updated_at = now()" + ) + .insert() + .await?; + let snapshot = Snapshot::query() + .filter( + Snapshot::build_id.eq(build_id) + & Snapshot::name.eq(name.as_str()) + & Snapshot::platform.eq(platform.as_str()), + ) + .first() + .await? + .ok_or_else(|| laravel::Error::msg("the registered snapshot wasn't saved"))?; + Ok(Ok(Registration { snapshot, needs_upload })) +} + +/// A text snapshot's format (`None` for documents and images). Plain text when none was stored. +#[must_use] +pub fn text_format(snapshot: &Snapshot) -> Option { + (snapshot.kind == "text").then(|| snapshot.format.as_deref().and_then(Format::parse).unwrap_or(Format::Text)) +} + +/// Whether this is the build's "visualci.yml" item. +#[must_use] +pub fn is_config_item(snapshot: &Snapshot) -> bool { + snapshot.platform == CONFIG_PLATFORM +} + +/// Whether a snapshot's state needs a person to look at it. +#[must_use] +pub fn is_change(snapshot: &Snapshot) -> bool { + matches!(snapshot.state.as_str(), "changed" | "added" | "removed") +} + +/// Ignore rules set in the test for this snapshot. +#[must_use] +pub fn own_ignore_rules(snapshot: &Snapshot) -> IgnoreRules { + serde_json::from_value(snapshot.ignore_rules.clone()).unwrap_or_default() +} diff --git a/app/src/http/api.rs b/app/src/http/api.rs deleted file mode 100644 index ec4c7bd4..00000000 --- a/app/src/http/api.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! The REST API, under `/api` (`/api/v1/...`). - -use laravel::prelude::*; -use serde_json::json; - -pub fn routes(route: &mut Router) { - route.get("/v1/version", async || { - Json(json!({ "visualci": env!("CARGO_PKG_VERSION"), "laravel": laravel::VERSION })) - }); - route.get("/v1/whoami", crate::auth::whoami); - route.fallback(async || laravel::abort(404)); -} diff --git a/app/src/http/api/builds.rs b/app/src/http/api/builds.rs new file mode 100644 index 00000000..d0ecb5ef --- /dev/null +++ b/app/src/http/api/builds.rs @@ -0,0 +1,227 @@ +//! Builds over the CI API: create, register snapshots (with upload URLs for new files), finalize, and show. + +use axum::response::Response; +use laravel::prelude::*; +use laravel::str::Uuid; +use serde::{Deserialize, Serialize}; + +use super::{ApiError, ApiProject, Body}; +use crate::auth::{Principal, Via}; +use crate::domain::build_settings::BuildSettings; +use crate::domain::builds::{self as domain, CreateParams, Stats}; +use crate::domain::snapshots::SnapshotParams; +use crate::models::{Build, Organization, Project}; +use crate::storage::BlobStore; + +pub fn routes(route: &mut Router) { + route.post("/v1/builds", create); + route.get("/v1/builds/{pid}", show); + route.post("/v1/builds/{pid}/snapshots", add_snapshots); + route.post("/v1/builds/{pid}/finalize", finalize); +} + +/// The renderer version documents are drawn with: part of the render cache key. +#[must_use] +pub fn renderer_version() -> String { + std::env::var("VISUALCI_RENDERER_VERSION").unwrap_or_else(|_| "1".to_string()) +} + +/// The web app's address, for links (`APP_URL`). +#[must_use] +pub fn app_url() -> String { + laravel::config().app.url.trim_end_matches('/').to_string() +} + +/// A build as the CI API answers it. +#[derive(Debug, Serialize)] +pub struct BuildResponse { + pub id: Uuid, + pub number: i32, + pub project: String, + pub state: String, + pub review_state: String, + pub conclusion: Option, + pub ci_mode: String, + /// Whether CI should pass, under the project's CI mode. `null` while running (or waiting for review in `wait` + /// mode). + pub passed: Option, + pub stats: Stats, + pub error: Option, + pub url: String, + /// Things to point out about the build's settings: a ci_mode visualci.yml can't loosen, ignore rules that + /// matched nothing. + pub warnings: Vec, + /// Whether it has finished comparing and can be reviewed. + pub reviewable: bool, + /// Set when the build can't be compared because its organization is out of credits. + pub blocked: Option, +} + +impl BuildResponse { + #[must_use] + pub fn new(build: &Build, project: &Project, organization: &Organization) -> Self { + let settings = BuildSettings::new(project, build); + Self { + id: build.pid, + number: build.number, + project: format!("{}/{}", organization.slug, project.slug), + state: build.state.clone(), + review_state: build.review_state.clone(), + conclusion: build.conclusion.clone(), + ci_mode: settings.ci_mode().to_string(), + passed: domain::passed(build, settings.ci_mode()), + stats: domain::stats(build), + error: build.error.clone(), + url: format!("{}/{}/{}/builds/{}", app_url(), organization.slug, project.slug, build.number), + warnings: serde_json::from_value(build.warnings.clone()).unwrap_or_default(), + reviewable: domain::reviewable(build), + blocked: None, + } + } +} + +fn respond(result: Result) -> Response { + match result { + Ok(body) => axum::response::IntoResponse::into_response(axum::Json(body)), + Err(e) => axum::response::IntoResponse::into_response(e), + } +} + +/// The project's build with this id. +async fn own_build(project: &Project, pid: Uuid) -> Result { + Build::query() + .filter(Build::pid.eq(pid) & Build::project_id.eq(project.id)) + .first() + .await? + .ok_or_else(ApiError::not_found) +} + +/// `POST /api/v1/builds`. +pub async fn create(auth: Result, Body(params): Body) -> Response { + respond( + async { + let ApiProject { project, organization, principal } = auth?; + // A person's token: the build is theirs (a local one waits for review in their lists only). + let creator = match &principal { + Principal::User { user, via: Via::Token { .. } } => Some(user.id), + _ => None, + }; + let build = domain::create(&project, ¶ms, creator).await.map_err(ApiError::from)?; + Ok(BuildResponse::new(&build, &project, &organization)) + } + .await, + ) +} + +/// `GET /api/v1/builds/{pid}`. +pub async fn show(auth: Result, Params(pid): Params) -> Response { + respond( + async { + let ApiProject { project, organization, .. } = auth?; + let build = own_build(&project, pid).await?; + Ok(BuildResponse::new(&build, &project, &organization)) + } + .await, + ) +} + +#[derive(Debug, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct SnapshotsParams { + snapshots: Vec, +} + +#[derive(Debug, Serialize)] +struct SnapshotUpload { + name: String, + platform: String, + /// PUT the file here, with this content type. `null` when the server already has it. + upload_url: Option, + content_type: String, +} + +#[derive(Debug, Serialize)] +struct SnapshotsResponse { + snapshots: Vec, +} + +/// `POST /api/v1/builds/{pid}/snapshots`: register up to 1000 snapshots, with an upload URL for each new file. +pub async fn add_snapshots( + auth: Result, + Params(pid): Params, + Body(params): Body, +) -> Response { + respond( + async { + let ApiProject { project, .. } = auth?; + if params.snapshots.len() > 1000 { + return Err(ApiError::bad_request("send at most 1000 snapshots per request")); + } + let store = BlobStore::current()?; + let build = own_build(&project, pid).await?; + if build.state != "receiving" { + return Err(ApiError::bad_request(format!( + "build {} is {}, not receiving snapshots", + build.number, build.state + ))); + } + let settings = BuildSettings::new(&project, &build); + let version = renderer_version(); + let mut snapshots = Vec::with_capacity(params.snapshots.len()); + for p in ¶ms.snapshots { + p.validate().map_err(ApiError::bad_request)?; + let registration = crate::domain::snapshots::register(&build, &settings, &version, p) + .await? + .map_err(ApiError::conflict)?; + snapshots.push(SnapshotUpload { + name: registration.snapshot.name.clone(), + platform: registration.snapshot.platform.clone(), + upload_url: if registration.needs_upload { Some(store.upload_url(&p.sha256)?) } else { None }, + content_type: p.content_type.clone(), + }); + } + Ok(SnapshotsResponse { snapshots }) + } + .await, + ) +} + +#[derive(Debug, Default, Deserialize)] +#[serde(deny_unknown_fields)] +struct FinalizeParams { + #[serde(default, deserialize_with = "crate::domain::lenient::optional")] + shard: Option, + /// The build may have no snapshots on purpose; otherwise one that was sent none fails. + #[serde(default)] + allow_empty: bool, + /// Why it has none ("inputs unchanged"): implies allow_empty, and shows in the build's summary. + #[serde(default)] + empty_reason: Option, +} + +/// `POST /api/v1/builds/{pid}/finalize`: a shard (or the build) has sent everything. An empty body is allowed. +pub async fn finalize( + auth: Result, + Params(pid): Params, + body: axum::body::Bytes, +) -> Response { + respond( + async { + let ApiProject { project, organization, .. } = auth?; + let build = own_build(&project, pid).await?; + let params: FinalizeParams = if body.iter().all(u8::is_ascii_whitespace) { + FinalizeParams::default() + } else { + serde_json::from_slice(&body).map_err(|e| ApiError::unreadable(&e))? + }; + let build = match params.empty_reason.as_deref() { + Some(reason) => domain::allow_empty_because(build, reason).await.map_err(ApiError::from)?, + None => build, + }; + let allow_empty = params.allow_empty || params.empty_reason.is_some(); + let build = domain::finalize_shard(build, params.shard, allow_empty).await.map_err(ApiError::from)?; + Ok(BuildResponse::new(&build, &project, &organization)) + } + .await, + ) +} diff --git a/app/src/http/api/mod.rs b/app/src/http/api/mod.rs new file mode 100644 index 00000000..ec458fd2 --- /dev/null +++ b/app/src/http/api/mod.rs @@ -0,0 +1,164 @@ +//! The REST API, under `/api` (`/api/v1/...`): the CLI's and client libraries'. Answers and errors keep today's JSON +//! (the golden files in tests/golden): errors are `{"error": , "description": }`, and an unreadable body +//! is a 422 `{"error": "invalid body: …"}`. + +pub mod builds; + +use axum::extract::FromRequestParts; +use axum::http::StatusCode; +use axum::http::request::Parts; +use laravel::prelude::*; +use serde_json::json; + +use crate::auth::{Principal, Role}; +use crate::models::{Organization, Project}; + +pub fn routes(route: &mut Router) { + route.get("/v1/version", async || { + Json(json!({ "visualci": env!("CARGO_PKG_VERSION"), "laravel": laravel::VERSION })) + }); + route.get("/v1/whoami", crate::auth::whoami); + builds::routes(route); + route.fallback(async || laravel::abort(404)); +} + +/// An API error, in today's JSON. +#[derive(Debug)] +pub struct ApiError { + status: StatusCode, + body: serde_json::Value, +} + +impl ApiError { + #[must_use] + pub fn bad_request(message: impl Into) -> Self { + Self { status: StatusCode::BAD_REQUEST, body: json!({ "error": "Bad Request", "description": message.into() }) } + } + + #[must_use] + pub fn conflict(message: impl Into) -> Self { + Self { status: StatusCode::CONFLICT, body: json!({ "error": "conflict", "description": message.into() }) } + } + + #[must_use] + pub fn unauthorized(message: impl Into) -> Self { + Self { + status: StatusCode::UNAUTHORIZED, + body: json!({ "error": "unauthorized", "description": message.into() }), + } + } + + #[must_use] + pub fn not_found() -> Self { + Self { + status: StatusCode::NOT_FOUND, + body: json!({ "error": "not_found", "description": "Resource was not found" }), + } + } + + #[must_use] + pub fn unreadable(e: &serde_json::Error) -> Self { + Self { status: StatusCode::UNPROCESSABLE_ENTITY, body: json!({ "error": format!("invalid body: {e}") }) } + } + + #[must_use] + pub fn server(e: &laravel::Error) -> Self { + tracing::error!(error = %e, "API request failed"); + Self { + status: StatusCode::INTERNAL_SERVER_ERROR, + body: json!({ "error": "internal_server_error", "description": "Internal Server Error" }), + } + } +} + +impl From for ApiError { + fn from(e: laravel::Error) -> Self { + Self::server(&e) + } +} + +impl From> for ApiError { + fn from(e: Result) -> Self { + match e { + Ok(crate::domain::builds::Invalid::Message(m)) => Self::bad_request(m), + Ok(crate::domain::builds::Invalid::Conflict(m)) => Self::conflict(m), + Err(e) => Self::server(&e), + } + } +} + +impl axum::response::IntoResponse for ApiError { + fn into_response(self) -> axum::response::Response { + axum::response::IntoResponse::into_response((self.status, axum::Json(self.body))) + } +} + +/// A JSON body, read strictly: a field the endpoint doesn't take, a missing one or a wrong type is a 422 that says +/// which, never ignored. The request structs deny unknown fields. +pub struct Body(pub T); + +impl axum::extract::FromRequest for Body { + type Rejection = axum::response::Response; + + async fn from_request(request: axum::extract::Request, state: &S) -> Result { + use axum::response::IntoResponse as _; + let bytes = axum::body::Bytes::from_request(request, state).await.map_err(|e| e.into_response())?; + serde_json::from_slice(&bytes).map(Body).map_err(|e| ApiError::unreadable(&e).into_response()) + } +} + +/// The header that names the project (`org/project`) when the token is a person's rather than a project's. +pub const PROJECT_HEADER: &str = "x-visualci-project"; + +/// The project a CI request is for: a project token's own, or for a personal token the project the +/// `X-VisualCI-Project` header names, when its person may send builds there (member or admin). +pub struct ApiProject { + pub project: Project, + pub organization: Organization, + pub principal: Principal, +} + +impl FromRequestParts for ApiProject { + type Rejection = ApiError; + + async fn from_request_parts(parts: &mut Parts, state: &S) -> Result { + let has_token = parts.headers.get(axum::http::header::AUTHORIZATION).is_some(); + let principal = Principal::from_request_parts(parts, state) + .await + .map_err(|_| ApiError::unauthorized(if has_token { "invalid token" } else { "missing project token" }))?; + let project = match &principal { + Principal::Project { project_id, .. } => { + Project::find(*project_id).await?.ok_or_else(ApiError::not_found)? + } + Principal::User { .. } => { + let named = parts.headers.get(PROJECT_HEADER).and_then(|v| v.to_str().ok()).ok_or_else(|| { + ApiError::bad_request( + "a personal access token needs the project: set `project: org/project` in visualci.yml or \ + pass --project", + ) + })?; + let (org, slug) = + named.split_once('/').ok_or_else(|| ApiError::bad_request("the project is org/project"))?; + let project = project_by_slugs(org, slug).await?.ok_or_else(ApiError::not_found)?; + match principal.role_in(&project).await? { + Some(role) if role >= Role::Member => project, + Some(_) => return Err(ApiError::unauthorized("read-only members can't send builds")), + None => return Err(ApiError::not_found()), + } + } + }; + let organization = Organization::find(project.organization_id).await?.ok_or_else(ApiError::not_found)?; + Ok(Self { project, organization, principal }) + } +} + +/// A project by its organization's slug and its own. +/// +/// # Errors +/// On a database error. +pub async fn project_by_slugs(org: &str, slug: &str) -> laravel::Result> { + let Some(organization) = Organization::query().filter(Organization::slug.eq(org)).first().await? else { + return Ok(None); + }; + Project::query().filter(Project::organization_id.eq(organization.id) & Project::slug.eq(slug)).first().await +} diff --git a/app/src/lib.rs b/app/src/lib.rs index a9cd9a1f..ff3441bc 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -2,6 +2,7 @@ pub mod auth; pub mod config; +pub mod domain; pub mod forge; pub mod http; pub mod listeners; diff --git a/app/src/models/builds.rs b/app/src/models/builds.rs index 701d88b9..1ff79561 100644 --- a/app/src/models/builds.rs +++ b/app/src/models/builds.rs @@ -1,3 +1,4 @@ +use laravel::db::Json; use laravel::model::model; use laravel::str::Uuid; use laravel::time::Timestamp; @@ -16,7 +17,8 @@ pub struct Build { pub branch: String, pub pr_number: Option, #[default] - pub parent_commits: serde_json::Value, + /// Ancestor commits, nearest first, at most 200: JSON until laravel/rust-framework#527 (PostgreSQL arrays). + pub parent_commits: Json>, #[default] pub mode: String, #[default] @@ -26,7 +28,7 @@ pub struct Build { #[default] pub shard_total: i32, #[default] - pub shards_finalized: serde_json::Value, + pub shards_finalized: Json>, pub base_build_id: Option, #[default] pub review_state: String, diff --git a/app/src/models/reviews.rs b/app/src/models/reviews.rs index a973f2dc..1ce725e6 100644 --- a/app/src/models/reviews.rs +++ b/app/src/models/reviews.rs @@ -1,3 +1,4 @@ +use laravel::db::Json; use laravel::model::model; use laravel::time::Timestamp; @@ -9,7 +10,7 @@ pub struct Review { pub user_id: Option, pub action: String, #[default] - pub snapshot_ids: serde_json::Value, + pub snapshot_ids: Json>, pub created_at: Timestamp, pub updated_at: Timestamp, pub client_name: Option, diff --git a/app/src/testing.rs b/app/src/testing.rs index d629b476..db01bf8f 100644 --- a/app/src/testing.rs +++ b/app/src/testing.rs @@ -35,6 +35,7 @@ pub fn configure() -> ApplicationBuilder { ("S3_BUCKET", "visualci-test"), ("S3_ACCESS_KEY_ID", "visualci"), ("S3_SECRET_ACCESS_KEY", "visualci-dev-secret"), + ("APP_URL", "https://app.visualci.test"), ]) .with_env("DATABASE_URL", url) .refresh_database() diff --git a/app/tests/api_builds.rs b/app/tests/api_builds.rs new file mode 100644 index 00000000..49c2e6d3 --- /dev/null +++ b/app/tests/api_builds.rs @@ -0,0 +1,126 @@ +//! The CI API's builds: today's answers (tests/golden/api) for the same requests. + +mod golden; + +use app::testing::fixtures; +use laravel::db; +use laravel::testing::prelude::*; +use serde_json::{Value, json}; + +/// A project in a fresh organization (slugs like today's tests', `org-xxxxxxxx`), and a project token for it. +async fn project_token(slug: &str) -> laravel::Result<(String, i64)> { + let org_slug = format!("org-{}", &laravel::str::uuid7().simple().to_string()[24..]); + let org = fixtures::organization(&org_slug).await?; + let project = fixtures::project(&org, slug).await?; + let token = format!("vci_{}", laravel::str::uuid7().simple()); + let (hash, project_id) = (app::models::token_hash(&token), project.id); + db::query!( + "INSERT INTO project_tokens (project_id, name, token_hash, token_prefix, created_at, updated_at) \ + VALUES ({project_id}, 'CI', {hash}, 'vci_ab', now(), now())" + ) + .insert() + .await?; + Ok((token, project_id)) +} + +fn build_params(nonce: Option<&str>) -> Value { + json!({ "commit": "abc123", "branch": "main", "parent_commits": ["abc122"], "nonce": nonce }) +} + +#[laravel::test] +async fn shards_with_the_same_nonce_share_a_build(app: Application) -> laravel::Result<()> { + let (token, _) = project_token("pdfs").await?; + let auth = format!("Bearer {token}"); + let a = app.post("/api/v1/builds").header("authorization", &auth).json(build_params(Some("workflow-1"))).await; + a.assert_ok(); + let a = a.json().clone(); + let b = app + .post("/api/v1/builds") + .header("authorization", &auth) + .json(build_params(Some("workflow-1"))) + .await + .json() + .clone(); + let c = app.post("/api/v1/builds").header("authorization", &auth).json(build_params(None)).await.json().clone(); + golden::check("api", "shards_with_the_same_nonce_share_a_build", "post-builds", &a); + assert_eq!(a["id"], b["id"]); + assert_eq!(a["number"], 1); + assert_eq!(c["number"], 2); + Ok(()) +} + +#[laravel::test] +async fn a_snapshot_sent_twice_with_other_content_is_a_conflict(app: Application) -> laravel::Result<()> { + let (token, _) = project_token("pdfs").await?; + let auth = format!("Bearer {token}"); + let build = app.post("/api/v1/builds").header("authorization", &auth).json(build_params(None)).await.json().clone(); + let id = build["id"].as_str().unwrap().to_string(); + let body = |sha: char| { + json!({ "snapshots": [{ + "name": "invoice", "platform": "chrome", "kind": "image", "fingerprint": "b".repeat(64), + "sha256": sha.to_string().repeat(64), "size": 10, "content_type": "image/png" + }]}) + }; + let url = format!("/api/v1/builds/{id}/snapshots"); + app.post(&url).header("authorization", &auth).json(body('a')).await.assert_ok(); + app.post(&url).header("authorization", &auth).json(body('a')).await.assert_ok(); + let other = app.post(&url).header("authorization", &auth).json(body('c')).await; + other.assert_status(409); + assert!( + other.text().contains("invoice (chrome) was already uploaded to this build with other content"), + "{}", + other.text() + ); + Ok(()) +} + +#[laravel::test] +async fn registers_snapshots_and_asks_for_new_files(app: Application) -> laravel::Result<()> { + fixtures::blob_store().await?; + let (token, _) = project_token("pdfs").await?; + let auth = format!("Bearer {token}"); + let build = app.post("/api/v1/builds").header("authorization", &auth).json(build_params(None)).await.json().clone(); + let id = build["id"].as_str().unwrap().to_string(); + let sha = "a".repeat(64); + let url = format!("/api/v1/builds/{id}/snapshots"); + let response = app + .post(&url) + .header("authorization", &auth) + .json(json!({ "snapshots": [{ + "name": "invoice", "kind": "document", "fingerprint": "b".repeat(64), "sha256": sha, + "size": 1234, "content_type": "application/pdf", "engine": "mutool" + }]})) + .await; + response.assert_ok(); + golden::check("api", "registers_snapshots_and_asks_for_new_files", "post-snapshots", &response.json()); + + let bad = app + .post(&url) + .header("authorization", &auth) + .json(json!({ "snapshots": [{ + "name": "x", "kind": "movie", "fingerprint": "b".repeat(64), "sha256": sha, "size": 1, "content_type": "x" + }]})) + .await; + bad.assert_status(400); + golden::check("api", "registers_snapshots_and_asks_for_new_files", "post-snapshots-invalid-kind", &bad.json()); + Ok(()) +} + +#[laravel::test] +async fn a_token_names_its_project(app: Application) -> laravel::Result<()> { + app.post("/api/v1/builds").json(build_params(None)).await.assert_status(401); + app.post("/api/v1/builds") + .header("authorization", "Bearer vci_nope") + .json(build_params(None)) + .await + .assert_status(401); + let (token, _) = project_token("pdfs").await?; + let unknown = app + .post("/api/v1/builds") + .header("authorization", format!("Bearer {token}")) + .json(json!({ "commit": "a", "branch": "main", "comitt": "x" })) + .await; + unknown.assert_status(422); + assert!(unknown.text().contains("unknown field `comitt`"), "{}", unknown.text()); + Ok(()) +} diff --git a/app/tests/credits.rs b/app/tests/credits.rs new file mode 100644 index 00000000..77c7defe --- /dev/null +++ b/app/tests/credits.rs @@ -0,0 +1,19 @@ +//! The credit ledger. + +use app::domain::credits; +use app::testing::fixtures; +use laravel::db; +use laravel::testing::prelude::*; + +#[laravel::test] +async fn purchased_packs_are_credited_once_per_reference(_app: Application) -> laravel::Result<()> { + let org = fixtures::organization("acme").await?; + assert!(credits::add_purchased_credits(org.id, 500, "in_123").await?); + assert!(!credits::add_purchased_credits(org.id, 500, "in_123").await?, "the same invoice again adds nothing"); + assert_eq!(credits::add_credits(org.id, -100, "adjustment", None).await?, 400); + let id = org.id; + let rows: Option = + db::query!("SELECT COUNT(*) FROM credit_transactions WHERE organization_id = {id}").scalar().await?; + assert_eq!(rows, Some(2)); + Ok(()) +} diff --git a/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/get-snapshots.json b/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/get-snapshots.json new file mode 100644 index 00000000..7adfabad --- /dev/null +++ b/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/get-snapshots.json @@ -0,0 +1,49 @@ +{ + "snapshots": [ + { + "error": null, + "id": "", + "kind": "text", + "name": "api/response", + "platform": "", + "review": null, + "state": "pending" + }, + { + "error": null, + "id": "", + "kind": "document", + "name": "invoice", + "platform": "", + "review": null, + "state": "pending" + }, + { + "error": null, + "id": "", + "kind": "text", + "name": "log", + "platform": "", + "review": null, + "state": "pending" + }, + { + "error": null, + "id": "", + "kind": "text", + "name": "page.html", + "platform": "", + "review": null, + "state": "pending" + }, + { + "error": null, + "id": "", + "kind": "text", + "name": "tree", + "platform": "", + "review": null, + "state": "pending" + } + ] +} diff --git a/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots-invalid-kind.json b/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots-invalid-kind.json new file mode 100644 index 00000000..573fa606 --- /dev/null +++ b/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots-invalid-kind.json @@ -0,0 +1,4 @@ +{ + "description": "x: kind must be one of [\"document\", \"image\", \"text\"]", + "error": "Bad Request" +} diff --git a/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots.json b/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots.json new file mode 100644 index 00000000..da05b4b4 --- /dev/null +++ b/app/tests/golden/api/registers_snapshots_and_asks_for_new_files/post-snapshots.json @@ -0,0 +1,10 @@ +{ + "snapshots": [ + { + "content_type": "application/pdf", + "name": "invoice", + "platform": "", + "upload_url": "http://127.0.0.1:59000/visualci-test/blobs/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?" + } + ] +} diff --git a/app/tests/golden/api/shards_with_the_same_nonce_share_a_build/post-builds.json b/app/tests/golden/api/shards_with_the_same_nonce_share_a_build/post-builds.json new file mode 100644 index 00000000..7751923d --- /dev/null +++ b/app/tests/golden/api/shards_with_the_same_nonce_share_a_build/post-builds.json @@ -0,0 +1,26 @@ +{ + "blocked": null, + "ci_mode": "review", + "conclusion": null, + "error": null, + "id": "", + "number": 1, + "passed": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-2.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-2.json new file mode 100644 index 00000000..6ebd60d1 --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-2.json @@ -0,0 +1,68 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc", + "config": { + "ci_mode": "strict", + "ignore": [ + { + "json_paths": [ + "$.generated_at" + ], + "snapshots": "api/**" + } + ], + "pdf": { + "dpi": 200, + "engine": "mutool" + }, + "threshold": { + "screenshots/**": 0.2 + } + } + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"strict\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "strict", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-3.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-3.json new file mode 100644 index 00000000..6b004ddd --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-3.json @@ -0,0 +1,55 @@ +{ + "arguments": { + "branch": "main", + "commit": "lmn", + "config": { + "ci_mode": "review" + } + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"strict\",\"commit\":\"lmn\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[\"visualci.yml sets ci_mode: review, but the project's mode is strict. The file can only make the mode stricter, so strict applies.\"]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "strict", + "commit": "lmn", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [ + "visualci.yml sets ci_mode: review, but the project's mode is strict. The file can only make the mode stricter, so strict applies." + ] + } + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-4.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-4.json new file mode 100644 index 00000000..78c707c5 --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build-4.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "main", + "commit": "def" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"strict\",\"commit\":\"def\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":3,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/3\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "strict", + "commit": "def", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 3, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/3", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build.json new file mode 100644 index 00000000..576a512a --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/create_build.json @@ -0,0 +1,24 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc", + "config": { + "ignore": [ + { + "json_paths": [ + "$.generated_at" + ] + } + ] + } + }, + "result": { + "content": [ + { + "text": "visualci.yml: missing field `snapshots`", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/get_build.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/get_build.json new file mode 100644 index 00000000..810e8fd9 --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/get_build.json @@ -0,0 +1,69 @@ +{ + "arguments": { + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"strict\",\"commit\":\"abc\",\"conclusion\":null,\"config\":{\"ci_mode\":\"strict\",\"ignore\":[{\"json_paths\":[\"$.generated_at\"],\"snapshots\":\"api/**\"}],\"pdf\":{\"dpi\":200,\"engine\":\"mutool\"},\"threshold\":{\"screenshots/**\":0.2}},\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "strict", + "commit": "abc", + "conclusion": null, + "config": { + "ci_mode": "strict", + "ignore": [ + { + "json_paths": [ + "$.generated_at" + ], + "snapshots": "api/**" + } + ], + "pdf": { + "dpi": 200, + "engine": "mutool" + }, + "threshold": { + "screenshots/**": 0.2 + } + }, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-2.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-2.json new file mode 100644 index 00000000..892d005b --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-2.json @@ -0,0 +1,353 @@ +{ + "arguments": { + "ignore_rules": [ + { + "json_paths": [ + "$.k0", + "$.k1", + "$.k2", + "$.k3", + "$.k4", + "$.k5", + "$.k6", + "$.k7", + "$.k8", + "$.k9", + "$.k10", + "$.k11", + "$.k12", + "$.k13", + "$.k14", + "$.k15", + "$.k16", + "$.k17", + "$.k18", + "$.k19", + "$.k20", + "$.k21", + "$.k22", + "$.k23", + "$.k24", + "$.k25", + "$.k26", + "$.k27", + "$.k28", + "$.k29", + "$.k30", + "$.k31", + "$.k32", + "$.k33", + "$.k34", + "$.k35", + "$.k36", + "$.k37", + "$.k38", + "$.k39", + "$.k40", + "$.k41", + "$.k42", + "$.k43", + "$.k44", + "$.k45", + "$.k46", + "$.k47", + "$.k48", + "$.k49", + "$.k50", + "$.k51", + "$.k52", + "$.k53", + "$.k54", + "$.k55", + "$.k56", + "$.k57", + "$.k58", + "$.k59", + "$.k60", + "$.k61", + "$.k62", + "$.k63", + "$.k64", + "$.k65", + "$.k66", + "$.k67", + "$.k68", + "$.k69", + "$.k70", + "$.k71", + "$.k72", + "$.k73", + "$.k74", + "$.k75", + "$.k76", + "$.k77", + "$.k78", + "$.k79", + "$.k80", + "$.k81", + "$.k82", + "$.k83", + "$.k84", + "$.k85", + "$.k86", + "$.k87", + "$.k88", + "$.k89", + "$.k90", + "$.k91", + "$.k92", + "$.k93", + "$.k94", + "$.k95", + "$.k96", + "$.k97", + "$.k98", + "$.k99", + "$.k100", + "$.k101", + "$.k102", + "$.k103", + "$.k104", + "$.k105", + "$.k106", + "$.k107", + "$.k108", + "$.k109", + "$.k110", + "$.k111", + "$.k112", + "$.k113", + "$.k114", + "$.k115", + "$.k116", + "$.k117", + "$.k118", + "$.k119", + "$.k120", + "$.k121", + "$.k122", + "$.k123", + "$.k124", + "$.k125", + "$.k126", + "$.k127", + "$.k128", + "$.k129", + "$.k130", + "$.k131", + "$.k132", + "$.k133", + "$.k134", + "$.k135", + "$.k136", + "$.k137", + "$.k138", + "$.k139", + "$.k140", + "$.k141", + "$.k142", + "$.k143", + "$.k144", + "$.k145", + "$.k146", + "$.k147", + "$.k148", + "$.k149" + ], + "snapshots": "**" + } + ], + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[{\"json_paths\":[\"$.k0\",\"$.k1\",\"$.k2\",\"$.k3\",\"$.k4\",\"$.k5\",\"$.k6\",\"$.k7\",\"$.k8\",\"$.k9\",\"$.k10\",\"$.k11\",\"$.k12\",\"$.k13\",\"$.k14\",\"$.k15\",\"$.k16\",\"$.k17\",\"$.k18\",\"$.k19\",\"$.k20\",\"$.k21\",\"$.k22\",\"$.k23\",\"$.k24\",\"$.k25\",\"$.k26\",\"$.k27\",\"$.k28\",\"$.k29\",\"$.k30\",\"$.k31\",\"$.k32\",\"$.k33\",\"$.k34\",\"$.k35\",\"$.k36\",\"$.k37\",\"$.k38\",\"$.k39\",\"$.k40\",\"$.k41\",\"$.k42\",\"$.k43\",\"$.k44\",\"$.k45\",\"$.k46\",\"$.k47\",\"$.k48\",\"$.k49\",\"$.k50\",\"$.k51\",\"$.k52\",\"$.k53\",\"$.k54\",\"$.k55\",\"$.k56\",\"$.k57\",\"$.k58\",\"$.k59\",\"$.k60\",\"$.k61\",\"$.k62\",\"$.k63\",\"$.k64\",\"$.k65\",\"$.k66\",\"$.k67\",\"$.k68\",\"$.k69\",\"$.k70\",\"$.k71\",\"$.k72\",\"$.k73\",\"$.k74\",\"$.k75\",\"$.k76\",\"$.k77\",\"$.k78\",\"$.k79\",\"$.k80\",\"$.k81\",\"$.k82\",\"$.k83\",\"$.k84\",\"$.k85\",\"$.k86\",\"$.k87\",\"$.k88\",\"$.k89\",\"$.k90\",\"$.k91\",\"$.k92\",\"$.k93\",\"$.k94\",\"$.k95\",\"$.k96\",\"$.k97\",\"$.k98\",\"$.k99\",\"$.k100\",\"$.k101\",\"$.k102\",\"$.k103\",\"$.k104\",\"$.k105\",\"$.k106\",\"$.k107\",\"$.k108\",\"$.k109\",\"$.k110\",\"$.k111\",\"$.k112\",\"$.k113\",\"$.k114\",\"$.k115\",\"$.k116\",\"$.k117\",\"$.k118\",\"$.k119\",\"$.k120\",\"$.k121\",\"$.k122\",\"$.k123\",\"$.k124\",\"$.k125\",\"$.k126\",\"$.k127\",\"$.k128\",\"$.k129\",\"$.k130\",\"$.k131\",\"$.k132\",\"$.k133\",\"$.k134\",\"$.k135\",\"$.k136\",\"$.k137\",\"$.k138\",\"$.k139\",\"$.k140\",\"$.k141\",\"$.k142\",\"$.k143\",\"$.k144\",\"$.k145\",\"$.k146\",\"$.k147\",\"$.k148\",\"$.k149\"],\"snapshots\":\"**\"}],\"name\":\"PDFs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"pdfs\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [ + { + "json_paths": [ + "$.k0", + "$.k1", + "$.k2", + "$.k3", + "$.k4", + "$.k5", + "$.k6", + "$.k7", + "$.k8", + "$.k9", + "$.k10", + "$.k11", + "$.k12", + "$.k13", + "$.k14", + "$.k15", + "$.k16", + "$.k17", + "$.k18", + "$.k19", + "$.k20", + "$.k21", + "$.k22", + "$.k23", + "$.k24", + "$.k25", + "$.k26", + "$.k27", + "$.k28", + "$.k29", + "$.k30", + "$.k31", + "$.k32", + "$.k33", + "$.k34", + "$.k35", + "$.k36", + "$.k37", + "$.k38", + "$.k39", + "$.k40", + "$.k41", + "$.k42", + "$.k43", + "$.k44", + "$.k45", + "$.k46", + "$.k47", + "$.k48", + "$.k49", + "$.k50", + "$.k51", + "$.k52", + "$.k53", + "$.k54", + "$.k55", + "$.k56", + "$.k57", + "$.k58", + "$.k59", + "$.k60", + "$.k61", + "$.k62", + "$.k63", + "$.k64", + "$.k65", + "$.k66", + "$.k67", + "$.k68", + "$.k69", + "$.k70", + "$.k71", + "$.k72", + "$.k73", + "$.k74", + "$.k75", + "$.k76", + "$.k77", + "$.k78", + "$.k79", + "$.k80", + "$.k81", + "$.k82", + "$.k83", + "$.k84", + "$.k85", + "$.k86", + "$.k87", + "$.k88", + "$.k89", + "$.k90", + "$.k91", + "$.k92", + "$.k93", + "$.k94", + "$.k95", + "$.k96", + "$.k97", + "$.k98", + "$.k99", + "$.k100", + "$.k101", + "$.k102", + "$.k103", + "$.k104", + "$.k105", + "$.k106", + "$.k107", + "$.k108", + "$.k109", + "$.k110", + "$.k111", + "$.k112", + "$.k113", + "$.k114", + "$.k115", + "$.k116", + "$.k117", + "$.k118", + "$.k119", + "$.k120", + "$.k121", + "$.k122", + "$.k123", + "$.k124", + "$.k125", + "$.k126", + "$.k127", + "$.k128", + "$.k129", + "$.k130", + "$.k131", + "$.k132", + "$.k133", + "$.k134", + "$.k135", + "$.k136", + "$.k137", + "$.k138", + "$.k139", + "$.k140", + "$.k141", + "$.k142", + "$.k143", + "$.k144", + "$.k145", + "$.k146", + "$.k147", + "$.k148", + "$.k149" + ], + "snapshots": "**" + } + ], + "name": "PDFs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "pdfs", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-3.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-3.json new file mode 100644 index 00000000..fd1787cf --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project-3.json @@ -0,0 +1,197 @@ +{ + "arguments": { + "ci_mode": "strict", + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"strict\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[{\"json_paths\":[\"$.k0\",\"$.k1\",\"$.k2\",\"$.k3\",\"$.k4\",\"$.k5\",\"$.k6\",\"$.k7\",\"$.k8\",\"$.k9\",\"$.k10\",\"$.k11\",\"$.k12\",\"$.k13\",\"$.k14\",\"$.k15\",\"$.k16\",\"$.k17\",\"$.k18\",\"$.k19\",\"$.k20\",\"$.k21\",\"$.k22\",\"$.k23\",\"$.k24\",\"$.k25\",\"$.k26\",\"$.k27\",\"$.k28\",\"$.k29\",\"$.k30\",\"$.k31\",\"$.k32\",\"$.k33\",\"$.k34\",\"$.k35\",\"$.k36\",\"$.k37\",\"$.k38\",\"$.k39\",\"$.k40\",\"$.k41\",\"$.k42\",\"$.k43\",\"$.k44\",\"$.k45\",\"$.k46\",\"$.k47\",\"$.k48\",\"$.k49\",\"$.k50\",\"$.k51\",\"$.k52\",\"$.k53\",\"$.k54\",\"$.k55\",\"$.k56\",\"$.k57\",\"$.k58\",\"$.k59\",\"$.k60\",\"$.k61\",\"$.k62\",\"$.k63\",\"$.k64\",\"$.k65\",\"$.k66\",\"$.k67\",\"$.k68\",\"$.k69\",\"$.k70\",\"$.k71\",\"$.k72\",\"$.k73\",\"$.k74\",\"$.k75\",\"$.k76\",\"$.k77\",\"$.k78\",\"$.k79\",\"$.k80\",\"$.k81\",\"$.k82\",\"$.k83\",\"$.k84\",\"$.k85\",\"$.k86\",\"$.k87\",\"$.k88\",\"$.k89\",\"$.k90\",\"$.k91\",\"$.k92\",\"$.k93\",\"$.k94\",\"$.k95\",\"$.k96\",\"$.k97\",\"$.k98\",\"$.k99\",\"$.k100\",\"$.k101\",\"$.k102\",\"$.k103\",\"$.k104\",\"$.k105\",\"$.k106\",\"$.k107\",\"$.k108\",\"$.k109\",\"$.k110\",\"$.k111\",\"$.k112\",\"$.k113\",\"$.k114\",\"$.k115\",\"$.k116\",\"$.k117\",\"$.k118\",\"$.k119\",\"$.k120\",\"$.k121\",\"$.k122\",\"$.k123\",\"$.k124\",\"$.k125\",\"$.k126\",\"$.k127\",\"$.k128\",\"$.k129\",\"$.k130\",\"$.k131\",\"$.k132\",\"$.k133\",\"$.k134\",\"$.k135\",\"$.k136\",\"$.k137\",\"$.k138\",\"$.k139\",\"$.k140\",\"$.k141\",\"$.k142\",\"$.k143\",\"$.k144\",\"$.k145\",\"$.k146\",\"$.k147\",\"$.k148\",\"$.k149\"],\"snapshots\":\"**\"}],\"name\":\"PDFs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"pdfs\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "strict", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [ + { + "json_paths": [ + "$.k0", + "$.k1", + "$.k2", + "$.k3", + "$.k4", + "$.k5", + "$.k6", + "$.k7", + "$.k8", + "$.k9", + "$.k10", + "$.k11", + "$.k12", + "$.k13", + "$.k14", + "$.k15", + "$.k16", + "$.k17", + "$.k18", + "$.k19", + "$.k20", + "$.k21", + "$.k22", + "$.k23", + "$.k24", + "$.k25", + "$.k26", + "$.k27", + "$.k28", + "$.k29", + "$.k30", + "$.k31", + "$.k32", + "$.k33", + "$.k34", + "$.k35", + "$.k36", + "$.k37", + "$.k38", + "$.k39", + "$.k40", + "$.k41", + "$.k42", + "$.k43", + "$.k44", + "$.k45", + "$.k46", + "$.k47", + "$.k48", + "$.k49", + "$.k50", + "$.k51", + "$.k52", + "$.k53", + "$.k54", + "$.k55", + "$.k56", + "$.k57", + "$.k58", + "$.k59", + "$.k60", + "$.k61", + "$.k62", + "$.k63", + "$.k64", + "$.k65", + "$.k66", + "$.k67", + "$.k68", + "$.k69", + "$.k70", + "$.k71", + "$.k72", + "$.k73", + "$.k74", + "$.k75", + "$.k76", + "$.k77", + "$.k78", + "$.k79", + "$.k80", + "$.k81", + "$.k82", + "$.k83", + "$.k84", + "$.k85", + "$.k86", + "$.k87", + "$.k88", + "$.k89", + "$.k90", + "$.k91", + "$.k92", + "$.k93", + "$.k94", + "$.k95", + "$.k96", + "$.k97", + "$.k98", + "$.k99", + "$.k100", + "$.k101", + "$.k102", + "$.k103", + "$.k104", + "$.k105", + "$.k106", + "$.k107", + "$.k108", + "$.k109", + "$.k110", + "$.k111", + "$.k112", + "$.k113", + "$.k114", + "$.k115", + "$.k116", + "$.k117", + "$.k118", + "$.k119", + "$.k120", + "$.k121", + "$.k122", + "$.k123", + "$.k124", + "$.k125", + "$.k126", + "$.k127", + "$.k128", + "$.k129", + "$.k130", + "$.k131", + "$.k132", + "$.k133", + "$.k134", + "$.k135", + "$.k136", + "$.k137", + "$.k138", + "$.k139", + "$.k140", + "$.k141", + "$.k142", + "$.k143", + "$.k144", + "$.k145", + "$.k146", + "$.k147", + "$.k148", + "$.k149" + ], + "snapshots": "**" + } + ], + "name": "PDFs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "pdfs", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project.json b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project.json new file mode 100644 index 00000000..557191ad --- /dev/null +++ b/app/tests/golden/mcp/a_builds_visualci_yml_overrides_the_project_settings/update_project.json @@ -0,0 +1,56 @@ +{ + "arguments": { + "ci_mode": "review", + "ignore_rules": [ + { + "json_paths": [ + "$.project_rule" + ], + "snapshots": "**" + } + ], + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[{\"json_paths\":[\"$.project_rule\"],\"snapshots\":\"**\"}],\"name\":\"PDFs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"pdfs\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [ + { + "json_paths": [ + "$.project_rule" + ], + "snapshots": "**" + } + ], + "name": "PDFs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "pdfs", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build-2.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build-2.json new file mode 100644 index 00000000..1672aaf0 --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build-2.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "main", + "commit": "def" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"def\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "def", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build.json new file mode 100644 index 00000000..326f689a --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/create_build.json @@ -0,0 +1,66 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":{\"billing_url\":\"https://app.visualci.test//billing\",\"credits_limit\":25000,\"credits_used\":25000,\"fixes\":[{\"action\":\"upgrade\",\"label\":\"Upgrade to Team\",\"url\":\"https://app.visualci.test//billing\"}],\"message\":\"Org is out of VisualCI credits until 1 January 2027: it has used all 25,000 credits on the Free plan, so builds aren't compared. An admin can upgrade to Team at https://app.visualci.test//billing\",\"pack_credits\":0,\"plan\":\"Free\",\"reason\":\"out_of_credits\",\"renews_at\":\"\"},\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": { + "billing_url": "https://app.visualci.test//billing", + "credits_limit": 25000, + "credits_used": 25000, + "fixes": [ + { + "action": "upgrade", + "label": "Upgrade to Team", + "url": "https://app.visualci.test//billing" + } + ], + "message": "Org is out of VisualCI credits until 1 January 2027: it has used all 25,000 credits on the Free plan, so builds aren't compared. An admin can upgrade to Team at https://app.visualci.test//billing", + "pack_credits": 0, + "plan": "Free", + "reason": "out_of_credits", + "renews_at": "" + }, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build-2.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build-2.json new file mode 100644 index 00000000..8a88116d --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build-2.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "allow_empty": true, + "build": "2" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"def\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"processing\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "def", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "processing", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build.json new file mode 100644 index 00000000..36395bee --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/finalize_build.json @@ -0,0 +1,65 @@ +{ + "arguments": { + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":{\"billing_url\":\"https://app.visualci.test//billing\",\"credits_limit\":25000,\"credits_used\":25000,\"fixes\":[{\"action\":\"upgrade\",\"label\":\"Upgrade to Team\",\"url\":\"https://app.visualci.test//billing\"}],\"message\":\"Org is out of VisualCI credits until 1 January 2027: it has used all 25,000 credits on the Free plan, so builds aren't compared. An admin can upgrade to Team at https://app.visualci.test//billing\",\"pack_credits\":0,\"plan\":\"Free\",\"reason\":\"out_of_credits\",\"renews_at\":\"\"},\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":\"Org has used this month's 25,000 credits on the Free plan and has no pack credits left, so this build wasn't compared. Upgrade to Team on the billing page, or wait for the allowance to renew on the 1st.\",\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":false,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"failed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": { + "billing_url": "https://app.visualci.test//billing", + "credits_limit": 25000, + "credits_used": 25000, + "fixes": [ + { + "action": "upgrade", + "label": "Upgrade to Team", + "url": "https://app.visualci.test//billing" + } + ], + "message": "Org is out of VisualCI credits until 1 January 2027: it has used all 25,000 credits on the Free plan, so builds aren't compared. An admin can upgrade to Team at https://app.visualci.test//billing", + "pack_credits": 0, + "plan": "Free", + "reason": "out_of_credits", + "renews_at": "" + }, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": "Org has used this month's 25,000 credits on the Free plan and has no pack credits left, so this build wasn't compared. Upgrade to Team on the billing page, or wait for the allowance to renew on the 1st.", + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": false, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "failed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/get_build.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/get_build.json new file mode 100644 index 00000000..a862e982 --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/get_build.json @@ -0,0 +1,56 @@ +{ + "arguments": { + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":{\"message\":\"Org has VisualCI credits again. Run CI again to compare this commit.\",\"reason\":\"out_of_credits\",\"resolved\":true},\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":\"Org has used this month's 25,000 credits on the Free plan and has no pack credits left, so this build wasn't compared. Upgrade to Team on the billing page, or wait for the allowance to renew on the 1st.\",\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":false,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[],\"state\":\"failed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": { + "message": "Org has VisualCI credits again. Run CI again to compare this commit.", + "reason": "out_of_credits", + "resolved": true + }, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": "Org has used this month's 25,000 credits on the Free plan and has no pack credits left, so this build wasn't compared. Upgrade to Team on the billing page, or wait for the allowance to renew on the 1st.", + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": false, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [], + "state": "failed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami-2.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami-2.json new file mode 100644 index 00000000..c7600d59 --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami-2.json @@ -0,0 +1,19 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"kind\":\"project\",\"open_comment_threads\":[],\"project\":\"/pdfs\",\"waiting_for_review\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "kind": "project", + "open_comment_threads": [], + "project": "/pdfs", + "waiting_for_review": [] + } + } +} diff --git a/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami.json b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami.json new file mode 100644 index 00000000..0340a7ff --- /dev/null +++ b/app/tests/golden/mcp/a_free_organization_over_its_allowance_gets_a_failed_build_that_says_why/whoami.json @@ -0,0 +1,35 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"blocked\":{\"billing_url\":\"https://app.visualci.test//billing\",\"credits_limit\":25000,\"credits_used\":25000,\"fixes\":[{\"action\":\"upgrade\",\"label\":\"Upgrade to Team\",\"url\":\"https://app.visualci.test//billing\"}],\"message\":\"Org is out of VisualCI credits until 1 January 2027: it has used all 25,000 credits on the Free plan, so builds aren't compared. An admin can upgrade to Team at https://app.visualci.test//billing\",\"pack_credits\":0,\"plan\":\"Free\",\"reason\":\"out_of_credits\",\"renews_at\":\"\"},\"kind\":\"project\",\"open_comment_threads\":[],\"project\":\"/pdfs\",\"waiting_for_review\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": { + "billing_url": "https://app.visualci.test//billing", + "credits_limit": 25000, + "credits_used": 25000, + "fixes": [ + { + "action": "upgrade", + "label": "Upgrade to Team", + "url": "https://app.visualci.test//billing" + } + ], + "message": "Org is out of VisualCI credits until 1 January 2027: it has used all 25,000 credits on the Free plan, so builds aren't compared. An admin can upgrade to Team at https://app.visualci.test//billing", + "pack_credits": 0, + "plan": "Free", + "reason": "out_of_credits", + "renews_at": "" + }, + "kind": "project", + "open_comment_threads": [], + "project": "/pdfs", + "waiting_for_review": [] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build-2.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build-2.json new file mode 100644 index 00000000..718b41b0 --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build-2.json @@ -0,0 +1,52 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc123", + "mode": "ci", + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc123", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build.json new file mode 100644 index 00000000..b7ac6304 --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/create_build.json @@ -0,0 +1,52 @@ +{ + "arguments": { + "branch": "my-branch", + "commit": "abc123", + "mode": "local", + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"my-branch\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"local\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"local\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "my-branch", + "ci_mode": "review", + "commit": "abc123", + "conclusion": null, + "created_at": "", + "environment": "local", + "environment_info": {}, + "error": null, + "id": "", + "mode": "local", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-2.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-2.json new file mode 100644 index 00000000..d9900d5a --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-2.json @@ -0,0 +1,54 @@ +{ + "arguments": { + "project": "/pdfs", + "waiting_for_review": true + }, + "result": { + "content": [ + { + "text": "{\"builds\":[{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":\"changes\",\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"pending\",\"reviewable\":true,\"reviews\":[],\"state\":\"completed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "builds": [ + { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc123", + "conclusion": "changes", + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "pending", + "reviewable": true, + "reviews": [], + "state": "completed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-3.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-3.json new file mode 100644 index 00000000..be3038bc --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-3.json @@ -0,0 +1,53 @@ +{ + "arguments": { + "waiting_for_review": true + }, + "result": { + "content": [ + { + "text": "{\"builds\":[{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":\"changes\",\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"pending\",\"reviewable\":true,\"reviews\":[],\"state\":\"completed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "builds": [ + { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc123", + "conclusion": "changes", + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "pending", + "reviewable": true, + "reviews": [], + "state": "completed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-4.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-4.json new file mode 100644 index 00000000..d9900d5a --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds-4.json @@ -0,0 +1,54 @@ +{ + "arguments": { + "project": "/pdfs", + "waiting_for_review": true + }, + "result": { + "content": [ + { + "text": "{\"builds\":[{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":\"changes\",\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"pending\",\"reviewable\":true,\"reviews\":[],\"state\":\"completed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "builds": [ + { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc123", + "conclusion": "changes", + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "pending", + "reviewable": true, + "reviews": [], + "state": "completed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds.json new file mode 100644 index 00000000..e148ddcc --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/list_builds.json @@ -0,0 +1,89 @@ +{ + "arguments": { + "project": "/pdfs", + "waiting_for_review": true + }, + "result": { + "content": [ + { + "text": "{\"builds\":[{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":\"changes\",\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":2,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"pending\",\"reviewable\":true,\"reviews\":[],\"state\":\"completed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/2\",\"warnings\":[]},{\"blocked\":null,\"branch\":\"my-branch\",\"ci_mode\":\"review\",\"commit\":\"abc123\",\"conclusion\":\"changes\",\"created_at\":\"\",\"environment\":\"local\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"local\",\"name\":\"default\",\"number\":1,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"pending\",\"reviewable\":true,\"reviews\":[],\"state\":\"completed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "builds": [ + { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc123", + "conclusion": "changes", + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 2, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "pending", + "reviewable": true, + "reviews": [], + "state": "completed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/2", + "warnings": [] + }, + { + "blocked": null, + "branch": "my-branch", + "ci_mode": "review", + "commit": "abc123", + "conclusion": "changes", + "created_at": "", + "environment": "local", + "environment_info": {}, + "error": null, + "id": "", + "mode": "local", + "name": "default", + "number": 1, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "pending", + "reviewable": true, + "reviews": [], + "state": "completed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-2.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-2.json new file mode 100644 index 00000000..c845acce --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-2.json @@ -0,0 +1,66 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"email\":\"@example.com\",\"identities\":[],\"kind\":\"user\",\"name\":\"bob\",\"organizations\":[{\"blocked\":null,\"name\":\"Org\",\"projects\":[\"/pdfs\",\"/shots\"],\"role\":\"member\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"install_github_app\",\"steps\":[{\"done\":true,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":true,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\"}],\"waiting_for_review\":[{\"branch\":\"main\",\"build\":2,\"commit\":\"abc123\",\"project\":\"/pdfs\",\"url\":\"https://app.visualci.test//pdfs/builds/2\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "email": "@example.com", + "identities": [], + "kind": "user", + "name": "bob", + "organizations": [ + { + "blocked": null, + "name": "Org", + "projects": [ + "/pdfs", + "/shots" + ], + "role": "member", + "setup": { + "complete": false, + "dismissed": false, + "next": "install_github_app", + "steps": [ + { + "done": true, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": true, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "" + } + ], + "waiting_for_review": [ + { + "branch": "main", + "build": 2, + "commit": "abc123", + "project": "/pdfs", + "url": "https://app.visualci.test//pdfs/builds/2" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-3.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-3.json new file mode 100644 index 00000000..4efb846c --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-3.json @@ -0,0 +1,27 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"kind\":\"project\",\"open_comment_threads\":[],\"project\":\"/pdfs\",\"waiting_for_review\":[{\"branch\":\"main\",\"build\":2,\"commit\":\"abc123\",\"project\":\"/pdfs\",\"url\":\"https://app.visualci.test//pdfs/builds/2\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "kind": "project", + "open_comment_threads": [], + "project": "/pdfs", + "waiting_for_review": [ + { + "branch": "main", + "build": 2, + "commit": "abc123", + "project": "/pdfs", + "url": "https://app.visualci.test//pdfs/builds/2" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-4.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-4.json new file mode 100644 index 00000000..47c1d81d --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami-4.json @@ -0,0 +1,66 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"email\":\"@example.com\",\"identities\":[],\"kind\":\"user\",\"name\":\"owner\",\"organizations\":[{\"blocked\":null,\"name\":\"Org\",\"projects\":[\"/pdfs\",\"/shots\"],\"role\":\"admin\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"install_github_app\",\"steps\":[{\"done\":true,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":true,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\"}],\"waiting_for_review\":[{\"branch\":\"main\",\"build\":2,\"commit\":\"abc123\",\"project\":\"/pdfs\",\"url\":\"https://app.visualci.test//pdfs/builds/2\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "email": "@example.com", + "identities": [], + "kind": "user", + "name": "owner", + "organizations": [ + { + "blocked": null, + "name": "Org", + "projects": [ + "/pdfs", + "/shots" + ], + "role": "admin", + "setup": { + "complete": false, + "dismissed": false, + "next": "install_github_app", + "steps": [ + { + "done": true, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": true, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "" + } + ], + "waiting_for_review": [ + { + "branch": "main", + "build": 2, + "commit": "abc123", + "project": "/pdfs", + "url": "https://app.visualci.test//pdfs/builds/2" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami.json b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami.json new file mode 100644 index 00000000..85af152c --- /dev/null +++ b/app/tests/golden/mcp/a_local_build_waits_only_for_its_person_and_closes_after_a_week_idle/whoami.json @@ -0,0 +1,73 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"email\":\"@example.com\",\"identities\":[],\"kind\":\"user\",\"name\":\"owner\",\"organizations\":[{\"blocked\":null,\"name\":\"Org\",\"projects\":[\"/pdfs\",\"/shots\"],\"role\":\"admin\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"install_github_app\",\"steps\":[{\"done\":true,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":true,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\"}],\"waiting_for_review\":[{\"branch\":\"main\",\"build\":2,\"commit\":\"abc123\",\"project\":\"/pdfs\",\"url\":\"https://app.visualci.test//pdfs/builds/2\"},{\"branch\":\"my-branch\",\"build\":1,\"commit\":\"abc123\",\"project\":\"/pdfs\",\"url\":\"https://app.visualci.test//pdfs/builds/1\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "email": "@example.com", + "identities": [], + "kind": "user", + "name": "owner", + "organizations": [ + { + "blocked": null, + "name": "Org", + "projects": [ + "/pdfs", + "/shots" + ], + "role": "admin", + "setup": { + "complete": false, + "dismissed": false, + "next": "install_github_app", + "steps": [ + { + "done": true, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": true, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "" + } + ], + "waiting_for_review": [ + { + "branch": "main", + "build": 2, + "commit": "abc123", + "project": "/pdfs", + "url": "https://app.visualci.test//pdfs/builds/2" + }, + { + "branch": "my-branch", + "build": 1, + "commit": "abc123", + "project": "/pdfs", + "url": "https://app.visualci.test//pdfs/builds/1" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_organization.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_organization.json new file mode 100644 index 00000000..3c90a5ba --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_organization.json @@ -0,0 +1,20 @@ +{ + "arguments": { + "name": "B", + "slug": "-b" + }, + "result": { + "content": [ + { + "text": "{\"name\":\"B\",\"plan\":\"Free\",\"slug\":\"-b\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "name": "B", + "plan": "Free", + "slug": "-b" + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project.json new file mode 100644 index 00000000..bdd62ca9 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project.json @@ -0,0 +1,43 @@ +{ + "arguments": { + "name": "Docs", + "org": "-b", + "slug": "docs" + }, + "result": { + "content": [ + { + "text": "{\"project\":\"-b/docs\",\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[],\"name\":\"Docs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"docs\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "project": "-b/docs", + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [], + "name": "Docs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "docs", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project_token.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project_token.json new file mode 100644 index 00000000..b2369112 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/create_project_token.json @@ -0,0 +1,20 @@ +{ + "arguments": { + "name": "CircleCI", + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "{\"id\":3,\"name\":\"CircleCI\",\"token\":\"\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "id": 3, + "name": "CircleCI", + "token": "" + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/delete_project_token.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/delete_project_token.json new file mode 100644 index 00000000..1b602218 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/delete_project_token.json @@ -0,0 +1,18 @@ +{ + "arguments": { + "project": "-b/docs", + "token_id": 3 + }, + "result": { + "content": [ + { + "text": "{\"deleted\":3}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "deleted": 3 + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization-2.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization-2.json new file mode 100644 index 00000000..9af823a3 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization-2.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "org": "nobody-else" + }, + "result": { + "content": [ + { + "text": "no organization nobody-else that this token can see", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization.json new file mode 100644 index 00000000..728fd5df --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_organization.json @@ -0,0 +1,111 @@ +{ + "arguments": { + "org": "" + }, + "result": { + "content": [ + { + "text": "{\"billing_url\":\"https://app.visualci.test//billing\",\"invitations\":[],\"members\":[{\"avatar_url\":null,\"email\":\"@example.com\",\"id\":\"\",\"identities\":[],\"login\":null,\"name\":\"owner\",\"role\":\"admin\",\"since\":\"\",\"source\":\"created\",\"synced_at\":null}],\"name\":\"Org\",\"projects\":[{\"last_build\":null,\"name\":\"PDFs\",\"project\":\"/pdfs\"},{\"last_build\":null,\"name\":\"Screenshots\",\"project\":\"/shots\"}],\"role\":\"admin\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"install_github_app\",\"steps\":[{\"done\":true,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":false,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\",\"usage\":{\"auto_reload_packs\":4,\"billing_problem\":null,\"credit_pack\":{\"credits\":500000,\"price_cents\":1500,\"reload_below\":100000},\"credits_this_month\":0,\"included_credits\":25000,\"open_source\":{\"pool\":1000000,\"projects\":0,\"used\":0},\"out_of_credits\":false,\"pack_credits\":0,\"plan\":{\"credit_packs\":false,\"id\":\"free\",\"included_credits\":25000,\"name\":\"Free\",\"price_cents\":0,\"unlimited\":false},\"rates\":{\"image_diff\":10,\"rendered_page\":20,\"snapshot_check\":1,\"text_diff\":5},\"reloads_paused\":false,\"reloads_this_month\":0,\"renews_at\":\"\",\"unlimited\":false},\"usage_history\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "billing_url": "https://app.visualci.test//billing", + "invitations": [], + "members": [ + { + "avatar_url": null, + "email": "@example.com", + "id": "", + "identities": [], + "login": null, + "name": "owner", + "role": "admin", + "since": "", + "source": "created", + "synced_at": null + } + ], + "name": "Org", + "projects": [ + { + "last_build": null, + "name": "PDFs", + "project": "/pdfs" + }, + { + "last_build": null, + "name": "Screenshots", + "project": "/shots" + } + ], + "role": "admin", + "setup": { + "complete": false, + "dismissed": false, + "next": "install_github_app", + "steps": [ + { + "done": true, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": false, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "", + "usage": { + "auto_reload_packs": 4, + "billing_problem": null, + "credit_pack": { + "credits": 500000, + "price_cents": 1500, + "reload_below": 100000 + }, + "credits_this_month": 0, + "included_credits": 25000, + "open_source": { + "pool": 1000000, + "projects": 0, + "used": 0 + }, + "out_of_credits": false, + "pack_credits": 0, + "plan": { + "credit_packs": false, + "id": "free", + "included_credits": 25000, + "name": "Free", + "price_cents": 0, + "unlimited": false + }, + "rates": { + "image_diff": 10, + "rendered_page": 20, + "snapshot_check": 1, + "text_diff": 5 + }, + "reloads_paused": false, + "reloads_this_month": 0, + "renews_at": "", + "unlimited": false + }, + "usage_history": [] + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_project.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_project.json new file mode 100644 index 00000000..5652ccc4 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/get_project.json @@ -0,0 +1,67 @@ +{ + "arguments": { + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "{\"gallery\":{\"enabled\":true,\"items\":[],\"manifest_url\":null},\"project\":\"-b/docs\",\"repository_seen_in_ci\":null,\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":150,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[{\"json_paths\":[\"$.generated_at\"],\"snapshots\":\"api/**\",\"text_patterns\":[\"\\\\d{4}-\\\\d{2}-\\\\d{2}\"]}],\"name\":\"Docs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"docs\",\"threshold\":0.0,\"tokens_can_approve\":true},\"tokens\":[{\"created_at\":\"\",\"id\":3,\"last_used_at\":null,\"name\":\"CircleCI\",\"prefix\":\"\"}],\"url\":\"https://app.visualci.test/-b/docs\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "gallery": { + "enabled": true, + "items": [], + "manifest_url": null + }, + "project": "-b/docs", + "repository_seen_in_ci": null, + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 150, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [ + { + "json_paths": [ + "$.generated_at" + ], + "snapshots": "api/**", + "text_patterns": [ + "\\d{4}-\\d{2}-\\d{2}" + ] + } + ], + "name": "Docs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "docs", + "threshold": 0.0, + "tokens_can_approve": true + }, + "tokens": [ + { + "created_at": "", + "id": 3, + "last_used_at": null, + "name": "CircleCI", + "prefix": "" + } + ], + "url": "https://app.visualci.test/-b/docs" + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-2.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-2.json new file mode 100644 index 00000000..42a38cb7 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-2.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "project": "-b/docs", + "repository_url": "https://example.com/a/b" + }, + "result": { + "content": [ + { + "text": "\"https://example.com/a/b\" isn't a repository URL VisualCI knows: https://github.com/owner/name, https://gitlab.com/group/project, or a project on a GitLab instance this organization added", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-3.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-3.json new file mode 100644 index 00000000..42478e3f --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-3.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "dpi": 9000, + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "dpi must be 36 to 600", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-4.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-4.json new file mode 100644 index 00000000..aae6cbfa --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-4.json @@ -0,0 +1,62 @@ +{ + "arguments": { + "ignore_rules": [ + { + "json_paths": [ + "$.generated_at", + " " + ], + "snapshots": "api/**", + "text_patterns": [ + "\\d{4}-\\d{2}-\\d{2}" + ] + } + ], + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":150,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[{\"json_paths\":[\"$.generated_at\"],\"snapshots\":\"api/**\",\"text_patterns\":[\"\\\\d{4}-\\\\d{2}-\\\\d{2}\"]}],\"name\":\"Docs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"docs\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 150, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [ + { + "json_paths": [ + "$.generated_at" + ], + "snapshots": "api/**", + "text_patterns": [ + "\\d{4}-\\d{2}-\\d{2}" + ] + } + ], + "name": "Docs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "docs", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-5.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-5.json new file mode 100644 index 00000000..94bb66f6 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-5.json @@ -0,0 +1,22 @@ +{ + "arguments": { + "ignore_rules": [ + { + "json_paths": [ + "$.items[" + ], + "snapshots": "**" + } + ], + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "ignore rule 1: the ignore rule for \"**\": JSON path \"$.items[\": expected an index, `*` or a quoted key in `[...]`", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-6.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-6.json new file mode 100644 index 00000000..4fc4e70d --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-6.json @@ -0,0 +1,22 @@ +{ + "arguments": { + "ignore_rules": [ + { + "snapshots": "**", + "text_patterns": [ + "(" + ] + } + ], + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "ignore rule 1: the ignore rule for \"**\": pattern \"(\": regex parse error:\n (\n ^\nerror: unclosed group", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-7.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-7.json new file mode 100644 index 00000000..0d21668d --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-7.json @@ -0,0 +1,22 @@ +{ + "arguments": { + "ignore_rules": [ + { + "json_paths": [ + "$.a" + ], + "snapshots": "" + } + ], + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "ignore rule 1: every ignore rule names the snapshots it applies to in `snapshots` (a glob such as `api/**`); rules without one aren't allowed", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-8.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-8.json new file mode 100644 index 00000000..9f352fdf --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project-8.json @@ -0,0 +1,21 @@ +{ + "arguments": { + "ignore_rules": [ + { + "json_paths": [ + "$.a" + ] + } + ], + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "failed to deserialize parameters: missing field `snapshots`\n\nupdate_project takes:\n- ci_mode (string): `review` (CI passes, the check waits for review), `strict` (CI fails on unreviewed changes) or `wait`.\n- default_branch (string): The branch whose builds become the baseline automatically.\n- dismiss_notice (boolean): `true` dismisses the project's notice.\n- dpi (integer): Render resolution for documents, 36 to 600.\n- forge_token (string): A project on your organization's own GitLab instance: an access token for it (a project or group access token with the `api` scope and the Developer role, or Maintainer to let VisualCI add its webhook), sent with `repository_url`. Stored encrypted; never shown again.\n- gallery_enabled (boolean): `false` takes the public gallery down (visualci.yml's `gallery` decides what's in it); `true` puts it back.\n- ignore_anti_aliasing (boolean): Ignore anti-aliasing differences in images.\n- ignore_rules (array): Values in text snapshots that change on every run, ignored when comparing. Replaces the project's rules. Each rule names the snapshots it applies to with a glob (`api/invoices/**`; `**` for every snapshot). A build's `visualci.yml` replaces these rules when it has `ignore`.\n- move_link (boolean): With `repository_url`: a repository belongs to one organization, so when another organization has it linked, `true` moves the link here (you must maintain the repository; that organization's admins get an email).\n- name (string): The project's display name.\n- project (string): `org/project`. Optional with a project token.\n- public (boolean): `true` lets anyone, signed in or not, read the project's builds and diffs (for open source projects); settings, tokens and reviewing stay with its members. Only a project linked to a public repository can be public. `false` makes it private again.\n- renderer (string): The PDF renderer: `pdfbox` or `mutool`.\n- repository_url (string): The repository this project tests, by URL (`https://github.com/acme/web`); an empty string unlinks it. Linking needs the forge's VisualCI app installed on the repository and you to be an admin or maintainer of it there. Its pull requests then get VisualCI's check, and people's access to this organization follows their permission on it.\n- slug (string): A new slug, renaming the project (`acme/old` → `acme/new`): lowercase letters, digits and dashes. Its builds, baselines and tokens stay. The old address and `acme/old` stop working.\n- threshold (number): The diff threshold, 0 to 1: 0 compares exactly; above 0 it's pixelmatch's colour threshold (how different a pixel's colour must be to count), and anti-aliased pixels are ignored.\n- tokens_can_approve (boolean): `false`: project tokens can't approve changes (people do); `true` lets CI's agents approve again.\nExample: {}", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project.json new file mode 100644 index 00000000..a37d3cef --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/update_project.json @@ -0,0 +1,41 @@ +{ + "arguments": { + "dpi": 150, + "project": "-b/docs" + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":150,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[],\"name\":\"Docs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"docs\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 150, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [], + "name": "Docs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "docs", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/whoami.json b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/whoami.json new file mode 100644 index 00000000..1896d6a6 --- /dev/null +++ b/app/tests/golden/mcp/a_personal_token_manages_organizations_projects_and_tokens/whoami.json @@ -0,0 +1,58 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"email\":\"@example.com\",\"identities\":[],\"kind\":\"user\",\"name\":\"owner\",\"organizations\":[{\"blocked\":null,\"name\":\"Org\",\"projects\":[\"/pdfs\",\"/shots\"],\"role\":\"admin\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"install_github_app\",\"steps\":[{\"done\":true,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":false,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\"}],\"waiting_for_review\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "email": "@example.com", + "identities": [], + "kind": "user", + "name": "owner", + "organizations": [ + { + "blocked": null, + "name": "Org", + "projects": [ + "/pdfs", + "/shots" + ], + "role": "admin", + "setup": { + "complete": false, + "dismissed": false, + "next": "install_github_app", + "steps": [ + { + "done": true, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": false, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "" + } + ], + "waiting_for_review": [] + } + } +} diff --git a/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review-2.json b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review-2.json new file mode 100644 index 00000000..2a2c6057 --- /dev/null +++ b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review-2.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "reject", + "build": 1 + }, + "result": { + "content": [ + { + "text": "no build 1 in this project", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review.json b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review.json new file mode 100644 index 00000000..51b363b7 --- /dev/null +++ b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "approve", + "build": 1 + }, + "result": { + "content": [ + { + "text": "this project keeps approving with people: a project token can't approve, accept a variant or ignore a change (rejecting and commenting still work); a person approves in the web app, or with their own token", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review_page.json b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review_page.json new file mode 100644 index 00000000..80e0a9cc --- /dev/null +++ b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/review_page.json @@ -0,0 +1,17 @@ +{ + "arguments": { + "action": "ignore", + "build": 1, + "name": "x", + "position": 0 + }, + "result": { + "content": [ + { + "text": "this project keeps approving with people: a project token can't approve, accept a variant or ignore a change (rejecting and commenting still work); a person approves in the web app, or with their own token", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_can_keep_approving_with_people/update_project.json b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/update_project.json new file mode 100644 index 00000000..4cdd3c0b --- /dev/null +++ b/app/tests/golden/mcp/a_project_can_keep_approving_with_people/update_project.json @@ -0,0 +1,41 @@ +{ + "arguments": { + "project": "/pdfs", + "tokens_can_approve": false + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[],\"name\":\"PDFs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"pdfs\",\"threshold\":0.0,\"tokens_can_approve\":false}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [], + "name": "PDFs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "pdfs", + "threshold": 0.0, + "tokens_can_approve": false + } + } + } +} diff --git a/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token-2.json b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token-2.json new file mode 100644 index 00000000..5d276b83 --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token-2.json @@ -0,0 +1,20 @@ +{ + "arguments": { + "name": "spare", + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "{\"id\":3,\"name\":\"spare\",\"token\":\"\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "id": 3, + "name": "spare", + "token": "" + } + } +} diff --git a/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token.json b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token.json new file mode 100644 index 00000000..ddf3e5cb --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/create_project_token.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "name": "spare" + }, + "result": { + "content": [ + { + "text": "only an admin of the organization can create project tokens; you're member", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/get_organization.json b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/get_organization.json new file mode 100644 index 00000000..f647a91e --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/get_organization.json @@ -0,0 +1,93 @@ +{ + "arguments": { + "org": "" + }, + "result": { + "content": [ + { + "text": "{\"billing_url\":\"https://app.visualci.test//billing\",\"invitations\":[],\"members\":[],\"name\":\"Org\",\"projects\":[{\"last_build\":null,\"name\":\"PDFs\",\"project\":\"/pdfs\"}],\"role\":\"project\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"connect_agent\",\"steps\":[{\"done\":false,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":false,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\",\"usage\":{\"auto_reload_packs\":4,\"billing_problem\":null,\"credit_pack\":{\"credits\":500000,\"price_cents\":1500,\"reload_below\":100000},\"credits_this_month\":0,\"included_credits\":25000,\"open_source\":{\"pool\":1000000,\"projects\":0,\"used\":0},\"out_of_credits\":false,\"pack_credits\":0,\"plan\":{\"credit_packs\":false,\"id\":\"free\",\"included_credits\":25000,\"name\":\"Free\",\"price_cents\":0,\"unlimited\":false},\"rates\":{\"image_diff\":10,\"rendered_page\":20,\"snapshot_check\":1,\"text_diff\":5},\"reloads_paused\":false,\"reloads_this_month\":0,\"renews_at\":\"\",\"unlimited\":false},\"usage_history\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "billing_url": "https://app.visualci.test//billing", + "invitations": [], + "members": [], + "name": "Org", + "projects": [ + { + "last_build": null, + "name": "PDFs", + "project": "/pdfs" + } + ], + "role": "project", + "setup": { + "complete": false, + "dismissed": false, + "next": "connect_agent", + "steps": [ + { + "done": false, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": false, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "", + "usage": { + "auto_reload_packs": 4, + "billing_problem": null, + "credit_pack": { + "credits": 500000, + "price_cents": 1500, + "reload_below": 100000 + }, + "credits_this_month": 0, + "included_credits": 25000, + "open_source": { + "pool": 1000000, + "projects": 0, + "used": 0 + }, + "out_of_credits": false, + "pack_credits": 0, + "plan": { + "credit_packs": false, + "id": "free", + "included_credits": 25000, + "name": "Free", + "price_cents": 0, + "unlimited": false + }, + "rates": { + "image_diff": 10, + "rendered_page": 20, + "snapshot_check": 1, + "text_diff": 5 + }, + "reloads_paused": false, + "reloads_this_month": 0, + "renews_at": "", + "unlimited": false + }, + "usage_history": [] + } + } +} diff --git a/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/list_organizations.json b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/list_organizations.json new file mode 100644 index 00000000..4aa54217 --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/list_organizations.json @@ -0,0 +1,60 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"organizations\":[{\"name\":\"Org\",\"projects\":[\"pdfs\"],\"role\":\"project\",\"slug\":\"\",\"usage\":{\"auto_reload_packs\":4,\"billing_problem\":null,\"credit_pack\":{\"credits\":500000,\"price_cents\":1500,\"reload_below\":100000},\"credits_this_month\":0,\"included_credits\":25000,\"open_source\":{\"pool\":1000000,\"projects\":0,\"used\":0},\"out_of_credits\":false,\"pack_credits\":0,\"plan\":{\"credit_packs\":false,\"id\":\"free\",\"included_credits\":25000,\"name\":\"Free\",\"price_cents\":0,\"unlimited\":false},\"rates\":{\"image_diff\":10,\"rendered_page\":20,\"snapshot_check\":1,\"text_diff\":5},\"reloads_paused\":false,\"reloads_this_month\":0,\"renews_at\":\"\",\"unlimited\":false}}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "organizations": [ + { + "name": "Org", + "projects": [ + "pdfs" + ], + "role": "project", + "slug": "", + "usage": { + "auto_reload_packs": 4, + "billing_problem": null, + "credit_pack": { + "credits": 500000, + "price_cents": 1500, + "reload_below": 100000 + }, + "credits_this_month": 0, + "included_credits": 25000, + "open_source": { + "pool": 1000000, + "projects": 0, + "used": 0 + }, + "out_of_credits": false, + "pack_credits": 0, + "plan": { + "credit_packs": false, + "id": "free", + "included_credits": 25000, + "name": "Free", + "price_cents": 0, + "unlimited": false + }, + "rates": { + "image_diff": 10, + "rendered_page": 20, + "snapshot_check": 1, + "text_diff": 5 + }, + "reloads_paused": false, + "reloads_this_month": 0, + "renews_at": "", + "unlimited": false + } + } + ] + } + } +} diff --git a/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/update_project.json b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/update_project.json new file mode 100644 index 00000000..28096be8 --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_acts_as_a_member_not_an_admin/update_project.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "ci_mode": "review" + }, + "result": { + "content": [ + { + "text": "only an admin of the organization can change a project's settings; you're member", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_token_reaches_only_its_project/create_organization.json b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/create_organization.json new file mode 100644 index 00000000..85d14c97 --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/create_organization.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "name": "X", + "slug": "x-y" + }, + "result": { + "content": [ + { + "text": "creating an organization needs a personal access token", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_token_reaches_only_its_project/get_project.json b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/get_project.json new file mode 100644 index 00000000..a1c6e05f --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/get_project.json @@ -0,0 +1,55 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"gallery\":{\"enabled\":true,\"items\":[],\"manifest_url\":null},\"project\":\"/shots\",\"repository_seen_in_ci\":null,\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[],\"name\":\"Screenshots\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"shots\",\"threshold\":0.0,\"tokens_can_approve\":true},\"tokens\":[{\"created_at\":\"\",\"id\":2,\"last_used_at\":\"\",\"name\":\"ci\",\"prefix\":\"\"}],\"url\":\"https://app.visualci.test//shots\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "gallery": { + "enabled": true, + "items": [], + "manifest_url": null + }, + "project": "/shots", + "repository_seen_in_ci": null, + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [], + "name": "Screenshots", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "shots", + "threshold": 0.0, + "tokens_can_approve": true + }, + "tokens": [ + { + "created_at": "", + "id": 2, + "last_used_at": "", + "name": "ci", + "prefix": "" + } + ], + "url": "https://app.visualci.test//shots" + } + } +} diff --git a/app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds-2.json b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds-2.json new file mode 100644 index 00000000..6ffe7c4a --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds-2.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "project": "/shots" + }, + "result": { + "content": [ + { + "text": "this project token is for /pdfs, not /shots", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds.json b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds.json new file mode 100644 index 00000000..487b7368 --- /dev/null +++ b/app/tests/golden/mcp/a_project_token_reaches_only_its_project/list_builds.json @@ -0,0 +1,15 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"builds\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "builds": [] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/create_build.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/create_build.json new file mode 100644 index 00000000..c3a15136 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/create_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "feat", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"feat\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "feat", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/delete_comment.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/delete_comment.json new file mode 100644 index 00000000..3cb27d32 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/delete_comment.json @@ -0,0 +1,18 @@ +{ + "arguments": { + "comment": "" + }, + "result": { + "content": [ + { + "text": "{\"deleted\":\"\",\"thread_deleted\":false}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "deleted": "", + "thread_deleted": false + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/get_build.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/get_build.json new file mode 100644 index 00000000..08df92b3 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/get_build.json @@ -0,0 +1,114 @@ +{ + "arguments": { + "build": 1, + "include_unchanged": true + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"feat\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"open_comment_threads\":[{\"anchor\":{\"kind\":\"point\",\"x\":20.0,\"y\":30.0},\"comments\":[{\"author\":{\"agent\":\"rmcp 3.12.0\",\"kind\":\"agent\",\"name\":null},\"body\":\"Is this change meant?\",\"created_at\":\"\",\"id\":\"\",\"updated_at\":\"\"},{\"author\":{\"agent\":\"rmcp 3.12.0\",\"kind\":\"agent\",\"name\":null},\"body\":\"Yes.\",\"created_at\":\"\",\"id\":\"\",\"updated_at\":\"\"}],\"id\":\"\",\"page\":0,\"platform\":\"\",\"resolved\":false,\"resolved_at\":null,\"side\":\"head\",\"snapshot\":\"greeting\",\"started_in_build\":1,\"started_in_snapshot\":\"\"}],\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"greeting\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"}],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "feat", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "open_comment_threads": [ + { + "anchor": { + "kind": "point", + "x": 20.0, + "y": 30.0 + }, + "comments": [ + { + "author": { + "agent": "rmcp 3.12.0", + "kind": "agent", + "name": null + }, + "body": "Is this change meant?", + "created_at": "", + "id": "", + "updated_at": "" + }, + { + "author": { + "agent": "rmcp 3.12.0", + "kind": "agent", + "name": null + }, + "body": "Yes.", + "created_at": "", + "id": "", + "updated_at": "" + } + ], + "id": "", + "page": 0, + "platform": "", + "resolved": false, + "resolved_at": null, + "side": "head", + "snapshot": "greeting", + "started_in_build": 1, + "started_in_snapshot": "" + } + ], + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [ + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "greeting", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + } + ], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-2.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-2.json new file mode 100644 index 00000000..b2dae3a7 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-2.json @@ -0,0 +1,18 @@ +{ + "arguments": { + "build": 1 + }, + "result": { + "content": [ + { + "text": "{\"branch\":\"feat\",\"threads\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "branch": "feat", + "threads": [] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-3.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-3.json new file mode 100644 index 00000000..382ac147 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments-3.json @@ -0,0 +1,60 @@ +{ + "arguments": { + "build": 1, + "include_resolved": true + }, + "result": { + "content": [ + { + "text": "{\"branch\":\"feat\",\"threads\":[{\"anchor\":{\"kind\":\"point\",\"x\":20.0,\"y\":30.0},\"comments\":[{\"author\":{\"agent\":\"rmcp 3.12.0\",\"kind\":\"agent\",\"name\":null},\"body\":\"Is this change meant?\",\"created_at\":\"\",\"id\":\"\",\"updated_at\":\"\"},{\"author\":{\"agent\":\"rmcp 3.12.0\",\"kind\":\"agent\",\"name\":null},\"body\":\"Yes.\",\"created_at\":\"\",\"id\":\"\",\"updated_at\":\"\"}],\"id\":\"\",\"page\":0,\"platform\":\"\",\"resolved\":true,\"resolved_at\":\"\",\"side\":\"head\",\"snapshot\":\"greeting\",\"started_in_build\":1,\"started_in_snapshot\":\"\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "branch": "feat", + "threads": [ + { + "anchor": { + "kind": "point", + "x": 20.0, + "y": 30.0 + }, + "comments": [ + { + "author": { + "agent": "rmcp 3.12.0", + "kind": "agent", + "name": null + }, + "body": "Is this change meant?", + "created_at": "", + "id": "", + "updated_at": "" + }, + { + "author": { + "agent": "rmcp 3.12.0", + "kind": "agent", + "name": null + }, + "body": "Yes.", + "created_at": "", + "id": "", + "updated_at": "" + } + ], + "id": "", + "page": 0, + "platform": "", + "resolved": true, + "resolved_at": "", + "side": "head", + "snapshot": "greeting", + "started_in_build": 1, + "started_in_snapshot": "" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments.json new file mode 100644 index 00000000..d7175265 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/list_comments.json @@ -0,0 +1,48 @@ +{ + "arguments": { + "build": 1 + }, + "result": { + "content": [ + { + "text": "{\"branch\":\"feat\",\"threads\":[{\"anchor\":{\"kind\":\"point\",\"x\":20.0,\"y\":30.0},\"comments\":[{\"author\":{\"agent\":\"rmcp 3.12.0\",\"kind\":\"agent\",\"name\":null},\"body\":\"Is this greeting **meant** to change?\",\"created_at\":\"\",\"id\":\"\",\"updated_at\":\"\"}],\"id\":\"\",\"page\":0,\"platform\":\"\",\"resolved\":false,\"resolved_at\":null,\"side\":\"head\",\"snapshot\":\"greeting\",\"started_in_build\":1,\"started_in_snapshot\":\"\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "branch": "feat", + "threads": [ + { + "anchor": { + "kind": "point", + "x": 20.0, + "y": 30.0 + }, + "comments": [ + { + "author": { + "agent": "rmcp 3.12.0", + "kind": "agent", + "name": null + }, + "body": "Is this greeting **meant** to change?", + "created_at": "", + "id": "", + "updated_at": "" + } + ], + "id": "", + "page": 0, + "platform": "", + "resolved": false, + "resolved_at": null, + "side": "head", + "snapshot": "greeting", + "started_in_build": 1, + "started_in_snapshot": "" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-2.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-2.json new file mode 100644 index 00000000..0bf9409a --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-2.json @@ -0,0 +1,21 @@ +{ + "arguments": { + "anchor": { + "kind": "point", + "x": -2, + "y": 0 + }, + "body": "x", + "build": 1, + "snapshot": "greeting" + }, + "result": { + "content": [ + { + "text": "anchor coordinates are pixels from the image's top left, so they can't be negative", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-3.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-3.json new file mode 100644 index 00000000..ae6f8c6f --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment-3.json @@ -0,0 +1,20 @@ +{ + "arguments": { + "body": "Yes.", + "build": 1, + "thread": "" + }, + "result": { + "content": [ + { + "text": "{\"comment\":\"\",\"thread\":\"\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "comment": "", + "thread": "" + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment.json new file mode 100644 index 00000000..db46b972 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/post_comment.json @@ -0,0 +1,27 @@ +{ + "arguments": { + "anchor": { + "kind": "point", + "x": 20, + "y": 30 + }, + "body": "Is this greeting **meant** to change?", + "build": 1, + "page": 0, + "snapshot": "greeting" + }, + "result": { + "content": [ + { + "text": "{\"branch\":\"feat\",\"snapshot\":\"greeting\",\"thread\":\"\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "branch": "feat", + "snapshot": "greeting", + "thread": "" + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/resolve_comment.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/resolve_comment.json new file mode 100644 index 00000000..3064aece --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/resolve_comment.json @@ -0,0 +1,18 @@ +{ + "arguments": { + "thread": "" + }, + "result": { + "content": [ + { + "text": "{\"resolved\":true,\"thread\":\"\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "resolved": true, + "thread": "" + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review-2.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review-2.json new file mode 100644 index 00000000..8831018d --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review-2.json @@ -0,0 +1,16 @@ +{ + "arguments": { + "action": "approve", + "build": 1, + "note": "why" + }, + "result": { + "content": [ + { + "text": "build 1 isn't finalized yet: run `visualci build finalize` first", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review.json new file mode 100644 index 00000000..0f6636af --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/review.json @@ -0,0 +1,16 @@ +{ + "arguments": { + "action": "approve", + "build": 1, + "comment": "nope" + }, + "result": { + "content": [ + { + "text": "build 1 isn't finalized yet: run `visualci build finalize` first", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/update_comment.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/update_comment.json new file mode 100644 index 00000000..23ee7969 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/update_comment.json @@ -0,0 +1,19 @@ +{ + "arguments": { + "body": "Is this change meant?", + "comment": "" + }, + "result": { + "content": [ + { + "text": "{\"body\":\"Is this change meant?\",\"comment\":\"\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "body": "Is this change meant?", + "comment": "" + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/upload_snapshots.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/upload_snapshots.json new file mode 100644 index 00000000..16605966 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/upload_snapshots.json @@ -0,0 +1,31 @@ +{ + "arguments": { + "build": 1, + "files": [ + { + "content_base64": "aGVsbG8K", + "filename": "greeting.txt", + "name": "greeting" + } + ] + }, + "result": { + "content": [ + { + "text": "{\"build\":1,\"snapshots\":[{\"name\":\"greeting\",\"platform\":\"\",\"stored\":false}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "build": 1, + "snapshots": [ + { + "name": "greeting", + "platform": "", + "stored": false + } + ] + } + } +} diff --git a/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/whoami.json b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/whoami.json new file mode 100644 index 00000000..c873c983 --- /dev/null +++ b/app/tests/golden/mcp/agents_comment_on_snapshots_and_resolve_threads/whoami.json @@ -0,0 +1,25 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"kind\":\"project\",\"open_comment_threads\":[{\"branch\":\"feat\",\"open\":1,\"project\":\"/pdfs\"}],\"project\":\"/pdfs\",\"waiting_for_review\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "kind": "project", + "open_comment_threads": [ + { + "branch": "feat", + "open": 1, + "project": "/pdfs" + } + ], + "project": "/pdfs", + "waiting_for_review": [] + } + } +} diff --git a/app/tests/golden/mcp/every_tool_refuses_arguments_it_does_not_take/review.json b/app/tests/golden/mcp/every_tool_refuses_arguments_it_does_not_take/review.json new file mode 100644 index 00000000..2feff9c4 --- /dev/null +++ b/app/tests/golden/mcp/every_tool_refuses_arguments_it_does_not_take/review.json @@ -0,0 +1,16 @@ +{ + "arguments": { + "action": "approve", + "build": 1, + "notes": "x" + }, + "result": { + "content": [ + { + "text": "review doesn't take `notes`.\n\nreview takes:\n- action (required; string): `approve` or `reject`.\n- build (required; integer or string)\n- comment (string): With `reject`: why, as a comment thread on each rejected snapshot (Markdown), so the next person or agent sees what's wrong. Approving a snapshot with an open thread is refused until the thread is resolved.\n- note (string): Why you approved or rejected, in a sentence. It's shown wherever the review appears (the build's reviews, the pull request comment). A note, not a thread: it never blocks anything.\n- only (string): Only the build's `added` (new) snapshots, only its `changed` ones, or only its `matching` ones (changes made only of changes merged pull requests approved: `get_build`'s `matches`), in one call. Not with `snapshots`.\n- project (string): `org/project`. Optional with a project token.\n- snapshots (array): Snapshot names to review; all changed snapshots when left out.\nExample: {\"action\":\"\",\"build\":8}", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/create_build.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/create_build.json new file mode 100644 index 00000000..560b7e67 --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/create_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-2.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-2.json new file mode 100644 index 00000000..c0ff4250 --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-2.json @@ -0,0 +1,290 @@ +{ + "arguments": { + "build": "1", + "include_unchanged": true, + "offset": 30 + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"groups\":[{\"count\":2,\"prefix\":\"\",\"state\":\"pending\"},{\"count\":5,\"prefix\":\"api/\",\"state\":\"pending\"},{\"count\":35,\"prefix\":\"screenshots/home/\",\"state\":\"pending\"}],\"id\":\"\",\"listed\":\"31 to 42 of 42\",\"mode\":\"ci\",\"name\":\"default\",\"next_offset\":null,\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/25\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/26\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/27\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/28\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/29\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/30\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/31\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/32\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/33\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/34\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"twice\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"twice\",\"pages\":null,\"platform\":\"firefox\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"}],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "groups": [ + { + "count": 2, + "prefix": "", + "state": "pending" + }, + { + "count": 5, + "prefix": "api/", + "state": "pending" + }, + { + "count": 35, + "prefix": "screenshots/home/", + "state": "pending" + } + ], + "id": "", + "listed": "31 to 42 of 42", + "mode": "ci", + "name": "default", + "next_offset": null, + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [ + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/25", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/26", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/27", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/28", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/29", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/30", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/31", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/32", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/33", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/34", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "twice", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "twice", + "pages": null, + "platform": "firefox", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + } + ], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-3.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-3.json new file mode 100644 index 00000000..dbcb084e --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build-3.json @@ -0,0 +1,613 @@ +{ + "arguments": { + "build": 1, + "include_unchanged": true + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"groups\":[{\"count\":2,\"prefix\":\"\",\"state\":\"pending\"},{\"count\":5,\"prefix\":\"api/\",\"state\":\"pending\"},{\"count\":35,\"prefix\":\"screenshots/home/\",\"state\":\"pending\"}],\"id\":\"\",\"listed\":\"1 to 30 of 42\",\"mode\":\"ci\",\"name\":\"default\",\"next_offset\":30,\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/0\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/1\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/2\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/3\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/4\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/00\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/01\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/02\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/03\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/04\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/05\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/06\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/07\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/08\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/09\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/10\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/11\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/12\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/13\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/14\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/15\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/16\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/17\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/18\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/19\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/20\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/21\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/22\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/23\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/24\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"}],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "groups": [ + { + "count": 2, + "prefix": "", + "state": "pending" + }, + { + "count": 5, + "prefix": "api/", + "state": "pending" + }, + { + "count": 35, + "prefix": "screenshots/home/", + "state": "pending" + } + ], + "id": "", + "listed": "1 to 30 of 42", + "mode": "ci", + "name": "default", + "next_offset": 30, + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [ + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/0", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/1", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/2", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/3", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/4", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/00", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/01", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/02", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/03", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/04", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/05", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/06", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/07", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/08", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/09", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/10", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/11", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/12", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/13", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/14", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/15", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/16", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/17", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/18", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/19", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/20", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/21", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/22", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/23", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/24", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + } + ], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build.json new file mode 100644 index 00000000..35693ffe --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_build.json @@ -0,0 +1,613 @@ +{ + "arguments": { + "build": "1", + "include_unchanged": true + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"groups\":[{\"count\":2,\"prefix\":\"\",\"state\":\"pending\"},{\"count\":5,\"prefix\":\"api/\",\"state\":\"pending\"},{\"count\":35,\"prefix\":\"screenshots/home/\",\"state\":\"pending\"}],\"id\":\"\",\"listed\":\"1 to 30 of 42\",\"mode\":\"ci\",\"name\":\"default\",\"next_offset\":30,\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/0\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/1\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/2\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/3\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"api/4\",\"pages\":null,\"platform\":\"\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/00\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/01\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/02\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/03\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/04\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/05\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/06\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/07\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/08\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/09\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/10\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/11\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/12\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/13\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/14\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/15\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/16\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/17\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/18\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/19\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/20\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/21\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/22\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/23\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"},{\"approved_elsewhere\":null,\"change\":null,\"changed_pages\":null,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"matched_environment\":null,\"moved_lines\":0,\"name\":\"screenshots/home/24\",\"pages\":null,\"platform\":\"chrome\",\"review\":null,\"state\":\"pending\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"}],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "groups": [ + { + "count": 2, + "prefix": "", + "state": "pending" + }, + { + "count": 5, + "prefix": "api/", + "state": "pending" + }, + { + "count": 35, + "prefix": "screenshots/home/", + "state": "pending" + } + ], + "id": "", + "listed": "1 to 30 of 42", + "mode": "ci", + "name": "default", + "next_offset": 30, + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [ + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/0", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/1", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/2", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/3", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "api/4", + "pages": null, + "platform": "", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/00", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/01", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/02", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/03", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/04", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/05", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/06", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/07", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/08", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/09", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/10", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/11", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/12", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/13", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/14", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/15", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/16", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/17", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/18", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/19", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/20", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/21", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/22", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/23", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + }, + { + "approved_elsewhere": null, + "change": null, + "changed_pages": null, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "matched_environment": null, + "moved_lines": 0, + "name": "screenshots/home/24", + "pages": null, + "platform": "chrome", + "review": null, + "state": "pending", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + } + ], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-2.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-2.json new file mode 100644 index 00000000..6a1fe8ff --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-2.json @@ -0,0 +1,16 @@ +{ + "arguments": { + "build": "1", + "name": "api/1", + "platform": "chrome" + }, + "result": { + "content": [ + { + "text": "\"api/1\" isn't in build 1 on platform \"chrome\"; it is on no platform", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-3.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-3.json new file mode 100644 index 00000000..a6dbb7cd --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-3.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": "1", + "name": "missing" + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-4.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-4.json new file mode 100644 index 00000000..be9d6aa6 --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-4.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": 1, + "id": "" + }, + "result": { + "content": [ + { + "text": "{\n \"base_lines\": 0,\n \"build\": 1,\n \"compared_with\": \"baseline\",\n \"error\": null,\n \"format\": \"text\",\n \"head_lines\": 0,\n \"ignore_rules\": [],\n \"json_changes\": null,\n \"json_changes_truncated\": false,\n \"kind\": \"text\",\n \"meta\": {},\n \"name\": \"twice\",\n \"note\": null,\n \"open_comment_threads\": [],\n \"platform\": \"chrome\",\n \"review\": null,\n \"state\": \"pending\",\n \"url\": \"https://app.visualci.test//pdfs/builds/1/snapshots/\"\n}", + "type": "text" + } + ], + "isError": false + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-5.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-5.json new file mode 100644 index 00000000..0eb58195 --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot-5.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": "#1", + "name": "" + }, + "result": { + "content": [ + { + "text": "{\n \"base_lines\": 0,\n \"build\": 1,\n \"compared_with\": \"baseline\",\n \"error\": null,\n \"format\": \"text\",\n \"head_lines\": 0,\n \"ignore_rules\": [],\n \"json_changes\": null,\n \"json_changes_truncated\": false,\n \"kind\": \"text\",\n \"meta\": {},\n \"name\": \"twice\",\n \"note\": null,\n \"open_comment_threads\": [],\n \"platform\": \"chrome\",\n \"review\": null,\n \"state\": \"pending\",\n \"url\": \"https://app.visualci.test//pdfs/builds/1/snapshots/\"\n}", + "type": "text" + } + ], + "isError": false + } +} diff --git a/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot.json b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot.json new file mode 100644 index 00000000..70acd9ba --- /dev/null +++ b/app/tests/golden/mcp/get_build_pages_long_lists_and_get_snapshot_finds_a_unique_name_without_its_platform/get_snapshot.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": "1", + "name": "twice" + }, + "result": { + "content": [ + { + "text": "\"twice\" is in build 1 on several platforms (chrome, firefox): pass platform", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json new file mode 100644 index 00000000..af752304 --- /dev/null +++ b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-2.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "name": "visualci-jenkins" + }, + "result": { + "content": [ + { + "text": "---\nname: visualci-jenkins\ndescription: \"Sets up VisualCI in a Jenkins pipeline (Jenkinsfile): the token as a credential, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel stages. Use when the user wants visual or snapshot review in Jenkins, or a project has a Jenkinsfile and VisualCI. Not for other CI providers, or for writing the tests themselves.\"\nlicense: Apache-2.0\nmetadata:\n docs: https://visualci.com/docs/ci/jenkins.md\n---\n\n\n\n# Jenkins\n\nStore a project token as a **Secret text** credential, say `visualci-token`. The CLI reads the commit from `GIT_COMMIT`, the branch from `CHANGE_BRANCH`, `BRANCH_NAME` or `GIT_BRANCH`, and the pull request from `CHANGE_ID`.\n\n```groovy\npipeline {\n agent any\n environment {\n VISUALCI_TOKEN = credentials('visualci-token')\n }\n stages {\n stage('Test') {\n steps {\n sh 'curl -fsSL https://visualci.com/install.sh | VISUALCI_VERSION=0.2.12 VISUALCI_INSTALL_DIR=\"$WORKSPACE/bin\" sh'\n sh '''\n export PATH=\"$WORKSPACE/bin:$PATH\"\n export VISUALCI_BUILD_ID=$(visualci build create)\n npm test -- -u # write snapshots instead of failing; see the snapshot guides\n visualci upload --from auto src tests\n visualci build finalize\n '''\n }\n }\n }\n}\n```\n\nEach `sh` step is its own shell, so keep the build's commands in one step, or pass `VISUALCI_BUILD_ID` on with `withEnv`.\n\n## Parallel stages\n\nCreate the build once, then give each parallel stage a shard number:\n\n```groovy\nstage('Start VisualCI') {\n steps {\n script {\n env.VISUALCI_BUILD_ID = sh(script: 'bin/visualci build create --shards 2', returnStdout: true).trim()\n }\n }\n}\nstage('Tests') {\n parallel {\n stage('Unit') { steps { sh 'npm run test:unit -- -u && bin/visualci upload --from auto src && bin/visualci build finalize --shard 0' } }\n stage('Browser') { steps { sh 'npm run test:e2e && bin/visualci upload screenshots && bin/visualci build finalize --shard 1' } }\n }\n}\n```\n\nSee [Other CI providers](https://visualci.com/docs/ci/other.md) for the environment variables and how shards work.\n\nThis skill is the page https://visualci.com/docs/ci/jenkins.md. All of VisualCI's documentation: https://visualci.com/llms.txt\n", + "type": "text" + } + ], + "isError": false + } +} diff --git a/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-3.json b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-3.json new file mode 100644 index 00000000..88227560 --- /dev/null +++ b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill-3.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "name": "nope" + }, + "result": { + "content": [ + { + "text": "no skill nope; call get_skill without a name to list them", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill.json b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill.json new file mode 100644 index 00000000..7a06804e --- /dev/null +++ b/app/tests/golden/mcp/get_skill_lists_the_skills_and_returns_one/get_skill.json @@ -0,0 +1,116 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "{\"skills\":[{\"description\":\"Sets up VisualCI, visual regression and snapshot review for PDFs, screenshots, images, JSON, HTML and text: installs the CLI, creates the project and a CI token, sends the first build, and picks the visualci-* skill for the user's CI provider and test tools. Use when the user mentions VisualCI, wants visual regression testing, screenshot or PDF comparison, or snapshot changes that wait for review instead of failing CI. Not for a specific CI provider or test tool once VisualCI is set up: use that skill.\",\"name\":\"visualci\"},{\"description\":\"Sets up VisualCI in Bitbucket Pipelines (bitbucket-pipelines.yml): the token as a secured variable, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel steps. Use when the user wants visual or snapshot review in Bitbucket Pipelines, or a project has bitbucket-pipelines.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-bitbucket\"},{\"description\":\"Sets up VisualCI in Buildkite pipelines: the token as a secret, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel jobs. Use when the user wants visual or snapshot review in Buildkite, or a project has .buildkite/ and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-buildkite\"},{\"description\":\"Sets up VisualCI in CircleCI (.circleci/config.yml): the token in a context or project variable, installing the CLI, creating the build, uploading snapshots and finalizing, including parallelism. Use when the user wants visual or snapshot review in CircleCI, or a project has .circleci/config.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-circleci\"},{\"description\":\"Writes and edits visualci.yml: ignore rules scoped to snapshot globs (JSON paths and regular expressions), thresholds, PDF rendering, the CI mode and what to upload. Use when the user wants to ignore volatile values such as timestamps or IDs, change thresholds or the CI mode, or keep VisualCI settings in the repository. Not for per-snapshot ignores in a single test.\",\"name\":\"visualci-config\"},{\"description\":\"Sends Cypress screenshots to VisualCI: taking them with cy.screenshot, turning off failure screenshots, uploading cypress/screenshots with a platform per browser and a threshold, and reviewing changes. Use when a project uses Cypress (cypress.config, cy.screenshot) and wants visual review with VisualCI. Not for Playwright or Capybara.\",\"name\":\"visualci-cypress\"},{\"description\":\"Makes browser screenshots deterministic so VisualCI shows only real changes, covering seeded randomness, loaded and self-hosted fonts, reduced motion, frozen animations, GIFs and videos, a pinned clock and timezone, a hermetic network, and a fixed viewport, scrollbar and device pixel ratio. Gives recipes for Playwright, Cypress and Storybook. Use when screenshots differ between runs of the same commit (flaky diffs), or when setting up visual tests. Not for uploading screenshots or setting up the CI provider.\",\"name\":\"visualci-deterministic\"},{\"description\":\"Sets up VisualCI in GitHub Actions, including Blacksmith and Depot runners, with VisualCI's action (DocSpring/visualci/clients/github-action): the token as a secret, what to upload, and matrix and parallel jobs, or with the CLI directly. Use when the user wants visual or snapshot review in GitHub Actions, or a project has .github/workflows and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-github-actions\"},{\"description\":\"Sets up VisualCI in GitLab CI (.gitlab-ci.yml): the token as a masked variable, installing the CLI, creating the build, uploading snapshots and finalizing, and the CI modes for reviewing without a GitHub check. Use when the user wants visual or snapshot review in GitLab CI, or a project has .gitlab-ci.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-gitlab\"},{\"description\":\"Sends insta (Rust) snapshot files to VisualCI, so a changed snapshot waits for review instead of failing cargo test: accepting snapshots in CI and uploading the .snap files. Use when a Rust project uses insta (assert_snapshot!, snapshots/*.snap) with VisualCI. Not for other languages.\",\"name\":\"visualci-insta\"},{\"description\":\"Sets up VisualCI in a Jenkins pipeline (Jenkinsfile): the token as a credential, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel stages. Use when the user wants visual or snapshot review in Jenkins, or a project has a Jenkinsfile and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-jenkins\"},{\"description\":\"Sends Jest snapshot files to VisualCI, so a changed snapshot waits for review instead of failing the build: running Jest with -u in CI and uploading the .snap files, one snapshot per test. Use when a project uses Jest snapshots (toMatchSnapshot, __snapshots__/*.snap) with VisualCI. Not for Vitest or screenshots.\",\"name\":\"visualci-jest\"},{\"description\":\"Sets up VisualCI for a Laravel Rust app's tests with the snapshot-testing-laravel crate: browser screenshots and HTML, JSON and text snapshots of responses, run under `visualci test -- cargo test`, with names, platforms, ignore rules and thresholds as VisualCI sees them. Use when a Laravel Rust project uses snapshot-testing-laravel, or wants screenshot or snapshot tests with VisualCI. Not for other Rust projects (see visualci-insta) or other frameworks.\",\"name\":\"visualci-laravel-rust\"},{\"description\":\"Runs tests on a laptop against VisualCI's baselines: local environments, each test failing once with every snapshot it changed, and approving local changes so the branch's baseline matches. Use when the user runs visual or snapshot tests locally with VisualCI, sees VisualCI failures in a local run, or wants to approve local results. Not for CI setup.\",\"name\":\"visualci-local-runs\"},{\"description\":\"Sends mobile app screenshots to VisualCI from iOS (XCUITest, swift-snapshot-testing), Android (Espresso, Paparazzi, Roborazzi), Maestro, Detox (React Native) and Flutter golden tests, with a platform tag per OS version and device. Use when an iOS, Android, React Native or Flutter project wants visual review with VisualCI. Not for browser screenshots (Playwright, Cypress) or for setting up the CI provider.\",\"name\":\"visualci-mobile\"},{\"description\":\"Compares PDFs a test suite generates (Ruby, Node, Python or anything else) with VisualCI, page by page in one pinned renderer: uploading them, fingerprints, checking fingerprints are stable, and reading page, text and moved-line changes. Use when a project generates PDFs (invoices, reports, statements, labels) and the user wants them checked for visual changes. Not for screenshots.\",\"name\":\"visualci-pdfs\"},{\"description\":\"Sends Playwright screenshots to VisualCI instead of toHaveScreenshot baselines in the repository: saving screenshots in tests, uploading them with a platform per browser project and a threshold, and reviewing changes. Use when a project uses Playwright (playwright.config, @playwright/test) and wants visual review with VisualCI. Not for Cypress or Capybara.\",\"name\":\"visualci-playwright\"},{\"description\":\"Reviews a VisualCI build over the MCP server: finds what changed, reads each snapshot's diff images, text diff or JSON changes, checks them against the code and the task, then approves intended changes or fixes the code and pushes. Use when a VisualCI check is pending or failing on a pull request, the user asks what changed visually, or asks to approve or reject snapshots. Not for setting VisualCI up in CI.\",\"name\":\"visualci-review\"},{\"description\":\"Adds VisualCI to RSpec feature and system specs with the visualci gem: screenshots from Capybara, PDFs, JSON, HTML and text matchers, per-snapshot ignore rules, local runs that fail each example once, and sharded CI builds. Use when a Ruby project wants visual review of Capybara screenshots or generated documents in RSpec. Not for rspec-snapshot files: see visualci-rspec-snapshot.\",\"name\":\"visualci-rspec-screenshots\"},{\"description\":\"Sends rspec-snapshot files to VisualCI, so a changed snapshot waits for review instead of failing RSpec: updating snapshots in CI and uploading the .snap files. Use when a Ruby project uses rspec-snapshot (match_snapshot) with VisualCI. Not for RSpec screenshots or PDFs: see visualci-rspec-screenshots and visualci-pdfs.\",\"name\":\"visualci-rspec-snapshot\"},{\"description\":\"Sets up VisualCI in Semaphore (.semaphore/semaphore.yml): the token as a secret, installing the CLI, creating the build, uploading snapshots and finalizing, including parallelism. Use when the user wants visual or snapshot review in Semaphore, or a project has .semaphore/ and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-semaphore\"},{\"description\":\"Sends syrupy (pytest) snapshot files to VisualCI, so a changed snapshot waits for review instead of failing pytest: updating snapshots in CI and uploading the .ambr files, one snapshot per test. Use when a Python project uses syrupy (snapshot fixture, __snapshots__/*.ambr) with VisualCI. Not for other languages.\",\"name\":\"visualci-syrupy\"},{\"description\":\"Sets up VisualCI in TeamCity: the token as a password parameter, the commit, branch and pull request from TeamCity's parameters, installing the CLI, creating the build, uploading snapshots and finalizing. Use when the user wants visual or snapshot review in TeamCity, or a project has a .teamcity/ directory and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-teamcity\"},{\"description\":\"Sets up VisualCI in Travis CI (.travis.yml): the token as a repository variable, installing the CLI, creating the build, uploading snapshots and finalizing. Use when the user wants visual or snapshot review in Travis CI, or a project has .travis.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.\",\"name\":\"visualci-travis\"},{\"description\":\"Sends Vitest snapshot files to VisualCI, so a changed snapshot waits for review instead of failing the build: running Vitest with -u in CI and uploading the .snap files, one snapshot per test. Use when a project uses Vitest snapshots (toMatchSnapshot, __snapshots__/*.snap) with VisualCI. Not for Jest or screenshots.\",\"name\":\"visualci-vitest\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "skills": [ + { + "description": "Sets up VisualCI, visual regression and snapshot review for PDFs, screenshots, images, JSON, HTML and text: installs the CLI, creates the project and a CI token, sends the first build, and picks the visualci-* skill for the user's CI provider and test tools. Use when the user mentions VisualCI, wants visual regression testing, screenshot or PDF comparison, or snapshot changes that wait for review instead of failing CI. Not for a specific CI provider or test tool once VisualCI is set up: use that skill.", + "name": "visualci" + }, + { + "description": "Sets up VisualCI in Bitbucket Pipelines (bitbucket-pipelines.yml): the token as a secured variable, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel steps. Use when the user wants visual or snapshot review in Bitbucket Pipelines, or a project has bitbucket-pipelines.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-bitbucket" + }, + { + "description": "Sets up VisualCI in Buildkite pipelines: the token as a secret, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel jobs. Use when the user wants visual or snapshot review in Buildkite, or a project has .buildkite/ and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-buildkite" + }, + { + "description": "Sets up VisualCI in CircleCI (.circleci/config.yml): the token in a context or project variable, installing the CLI, creating the build, uploading snapshots and finalizing, including parallelism. Use when the user wants visual or snapshot review in CircleCI, or a project has .circleci/config.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-circleci" + }, + { + "description": "Writes and edits visualci.yml: ignore rules scoped to snapshot globs (JSON paths and regular expressions), thresholds, PDF rendering, the CI mode and what to upload. Use when the user wants to ignore volatile values such as timestamps or IDs, change thresholds or the CI mode, or keep VisualCI settings in the repository. Not for per-snapshot ignores in a single test.", + "name": "visualci-config" + }, + { + "description": "Sends Cypress screenshots to VisualCI: taking them with cy.screenshot, turning off failure screenshots, uploading cypress/screenshots with a platform per browser and a threshold, and reviewing changes. Use when a project uses Cypress (cypress.config, cy.screenshot) and wants visual review with VisualCI. Not for Playwright or Capybara.", + "name": "visualci-cypress" + }, + { + "description": "Makes browser screenshots deterministic so VisualCI shows only real changes, covering seeded randomness, loaded and self-hosted fonts, reduced motion, frozen animations, GIFs and videos, a pinned clock and timezone, a hermetic network, and a fixed viewport, scrollbar and device pixel ratio. Gives recipes for Playwright, Cypress and Storybook. Use when screenshots differ between runs of the same commit (flaky diffs), or when setting up visual tests. Not for uploading screenshots or setting up the CI provider.", + "name": "visualci-deterministic" + }, + { + "description": "Sets up VisualCI in GitHub Actions, including Blacksmith and Depot runners, with VisualCI's action (DocSpring/visualci/clients/github-action): the token as a secret, what to upload, and matrix and parallel jobs, or with the CLI directly. Use when the user wants visual or snapshot review in GitHub Actions, or a project has .github/workflows and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-github-actions" + }, + { + "description": "Sets up VisualCI in GitLab CI (.gitlab-ci.yml): the token as a masked variable, installing the CLI, creating the build, uploading snapshots and finalizing, and the CI modes for reviewing without a GitHub check. Use when the user wants visual or snapshot review in GitLab CI, or a project has .gitlab-ci.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-gitlab" + }, + { + "description": "Sends insta (Rust) snapshot files to VisualCI, so a changed snapshot waits for review instead of failing cargo test: accepting snapshots in CI and uploading the .snap files. Use when a Rust project uses insta (assert_snapshot!, snapshots/*.snap) with VisualCI. Not for other languages.", + "name": "visualci-insta" + }, + { + "description": "Sets up VisualCI in a Jenkins pipeline (Jenkinsfile): the token as a credential, installing the CLI, creating the build, uploading snapshots and finalizing, including parallel stages. Use when the user wants visual or snapshot review in Jenkins, or a project has a Jenkinsfile and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-jenkins" + }, + { + "description": "Sends Jest snapshot files to VisualCI, so a changed snapshot waits for review instead of failing the build: running Jest with -u in CI and uploading the .snap files, one snapshot per test. Use when a project uses Jest snapshots (toMatchSnapshot, __snapshots__/*.snap) with VisualCI. Not for Vitest or screenshots.", + "name": "visualci-jest" + }, + { + "description": "Sets up VisualCI for a Laravel Rust app's tests with the snapshot-testing-laravel crate: browser screenshots and HTML, JSON and text snapshots of responses, run under `visualci test -- cargo test`, with names, platforms, ignore rules and thresholds as VisualCI sees them. Use when a Laravel Rust project uses snapshot-testing-laravel, or wants screenshot or snapshot tests with VisualCI. Not for other Rust projects (see visualci-insta) or other frameworks.", + "name": "visualci-laravel-rust" + }, + { + "description": "Runs tests on a laptop against VisualCI's baselines: local environments, each test failing once with every snapshot it changed, and approving local changes so the branch's baseline matches. Use when the user runs visual or snapshot tests locally with VisualCI, sees VisualCI failures in a local run, or wants to approve local results. Not for CI setup.", + "name": "visualci-local-runs" + }, + { + "description": "Sends mobile app screenshots to VisualCI from iOS (XCUITest, swift-snapshot-testing), Android (Espresso, Paparazzi, Roborazzi), Maestro, Detox (React Native) and Flutter golden tests, with a platform tag per OS version and device. Use when an iOS, Android, React Native or Flutter project wants visual review with VisualCI. Not for browser screenshots (Playwright, Cypress) or for setting up the CI provider.", + "name": "visualci-mobile" + }, + { + "description": "Compares PDFs a test suite generates (Ruby, Node, Python or anything else) with VisualCI, page by page in one pinned renderer: uploading them, fingerprints, checking fingerprints are stable, and reading page, text and moved-line changes. Use when a project generates PDFs (invoices, reports, statements, labels) and the user wants them checked for visual changes. Not for screenshots.", + "name": "visualci-pdfs" + }, + { + "description": "Sends Playwright screenshots to VisualCI instead of toHaveScreenshot baselines in the repository: saving screenshots in tests, uploading them with a platform per browser project and a threshold, and reviewing changes. Use when a project uses Playwright (playwright.config, @playwright/test) and wants visual review with VisualCI. Not for Cypress or Capybara.", + "name": "visualci-playwright" + }, + { + "description": "Reviews a VisualCI build over the MCP server: finds what changed, reads each snapshot's diff images, text diff or JSON changes, checks them against the code and the task, then approves intended changes or fixes the code and pushes. Use when a VisualCI check is pending or failing on a pull request, the user asks what changed visually, or asks to approve or reject snapshots. Not for setting VisualCI up in CI.", + "name": "visualci-review" + }, + { + "description": "Adds VisualCI to RSpec feature and system specs with the visualci gem: screenshots from Capybara, PDFs, JSON, HTML and text matchers, per-snapshot ignore rules, local runs that fail each example once, and sharded CI builds. Use when a Ruby project wants visual review of Capybara screenshots or generated documents in RSpec. Not for rspec-snapshot files: see visualci-rspec-snapshot.", + "name": "visualci-rspec-screenshots" + }, + { + "description": "Sends rspec-snapshot files to VisualCI, so a changed snapshot waits for review instead of failing RSpec: updating snapshots in CI and uploading the .snap files. Use when a Ruby project uses rspec-snapshot (match_snapshot) with VisualCI. Not for RSpec screenshots or PDFs: see visualci-rspec-screenshots and visualci-pdfs.", + "name": "visualci-rspec-snapshot" + }, + { + "description": "Sets up VisualCI in Semaphore (.semaphore/semaphore.yml): the token as a secret, installing the CLI, creating the build, uploading snapshots and finalizing, including parallelism. Use when the user wants visual or snapshot review in Semaphore, or a project has .semaphore/ and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-semaphore" + }, + { + "description": "Sends syrupy (pytest) snapshot files to VisualCI, so a changed snapshot waits for review instead of failing pytest: updating snapshots in CI and uploading the .ambr files, one snapshot per test. Use when a Python project uses syrupy (snapshot fixture, __snapshots__/*.ambr) with VisualCI. Not for other languages.", + "name": "visualci-syrupy" + }, + { + "description": "Sets up VisualCI in TeamCity: the token as a password parameter, the commit, branch and pull request from TeamCity's parameters, installing the CLI, creating the build, uploading snapshots and finalizing. Use when the user wants visual or snapshot review in TeamCity, or a project has a .teamcity/ directory and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-teamcity" + }, + { + "description": "Sets up VisualCI in Travis CI (.travis.yml): the token as a repository variable, installing the CLI, creating the build, uploading snapshots and finalizing. Use when the user wants visual or snapshot review in Travis CI, or a project has .travis.yml and VisualCI. Not for other CI providers, or for writing the tests themselves.", + "name": "visualci-travis" + }, + { + "description": "Sends Vitest snapshot files to VisualCI, so a changed snapshot waits for review instead of failing the build: running Vitest with -u in CI and uploading the .snap files, one snapshot per test. Use when a project uses Vitest snapshots (toMatchSnapshot, __snapshots__/*.snap) with VisualCI. Not for Jest or screenshots.", + "name": "visualci-vitest" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-project-token.json b/app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-project-token.json new file mode 100644 index 00000000..ac56be47 --- /dev/null +++ b/app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-project-token.json @@ -0,0 +1,1579 @@ +{ + "tools": [ + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Contact sheet" + }, + "description": "Many snapshots of a build at a glance: one image with a grid of thumbnails (each snapshot's first page, the new version, or the old one for a removed snapshot), and the list of what's in it in the same order, left to right and top to bottom, with each one's name, state and link. For checking a build with many added or changed snapshots in a few calls; page through with offset. Text snapshots have no thumbnail: look at them with get_snapshot.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "description": "The build number or id.", + "type": [ + "integer", + "string" + ] + }, + "columns": { + "description": "Thumbnails per row, 1 to 8. Default 4.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "limit": { + "description": "How many per sheet, at most 48. Default 24.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "offset": { + "description": "Skip this many (for the next sheet). Default 0.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "order": { + "description": "`change` (the default): the largest change first, then added and removed. `name`: by name. The order snapshots are listed in for review. `change`: Changed snapshots, the largest change first; then added, removed, failed and the rest. The default; `name`: By name.", + "enum": [ + "change", + "name" + ], + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "states": { + "description": "Which snapshots, by state: comma-separated, from `changed`, `added`, `removed`, `unchanged`, `ignored`\n(default `changed,added`).", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "contact_sheet" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create build" + }, + "description": "Start a build, as CI does: then `upload_snapshots` and `finalize_build`. VisualCI compares it with the baseline from the branch's ancestors (or the default branch).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "type": "string" + }, + "commit": { + "description": "The commit SHA the files come from.", + "type": "string" + }, + "config": { + "description": "The repository's visualci.yml as JSON (the CLI sends it). Its fields override the project's settings for this\nbuild; ignore rules must each name their snapshots.", + "type": "object" + }, + "environment": { + "description": "Where the build runs: `ci` (the default), `local-mac`, `local-linux`. Screenshots keep a baseline set per\nenvironment; documents and text share one.", + "type": [ + "string", + "null" + ] + }, + "mode": { + "description": "`ci` (the default) or `local` (a check from a laptop that never becomes a baseline).", + "type": [ + "string", + "null" + ] + }, + "name": { + "description": "Builds with different names (e.g. `pdfs`, `browser`) keep separate baselines. Default `default`.", + "type": [ + "string", + "null" + ] + }, + "nonce": { + "description": "Calls with the same nonce get the same build back (for parallel shards).", + "type": [ + "string", + "null" + ] + }, + "parent_commits": { + "default": [], + "description": "Ancestor commits, nearest first, for finding the baseline.", + "items": { + "type": "string" + }, + "type": "array" + }, + "pr_number": { + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "shard_total": { + "description": "How many shards will finalize the build (default 1).", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "subset": { + "default": false, + "description": "The build has only some of the project's snapshots; missing ones are carried forward, not removed.", + "type": "boolean" + } + }, + "required": [ + "commit", + "branch" + ], + "type": "object" + }, + "name": "create_build" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create organization" + }, + "description": "Create an organization with you as its admin (personal access tokens only), on the Free plan.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "slug": { + "description": "Lowercase letters, digits and dashes; used in URLs.", + "type": "string" + } + }, + "required": [ + "slug", + "name" + ], + "type": "object" + }, + "name": "create_organization" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create project" + }, + "description": "Create a project in an organization (owners and admins). Then `create_project_token` for CI, and `update_project` to link its GitHub repository.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "org": { + "type": "string" + }, + "slug": { + "description": "Lowercase letters, digits and dashes; used in URLs.", + "type": "string" + } + }, + "required": [ + "org", + "slug", + "name" + ], + "type": "object" + }, + "name": "create_project" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create project token" + }, + "description": "Create a project token (`vci_...`) for CI or the CLI. The token is in this answer only: store it where it's needed (e.g. as VISUALCI_TOKEN).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "description": "What the token is for, e.g. `CircleCI`.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "name": "create_project_token" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Delete comment" + }, + "description": "Delete a comment (your own; an organization admin can delete anyone's). A thread left with no comments goes too.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "body": { + "description": "The new text (Markdown), for `update_comment`.", + "type": [ + "string", + "null" + ] + }, + "comment": { + "description": "The comment's id.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "comment" + ], + "type": "object" + }, + "name": "delete_comment" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Delete project token" + }, + "description": "Delete a project token. Anything still using it (a CI variable) stops working.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "token_id": { + "description": "The token's id, from `get_project`.", + "format": "int64", + "type": "integer" + } + }, + "required": [ + "token_id" + ], + "type": "object" + }, + "name": "delete_project_token" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Finalize build" + }, + "description": "Finish a build (or one shard of it): VisualCI renders and compares what was uploaded. Then poll `get_build` until its state is completed. A build that was sent no snapshots fails, unless allow_empty is true or empty_reason says why it has none (\"inputs unchanged\").", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "allow_empty": { + "description": "True when the build may have no snapshots on purpose. Otherwise a build that was sent none fails.", + "type": [ + "boolean", + "null" + ] + }, + "build": { + "type": [ + "integer", + "string" + ] + }, + "empty_reason": { + "description": "Why it has none, like \"inputs unchanged\" (the CI run skipped the tests): implies allow_empty, and shows in the\nbuild's summary with the build its baseline came from.", + "type": [ + "string", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "shard": { + "description": "The shard that finished, when the build has several.", + "format": "int32", + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "finalize_build" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get build" + }, + "description": "A build's status and its snapshots that need attention, 30 at a time (offset and limit page through; longer lists also come grouped by state and name prefix) (changed, added, removed, failed), with how many pages changed in each, the largest change first (order: name to sort by name), and approved_elsewhere when the same new version was already approved on another branch (a hint: it approves nothing). Unchanged snapshots are only counted unless include_unchanged is set. `config` is the visualci.yml the build was sent (null when it had none: the project's settings applied). `flaky: true` marks a change whose content flipped back and forth over the branch's recent builds: often something that differs between runs (the time, an animation, a late font) rather than a real change, so check it before approving, and make the test deterministic. On a pull request's build, `on_main_unreviewed: true` marks a change that's the default branch's own unreviewed change (its newest build, still waiting for review, has it too), and `inherited` counts them: review those on main's build. `matches` marks a change made only of changes a merged pull request approved (two PRs that changed the same screen and merged separately): approve those with `review` and `only: \"matching\"`.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "description": "The build number (as in the build's URL) or its id.", + "type": [ + "integer", + "string" + ] + }, + "include_unchanged": { + "default": false, + "description": "Also list unchanged snapshots (by default they're only counted).", + "type": "boolean" + }, + "limit": { + "description": "List at most this many snapshots, 1 to 200. Default 30. Longer lists also come grouped by state and name\nprefix, so a build with hundreds of new snapshots reads in one answer.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "offset": { + "description": "Skip this many listed snapshots (for the next page). Default 0.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "order": { + "description": "`change` (the default): changed snapshots with the largest change first, then added, removed, failed and the\nrest. `name`: by name. The order snapshots are listed in for review. `change`: Changed snapshots, the largest change first; then added, removed, failed and the rest. The default; `name`: By name.", + "enum": [ + "change", + "name" + ], + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "get_build" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get organization" + }, + "description": "An organization: its members (role admin, member or read, and where each one's access came from: `github` when it follows their permission on the linked repositories, `invite`, `staff` or `created`), its projects (with each one's latest build), its plan, the credits used this month with what each thing costs (a snapshot check, a text diff, an image diff, a PDF page drawn) and its last 50 builds' usage. Choosing a plan and paying are left to a person in the web app.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "org": { + "description": "The organization's slug.", + "type": "string" + } + }, + "required": [ + "org" + ], + "type": "object" + }, + "name": "get_organization" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get PR changeset" + }, + "description": "Everything a pull request (or branch) changes, across all of its builds, against the baseline it forked from: each suite's added, changed and removed snapshots, with where review stands for each (approved, here or in an earlier build of the PR; pending; rejected; failed). A per-build diff can hide a change approved in an earlier build; this doesn't. Use it as the final self-check before asking for a merge: nothing should be pending or unexpected.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "description": "A branch, instead of a pull request number.", + "type": [ + "string", + "null" + ] + }, + "pr": { + "description": "The pull request's number.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_pr_changeset" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get project" + }, + "description": "A project's settings (renderer, dpi, threshold, CI mode, default branch, linked repository) and its tokens (names and prefixes; a token itself is shown only when it's created).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_project" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get a skill" + }, + "description": "VisualCI's agent skills: setting VisualCI up in each CI provider and test tool, reviewing builds, local runs and visualci.yml. Without `name`, lists them; with it, returns that skill's SKILL.md.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "default": null, + "description": "A skill's name, such as `visualci-circleci`. Leave it out to list the skills.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_skill" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get snapshot" + }, + "description": "Look at one snapshot's comparison. Documents and images: for every page its operation (unchanged, changed, inserted, removed), the diff's changed pixels and regions, and the text diff; lines that moved to another page; and the base, head and diff images of changed pages (the first three, or the pages you name). Each page's `embed_url` has week-long links to its images, for a pull request comment or a report. Text, JSON and HTML snapshots: the format, the changes by JSON path (`items[3].price: 10 → 12`) and a unified diff of the normalized text (sorted JSON keys, one HTML node per line, ignore rules applied); `images: head`, `base` or `all` adds that whole version. An unchanged snapshot's images come too (its first pages), so any build's version can be looked at. Also the snapshot's open comment threads, each with the build it was drawn on. `against: \"previous\"` compares with the branch's previous build instead of the baseline, to check a fix against a comment left there.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "against": { + "description": "What the new side is compared with: `baseline` (the default, what review uses), `previous` (the newest earlier\nbuild of this snapshot on the branch: did a fix answer a comment there?), or an earlier build's number on the\nbranch. Only `baseline` decides the review; the others are a view.", + "type": [ + "string", + "null" + ] + }, + "build": { + "description": "The build number or id.", + "type": [ + "integer", + "string" + ] + }, + "crop": { + "description": "`changed` crops each image to the changed regions with a margin, for a close look at a small change on a tall\npage.", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "The snapshot's id, as `get_build` lists it: instead of `name` and `platform`.", + "type": [ + "string", + "null" + ] + }, + "images": { + "description": "Which images to include: `all` (base, head, diff; the default), `diff`, `head`, `base`, or `none`.\nFor text, JSON and HTML: `head`, `base` or `all` adds that whole version's text.", + "type": [ + "string", + "null" + ] + }, + "max_width": { + "description": "Scale images down to this width in pixels (default 1200). Large ones come back as JPEG.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "name": { + "default": "", + "description": "The snapshot's name, as `get_build` lists it, or its `id` from `get_build`.", + "type": "string" + }, + "pages": { + "description": "Positions of the pages to include images for (from a previous answer). Default: the first three changed pages.", + "items": { + "format": "int32", + "type": "integer" + }, + "type": [ + "array", + "null" + ] + }, + "platform": { + "default": "", + "description": "The snapshot's platform. Optional when the name is on one platform only.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "get_snapshot" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Invite member" + }, + "description": "Invite someone to an organization by email address or GitHub login (admins, with a personal access token). They're emailed, and join with `role` (admin, member or read) once they accept it in the web app, whether or not they already have an account. People with access to a linked repository on GitHub don't need an invitation: their access follows their permission there.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "invitee": { + "description": "An email address, or a GitHub login (`octocat` or `@octocat`).", + "type": "string" + }, + "org": { + "description": "The organization's slug.", + "type": "string" + }, + "role": { + "description": "`admin` (settings, projects, tokens, billing, members), `member` (send builds, review and approve) or `read`. A member's role, lowest first. `read`: Sees builds and snapshots; changes nothing; `member`: Everything a build needs: uploads, review and approval; `admin`: Also settings, projects, tokens, billing and members.", + "enum": [ + "read", + "member", + "admin" + ], + "type": "string" + } + }, + "required": [ + "org", + "invitee", + "role" + ], + "type": "object" + }, + "name": "invite_member" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "List builds" + }, + "description": "List a project's builds, newest first: number, name, branch, commit, PR, state, conclusion (unchanged, changes or failed), review state, counts and URL. waiting_for_review: only builds whose changes wait for a review.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "description": "Only builds of this branch.", + "type": [ + "string", + "null" + ] + }, + "limit": { + "description": "How many, newest first (default 20, at most 100).", + "format": "uint64", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "waiting_for_review": { + "description": "Only builds whose changes wait for a review (a local build only for the person whose run it was).", + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, + "name": "list_builds" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "List comments" + }, + "description": "Comment threads on a build's branch: each with the build it was drawn on (`started_in_build`; its pin is on that build's image, and an open one still blocks approving the snapshot in newer builds), its snapshot, page, side (base or head), anchor (point, box or the whole image, in that image's pixels), whether it's resolved, and its comments with their authors (a person, or an agent and its name). Open threads only unless `include_resolved`. An open thread blocks approving its snapshot.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "description": "A build: its branch's threads are listed (threads follow the branch).", + "type": [ + "integer", + "string" + ] + }, + "include_resolved": { + "default": false, + "description": "Also resolved threads. Default: open ones only.", + "type": "boolean" + }, + "platform": { + "default": "", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "snapshot": { + "description": "Only this snapshot's threads (its name, or its id from `get_build`).", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "list_comments" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "List organizations" + }, + "description": "The organizations this token can reach, with each one's projects, the caller's role, and its plan and credits used this month.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "type": "object" + }, + "name": "list_organizations" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Post comment" + }, + "description": "Comment on a snapshot: start a thread pinned to a point or a box (in that image's pixels, like get_snapshot's regions) or the whole image of a page's head (new) or base (old) side, or reply in a thread (`thread`). Markdown. Use it to ask about a change you can't judge, or to say why you rejected one; a person's open thread on a snapshot stops `review` from approving it until someone resolves the thread. Replying reopens a resolved thread.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "anchor": { + "description": "Where on the image: `{\"kind\": \"image\"}` (the default), `{\"kind\": \"point\", \"x\": 410, \"y\": 96}` or\n`{\"kind\": \"box\", \"x\": 120, \"y\": 80, \"w\": 300, \"h\": 140}`, in pixels of that side's image from its top left:\nthe same units as `regions` in `get_snapshot`, so a region can be pinned as it is. Where a thread is pinned, in pixels of the pinned side's own image (base or head), from its top left. Pixels, not\nfractions: when a full-page screenshot grows at the bottom in a later build of the branch, a pin stays on the same\ncontent. They're also the units of the regions `get_snapshot` gives. The whole image.", + "properties": { + "kind": { + "const": "image", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": [ + "object", + "null" + ] + }, + "body": { + "description": "Markdown.", + "type": "string" + }, + "build": { + "description": "The build being looked at.", + "type": [ + "integer", + "string" + ] + }, + "page": { + "description": "The page's position (from `get_snapshot`); leave out for the whole snapshot.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "platform": { + "default": "", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "side": { + "description": "`head` (the new image, the default) or `base`.", + "type": [ + "string", + "null" + ] + }, + "snapshot": { + "description": "To start a thread: the snapshot's name (or its id from `get_build`).", + "type": [ + "string", + "null" + ] + }, + "thread": { + "description": "To reply: the thread's id. Leave out to start a thread.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build", + "body" + ], + "type": "object" + }, + "name": "post_comment" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Resolve comment" + }, + "description": "Resolve a comment thread once its question is answered (or reopen it with `resolved: false`). Resolving the open threads on a snapshot lets `review` approve it.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "resolved": { + "description": "`false` reopens it. Default `true`.", + "type": [ + "boolean", + "null" + ] + }, + "thread": { + "description": "The thread's id.", + "type": "string" + } + }, + "required": [ + "thread" + ], + "type": "object" + }, + "name": "resolve_comment" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Review build" + }, + "description": "Approve or reject a build's changes, some snapshots' changes (`snapshots`), or only its new or only its changed snapshots (`only`). Approved snapshots become the baseline, and the pull request's VisualCI check updates. Approve only changes the person you work for asked for. A build that's still comparing (straight after a run) is waited for, up to a minute.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "action": { + "description": "`approve` or `reject`.", + "type": "string" + }, + "build": { + "type": [ + "integer", + "string" + ] + }, + "comment": { + "description": "With `reject`: why, as a comment thread on each rejected snapshot (Markdown), so the next person or agent sees\nwhat's wrong. Approving a snapshot with an open thread is refused until the thread is resolved.", + "type": [ + "string", + "null" + ] + }, + "note": { + "description": "Why you approved or rejected, in a sentence. It's shown wherever the review appears (the build's\nreviews, the pull request comment). A note, not a thread: it never blocks anything.", + "type": [ + "string", + "null" + ] + }, + "only": { + "description": "Only the build's `added` (new) snapshots, only its `changed` ones, or only its `matching` ones (changes made\nonly of changes merged pull requests approved: `get_build`'s `matches`), in one call. Not with `snapshots`.", + "type": [ + "string", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "snapshots": { + "description": "Snapshot names to review; all changed snapshots when left out.", + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + } + }, + "required": [ + "build", + "action" + ], + "type": "object" + }, + "name": "review" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Review page" + }, + "description": "Review one changed page: `variant` keeps the new page as another accepted baseline next to the old one (both are fine, e.g. a page that legitimately renders two ways); `ignore` ignores this exact change, in this build and later ones.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "action": { + "description": "`variant` (both the old and the new page are fine: keep both as baselines) or `ignore` (ignore this exact\nchange in later builds too).", + "type": "string" + }, + "build": { + "type": [ + "integer", + "string" + ] + }, + "name": { + "type": "string" + }, + "platform": { + "default": "", + "type": "string" + }, + "position": { + "description": "The page's position, from `get_snapshot`.", + "format": "int32", + "type": "integer" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build", + "name", + "position", + "action" + ], + "type": "object" + }, + "name": "review_page" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Snapshot history" + }, + "description": "One snapshot across recent builds, newest first: in each build its state (unchanged, changed, added, removed, failed) and review. Use it to find when a page started changing.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "description": "Only builds of this branch.", + "type": [ + "string", + "null" + ] + }, + "limit": { + "description": "How many builds to look back (default 20, at most 200).", + "format": "uint64", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "name": { + "type": "string" + }, + "platform": { + "default": "", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "name": "snapshot_history" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Send to the VisualCI team" + }, + "description": "Send something to the VisualCI team. Only about VisualCI itself. Never include secrets, credentials or the user's data. feedback: something got in your way and the work still got done (title, kind, description). Nobody replies. Send it without asking, once per problem, then tell the user what you sent. If a call fails, carry on and don't retry.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "action": { + "enum": [ + "feedback" + ], + "type": "string" + }, + "agent": { + "additionalProperties": true, + "description": "The agent sending it, as an object such as `{name, version, model}`.", + "type": [ + "object", + "null" + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "idempotency_key": { + "type": [ + "string", + "null" + ] + }, + "impact": { + "enum": [ + "blocked", + "worked_around", + "friction", + null + ], + "type": [ + "string", + "null" + ] + }, + "kind": { + "enum": [ + "bug", + "crash", + "wrong_result", + "confusing", + "missing_feature", + "docs", + "question", + "other", + null + ], + "type": [ + "string", + "null" + ] + }, + "request_ids": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "session": { + "type": [ + "string", + "null" + ] + }, + "source": { + "enum": [ + "user", + "agent", + null + ], + "type": [ + "string", + "null" + ] + }, + "suggestion": { + "type": [ + "string", + "null" + ] + }, + "task": { + "type": [ + "string", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "tool": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "action" + ], + "type": "object" + }, + "name": "support_send" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Update comment" + }, + "description": "Edit one of your own comments (`body`, Markdown).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "body": { + "description": "The new text (Markdown), for `update_comment`.", + "type": [ + "string", + "null" + ] + }, + "comment": { + "description": "The comment's id.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "comment" + ], + "type": "object" + }, + "name": "update_comment" + }, + { + "annotations": { + "destructiveHint": true, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Update project" + }, + "description": "Change a project's settings. Fields left out stay as they are. These are defaults: a build's visualci.yml overrides them field by field. `ignore_rules` replaces the project's rules for values in text snapshots that change on every run, as a list of `{snapshots, json_paths, text_patterns}`: `snapshots` is a required glob over snapshot names (`api/invoices/**`, `**` for all), `json_paths` like `$.generated_at`, `$.items[*].id`, `$..request_id`, and `text_patterns` regular expressions.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "ci_mode": { + "description": "`review` (CI passes, the check waits for review), `strict` (CI fails on unreviewed changes) or `wait`.", + "type": [ + "string", + "null" + ] + }, + "default_branch": { + "description": "The branch whose builds become the baseline automatically.", + "type": [ + "string", + "null" + ] + }, + "dismiss_notice": { + "description": "`true` dismisses the project's notice.", + "type": [ + "boolean", + "null" + ] + }, + "dpi": { + "description": "Render resolution for documents, 36 to 600.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "forge_token": { + "description": "A project on your organization's own GitLab instance: an access token for it (a project or group access token\nwith the `api` scope and the Developer role, or Maintainer to let VisualCI add its webhook), sent with\n`repository_url`. Stored encrypted; never shown again.", + "type": [ + "string", + "null" + ] + }, + "gallery_enabled": { + "description": "`false` takes the public gallery down (visualci.yml's `gallery` decides what's in it); `true` puts it back.", + "type": [ + "boolean", + "null" + ] + }, + "ignore_anti_aliasing": { + "description": "Ignore anti-aliasing differences in images.", + "type": [ + "boolean", + "null" + ] + }, + "ignore_rules": { + "description": "Values in text snapshots that change on every run, ignored when comparing. Replaces the project's rules. Each\nrule names the snapshots it applies to with a glob (`api/invoices/**`; `**` for every snapshot). A build's\n`visualci.yml` replaces these rules when it has `ignore`.", + "items": { + "additionalProperties": false, + "description": "An ignore rule for the snapshots whose names match a glob.", + "properties": { + "json_paths": { + "description": "JSON paths whose values are ignored: `$.generated_at`, `$.items[*].id`, `$..request_id`.", + "items": { + "type": "string" + }, + "type": "array" + }, + "snapshots": { + "description": "The snapshots this rule applies to, as a glob over snapshot names: `api/invoices/**`, `emails/*.html`.", + "type": "string" + }, + "text_patterns": { + "description": "Regular expressions; matching text is ignored in every text format.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "snapshots" + ], + "type": "object" + }, + "type": [ + "array", + "null" + ] + }, + "move_link": { + "default": false, + "description": "With `repository_url`: a repository belongs to one organization, so when another organization has it linked,\n`true` moves the link here (you must maintain the repository; that organization's admins get an email).", + "type": "boolean" + }, + "name": { + "description": "The project's display name.", + "type": [ + "string", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "public": { + "description": "`true` lets anyone, signed in or not, read the project's builds and diffs (for open source projects);\nsettings, tokens and reviewing stay with its members. Only a project linked to a public repository can be\npublic. `false` makes it private again.", + "type": [ + "boolean", + "null" + ] + }, + "renderer": { + "description": "The PDF renderer: `pdfbox` or `mutool`.", + "type": [ + "string", + "null" + ] + }, + "repository_url": { + "description": "The repository this project tests, by URL (`https://github.com/acme/web`); an empty string unlinks it.\nLinking needs the forge's VisualCI app installed on the repository and you to be an admin or maintainer of\nit there. Its pull requests then get VisualCI's check, and people's access to this organization follows their\npermission on it.", + "type": [ + "string", + "null" + ] + }, + "slug": { + "description": "A new slug, renaming the project (`acme/old` → `acme/new`): lowercase letters, digits and dashes. Its builds,\nbaselines and tokens stay. The old address and `acme/old` stop working.", + "type": [ + "string", + "null" + ] + }, + "threshold": { + "description": "The diff threshold, 0 to 1: 0 compares exactly; above 0 it's pixelmatch's colour threshold (how different a\npixel's colour must be to count), and anti-aliased pixels are ignored.", + "format": "double", + "type": [ + "number", + "null" + ] + }, + "tokens_can_approve": { + "description": "`false`: project tokens can't approve changes (people do); `true` lets CI's agents approve again.", + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, + "name": "update_project" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Upload snapshots" + }, + "description": "Add files to a build that's still receiving: PDFs, PNG/JPEG/WebP images, or text snapshots (plain text, JSON, HTML, serialized component trees; `format` or the file name's extension decides), base64. Files VisualCI has seen before aren't stored again. Up to 64 MB per call; call it as often as needed.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "type": [ + "integer", + "string" + ] + }, + "files": { + "items": { + "properties": { + "content_base64": { + "description": "The file's bytes, base64. PDFs, PNG, JPEG or WebP images, or text (plain text, JSON, HTML, a serialized\ncomponent tree).", + "type": "string" + }, + "engine": { + "description": "Documents: `pdfbox` or `mutool`, overriding the project's renderer.", + "type": [ + "string", + "null" + ] + }, + "filename": { + "description": "The file's name or extension (e.g. `invoice.pdf`, `.png`, `response.json`), to tell images from text and JSON\nor HTML from plain text.", + "type": [ + "string", + "null" + ] + }, + "format": { + "description": "Text: `text`, `json` or `html`, overriding the file name. JSON is compared with keys sorted, HTML with\nattributes sorted and whitespace collapsed.", + "type": [ + "string", + "null" + ] + }, + "ignore": { + "additionalProperties": false, + "description": "Text: values to ignore in this snapshot only, `{json_paths, text_patterns}`, on top of the visualci.yml's or\nproject's rules. Rules for values that change on every run.", + "properties": { + "json_paths": { + "default": [], + "description": "JSON paths whose values are ignored: `$.generated_at`, `$.items[*].id`, `$..request_id`, `$[\"odd key\"]`.", + "items": { + "type": "string" + }, + "type": "array" + }, + "text_patterns": { + "default": [], + "description": "Regular expressions; matching text is ignored in every text format (after normalization).", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": [ + "object", + "null" + ] + }, + "meta": { + "description": "Anything to keep with the snapshot (test file, URL, viewport).", + "type": "object" + }, + "name": { + "description": "The snapshot's name, unique in the build (e.g. the test's name).", + "type": "string" + }, + "platform": { + "default": "", + "description": "For screenshots: the browser or device, so each platform keeps its own baseline.", + "type": "string" + }, + "threshold": { + "description": "The diff threshold (0 to 1), overriding the project's: 0 is exact, above 0 a perceptual colour threshold.", + "format": "double", + "type": [ + "number", + "null" + ] + } + }, + "required": [ + "name", + "content_base64" + ], + "type": "object" + }, + "type": "array" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build", + "files" + ], + "type": "object" + }, + "name": "upload_snapshots" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Who am I" + }, + "description": "Who this token belongs to (a person or a project), the organizations and projects it can reach with each organization's setup checklist (`setup`: steps done and the next one), and the newest builds whose changes wait for a review (`waiting_for_review`, at most 10). With no builds yet, `demo` names the public demo project to look at first.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "type": "object" + }, + "name": "whoami" + } + ] +} diff --git a/app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-user-token.json b/app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-user-token.json new file mode 100644 index 00000000..ac56be47 --- /dev/null +++ b/app/tests/golden/mcp/lists_the_tools_each_kind_of_token_can_use/tools-list-user-token.json @@ -0,0 +1,1579 @@ +{ + "tools": [ + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Contact sheet" + }, + "description": "Many snapshots of a build at a glance: one image with a grid of thumbnails (each snapshot's first page, the new version, or the old one for a removed snapshot), and the list of what's in it in the same order, left to right and top to bottom, with each one's name, state and link. For checking a build with many added or changed snapshots in a few calls; page through with offset. Text snapshots have no thumbnail: look at them with get_snapshot.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "description": "The build number or id.", + "type": [ + "integer", + "string" + ] + }, + "columns": { + "description": "Thumbnails per row, 1 to 8. Default 4.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "limit": { + "description": "How many per sheet, at most 48. Default 24.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "offset": { + "description": "Skip this many (for the next sheet). Default 0.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "order": { + "description": "`change` (the default): the largest change first, then added and removed. `name`: by name. The order snapshots are listed in for review. `change`: Changed snapshots, the largest change first; then added, removed, failed and the rest. The default; `name`: By name.", + "enum": [ + "change", + "name" + ], + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "states": { + "description": "Which snapshots, by state: comma-separated, from `changed`, `added`, `removed`, `unchanged`, `ignored`\n(default `changed,added`).", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "contact_sheet" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create build" + }, + "description": "Start a build, as CI does: then `upload_snapshots` and `finalize_build`. VisualCI compares it with the baseline from the branch's ancestors (or the default branch).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "type": "string" + }, + "commit": { + "description": "The commit SHA the files come from.", + "type": "string" + }, + "config": { + "description": "The repository's visualci.yml as JSON (the CLI sends it). Its fields override the project's settings for this\nbuild; ignore rules must each name their snapshots.", + "type": "object" + }, + "environment": { + "description": "Where the build runs: `ci` (the default), `local-mac`, `local-linux`. Screenshots keep a baseline set per\nenvironment; documents and text share one.", + "type": [ + "string", + "null" + ] + }, + "mode": { + "description": "`ci` (the default) or `local` (a check from a laptop that never becomes a baseline).", + "type": [ + "string", + "null" + ] + }, + "name": { + "description": "Builds with different names (e.g. `pdfs`, `browser`) keep separate baselines. Default `default`.", + "type": [ + "string", + "null" + ] + }, + "nonce": { + "description": "Calls with the same nonce get the same build back (for parallel shards).", + "type": [ + "string", + "null" + ] + }, + "parent_commits": { + "default": [], + "description": "Ancestor commits, nearest first, for finding the baseline.", + "items": { + "type": "string" + }, + "type": "array" + }, + "pr_number": { + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "shard_total": { + "description": "How many shards will finalize the build (default 1).", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "subset": { + "default": false, + "description": "The build has only some of the project's snapshots; missing ones are carried forward, not removed.", + "type": "boolean" + } + }, + "required": [ + "commit", + "branch" + ], + "type": "object" + }, + "name": "create_build" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create organization" + }, + "description": "Create an organization with you as its admin (personal access tokens only), on the Free plan.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "slug": { + "description": "Lowercase letters, digits and dashes; used in URLs.", + "type": "string" + } + }, + "required": [ + "slug", + "name" + ], + "type": "object" + }, + "name": "create_organization" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create project" + }, + "description": "Create a project in an organization (owners and admins). Then `create_project_token` for CI, and `update_project` to link its GitHub repository.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "type": "string" + }, + "org": { + "type": "string" + }, + "slug": { + "description": "Lowercase letters, digits and dashes; used in URLs.", + "type": "string" + } + }, + "required": [ + "org", + "slug", + "name" + ], + "type": "object" + }, + "name": "create_project" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Create project token" + }, + "description": "Create a project token (`vci_...`) for CI or the CLI. The token is in this answer only: store it where it's needed (e.g. as VISUALCI_TOKEN).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "description": "What the token is for, e.g. `CircleCI`.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "name": "create_project_token" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Delete comment" + }, + "description": "Delete a comment (your own; an organization admin can delete anyone's). A thread left with no comments goes too.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "body": { + "description": "The new text (Markdown), for `update_comment`.", + "type": [ + "string", + "null" + ] + }, + "comment": { + "description": "The comment's id.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "comment" + ], + "type": "object" + }, + "name": "delete_comment" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Delete project token" + }, + "description": "Delete a project token. Anything still using it (a CI variable) stops working.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "token_id": { + "description": "The token's id, from `get_project`.", + "format": "int64", + "type": "integer" + } + }, + "required": [ + "token_id" + ], + "type": "object" + }, + "name": "delete_project_token" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Finalize build" + }, + "description": "Finish a build (or one shard of it): VisualCI renders and compares what was uploaded. Then poll `get_build` until its state is completed. A build that was sent no snapshots fails, unless allow_empty is true or empty_reason says why it has none (\"inputs unchanged\").", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "allow_empty": { + "description": "True when the build may have no snapshots on purpose. Otherwise a build that was sent none fails.", + "type": [ + "boolean", + "null" + ] + }, + "build": { + "type": [ + "integer", + "string" + ] + }, + "empty_reason": { + "description": "Why it has none, like \"inputs unchanged\" (the CI run skipped the tests): implies allow_empty, and shows in the\nbuild's summary with the build its baseline came from.", + "type": [ + "string", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "shard": { + "description": "The shard that finished, when the build has several.", + "format": "int32", + "type": [ + "integer", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "finalize_build" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get build" + }, + "description": "A build's status and its snapshots that need attention, 30 at a time (offset and limit page through; longer lists also come grouped by state and name prefix) (changed, added, removed, failed), with how many pages changed in each, the largest change first (order: name to sort by name), and approved_elsewhere when the same new version was already approved on another branch (a hint: it approves nothing). Unchanged snapshots are only counted unless include_unchanged is set. `config` is the visualci.yml the build was sent (null when it had none: the project's settings applied). `flaky: true` marks a change whose content flipped back and forth over the branch's recent builds: often something that differs between runs (the time, an animation, a late font) rather than a real change, so check it before approving, and make the test deterministic. On a pull request's build, `on_main_unreviewed: true` marks a change that's the default branch's own unreviewed change (its newest build, still waiting for review, has it too), and `inherited` counts them: review those on main's build. `matches` marks a change made only of changes a merged pull request approved (two PRs that changed the same screen and merged separately): approve those with `review` and `only: \"matching\"`.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "description": "The build number (as in the build's URL) or its id.", + "type": [ + "integer", + "string" + ] + }, + "include_unchanged": { + "default": false, + "description": "Also list unchanged snapshots (by default they're only counted).", + "type": "boolean" + }, + "limit": { + "description": "List at most this many snapshots, 1 to 200. Default 30. Longer lists also come grouped by state and name\nprefix, so a build with hundreds of new snapshots reads in one answer.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "offset": { + "description": "Skip this many listed snapshots (for the next page). Default 0.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "order": { + "description": "`change` (the default): changed snapshots with the largest change first, then added, removed, failed and the\nrest. `name`: by name. The order snapshots are listed in for review. `change`: Changed snapshots, the largest change first; then added, removed, failed and the rest. The default; `name`: By name.", + "enum": [ + "change", + "name" + ], + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "get_build" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get organization" + }, + "description": "An organization: its members (role admin, member or read, and where each one's access came from: `github` when it follows their permission on the linked repositories, `invite`, `staff` or `created`), its projects (with each one's latest build), its plan, the credits used this month with what each thing costs (a snapshot check, a text diff, an image diff, a PDF page drawn) and its last 50 builds' usage. Choosing a plan and paying are left to a person in the web app.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "org": { + "description": "The organization's slug.", + "type": "string" + } + }, + "required": [ + "org" + ], + "type": "object" + }, + "name": "get_organization" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get PR changeset" + }, + "description": "Everything a pull request (or branch) changes, across all of its builds, against the baseline it forked from: each suite's added, changed and removed snapshots, with where review stands for each (approved, here or in an earlier build of the PR; pending; rejected; failed). A per-build diff can hide a change approved in an earlier build; this doesn't. Use it as the final self-check before asking for a merge: nothing should be pending or unexpected.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "description": "A branch, instead of a pull request number.", + "type": [ + "string", + "null" + ] + }, + "pr": { + "description": "The pull request's number.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_pr_changeset" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get project" + }, + "description": "A project's settings (renderer, dpi, threshold, CI mode, default branch, linked repository) and its tokens (names and prefixes; a token itself is shown only when it's created).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_project" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get a skill" + }, + "description": "VisualCI's agent skills: setting VisualCI up in each CI provider and test tool, reviewing builds, local runs and visualci.yml. Without `name`, lists them; with it, returns that skill's SKILL.md.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "name": { + "default": null, + "description": "A skill's name, such as `visualci-circleci`. Leave it out to list the skills.", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" + }, + "name": "get_skill" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Get snapshot" + }, + "description": "Look at one snapshot's comparison. Documents and images: for every page its operation (unchanged, changed, inserted, removed), the diff's changed pixels and regions, and the text diff; lines that moved to another page; and the base, head and diff images of changed pages (the first three, or the pages you name). Each page's `embed_url` has week-long links to its images, for a pull request comment or a report. Text, JSON and HTML snapshots: the format, the changes by JSON path (`items[3].price: 10 → 12`) and a unified diff of the normalized text (sorted JSON keys, one HTML node per line, ignore rules applied); `images: head`, `base` or `all` adds that whole version. An unchanged snapshot's images come too (its first pages), so any build's version can be looked at. Also the snapshot's open comment threads, each with the build it was drawn on. `against: \"previous\"` compares with the branch's previous build instead of the baseline, to check a fix against a comment left there.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "against": { + "description": "What the new side is compared with: `baseline` (the default, what review uses), `previous` (the newest earlier\nbuild of this snapshot on the branch: did a fix answer a comment there?), or an earlier build's number on the\nbranch. Only `baseline` decides the review; the others are a view.", + "type": [ + "string", + "null" + ] + }, + "build": { + "description": "The build number or id.", + "type": [ + "integer", + "string" + ] + }, + "crop": { + "description": "`changed` crops each image to the changed regions with a margin, for a close look at a small change on a tall\npage.", + "type": [ + "string", + "null" + ] + }, + "id": { + "description": "The snapshot's id, as `get_build` lists it: instead of `name` and `platform`.", + "type": [ + "string", + "null" + ] + }, + "images": { + "description": "Which images to include: `all` (base, head, diff; the default), `diff`, `head`, `base`, or `none`.\nFor text, JSON and HTML: `head`, `base` or `all` adds that whole version's text.", + "type": [ + "string", + "null" + ] + }, + "max_width": { + "description": "Scale images down to this width in pixels (default 1200). Large ones come back as JPEG.", + "format": "uint32", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "name": { + "default": "", + "description": "The snapshot's name, as `get_build` lists it, or its `id` from `get_build`.", + "type": "string" + }, + "pages": { + "description": "Positions of the pages to include images for (from a previous answer). Default: the first three changed pages.", + "items": { + "format": "int32", + "type": "integer" + }, + "type": [ + "array", + "null" + ] + }, + "platform": { + "default": "", + "description": "The snapshot's platform. Optional when the name is on one platform only.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "get_snapshot" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Invite member" + }, + "description": "Invite someone to an organization by email address or GitHub login (admins, with a personal access token). They're emailed, and join with `role` (admin, member or read) once they accept it in the web app, whether or not they already have an account. People with access to a linked repository on GitHub don't need an invitation: their access follows their permission there.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "invitee": { + "description": "An email address, or a GitHub login (`octocat` or `@octocat`).", + "type": "string" + }, + "org": { + "description": "The organization's slug.", + "type": "string" + }, + "role": { + "description": "`admin` (settings, projects, tokens, billing, members), `member` (send builds, review and approve) or `read`. A member's role, lowest first. `read`: Sees builds and snapshots; changes nothing; `member`: Everything a build needs: uploads, review and approval; `admin`: Also settings, projects, tokens, billing and members.", + "enum": [ + "read", + "member", + "admin" + ], + "type": "string" + } + }, + "required": [ + "org", + "invitee", + "role" + ], + "type": "object" + }, + "name": "invite_member" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "List builds" + }, + "description": "List a project's builds, newest first: number, name, branch, commit, PR, state, conclusion (unchanged, changes or failed), review state, counts and URL. waiting_for_review: only builds whose changes wait for a review.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "description": "Only builds of this branch.", + "type": [ + "string", + "null" + ] + }, + "limit": { + "description": "How many, newest first (default 20, at most 100).", + "format": "uint64", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "waiting_for_review": { + "description": "Only builds whose changes wait for a review (a local build only for the person whose run it was).", + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, + "name": "list_builds" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "List comments" + }, + "description": "Comment threads on a build's branch: each with the build it was drawn on (`started_in_build`; its pin is on that build's image, and an open one still blocks approving the snapshot in newer builds), its snapshot, page, side (base or head), anchor (point, box or the whole image, in that image's pixels), whether it's resolved, and its comments with their authors (a person, or an agent and its name). Open threads only unless `include_resolved`. An open thread blocks approving its snapshot.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "description": "A build: its branch's threads are listed (threads follow the branch).", + "type": [ + "integer", + "string" + ] + }, + "include_resolved": { + "default": false, + "description": "Also resolved threads. Default: open ones only.", + "type": "boolean" + }, + "platform": { + "default": "", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "snapshot": { + "description": "Only this snapshot's threads (its name, or its id from `get_build`).", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build" + ], + "type": "object" + }, + "name": "list_comments" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "List organizations" + }, + "description": "The organizations this token can reach, with each one's projects, the caller's role, and its plan and credits used this month.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "type": "object" + }, + "name": "list_organizations" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Post comment" + }, + "description": "Comment on a snapshot: start a thread pinned to a point or a box (in that image's pixels, like get_snapshot's regions) or the whole image of a page's head (new) or base (old) side, or reply in a thread (`thread`). Markdown. Use it to ask about a change you can't judge, or to say why you rejected one; a person's open thread on a snapshot stops `review` from approving it until someone resolves the thread. Replying reopens a resolved thread.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "anchor": { + "description": "Where on the image: `{\"kind\": \"image\"}` (the default), `{\"kind\": \"point\", \"x\": 410, \"y\": 96}` or\n`{\"kind\": \"box\", \"x\": 120, \"y\": 80, \"w\": 300, \"h\": 140}`, in pixels of that side's image from its top left:\nthe same units as `regions` in `get_snapshot`, so a region can be pinned as it is. Where a thread is pinned, in pixels of the pinned side's own image (base or head), from its top left. Pixels, not\nfractions: when a full-page screenshot grows at the bottom in a later build of the branch, a pin stays on the same\ncontent. They're also the units of the regions `get_snapshot` gives. The whole image.", + "properties": { + "kind": { + "const": "image", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": [ + "object", + "null" + ] + }, + "body": { + "description": "Markdown.", + "type": "string" + }, + "build": { + "description": "The build being looked at.", + "type": [ + "integer", + "string" + ] + }, + "page": { + "description": "The page's position (from `get_snapshot`); leave out for the whole snapshot.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "platform": { + "default": "", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "side": { + "description": "`head` (the new image, the default) or `base`.", + "type": [ + "string", + "null" + ] + }, + "snapshot": { + "description": "To start a thread: the snapshot's name (or its id from `get_build`).", + "type": [ + "string", + "null" + ] + }, + "thread": { + "description": "To reply: the thread's id. Leave out to start a thread.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build", + "body" + ], + "type": "object" + }, + "name": "post_comment" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Resolve comment" + }, + "description": "Resolve a comment thread once its question is answered (or reopen it with `resolved: false`). Resolving the open threads on a snapshot lets `review` approve it.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "resolved": { + "description": "`false` reopens it. Default `true`.", + "type": [ + "boolean", + "null" + ] + }, + "thread": { + "description": "The thread's id.", + "type": "string" + } + }, + "required": [ + "thread" + ], + "type": "object" + }, + "name": "resolve_comment" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Review build" + }, + "description": "Approve or reject a build's changes, some snapshots' changes (`snapshots`), or only its new or only its changed snapshots (`only`). Approved snapshots become the baseline, and the pull request's VisualCI check updates. Approve only changes the person you work for asked for. A build that's still comparing (straight after a run) is waited for, up to a minute.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "action": { + "description": "`approve` or `reject`.", + "type": "string" + }, + "build": { + "type": [ + "integer", + "string" + ] + }, + "comment": { + "description": "With `reject`: why, as a comment thread on each rejected snapshot (Markdown), so the next person or agent sees\nwhat's wrong. Approving a snapshot with an open thread is refused until the thread is resolved.", + "type": [ + "string", + "null" + ] + }, + "note": { + "description": "Why you approved or rejected, in a sentence. It's shown wherever the review appears (the build's\nreviews, the pull request comment). A note, not a thread: it never blocks anything.", + "type": [ + "string", + "null" + ] + }, + "only": { + "description": "Only the build's `added` (new) snapshots, only its `changed` ones, or only its `matching` ones (changes made\nonly of changes merged pull requests approved: `get_build`'s `matches`), in one call. Not with `snapshots`.", + "type": [ + "string", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "snapshots": { + "description": "Snapshot names to review; all changed snapshots when left out.", + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + } + }, + "required": [ + "build", + "action" + ], + "type": "object" + }, + "name": "review" + }, + { + "annotations": { + "destructiveHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Review page" + }, + "description": "Review one changed page: `variant` keeps the new page as another accepted baseline next to the old one (both are fine, e.g. a page that legitimately renders two ways); `ignore` ignores this exact change, in this build and later ones.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "action": { + "description": "`variant` (both the old and the new page are fine: keep both as baselines) or `ignore` (ignore this exact\nchange in later builds too).", + "type": "string" + }, + "build": { + "type": [ + "integer", + "string" + ] + }, + "name": { + "type": "string" + }, + "platform": { + "default": "", + "type": "string" + }, + "position": { + "description": "The page's position, from `get_snapshot`.", + "format": "int32", + "type": "integer" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build", + "name", + "position", + "action" + ], + "type": "object" + }, + "name": "review_page" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Snapshot history" + }, + "description": "One snapshot across recent builds, newest first: in each build its state (unchanged, changed, added, removed, failed) and review. Use it to find when a page started changing.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "branch": { + "description": "Only builds of this branch.", + "type": [ + "string", + "null" + ] + }, + "limit": { + "description": "How many builds to look back (default 20, at most 200).", + "format": "uint64", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "name": { + "type": "string" + }, + "platform": { + "default": "", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "name": "snapshot_history" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Send to the VisualCI team" + }, + "description": "Send something to the VisualCI team. Only about VisualCI itself. Never include secrets, credentials or the user's data. feedback: something got in your way and the work still got done (title, kind, description). Nobody replies. Send it without asking, once per problem, then tell the user what you sent. If a call fails, carry on and don't retry.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "action": { + "enum": [ + "feedback" + ], + "type": "string" + }, + "agent": { + "additionalProperties": true, + "description": "The agent sending it, as an object such as `{name, version, model}`.", + "type": [ + "object", + "null" + ] + }, + "description": { + "type": [ + "string", + "null" + ] + }, + "error": { + "type": [ + "string", + "null" + ] + }, + "idempotency_key": { + "type": [ + "string", + "null" + ] + }, + "impact": { + "enum": [ + "blocked", + "worked_around", + "friction", + null + ], + "type": [ + "string", + "null" + ] + }, + "kind": { + "enum": [ + "bug", + "crash", + "wrong_result", + "confusing", + "missing_feature", + "docs", + "question", + "other", + null + ], + "type": [ + "string", + "null" + ] + }, + "request_ids": { + "items": { + "type": "string" + }, + "type": [ + "array", + "null" + ] + }, + "session": { + "type": [ + "string", + "null" + ] + }, + "source": { + "enum": [ + "user", + "agent", + null + ], + "type": [ + "string", + "null" + ] + }, + "suggestion": { + "type": [ + "string", + "null" + ] + }, + "task": { + "type": [ + "string", + "null" + ] + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "tool": { + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "action" + ], + "type": "object" + }, + "name": "support_send" + }, + { + "annotations": { + "destructiveHint": false, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Update comment" + }, + "description": "Edit one of your own comments (`body`, Markdown).", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "body": { + "description": "The new text (Markdown), for `update_comment`.", + "type": [ + "string", + "null" + ] + }, + "comment": { + "description": "The comment's id.", + "type": "string" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "comment" + ], + "type": "object" + }, + "name": "update_comment" + }, + { + "annotations": { + "destructiveHint": true, + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Update project" + }, + "description": "Change a project's settings. Fields left out stay as they are. These are defaults: a build's visualci.yml overrides them field by field. `ignore_rules` replaces the project's rules for values in text snapshots that change on every run, as a list of `{snapshots, json_paths, text_patterns}`: `snapshots` is a required glob over snapshot names (`api/invoices/**`, `**` for all), `json_paths` like `$.generated_at`, `$.items[*].id`, `$..request_id`, and `text_patterns` regular expressions.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "ci_mode": { + "description": "`review` (CI passes, the check waits for review), `strict` (CI fails on unreviewed changes) or `wait`.", + "type": [ + "string", + "null" + ] + }, + "default_branch": { + "description": "The branch whose builds become the baseline automatically.", + "type": [ + "string", + "null" + ] + }, + "dismiss_notice": { + "description": "`true` dismisses the project's notice.", + "type": [ + "boolean", + "null" + ] + }, + "dpi": { + "description": "Render resolution for documents, 36 to 600.", + "format": "int32", + "type": [ + "integer", + "null" + ] + }, + "forge_token": { + "description": "A project on your organization's own GitLab instance: an access token for it (a project or group access token\nwith the `api` scope and the Developer role, or Maintainer to let VisualCI add its webhook), sent with\n`repository_url`. Stored encrypted; never shown again.", + "type": [ + "string", + "null" + ] + }, + "gallery_enabled": { + "description": "`false` takes the public gallery down (visualci.yml's `gallery` decides what's in it); `true` puts it back.", + "type": [ + "boolean", + "null" + ] + }, + "ignore_anti_aliasing": { + "description": "Ignore anti-aliasing differences in images.", + "type": [ + "boolean", + "null" + ] + }, + "ignore_rules": { + "description": "Values in text snapshots that change on every run, ignored when comparing. Replaces the project's rules. Each\nrule names the snapshots it applies to with a glob (`api/invoices/**`; `**` for every snapshot). A build's\n`visualci.yml` replaces these rules when it has `ignore`.", + "items": { + "additionalProperties": false, + "description": "An ignore rule for the snapshots whose names match a glob.", + "properties": { + "json_paths": { + "description": "JSON paths whose values are ignored: `$.generated_at`, `$.items[*].id`, `$..request_id`.", + "items": { + "type": "string" + }, + "type": "array" + }, + "snapshots": { + "description": "The snapshots this rule applies to, as a glob over snapshot names: `api/invoices/**`, `emails/*.html`.", + "type": "string" + }, + "text_patterns": { + "description": "Regular expressions; matching text is ignored in every text format.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "snapshots" + ], + "type": "object" + }, + "type": [ + "array", + "null" + ] + }, + "move_link": { + "default": false, + "description": "With `repository_url`: a repository belongs to one organization, so when another organization has it linked,\n`true` moves the link here (you must maintain the repository; that organization's admins get an email).", + "type": "boolean" + }, + "name": { + "description": "The project's display name.", + "type": [ + "string", + "null" + ] + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + }, + "public": { + "description": "`true` lets anyone, signed in or not, read the project's builds and diffs (for open source projects);\nsettings, tokens and reviewing stay with its members. Only a project linked to a public repository can be\npublic. `false` makes it private again.", + "type": [ + "boolean", + "null" + ] + }, + "renderer": { + "description": "The PDF renderer: `pdfbox` or `mutool`.", + "type": [ + "string", + "null" + ] + }, + "repository_url": { + "description": "The repository this project tests, by URL (`https://github.com/acme/web`); an empty string unlinks it.\nLinking needs the forge's VisualCI app installed on the repository and you to be an admin or maintainer of\nit there. Its pull requests then get VisualCI's check, and people's access to this organization follows their\npermission on it.", + "type": [ + "string", + "null" + ] + }, + "slug": { + "description": "A new slug, renaming the project (`acme/old` → `acme/new`): lowercase letters, digits and dashes. Its builds,\nbaselines and tokens stay. The old address and `acme/old` stop working.", + "type": [ + "string", + "null" + ] + }, + "threshold": { + "description": "The diff threshold, 0 to 1: 0 compares exactly; above 0 it's pixelmatch's colour threshold (how different a\npixel's colour must be to count), and anti-aliased pixels are ignored.", + "format": "double", + "type": [ + "number", + "null" + ] + }, + "tokens_can_approve": { + "description": "`false`: project tokens can't approve changes (people do); `true` lets CI's agents approve again.", + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, + "name": "update_project" + }, + { + "annotations": { + "destructiveHint": false, + "openWorldHint": false, + "readOnlyHint": false, + "title": "Upload snapshots" + }, + "description": "Add files to a build that's still receiving: PDFs, PNG/JPEG/WebP images, or text snapshots (plain text, JSON, HTML, serialized component trees; `format` or the file name's extension decides), base64. Files VisualCI has seen before aren't stored again. Up to 64 MB per call; call it as often as needed.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "build": { + "type": [ + "integer", + "string" + ] + }, + "files": { + "items": { + "properties": { + "content_base64": { + "description": "The file's bytes, base64. PDFs, PNG, JPEG or WebP images, or text (plain text, JSON, HTML, a serialized\ncomponent tree).", + "type": "string" + }, + "engine": { + "description": "Documents: `pdfbox` or `mutool`, overriding the project's renderer.", + "type": [ + "string", + "null" + ] + }, + "filename": { + "description": "The file's name or extension (e.g. `invoice.pdf`, `.png`, `response.json`), to tell images from text and JSON\nor HTML from plain text.", + "type": [ + "string", + "null" + ] + }, + "format": { + "description": "Text: `text`, `json` or `html`, overriding the file name. JSON is compared with keys sorted, HTML with\nattributes sorted and whitespace collapsed.", + "type": [ + "string", + "null" + ] + }, + "ignore": { + "additionalProperties": false, + "description": "Text: values to ignore in this snapshot only, `{json_paths, text_patterns}`, on top of the visualci.yml's or\nproject's rules. Rules for values that change on every run.", + "properties": { + "json_paths": { + "default": [], + "description": "JSON paths whose values are ignored: `$.generated_at`, `$.items[*].id`, `$..request_id`, `$[\"odd key\"]`.", + "items": { + "type": "string" + }, + "type": "array" + }, + "text_patterns": { + "default": [], + "description": "Regular expressions; matching text is ignored in every text format (after normalization).", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": [ + "object", + "null" + ] + }, + "meta": { + "description": "Anything to keep with the snapshot (test file, URL, viewport).", + "type": "object" + }, + "name": { + "description": "The snapshot's name, unique in the build (e.g. the test's name).", + "type": "string" + }, + "platform": { + "default": "", + "description": "For screenshots: the browser or device, so each platform keeps its own baseline.", + "type": "string" + }, + "threshold": { + "description": "The diff threshold (0 to 1), overriding the project's: 0 is exact, above 0 a perceptual colour threshold.", + "format": "double", + "type": [ + "number", + "null" + ] + } + }, + "required": [ + "name", + "content_base64" + ], + "type": "object" + }, + "type": "array" + }, + "project": { + "description": "`org/project`. Optional with a project token.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "build", + "files" + ], + "type": "object" + }, + "name": "upload_snapshots" + }, + { + "annotations": { + "idempotentHint": true, + "openWorldHint": false, + "readOnlyHint": true, + "title": "Who am I" + }, + "description": "Who this token belongs to (a person or a project), the organizations and projects it can reach with each organization's setup checklist (`setup`: steps done and the next one), and the newest builds whose changes wait for a review (`waiting_for_review`, at most 10). With no builds yet, `demo` names the public demo project to look at first.", + "inputSchema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "type": "object" + }, + "name": "whoami" + } + ] +} diff --git a/app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds-2.json b/app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds-2.json new file mode 100644 index 00000000..8a156677 --- /dev/null +++ b/app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds-2.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "limit": "lots" + }, + "result": { + "content": [ + { + "text": "failed to deserialize parameters: invalid type: string \"lots\", expected u64\n\nlist_builds takes:\n- branch (string): Only builds of this branch.\n- limit (integer): How many, newest first (default 20, at most 100).\n- project (string): `org/project`. Optional with a project token.\n- waiting_for_review (boolean): Only builds whose changes wait for a review (a local build only for the person whose run it was).\nExample: {}", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds.json b/app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds.json new file mode 100644 index 00000000..1b5e50e4 --- /dev/null +++ b/app/tests/golden/mcp/numbers_sent_as_strings_are_read_as_numbers/list_builds.json @@ -0,0 +1,17 @@ +{ + "arguments": { + "limit": "2" + }, + "result": { + "content": [ + { + "text": "{\"builds\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "builds": [] + } + } +} diff --git a/app/tests/golden/mcp/projects_can_be_renamed/get_project-2.json b/app/tests/golden/mcp/projects_can_be_renamed/get_project-2.json new file mode 100644 index 00000000..dd8e7baf --- /dev/null +++ b/app/tests/golden/mcp/projects_can_be_renamed/get_project-2.json @@ -0,0 +1,57 @@ +{ + "arguments": { + "project": "/monorepo" + }, + "result": { + "content": [ + { + "text": "{\"gallery\":{\"enabled\":true,\"items\":[],\"manifest_url\":null},\"project\":\"/monorepo\",\"repository_seen_in_ci\":null,\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[],\"name\":\"PDFs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"monorepo\",\"threshold\":0.0,\"tokens_can_approve\":true},\"tokens\":[{\"created_at\":\"\",\"id\":1,\"last_used_at\":null,\"name\":\"ci\",\"prefix\":\"\"}],\"url\":\"https://app.visualci.test//monorepo\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "gallery": { + "enabled": true, + "items": [], + "manifest_url": null + }, + "project": "/monorepo", + "repository_seen_in_ci": null, + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [], + "name": "PDFs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "monorepo", + "threshold": 0.0, + "tokens_can_approve": true + }, + "tokens": [ + { + "created_at": "", + "id": 1, + "last_used_at": null, + "name": "ci", + "prefix": "" + } + ], + "url": "https://app.visualci.test//monorepo" + } + } +} diff --git a/app/tests/golden/mcp/projects_can_be_renamed/get_project.json b/app/tests/golden/mcp/projects_can_be_renamed/get_project.json new file mode 100644 index 00000000..02da4036 --- /dev/null +++ b/app/tests/golden/mcp/projects_can_be_renamed/get_project.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "project": "/pdfs" + }, + "result": { + "content": [ + { + "text": "no project /pdfs that you can see", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/projects_can_be_renamed/update_project-2.json b/app/tests/golden/mcp/projects_can_be_renamed/update_project-2.json new file mode 100644 index 00000000..69daf1a3 --- /dev/null +++ b/app/tests/golden/mcp/projects_can_be_renamed/update_project-2.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "project": "/monorepo", + "slug": "shots" + }, + "result": { + "content": [ + { + "text": "the organization already has a project called shots", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/projects_can_be_renamed/update_project-3.json b/app/tests/golden/mcp/projects_can_be_renamed/update_project-3.json new file mode 100644 index 00000000..e71a8088 --- /dev/null +++ b/app/tests/golden/mcp/projects_can_be_renamed/update_project-3.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "project": "/monorepo", + "slug": "Not OK" + }, + "result": { + "content": [ + { + "text": "slug must be lowercase letters, digits and dashes, at most 60 characters", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/projects_can_be_renamed/update_project.json b/app/tests/golden/mcp/projects_can_be_renamed/update_project.json new file mode 100644 index 00000000..dc46ee3a --- /dev/null +++ b/app/tests/golden/mcp/projects_can_be_renamed/update_project.json @@ -0,0 +1,41 @@ +{ + "arguments": { + "project": "/pdfs", + "slug": "monorepo" + }, + "result": { + "content": [ + { + "text": "{\"settings\":{\"ci_mode\":\"review\",\"default_branch\":\"main\",\"dpi\":140,\"forge\":null,\"forge_app_installed\":false,\"forge_webhook_at\":null,\"gallery_enabled\":true,\"ignore_anti_aliasing\":false,\"ignore_rules\":[],\"name\":\"PDFs\",\"notice\":null,\"open_source\":false,\"open_source_note\":null,\"open_source_pool\":false,\"open_source_withdrawn\":false,\"public\":false,\"renderer\":\"pdfbox\",\"repository_public\":false,\"repository_url\":null,\"slug\":\"monorepo\",\"threshold\":0.0,\"tokens_can_approve\":true}}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "settings": { + "ci_mode": "review", + "default_branch": "main", + "dpi": 140, + "forge": null, + "forge_app_installed": false, + "forge_webhook_at": null, + "gallery_enabled": true, + "ignore_anti_aliasing": false, + "ignore_rules": [], + "name": "PDFs", + "notice": null, + "open_source": false, + "open_source_note": null, + "open_source_pool": false, + "open_source_withdrawn": false, + "public": false, + "renderer": "pdfbox", + "repository_public": false, + "repository_url": null, + "slug": "monorepo", + "threshold": 0.0, + "tokens_can_approve": true + } + } + } +} diff --git a/app/tests/golden/mcp/runs_a_build_from_uploaded_files/create_build.json b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/create_build.json new file mode 100644 index 00000000..560b7e67 --- /dev/null +++ b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/create_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/runs_a_build_from_uploaded_files/finalize_build.json b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/finalize_build.json new file mode 100644 index 00000000..827bdd3e --- /dev/null +++ b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/finalize_build.json @@ -0,0 +1,49 @@ +{ + "arguments": { + "build": "#1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"processing\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "processing", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_build.json b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_build.json new file mode 100644 index 00000000..f8847cf1 --- /dev/null +++ b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_build.json @@ -0,0 +1,76 @@ +{ + "arguments": { + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":\"changes\",\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"auto_approved\",\"reviewable\":true,\"reviews\":[],\"snapshots\":[{\"approved_elsewhere\":null,\"change\":{\"amount\":2,\"fraction\":1.0},\"changed_pages\":1,\"environment\":\"\",\"error\":null,\"format\":\"text\",\"id\":\"\",\"kind\":\"text\",\"lines_added\":2,\"lines_removed\":0,\"matched_environment\":null,\"moved_lines\":0,\"name\":\"greeting\",\"pages\":1,\"platform\":\"\",\"review\":null,\"state\":\"added\",\"url\":\"https://app.visualci.test//pdfs/builds/1/snapshots/\"}],\"state\":\"completed\",\"stats\":{\"added\":1,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":1,\"unchanged\":0},\"summary\":\"1 added\",\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": "changes", + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "auto_approved", + "reviewable": true, + "reviews": [], + "snapshots": [ + { + "approved_elsewhere": null, + "change": { + "amount": 2, + "fraction": 1.0 + }, + "changed_pages": 1, + "environment": "", + "error": null, + "format": "text", + "id": "", + "kind": "text", + "lines_added": 2, + "lines_removed": 0, + "matched_environment": null, + "moved_lines": 0, + "name": "greeting", + "pages": 1, + "platform": "", + "review": null, + "state": "added", + "url": "https://app.visualci.test//pdfs/builds/1/snapshots/" + } + ], + "state": "completed", + "stats": { + "added": 1, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 1, + "unchanged": 0 + }, + "summary": "1 added", + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_organization.json b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_organization.json new file mode 100644 index 00000000..3aca3267 --- /dev/null +++ b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/get_organization.json @@ -0,0 +1,152 @@ +{ + "arguments": { + "org": "" + }, + "result": { + "content": [ + { + "text": "{\"billing_url\":\"https://app.visualci.test//billing\",\"invitations\":[],\"members\":[{\"avatar_url\":null,\"email\":\"@example.com\",\"id\":\"\",\"identities\":[],\"login\":null,\"name\":\"owner\",\"role\":\"admin\",\"since\":\"\",\"source\":\"created\",\"synced_at\":null}],\"name\":\"Org\",\"projects\":[{\"last_build\":{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":\"changes\",\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":true,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"auto_approved\",\"reviewable\":true,\"reviews\":[],\"state\":\"completed\",\"stats\":{\"added\":1,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":1,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]},\"name\":\"PDFs\",\"project\":\"/pdfs\"},{\"last_build\":null,\"name\":\"Screenshots\",\"project\":\"/shots\"}],\"role\":\"admin\",\"setup\":{\"complete\":false,\"dismissed\":false,\"next\":\"install_github_app\",\"steps\":[{\"done\":true,\"key\":\"connect_agent\"},{\"done\":true,\"key\":\"create_project\"},{\"done\":false,\"key\":\"install_github_app\"},{\"done\":true,\"key\":\"add_to_ci\"},{\"done\":false,\"key\":\"review_changes\"}]},\"slug\":\"\",\"usage\":{\"auto_reload_packs\":4,\"billing_problem\":null,\"credit_pack\":{\"credits\":500000,\"price_cents\":1500,\"reload_below\":100000},\"credits_this_month\":1,\"included_credits\":25000,\"open_source\":{\"pool\":1000000,\"projects\":0,\"used\":0},\"out_of_credits\":false,\"pack_credits\":0,\"plan\":{\"credit_packs\":false,\"id\":\"free\",\"included_credits\":25000,\"name\":\"Free\",\"price_cents\":0,\"unlimited\":false},\"rates\":{\"image_diff\":10,\"rendered_page\":20,\"snapshot_check\":1,\"text_diff\":5},\"reloads_paused\":false,\"reloads_this_month\":0,\"renews_at\":\"\",\"unlimited\":false},\"usage_history\":[{\"created_at\":\"\",\"credits\":1,\"kind\":\"build\",\"reference\":\"build pdfs/1: 1 snapshot checked\"}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "billing_url": "https://app.visualci.test//billing", + "invitations": [], + "members": [ + { + "avatar_url": null, + "email": "@example.com", + "id": "", + "identities": [], + "login": null, + "name": "owner", + "role": "admin", + "since": "", + "source": "created", + "synced_at": null + } + ], + "name": "Org", + "projects": [ + { + "last_build": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": "changes", + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": true, + "pr_number": null, + "project": "/pdfs", + "review_state": "auto_approved", + "reviewable": true, + "reviews": [], + "state": "completed", + "stats": { + "added": 1, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 1, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + }, + "name": "PDFs", + "project": "/pdfs" + }, + { + "last_build": null, + "name": "Screenshots", + "project": "/shots" + } + ], + "role": "admin", + "setup": { + "complete": false, + "dismissed": false, + "next": "install_github_app", + "steps": [ + { + "done": true, + "key": "connect_agent" + }, + { + "done": true, + "key": "create_project" + }, + { + "done": false, + "key": "install_github_app" + }, + { + "done": true, + "key": "add_to_ci" + }, + { + "done": false, + "key": "review_changes" + } + ] + }, + "slug": "", + "usage": { + "auto_reload_packs": 4, + "billing_problem": null, + "credit_pack": { + "credits": 500000, + "price_cents": 1500, + "reload_below": 100000 + }, + "credits_this_month": 1, + "included_credits": 25000, + "open_source": { + "pool": 1000000, + "projects": 0, + "used": 0 + }, + "out_of_credits": false, + "pack_credits": 0, + "plan": { + "credit_packs": false, + "id": "free", + "included_credits": 25000, + "name": "Free", + "price_cents": 0, + "unlimited": false + }, + "rates": { + "image_diff": 10, + "rendered_page": 20, + "snapshot_check": 1, + "text_diff": 5 + }, + "reloads_paused": false, + "reloads_this_month": 0, + "renews_at": "", + "unlimited": false + }, + "usage_history": [ + { + "created_at": "", + "credits": 1, + "kind": "build", + "reference": "build pdfs/1: 1 snapshot checked" + } + ] + } + } +} diff --git a/app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots-2.json b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots-2.json new file mode 100644 index 00000000..bf90b912 --- /dev/null +++ b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots-2.json @@ -0,0 +1,20 @@ +{ + "arguments": { + "build": "1", + "files": [ + { + "content_base64": "%%%", + "name": "x" + } + ] + }, + "result": { + "content": [ + { + "text": "x: content_base64 isn't base64: Invalid symbol 37, offset 0.", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots.json b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots.json new file mode 100644 index 00000000..f0d3d703 --- /dev/null +++ b/app/tests/golden/mcp/runs_a_build_from_uploaded_files/upload_snapshots.json @@ -0,0 +1,31 @@ +{ + "arguments": { + "build": 1, + "files": [ + { + "content_base64": "aGVsbG8Kd29ybGQK", + "filename": "greeting.txt", + "name": "greeting" + } + ] + }, + "result": { + "content": [ + { + "text": "{\"build\":1,\"snapshots\":[{\"name\":\"greeting\",\"platform\":\"\",\"stored\":false}]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "build": 1, + "snapshots": [ + { + "name": "greeting", + "platform": "", + "stored": false + } + ] + } + } +} diff --git a/app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/create_build.json b/app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/create_build.json new file mode 100644 index 00000000..560b7e67 --- /dev/null +++ b/app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/create_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/finalize_build.json b/app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/finalize_build.json new file mode 100644 index 00000000..0517d2ba --- /dev/null +++ b/app/tests/golden/mcp/staff_plan_records_usage_but_never_runs_out/finalize_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "allow_empty": true, + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"processing\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "processing", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-2.json b/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-2.json new file mode 100644 index 00000000..42ac0e7e --- /dev/null +++ b/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-2.json @@ -0,0 +1,27 @@ +{ + "arguments": { + "action": "feedback", + "description": "A tiled watermark outlines every region. Token leaked here.", + "idempotency_key": "k1", + "impact": "friction", + "kind": "confusing", + "title": "Diff regions cover the whole page" + }, + "result": { + "content": [ + { + "text": "{\"duplicate\":true,\"feedback\":{\"id\":\"\",\"received_at\":\"\"},\"follow_up\":\"Nobody replies to feedback. The VisualCI team may email the user if it acts on this.\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "duplicate": true, + "feedback": { + "id": "", + "received_at": "" + }, + "follow_up": "Nobody replies to feedback. The VisualCI team may email the user if it acts on this." + } + } +} diff --git a/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-3.json b/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-3.json new file mode 100644 index 00000000..0d364d60 --- /dev/null +++ b/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send-3.json @@ -0,0 +1,16 @@ +{ + "arguments": { + "action": "feedback", + "description": "x", + "title": "Something" + }, + "result": { + "content": [ + { + "text": "support_send with action feedback needs title (3 to 200 characters), kind (bug, crash, wrong_result, confusing, missing_feature, docs, question, other) and description (1 to 4000 characters). Problem: kind is missing.", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send.json b/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send.json new file mode 100644 index 00000000..852f3b0a --- /dev/null +++ b/app/tests/golden/mcp/takes_feedback_and_says_what_a_bad_report_is_missing/support_send.json @@ -0,0 +1,27 @@ +{ + "arguments": { + "action": "feedback", + "description": "A tiled watermark outlines every region. Token leaked here.", + "idempotency_key": "k1", + "impact": "friction", + "kind": "confusing", + "title": "Diff regions cover the whole page" + }, + "result": { + "content": [ + { + "text": "{\"duplicate\":false,\"feedback\":{\"id\":\"\",\"received_at\":\"\"},\"follow_up\":\"Nobody replies to feedback. The VisualCI team may email the user if it acts on this.\"}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "duplicate": false, + "feedback": { + "id": "", + "received_at": "" + }, + "follow_up": "Nobody replies to feedback. The VisualCI team may email the user if it acts on this." + } + } +} diff --git a/app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/create_build.json b/app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/create_build.json new file mode 100644 index 00000000..94120d29 --- /dev/null +++ b/app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/create_build.json @@ -0,0 +1,71 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":{\"billing_url\":\"https://app.visualci.test//billing\",\"credits_limit\":1000000,\"credits_used\":1500000,\"fixes\":[{\"action\":\"buy_pack\",\"label\":\"Buy a credit pack\",\"url\":\"https://app.visualci.test//billing\"},{\"action\":\"turn_on_auto_buy\",\"label\":\"Turn on automatic packs, with a card\",\"url\":\"https://app.visualci.test//billing\"}],\"message\":\"Org is out of VisualCI credits until 1 January 2027: it has used all 1,000,000 credits on the Team plan, so builds aren't compared. An admin can buy a credit pack or turn on automatic packs at https://app.visualci.test//billing\",\"pack_credits\":0,\"plan\":\"Team\",\"reason\":\"out_of_credits\",\"renews_at\":\"\"},\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": { + "billing_url": "https://app.visualci.test//billing", + "credits_limit": 1000000, + "credits_used": 1500000, + "fixes": [ + { + "action": "buy_pack", + "label": "Buy a credit pack", + "url": "https://app.visualci.test//billing" + }, + { + "action": "turn_on_auto_buy", + "label": "Turn on automatic packs, with a card", + "url": "https://app.visualci.test//billing" + } + ], + "message": "Org is out of VisualCI credits until 1 January 2027: it has used all 1,000,000 credits on the Team plan, so builds aren't compared. An admin can buy a credit pack or turn on automatic packs at https://app.visualci.test//billing", + "pack_credits": 0, + "plan": "Team", + "reason": "out_of_credits", + "renews_at": "" + }, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/finalize_build.json b/app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/finalize_build.json new file mode 100644 index 00000000..8425b934 --- /dev/null +++ b/app/tests/golden/mcp/team_uses_its_allowance_first_then_pack_credits_and_stops_when_both_run_out/finalize_build.json @@ -0,0 +1,70 @@ +{ + "arguments": { + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":{\"billing_url\":\"https://app.visualci.test//billing\",\"credits_limit\":1000000,\"credits_used\":1500000,\"fixes\":[{\"action\":\"buy_pack\",\"label\":\"Buy a credit pack\",\"url\":\"https://app.visualci.test//billing\"},{\"action\":\"turn_on_auto_buy\",\"label\":\"Turn on automatic packs, with a card\",\"url\":\"https://app.visualci.test//billing\"}],\"message\":\"Org is out of VisualCI credits until 1 January 2027: it has used all 1,000,000 credits on the Team plan, so builds aren't compared. An admin can buy a credit pack or turn on automatic packs at https://app.visualci.test//billing\",\"pack_credits\":0,\"plan\":\"Team\",\"reason\":\"out_of_credits\",\"renews_at\":\"\"},\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":\"Org has used this month's 1,000,000 credits on the Team plan and has no pack credits left, so this build wasn't compared. Buy a credit pack on the billing page, or raise the limit on automatic reloads.\",\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":false,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"failed\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": { + "billing_url": "https://app.visualci.test//billing", + "credits_limit": 1000000, + "credits_used": 1500000, + "fixes": [ + { + "action": "buy_pack", + "label": "Buy a credit pack", + "url": "https://app.visualci.test//billing" + }, + { + "action": "turn_on_auto_buy", + "label": "Turn on automatic packs, with a card", + "url": "https://app.visualci.test//billing" + } + ], + "message": "Org is out of VisualCI credits until 1 January 2027: it has used all 1,000,000 credits on the Team plan, so builds aren't compared. An admin can buy a credit pack or turn on automatic packs at https://app.visualci.test//billing", + "pack_credits": 0, + "plan": "Team", + "reason": "out_of_credits", + "renews_at": "" + }, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": "Org has used this month's 1,000,000 credits on the Team plan and has no pack credits left, so this build wasn't compared. Buy a credit pack on the billing page, or raise the limit on automatic reloads.", + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": false, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "failed", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/create_build.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/create_build.json new file mode 100644 index 00000000..560b7e67 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/create_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "branch": "main", + "commit": "abc" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/finalize_build.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/finalize_build.json new file mode 100644 index 00000000..2e21e8fa --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/finalize_build.json @@ -0,0 +1,50 @@ +{ + "arguments": { + "allow_empty": true, + "build": "" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"state\":\"processing\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "state": "processing", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-2.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-2.json new file mode 100644 index 00000000..2cc323d5 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-2.json @@ -0,0 +1,52 @@ +{ + "arguments": { + "build": "1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-3.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-3.json new file mode 100644 index 00000000..2cb65e4c --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-3.json @@ -0,0 +1,52 @@ +{ + "arguments": { + "build": "#1" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-4.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-4.json new file mode 100644 index 00000000..e237404d --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build-4.json @@ -0,0 +1,52 @@ +{ + "arguments": { + "build": "" + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build.json new file mode 100644 index 00000000..8e817a57 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_build.json @@ -0,0 +1,52 @@ +{ + "arguments": { + "build": 1 + }, + "result": { + "content": [ + { + "text": "{\"blocked\":null,\"branch\":\"main\",\"ci_mode\":\"review\",\"commit\":\"abc\",\"conclusion\":null,\"config\":null,\"created_at\":\"\",\"environment\":\"ci\",\"environment_info\":{},\"error\":null,\"id\":\"\",\"mode\":\"ci\",\"name\":\"default\",\"number\":1,\"passed\":null,\"pr_number\":null,\"project\":\"/pdfs\",\"review_state\":\"none\",\"reviewable\":false,\"reviews\":[],\"snapshots\":[],\"state\":\"receiving\",\"stats\":{\"added\":0,\"changed\":0,\"config\":0,\"failed\":0,\"ignored\":0,\"pending\":0,\"removed\":0,\"total\":0,\"unchanged\":0},\"summary\":null,\"url\":\"https://app.visualci.test//pdfs/builds/1\",\"warnings\":[]}", + "type": "text" + } + ], + "isError": false, + "structuredContent": { + "blocked": null, + "branch": "main", + "ci_mode": "review", + "commit": "abc", + "conclusion": null, + "config": null, + "created_at": "", + "environment": "ci", + "environment_info": {}, + "error": null, + "id": "", + "mode": "ci", + "name": "default", + "number": 1, + "passed": null, + "pr_number": null, + "project": "/pdfs", + "review_state": "none", + "reviewable": false, + "reviews": [], + "snapshots": [], + "state": "receiving", + "stats": { + "added": 0, + "changed": 0, + "config": 0, + "failed": 0, + "ignored": 0, + "pending": 0, + "removed": 0, + "total": 0, + "unchanged": 0 + }, + "summary": null, + "url": "https://app.visualci.test//pdfs/builds/1", + "warnings": [] + } + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-2.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-2.json new file mode 100644 index 00000000..a6dbb7cd --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-2.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": "1", + "name": "missing" + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-3.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-3.json new file mode 100644 index 00000000..0655a480 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-3.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": "#1", + "name": "missing" + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-4.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-4.json new file mode 100644 index 00000000..cc4fb8fb --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-4.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": "", + "name": "missing" + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-5.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-5.json new file mode 100644 index 00000000..90d5bb4e --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-5.json @@ -0,0 +1,14 @@ +{ + "arguments": { + "build_number": 1 + }, + "result": { + "content": [ + { + "text": "get_snapshot doesn't take `build_number`.\n\nget_snapshot takes:\n- build (required; integer or string): The build number or id.\n- against (string): What the new side is compared with: `baseline` (the default, what review uses), `previous` (the newest earlier build of this snapshot on the branch: did a fix answer a comment there?), or an earlier build's number on the branch. Only `baseline` decides the review; the others are a view.\n- crop (string): `changed` crops each image to the changed regions with a margin, for a close look at a small change on a tall page.\n- id (string): The snapshot's id, as `get_build` lists it: instead of `name` and `platform`.\n- images (string): Which images to include: `all` (base, head, diff; the default), `diff`, `head`, `base`, or `none`. For text, JSON and HTML: `head`, `base` or `all` adds that whole version's text.\n- max_width (integer): Scale images down to this width in pixels (default 1200). Large ones come back as JPEG.\n- name (string): The snapshot's name, as `get_build` lists it, or its `id` from `get_build`.\n- pages (array): Positions of the pages to include images for (from a previous answer). Default: the first three changed pages.\n- platform (string): The snapshot's platform. Optional when the name is on one platform only.\n- project (string): `org/project`. Optional with a project token.\nExample: {\"build\":8}", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-6.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-6.json new file mode 100644 index 00000000..2581a697 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot-6.json @@ -0,0 +1,12 @@ +{ + "arguments": {}, + "result": { + "content": [ + { + "text": "failed to deserialize parameters: missing field `build`\n\nget_snapshot takes:\n- build (required; integer or string): The build number or id.\n- against (string): What the new side is compared with: `baseline` (the default, what review uses), `previous` (the newest earlier build of this snapshot on the branch: did a fix answer a comment there?), or an earlier build's number on the branch. Only `baseline` decides the review; the others are a view.\n- crop (string): `changed` crops each image to the changed regions with a margin, for a close look at a small change on a tall page.\n- id (string): The snapshot's id, as `get_build` lists it: instead of `name` and `platform`.\n- images (string): Which images to include: `all` (base, head, diff; the default), `diff`, `head`, `base`, or `none`. For text, JSON and HTML: `head`, `base` or `all` adds that whole version's text.\n- max_width (integer): Scale images down to this width in pixels (default 1200). Large ones come back as JPEG.\n- name (string): The snapshot's name, as `get_build` lists it, or its `id` from `get_build`.\n- pages (array): Positions of the pages to include images for (from a previous answer). Default: the first three changed pages.\n- platform (string): The snapshot's platform. Optional when the name is on one platform only.\n- project (string): `org/project`. Optional with a project token.\nExample: {\"build\":8}", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot.json new file mode 100644 index 00000000..44effc2f --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/get_snapshot.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "build": 1, + "name": "missing" + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-2.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-2.json new file mode 100644 index 00000000..d8916521 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-2.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "approve", + "build": "1" + }, + "result": { + "content": [ + { + "text": "build 1 isn't finalized yet: run `visualci build finalize` first", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-3.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-3.json new file mode 100644 index 00000000..93866b87 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-3.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "approve", + "build": "#1" + }, + "result": { + "content": [ + { + "text": "build 1 isn't finalized yet: run `visualci build finalize` first", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-4.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-4.json new file mode 100644 index 00000000..29ddebf8 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-4.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "approve", + "build": "" + }, + "result": { + "content": [ + { + "text": "build 1 isn't finalized yet: run `visualci build finalize` first", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-5.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-5.json new file mode 100644 index 00000000..5229b56a --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review-5.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "approve", + "build": true + }, + "result": { + "content": [ + { + "text": "failed to deserialize parameters: build must be a number or a string, not true\n\nreview takes:\n- action (required; string): `approve` or `reject`.\n- build (required; integer or string)\n- comment (string): With `reject`: why, as a comment thread on each rejected snapshot (Markdown), so the next person or agent sees what's wrong. Approving a snapshot with an open thread is refused until the thread is resolved.\n- note (string): Why you approved or rejected, in a sentence. It's shown wherever the review appears (the build's reviews, the pull request comment). A note, not a thread: it never blocks anything.\n- only (string): Only the build's `added` (new) snapshots, only its `changed` ones, or only its `matching` ones (changes made only of changes merged pull requests approved: `get_build`'s `matches`), in one call. Not with `snapshots`.\n- project (string): `org/project`. Optional with a project token.\n- snapshots (array): Snapshot names to review; all changed snapshots when left out.\nExample: {\"action\":\"\",\"build\":8}", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review.json new file mode 100644 index 00000000..3ceef45a --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review.json @@ -0,0 +1,15 @@ +{ + "arguments": { + "action": "approve", + "build": 1 + }, + "result": { + "content": [ + { + "text": "build 1 isn't finalized yet: run `visualci build finalize` first", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-2.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-2.json new file mode 100644 index 00000000..4a542c23 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-2.json @@ -0,0 +1,17 @@ +{ + "arguments": { + "action": "variant", + "build": "1", + "name": "missing", + "position": 1 + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-3.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-3.json new file mode 100644 index 00000000..1a5d9832 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-3.json @@ -0,0 +1,17 @@ +{ + "arguments": { + "action": "variant", + "build": "#1", + "name": "missing", + "position": 1 + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-4.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-4.json new file mode 100644 index 00000000..daaebaf4 --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page-4.json @@ -0,0 +1,17 @@ +{ + "arguments": { + "action": "variant", + "build": "", + "name": "missing", + "position": 1 + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page.json b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page.json new file mode 100644 index 00000000..53bcf0fb --- /dev/null +++ b/app/tests/golden/mcp/tools_that_take_a_build_read_every_form_and_explain_bad_arguments/review_page.json @@ -0,0 +1,17 @@ +{ + "arguments": { + "action": "variant", + "build": 1, + "name": "missing", + "position": 1 + }, + "result": { + "content": [ + { + "text": "no snapshot \"missing\" in build 1", + "type": "text" + } + ], + "isError": true + } +} diff --git a/app/tests/golden/mod.rs b/app/tests/golden/mod.rs new file mode 100644 index 00000000..faa68750 --- /dev/null +++ b/app/tests/golden/mod.rs @@ -0,0 +1,85 @@ +//! Today's answers, recorded from the Loco server's request tests (`VISUALCI_JSON_SNAPSHOTS`), as the port's contract: +//! the same request must answer the same JSON once run-to-run noise (ids, slugs, tokens, times, signatures) is replaced +//! by numbered placeholders, as server/tests/requests/json_snapshots.rs did. + +use std::collections::HashMap; +use std::sync::LazyLock; + +use regex::Regex; + +/// Assert that `value` matches the golden file `tests/golden///.json`. +/// +/// # Panics +/// When it doesn't, showing both. +pub fn check(kind: &str, test: &str, name: &str, value: &serde_json::Value) { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/golden") + .join(kind) + .join(test) + .join(format!("{name}.json")); + let golden: serde_json::Value = serde_json::from_str( + &std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("reading {}: {e}", path.display())), + ) + .expect("a golden file is JSON"); + let got = normalize(value); + assert!( + got == golden, + "{} differs from today's answer.\n--- today\n{}\n--- now\n{}", + path.display(), + serde_json::to_string_pretty(&golden).unwrap_or_default(), + serde_json::to_string_pretty(&got).unwrap_or_default() + ); +} + +static NOISE: LazyLock> = LazyLock::new(|| { + [ + ("presigned", r"X-Amz-[A-Za-z-]+=[^&\s\x22\\]*(&X-Amz-[A-Za-z-]+=[^&\s\x22\\]*)*"), + ("token", r"\bvc[iu]_[A-Za-z0-9]+"), + ("id", r"\b[a-z]{2,8}_[0-9a-f]{32}\b"), + ("uuid", r"\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b"), + ("org", r"\borg-[0-9a-f]{8}\b"), + ("time", r"\b\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:?\d{2})?"), + ] + .into_iter() + .map(|(kind, re)| (kind, Regex::new(re).expect("a valid pattern"))) + .collect() +}); + +fn normalize(value: &serde_json::Value) -> serde_json::Value { + let mut seen: HashMap<(&'static str, String), usize> = HashMap::new(); + let mut counts: HashMap<&'static str, usize> = HashMap::new(); + let mut fix = |s: &str| -> String { + let mut out = s.to_string(); + for &(kind, ref re) in NOISE.iter() { + out = re + .replace_all(&out, |caps: ®ex::Captures| { + if kind == "presigned" { + return "".to_string(); + } + let n = *seen.entry((kind, caps[0].to_string())).or_insert_with(|| { + let c = counts.entry(kind).or_insert(0); + *c += 1; + *c + }); + format!("<{kind}:{n}>") + }) + .into_owned(); + } + out + }; + walk(value, &mut fix) +} + +fn walk(value: &serde_json::Value, fix: &mut impl FnMut(&str) -> String) -> serde_json::Value { + match value { + serde_json::Value::String(s) => serde_json::Value::String(fix(s)), + serde_json::Value::Array(items) => items.iter().map(|v| walk(v, fix)).collect(), + // Keys in sorted order, as today's server (without serde_json's preserve_order) numbered its placeholders. + serde_json::Value::Object(map) => { + let mut keys: Vec<&String> = map.keys().collect(); + keys.sort(); + keys.into_iter().map(|k| (k.clone(), walk(&map[k], fix))).collect() + } + other => other.clone(), + } +} From cb7fee4178bac8c79da214dd34815aa57448fc9c Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Thu, 3 Dec 2026 03:15:06 +1300 Subject: [PATCH 2/2] app/: the API takes the application's blob store --- app/src/http/api/builds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/http/api/builds.rs b/app/src/http/api/builds.rs index d0ecb5ef..052aec39 100644 --- a/app/src/http/api/builds.rs +++ b/app/src/http/api/builds.rs @@ -157,7 +157,7 @@ pub async fn add_snapshots( if params.snapshots.len() > 1000 { return Err(ApiError::bad_request("send at most 1000 snapshots per request")); } - let store = BlobStore::current()?; + let store = BlobStore::current().await?; let build = own_build(&project, pid).await?; if build.state != "receiving" { return Err(ApiError::bad_request(format!(