@polycode-projects/the-mechanical-code-talker 6.0.0 → 6.0.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/README.md +27 -0
- package/bin/tmct.mjs +61 -0
- package/package.json +1 -1
- package/src/adapters/memory/core.mjs +522 -146
- package/src/adapters/memory/corpus-bands.mjs +155 -0
- package/src/adapters/memory/dynamo-circuit-breaker.mjs +266 -0
- package/src/adapters/memory/systemic-failure.mjs +28 -0
- package/src/domain/ask.mjs +341 -75
- package/src/domain/cli-verbs.mjs +17 -0
- package/src/domain/news-feed.mjs +42 -4
- package/src/domain/retrieval-marker.mjs +120 -0
- package/src/domain/retrieval-modes.mjs +13 -0
- package/src/services/chat-session.mjs +13 -2
- package/src/services/chat.mjs +73 -16
- package/src/services/corpus-loader.mjs +222 -0
- package/src/services/subgraph-retrieval.mjs +4 -33
- package/src/surfaces/web/http-row-backend.mjs +150 -0
- package/src/surfaces/web/memory-ask-browser.bundle.js +120 -117
package/README.md
CHANGED
|
@@ -981,6 +981,18 @@ package or a bare user gets a working install in one command.
|
|
|
981
981
|
> Install-size note: tmct depends on wink-nlp's deterministic English language
|
|
982
982
|
> model (~3.8 MB installed). That model is a lookup table, not an LLM.
|
|
983
983
|
|
|
984
|
+
### Custom memory backends
|
|
985
|
+
|
|
986
|
+
Memory — the facts you teach tmct — lives behind a pluggable adapter seam. The CLI and library come with three backends: in-memory (ephemeral), SQLite (the CLI's default), and DynamoDB (for hosted deployments). You can inject a custom backend and tmct will read and write through it instead. The backend is a small async row store scoped to one session key — it needs eight methods (read, write, delete, and a couple of scalar sidecars). The published conformance suite validates that a custom backend meets the contract. See `docs/adapter-contract.md` for the full interface and `src/adapters/memory/row-backend-memory.mjs` for the reference implementation. Wire it into a session:
|
|
987
|
+
|
|
988
|
+
```js skip=illustrative-import
|
|
989
|
+
import { createSession } from "@polycode-projects/the-mechanical-code-talker";
|
|
990
|
+
import { createMyBackend } from "./my-backend.mjs";
|
|
991
|
+
|
|
992
|
+
const backend = createMyBackend(sessionKey, config);
|
|
993
|
+
const session = await createSession({ memoryBackend: backend });
|
|
994
|
+
```
|
|
995
|
+
|
|
984
996
|
### Full command reference (`tmct --help`)
|
|
985
997
|
|
|
986
998
|
`tmct --help` always prints the real, current flags. What follows is that
|
|
@@ -1194,6 +1206,21 @@ kill $SERVE_PID
|
|
|
1194
1206
|
[--graph <path>] the same thing. --graph names the graph file outright
|
|
1195
1207
|
[--config <path>] (repeatable), --config an alternate tmct.toml
|
|
1196
1208
|
tmct cli digest '{…}' architecture map + per-module context bundles
|
|
1209
|
+
```
|
|
1210
|
+
|
|
1211
|
+
`tmct corpus` loads a shared, read-only corpus band into a DynamoDB
|
|
1212
|
+
row-backend table, or clears one; the deployed turn service reads the loaded
|
|
1213
|
+
bands per query:
|
|
1214
|
+
|
|
1215
|
+
```output:help:corpus
|
|
1216
|
+
tmct corpus load <band> [--table <name>] [--source <path>] [--dry-run] load a shared, read-only corpus band (wikidata-slice, wordnet-complete,
|
|
1217
|
+
[--table <name>] conceptnet-full) into a DynamoDB row-backend table from a jsonl of
|
|
1218
|
+
wire-row-shaped facts (default table from TMCT_DYNAMO_TABLE); a
|
|
1219
|
+
source whose digest already matches the band's manifest is a no-op
|
|
1220
|
+
[--source <path>] the band's jsonl (a scripts/corpus-bands/ build output, or any jsonl
|
|
1221
|
+
in the same wire-row shape)
|
|
1222
|
+
[--dry-run] report the row count and source digest without writing anything
|
|
1223
|
+
tmct corpus clear <band> [--table <name>] physically delete every row and the manifest for one band
|
|
1197
1224
|
tmct --help show this help
|
|
1198
1225
|
```
|
|
1199
1226
|
|
package/bin/tmct.mjs
CHANGED
|
@@ -1821,6 +1821,67 @@ async function main() {
|
|
|
1821
1821
|
return;
|
|
1822
1822
|
}
|
|
1823
1823
|
|
|
1824
|
+
if (mode === "corpus") {
|
|
1825
|
+
// `tmct corpus load|clear <band>` — the credentialed operator verb pair
|
|
1826
|
+
// over the shared, read-only corpus bands (src/adapters/memory/corpus-bands.mjs,
|
|
1827
|
+
// src/services/corpus-loader.mjs). Ambient AWS credentials only (a
|
|
1828
|
+
// profile locally, OIDC in CI) — this dispatch never embeds any.
|
|
1829
|
+
const rest = process.argv.slice(3);
|
|
1830
|
+
const subcommand = rest[0];
|
|
1831
|
+
if (subcommand !== "load" && subcommand !== "clear") {
|
|
1832
|
+
process.stderr.write("tmct corpus — name an action: `tmct corpus load <band>` or `tmct corpus clear <band>`\n");
|
|
1833
|
+
process.exitCode = 1;
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
const band = rest.slice(1).find((a) => !a.startsWith("-"));
|
|
1837
|
+
if (!band) {
|
|
1838
|
+
process.stderr.write(`tmct corpus ${subcommand} — name a band: \`tmct corpus ${subcommand} <band>\`\n`);
|
|
1839
|
+
process.exitCode = 1;
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
const { strFlag } = await import("../src/services/cli-args.mjs");
|
|
1843
|
+
const tableName = strFlag(rest, "--table") || process.env.TMCT_DYNAMO_TABLE;
|
|
1844
|
+
if (!tableName) {
|
|
1845
|
+
process.stderr.write("tmct corpus — no table name given (--table <name> or TMCT_DYNAMO_TABLE)\n");
|
|
1846
|
+
process.exitCode = 1;
|
|
1847
|
+
return;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
let DynamoDBClient;
|
|
1851
|
+
let DynamoDBDocument;
|
|
1852
|
+
try {
|
|
1853
|
+
({ DynamoDBClient } = await import("@aws-sdk/client-dynamodb"));
|
|
1854
|
+
({ DynamoDBDocument } = await import("@aws-sdk/lib-dynamodb"));
|
|
1855
|
+
} catch (cause) {
|
|
1856
|
+
process.stderr.write(
|
|
1857
|
+
"tmct corpus needs \"@aws-sdk/lib-dynamodb\" (>=3) installed alongside tmct; "
|
|
1858
|
+
+ `run \`npm install @aws-sdk/lib-dynamodb\` and retry (${cause.message})\n`,
|
|
1859
|
+
);
|
|
1860
|
+
process.exitCode = 1;
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
const client = DynamoDBDocument.from(new DynamoDBClient({}));
|
|
1864
|
+
|
|
1865
|
+
if (subcommand === "load") {
|
|
1866
|
+
const source = strFlag(rest, "--source");
|
|
1867
|
+
if (!source) {
|
|
1868
|
+
process.stderr.write("tmct corpus load — name a source: `tmct corpus load <band> --source <path>`\n");
|
|
1869
|
+
process.exitCode = 1;
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
const { loadBand } = await import("../src/services/corpus-loader.mjs");
|
|
1873
|
+
const result = await loadBand({ client, tableName, band, source, dryRun: rest.includes("--dry-run") });
|
|
1874
|
+
const verb = { unchanged: "unchanged", loaded: "loaded", "dry-run": "would load" }[result.status];
|
|
1875
|
+
process.stdout.write(`tmct corpus load ${band}: ${verb} (${result.rowCount} row(s), source digest ${result.sourceDigest})\n`);
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
const { clearBand } = await import("../src/services/corpus-loader.mjs");
|
|
1880
|
+
const result = await clearBand({ client, tableName, band });
|
|
1881
|
+
process.stdout.write(`tmct corpus clear ${band}: deleted ${result.deleted} item(s)\n`);
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1824
1885
|
// An unknown mode gets the instructive usage line and exit 2. (A bare invocation
|
|
1825
1886
|
// never lands here — the argv splice above rewrote it to `chat`.)
|
|
1826
1887
|
process.stderr.write(unknownInvocationMessage(process.argv.slice(2).join(" ")));
|
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.1",
|
|
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.",
|