opencodekit 0.15.6 → 0.15.8

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.
@@ -11,7 +11,7 @@
11
11
  "type-check": "tsc --noEmit"
12
12
  },
13
13
  "dependencies": {
14
- "@opencode-ai/plugin": "1.1.25"
14
+ "@opencode-ai/plugin": "1.1.31"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/node": "^25.0.3",
@@ -0,0 +1,322 @@
1
+ /**
2
+ * GitHub Copilot Auth Plugin
3
+ * Simplified auth provider without token expiration checks
4
+ */
5
+
6
+ import type { Plugin } from "@opencode-ai/plugin";
7
+
8
+ const CLIENT_ID = "Iv1.b507a08c87ecfe98";
9
+
10
+ const HEADERS = {
11
+ "User-Agent": "GitHubCopilotChat/0.35.0",
12
+ "Editor-Version": "vscode/1.107.0",
13
+ "Editor-Plugin-Version": "copilot-chat/0.35.0",
14
+ "Copilot-Integration-Id": "vscode-chat",
15
+ };
16
+
17
+ const RESPONSES_API_ALTERNATE_INPUT_TYPES = [
18
+ "file_search_call",
19
+ "computer_call",
20
+ "computer_call_output",
21
+ "web_search_call",
22
+ "function_call",
23
+ "function_call_output",
24
+ "image_generation_call",
25
+ "code_interpreter_call",
26
+ "local_shell_call",
27
+ "local_shell_call_output",
28
+ "mcp_list_tools",
29
+ "mcp_approval_request",
30
+ "mcp_approval_response",
31
+ "mcp_call",
32
+ "reasoning",
33
+ ];
34
+
35
+ function normalizeDomain(url: string): string {
36
+ return url.replace(/^https?:\/\//, "").replace(/\/$/, "");
37
+ }
38
+
39
+ function getUrls(domain: string) {
40
+ return {
41
+ DEVICE_CODE_URL: `https://${domain}/login/device/code`,
42
+ ACCESS_TOKEN_URL: `https://${domain}/login/oauth/access_token`,
43
+ COPILOT_API_KEY_URL: `https://api.github.com/copilot_internal/v2/token`,
44
+ };
45
+ }
46
+
47
+ export const CopilotAuthPlugin: Plugin = async ({ client }) => {
48
+ return {
49
+ auth: {
50
+ provider: "github-copilot",
51
+ loader: async (getAuth, provider) => {
52
+ const info = await getAuth();
53
+ if (!info || info.type !== "oauth") return {};
54
+
55
+ if (provider && provider.models) {
56
+ for (const model of Object.values(provider.models)) {
57
+ model.cost = {
58
+ input: 0,
59
+ output: 0,
60
+ cache: {
61
+ read: 0,
62
+ write: 0,
63
+ },
64
+ };
65
+ }
66
+ }
67
+
68
+ const enterpriseUrl = info.enterpriseUrl;
69
+ const baseURL = enterpriseUrl
70
+ ? `https://copilot-api.${normalizeDomain(enterpriseUrl)}`
71
+ : "https://api.githubcopilot.com";
72
+
73
+ return {
74
+ baseURL,
75
+ apiKey: "",
76
+ async fetch(input, init) {
77
+ const info = await getAuth();
78
+ if (info.type !== "oauth") return {};
79
+ if (!info.access) {
80
+ const domain = info.enterpriseUrl
81
+ ? normalizeDomain(info.enterpriseUrl)
82
+ : "github.com";
83
+ const urls = getUrls(domain);
84
+
85
+ const response = await fetch(urls.COPILOT_API_KEY_URL, {
86
+ headers: {
87
+ Accept: "application/json",
88
+ Authorization: `Bearer ${info.refresh}`,
89
+ ...HEADERS,
90
+ },
91
+ });
92
+
93
+ if (!response.ok) {
94
+ throw new Error(`Token refresh failed: ${response.status}`);
95
+ }
96
+
97
+ const tokenData = await response.json();
98
+
99
+ const saveProviderID = info.enterpriseUrl
100
+ ? "github-copilot-enterprise"
101
+ : "github-copilot";
102
+ await client.auth.set({
103
+ path: {
104
+ id: saveProviderID,
105
+ },
106
+ body: {
107
+ type: "oauth",
108
+ refresh: info.refresh,
109
+ access: tokenData.token,
110
+ expires: tokenData.expires_at * 1000 - 5 * 60 * 1000,
111
+ ...(info.enterpriseUrl && {
112
+ enterpriseUrl: info.enterpriseUrl,
113
+ }),
114
+ },
115
+ });
116
+ info.access = tokenData.token;
117
+ }
118
+
119
+ let isAgentCall = false;
120
+ let isVisionRequest = false;
121
+ try {
122
+ const body =
123
+ typeof init.body === "string"
124
+ ? JSON.parse(init.body)
125
+ : init.body;
126
+ if (body?.messages) {
127
+ isAgentCall = body.messages.some(
128
+ (msg: any) =>
129
+ msg.role && ["tool", "assistant"].includes(msg.role),
130
+ );
131
+ isVisionRequest = body.messages.some(
132
+ (msg: any) =>
133
+ Array.isArray(msg.content) &&
134
+ msg.content.some((part: any) => part.type === "image_url"),
135
+ );
136
+ }
137
+
138
+ if (body?.input) {
139
+ const lastInput = body.input[body.input.length - 1];
140
+
141
+ const isAssistant = lastInput?.role === "assistant";
142
+ const hasAgentType = lastInput?.type
143
+ ? RESPONSES_API_ALTERNATE_INPUT_TYPES.includes(lastInput.type)
144
+ : false;
145
+ isAgentCall = isAssistant || hasAgentType;
146
+
147
+ isVisionRequest =
148
+ Array.isArray(lastInput?.content) &&
149
+ lastInput.content.some(
150
+ (part: any) => part.type === "input_image",
151
+ );
152
+ }
153
+ } catch {}
154
+
155
+ const headers = {
156
+ ...init.headers,
157
+ ...HEADERS,
158
+ Authorization: `Bearer ${info.access}`,
159
+ "Openai-Intent": "conversation-edits",
160
+ "X-Initiator": isAgentCall ? "agent" : "user",
161
+ };
162
+ if (isVisionRequest) {
163
+ headers["Copilot-Vision-Request"] = "true";
164
+ }
165
+
166
+ delete headers["x-api-key"];
167
+ delete headers["authorization"];
168
+
169
+ return fetch(input, {
170
+ ...init,
171
+ headers,
172
+ });
173
+ },
174
+ };
175
+ },
176
+ methods: [
177
+ {
178
+ type: "oauth",
179
+ label: "Login with GitHub Copilot",
180
+ prompts: [
181
+ {
182
+ type: "select",
183
+ key: "deploymentType",
184
+ message: "Select GitHub deployment type",
185
+ options: [
186
+ {
187
+ label: "GitHub.com",
188
+ value: "github.com",
189
+ hint: "Public",
190
+ },
191
+ {
192
+ label: "GitHub Enterprise",
193
+ value: "enterprise",
194
+ hint: "Data residency or self-hosted",
195
+ },
196
+ ],
197
+ },
198
+ {
199
+ type: "text",
200
+ key: "enterpriseUrl",
201
+ message: "Enter your GitHub Enterprise URL or domain",
202
+ placeholder: "company.ghe.com or https://company.ghe.com",
203
+ condition: (inputs: any) =>
204
+ inputs.deploymentType === "enterprise",
205
+ validate: (value: string) => {
206
+ if (!value) return "URL or domain is required";
207
+ try {
208
+ const url = value.includes("://")
209
+ ? new URL(value)
210
+ : new URL(`https://${value}`);
211
+ if (!url.hostname)
212
+ return "Please enter a valid URL or domain";
213
+ return undefined;
214
+ } catch {
215
+ return "Please enter a valid URL (e.g., company.ghe.com or https://company.ghe.com)";
216
+ }
217
+ },
218
+ },
219
+ ],
220
+ async authorize(inputs: any = {}) {
221
+ const deploymentType = inputs.deploymentType || "github.com";
222
+
223
+ let domain = "github.com";
224
+ let actualProvider = "github-copilot";
225
+
226
+ if (deploymentType === "enterprise") {
227
+ const enterpriseUrl = inputs.enterpriseUrl;
228
+ domain = normalizeDomain(enterpriseUrl);
229
+ actualProvider = "github-copilot-enterprise";
230
+ }
231
+
232
+ const urls = getUrls(domain);
233
+
234
+ const deviceResponse = await fetch(urls.DEVICE_CODE_URL, {
235
+ method: "POST",
236
+ headers: {
237
+ Accept: "application/json",
238
+ "Content-Type": "application/json",
239
+ "User-Agent": "GitHubCopilotChat/0.35.0",
240
+ },
241
+ body: JSON.stringify({
242
+ client_id: CLIENT_ID,
243
+ scope: "read:user",
244
+ }),
245
+ });
246
+
247
+ if (!deviceResponse.ok) {
248
+ throw new Error("Failed to initiate device authorization");
249
+ }
250
+
251
+ const deviceData = await deviceResponse.json();
252
+
253
+ return {
254
+ url: deviceData.verification_uri,
255
+ instructions: `Enter code: ${deviceData.user_code}`,
256
+ method: "auto",
257
+ callback: async () => {
258
+ while (true) {
259
+ const response = await fetch(urls.ACCESS_TOKEN_URL, {
260
+ method: "POST",
261
+ headers: {
262
+ Accept: "application/json",
263
+ "Content-Type": "application/json",
264
+ "User-Agent": "GitHubCopilotChat/0.35.0",
265
+ },
266
+ body: JSON.stringify({
267
+ client_id: CLIENT_ID,
268
+ device_code: deviceData.device_code,
269
+ grant_type:
270
+ "urn:ietf:params:oauth:grant-type:device_code",
271
+ }),
272
+ });
273
+
274
+ if (!response.ok) return { type: "failed" };
275
+
276
+ const data = await response.json();
277
+
278
+ if (data.access_token) {
279
+ const result: {
280
+ type: "success";
281
+ refresh: string;
282
+ access: string;
283
+ expires: number;
284
+ provider?: string;
285
+ enterpriseUrl?: string;
286
+ } = {
287
+ type: "success",
288
+ refresh: data.access_token,
289
+ access: "",
290
+ expires: 0,
291
+ };
292
+
293
+ if (actualProvider === "github-copilot-enterprise") {
294
+ result.provider = "github-copilot-enterprise";
295
+ result.enterpriseUrl = domain;
296
+ }
297
+
298
+ return result;
299
+ }
300
+
301
+ if (data.error === "authorization_pending") {
302
+ await new Promise((resolve) =>
303
+ setTimeout(resolve, deviceData.interval * 1000),
304
+ );
305
+ continue;
306
+ }
307
+
308
+ if (data.error) return { type: "failed" };
309
+
310
+ await new Promise((resolve) =>
311
+ setTimeout(resolve, deviceData.interval * 1000),
312
+ );
313
+ continue;
314
+ }
315
+ },
316
+ };
317
+ },
318
+ },
319
+ ],
320
+ },
321
+ };
322
+ };
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: stitch
3
+ description: Google Stitch MCP for AI-powered UI design. Extract design context, generate code from designs, and create screens from descriptions. Use when working with Stitch designs and UI generation.
4
+ ---
5
+
6
+ # Google Stitch MCP
7
+
8
+ Access Google Stitch UI designs directly through the Model Context Protocol.
9
+
10
+ ## Overview
11
+
12
+ Stitch MCP is Google's official Model Context Protocol server for interacting with Google Stitch designs. It allows AI agents to extract design context (colors, typography, spacing), generate production-ready code from designs, and create new designs from text descriptions.
13
+
14
+ ## Endpoint
15
+
16
+ **MCP Server URL**: `https://stitch.googleapis.com/mcp`
17
+
18
+ **Authentication**: Google Cloud credentials with Bearer token and project ID header
19
+
20
+ ## Prerequisites
21
+
22
+ 1. **Google Cloud Project** with Stitch API enabled
23
+ 2. **Google Cloud CLI** (`gcloud`) installed and initialized
24
+ 3. **Required IAM Roles**:
25
+ - `roles/serviceusage.serviceUsageAdmin` (to enable the service)
26
+ - `roles/mcp.toolUser` (to call MCP tools)
27
+
28
+ ## Setup Steps
29
+
30
+ ### 1. Enable Stitch API in Google Cloud
31
+
32
+ ```bash
33
+ # Set your Google Cloud project
34
+ gcloud config set project PROJECT_ID
35
+
36
+ # Enable the Stitch MCP service
37
+ gcloud beta services mcp enable stitch.googleapis.com --project=PROJECT_ID
38
+ ```
39
+
40
+ ### 2. Get Your Access Token
41
+
42
+ ```bash
43
+ # Authenticate with Google Cloud
44
+ gcloud auth login
45
+
46
+ # Get your access token
47
+ gcloud auth print-access-token
48
+ ```
49
+
50
+ ### 3. Set Environment Variables
51
+
52
+ ```bash
53
+ # Set your Google Cloud project ID
54
+ export GOOGLE_CLOUD_PROJECT="your-project-id"
55
+
56
+ # Get and set your access token
57
+ export STITCH_ACCESS_TOKEN=$(gcloud auth print-access-token)
58
+ ```
59
+
60
+ ### 4. Configuration
61
+
62
+ Stitch MCP is pre-configured in `opencode.json` as a default MCP server. Once environment variables are set, restart OpenCode and the tools will be available.
63
+
64
+ ## Available Tools
65
+
66
+ Once configured, the Stitch MCP exposes the following tools:
67
+
68
+ | Tool | Description |
69
+ | ---------------------------------- | --------------------------------- |
70
+ | `stitch_list_projects` | List all your Stitch projects |
71
+ | `stitch_create_project` | Create a new UI design project |
72
+ | `stitch_get_project` | Get project details |
73
+ | `stitch_list_screens` | List screens in a project |
74
+ | `stitch_get_screen` | Get screen details with HTML code |
75
+ | `stitch_generate_screen_from_text` | Generate UI from text prompt |
76
+
77
+ ## Usage Examples
78
+
79
+ ### List Projects
80
+
81
+ ```typescript
82
+ stitch_list_projects({});
83
+ ```
84
+
85
+ ### Create a Project
86
+
87
+ ```typescript
88
+ stitch_create_project({
89
+ title: "My E-commerce App",
90
+ });
91
+ ```
92
+
93
+ ### Generate Screen from Text
94
+
95
+ ```typescript
96
+ stitch_generate_screen_from_text({
97
+ projectId: "my-project-123",
98
+ prompt:
99
+ "Create a modern login page with email and password fields, social login buttons, and a forgot password link",
100
+ deviceType: "MOBILE",
101
+ });
102
+ ```
103
+
104
+ ## Troubleshooting
105
+
106
+ ### "Stitch API not enabled"
107
+
108
+ ```bash
109
+ gcloud beta services mcp enable stitch.googleapis.com --project=YOUR_PROJECT_ID
110
+ ```
111
+
112
+ ### "Authentication failed"
113
+
114
+ ```bash
115
+ # Refresh your access token (expires after ~1 hour)
116
+ export STITCH_ACCESS_TOKEN=$(gcloud auth print-access-token)
117
+ # Restart OpenCode
118
+ ```
119
+
120
+ ### "Project not set"
121
+
122
+ ```bash
123
+ gcloud config set project YOUR_PROJECT_ID
124
+ export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT_ID
125
+ ```
126
+
127
+ ## Documentation
128
+
129
+ - [Google Stitch](https://stitch.withgoogle.com)
130
+ - [Stitch MCP Setup](https://stitch.withgoogle.com/docs/mcp/setup)
131
+ - [Google Cloud MCP Overview](https://docs.cloud.google.com/mcp/overview)
132
+
133
+ ## Tips
134
+
135
+ - Access tokens expire after ~1 hour, refresh with `gcloud auth print-access-token`
136
+ - Use descriptive prompts for better UI generation results
137
+ - Test generated code in your target framework before production use
@@ -0,0 +1,9 @@
1
+ {
2
+ "stitch": {
3
+ "serverUrl": "https://stitch.googleapis.com/mcp",
4
+ "headers": {
5
+ "Authorization": "Bearer ${STITCH_ACCESS_TOKEN}",
6
+ "X-Goog-User-Project": "${GOOGLE_CLOUD_PROJECT}"
7
+ }
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencodekit",
3
- "version": "0.15.6",
3
+ "version": "0.15.8",
4
4
  "description": "CLI tool for bootstrapping and managing OpenCodeKit projects",
5
5
  "keywords": ["agents", "cli", "mcp", "opencode", "opencodekit", "template"],
6
6
  "license": "MIT",
@@ -1,27 +0,0 @@
1
- ---
2
- type: learning
3
- created: 2026-01-19T11:03:46.163Z
4
- confidence: high
5
- valid_until: null
6
- superseded_by: null
7
- concepts: ["agent orchestration", "plugin architecture", "background tasks", "tmux integration", "OpenCode"]
8
- files: ["oh-my-opencode-slim", "opencodekit-template"]
9
- ---
10
-
11
- # 📚 oh-my-opencode-slim vs opencodekit-template Analysis
12
-
13
- 🟢 **Confidence:** high
14
-
15
- Comprehensive analysis of oh-my-opencode-slim project including:
16
- 1. Project overview and architecture
17
- 2. Code structure and key components
18
- 3. Feature comparison with opencodekit-template
19
- 4. Learnings and improvement opportunities
20
- 5. Implementation patterns and approaches
21
-
22
- Key findings:
23
- - Slim fork of oh-my-opencode with 87% less code (56 vs 403 files)
24
- - Focus on agent orchestration with 5 specialized agents
25
- - Background task management with tmux integration
26
- - Clean plugin architecture using @opencode-ai/plugin SDK
27
- - Strong emphasis on low token consumption and simplicity