@polycode-projects/the-mechanical-code-talker 1.9.2 → 1.10.0

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.
Files changed (80) hide show
  1. package/README.md +441 -202
  2. package/bin/tmct.mjs +126 -1
  3. package/package.json +4 -2
  4. package/src/answer-variants.mjs +8 -36
  5. package/src/ask-browser-entry.mjs +5 -23
  6. package/src/ask-browser.bundle.js +1 -2
  7. package/src/ask-nlp.mjs +9 -23
  8. package/src/ask-vocab.mjs +139 -589
  9. package/src/ask.mjs +627 -1729
  10. package/src/chat.mjs +1684 -2872
  11. package/src/cli-args.mjs +14 -28
  12. package/src/codegraph.mjs +236 -644
  13. package/src/completions/complete.mjs +18 -62
  14. package/src/completions/graph-adapter.mjs +14 -60
  15. package/src/completions/group.mjs +12 -68
  16. package/src/completions/infer.mjs +38 -126
  17. package/src/completions/prune.mjs +17 -70
  18. package/src/completions/rank.mjs +16 -69
  19. package/src/completions/search.mjs +8 -31
  20. package/src/concept.mjs +32 -88
  21. package/src/conformance.mjs +11 -15
  22. package/src/corpus/conceptnet.mjs +31 -89
  23. package/src/corpus/templates.mjs +19 -45
  24. package/src/corpus/unknown-ingest.mjs +31 -92
  25. package/src/embed.mjs +10 -22
  26. package/src/extensions.mjs +50 -154
  27. package/src/finish.mjs +35 -91
  28. package/src/grammar/ace.mjs +16 -40
  29. package/src/grammar/assert.mjs +1 -1
  30. package/src/grammar/lexicon-core.json +1 -1
  31. package/src/grammar/lexicon.mjs +9 -27
  32. package/src/graph-merge.mjs +2 -3
  33. package/src/hash.mjs +6 -14
  34. package/src/index.mjs +6 -10
  35. package/src/init.mjs +38 -125
  36. package/src/interpret/fuzzy.mjs +10 -29
  37. package/src/interpret/merge.mjs +9 -27
  38. package/src/interpret/normalize.mjs +137 -585
  39. package/src/interpret/pipeline.mjs +23 -71
  40. package/src/interpret/strategies/ace.mjs +7 -31
  41. package/src/interpret/strategies/constructions.mjs +14 -41
  42. package/src/interpret/strategies/grammar.mjs +21 -60
  43. package/src/interpret/strategies/keywords.mjs +42 -131
  44. package/src/interpret/strategies/noise-strip.mjs +18 -89
  45. package/src/memory/bias.mjs +11 -54
  46. package/src/memory/blocks.mjs +18 -69
  47. package/src/memory/core.mjs +171 -591
  48. package/src/memory/fold.mjs +0 -0
  49. package/src/memory/inspect.mjs +7 -25
  50. package/src/memory/shacl.mjs +10 -39
  51. package/src/memory/trust.mjs +26 -127
  52. package/src/memory-ask-browser-entry.mjs +7 -30
  53. package/src/memory-ask-browser.bundle.js +1 -1
  54. package/src/paraphrase.mjs +20 -53
  55. package/src/planning.mjs +15 -157
  56. package/src/prose-nlp.mjs +4 -17
  57. package/src/prose.mjs +19 -67
  58. package/src/providers/bootstrap.mjs +1 -2
  59. package/src/providers/fixture.mjs +1 -2
  60. package/src/providers/graph-service.mjs +28 -59
  61. package/src/repository-interface.mjs +6 -8
  62. package/src/router/drive.mjs +183 -0
  63. package/src/router/goal-reasoner.mjs +66 -231
  64. package/src/router/guardrail.mjs +20 -58
  65. package/src/router/planner.mjs +15 -46
  66. package/src/router/registry.mjs +13 -43
  67. package/src/router/resolver.mjs +46 -131
  68. package/src/router/results.mjs +231 -0
  69. package/src/schema-docs.mjs +10 -27
  70. package/src/server-http.mjs +10 -19
  71. package/src/server.mjs +22 -28
  72. package/src/sessions.mjs +15 -30
  73. package/src/source-slice.mjs +5 -7
  74. package/src/source.mjs +10 -20
  75. package/src/syllogise.mjs +187 -575
  76. package/src/telemetry.mjs +3 -3
  77. package/src/toml-config.mjs +4 -4
  78. package/src/tui/app.mjs +9 -19
  79. package/src/viz.mjs +66 -123
  80. package/src/wink-model.mjs +10 -24
