浏览 1.1.1 文档
1.1.1

ait worktree — 完整参考

查看、诊断、恢复、迁移并清理由 AIT 持有的 Task worktree 及其元数据。

适用人群: coding agent 与仓库运维

作用边界#

用途: 查看、诊断、恢复、迁移并清理由 AIT 持有的 Task worktree 及其元数据。

影响类别: 读取与本地恢复/清理混合的入口;确切的归属检查决定哪些写操作被允许。

覆盖: ait worktree 下共 16 个公开 help surface。

下面的代码块原样保留 1.1.1 二进制的输出,包含它给出的每一个参数、选项、 默认值、可选值、冲突关系和必填要求。

完整命令树#

代码 · text
ait worktree
ait worktree status
ait worktree restore
ait worktree show
ait worktree path
ait worktree doctor
ait worktree cleanup-candidates
ait worktree cleanup
ait worktree prune-stale
ait worktree list
ait worktree sync
ait worktree recreate
ait worktree recover-task
ait worktree restore-owned-head
ait worktree rebase
ait worktree remove

原样输出的 help#

ait worktree#

二进制描述: Inspect and maintain isolated worktrees that share repository .ait data while carrying their own checked-out files, current Line, and optional Task/Change binding. Normal Task worktrees are created by task start. Cleanup, prune-stale, and remove require --yes when applied; use --dry-run to preview destructive removal.

代码 · text
Inspect and maintain isolated worktrees that share repository .ait data while carrying their own checked-out files, current Line, and optional Task/Change binding. Normal Task worktrees are created by task start. Cleanup, prune-stale, and remove require --yes when applied; use --dry-run to preview destructive removal.

Usage: ait worktree <COMMAND>

Commands:
  status              Compare one checkout with a Line head or specific Snapshot.
  restore             Restore all or selected checkout content from a Line head or Snapshot.
  show                Show one registered worktree and its refreshed live status.
  path                Print one worktree path or a shell command that enters it. [alias: open]
  doctor              Summarize registered worktree health and cleanup classification.
  cleanup-candidates  Inspect policy-selected cleanup candidates without removing them.
  cleanup             Preview or remove policy-selected safe worktrees.
  prune-stale         Preview or prune missing and detached worktree registrations.
  list                List every registered worktree.
  sync                Synchronize one or all worktrees to their selected Line heads.
  recreate            Recreate a missing registered Task worktree.
  recover-task        Recover a local authoring worktree for an existing remote Task and Change.
  restore-owned-head  Restore the last contiguous Snapshot head owned by a bound Task worktree.
  rebase              Replay a worktree's feature delta onto a target base Line.
  remove              Preview or explicitly remove registered worktrees.
  help                Print this message or the help of the given subcommand(s)

Options:
  -h, --help
          Print help (see a summary with '-h')

说明

查看并维护隔离的 worktree:它们共享仓库 .ait 数据,但各自拥有 checkout 文件、当前 Line 和可选的 Task/Change 绑定。普通 Task worktree 由 task start 创建。应用 cleanup、prune-stale 和 remove 时必须带 --yes;用 --dry-run 预览破坏性删除。

参数 / 选项说明
status把一个 checkout 与 Line head 或特定 Snapshot 比较。
restore从 Line head 或 Snapshot 恢复全部或选定的检出内容。
show显示一个已注册 worktree 及其刷新后的实时状态。
path打印一个 worktree 路径,或一条进入该路径的 shell 命令。[alias: open]
doctor汇总已注册 worktree 的健康状况和清理分类。
cleanup-candidates查看按策略选出的清理候选,不删除它们。
cleanup预览或删除按策略选出的安全 worktree。
prune-stale预览或清理路径缺失和已脱离的 worktree 注册。
list列出每个已注册的 worktree。
sync将一个或全部 worktree 同步到其选定的 Line head。
recreate重建一个路径缺失的已注册 Task worktree。
recover-task为已有的远程 Task 和 Change 找回一个本地编写 worktree。
restore-owned-head恢复由绑定的 Task worktree 拥有的最后一段连续 Snapshot head。
rebase将一个 worktree 的功能增量重放到目标基 Line 上。
remove预览或显式删除已注册的 worktree。
help打印本消息或给定子命令的帮助

ait worktree status#

二进制描述: Report modified, missing, and untracked paths in the selected checkout without restoring content or moving a Line head. NAME selects a registered worktree; when omitted, inspect the current checkout. --snapshot and --line are mutually exclusive, and omission of both compares with the current Line head.

代码 · text
Report modified, missing, and untracked paths in the selected checkout without restoring content or moving a Line head. NAME selects a registered worktree; when omitted, inspect the current checkout. --snapshot and --line are mutually exclusive, and omission of both compares with the current Line head.

Usage: ait worktree status [OPTIONS] [NAME]

Arguments:
  [NAME]
          Registered worktree name; omit it to inspect the current checkout

Options:
      --snapshot <SNAPSHOT_ID>
          Compare with this exact local Snapshot instead of a Line head

      --line <LINE_NAME>
          Compare with this local Line head instead of the current Line head

      --verbose
          Show baseline and workspace-root detail in text output

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

报告所选检出中已修改、缺失和未跟踪的路径,不恢复内容也不移动 Line head。NAME 选择一个已注册 worktree;省略时查看当前检出。--snapshot 与 --line 互斥,两者都省略时与当前 Line head 比较。

ait worktree restore#

二进制描述: Restore the selected registered worktree, or the current checkout when NAME is omitted. With no source option, restore the whole checkout from its current Line head. --snapshot and --line are mutually exclusive. Every --path is an exact workspace-relative path and requires an explicit --snapshot or --line; selected-path restore does not switch the current Line. Unsaved changes require --force, while --dry-run only reports the restore plan.

代码 · text
Restore the selected registered worktree, or the current checkout when NAME is omitted. With no source option, restore the whole checkout from its current Line head. --snapshot and --line are mutually exclusive. Every --path is an exact workspace-relative path and requires an explicit --snapshot or --line; selected-path restore does not switch the current Line. Unsaved changes require --force, while --dry-run only reports the restore plan.

Usage: ait worktree restore [OPTIONS] [NAME]

Arguments:
  [NAME]
          Registered worktree name; omit it to restore the current checkout

Options:
      --snapshot <SNAPSHOT_ID>
          Restore from this exact local Snapshot; mutually exclusive with --line

      --line <LINE_NAME>
          Restore from this local Line head; a whole-checkout restore also switches the current Line

      --path <PATH>
          Restore one exact workspace-relative path; repeat for more paths and supply --snapshot or --line

      --force
          Overwrite unsaved changes in the selected files

      --dry-run
          Report writes, removals, and overwritten changes without restoring content

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

恢复所选的已注册 worktree,省略 NAME 时恢复当前检出。未给来源选项时,从其当前 Line head 恢复整个检出。--snapshot 与 --line 互斥。每个 --path 都是确切的工作区相对路径,且需要显式的 --snapshot 或 --line;按路径恢复不会切换当前 Line。有未保存改动时需要 --force,--dry-run 仅报告恢复计划。

ait worktree show#

二进制描述: Show the registered and current Line, checked-out Snapshot, Task/Change binding, cleanup classification, and rebase or merge state for one worktree. NAME may be omitted only when the current checkout belongs to a registered worktree.

代码 · text
Show the registered and current Line, checked-out Snapshot, Task/Change binding, cleanup classification, and rebase or merge state for one worktree. NAME may be omitted only when the current checkout belongs to a registered worktree.

Usage: ait worktree show [OPTIONS] [NAME]

Arguments:
  [NAME]
          Registered worktree name; omit it to use the current runtime worktree binding

Options:
      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

显示一个 worktree 的注册 Line 与当前 Line、checkout Snapshot、Task/Change 绑定、清理分类以及 rebase 或 merge 状态。只有当前 checkout 属于已注册 worktree 时,才可省略 NAME。

ait worktree path#

二进制描述: Print the managed alias path when available, otherwise the registered physical path. This command refreshes live status and records worktree use. --shell prints a command that changes directory and exports managed Cargo paths when enabled; the visible alias open has identical print-only behavior.

代码 · text
Print the managed alias path when available, otherwise the registered physical path. This command refreshes live status and records worktree use. --shell prints a command that changes directory and exports managed Cargo paths when enabled; the visible alias `open` has identical print-only behavior.

Usage: ait worktree path [OPTIONS] [NAME]

Arguments:
  [NAME]
          Registered worktree name; omit it to use the current runtime worktree binding

Options:
      --shell
          Print a shell command that enters the worktree and exports managed Cargo paths

      --json
          Emit machine-readable path, command, status, and managed runtime fields

  -h, --help
          Print help (see a summary with '-h')

说明

可用时打印受管别名路径,否则打印注册的物理路径。此命令会刷新实时状态并记录 worktree 的使用。--shell 打印一条切换目录并在启用时导出受管 Cargo 路径的命令;可见别名 open 具有完全相同的仅打印行为。

ait worktree doctor#

二进制描述: Summarize current, clean, dirty, missing, detached, protected, and cleanup-candidate worktrees. The default uses metadata and cached status without a full content scan. --refresh verifies live content and may refresh derived runtime layout and status caches.

代码 · text
Summarize current, clean, dirty, missing, detached, protected, and cleanup-candidate worktrees. The default uses metadata and cached status without a full content scan. --refresh verifies live content and may refresh derived runtime layout and status caches.

Usage: ait worktree doctor [OPTIONS]

Options:
      --refresh
          Verify each worktree's live content and refresh derived runtime status before reporting

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

汇总当前、干净、有改动、路径缺失、已脱离、受保护和清理候选的 worktree。默认使用元数据和缓存状态,不做完整内容扫描。--refresh 会核实实际内容,并可能刷新派生的运行时布局与状态缓存。

ait worktree cleanup-candidates#

二进制描述: Refresh and classify registered worktrees without removing paths or registrations. Filter by cleanup policy or idle age, opt clean manual-only worktrees into review, and optionally include protected rows with their exact reasons. Missing or detached registrations remain stale rather than cleanup candidates.

代码 · text
Refresh and classify registered worktrees without removing paths or registrations. Filter by cleanup policy or idle age, opt clean manual-only worktrees into review, and optionally include protected rows with their exact reasons. Missing or detached registrations remain stale rather than cleanup candidates.

Usage: ait worktree cleanup-candidates [OPTIONS]

Options:
      --older-than <DURATION>
          Idle threshold for after_idle policy, written as integer days, hours, or minutes (for example 7d, 12h, or 30m)
          
          [default: 7d]

      --policy <POLICY>
          Filter by cleanup policy: manual_only, after_remote_land, after_task_complete, after_idle, or never

      --allow-manual-only
          Classify otherwise-safe clean manual_only worktrees as explicit cleanup candidates

      --include-protected
          Include protected worktree rows and their reasons without making them removable

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

刷新并分类已注册的 worktree,不删除路径或注册。可按清理策略或空闲时长过滤、将干净的仅手动 worktree 纳入审查,并可选包含受保护行及其确切原因。路径缺失或已脱离的注册保持为陈旧状态,而不是清理候选。

ait worktree cleanup#

二进制描述: Select safe cleanup candidates using the same policy rules as cleanup-candidates. --dry-run previews the exact ordered removal plan without requiring confirmation. Applied cleanup deletes selected worktree paths, managed aliases, registrations, and managed Task Cargo build caches and therefore requires --yes.

代码 · text
Select safe cleanup candidates using the same policy rules as cleanup-candidates. --dry-run previews the exact ordered removal plan without requiring confirmation. Applied cleanup deletes selected worktree paths, managed aliases, registrations, and managed Task Cargo build caches and therefore requires --yes.

Usage: ait worktree cleanup [OPTIONS]

Options:
      --older-than <DURATION>
          Idle threshold for after_idle policy, written as integer days, hours, or minutes (for example 7d, 12h, or 30m)
          
          [default: 7d]

      --policy <POLICY>
          Filter by cleanup policy: manual_only, after_remote_land, after_task_complete, after_idle, or never

      --allow-manual-only
          Permit otherwise-safe clean manual_only worktrees to be selected for removal

      --limit <COUNT>
          Remove at most this many ordered candidates

      --dry-run
          Preview the exact ordered removals without changing paths or registrations

      --yes
          Confirm and apply cleanup removal; required unless --dry-run is supplied

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

使用与 cleanup-candidates 相同的策略规则选出安全清理候选。--dry-run 预览确切的有序删除计划,无需确认。实际清理会删除选定的 worktree 路径、受管别名、注册以及受管的 Task Cargo 构建缓存,因此需要 --yes。

ait worktree prune-stale#

二进制描述: Select registrations whose path is missing or whose worktree runtime layout is detached. Pruning removes stale registration and alias state without deleting surviving checkout content. --dry-run previews the exact rows; applied pruning requires --yes.

代码 · text
Select registrations whose path is missing or whose worktree runtime layout is detached. Pruning removes stale registration and alias state without deleting surviving checkout content. --dry-run previews the exact rows; applied pruning requires --yes.

Usage: ait worktree prune-stale [OPTIONS]

Options:
      --dry-run
          Preview missing and detached registrations without pruning them

      --yes
          Confirm and apply stale-registration pruning; required unless --dry-run is supplied

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

选出路径缺失或 worktree 运行时布局已脱离的注册。清理会删除陈旧的注册和别名状态,但不删除仍存在的检出内容。--dry-run 预览确切的行;实际清理需要 --yes。

ait worktree list#

二进制描述: List registered paths, current Lines, cached workspace status, cleanup classification, and current-context identity. --refresh verifies live content and may refresh derived runtime layout and status caches.

代码 · text
List registered paths, current Lines, cached workspace status, cleanup classification, and current-context identity. --refresh verifies live content and may refresh derived runtime layout and status caches.

Usage: ait worktree list [OPTIONS]

Options:
      --json
          Emit the complete stable machine-readable JSON array

      --refresh
          Verify live content and refresh derived runtime status for every worktree

  -h, --help
          Print help (see a summary with '-h')

说明

列出已注册路径、当前 Line、缓存的工作区状态、清理分类和当前上下文身份。--refresh 会核实实际内容,并可能刷新派生的运行时布局与状态缓存。

ait worktree sync#

二进制描述: Restore a complete registered worktree to a Line head and update its checked-out Snapshot, current Line, and runtime metadata. NAME selects one worktree; --all selects every available worktree and uses each one's current Line. --all cannot be combined with NAME or --line. Unsaved changes require --force, and --dry-run previews without applying the restore.

代码 · text
Restore a complete registered worktree to a Line head and update its checked-out Snapshot, current Line, and runtime metadata. NAME selects one worktree; --all selects every available worktree and uses each one's current Line. --all cannot be combined with NAME or --line. Unsaved changes require --force, and --dry-run previews without applying the restore.

Usage: ait worktree sync [OPTIONS] [NAME]

Arguments:
  [NAME]
          Registered worktree name; omit it to use the current runtime worktree binding

Options:
      --all
          Synchronize every live worktree to its own current Line; cannot be combined with NAME or --line

      --line <LINE_NAME>
          Synchronize one worktree to this Line head and make that Line current

      --force
          Overwrite unsaved changes while synchronizing

      --dry-run
          Preview complete restore plans without synchronizing content or metadata

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

把一个完整注册的 worktree 恢复到 Line head,并更新其 checkout Snapshot、当前 Line 和运行时元数据。NAME 选择一个 worktree;--all 选择所有可用 worktree,并使用各自当前 Line。--all 不能与 NAME 或 --line 组合。未保存改动必须带 --force;--dry-run 只预览,不应用恢复。

ait worktree recreate#

二进制描述: Recreate the recorded path and alias of a Task-bound worktree whose registered path is missing. Recovery selects the first locally available current-Line head, fork Snapshot, or selected remote Patchset revision. An existing or unbound worktree is rejected; --dry-run validates and reports the candidate without creating its files.

代码 · text
Recreate the recorded path and alias of a Task-bound worktree whose registered path is missing. Recovery selects the first locally available current-Line head, fork Snapshot, or selected remote Patchset revision. An existing or unbound worktree is rejected; --dry-run validates and reports the candidate without creating its files.

Usage: ait worktree recreate [OPTIONS] [NAME]

Arguments:
  [NAME]
          Missing registered Task worktree name; omit it to use the current runtime binding

Options:
      --dry-run
          Validate recovery candidates, path, and alias without recreating the worktree

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

重建注册路径缺失的 Task 绑定 worktree 的已记录路径和别名。恢复会依次选择本地可用的当前 Line head、fork Snapshot 或选定远程 Patchset 修订。已有或未绑定的 worktree 会被拒绝;--dry-run 只校验并报告候选,不创建文件。

ait worktree recover-task#

二进制描述: Run from the main repository root to validate an active or draft remote Task and its draft or review Change, then recreate their local feature Line and Task-bound worktree. This command does not create a remote Task or Change. If a registration already exists but its path is missing, use worktree recreate instead.

代码 · text
Run from the main repository root to validate an active or draft remote Task and its draft or review Change, then recreate their local feature Line and Task-bound worktree. This command does not create a remote Task or Change. If a registration already exists but its path is missing, use worktree recreate instead.

Usage: ait worktree recover-task [OPTIONS] --change <CHANGE> <TASK_ID>

Arguments:
  <TASK_ID>
          Existing remote Task ID to recover

Options:
      --change <CHANGE>
          Existing remote Change ID or Task-owned Change reference

      --remote <REMOTE>
          Configured remote name; omit it to use the effective default remote

      --dry-run
          Validate remote identity, local Snapshots, and placement without creating a worktree

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

从主仓库根运行,校验活动或 draft 远程 Task 及其 draft 或 review Change,然后重建其本地功能 Line 和 Task 绑定 worktree。此命令不会创建远程 Task 或 Change。如果注册已存在但路径缺失,应改用 worktree recreate。

ait worktree restore-owned-head#

二进制描述: Inspect first-parent history after the registered fork and retain the last contiguous Snapshot owned by the bound Task, Change, and worktree. Any first foreign Snapshot and its descendants are dropped from the Line head. The worktree must be Task-bound, clean, and outside a conflicted rebase; --dry-run reports the ownership decision without changing content or the head.

代码 · text
Inspect first-parent history after the registered fork and retain the last contiguous Snapshot owned by the bound Task, Change, and worktree. Any first foreign Snapshot and its descendants are dropped from the Line head. The worktree must be Task-bound, clean, and outside a conflicted rebase; --dry-run reports the ownership decision without changing content or the head.

Usage: ait worktree restore-owned-head [OPTIONS] [NAME]

Arguments:
  [NAME]
          Task-bound worktree name; omit it to use the current runtime worktree binding

Options:
      --dry-run
          Report the retained owned head and dropped foreign Snapshots without restoring

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

检查注册分叉之后的第一父级历史,保留由绑定的 Task、Change 和 worktree 拥有的最后一段连续 Snapshot。首个外来 Snapshot 及其后代会从 Line head 上丢弃。该 worktree 必须绑定 Task、干净且不处于冲突 rebase 中;--dry-run 只报告归属判定,不更改内容或 head。

ait worktree rebase#

二进制描述: Rebase the current feature Line from its registered fork onto --onto or the recorded target base Line. Starting an applied rebase requires a clean worktree. --dry-run previews ancestry, writes, removals, and conflicts. A conflicted rebase must later use exactly one of --continue or --abort; neither continuation mode accepts --dry-run.

代码 · text
Rebase the current feature Line from its registered fork onto --onto or the recorded target base Line. Starting an applied rebase requires a clean worktree. --dry-run previews ancestry, writes, removals, and conflicts. A conflicted rebase must later use exactly one of --continue or --abort; neither continuation mode accepts --dry-run.

Usage: ait worktree rebase [OPTIONS] [NAME]

Arguments:
  [NAME]
          Registered worktree name; omit it to use the current runtime worktree binding

Options:
      --onto <LINE_NAME>
          Target base Line for a new rebase; omit it to use recorded target metadata

      --continue
          Snapshot the resolved conflicted workspace and complete its rebase

      --abort
          Discard conflicted workspace resolution and restore the original head

      --dry-run
          Preview a new rebase plan; cannot be combined with --continue or --abort

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

将当前功能 Line 从其注册分叉 rebase 到 --onto 或记录的目标基 Line 上。实际启动 rebase 需要干净的 worktree。--dry-run 预览祖先关系、写入、删除和冲突。发生冲突的 rebase 之后必须恰好使用 --continue 或 --abort 之一;两种续作模式都不接受 --dry-run。

ait worktree remove#

二进制描述: Remove one or more named worktree registrations, managed aliases, and runtime identity files, leaving ordinary checkout content unless --delete-path is supplied. --all-stale performs the same stale-registration pruning as prune-stale and cannot be combined with names, --delete-path, or --force. --dry-run previews the exact plan; every applied removal requires --yes.

代码 · text
Remove one or more named worktree registrations, managed aliases, and runtime identity files, leaving ordinary checkout content unless --delete-path is supplied. --all-stale performs the same stale-registration pruning as prune-stale and cannot be combined with names, --delete-path, or --force. --dry-run previews the exact plan; every applied removal requires --yes.

Usage: ait worktree remove [OPTIONS] [NAME]...

Arguments:
  [NAME]...
          One or more registered worktree names; mutually exclusive with --all-stale

Options:
      --all-stale
          Prune every missing or detached registration; cannot be combined with names, --delete-path, or --force

      --delete-path
          Also delete each physical worktree path and managed Task Cargo build cache

      --force
          Permit explicit removal of dirty worktrees; does not bypass other safety checks

      --dry-run
          Preview exact removals without changing paths, aliases, or registrations

      --yes
          Confirm and apply worktree removal; required unless --dry-run is supplied

      --json
          Emit the complete stable machine-readable JSON payload

  -h, --help
          Print help (see a summary with '-h')

说明

删除一个或多个指定名称的 worktree 注册、受管别名和运行时身份文件,除非提供 --delete-path,否则保留普通检出内容。--all-stale 执行与 prune-stale 相同的陈旧注册清理,不能与名称、--delete-path 或 --force 组合。--dry-run 预览确切计划;每次实际删除都需要 --yes。

版本权威

对照 1.1.1 源码逐条核对

这一页是公开文档,不是第二份产品契约。要确认发布权威,请以确切的源码和分发契约为准。

所属组件 Snapshot
  • ait-coreSNP-ED7593DBF982
  • ait-serverSNP-0CCD7DD2A077
  • ait-runnerSNP-35C9C133D2EE
  • ait-pythonSNP-756C731A4CC0
  • ait-nodeSNP-55E90D0A81F1