feat: explicit namespace field + compat shim (0.0.6)#23
Merged
Conversation
Adds first-class support for xpkg V1's `namespace` field in both
mcpp.toml and xpkg .lua descriptors:
[package]
namespace = "mcpplibs" # NEW (0.0.6+)
name = "cmdline" # now the short name only
Previously, namespace was inferred by splitting on the first dot in
`name = "mcpplibs.cmdline"`. That legacy form keeps working via the
new `src/pm/compat.cppm` shim module, which centralises all backward-
compatibility logic:
* `resolve_package_name(name, ns)` — canonical (ns field) vs legacy
(dotted split) vs bare (default ns "mcpp"). Rule priority: explicit
field > first-dot split > default.
* `qualified_name(ns, short)` — reconstruct "mcpplibs.cmdline" when
needed (e.g. xpkgs directory lookup, error messages).
* `xpkg_dir_name(index, ns, short)` — encapsulate the xpkgs/
directory naming convention in one place.
DEPRECATION SCHEDULE (documented in compat.cppm header):
The dotted-name-as-namespace convention is slated for removal in
mcpp 1.0.0. Projects should migrate to the canonical `namespace`
field before that point.
Other changes:
* manifest.cppm: Package struct gains `namespace_` field; TOML
parser reads `package.namespace`; new `extract_xpkg_namespace()`
reads the field from xpkg .lua descriptors.
* cli.cppm: dep name matching uses compat::resolve_package_name;
lua-level namespace propagates into loaded manifests.
* Version bump to 0.0.6.
Extends PR #23 with: 1. Design doc (.agents/docs/2026-05-11-namespace-field-design.md) covering the full namespace scheme: mcpplibs / mcpplibs.capi / compat, with xpkgs directory naming, migration path, and deprecation timeline. 2. package_fetcher.cppm: install_path() now supports namespace-aware directory lookup. Priority order: a. New: <namespace>-x-<shortName> (e.g. "mcpplibs-x-cmdline") b. Old: <defaultIndex>-x-<fullName> (e.g. "mcpp-index-x-mcpplibs.cmdline") c. Old short: <defaultIndex>-x-<name> (e.g. "mcpp-index-x-gtest") d. Fallback scan: any directory matching *-x-<name> This ensures both new installs (namespace-aware xpkgs paths) and pre-0.0.6 cached installs (index-prefixed paths) resolve correctly, enabling a smooth migration with no forced cache invalidation.
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
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.
Summary
Adds first-class
namespacefield support to mcpp.toml and xpkg .lua descriptors (xpkg V1 style), plus a dedicatedsrc/pm/compat.cppmmodule that centralises all backward-compatibility logic.Before (legacy, works until 1.0.0)
After (canonical, 0.0.6+)
Both forms work simultaneously —
compat::resolve_package_namehandles the dispatch.Pieces
src/pm/compat.cppm(new) —resolve_package_name,qualified_name,xpkg_dir_namesrc/manifest.cppm—Package.namespace_field + TOML/lua parsingsrc/cli.cppm— name matching via compat + lua namespace propagationDeprecation
Dotted-name-as-namespace is deprecated, removal planned for 1.0.0.
Test plan