Files
Agent-System-Dev/Makefile
T
weichen 106ef07ef0 Add read-only svc.sh info report for services, databases, and config snapshots
Why: svc.sh could show a service table (list), per-instance DB names one at a
time (db ls), and per-service status, but had no single view answering "what
is running, which databases exist, and what is configured" -- the questions
asked when inspecting or handing over a machine.

Evidence: exercised in the task worktree runtime -- empty-state report; fake
agent/static/postgres registrations proving masking (exec DSN password,
password=, SVC_TAVILY_KEYS -> ***, non-secret values verbatim; --reveal shows
plaintext); a real postgres instance (db create r-pg --port 18901, start,
extra orders db, one backup) whose info section lists inner databases with
sizes, pgdata size and backup stats; regressions list/history/--help/help
lifecycle/make svc-info; info stdout carries the full report (stderr 0 bytes)
so it can be redirected as a snapshot. Full log in the task card.

Impact: new read-only `scripts/svc.sh info [name] [--tag T] [--reveal]`
command (also `make svc-info`): service table + running summary, postgres
instances incl. inner databases, per-service svc.env content snapshots plus
global .svc.env / --config / exported SVC_* vars, and recent events. Secrets
are masked by default. No deploy/lifecycle/db-ops behavior changes; `info`
becomes a reserved service name; docs/svc.md gains section 6.2 (former
6.2-6.4 shifted to 6.3-6.5).

Refs: task card .task/feature-svc-info.md (same doc as the PR); docs/svc.md
2026-10-04 12:42:49 +00:00

