oh-my-opencode 0.1.18 → 0.1.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 (2) hide show
  1. package/dist/index.js +23 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -15759,25 +15759,22 @@ function showOutputToUser(context, output) {
15759
15759
  const ctx = context;
15760
15760
  ctx.metadata?.({ metadata: { output } });
15761
15761
  }
15762
- var JS_TS_LANGUAGES = ["javascript", "typescript", "tsx"];
15763
- function validatePatternForCli(pattern, lang) {
15764
- if (!JS_TS_LANGUAGES.includes(lang)) {
15765
- return;
15766
- }
15762
+ function getEmptyResultHint(pattern, lang) {
15767
15763
  const src = pattern.trim();
15768
- const incompleteFunctionDecl = /^(export\s+)?(default\s+)?(async\s+)?function\s+\$[A-Z_][A-Z0-9_]*\s*$/i.test(src);
15769
- if (incompleteFunctionDecl) {
15770
- throw new Error(`Incomplete AST pattern for ${lang}: "${pattern}"
15771
-
15772
- ` + `ast-grep requires complete AST nodes. Function declarations must include parameters and body.
15773
-
15774
- ` + `Examples of correct patterns:
15775
- ` + ` - "export async function $NAME($$$) { $$$ }" (matches export async functions)
15776
- ` + ` - "function $NAME($$$) { $$$ }" (matches all function declarations)
15777
- ` + ` - "async function $NAME($$$) { $$$ }" (matches async functions)
15778
-
15779
- ` + `Your pattern "${pattern}" is missing the parameter list and body.`);
15764
+ if (lang === "python") {
15765
+ if (src.startsWith("class ") && src.endsWith(":")) {
15766
+ return `\uD83D\uDCA1 Hint: Python class patterns need body. Try "class $NAME" or include body with $$$BODY`;
15767
+ }
15768
+ if ((src.startsWith("def ") || src.startsWith("async def ")) && src.endsWith(":")) {
15769
+ return `\uD83D\uDCA1 Hint: Python function patterns need body. Try "def $FUNC($$$):\\n $$$BODY"`;
15770
+ }
15780
15771
  }
15772
+ if (["javascript", "typescript", "tsx"].includes(lang)) {
15773
+ if (/^(export\s+)?(async\s+)?function\s+\$[A-Z_]+\s*$/i.test(src)) {
15774
+ return `\uD83D\uDCA1 Hint: Function patterns need params and body. Try "function $NAME($$$) { $$$ }"`;
15775
+ }
15776
+ }
15777
+ return null;
15781
15778
  }
15782
15779
  var ast_grep_search = tool({
15783
15780
  description: "Search code patterns across filesystem using AST-aware matching. Supports 25 languages. " + "Use meta-variables: $VAR (single node), $$$ (multiple nodes). " + "IMPORTANT: Patterns must be complete AST nodes (valid code). " + "For functions, include params and body: 'export async function $NAME($$$) { $$$ }' not 'export async function $NAME'. " + "Examples: 'console.log($MSG)', 'def $FUNC($$$):', 'async function $NAME($$$)'",
@@ -15790,7 +15787,6 @@ var ast_grep_search = tool({
15790
15787
  },
15791
15788
  execute: async (args, context) => {
15792
15789
  try {
15793
- validatePatternForCli(args.pattern, args.lang);
15794
15790
  const matches = await runSg({
15795
15791
  pattern: args.pattern,
15796
15792
  lang: args.lang,
@@ -15798,7 +15794,15 @@ var ast_grep_search = tool({
15798
15794
  globs: args.globs,
15799
15795
  context: args.context
15800
15796
  });
15801
- const output = formatSearchResult(matches);
15797
+ let output = formatSearchResult(matches);
15798
+ if (matches.length === 0) {
15799
+ const hint = getEmptyResultHint(args.pattern, args.lang);
15800
+ if (hint) {
15801
+ output += `
15802
+
15803
+ ${hint}`;
15804
+ }
15805
+ }
15802
15806
  showOutputToUser(context, output);
15803
15807
  return output;
15804
15808
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",