chore(.agents/skills): update existing skills
This commit is contained in:
@@ -28,7 +28,7 @@ Use this skill for `xsai` code, package selection, API selection, canonical exam
|
||||
- If the user has not chosen xsAI yet, confirm the task fits an OpenAI-compatible surface before recommending it.
|
||||
- Prefer the smallest package that solves the task. Use the umbrella `xsai` package only when the user needs several features at once or explicitly wants one dependency.
|
||||
- When writing or editing code, read `references/recipes.md` first and start from the closest canonical example.
|
||||
- Keep examples minimal and runnable. Include `baseURL` and `model` explicitly. Include `apiKey` for hosted providers; omit it only when the target endpoint truly does not need one.
|
||||
- Keep examples minimal and runnable. Include `baseURL` and `model` explicitly. For hosted providers, show `apiKey` wired from `process.env` in Node.js and from `localStorage` in the browser; omit it only when the target endpoint truly does not need one. Do not recommend hardcoding secrets.
|
||||
- Preserve the project's existing schema library and provider wiring unless there is a clear reason to change them.
|
||||
- Keep recommendations aligned with xsAI's scope: OpenAI-compatible, Fetch-based, runtime-portable, and intentionally narrow.
|
||||
- If the user is optimizing for bundle or install size, explicitly prefer granular packages such as `@xsai/generate-text` over `xsai`.
|
||||
@@ -56,11 +56,11 @@ Use this skill for `xsai` code, package selection, API selection, canonical exam
|
||||
## Key constraints
|
||||
|
||||
- `baseURL` and `model` are usually required in practice for xsAI calls.
|
||||
- `apiKey` is provider-dependent. Most hosted providers need it; local or proxy endpoints may not.
|
||||
- `apiKey` is provider-dependent. Most hosted providers need it; local or proxy endpoints may not. In Node.js, prefer `process.env`. In browsers, prefer reading from `localStorage`. Do not recommend hardcoding API keys.
|
||||
- xsAI is OpenAI-compatible-first. Do not imply support for non-compatible provider APIs.
|
||||
- `streamText()` returns immediately; callers consume `textStream`, `fullStream`, and result promises asynchronously.
|
||||
- `streamObject()` is async because schema conversion happens before streaming starts.
|
||||
- `maxSteps` controls repeated tool-use loops by issuing additional API calls with tool results appended.
|
||||
- `stopWhen` controls repeated tool-use loops with explicit stop predicates such as `stepCountAtLeast()` and `hasToolCall()`.
|
||||
- `generateObject()`, `streamObject()`, and `tool()` rely on `xsschema`; some schema vendors need extra JSON Schema converter packages.
|
||||
- xsAI is designed to stay small. Avoid recommending the umbrella package when a smaller package is enough.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
interface:
|
||||
display_name: 'xsAI'
|
||||
short_description: 'Use xsAI for minimal OpenAI-compatible code'
|
||||
default_prompt: 'Use $xsai to choose the smallest xsAI package and build a runnable OpenAI-compatible example.'
|
||||
display_name: xsAI
|
||||
short_description: Use xsAI for minimal OpenAI-compatible code
|
||||
default_prompt: Use $xsai to choose the smallest xsAI package and build a runnable OpenAI-compatible example.
|
||||
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
|
||||
@@ -7,7 +7,7 @@ Use this reference when the user wants code, when you are editing xsAI code, or
|
||||
- Prefer granular `@xsai/*` imports in new examples.
|
||||
- Switch to the umbrella `xsai` package only when the repo already uses it or the user explicitly wants one dependency.
|
||||
- Keep `baseURL` and `model` explicit.
|
||||
- Include `apiKey` for hosted providers. For local or proxy endpoints, only include it if the target actually requires one.
|
||||
- Include `apiKey` for hosted providers. In Node.js examples, prefer `process.env`. In browser examples, prefer `localStorage`. For local or proxy endpoints, only include it if the target actually requires one. Do not hardcode secrets.
|
||||
- Preserve the repo's existing schema library instead of swapping between Zod, Valibot, ArkType, or Effect without a reason.
|
||||
|
||||
## Minimal text generation
|
||||
@@ -36,12 +36,15 @@ const { text } = await generateText({
|
||||
|
||||
Use this as the default starting point for simple scripts, tests, and one-shot helpers.
|
||||
|
||||
These examples use `node:process` because they target Node.js. For browser examples, prefer reading the API key from `localStorage` instead of hardcoding it.
|
||||
|
||||
## Streaming text with tools
|
||||
|
||||
```ts
|
||||
import { env } from 'node:process'
|
||||
|
||||
import { streamText } from '@xsai/stream-text'
|
||||
import { stepCountAtLeast } from '@xsai/stream-text/shared-chat'
|
||||
import { tool } from '@xsai/tool'
|
||||
|
||||
import * as v from 'valibot'
|
||||
@@ -59,7 +62,6 @@ const add = await tool({
|
||||
const { fullStream } = streamText({
|
||||
apiKey: env.OPENAI_API_KEY!,
|
||||
baseURL: 'https://api.openai.com/v1/',
|
||||
maxSteps: 2,
|
||||
messages: [
|
||||
{
|
||||
content: 'You are a helpful assistant.',
|
||||
@@ -71,6 +73,7 @@ const { fullStream } = streamText({
|
||||
},
|
||||
],
|
||||
model: 'gpt-4o',
|
||||
stopWhen: stepCountAtLeast(2),
|
||||
toolChoice: 'required',
|
||||
tools: [add],
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ For chat-style APIs, expect common options such as:
|
||||
- `seed`
|
||||
- `toolChoice`
|
||||
- `tools`
|
||||
- `maxSteps`
|
||||
- `stopWhen`
|
||||
|
||||
## `generateText`
|
||||
|
||||
@@ -64,7 +64,9 @@ It returns immediately and exposes:
|
||||
|
||||
## Tool loops
|
||||
|
||||
- `maxSteps` enables repeated tool-use loops.
|
||||
- `stopWhen` enables repeated tool-use loops with explicit predicates.
|
||||
- Reach for `stepCountAtLeast(n)` as the default loop bound.
|
||||
- Combine conditions with `and()`, `or()`, and `not()` when the stop logic is more specific.
|
||||
- Each step appends assistant output and tool results, then makes another API call if needed.
|
||||
- Use `toolChoice: 'required'` when the model must call a tool.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user