@danypops/papyrus 0.27.13 → 0.27.14

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.
@@ -658,7 +658,10 @@ class AskComponent extends Container {
658
658
  this.addChild(new BoxBorderBottom((s) => theme.fg("accent", s)));
659
659
 
660
660
  this.updateStaticText();
661
- this.showSelectMode();
661
+ // A freeform-only ask (no options at all) has no select list to show -- start directly in
662
+ // the freeform editor instead of a select mode that would have nothing to render.
663
+ if (this.options.length === 0) this.showFreeformMode();
664
+ else this.showSelectMode();
662
665
  }
663
666
 
664
667
  override invalidate(): void { super.invalidate(); this.updateStaticText(); this.updateHelpText(); }
@@ -877,12 +880,13 @@ class AskComponent extends Container {
877
880
 
878
881
  if (this.mode === "freeform" || this.mode === "comment") {
879
882
  const alternateCancelKeys = this.keybindings.getKeys("tui.select.cancel").filter((key) => key !== "escape" && key !== "esc");
883
+ const canGoBack = this.options.length > 0;
880
884
  const hints = [
881
885
  keybindingHint(theme, this.keybindings, "tui.input.submit", this.mode === "comment" ? "submit/skip" : "submit"),
882
886
  keybindingHint(theme, this.keybindings, "tui.input.newLine", "newline"),
883
- literalHint(theme, "esc", "back"),
887
+ literalHint(theme, "esc", canGoBack ? "back" : "cancel"),
884
888
  overlayHint,
885
- alternateCancelKeys.length > 0 ? literalHint(theme, formatKeyList(alternateCancelKeys), "cancel") : null,
889
+ canGoBack && alternateCancelKeys.length > 0 ? literalHint(theme, formatKeyList(alternateCancelKeys), "cancel") : null,
886
890
  ].filter((hint): hint is string => !!hint).join(" • ");
887
891
  this.helpText.setText(theme.fg("dim", hints));
888
892
  return;
@@ -1031,7 +1035,8 @@ class AskComponent extends Container {
1031
1035
  handleInput(data: string): void {
1032
1036
  if (this.handlePromptScrollInput(data)) { this.tui.requestRender(); return; }
1033
1037
  if (this.mode === "freeform" || this.mode === "comment") {
1034
- if (matchesKey(data, Key.escape)) { this.showSelectMode(); return; }
1038
+ // A freeform-only ask has no select mode to go back to -- escape cancels outright.
1039
+ if (matchesKey(data, Key.escape)) { if (this.options.length > 0) this.showSelectMode(); else this.onDone(null); return; }
1035
1040
  if (this.keybindings.matches(data, "tui.select.cancel")) { this.onDone(null); return; }
1036
1041
  this.ensureEditor().handleInput(data);
1037
1042
  this.tui.requestRender();
@@ -1057,6 +1062,11 @@ async function askViaDialogs(
1057
1062
  const dialogOpts = timeout ? { timeout } : undefined;
1058
1063
  const prompt = context ? `${question}\n\nContext:\n${context}` : question;
1059
1064
 
1065
+ if (options.length === 0) {
1066
+ const answer = (await ui.input(prompt, "Type your answer...", dialogOpts)) as string | undefined;
1067
+ return isCancelledInput(answer) ? null : createFreeformResponse(answer);
1068
+ }
1069
+
1060
1070
  if (allowMultiple) {
1061
1071
  const rawSelections = (await ui.input(`${prompt}\n\nOptions (select one or more):\n${formatOptionsForMessage(options)}`, "Type your selection(s)...", dialogOpts)) as string | undefined;
1062
1072
  if (isCancelledInput(rawSelections)) return null;
@@ -1139,13 +1149,9 @@ async function askQuestionBlocking(
1139
1149
  displayMode: AskDisplayMode,
1140
1150
  normalizedContext: string | undefined,
1141
1151
  ): Promise<AskAnswer | undefined> {
1142
- if (options.length === 0) {
1143
- const prompt = normalizedContext ? `${params.question}\n\nContext:\n${normalizedContext}` : params.question;
1144
- const answer = await ctx.ui.input(prompt, "Type your answer...", params.timeout ? { timeout: params.timeout } : undefined);
1145
- const response = createFreeformResponse(answer);
1146
- return response ? toAskAnswer(response) : undefined;
1147
- }
1148
-
1152
+ // A freeform-only ask (no options) still goes through the same rich AskComponent/ctx.ui.custom()
1153
+ // path below, not a bare ctx.ui.input() -- otherwise it renders as a plain, contextless single
1154
+ // line while every options-bearing ask gets the full bordered box, title, and markdown context.
1149
1155
  const shortcuts: ResolvedAskShortcuts = {
1150
1156
  overlayToggle: resolveShortcut(undefined, process.env["PAPYRUS_DISCUSS_OVERLAY_TOGGLE_KEY"], DEFAULT_OVERLAY_TOGGLE_KEY),
1151
1157
  commentToggle: resolveShortcut(undefined, process.env["PAPYRUS_DISCUSS_COMMENT_TOGGLE_KEY"], DEFAULT_COMMENT_TOGGLE_KEY),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/papyrus",
3
- "version": "0.27.13",
3
+ "version": "0.27.14",
4
4
  "description": "Daemon-backed graph artifacts, evidence-bearing tasks, rules, skills, and native TUI workflows for Pi",
5
5
  "type": "module",
6
6
  "keywords": ["pi-package"],