@slatesvideo/shared 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics/events.d.ts +155 -0
- package/dist/analytics/events.js +430 -0
- package/dist/clients/cloud.d.ts +4 -0
- package/dist/clients/cloud.js +11 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -0
- package/dist/manual/content.d.ts +1 -1
- package/dist/manual/content.js +1 -1
- package/dist/operations/index.d.ts +14 -7
- package/dist/operations/index.js +379 -160
- package/dist/operations/surface.d.ts +6 -2
- package/dist/operations/surface.js +30 -5
- package/dist/prompts/agent-doctrine.d.ts +4 -4
- package/dist/prompts/agent-doctrine.js +63 -55
- package/dist/prompts/banned-tokens.d.ts +18 -0
- package/dist/prompts/banned-tokens.js +59 -4
- package/dist/prompts/guide-discovery.d.ts +23 -0
- package/dist/prompts/guide-discovery.js +39 -0
- package/dist/prompts/guide-retrieval.js +1 -1
- package/dist/prompts/model-capabilities.d.ts +8 -9
- package/dist/prompts/model-capabilities.js +13 -53
- package/dist/prompts/model-facts.d.ts +3 -3
- package/dist/prompts/model-facts.js +15 -26
- package/dist/prompts/partials.generated.js +6 -3
- package/dist/prompts/prompting-tips.d.ts +1 -1
- package/dist/prompts/prompting-tips.js +27 -69
- package/dist/prompts/search-terms.d.ts +3 -0
- package/dist/prompts/search-terms.js +24 -0
- package/dist/prompts/shot-grammar.d.ts +2 -2
- package/dist/prompts/shot-grammar.js +2 -2
- package/dist/skills/content.js +36 -37
- package/dist/skills/metadata.d.ts +7 -0
- package/dist/skills/metadata.js +29 -0
- package/dist/update-check.js +1 -1
- package/exports/slates-chatgpt-images/generated/SKILL.md +7 -1
- package/exports/slates-chatgpt-images/generated/slates-chatgpt-images.skill +0 -0
- package/exports/slates-prompt-builder/generated/SKILL.md +28 -16
- package/exports/slates-prompt-builder/generated/reference-character.md +12 -13
- package/exports/slates-prompt-builder/generated/reference-content-policy.md +2 -2
- package/exports/slates-prompt-builder/generated/reference-gpt-image-2-5.md +191 -0
- package/exports/slates-prompt-builder/generated/reference-kling.md +32 -11
- package/exports/slates-prompt-builder/generated/reference-nano-banana.md +24 -6
- package/exports/slates-prompt-builder/generated/reference-omni-flash.md +65 -0
- package/exports/slates-prompt-builder/generated/reference-seedance-2-5.md +362 -0
- package/exports/slates-prompt-builder/generated/reference-seedance.md +34 -4
- package/exports/slates-prompt-builder/generated/slates-prompt-builder-manifest.json +77 -23
- package/exports/slates-prompt-builder/generated/slates-prompt-builder.skill +0 -0
- package/package.json +6 -2
- package/skills/_partials/blender-action-curves.md +24 -0
- package/skills/_partials/iteration-diagnosis.md +5 -0
- package/skills/_partials/model-routing.md +35 -0
- package/skills/_partials/seedance-25-timestamps.md +2 -2
- package/skills/_partials/still-gate.md +2 -2
- package/skills/_partials/thresholds.md +1 -1
- package/skills/slates-blocking-to-prompt.md +15 -13
- package/skills/slates-camera-language.md +45 -7
- package/skills/slates-character-identity.md +8 -6
- package/skills/slates-chatgpt-images.md +7 -1
- package/skills/slates-cinematic-look.md +1 -1
- package/skills/slates-content-policy.md +4 -6
- package/skills/slates-cost-discipline.md +18 -12
- package/skills/slates-dialogue-blocking.md +6 -6
- package/skills/slates-direct-response-ad.md +1 -1
- package/skills/slates-edit-and-iterate.md +12 -4
- package/skills/slates-model-selection.md +82 -90
- package/skills/slates-one-prompt-film.md +1 -1
- package/skills/slates-previs-blocking.md +44 -13
- package/skills/slates-project-organization.md +2 -2
- package/skills/slates-prompting-elevenlabs.md +4 -4
- package/skills/slates-prompting-flux-2-max.md +2 -3
- package/skills/slates-prompting-gpt-image-2-5.md +2 -2
- package/skills/slates-prompting-inworld-tts.md +174 -174
- package/skills/slates-prompting-kling-v3.md +11 -9
- package/skills/slates-prompting-lip-sync.md +15 -15
- package/skills/slates-prompting-ltx-2-5.md +5 -6
- package/skills/slates-prompting-minimax-h3.md +11 -11
- package/skills/slates-prompting-motion-transfer.md +8 -8
- package/skills/slates-prompting-nano-banana-2.md +8 -4
- package/skills/slates-prompting-omni-flash.md +9 -9
- package/skills/slates-prompting-seed-audio.md +24 -4
- package/skills/slates-prompting-seedance-2-5.md +40 -30
- package/skills/slates-prompting-seedance.md +4 -4
- package/skills/slates-prompting-seedream-5-lite.md +6 -6
- package/skills/slates-restyle-from-blocking.md +2 -2
- package/skills/slates-script-craft.md +1 -1
- package/skills/slates-shot-variety.md +1 -1
- package/skills/slates-storyboard-from-script.md +1 -1
- package/skills/slates-style-prompting.md +56 -54
- package/skills/slates-ugc-influencer-ad.md +1 -1
- package/skills/slates-vision-feedback-loop.md +20 -12
- package/skills/slates-prompting-veo-3.md +0 -224
|
@@ -61,12 +61,16 @@ export declare function toolDefinition(op: SurfaceOp): ToolDefinition;
|
|
|
61
61
|
* Render a tool surface.
|
|
62
62
|
*
|
|
63
63
|
* `desktop` sends `core` plus whatever groups have been loaded this run; `mcp`
|
|
64
|
-
* renders
|
|
65
|
-
* `--tools=compact`.
|
|
64
|
+
* renders every definition for the fixed MCP list.
|
|
66
65
|
*/
|
|
67
66
|
export declare function toolDefinitions(ops: readonly SurfaceOp[], opts: {
|
|
68
67
|
surface: 'desktop' | 'mcp';
|
|
69
68
|
groups?: readonly OperationGroup[];
|
|
70
69
|
names?: readonly string[];
|
|
71
70
|
}): ToolDefinition[];
|
|
71
|
+
/** Rank exact task words by rarity across the current registry, returning at most ten. */
|
|
72
|
+
export declare function searchTools<T extends Pick<SurfaceOp, 'id' | 'description'>>(operations: readonly T[], query: string): Array<{
|
|
73
|
+
op: T;
|
|
74
|
+
score: number;
|
|
75
|
+
}>;
|
|
72
76
|
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
// mechanism: we build every turn there, so a load reaches the model. The
|
|
16
16
|
// MCP server lists every op and leaves hiding definitions to the host
|
|
17
17
|
// (tiering there left Claude and Codex users unable to generate in 0.6.0;
|
|
18
|
-
// see the TOOLS comment in packages/mcp/src/server.ts).
|
|
19
|
-
// is the opt-in exception.
|
|
18
|
+
// see the TOOLS comment in packages/mcp/src/server.ts).
|
|
20
19
|
//
|
|
21
20
|
// 3. ONE SCHEMA RENDERER. The desktop rendered `$refStrategy: 'none'` and
|
|
22
21
|
// the MCP server rendered `target: 'openApi3'`, so "the two surfaces
|
|
@@ -29,6 +28,7 @@
|
|
|
29
28
|
// an op whose `run` body posts is a lie that lets a host auto-approve a
|
|
30
29
|
// mutation, so the check has to be able to catch it, and it is mutation-tested.
|
|
31
30
|
// ============================================================
|
|
31
|
+
import { searchTerms } from '../prompts/search-terms.js';
|
|
32
32
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
33
33
|
// ── 1. Annotations ──────────────────────────────────────────────────────────
|
|
34
34
|
/** Ops that only read. Prefixes, because the verb IS the first word of the id. */
|
|
@@ -169,6 +169,7 @@ export const OPERATION_GROUPS = {
|
|
|
169
169
|
// Rename, delete, reorder. The 63-op CRUD tail the review measured at 39.5 KB.
|
|
170
170
|
admin: [
|
|
171
171
|
'slates_update_project',
|
|
172
|
+
'slates_update_asset',
|
|
172
173
|
'slates_delete_project',
|
|
173
174
|
'slates_delete_asset',
|
|
174
175
|
'slates_update_character',
|
|
@@ -221,7 +222,7 @@ export function tierFor(id) {
|
|
|
221
222
|
export const GROUP_SUMMARY = {
|
|
222
223
|
library: 'folders, the Library (user-named categories of saved references: characters, locations, products, looks), moving and copying assets and Library items between projects, moving a project into the current projects folder, revealing files on disk',
|
|
223
224
|
script: 'rich script documents, anchored sections and their saved versions, reusable passages, variations and take input history',
|
|
224
|
-
timeline: 'named cuts and selected exports; the timeline (tracks, clips, markers, settings), video export and export for DaVinci
|
|
225
|
+
timeline: 'named cuts and selected exports; the timeline (tracks, clips, markers, settings), video export and FCP7 XML export for DaVinci Resolve or Premiere, clip trimming',
|
|
225
226
|
admin: 'rename / delete / reorder for projects, characters, locations, looks, boards, scenes and frames; shot duplicate, split and merge',
|
|
226
227
|
blender: 'the Blender previs bridge — scene inspection, bpy execution, API docs, grey-box render',
|
|
227
228
|
};
|
|
@@ -247,8 +248,7 @@ export function toolDefinition(op) {
|
|
|
247
248
|
* Render a tool surface.
|
|
248
249
|
*
|
|
249
250
|
* `desktop` sends `core` plus whatever groups have been loaded this run; `mcp`
|
|
250
|
-
* renders
|
|
251
|
-
* `--tools=compact`.
|
|
251
|
+
* renders every definition for the fixed MCP list.
|
|
252
252
|
*/
|
|
253
253
|
export function toolDefinitions(ops, opts) {
|
|
254
254
|
const loaded = new Set(opts.groups ?? []);
|
|
@@ -261,4 +261,29 @@ export function toolDefinitions(ops, opts) {
|
|
|
261
261
|
})
|
|
262
262
|
.map(toolDefinition);
|
|
263
263
|
}
|
|
264
|
+
// Natural brief words for capabilities whose API names use technical terms.
|
|
265
|
+
const TASK_ALIASES = {
|
|
266
|
+
slates_generate_video: 'create animate photo picture film movie ad advert advertisement',
|
|
267
|
+
slates_generate_from_shots: 'create make film movie ad advert advertisement',
|
|
268
|
+
slates_generate_image: 'photo picture illustration',
|
|
269
|
+
slates_edit_image: 'photo picture',
|
|
270
|
+
slates_use_pictures_as_first_frames: 'photo animate',
|
|
271
|
+
slates_generate_audio: 'voiceover narration speech ambience sound effect',
|
|
272
|
+
};
|
|
273
|
+
/** Rank exact task words by rarity across the current registry, returning at most ten. */
|
|
274
|
+
export function searchTools(operations, query) {
|
|
275
|
+
const terms = searchTerms(query);
|
|
276
|
+
const documents = operations.map(op => ({
|
|
277
|
+
op,
|
|
278
|
+
name: new Set(searchTerms(op.id)),
|
|
279
|
+
words: new Set(searchTerms(`${op.description} ${TASK_ALIASES[op.id] ?? ''}`)),
|
|
280
|
+
}));
|
|
281
|
+
const frequency = new Map(terms.map(term => [term, documents.filter(doc => doc.name.has(term) || doc.words.has(term)).length]));
|
|
282
|
+
return documents.map(doc => ({
|
|
283
|
+
op: doc.op,
|
|
284
|
+
score: terms.reduce((sum, term) => sum + (doc.name.has(term) || doc.words.has(term)
|
|
285
|
+
? Math.log(1 + documents.length / (1 + (frequency.get(term) ?? 0))) * (doc.name.has(term) ? 2 : 1)
|
|
286
|
+
: 0), 0),
|
|
287
|
+
})).filter(match => match.score > 0).sort((a, b) => b.score - a.score || a.op.id.localeCompare(b.op.id)).slice(0, 10);
|
|
288
|
+
}
|
|
264
289
|
//# sourceMappingURL=surface.js.map
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
* `desktop` — the in-app Studio Agent. Its loop enforces plan approval in
|
|
5
5
|
* code, auto-polls generation status, and displays orchestration cost itself.
|
|
6
6
|
* `mcp` — Claude Code / Claude Desktop / Cursor / Codex over stdio. No
|
|
7
|
-
* `present_plan` tool, no auto-poll, no app chrome
|
|
8
|
-
* op-level `requires_confirm`
|
|
9
|
-
* tool approval
|
|
7
|
+
* `present_plan` tool, no auto-poll, no app chrome. The user approves the
|
|
8
|
+
* itemized spend in chat; op-level `requires_confirm` is a threshold backstop.
|
|
9
|
+
* Host tool approval depends on the client. See slates-mcp/CLAUDE.md.
|
|
10
10
|
*/
|
|
11
11
|
export type AgentSurface = 'desktop' | 'mcp';
|
|
12
12
|
interface SkillIndexEntry {
|
|
13
13
|
name: string;
|
|
14
14
|
description: string;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/** Generated from the same validated metadata used by discovery and installation. */
|
|
17
17
|
export declare function buildSkillIndex(): SkillIndexEntry[];
|
|
18
18
|
export declare const WORKING_METHOD: ReadonlyArray<Record<AgentSurface, string>>;
|
|
19
19
|
export declare const HARD_RULES: ReadonlyArray<Record<AgentSurface, string>>;
|
|
@@ -27,13 +27,18 @@
|
|
|
27
27
|
// 3. PROSE IS EXPLANATION, NOT ENFORCEMENT. The two rules the agent actually
|
|
28
28
|
// breaks — "load the guide" and "quality-check with vision" — are enforced
|
|
29
29
|
// STRUCTURALLY in the op layer (generated banned-token lists inlined into
|
|
30
|
-
// the generate ops' descriptions,
|
|
31
|
-
//
|
|
30
|
+
// the generate ops' descriptions, warnings on the submitted prompt that the
|
|
31
|
+
// desktop loop turns into a refusal before the spend, and a review pointer
|
|
32
|
+
// on every generation result). A rule with no
|
|
32
33
|
// check is a suggestion, and an LLM is the least reliable enforcer you
|
|
33
34
|
// could pick. Do not "fix" a skipped rule by adding a sentence here.
|
|
34
|
-
// 4. NEVER BLOCK. PRODUCT_PHILOSOPHY.md → the Sandbox Doctrine: make
|
|
35
|
-
// visible, never block.
|
|
36
|
-
// and violations are reported back
|
|
35
|
+
// 4. NEVER BLOCK THE USER. PRODUCT_PHILOSOPHY.md → the Sandbox Doctrine: make
|
|
36
|
+
// state visible, never block. In the op layer enforcement means the guidance
|
|
37
|
+
// is already present and violations are reported back. The desktop loop may
|
|
38
|
+
// refuse an AGENT's call that breaks a rule code can check (never-use words
|
|
39
|
+
// before a spend, a project nobody asked for, a model the plan did not
|
|
40
|
+
// approve: slate `studio-agent/guards.ts`, 2026-10-07), and each refusal has
|
|
41
|
+
// a way through for the user: their own words, an approved plan, a resend.
|
|
37
42
|
// 5. CACHE DISCIPLINE. This output is the desktop's cached prompt prefix and
|
|
38
43
|
// its byte-stability IS the cache mechanism (measured 97.4% steady-state
|
|
39
44
|
// cache hit). No timestamps, no balances, no project names, no per-session
|
|
@@ -50,6 +55,7 @@
|
|
|
50
55
|
// the whole embedded SKILLS record. Root barrel only.
|
|
51
56
|
// ============================================================
|
|
52
57
|
import { SKILLS } from '../skills/content.js';
|
|
58
|
+
import { guideCatalog } from './guide-discovery.js';
|
|
53
59
|
import { VIDEO_MODELS, AUDIO_MODELS } from '../operations/index.js';
|
|
54
60
|
/** A line that is identical on both surfaces. The default. */
|
|
55
61
|
function both(text) {
|
|
@@ -59,21 +65,9 @@ function both(text) {
|
|
|
59
65
|
function fork(desktop, mcp) {
|
|
60
66
|
return { desktop, mcp };
|
|
61
67
|
}
|
|
62
|
-
/**
|
|
68
|
+
/** Generated from the same validated metadata used by discovery and installation. */
|
|
63
69
|
export function buildSkillIndex() {
|
|
64
|
-
|
|
65
|
-
for (const key of Object.keys(SKILLS).sort()) {
|
|
66
|
-
const content = SKILLS[key];
|
|
67
|
-
const fm = /^---\n([\s\S]*?)\n---/.exec(content);
|
|
68
|
-
let description = '';
|
|
69
|
-
if (fm) {
|
|
70
|
-
const m = /^description:\s*(.+)$/m.exec(fm[1]);
|
|
71
|
-
if (m)
|
|
72
|
-
description = m[1].trim().replace(/^['"]|['"]$/g, '');
|
|
73
|
-
}
|
|
74
|
-
entries.push({ name: key, description });
|
|
75
|
-
}
|
|
76
|
-
return entries;
|
|
70
|
+
return guideCatalog(SKILLS).map(({ name, description }) => ({ name, description }));
|
|
77
71
|
}
|
|
78
72
|
// ── Preamble ───────────────────────────────────────────────────────
|
|
79
73
|
// FORKED, and the MCP side is a SUMMARY THAT MUST FIT IN THE CUT. Claude Code
|
|
@@ -83,16 +77,16 @@ export function buildSkillIndex() {
|
|
|
83
77
|
// find a tool when the host shows names only, the spend gate, real numbers, the
|
|
84
78
|
// current project — sits here; the sections below expand it for clients that
|
|
85
79
|
// read everything. mcp-instructions-smoke asserts these lines land inside the
|
|
86
|
-
// cut
|
|
87
|
-
const PREAMBLE = fork(`You are the Slates Studio Agent — a production assistant living inside Slates, the AI video creation studio.
|
|
88
|
-
|
|
89
|
-
## Essentials (the sections below expand on these)
|
|
90
|
-
|
|
91
|
-
- FINDING TOOLS: every Slates capability is its own slates_* tool. If your client shows tool names only, search your tools for the task (for example "slates generate video") and load that tool before calling it.
|
|
92
|
-
- SPENDING: before ANY generation, price every step with slates_estimate_generation_cost, show the user the itemized total in ONE message, and wait for their OK. Pass confirm: true only to relay an explicit user OK for that exact spend.
|
|
93
|
-
- REAL NUMBERS ONLY: every cost, balance or count you state is copied from a tool result in this session. Never describe how a generation looks unless you fetched it this session.
|
|
94
|
-
- PROJECT: call slates_get_workspace_state once, work in the user's current project, and never create a project unless asked.
|
|
95
|
-
- CRAFT:
|
|
80
|
+
// cut when UPDATE AVAILABLE follows the first doctrine paragraph.
|
|
81
|
+
const PREAMBLE = fork(`You are the Slates Studio Agent — a production assistant living inside Slates, the AI video creation studio. Turn the user's vision into finished work using the optional Slates tools and relevant production craft. Choose the workflow for the brief; start from the user's existing material and bring results into their project or timeline when asked.`, `Turn the user's vision into finished work in Slates. Find craft with slates_get_prompting_guide(query: the brief); reuse current guidance. Tools generate real media and spend credits. Before generation, estimate every step, show the itemized total and wait for approval. Work in the current project. Choose tools to fit the brief.
|
|
82
|
+
|
|
83
|
+
## Essentials (the sections below expand on these)
|
|
84
|
+
|
|
85
|
+
- FINDING TOOLS: every Slates capability is its own slates_* tool. If your client shows tool names only, search your tools for the task (for example "slates generate video") and load that tool before calling it. slates_load_tools searches Slates tools by task and returns exact schemas.
|
|
86
|
+
- SPENDING: before ANY generation, price every step with slates_estimate_generation_cost, show the user the itemized total in ONE message, and wait for their OK. Pass confirm: true only to relay an explicit user OK for that exact spend.
|
|
87
|
+
- REAL NUMBERS ONLY: every cost, balance or count you state is copied from a tool result in this session. Never describe how a generation looks unless you fetched it this session.
|
|
88
|
+
- PROJECT: call slates_get_workspace_state once, work in the user's current project, and never create a project unless asked.
|
|
89
|
+
- CRAFT: discover relevant guides with slates_get_prompting_guide(query: the brief). Reuse current cards and guidance; fetch sections for missing craft. For UI help, use topic "app-manual".
|
|
96
90
|
- Speak in the app's words and name assets by code and label (IMG-A12), never by tool name or UUID.`);
|
|
97
91
|
// ── The working method ─────────────────────────────────────────────
|
|
98
92
|
export const WORKING_METHOD = [
|
|
@@ -103,15 +97,17 @@ export const WORKING_METHOD = [
|
|
|
103
97
|
// so its agent must load before calling. The MCP server lists every tool and
|
|
104
98
|
// the host decides what to show (Essentials, FINDING TOOLS), so telling an MCP
|
|
105
99
|
// client to load first costs it a turn for a tool it already has.
|
|
106
|
-
fork(`3. LOAD KNOWLEDGE ON DEMAND: slates_get_prompting_guide returns a short card
|
|
100
|
+
fork(`3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Use slates_load_tools with query to find a capability, then names to load its exact schema. A load replaces the previous optional selection. Before quoting a model, load its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Read the model card delivered by the estimate; fetch a section or full guide for an unfamiliar mode or missing detail. Reuse guidance already in context; retrieve it again when omitted or stale.`, `3. LOAD KNOWLEDGE ON DEMAND: discover craft from the brief with slates_get_prompting_guide(query: the need); no topic returns ranked guides, no query returns the catalog. With a topic, read a short card or query a section/technique when needed. Before quoting a model, read its tool schema or routing guide. Use workspace generationDefaults when the user has no preference. Read the model card delivered by the estimate; fetch a section or full guide for an unfamiliar mode or missing detail. Reuse guidance already in context; retrieve it again when omitted or stale.`),
|
|
107
101
|
// FORKED: `present_plan` is a loop-level DESKTOP tool, deliberately not in
|
|
108
102
|
// ALL_OPERATIONS, so MCP never sees it and has no plan gate at all. Its
|
|
109
|
-
// substitute is the
|
|
110
|
-
//
|
|
103
|
+
// substitute is the itemized quote and explicit user approval in chat,
|
|
104
|
+
// backed by per-op `requires_confirm`. Describing the desktop gate to an MCP
|
|
111
105
|
// client would name a tool that does not exist.
|
|
112
106
|
fork(`4. PLAN + GET APPROVAL: before ANY generation, call present_plan with itemized credit costs (slates_estimate_generation_cost per step). One approval covers the plan's listed steps ONLY. Generation tools are rejected without an approved plan — and any user revision, question, or new instruction after an approval means you MUST re-present the plan BEFORE the next generation call (calling a generation op first just gets BLOCKED and wastes a turn).`, `4. PLAN + GET APPROVAL: before ANY generation, price every step with slates_estimate_generation_cost and put the itemized total in front of the user in ONE message, then wait for their answer. There is no present_plan tool on this surface — consent is per call: a generation over the confirm threshold returns requires_confirm, and confirm: true is only ever a relay of an explicit user OK for that exact spend. Never pass confirm: true to clear a gate the user has not seen.`),
|
|
113
107
|
fork(`5. EXECUTE: after approval, pass confirm: true (the approval IS the consent — never re-ask per step). Use background: true + status polling for video.`, `5. EXECUTE: run the approved steps, passing confirm: true only for the spend the user actually OK'd. Use background: true + status polling for video.`),
|
|
114
|
-
|
|
108
|
+
// Desktop adds the frame-edge check (2026-10-08: Haiku looked at a lighthouse with its top cropped
|
|
109
|
+
// off and kept it, agent-eval round 6); the MCP copy is unchanged, its instructions sit at the ceiling.
|
|
110
|
+
fork(`6. QUALITY-CHECK: you have vision. Inspect images or sampled video frames against the brief (slates-vision-feedback-loop), starting at the frame edges: is the whole subject in frame, and is anything the brief named cut off? Frames establish visible appearance, not continuous motion, lip sync or sound: review those through actual playback or an audio-capable host when available; otherwise state they remain unreviewed. Fix real problems and change ONE variable per regeneration.`, `6. QUALITY-CHECK: you have vision. Inspect images or sampled video frames against the brief (slates-vision-feedback-loop). Frames establish visible appearance, not continuous motion, lip sync or sound: review those through actual playback or an audio-capable host when available; otherwise state they remain unreviewed. Fix real problems and change ONE variable per regeneration.`),
|
|
115
111
|
both(`7. REPORT: when done, summarize what was made and where it landed. Concise and concrete.`),
|
|
116
112
|
];
|
|
117
113
|
// ── Hard rules ─────────────────────────────────────────────────────
|
|
@@ -120,12 +116,12 @@ export const WORKING_METHOD = [
|
|
|
120
116
|
// the exception: it is multi-line and generated, and supplies its own bullet.
|
|
121
117
|
export const HARD_RULES = [
|
|
122
118
|
// FORKED: "outside an approved plan" names the desktop's code-level gate.
|
|
123
|
-
fork(`- COST DISCIPLINE (slates-cost-discipline): never fire a billable generation outside an approved plan. Estimate before you promise. Batch related generations into one plan.`, `- COST DISCIPLINE (slates-cost-discipline): never fire a billable generation the user has not agreed to. Estimate before you promise. Batch related generations into one quote so the user approves a total, not a drip.`),
|
|
119
|
+
fork(`- COST DISCIPLINE (slates-cost-discipline): never fire a billable generation outside an approved plan. Estimate before you promise. Batch related generations into one plan. When the user says cheap or cheapest, price decides: plan the lowest-priced setting the estimates show (at a tie, the better quality at that price); "best" then means the best picture at that price, never a dearer tier. A dearer tier is named in words, never generated unless the user asks for it.`, `- COST DISCIPLINE (slates-cost-discipline): never fire a billable generation the user has not agreed to. Estimate before you promise. Batch related generations into one quote so the user approves a total, not a drip.`),
|
|
124
120
|
both(`- CONTENT POLICY: before writing prompts involving real people/celebrities, minors, brands/logos, weapons, or gore, load slates-content-policy and build the scene safe from the first word. If a provider rejects (e.g. real-face detection), explain in plain language — refunds for provider rejections are automatic.`),
|
|
125
121
|
both(`- PROMPT IS LAW (reference doctrine): references are cited inline by name and image number ("Marcus (images 1 and 2)"); the prompt text leads. Never write role-essays about what each reference is "for".`),
|
|
126
122
|
both(`- NAMES AND DESCRIPTIONS ARE THE USER'S UI, NOT YOUR NOTEPAD. A project, board or shot name is rendered at the top of the user's screen at all times. Name it after the piece ("Kaiju selfie"), never after your process, and NEVER append your own status or housekeeping — no "shot list", no "v2", no "Written from IMG-A172 and IMG-A182", no "Delete freely", no "scratch". Leave the description empty unless the user gave you one worth keeping: a note-to-self at the top of the screen reads as part of the product, and the user has to look at it every day. Say that kind of thing in your reply to them instead.`),
|
|
127
123
|
both(`- SAY THE APP'S WORDS. Tool and parameter names keep older nouns; the screen does not, and the user only ever sees the screen. Say board (not storyboard), location (not environment) and look (not style) for Library items, timeline (a saved version of it is a cut), version (a saved rewrite of a script section; not alternative), Words or Words + shots (the Script page's switch), the Generate panel (not the quote), and tab (Media, Script and Board; not lens). Describe what you did in plain words ("Checked your project", "Priced 6 clips"), never a tool or parameter name.`),
|
|
128
|
-
both(`- RESOLUTION DEFAULT
|
|
124
|
+
both(`- RESOLUTION DEFAULT: each model's own default. Do not crank resolution the user didn't ask for.`),
|
|
129
125
|
// ⛔ THE MODEL ROUTING BLOCK IS GONE FROM HERE, DELIBERATELY (2026-08-30).
|
|
130
126
|
//
|
|
131
127
|
// It was 17,700 characters — 47% of the whole doctrine — and every lane of it
|
|
@@ -141,10 +137,17 @@ export const HARD_RULES = [
|
|
|
141
137
|
// The old `buildModelRouting()` renderer was DELETED rather than left
|
|
142
138
|
// exported "in case": an export nothing calls is an export nothing keeps
|
|
143
139
|
// honest. `describeRouting()` in model-facts.ts is the renderer now.
|
|
144
|
-
both(`- MODEL KINDS: image, video and audio models are disjoint — no image model makes a video, no video model makes a standalone image, no image or video model makes audio. Which SEAT to pick inside a kind is on each generate op's own \`model\` description, and the full table is the slates-model-selection skill.`),
|
|
140
|
+
both(`- MODEL KINDS: image, video and audio models are disjoint — no image model makes a video, no video model makes a standalone image, no image or video model makes a standalone audio file (video models can generate sound inside the clip). Which SEAT to pick inside a kind is on each generate op's own \`model\` description, and the full table is the slates-model-selection skill.`),
|
|
145
141
|
both(`- ASSET CODES + STALENESS: every asset carries a badge code (IMG-A12 / VID-V3 / AUD-S1, top-left of its gallery card); speak about assets by code + label. When the user says "these" or "this one", call slates_get_selection rather than asking which. Asset lists go STALE — the user creates assets in the Slates UI mid-conversation. When the user names a code you have NOT seen in a tool result this session, resolve it with slates_list_assets (use the search filter) BEFORE using it. NEVER guess an asset id or reuse a nearby UUID — pass the exact id a tool returned for that exact code. A wrong start frame burns real credits.`),
|
|
146
|
-
both(`- CREDITS ONLY: every generation you drive bills Slates credits (your tool calls enforce this). Never suggest BYOK keys for agent work.`),
|
|
142
|
+
both(`- CREDITS ONLY: every generation you drive bills Slates credits (your tool calls enforce this), except ChatGPT images, which use the person's ChatGPT account. Never suggest BYOK keys for agent work.`),
|
|
147
143
|
both(`- Do not invent tools, asset ids, or credit prices. If a tool errors, read the error and fix that exact issue; don't repeat the same call unchanged and never switch models to route around a parameter mistake.`),
|
|
144
|
+
// 2026-10-08, measured: Haiku 5.5 called slates_list_assets in the SAME turn as
|
|
145
|
+
// slates_get_workspace_state, with a project id it made up, read the empty
|
|
146
|
+
// answer as "IMG-A8 does not exist" and stopped (slate scripts/agent-eval
|
|
147
|
+
// README, round 5). Dependent calls wait; independent ones may still run together.
|
|
148
|
+
// Desktop loop only: the invented id came from the desktop brain, and the MCP
|
|
149
|
+
// instructions sit at their 14,000-character ceiling (agent-surface check).
|
|
150
|
+
fork(`- IDS COME FROM RESULTS: pass only a project, asset, shot, folder or board id you read in a tool result in this conversation. When a call needs another call's answer (the open project's id from slates_get_workspace_state, an asset's id from slates_list_assets), make the first call, read its result, then make the second; never fill the id in ahead of the answer. Calls that do not depend on each other may run together. "No project …" or "No asset …" means the id was wrong, not that the thing is missing: get the real id and try again.`, ``),
|
|
148
151
|
// FORKED: only the desktop loop auto-polls generation status
|
|
149
152
|
// (loop.ts → autoPollUntilTerminal). Telling an MCP client "the app keeps
|
|
150
153
|
// polling for you" would strand a job nobody is watching.
|
|
@@ -160,18 +163,23 @@ export const HARD_RULES = [
|
|
|
160
163
|
// compliance 0/8 → 30/32, while the same guidance behind a guide fetch sat at
|
|
161
164
|
// 13% before and after. This sentence exists only to say the numbers are
|
|
162
165
|
// there and must be looked at; the craft is the skill.
|
|
166
|
+
// 2026-10-07, measured: asked for "just the shot list for now", GLM-5.3-Flash
|
|
167
|
+
// AND Opus 5.5 both wrote a good list into the chat, 0/8 each, and never
|
|
168
|
+
// created a Shot. Neither knew that in Slates a shot list IS Shots — and on
|
|
169
|
+
// the desktop slates_create_shot is not core, so nothing on screen said so.
|
|
170
|
+
fork(`- A SHOT LIST IS SHOTS: asked for a shot list, storyboard or breakdown, write each beat as a Shot with slates_create_shot (load it by name first): Shots land on the board and can be priced and fired later; a chat list cannot. Read the set back with slates_list_shots. Writing Shots is free, even under "don't generate yet". Firing Shots is slates_generate_from_shots, so each take lands on its Shot; to fire them at other settings, change each Shot first with slates_update_shot and say so in the plan. A loose slates_generate_video leaves the board without its takes.`, `- A SHOT LIST IS SHOTS: asked for a shot list, storyboard or breakdown, write each beat as a Shot with slates_create_shot: Shots land on the board and can be priced and fired later; a chat list cannot. Read the set back with slates_list_shots. Writing Shots is free, even under "don't generate yet".`),
|
|
163
171
|
both(`- READ THE VARIETY COUNTS BEFORE FIRING A SET: slates_list_shots and slates_get_storyboard_with_frames return authored framing and movement distributions. Review unintended sameness while preserving deliberate repetition and the user's format; counts do not require a rewrite. slates-shot-variety is the craft.`),
|
|
164
172
|
both(`- AUDIO LENGTH IS PROMPT-DRIVEN ON SEED AUDIO: it has no duration parameter, so the durationSeconds you pass is written into the prompt AND is what the user is charged, whatever comes back. Choose it deliberately and load slates-prompting-seed-audio before the first call.`),
|
|
165
173
|
];
|
|
166
174
|
// ── Surface-only footers ───────────────────────────────────────────
|
|
167
175
|
//
|
|
168
176
|
// MCP clients have no Slates chrome and may have no skill FILES installed
|
|
169
|
-
// (`slates install-skills` covers Claude Code;
|
|
170
|
-
//
|
|
177
|
+
// (`slates install-skills` covers Claude Code and Codex; other hosts may
|
|
178
|
+
// use different native skill locations). The desktop always has the embedded
|
|
171
179
|
// record, so this paragraph would be dead weight in its cached prefix.
|
|
172
|
-
const MCP_FOOTER = `## Working without skill files
|
|
173
|
-
|
|
174
|
-
If slates-* skill files are not installed in this client, every one of them is still reachable as data: call slates_get_prompting_guide with the skill name (or a model id — it resolves aliases).
|
|
180
|
+
const MCP_FOOTER = `## Working without skill files
|
|
181
|
+
|
|
182
|
+
If slates-* skill files are not installed in this client, every one of them is still reachable as data: call slates_get_prompting_guide with the skill name (or a model id — it resolves aliases). Query the brief or browse topic "catalog" for generated discovery and entitled member playbooks. "No skill installed" is never a reason to prompt a model blind.
|
|
175
183
|
`;
|
|
176
184
|
/**
|
|
177
185
|
* THE doctrine string for a surface. The desktop's whole system prompt and the
|
|
@@ -206,19 +214,19 @@ export function buildAgentDoctrine({ surface }) {
|
|
|
206
214
|
const skillIndex = rest.map((s) => `- ${s.name}: ${firstSentence(s.description)}`).join('\n') +
|
|
207
215
|
`\n- PER-MODEL PROMPTING GUIDES — pass the model id, or the name: ` +
|
|
208
216
|
perModel.map((s) => s.name).join(', ');
|
|
209
|
-
return `${PREAMBLE[surface]}
|
|
210
|
-
|
|
211
|
-
## How you work
|
|
212
|
-
|
|
213
|
-
${WORKING_METHOD.map((s) => s[surface]).join('\n')}
|
|
214
|
-
|
|
215
|
-
## Hard rules
|
|
216
|
-
|
|
217
|
-
${HARD_RULES.map((r) => r[surface]).join('\n')}
|
|
218
|
-
|
|
219
|
-
## Guide index (load via slates_get_prompting_guide)
|
|
220
|
-
|
|
221
|
-
${skillIndex}
|
|
217
|
+
return `${PREAMBLE[surface]}
|
|
218
|
+
|
|
219
|
+
## How you work
|
|
220
|
+
|
|
221
|
+
${WORKING_METHOD.map((s) => s[surface]).join('\n')}
|
|
222
|
+
|
|
223
|
+
## Hard rules
|
|
224
|
+
|
|
225
|
+
${HARD_RULES.map((r) => r[surface]).join('\n')}
|
|
226
|
+
|
|
227
|
+
## Guide index (load via slates_get_prompting_guide)
|
|
228
|
+
|
|
229
|
+
${skillIndex}
|
|
222
230
|
${surface === 'mcp' ? `\n${MCP_FOOTER}` : ''}`;
|
|
223
231
|
}
|
|
224
232
|
//# sourceMappingURL=agent-doctrine.js.map
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
export type BannedTokenScope = 'image' | 'video';
|
|
2
|
+
/** The call shape a block's heading limits its tokens to. */
|
|
3
|
+
export type BannedTokenCondition = 'reference-video' | 'edit';
|
|
2
4
|
export interface BannedToken {
|
|
3
5
|
token: string;
|
|
4
6
|
skill: string;
|
|
5
7
|
scope: BannedTokenScope;
|
|
8
|
+
/** The never-use line the token came from, as the skill words it. */
|
|
9
|
+
note: string;
|
|
10
|
+
/** False when the rule needs context the call cannot show; such a token only warns. */
|
|
11
|
+
checkable: boolean;
|
|
12
|
+
/** Set when the block's heading limits it to a call shape. */
|
|
13
|
+
when?: BannedTokenCondition;
|
|
6
14
|
}
|
|
7
15
|
/** Compatibility exports: there is no cross-model blacklist. */
|
|
8
16
|
export declare const BANNED_PROMPT_TOKENS: readonly BannedToken[];
|
|
@@ -10,6 +18,16 @@ export declare function bannedTokensFor(_scope: BannedTokenScope): readonly Bann
|
|
|
10
18
|
export declare function describeBannedTokens(_scope: BannedTokenScope): string;
|
|
11
19
|
export declare function bannedTokensForSkill(skill: string): readonly BannedToken[];
|
|
12
20
|
export declare function findBannedTokens(prompt: string, _scope: BannedTokenScope, skill?: string): BannedToken[];
|
|
21
|
+
/**
|
|
22
|
+
* The never-use words this CALL breaks, as far as the call can show: checkable
|
|
23
|
+
* tokens, and a heading-limited token only when the call has that shape (a
|
|
24
|
+
* Seedance 2.5 "edit" reclassifies a fresh generation only with a reference
|
|
25
|
+
* video attached). The desktop loop refuses these before the spend.
|
|
26
|
+
*/
|
|
27
|
+
export declare function refusableBannedTokens(prompt: string, scope: BannedTokenScope, skill: string | undefined, call?: {
|
|
28
|
+
referenceVideo?: boolean;
|
|
29
|
+
edit?: boolean;
|
|
30
|
+
}): BannedToken[];
|
|
13
31
|
export declare function describeBannedTokensForSkill(skill: string): string;
|
|
14
32
|
export declare function bannedTokenWarning(prompt: string, scope: BannedTokenScope, skill?: string): string;
|
|
15
33
|
//# sourceMappingURL=banned-tokens.d.ts.map
|
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
/** Model-specific prompt advice, extracted from each skill's @banned blocks.
|
|
2
|
-
*
|
|
2
|
+
* The op layer only warns: it never rewrites or blocks a prompt, on any surface.
|
|
3
|
+
* The desktop Studio Agent's loop refuses an agent-written generation prompt
|
|
4
|
+
* BEFORE the spend when it carries a word code can check from the call alone
|
|
5
|
+
* (`refusableBannedTokens`; slate `src/main/studio-agent/guards.ts`,
|
|
6
|
+
* 2026-10-07): a word the user typed passes, and the identical call sent again
|
|
7
|
+
* after the refusal runs. No model's list is universal.
|
|
8
|
+
*
|
|
9
|
+
* WHAT A BLOCK MAY CONTAIN. Every `backticked` string is a never-use token,
|
|
10
|
+
* except the right way written beside it, which is never a token: `(say \`x\`)`,
|
|
11
|
+
* `than \`x\``, `as in: \`x\`` and `(\`x\`) passed`. A heading that limits the
|
|
12
|
+
* block to a call shape ("with a reference video", "in an EDIT prompt") limits
|
|
13
|
+
* the refusal to calls of that shape. A line whose rule depends on context the
|
|
14
|
+
* call cannot show ("after the first introduction") stays a warning only.
|
|
3
15
|
*/
|
|
4
16
|
import { SKILLS } from '../skills/content.js';
|
|
17
|
+
/** The right way, written next to the wrong one: never a token. */
|
|
18
|
+
const POSITIVE_BEFORE = [/\(\s*say\s*$/i, /\bthan\s*$/i, /\bas in:?\s*$/i];
|
|
19
|
+
const POSITIVE_AFTER = /^\)\s*passed\b/i;
|
|
20
|
+
/** A rule the call alone cannot settle. */
|
|
21
|
+
const CONTEXTUAL = /after the first introduction/i;
|
|
22
|
+
function conditionOf(heading) {
|
|
23
|
+
if (/with a reference video/i.test(heading))
|
|
24
|
+
return 'reference-video';
|
|
25
|
+
if (/in an EDIT prompt/i.test(heading))
|
|
26
|
+
return 'edit';
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/** One fence → its tokens, positives dropped, each with its line and its limits. */
|
|
30
|
+
function parseBannedBlock(body, skill, scope) {
|
|
31
|
+
const lines = body.replace(/<!--[\s\S]*?-->/g, '').split('\n').map((l) => l.trim()).filter(Boolean);
|
|
32
|
+
const heading = lines.find((l) => /never use|avoid/i.test(l)) ?? '';
|
|
33
|
+
const when = conditionOf(heading.replace(/`[^`\n]*`/g, ''));
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const line of lines) {
|
|
36
|
+
const note = line.replace(/^-\s*/, '').replace(/`([^`\n]+)`/g, '"$1"');
|
|
37
|
+
for (const m of line.matchAll(/`([^`\n]+)`/g)) {
|
|
38
|
+
const before = line.slice(0, m.index);
|
|
39
|
+
const after = line.slice((m.index ?? 0) + m[0].length);
|
|
40
|
+
if (POSITIVE_BEFORE.some((re) => re.test(before)) || POSITIVE_AFTER.test(after))
|
|
41
|
+
continue;
|
|
42
|
+
const token = m[1].trim();
|
|
43
|
+
if (out.some((t) => t.token === token))
|
|
44
|
+
continue;
|
|
45
|
+
out.push({ token, skill, scope, note, checkable: !CONTEXTUAL.test(line), ...(when ? { when } : {}) });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
5
50
|
const bySkill = new Map();
|
|
6
51
|
for (const [skill, content] of Object.entries(SKILLS)) {
|
|
7
52
|
const fences = [...content.matchAll(/<!--\s*@banned:start\s*-->([\s\S]*?)<!--\s*@banned:end\s*-->/g)];
|
|
8
53
|
if (!fences.length)
|
|
9
54
|
continue;
|
|
10
|
-
const
|
|
55
|
+
const scope = /nano-banana|gpt-image|flux|seedream/.test(skill) ? 'image' : 'video';
|
|
56
|
+
const tokens = fences.flatMap((f) => parseBannedBlock(f[1], skill, scope))
|
|
57
|
+
.filter((t, i, all) => all.findIndex((o) => o.token === t.token) === i);
|
|
11
58
|
if (!tokens.length)
|
|
12
59
|
throw new Error(`${skill}: @banned block contains no tokens`);
|
|
13
|
-
|
|
14
|
-
bySkill.set(skill, tokens.map((token) => ({ token, skill, scope })));
|
|
60
|
+
bySkill.set(skill, tokens);
|
|
15
61
|
}
|
|
16
62
|
/** Compatibility exports: there is no cross-model blacklist. */
|
|
17
63
|
export const BANNED_PROMPT_TOKENS = Object.freeze([]);
|
|
@@ -31,6 +77,15 @@ function matcherFor(token) {
|
|
|
31
77
|
export function findBannedTokens(prompt, _scope, skill) {
|
|
32
78
|
return skill ? bannedTokensForSkill(skill).filter((b) => matcherFor(b.token).test(prompt)) : [];
|
|
33
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* The never-use words this CALL breaks, as far as the call can show: checkable
|
|
82
|
+
* tokens, and a heading-limited token only when the call has that shape (a
|
|
83
|
+
* Seedance 2.5 "edit" reclassifies a fresh generation only with a reference
|
|
84
|
+
* video attached). The desktop loop refuses these before the spend.
|
|
85
|
+
*/
|
|
86
|
+
export function refusableBannedTokens(prompt, scope, skill, call = {}) {
|
|
87
|
+
return findBannedTokens(prompt, scope, skill).filter((b) => b.checkable && (b.when === undefined || (b.when === 'reference-video' ? !!call.referenceVideo : !!call.edit)));
|
|
88
|
+
}
|
|
34
89
|
export function describeBannedTokensForSkill(skill) {
|
|
35
90
|
const list = bannedTokensForSkill(skill);
|
|
36
91
|
return list.length ? `Avoid these phrases for ${skill}: ${list.map((b) => `"${b.token}"`).join(', ')}. Describe the intended result specifically.` : '';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface GuideCatalogEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
tier: 'free' | 'paid';
|
|
5
|
+
}
|
|
6
|
+
/** Metadata is the catalog; headings supply technique vocabulary without returning whole guides. */
|
|
7
|
+
export declare function guideCatalog(skills: Readonly<Record<string, string>>): GuideCatalogEntry[];
|
|
8
|
+
export declare function discoverGuides(entries: readonly GuideCatalogEntry[], skills: Readonly<Record<string, string>>, query?: string, limit?: number, offset?: number): {
|
|
9
|
+
query: string | null;
|
|
10
|
+
fallback: boolean;
|
|
11
|
+
total: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
nextOffset: number | null;
|
|
14
|
+
guides: {
|
|
15
|
+
matched: string[];
|
|
16
|
+
sections: string[];
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
tier: "free" | "paid";
|
|
20
|
+
}[];
|
|
21
|
+
rest: GuideCatalogEntry[];
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=guide-discovery.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { parseSkillMetadata } from '../skills/metadata.js';
|
|
2
|
+
import { guideSections } from './guide-retrieval.js';
|
|
3
|
+
import { searchTerms } from './search-terms.js';
|
|
4
|
+
// Brief filler that matches guides by accident ("30 second", "how much", "I need").
|
|
5
|
+
const GUIDE_FILLER = ['create', 'make', 'use', 'video', 'image', 'need', 'how', 'much', 'turn', 'keep', 'get', 'like', 'just', 'about', 'every', 'second', 'minute'];
|
|
6
|
+
const words = (text) => searchTerms(text, GUIDE_FILLER).filter(word => !/^\d{1,2}$/.test(word));
|
|
7
|
+
/** Metadata is the catalog; headings supply technique vocabulary without returning whole guides. */
|
|
8
|
+
export function guideCatalog(skills) {
|
|
9
|
+
return Object.keys(skills).sort().map(name => ({ ...parseSkillMetadata(skills[name], name), tier: 'free' }));
|
|
10
|
+
}
|
|
11
|
+
export function discoverGuides(entries, skills, query, limit, offset = 0) {
|
|
12
|
+
const terms = words(query ?? '');
|
|
13
|
+
const documents = entries.map(entry => {
|
|
14
|
+
const sections = skills[entry.name] ? guideSections(skills[entry.name]) : [];
|
|
15
|
+
const metadata = new Set(words(`${entry.name.replace(/-/g, ' ')} ${entry.description}`));
|
|
16
|
+
const headings = sections.map(section => ({ heading: section.title, terms: new Set(words(section.title)) }));
|
|
17
|
+
return { entry, metadata, headings };
|
|
18
|
+
});
|
|
19
|
+
// Rare terms in the corpus carry more weight than generic production vocabulary.
|
|
20
|
+
const frequency = new Map(terms.map(term => [term, documents.filter(doc => doc.metadata.has(term) || doc.headings.some(section => section.terms.has(term))).length]));
|
|
21
|
+
const ranked = documents.map(doc => {
|
|
22
|
+
const matched = terms.filter(term => doc.metadata.has(term) || doc.headings.some(section => section.terms.has(term)));
|
|
23
|
+
const score = matched.reduce((sum, term) => sum + Math.log(1 + documents.length / (1 + (frequency.get(term) ?? 0))) * (doc.metadata.has(term) ? 3 : 1), 0);
|
|
24
|
+
const sections = doc.headings.filter(section => matched.some(term => section.terms.has(term))).slice(0, 3).map(section => section.heading);
|
|
25
|
+
return { ...doc.entry, matched, sections, score };
|
|
26
|
+
}).filter(entry => !terms.length || entry.score > 0).sort((a, b) => b.score - a.score || a.name.localeCompare(b.name));
|
|
27
|
+
// An unfamiliar brief still exposes the catalog and its pagination; it never asks the user to route it.
|
|
28
|
+
const fallback = terms.length > 0 && ranked.length === 0;
|
|
29
|
+
const candidates = fallback ? documents.map(doc => ({ ...doc.entry, matched: [], sections: [], score: 0 })) : ranked;
|
|
30
|
+
// Browsing, or a brief with no keyword match, returns the whole catalog unless the caller pages it.
|
|
31
|
+
const size = limit ?? (terms.length && !fallback ? 8 : candidates.length);
|
|
32
|
+
const page = candidates.slice(offset, offset + size).map(({ score: _score, ...entry }) => entry);
|
|
33
|
+
// Keyword ranking only sees shared words, so the first page of a search also carries
|
|
34
|
+
// every other guide's description: the model chooses by the brief, as with native skills.
|
|
35
|
+
const shown = new Set(page.map(entry => entry.name));
|
|
36
|
+
const rest = terms.length && !fallback && offset === 0 ? entries.filter(entry => !shown.has(entry.name)) : [];
|
|
37
|
+
return { query: query ?? null, fallback, total: candidates.length, offset, nextOffset: offset + page.length < candidates.length ? offset + page.length : null, guides: page, rest };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=guide-discovery.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { craftCard } from './craft-cards.js';
|
|
2
2
|
/** Parse headings outside code fences; maintainer comments never reach agents. */
|
|
3
3
|
export function guideSections(content) {
|
|
4
|
-
const clean = content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').
|
|
4
|
+
const clean = content.replace(/<!--[\s\S]*?-->/g, '').trimStart().replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trim();
|
|
5
5
|
const sections = [];
|
|
6
6
|
let current = { title: 'Overview', body: '' };
|
|
7
7
|
let fenced = false;
|
|
@@ -35,9 +35,9 @@ export interface DurationCapability {
|
|
|
35
35
|
mode: 'continuous' | 'discrete';
|
|
36
36
|
/** For discrete mode: the exact allowed durations. */
|
|
37
37
|
values?: number[];
|
|
38
|
-
/** Resolution-dependent narrowing
|
|
38
|
+
/** Resolution-dependent narrowing: a resolution that allows fewer durations (LTX sets this). */
|
|
39
39
|
resolutionOverrides?: Record<string, Pick<DurationCapability, 'min' | 'max' | 'mode' | 'values'>>;
|
|
40
|
-
/** Prompt-mode narrowing
|
|
40
|
+
/** Prompt-mode narrowing: a mode, such as reference-to-video, that allows fewer durations. No row sets one today. */
|
|
41
41
|
modeOverrides?: Record<string, Pick<DurationCapability, 'min' | 'max' | 'mode' | 'values'>>;
|
|
42
42
|
}
|
|
43
43
|
/** Video resolution constraints. */
|
|
@@ -188,15 +188,14 @@ export interface ModelCapability {
|
|
|
188
188
|
voiceClone?: VoiceCloneCapability;
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
|
-
* The provider every AGENT generation actually lands on for Kling
|
|
191
|
+
* The provider every AGENT generation actually lands on for Kling.
|
|
192
192
|
*
|
|
193
193
|
* 🚨 THIS IS WHY `providerAspectRatios` MATTERS TO THE OP. MCP/CLI/Studio-Agent
|
|
194
194
|
* generations are credits-only (BYOK is retired on the agent surface), and the
|
|
195
|
-
* credits route carries Kling
|
|
196
|
-
* never sends `klingProvider`, so `handlers/video.ts` defaults it to `'fal'
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* TWO — not the eight and ten those models take on their direct APIs. Validating
|
|
195
|
+
* credits route carries Kling on fal: `slate/src/main/agent/routes.ts`
|
|
196
|
+
* never sends `klingProvider`, so `handlers/video.ts` defaults it to `'fal'`.
|
|
197
|
+
* So an agent gets Kling's THREE fal ratios, not the eight it takes on its
|
|
198
|
+
* direct API. Validating
|
|
200
199
|
* against the direct sets would accept a ratio fal rejects, which is the exact
|
|
201
200
|
* failure this module exists to delete.
|
|
202
201
|
*/
|
|
@@ -257,7 +256,7 @@ export declare function checkDuration(model: string, duration: number | undefine
|
|
|
257
256
|
export declare function describeAspectRatios(models: readonly string[], provider?: string): string;
|
|
258
257
|
/** e.g. "seedance-2: 480p, 720p, 1080p, 4k (default 1080p) · omni-flash: 720p only (fixed)" */
|
|
259
258
|
export declare function describeVideoResolutions(models: readonly string[]): string;
|
|
260
|
-
/** e.g. "kling-v3.0-std: 3-15s ·
|
|
259
|
+
/** e.g. "kling-v3.0-std: 3-15s · ltx-2-5: 6s/8s/10s/12s/14s/16s/18s/20s (1440p/4k: 6s/8s/10s only)" */
|
|
261
260
|
export declare function describeDurations(models: readonly string[]): string;
|
|
262
261
|
/** e.g. "seedance-2: 9 · seedance-2.5: 30 · omni-flash: 7 · seedance-2.5-edit: 0 (prompt + source clip only)" */
|
|
263
262
|
export declare function describeReferenceImageCaps(models: readonly string[]): string;
|