@engenty/wizards-runtime 0.12.1 → 0.13.0

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.
Files changed (129) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +42 -5
  2. package/apps/runtime/dist/app.js +15 -4
  3. package/apps/runtime/dist/credits/estimate.js +3 -3
  4. package/apps/runtime/dist/db/live-triggers.js +13 -3
  5. package/apps/runtime/dist/db/migrations/tenant/0027_space_skill.sql +48 -0
  6. package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +4120 -0
  7. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  8. package/apps/runtime/dist/db/schema.js +31 -0
  9. package/apps/runtime/dist/docs/dev/skills.md +116 -0
  10. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +20 -2
  11. package/apps/runtime/dist/docs/user-guide/models.md +105 -30
  12. package/apps/runtime/dist/docs/user-guide/skills.md +85 -0
  13. package/apps/runtime/dist/docs/user-guide/together.md +15 -2
  14. package/apps/runtime/dist/engine/decide.js +1 -1
  15. package/apps/runtime/dist/engine/requirements.js +139 -11
  16. package/apps/runtime/dist/engine/runner.js +47 -5
  17. package/apps/runtime/dist/engine/steps.js +23 -6
  18. package/apps/runtime/dist/engine/template.js +17 -0
  19. package/apps/runtime/dist/harness/model.js +4 -0
  20. package/apps/runtime/dist/link-preview.js +9 -0
  21. package/apps/runtime/dist/live/views.js +2 -0
  22. package/apps/runtime/dist/manage.js +25 -0
  23. package/apps/runtime/dist/mcp/handler.js +55 -1
  24. package/apps/runtime/dist/mcp/seen.js +47 -0
  25. package/apps/runtime/dist/models.js +206 -11
  26. package/apps/runtime/dist/motion-graphics/step.js +2 -2
  27. package/apps/runtime/dist/prompts/goose.md +15 -7
  28. package/apps/runtime/dist/prompts/safety.md +18 -0
  29. package/apps/runtime/dist/prompts/step.md +20 -2
  30. package/apps/runtime/dist/prompts/tools.md +33 -0
  31. package/apps/runtime/dist/routes/marketplace.js +3 -3
  32. package/apps/runtime/dist/routes/runs.js +5 -0
  33. package/apps/runtime/dist/routes/skills.js +84 -0
  34. package/apps/runtime/dist/routes/studio.js +103 -4
  35. package/apps/runtime/dist/safety.js +60 -18
  36. package/apps/runtime/dist/services/manage-reports.js +3 -0
  37. package/apps/runtime/dist/services/marketplace.js +7 -31
  38. package/apps/runtime/dist/services/pages.js +6 -2
  39. package/apps/runtime/dist/services/shares.js +5 -0
  40. package/apps/runtime/dist/services/skills-registry.js +209 -0
  41. package/apps/runtime/dist/services/skills.js +478 -0
  42. package/apps/runtime/dist/services/spaces.js +15 -1
  43. package/apps/runtime/dist/sync/records.js +81 -1
  44. package/apps/runtime/dist/texts.js +45 -0
  45. package/apps/runtime/dist/tools/index.js +7 -4
  46. package/apps/runtime/dist/tools/net-guard.js +8 -4
  47. package/apps/runtime/dist/tools/skills.js +197 -0
  48. package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +1 -0
  49. package/apps/web/dist/assets/{ChangelogDialog-BWaEdlt3.js → ChangelogDialog-SwyId00t.js} +1 -1
  50. package/apps/web/dist/assets/CodeEditor-BwZsk5Al.js +2 -0
  51. package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +3 -0
  52. package/apps/web/dist/assets/{FlowPreview-DXpzFBRj.js → FlowPreview-DtSpjVTl.js} +1 -1
  53. package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +2 -0
  54. package/apps/web/dist/assets/{NewWizardChannels-B5wuTm7J.js → NewWizardChannels-Tgoexgj4.js} +1 -1
  55. package/apps/web/dist/assets/NewWizardPage-B24AF482.js +7 -0
  56. package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +1 -0
  57. package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +10 -0
  58. package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +10 -0
  59. package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +1 -0
  60. package/apps/web/dist/assets/{ReadOnly-Cap_e5ke.js → ReadOnly-BXjv-MSv.js} +1 -1
  61. package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +2 -0
  62. package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +1 -0
  63. package/apps/web/dist/assets/{SharePage-DEeVGatD.js → SharePage-DXGzJSnR.js} +1 -1
  64. package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +1 -0
  65. package/apps/web/dist/assets/changelog-BLdS-0Bj.js +1 -0
  66. package/apps/web/dist/assets/code-xml-TwKzzMtA.js +1 -0
  67. package/apps/web/dist/assets/{dist-BwhPmMDu.js → dist-BdDd1FxP.js} +1 -1
  68. package/apps/web/dist/assets/dist-EBVTpvRr.js +10 -0
  69. package/apps/web/dist/assets/dist-GlRRx9Xl.js +1 -0
  70. package/apps/web/dist/assets/dist-H1UN89OA.js +1 -0
  71. package/apps/web/dist/assets/eye-Brd-xPUJ.js +1 -0
  72. package/apps/web/dist/assets/i18n-8-Sw11tB.js +55 -0
  73. package/apps/web/dist/assets/index-OsdQFHmh.js +49 -0
  74. package/apps/web/dist/assets/index-QPipX5Fi.css +1 -0
  75. package/apps/web/dist/assets/json-CEsfHdlZ.js +1 -0
  76. package/apps/web/dist/assets/{lock-D-CjMpqn.js → lock-C0uxcOlq.js} +1 -1
  77. package/apps/web/dist/assets/markdown-5-I9_izp.js +29 -0
  78. package/apps/web/dist/assets/{oss-credits-CUpVhKSr.js → oss-credits-DpRWUPjD.js} +1 -1
  79. package/apps/web/dist/assets/{phone-CXSrxw3H.js → phone-DhkHteoJ.js} +1 -1
  80. package/apps/web/dist/assets/{runners-D71NjXtA.js → runners-G-XYaDgR.js} +1 -1
  81. package/apps/web/dist/assets/{session-B2LtqeDq.js → session-BWI-KENJ.js} +1 -1
  82. package/apps/web/dist/assets/theme-D7krsx0_.js +11 -0
  83. package/apps/web/dist/assets/ui-DSXG3f49.js +83 -0
  84. package/apps/web/dist/assets/{upload-hLkuT3Q6.js → upload-BYZTwJTD.js} +1 -1
  85. package/apps/web/dist/assets/{useMutation-C3XBoSVf.js → useMutation-D0QP_k2-.js} +1 -1
  86. package/apps/web/dist/assets/{volume-2-DIxdTlaA.js → volume-2-CVHoxdGM.js} +1 -1
  87. package/apps/web/dist/index.html +9 -8
  88. package/apps/web/dist/mcp/flow.html +66 -66
  89. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +3 -2
  90. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +1 -0
  91. package/node_modules/@engenty/wizards-shared/dist/assistant.js +5 -0
  92. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +107 -0
  93. package/node_modules/@engenty/wizards-shared/dist/definition.js +67 -4
  94. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +18 -0
  95. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +18 -0
  96. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +1 -1
  97. package/node_modules/@engenty/wizards-shared/dist/marketplace.d.ts +0 -5
  98. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +62 -0
  99. package/node_modules/@engenty/wizards-shared/dist/run.js +52 -0
  100. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +165 -0
  101. package/node_modules/@engenty/wizards-shared/dist/skills.js +346 -0
  102. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +4 -2
  103. package/node_modules/@engenty/wizards-shared/dist/sync.js +2 -1
  104. package/node_modules/@engenty/wizards-shared/dist/tiers.d.ts +195 -0
  105. package/node_modules/@engenty/wizards-shared/dist/tiers.js +98 -0
  106. package/package.json +7 -7
  107. package/plugin/.claude-plugin/plugin.json +1 -1
  108. package/plugin/plugin.json +1 -1
  109. package/apps/web/dist/assets/AboutDialog-uGYGy2R2.js +0 -1
  110. package/apps/web/dist/assets/CodeEditor-B5hV1IvK.js +0 -2
  111. package/apps/web/dist/assets/EditorPage-j9BOx5-V.js +0 -3
  112. package/apps/web/dist/assets/Marketplace-DSo6uZF6.js +0 -2
  113. package/apps/web/dist/assets/NewWizardPage-Ci1ZsTJk.js +0 -7
  114. package/apps/web/dist/assets/OnboardingPage-QkdluEZk.js +0 -1
  115. package/apps/web/dist/assets/PreviewPane-swAH89un.js +0 -10
  116. package/apps/web/dist/assets/ProjectPage-Djv5EOYU.js +0 -1
  117. package/apps/web/dist/assets/PublicRunner-Bt8gMxit.js +0 -1
  118. package/apps/web/dist/assets/SettingsPage-C2rmXm_Q.js +0 -2
  119. package/apps/web/dist/assets/SetupPage-CbqGgFPZ.js +0 -1
  120. package/apps/web/dist/assets/changelog-DAY6ZEyy.js +0 -1
  121. package/apps/web/dist/assets/dist-DVpDdhG9.js +0 -1
  122. package/apps/web/dist/assets/dist-DzdNG7Sf.js +0 -10
  123. package/apps/web/dist/assets/i18n-B3J2ypKu.js +0 -55
  124. package/apps/web/dist/assets/index-Dxwbli0m.css +0 -1
  125. package/apps/web/dist/assets/index-WY5lJ_-h.js +0 -49
  126. package/apps/web/dist/assets/json-D2GVvTXK.js +0 -1
  127. package/apps/web/dist/assets/markdown-DwdMW7q0.js +0 -29
  128. package/apps/web/dist/assets/theme-Dab079EV.js +0 -11
  129. package/apps/web/dist/assets/ui-DQX_CQ7c.js +0 -83
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Skills of a space (docs/plans/skills.md): instructions in the Agent Skills format – a folder
3
+ * with a `SKILL.md` (front matter `name` and `description`, then Markdown) and the files it
4
+ * points to. A space's wizards follow a skill that is always on in every AI step; one on demand
5
+ * they see by name and description and read when it fits the task. A skill whose scripts may
6
+ * run gets its folder in the run's sandbox. Behind the `skills` switch.
7
+ */
8
+ /** When a skill counts: in every AI step, when a step reads it, or not at all. */
9
+ export declare const SKILL_MODES: readonly ["always", "demand", "off"];
10
+ export type SkillMode = (typeof SKILL_MODES)[number];
11
+ /** Where it came from: written in the studio, uploaded, or added from skills.sh. */
12
+ export declare const SKILL_SOURCES: readonly ["own", "upload", "skills.sh"];
13
+ export type SkillSource = (typeof SKILL_SOURCES)[number];
14
+ export declare const SKILL_LIMITS: {
15
+ /** A name, as the Agent Skills format allows it. */
16
+ readonly name: 64;
17
+ readonly description: 1024;
18
+ /** Bytes of the `SKILL.md`, of any other file, of the whole skill, and its files. */
19
+ readonly skillMd: 100000;
20
+ readonly file: 256000;
21
+ readonly total: 1000000;
22
+ readonly files: 100;
23
+ readonly perSpace: 100;
24
+ /** Skills always on, and the characters of their instructions together: each is in every AI step. */
25
+ readonly always: 5;
26
+ readonly alwaysChars: 20000;
27
+ /** Skills on demand a step sees by name; more are left out of its list. */
28
+ readonly listed: 50;
29
+ /**
30
+ * Files kept for scripts only (fonts, templates, schemas): bytes of one, of all of a skill's
31
+ * together, and how many. They live in the blob store, not in the skill's row.
32
+ */
33
+ readonly blobFile: 5000000;
34
+ readonly blobTotal: 20000000;
35
+ readonly blobFiles: 200;
36
+ };
37
+ /** Lower-case letters, digits and single hyphens inside. */
38
+ export declare const SKILL_NAME: RegExp;
39
+ /**
40
+ * The GitHub owners skills.sh lists as official (skills.sh/official, October 2026). A skill from
41
+ * one of them shows as from an official source; any other is shown as not checked.
42
+ */
43
+ export declare const OFFICIAL_SKILL_OWNERS: readonly string[];
44
+ /** A skill's address on skills.sh: `owner/repo/skill`. */
45
+ export declare const SKILL_REF: RegExp;
46
+ export declare function officialSkill(ref: string | null | undefined): boolean;
47
+ /** A file of a skill beside its `SKILL.md`: a path inside the skill's folder and its text. */
48
+ export interface SkillFile {
49
+ path: string;
50
+ text: string;
51
+ }
52
+ /**
53
+ * A file of a skill that no model reads: not text, or of a kind the format keeps for its scripts
54
+ * (a font, a template, a schema). Its bytes are in the blob store, by their hash; they reach a
55
+ * run's sandbox when the skill's scripts may run.
56
+ */
57
+ export interface SkillBlobFile {
58
+ path: string;
59
+ hash: string;
60
+ bytes: number;
61
+ }
62
+ /** A skill as the list shows it. */
63
+ export interface SkillSummary {
64
+ id: string;
65
+ name: string;
66
+ description: string;
67
+ mode: SkillMode;
68
+ source: SkillSource;
69
+ /** skills.sh: `owner/repo/skill`. */
70
+ origin: string | null;
71
+ official: boolean;
72
+ /** Its scripts run in the sandbox of a step that has one. Off until someone switches it on. */
73
+ runScripts: boolean;
74
+ /** Its files beside the `SKILL.md`, the ones for scripts too. */
75
+ files: number;
76
+ /** Characters of its instructions: what a step reads, or carries when it is always on. */
77
+ chars: number;
78
+ updatedAt: string;
79
+ }
80
+ export interface SkillsList {
81
+ skills: SkillSummary[];
82
+ readOnly: boolean;
83
+ }
84
+ /** A skill opened: its instructions, the rest of its front matter and its files. */
85
+ export interface SkillDetail extends SkillSummary {
86
+ projectId: string;
87
+ body: string;
88
+ /** Front matter beside `name` and `description`, kept as it came (`license`, `metadata` …). */
89
+ meta: Record<string, unknown>;
90
+ fileList: SkillFile[];
91
+ /** Files for its scripts only. */
92
+ blobList: SkillBlobFile[];
93
+ /** The hash of what skills.sh had when it was added: an update is offered when it differs. */
94
+ originHash: string | null;
95
+ readOnly: boolean;
96
+ }
97
+ /** A skill on skills.sh, as a search finds it. */
98
+ export interface SkillHit {
99
+ ref: string;
100
+ name: string;
101
+ /** `owner/repo` on GitHub. */
102
+ source: string;
103
+ installs: number;
104
+ official: boolean;
105
+ /** The space has a skill from this address already. */
106
+ added: boolean;
107
+ }
108
+ /** A skill of skills.sh read whole, before it is added. */
109
+ export interface SkillPreview {
110
+ ref: string;
111
+ name: string;
112
+ description: string;
113
+ body: string;
114
+ meta: Record<string, unknown>;
115
+ fileList: SkillFile[];
116
+ /** Files kept for its scripts only. */
117
+ blobList: {
118
+ path: string;
119
+ bytes: number;
120
+ }[];
121
+ /** Files left out: not text, or too large. */
122
+ skipped: {
123
+ path: string;
124
+ reason: "binary" | "size" | "path" | "count";
125
+ }[];
126
+ official: boolean;
127
+ bytes: number;
128
+ hash: string;
129
+ }
130
+ /** Whether a path may be a file of a skill: relative, inside its folder, no hidden or odd parts. */
131
+ export declare function skillPathOk(path: string): boolean;
132
+ export declare function skillTextPath(path: string): boolean;
133
+ /** A script: text a model reads, run in the sandbox when the skill's scripts may run. */
134
+ export declare function skillScript(path: string): boolean;
135
+ export interface ParsedSkillMd {
136
+ name: string;
137
+ description: string;
138
+ body: string;
139
+ /** The other keys of the front matter. */
140
+ meta: Record<string, unknown>;
141
+ }
142
+ /** Why a `SKILL.md` was not taken: no front matter, or no name or description in it. */
143
+ export type SkillMdProblem = "frontmatter" | "name" | "description";
144
+ export declare class SkillMdError extends Error {
145
+ readonly problem: SkillMdProblem;
146
+ constructor(problem: SkillMdProblem);
147
+ }
148
+ /**
149
+ * The front matter of a `SKILL.md`, in the part of YAML skills use: `key: value` with quoted or
150
+ * plain values, plain values going on over indented lines, block scalars (`|`, `>`), one level
151
+ * of mapping (`metadata:`) and lists of plain items. What it does not read it leaves out.
152
+ */
153
+ export declare function parseFrontmatter(yaml: string): Record<string, unknown>;
154
+ /** A `SKILL.md` read: its name, description, the rest of its front matter and its instructions. */
155
+ export declare function parseSkillMd(text: string): ParsedSkillMd;
156
+ /** A skill as its `SKILL.md`: front matter with name, description and the rest, then its instructions. */
157
+ export declare function skillMd(skill: {
158
+ name: string;
159
+ description: string;
160
+ body: string;
161
+ meta?: Record<string, unknown>;
162
+ }): string;
163
+ /** A name the format allows, made from any title: `Tonalität & Stil` → `tonalitaet-stil`. */
164
+ export declare function skillNameOf(text: string): string;
165
+ export declare const byteLength: (text: string) => number;
@@ -0,0 +1,346 @@
1
+ /**
2
+ * Skills of a space (docs/plans/skills.md): instructions in the Agent Skills format – a folder
3
+ * with a `SKILL.md` (front matter `name` and `description`, then Markdown) and the files it
4
+ * points to. A space's wizards follow a skill that is always on in every AI step; one on demand
5
+ * they see by name and description and read when it fits the task. A skill whose scripts may
6
+ * run gets its folder in the run's sandbox. Behind the `skills` switch.
7
+ */
8
+ /** When a skill counts: in every AI step, when a step reads it, or not at all. */
9
+ export const SKILL_MODES = ["always", "demand", "off"];
10
+ /** Where it came from: written in the studio, uploaded, or added from skills.sh. */
11
+ export const SKILL_SOURCES = ["own", "upload", "skills.sh"];
12
+ export const SKILL_LIMITS = {
13
+ /** A name, as the Agent Skills format allows it. */
14
+ name: 64,
15
+ description: 1024,
16
+ /** Bytes of the `SKILL.md`, of any other file, of the whole skill, and its files. */
17
+ skillMd: 100_000,
18
+ file: 256_000,
19
+ total: 1_000_000,
20
+ files: 100,
21
+ perSpace: 100,
22
+ /** Skills always on, and the characters of their instructions together: each is in every AI step. */
23
+ always: 5,
24
+ alwaysChars: 20_000,
25
+ /** Skills on demand a step sees by name; more are left out of its list. */
26
+ listed: 50,
27
+ /**
28
+ * Files kept for scripts only (fonts, templates, schemas): bytes of one, of all of a skill's
29
+ * together, and how many. They live in the blob store, not in the skill's row.
30
+ */
31
+ blobFile: 5_000_000,
32
+ blobTotal: 20_000_000,
33
+ blobFiles: 200,
34
+ };
35
+ /** Lower-case letters, digits and single hyphens inside. */
36
+ export const SKILL_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
37
+ /**
38
+ * The GitHub owners skills.sh lists as official (skills.sh/official, October 2026). A skill from
39
+ * one of them shows as from an official source; any other is shown as not checked.
40
+ */
41
+ export const OFFICIAL_SKILL_OWNERS = [
42
+ "aave",
43
+ "anthropics",
44
+ "antithesishq",
45
+ "apify",
46
+ "apollographql",
47
+ "astronomer",
48
+ "auth0",
49
+ "automattic",
50
+ "aws",
51
+ "axiomhq",
52
+ "base",
53
+ "better-auth",
54
+ "bitwarden",
55
+ "box",
56
+ "brave",
57
+ "browser-use",
58
+ "browserbase",
59
+ "callstackincubator",
60
+ "clerk",
61
+ "clickhouse",
62
+ "cloudflare",
63
+ "coderabbitai",
64
+ "coinbase",
65
+ "contentful",
66
+ "contentstack",
67
+ "convex-dev",
68
+ "dagster-io",
69
+ "dash0hq",
70
+ "datadog-labs",
71
+ "dbt-labs",
72
+ "deepgram",
73
+ "denoland",
74
+ "elevenlabs",
75
+ "encoredev",
76
+ "exploreomni",
77
+ "expo",
78
+ "facebook",
79
+ "factory-ai",
80
+ "figma",
81
+ "firebase",
82
+ "firecrawl",
83
+ "flutter",
84
+ "getsentry",
85
+ "github",
86
+ "google-gemini",
87
+ "google-labs-code",
88
+ "hashicorp",
89
+ "huggingface",
90
+ "kotlin",
91
+ "langchain-ai",
92
+ "langfuse",
93
+ "launchdarkly",
94
+ "makenotion",
95
+ "mapbox",
96
+ "mastra-ai",
97
+ "mcp-use",
98
+ "medusajs",
99
+ "microsoft",
100
+ "mongodb",
101
+ "n8n-io",
102
+ "neondatabase",
103
+ "nuxt",
104
+ "nvidia",
105
+ "openai",
106
+ "openshift",
107
+ "parallel-web",
108
+ "pinecone-io",
109
+ "planetscale",
110
+ "posthog",
111
+ "prisma",
112
+ "pulumi",
113
+ "pytorch",
114
+ "redis",
115
+ "remotion-dev",
116
+ "resend",
117
+ "rivet-dev",
118
+ "runwayml",
119
+ "sanity-io",
120
+ "semgrep",
121
+ "shopify",
122
+ "signoz",
123
+ "streamlit",
124
+ "stripe",
125
+ "supabase",
126
+ "sveltejs",
127
+ "tavily-ai",
128
+ "temporalio",
129
+ "tinybirdco",
130
+ "tldraw",
131
+ "triggerdotdev",
132
+ "uniformdev",
133
+ "upstash",
134
+ "vapiai",
135
+ "vercel",
136
+ "vercel-labs",
137
+ "webflow",
138
+ "wix",
139
+ "wordpress",
140
+ ];
141
+ /** A skill's address on skills.sh: `owner/repo/skill`. */
142
+ export const SKILL_REF = /^[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.-]{1,100}\/[A-Za-z0-9_.:-]{1,100}$/;
143
+ export function officialSkill(ref) {
144
+ const owner = ref?.split("/")[0]?.toLowerCase();
145
+ return Boolean(owner && OFFICIAL_SKILL_OWNERS.includes(owner));
146
+ }
147
+ /** Whether a path may be a file of a skill: relative, inside its folder, no hidden or odd parts. */
148
+ export function skillPathOk(path) {
149
+ if (!path || path.length > 200 || path.startsWith("/") || path.includes("\\")) {
150
+ return false;
151
+ }
152
+ return path
153
+ .split("/")
154
+ .every((part) => part !== "" && part !== "." && part !== ".." && /^[\w.@+ -]+$/.test(part));
155
+ }
156
+ /** Files a model reads as text: instructions, references, data and scripts. */
157
+ const TEXT_EXT = /\.(md|markdown|mdx|txt|text|csv|tsv|json|jsonl|yaml|yml|toml|xml|html|htm|css|js|mjs|cjs|ts|tsx|jsx|py|sh|bash|zsh|rb|go|rs|java|kt|swift|php|sql|r|ini|cfg|conf|env\.example|svg|tex|rst|adoc)$/i;
158
+ const TEXT_NAMES = /^(LICENSE|LICENCE|NOTICE|README|CHANGELOG|COPYING|Makefile|Dockerfile)(\.\w+)?$/i;
159
+ export function skillTextPath(path) {
160
+ const name = path.split("/").pop() ?? "";
161
+ return TEXT_EXT.test(name) || TEXT_NAMES.test(name);
162
+ }
163
+ const scriptPath = /\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;
164
+ /** A script: text a model reads, run in the sandbox when the skill's scripts may run. */
165
+ export function skillScript(path) {
166
+ return scriptPath.test(path);
167
+ }
168
+ export class SkillMdError extends Error {
169
+ problem;
170
+ constructor(problem) {
171
+ super(`SKILL.md: ${problem}`);
172
+ this.problem = problem;
173
+ }
174
+ }
175
+ function unquote(value) {
176
+ const v = value.trim();
177
+ if (v.length >= 2 && v.startsWith('"') && v.endsWith('"')) {
178
+ try {
179
+ return JSON.parse(v);
180
+ }
181
+ catch {
182
+ return v.slice(1, -1);
183
+ }
184
+ }
185
+ if (v.length >= 2 && v.startsWith("'") && v.endsWith("'")) {
186
+ return v.slice(1, -1).replace(/''/g, "'");
187
+ }
188
+ return v;
189
+ }
190
+ /** A block scalar's lines (`|`, `>`, with `-` or `+`), indentation taken off. */
191
+ function blockScalar(style, lines) {
192
+ const indent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.length - l.trimStart().length));
193
+ const plain = lines.map((l) => l.slice(Number.isFinite(indent) ? indent : 0));
194
+ let text;
195
+ if (style.startsWith("|")) {
196
+ text = plain.join("\n");
197
+ }
198
+ else {
199
+ // Folded: lines of a paragraph join with a space, an empty line stays a break.
200
+ text = plain
201
+ .join("\n")
202
+ .replace(/([^\n])\n(?!\n)/g, "$1 ")
203
+ .replace(/\n\n/g, "\n");
204
+ }
205
+ return style.includes("-") ? text.replace(/\s+$/, "") : `${text.replace(/\n*$/, "")}\n`;
206
+ }
207
+ /**
208
+ * The front matter of a `SKILL.md`, in the part of YAML skills use: `key: value` with quoted or
209
+ * plain values, plain values going on over indented lines, block scalars (`|`, `>`), one level
210
+ * of mapping (`metadata:`) and lists of plain items. What it does not read it leaves out.
211
+ */
212
+ export function parseFrontmatter(yaml) {
213
+ const out = {};
214
+ const lines = yaml.replace(/\r\n?/g, "\n").split("\n");
215
+ let i = 0;
216
+ const more = (from) => {
217
+ const taken = [];
218
+ let j = from;
219
+ while (j < lines.length && (lines[j].trim() === "" || /^\s/.test(lines[j]))) {
220
+ taken.push(lines[j]);
221
+ j++;
222
+ }
223
+ while (taken.length && taken[taken.length - 1].trim() === "") {
224
+ taken.pop();
225
+ j--;
226
+ }
227
+ return { taken, next: j };
228
+ };
229
+ while (i < lines.length) {
230
+ const line = lines[i];
231
+ const m = /^([A-Za-z_][\w.-]*)\s*:(.*)$/.exec(line);
232
+ if (!m || line.trimStart().startsWith("#")) {
233
+ i++;
234
+ continue;
235
+ }
236
+ const key = m[1];
237
+ const rest = m[2].trim();
238
+ const { taken, next } = more(i + 1);
239
+ i = next;
240
+ if (/^[|>][+-]?\d*$/.test(rest)) {
241
+ out[key] = blockScalar(rest, taken);
242
+ }
243
+ else if (rest === "" && taken.length) {
244
+ const items = taken.filter((l) => l.trim());
245
+ if (items.every((l) => /^\s*-\s/.test(l))) {
246
+ out[key] = items.map((l) => unquote(l.replace(/^\s*-\s/, "")));
247
+ }
248
+ else {
249
+ const map = {};
250
+ for (const l of items) {
251
+ const kv = /^\s*([^:#]+?)\s*:\s*(.*)$/.exec(l);
252
+ if (kv) {
253
+ map[kv[1]] = unquote(kv[2]);
254
+ }
255
+ }
256
+ out[key] = map;
257
+ }
258
+ }
259
+ else if (rest.startsWith("[") && rest.endsWith("]")) {
260
+ out[key] = rest
261
+ .slice(1, -1)
262
+ .split(",")
263
+ .map((s) => unquote(s))
264
+ .filter(Boolean);
265
+ }
266
+ else if (/^["']/.test(rest) && !/^(["']).*\1\s*$/.test(rest)) {
267
+ // A quoted value over several lines.
268
+ out[key] = unquote([rest, ...taken.map((l) => l.trim())].join(" "));
269
+ }
270
+ else {
271
+ const value = [rest, ...taken.map((l) => l.trim()).filter(Boolean)].join(" ");
272
+ out[key] = unquote(value);
273
+ }
274
+ }
275
+ return out;
276
+ }
277
+ const FRONTMATTER = /^?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
278
+ /** A `SKILL.md` read: its name, description, the rest of its front matter and its instructions. */
279
+ export function parseSkillMd(text) {
280
+ const m = FRONTMATTER.exec(text);
281
+ if (!m) {
282
+ throw new SkillMdError("frontmatter");
283
+ }
284
+ const front = parseFrontmatter(m[1]);
285
+ const name = typeof front.name === "string" ? front.name.trim() : "";
286
+ const description = typeof front.description === "string" ? front.description.replace(/\s+/g, " ").trim() : "";
287
+ if (!name) {
288
+ throw new SkillMdError("name");
289
+ }
290
+ if (!description) {
291
+ throw new SkillMdError("description");
292
+ }
293
+ const { name: _n, description: _d, ...meta } = front;
294
+ return { name, description, body: text.slice(m[0].length).replace(/^\s*\n/, ""), meta };
295
+ }
296
+ function yamlValue(value, indent = "") {
297
+ if (Array.isArray(value)) {
298
+ return `\n${value.map((v) => `${indent} - ${yamlScalar(String(v))}`).join("\n")}`;
299
+ }
300
+ if (value && typeof value === "object") {
301
+ return `\n${Object.entries(value)
302
+ .map(([k, v]) => `${indent} ${k}: ${yamlScalar(String(v))}`)
303
+ .join("\n")}`;
304
+ }
305
+ return ` ${yamlScalar(String(value ?? ""))}`;
306
+ }
307
+ /** A plain scalar where YAML reads it back the same, else a double-quoted one. */
308
+ function yamlScalar(value) {
309
+ return /^[^\s"'#&*!|>%@`{}[\],?:-][^\n#]*$/.test(value) &&
310
+ !/:\s|\s$/.test(value) &&
311
+ !/^(true|false|null|yes|no|~|[\d.+-]+)$/i.test(value)
312
+ ? value
313
+ : JSON.stringify(value);
314
+ }
315
+ /** A skill as its `SKILL.md`: front matter with name, description and the rest, then its instructions. */
316
+ export function skillMd(skill) {
317
+ const keys = Object.entries(skill.meta ?? {})
318
+ .filter(([, v]) => v !== undefined && v !== null)
319
+ .map(([k, v]) => `${k}:${yamlValue(v)}`);
320
+ return [
321
+ "---",
322
+ `name: ${yamlScalar(skill.name)}`,
323
+ `description: ${yamlScalar(skill.description)}`,
324
+ ...keys,
325
+ "---",
326
+ "",
327
+ skill.body.replace(/^\n+/, ""),
328
+ ].join("\n");
329
+ }
330
+ /** A name the format allows, made from any title: `Tonalität & Stil` → `tonalitaet-stil`. */
331
+ export function skillNameOf(text) {
332
+ return text
333
+ .toLowerCase()
334
+ .replace(/ä/g, "ae")
335
+ .replace(/ö/g, "oe")
336
+ .replace(/ü/g, "ue")
337
+ .replace(/ß/g, "ss")
338
+ .normalize("NFKD")
339
+ .replace(/[̀-ͯ]/g, "")
340
+ .replace(/[^a-z0-9]+/g, "-")
341
+ .replace(/^-+|-+$/g, "")
342
+ .slice(0, SKILL_LIMITS.name)
343
+ .replace(/-+$/, "");
344
+ }
345
+ const encoder = new TextEncoder();
346
+ export const byteLength = (text) => encoder.encode(text).length;
@@ -9,9 +9,9 @@ import type { MergeConflict } from "./sync-merge.js";
9
9
  /**
10
10
  * What syncs, one row each: the space's details, a wizard (its draft and workspace together),
11
11
  * a translation, a message of a wizard's build chat, a page, a table, a row, a category (with
12
- * its values), a file, an imported connector. Runs, chats, the store and the index do not.
12
+ * its values), a file, an imported connector, a skill. Runs, chats, the store and the index do not.
13
13
  */
14
- export declare const SYNC_KINDS: readonly ["space", "wizard", "translation", "message", "page", "table", "row", "category", "file", "connector"];
14
+ export declare const SYNC_KINDS: readonly ["space", "wizard", "translation", "message", "page", "table", "row", "category", "file", "connector", "skill"];
15
15
  export type SyncKind = (typeof SYNC_KINDS)[number];
16
16
  /** One item as it travels: its fields, never the tenant's id; `null` = deleted. */
17
17
  export type SyncRecord = Record<string, unknown>;
@@ -33,6 +33,7 @@ export declare const pushItemSchema: z.ZodObject<{
33
33
  message: "message";
34
34
  page: "page";
35
35
  row: "row";
36
+ skill: "skill";
36
37
  space: "space";
37
38
  table: "table";
38
39
  translation: "translation";
@@ -53,6 +54,7 @@ export declare const pushSchema: z.ZodObject<{
53
54
  message: "message";
54
55
  page: "page";
55
56
  row: "row";
57
+ skill: "skill";
56
58
  space: "space";
57
59
  table: "table";
58
60
  translation: "translation";
@@ -8,7 +8,7 @@ import { z } from "zod";
8
8
  /**
9
9
  * What syncs, one row each: the space's details, a wizard (its draft and workspace together),
10
10
  * a translation, a message of a wizard's build chat, a page, a table, a row, a category (with
11
- * its values), a file, an imported connector. Runs, chats, the store and the index do not.
11
+ * its values), a file, an imported connector, a skill. Runs, chats, the store and the index do not.
12
12
  */
13
13
  export const SYNC_KINDS = [
14
14
  "space",
@@ -21,6 +21,7 @@ export const SYNC_KINDS = [
21
21
  "category",
22
22
  "file",
23
23
  "connector",
24
+ "skill",
24
25
  ];
25
26
  /** Items carry ids as installs make them (nanoid), or `<id>:<part>` for a wizard's translations and a space's connectors. */
26
27
  export const syncItemId = z.string().regex(/^[A-Za-z0-9_-]{1,64}(:[A-Za-z0-9_.-]{1,64})?$/);