Skip to content

feat(import): real Bruno (.bru) → .http translator#15

Merged
GamalAnwar merged 1 commit into
masterfrom
claude/bruno-translator
Jun 18, 2026
Merged

feat(import): real Bruno (.bru) → .http translator#15
GamalAnwar merged 1 commit into
masterfrom
claude/bruno-translator

Conversation

@GamalAnwar

Copy link
Copy Markdown
Contributor

Summary

The previous Bruno importer copied each request.bru file's contents verbatim into a .http file — but .bru syntax isn't .http syntax, so imported collections didn't actually run. This replaces it with a real Bru Lang → .http translator so a Bruno user can import their collection and have it execute immediately. (This is the migration on-ramp identified in the Bruno gap analysis.)

bru_to_http parses Bruno's block format and emits equivalent Forge directives:

  • meta / method / url, query (params:query/query block or inline), headers (disabled ~ entries dropped)
  • All auth schemes: bearer, basic, apikey, digest, ntlm, awsv4, wsse, and oauth2 (client-credentials / password / authorization-code grants)
  • Bodies: json, xml, text, sparql, graphql (+ variables), form-urlencoded, multipart (with @file(...) parts) — with brace-balanced block parsing so JSON bodies survive intact
  • Pre-request vars → file variables; post-response vars@capture; assertions@assert (operators mapped; unsupported ones dropped rather than mistranslated); pre/post scripts and tests {} → script blocks; docs → comments (prefixed so a markdown ### can't be read as a request separator)

The collection importer now handles both the modern (requests at the collection root) and legacy (.bruno/requests) layouts, skips folder/collection settings files, and translates Bruno environment .bru (vars {}) files into --env-file-loadable .env files.

Testing

Every translation test re-parses the emitted .http with the Forge parser and asserts the resulting model — a true round trip, not a string match. 30 tests; the module is at ~96% line coverage and the workspace stays above the 95% gate.

🤖 Generated with Claude Code


Generated by Claude Code

The previous Bruno importer copied each `request.bru` file's contents
verbatim into a `.http` file, so imported collections did not run — `.bru`
syntax is not `.http` syntax. This replaces it with an actual Bru Lang
parser (`bru_to_http`) that understands Bruno's block format and re-emits
equivalent Forge `.http` requests:

- meta/method/url, query (`params:query` or inline), headers (disabled
  entries dropped)
- all auth schemes: bearer, basic, apikey, digest, ntlm, awsv4, wsse, and
  oauth2 (client-credentials / password / authorization-code grants)
- bodies: json, xml, text, sparql, graphql (+ variables), form-urlencoded,
  multipart (with `@file(...)` parts) — with brace-balanced block parsing
  so JSON bodies survive intact
- pre-request vars → file variables; post-response vars → `@capture`;
  assertions → `@assert` (operators mapped, unsupported ones dropped);
  pre/post scripts and `tests {}` → script blocks; docs → comments

The collection importer now handles both the modern (requests at the
collection root) and legacy (`.bruno/requests`) layouts, skips
folder/collection settings files, and translates Bruno environment
`.bru` (`vars {}`) files into `--env-file`-loadable `.env` files.

Every translation test re-parses the emitted `.http` with the Forge
parser and asserts the resulting model — a true round trip.

https://claude.ai/code/session_016jgMTwiYCiZA8F9JMFGfWR
@GamalAnwar GamalAnwar merged commit fc33a73 into master Jun 18, 2026
2 checks passed
@GamalAnwar GamalAnwar deleted the claude/bruno-translator branch June 18, 2026 07:34
GamalAnwar added a commit that referenced this pull request Jun 18, 2026
The previous Bruno importer copied each `request.bru` file's contents
verbatim into a `.http` file, so imported collections did not run — `.bru`
syntax is not `.http` syntax. This replaces it with an actual Bru Lang
parser (`bru_to_http`) that understands Bruno's block format and re-emits
equivalent Forge `.http` requests:

- meta/method/url, query (`params:query` or inline), headers (disabled
  entries dropped)
- all auth schemes: bearer, basic, apikey, digest, ntlm, awsv4, wsse, and
  oauth2 (client-credentials / password / authorization-code grants)
- bodies: json, xml, text, sparql, graphql (+ variables), form-urlencoded,
  multipart (with `@file(...)` parts) — with brace-balanced block parsing
  so JSON bodies survive intact
- pre-request vars → file variables; post-response vars → `@capture`;
  assertions → `@assert` (operators mapped, unsupported ones dropped);
  pre/post scripts and `tests {}` → script blocks; docs → comments

The collection importer now handles both the modern (requests at the
collection root) and legacy (`.bruno/requests`) layouts, skips
folder/collection settings files, and translates Bruno environment
`.bru` (`vars {}`) files into `--env-file`-loadable `.env` files.

Every translation test re-parses the emitted `.http` with the Forge
parser and asserts the resulting model — a true round trip.
GamalAnwar added a commit that referenced this pull request Jun 18, 2026
The previous Bruno importer copied each `request.bru` file's contents
verbatim into a `.http` file, so imported collections did not run — `.bru`
syntax is not `.http` syntax. This replaces it with an actual Bru Lang
parser (`bru_to_http`) that understands Bruno's block format and re-emits
equivalent Forge `.http` requests:

- meta/method/url, query (`params:query` or inline), headers (disabled
  entries dropped)
- all auth schemes: bearer, basic, apikey, digest, ntlm, awsv4, wsse, and
  oauth2 (client-credentials / password / authorization-code grants)
- bodies: json, xml, text, sparql, graphql (+ variables), form-urlencoded,
  multipart (with `@file(...)` parts) — with brace-balanced block parsing
  so JSON bodies survive intact
- pre-request vars → file variables; post-response vars → `@capture`;
  assertions → `@assert` (operators mapped, unsupported ones dropped);
  pre/post scripts and `tests {}` → script blocks; docs → comments

The collection importer now handles both the modern (requests at the
collection root) and legacy (`.bruno/requests`) layouts, skips
folder/collection settings files, and translates Bruno environment
`.bru` (`vars {}`) files into `--env-file`-loadable `.env` files.

Every translation test re-parses the emitted `.http` with the Forge
parser and asserts the resulting model — a true round trip.
GamalAnwar added a commit that referenced this pull request Jun 18, 2026
The previous Bruno importer copied each `request.bru` file's contents
verbatim into a `.http` file, so imported collections did not run — `.bru`
syntax is not `.http` syntax. This replaces it with an actual Bru Lang
parser (`bru_to_http`) that understands Bruno's block format and re-emits
equivalent Forge `.http` requests:

- meta/method/url, query (`params:query` or inline), headers (disabled
  entries dropped)
- all auth schemes: bearer, basic, apikey, digest, ntlm, awsv4, wsse, and
  oauth2 (client-credentials / password / authorization-code grants)
- bodies: json, xml, text, sparql, graphql (+ variables), form-urlencoded,
  multipart (with `@file(...)` parts) — with brace-balanced block parsing
  so JSON bodies survive intact
- pre-request vars → file variables; post-response vars → `@capture`;
  assertions → `@assert` (operators mapped, unsupported ones dropped);
  pre/post scripts and `tests {}` → script blocks; docs → comments

The collection importer now handles both the modern (requests at the
collection root) and legacy (`.bruno/requests`) layouts, skips
folder/collection settings files, and translates Bruno environment
`.bru` (`vars {}`) files into `--env-file`-loadable `.env` files.

Every translation test re-parses the emitted `.http` with the Forge
parser and asserts the resulting model — a true round trip.
GamalAnwar added a commit that referenced this pull request Jun 18, 2026
The previous Bruno importer copied each `request.bru` file's contents
verbatim into a `.http` file, so imported collections did not run — `.bru`
syntax is not `.http` syntax. This replaces it with an actual Bru Lang
parser (`bru_to_http`) that understands Bruno's block format and re-emits
equivalent Forge `.http` requests:

- meta/method/url, query (`params:query` or inline), headers (disabled
  entries dropped)
- all auth schemes: bearer, basic, apikey, digest, ntlm, awsv4, wsse, and
  oauth2 (client-credentials / password / authorization-code grants)
- bodies: json, xml, text, sparql, graphql (+ variables), form-urlencoded,
  multipart (with `@file(...)` parts) — with brace-balanced block parsing
  so JSON bodies survive intact
- pre-request vars → file variables; post-response vars → `@capture`;
  assertions → `@assert` (operators mapped, unsupported ones dropped);
  pre/post scripts and `tests {}` → script blocks; docs → comments

The collection importer now handles both the modern (requests at the
collection root) and legacy (`.bruno/requests`) layouts, skips
folder/collection settings files, and translates Bruno environment
`.bru` (`vars {}`) files into `--env-file`-loadable `.env` files.

Every translation test re-parses the emitted `.http` with the Forge
parser and asserts the resulting model — a true round trip.
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