Pass knowledge to a run without writing a file - #140
Open
DavertMik wants to merge 4 commits into
Open
Conversation
--knowledge takes facts on the command line and keeps them in memory for
that run only, so credentials and one-off test data never land in
knowledge/. Plain text applies everywhere; frontmatter scopes it the way
a knowledge file does - url: for a page, endpoint: for an API endpoint -
and the rest of the file grammar follows, including wait/waitForElement
and ${env.VAR} interpolation. The flag repeats, since gray-matter reads
one frontmatter block per string.
KnowledgeTracker holds session entries beside the ones it loads from
disk and matches both through the same structural patterns. Its
constructor now takes an options object, which lets the API boat point
it at its own knowledge directory without a loaded web ConfigParser.
That directory was never read at runtime before, so endpoint knowledge
written by `api know` sat unused. Chief now loads it when planning an
endpoint and Curler when testing one, which is what makes --knowledge
useful for auth on the API side.
drill's --knowledge <path> becomes --save-knowledge <path>, in the CLI
and in the TUI. It saves what drilling learned rather than supplying
facts, and the two cannot share a flag on the same command.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
The flag was threaded through four option interfaces, four buildOptions functions and four addCommonOptions helpers to reach a tracker that already knew what to do with it. It now registers on the program the way --ws does: one option plus a preAction hook, both living in knowledge-tracker.ts beside the code that reads them. Commander merges parent options down through optsWithGlobals, so one registration covers every command, the mounted api/docs/prima subcommands included, and the flag can sit anywhere on the line - before the command, after it, or after variadic arguments. Prima, doc-collector and the api CLI go back to what they were; ExplorBot no longer carries a knowledge option at all. The constructor still takes one, which is what the tests use and what makes the module state a fallback rather than the only way in. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--knowledgetakes facts on the command line and keeps them in memory for that run only, so credentials and one-off test data never land inknowledge/.npx explorbot explore /pay --knowledge 'my credit card is 13213213213'Plain text applies everywhere. Frontmatter scopes it the way a knowledge file does —
url:for a page,endpoint:for an API endpoint — and the rest of the file grammar follows, includingwait/waitForElementand${env.VAR}interpolation:The flag repeats, since gray-matter reads one frontmatter block per string, so several scoped facts need several flags.
How it works
It registers once on the program root, the way
--wsdoes: one.option()plus apreActionhook, both inknowledge-tracker.tsbeside the code that reads them. Commander merges parent options down throughoptsWithGlobals, so that single registration covers every command — the mountedapi,docsandprimasubcommands included — and the flag can sit anywhere on the line: before the command, after it, or after variadic arguments. Nothing inExplorBot,Prima,DocBotorApiBotcarries a knowledge option; the three standalone boat bins get one registration line each.KnowledgeTrackerholds the parsed entries beside the ones it loads from disk and matches both through the same structural patterns — no new matching path. Its constructor takes an optional override, which is what the tests use and what keeps the module state a fallback rather than the only way in.Session entries stay out of
knowsandlistAllKnowledge, which report what is on disk. They do show in/context:knowledge, listed as--knowledge #1.The API boat now reads knowledge
knowledge/was never read at runtime by the API boat, so endpoint knowledge written byapi knowsat unused. Chief now loads it when planning an endpoint and Curler when testing one — which is what makes--knowledgeuseful for auth on the API side.This changes behaviour for existing users:
endpoint:files already on disk, andEXPLORBOT_KNOWLEDGE, now appear in Chief and Curler prompts where they previously did not.Breaking:
drill --knowledgerenamedexplorbot drill --knowledge <path>is now--save-knowledge <path>, in the CLI and in the TUI (/drill --save-knowledge). It saves what drilling learned rather than supplying facts, and the two cannot share a flag on the same command.Checks
bun test tests/unit(1084),tests/integration(80),boat/prima/tests(131),node --test tests/node/*.mjs(10), format and lint all pass. Eight new unit tests cover session parsing — no-frontmatter reaching every page and endpoint,url:andendpoint:scoping, several entries staying independent, frontmatter hints reachinggetStateParameters,${env.VAR}interpolation, nothing written to the knowledge directory — plus a round trip through the registered option proving the flag reaches a freshly built tracker.This one is worth a regression run before merge — it changes what reaches Chief and Curler prompts on every API run.
🤖 Generated with Claude Code