mirror of
https://github.com/openai/skills.git
synced 2026-09-14 13:06:32 +03:00
Make latest model resolver self-starting
This commit is contained in:
@@ -8,17 +8,25 @@ description: "Use when the user asks how to build with OpenAI products or APIs,
|
||||
|
||||
Provide authoritative, current guidance from OpenAI developer docs using the developers.openai.com MCP server. "Docs MCP" means `mcp__openaiDeveloperDocs__search_openai_docs` and `mcp__openaiDeveloperDocs__fetch_openai_doc`; for API reference, schema, parameter, or required-field questions, also use `mcp__openaiDeveloperDocs__get_openapi_spec` when available. Official-domain web search is fallback after those tools are unavailable or unhelpful. Broad Codex questions use the manual helper before Docs MCP. This skill also owns model selection, API model migration, and prompt-upgrade guidance.
|
||||
|
||||
## Workflow Configuration
|
||||
## First action for latest-model changes
|
||||
|
||||
### Source Priority
|
||||
Before reading memory, inspecting the repo, fetching docs, or checking API credentials, classify the request:
|
||||
|
||||
- **Latest/current prompting guidance, or change requested + latest/current/newest/recommended/default/flagship/unspecified target:** immediately execute the platform wrapper and inspect its JSON output. Use `<skill-dir>/scripts/resolve-latest-model-info` on macOS/Linux and `<skill-dir>\scripts\resolve-latest-model-info.cmd` on native Windows. This includes asking how to prompt the latest model, changing prompts, a model picker, model references, an SDK integration, replacing an older named model with "the current model", or asking "which model should I migrate/upgrade to?". Do not directly fetch `latest-model.md` for this branch.
|
||||
- **Pure model-selection question only, with no prompting guidance or requested change:** directly fetch `https://developers.openai.com/api/docs/guides/latest-model.md`; do not run the resolver.
|
||||
- **Change requested + explicit target model:** preserve that target; do not run the latest-model resolver.
|
||||
|
||||
For the resolver branch, do not suppress or redirect its stdout. Success requires JSON containing `model`, `migrationGuideUrl`, and `promptingGuideUrl`; if the command exits without all three fields, run it once more before any fallback.
|
||||
|
||||
## Source Priority
|
||||
|
||||
- For Codex self-knowledge, use the Codex source route below; it owns when to use the manual helper, Docs MCP, or bounded uncertainty.
|
||||
- For non-Codex OpenAI docs questions, use `mcp__openaiDeveloperDocs__search_openai_docs` to find the most relevant doc pages.
|
||||
- For non-Codex OpenAI docs questions, fetch the relevant page with `mcp__openaiDeveloperDocs__fetch_openai_doc` before answering. If search is noisy, run a narrower Docs MCP search; when any plausible official OpenAI docs URL is known or found, try fetching that URL through Docs MCP before relying on web-search content.
|
||||
- For API reference, schema, parameter, or required-field questions, use `mcp__openaiDeveloperDocs__get_openapi_spec` when available to verify the API shape alongside the relevant guide or reference page.
|
||||
- Use `mcp__openaiDeveloperDocs__list_openai_docs` only when you need to browse or discover non-Codex pages without a clear query.
|
||||
- For model-selection, "latest model", or default-model questions, fetch `https://developers.openai.com/api/docs/guides/latest-model.md` first. If that is unavailable, load `references/latest-model.md`.
|
||||
- For model upgrades or prompt upgrades, run `node scripts/resolve-latest-model-info.js` only when the target is latest/current/default or otherwise unspecified; otherwise preserve the explicitly requested target.
|
||||
- For latest/current prompting guidance, model upgrades, or prompt upgrades, apply the first-action classifier above. Run the platform wrapper rather than the implementation file: `<skill-dir>/scripts/resolve-latest-model-info` on macOS/Linux or `<skill-dir>\scripts\resolve-latest-model-info.cmd` on native Windows. The wrapper uses `$NODE` or `%NODE%` when supplied, then PATH and bundled/system fallbacks. If it reports no usable runtime, call `load_workspace_dependencies` when available, set `NODE` to the returned Node.js executable, and retry the wrapper once.
|
||||
- For docs-only model-selection questions that do not ask to change an app, project, repo, model configuration, or prompts, fetch `https://developers.openai.com/api/docs/guides/latest-model.md` first. If that is unavailable, load `references/latest-model.md`.
|
||||
- Preserve explicit target requests: if the user names a target model like "migrate to GPT-5.4", keep that requested target even if `latest-model.md` names a newer model. Mention newer guidance only as optional.
|
||||
- If current remote guidance is needed, fetch both the returned migration and prompting guide URLs directly. If direct fetch fails, use MCP/search fallback; if that also fails, use bundled fallback references and disclose the fallback.
|
||||
|
||||
@@ -118,11 +126,9 @@ If MCP tools fail or no OpenAI docs resources are available:
|
||||
1. Clarify whether the request is general docs lookup, model selection, a model-string upgrade, prompt-upgrade guidance, or broader API/provider migration.
|
||||
2. For Codex self-knowledge requests, follow the Codex self-knowledge source procedure above.
|
||||
3. For model-selection or upgrade requests, prefer current remote docs over bundled references when the user asks for latest/current/default guidance.
|
||||
- Fetch `https://developers.openai.com/api/docs/guides/latest-model.md`.
|
||||
- Find the latest model ID and explicit migration or prompt-guidance links.
|
||||
- Prefer explicit links from the latest-model page over derived URLs.
|
||||
- For docs-only model-selection questions, fetch `https://developers.openai.com/api/docs/guides/latest-model.md`, find the latest model ID and explicit migration or prompt-guidance links, and prefer explicit links over derived URLs.
|
||||
- For explicit named-model requests, preserve the requested model target. Mention newer remote guidance only as optional.
|
||||
- For dynamic latest/current/default upgrades, run `node scripts/resolve-latest-model-info.js`, then fetch both returned guide URLs directly when possible.
|
||||
- For latest/current/default prompting guidance or dynamic upgrades, run the platform wrapper (`<skill-dir>/scripts/resolve-latest-model-info` on macOS/Linux or `<skill-dir>\scripts\resolve-latest-model-info.cmd` on native Windows) as the first docs operation before any direct latest-model.md fetch or API-key credential gate, then fetch both returned guide URLs directly when possible.
|
||||
- If direct guide fetch fails, use the developer-docs MCP tools or official OpenAI-domain search to find the same guide content.
|
||||
- If remote docs are unavailable, use bundled fallback references and say that fallback guidance was used.
|
||||
4. For model upgrades, keep changes narrow: update active OpenAI API model defaults and directly related prompts only when safe.
|
||||
|
||||
@@ -4,7 +4,7 @@ Use this guide when the user explicitly asks to upgrade an existing integration
|
||||
|
||||
## Freshness check
|
||||
|
||||
Before applying this bundled guide for a latest/current/default model upgrade, run `node scripts/resolve-latest-model-info.js` from the OpenAI Docs skill directory.
|
||||
Before applying this bundled guide for a latest/current/default model upgrade, run the platform wrapper from the OpenAI Docs skill directory: `scripts/resolve-latest-model-info` on macOS/Linux or `scripts\resolve-latest-model-info.cmd` on native Windows.
|
||||
|
||||
- If the command returns `modelSlug: "gpt-5p5"`, continue with this bundled guide and use `references/prompting-guide.md` when prompt updates are needed.
|
||||
- If the command returns a different `modelSlug`, fetch both the returned `migrationGuideUrl` and `promptingGuideUrl` and use them as the current source of truth instead of the bundled references.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
SCRIPT_PATH="$SCRIPT_DIR/resolve-latest-model-info.cjs"
|
||||
|
||||
if [ -n "${NODE:-}" ] && [ -x "$NODE" ]; then
|
||||
"$NODE" "$SCRIPT_PATH" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if command -v node >/dev/null 2>&1; then
|
||||
node "$SCRIPT_PATH" "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
for CANDIDATE in \
|
||||
"$HOME/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin/node" \
|
||||
"$HOME/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin/node" \
|
||||
"/opt/homebrew/bin/node" \
|
||||
"/usr/local/bin/node" \
|
||||
"/usr/bin/node"
|
||||
do
|
||||
if [ -x "$CANDIDATE" ]; then
|
||||
"$CANDIDATE" "$SCRIPT_PATH" "$@"
|
||||
exit $?
|
||||
fi
|
||||
done
|
||||
|
||||
echo "No usable Node runtime found for resolve-latest-model-info.cjs" >&2
|
||||
exit 127
|
||||
Executable → Regular
+24
-6
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Keep this entrypoint CommonJS-safe when the skill is copied into a type=module repo.
|
||||
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
|
||||
@@ -36,15 +38,31 @@ async function readSource(source) {
|
||||
return fs.readFile(path.resolve(source), "utf8");
|
||||
}
|
||||
|
||||
const response = await fetch(source, {
|
||||
headers: { accept: "text/markdown,text/plain,*/*" },
|
||||
});
|
||||
let lastError;
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
try {
|
||||
const response = await fetch(source, {
|
||||
headers: { accept: "text/markdown,text/plain,*/*" },
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`failed to fetch ${source}: ${response.status}`);
|
||||
if (response.ok) {
|
||||
return response.text();
|
||||
}
|
||||
|
||||
lastError = new Error("failed to fetch " + source + ": " + response.status);
|
||||
if (response.status < 500 && response.status !== 429) {
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
lastError = error;
|
||||
}
|
||||
|
||||
if (attempt < 3) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 250 * attempt));
|
||||
}
|
||||
}
|
||||
|
||||
return response.text();
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
function parseIndentedInfo(lines, startIndex) {
|
||||
@@ -0,0 +1,33 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
|
||||
set "SCRIPT_PATH=%~dp0resolve-latest-model-info.cjs"
|
||||
|
||||
if defined NODE (
|
||||
if exist "%NODE%" (
|
||||
"%NODE%" "%SCRIPT_PATH%" %*
|
||||
exit /b !ERRORLEVEL!
|
||||
)
|
||||
)
|
||||
|
||||
where node >nul 2>nul
|
||||
if not errorlevel 1 (
|
||||
node "%SCRIPT_PATH%" %*
|
||||
exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
||||
for %%N in (
|
||||
"%USERPROFILE%\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe"
|
||||
"%USERPROFILE%\.cache\codex-runtimes\codex-primary-runtime\dependencies\bin\node.exe"
|
||||
"%LOCALAPPDATA%\Programs\nodejs\node.exe"
|
||||
"%ProgramFiles%\nodejs\node.exe"
|
||||
"%ProgramFiles(x86)%\nodejs\node.exe"
|
||||
) do (
|
||||
if exist "%%~N" (
|
||||
"%%~N" "%SCRIPT_PATH%" %*
|
||||
exit /b !ERRORLEVEL!
|
||||
)
|
||||
)
|
||||
|
||||
>&2 echo No usable Node runtime found for resolve-latest-model-info.cjs
|
||||
exit /b 127
|
||||
Reference in New Issue
Block a user