@pmndre/pine 0.35.0 → 0.35.1

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.
package/changes.json CHANGED
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.35.1",
4
+ "changes": [
5
+ "fix: when pine asks you for several values at once (the two tokens of a Slack app), each is a block of its own in the dialog"
6
+ ]
7
+ },
2
8
  {
3
9
  "version": "0.35.0",
4
10
  "changes": [
@@ -255,11 +261,5 @@
255
261
  "feat: steering, undo, plan mode, goals, background commands, questions and a list of steps",
256
262
  "feat: an agent operates the apps on a Mac, by outline or by picture, and asks once per app"
257
263
  ]
258
- },
259
- {
260
- "version": "0.9.1",
261
- "changes": [
262
- "fix: an agent does not act on a browser page its owner opened unseen, and esc spares the message typed meanwhile"
263
- ]
264
264
  }
265
265
  ]
@@ -369,10 +369,12 @@ answer the one before it or put it off.
369
369
  | `esc` | Later: the request stays open until `security.approvalTimeout` (5 minutes) has passed and then counts as denied. Until then the status line keeps reminding you, `enter` on an empty line opens the dialog again, and `/approve` or `/deny` answer it A question in a tab that is not in front opens no dialog there: that tab gets a `!` in the tab bar, and the status line of the tab you are in says which tab waits (`alt+<n>` goes there) |
370
370
 
371
371
  When the action needs something only you have (a bot's token, a device's password), the dialog
372
- has a field for it. Type or paste it: a secret is shown as dots, goes into pine's `.env` and is
372
+ has a field for it: the value's name, under it what it is, and a bar to type into. When it needs
373
+ several (the two tokens of a Slack app), each is a block of its own, numbered "1 of 2", and the
374
+ name of the one you are typing into is in colour. Type or paste it: a secret is shown as dots, goes into pine's `.env` and is
373
375
  never seen by the agent or its model. (Pairing a Telegram account uses the same dialog for the
374
376
  six-digit code the bot sent to your phone; the code is shown as you type and is not stored.)
375
- `enter` saves and allows, `tab` and `shift+tab` or the arrow keys move between fields, `ctrl+u`
377
+ `enter` saves and allows, `tab` and `shift+tab`, the arrow keys or a click on a field move between fields, `ctrl+u`
376
378
  empties one, `esc` leaves it for later, and `/approve` opens the dialog again. The letter keys
377
379
  are part of what you type there, so `a` and `d` are not shortcuts in this dialog; Deny is a
378
380
  button to click.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmndre/pine",
3
- "version": "0.35.0",
3
+ "version": "0.35.1",
4
4
  "description": "PI neural engine: an event-driven multi-agent daemon built on the pi coding agent SDK",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/tui/app.js CHANGED
