Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Install the CLI:

```bash
curl -fsSL https://raw.githubusercontent.com/mainline-org/mainline/main/install.sh | bash
mainline doctor --setup
mainline version
```

You can also install with Go:
Expand All @@ -147,6 +147,10 @@ go install github.com/mainline-org/mainline@latest
Downloadable release archives and checksums are published on
[GitHub Releases](https://github.com/mainline-org/mainline/releases/latest).

`mainline version` only verifies that the CLI is installed and on your `PATH`.
`mainline doctor --setup` is a per-repository wiring check and expects to run
inside a Git repository.

Initialize each repo once:

```bash
Expand Down
5 changes: 4 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ mainline seal --submit --json < .ml-cache/seal.json

```bash
curl -fsSL https://raw.githubusercontent.com/mainline-org/mainline/main/install.sh | bash
mainline doctor --setup
mainline version
```

也可以用 Go 安装:
Expand All @@ -126,6 +126,9 @@ go install github.com/mainline-org/mainline@latest
预编译 archive 和 checksums 在
[GitHub Releases](https://github.com/mainline-org/mainline/releases/latest)。

`mainline version` 只验证 CLI 已安装并且在 `PATH` 中。`mainline doctor --setup`
是每个 repo 内的配置检查,需要在 Git 仓库里运行。

每个 repo 初始化一次:

```bash
Expand Down
12 changes: 9 additions & 3 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ cd mainline
go build -o mainline .
```

Verify setup at any time:
Verify the installed binary after any install method:

```bash
mainline doctor --setup
mainline version
```

## Getting Started With An Agent
Expand All @@ -82,6 +82,12 @@ One-time setup per repository:
mainline init --actor-name "<your name>"
```

Verify repository wiring from inside that Git repository:

```bash
mainline doctor --setup
```

`mainline init` does three things:

1. Writes `.mainline/config.toml` and configures Git refspecs.
Expand Down Expand Up @@ -435,7 +441,7 @@ Reviewer and maintainer extras:
| `mainline followups add` | Add explicit deferred work. |
| `mainline check --prepare` | Prepare a phase-2 conflict review task package. |
| `mainline check --submit` | Submit phase-2 judgment. |
| `mainline doctor --setup` | Verify installation, refspecs, identity, `.gitignore`, and optional policy state. |
| `mainline doctor --setup` | Verify repository wiring: refspecs, identity, `.gitignore`, and optional policy state. |
| `mainline init --rewire` | Re-apply refspec config, notes display refs, and `.gitignore` entries. |

All commands accept `--json`. The persistent `--no-sync` flag opts a command out
Expand Down
12 changes: 9 additions & 3 deletions docs/reference.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ cd mainline
go build -o mainline .
```

随时检查本机配置
用任意方式安装后,可以这样确认二进制已安装

```bash
mainline doctor --setup
mainline version
```

## 让 Agent 用起来
Expand All @@ -76,6 +76,12 @@ mainline doctor --setup
mainline init --actor-name "<你的名字>"
```

在这个 Git 仓库里检查仓库配置:

```bash
mainline doctor --setup
```

`mainline init` 做三件事:

1. 写入 `.mainline/config.toml` 并配置 Git refspecs。
Expand Down Expand Up @@ -394,7 +400,7 @@ Reviewer / maintainer 额外命令:
| `mainline followups add` | 添加 explicit deferred work。 |
| `mainline check --prepare` | 准备 phase-2 conflict review task package。 |
| `mainline check --submit` | 提交 phase-2 judgment。 |
| `mainline doctor --setup` | 检查安装、refspecs、identity、`.gitignore` 和 policy state。 |
| `mainline doctor --setup` | 检查仓库配置:refspecs、identity、`.gitignore` 和 policy state。 |
| `mainline init --rewire` | 重新应用 refspec config、notes display refs 和 `.gitignore` 条目。 |

所有命令都支持 `--json`。`--no-sync` 可以跳过 auto-sync wrapper。
Expand Down
19 changes: 17 additions & 2 deletions internal/cli/doctor.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package cli

import (
"errors"
"fmt"
"time"

"github.com/spf13/cobra"

"github.com/mainline-org/mainline/internal/domain"
"github.com/mainline-org/mainline/internal/engine"
)

Expand All @@ -24,7 +26,7 @@ var doctorCmd = &cobra.Command{
Long: `Default mode: scans local drafts for orphans (referencing missing
git branches) and stale ones; --fix deletes orphans.

--setup mode: runs install / wiring sanity checks — verifies the git
--setup mode: runs repository wiring sanity checks — verifies the git
remote refspec configuration, identity file, and .gitignore.
Combined with --fix, missing remote refspec entries
are rewired in place. Use this as the first step when 'mainline sync'
Expand All @@ -39,6 +41,19 @@ or force-pushes. It is read-only; use migrate notes for repairs.`,
Run: func(cmd *cobra.Command, args []string) {
svc, err := getService()
if err != nil {
if doctorSetup {
var mlErr *domain.MainlineError
if errors.As(err, &mlErr) && mlErr.Code == domain.ErrNotInGitRepo {
outputError(domain.NewRecoverableError(
domain.ErrNotInGitRepo,
"doctor --setup must run inside a Git repository",
"`mainline version` verifies that the CLI is installed",
"`cd <repo>` to an existing Git repository, or run `git init` first",
"then run `mainline init --actor-name \"<your name>\"` before `mainline doctor --setup`",
))
return
}
}
outputError(err)
return
}
Expand Down Expand Up @@ -251,7 +266,7 @@ func renderSetupReport(r *engine.DoctorSetupReport, fixed bool) {
func init() {
doctorCmd.Flags().BoolVar(&doctorFix, "fix", false, "delete orphan local draft files (default mode), or rewire refspecs (with --setup)")
doctorCmd.Flags().DurationVar(&doctorStaleAfter, "stale-after", 24*time.Hour, "mark drafting intents stale after this duration")
doctorCmd.Flags().BoolVar(&doctorSetup, "setup", false, "run install / wiring sanity checks (refspec, identity, .gitignore)")
doctorCmd.Flags().BoolVar(&doctorSetup, "setup", false, "run repository wiring sanity checks (refspec, identity, .gitignore)")
doctorCmd.Flags().BoolVar(&doctorProposals, "proposals", false, "diagnose proposed intents that may need cleanup")
doctorCmd.Flags().DurationVar(&doctorStaleProposedAfter, "stale-proposed-after", engine.DefaultStaleProposedAfter, "mark proposed intents suspicious after this duration")
doctorCmd.Flags().BoolVar(&doctorNotes, "notes", false, "diagnose git-notes rewrite drift after history rewrites")
Expand Down
Loading