@openweave/weave-skills 1.0.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/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/config-loader.d.ts +52 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +123 -0
- package/dist/config-loader.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/skill-registry.d.ts +96 -0
- package/dist/skill-registry.d.ts.map +1 -0
- package/dist/skill-registry.js +218 -0
- package/dist/skill-registry.js.map +1 -0
- package/dist/skills/auto-fix.d.ts +35 -0
- package/dist/skills/auto-fix.d.ts.map +1 -0
- package/dist/skills/auto-fix.js +121 -0
- package/dist/skills/auto-fix.js.map +1 -0
- package/dist/skills/cli-interactive.d.ts +60 -0
- package/dist/skills/cli-interactive.d.ts.map +1 -0
- package/dist/skills/cli-interactive.js +264 -0
- package/dist/skills/cli-interactive.js.map +1 -0
- package/dist/skills/code-review.d.ts +39 -0
- package/dist/skills/code-review.d.ts.map +1 -0
- package/dist/skills/code-review.js +204 -0
- package/dist/skills/code-review.js.map +1 -0
- package/dist/skills/commit-composer.d.ts +51 -0
- package/dist/skills/commit-composer.d.ts.map +1 -0
- package/dist/skills/commit-composer.js +223 -0
- package/dist/skills/commit-composer.js.map +1 -0
- package/dist/skills/container-advisor.d.ts +43 -0
- package/dist/skills/container-advisor.d.ts.map +1 -0
- package/dist/skills/container-advisor.js +274 -0
- package/dist/skills/container-advisor.js.map +1 -0
- package/dist/skills/context-memory.d.ts +44 -0
- package/dist/skills/context-memory.d.ts.map +1 -0
- package/dist/skills/context-memory.js +160 -0
- package/dist/skills/context-memory.js.map +1 -0
- package/dist/skills/dep-audit.d.ts +55 -0
- package/dist/skills/dep-audit.d.ts.map +1 -0
- package/dist/skills/dep-audit.js +248 -0
- package/dist/skills/dep-audit.js.map +1 -0
- package/dist/skills/deploy-provision.d.ts +47 -0
- package/dist/skills/deploy-provision.d.ts.map +1 -0
- package/dist/skills/deploy-provision.js +270 -0
- package/dist/skills/deploy-provision.js.map +1 -0
- package/dist/skills/docs-gen.d.ts +36 -0
- package/dist/skills/docs-gen.d.ts.map +1 -0
- package/dist/skills/docs-gen.js +187 -0
- package/dist/skills/docs-gen.js.map +1 -0
- package/dist/skills/index.d.ts +19 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +55 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/multi-repo.d.ts +50 -0
- package/dist/skills/multi-repo.d.ts.map +1 -0
- package/dist/skills/multi-repo.js +175 -0
- package/dist/skills/multi-repo.js.map +1 -0
- package/dist/skills/onboarding.d.ts +48 -0
- package/dist/skills/onboarding.d.ts.map +1 -0
- package/dist/skills/onboarding.js +245 -0
- package/dist/skills/onboarding.js.map +1 -0
- package/dist/skills/perf-profile.d.ts +36 -0
- package/dist/skills/perf-profile.d.ts.map +1 -0
- package/dist/skills/perf-profile.js +179 -0
- package/dist/skills/perf-profile.js.map +1 -0
- package/dist/skills/pipeline-aware.d.ts +33 -0
- package/dist/skills/pipeline-aware.d.ts.map +1 -0
- package/dist/skills/pipeline-aware.js +226 -0
- package/dist/skills/pipeline-aware.js.map +1 -0
- package/dist/skills/refactor.d.ts +33 -0
- package/dist/skills/refactor.d.ts.map +1 -0
- package/dist/skills/refactor.js +210 -0
- package/dist/skills/refactor.js.map +1 -0
- package/dist/skills/test-gen.d.ts +36 -0
- package/dist/skills/test-gen.d.ts.map +1 -0
- package/dist/skills/test-gen.js +154 -0
- package/dist/skills/test-gen.js.map +1 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lemur bookstores
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# @openweave/weave-skills
|
|
2
|
+
|
|
3
|
+
> **WeaveSkills** — Skill Module Registry (M19)
|
|
4
|
+
> Pluggable skill architecture for the OpenWeave agent.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
WeaveSkills provides the **infrastructure** for registering, enabling and executing
|
|
11
|
+
optional skill modules in the OpenWeave agent.
|
|
12
|
+
|
|
13
|
+
Each skill is an independent module that implements the `SkillModule` interface.
|
|
14
|
+
The `SkillRegistry` manages lifecycle; `.weave.config.json` persists the enabled state.
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
.weave.config.json ← per-project skill config
|
|
18
|
+
│
|
|
19
|
+
▼
|
|
20
|
+
SkillRegistry ← runtime registry (in-memory)
|
|
21
|
+
├── register(module)
|
|
22
|
+
├── enable(id) / disable(id)
|
|
23
|
+
├── execute(id, context)
|
|
24
|
+
└── executeAll(context)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Define a skill
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import type { SkillModule, SkillContext, SkillResult } from '@openweave/weave-skills';
|
|
35
|
+
|
|
36
|
+
export const mySkill: SkillModule = {
|
|
37
|
+
id: 'my-skill',
|
|
38
|
+
name: 'My Skill',
|
|
39
|
+
description: 'Does something useful at agent runtime',
|
|
40
|
+
version: '1.0.0',
|
|
41
|
+
enabled: true,
|
|
42
|
+
tags: ['dev'],
|
|
43
|
+
async execute(ctx: SkillContext): Promise<SkillResult> {
|
|
44
|
+
// ctx.files, ctx.graph, ctx.session, ctx.git are available
|
|
45
|
+
return { success: true, output: 'All done.' };
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Register and execute
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { SkillRegistry, loadSkillConfig } from '@openweave/weave-skills';
|
|
54
|
+
import { mySkill } from './my-skill.js';
|
|
55
|
+
|
|
56
|
+
const registry = new SkillRegistry();
|
|
57
|
+
registry.register(mySkill);
|
|
58
|
+
|
|
59
|
+
// Apply persisted config (enables/disables from .weave.config.json)
|
|
60
|
+
const config = loadSkillConfig();
|
|
61
|
+
registry.loadFromConfig(config);
|
|
62
|
+
|
|
63
|
+
// Execute a single skill
|
|
64
|
+
const result = await registry.execute('my-skill', {
|
|
65
|
+
projectRoot: process.cwd(),
|
|
66
|
+
files: [],
|
|
67
|
+
graph: null,
|
|
68
|
+
session: null,
|
|
69
|
+
git: null,
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## CLI
|
|
76
|
+
|
|
77
|
+
Manage skills from the terminal via `weave skills`:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
weave skills list # List all configured skills
|
|
81
|
+
weave skills enable auto-fix # Enable a skill
|
|
82
|
+
weave skills disable code-review # Disable a skill
|
|
83
|
+
weave skills info test-gen # Show config entry for a skill
|
|
84
|
+
weave skills list --json # Machine-readable output
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Config is saved to `.weave.config.json` in the project root:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"skills": {
|
|
92
|
+
"auto-fix": true,
|
|
93
|
+
"code-review": false,
|
|
94
|
+
"test-gen": true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## API Reference
|
|
102
|
+
|
|
103
|
+
### `SkillRegistry`
|
|
104
|
+
|
|
105
|
+
| Method | Description |
|
|
106
|
+
|--------|-------------|
|
|
107
|
+
| `register(module)` | Register a skill (throws on duplicate id) |
|
|
108
|
+
| `replace(module)` | Register or overwrite a skill |
|
|
109
|
+
| `unregister(id)` | Remove a skill |
|
|
110
|
+
| `enable(id)` | Mark skill as enabled |
|
|
111
|
+
| `disable(id)` | Mark skill as disabled |
|
|
112
|
+
| `get(id)` | Get `RegisteredSkill` by id |
|
|
113
|
+
| `has(id)` | Check registration |
|
|
114
|
+
| `list()` | All skills (enabled + disabled) |
|
|
115
|
+
| `listEnabled()` | Only enabled skill modules |
|
|
116
|
+
| `execute(id, ctx)` | Execute one skill; throws if disabled |
|
|
117
|
+
| `executeSafe(id, ctx)` | Execute one skill; returns failed result instead of throwing |
|
|
118
|
+
| `executeAll(ctx)` | Execute all enabled skills; returns `Map<id, SkillResult>` |
|
|
119
|
+
| `loadFromConfig(cfg)` | Apply a `SkillConfig` to the registry |
|
|
120
|
+
| `toConfig()` | Serialize registry state to `SkillConfig` |
|
|
121
|
+
|
|
122
|
+
### Config helpers
|
|
123
|
+
|
|
124
|
+
| Function | Description |
|
|
125
|
+
|----------|-------------|
|
|
126
|
+
| `loadSkillConfig(root?)` | Read `.weave.config.json` → `SkillConfig` |
|
|
127
|
+
| `saveSkillConfig(cfg, root?)` | Write (merge) `SkillConfig` to file |
|
|
128
|
+
| `setSkillEnabled(id, enabled, root?)` | Toggle a single skill |
|
|
129
|
+
| `mergeSkillConfig(updates, root?)` | Merge partial updates |
|
|
130
|
+
| `configExists(root?)` | Check if config file exists |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Phase 9 Skill IDs
|
|
135
|
+
|
|
136
|
+
The following skill ids are planned for M20–M22:
|
|
137
|
+
|
|
138
|
+
| Phase | Id | Description |
|
|
139
|
+
|-------|----|-------------|
|
|
140
|
+
| M20 | `auto-fix` | Apply VULN patches automatically |
|
|
141
|
+
| M20 | `code-review` | Structured review of `git diff HEAD` |
|
|
142
|
+
| M20 | `test-gen` | Generate missing Vitest unit tests |
|
|
143
|
+
| M20 | `docs-gen` | JSDoc + README + CHANGELOG generation |
|
|
144
|
+
| M20 | `refactor` | Code smell detection + diff preview |
|
|
145
|
+
| M21 | `pipeline-aware` | CI/CD log diagnosis |
|
|
146
|
+
| M21 | `dep-audit` | Dependency CVE + outdated detection |
|
|
147
|
+
| M21 | `perf-profile` | Build/test bottleneck analysis |
|
|
148
|
+
| M21 | `container-advisor` | Dockerfile best-practice audit |
|
|
149
|
+
| M21 | `deploy-provision` | Interactive production provisioning |
|
|
150
|
+
| M22 | `onboarding` | Interactive project tour |
|
|
151
|
+
| M22 | `commit-composer` | Conventional Commits message generation |
|
|
152
|
+
| M22 | `context-memory` | Cross-session architectural memory |
|
|
153
|
+
| M22 | `multi-repo` | Multi-repository reasoning |
|
|
154
|
+
| M22 | `cli-interactive` | REPL `weave chat` with all skills |
|
|
@@ -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,123 @@
|
|
|
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 { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { join, resolve } from 'node:path';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Constants
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/** Name of the config file, located at the project root (not inside .weave/). */
|
|
13
|
+
export const CONFIG_FILENAME = '.weave.config.json';
|
|
14
|
+
/** A SkillConfig with no skills registered. */
|
|
15
|
+
export const DEFAULT_SKILL_CONFIG = {
|
|
16
|
+
skills: {},
|
|
17
|
+
};
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Public API
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/**
|
|
22
|
+
* Load the SkillConfig from `.weave.config.json` in the given project root.
|
|
23
|
+
* Returns DEFAULT_SKILL_CONFIG if the file does not exist or has no `skills` key.
|
|
24
|
+
*
|
|
25
|
+
* @param projectRoot - Absolute or relative path to the project root (default: cwd)
|
|
26
|
+
*/
|
|
27
|
+
export function loadSkillConfig(projectRoot) {
|
|
28
|
+
const root = resolve(projectRoot ?? process.cwd());
|
|
29
|
+
const configPath = _configPath(root);
|
|
30
|
+
if (!existsSync(configPath)) {
|
|
31
|
+
return { skills: {} };
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const raw = readFileSync(configPath, 'utf-8');
|
|
35
|
+
const parsed = JSON.parse(raw);
|
|
36
|
+
return {
|
|
37
|
+
skills: parsed.skills ?? {},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Invalid JSON — return empty config rather than crashing
|
|
42
|
+
return { skills: {} };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load the full `.weave.config.json` object (all keys, not just skills).
|
|
47
|
+
* Returns an empty object if the file does not exist.
|
|
48
|
+
*/
|
|
49
|
+
export function loadWeaveConfig(projectRoot) {
|
|
50
|
+
const root = resolve(projectRoot ?? process.cwd());
|
|
51
|
+
const configPath = _configPath(root);
|
|
52
|
+
if (!existsSync(configPath)) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const raw = readFileSync(configPath, 'utf-8');
|
|
57
|
+
return JSON.parse(raw);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Persist a SkillConfig into `.weave.config.json`.
|
|
65
|
+
* Merges with any existing keys in the file so other sections are preserved.
|
|
66
|
+
*
|
|
67
|
+
* @param config - The SkillConfig to save
|
|
68
|
+
* @param projectRoot - Absolute or relative path to the project root (default: cwd)
|
|
69
|
+
*/
|
|
70
|
+
export function saveSkillConfig(config, projectRoot) {
|
|
71
|
+
const root = resolve(projectRoot ?? process.cwd());
|
|
72
|
+
const configPath = _configPath(root);
|
|
73
|
+
// Read existing config to preserve non-skills keys
|
|
74
|
+
const existing = loadWeaveConfig(root);
|
|
75
|
+
const merged = {
|
|
76
|
+
...existing,
|
|
77
|
+
skills: config.skills,
|
|
78
|
+
};
|
|
79
|
+
writeFileSync(configPath, JSON.stringify(merged, null, 2) + '\n', 'utf-8');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Enable or disable a single skill in `.weave.config.json`.
|
|
83
|
+
* Creates the config file if it does not exist.
|
|
84
|
+
*
|
|
85
|
+
* @param skillId - The skill identifier (e.g. 'auto-fix')
|
|
86
|
+
* @param enabled - true to enable, false to disable
|
|
87
|
+
* @param projectRoot - Project root (default: cwd)
|
|
88
|
+
*/
|
|
89
|
+
export function setSkillEnabled(skillId, enabled, projectRoot) {
|
|
90
|
+
const existing = loadSkillConfig(projectRoot);
|
|
91
|
+
const updated = {
|
|
92
|
+
skills: { ...existing.skills, [skillId]: enabled },
|
|
93
|
+
};
|
|
94
|
+
saveSkillConfig(updated, projectRoot);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Merge a partial SkillConfig update into the existing config and persist.
|
|
98
|
+
*
|
|
99
|
+
* @param updates - Partial skills map to merge
|
|
100
|
+
* @param projectRoot - Project root (default: cwd)
|
|
101
|
+
*/
|
|
102
|
+
export function mergeSkillConfig(updates, projectRoot) {
|
|
103
|
+
const existing = loadSkillConfig(projectRoot);
|
|
104
|
+
const merged = {
|
|
105
|
+
skills: { ...existing.skills, ...(updates.skills ?? {}) },
|
|
106
|
+
};
|
|
107
|
+
saveSkillConfig(merged, projectRoot);
|
|
108
|
+
return merged;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns true if `.weave.config.json` exists in the given project root.
|
|
112
|
+
*/
|
|
113
|
+
export function configExists(projectRoot) {
|
|
114
|
+
const root = resolve(projectRoot ?? process.cwd());
|
|
115
|
+
return existsSync(_configPath(root));
|
|
116
|
+
}
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// Internal helpers
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
function _configPath(root) {
|
|
121
|
+
return join(root, CONFIG_FILENAME);
|
|
122
|
+
}
|
|
123
|
+
//# 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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AAC,CAAC;IAC9C,MAAM,MAAM,GAAgB;QAC1B,MAAM,EAAE,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE;KAC1D,CAAC;IACF,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,WAAoB;IAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,OAAO,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
// Registry
|
|
9
|
+
export { SkillRegistry } from './skill-registry.js';
|
|
10
|
+
// Config helpers
|
|
11
|
+
export { CONFIG_FILENAME, DEFAULT_SKILL_CONFIG, loadSkillConfig, loadWeaveConfig, saveSkillConfig, setSkillEnabled, mergeSkillConfig, configExists, } from './config-loader.js';
|
|
12
|
+
// Core Dev Skills (M20) + DevOps Skills (M21) + Developer Experience Skills (M22)
|
|
13
|
+
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';
|
|
14
|
+
//# 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,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,iBAAiB;AACjB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,kFAAkF;AAClF,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,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;;;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