Files
msd-core/tests/kimi-skill-converter.test.cjs
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

95 lines
3.4 KiB
JavaScript

/**
* Kimi CLI skill converter tests.
*
* Kimi Agent Skills use msd-<command>/SKILL.md directories with lowercase
* hyphenated frontmatter names and /skill:<name> invocation syntax.
*/
process.env.MSD_TEST_MODE = '1';
const { test, describe } = require('node:test');
const assert = require('node:assert/strict');
const {
convertClaudeCommandToKimiSkill,
} = require('../bin/install.js');
function sampleCommand() {
return [
'---',
'name: msd:new-project',
'description: Create a new MSD project',
'allowed-tools:',
' - Read',
' - Bash',
'agent: msd-planner',
'tools: Read, Bash',
'model: opus',
'color: blue',
'skills:',
' - msd-planner-workflow',
'hooks:',
' PostToolUse:',
' - matcher: "Write|Edit"',
'---',
'',
'Invoke /msd:new-project from slash form.',
'Invoke msd:new-project from bare colon form.',
'Invoke /msd-new-project from hyphen slash form.',
'Invoke $msd-new-project from shell-style form.',
'Do not rewrite /msd-tools, msd-new-projector, or $msd-planets.',
].join('\n');
}
describe('convertClaudeCommandToKimiSkill', () => {
test('emits Kimi SKILL.md frontmatter with name and description only', () => {
const result = convertClaudeCommandToKimiSkill(sampleCommand(), 'msd-new-project');
assert.ok(result.startsWith('---\n'), 'frontmatter starts with ---');
assert.ok(result.includes('\n---\n'), 'frontmatter closes with ---');
assert.ok(result.includes('name: msd-new-project'), 'frontmatter name uses Kimi-safe hyphen form');
assert.ok(
result.includes('description: "Create a new MSD project"'),
'description is preserved from source frontmatter'
);
for (const unsupported of [
'allowed-tools',
'agent',
'tools',
'model',
'color',
'skills',
'hooks',
]) {
assert.ok(!result.includes(`${unsupported}:`), `${unsupported}: is stripped from Kimi frontmatter`);
}
});
test('rewrites MSD command references to Kimi skill invocation syntax', () => {
const result = convertClaudeCommandToKimiSkill(sampleCommand(), 'msd-new-project');
assert.equal(
(result.match(/\/skill:msd-new-project/g) || []).length,
5,
'self invocation hint and all supported source invocation forms are emitted'
);
assert.ok(!result.includes('/msd:new-project'), 'slash colon form is removed');
assert.ok(!result.includes('msd:new-project'), 'bare colon form is removed');
assert.ok(!result.includes('/msd-new-project'), 'slash hyphen form is removed');
assert.ok(!result.includes('$msd-new-project'), 'shell-style form is removed');
});
test('does not rewrite unrelated words or introduce Phase 3 artifacts', () => {
const result = convertClaudeCommandToKimiSkill(sampleCommand(), 'msd-new-project');
assert.ok(result.includes('/msd-tools'), 'non-command slash token is preserved');
assert.ok(result.includes('msd-new-projector'), 'longer hyphenated word is preserved');
assert.ok(result.includes('$msd-planets'), 'unrelated shell-style token is preserved');
assert.ok(!result.includes('type: flow'), 'Phase 2 does not create Kimi flow skills');
assert.ok(!result.includes('kimi_cli.tools'), 'Phase 2 does not emit Kimi tool module paths');
assert.ok(!result.includes('system_prompt_path'), 'Phase 2 does not emit custom agent YAML');
assert.ok(!result.includes('version: 1'), 'Phase 2 does not emit Kimi agent YAML markers');
});
});