opencodekit 0.15.19 → 0.15.20

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 (22) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.opencode/memory/observations/2026-01-30-discovery-context-management-research-critical-gap.md +14 -0
  3. package/dist/template/.opencode/memory/observations/2026-01-31-decision-copilot-auth-plugin-updated-with-baseurl.md +63 -0
  4. package/dist/template/.opencode/memory/observations/2026-01-31-learning-opencode-copilot-auth-comparison-finding.md +61 -0
  5. package/dist/template/.opencode/memory/observations/2026-01-31-learning-opencode-copilot-reasoning-architecture-.md +66 -0
  6. package/dist/template/.opencode/memory/observations/2026-01-31-warning-copilot-claude-v1-endpoint-returns-404-c.md +48 -0
  7. package/dist/template/.opencode/memory/research/context-management-analysis.md +685 -0
  8. package/dist/template/.opencode/opencode.json +52 -156
  9. package/dist/template/.opencode/package.json +1 -1
  10. package/dist/template/.opencode/plugins/copilot-auth.ts +289 -24
  11. package/dist/template/.opencode/plugins/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +181 -0
  12. package/dist/template/.opencode/plugins/sdk/copilot/chat/get-response-metadata.ts +15 -0
  13. package/dist/template/.opencode/plugins/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +19 -0
  14. package/dist/template/.opencode/plugins/sdk/copilot/chat/openai-compatible-api-types.ts +72 -0
  15. package/dist/template/.opencode/plugins/sdk/copilot/chat/openai-compatible-chat-language-model.ts +823 -0
  16. package/dist/template/.opencode/plugins/sdk/copilot/chat/openai-compatible-chat-options.ts +30 -0
  17. package/dist/template/.opencode/plugins/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +48 -0
  18. package/dist/template/.opencode/plugins/sdk/copilot/chat/openai-compatible-prepare-tools.ts +92 -0
  19. package/dist/template/.opencode/plugins/sdk/copilot/copilot-provider.ts +94 -0
  20. package/dist/template/.opencode/plugins/sdk/copilot/index.ts +5 -0
  21. package/dist/template/.opencode/plugins/sdk/copilot/openai-compatible-error.ts +30 -0
  22. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -750,7 +750,7 @@ var cac = (name = "") => new CAC(name);
750
750
  // package.json
