@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
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill: cli-interactive
|
|
3
|
+
*
|
|
4
|
+
* REPL mode descriptor and command dispatcher for `weave chat`.
|
|
5
|
+
* Opens a persistent conversational session with history, command autocompletion
|
|
6
|
+
* and access to all active skills.
|
|
7
|
+
*
|
|
8
|
+
* In practice, the actual REPL loop is handled by the CLI process; this skill
|
|
9
|
+
* provides the session configuration, help text and simulated command dispatch
|
|
10
|
+
* for testing purposes.
|
|
11
|
+
*
|
|
12
|
+
* Input (via SkillContext.graph):
|
|
13
|
+
* - `ctx.graph['command']` â string to simulate a REPL command (for tests)
|
|
14
|
+
* - `ctx.graph['history']` â string[] of previous commands (injectable)
|
|
15
|
+
* - `ctx.graph['skills']` â string[] of active skill IDs for help text
|
|
16
|
+
* - `ctx.graph['sessionId']` â override session ID
|
|
17
|
+
*
|
|
18
|
+
* Output data:
|
|
19
|
+
* - CliInteractiveResult
|
|
20
|
+
*/
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Built-in REPL commands
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
export const REPL_COMMANDS = [
|
|
25
|
+
{
|
|
26
|
+
name: 'help',
|
|
27
|
+
aliases: ['?', 'h'],
|
|
28
|
+
description: 'Show available commands and active skills',
|
|
29
|
+
usage: 'help [command]',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'skills',
|
|
33
|
+
aliases: ['ls'],
|
|
34
|
+
description: 'List all active skills',
|
|
35
|
+
usage: 'skills',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'run',
|
|
39
|
+
aliases: ['exec'],
|
|
40
|
+
description: 'Execute a skill by ID',
|
|
41
|
+
usage: 'run <skill-id> [--option value]',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'history',
|
|
45
|
+
aliases: ['hist'],
|
|
46
|
+
description: 'Show command history',
|
|
47
|
+
usage: 'history [n]',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'clear',
|
|
51
|
+
aliases: ['cls'],
|
|
52
|
+
description: 'Clear the terminal screen',
|
|
53
|
+
usage: 'clear',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'session',
|
|
57
|
+
aliases: ['info'],
|
|
58
|
+
description: 'Show current session information',
|
|
59
|
+
usage: 'session',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'quit',
|
|
63
|
+
aliases: ['exit', 'q'],
|
|
64
|
+
description: 'Exit the interactive session',
|
|
65
|
+
usage: 'quit',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Helpers
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
export function buildHelpText(commands, activeSkills) {
|
|
72
|
+
const lines = [
|
|
73
|
+
'âââââââââââââââââââââââââââââââââââââââââ',
|
|
74
|
+
'â OpenWeave Interactive (REPL) â',
|
|
75
|
+
'âââââââââââââââââââââââââââââââââââââââââ',
|
|
76
|
+
'',
|
|
77
|
+
'Commands:',
|
|
78
|
+
...commands.map((c) => ` ${c.name.padEnd(12)} ${c.description}`),
|
|
79
|
+
'',
|
|
80
|
+
`Active skills (${activeSkills.length}):`,
|
|
81
|
+
...(activeSkills.length > 0
|
|
82
|
+
? activeSkills.map((s) => ` âĸ ${s}`)
|
|
83
|
+
: [' No skills active â run `weave skills enable <id>`']),
|
|
84
|
+
'',
|
|
85
|
+
'Type `help <command>` for detailed usage.',
|
|
86
|
+
'Type `quit` or press Ctrl+C to exit.',
|
|
87
|
+
];
|
|
88
|
+
return lines.join('\n');
|
|
89
|
+
}
|
|
90
|
+
export function buildWelcomeMessage(sessionId) {
|
|
91
|
+
return [
|
|
92
|
+
`đ§ OpenWeave v0.9.0 â Interactive Mode`,
|
|
93
|
+
`Session: ${sessionId}`,
|
|
94
|
+
`Type 'help' for commands, 'quit' to exit.`,
|
|
95
|
+
].join('\n');
|
|
96
|
+
}
|
|
97
|
+
export function parseCommand(input) {
|
|
98
|
+
const parts = input.trim().split(/\s+/);
|
|
99
|
+
return { name: parts[0]?.toLowerCase() ?? '', args: parts.slice(1) };
|
|
100
|
+
}
|
|
101
|
+
export function dispatchCommand(parsed, config, history) {
|
|
102
|
+
const { name, args } = parsed;
|
|
103
|
+
// Resolve aliases
|
|
104
|
+
const cmd = config.commands.find((c) => c.name === name || c.aliases.includes(name));
|
|
105
|
+
if (!cmd) {
|
|
106
|
+
return {
|
|
107
|
+
command: name,
|
|
108
|
+
args,
|
|
109
|
+
output: `Unknown command: "${name}". Type 'help' for available commands.`,
|
|
110
|
+
type: 'error',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
switch (cmd.name) {
|
|
114
|
+
case 'help': {
|
|
115
|
+
if (args.length > 0) {
|
|
116
|
+
const target = config.commands.find((c) => c.name === args[0] || c.aliases.includes(args[0] ?? ''));
|
|
117
|
+
if (target) {
|
|
118
|
+
return {
|
|
119
|
+
command: name,
|
|
120
|
+
args,
|
|
121
|
+
output: `${target.name} â ${target.description}\nUsage: ${target.usage}\nAliases: ${target.aliases.join(', ')}`,
|
|
122
|
+
type: 'info',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
command: name,
|
|
128
|
+
args,
|
|
129
|
+
output: buildHelpText(config.commands, config.activeSkills),
|
|
130
|
+
type: 'info',
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
case 'skills':
|
|
134
|
+
return {
|
|
135
|
+
command: name,
|
|
136
|
+
args,
|
|
137
|
+
output: config.activeSkills.length > 0
|
|
138
|
+
? `Active skills:\n${config.activeSkills.map((s) => ` âĸ ${s}`).join('\n')}`
|
|
139
|
+
: 'No skills active. Run `weave skills enable <id>` to activate skills.',
|
|
140
|
+
type: 'info',
|
|
141
|
+
};
|
|
142
|
+
case 'history': {
|
|
143
|
+
const n = parseInt(args[0] ?? '10', 10);
|
|
144
|
+
const slice = history.slice(-n);
|
|
145
|
+
return {
|
|
146
|
+
command: name,
|
|
147
|
+
args,
|
|
148
|
+
output: slice.length > 0
|
|
149
|
+
? slice.map((h, i) => ` ${i + 1}. ${h}`).join('\n')
|
|
150
|
+
: 'No history yet.',
|
|
151
|
+
type: 'info',
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
case 'session':
|
|
155
|
+
return {
|
|
156
|
+
command: name,
|
|
157
|
+
args,
|
|
158
|
+
output: `Session ID: ${config.sessionId}\nActive skills: ${config.activeSkills.length}\nHistory entries: ${history.length}`,
|
|
159
|
+
type: 'info',
|
|
160
|
+
};
|
|
161
|
+
case 'run': {
|
|
162
|
+
const skillId = args[0];
|
|
163
|
+
if (!skillId) {
|
|
164
|
+
return {
|
|
165
|
+
command: name,
|
|
166
|
+
args,
|
|
167
|
+
output: 'Usage: run <skill-id>',
|
|
168
|
+
type: 'error',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (!config.activeSkills.includes(skillId)) {
|
|
172
|
+
return {
|
|
173
|
+
command: name,
|
|
174
|
+
args,
|
|
175
|
+
output: `Skill "${skillId}" is not active. Enable it with: weave skills enable ${skillId}`,
|
|
176
|
+
type: 'error',
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
command: name,
|
|
181
|
+
args,
|
|
182
|
+
output: `Running skill "${skillId}"âĻ [dispatched to SkillRegistry]`,
|
|
183
|
+
type: 'skill',
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
case 'clear':
|
|
187
|
+
return {
|
|
188
|
+
command: name,
|
|
189
|
+
args,
|
|
190
|
+
output: '\x1B[2J\x1B[0f', // ANSI clear screen
|
|
191
|
+
type: 'success',
|
|
192
|
+
};
|
|
193
|
+
case 'quit':
|
|
194
|
+
return {
|
|
195
|
+
command: name,
|
|
196
|
+
args,
|
|
197
|
+
output: 'Goodbye! đ',
|
|
198
|
+
type: 'success',
|
|
199
|
+
};
|
|
200
|
+
default:
|
|
201
|
+
return {
|
|
202
|
+
command: name,
|
|
203
|
+
args,
|
|
204
|
+
output: `Command "${cmd.name}" is registered but not yet implemented.`,
|
|
205
|
+
type: 'info',
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
// Skill
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
export const cliInteractiveSkill = {
|
|
213
|
+
id: 'cli-interactive',
|
|
214
|
+
name: 'CLI Interactive (REPL)',
|
|
215
|
+
description: 'Provides configuration and command dispatch for the `weave chat` REPL mode with persistent history and skill access.',
|
|
216
|
+
version: '1.0.0',
|
|
217
|
+
enabled: true,
|
|
218
|
+
tags: ['cli', 'repl', 'dx', 'interactive'],
|
|
219
|
+
async execute(ctx) {
|
|
220
|
+
const opts = (ctx.graph ?? {});
|
|
221
|
+
const sessionId = opts['sessionId'] ??
|
|
222
|
+
ctx.session?.id ??
|
|
223
|
+
`repl-${Date.now()}`;
|
|
224
|
+
const activeSkills = Array.isArray(opts['skills'])
|
|
225
|
+
? opts['skills']
|
|
226
|
+
: [];
|
|
227
|
+
const history = Array.isArray(opts['history'])
|
|
228
|
+
? opts['history']
|
|
229
|
+
: [];
|
|
230
|
+
const config = {
|
|
231
|
+
sessionId,
|
|
232
|
+
prompt: 'weave> ',
|
|
233
|
+
historyFile: '.weave/.repl_history',
|
|
234
|
+
maxHistory: 500,
|
|
235
|
+
activeSkills,
|
|
236
|
+
commands: REPL_COMMANDS,
|
|
237
|
+
};
|
|
238
|
+
const helpText = buildHelpText(REPL_COMMANDS, activeSkills);
|
|
239
|
+
const welcomeMessage = buildWelcomeMessage(sessionId);
|
|
240
|
+
const result = {
|
|
241
|
+
config,
|
|
242
|
+
helpText,
|
|
243
|
+
welcomeMessage,
|
|
244
|
+
};
|
|
245
|
+
// If a command was provided, simulate dispatch
|
|
246
|
+
const rawCommand = opts['command'];
|
|
247
|
+
if (rawCommand) {
|
|
248
|
+
const parsed = parseCommand(rawCommand);
|
|
249
|
+
const cmdResult = dispatchCommand(parsed, config, history);
|
|
250
|
+
result.commandResult = cmdResult;
|
|
251
|
+
return {
|
|
252
|
+
success: cmdResult.type !== 'error',
|
|
253
|
+
output: cmdResult.output,
|
|
254
|
+
data: result,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
success: true,
|
|
259
|
+
output: welcomeMessage,
|
|
260
|
+
data: result,
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=cli-interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-interactive.js","sourceRoot":"","sources":["../../src/skills/cli-interactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAsCH,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;QACnB,WAAW,EAAE,2CAA2C;QACxD,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,IAAI,CAAC;QACf,WAAW,EAAE,wBAAwB;QACrC,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,uBAAuB;QACpC,KAAK,EAAE,iCAAiC;KACzC;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,sBAAsB;QACnC,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,CAAC,KAAK,CAAC;QAChB,WAAW,EAAE,2BAA2B;QACxC,KAAK,EAAE,OAAO;KACf;IACD;QACE,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,WAAW,EAAE,k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CAAC,CAAC;YACxC,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC3D,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;YAEjC,OAAO;gBACL,OAAO,EAAE,SAAS,CAAC,IAAI,KAAK,OAAO;gBACnC,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,MAAM;SACb,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill: code-review
|
|
3
|
+
*
|
|
4
|
+
* Performs static code review on the current `git diff HEAD`.
|
|
5
|
+
* No LLM required â pure pattern matching on diffs.
|
|
6
|
+
*
|
|
7
|
+
* Checks:
|
|
8
|
+
* - console.log / console.error / debugger statements
|
|
9
|
+
* - TODO / FIXME / HACK / XXX annotations
|
|
10
|
+
* - Lines exceeding 120 characters
|
|
11
|
+
* - Hard-coded secret patterns (password=, api_key=, SECRET, TOKEN in assignments)
|
|
12
|
+
* - Missing `await` on common async patterns
|
|
13
|
+
* - `@ts-ignore` / `@ts-nocheck` suppressions
|
|
14
|
+
* - `any` type annotations in TypeScript
|
|
15
|
+
* - Empty catch blocks
|
|
16
|
+
*/
|
|
17
|
+
import type { SkillModule } from '../types.js';
|
|
18
|
+
export type ReviewCategory = 'debug' | 'note' | 'style' | 'security' | 'performance' | 'type-safety';
|
|
19
|
+
export type ReviewSeverity = 'error' | 'warning' | 'info';
|
|
20
|
+
export interface ReviewComment {
|
|
21
|
+
file: string;
|
|
22
|
+
line: number;
|
|
23
|
+
category: ReviewCategory;
|
|
24
|
+
severity: ReviewSeverity;
|
|
25
|
+
message: string;
|
|
26
|
+
snippet: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CodeReviewResult {
|
|
29
|
+
diff: string;
|
|
30
|
+
comments: ReviewComment[];
|
|
31
|
+
summary: {
|
|
32
|
+
errors: number;
|
|
33
|
+
warnings: number;
|
|
34
|
+
infos: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare function parseDiff(diff: string): ReviewComment[];
|
|
38
|
+
export declare const codeReviewSkill: SkillModule;
|
|
39
|
+
//# sourceMappingURL=code-review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-review.d.ts","sourceRoot":"","sources":["../../src/skills/code-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,WAAW,EAA6B,MAAM,aAAa,CAAC;AAM1E,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,aAAa,CAAC;AACrG,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D;AAoED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CA0DvD;AA4BD,eAAO,MAAM,eAAe,EAAE,WA4D7B,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill: code-review
|
|
3
|
+
*
|
|
4
|
+
* Performs static code review on the current `git diff HEAD`.
|
|
5
|
+
* No LLM required â pure pattern matching on diffs.
|
|
6
|
+
*
|
|
7
|
+
* Checks:
|
|
8
|
+
* - console.log / console.error / debugger statements
|
|
9
|
+
* - TODO / FIXME / HACK / XXX annotations
|
|
10
|
+
* - Lines exceeding 120 characters
|
|
11
|
+
* - Hard-coded secret patterns (password=, api_key=, SECRET, TOKEN in assignments)
|
|
12
|
+
* - Missing `await` on common async patterns
|
|
13
|
+
* - `@ts-ignore` / `@ts-nocheck` suppressions
|
|
14
|
+
* - `any` type annotations in TypeScript
|
|
15
|
+
* - Empty catch blocks
|
|
16
|
+
*/
|
|
17
|
+
import { execSync } from 'node:child_process';
|
|
18
|
+
const RULES = [
|
|
19
|
+
{
|
|
20
|
+
pattern: /console\.(log|warn|error|debug|info)\s*\(/,
|
|
21
|
+
category: 'debug',
|
|
22
|
+
severity: 'warning',
|
|
23
|
+
message: 'Remove console statement before merging',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
pattern: /\bdebugger\b/,
|
|
27
|
+
category: 'debug',
|
|
28
|
+
severity: 'error',
|
|
29
|
+
message: 'Remove debugger statement',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
pattern: /\b(TODO|FIXME|HACK|XXX)\b/,
|
|
33
|
+
category: 'note',
|
|
34
|
+
severity: 'info',
|
|
35
|
+
message: 'Unresolved annotation â consider filing an issue',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
pattern: /(password|passwd|secret|api_key|apikey|token)\s*=\s*['"`][^'"`]{4,}/i,
|
|
39
|
+
category: 'security',
|
|
40
|
+
severity: 'error',
|
|
41
|
+
message: 'Potential hard-coded credential â use environment variables',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
pattern: /@ts-ignore|@ts-nocheck/,
|
|
45
|
+
category: 'type-safety',
|
|
46
|
+
severity: 'warning',
|
|
47
|
+
message: 'TypeScript suppression annotation â resolve the underlying type error',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
pattern: /:\s*any\b/,
|
|
51
|
+
category: 'type-safety',
|
|
52
|
+
severity: 'info',
|
|
53
|
+
message: 'Explicit `any` type â consider a more specific type',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
pattern: /catch\s*\([^)]*\)\s*\{\s*\}/,
|
|
57
|
+
category: 'debug',
|
|
58
|
+
severity: 'warning',
|
|
59
|
+
message: 'Empty catch block swallows errors silently',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
pattern: /\.then\s*\(/,
|
|
63
|
+
category: 'performance',
|
|
64
|
+
severity: 'info',
|
|
65
|
+
message: 'Prefer async/await over raw .then() chains for readability',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Parser
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
export function parseDiff(diff) {
|
|
72
|
+
const comments = [];
|
|
73
|
+
let currentFile = '';
|
|
74
|
+
let lineNumber = 0;
|
|
75
|
+
for (const line of diff.split('\n')) {
|
|
76
|
+
// Track current file
|
|
77
|
+
if (line.startsWith('+++ b/')) {
|
|
78
|
+
currentFile = line.slice(6);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
// Track line numbers in new file
|
|
82
|
+
const hunkMatch = /^@@ -\d+(?:,\d+)? \+(\d+)/.exec(line);
|
|
83
|
+
if (hunkMatch) {
|
|
84
|
+
lineNumber = parseInt(hunkMatch[1], 10) - 1;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Skip removed lines and metadata
|
|
88
|
+
if (line.startsWith('-') || line.startsWith('diff ') || line.startsWith('index '))
|
|
89
|
+
continue;
|
|
90
|
+
// Added or context lines advance line counter
|
|
91
|
+
if (line.startsWith('+') || (!line.startsWith('@') && !line.startsWith('\\'))) {
|
|
92
|
+
lineNumber++;
|
|
93
|
+
}
|
|
94
|
+
// Only check added lines (+) â not context lines
|
|
95
|
+
if (!line.startsWith('+'))
|
|
96
|
+
continue;
|
|
97
|
+
const code = line.slice(1); // strip leading +
|
|
98
|
+
// Long line check
|
|
99
|
+
if (code.length > 120) {
|
|
100
|
+
comments.push({
|
|
101
|
+
file: currentFile,
|
|
102
|
+
line: lineNumber,
|
|
103
|
+
category: 'style',
|
|
104
|
+
severity: 'info',
|
|
105
|
+
message: `Line is ${code.length} chars (limit: 120)`,
|
|
106
|
+
snippet: code.slice(0, 80) + 'âĻ',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Rule-based checks
|
|
110
|
+
for (const rule of RULES) {
|
|
111
|
+
if (rule.pattern.test(code)) {
|
|
112
|
+
comments.push({
|
|
113
|
+
file: currentFile,
|
|
114
|
+
line: lineNumber,
|
|
115
|
+
category: rule.category,
|
|
116
|
+
severity: rule.severity,
|
|
117
|
+
message: rule.message,
|
|
118
|
+
snippet: code.trim().slice(0, 100),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return comments;
|
|
124
|
+
}
|
|
125
|
+
function formatComments(comments) {
|
|
126
|
+
if (comments.length === 0)
|
|
127
|
+
return ' â
No issues found.';
|
|
128
|
+
const byFile = new Map();
|
|
129
|
+
for (const c of comments) {
|
|
130
|
+
const list = byFile.get(c.file) ?? [];
|
|
131
|
+
list.push(c);
|
|
132
|
+
byFile.set(c.file, list);
|
|
133
|
+
}
|
|
134
|
+
const lines = [];
|
|
135
|
+
for (const [file, cs] of byFile.entries()) {
|
|
136
|
+
lines.push(`\n đ ${file}`);
|
|
137
|
+
for (const c of cs) {
|
|
138
|
+
const icon = c.severity === 'error' ? 'â' : c.severity === 'warning' ? 'â ī¸ ' : 'âšī¸ ';
|
|
139
|
+
lines.push(` ${icon} L${c.line} [${c.category}] ${c.message}`);
|
|
140
|
+
lines.push(` ${c.snippet}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return lines.join('\n');
|
|
144
|
+
}
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// Skill
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
export const codeReviewSkill = {
|
|
149
|
+
id: 'code-review',
|
|
150
|
+
name: 'Code Review',
|
|
151
|
+
description: 'Static code review of git diff HEAD â detects debug statements, security issues and style violations',
|
|
152
|
+
version: '1.0.0',
|
|
153
|
+
enabled: false,
|
|
154
|
+
tags: ['dev', 'quality'],
|
|
155
|
+
async execute(ctx) {
|
|
156
|
+
// Allow injecting diff via context for testability
|
|
157
|
+
const opts = ctx.graph ?? {};
|
|
158
|
+
let diff;
|
|
159
|
+
const diffInjected = 'diff' in opts;
|
|
160
|
+
if (diffInjected) {
|
|
161
|
+
diff = String(opts['diff'] ?? '');
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
try {
|
|
165
|
+
diff = execSync('git diff HEAD', {
|
|
166
|
+
cwd: ctx.projectRoot,
|
|
167
|
+
stdio: 'pipe',
|
|
168
|
+
encoding: 'utf-8',
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
output: 'â Could not run git diff â is this a git repository?',
|
|
175
|
+
error: 'git diff HEAD failed',
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (!diff.trim()) {
|
|
180
|
+
return {
|
|
181
|
+
success: true,
|
|
182
|
+
output: 'â
No staged changes found â working tree is clean.',
|
|
183
|
+
data: { diff: '', comments: [], summary: { errors: 0, warnings: 0, infos: 0 } },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const comments = parseDiff(diff);
|
|
187
|
+
const summary = {
|
|
188
|
+
errors: comments.filter((c) => c.severity === 'error').length,
|
|
189
|
+
warnings: comments.filter((c) => c.severity === 'warning').length,
|
|
190
|
+
infos: comments.filter((c) => c.severity === 'info').length,
|
|
191
|
+
};
|
|
192
|
+
const statusLine = summary.errors > 0
|
|
193
|
+
? `â ${summary.errors} error(s), ${summary.warnings} warning(s), ${summary.infos} info(s)`
|
|
194
|
+
: summary.warnings > 0
|
|
195
|
+
? `â ī¸ 0 errors, ${summary.warnings} warning(s), ${summary.infos} info(s)`
|
|
196
|
+
: `â
0 errors, 0 warnings, ${summary.infos} info(s)`;
|
|
197
|
+
return {
|
|
198
|
+
success: true,
|
|
199
|
+
output: `đ Code Review\n${statusLine}\n${formatComments(comments)}`,
|
|
200
|
+
data: { diff, comments, summary },
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=code-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-review.js","sourceRoot":"","sources":["../../src/skills/code-review.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAoC9C,MAAM,KAAK,GAAiB;IAC1B;QACE,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,yCAAyC;KACnD;IACD;QACE,OAAO,EAAE,cAAc;QACvB,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,2BAA2B;KACrC;IACD;QACE,OAAO,EAAE,2BAA2B;QACpC,QAAQ,EAAE,MAAM;QAChB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,kDAAkD;KAC5D;IACD;QACE,OAAO,EAAE,sEAAsE;QAC/E,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,6DAA6D;KACvE;IACD;QACE,OAAO,EAAE,wBAAwB;QACjC,QAAQ,EAAE,aAAa;QACvB,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,uEAAuE;KACjF;IACD;QACE,OAAO,EAAE,WAAW;QACpB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AM;YAC7D,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,MAAM;YACjE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM;SAC5D,CAAC;QAEF,MAAM,UAAU,GACd,OAAO,CAAC,MAAM,GAAG,CAAC;YAChB,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,cAAc,OAAO,CAAC,QAAQ,gBAAgB,OAAO,CAAC,KAAK,UAAU;YAC1F,CAAC,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC;gBACtB,CAAC,CAAC,iBAAiB,OAAO,CAAC,QAAQ,gBAAgB,OAAO,CAAC,KAAK,UAAU;gBAC1E,CAAC,CAAC,2BAA2B,OAAO,CAAC,KAAK,UAAU,CAAC;QAEzD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,mBAAmB,UAAU,KAAK,cAAc,CAAC,QAAQ,CAAC,EAAE;YACpE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAsB;SACtD,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill: commit-composer
|
|
3
|
+
*
|
|
4
|
+
* Analyses `git diff --staged` and proposes a Conventional Commits message.
|
|
5
|
+
* No LLM required â pure pattern-matching on diff hunks.
|
|
6
|
+
*
|
|
7
|
+
* Conventional format: <type>(<scope>): <description>
|
|
8
|
+
* [optional body]
|
|
9
|
+
* [optional footer: BREAKING CHANGE: ...]
|
|
10
|
+
*
|
|
11
|
+
* Types detected: feat, fix, docs, style, refactor, test, chore, perf, ci, build
|
|
12
|
+
*
|
|
13
|
+
* Input (via SkillContext.graph):
|
|
14
|
+
* - `ctx.graph['diff']` â staged diff string (injectable for tests)
|
|
15
|
+
* - `ctx.graph['stagedFiles']` â string[] (overrides ctx.git?.stagedFiles)
|
|
16
|
+
*
|
|
17
|
+
* Output data:
|
|
18
|
+
* - CommitComposerResult
|
|
19
|
+
*/
|
|
20
|
+
import type { SkillModule } from '../types.js';
|
|
21
|
+
export type ConventionalType = 'feat' | 'fix' | 'docs' | 'style' | 'refactor' | 'test' | 'chore' | 'perf' | 'ci' | 'build';
|
|
22
|
+
export interface CommitComposerResult {
|
|
23
|
+
suggestedMessage: string;
|
|
24
|
+
type: ConventionalType;
|
|
25
|
+
scope: string | null;
|
|
26
|
+
description: string;
|
|
27
|
+
breakingChange: boolean;
|
|
28
|
+
breakingChangeNote: string | null;
|
|
29
|
+
changedFiles: string[];
|
|
30
|
+
stats: {
|
|
31
|
+
additions: number;
|
|
32
|
+
deletions: number;
|
|
33
|
+
filesChanged: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
interface DiffStats {
|
|
37
|
+
additions: number;
|
|
38
|
+
deletions: number;
|
|
39
|
+
filesChanged: string[];
|
|
40
|
+
}
|
|
41
|
+
export declare function parseDiffStats(diff: string): DiffStats;
|
|
42
|
+
export declare function detectScope(files: string[]): string | null;
|
|
43
|
+
export declare function detectType(files: string[], diff: string): ConventionalType;
|
|
44
|
+
export declare function detectBreakingChange(diff: string): {
|
|
45
|
+
breaking: boolean;
|
|
46
|
+
note: string | null;
|
|
47
|
+
};
|
|
48
|
+
export declare function buildDescription(type: ConventionalType, _scope: string | null, _stats: DiffStats, files: string[]): string;
|
|
49
|
+
export declare const commitComposerSkill: SkillModule;
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=commit-composer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-composer.d.ts","sourceRoot":"","sources":["../../src/skills/commit-composer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,WAAW,E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