opencodekit 0.9.0 → 0.9.2

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
  "author": "",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@opencode-ai/plugin": "1.0.222"
14
+ "@opencode-ai/plugin": "1.0.223"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/node": "^25.0.3",
@@ -1,16 +1,93 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
1
3
  import type { Plugin } from "@opencode-ai/plugin";
2
4
 
3
5
  /**
4
- * Compaction Plugin - Customizes session compaction for context continuity
6
+ * Memory & Compaction Plugin
5
7
  *
6
- * This plugin injects additional context into the compaction process,
7
- * including beads state and memory file references.
8
+ * Combines memory auto-loading with session compaction customization:
9
+ * 1. Auto-load memory on session start (session.start hook)
10
+ * 2. Inject memory + beads context into compaction
11
+ * 3. Custom compaction prompt for context continuity
8
12
  */
13
+
14
+ // Memory paths
15
+ const getGlobalUserMemoryPath = () =>
16
+ path.join(process.env.HOME || "~", ".config/opencode/memory/user.md");
17
+
18
+ const getProjectMemoryPath = (directory: string) =>
19
+ path.join(directory, ".opencode/memory");
20
+
21
+ // Load memory files for injection
22
+ const loadMemoryContext = async (directory: string): Promise<string[]> => {
23
+ const context: string[] = [];
24
+
25
+ // 1. Global user memory (cross-project preferences)
26
+ const globalUserPath = getGlobalUserMemoryPath();
27
+ if (fs.existsSync(globalUserPath)) {
28
+ try {
29
+ const content = fs.readFileSync(globalUserPath, "utf-8");
30
+ if (content.trim() && !content.includes("<!-- ")) {
31
+ context.push(`## User Profile (Global)\n${content}`);
32
+ }
33
+ } catch {}
34
+ }
35
+
36
+ // 2. Project memory files
37
+ const projectMemoryPath = getProjectMemoryPath(directory);
38
+ if (fs.existsSync(projectMemoryPath)) {
39
+ const files = [
40
+ "project/commands.md",
41
+ "project/conventions.md",
42
+ "project/gotchas.md",
43
+ "project/architecture.md",
44
+ ];
45
+ for (const file of files) {
46
+ const filePath = path.join(projectMemoryPath, file);
47
+ if (fs.existsSync(filePath)) {
48
+ try {
49
+ const content = fs.readFileSync(filePath, "utf-8");
50
+ // Only include if has actual content (not just template)
51
+ if (content.trim() && !content.includes("<!-- ")) {
52
+ const name = path.basename(file, ".md");
53
+ context.push(`## Project ${name}\n${content}`);
54
+ }
55
+ } catch {}
56
+ }
57
+ }
58
+ }
59
+
60
+ return context;
61
+ };
62
+
9
63
  export const CompactionPlugin: Plugin = async (ctx) => {
10
64
  const { $, directory } = ctx;
11
65
 
12
66
  return {
67
+ // 1. Auto-load memory context on session start
68
+ "session.start": async (
69
+ _input: unknown,
70
+ output: { additionalContext?: string },
71
+ ) => {
72
+ const memoryContext = await loadMemoryContext(directory);
73
+
74
+ if (memoryContext.length > 0) {
75
+ output.additionalContext = `
76
+ # Memory Context (Auto-loaded)
77
+
78
+ ${memoryContext.join("\n\n")}
79
+ `;
80
+ console.log(
81
+ `[compaction] Injected ${memoryContext.length} memory contexts into session`,
82
+ );
83
+ }
84
+ },
85
+
86
+ // 2. Inject context into compaction
13
87
  "experimental.session.compacting": async (input, output) => {
88
+ // Load memory context for compaction
89
+ const memoryContext = await loadMemoryContext(directory);
90
+
14
91
  // Inject beads state if available
15
92
  let beadsContext = "";
16
93
  try {
@@ -26,9 +103,15 @@ export const CompactionPlugin: Plugin = async (ctx) => {
26
103
  // Beads not available, skip
27
104
  }
28
105
 
29
- // Inject custom context
106
+ // Inject custom context with memory
107
+ const memorySection =
108
+ memoryContext.length > 0
109
+ ? `\n## Persistent Memory\n${memoryContext.join("\n\n")}\n`
110
+ : "";
111
+
30
112
  output.context.push(`## Session Context
31
113
  ${beadsContext}
114
+ ${memorySection}
32
115
  ## Memory Files to Check
33
116
  - .opencode/memory/project/gotchas.md - Non-obvious behaviors discovered
34
117
  - .opencode/memory/project/commands.md - Build/test commands learned
@@ -53,7 +53,7 @@ function parseYamlFrontmatter(content: string): {
53
53
  if (!trimmed || trimmed.startsWith("#")) continue;
54
54
 
55
55
  const indent = line.search(/\S/);
56
- const keyMatch = trimmed.match(/^(\w+):\s*(.*)$/);
56
+ const keyMatch = trimmed.match(/^([\w-]+):\s*(.*)$/);
57
57
 
58
58
  if (keyMatch) {
59
59
  const [, key, value] = keyMatch;
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: chrome-devtools
3
+ description: Chrome DevTools for debugging, performance analysis, and browser automation. Use when debugging web apps, analyzing performance, inspecting network requests, or automating browser interactions.
4
+ mcp:
5
+ chrome-devtools:
6
+ command: npx
7
+ args: ["-y", "chrome-devtools-mcp@latest", "--stdio"]
8
+ ---
9
+
10
+ # Chrome DevTools (MCP)
11
+
12
+ Control and inspect a live Chrome browser via Chrome DevTools Protocol. Debug, analyze performance, inspect network, and automate browser interactions.
13
+
14
+ ## Quick Start
15
+
16
+ ```
17
+ skill_mcp(skill_name="chrome-devtools", tool_name="take_snapshot")
18
+ skill_mcp(skill_name="chrome-devtools", tool_name="navigate_page", arguments='{"type": "url", "url": "https://example.com"}')
19
+ ```
20
+
21
+ ## Tools
22
+
23
+ ### Input
24
+
25
+ | Tool | Description | Parameters |
26
+ | --------------- | -------------------- | ---------------------------- |
27
+ | `click` | Click element | `uid` |
28
+ | `fill` | Type text | `uid`, `value` |
29
+ | `fill_form` | Fill multiple fields | `elements` array |
30
+ | `hover` | Hover element | `uid` |
31
+ | `press_key` | Press key | `key` (e.g., "Enter") |
32
+ | `drag` | Drag element | `from_uid`, `to_uid` |
33
+ | `upload_file` | Upload file | `uid`, `filePath` |
34
+ | `handle_dialog` | Handle dialog | `action`: "accept"/"dismiss" |
35
+
36
+ ### Navigation
37
+
38
+ | Tool | Description | Parameters |
39
+ | --------------- | ------------- | ---------------------------------------------- |
40
+ | `navigate_page` | Navigate | `type`: "url"/"back"/"forward"/"reload", `url` |
41
+ | `new_page` | Open new page | `url` |
42
+ | `list_pages` | List pages | - |
43
+ | `select_page` | Switch page | `pageIdx` |
44
+ | `close_page` | Close page | `pageIdx` |
45
+ | `wait_for` | Wait for text | `text`, `timeout` |
46
+
47
+ ### Debugging
48
+
49
+ | Tool | Description | Parameters |
50
+ | ----------------------- | ------------------ | --------------------------- |
51
+ | `take_snapshot` | A11y tree snapshot | `verbose` |
52
+ | `take_screenshot` | Screenshot | `uid`, `fullPage`, `format` |
53
+ | `evaluate_script` | Run JS | `function`, `args` |
54
+ | `list_console_messages` | Console logs | `types` filter |
55
+ | `get_console_message` | Get message | `msgid` |
56
+
57
+ ### Network
58
+
59
+ | Tool | Description | Parameters |
60
+ | ----------------------- | --------------- | --------------------------- |
61
+ | `list_network_requests` | List requests | `resourceTypes`, `pageSize` |
62
+ | `get_network_request` | Request details | `reqid` |
63
+
64
+ ### Performance
65
+
66
+ | Tool | Description | Parameters |
67
+ | ----------------------------- | ----------- | ----------------------------- |
68
+ | `performance_start_trace` | Start trace | `reload`, `autoStop` |
69
+ | `performance_stop_trace` | Stop trace | - |
70
+ | `performance_analyze_insight` | Analyze | `insightSetId`, `insightName` |
71
+
72
+ ### Emulation
73
+
74
+ | Tool | Description | Parameters |
75
+ | ------------- | ------------------ | ---------------------------------------- |
76
+ | `emulate` | Emulate conditions | `networkConditions`, `cpuThrottlingRate` |
77
+ | `resize_page` | Resize viewport | `width`, `height` |
78
+
79
+ ## Tips
80
+
81
+ - **Always `take_snapshot` first** to get element `uid`s
82
+ - **Element uids change** after navigation - take fresh snapshot
83
+ - **Network conditions**: "Slow 3G", "Fast 3G", "Offline"
84
+
85
+ ## vs Playwright
86
+
87
+ - **chrome-devtools**: Performance profiling, network inspection, console - Chrome only
88
+ - **playwright**: Cross-browser testing - Chrome, Firefox, WebKit
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: polar
3
+ description: Polar payment platform integration for monetization, subscriptions, and license keys. Use when implementing checkout, managing products, or building customer portals.
4
+ ---
5
+
6
+ # Polar Integration
7
+
8
+ Polar is a merchant-of-record platform for digital products, subscriptions, and license keys.
9
+
10
+ ## What I Do
11
+
12
+ - Guide implementation of Polar checkout and payments
13
+ - Help with subscription management and billing
14
+ - Assist with license key validation
15
+ - Set up webhook handlers for payment events
16
+
17
+ ## When to Use Me
18
+
19
+ - Implementing checkout flow for a product
20
+ - Adding subscription billing to an app
21
+ - Setting up license key validation
22
+ - Building a customer portal
23
+ - Handling payment webhooks
24
+
25
+ ## Quick Start
26
+
27
+ ```bash
28
+ npm install @polar-sh/sdk
29
+ ```
30
+
31
+ ```typescript
32
+ import { Polar } from "@polar-sh/sdk";
33
+
34
+ const polar = new Polar({
35
+ accessToken: process.env.POLAR_ACCESS_TOKEN!,
36
+ server: "production", // or "sandbox"
37
+ });
38
+ ```
39
+
40
+ ## Key APIs
41
+
42
+ | API | Purpose |
43
+ | ----------------------- | --------------------------------- |
44
+ | `polar.products.*` | Create/manage products and prices |
45
+ | `polar.checkouts.*` | Create checkout sessions |
46
+ | `polar.subscriptions.*` | Manage subscriptions |
47
+ | `polar.orders.*` | View order history |
48
+ | `polar.customers.*` | Customer management |
49
+ | `polar.licenseKeys.*` | Issue and validate licenses |
50
+
51
+ ## Environment Variables
52
+
53
+ | Variable | Description |
54
+ | ---------------------- | ------------------------------- |
55
+ | `POLAR_ACCESS_TOKEN` | Organization Access Token (OAT) |
56
+ | `POLAR_WEBHOOK_SECRET` | Webhook signing secret |
57
+
58
+ ## Common Patterns
59
+
60
+ ### Create Checkout
61
+
62
+ ```typescript
63
+ const checkout = await polar.checkouts.create({
64
+ productId: "prod_xxx",
65
+ successUrl: "https://myapp.com/success",
66
+ });
67
+ // Redirect to checkout.url
68
+ ```
69
+
70
+ ### Validate License Key
71
+
72
+ ```typescript
73
+ const result = await polar.licenseKeys.validate({
74
+ key: "XXXX-XXXX-XXXX-XXXX",
75
+ organizationId: "org_xxx",
76
+ });
77
+ ```
78
+
79
+ ### Handle Webhook
80
+
81
+ ```typescript
82
+ import { validateEvent } from "@polar-sh/sdk/webhooks";
83
+
84
+ const event = validateEvent(body, signature, process.env.POLAR_WEBHOOK_SECRET!);
85
+ // event.type: "subscription.created", "order.created", etc.
86
+ ```
87
+
88
+ ## Links
89
+
90
+ - [Dashboard](https://polar.sh)
91
+ - [API Docs](https://docs.polar.sh/api-reference)
92
+ - [SDK](https://www.npmjs.com/package/@polar-sh/sdk)