Add platform-independent path/config resolution library
Implements core/paths (Config/Data/State/Cache/Runtime/Log/Bin
directory resolution with canonical-vs-search-dir separation, XDG on
Unix, native APPDATA/LOCALAPPDATA/PROGRAMDATA layering on Windows,
~/Library on macOS Desktop, injectable environment/platform for
deterministic cross-platform tests) and core/config (file search,
first-match resolution, layered YAML merging, safe ${VAR} expansion,
Explain/doctor introspection) on top of the shared Application/
Kind/Scope model in the core package.
This commit is contained in:
1 parent
027b327c3d
commit
13801bec11
41 files changed
+4834
-2
No files matched your search
@@ -0,0 +1,90 @@
|
||||
# TODO / open architecture questions
|
||||
|
||||
Deliberately not resolved in this V1 (see spec section 63 and AGENTS.md's
|
||||
"no over-abstraction" rule) -- tracked here rather than solved
|
||||
speculatively.
|
||||
|
||||
## Migration
|
||||
|
||||
- **Migrate `yet` onto `core/paths`/`core/config`.** `yet`'s
|
||||
`internal/store.Home()` (`$YETANO_HOME`, defaulting to
|
||||
`os.UserConfigDir()/yetano`) and `internal/config` (fixed
|
||||
`/etc/yetano/yetano.yaml` -> `~/.config/yetano/yetano.yaml` ->
|
||||
`./yetano.yaml` -> `--config` cascade) predate this library and
|
||||
overlap with what it now provides. Migrating is a deliberately
|
||||
separate follow-up, not part of this change -- `yet`'s existing
|
||||
behavior needs to be evaluated field-by-field (e.g. `$YETANO_HOME`'s
|
||||
default of `os.UserConfigDir()/yetano` is *not* the same location
|
||||
`core/paths` would resolve for an app named "yetano"/"yet"; that
|
||||
divergence needs a conscious decision, not a silent behavior change).
|
||||
- Once `yet` migrates, evaluate `yasta`, `yamocir`, `yaiam`, and
|
||||
`yalsh`-adjacent projects the same way (per the original task
|
||||
description) -- each on its own merits, not as a blanket sweep.
|
||||
|
||||
## Platform tuning
|
||||
|
||||
- FreeBSD's flavor (`freebsd.go`) is a best-effort first pass. Other BSD
|
||||
and Unix-family `GOOS` values (`openbsd`, `netbsd`, `dragonfly`,
|
||||
`solaris`, `illumos`, ...) currently fall back to the Linux flavor
|
||||
(`flavor()`'s default case) -- verified to compile and behave
|
||||
sensibly, not verified against each OS's actual convention. Adding a
|
||||
dedicated flavor table for one of them is a small, additive change
|
||||
(a new `<os>.go` file plus one `case` in `flavor()`), never a
|
||||
redesign.
|
||||
- macOS Desktop's `RuntimeDir()` (`~/Library/Application
|
||||
Support/<App>/Runtime`) is a placeholder -- macOS has no strong native
|
||||
convention for a GUI app's ephemeral runtime directory the way
|
||||
XDG_RUNTIME_DIR does on Linux. Revisit if a real Desktop consumer
|
||||
needs something more specific (e.g. a `TemporaryItems`-based
|
||||
location).
|
||||
- `LogAliasDir()` (spec section 39: `~/.local/log/<app>` as a Unix
|
||||
convenience symlink target) is resolved but never created -- no
|
||||
symlink-creation API exists yet. Decide whether this is worth adding
|
||||
before any consumer actually wants it.
|
||||
|
||||
## Windows
|
||||
|
||||
- **BinDir / installer strategy.** `paths.BinDir()` for Windows
|
||||
resolves `%LOCALAPPDATA%\Yetano\bin` (user) /
|
||||
`%PROGRAMDATA%\Yetano\bin` (system) as *locations*, per spec section
|
||||
19. Whether/how `yet` actually adds either to `PATH`, and how a
|
||||
package gets "activated" there (symlink vs. junction vs. copy/shim
|
||||
launcher, spec section 20) is explicitly out of scope for `core` --
|
||||
path resolution and package activation stay separate concerns (spec
|
||||
section 20's own instruction).
|
||||
- The native `SHGetKnownFolderPath` fallback in
|
||||
`knownfolders_windows.go` has only been verified to compile
|
||||
(`GOOS=windows go build`/`go vet`), never run on an actual Windows
|
||||
host. It is a secondary fallback below environment variables, so a
|
||||
latent bug there would only matter in the edge case where
|
||||
`APPDATA`/`LOCALAPPDATA`/`PROGRAMDATA` are all unset in the process
|
||||
environment on real Windows.
|
||||
|
||||
## Portability / distribution model
|
||||
|
||||
- `paths.WithRoot`/`YETANO_HOME`-style portable mode: `WithRoot` exists
|
||||
and is tested, but there is no ecosystem-wide "portable install"
|
||||
concept wired up yet (spec section 41's "optional later:
|
||||
`YETANO_HOME` or portable mode").
|
||||
- The future `yet` package store model (spec sections 2/37/38: package
|
||||
store vs. application data vs. config vs. state vs. cache vs. runtime
|
||||
vs. executables, as distinct concepts) is intentionally not
|
||||
implemented here -- `core/paths` only provides the primitives (scoped,
|
||||
prioritized directories) a future store implementation would sit on
|
||||
top of.
|
||||
- Plugin/extension search paths: no dedicated category exists yet;
|
||||
`paths.FindFile` is generic enough that a caller can build one today
|
||||
(e.g. over `DataSearchDirs()` with a `plugins/` suffix) without
|
||||
needing a new `PathKind`.
|
||||
- Atomic package activation, versioning/rollback for that future store:
|
||||
out of scope, same as above.
|
||||
|
||||
## Central Yetano config
|
||||
|
||||
- `config.WithYetanoDefaults(true)` resolves the shared
|
||||
`~/.config/yetano/` (or platform equivalent) via a pseudo-`Application
|
||||
{Name: "yetano", Kind: core.CLI}`. This is deliberately always
|
||||
CLI-shaped (XDG-flavored everywhere), even for a Desktop or Service
|
||||
caller, since it's a shared, admin/CLI-facing location -- revisit only
|
||||
if a real consumer needs the shared config to follow a different
|
||||
convention on macOS/Windows Desktop apps specifically.
|
||||
Reference in new issue
Block a user