devchain-cli 0.8.5 → 0.9.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/dist/drizzle/0038_soft_texas_twister.sql +51 -0
- package/dist/drizzle/0039_early_the_spike.sql +1 -0
- package/dist/drizzle/0040_typical_mole_man.sql +3 -0
- package/dist/drizzle/meta/0037_snapshot.json +3670 -0
- package/dist/drizzle/meta/0038_snapshot.json +4019 -0
- package/dist/drizzle/meta/0039_snapshot.json +4026 -0
- package/dist/drizzle/meta/0040_snapshot.json +4028 -0
- package/dist/drizzle/meta/_journal.json +22 -1
- package/dist/server/app.module.js +2 -0
- package/dist/server/app.module.js.map +1 -1
- package/dist/server/modules/epics/controllers/epics.controller.js +4 -0
- package/dist/server/modules/epics/controllers/epics.controller.js.map +1 -1
- package/dist/server/modules/mcp/dtos/mcp.dto.d.ts +74 -0
- package/dist/server/modules/mcp/dtos/mcp.dto.js +18 -1
- package/dist/server/modules/mcp/dtos/mcp.dto.js.map +1 -1
- package/dist/server/modules/mcp/dtos/schema-registry.js +2 -0
- package/dist/server/modules/mcp/dtos/schema-registry.js.map +1 -1
- package/dist/server/modules/mcp/mcp.module.js +2 -0
- package/dist/server/modules/mcp/mcp.module.js.map +1 -1
- package/dist/server/modules/mcp/services/mcp.service.d.ts +7 -1
- package/dist/server/modules/mcp/services/mcp.service.js +126 -2
- package/dist/server/modules/mcp/services/mcp.service.js.map +1 -1
- package/dist/server/modules/mcp/tool-definitions.d.ts +177 -0
- package/dist/server/modules/mcp/tool-definitions.js +48 -0
- package/dist/server/modules/mcp/tool-definitions.js.map +1 -1
- package/dist/server/modules/projects/dtos/export.dto.d.ts +15 -15
- package/dist/server/modules/seeders/seeders/0002_seed_replace_permission_mode_plan.d.ts +3 -0
- package/dist/server/modules/seeders/seeders/0002_seed_replace_permission_mode_plan.js +45 -0
- package/dist/server/modules/seeders/seeders/0002_seed_replace_permission_mode_plan.js.map +1 -0
- package/dist/server/modules/seeders/services/data-seeder.service.js +5 -1
- package/dist/server/modules/seeders/services/data-seeder.service.js.map +1 -1
- package/dist/server/modules/settings/dtos/settings.dto.d.ts +18 -0
- package/dist/server/modules/settings/dtos/settings.dto.js +5 -0
- package/dist/server/modules/settings/dtos/settings.dto.js.map +1 -1
- package/dist/server/modules/settings/services/settings.service.d.ts +5 -0
- package/dist/server/modules/settings/services/settings.service.js +80 -1
- package/dist/server/modules/settings/services/settings.service.js.map +1 -1
- package/dist/server/modules/skills/adapters/anthropic-skill-source.adapter.d.ts +9 -0
- package/dist/server/modules/skills/adapters/anthropic-skill-source.adapter.js +169 -0
- package/dist/server/modules/skills/adapters/anthropic-skill-source.adapter.js.map +1 -0
- package/dist/server/modules/skills/adapters/github-skill-source.base.d.ts +48 -0
- package/dist/server/modules/skills/adapters/github-skill-source.base.js +382 -0
- package/dist/server/modules/skills/adapters/github-skill-source.base.js.map +1 -0
- package/dist/server/modules/skills/adapters/microsoft-skill-source.adapter.d.ts +11 -0
- package/dist/server/modules/skills/adapters/microsoft-skill-source.adapter.js +227 -0
- package/dist/server/modules/skills/adapters/microsoft-skill-source.adapter.js.map +1 -0
- package/dist/server/modules/skills/adapters/openai-skill-source.adapter.d.ts +13 -0
- package/dist/server/modules/skills/adapters/openai-skill-source.adapter.js +260 -0
- package/dist/server/modules/skills/adapters/openai-skill-source.adapter.js.map +1 -0
- package/dist/server/modules/skills/adapters/skill-source.adapter.d.ts +26 -0
- package/dist/server/modules/skills/adapters/skill-source.adapter.js +5 -0
- package/dist/server/modules/skills/adapters/skill-source.adapter.js.map +1 -0
- package/dist/server/modules/skills/adapters/trailofbits-skill-source.adapter.d.ts +14 -0
- package/dist/server/modules/skills/adapters/trailofbits-skill-source.adapter.js +253 -0
- package/dist/server/modules/skills/adapters/trailofbits-skill-source.adapter.js.map +1 -0
- package/dist/server/modules/skills/adapters/vercel-skill-source.adapter.d.ts +15 -0
- package/dist/server/modules/skills/adapters/vercel-skill-source.adapter.js +292 -0
- package/dist/server/modules/skills/adapters/vercel-skill-source.adapter.js.map +1 -0
- package/dist/server/modules/skills/controllers/skills.controller.d.ts +42 -0
- package/dist/server/modules/skills/controllers/skills.controller.js +257 -0
- package/dist/server/modules/skills/controllers/skills.controller.js.map +1 -0
- package/dist/server/modules/skills/dtos/skill.dto.d.ts +169 -0
- package/dist/server/modules/skills/dtos/skill.dto.js +116 -0
- package/dist/server/modules/skills/dtos/skill.dto.js.map +1 -0
- package/dist/server/modules/skills/services/skill-category.service.d.ts +5 -0
- package/dist/server/modules/skills/services/skill-category.service.js +155 -0
- package/dist/server/modules/skills/services/skill-category.service.js.map +1 -0
- package/dist/server/modules/skills/services/skill-sync.service.d.ts +38 -0
- package/dist/server/modules/skills/services/skill-sync.service.js +283 -0
- package/dist/server/modules/skills/services/skill-sync.service.js.map +1 -0
- package/dist/server/modules/skills/services/skills.service.d.ts +119 -0
- package/dist/server/modules/skills/services/skills.service.js +731 -0
- package/dist/server/modules/skills/services/skills.service.js.map +1 -0
- package/dist/server/modules/skills/skills.module.d.ts +2 -0
- package/dist/server/modules/skills/skills.module.js +70 -0
- package/dist/server/modules/skills/skills.module.js.map +1 -0
- package/dist/server/modules/storage/db/schema.d.ts +629 -0
- package/dist/server/modules/storage/db/schema.js +56 -1
- package/dist/server/modules/storage/db/schema.js.map +1 -1
- package/dist/server/modules/storage/interfaces/storage.interface.d.ts +1 -0
- package/dist/server/modules/storage/interfaces/storage.interface.js.map +1 -1
- package/dist/server/modules/storage/local/local-storage.service.d.ts +2 -0
- package/dist/server/modules/storage/local/local-storage.service.js +50 -7
- package/dist/server/modules/storage/local/local-storage.service.js.map +1 -1
- package/dist/server/modules/storage/models/domain.models.d.ts +47 -1
- package/dist/server/templates/dev-loop.json +85 -78
- package/dist/server/tsconfig.tsbuildinfo +1 -1
- package/dist/server/ui/assets/{ReviewDetailPage-DNZbiwkx.js → ReviewDetailPage-D_-bS1MK.js} +1 -1
- package/dist/server/ui/assets/{ReviewsPage-Dow8B8sr.js → ReviewsPage-BE1gxYlC.js} +1 -1
- package/dist/server/ui/assets/index-C094CE5I.js +945 -0
- package/dist/server/ui/assets/index-CbtpBUHu.css +32 -0
- package/dist/server/ui/assets/useReviewSubscription-Bs-17h-m.js +77 -0
- package/dist/server/ui/index.html +2 -2
- package/dist/templates/dev-loop.json +85 -78
- package/package.json +14 -1
- package/dist/server/ui/assets/index--HtPKe24.js +0 -914
- package/dist/server/ui/assets/index-BkiWahA0.css +0 -32
- package/dist/server/ui/assets/useReviewSubscription-CNhZ4Xwh.js +0 -83
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SkillCategoryService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const CATEGORY_RULES = [
|
|
12
|
+
{
|
|
13
|
+
category: 'security',
|
|
14
|
+
patterns: [
|
|
15
|
+
/\bsecurity\b/,
|
|
16
|
+
/\bsecure\b/,
|
|
17
|
+
/\bowasp\b/,
|
|
18
|
+
/\bvulnerab(?:ility|ilities)\b/,
|
|
19
|
+
/\bauth(?:entication|orization)?\b/,
|
|
20
|
+
/\bencrypt(?:ion|ed)?\b/,
|
|
21
|
+
/\bthreat\b/,
|
|
22
|
+
/\bcve\b/,
|
|
23
|
+
/\bcsrf\b/,
|
|
24
|
+
/\bxss\b/,
|
|
25
|
+
/\bcompliance\b/,
|
|
26
|
+
/\bsecret(?:s)?\b/,
|
|
27
|
+
/\b(?:pen(?:etration)?|pentest)\b/,
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
category: 'testing',
|
|
32
|
+
patterns: [
|
|
33
|
+
/\btest(?:ing|s)?\b/,
|
|
34
|
+
/\bspec(?:s)?\b/,
|
|
35
|
+
/\bcoverage\b/,
|
|
36
|
+
/\bmock(?:ing|s)?\b/,
|
|
37
|
+
/\bfixture(?:s)?\b/,
|
|
38
|
+
/\bqa\b/,
|
|
39
|
+
/\bassert(?:ion|ions)?\b/,
|
|
40
|
+
/\be2e\b/,
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
category: 'deployment',
|
|
45
|
+
patterns: [
|
|
46
|
+
/\bdeploy(?:ment|ing)?\b/,
|
|
47
|
+
/\brelease\b/,
|
|
48
|
+
/\brollout\b/,
|
|
49
|
+
/\bkubernetes\b/,
|
|
50
|
+
/\bk8s\b/,
|
|
51
|
+
/\bdocker\b/,
|
|
52
|
+
/\bterraform\b/,
|
|
53
|
+
/\bci\/cd\b/,
|
|
54
|
+
/\bpipeline(?:s)?\b/,
|
|
55
|
+
/\bhosting\b/,
|
|
56
|
+
/\bcloudflare\b/,
|
|
57
|
+
/\bvercel\b/,
|
|
58
|
+
/\bnetlify\b/,
|
|
59
|
+
/\brender\b/,
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
category: 'documents',
|
|
64
|
+
patterns: [
|
|
65
|
+
/\bdocs?\b/,
|
|
66
|
+
/\bdocument(?:ation|s)?\b/,
|
|
67
|
+
/\breadme\b/,
|
|
68
|
+
/\bknowledge\b/,
|
|
69
|
+
/\bnotion\b/,
|
|
70
|
+
/\bconfluence\b/,
|
|
71
|
+
/\bpdf\b/,
|
|
72
|
+
/\bspreadsheet(?:s)?\b/,
|
|
73
|
+
/\breport(?:s)?\b/,
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
category: 'design',
|
|
78
|
+
patterns: [
|
|
79
|
+
/\bdesign\b/,
|
|
80
|
+
/\bfigma\b/,
|
|
81
|
+
/\bprototype(?:s)?\b/,
|
|
82
|
+
/\bwireframe(?:s)?\b/,
|
|
83
|
+
/\bui\b/,
|
|
84
|
+
/\bux\b/,
|
|
85
|
+
/\bstyle\s*guide\b/,
|
|
86
|
+
/\bvisual\b/,
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
category: 'integration',
|
|
91
|
+
patterns: [
|
|
92
|
+
/\bintegration(?:s)?\b/,
|
|
93
|
+
/\bapi(?:s)?\b/,
|
|
94
|
+
/\bwebhook(?:s)?\b/,
|
|
95
|
+
/\bconnector(?:s)?\b/,
|
|
96
|
+
/\bmcp\b/,
|
|
97
|
+
/\bsdk(?:s)?\b/,
|
|
98
|
+
/\bplugin(?:s)?\b/,
|
|
99
|
+
/\bthird[- ]party\b/,
|
|
100
|
+
/\bsync\b/,
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
category: 'creative',
|
|
105
|
+
patterns: [
|
|
106
|
+
/\bcreative\b/,
|
|
107
|
+
/\bimage(?:gen)?\b/,
|
|
108
|
+
/\bvideo\b/,
|
|
109
|
+
/\baudio\b/,
|
|
110
|
+
/\bmusic\b/,
|
|
111
|
+
/\bstory\b/,
|
|
112
|
+
/\billustration\b/,
|
|
113
|
+
/\bart\b/,
|
|
114
|
+
/\bsora\b/,
|
|
115
|
+
/\bspeech\b/,
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
category: 'communication',
|
|
120
|
+
patterns: [
|
|
121
|
+
/\bcommunicat(?:e|ion)\b/,
|
|
122
|
+
/\bemail\b/,
|
|
123
|
+
/\bmessage(?:s)?\b/,
|
|
124
|
+
/\bchat\b/,
|
|
125
|
+
/\bslack\b/,
|
|
126
|
+
/\bteams\b/,
|
|
127
|
+
/\bmeeting(?:s)?\b/,
|
|
128
|
+
/\bpresentation(?:s)?\b/,
|
|
129
|
+
/\btranscribe\b/,
|
|
130
|
+
/\bsummar(?:ize|y)\b/,
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
let SkillCategoryService = class SkillCategoryService {
|
|
135
|
+
deriveCategory(name, description, compatibility) {
|
|
136
|
+
const haystack = this.buildSearchText(name, description, compatibility);
|
|
137
|
+
for (const rule of CATEGORY_RULES) {
|
|
138
|
+
if (rule.patterns.some((pattern) => pattern.test(haystack))) {
|
|
139
|
+
return rule.category;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return 'development';
|
|
143
|
+
}
|
|
144
|
+
buildSearchText(name, description, compatibility) {
|
|
145
|
+
return [name, description, compatibility]
|
|
146
|
+
.map((value) => (typeof value === 'string' ? value.trim().toLowerCase() : ''))
|
|
147
|
+
.filter((value) => value.length > 0)
|
|
148
|
+
.join(' ');
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
exports.SkillCategoryService = SkillCategoryService;
|
|
152
|
+
exports.SkillCategoryService = SkillCategoryService = __decorate([
|
|
153
|
+
(0, common_1.Injectable)()
|
|
154
|
+
], SkillCategoryService);
|
|
155
|
+
//# sourceMappingURL=skill-category.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-category.service.js","sourceRoot":"","sources":["../../../../src/modules/skills/services/skill-category.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAkB5C,MAAM,cAAc,GAA4B;IAC9C;QACE,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE;YACR,cAAc;YACd,YAAY;YACZ,WAAW;YACX,+BAA+B;YAC/B,mCAAmC;YACnC,wBAAwB;YACxB,YAAY;YACZ,SAAS;YACT,UAAU;YACV,SAAS;YACT,gBAAgB;YAChB,kBAAkB;YAClB,kCAAkC;SACnC;KACF;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;YAChB,qBAAqB;SACtB;KACF;CACO,CAAC;AAGJ,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,cAAc,CACZ,IAAoB,EACpB,WAA2B,EAC3B,aAA6B;QAE7B,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;QAExE,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;gBAC5D,OAAO,IAAI,CAAC,QAAQ,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;IAEO,eAAe,CACrB,IAAoB,EACpB,WAA2B,EAC3B,aAA6B;QAE7B,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC;aACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aAC7E,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;aACnC,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF,CAAA;AA3BY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;GACA,oBAAoB,CA2BhC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
+
import { SettingsService } from '../../settings/services/settings.service';
|
|
3
|
+
import { SkillSourceAdapter } from '../adapters/skill-source.adapter';
|
|
4
|
+
import { SkillCategoryService } from './skill-category.service';
|
|
5
|
+
import { SkillsService } from './skills.service';
|
|
6
|
+
export interface SyncError {
|
|
7
|
+
sourceName: string;
|
|
8
|
+
skillSlug?: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SyncResult {
|
|
12
|
+
status: 'completed' | 'already_running';
|
|
13
|
+
added: number;
|
|
14
|
+
updated: number;
|
|
15
|
+
failed: number;
|
|
16
|
+
unchanged: number;
|
|
17
|
+
errors: SyncError[];
|
|
18
|
+
}
|
|
19
|
+
export declare class SkillSyncService implements OnApplicationBootstrap {
|
|
20
|
+
private readonly adapters;
|
|
21
|
+
private readonly skillsService;
|
|
22
|
+
private readonly skillCategoryService;
|
|
23
|
+
private readonly settingsService;
|
|
24
|
+
private syncInProgress;
|
|
25
|
+
constructor(adapters: SkillSourceAdapter[], skillsService: SkillsService, skillCategoryService: SkillCategoryService, settingsService: SettingsService);
|
|
26
|
+
onApplicationBootstrap(): void;
|
|
27
|
+
syncAll(): Promise<SyncResult>;
|
|
28
|
+
syncSource(sourceName: string): Promise<SyncResult>;
|
|
29
|
+
private withMutex;
|
|
30
|
+
private syncAdapter;
|
|
31
|
+
private markSkillSyncError;
|
|
32
|
+
private buildSkillSlug;
|
|
33
|
+
private getExistingSkill;
|
|
34
|
+
private createEmptyResult;
|
|
35
|
+
private createAlreadyRunningResult;
|
|
36
|
+
private mergeSyncResults;
|
|
37
|
+
private isSourceEnabled;
|
|
38
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SkillSyncService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const error_types_1 = require("../../../common/errors/error-types");
|
|
18
|
+
const logger_1 = require("../../../common/logging/logger");
|
|
19
|
+
const settings_service_1 = require("../../settings/services/settings.service");
|
|
20
|
+
const skill_source_adapter_1 = require("../adapters/skill-source.adapter");
|
|
21
|
+
const skill_category_service_1 = require("./skill-category.service");
|
|
22
|
+
const skills_service_1 = require("./skills.service");
|
|
23
|
+
const logger = (0, logger_1.createLogger)('SkillSyncService');
|
|
24
|
+
let SkillSyncService = class SkillSyncService {
|
|
25
|
+
constructor(adapters, skillsService, skillCategoryService, settingsService) {
|
|
26
|
+
this.adapters = adapters;
|
|
27
|
+
this.skillsService = skillsService;
|
|
28
|
+
this.skillCategoryService = skillCategoryService;
|
|
29
|
+
this.settingsService = settingsService;
|
|
30
|
+
this.syncInProgress = false;
|
|
31
|
+
}
|
|
32
|
+
onApplicationBootstrap() {
|
|
33
|
+
if (!this.settingsService.getSkillsSyncOnStartup()) {
|
|
34
|
+
logger.info('Startup skills sync disabled via settings');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
void this.syncAll().catch((error) => {
|
|
38
|
+
logger.error({ error: error instanceof Error ? error.message : String(error) }, 'Startup skills sync failed');
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async syncAll() {
|
|
42
|
+
return this.withMutex(async () => {
|
|
43
|
+
const sourceSettings = this.settingsService.getSkillSourcesEnabled();
|
|
44
|
+
const enabledAdapters = this.adapters.filter((adapter) => this.isSourceEnabled(adapter.sourceName, sourceSettings));
|
|
45
|
+
for (const adapter of this.adapters) {
|
|
46
|
+
if (!this.isSourceEnabled(adapter.sourceName, sourceSettings)) {
|
|
47
|
+
logger.info({ sourceName: adapter.sourceName }, 'Skill sync skipped because source is disabled');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (enabledAdapters.length === 0) {
|
|
51
|
+
return this.createEmptyResult();
|
|
52
|
+
}
|
|
53
|
+
const settledResults = await Promise.allSettled(enabledAdapters.map((adapter) => this.syncAdapter(adapter)));
|
|
54
|
+
return settledResults.reduce((acc, result, index) => {
|
|
55
|
+
if (result.status === 'fulfilled') {
|
|
56
|
+
return this.mergeSyncResults(acc, result.value);
|
|
57
|
+
}
|
|
58
|
+
const adapterName = enabledAdapters[index]?.sourceName ?? 'unknown';
|
|
59
|
+
acc.failed += 1;
|
|
60
|
+
acc.errors.push({
|
|
61
|
+
sourceName: adapterName,
|
|
62
|
+
message: result.reason instanceof Error ? result.reason.message : String(result.reason),
|
|
63
|
+
});
|
|
64
|
+
return acc;
|
|
65
|
+
}, this.createEmptyResult());
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async syncSource(sourceName) {
|
|
69
|
+
const normalizedSourceName = sourceName.trim().toLowerCase();
|
|
70
|
+
const adapter = this.adapters.find((item) => item.sourceName === normalizedSourceName);
|
|
71
|
+
if (!adapter) {
|
|
72
|
+
throw new error_types_1.ValidationError(`Unknown skill source: ${normalizedSourceName}`, {
|
|
73
|
+
sourceName: normalizedSourceName,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (!this.isSourceEnabled(normalizedSourceName, this.settingsService.getSkillSourcesEnabled())) {
|
|
77
|
+
logger.info({ sourceName: normalizedSourceName }, 'Skill sync skipped because source is disabled');
|
|
78
|
+
return this.createEmptyResult();
|
|
79
|
+
}
|
|
80
|
+
return this.withMutex(() => this.syncAdapter(adapter));
|
|
81
|
+
}
|
|
82
|
+
async withMutex(run) {
|
|
83
|
+
if (this.syncInProgress) {
|
|
84
|
+
logger.info('Skill sync skipped because another sync is already running');
|
|
85
|
+
return this.createAlreadyRunningResult();
|
|
86
|
+
}
|
|
87
|
+
this.syncInProgress = true;
|
|
88
|
+
try {
|
|
89
|
+
return await run();
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
this.syncInProgress = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async syncAdapter(adapter) {
|
|
96
|
+
const result = this.createEmptyResult();
|
|
97
|
+
let sourceCommit = '';
|
|
98
|
+
let syncContext = null;
|
|
99
|
+
try {
|
|
100
|
+
sourceCommit = await adapter.getLatestCommit();
|
|
101
|
+
syncContext = await adapter.createSyncContext();
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (syncContext) {
|
|
105
|
+
try {
|
|
106
|
+
await syncContext.dispose();
|
|
107
|
+
}
|
|
108
|
+
catch (disposeError) {
|
|
109
|
+
logger.warn({
|
|
110
|
+
sourceName: adapter.sourceName,
|
|
111
|
+
error: disposeError instanceof Error ? disposeError.message : String(disposeError),
|
|
112
|
+
}, 'Failed to dispose skill sync context after setup failure');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
result.failed += 1;
|
|
116
|
+
result.errors.push({
|
|
117
|
+
sourceName: adapter.sourceName,
|
|
118
|
+
message: error instanceof Error ? error.message : String(error),
|
|
119
|
+
});
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
if (!syncContext) {
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
for (const [skillName, manifest] of syncContext.manifests.entries()) {
|
|
127
|
+
const skillSlug = this.buildSkillSlug(adapter.sourceName, skillName);
|
|
128
|
+
const existingSkill = await this.getExistingSkill(skillSlug);
|
|
129
|
+
const isUnchanged = existingSkill &&
|
|
130
|
+
existingSkill.sourceCommit === sourceCommit &&
|
|
131
|
+
existingSkill.status !== 'sync_error';
|
|
132
|
+
if (isUnchanged) {
|
|
133
|
+
result.unchanged += 1;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const contentPath = await syncContext.downloadSkill(skillName, '');
|
|
138
|
+
await this.skillsService.upsertSkill(skillSlug, {
|
|
139
|
+
name: manifest.name || skillName,
|
|
140
|
+
displayName: manifest.displayName ?? manifest.name ?? skillName,
|
|
141
|
+
description: manifest.description,
|
|
142
|
+
shortDescription: manifest.shortDescription ?? null,
|
|
143
|
+
source: adapter.sourceName,
|
|
144
|
+
sourceUrl: manifest.sourceUrl,
|
|
145
|
+
sourceCommit,
|
|
146
|
+
category: this.skillCategoryService.deriveCategory(manifest.name || skillName, manifest.description, manifest.compatibility),
|
|
147
|
+
license: manifest.license ?? null,
|
|
148
|
+
compatibility: manifest.compatibility ?? null,
|
|
149
|
+
frontmatter: manifest.frontmatter ?? {},
|
|
150
|
+
instructionContent: manifest.instructionContent,
|
|
151
|
+
contentPath,
|
|
152
|
+
resources: manifest.resources,
|
|
153
|
+
status: 'available',
|
|
154
|
+
lastSyncedAt: new Date().toISOString(),
|
|
155
|
+
});
|
|
156
|
+
if (existingSkill) {
|
|
157
|
+
result.updated += 1;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
result.added += 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
result.failed += 1;
|
|
165
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
166
|
+
result.errors.push({
|
|
167
|
+
sourceName: adapter.sourceName,
|
|
168
|
+
skillSlug,
|
|
169
|
+
message: errorMessage,
|
|
170
|
+
});
|
|
171
|
+
await this.markSkillSyncError({
|
|
172
|
+
adapter,
|
|
173
|
+
skillName,
|
|
174
|
+
skillSlug,
|
|
175
|
+
sourceCommit,
|
|
176
|
+
manifest,
|
|
177
|
+
});
|
|
178
|
+
if (error instanceof error_types_1.TimeoutError) {
|
|
179
|
+
logger.warn({ sourceName: adapter.sourceName, skillSlug, error: error.message }, 'Skill download timed out; skill marked as sync_error');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
finally {
|
|
185
|
+
try {
|
|
186
|
+
await syncContext.dispose();
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
logger.warn({
|
|
190
|
+
sourceName: adapter.sourceName,
|
|
191
|
+
error: error instanceof Error ? error.message : String(error),
|
|
192
|
+
}, 'Failed to dispose skill sync context');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
async markSkillSyncError(params) {
|
|
198
|
+
try {
|
|
199
|
+
await this.skillsService.upsertSkill(params.skillSlug, {
|
|
200
|
+
name: params.manifest.name || params.skillName,
|
|
201
|
+
displayName: params.manifest.displayName ?? params.manifest.name ?? params.skillName,
|
|
202
|
+
description: params.manifest.description,
|
|
203
|
+
shortDescription: params.manifest.shortDescription ?? null,
|
|
204
|
+
source: params.adapter.sourceName,
|
|
205
|
+
sourceUrl: params.manifest.sourceUrl,
|
|
206
|
+
sourceCommit: params.sourceCommit,
|
|
207
|
+
category: this.skillCategoryService.deriveCategory(params.manifest.name || params.skillName, params.manifest.description, params.manifest.compatibility),
|
|
208
|
+
license: params.manifest.license ?? null,
|
|
209
|
+
compatibility: params.manifest.compatibility ?? null,
|
|
210
|
+
frontmatter: params.manifest.frontmatter ?? {},
|
|
211
|
+
instructionContent: params.manifest.instructionContent,
|
|
212
|
+
resources: params.manifest.resources,
|
|
213
|
+
status: 'sync_error',
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
logger.error({
|
|
218
|
+
sourceName: params.adapter.sourceName,
|
|
219
|
+
skillSlug: params.skillSlug,
|
|
220
|
+
error: error instanceof Error ? error.message : String(error),
|
|
221
|
+
}, 'Failed to mark skill as sync_error after sync failure');
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
buildSkillSlug(sourceName, skillName) {
|
|
225
|
+
const normalizedSource = sourceName.trim().toLowerCase();
|
|
226
|
+
const normalizedSkill = skillName.trim().toLowerCase();
|
|
227
|
+
return `${normalizedSource}/${normalizedSkill}`;
|
|
228
|
+
}
|
|
229
|
+
async getExistingSkill(slug) {
|
|
230
|
+
try {
|
|
231
|
+
return await this.skillsService.getSkillBySlug(slug);
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
if (error instanceof error_types_1.NotFoundError) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
createEmptyResult() {
|
|
241
|
+
return {
|
|
242
|
+
status: 'completed',
|
|
243
|
+
added: 0,
|
|
244
|
+
updated: 0,
|
|
245
|
+
failed: 0,
|
|
246
|
+
unchanged: 0,
|
|
247
|
+
errors: [],
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
createAlreadyRunningResult() {
|
|
251
|
+
return {
|
|
252
|
+
status: 'already_running',
|
|
253
|
+
added: 0,
|
|
254
|
+
updated: 0,
|
|
255
|
+
failed: 0,
|
|
256
|
+
unchanged: 0,
|
|
257
|
+
errors: [],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
mergeSyncResults(left, right) {
|
|
261
|
+
return {
|
|
262
|
+
status: 'completed',
|
|
263
|
+
added: left.added + right.added,
|
|
264
|
+
updated: left.updated + right.updated,
|
|
265
|
+
failed: left.failed + right.failed,
|
|
266
|
+
unchanged: left.unchanged + right.unchanged,
|
|
267
|
+
errors: [...left.errors, ...right.errors],
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
isSourceEnabled(sourceName, sourceSettings) {
|
|
271
|
+
const normalizedSourceName = sourceName.trim().toLowerCase();
|
|
272
|
+
return sourceSettings[normalizedSourceName] !== false;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
exports.SkillSyncService = SkillSyncService;
|
|
276
|
+
exports.SkillSyncService = SkillSyncService = __decorate([
|
|
277
|
+
(0, common_1.Injectable)(),
|
|
278
|
+
__param(0, (0, common_1.Inject)(skill_source_adapter_1.SKILL_SOURCE_ADAPTERS)),
|
|
279
|
+
__metadata("design:paramtypes", [Array, skills_service_1.SkillsService,
|
|
280
|
+
skill_category_service_1.SkillCategoryService,
|
|
281
|
+
settings_service_1.SettingsService])
|
|
282
|
+
], SkillSyncService);
|
|
283
|
+
//# sourceMappingURL=skill-sync.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-sync.service.js","sourceRoot":"","sources":["../../../../src/modules/skills/services/skill-sync.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4E;AAC5E,oEAAkG;AAClG,2DAA8D;AAC9D,+EAA2E;AAC3E,2EAK0C;AAE1C,qEAAgE;AAChE,qDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAC;AAkBzC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG3B,YACiC,QAA+C,EAC7D,aAA4B,EAC5B,oBAA0C,EAC1C,eAAgC;QAHD,aAAQ,GAAR,QAAQ,CAAsB;QAC7D,kBAAa,GAAb,aAAa,CAAe;QAC5B,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,oBAAe,GAAf,eAAe,CAAiB;QAN3C,mBAAc,GAAG,KAAK,CAAC;IAO5B,CAAC;IAEJ,sBAAsB;QACpB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnD,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;YACzD,OAAO;QACT,CAAC;QAED,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAClC,MAAM,CAAC,KAAK,CACV,E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
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
import { SettingsService } from '../../settings/services/settings.service';
|
|
3
|
+
import type { ResolvedSkillSummary } from '../dtos/skill.dto';
|
|
4
|
+
import type { Skill, SkillStatus, SkillUsageLog as SkillUsageLogModel } from '../../storage/models/domain.models';
|
|
5
|
+
import { SkillSourceAdapter } from '../adapters/skill-source.adapter';
|
|
6
|
+
export interface ListSkillsOptions {
|
|
7
|
+
source?: string;
|
|
8
|
+
category?: string;
|
|
9
|
+
status?: SkillStatus;
|
|
10
|
+
q?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ListProjectSkillsOptions {
|
|
13
|
+
q?: string;
|
|
14
|
+
source?: string;
|
|
15
|
+
category?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ProjectSkill extends Skill {
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface UpsertSkillData {
|
|
21
|
+
name?: string;
|
|
22
|
+
displayName?: string;
|
|
23
|
+
description?: string | null;
|
|
24
|
+
shortDescription?: string | null;
|
|
25
|
+
source?: string;
|
|
26
|
+
sourceUrl?: string | null;
|
|
27
|
+
sourceCommit?: string | null;
|
|
28
|
+
category?: string | null;
|
|
29
|
+
license?: string | null;
|
|
30
|
+
compatibility?: string | null;
|
|
31
|
+
frontmatter?: Record<string, unknown> | null;
|
|
32
|
+
instructionContent?: string | null;
|
|
33
|
+
contentPath?: string | null;
|
|
34
|
+
resources?: string[];
|
|
35
|
+
status?: SkillStatus;
|
|
36
|
+
lastSyncedAt?: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface SkillUsageStatsOptions {
|
|
39
|
+
projectId?: string | null;
|
|
40
|
+
from?: string;
|
|
41
|
+
to?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
offset?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface SkillUsageStat {
|
|
46
|
+
skillId: string;
|
|
47
|
+
skillSlug: string;
|
|
48
|
+
usageCount: number;
|
|
49
|
+
firstAccessedAt: string | null;
|
|
50
|
+
lastAccessedAt: string | null;
|
|
51
|
+
skillName: string | null;
|
|
52
|
+
skillDisplayName: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface SkillUsageLogOptions {
|
|
55
|
+
projectId?: string;
|
|
56
|
+
skillId?: string;
|
|
57
|
+
agentId?: string;
|
|
58
|
+
from?: string;
|
|
59
|
+
to?: string;
|
|
60
|
+
limit?: number;
|
|
61
|
+
offset?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface SkillUsageLogListResult {
|
|
64
|
+
items: SkillUsageLogModel[];
|
|
65
|
+
total: number;
|
|
66
|
+
limit: number;
|
|
67
|
+
offset: number;
|
|
68
|
+
}
|
|
69
|
+
export interface SkillSourceMetadata {
|
|
70
|
+
name: string;
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
repoUrl: string;
|
|
73
|
+
skillCount: number;
|
|
74
|
+
}
|
|
75
|
+
export declare class SkillsService {
|
|
76
|
+
private readonly db;
|
|
77
|
+
private readonly settingsService;
|
|
78
|
+
private readonly adapters;
|
|
79
|
+
constructor(db: BetterSQLite3Database, settingsService: SettingsService, adapters: SkillSourceAdapter[]);
|
|
80
|
+
listSkills(options?: ListSkillsOptions): Promise<Skill[]>;
|
|
81
|
+
listAllForProject(projectId: string, options?: ListProjectSkillsOptions): Promise<ProjectSkill[]>;
|
|
82
|
+
listDiscoverable(projectId: string, options?: ListProjectSkillsOptions): Promise<Skill[]>;
|
|
83
|
+
getSkill(id: string): Promise<Skill>;
|
|
84
|
+
getSkillBySlug(slug: string): Promise<Skill>;
|
|
85
|
+
resolveSkillSummariesBySlugs(slugsToResolve: string[]): Promise<Record<string, ResolvedSkillSummary>>;
|
|
86
|
+
upsertSkill(slug: string, data: UpsertSkillData): Promise<Skill>;
|
|
87
|
+
disableSkill(projectId: string, skillId: string): Promise<void>;
|
|
88
|
+
enableSkill(projectId: string, skillId: string): Promise<void>;
|
|
89
|
+
listDisabled(projectId: string): Promise<string[]>;
|
|
90
|
+
disableAll(projectId: string): Promise<number>;
|
|
91
|
+
enableAll(projectId: string): Promise<number>;
|
|
92
|
+
listSources(): Promise<SkillSourceMetadata[]>;
|
|
93
|
+
setSourceEnabled(sourceName: string, enabled: boolean): Promise<{
|
|
94
|
+
name: string;
|
|
95
|
+
enabled: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
logUsage(skillId: string, skillSlug: string, projectId?: string | null, agentId?: string | null, agentNameSnapshot?: string | null): Promise<SkillUsageLogModel>;
|
|
98
|
+
getUsageStats(options?: SkillUsageStatsOptions): Promise<SkillUsageStat[]>;
|
|
99
|
+
listUsageLog(options?: SkillUsageLogOptions): Promise<SkillUsageLogListResult>;
|
|
100
|
+
private appendProjectSkillFilterConditions;
|
|
101
|
+
private mapSkillRow;
|
|
102
|
+
private parseJsonObject;
|
|
103
|
+
private parseResources;
|
|
104
|
+
private serializeJsonObject;
|
|
105
|
+
private serializeResources;
|
|
106
|
+
private validateStatus;
|
|
107
|
+
private parseStatus;
|
|
108
|
+
private normalizeNullableString;
|
|
109
|
+
private requireNonEmpty;
|
|
110
|
+
private combineConditions;
|
|
111
|
+
private getRegisteredSources;
|
|
112
|
+
private getEnabledSources;
|
|
113
|
+
private isSourceEnabled;
|
|
114
|
+
private requireKnownSourceName;
|
|
115
|
+
private isUniqueConstraintError;
|
|
116
|
+
private isForeignKeyConstraintError;
|
|
117
|
+
private readErrorCode;
|
|
118
|
+
private readErrorMessage;
|
|
119
|
+
}
|