init.js 612 B

1234567891011121314
  1. import { installWorkdir } from '../installer/index.js'
  2. /**
  3. * init [--hosts=a,b] [--force]:一条命令装出工作目录(multi-agent spec §8.1)。
  4. * 已有安装时等价 update(哈希三态,不静默覆盖手改)。
  5. * 契约:纯返回 {ok, output?, error?}。
  6. */
  7. export const scope = 'anywhere'
  8. export async function run(args, options, ctx) {
  9. const hostsOverride = options.hosts && options.hosts !== true ? options.hosts : null
  10. const r = await installWorkdir(ctx, { hostsOverride, force: !!options.force })
  11. return r.ok ? { ok: true, output: r.report } : { ok: false, error: r.error }
  12. }