@dsh-gis/dsh-opengis-skill 0.3.0 → 0.5.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/CHANGELOG.md +89 -1
- package/README.md +78 -21
- package/adaptations/brutile.md +19 -6
- package/adaptations/cesiumjs.md +14 -5
- package/adaptations/common.md +49 -16
- package/adaptations/deck-gl.md +19 -6
- package/adaptations/duckdb-spatial.md +20 -6
- package/adaptations/gdal-api.md +24 -6
- package/adaptations/gdal.md +22 -6
- package/adaptations/geolibre.md +20 -6
- package/adaptations/geometry-api-java.md +14 -6
- package/adaptations/geometry-api-net.md +17 -6
- package/adaptations/geonode.md +17 -6
- package/adaptations/geopandas.md +21 -6
- package/adaptations/geopipe-agent.md +21 -6
- package/adaptations/geos.md +23 -0
- package/adaptations/geoserver-cloud.md +17 -6
- package/adaptations/geoserver-rest-api.md +17 -6
- package/adaptations/geoserver.md +18 -6
- package/adaptations/geotools.md +19 -6
- package/adaptations/grass-gis.md +24 -6
- package/adaptations/jts.md +18 -6
- package/adaptations/kepler-gl.md +18 -5
- package/adaptations/leaflet.md +25 -6
- package/adaptations/mapbox-gl-js.md +23 -6
- package/adaptations/maplibre-gl-js.md +20 -0
- package/adaptations/maplibre-native.md +19 -0
- package/adaptations/mapserver.md +22 -6
- package/adaptations/mapsui.md +22 -6
- package/adaptations/nettopologysuite.md +19 -6
- package/adaptations/opendronemap.md +21 -0
- package/adaptations/opengis-all.md +16 -5
- package/adaptations/opengis-daf.md +16 -5
- package/adaptations/opengis-utils-for-java.md +20 -6
- package/adaptations/opengis-utils-for-net.md +23 -6
- package/adaptations/openlayers.md +20 -6
- package/adaptations/pdal.md +26 -6
- package/adaptations/postgis.md +20 -6
- package/adaptations/proj.md +20 -6
- package/adaptations/projnet4geoapi.md +21 -6
- package/adaptations/pyqgis.md +18 -6
- package/adaptations/qgis-process.md +21 -6
- package/adaptations/qgis-server.md +18 -6
- package/adaptations/shapely.md +22 -6
- package/adaptations/sharpmap.md +19 -6
- package/adaptations/spatialite.md +23 -6
- package/adaptations/stac-cog-titiler.md +23 -0
- package/adaptations/whitebox-tools.md +19 -6
- package/assets/deck-gl/SKILL.md +1 -0
- package/assets/duckdb-spatial/SKILL.md +36 -13
- package/assets/gdal/SKILL.md +6 -6
- package/assets/gdal-api/SKILL.md +2 -2
- package/assets/geolibre/SKILL.md +1 -0
- package/assets/geonode/SKILL.md +3 -3
- package/assets/geopandas/SKILL.md +42 -8
- package/assets/geopandas/reference/core-api.md +51 -0
- package/assets/geos/SKILL.md +372 -0
- package/assets/geoserver/SKILL.md +1 -1
- package/assets/geoserver-cloud/SKILL.md +0 -2
- package/assets/grass-gis/SKILL.md +31 -7
- package/assets/kepler-gl/SKILL.md +1 -0
- package/assets/leaflet/SKILL.md +2 -2
- package/assets/mapbox-gl-js/SKILL.md +1 -0
- package/assets/maplibre-gl-js/SKILL.md +478 -0
- package/assets/maplibre-native/SKILL.md +383 -0
- package/assets/mapserver/SKILL.md +7 -5
- package/assets/mapsui/SKILL.md +4 -2
- package/assets/opendronemap/SKILL.md +309 -0
- package/assets/opengis-all/SKILL.md +1 -0
- package/assets/pdal/SKILL.md +9 -1
- package/assets/projnet4geoapi/SKILL.md +1 -1
- package/assets/shapely/SKILL.md +24 -4
- package/assets/shapely/reference/operations-reference.md +30 -0
- package/assets/spatialite/SKILL.md +8 -2
- package/assets/stac-cog-titiler/SKILL.md +420 -0
- package/assets/whitebox-tools/SKILL.md +20 -4
- package/lib/adaptations.d.ts +22 -1
- package/lib/adaptations.js +166 -20
- package/lib/index.d.ts +13 -9
- package/lib/index.js +58 -12
- package/lib/taxonomy.d.ts +41 -0
- package/lib/taxonomy.js +332 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +10 -4
- package/upstream.json +36 -26
package/lib/adaptations.js
CHANGED
|
@@ -9,6 +9,18 @@
|
|
|
9
9
|
* "<skill>.md" carries the skill-specific notes. The provider appends both to
|
|
10
10
|
* the upstream body when a skill is loaded.
|
|
11
11
|
*
|
|
12
|
+
* The tool lists below are split by availability, not by usefulness:
|
|
13
|
+
*
|
|
14
|
+
* - "CORE_TOOLS" ship with every supported DeepSeek Harness build, so guidance
|
|
15
|
+
* may rely on them. A per-skill file must cite at least two of them, and the
|
|
16
|
+
* shared file at least eight, which is what stops the layer from decaying
|
|
17
|
+
* into tool-agnostic advice the upstream bodies already carry.
|
|
18
|
+
* - "OPTIONAL_TOOLS" come from optional plugins (Agent Teams, desktop control,
|
|
19
|
+
* scheduled tasks, workspace dependency introspection). Guidance may name
|
|
20
|
+
* them, but must phrase them as a capability the session may or may not
|
|
21
|
+
* expose and keep a fallback, because a bare citation would break in a
|
|
22
|
+
* session without that plugin.
|
|
23
|
+
*
|
|
12
24
|
* Every function here is pure Node built-ins and takes the adaptation root as
|
|
13
25
|
* an argument, so the plugin, the validation script, and the tests share one
|
|
14
26
|
* implementation. No DeepSeek Harness imports.
|
|
@@ -39,12 +51,42 @@ export const SKILL_SEPARATOR = "\n\n---\n\n";
|
|
|
39
51
|
export const REQUIRED_LABELS = ["加载与引用", "执行环境", "先探测版本", "验证产物", "风险与权限"];
|
|
40
52
|
|
|
41
53
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
54
|
+
* Labels whose bullet must carry a concrete command or tool in backticks.
|
|
55
|
+
*
|
|
56
|
+
* "先探测版本" without a probe command and "验证产物" without a check command
|
|
57
|
+
* are the two ways this layer most easily degenerates into an assertion: the
|
|
58
|
+
* model reads "check the result" and reports success without checking.
|
|
59
|
+
*/
|
|
60
|
+
export const CONCRETE_LABELS = ["先探测版本", "验证产物"];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* How many of the required labels must decompose into indented sub-bullets, and
|
|
64
|
+
* how many sub-bullets a file must carry in total.
|
|
65
|
+
*
|
|
66
|
+
* A flat file with six 600-character bullets is technically complete and
|
|
67
|
+
* practically unreadable: the model sees one paragraph per label and cannot
|
|
68
|
+
* tell which sentence applies now. Sub-bullets are the cheapest fix that keeps
|
|
69
|
+
* the five required labels and the character budget intact.
|
|
70
|
+
*/
|
|
71
|
+
export const MIN_NESTED_LABELS = 4;
|
|
72
|
+
|
|
73
|
+
/** Minimum indented sub-bullets across one per-skill guidance file. */
|
|
74
|
+
export const MIN_NESTED_BULLETS = 8;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Words that mark an optional-plugin capability as guarded.
|
|
78
|
+
*
|
|
79
|
+
* Guidance may name tools such as "spawn_teammate", but a bare citation breaks
|
|
80
|
+
* in a session without that plugin. The same line must say what happens when
|
|
81
|
+
* the capability is absent, so the fallback travels with the citation.
|
|
82
|
+
*/
|
|
83
|
+
const FALLBACK = /退回|没有|不一定|可选插件|未启用|不存在/u;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* DeepSeek Harness tools that every supported build exposes. Guidance may
|
|
87
|
+
* depend on these unconditionally.
|
|
46
88
|
*/
|
|
47
|
-
export const
|
|
89
|
+
export const CORE_TOOLS = Object.freeze([
|
|
48
90
|
"skill",
|
|
49
91
|
"ops_bash",
|
|
50
92
|
"pwsh",
|
|
@@ -61,23 +103,50 @@ export const DSH_TOOLS = [
|
|
|
61
103
|
"ask_user_question",
|
|
62
104
|
"job_output",
|
|
63
105
|
"job_kill",
|
|
106
|
+
"job_list",
|
|
64
107
|
"web_fetch",
|
|
65
108
|
"web_search",
|
|
66
109
|
"working_directory",
|
|
67
110
|
"load_workspace_dependencies"
|
|
68
|
-
];
|
|
111
|
+
]);
|
|
69
112
|
|
|
70
|
-
/**
|
|
71
|
-
|
|
113
|
+
/**
|
|
114
|
+
* DeepSeek Harness tools that arrive with an optional plugin: Agent Teams,
|
|
115
|
+
* desktop control, scheduled tasks, derived "subagent" branches, and MCP
|
|
116
|
+
* resource reads. Guidance may name them, but only together with the fallback
|
|
117
|
+
* that applies when the session does not expose them.
|
|
118
|
+
*/
|
|
119
|
+
export const OPTIONAL_TOOLS = Object.freeze([
|
|
120
|
+
"spawn_teammate",
|
|
121
|
+
"send_message",
|
|
122
|
+
"wait_agent",
|
|
123
|
+
"team_task_create",
|
|
124
|
+
"team_task_list",
|
|
125
|
+
"team_task_get",
|
|
126
|
+
"team_task_update",
|
|
127
|
+
"subagent_fork",
|
|
128
|
+
"windows_desktop",
|
|
129
|
+
"schedule_create",
|
|
130
|
+
"schedule_list",
|
|
131
|
+
"schedule_edit",
|
|
132
|
+
"list_mcp_resources",
|
|
133
|
+
"read_mcp_resource"
|
|
134
|
+
]);
|
|
72
135
|
|
|
73
|
-
/**
|
|
74
|
-
const
|
|
136
|
+
/** Every tool name the guidance may cite; the union of both lists. */
|
|
137
|
+
export const DSH_TOOLS = Object.freeze([...CORE_TOOLS, ...OPTIONAL_TOOLS]);
|
|
138
|
+
|
|
139
|
+
/** Minimum distinct core DSH tools one per-skill guidance must cite. */
|
|
140
|
+
const SKILL_MIN_CORE_TOOLS = 2;
|
|
141
|
+
|
|
142
|
+
/** Minimum distinct core DSH tools the shared guidance must cite. */
|
|
143
|
+
const COMMON_MIN_CORE_TOOLS = 8;
|
|
75
144
|
|
|
76
145
|
/** Minimum bullets in the shared guidance. */
|
|
77
|
-
const COMMON_MIN_BULLETS =
|
|
146
|
+
const COMMON_MIN_BULLETS = 14;
|
|
78
147
|
|
|
79
148
|
/** Minimum characters in the shared guidance. */
|
|
80
|
-
const COMMON_MIN_CHARACTERS =
|
|
149
|
+
const COMMON_MIN_CHARACTERS = 2600;
|
|
81
150
|
|
|
82
151
|
/** Maximum characters in the shared guidance. */
|
|
83
152
|
const COMMON_MAX_CHARACTERS = 9000;
|
|
@@ -244,12 +313,62 @@ export function citedTools(text) {
|
|
|
244
313
|
return found;
|
|
245
314
|
}
|
|
246
315
|
|
|
316
|
+
/**
|
|
317
|
+
* List the distinct core tool names cited in backticks.
|
|
318
|
+
*
|
|
319
|
+
* The minimums are counted on this list: a file that only names optional-plugin
|
|
320
|
+
* capabilities would be useless in a session where those plugins are off.
|
|
321
|
+
*
|
|
322
|
+
* @param text - the normalized adaptation text.
|
|
323
|
+
* @returns the distinct core tool names found, in first-citation order.
|
|
324
|
+
*/
|
|
325
|
+
export function citedCoreTools(text) {
|
|
326
|
+
return citedTools(text).filter((name) => CORE_TOOLS.includes(name));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Extract the body of one "- **label**:…" bullet.
|
|
331
|
+
*
|
|
332
|
+
* @param text - the normalized adaptation text.
|
|
333
|
+
* @param label - the label between the asterisks.
|
|
334
|
+
* @returns the bullet body after the label, or undefined when the bullet is missing.
|
|
335
|
+
*/
|
|
336
|
+
function bulletBody(text, label) {
|
|
337
|
+
const marker = "- **" + label + "**";
|
|
338
|
+
const start = text.indexOf(marker);
|
|
339
|
+
if (start === -1) return undefined;
|
|
340
|
+
const rest = text.slice(start + marker.length);
|
|
341
|
+
const next = rest.indexOf("\n- **");
|
|
342
|
+
return next === -1 ? rest : rest.slice(0, next);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* List the indented sub-bullets of one "\"- **label**:…\"" section.
|
|
347
|
+
*
|
|
348
|
+
* Sub-bullets are written two spaces in, so they stay inside their parent
|
|
349
|
+
* section and never count as one of the five required top-level bullets.
|
|
350
|
+
*
|
|
351
|
+
* @param text - the normalized adaptation text.
|
|
352
|
+
* @param label - the label between the asterisks; omit to count the whole file.
|
|
353
|
+
* @returns the sub-bullet lines, already trimmed.
|
|
354
|
+
*/
|
|
355
|
+
export function nestedBullets(text, label) {
|
|
356
|
+
const source = label === undefined ? text : bulletBody(text, label);
|
|
357
|
+
if (source === undefined) return [];
|
|
358
|
+
return source
|
|
359
|
+
.split("\n")
|
|
360
|
+
.filter((line) => /^[ \t]+-[ \t]+\S/u.test(line))
|
|
361
|
+
.map((line) => line.trim());
|
|
362
|
+
}
|
|
363
|
+
|
|
247
364
|
/**
|
|
248
365
|
* Report every problem with one per-skill adaptation file.
|
|
249
366
|
*
|
|
250
|
-
* The checks keep the
|
|
251
|
-
* where the commands run, how to probe the installed version, how to verify
|
|
252
|
-
* the artifact, and which operations need the user's consent.
|
|
367
|
+
* The checks keep the per-skill files comparable: each one states how to load
|
|
368
|
+
* it, where the commands run, how to probe the installed version, how to verify
|
|
369
|
+
* the artifact, and which operations need the user's consent. The probe and
|
|
370
|
+
* verification bullets must carry a concrete command or tool, and the file must
|
|
371
|
+
* cite core harness tools rather than only optional-plugin capabilities.
|
|
253
372
|
*
|
|
254
373
|
* @param name - kebab-case skill name, used in every message.
|
|
255
374
|
* @param text - the normalized adaptation text.
|
|
@@ -278,9 +397,30 @@ export function adaptationProblems(name, text) {
|
|
|
278
397
|
}
|
|
279
398
|
}
|
|
280
399
|
if (!/`[^`]+`/u.test(text)) problems.push(label + ": must name at least one concrete command or tool in backticks");
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
400
|
+
for (const required of CONCRETE_LABELS) {
|
|
401
|
+
const body = bulletBody(text, required);
|
|
402
|
+
if (body === undefined) continue;
|
|
403
|
+
if (!/`[^`]+`/u.test(body)) problems.push(label + ': "' + required + '" must cite a concrete command or tool in backticks, not just prose');
|
|
404
|
+
}
|
|
405
|
+
const emptyLabels = REQUIRED_LABELS.filter((required) => nestedBullets(text, required).length === 0);
|
|
406
|
+
if (REQUIRED_LABELS.length - emptyLabels.length < MIN_NESTED_LABELS) {
|
|
407
|
+
problems.push(
|
|
408
|
+
label +
|
|
409
|
+
": " +
|
|
410
|
+
(REQUIRED_LABELS.length - emptyLabels.length) +
|
|
411
|
+
" label(s) decompose into sub-bullets, needs at least " +
|
|
412
|
+
MIN_NESTED_LABELS +
|
|
413
|
+
"; add two-space \"- \" items under " +
|
|
414
|
+
emptyLabels.slice(0, REQUIRED_LABELS.length - MIN_NESTED_LABELS).join(" / ")
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
const nested = nestedBullets(text);
|
|
418
|
+
if (nested.length < MIN_NESTED_BULLETS) {
|
|
419
|
+
problems.push(label + ": carries " + nested.length + " sub-bullet(s), needs at least " + MIN_NESTED_BULLETS + " so each label breaks into concrete items");
|
|
420
|
+
}
|
|
421
|
+
const tools = citedCoreTools(text);
|
|
422
|
+
if (tools.length < SKILL_MIN_CORE_TOOLS) {
|
|
423
|
+
problems.push(label + ": cites " + tools.length + " core DeepSeek Harness tool(s), needs at least " + SKILL_MIN_CORE_TOOLS + " (one of " + CORE_TOOLS.slice(0, 6).join("/") + "/…); optional-plugin tools do not count");
|
|
284
424
|
}
|
|
285
425
|
if (UNFINISHED.test(text)) problems.push(label + ": still contains an unfinished marker (TODO/FIXME/TBD/待补充/占位)");
|
|
286
426
|
return problems;
|
|
@@ -302,8 +442,14 @@ export function commonProblems(text) {
|
|
|
302
442
|
if (text.length > COMMON_MAX_CHARACTERS) problems.push(label + ": " + text.length + " characters exceeds the " + COMMON_MAX_CHARACTERS + "-character budget");
|
|
303
443
|
const bullets = text.split("\n").filter((line) => line.startsWith("- **"));
|
|
304
444
|
if (bullets.length < COMMON_MIN_BULLETS) problems.push(label + ": needs at least " + COMMON_MIN_BULLETS + ' bullets of the form "- **label**:…"');
|
|
305
|
-
const tools =
|
|
306
|
-
if (tools.length <
|
|
445
|
+
const tools = citedCoreTools(text);
|
|
446
|
+
if (tools.length < COMMON_MIN_CORE_TOOLS) problems.push(label + ": cites " + tools.length + " core DeepSeek Harness tool(s), needs at least " + COMMON_MIN_CORE_TOOLS);
|
|
447
|
+
for (const line of text.split("\n")) {
|
|
448
|
+
const optional = OPTIONAL_TOOLS.filter((tool) => line.includes("`" + tool + "`"));
|
|
449
|
+
if (optional.length > 0 && !FALLBACK.test(line)) {
|
|
450
|
+
problems.push(label + ": cites optional-plugin tool(s) " + optional.join("/") + " without stating the fallback for sessions that do not expose them");
|
|
451
|
+
}
|
|
452
|
+
}
|
|
307
453
|
if (UNFINISHED.test(text)) problems.push(label + ": still contains an unfinished marker (TODO/FIXME/TBD/待补充/占位)");
|
|
308
454
|
return problems;
|
|
309
455
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -16,12 +16,16 @@ export interface OpenGisResourceBase {
|
|
|
16
16
|
path: string;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/**
|
|
19
|
+
/** Routing metadata carried on a candidate (never on a definition). */
|
|
20
20
|
export interface OpenGisSkillMetadata {
|
|
21
21
|
/** Upstream category directory, always "gis" for this pack. */
|
|
22
22
|
category?: string;
|
|
23
23
|
/** Parsed upstream metadata.tags. */
|
|
24
24
|
tags: string[];
|
|
25
|
+
/** Coarse groups from lib/taxonomy.js, used by the plugin config filter. */
|
|
26
|
+
groups: string[];
|
|
27
|
+
/** Local trigger phrases from lib/taxonomy.js, in request wording. */
|
|
28
|
+
keywords: string[];
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
/** One skill summary returned by the provider catalog. */
|
|
@@ -57,12 +61,12 @@ export interface OpenGisSkillProvider {
|
|
|
57
61
|
get(candidate: OpenGisSkillCandidate, options?: { signal?: AbortSignal }): Promise<OpenGisSkillDefinition>;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
/**
|
|
61
|
-
export interface
|
|
62
|
-
skills
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
/** Plugin config: trim the bundled catalog without editing the package. */
|
|
65
|
+
export interface OpenGisSkillConfig {
|
|
66
|
+
/** Groups to union; ignored when "skills" is non-empty. */
|
|
67
|
+
groups?: string[];
|
|
68
|
+
/** Explicit skill allow list; wins over "groups". */
|
|
69
|
+
skills?: string[];
|
|
70
|
+
/** Skill deny list, applied last. */
|
|
71
|
+
exclude?: string[];
|
|
65
72
|
}
|
|
66
|
-
|
|
67
|
-
/** Register the bundled OpenGIS skill provider on "ctx.skills". */
|
|
68
|
-
export declare function apply(ctx: OpenGisSkillHost): void;
|
package/lib/index.js
CHANGED
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
* guidance lives outside them: "adaptations/<skill>.md" plus the shared
|
|
12
12
|
* "adaptations/common.md" are appended when a skill is loaded.
|
|
13
13
|
*
|
|
14
|
+
* Three catalog layers stay outside the vendored snapshot on purpose:
|
|
15
|
+
*
|
|
16
|
+
* - "lib/taxonomy.js" maps each skill to coarse groups and to the Chinese
|
|
17
|
+
* trigger phrases a request actually uses, and the provider exposes both on
|
|
18
|
+
* the candidate metadata.
|
|
19
|
+
* - The plugin config ("groups", "skills", "exclude") trims the catalog per
|
|
20
|
+
* bundle configuration, so a browser-map session never pays for the server
|
|
21
|
+
* and database skills.
|
|
22
|
+
* - Loading appends the DSH guidance, so the upstream body stays byte-identical.
|
|
23
|
+
*
|
|
14
24
|
* @module @dsh-gis/dsh-opengis-skill
|
|
15
25
|
*/
|
|
16
26
|
|
|
@@ -19,6 +29,7 @@ import { fileURLToPath } from "node:url";
|
|
|
19
29
|
import { composeSkillContent, readAdaptation, readCommon } from "./adaptations.js";
|
|
20
30
|
import { readSkillCatalog, resourceBaseOf } from "./catalog.js";
|
|
21
31
|
import { parseSkillFile } from "./skill-file.js";
|
|
32
|
+
import { groupsOf, keywordsOf, normalizeSelection, selectSkills } from "./taxonomy.js";
|
|
22
33
|
|
|
23
34
|
/** Provider name registered on "ctx.skills" (the runtime name "runtime" is reserved). */
|
|
24
35
|
const PROVIDER_NAME = "opengis";
|
|
@@ -45,18 +56,49 @@ const inject = ["skills"];
|
|
|
45
56
|
const INVOCATION = { modelInvocable: true, userInvocable: true };
|
|
46
57
|
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
59
|
+
* Cached shared-guidance read.
|
|
60
|
+
*
|
|
61
|
+
* "common.md" is appended to every loaded skill and never changes while the
|
|
62
|
+
* process runs, so it is read once and reused. Only a successful read is
|
|
63
|
+
* cached: a transient failure must not poison the provider for the rest of the
|
|
64
|
+
* session, and a caller-supplied abort signal must not cancel a shared read
|
|
65
|
+
* that other callers are waiting on.
|
|
66
|
+
*/
|
|
67
|
+
let commonContent;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Read the shared DSH guidance, memoizing the successful result.
|
|
71
|
+
*
|
|
72
|
+
* @returns the normalized guidance text.
|
|
73
|
+
*/
|
|
74
|
+
function sharedGuidance() {
|
|
75
|
+
if (commonContent === undefined) {
|
|
76
|
+
commonContent = readCommon(ADAPTATION_ROOT).catch((cause) => {
|
|
77
|
+
commonContent = undefined;
|
|
78
|
+
throw cause;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return commonContent;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Build the candidate metadata from the upstream frontmatter plus the local
|
|
86
|
+
* taxonomy.
|
|
49
87
|
*
|
|
50
88
|
* "category" is omitted when upstream does not declare one, so consumers never
|
|
51
|
-
* see an explicit undefined; "tags"
|
|
52
|
-
* over
|
|
89
|
+
* see an explicit undefined; "tags", "groups" and "keywords" are always arrays
|
|
90
|
+
* so a consumer can map over them without a guard. "groups" and "keywords" are
|
|
91
|
+
* local additions: upstream carries neither, and a host that does not know them
|
|
92
|
+
* simply ignores the keys.
|
|
53
93
|
*
|
|
54
|
-
* @param
|
|
94
|
+
* @param skill - the parsed catalog entry.
|
|
55
95
|
* @returns the metadata object carried on the candidate.
|
|
56
96
|
*/
|
|
57
|
-
function candidateMetadata(
|
|
58
|
-
const tags = Array.isArray(metadata?.tags) ? metadata.tags : [];
|
|
59
|
-
|
|
97
|
+
function candidateMetadata(skill) {
|
|
98
|
+
const tags = Array.isArray(skill.metadata?.tags) ? skill.metadata.tags : [];
|
|
99
|
+
const metadata = { tags, groups: groupsOf(skill.name), keywords: keywordsOf(skill.name) };
|
|
100
|
+
if (skill.metadata?.category !== undefined) metadata.category = skill.metadata.category;
|
|
101
|
+
return metadata;
|
|
60
102
|
}
|
|
61
103
|
|
|
62
104
|
/**
|
|
@@ -81,11 +123,15 @@ function loadSkills() {
|
|
|
81
123
|
* so plugin unload removes the provider without an extra "ctx.effect" wrapper.
|
|
82
124
|
*
|
|
83
125
|
* @param ctx - Cordis context carrying the skill registry.
|
|
126
|
+
* @param config - optional plugin config: "groups" (string[]), "skills"
|
|
127
|
+
* (string[] allow list) and "exclude" (string[] deny list). Unknown names are
|
|
128
|
+
* rejected so a typo cannot silently return the wrong catalog.
|
|
84
129
|
*/
|
|
85
|
-
function apply(ctx) {
|
|
130
|
+
function apply(ctx, config) {
|
|
86
131
|
const skills = loadSkills();
|
|
87
|
-
const
|
|
88
|
-
const
|
|
132
|
+
const visible = selectSkills(skills, normalizeSelection(config, skills));
|
|
133
|
+
const byName = new Map(visible.map((skill) => [skill.name, skill]));
|
|
134
|
+
const candidates = visible.map((skill) => ({
|
|
89
135
|
name: skill.name,
|
|
90
136
|
description: skill.description,
|
|
91
137
|
invocation: { ...INVOCATION },
|
|
@@ -98,7 +144,7 @@ function apply(ctx) {
|
|
|
98
144
|
// The registry keeps upstream routing metadata on the candidate only;
|
|
99
145
|
// a definition is a summary and must not carry it. Absent values are
|
|
100
146
|
// omitted rather than emitted as undefined keys.
|
|
101
|
-
metadata: candidateMetadata(skill
|
|
147
|
+
metadata: candidateMetadata(skill)
|
|
102
148
|
}));
|
|
103
149
|
const provider = {
|
|
104
150
|
name: PROVIDER_NAME,
|
|
@@ -109,7 +155,7 @@ function apply(ctx) {
|
|
|
109
155
|
const [raw, adaptation, common] = await Promise.all([
|
|
110
156
|
readFile(skill.path, { encoding: "utf8", signal: options?.signal }),
|
|
111
157
|
readAdaptation(ADAPTATION_ROOT, skill.name, options?.signal),
|
|
112
|
-
|
|
158
|
+
sharedGuidance()
|
|
113
159
|
]);
|
|
114
160
|
let parsed;
|
|
115
161
|
try {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** The coarse groups a plugin config may select from. */
|
|
2
|
+
export declare const GROUP_IDS: readonly string[];
|
|
3
|
+
|
|
4
|
+
/** One-line description of every group. */
|
|
5
|
+
export declare const GROUP_DESCRIPTIONS: Readonly<Record<string, string>>;
|
|
6
|
+
|
|
7
|
+
/** The groups one skill belongs to. */
|
|
8
|
+
export declare function groupsOf(name: string): string[];
|
|
9
|
+
|
|
10
|
+
/** The trigger keywords of one skill. */
|
|
11
|
+
export declare function keywordsOf(name: string): string[];
|
|
12
|
+
|
|
13
|
+
/** One routing score for one skill. */
|
|
14
|
+
export interface OpenGisRoutingScore {
|
|
15
|
+
/** Kebab-case skill name. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Weighted hits: 3 per keyword match, 1 per description token match. */
|
|
18
|
+
score: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Score every catalog entry against one lowercased request. */
|
|
22
|
+
export declare function keywordScores(skills: readonly { name: string; description?: string }[], query: string): OpenGisRoutingScore[];
|
|
23
|
+
|
|
24
|
+
/** Report taxonomy entries that disagree with the catalog. */
|
|
25
|
+
export declare function taxonomyProblems(names: readonly string[]): string[];
|
|
26
|
+
|
|
27
|
+
/** The normalized plugin selection. */
|
|
28
|
+
export interface OpenGisSkillSelection {
|
|
29
|
+
/** Groups to union; ignored when "only" is non-empty. */
|
|
30
|
+
groups: string[];
|
|
31
|
+
/** Explicit skill allow list; wins over "groups". */
|
|
32
|
+
only: string[];
|
|
33
|
+
/** Skill deny list, applied last. */
|
|
34
|
+
exclude: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Validate and normalize the raw plugin config. */
|
|
38
|
+
export declare function normalizeSelection(config: unknown, skills: readonly { name: string }[]): OpenGisSkillSelection;
|
|
39
|
+
|
|
40
|
+
/** Apply one selection to the catalog, keeping the catalog order. */
|
|
41
|
+
export declare function selectSkills<T extends { name: string }>(skills: readonly T[], selection: OpenGisSkillSelection): T[];
|