#!/usr/bin/env node // Copyright (c) 未来飞马 // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. // // Trademark Notice: // The MPL-2.0 license grants copyright permissions for source code only. // It does NOT grant any rights to use trademarks including "未来飞马", // "Harness Loop", "RSI", and associated slogan "让AI进化提前发生,让AI落地快人一步". // Any use of these trademarks requires separate written permission. /** * skill-deliverable CLI — 交付物自动上报 * Usage: * skill-deliverable check # 检查容器身份+凭据 * skill-deliverable report ... # 上报交付物 * skill-deliverable list # 列出上报记录 * skill-deliverable init # 初始化凭据 */ import { resolveAgentId, resolveSessionToken, report, list } from '../lib/index.mjs'; import { hostname } from 'node:os'; const [cmd, ...args] = process.argv.slice(2); switch (cmd) { case 'check': { const agentId = resolveAgentId(); const token = resolveSessionToken(); console.log(JSON.stringify({ agentId: agentId || '(缺失)', sessionToken: token ? token.slice(0, 12) + '...' : '(缺失)', status: (agentId && token) ? 'ready' : 'incomplete', hostname: hostname(), }, null, 2)); break; } case 'report': { const title = getArg('--title'); const summary = getArg('--summary') || ''; const project = getArg('--project') || ''; const artifacts = parseArg('--artifacts') || []; const tags = parseArg('--tags') || []; if (!title) { console.error('--title 必填'); process.exit(1); } const r = await report({ agentId: resolveAgentId(), title, summary, project, artifacts, tags }); console.log(JSON.stringify(r, null, 2)); break; } case 'list': { const limit = parseInt(getArg('--limit') || '5', 10); const items = await list({ limit }); console.log(JSON.stringify(items, null, 2)); break; } case 'init': { console.log('→ 凭据自举:尝试从 ~/.fmode/ 或 env 读取...'); const token = resolveSessionToken(); if (token) { console.log('✅ 已有 sessionToken,无需初始化'); } else { console.error('❌ 无 sessionToken。请设置 FMODE_SESSION_TOKEN 或登录 FMODE Studio'); process.exit(1); } break; } default: console.log(`用法: skill-deliverable check 检查容器身份+凭据状态 report 上报交付物 (--title <必填> --summary --project --artifacts --tags) list 最近上报记录 (--limit) init 初始化凭据`); } function getArg(name) { const i = args.indexOf(name); return i >= 0 ? args[i + 1] : undefined; } function parseArg(name) { const v = getArg(name); if (!v) return undefined; try { return JSON.parse(v); } catch { return v.split(','); } }