Skip to content

Improve mnemonic handling and remote repo resolution#46

Merged
amhellmund merged 3 commits intomainfrom
claude/issue-43-20260301-2038
Mar 1, 2026
Merged

Improve mnemonic handling and remote repo resolution#46
amhellmund merged 3 commits intomainfrom
claude/issue-43-20260301-2038

Conversation

@amhellmund
Copy link
Copy Markdown
Owner

Fixes #43

Changes

  • Mnemonic validation: names must match ^[a-z][a-z0-9_-]*$ (lowercase letter, then alphanumeric/dash/underscore; no slashes or uppercase)
  • At least one source-import required per workspace config
  • source_import_map modelled as dict[tuple[str, str], Path] keyed by (repo_id, mnemonic): local mnemonics use "" as repo_id, remote repos use "@name"
  • Source file repo context: bare mnemonic imports (mnemonic/path) resolve using the source file's repo; remote imports require @repo/mnemonic/path format
  • CLI scan: only files under configured local mnemonic paths are scanned
  • init validation: validates mnemonic format before creating workspace

Generated with Claude Code

- Validate mnemonic names: must match `^[a-z][a-z0-9_-]*$` (lowercase
  letter, then alphanumeric/dash/underscore; no slashes or uppercase)
- Require at least one source-import per workspace config
- Validate mnemonic names in `archml init` CLI command
- Model source_import_map as `dict[tuple[str, str], Path]` keyed by
  `(repo_id, mnemonic)`: local mnemonics use `""` as repo_id, remote
  repos use `"@name"`
- Add `_get_source_repo()` to determine which repo a source file belongs to
- Update `_resolve_import_source()` to accept source_repo context so bare
  mnemonic imports (`mnemonic/path`) resolve against the source file's repo
- Remote imports require full `@repo/mnemonic/path` format; bare imports
  require `mnemonic/path` format (no bare unqualified paths)
- CLI `check` scans only files under configured local mnemonic paths
  (not the workspace root), and does not add a bare `@repo` fallback key
- Update all tests for the new mnemonic-based import and map structure

Co-authored-by: Andi Hellmund <amhellmund@users.noreply.github.com>

# Build the source import map: (repo_id, mnemonic) -> absolute base path.
# Local mnemonics use "" as repo_id; remote repos use "@name".
source_import_map: dict[tuple[str, str], Path] = {}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude Use a namedtuple here instead of a plain tuple.

for imp in config.source_imports:
if isinstance(imp, LocalPathImport):
source_import_map[imp.name] = (directory / imp.local_path).resolve()
source_import_map[("", imp.name)] = (directory / imp.local_path).resolve()
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude
Always use a repo name. Even the local import has a repo name, the name of the archml workspace.

@amhellmund amhellmund merged commit 266df51 into main Mar 1, 2026
5 checks passed
Sign up for free to 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.

Handling of remote repos and mnemonics

1 participant