Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Trim Claude CI command flags

Cursor Agent8973e029b4a3
diff --git a/cli/beacon/README.md b/cli/beacon/README.md
index b2423795..df57b6cc 100644
--- a/cli/beacon/README.md
+++ b/cli/beacon/README.md
@@ -76,7 +76,7 @@ without installing a persistent endpoint service or changing
`~/.claude/settings.json`:
```bash
-./beacon ci exec --harness claude -- claude --print "Summarize this repository in one sentence"
+./beacon ci exec -- claude --print "Summarize this repository in one sentence"
```
Beacon starts the bundled `beacon-otelcol` in the foreground, writes a
@@ -89,7 +89,6 @@ Validate an existing CI artifact explicitly:
```bash
./beacon ci validate \
- --harness claude \
--log-path "$RUNNER_TEMP/beacon/runtime.jsonl" \
--min-events 1
```
@@ -98,7 +97,7 @@ Upload the log from GitHub Actions for customer-controlled retention:
```yaml
- name: Run Claude with Beacon telemetry
- run: beacon ci exec --harness claude -- claude --print "Summarize this repository"
+ run: beacon ci exec -- claude --print "Summarize this repository"
- name: Upload Beacon telemetry
if: always()
diff --git a/cli/beacon/cmd/ci.go b/cli/beacon/cmd/ci.go
index fff238ae..cc6b3b3e 100644
--- a/cli/beacon/cmd/ci.go
+++ b/cli/beacon/cmd/ci.go
@@ -27,7 +27,6 @@ var ciOpts struct {
jsonOutput bool
keepArtifacts bool
minEvents int
- requireHarness string
}
var ciCmd = &cobra.Command{
@@ -38,7 +37,7 @@ persistent endpoint service or modifying user harness configuration.`,
}
var ciExecCmd = &cobra.Command{
- Use: "exec --harness claude -- <command> [args...]",
+ Use: "exec [--harness claude] -- <command> [args...]",
Short: "Run a command with Claude Code telemetry captured for CI",
Args: cobra.MinimumNArgs(1),
SilenceUsage: true,
@@ -61,7 +60,6 @@ func init() {
cmd.Flags().StringVar(&ciOpts.harness, "harness", beaconci.DefaultHarness, "CI harness to configure (currently only claude)")
cmd.Flags().BoolVar(&ciOpts.jsonOutput, "json", false, "Print result as JSON")
cmd.Flags().IntVar(&ciOpts.minEvents, "min-events", beaconci.DefaultValidationMin, "Minimum matching events required during validation")
- cmd.Flags().StringVar(&ciOpts.requireHarness, "require-harness", "", "Require at least one event from this harness")
}
ciExecCmd.Flags().StringVar(&ciOpts.baseDir, "base-dir", "", "CI session base directory (defaults to $RUNNER_TEMP/beacon or a temp directory)")
ciExecCmd.Flags().StringVar(&ciOpts.workDir, "work-dir", "", "Working directory for the child command")
@@ -70,15 +68,14 @@ func init() {
ciExecCmd.Flags().IntVar(&ciOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")
ciExecCmd.Flags().StringVar(&ciOpts.contentRetention, "content-retention", string(endpointconfig.ContentRetentionFull), "Content retention mode: metadata, redacted, or full")
ciExecCmd.Flags().BoolVar(&ciOpts.keepArtifacts, "keep-artifacts", true, "Keep CI runtime log and collector config after exit")
+ for _, name := range []string{"base-dir", "work-dir", "collector", "otlp-grpc-port", "otlp-http-port"} {
+ _ = ciExecCmd.Flags().MarkHidden(name)
+ }
}
func runCIExec(cmd *cobra.Command, args []string) error {
runCtx, stopSignals := signal.NotifyContext(cmd.Context(), os.Interrupt, syscall.SIGTERM)
defer stopSignals()
- requireHarness := ciOpts.requireHarness
- if requireHarness == "" {
- requireHarness = ciOpts.harness
- }
session, err := beaconci.Provision(beaconci.Options{
BaseDir: ciOpts.baseDir,
LogPath: ciOpts.logPath,
@@ -109,7 +106,8 @@ func runCIExec(cmd *cobra.Command, args []string) error {
result := beaconci.Validate(beaconci.ValidationOptions{
LogPath: session.LogPath,
MinEvents: ciOpts.minEvents,
- RequireHarness: requireHarness,
+ RequireHarness: ciOpts.harness,
+ Since: session.StartedAtTime(),
})
execResult := beaconci.ExecResult{
Session: *session,
@@ -147,14 +145,10 @@ func runCIValidate(cmd *cobra.Command, args []string) error {
if logPath == "" {
logPath = beaconci.DefaultLogPath()
}
- requireHarness := ciOpts.requireHarness
- if requireHarness == "" {
- requireHarness = ciOpts.harness
- }
result := beaconci.Validate(beaconci.ValidationOptions{
LogPath: logPath,
MinEvents: ciOpts.minEvents,
- RequireHarness: requireHarness,
+ RequireHarness: ciOpts.harness,
})
if ciOpts.jsonOutput {
_ = json.NewEncoder(os.Stdout).Encode(result)
diff --git a/cli/beacon/cmd/ci_test.go b/cli/beacon/cmd/ci_test.go
index 4b4830a9..26117e52 100644
--- a/cli/beacon/cmd/ci_test.go
+++ b/cli/beacon/cmd/ci_test.go
@@ -16,7 +16,7 @@ func TestCICommandsRegistered(t *testing.T) {
t.Fatalf("command %v not registered", path)
}
}
- for _, name := range []string{"harness", "log-path", "min-events", "require-harness", "json"} {
+ for _, name := range []string{"harness", "log-path", "min-events", "json"} {
if ciExecCmd.Flags().Lookup(name) == nil {
t.Fatalf("ci exec missing --%s", name)
}
@@ -24,11 +24,23 @@ func TestCICommandsRegistered(t *testing.T) {
t.Fatalf("ci validate missing --%s", name)
}
}
- for _, name := range []string{"base-dir", "work-dir", "collector", "otlp-grpc-port", "otlp-http-port", "content-retention", "keep-artifacts"} {
+ for _, name := range []string{"content-retention", "keep-artifacts"} {
if ciExecCmd.Flags().Lookup(name) == nil {
t.Fatalf("ci exec missing --%s", name)
}
}
+ if ciExecCmd.Flags().Lookup("require-harness") != nil || ciValidateCmd.Flags().Lookup("require-harness") != nil {
+ t.Fatal("CI commands should not expose --require-harness")
+ }
+ for _, name := range []string{"base-dir", "work-dir", "collector", "otlp-grpc-port", "otlp-http-port"} {
+ flag := ciExecCmd.Flags().Lookup(name)
+ if flag == nil {
+ t.Fatalf("ci exec missing advanced --%s", name)
+ }
+ if !flag.Hidden {
+ t.Fatalf("ci exec --%s should be hidden", name)
+ }
+ }
}
func TestCIHarnessDefaultIsClaudeOnly(t *testing.T) {
diff --git a/cli/beacon/internal/ci/session.go b/cli/beacon/internal/ci/session.go
index beb21613..410a1c7c 100644
--- a/cli/beacon/internal/ci/session.go
+++ b/cli/beacon/internal/ci/session.go
@@ -56,9 +56,10 @@ type Session struct {
StartedAt string `json:"started_at"`
Run *schema.RunInfo `json:"run,omitempty"`
- cfg endpointconfig.Config
- cmd *exec.Cmd
- done chan error
+ cfg endpointconfig.Config
+ startedAt time.Time
+ cmd *exec.Cmd
+ done chan error
}
type ExecResult struct {
@@ -78,7 +79,7 @@ func Provision(opts Options) (*Session, error) {
if err := endpointconfig.ValidateContentRetention(opts.ContentRetention); err != nil {
return nil, err
}
- baseDir, err := resolveBaseDir(opts.BaseDir)
+ baseDir, err := resolveBaseDir(opts.BaseDir, opts.LogPath)
if err != nil {
return nil, err
}
@@ -132,6 +133,7 @@ func Provision(opts Options) (*Session, error) {
StartedAt: startedAt.Format(time.RFC3339),
Run: detectRunInfo(),
cfg: cfg,
+ startedAt: startedAt,
}, nil
}
@@ -218,6 +220,17 @@ func (s *Session) Config() endpointconfig.Config {
return s.cfg
}
+func (s *Session) StartedAtTime() time.Time {
+ if s == nil {
+ return time.Time{}
+ }
+ if !s.startedAt.IsZero() {
+ return s.startedAt
+ }
+ startedAt, _ := time.Parse(time.RFC3339, s.StartedAt)
+ return startedAt
+}
+
func validateHarness(harness string) error {
harness = strings.TrimSpace(harness)
if harness == "" || harness == DefaultHarness || harness == "claude_code" {
@@ -226,13 +239,20 @@ func validateHarness(harness string) error {
return fmt.Errorf("unsupported CI harness %q; only claude is supported", harness)
}
-func resolveBaseDir(configured string) (string, error) {
+func resolveBaseDir(configured, logPath string) (string, error) {
if strings.TrimSpace(configured) != "" {
if err := os.MkdirAll(configured, 0755); err != nil {
return "", err
}
return filepath.Abs(configured)
}
+ if strings.TrimSpace(logPath) != "" {
+ base := filepath.Dir(logPath)
+ if err := os.MkdirAll(base, 0755); err != nil {
+ return "", err
+ }
+ return filepath.Abs(base)
+ }
if runnerTemp := strings.TrimSpace(os.Getenv("RUNNER_TEMP")); runnerTemp != "" {
base := filepath.Join(runnerTemp, "beacon")
if err := os.MkdirAll(base, 0755); err != nil {
diff --git a/cli/beacon/internal/ci/session_test.go b/cli/beacon/internal/ci/session_test.go
index 0ed0191b..556254d4 100644
--- a/cli/beacon/internal/ci/session_test.go
+++ b/cli/beacon/internal/ci/session_test.go
@@ -44,6 +44,26 @@ func TestProvisionUsesRunnerTempAndWritesCollectorConfig(t *testing.T) {
}
}
+func TestProvisionUsesLogPathDirectoryAsBaseDir(t *testing.T) {
+ dir := t.TempDir()
+ logPath := filepath.Join(dir, "artifacts", "runtime.jsonl")
+ collector := fakeExecutable(t, "collector", "#!/bin/sh\nsleep 60\n")
+ oldResolve := resolveCollectorBinary
+ resolveCollectorBinary = func(string) (string, error) { return collector, nil }
+ t.Cleanup(func() { resolveCollectorBinary = oldResolve })
+
+ session, err := Provision(Options{CollectorPath: collector, LogPath: logPath, Harness: "claude"})
+ if err != nil {
+ t.Fatalf("Provision returned error: %v", err)
+ }
+ if want := filepath.Dir(logPath); session.BaseDir != want {
+ t.Fatalf("BaseDir = %q, want %q", session.BaseDir, want)
+ }
+ if session.ConfigPath != filepath.Join(filepath.Dir(logPath), "otelcol.yaml") {
+ t.Fatalf("ConfigPath = %q", session.ConfigPath)
+ }
+}
+
func TestProvisionRejectsUnsupportedHarness(t *testing.T) {
if _, err := Provision(Options{Harness: "codex"}); err == nil {
t.Fatal("Provision accepted unsupported harness")
diff --git a/cli/beacon/internal/ci/validate_test.go b/cli/beacon/internal/ci/validate_test.go
index 59861ad3..adf618d6 100644
--- a/cli/beacon/internal/ci/validate_test.go
+++ b/cli/beacon/internal/ci/validate_test.go
@@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"testing"
+ "time"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
)
@@ -53,6 +54,27 @@ func TestValidateFailsWhenHarnessEventMissing(t *testing.T) {
}
}
+func TestValidateFiltersEventsBeforeSince(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "runtime.jsonl")
+ event := NewSessionEvent("ci.test", "test event", nil)
+ event.Harness.Name = "claude_code"
+ event.Timestamp = time.Now().Add(-1 * time.Hour).UTC().Format(time.RFC3339)
+ writeEventLine(t, path, event)
+
+ result := Validate(ValidationOptions{
+ LogPath: path,
+ MinEvents: 1,
+ RequireHarness: "claude",
+ Since: time.Now().Add(-1 * time.Minute),
+ })
+ if result.Status != "fail" {
+ t.Fatalf("Validate status = %q, want fail for stale event", result.Status)
+ }
+ if result.EventCount != 0 {
+ t.Fatalf("EventCount = %d, want 0", result.EventCount)
+ }
+}
+
func writeEventLine(t *testing.T, path string, event schema.Event) {
t.Helper()
data, err := json.Marshal(event)