@polycode-projects/the-mechanical-code-talker 7.1.0 → 7.1.2
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": "7.1.
|
|
3
|
+
"version": "7.1.2",
|
|
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.",
|
|
@@ -45,13 +45,18 @@ function definitionEntries(body) {
|
|
|
45
45
|
return [];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
/** The first English noun-or-verb sense's definition sentence, or "".
|
|
48
|
+
/** The first English noun-or-verb sense's definition sentence, or "". A
|
|
49
|
+
* sense list can open on an empty or markup-only definition, so the first
|
|
50
|
+
* definition with text left after the markup goes is the sense. */
|
|
49
51
|
function firstGroundedDefinition(body) {
|
|
50
52
|
for (const entry of definitionEntries(body)) {
|
|
51
53
|
if (entry?.language && entry.language !== "English") continue;
|
|
52
54
|
if (!GROUNDED_PARTS_OF_SPEECH.has(String(entry?.partOfSpeech ?? "").toLowerCase())) continue;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
+
for (const sense of entry?.definitions ?? []) {
|
|
56
|
+
if (typeof sense?.definition !== "string") continue;
|
|
57
|
+
const definition = stripMarkup(sense.definition);
|
|
58
|
+
if (definition.trim()) return definition;
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
61
|
return "";
|
|
57
62
|
}
|
|
@@ -38,6 +38,9 @@ export function stripMarkup(text) {
|
|
|
38
38
|
s = s.replace(/<!--[\s\S]*?-->/g, " ");
|
|
39
39
|
s = s.replace(/<[^>]*>/g, " ");
|
|
40
40
|
s = s.replace(/\s+/g, " ").trim();
|
|
41
|
+
// A tag that closes right before punctuation ("<i>Hippotigris</i>,") left a
|
|
42
|
+
// space in front of it.
|
|
43
|
+
s = s.replace(/ ([,.;:!?])/g, "$1");
|
|
41
44
|
return s;
|
|
42
45
|
}
|
|
43
46
|
|