Skip to content

Commit 5451ace

Browse files
committed
Add a skill-md subcommand to print SKILL.md.
This makes the Latchkey command entirely self-contained. This fixes LAT-11.
1 parent 3c1b4d0 commit 5451ace

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
"latchkey": "./dist/src/cli.js"
1919
},
2020
"files": [
21-
"dist",
22-
"README.md",
23-
"LICENSE"
21+
"dist",
22+
"README.md",
23+
"LICENSE"
2424
],
2525
"scripts": {
2626
"prepublishOnly": "npm run build",
27-
"build": "tsc",
27+
"build": "tsc && node -e \"require('fs').cpSync('integrations', 'dist/integrations', {recursive:true})\" ",
2828
"dev": "tsc --watch",
2929
"lint": "eslint src tests scripts",
3030
"lint:fix": "eslint src tests scripts --fix",

src/cliCommands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { EncryptedStorage } from './encryptedStorage.js';
2121
import { Registry, REGISTRY } from './registry.js';
2222
import { LoginCancelledError, LoginFailedError } from './services/index.js';
2323
import { run as curlRun } from './curl.js';
24+
import { getSkillMdContent } from './skillMd.js';
2425

2526
// Curl flags that don't affect the HTTP request semantics but may not be supported by URL extraction.
2627
const CURL_PASSTHROUGH_FLAGS = new Set(['-v', '--verbose']);
@@ -203,6 +204,13 @@ export function registerCommands(program: Command, deps: CliDependencies): void
203204
deps.log(serviceNames.join(' '));
204205
});
205206

207+
program
208+
.command('skill-md')
209+
.description('Print the SKILL.md file for AI agent integration.')
210+
.action(async () => {
211+
deps.log(await getSkillMdContent());
212+
});
213+
206214
program
207215
.command('ensure-browser')
208216
.description('Ensure a Chrome/Chromium browser is available for Latchkey to use.')

src/skillMd.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { readFileSync } from 'node:fs';
2+
import { resolve } from 'node:path';
3+
4+
export async function getSkillMdContent(): Promise<string> {
5+
return readFileSync(await getSkillMdPath(), 'utf-8');
6+
}
7+
8+
async function getSkillMdPath(): Promise<string> {
9+
try {
10+
// @ts-expect-error - Bun-specific import attribute
11+
const mod = await import('../integrations/SKILL.md', { with: { type: 'text' } });
12+
return mod.default;
13+
} catch {
14+
return resolve(import.meta.dirname, '../integrations/SKILL.md');
15+
}
16+
}

0 commit comments

Comments
 (0)