dsh-desktop-kit 0.0.0-stage → 2.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 +152 -2
- package/client.js +4101 -0
- package/cordis.patch.yml +5 -0
- package/docs/ARCHITECTURE.md +114 -0
- package/docs/COMPATIBILITY.md +61 -0
- package/docs/INSTALL.md +84 -0
- package/docs/PRIVACY.md +50 -0
- package/docs/ROADMAP.md +57 -0
- package/docs/TOKENS.md +118 -0
- package/docs/TROUBLESHOOTING.md +68 -0
- package/docs/images/hero.png +0 -0
- package/index.js +84 -0
- package/package.json +70 -4
- package/plugins/dsh-gkb-ru-ui/cordis.patch.yml +6 -0
- package/plugins/dsh-gkb-ru-ui/lib/client.js +1331 -0
- package/plugins/dsh-gkb-ru-ui/lib/index.js +186 -0
- package/plugins/dsh-gkb-ru-ui/lib/skills.js +570 -0
- package/plugins/dsh-gkb-ru-ui/package.json +28 -0
- package/plugins/dsh-gkb-ru-ui/screenshots/01-home-tiles-1440-light.png +0 -0
- package/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png +0 -0
- package/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png +0 -0
- package/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png +0 -0
- package/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png +0 -0
- package/plugins/dsh-gkb-ru-ui/screenshots/06-home-tiles-1440-dark.png +0 -0
- package/plugins/dsh-peak-guard/README.md +70 -0
- package/plugins/dsh-peak-guard/client.js +741 -0
- package/plugins/dsh-peak-guard/cordis.patch.yml +5 -0
- package/plugins/dsh-peak-guard/icon.svg +12 -0
- package/plugins/dsh-peak-guard/index.js +2 -0
- package/plugins/dsh-peak-guard/locale/en.json +6 -0
- package/plugins/dsh-peak-guard/locale/ru.json +6 -0
- package/plugins/dsh-peak-guard/locale/zh.json +6 -0
- package/plugins/dsh-peak-guard/package.json +33 -0
- package/plugins/dsh-peak-guard/screenshots/01-real-time-peak-start.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/02-real-time-peak-end.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/05-peak-card-768-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/06-peak-card-390-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/07-live-preview-check.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/07-pre-peak-1440-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/08-peak-start-1440-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/09-peak-end-1440-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/10-pre-peak-card-1440-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/11-pre-peak-card-1440-dark.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/12-pre-peak-card-390-light.png +0 -0
- package/plugins/dsh-peak-guard/screenshots/qa-report.json +74 -0
- package/plugins/dsh-profile-transfer/README.md +62 -0
- package/plugins/dsh-profile-transfer/bootstrap/01-INSTALL.cmd +7 -0
- package/plugins/dsh-profile-transfer/bootstrap/README-ARCHIVE.md +54 -0
- package/plugins/dsh-profile-transfer/bootstrap/README-/320/243/320/241/320/242/320/220/320/235/320/236/320/222/320/232/320/220.md +42 -0
- package/plugins/dsh-profile-transfer/bootstrap/install-on-clean-machine.ps1 +119 -0
- package/plugins/dsh-profile-transfer/bootstrap//320/243/320/241/320/242/320/220/320/235/320/236/320/222/320/230/320/242/320/254.cmd +5 -0
- package/plugins/dsh-profile-transfer/client.js +806 -0
- package/plugins/dsh-profile-transfer/cordis.patch.yml +3 -0
- package/plugins/dsh-profile-transfer/icon.svg +13 -0
- package/plugins/dsh-profile-transfer/index.js +375 -0
- package/plugins/dsh-profile-transfer/locale/en.json +6 -0
- package/plugins/dsh-profile-transfer/locale/ru.json +6 -0
- package/plugins/dsh-profile-transfer/locale/zh.json +6 -0
- package/plugins/dsh-profile-transfer/package.json +36 -0
- package/plugins/dsh-profile-transfer/screenshots/01-settings-transfer-1440-light.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/02-settings-transfer-preview-1440-light.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/03-settings-transfer-1440-dark.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/04-settings-transfer-390-light.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/05-settings-transfer-768-light.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/06-settings-transfer-390-dark.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/07-settings-transfer-export-result.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/08-settings-transfer-workspaces-1440-light.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/09-settings-transfer-workspaces-1440-dark.png +0 -0
- package/plugins/dsh-profile-transfer/screenshots/10-settings-transfer-workspaces-390-light.png +0 -0
- package/plugins/dsh-profile-transfer/transfer.js +1004 -0
- package/plugins/dsh-project-memory/README.md +71 -0
- package/plugins/dsh-project-memory/cordis.patch.yml +4 -0
- package/plugins/dsh-project-memory/icon.svg +12 -0
- package/plugins/dsh-project-memory/index.js +1240 -0
- package/plugins/dsh-project-memory/locale/en.json +6 -0
- package/plugins/dsh-project-memory/locale/ru.json +6 -0
- package/plugins/dsh-project-memory/locale/zh.json +6 -0
- package/plugins/dsh-project-memory/package.json +26 -0
- package/plugins/dsh-session-move/README.md +67 -0
- package/plugins/dsh-session-move/client.js +719 -0
- package/plugins/dsh-session-move/cordis.patch.yml +5 -0
- package/plugins/dsh-session-move/icon.svg +14 -0
- package/plugins/dsh-session-move/index.js +497 -0
- package/plugins/dsh-session-move/locale/en.json +6 -0
- package/plugins/dsh-session-move/locale/ru.json +6 -0
- package/plugins/dsh-session-move/locale/zh.json +6 -0
- package/plugins/dsh-session-move/package.json +31 -0
- package/plugins/dsh-session-move/screenshots/01-row-menu-1440-light.png +0 -0
- package/plugins/dsh-session-move/screenshots/02-dialog-1440-light.png +0 -0
- package/plugins/dsh-session-move/screenshots/03-dialog-390-light.png +0 -0
- package/plugins/dsh-session-move/screenshots/04-dialog-1440-dark.png +0 -0
- package/plugins/dsh-session-move/screenshots/05-drag-highlight-1440-light.png +0 -0
- package/plugins/dsh-session-move/screenshots/06-drop-ungrouped-highlight.png +0 -0
- package/plugins/dsh-session-move/screenshots/07-after-drop-ungrouped.png +0 -0
- package/plugins/dsh-session-move/screenshots/08-move-dialog.png +0 -0
- package/plugins/dsh-session-move/screenshots/09-moved-to-second-workspace.png +0 -0
- package/plugins/dsh-session-move/screenshots/qa-report.json +62 -0
- package/plugins/dsh-skill-autopilot/cordis.patch.yml +3 -0
- package/plugins/dsh-skill-autopilot/index.js +444 -0
- package/plugins/dsh-skill-autopilot/package.json +19 -0
- package/plugins/dsh-token-lab/cordis.patch.yml +3 -0
- package/plugins/dsh-token-lab/lib/client.js +504 -0
- package/plugins/dsh-token-lab/lib/index.js +275 -0
- package/plugins/dsh-token-lab/package.json +26 -0
- package/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png +0 -0
- package/plugins/dsh-token-lab/screenshots/02-token-lab-1440-dark.png +0 -0
- package/skills/code-review-checklist/SKILL.md +55 -0
- package/skills/content-writing/README.md +87 -0
- package/skills/content-writing/SKILL.md +85 -0
- package/skills/content-writing/assets/checklists/fact-check.md +53 -0
- package/skills/content-writing/assets/checklists/publish.md +65 -0
- package/skills/content-writing/assets/checklists/social.md +40 -0
- package/skills/content-writing/assets/templates/article.md +47 -0
- package/skills/content-writing/assets/templates/brief.md +44 -0
- package/skills/content-writing/assets/templates/doctor-card.md +41 -0
- package/skills/content-writing/assets/templates/image-prompts.md +128 -0
- package/skills/content-writing/assets/templates/post-telegram.md +36 -0
- package/skills/content-writing/assets/templates/post-vk.md +42 -0
- package/skills/content-writing/assets/templates/press-release.md +56 -0
- package/skills/content-writing/assets/templates/science-pop-note.md +55 -0
- package/skills/content-writing/assets/templates/service-card.md +46 -0
- package/skills/content-writing/references/anti-ai-style.md +248 -0
- package/skills/content-writing/references/editing.md +185 -0
- package/skills/content-writing/references/fact-checking.md +205 -0
- package/skills/content-writing/references/government-medical.md +246 -0
- package/skills/content-writing/references/images.md +212 -0
- package/skills/content-writing/references/journalism.md +252 -0
- package/skills/content-writing/references/process.md +123 -0
- package/skills/content-writing/references/quick-recipes.md +99 -0
- package/skills/content-writing/references/rules.md +85 -0
- package/skills/content-writing/references/science-popular.md +218 -0
- package/skills/content-writing/references/seo-content.md +172 -0
- package/skills/content-writing/references/social-media.md +253 -0
- package/skills/content-writing/references/sources.md +49 -0
- package/skills/content-writing/references/templates.md +291 -0
- package/skills/context-economy/SKILL.md +60 -0
- package/skills/context-economy/references/long-session.md +35 -0
- package/skills/context-economy/references/token-math.md +42 -0
- package/skills/context-economy/references/tool-recipes.md +34 -0
- package/skills/database-safety/SKILL.md +47 -0
- package/skills/debugging-playbook/SKILL.md +42 -0
- package/skills/design-critique/SKILL.md +65 -0
- package/skills/design-critique/references/a11y.md +25 -0
- package/skills/design-critique/references/diagnoses.md +33 -0
- package/skills/design-critique/references/quick-tests.md +30 -0
- package/skills/design-critique/references/report-template.md +63 -0
- package/skills/design-critique/references/rubric-fast.md +73 -0
- package/skills/dev-workflow/SKILL.md +48 -0
- package/skills/dev-workflow/references/definition-of-done.md +44 -0
- package/skills/dev-workflow/references/memory-and-boundaries.md +31 -0
- package/skills/dev-workflow/references/stages.md +67 -0
- package/skills/git-and-ci/SKILL.md +60 -0
- package/skills/pg-upgrade-verify/SKILL.md +67 -0
- package/skills/project-deep-dive/SKILL.md +45 -0
- package/skills/project-deep-dive/references/recon-commands.md +90 -0
- package/skills/project-deep-dive/references/section-templates.md +104 -0
- package/skills/project-deep-dive/references/tool-and-process.md +86 -0
- package/skills/project-memory-maintenance/SKILL.md +55 -0
- package/skills/project-memory-maintenance/references/api-and-checklist.md +99 -0
- package/skills/project-memory-maintenance/references/journal-template.md +50 -0
- package/skills/project-memory-maintenance/references/section-rules.md +59 -0
- package/skills/release-and-deploy/SKILL.md +53 -0
- package/skills/requirements-and-planning/SKILL.md +49 -0
- package/skills/requirements-and-planning/references/antipatterns-and-checklist.md +20 -0
- package/skills/requirements-and-planning/references/process-steps.md +52 -0
- package/skills/requirements-and-planning/references/templates-and-estimates.md +29 -0
- package/skills/security-review/SKILL.md +40 -0
- package/skills/seo/README.md +60 -0
- package/skills/seo/SKILL.md +77 -0
- package/skills/seo/assets/README.md +66 -0
- package/skills/seo/assets/scripts/LICENSE-playwright-core.txt +202 -0
- package/skills/seo/assets/scripts/README.md +179 -0
- package/skills/seo/assets/scripts/lib/args.mjs +105 -0
- package/skills/seo/assets/scripts/lib/browser.mjs +620 -0
- package/skills/seo/assets/scripts/lib/zip.mjs +191 -0
- package/skills/seo/assets/scripts/seo-audit.mjs +1675 -0
- package/skills/seo/assets/snippets/jsonld-breadcrumb.json +30 -0
- package/skills/seo/assets/snippets/jsonld-faq.json +39 -0
- package/skills/seo/assets/snippets/jsonld-medical-clinic.json +49 -0
- package/skills/seo/assets/snippets/jsonld-medical-webpage.json +33 -0
- package/skills/seo/assets/snippets/jsonld-organization.json +74 -0
- package/skills/seo/assets/snippets/jsonld-physician.json +46 -0
- package/skills/seo/assets/snippets/meta.blade.php +61 -0
- package/skills/seo/assets/snippets/robots.txt +61 -0
- package/skills/seo/assets/snippets/sitemap-urlset-example.xml +72 -0
- package/skills/seo/assets/snippets/sitemap.xml +36 -0
- package/skills/seo/references/antipatterns.md +66 -0
- package/skills/seo/references/audit-checklist.md +319 -0
- package/skills/seo/references/content-seo.md +204 -0
- package/skills/seo/references/eeat-medical.md +219 -0
- package/skills/seo/references/measurement.md +250 -0
- package/skills/seo/references/on-page.md +214 -0
- package/skills/seo/references/page-templates.md +56 -0
- package/skills/seo/references/stack-recipes.md +695 -0
- package/skills/seo/references/structured-data.md +487 -0
- package/skills/seo/references/technical-seo.md +296 -0
- package/skills/service-desk-conventions/SKILL.md +52 -0
- package/skills/service-desk-db-safety/SKILL.md +63 -0
- package/skills/service-desk-release/SKILL.md +61 -0
- package/skills/service-desk-testing/SKILL.md +61 -0
- package/skills/service-desk-ui/SKILL.md +52 -0
- package/skills/skills-router/SKILL.md +53 -0
- package/skills/skills-router/references/applying-skills.md +25 -0
- package/skills/skills-router/references/routing-matrix.md +52 -0
- package/skills/testing-strategy/SKILL.md +52 -0
- package/skills/ui-design-system/SKILL.md +50 -0
- package/skills/ui-design-system/references/accessibility-and-responsive.md +50 -0
- package/skills/ui-design-system/references/tokens-and-components.md +67 -0
- package/skills/ui-design-system/references/visual-qa.md +44 -0
- package/skills/web-research/SKILL.md +47 -0
- package/skills/web-research/references/answer-and-citations.md +60 -0
- package/skills/web-research/references/query-recipes.md +44 -0
- package/skills/wow-design/SKILL.md +89 -0
- package/skills/wow-design/assets/kit/README.md +195 -0
- package/skills/wow-design/assets/kit/assets/css/base.css +158 -0
- package/skills/wow-design/assets/kit/assets/css/components.css +1001 -0
- package/skills/wow-design/assets/kit/assets/css/fonts.css +73 -0
- package/skills/wow-design/assets/kit/assets/css/pages.css +737 -0
- package/skills/wow-design/assets/kit/assets/css/tokens.css +218 -0
- package/skills/wow-design/assets/kit/assets/fonts/LICENSE-golos-text.txt +93 -0
- package/skills/wow-design/assets/kit/assets/fonts/LICENSE-lora.txt +93 -0
- package/skills/wow-design/assets/kit/assets/fonts/LICENSE-unbounded.txt +93 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-cyrillic-400-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-cyrillic-500-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-cyrillic-600-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-cyrillic-700-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-latin-400-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-latin-500-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-latin-600-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/golos-text-latin-700-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-cyrillic-400-italic.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-cyrillic-400-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-cyrillic-500-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-cyrillic-600-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-latin-400-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-latin-500-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/lora-latin-600-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/unbounded-cyrillic-400-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/unbounded-cyrillic-500-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/unbounded-cyrillic-600-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/unbounded-latin-400-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/unbounded-latin-500-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/fonts/unbounded-latin-600-normal.woff2 +0 -0
- package/skills/wow-design/assets/kit/assets/js/kit.js +550 -0
- package/skills/wow-design/assets/kit/pages/dashboard.html +539 -0
- package/skills/wow-design/assets/kit/pages/hospital.html +430 -0
- package/skills/wow-design/assets/kit/showcase.html +1164 -0
- package/skills/wow-design/assets/scripts/LICENSE-axe-core.txt +362 -0
- package/skills/wow-design/assets/scripts/LICENSE-playwright-core.txt +202 -0
- package/skills/wow-design/assets/scripts/README.md +312 -0
- package/skills/wow-design/assets/scripts/audit.mjs +1200 -0
- package/skills/wow-design/assets/scripts/capture.mjs +337 -0
- package/skills/wow-design/assets/scripts/package.json +30 -0
- package/skills/wow-design/references/anti-patterns.md +252 -0
- package/skills/wow-design/references/critique-rubric.md +262 -0
- package/skills/wow-design/references/design-brief-template.md +48 -0
- package/skills/wow-design/references/inspiration.md +203 -0
- package/skills/wow-design/references/presets.md +99 -0
- package/skills/wow-design/references/principles.md +371 -0
- package/skills/wow-design/references/quick-presets.md +50 -0
- package/skills/wow-design/references/report-template.md +21 -0
- package/skills/wow-design/references/stack-recipes.md +96 -0
- package/skills/wow-design/references/visual-qa.md +82 -0
- package/skills/wow-design/references/wow-levers.md +43 -0
- package/tools/skill-cost.mjs +76 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-gkb-ru-ui — Host half.
|
|
3
|
+
*
|
|
4
|
+
* Russian language pack marker + Skills catalog RPC:
|
|
5
|
+
* skills — inventory of ~/.dsh/skills with usage statistics from sessions
|
|
6
|
+
* skill — one skill with its SKILL.md content
|
|
7
|
+
* open-skill — reveal a skill folder / SKILL.md in the OS file manager
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import os from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { spawn } from "node:child_process";
|
|
14
|
+
import { collectSkillsData, listSkills, readSkillContent, skillsHome, saveSkillContent, createSkill, duplicateSkill, deleteSkill } from "./skills.js";
|
|
15
|
+
|
|
16
|
+
const ROUTE_BASE = "/api/dsh-gkb-ru-ui";
|
|
17
|
+
const RPC_NAMESPACE = "dsh-gkb-ru-ui";
|
|
18
|
+
|
|
19
|
+
export const inject = ["connection"];
|
|
20
|
+
|
|
21
|
+
function okEnvelope(rpcId, value) {
|
|
22
|
+
return Response.json({ type: "server-response", rpcId, result: { ok: true, value } });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function errorEnvelope(rpcId, code, message) {
|
|
26
|
+
return Response.json({ type: "server-response", rpcId, result: { ok: false, error: { code, message } } });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function readEnvelope(request) {
|
|
30
|
+
let body;
|
|
31
|
+
try {
|
|
32
|
+
body = await request.json();
|
|
33
|
+
} catch {
|
|
34
|
+
const error = new Error("тело запроса не JSON");
|
|
35
|
+
error.code = "skills/bad-request";
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
if (body === null || typeof body !== "object" || body.type !== "client-request" || typeof body.rpcId !== "string" || typeof body.method !== "string") {
|
|
39
|
+
const error = new Error("некорректный конверт Connection");
|
|
40
|
+
error.code = "skills/bad-request";
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
return { rpcId: body.rpcId, method: body.method, payload: body.payload ?? {} };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function openInExplorer(target, isFile) {
|
|
47
|
+
const platform = process.platform;
|
|
48
|
+
if (platform === "win32") {
|
|
49
|
+
const child = spawn("explorer.exe", [isFile ? `/select,${target}` : target], { detached: true, stdio: "ignore" });
|
|
50
|
+
child.unref?.();
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const command = platform === "darwin" ? "open" : "xdg-open";
|
|
54
|
+
const child = spawn(command, [isFile ? path.dirname(target) : target], { detached: true, stdio: "ignore" });
|
|
55
|
+
child.unref?.();
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function registerOperation(ctx, operation, handler) {
|
|
60
|
+
const route = {
|
|
61
|
+
path: `${ROUTE_BASE}/${operation}`,
|
|
62
|
+
methods: ["POST"],
|
|
63
|
+
requestBody: "buffered",
|
|
64
|
+
fetch: async (request) => {
|
|
65
|
+
let rpcId = "invalid-request";
|
|
66
|
+
try {
|
|
67
|
+
const envelope = await readEnvelope(request);
|
|
68
|
+
rpcId = envelope.rpcId;
|
|
69
|
+
if (envelope.method !== `${RPC_NAMESPACE}/${operation}`) {
|
|
70
|
+
return errorEnvelope(rpcId, "skills/bad-request", "метод конверта не совпадает с endpoint");
|
|
71
|
+
}
|
|
72
|
+
const value = await handler(envelope.payload);
|
|
73
|
+
return okEnvelope(rpcId, value);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
const code = typeof error?.code === "string" ? error.code : "skills/internal";
|
|
76
|
+
if (code === "skills/internal") ctx.logger?.warn?.(`[gkb-skills] ${operation} failed: ${String(error)}`);
|
|
77
|
+
return errorEnvelope(rpcId, code, error instanceof Error ? error.message : String(error));
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
ctx.effect(() => {
|
|
82
|
+
const dispose = ctx.connection.fetch.register(route);
|
|
83
|
+
return () => {
|
|
84
|
+
try {
|
|
85
|
+
void Promise.resolve(dispose()).catch(() => {});
|
|
86
|
+
} catch {
|
|
87
|
+
/* carrier unloading */
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}, `gkb-ru: ${operation} route`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function apply(ctx) {
|
|
94
|
+
try {
|
|
95
|
+
fs.writeFileSync(
|
|
96
|
+
path.join(os.tmpdir(), "dsh-gkb-ru-ui-loaded.json"),
|
|
97
|
+
JSON.stringify({ at: new Date().toISOString(), pid: process.pid, version: "1.8.0" }),
|
|
98
|
+
"utf8",
|
|
99
|
+
);
|
|
100
|
+
} catch {
|
|
101
|
+
/* marker is best effort */
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
registerOperation(ctx, "skills", async (payload) => {
|
|
105
|
+
const sessionId = typeof payload?.sessionId === "string" && payload.sessionId.length > 0 ? payload.sessionId : null;
|
|
106
|
+
const home = skillsHome();
|
|
107
|
+
const data = collectSkillsData(home, sessionId);
|
|
108
|
+
return { ...data, home };
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
registerOperation(ctx, "skill", async (payload) => {
|
|
112
|
+
const name = typeof payload?.name === "string" ? payload.name : "";
|
|
113
|
+
if (name.length === 0) {
|
|
114
|
+
const error = new Error("не указано имя навыка");
|
|
115
|
+
error.code = "skills/bad-request";
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
const home = skillsHome();
|
|
119
|
+
const skill = readSkillContent(home, name);
|
|
120
|
+
if (skill === null) {
|
|
121
|
+
const error = new Error(`навык «${name}» не найден`);
|
|
122
|
+
error.code = "skills/not-found";
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
const data = collectSkillsData(home, typeof payload?.sessionId === "string" ? payload.sessionId : null);
|
|
126
|
+
const usage = data.skills.find((item) => item.name === skill.name)?.usage ?? null;
|
|
127
|
+
return { skill, usage };
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
registerOperation(ctx, "skill-save", async (payload) => {
|
|
131
|
+
const name = typeof payload?.name === "string" ? payload.name : "";
|
|
132
|
+
const content = typeof payload?.content === "string" ? payload.content : "";
|
|
133
|
+
if (name.length === 0) {
|
|
134
|
+
const error = new Error("не указано имя навыка");
|
|
135
|
+
error.code = "skills/bad-request";
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
const saved = saveSkillContent(skillsHome(), name, content);
|
|
139
|
+
const data = collectSkillsData(skillsHome(), typeof payload?.sessionId === "string" ? payload.sessionId : null);
|
|
140
|
+
return { ...saved, totals: data.totals };
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
registerOperation(ctx, "skill-create", async (payload) => {
|
|
144
|
+
const skill = createSkill(skillsHome(), payload);
|
|
145
|
+
const data = collectSkillsData(skillsHome(), typeof payload?.sessionId === "string" ? payload.sessionId : null);
|
|
146
|
+
return { skill, totals: data.totals };
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
registerOperation(ctx, "skill-duplicate", async (payload) => {
|
|
150
|
+
const source = typeof payload?.source === "string" ? payload.source : "";
|
|
151
|
+
const name = typeof payload?.name === "string" ? payload.name : "";
|
|
152
|
+
if (source.length === 0) {
|
|
153
|
+
const error = new Error("не указан исходный навык");
|
|
154
|
+
error.code = "skills/bad-request";
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
const skill = duplicateSkill(skillsHome(), source, name);
|
|
158
|
+
const data = collectSkillsData(skillsHome(), typeof payload?.sessionId === "string" ? payload.sessionId : null);
|
|
159
|
+
return { skill, totals: data.totals };
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
registerOperation(ctx, "skill-delete", async (payload) => {
|
|
163
|
+
const name = typeof payload?.name === "string" ? payload.name : "";
|
|
164
|
+
if (name.length === 0) {
|
|
165
|
+
const error = new Error("не указано имя навыка");
|
|
166
|
+
error.code = "skills/bad-request";
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
const result = deleteSkill(skillsHome(), name);
|
|
170
|
+
const data = collectSkillsData(skillsHome(), typeof payload?.sessionId === "string" ? payload.sessionId : null);
|
|
171
|
+
return { ...result, totals: data.totals };
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
registerOperation(ctx, "open-skill", async (payload) => {
|
|
175
|
+
const name = typeof payload?.name === "string" ? payload.name : "";
|
|
176
|
+
const home = skillsHome();
|
|
177
|
+
const skill = listSkills(home).find((item) => item.name === name || item.directory === name);
|
|
178
|
+
if (skill === undefined) {
|
|
179
|
+
const error = new Error(`навык «${name}» не найден`);
|
|
180
|
+
error.code = "skills/not-found";
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
openInExplorer(skill.skillFile, true);
|
|
184
|
+
return { opened: true, path: skill.path };
|
|
185
|
+
});
|
|
186
|
+
}
|