From a5c83a7449779c2a96555286f25ea05e016fb965 Mon Sep 17 00:00:00 2001 From: Willie Date: Thu, 26 Feb 2026 21:43:21 +0800 Subject: [PATCH] fix(log): --stats --cmd audit now reads audit.log instead of operations.log runLogStats() only checked the --audit flag to pick the log file, ignoring filter.Cmd. This caused `log --stats --cmd audit` to read operations.log and report "No log entries" even when audit data existed. Align with runLog() by also checking f.Cmd == "audit". --- cmd/skillshare/log.go | 2 +- tests/integration/log_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cmd/skillshare/log.go b/cmd/skillshare/log.go index 13d1b3d18..201e30363 100644 --- a/cmd/skillshare/log.go +++ b/cmd/skillshare/log.go @@ -245,7 +245,7 @@ Examples: func runLogStats(configPath string, auditOnly bool, f oplog.Filter) error { filename := oplog.OpsFile - if auditOnly { + if auditOnly || f.Cmd == "audit" { filename = oplog.AuditFile } diff --git a/tests/integration/log_test.go b/tests/integration/log_test.go index d20f7ddef..c456237df 100644 --- a/tests/integration/log_test.go +++ b/tests/integration/log_test.go @@ -464,6 +464,26 @@ targets: result.AssertOutputContains(t, "OK:") } +func TestLog_StatsCmdAuditReadsAuditLog(t *testing.T) { + sb := testutil.NewSandbox(t) + defer sb.Cleanup() + + sb.CreateSkill("s1", map[string]string{"SKILL.md": "# S\n\nTest."}) + tp := sb.CreateTarget("claude") + sb.WriteConfig(`source: ` + sb.SourcePath + ` +targets: + claude: + path: ` + tp + ` +`) + + sb.RunCLI("audit") + + result := sb.RunCLI("log", "--stats", "--cmd", "audit") + result.AssertSuccess(t) + result.AssertOutputContains(t, "audit") + result.AssertOutputContains(t, "OK:") +} + func TestLog_CheckCreatesEntry(t *testing.T) { sb := testutil.NewSandbox(t) defer sb.Cleanup()