@runeditrun/rer 0.2.121 → 0.2.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/cli/README.md +124 -5
  2. package/cli/archive.mjs +1 -1
  3. package/cli/authoring.mjs +1 -1
  4. package/cli/browser-runtime.mjs +2 -2
  5. package/cli/business/agent-help.mjs +11 -11
  6. package/cli/business/agent-verbs.mjs +9 -8
  7. package/cli/business/api.mjs +11 -7
  8. package/cli/business/carry.mjs +4 -3
  9. package/cli/business/choices.mjs +1 -1
  10. package/cli/business/command.mjs +33 -11
  11. package/cli/business/connect.mjs +4 -4
  12. package/cli/business/credential-file.mjs +102 -0
  13. package/cli/business/errors.mjs +5 -2
  14. package/cli/business/invocation.mjs +7 -4
  15. package/cli/business/keychain.mjs +6 -2
  16. package/cli/business/local-commands.mjs +9 -3
  17. package/cli/business/mcp-bridge.mjs +2 -1
  18. package/cli/business/questions.mjs +1 -1
  19. package/cli/business/run-child.mjs +5 -5
  20. package/cli/business/run-grant.mjs +27 -8
  21. package/cli/business/run-mask.mjs +8 -1
  22. package/cli/business/scan-command.mjs +1 -1
  23. package/cli/business/service.mjs +4 -2
  24. package/cli/business/state.mjs +2 -2
  25. package/cli/checkout-folders.mjs +1 -1
  26. package/cli/checkout-preparation.mjs +4 -4
  27. package/cli/command-guidance.mjs +9 -0
  28. package/cli/companion/command.mjs +4 -3
  29. package/cli/companion/providers/sandbox.mjs +1 -1
  30. package/cli/companion/setup.mjs +4 -4
  31. package/cli/contract.mjs +8 -8
  32. package/cli/demo.mjs +1 -1
  33. package/cli/deploy-command.mjs +10 -5
  34. package/cli/deploy-hook.mjs +3 -2
  35. package/cli/deploy-inputs.mjs +7 -3
  36. package/cli/deploy-owner-input.mjs +2 -2
  37. package/cli/deploy-source.mjs +1 -1
  38. package/cli/deploy.mjs +4 -2
  39. package/cli/deployment-record.mjs +1 -1
  40. package/cli/dev-identity.mjs +4 -4
  41. package/cli/door-clauses.mjs +2 -2
  42. package/cli/door-mode.mjs +7 -7
  43. package/cli/door.mjs +7 -7
  44. package/cli/errors.mjs +15 -1
  45. package/cli/export-summary.mjs +1 -1
  46. package/cli/export.mjs +1 -1
  47. package/cli/hosted-export.mjs +1 -1
  48. package/cli/hosted-output.mjs +2 -2
  49. package/cli/human-error.mjs +8 -2
  50. package/cli/hydration/browser.mjs +1 -1
  51. package/cli/hydration/check.mjs +1 -1
  52. package/cli/import-summary.mjs +2 -2
  53. package/cli/inspect.mjs +3 -3
  54. package/cli/lifecycle.mjs +9 -9
  55. package/cli/listen.mjs +1 -1
  56. package/cli/listing.mjs +1 -1
  57. package/cli/local-env.mjs +1 -1
  58. package/cli/local.mjs +4 -4
  59. package/cli/managed-server.mjs +36 -13
  60. package/cli/output.mjs +2 -1
  61. package/cli/owner-entry-ready.mjs +92 -0
  62. package/cli/parse.mjs +8 -8
  63. package/cli/port.mjs +3 -3
  64. package/cli/portability-runtime.mjs +16 -0
  65. package/cli/portability.mjs +4 -4
  66. package/cli/production-auth.mjs +4 -2
  67. package/cli/production-mail.mjs +1 -1
  68. package/cli/project.mjs +2 -0
  69. package/cli/rehearse/options.mjs +3 -3
  70. package/cli/release-candidate.mjs +2 -2
  71. package/cli/release.mjs +5 -5
  72. package/cli/server-registry.mjs +3 -3
  73. package/cli/server-resources.mjs +1 -1
  74. package/cli/setup-input.mjs +6 -6
  75. package/cli/signin.mjs +11 -10
  76. package/cli/site-render.mjs +1 -1
  77. package/cli/size/schema.mjs +1 -1
  78. package/cli/size/verify-step.mjs +1 -1
  79. package/cli/transfers.mjs +4 -4
  80. package/edition-authoring/api-source.mjs +121 -0
  81. package/edition-authoring/archive-source.mjs +1 -86
  82. package/edition-authoring/base-copies.mjs +5 -3
  83. package/global/CHANGELOG.md +31 -0
  84. package/global/cli/command.mjs +6 -5
  85. package/global/cli/install.mjs +6 -3
  86. package/global/cli/path-link.mjs +11 -22
  87. package/global/cli/repo-command.mjs +4 -3
  88. package/global/cli/repository-contract.mjs +3 -3
  89. package/global/door/command.mjs +39 -38
  90. package/global/door/control.mjs +3 -3
  91. package/global/door/pages.mjs +6 -5
  92. package/global/door/server.mjs +8 -5
  93. package/global/door/sites.mjs +14 -13
  94. package/global/launch/capacity.mjs +2 -2
  95. package/global/launch/dev.mjs +6 -6
  96. package/global/launch/door.mjs +1 -1
  97. package/global/launch/facts.mjs +2 -2
  98. package/global/launch/failure.mjs +1 -1
  99. package/global/launch/prepare.mjs +3 -3
  100. package/global/launch/render.mjs +3 -2
  101. package/global/launch/worker.mjs +1 -1
  102. package/global/list.mjs +4 -4
  103. package/global/main.mjs +32 -31
  104. package/global/registry.mjs +1 -1
  105. package/global/run.mjs +4 -4
  106. package/global/update/command.mjs +5 -5
  107. package/global/update/notice.mjs +1 -1
  108. package/global/version.mjs +1 -1
  109. package/install.sh +17 -4
  110. package/modules/deploy-kit/README.md +10 -3
  111. package/modules/deploy-kit/asset-health.mjs +6 -4
  112. package/modules/deploy-kit/cancellation.mjs +26 -0
  113. package/modules/deploy-kit/d1-import-diagnostics.mjs +3 -2
  114. package/modules/deploy-kit/deploy.mjs +8 -3
  115. package/modules/deploy-kit/diagnostics.mjs +11 -4
  116. package/modules/deploy-kit/health-request.mjs +16 -9
  117. package/modules/deploy-kit/health.mjs +14 -11
  118. package/modules/deploy-kit/owner-cli.mjs +49 -21
  119. package/modules/deploy-kit/owner-remove.mjs +7 -6
  120. package/modules/deploy-kit/owner-secret.mjs +7 -4
  121. package/modules/deploy-kit/owner.mjs +46 -28
  122. package/modules/deploy-kit/provider-transport.mjs +2 -0
  123. package/modules/deploy-kit/provider.mjs +10 -9
  124. package/modules/deploy-kit/readiness-window.mjs +5 -3
  125. package/modules/deploy-kit/site.mjs +1 -1
  126. package/modules/deploy-kit/teardown.mjs +5 -4
  127. package/modules/operator-auth/dev/index.mjs +4 -3
  128. package/modules/operator-auth/dev/sign-in-as.mjs +2 -1
  129. package/modules/operator-auth/dev-gate.mjs +3 -2
  130. package/modules/operator-auth/routes.mjs +2 -1
  131. package/modules/operator-auth/terminal-guidance.mjs +3 -0
  132. package/onboarding/adapter-settings.mjs +1 -0
  133. package/onboarding/adapter.mjs +3 -3
  134. package/onboarding/agent-handoff.mjs +1 -1
  135. package/onboarding/busy.mjs +1 -1
  136. package/onboarding/launcher.mjs +1 -1
  137. package/onboarding/local/environment.mjs +1 -1
  138. package/onboarding/local/operation.mjs +12 -4
  139. package/onboarding/local/owner.mjs +2 -2
  140. package/onboarding/operator-installer.mjs +4 -3
  141. package/onboarding/operator-migrations.mjs +1 -1
  142. package/onboarding/operator-prerequisites.mjs +26 -14
  143. package/onboarding/operator-settings.mjs +28 -0
  144. package/onboarding/process-diagnostics.mjs +2 -2
  145. package/onboarding/project-vite.mjs +1 -1
  146. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import {resolve} from 'node:path';
2
2
  import {invalid} from '../errors.mjs';
3
3
 
4
- export const rehearseHelp = `Usage: rer rehearse [--cwd DIR] [--ref REF] [--json] [FLAGS]
4
+ export const rehearseHelp = `Usage: ~/.local/bin/rer rehearse [--cwd DIR] [--ref REF] [--json] [FLAGS]
5
5
 
6
6
  Rehearse the first managed build in a fresh two-commit copy, outside this checkout.
7
7
  Runs every declared setup, build, verify and artifact operation, in that order,
@@ -27,7 +27,7 @@ Operations are trusted seed code and can install packages and contact the networ
27
27
  This is a local build rehearsal; it does not attest, upload or deploy an artifact.
28
28
 
29
29
  Heavy work: signers and seed lanes must run through .tools/heavy-slot.py:
30
- python3 -I /path/to/.tools/heavy-slot.py --remote auto -- rer rehearse --cwd SEED
30
+ python3 -I /path/to/.tools/heavy-slot.py --remote auto -- ~/.local/bin/rer rehearse --cwd SEED
31
31
  Use a clean committed worktree when routing remotely; the selected source must be local
32
32
  on that runner. Only declared operations may acquire dependencies over the network.
33
33
  `;
@@ -46,7 +46,7 @@ export function rehearseOptions(args) {
46
46
  if (!/^[1-9][0-9]*$/.test(value) || !Number.isSafeInteger(Number(value)) || Number(value)>86400) throw invalid(`${flag} takes integer seconds from 1 to 86400.`);
47
47
  options[key]=Number(value);
48
48
  } else options[key]=value;
49
- } else throw invalid(`Unsupported rehearsal flag ${flag}. Run rer rehearse --help.`);
49
+ } else throw invalid(`Unsupported rehearsal flag ${flag}. Run ~/.local/bin/rer rehearse --help.`);
50
50
  }
51
51
  options.cwd=resolve(options.cwd);
52
52
  if (options.ref.startsWith('-')) throw invalid('--ref must name a Git commit or reference.');
@@ -1,7 +1,7 @@
1
1
  import {resolve} from 'node:path';
2
2
  import {prepareCandidate} from '../modules/release/candidate.mjs';
3
3
 
4
- export const candidateHelp = `Usage: rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
4
+ export const candidateHelp = `Usage: ~/.local/bin/rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
5
5
 
6
6
  Prepare stage-only version metadata in one local commit on the caller's checkout.
7
7
  Updates only version in seed.json, package.json and RELEASE.json; requires a clean
@@ -24,7 +24,7 @@ export async function candidateCommand(args) {
24
24
  if (seen.has(flag)) throw Error(`Repeated candidate flag ${flag}.`); seen.add(flag);
25
25
  if (flag==='--help') {console.log(candidateHelp);return 0;}
26
26
  if (flag==='--json' || flag==='--non-interactive') continue;
27
- if (!['--cwd','--tag'].includes(flag) || !args[index+1]?.trim() || args[index+1].startsWith('--')) throw Error('Use rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json].');
27
+ if (!['--cwd','--tag'].includes(flag) || !args[index+1]?.trim() || args[index+1].startsWith('--')) throw Error('Use ~/.local/bin/rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json].');
28
28
  const value=args[++index]; if(flag==='--cwd')cwd=resolve(value);else tag=value;
29
29
  }
30
30
  console.log(JSON.stringify(prepareCandidate(cwd, tag), null, 2));return 0;
package/cli/release.mjs CHANGED
@@ -2,7 +2,7 @@ import { releaseVerb } from './contract.mjs';
2
2
  import { parseTimeoutSeconds, timeoutBounds } from '../scripts/publish-check/timeout.mjs';
3
3
 
4
4
  // Preserve release's accepted parser, producer, receipt and validation exits.
5
- const releaseHelp = `Usage: rer release --repo DIR --project OWNER/NAME --repository GITHUB_URL --output NEW_DIR [FLAGS]
5
+ const releaseHelp = `Usage: ~/.local/bin/rer release --repo DIR --project OWNER/NAME --repository GITHUB_URL --output NEW_DIR [FLAGS]
6
6
 
7
7
  Produce local artifacts using the exact source commit's green GitHub Verify,
8
8
  frozen installation, local build and publication checks.
@@ -39,12 +39,12 @@ Without --tag, write a preview. This command never pushes, uploads or deploys.
39
39
  --help Print this help without performing release work.
40
40
 
41
41
  Stage-only metadata preparation:
42
- rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
42
+ ~/.local/bin/rer release candidate --tag vVERSION-PRERELEASE [--cwd DIR] [--json]
43
43
 
44
44
  Signing and receipt commands:
45
- rer release sign --artifact DIR (--key-file FILE | --key-stdin) [--scope test|rer] [--publisher NAMESPACE]
46
- rer release receipt --artifact DIR --anchors FILE [--environment test] [--after VERSION:SHA256]
47
- rer release keygen --scope test|rer --publisher NAMESPACE --github-owner LOGIN --github-owner-id ID --anchor-out FILE
45
+ ~/.local/bin/rer release sign --artifact DIR (--key-file FILE | --key-stdin) [--scope test|rer] [--publisher NAMESPACE]
46
+ ~/.local/bin/rer release receipt --artifact DIR --anchors FILE [--environment test] [--after VERSION:SHA256]
47
+ ~/.local/bin/rer release keygen --scope test|rer --publisher NAMESPACE --github-owner LOGIN --github-owner-id ID --anchor-out FILE
48
48
  [--not-before YYYY-MM-DDTHH:MM:SSZ] [--not-after YYYY-MM-DDTHH:MM:SSZ]
49
49
  [--unsigned-through PROJECT:VERSION ...]
50
50
 
@@ -17,7 +17,7 @@ export function positive(value, name, fallback) {
17
17
  if(!/^[1-9][0-9]*$/.test(String(value)) || !Number.isSafeInteger(Number(value)))throw invalid(`${name} must be positive integer seconds/count.`);
18
18
  return Number(value);
19
19
  }
20
- export const stopInstruction = record => `rer ${record.mode} --cwd ${JSON.stringify(record.checkout)} --stop`;
20
+ export const stopInstruction = record => `~/.local/bin/rer ${record.mode} --cwd ${JSON.stringify(record.checkout)} --stop`;
21
21
  // Plain-words listing of one running server for the limit refusal.
22
22
  const listing = record => ` ${record.mode} on port ${record.port ?? '(starting)'} in ${record.checkout}\n stop it with: ${stopInstruction(record)}`;
23
23
  export const description = record => `${record.mode} ${record.url ?? '(starting)'} for ${record.checkout}; stop it with: ${stopInstruction(record)}`;
@@ -56,7 +56,7 @@ function memoryMessage(counted,available,floor,mode) {
56
56
  const gib=bytes=>(bytes/1024**3).toFixed(1);
57
57
  const head=`Not started: this computer is short of memory. ${gib(available)} GiB is available and a new server starts only at ${gib(floor)} GiB or more.`;
58
58
  const list=counted.length?`Running now:\n${counted.map(listing).join('\n')}\nA dev server holds about 0.5-1.3 GiB and a preview 0.4-0.8 GiB; stopping one with its command above frees that.`:'No dev or preview server is running, so something else is using the memory.';
59
- return `${head}\n${list}\nTo start anyway, lower the floor, for example RER_SERVERS_MIN_MEMORY_BYTES=${Math.floor(floor/2)} rer ${mode} (0 turns it off).`;
59
+ return `${head}\n${list}\nTo start anyway, lower the floor, for example RER_SERVERS_MIN_MEMORY_BYTES=${Math.floor(floor/2)} ~/.local/bin/rer ${mode} (0 turns it off).`;
60
60
  }
61
61
  function limitMessage(counted,cap,explicit,mode,file) {
62
62
  const holders=explicit?[]:counted.filter(item=>item.explicit&&item.limit===cap);
@@ -67,7 +67,7 @@ function limitMessage(counted,cap,explicit,mode,file) {
67
67
  :holders.length
68
68
  ?`The limit is ${cap} because ${holders.length===1?'a server was':'servers were'} started with RER_SERVER_LIMIT=${cap} (${holders.map(item=>item.checkout).join(', ')}). Stop ${holders.length===1?'it':'them'} and start again, or start everything with a higher RER_SERVER_LIMIT=N.`
69
69
  :explicit?`This start set RER_SERVER_LIMIT=${cap}; to allow more, start it with a higher RER_SERVER_LIMIT=N.`
70
- :`To allow more, start this one with a higher limit, for example RER_SERVER_LIMIT=${cap*2} rer ${mode}. Servers started without RER_SERVER_LIMIT allow ${defaultServerLimit}.`;
70
+ :`To allow more, start this one with a higher limit, for example RER_SERVER_LIMIT=${cap*2} ~/.local/bin/rer ${mode}. Servers started without RER_SERVER_LIMIT allow ${defaultServerLimit}.`;
71
71
  return `${head}\n${list}\nTo make room, stop one with its command above. ${raise}`;
72
72
  }
73
73
  // A server is only ever stopped by the checkout that owns it, through its own
@@ -51,7 +51,7 @@ export async function serverResources(root,{load=()=>loadavg()[0],disk=statfs,en
51
51
  // Validate explicit values before doing any measurements.
52
52
  let floor=serversDiskFloor(env);
53
53
  const measured=threshold===Infinity?0:await load();
54
- if(!Number.isFinite(measured)||measured>threshold)throw refuse(`Not started: this computer is busy. Its 1-minute load is ${Number.isFinite(measured)?measured.toFixed(1):'unknown'} and a server starts only at ${threshold} or below.\nTry again in a few minutes, or start it anyway with a higher threshold, for example RER_SERVERS_LOAD_THRESHOLD=${Math.ceil(Math.max(threshold,Number.isFinite(measured)?measured:0)*2)} rer dev.`);
54
+ if(!Number.isFinite(measured)||measured>threshold)throw refuse(`Not started: this computer is busy. Its 1-minute load is ${Number.isFinite(measured)?measured.toFixed(1):'unknown'} and a server starts only at ${threshold} or below.\nTry again in a few minutes, or start it anyway with a higher threshold, for example RER_SERVERS_LOAD_THRESHOLD=${Math.ceil(Math.max(threshold,Number.isFinite(measured)?measured:0)*2)} ~/.local/bin/rer dev.`);
55
55
  if(env.RER_SERVERS_DISK_FLOOR_GIB===undefined)floor=serversDiskFloor(env,await seedDiskBytes(root));
56
56
  const temporary=resolve(env.TMPDIR||env.TMP||env.TEMP||tmpdir());
57
57
  for(const path of new Set([resolve(root),temporary,serversDirectory(env)])){
@@ -81,7 +81,7 @@ export async function setupInput(project, options, vars, signal, { origin } = {}
81
81
  shape[key]=privateValue?'<private value>':choices?.[0]??'<value>';
82
82
  return `${key} (${type}${choices?`; choices: ${choices.map(value=>JSON.stringify(value)).join(' | ')}`:''})`;
83
83
  });
84
- throw missing(`Missing or invalid active setup fields: ${details.join(', ')}. Create an owner-only JSON file (chmod 600 answers.json) shaped ${JSON.stringify(shape)}, then run rer setup --answers answers.json --non-interactive. --owner-email EMAIL and --owner-name NAME are also accepted when declared; use manifest field names inside the JSON, never an environment-file wrapper.`);
84
+ throw missing(`Missing or invalid active setup fields: ${details.join(', ')}. Create an owner-only JSON file (chmod 600 answers.json) shaped ${JSON.stringify(shape)}, then run ~/.local/bin/rer setup --answers answers.json --non-interactive. --owner-email EMAIL and --owner-name NAME are also accepted when declared; use manifest field names inside the JSON, never an environment-file wrapper.`);
85
85
  }
86
86
  if(!mailbox(answers[names.email]))throw invalid('Provide a valid plain owner mailbox.');
87
87
  answers[names.email]=answers[names.email].toLowerCase();
@@ -89,13 +89,13 @@ export async function setupInput(project, options, vars, signal, { origin } = {}
89
89
  const {owners,placeholder}=await assertLocalOwner(project.root,answers[names.email],message=>refuse(message),project.adapter.hooks?.localOwner,`${names.email} in ${project.adapter.hooks?.secrets?.file??'.dev.vars'}`);
90
90
  // The zero-setup owner gives way to the real one; lifecycle renames it in place.
91
91
  if(placeholder&&placeholder.toLowerCase()!==answers[names.email])project.ownerReplacement={from:placeholder,to:answers[names.email]};
92
- if(savedEmail&&!mailbox(savedEmail))throw refuse('Saved owner is malformed. Restore private settings or run rer reset --yes.');
92
+ if(savedEmail&&!mailbox(savedEmail))throw refuse('Saved owner is malformed. Restore private settings or run ~/.local/bin/rer reset --yes.');
93
93
  if(savedEmail&&savedEmail.toLowerCase()!==answers[names.email]&&(owners.length?!placeholder:savedEmail.toLowerCase()!==zeroSetupOwner(await realpath(project.root)))){
94
- if(owners.length)throw refuse(`Private setting ${names.email} differs from the retained database owner. Restore ${names.email} in ${project.adapter.hooks?.secrets?.file??'.dev.vars'} to ${answers[names.email]}, then run rer setup --owner-email ${answers[names.email]}; or back up data and run rer reset --yes. Private bytes were kept.`);
95
- throw refuse(`Owner conflicts with the saved installation (${savedEmail}). Run rer setup --owner-email ${savedEmail}, or back up data, run rer dev --stop, then rer reset --yes followed by rer setup --owner-email ${answers[names.email]}. Reset deletes local data.`);
94
+ if(owners.length)throw refuse(`Private setting ${names.email} differs from the retained database owner. Restore ${names.email} in ${project.adapter.hooks?.secrets?.file??'.dev.vars'} to ${answers[names.email]}, then run ~/.local/bin/rer setup --owner-email ${answers[names.email]}; or back up data and run ~/.local/bin/rer reset --yes. Private bytes were kept.`);
95
+ throw refuse(`Owner conflicts with the saved installation (${savedEmail}). Run ~/.local/bin/rer setup --owner-email ${savedEmail}, or back up data, run ~/.local/bin/rer dev --stop, then ~/.local/bin/rer reset --yes followed by ~/.local/bin/rer setup --owner-email ${answers[names.email]}. Reset deletes local data.`);
96
96
  }
97
97
 
98
- try{return seed.model.validateInput(answers,known);}catch{throw missing('Installer answers are incomplete. Supply the active manifest fields using rer setup --answers answers.json --non-interactive.');}
98
+ try{return seed.model.validateInput(answers,known);}catch{throw missing('Installer answers are incomplete. Supply the active manifest fields using ~/.local/bin/rer setup --answers answers.json --non-interactive.');}
99
99
  }
100
100
 
101
101
  async function question(label,privateValue,signal){
@@ -103,7 +103,7 @@ async function question(label,privateValue,signal){
103
103
  const output=new Writable({write(chunk,_encoding,done){if(!muted)process.stderr.write(chunk);done();}});
104
104
  const prompt=createInterface({input:process.stdin,output,terminal:true});
105
105
  prompt.on('SIGINT',()=>process.kill(process.pid,'SIGINT'));
106
- const closed=new Promise((_,reject)=>prompt.once('close',()=>reject(missing('Terminal input closed before setup answers were complete. Use rer setup --answers answers.json --non-interactive.'))));
106
+ const closed=new Promise((_,reject)=>prompt.once('close',()=>reject(missing('Terminal input closed before setup answers were complete. Use ~/.local/bin/rer setup --answers answers.json --non-interactive.'))));
107
107
  try{const pending=prompt.question(label+'\n',{signal});muted=privateValue;return await Promise.race([pending,closed]);}finally{prompt.close();muted=false;output.end();if(privateValue)process.stderr.write('\n');}
108
108
  }
109
109
 
package/cli/signin.mjs CHANGED
@@ -5,7 +5,7 @@ import { invalid, missing, refuse, RerError } from './errors.mjs';
5
5
  import { shared } from './shared.mjs';
6
6
  import { settingKinds } from './deploy-settings.mjs';
7
7
  import { main as owner } from '../modules/deploy-kit/owner-cli.mjs';
8
- import { deployDiagnostic, providerRefusal } from '../modules/deploy-kit/diagnostics.mjs';
8
+ import { deployDiagnostic, providerRefusal, ownerTargetFailure } from '../modules/deploy-kit/diagnostics.mjs';
9
9
 
10
10
  // rer signin: the owner's way into a hosted install without mail. With the same
11
11
  // Cloudflare credentials that deployed it, rer writes a one-time grant (only its
@@ -13,12 +13,12 @@ import { deployDiagnostic, providerRefusal } from '../modules/deploy-kit/diagnos
13
13
  // It never reaches a log, receipt or the deploy record; the Worker admits it only
14
14
  // for the recorded owner, once, within 15 minutes, and logs its use.
15
15
  export async function signinCommand(project, options, out, { fetch } = {}) {
16
- if (project.profile !== 'first-party' || typeof project.adapter?.deploy !== 'function') throw refuse('rer signin needs a seed with an owner-account deploy declaration.');
17
- const root = project.root, environment = options.environment ?? 'production', again = deployAgain(options).replace(/^rer deploy/, 'rer signin');
16
+ if (project.profile !== 'first-party' || typeof project.adapter?.deploy !== 'function') throw refuse('~/.local/bin/rer signin needs a seed with an owner-account deploy declaration.');
17
+ const root = project.root, environment = options.environment ?? 'production', again = deployAgain(options).replace('~/.local/bin/rer deploy', '~/.local/bin/rer signin');
18
18
  const { path, value: declaration } = await declarationFor(root, project.adapter);
19
19
  const state = await deploymentRecord(root, { ...options, verb: 'signin' });
20
20
  const { env } = await deployEnvironment({ root, options, declaration, localOnlyKeys: project.adapter.localOnlyKeys ?? [] });
21
- if (['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN'].some(name => !env[name]?.trim())) throw missing('rer signin uses the Cloudflare credentials that deployed this environment: set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment or an --env-file, then run it again.');
21
+ if (['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN'].some(name => !env[name]?.trim())) throw missing('~/.local/bin/rer signin uses the Cloudflare credentials that deployed this environment: set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment or an --env-file, then run it again.');
22
22
  const { createRedaction } = await shared('redaction.mjs');
23
23
  const redaction = createRedaction();
24
24
  redaction.addSecrets([...(await settingKinds({ declaration, setupManifest: project.setupManifest })).privateValues(env), env.CLOUDFLARE_ACCOUNT_ID]);
@@ -31,17 +31,18 @@ export async function signinCommand(project, options, out, { fetch } = {}) {
31
31
  }
32
32
 
33
33
  function failure(error, { environment, again, adapter, redact }) {
34
+ if (ownerTargetFailure(error)) return refuse(redact(ownerTargetFailure(error)));
34
35
  const code = deployDiagnostic(error, redact)?.code ?? error.message;
35
- if (code === 'missing-owner-receipt') return refuse(`This checkout has no completed rer deployment of the ${environment} environment. Run rer signin from the checkout that deployed it (rer deploy --environment ${environment}).`);
36
- if (code === 'owned-resource-replaced') return refuse(`The ${environment} Worker is no longer the one this checkout deployed, so rer will not sign anyone in to it. Run rer deploy --environment ${environment} first.`);
36
+ if (code === 'missing-owner-receipt') return refuse(`This checkout has no completed rer deployment of the ${environment} environment. Run ~/.local/bin/rer signin from the checkout that deployed it (~/.local/bin/rer deploy --environment ${environment}).`);
37
+ if (code === 'owned-resource-replaced') return refuse(`The ${environment} Worker is no longer the one this checkout deployed, so rer will not sign anyone in to it. Run ~/.local/bin/rer deploy --environment ${environment} first.`);
37
38
  if (code === 'owner-signin-unsupported') {
38
39
  const path = adapter.signInPath;
39
- if (path !== undefined && (typeof path !== 'string' || path.length > 2048 || !path.startsWith('/') || path.startsWith('//') || /[\\\s\u0000-\u001f\u007f-\u009f]/u.test(path))) return invalid('The adapter signInPath must be a same-origin browser path such as /login. Correct the seed declaration, then run rer signin again.');
40
+ if (path !== undefined && (typeof path !== 'string' || path.length > 2048 || !path.startsWith('/') || path.startsWith('//') || /[\\\s\u0000-\u001f\u007f-\u009f]/u.test(path))) return invalid('The adapter signInPath must be a same-origin browser path such as /login. Correct the seed declaration, then run ~/.local/bin/rer signin again.');
40
41
  const destination = new URL(path ?? '/setup', error.origin).href;
41
- return refuse(redact(`The ${environment} deployment signs owners in through the seed's own sign-in flow. ${path ? `Open ${destination} to sign in.` : `Open ${destination} for the seed's owner recovery.`} rer signin cannot issue a link for this seed.`));
42
+ return refuse(redact(`The ${environment} deployment signs owners in through the seed's own sign-in flow. ${path ? `Open ${destination} to sign in.` : `Open ${destination} for the seed's owner recovery.`} ~/.local/bin/rer signin cannot issue a link for this seed.`));
42
43
  }
43
44
  if (code === 'owner-signin-ambiguous') return refuse(`More than one D1 database of the ${environment} deployment holds an owner sign-in table, so rer cannot tell which one signs in the owner. Nothing was written.`);
44
- if (code === 'owner-not-claimed') return refuse(`No owner has claimed the ${environment} deployment yet. Run rer deploy --environment ${environment}: it claims the owner. Nothing was written.`);
45
+ if (code === 'owner-not-claimed') return refuse(`No owner has claimed the ${environment} deployment yet. Run ~/.local/bin/rer deploy --environment ${environment}: it claims the owner. Nothing was written.`);
45
46
  const refusal = providerRefusal(error, redact);
46
- return new RerError('command_failed', `rer signin failed: ${/^[a-zA-Z0-9_-]{1,120}$/.test(code) ? redact(code) : 'signin-failed'}${refusal ? ` (${refusal})` : ''}. No sign-in link was issued; run ${again} again.`, 1);
47
+ return new RerError('command_failed', `~/.local/bin/rer signin failed: ${/^[a-zA-Z0-9_-]{1,120}$/.test(code) ? redact(code) : 'signin-failed'}${refusal ? ` (${refusal})` : ''}. No sign-in link was issued; run ${again} again.`, 1);
47
48
  }
@@ -35,7 +35,7 @@ const ASSETS = 'site-assets';
35
35
 
36
36
  let vite;
37
37
  try { vite = await import(pathToFileURL(createRequire(join(root, 'package.json')).resolve('vite')).href); }
38
- catch { fail('The run site renders with the checkout\'s own Vite. Run rer install first.'); }
38
+ catch { fail('The run site renders with the checkout\'s own Vite. Run ~/.local/bin/rer install first.'); }
39
39
  process.env.NODE_ENV ??= 'production';
40
40
 
41
41
  let contract;
@@ -42,7 +42,7 @@ export async function schemasFromBuild(root, { wrangler = defaultBuild.wrangler
42
42
  const file = join(root, wrangler), build = dirname(file);
43
43
  let config;
44
44
  try { config = JSON.parse(await readFile(file, 'utf8')); }
45
- catch { throw missing(`No production build at ${wrangler}. Run rer build, or point --migrations at a directory of D1 migrations.`); }
45
+ catch { throw missing(`No production build at ${wrangler}. Run ~/.local/bin/rer build, or point --migrations at a directory of D1 migrations.`); }
46
46
  const schemas = [];
47
47
  for (const item of config.d1_databases ?? []) {
48
48
  const directory = resolve(build, item.migrations_dir ?? 'migrations');
@@ -14,7 +14,7 @@ function failureText({ statements, size = {}, flows = [] }) {
14
14
  for (const name of ['small', 'large']) if (size[name]?.error) parts.push(`the ${name} size did not build: ${size[name].error}`);
15
15
  const failing = flows.filter(flow => !flow.ok);
16
16
  if (failing.length) parts.push(`${failing.length} of ${flows.length} declared flows fail: ${join(failing.map(flow => `${flow.name} (${[...new Set(flow.failures.map(failure => failure.rule))].join(', ')})`))}`);
17
- return `Size check failed: ${parts.join('; ')}. Run rer size for the full report.`;
17
+ return `Size check failed: ${parts.join('; ')}. Run ~/.local/bin/rer size for the full report.`;
18
18
  }
19
19
 
20
20
  /**
package/cli/transfers.mjs CHANGED
@@ -24,7 +24,7 @@ export async function transfer(project, options, signal, custody) {
24
24
  if (error.code === 'safety_refusal' && error.message === 'Path must be a contained checkout path without traversal.') {
25
25
  const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
26
26
  const staged = value => `.rer/recovery/${basename(value.replaceAll('\\', '/'))}`;
27
- const args = ['rer import', '--input', quote(flag === '--input' ? staged(options.input) : options.input), ...(options.journal ? ['--journal', quote(staged(options.journal))] : []), '--yes', '--cwd', quote(project.root)];
27
+ const args = ['~/.local/bin/rer import', '--input', quote(flag === '--input' ? staged(options.input) : options.input), ...(options.journal ? ['--journal', quote(staged(options.journal))] : []), '--yes', '--cwd', quote(project.root)];
28
28
  error.humanMessage = `${flag} ${JSON.stringify(options[flag.slice(2)])} must stay inside this checkout, without .. or an absolute path, for example .rer/recovery/<name>.rer. Stage the archives there as owned private files (0600), then run: ${args.join(' ')}`;
29
29
  }
30
30
  throw error;
@@ -47,8 +47,8 @@ export async function transfer(project, options, signal, custody) {
47
47
  // The archive's size, for the line a finished export ends with.
48
48
  if(direction==='export')return {...result,target,...(target==='remote'&&options.origin?{origin:new URL(options.origin).origin}:{}),output:result.output??relative(project.root,path),bytes:(await stat(path)).size,captureLog:relative(project.root,custody.store.logPath)};
49
49
  if(direction==='import' && target==='local' && (await localDependencyLinks(project.root)).some(link=>link.needs_relink)) {
50
- custody.store.report('Imported provider links need fresh approval. Run rer setup with RER_LINK_TOKEN_FILE to re-link this installation.');
51
- return {...result,needsRelink:true,nextCommand:'rer setup'};
50
+ custody.store.report('Imported provider links need fresh approval. Run ~/.local/bin/rer setup with RER_LINK_TOKEN_FILE to re-link this installation.');
51
+ return {...result,needsRelink:true,nextCommand:'~/.local/bin/rer setup'};
52
52
  }
53
- return direction === 'import' ? { ...result, captureLog: relative(project.root, custody.store.logPath), nextCommand: 'rer setup' } : result;
53
+ return direction === 'import' ? { ...result, captureLog: relative(project.root, custody.store.logPath), nextCommand: '~/.local/bin/rer setup' } : result;
54
54
  }
@@ -0,0 +1,121 @@
1
+ // --from-api retains its snapshot semantics, but acquires immutable Git objects
2
+ // in packs over HTTPS. This spends no GitHub REST core allowance.
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import crypto from 'node:crypto';
7
+ import {execFileSync} from 'node:child_process';
8
+ import {hash, safe} from './files.mjs';
9
+ import {offlineRepository} from './offline-git.mjs';
10
+
11
+ const limit = 64 * 1024 * 1024, commit = /^[a-f0-9]{40}$/;
12
+ const objectId = bytes => crypto.createHash('sha1').update(`blob ${bytes.length}\0`).update(bytes).digest('hex');
13
+
14
+ export function apiReader(repository, revision) {
15
+ if (!commit.test(revision)) throw Error('Base API requires an immutable full 40-character commit');
16
+ if (!/^[\w.-]+\/[\w.-]+$/.test(repository)) throw Error('--from-api requires a GitHub Base repository');
17
+ const remote = `https://github.com/${repository}.git`;
18
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'base-api-'));
19
+ const env = Object.fromEntries(Object.entries(process.env).filter(([name]) =>
20
+ !/^GIT_(?:DIR|COMMON_DIR|WORK_TREE|INDEX_FILE|OBJECT_DIRECTORY|ALTERNATE_OBJECT_DIRECTORIES|SHALLOW_FILE|NAMESPACE|QUARANTINE_PATH|REPLACE_REF_BASE)$/.test(name)));
21
+ Object.assign(env, {GIT_NO_REPLACE_OBJECTS: '1', GIT_TERMINAL_PROMPT: '0', GIT_NO_LAZY_FETCH: '1'});
22
+ let local;
23
+ const close = () => { local?.close(); fs.rmSync(directory, {recursive: true, force: true}); };
24
+ const run = (args, input, localOnly = false) => {
25
+ try {
26
+ if (localOnly) local ??= offlineRepository(directory);
27
+ const repository = localOnly ? {root: local.root, env: local.env} : {root: directory, env};
28
+ return execFileSync('git', ['-C', repository.root, '-c', `core.hooksPath=${os.devNull}`, ...args], {
29
+ env: repository.env, input, stdio: ['pipe', 'pipe', 'pipe'], timeout: 60_000, maxBuffer: limit,
30
+ });
31
+ } catch (error) {
32
+ // Identify the exact failed request without echoing transport diagnostics,
33
+ // credential helpers or authenticated URLs from Git's stderr.
34
+ if (args.includes('fetch')) throw Error(`Cannot acquire Base ${revision}: git ${args.join(' ')}${input ? ` (stdin: ${input.trim().split('\n').join(' ')})` : ''} failed; no files were refreshed or copy record changed.`);
35
+ if (error.code === 'ENOBUFS') throw Error('Base API source output exceeds the 64 MiB acquisition limit');
36
+ throw Error(`Cannot read Base ${revision}: git ${args.join(' ')} failed; no files were refreshed or copy record changed.`);
37
+ }
38
+ };
39
+ const available = new Set(), trees = new Map(), objects = new Map(), ancestry = new Map();
40
+ const ensure = pin => {
41
+ if (!commit.test(pin)) throw Error('Base API requires an immutable full 40-character commit');
42
+ if (available.has(pin)) return;
43
+ let resolved;
44
+ try { resolved = run(['rev-parse', '--verify', `${pin}^{commit}`]).toString().trim(); } catch { /* Acquire only a missing immutable tip. */ }
45
+ if (resolved !== pin) {
46
+ // Full ancestry and trees arrive together. Blob probes use a separate
47
+ // object-store view without remotes: older Git ignores GIT_NO_LAZY_FETCH.
48
+ // Required blobs are acquired explicitly in packs below.
49
+ run(['-c', 'fetch.fsckObjects=true', 'fetch', '--filter=blob:none', '--no-tags', '--no-recurse-submodules', '--', remote, pin]);
50
+ if (run(['rev-parse', '--verify', `${pin}^{commit}`]).toString().trim() !== pin) throw Error('Base did not resolve the immutable commit');
51
+ }
52
+ if (!local) fs.writeFileSync(path.join(directory, 'HEAD'), pin + '\n');
53
+ available.add(pin);
54
+ };
55
+ try { run(['init', '--bare', '--quiet', '--template=', '--object-format=sha1']); }
56
+ catch (error) { close(); throw error; }
57
+ return {
58
+ close,
59
+ historyAvailable: false,
60
+ objectId,
61
+ tree(pin) {
62
+ ensure(pin);
63
+ if (!trees.has(pin)) {
64
+ const entries = new Map();
65
+ for (const line of run(['ls-tree', '-rz', '--full-tree', pin]).toString('utf8').split('\0').filter(Boolean)) {
66
+ const tab = line.indexOf('\t'), [mode, type, object] = line.slice(0, tab).split(' '), name = line.slice(tab + 1);
67
+ safe(name);
68
+ if (!commit.test(object)) throw Error('Invalid Base Git tree entry');
69
+ if (type === 'blob' && ['100644', '100755'].includes(mode)) entries.set(name, {object, mode});
70
+ }
71
+ trees.set(pin, new Map([...entries].sort(([a], [b]) => Buffer.compare(Buffer.from(a), Buffer.from(b)))));
72
+ }
73
+ return trees.get(pin);
74
+ },
75
+ blobs(ids) {
76
+ const unique = [...new Set(ids)], missing = unique.filter(id => !objects.has(id));
77
+ if (unique.some(id => !commit.test(id))) throw Error('Invalid Base API blob identity');
78
+ if (missing.length) {
79
+ const absent = run(['cat-file', '--batch-check'], missing.join('\n') + '\n', true).toString().trim().split('\n')
80
+ .filter(line => line.endsWith(' missing')).map(line => line.split(' ')[0]);
81
+ if (absent.length) run(['-c', 'fetch.fsckObjects=true', 'fetch', '--no-tags', '--no-recurse-submodules', '--stdin', '--', remote], absent.join('\n') + '\n');
82
+ }
83
+ for (let i = 0; i < missing.length; i += 100) {
84
+ const chunk = missing.slice(i, i + 100), output = run(['cat-file', '--batch'], chunk.join('\n') + '\n', true);
85
+ let offset = 0;
86
+ for (const object of chunk) {
87
+ const newline = output.indexOf(10, offset), [identity, type, size] = output.subarray(offset, newline).toString().split(' ');
88
+ const bytes = Buffer.from(output.subarray(newline + 1, newline + 1 + Number(size)));
89
+ if (identity !== object || type !== 'blob' || bytes.length !== Number(size) || objectId(bytes) !== object) throw Error('Base API blob integrity mismatch');
90
+ objects.set(object, bytes);
91
+ offset = newline + 1 + bytes.length + 1;
92
+ }
93
+ }
94
+ const result = new Map();
95
+ let size = 0;
96
+ for (const object of unique) {
97
+ const bytes = objects.get(object);
98
+ size += bytes.length;
99
+ if (size > limit) throw Error('Base API source output exceeds the 64 MiB acquisition limit');
100
+ result.set(object, bytes);
101
+ }
102
+ return result;
103
+ },
104
+ digests(ids) { return new Map([...this.blobs(ids)].map(([object, bytes]) => [object, hash(bytes)])); },
105
+ contains(pin, introduced) {
106
+ ensure(pin); ensure(introduced);
107
+ const key = introduced + '...' + pin;
108
+ if (!ancestry.has(key)) {
109
+ // rev-list handles disconnected histories as a valid negative proof;
110
+ // missing or corrupt objects still fail explicitly.
111
+ const absent = run(['rev-list', '--max-count=1', introduced, '--not', pin]).length;
112
+ ancestry.set(key, absent === 0);
113
+ }
114
+ return ancestry.get(key);
115
+ },
116
+ history(pin, name) {
117
+ const entry = this.tree(pin).get(safe(name));
118
+ return entry ? [{revision: pin, ...entry}] : [];
119
+ },
120
+ };
121
+ }
@@ -1,96 +1,11 @@
1
- // Directory archives supply one snapshot. GitHub can also prove ancestry and
2
- // supply older immutable trees without requiring a local Git object store.
1
+ // Directory archives supply one immutable snapshot without Git history.
3
2
  import fs from 'node:fs';
