[AI-stack P3] plugin-ai: ai runtime-registry codegen target for netscript generate#381
Merged
Merged
Conversation
…ate (#261) Populate plugins/ai/scaffold.runtime.json with two runtime-registry targets consumed by the shared collector: ai-tools (name-keyed by descriptor.name) and ai-agents (stem-keyed factory map). Add a thin CLI + AI-specific compiler that own only the AI resource specifics and delegate all path math + module assembly to renderRegistryModule from @netscript/plugin/cli - no forked generator logic. Tools use AiToolDefinition from @netscript/ai/tools; agents use AgentLoop from @netscript/ai/agent (exported factory functions, keyed by file stem). Type- predicate guards only - no as/any casts. Missing/empty resource dirs short- circuit (guards a LocalProjectFiles NotFound-on-iterate crash). Skills registry target deferred to #290 (no skill scaffolder shipped in P2). Closes #261 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012wKHquACkXnWPDgJYhhFjN
rickylabs
marked this pull request as ready for review
July 3, 2026 23:46
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.
[AI-stack P3] plugin-ai: ai runtime-registry codegen target for
netscript generateWires
plugins/aiinto the shared runtime-registry codegen sonetscript generateemits static_registry.tsmaps for user-authored AI resources, the same wayplugins/workers/plugins/triggersdo. Shared engine untouched — this slice only supplies a manifest + a thin CLI that delegates torenderRegistryModulefrom@netscript/plugin/cli.Closes #261
What ships
plugins/ai/scaffold.runtime.json— two targets consumed by the sharedregenerateCopiedRuntimeRegistriescollector:ai-tools→ai/tools/*.ts→.netscript/generated/plugin-ai/tools.registry.ts,ReadonlyMap<string, AiToolDefinition>keyed bydescriptor.name, type from@netscript/ai/tools.ai-agents→ai/agents/*.ts→.netscript/generated/plugin-ai/agents.registry.ts,ReadonlyMap<string, () => AgentLoop>keyed by file stem, type from@netscript/ai/agent.src/cli/ai-registry-compiler.ts— owns only the AI specifics (discovered dir, import line, entry/map shape); delegates path math + module assembly torenderRegistryModule. No forked generator logic.src/cli/generate-runtime-registries.ts— thin CLI matching the triggers/workers pattern (--project-root/--manifest/--profile/--official-samplesparity), loops manifest targets through the compiler.src/cli/ai-registry-compiler.test.ts— 3 in-memory unit tests: name-keyed tools (nested +_registryexclusion), stem-keyed agents (mod.tsexclusion), empty/missing-dir short-circuit; plus a generated-output no-unsound-cast assertion.Grounded decisions (issue body predated P2; 3 assumptions corrected)
ai/skillsdir /SkillDefinitiontype (README defers--mcp/skill-loader to [AI-stack P2-follow] plugins/ai --mcp / skill scaffolder + e2e variant (needs E5 SkillLoaderPort) #290, needs E7 SkillLoaderPort). Not invented here.AgentLoop, so the registry is stem-keyed() => AgentLoop, whichrenderRegistryModule's callback design supports.AiToolDefinitionfrom@netscript/ai/tools(issue guessedToolDefinition)..netscript/generated/plugin-ai/*.registry.tsfor sibling-consistency with workers/triggers generated output.as/anyin shipped runtime code — type-predicate guards only. The oneJSON.parse(...) as RuntimeManifestin the CLI is the verbatim manifest-deserialization boundary pattern used by the merged triggers CLI (plugins/triggers/src/cli/generate-runtime-registries.ts:139).Drift (for the record)
LocalProjectFiles.listFilesNotFound-on-iterate for a wholly-absent dir (Windows) would crash the generator; guarded locally (catch Deno.errors.NotFound → []) since the shared adapter is out of scope. Worth a follow-up fix in the shared adapter.defineAiTool, but the real builder is a string-arg fluent builder — noted, not in scope here.Validation (author + independent separate-session eval both green)
plugins/aiCLI tests: 3/3 pass; fullplugins/aisuite: 14/14.run-deno-checkonplugins/ai(28 files): 0 findings; author's fulldeno task check(2059 files): 0.run-deno-fmt/run-deno-lint: 0 findings each.deno task arch:check:aiFAIL=0 (pre-existing WARN/INFO only, none in new files).@netscript/ai/tools+@netscript/ai/agenttypes; missing/empty dir writes nothing (no crash); collector-exact invocation generates both registries.deno.lockchurn; diff = 1 manifest edit + 3 new CLI files.Merge-readiness note
The expensive
deno task e2e:cli run scaffold.runtime --cleanupgate (end-to-end collector wiring in a real scaffold) is the remaining merge-gate — recommend running it at merge time.🤖 Generated with Claude Code
https://claude.ai/code/session_012wKHquACkXnWPDgJYhhFjN