751
751
  var package_default = {
752
752
  name: "opencodekit",
753
- version: "0.15.19",
753
+ version: "0.15.20",
754
754
  description: "CLI tool for bootstrapping and managing OpenCodeKit projects",
755
755
  keywords: ["agents", "cli", "mcp", "opencode", "opencodekit", "template"],
756
756
  license: "MIT",
@@ -0,0 +1,14 @@
1
+ ---
2
+ type: discovery
3
+ created: 2026-01-30T16:51:31.023Z
4
+ confidence: high
5
+ valid_until: null
6
+ superseded_by: null
7
+ concepts: ["context-management", "tool-loadout", "context-pruning", "subagents", "swarm-coordination", "RAG"]
8
+ ---
9
+
10
+ # 💡 Context Management Research - Critical Gaps in OpenCodeKit
11
+
12
+ 🟢 **Confidence:** high
13
+
14
+ Research from dbreunig.com reveals four context failure modes: Poisoning, Distraction, Confusion, Clash. Key findings: models fail beyond 100k tokens, >30 tools causes guaranteed failures, multi-turn prompts yield 39% worse results. OpenCodeKit has 40+ tools in context (33% over limit). Critical gaps: 1) No tool loadout system, 2) No structured context assembly, 3) No scratchpad/think tool, 4) No automated pruning at thresholds, 5) No poisoning detection. Immediate action needed: implement tool loadout to reduce tools from 40+ to <25. Should improve accuracy 20-40% based on Berkeley Function-Calling Leaderboard findings.
@@ -0,0 +1,63 @@
1
+ ---
2
+ type: decision
3
+ created: 2026-01-31T05:13:11.027Z
4
+ confidence: high
5
+ valid_until: null
6
+ superseded_by: null
7
+ concepts: ["copilot", "auth", "plugin", "baseURL", "chat.headers", "anthropic-beta", "reasoning", "thinking", "enterprise"]
8
+ ---
9
+
10
+ # 🎯 Copilot Auth Plugin Updated with baseURL and chat.headers
11
+
12
+ 🟢 **Confidence:** high
13
+
14
+ ## Changes Made to copilot-auth.ts
15
+
16
+ ### 1. Added baseURL return for enterprise support
17
+ ```typescript
18
+ // Enterprise URL support for baseURL
19
+ const enterpriseUrl = (info as any).enterpriseUrl;
20
+ const baseURL = enterpriseUrl
21
+ ? `https://copilot-api.${normalizeDomain(enterpriseUrl)}`
22
+ : undefined;
23
+
24
+ return {
25
+ baseURL, // ← Now returned
26
+ apiKey: "",
27
+ // ...
28
+ }
29
+ ```
30
+
31
+ ### 2. Added chat.headers hook for Claude reasoning support
32
+ ```typescript
33
+ "chat.headers": async (input: any, output: any) => {
34
+ // Only apply to GitHub Copilot provider
35
+ if (!input.model?.providerID?.includes("github-copilot")) return;
36
+
37
+ // Add Anthropic beta header for interleaved thinking (extended reasoning)
38
+ if (input.model?.api?.npm === "@ai-sdk/anthropic") {
39
+ output.headers["anthropic-beta"] = "interleaved-thinking-2025-05-14";
40
+ }
41
+
42
+ // Mark subagent sessions as agent-initiated
43
+ const session = await sdk.session.get(...);
44
+ if (session?.data?.parentID) {
45
+ output.headers["x-initiator"] = "agent";
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### Why These Changes Matter
51
+
52
+ 1. **baseURL**: Enterprise users using GitHub Enterprise with data residency will now get correct API routing to `copilot-api.<domain>`.
53
+
54
+ 2. **anthropic-beta header**: When Claude routing is re-enabled (the commented-out code), this header will be automatically added to enable extended thinking/reasoning. The header `interleaved-thinking-2025-05-14` is required for Claude to return thinking blocks.
55
+
56
+ 3. **Subagent x-initiator**: Sessions that are children of other sessions (subagents) will be marked as `agent` initiated, matching the standard that other Copilot tools use.
57
+
58
+ ### Note on Reasoning Activation
59
+
60
+ The anthropic-beta header only activates when:
61
+ - `input.model.api.npm === "@ai-sdk/anthropic"`
62
+
63
+ Currently, all models use `@ai-sdk/github-copilot`, so the header won't be added until the commented Claude routing code is re-enabled.
@@ -0,0 +1,61 @@
1
+ ---
2
+ type: learning
3
+ created: 2026-01-31T05:04:00.660Z
4
+ confidence: high
5
+ valid_until: null
6
+ superseded_by: null
7
+ concepts: ["copilot", "auth", "plugin", "token-refresh", "reasoning", "thinking", "github-copilot", "opencode", "comparison"]
8
+ files: ["index.mjs"]
9
+ ---
10
+
11
+ # 📚 OpenCode Copilot Auth Comparison Findings
12
+
13
+ 🟢 **Confidence:** high
14
+
15
+ ## Key Findings from Comparing Local vs Official OpenCode Copilot Auth Plugin
16
+
17
+ ### Official Plugin Location
18
+ - Repository: `anomalyco/opencode-copilot-auth` (separate repo)
19
+ - File: `index.mjs`
20
+ - The auth.ts in main opencode repo is just auth orchestration, not the actual plugin
21
+
22
+ ### Critical Differences Found
23
+
24
+ #### 1. CLIENT_ID Mismatch
25
+ - **Local**: `Ov23li8tweQw6odWQebz`
26
+ - **Official**: `Iv1.b507a08c87ecfe98`
27
+ - CRITICAL: Different OAuth client IDs will affect authentication!
28
+
29
+ #### 2. Token Refresh Mechanism
30
+ - **Local**: Does NOT refresh Copilot API token - uses OAuth access token directly
31
+ - **Official**: Uses `COPILOT_API_KEY_URL` (`/copilot_internal/v2/token`) to get short-lived Copilot tokens
32
+ - CRITICAL: Local version may have token expiration issues
33
+
34
+ #### 3. Token Storage
35
+ - **Local**: Stores `data.access_token` as both `refresh` and `access` with `expires: 0`
36
+ - **Official**: Stores OAuth token as `refresh`, and fetches separate Copilot token as `access` with proper expiration
37
+
38
+ #### 4. Rate Limit Handling
39
+ - **Local**: Has retry logic with exponential backoff for 429 errors
40
+ - **Official**: No retry logic - relies on proper token refresh instead
41
+
42
+ #### 5. Model Configuration
43
+ - **Local**: Sets `model.api.npm = "@ai-sdk/github-copilot"` explicitly
44
+ - **Official**: Does NOT modify model SDK - lets OpenCode core handle it
45
+
46
+ #### 6. Agent Detection Logic
47
+ - **Local**: Checks ALL messages for tool/assistant roles
48
+ - **Official**: Only checks LAST message for agent detection
49
+
50
+ #### 7. baseURL Configuration
51
+ - **Local**: Does NOT set baseURL (commented out Claude routing)
52
+ - **Official**: Sets baseURL dynamically based on enterprise vs public deployment
53
+
54
+ ### Reasoning/Thinking Block Fix Context
55
+ The v1.1.46 fix "Remove AI SDK middleware that was preventing think blocks" is in the core OpenCode provider code, NOT in the copilot auth plugin. The `extractReasoningMiddleware` is used to extract thinking from tags like `<think>`, but Anthropic's native thinking doesn't need this.
56
+
57
+ ### Recommendation
58
+ The local plugin has diverged significantly from official. Key issues:
59
+ 1. Wrong CLIENT_ID will cause auth problems
60
+ 2. Missing token refresh logic will cause "Not Found" or auth errors
61
+ 3. Agent detection differs which affects `x-initiator` header
@@ -0,0 +1,66 @@
1
+ ---
2
+ type: learning
3
+ created: 2026-01-31T05:23:35.673Z
4
+ confidence: high
5
+ valid_until: null
6
+ superseded_by: null
7
+ concepts: ["copilot", "reasoning", "thinking", "config", "opencode", "sdk", "thinking_budget", "reasoning_text", "reasoning_opaque"]
8
+ ---
9
+
10
+ # 📚 OpenCode Copilot Reasoning Architecture Explained
11
+
12
+ 🟢 **Confidence:** high
13
+
14
+ ## OpenCode Copilot Reasoning Architecture
15
+
16
+ ### Config Parameters Found in opencode.json
17
+ The `github-copilot` provider has Claude models with reasoning configured:
18
+ ```json
19
+ "claude-haiku-4.5": {
20
+ "reasoning": true,
21
+ "variants": {
22
+ "high": {
23
+ "options": {
24
+ "thinking": {
25
+ "budgetTokens": 32000,
26
+ "type": "enabled"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ### How OpenCode v1.1.46 Actually Handles Copilot Reasoning
35
+
36
+ OpenCode created a custom Copilot SDK (`packages/opencode/src/provider/sdk/copilot/`) that:
37
+
38
+ 1. **Does NOT use Anthropic's `/v1/messages` endpoint** - uses standard `/chat/completions`
39
+ 2. **Sends `thinking_budget` parameter** in request args
40
+ 3. **Looks for `reasoning_text` and `reasoning_opaque` fields** in response
41
+ 4. **Preserves `reasoning_opaque`** for multi-turn conversations
42
+
43
+ ### Key Response Schema Fields (Copilot-specific)
44
+ ```typescript
45
+ message: {
46
+ content: z.string().nullish(),
47
+ reasoning_text: z.string().nullish(), // Reasoning content
48
+ reasoning_opaque: z.string().nullish(), // Opaque token for multi-turn
49
+ }
50
+ ```
51
+
52
+ ### Provider Options Mapping
53
+ The custom SDK accepts:
54
+ - `thinking_budget` → budget tokens for thinking
55
+ - `reasoningEffort` → low/medium/high effort level
56
+
57
+ ### Why Standard SDK Doesn't Work
58
+ - `@ai-sdk/github-copilot` doesn't look for `reasoning_text` field
59
+ - It doesn't pass `thinking_budget` to the API
60
+ - It doesn't preserve `reasoning_opaque` for conversation continuity
61
+
62
+ ### Solution Required
63
+ To enable Copilot reasoning, need to either:
64
+ 1. Wait for `@ai-sdk/github-copilot` to add support
65
+ 2. Copy OpenCode's custom `sdk/copilot` implementation
66
+ 3. Contribute the feature upstream
@@ -0,0 +1,48 @@
1
+ ---
2
+ type: warning
3
+ created: 2026-01-31T05:19:40.401Z
4
+ confidence: high
5
+ valid_until: null
6
+ superseded_by: null
7
+ concepts: ["copilot", "claude", "routing", "v1", "404", "not-found", "anthropic", "messages-api", "limitation"]
8
+ files: ["api.githubcopilot.com"]
9
+ ---
10
+
11
+ # ⚠️ Copilot Claude /v1 Endpoint Returns 404 - Confirmed
12
+
13
+ 🟢 **Confidence:** high
14
+
15
+ ## Confirmed: GitHub Copilot Does NOT Support Claude /v1 Endpoint
16
+
17
+ ### Test Result
18
+ Re-enabling Claude routing with `/v1` endpoint causes 404 "Not Found" errors.
19
+
20
+ ### Root Cause
21
+ GitHub Copilot API (`api.githubcopilot.com`) only exposes:
22
+ - `/v1/chat/completions` - OpenAI-compatible endpoint
23
+
24
+ It does NOT expose:
25
+ - `/v1/messages` - Anthropic's native Messages API (required for extended thinking)
26
+
27
+ ### Conclusion
28
+ **Extended thinking/reasoning is NOT available for Claude through GitHub Copilot.**
29
+
30
+ The Copilot API acts as a proxy that:
31
+ 1. Accepts OpenAI-format requests
32
+ 2. Translates them internally to Claude
33
+ 3. Returns OpenAI-format responses
34
+
35
+ This translation layer strips thinking blocks and doesn't support the `thinking` parameter.
36
+
37
+ ### Final Configuration
38
+ All Claude models must use `@ai-sdk/github-copilot` SDK, NOT `@ai-sdk/anthropic`.
39
+
40
+ ```typescript
41
+ // This is the ONLY working configuration
42
+ model.api.npm = "@ai-sdk/github-copilot";
43
+ ```
44
+
45
+ ### Workaround for Reasoning
46
+ To get Claude reasoning, users must:
47
+ 1. Use direct Anthropic API with separate API key
48
+ 2. Or use a provider that exposes native Anthropic Messages API (Vertex AI, AWS Bedrock)