Skip to content

feat: explicit namespace field + compat shim (0.0.6)#23

Merged
Sunrisepeak merged 2 commits into
mainfrom
feat/namespace-field
May 11, 2026
Merged

feat: explicit namespace field + compat shim (0.0.6)#23
Sunrisepeak merged 2 commits into
mainfrom
feat/namespace-field

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

Adds first-class namespace field support to mcpp.toml and xpkg .lua descriptors (xpkg V1 style), plus a dedicated src/pm/compat.cppm module that centralises all backward-compatibility logic.

Before (legacy, works until 1.0.0)

[package]
name = "mcpplibs.cmdline"     # namespace embedded in name

After (canonical, 0.0.6+)

[package]
namespace = "mcpplibs"
name      = "cmdline"

Both forms work simultaneously — compat::resolve_package_name handles the dispatch.

Pieces

  • src/pm/compat.cppm (new) — resolve_package_name, qualified_name, xpkg_dir_name
  • src/manifest.cppmPackage.namespace_ field + TOML/lua parsing
  • src/cli.cppm — name matching via compat + lua namespace propagation

Deprecation

Dotted-name-as-namespace is deprecated, removal planned for 1.0.0.

Test plan

  • Builds clean
  • CI e2e suite green (31/32/33 cover the dep resolver paths)

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.
@Sunrisepeak Sunrisepeak merged commit 940c9d2 into main May 11, 2026
1 check 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.

1 participant