forked from sipeed/picoclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
207 lines (175 loc) · 6.07 KB
/
Makefile
File metadata and controls
207 lines (175 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
.PHONY: all build install uninstall clean help test test-memory test-persona memory-eval memory-canary docs-gen docs-check docs-build docs-serve
# Build variables
BINARY_NAME=dotagent
BUILD_DIR=build
CMD_DIR=cmd/$(BINARY_NAME)
MAIN_GO=$(CMD_DIR)/main.go
# Version
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT=$(shell git rev-parse --short=8 HEAD 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date +%FT%T%z)
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)"
# Go variables
GO?=go
GOFLAGS?=-v
# Installation
INSTALL_PREFIX?=$(HOME)/.local
INSTALL_BIN_DIR=$(INSTALL_PREFIX)/bin
INSTALL_MAN_DIR=$(INSTALL_PREFIX)/share/man/man1
# Workspace
DOTAGENT_HOME?=$(HOME)/.dotagent
WORKSPACE_DIR?=$(DOTAGENT_HOME)/workspace
# OS detection
UNAME_S:=$(shell uname -s)
UNAME_M:=$(shell uname -m)
# Platform-specific settings
ifeq ($(UNAME_S),Linux)
PLATFORM=linux
ifeq ($(UNAME_M),x86_64)
ARCH=amd64
else ifeq ($(UNAME_M),aarch64)
ARCH=arm64
else ifeq ($(UNAME_M),riscv64)
ARCH=riscv64
else
ARCH=$(UNAME_M)
endif
else ifeq ($(UNAME_S),Darwin)
PLATFORM=darwin
ifeq ($(UNAME_M),x86_64)
ARCH=amd64
else ifeq ($(UNAME_M),arm64)
ARCH=arm64
else
ARCH=$(UNAME_M)
endif
else
PLATFORM=$(UNAME_S)
ARCH=$(UNAME_M)
endif
BINARY_PATH=$(BUILD_DIR)/$(BINARY_NAME)-$(PLATFORM)-$(ARCH)
# Default target
all: build
## generate: Run generate
generate:
@echo "Run generate..."
@rm -r ./$(CMD_DIR)/workspace 2>/dev/null || true
@$(GO) generate ./...
@echo "Run generate complete"
## build: Build the dotagent binary for current platform
build: generate
@echo "Building $(BINARY_NAME) for $(PLATFORM)/$(ARCH)..."
@mkdir -p $(BUILD_DIR)
@$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BINARY_PATH) ./$(CMD_DIR)
@echo "Build complete: $(BINARY_PATH)"
@ln -sf $(BINARY_NAME)-$(PLATFORM)-$(ARCH) $(BUILD_DIR)/$(BINARY_NAME)
## build-all: Build dotagent for all platforms
build-all: generate
@echo "Building for multiple platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./$(CMD_DIR)
GOOS=linux GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./$(CMD_DIR)
GOOS=linux GOARCH=riscv64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-riscv64 ./$(CMD_DIR)
GOOS=darwin GOARCH=arm64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./$(CMD_DIR)
GOOS=windows GOARCH=amd64 $(GO) build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR)
@echo "All builds complete"
## install: Install dotagent to system
install: build
@echo "Installing $(BINARY_NAME)..."
@mkdir -p $(INSTALL_BIN_DIR)
@cp $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_BIN_DIR)/$(BINARY_NAME)
@chmod +x $(INSTALL_BIN_DIR)/$(BINARY_NAME)
@echo "Installed binary to $(INSTALL_BIN_DIR)/$(BINARY_NAME)"
@echo "Installation complete!"
## uninstall: Remove dotagent from system
uninstall:
@echo "Uninstalling $(BINARY_NAME)..."
@rm -f $(INSTALL_BIN_DIR)/$(BINARY_NAME)
@echo "Removed binary from $(INSTALL_BIN_DIR)/$(BINARY_NAME)"
@echo "Note: Only the executable file has been deleted."
@echo "If you need to delete all configurations (config.json, workspace, etc.), run 'make uninstall-all'"
## uninstall-all: Remove dotagent and all data
uninstall-all:
@echo "Removing workspace and skills..."
@rm -rf $(DOTAGENT_HOME)
@echo "Removed workspace: $(DOTAGENT_HOME)"
@echo "Complete uninstallation done!"
## clean: Remove build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BUILD_DIR)
@echo "Clean complete"
## vet: Run go vet for static analysis
vet:
@$(GO) vet ./...
## fmt: Format Go code
test:
@$(GO) test ./...
## test-memory: Run memory + agent continuity tests
test-memory:
@$(GO) test ./pkg/memory ./pkg/agent
## test-persona: Run persona-focused reliability tests
test-persona:
@$(GO) test ./pkg/memory -run "TestPersona|TestPersonalizationEval|TestPersonaApplySync" -count=1
## memory-eval: Run long-horizon continuity evaluation suite
memory-eval:
@$(GO) test ./pkg/memory -run TestContinuityEval_LongHorizonSynthetic -count=1
## memory-canary: Regression gate for memory changes (unit + eval)
memory-canary:
@$(GO) test ./pkg/memory ./pkg/agent
@$(GO) test ./pkg/memory -run TestContinuityEval_LongHorizonSynthetic -count=1
## fmt: Format Go code
fmt:
@$(GO) fmt ./...
## docs-gen: Generate reference documentation from code
docs-gen:
@$(GO) run ./cmd/dotagent docs generate --output docs
## docs-build: Build MkDocs site (strict mode)
docs-build:
@mkdocs build --strict
## docs-check: Verify generated docs are current and site builds
docs-check:
@$(GO) run ./cmd/dotagent docs generate --output docs --check
@mkdocs build --strict
## docs-serve: Serve docs locally at http://127.0.0.1:8000
docs-serve:
@mkdocs serve
## deps: Download dependencies
deps:
@$(GO) mod download
@$(GO) mod verify
## update-deps: Update dependencies
update-deps:
@$(GO) get -u ./...
@$(GO) mod tidy
## check: Run vet, fmt, and verify dependencies
check: deps fmt vet test
## run: Build and run dotagent
run: build
@$(BUILD_DIR)/$(BINARY_NAME) $(ARGS)
## help: Show this help message
help:
@echo "dotagent Makefile"
@echo ""
@echo "Usage:"
@echo " make [target]"
@echo ""
@echo "Targets:"
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /'
@echo ""
@echo "Examples:"
@echo " make build # Build for current platform"
@echo " make install # Install to ~/.local/bin"
@echo " make uninstall # Remove from /usr/local/bin"
@echo ""
@echo "Environment Variables:"
@echo " INSTALL_PREFIX # Installation prefix (default: ~/.local)"
@echo " WORKSPACE_DIR # Workspace directory (default: ~/.dotagent/workspace)"
@echo " VERSION # Version string (default: git describe)"
@echo ""
@echo "Current Configuration:"
@echo " Platform: $(PLATFORM)/$(ARCH)"
@echo " Binary: $(BINARY_PATH)"
@echo " Install Prefix: $(INSTALL_PREFIX)"
@echo " Workspace: $(WORKSPACE_DIR)"