@percena/weft 0.4.0-next.1 → 0.4.0-next.3

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/skills.d.cts DELETED
@@ -1,218 +0,0 @@
1
-
2
-
3
- // ── inlined from @weft/skills ──
4
- // -- @weft/skills/browser.d.ts --
5
- /**
6
- * Skills Types
7
- *
8
- * Type definitions for workspace skills.
9
- * Skills are specialized instructions that extend Claude's capabilities.
10
- */
11
- /**
12
- * Skill metadata from SKILL.md YAML frontmatter
13
- */
14
- interface SkillMetadata {
15
- /** Display name for the skill */
16
- name: string;
17
- /** Brief description shown in skill list */
18
- description: string;
19
- /** Optional file patterns that trigger this skill */
20
- globs?: string[];
21
- /** Optional tools to always allow when skill is active */
22
- alwaysAllow?: string[];
23
- /**
24
- * Optional icon - emoji or URL only.
25
- * - Emoji: rendered directly in UI (e.g., "🔧")
26
- * - URL: auto-downloaded to icon.{ext} file
27
- * Note: Relative paths and inline SVG are NOT supported.
28
- */
29
- icon?: string;
30
- /** Optional source slugs to auto-enable when this skill is invoked */
31
- requiredSources?: string[];
32
- }
33
- /** Source of a loaded skill */
34
- type SkillSource = 'global' | 'workspace' | 'project';
35
- /**
36
- * Plugin name for project-level and global skills.
37
- *
38
- * The SDK derives plugin names from `path.basename()` of the registered plugin
39
- * directory. Both `{project}/.agents/` and `~/.agents/` share the basename
40
- * `.agents`, so skills from either tier resolve to `.agents:skillSlug`.
41
- */
42
- declare const AGENTS_PLUGIN_NAME = ".agents";
43
- /**
44
- * A loaded skill with parsed content
45
- */
46
- interface LoadedSkill {
47
- /** Directory name (slug) */
48
- slug: string;
49
- /** Parsed metadata from YAML frontmatter */
50
- metadata: SkillMetadata;
51
- /** Full SKILL.md content (without frontmatter) */
52
- content: string;
53
- /** Absolute path to icon file if exists */
54
- iconPath?: string;
55
- /** Absolute path to skill directory */
56
- path: string;
57
- /** Where this skill was loaded from */
58
- source: SkillSource;
59
- }
60
-
61
- type SkillActivationReason = 'prompt-mention' | 'file-glob' | 'host-selection';
62
- interface SkillActivation {
63
- skill: LoadedSkill;
64
- reason: SkillActivationReason;
65
- }
66
- interface CreateSkillActivationPlanOptions {
67
- skills: LoadedSkill[];
68
- prompt?: string;
69
- filePaths?: string[];
70
- selectedSkillSlugs?: string[];
71
- enabledSourceSlugs?: string[];
72
- prerequisiteFileExists?: (path: string) => boolean;
73
- }
74
- interface SkillPolicyExtension {
75
- toolName: string;
76
- scope: {
77
- type: 'skill';
78
- skillSlug: string;
79
- };
80
- }
81
- interface SkillActivationPlan {
82
- activeSkillSlugs: string[];
83
- activations: SkillActivation[];
84
- requiredSourceSlugs: string[];
85
- missingRequiredSourceSlugs: string[];
86
- policyExtensions: SkillPolicyExtension[];
87
- providerInstructions: string;
88
- prerequisiteFiles: string[];
89
- }
90
- declare function createSkillActivationPlan(options: CreateSkillActivationPlanOptions): SkillActivationPlan;
91
-
92
- /**
93
- * Format a skill prerequisite directive that instructs the agent to read
94
- * SKILL.md files before taking any other action.
95
- *
96
- * Returns undefined if no prerequisite files are specified.
97
- */
98
- declare function formatSkillDirective(prerequisiteFiles: string[]): string | undefined;
99
- /**
100
- * Prepend a skill directive to a user message if prerequisite files exist.
101
- * Returns the original message if no prerequisites.
102
- */
103
- declare function prependSkillDirective(message: string, prerequisiteFiles: string[]): string;
104
-
105
- export { AGENTS_PLUGIN_NAME, type CreateSkillActivationPlanOptions, type LoadedSkill, type SkillActivation, type SkillActivationPlan, type SkillActivationReason, type SkillMetadata, type SkillPolicyExtension, type SkillSource, createSkillActivationPlan, formatSkillDirective, prependSkillDirective };
106
-
107
- // -- @weft/skills/index.d.ts --
108
-
109
- interface SkillValidationIssue {
110
- file: string;
111
- path: string;
112
- message: string;
113
- severity: 'error' | 'warning' | 'info';
114
- suggestion?: string;
115
- }
116
- interface SkillValidationResult {
117
- valid: boolean;
118
- errors: SkillValidationIssue[];
119
- warnings: SkillValidationIssue[];
120
- }
121
- declare function validateSkillDefinitionContent(content: string, file?: string): SkillValidationResult;
122
-
123
- /**
124
- * Skills Storage
125
- *
126
- * CRUD operations for workspace skills.
127
- * Skills are stored in {workspace}/skills/{slug}/ directories.
128
- */
129
-
130
- /** Global agent skills directory: ~/.agents/skills/ */
131
- declare const GLOBAL_AGENT_SKILLS_DIR: string;
132
- /** Project-level agent skills relative directory name */
133
- declare const PROJECT_AGENT_SKILLS_DIR = ".agents/skills";
134
- /**
135
- * Load a single skill from a workspace
136
- * @param workspaceRoot - Absolute path to workspace root
137
- * @param slug - Skill directory name
138
- */
139
- declare function loadSkill(workspaceRoot: string, slug: string): LoadedSkill | null;
140
- /** Invalidate the skills cache (call on working dir change or skill file events). */
141
- declare function invalidateSkillsCache(): void;
142
- /**
143
- * Load all skills from all sources (global, workspace, project)
144
- * Skills with the same slug are overridden by higher-priority sources.
145
- * Priority: global (lowest) < workspace < project (highest)
146
- *
147
- * Results are cached per (workspaceRoot, projectRoot) pair. Call
148
- * invalidateSkillsCache() on working directory changes or skill file events.
149
- *
150
- * @param workspaceRoot - Absolute path to workspace root
151
- * @param projectRoot - Optional project root (working directory) for project-level skills
152
- */
153
- declare function loadAllSkills(workspaceRoot: string, projectRoot?: string): LoadedSkill[];
154
- /**
155
- * Load a single skill by slug from all sources (project > workspace > global).
156
- * Unlike loadAllSkills(), this only reads the specific slug directory — O(1) not O(N).
157
- *
158
- * @param workspaceRoot - Absolute path to workspace root
159
- * @param slug - Skill slug to load
160
- * @param projectRoot - Optional project root for project-level skills
161
- */
162
- declare function loadSkillBySlug(workspaceRoot: string, slug: string, projectRoot?: string): LoadedSkill | null;
163
- /**
164
- * Get icon path for a skill
165
- * @param workspaceRoot - Absolute path to workspace root
166
- * @param slug - Skill directory name
167
- */
168
- declare function getSkillIconPath(workspaceRoot: string, slug: string): string | null;
169
- /**
170
- * Delete a skill from a workspace
171
- * @param workspaceRoot - Absolute path to workspace root
172
- * @param slug - Skill directory name
173
- */
174
- declare function deleteSkill(workspaceRoot: string, slug: string): boolean;
175
- interface CreateSkillInput {
176
- slug: string;
177
- name: string;
178
- description: string;
179
- content: string;
180
- globs?: string[];
181
- alwaysAllow?: string[];
182
- icon?: string;
183
- requiredSources?: string[];
184
- }
185
- interface UpdateSkillInput {
186
- name?: string;
187
- description?: string;
188
- content?: string;
189
- globs?: string[];
190
- alwaysAllow?: string[];
191
- icon?: string;
192
- requiredSources?: string[];
193
- }
194
- declare function createSkill(workspaceRoot: string, input: CreateSkillInput): LoadedSkill;
195
- declare function updateSkill(workspaceRoot: string, slug: string, patch: UpdateSkillInput): LoadedSkill;
196
- /**
197
- * Check if a skill exists in a workspace
198
- * @param workspaceRoot - Absolute path to workspace root
199
- * @param slug - Skill directory name
200
- */
201
- declare function skillExists(workspaceRoot: string, slug: string): boolean;
202
- /**
203
- * List skill slugs in a workspace
204
- * @param workspaceRoot - Absolute path to workspace root
205
- */
206
- declare function listSkillSlugs(workspaceRoot: string): string[];
207
- /**
208
- * Download an icon from a URL and save it to the skill directory.
209
- * Returns the path to the downloaded icon, or null on failure.
210
- */
211
- declare function downloadSkillIcon(skillDir: string, iconUrl: string): Promise<string | null>;
212
- /**
213
- * Check if a skill needs its icon downloaded.
214
- * Returns true if metadata has a URL icon and no local icon file exists.
215
- */
216
- declare function skillNeedsIconDownload(skill: LoadedSkill): boolean;
217
-
218
- export { type CreateSkillInput, GLOBAL_AGENT_SKILLS_DIR, LoadedSkill, PROJECT_AGENT_SKILLS_DIR, type SkillValidationIssue, type SkillValidationResult, type UpdateSkillInput, createSkill, deleteSkill, downloadSkillIcon, getSkillIconPath, invalidateSkillsCache, listSkillSlugs, loadAllSkills, loadSkill, loadSkillBySlug, skillExists, skillNeedsIconDownload, updateSkill, validateSkillDefinitionContent };
package/dist/skills.d.ts DELETED
@@ -1,218 +0,0 @@
1
-
2
-
3
- // ── inlined from @weft/skills ──
4
- // -- @weft/skills/browser.d.ts --
5
- /**
6
- * Skills Types
7
- *
8
- * Type definitions for workspace skills.
9
- * Skills are specialized instructions that extend Claude's capabilities.
10
- */
11
- /**
12
- * Skill metadata from SKILL.md YAML frontmatter
13
- */
14
- interface SkillMetadata {
15
- /** Display name for the skill */
16
- name: string;
17
- /** Brief description shown in skill list */
18
- description: string;
19
- /** Optional file patterns that trigger this skill */
20
- globs?: string[];
21
- /** Optional tools to always allow when skill is active */
22
- alwaysAllow?: string[];
23
- /**
24
- * Optional icon - emoji or URL only.
25
- * - Emoji: rendered directly in UI (e.g., "🔧")
26
- * - URL: auto-downloaded to icon.{ext} file
27
- * Note: Relative paths and inline SVG are NOT supported.
28
- */
29
- icon?: string;
30
- /** Optional source slugs to auto-enable when this skill is invoked */
31
- requiredSources?: string[];
32
- }
33
- /** Source of a loaded skill */
34
- type SkillSource = 'global' | 'workspace' | 'project';
35
- /**
36
- * Plugin name for project-level and global skills.
37
- *
38
- * The SDK derives plugin names from `path.basename()` of the registered plugin
39
- * directory. Both `{project}/.agents/` and `~/.agents/` share the basename
40
- * `.agents`, so skills from either tier resolve to `.agents:skillSlug`.
41
- */
42
- declare const AGENTS_PLUGIN_NAME = ".agents";
43
- /**
44
- * A loaded skill with parsed content
45
- */
46
- interface LoadedSkill {
47
- /** Directory name (slug) */
48
- slug: string;
49
- /** Parsed metadata from YAML frontmatter */
50
- metadata: SkillMetadata;
51
- /** Full SKILL.md content (without frontmatter) */
52
- content: string;
53
- /** Absolute path to icon file if exists */
54
- iconPath?: string;
55
- /** Absolute path to skill directory */
56
- path: string;
57
- /** Where this skill was loaded from */
58
- source: SkillSource;
59
- }
60
-
61
- type SkillActivationReason = 'prompt-mention' | 'file-glob' | 'host-selection';
62
- interface SkillActivation {
63
- skill: LoadedSkill;
64
- reason: SkillActivationReason;
65
- }
66
- interface CreateSkillActivationPlanOptions {
67
- skills: LoadedSkill[];
68
- prompt?: string;
69
- filePaths?: string[];
70
- selectedSkillSlugs?: string[];
71
- enabledSourceSlugs?: string[];
72
- prerequisiteFileExists?: (path: string) => boolean;
73
- }
74
- interface SkillPolicyExtension {
75
- toolName: string;
76
- scope: {
77
- type: 'skill';
78
- skillSlug: string;
79
- };
80
- }
81
- interface SkillActivationPlan {
82
- activeSkillSlugs: string[];
83
- activations: SkillActivation[];
84
- requiredSourceSlugs: string[];
85
- missingRequiredSourceSlugs: string[];
86
- policyExtensions: SkillPolicyExtension[];
87
- providerInstructions: string;
88
- prerequisiteFiles: string[];
89
- }
90
- declare function createSkillActivationPlan(options: CreateSkillActivationPlanOptions): SkillActivationPlan;
91
-
92
- /**
93
- * Format a skill prerequisite directive that instructs the agent to read
94
- * SKILL.md files before taking any other action.
95
- *
96
- * Returns undefined if no prerequisite files are specified.
97
- */
98
- declare function formatSkillDirective(prerequisiteFiles: string[]): string | undefined;
99
- /**
100
- * Prepend a skill directive to a user message if prerequisite files exist.
101
- * Returns the original message if no prerequisites.
102
- */
103
- declare function prependSkillDirective(message: string, prerequisiteFiles: string[]): string;
104
-
105
- export { AGENTS_PLUGIN_NAME, type CreateSkillActivationPlanOptions, type LoadedSkill, type SkillActivation, type SkillActivationPlan, type SkillActivationReason, type SkillMetadata, type SkillPolicyExtension, type SkillSource, createSkillActivationPlan, formatSkillDirective, prependSkillDirective };
106
-
107
- // -- @weft/skills/index.d.ts --
108
-
109
- interface SkillValidationIssue {
110
- file: string;
111
- path: string;
112
- message: string;
113
- severity: 'error' | 'warning' | 'info';
114
- suggestion?: string;
115
- }
116
- interface SkillValidationResult {
117
- valid: boolean;
118
- errors: SkillValidationIssue[];
119
- warnings: SkillValidationIssue[];
120
- }
121
- declare function validateSkillDefinitionContent(content: string, file?: string): SkillValidationResult;
122
-
123
- /**
124
- * Skills Storage
125
- *
126
- * CRUD operations for workspace skills.
127
- * Skills are stored in {workspace}/skills/{slug}/ directories.
128
- */
129
-
130
- /** Global agent skills directory: ~/.agents/skills/ */
131
- declare const GLOBAL_AGENT_SKILLS_DIR: string;
132
- /** Project-level agent skills relative directory name */
133
- declare const PROJECT_AGENT_SKILLS_DIR = ".agents/skills";
134
- /**
135
- * Load a single skill from a workspace
136
- * @param workspaceRoot - Absolute path to workspace root
137
- * @param slug - Skill directory name
138
- */
139
- declare function loadSkill(workspaceRoot: string, slug: string): LoadedSkill | null;
140
- /** Invalidate the skills cache (call on working dir change or skill file events). */
141
- declare function invalidateSkillsCache(): void;
142
- /**
143
- * Load all skills from all sources (global, workspace, project)
144
- * Skills with the same slug are overridden by higher-priority sources.
145
- * Priority: global (lowest) < workspace < project (highest)
146
- *
147
- * Results are cached per (workspaceRoot, projectRoot) pair. Call
148
- * invalidateSkillsCache() on working directory changes or skill file events.
149
- *
150
- * @param workspaceRoot - Absolute path to workspace root
151
- * @param projectRoot - Optional project root (working directory) for project-level skills
152
- */
153
- declare function loadAllSkills(workspaceRoot: string, projectRoot?: string): LoadedSkill[];
154
- /**
155
- * Load a single skill by slug from all sources (project > workspace > global).
156
- * Unlike loadAllSkills(), this only reads the specific slug directory — O(1) not O(N).
157
- *
158
- * @param workspaceRoot - Absolute path to workspace root
159
- * @param slug - Skill slug to load
160
- * @param projectRoot - Optional project root for project-level skills
161
- */
162
- declare function loadSkillBySlug(workspaceRoot: string, slug: string, projectRoot?: string): LoadedSkill | null;
163
- /**
164
- * Get icon path for a skill
165
- * @param workspaceRoot - Absolute path to workspace root
166
- * @param slug - Skill directory name
167
- */
168
- declare function getSkillIconPath(workspaceRoot: string, slug: string): string | null;
169
- /**
170
- * Delete a skill from a workspace
171
- * @param workspaceRoot - Absolute path to workspace root
172
- * @param slug - Skill directory name
173
- */
174
- declare function deleteSkill(workspaceRoot: string, slug: string): boolean;
175
- interface CreateSkillInput {
176
- slug: string;
177
- name: string;
178
- description: string;
179
- content: string;
180
- globs?: string[];
181
- alwaysAllow?: string[];
182
- icon?: string;
183
- requiredSources?: string[];
184
- }
185
- interface UpdateSkillInput {
186
- name?: string;
187
- description?: string;
188
- content?: string;
189
- globs?: string[];
190
- alwaysAllow?: string[];
191
- icon?: string;
192
- requiredSources?: string[];
193
- }
194
- declare function createSkill(workspaceRoot: string, input: CreateSkillInput): LoadedSkill;
195
- declare function updateSkill(workspaceRoot: string, slug: string, patch: UpdateSkillInput): LoadedSkill;
196
- /**
197
- * Check if a skill exists in a workspace
198
- * @param workspaceRoot - Absolute path to workspace root
199
- * @param slug - Skill directory name
200
- */
201
- declare function skillExists(workspaceRoot: string, slug: string): boolean;
202
- /**
203
- * List skill slugs in a workspace
204
- * @param workspaceRoot - Absolute path to workspace root
205
- */
206
- declare function listSkillSlugs(workspaceRoot: string): string[];
207
- /**
208
- * Download an icon from a URL and save it to the skill directory.
209
- * Returns the path to the downloaded icon, or null on failure.
210
- */
211
- declare function downloadSkillIcon(skillDir: string, iconUrl: string): Promise<string | null>;
212
- /**
213
- * Check if a skill needs its icon downloaded.
214
- * Returns true if metadata has a URL icon and no local icon file exists.
215
- */
216
- declare function skillNeedsIconDownload(skill: LoadedSkill): boolean;
217
-
218
- export { type CreateSkillInput, GLOBAL_AGENT_SKILLS_DIR, LoadedSkill, PROJECT_AGENT_SKILLS_DIR, type SkillValidationIssue, type SkillValidationResult, type UpdateSkillInput, createSkill, deleteSkill, downloadSkillIcon, getSkillIconPath, invalidateSkillsCache, listSkillSlugs, loadAllSkills, loadSkill, loadSkillBySlug, skillExists, skillNeedsIconDownload, updateSkill, validateSkillDefinitionContent };