ai-coding-agent-linux-x64 0.3.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/bin/ai-coding-agent +0 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# AI Coding Agent
|
|
2
|
+
|
|
3
|
+
跨平台 Go 客户端,在 Git `post-commit`、`post-merge`、`pre-push` 阶段采集提交、Git AI、AI 工具和系统元数据,并向编译内置的 git-ai-server 异步上报。
|
|
4
|
+
|
|
5
|
+
## npm 自动安装
|
|
6
|
+
|
|
7
|
+
正式发布后,用户只需:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g ai-coding-agent
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
npm 会下载当前操作系统和 CPU 对应的 Go 二进制,并在 `postinstall` 阶段自动运行 `ai-coding-agent install`。如果 npm 使用了 `--ignore-scripts`,需再手动执行一次 `ai-coding-agent install`。
|
|
14
|
+
|
|
15
|
+
执行 `npm uninstall -g ai-coding-agent` 时会自动移除 Agent 自己安装的 Hook、配置和数据,并恢复安装前的 `core.hooksPath`。
|
|
16
|
+
|
|
17
|
+
发布者先生成六个平台包:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm run build:npm
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
在源码仓库中测试自动安装时,也应先执行上述构建命令,再运行 `npm run postinstall`。本地测试会从 `npm/platforms` 选择当前平台的二进制。
|
|
24
|
+
|
|
25
|
+
然后先发布 `npm/platforms/*` 下的平台包,最后发布根目录主包。所有包版本必须一致。
|
|
26
|
+
|
|
27
|
+
## 源码使用
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
go build -o ai-coding-agent ./cmd/agent
|
|
31
|
+
./ai-coding-agent install
|
|
32
|
+
./ai-coding-agent status
|
|
33
|
+
./ai-coding-agent collect commit
|
|
34
|
+
./ai-coding-agent collect pull
|
|
35
|
+
./ai-coding-agent collect push
|
|
36
|
+
./ai-coding-agent uninstall
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
配置中的 `endpoint` 键已废弃并被忽略(服务器地址编译在二进制中,当前为 `http://192.168.110.120:8080`,改地址需修改代码重新发版);`config.yaml` 只保存身份与超时(Windows 为 `%LOCALAPPDATA%\\ai-coding-agent\\config.yaml`)。上报失败的数据会保存到 `data/queue`,下次采集时重放;详见下文「上报」。
|
|
40
|
+
|
|
41
|
+
构建目标示例:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
GOOS=darwin GOARCH=arm64 go build -o dist/ai-coding-agent-darwin-arm64 ./cmd/agent
|
|
45
|
+
GOOS=windows GOARCH=amd64 go build -o dist/ai-coding-agent-windows-amd64.exe ./cmd/agent
|
|
46
|
+
GOOS=linux GOARCH=arm64 go build -o dist/ai-coding-agent-linux-arm64 ./cmd/agent
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Hook 只负责启动 Agent,所有采集、脱敏和 HTTP 逻辑均在 Go 程序中执行。工具配置仅用于判断是否安装/配置;API key 只在本机读取并打码(前 6 位 + `...` + 后 4 位)后上报,完整 key 不落盘、不出本机。
|
|
50
|
+
|
|
51
|
+
Git 数据包含 `repository_url`。HTTPS/SSH 地址会移除用户名、密码、Token、查询参数和 fragment 后再上报;本地仓库磁盘路径不会上传。
|
|
52
|
+
|
|
53
|
+
`post-commit`、`post-merge`、`pre-push` 都使用 Git 自带的 POSIX shell 执行,兼容 macOS、Linux 和 Windows Git for Windows。Windows 安装路径会转换为 Git Bash 的 `/c/...` 格式;Hook 使用 LF 换行、后台启动 Agent,并始终忽略 Agent 启动失败,确保不影响 Git 操作。
|
|
54
|
+
|
|
55
|
+
## 上报
|
|
56
|
+
|
|
57
|
+
post-commit / post-merge / pre-push 钩子触发 `ai-coding-agent collect <type>`,向 git-ai-server 上报:
|
|
58
|
+
|
|
59
|
+
| 端点 | 触发 | 内容 |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| POST /api/v1/commits/stats | commit | 本次 commit 的 AI 归属统计(sha/时间/工具×模型) |
|
|
62
|
+
| POST /api/v1/tools/env | 全部 | 本机 AI 工具安装/配置状态(全量替换) |
|
|
63
|
+
| POST /api/v1/tools/keys | 全部 | 各工具 API key 状态(**打码前缀**,完整 key 不上报) |
|
|
64
|
+
| POST /api/v1/usage | 全部 | 当日 usage 快照(`--period <当日>`,服务器按 (日期,用户,项目) 覆盖)<br>内嵌 git-ai 不支持日期窗口时自动回退 `--period 1d`(`usage_date` 仍为当日);升级内嵌二进制后自动启用日期窗口。 |
|
|
65
|
+
| POST /api/v1/skills | 全部 | 技能使用统计(`npx skillusage`,每次触发 `-d 1`、首次 `-d 30` 回填;按日×技能覆盖写入,raw 完整留档) |
|
|
66
|
+
|
|
67
|
+
- 服务器地址编译在二进制中(当前 `http://192.168.110.120:8080`),改地址需重新发版
|
|
68
|
+
- 身份:`author = team_name + "-" + git user.name`;`team_id/team_name` 在 `~/.ai-coding-agent/config.yaml` 配置(未配置则跳过上报)
|
|
69
|
+
- `git config user.name` 必须是 **团队-姓名** 格式(如 `运维-张三`),install 会校验并阻断不符合的安装
|
|
70
|
+
- 失败自动入队(`data/queue/`),下次触发时重放;日志见 `logs/client.log`(1MB×3 轮转)
|
|
Binary file
|
package/package.json
ADDED