dsh-agent-team-presets 0.3.2 → 0.3.4
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/NOTICE +58 -3
- package/README.md +73 -398
- package/README.zh.md +79 -404
- package/assets/card-patches/catalog.json +30 -0
- package/assets/card-patches/dsh-context-0.85.0.client.js.gz +0 -0
- package/assets/card-patches/dsh-context-0.85.1.client.js.gz +0 -0
- package/assets/card-patches/dsh-context-0.87.0.client.js.gz +0 -0
- package/assets/skills/agent-leader-communication/SKILL.md +100 -0
- package/assets/skills/agent-subagent-orchestration/SKILL.md +56 -0
- package/assets/skills/agent-subagent-orchestration/references/executor-parallel-execution.md +56 -0
- package/assets/skills/agent-subagent-orchestration/references/leader-discovery.md +53 -0
- package/assets/skills/agent-subagent-orchestration/references/subagent-communication.md +58 -0
- package/assets/skills/backend-architecture-workflow/SKILL.md +55 -0
- package/assets/skills/backend-architecture-workflow/references/README.md +9 -0
- package/assets/skills/backend-architecture-workflow/references/architecture-audit.md +70 -0
- package/assets/skills/backend-architecture-workflow/references/architecture-decay-risks.md +75 -0
- package/assets/skills/backend-architecture-workflow/references/architecture-design.md +151 -0
- package/assets/skills/backend-architecture-workflow/references/bugfix-regression.md +63 -0
- package/assets/skills/backend-architecture-workflow/references/complex-bug-diagnosis.md +104 -0
- package/assets/skills/executor-short-task-workflow/SKILL.md +48 -0
- package/assets/skills/executor-short-task-workflow/references/agent-communication.md +44 -0
- package/assets/skills/executor-short-task-workflow/references/verification-and-reporting.md +45 -0
- package/assets/skills/frontend-engineering-workflow/SKILL.md +47 -0
- package/assets/skills/frontend-engineering-workflow/references/README.md +7 -0
- package/assets/skills/frontend-engineering-workflow/references/frontend-implementation.md +46 -0
- package/assets/skills/frontend-engineering-workflow/references/visual-design.md +43 -0
- package/assets/skills/frontend-engineering-workflow/references/visual-qa.md +126 -0
- package/assets/skills/fullstack-advisor/SKILL.md +50 -0
- package/assets/skills/fullstack-advisor/references/brooks-principles.md +51 -0
- package/assets/skills/fullstack-advisor/references/consultant-communication.md +51 -0
- package/assets/skills/fullstack-advisor/references/consultation-workflow.md +71 -0
- package/assets/skills/git-release-hygiene/SKILL.md +33 -21
- package/assets/skills/git-release-hygiene/references/git-safety.md +66 -0
- package/assets/skills/git-release-hygiene/references/pr-changelog.md +98 -0
- package/assets/skills/git-release-hygiene/references/release-standard.md +139 -0
- package/assets/skills/git-release-hygiene/references/validation-checklist.md +42 -0
- package/assets/skills/github-repository-presentation/SKILL.md +49 -130
- package/assets/skills/github-repository-presentation/references/bilingual-writing.md +43 -0
- package/assets/skills/github-repository-presentation/references/documentation-architecture.md +156 -0
- package/assets/skills/github-repository-presentation/references/readme-standard.md +273 -0
- package/assets/skills/github-repository-presentation/references/release-notes.md +70 -0
- package/assets/skills/github-repository-presentation/references/validation-checklist.md +47 -0
- package/assets/skills/independent-code-review-workflow/SKILL.md +60 -0
- package/assets/skills/independent-code-review-workflow/references/README.md +9 -0
- package/assets/skills/independent-code-review-workflow/references/decay-risks.md +99 -0
- package/assets/skills/independent-code-review-workflow/references/review-checklist.md +53 -0
- package/assets/skills/independent-code-review-workflow/references/review-methodology.md +113 -0
- package/assets/skills/independent-code-review-workflow/references/review-severity.md +49 -0
- package/assets/skills/independent-code-review-workflow/references/test-quality-review.md +71 -0
- package/assets/skills/leader-long-task-orchestration/SKILL.md +49 -0
- package/assets/skills/leader-long-task-orchestration/references/delivery-plan-template.md +73 -0
- package/assets/skills/leader-long-task-orchestration/references/product-alignment.md +46 -0
- package/assets/skills/leader-long-task-orchestration/references/rolling-wave-planning.md +32 -0
- package/assets/skills/leader-long-task-orchestration/references/technical-decisions-and-escalation.md +34 -0
- package/assets/skills/leader-medium-task-workflow/SKILL.md +55 -0
- package/assets/skills/leader-medium-task-workflow/references/task-board-and-leader-todo.md +41 -0
- package/docs/builtin-team-skills.md +82 -0
- package/docs/builtin-team-skills.zh.md +82 -0
- package/docs/builtin-teams.md +62 -0
- package/docs/builtin-teams.zh.md +62 -0
- package/docs/developer/architecture.md +54 -0
- package/docs/developer/architecture.zh.md +54 -0
- package/docs/guide/install.md +86 -0
- package/docs/guide/install.zh.md +86 -0
- package/docs/guide/integrations.md +50 -0
- package/docs/guide/integrations.zh.md +50 -0
- package/docs/guide/team-skills.md +68 -0
- package/docs/guide/team-skills.zh.md +68 -0
- package/docs/guide/using-teams.md +92 -0
- package/docs/guide/using-teams.zh.md +92 -0
- package/docs/index.md +53 -0
- package/docs/index.zh.md +53 -0
- package/docs/reference/tools-and-permissions.md +62 -0
- package/docs/reference/tools-and-permissions.zh.md +62 -0
- package/docs/reference/troubleshooting.md +59 -0
- package/docs/reference/troubleshooting.zh.md +59 -0
- package/icon.webp +0 -0
- package/lib/client.js +1459 -253
- package/lib/index.js +960 -342
- package/lib/typert.host.js +402 -29
- package/lib/typert.remote-client.d.ts +9 -9
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +402 -29
- package/lib/types/client/CardPatchView.js +21 -1
- package/lib/types/client/ComposerTeamSelect.js +24 -8
- package/lib/types/client/TeamAgentView.d.ts +1 -1
- package/lib/types/client/TeamAgentView.js +11 -6
- package/lib/types/client/TeamImportDialog.d.ts +4 -15
- package/lib/types/client/TeamImportDialog.js +29 -25
- package/lib/types/client/TeamPresetsSection.js +14 -5
- package/lib/types/client/TeamSkillsView.d.ts +5 -4
- package/lib/types/client/TeamSkillsView.js +64 -15
- package/lib/types/client/locales.d.ts +41 -2
- package/lib/types/client/locales.js +185 -8
- package/lib/types/client/team-presets-controller.d.ts +15 -2
- package/lib/types/client/team-presets-controller.js +86 -30
- package/lib/types/client/team-skills-controller.d.ts +14 -5
- package/lib/types/client/team-skills-controller.js +71 -37
- package/lib/types/index.js +57 -19
- package/lib/types/preset-editor.js +3 -4
- package/lib/types/preset-transfer.d.ts +1 -1
- package/lib/types/presets.d.ts +21 -23
- package/lib/types/presets.js +72 -36
- package/lib/types/team-catalog.d.ts +50 -3
- package/lib/types/team-catalog.js +214 -43
- package/lib/types/team-mode.d.ts +48 -0
- package/lib/types/team-mode.js +64 -0
- package/lib/types/team-skills/import.d.ts +17 -7
- package/lib/types/team-skills/import.js +115 -21
- package/lib/types/team-skills/index.d.ts +2 -3
- package/lib/types/team-skills/index.js +4 -8
- package/lib/types/team-skills/manager.d.ts +24 -15
- package/lib/types/team-skills/manager.js +98 -105
- package/lib/types/team-skills/official-bindings.d.ts +29 -0
- package/lib/types/team-skills/official-bindings.js +51 -0
- package/lib/types/team-skills/service.d.ts +7 -12
- package/lib/types/team-skills/service.js +143 -63
- package/lib/types/team-skills/store.d.ts +27 -6
- package/lib/types/team-skills/store.js +151 -15
- package/lib/types/types.d.ts +18 -4
- package/package.json +21 -2
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @module dsh-agent-team-presets/team-skills/import
|
|
15
15
|
*/
|
|
16
16
|
import { inflateRawSync } from 'node:zlib';
|
|
17
|
-
import { parseDocument } from 'yaml';
|
|
17
|
+
import { isAlias, isMap, isScalar, parseDocument, stringify } from 'yaml';
|
|
18
18
|
import { MAX_SKILL_FILE_BYTES, checkFolder, normalizeSkillPath, SkillPathError, } from "./paths.js";
|
|
19
19
|
/** The instruction file every Team Skill must carry. */
|
|
20
20
|
export const SKILL_FILE = 'SKILL.md';
|
|
@@ -22,36 +22,54 @@ export const SKILL_FILE = 'SKILL.md';
|
|
|
22
22
|
export const MAX_ZIP_BYTES = 64 * 1024 * 1024;
|
|
23
23
|
/** Most entries one ZIP may declare. */
|
|
24
24
|
export const MAX_ZIP_ENTRIES = 4000;
|
|
25
|
+
const DEPENDENCY_FRONTMATTER_FIELDS = ['executables', 'mcpServers', 'otherSkills'];
|
|
25
26
|
/** The kebab-case grammar the official skill registry enforces. */
|
|
26
27
|
const SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* `metadata`, `allowed-tools`, an unknown vendor key — stays in the file
|
|
33
|
-
* untouched, because the document is portable and this reader is one consumer.
|
|
34
|
-
* @param text - the whole document.
|
|
35
|
-
* @returns the two required fields, or undefined when the fence is absent.
|
|
36
|
-
*/
|
|
37
|
-
export function parseSkillFrontmatter(text) {
|
|
38
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(text);
|
|
39
|
-
if (match?.[1] === undefined)
|
|
28
|
+
/** Read the frontmatter and retain the location of the YAML source. */
|
|
29
|
+
function readSkillFrontmatter(text, keepSourceTokens = false) {
|
|
30
|
+
const match = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/du.exec(text);
|
|
31
|
+
const range = match?.indices?.[1];
|
|
32
|
+
if (match?.[1] === undefined || range === undefined)
|
|
40
33
|
return undefined;
|
|
41
34
|
try {
|
|
42
|
-
const document = parseDocument(match[1], { uniqueKeys: true });
|
|
35
|
+
const document = parseDocument(match[1], { uniqueKeys: true, keepSourceTokens });
|
|
43
36
|
if (document.errors.length > 0)
|
|
44
37
|
return undefined;
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
38
|
+
const value = document.toJS({ maxAliasCount: 100 });
|
|
39
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
47
40
|
return undefined;
|
|
48
|
-
const
|
|
49
|
-
return {
|
|
41
|
+
const fields = value;
|
|
42
|
+
return {
|
|
43
|
+
document,
|
|
44
|
+
yamlStart: range[0],
|
|
45
|
+
name: typeof fields['name'] === 'string' ? fields['name'] : '',
|
|
46
|
+
description: typeof fields['description'] === 'string' ? fields['description'] : '',
|
|
47
|
+
};
|
|
50
48
|
}
|
|
51
49
|
catch {
|
|
52
50
|
return undefined;
|
|
53
51
|
}
|
|
54
52
|
}
|
|
53
|
+
/** Find an explicitly written top-level field without following YAML merges. */
|
|
54
|
+
function explicitField(document, field) {
|
|
55
|
+
if (!isMap(document.contents))
|
|
56
|
+
return undefined;
|
|
57
|
+
return document.contents.items.findLast(({ key }) => {
|
|
58
|
+
const resolved = isAlias(key) ? key.resolve(document) : key;
|
|
59
|
+
return isScalar(resolved) && resolved.value === field;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parse the two required Agent Skills fields from `SKILL.md`.
|
|
64
|
+
* @param text - the whole document.
|
|
65
|
+
* @returns the required fields, or undefined when the frontmatter cannot be parsed.
|
|
66
|
+
*/
|
|
67
|
+
export function parseSkillFrontmatter(text) {
|
|
68
|
+
const frontmatter = readSkillFrontmatter(text);
|
|
69
|
+
if (frontmatter === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
return { name: frontmatter.name, description: frontmatter.description };
|
|
72
|
+
}
|
|
55
73
|
/**
|
|
56
74
|
* Validate one decoded folder as a Team Skill.
|
|
57
75
|
*
|
|
@@ -83,18 +101,21 @@ export function buildSkillPackage(input) {
|
|
|
83
101
|
return { ok: false, reason: 'missing-skill-file', path: SKILL_FILE };
|
|
84
102
|
let text;
|
|
85
103
|
try {
|
|
86
|
-
text = new TextDecoder('utf-8', { fatal: true }).decode(instruction.bytes);
|
|
104
|
+
text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(instruction.bytes);
|
|
87
105
|
}
|
|
88
106
|
catch {
|
|
89
107
|
return { ok: false, reason: 'invalid-frontmatter', path: SKILL_FILE };
|
|
90
108
|
}
|
|
91
|
-
const frontmatter =
|
|
109
|
+
const frontmatter = readSkillFrontmatter(text);
|
|
92
110
|
if (frontmatter === undefined)
|
|
93
111
|
return { ok: false, reason: 'invalid-frontmatter', path: SKILL_FILE };
|
|
94
112
|
if (!SKILL_NAME.test(frontmatter.name))
|
|
95
113
|
return { ok: false, reason: 'invalid-name', path: SKILL_FILE };
|
|
96
114
|
if (frontmatter.description.trim() === '')
|
|
97
115
|
return { ok: false, reason: 'missing-description', path: SKILL_FILE };
|
|
116
|
+
const dependencyWarnings = DEPENDENCY_FRONTMATTER_FIELDS
|
|
117
|
+
.filter(field => explicitField(frontmatter.document, field) !== undefined)
|
|
118
|
+
.map(field => ({ code: 'unsupported-dependency-frontmatter', field }));
|
|
98
119
|
const totalBytes = ordered.reduce((sum, file) => sum + file.bytes.byteLength, 0);
|
|
99
120
|
const warnings = [];
|
|
100
121
|
// Advisory only: a script is legitimate content, and refusing it would break
|
|
@@ -108,8 +129,81 @@ export function buildSkillPackage(input) {
|
|
|
108
129
|
ok: true,
|
|
109
130
|
skill: { name: frontmatter.name, description: frontmatter.description, files: ordered, totalBytes },
|
|
110
131
|
warnings,
|
|
132
|
+
dependencyWarnings,
|
|
111
133
|
};
|
|
112
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Rename an already validated Team Skill package for a new copy.
|
|
137
|
+
* @param package_ - the source package, whose files are left intact.
|
|
138
|
+
* @param name - the new kebab-case name.
|
|
139
|
+
* @returns the renamed package, with only the instruction file changed.
|
|
140
|
+
*/
|
|
141
|
+
export function renameSkillPackage(package_, name) {
|
|
142
|
+
if (!SKILL_NAME.test(name))
|
|
143
|
+
throw new Error(`invalid Team Skill name: ${name}`);
|
|
144
|
+
const instruction = package_.files.find(file => file.path === SKILL_FILE);
|
|
145
|
+
if (instruction === undefined)
|
|
146
|
+
throw new Error(`missing ${SKILL_FILE}`);
|
|
147
|
+
const text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(instruction.bytes);
|
|
148
|
+
const frontmatter = readSkillFrontmatter(text, true);
|
|
149
|
+
if (frontmatter === undefined || !SKILL_NAME.test(frontmatter.name))
|
|
150
|
+
throw new Error(`invalid skill name in ${SKILL_FILE}`);
|
|
151
|
+
if (frontmatter.name === name && package_.name === name)
|
|
152
|
+
return package_;
|
|
153
|
+
const { document, yamlStart } = frontmatter;
|
|
154
|
+
const node = explicitField(document, 'name')?.value;
|
|
155
|
+
let replacement = stringify(name, { version: document.directives.yaml.version }).trimEnd();
|
|
156
|
+
let start;
|
|
157
|
+
let end;
|
|
158
|
+
if ((isScalar(node) || isAlias(node)) && node.range !== undefined) {
|
|
159
|
+
[start, end] = node.range;
|
|
160
|
+
}
|
|
161
|
+
else if (isMap(document.contents) && document.contents.range !== undefined) {
|
|
162
|
+
// A YAML merge can supply the name. Override it without editing the anchor.
|
|
163
|
+
start = document.contents.range[0];
|
|
164
|
+
if (document.contents.flow) {
|
|
165
|
+
start += 1;
|
|
166
|
+
replacement = `name: ${replacement}, `;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
const keyStart = yamlStart + start;
|
|
170
|
+
const lineStart = text.lastIndexOf('\n', keyStart - 1) + 1;
|
|
171
|
+
const indent = text.slice(lineStart, keyStart);
|
|
172
|
+
const newline = text[lineStart - 2] === '\r' ? '\r\n' : '\n';
|
|
173
|
+
replacement = `name: ${replacement}${newline}${indent}`;
|
|
174
|
+
}
|
|
175
|
+
end = start;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
throw new Error(`cannot locate name in ${SKILL_FILE}`);
|
|
179
|
+
}
|
|
180
|
+
if (isScalar(node) && node.srcToken?.type === 'block-scalar') {
|
|
181
|
+
// Change the one name in the scalar body. Its header can carry a comment.
|
|
182
|
+
const { source } = node.srcToken;
|
|
183
|
+
const offset = source.indexOf(frontmatter.name);
|
|
184
|
+
if (offset < 0)
|
|
185
|
+
throw new Error(`cannot locate name in ${SKILL_FILE}`);
|
|
186
|
+
start = end - source.length + offset;
|
|
187
|
+
end = start + frontmatter.name.length;
|
|
188
|
+
replacement = name;
|
|
189
|
+
}
|
|
190
|
+
else if (isScalar(node) && node.type === 'QUOTE_SINGLE') {
|
|
191
|
+
replacement = `'${name}'`;
|
|
192
|
+
}
|
|
193
|
+
else if (isScalar(node) && node.type === 'QUOTE_DOUBLE') {
|
|
194
|
+
replacement = JSON.stringify(name);
|
|
195
|
+
}
|
|
196
|
+
const renamed = text.slice(0, yamlStart + start) + replacement + text.slice(yamlStart + end);
|
|
197
|
+
const files = package_.files.map(file => file === instruction
|
|
198
|
+
? { path: file.path, bytes: new TextEncoder().encode(renamed) }
|
|
199
|
+
: file);
|
|
200
|
+
const result = buildSkillPackage(files);
|
|
201
|
+
if (!result.ok)
|
|
202
|
+
throw new Error(`invalid renamed Team Skill: ${result.reason}`);
|
|
203
|
+
if (result.skill.name !== name)
|
|
204
|
+
throw new Error(`could not rename ${SKILL_FILE} to ${name}`);
|
|
205
|
+
return result.skill;
|
|
206
|
+
}
|
|
113
207
|
/**
|
|
114
208
|
* Read the central directory of one ZIP archive.
|
|
115
209
|
*
|
|
@@ -45,10 +45,9 @@ export interface AgentSkillSync {
|
|
|
45
45
|
*/
|
|
46
46
|
readonly assigned: number | undefined;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
export declare const OFFICIAL_SKILL_IDS: readonly ["github-repository-presentation", "git-release-hygiene", "grilling", "research"];
|
|
48
|
+
export { OFFICIAL_SKILL_IDS } from './official-bindings.ts';
|
|
50
49
|
/** Version stamped on the shipped assets; bumped when the packaged copies change. */
|
|
51
|
-
export declare const OFFICIAL_SKILL_VERSION = "
|
|
50
|
+
export declare const OFFICIAL_SKILL_VERSION = "5";
|
|
52
51
|
/**
|
|
53
52
|
* Resolve the private Team Skill root.
|
|
54
53
|
* @param configured - an explicit `skillRoot` from the plugin config, when set.
|
|
@@ -19,18 +19,13 @@ import { dirname, join } from 'node:path';
|
|
|
19
19
|
import { fileURLToPath } from 'node:url';
|
|
20
20
|
import { readdir } from 'node:fs/promises';
|
|
21
21
|
import { TeamSkillManager, CAPTAIN_ROLE } from "./manager.js";
|
|
22
|
+
import { OFFICIAL_SKILL_IDS } from "./official-bindings.js";
|
|
22
23
|
import { TeamSkillRuntime } from "./provider.js";
|
|
23
24
|
import { TeamSkillStore } from "./store.js";
|
|
24
25
|
import { memberTargets } from "../presets.js";
|
|
25
|
-
|
|
26
|
-
export const OFFICIAL_SKILL_IDS = [
|
|
27
|
-
'github-repository-presentation',
|
|
28
|
-
'git-release-hygiene',
|
|
29
|
-
'grilling',
|
|
30
|
-
'research',
|
|
31
|
-
];
|
|
26
|
+
export { OFFICIAL_SKILL_IDS } from "./official-bindings.js";
|
|
32
27
|
/** Version stamped on the shipped assets; bumped when the packaged copies change. */
|
|
33
|
-
export const OFFICIAL_SKILL_VERSION = '
|
|
28
|
+
export const OFFICIAL_SKILL_VERSION = '5';
|
|
34
29
|
/**
|
|
35
30
|
* Resolve the private Team Skill root.
|
|
36
31
|
* @param configured - an explicit `skillRoot` from the plugin config, when set.
|
|
@@ -142,6 +137,7 @@ export class TeamSkills {
|
|
|
142
137
|
}
|
|
143
138
|
this.official = entries.map(entry => entry.skillId);
|
|
144
139
|
const warnings = [];
|
|
140
|
+
await this.store.renameLegacyCopies(OFFICIAL_SKILL_IDS);
|
|
145
141
|
const changed = await this.store.ensureOfficial(entries, warnings);
|
|
146
142
|
for (const warning of warnings)
|
|
147
143
|
log(warning);
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
import type { TeamSkillAsset, TeamSkillBinding, TeamSkillBindingSummary, TeamSkillDeleteBlocker } from '../types.ts';
|
|
21
21
|
import type { TeamPreset } from '../types.ts';
|
|
22
22
|
import type { TeamSkillStore } from './store.ts';
|
|
23
|
-
|
|
24
|
-
export declare const CAPTAIN_ROLE = "captain";
|
|
23
|
+
export { CAPTAIN_ROLE } from './official-bindings.ts';
|
|
25
24
|
/** What the manager needs from the rest of the plugin to answer a delete. */
|
|
26
25
|
export interface TeamSkillGuardContext {
|
|
27
26
|
/** Teams the page currently shows, for dependency labels. */
|
|
@@ -50,6 +49,17 @@ export interface TeamSkillDeleteOutcome {
|
|
|
50
49
|
readonly warnings: readonly string[];
|
|
51
50
|
}
|
|
52
51
|
/** The Team Skill library plus its role bindings. */
|
|
52
|
+
/**
|
|
53
|
+
* Whether two assets are the shipped copy and its own editable copy.
|
|
54
|
+
*
|
|
55
|
+
* They share a name because they ARE the same skill: the override is the shipped
|
|
56
|
+
* body with the user's edits. Presenting that pair as a name clash made an
|
|
57
|
+
* ordinary "I made a local copy" state read as a defect.
|
|
58
|
+
* @param left - one asset.
|
|
59
|
+
* @param right - the other asset.
|
|
60
|
+
* @returns true when one is the shipped copy and the other its override.
|
|
61
|
+
*/
|
|
62
|
+
export declare function sanctionedCopy(left: TeamSkillAsset, right: TeamSkillAsset): boolean;
|
|
53
63
|
export declare class TeamSkillManager {
|
|
54
64
|
private readonly store;
|
|
55
65
|
private bindings;
|
|
@@ -90,7 +100,7 @@ export declare class TeamSkillManager {
|
|
|
90
100
|
assetId: string;
|
|
91
101
|
captain?: boolean;
|
|
92
102
|
}): Promise<TeamSkillAssignResult>;
|
|
93
|
-
/** Replace existing shipped
|
|
103
|
+
/** Replace only existing bindings to the shipped skill after an explicit switch. */
|
|
94
104
|
replaceBuiltinBindings(skillId: string, overrideId: string): Promise<number>;
|
|
95
105
|
/**
|
|
96
106
|
* Remove the assignment of one role slot.
|
|
@@ -132,18 +142,17 @@ export declare class TeamSkillManager {
|
|
|
132
142
|
reconcile(): Promise<void>;
|
|
133
143
|
private reconcileNow;
|
|
134
144
|
/**
|
|
135
|
-
*
|
|
145
|
+
* Move every role holding one asset onto another.
|
|
136
146
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
private seededAssetId;
|
|
147
|
+
* Used by "restore to the built-in version": the roles reading a local copy
|
|
148
|
+
* have to read the shipped one again, or the restore would only change bytes
|
|
149
|
+
* nobody is bound to.
|
|
150
|
+
* @param fromAssetId - asset the roles hold now.
|
|
151
|
+
* @param toAssetId - asset they should hold.
|
|
152
|
+
* @returns the number of bindings moved.
|
|
153
|
+
*/
|
|
154
|
+
replaceAssetBindings(fromAssetId: string, toAssetId: string): Promise<number>;
|
|
155
|
+
private replaceAssetBindingsNow;
|
|
147
156
|
private mutate;
|
|
148
157
|
/**
|
|
149
158
|
* Find text mentions of one skill name inside another asset.
|
|
@@ -206,7 +215,7 @@ export declare class TeamSkillManager {
|
|
|
206
215
|
* and reconcile to restore the official default bindings.
|
|
207
216
|
* @param teamIds - optional list of team identities to restore; defaults to all built-in teams.
|
|
208
217
|
*/
|
|
209
|
-
restoreBuiltinBindings(teamIds?: readonly string[]): Promise<void>;
|
|
218
|
+
restoreBuiltinBindings(teamIds?: readonly string[] | null): Promise<void>;
|
|
210
219
|
/**
|
|
211
220
|
* Persist the bindings document atomically enough for a UI write.
|
|
212
221
|
* @returns after the document is on disk.
|
|
@@ -21,12 +21,12 @@ import { access, readFile, stat } from 'node:fs/promises';
|
|
|
21
21
|
import { delimiter, join } from 'node:path';
|
|
22
22
|
import { atomicWriteJson } from "./store.js";
|
|
23
23
|
import { assertNoSymlinks } from "./paths.js";
|
|
24
|
-
import {
|
|
24
|
+
import { BUILTIN_TEAM_IDS } from "../team-catalog.js";
|
|
25
|
+
import { CAPTAIN_ROLE, isOfficialSkillAsset, isOfficialSkillOverride, officialSkillDefaults, officialSkillTarget } from "./official-bindings.js";
|
|
25
26
|
import { constants } from 'node:fs';
|
|
26
27
|
/** Bindings document revision this build understands. */
|
|
27
28
|
const BINDINGS_VERSION = 1;
|
|
28
|
-
|
|
29
|
-
export const CAPTAIN_ROLE = 'captain';
|
|
29
|
+
export { CAPTAIN_ROLE } from "./official-bindings.js";
|
|
30
30
|
/** Windows executable extensions assumed when PATHEXT is unset. */
|
|
31
31
|
const DEFAULT_PATHEXT = '.COM;.EXE;.BAT;.CMD';
|
|
32
32
|
/**
|
|
@@ -92,6 +92,20 @@ function seedOwner(key) {
|
|
|
92
92
|
return undefined;
|
|
93
93
|
}
|
|
94
94
|
/** The Team Skill library plus its role bindings. */
|
|
95
|
+
/**
|
|
96
|
+
* Whether two assets are the shipped copy and its own editable copy.
|
|
97
|
+
*
|
|
98
|
+
* They share a name because they ARE the same skill: the override is the shipped
|
|
99
|
+
* body with the user's edits. Presenting that pair as a name clash made an
|
|
100
|
+
* ordinary "I made a local copy" state read as a defect.
|
|
101
|
+
* @param left - one asset.
|
|
102
|
+
* @param right - the other asset.
|
|
103
|
+
* @returns true when one is the shipped copy and the other its override.
|
|
104
|
+
*/
|
|
105
|
+
export function sanctionedCopy(left, right) {
|
|
106
|
+
return (left.origin === 'builtin' && right.origin === 'override' && right.officialSkillId === left.skillId)
|
|
107
|
+
|| (right.origin === 'builtin' && left.origin === 'override' && left.officialSkillId === right.skillId);
|
|
108
|
+
}
|
|
95
109
|
export class TeamSkillManager {
|
|
96
110
|
store;
|
|
97
111
|
bindings = [];
|
|
@@ -179,40 +193,14 @@ export class TeamSkillManager {
|
|
|
179
193
|
return { ok: true, binding, unverified: blockers.unverified };
|
|
180
194
|
}));
|
|
181
195
|
}
|
|
182
|
-
/** Replace existing shipped
|
|
196
|
+
/** Replace only existing bindings to the shipped skill after an explicit switch. */
|
|
183
197
|
async replaceBuiltinBindings(skillId, overrideId) {
|
|
184
198
|
return this.mutate(() => this.store.withLock(async () => {
|
|
185
199
|
const replacement = this.store.get(overrideId);
|
|
186
200
|
if (replacement?.origin !== 'override' || replacement.officialSkillId !== skillId) {
|
|
187
201
|
throw new Error('replacement must be an override of the shipped skill');
|
|
188
202
|
}
|
|
189
|
-
|
|
190
|
-
let replaced = 0;
|
|
191
|
-
const seen = new Set();
|
|
192
|
-
const next = [];
|
|
193
|
-
for (const binding of this.bindings) {
|
|
194
|
-
// A role already using another explicit override keeps that choice.
|
|
195
|
-
const hasOtherOverride = binding.assetId === builtinId && this.bindings.some(other => {
|
|
196
|
-
if (other.teamId !== binding.teamId || other.roleId !== binding.roleId || other.assetId === overrideId)
|
|
197
|
-
return false;
|
|
198
|
-
const asset = this.store.get(other.assetId);
|
|
199
|
-
return asset?.origin === 'override' && asset.officialSkillId === skillId;
|
|
200
|
-
});
|
|
201
|
-
const convert = binding.assetId === builtinId && !hasOtherOverride;
|
|
202
|
-
const row = convert ? { ...binding, assetId: overrideId } : binding;
|
|
203
|
-
if (convert)
|
|
204
|
-
replaced += 1;
|
|
205
|
-
const key = JSON.stringify([row.teamId, row.roleId, row.assetId]);
|
|
206
|
-
if (row.assetId !== overrideId || !seen.has(key))
|
|
207
|
-
next.push(row);
|
|
208
|
-
if (row.assetId === overrideId)
|
|
209
|
-
seen.add(key);
|
|
210
|
-
}
|
|
211
|
-
if (replaced === 0)
|
|
212
|
-
return 0;
|
|
213
|
-
this.bindings = next;
|
|
214
|
-
await this.flush();
|
|
215
|
-
return replaced;
|
|
203
|
+
return this.replaceAssetBindingsNow(`builtin:${skillId}`, overrideId);
|
|
216
204
|
}));
|
|
217
205
|
}
|
|
218
206
|
/**
|
|
@@ -360,91 +348,72 @@ export class TeamSkillManager {
|
|
|
360
348
|
return owner !== undefined && this.hasRole(owner[0], owner[1]);
|
|
361
349
|
}));
|
|
362
350
|
for (const team of teams) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
// Local user teams and imported documents keep their own declaration.
|
|
367
|
-
const declarations = BUILTIN_TEAM_CATALOG.find(entry => entry.id === team.id)?.officialSkillBindings
|
|
368
|
-
?? team.officialSkills
|
|
369
|
-
?? [];
|
|
370
|
-
for (const declaration of declarations) {
|
|
371
|
-
// A declared role name addresses the captain slot or one member, never
|
|
372
|
-
// both. `CAPTAIN_ROLE` is a sentinel rather than a role name, so a
|
|
373
|
-
// member whose own stored identity happens to read as that sentinel
|
|
374
|
-
// cannot be addressed without also matching the captain: the
|
|
375
|
-
// declaration is dropped instead of being granted to the captain's
|
|
376
|
-
// slot, because a member's default skill appearing on the captain is
|
|
377
|
-
// exactly the role leak this table exists to prevent.
|
|
378
|
-
const isCaptain = team.captain.name === declaration.roleName;
|
|
379
|
-
const member = isCaptain ? undefined : team.members.find(member => member.name === declaration.roleName);
|
|
380
|
-
const memberRole = member === undefined ? undefined : member.id ?? member.name;
|
|
381
|
-
const roleId = isCaptain ? CAPTAIN_ROLE : memberRole === CAPTAIN_ROLE ? undefined : memberRole;
|
|
382
|
-
if (roleId === undefined)
|
|
351
|
+
for (const declaration of officialSkillDefaults(team).declarations) {
|
|
352
|
+
const target = officialSkillTarget(team, declaration);
|
|
353
|
+
if (target.status !== 'valid')
|
|
383
354
|
continue;
|
|
384
|
-
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
// resolved to: an override can appear or disappear between restarts,
|
|
397
|
-
// and a key that followed it would stop matching the marker a user's
|
|
398
|
-
// explicit unbind wrote, resurrecting a default they removed.
|
|
399
|
-
const key = JSON.stringify([team.id, roleId, `builtin:${declaration.skillId}`]);
|
|
400
|
-
const already = this.seeded.has(key);
|
|
401
|
-
// A role that still holds the shipped copy of a default, in a deployment
|
|
402
|
-
// that now has an override for it, is moved onto that override: the
|
|
403
|
-
// marker records that the default was offered, not which copy it landed
|
|
404
|
-
// on, so it must not pin a role to a body the user has replaced. Only
|
|
405
|
-
// this exact pair is migrated — a role holding a different asset (an
|
|
406
|
-
// explicit choice, or another override) is left alone.
|
|
407
|
-
if (already) {
|
|
408
|
-
const builtinId = `builtin:${declaration.skillId}`;
|
|
409
|
-
if (assetId !== builtinId) {
|
|
410
|
-
const stale = this.bindings.findIndex(row => row.teamId === team.id && row.roleId === roleId && row.assetId === builtinId);
|
|
411
|
-
if (stale >= 0) {
|
|
412
|
-
this.bindings[stale] = { teamId: team.id, roleId, assetId, ...(roleId === CAPTAIN_ROLE ? { captain: true } : {}) };
|
|
413
|
-
}
|
|
414
|
-
}
|
|
355
|
+
const { roleId, assetId } = target;
|
|
356
|
+
// The marker follows the declaration across changes to local copies.
|
|
357
|
+
const key = JSON.stringify([team.id, roleId, assetId]);
|
|
358
|
+
const holdsSkill = this.bindings.some(row => {
|
|
359
|
+
if (row.teamId !== team.id || row.roleId !== roleId)
|
|
360
|
+
return false;
|
|
361
|
+
const asset = this.store.get(row.assetId);
|
|
362
|
+
return asset !== undefined && (isOfficialSkillAsset(asset, assetId)
|
|
363
|
+
|| isOfficialSkillOverride(asset, declaration.skillId));
|
|
364
|
+
});
|
|
365
|
+
if (holdsSkill) {
|
|
366
|
+
this.seeded.add(key);
|
|
415
367
|
continue;
|
|
416
368
|
}
|
|
369
|
+
const shipped = this.store.get(assetId);
|
|
370
|
+
if (shipped === undefined || !isOfficialSkillAsset(shipped, assetId))
|
|
371
|
+
continue;
|
|
372
|
+
// The marker means "this default was offered and the user removed it",
|
|
373
|
+
// so re-adding would resurrect an explicit unbind. The paths that DO
|
|
374
|
+
// return a missing default -- deleting the copy, restoring it -- clear
|
|
375
|
+
// the marker themselves before reconciling.
|
|
376
|
+
if (this.seeded.has(key))
|
|
377
|
+
continue;
|
|
417
378
|
this.seeded.add(key);
|
|
418
|
-
|
|
419
|
-
this.bindings.push({ teamId: team.id, roleId, assetId, ...(roleId === CAPTAIN_ROLE ? { captain: true } : {}) });
|
|
420
|
-
}
|
|
379
|
+
this.bindings.push({ teamId: team.id, roleId, assetId, ...(roleId === CAPTAIN_ROLE ? { captain: true } : {}) });
|
|
421
380
|
}
|
|
422
381
|
}
|
|
423
382
|
if (JSON.stringify([this.bindings, [...this.seeded]]) !== before)
|
|
424
383
|
await this.flush();
|
|
425
384
|
}
|
|
426
385
|
/**
|
|
427
|
-
*
|
|
386
|
+
* Move every role holding one asset onto another.
|
|
428
387
|
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
* @param skillId - shipped skill identity the default names.
|
|
436
|
-
* @returns the asset identity to bind, or undefined when neither copy exists.
|
|
388
|
+
* Used by "restore to the built-in version": the roles reading a local copy
|
|
389
|
+
* have to read the shipped one again, or the restore would only change bytes
|
|
390
|
+
* nobody is bound to.
|
|
391
|
+
* @param fromAssetId - asset the roles hold now.
|
|
392
|
+
* @param toAssetId - asset they should hold.
|
|
393
|
+
* @returns the number of bindings moved.
|
|
437
394
|
*/
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
395
|
+
async replaceAssetBindings(fromAssetId, toAssetId) {
|
|
396
|
+
return this.mutate(() => this.replaceAssetBindingsNow(fromAssetId, toAssetId));
|
|
397
|
+
}
|
|
398
|
+
async replaceAssetBindingsNow(fromAssetId, toAssetId) {
|
|
399
|
+
if (fromAssetId === toAssetId || this.store.get(toAssetId) === undefined)
|
|
400
|
+
return 0;
|
|
401
|
+
const moved = this.bindings.filter(row => row.assetId === fromAssetId).length;
|
|
402
|
+
if (moved === 0)
|
|
403
|
+
return 0;
|
|
404
|
+
const seen = new Set();
|
|
405
|
+
this.bindings = this.bindings.flatMap((binding) => {
|
|
406
|
+
const row = binding.assetId === fromAssetId ? { ...binding, assetId: toAssetId } : binding;
|
|
407
|
+
if (row.assetId !== toAssetId)
|
|
408
|
+
return [row];
|
|
409
|
+
const key = JSON.stringify([row.teamId, row.roleId]);
|
|
410
|
+
if (seen.has(key))
|
|
411
|
+
return [];
|
|
412
|
+
seen.add(key);
|
|
413
|
+
return [row];
|
|
414
|
+
});
|
|
415
|
+
await this.flush();
|
|
416
|
+
return moved;
|
|
448
417
|
}
|
|
449
418
|
mutate(operation) {
|
|
450
419
|
const result = this.pending.then(async () => {
|
|
@@ -576,12 +545,36 @@ export class TeamSkillManager {
|
|
|
576
545
|
*/
|
|
577
546
|
async restoreBuiltinBindings(teamIds) {
|
|
578
547
|
return this.mutate(async () => {
|
|
579
|
-
|
|
548
|
+
// "Restore these Teams" with nothing named means all of them: the page
|
|
549
|
+
// calls this without arguments, and a remote call can deliver that absence
|
|
550
|
+
// as `[]`, `null` or an empty object. Treating any of those as a filter is
|
|
551
|
+
// what made the whole restore a silent no-op that still answered 200, so
|
|
552
|
+
// only a real, non-empty array narrows the set.
|
|
553
|
+
const requested = Array.isArray(teamIds) ? teamIds : [];
|
|
554
|
+
const targets = new Set(requested.length === 0 ? BUILTIN_TEAM_IDS : requested);
|
|
580
555
|
this.seeded = new Set([...this.seeded].filter(key => {
|
|
581
556
|
const owner = seedOwner(key);
|
|
582
557
|
return owner === undefined || !targets.has(owner[0]);
|
|
583
558
|
}));
|
|
559
|
+
// "Restore built-in presets" restores the shipped defaults, which are the
|
|
560
|
+
// shipped skills. A role still reading an override of a declared skill is
|
|
561
|
+
// returned to the shipped copy, or the restore would leave the visible
|
|
562
|
+
// binding on the user's own asset and look like it did nothing.
|
|
563
|
+
this.bindings = this.bindings.map((row) => {
|
|
564
|
+
if (!targets.has(row.teamId))
|
|
565
|
+
return row;
|
|
566
|
+
const asset = this.store.get(row.assetId);
|
|
567
|
+
if (asset?.origin !== 'override' || asset.officialSkillId === undefined)
|
|
568
|
+
return row;
|
|
569
|
+
const builtinId = `builtin:${asset.officialSkillId}`;
|
|
570
|
+
return this.store.get(builtinId) === undefined ? row : { ...row, assetId: builtinId };
|
|
571
|
+
});
|
|
584
572
|
await this.reconcileNow();
|
|
573
|
+
// `reconcileNow` flushes only when IT changed something. The conversion
|
|
574
|
+
// above already mutated the list, so its own before/after reads as "no
|
|
575
|
+
// change" and nothing would reach the disk: the restore appeared to do
|
|
576
|
+
// nothing, and the next restart brought the old bindings back.
|
|
577
|
+
await this.flush();
|
|
585
578
|
});
|
|
586
579
|
}
|
|
587
580
|
/**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OfficialSkillBinding } from '../team-catalog.ts';
|
|
2
|
+
import type { TeamPreset } from '../types.ts';
|
|
3
|
+
/** Skills shipped under `assets/skills`, including assets missing from this installation. */
|
|
4
|
+
export declare const OFFICIAL_SKILL_IDS: readonly ["agent-leader-communication", "leader-medium-task-workflow", "leader-long-task-orchestration", "agent-subagent-orchestration", "fullstack-advisor", "executor-short-task-workflow", "github-repository-presentation", "git-release-hygiene", "frontend-engineering-workflow", "backend-architecture-workflow", "independent-code-review-workflow", "grilling", "research"];
|
|
5
|
+
/** The binding slot reserved for a captain. */
|
|
6
|
+
export declare const CAPTAIN_ROLE = "captain";
|
|
7
|
+
/** Shipped identities always use the catalog, including records from earlier releases. */
|
|
8
|
+
export declare function officialSkillDefaults(team: Pick<TeamPreset, 'id' | 'officialSkills'>): {
|
|
9
|
+
readonly source: 'catalog' | 'preset';
|
|
10
|
+
readonly declarations: readonly OfficialSkillBinding[];
|
|
11
|
+
};
|
|
12
|
+
/** A declaration can address only an unambiguous name and an unambiguous binding slot. */
|
|
13
|
+
export declare function officialSkillTarget(team: Pick<TeamPreset, 'captain' | 'members'>, declaration: OfficialSkillBinding): {
|
|
14
|
+
readonly status: 'valid';
|
|
15
|
+
readonly roleId: string;
|
|
16
|
+
readonly assetId: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly status: 'unknown-skill' | 'missing-role' | 'ambiguous-role';
|
|
19
|
+
};
|
|
20
|
+
/** A default can seed only the shipped asset with the declared identity. */
|
|
21
|
+
export declare function isOfficialSkillAsset(asset: {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly origin: string;
|
|
24
|
+
}, assetId: string): boolean;
|
|
25
|
+
/** A role that already holds a derived override keeps its explicit assignment. */
|
|
26
|
+
export declare function isOfficialSkillOverride(asset: {
|
|
27
|
+
readonly origin: string;
|
|
28
|
+
readonly officialSkillId?: string;
|
|
29
|
+
}, skillId: string): boolean;
|