Expand description
Package-root prompt asset addressing (issue #742).
Pipelines that move files around want stable, refactor-safe paths to
.harn.prompt assets. Source-relative ../../partials/foo.harn.prompt
paths break the moment a caller is renamed or relocated. This module
resolves a small URI scheme that anchors prompt assets at the
project root or a project-defined alias instead:
@/<rel>→ resolved from the calling module’s project root (the nearestharn.tomlancestor of the calling file, not the workspace cwd).@<alias>/<rel>→ resolved from a[asset_roots]entry in the project’sharn.toml, e.g.[asset_roots] partials = "...".
Plain (non-@) paths fall through to the caller’s existing
source-relative resolver — back-compat is exact.
Lives in harn-modules so the VM, the LSP, and the CLI’s preflight
checker can share one resolver and produce identical errors.
Enums§
- Asset
Ref - A parsed
@-prefixed asset reference.
Functions§
- find_
project_ root - Walk up from
baselooking for the nearest ancestor containingharn.toml. Mirrorsharn-vm’s in-VM walker so the resolver can run from the LSP/CLI without dragging in the VM crate. - is_
asset_ path - Returns true when
pathstarts with the@-asset prefix. - parse
- Parse an
@-prefixed path. ReturnsNonefor plain paths so callers can fall back to source-relative resolution. Malformed@-paths (e.g.@foowith no slash) also returnNone; the resolver wrapsNonecases into a parse-time error when the caller knows it has an@prefix. - resolve
- Resolve an
@-prefixed asset path to an absolute filesystem path. - resolve_
or - Convenience for the common case in
render_prompt(path, ...): resolve@-prefixed paths against the project root, otherwise apply the caller’s source-relative fallback.