@dzhechkov/harness-core 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/create-skill.d.ts +37 -0
- package/dist/create-skill.d.ts.map +1 -0
- package/dist/create-skill.js +121 -0
- package/dist/create-skill.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/create-skill.ts +157 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill scaffolder — creates a complete SKILL.md directory structure.
|
|
3
|
+
*
|
|
4
|
+
* Generates: SKILL.md (agentskills.io frontmatter), schemas/output.json,
|
|
5
|
+
* scripts/validate-config.json. Optionally: evals/, references/.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/** Options for skill creation. */
|
|
10
|
+
export interface CreateSkillOptions {
|
|
11
|
+
/** Skill id (kebab-case directory name). */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** One-line description for SKILL.md frontmatter. */
|
|
14
|
+
readonly description: string;
|
|
15
|
+
/** Parent directory where skill dir will be created. Default: `.claude/skills`. */
|
|
16
|
+
readonly skillsDir?: string | undefined;
|
|
17
|
+
/** Include evals/ directory with template. */
|
|
18
|
+
readonly withEvals?: boolean | undefined;
|
|
19
|
+
/** Include references/ directory. */
|
|
20
|
+
readonly withReferences?: boolean | undefined;
|
|
21
|
+
/** Trust tier (1-3). Default: 1. */
|
|
22
|
+
readonly trustTier?: number | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Result of skill creation. */
|
|
25
|
+
export interface CreateSkillResult {
|
|
26
|
+
readonly skillDir: string;
|
|
27
|
+
readonly filesCreated: readonly string[];
|
|
28
|
+
readonly alreadyExists: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create a new skill directory with all required files.
|
|
32
|
+
*
|
|
33
|
+
* Returns the list of created files. If the skill directory already exists,
|
|
34
|
+
* returns `alreadyExists: true` and creates nothing.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSkill(opts: CreateSkillOptions): CreateSkillResult;
|
|
37
|
+
//# sourceMappingURL=create-skill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-skill.d.ts","sourceRoot":"","sources":["../src/create-skill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,kCAAkC;AAClC,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,8CAA8C;IAC9C,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,qCAAqC;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9C,oCAAoC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,gCAAgC;AAChC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AA4ED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,iBAAiB,CAyCvE"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill scaffolder — creates a complete SKILL.md directory structure.
|
|
3
|
+
*
|
|
4
|
+
* Generates: SKILL.md (agentskills.io frontmatter), schemas/output.json,
|
|
5
|
+
* scripts/validate-config.json. Optionally: evals/, references/.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
/** Generate SKILL.md content with agentskills.io frontmatter. */
|
|
12
|
+
function generateSkillMd(opts) {
|
|
13
|
+
const tier = opts.trustTier ?? 1;
|
|
14
|
+
return `---
|
|
15
|
+
name: "${opts.name}"
|
|
16
|
+
description: "${opts.description}"
|
|
17
|
+
trust_tier: ${tier}
|
|
18
|
+
trust_tier_label: "${tier === 3 ? 'Verified' : tier === 2 ? 'Validated' : 'Structured'}"
|
|
19
|
+
validation:
|
|
20
|
+
schema_path: schemas/output.json
|
|
21
|
+
validator_path: scripts/validate-config.json
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# ${opts.name}
|
|
25
|
+
|
|
26
|
+
${opts.description}
|
|
27
|
+
|
|
28
|
+
## When to use
|
|
29
|
+
|
|
30
|
+
Use when [describe the trigger conditions].
|
|
31
|
+
|
|
32
|
+
## Protocol
|
|
33
|
+
|
|
34
|
+
1. [Step 1]
|
|
35
|
+
2. [Step 2]
|
|
36
|
+
3. [Step 3]
|
|
37
|
+
|
|
38
|
+
## Output
|
|
39
|
+
|
|
40
|
+
Structured output per \`schemas/output.json\`.
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
/** Generate output schema template. */
|
|
44
|
+
function generateOutputSchema(name) {
|
|
45
|
+
return JSON.stringify({
|
|
46
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
47
|
+
title: `${name} output`,
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
status: { type: 'string', enum: ['success', 'failure', 'partial'] },
|
|
51
|
+
summary: { type: 'string' },
|
|
52
|
+
artifacts: { type: 'array', items: { type: 'string' } },
|
|
53
|
+
},
|
|
54
|
+
required: ['status', 'summary'],
|
|
55
|
+
}, null, 2);
|
|
56
|
+
}
|
|
57
|
+
/** Generate validate-config.json template. */
|
|
58
|
+
function generateValidateConfig(name) {
|
|
59
|
+
return JSON.stringify({
|
|
60
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
61
|
+
title: `${name} config validation`,
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
enabled: { type: 'boolean', default: true },
|
|
65
|
+
},
|
|
66
|
+
}, null, 2);
|
|
67
|
+
}
|
|
68
|
+
/** Generate eval template. */
|
|
69
|
+
function generateEval(name) {
|
|
70
|
+
return `# ${name} evaluation
|
|
71
|
+
# Run: aqe eval ${name}
|
|
72
|
+
|
|
73
|
+
test_cases:
|
|
74
|
+
- name: "basic invocation"
|
|
75
|
+
input: "Run ${name}"
|
|
76
|
+
expected:
|
|
77
|
+
status: success
|
|
78
|
+
summary_contains: "${name}"
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a new skill directory with all required files.
|
|
83
|
+
*
|
|
84
|
+
* Returns the list of created files. If the skill directory already exists,
|
|
85
|
+
* returns `alreadyExists: true` and creates nothing.
|
|
86
|
+
*/
|
|
87
|
+
export function createSkill(opts) {
|
|
88
|
+
const skillsDir = opts.skillsDir ?? '.claude/skills';
|
|
89
|
+
const skillDir = join(skillsDir, opts.name);
|
|
90
|
+
const filesCreated = [];
|
|
91
|
+
if (existsSync(skillDir)) {
|
|
92
|
+
return { skillDir, filesCreated: [], alreadyExists: true };
|
|
93
|
+
}
|
|
94
|
+
// Create directories
|
|
95
|
+
mkdirSync(join(skillDir, 'schemas'), { recursive: true });
|
|
96
|
+
mkdirSync(join(skillDir, 'scripts'), { recursive: true });
|
|
97
|
+
// SKILL.md
|
|
98
|
+
const skillMdPath = join(skillDir, 'SKILL.md');
|
|
99
|
+
writeFileSync(skillMdPath, generateSkillMd(opts));
|
|
100
|
+
filesCreated.push('SKILL.md');
|
|
101
|
+
// schemas/output.json
|
|
102
|
+
writeFileSync(join(skillDir, 'schemas', 'output.json'), generateOutputSchema(opts.name));
|
|
103
|
+
filesCreated.push('schemas/output.json');
|
|
104
|
+
// scripts/validate-config.json
|
|
105
|
+
writeFileSync(join(skillDir, 'scripts', 'validate-config.json'), generateValidateConfig(opts.name));
|
|
106
|
+
filesCreated.push('scripts/validate-config.json');
|
|
107
|
+
// Optional: evals/
|
|
108
|
+
if (opts.withEvals !== false) {
|
|
109
|
+
mkdirSync(join(skillDir, 'evals'), { recursive: true });
|
|
110
|
+
writeFileSync(join(skillDir, 'evals', `${opts.name}.yaml`), generateEval(opts.name));
|
|
111
|
+
filesCreated.push(`evals/${opts.name}.yaml`);
|
|
112
|
+
}
|
|
113
|
+
// Optional: references/
|
|
114
|
+
if (opts.withReferences) {
|
|
115
|
+
mkdirSync(join(skillDir, 'references'), { recursive: true });
|
|
116
|
+
writeFileSync(join(skillDir, 'references', '.gitkeep'), '');
|
|
117
|
+
filesCreated.push('references/.gitkeep');
|
|
118
|
+
}
|
|
119
|
+
return { skillDir, filesCreated, alreadyExists: false };
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=create-skill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-skill.js","sourceRoot":"","sources":["../src/create-skill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAyBjC,iEAAiE;AACjE,SAAS,eAAe,CAAC,IAAwB;IAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;IACjC,OAAO;SACA,IAAI,CAAC,IAAI;gBACF,IAAI,CAAC,WAAW;cAClB,IAAI;qBACG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,KAAK,CAA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AE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACrF,YAAY,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,wBAAwB;IACxB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5D,YAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAC1D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,6 @@ export * from './apply.js';
|
|
|
10
10
|
export * from './targets.js';
|
|
11
11
|
export * from './operations.js';
|
|
12
12
|
export * from './workflows.js';
|
|
13
|
+
export { createSkill } from './create-skill.js';
|
|
14
|
+
export type { CreateSkillOptions, CreateSkillResult } from './create-skill.js';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yDAAyD;AACzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill scaffolder — creates a complete SKILL.md directory structure.
|
|
3
|
+
*
|
|
4
|
+
* Generates: SKILL.md (agentskills.io frontmatter), schemas/output.json,
|
|
5
|
+
* scripts/validate-config.json. Optionally: evals/, references/.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
/** Options for skill creation. */
|
|
14
|
+
export interface CreateSkillOptions {
|
|
15
|
+
/** Skill id (kebab-case directory name). */
|
|
16
|
+
readonly name: string;
|
|
17
|
+
/** One-line description for SKILL.md frontmatter. */
|
|
18
|
+
readonly description: string;
|
|
19
|
+
/** Parent directory where skill dir will be created. Default: `.claude/skills`. */
|
|
20
|
+
readonly skillsDir?: string | undefined;
|
|
21
|
+
/** Include evals/ directory with template. */
|
|
22
|
+
readonly withEvals?: boolean | undefined;
|
|
23
|
+
/** Include references/ directory. */
|
|
24
|
+
readonly withReferences?: boolean | undefined;
|
|
25
|
+
/** Trust tier (1-3). Default: 1. */
|
|
26
|
+
readonly trustTier?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Result of skill creation. */
|
|
30
|
+
export interface CreateSkillResult {
|
|
31
|
+
readonly skillDir: string;
|
|
32
|
+
readonly filesCreated: readonly string[];
|
|
33
|
+
readonly alreadyExists: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Generate SKILL.md content with agentskills.io frontmatter. */
|
|
37
|
+
function generateSkillMd(opts: CreateSkillOptions): string {
|
|
38
|
+
const tier = opts.trustTier ?? 1;
|
|
39
|
+
return `---
|
|
40
|
+
name: "${opts.name}"
|
|
41
|
+
description: "${opts.description}"
|
|
42
|
+
trust_tier: ${tier}
|
|
43
|
+
trust_tier_label: "${tier === 3 ? 'Verified' : tier === 2 ? 'Validated' : 'Structured'}"
|
|
44
|
+
validation:
|
|
45
|
+
schema_path: schemas/output.json
|
|
46
|
+
validator_path: scripts/validate-config.json
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# ${opts.name}
|
|
50
|
+
|
|
51
|
+
${opts.description}
|
|
52
|
+
|
|
53
|
+
## When to use
|
|
54
|
+
|
|
55
|
+
Use when [describe the trigger conditions].
|
|
56
|
+
|
|
57
|
+
## Protocol
|
|
58
|
+
|
|
59
|
+
1. [Step 1]
|
|
60
|
+
2. [Step 2]
|
|
61
|
+
3. [Step 3]
|
|
62
|
+
|
|
63
|
+
## Output
|
|
64
|
+
|
|
65
|
+
Structured output per \`schemas/output.json\`.
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Generate output schema template. */
|
|
70
|
+
function generateOutputSchema(name: string): string {
|
|
71
|
+
return JSON.stringify({
|
|
72
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
73
|
+
title: `${name} output`,
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
status: { type: 'string', enum: ['success', 'failure', 'partial'] },
|
|
77
|
+
summary: { type: 'string' },
|
|
78
|
+
artifacts: { type: 'array', items: { type: 'string' } },
|
|
79
|
+
},
|
|
80
|
+
required: ['status', 'summary'],
|
|
81
|
+
}, null, 2);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Generate validate-config.json template. */
|
|
85
|
+
function generateValidateConfig(name: string): string {
|
|
86
|
+
return JSON.stringify({
|
|
87
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
88
|
+
title: `${name} config validation`,
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
enabled: { type: 'boolean', default: true },
|
|
92
|
+
},
|
|
93
|
+
}, null, 2);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Generate eval template. */
|
|
97
|
+
function generateEval(name: string): string {
|
|
98
|
+
return `# ${name} evaluation
|
|
99
|
+
# Run: aqe eval ${name}
|
|
100
|
+
|
|
101
|
+
test_cases:
|
|
102
|
+
- name: "basic invocation"
|
|
103
|
+
input: "Run ${name}"
|
|
104
|
+
expected:
|
|
105
|
+
status: success
|
|
106
|
+
summary_contains: "${name}"
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Create a new skill directory with all required files.
|
|
112
|
+
*
|
|
113
|
+
* Returns the list of created files. If the skill directory already exists,
|
|
114
|
+
* returns `alreadyExists: true` and creates nothing.
|
|
115
|
+
*/
|
|
116
|
+
export function createSkill(opts: CreateSkillOptions): CreateSkillResult {
|
|
117
|
+
const skillsDir = opts.skillsDir ?? '.claude/skills';
|
|
118
|
+
const skillDir = join(skillsDir, opts.name);
|
|
119
|
+
const filesCreated: string[] = [];
|
|
120
|
+
|
|
121
|
+
if (existsSync(skillDir)) {
|
|
122
|
+
return { skillDir, filesCreated: [], alreadyExists: true };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Create directories
|
|
126
|
+
mkdirSync(join(skillDir, 'schemas'), { recursive: true });
|
|
127
|
+
mkdirSync(join(skillDir, 'scripts'), { recursive: true });
|
|
128
|
+
|
|
129
|
+
// SKILL.md
|
|
130
|
+
const skillMdPath = join(skillDir, 'SKILL.md');
|
|
131
|
+
writeFileSync(skillMdPath, generateSkillMd(opts));
|
|
132
|
+
filesCreated.push('SKILL.md');
|
|
133
|
+
|
|
134
|
+
// schemas/output.json
|
|
135
|
+
writeFileSync(join(skillDir, 'schemas', 'output.json'), generateOutputSchema(opts.name));
|
|
136
|
+
filesCreated.push('schemas/output.json');
|
|
137
|
+
|
|
138
|
+
// scripts/validate-config.json
|
|
139
|
+
writeFileSync(join(skillDir, 'scripts', 'validate-config.json'), generateValidateConfig(opts.name));
|
|
140
|
+
filesCreated.push('scripts/validate-config.json');
|
|
141
|
+
|
|
142
|
+
// Optional: evals/
|
|
143
|
+
if (opts.withEvals !== false) {
|
|
144
|
+
mkdirSync(join(skillDir, 'evals'), { recursive: true });
|
|
145
|
+
writeFileSync(join(skillDir, 'evals', `${opts.name}.yaml`), generateEval(opts.name));
|
|
146
|
+
filesCreated.push(`evals/${opts.name}.yaml`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Optional: references/
|
|
150
|
+
if (opts.withReferences) {
|
|
151
|
+
mkdirSync(join(skillDir, 'references'), { recursive: true });
|
|
152
|
+
writeFileSync(join(skillDir, 'references', '.gitkeep'), '');
|
|
153
|
+
filesCreated.push('references/.gitkeep');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return { skillDir, filesCreated, alreadyExists: false };
|
|
157
|
+
}
|
package/src/index.ts
CHANGED