Guidance for ZCode agents working in this repository. For deeper background, also see CLAUDE.md, README.md, and dev-docs/.
reference is a local Git-repository reference manager for the AI-assisted coding era. It clones/caches arbitrary remote or local Git repos globally, links them into the current project via Junction/Symlink, and injects AI sub-agent + Skill configs so an AI can read repo source and accumulated Markdown knowledge with zero network latency and zero context pollution.
- Go CLI (
reference) + Wails v2 desktop GUI (reference-gui) - Module path:
github.com/cicbyte/reference - Go 1.25.2 (go-git/v5 needs 1.24+). Pure Go — no CGO (SQLite via
github.com/glebarez/sqlite).
| Path | Purpose |
|---|---|
main.go |
CLI entry; embeds prompts/** into common.PromptsFS, calls cmd.Execute() |
cmd/ |
Cobra CMD layer. root.go is the only root command; subpkgs: repo/, global/, proxy/, wiki/, version/ |
internal/logic/ |
Business logic, no cobra dependency. repo/, global/, wiki/ each expose *Config + NewXxxProcessor(...).Execute(ctx) factories |
internal/models/ |
GORM models (Repo, AppConfig, ProjectSettings) + settings JSON load/save |
internal/utils/ |
DB (GetGormDB singleton + AutoMigrate), config singleton, paths, formatting |
internal/common/ |
Global bridges: AppConfigModel, PromptsFS, asset helpers |
internal/log/ |
Zap logger + GORM logger + lumberjack rotation |
pkg/ |
Public Go SDK. Engine wraps repo ops; consumers should use this, not internal/ |
prompts/ |
Embedded agent templates: agents/reference-{explorer,analyzer}.{md,toml}, skills/reference/SKILL.md |
gui/ |
Wails v2 app (Go backend in app.go/binding.go/main.go) + Vue 3 frontend in gui/frontend/ |
scripts/ |
build.py (cross-compile), release.py, gen_release_notes.py, generate_logo.py |
docs/ |
Per-command user docs; dev-docs/ holds internal design + GUI PRD |
go build -o reference.exe . # dev build (version = "dev")
go test ./... # all tests
go test ./internal/logic/repo/... # focused
go test -run TestParseGitURL_HTTPS ./internal/logic/repo/...
go mod tidy
python scripts/build.py --local # current platform → dist/ (with ldflags + optional UPX)Versioning: VERSION file is the single source of truth. CI and build.py read it. Version/commit/build-time are injected via -ldflags -X into package github.com/cicbyte/reference/cmd/version. Don't hardcode versions.
Tests use in-memory SQLite (file::memory:?cache=shared) — no external deps. Test style is plain testing with a local assert(t, got, want) helper (see url_test.go); no testify.
- Backend:
gui/binding.gobindsReferenceAppmethods to the frontend — each method delegates tointernal/logic/*Processors (same layer the CLI uses). Add GUI features by adding methods here. - Frontend:
gui/frontend/(Vite + Vue 3 + Ant Design Vue + Pinia + vue-router). Views insrc/views/, one per CLI area. - Build:
gui/wails.jsondrives Wails (frontend:build=npm run build, which runsvue-tsc --noEmit && vite build). - Window is frameless (
Frameless: true);WindowMinimize/Maximize/Closeare no-op stubs inbinding.go— wire them toruntimeif implementing window controls. gui/build/holdsappicon.pngand platform manifests;gui/frontend/dist/is//go:embed-ed into the binary.
- CMD/Logic separation is strict.
cmd/*binds flags, validates, builds a*Config, and calls a Processor'sExecute(ctx). Never import cobra frominternal/logic/. Return structured results, let CMD format output (global-f table|json|jsonl). - Adding a command: create the file under
cmd/<module>/, add aNewXxxProcessorininternal/logic/<module>/, thenrootCmd.AddCommand(...)incmd/root.goinit(). - Adding a supported AI assistant: register one entry in
AgentRegistry(internal/logic/repo/agent_registry.go) — inject/doctor/remove all read from this map. Don't scatter agent-specific paths elsewhere. - Two-layer agent design is intentional:
reference-explorer(topic Q&A →<topic>.md) andreference-analyzer(full architecture →reference.md, once per repo). Knowledge is written under the wiki dir and Junction-linked into.reference/wiki/<refName>/. Preserve this split. - App init order in
cmd/root.goinit()is fixed and load-bearing:InitAppDirs → LoadConfig → ApplyConfig → InitDataDirs → InitLog → GetGormDB (AutoMigrate) → MigratePathsIfNeeded → EnsureGitInit(wiki) → EnsureGitInit(localwiki). Any step failing callsos.Exit(1). Note:EnsureAutoPullexists but is not called in rootinit().
- Cross-platform links: Unix uses Symlink; Windows uses PowerShell
New-Item -ItemType Junction(no admin rights needed). Seeinternal/logic/repo/linker.go. - Project data lives in
.reference/(Junctions to global cache + wiki)..reference/,.zcode/,.claude/, etc. are gitignored — they are per-project generated state, do not commit them. - User data lives in
~/.cicbyte/apps/reference/:config/config.yaml,db/app.db,repos/,wiki/(remote, nested<platform>/<namespace>/<repo>/),localwiki/(local repos),logs/. repo adddefault changed: cached repos are NOT auto-updated; require explicit--update/-u.- Remote vs local wiki are separate Git repos (
wiki/andlocalwiki/); switch target with--local/-l. ProjectSettings.Agent(single) is deprecated → migrated automatically toAgentsarray. Always write the array form.- Logging is Zap (
log.Info,log.Error, withzap.String/zap.Errorfields); neverfmt.Printlnfrom logic layer (only from CMD/user-facing output). - Global state is bridged through
common.AppConfigModeland theutils.ConfigInstancesingleton — read config via these, not by re-parsingconfig.yaml. - Commit messages follow Conventional Commits in Chinese (e.g.
feat(gui): ...,refactor(repo/cache): ...); seegit logfor tone.
docs/agent-platform-adapter.md— how each AI platform's config dir/files are targeteddev-docs/reference-gui-prd.md— GUI scope, views, and binding contractsdev-docs/global-management-backend.md— cross-project GC/stats logicCHANGELOG.md— recent behavior changes (e.g.--updatedefault, multi-agent migration)