Skip to content

fix(cli): unify Space ref handling across commands and keep sessions tail --json clean - #550

Open
atou42 wants to merge 2 commits into
netaart:mainfrom
atou42:fix/cli-space-ref-and-tail
Open

atou42 wants to merge 2 commits into
netaart:mainfrom
atou42:fix/cli-space-ref-and-tail

Conversation

@atou42

@atou42 atou42 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Two focused, zero-new-command CLI consistency and bug fixes:

1. Unify Space reference resolution (UUID, home, own slug, username/slug) across CLI commands

  • packages/cli/src/commands/spaces.ts: Resolves positional Space arguments via resolveSpaceRef + failSpaceTarget on setup [id], spaces get [id] (falling back to resolveSpace(spacesCmd) when omitted), spaces update <id>, spaces rename <id> <name>, spaces config <id> (including guest app lookup), spaces pin <id>, spaces unpin <id>, spaces archive <ids...>, and spaces unarchive <ids...>.
  • packages/cli/src/commands/search.ts & packages/cli/src/space.ts: Extracts explicitSpaceFlag(command) (reads ancestor -s/--space flags without COHUB_SPACE_ID), so cohub -s alice/project search "query" and cohub search --space-id alice/project "query" both resolve Space refs (--space-id wins when both are set), while unscoped cohub search stays global inside sandboxes.
  • packages/cli/src/commands/run.ts & packages/cli/src/help-path.ts: Accepts -s <space>, --space <space>, and --space=<space> both before and after run (before -- or command tokens), leaving command flags untouched.

2. Keep cohub spaces sessions tail <id> --json stdout pure JSONL

  • packages/cli/src/commands/spaces.ts: Suppresses decorative " Listening for events..." and " ✓ Done" lines on stdout when --json is set, and cleanly await client.disconnect().catch(() => undefined) before exiting on turn.finalized and turn.error.

Verification

  • pnpm --filter @neta-art/cohub-cli typecheck & build — passed
  • pnpm exec biome check on all 9 touched/new files — 0 errors, 0 warnings
  • node --import tsx --test on run.test.ts, space.test.ts, space-turns.test.ts, help-path.test.ts, space-ref-cli.test.ts, spaces-create.test.ts, spaces-upload.test.ts, output.test.ts — 33/33 passed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant