@compilr-dev/sdk 0.9.30 → 0.10.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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -3
- package/dist/skills/index.d.ts +5 -0
- package/dist/skills/index.js +3 -3
- package/dist/skills/loader.d.ts +30 -0
- package/dist/skills/loader.js +133 -0
- package/dist/skills/resolver.d.ts +55 -0
- package/dist/skills/resolver.js +80 -0
- package/dist/skills/types.d.ts +84 -0
- package/dist/skills/types.js +67 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export type { GuideEntry, ContentTopic, ContentSection, GuideToolConfig } from '
|
|
|
67
67
|
export { createPlatformTools, createProjectTools, createWorkItemTools, createDocumentTools, createPlanTools, createBacklogTools, createAnchorTools, createArtifactTools, createEpisodeTools, createImageTools, ProjectAnchorStore, } from './platform/index.js';
|
|
68
68
|
export type { ProjectAnchorStoreConfig, ImageToolsConfig, ImageResizer } from './platform/index.js';
|
|
69
69
|
export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './platform/index.js';
|
|
70
|
+
export type { CustomSkill, CompilrSkillExtension, ForkedFromMarker, SkillEligibilityContext, } from './skills/index.js';
|
|
71
|
+
export { RESERVED_SKILL_NAMES, isReservedSkillName, parseSkillMarkdown, loadSkillsFromDir, resolveLayeredSkills, resolveSkillsForAgent, } from './skills/index.js';
|
|
70
72
|
export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, outlineSkill, literatureReviewSkill, draftSectionSkill, peerReviewSkill, researchScaffoldSkill, businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, financialModelSkill, pitchOutlineSkill, businessReviewSkill, brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './skills/index.js';
|
|
71
73
|
export { ACTION_REGISTRY, getActionsForContext, getActionById, resolveActionPrompt, buildContextSummary, getSuggestedRole, } from './actions/index.js';
|
|
72
74
|
export type { ActionContext, ActionDefinition } from './actions/index.js';
|
package/dist/index.js
CHANGED
|
@@ -152,9 +152,7 @@ export { createPlatformTools, createProjectTools, createWorkItemTools, createDoc
|
|
|
152
152
|
// Platform Workflow (pure step-criteria logic)
|
|
153
153
|
// =============================================================================
|
|
154
154
|
export { STEP_ORDER, GUIDED_STEP_CRITERIA, getNextStep, isValidTransition, getStepCriteria, formatStepDisplay, getStepNumber, } from './platform/index.js';
|
|
155
|
-
|
|
156
|
-
// Platform Skills (platform-specific prompt expansions)
|
|
157
|
-
// =============================================================================
|
|
155
|
+
export { RESERVED_SKILL_NAMES, isReservedSkillName, parseSkillMarkdown, loadSkillsFromDir, resolveLayeredSkills, resolveSkillsForAgent, } from './skills/index.js';
|
|
158
156
|
export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, outlineSkill, literatureReviewSkill, draftSectionSkill, peerReviewSkill, researchScaffoldSkill, businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, financialModelSkill, pitchOutlineSkill, businessReviewSkill, brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './skills/index.js';
|
|
159
157
|
// =============================================================================
|
|
160
158
|
// Contextual Actions (skill invocations with context)
|
package/dist/skills/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Skills — barrel export
|
|
3
3
|
*/
|
|
4
|
+
export type { CustomSkill, CompilrSkillExtension, ForkedFromMarker } from './types.js';
|
|
5
|
+
export { RESERVED_SKILL_NAMES, isReservedSkillName } from './types.js';
|
|
6
|
+
export { parseSkillMarkdown, loadSkillsFromDir } from './loader.js';
|
|
7
|
+
export type { SkillEligibilityContext } from './resolver.js';
|
|
8
|
+
export { resolveLayeredSkills, resolveSkillsForAgent } from './resolver.js';
|
|
4
9
|
export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, outlineSkill, literatureReviewSkill, draftSectionSkill, peerReviewSkill, researchScaffoldSkill, businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, financialModelSkill, pitchOutlineSkill, businessReviewSkill, brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './platform-skills.js';
|
package/dist/skills/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { RESERVED_SKILL_NAMES, isReservedSkillName } from './types.js';
|
|
2
|
+
export { parseSkillMarkdown, loadSkillsFromDir } from './loader.js';
|
|
3
|
+
export { resolveLayeredSkills, resolveSkillsForAgent } from './resolver.js';
|
|
4
4
|
export { platformSkills, designSkill, sketchSkill, prdSkill, refineSkill, refineItemSkill, architectureSkill, sessionNotesSkill, buildSkill, scaffoldSkill, outlineSkill, literatureReviewSkill, draftSectionSkill, peerReviewSkill, researchScaffoldSkill, businessVisionSkill, marketAnalysisSkill, competitorAnalysisSkill, financialModelSkill, pitchOutlineSkill, businessReviewSkill, brandSetupSkill, contentStrategySkill, contentCalendarSkill, createContentSkill, contentReviewSkill, curriculumDesignSkill, lessonPlanSkill, assessmentDesignSkill, courseReviewSkill, bookOutlineSkill, characterDesignSkill, plotThreadsSkill, sceneBreakdownSkill, bookReviewSkill, } from './platform-skills.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill loader — reads <dir>/<name>/SKILL.md from disk into CustomSkill objects.
|
|
3
|
+
*
|
|
4
|
+
* File format follows Anthropic Agent Skills spec (agentskills.io):
|
|
5
|
+
* <name>/SKILL.md — required, frontmatter + body
|
|
6
|
+
* <name>/references/ — optional progressive-disclosure detail
|
|
7
|
+
* <name>/scripts/ — optional executable scripts
|
|
8
|
+
* <name>/templates/ — optional starter files
|
|
9
|
+
* <name>/assets/ — optional binary assets
|
|
10
|
+
* <name>/LICENSE.txt — optional, author's choice
|
|
11
|
+
*
|
|
12
|
+
* Spec: /workspace/project-docs/00-requirements/compilr-dev-sdk/custom-skills-spec.md
|
|
13
|
+
*/
|
|
14
|
+
import type { CustomSkill } from './types.js';
|
|
15
|
+
/**
|
|
16
|
+
* Parse a SKILL.md string into a CustomSkill.
|
|
17
|
+
*
|
|
18
|
+
* Minimal YAML frontmatter parser — handles the subset we use without
|
|
19
|
+
* pulling in a yaml dependency. Returns null on malformed input so the
|
|
20
|
+
* caller can warn-and-skip rather than crash.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseSkillMarkdown(content: string, sourcePath?: string, source?: CustomSkill['source']): CustomSkill | null;
|
|
23
|
+
/**
|
|
24
|
+
* Load all skills from a directory. Each subdirectory containing a
|
|
25
|
+
* SKILL.md becomes one CustomSkill. Malformed files are skipped with
|
|
26
|
+
* a warning callback.
|
|
27
|
+
*
|
|
28
|
+
* Returns [] if the directory doesn't exist.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadSkillsFromDir(dir: string, source?: CustomSkill['source'], onWarn?: (msg: string) => void): Promise<CustomSkill[]>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill loader — reads <dir>/<name>/SKILL.md from disk into CustomSkill objects.
|
|
3
|
+
*
|
|
4
|
+
* File format follows Anthropic Agent Skills spec (agentskills.io):
|
|
5
|
+
* <name>/SKILL.md — required, frontmatter + body
|
|
6
|
+
* <name>/references/ — optional progressive-disclosure detail
|
|
7
|
+
* <name>/scripts/ — optional executable scripts
|
|
8
|
+
* <name>/templates/ — optional starter files
|
|
9
|
+
* <name>/assets/ — optional binary assets
|
|
10
|
+
* <name>/LICENSE.txt — optional, author's choice
|
|
11
|
+
*
|
|
12
|
+
* Spec: /workspace/project-docs/00-requirements/compilr-dev-sdk/custom-skills-spec.md
|
|
13
|
+
*/
|
|
14
|
+
import { promises as fs } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { parse as parseYamlReal } from 'yaml';
|
|
17
|
+
/**
|
|
18
|
+
* Parse a SKILL.md string into a CustomSkill.
|
|
19
|
+
*
|
|
20
|
+
* Minimal YAML frontmatter parser — handles the subset we use without
|
|
21
|
+
* pulling in a yaml dependency. Returns null on malformed input so the
|
|
22
|
+
* caller can warn-and-skip rather than crash.
|
|
23
|
+
*/
|
|
24
|
+
export function parseSkillMarkdown(content, sourcePath, source) {
|
|
25
|
+
// Frontmatter is delimited by `---` on its own line at the very top.
|
|
26
|
+
const fm = matchFrontmatter(content);
|
|
27
|
+
if (!fm)
|
|
28
|
+
return null;
|
|
29
|
+
const meta = parseYaml(fm.frontmatter);
|
|
30
|
+
if (!meta)
|
|
31
|
+
return null;
|
|
32
|
+
const name = typeof meta['name'] === 'string' ? meta['name'] : null;
|
|
33
|
+
const description = typeof meta['description'] === 'string' ? meta['description'] : null;
|
|
34
|
+
if (!name || !description)
|
|
35
|
+
return null;
|
|
36
|
+
const skill = {
|
|
37
|
+
name,
|
|
38
|
+
description,
|
|
39
|
+
prompt: fm.body.trim(),
|
|
40
|
+
sourcePath,
|
|
41
|
+
source,
|
|
42
|
+
};
|
|
43
|
+
if (typeof meta['license'] === 'string')
|
|
44
|
+
skill.license = meta['license'];
|
|
45
|
+
if (typeof meta['version'] === 'string')
|
|
46
|
+
skill.version = meta['version'];
|
|
47
|
+
if (Array.isArray(meta['tags']))
|
|
48
|
+
skill.tags = meta['tags'].filter((t) => typeof t === 'string');
|
|
49
|
+
if (typeof meta['enabled'] === 'boolean')
|
|
50
|
+
skill.enabled = meta['enabled'];
|
|
51
|
+
if (meta['compilr'] && typeof meta['compilr'] === 'object') {
|
|
52
|
+
skill.compilr = meta['compilr'];
|
|
53
|
+
}
|
|
54
|
+
if (meta['forkedFrom'] && typeof meta['forkedFrom'] === 'object') {
|
|
55
|
+
skill.forkedFrom = meta['forkedFrom'];
|
|
56
|
+
}
|
|
57
|
+
return skill;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Load all skills from a directory. Each subdirectory containing a
|
|
61
|
+
* SKILL.md becomes one CustomSkill. Malformed files are skipped with
|
|
62
|
+
* a warning callback.
|
|
63
|
+
*
|
|
64
|
+
* Returns [] if the directory doesn't exist.
|
|
65
|
+
*/
|
|
66
|
+
export async function loadSkillsFromDir(dir, source = 'user', onWarn) {
|
|
67
|
+
let entries;
|
|
68
|
+
try {
|
|
69
|
+
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
const skills = [];
|
|
75
|
+
for (const entry of entries) {
|
|
76
|
+
if (!entry.isDirectory())
|
|
77
|
+
continue;
|
|
78
|
+
const skillDir = join(dir, entry.name);
|
|
79
|
+
const skillFile = join(skillDir, 'SKILL.md');
|
|
80
|
+
let content;
|
|
81
|
+
try {
|
|
82
|
+
content = await fs.readFile(skillFile, 'utf-8');
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
continue; // No SKILL.md in this directory — not a skill folder.
|
|
86
|
+
}
|
|
87
|
+
const parsed = parseSkillMarkdown(content, skillDir, source);
|
|
88
|
+
if (!parsed) {
|
|
89
|
+
onWarn?.(`Skill at ${skillFile} has invalid frontmatter (missing name or description)`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Auto-set scope from source if not explicit.
|
|
93
|
+
if (!parsed.compilr)
|
|
94
|
+
parsed.compilr = {};
|
|
95
|
+
if (!parsed.compilr.scope) {
|
|
96
|
+
parsed.compilr.scope =
|
|
97
|
+
source === 'project' ? 'project' : source === 'user' ? 'user' : undefined;
|
|
98
|
+
}
|
|
99
|
+
skills.push(parsed);
|
|
100
|
+
}
|
|
101
|
+
return skills;
|
|
102
|
+
}
|
|
103
|
+
// =============================================================================
|
|
104
|
+
// Internal — frontmatter + minimal YAML
|
|
105
|
+
// =============================================================================
|
|
106
|
+
function matchFrontmatter(content) {
|
|
107
|
+
if (!content.startsWith('---'))
|
|
108
|
+
return null;
|
|
109
|
+
const lines = content.split('\n');
|
|
110
|
+
if (lines[0] !== '---')
|
|
111
|
+
return null;
|
|
112
|
+
for (let i = 1; i < lines.length; i++) {
|
|
113
|
+
if (lines[i] === '---') {
|
|
114
|
+
return {
|
|
115
|
+
frontmatter: lines.slice(1, i).join('\n'),
|
|
116
|
+
body: lines.slice(i + 1).join('\n'),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
function parseYaml(text) {
|
|
123
|
+
try {
|
|
124
|
+
const parsed = parseYamlReal(text);
|
|
125
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return parsed;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill resolver — 5-layer priority + 2-stage selection.
|
|
3
|
+
*
|
|
4
|
+
* Spec: /workspace/project-docs/00-requirements/compilr-dev-sdk/custom-skills-spec.md
|
|
5
|
+
*
|
|
6
|
+
* 5-layer priority (first match by name wins):
|
|
7
|
+
* 1. project (<projectDir>/.compilr/skills/)
|
|
8
|
+
* 2. user (~/.compilr-dev/skills/)
|
|
9
|
+
* 3. sdk (platformSkills)
|
|
10
|
+
* 4. agents (builtinSkills)
|
|
11
|
+
* 5. agents-coding (codingSkills)
|
|
12
|
+
*
|
|
13
|
+
* 2-stage selection:
|
|
14
|
+
* - Stage 1 ELIGIBILITY: declarative filter, runs at agent boot.
|
|
15
|
+
* - Stage 2 ACTIVATION: model picks from descriptions, runs per turn.
|
|
16
|
+
* (Stage 2 is the existing skill invocation — this file only does Stage 1.)
|
|
17
|
+
*/
|
|
18
|
+
import type { CustomSkill } from './types.js';
|
|
19
|
+
/**
|
|
20
|
+
* Agent context used for eligibility filtering. Decoupled from the full
|
|
21
|
+
* Agent class so non-runtime callers (CLI listers, desktop preview) can
|
|
22
|
+
* compute eligibility without instantiating an agent.
|
|
23
|
+
*/
|
|
24
|
+
export interface SkillEligibilityContext {
|
|
25
|
+
/** Agent's role identifier ('arch', 'qa', 'researcher', 'writer', etc.). */
|
|
26
|
+
role?: string;
|
|
27
|
+
/** Specific custom-agent id, if any. */
|
|
28
|
+
agentId?: string;
|
|
29
|
+
/** Tool names this agent has access to. */
|
|
30
|
+
toolNames?: ReadonlySet<string> | readonly string[];
|
|
31
|
+
/** Explicit skill allowlist on the agent (legacy enabledSkills). */
|
|
32
|
+
enabledSkills?: readonly string[];
|
|
33
|
+
/** Active project category ('software', 'research', 'business', ...). */
|
|
34
|
+
projectType?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a list of skills from layered sources by priority. First match
|
|
38
|
+
* by name wins. Returns the deduplicated list, with each skill carrying
|
|
39
|
+
* its `source` field so callers can render origin in the UI.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveLayeredSkills(layers: {
|
|
42
|
+
project?: CustomSkill[];
|
|
43
|
+
user?: CustomSkill[];
|
|
44
|
+
sdk?: CustomSkill[];
|
|
45
|
+
agents?: CustomSkill[];
|
|
46
|
+
agentsCoding?: CustomSkill[];
|
|
47
|
+
}): CustomSkill[];
|
|
48
|
+
/**
|
|
49
|
+
* Stage 1 — Eligibility filter. Given a resolved skill registry and an
|
|
50
|
+
* agent context, return only the skills this agent should see.
|
|
51
|
+
*
|
|
52
|
+
* Stage 2 (model picks based on description) is the existing skill
|
|
53
|
+
* activation flow and lives at the call site, not here.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveSkillsForAgent(skills: CustomSkill[], context: SkillEligibilityContext): CustomSkill[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill resolver — 5-layer priority + 2-stage selection.
|
|
3
|
+
*
|
|
4
|
+
* Spec: /workspace/project-docs/00-requirements/compilr-dev-sdk/custom-skills-spec.md
|
|
5
|
+
*
|
|
6
|
+
* 5-layer priority (first match by name wins):
|
|
7
|
+
* 1. project (<projectDir>/.compilr/skills/)
|
|
8
|
+
* 2. user (~/.compilr-dev/skills/)
|
|
9
|
+
* 3. sdk (platformSkills)
|
|
10
|
+
* 4. agents (builtinSkills)
|
|
11
|
+
* 5. agents-coding (codingSkills)
|
|
12
|
+
*
|
|
13
|
+
* 2-stage selection:
|
|
14
|
+
* - Stage 1 ELIGIBILITY: declarative filter, runs at agent boot.
|
|
15
|
+
* - Stage 2 ACTIVATION: model picks from descriptions, runs per turn.
|
|
16
|
+
* (Stage 2 is the existing skill invocation — this file only does Stage 1.)
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a list of skills from layered sources by priority. First match
|
|
20
|
+
* by name wins. Returns the deduplicated list, with each skill carrying
|
|
21
|
+
* its `source` field so callers can render origin in the UI.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveLayeredSkills(layers) {
|
|
24
|
+
const seen = new Map();
|
|
25
|
+
const tag = (skills, source) => (skills ?? []).map((s) => ({ ...s, source: s.source ?? source }));
|
|
26
|
+
// Priority order: project > user > sdk > agents > agents-coding.
|
|
27
|
+
for (const skill of [
|
|
28
|
+
...tag(layers.project, 'project'),
|
|
29
|
+
...tag(layers.user, 'user'),
|
|
30
|
+
...tag(layers.sdk, 'sdk'),
|
|
31
|
+
...tag(layers.agents, 'agents'),
|
|
32
|
+
...tag(layers.agentsCoding, 'agents-coding'),
|
|
33
|
+
]) {
|
|
34
|
+
if (!seen.has(skill.name)) {
|
|
35
|
+
seen.set(skill.name, skill);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return [...seen.values()];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Stage 1 — Eligibility filter. Given a resolved skill registry and an
|
|
42
|
+
* agent context, return only the skills this agent should see.
|
|
43
|
+
*
|
|
44
|
+
* Stage 2 (model picks based on description) is the existing skill
|
|
45
|
+
* activation flow and lives at the call site, not here.
|
|
46
|
+
*/
|
|
47
|
+
export function resolveSkillsForAgent(skills, context) {
|
|
48
|
+
const toolSet = context.toolNames instanceof Set ? context.toolNames : new Set(context.toolNames ?? []);
|
|
49
|
+
const allowlist = context.enabledSkills ? new Set(context.enabledSkills) : null;
|
|
50
|
+
return skills.filter((skill) => {
|
|
51
|
+
if (skill.enabled === false)
|
|
52
|
+
return false;
|
|
53
|
+
// Stage 1.1 — Targeting. Default = targets every agent.
|
|
54
|
+
const targets = skill.compilr?.targets;
|
|
55
|
+
if (targets) {
|
|
56
|
+
const matches = targets.all === true ||
|
|
57
|
+
(targets.roles && context.role && targets.roles.includes(context.role)) ||
|
|
58
|
+
(targets.agentIds && context.agentId && targets.agentIds.includes(context.agentId));
|
|
59
|
+
if (!matches)
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// Stage 1.2 — Project type filter.
|
|
63
|
+
const requires = skill.compilr?.requires;
|
|
64
|
+
if (requires?.projectTypes && context.projectType) {
|
|
65
|
+
if (!requires.projectTypes.includes(context.projectType))
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
// Stage 1.3 — Tool guard.
|
|
69
|
+
if (requires?.tools) {
|
|
70
|
+
for (const t of requires.tools) {
|
|
71
|
+
if (!toolSet.has(t))
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Stage 1.4 — Agent's explicit enabledSkills allowlist (legacy mechanism).
|
|
76
|
+
if (allowlist && !allowlist.has(skill.name))
|
|
77
|
+
return false;
|
|
78
|
+
return true;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom skill types — Anthropic-format frontmatter + compilr extensions.
|
|
3
|
+
*
|
|
4
|
+
* Spec: /workspace/project-docs/00-requirements/compilr-dev-sdk/custom-skills-spec.md
|
|
5
|
+
*
|
|
6
|
+
* The base shape matches Anthropic's Agent Skills standard
|
|
7
|
+
* (https://agentskills.io/specification): folder with SKILL.md, YAML
|
|
8
|
+
* frontmatter requiring only `name` + `description`. Our multi-agent
|
|
9
|
+
* extensions live under the optional `compilr:` block, which
|
|
10
|
+
* Anthropic-compatible runtimes ignore.
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentRole } from '../team/types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Compilr-specific skill targeting and requirements.
|
|
15
|
+
*
|
|
16
|
+
* Lives under the `compilr:` key in SKILL.md frontmatter. Optional —
|
|
17
|
+
* defaults to `targets: { all: true }` and no requires.
|
|
18
|
+
*/
|
|
19
|
+
export interface CompilrSkillExtension {
|
|
20
|
+
/** Which agents are eligible to load this skill. */
|
|
21
|
+
targets?: {
|
|
22
|
+
/** Match by role (e.g. 'researcher', 'writer', 'arch', 'qa'). */
|
|
23
|
+
roles?: AgentRole[];
|
|
24
|
+
/** Match by specific custom-agent id. */
|
|
25
|
+
agentIds?: string[];
|
|
26
|
+
/** Set true to target every agent in the project. */
|
|
27
|
+
all?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** Conditions that must hold for the skill to be eligible. */
|
|
30
|
+
requires?: {
|
|
31
|
+
/** Tool names the agent must have to load this skill. */
|
|
32
|
+
tools?: string[];
|
|
33
|
+
/** Project categories where this skill applies. */
|
|
34
|
+
projectTypes?: string[];
|
|
35
|
+
};
|
|
36
|
+
/** Where the skill lives. Auto-set by location, but explicit is allowed. */
|
|
37
|
+
scope?: 'user' | 'project';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Marker on forked SDK skills.
|
|
41
|
+
*/
|
|
42
|
+
export interface ForkedFromMarker {
|
|
43
|
+
source: string;
|
|
44
|
+
skill: string;
|
|
45
|
+
version: string;
|
|
46
|
+
forkedAt: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Custom skill — matches Anthropic spec + compilr extensions.
|
|
50
|
+
*
|
|
51
|
+
* Loaded from SKILL.md files in user/project skill directories. Built-in
|
|
52
|
+
* SDK skills (defined via defineSkill()) extend the base agents-lib Skill
|
|
53
|
+
* shape with these same optional fields for consistency.
|
|
54
|
+
*/
|
|
55
|
+
export interface CustomSkill {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
/** Markdown body — the prompt text. */
|
|
59
|
+
prompt: string;
|
|
60
|
+
license?: string;
|
|
61
|
+
version?: string;
|
|
62
|
+
tags?: string[];
|
|
63
|
+
enabled?: boolean;
|
|
64
|
+
compilr?: CompilrSkillExtension;
|
|
65
|
+
/** Set when this skill was created via /skill fork. */
|
|
66
|
+
forkedFrom?: ForkedFromMarker;
|
|
67
|
+
/** Absolute path to the skill directory (containing SKILL.md). */
|
|
68
|
+
sourcePath?: string;
|
|
69
|
+
/** Where this skill came from. */
|
|
70
|
+
source?: 'project' | 'user' | 'sdk' | 'agents' | 'agents-coding';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* SDK skill names that are reserved — user/project skills cannot use these.
|
|
74
|
+
*
|
|
75
|
+
* The CLI's `/skill new` validation rejects creation of any of these
|
|
76
|
+
* names. Customizing behavior of a reserved name happens via:
|
|
77
|
+
* /skill fork <name> → clone under a new name
|
|
78
|
+
* /skill bind <cmd> → remap slash command to a custom skill
|
|
79
|
+
*
|
|
80
|
+
* This list is the union of all platform-skill names exported by
|
|
81
|
+
* platform-skills.ts. Keep it in sync when adding new SDK skills.
|
|
82
|
+
*/
|
|
83
|
+
export declare const RESERVED_SKILL_NAMES: readonly string[];
|
|
84
|
+
export declare function isReservedSkillName(name: string): boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom skill types — Anthropic-format frontmatter + compilr extensions.
|
|
3
|
+
*
|
|
4
|
+
* Spec: /workspace/project-docs/00-requirements/compilr-dev-sdk/custom-skills-spec.md
|
|
5
|
+
*
|
|
6
|
+
* The base shape matches Anthropic's Agent Skills standard
|
|
7
|
+
* (https://agentskills.io/specification): folder with SKILL.md, YAML
|
|
8
|
+
* frontmatter requiring only `name` + `description`. Our multi-agent
|
|
9
|
+
* extensions live under the optional `compilr:` block, which
|
|
10
|
+
* Anthropic-compatible runtimes ignore.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* SDK skill names that are reserved — user/project skills cannot use these.
|
|
14
|
+
*
|
|
15
|
+
* The CLI's `/skill new` validation rejects creation of any of these
|
|
16
|
+
* names. Customizing behavior of a reserved name happens via:
|
|
17
|
+
* /skill fork <name> → clone under a new name
|
|
18
|
+
* /skill bind <cmd> → remap slash command to a custom skill
|
|
19
|
+
*
|
|
20
|
+
* This list is the union of all platform-skill names exported by
|
|
21
|
+
* platform-skills.ts. Keep it in sync when adding new SDK skills.
|
|
22
|
+
*/
|
|
23
|
+
export const RESERVED_SKILL_NAMES = [
|
|
24
|
+
// Software (9)
|
|
25
|
+
'design',
|
|
26
|
+
'sketch',
|
|
27
|
+
'prd',
|
|
28
|
+
'refine',
|
|
29
|
+
'refine-item',
|
|
30
|
+
'architecture',
|
|
31
|
+
'session-notes',
|
|
32
|
+
'build',
|
|
33
|
+
'scaffold',
|
|
34
|
+
// Research (5)
|
|
35
|
+
'outline',
|
|
36
|
+
'literature-review',
|
|
37
|
+
'draft-section',
|
|
38
|
+
'peer-review',
|
|
39
|
+
'research-scaffold',
|
|
40
|
+
// Business (6)
|
|
41
|
+
'business-vision',
|
|
42
|
+
'market-analysis',
|
|
43
|
+
'competitor-analysis',
|
|
44
|
+
'financial-model',
|
|
45
|
+
'pitch-outline',
|
|
46
|
+
'business-review',
|
|
47
|
+
// Content (5)
|
|
48
|
+
'brand-setup',
|
|
49
|
+
'content-strategy',
|
|
50
|
+
'content-calendar',
|
|
51
|
+
'create-content',
|
|
52
|
+
'content-review',
|
|
53
|
+
// Course (4)
|
|
54
|
+
'curriculum-design',
|
|
55
|
+
'lesson-plan',
|
|
56
|
+
'assessment-design',
|
|
57
|
+
'course-review',
|
|
58
|
+
// Book (5)
|
|
59
|
+
'book-outline',
|
|
60
|
+
'character-design',
|
|
61
|
+
'plot-threads',
|
|
62
|
+
'scene-breakdown',
|
|
63
|
+
'book-review',
|
|
64
|
+
];
|
|
65
|
+
export function isReservedSkillName(name) {
|
|
66
|
+
return RESERVED_SKILL_NAMES.includes(name);
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compilr-dev/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Universal agent runtime for building AI-powered applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@compilr-dev/agents": "^0.5.7",
|
|
60
60
|
"@compilr-dev/logger": "^0.1.0",
|
|
61
|
-
"ajv": "^6.14.0"
|
|
61
|
+
"ajv": "^6.14.0",
|
|
62
|
+
"yaml": "^2.8.4"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"@compilr-dev/agents-coding": "^1.0.6",
|