Skip to content

chore: update formatting script#101

Open
christianalfoni wants to merge 4 commits into
mainfrom
CSB-1411
Open

chore: update formatting script#101
christianalfoni wants to merge 4 commits into
mainfrom
CSB-1411

Conversation

@christianalfoni

@christianalfoni christianalfoni commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Repo-wide formatting enforced by CI, with a single script for contributors

❌ Current behavior

No formatter is configured. TS/JS/Python files drift in style PR-to-PR and there's no automated check.

contributor edits file → opens PR → reviewer eyeballs whitespace → bikeshed

✅ New behavior

A single format.sh script formats the whole repo. A blocking CI job runs the same script in check mode on every PR.

$ bash format.sh
→ Bootstrapping .venv-format (one-time, ~10MB)…
Checking formatting...
All matched files use Prettier code style!
42 files reformatted, 0 files unchanged

$ bash format.sh check     # what CI runs — exits non-zero on diff
PR Checks
├── formatting          ← new, blocking
├── typescript-tests
├── validate-release-config
├── python-tests
└── build-dry-run

🤔 Assumptions

  • Contributors have python3 available (macOS ships it; CI provisions it via setup-python)
  • Prettier-style enforcement (semis, double quotes, width 100, trailing commas) is acceptable as the project-wide TS/JS/JSON/MD/YAML style
  • Ruff format only (no lint-fixing) for Python, double-quote style, line length 100
  • Generated code under src/api-clients/, together_sandbox/api/, together_sandbox/sandbox/, and SDK doc output directories must never be touched

🧠 Decisions

  • Single shell script over pre-commit framework — keeps tooling surface minimal; no pipx/brew install pre-commit required
  • Venv-bootstrap inside format.sh for Ruff — first run creates .venv-format/ and pins ruff==0.15.15; no brew install ruff or other manual setup
  • Prettier as a root npm devDep — comes for free with npm install at the repo root (already a workspace)
  • CI is the source of truth — no Git hooks; if you don't run the script, CI tells you. PRs are blocked on failure
  • Configs colocated with each tool.prettierrc.json / .prettierignore at repo root, [tool.ruff] block in together-sandbox-python/pyproject.toml
  • Mass-format applied as part of this PR — keeps the noisy reformat to a single, clearly-labelled commit

🔄 Discussions

Considered several approaches before landing on the current one:

  1. Husky + lint-staged — rejected: adds Git hook machinery that's bypassable and only formats staged files
  2. pre-commit framework (.pre-commit-config.yaml) — initially drafted; rejected because it requires every contributor to install pipx/pre-commit, which is exactly the DX friction we wanted to avoid
  3. pre-commit.ci hosted bot — best DX (auto-pushes fix commits to PRs) but felt like too much magic for v1
  4. brew install ruff — rejected after CI failure surfaced the same friction locally; replaced with the venv-bootstrap version of format.sh so neither CI nor contributors need to install Ruff out-of-band

🧪 Testing

  • bash format.sh ran cleanly locally and produced the mass-format commit (958e80c)
  • bash format.sh check returns 0 on the formatted tree
  • CI formatting job passes after format.sh was rewritten to bootstrap Ruff into .venv-format/ (earlier revision failed with ruff: command not found)
  • .venv-format/ is gitignored
  • format.sh is committed with mode 100755 (executable, like generate.sh)

📁 References

@christianalfoni christianalfoni changed the title chore: add formatting chore: update formatting script Jun 3, 2026
@christianalfoni christianalfoni requested a review from Copilot June 4, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces repo-wide, CI-enforced formatting via a single format.sh script, and applies the resulting mass-formatting changes across the TypeScript, Python, CLI, docs, and OpenAPI spec files.

Changes:

  • Add format.sh plus Prettier/Ruff configuration and update CI to block PRs on formatting drift.
  • Add root Prettier devDependency and ignore rules; add Ruff formatting config to Python pyproject.toml.
  • Apply Prettier/Ruff formatting across existing TS/Python/JSON/MD/YAML files.

Reviewed changes

Copilot reviewed 41 out of 43 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
together-sandbox-typescript/tests/utils.test.ts Prettier reflow in test expectations.
together-sandbox-typescript/src/utils.ts Prettier reflow in utility functions/types.
together-sandbox-typescript/src/utils.test.ts Prettier reflow across retry/callApi tests.
together-sandbox-typescript/src/types.ts Prettier reflow in shared types.
together-sandbox-typescript/src/TogetherSandbox.ts Prettier reflow in constructor logic.
together-sandbox-typescript/src/Snapshots.ts Prettier reflow in imports/types/logic.
together-sandbox-typescript/src/Sandboxes.ts Prettier reflow in imports/expressions/ctor call.
together-sandbox-typescript/src/Sandbox.ts Prettier reflow in imports/method signatures/expressions.
together-sandbox-typescript/src/RemoteImageBuilder.ts Prettier reflow in request and stream handling.
together-sandbox-typescript/src/lifecycle.ts Prettier reflow in hint map and helpers.
together-sandbox-typescript/src/index.ts Prettier reflow of exports.
together-sandbox-typescript/src/errors.ts Prettier reflow of type guard signature.
together-sandbox-typescript/src/docker.ts Prettier reflow in docker helper functions/errors.
together-sandbox-typescript/CLAUDE.md Prettier reflow in docs snippet.
together-sandbox-python/together_sandbox/docker.py Ruff format reflow in subprocess invocations/errors.
together-sandbox-python/together_sandbox/_utils.py Ruff format reflow in retry utilities and hints.
together-sandbox-python/together_sandbox/_together_sandbox.py Ruff format reflow in config validation error.
together-sandbox-python/together_sandbox/_streaming.py Ruff format reflow in SSEEvent constructor.
together-sandbox-python/together_sandbox/_snapshots.py Ruff format reflow in snapshot build/push logic.
together-sandbox-python/together_sandbox/_sandboxes.py Ruff format reflow in request body construction.
together-sandbox-python/together_sandbox/_sandbox.py Ruff format reflow in API call lambda.
together-sandbox-python/together_sandbox/_remote_image_builder.py Ruff format reflow in SSE and client requests.
together-sandbox-python/together_sandbox/_lifecycle.py Ruff format reflow in stop-reason hint map.
together-sandbox-python/tests/test_with_retry.py Ruff format reflow in test call sites.
together-sandbox-python/tests/test_utils.py Ruff format whitespace normalization.
together-sandbox-python/tests/test_call_api.py Ruff format reflow in helpers/tests.
together-sandbox-python/tests/e2e/test_sandbox_execs.py Ruff format reflow in e2e tests.
together-sandbox-python/tests/e2e/helpers.py Ruff format reflow in timeout exception.
together-sandbox-python/pyproject.toml Add Ruff formatting configuration.
together-sandbox-cli/src/utils/misc.ts Prettier adds trailing comma / reflow.
together-sandbox-cli/src/commands/snapshots.ts Prettier reflow in yargs command and error printing.
together-sandbox-cli/esbuild.cjs Prettier reflow in alias path.
sandbox-openapi.json Prettier reflow/minification of arrays.
api-openapi.json Prettier reflow/minification of arrays/types.
docs/typescript-sdk.md Prettier reflow in code examples/imports.
package.json Add root Prettier devDependency.
package-lock.json Lockfile updates to include Prettier and workspace metadata.
format.sh New unified formatter (Prettier + Ruff) with venv bootstrap.
.prettierrc.json New repo-wide Prettier configuration.
.prettierignore New ignore rules for generated/large paths.
.gitignore Ignore .venv-format/ bootstrap venv.
CLAUDE.md Document formatting workflow and exclusions.
.github/workflows/pr-checks.yml Add new blocking formatting CI job.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread format.sh
mode="${1:-write}"
case "$mode" in
write)
npx prettier --write .
Comment thread format.sh
"$RUFF" format together-sandbox-python
;;
check)
npx prettier --check .
Comment thread .prettierignore
Comment on lines +1 to +2
node_modules
**/dist
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.

2 participants