Skip to content

refactor: remove src/ directory layer from all workspace packages - #8

Merged
antosubash merged 4 commits into
mainfrom
claude/simplify-package-layout-M1uPu
Apr 14, 2026
Merged

refactor: remove src/ directory layer from all workspace packages#8
antosubash merged 4 commits into
mainfrom
claude/simplify-package-layout-M1uPu

Conversation

@antosubash

Copy link
Copy Markdown
Owner

The src-layout adds unnecessary depth in a uv-managed monorepo workspace.
Paths like modules/products/src/sm_products/module.py become
modules/products/sm_products/module.py — one fewer directory level to
navigate. Hatchling auto-detects flat layout when src/ is absent, so no
pyproject.toml build config changes are needed.

Changes:

  • Move all package dirs from {pkg}/src/{name}/ to {pkg}/{name}/
  • Update ty extra-paths in root pyproject.toml (drop /src suffix)
  • Fix relative path traversals in app_builder.py (one fewer parent dir)

https://claude.ai/code/session_01Fi5iPfiDg7YLggyzS7VgLp

The src-layout adds unnecessary depth in a uv-managed monorepo workspace.
Paths like modules/products/src/sm_products/module.py become
modules/products/sm_products/module.py — one fewer directory level to
navigate. Hatchling auto-detects flat layout when src/ is absent, so no
pyproject.toml build config changes are needed.
Changes:
- Move all package dirs from {pkg}/src/{name}/ to {pkg}/{name}/
- Update ty extra-paths in root pyproject.toml (drop /src suffix)
- Fix relative path traversals in app_builder.py (one fewer parent dir)
https://claude.ai/code/session_01Fi5iPfiDg7YLggyzS7VgLp
New files added in main under the old src/ paths (inertia_utils.py,
permissions.py, validation.ts) are placed at the flat-layout locations.
app_builder.py auto-merged cleanly, preserving the corrected relative paths.
https://claude.ai/code/session_01Fi5iPfiDg7YLggyzS7VgLp
…th resolution
- pages.ts: update glob pattern and regex to match flat layout
- tsconfig.json: update include paths for modules (no src/)
- biome.json: update file includes for modules (no src/)
- app_builder.py: replace fragile os.path.join("..", "..") chains with
a single _PROJECT_ROOT constant using pathlib; remove unused os import
https://claude.ai/code/session_01Fi5iPfiDg7YLggyzS7VgLp
@antosubash
antosubash merged commit bcc06dc into mainApr 14, 2026
antosubash pushed a commit that referenced this pull request Apr 14, 2026
Updates the scaffolding to match PR #8's layout change that removed
the src/ directory from all workspace packages:
- Generate files at modules/<name>/sm_<name>/ instead of
modules/<name>/src/sm_<name>/
- Update root pyproject.toml to insert modules/<name> in ty paths
(no /src suffix)
- Rewrite insertion helpers with cleaner regex-based approach that
correctly handles the new host/pyproject.toml structure with
multiple sm-* dependencies
https://claude.ai/code/session_01G5HHXJfxAQ53grAwiyUzyj
antosubash pushed a commit that referenced this pull request Apr 14, 2026
…t-delete)
- Drop src/ directory layer in path references (main #8)
- Keep our Request/Response imports (RedirectResponse no longer used
after removing old redirect workaround)
- Update pages.ts glob to match new module layout without src/
https://claude.ai/code/session_01TcCi9nT9jkWrXfByuqzDVs
antosubash added a commit that referenced this pull request Apr 14, 2026
* feat: add module scaffolding CLI (make new-module name=<name>)
Automates new module creation, eliminating the need to manually create
14+ files and update config. The script generates the full module
structure (pyproject.toml, module class, models, service, schemas,
contracts, endpoints, deps, tests) and registers the module in
host/pyproject.toml and root pyproject.toml.
Also updates conftest.py to auto-discover module Base classes via
entry points, so new modules' tables are automatically created in
the test database.
https://claude.ai/code/session_01G5HHXJfxAQ53grAwiyUzyj
* refactor: simplify scaffolding code from review findings
- conftest.py: reuse framework's discover_modules() + all_module_bases
instead of reimplementing entry point discovery; cache with lru_cache;
batch create_all into single run_sync; extract _create_all_tables helper
- new_module.py: replace hardcoded anchor strings with last-entry
insertion via _insert_before_last(); add warnings on missing anchors
- test_new_module.py: extract repeated setup into module_root fixture
https://claude.ai/code/session_01G5HHXJfxAQ53grAwiyUzyj
* fix: adapt scaffolding to new layout without src/ directory
Updates the scaffolding to match PR #8's layout change that removed
the src/ directory from all workspace packages:
- Generate files at modules/<name>/sm_<name>/ instead of
modules/<name>/src/sm_<name>/
- Update root pyproject.toml to insert modules/<name> in ty paths
(no /src suffix)
- Rewrite insertion helpers with cleaner regex-based approach that
correctly handles the new host/pyproject.toml structure with
multiple sm-* dependencies
https://claude.ai/code/session_01G5HHXJfxAQ53grAwiyUzyj
* test: expand scaffolding test coverage from 23 to 49 tests
Adds coverage for previously untested code paths and behaviors:
- _insert_after_last_match helper: 4 direct unit tests
- create_file utility: 3 tests (content, parent dir creation, dedent)
- main() CLI entry point: 2 tests (happy path + invalid name)
- End-to-end subprocess test: verifies script runs standalone
New TestUpdateRootPyproject cases:
- Realistic multi-module pyproject.toml matching real repo
- Skips when already present
- Warns to stderr when no insertion point found
New TestGeneratedFilesSyntaxValidity:
- All generated Python files parse with ast.parse
- Generated pyproject.toml parses with tomllib
- Compound names (blog_posts) produce valid TOML
New TestGeneratedTemplateContent covers:
- service.py has full CRUD methods
- endpoints/api.py has all REST endpoints with correct status codes
- endpoints/views.py uses Inertia properly
- deps.py provides DI function
- contracts/service.py defines Protocol
- contracts/__init__.py exports public API
- module.py registers routes and permissions
- models.py uses AuditMixin with correct tablename
- test_<name>.py contains all expected test classes
https://claude.ai/code/session_01G5HHXJfxAQ53grAwiyUzyj
* refactor: simplify scaffolding tests from review findings
- Add scaffolded_orders fixture: scaffold_module() now runs once per test
rather than 10x in TestGeneratedTemplateContent
- Add workspace fixture: deduplicates the host/pyproject + root pyproject
setup between TestMainCLI tests
- Extract MINIMAL_HOST_PYPROJECT and MINIMAL_ROOT_PYPROJECT constants
- TestCreateFile: replace inline monkeypatch with the existing module_root
fixture (3 tests collapsed to clean one-liners)
- TestScaffoldModule: use scaffolded_orders fixture; eliminate repeated
`module_root / "modules" / "orders" / "sm_orders"` path strings
- TestGeneratedFilesSyntaxValidity: reuse scaffolded_orders for the
orders-based tests
- Drop TestCLIAsSubprocess: TestMainCLI::test_main_invokes_full_pipeline
with capsys covers the same ground without a subprocess fork
- Move `import new_module` to module level (reused by all fixtures)
- Strip narrative comments
49 tests → 48 tests, suite time 0.58s → 0.42s
Sign up for freeto 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

@antosubash@claude