@causyne/agent 1.20.99 → 1.20.103
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/bin/causyne.js +18 -1
- package/package.json +1 -1
- package/src/agentLoop.js +81 -21
- package/src/agentLoop.ts +78 -21
- package/src/autoUpdate.js +4 -4
- package/src/autoUpdate.ts +4 -4
- package/src/cliMode.js +2 -0
- package/src/compiledSkills.d.ts +5 -0
- package/src/launchIntent.js +52 -1
- package/src/launchIntent.ts +56 -1
- package/src/plugins/pluginManager.d.ts +7 -0
- package/src/plugins/pluginSkills.js +1 -0
- package/src/plugins/pluginSkills.ts +1 -0
- package/src/promptMentions.js +1 -1
- package/src/promptMentions.ts +1 -1
- package/src/skills/skillResourceSafety.js +38 -2
- package/src/skills/skillResourceSafety.ts +39 -2
- package/src/skillsManager.js +224 -232
- package/src/skillsManager.ts +354 -0
- package/src/tools/createSkill.js +92 -104
- package/src/tools/createSkill.ts +142 -0
- package/src/tools/fsEdit.js +104 -91
- package/src/tools/fsEdit.ts +144 -0
- package/src/tools/multiEdit.js +105 -93
- package/src/tools/multiEdit.ts +145 -0
- package/src/tools/readNativeSkill.js +2 -1
- package/src/tools/readNativeSkill.ts +2 -1
- package/src/tui/mouseHover.js +0 -4
- package/src/tui/mouseHover.ts +0 -4
- package/src/tui/prompt.js +12 -0
- package/src/tui/stageSurface.js +12 -13
- package/src/userSkills.js +5 -4
- package/src/userSkills.ts +6 -4
- package/src/skillsManager.d.ts +0 -7
package/src/skillsManager.js
CHANGED
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
4
3
|
import { COMPILED_SKILLS } from './compiledSkills.js';
|
|
5
4
|
import { loadUserSkills } from './userSkills.js';
|
|
6
5
|
import { getPluginSkills } from './plugins/pluginManager.js';
|
|
7
|
-
|
|
6
|
+
const compiledSkillsCatalog = COMPILED_SKILLS;
|
|
8
7
|
// User skills are read from disk, and the disk is slow relative to how often
|
|
9
8
|
// these functions are called (every completion keystroke asks for the
|
|
10
9
|
// catalogue). Cache for a moment so typing stays instant, but keep the window
|
|
11
10
|
// short enough that a skill the agent just wrote shows up without a restart.
|
|
12
11
|
const USER_CACHE_MS = 2000;
|
|
13
12
|
let userCache = { at: 0, skills: [], problems: [] };
|
|
14
|
-
|
|
15
13
|
export function invalidateUserSkills() {
|
|
16
|
-
|
|
14
|
+
userCache = { at: 0, skills: [], problems: [] };
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
function userSkills() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
const now = Date.now();
|
|
18
|
+
if (now - userCache.at < USER_CACHE_MS)
|
|
19
|
+
return userCache;
|
|
20
|
+
try {
|
|
21
|
+
const loaded = loadUserSkills();
|
|
22
|
+
userCache = { at: now, skills: loaded.skills, problems: loaded.problems };
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
// A broken skills directory must never stop a session from starting.
|
|
26
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
27
|
+
userCache = { at: now, skills: [], problems: [`user skills unavailable: ${msg}`] };
|
|
28
|
+
}
|
|
29
|
+
return userCache;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
31
|
export function userSkillProblems() {
|
|
33
|
-
|
|
32
|
+
return userSkills().problems;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
34
|
// What a workspace looks like from the outside.
|
|
37
35
|
//
|
|
38
36
|
// This used to name four domains, which meant that of the compiled skills only
|
|
@@ -43,48 +41,46 @@ export function userSkillProblems() {
|
|
|
43
41
|
// Marker files only; no globbing and no directory walking, so detection stays a
|
|
44
42
|
// handful of stat calls whatever the size of the repository.
|
|
45
43
|
const DOMAIN_INDICATORS = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
android: ['build.gradle', 'build.gradle.kts', 'app/build.gradle', 'app/build.gradle.kts',
|
|
45
|
+
'app/src/main/AndroidManifest.xml', 'settings.gradle.kts', 'gradlew'],
|
|
46
|
+
mobile: ['pubspec.yaml', 'ios/Podfile', 'Podfile', 'app.json', 'metro.config.js',
|
|
47
|
+
'react-native.config.js', 'expo.json'],
|
|
48
|
+
web: ['next.config.js', 'next.config.mjs', 'next.config.ts', 'nuxt.config.ts',
|
|
51
49
|
'svelte.config.js', 'vue.config.js', 'astro.config.mjs', 'vite.config.js',
|
|
52
50
|
'vite.config.ts', 'angular.json', 'index.html', 'tailwind.config.js'],
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
backend: ['package.json', 'go.mod', 'Cargo.toml', 'pom.xml', 'build.sbt',
|
|
52
|
+
'Gemfile', 'composer.json', 'nest-cli.json'],
|
|
53
|
+
python: ['requirements.txt', 'pyproject.toml', 'Pipfile', 'setup.py', 'setup.cfg',
|
|
54
|
+
'uv.lock', 'poetry.lock', 'environment.yml'],
|
|
55
|
+
devops: ['Dockerfile', 'docker-compose.yml', 'docker-compose.yaml', '.github/workflows',
|
|
56
|
+
'.gitlab-ci.yml', 'Jenkinsfile', 'Makefile', '.circleci/config.yml'],
|
|
57
|
+
cloud: ['main.tf', 'terraform.tf', 'serverless.yml', 'template.yaml', 'Pulumi.yaml',
|
|
58
|
+
'cdk.json', 'k8s', 'kubernetes', 'helm', 'skaffold.yaml'],
|
|
59
|
+
database: ['prisma/schema.prisma', 'migrations', 'alembic.ini', 'knexfile.js',
|
|
60
|
+
'schema.sql', 'db/schema.rb', 'drizzle.config.ts', 'flyway.conf'],
|
|
61
|
+
testing: ['jest.config.js', 'jest.config.ts', 'vitest.config.ts', 'playwright.config.ts',
|
|
62
|
+
'cypress.config.js', 'pytest.ini', 'tox.ini', 'tests', 'test', '__tests__'],
|
|
63
|
+
security: ['.github/dependabot.yml', 'SECURITY.md', '.snyk', 'socket.yml', 'socket.json'],
|
|
64
|
+
design: ['tailwind.config.js', 'tailwind.config.ts', 'styles', 'src/styles',
|
|
65
|
+
'theme.js', 'theme.ts', 'tokens.json', 'postcss.config.js'],
|
|
66
|
+
// A 3D/video workspace. Without a rule here the media skills compile into
|
|
67
|
+
// the artefact and are unreachable by domain detection — tool_search still
|
|
68
|
+
// finds them, but the workspace never volunteers them.
|
|
69
|
+
media: ['.blend', 'assets/3d', 'renders', 'blender', 'shots', 'Resolve Projects'],
|
|
70
|
+
git: ['.git', '.gitignore', '.gitattributes'],
|
|
71
|
+
performance: ['lighthouserc.js', 'lighthouserc.json', '.lighthouserc.yml', 'k6.js',
|
|
72
|
+
'benchmark', 'benchmarks'],
|
|
73
|
+
'ai-engineering': ['.env.example', 'prompts', 'evals', 'langchain.json',
|
|
74
|
+
'llm.config.js', 'openai.json'],
|
|
75
|
+
data: ['dbt_project.yml', 'airflow.cfg', 'dags', 'notebooks', '*.ipynb',
|
|
76
|
+
'dvc.yaml', 'great_expectations']
|
|
79
77
|
};
|
|
80
|
-
|
|
81
78
|
// Domains that apply to every task regardless of what the workspace looks like.
|
|
82
79
|
//
|
|
83
80
|
// Design and security are not properties of a file layout — an agent writing a
|
|
84
81
|
// UI needs the anti-slop direction whether or not a tailwind config exists, and
|
|
85
82
|
// input validation matters whether or not the repository has a SECURITY.md.
|
|
86
83
|
const UNIVERSAL_DOMAINS = ['design', 'security'];
|
|
87
|
-
|
|
88
84
|
// Ceiling on how many skill descriptions may enter the system prompt.
|
|
89
85
|
//
|
|
90
86
|
// With 100 skills, injecting every description of every detected domain would
|
|
@@ -92,72 +88,66 @@ const UNIVERSAL_DOMAINS = ['design', 'security'];
|
|
|
92
88
|
// This is the progressive-disclosure contract: the model sees names and routing
|
|
93
89
|
// conditions, and pulls a body with fs_read_skill only when one is relevant.
|
|
94
90
|
const MAX_INDEXED_SKILLS = 40;
|
|
95
|
-
|
|
96
91
|
export function detectWorkspaceDomains(workspaceRoot) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
if (!workspaceRoot || !fs.existsSync(workspaceRoot))
|
|
93
|
+
return UNIVERSAL_DOMAINS.slice();
|
|
94
|
+
const detectedDomains = [];
|
|
95
|
+
for (const [domain, indicators] of Object.entries(DOMAIN_INDICATORS)) {
|
|
96
|
+
for (const indicator of indicators) {
|
|
97
|
+
// A glob marker means "any file with this extension at the root". Kept to
|
|
98
|
+
// one readdir rather than a walk — a recursive search of a large monorepo
|
|
99
|
+
// on every task start is not worth one extra domain.
|
|
100
|
+
if (indicator.startsWith('*.')) {
|
|
101
|
+
try {
|
|
102
|
+
const extension = indicator.slice(1);
|
|
103
|
+
if (fs.readdirSync(workspaceRoot).some((name) => name.endsWith(extension))) {
|
|
104
|
+
detectedDomains.push(domain);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch { /* unreadable directory is simply not a match */ }
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (fs.existsSync(path.join(workspaceRoot, indicator))) {
|
|
112
|
+
detectedDomains.push(domain);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Shallow check of immediate subdirectories for Android projects located in subfolders
|
|
118
|
+
if (!detectedDomains.includes('android')) {
|
|
107
119
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
120
|
+
const entries = fs.readdirSync(workspaceRoot, { withFileTypes: true });
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules' && entry.name !== 'Library') {
|
|
123
|
+
const subDir = path.join(workspaceRoot, entry.name);
|
|
124
|
+
if (fs.existsSync(path.join(subDir, 'build.gradle')) ||
|
|
125
|
+
fs.existsSync(path.join(subDir, 'build.gradle.kts')) ||
|
|
126
|
+
fs.existsSync(path.join(subDir, 'gradlew')) ||
|
|
127
|
+
fs.existsSync(path.join(subDir, 'app/build.gradle')) ||
|
|
128
|
+
fs.existsSync(path.join(subDir, 'app/build.gradle.kts')) ||
|
|
129
|
+
fs.existsSync(path.join(subDir, 'app/src/main/AndroidManifest.xml'))) {
|
|
130
|
+
detectedDomains.push('android');
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch { /* unreadable directory is simply skipped */ }
|
|
137
|
+
}
|
|
138
|
+
for (const domain of UNIVERSAL_DOMAINS) {
|
|
139
|
+
if (!detectedDomains.includes(domain))
|
|
110
140
|
detectedDomains.push(domain);
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
} catch (e) { /* unreadable directory is simply not a match */ }
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (fs.existsSync(path.join(workspaceRoot, indicator))) {
|
|
117
|
-
detectedDomains.push(domain);
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
141
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// Shallow check of immediate subdirectories for Android projects located in subfolders
|
|
124
|
-
if (!detectedDomains.includes('android')) {
|
|
125
|
-
try {
|
|
126
|
-
const entries = fs.readdirSync(workspaceRoot, { withFileTypes: true });
|
|
127
|
-
for (const entry of entries) {
|
|
128
|
-
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules' && entry.name !== 'Library') {
|
|
129
|
-
const subDir = path.join(workspaceRoot, entry.name);
|
|
130
|
-
if (fs.existsSync(path.join(subDir, 'build.gradle')) ||
|
|
131
|
-
fs.existsSync(path.join(subDir, 'build.gradle.kts')) ||
|
|
132
|
-
fs.existsSync(path.join(subDir, 'gradlew')) ||
|
|
133
|
-
fs.existsSync(path.join(subDir, 'app/build.gradle')) ||
|
|
134
|
-
fs.existsSync(path.join(subDir, 'app/build.gradle.kts')) ||
|
|
135
|
-
fs.existsSync(path.join(subDir, 'app/src/main/AndroidManifest.xml'))) {
|
|
136
|
-
detectedDomains.push('android');
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} catch (e) { /* unreadable directory is simply skipped */ }
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
for (const domain of UNIVERSAL_DOMAINS) {
|
|
145
|
-
if (!detectedDomains.includes(domain)) detectedDomains.push(domain);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return detectedDomains;
|
|
142
|
+
return detectedDomains;
|
|
149
143
|
}
|
|
150
|
-
|
|
151
144
|
export { MAX_INDEXED_SKILLS, UNIVERSAL_DOMAINS };
|
|
152
|
-
|
|
153
145
|
export function ensureSkillRepo(domain) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return false;
|
|
146
|
+
if (compiledSkillsCatalog[domain]) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
159
150
|
}
|
|
160
|
-
|
|
161
151
|
/**
|
|
162
152
|
* The index the model sees: names and routing conditions, never bodies.
|
|
163
153
|
*
|
|
@@ -173,52 +163,49 @@ export function ensureSkillRepo(domain) {
|
|
|
173
163
|
* the cut falls on the least relevant.
|
|
174
164
|
*/
|
|
175
165
|
export function getUniversalSkillsIndex(domains) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// A user's own domains are always offered: someone who wrote a `team/` skill
|
|
187
|
-
// wants it considered, and no marker file in the workspace announces it.
|
|
188
|
-
const ownDomains = [...new Set(userSkills().skills.map((skill) => skill.domain))];
|
|
189
|
-
const wanted = [...new Set([...ownDomains, ...domains])];
|
|
190
|
-
|
|
191
|
-
for (const domain of wanted) {
|
|
192
|
-
const domainSkills = catalogue.get(domain);
|
|
193
|
-
if (!domainSkills || domainSkills.length === 0) continue;
|
|
194
|
-
if (totalSkillsCount >= MAX_INDEXED_SKILLS) break;
|
|
195
|
-
|
|
196
|
-
let domainSkillsCount = 0;
|
|
197
|
-
let domainIndexText = `### ${domain.toUpperCase()} SKILLS\n`;
|
|
198
|
-
|
|
199
|
-
for (const skill of domainSkills) {
|
|
200
|
-
if (totalSkillsCount + domainSkillsCount >= MAX_INDEXED_SKILLS) break;
|
|
201
|
-
const mark = skill.source === 'user' ? ' [your own]' : '';
|
|
202
|
-
domainIndexText += `- **${skill.name}**${mark} (ID: ${domain}/${skill.id}): ${skill.description}\n`;
|
|
203
|
-
domainSkillsCount++;
|
|
166
|
+
let indexText = '';
|
|
167
|
+
let totalSkillsCount = 0;
|
|
168
|
+
// One catalogue, so a user skill is as visible to the agent as a compiled one.
|
|
169
|
+
const catalogue = new Map();
|
|
170
|
+
for (const skill of listCompiledSkills()) {
|
|
171
|
+
if (!catalogue.has(skill.domain))
|
|
172
|
+
catalogue.set(skill.domain, []);
|
|
173
|
+
catalogue.get(skill.domain).push(skill);
|
|
204
174
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
175
|
+
// A user's own domains are always offered: someone who wrote a `team/` skill
|
|
176
|
+
// wants it considered, and no marker file in the workspace announces it.
|
|
177
|
+
const ownDomains = [...new Set(userSkills().skills.map((skill) => skill.domain))];
|
|
178
|
+
const wanted = [...new Set([...ownDomains, ...domains])];
|
|
179
|
+
for (const domain of wanted) {
|
|
180
|
+
const domainSkills = catalogue.get(domain);
|
|
181
|
+
if (!domainSkills || domainSkills.length === 0)
|
|
182
|
+
continue;
|
|
183
|
+
if (totalSkillsCount >= MAX_INDEXED_SKILLS)
|
|
184
|
+
break;
|
|
185
|
+
let domainSkillsCount = 0;
|
|
186
|
+
let domainIndexText = `### ${domain.toUpperCase()} SKILLS\n`;
|
|
187
|
+
for (const skill of domainSkills) {
|
|
188
|
+
if (totalSkillsCount + domainSkillsCount >= MAX_INDEXED_SKILLS)
|
|
189
|
+
break;
|
|
190
|
+
const mark = skill.source === 'user' ? ' [your own]' : '';
|
|
191
|
+
const safeName = String(skill.name || skill.id).replace(/[<>]/g, '');
|
|
192
|
+
const safeDesc = String(skill.description || '').replace(/[<>]/g, '');
|
|
193
|
+
domainIndexText += `- **${safeName}**${mark} (ID: ${domain}/${skill.id}): ${safeDesc}\n`;
|
|
194
|
+
domainSkillsCount++;
|
|
195
|
+
}
|
|
196
|
+
if (domainSkillsCount > 0) {
|
|
197
|
+
indexText += domainIndexText + '\n';
|
|
198
|
+
totalSkillsCount += domainSkillsCount;
|
|
199
|
+
}
|
|
209
200
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
finalOutput += `</causyne_universal_skills>\n`;
|
|
218
|
-
|
|
219
|
-
return finalOutput;
|
|
201
|
+
if (totalSkillsCount === 0)
|
|
202
|
+
return '';
|
|
203
|
+
let finalOutput = `\n<causyne_universal_skills>\n`;
|
|
204
|
+
finalOutput += `You have access to highly-curated, domain-specific intelligence skills provided as readable local skill data. If a skill is relevant to the user's task, you MUST use the \`fs_read_skill\` tool (passing the ID) to read its full instruction BEFORE proceeding with your plan. NEVER guess syntax if a skill exists for it.\n\n`;
|
|
205
|
+
finalOutput += indexText;
|
|
206
|
+
finalOutput += `</causyne_universal_skills>\n`;
|
|
207
|
+
return finalOutput;
|
|
220
208
|
}
|
|
221
|
-
|
|
222
209
|
/**
|
|
223
210
|
* The compact form of the skills index: what domains exist and how to search
|
|
224
211
|
* them, instead of forty name-and-description lines.
|
|
@@ -233,30 +220,28 @@ export function getUniversalSkillsIndex(domains) {
|
|
|
233
220
|
* a capability regression wearing an optimisation's clothes. Retrieval replaces
|
|
234
221
|
* a catalogue only once the retrieval exists.
|
|
235
222
|
*
|
|
236
|
-
* @param
|
|
237
|
-
* @returns
|
|
223
|
+
* @param domains Workspace domains detected for this task.
|
|
224
|
+
* @returns System-prompt fragment, '' when nothing exists.
|
|
238
225
|
*/
|
|
239
226
|
export function getSkillDomainHeader(domains) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return out;
|
|
227
|
+
const catalogue = new Map();
|
|
228
|
+
for (const skill of listCompiledSkills()) {
|
|
229
|
+
catalogue.set(skill.domain, (catalogue.get(skill.domain) || 0) + 1);
|
|
230
|
+
}
|
|
231
|
+
if (catalogue.size === 0)
|
|
232
|
+
return '';
|
|
233
|
+
const total = [...catalogue.values()].reduce((sum, n) => sum + n, 0);
|
|
234
|
+
const relevant = [...new Set(domains || [])].filter((d) => catalogue.has(d));
|
|
235
|
+
const all = [...catalogue.keys()].sort();
|
|
236
|
+
let out = `\n<causyne_universal_skills>\n`;
|
|
237
|
+
out += `${total} curated engineering skills are compiled into you, across: ${all.join(', ')}.\n`;
|
|
238
|
+
if (relevant.length > 0) {
|
|
239
|
+
out += `This workspace looks like: ${relevant.join(', ')}.\n`;
|
|
240
|
+
}
|
|
241
|
+
out += `Call \`tool_search\` with what you are trying to do to find the relevant skill ids, then read one with \`fs_read_skill\`. Do this BEFORE planning anything the skills cover. NEVER guess syntax a skill documents.\n`;
|
|
242
|
+
out += `</causyne_universal_skills>\n`;
|
|
243
|
+
return out;
|
|
258
244
|
}
|
|
259
|
-
|
|
260
245
|
/**
|
|
261
246
|
* The whole catalogue as a flat list, for the picker and for `/skills`.
|
|
262
247
|
*
|
|
@@ -264,64 +249,71 @@ export function getSkillDomainHeader(domains) {
|
|
|
264
249
|
* never disagree about what exists.
|
|
265
250
|
*/
|
|
266
251
|
export function listCompiledSkills() {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
252
|
+
const out = [];
|
|
253
|
+
const seen = new Set();
|
|
254
|
+
// The user's own skills come first and SHADOW a compiled skill of the same
|
|
255
|
+
// id. That is the customisation: someone whose deployment genuinely differs
|
|
256
|
+
// from the shipped procedure writes their own `devops/zero-downtime-deploys`
|
|
257
|
+
// and theirs is the one the agent reads. Shipping a library that cannot be
|
|
258
|
+
// corrected is shipping an opinion.
|
|
259
|
+
for (const skill of userSkills().skills) {
|
|
260
|
+
const key = `${skill.domain}/${skill.id}`;
|
|
261
|
+
seen.add(key);
|
|
262
|
+
out.push({
|
|
263
|
+
domain: skill.domain,
|
|
264
|
+
id: skill.id,
|
|
265
|
+
name: skill.name,
|
|
266
|
+
description: skill.description,
|
|
267
|
+
source: 'user'
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// Plugin skills live in a plugin-owned namespace (`plugin-<name>/...`) and
|
|
271
|
+
// appear only after explicit digest-pinned enablement. A user's own skill can
|
|
272
|
+
// still shadow one, which preserves local authority over every instruction.
|
|
273
|
+
for (const skill of getPluginSkills()) {
|
|
274
|
+
const key = `${skill.domain}/${skill.id}`;
|
|
275
|
+
if (seen.has(key))
|
|
276
|
+
continue;
|
|
277
|
+
seen.add(key);
|
|
278
|
+
out.push({
|
|
279
|
+
domain: skill.domain,
|
|
280
|
+
id: skill.id,
|
|
281
|
+
name: skill.name || skill.id,
|
|
282
|
+
description: skill.description || '',
|
|
283
|
+
source: 'plugin'
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
for (const [domain, skills] of Object.entries(compiledSkillsCatalog)) {
|
|
287
|
+
for (const [id, data] of Object.entries(skills)) {
|
|
288
|
+
if (seen.has(`${domain}/${id}`))
|
|
289
|
+
continue;
|
|
290
|
+
out.push({
|
|
291
|
+
domain,
|
|
292
|
+
id,
|
|
293
|
+
name: data.name || id,
|
|
294
|
+
description: data.description || '',
|
|
295
|
+
source: 'native'
|
|
296
|
+
});
|
|
297
|
+
}
|
|
304
298
|
}
|
|
305
|
-
|
|
306
|
-
return out;
|
|
299
|
+
return out;
|
|
307
300
|
}
|
|
308
|
-
|
|
309
301
|
export function readCompiledSkill(domain, skillId) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
302
|
+
// A user skill of the same id wins, for the same reason it does in the
|
|
303
|
+
// listing: the user's version is the corrected one.
|
|
304
|
+
const own = userSkills().skills
|
|
305
|
+
.find((skill) => skill.domain === domain && skill.id === skillId);
|
|
306
|
+
if (own)
|
|
307
|
+
return own.content;
|
|
308
|
+
const pluginSkill = getPluginSkills()
|
|
309
|
+
.find((skill) => skill.domain === domain && skill.id === skillId);
|
|
310
|
+
if (pluginSkill)
|
|
311
|
+
return pluginSkill.content;
|
|
312
|
+
const domainSkills = compiledSkillsCatalog[domain];
|
|
313
|
+
if (!domainSkills)
|
|
314
|
+
return `Error: Domain ${domain} not found in compiled skills.`;
|
|
315
|
+
const skillData = domainSkills[skillId];
|
|
316
|
+
if (!skillData)
|
|
317
|
+
return `Error: Skill ${skillId} not found in domain ${domain}.`;
|
|
318
|
+
return skillData.content;
|
|
327
319
|
}
|