Skip to content

機能仕様書: Agent向け CLI schema/dry-run/strict validation #100

@akiojin

Description

@akiojin

Spec

Background

Agent からの CLI 利用で、ツール仕様の内省不足と副作用制御不足が原因で再試行や失敗率が増える。

User Scenarios

  • P0: Agent が tool schema で入力仕様を取得し、正しい JSON を生成できる
  • P0: 変更系コマンドを --dry-run で安全に事前確認できる
  • P1: 不正な入力が実行前に明確なエラーで拒否される

Functional Requirements

  • FR-001: unity-cli tool schema [tool_name] を提供する
  • FR-002: tool schema は全ツール分の最小機械可読スキーマを返す
  • FR-003: グローバル --dry-run は mutating ツールのみ実行抑止する
  • FR-004: バッチ実行で --dry-run 指定時、mutating ツールを item 単位で skip する
  • FR-005: 明示スキーマ対象は strict validation(required/type/additionalProperties)を適用する

Non-Functional Requirements

  • NFR-001: tool list の既存出力互換を維持する
  • NFR-002: validation エラーは tool 名とフィールド位置を含む

Success Criteria

  • SC-001: tool schema --output json で全ツール定義が返る
  • SC-002: --dry-run で変更系実行が抑止される
  • SC-003: 不正パラメータが実行前にエラー化される

Plan

  • CLIに tool schema--dry-run を追加
  • ツールカタログに ToolSpec/schema/metadata を追加
  • 実行経路に共通 validation + dry-run 判定を追加
  • batch は通常経路互換を維持しつつ dry-run item skip を追加
  • README/docs を更新

Tasks

  • CLI定義に --dry-run / tool schema 追加
  • tool_catalogToolSpec と最小スキーマ群を追加
  • 実行前 strict validation を追加
  • mutating 判定による dry-run スキップを追加
  • batch dry-run item skip を追加
  • ユニットテスト追加
  • ドキュメント更新

TDD

  • RED: schemaコマンド、validation失敗、dry-runスキップのテストを先に追加
  • GREEN: 最小実装でテストを通過
  • REFACTOR: 共通関数化、既存互換維持を確認

Research

  • 既存構成: src/cli.rs, src/main.rs, src/tool_catalog.rs
  • 既存 batch 挙動は通常経路で維持すべき(回帰防止)

Data Model

  • ToolSpec
    • name, description, mutating, executor, params_schema, response_schema

Quickstart

cargo run -- tool schema ping --output json
cargo run -- --dry-run tool call create_scene --json {sceneName:Main} --output json
cargo run -- tool call ping --json {unknown:true} --output json

Contracts

Artifact files are managed in issue comments with contract:<name> entries.

Checklists

Artifact files are managed in issue comments with checklist:<name> entries.

Acceptance Checklist

  • tool schema 実装
  • --dry-run 実装
  • strict validation 実装
  • テスト通過(cargo test --all-targets
  • clippy 通過(cargo clippy --all-targets -- -D warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions