فهرست منبع

docs(codemode): clarify implicit return guidance (#35763)

Co-authored-by: Kit Langton <kit.langton@gmail.com>
opencode-agent[bot] 1 ماه پیش
والد
کامیت
cb18a42a47
2فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 1 0
      packages/codemode/src/tool-runtime.ts
  2. 3 0
      packages/codemode/test/codemode.test.ts

+ 1 - 0
packages/codemode/src/tool-runtime.ts

@@ -617,6 +617,7 @@ export const prepare = <R>(tools: HostTools<R>, catalogBudget = defaultCatalogBu
     "",
     "Use common JavaScript data operations, functions, control flow, selected standard-library methods, and awaited tool calls. Built-ins include Date, RegExp, Map, Set, URL, URLSearchParams, and URI encoding helpers.",
     "Modules/imports, classes, generators, timers, fetch, eval, prototype access, unlisted methods, and promise chaining are unavailable. Use Code Mode tools for external operations. Use await with try/catch.",
+    "Prefer explicit `return`; otherwise only the final top-level expression becomes the result.",
     "Dates and URLs serialize to strings at data boundaries; Map/Set/RegExp/URLSearchParams serialize to `{}`.",
   ]
 

+ 3 - 0
packages/codemode/test/codemode.test.ts

@@ -658,6 +658,9 @@ describe("CodeMode public contract", () => {
     expect(instructions).toContain("URL, URLSearchParams, and URI encoding helpers")
     expect(instructions).not.toContain("host globals")
     expect(instructions).toContain("Use Code Mode tools for external operations")
+    expect(instructions).toContain(
+      "Prefer explicit `return`; otherwise only the final top-level expression becomes the result.",
+    )
     expect(instructions).toContain(
       "Dates and URLs serialize to strings at data boundaries; Map/Set/RegExp/URLSearchParams serialize to `{}`.",
     )