Skip to content

refactor(completions): replace Fig spec string concatenation with serde_json#159

Merged
avihut merged 1 commit intomasterfrom
daft-146/kiro-completions-fix
Feb 3, 2026
Merged

refactor(completions): replace Fig spec string concatenation with serde_json#159
avihut merged 1 commit intomasterfrom
daft-146/kiro-completions-fix

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Feb 3, 2026

Summary

  • Replace manual string building in the four Fig/Kiro completion spec generators with structured Serialize types and serde_json::to_string_pretty()
  • Add FigSpec, FigArgs, FigArg, FigGenerator, FigOption, FigName, FigSubcommand structs with serde attributes for clean serialization
  • Remove fig_generator_block(), fig_generator_block_indented(), and escape_js_string() (no longer needed)
  • Fix Fig specs to use ESM format (const + export default) instead of CommonJS (var + module.exports)
  • Fix Fig install path to use autocomplete/build/ subdirectory (required by Kiro / Amazon Q)
  • Add 6 structural unit tests and 2 integration tests for the new output

Fixes #146

Test plan

  • cargo fmt -- --check passes
  • cargo clippy -- -D warnings passes with zero warnings
  • cargo test — 170 unit tests pass (including 6 new structural tests)
  • just test-integration-completions — all 29 integration tests pass
  • Verified JSON-formatted ESM output with daft completions fig --command git-worktree-checkout

🤖 Generated with Claude Code

…de_json

Replace manual string building in the four Fig/Kiro completion spec
generators with structured Serialize types and serde_json::to_string_pretty().
This produces valid JSON (which is also valid JS) instead of hand-crafted
JS object literals, eliminating the need for custom escaping and indentation
logic.

- Add FigSpec, FigArgs, FigArg, FigGenerator, FigOption, FigName,
  FigSubcommand structs with serde attributes
- Add wrap_esm() and build_fig_generator() shared helpers
- Rewrite generate_fig_completion_string, generate_fig_alias_string,
  generate_fig_daft_spec, generate_fig_git_daft_spec
- Remove fig_generator_block, fig_generator_block_indented, escape_js_string
- Add 6 structural unit tests for the new serde-based output
- Fix Fig install path to use autocomplete/build/ subdirectory
- Fix Fig specs to use ESM format (const + export default)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@avihut avihut added this to the v1.1.0 milestone Feb 3, 2026
@avihut avihut added fix Bug fix refactor Code refactoring labels Feb 3, 2026
@avihut avihut self-assigned this Feb 3, 2026
@avihut avihut merged commit 1705e53 into master Feb 3, 2026
5 checks passed
@avihut avihut deleted the daft-146/kiro-completions-fix branch February 3, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kiro / Amazon Q completions still don't work

1 participant