Skip to content

feat: modular primitive architecture#481

Open
tejaskash wants to merge 3 commits intomainfrom
feat/primitive-architecture
Open

feat: modular primitive architecture#481
tejaskash wants to merge 3 commits intomainfrom
feat/primitive-architecture

Conversation

@tejaskash
Copy link
Contributor

Summary

Introduces BasePrimitive — an abstract base class that all resource types (agent, memory, credential, gateway, gateway-target) extend. Each primitive is a self-contained class in src/cli/primitives/ that owns the full add/remove lifecycle for its resource type.

  • BasePrimitive defines the contract: add(), remove(), previewRemove(), getRemovable(), registerCommands(), addScreen()
  • AgentPrimitive absorbs handleAddAgent, handleCreatePath, handleByoPath, removeAgent
  • MemoryPrimitive absorbs createMemory, removeMemory, getRemovableMemories
  • CredentialPrimitive absorbs createCredential, removeCredential, resolveCredentialStrategy; adds OAuth2 discriminated union, managed credential protection, gateway target reference checking
  • GatewayPrimitive absorbs createGatewayFromWizard, removeGateway; adds unassigned targets, OAuth auto-credential, allowedScopes
  • GatewayTargetPrimitive absorbs createToolFromWizard, removeMcpTool (now removeGatewayTarget); adds external endpoint support
  • Registry (registry.ts) exports singleton instances and ALL_PRIMITIVES array
  • CLI commands (add, remove) are now thin wrappers that delegate to primitives via registerCommands()
  • TUI hooks use primitives directly instead of scattered operation functions
  • Deleted 9 operation files that were absorbed into primitives, plus their obsolete tests

Note: The RefactorTest/ directory is a test project created during development and should be removed before merge.

Test plan

  • TypeScript compilation passes (tsc --noEmit)
  • All 157 test files pass (1865 tests, 0 failures)
  • ESLint passes with no warnings
  • Pre-commit hooks pass (lint, prettier, typecheck)
  • Manual: agentcore add agent interactive flow generates code + updates agentcore.json
  • Manual: agentcore add memory --name test --strategies SEMANTIC --json produces correct output
  • Manual: agentcore remove memory --name test --json removes memory
  • Manual: TUI agentcore add shows all resource types with working wizards

Refactor all resource types (agent, memory, credential, gateway,
gateway-target) into self-contained primitive classes that own the
full add/remove lifecycle. Each primitive extends BasePrimitive and
implements add(), remove(), previewRemove(), getRemovable(), and
registerCommands(). Primitives absorb scattered operation functions
and register their own CLI subcommands via a registry loop.
…e issues

Absorb gateway integration changes from main into the primitive architecture:
- Update GatewayPrimitive with unassigned targets, OAuth auto-credential, allowedScopes
- Update GatewayTargetPrimitive with mcp-tool→gateway-target rename and external endpoints
- Update CredentialPrimitive with OAuth2 discriminated union, managed credential protection,
  gateway target reference checking, and hyphen→underscore env var fix
- Remove VPC-related code from AgentPrimitive (removed upstream)
- Break circular dependency: validate.ts no longer imports from primitive registry
- Delete obsolete test files for absorbed modules, fix test mocks and expectations
@tejaskash tejaskash requested a review from a team March 2, 2026 23:44
@github-actions github-actions bot added the size/xl PR size: XL label Mar 2, 2026
Test project accidentally included in the primitive architecture commit.
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.92% 3389 / 7895
🔵 Statements 42.54% 3570 / 8391
🔵 Functions 43.98% 688 / 1564
🔵 Branches 46.05% 2188 / 4751
Generated in workflow #813 for commit dde03cf by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant