63 lines
2.0 KiB
JavaScript
Executable File
63 lines
2.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
const crypto = require('node:crypto');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const projectRoot = path.resolve(__dirname, '..');
|
|
const source = path.join(projectRoot, 'skills', 'crypstie', 'SKILL.md');
|
|
const outputRoot = path.resolve(process.argv[2] || path.join(projectRoot, 'build', 'agent-skills'));
|
|
const skillDirectory = path.join(outputRoot, 'crypstie');
|
|
const skillTarget = path.join(skillDirectory, 'SKILL.md');
|
|
const indexTarget = path.join(outputRoot, 'index.json');
|
|
const llmsTarget = path.join(outputRoot, 'llms.txt');
|
|
|
|
const skill = fs.readFileSync(source);
|
|
const text = skill.toString('utf8');
|
|
const description = text.match(/^description:\s*(.+)$/m)?.[1]?.trim();
|
|
|
|
if (!description) {
|
|
throw new Error('skills/crypstie/SKILL.md has no description in its frontmatter');
|
|
}
|
|
|
|
fs.mkdirSync(skillDirectory, { recursive: true });
|
|
fs.writeFileSync(skillTarget, skill);
|
|
|
|
const digest = crypto.createHash('sha256').update(skill).digest('hex');
|
|
const index = {
|
|
$schema: 'https://schemas.agentskills.io/discovery/0.2.0/schema.json',
|
|
skills: [
|
|
{
|
|
name: 'crypstie',
|
|
type: 'skill-md',
|
|
description,
|
|
url: '/.well-known/agent-skills/crypstie/SKILL.md',
|
|
digest: `sha256:${digest}`,
|
|
},
|
|
],
|
|
};
|
|
|
|
fs.writeFileSync(indexTarget, `${JSON.stringify(index, null, 2)}\n`);
|
|
fs.writeFileSync(
|
|
llmsTarget,
|
|
[
|
|
'# Crypstie',
|
|
'',
|
|
'> End-to-end encrypted links for text and files.',
|
|
'',
|
|
'## Agent skill',
|
|
'',
|
|
'- [Crypstie skill](https://crypstie.com/.well-known/agent-skills/crypstie/SKILL.md): Create and open Crypstie links with the npm CLI.',
|
|
'- [Skill discovery index](https://crypstie.com/.well-known/agent-skills/index.json): Machine-readable Agent Skills index with integrity metadata.',
|
|
'',
|
|
'## Package',
|
|
'',
|
|
'- [crypstie on npm](https://www.npmjs.com/package/crypstie): Node.js library and command-line client.',
|
|
'',
|
|
].join('\n'),
|
|
);
|
|
|
|
console.log(outputRoot);
|