Implement PromptTemplate (#119)#172
Conversation
Add PromptTemplate.createAnalysisAndCodeGeneration(), which builds the Claude API prompt combining gap analysis of the SyntaxKit library against an expected Swift output, its AST, and a DSL sample with strict code-generation output rules: complete files (no diffs) in <file path="..."> blocks, compile validity under Swift 6.1 / SwiftSyntax 601, and one type per file. Uses a caseless enum instead of the struct named in the issue because SwiftLint's convenience_type rule flags static-only structs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Code Review — PR 172: Implement PromptTemplate Overall this is clean, well-structured code. One security/correctness concern worth addressing before merge. Security — XML tag injection in prompt inputs
Recommendation: Strip or escape the closing tags from each input before interpolation, or switch to a delimiter that can't collide with arbitrary Swift source (e.g. a random UUID fence, or base64-encode the inputs). At minimum, add a note in the doc comment warning callers that inputs containing the XML closing tags will corrupt the prompt structure. Minor observations
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## claude-prompt #172 +/- ##
=================================================
- Coverage 80.16% 79.97% -0.20%
=================================================
Files 153 153
Lines 5209 5209
=================================================
- Hits 4176 4166 -10
- Misses 1033 1043 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #119.
Summary
Sources/AiSTKit/PromptTemplate.swiftwithPromptTemplate.createAnalysisAndCodeGeneration(syntaxKitLibrary:expectedSwift:swiftAST:swiftDSL:), the prompt builder the ClaudeKit wrapper (Implement ClaudeKit Wrapper #116) will use forskit analyze.<syntaxkit_library>,<swift_code>,<swift_ast>,<swift_dsl>), walks Claude through a SyntaxKit-specific gap analysis (CodeBlockconformance, existing protocols, result builders, source directory layout), then requests a plain-text summary followed by the implementation.<file path="relative/path.swift">…</file>with COMPLETE content (diffs and "rest unchanged" elisions explicitly forbidden), no markdown fences, summary before the first file block.swift buildunder Swift 6.1 / SwiftSyntax 601) and one-type-per-file organization required.Notes
enuminstead of the issue's "struct": SwiftLint'sconvenience_typerule flags static-only structs; matches the existingAiSTKitnamespace enum.publicaccess per ACL preference from Implement AuthenticationMiddleware #117 planning.Verification
swift buildpasses.mise exec -- swiftlint lintandmise exec -- swift-format lintclean on the new file../Scripts/lint.shPeriphery step fails with a pre-existing "index store path does not exist" error that reproduces on a clean tree (verified via stash); unrelated to this change.🤖 Generated with Claude Code