refactor(completions): replace Fig spec string concatenation with serde_json#159
Merged
refactor(completions): replace Fig spec string concatenation with serde_json#159
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Serializetypes andserde_json::to_string_pretty()FigSpec,FigArgs,FigArg,FigGenerator,FigOption,FigName,FigSubcommandstructs with serde attributes for clean serializationfig_generator_block(),fig_generator_block_indented(), andescape_js_string()(no longer needed)const+export default) instead of CommonJS (var+module.exports)autocomplete/build/subdirectory (required by Kiro / Amazon Q)Fixes #146
Test plan
cargo fmt -- --checkpassescargo clippy -- -D warningspasses with zero warningscargo test— 170 unit tests pass (including 6 new structural tests)just test-integration-completions— all 29 integration tests passdaft completions fig --command git-worktree-checkout🤖 Generated with Claude Code