4
3
  import path from 'node:path';
5
4
  import crypto from 'node:crypto';
6
- import {execFileSync} from 'node:child_process';
7
5
  import {hash, safe} from './files.mjs';
8
6
 
9
7
  const limit = 64 * 1024 * 1024;
10
8
  const objectId = bytes => crypto.createHash('sha1').update(`blob ${bytes.length}\0`).update(bytes).digest('hex');
11
- const commit = /^[a-f0-9]{40}$/;
12
-
13
- export function apiReader(repository, revision) {
14
- if (!commit.test(revision)) throw Error('Base API requires an immutable full 40-character commit');
15
- const request = endpoint => {
16
- try {
17
- return JSON.parse(execFileSync('gh', ['api', `repos/${repository}/${endpoint}`], {
18
- encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 60_000, maxBuffer: limit,
19
- }));
20
- } catch (error) {
21
- // Keep provider failures explicit without echoing arbitrary gh stderr,
22
- // authentication diagnostics or credential-bearing transport URLs.
23
- const status = /\bHTTP (\d{3})\b/.exec(error.stderr?.toString() ?? '')?.[1];
24
- throw Error(`Cannot read Base ${revision} from the GitHub API${status ? ` (HTTP ${status})` : ''} (${endpoint}); no files were refreshed or copy record changed.`);
25
- }
26
- };
27
- const trees = new Map(), objects = new Map(), ancestry = new Map();
28
- return {
29
- // Workflow-template discovery remains snapshot-only; no path history is
30
- // invented from the API tree or the archive's version.
31
- historyAvailable: false,
32
- objectId,
33
- tree(pin) {
34
- if (!commit.test(pin)) throw Error('Base API requires an immutable full 40-character commit');
35
- if (!trees.has(pin)) {
36
- const pinned = request(`git/commits/${pin}`);
37
- if (pinned.sha !== pin || !commit.test(pinned.tree?.sha)) throw Error('Base API did not resolve the immutable commit');
38
- const entries = new Map();
39
- const walk = (identity, prefix = '', recursive = true) => {
40
- const tree = request(`git/trees/${identity}${recursive ? '?recursive=1' : ''}`);
41
- if (recursive && tree.sha === identity && tree.truncated === true) return walk(identity, prefix, false);
42
- if (tree.sha !== identity || tree.truncated !== false || !Array.isArray(tree.tree)) throw Error('Incomplete Base API tree');
43
- for (const entry of tree.tree) {
44
- safe(entry.path);
45
- if ((!recursive && entry.path.includes('/')) || !commit.test(entry.sha)) throw Error('Invalid Base API tree entry');
46
- const name = prefix + entry.path;
47
- if (!recursive && entry.type === 'tree' && entry.mode === '040000') walk(entry.sha, name + '/');
48
- else if (entry.type === 'blob' && ['100644', '100755'].includes(entry.mode)) entries.set(name, {object: entry.sha, mode: entry.mode});
49
- }
50
- };
51
- walk(pinned.tree.sha);
52
- trees.set(pin, new Map([...entries].sort(([a], [b]) => Buffer.compare(Buffer.from(a), Buffer.from(b)))));
53
- }
54
- return trees.get(pin);
55
- },
56
- blobs(ids) {
57
- const result = new Map();
58
- let size = 0;
59
- for (const object of new Set(ids)) {
60
- if (!commit.test(object)) throw Error('Invalid Base API blob identity');
61
- if (!objects.has(object)) {
62
- const blob = request(`git/blobs/${object}`);
63
- if (blob.sha !== object || blob.encoding !== 'base64' || typeof blob.content !== 'string') throw Error('Invalid Base API blob');
64
- const bytes = Buffer.from(blob.content, 'base64');
65
- if (blob.size !== bytes.length || objectId(bytes) !== object) throw Error('Base API blob integrity mismatch');
66
- objects.set(object, bytes);
67
- }
68
- const bytes = objects.get(object);
69
- size += bytes.length;
70
- if (size > limit) throw Error('Base API source output exceeds the 64 MiB acquisition limit');
71
- result.set(object, bytes);
72
- }
73
- return result;
74
- },
75
- digests(ids) { return new Map([...this.blobs(ids)].map(([object, bytes]) => [object, hash(bytes)])); },
76
- contains(pin, introduced) {
77
- if (!commit.test(pin) || !commit.test(introduced)) throw Error('Base API ancestry requires immutable full commits');
78
- const key = introduced + '...' + pin;
79
- if (!ancestry.has(key)) {
80
- const comparison = request(`compare/${key}?per_page=1`);
81
- if (comparison.base_commit?.sha !== introduced || !commit.test(comparison.merge_base_commit?.sha) ||
82
- !['ahead', 'identical', 'behind', 'diverged'].includes(comparison.status)) throw Error('Invalid Base API ancestry comparison');
83
- if (['ahead', 'identical'].includes(comparison.status) && comparison.merge_base_commit.sha !== introduced) throw Error('Invalid Base API ancestry proof');
84
- ancestry.set(key, ['ahead', 'identical'].includes(comparison.status));
85
- }
86
- return ancestry.get(key);
87
- },
88
- history(pin, name) {
89
- const entry = this.tree(pin).get(safe(name));
90
- return entry ? [{revision: pin, ...entry}] : [];
91
- },
92
- };
93
- }
94
9
 
