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
Add hook to Canvas plugin to encourage using the sync tool on every turn start (#320)
McCall Saltzmancf84f3893a47
diff --git a/plugins/canvas-apps/.claude-plugin/plugin.json b/plugins/canvas-apps/.claude-plugin/plugin.jsonindex adedd4c4a..260060c85 100644--- a/plugins/canvas-apps/.claude-plugin/plugin.json+++ b/plugins/canvas-apps/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "canvas-apps",- "version": "2.1.1",+ "version": "2.2.0","description": "Build Power Apps Canvas Apps using the Canvas Authoring MCP server.","author": {"name": "Microsoft",@@ -9,6 +9,7 @@"homepage": "https://github.com/microsoft/power-platform-skills/","repository": "https://github.com/microsoft/power-platform-skills/","license": "MIT",+ "hooks": "hooks/hooks.json","keywords": ["canvas-apps","power-apps",diff --git a/plugins/canvas-apps/.plugin/plugin.json b/plugins/canvas-apps/.plugin/plugin.jsonindex adedd4c4a..260060c85 100644--- a/plugins/canvas-apps/.plugin/plugin.json+++ b/plugins/canvas-apps/.plugin/plugin.json@@ -1,6 +1,6 @@{"name": "canvas-apps",- "version": "2.1.1",+ "version": "2.2.0","description": "Build Power Apps Canvas Apps using the Canvas Authoring MCP server.","author": {"name": "Microsoft",@@ -9,6 +9,7 @@"homepage": "https://github.com/microsoft/power-platform-skills/","repository": "https://github.com/microsoft/power-platform-skills/","license": "MIT",+ "hooks": "hooks/hooks.json","keywords": ["canvas-apps","power-apps",diff --git a/plugins/canvas-apps/AGENTS.md b/plugins/canvas-apps/AGENTS.mdindex 3494b7e70..aa59874d6 100644--- a/plugins/canvas-apps/AGENTS.md+++ b/plugins/canvas-apps/AGENTS.md@@ -19,10 +19,13 @@ claude --plugin-dir /path/to/plugins/canvas-apps## Architecture```-.plugin/plugin.json ← Open Plugins metadata (name, version, keywords)+.plugin/plugin.json ← Open Plugins metadata and Copilot hook path.mcp.json ← MCP server config (canvas-authoring, auto-registered)AGENTS.md ← Plugin guidance for AI agents (this file)CLAUDE.md ← Symlink → AGENTS.md+hooks/+ hooks.json ← Claude and Copilot prompt hook registration+ inject-sync-reminder.cs ← File-based .NET app that injects a cross-host sync reminderreferences/TechnicalGuide.md ← YAML syntax, control selection, layout strategies, Power Fx patternsDesignGuide.md ← Aesthetic guidelines, anti-patterns, design process@@ -75,6 +78,20 @@ The `canvas-authoring` MCP server exposes the following tools:| `list_data_sources` | Lists all available data sources in the current authoring session || `sync_canvas` | Syncs the current coauthoring session state from the server to a local directory, writing all YAML files |+## Hooks++Hook registration is centralized in `hooks/hooks.json`. It registers Claude Code's+`UserPromptSubmit` event and Copilot's `userPromptTransformed` event. Both invoke the+file-based .NET app at `hooks/inject-sync-reminder.cs` with `dotnet run --file`; the app+emits `modifiedTransformedPrompt` for Copilot and+`hookSpecificOutput.additionalContext` for Claude Code. This avoids requiring Node.js at+plugin runtime. Both paths remind the agent to call `sync_canvas` (targeting the app's+working directory) before acting, so it never edits stale local `.pa.yaml` files. The+reminder is conditional in wording — the agent skips the sync when no coauthoring session+is active or the request is unrelated to a canvas app. Keep the Copilot event name+lowercase: Copilot ignores the PascalCase variant, while Claude Code ignores the+Copilot-only event and continues loading `UserPromptSubmit`.+## PrerequisitesBefore the MCP server will start, you need:diff --git a/plugins/canvas-apps/hooks/hooks.json b/plugins/canvas-apps/hooks/hooks.jsonnew file mode 100644index 000000000..eeb662aaa--- /dev/null+++ b/plugins/canvas-apps/hooks/hooks.json@@ -0,0 +1,27 @@+{+ "description": "Canvas Apps lifecycle hooks",+ "hooks": {+ "UserPromptSubmit": [+ {+ "hooks": [+ {+ "type": "command",+ "command": "dotnet run --file \"${CLAUDE_PLUGIN_ROOT}/hooks/inject-sync-reminder.cs\"",+ "timeout": 30+ }+ ]+ }+ ],+ "userPromptTransformed": [+ {+ "hooks": [+ {+ "type": "command",+ "command": "dotnet run --file \"${PLUGIN_ROOT}/hooks/inject-sync-reminder.cs\"",+ "timeout": 30+ }+ ]+ }+ ]+ }+}diff --git a/plugins/canvas-apps/hooks/inject-sync-reminder.cs b/plugins/canvas-apps/hooks/inject-sync-reminder.csnew file mode 100644index 000000000..33e2fbf27--- /dev/null+++ b/plugins/canvas-apps/hooks/inject-sync-reminder.cs@@ -0,0 +1,63 @@+#:property PublishAot=false++using System.Text.Json;++// Prompt hook for the canvas-apps plugin.+//+// The hook injects guidance instead of calling sync_canvas directly because it only+// receives the session cwd, not the per-app working directory. A blanket sync could+// overwrite the wrong directory or clobber local edits that have not been pushed.+const string Reminder =+ "Canvas Apps coauthoring reminder: " ++ "Before acting on this request, if a Canvas Authoring session is " ++ "active (i.e. `connect` has already been called for a canvas app), first call " ++ "the `sync_canvas` MCP tool targeting the app's working directory to pull the " ++ "current session state into the local .pa.yaml files. This avoids editing stale " ++ "YAML. If no coauthoring session is active yet, or this request is unrelated to " ++ "a canvas app, skip the sync.";++try+{+ var rawInput = await Console.In.ReadToEndAsync();+ string? transformedPrompt = null;++ try+ {+ using var input = JsonDocument.Parse(rawInput);+ if (input.RootElement.ValueKind == JsonValueKind.Object &&+ input.RootElement.TryGetProperty("transformedPrompt", out var prompt) &&+ prompt.ValueKind == JsonValueKind.String)+ {+ transformedPrompt = prompt.GetString();+ }+ }+ catch (JsonException)+ {+ // Hook failures must not block the user's prompt. If parsing fails, emit the+ // Claude Code additional-context shape (Copilot will ignore it).+ }++ using var writer = new Utf8JsonWriter(Console.OpenStandardOutput());+ writer.WriteStartObject();++ if (transformedPrompt is not null)+ {+ writer.WriteString(+ "modifiedTransformedPrompt",+ $"{transformedPrompt}\n\n{Reminder}");+ }+ else+ {+ writer.WriteStartObject("hookSpecificOutput");+ writer.WriteString("hookEventName", "UserPromptSubmit");+ writer.WriteString("additionalContext", Reminder);+ writer.WriteEndObject();+ }++ writer.WriteEndObject();+ writer.Flush();+}+catch+{+ // Hooks are advisory and must never prevent the host from processing a prompt.+}diff --git a/plugins/canvas-apps/skills/generate-canvas-app/SKILL.md b/plugins/canvas-apps/skills/generate-canvas-app/SKILL.mddeleted file mode 100644index 62ccaeaca..000000000--- a/plugins/canvas-apps/skills/generate-canvas-app/SKILL.md+++ /dev/null@@ -1,16 +0,0 @@-----name: generate-canvas-app-version: 2.0.0-description: "[DEPRECATED — use canvas-app instead] Generate a complete Power Apps canvas app."-author: Microsoft Corporation-user-invocable: true-allowed-tools: Read------# ⚠️ Deprecated — Use `canvas-app`--This skill has been replaced by the unified **`canvas-app`** skill, which handles both-creating and editing canvas apps.--Please use `/canvas-app` instead. It will automatically detect that the app is empty and-run the full generation workflow.