opencodev2-agentswitch 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -2
  3. package/index.ts +54 -0
  4. package/package.json +31 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christian Loehnert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # Figma
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An opt-in OpenCode plugin that registers Figma's remote MCP server and official Figma skills. It uses OpenCode's existing OAuth/DCR flow and credential storage, without a shared client secret.
4
+
5
+ ## Install
6
+
7
+ Install directly from Git:
8
+
9
+ ```sh
10
+ opencode plugin add 'git+https://github.com/anomalyco/opencode.git#path:packages/plugins/figma'
11
+ ```
12
+
13
+ The URL selects the Figma directory and uses the repository's default branch, so no explicit branch name is needed. Installation is Git-only.
14
+
15
+ The plugin exports `index.ts` directly. There is no build step or installation hook.
16
+
17
+ For local development, add the directory to `plugins` in the project's `opencode.jsonc`:
18
+
19
+ ```jsonc
20
+ {
21
+ "$schema": "https://opencode.ai/config.json",
22
+ "plugins": ["./packages/plugins/figma"],
23
+ }
24
+ ```
25
+
26
+ The plugin is not activated merely by being present in the repository. Installing it adds it to the user's configuration.
27
+
28
+ ## Sign in and test
29
+
30
+ 1. Open `/mcps`, select `figma`, and sign in.
31
+ 2. Confirm that the server is connected.
32
+ 3. Ask the agent to call Figma's `whoami` tool.
33
+
34
+ The connection uses Figma's public endpoint with dynamic client registration (DCR). OAuth discovery supplies the scope, and OpenCode chooses an available loopback callback port; no client credentials or explicit OAuth settings are needed.
35
+
36
+ Existing `mcp.servers.figma` configuration takes precedence, including disabled servers and custom endpoints.
37
+
38
+ ## Official skills
39
+
40
+ `skills/` contains the complete skill bundle copied unchanged from the pinned revision of [Figma's official plugin](https://github.com/figma/mcp-server-guide/tree/main/skills). [skills-source.json](skills-source.json) records the exact upstream revision and the discovered skill IDs; it is not an allowlist.
41
+
42
+ The bundle covers design-to-code, canvas editing, screen and library generation, Code Connect, file creation, diagrams, FigJam, Slides, motion, SwiftUI, shaders, and generative plugins. Supporting references and scripts are included. No replacement instructions are authored by OpenCode. Existing skills with the same IDs are preserved.
43
+
44
+ The vendored Figma materials remain Figma's materials, not OpenCode-authored MIT code. See [skills/NOTICE.md](skills/NOTICE.md) for attribution and the Figma Developer Terms.
45
+
46
+ ## Manually sync skills
47
+
48
+ From `packages/plugins/figma`, explicitly run:
49
+
50
+ ```sh
51
+ bun run sync:skills
52
+ ```
53
+
54
+ This fetches upstream `main`, discovers every skill directory containing `SKILL.md`, copies all of them with their supporting files, removes previously bundled skills that no longer exist upstream, and records the resolved commit and skill IDs. No skill names are filtered or hardcoded in the sync script. To use a particular branch, tag, or commit, pass it as an argument. To reproduce the current bundle, pass the revision in `skills-source.json`.
55
+
56
+ Review and commit `skills/` and `skills-source.json` together. Sync replaces local edits within bundled skill directories, so keep the upstream files unchanged and review updates before releasing them.
57
+
58
+ Sync never runs automatically during installation, plugin startup, typechecking, or CI. The plugin loads only the checked-in files. Supporting Figma scripts are guidance assets; the plugin does not execute them.
59
+
60
+ ## Remove
61
+
62
+ ```sh
63
+ opencode plugin remove 'git+https://github.com/anomalyco/opencode.git#path:packages/plugins/figma'
64
+ ```
65
+
66
+ If you installed with a different Git specification, pass that same specification to remove it. An independently configured `mcp.servers.figma` entry remains unaffected.
package/index.ts ADDED
@@ -0,0 +1,54 @@
1
+ import {Plugin} from "@opencode/plugin"
2
+
3
+ export default Plugin.define({
4
+ id: "switch-agent",
5
+ async setup(ctx) {
6
+ const agents = new Set<string>()
7
+ await ctx.agent.transform(editor => {
8
+ editor.list()
9
+ .map((e => e.name))
10
+ .forEach(name => agents.add(name.trim().toString()));
11
+ });
12
+ await ctx.tool.transform((editor) => {
13
+ if (editor.get("switch-agent")) return
14
+ editor.namespace({
15
+ name: "sks",
16
+ description: "sks tools",
17
+ })
18
+ editor.add({
19
+ name: "switch-agent",
20
+ description: "Allows the currently active agent to change the sessions agent. Use to switch the agent instead of launching a single sub agent. Use the compact tool when the new agent does not need the full context history.",
21
+ input: {
22
+ type: "object",
23
+ properties: {agent_name: {type: "string"}, compact: {type: "bool"}},
24
+ required: ["agent_name"],
25
+ additionalProperties: false,
26
+ },
27
+ options: {namespace: "sks", codemode: true},
28
+ execute: async (input, context) => {
29
+ if (input == null || typeof input != 'object') {
30
+ throw new Error(`Unexpected input ${JSON.stringify(input)}`);
31
+ }
32
+ const sessionID = context.sessionID;
33
+
34
+ const possibleAgentName = 'agent_name' in input
35
+ && typeof input.agent_name == 'string'
36
+ && input.agent_name.trim().length > 0
37
+ ? input.agent_name
38
+ : null;
39
+
40
+ if (!agents.has(possibleAgentName?.trim() || '')) {
41
+ throw new Error(`Agent ${possibleAgentName} is not known to opencode`);
42
+ }
43
+ const compact = 'compact' in input && typeof input.compact === 'boolean' ? input.compact:false;
44
+ if (compact) {
45
+ await ctx.session.compact({sessionID});
46
+
47
+ }
48
+ await ctx.session.switchAgent({sessionID, agent: possibleAgentName!});
49
+ return {content:`Switch to agent ${possibleAgentName!}${compact? ' and compacted' : ''}`};
50
+ },
51
+ })
52
+ });
53
+ },
54
+ })
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "opencodev2-agentswitch",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
4
+ "version": "0.0.1",
5
+ "description": "Agent switch tool",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/krampenschiesser/opencodev2-agentswitch.git"
11
+ },
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "exports": {
16
+ ".": "./index.ts",
17
+ "./server": "./index.ts"
18
+ },
19
+ "files": [
20
+ "index.ts"
21
+ ],
22
+ "scripts": {
23
+ "typecheck": "tsgo --noEmit"
24
+ },
25
+ "dependencies": {
26
+ "@opencode/plugin": "^2.0.29"
27
+ },
28
+ "devDependencies": {
29
+ "@tsconfig/bun": "1.0.9",
30
+ "@types/bun": "1.4.0",
31
+ "@typescript/native-preview": "7.0.0-dev.20260707.2"
32
+ }
33
+ }