95
10
  export function archiveReader(directory, revision) {
96
11
  if (!/^[a-f0-9]{40}$/.test(revision)) throw Error('A Base archive requires its immutable full 40-character Base commit in --ref');
@@ -17,7 +17,8 @@ import {requireMaterializedCopies, preflightRefresh} from './copy-checkout.mjs';
17
17
  import {completeModuleCopies} from './module-closure.mjs';
18
18
  import {editionMigrations} from './edition-migrations.mjs';
19
19
  import {adoptWorkflowTemplates, completeWorkflowHelpers} from './workflow-copies.mjs';
20
- import {archiveReader, apiReader} from './archive-source.mjs';
20
+ import {archiveReader} from './archive-source.mjs';
21
+ import {apiReader} from './api-source.mjs';
21
22
 
22
23
  export const RECORD = 'base-copies.json';
23
24
  const commit = /^[a-f0-9]{40}$/, sha256 = /^[a-f0-9]{64}$/;
@@ -101,12 +102,13 @@ export function options(args, count) {
101
102
  return result;
102
103
  }
103
104
 
104
- // Share the authenticated immutable API reader for recording and refreshing.
105
+ // Share immutable GitHub acquisition for recording and refreshing.
105
106
  function apiSource(record, root, revision) {
106
107
  const declared = record.repository ?? baseRepository(root);
107
108
  const repository = /^(?:https:\/\/github\.com\/)?([\w.-]+\/[\w.-]+?)(?:\.git)?$/.exec(declared)?.[1];
108
109
  if (!repository) throw Error('--from-api requires a GitHub Base repository');
109
- return {read: apiReader(repository, revision), head: revision, close() {}};
110
+ const read = apiReader(repository, revision);
111
+ return {read, head: revision, close: read.close};
110
112
  }
111
113
 
112
114
  export function validate(record) {
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.122
4
+
5
+ Signed: Run Edit Run fleet, 2026-11-17.
6
+
7
+ ### Owner entry and local prerequisites
8
+
9
+ - Managed dev, preview and demo verify the declared owner entry through its public origin before announcing `RER_READY`, `RER_OPEN` or JSON readiness. The headless browser follows the entry exchange and redirects to a same-origin 2xx destination with visible rendered content, including read-only owner pages. Busy, loading and refresh interstitials do not qualify. Native single-use entries are checked before issuing a fresh link for the owner; startup visits stay attached to the server already starting.
10
+ - Readiness failures name the destination status and unmet exchange, navigation or content conditions without printing credential fragments or query values. `rer dev` names the failed local prerequisite, its safe found/expected values and the setup command, including missing migrations, owner state and local authentication/mail settings.
11
+ - Setup and the local installer repair stored hosted mail choices to local `MAIL_PROVIDER=development` before build isolation, suppressing local mail while keeping stored installer choices separate. Fresh local answers that request a hosted mail provider are refused with repair guidance.
12
+
13
+ ### Commands in a new terminal
14
+
15
+ - Printed restart, stop and recovery commands use `~/.local/bin/rer`, including direct CLI, browser and adapter sign-in guidance, so the command works before PATH is configured.
16
+ - `rer cli path` prints the shell command to add `~/.local/bin` to PATH. For zsh and bash, executing that command adds the exact PATH line to `~/.zshrc` or `~/.bashrc` only if absent and updates the current terminal. The installer prints this step and new-terminal guidance; it does not edit shell files itself. Fish receives `fish_add_path`; other shells receive a current-terminal export.
17
+
18
+ ### Granted deployments and recovery
19
+
20
+ - Business command grants report the scoped credential's expiry and distinguish an expiry stop from the child's result. A refused exchange can print Business's gap sentence, pending state and permission-catalogue counts while keeping other response fields private. Sealed launchers can select `RER_BUSINESS_CREDENTIAL_DIR` for owned 0700 directory/0600 file storage instead of OS credential storage, with device credentials masked in command and agent output.
21
+ - Deploy recovery follows the recorded Worker name, including native uploaders with a custom prefix, and refuses mismatched account/project/environment or provider identity. A dead writer's lock can be recovered; live writers stay protected. An authenticated matching interrupted upload completes without creating another code version; partial asset uploads restart in a new session. Unconfirmed resource creates retain their ownership uncertainty.
22
+ - An ambient Cloudflare token cannot be replaced by provider keys from `--env-file`. Cancellation reaches provider requests, response reads, health waits and owned Git processes, preserves deploy state and releases the lock. Resume uses the same checkout, account and environment under a fresh grant.
23
+
24
+ ### Source refresh, archives and test isolation
25
+
26
+ - `rer refresh-base --from-api` acquires immutable Git objects in packs over HTTPS without spending GitHub REST core allowance, retaining full-commit selection and snapshot semantics.
27
+ - Installation archive adapters use the selected CLI's portability runtime even when the checkout pins another rer. Failed export/import commands retain their redacted capture-log path. The archive format and identity are unchanged.
28
+ - CLI fixtures scope their test ports and journey processes to each run and keep fixture ownership separate from top-level CLI context.
29
+
30
+ ChargeDesk checkouts pin rer 0.2.118 (and other seeds have older pins) and need a re-pin to receive deploy-kit, export and PATH fixes.
31
+
32
+ These changes require adoption through the seed's pinned package or refreshed source. This preparation establishes no seed adoption, provider delivery, deployment or production result. The source range changes no import-kit or portability module, product migration or archive format identity.
33
+
3
34
  ## 0.2.121
4
35
 
5
36
  Signed: Run Edit Run fleet, 2026-11-16.
@@ -1,17 +1,18 @@
1
+ import { withCommandHelp } from '../../cli/command-guidance.mjs';
1
2
  // rer cli status|install|uninstall
2
- const usage = 'Usage: rer cli status [--json] | rer cli install | rer cli uninstall | rer cli path\n';
3
+ const usage = 'Usage: ~/.local/bin/rer cli status [--json] | ~/.local/bin/rer cli install | ~/.local/bin/rer cli uninstall | ~/.local/bin/rer cli path\n';
3
4
 
4
5
  export async function cliCommand(args) {
5
6
  const [action, ...flags] = args;
6
- if (!action || ['--help', '-h'].includes(action)) { process.stdout.write(usage); return 0; }
7
+ if (!action || ['--help', '-h'].includes(action)) { process.stdout.write(withCommandHelp(usage) + '\n'); return 0; }
7
8
  const allowed = action === 'status' ? ['--json'] : [];
8
9
  const unknown = flags.find(flag => !allowed.includes(flag));
9
- if (!['status', 'install', 'uninstall', 'path'].includes(action) || unknown !== undefined) { process.stderr.write(`Unsupported: rer cli ${args.join(' ')}\n${usage}`); return 2; }
10
+ if (!['status', 'install', 'uninstall', 'path'].includes(action) || unknown !== undefined) { process.stderr.write(withCommandHelp(`Unsupported: ~/.local/bin/rer cli ${args.join(' ')}\n${usage}`) + '\n'); return 2; }
10
11
  if (action === 'status') return (await import('./status.mjs')).status({ json: flags.includes('--json') });
11
12
  if (action === 'path') {
12
- const { pathAdvice } = await import('./path-link.mjs');
13
+ const { shellStartup } = await import('./path-link.mjs');
13
14
  const { layout } = await import('./layout.mjs');
14
- process.stdout.write((await pathAdvice(layout()) || 'rer is available in this terminal and future terminals.') + '\n');
15
+ process.stdout.write((await shellStartup(layout().home)).line + '\n');
15
16
  return 0;
16
17
  }
17
18
  if (action === 'install') return (await import('./install.mjs')).install();
@@ -7,6 +7,7 @@ import { basename, join, resolve } from 'node:path';
7
7
  import { ownManifest, ownRoot, packageDigest, packageFileList } from '../package-info.mjs';
8
8
  import { installRecord, launcherOwner, launcherScript, layout } from './layout.mjs';
9
9
  import { pathAdvice } from './path-link.mjs';
10
+ import { commandNotFoundHelp } from '../../cli/command-guidance.mjs';
10
11
  import { runningDoor } from '../../cli/door.mjs';
11
12
  import { channelOf } from './status.mjs';
12
13
 
@@ -41,10 +42,12 @@ async function writeLauncher(paths) {
41
42
  }
42
43
 
43
44
  // The absolute launcher works immediately, without editing shell files.
44
- const shellQuote = value => "'" + value.replaceAll("'", "'\"'\"'") + "'";
45
45
  async function closing(paths) {
46
46
  const notices = await pathAdvice(paths, process.env, { includeShellStep: false });
47
- return (notices ? notices + '\n' : '') + (process.env.RER_INSTALL_NO_NEXT ? '' : `Run a downloaded JavaScript tool with the installed runtime: ${shellQuote(paths.launcher)} run --script ./tool.mjs [ARGS...]\nNext, start an app: ${shellQuote(paths.launcher)} dev <owner>/<repo>\n`);
47
+ if (process.env.RER_INSTALL_NO_NEXT) return notices ? notices + '\n' : '';
48
+ const advice = await pathAdvice(paths);
49
+ const terminal = !advice && ['zsh', 'bash'].includes(basename(process.env.SHELL ?? '')) ? 'Open a new Terminal window, then `rer` works by name.\n' : '';
50
+ return `Run a downloaded JavaScript tool with the installed runtime: ~/.local/bin/rer run --script ./tool.mjs [ARGS...]\nNext, start an app: ~/.local/bin/rer dev <owner>/<repo>\n${commandNotFoundHelp}\n${advice ? advice + '\n' : terminal}`;
48
51
  }
49
52
 
50
53
  export async function install({ quiet = false } = {}) {
@@ -53,7 +56,7 @@ export async function install({ quiet = false } = {}) {
53
56
  const channel = (process.env.RER_INSTALL_CHANNEL ?? (await channelOf(paths)).channel) === 'script' ? 'script' : 'npx';
54
57
  const launcher = await launcherOwner(paths.launcher);
55
58
  if (launcher.state === 'foreign') {
56
- process.stderr.write(`rer cli install: ${paths.launcher} already exists and was not written by rer cli install (it may be the unrelated npm package "rer"). Nothing was changed. Remove or rename it, then run the install again.\n`);
59
+ process.stderr.write(`~/.local/bin/rer cli install: ${paths.launcher} already exists and was not written by ~/.local/bin/rer cli install (it may be the unrelated npm package "rer"). Nothing was changed. Remove or rename it, then run the install again.\n`);
57
60
  return 4;
58
61
  }
59
62
  const record = await installRecord(paths), current = await readLink(paths.current);