Merge branch 'v0.8.0' of github.com:ZSeven-W/openpencil into v0.8.0

This commit is contained in:
Fini 2026-05-04 21:45:19 +08:00
parent a4b7f62e9a
commit 1f2d3c5e1d
2 changed files with 26 additions and 9 deletions

View file

@ -451,6 +451,23 @@ async function executeSubAgent(
reducedComplexity,
);
// When element tools are enabled, the ELEMENT_TOOL_OUTPUT_FORMAT block
// (appended below) is the authoritative output-format instruction —
// teaching the model to emit `<op_tool>` tags. The jsonl-format /
// jsonl-format-simplified skills lead with a CRITICAL directive saying
// "Output ONLY ```json … Do NOT use tool calls", which directly conflicts
// with `<op_tool>` and confuses weak models (MiniMax / GLM / Kimi):
// they anchor on the front-of-prompt CRITICAL and emit raw JSONL,
// bypassing every element tool — which defeats the entire point of the
// n-tools-per-element design (stability for weak models in the built-in
// sub-agent path). Drop those two skills here so ELEMENT_TOOL_OUTPUT_FORMAT
// is the only output-format instruction the model sees.
if (elementToolsEnabled) {
resolvedSkills = resolvedSkills.filter(
(s) => s.meta.name !== 'jsonl-format' && s.meta.name !== 'jsonl-format-simplified',
);
}
const skillPrompt = resolvedSkills.map((s) => s.content).join('\n\n');
const systemPrompt = elementToolsEnabled
? skillPrompt + '\n\n' + ELEMENT_TOOL_OUTPUT_FORMAT

View file

@ -10,14 +10,16 @@ category: base
---
<!--
IMPORTANT: This skill is gated by the `hasMcpTools` flag. It only
auto-loads into the generation-phase prompt when the caller declares
the AI has live access to MCP element tools (external clients:
Claude Code / Codex / Gemini CLI / Cursor). The embedded orchestrator
in apps/web emits single-shot JSON and cannot call MCP tools — this
skill would be 1500 tokens of dead weight there, so it stays excluded.
IMPORTANT: This skill is gated by the `hasMcpTools` flag. It auto-loads
into the generation-phase prompt for any caller that declares element-
tool access — both external MCP clients (Claude Code / Codex / Gemini
CLI / Cursor) AND the apps/web embedded orchestrator when
VITE_ENABLE_ELEMENT_TOOLS is on. In the embedded path the model emits
`<op_tool>` blocks (parsed by `tryParseAllElementToolOutputs` and
dispatched via `element-tools-dispatcher.ts`), giving weak models the
same schema-locked surface as external MCP clients.
External MCP clients still retrieve the content explicitly via
External MCP clients can also retrieve this content explicitly via
get_design_prompt(section='elements'), which bypasses resolveSkills'
trigger filter (uses getSkillByName for direct lookup).
@ -50,8 +52,6 @@ Multi-tool example — a "Notifications" settings section with a header + 4 togg
## Theme handling — when to pass `theme: 'system'`
> **This section applies to the MCP tool-call path only** (codex CLI / Claude Code / Cursor calling `add_X_v1` directly). The web-app sub-agent JSONL path forbids tool calls — there, write `$color-*` / `$type-*` / `$spacing-*` / `$radius-*` refs directly in JSONL fills/fontSize/etc. See the **DESIGN SYSTEM TOKENS** section in `jsonl-format.md` for the available token names and when refs vs literals are appropriate.
**Default to `theme: 'system'`** for every v1 tool call. This makes the output respect the user's design system (`doc.variables` / `doc.themes`):
- If user has seeded `applySemanticPalette(doc)` or set custom token values, v1 'system' mode emits `$color-*` / `$type-*` / `$spacing-*` / `$radius-*` refs that resolve to user's design system at paint time.