@polycode-projects/the-mechanical-code-talker 5.0.41 → 5.0.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polycode-projects/the-mechanical-code-talker",
3
- "version": "5.0.41",
3
+ "version": "5.0.43",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "The Mechanical Code Talker (tmct) — a tolerant, offline, $0 chat surface that guides you toward precision queries about a software repository. ELIZA/PARRY-style but domain-obsessed with code. No model calls; indexes a repo on request (tmct index) or reads any producer's graph.",
@@ -2746,6 +2746,45 @@ function coverageGrainNote(parsed, entityType) {
2746
2746
  return `This index records tests edges module to module, so a ${noun} counts as covered exactly when the module it lives in is tested — ask about that module to see the coverage itself.`;
2747
2747
  }
2748
2748
 
2749
+ /** The two shapes that filter a whole kind by a qualifier and nothing else:
2750
+ * the plain "which functions are exported", and the boolean the negative
2751
+ * polarity compiles to. Both carry the same two facts — which kind, which
2752
+ * adjective — and the third says which way the question ran. */
2753
+ function wholeKindQualifierFilter(parsed) {
2754
+ if (parsed?.node === "qualifier" && parsed.inner?.node === "allOfClass" && parsed.filters?.length) {
2755
+ return { entityType: parsed.inner.entityType || parsed.entityType, filters: parsed.filters, negated: false };
2756
+ }
2757
+ if (parsed?.node !== "boolean" || parsed.atoms?.length !== 2) return null;
2758
+ const [seed, filter] = parsed.atoms;
2759
+ if (seed.op !== "seed" || seed.ast?.node !== "allOfClass") return null;
2760
+ if (filter.kind !== "qual" || !filter.filters?.length) return null;
2761
+ if (filter.op !== "difference" && filter.op !== "intersection") return null;
2762
+ return {
2763
+ entityType: seed.ast.entityType || parsed.entityType,
2764
+ filters: filter.filters,
2765
+ negated: filter.op === "difference",
2766
+ };
2767
+ }
2768
+
2769
+ /** The branch to point at when a qualifier emptied a set drawn from a whole
2770
+ * kind. "which functions are not exported" takes every function the index
2771
+ * holds and removes the exported ones, so the qualifier is the only thing
2772
+ * that can have emptied it, and the exported functions are the branch worth
2773
+ * offering. The polarity flips to the side the question did not ask about,
2774
+ * and both phrasings are ones the parser accepts, so the nudge can never name
2775
+ * a shape that misses.
2776
+ *
2777
+ * Only an unrestricted set qualifies. Once a clause narrows it first, that
2778
+ * clause may be what emptied it, and naming the qualifier's branch would
2779
+ * point past the real gap. */
2780
+ function qualifierBranchNote(parsed) {
2781
+ const filtered = wholeKindQualifierFilter(parsed);
2782
+ if (!filtered) return null;
2783
+ const kindPlural = nounFor(filtered.entityType || "Module", 2);
2784
+ const polarity = filtered.negated ? "" : "not ";
2785
+ return `Try "which ${kindPlural} are ${polarity}${listJoin(filtered.filters)}" for that branch on its own.`;
2786
+ }
2787
+
2749
2788
  function renderComposite(parsed, result, graph) {
2750
2789
  if (result.compositeMiss) {
2751
2790
  if (result.reason === "no-prev") {
@@ -3006,7 +3045,9 @@ function renderComposite(parsed, result, graph) {
3006
3045
  miss: true, ambiguous: false, matches: [],
3007
3046
  };
3008
3047
  }
3009
- const hint = coverageGrainNote(parsed, result.entityType) || touchesRephraseHint(graph);
3048
+ const hint = coverageGrainNote(parsed, result.entityType)
3049
+ || qualifierBranchNote(parsed)
3050
+ || touchesRephraseHint(graph);
3010
3051
  return { content: `nothing in the index matches that${result.entityType ? ` (${nounFor(result.entityType, 2)})` : ""}. ${hint}`, miss: true, ambiguous: false, matches: [] };
3011
3052
  }
3012
3053
  return { content: `${compositeList(result.matches)}.`, miss: false, ambiguous: false, matches: result.matches };
@@ -150,7 +150,13 @@ function parseInline(text) {
150
150
  // CHOICE_MAX_OPTIONS (an eight-option "A) ... H) ...") is still recognized
151
151
  // as enumerated and declines on the option count, rather than the marker
152
152
  // regex itself silently stopping short and truncating the list.
153
- const LABEL_MARKER_RE = /\(([A-Za-z])\)|\b([A-Za-z])[.):]/g;
153
+ //
154
+ // A marker stands alone: whitespace or the start of the text before it, and
155
+ // whitespace or the end of the text after it. Without both edges the letter
156
+ // and dot inside a dotted path ("app/lib/a.mjs … app/lib/b.mjs") read as an
157
+ // A, B label run, and an ordinary set question gets answered as a closed
158
+ // multiple choice over the fragments either side of the slash.
159
+ const LABEL_MARKER_RE = /(?<=^|\s)\(?([A-Za-z])[.):](?=\s|$)/g;
154
160
 
155
161
  /** The longest run of label markers found in strict A, B, C, ... sequence.
156
162
  * A marker that does not match the next expected letter is skipped rather
@@ -162,7 +168,7 @@ function findAcceptedLabelSequence(text) {
162
168
  LABEL_MARKER_RE.lastIndex = 0;
163
169
  let m;
164
170
  while ((m = LABEL_MARKER_RE.exec(text))) {
165
- const letter = (m[1] || m[2]).toUpperCase();
171
+ const letter = m[1].toUpperCase();
166
172
  if (letter === String.fromCharCode(65 + expected)) {
167
173
  accepted.push({ letter, start: m.index, end: LABEL_MARKER_RE.lastIndex });
168
174
  expected += 1;