165 lines
8.0 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Agent-System-Dev 顶层编排
# 部署约束:非容器化;默认产物为单二进制(modules/backend,内嵌前端与嵌入式存储)。
SHELL := /bin/bash
CORE := modules/core
BACKEND := modules/backend
FRONTEND := modules/frontend
UI := modules/ui
BIN := bin/agent-system
EMBED_DIR := $(BACKEND)/web/dist
PLUGINS := plugins
# 版本溯源(release-operations:运行制品须可对上固定组合)。无 tag 时 --always 给短 SHA。
COMBO := core=$(shell git -C $(CORE) rev-parse --short HEAD 2>/dev/null)+backend=$(shell git -C $(BACKEND) rev-parse --short HEAD 2>/dev/null)+frontend=$(shell git -C $(FRONTEND) rev-parse --short HEAD 2>/dev/null)+ui=$(shell git -C $(UI) rev-parse --short HEAD 2>/dev/null)+agentcmd=$(shell git -C deps/agent-command rev-parse --short HEAD 2>/dev/null)+documents=$(shell git -C modules/documents rev-parse --short HEAD 2>/dev/null)+native=$(shell git -C deps/agent-native rev-parse --short HEAD 2>/dev/null)+squad=$(shell git -C deps/agent-squad rev-parse --short HEAD 2>/dev/null)+intent=$(shell git -C deps/agent-intent rev-parse --short HEAD 2>/dev/null)
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null)+$(COMBO)
.PHONY: help sync status build frontend svc svc-list svc-info svc-commits svc-history svc-update test-backend test-frontend test-ui test-core test-agentcmd test-pins test-libs dev pin clean setup precheck task-start task-sync task-close task-finish version
version:
@echo "agent-system $(VERSION)"
TASK := scripts/task.sh
setup:
git config core.hooksPath scripts/hooks
chmod +x scripts/hooks/pre-commit scripts/hooks/post-merge scripts/task.sh
@echo "OK: pre-commit/post-merge 钩子已启用(core.hooksPath=scripts/hooks)"
precheck:
@bash $(TASK) precheck
task-start:
@if [ -z "$(NAME)" ]; then echo "usage: make task-start NAME=feature/<slug>"; exit 2; fi
@bash $(TASK) start "$(NAME)"
task-sync:
@bash $(TASK) sync
task-close:
@bash $(TASK) close $(FOLD)
task-finish:
@bash $(TASK) finish $(ABANDON)
help:
@echo "make sync 物化全部 submodule(递归)"
@echo "make build 构建单二进制 bin/agent-system(契约同步→前端构建→embed→静态链接)"
@echo "make test 全量测试(boundaries + pins + libs + core + backend + frontend + ui + agent-command)"
@echo "make svc 服务级操作:make svc ENV=<name> [ACTION=deploy|start|stop|restart|status|logs] [ARGS='--from dev@<sha> --tag ...']"
@echo "make svc-list 服务总览:make svc-list [ARGS='--tag core'];数据库运维:scripts/svc.sh db create|dsn|backup|backups|restore|clone|copy|ls|set"
@echo "make svc-info 综合信息报告(只读):make svc-info [ARGS='pg1 --reveal']——运行服务/数据库实例与内部库/配置快照"
@echo "make svc-commits 列出可部署提交:make svc-commits SRC=dev|release [N=20]"
@echo "make svc-history 事件历史:make svc-history [ENV] [N=20](完整文档:docs/svc.md)"
@echo "make svc-update 自动更新过时服务:make svc-update [NAMES='dev pg1'] [ARGS='--check --all']"
@echo "make dev 开发模式说明(前后端分离热更新)"
@echo "make pin 推进 submodule 指针到各仓远端 main(提交前须 make test 通过)"
@echo "make status submodule 状态"
sync:
git submodule update --init --recursive
status:
@git submodule status
# 契约同步:Core 的 TS 类型镜像到前端与 UI 组件库(Core 为权威,单一来源)。
contracts:
cp $(CORE)/ts/types.ts $(FRONTEND)/src/contracts.ts.tmp
{ echo "// 从 Agent-System-Core ts/types.ts 同步(make contracts 生成;Core 为权威)。"; cat $(FRONTEND)/src/contracts.ts.tmp; } > $(FRONTEND)/src/contracts.ts
rm $(FRONTEND)/src/contracts.ts.tmp
cp $(CORE)/ts/types.ts $(UI)/src/contracts.ts.tmp
{ echo "// 从 Agent-System-Core ts/types.ts 同步(make contracts 生成;Core 为权威)。"; cat $(UI)/src/contracts.ts.tmp; } > $(UI)/src/contracts.ts
rm $(UI)/src/contracts.ts.tmp
frontend: contracts
cd $(UI) && npm ci --no-fund --no-audit
cd $(FRONTEND) && npm ci --no-fund --no-audit && npm run build
rm -rf $(EMBED_DIR) && mkdir -p $(EMBED_DIR) && cp -r $(FRONTEND)/dist/* $(EMBED_DIR)/ && touch $(EMBED_DIR)/.gitkeep
build: frontend
cd $(BACKEND) && CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$(VERSION)" -o ../../$(BIN) ./cmd/agent-system
@echo "OK: $(BIN)(版本 $(VERSION);随附插件目录 $(PLUGINS)/)"
test-core:
cd $(CORE) && go test ./...
test-backend:
cd $(BACKEND) && go test ./...
eval-deliverables:
cd $(BACKEND) && go test ./eval/ ./internal/quality/ -count=1
test-frontend: contracts
cd $(FRONTEND) && npm ci --no-fund --no-audit && npx vitest run && node scripts/check-knip.mjs
test-ui: contracts
cd $(UI) && npm ci --no-fund --no-audit && npx tsc --noEmit && npx vitest run && node scripts/check-knip.mjs
test-agentcmd:
cd deps/agent-command && go vet ./... && go test -count=1 ./...
test-boundaries:
bash scripts/lint-boundaries.sh
# 容器仓 deps/ gitlink 与 Dev 顶层指针一致。读索引中的 gitlink。
test-pins:
bash scripts/check-pins.sh
# 三个库在各自模块内测试。不用 go.work:工作区 MVS 会抬高 golang.org/x 版本。
test-libs:
cd deps/agent-intent && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
cd deps/agent-native && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
cd deps/agent-squad && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
cd deps/agent-squad/adapters/intent && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
cd deps/agent-squad/adapters/native && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
cd deps/agent-squad/adapters/sqlite && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
cd deps/agent-squad/cmd/agent-squad && GOWORK=off go vet ./... && GOWORK=off go test -count=1 ./...
plugin-new:
@test -n "$(NAME)" || (echo "用法:make plugin-new NAME=<id>"; exit 2)
bash scripts/plugin-new.sh "$(NAME)"
test: test-boundaries test-pins test-libs test-core test-backend test-frontend test-ui test-agentcmd
# 运行演示(mock 模式):单二进制 + 示例插件 + 嵌入式存储,浏览器 http://127.0.0.1:8787
# 环境服务管理(scripts/svc.sh):deploy = 停旧 → 构建 → 启动;dev/prod 相互隔离。
svc:
@test -n "$(ENV)" || (echo "用法:make svc ENV=<name> [ACTION=deploy|stop|start|restart|status|logs] [ARGS='--port 9000 --tag ...']"; exit 2)
scripts/svc.sh $(ENV) $(ACTION) $(ARGS)
svc-list:
scripts/svc.sh list $(ARGS)
svc-info:
scripts/svc.sh info $(ARGS)
svc-commits:
@test -n "$(SRC)" || (echo "用法:make svc-commits SRC=dev|release [N=20]"; exit 2)
scripts/svc.sh commits $(SRC) $(N)
svc-history:
scripts/svc.sh history $(ENV) $(N)
svc-update:
scripts/svc.sh update $(NAMES) $(ARGS)
demo: build
$(BIN) serve --addr 127.0.0.1:8787 --data ./data --plugins $(PLUGINS) --mock
dev:
@echo "开发模式(原生,非容器):"
@echo " 1. make sync && make contracts"
@echo " 2. 终端 A:cd $(BACKEND) && go run ./cmd/agent-system serve --addr 127.0.0.1:8787 --data ./data --plugins ../$(PLUGINS)"
@echo " 3. 终端 B:cd $(FRONTEND) && npm ci && npm run dev # Vite 代理到 8787"
@echo " 4. mock 演示:设置→运行时→演示模式;或终端 A 加 --mock"
# 推进指针(多仓纪律:先验证后固定)。
pin:
@for m in modules/core modules/backend modules/frontend modules/ui modules/documents deps/agent-native deps/agent-squad deps/agent-intent deps/error-code-system deps/logging-system deps/development-guidelines deps/agent-command; do \
(git -C $$m fetch -q origin && git -C $$m checkout -q origin/main) || echo "skip $$m"; \
done
@echo "submodule 指针已推进;请 make test 后 git add .gitmodules modules deps && git commit"
@scripts/check-pins.sh || echo "pin: check-pins 未通过,上面列出的容器需要重钉;pin 本身不失败"
clean:
rm -rf $(BIN) $(FRONTEND)/dist $(FRONTEND)/node_modules $(UI)/node_modules data