@openweave/weave-skills 1.0.0 → 1.0.1
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/cjs/config-loader.d.ts +52 -0
- package/dist/cjs/config-loader.d.ts.map +1 -0
- package/dist/cjs/config-loader.js +132 -0
- package/dist/cjs/config-loader.js.map +1 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/skill-registry.d.ts +96 -0
- package/dist/cjs/skill-registry.d.ts.map +1 -0
- package/dist/cjs/skill-registry.js +222 -0
- package/dist/cjs/skill-registry.js.map +1 -0
- package/dist/cjs/skills/auto-fix.d.ts +35 -0
- package/dist/cjs/skills/auto-fix.d.ts.map +1 -0
- package/dist/cjs/skills/auto-fix.js +125 -0
- package/dist/cjs/skills/auto-fix.js.map +1 -0
- package/dist/cjs/skills/cli-interactive.d.ts +60 -0
- package/dist/cjs/skills/cli-interactive.d.ts.map +1 -0
- package/dist/cjs/skills/cli-interactive.js +271 -0
- package/dist/cjs/skills/cli-interactive.js.map +1 -0
- package/dist/cjs/skills/code-review.d.ts +39 -0
- package/dist/cjs/skills/code-review.d.ts.map +1 -0
- package/dist/cjs/skills/code-review.js +208 -0
- package/dist/cjs/skills/code-review.js.map +1 -0
- package/dist/cjs/skills/commit-composer.d.ts +51 -0
- package/dist/cjs/skills/commit-composer.d.ts.map +1 -0
- package/dist/cjs/skills/commit-composer.js +231 -0
- package/dist/cjs/skills/commit-composer.js.map +1 -0
- package/dist/cjs/skills/container-advisor.d.ts +43 -0
- package/dist/cjs/skills/container-advisor.d.ts.map +1 -0
- package/dist/cjs/skills/container-advisor.js +278 -0
- package/dist/cjs/skills/container-advisor.js.map +1 -0
- package/dist/cjs/skills/context-memory.d.ts +44 -0
- package/dist/cjs/skills/context-memory.d.ts.map +1 -0
- package/dist/cjs/skills/context-memory.js +167 -0
- package/dist/cjs/skills/context-memory.js.map +1 -0
- package/dist/cjs/skills/dep-audit.d.ts +55 -0
- package/dist/cjs/skills/dep-audit.d.ts.map +1 -0
- package/dist/cjs/skills/dep-audit.js +255 -0
- package/dist/cjs/skills/dep-audit.js.map +1 -0
- package/dist/cjs/skills/deploy-provision.d.ts +47 -0
- package/dist/cjs/skills/deploy-provision.d.ts.map +1 -0
- package/dist/cjs/skills/deploy-provision.js +273 -0
- package/dist/cjs/skills/deploy-provision.js.map +1 -0
- package/dist/cjs/skills/docs-gen.d.ts +36 -0
- package/dist/cjs/skills/docs-gen.d.ts.map +1 -0
- package/dist/cjs/skills/docs-gen.js +193 -0
- package/dist/cjs/skills/docs-gen.js.map +1 -0
- package/dist/cjs/skills/index.d.ts +19 -0
- package/dist/cjs/skills/index.d.ts.map +1 -0
- package/dist/cjs/skills/index.js +73 -0
- package/dist/cjs/skills/index.js.map +1 -0
- package/dist/cjs/skills/multi-repo.d.ts +50 -0
- package/dist/cjs/skills/multi-repo.d.ts.map +1 -0
- package/dist/cjs/skills/multi-repo.js +181 -0
- package/dist/cjs/skills/multi-repo.js.map +1 -0
- package/dist/cjs/skills/onboarding.d.ts +48 -0
- package/dist/cjs/skills/onboarding.d.ts.map +1 -0
- package/dist/cjs/skills/onboarding.js +253 -0
- package/dist/cjs/skills/onboarding.js.map +1 -0
- package/dist/cjs/skills/perf-profile.d.ts +36 -0
- package/dist/cjs/skills/perf-profile.d.ts.map +1 -0
- package/dist/cjs/skills/perf-profile.js +184 -0
- package/dist/cjs/skills/perf-profile.js.map +1 -0
- package/dist/cjs/skills/pipeline-aware.d.ts +33 -0
- package/dist/cjs/skills/pipeline-aware.d.ts.map +1 -0
- package/dist/cjs/skills/pipeline-aware.js +231 -0
- package/dist/cjs/skills/pipeline-aware.js.map +1 -0
- package/dist/cjs/skills/refactor.d.ts +33 -0
- package/dist/cjs/skills/refactor.d.ts.map +1 -0
- package/dist/cjs/skills/refactor.js +214 -0
- package/dist/cjs/skills/refactor.js.map +1 -0
- package/dist/cjs/skills/test-gen.d.ts +36 -0
- package/dist/cjs/skills/test-gen.d.ts.map +1 -0
- package/dist/cjs/skills/test-gen.js +159 -0
- package/dist/cjs/skills/test-gen.js.map +1 -0
- package/dist/cjs/types.d.ts +133 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +9 -0
- package/dist/cjs/types.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WeaveSkills — Config Loader
|
|
3
|
+
*
|
|
4
|
+
* Reads and writes the `skills` section of `.weave.config.json`.
|
|
5
|
+
* All I/O is synchronous to keep it usable in CLI and agent init paths.
|
|
6
|
+
*/
|
|
7
|
+
import type { SkillConfig, WeaveConfig } from './types.js';
|
|
8
|
+
/** Name of the config file, located at the project root (not inside .weave/). */
|
|
9
|
+
export declare const CONFIG_FILENAME = ".weave.config.json";
|
|
10
|
+
/** A SkillConfig with no skills registered. */
|
|
11
|
+
export declare const DEFAULT_SKILL_CONFIG: SkillConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Load the SkillConfig from `.weave.config.json` in the given project root.
|
|
14
|
+
* Returns DEFAULT_SKILL_CONFIG if the file does not exist or has no `skills` key.
|
|
15
|
+
*
|
|
16
|
+
* @param projectRoot - Absolute or relative path to the project root (default: cwd)
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadSkillConfig(projectRoot?: string): SkillConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Load the full `.weave.config.json` object (all keys, not just skills).
|
|
21
|
+
* Returns an empty object if the file does not exist.
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadWeaveConfig(projectRoot?: string): WeaveConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Persist a SkillConfig into `.weave.config.json`.
|
|
26
|
+
* Merges with any existing keys in the file so other sections are preserved.
|
|
27
|
+
*
|
|
28
|
+
* @param config - The SkillConfig to save
|
|
29
|
+
* @param projectRoot - Absolute or relative path to the project root (default: cwd)
|
|
30
|
+
*/
|
|
31
|
+
export declare function saveSkillConfig(config: SkillConfig, projectRoot?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Enable or disable a single skill in `.weave.config.json`.
|
|
34
|
+
* Creates the config file if it does not exist.
|
|
35
|
+
*
|
|
36
|
+
* @param skillId - The skill identifier (e.g. 'auto-fix')
|
|
37
|
+
* @param enabled - true to enable, false to disable
|
|
38
|
+
* @param projectRoot - Project root (default: cwd)
|
|
39
|
+
*/
|
|
40
|
+
export declare function setSkillEnabled(skillId: string, enabled: boolean, projectRoot?: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Merge a partial SkillConfig update into the existing config and persist.
|
|
43
|
+
*
|
|
44
|
+
* @param updates - Partial skills map to merge
|
|
45
|
+
* @param projectRoot - Project root (default: cwd)
|
|
46
|
+
*/
|
|
47
|
+
export declare function mergeSkillConfig(updates: Partial<SkillConfig>, projectRoot?: string): SkillConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if `.weave.config.json` exists in the given project root.
|
|
50
|
+
*/
|
|
51
|
+
export declare function configExists(projectRoot?: string): boolean;
|
|
52
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM3D,iFAAiF;AACjF,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD,+CAA+C;AAC/C,eAAO,MAAM,oBAAoB,EAAE,WAElC,CAAC;AAMF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAkBjE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAcjE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAY/E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAM7F;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,EAC7B,WAAW,CAAC,EAAE,MAAM,GACnB,WAAW,CAOb;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAG1D"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WeaveSkills — Config Loader
|
|
4
|
+
*
|
|
5
|
+
* Reads and writes the `skills` section of `.weave.config.json`.
|
|
6
|
+
* All I/O is synchronous to keep it usable in CLI and agent init paths.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_SKILL_CONFIG = exports.CONFIG_FILENAME = void 0;
|
|
10
|
+
exports.loadSkillConfig = loadSkillConfig;
|
|
11
|
+
exports.loadWeaveConfig = loadWeaveConfig;
|
|
12
|
+
exports.saveSkillConfig = saveSkillConfig;
|
|
13
|
+
exports.setSkillEnabled = setSkillEnabled;
|
|
14
|
+
exports.mergeSkillConfig = mergeSkillConfig;
|
|
15
|
+
exports.configExists = configExists;
|
|
16
|
+
const node_fs_1 = require("node:fs");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Constants
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/** Name of the config file, located at the project root (not inside .weave/). */
|
|
22
|
+
exports.CONFIG_FILENAME = '.weave.config.json';
|
|
23
|
+
/** A SkillConfig with no skills registered. */
|
|
24
|
+
exports.DEFAULT_SKILL_CONFIG = {
|
|
25
|
+
skills: {},
|
|
26
|
+
};
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Public API
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/**
|
|
31
|
+
* Load the SkillConfig from `.weave.config.json` in the given project root.
|
|
32
|
+
* Returns DEFAULT_SKILL_CONFIG if the file does not exist or has no `skills` key.
|
|
33
|
+
*
|
|
34
|
+
* @param projectRoot - Absolute or relative path to the project root (default: cwd)
|
|
35
|
+
*/
|
|
36
|
+
function loadSkillConfig(projectRoot) {
|
|
37
|
+
const root = (0, node_path_1.resolve)(projectRoot ?? process.cwd());
|
|
38
|
+
const configPath = _configPath(root);
|
|
39
|
+
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
40
|
+
return { skills: {} };
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const raw = (0, node_fs_1.readFileSync)(configPath, 'utf-8');
|
|
44
|
+
const parsed = JSON.parse(raw);
|
|
45
|
+
return {
|
|
46
|
+
skills: parsed.skills ?? {},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Invalid JSON — return empty config rather than crashing
|
|
51
|
+
return { skills: {} };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Load the full `.weave.config.json` object (all keys, not just skills).
|
|
56
|
+
* Returns an empty object if the file does not exist.
|
|
57
|
+
*/
|
|
58
|
+
function loadWeaveConfig(projectRoot) {
|
|
59
|
+
const root = (0, node_path_1.resolve)(projectRoot ?? process.cwd());
|
|
60
|
+
const configPath = _configPath(root);
|
|
61
|
+
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const raw = (0, node_fs_1.readFileSync)(configPath, 'utf-8');
|
|
66
|
+
return JSON.parse(raw);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Persist a SkillConfig into `.weave.config.json`.
|
|
74
|
+
* Merges with any existing keys in the file so other sections are preserved.
|
|
75
|
+
*
|
|
76
|
+
* @param config - The SkillConfig to save
|
|
77
|
+
* @param projectRoot - Absolute or relative path to the project root (default: cwd)
|
|
78
|
+
*/
|
|
79
|
+
function saveSkillConfig(config, projectRoot) {
|
|
80
|
+
const root = (0, node_path_1.resolve)(projectRoot ?? process.cwd());
|
|
81
|
+
const configPath = _configPath(root);
|
|
82
|
+
// Read existing config to preserve non-skills keys
|
|
83
|
+
const existing = loadWeaveConfig(root);
|
|
84
|
+
const merged = {
|
|
85
|
+
...existing,
|
|
86
|
+
skills: config.skills,
|
|
87
|
+
};
|
|
88
|
+
(0, node_fs_1.writeFileSync)(configPath, JSON.stringify(merged, null, 2) + '\n', 'utf-8');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Enable or disable a single skill in `.weave.config.json`.
|
|
92
|
+
* Creates the config file if it does not exist.
|
|
93
|
+
*
|
|
94
|
+
* @param skillId - The skill identifier (e.g. 'auto-fix')
|
|
95
|
+
* @param enabled - true to enable, false to disable
|
|
96
|
+
* @param projectRoot - Project root (default: cwd)
|
|
97
|
+
*/
|
|
98
|
+
function setSkillEnabled(skillId, enabled, projectRoot) {
|
|
99
|
+
const existing = loadSkillConfig(projectRoot);
|
|
100
|
+
const updated = {
|
|
101
|
+
skills: { ...existing.skills, [skillId]: enabled },
|
|
102
|
+
};
|
|
103
|
+
saveSkillConfig(updated, projectRoot);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Merge a partial SkillConfig update into the existing config and persist.
|
|
107
|
+
*
|
|
108
|
+
* @param updates - Partial skills map to merge
|
|
109
|
+
* @param projectRoot - Project root (default: cwd)
|
|
110
|
+
*/
|
|
111
|
+
function mergeSkillConfig(updates, projectRoot) {
|
|
112
|
+
const existing = loadSkillConfig(projectRoot);
|
|
113
|
+
const merged = {
|
|
114
|
+
skills: { ...existing.skills, ...(updates.skills ?? {}) },
|
|
115
|
+
};
|
|
116
|
+
saveSkillConfig(merged, projectRoot);
|
|
117
|
+
return merged;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns true if `.weave.config.json` exists in the given project root.
|
|
121
|
+
*/
|
|
122
|
+
function configExists(projectRoot) {
|
|
123
|
+
const root = (0, node_path_1.resolve)(projectRoot ?? process.cwd());
|
|
124
|
+
return (0, node_fs_1.existsSync)(_configPath(root));
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// Internal helpers
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
function _configPath(root) {
|
|
130
|
+
return (0, node_path_1.join)(root, exports.CONFIG_FILENAME);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=config-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/config-loader.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA4BH,0CAkBC;AAMD,0CAcC;AASD,0CAYC;AAUD,0CAMC;AAQD,4CAUC;AAKD,oCAGC;AA/HD,qCAAkE;AAClE,yCAA0C;AAG1C,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,iFAAiF;AACpE,QAAA,eAAe,GAAG,oBAAoB,CAAC;AAEpD,+CAA+C;AAClC,QAAA,oBAAoB,GAAgB;IAC/C,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,WAAoB;IAClD,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,MAAM,UAAU,GA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AE9E,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAA,gBAAI,EAAC,IAAI,EAAE,uBAAe,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @openweave/weave-skills
|
|
3
|
+
*
|
|
4
|
+
* Skill Module Registry — M19
|
|
5
|
+
* Provides the infrastructure for registering, activating and composing
|
|
6
|
+
* optional skill modules in the OpenWeave agent.
|
|
7
|
+
*/
|
|
8
|
+
export type { SkillModule, SkillContext, SkillGitContext, SkillResult, SkillConfig, WeaveConfig, RegisteredSkill, } from './types.js';
|
|
9
|
+
export { SkillRegistry } from './skill-registry.js';
|
|
10
|
+
export { CONFIG_FILENAME, DEFAULT_SKILL_CONFIG, loadSkillConfig, loadWeaveConfig, saveSkillConfig, setSkillEnabled, mergeSkillConfig, configExists, } from './config-loader.js';
|
|
11
|
+
export { autoFixSkill, codeReviewSkill, testGenSkill, docsGenSkill, refactorSkill, CORE_DEV_SKILLS, pipelineAwareSkill, depAuditSkill, perfProfileSkill, containerAdvisorSkill, deployProvisionSkill, DEVOPS_SKILLS, onboardingSkill, commitComposerSkill, contextMemorySkill, multiRepoSkill, cliInteractiveSkill, DEV_EXPERIENCE_SKILLS, } from './skills/index.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @openweave/weave-skills
|
|
4
|
+
*
|
|
5
|
+
* Skill Module Registry — M19
|
|
6
|
+
* Provides the infrastructure for registering, activating and composing
|
|
7
|
+
* optional skill modules in the OpenWeave agent.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DEV_EXPERIENCE_SKILLS = exports.cliInteractiveSkill = exports.multiRepoSkill = exports.contextMemorySkill = exports.commitComposerSkill = exports.onboardingSkill = exports.DEVOPS_SKILLS = exports.deployProvisionSkill = exports.containerAdvisorSkill = exports.perfProfileSkill = exports.depAuditSkill = exports.pipelineAwareSkill = exports.CORE_DEV_SKILLS = exports.refactorSkill = exports.docsGenSkill = exports.testGenSkill = exports.codeReviewSkill = exports.autoFixSkill = exports.configExists = exports.mergeSkillConfig = exports.setSkillEnabled = exports.saveSkillConfig = exports.loadWeaveConfig = exports.loadSkillConfig = exports.DEFAULT_SKILL_CONFIG = exports.CONFIG_FILENAME = exports.SkillRegistry = void 0;
|
|
11
|
+
// Registry
|
|
12
|
+
var skill_registry_js_1 = require("./skill-registry.js");
|
|
13
|
+
Object.defineProperty(exports, "SkillRegistry", { enumerable: true, get: function () { return skill_registry_js_1.SkillRegistry; } });
|
|
14
|
+
// Config helpers
|
|
15
|
+
var config_loader_js_1 = require("./config-loader.js");
|
|
16
|
+
Object.defineProperty(exports, "CONFIG_FILENAME", { enumerable: true, get: function () { return config_loader_js_1.CONFIG_FILENAME; } });
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_SKILL_CONFIG", { enumerable: true, get: function () { return config_loader_js_1.DEFAULT_SKILL_CONFIG; } });
|
|
18
|
+
Object.defineProperty(exports, "loadSkillConfig", { enumerable: true, get: function () { return config_loader_js_1.loadSkillConfig; } });
|
|
19
|
+
Object.defineProperty(exports, "loadWeaveConfig", { enumerable: true, get: function () { return config_loader_js_1.loadWeaveConfig; } });
|
|
20
|
+
Object.defineProperty(exports, "saveSkillConfig", { enumerable: true, get: function () { return config_loader_js_1.saveSkillConfig; } });
|
|
21
|
+
Object.defineProperty(exports, "setSkillEnabled", { enumerable: true, get: function () { return config_loader_js_1.setSkillEnabled; } });
|
|
22
|
+
Object.defineProperty(exports, "mergeSkillConfig", { enumerable: true, get: function () { return config_loader_js_1.mergeSkillConfig; } });
|
|
23
|
+
Object.defineProperty(exports, "configExists", { enumerable: true, get: function () { return config_loader_js_1.configExists; } });
|
|
24
|
+
// Core Dev Skills (M20) + DevOps Skills (M21) + Developer Experience Skills (M22)
|
|
25
|
+
var index_js_1 = require("./skills/index.js");
|
|
26
|
+
Object.defineProperty(exports, "autoFixSkill", { enumerable: true, get: function () { return index_js_1.autoFixSkill; } });
|
|
27
|
+
Object.defineProperty(exports, "codeReviewSkill", { enumerable: true, get: function () { return index_js_1.codeReviewSkill; } });
|
|
28
|
+
Object.defineProperty(exports, "testGenSkill", { enumerable: true, get: function () { return index_js_1.testGenSkill; } });
|
|
29
|
+
Object.defineProperty(exports, "docsGenSkill", { enumerable: true, get: function () { return index_js_1.docsGenSkill; } });
|
|
30
|
+
Object.defineProperty(exports, "refactorSkill", { enumerable: true, get: function () { return index_js_1.refactorSkill; } });
|
|
31
|
+
Object.defineProperty(exports, "CORE_DEV_SKILLS", { enumerable: true, get: function () { return index_js_1.CORE_DEV_SKILLS; } });
|
|
32
|
+
Object.defineProperty(exports, "pipelineAwareSkill", { enumerable: true, get: function () { return index_js_1.pipelineAwareSkill; } });
|
|
33
|
+
Object.defineProperty(exports, "depAuditSkill", { enumerable: true, get: function () { return index_js_1.depAuditSkill; } });
|
|
34
|
+
Object.defineProperty(exports, "perfProfileSkill", { enumerable: true, get: function () { return index_js_1.perfProfileSkill; } });
|
|
35
|
+
Object.defineProperty(exports, "containerAdvisorSkill", { enumerable: true, get: function () { return index_js_1.containerAdvisorSkill; } });
|
|
36
|
+
Object.defineProperty(exports, "deployProvisionSkill", { enumerable: true, get: function () { return index_js_1.deployProvisionSkill; } });
|
|
37
|
+
Object.defineProperty(exports, "DEVOPS_SKILLS", { enumerable: true, get: function () { return index_js_1.DEVOPS_SKILLS; } });
|
|
38
|
+
Object.defineProperty(exports, "onboardingSkill", { enumerable: true, get: function () { return index_js_1.onboardingSkill; } });
|
|
39
|
+
Object.defineProperty(exports, "commitComposerSkill", { enumerable: true, get: function () { return index_js_1.commitComposerSkill; } });
|
|
40
|
+
Object.defineProperty(exports, "contextMemorySkill", { enumerable: true, get: function () { return index_js_1.contextMemorySkill; } });
|
|
41
|
+
Object.defineProperty(exports, "multiRepoSkill", { enumerable: true, get: function () { return index_js_1.multiRepoSkill; } });
|
|
42
|
+
Object.defineProperty(exports, "cliInteractiveSkill", { enumerable: true, get: function () { return index_js_1.cliInteractiveSkill; } });
|
|
43
|
+
Object.defineProperty(exports, "DEV_EXPERIENCE_SKILLS", { enumerable: true, get: function () { return index_js_1.DEV_EXPERIENCE_SKILLS; } });
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAaH,WAAW;AACX,yDAAoD;AAA3C,kHAAA,aAAa,OAAA;AAEtB,iBAAiB;AACjB,uDAS4B;AAR1B,mHAAA,eAAe,OAAA;AACf,wHAAA,oBAAoB,OAAA;AACpB,mHAAA,eAAe,OAAA;AACf,mHAAA,eAAe,OAAA;AACf,mHAAA,eAAe,OAAA;AACf,mHAAA,eAAe,OAAA;AACf,oHAAA,gBAAgB,OAAA;AAChB,gHAAA,YAAY,OAAA;AAGd,kFAAkF;AAClF,8CAmB2B;AAlBzB,wGAAA,YAAY,OAAA;AACZ,2GAAA,eAAe,OAAA;AACf,wGAAA,YAAY,OAAA;AACZ,wGAAA,YAAY,OAAA;AACZ,yGAAA,aAAa,OAAA;AACb,2GAAA,eAAe,OAAA;AACf,8GAAA,kBAAkB,OAAA;AAClB,yGAAA,aAAa,OAAA;AACb,4GAAA,gBAAgB,OAAA;AAChB,iHAAA,qBAAqB,OAAA;AACrB,gHAAA,oBAAoB,OAAA;AACpB,yGAAA,aAAa,OAAA;AACb,2GAAA,eAAe,OAAA;AACf,+GAAA,mBAAmB,OAAA;AACnB,8GAAA,kBAAkB,OAAA;AAClB,0GAAA,cAAc,OAAA;AACd,+GAAA,mBAAmB,OAAA;AACnB,iHAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WeaveSkills — SkillRegistry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all skill modules.
|
|
5
|
+
* Manages lifecycle: register → enable/disable → execute.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const registry = new SkillRegistry();
|
|
10
|
+
* registry.register(mySkill);
|
|
11
|
+
* registry.enable('my-skill');
|
|
12
|
+
* await registry.execute('my-skill', context);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { SkillModule, SkillContext, SkillResult, SkillConfig, RegisteredSkill } from './types.js';
|
|
16
|
+
export declare class SkillRegistry {
|
|
17
|
+
private readonly _skills;
|
|
18
|
+
/**
|
|
19
|
+
* Register a skill module.
|
|
20
|
+
* If a SkillConfig has been loaded, the config's enabled flag takes priority
|
|
21
|
+
* over the module's `enabled` default.
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} if a skill with the same id is already registered
|
|
24
|
+
*/
|
|
25
|
+
register(module: SkillModule): void;
|
|
26
|
+
/**
|
|
27
|
+
* Register a skill module, replacing any existing entry with the same id.
|
|
28
|
+
* Useful for testing and hot-reloading scenarios.
|
|
29
|
+
*/
|
|
30
|
+
replace(module: SkillModule): void;
|
|
31
|
+
/**
|
|
32
|
+
* Unregister a skill by id.
|
|
33
|
+
* @returns true if the skill existed and was removed, false otherwise
|
|
34
|
+
*/
|
|
35
|
+
unregister(id: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Enable a registered skill.
|
|
38
|
+
* @throws {Error} if the skill is not registered
|
|
39
|
+
*/
|
|
40
|
+
enable(id: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Disable a registered skill.
|
|
43
|
+
* @throws {Error} if the skill is not registered
|
|
44
|
+
*/
|
|
45
|
+
disable(id: string): void;
|
|
46
|
+
/** Returns the full registered skill entry, or undefined if not found. */
|
|
47
|
+
get(id: string): RegisteredSkill | undefined;
|
|
48
|
+
/** Returns true if a skill with the given id is registered. */
|
|
49
|
+
has(id: string): boolean;
|
|
50
|
+
/** Returns all registered skills (enabled and disabled). */
|
|
51
|
+
list(): RegisteredSkill[];
|
|
52
|
+
/** Returns only enabled skills. */
|
|
53
|
+
listEnabled(): SkillModule[];
|
|
54
|
+
/** Total number of registered skills. */
|
|
55
|
+
get size(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Execute a skill by id.
|
|
58
|
+
*
|
|
59
|
+
* @param id - Skill identifier
|
|
60
|
+
* @param context - Runtime context injected into the skill
|
|
61
|
+
* @returns SkillResult — never throws; errors are captured into result.error
|
|
62
|
+
* @throws {Error} if the skill is not registered or is disabled
|
|
63
|
+
*/
|
|
64
|
+
execute(id: string, context: SkillContext): Promise<SkillResult>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute a skill by id, returning a failed SkillResult instead of throwing
|
|
67
|
+
* if the skill is not registered or is disabled.
|
|
68
|
+
* Useful for fire-and-forget scenarios where you don't want to handle missing skills.
|
|
69
|
+
*/
|
|
70
|
+
executeSafe(id: string, context: SkillContext): Promise<SkillResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Execute all currently enabled skills in registration order.
|
|
73
|
+
* Skills that throw are caught and returned as failed results — they never
|
|
74
|
+
* block execution of subsequent skills.
|
|
75
|
+
*
|
|
76
|
+
* @param context - Runtime context shared across all skills
|
|
77
|
+
* @returns Map of skill id → SkillResult
|
|
78
|
+
*/
|
|
79
|
+
executeAll(context: SkillContext): Promise<Map<string, SkillResult>>;
|
|
80
|
+
/**
|
|
81
|
+
* Apply a SkillConfig to the registry.
|
|
82
|
+
*
|
|
83
|
+
* - Skills present in config.skills are enabled/disabled accordingly.
|
|
84
|
+
* - Skills not mentioned in config are left at their current state.
|
|
85
|
+
* - Skills in config that are not yet registered are silently ignored
|
|
86
|
+
* (they will be applied when registered later via register()).
|
|
87
|
+
*/
|
|
88
|
+
loadFromConfig(config: SkillConfig): void;
|
|
89
|
+
/**
|
|
90
|
+
* Produce a SkillConfig snapshot from the current registry state.
|
|
91
|
+
* Useful for serialising the registry to `.weave.config.json`.
|
|
92
|
+
*/
|
|
93
|
+
toConfig(): SkillConfig;
|
|
94
|
+
private _getOrThrow;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=skill-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-registry.d.ts","sourceRoot":"","sources":["../../src/skill-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IAMnE;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAWnC;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IASlC;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAQ/B;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKxB;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IASzB,0EAA0E;IAC1E,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI5C,+DAA+D;IAC/D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB,4DAA4D;IAC5D,IAAI,IAAI,eAAe,EAAE;IAIzB,mCAAmC;IACnC,WAAW,IAAI,WAAW,EAAE;IAM5B,yCAAyC;IACzC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAMD;;;;;;;OAOG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAkBtE;;;;OAIG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAsB1E;;;;;;;OAOG;IACG,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAwB1E;;;;;;;OAOG;IACH,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IASzC;;;OAGG;IACH,QAAQ,IAAI,WAAW;IAYvB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WeaveSkills — SkillRegistry
|
|
4
|
+
*
|
|
5
|
+
* Central registry for all skill modules.
|
|
6
|
+
* Manages lifecycle: register → enable/disable → execute.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const registry = new SkillRegistry();
|
|
11
|
+
* registry.register(mySkill);
|
|
12
|
+
* registry.enable('my-skill');
|
|
13
|
+
* await registry.execute('my-skill', context);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.SkillRegistry = void 0;
|
|
18
|
+
class SkillRegistry {
|
|
19
|
+
_skills = new Map();
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Registration
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Register a skill module.
|
|
25
|
+
* If a SkillConfig has been loaded, the config's enabled flag takes priority
|
|
26
|
+
* over the module's `enabled` default.
|
|
27
|
+
*
|
|
28
|
+
* @throws {Error} if a skill with the same id is already registered
|
|
29
|
+
*/
|
|
30
|
+
register(module) {
|
|
31
|
+
if (this._skills.has(module.id)) {
|
|
32
|
+
throw new Error(`Skill '${module.id}' is already registered. Use replace() to overwrite.`);
|
|
33
|
+
}
|
|
34
|
+
this._skills.set(module.id, {
|
|
35
|
+
module,
|
|
36
|
+
enabled: module.enabled,
|
|
37
|
+
registeredAt: new Date(),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Register a skill module, replacing any existing entry with the same id.
|
|
42
|
+
* Useful for testing and hot-reloading scenarios.
|
|
43
|
+
*/
|
|
44
|
+
replace(module) {
|
|
45
|
+
const existing = this._skills.get(module.id);
|
|
46
|
+
this._skills.set(module.id, {
|
|
47
|
+
module,
|
|
48
|
+
enabled: existing ? existing.enabled : module.enabled,
|
|
49
|
+
registeredAt: existing ? existing.registeredAt : new Date(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Unregister a skill by id.
|
|
54
|
+
* @returns true if the skill existed and was removed, false otherwise
|
|
55
|
+
*/
|
|
56
|
+
unregister(id) {
|
|
57
|
+
return this._skills.delete(id);
|
|
58
|
+
}
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Enable / Disable
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
/**
|
|
63
|
+
* Enable a registered skill.
|
|
64
|
+
* @throws {Error} if the skill is not registered
|
|
65
|
+
*/
|
|
66
|
+
enable(id) {
|
|
67
|
+
const entry = this._getOrThrow(id);
|
|
68
|
+
entry.enabled = true;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Disable a registered skill.
|
|
72
|
+
* @throws {Error} if the skill is not registered
|
|
73
|
+
*/
|
|
74
|
+
disable(id) {
|
|
75
|
+
const entry = this._getOrThrow(id);
|
|
76
|
+
entry.enabled = false;
|
|
77
|
+
}
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Query
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
/** Returns the full registered skill entry, or undefined if not found. */
|
|
82
|
+
get(id) {
|
|
83
|
+
return this._skills.get(id);
|
|
84
|
+
}
|
|
85
|
+
/** Returns true if a skill with the given id is registered. */
|
|
86
|
+
has(id) {
|
|
87
|
+
return this._skills.has(id);
|
|
88
|
+
}
|
|
89
|
+
/** Returns all registered skills (enabled and disabled). */
|
|
90
|
+
list() {
|
|
91
|
+
return Array.from(this._skills.values());
|
|
92
|
+
}
|
|
93
|
+
/** Returns only enabled skills. */
|
|
94
|
+
listEnabled() {
|
|
95
|
+
return Array.from(this._skills.values())
|
|
96
|
+
.filter((s) => s.enabled)
|
|
97
|
+
.map((s) => s.module);
|
|
98
|
+
}
|
|
99
|
+
/** Total number of registered skills. */
|
|
100
|
+
get size() {
|
|
101
|
+
return this._skills.size;
|
|
102
|
+
}
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Execution
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Execute a skill by id.
|
|
108
|
+
*
|
|
109
|
+
* @param id - Skill identifier
|
|
110
|
+
* @param context - Runtime context injected into the skill
|
|
111
|
+
* @returns SkillResult — never throws; errors are captured into result.error
|
|
112
|
+
* @throws {Error} if the skill is not registered or is disabled
|
|
113
|
+
*/
|
|
114
|
+
async execute(id, context) {
|
|
115
|
+
const entry = this._getOrThrow(id);
|
|
116
|
+
if (!entry.enabled) {
|
|
117
|
+
throw new Error(`Skill '${id}' is disabled. Enable it first with registry.enable('${id}').`);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return await entry.module.execute(context);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
output: `Skill '${id}' threw an unexpected error`,
|
|
126
|
+
error: err instanceof Error ? err.message : String(err),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Execute a skill by id, returning a failed SkillResult instead of throwing
|
|
132
|
+
* if the skill is not registered or is disabled.
|
|
133
|
+
* Useful for fire-and-forget scenarios where you don't want to handle missing skills.
|
|
134
|
+
*/
|
|
135
|
+
async executeSafe(id, context) {
|
|
136
|
+
const entry = this._skills.get(id);
|
|
137
|
+
if (!entry) {
|
|
138
|
+
return { success: false, output: '', error: `Skill '${id}' is not registered.` };
|
|
139
|
+
}
|
|
140
|
+
if (!entry.enabled) {
|
|
141
|
+
return { success: false, output: '', error: `Skill '${id}' is disabled.` };
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
return await entry.module.execute(context);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
return {
|
|
148
|
+
success: false,
|
|
149
|
+
output: `Skill '${id}' threw an unexpected error`,
|
|
150
|
+
error: err instanceof Error ? err.message : String(err),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Execute all currently enabled skills in registration order.
|
|
156
|
+
* Skills that throw are caught and returned as failed results — they never
|
|
157
|
+
* block execution of subsequent skills.
|
|
158
|
+
*
|
|
159
|
+
* @param context - Runtime context shared across all skills
|
|
160
|
+
* @returns Map of skill id → SkillResult
|
|
161
|
+
*/
|
|
162
|
+
async executeAll(context) {
|
|
163
|
+
const results = new Map();
|
|
164
|
+
for (const entry of this._skills.values()) {
|
|
165
|
+
if (!entry.enabled)
|
|
166
|
+
continue;
|
|
167
|
+
try {
|
|
168
|
+
results.set(entry.module.id, await entry.module.execute(context));
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
results.set(entry.module.id, {
|
|
172
|
+
success: false,
|
|
173
|
+
output: `Skill '${entry.module.id}' threw an unexpected error`,
|
|
174
|
+
error: err instanceof Error ? err.message : String(err),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return results;
|
|
179
|
+
}
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
// Config integration
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
/**
|
|
184
|
+
* Apply a SkillConfig to the registry.
|
|
185
|
+
*
|
|
186
|
+
* - Skills present in config.skills are enabled/disabled accordingly.
|
|
187
|
+
* - Skills not mentioned in config are left at their current state.
|
|
188
|
+
* - Skills in config that are not yet registered are silently ignored
|
|
189
|
+
* (they will be applied when registered later via register()).
|
|
190
|
+
*/
|
|
191
|
+
loadFromConfig(config) {
|
|
192
|
+
for (const [id, enabled] of Object.entries(config.skills)) {
|
|
193
|
+
const entry = this._skills.get(id);
|
|
194
|
+
if (entry) {
|
|
195
|
+
entry.enabled = enabled;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Produce a SkillConfig snapshot from the current registry state.
|
|
201
|
+
* Useful for serialising the registry to `.weave.config.json`.
|
|
202
|
+
*/
|
|
203
|
+
toConfig() {
|
|
204
|
+
const skills = {};
|
|
205
|
+
for (const [id, entry] of this._skills.entries()) {
|
|
206
|
+
skills[id] = entry.enabled;
|
|
207
|
+
}
|
|
208
|
+
return { skills };
|
|
209
|
+
}
|
|
210
|
+
// ---------------------------------------------------------------------------
|
|
211
|
+
// Private helpers
|
|
212
|
+
// ---------------------------------------------------------------------------
|
|
213
|
+
_getOrThrow(id) {
|
|
214
|
+
const entry = this._skills.get(id);
|
|
215
|
+
if (!entry) {
|
|
216
|
+
throw new Error(`Skill '${id}' is not registered.`);
|
|
217
|
+
}
|
|
218
|
+
return entry;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.SkillRegistry = SkillRegistry;
|
|
222
|
+
//# sourceMappingURL=skill-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-registry.js","sourceRoot":"","sources":["../../src/skill-registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAUH,MAAa,aAAa;IACP,OAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;IAEnE,8EAA8E;IAC9E,eAAe;IACf,8EAA8E;IAE9E;;;;;;OAMG;IACH,QAAQ,CAAC,MAAmB;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,CAAC,EAAE,sDAAsD,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE;YAC1B,MAAM;YACN,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,YAAY,EAAE,IAAI,IAAI,EAAE;SACzB,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,MAAmB;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE;YAC1B,MAAM;YACN,OAAO,EAAE,QAAQ,CAAC,C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AED,8EAA8E;IAC9E,qBAAqB;IACrB,8EAA8E;IAE9E;;;;;;;OAOG;IACH,cAAc,CAAC,MAAmB;QAChC,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACnC,IAAI,KAAK,EAAE,CAAC;gBACV,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YACjD,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,8EAA8E;IAC9E,kBAAkB;IAClB,8EAA8E;IAEtE,WAAW,CAAC,EAAU;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AApOD,sCAoOC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill: auto-fix
|
|
3
|
+
*
|
|
4
|
+
* Reads VULN-*.md remediation files and reports what patches need to be applied.
|
|
5
|
+
* In apply mode, writes the patches and creates one git commit per VULN.
|
|
6
|
+
*
|
|
7
|
+
* Input (via SkillContext.graph or options in data):
|
|
8
|
+
* - `sentinelDir` — directory containing VULN-*.md files (default: .sentinel_logs)
|
|
9
|
+
* - `apply` — if true, attempt to apply patches via execSync (default: false / dry-run)
|
|
10
|
+
*
|
|
11
|
+
* Output data:
|
|
12
|
+
* - vulns: VulnReport[] — one entry per VULN file found
|
|
13
|
+
* - applied: number — commits created (only in apply mode)
|
|
14
|
+
*/
|
|
15
|
+
import type { SkillModule } from '../types.js';
|
|
16
|
+
export interface VulnReport {
|
|
17
|
+
id: string;
|
|
18
|
+
file: string;
|
|
19
|
+
title: string;
|
|
20
|
+
severity: string;
|
|
21
|
+
affectedFiles: string[];
|
|
22
|
+
remediation: string;
|
|
23
|
+
status: 'pending' | 'applied' | 'error';
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AutoFixResult {
|
|
27
|
+
vulns: VulnReport[];
|
|
28
|
+
applied: number;
|
|
29
|
+
skipped: number;
|
|
30
|
+
errors: number;
|
|
31
|
+
dryRun: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function parseVulnFile(content: string, filePath: string): VulnReport;
|
|
34
|
+
export declare const autoFixSkill: SkillModule;
|
|
35
|
+
//# sourceMappingURL=auto-fix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-fix.d.ts","sourceRoot":"","sources":["../../../src/skills/auto-fix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,WAAW,EAA6B,MAAM,aAAa,CAAC;AAM1E,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAYD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAiB3E;AAcD,eAAO,MAAM,YAAY,EAAE,WAgF1B,CAAC"}
|