Skip to content

feat(cli): add nano package init for a pinned example scaffold (#84) - #95

Merged
AetherAI3 merged 4 commits into
mainfrom
claude/nano84-package-init
Nov 8, 2026
Merged

AetherAI3 merged 4 commits into
mainfrom
claude/nano84-package-init

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

Optional follow-up slice named in #84: nano package init --directory PATH. It creates one minimal, already-pinned example package, only in a new or empty destination, so a user can run check, build and test right away. The contract was frozen in docs/package-cli.md (commit 1883bb5) before any code.

What changed

  • nano/cli/package_init.py (new): a fixed template of five LF files: agent.nano, rules.nano (one pure helper), nano.json, nano.lock, cases.json (one positive and one negative case). Lock pins come from the template bytes in memory. Nothing existing is read, discovered, repinned or rewritten.
  • Refusals before any write: a non-empty directory, an existing file, or a symlink/junction exits 2. A missing parent exits 3 (no parent creation or search).
  • No partial scaffold. A new destination is staged in a temporary sibling and renamed into place. An empty destination gets exclusive (xb) creates, and anything already created is removed if a later write fails.
  • nano/cli/package.py: dispatch and parser entry only. main.py epilog, RFC 0066 (fmt remains deferred).

Evidence (base main 27e8a5f8d502f2c25cfa2b899de62871a63edc86, head 2f9767f3194f7ce3b08fbbdf89ae4a6daf5992e5)

  • RED: tests/test_package_init.py 10 failed / 1 passed (the pass is the trivial missing-argument exit 2), then GREEN at 11/11 on the first implementation. Negative controls:

    • non-empty dir, existing file, symlink (run, not skipped);
    • existing stale project: bytes and mtimes unchanged, exit 2;
    • missing parent: exit 3, nothing created;
    • injected ENOSPC on the 3rd write, in both new-dir and empty-dir modes: nothing left behind.
  • Byte-identical scaffolds across runs and from another working directory (relative --directory). check, build and test --json accept the scaffold, and its two cases produce different intents (EXECUTE vs PAUSE).

  • Focused + adjacent suite (init, package_cli, package_cases, package_test_cli, cli, package, compiler_diagnostics, conformance, acceptance_parity, examples, docs):

    Python Passed Failed Skipped
    3.13.5 459 1 1
    3.12.10 459 1 1

    The failure is the pre-existing py≥3.12 test_metadata_depth_is_positioned, which fix(package): enforce metadata depth before JSON decoding #94 fixes; I'll rebase after it lands. check_contribution --all: 55 ready.

  • Held-out: wheel sha256 9c3d549d…443a, installed --no-deps --no-index into a fresh Python 3.10.0 venv (no quantum extras), run outside the repo:

    • init exits 0, and a repeat init into the same directory exits 2;
    • check packageHash is sha256:16bfedd0…2b66, identical to the in-repo scaffold;
    • test is 2/2;
    • all five files contain zero CR bytes.

Merge plan: merge only on green CI for the exact head on the self-hosted runner, after rebasing onto #94. The repo owner authorized merging this PR in-session.

Refs #84, #67

🤖 Generated with Claude Code

@AetherAI3
AetherAI3 force-pushed the claude/nano84-package-init branch 2 times, most recently from bd8f428 to 55240f4 Compare November 8, 2026 03:11
AetherAI3 and others added 4 commits November 7, 2026 23:24
Specifies init --directory before any implementation: new or empty
destination only, refuse overwrite and symlinks with exit 2, no parent
creation or search, fixed LF template whose pins are computed from the
template bytes, atomic placement, and a scaffold that check/build/test
accept.

Refs #84, #67

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Writes one fixed five-file package (entry, one pure helper module,
manifest, lock, cases) only into a destination that does not exist or is
an empty directory. Non-empty directories, files and symlinks/junctions
are refused with exit 2 before any write; a missing parent is exit 3.
Pins are computed from the template bytes in memory, never by reading or
rewriting an existing project. New destinations are staged in a temporary
sibling and renamed into place; empty destinations get exclusive creates
with removal on failure, so a failed init leaves no partial scaffold.

Refs #84, #67

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review findings on nano package init:
- a file opened and partly written before a failure was left behind;
  _write_new_file now removes its own file on any write failure;
- an OSError from the destination check (e.g. unreadable directory)
  escaped as a traceback; it is now an I/O diagnostic, exit 3;
- the destination is re-checked before every file, so a swap to a link
  mid-write is refused (exit 3) instead of writing through it; the
  remaining local race is documented;
- a staging directory that cleanup cannot remove is reported on stderr;
- tests now cover open-then-fail and a real Windows junction.

Refs #84

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI (self-hosted, py3.11) caught test_nothing_in_nano_imports_dynamically
flagging getattr(stat, ...). Use the documented Win32
FILE_ATTRIBUTE_REPARSE_POINT literal instead; behaviour is unchanged.

Refs #84

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AetherAI3
AetherAI3 force-pushed the claude/nano84-package-init branch from 55240f4 to 80593f3 Compare November 8, 2026 04:26
@AetherAI3
AetherAI3 merged commit 4307f4b into main Nov 8, 2026
7 of 9 checks passed
@AetherAI3
AetherAI3 deleted the claude/nano84-package-init branch November 8, 2026 19:03
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