@polycode-projects/the-mechanical-code-talker 5.0.8 → 5.0.10
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.
|
|
3
|
+
"version": "5.0.10",
|
|
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.",
|
|
@@ -154,7 +154,8 @@
|
|
|
154
154
|
"template:coverage": "node scripts/template-coverage.mjs",
|
|
155
155
|
"audit": "npm audit --audit-level=high",
|
|
156
156
|
"audit:fix": "npm audit fix",
|
|
157
|
-
"demo:build": "node scripts/build-demo-site.mjs
|
|
157
|
+
"demo:build": "node scripts/build-demo-site.mjs",
|
|
158
|
+
"bench:receipts": "node scripts/bench-receipts.mjs",
|
|
158
159
|
"roll": "node scripts/roll.mjs",
|
|
159
160
|
"build:ask-bundle": "node scripts/build-ask-bundle.mjs",
|
|
160
161
|
"build:chat-bundle": "node scripts/build-chat-bundle.mjs",
|
|
@@ -235,6 +235,10 @@ const WONDERING_WRAPPER_RE = /^i(?:\s+was|\s+am|'m)?\s+(?:just\s+)?(?:wonder(?:i
|
|
|
235
235
|
* ("what the parser does with X …") is never re-inverted. */
|
|
236
236
|
const EMBEDDED_WHATIS_RE = /^what\s+((?:an?\s+|the\s+)?[\w'-]+(?:\s+[\w'-]+){0,2})\s+(is|are)\??$/i;
|
|
237
237
|
const EMBEDDED_MEANS_RE = /^what\s+((?:an?\s+|the\s+)?[\w'-]+(?:\s+[\w'-]+){0,2})\s+means\??$/i;
|
|
238
|
+
/** The memory-question sibling: "tell me what you know about X" peels to
|
|
239
|
+
* "what you know about X", which keeps the same declarative order and misses
|
|
240
|
+
* the memory lane's own "what do you know about X" shape. */
|
|
241
|
+
const EMBEDDED_KNOW_ABOUT_RE = /^what\s+you\s+(know|remember)\s+about\s+(.+?)\??$/i;
|
|
238
242
|
/** show/give-me presentation bridge: a kind-listing remainder is left
|
|
239
243
|
* untouched, a relation/interrogative remainder unwraps to itself, anything
|
|
240
244
|
* else bridges to "describe <thing>". */
|
|
@@ -309,6 +313,8 @@ export function applyPreambleFrames(text) {
|
|
|
309
313
|
if (m) q = `what ${m[2].toLowerCase()} ${m[1].trim()}`;
|
|
310
314
|
m = q.match(EMBEDDED_MEANS_RE);
|
|
311
315
|
if (m) q = `what does ${m[1].trim()} mean`;
|
|
316
|
+
m = q.match(EMBEDDED_KNOW_ABOUT_RE);
|
|
317
|
+
if (m) q = `what do you ${m[1].toLowerCase()} about ${m[2].trim()}`;
|
|
312
318
|
m = q.match(SHOW_GIVE_ME_RE);
|
|
313
319
|
if (m) {
|
|
314
320
|
const rest = m[1].trim();
|
package/src/services/chat.mjs
CHANGED
|
@@ -14071,14 +14071,27 @@ async function runAsk(query, { config, source, graph, focus, last, templates, me
|
|
|
14071
14071
|
// graph entity.
|
|
14072
14072
|
// Contraction-expanded, so "what's X" earns the same offer "what is X"
|
|
14073
14073
|
// does. Both shapes below anchor on the written-out copula.
|
|
14074
|
-
|
|
14075
|
-
const knowAboutTerm = offerSrc.match(KNOW_ABOUT_RE)?.[1]?.trim();
|
|
14074
|
+
//
|
|
14076
14075
|
// "who is grelb" asks about a term the same way "what is grelb" does, and
|
|
14077
14076
|
// a name is exactly what a person teaches next — without this the who-form
|
|
14078
14077
|
// dead-ends on the bare grammar wall while its what-form twin offers the
|
|
14079
14078
|
// teach phrasing.
|
|
14080
|
-
const
|
|
14081
|
-
|
|
14079
|
+
const teachableTermOf = (src) => {
|
|
14080
|
+
const knowAbout = src.match(KNOW_ABOUT_RE)?.[1]?.trim();
|
|
14081
|
+
const who = shortTermQuestionTerm(src) ? src.match(WHO_IS_BARE_RE)?.[1]?.trim() : null;
|
|
14082
|
+
return { knowAbout, term: knowAbout || metaTermOf(src, envelope) || who };
|
|
14083
|
+
};
|
|
14084
|
+
const offerSrc = expandContractions(String(query).trim());
|
|
14085
|
+
// All three shapes anchor at the start of the string, so a politeness or
|
|
14086
|
+
// modal wrapper ("please tell me what a grelb is") hides the term from
|
|
14087
|
+
// every one of them and the turn dead-ends on the bare wall instead. The
|
|
14088
|
+
// peeled form is a fallback, tried only when the raw one names nothing, so
|
|
14089
|
+
// a query that already matched resolves exactly as before.
|
|
14090
|
+
let { knowAbout: knowAboutTerm, term: offerTerm } = teachableTermOf(offerSrc);
|
|
14091
|
+
if (!offerTerm) {
|
|
14092
|
+
const peeledSrc = applyPreambleFrames(offerSrc);
|
|
14093
|
+
if (peeledSrc !== offerSrc) ({ knowAbout: knowAboutTerm, term: offerTerm } = teachableTermOf(peeledSrc));
|
|
14094
|
+
}
|
|
14082
14095
|
// A term that LEADS with a bindable anaphor ("it used for", from an
|
|
14083
14096
|
// unresolved "what is it used for") is a pronoun that failed to bind,
|
|
14084
14097
|
// not a teachable subject — offering to learn facts about it would echo
|