# knqyf263/pet — AlpLab Radar Static Code Audit

- Ring: `watch`
- Category: `dev`
- Overall score: `3.6/5`
- Implementation check: `verified`
- Maturity: `dormant`
- Audited commit: `3661dc9cb080` (read-only; nothing from the repository was executed)
- Reviewed at: 2026-12-02T05:51:29Z
- Repository: https://github.com/knqyf263/pet
- Radar entry: https://radar.alplab.co/#repo/knqyf263/pet
- License: `MIT`
- CI workflows: `.github/workflows`
- Tags: `cli`, `snippet-manager`, `go`, `fzf`, `gist-sync`, `developer-productivity`

## Summary

A Go CLI snippet manager that stores tagged command snippets in TOML files, lets you search/select them via fzf/peco, fill in <param> placeholders through a gocui TUI dialog, execute or clipboard-copy them, and sync them to GitHub Gist, GitHub Enterprise Gist, or GitLab Snippets.

## Implementation Check

Every core README claim maps to working code — pet new/exec/search/clip/edit in cmd/, parameter parsing in dialog/params.go SearchForParams and dialog/view.go GenerateParamsLayout, TOML persistence in snippet/snippet.go Load/Save, and Gist/GHE/GitLab sync in sync/gist.go, sync/ghe.go, sync/gitlab.go — though the README documents $PET_GITHUB_ENTERPRISE_ACCESS_TOKEN while sync/ghe.go:17 actually reads PET_GHE_ACCESS_TOKEN.

## When to Use

Use it as a lightweight personal command-snippet manager when you want fzf-driven search/execute with placeholder parameters and optional Gist/GitLab sync; don't rely on it if you need actively maintained software (no commits since 2026-03, last release 2024-12) or secure handling of sync tokens in plaintext config.

## Sub-scores

| Dimension | Score |
|---|---|
| quality | 4.0/5 |
| usability | 4.0/5 |
| reliability | 3.0/5 |
| security | 3.0/5 |
| integration | 4.0/5 |

## Code Evidence

main.go calls cmd.Execute() (cobra root in cmd/root.go); snippet/snippet.go implements Load(includeDirs)/Save/Order/FilterByTags over TOML with per-file Filename tracking; cmd/util.go filter() pipes formatted snippet lines into config.Conf.General.SelectCmd and, for a single non-raw selection, feeds the command through dialog.SearchForParams and dialog/view.go GenerateParamsLayout (gocui) before returning dialog.FinalCommand; cmd/util_unix.go run() executes selections via exec.Command("sh", "-c", command) or the configured General.Cmd list, and cmd/exec.go _execute joins multiple selections with '; '; clipboard copy via atotto/clipboard in cmd/clip.go; sync/sync.go AutoSync compares local file mtime vs remote Snippet.UpdatedAt and uploads/downloads via Client interface implemented in sync/gist.go, sync/ghe.go, sync/gitlab.go with token lookup from config or PET_*_ACCESS_TOKEN env vars; tests exist for scan/new (cmd/new_test.go), exec flags (cmd/exec_test.go), snippet load/save/filter (snippet/snippet_test.go), and dialog params (dialog/params_test.go), wired to CI in .github/workflows/test.yaml running make test on ubuntu/windows/macos plus CodeQL in .github/workflows/codeql.yml.

## Issues Found

sync/gitlab.go:50 sets tls.Config{InsecureSkipVerify: true} when GitLab skip_ssl=true (opt-in TLS verification bypass); sync/sync.go download() writes the snippet file with os.ModePerm (0777); cmd/new.go scanMultiLine uses the fixed predictable path /tmp/pet.tmp as readline HistoryFile; path/path.go expandPath strips path[2:] for any '~x' input, mangling paths like '~user/file'; README documents $PET_GITHUB_ENTERPRISE_ACCESS_TOKEN but sync/ghe.go:17 reads PET_GHE_ACCESS_TOKEN; cmd/util.go filter() returns (nil, nil) on selector failure, silently yielding empty results.

## Key Risks

Requires an external selector (fzf/peco) on PATH for search/exec/clip/edit; sync needs GitHub/GitLab tokens stored in plaintext config.toml (env vars are the safer documented option); the interactive selection path itself is barely testable — cmd/util.go filter() swallows selector errors (return nil, nil) and the only matching-command exec test in cmd/exec_test.go is commented out, so CI green does not prove the fzf round-trip; multi-directory snippet files are excluded from sync by design; behavior verified only statically, nothing was executed.

## Reviewed Files

- `main.go`
- `go.mod`
- `README.md`
- `Makefile`
- `SECURITY.md`
- `cmd/root.go`
- `cmd/new.go`
- `cmd/new_test.go`
- `cmd/exec.go`
- `cmd/exec_test.go`
- `cmd/search.go`
- `cmd/clip.go`
- `cmd/edit.go`
- `cmd/list.go`
- `cmd/sync.go`
- `cmd/configure.go`
- `cmd/util.go`
- `cmd/util_unix.go`
- `cmd/util_windows.go`
- `config/config.go`
- `dialog/params.go`
- `dialog/view.go`
- `snippet/snippet.go`
- `snippet/snippet_test.go`
- `snippet/util.go`
- `path/path.go`
- `sync/sync.go`
- `sync/gist.go`
- `sync/ghe.go`
- `sync/gitlab.go`
- `.github/dependabot.yml`
- `.github/workflows/test.yaml`
- `.github/workflows/release.yaml`
- `.github/workflows/codeql.yml`
