cognitive-core 0.2.2 → 0.2.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/dist/surfacing/skill-publisher.d.ts.map +1 -1
- package/dist/surfacing/skill-publisher.js +74 -23
- package/dist/surfacing/skill-publisher.js.map +1 -1
- package/dist/types/playbook.d.ts +11 -0
- package/dist/types/playbook.d.ts.map +1 -1
- package/dist/types/playbook.js +2 -0
- package/dist/types/playbook.js.map +1 -1
- package/dist/workspace/templates/index.d.ts +1 -0
- package/dist/workspace/templates/index.d.ts.map +1 -1
- package/dist/workspace/templates/index.js +2 -0
- package/dist/workspace/templates/index.js.map +1 -1
- package/dist/workspace/templates/skill-enrichment.d.ts +48 -0
- package/dist/workspace/templates/skill-enrichment.d.ts.map +1 -0
- package/dist/workspace/templates/skill-enrichment.js +175 -0
- package/dist/workspace/templates/skill-enrichment.js.map +1 -0
- package/package.json +5 -5
- package/src/surfacing/skill-publisher.ts +92 -26
- package/src/types/playbook.ts +15 -0
- package/src/workspace/templates/index.ts +7 -0
- package/src/workspace/templates/skill-enrichment.ts +275 -0
- package/tests/surfacing/skill-publisher.test.ts +81 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-publisher.d.ts","sourceRoot":"","sources":["../../src/surfacing/skill-publisher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"skill-publisher.d.ts","sourceRoot":"","sources":["../../src/surfacing/skill-publisher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA2CrE;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CA6GhE;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,YAAY,CAA0B;gBAElC,OAAO,EAAE,cAAc;IAInC;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;IAyBjE;;OAEG;IACG,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAQvE;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAuB/E;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIxC;;OAEG;IACH,iBAAiB,IAAI,MAAM;CAG5B"}
|
|
@@ -6,6 +6,42 @@
|
|
|
6
6
|
* conversion at the publish boundary.
|
|
7
7
|
*/
|
|
8
8
|
import { getPlaybookSuccessRate } from '../types/playbook.js';
|
|
9
|
+
/**
|
|
10
|
+
* Maximum length for the generated `description` field.
|
|
11
|
+
* Claude Code's skill format caps description at 1024 chars, so we truncate
|
|
12
|
+
* to stay safely within that boundary.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
15
|
+
/**
|
|
16
|
+
* Build the `description` field for a published Skill.
|
|
17
|
+
*
|
|
18
|
+
* The description is what lightweight trigger matchers — notably Claude Code's
|
|
19
|
+
* skill loader — key off to decide whether to load a skill. It needs two things:
|
|
20
|
+
*
|
|
21
|
+
* 1. A short "what it does" lead (pulled from the first situation, or the
|
|
22
|
+
* strategy if no situation is set).
|
|
23
|
+
* 2. The concrete trigger phrases, surfaced inline so substring/keyword
|
|
24
|
+
* matchers catch them. These live in `applicability.triggers` on the
|
|
25
|
+
* playbook but are invisible to downstream consumers unless we lift them.
|
|
26
|
+
*
|
|
27
|
+
* Shape: `<lead>. Use when "<t1>", "<t2>", ..., "<tN>".`
|
|
28
|
+
*/
|
|
29
|
+
function buildDescription(playbook) {
|
|
30
|
+
let lead = playbook.applicability.situations[0]
|
|
31
|
+
?? `${playbook.name}: ${playbook.guidance.strategy.slice(0, 100)}`;
|
|
32
|
+
// Ensure a sentence terminator before appending the trigger clause.
|
|
33
|
+
if (lead.length > 0 && !/[.!?]$/.test(lead)) {
|
|
34
|
+
lead += '.';
|
|
35
|
+
}
|
|
36
|
+
const triggers = playbook.applicability.triggers;
|
|
37
|
+
const triggerClause = triggers.length > 0
|
|
38
|
+
? ` Use when ${triggers.map((t) => `"${t}"`).join(', ')}.`
|
|
39
|
+
: '';
|
|
40
|
+
const full = lead + triggerClause;
|
|
41
|
+
if (full.length <= MAX_DESCRIPTION_LENGTH)
|
|
42
|
+
return full;
|
|
43
|
+
return full.slice(0, MAX_DESCRIPTION_LENGTH - 3) + '...';
|
|
44
|
+
}
|
|
9
45
|
/**
|
|
10
46
|
* Convert a Playbook to a Skill
|
|
11
47
|
*/
|
|
@@ -20,37 +56,52 @@ export function convertPlaybookToSkill(playbook) {
|
|
|
20
56
|
if (playbook.guidance.steps?.length) {
|
|
21
57
|
solution += '\n\nSteps:\n' + playbook.guidance.steps.map((s, i) => `${i + 1}. ${s}`).join('\n');
|
|
22
58
|
}
|
|
23
|
-
// Build
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
59
|
+
// Build description for semantic matching and lightweight trigger routing
|
|
60
|
+
const description = buildDescription(playbook);
|
|
61
|
+
// Build structured instructions body
|
|
62
|
+
const instructionParts = [];
|
|
63
|
+
// --- When to use / When not to use (Change A) ---
|
|
64
|
+
if (playbook.applicability.situations.length > 0) {
|
|
65
|
+
instructionParts.push('## When to use\n\n'
|
|
66
|
+
+ playbook.applicability.situations.map((s) => `- ${s}`).join('\n'));
|
|
67
|
+
}
|
|
29
68
|
if (playbook.applicability.antiPatterns.length > 0) {
|
|
30
|
-
|
|
69
|
+
instructionParts.push('## When not to use\n\n'
|
|
70
|
+
+ playbook.applicability.antiPatterns.map((a) => `- ${a}`).join('\n'));
|
|
31
71
|
}
|
|
32
|
-
|
|
33
|
-
|
|
72
|
+
// --- Solution ---
|
|
73
|
+
instructionParts.push(`## Solution\n\n${solution}`);
|
|
74
|
+
// --- Verification with bulleted indicators (Change B) ---
|
|
75
|
+
const verificationParts = [];
|
|
76
|
+
if (playbook.verification.successIndicators.length > 0) {
|
|
77
|
+
verificationParts.push('Success:\n'
|
|
78
|
+
+ playbook.verification.successIndicators.map((s) => `- ${s}`).join('\n'));
|
|
34
79
|
}
|
|
35
|
-
if (playbook.
|
|
36
|
-
|
|
80
|
+
if (playbook.verification.failureIndicators.length > 0) {
|
|
81
|
+
verificationParts.push('Failure:\n'
|
|
82
|
+
+ playbook.verification.failureIndicators.map((f) => `- ${f}`).join('\n'));
|
|
37
83
|
}
|
|
38
84
|
if (playbook.verification.rollbackStrategy) {
|
|
39
|
-
|
|
85
|
+
verificationParts.push(`Rollback: ${playbook.verification.rollbackStrategy}`);
|
|
86
|
+
}
|
|
87
|
+
if (verificationParts.length > 0) {
|
|
88
|
+
instructionParts.push(`## Verification\n\n${verificationParts.join('\n\n')}`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
instructionParts.push('## Verification\n\nVerify the approach worked as expected.');
|
|
92
|
+
}
|
|
93
|
+
// --- Notes (refinements only — anti-patterns now in their own section) ---
|
|
94
|
+
const notesParts = [];
|
|
95
|
+
if (playbook.evolution.refinements.length > 0) {
|
|
96
|
+
notesParts.push('Refinements:\n'
|
|
97
|
+
+ playbook.evolution.refinements.map((r) => `- In ${r.context}: ${r.addition}`).join('\n'));
|
|
40
98
|
}
|
|
41
|
-
// Build description for semantic matching
|
|
42
|
-
const description = playbook.applicability.situations[0]
|
|
43
|
-
?? `${playbook.name}: ${playbook.guidance.strategy.slice(0, 100)}`;
|
|
44
|
-
// Build instructions as structured markdown combining all content
|
|
45
|
-
const instructionParts = [];
|
|
46
|
-
instructionParts.push(`## Problem\n${playbook.applicability.situations.join('. ')}`);
|
|
47
|
-
instructionParts.push(`## Solution\n${solution}`);
|
|
48
|
-
instructionParts.push(`## Verification\n${verification}`);
|
|
49
99
|
if (notesParts.length > 0) {
|
|
50
|
-
instructionParts.push(`## Notes\n${notesParts.join('\n\n')}`);
|
|
100
|
+
instructionParts.push(`## Notes\n\n${notesParts.join('\n\n')}`);
|
|
51
101
|
}
|
|
102
|
+
// --- Example ---
|
|
52
103
|
if (playbook.guidance.codeExample) {
|
|
53
|
-
instructionParts.push(`## Example\n\`\`\`\n${playbook.guidance.codeExample}\n\`\`\``);
|
|
104
|
+
instructionParts.push(`## Example\n\n\`\`\`\n${playbook.guidance.codeExample}\n\`\`\``);
|
|
54
105
|
}
|
|
55
106
|
const instructions = instructionParts.join('\n\n');
|
|
56
107
|
// Estimate tokens (rough: 4 chars per token)
|
|
@@ -61,7 +112,7 @@ export function convertPlaybookToSkill(playbook) {
|
|
|
61
112
|
version: playbook.evolution.version,
|
|
62
113
|
description,
|
|
63
114
|
instructions,
|
|
64
|
-
author: 'cognitive-core',
|
|
115
|
+
author: playbook.provenance?.curatedBy ?? 'cognitive-core',
|
|
65
116
|
tags: playbook.applicability.domains,
|
|
66
117
|
status: 'active',
|
|
67
118
|
metrics: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-publisher.js","sourceRoot":"","sources":["../../src/surfacing/skill-publisher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;GAEG;AACH,MAAM,UAAU,sBAAsB,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EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,UAAkB;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;IAChC,CAAC;CACF"}
|
package/dist/types/playbook.d.ts
CHANGED
|
@@ -22,6 +22,17 @@ export interface Playbook {
|
|
|
22
22
|
embedding?: number[];
|
|
23
23
|
createdAt: Date;
|
|
24
24
|
updatedAt: Date;
|
|
25
|
+
/**
|
|
26
|
+
* Whether end-users can invoke this skill directly (e.g. via /slash-command).
|
|
27
|
+
* Propagated into the published SKILL.md frontmatter as `user-invocable`.
|
|
28
|
+
*/
|
|
29
|
+
userInvocable?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Arbitrary key-value metadata propagated verbatim into the published
|
|
32
|
+
* SKILL.md frontmatter `metadata:` block. Use for ecosystem-specific
|
|
33
|
+
* fields (audience, component, ecosystem) without changing the core schema.
|
|
34
|
+
*/
|
|
35
|
+
publishMetadata?: Record<string, unknown>;
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* When to apply this playbook
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playbook.d.ts","sourceRoot":"","sources":["../../src/types/playbook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IAGb,aAAa,EAAE,qBAAqB,CAAC;IAGrC,QAAQ,EAAE,gBAAgB,CAAC;IAG3B,YAAY,EAAE,oBAAoB,CAAC;IAGnC,SAAS,EAAE,iBAAiB,CA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,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzC,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAEnE;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,qBAAqB,CAAC;IACrC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,GACA,QAAQ,CAgCV;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,IAAI,GAAE,OAAO,GAAG,OAAO,GAAG,OAAiB,GAC1C,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAIjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,MAAU,GAAG,OAAO,CAEjF"}
|
package/dist/types/playbook.js
CHANGED
|
@@ -34,6 +34,8 @@ export function createPlaybook(input) {
|
|
|
34
34
|
complexity: input.complexity ?? 'moderate',
|
|
35
35
|
estimatedEffort: input.estimatedEffort ?? 3,
|
|
36
36
|
embedding: input.embedding,
|
|
37
|
+
userInvocable: input.userInvocable,
|
|
38
|
+
publishMetadata: input.publishMetadata,
|
|
37
39
|
createdAt: input.createdAt ?? now,
|
|
38
40
|
updatedAt: input.updatedAt ?? now,
|
|
39
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playbook.js","sourceRoot":"","sources":["../../src/types/playbook.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"playbook.js","sourceRoot":"","sources":["../../src/types/playbook.ts"],"names":[],"mappings":"AAAA;;;;;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B,EAClB,OAAoC,OAAO;IAE3C,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAChF,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC;QAC5B,KAAK,OAAO;YACV,OAAO,GAAG,KAAK,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC;QACnC,KAAK,OAAO,CAAC;QACb;YACE,OAAO,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;IAC5C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAAkB;IACvD,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC;IAChF,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1B,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAkB,EAAE,UAAkB,CAAC;IACtE,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,YAAY,IAAI,OAAO,CAAC;AACtF,CAAC"}
|
|
@@ -11,4 +11,5 @@ export { teamPlaybookExtractionTemplate, type TeamPlaybookExtractionInput, type
|
|
|
11
11
|
export { playbookEfficacyAuditTemplate, type PlaybookEfficacyAuditInput, type PlaybookEfficacyAuditOutput, type PlaybookRecommendation, } from './playbook-efficacy-audit.js';
|
|
12
12
|
export { playbookDecayDetectionTemplate, type PlaybookDecayDetectionInput, type PlaybookDecayDetectionOutput, type DecaySignal, } from './playbook-decay-detection.js';
|
|
13
13
|
export { playbookLifecycleReviewTemplate, type PlaybookLifecycleReviewInput, type PlaybookLifecycleReviewOutput, type LifecycleRecommendation, } from './playbook-lifecycle-review.js';
|
|
14
|
+
export { skillEnrichmentTemplate, type SkillEnrichmentInput, type SkillEnrichmentOutput, } from './skill-enrichment.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workspace/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,0BAA0B,EAC1B,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,0BAA0B,EAC1B,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,sBAAsB,EACtB,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,0BAA0B,EAC1B,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,0BAA0B,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,GACpB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,2BAA2B,EAC3B,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,uBAAuB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,8BAA8B,EAC9B,KAAK,2BAA2B,GACjC,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,8BAA8B,EAC9B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,6BAA6B,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,2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EACL,6BAA6B,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,GAC5B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,8BAA8B,EAC9B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,WAAW,GACjB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,+BAA+B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,GAC7B,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,uBAAuB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC"}
|
|
@@ -24,4 +24,6 @@ export { playbookEfficacyAuditTemplate, } from './playbook-efficacy-audit.js';
|
|
|
24
24
|
export { playbookDecayDetectionTemplate, } from './playbook-decay-detection.js';
|
|
25
25
|
// Playbook Lifecycle Review (meta-learning — portfolio health)
|
|
26
26
|
export { playbookLifecycleReviewTemplate, } from './playbook-lifecycle-review.js';
|
|
27
|
+
// Skill Enrichment (publish pipeline — agent-enriched SKILL.md generation)
|
|
28
|
+
export { skillEnrichmentTemplate, } from './skill-enrichment.js';
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workspace/templates/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EACL,0BAA0B,GAE3B,MAAM,0BAA0B,CAAC;AAElC,sFAAsF;AACtF,OAAO,EACL,0BAA0B,GAE3B,MAAM,0BAA0B,CAAC;AAElC,6DAA6D;AAC7D,OAAO,EACL,sBAAsB,GAEvB,MAAM,sBAAsB,CAAC;AAE9B,qEAAqE;AACrE,OAAO,EACL,sBAAsB,GAGvB,MAAM,sBAAsB,CAAC;AAE9B,4DAA4D;AAC5D,OAAO,EACL,0BAA0B,GAE3B,MAAM,0BAA0B,CAAC;AAElC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A+B,CAAC;AAEvC,2DAA2D;AAC3D,OAAO,EACL,8BAA8B,GAK/B,MAAM,+BAA+B,CAAC;AAEvC,6DAA6D;AAC7D,OAAO,EACL,6BAA6B,GAI9B,MAAM,8BAA8B,CAAC;AAEtC,qEAAqE;AACrE,OAAO,EACL,8BAA8B,GAI/B,MAAM,+BAA+B,CAAC;AAEvC,+DAA+D;AAC/D,OAAO,EACL,+BAA+B,GAIhC,MAAM,gCAAgC,CAAC;AAExC,2EAA2E;AAC3E,OAAO,EACL,uBAAuB,GAGxB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Enrichment Template
|
|
3
|
+
*
|
|
4
|
+
* Agent-in-the-loop step between playbook extraction and skill publishing.
|
|
5
|
+
* Given a Playbook and its procedurally generated SKILL.md skeleton, an agent
|
|
6
|
+
* enriches the skill with narrative prose, worked examples, cross-references,
|
|
7
|
+
* and a trigger-rich description — things a procedural converter cannot produce.
|
|
8
|
+
*
|
|
9
|
+
* Complexity routing:
|
|
10
|
+
* - Simple playbooks (<=3 tactics, low complexity) → heuristic: keep procedural output as-is
|
|
11
|
+
* - Standard/complex playbooks → agent enrichment
|
|
12
|
+
*/
|
|
13
|
+
import type { Playbook } from '../../types/index.js';
|
|
14
|
+
import type { AgenticTaskTemplate } from '../types.js';
|
|
15
|
+
export interface SkillEnrichmentInput {
|
|
16
|
+
/** The playbook to enrich into a skill */
|
|
17
|
+
playbook: Playbook;
|
|
18
|
+
/** Optional: existing hand-written SKILL.md to use as style reference */
|
|
19
|
+
styleReference?: string;
|
|
20
|
+
/** Optional: related skill names for cross-referencing */
|
|
21
|
+
relatedSkills?: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
}>;
|
|
25
|
+
/** Optional: domain context (e.g. "swarmkit ecosystem", "TypeScript tooling") */
|
|
26
|
+
domainContext?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SkillEnrichmentOutput {
|
|
29
|
+
/** Enriched SKILL.md frontmatter description (trigger-rich, under 1024 chars) */
|
|
30
|
+
description: string;
|
|
31
|
+
/** Enriched markdown body (replaces the procedural instructions) */
|
|
32
|
+
instructions: string;
|
|
33
|
+
/** Worked examples the agent generated */
|
|
34
|
+
examples: Array<{
|
|
35
|
+
title: string;
|
|
36
|
+
scenario: string;
|
|
37
|
+
steps: string;
|
|
38
|
+
}>;
|
|
39
|
+
/** Cross-references to related skills */
|
|
40
|
+
seeAlso: Array<{
|
|
41
|
+
name: string;
|
|
42
|
+
relation: string;
|
|
43
|
+
}>;
|
|
44
|
+
/** Agent's assessment of the playbook's completeness */
|
|
45
|
+
gaps: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare const skillEnrichmentTemplate: AgenticTaskTemplate<SkillEnrichmentInput, SkillEnrichmentOutput>;
|
|
48
|
+
//# sourceMappingURL=skill-enrichment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-enrichment.d.ts","sourceRoot":"","sources":["../../../src/workspace/templates/skill-enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,QAAQ,EAAE,QAAQ,CAAC;IACnB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,QAAQ,EAAE,KAAK,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,yCAAyC;IACzC,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,wDAAwD;IACxD,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAMD,eAAO,MAAM,uBAAuB,EAAE,mBAAmB,CACvD,oBAAoB,EACpB,qBAAqB,CAkNtB,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Enrichment Template
|
|
3
|
+
*
|
|
4
|
+
* Agent-in-the-loop step between playbook extraction and skill publishing.
|
|
5
|
+
* Given a Playbook and its procedurally generated SKILL.md skeleton, an agent
|
|
6
|
+
* enriches the skill with narrative prose, worked examples, cross-references,
|
|
7
|
+
* and a trigger-rich description — things a procedural converter cannot produce.
|
|
8
|
+
*
|
|
9
|
+
* Complexity routing:
|
|
10
|
+
* - Simple playbooks (<=3 tactics, low complexity) → heuristic: keep procedural output as-is
|
|
11
|
+
* - Standard/complex playbooks → agent enrichment
|
|
12
|
+
*/
|
|
13
|
+
import { convertPlaybookToSkill } from '../../surfacing/skill-publisher.js';
|
|
14
|
+
// ============================================================
|
|
15
|
+
// Template Implementation
|
|
16
|
+
// ============================================================
|
|
17
|
+
export const skillEnrichmentTemplate = {
|
|
18
|
+
taskType: 'skill-enrichment',
|
|
19
|
+
domain: 'skill-publishing',
|
|
20
|
+
description: 'Enrich a procedurally generated SKILL.md with narrative prose, examples, and cross-references',
|
|
21
|
+
assessComplexity(input) {
|
|
22
|
+
const pb = input.playbook;
|
|
23
|
+
const tacticCount = pb.guidance.tactics.length;
|
|
24
|
+
const hasSteps = (pb.guidance.steps?.length ?? 0) > 0;
|
|
25
|
+
const isComplex = pb.complexity === 'complex';
|
|
26
|
+
if (tacticCount <= 3 && !hasSteps && !isComplex)
|
|
27
|
+
return 'heuristic';
|
|
28
|
+
if (isComplex || tacticCount > 8)
|
|
29
|
+
return 'thorough';
|
|
30
|
+
return 'standard';
|
|
31
|
+
},
|
|
32
|
+
async heuristicFallback(input) {
|
|
33
|
+
const skill = convertPlaybookToSkill(input.playbook);
|
|
34
|
+
return {
|
|
35
|
+
description: skill.description,
|
|
36
|
+
instructions: skill.instructions,
|
|
37
|
+
examples: [],
|
|
38
|
+
seeAlso: (input.relatedSkills ?? []).map((r) => ({
|
|
39
|
+
name: r.name,
|
|
40
|
+
relation: `Related: ${r.description}`,
|
|
41
|
+
})),
|
|
42
|
+
gaps: [],
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
async prepareWorkspace(input, handle) {
|
|
46
|
+
// Write the playbook as structured JSON
|
|
47
|
+
await handle.writeJson('input', 'playbook.json', {
|
|
48
|
+
name: input.playbook.name,
|
|
49
|
+
applicability: input.playbook.applicability,
|
|
50
|
+
guidance: input.playbook.guidance,
|
|
51
|
+
verification: input.playbook.verification,
|
|
52
|
+
complexity: input.playbook.complexity,
|
|
53
|
+
confidence: input.playbook.confidence,
|
|
54
|
+
evolution: {
|
|
55
|
+
version: input.playbook.evolution.version,
|
|
56
|
+
successCount: input.playbook.evolution.successCount,
|
|
57
|
+
failureCount: input.playbook.evolution.failureCount,
|
|
58
|
+
refinements: input.playbook.evolution.refinements,
|
|
59
|
+
},
|
|
60
|
+
provenance: input.playbook.provenance,
|
|
61
|
+
userInvocable: input.playbook.userInvocable,
|
|
62
|
+
publishMetadata: input.playbook.publishMetadata,
|
|
63
|
+
});
|
|
64
|
+
// Write the procedural skeleton for the agent to improve upon
|
|
65
|
+
const skill = convertPlaybookToSkill(input.playbook);
|
|
66
|
+
await handle.writeRaw('input', 'skeleton.md', skill.instructions);
|
|
67
|
+
await handle.writeRaw('input', 'skeleton-description.txt', skill.description);
|
|
68
|
+
// Style reference (if provided)
|
|
69
|
+
if (input.styleReference) {
|
|
70
|
+
await handle.writeRaw('input', 'style-reference.md', input.styleReference);
|
|
71
|
+
}
|
|
72
|
+
// Related skills for cross-referencing
|
|
73
|
+
if (input.relatedSkills && input.relatedSkills.length > 0) {
|
|
74
|
+
await handle.writeJson('input', 'related-skills.json', input.relatedSkills);
|
|
75
|
+
}
|
|
76
|
+
// Domain context
|
|
77
|
+
if (input.domainContext) {
|
|
78
|
+
await handle.writeRaw('input', 'domain-context.txt', input.domainContext);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
buildTaskPrompt(input) {
|
|
82
|
+
const parts = [
|
|
83
|
+
`Enrich the skill "${input.playbook.name}" into a high-quality SKILL.md that an AI agent will load and follow.`,
|
|
84
|
+
'',
|
|
85
|
+
'## Inputs',
|
|
86
|
+
'',
|
|
87
|
+
'- `input/playbook.json` — the structured playbook (applicability, guidance, verification)',
|
|
88
|
+
'- `input/skeleton.md` — procedurally generated markdown body (your starting point)',
|
|
89
|
+
'- `input/skeleton-description.txt` — procedurally generated frontmatter description',
|
|
90
|
+
];
|
|
91
|
+
if (input.styleReference) {
|
|
92
|
+
parts.push('- `input/style-reference.md` — a hand-written SKILL.md to match in tone and structure');
|
|
93
|
+
}
|
|
94
|
+
if (input.relatedSkills && input.relatedSkills.length > 0) {
|
|
95
|
+
parts.push('- `input/related-skills.json` — related skills to cross-reference');
|
|
96
|
+
}
|
|
97
|
+
if (input.domainContext) {
|
|
98
|
+
parts.push('- `input/domain-context.txt` — domain context for accurate terminology');
|
|
99
|
+
}
|
|
100
|
+
parts.push('', '## What to produce', '', 'Read all inputs, then write `output/enrichment.json` with this schema:', '', '```json', '{', ' "description": "Trigger-rich frontmatter description, under 1024 chars. Structure: [What it does] + [Use when ...trigger phrases...]. Include concrete phrases users would say.",', ' "instructions": "Full markdown body. Must include:\\n- ## When to use (bulleted)\\n- ## When not to use (bulleted)\\n- ## Workflow (numbered tactics expanded into full prose — explain WHY each step matters, not just WHAT to do)\\n- ## Inputs / ## Outputs\\n- ## Verification (bulleted success/failure indicators)\\n- ## Edge cases (narrative, with recovery paths)\\n- ## Examples (2-3 worked scenarios with concrete commands)\\n- ## See also (cross-references)",', ' "examples": [{"title": "...", "scenario": "...", "steps": "..."}],', ' "seeAlso": [{"name": "skill-name", "relation": "why it is related"}],', ' "gaps": ["anything missing from the playbook that the skill should cover but cannot without more data"]', '}', '```', '', '## Guidelines', '', '- The skeleton is your starting point — improve it, do not discard it.', '- Expand each tactic in the Workflow section into a paragraph that explains the rationale, not just the command.', '- Generate 2-3 realistic examples with concrete tool calls (MCP tools, CLI commands, or library calls as appropriate for the domain).', '- Cross-reference related skills by name in the See Also section.', '- Flag gaps honestly — if the playbook is missing triggers, anti-patterns, or verification criteria, say so in the gaps array.', '- Keep the description under 1024 characters. It must include trigger phrases users would actually say.', '- Do not invent capabilities the playbook does not describe. Enrich what is there; do not fabricate.');
|
|
101
|
+
if (input.styleReference) {
|
|
102
|
+
parts.push('- Match the tone, section structure, and level of detail from the style reference.');
|
|
103
|
+
}
|
|
104
|
+
return parts.join('\n');
|
|
105
|
+
},
|
|
106
|
+
getSkills() { return []; },
|
|
107
|
+
getResources(input) {
|
|
108
|
+
const resources = [];
|
|
109
|
+
if (input.domainContext) {
|
|
110
|
+
resources.push({
|
|
111
|
+
type: 'file',
|
|
112
|
+
path: 'domain-context.txt',
|
|
113
|
+
source: input.domainContext,
|
|
114
|
+
description: 'Domain context for accurate terminology',
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return resources;
|
|
118
|
+
},
|
|
119
|
+
outputConfig: {
|
|
120
|
+
files: [
|
|
121
|
+
{
|
|
122
|
+
path: 'enrichment.json',
|
|
123
|
+
format: 'json',
|
|
124
|
+
required: true,
|
|
125
|
+
description: 'Enriched skill content with description, instructions, examples, cross-refs, and gaps',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
async collectOutput(handle) {
|
|
130
|
+
const raw = await handle.readJson('output', 'enrichment.json');
|
|
131
|
+
return {
|
|
132
|
+
description: typeof raw.description === 'string'
|
|
133
|
+
? raw.description.slice(0, 1024)
|
|
134
|
+
: '',
|
|
135
|
+
instructions: typeof raw.instructions === 'string'
|
|
136
|
+
? raw.instructions
|
|
137
|
+
: '',
|
|
138
|
+
examples: Array.isArray(raw.examples)
|
|
139
|
+
? raw.examples.map((e) => ({
|
|
140
|
+
title: String(e.title ?? ''),
|
|
141
|
+
scenario: String(e.scenario ?? ''),
|
|
142
|
+
steps: String(e.steps ?? ''),
|
|
143
|
+
}))
|
|
144
|
+
: [],
|
|
145
|
+
seeAlso: Array.isArray(raw.seeAlso)
|
|
146
|
+
? raw.seeAlso.map((s) => ({
|
|
147
|
+
name: String(s.name ?? ''),
|
|
148
|
+
relation: String(s.relation ?? ''),
|
|
149
|
+
}))
|
|
150
|
+
: [],
|
|
151
|
+
gaps: Array.isArray(raw.gaps)
|
|
152
|
+
? raw.gaps.map(String)
|
|
153
|
+
: [],
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
async processOutput() {
|
|
157
|
+
// Caller handles merging the enriched output back into the Skill
|
|
158
|
+
// and publishing via SkillPublisher.
|
|
159
|
+
},
|
|
160
|
+
computeRequirements: {
|
|
161
|
+
mode: 'local',
|
|
162
|
+
complexity: 'standard',
|
|
163
|
+
},
|
|
164
|
+
getComputeRequirements(_input, complexity) {
|
|
165
|
+
return {
|
|
166
|
+
mode: 'local',
|
|
167
|
+
complexity,
|
|
168
|
+
timeout: complexity === 'thorough' ? 300_000 : 180_000,
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
agentType: 'claude-code',
|
|
172
|
+
timeout: 180_000,
|
|
173
|
+
captureToolCalls: true,
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=skill-enrichment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-enrichment.js","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b,UAAU;YACV,OAAO,EAAE,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;SACvD,CAAC;IACJ,CAAC;IAED,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,OAAO;IAChB,gBAAgB,EAAE,IAAI;CACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognitive-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "TypeScript-native cognitive core for adaptive learning and abstraction",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
"author": "Alex Ngai",
|
|
66
66
|
"license": "MIT",
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@types/better-sqlite3": "^7.6.
|
|
68
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
69
69
|
"@types/node": "^20.10.0",
|
|
70
70
|
"eslint": "^8.55.0",
|
|
71
71
|
"typescript": "^5.3.0",
|
|
72
72
|
"vitest": "^1.0.0"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"acp-factory": "^0.1.
|
|
76
|
-
"agent-workspace": "^0.1.
|
|
77
|
-
"better-sqlite3": "^
|
|
75
|
+
"acp-factory": "^0.1.14",
|
|
76
|
+
"agent-workspace": "^0.1.5",
|
|
77
|
+
"better-sqlite3": "^12.0.0",
|
|
78
78
|
"minimem": "^0.1.0",
|
|
79
79
|
"sessionlog": "^0.0.4",
|
|
80
80
|
"skill-tree": "^0.1.5",
|
|
@@ -11,6 +11,46 @@ import type { Playbook } from '../types/index.js';
|
|
|
11
11
|
import type { PublishResult, DeprecateResult } from './publisher.js';
|
|
12
12
|
import { getPlaybookSuccessRate } from '../types/playbook.js';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Maximum length for the generated `description` field.
|
|
16
|
+
* Claude Code's skill format caps description at 1024 chars, so we truncate
|
|
17
|
+
* to stay safely within that boundary.
|
|
18
|
+
*/
|
|
19
|
+
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Build the `description` field for a published Skill.
|
|
23
|
+
*
|
|
24
|
+
* The description is what lightweight trigger matchers — notably Claude Code's
|
|
25
|
+
* skill loader — key off to decide whether to load a skill. It needs two things:
|
|
26
|
+
*
|
|
27
|
+
* 1. A short "what it does" lead (pulled from the first situation, or the
|
|
28
|
+
* strategy if no situation is set).
|
|
29
|
+
* 2. The concrete trigger phrases, surfaced inline so substring/keyword
|
|
30
|
+
* matchers catch them. These live in `applicability.triggers` on the
|
|
31
|
+
* playbook but are invisible to downstream consumers unless we lift them.
|
|
32
|
+
*
|
|
33
|
+
* Shape: `<lead>. Use when "<t1>", "<t2>", ..., "<tN>".`
|
|
34
|
+
*/
|
|
35
|
+
function buildDescription(playbook: Playbook): string {
|
|
36
|
+
let lead = playbook.applicability.situations[0]
|
|
37
|
+
?? `${playbook.name}: ${playbook.guidance.strategy.slice(0, 100)}`;
|
|
38
|
+
|
|
39
|
+
// Ensure a sentence terminator before appending the trigger clause.
|
|
40
|
+
if (lead.length > 0 && !/[.!?]$/.test(lead)) {
|
|
41
|
+
lead += '.';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const triggers = playbook.applicability.triggers;
|
|
45
|
+
const triggerClause = triggers.length > 0
|
|
46
|
+
? ` Use when ${triggers.map((t) => `"${t}"`).join(', ')}.`
|
|
47
|
+
: '';
|
|
48
|
+
|
|
49
|
+
const full = lead + triggerClause;
|
|
50
|
+
if (full.length <= MAX_DESCRIPTION_LENGTH) return full;
|
|
51
|
+
return full.slice(0, MAX_DESCRIPTION_LENGTH - 3) + '...';
|
|
52
|
+
}
|
|
53
|
+
|
|
14
54
|
/**
|
|
15
55
|
* Convert a Playbook to a Skill
|
|
16
56
|
*/
|
|
@@ -27,43 +67,69 @@ export function convertPlaybookToSkill(playbook: Playbook): Skill {
|
|
|
27
67
|
solution += '\n\nSteps:\n' + playbook.guidance.steps.map((s, i) => `${i + 1}. ${s}`).join('\n');
|
|
28
68
|
}
|
|
29
69
|
|
|
30
|
-
// Build
|
|
31
|
-
const
|
|
32
|
-
? playbook.verification.successIndicators.join('. ')
|
|
33
|
-
: 'Verify the approach worked as expected.';
|
|
70
|
+
// Build description for semantic matching and lightweight trigger routing
|
|
71
|
+
const description = buildDescription(playbook);
|
|
34
72
|
|
|
35
|
-
// Build
|
|
36
|
-
const
|
|
73
|
+
// Build structured instructions body
|
|
74
|
+
const instructionParts: string[] = [];
|
|
75
|
+
|
|
76
|
+
// --- When to use / When not to use (Change A) ---
|
|
77
|
+
if (playbook.applicability.situations.length > 0) {
|
|
78
|
+
instructionParts.push(
|
|
79
|
+
'## When to use\n\n'
|
|
80
|
+
+ playbook.applicability.situations.map((s) => `- ${s}`).join('\n'),
|
|
81
|
+
);
|
|
82
|
+
}
|
|
37
83
|
if (playbook.applicability.antiPatterns.length > 0) {
|
|
38
|
-
|
|
84
|
+
instructionParts.push(
|
|
85
|
+
'## When not to use\n\n'
|
|
86
|
+
+ playbook.applicability.antiPatterns.map((a) => `- ${a}`).join('\n'),
|
|
87
|
+
);
|
|
39
88
|
}
|
|
40
|
-
|
|
41
|
-
|
|
89
|
+
|
|
90
|
+
// --- Solution ---
|
|
91
|
+
instructionParts.push(`## Solution\n\n${solution}`);
|
|
92
|
+
|
|
93
|
+
// --- Verification with bulleted indicators (Change B) ---
|
|
94
|
+
const verificationParts: string[] = [];
|
|
95
|
+
if (playbook.verification.successIndicators.length > 0) {
|
|
96
|
+
verificationParts.push(
|
|
97
|
+
'Success:\n'
|
|
98
|
+
+ playbook.verification.successIndicators.map((s) => `- ${s}`).join('\n'),
|
|
99
|
+
);
|
|
42
100
|
}
|
|
43
|
-
if (playbook.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
101
|
+
if (playbook.verification.failureIndicators.length > 0) {
|
|
102
|
+
verificationParts.push(
|
|
103
|
+
'Failure:\n'
|
|
104
|
+
+ playbook.verification.failureIndicators.map((f) => `- ${f}`).join('\n'),
|
|
105
|
+
);
|
|
47
106
|
}
|
|
48
107
|
if (playbook.verification.rollbackStrategy) {
|
|
49
|
-
|
|
108
|
+
verificationParts.push(`Rollback: ${playbook.verification.rollbackStrategy}`);
|
|
109
|
+
}
|
|
110
|
+
if (verificationParts.length > 0) {
|
|
111
|
+
instructionParts.push(`## Verification\n\n${verificationParts.join('\n\n')}`);
|
|
112
|
+
} else {
|
|
113
|
+
instructionParts.push('## Verification\n\nVerify the approach worked as expected.');
|
|
50
114
|
}
|
|
51
115
|
|
|
52
|
-
//
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
instructionParts.push(`## Verification\n${verification}`);
|
|
116
|
+
// --- Notes (refinements only — anti-patterns now in their own section) ---
|
|
117
|
+
const notesParts: string[] = [];
|
|
118
|
+
if (playbook.evolution.refinements.length > 0) {
|
|
119
|
+
notesParts.push(
|
|
120
|
+
'Refinements:\n'
|
|
121
|
+
+ playbook.evolution.refinements.map((r) => `- In ${r.context}: ${r.addition}`).join('\n'),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
61
124
|
if (notesParts.length > 0) {
|
|
62
|
-
instructionParts.push(`## Notes\n${notesParts.join('\n\n')}`);
|
|
125
|
+
instructionParts.push(`## Notes\n\n${notesParts.join('\n\n')}`);
|
|
63
126
|
}
|
|
127
|
+
|
|
128
|
+
// --- Example ---
|
|
64
129
|
if (playbook.guidance.codeExample) {
|
|
65
|
-
instructionParts.push(`## Example\n\`\`\`\n${playbook.guidance.codeExample}\n\`\`\``);
|
|
130
|
+
instructionParts.push(`## Example\n\n\`\`\`\n${playbook.guidance.codeExample}\n\`\`\``);
|
|
66
131
|
}
|
|
132
|
+
|
|
67
133
|
const instructions = instructionParts.join('\n\n');
|
|
68
134
|
|
|
69
135
|
// Estimate tokens (rough: 4 chars per token)
|
|
@@ -75,7 +141,7 @@ export function convertPlaybookToSkill(playbook: Playbook): Skill {
|
|
|
75
141
|
version: playbook.evolution.version,
|
|
76
142
|
description,
|
|
77
143
|
instructions,
|
|
78
|
-
author: 'cognitive-core',
|
|
144
|
+
author: playbook.provenance?.curatedBy ?? 'cognitive-core',
|
|
79
145
|
tags: playbook.applicability.domains,
|
|
80
146
|
status: 'active',
|
|
81
147
|
metrics: {
|
package/src/types/playbook.ts
CHANGED
|
@@ -35,6 +35,19 @@ export interface Playbook {
|
|
|
35
35
|
embedding?: number[]; // For semantic search
|
|
36
36
|
createdAt: Date;
|
|
37
37
|
updatedAt: Date;
|
|
38
|
+
|
|
39
|
+
// === PUBLISH HINTS (optional, used by SkillPublisher) ===
|
|
40
|
+
/**
|
|
41
|
+
* Whether end-users can invoke this skill directly (e.g. via /slash-command).
|
|
42
|
+
* Propagated into the published SKILL.md frontmatter as `user-invocable`.
|
|
43
|
+
*/
|
|
44
|
+
userInvocable?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Arbitrary key-value metadata propagated verbatim into the published
|
|
47
|
+
* SKILL.md frontmatter `metadata:` block. Use for ecosystem-specific
|
|
48
|
+
* fields (audience, component, ecosystem) without changing the core schema.
|
|
49
|
+
*/
|
|
50
|
+
publishMetadata?: Record<string, unknown>;
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
/**
|
|
@@ -159,6 +172,8 @@ export function createPlaybook(
|
|
|
159
172
|
complexity: input.complexity ?? 'moderate',
|
|
160
173
|
estimatedEffort: input.estimatedEffort ?? 3,
|
|
161
174
|
embedding: input.embedding,
|
|
175
|
+
userInvocable: input.userInvocable,
|
|
176
|
+
publishMetadata: input.publishMetadata,
|
|
162
177
|
createdAt: input.createdAt ?? now,
|
|
163
178
|
updatedAt: input.updatedAt ?? now,
|
|
164
179
|
};
|
|
@@ -86,3 +86,10 @@ export {
|
|
|
86
86
|
type PlaybookLifecycleReviewOutput,
|
|
87
87
|
type LifecycleRecommendation,
|
|
88
88
|
} from './playbook-lifecycle-review.js';
|
|
89
|
+
|
|
90
|
+
// Skill Enrichment (publish pipeline — agent-enriched SKILL.md generation)
|
|
91
|
+
export {
|
|
92
|
+
skillEnrichmentTemplate,
|
|
93
|
+
type SkillEnrichmentInput,
|
|
94
|
+
type SkillEnrichmentOutput,
|
|
95
|
+
} from './skill-enrichment.js';
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Enrichment Template
|
|
3
|
+
*
|
|
4
|
+
* Agent-in-the-loop step between playbook extraction and skill publishing.
|
|
5
|
+
* Given a Playbook and its procedurally generated SKILL.md skeleton, an agent
|
|
6
|
+
* enriches the skill with narrative prose, worked examples, cross-references,
|
|
7
|
+
* and a trigger-rich description — things a procedural converter cannot produce.
|
|
8
|
+
*
|
|
9
|
+
* Complexity routing:
|
|
10
|
+
* - Simple playbooks (<=3 tactics, low complexity) → heuristic: keep procedural output as-is
|
|
11
|
+
* - Standard/complex playbooks → agent enrichment
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { WorkspaceHandle } from 'agent-workspace';
|
|
15
|
+
import type { Playbook } from '../../types/index.js';
|
|
16
|
+
import { convertPlaybookToSkill } from '../../surfacing/skill-publisher.js';
|
|
17
|
+
import type {
|
|
18
|
+
AgenticTaskTemplate,
|
|
19
|
+
AnalysisComplexity,
|
|
20
|
+
ResourceSpec,
|
|
21
|
+
} from '../types.js';
|
|
22
|
+
import type { ComputeRequirements } from '../../runtime/compute-provider.js';
|
|
23
|
+
|
|
24
|
+
// ============================================================
|
|
25
|
+
// Input / Output Types
|
|
26
|
+
// ============================================================
|
|
27
|
+
|
|
28
|
+
export interface SkillEnrichmentInput {
|
|
29
|
+
/** The playbook to enrich into a skill */
|
|
30
|
+
playbook: Playbook;
|
|
31
|
+
/** Optional: existing hand-written SKILL.md to use as style reference */
|
|
32
|
+
styleReference?: string;
|
|
33
|
+
/** Optional: related skill names for cross-referencing */
|
|
34
|
+
relatedSkills?: Array<{ name: string; description: string }>;
|
|
35
|
+
/** Optional: domain context (e.g. "swarmkit ecosystem", "TypeScript tooling") */
|
|
36
|
+
domainContext?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface SkillEnrichmentOutput {
|
|
40
|
+
/** Enriched SKILL.md frontmatter description (trigger-rich, under 1024 chars) */
|
|
41
|
+
description: string;
|
|
42
|
+
/** Enriched markdown body (replaces the procedural instructions) */
|
|
43
|
+
instructions: string;
|
|
44
|
+
/** Worked examples the agent generated */
|
|
45
|
+
examples: Array<{
|
|
46
|
+
title: string;
|
|
47
|
+
scenario: string;
|
|
48
|
+
steps: string;
|
|
49
|
+
}>;
|
|
50
|
+
/** Cross-references to related skills */
|
|
51
|
+
seeAlso: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
relation: string;
|
|
54
|
+
}>;
|
|
55
|
+
/** Agent's assessment of the playbook's completeness */
|
|
56
|
+
gaps: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ============================================================
|
|
60
|
+
// Template Implementation
|
|
61
|
+
// ============================================================
|
|
62
|
+
|
|
63
|
+
export const skillEnrichmentTemplate: AgenticTaskTemplate<
|
|
64
|
+
SkillEnrichmentInput,
|
|
65
|
+
SkillEnrichmentOutput
|
|
66
|
+
> = {
|
|
67
|
+
taskType: 'skill-enrichment',
|
|
68
|
+
domain: 'skill-publishing',
|
|
69
|
+
description: 'Enrich a procedurally generated SKILL.md with narrative prose, examples, and cross-references',
|
|
70
|
+
|
|
71
|
+
assessComplexity(input: SkillEnrichmentInput): AnalysisComplexity {
|
|
72
|
+
const pb = input.playbook;
|
|
73
|
+
const tacticCount = pb.guidance.tactics.length;
|
|
74
|
+
const hasSteps = (pb.guidance.steps?.length ?? 0) > 0;
|
|
75
|
+
const isComplex = pb.complexity === 'complex';
|
|
76
|
+
|
|
77
|
+
if (tacticCount <= 3 && !hasSteps && !isComplex) return 'heuristic';
|
|
78
|
+
if (isComplex || tacticCount > 8) return 'thorough';
|
|
79
|
+
return 'standard';
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
async heuristicFallback(input: SkillEnrichmentInput): Promise<SkillEnrichmentOutput> {
|
|
83
|
+
const skill = convertPlaybookToSkill(input.playbook);
|
|
84
|
+
return {
|
|
85
|
+
description: skill.description,
|
|
86
|
+
instructions: skill.instructions,
|
|
87
|
+
examples: [],
|
|
88
|
+
seeAlso: (input.relatedSkills ?? []).map((r) => ({
|
|
89
|
+
name: r.name,
|
|
90
|
+
relation: `Related: ${r.description}`,
|
|
91
|
+
})),
|
|
92
|
+
gaps: [],
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
async prepareWorkspace(
|
|
97
|
+
input: SkillEnrichmentInput,
|
|
98
|
+
handle: WorkspaceHandle,
|
|
99
|
+
): Promise<void> {
|
|
100
|
+
// Write the playbook as structured JSON
|
|
101
|
+
await handle.writeJson('input', 'playbook.json', {
|
|
102
|
+
name: input.playbook.name,
|
|
103
|
+
applicability: input.playbook.applicability,
|
|
104
|
+
guidance: input.playbook.guidance,
|
|
105
|
+
verification: input.playbook.verification,
|
|
106
|
+
complexity: input.playbook.complexity,
|
|
107
|
+
confidence: input.playbook.confidence,
|
|
108
|
+
evolution: {
|
|
109
|
+
version: input.playbook.evolution.version,
|
|
110
|
+
successCount: input.playbook.evolution.successCount,
|
|
111
|
+
failureCount: input.playbook.evolution.failureCount,
|
|
112
|
+
refinements: input.playbook.evolution.refinements,
|
|
113
|
+
},
|
|
114
|
+
provenance: input.playbook.provenance,
|
|
115
|
+
userInvocable: input.playbook.userInvocable,
|
|
116
|
+
publishMetadata: input.playbook.publishMetadata,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Write the procedural skeleton for the agent to improve upon
|
|
120
|
+
const skill = convertPlaybookToSkill(input.playbook);
|
|
121
|
+
await handle.writeRaw('input', 'skeleton.md', skill.instructions);
|
|
122
|
+
await handle.writeRaw('input', 'skeleton-description.txt', skill.description);
|
|
123
|
+
|
|
124
|
+
// Style reference (if provided)
|
|
125
|
+
if (input.styleReference) {
|
|
126
|
+
await handle.writeRaw('input', 'style-reference.md', input.styleReference);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Related skills for cross-referencing
|
|
130
|
+
if (input.relatedSkills && input.relatedSkills.length > 0) {
|
|
131
|
+
await handle.writeJson('input', 'related-skills.json', input.relatedSkills);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Domain context
|
|
135
|
+
if (input.domainContext) {
|
|
136
|
+
await handle.writeRaw('input', 'domain-context.txt', input.domainContext);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
buildTaskPrompt(input: SkillEnrichmentInput): string {
|
|
141
|
+
const parts: string[] = [
|
|
142
|
+
`Enrich the skill "${input.playbook.name}" into a high-quality SKILL.md that an AI agent will load and follow.`,
|
|
143
|
+
'',
|
|
144
|
+
'## Inputs',
|
|
145
|
+
'',
|
|
146
|
+
'- `input/playbook.json` — the structured playbook (applicability, guidance, verification)',
|
|
147
|
+
'- `input/skeleton.md` — procedurally generated markdown body (your starting point)',
|
|
148
|
+
'- `input/skeleton-description.txt` — procedurally generated frontmatter description',
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
if (input.styleReference) {
|
|
152
|
+
parts.push('- `input/style-reference.md` — a hand-written SKILL.md to match in tone and structure');
|
|
153
|
+
}
|
|
154
|
+
if (input.relatedSkills && input.relatedSkills.length > 0) {
|
|
155
|
+
parts.push('- `input/related-skills.json` — related skills to cross-reference');
|
|
156
|
+
}
|
|
157
|
+
if (input.domainContext) {
|
|
158
|
+
parts.push('- `input/domain-context.txt` — domain context for accurate terminology');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
parts.push(
|
|
162
|
+
'',
|
|
163
|
+
'## What to produce',
|
|
164
|
+
'',
|
|
165
|
+
'Read all inputs, then write `output/enrichment.json` with this schema:',
|
|
166
|
+
'',
|
|
167
|
+
'```json',
|
|
168
|
+
'{',
|
|
169
|
+
' "description": "Trigger-rich frontmatter description, under 1024 chars. Structure: [What it does] + [Use when ...trigger phrases...]. Include concrete phrases users would say.",',
|
|
170
|
+
' "instructions": "Full markdown body. Must include:\\n- ## When to use (bulleted)\\n- ## When not to use (bulleted)\\n- ## Workflow (numbered tactics expanded into full prose — explain WHY each step matters, not just WHAT to do)\\n- ## Inputs / ## Outputs\\n- ## Verification (bulleted success/failure indicators)\\n- ## Edge cases (narrative, with recovery paths)\\n- ## Examples (2-3 worked scenarios with concrete commands)\\n- ## See also (cross-references)",',
|
|
171
|
+
' "examples": [{"title": "...", "scenario": "...", "steps": "..."}],',
|
|
172
|
+
' "seeAlso": [{"name": "skill-name", "relation": "why it is related"}],',
|
|
173
|
+
' "gaps": ["anything missing from the playbook that the skill should cover but cannot without more data"]',
|
|
174
|
+
'}',
|
|
175
|
+
'```',
|
|
176
|
+
'',
|
|
177
|
+
'## Guidelines',
|
|
178
|
+
'',
|
|
179
|
+
'- The skeleton is your starting point — improve it, do not discard it.',
|
|
180
|
+
'- Expand each tactic in the Workflow section into a paragraph that explains the rationale, not just the command.',
|
|
181
|
+
'- Generate 2-3 realistic examples with concrete tool calls (MCP tools, CLI commands, or library calls as appropriate for the domain).',
|
|
182
|
+
'- Cross-reference related skills by name in the See Also section.',
|
|
183
|
+
'- Flag gaps honestly — if the playbook is missing triggers, anti-patterns, or verification criteria, say so in the gaps array.',
|
|
184
|
+
'- Keep the description under 1024 characters. It must include trigger phrases users would actually say.',
|
|
185
|
+
'- Do not invent capabilities the playbook does not describe. Enrich what is there; do not fabricate.',
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
if (input.styleReference) {
|
|
189
|
+
parts.push(
|
|
190
|
+
'- Match the tone, section structure, and level of detail from the style reference.',
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return parts.join('\n');
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
getSkills() { return []; },
|
|
198
|
+
getResources(input: SkillEnrichmentInput): ResourceSpec[] {
|
|
199
|
+
const resources: ResourceSpec[] = [];
|
|
200
|
+
if (input.domainContext) {
|
|
201
|
+
resources.push({
|
|
202
|
+
type: 'file',
|
|
203
|
+
path: 'domain-context.txt',
|
|
204
|
+
source: input.domainContext,
|
|
205
|
+
description: 'Domain context for accurate terminology',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
return resources;
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
outputConfig: {
|
|
212
|
+
files: [
|
|
213
|
+
{
|
|
214
|
+
path: 'enrichment.json',
|
|
215
|
+
format: 'json' as const,
|
|
216
|
+
required: true,
|
|
217
|
+
description: 'Enriched skill content with description, instructions, examples, cross-refs, and gaps',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
async collectOutput(handle: WorkspaceHandle): Promise<SkillEnrichmentOutput> {
|
|
223
|
+
const raw = await handle.readJson('output', 'enrichment.json') as Record<string, unknown>;
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
description: typeof raw.description === 'string'
|
|
227
|
+
? raw.description.slice(0, 1024)
|
|
228
|
+
: '',
|
|
229
|
+
instructions: typeof raw.instructions === 'string'
|
|
230
|
+
? raw.instructions
|
|
231
|
+
: '',
|
|
232
|
+
examples: Array.isArray(raw.examples)
|
|
233
|
+
? (raw.examples as Array<Record<string, unknown>>).map((e) => ({
|
|
234
|
+
title: String(e.title ?? ''),
|
|
235
|
+
scenario: String(e.scenario ?? ''),
|
|
236
|
+
steps: String(e.steps ?? ''),
|
|
237
|
+
}))
|
|
238
|
+
: [],
|
|
239
|
+
seeAlso: Array.isArray(raw.seeAlso)
|
|
240
|
+
? (raw.seeAlso as Array<Record<string, unknown>>).map((s) => ({
|
|
241
|
+
name: String(s.name ?? ''),
|
|
242
|
+
relation: String(s.relation ?? ''),
|
|
243
|
+
}))
|
|
244
|
+
: [],
|
|
245
|
+
gaps: Array.isArray(raw.gaps)
|
|
246
|
+
? (raw.gaps as Array<unknown>).map(String)
|
|
247
|
+
: [],
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
async processOutput(): Promise<void> {
|
|
252
|
+
// Caller handles merging the enriched output back into the Skill
|
|
253
|
+
// and publishing via SkillPublisher.
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
computeRequirements: {
|
|
257
|
+
mode: 'local',
|
|
258
|
+
complexity: 'standard',
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
getComputeRequirements(
|
|
262
|
+
_input: SkillEnrichmentInput,
|
|
263
|
+
complexity: AnalysisComplexity,
|
|
264
|
+
): ComputeRequirements {
|
|
265
|
+
return {
|
|
266
|
+
mode: 'local',
|
|
267
|
+
complexity,
|
|
268
|
+
timeout: complexity === 'thorough' ? 300_000 : 180_000,
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
agentType: 'claude-code',
|
|
273
|
+
timeout: 180_000,
|
|
274
|
+
captureToolCalls: true,
|
|
275
|
+
};
|
|
@@ -77,10 +77,73 @@ describe('SkillPublisher', () => {
|
|
|
77
77
|
const playbook = createSamplePlaybook();
|
|
78
78
|
const skill = convertPlaybookToSkill(playbook);
|
|
79
79
|
|
|
80
|
-
expect(skill.description).
|
|
80
|
+
expect(skill.description).toContain('TypeScript import fails with TS2307');
|
|
81
81
|
expect(skill.instructions).toContain('TypeScript import fails with TS2307');
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
it('should surface trigger phrases inline in description for lightweight matching', () => {
|
|
85
|
+
const playbook = createSamplePlaybook();
|
|
86
|
+
const skill = convertPlaybookToSkill(playbook);
|
|
87
|
+
|
|
88
|
+
// Lead situation still present.
|
|
89
|
+
expect(skill.description).toContain('TypeScript import fails with TS2307');
|
|
90
|
+
// Explicit "Use when" clause listing each trigger phrase, quoted.
|
|
91
|
+
expect(skill.description).toContain('Use when');
|
|
92
|
+
expect(skill.description).toContain('"TS2307"');
|
|
93
|
+
expect(skill.description).toContain('"Cannot find module"');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should omit trigger clause when no triggers are declared', () => {
|
|
97
|
+
const playbook = createSamplePlaybook({
|
|
98
|
+
applicability: {
|
|
99
|
+
situations: ['Some situation'],
|
|
100
|
+
triggers: [],
|
|
101
|
+
antiPatterns: [],
|
|
102
|
+
domains: [],
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
const skill = convertPlaybookToSkill(playbook);
|
|
106
|
+
|
|
107
|
+
expect(skill.description).toBe('Some situation.');
|
|
108
|
+
expect(skill.description).not.toContain('Use when');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should cap description at 1024 chars', () => {
|
|
112
|
+
const playbook = createSamplePlaybook({
|
|
113
|
+
applicability: {
|
|
114
|
+
situations: ['X'.repeat(500)],
|
|
115
|
+
// Many long triggers would push past 1024 chars combined.
|
|
116
|
+
triggers: Array.from({ length: 20 }, (_, i) => 'trigger-phrase-' + 'y'.repeat(50) + `-${i}`),
|
|
117
|
+
antiPatterns: [],
|
|
118
|
+
domains: [],
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const skill = convertPlaybookToSkill(playbook);
|
|
122
|
+
|
|
123
|
+
expect(skill.description.length).toBeLessThanOrEqual(1024);
|
|
124
|
+
expect(skill.description).toMatch(/\.\.\.$/);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should use provenance.curatedBy as author when set', () => {
|
|
128
|
+
const playbook = createSamplePlaybook({
|
|
129
|
+
provenance: {
|
|
130
|
+
origin: 'curated',
|
|
131
|
+
curatedBy: 'swarmkit-skills',
|
|
132
|
+
recordedAt: new Date(),
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
const skill = convertPlaybookToSkill(playbook);
|
|
136
|
+
|
|
137
|
+
expect(skill.author).toBe('swarmkit-skills');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should fall back to cognitive-core as author when provenance.curatedBy is absent', () => {
|
|
141
|
+
const playbook = createSamplePlaybook();
|
|
142
|
+
const skill = convertPlaybookToSkill(playbook);
|
|
143
|
+
|
|
144
|
+
expect(skill.author).toBe('cognitive-core');
|
|
145
|
+
});
|
|
146
|
+
|
|
84
147
|
it('should build instructions from strategy, tactics, and steps', () => {
|
|
85
148
|
const playbook = createSamplePlaybook();
|
|
86
149
|
const skill = convertPlaybookToSkill(playbook);
|
|
@@ -92,15 +155,25 @@ describe('SkillPublisher', () => {
|
|
|
92
155
|
expect(skill.instructions).toContain('Verify with tsc --noEmit');
|
|
93
156
|
});
|
|
94
157
|
|
|
95
|
-
it('should include verification and
|
|
158
|
+
it('should include structured verification, when-to-use, and when-not-to-use sections', () => {
|
|
96
159
|
const playbook = createSamplePlaybook();
|
|
97
160
|
const skill = convertPlaybookToSkill(playbook);
|
|
98
161
|
|
|
99
|
-
|
|
100
|
-
expect(skill.instructions).toContain('
|
|
101
|
-
expect(skill.instructions).toContain('
|
|
102
|
-
expect(skill.instructions).toContain('Refinements:');
|
|
162
|
+
// Verification indicators rendered as bulleted lists
|
|
163
|
+
expect(skill.instructions).toContain('Success:\n- Build passes');
|
|
164
|
+
expect(skill.instructions).toContain('Failure:\n- Same error persists');
|
|
103
165
|
expect(skill.instructions).toContain('Rollback:');
|
|
166
|
+
|
|
167
|
+
// Anti-patterns now live in their own section, not in Notes
|
|
168
|
+
expect(skill.instructions).toContain('## When not to use');
|
|
169
|
+
expect(skill.instructions).toContain('- Module genuinely does not exist');
|
|
170
|
+
|
|
171
|
+
// Situations get their own section
|
|
172
|
+
expect(skill.instructions).toContain('## When to use');
|
|
173
|
+
expect(skill.instructions).toContain('- TypeScript import fails with TS2307');
|
|
174
|
+
|
|
175
|
+
// Refinements remain in Notes
|
|
176
|
+
expect(skill.instructions).toContain('Refinements:');
|
|
104
177
|
});
|
|
105
178
|
|
|
106
179
|
it('should compute metrics from evolution data', () => {
|
|
@@ -277,12 +350,12 @@ describe('SkillPublisher', () => {
|
|
|
277
350
|
expect(result.error).toContain('not found');
|
|
278
351
|
});
|
|
279
352
|
|
|
280
|
-
it('should preserve existing
|
|
353
|
+
it('should preserve existing content when deprecating', async () => {
|
|
281
354
|
const publisher = new SkillPublisher(storage);
|
|
282
355
|
await publisher.publishPlaybook(createSamplePlaybook({ id: 'notes-1' }));
|
|
283
356
|
|
|
284
357
|
const before = await storage.getSkill('notes-1');
|
|
285
|
-
expect(before!.instructions).toContain('
|
|
358
|
+
expect(before!.instructions).toContain('## When not to use');
|
|
286
359
|
|
|
287
360
|
await publisher.deprecateSkill('notes-1', 'Superseded');
|
|
288
361
|
|