import { Command } from 'commander'; import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { getWorkspaceDir } from '../lib/init-command.js'; import { getRuntimeDir } from '../lib/user-data.js'; import { resolveBundledClawclawSkill } from '../lib/skill-host.js'; export function createRuntimeCommand(): Command { const command = new Command('runtime').description('Inspect the effective local CCL installation'); command.command('info').option('--json').action(() => { const workspace = getWorkspaceDir(); const skillDirectory = resolveBundledClawclawSkill(); const root = dirname(dirname(skillDirectory)); const {version} = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')); console.log(JSON.stringify({ protocolVersion: 1, version, workspace, runtimeDirectory: getRuntimeDir(workspace), skillDirectory, executable: process.execPath, cli: join(root, 'bin', 'clawclaw-cli.mjs') })); }); command.command('skills').option('--json').action(async () => { const { AuthStore } = await import('../lib/auth.js'); const { accountManagedSkillSources } = await import('../lib/agent-workspace-skills.js'); const profile = new AuthStore().getActive(); const sources = profile ? accountManagedSkillSources(getWorkspaceDir(), profile) : new Map(); console.log(JSON.stringify(Array.from(sources, ([name, directory]) => ({ name, directory })))); }); return command; }