@@ -818,6 +818,8 @@ class ApprovalDialog {
818
818
  */
819
819
  fields;
820
820
  field = 0;
821
+ /** The rows each value's block takes in the dialog, for a click on one. */
822
+ areas = [];
821
823
  constructor(req, done) {
822
824
  this.req = req;
823
825
  this.done = done;
@@ -851,6 +853,10 @@ class ApprovalDialog {
851
853
  const b = this.buttons.find((x) => e.y === x.row && e.x >= x.from && e.x < x.to);
852
854
  if (b && e.type === "click" && e.button === "left")
853
855
  this.answer(b.answer);
856
+ // A click on a value's block is where the typing goes next.
857
+ const area = this.areas.find((x) => e.y >= x.from && e.y < x.to);
858
+ if (area && e.type === "click" && e.button === "left")
859
+ this.field = area.field;
854
860
  return { handled: true, render: true };
855
861
  }
856
862
  handleInput(data) {
@@ -895,11 +901,6 @@ class ApprovalDialog {
895
901
  }
896
902
  render(width) {
897
903
  const inner = Math.max(20, width - 4);
898
- const inputs = this.fields.flatMap((f, i) => [
899
- ...wrapTextWithAnsi(c.bold(f.label), inner),
900
- // A secret is never shown: a dot for each character, so that you see it arrive.
901
- `${i === this.field ? c.accent(">") : " "} ${c.yellow(f.secret ? "•".repeat(Math.min(f.value.length, inner - 6)) : f.value.slice(-(inner - 6)))}${i === this.field ? c.inverse(" ") : ""}`,
902
- ]);
903
904
  const body = [
904
905
  c.bold(c.yellow(this.fields.length ? "Approval needed, and something only you have" : "Approval needed")),
905
906
  "",
@@ -911,9 +912,33 @@ class ApprovalDialog {
911
912
  ...(this.req.holds ? wrapTextWithAnsi(c.gray(`"Allow" holds for ${this.req.holds}: you are not asked about it again there.`), inner) : []),
912
913
  ...(this.req.remember ? wrapTextWithAnsi(c.gray(`"Always here" stops asking about ${this.req.remember} in this conversation.`), inner) : []),
913
914
  ...(!this.req.remember && !this.req.holds && !this.fields.length ? wrapTextWithAnsi(c.gray("This one is asked every time: there is no \"always\" for it."), inner) : []),
914
- ...(inputs.length ? ["", ...inputs, ...wrapTextWithAnsi(c.gray(this.fields.some((f) => f.secret) ? "Type or paste it here. It is not shown, goes into pine's .env file, and never reaches the agent or its model." : "Type it here and press enter. Without it, this cannot be allowed."), inner)] : []),
915
- "",
916
915
  ];
916
+ // Each value is a block of its own: its name, what it is, and a bar to type into, with an empty
917
+ // line before it. Run together, two tokens read as one paragraph.
918
+ const bar = inner - 2;
919
+ this.areas = [];
920
+ this.fields.forEach((f, i) => {
921
+ const active = i === this.field;
922
+ // A label that reads "name: what it is" or "NAME (what it is)" is its name and, under it, the rest.
923
+ const [, name, about] = f.label.match(/^([\w.-]+): ([\s\S]+)$/) ?? f.label.match(/^([\w.-]+) \(([\s\S]+)\)$/) ?? [null, f.label, ""];
924
+ const count = this.fields.length > 1 ? `${i + 1} of ${this.fields.length}` : "";
925
+ // A secret is never shown: a dot for each character, so that you see it arrive.
926
+ const shown = f.secret ? "•".repeat(Math.min(f.value.length, bar - 2)) : f.value.slice(-(bar - 2));
927
+ const typed = shown || active ? `${c.yellow(shown)}${active ? c.inverse(" ") : ""}` : c.gray("empty");
928
+ body.push("");
929
+ const from = 1 + body.length;
930
+ body.push(...wrapTextWithAnsi(active ? c.bold(c.accent(name)) : c.bold(name), inner - count.length - 2).map((l, n) => (n || !count ? l : `${l}${" ".repeat(Math.max(2, inner - visibleWidth(l) - count.length))}${c.gray(count)}`)), ...(about ? wrapTextWithAnsi(about, inner) : []), `${active ? c.accent(">") : " "} ${c.bgPanel(`${typed}${" ".repeat(Math.max(0, bar - visibleWidth(typed)))}`)}`);
931
+ this.areas.push({ from, to: 1 + body.length, field: i });
932
+ });
933
+ if (this.fields.length) {
934
+ const hint = !this.fields.some((f) => f.secret)
935
+ ? "Type it here and press enter. Without it, this cannot be allowed."
936
+ : this.fields.length > 1
937
+ ? "Type or paste each one into its bar; tab goes to the next. They are not shown, go into pine's .env file, and never reach the agent or its model."
938
+ : "Type or paste it here. It is not shown, goes into pine's .env file, and never reaches the agent or its model.";
939
+ body.push("", ...wrapTextWithAnsi(c.gray(hint), inner));
940
+ }
941
+ body.push("");
917
942
  // The buttons, wrapped onto a second line in a narrow window. Their places are kept for clicks:
918
943
  // two columns of border and padding, then the labels.
919
944
  const rows = [""];