package/src/cli-args.mjs CHANGED
@@ -1,28 +1,21 @@
1
- // cli-args.mjs — the ONE shared argv/config resolver for bin/tmct.mjs's
2
- // subcommands. Replaces four independently hand-rolled `configFor` copies
3
- // (bin/tmct.mjs's cli-mode and serve-mode ones, chat.mjs's own, and the richer
4
- // 4-tier version inlined in chat.mjs's createSession) with a single, tested
5
- // precedence chain — built on top of toml-config.mjs's already-tested
6
- // mergeEffective/normalizeConfig (arg > toml > default), not a rebuild of it.
1
+ // cli-args.mjs — the ONE shared argv/config resolver for bin/tmct.mjs's subcommands: a
2
+ // single, tested precedence chain built on toml-config.mjs's mergeEffective/
3
+ // normalizeConfig (arg > toml > default).
7
4
  //
8
5
  // Four tiny flag helpers (pure, no I/O) plus the one async resolver:
9
6
  // strFlag(rest, names, dflt) → single value, last flag occurrence wins
10
7
  // repeatedFlag(rest, names) → every value for a repeatable flag (e.g. --graph)
11
8
  // boolFlag(rest, names) → true if any of `names` appears at all
12
9
  // enumFlag(rest, names, choices) → strFlag, validated against a closed set
13
- // (throws a clear error naming the flag + the choices — the shared shape
14
- // for a closed-choice option like `--memory-backend default|memory|sqlite`,
15
- // matching `--with-persona`'s own "unknown name" error style)
16
10
  // resolveRuntimeConfig({argv, cwd, env, gitRoot}) → the resolved repo/config
17
11
  //
18
- // Graph-path precedence (documented once, here — every subcommand shares it):
12
+ // Graph-path precedence (every subcommand shares it):
19
13
  // 1. --graph <path> (repeatable; --graph wins outright, even over env)
20
14
  // 2. TMCT_GRAPH_FILE (env)
21
15
  // 3. tmct.toml's `graph_file` / `graph_files`
22
16
  // 4. <repo>/.tmct/graph.json, where repo is --repo, else git root, else cwd
23
17
  //
24
- // Deliberately does NOT import chat.mjs (that would be circular once chat.mjs
25
- // itself is rewired to call resolveRuntimeConfig) — the git-root lookup below
18
+ // Deliberately does NOT import chat.mjs (would be circular) the git-root lookup below
26
19
  // is a small, self-contained copy of chat.mjs's own gitToplevel().
27
20
 
28
21
  import { spawnSync } from "node:child_process";
@@ -73,12 +66,9 @@ export function boolFlag(rest, names) {
73
66
  return rest.some((r) => list.includes(r));
74
67
  }
75
68
 
76
- /** Closed-choice single-value flag: `strFlag` plus validation against
77
- * `choices`. Returns `undefined` when absent (never a default the caller
78
- * decides what "absent" means, same as an omitted `strFlag` call). Throws a
79
- * clear, user-facing error naming the flag and the valid choices when a
80
- * value IS given but isn't one of them — validate-before-any-disk-write,
81
- * the same discipline `tmct init --with-persona <unknown>` already uses. */
69
+ /** Closed-choice single-value flag: `strFlag` plus validation against `choices`.
70
+ * Returns `undefined` when absent. Throws a clear, user-facing error naming the flag
71
+ * and the valid choices when a value is given but isn't one of them. */
82
72
  export function enumFlag(rest, names, choices) {
83
73
  const val = strFlag(rest, names, undefined);
84
74
  if (val !== undefined && !choices.includes(val)) {
@@ -89,20 +79,16 @@ export function enumFlag(rest, names, choices) {
89
79
  }
90
80
 
91
81
  /**
92
- * Resolve one subcommand invocation's repo root, tmct.toml, and graph
93
- * path(s) — the shared precedence chain every subcommand (chat/memory/init/
94
- * import/syllogise/serve) now funnels through instead of re-deriving it.
82
+ * Resolve one subcommand invocation's repo root, tmct.toml, and graph path(s) — the
83
+ * shared precedence chain every subcommand funnels through.
95
84
  *
96
85
  * @param {object} opts
97
- * @param {string[]} [opts.argv] the subcommand's own argv tail (already past
98
- * `tmct <mode>` — the same slice each subcommand hand-parses today).
86
+ * @param {string[]} [opts.argv] the subcommand's own argv tail (already past `tmct <mode>`)
99
87
  * @param {string} [opts.cwd]
100
88
  * @param {object} [opts.env]
101
- * @param {(cwd:string)=>string|null} [opts.gitRoot] injectable for tests,
102
- * mirrors createSession's own `gitRoot` param.
103
- * @param {object} [opts.args] extra already-parsed args to fold into
104
- * mergeEffective's "arg" tier (e.g. a subcommand's own flags) — optional,
105
- * defaults to {}.
89
+ * @param {(cwd:string)=>string|null} [opts.gitRoot] injectable for tests
90
+ * @param {object} [opts.args] extra already-parsed args folded into mergeEffective's
91
+ * "arg" tier; defaults to {}
106
92
  * @returns {Promise<{
107
93
  * repo: string, configPath: string, toml: object,
108
94
  * config: {graphFile: string, graphFiles: string[]},