@sonnechasser/ntrp 0.2.0 → 0.2.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/dist/index.js CHANGED
@@ -15584,15 +15584,18 @@ function inferHandoffTarget(input) {
15584
15584
  return "plan";
15585
15585
  }
15586
15586
  function isShipIntent(input) {
15587
- return /\b(handoff|ship|deliver|board memo|export|turn this into|write.?up|action plan)\b/i.test(
15588
- input.trim()
15589
- );
15587
+ const line = input.trim();
15588
+ if (/\?\s*$/.test(line) || QUESTION_LEAD_RE.test(line)) return false;
15589
+ return SHIP_INTENT_RE.test(line);
15590
15590
  }
15591
+ var QUESTION_LEAD_RE, SHIP_INTENT_RE;
15591
15592
  var init_handoff_draft = __esm({
15592
15593
  "src/conversation/handoff-draft.ts"() {
15593
15594
  "use strict";
15594
15595
  init_profile();
15595
15596
  init_session_analysis();
15597
+ QUESTION_LEAD_RE = /^\s*(what|why|how|when|where|who|which|is|are|was|were|do|does|did|explain|tell me|help me understand)\b/i;
15598
+ SHIP_INTENT_RE = /\b(ship|export|deliver|write[- ]?up|board memo|action plan|turn (this|it|that) into|(draft|create|make|build|prepare|generate|send)\s+(me\s+)?(a\s+|the\s+)?hand[- ]?off|hand[- ]?off\s+(prompt|doc|document|plan))\b/i;
15596
15599
  }
15597
15600
  });
15598
15601
 
@@ -26633,10 +26636,10 @@ function randomGoodbye() {
26633
26636
  return GOODBYES[Math.floor(Math.random() * GOODBYES.length)] ?? "Bye.";
26634
26637
  }
26635
26638
  function commandCompletionCandidates() {
26636
- return [
26639
+ return [.../* @__PURE__ */ new Set([
26637
26640
  ...REPL_BUILTINS,
26638
- ...listCommandNames(false).map((name) => `/${name}`)
26639
- ];
26641
+ ...listCommandNames(true).map((name) => `/${name}`)
26642
+ ])];
26640
26643
  }
26641
26644
  function completeCommand(line) {
26642
26645
  const firstToken2 = line.split(/\s/, 1)[0] ?? "";
@@ -26648,17 +26651,35 @@ function completeCommand(line) {
26648
26651
  function inlineCommandSuggestion(line) {
26649
26652
  if (!line.startsWith("/") || /\s/.test(line)) return null;
26650
26653
  const matches = commandCompletionCandidates().filter((command) => command.startsWith(line));
26651
- if (matches.length !== 1 || matches[0] === line) return null;
26652
- return matches[0].slice(line.length);
26654
+ if (matches.length === 0) return null;
26655
+ if (matches.length === 1) {
26656
+ return matches[0] === line ? null : matches[0].slice(line.length);
26657
+ }
26658
+ let common = matches[0];
26659
+ for (const match of matches) {
26660
+ let i = 0;
26661
+ while (i < common.length && i < match.length && common[i] === match[i]) i++;
26662
+ common = common.slice(0, i);
26663
+ }
26664
+ return common.length > line.length ? common.slice(line.length) : null;
26653
26665
  }
26654
26666
  function renderInlineSuggestion(rl, prompt) {
26655
26667
  const line = rl.line;
26656
26668
  const cursor = rl.cursor;
26657
26669
  const suffix = cursor === line.length ? inlineCommandSuggestion(line) : null;
26670
+ const promptWidth = visibleLength(prompt);
26671
+ const columns = process.stdout.columns ?? 80;
26672
+ const fitsOneRow = promptWidth + line.length + (suffix?.length ?? 0) < columns;
26673
+ const shouldPaint = (suffix !== null || suggestionPainted) && fitsOneRow;
26674
+ if (!shouldPaint) {
26675
+ suggestionPainted = false;
26676
+ return;
26677
+ }
26678
+ suggestionPainted = suffix !== null;
26658
26679
  clearLine2(process.stdout, 0);
26659
26680
  cursorTo2(process.stdout, 0);
26660
26681
  process.stdout.write(prompt + line + (suffix ? chalk68.dim(suffix) : ""));
26661
- cursorTo2(process.stdout, visibleLength(prompt) + cursor);
26682
+ cursorTo2(process.stdout, promptWidth + cursor);
26662
26683
  }
26663
26684
  function appendTurnLine(current, promptLabel, currentSummary) {
26664
26685
  const currentLine = currentSummary ? `${promptLabel} ${current} ${chalk68.white("\u2192")} ${currentSummary}` : `${promptLabel} ${current}`;
@@ -26885,7 +26906,7 @@ function printHelp() {
26885
26906
  console.log(" " + chalk68.dim("Power-user commands (") + paint("accent", "/new") + chalk68.dim(", ") + paint("accent", "/diagnose") + chalk68.dim(", ") + paint("accent", "/metrics") + chalk68.dim(") remain available."));
26886
26907
  console.log();
26887
26908
  }
26888
- var REPL_BUILTINS, ANSI_PATTERN, GOODBYES;
26909
+ var REPL_BUILTINS, ANSI_PATTERN, GOODBYES, suggestionPainted;
26889
26910
  var init_repl = __esm({
26890
26911
  "src/cli/repl.ts"() {
26891
26912
  "use strict";
@@ -26945,6 +26966,7 @@ var init_repl = __esm({
26945
26966
  "May your pipeline stay hydrated.",
26946
26967
  "Don't let the zombie deals bite."
26947
26968
  ];
26969
+ suggestionPainted = false;
26948
26970
  }
26949
26971
  });
26950
26972