Skip to content

Commit 7282b56

Browse files
committed
feat(startup): support go install startup
1 parent 39b70ce commit 7282b56

72 files changed

Lines changed: 519 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,30 @@ inspect directly. AgentMeter turns that data into answers you can use:
9191

9292
## Quick Start
9393

94-
For packaged builds, download the matching `AgentMeter-<platform>-<arch>` asset
95-
from [Releases](https://github.com/LyleMi/AgentMeter/releases). For local source
96-
startup, use the commands below.
94+
The easiest path is a packaged build: download the matching
95+
`AgentMeter-<platform>-<arch>` asset from
96+
[Releases](https://github.com/LyleMi/AgentMeter/releases), unpack it, and run
97+
`AgentMeter -start`.
9798

98-
Requirements:
99+
Go toolchain install:
99100

100-
- Go matching the version in `go.mod`
101-
- Node.js and npm
101+
```sh
102+
go install github.com/LyleMi/AgentMeter@latest
103+
AgentMeter -start
104+
```
105+
106+
One-shot run without keeping a binary:
107+
108+
```sh
109+
go run github.com/LyleMi/AgentMeter@latest start
110+
```
111+
112+
For Go install/run, make sure your Go binary directory is on `PATH`. Web startup
113+
uses Node.js and npm the first time it needs to build the bundled frontend
114+
source. The old `go get` command is not recommended for installing binaries on
115+
modern Go versions; use `go install ...@latest`.
102116

103-
Recommended local start:
117+
From a source checkout:
104118

105119
```sh
106120
go run . -start

README.zh-CN.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,28 @@ AgentMeter 将这些数据整理成可以直接回答的问题:
8484

8585
## 快速开始
8686

87-
如需使用打包版本,请从
87+
最省事的方式是使用打包版本:从
8888
[Releases](https://github.com/LyleMi/AgentMeter/releases) 下载匹配的
89-
`AgentMeter-<platform>-<arch>` 资产。如需从源码本地启动,请使用下面的命令
89+
`AgentMeter-<platform>-<arch>` 资产,解压后运行 `AgentMeter -start`
9090

91-
要求
91+
通过 Go 工具链安装
9292

93-
- Go 版本与 `go.mod` 中声明的版本匹配
94-
- Node.js 和 npm
93+
```sh
94+
go install github.com/LyleMi/AgentMeter@latest
95+
AgentMeter -start
96+
```
97+
98+
不保留二进制、直接运行:
99+
100+
```sh
101+
go run github.com/LyleMi/AgentMeter@latest start
102+
```
103+
104+
使用 Go install/run 时,请确认 Go 的二进制目录已经加入 `PATH`。Web 首次
105+
启动如果需要构建内置前端源码,会使用 Node.js 和 npm。现代 Go 版本不再推荐
106+
`go get` 安装命令行二进制,请使用 `go install ...@latest`
95107

96-
推荐的本地启动方式
108+
从源码 checkout 启动
97109

98110
```sh
99111
go run . -start

docs/install.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,42 @@ Portable releases are not installer packages. Signing and notarization are
4646
future packaging work, so your operating system may ask you to confirm that you
4747
want to run the downloaded binary.
4848

49-
## Option 2: Run From Source
49+
## Option 2: Go Toolchain Install
50+
51+
Requirements:
52+
53+
- Go matching the version in `go.mod`
54+
- Node.js and npm for Web startup when built Web assets are not already present
55+
56+
Install the command:
57+
58+
```sh
59+
go install github.com/LyleMi/AgentMeter@latest
60+
```
61+
62+
Make sure your Go binary directory is on `PATH`, then start the Web UI:
63+
64+
```sh
65+
AgentMeter -start
66+
```
67+
68+
On Windows, the installed command may be invoked as:
69+
70+
```powershell
71+
AgentMeter.exe -start
72+
```
73+
74+
You can also run without keeping an installed binary:
75+
76+
```sh
77+
go run github.com/LyleMi/AgentMeter@latest start
78+
```
79+
80+
Modern Go versions do not use `go get` to install command binaries. Use
81+
`go install ...@latest` for persistent installs, or `go run ...@latest` for a
82+
one-shot run.
83+
84+
## Option 3: Run From Source
5085

5186
Requirements:
5287

@@ -116,6 +151,12 @@ From source:
116151
go run . -ui tui
117152
```
118153

154+
From a Go toolchain install:
155+
156+
```sh
157+
AgentMeter -ui tui
158+
```
159+
119160
See [UI Modes](ui-modes.md) for mode behavior and TUI keyboard shortcuts.
120161

121162
## Common Run Options

frontend/assets.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package frontend
2+
3+
import "embed"
4+
5+
// SourceFS contains the files needed to build the Web UI when AgentMeter is
6+
// installed with `go install` and no source checkout is available.
7+
//
8+
//go:embed package.json package-lock.json index.html tsconfig.json tsconfig.node.json vite.config.ts public src
9+
var SourceFS embed.FS

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module AgentMeter
1+
module github.com/LyleMi/AgentMeter
22

33
go 1.25
44

internal/agent/source.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package agent
1+
package agent
22

33
import (
44
"os"
55
"path/filepath"
66
"strings"
77

8-
"AgentMeter/internal/sourcepath"
8+
"github.com/LyleMi/AgentMeter/internal/sourcepath"
99
)
1010

1111
type SourceSpec struct {

internal/app/app.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app
1+
package app
22

33
import (
44
"context"
@@ -9,15 +9,15 @@ import (
99
"sync"
1010
"time"
1111

12-
"AgentMeter/internal/agent"
13-
"AgentMeter/internal/db"
14-
"AgentMeter/internal/ingest"
15-
"AgentMeter/internal/model"
16-
"AgentMeter/internal/platform"
17-
"AgentMeter/internal/pricing"
18-
"AgentMeter/internal/privacy"
19-
"AgentMeter/internal/query"
20-
"AgentMeter/internal/sourcepath"
12+
"github.com/LyleMi/AgentMeter/internal/agent"
13+
"github.com/LyleMi/AgentMeter/internal/db"
14+
"github.com/LyleMi/AgentMeter/internal/ingest"
15+
"github.com/LyleMi/AgentMeter/internal/model"
16+
"github.com/LyleMi/AgentMeter/internal/platform"
17+
"github.com/LyleMi/AgentMeter/internal/pricing"
18+
"github.com/LyleMi/AgentMeter/internal/privacy"
19+
"github.com/LyleMi/AgentMeter/internal/query"
20+
"github.com/LyleMi/AgentMeter/internal/sourcepath"
2121
)
2222

2323
type App struct {

internal/app/app_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app
1+
package app
22

33
import (
44
"context"
@@ -11,9 +11,9 @@ import (
1111
"testing"
1212
"testing/fstest"
1313

14-
"AgentMeter/internal/db"
15-
"AgentMeter/internal/model"
16-
"AgentMeter/internal/sourcepath"
14+
"github.com/LyleMi/AgentMeter/internal/db"
15+
"github.com/LyleMi/AgentMeter/internal/model"
16+
"github.com/LyleMi/AgentMeter/internal/sourcepath"
1717
)
1818

1919
func TestStartupAddsDetectedAgentDefaultsToExistingSourceEntries(t *testing.T) {

internal/app/http.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package app
1+
package app
22

33
import (
44
"database/sql"
@@ -10,8 +10,8 @@ import (
1010
"strconv"
1111
"strings"
1212

13-
"AgentMeter/internal/model"
14-
"AgentMeter/internal/pricing"
13+
"github.com/LyleMi/AgentMeter/internal/model"
14+
"github.com/LyleMi/AgentMeter/internal/pricing"
1515
)
1616

1717
func writeJSON(w http.ResponseWriter, value any, err error) {

internal/audit/audit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package audit
1+
package audit
22

33
import (
44
"fmt"
55
"strings"
66
"time"
77

8-
"AgentMeter/internal/model"
8+
"github.com/LyleMi/AgentMeter/internal/model"
99
)
1010

1111
const (

0 commit comments

Comments
 (0)