turnzero 0.21.4 → 0.21.5

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.
@@ -917,7 +917,10 @@ var variableReadSentence = (origin, standing) => {
917
917
  };
918
918
  var fileReadSentence = (origin) => `The credential this run read was this computer's token for ${origin}, from its credential file: where the platform no longer accepts it, run ${LOGIN_SUBCOMMAND}${originWordsOf(origin)} to authorize this computer again.`;
919
919
  var noTokenSentence = (origin, expiredAt) => expiredAt === null ? `No credential was read, so nothing was sent: ${MINTED_TOKEN_VARIABLE} is not set, and this computer's credential file holds no token for ${origin}.` : `No credential was read, so nothing was sent: ${MINTED_TOKEN_VARIABLE} is not set, and this computer's token for ${origin} in its credential file expired at ${expiredAt}.`;
920
- var VARIABLE_ROUTE_SENTENCES = `A tool connected by a minted token, or a job, sets ${MINTED_TOKEN_VARIABLE} from where its token is kept, never by writing the value in a line, and ${ORIGIN_VARIABLE} to the address that minted the token where that is not ${DEFAULT_COMMAND_ORIGIN}, then runs the line again. Such a tool cannot use ${MINT_TOKEN_ACTION}, which takes a sign-in alone. A tool sets ${MINTED_TOKEN_VARIABLE} for the deploy, check, take, or scaffold line alone and unsets it once that line ends.`;
920
+ var VARIABLE_ROUTE_SENTENCES = variableRouteSentencesOf("runs the line again");
921
+ function variableRouteSentencesOf(then) {
922
+ return `A tool connected by a minted token, or a job, sets ${MINTED_TOKEN_VARIABLE} from where its token is kept, never by writing the value in a line, and ${ORIGIN_VARIABLE} to the address that minted the token where that is not ${DEFAULT_COMMAND_ORIGIN}, then ${then}. Such a tool cannot use ${MINT_TOKEN_ACTION}, which takes a sign-in alone. A tool sets ${MINTED_TOKEN_VARIABLE} for the deploy, check, take, or scaffold line alone and unsets it once that line ends.`;
923
+ }
921
924
  var LOGIN_ROUTE_OPENER = "A person logs this computer in once, in a terminal of their own, and its token then stays on this computer for 30 days:";
922
925
  var DEPLOY_FILES_ROUTE_SENTENCE = "A folder within the caps of your tool's deploy_files call deploys now through deploy_files, with no login.";
923
926
  var loginRouteLines = (io2, origin, deployFiles = true) => [
@@ -4884,12 +4887,15 @@ async function readTakeCredential(io2, named, afterLogin, why) {
4884
4887
  const line = { named, closing: NOTHING_WRITTEN2 };
4885
4888
  const read2 = await readCredential(io2, LIBRARY_CREDENTIAL, "", line);
4886
4889
  if ("unauthorized" in read2) {
4887
- const lines = [noTokenSentence(read2.unauthorized.origin, read2.unauthorized.expiredAt), ...why !== void 0 ? [why] : [], VARIABLE_ROUTE_SENTENCES];
4890
+ const head = [noTokenSentence(read2.unauthorized.origin, read2.unauthorized.expiredAt), ...why !== void 0 ? [why] : []];
4888
4891
  const origin = authorizationOriginOf(io2.env, named, NOTHING_WRITTEN2);
4889
- if ("refusal" in origin) return { lines: [...lines, origin.refusal] };
4892
+ if ("refusal" in origin) return { lines: [...head, VARIABLE_ROUTE_SENTENCES, origin.refusal] };
4890
4893
  const unwritable = loginRouteRefusalOf(io2, NOTHING_WRITTEN2);
4891
- if (unwritable !== null) return { lines: [...lines, unwritable] };
4892
- return { lines: [...lines, ...loginRouteLines(io2, origin.origin, false), afterLogin] };
4894
+ if (unwritable !== null) return { lines: [...head, VARIABLE_ROUTE_SENTENCES, unwritable] };
4895
+ const route = loginRouteLines(io2, origin.origin, false);
4896
+ if (typeof afterLogin === "string") return { lines: [...head, VARIABLE_ROUTE_SENTENCES, ...route, afterLogin] };
4897
+ const close = afterLogin(origin.origin);
4898
+ return { lines: [...head, close.variableRoute, ...route, close.afterLogin], signIn: origin.origin };
4893
4899
  }
4894
4900
  if ("refusal" in read2) return { lines: [read2.refusal] };
4895
4901
  io2.hide(read2.credential, REDACTED_TOKEN);
@@ -8511,18 +8517,21 @@ var folderRefusalOf = (io2, options, files, takeLines) => {
8511
8517
  return null;
8512
8518
  };
8513
8519
  var RUN_AGAIN = "Run the same line again.";
8514
- var finishSentence = (entry, takeLine) => `To finish, run this line at the project's root, which takes the ${entry} entry again whole and installs, then run npm test in ${APPLICATION_FOLDER}/: ${takeLine}`;
8520
+ var FINISH_WORDS = Object.freeze({ opening: "To finish,", again: " again whole" });
8521
+ var AFTER_LOGIN_FINISH_WORDS = Object.freeze({ opening: `Once ${LOGIN_SUBCOMMAND} has printed authorized:,`, again: "" });
8522
+ var finishSentence = (entry, takeLine, words = FINISH_WORDS) => `${words.opening} run this line at the project's root, which takes the ${entry} entry${words.again} and installs, then run npm test in ${APPLICATION_FOLDER}/: ${takeLine}`;
8515
8523
  var LINE_COUNT_WORDS = Object.freeze({ 2: "two", 3: "three", 4: "four" });
8516
- var finishEachSentence = (entries, takeLines) => [
8517
- `To finish, run each of these ${LINE_COUNT_WORDS[takeLines.length] ?? takeLines.length} lines at the project's root, in order, which take the ${listedAnd(entries)} entries again whole and install, then run npm test in ${APPLICATION_FOLDER}/:`,
8524
+ var finishEachSentence = (entries, takeLines, words = FINISH_WORDS) => [
8525
+ `${words.opening} run each of these ${LINE_COUNT_WORDS[takeLines.length] ?? takeLines.length} lines at the project's root, in order, which take the ${listedAnd(entries)} entries${words.again} and install, then run npm test in ${APPLICATION_FOLDER}/:`,
8518
8526
  ...takeLines
8519
8527
  ].join("\n");
8520
8528
  var FINISH_UNTAKEN = `To finish, run npm install and then npm test in ${APPLICATION_FOLDER}/.`;
8521
- var finishOf = (entry, takeLine) => {
8529
+ var finishOf = (entry, takeLine, words = FINISH_WORDS) => {
8522
8530
  const [entries, lines] = [listOf(entry), listOf(takeLine)];
8523
8531
  if (entries.length === 0 || lines.length !== entries.length) return FINISH_UNTAKEN;
8524
- return entries.length === 1 ? finishSentence(entries[0], lines[0]) : finishEachSentence(entries, lines);
8532
+ return entries.length === 1 ? finishSentence(entries[0], lines[0], words) : finishEachSentence(entries, lines, words);
8525
8533
  };
8534
+ var afterLoginFinishOf = (entries, takeLines) => finishOf(entries, takeLines, AFTER_LOGIN_FINISH_WORDS);
8526
8535
  var writtenClause = (entry) => {
8527
8536
  const entries = listOf(entry);
8528
8537
  if (entries.length === 0) return "the service's files are written";
@@ -8567,11 +8576,11 @@ var standsWayOn = (template, takeLines) => {
8567
8576
  return `${takes.length > 0 ? `. ${takes.join("\n")}` : `: ${SCAFFOLD_SUBCOMMAND} starts a new application and writes over none.`}
8568
8577
  ${STANDS_DEPLOY_LINE}`;
8569
8578
  };
8570
- var stoppedCloseOf = (state, template, takeLines) => {
8579
+ var stoppedCloseOf = (state, template, takeLines, words = FINISH_WORDS) => {
8571
8580
  const before = `before ${APPLICATION_FOLDER}/ was written`;
8572
8581
  switch (state) {
8573
8582
  case "template":
8574
- return `after ${APPLICATION_FOLDER}/ was written. ${finishOf(TEMPLATE_FACTS[template].takes.map((take) => take.entry), takeLines)}`;
8583
+ return `after ${APPLICATION_FOLDER}/ was written. ${finishOf(TEMPLATE_FACTS[template].takes.map((take) => take.entry), takeLines, words)}`;
8575
8584
  case "absent":
8576
8585
  return `${before}, and no ${APPLICATION_FOLDER}/ stands. ${RUN_AGAIN}`;
8577
8586
  case "empty":
@@ -8584,8 +8593,8 @@ var stoppedCloseOf = (state, template, takeLines) => {
8584
8593
  return `${before}, and what stands at ${APPLICATION_FOLDER} could not be read: make it readable or move it, then run the same line again.`;
8585
8594
  }
8586
8595
  };
8587
- var ownErrorLine = (error, state, template, takeLines) => `The command stopped on an error of its own (${errorWordOf(error)}) ${stoppedCloseOf(state, template, takeLines)}`;
8588
- var signalEndedLine = (state, template, takeLines) => `A signal ended the command ${stoppedCloseOf(state, template, takeLines)}`;
8596
+ var ownErrorLine = (error, state, template, takeLines, words = FINISH_WORDS) => `The command stopped on an error of its own (${errorWordOf(error)}) ${stoppedCloseOf(state, template, takeLines, words)}`;
8597
+ var signalEndedLine = (state, template, takeLines, words = FINISH_WORDS) => `A signal ended the command ${stoppedCloseOf(state, template, takeLines, words)}`;
8589
8598
  var ApplicationArrived = class extends Error {
8590
8599
  };
8591
8600
  var arrivedLine = (template, takeLines) => `${APPLICATION_FOLDER}/ took a file or a folder while the scaffold ran, so an application stands there and the template was not written${standsWayOn(template, takeLines)}`;
@@ -8681,6 +8690,7 @@ async function scaffold(call, io2) {
8681
8690
  const takeLinesFor = (at) => takes.map((take) => machineLineOf(libraryTakeLineOf({ origin: at, entry: take.entry }), { windows: io2.windows ?? LINES_IN_WINDOWS_FORM, npx: ranThroughNpx(io2) }, at));
8682
8691
  let lineOrigin = origin;
8683
8692
  let takeLines = takeLinesFor(lineOrigin);
8693
+ let finishWords = FINISH_WORDS;
8684
8694
  let reached = "checks";
8685
8695
  const stateNow = () => {
8686
8696
  if (reached === "template") return "template";
@@ -8702,26 +8712,44 @@ async function scaffold(call, io2) {
8702
8712
  if (refused !== null) return refuse(...refused);
8703
8713
  const checks = [];
8704
8714
  let held;
8715
+ let unsigned = null;
8716
+ const untaken = () => untakenLibraryOf(io2, root, (library) => writesOver(library, app));
8705
8717
  if (takes.length === 0) {
8706
- const found = untakenLibraryOf(io2, root, (library) => writesOver(library, app));
8718
+ const found = untaken();
8707
8719
  if ("lines" in found) return refuse(...found.lines);
8708
8720
  held = found;
8709
8721
  } else {
8710
- const credential = await readTakeCredential(io2, call.named[SCAFFOLD_OPTION.origin], SCAFFOLD_AFTER_LOGIN, SCAFFOLD_SIGN_IN_WHY);
8711
- if ("lines" in credential) return refuse(...credential.lines);
8712
- lineOrigin = credential.origin;
8713
- takeLines = takeLinesFor(lineOrigin);
8714
- for (const take of takes) {
8715
- const copy = join10(app, "lib", take.entry);
8716
- const planOf = (library) => writesOver(library, copy) ? { refusal: LIBRARY_OVER_APPLICATION } : { application: app, copy, declared: null, declaredAt: null };
8717
- const read2 = await readTake(io2, { entry: take.entry, root, named: options.named, origin: credential.origin }, agent.userAgent, credential.bearer, planOf, checks.length > 0);
8718
- if ("lines" in read2) return refuse(...read2.lines);
8719
- if (read2.plan === null) {
8720
- return refuse(`The ${take.entry} entry the library served carries no compiled modules, which the service's package file declares and installs. That is the platform's to fix: report it. ${NOTHING_WRITTEN2}`);
8722
+ const entries = takes.map((take) => take.entry);
8723
+ const credential = await readTakeCredential(
8724
+ io2,
8725
+ call.named[SCAFFOLD_OPTION.origin],
8726
+ (at) => ({ variableRoute: scaffoldVariableRouteOf(entries.length), afterLogin: afterLoginFinishOf(entries, takeLinesFor(at)) }),
8727
+ SCAFFOLD_SIGN_IN_WHY
8728
+ );
8729
+ if ("lines" in credential) {
8730
+ if (credential.signIn === void 0) return refuse(...credential.lines);
8731
+ lineOrigin = credential.signIn;
8732
+ takeLines = takeLinesFor(lineOrigin);
8733
+ const found = untaken();
8734
+ if ("lines" in found) return refuse(...found.lines);
8735
+ held = found;
8736
+ unsigned = credential.lines;
8737
+ finishWords = AFTER_LOGIN_FINISH_WORDS;
8738
+ } else {
8739
+ lineOrigin = credential.origin;
8740
+ takeLines = takeLinesFor(lineOrigin);
8741
+ for (const take of takes) {
8742
+ const copy = join10(app, "lib", take.entry);
8743
+ const planOf = (library) => writesOver(library, copy) ? { refusal: LIBRARY_OVER_APPLICATION } : { application: app, copy, declared: null, declaredAt: null };
8744
+ const read2 = await readTake(io2, { entry: take.entry, root, named: options.named, origin: credential.origin }, agent.userAgent, credential.bearer, planOf, checks.length > 0);
8745
+ if ("lines" in read2) return refuse(...read2.lines);
8746
+ if (read2.plan === null) {
8747
+ return refuse(`The ${take.entry} entry the library served carries no compiled modules, which the service's package file declares and installs. That is the platform's to fix: report it. ${NOTHING_WRITTEN2}`);
8748
+ }
8749
+ checks.push(read2);
8721
8750
  }
8722
- checks.push(read2);
8751
+ held = { library: checks[0].library, fresh: checks[0].fresh, packages: takenPackagesOf(checks) };
8723
8752
  }
8724
- held = { library: checks[0].library, fresh: checks[0].fresh, packages: takenPackagesOf(checks) };
8725
8753
  }
8726
8754
  const arrived = folderRefusalOf(io2, options, files, takeLines);
8727
8755
  if (arrived !== null) return refuse(...arrived);
@@ -8730,7 +8758,7 @@ async function scaffold(call, io2) {
8730
8758
  let ended = false;
8731
8759
  release = io2.whenEnded(() => {
8732
8760
  ended = true;
8733
- printEach(io2, signalEndedLine(stateNow(), template, takeLines));
8761
+ printEach(io2, signalEndedLine(stateNow(), template, takeLines, finishWords));
8734
8762
  });
8735
8763
  reached = "writes";
8736
8764
  if (io2.stat(root) === null) io2.makeFolder(root);
@@ -8746,12 +8774,16 @@ async function scaffold(call, io2) {
8746
8774
  await io2.sleep(LOOP_TURN_MS);
8747
8775
  release();
8748
8776
  if (ended) return COMMAND_STATUS.unknown;
8777
+ if (unsigned !== null) {
8778
+ for (const line of unsigned) printEach(io2, line);
8779
+ return COMMAND_STATUS.failed;
8780
+ }
8749
8781
  const taken = checks.map((check2, index) => ({ entry: takes[index].entry, version: check2.entry.version, line: takeLines[index] }));
8750
8782
  return await installAndTest(io2, app, template, taken, lineOrigin, { tools, claude: claudeStands });
8751
8783
  } catch (error) {
8752
8784
  const state = stateNow();
8753
8785
  const arrivedAs = error instanceof ApplicationArrived ? state : null;
8754
- printEach(io2, arrivedAs === "held" ? arrivedLine(template, takeLines) : arrivedAs === "no folder" ? ARRIVED_NO_FOLDER_LINE : ownErrorLine(error, state, template, takeLines));
8786
+ printEach(io2, arrivedAs === "held" ? arrivedLine(template, takeLines) : arrivedAs === "no folder" ? ARRIVED_NO_FOLDER_LINE : ownErrorLine(error, state, template, takeLines, finishWords));
8755
8787
  return COMMAND_STATUS.unknown;
8756
8788
  } finally {
8757
8789
  release();
@@ -8799,17 +8831,17 @@ async function installAndTest(io2, app, template, taken, origin, left) {
8799
8831
  }
8800
8832
  var SCAFFOLD_CREDENTIAL = LIBRARY_CREDENTIAL;
8801
8833
  var SCAFFOLD_READS = `under a template that takes library entries what library take reads, ${LIBRARY_READS}; and under a template that takes none, no credential`;
8802
- var SCAFFOLD_AFTER_LOGIN = `Once ${LOGIN_SUBCOMMAND} has printed authorized:, run this scaffold line again. ${NOTHING_WRITTEN2}`;
8834
+ var scaffoldVariableRouteOf = (count) => variableRouteSentencesOf(count === 1 ? "runs the take line below at the project's root, and not this line again" : "runs the take lines below at the project's root, in order, and not this line again");
8803
8835
  var SCAFFOLD_SIGN_IN_WHY = `A template that takes library entries needs a sign-in, since the library's reads are under a credential; ${SCAFFOLD_DEFAULT_TEMPLATE}, which takes none, runs without one.`;
8804
8836
  var SCAFFOLD_ROW = Object.freeze({
8805
8837
  name: SCAFFOLD_SUBCOMMAND,
8806
- summary: `Writes a new service from a template into a project, ${SCAFFOLD_DEFAULT_TEMPLATE} where the line names no ${SCAFFOLD_OPTION.template}. A template that takes library entries, as database-service takes the Database entry and web-app takes three, takes each as library take does, under the credential library take reads, checking each file's SHA-256 and each entry's closure hash before it writes anything. It then writes the template's files under app/, the manifest's packages member filled from the library folder's rows, runs npm install and npm test there, and prints the next steps. It starts a new application and writes over none. A template that takes no entry reads no credential.`,
8838
+ summary: `Writes a new service from a template into a project, ${SCAFFOLD_DEFAULT_TEMPLATE} where the line names no ${SCAFFOLD_OPTION.template}. A template that takes library entries, as database-service takes the Database entry and web-app takes three, takes each as library take does, under the credential library take reads, checking each file's SHA-256 and each entry's closure hash before it writes anything. It then writes the template's files under app/, the manifest's packages member filled from the library folder's rows, runs npm install and npm test there, and prints the next steps. Where such a template reads no credential, it writes the template's files, takes no entry, runs no npm, and prints the login route and the take lines that finish the service. It starts a new application and writes over none. A template that takes no entry reads no credential.`,
8807
8839
  options: SCAFFOLD_OPTIONS,
8808
8840
  credential: SCAFFOLD_CREDENTIAL,
8809
8841
  reads: SCAFFOLD_READS,
8810
8842
  statuses: {
8811
8843
  done: "the files written and installed, the entries taken where the template takes any, and the tests passed",
8812
- failed: "the files written, and npm install or the tests failed",
8844
+ failed: "the files written, and npm install or the tests failed, or no credential was read, so no library entry was taken",
8813
8845
  unknown: "the run stopped before its end, by an interrupt or another signal that ended npm, by an error of the command's own, or by something that came to stand at app while it wrote: the printed sentence names the way on",
8814
8846
  nothing_started: "nothing was written"
8815
8847
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turnzero",
3
- "version": "0.21.4",
3
+ "version": "0.21.5",
4
4
  "type": "module",
5
5
  "description": "The Turn Zero Cloud command, which an AI coding tool runs on your machine to deploy an application, store a secret, upload a file, download an export, take a library entry, write a local run's settings, start the application locally, and scaffold a new service from a template.",
6
6
  "license": "Apache-2.0",