Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
f5ddc03
Update core-libs
KennyDizi Jan 27, 2026
611c31d
@types/picomatch v4.0.2
KennyDizi Jan 27, 2026
e8f8b26
Merge branch 'dev' into sdk-upstream
KennyDizi Jan 28, 2026
18bd087
Update build process
KennyDizi Jan 28, 2026
7b5bcb8
Merge branch 'dev' into sdk-upstream
KennyDizi Jan 28, 2026
955fc8a
Merge branch 'dev' into sdk-upstream
KennyDizi Jan 28, 2026
904bc7a
Update core-libs
KennyDizi Jan 28, 2026
b53dfbe
Add build configs
KennyDizi Jan 28, 2026
b56404b
Add opencode config
KennyDizi Jan 28, 2026
19880a4
Update install shell script
KennyDizi Jan 28, 2026
4f91898
Fix rsbuild compatible
KennyDizi Jan 28, 2026
9bd6e40
v3.1.3
KennyDizi Jan 28, 2026
8a2b54f
Merge branch 'dev' into sdk-upstream
KennyDizi Jan 28, 2026
639389a
Update core-libs
KennyDizi Jan 28, 2026
138c391
Merge branch 'dev' into sdk-upstream
KennyDizi Jan 28, 2026
9850047
Update core-libs
KennyDizi Jan 28, 2026
57dfee4
Merge branch 'code-yeongyu:dev' into sdk-upstream
KennyDizi Jan 28, 2026
27bb086
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 28, 2026
3d3ff97
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 28, 2026
a469223
Update bun lock file
KennyDizi Jan 28, 2026
83e0b3c
remove unused files
KennyDizi Jan 28, 2026
744d7a8
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 28, 2026
556bd0d
update core-libs
KennyDizi Jan 28, 2026
e5db21a
oc sdk v1.1.40
KennyDizi Jan 28, 2026
96c4987
Fix the externalized `commonjs` build warning
KennyDizi Jan 28, 2026
1dabe13
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 29, 2026
f21821e
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 29, 2026
d68dc2b
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 29, 2026
5eab038
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 29, 2026
009a093
Update core-libs
KennyDizi Jan 29, 2026
4b9bc1b
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 29, 2026
1fe4a81
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
a2d71b1
Update core-libs
KennyDizi Jan 30, 2026
cd27693
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
738967c
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
0a2114c
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
faad542
Update core-libs
KennyDizi Jan 30, 2026
43570b3
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
b7a2e7f
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
3737bf5
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
8a5d491
Update test case
KennyDizi Jan 30, 2026
594ae57
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
df83b3f
Update `@rslib/core`
KennyDizi Jan 30, 2026
2aa6745
Update core-libs
KennyDizi Jan 30, 2026
8ef77b9
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 30, 2026
aca97ef
Update core-libs
KennyDizi Jan 30, 2026
b43e710
Update bunn lock file
KennyDizi Jan 30, 2026
2eea8dc
Update core-libs
KennyDizi Jan 31, 2026
459eb77
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 31, 2026
61f3a23
Update core-libs
KennyDizi Jan 31, 2026
ead6ff2
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 31, 2026
b1511b4
v3.1.10
KennyDizi Jan 31, 2026
e6bb7ee
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Jan 31, 2026
2c59428
Update bun lock file
KennyDizi Jan 31, 2026
e02b35b
Update core-libs
KennyDizi Feb 1, 2026
cf4a1b4
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
10f6cbc
Update lock file
KennyDizi Feb 1, 2026
9175c0e
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
673a248
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
dfe2ffa
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
7da3d42
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
9a38963
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
7097b18
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
be2c9bc
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
05fa62b
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 1, 2026
2582cd5
update bun lock file
KennyDizi Feb 1, 2026
f5a72a6
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 2, 2026
84d9ddf
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 2, 2026
eb0539c
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 2, 2026
d6ec489
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
791971e
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
274ede4
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
65b6ac3
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
7b76a84
Update core-libs
KennyDizi Feb 3, 2026
fc7bc0c
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
9e35145
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
7499c0b
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 3, 2026
6fe677e
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
bb8b7ea
Update lock file
KennyDizi Feb 4, 2026
99797b0
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
99f4a8a
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
3acb3d9
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
4e22cda
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
f120ccf
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
98f6606
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 4, 2026
e6759df
Update `opencode-ai` core-libs
KennyDizi Feb 4, 2026
53d35d0
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 5, 2026
280c7aa
Update core-libs
KennyDizi Feb 5, 2026
0baab86
Merge remote-tracking branch 'origin' into sdk-upstream
KennyDizi Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
400 changes: 356 additions & 44 deletions bun.lock

Large diffs are not rendered by default.

