Skip to content

feat: init --workspace auto-detects monorepo markers and configures prefix#253

Merged
indaco merged 7 commits intomainfrom
feat/init-workspace-auto-detect
Apr 2, 2026
Merged

feat: init --workspace auto-detects monorepo markers and configures prefix#253
indaco merged 7 commits intomainfrom
feat/init-workspace-auto-detect

Conversation

@indaco
Copy link
Copy Markdown
Owner

@indaco indaco commented Apr 2, 2026

Description

sley init --workspace now detects monorepo workspace markers and automatically configures tag prefix and versioning mode. Detection supports four ecosystems (checked in order, first match wins):

  1. go.work - parses use directives for module paths
  2. pnpm-workspace.yaml - parses packages field, expands globs
  3. package.json with workspaces - parses JSON array, expands globs
  4. Cargo.toml with [workspace] - scans for section, parses members

When detected:

  • Sets workspace.versioning: independent in generated config
  • Sets plugins.tag-manager.prefix: "{module_path}/v"
  • Creates .version files (initialized to 0.0.0) in each discovered module directory (skips existing files)
  • In interactive mode, prompts for confirmation before applying defaults

Also includes the workspace.versioning config field addition (shared with the discover mismatch warnings feature).

Related Issue

  • None

Notes for Reviewers

  • External go.work paths (e.g., use ../shared) are excluded - only subdirectories are included

indaco and others added 7 commits April 2, 2026 14:38
…prefix

Add DetectMonorepo() supporting go.work, pnpm-workspace.yaml, package.json
workspaces, and Cargo.toml [workspace]. When detected, init --workspace sets
tag prefix to {module_path}/v, workspace.versioning to independent, and
creates .version files in discovered module directories.

Also adds workspace.versioning config field (independent|coordinated) with
validation, shared with the discover mismatch warnings feature.
Add 8 TestDetectMonorepo_* tests covering go.work (block/single-line/external),
pnpm-workspace.yaml, package.json workspaces, Cargo.toml [workspace], no markers,
and priority ordering. Add TestCreateMonorepoVersionFiles verifying .version
creation and skip-if-exists behavior.
…ions)

Fix unchecked os.MkdirAll in tests, add filepath.Clean for gosec path
traversal warnings, use 0o600 for .version file permissions.
Extract chdirTest, buildTestModules, assertError, and assertCreatedTags helpers.

Co-Authored-By: Claude <noreply@anthropic.com>
@indaco indaco added the enhancement New feature or request label Apr 2, 2026
@indaco indaco merged commit ce3c1c2 into main Apr 2, 2026
7 checks passed
@indaco indaco deleted the feat/init-workspace-auto-detect branch April 2, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant