skillshield 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 +400 -0
- package/dist/channels/discord.d.ts +18 -0
- package/dist/channels/discord.d.ts.map +1 -0
- package/dist/channels/discord.js +275 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/channels/index.d.ts +67 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +127 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/slack.d.ts +20 -0
- package/dist/channels/slack.d.ts.map +1 -0
- package/dist/channels/slack.js +296 -0
- package/dist/channels/slack.js.map +1 -0
- package/dist/channels/telegram.d.ts +20 -0
- package/dist/channels/telegram.d.ts.map +1 -0
- package/dist/channels/telegram.js +223 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/channels/whatsapp.d.ts +25 -0
- package/dist/channels/whatsapp.d.ts.map +1 -0
- package/dist/channels/whatsapp.js +187 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/cli/commands/badge.d.ts +11 -0
- package/dist/cli/commands/badge.d.ts.map +1 -0
- package/dist/cli/commands/badge.js +98 -0
- package/dist/cli/commands/badge.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +140 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +3 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +56 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +99 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/install.d.ts +3 -0
- package/dist/cli/commands/install.d.ts.map +1 -0
- package/dist/cli/commands/install.js +90 -0
- package/dist/cli/commands/install.js.map +1 -0
- package/dist/cli/commands/list.d.ts +3 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +76 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +160 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +3 -0
- package/dist/cli/commands/scan.d.ts.map +1 -0
- package/dist/cli/commands/scan.js +133 -0
- package/dist/cli/commands/scan.js.map +1 -0
- package/dist/cli/commands/search.d.ts +3 -0
- package/dist/cli/commands/search.d.ts.map +1 -0
- package/dist/cli/commands/search.js +56 -0
- package/dist/cli/commands/search.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +70 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +167 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +398 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/parser.d.ts +34 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +462 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/runtime.d.ts +68 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +560 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/core/types.d.ts +525 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +44 -0
- package/dist/core/types.js.map +1 -0
- package/dist/guard/index.d.ts +57 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +238 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/patterns.d.ts +21 -0
- package/dist/guard/patterns.d.ts.map +1 -0
- package/dist/guard/patterns.js +797 -0
- package/dist/guard/patterns.js.map +1 -0
- package/dist/hub/index.d.ts +44 -0
- package/dist/hub/index.d.ts.map +1 -0
- package/dist/hub/index.js +144 -0
- package/dist/hub/index.js.map +1 -0
- package/dist/hub/registry.d.ts +52 -0
- package/dist/hub/registry.d.ts.map +1 -0
- package/dist/hub/registry.js +192 -0
- package/dist/hub/registry.js.map +1 -0
- package/dist/i18n/index.d.ts +19 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +92 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/locales/en.d.ts +110 -0
- package/dist/i18n/locales/en.d.ts.map +1 -0
- package/dist/i18n/locales/en.js +123 -0
- package/dist/i18n/locales/en.js.map +1 -0
- package/dist/i18n/locales/es.d.ts +110 -0
- package/dist/i18n/locales/es.d.ts.map +1 -0
- package/dist/i18n/locales/es.js +123 -0
- package/dist/i18n/locales/es.js.map +1 -0
- package/dist/i18n/locales/pt.d.ts +110 -0
- package/dist/i18n/locales/pt.d.ts.map +1 -0
- package/dist/i18n/locales/pt.js +123 -0
- package/dist/i18n/locales/pt.js.map +1 -0
- package/dist/i18n/locales/zh.d.ts +110 -0
- package/dist/i18n/locales/zh.d.ts.map +1 -0
- package/dist/i18n/locales/zh.js +123 -0
- package/dist/i18n/locales/zh.js.map +1 -0
- package/dist/index.d.ts +168 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +275 -0
- package/dist/index.js.map +1 -0
- package/dist/router/index.d.ts +89 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +292 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/providers.d.ts +48 -0
- package/dist/router/providers.d.ts.map +1 -0
- package/dist/router/providers.js +733 -0
- package/dist/router/providers.js.map +1 -0
- package/dist/runtime/executor.d.ts +96 -0
- package/dist/runtime/executor.d.ts.map +1 -0
- package/dist/runtime/executor.js +389 -0
- package/dist/runtime/executor.js.map +1 -0
- package/dist/sandbox/index.d.ts +52 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +248 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/security/skillguard.d.ts +25 -0
- package/dist/security/skillguard.d.ts.map +1 -0
- package/dist/security/skillguard.js +137 -0
- package/dist/security/skillguard.js.map +1 -0
- package/dist/tools/index.d.ts +55 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +276 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/web-engine.d.ts +158 -0
- package/dist/tools/web-engine.d.ts.map +1 -0
- package/dist/tools/web-engine.js +802 -0
- package/dist/tools/web-engine.js.map +1 -0
- package/dist/tools/web-tools.d.ts +173 -0
- package/dist/tools/web-tools.d.ts.map +1 -0
- package/dist/tools/web-tools.js +251 -0
- package/dist/tools/web-tools.js.map +1 -0
- package/dist/utils/errors.d.ts +44 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +130 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +28 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +121 -0
- package/dist/utils/logger.js.map +1 -0
- package/examples/basic-usage.ts +276 -0
- package/examples/code-reviewer.skill.md +83 -0
- package/examples/creative-writer.skill.md +80 -0
- package/examples/data-analyzer.skill.md +61 -0
- package/examples/hello-world.skill.md +36 -0
- package/examples/sample-skill.md +156 -0
- package/examples/summarizer.skill.md +62 -0
- package/examples/translator.skill.md +45 -0
- package/package.json +110 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
const ERROR_MESSAGES = {
|
|
3
|
+
PARSE_ERROR: 'Failed to parse SKILL.md file',
|
|
4
|
+
MODEL_ERROR: 'Model execution error',
|
|
5
|
+
SECURITY_ERROR: 'Security violation detected',
|
|
6
|
+
CHANNEL_ERROR: 'Channel communication error',
|
|
7
|
+
HUB_ERROR: 'Hub operation failed',
|
|
8
|
+
SANDBOX_ERROR: 'Sandbox execution error',
|
|
9
|
+
CONFIG_ERROR: 'Invalid configuration',
|
|
10
|
+
TOOL_ERROR: 'Tool execution failed',
|
|
11
|
+
TIMEOUT_ERROR: 'Operation timed out',
|
|
12
|
+
NOT_FOUND: 'Resource not found',
|
|
13
|
+
INVALID_INPUT: 'Invalid input provided',
|
|
14
|
+
PERMISSION_DENIED: 'Permission denied',
|
|
15
|
+
};
|
|
16
|
+
export class SkillKitError extends Error {
|
|
17
|
+
constructor(code, message, details) {
|
|
18
|
+
const fullMessage = message || ERROR_MESSAGES[code] || 'Unknown error';
|
|
19
|
+
super(fullMessage);
|
|
20
|
+
this.name = 'SkillKitError';
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.details = details;
|
|
23
|
+
this.timestamp = new Date();
|
|
24
|
+
// Maintain proper prototype chain
|
|
25
|
+
Object.setPrototypeOf(this, SkillKitError.prototype);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class ParseError extends SkillKitError {
|
|
29
|
+
constructor(message, details) {
|
|
30
|
+
super('PARSE_ERROR', message, details);
|
|
31
|
+
this.name = 'ParseError';
|
|
32
|
+
Object.setPrototypeOf(this, ParseError.prototype);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class ModelError extends SkillKitError {
|
|
36
|
+
constructor(message, details) {
|
|
37
|
+
super('MODEL_ERROR', message, details);
|
|
38
|
+
this.name = 'ModelError';
|
|
39
|
+
Object.setPrototypeOf(this, ModelError.prototype);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class SecurityError extends SkillKitError {
|
|
43
|
+
constructor(message, details) {
|
|
44
|
+
super('SECURITY_ERROR', message, details);
|
|
45
|
+
this.name = 'SecurityError';
|
|
46
|
+
Object.setPrototypeOf(this, SecurityError.prototype);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ChannelError extends SkillKitError {
|
|
50
|
+
constructor(message, details) {
|
|
51
|
+
super('CHANNEL_ERROR', message, details);
|
|
52
|
+
this.name = 'ChannelError';
|
|
53
|
+
Object.setPrototypeOf(this, ChannelError.prototype);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class HubError extends SkillKitError {
|
|
57
|
+
constructor(message, details) {
|
|
58
|
+
super('HUB_ERROR', message, details);
|
|
59
|
+
this.name = 'HubError';
|
|
60
|
+
Object.setPrototypeOf(this, HubError.prototype);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export class SandboxError extends SkillKitError {
|
|
64
|
+
constructor(message, details) {
|
|
65
|
+
super('SANDBOX_ERROR', message, details);
|
|
66
|
+
this.name = 'SandboxError';
|
|
67
|
+
Object.setPrototypeOf(this, SandboxError.prototype);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class ConfigError extends SkillKitError {
|
|
71
|
+
constructor(message, details) {
|
|
72
|
+
super('CONFIG_ERROR', message, details);
|
|
73
|
+
this.name = 'ConfigError';
|
|
74
|
+
Object.setPrototypeOf(this, ConfigError.prototype);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export class ToolError extends SkillKitError {
|
|
78
|
+
constructor(message, details) {
|
|
79
|
+
super('TOOL_ERROR', message, details);
|
|
80
|
+
this.name = 'ToolError';
|
|
81
|
+
Object.setPrototypeOf(this, ToolError.prototype);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class TimeoutError extends SkillKitError {
|
|
85
|
+
constructor(message, details) {
|
|
86
|
+
super('TIMEOUT_ERROR', message, details);
|
|
87
|
+
this.name = 'TimeoutError';
|
|
88
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function formatError(error, verbose = false) {
|
|
92
|
+
const timestamp = new Date().toISOString();
|
|
93
|
+
if (error instanceof SkillKitError) {
|
|
94
|
+
return {
|
|
95
|
+
code: error.code,
|
|
96
|
+
message: error.message,
|
|
97
|
+
details: error.details,
|
|
98
|
+
timestamp,
|
|
99
|
+
stack: verbose ? error.stack : undefined,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (error instanceof Error) {
|
|
103
|
+
return {
|
|
104
|
+
code: 'MODEL_ERROR',
|
|
105
|
+
message: error.message,
|
|
106
|
+
timestamp,
|
|
107
|
+
stack: verbose ? error.stack : undefined,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
code: 'MODEL_ERROR',
|
|
112
|
+
message: String(error),
|
|
113
|
+
timestamp,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export function formatErrorForCLI(error) {
|
|
117
|
+
const formatted = formatError(error, true);
|
|
118
|
+
let output = '';
|
|
119
|
+
output += chalk.red.bold(`❌ ${formatted.code}\n`);
|
|
120
|
+
output += chalk.red(`${formatted.message}\n`);
|
|
121
|
+
if (formatted.details) {
|
|
122
|
+
output += chalk.dim(`\nDetails:\n${JSON.stringify(formatted.details, null, 2)}\n`);
|
|
123
|
+
}
|
|
124
|
+
if (formatted.stack) {
|
|
125
|
+
output += chalk.dim(`\nStack:\n${formatted.stack}\n`);
|
|
126
|
+
}
|
|
127
|
+
output += chalk.dim(`\nTime: ${formatted.timestamp}`);
|
|
128
|
+
return output;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,MAAM,cAAc,GAA8B;IAChD,WAAW,EAAE,+BAA+B;IAC5C,WAAW,EAAE,uBAAuB;IACpC,cAAc,EAAE,6BAA6B;IAC7C,aAAa,EAAE,6BAA6B;IAC5C,SAAS,EAAE,sBAAsB;IACjC,aAAa,EAAE,yBAAyB;IACxC,YAAY,EAAE,uBAAuB;IACrC,UAAU,EAAE,uBAAuB;IACnC,aAAa,EAAE,qBAAqB;IACpC,SAAS,EAAE,oBAAoB;IAC/B,aAAa,EAAE,wBAAwB;IACvC,iBAAiB,EAAE,mBAAmB;CACvC,CAAC;AAEF,MAAM,OAAO,aAAc,SA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M,GAAG,EAAE,CAAC;IAChB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,IAAI,IAAI,CAAC,CAAC;IAClD,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,OAAO,IAAI,CAAC,CAAC;IAE9C,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;IAEtD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
export declare class Logger {
|
|
3
|
+
private minLevel;
|
|
4
|
+
private verbose;
|
|
5
|
+
private quiet;
|
|
6
|
+
private fileStream;
|
|
7
|
+
constructor(options?: {
|
|
8
|
+
level?: LogLevel;
|
|
9
|
+
verbose?: boolean;
|
|
10
|
+
quiet?: boolean;
|
|
11
|
+
logFile?: boolean;
|
|
12
|
+
});
|
|
13
|
+
private initializeFileLogging;
|
|
14
|
+
private formatTimestamp;
|
|
15
|
+
private shouldLog;
|
|
16
|
+
private writeToFile;
|
|
17
|
+
private log;
|
|
18
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
19
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
20
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
21
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
22
|
+
setLevel(level: LogLevel): void;
|
|
23
|
+
setVerbose(verbose: boolean): void;
|
|
24
|
+
setQuiet(quiet: boolean): void;
|
|
25
|
+
close(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare const defaultLogger: Logger;
|
|
28
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAuB3D,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,UAAU,CAAsC;gBAE5C,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,QAAQ,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAgBjG,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,GAAG;IA0BX,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI9B,KAAK,IAAI,IAAI;CAMd;AAGD,eAAO,MAAM,aAAa,QAAe,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { createWriteStream, mkdirSync, existsSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
const LEVEL_PRIORITY = {
|
|
6
|
+
debug: 0,
|
|
7
|
+
info: 1,
|
|
8
|
+
warn: 2,
|
|
9
|
+
error: 3,
|
|
10
|
+
};
|
|
11
|
+
const LEVEL_COLORS = {
|
|
12
|
+
debug: chalk.gray,
|
|
13
|
+
info: chalk.blue,
|
|
14
|
+
warn: chalk.yellow,
|
|
15
|
+
error: chalk.red,
|
|
16
|
+
};
|
|
17
|
+
const LEVEL_EMOJI = {
|
|
18
|
+
debug: '🐛',
|
|
19
|
+
info: 'ℹ️',
|
|
20
|
+
warn: '⚠️',
|
|
21
|
+
error: '❌',
|
|
22
|
+
};
|
|
23
|
+
export class Logger {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.minLevel = 'info';
|
|
26
|
+
this.verbose = false;
|
|
27
|
+
this.quiet = false;
|
|
28
|
+
this.fileStream = null;
|
|
29
|
+
if (options?.level) {
|
|
30
|
+
this.minLevel = options.level;
|
|
31
|
+
}
|
|
32
|
+
if (options?.verbose) {
|
|
33
|
+
this.verbose = options.verbose;
|
|
34
|
+
}
|
|
35
|
+
if (options?.quiet) {
|
|
36
|
+
this.quiet = options.quiet;
|
|
37
|
+
}
|
|
38
|
+
if (options?.logFile) {
|
|
39
|
+
this.initializeFileLogging();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
initializeFileLogging() {
|
|
43
|
+
try {
|
|
44
|
+
const logsDir = join(homedir(), '.skillkit', 'logs');
|
|
45
|
+
if (!existsSync(logsDir)) {
|
|
46
|
+
mkdirSync(logsDir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
49
|
+
const logPath = join(logsDir, `skillkit-${timestamp}.log`);
|
|
50
|
+
this.fileStream = createWriteStream(logPath, { flags: 'a' });
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
// Silently fail if file logging can't be set up
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
formatTimestamp() {
|
|
57
|
+
return new Date().toISOString();
|
|
58
|
+
}
|
|
59
|
+
shouldLog(level) {
|
|
60
|
+
return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[this.minLevel];
|
|
61
|
+
}
|
|
62
|
+
writeToFile(level, message, context) {
|
|
63
|
+
if (!this.fileStream)
|
|
64
|
+
return;
|
|
65
|
+
const timestamp = this.formatTimestamp();
|
|
66
|
+
const contextStr = context ? ` ${JSON.stringify(context)}` : '';
|
|
67
|
+
const logLine = `[${timestamp}] [${level.toUpperCase()}] ${message}${contextStr}\n`;
|
|
68
|
+
this.fileStream.write(logLine);
|
|
69
|
+
}
|
|
70
|
+
log(level, message, context) {
|
|
71
|
+
if (!this.shouldLog(level))
|
|
72
|
+
return;
|
|
73
|
+
this.writeToFile(level, message, context);
|
|
74
|
+
if (this.quiet) {
|
|
75
|
+
// Output JSON only
|
|
76
|
+
console.log(JSON.stringify({ level, message, context, timestamp: this.formatTimestamp() }));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const timestamp = chalk.gray(this.formatTimestamp());
|
|
80
|
+
const emoji = LEVEL_EMOJI[level];
|
|
81
|
+
const coloredLevel = LEVEL_COLORS[level](level.toUpperCase().padEnd(5));
|
|
82
|
+
let output = `${emoji} ${timestamp} [${coloredLevel}] ${message}`;
|
|
83
|
+
if (this.verbose && context) {
|
|
84
|
+
output += `\n${chalk.dim(JSON.stringify(context, null, 2))}`;
|
|
85
|
+
}
|
|
86
|
+
else if (context && level === 'error') {
|
|
87
|
+
output += `\n${chalk.dim(JSON.stringify(context, null, 2))}`;
|
|
88
|
+
}
|
|
89
|
+
console.log(output);
|
|
90
|
+
}
|
|
91
|
+
debug(message, context) {
|
|
92
|
+
this.log('debug', message, context);
|
|
93
|
+
}
|
|
94
|
+
info(message, context) {
|
|
95
|
+
this.log('info', message, context);
|
|
96
|
+
}
|
|
97
|
+
warn(message, context) {
|
|
98
|
+
this.log('warn', message, context);
|
|
99
|
+
}
|
|
100
|
+
error(message, context) {
|
|
101
|
+
this.log('error', message, context);
|
|
102
|
+
}
|
|
103
|
+
setLevel(level) {
|
|
104
|
+
this.minLevel = level;
|
|
105
|
+
}
|
|
106
|
+
setVerbose(verbose) {
|
|
107
|
+
this.verbose = verbose;
|
|
108
|
+
}
|
|
109
|
+
setQuiet(quiet) {
|
|
110
|
+
this.quiet = quiet;
|
|
111
|
+
}
|
|
112
|
+
close() {
|
|
113
|
+
if (this.fileStream) {
|
|
114
|
+
this.fileStream.end();
|
|
115
|
+
this.fileStream = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Singleton instance
|
|
120
|
+
export const defaultLogger = new Logger();
|
|
121
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAI7B,MAAM,cAAc,GAA6B;IAC/C,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AE,OAAO,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,OAAiC;QACrD,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAAiC;QACtD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,QAAQ,CAAC,KAAe;QACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,QAAQ,CAAC,KAAc;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;IACH,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic SkillKit Usage Examples
|
|
3
|
+
* Demonstrates core functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
initializeConfig,
|
|
8
|
+
getConfig,
|
|
9
|
+
SkillRunner,
|
|
10
|
+
executeSkill,
|
|
11
|
+
ModelProvider,
|
|
12
|
+
} from '../src/index.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Example 1: Initialize configuration
|
|
16
|
+
*/
|
|
17
|
+
async function example1_InitializeConfig() {
|
|
18
|
+
console.log('=== Example 1: Initialize Configuration ===\n');
|
|
19
|
+
|
|
20
|
+
// Initialize with custom config directory
|
|
21
|
+
const config = initializeConfig('/home/user/.skillkit');
|
|
22
|
+
|
|
23
|
+
// Set API keys
|
|
24
|
+
config.setApiKey(ModelProvider.ANTHROPIC, 'sk-ant-...');
|
|
25
|
+
config.setApiKey(ModelProvider.OPENAI, 'sk-proj-...');
|
|
26
|
+
|
|
27
|
+
// Set default provider
|
|
28
|
+
config.setDefaultProvider(ModelProvider.ANTHROPIC);
|
|
29
|
+
|
|
30
|
+
// Configure model
|
|
31
|
+
config.setModel(ModelProvider.ANTHROPIC, 'claude-3-5-sonnet-20241022');
|
|
32
|
+
config.setMaxTokens(4096);
|
|
33
|
+
|
|
34
|
+
// Save configuration
|
|
35
|
+
config.save();
|
|
36
|
+
|
|
37
|
+
console.log('Configuration saved to:', config.getConfigPath());
|
|
38
|
+
console.log('Default provider:', config.getDefaultProvider());
|
|
39
|
+
console.log('Default model:', config.getModel(ModelProvider.ANTHROPIC));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Example 2: Execute a simple skill
|
|
44
|
+
*/
|
|
45
|
+
async function example2_SimpleExecution() {
|
|
46
|
+
console.log('\n=== Example 2: Simple Skill Execution ===\n');
|
|
47
|
+
|
|
48
|
+
// Get global config
|
|
49
|
+
const config = getConfig();
|
|
50
|
+
config.setApiKey(ModelProvider.ANTHROPIC, process.env.ANTHROPIC_API_KEY!);
|
|
51
|
+
config.setDefaultProvider(ModelProvider.ANTHROPIC);
|
|
52
|
+
|
|
53
|
+
const result = await executeSkill(
|
|
54
|
+
'/path/to/skill.md', // Could be file path or registry ID
|
|
55
|
+
{
|
|
56
|
+
topic: 'machine learning',
|
|
57
|
+
language: 'spanish',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
streaming: false,
|
|
61
|
+
timeout: 30000,
|
|
62
|
+
maxTokens: 2048,
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (result.success) {
|
|
67
|
+
console.log('Execution successful!');
|
|
68
|
+
console.log('Output:', result.outputs);
|
|
69
|
+
console.log('Duration:', result.duration, 'ms');
|
|
70
|
+
console.log('Tokens used:', result.usage?.totalTokens);
|
|
71
|
+
} else {
|
|
72
|
+
console.error('Execution failed:', result.error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Example 3: Using SkillRunner for advanced control
|
|
78
|
+
*/
|
|
79
|
+
async function example3_SkillRunnerAdvanced() {
|
|
80
|
+
console.log('\n=== Example 3: Advanced SkillRunner Usage ===\n');
|
|
81
|
+
|
|
82
|
+
const runner = new SkillRunner({
|
|
83
|
+
verbose: true,
|
|
84
|
+
skipSecurityScans: false,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Listen to execution events
|
|
88
|
+
runner.on('execution:start', (data) => {
|
|
89
|
+
console.log(`Started executing: ${data.skillName}`);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
runner.on('execution:complete', (data) => {
|
|
93
|
+
console.log(`Completed executing: ${data.skillName}`);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
runner.on('execution:error', (data) => {
|
|
97
|
+
console.error(`Error in ${data.executionId}:`, data.error);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Execute with custom options
|
|
101
|
+
const result = await runner.executeSkill(
|
|
102
|
+
'search-master-5x', // From ClawHub registry
|
|
103
|
+
{
|
|
104
|
+
query: 'latest TypeScript frameworks 2026',
|
|
105
|
+
maxResults: 5,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
provider: ModelProvider.OPENAI,
|
|
109
|
+
model: 'gpt-4-turbo',
|
|
110
|
+
streaming: true,
|
|
111
|
+
onChunk: (chunk) => {
|
|
112
|
+
if (chunk.type === 'content') {
|
|
113
|
+
console.log('Streaming:', chunk.content);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
console.log('\nFinal result:', result.outputs);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Example 4: Batch execution
|
|
124
|
+
*/
|
|
125
|
+
async function example4_BatchExecution() {
|
|
126
|
+
console.log('\n=== Example 4: Batch Skill Execution ===\n');
|
|
127
|
+
|
|
128
|
+
const runner = new SkillRunner();
|
|
129
|
+
|
|
130
|
+
const batchResult = await runner.executeBatch({
|
|
131
|
+
skillPath: 'summarizer',
|
|
132
|
+
inputs: [
|
|
133
|
+
{ text: 'Long article 1...', language: 'en' },
|
|
134
|
+
{ text: 'Long article 2...', language: 'en' },
|
|
135
|
+
{ text: 'Long article 3...', language: 'en' },
|
|
136
|
+
],
|
|
137
|
+
options: {
|
|
138
|
+
provider: ModelProvider.ANTHROPIC,
|
|
139
|
+
timeout: 30000,
|
|
140
|
+
},
|
|
141
|
+
continueOnError: true,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
console.log(`Batch completed: ${batchResult.succeeded}/${batchResult.total} succeeded`);
|
|
145
|
+
console.log('Total duration:', batchResult.duration, 'ms');
|
|
146
|
+
|
|
147
|
+
for (const result of batchResult.results) {
|
|
148
|
+
if ('success' in result && result.success) {
|
|
149
|
+
console.log('Success:', result.outputs);
|
|
150
|
+
} else if ('error' in result) {
|
|
151
|
+
console.error('Failed:', result.error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Example 5: Configuration management
|
|
158
|
+
*/
|
|
159
|
+
async function example5_ConfigManagement() {
|
|
160
|
+
console.log('\n=== Example 5: Configuration Management ===\n');
|
|
161
|
+
|
|
162
|
+
const config = getConfig();
|
|
163
|
+
|
|
164
|
+
// Get current config
|
|
165
|
+
const fullConfig = config.getConfig();
|
|
166
|
+
console.log('Current language:', config.getLanguage());
|
|
167
|
+
console.log('Timeout:', config.getTimeout(), 'ms');
|
|
168
|
+
console.log('Security level:', config.getSecurityLevel());
|
|
169
|
+
|
|
170
|
+
// Update settings
|
|
171
|
+
config.setLanguage('es');
|
|
172
|
+
config.setTimeout(45000);
|
|
173
|
+
config.setSecurityLevel('strict');
|
|
174
|
+
|
|
175
|
+
// Custom settings
|
|
176
|
+
config.setCustom('myOrganization', 'ACME Corp');
|
|
177
|
+
config.setCustom('customApiEndpoint', 'https://api.acme.com');
|
|
178
|
+
|
|
179
|
+
console.log('\nUpdated settings:');
|
|
180
|
+
console.log('Language:', config.getLanguage());
|
|
181
|
+
console.log('Organization:', config.getCustom('myOrganization'));
|
|
182
|
+
|
|
183
|
+
// Validate API keys
|
|
184
|
+
const validation = config.validateApiKeys([
|
|
185
|
+
ModelProvider.ANTHROPIC,
|
|
186
|
+
ModelProvider.OPENAI,
|
|
187
|
+
]);
|
|
188
|
+
|
|
189
|
+
console.log('API keys valid:', validation.valid);
|
|
190
|
+
if (!validation.valid) {
|
|
191
|
+
console.log('Missing keys:', validation.missing);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
config.save();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Example 6: Multiple providers
|
|
199
|
+
*/
|
|
200
|
+
async function example6_MultipleProviders() {
|
|
201
|
+
console.log('\n=== Example 6: Multi-Provider Execution ===\n');
|
|
202
|
+
|
|
203
|
+
const runner = new SkillRunner();
|
|
204
|
+
const skillPath = 'content-writer';
|
|
205
|
+
const input = { topic: 'AI trends', wordCount: 500 };
|
|
206
|
+
|
|
207
|
+
const providers = [
|
|
208
|
+
ModelProvider.ANTHROPIC,
|
|
209
|
+
ModelProvider.OPENAI,
|
|
210
|
+
ModelProvider.GOOGLE,
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
const results = await Promise.all(
|
|
214
|
+
providers.map((provider) =>
|
|
215
|
+
runner.executeSkill(skillPath, input, { provider })
|
|
216
|
+
)
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < results.length; i++) {
|
|
220
|
+
const result = results[i];
|
|
221
|
+
console.log(
|
|
222
|
+
`${providers[i]} result:`,
|
|
223
|
+
result.success ? 'Success' : 'Failed'
|
|
224
|
+
);
|
|
225
|
+
console.log(' Duration:', result.duration, 'ms');
|
|
226
|
+
console.log(' Model:', result.modelUsed);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Example 7: Error handling
|
|
232
|
+
*/
|
|
233
|
+
async function example7_ErrorHandling() {
|
|
234
|
+
console.log('\n=== Example 7: Error Handling ===\n');
|
|
235
|
+
|
|
236
|
+
const runner = new SkillRunner();
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
const result = await runner.executeSkill(
|
|
240
|
+
'nonexistent-skill',
|
|
241
|
+
{ foo: 'bar' },
|
|
242
|
+
{ timeout: 5000 }
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
if (!result.success) {
|
|
246
|
+
console.error('Execution failed:');
|
|
247
|
+
console.error(' Status:', result.status);
|
|
248
|
+
console.error(' Error:', result.error);
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.error('Error during execution:', error);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Run all examples
|
|
257
|
+
*/
|
|
258
|
+
async function main() {
|
|
259
|
+
try {
|
|
260
|
+
// Uncomment examples to run
|
|
261
|
+
// await example1_InitializeConfig();
|
|
262
|
+
// await example2_SimpleExecution();
|
|
263
|
+
// await example3_SkillRunnerAdvanced();
|
|
264
|
+
// await example4_BatchExecution();
|
|
265
|
+
// await example5_ConfigManagement();
|
|
266
|
+
// await example6_MultipleProviders();
|
|
267
|
+
// await example7_ErrorHandling();
|
|
268
|
+
|
|
269
|
+
console.log('\nAll examples completed!');
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.error('Fatal error:', error);
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
main();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-reviewer
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
description: Review code for bugs, security issues, performance problems, and best practices
|
|
5
|
+
author: ArtefactForge
|
|
6
|
+
tags: [code-review, security, performance, best-practices, developer-tools]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# System Prompt
|
|
10
|
+
|
|
11
|
+
You are a senior software engineer performing code reviews. You focus on correctness, security, performance, readability, and maintainability. You are direct and constructive — you explain WHY something is a problem and suggest a concrete fix. You never rewrite the entire code unless asked; you point to specific lines and issues.
|
|
12
|
+
|
|
13
|
+
# Instructions
|
|
14
|
+
|
|
15
|
+
1. Read the submitted code carefully
|
|
16
|
+
2. Identify issues in this priority order:
|
|
17
|
+
- **Critical**: Bugs, security vulnerabilities, data loss risks
|
|
18
|
+
- **Warning**: Performance issues, race conditions, memory leaks
|
|
19
|
+
- **Suggestion**: Readability improvements, naming conventions, missing types
|
|
20
|
+
3. For each issue, provide:
|
|
21
|
+
- The problematic line or section
|
|
22
|
+
- What the problem is
|
|
23
|
+
- A suggested fix (code snippet)
|
|
24
|
+
4. End with an overall assessment (APPROVE, REQUEST CHANGES, or BLOCK)
|
|
25
|
+
5. If the code is clean, say so — don't invent problems
|
|
26
|
+
|
|
27
|
+
# Input
|
|
28
|
+
|
|
29
|
+
The user pastes a code snippet or file. Optionally specifies the language and context.
|
|
30
|
+
|
|
31
|
+
# Output Format
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
## Code Review: [filename or description]
|
|
35
|
+
|
|
36
|
+
### Critical Issues
|
|
37
|
+
- **Line X**: [description]
|
|
38
|
+
```suggestion
|
|
39
|
+
// fixed code here
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Warnings
|
|
43
|
+
- **Line X**: [description]
|
|
44
|
+
|
|
45
|
+
### Suggestions
|
|
46
|
+
- **Line X**: [description]
|
|
47
|
+
|
|
48
|
+
### Verdict: [APPROVE | REQUEST CHANGES | BLOCK]
|
|
49
|
+
[One sentence summary]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
# Examples
|
|
53
|
+
|
|
54
|
+
**Input:**
|
|
55
|
+
```javascript
|
|
56
|
+
app.get('/user/:id', (req, res) => {
|
|
57
|
+
const query = `SELECT * FROM users WHERE id = ${req.params.id}`;
|
|
58
|
+
db.query(query, (err, result) => {
|
|
59
|
+
res.json(result);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Output:**
|
|
65
|
+
## Code Review: user endpoint
|
|
66
|
+
|
|
67
|
+
### Critical Issues
|
|
68
|
+
- **Line 2**: SQL injection vulnerability. User input is interpolated directly into query string.
|
|
69
|
+
```suggestion
|
|
70
|
+
const query = 'SELECT * FROM users WHERE id = ?';
|
|
71
|
+
db.query(query, [req.params.id], (err, result) => {
|
|
72
|
+
```
|
|
73
|
+
- **Line 3**: Missing error handling. If `err` is truthy, `result` may be undefined.
|
|
74
|
+
```suggestion
|
|
75
|
+
db.query(query, [req.params.id], (err, result) => {
|
|
76
|
+
if (err) return res.status(500).json({ error: 'Database error' });
|
|
77
|
+
if (!result.length) return res.status(404).json({ error: 'User not found' });
|
|
78
|
+
res.json(result[0]);
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Verdict: BLOCK
|
|
83
|
+
SQL injection vulnerability must be fixed before merge.
|