Skip to content

feat: write agent docs natively in C#, Java, Kotlin and Rust - #675

Merged
dmealing merged 5 commits into
mainfrom
fm/mo-130-agent-docs-native
Nov 28, 2026
Merged

dmealing merged 5 commits into
mainfrom
fm/mo-130-agent-docs-native

Conversation

@dmealing

Copy link
Copy Markdown
Member

What Changed

  • Adds native agent-docs commands with no Node: dotnet meta agent-docs (C#), mvn metaobjects:agent-docs (Java and Kotlin) and cargo meta agent-docs (Rust, new). Each writes .metaobjects/AGENTS.md, the metaobjects-* skills, the .agent-context.json manifest and the root AGENTS.md/CLAUDE.md import, byte-for-byte matching the Node and Python output. Before this, the C# and Maven commands printed "run npx meta agent-docs" and exited 1, and Rust had no command.
  • Moves the shipped agent-context tree into agent-context-shipped/ with a manifest. C# and the Maven plugin embed it at build time. The Rust crate and Python wheel keep committed copies, refreshed by scripts/sync-agent-context-shipped.sh (replaces sync-python-agent-context.sh). The gates lane (gate_agent_context_copy_drift) fails when either copy is stale.
  • Shipped C#, Java and Kotlin skill references now tell agents to run the port's own command instead of npx meta agent-docs. The gen/verify staleness nudge in C# and Java names the port's own command too. Every port's tests reproduce every fixtures/agent-context-conformance/ stack, so the corpus gates all ports.

Changelog fragment: changelog.d/agent-docs-native-every-port.md.

Validation

Risk Assessment

⚠️ Medium: The native writers match the Python reference in the paths I traced and the shipped-tree copies are byte-identical, but the Maven goal as documented will likely write and wire agent files into every module of a multi-module build, and the remaining findings are minor.

Testing

Baseline scripts/ci-local.sh --affected --strict-toolchains already passed at this commit and covers broad regression; no source edits were made here. Drove the built C# agent-docs CLI live with no Node on PATH for three scenarios: client-only on a fresh project (pass, csharp|react), recorded-stack refresh keeping java when only --client is given (pass), and unknown-client refusal (pass). The focused AgentDocs test filter passed 23/23. Scratch dirs were removed.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
C# agent-docs with --client only on a fresh project writes csharp+react stack with no Node on PATH ✅ pass live live run of built MetaObjects.Cli.dll agent-docs --client react under env -i PATH=/usr/bin:/bin; exit 0; .metaobjects/.agent-context.json servers=[csharp] clients=[react]; .claude/skills tree writte…
C# agent-docs --client only on a project recorded as java keeps the recorded server ✅ pass live live run: agent-docs --server java then agent-docs --client react in same temp project; manifest servers=[java] clients=[react]
Adversarial: unknown --client value is refused without writing files ✅ pass live live run agent-docs --client bogus; stderr 'unknown stack value: --client bogus (known: react, tanstack, angular)', exit 2, empty output dir

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

📌 **Review** - 9 issues (2 warnings, 7 infos) left as notes at the round cap
  • ⚠️ server/csharp/MetaObjects.Cli/AgentDocsCommand.cs:489 - With --client and no --server, the native agent-docs commands fail. The default server (the recorded stack, else the port's language) only applies when BOTH lists are empty. So dotnet meta agent-docs --client react builds the stack id react, which no manifest entry has, and exits 2 with no shipped agent files for the stack "react". This change documents exactly that invocation for C# users: server/csharp/README.md:33 (dotnet meta agent-docs [--client react] [--out <dir>]), agent-context/skills/metaobjects-audit/references/csharp.md:127 (dotnet meta agent-docs [--client <fw>] [--out <dir>]), agent-context/skills/metaobjects-codegen/references/csharp.md:332-335 ("Add --client <fw> for a web client") and the Usage text at AgentDocsCommand.cs:560 ("(default --server csharp)"). The TypeScript CLI resolves the server by detection when only clients are given (init.ts stackForAgentContext/resolveStack). Same check in other ports: server/java/maven-plugin/src/main/java/com/metaobjects/mojo/AgentDocsWriter.java:578, server/rust/metaobjects-cli/src/agent_docs.rs:630, and the Python reference server/python/src/metaobjects/agent_context/agent_docs.py:113. Fix: when servers is empty, take the prior manifest's servers, else DEFAULT_SERVER, whatever the clients are. Keep both-empty reusing the recorded clients too. Add a --client-only test per port.
  • ℹ️ server/csharp/MetaObjects.Cli/MetaObjects.Cli.csproj:27 - The EmbeddedResource comment had lost its command name ("so writes them"). It now reads "so dotnet meta agent-docs writes them with no Node on the path."

🔧 Fix applied.
📌 Review round cap reached: 9 issues (2 warnings, 7 infos) left unresolved as notes (no further fix round):

  • ⚠️ server/csharp/MetaObjects.Cli/AgentDocsCommand.cs:489 - With --client and no --server, the native agent-docs commands fail. The default server (the recorded stack, else the port's language) only applies when BOTH lists are empty. So dotnet meta agent-docs --client react builds the stack id react, which no manifest entry has, and exits 2 with no shipped agent files for the stack "react". This change documents exactly that invocation for C# users: server/csharp/README.md:33 (dotnet meta agent-docs [--client react] [--out <dir>]), agent-context/skills/metaobjects-audit/references/csharp.md:127 (dotnet meta agent-docs [--client <fw>] [--out <dir>]), agent-context/skills/metaobjects-codegen/references/csharp.md:332-335 ("Add --client <fw> for a web client") and the Usage text at AgentDocsCommand.cs:560 ("(default --server csharp)"). The TypeScript CLI resolves the server by detection when only clients are given (init.ts stackForAgentContext/resolveStack). Same check in other ports: server/java/maven-plugin/src/main/java/com/metaobjects/mojo/AgentDocsWriter.java:578, server/rust/metaobjects-cli/src/agent_docs.rs:630, and the Python reference server/python/src/metaobjects/agent_context/agent_docs.py:113. Fix: when servers is empty, take the prior manifest's servers, else DEFAULT_SERVER, whatever the clients are. Keep both-empty reusing the recorded clients too. Add a --client-only test per port.
  • ℹ️ server/csharp/MetaObjects.Cli/MetaObjects.Cli.csproj:27 - The EmbeddedResource comment had lost its command name ("so writes them"). It now reads "so dotnet meta agent-docs writes them with no Node on the path."
  • ⚠️ server/java/maven-plugin/src/main/java/com/metaobjects/mojo/AgentDocsMojo.java:26 - The @Mojo has no aggregator = true, and outputDirectory defaults to ${project.basedir}. Maven runs a directly invoked non-aggregator goal once for each reactor project. So the documented mvn metaobjects:agent-docs at the root of a multi-module build writes .metaobjects/AGENTS.md, the .claude/skills tree and the manifest into the parent and into every module. With the default wireRoot, it also creates or edits AGENTS.md and CLAUDE.md in each. The old stub only failed, so this fan-out is new. Sites that give the same invocation: server/java/README.md:158-160 (usage), agent-context/skills/metaobjects-audit/references/java.md:126 and kotlin.md:131 (shipped agent instructions), server/java/metadata/src/main/java/com/metaobjects/agentcontext/AgentContextScaffold.java:76 (stale nudge). Fix: make the goal an aggregator, or write only at the execution root unless -Dmetaobjects.outputDirectory is set. Note that the nudge reads the manifest from the module basedir (AbstractMetaDataMojo.java:1059).
  • ℹ️ server/csharp/MetaObjects.Cli/AgentDocsCommand.cs:142 - CanonicalStack maps aliases but keeps the caller's order and duplicates, and the manifest records those lists. TypeScript records makeStack's output, which is deduplicated and in canonical order. For --server kotlin --server java --client tanstack --client react (the example in agent-context-shipped/README.md), a native port writes servers:[kotlin,java] and clients:[tanstack,react]. Node writes [java,kotlin] and [react,tanstack]. The same happens with -Dmetaobjects.servers=kotlin,java, and --server cs... --server dotnet records a duplicate. This contradicts the changelog's byte-for-byte manifest claim, and the manifest is rewritten whenever the tool changes. Sibling sites: server/java/maven-plugin/src/main/java/com/metaobjects/mojo/AgentDocsWriter.java:188-211, server/rust/metaobjects-cli/src/agent_docs.rs:186-214, server/python/src/metaobjects/agent_context/shipped.py:76 (the reference all three copy). Fix: filter SERVER_LANGS and CLIENT_FRAMEWORKS by the collected values before returning.
  • ℹ️ docs/llms/llms-full.txt:45 - This LLM-facing doc still says "the JVM and C# CLIs redirect to the Node CLI", and docs/llms/llms.txt:37 says the same. The change removes those redirects. An LLM reader would therefore tell a C#, Java or Kotlin adopter to install Node, which the intent rules out. Neither file mentions cargo meta agent-docs. Update both to name each port's own command.
  • ℹ️ docs/RELEASING.md:301 - C# and the Maven plugin now embed the repo-root agent-context-shipped/ tree, which lies outside server/csharp and server/java. The publish-what-changed rule publishes a registry only when it has a changed product file. A later change to skill text alone changes files under the npm, Python and Rust directories, so a release judged by port directory can leave NuGet and Maven shipping old agent files. Add one sentence to the rule: agent-context-shipped/ is a shipped product file of NuGet and Maven Central. See server/csharp/MetaObjects.Cli/MetaObjects.Cli.csproj:29 and server/java/maven-plugin/pom.xml:58.
  • ℹ️ server/csharp/MetaObjects.Cli.Tests/AgentDocsCommandTests.cs:159 - The "native stamp satisfies the staleness check" assertion builds a Manifest by hand with Release and compares it with Release. It never feeds the written stamp to the check, so it passes whatever the writer stamps. It also never covers the real default path: Run(version: null) stamps EjectCommand.ToolVersion(), while gen and verify compare against AgentContextStalenessCheck.CurrentVersion(), which reads a different assembly and keeps +sha. Run with no version, read generatedBy from the written manifest, and check it against CurrentVersion(). The sibling at server/java/maven-plugin/src/test/java/com/metaobjects/mojo/AgentDocsWriterTest.java:162 also hand-builds the manifest with "1.3.0" and should parse the written one.
  • ℹ️ docs/features/cli.md:963 - Fixed a stale statement inline. It said only meta agent-docs and Python add the agent-pages section. It now says every port's agent-docs command does.
  • ℹ️ server/java/metadata/src/main/java/com/metaobjects/agentcontext/AgentContextScaffold.java:99 - Fixed a stale Javadoc inline (comment only). It said the manifest is always stamped by the Node CLI and that other ports redirect to it. It now says both Node and the Maven goal stamp an npm-line version.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
C# agent-docs with --client only on a fresh project writes csharp+react stack with no Node on PATH ✅ pass live live run of built MetaObjects.Cli.dll agent-docs --client react under env -i PATH=/usr/bin:/bin; exit 0; .metaobjects/.agent-context.json servers=[csharp] clients=[react]; .claude/skills tree writte…
C# agent-docs --client only on a project recorded as java keeps the recorded server ✅ pass live live run: agent-docs --server java then agent-docs --client react in same temp project; manifest servers=[java] clients=[react]
Adversarial: unknown --client value is refused without writing files ✅ pass live live run agent-docs --client bogus; stderr 'unknown stack value: --client bogus (known: react, tanstack, angular)', exit 2, empty output dir
  • scripts/ci-local.sh --affected --strict-toolchains
  • cd server/csharp && dotnet test MetaObjects.Cli.Tests --filter "FullyQualifiedName~AgentDocs" (23 passed, includes A_client_alone_takes_the_recorded_server_else_csharp)
  • Live: built MetaObjects.Cli.dll, ran agent-docs --client react in a fresh temp project under $DEV_SCRATCH with env -i PATH=/usr/bin:/bin (no Node); manifest servers=[csharp], clients=[react]
  • Live: agent-docs --server java then agent-docs --client react in the same project; manifest servers=[java], clients=[react]
  • Live adversarial: agent-docs --client bogus in a fresh project; stderr 'unknown stack value: --client bogus (known: react, tanstack, angular)', exit 2, no files written
  • Removed scratch directories; worktree git status clean
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…and Rust

dotnet meta agent-docs, mvn metaobjects:agent-docs (Java and Kotlin) and a new
cargo meta agent-docs now write .metaobjects/AGENTS.md, the metaobjects-* skills,
the .agent-context.json manifest and the root AGENTS.md/CLAUDE.md import with no
Node. They replace the "use npx meta agent-docs" stubs. Each port copies one stack out of
the shipped agent-context-shipped/ tree (C# and the Maven plugin embed it at build
time; the Rust crate keeps a committed copy like the Python wheel), using
Python's re-run rules. Every port's tests reproduce every
fixtures/agent-context-conformance/ stack and the agent-pages-pointer corpus, so
the corpus is now a cross-port gate.

The sync script is generalized to scripts/sync-agent-context-shipped.sh (Python
and Rust copies), and the gates lane checks both copies. The C#/Java staleness
nudge names the port's own command, and the shipped C#, Java and Kotlin skill
references no longer send agents to npx.
@dmealing
dmealing merged commit b57389a into main Nov 28, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-130-agent-docs-native branch November 28, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant