Skip to content

Commit 8ccb4b3

Browse files
author
echoVic
committed
feat: 更新版本至0.0.14并重构存储路径结构
重构存储路径从项目内.bar/迁移到~/.bar/目录 新增GlobalBarDir()和ProjectID()函数 移除.gitignore检查逻辑 添加路径相关单元测试 更新CHANGELOG.md和文档 改进release.sh脚本支持版本管理
1 parent bb88f8c commit 8ccb4b3

13 files changed

Lines changed: 524 additions & 67 deletions

File tree

CHANGELOG.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.0.13] - 2026-02-01
9+
10+
### Changed
11+
- Web UI 改进
12+
13+
## [0.0.12] - 2026-02-01
14+
15+
### Fixed
16+
- 修复 wrapped 命令退出时关闭 Web UI
17+
18+
## [0.0.11] - 2026-02-01
19+
20+
### Fixed
21+
- 修复 wrapped 命令退出后保持 Web UI 运行
22+
23+
## [0.0.10] - 2026-02-01
24+
25+
### Changed
26+
- `bar wrap` 默认启用 Web UI
27+
28+
### Fixed
29+
- 修复 `bar wrap --ui` 的 URL 格式
30+
31+
## [0.0.9] - 2026-02-01
32+
33+
### Added
34+
- `bar wrap` 新增 `--ui` 参数
35+
36+
## [0.0.8] - 2026-02-01
37+
38+
### Changed
39+
- Web UI v2 重新设计(Split View + Monaco Editor)
40+
41+
## [0.0.7] - 2026-02-01
42+
43+
### Added
44+
- Web UI 任务审计界面
45+
46+
## [0.0.6] - 2026-02-01
47+
48+
### Fixed
49+
- 修复 release 脚本中 cmd/bar 文件强制添加
50+
51+
## [0.0.5] - 2026-02-01
52+
53+
### Added
54+
- `bar wrap` 自动初始化并创建任务
55+
56+
## [0.0.4] - 2026-02-01
57+
58+
### Added
59+
- `bar update` 命令
60+
- `bar version` 命令
61+
62+
## [0.0.3] - 2026-02-01
63+
64+
### Added
65+
- 任务启动时自动初始化 BAR
66+
67+
## [0.0.2] - 2026-02-01
68+
69+
### Added
70+
- `bar wrap` 命令,支持交互式 Agent
71+
- curl 安装脚本
72+
- GitHub Pages 短链接安装
73+
74+
## [0.0.1] - 2026-02-01
75+
76+
### Added
77+
- 初始实现 Blade Agent Runtime (BAR)
78+
- 核心功能:任务管理、diff/apply、workspace 管理
79+
- CLI 命令:init, task, run, diff, apply, rollback, status, log
80+
- Policy 引擎
81+
- 单元测试

cmd/bar/init.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ package main
33
import (
44
"os"
55
"path/filepath"
6-
"strings"
76

87
"github.com/spf13/cobra"
98

109
"github.com/user/blade-agent-runtime/internal/core/config"
1110
"github.com/user/blade-agent-runtime/internal/core/task"
12-
utillog "github.com/user/blade-agent-runtime/internal/util/log"
1311
utilpath "github.com/user/blade-agent-runtime/internal/util/path"
1412
)
1513

@@ -45,7 +43,6 @@ func initCmd() *cobra.Command {
4543
return err
4644
}
4745
app.Logger.Info("Initialized BAR in %s", app.BarDir)
48-
checkGitignore(app.RepoRoot, app.Logger)
4946
return nil
5047
},
5148
}
@@ -104,7 +101,6 @@ func initAppWithAutoInit() (*App, error) {
104101
if err != nil {
105102
return nil, err
106103
}
107-
checkGitignore(repoRoot, app.Logger)
108104
return app, nil
109105
}
110106

@@ -131,20 +127,5 @@ func ensureBarInit(app *App) error {
131127
return err
132128
}
133129
app.Logger.Info("Initialized BAR in %s", app.BarDir)
134-
checkGitignore(app.RepoRoot, app.Logger)
135130
return nil
136131
}
137-
138-
func checkGitignore(repoRoot string, logger *utillog.Logger) {
139-
path := filepath.Join(repoRoot, ".gitignore")
140-
data, err := os.ReadFile(path)
141-
if err != nil {
142-
logger.Info("Tip: Add '.bar/' to your .gitignore")
143-
return
144-
}
145-
146-
content := string(data)
147-
if !strings.Contains(content, ".bar/") && !strings.Contains(content, ".bar") {
148-
logger.Info("Tip: Add '.bar/' to your .gitignore")
149-
}
150-
}

cmd/bar/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
repoOwner = "echoVic"
1717
repoName = "blade-agent-runtime"
1818
installURL = "https://echovic.github.io/blade-agent-runtime/install.sh"
19-
currentVersion = "0.0.13"
19+
currentVersion = "0.0.14"
2020
)
2121

2222
func updateCmd() *cobra.Command {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/rfcs/storage-migration.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# 存档目录迁移:从 `.bar``~/.bar`
2+
3+
## 背景
4+
5+
原设计将存档目录放在项目内的 `.bar/`,存在以下问题:
6+
1. 每个项目都需要在 `.gitignore` 中添加 `.bar/`
7+
2. 不符合常见 CLI 工具的惯例(如 `~/.npm`, `~/.cargo`, `~/.docker`
8+
3. workspaces 使用 git worktree 会在项目内创建大量副本
9+
10+
## 设计决策
11+
12+
### 方案对比
13+
14+
| 方案 | 结构 | 优点 | 缺点 |
15+
|------|------|------|------|
16+
| A: Hash 映射 | `~/.bar/repos/<hash>/` | 绝对唯一 | 不直观,需要额外映射文件 |
17+
| B: 项目名分组 | `~/.bar/projects/<name>/` | 直观可读 | 同名项目冲突 |
18+
| C: 项目名+Hash | `~/.bar/projects/<name>-<hash4>/` | 直观且唯一 | 名称稍长 |
19+
20+
**最终选择方案 C**`<项目名>-<路径SHA256前4位>`,兼顾可读性和唯一性。
21+
22+
## 新目录结构
23+
24+
```
25+
~/.bar/
26+
├── config.yaml # 全局配置(可选)
27+
└── projects/
28+
└── <project_name>-<hash4>/ # 如 "blade-agent-runtime-a3f2"
29+
├── state.json
30+
├── tasks/
31+
│ └── <task_id>/
32+
│ ├── task.json
33+
│ ├── ledger.jsonl
34+
│ └── artifacts/
35+
└── workspaces/
36+
└── <task_id>/
37+
```
38+
39+
**命名规则**: `<项目目录名>-<路径SHA256前4位>`
40+
- 例如: `/Users/bytedance/Documents/GitHub/blade-agent-runtime``blade-agent-runtime-a3f2`
41+
42+
## 修改文件清单
43+
44+
| 文件 | 修改内容 |
45+
|------|----------|
46+
| `internal/util/path/path.go` | 新增 `GlobalBarDir()` 返回 `~/.bar`;新增 `ProjectID(repoRoot)` 生成 `name-hash4` |
47+
| `cmd/bar/root.go` | 修改 `initApp()` 使用新的 barDir 路径 |
48+
| `cmd/bar/init.go` | 移除 `.gitignore` 检查逻辑 |
49+
| `internal/core/config/model.go` | 调整默认 policy 路径 |
50+
51+
## 具体修改
52+
53+
### 1. `internal/util/path/path.go`
54+
```go
55+
func GlobalBarDir() string {
56+
home, _ := os.UserHomeDir()
57+
return filepath.Join(home, ".bar")
58+
}
59+
60+
func ProjectID(repoRoot string) string {
61+
name := filepath.Base(repoRoot)
62+
hash := sha256.Sum256([]byte(repoRoot))
63+
return fmt.Sprintf("%s-%x", name, hash[:2]) // 前4位hex
64+
}
65+
66+
func BarDir(repoRoot string) string {
67+
return filepath.Join(GlobalBarDir(), "projects", ProjectID(repoRoot))
68+
}
69+
```
70+
71+
### 2. `cmd/bar/init.go`
72+
- 删除 `checkGitignore()` 函数及其调用
73+
74+
### 3. `internal/util/path/path_test.go`
75+
新增单元测试覆盖:
76+
- `TestGlobalBarDir` - 验证返回 `~/.bar`
77+
- `TestProjectID` - 验证格式为 `<项目名>-<4位hash>`
78+
- `TestProjectID_Uniqueness` - 验证不同路径生成不同 ID
79+
- `TestProjectID_Consistency` - 验证相同路径生成相同 ID
80+
- `TestBarDir` - 验证完整路径结构
81+
- `TestFindRepoRoot` - 验证 git 仓库根目录查找
82+
- `TestEnsureDir` - 验证递归创建目录
83+
84+
## 迁移影响
85+
86+
### 用户侧
87+
- 无需再修改 `.gitignore`
88+
- 所有项目的存档统一管理在 `~/.bar/`
89+
- 可通过 `ls ~/.bar/projects/` 查看所有项目
90+
91+
### 开发侧
92+
- `BarDir()` 函数签名不变,调用方无需修改
93+
- 新增 `GlobalBarDir()``ProjectID()` 供其他模块使用
File renamed without changes.

0 commit comments

Comments
 (0)