diff --git a/.surface b/.surface index 5da6e8ecc..4e3abf319 100644 --- a/.surface +++ b/.surface @@ -15087,13 +15087,16 @@ FLAG basecamp schedule create --cache-dir type=string FLAG basecamp schedule create --count type=bool FLAG basecamp schedule create --desc type=string FLAG basecamp schedule create --description type=string +FLAG basecamp schedule create --draft type=bool FLAG basecamp schedule create --end type=string FLAG basecamp schedule create --ends-at type=string FLAG basecamp schedule create --format type=string FLAG basecamp schedule create --help type=bool +FLAG basecamp schedule create --highlight type=bool FLAG basecamp schedule create --hints type=bool FLAG basecamp schedule create --ids-only type=bool FLAG basecamp schedule create --in type=string +FLAG basecamp schedule create --join-url type=string FLAG basecamp schedule create --jq type=string FLAG basecamp schedule create --json type=bool FLAG basecamp schedule create --markdown type=bool @@ -15255,9 +15258,11 @@ FLAG basecamp schedule update --end type=string FLAG basecamp schedule update --ends-at type=string FLAG basecamp schedule update --format type=string FLAG basecamp schedule update --help type=bool +FLAG basecamp schedule update --highlight type=bool FLAG basecamp schedule update --hints type=bool FLAG basecamp schedule update --ids-only type=bool FLAG basecamp schedule update --in type=string +FLAG basecamp schedule update --join-url type=string FLAG basecamp schedule update --jq type=string FLAG basecamp schedule update --json type=bool FLAG basecamp schedule update --markdown type=bool diff --git a/API-COVERAGE.md b/API-COVERAGE.md index b66518a34..a5d4095ea 100644 --- a/API-COVERAGE.md +++ b/API-COVERAGE.md @@ -282,7 +282,7 @@ cannot faithfully cover at least one endpoint for a reason outside the CLI. A | **Schedule** | | calendars | 2 | `calendars` | ✅ | BC5 | - | show, update (color only). No index endpoint, so there is no `calendars list` — address one by id or pasted URL. The eleven colors are validated client-side for an immediate answer that names the alternatives; since v0.13.0 the SDK also carries the server's field-keyed 422 message | | schedules | 2 | `schedule` | ✅ | BC4 | - | Schedule container + settings | -| schedule_entries | 5 | `schedule` | ✅ | BC4 | - | list, show, create, update, occurrences. Create supports `--subscribe`/`--no-subscribe` | +| schedule_entries | 5 | `schedule` | ✅ | BC4 | - | list, show, create, update, occurrences. Create supports `--subscribe`/`--no-subscribe`; `--draft` sends `status: drafted` via SDK `CreateEntry`, otherwise `status: active`. Create and update support `--highlight` (including `--highlight=false`) and `--join-url` (including an empty string to clear); omission preserves existing values on update. The join link is written as `url` and read as `join_url`; response `url` remains the API address. Open the returned draft link in Basecamp to edit and publish. Status updates/publication are excluded: the SDK update/replace requests expose no status field; generic archive/trash/restore commands cover recording lifecycle, not draft publication. | | events | 1 | `events` | ✅ | BC4 | - | Recording change audit trail | | **Event Feed** | | event_feed | 3 | `events poll`, `events ticket`, `inbox` | ✅ | BC5 | - | The account-wide event feed: `GET /events.json` (`events poll`), `GET /inbox.json` (`inbox`, agent principals only), `POST /events/stream_ticket.json` (`events ticket`). Pagination is the body envelope — a durable `position` and a `next` continuation URL — not the Link-header page walk, so `--all` walks `next` rather than page numbers. The live WebSocket lane the ticket opens is out of scope for the CLI: the SDK's cable client carries a WebSocket dependency the CLI does not take. The mint is a CLI command only — it is excluded from the MCP surface, whose dispatcher would return the bearer verbatim into a model transcript and which could not open the socket anyway | diff --git a/e2e/smoke/smoke_schedule_write.bats b/e2e/smoke/smoke_schedule_write.bats index e67eb506e..14f20d8a7 100644 --- a/e2e/smoke/smoke_schedule_write.bats +++ b/e2e/smoke/smoke_schedule_write.bats @@ -22,6 +22,36 @@ setup_file() { echo "$output" | jq -r '.data.id' > "$BATS_FILE_TMPDIR/entry_id" } +@test "schedule create saves a draft only when requested" { + local mode expected entry_id + local flags=() + for mode in draft default false; do + flags=() + expected=active + if [[ "$mode" == draft ]]; then + flags=(--draft) + expected=drafted + elif [[ "$mode" == false ]]; then + flags=(--draft=false) + fi + run_smoke basecamp schedule create "CLI smoke publication $mode $(date +%s)" \ + --starts-at '2026-11-19T14:00:00Z' --ends-at '2026-11-19T14:30:00Z' \ + --schedule "$QA_SCHEDULE" -p "$QA_PROJECT" --no-subscribe --json "${flags[@]}" + assert_success + assert_json_value '.data.status' "$expected" + assert_json_not_null '.data.app_url' + entry_id=$(echo "$output" | jq -r '.data.id') + if [[ "$mode" == draft ]]; then + [[ "$(echo "$output" | jq -r '.notice // ""')" == *'edit and publish'* ]] + fi + + run_smoke basecamp schedule show "$entry_id" --no-comments --json + assert_success + assert_json_value '.data.id' "$entry_id" + assert_json_value '.data.status' "$expected" + done +} + @test "schedule update updates a schedule entry" { local id_file="$BATS_FILE_TMPDIR/entry_id" [[ -f "$id_file" ]] || mark_unverifiable "No schedule entry created in prior test" diff --git a/internal/commands/schedule.go b/internal/commands/schedule.go index e43b19b0c..3e023e8ea 100644 --- a/internal/commands/schedule.go +++ b/internal/commands/schedule.go @@ -416,17 +416,20 @@ func newScheduleCreateCmd(project, scheduleID *string) *cobra.Command { var endsAt string var description string var allDay bool + var highlight bool + var joinURL string var notify bool var participants string var subscribe string var noSubscribe bool var attachFiles []string var visibleToClients bool + var draft bool cmd := &cobra.Command{ Use: "create ", Short: "Create a schedule entry", - Long: "Create a new entry in the project schedule.", + Long: "Create a published entry in the project schedule. Use --draft to save an unpublished draft, then open its link in Basecamp to edit and publish it.", Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { entrySummary := summary @@ -473,11 +476,12 @@ func newScheduleCreateCmd(project, scheduleID *string) *cobra.Command { } app := appctx.FromContext(cmd.Context()) + scope := newFollowUpScope(app) if err := ensureAccount(cmd, app); err != nil { return err } - return runScheduleCreate(cmd, app, *project, *scheduleID, entrySummary, startsAt, endsAt, description, allDay, notify, visibleToClients, participants, subscribe, noSubscribe, attachFiles) + return runScheduleCreate(cmd, app, scope, *project, *scheduleID, entrySummary, startsAt, endsAt, description, allDay, notify, visibleToClients, draft, highlight, joinURL, participants, subscribe, noSubscribe, attachFiles) }, } @@ -490,6 +494,8 @@ func newScheduleCreateCmd(project, scheduleID *string) *cobra.Command { cmd.Flags().StringVar(&description, "description", "", "Detailed description; use - to read from stdin") cmd.Flags().StringVar(&description, "desc", "", "Description (alias)") cmd.Flags().BoolVar(&allDay, "all-day", false, "Mark as all-day event") + cmd.Flags().BoolVar(&highlight, "highlight", false, "Highlight the entry on the schedule (false removes the highlight)") + cmd.Flags().StringVar(&joinURL, "join-url", "", "Join link for the event (empty clears it; returned as join_url)") cmd.Flags().BoolVar(¬ify, "notify", false, "Notify participants") cmd.Flags().StringVar(&participants, "participants", "", "Comma-separated person IDs") cmd.Flags().StringVar(&participants, "people", "", "Person IDs (alias)") @@ -499,12 +505,13 @@ func newScheduleCreateCmd(project, scheduleID *string) *cobra.Command { cmd.Flags().BoolVar(&noSubscribe, "no-subscribe", false, "Don't subscribe anyone else (silent, no notifications)") cmd.Flags().StringArrayVar(&attachFiles, "attach", nil, "Attach file (repeatable)") cmd.Flags().BoolVar(&visibleToClients, "visible-to-clients", false, "Make the schedule entry visible to clients on the project (omit for the server default; client-authenticated callers always post client-visible)") + cmd.Flags().BoolVar(&draft, "draft", false, "Save an unpublished draft (open its link in Basecamp to edit and publish)") addRichTextFormatFlag(cmd) return cmd } -func runScheduleCreate(cmd *cobra.Command, app *appctx.App, project, scheduleID, summary, startsAt, endsAt, description string, allDay, notify, visibleToClients bool, participants, subscribe string, noSubscribe bool, attachFiles []string) error { +func runScheduleCreate(cmd *cobra.Command, app *appctx.App, scope followUpScope, project, scheduleID, summary, startsAt, endsAt, description string, allDay, notify, visibleToClients, draft, highlight bool, joinURL, participants, subscribe string, noSubscribe bool, attachFiles []string) error { // Resolve subscription flags early (fail fast on bad input) subs, err := applySubscribeFlags(cmd.Context(), app.Names, subscribe, cmd.Flags().Changed("subscribe"), noSubscribe) if err != nil { @@ -567,7 +574,12 @@ func runScheduleCreate(cmd *cobra.Command, app *appctx.App, project, scheduleID, } // Build request + status := "active" + if draft { + status = "drafted" + } req := &basecamp.CreateScheduleEntryRequest{ + Status: &status, Summary: summary, StartsAt: startsAt, EndsAt: endsAt, @@ -577,6 +589,13 @@ func runScheduleCreate(cmd *cobra.Command, app *appctx.App, project, scheduleID, Subscriptions: subs, } + if cmd.Flags().Changed("highlight") { + req.Highlighted = &highlight + } + if cmd.Flags().Changed("join-url") { + req.URL = &joinURL + } + // Set client visibility only when the flag was provided. Omitting it uses the // server's default: team-only when posting as a team member, but a // client-authenticated caller always creates client-visible records (an @@ -604,24 +623,37 @@ func runScheduleCreate(cmd *cobra.Command, app *appctx.App, project, scheduleID, } resultSummary := fmt.Sprintf("Created schedule entry #%d: %s", entry.ID, summary) + scopeArgs := scope.args(app.Config.AccountID) + crumbs := []output.Breadcrumb{{ + Action: "show", + Cmd: fmt.Sprintf("basecamp schedule show %d --project %s%s", entry.ID, resolvedProjectID, scopeArgs), + Description: "View entry", + }} + if draft { + resultSummary = fmt.Sprintf("Created draft schedule entry #%d: %s", entry.ID, summary) + } else { + crumbs = append(crumbs, output.Breadcrumb{ + Action: "entries", + Cmd: fmt.Sprintf("basecamp schedule entries --project %s --schedule %d%s", resolvedProjectID, scheduleIDInt, scopeArgs), + Description: "View all entries", + }) + } respOpts := []output.ResponseOption{ output.WithSummary(resultSummary), - output.WithBreadcrumbs( - output.Breadcrumb{ - Action: "show", - Cmd: fmt.Sprintf("basecamp schedule show %d --project %s", entry.ID, resolvedProjectID), - Description: "View entry", - }, - output.Breadcrumb{ - Action: "entries", - Cmd: fmt.Sprintf("basecamp schedule entries --project %s", resolvedProjectID), - Description: "View all entries", - }, - ), + output.WithBreadcrumbs(crumbs...), + } + notice := mentionNotice + if draft { + notice = strings.TrimSpace(fmt.Sprintf("Unpublished. Open %s in Basecamp to edit and publish this draft. %s", entry.AppURL, mentionNotice)) } if mentionNotice != "" { - respOpts = append(respOpts, output.WithDiagnostic(mentionNotice)) + if app.Output.EffectiveFormat() == output.FormatQuiet { + notice = mentionNotice + } + respOpts = append(respOpts, output.WithDiagnostic(notice)) + } else if notice != "" { + respOpts = append(respOpts, output.WithNotice(notice)) } return app.OK(entry, respOpts...) } @@ -632,6 +664,8 @@ func newScheduleUpdateCmd(project *string) *cobra.Command { var endsAt string var description string var allDay bool + var highlight bool + var joinURL string var notify bool var participants string var attachFiles []string @@ -719,6 +753,15 @@ You can pass either an entry ID or a Basecamp URL: req := &basecamp.UpdateScheduleEntryRequest{} hasChanges := false + if cmd.Flags().Changed("highlight") { + req.Highlighted = &highlight + hasChanges = true + } + if cmd.Flags().Changed("join-url") { + req.URL = &joinURL + hasChanges = true + } + if summary != "" { req.Summary = basecamp.Ptr(summary) hasChanges = true @@ -831,6 +874,8 @@ You can pass either an entry ID or a Basecamp URL: cmd.Flags().StringVar(&description, "description", "", "Detailed description; use - to read from stdin") cmd.Flags().StringVar(&description, "desc", "", "Description (alias)") cmd.Flags().BoolVar(&allDay, "all-day", false, "Mark as all-day event") + cmd.Flags().BoolVar(&highlight, "highlight", false, "Highlight the entry on the schedule (false removes the highlight)") + cmd.Flags().StringVar(&joinURL, "join-url", "", "Join link for the event (empty clears it; returned as join_url)") cmd.Flags().BoolVar(¬ify, "notify", false, "Notify participants") cmd.Flags().StringVar(&participants, "participants", "", "Comma-separated person IDs") cmd.Flags().StringVar(&participants, "people", "", "Person IDs (alias)") diff --git a/internal/commands/schedule_draft_test.go b/internal/commands/schedule_draft_test.go new file mode 100644 index 000000000..f40232c5d --- /dev/null +++ b/internal/commands/schedule_draft_test.go @@ -0,0 +1,133 @@ +package commands + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/basecamp/basecamp-cli/internal/config" + "github.com/basecamp/basecamp-cli/internal/output" +) + +type scheduleDraftTransport struct { + mockScheduleCreateTransport + writes int +} + +func (tr *scheduleDraftTransport) RoundTrip(req *http.Request) (*http.Response, error) { + if req.Method == http.MethodGet && strings.Contains(req.URL.Path, "/people") { + return &http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": {"application/json"}}, Body: io.NopCloser(strings.NewReader(`[]`))}, nil + } + resp, err := tr.mockScheduleCreateTransport.RoundTrip(req) + if err != nil || req.Method != http.MethodPost { + return resp, err + } + tr.writes++ + var body map[string]any + if err := json.Unmarshal(tr.capturedBody, &body); err != nil { + return nil, err + } + status, _ := body["status"].(string) + if status == "" { + status = "active" + } + resp.Body.Close() + resp.Body = io.NopCloser(strings.NewReader(fmt.Sprintf(`{"id":999,"status":%q,"summary":"Event","app_url":"https://3.basecamp.com/99999/buckets/123/schedule_entries/999","starts_at":"2026-03-04T09:00:00Z","ends_at":"2026-03-04T09:30:00Z"}`, status))) + return resp, nil +} + +func TestScheduleCreatePublicationState(t *testing.T) { + for _, tc := range []struct { + name string + flags []string + status string + }{ + {"published by default", nil, "active"}, + {"explicit draft", []string{"--draft"}, "drafted"}, + {"explicit false publishes", []string{"--draft=false"}, "active"}, + } { + t.Run(tc.name, func(t *testing.T) { + tr := &scheduleDraftTransport{} + app, buf := newTestAppWithTransport(t, tr) + app.Flags.Hints = true + app.Config.ActiveProfile = "alternate" + app.Config.Sources = map[string]string{"account_id": string(config.SourceFlag)} + args := append([]string{"create", "Event", "--starts-at", "2026-03-04T09:00:00Z", "--ends-at", "2026-03-04T09:30:00Z"}, tc.flags...) + require.NoError(t, executeRecordingCommand(NewScheduleCmd(), app, args...)) + require.Equal(t, 1, tr.writes) + var body map[string]any + require.NoError(t, json.Unmarshal(tr.capturedBody, &body)) + assert.Equal(t, tc.status, body["status"]) + var out struct { + Data struct { + ID int64 `json:"id"` + Status string `json:"status"` + AppURL string `json:"app_url"` + } `json:"data"` + Summary string `json:"summary"` + Notice string `json:"notice"` + Breadcrumbs []struct { + Cmd string `json:"cmd"` + } `json:"breadcrumbs"` + } + require.NoError(t, json.Unmarshal(buf.Bytes(), &out)) + assert.Equal(t, int64(999), out.Data.ID) + assert.Equal(t, tc.status, out.Data.Status) + assert.Equal(t, "https://3.basecamp.com/99999/buckets/123/schedule_entries/999", out.Data.AppURL) + require.NotEmpty(t, out.Breadcrumbs) + assert.Contains(t, out.Breadcrumbs[0].Cmd, "schedule show 999") + assert.Contains(t, out.Breadcrumbs[0].Cmd, "--profile alternate --account 99999") + if tc.status == "drafted" { + assert.Contains(t, out.Summary, "draft") + assert.Contains(t, out.Notice, "edit and publish") + assert.Len(t, out.Breadcrumbs, 1, "ordinary listings omit drafts") + } else { + assert.NotContains(t, out.Summary, "draft") + } + }) + } +} + +func TestScheduleCreateDraftDoesNotWarnInQuietMode(t *testing.T) { + tr := &scheduleDraftTransport{} + app, _ := newTestAppWithTransport(t, tr) + var stdout, stderr bytes.Buffer + app.Output = output.New(output.Options{Format: output.FormatQuiet, Writer: &stdout, ErrWriter: &stderr}) + require.NoError(t, executeRecordingCommand(NewScheduleCmd(), app, "create", "Event", "--starts-at", "2026-03-04T09:00:00Z", "--ends-at", "2026-03-04T09:30:00Z", "--draft")) + assert.Empty(t, stderr.String()) + var entry struct { + Status string `json:"status"` + } + require.NoError(t, json.Unmarshal(stdout.Bytes(), &entry)) + assert.Equal(t, "drafted", entry.Status) +} + +func TestScheduleCreateDraftWithUnresolvedMention(t *testing.T) { + for _, format := range []output.Format{output.FormatJSON, output.FormatQuiet} { + t.Run(fmt.Sprint(format), func(t *testing.T) { + tr := &scheduleDraftTransport{} + app, _ := newTestAppWithTransport(t, tr) + var stdout, stderr bytes.Buffer + app.Output = output.New(output.Options{Format: format, Writer: &stdout, ErrWriter: &stderr}) + require.NoError(t, executeRecordingCommand(NewScheduleCmd(), app, "create", "Event", "--starts-at", "2026-03-04T09:00:00Z", "--ends-at", "2026-03-04T09:30:00Z", "--description", "Ask @Nobody", "--draft")) + if format == output.FormatQuiet { + assert.Contains(t, stderr.String(), "@Nobody") + assert.NotContains(t, stderr.String(), "edit and publish") + } else { + var result struct { + Notice string `json:"notice"` + } + require.NoError(t, json.Unmarshal(stdout.Bytes(), &result)) + assert.Contains(t, result.Notice, "@Nobody") + assert.Contains(t, result.Notice, "edit and publish") + } + }) + } +} diff --git a/internal/commands/schedule_options_test.go b/internal/commands/schedule_options_test.go new file mode 100644 index 000000000..c03490495 --- /dev/null +++ b/internal/commands/schedule_options_test.go @@ -0,0 +1,59 @@ +package commands + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestScheduleEntryHighlightAndJoinURL(t *testing.T) { + for _, action := range []string{"create", "update"} { + for _, tc := range []struct { + name string + flags []string + highlighted any + url any + }{ + {name: "omitted"}, + {name: "set", flags: []string{"--highlight", "--join-url", "https://meet.example.com/planning"}, highlighted: true, url: "https://meet.example.com/planning"}, + {name: "clear", flags: []string{"--highlight=false", "--join-url="}, highlighted: false, url: ""}, + {name: "highlight only", flags: []string{"--highlight=false"}, highlighted: false}, + {name: "link only", flags: []string{"--join-url="}, url: ""}, + } { + t.Run(action+"/"+tc.name, func(t *testing.T) { + tr := &mockScheduleCreateTransport{} + app, _ := newTestAppWithTransport(t, tr) + args := []string{"create", "Event", "--starts-at", "2026-03-04T09:00:00Z", "--ends-at", "2026-03-04T09:30:00Z"} + if action == "update" { + args = []string{"update", "999", "--summary", "Updated"} + } + require.NoError(t, executeRecordingCommand(NewScheduleCmd(), app, append(args, tc.flags...)...)) + var body map[string]any + require.NoError(t, json.Unmarshal(tr.capturedBody, &body)) + for key, expected := range map[string]any{"highlighted": tc.highlighted, "url": tc.url} { + if expected == nil { + assert.NotContains(t, body, key) + } else { + assert.Equal(t, expected, body[key]) + } + } + assert.NotContains(t, body, "join_url") + if action == "update" { + assert.NotContains(t, body, "status") + assert.Equal(t, "Updated", body["summary"]) + } + }) + } + } +} + +func TestScheduleUpdateOptionsAlone(t *testing.T) { + for _, flags := range [][]string{{"--highlight"}, {"--highlight=false"}, {"--join-url", "https://meet.example.com/room"}, {"--join-url="}} { + tr := &mockScheduleCreateTransport{} + app, _ := newTestAppWithTransport(t, tr) + require.NoError(t, executeRecordingCommand(NewScheduleCmd(), app, append([]string{"update", "999"}, flags...)...)) + require.NotEmpty(t, tr.capturedBody) + } +} diff --git a/internal/commands/schedule_test.go b/internal/commands/schedule_test.go index d40e1c175..59e9abd68 100644 --- a/internal/commands/schedule_test.go +++ b/internal/commands/schedule_test.go @@ -86,8 +86,10 @@ func (t *mockScheduleCreateTransport) RoundTrip(req *http.Request) (*http.Respon } else if strings.Contains(req.URL.Path, "/schedule_entries/") { // UpdateEntry is a merge-safe composite since SDK v0.13.0: it GETs // the entry first and refuses one missing required fields, so the - // stub must serve a complete entry rather than `{}`. - body = `{"id": 999, "summary": "Event", "starts_at": "2026-03-04T09:00:00Z", "ends_at": "2026-03-04T09:30:00Z", "all_day": false, "participants": []}` + // stub must serve a complete entry rather than `{}`. Populated + // options and distinct API/join URLs catch accidental overwrites + // during unrelated edits. + body = `{"id": 999, "summary": "Event", "starts_at": "2026-03-04T09:00:00Z", "ends_at": "2026-03-04T09:30:00Z", "all_day": false, "participants": [], "url": "https://3.basecampapi.com/99999/buckets/123/schedule_entries/999.json", "join_url": "https://meet.example.com/existing", "highlighted": true}` } else { body = `{}` } diff --git a/internal/resilience/rate_limiter_test.go b/internal/resilience/rate_limiter_test.go index 0909b1da2..a7bc7bb32 100644 --- a/internal/resilience/rate_limiter_test.go +++ b/internal/resilience/rate_limiter_test.go @@ -2,6 +2,7 @@ package resilience import ( "testing" + "testing/synctest" "time" "github.com/stretchr/testify/assert" @@ -89,34 +90,50 @@ func TestRateLimiterCapsAtMaxTokens(t *testing.T) { } func TestRateLimiterRetryAfter(t *testing.T) { - dir := t.TempDir() - store := NewStore(dir) - rl := NewRateLimiter(store, RateLimiterConfig{ - MaxTokens: 5, - RefillRate: 10, - TokensPerRequest: 1, - }) - - // Set retry-after for a short duration - require.NoError(t, rl.SetRetryAfterDuration(50*time.Millisecond)) + // Filesystem work under race instrumentation can outlast a 50ms block. + // Advance virtual time explicitly so the assertions test the deadline. + synctest.Test(t, func(t *testing.T) { + dir := t.TempDir() + store := NewStore(dir) + rl := NewRateLimiter(store, RateLimiterConfig{ + MaxTokens: 5, + RefillRate: 10, + TokensPerRequest: 1, + }) + + // Set retry-after for a short duration + require.NoError(t, rl.SetRetryAfterDuration(50*time.Millisecond)) + + // Should reject requests during retry-after + allowed, err := rl.Allow() + require.NoError(t, err) + assert.False(t, allowed, "expected request to be rejected during retry-after period") - // Should reject requests during retry-after - allowed, err := rl.Allow() - require.NoError(t, err) - assert.False(t, allowed, "expected request to be rejected during retry-after period") + // Check remaining time + remaining, err := rl.RetryAfterRemaining() + require.NoError(t, err) + assert.Equal(t, 50*time.Millisecond, remaining) - // Check remaining time - remaining, err := rl.RetryAfterRemaining() - require.NoError(t, err) - assert.True(t, remaining > 0 && remaining <= 60*time.Millisecond, "expected remaining time between 0-60ms, got %v", remaining) + // Just before expiry, the block still applies. + time.Sleep(40 * time.Millisecond) + remaining, err = rl.RetryAfterRemaining() + require.NoError(t, err) + assert.Equal(t, 10*time.Millisecond, remaining) + allowed, err = rl.Allow() + require.NoError(t, err) + assert.False(t, allowed) - // Wait past retry-after - time.Sleep(60 * time.Millisecond) + // At the deadline, the block has expired. + time.Sleep(10 * time.Millisecond) + remaining, err = rl.RetryAfterRemaining() + require.NoError(t, err) + assert.Zero(t, remaining) - // Should allow requests now - allowed, err = rl.Allow() - require.NoError(t, err) - assert.True(t, allowed, "expected request to be allowed after retry-after period") + // Should allow requests now + allowed, err = rl.Allow() + require.NoError(t, err) + assert.True(t, allowed, "expected request to be allowed after retry-after period") + }) } func TestRateLimiterSetRetryAfter(t *testing.T) { diff --git a/nix/package.nix b/nix/package.nix index 4b6c9d3b6..1517541ba 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -8,7 +8,7 @@ buildGoModule.override { go = go_1_26; } (finalAttrs: { src = lib.cleanSource ./..; # To update: set to lib.fakeHash, run `nix build`, use the hash from the error. - vendorHash = "sha256-YmTf0U8ORBITbKfQLkCBakOlbMmzaK7XukmYu/NteI8="; + vendorHash = "sha256-G4ZStXZ/h7D33tLkgna/3LkpCtLprYcsGWrtkkgg0OE="; subPackages = [ "cmd/basecamp" ]; diff --git a/skills/basecamp/SKILL.md b/skills/basecamp/SKILL.md index c43d849ba..11314fa6f 100644 --- a/skills/basecamp/SKILL.md +++ b/skills/basecamp/SKILL.md @@ -117,8 +117,7 @@ For each task: 5. Execute with an explicit output mode, then read structured errors and breadcrumbs before deciding what to do next. -Leaf help is cheap and local; root help returns the full catalog and costs many -tokens. Do not load it to confirm global flags this skill documents. For obvious Docs & Files requests, route +Do not load root help to confirm global flags documented here. For obvious Docs & Files requests, route straight to `files list`, `files download`, or `files uploads create` before trying parent or root help. A subcommand's `inherited_flags` is intentionally short; global flags such as `--agent`, `--jq`, `--profile`, and `--verbose` still @@ -172,13 +171,6 @@ for human-facing listings, but remember that `--md` alone does not suppress interactive prompts. Add enough scope to remove ambiguity or set `BASECAMP_NONINTERACTIVE=1`. -Generic examples, not command discovery: - -```bash -basecamp --jq '.data | length' -basecamp --jq '[.data[] | {id, name}]' -``` - ## Project, account, and pagination scope Do not infer project or account scope from a command's noun; inspect leaf help @@ -422,3 +414,9 @@ Basecamp stays silent otherwise. For destructive or broad operations, preview when the command offers a dry-run and do not expand the user's requested scope. + +## Schedule options + +`schedule create/update`: `--highlight=false` / `--join-url=""` clears; omitted +flags preserve on update. Read join links as `join_url`. Create `--draft` saves +unpublished; publish via the returned Basecamp link.