Skip to content

fix(new): resolve namespaced packages in --template fetch#130

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/template-namespaced-packages
Jun 10, 2026
Merged

fix(new): resolve namespaced packages in --template fetch#130
Sunrisepeak merged 1 commit into
mainfrom
fix/template-namespaced-packages

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Problem

mcpp new <name> --template llmapi (and --list-templates llmapi) failed:

 Downloading llmapi v0.2.6
error: fetch 'llmapi@0.2.6' failed (exit 1)

The template fetch finds pkgs/l/llmapi.lua by bare filename candidates, but keeps namespace "" from the candidate loop. The install target then becomes llmapi@0.2.6, while xlings resolves packages by the descriptor's qualified name (mcpplibs.llmapi). Any namespaced package was unusable as a template source (llmapi, tinyhttps, …); only root-index packages like imgui worked.

Fix

fetch_template_package now derives the structured (namespace, shortName) from the descriptor fields (namespace = / name =) via a new pure helper pm::compat::descriptor_coordinates(), instead of trusting the filename hit:

  • legacy embedded form (namespace = "mcpplibs", name = "mcpplibs.llmapi") → (mcpplibs, llmapi)
  • canonical form (namespace = "mcpplibs", name = "llmapi") → (mcpplibs, llmapi)
  • legacy dotted name without namespace field → split on first dot
  • root-index packages (imgui) keep namespace "" and still install by bare name (unlike resolve_package_name(), no default-namespace promotion)

Verification

  • mcpp test: 18/18 unit suites pass, incl. 6 new descriptor_coordinates cases in test_pm_compat
  • mcpp new --list-templates llmapi / tinyhttps: now resolves and installs the package (reports "ships no templates/" — correct for 0.2.6)
  • mcpp new --list-templates imgui: unchanged (lists window/docking)
  • e2e 02_new_build_run.sh: OK

Needed for the llmapi 0.2.7 template release (mcpplibs/llmapi#17) so mcpp new xxx --template llmapi closes the loop.

`mcpp new --template llmapi` failed with `fetch 'llmapi@0.2.6' failed`:
the index lookup finds pkgs/l/llmapi.lua by bare filename, but the
namespace stayed "" while the descriptor declares namespace="mcpplibs"
(legacy name="mcpplibs.llmapi") — and xlings resolves install targets
by the descriptor's qualified name.

fetch_template_package now derives the structured (namespace, shortName)
from the descriptor fields via the new pm::compat::descriptor_coordinates
helper instead of trusting the filename hit. Root-index packages (imgui)
keep namespace "" and still install by bare name; legacy embedded/dotted
names and canonical namespace fields all normalize to the same
coordinates. Covered by unit tests in test_pm_compat.
Sunrisepeak added a commit to mcpplibs/mcpp-index that referenced this pull request Jun 10, 2026
GLOBAL: GitHub tag tarball (sha256 verified). CN: gitcode mcpp-res
release asset, byte-identical per mirror convention. 0.2.8 ships
templates/ (openai default, chat, anthropic, deepseek) consumed by
`mcpp new <name> --template llmapi` (needs mcpp > 0.0.52 for the
namespaced template fetch fix, mcpp-community/mcpp#130). 0.2.7 is
skipped: its default template did not compile under import std.
@Sunrisepeak Sunrisepeak merged commit a62fb8e into main Jun 10, 2026
3 checks passed
Sunrisepeak added a commit to mcpplibs/mcpp-index that referenced this pull request Jun 10, 2026
GLOBAL: GitHub tag tarball; CN: gitcode mcpp-res asset (byte-identical, sha256 verified). 0.2.8 ships templates (openai default, chat, anthropic, deepseek) for mcpp new --template llmapi (needs namespaced-template fix, mcpp-community/mcpp#130). 0.2.7 skipped (broken default template).
Sunrisepeak added a commit that referenced this pull request Jun 10, 2026
Sunrisepeak added a commit that referenced this pull request Jun 10, 2026
… subsystems; 0.0.54 (#129)

* docs(agents): cli modularization architecture + implementation plan

* refactor(cli): split cli.cppm into focused modules (dispatcher-only cli)

cli.cppm (6192 lines) -> thin dispatcher (481 lines). All command
implementations move into dedicated modules, byte-identical bodies:

  mcpp.cli.common         project/workspace discovery + fs utils
  mcpp.cli.install_ui     xlings NDJSON -> ui download-progress adapters
  mcpp.toolchain.post_install  patchelf/specs/cfg payload fixups
  mcpp.cli.build          BuildContext + prepare_build (build core)
  mcpp.cli.cmd_build      build/run/test/clean/dyndep + fast-path cache
  mcpp.cli.cmd_new        new + package templates
  mcpp.cli.cmd_registry   search + index management
  mcpp.cli.cmd_cache      cache list/info/prune/clean
  mcpp.cli.cmd_toolchain  toolchain install/list/default/remove
  mcpp.cli.cmd_publish    publish/pack/emit-xpkg
  mcpp.cli.cmd_self       self */doctor/why/env/explain

Zero behavior change (same statement order, messages, exit codes).
Architecture + plan: .agents/docs/2026-06-10-cli-modularization.md

* docs(agents): mark cli modularization plan executed + verification results

* refactor(arch): relocate domain logic out of the cli layer (cli = parse + route)

Phase 2 of the cli modularization: every implementation now lives in
its owning subsystem; cli/cmd_* modules contain only argument handling,
CLI-shape validation and routing (no ParsedArgs below the cli layer).

  mcpp.project            manifest/workspace discovery (pm.commands' private
                          copy folded in)
  mcpp.fetcher.progress   xlings NDJSON -> ui adapters (InstallProgressHandler)
  mcpp.build.prepare      BuildContext + prepare_build
  mcpp.build.execute      build cache/fast-path, run_build_plan, run/test/clean
  mcpp.toolchain.manager  toolchain list/install/set-default/remove
  mcpp.pm.index_ops       search + index list/add/remove/update/pin/unpin
  mcpp.bmi_cache.ops      cache walk/list/info/prune/clean + fs size helpers
  mcpp.scaffold.ops       package templates + builtin project creation
  mcpp.publish.ops        publish pipeline + emit xpkg
  mcpp.pack.ops           pack orchestration
  mcpp.doctor             doctor/why/env/explain + self init/config

mcpp.cli.{common,install_ui,build} are gone; the whole cli layer is now
cli.cppm (481) + seven adapters (450 lines total). Bodies moved verbatim
(zero behavior change). Doc: .agents/docs/2026-06-10-cli-modularization.md

* refactor(naming): replace grab-bag ops/manager module names with responsibility names

mcpp.bmi_cache.ops      -> mcpp.bmi_cache.maintenance
mcpp.scaffold.ops       -> mcpp.scaffold.create
mcpp.publish.ops        -> mcpp.publish.pipeline
mcpp.pack.ops           -> mcpp.pack.pipeline
mcpp.pm.index_ops       -> mcpp.pm.index_management
mcpp.toolchain.manager  -> mcpp.toolchain.lifecycle

Pure rename (module/file/import sites); namespaces, exported symbols and
behavior unchanged.

* release: bump version to 0.0.54 + changelog (cli architecture refactor, #130)
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