[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M699RZ356JNKM1K10HYSTRDD":3,"skill-same:01M699RZ356JNKM1K10HYSTRDD":117},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":31,"publishedAt":57,"linkOnly":58,"markdownContent":59,"markdownBody":60,"frontMatter":61,"refName":66,"commitSha":67,"skillDirectory":68,"forksCount":69,"repositoryHtmlUrl":70,"repositoryHomepageUrl":71,"ownerHtmlUrl":72,"ownerBlogUrl":73,"ownerDescription":74,"updatedAt":75,"install":76,"resources":88},"01M699RZ356JNKM1K10HYSTRDD","add-ai-webapi",null,"Integrates Power Pages generative-AI summarization APIs (PREVIEW) into a Single Page Application (SPA) site — the Search Summary API and the Data Summarization API — on any record-detail or list page. Generates per-target service code (CSRF-handled) and AI site settings; delegates Web API settings, table permissions, and web roles to `\u002Fintegrate-webapi` and `\u002Fcreate-webroles`. Use whenever a user wants AI\u002FCopilot output that condenses Dataverse content on a Power Pages site — an AI summary, AI-generated overview or \"key insights\" across a record or list, a search-results summary, a case\u002Fincident summary, or recommendation-chip refinement — even when phrased as \"AI-generated paragraph\", \"insights\", or \"overview\". Do NOT use for: generative pages in model-driven apps (use the model-apps `genpage` skill), Copilot Studio agents\u002Fchatbots, summarizing documents or PDFs, Power BI dashboards, plain keyword search with no AI summary, or plain Dataverse CRUD (use `\u002Fintegrate-webapi`).","microsoft\u002Fpower-platform-skills","microsoft","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6154722?v=4","01M698VYDXZ6JW5WH3CRV650R8","Microsoft","01M699JVYJFB75D9JM70BN4H0Q",1149,"MIT","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":27,"categoryName":28,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,9,55,56],"add","add ai webapi","create","generative","which","apps","power","edit","write","read","csrf","search","permissions","capabilities","MCP","power bi","copilot studio","incident summary","documents","genpage","copilot","power pages","dataverse","web","docs","2026-11-10 10:12:30",false,"---\nname: add-ai-webapi\ndescription: >-\n  Integrates Power Pages generative-AI summarization APIs (PREVIEW) into a Single Page Application\n  (SPA) site — the Search Summary API and the Data Summarization API — on any record-detail or list\n  page. Generates per-target service code (CSRF-handled) and AI site settings; delegates Web API\n  settings, table permissions, and web roles to `\u002Fintegrate-webapi` and `\u002Fcreate-webroles`. Use\n  whenever a user wants AI\u002FCopilot output that condenses Dataverse content on a Power Pages site —\n  an AI summary, AI-generated overview or \"key insights\" across a record or list, a search-results\n  summary, a case\u002Fincident summary, or recommendation-chip refinement — even when phrased as\n  \"AI-generated paragraph\", \"insights\", or \"overview\". Do NOT use for: generative pages in\n  model-driven apps (use the model-apps `genpage` skill), Copilot Studio agents\u002Fchatbots,\n  summarizing documents or PDFs, Power BI dashboards, plain keyword search with no AI summary, or\n  plain Dataverse CRUD (use `\u002Fintegrate-webapi`).\nuser-invocable: true\nargument-hint: Optional description of which pages\u002Ftables need AI capabilities\nallowed-tools: Read, Write, Edit, Bash, Grep, Glob, AskUserQuestion, Skill, Task, TaskCreate, TaskUpdate, TaskList, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_search, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch\nmodel: opus\n---\n\n> **Plugin check**: Run `node \"${PLUGIN_ROOT}\u002Fscripts\u002Fcheck-version.js\"` — if it outputs a message, show it to the user before proceeding.\n\n# Add AI Web API\n\n> **Note**\n>\n> AI summarization APIs are a preview feature. Preview features aren't meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.\n\n**Surface this note to the user verbatim** during Phase 1 and again in the Phase 8 summary —\ncopy the exact `**Note**` block above (including its wording about \"available before an official\nrelease so that customers can get early access and provide feedback\"). Do not paraphrase it into\nyour own \"Preview-feature note: ...\" sentence; the wording matches the Microsoft Learn preview\ndisclaimer and rephrasing it loses that fidelity.\n\nIntegrate Power Pages generative-AI summarization APIs into a SPA site. This skill focuses on the AI layer (Layer 3): the summarization service code and the `Summarization\u002F*` site settings. The underlying Web API prerequisites — `Webapi\u002F\u003Ctable>\u002Fenabled`, `Webapi\u002F\u003Ctable>\u002Ffields`, table permissions, and web roles — are **delegated** to `\u002Fintegrate-webapi` and `\u002Fcreate-webroles` so there is a single source of truth for every layer.\n\n## The two APIs covered\n\n| # | API | URL | Body | Response |\n|---|-----|-----|------|----------|\n| 1 | **Search Summary** | `POST \u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` | `{ userQuery }` | `{ Summary, Citations }` |\n| 2 | **Data Summarization** | `POST \u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F\u003CentitySet>(\u003Cid>)?$select=...&$expand=...` | `{ InstructionIdentifier }` or `{ RecommendationConfig }` | `{ Summary, Recommendations }` |\n\n> **Example: Microsoft-shipped Copilot summary on a support-case page.** Data Summarization can be\n> called with any combination of entity set, columns, and prompt — but Microsoft documents and\n> ships one specific configuration for the standard `incident` table:\n> `POST \u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002Fincidents(\u003CcaseId>)?$select=description,title&$expand=incident_adx_portalcomments($select=description)`\n> with body `{ \"InstructionIdentifier\": \"Summarization\u002Fprompt\u002Fcase_summary\" }`. This is sometimes\n> called the \"Case-page Copilot preset\" in Microsoft Learn. Treat it as one possible Data\n> Summarization recipe — useful when the user explicitly wants to mirror the Microsoft sample —\n> not as an automatic recommendation. A custom case-like table (`cr363_servicerequest`,\n> `adx_case`), or the standard incident table summarised on different facets (priority, owner,\n> SLA timer), is just a regular Data Summarization call with maker-defined values.\n\n> Reference: `${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fai-api-reference.md` — canonical\n> API shapes, required headers, site-setting names, error codes, and the documented support-case\n> example. Read this at the start of the workflow; fetch the Microsoft Learn source pages with\n> `mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch` if the user asks for the latest.\n\n> **Admin governance hierarchy**: both APIs are gated by a **three-level admin\n> hierarchy** — tenant PowerShell setting (`enableGenerativeAIFeaturesForSiteUsers`), Copilot Hub\n> environment\u002Fsite governance, and the site-level maker toggle (for Search Summary: Set up\n> workspace → Copilot → Site search (preview) → Enable Site search with generative AI (preview)).\n> **Each level overrides the one below it**, so \"the maker toggle is on but the API still says\n> disabled\" is a real scenario — admin-level governance wins.\n>\n> The two endpoints surface disablement differently:\n>\n> - **Search Summary** → HTTP **200** with an embedded envelope `{ Code: 400, Message: \"Gen AI\n>   Search is disabled.\" }`. The generated `fetchSearchSummary` detects this and throws\n>   `SearchSummaryApiError`; the UI renders a remediation card.\n> - **Data Summarization** → HTTP **400** with `error.code = 90041001` (admin-level disabled) or\n>   `90041003` (per-site `Summarization\u002FData\u002FEnable=false`).\n>\n> Full troubleshooting checklist (tenant → environment → site, plus runtime version, Bing\n> dependency, and cross-region data movement) lives in\n> `references\u002Fai-api-reference.md` §1 \"Troubleshooting: AI feature appears disabled (admin\n> hierarchy)\" — point users there when either disablement shape surfaces. Mention this governance\n> hierarchy explicitly to the user before Phase 7, and again in the Phase 8 summary.\n\n> **Built-in search control vs. custom code path**: if the site uses the Microsoft-shipped Power\n> Pages search **control** and only wants AI-summarised search results on that page, they don't\n> need this skill — just the Copilot workspace toggle and the `Search\u002FSummary\u002FTitle` content\n> snippet. This skill is for sites that build their own search UI or need to call\n> `\u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` from custom code. Confirm which path the user is on in Phase 1.\n\n## Core principles\n\n- **Layer 3 only, delegate the rest.** Web API site settings, table permissions, and web roles all belong to `\u002Fintegrate-webapi` and `\u002Fcreate-webroles`. This skill creates the summarization service code and the `Summarization\u002F*` site settings — nothing else.\n- **Sequential agent spawning.** Per `plugins\u002Fpower-pages\u002FAGENTS.md`, spawn the `ai-webapi-integration` agent sequentially per target (never in parallel). The first call establishes the shared summarization service file and CSRF helper; subsequent calls extend it. `ai-webapi-settings-architect` runs alone, after all code integrations land.\n- **Raw `fetch` + CSRF.** Every summarization request attaches `__RequestVerificationToken` (from `\u002F_layout\u002Ftokenhtml`) and `X-Requested-With: XMLHttpRequest`. Never route through an OData wrapper.\n- **Skip `\u002Fintegrate-webapi` when it's not needed.** If every confirmed target is Search Summary (which has no per-table Web API prerequisites), or every Layer 1\u002F2 prerequisite already exists on disk, the skill goes straight from Phase 3 to Phase 5.\n- **Use TaskCreate\u002FTaskUpdate** — create the todo list upfront with all phases before starting.\n- **Preserve site integrity.** Before adding or tweaking an AI surface, read `${PLUGIN_ROOT}\u002Freferences\u002Fsite-modification-integrity.md`; localization covers labels, loading, empty, error, citation, recommendation, and remediation states, and the UI must remain bidirectional and expansion-safe.\n\n> **Prerequisites:**\n>\n> - An existing Power Pages SPA site created via `\u002Fcreate-site`\n> - A Dataverse data model (tables + columns) set up via `\u002Fsetup-datamodel` or manually — for any\n>   Data Summarization target\n> - The site must have been deployed at least once (`.powerpages-site` folder must exist) for the\n>   settings phase\n\n**Initial request:** $ARGUMENTS\n\n---\n\n## Workflow\n\n(Phase headings below the workflow keep the technical \"Layer 1+2 \u002F Layer 3\" names because they\ndescribe the runtime layering and are what maintainers grep for. The titles here mirror the\nuser-facing task list.)\n\n1. **Check site is ready** — locate project, detect framework, check data model, deployment status, and web-role presence.\n2. **Find where AI summaries fit** — scan code for search \u002F data summarization candidates.\n3. **Confirm what to add** — review the manifest and pick which APIs \u002F targets to integrate.\n4. **Set up data access for AI** — invoke `\u002Fcreate-webroles` if needed, then invoke `\u002Fintegrate-webapi` in AI-only read mode for data\u002Fcase targets. Skip entirely for search-only or when prerequisites already exist.\n5. **Add AI summary code** — invoke the `ai-webapi-integration` agent sequentially per target.\n6. **Register AI prompts** — invoke the `ai-webapi-settings-architect` agent.\n7. **Verify everything** — header-contract grep, `$select` grep, `npm run build`, validator script.\n8. **Review and deploy** — record skill usage, summarise, offer `\u002Fdeploy-site`.\n\n---\n\n## Iteration mode (after first run)\n\nThis skill is a **one-shot setup skill** — Phases 1–8 run end-to-end the first time the user asks\nto integrate a summarization API. Once an AI surface is in place (service file, framework wrapper,\nUI call site, and `Summarization\u002F*` settings all exist), follow-up requests to tweak the rendered\nUI (colours, spacing, copy, moving a button, a different empty-state message, wiring a second\nrecommendation into the hook, etc.) are **not** a reason to re-enter this skill mentally and run\nevery phase again. Doing so triggers a full `pac pages upload-code-site` and a chain of\n`git commit`s for each tweak, which is exactly the noisy cadence the Phase 5.5 \u002F 6.4 prompts above\nare there to avoid.\n\nWhen the user asks for follow-up UI changes to an already-integrated AI surface:\n\n- **Edit the file(s) and run `npm run build`** locally to verify the tweak compiles. That is the\n  whole validation loop for a UI change.\n- **Do NOT automatically run `pac pages upload-code-site`.** Uploading should happen once, at the\n  end of the session, when the user has finished tweaking.\n- **Do NOT automatically `git commit`.** Let the user batch related tweaks into a single commit.\n- **Batch the deployment and commit into a single end-of-session prompt** once the user signals\n  they're done (or when you've completed the last requested change).\n\n\u003C!-- gate: add-ai-webapi:iter.deploy-commit | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:iter.deploy-commit):** End-of-iteration batched deploy + commit prompt — avoids a noisy per-tweak upload\u002Fcommit cadence.\n>\n> **Trigger:** User signals they're done with UI tweaks for the session.\n> **Why we ask:** Auto-deploying or committing after every small edit produces one `git commit` + one `pac pages upload-code-site` per tweak; batching keeps history readable and avoids redundant deploys.\n> **Cancel leaves:** Nothing — source files already edited; no deploy or commit fired.\n\n  Use `AskUserQuestion`:\n\n  | Question | Header | Options |\n  |----------|--------|---------|\n  | All the UI tweaks look good. Deploy the site and commit the changes now? | Deploy & commit | Yes, deploy and commit (Recommended), Just commit — I'll deploy later, Just deploy — I'll commit later, Neither — I'll handle both myself |\n\nRe-enter the full skill flow only when the user is adding a **new** AI surface (a new page, a new\ntable, a second API). If you're unsure whether a request is a tweak or a new surface, ask.\n\n---\n\n## Phase 1: Verify Site Exists\n\n**Goal**: Locate the Power Pages project root and confirm prerequisites.\n\n### 1.0 Detect iteration mode (before anything else)\n\nRe-entry detection comes first because the rest of the skill assumes a first-time setup.\nCapture two signals about the project state:\n\n1. **Service signal**: a summarization service exists — `src\u002Fservices\u002FaiSummaryService.*`, or any\n   source file under `src\u002F` that contains `\u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` or\n   `\u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F`. When the signal is present, also note which API surface(s)\n   the service code references — search-only, data-only, or both. This sub-classification matters\n   below.\n2. **Settings signal**: at least one Layer 3 site setting exists in\n   `.powerpages-site\u002Fsite-settings\u002FSummarization-*.sitesetting.yml`.\n\nThen route on the combination:\n\n- **Both signals present** → re-entry. A previous `\u002Fadd-ai-webapi` run completed end-to-end. Show\n  the iteration-mode prompt below.\n- **Service signal present and the existing service code is search-only** (it references\n  `\u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` but **not** `\u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F`) → re-entry. Search-only\n  sites legitimately have no `Summarization\u002F*` settings (Search Summary uses the workspace toggle,\n  not per-call settings), so the absence of the settings signal is the steady state, not a\n  failed run. Show the iteration-mode prompt below.\n- **Service signal present and the existing service code includes Data Summarization** but the\n  settings signal is absent → in-flight first run (a previous attempt failed before Phase 6\n  landed). Continue with the full flow without prompting.\n- **Neither signal present** → first-time run. Continue with Phase 1.1.\n\nWhen you reach the iteration-mode branch, ask:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| It looks like an AI summary surface is already wired into this site. Is this request a tweak to the existing one, or are you adding a brand-new surface (new page, new table, second API)? | Mode | Tweak the existing surface (Recommended for visual\u002Fcopy edits), Add a new surface (run the full skill again), Not sure — show me what's already wired |\n\n- **Tweak the existing surface**: stop running this skill. Switch into the workflow described in\n  the [Iteration mode](#iteration-mode-after-first-run) section above — Edit + `npm run build`,\n  no auto upload-code-site, no auto commit, batched end-of-session prompt for deploy + commit.\n- **Add a new surface**: continue with Phase 1.1 (full flow). The downstream phases will detect\n  existing infrastructure (CSRF helper, summarization service, settings) and extend rather than\n  duplicate.\n- **Not sure — show me what's already wired**: list the existing service file(s), wired UI\n  components, and `Summarization\u002F*` settings, then re-ask the same question.\n\n### 1.1 Create todo list\n\nCreate all 8 phase tasks upfront via `TaskCreate` — see [Progress Tracking](#progress-tracking).\n\n### 1.2 Locate project\n\nLook for `powerpages.config.json` in the current directory or immediate subdirectories.\n\n**If not found**: tell the user to create a site first with `\u002Fcreate-site`.\n\n### 1.3 Detect framework\n\nRead `package.json` and detect React \u002F Vue \u002F Angular \u002F Astro. See\n`${PLUGIN_ROOT}\u002Freferences\u002Fframework-conventions.md`.\n\n### 1.4 Check for data model\n\nLook for `.datamodel-manifest.json`. If found, read it — tables listed here are candidates for the\nData Summarization API. The standard `incident` table is a candidate like any other; do not\ntreat it specially.\n\n### 1.5 Check deployment status — hard prerequisite\n\nLook for `.powerpages-site`. Phase 4 (`\u002Fintegrate-webapi`) and Phase 6 (`ai-webapi-settings-architect`)\nboth require this folder to exist. Deferring the deploy until later is **not** a viable workaround:\nonce Phase 5 has written the AI-calling service code, deploying a site whose Layer 1\u002F2\u002F3 settings\naren't yet on disk publishes runtime-broken code (every summarization call 403\u002F500s until a second\ndeploy lands). The cleanest sequence is to deploy the **clean scaffold** now, before any AI code\nexists.\n\n**If `.powerpages-site` does NOT exist:**\n\n| Question | Header | Options |\n|----------|--------|---------|\n| `.powerpages-site` was not found. The AI summary skill needs the site deployed at least once before configuring permissions and settings. Deploy the clean scaffold now (no AI code yet — keeps the intermediate state safe), or stop and run `\u002Fdeploy-site` yourself first? | Bootstrap deploy | Yes, deploy the scaffold now (Recommended), Stop — I'll deploy first then re-run \u002Fadd-ai-webapi |\n\nOn **Yes**: invoke the `Skill` tool for `power-pages:deploy-site` and wait for completion. Then\nre-check `.powerpages-site` exists before proceeding. **If it is still absent** after the\nsub-skill returns (deploy failed mid-flow, the user cancelled it, or an upload completed but the\nlocal folder wasn't created), stop here with a clear message — surface the deploy-site outcome\nverbatim so the user can debug it, and tell them to re-run `\u002Fdeploy-site` followed by\n`\u002Fadd-ai-webapi`. Do NOT silently fall through to Phase 2; the downstream sub-skills require this\nfolder.\n\nOn **Stop**: end the skill with a clear next-step message (\"Run `\u002Fdeploy-site`, then re-invoke\n`\u002Fadd-ai-webapi` to continue\"). Do NOT continue to Phase 2 — the downstream sub-skills can't run.\n\n### 1.6 Check web roles\n\nLook for `.powerpages-site\u002Fweb-roles\u002F*.yml`. Record whether any roles exist — the Phase 4\ndelegation needs at least one role before `\u002Fintegrate-webapi` can create table permissions.\n\n**Output**: confirmed project root, framework, data-model availability, deployment status, web-role inventory.\n\n---\n\n## Phase 2: Explore AI integration points\n\n**Goal**: Find every candidate for each of the two APIs — scoped to AI only.\n\nThe full Explore-agent prompt body, manifest shape, and delegation-decision rules live in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fexplore-prompt.md`. Read that file\nfirst, then invoke the **Explore agent** (via `Task` with `subagent_type: \"Explore\"`,\nthoroughness `medium`) and pass the prompt body verbatim.\n\nWhat the Explore agent reports back (summary — see the reference for the exact prompt):\n\n- **Reserved-slot markers** (`POWERPAGES:AI-SLOT kind=\u003Cpick>`) — authoritative placement hints\n  planted by `\u002Fcreate-site`; orphan markers are flagged for Phase 3 to resolve.\n- **Search Summary candidates** including related-record-discovery targets on detail pages\n  (\"suggested KB articles\", \"similar cases\").\n- **Data Summarization candidates** classified `single-record` \u002F `list` \u002F `intent-mismatch`,\n  each with the existing fetch's OData query and a scope classification\n  (`matches-existing-fetch` \u002F `scope-extends-beyond-existing-fetch` \u002F `needs-definition` \u002F\n  `intent-mismatch`).\n- **Existing infrastructure** — CSRF helper, `powerPagesApi.ts`, prior `aiSummaryService.*`.\n- **Layer 1\u002F2 status** per Data Summarization target plus every `$expand` target —\n  `ready` \u002F `missing` \u002F `n\u002Fa (search)`.\n- **Fields-list breadth advisory** — for Layer 1\u002F2 `ready` rows whose existing\n  `Webapi\u002F\u003Ctable>\u002Ffields` is broader than the AI surface needs (primary key included, relationship\n  Navigation Properties unused by `@odata.bind`, unused columns), flagged `fields-broader-than-ai-mode` so Phase 3 can surface\n  it.\n- **Layer 3 status** per Data Summarization target — `Summarization\u002FData\u002FEnable` and the\n  specific `Summarization\u002Fprompt\u002F\u003Cid>` the code will send.\n\nCompile the integration manifest from the agent's output (one row per candidate, columns:\n`#`, `API`, `Target file`, `Target kind`, `Entity Set`, `$select` \u002F `$expand`, `Source`,\n`Layer 1\u002F2 status`, `Layer 3 status`) — the reference file contains a worked example.\n\n**Delegation decisions** (compute directly from the status columns):\n\n- Run `\u002Fintegrate-webapi`? → True if any row's Layer 1\u002F2 status is `missing`. Send only the\n  missing-status rows in the `tables=` sentinel; don't re-audit settled tables.\n- Run `ai-webapi-settings-architect`? → True if any row's Layer 3 status is `missing`.\n\n**Output**: integration manifest + delegation decisions + existing-infra report +\nfields-broader-than-ai-mode advisory list (if any).\n\n---\n\n## Phase 3: Review AI plan\n\n**Goal**: Present the manifest and confirm which APIs \u002F targets to integrate.\n\nShow the user:\n\n1. The list of APIs and targets found.\n2. For each: which file references it and what the service will do.\n3. The two delegation decisions from Phase 2 (\"Will invoke `\u002Fintegrate-webapi` for [tables]\",\n   \"Will invoke `ai-webapi-settings-architect` for Layer 3\").\n4. Existing-infrastructure notes (CSRF helper reuse, `powerPagesApi.ts`, previous\n   `aiSummaryService.*`).\n\n### Approval cadence (set expectations up-front)\n\nBefore asking the integration question, briefly tell the user how many more decision points\nare coming so the \"one-shot\" run isn't surprising. Count them from the\n[Key decision points](#key-decision-points-wait-for-user) list, subtracting the ones that\ndon't apply for this run:\n\n- **Search-only run**: drop the `\u002Fintegrate-webapi` delegation (Phase 4) and the settings\n  architect (Phase 6) — 4–5 more pauses after this one.\n- **Layer 1\u002F2 already ready**: drop the Phase 4.3 architect approvals.\n- **No list \u002F scope-extends \u002F intent-mismatch rows**: drop the per-target Phase 3 follow-ups.\n- **First-time run with all branches firing**: 7–10 more pauses (web-role choice, per-target\n  list-trigger and scope-confirmation, two integrate-webapi architect plans, the AI\n  settings architect plan, two commit prompts, final deploy).\n\nPhrase it as a heads-up, not a warning — e.g., \"I'll pause for your input ~6 more times\nafter this one (web-role choice, two architect plans, two commit prompts, final deploy).\nCould be a couple more if any list target needs a trigger or scope decision.\"\n\n### The integration question\n\nUse `AskUserQuestion` and **build the option list dynamically** from the Phase 2 manifest — do\nnot hardcode \"Search summary and Data summarization\" when only one category has candidates.\nConstruct the question text from what was found:\n\n- If both categories have candidates: \"I found candidates for Search Summary and Data\n  Summarization. Which should I integrate?\"\n- If only one category with one target: skip \"All of them\" — just confirm the single target\n  (\"Wire Search Summary into `\u003Cpage>`?\").\n\nThe default option list, with rows present only when the corresponding category has candidates:\n\n| Option | When to include |\n|--------|-----------------|\n| All of them (Recommended) | Both categories present |\n| Only Search Summary | Search candidates present AND Data Summarization candidates present |\n| Only Data Summarization | Data Summarization candidates present AND Search candidates present |\n| Let me select specific ones | Always (multi-target runs) |\n| None — cancel | Always |\n\nIf the user chooses \"Let me select specific ones\", follow up with a multi-select question listing\neach row of the integration manifest. When a detail-page candidate was flagged in Phase 2 as a\nrelated-record-discovery target, include it as a dedicated option (in addition to any Data\nSummarization option for the same page) so the user can consciously pick the AI-grounded path\nrather than a hand-rolled OData match — e.g.:\n\n- `Search Summary on CaseDetail.tsx (finds related KB articles via generative AI)`\n- `Search Summary on ProductDetail.tsx (finds related products via generative AI)`\n\nLabel the option with the page name and the outcome it produces, not just \"Search Summary\", so the\nuser sees exactly where the AI surface will appear.\n\n### Per-target follow-up questions\n\nAfter the user confirms targets, ask per-target follow-up questions only when needed:\n\n- **List-trigger** — every list target gets a \"load on open\" vs \"manual button\" question.\n- **Scope confirmation** — only when Phase 2 flagged the row `scope-extends-beyond-existing-fetch`,\n  `needs-definition`, or `intent-mismatch`. Resolve `intent-mismatch` first because the\n  chosen target kind decides which scope question (LIST or SINGLE-RECORD) to ask next.\n\nQuestion text, option lists, and the scope-classification → question mapping live in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fscope-classification.md`. Read it\nwhen any per-target follow-up is required.\n\nThe chosen values flow into the Phase 5 agent-invocation prompt as the **Scope for the summary\ncall** block (`$filter`, `$orderby`, `Scope source`, `Target's existing list fetch`). The\nexisting UI fetch on the target component stays in place unchanged — the summary URL is an\naddition, never a replacement.\n\nIf the user picks a scope that adds new `$expand` targets (e.g., \"include its line items\"),\nre-evaluate the Phase 2 Layer 1\u002F2 delegation decision — the new expansion is a new\nprerequisite (Web API enabled + parent-scope permission on the child table).\n\n### Handling \"None — cancel\"\n\nWhen the user picks `None — cancel`:\n\n1. Mark the remaining tasks as `completed` with a `(skipped — cancelled by user)` suffix in the\n   activeForm so the task list reads cleanly rather than leaving them stuck `pending`.\n2. Jump straight to **Phase 8.1** (record skill usage with `--skillName \"AddAiWebapi\"` and an\n   outcome of `cancelled`) and **Phase 8.2** (present a one-line summary: \"No changes made — you\n   cancelled at the plan-review step\").\n3. Skip Phases 4, 5, 6, 7, and 8.3 entirely. Do **not** invoke `\u002Fintegrate-webapi`,\n   `ai-webapi-integration`, `ai-webapi-settings-architect`, or `\u002Fdeploy-site`. Do **not** commit.\n\n**Output**: user-confirmed integration manifest, or a clean cancellation.\n\n---\n\n## Phase 4: Delegate Layer 1 + Layer 2\n\n**Goal**: Ensure every Web API prerequisite for the AI target tables exists, by delegating to\n`\u002Fcreate-webroles` and `\u002Fintegrate-webapi` (AI-only read mode) instead of writing Layer 1\u002F2 files\ndirectly.\n\n### 4.1 Skip-check\n\nSkip this entire phase when **any** of the following is true:\n\n- Every confirmed target is Search Summary (search has no per-table Web API prerequisites).\n- The Phase 2 delegation decision said \"Run `\u002Fintegrate-webapi`? No\" — all Layer 1\u002F2 prerequisites\n  are already on disk from prior runs.\n- `.powerpages-site` does not exist (the sub-skills both require it).\n\nIn the skip case, proceed to Phase 5 and note this in the final summary.\n\n### 4.2 Create missing web roles (if needed)\n\nFrom Phase 1.6: if no web roles exist in `.powerpages-site\u002Fweb-roles\u002F`, or the roles that exist\ndon't match the site's auth model, ask the user:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| `\u002Fintegrate-webapi` needs at least one web role to attach table permissions to. No matching role was found. Create one now via `\u002Fcreate-webroles`? | Web role | Yes, create via \u002Fcreate-webroles (Recommended), Skip — I'll handle roles separately |\n\nOn **Yes**: invoke the `Skill` tool for `power-pages:create-webroles` with a prompt that\nincludes the caller-suppress sentinel so the sub-skill does not issue its own deploy\nprompts (the orchestrator owns the single end-of-run deploy decision):\n\n> `[CALLED-BY-PARENT-SKILL] caller=add-ai-webapi`\n>\n> Create web roles for this Power Pages SPA site. The parent skill `\u002Fadd-ai-webapi` will\n> later attach AI-only read-mode table permissions to the role(s) you create. Do not issue\n> deploy-now prompts — the orchestrator batches the deploy at the end.\n\nWait for it to complete. Then re-check `.powerpages-site\u002Fweb-roles\u002F` before proceeding to 4.3.\n\nOn **Skip**: this puts the run on a known-broken path — the AI endpoints will return 403 at\nruntime until the user manually creates a web role + table permissions. Don't fall through\nsilently.\n\n\u003C!-- gate: add-ai-webapi:4.2.skip-webrole | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:4.2.skip-webrole):** Explicit acknowledgement before continuing without a web role — skipping leaves Layer 1\u002F2 broken at runtime.\n>\n> **Trigger:** User chose \"Skip\" on the web-role creation offer.\n> **Why we ask:** Proceeding silently means the AI API endpoints return 403 at runtime; surfacing the trade-off lets the user make an informed stop-vs-continue choice.\n> **Cancel leaves:** Nothing — no code written yet.\n\nConfirm the trade-off with a second `AskUserQuestion`:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Without a web role I can't set up table permissions, so the AI endpoints will return 403 at runtime until you configure them yourself. Stop here so you can run `\u002Fcreate-webroles` first, or continue to write the frontend code anyway and let me flag the gap in the final summary? | Continue? | Stop here (Recommended), Continue — write frontend code only and flag the gap in the summary |\n\nOn **Stop here**: end the skill cleanly. Tell the user to run `\u002Fcreate-webroles` (and optionally\n`\u002Fintegrate-webapi`) first, then re-invoke `\u002Fadd-ai-webapi`.\n\nOn **Continue**: skip the rest of Phase 4 (the `\u002Fintegrate-webapi` delegation needs a web role to\nattach permissions to, so running 4.3 would fail) and jump to Phase 5. In the Phase 8 summary,\nflag the Layer 1\u002F2 gap loudly — list the exact files the user still needs to create\n(`Webapi\u002F\u003Ctable>\u002Fenabled`, `Webapi\u002F\u003Ctable>\u002Ffields`, table permissions per target) so the path to\na working runtime is obvious from the final message.\n\n### 4.3 Invoke `\u002Fintegrate-webapi` in AI-only read mode\n\nBuild the sentinel arguments from the Phase 2 manifest:\n\n- `primary=\u003Cprimary table logical name>` (the table whose record \u002F collection is being summarised — e.g., `incident`, `cr4fc_product`, `cr363_workorder`)\n- `tables=\u003Cprimary plus every $expand target, comma-separated>`\n- `expand-targets=\u003Cevery $expand target, comma-separated; empty for pure data-summary targets with no $expand>`\n- `caller=add-ai-webapi`\n\nInvoke the `Skill` tool for `power-pages:integrate-webapi` with a single prompt:\n\n> `[AI-READ-ONLY] mode=ai-read-only primary=\u003Cprimary> tables=\u003Clist> expand-targets=\u003Clist> caller=add-ai-webapi`\n>\n> Configure Layer 1\u002F2 (Web API site settings + table permissions) for the following Power Pages\n> AI summarization targets: \u003Ctable list>. This is a read-only integration — the `\u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F`\n> endpoint never mutates Dataverse. Return when all Web API site settings, table permissions, and the\n> shared `powerPagesApi.ts` client are written to disk.\n>\n> **Per the AI-only read-mode contract** (your SKILL.md Phase 1.6):\n> - **Do not commit.** Skip Phase 4.4 and Phase 6.5 — print the file list you would have\n>   committed so this orchestrator can stage it later. The parent skill batches commits.\n> - **Do not deploy.** Skip Phase 6.1 deploy ask, Phase 7.3 deploy ask, and Phase 7.4\n>   post-deploy notes. Return the Phase 7.2 summary and stop. The parent skill owns the\n>   single end-of-orchestration deploy.\n\n`\u002Fintegrate-webapi` detects the `[AI-READ-ONLY]` sentinel (its Phase 1.6) and runs its full flow\nwith hardened prompts: read-only table permissions, minimal fields list (no PK, only `_\u003Ccol>_value`\nfor lookups), and a read-only service layer. It still presents plan-mode approval prompts to the\nuser for each architect — this skill does not suppress those.\n\nWait for `\u002Fintegrate-webapi` to complete. Re-check the file system:\n\n- `src\u002Fshared\u002FpowerPagesApi.ts` exists\n- For every target table: `Webapi\u002F\u003Ctable>\u002Fenabled` exists, `Webapi\u002F\u003Ctable>\u002Ffields` exists\n- For every target table: at least one table permission with `read: true` exists; Parent-scope\n  permission present for every `$expand` target\n\nIf any prerequisite is still missing, surface this to the user before moving on — something in the\ndelegated flow didn't land (for example, the user declined the architect's plan). Do NOT silently\nfall back to writing Layer 1\u002F2 files here.\n\n**Output**: Layer 1\u002F2 prerequisites are on disk; shared `powerPagesApi.ts` + read-only service\nexists; web roles exist.\n\n---\n\n## Phase 5: Implement Layer 3 code\n\n**Goal**: Create the AI summarization service and wire it into each target's UI.\n\n### 5.1 Invoke the `ai-webapi-integration` agent — first target (sequential)\n\nFor the first target in the confirmed manifest, invoke the agent at\n`${PLUGIN_ROOT}\u002Fagents\u002Fai-webapi-integration.md` via `Task`. The full prompt\ntemplate — every field the agent expects, with notes on which orchestrator phase resolved\neach value — lives in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fagent-invocation-prompt.md`. Read\nthat file, copy the template, replace every `\u003C…>` placeholder with the concrete value for\nthe current target, and pass it via `Task`. The agent does not interpret placeholders;\nsending the literal text `\u003Csearch | data>` will confuse it.\n\nThe first call is sequential because it establishes the shared summarization service file\n(`src\u002Fservices\u002FaiSummaryService.*`) and the CSRF helper that subsequent targets reuse. The\nagent returns a structured file-modification list (see its \"Return value\" section); record\nit for Phase 5.5's per-file commit.\n\n### 5.2 Verify service + CSRF helper exist\n\nBefore spawning more agents, verify:\n\n- The summarization service file exists (default `src\u002Fservices\u002FaiSummaryService.ts`).\n- `getCsrfToken` is defined once in the codebase (or imported from a pre-existing helper).\n\n### 5.3 Invoke the agent for remaining targets — sequentially\n\nPer `plugins\u002Fpower-pages\u002FAGENTS.md`, agent spawning is **sequential**. Invoke\n`ai-webapi-integration` once per remaining target, waiting for each completion before starting the\nnext. Each target only adds an independent exported function, a framework wrapper (if not already\npresent), and wires one UI file — there are no merge conflicts, but the sequential rule keeps\nfailure modes simple.\n\nIf there is only one target total, skip 5.3.\n\n### 5.4 Replace placeholder POSTs\n\nFor any placeholder `InstructionIdentifier` body the Explore agent flagged in Phase 2, the\nsub-agent will have replaced them. Confirm by grepping for `InstructionIdentifier` in the affected\nfiles and verifying each resolved call uses the real entity set and id.\n\n### 5.5 Offer to commit\n\nDon't commit automatically — on iterative runs an unprompted `git commit` here creates a noisy\nseries of commits for what is effectively one set of changes.\n\n\u003C!-- gate: add-ai-webapi:5.5.commit | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:5.5.commit):** Explicit commit decision after Phase 5 summarization-service + UI wiring is complete.\n>\n> **Trigger:** All Phase 5 targets have been wired (service, framework wrapper, UI call sites).\n> **Why we ask:** Auto-committing on every integration run creates noisy one-commit-per-tweak history; letting the user batch is safer.\n> **Cancel leaves:** Nothing — source files written; no `git commit` fired.\n\nUse `AskUserQuestion`:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Commit these Layer 3 integration changes now? | Commit | Yes, commit now (Recommended), Skip — I'll commit later |\n\nOn **Yes**: stage **only the files modified during Phase 5** — the summarization service,\nframework wrapper(s), each wired UI page, and any safe-markdown renderer component the agent\nemitted. The orchestrator already has this list from each `ai-webapi-integration` invocation's\nfile-modification report. Use explicit `git add \u003Cpath>` per file; do **not** use `git add -A` —\nunrelated work-in-progress files in `src\u002F` could otherwise be swept into the commit. Substitute\n`\u003Ctargets>` in the commit message with a short human-readable list (e.g., `CaseDetail and SearchResults`,\nor `3 pages` when there are many):\n\n```powershell\ngit add \u003Ceach file modified by the Phase 5 agents>\ngit commit -m \"Add AI summarization integration for \u003Ctargets>\"\n```\n\nOn **Skip**: proceed without committing. The user will batch the commit themselves at the end.\n\n**Output**: summarization service + framework wrappers + UI call sites created for every confirmed\ntarget.\n\n---\n\n## Phase 6: Configure Layer 3 settings\n\n**Goal**: Register the `Summarization\u002F*` site settings via the `ai-webapi-settings-architect` agent.\n\n### 6.1 Skip-check\n\nSkip this phase when both of the following are true:\n\n- Every confirmed target is Search Summary (search has no per-call `Summarization\u002F*` site settings;\n  see [ai-api-reference.md](references\u002Fai-api-reference.md#1-search-summary-api)).\n- No Data Summarization target was added in Phase 3.\n\nFor search-only, remind the user to enable **Site search with generative AI (preview)** in the\nsite's Copilot workspace after deploy, and proceed to Phase 7.\n\n### 6.2 Confirm deployment prerequisite still holds\n\nPhase 1.5 already gated on `.powerpages-site` existing. Re-check it here as a guard — if it has\ndisappeared between Phase 1 and now (rare, but possible if the user manually cleaned the folder),\nstop and re-run the Phase 1.5 bootstrap-deploy prompt. Do NOT silently fall through into the\narchitect with a missing folder.\n\n### 6.3 Invoke `ai-webapi-settings-architect`\n\nInvoke the agent at `${PLUGIN_ROOT}\u002Fagents\u002Fai-webapi-settings-architect.md` via `Task`:\n\n> \"Analyse this Power Pages SPA site and propose generative-AI summarization site settings.\n> The following Data Summarization targets were integrated in Phase 5: [list each target with its\n> entity set, per-target `InstructionIdentifier` value, and **target kind** (`single-record` or\n> `list`) — the architect needs this to decide on `Summarization\u002FData\u002FContentSizeLimit`].\n> **If any target is `list`, the plan MUST include `Summarization\u002FData\u002FContentSizeLimit=200000`** —\n> the 100k server default silently truncates list content; this is non-negotiable.\n> Check for existing `Summarization\u002F*` settings. Layer 1\n> (`Webapi\u002F\u003Ctable>\u002F*`) and Layer 2 (table permissions) were configured in Phase 4 via\n> `\u002Fintegrate-webapi` in AI-only read mode — verify they are present on disk and cite them as\n> met in your plan's prerequisite table. Propose the AI plan via plan mode, and on approval\n> create the YAMLs with `create-site-setting.js`.\"\n\nWait for the agent to complete. If it reports missing Layer 1\u002F2 prerequisites, something in\nPhase 4 didn't land — read the file system, identify the gap, and surface it to the user rather\nthan attempting to create Layer 1\u002F2 files here.\n\n### 6.4 Offer to commit\n\n\u003C!-- gate: add-ai-webapi:6.4.commit | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:6.4.commit):** Explicit commit decision after `Summarization\u002F*` site settings are created by the architect.\n>\n> **Trigger:** `ai-webapi-settings-architect` has written all `Summarization\u002FData\u002FEnable` + `Summarization\u002Fprompt\u002F\u003Cid>` YAMLs.\n> **Why we ask:** Auto-committing could bundle dirty pre-existing YAMLs into the commit; explicit consent scopes the commit to just the architect's output.\n> **Cancel leaves:** Nothing — YAML files written to disk; no `git commit` fired.\n\nUse `AskUserQuestion`:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Commit the new `Summarization\u002F*` site settings? | Commit | Yes, commit now (Recommended), Skip — I'll commit later |\n\nOn **Yes**: stage **only the files the architect just created** — use the\n`filePath` list returned by `ai-webapi-settings-architect` (or the per-file paths printed by\neach `create-site-setting.js` invocation), not a glob. A glob can sweep in pre-existing\n`Summarization-*` YAMLs that are dirty for unrelated reasons (e.g., a prior partial run, or\na maker-edited prompt) and bundle them into the commit by accident.\n\nUse explicit `git add \u003Cpath>` per file:\n\n```bash\ngit add \u003Ceach Summarization-*.sitesetting.yml the architect just wrote>\ngit commit -m \"Add AI summarization site settings\"\n```\n\nOn **Skip**: proceed without committing.\n\n**Output**: `Summarization\u002FData\u002FEnable`, `Summarization\u002Fprompt\u002F\u003Cid>` settings created.\n\n---\n\n## Phase 7: Verify\n\n**Goal**: Confirm every expected file exists, all POSTs set both required headers, and the project\nbuilds.\n\n> **Preview-feature reminder.** A green build doesn't mean the API will return a summary at\n> runtime — admin-level governance (tenant PowerShell, Copilot Hub) or the site-level maker\n> toggle for Search Summary can still block it. See the Preview-feature note at the top of\n> this skill and the admin-hierarchy checklist in\n> `references\u002Fai-api-reference.md` §1 \"Troubleshooting: AI feature appears disabled\". Tell\n> the user now so the post-deploy test isn't a surprise.\n\n### 7.1 File inventory\n\nFor each confirmed target, confirm:\n\n- **Service file**: `src\u002Fservices\u002FaiSummaryService.ts` (or project-convention equivalent) contains\n  the expected exported function (`fetchSearchSummary` or `fetchDataSummary`; the agent may also\n  emit a thin wrapper such as `fetchCaseSummary` when the user picked the support-case scenario).\n- **Framework wrapper** (non-Astro): React hook in `src\u002Fhooks\u002F`, Vue composable in\n  `src\u002Fcomposables\u002F`, or Angular service in `src\u002Fapp\u002Fservices\u002F`.\n- **UI wiring**: at least one page\u002Fcomponent imports the service or wrapper and calls it.\n- **Shared API client** `src\u002Fshared\u002FpowerPagesApi.ts` exists when any Data Summarization target was in scope.\n- **`Summarization\u002FData\u002FContentSizeLimit` site setting** when any list-summary target was\n  integrated. Grep the source for `fetchListSummary` — if any match exists, confirm\n  `.powerpages-site\u002Fsite-settings\u002FSummarization-Data-ContentSizeLimit.sitesetting.yml` is\n  present with `value: 200000` (or higher). Missing this setting silently caps list summaries at\n  the 100k server default and ships the user truncated input. If it's missing, surface the gap\n  to the user before completing Phase 7 — re-run the architect or create the YAML manually.\n\n### 7.2 Header contract grep\n\n```\nGrep: \"_api\u002Fsearch\u002Fv1\\\\.0\u002Fsummary|_api\u002Fsummarization\u002Fdata\u002Fv1\\\\.0\u002F\" in src\u002F**\u002F*.{ts,tsx,js,jsx,vue,astro}\n```\n\nFor every file that matches, verify the surrounding fetch includes:\n\n- `__RequestVerificationToken` (CSRF token, fetched from `\u002F_layout\u002Ftokenhtml`) — **hard rule**\n- `X-Requested-With: XMLHttpRequest` — **recommended** (the validator warns when it's missing but\n  does not block; it matches `shell.ajaxSafePost` and every other Power Pages POST)\n\nFor data summarization calls, additionally verify (both **hard rules**):\n\n- The URL contains `$select=` (no wildcards)\n- `OData-MaxVersion: 4.0` and `OData-Version: 4.0` headers are set\n\nFix any missing **hard-rule** header before proceeding. Missing CSRF produces 500s; missing\n`$select` or OData headers produces 403\u002F400s. A missing `X-Requested-With` only produces a\nvalidator warning — add it for consistency, but it does not break the run.\n\n### 7.3 Build check\n\n```powershell\ncd \"\u003CPROJECT_ROOT>\"\nnpm run build\n```\n\nFix any type or import errors. Common issues: missing import of the summarization service in a\nwired page; type mismatch between `DataSummaryResponse` and the UI consumer; duplicate\n`getCsrfToken` declarations (if Phase 5 failed to reuse the existing helper).\n\n### 7.4 Present verification results\n\n| Target file | API | Service fn | Wrapper | UI call site | Headers ✓ | `$select` ✓ |\n|-------------|-----|-----------|---------|--------------|-----------|-------------|\n| `src\u002Fpages\u002FSearchResults.tsx` | Search summary | `fetchSearchSummary` | `useSearchSummary` | Yes | Yes | n\u002Fa |\n| `src\u002Fpages\u002FCaseDetail.tsx` | Data summarization | `fetchDataSummary` (optionally wrapped as `fetchCaseSummary`) | `useCaseSummary` | Yes | Yes | Yes |\n| `src\u002Fpages\u002FProductDetail.tsx` | Data summarization | `fetchDataSummary` | `useProductSummary` | Yes | Yes | Yes |\n\n(Same row order and example file paths as the Phase 2 manifest example, so a maintainer reading\nboth tables can trace each row top-to-bottom. Row 2 mirrors the Microsoft-shipped support-case\nrecipe — a Data Summarization call configured for `incidents` with the `case_summary` prompt\nidentifier.)\n\n**Build status:** Pass \u002F Fail (with details).\n\n### 7.5 Final site-integrity gate\n\nAfter all AI integration source changes and the build verification are complete, run:\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Fvalidate-site-integrity.js\" --projectRoot \"\u003CPROJECT_ROOT>\"\n```\n\nFix every blocking error before presenting completion or asking to deploy. Inspect and report\nreview findings in both directions and with expanded content. Rerun this gate after any later\nsource change.\n\n**Output**: all integration files verified; project builds.\n\n---\n\n## Phase 8: Review & Deploy\n\n**Goal**: Record skill usage, present a summary, and offer deployment.\n\n### 8.1 Record skill usage\n\n> Reference: `${PLUGIN_ROOT}\u002Freferences\u002Fskill-tracking-reference.md`\n\nUse `--skillName \"AddAiWebapi\"`.\n\n### 8.2 Present summary\n\n| Step | Status | Details |\n|------|--------|---------|\n| Web roles | Created via \u002Fcreate-webroles \u002F Reused existing \u002F Skipped | role name(s) |\n| Layer 1\u002F2 (Web API settings + permissions) | Created via \u002Fintegrate-webapi \u002F Reused existing \u002F Skipped (search-only) | list of files written |\n| Summarization service | Created \u002F Extended | exported functions, file path |\n| Framework wrappers | Created \u002F Extended | hook\u002Fcomposable\u002Fservice paths |\n| UI call sites | Wired | list of files |\n| Layer 3 (Summarization\u002F* settings) | Created \u002F Already existed \u002F Skipped | `Summarization\u002FData\u002FEnable`, one per prompt |\n\n### 8.3 Ask to deploy\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Everything is ready. Deploy the site so the summarization APIs become live? | Deploy | Yes, deploy now (Recommended), No, I'll deploy later |\n\n**Yes**: invoke `\u002Fdeploy-site`.\n**No**: acknowledge. Remind that the API calls will not work until the site is deployed with the\nnew settings and permissions.\n\n### 8.4 Post-deploy notes\n\nSurface these to the user at the end of the run:\n\n- **Search Summary toggle** — for any Search Summary integration, remind the user to flip\n  **Set up workspace → Copilot → Site search (preview) → \"Enable Site search with generative\n  AI (preview)\"**. Without it, the endpoint returns the disabled envelope and the UI renders\n  the remediation card instead of a summary.\n- **Test recipe** — for Data Summarization, open a record-detail or list page, trigger the\n  summary, confirm 200 + rendered text, then click a recommendation chip and confirm the\n  follow-up sends `RecommendationConfig`. For Search Summary, perform a search and confirm\n  the summary renders above keyword hits with citation anchors pointing at the SPA route\n  (not `\u002Fpage-not-found\u002F`). The `90041005` \"nothing to summarize\" branch is normal for the\n  Microsoft-shipped support-case recipe on a freshly-created case with no comments — test\n  with a record that has substantive content in every selected \u002F expanded column.\n- **When the disabled-state card or `90041001` shows up** — walk the admin-hierarchy\n  checklist in `references\u002Fai-api-reference.md` §1 \"Troubleshooting: AI feature appears\n  disabled (admin hierarchy)\". Retry doesn't help; an admin or maker has to change\n  governance \u002F flip the site toggle.\n- **403 on any summarization call is always a Layer 1\u002F2 issue** (column casing in\n  `Webapi\u002F\u003Ctable>\u002Ffields`, or missing `read: true` table permission) — re-run\n  `\u002Fintegrate-webapi` in AI-only read mode rather than hand-editing YAML.\n- **Full error-code reference** (`90041001` … `90041006`) is in\n  `references\u002Fai-api-reference.md` §2 \"Error codes\". Open it when the user reports a 400.\n- **Column permission profiles can silently hide content.** If a summary has obvious\n  omissions, check Dataverse column permission profiles on the web role before suspecting\n  the prompt or fields list.\n\n**Output**: summary presented, deployment completed or deferred, post-deploy guidance given.\n\n---\n\n## Important Notes\n\n### Throughout all phases\n\n- **Use TaskCreate\u002FTaskUpdate** to track progress at every phase.\n- **Ask for user confirmation** at key decision points (list below).\n- **Sequential agent spawning** — per the \"Agent spawning\" rule in `plugins\u002Fpower-pages\u002FAGENTS.md`. Never spawn `ai-webapi-integration` in parallel across targets (every target extends the same `aiSummaryService.*` file, so parallel runs would conflict).\n- **Commit at milestones** — after implementation (Phase 5) and after settings creation (Phase 6).\n- **Never use an OData wrapper for summarization fetches** — raw `fetch` only.\n- **Never write Layer 1\u002F2 files directly** — always delegate to `\u002Fintegrate-webapi` \u002F `\u002Fcreate-webroles`. This skill is Layer 3.\n\n### Key decision points (wait for user)\n\nThe list below is the conservative upper bound — many runs hit fewer prompts because skip\nchecks (search-only run, Layer 1\u002F2 ready, no list\u002Fintent-mismatch targets) eliminate whole\nbranches. Realistic worst case for a multi-target first-time run is ~10 prompts; a clean\nre-entry tweak is just 1 prompt (the Phase 1.0 mode question).\n\n1. **At Phase 1.0 (re-entry detection)**: tweak existing surface, add a new surface, or\n   review what's already wired. Only fires when a previous `\u002Fadd-ai-webapi` run left a\n   service file or `Summarization\u002F*` settings on disk.\n2. **At Phase 1.5**: bootstrap deploy or stop (if `.powerpages-site` is missing).\n3. **After Phase 3 (main)**: confirm which APIs \u002F targets to integrate.\n4. **Phase 3 per-target follow-ups (variable count)**: list-trigger choice (one per list\n   target), and scope-confirmation (one per `scope-extends-beyond-existing-fetch`,\n   `needs-definition`, or `intent-mismatch` row). Question text and option lists live in\n   `references\u002Fscope-classification.md`.\n5. **At Phase 4.2**: create missing web role via `\u002Fcreate-webroles` (if needed). The\n   sub-skill is invoked with the caller-suppress sentinel — its own deploy prompts don't\n   fire.\n6. **At Phase 4.2 (Skip path only)**: confirm continuing despite known broken-runtime risk.\n7. **Inside the Phase 4.3 `\u002Fintegrate-webapi` delegation**: approve its\n   `table-permissions-architect` plan and its `webapi-settings-architect` plan (each\n   architect owns its own plan-mode prompt; the sub-skill is in AI-only read mode so its\n   commit and deploy prompts are suppressed).\n8. **At Phase 5.5**: commit the integration changes now or later.\n9. **Inside the Phase 6.3 `ai-webapi-settings-architect` call**: approve its plan.\n10. **At Phase 6.4**: commit the new settings now or later.\n11. **At Phase 8.3**: deploy now or later.\n\n### List-summary use case playbook\n\nWhen the target is a LIST of records (not a single record), the defaults for a single-record\nCopilot card are the wrong defaults — collection endpoint, tabular-insight prompt,\n`ContentSizeLimit=200000`, `normalizeSummaryString` + safe-markdown renderer, etc.\n\nThe full 10-rule playbook (collection endpoint, scope mirroring, prompt size, nav-property\ncasing, mandatory `ContentSizeLimit`) lives in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fai-api-reference.md` §2 \"List-summary\nplaybook\". Read that section before any list-summary target reaches Phase 5 — the Phase 5\nagent and the Phase 6 settings architect both reference the same playbook.\n\n### Progress tracking\n\nBefore starting Phase 1, create a task list with all phases using `TaskCreate`:\n\n| Task subject | activeForm | Description |\n|-------------|------------|-------------|\n| Check site is ready | Checking site prerequisites | Locate project root, detect framework, check data model, deployment status, web-role inventory |\n| Find where AI summaries fit | Scanning code for AI summary opportunities | Use Explore agent to find search\u002Fdata\u002Fcase candidates, existing infra, and delegation decisions |\n| Confirm what to add | Confirming the AI summary plan | Present manifest and confirm which APIs and targets to integrate |\n| Set up data access for AI | Setting up Web API access and permissions | Invoke \u002Fcreate-webroles if needed, then \u002Fintegrate-webapi in AI-only read mode (or skip for search-only) |\n| Add AI summary code | Adding AI summary code to your pages | Sequential ai-webapi-integration calls: first target creates shared service + CSRF helper, remaining targets extend it |\n| Register AI prompts | Registering AI prompt settings | Invoke ai-webapi-settings-architect to create Summarization\u002F* settings |\n| Verify everything | Verifying file inventory, headers, and the build | Confirm service file, wrappers, UI wiring, header contract, run project build |\n| Review and deploy | Reviewing summary and deploying | Record skill usage, present summary, offer \u002Fdeploy-site, give post-deploy guidance |\n\nMark each task `in_progress` when starting and `completed` when done via `TaskUpdate`.\n\n---\n\n**Begin with Phase 1: Verify Site Exists**\n","> **Plugin check**: Run `node \"${PLUGIN_ROOT}\u002Fscripts\u002Fcheck-version.js\"` — if it outputs a message, show it to the user before proceeding.\n\n# Add AI Web API\n\n> **Note**\n>\n> AI summarization APIs are a preview feature. Preview features aren't meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.\n\n**Surface this note to the user verbatim** during Phase 1 and again in the Phase 8 summary —\ncopy the exact `**Note**` block above (including its wording about \"available before an official\nrelease so that customers can get early access and provide feedback\"). Do not paraphrase it into\nyour own \"Preview-feature note: ...\" sentence; the wording matches the Microsoft Learn preview\ndisclaimer and rephrasing it loses that fidelity.\n\nIntegrate Power Pages generative-AI summarization APIs into a SPA site. This skill focuses on the AI layer (Layer 3): the summarization service code and the `Summarization\u002F*` site settings. The underlying Web API prerequisites — `Webapi\u002F\u003Ctable>\u002Fenabled`, `Webapi\u002F\u003Ctable>\u002Ffields`, table permissions, and web roles — are **delegated** to `\u002Fintegrate-webapi` and `\u002Fcreate-webroles` so there is a single source of truth for every layer.\n\n## The two APIs covered\n\n| # | API | URL | Body | Response |\n|---|-----|-----|------|----------|\n| 1 | **Search Summary** | `POST \u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` | `{ userQuery }` | `{ Summary, Citations }` |\n| 2 | **Data Summarization** | `POST \u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F\u003CentitySet>(\u003Cid>)?$select=...&$expand=...` | `{ InstructionIdentifier }` or `{ RecommendationConfig }` | `{ Summary, Recommendations }` |\n\n> **Example: Microsoft-shipped Copilot summary on a support-case page.** Data Summarization can be\n> called with any combination of entity set, columns, and prompt — but Microsoft documents and\n> ships one specific configuration for the standard `incident` table:\n> `POST \u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002Fincidents(\u003CcaseId>)?$select=description,title&$expand=incident_adx_portalcomments($select=description)`\n> with body `{ \"InstructionIdentifier\": \"Summarization\u002Fprompt\u002Fcase_summary\" }`. This is sometimes\n> called the \"Case-page Copilot preset\" in Microsoft Learn. Treat it as one possible Data\n> Summarization recipe — useful when the user explicitly wants to mirror the Microsoft sample —\n> not as an automatic recommendation. A custom case-like table (`cr363_servicerequest`,\n> `adx_case`), or the standard incident table summarised on different facets (priority, owner,\n> SLA timer), is just a regular Data Summarization call with maker-defined values.\n\n> Reference: `${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fai-api-reference.md` — canonical\n> API shapes, required headers, site-setting names, error codes, and the documented support-case\n> example. Read this at the start of the workflow; fetch the Microsoft Learn source pages with\n> `mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch` if the user asks for the latest.\n\n> **Admin governance hierarchy**: both APIs are gated by a **three-level admin\n> hierarchy** — tenant PowerShell setting (`enableGenerativeAIFeaturesForSiteUsers`), Copilot Hub\n> environment\u002Fsite governance, and the site-level maker toggle (for Search Summary: Set up\n> workspace → Copilot → Site search (preview) → Enable Site search with generative AI (preview)).\n> **Each level overrides the one below it**, so \"the maker toggle is on but the API still says\n> disabled\" is a real scenario — admin-level governance wins.\n>\n> The two endpoints surface disablement differently:\n>\n> - **Search Summary** → HTTP **200** with an embedded envelope `{ Code: 400, Message: \"Gen AI\n>   Search is disabled.\" }`. The generated `fetchSearchSummary` detects this and throws\n>   `SearchSummaryApiError`; the UI renders a remediation card.\n> - **Data Summarization** → HTTP **400** with `error.code = 90041001` (admin-level disabled) or\n>   `90041003` (per-site `Summarization\u002FData\u002FEnable=false`).\n>\n> Full troubleshooting checklist (tenant → environment → site, plus runtime version, Bing\n> dependency, and cross-region data movement) lives in\n> `references\u002Fai-api-reference.md` §1 \"Troubleshooting: AI feature appears disabled (admin\n> hierarchy)\" — point users there when either disablement shape surfaces. Mention this governance\n> hierarchy explicitly to the user before Phase 7, and again in the Phase 8 summary.\n\n> **Built-in search control vs. custom code path**: if the site uses the Microsoft-shipped Power\n> Pages search **control** and only wants AI-summarised search results on that page, they don't\n> need this skill — just the Copilot workspace toggle and the `Search\u002FSummary\u002FTitle` content\n> snippet. This skill is for sites that build their own search UI or need to call\n> `\u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` from custom code. Confirm which path the user is on in Phase 1.\n\n## Core principles\n\n- **Layer 3 only, delegate the rest.** Web API site settings, table permissions, and web roles all belong to `\u002Fintegrate-webapi` and `\u002Fcreate-webroles`. This skill creates the summarization service code and the `Summarization\u002F*` site settings — nothing else.\n- **Sequential agent spawning.** Per `plugins\u002Fpower-pages\u002FAGENTS.md`, spawn the `ai-webapi-integration` agent sequentially per target (never in parallel). The first call establishes the shared summarization service file and CSRF helper; subsequent calls extend it. `ai-webapi-settings-architect` runs alone, after all code integrations land.\n- **Raw `fetch` + CSRF.** Every summarization request attaches `__RequestVerificationToken` (from `\u002F_layout\u002Ftokenhtml`) and `X-Requested-With: XMLHttpRequest`. Never route through an OData wrapper.\n- **Skip `\u002Fintegrate-webapi` when it's not needed.** If every confirmed target is Search Summary (which has no per-table Web API prerequisites), or every Layer 1\u002F2 prerequisite already exists on disk, the skill goes straight from Phase 3 to Phase 5.\n- **Use TaskCreate\u002FTaskUpdate** — create the todo list upfront with all phases before starting.\n- **Preserve site integrity.** Before adding or tweaking an AI surface, read `${PLUGIN_ROOT}\u002Freferences\u002Fsite-modification-integrity.md`; localization covers labels, loading, empty, error, citation, recommendation, and remediation states, and the UI must remain bidirectional and expansion-safe.\n\n> **Prerequisites:**\n>\n> - An existing Power Pages SPA site created via `\u002Fcreate-site`\n> - A Dataverse data model (tables + columns) set up via `\u002Fsetup-datamodel` or manually — for any\n>   Data Summarization target\n> - The site must have been deployed at least once (`.powerpages-site` folder must exist) for the\n>   settings phase\n\n**Initial request:** $ARGUMENTS\n\n---\n\n## Workflow\n\n(Phase headings below the workflow keep the technical \"Layer 1+2 \u002F Layer 3\" names because they\ndescribe the runtime layering and are what maintainers grep for. The titles here mirror the\nuser-facing task list.)\n\n1. **Check site is ready** — locate project, detect framework, check data model, deployment status, and web-role presence.\n2. **Find where AI summaries fit** — scan code for search \u002F data summarization candidates.\n3. **Confirm what to add** — review the manifest and pick which APIs \u002F targets to integrate.\n4. **Set up data access for AI** — invoke `\u002Fcreate-webroles` if needed, then invoke `\u002Fintegrate-webapi` in AI-only read mode for data\u002Fcase targets. Skip entirely for search-only or when prerequisites already exist.\n5. **Add AI summary code** — invoke the `ai-webapi-integration` agent sequentially per target.\n6. **Register AI prompts** — invoke the `ai-webapi-settings-architect` agent.\n7. **Verify everything** — header-contract grep, `$select` grep, `npm run build`, validator script.\n8. **Review and deploy** — record skill usage, summarise, offer `\u002Fdeploy-site`.\n\n---\n\n## Iteration mode (after first run)\n\nThis skill is a **one-shot setup skill** — Phases 1–8 run end-to-end the first time the user asks\nto integrate a summarization API. Once an AI surface is in place (service file, framework wrapper,\nUI call site, and `Summarization\u002F*` settings all exist), follow-up requests to tweak the rendered\nUI (colours, spacing, copy, moving a button, a different empty-state message, wiring a second\nrecommendation into the hook, etc.) are **not** a reason to re-enter this skill mentally and run\nevery phase again. Doing so triggers a full `pac pages upload-code-site` and a chain of\n`git commit`s for each tweak, which is exactly the noisy cadence the Phase 5.5 \u002F 6.4 prompts above\nare there to avoid.\n\nWhen the user asks for follow-up UI changes to an already-integrated AI surface:\n\n- **Edit the file(s) and run `npm run build`** locally to verify the tweak compiles. That is the\n  whole validation loop for a UI change.\n- **Do NOT automatically run `pac pages upload-code-site`.** Uploading should happen once, at the\n  end of the session, when the user has finished tweaking.\n- **Do NOT automatically `git commit`.** Let the user batch related tweaks into a single commit.\n- **Batch the deployment and commit into a single end-of-session prompt** once the user signals\n  they're done (or when you've completed the last requested change).\n\n\u003C!-- gate: add-ai-webapi:iter.deploy-commit | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:iter.deploy-commit):** End-of-iteration batched deploy + commit prompt — avoids a noisy per-tweak upload\u002Fcommit cadence.\n>\n> **Trigger:** User signals they're done with UI tweaks for the session.\n> **Why we ask:** Auto-deploying or committing after every small edit produces one `git commit` + one `pac pages upload-code-site` per tweak; batching keeps history readable and avoids redundant deploys.\n> **Cancel leaves:** Nothing — source files already edited; no deploy or commit fired.\n\n  Use `AskUserQuestion`:\n\n  | Question | Header | Options |\n  |----------|--------|---------|\n  | All the UI tweaks look good. Deploy the site and commit the changes now? | Deploy & commit | Yes, deploy and commit (Recommended), Just commit — I'll deploy later, Just deploy — I'll commit later, Neither — I'll handle both myself |\n\nRe-enter the full skill flow only when the user is adding a **new** AI surface (a new page, a new\ntable, a second API). If you're unsure whether a request is a tweak or a new surface, ask.\n\n---\n\n## Phase 1: Verify Site Exists\n\n**Goal**: Locate the Power Pages project root and confirm prerequisites.\n\n### 1.0 Detect iteration mode (before anything else)\n\nRe-entry detection comes first because the rest of the skill assumes a first-time setup.\nCapture two signals about the project state:\n\n1. **Service signal**: a summarization service exists — `src\u002Fservices\u002FaiSummaryService.*`, or any\n   source file under `src\u002F` that contains `\u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` or\n   `\u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F`. When the signal is present, also note which API surface(s)\n   the service code references — search-only, data-only, or both. This sub-classification matters\n   below.\n2. **Settings signal**: at least one Layer 3 site setting exists in\n   `.powerpages-site\u002Fsite-settings\u002FSummarization-*.sitesetting.yml`.\n\nThen route on the combination:\n\n- **Both signals present** → re-entry. A previous `\u002Fadd-ai-webapi` run completed end-to-end. Show\n  the iteration-mode prompt below.\n- **Service signal present and the existing service code is search-only** (it references\n  `\u002F_api\u002Fsearch\u002Fv1.0\u002Fsummary` but **not** `\u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F`) → re-entry. Search-only\n  sites legitimately have no `Summarization\u002F*` settings (Search Summary uses the workspace toggle,\n  not per-call settings), so the absence of the settings signal is the steady state, not a\n  failed run. Show the iteration-mode prompt below.\n- **Service signal present and the existing service code includes Data Summarization** but the\n  settings signal is absent → in-flight first run (a previous attempt failed before Phase 6\n  landed). Continue with the full flow without prompting.\n- **Neither signal present** → first-time run. Continue with Phase 1.1.\n\nWhen you reach the iteration-mode branch, ask:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| It looks like an AI summary surface is already wired into this site. Is this request a tweak to the existing one, or are you adding a brand-new surface (new page, new table, second API)? | Mode | Tweak the existing surface (Recommended for visual\u002Fcopy edits), Add a new surface (run the full skill again), Not sure — show me what's already wired |\n\n- **Tweak the existing surface**: stop running this skill. Switch into the workflow described in\n  the [Iteration mode](#iteration-mode-after-first-run) section above — Edit + `npm run build`,\n  no auto upload-code-site, no auto commit, batched end-of-session prompt for deploy + commit.\n- **Add a new surface**: continue with Phase 1.1 (full flow). The downstream phases will detect\n  existing infrastructure (CSRF helper, summarization service, settings) and extend rather than\n  duplicate.\n- **Not sure — show me what's already wired**: list the existing service file(s), wired UI\n  components, and `Summarization\u002F*` settings, then re-ask the same question.\n\n### 1.1 Create todo list\n\nCreate all 8 phase tasks upfront via `TaskCreate` — see [Progress Tracking](#progress-tracking).\n\n### 1.2 Locate project\n\nLook for `powerpages.config.json` in the current directory or immediate subdirectories.\n\n**If not found**: tell the user to create a site first with `\u002Fcreate-site`.\n\n### 1.3 Detect framework\n\nRead `package.json` and detect React \u002F Vue \u002F Angular \u002F Astro. See\n`${PLUGIN_ROOT}\u002Freferences\u002Fframework-conventions.md`.\n\n### 1.4 Check for data model\n\nLook for `.datamodel-manifest.json`. If found, read it — tables listed here are candidates for the\nData Summarization API. The standard `incident` table is a candidate like any other; do not\ntreat it specially.\n\n### 1.5 Check deployment status — hard prerequisite\n\nLook for `.powerpages-site`. Phase 4 (`\u002Fintegrate-webapi`) and Phase 6 (`ai-webapi-settings-architect`)\nboth require this folder to exist. Deferring the deploy until later is **not** a viable workaround:\nonce Phase 5 has written the AI-calling service code, deploying a site whose Layer 1\u002F2\u002F3 settings\naren't yet on disk publishes runtime-broken code (every summarization call 403\u002F500s until a second\ndeploy lands). The cleanest sequence is to deploy the **clean scaffold** now, before any AI code\nexists.\n\n**If `.powerpages-site` does NOT exist:**\n\n| Question | Header | Options |\n|----------|--------|---------|\n| `.powerpages-site` was not found. The AI summary skill needs the site deployed at least once before configuring permissions and settings. Deploy the clean scaffold now (no AI code yet — keeps the intermediate state safe), or stop and run `\u002Fdeploy-site` yourself first? | Bootstrap deploy | Yes, deploy the scaffold now (Recommended), Stop — I'll deploy first then re-run \u002Fadd-ai-webapi |\n\nOn **Yes**: invoke the `Skill` tool for `power-pages:deploy-site` and wait for completion. Then\nre-check `.powerpages-site` exists before proceeding. **If it is still absent** after the\nsub-skill returns (deploy failed mid-flow, the user cancelled it, or an upload completed but the\nlocal folder wasn't created), stop here with a clear message — surface the deploy-site outcome\nverbatim so the user can debug it, and tell them to re-run `\u002Fdeploy-site` followed by\n`\u002Fadd-ai-webapi`. Do NOT silently fall through to Phase 2; the downstream sub-skills require this\nfolder.\n\nOn **Stop**: end the skill with a clear next-step message (\"Run `\u002Fdeploy-site`, then re-invoke\n`\u002Fadd-ai-webapi` to continue\"). Do NOT continue to Phase 2 — the downstream sub-skills can't run.\n\n### 1.6 Check web roles\n\nLook for `.powerpages-site\u002Fweb-roles\u002F*.yml`. Record whether any roles exist — the Phase 4\ndelegation needs at least one role before `\u002Fintegrate-webapi` can create table permissions.\n\n**Output**: confirmed project root, framework, data-model availability, deployment status, web-role inventory.\n\n---\n\n## Phase 2: Explore AI integration points\n\n**Goal**: Find every candidate for each of the two APIs — scoped to AI only.\n\nThe full Explore-agent prompt body, manifest shape, and delegation-decision rules live in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fexplore-prompt.md`. Read that file\nfirst, then invoke the **Explore agent** (via `Task` with `subagent_type: \"Explore\"`,\nthoroughness `medium`) and pass the prompt body verbatim.\n\nWhat the Explore agent reports back (summary — see the reference for the exact prompt):\n\n- **Reserved-slot markers** (`POWERPAGES:AI-SLOT kind=\u003Cpick>`) — authoritative placement hints\n  planted by `\u002Fcreate-site`; orphan markers are flagged for Phase 3 to resolve.\n- **Search Summary candidates** including related-record-discovery targets on detail pages\n  (\"suggested KB articles\", \"similar cases\").\n- **Data Summarization candidates** classified `single-record` \u002F `list` \u002F `intent-mismatch`,\n  each with the existing fetch's OData query and a scope classification\n  (`matches-existing-fetch` \u002F `scope-extends-beyond-existing-fetch` \u002F `needs-definition` \u002F\n  `intent-mismatch`).\n- **Existing infrastructure** — CSRF helper, `powerPagesApi.ts`, prior `aiSummaryService.*`.\n- **Layer 1\u002F2 status** per Data Summarization target plus every `$expand` target —\n  `ready` \u002F `missing` \u002F `n\u002Fa (search)`.\n- **Fields-list breadth advisory** — for Layer 1\u002F2 `ready` rows whose existing\n  `Webapi\u002F\u003Ctable>\u002Ffields` is broader than the AI surface needs (primary key included, relationship\n  Navigation Properties unused by `@odata.bind`, unused columns), flagged `fields-broader-than-ai-mode` so Phase 3 can surface\n  it.\n- **Layer 3 status** per Data Summarization target — `Summarization\u002FData\u002FEnable` and the\n  specific `Summarization\u002Fprompt\u002F\u003Cid>` the code will send.\n\nCompile the integration manifest from the agent's output (one row per candidate, columns:\n`#`, `API`, `Target file`, `Target kind`, `Entity Set`, `$select` \u002F `$expand`, `Source`,\n`Layer 1\u002F2 status`, `Layer 3 status`) — the reference file contains a worked example.\n\n**Delegation decisions** (compute directly from the status columns):\n\n- Run `\u002Fintegrate-webapi`? → True if any row's Layer 1\u002F2 status is `missing`. Send only the\n  missing-status rows in the `tables=` sentinel; don't re-audit settled tables.\n- Run `ai-webapi-settings-architect`? → True if any row's Layer 3 status is `missing`.\n\n**Output**: integration manifest + delegation decisions + existing-infra report +\nfields-broader-than-ai-mode advisory list (if any).\n\n---\n\n## Phase 3: Review AI plan\n\n**Goal**: Present the manifest and confirm which APIs \u002F targets to integrate.\n\nShow the user:\n\n1. The list of APIs and targets found.\n2. For each: which file references it and what the service will do.\n3. The two delegation decisions from Phase 2 (\"Will invoke `\u002Fintegrate-webapi` for [tables]\",\n   \"Will invoke `ai-webapi-settings-architect` for Layer 3\").\n4. Existing-infrastructure notes (CSRF helper reuse, `powerPagesApi.ts`, previous\n   `aiSummaryService.*`).\n\n### Approval cadence (set expectations up-front)\n\nBefore asking the integration question, briefly tell the user how many more decision points\nare coming so the \"one-shot\" run isn't surprising. Count them from the\n[Key decision points](#key-decision-points-wait-for-user) list, subtracting the ones that\ndon't apply for this run:\n\n- **Search-only run**: drop the `\u002Fintegrate-webapi` delegation (Phase 4) and the settings\n  architect (Phase 6) — 4–5 more pauses after this one.\n- **Layer 1\u002F2 already ready**: drop the Phase 4.3 architect approvals.\n- **No list \u002F scope-extends \u002F intent-mismatch rows**: drop the per-target Phase 3 follow-ups.\n- **First-time run with all branches firing**: 7–10 more pauses (web-role choice, per-target\n  list-trigger and scope-confirmation, two integrate-webapi architect plans, the AI\n  settings architect plan, two commit prompts, final deploy).\n\nPhrase it as a heads-up, not a warning — e.g., \"I'll pause for your input ~6 more times\nafter this one (web-role choice, two architect plans, two commit prompts, final deploy).\nCould be a couple more if any list target needs a trigger or scope decision.\"\n\n### The integration question\n\nUse `AskUserQuestion` and **build the option list dynamically** from the Phase 2 manifest — do\nnot hardcode \"Search summary and Data summarization\" when only one category has candidates.\nConstruct the question text from what was found:\n\n- If both categories have candidates: \"I found candidates for Search Summary and Data\n  Summarization. Which should I integrate?\"\n- If only one category with one target: skip \"All of them\" — just confirm the single target\n  (\"Wire Search Summary into `\u003Cpage>`?\").\n\nThe default option list, with rows present only when the corresponding category has candidates:\n\n| Option | When to include |\n|--------|-----------------|\n| All of them (Recommended) | Both categories present |\n| Only Search Summary | Search candidates present AND Data Summarization candidates present |\n| Only Data Summarization | Data Summarization candidates present AND Search candidates present |\n| Let me select specific ones | Always (multi-target runs) |\n| None — cancel | Always |\n\nIf the user chooses \"Let me select specific ones\", follow up with a multi-select question listing\neach row of the integration manifest. When a detail-page candidate was flagged in Phase 2 as a\nrelated-record-discovery target, include it as a dedicated option (in addition to any Data\nSummarization option for the same page) so the user can consciously pick the AI-grounded path\nrather than a hand-rolled OData match — e.g.:\n\n- `Search Summary on CaseDetail.tsx (finds related KB articles via generative AI)`\n- `Search Summary on ProductDetail.tsx (finds related products via generative AI)`\n\nLabel the option with the page name and the outcome it produces, not just \"Search Summary\", so the\nuser sees exactly where the AI surface will appear.\n\n### Per-target follow-up questions\n\nAfter the user confirms targets, ask per-target follow-up questions only when needed:\n\n- **List-trigger** — every list target gets a \"load on open\" vs \"manual button\" question.\n- **Scope confirmation** — only when Phase 2 flagged the row `scope-extends-beyond-existing-fetch`,\n  `needs-definition`, or `intent-mismatch`. Resolve `intent-mismatch` first because the\n  chosen target kind decides which scope question (LIST or SINGLE-RECORD) to ask next.\n\nQuestion text, option lists, and the scope-classification → question mapping live in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fscope-classification.md`. Read it\nwhen any per-target follow-up is required.\n\nThe chosen values flow into the Phase 5 agent-invocation prompt as the **Scope for the summary\ncall** block (`$filter`, `$orderby`, `Scope source`, `Target's existing list fetch`). The\nexisting UI fetch on the target component stays in place unchanged — the summary URL is an\naddition, never a replacement.\n\nIf the user picks a scope that adds new `$expand` targets (e.g., \"include its line items\"),\nre-evaluate the Phase 2 Layer 1\u002F2 delegation decision — the new expansion is a new\nprerequisite (Web API enabled + parent-scope permission on the child table).\n\n### Handling \"None — cancel\"\n\nWhen the user picks `None — cancel`:\n\n1. Mark the remaining tasks as `completed` with a `(skipped — cancelled by user)` suffix in the\n   activeForm so the task list reads cleanly rather than leaving them stuck `pending`.\n2. Jump straight to **Phase 8.1** (record skill usage with `--skillName \"AddAiWebapi\"` and an\n   outcome of `cancelled`) and **Phase 8.2** (present a one-line summary: \"No changes made — you\n   cancelled at the plan-review step\").\n3. Skip Phases 4, 5, 6, 7, and 8.3 entirely. Do **not** invoke `\u002Fintegrate-webapi`,\n   `ai-webapi-integration`, `ai-webapi-settings-architect`, or `\u002Fdeploy-site`. Do **not** commit.\n\n**Output**: user-confirmed integration manifest, or a clean cancellation.\n\n---\n\n## Phase 4: Delegate Layer 1 + Layer 2\n\n**Goal**: Ensure every Web API prerequisite for the AI target tables exists, by delegating to\n`\u002Fcreate-webroles` and `\u002Fintegrate-webapi` (AI-only read mode) instead of writing Layer 1\u002F2 files\ndirectly.\n\n### 4.1 Skip-check\n\nSkip this entire phase when **any** of the following is true:\n\n- Every confirmed target is Search Summary (search has no per-table Web API prerequisites).\n- The Phase 2 delegation decision said \"Run `\u002Fintegrate-webapi`? No\" — all Layer 1\u002F2 prerequisites\n  are already on disk from prior runs.\n- `.powerpages-site` does not exist (the sub-skills both require it).\n\nIn the skip case, proceed to Phase 5 and note this in the final summary.\n\n### 4.2 Create missing web roles (if needed)\n\nFrom Phase 1.6: if no web roles exist in `.powerpages-site\u002Fweb-roles\u002F`, or the roles that exist\ndon't match the site's auth model, ask the user:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| `\u002Fintegrate-webapi` needs at least one web role to attach table permissions to. No matching role was found. Create one now via `\u002Fcreate-webroles`? | Web role | Yes, create via \u002Fcreate-webroles (Recommended), Skip — I'll handle roles separately |\n\nOn **Yes**: invoke the `Skill` tool for `power-pages:create-webroles` with a prompt that\nincludes the caller-suppress sentinel so the sub-skill does not issue its own deploy\nprompts (the orchestrator owns the single end-of-run deploy decision):\n\n> `[CALLED-BY-PARENT-SKILL] caller=add-ai-webapi`\n>\n> Create web roles for this Power Pages SPA site. The parent skill `\u002Fadd-ai-webapi` will\n> later attach AI-only read-mode table permissions to the role(s) you create. Do not issue\n> deploy-now prompts — the orchestrator batches the deploy at the end.\n\nWait for it to complete. Then re-check `.powerpages-site\u002Fweb-roles\u002F` before proceeding to 4.3.\n\nOn **Skip**: this puts the run on a known-broken path — the AI endpoints will return 403 at\nruntime until the user manually creates a web role + table permissions. Don't fall through\nsilently.\n\n\u003C!-- gate: add-ai-webapi:4.2.skip-webrole | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:4.2.skip-webrole):** Explicit acknowledgement before continuing without a web role — skipping leaves Layer 1\u002F2 broken at runtime.\n>\n> **Trigger:** User chose \"Skip\" on the web-role creation offer.\n> **Why we ask:** Proceeding silently means the AI API endpoints return 403 at runtime; surfacing the trade-off lets the user make an informed stop-vs-continue choice.\n> **Cancel leaves:** Nothing — no code written yet.\n\nConfirm the trade-off with a second `AskUserQuestion`:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Without a web role I can't set up table permissions, so the AI endpoints will return 403 at runtime until you configure them yourself. Stop here so you can run `\u002Fcreate-webroles` first, or continue to write the frontend code anyway and let me flag the gap in the final summary? | Continue? | Stop here (Recommended), Continue — write frontend code only and flag the gap in the summary |\n\nOn **Stop here**: end the skill cleanly. Tell the user to run `\u002Fcreate-webroles` (and optionally\n`\u002Fintegrate-webapi`) first, then re-invoke `\u002Fadd-ai-webapi`.\n\nOn **Continue**: skip the rest of Phase 4 (the `\u002Fintegrate-webapi` delegation needs a web role to\nattach permissions to, so running 4.3 would fail) and jump to Phase 5. In the Phase 8 summary,\nflag the Layer 1\u002F2 gap loudly — list the exact files the user still needs to create\n(`Webapi\u002F\u003Ctable>\u002Fenabled`, `Webapi\u002F\u003Ctable>\u002Ffields`, table permissions per target) so the path to\na working runtime is obvious from the final message.\n\n### 4.3 Invoke `\u002Fintegrate-webapi` in AI-only read mode\n\nBuild the sentinel arguments from the Phase 2 manifest:\n\n- `primary=\u003Cprimary table logical name>` (the table whose record \u002F collection is being summarised — e.g., `incident`, `cr4fc_product`, `cr363_workorder`)\n- `tables=\u003Cprimary plus every $expand target, comma-separated>`\n- `expand-targets=\u003Cevery $expand target, comma-separated; empty for pure data-summary targets with no $expand>`\n- `caller=add-ai-webapi`\n\nInvoke the `Skill` tool for `power-pages:integrate-webapi` with a single prompt:\n\n> `[AI-READ-ONLY] mode=ai-read-only primary=\u003Cprimary> tables=\u003Clist> expand-targets=\u003Clist> caller=add-ai-webapi`\n>\n> Configure Layer 1\u002F2 (Web API site settings + table permissions) for the following Power Pages\n> AI summarization targets: \u003Ctable list>. This is a read-only integration — the `\u002F_api\u002Fsummarization\u002Fdata\u002Fv1.0\u002F`\n> endpoint never mutates Dataverse. Return when all Web API site settings, table permissions, and the\n> shared `powerPagesApi.ts` client are written to disk.\n>\n> **Per the AI-only read-mode contract** (your SKILL.md Phase 1.6):\n> - **Do not commit.** Skip Phase 4.4 and Phase 6.5 — print the file list you would have\n>   committed so this orchestrator can stage it later. The parent skill batches commits.\n> - **Do not deploy.** Skip Phase 6.1 deploy ask, Phase 7.3 deploy ask, and Phase 7.4\n>   post-deploy notes. Return the Phase 7.2 summary and stop. The parent skill owns the\n>   single end-of-orchestration deploy.\n\n`\u002Fintegrate-webapi` detects the `[AI-READ-ONLY]` sentinel (its Phase 1.6) and runs its full flow\nwith hardened prompts: read-only table permissions, minimal fields list (no PK, only `_\u003Ccol>_value`\nfor lookups), and a read-only service layer. It still presents plan-mode approval prompts to the\nuser for each architect — this skill does not suppress those.\n\nWait for `\u002Fintegrate-webapi` to complete. Re-check the file system:\n\n- `src\u002Fshared\u002FpowerPagesApi.ts` exists\n- For every target table: `Webapi\u002F\u003Ctable>\u002Fenabled` exists, `Webapi\u002F\u003Ctable>\u002Ffields` exists\n- For every target table: at least one table permission with `read: true` exists; Parent-scope\n  permission present for every `$expand` target\n\nIf any prerequisite is still missing, surface this to the user before moving on — something in the\ndelegated flow didn't land (for example, the user declined the architect's plan). Do NOT silently\nfall back to writing Layer 1\u002F2 files here.\n\n**Output**: Layer 1\u002F2 prerequisites are on disk; shared `powerPagesApi.ts` + read-only service\nexists; web roles exist.\n\n---\n\n## Phase 5: Implement Layer 3 code\n\n**Goal**: Create the AI summarization service and wire it into each target's UI.\n\n### 5.1 Invoke the `ai-webapi-integration` agent — first target (sequential)\n\nFor the first target in the confirmed manifest, invoke the agent at\n`${PLUGIN_ROOT}\u002Fagents\u002Fai-webapi-integration.md` via `Task`. The full prompt\ntemplate — every field the agent expects, with notes on which orchestrator phase resolved\neach value — lives in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fagent-invocation-prompt.md`. Read\nthat file, copy the template, replace every `\u003C…>` placeholder with the concrete value for\nthe current target, and pass it via `Task`. The agent does not interpret placeholders;\nsending the literal text `\u003Csearch | data>` will confuse it.\n\nThe first call is sequential because it establishes the shared summarization service file\n(`src\u002Fservices\u002FaiSummaryService.*`) and the CSRF helper that subsequent targets reuse. The\nagent returns a structured file-modification list (see its \"Return value\" section); record\nit for Phase 5.5's per-file commit.\n\n### 5.2 Verify service + CSRF helper exist\n\nBefore spawning more agents, verify:\n\n- The summarization service file exists (default `src\u002Fservices\u002FaiSummaryService.ts`).\n- `getCsrfToken` is defined once in the codebase (or imported from a pre-existing helper).\n\n### 5.3 Invoke the agent for remaining targets — sequentially\n\nPer `plugins\u002Fpower-pages\u002FAGENTS.md`, agent spawning is **sequential**. Invoke\n`ai-webapi-integration` once per remaining target, waiting for each completion before starting the\nnext. Each target only adds an independent exported function, a framework wrapper (if not already\npresent), and wires one UI file — there are no merge conflicts, but the sequential rule keeps\nfailure modes simple.\n\nIf there is only one target total, skip 5.3.\n\n### 5.4 Replace placeholder POSTs\n\nFor any placeholder `InstructionIdentifier` body the Explore agent flagged in Phase 2, the\nsub-agent will have replaced them. Confirm by grepping for `InstructionIdentifier` in the affected\nfiles and verifying each resolved call uses the real entity set and id.\n\n### 5.5 Offer to commit\n\nDon't commit automatically — on iterative runs an unprompted `git commit` here creates a noisy\nseries of commits for what is effectively one set of changes.\n\n\u003C!-- gate: add-ai-webapi:5.5.commit | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:5.5.commit):** Explicit commit decision after Phase 5 summarization-service + UI wiring is complete.\n>\n> **Trigger:** All Phase 5 targets have been wired (service, framework wrapper, UI call sites).\n> **Why we ask:** Auto-committing on every integration run creates noisy one-commit-per-tweak history; letting the user batch is safer.\n> **Cancel leaves:** Nothing — source files written; no `git commit` fired.\n\nUse `AskUserQuestion`:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Commit these Layer 3 integration changes now? | Commit | Yes, commit now (Recommended), Skip — I'll commit later |\n\nOn **Yes**: stage **only the files modified during Phase 5** — the summarization service,\nframework wrapper(s), each wired UI page, and any safe-markdown renderer component the agent\nemitted. The orchestrator already has this list from each `ai-webapi-integration` invocation's\nfile-modification report. Use explicit `git add \u003Cpath>` per file; do **not** use `git add -A` —\nunrelated work-in-progress files in `src\u002F` could otherwise be swept into the commit. Substitute\n`\u003Ctargets>` in the commit message with a short human-readable list (e.g., `CaseDetail and SearchResults`,\nor `3 pages` when there are many):\n\n```powershell\ngit add \u003Ceach file modified by the Phase 5 agents>\ngit commit -m \"Add AI summarization integration for \u003Ctargets>\"\n```\n\nOn **Skip**: proceed without committing. The user will batch the commit themselves at the end.\n\n**Output**: summarization service + framework wrappers + UI call sites created for every confirmed\ntarget.\n\n---\n\n## Phase 6: Configure Layer 3 settings\n\n**Goal**: Register the `Summarization\u002F*` site settings via the `ai-webapi-settings-architect` agent.\n\n### 6.1 Skip-check\n\nSkip this phase when both of the following are true:\n\n- Every confirmed target is Search Summary (search has no per-call `Summarization\u002F*` site settings;\n  see [ai-api-reference.md](references\u002Fai-api-reference.md#1-search-summary-api)).\n- No Data Summarization target was added in Phase 3.\n\nFor search-only, remind the user to enable **Site search with generative AI (preview)** in the\nsite's Copilot workspace after deploy, and proceed to Phase 7.\n\n### 6.2 Confirm deployment prerequisite still holds\n\nPhase 1.5 already gated on `.powerpages-site` existing. Re-check it here as a guard — if it has\ndisappeared between Phase 1 and now (rare, but possible if the user manually cleaned the folder),\nstop and re-run the Phase 1.5 bootstrap-deploy prompt. Do NOT silently fall through into the\narchitect with a missing folder.\n\n### 6.3 Invoke `ai-webapi-settings-architect`\n\nInvoke the agent at `${PLUGIN_ROOT}\u002Fagents\u002Fai-webapi-settings-architect.md` via `Task`:\n\n> \"Analyse this Power Pages SPA site and propose generative-AI summarization site settings.\n> The following Data Summarization targets were integrated in Phase 5: [list each target with its\n> entity set, per-target `InstructionIdentifier` value, and **target kind** (`single-record` or\n> `list`) — the architect needs this to decide on `Summarization\u002FData\u002FContentSizeLimit`].\n> **If any target is `list`, the plan MUST include `Summarization\u002FData\u002FContentSizeLimit=200000`** —\n> the 100k server default silently truncates list content; this is non-negotiable.\n> Check for existing `Summarization\u002F*` settings. Layer 1\n> (`Webapi\u002F\u003Ctable>\u002F*`) and Layer 2 (table permissions) were configured in Phase 4 via\n> `\u002Fintegrate-webapi` in AI-only read mode — verify they are present on disk and cite them as\n> met in your plan's prerequisite table. Propose the AI plan via plan mode, and on approval\n> create the YAMLs with `create-site-setting.js`.\"\n\nWait for the agent to complete. If it reports missing Layer 1\u002F2 prerequisites, something in\nPhase 4 didn't land — read the file system, identify the gap, and surface it to the user rather\nthan attempting to create Layer 1\u002F2 files here.\n\n### 6.4 Offer to commit\n\n\u003C!-- gate: add-ai-webapi:6.4.commit | category=consent | cancel-leaves=nothing -->\n\n> ? **Gate (consent · add-ai-webapi:6.4.commit):** Explicit commit decision after `Summarization\u002F*` site settings are created by the architect.\n>\n> **Trigger:** `ai-webapi-settings-architect` has written all `Summarization\u002FData\u002FEnable` + `Summarization\u002Fprompt\u002F\u003Cid>` YAMLs.\n> **Why we ask:** Auto-committing could bundle dirty pre-existing YAMLs into the commit; explicit consent scopes the commit to just the architect's output.\n> **Cancel leaves:** Nothing — YAML files written to disk; no `git commit` fired.\n\nUse `AskUserQuestion`:\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Commit the new `Summarization\u002F*` site settings? | Commit | Yes, commit now (Recommended), Skip — I'll commit later |\n\nOn **Yes**: stage **only the files the architect just created** — use the\n`filePath` list returned by `ai-webapi-settings-architect` (or the per-file paths printed by\neach `create-site-setting.js` invocation), not a glob. A glob can sweep in pre-existing\n`Summarization-*` YAMLs that are dirty for unrelated reasons (e.g., a prior partial run, or\na maker-edited prompt) and bundle them into the commit by accident.\n\nUse explicit `git add \u003Cpath>` per file:\n\n```bash\ngit add \u003Ceach Summarization-*.sitesetting.yml the architect just wrote>\ngit commit -m \"Add AI summarization site settings\"\n```\n\nOn **Skip**: proceed without committing.\n\n**Output**: `Summarization\u002FData\u002FEnable`, `Summarization\u002Fprompt\u002F\u003Cid>` settings created.\n\n---\n\n## Phase 7: Verify\n\n**Goal**: Confirm every expected file exists, all POSTs set both required headers, and the project\nbuilds.\n\n> **Preview-feature reminder.** A green build doesn't mean the API will return a summary at\n> runtime — admin-level governance (tenant PowerShell, Copilot Hub) or the site-level maker\n> toggle for Search Summary can still block it. See the Preview-feature note at the top of\n> this skill and the admin-hierarchy checklist in\n> `references\u002Fai-api-reference.md` §1 \"Troubleshooting: AI feature appears disabled\". Tell\n> the user now so the post-deploy test isn't a surprise.\n\n### 7.1 File inventory\n\nFor each confirmed target, confirm:\n\n- **Service file**: `src\u002Fservices\u002FaiSummaryService.ts` (or project-convention equivalent) contains\n  the expected exported function (`fetchSearchSummary` or `fetchDataSummary`; the agent may also\n  emit a thin wrapper such as `fetchCaseSummary` when the user picked the support-case scenario).\n- **Framework wrapper** (non-Astro): React hook in `src\u002Fhooks\u002F`, Vue composable in\n  `src\u002Fcomposables\u002F`, or Angular service in `src\u002Fapp\u002Fservices\u002F`.\n- **UI wiring**: at least one page\u002Fcomponent imports the service or wrapper and calls it.\n- **Shared API client** `src\u002Fshared\u002FpowerPagesApi.ts` exists when any Data Summarization target was in scope.\n- **`Summarization\u002FData\u002FContentSizeLimit` site setting** when any list-summary target was\n  integrated. Grep the source for `fetchListSummary` — if any match exists, confirm\n  `.powerpages-site\u002Fsite-settings\u002FSummarization-Data-ContentSizeLimit.sitesetting.yml` is\n  present with `value: 200000` (or higher). Missing this setting silently caps list summaries at\n  the 100k server default and ships the user truncated input. If it's missing, surface the gap\n  to the user before completing Phase 7 — re-run the architect or create the YAML manually.\n\n### 7.2 Header contract grep\n\n```\nGrep: \"_api\u002Fsearch\u002Fv1\\\\.0\u002Fsummary|_api\u002Fsummarization\u002Fdata\u002Fv1\\\\.0\u002F\" in src\u002F**\u002F*.{ts,tsx,js,jsx,vue,astro}\n```\n\nFor every file that matches, verify the surrounding fetch includes:\n\n- `__RequestVerificationToken` (CSRF token, fetched from `\u002F_layout\u002Ftokenhtml`) — **hard rule**\n- `X-Requested-With: XMLHttpRequest` — **recommended** (the validator warns when it's missing but\n  does not block; it matches `shell.ajaxSafePost` and every other Power Pages POST)\n\nFor data summarization calls, additionally verify (both **hard rules**):\n\n- The URL contains `$select=` (no wildcards)\n- `OData-MaxVersion: 4.0` and `OData-Version: 4.0` headers are set\n\nFix any missing **hard-rule** header before proceeding. Missing CSRF produces 500s; missing\n`$select` or OData headers produces 403\u002F400s. A missing `X-Requested-With` only produces a\nvalidator warning — add it for consistency, but it does not break the run.\n\n### 7.3 Build check\n\n```powershell\ncd \"\u003CPROJECT_ROOT>\"\nnpm run build\n```\n\nFix any type or import errors. Common issues: missing import of the summarization service in a\nwired page; type mismatch between `DataSummaryResponse` and the UI consumer; duplicate\n`getCsrfToken` declarations (if Phase 5 failed to reuse the existing helper).\n\n### 7.4 Present verification results\n\n| Target file | API | Service fn | Wrapper | UI call site | Headers ✓ | `$select` ✓ |\n|-------------|-----|-----------|---------|--------------|-----------|-------------|\n| `src\u002Fpages\u002FSearchResults.tsx` | Search summary | `fetchSearchSummary` | `useSearchSummary` | Yes | Yes | n\u002Fa |\n| `src\u002Fpages\u002FCaseDetail.tsx` | Data summarization | `fetchDataSummary` (optionally wrapped as `fetchCaseSummary`) | `useCaseSummary` | Yes | Yes | Yes |\n| `src\u002Fpages\u002FProductDetail.tsx` | Data summarization | `fetchDataSummary` | `useProductSummary` | Yes | Yes | Yes |\n\n(Same row order and example file paths as the Phase 2 manifest example, so a maintainer reading\nboth tables can trace each row top-to-bottom. Row 2 mirrors the Microsoft-shipped support-case\nrecipe — a Data Summarization call configured for `incidents` with the `case_summary` prompt\nidentifier.)\n\n**Build status:** Pass \u002F Fail (with details).\n\n### 7.5 Final site-integrity gate\n\nAfter all AI integration source changes and the build verification are complete, run:\n\n```bash\nnode \"${PLUGIN_ROOT}\u002Fscripts\u002Fvalidate-site-integrity.js\" --projectRoot \"\u003CPROJECT_ROOT>\"\n```\n\nFix every blocking error before presenting completion or asking to deploy. Inspect and report\nreview findings in both directions and with expanded content. Rerun this gate after any later\nsource change.\n\n**Output**: all integration files verified; project builds.\n\n---\n\n## Phase 8: Review & Deploy\n\n**Goal**: Record skill usage, present a summary, and offer deployment.\n\n### 8.1 Record skill usage\n\n> Reference: `${PLUGIN_ROOT}\u002Freferences\u002Fskill-tracking-reference.md`\n\nUse `--skillName \"AddAiWebapi\"`.\n\n### 8.2 Present summary\n\n| Step | Status | Details |\n|------|--------|---------|\n| Web roles | Created via \u002Fcreate-webroles \u002F Reused existing \u002F Skipped | role name(s) |\n| Layer 1\u002F2 (Web API settings + permissions) | Created via \u002Fintegrate-webapi \u002F Reused existing \u002F Skipped (search-only) | list of files written |\n| Summarization service | Created \u002F Extended | exported functions, file path |\n| Framework wrappers | Created \u002F Extended | hook\u002Fcomposable\u002Fservice paths |\n| UI call sites | Wired | list of files |\n| Layer 3 (Summarization\u002F* settings) | Created \u002F Already existed \u002F Skipped | `Summarization\u002FData\u002FEnable`, one per prompt |\n\n### 8.3 Ask to deploy\n\n| Question | Header | Options |\n|----------|--------|---------|\n| Everything is ready. Deploy the site so the summarization APIs become live? | Deploy | Yes, deploy now (Recommended), No, I'll deploy later |\n\n**Yes**: invoke `\u002Fdeploy-site`.\n**No**: acknowledge. Remind that the API calls will not work until the site is deployed with the\nnew settings and permissions.\n\n### 8.4 Post-deploy notes\n\nSurface these to the user at the end of the run:\n\n- **Search Summary toggle** — for any Search Summary integration, remind the user to flip\n  **Set up workspace → Copilot → Site search (preview) → \"Enable Site search with generative\n  AI (preview)\"**. Without it, the endpoint returns the disabled envelope and the UI renders\n  the remediation card instead of a summary.\n- **Test recipe** — for Data Summarization, open a record-detail or list page, trigger the\n  summary, confirm 200 + rendered text, then click a recommendation chip and confirm the\n  follow-up sends `RecommendationConfig`. For Search Summary, perform a search and confirm\n  the summary renders above keyword hits with citation anchors pointing at the SPA route\n  (not `\u002Fpage-not-found\u002F`). The `90041005` \"nothing to summarize\" branch is normal for the\n  Microsoft-shipped support-case recipe on a freshly-created case with no comments — test\n  with a record that has substantive content in every selected \u002F expanded column.\n- **When the disabled-state card or `90041001` shows up** — walk the admin-hierarchy\n  checklist in `references\u002Fai-api-reference.md` §1 \"Troubleshooting: AI feature appears\n  disabled (admin hierarchy)\". Retry doesn't help; an admin or maker has to change\n  governance \u002F flip the site toggle.\n- **403 on any summarization call is always a Layer 1\u002F2 issue** (column casing in\n  `Webapi\u002F\u003Ctable>\u002Ffields`, or missing `read: true` table permission) — re-run\n  `\u002Fintegrate-webapi` in AI-only read mode rather than hand-editing YAML.\n- **Full error-code reference** (`90041001` … `90041006`) is in\n  `references\u002Fai-api-reference.md` §2 \"Error codes\". Open it when the user reports a 400.\n- **Column permission profiles can silently hide content.** If a summary has obvious\n  omissions, check Dataverse column permission profiles on the web role before suspecting\n  the prompt or fields list.\n\n**Output**: summary presented, deployment completed or deferred, post-deploy guidance given.\n\n---\n\n## Important Notes\n\n### Throughout all phases\n\n- **Use TaskCreate\u002FTaskUpdate** to track progress at every phase.\n- **Ask for user confirmation** at key decision points (list below).\n- **Sequential agent spawning** — per the \"Agent spawning\" rule in `plugins\u002Fpower-pages\u002FAGENTS.md`. Never spawn `ai-webapi-integration` in parallel across targets (every target extends the same `aiSummaryService.*` file, so parallel runs would conflict).\n- **Commit at milestones** — after implementation (Phase 5) and after settings creation (Phase 6).\n- **Never use an OData wrapper for summarization fetches** — raw `fetch` only.\n- **Never write Layer 1\u002F2 files directly** — always delegate to `\u002Fintegrate-webapi` \u002F `\u002Fcreate-webroles`. This skill is Layer 3.\n\n### Key decision points (wait for user)\n\nThe list below is the conservative upper bound — many runs hit fewer prompts because skip\nchecks (search-only run, Layer 1\u002F2 ready, no list\u002Fintent-mismatch targets) eliminate whole\nbranches. Realistic worst case for a multi-target first-time run is ~10 prompts; a clean\nre-entry tweak is just 1 prompt (the Phase 1.0 mode question).\n\n1. **At Phase 1.0 (re-entry detection)**: tweak existing surface, add a new surface, or\n   review what's already wired. Only fires when a previous `\u002Fadd-ai-webapi` run left a\n   service file or `Summarization\u002F*` settings on disk.\n2. **At Phase 1.5**: bootstrap deploy or stop (if `.powerpages-site` is missing).\n3. **After Phase 3 (main)**: confirm which APIs \u002F targets to integrate.\n4. **Phase 3 per-target follow-ups (variable count)**: list-trigger choice (one per list\n   target), and scope-confirmation (one per `scope-extends-beyond-existing-fetch`,\n   `needs-definition`, or `intent-mismatch` row). Question text and option lists live in\n   `references\u002Fscope-classification.md`.\n5. **At Phase 4.2**: create missing web role via `\u002Fcreate-webroles` (if needed). The\n   sub-skill is invoked with the caller-suppress sentinel — its own deploy prompts don't\n   fire.\n6. **At Phase 4.2 (Skip path only)**: confirm continuing despite known broken-runtime risk.\n7. **Inside the Phase 4.3 `\u002Fintegrate-webapi` delegation**: approve its\n   `table-permissions-architect` plan and its `webapi-settings-architect` plan (each\n   architect owns its own plan-mode prompt; the sub-skill is in AI-only read mode so its\n   commit and deploy prompts are suppressed).\n8. **At Phase 5.5**: commit the integration changes now or later.\n9. **Inside the Phase 6.3 `ai-webapi-settings-architect` call**: approve its plan.\n10. **At Phase 6.4**: commit the new settings now or later.\n11. **At Phase 8.3**: deploy now or later.\n\n### List-summary use case playbook\n\nWhen the target is a LIST of records (not a single record), the defaults for a single-record\nCopilot card are the wrong defaults — collection endpoint, tabular-insight prompt,\n`ContentSizeLimit=200000`, `normalizeSummaryString` + safe-markdown renderer, etc.\n\nThe full 10-rule playbook (collection endpoint, scope mirroring, prompt size, nav-property\ncasing, mandatory `ContentSizeLimit`) lives in\n`${PLUGIN_ROOT}\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fai-api-reference.md` §2 \"List-summary\nplaybook\". Read that section before any list-summary target reaches Phase 5 — the Phase 5\nagent and the Phase 6 settings architect both reference the same playbook.\n\n### Progress tracking\n\nBefore starting Phase 1, create a task list with all phases using `TaskCreate`:\n\n| Task subject | activeForm | Description |\n|-------------|------------|-------------|\n| Check site is ready | Checking site prerequisites | Locate project root, detect framework, check data model, deployment status, web-role inventory |\n| Find where AI summaries fit | Scanning code for AI summary opportunities | Use Explore agent to find search\u002Fdata\u002Fcase candidates, existing infra, and delegation decisions |\n| Confirm what to add | Confirming the AI summary plan | Present manifest and confirm which APIs and targets to integrate |\n| Set up data access for AI | Setting up Web API access and permissions | Invoke \u002Fcreate-webroles if needed, then \u002Fintegrate-webapi in AI-only read mode (or skip for search-only) |\n| Add AI summary code | Adding AI summary code to your pages | Sequential ai-webapi-integration calls: first target creates shared service + CSRF helper, remaining targets extend it |\n| Register AI prompts | Registering AI prompt settings | Invoke ai-webapi-settings-architect to create Summarization\u002F* settings |\n| Verify everything | Verifying file inventory, headers, and the build | Confirm service file, wrappers, UI wiring, header contract, run project build |\n| Review and deploy | Reviewing summary and deploying | Record skill usage, present summary, offer \u002Fdeploy-site, give post-deploy guidance |\n\nMark each task `in_progress` when starting and `completed` when done via `TaskUpdate`.\n\n---\n\n**Begin with Phase 1: Verify Site Exists**\n",{"name":5,"model":62,"description":7,"allowed-tools":63,"argument-hint":64,"user-invocable":65},"opus","Read, Write, Edit, Bash, Grep, Glob, AskUserQuestion, Skill, Task, TaskCreate, TaskUpdate, TaskList, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_search, mcp__plugin_power-pages_microsoft-learn__microsoft_docs_fetch","Optional description of which pages\u002Ftables need AI capabilities",true,"main","0a55a88fa2855404029d1e5450faf92878baf763","plugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi",232,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills","https:\u002F\u002Fmicrosoft.github.io\u002Fpower-platform-skills\u002F","https:\u002F\u002Fgithub.com\u002Fmicrosoft","https:\u002F\u002Fopensource.microsoft.com","Open source projects and samples from Microsoft","2026-11-14 21:46:39",{"source":8,"skillName":5,"commands":77,"prompt":87,"zipAvailable":65},[78,81,84],{"tool":79,"command":80},"npx","npx skills add microsoft\u002Fpower-platform-skills --skill add-ai-webapi",{"tool":82,"command":83},"bunx","bunx skills add microsoft\u002Fpower-platform-skills --skill add-ai-webapi",{"tool":85,"command":86},"pnpm","pnpm dlx skills add microsoft\u002Fpower-platform-skills --skill add-ai-webapi","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002FSKILL.md",[89,95,99,103,107,111],{"path":90,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fagent-invocation-prompt.md","REFERENCE","参考文档",4920,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fagent-invocation-prompt.md",{"path":96,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Fai-api-reference.md",41893,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fai-api-reference.md",{"path":100,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fexplore-prompt.md",12216,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fexplore-prompt.md",{"path":104,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":105,"sourceHtmlUrl":106},"references\u002Fframework-equivalents.md",9841,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fframework-equivalents.md",{"path":108,"resourceType":91,"resourceTypeDesc":92,"sizeBytes":109,"sourceHtmlUrl":110},"references\u002Fscope-classification.md",5900,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002Freferences\u002Fscope-classification.md",{"path":112,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":115,"sourceHtmlUrl":116},"scripts\u002Fvalidate-ai-webapi.js","SCRIPT","脚本",20043,"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fadd-ai-webapi\u002Fscripts\u002Fvalidate-ai-webapi.js",[118,126,147,168,186,200],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":125},"01M78JN2BFRRV1J54Q6WKZQ08D","compare-site-configurations","Compare Power Pages site configurations between two environments, such as dev, test and production, or between a local download and the live site, and explain which differences change site behavior. Use when a site works in one environment but not another (for example, works in dev but fails in test), to check configuration drift before promoting or deploying, or to see what changed between two sites. Produces a shareable HTML report and a JSON file that VS Code can import.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fpower-pages\u002Fskills\u002Fcompare-site-configurations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":57},"01M699WVHX0XN59EPBTTPEKYPG","setup","Use when Process Intelligence needs building, explicit cloud\u002Faccount\u002Fenvironment configuration, sign-in, connection diagnostics, or recovery from an authentication error.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Fsetup\u002FSKILL.md",[],[128,133,134,135,136,137,138,139,140,141,142,143,144,145,41,146],"configuration","diagnostics","error","environment","cloud","when","connection","authentication","use","Bash","recovery","process","sign","intelligence",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":156,"publishedAt":57},"01M699WSR9EX55YY1WD9J22FEG","report-issue","Use when the user wants a Process Intelligence bug-report draft or support summary for a failed operation.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Freport-issue\u002FSKILL.md",[153],{"categoryNo":154,"categoryName":155,"taxonomyType":29,"taxonomyTypeDesc":30},"01JBSEEDCAT000000000000034","行政与办公人员",[157,158,159,160,141,138,161,162,144,163,146,164,165,166,167],"issue","report","report issue","bug-report","operation","draft","bug","summary","user","for","support",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":174,"publishedAt":57},"01M699WR26YQ9Q21KE6MJF5B2G","investigate-process","Use when a broad Process Mining business question, observed pattern or competing explanation needs investigation across analytical perspectives.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Finvestigate-process\u002FSKILL.md",[],[175,144,176,177,141,178,179,138,180,181,182,41,183,184,185],"investigate","investigate process","question","process mining","business","across","perspectives","mining","pattern","investigation","analytical",{"skillNo":187,"name":188,"nameZh":6,"description":189,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":190,"categories":191,"keywords":192,"publishedAt":57},"01M699WP9SDG5ZR12P8VYNXKTN","derive-metric","Use when a requested measure is missing, a saved custom metric needs reuse, or an ephemeral formula or derived scalar is needed.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Fderive-metric\u002FSKILL.md",[],[193,194,195,196,197,198,141,138,199,41],"metric","derive metric","missing","formula","custom","reuse","saved",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":206,"publishedAt":57},"01M699WMG5R8P6SMTDAS1TKF9E","compare-cohorts","Use when comparing process cohorts, departments, periods or before-and-after results under matched definitions.","https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Fpower-platform-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprocess-intelligence\u002Fskills\u002Fcompare-cohorts\u002FSKILL.md",[],[207,208,141,138,209,144,41],"compare","compare cohorts","results"]