A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
JavaScript claude-code-pluginclaude-code-skillscode-appsgithub-copilot-pluginpower-appspower-pagespower-platform
mobile-apps: route natural-language requests to matching skills (#720)
Shubham Agarwal1a967074a96e
diff --git a/plugins/mobile-apps/.claude-plugin/plugin.json b/plugins/mobile-apps/.claude-plugin/plugin.jsonindex b520b834d..ebfcd23e6 100644--- a/plugins/mobile-apps/.claude-plugin/plugin.json+++ b/plugins/mobile-apps/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "mobile-app",- "version": "0.5.3",+ "version": "0.5.4","description": "Build and deploy Power Apps code apps for mobile using Expo (React Native), with native device functionality and Power Platform connectors","author": {"name": "Microsoft",diff --git a/plugins/mobile-apps/.plugin/plugin.json b/plugins/mobile-apps/.plugin/plugin.jsonindex b520b834d..ebfcd23e6 100644--- a/plugins/mobile-apps/.plugin/plugin.json+++ b/plugins/mobile-apps/.plugin/plugin.json@@ -1,6 +1,6 @@{"name": "mobile-app",- "version": "0.5.3",+ "version": "0.5.4","description": "Build and deploy Power Apps code apps for mobile using Expo (React Native), with native device functionality and Power Platform connectors","author": {"name": "Microsoft",diff --git a/plugins/mobile-apps/AGENTS.md b/plugins/mobile-apps/AGENTS.mdindex a83431d60..0d2499607 100644--- a/plugins/mobile-apps/AGENTS.md+++ b/plugins/mobile-apps/AGENTS.md@@ -120,10 +120,13 @@ Do not add preparation rewrites for `scheme`, `package`, `bundleIdentifier`, `srfabricate the four-approval create-only execution receipt for an edit.23. **Feature entry points share one edit owner** — Direct native, connector,data-model, and design requests on existing apps choose implementation-only,- full integration, or cancellation before costly work. Approved children- reuse their current owner/root/phase/scope and never recurse into another- edit. Follow [app-edit-routing.md](shared/references/app-edit-routing.md);- the choice enters a workflow, not permission to mutate.+ full integration, or cancellation before costly work. Natural-language+ existing-app feature requests preserve the original prompt and invoke+ `/edit-app` after full-integration consent; never merely suggest the command+ or send an existing app through `/create-mobile-app`. Approved children reuse+ their current owner/root/phase/scope and never recurse into another edit.+ Follow [app-edit-routing.md](shared/references/app-edit-routing.md); the+ choice enters a workflow, not permission to mutate.24. **Shared entry policy is not copied into every skill** — Every new publicapp workflow starts with a read-first link to `shared/shared-instructions.md`and allows `Read`. The shared preflight classifies feature work before@@ -131,6 +134,16 @@ Do not add preparation rewrites for `scheme`, `package`, `bundleIdentifier`, `srcover newly added skills automatically. These static checks verify theinstruction contract, not model compliance; do not claim smaller-model orhost reliability without agent-run evidence.+25. **Natural-language routing is not a fixed skill list** — App guidance selects+ the most specific host-advertised skill by description and supported scope,+ including future/custom workflows not in the example table. Invoke rather+ than merely recommend it after required entry consent. Preserve exact+ namespaces, invocation restrictions, current owners, and all approval gates;+ do not route every request through `/edit-app`.+ Selection needs no extra invocation-approval prompt, but Dataverse and other+ consequential actions keep their target/scope checks and mutation approvals.+ Never fabricate approval context or substitute ad-hoc mutations for an+ unavailable domain workflow.## Telemetrydiff --git a/plugins/mobile-apps/README.md b/plugins/mobile-apps/README.mdindex e3e9097de..0da56c056 100644--- a/plugins/mobile-apps/README.md+++ b/plugins/mobile-apps/README.md@@ -167,11 +167,40 @@ After the prereq sanity check passes:> /create-mobile-app build me a small notes app```-Expected: ~6 prompts (wizard + gates), then ~5 minutes of scaffolding, table creation, and parallel screen builds. End state: a working Notes app with a project-local Metro session ready to scan and debug. If anything fails, the [memory bank](#glossary) remembers where you left off — re-run the same command and it resumes.+Expected: ~6 prompts (wizard + gates), then ~5 minutes of scaffolding, table creation, and parallel screen builds. End state: a working Notes app with a project-local Metro session ready to scan and debug.++If creation stops, explicitly ask to continue that creation. The skill checks+the [memory bank](#glossary), saved build-plan progress, and current artifacts,+then confirms the unfinished phase. A plan written before app initialization+is not a completed app. Opening an existing app or asking for a feature change+does not automatically resume creation, even if a memory bank exists.## Quick examples-The plugin is conversational — you describe what you want and the skill drives the rest. Five typical flows:+The plugin is conversational: slash commands are optional when the agent host+loads the app guidance and advertises the matching skills. Describe the task+naturally, such as "Add signature capture", "Connect a data source", or "Upgrade+this app's dependencies". The agent selects the most specific matching skill by+description and supported scope, then invokes it after any required entry+consent rather than asking you to repeat the prompt as a command.++The intent table in the generated app guidance is examples, not a closed+allowlist. Future or custom skills advertised by your host are eligible too.+An ambiguous scope prompts clarification; a missing plugin requires approval+before installation or enabling. Opening the folder alone starts nothing, and+`edit-app` is not the default for every request. Existing approval gates and+fresh-template safeguards still apply.++There is no extra approval just to select or load a clearly matching skill.+Approvals cover the work: integration scope/cost, Dataverse schema/data changes,+installations, native builds, and deployment. Dataverse workflows validate the+app root and selected environment/tenant, inspect existing inventory, and show+the proposed changes before mutation approval. Missing skills or unresolved+targets block that work instead of falling back to ad-hoc commands. Approval to+install a plugin never authorizes its Dataverse changes; current approvals are+reused only for the same target and scope.++Five typical flows:### 1. Create a new app from a one-liner@@ -281,7 +310,29 @@ separate approval. Cloud-flow integration is not supported.> /report-issue # copy-paste-ready GitHub issue body```-Use `/edit-app` for post-generation improvements. It first inspects the existing app and asks only for missing intent details (which screen, table, scanned field, launch point, brand source, etc.). Then it updates `native-app-plan.md` when the request changes the plan, applies the generated app edits, runs the relevant verification, updates `memory-bank.md`, and regenerates `preview.html` when UI changed. You do not need to manually run `npm run generate-schemas`, `npx --no-install tsc --noEmit`, or `/preview-screens` after each edit unless you are doing diagnostics outside the skill.+Use `/edit-app` for post-generation improvements. Users can invoke it directly+or ask naturally, for example, "This app already exists; add an asset detail+screen." For a natural-language existing-app feature request, the generated app+guidance asks whether the user wants **Implementation only**, **Full app+integration**, or **Cancel**. Full integration invokes `/edit-app` with the+original request; it does not merely recommend the command or ask the user to+repeat the prompt. Reported failures still go to `/debug-app`, dependency or+template upgrades go to `/check-updates`, and small app-owned fixes remain+small.++A fresh starter is not an already-generated app. Native-control requests such+as "Add signature capture" use `/add-native` and its standalone prerequisites;+they do not automatically start `/edit-app` or full app creation. An existing+app with a missing plan is not considered fresh and must not be re-scaffolded.++`/edit-app` first inspects the existing app and asks only for missing intent+details (which screen, table, scanned field, launch point, brand source, etc.).+Then it updates `native-app-plan.md` when the request changes the plan, applies+the generated app edits, runs the relevant verification, updates+`memory-bank.md`, and regenerates `preview.html` when UI changed. You do not+need to manually run `npm run generate-schemas`,+`npx --no-install tsc --noEmit`, or `/preview-screens` after each edit unless+you are doing diagnostics outside the skill.Common follow-ups:diff --git a/plugins/mobile-apps/scripts/tests/app-docs.test.js b/plugins/mobile-apps/scripts/tests/app-docs.test.jsindex 76de2d22c..cec8d9304 100644--- a/plugins/mobile-apps/scripts/tests/app-docs.test.js+++ b/plugins/mobile-apps/scripts/tests/app-docs.test.js@@ -420,7 +420,7 @@ test('a section nobody is asked to approve does not raise the waiting banner', (assert.match(summarize(state).awaitingInput, /Review the data model/);});-test('the skill marks a phase failed before it stops', () => {+test('the skill records creation failures without mutating routing exits', () => {const skill = fs.readFileSync(path.resolve(__dirname, '..', '..', 'skills', 'create-mobile-app', 'SKILL.md'), 'utf8',);@@ -429,7 +429,8 @@ test('the skill marks a phase failed before it stops', () => {// issuing it left the last phase `active`, so a terminal STOP produced a plan that reloaded// forever reporting work in progress on a run that had ended.assert.match(skill, /step --id <phase> --status failed/);- assert.match(skill, /Mark the phase `failed` before you stop/);+ assert.match(skill, /Mark the active creation phase `failed` before stopping on a creation error/);+ assert.match(skill, /Step 0 routing exits leave existing creation history untouched/);// And nothing may switch the protocol off: the plan is how an abandoned run explains itself.assert.doesNotMatch(skill, /Skip the protocol entirely when/);@@ -624,6 +625,13 @@ test('a stopped plan names the failed phase by id, and a resume reopens it', ()const resume = skill.slice(skill.indexOf('### Step 0 '), skill.indexOf('### Step 1 '));assert.match(resume, /step --id <failedPhase> --status active/);assert.match(resume, /docs\/create-app-plan\.html/, 'a resume skips 2b, so it must reopen the plan');+ assert.match(resume, /Reopen the build plan only after continuation approval/);+ assert.match(resume, /failedPhase` matching the approved continuation/);+ assert.ok(+ resume.indexOf('return without entering Step 1 or modifying creation progress')+ < resume.indexOf('step --id <failedPhase> --status active'),+ 'Existing-app routing must return before reopening a creation phase',+ );});test('every waiting note is taken down by the step that set it', () => {diff --git a/plugins/mobile-apps/scripts/tests/app-edit-routing-contract.test.js b/plugins/mobile-apps/scripts/tests/app-edit-routing-contract.test.jsindex 9ee13400b..c498f87a5 100644--- a/plugins/mobile-apps/scripts/tests/app-edit-routing-contract.test.js+++ b/plugins/mobile-apps/scripts/tests/app-edit-routing-contract.test.js@@ -13,6 +13,8 @@ const skill = (name) => read(`skills/${name}/SKILL.md`);const shared = read('shared/shared-instructions.md');const routing = read('shared/references/app-edit-routing.md');const removal = read('shared/references/data-source-removal.md');+const pluginGuidance = read('AGENTS.md');+const templateGuidance = read('template/AGENTS.md');const edit = skill('edit-app');const create = skill('create-mobile-app');const pluginCheck = '> **Plugin check**: Run `node "${PLUGIN_ROOT}/scripts/check-version.js"` - if it outputs a message, show it to the user before proceeding.';@@ -25,6 +27,45 @@ function section(text, start, end) {return text.slice(startIndex, endIndex);}+function creationStateRow(content, state) {+ const routing = section(content, '## Fresh-template working-directory mode', '## TypeScript Gate Policy');+ const row = routing.split('\n').find(line => line.startsWith(`| ${state} |`));+ assert.ok(row, `Missing creation state: ${state}`);+ const [, , detection, action] = row.split('|').map(cell => cell.trim());+ return { row, detection, action };+}++function assertCreationStateRouting(content) {+ const fresh = creationStateRow(content, 'Fresh template');+ assert.match(fresh.detection, /Confirmed new-app intent/);+ assert.match(fresh.detection, /confirmed uncustomized starter/);+ assert.match(fresh.action, /only when every condition is satisfied/);+ assert.match(fresh.detection, /approved creation plan and its planning artifacts are allowed/);++ const existing = creationStateRow(content, 'Already-created app');+ assert.match(existing.detection, /Existing-app intent or confirmed app customizations/);+ assert.match(existing.detection, /even when generated markers are missing/);+ assert.doesNotMatch(existing.detection, /native-app-plan\.md/);+ const continuation = creationStateRow(content, 'Creation continuation');+ assert.match(continuation.detection, /Explicit creation-continuation intent/);+ assert.match(continuation.detection, /not a request to edit an existing app/);+ assert.match(continuation.action, /matching unfinished creation progress/);++ const entry = section(content, '### Step 0 ', '### Step 1 ');+ assert.match(entry, /Apply the state-routing table above once/);+ assert.match(entry, /Classify the original request before\s+considering a creation resume/);+ const handoff = entry.indexOf('**Existing-app changes leave this skill before resume handling.**');+ const resume = entry.indexOf('#### Creation continuation');+ assert.ok(handoff >= 0 && resume > handoff, 'Existing-app handoff must precede resume handling');+ assert.match(entry, /return without entering Step 1 or modifying creation progress/);+ assert.match(entry, /Pre-initialization creation may have an approved plan and saved planning\s+progress without a memory bank/);+ assert.match(entry, /Completed creation[\s\S]*no unfinished creation to resume/);+ assert.match(entry, /Missing or conflicting progress[\s\S]*then stop/);+ assert.match(entry, /Reopen the build plan only after continuation approval/);+ assert.doesNotMatch(entry, /\*\*Bank absent\*\*.*fresh project|highest-numbered completed step|The bank is the only resume mechanism/);+ assert.doesNotMatch(entry, /If any already-created-app marker[\s\S]*STOP and tell the user to materialize a fresh template/);+}+for (const [name, ending] of [['LF', '\n'], ['CRLF', '\r\n']]) {test(`Markdown reader preserves the same contracts with ${name} line endings`, (t) => {const file = 'shared/references/app-edit-routing.md';@@ -108,6 +149,183 @@ test('direct requests preserve intent and do not infer implementation-only work'assert.match(routing, /UI integration was intentionally\nnot performed/);});+test('app guidance selects any matching advertised skill without requiring slash commands', () => {+ const guidance = section(+ templateGuidance,+ '## Route natural-language requests to available skills',+ '## Identify the app state first',+ );+ assert.match(guidance, /do not need to type a slash command/);+ assert.match(guidance, /folder alone does not start a workflow/);+ assert.match(guidance, /app state against advertised skill descriptions/);+ assert.match(guidance, /most specific matching workflow/);+ assert.match(guidance, /exact advertised skill name and namespace/);+ assert.match(guidance, /respect its invocation\s+restrictions/);+ assert.match(guidance, /Hidden implementation helpers[\s\S]*do not invoke them directly/);+ assert.match(guidance, /required entry consent is captured, invoke the matching\s+skill/);+ assert.match(guidance, /Do not merely suggest its command/);+ assert.match(guidance, /Forward the original request[\s\S]*`working_dir`/);+ assert.match(guidance, /Do not restart routing once a matching skill is running/);+ assert.match(guidance, /invocations and approved children; let that skill own its workflow/);+ assert.match(guidance, /not an exhaustive list or closed allowlist/);+ assert.match(guidance, /Future or custom skills advertised by the host can match without a table entry/);+ assert.match(guidance, /multiple workflows fit but differ in scope, ask before choosing/);+ assert.match(guidance, /If none matches, continue only authorized bounded work/);+ assert.match(guidance, /never install or enable skills automatically/);+ assert.match(guidance, /Do not add a separate approval prompt just to choose or load a matching skill/);+ assert.match(guidance, /Keep the workflow's existing scope\/cost gates/);+ assert.match(shared, /host-advertised skill descriptions/);+ assert.match(shared, /Future or custom advertised workflows remain eligible/);+ assert.match(shared, /Invoke a matching skill\s+instead of merely recommending its command, after required entry consent/);+ assert.match(shared, /do not force unrelated intents through `\/edit-app`/i);+ assert.match(shared, /already-running matching skill owns its workflow; do not invoke it again/);+ assert.match(shared, /re-dispatch an approved\s+child from its current owner/);+ assert.match(pluginGuidance, /Natural-language routing is not a fixed skill list/);+ assert.match(pluginGuidance, /including future\/custom workflows not in the example table/);+});++test('automatic skill invocation is not Dataverse mutation or installation approval', () => {+ const approvals = section(+ templateGuidance,+ '## Keep operation approvals separate from routing',+ '## Identify the app state first',+ );+ assert.match(approvals, /every selected workflow, including future\/custom skills/);+ assert.match(approvals, /Confirm the exact target and proposed scope before cloud\/data mutations/);+ assert.match(approvals, /changed targets or expanded scope need renewed approval/);+ assert.match(approvals, /Dataverse work must use a matching data-workflow skill/);+ assert.match(approvals, /validate the selected environment and tenant/);+ assert.match(approvals, /inventory for reuse before proposing changes/);+ assert.match(approvals, /exact schema, record,\s+connection, or app-binding changes/);+ assert.match(approvals, /mutation approval\s+before writing/);+ assert.match(approvals, /target is missing or conflicting, stop and clarify/);+ assert.match(approvals, /Honor `--plan-only`/);+ assert.match(approvals, /Never fabricate `approved_scope`, approval\s+receipts, or caller context/);+ assert.match(approvals, /Cancellation, dismissal, or unclear consent stops the pending operation/);+ const unavailable = section(templateGuidance, '## If skills are unavailable', '## Respect code ownership');+ assert.match(unavailable, /required data-workflow skill is unavailable or cannot load/);+ assert.match(unavailable, /do not replace\s+it with a generic editor or ad-hoc CLI\/HTTP mutations/);+ assert.match(unavailable, /blocked until the required workflow and prerequisites are available/);+ assert.match(shared, /Do not add a separate approval prompt just to select or load a matching skill/);+ assert.match(shared, /Automatic routing never creates `approved_scope`, approval\s+receipts, or caller context/);+ const dataScope = section(shared, '## Data-source invocation scope', '## Version Check');+ assert.match(dataScope, /Dataverse work requires a matching data-workflow skill/);+ assert.match(dataScope, /before obtaining mutation approval/);+ assert.match(dataScope, /Missing\/conflicting\s+target context requires clarification/);+ assert.match(dataScope, /never substitute a generic editor or ad-hoc\s+CLI\/HTTP mutations/);+ assert.match(dataScope, /Installation approval is not approval of Dataverse changes/);+});++test('fresh starters do not enter the existing-app edit workflow', () => {+ const state = section(+ templateGuidance,+ '## Identify the app state first',+ '## Trigger edit-app for existing-app feature work',+ );+ assert.match(state, /minimal local markers/);+ assert.match(state, /Honor current approved create\/edit\s+caller context first/);+ assert.match(state, /Confirmed fresh starter[\s\S]*do not invoke `edit-app`/);+ assert.match(state, /native-control request uses the available `add-native`/);+ assert.match(state, /standalone prerequisites and approval gates/);+ assert.match(state, /Do not\s+silently widen it to full app creation/);+ assert.match(state, /missing\s+plan does not make the app fresh/);+ assert.match(state, /ask to restore the plan or approve bounded/);+ assert.match(state, /Unclear state or intent[\s\S]*ask before choosing/);+ const direct = section(routing, '## Direct requests', '## Orchestrated calls');+ assert.match(direct, /confirmed fresh starter stays with `\/add-native`/);+ assert.match(direct, /do not invoke `\/edit-app` or silently start full app creation/);+ assert.match(direct, /Current approved create\/edit children retain their owner/);+});++test('template guidance invokes edit-app after explicit existing-app integration consent', () => {+ const editing = section(+ templateGuidance,+ '## Trigger edit-app for existing-app feature work',+ '## Trigger debug-app for reported issues',+ );+ assert.match(editing, /use the advertised `edit-app` workflow/);+ assert.match(editing, /do not force other intents or custom workflows\s+through `edit-app`/);+ assert.match(editing, /Do not merely suggest that the user run it/);+ assert.match(editing, /Native-control prompts[\s\S]*`add-native` entry point and its shared routing/);+ assert.match(editing, /approved child context; it does not\s+restart the entry-choice gate/);+ assert.match(editing, /before loading or invoking `edit-app`/);+ assert.match(editing, /\*\*Full app integration\*\*[\s\S]*invoke the available `edit-app` skill/);+ assert.match(editing, /original request[\s\S]*absolute app root as `working_dir`[\s\S]*`entry_choice: full-integration`/);+ assert.match(editing, /\*\*Implementation only\*\*[\s\S]*do not invoke `edit-app`/);+ assert.match(editing, /\*\*Cancel\*\*[\s\S]*stop without loading `edit-app` or changing files/);+ assert.match(editing, /direct `edit-app` invocation needs no mode question/);+ assert.match(editing, /reported runtime or build problems to `debug-app`/);+ assert.match(editing, /dependency\/template\nupgrades to `check-updates`/);+ assert.match(editing, /genuinely new apps to `create-mobile-app`/);+});++test('edit-app metadata recognizes natural existing-app requests', () => {+ const description = edit.match(/^description:\s*"([^"]+)"$/m)?.[1];+ assert.ok(description, 'edit-app needs a single-line routing description');+ for (const trigger of [+ 'the app already exists',+ 'edit my app',+ 'change this screen',+ 'add a feature to this app',+ ]) {+ assert.match(description, new RegExp(trigger));+ }+});++test('plugin maintenance guidance preserves natural existing-app routing', () => {+ assert.match(pluginGuidance, /Natural-language\n\s+existing-app feature requests preserve the original prompt and invoke/);+ assert.match(pluginGuidance, /`\/edit-app` after full-integration consent/);+ assert.match(pluginGuidance, /never merely suggest the command/);+ assert.match(pluginGuidance, /never merely suggest the command[\s\S]*`\/create-mobile-app`/);+});++test('create-mobile-app redirects existing-app change requests without re-scaffolding', () => {+ const freshMode = section(+ create,+ '## Fresh-template working-directory mode',+ '## TypeScript Gate Policy',+ );+ assert.match(freshMode, /Already-created app[\s\S]*never re-scaffold it/);+ assert.match(freshMode, /Do not send\s+an existing-app edit request to a new folder/);+ assert.match(freshMode, /Missing generated markers alone do\s+not prove freshness/);+ assert.match(freshMode, /preserve the original request and execute the shared existing-app entry routing/);+ assert.match(freshMode, /invoke `\/edit-app` only after \*\*Full app integration\*\*/);+ assert.match(freshMode, /Do not merely suggest `\/edit-app` or ask the user to repeat/);+ assert.match(freshMode, /original request, absolute `working_dir`, and\s+`entry_choice: full-integration`/);+ assert.match(freshMode, /Reported\s+problems still route to `\/debug-app`/);+ assert.match(freshMode, /dependency\/template upgrades route to\s+`\/check-updates`/);+ assertCreationStateRouting(create);+});++test('creation routing rejects marker-only freshness and contradictory resume rules', () => {+ const fresh = creationStateRow(create, 'Fresh template');+ const existing = creationStateRow(create, 'Already-created app');+ const mutations = [+ ['fresh without new-app intent', create.replace(fresh.row, fresh.row.replace('Confirmed new-app intent and ', ''))],+ ['fresh without customization confirmation', create.replace(fresh.row, fresh.row.replace('a confirmed uncustomized starter', 'a directory'))],+ ['plan alone treated as materialization', create.replace(existing.row, existing.row.replace('`memory-bank.md`', '`native-app-plan.md`, `memory-bank.md`'))],+ ['bank absence treated as fresh', create.replace('#### Fresh run', '#### Fresh run\n\n- **Bank absent** -> fresh project. Continue to Step 1.')],+ ['bank presence chooses arbitrary resume', create.replace('#### Creation continuation', '#### Creation continuation\n\nIdentify the highest-numbered completed step and resume it.')],+ ['old re-scaffold fallback returns', create.replace('#### Fresh run', '#### Fresh run\n\nIf any already-created-app marker exists, STOP and tell the user to materialize a fresh template.')],+ ['Step 0 no longer uses the shared decision', create.replace('Apply the state-routing table above once.', 'Run a separate freshness decision after checking the bank.')],+ ];+ for (const [name, mutated] of mutations) {+ assert.notEqual(mutated, create, `${name}: mutation must change the source`);+ assert.throws(() => assertCreationStateRouting(mutated), name);+ }+});++test('creation progress is not resumed or mutated for existing-app routing exits', () => {+ const protocol = section(create, '## Build documentation protocol', '### Step 0 ');+ assert.match(protocol, /after Step 0 selects fresh creation or an approved\s+creation continuation/);+ assert.match(protocol, /does not create, reopen, or reset the\s+creation plan or change its phase status/);+ assert.match(protocol, /Step 0 routing exits leave existing creation history untouched/);+ const memory = section(shared, '## Memory Bank', '## Preferred Environment');+ assert.match(memory, /Resume on explicit continuation/);+ assert.match(memory, /bank presence\s+alone is not resume intent/);+ assert.match(memory, /Existing-app edits must not resume creation/);+});+test('the entry choice precedes costly work and requires explicit integration consent', () => {const direct = section(routing, '## Direct requests', '## Orchestrated calls');assert.match(direct, /before loading\nor invoking `\/edit-app`/);diff --git a/plugins/mobile-apps/scripts/tests/mobile-telemetry-lifecycle.test.js b/plugins/mobile-apps/scripts/tests/mobile-telemetry-lifecycle.test.jsindex 9e5db1790..b98dea000 100644--- a/plugins/mobile-apps/scripts/tests/mobile-telemetry-lifecycle.test.js+++ b/plugins/mobile-apps/scripts/tests/mobile-telemetry-lifecycle.test.js@@ -747,6 +747,32 @@ test('run lock serializes parent completion and retry creation across processes'const configDir = path.join(projectRoot, 'config');const ikeyPath = path.join(configDir, 'ikey.json');const cli = path.join(PLUGIN_ROOT, 'scripts', 'emit-telemetry-checkpoint.js');+ const traceFs = path.join(projectRoot, 'trace-lifecycle-fs.cjs');+ // The CLI sanitizes failures, so trace fixture I/O errors inside test children.+ fs.writeFileSync(traceFs, `+const fs = require('node:fs');+const path = require('node:path');+const failures = [];+for (const operation of ['linkSync', 'rmSync', 'statSync', 'readFileSync']) {+ const original = fs[operation];+ fs[operation] = function (...args) {+ try {+ return original.apply(this, args);+ } catch (error) {+ if (typeof args[0] === 'string') {+ failures.push({+ operation, code: error.code, file: path.basename(args[0]),+ target: typeof args[1] === 'string' && operation === 'linkSync' ? path.basename(args[1]) : undefined,+ });+ }+ throw error;+ }+ };+}+process.on('exit', () => {+ for (const failure of failures) process.stderr.write(JSON.stringify(failure) + '\\n');+});+`);fs.mkdirSync(configDir, { recursive: true });fs.writeFileSync(ikeyPath, JSON.stringify(provisioned));const env = {@@ -756,7 +782,7 @@ test('run lock serializes parent completion and retry creation across processes'POWER_PLATFORM_SKILLS_TELEMETRY_MOBILE_APP_OPTOUT: '1',};const runCli = (args) => new Promise((resolve, reject) => {- const child = spawn(process.execPath, [cli, ...args], {+ const child = spawn(process.execPath, ['--require', traceFs, cli, ...args], {cwd: projectRoot,env,stdio: ['ignore', 'pipe', 'pipe'],@@ -806,7 +832,8 @@ test('run lock serializes parent completion and retry creation across processes');}- for (const spanType of ['skill', 'checkpoint']) {+ for (let retryTrial = 0; retryTrial < 32; retryTrial += 1) {+ const spanType = retryTrial % 2 === 0 ? 'skill' : 'checkpoint';const root = lifecycle.beginSpan({projectRoot, configDir, skillName: 'create-mobile-app',});@@ -831,8 +858,9 @@ test('run lock serializes parent completion and retry creation across processes'assert.equal(result.code, 0, result.stderr);return JSON.parse(result.stdout);});- assert.equal(attempts.filter((attempt) => attempt.state === 'started').length, 1);- assert.equal(attempts.filter((attempt) => attempt.reason === 'invalid_retry').length, 1);+ const retryResults = `${spanType} retry trial ${retryTrial}: ${JSON.stringify(attempts)}\n${results.map(result => result.stderr).join('\n')}`;+ assert.equal(attempts.filter((attempt) => attempt.state === 'started').length, 1, retryResults);+ assert.equal(attempts.filter((attempt) => attempt.reason === 'invalid_retry').length, 1, retryResults);const retry = attempts.find((attempt) => attempt.state === 'started');lifecycle.finishSpan({ ...options, spanId: retry.spanId, state: 'completed' });const repeated = await runCli(args);diff --git a/plugins/mobile-apps/shared/references/app-edit-routing.md b/plugins/mobile-apps/shared/references/app-edit-routing.mdindex 6ba9aadf6..f50899b5d 100644--- a/plugins/mobile-apps/shared/references/app-edit-routing.md+++ b/plugins/mobile-apps/shared/references/app-edit-routing.md@@ -17,6 +17,14 @@ or starting a planner; do not broaden the available CLI surface.## Direct requests+Distinguish a confirmed fresh starter from an existing or customized app using+the supplied intent and minimal local markers. Shipped starter routes alone do+not prove generation, and a missing plan alone does not prove freshness. If+unclear, ask before choosing creation or editing. A native-control request in a+confirmed fresh starter stays with `/add-native` and its standalone prerequisites+and approval gates; do not invoke `/edit-app` or silently start full app creation.+Current approved create/edit children retain their owner even when a plan exists.+For an existing mobile app, use a lightweight **entry-choice gate** before loadingor invoking `/edit-app`. Check only the supplied request/caller context and localproject markers needed to identify the app. Do not run health/type checks, scandiff --git a/plugins/mobile-apps/shared/shared-instructions.md b/plugins/mobile-apps/shared/shared-instructions.mdindex 15ee5136c..5eb82d6de 100644--- a/plugins/mobile-apps/shared/shared-instructions.md+++ b/plugins/mobile-apps/shared/shared-instructions.md@@ -15,6 +15,28 @@ For native or data-source feature work, bind the invocation through[app-working-directory.md](references/app-working-directory.md) before readingeven the minimal local app markers. A child's launch directory is not its app root.+Natural-language requests do not require a slash command. App-level routing+matches intent and app state against host-advertised skill descriptions and+supported scope; the template's intent table is examples, not a closed allowlist.+Future or custom advertised workflows remain eligible. Use the exact advertised+name/namespace and respect invocation restrictions. Invoke a matching skill+instead of merely recommending its command, after required entry consent.+An already-running matching skill owns its workflow; do not invoke it again.+Do not force unrelated intents through `/edit-app` or re-dispatch an approved+child from its current owner. Unclear scope requires clarification; missing+skills are not permission to install or enable+plugins automatically. The classification and approval gates below still apply.++Do not add a separate approval prompt just to select or load a matching skill+for a clear request. Preserve existing workflow-entry scope/cost gates before+costly planning. Automatic routing never creates `approved_scope`, approval+receipts, or caller context; forward only the current approvals actually given.+Read-only discovery and skill invocation are not mutation consent. Confirm+cloud/data changes, installations, native builds/runs, and deployment through+the owning workflow's operation gates; reuse current approval only for the same+target and scope. Cancellation, dismissal, or unclear consent never authorizes+the pending operation.+The standard plugin-update notification remains first. Classify the currentrequest from supplied intent, caller context, and minimal local app markersbefore operational toolchain/auth checks, metadata discovery, or planners:@@ -49,6 +71,15 @@ An existing plan or inventory is context, not permission to replay every row.Standalone implementation-only calls keep the data workflow's own approval andvalidation gates; the full-integration entry choice delegates to `/edit-app`.+Dataverse work requires a matching data-workflow skill with the app-root,+environment/tenant, schema, and generated-service checks below. Use the selected+target and existing inventory; show the exact proposed schema, record, connection,+or app-binding changes before obtaining mutation approval. Missing/conflicting+target context requires clarification, not a guessed or silently switched+environment. If a required skill is unavailable or cannot load, stop that work+and offer the approved setup path; never substitute a generic editor or ad-hoc+CLI/HTTP mutations. Installation approval is not approval of Dataverse changes.+For every data child handoff, including routers and retries, pass`MOBILE_APP_ORCHESTRATING=1`, the owning `orchestrator`, absolute `working_dir`,current `phase`, and exact `approved_scope` with supplied answers. The marker is@@ -208,7 +239,10 @@ Per-project notebook persisted at `<working_dir>/memory-bank.md`. Every skill MU1. **Read it at start** — locate at `<working_dir>/memory-bank.md`. If present, parse Project facts, Power Platform context, Data model, Connectors, Screens, Build history. Inform the user what was found.2. **Skip work already done** — if a step is marked complete, ask whether to redo or move on. If invoked from another skill that already updated the bank, skip the summary.3. **Update at end** — append to the relevant section after a successful step. Use ISO dates. One-line entries. Never delete — mark `~~superseded~~`.-4. **Resume on failure** — if a previous run died partway, the bank is the only record of where. Resume from the first incomplete step rather than re-running everything.+4. **Resume on explicit continuation** — use the bank and the owning workflow's+ saved progress only when the user requests continuation of that unfinished+ workflow. Follow its resume gate and verify the current phase; bank presence+ alone is not resume intent. Existing-app edits must not resume creation.If the bank doesn't exist yet, `/create-mobile-app` is responsible for copying the template (`${PLUGIN_ROOT}/shared/memory-bank.md`) into the working directory at Step 6 (right after `pa app init` succeeds).diff --git a/plugins/mobile-apps/skills/create-mobile-app/SKILL.md b/plugins/mobile-apps/skills/create-mobile-app/SKILL.mdindex b6e77823d..14ec0a837 100644--- a/plugins/mobile-apps/skills/create-mobile-app/SKILL.md+++ b/plugins/mobile-apps/skills/create-mobile-app/SKILL.md@@ -26,7 +26,7 @@ to their phase; this marker never skips those gates.## Workflow-Resume/template checks → prerequisites → requirements (iOS + Android fixed) →+Intent and creation-state checks → prerequisites → requirements (iOS + Android fixed) →rough plan preview → Gate 1 architecture (native capabilities, connectors,then data platform) → Gate 2 Dataverse model when selected → Gates 3 and 4screen graph/specifications → environment and template preparation → app@@ -41,18 +41,43 @@ and summary.This skill assumes the user already has a **fresh** `microsoft/power-platform-skills/plugins/mobile-apps/template#main` template materialized with `degit` in the target working directory and has already run `npm install` there. The skill turns that fresh template into an app; it does not clone, degit, or copy a template itself.-**Fresh template required.** If the working directory is not a template, or if it already looks like an app created by this skill, STOP and tell the user to materialize a fresh `microsoft/power-platform-skills/plugins/mobile-apps/template#main` template with `degit` into a new folder, run `npm install`, then rerun `/create-mobile-app --working-dir <fresh-template-dir>`.+**Fresh template required for creation.** If the working directory is not a fresh+template, STOP creation and follow the state-specific routing below. Do not send+an existing-app edit request to a new folder. Missing generated markers alone do+not prove freshness: if the template is customized or its state is unclear, ask+before proceeding. Only a request for a new app requires a fresh template folder.-Use these markers:+Resolve the original request before classifying project state. Apply this+state-routing table once in Step 0, in the order below; file markers are+supporting evidence, not user intent or approval.| State | Detection | Action ||---|---|---|-| Fresh template | `package.json`, `app.config.js`, `auth.config.json`, `tamagui.config.ts` exist; `node_modules/expo` exists; `memory-bank.md`, `native-app-plan.md`, `.datamodel-manifest.json`, and generated Dataverse services are absent | Proceed. |-| Template not installed | Fresh-template files exist but `node_modules/expo` is absent | STOP: ask user to run `npm install` in the template folder, then rerun. Do not provision ADO npm tokens here. |-| Already-created app | `memory-bank.md`, `native-app-plan.md`, `.datamodel-manifest.json`, or `src/generated/services/*.ts` exists | STOP: this is not a fresh create target. Ask user to materialize a fresh template folder with `degit`. |-| Not template | Required template files are missing | STOP: ask user to materialize `microsoft/power-platform-skills/plugins/mobile-apps/template#main` into the working directory with `degit` and run `npm install`. |--This gate is intentionally simple: `/create-mobile-app` creates a new app from a fresh template. It does not adopt, repair, resume, or overwrite an already-created app.+| Creation continuation | Explicit creation-continuation intent or a valid current create handoff for this app, not a request to edit an existing app | Use Step 0's continuation path. Require matching unfinished creation progress and confirm the next phase before continuing; missing or conflicting progress requires clarification, not fresh scaffolding. |+| Already-created app | Existing-app intent or confirmed app customizations/materialized state, even when generated markers are missing. `memory-bank.md`, `.datamodel-manifest.json`, and `src/generated/services/*.ts` can corroborate state, but do not select creation resume | STOP creation: never re-scaffold it. If the request changes this app, preserve the original request and execute the shared existing-app entry routing; invoke `/edit-app` only after **Full app integration**. If the user wants a separate new app, ask for a fresh template folder. |+| Fresh template | Confirmed new-app intent and a confirmed uncustomized starter; `package.json`, `app.config.js`, `auth.config.json`, and `tamagui.config.ts` exist; `node_modules/expo` exists; no materialized app bindings, `memory-bank.md`, `.datamodel-manifest.json`, or generated Dataverse services. An approved creation plan and its planning artifacts are allowed | Proceed to Step 1 only when every condition is satisfied. Missing generated markers alone do not establish freshness. |+| Template not installed | Confirmed new-app intent and a confirmed uncustomized starter with the required template files, but `node_modules/expo` is absent | STOP: ask user to run `npm install` in the template folder, then rerun. Do not provision ADO npm tokens here. |+| Not template | Confirmed new-app intent in a new/unsupported directory, after excluding existing-app work and creation continuation | STOP: ask user to materialize `microsoft/power-platform-skills/plugins/mobile-apps/template#main` into a new or empty folder with `degit` and run `npm install`; never overwrite existing work. |+| Unclear state or intent | New-app versus edit intent, customization, or creation progress cannot be established | Ask before selecting a workflow. Preserve the directory, plan, and history; do not default to fresh creation or resume. |++An approved `native-app-plan.md` alone is not a created-app marker. Creation+writes it before template preparation, and `assertFreshTemplate` intentionally+allows it. A plan alone also does not identify a safe resume phase: use current+caller context and saved creation progress, or ask. Do not treat an unrelated or+stale plan as approved for this request.++`/create-mobile-app` creates from a confirmed fresh starter or continues an+explicitly requested unfinished creation. It does not adopt, repair, overwrite,+or resume a completed app just because a bank or plan exists.++An already-created app is a routing boundary, not a reason to discard the+user's edit request. Do not merely suggest `/edit-app` or ask the user to repeat+the request. For a current-app feature request, execute+[app-edit-routing.md](../../shared/references/app-edit-routing.md), then invoke+`/edit-app` with the original request, absolute `working_dir`, and+`entry_choice: full-integration` only when that choice is approved. Reported+problems still route to `/debug-app`; dependency/template upgrades route to+`/check-updates`.---@@ -87,6 +112,11 @@ This gate is intentionally simple: `/create-mobile-app` creates a new app from a## Build documentation protocol+This protocol applies after Step 0 selects fresh creation or an approved+creation continuation. Routing an existing-app request elsewhere, asking for+unclear intent, or declining creation does not create, reopen, or reset the+creation plan or change its phase status.+The run also writes a plan the user can read while it happens and keep afterwards:`<working_dir>/docs/create-app-plan.html`, rendered by[`scripts/app-docs.js`](${PLUGIN_ROOT}/scripts/app-docs.js) in the same Fluent format the@@ -176,46 +206,91 @@ all user-authored, so they are written to a file with the `Write` tool and passe**Every one of these calls is best-effort.** If `app-docs.js` fails, say nothing and carry on:the documentation must never gate, retry, or fail a build.-**Mark the phase `failed` before you stop.** Every STOP in this skill is a terminal state the-user has to act on, and the plan is probably still open in their browser. Without this the last+**Mark the active creation phase `failed` before stopping on a creation error.**+Step 0 routing exits leave existing creation history untouched. Once creation is+underway, a STOP is a terminal state the user has to act on, and the plan is+probably still open in their browser. Without this the lastphase stays `active`, so the page keeps reloading and keeps reporting work in progress on a runthat ended. A failed phase settles the page, so the final thing it shows names what stopped.**No argument switches this protocol off.** `--no-design` suppresses design previews and`--no-preview` does not exist (Step 2c). The plan is how an abandoned or failed run explains-itself, so it is written on every path.+itself, so it is written on every creation path after Step 0's routing decision.----### Step 0 — Resume check + fresh-template gate+### Step 0 — Intent routing + creation-state gate**Telemetry checkpoint: `validate_fresh_template`**-If `$ARGUMENTS` includes a `--working-dir` (or the user names an existing directory), check whether `<working_dir>/memory-bank.md` exists.--- **Bank present** → read it. Identify the highest-numbered completed step. Inform the user:- > "Found existing project '<name>' at `<dir>`. Steps 1–<N> already completed (last update <date>). Resume from Step <N+1>?"- Wait for confirmation. If the user says yes, jump to that step. Skip the wizard (Step 2) and re-use the values stored in the bank.-- **Reopen the build plan on resume.** A resume skips Step 2b, where the plan is created and- opened, so open `<working_dir>/docs/create-app-plan.html` in the browser yourself when it exists.- If the earlier run stopped on a failure, the plan still says so and has stopped reloading. Run- `node "${PLUGIN_ROOT}/scripts/app-docs.js" --working-dir '<working_dir>' show`, and if it reports a `failedPhase`, reopen that phase before continuing:-- ```bash- node "${PLUGIN_ROOT}/scripts/app-docs.js" --working-dir '<working_dir>' step --id <failedPhase> --status active- ```-- **Bank absent** → fresh project. Continue to Step 1.-- **Bank present but corrupted** (missing required headings) → surface the parse error, ask the user whether to overwrite (lose history) or fix manually before proceeding.+Before project reads or commands, bind the absolute `working_dir` through+[app-working-directory.md](../../shared/references/app-working-directory.md).+Apply the state-routing table above once. Classify the original request before+considering a creation resume or testing freshness; do not derive the requested+operation from the presence or absence of `memory-bank.md`.++**Existing-app changes leave this skill before resume handling.** Follow the+table's existing-app handoff, preserving the original request and root, then+return without entering Step 1 or modifying creation progress. Reported problems+and dependency/template upgrades retain their matching workflows. If intent or+customization is unclear, ask and wait; do not offer a creation resume merely+because a bank exists.++Only a confirmed **Fresh template** or explicit **Creation continuation**+enters the creation workflow below. All other table outcomes stop or hand off+without re-scaffolding, overwriting history, or running template preparation.++#### Fresh run++Require every condition in the Fresh-template row, including confirmed new-app+intent and an uncustomized starter. The template/dependency failure rows apply+only after that intent is established. An approved plan from the current+creation is allowed; preparation stays in Step 5, not this read-only entry gate.+Resolve the CLI below, then continue to Step 1.++#### Creation continuation++For an explicit request to continue this app's unfinished creation, inspect the+matching `memory-bank.md` when present, `docs/.run-plan.json` when present, the+approved creation plan, and any valid current create caller context. Establish+the unfinished creation phase and corroborate it against current app artifacts.+Do not infer the next phase from arbitrary completed entries belonging to edits,+deployment, or another workflow.++- **Missing or conflicting progress** — ask which creation phase is being+ continued or ask to restore its records, then stop. Do not guess a phase,+ restart creation, or classify the app as fresh.+- **Completed creation** — report that there is no unfinished creation to resume.+ Clarify whether the user wants an app edit or a separate new app and use the+ table's matching route.+- **Corrupt records** — report the error and ask to repair/restore them. Do not+ delete or overwrite history to make the directory pass a freshness check.+- **Verified unfinished phase** — show the phase, remaining scope, and target+ app, then obtain continuation approval unless that exact continuation already+ has current approval. Reuse only decisions approved for the same current+ scope; pending or changed decisions keep their owning approval gates.++Pre-initialization creation may have an approved plan and saved planning+progress without a memory bank. It stays on this continuation path when the+phase can be established; the plan's presence does not redirect it to editing.+For a post-initialization continuation, resume the verified phase directly; do+not rerun the fresh preparation or `pa app init` over the materialized app.++**Reopen the build plan only after continuation approval.** When+`<working_dir>/docs/create-app-plan.html` exists, reopen it. Inspect the existing+plan with the read-only+`node "${PLUGIN_ROOT}/scripts/app-docs.js" --working-dir '<working_dir>' show`+command. If it reports a `failedPhase` matching the approved continuation,+reopen that phase before continuing:-The bank is the only resume mechanism. Do not infer resume state from `package.json` or `node_modules/` — those can lie.--After the resume check, run the **fresh-template gate** from the section above. This is a create-only command:+```bash+cd -- '<working_dir>' || { echo "BLOCKED: cannot enter working_dir" >&2; exit 1; }+node "${PLUGIN_ROOT}/scripts/app-docs.js" --working-dir '<working_dir>' step --id <failedPhase> --status active+```-- If `memory-bank.md` exists and the user confirms resume, resume as documented above.-- If any already-created-app marker exists and there is no approved resume path, STOP and tell the user to materialize a fresh template into a new folder with `degit`.-- If required template files are missing, STOP and tell the user to materialize `microsoft/power-platform-skills/plugins/mobile-apps/template#main` into the working directory with `degit` and run `npm install`.-- If `node_modules/expo` is missing, STOP and tell the user to run `npm install` in that template folder before rerunning this skill.+Use only a validated phase ID from the recorded creation state. Resolve the CLI+below before entering the verified phase; do not skip unresolved approval or+validation gates merely because an older plan exists.**Do not silently copy a bundled template over the user's folder.** A fresh `plugins/mobile-apps/template` template may contain placeholder `power.config.json` with an empty `environmentId`; Step 5 removes that placeholder immediately before Step 6 runs `pa app init`.diff --git a/plugins/mobile-apps/skills/edit-app/SKILL.md b/plugins/mobile-apps/skills/edit-app/SKILL.mdindex 178ad5da0..0c94e5ecd 100644--- a/plugins/mobile-apps/skills/edit-app/SKILL.md+++ b/plugins/mobile-apps/skills/edit-app/SKILL.md@@ -1,6 +1,6 @@---name: edit-app-description: "Use when the user wants to iterate on an existing generated Power Apps mobile app after /create-mobile-app: update Application Insights configuration, the plan, data model, native capabilities, design, screens, generated app code, and preview without restarting the full project flow."+description: "Use when the user wants to iterate on an existing generated Power Apps mobile app after /create-mobile-app: update Application Insights configuration, the plan, data model, native capabilities, design, screens, generated app code, and preview without restarting the full project flow. Natural-language triggers include 'the app already exists', 'edit my app', 'change this screen', and 'add a feature to this app'."user-invocable: trueallowed-tools: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, Task, Skillmodel: opusdiff --git a/plugins/mobile-apps/template/AGENTS.md b/plugins/mobile-apps/template/AGENTS.mdindex 9e2e681bf..a036d33f8 100644--- a/plugins/mobile-apps/template/AGENTS.md+++ b/plugins/mobile-apps/template/AGENTS.md@@ -5,12 +5,43 @@ customer feature code in `app/` and app-owned `src/` files. Read[CUSTOMIZATION.md](CUSTOMIZATION.md) before changing root configuration.Microsoft packages are consumed dependencies, not part of this app's source.-## Choose an available mobile-app skill+## Route natural-language requests to available skillsCheck the skills advertised by the current agent host. Do not search privateplugin caches, assume a plugin is installed, or invent skill invocations.Use a matching available skill and its workflow rather than duplicating it here.+Users do not need to type a slash command or know a skill name. Opening the+folder alone does not start a workflow. For each actionable request:++1. Match the original intent and app state against advertised skill descriptions+ and supported scope. Prefer the most specific matching workflow, not+ `edit-app` for every request. Honor an explicitly requested available skill+ within its supported scope.+2. Use the exact advertised skill name and namespace and respect its invocation+ restrictions. Hidden implementation helpers stay owned by their entry skill;+ do not invoke them directly.+3. Apply the app-state, integration-choice, and approval rules below. Once the+ route is clear and required entry consent is captured, invoke the matching+ skill through the host's skill mechanism. Do not merely suggest its command+ or ask the user to repeat the request.+4. Forward the original request, resolved `working_dir` when applicable, supplied+ answers, and current approval/owner context. Routing is not mutation consent.+ Do not restart routing once a matching skill is running, including explicit+ invocations and approved children; let that skill own its workflow.++Do not add a separate approval prompt just to choose or load a matching skill+for a clear request. Keep the workflow's existing scope/cost gates, including+the full-app integration choice below. Explicit skill invocation is not blanket+permission for the operations it can perform.++The table lists common examples, not an exhaustive list or closed allowlist.+Future or custom skills advertised by the host can match without a table entry.+If multiple workflows fit but differ in scope, ask before choosing; do not invoke+several speculatively. If none matches, continue only authorized bounded work or+explain the missing workflow. For an unavailable mobile-app workflow, follow the+opt-in installation flow below; never install or enable skills automatically.+| Intent | Skill || --- | --- || Start a new app | `create-mobile-app` |@@ -29,13 +60,83 @@ Use a matching available skill and its workflow rather than duplicating it here.| Report a plugin or Microsoft native-package problem | `report-issue` |Keep a small app-owned fix small. Do not route explanations, typo fixes, or-bounded bug fixes through full app planning. For an existing-app feature whose-integration scope is undecided, ask through the host's question tool before-loading planners, discovering cloud metadata, or generating previews:-**Implementation only**, **Full app integration**, or **Cancel**.-Explain that full integration takes more time and cost. Reuse a choice already-made for this request; an approved create/edit child call must not ask again or-start another orchestration. An integration choice does not approve mutations.+bounded bug fixes through full app planning.++## Keep operation approvals separate from routing++These boundaries apply to every selected workflow, including future/custom skills:++- Confirm the exact target and proposed scope before cloud/data mutations,+ dependency or plugin installation/enabling, native builds/runs, destructive+ actions, or deployment. Reuse explicit approval already given for that same+ operation and scope; changed targets or expanded scope need renewed approval.+- Dataverse work must use a matching data-workflow skill and its existing+ app-root, environment, schema, and generated-service checks. Bind the absolute+ app root, validate the selected environment and tenant, and inspect existing+ inventory for reuse before proposing changes. Show the exact schema, record,+ connection, or app-binding changes and obtain the workflow's mutation approval+ before writing. If the target is missing or conflicting, stop and clarify;+ never guess or silently switch the environment.+- Read-only discovery, selecting a skill, and choosing full integration do not+ approve writes. Honor `--plan-only`. Never fabricate `approved_scope`, approval+ receipts, or caller context from automatic routing or an old plan.+- An approved child retains its current owner, target, and scope without asking+ again. Cancellation, dismissal, or unclear consent stops the pending operation;+ never default to approval.++## Identify the app state first++Resolve the absolute app root and inspect only minimal local markers:+`package.json`, `native-app-plan.md`, `memory-bank.md`, `.datamodel-manifest.json`,+and generated services. The shipped starter routes and this guidance alone do+not prove that an app has been generated. Honor current approved create/edit+caller context first; creation can already have a plan without being finished.++- **Confirmed fresh starter** — do not invoke `edit-app` merely because the+ template is open. A native-control request uses the available `add-native`+ entry point with its standalone prerequisites and approval gates. Do not+ silently widen it to full app creation.+- **Existing or customized app** — use the existing-app routing below. A missing+ plan does not make the app fresh; ask to restore the plan or approve bounded+ implementation-only work rather than re-scaffolding it.+- **Unclear state or intent** — ask before choosing creation or editing. Do not+ infer a fresh starter solely from missing generated markers.++## Trigger edit-app for existing-app feature work++For mobile-app feature work in an existing generated app that requires full+integration, use the advertised `edit-app` workflow. Specific matching entry+skills retain their own routing; do not force other intents or custom workflows+through `edit-app`.+Do not merely suggest that the user run it, ask them to repeat the request, or+send them through `create-mobile-app`.++Native-control prompts such as "Add signature capture" use the available+`add-native` entry point and its shared routing. Full integration enters+`edit-app`, which calls `add-native` with approved child context; it does not+restart the entry-choice gate.++For an existing-app feature whose integration scope is undecided, ask through+the host's question tool before loading or invoking `edit-app`, loading planners,+discovering cloud metadata, scanning the whole app, or generating previews:+**Implementation only**, **Full app integration**, or **Cancel**. Explain that+full integration takes more time and cost.++- **Full app integration** — invoke the available `edit-app` skill and pass the+ original request, resolved absolute app root as `working_dir`, and+ `entry_choice: full-integration`. Do not ask the user to restate intent or+ repeat the mode question.+- **Implementation only** — do not invoke `edit-app`; use the matching bounded+ app-owned or leaf-skill workflow within the approved scope.+- **Cancel** — stop without loading `edit-app` or changing files.++A direct `edit-app` invocation needs no mode question, but it still keeps its+impact, plan, and mutation approval gates. Reuse a choice already made for the+current request; an approved create/edit child call must not ask again or start+another orchestration. An integration choice does not approve mutations.++Route reported runtime or build problems to `debug-app`, dependency/template+upgrades to `check-updates`, and genuinely new apps to `create-mobile-app`.## Trigger debug-app for reported issues@@ -110,6 +211,11 @@ If declined, do not repeatedly prompt. Continue only already-approved, boundedapp-owned work that does not require a missing skill. Otherwise explain theblocked step and stop instead of silently recreating its workflow.+If a required data-workflow skill is unavailable or cannot load, do not replace+it with a generic editor or ad-hoc CLI/HTTP mutations. Dataverse work remains+blocked until the required workflow and prerequisites are available, even when+the user approved installing the plugin.+## Respect code ownership- Treat Microsoft dependencies as vendor-owned. Do not modify