-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Multi-package support with same-directory file merging #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hemanta212
wants to merge
11
commits into
rlch:main
Choose a base branch
from
hemanta212:feat/multi-package-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Owner
|
LGTM |
b22cf17 to
a4bf1c6
Compare
Amp-Thread-ID: https://ampcode.com/threads/T-019bb083-728f-70ce-9a30-5cdd1c2a1409 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019bb083-728f-70ce-9a30-5cdd1c2a1409 Co-authored-by: Amp <amp@ampcode.com>
- example/repro-multi-package/: demonstrates file overwrite and same-package import issues - .plans/multi-package-support.prd: detailed implementation with pseudocode and file citations Refs: T-019b9974-f6d1-72b9-878a-58d488781789 Amp-Thread-ID: https://ampcode.com/threads/T-019bb083-728f-70ce-9a30-5cdd1c2a1409 Co-authored-by: Amp <amp@ampcode.com>
- Add module/merge.go with MergePackageFiles() for merging same-dir .scaf files - Import deduplication by resolved path - Same-package import detection with warnings - Duplicate function detection with errors - Setup/teardown conflict detection - Add language/go/package.go with InferPackageName() using stdlib ladder - go/build.ImportDir (respects build tags) - parser.ParseFile with PackageClauseOnly (catches hidden files) - SanitizePackageName fallback (folder name) - Refactor cmd/scaf/generate.go for go-generate style flow - Config discovery walks up from cwd to find .scaf.yaml - Schema loaded relative to config location - Uses gocodewalker for fast .gitignore-aware directory traversal - Groups .scaf files by directory, merges each package
- Add same-package-import rule to analysis/rules.go for LSP diagnostics - Extract loadConfigWithDir to cmd/scaf/config.go for shared use - Update test.go to use shared config discovery (walks up from cwd) - Consolidate MergePackageFiles API to use ParsedFile struct - Fix same-package imports to be skipped entirely (not just warned) - Remove redundant MergePackageFilesWithPaths wrapper Amp-Thread-ID: https://ampcode.com/threads/T-019bb66a-8528-772c-9c6a-8d6ece466737 Co-authored-by: Amp <amp@ampcode.com>
a4bf1c6 to
a217b7d
Compare
a217b7d to
3abdbe6
Compare
- Add InferPackageName to Language interface - Add PackageName and AdapterName to GenerateContext - Move Go-specific logic (binding lookup, package inference) into GoLanguage.Generate() - Remove direct golang import from cmd/scaf/generate.go - Use go/token.Lookup for keyword detection instead of hardcoded map - Add warning when folder name is a Go keyword (e.g., func -> funcpkg) - Clean up comments and remove gocodewalker references from docs
d478c98 to
6123de3
Compare
Setup and teardown clauses are only used by 'scaf test' for runtime execution against a real database. The 'scaf generate' command only uses Functions (-> scaf.go) and Scopes (-> scaf_test.go mocks). Erroring on conflicting setup/teardown was blocking valid multi-file packages where each file has its own test fixtures.
Same-package imports (e.g., import "./fixtures") are valid for 'scaf test' runtime resolution but redundant for 'scaf generate'. Removed the warning as it was noisy and implied user error when the scaf file was correctly written for testing.
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.
Overview
Run
scaf generatefrom project root to discover and generate code for all packages.What Changed
Core Features
.scaffiles in same directory merge into singlescaf.go/scaf_test.go.scaf.yaml, schema resolved relative to configArchitecture (Layer Separation)
module/merge.golanguage/go/package.golanguage/language.gocmd/scaf/generate.gocmd/scaf/config.goanalysis/rules.goKey Deviations from Original Plan
InferPackageName(dir)toLanguageinterface so cmd doesn't couple to language/gogo/token.Lookup().IsKeyword()instead of hardcoded mapgenerateandtestcommands use same config discovery (walks up from cwd)Package Name Inference (Go)
Testing