clavarium-parley 0.10.2 → 0.10.3

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/bin/parley.mjs CHANGED
@@ -46,8 +46,10 @@ export const HELP = `parley: talk with the person you work for. They read and an
46
46
  parley read --all the whole exchange, both sides, oldest first: to pick up the
47
47
  thread after a restart
48
48
  parley tell [--short "title"] "text" tell them something: where you are, what you did, what you found
49
- parley ask [--short "title"] "question" [choice ...]
50
- ask them something; give the answers they can pick when you can
49
+ parley ask [--short "title"] "question" [--choice "answer" ...]
50
+ ask them something; give the answers they can pick when you can,
51
+ each with --choice (the question first; "-" for the question
52
+ read from standard input)
51
53
  parley close ID "answer" close a question of yours they answered another way (a message
52
54
  typed later), saying the answer you understood; ID as read shows it
53
55
  parley show path ["note"] point them to a file you made, so that they can open it
@@ -140,7 +142,22 @@ export function run(argv, { env = process.env, cwd = process.cwd(), stdin = () =
140
142
  const at2 = rest.indexOf('--short');
141
143
  let short;
142
144
  if (at2 >= 0) { short = rest[at2 + 1]; if (short === undefined) return { code: 64, out: '', err: '--short needs a title.\n' }; rest.splice(at2, 2); }
143
- said = verb === 'tell' ? verbs.tell(text(rest.join(' ')), { short }) : verbs.ask(text(rest[0]), rest.slice(1), { short });
145
+ if (verb === 'tell') said = verbs.tell(text(rest.join(' ')), { short });
146
+ else {
147
+ /* Its answers: --choice "...", once each, anywhere; or, as before, the words after the question. */
148
+ const choices = [];
149
+ for (let i = rest.indexOf('--choice'); i >= 0; i = rest.indexOf('--choice')) {
150
+ if (rest[i + 1] === undefined) return { code: 64, out: '', err: '--choice needs an answer.\n' };
151
+ choices.push(rest[i + 1]); rest.splice(i, 2);
152
+ }
153
+ /* The question first, then its answers: "-" (the question from standard input) is the
154
+ question, never an answer -- a question asked the other way round showed its first
155
+ answer as the question and the rest as buttons. */
156
+ if (rest.slice(1).includes('-')) return { code: 64, out: '', err: 'The question comes first, then its answers: parley ask [--short "title"] "question" (or -) [--choice "answer" ...].\n' };
157
+ const question = rest[0] === undefined ? '' : text(rest[0]);
158
+ if (!String(question).trim()) return { code: 64, out: '', err: 'A question needs its text: parley ask "question" [--choice "answer" ...].\n' };
159
+ said = verbs.ask(question, [...rest.slice(1), ...choices], { short });
160
+ }
144
161
  }
145
162
  else if (verb === 'close') said = verbs.close(rest[0], text(rest.slice(1).join(' ')));
146
163
  else if (verb === 'doing') said = verbs.doing(text(rest.join(' ')));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium-parley",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A bridge between a command-line agent and a screen of its own: a command and an MCP server of five verbs, and a small library that shows the exchange.",
@@ -32,7 +32,7 @@ import { fileURLToPath } from 'node:url';
32
32
  import { randomUUID } from 'node:crypto';
33
33
  import { createInterface } from 'node:readline';
34
34
 
35
- export const VERSION = '0.10.2';
35
+ export const VERSION = '0.10.3';
36
36
  /* A message may be long: the screen folds it, and shows its short version first. */
37
37
  export const TEXT_MAX = 16000;
38
38
  /* Its short version: a title of one or two lines. */