46 changes: 27 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./cli": {
"types": "./dist/cli",
"import": "./dist/cli/index.js"
},
"./schema.json": "./dist/oh-my-opencode.schema.json"
},
"scripts": {
"build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema",
"build:all": "bun run build && bun run build:binaries",
"build": "rslib build",
"build:all": "rslib build && bun run build:binaries",
"build:binaries": "bun run script/build-binaries.ts",
"build:schema": "bun run script/build-schema.ts",
"clean": "rm -rf dist",
"clean": "rslib clean",
"postinstall": "node postinstall.mjs",
"prepublishOnly": "bun run clean && bun run build",
"typecheck": "tsc --noEmit",
Expand All @@ -51,27 +55,31 @@
},
"homepage": "https://github.com/code-yeongyu/oh-my-opencode#readme",
"dependencies": {
"@ast-grep/cli": "^0.40.0",
"@ast-grep/napi": "^0.40.0",
"@clack/prompts": "^0.11.0",
"@code-yeongyu/comment-checker": "^0.6.1",
"@modelcontextprotocol/sdk": "^1.25.1",
"@opencode-ai/plugin": "^1.1.19",
"@opencode-ai/sdk": "^1.1.19",
"commander": "^14.0.2",
"detect-libc": "^2.0.0",
"@ast-grep/cli": "^0.40.5",
"@ast-grep/napi": "^0.40.5",
"@clack/prompts": "^1.0.0",
"@code-yeongyu/comment-checker": "^0.7.0",
"@modelcontextprotocol/sdk": "^1.26.0",
"@opencode-ai/plugin": "^1.1.51",
"@opencode-ai/sdk": "^1.1.51",
"commander": "^14.0.3",
"detect-libc": "^2.1.2",
"js-yaml": "^4.1.1",
"jsonc-parser": "^3.3.1",
"picocolors": "^1.1.1",
"picomatch": "^4.0.2",
"vscode-jsonrpc": "^8.2.0",
"zod": "^4.1.8"
"picomatch": "^4.0.3",
"vscode-jsonrpc": "^8.2.1",
"zod": "^4.3.6"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.56.2",
"@rsdoctor/core": "^1.5.1",
"@rsdoctor/rspack-plugin": "^1.5.1",
"@rslib/core": "^0.19.4",
"@types/js-yaml": "^4.0.9",
"@types/picomatch": "^3.0.2",
"bun-types": "1.3.6",
"typescript": "^5.7.3"
"@types/picomatch": "^4.0.2",
"bun-types": "^1.3.8",
"typescript": "^5.9.3"
},
"optionalDependencies": {
"oh-my-opencode-darwin-arm64": "3.2.3",
Expand All @@ -87,4 +95,4 @@
"@ast-grep/napi",
"@code-yeongyu/comment-checker"
]
}
}
42 changes: 42 additions & 0 deletions rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [
// Main plugin entry
{
format: 'esm',
bundle: true,
dts: {
bundle: true,
},
output: {
distPath: './dist',
},
source: {
entry: {
index: './src/index.ts',
},
},
},
// CLI entry
{
format: 'esm',
dts: {
bundle: false,
},
output: {
distPath: './dist/cli',
},
source: {
entry: {
index: './src/cli/index.ts',
},
},
},
],
output: {
target: 'node', // Bun supports Node.js APIs
cleanDistPath: true, // Clean dist directory before build
externals: ['bun'], // Don't bundle 'bun' runtime imports
},
});
105 changes: 105 additions & 0 deletions scripts/analyze-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env node
import { promises as fs } from 'fs';
import path from 'path';

console.log('=== Manual Bundle Analysis ===\n');

try {
// Read the bundle file
const bundlePath = './dist/index.js';
const bundleContent = await fs.readFile(bundlePath, 'utf-8');

console.log(`📂 Reading bundle: ${bundlePath}`);
console.log(`📏 Bundle size: ${(bundleContent.length / 1024).toFixed(2)} KB\n`);

// Basic statistics
const lines = bundleContent.split('\n').length;
const wordCount = bundleContent.split(/\s+/).length;

console.log('📊 BASIC METRICS:');
console.log(` Lines of code: ${lines}`);
console.log(` Word count: ${wordCount}`);
console.log(` File size: ${bundleContent.length} bytes\n`);

// Analyze code structure
const functionMatches = bundleContent.match(/function\s+\w+\s*\(/g);
const arrowFunctionMatches = bundleContent.match(/=>/g);
const classMatches = bundleContent.match(/\bclass\s+\w+/g);

console.log('🏗️ CODE STRUCTURE:');
console.log(` Function declarations: ${functionMatches?.length || 0}`);
console.log(` Arrow functions: ${arrowFunctionMatches?.length || 0}`);
console.log(` Class definitions: ${classMatches?.length || 0}\n`);

// Find common patterns
const importRegex = /import\s+.*from\s+['"](.+)['"]/g;
const importCount = (bundleContent.match(importRegex) || []).length;

const requireRegex = /require\s*\(\s*['"](.+)['"]\s*\)/g;
const requireCount = (bundleContent.match(requireRegex) || []).length;

console.log('🔗 IMPORTS/REQUIRES:');
console.log(` ES6 imports: ${importCount}`);
console.log(` CommonJS requires: ${requireCount}\n`);

// Find large dependencies
const largeDependencies = [];
const depRegex = /['"]([^'"]+\.(js|ts|json))['"]/g;
let match;
while ((match = depRegex.exec(bundleContent)) !== null) {
const depPath = match[1];
// Skip built-in modules, relative paths, and small files
if (!depPath.startsWith('.') && !depPath.startsWith('/') && depPath.length > 5) {
largeDependencies.push(depPath);
}
}

console.log('📦 POTENTIAL DEPENDENCIES:');
largeDependencies.slice(0, 20).forEach(dep => {
console.log(` - ${dep}`);
});
if (largeDependencies.length > 20) {
console.log(` ... and ${largeDependencies.length - 20} more`);
}

// Check for specific patterns
const hasConfig = bundleContent.includes('config');
const hasAgents = bundleContent.includes('agents');
const hasHooks = bundleContent.includes('hooks');
const hasTools = bundleContent.includes('tools');
const hasMCP = bundleContent.includes('mcp');

console.log('\n🔍 FEATURE DETECTION:');
console.log(` Config handling: ${hasConfig ? '✓' : '✗'}`);
console.log(` Agent definitions: ${hasAgents ? '✓' : '✗'}`);
console.log(` Hook system: ${hasHooks ? '✓' : '✗'}`);
console.log(` Tool registry: ${hasTools ? '✓' : '✗'}`);
console.log(` MCP integration: ${hasMCP ? '✓' : '✗'}\n`);

// Module size breakdown (approximate by file extension)
const jsFiles = bundleContent.match(/['"]([^'"]+\.js)['"]/g) || [];
const tsFiles = bundleContent.match(/['"]([^'"]+\.ts)['"]/g) || [];
const dtsFiles = bundleContent.match(/['"]([^'"]+\.d\.ts)['"]/g) || [];

console.log('📄 FILE TYPE BREAKDOWN:');
console.log(` JavaScript files referenced: ${jsFiles.length}`);
console.log(` TypeScript files referenced: ${tsFiles.length}`);
console.log(` Type definition files: ${dtsFiles.length}\n`);

// Optimization opportunities
console.log('💡 OPTIMIZATION RECOMMENDATIONS:');
console.log(' 1. Code splitting: Consider splitting large bundles by feature');
console.log(' 2. Dynamic imports: Lazy load agents, hooks, and tools');
console.log(' 3. Tree shaking: Ensure unused exports are eliminated');
console.log(' 4. Dead code elimination: Remove commented-out code and tests');
console.log(' 5. Bundle size: 1.0 MB is reasonable but could be optimized');
console.log(' 6. Dependency analysis: Audit for unused dependencies');
console.log(' 7. Minification: Already using Terser/Esbuild minification');

console.log('\n✨ Analysis complete! Use Rsdoctor Web UI (http://localhost:9100) for interactive analysis');

} catch (err) {
console.error('❌ Analysis failed:', err);
console.error('\nStack trace:', err.stack);
process.exit(1);
}
4 changes: 3 additions & 1 deletion src/tools/ast-grep/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ export function checkEnvironment(): EnvironmentCheckResult {

// Check NAPI availability
try {
require("@ast-grep/napi")
const require = createRequire(import.meta.url)
const napiModuleId = "@ast-grep/" + "napi"
require(napiModuleId)
result.napi.available = true
} catch (e) {
result.napi.available = false
Expand Down
43 changes: 16 additions & 27 deletions src/tools/look-at/tools.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { describe, expect, test } from "bun:test"
import type { ToolContext } from "@opencode-ai/plugin/tool"
import { normalizeArgs, validateArgs, createLookAt } from "./tools"
import type { ToolContext } from "@opencode-ai/plugin/tool";
import { describe, expect, test } from "bun:test";
import { createLookAt, normalizeArgs, validateArgs } from "./tools";

const mockContext: ToolContext = {
sessionID: "test-session",
messageID: "test-message",
agent: "test-agent",
abort: new AbortController().signal,
directory: "/test/project",
worktree: "/test/project",
metadata: (_input: { title?: string; metadata?: Record<string, unknown> }) => {},
ask: (_input: { permission: string; patterns: string[]; always: string[]; metadata: Record<string, unknown> }) => Promise.resolve(),
}

describe("look-at tool", () => {
describe("normalizeArgs", () => {
Expand Down Expand Up @@ -131,20 +142,9 @@ describe("look-at tool", () => {
directory: "/project",
} as any)

const toolContext: ToolContext = {
sessionID: "parent-session",
messageID: "parent-message",
agent: "sisyphus",
directory: "/project",
worktree: "/project",
abort: new AbortController().signal,
metadata: () => {},
ask: async () => {},
}

const result = await tool.execute(
{ file_path: "/test/file.png", goal: "analyze image" },
toolContext
mockContext
)

expect(result).toContain("Error: Failed to analyze")
Expand Down Expand Up @@ -173,20 +173,9 @@ describe("look-at tool", () => {
directory: "/project",
} as any)

const toolContext: ToolContext = {
sessionID: "parent-session",
messageID: "parent-message",
agent: "sisyphus",
directory: "/project",
worktree: "/project",
abort: new AbortController().signal,
metadata: () => {},
ask: async () => {},
}

const result = await tool.execute(
{ file_path: "/test/file.pdf", goal: "extract text" },
toolContext
mockContext
)

expect(result).toContain("Error: Failed to send prompt")
Expand Down
Loading