Browse Source
G-033: an explicit `proj` package-mode token lets an installed (visitor) punkshell binary detect the punk project containing the cwd - walking up to the nearest VCS repo root, the marker punk::repo::is_project_root already uses - and set up source/dev library resolution against THAT project, so `punkshell proj shell` explores a project interactively even when the project builds no shell-capable binary (or no binary at all). History check recorded: cwd project-structure detection was never active in the boot modes (src/dev are exe-relative; os is shallow cwd-only), but the runtime detector find_project already exists and dev commands use it - so the marker question (VCS repo root, not punkproject.toml which tomlish lacks) is already answered; this aligns boot modes with it. Explicit token gates it per user decision (no silent rebind on cd); boot chicken-and-egg (find_project is in punk::repo, not loadable at the package-mode phase) handled by a lean inline VCS-root walk-up or post-boot deferral. Reuses the existing src-mode path machinery, parameterised on the detected root. Not gated on the module.templates/punk::cap plugin machinery. G-034: zip-based #modpod modules (e.g. punk::mix::templates) fail to mount in the shell subcommand's code interp on Tcl 8.6 - `dev module.templates` errors with `invalid command name vfs::RegisterMount` / no template providers - while the same call works via the script subcommand / main interp (reproduced 2026-07-07). The code interp lacks the vfs::zip library that supplies zip mounting for pre-zipfs Tcl. Tcl 9 (zipfs) unaffected. Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.commaster
2 changed files with 96 additions and 0 deletions
@ -0,0 +1,85 @@
|
||||
# G-033 `proj` package-mode: visitor binary detects the cwd's project and explores it |
||||
|
||||
Status: proposed |
||||
Scope: src/vfs/_config/punk_main.tcl (package-mode dispatch and boot-time root discovery), src/modules/punk/repo-999999.0a1.0.tm (find_project / is_project_root - reuse or lean boot mirror), bin/AGENTS.md (mode docs) |
||||
Acceptance: as in root GOALS.md index (canonical). |
||||
|
||||
## Context |
||||
|
||||
The earlier intent (recalled 2026-07-07): an installed punkshell binary sitting |
||||
in PATH - possibly a downloaded binary, not built from the project - should be |
||||
able to detect when the cwd is inside a punkshell project and set up the |
||||
appropriate source/dev library resolution for it, so the user can explore that |
||||
project interactively via the `shell` subcommand. The project being worked on |
||||
might not build a shell-capable binary, or might build no executable at all |
||||
(e.g. a modules-only project like a library). |
||||
|
||||
History check: this was **never active** in the full sense. `src` mode is new |
||||
(checkin 3d2d098d) and discovers the project root **exe-relative** (backtrack |
||||
from the executable's `bin/`) - it assumes the binary belongs to the project. |
||||
`dev` mode is likewise exe-relative. `os` mode is the only cwd-relative piece, |
||||
and only shallowly (adds `[pwd]` and cwd-relative `modules`/`modules_tcl<N>` |
||||
ad-hoc `.tm` sources - no walk-up, no `src/` structure). The comments in |
||||
punk_main.tcl name "the info nameofexecutable or info script or pwd relative |
||||
paths" as design axes, so the *intent* seeded `os` mode, but cwd project- |
||||
structure detection was never built into the boot modes. |
||||
|
||||
Crucially, the cwd-relative detector **already exists at the runtime layer**: |
||||
`punk::repo::find_project` walks up from cwd via `is_project_root`, and `dev` |
||||
commands (module.templates, module.new, ...) already use it. So the marker |
||||
question is answered: `is_project_root` defines a project as a **VCS repo root** |
||||
(git or fossil) that is not an excluded location - deliberately NOT relying on |
||||
`punkproject.toml` (its own comment notes that file also appears in layout |
||||
templates, and tomlish has no punkproject.toml yet but IS a fossil root). This |
||||
goal aligns the boot-time package modes with that existing runtime detection. |
||||
|
||||
## Approach |
||||
|
||||
- New explicit token `proj` in the package-mode list (dev/os/src/internal/proj). |
||||
Explicit gate = no `cd` silently rebinds a normal launch; the visitor |
||||
behaviour is opt-in. |
||||
- On `proj`: walk up from `[pwd]` to the nearest VCS repo root (the |
||||
`is_project_root` marker) and use that as the project root, then feed it into |
||||
the **existing src-mode path machinery** (which is already parameterised on a |
||||
root variable - adds src/modules, src/modules_tcl<N>, src/bootsupport/modules, |
||||
src/vendormodules to the tm path, src/lib to auto_path, registers #modpod |
||||
modules, sets package prefer latest). The only new part is cwd-relative |
||||
*discovery*; the setup is reused. |
||||
- Boot chicken-and-egg: `find_project`/`is_project_root` live in `punk::repo`, |
||||
which is not loadable at the early package-mode phase (punk_main.tcl avoids |
||||
package requires there by design). Options, decision to record: (a) a lean |
||||
inline VCS-root walk-up in punk_main mirroring is_project_root (fossil: |
||||
_FOSSIL_/.fslckout/.fos; git: .git) using only Tcl builtins; (b) defer proj |
||||
setup to a post-boot phase where punk::repo is available. (a) matches how the |
||||
src-mode #modpod scan already inlines logic at boot. |
||||
- Composition: decide `proj` + built-vs-source selectors. Natural default: |
||||
`proj` alone implies source-tree resolution (like src) against the detected |
||||
root; `proj-dev` selects built `modules/` output; document the matrix. |
||||
- No-project case: `proj` from a non-project cwd warns and proceeds as |
||||
`internal` - never a false rebind. |
||||
- Exe-relative `src`/`dev` for a binary that IS in a project bin/ stays |
||||
unchanged; `proj` is the visitor-binary path. |
||||
|
||||
## Alternatives considered |
||||
|
||||
- Automatic cwd-detection with no token - rejected (user decision 2026-07-07): |
||||
silently rebinding the module world on `cd` is surprising; an explicit `proj` |
||||
token is the safer gate. |
||||
- A dedicated project-marker file (punkproject.toml) as the sole signal - |
||||
rejected: not universal (tomlish lacks it; it also appears in layout |
||||
templates), and is_project_root already provides a VCS-root marker that works |
||||
today. |
||||
|
||||
## Notes |
||||
|
||||
- The related `dev` machinery (module.templates -> punk::mix::commandset::module |
||||
-> punk::cap `punk.templates` plugin handlers) uses find_project and has |
||||
unpolished plugin issues, plus an 8.6 shell-context zip-modpod-mount failure |
||||
(G-034). This goal deliberately does NOT gate on synchronising with that |
||||
machinery - it only reuses the find_project detection concept. |
||||
- Related: G-018 (the installable generic/plain binary this serves), G-031 |
||||
(boot core is where proj discovery belongs; the template project_main.tcl |
||||
lacks even src mode - fork drift), G-015 (`script` also benefits: a visitor |
||||
binary running `proj script` against a cwd project), G-027 (if a universal |
||||
project marker is ever seeded, proj could prefer it over the structural VCS |
||||
heuristic). |
||||
Loading…
Reference in new issue