Skip to content

init --no-mcp and EPERM diagnostics, fence-aware docs search, fixed-contract adapter recipe (#825, #826, #828) - #831

Merged
jimhoyd merged 6 commits into
mainfrom
claude/issues-825-828
Sep 27, 2026
Merged

jimhoyd merged 6 commits into
mainfrom
claude/issues-825-828

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

#825: init --no-mcp, and a clear diagnostic when a sandbox refuses a write

  • New flag: urlcode init <dir> --no-mcp skips .mcp.json, the only client configuration file init writes. bootstrap --create --no-mcp passes it through, with or without --adopt.
    • AGENTS.md is guidance and is still written.
    • An existing .mcp.json or .claude/ is left untouched.
    • JSON output reports "mcpRegistration":"skipped" with a note; it never claims MCP registration succeeded.
    • The default init is unchanged.
  • Refused writes: EPERM, EACCES and EROFS during init now give code init-write-denied, with a path relative to the destination and a limited message. For .mcp.json, the message suggests --no-mcp. It never recommends disabling a sandbox or changing permissions. EPERM and EROFS are added to both general error maps.
  • Rollback: only what this run created is removed. An in-place package.json is restored only if init actually rewrote it.
  • Packaging: starters/default/.mcp.json is removed, since init already renders it. That avoids EPERM warnings from npm install under protected agent-config paths. The package smoke test asserts the tarball contains no .mcp.json, and runs init --no-mcp followed by urlcode test.

#826: docs search ignores # inside fenced code

  • Headings: headingsOf() scans a document once, following CommonMark fence rules: ``` and ~~~ fences, matching length, info strings, and an unclosed fence runs to the end. sectionAt and the "opens a section" ranking both use it.
  • Unchanged elsewhere: 45 queries over the core docs give identical results.

#828: compatibility audit and the fixed-contract-adapter recipe (owner decision: option a)

  • Why a function route can't be the adapter: project function routes can't be the adapter. Guest code never receives the session cookie or the principal while extensions are active, and a proxy back to the site refuses cookies.
  • What the adapter is: a small private operator extension (defineExtension, requires: [auth, store]) that uses only AuthExports and StoreExports, with auth: true on its mounts. It lives in the recipe README next to host.mjs, and the tests run that README code.
  • Owned by auth and store, never re-implemented: passwords, sessions, CSRF, origin, cookies and ownership.
  • The audit in the README, with code citations, sets out what's safe and what's deliberately unsupported:
    • Safe:
    • Unsupported, or the client adapts:
      • POST /api/login and /api/logout at contract paths;
      • skipping CSRF or origin checks;
      • an app envelope on auth's 401 and 403;
      • bearer sessions;
      • cross-owner listing;
      • custom password hashing;
      • DELETE through the contract path.
  • Tests: a 50-step cookie-jar lifecycle plus 17 fixtures. urlcode audit --expect-routes 5 reports ready. The native headless-auth-profile contract still passes on the same auth service.
  • Registered: in the recipe list, plan-feature ("existing API contract login /api/login" ranks it first), RECIPES, AI-AUTHORING, llms, the auth JSON-API doc and the skill.

Verification

  • npm run verify exits 0.

    • Core: 1084 pass.
    • Workspaces: abuse 41, audit 42, mail 34, mcp 49, ui 103, forms 58, store 86, auth 271, form-records 23, admin 49, all with 0 failures.
    • test:addons: 4/4.
  • npm run test:package exits 0: "39 packaged example commands ran from consumer copies; Packed installation and starter/cookbook checks passed".

  • New tests:

    • test/init-no-mcp.test.ts (8). EPERM is injected through a preloaded fs stub rather than chmod, so it should also work on Windows.
    • Three tests in test/docs-search.test.ts.
    • packages/auth/test/fixed-contract-adapter-recipe.test.ts (4).
    • A plan-feature ranking test.
  • Core package budget, set from the merged measurement:

    Old budget New budget Measured
    Packed 844 KiB 860 KiB 876609 bytes
    Unpacked 3330 KiB 3395 KiB 3468112 bytes
    Entries 493

    All other packages are within budget; auth is at 248008 of 250 KiB packed.

Limitations

Closes #825
Closes #826
Closes #828

🤖 Generated with Claude Code

jimhoyd and others added 6 commits September 27, 2026 18:26
…ions (#826)

Docs search found headings with a multiline regex over the whole document,
so a shell or YAML comment in a fenced code block (the store README's
'# or, in an existing site:') became the reported section and could pull
the excerpt toward it. headingsOf now scans each document once, tracking
CommonMark backtick/tilde fences (same character, at least as long, blank
after to close; unclosed runs to the end), and both sectionAt and the
'opens a section' ranking in focus use that list. Headings stay column-0
ATX only, so indented code blocks cannot hold one. Output for the core
documents is unchanged (45 queries, 124 results compared against main).

Refs #826

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…p.json (#825)

- `urlcode init --no-mcp` and `urlcode bootstrap --create --no-mcp` (alone or
  with --adopt, and with init --with) create the same runnable site without
  .mcp.json, the only client configuration init writes (AGENTS.md is guidance,
  .github/ is CI). Existing .mcp.json and .claude/ are left untouched. Output
  and the bootstrap packet report mcpRegistration: skipped with a note; the
  default init still writes .mcp.json and its output is unchanged.
- A write the OS or a sandbox refuses (EPERM, EACCES, EROFS) during init is a
  ConfigError with code init-write-denied naming the operation and the
  destination-relative path; for .mcp.json it points at --no-mcp, otherwise at
  a writable destination. It never suggests changing permissions or disabling
  a sandbox. Both system error maps gain fixed EPERM and EROFS sentences.
- Rollback removes only what the run created; an in-place package.json is
  restored only if init actually rewrote it, so a refused run leaves it
  byte- and mtime-identical.
- starters/default/.mcp.json is deleted (init already renders it), so the
  package ships no client configuration; package-smoke asserts that and
  exercises init --no-mcp on the installed CLI.
- Docs: TOOLING, STARTERS, AI-AUTHORING, llms.txt, CONTRIBUTING, CLI help.

Refs #825, #542, #807, #814, #581

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Per the owner decision on #828 (option a): a compatibility audit plus a
tested recipe, with no new runtime capability, no generic response
rewriting and no new extension package.

recipes/fixed-contract-adapter serves a typical fixed JSON contract through
a thin operator module (api-contract.mjs, carried in the README, registered
in host.mjs after auth and store). It reads the signed-in account through
AuthExports.account() and keeps owner-scoped items through
StoreExports.records(), projecting to {email, role} and {id, title, done}
and mapping store and body refusals to a fixed {error: {code, message}}
envelope; site.errors (#821) gives runtime errors under /api the same
envelope. It never reads a cookie, checks a password or token, starts or
ends a session, or compares owners, and refuses to activate on a contract
route without auth's principal-providing policy, on a shared collection or
with an undeclared field.

The README's compatibility audit lists what is safe over the public APIs
and what the client must change: sign-in and sign-out at contract paths
(AuthExports has neither; AuthService.login would skip auth's CSRF, backoff,
device and cookie handling), CSRF/origin skipping, header-borne sessions,
the contract body on auth's 401/403 (never rewritten), cross-owner access,
custom password hashing, and delete (StoreExports v1 has no delete; the
native store mount deletes).

packages/auth/test/fixed-contract-adapter-recipe.test.ts runs the README
module against the real extensions: the lifecycle and every error mapping,
activation refusals, the fixtures twice, headless-auth-profile's fixtures
on the same auth database, and urlcode test/audit through --host-file
(audit ready, 5 routes). Catalog, planner terms, RECIPES, AI-AUTHORING,
EXTENSIONS, llms, the auth JSON contract page and the authoring skill link
the recipe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rement

Measured on the merged branch (Node 26): 876609 packed, 3468112 unpacked,
493 entries. Budgets: 860 KiB packed, 3395 KiB unpacked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 27, 2026 23:47
@jimhoyd
jimhoyd merged commit 6752ad0 into main Sep 27, 2026
32 checks passed
@jimhoyd
jimhoyd deleted the claude/issues-825-828 branch September 27, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant