@polycode-projects/the-mechanical-code-talker 6.0.6 → 6.0.7
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": "6.0.
|
|
3
|
+
"version": "6.0.7",
|
|
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.",
|
package/src/domain/ask.mjs
CHANGED
|
@@ -2443,7 +2443,10 @@ function evalCommitFilter(graph, ast) {
|
|
|
2443
2443
|
function evalTemporal(graph, ast, opts) {
|
|
2444
2444
|
const inner = evalSet(graph, ast.inner, opts);
|
|
2445
2445
|
const ids = new Set(inner.map((i) => i.id));
|
|
2446
|
-
if (!ids.size)
|
|
2446
|
+
if (!ids.size) {
|
|
2447
|
+
const emptied = emptiedBranch(graph, ast.inner, opts);
|
|
2448
|
+
return { compositeKind: "temporal", matches: [], entityType: ast.entityType, innerCount: 0, ...(emptied ? { emptied } : {}) };
|
|
2449
|
+
}
|
|
2447
2450
|
// reverseOverSet(touches) collects touching commits across both grains.
|
|
2448
2451
|
const commits = reverseOverSet(graph, "touches", "Commit", ids);
|
|
2449
2452
|
const dateOf = (c) => String((c.attributes || []).find((a) => a.key === "date")?.value || "");
|
|
@@ -2455,9 +2458,11 @@ function evalTemporal(graph, ast, opts) {
|
|
|
2455
2458
|
* recorded site for the renderer to cite. */
|
|
2456
2459
|
function evalWhereSet(graph, ast, opts) {
|
|
2457
2460
|
const matches = evalSet(graph, ast.inner, opts);
|
|
2461
|
+
const emptied = matches.length ? null : emptiedBranch(graph, ast.inner, opts);
|
|
2458
2462
|
return {
|
|
2459
2463
|
compositeKind: "whereSet", matches, entityType: ast.entityType,
|
|
2460
2464
|
sites: matches.map((ind) => (ind.attributes || []).find((a) => a.key === "site")?.value || null),
|
|
2465
|
+
...(emptied ? { emptied } : {}),
|
|
2461
2466
|
};
|
|
2462
2467
|
}
|
|
2463
2468
|
|
|
@@ -3021,16 +3026,16 @@ function heldBranchQuestion(held) {
|
|
|
3021
3026
|
* can mistake for the answer, however carefully the rest of the sentence
|
|
3022
3027
|
* excludes it. Null where the step may claim nothing, which leaves the caller
|
|
3023
3028
|
* its own honest empty. */
|
|
3024
|
-
function emptiedBranchLine(emptied, entityType,
|
|
3029
|
+
function emptiedBranchLine(emptied, entityType, { branchNote = null, verdictTail = "" } = {}) {
|
|
3025
3030
|
if (!emptied?.held) return null;
|
|
3026
3031
|
const step = stepPhrases(emptied.step);
|
|
3027
3032
|
if (!step) return null;
|
|
3028
3033
|
const held = emptied.held;
|
|
3029
3034
|
const phrases = heldPhrases(held);
|
|
3030
3035
|
const one = held.count === 1;
|
|
3031
|
-
const branch = heldBranchQuestion(held) ||
|
|
3036
|
+
const branch = heldBranchQuestion(held) || branchNote;
|
|
3032
3037
|
const verdict = entityType ? `no ${nounFor(entityType, 2)} match that` : "nothing matches that";
|
|
3033
|
-
return `${verdict}. ${one ? phrases.one : phrases.many}, but ${one ? step.one : step.many}.${branch ? ` ${branch}` : ""}`;
|
|
3038
|
+
return `${verdict}${verdictTail}. ${one ? phrases.one : phrases.many}, but ${one ? step.one : step.many}.${branch ? ` ${branch}` : ""}`;
|
|
3034
3039
|
}
|
|
3035
3040
|
|
|
3036
3041
|
/** The empty line for a composition whose first clause held nothing: the
|
|
@@ -3048,12 +3053,29 @@ function emptyClauseLine(leaf) {
|
|
|
3048
3053
|
/** The last resort, and the one sentence that must never over-claim: an index
|
|
3049
3054
|
* holding none of a kind and an index holding plenty of it are different
|
|
3050
3055
|
* answers, so they get different words. */
|
|
3051
|
-
function
|
|
3056
|
+
function emptyKindClause(graph, entityType) {
|
|
3052
3057
|
const total = kindPopulation(graph, entityType);
|
|
3053
|
-
if (total === null) return `nothing in the index matches that${entityType ? ` (${nounFor(entityType, 2)})` : ""}
|
|
3054
|
-
if (total === 0) return `no ${nounFor(entityType, 2)} in this index
|
|
3055
|
-
if (total === 1) return `the index has 1 ${nounFor(entityType, 1)}, and it does not match that
|
|
3056
|
-
return `the index has ${total} ${nounFor(entityType, 2)}, and none of them matches that
|
|
3058
|
+
if (total === null) return `nothing in the index matches that${entityType ? ` (${nounFor(entityType, 2)})` : ""}`;
|
|
3059
|
+
if (total === 0) return `no ${nounFor(entityType, 2)} in this index`;
|
|
3060
|
+
if (total === 1) return `the index has 1 ${nounFor(entityType, 1)}, and it does not match that`;
|
|
3061
|
+
return `the index has ${total} ${nounFor(entityType, 2)}, and none of them matches that`;
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
const emptyKindLine = (graph, entityType) => `${emptyKindClause(graph, entityType)}.`;
|
|
3065
|
+
|
|
3066
|
+
/** The empty answer for a lane that has to resolve an inner set before it can
|
|
3067
|
+
* answer anything at all. It gets the same emptied-branch receipt every other
|
|
3068
|
+
* empty composition gets, and carries the lane's own consequence — no location
|
|
3069
|
+
* to cite, no change history to date — on the end of the verdict, so the reader
|
|
3070
|
+
* is told what emptied the set and what that costs them in one sentence. */
|
|
3071
|
+
function emptyInnerSetLine(graph, parsed, result, consequence, fallbackHint) {
|
|
3072
|
+
const branchNote = coverageGrainNote(parsed.inner, result.entityType) || qualifierBranchNote(parsed.inner);
|
|
3073
|
+
const receipt = emptiedBranchLine(result.emptied, result.entityType, { branchNote, verdictTail: consequence });
|
|
3074
|
+
if (receipt) return receipt;
|
|
3075
|
+
const lead = result.emptied?.leaf
|
|
3076
|
+
? emptyClauseLine(result.emptied.leaf)
|
|
3077
|
+
: emptyKindClause(graph, result.entityType);
|
|
3078
|
+
return `${lead}${consequence}. ${branchNote || fallbackHint}`;
|
|
3057
3079
|
}
|
|
3058
3080
|
|
|
3059
3081
|
function renderComposite(parsed, result, graph) {
|
|
@@ -3267,7 +3289,8 @@ function renderComposite(parsed, result, graph) {
|
|
|
3267
3289
|
const setNoun = result.entityType ? nounFor(result.entityType, n || 2) : (n === 1 ? "entity" : "entities");
|
|
3268
3290
|
const wasWere = n === 1 ? "was" : "were";
|
|
3269
3291
|
if (!n) {
|
|
3270
|
-
|
|
3292
|
+
const lead = emptyInnerSetLine(graph, parsed, result, ", so there is no change history to date", touchesRephraseHint(graph));
|
|
3293
|
+
return { content: lead, miss: true, ambiguous: false, matches: [] };
|
|
3271
3294
|
}
|
|
3272
3295
|
if (!result.matches.length) {
|
|
3273
3296
|
return { content: `no recorded commit touched the ${n} ${setNoun} in that set in this index. ${touchesRephraseHint(graph)}`, miss: true, ambiguous: false, matches: [] };
|
|
@@ -3290,9 +3313,9 @@ function renderComposite(parsed, result, graph) {
|
|
|
3290
3313
|
// said out loud rather than dropped, so the count of answers always matches
|
|
3291
3314
|
// the count of entities the clause resolved to.
|
|
3292
3315
|
if (result.compositeKind === "whereSet") {
|
|
3293
|
-
const setNoun = result.entityType ? nounFor(result.entityType, 2) : "entities";
|
|
3294
3316
|
if (!result.matches.length) {
|
|
3295
|
-
|
|
3317
|
+
const lead = emptyInnerSetLine(graph, parsed, result, ", so there is no location to cite", `${compositionalHint()}.`);
|
|
3318
|
+
return { content: lead, miss: true, ambiguous: false, matches: [] };
|
|
3296
3319
|
}
|
|
3297
3320
|
const lines = result.matches.map((ind, i) => definedAtLine(ind, result.sites[i])
|
|
3298
3321
|
|| `${ind.label} has no recorded code location in this index.`);
|
|
@@ -3308,7 +3331,7 @@ function renderComposite(parsed, result, graph) {
|
|
|
3308
3331
|
// to them, instead of a blanket "nothing matches" beside an unrelated
|
|
3309
3332
|
// recovery.
|
|
3310
3333
|
const branchNote = coverageGrainNote(parsed, result.entityType) || qualifierBranchNote(parsed);
|
|
3311
|
-
const receipt = emptiedBranchLine(result.emptied, result.entityType, branchNote);
|
|
3334
|
+
const receipt = emptiedBranchLine(result.emptied, result.entityType, { branchNote });
|
|
3312
3335
|
if (receipt) return { content: receipt, miss: true, ambiguous: false, matches: [] };
|
|
3313
3336
|
const hint = branchNote || touchesRephraseHint(graph);
|
|
3314
3337
|
const lead = result.emptied?.leaf
|
|
@@ -68,9 +68,9 @@ async function runFetch(fetchImpl, url, init, networkFailureMessage) {
|
|
|
68
68
|
|
|
69
69
|
/** One retry, on a 5xx only, for the one call the spec singles out.
|
|
70
70
|
* `deleteAll`'s purge is query-then-mark and idempotent, so a retried
|
|
71
|
-
*
|
|
71
|
+
* delete just re-marks whatever the first attempt already reached; it
|
|
72
72
|
* never double-applies. Every other mutation gets one attempt only:
|
|
73
|
-
* retrying a PUT or a keyed
|
|
73
|
+
* retrying a PUT or a keyed delete past a 5xx is a caller decision, not
|
|
74
74
|
* this backend's. */
|
|
75
75
|
async function fetchWithOneRetryOn5xx(fetchImpl, url, init, networkFailureMessage) {
|
|
76
76
|
const first = await runFetch(fetchImpl, url, init, networkFailureMessage);
|
|
@@ -141,12 +141,15 @@ export function createHttpRowBackend({ apiBase, sessionKey, fetchImpl = fetch }
|
|
|
141
141
|
|
|
142
142
|
async deleteRows(rowKeys) {
|
|
143
143
|
assertOpen();
|
|
144
|
-
|
|
144
|
+
// CloudFront's OAC signs a DELETE as body-less, so the edge can never
|
|
145
|
+
// pass a body-carrying DELETE through. POST .../rows/delete is the
|
|
146
|
+
// edge-safe spelling of the same call.
|
|
147
|
+
await mutate(`/api/sessions/${sessionKey}/rows/delete`, { method: "POST", body: { rowKeys } });
|
|
145
148
|
},
|
|
146
149
|
|
|
147
150
|
async deleteAll() {
|
|
148
151
|
assertOpen();
|
|
149
|
-
await mutate(`/api/sessions/${sessionKey}/rows`, { method: "
|
|
152
|
+
await mutate(`/api/sessions/${sessionKey}/rows/delete`, { method: "POST", body: { all: true } }, { retryOn5xx: true });
|
|
150
153
|
},
|
|
151
154
|
|
|
152
155
|
async readMeta(key) {
|