docs(codemode): narrow chaining guidance

This commit is contained in:
Aiden Cline 2026-07-06 18:20:32 -05:00
commit d7d0113591
3 changed files with 5 additions and 4 deletions

View file

@ -615,8 +615,8 @@ export const prepare = <R>(tools: HostTools<R>, catalogBudget = defaultCatalogBu
"",
"## Language",
"",
"Use common JavaScript data operations, functions, control flow, selected standard-library methods, and tool calls. Promises support await, then/catch/finally, and Promise.all/allSettled/race/resolve/reject. Built-ins include Date, RegExp, Map, Set, URL, URLSearchParams, and URI encoding helpers.",
"Modules/imports, classes, generators, timers, fetch, eval, prototype access, and unlisted methods are unavailable. Use Code Mode tools for external operations.",
"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, and unlisted methods are unavailable. Use Code Mode tools for external operations. Use await with try/catch.",
"Dates and URLs serialize to strings at data boundaries; Map/Set/RegExp/URLSearchParams serialize to `{}`.",
]

View file

@ -655,7 +655,9 @@ describe("CodeMode public contract", () => {
for (const missing of ["Modules/imports", "classes", "generators", "fetch"]) {
expect(instructions).toContain(missing)
}
expect(instructions).toContain("Promises support await, then/catch/finally")
expect(instructions).toContain("selected standard-library methods, and awaited tool calls")
expect(instructions).toContain("Use await with try/catch")
expect(instructions).not.toContain("promise chaining are unavailable")
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")

View file

@ -184,7 +184,6 @@ it.effect("advertises MCP output schemas to Code Mode", () =>
const execute = (yield* toolDefinitions(registry)).find((tool) => tool.name === "execute")
expect(execute?.description).toContain("tools.demo.search(input: {}): Promise<{\n ok: boolean,\n}>")
expect(execute?.description).toContain("Promises support await, then/catch/finally")
expect(execute?.description).not.toContain("promise chaining are unavailable")
}),
)