Skip to main content

Component Diagrams (Level 3)

Detailed component diagrams for key subsystems within the AI Primitives Hub packages.

CLI Package Components

flowchart TB
subgraph CLI["@ai-primitives-hub/cli"]
subgraph Commands["CLI Commands"]
collCmd[Collection Commands<br/>create, validate, list, affected]
primCmd[Primitive Commands<br/>prompt, instruction, agent, skill, plugin, hook]
bundleCmd[Bundle Commands<br/>build, manifest]
initCmd[Init Command<br/>Initialize project]
sourceCmd[Source Commands<br/>add, list, remove]
hubCmd[Hub Commands<br/>add, use, list, remove, create, sync, refresh]
profileCmd[Profile Commands<br/>list, show, activate, deactivate, create, edit, publish]
targetCmd[Target Commands<br/>add, list, remove, types]
indexCmd[Index Commands<br/>build, harvest, search, shortlist, export, stats, report, eval, bench]
installCmd[Install Commands<br/>install, uninstall, update, apply]
utilCmd[Utility Commands<br/>status, doctor, explain, discover, config, version compute, completion]
end

subgraph Framework["CLI Framework"]
ctx[Context<br/>I/O abstraction]
err[RegistryError<br/>Structured errors]
fmt[Formatters<br/>Output formatting]
cmdClass[Command Class<br/>Base class]
cfg[Config Loader<br/>Target/config loading]
end

subgraph Validation["Validation"]
collVal[Collection Validation<br/>YAML schema validation]
end

subgraph Builder["Bundle Builder"]
zipBuilder[ZIP Builder<br/>Deterministic bundle creation]
end
end

FS[(File System<br/>Node.js fs)]

collCmd --> ctx
collCmd --> err
collCmd --> fmt
collCmd --> collVal

primCmd --> ctx
primCmd --> err
primCmd --> fmt

bundleCmd --> ctx
bundleCmd --> err
bundleCmd --> fmt
bundleCmd --> zipBuilder

initCmd --> ctx
initCmd --> err
initCmd --> fmt

sourceCmd --> ctx
sourceCmd --> err
sourceCmd --> fmt

hubCmd --> ctx
hubCmd --> err
hubCmd --> fmt

profileCmd --> ctx
profileCmd --> err
profileCmd --> fmt

targetCmd --> ctx
targetCmd --> err
targetCmd --> fmt

indexCmd --> ctx
indexCmd --> err
indexCmd --> fmt

installCmd --> ctx
installCmd --> err
installCmd --> fmt

utilCmd --> ctx
utilCmd --> err
utilCmd --> fmt

ctx --> FS
cfg --> FS
collVal --> FS
zipBuilder --> FS

Key Components

ComponentResponsibilityKey Files
Collection CommandsCollection scaffolding, validation, and change detectioncollection-create.ts, collection-validate.ts, collection-list.ts, collection-affected.ts
Primitive CommandsPrimitive scaffolding (7 types)prompt-create.ts, instruction-create.ts, agent-create.ts, skill-create.ts, skill-new.ts, skill-validate.ts, plugin-create.ts, hook-create.ts
Bundle CommandsBundle building and manifest generationbundle-build.ts, bundle-manifest.ts
Init CommandProject initialization and first target setupinit.ts
Source CommandsDetached source managementsource.ts
Hub CommandsHub import, activation, and synchub.ts
Profile CommandsProfile listing, activation, and publishingprofile.ts
Target CommandsTarget configurationtarget-add.ts, target-list.ts, target-remove.ts, target-types.ts
Index CommandsPrimitive index/search/shortlistindex-build.ts, index-harvest.ts, index-search.ts, index-shortlist.ts, etc.
Install CommandsBundle install, uninstall, update, applyinstall.ts, uninstall.ts, update.ts, apply.ts
Utility CommandsStatus, diagnostics, discovery, config, versionstatus.ts, doctor.ts, explain.ts, discover.ts, config-get.ts, config-list.ts, version-compute.ts, completion.ts
CLI FrameworkI/O abstraction, error handling, output formatting, command base class, config loadingframework/cli.ts, framework/context.ts, framework/error.ts, framework/output.ts, framework/command-class.ts, framework/config.ts
Collection ValidationYAML schema validationvalidate.ts
Bundle BuilderDeterministic ZIP creationbundle-build.ts

Infra Package Components

flowchart TB
subgraph Infra["@ai-primitives-hub/infra"]
subgraph Auth["Authentication"]
tokenProvider[Token Provider<br/>env / gh CLI / static]
composite[Composite Provider<br/>Strategy chain]
end

subgraph HTTP["HTTP / GitHub"]
httpClient[NodeHttpClient<br/>Redirects + proxies]
ghClient[GitHubApiClient<br/>Rate limit + retry]
ghHost[GitHub Host Helper<br/>Host predicates]
end

subgraph Adapters["Source Adapters"]
local[LocalAdapter]
github[GitHubAdapter]
awesome[AwesomeCopilotAdapter]
apm[ApmAdapter]
skills[SkillsAdapter]
localVariants[Local variants]
end

subgraph Harvester["Harvester"]
harvester[Harvester<br/>Bundle discovery]
hubHarvester[HubHarvester<br/>Hub-wide harvesting]
providers[Bundle Providers]
treeEnum[Tree Enumerator]
extractor[Extractor<br/>Primitive extraction]
blobCache[Blob Cache]
etagStore[ETag Store]
progressLog[Progress Log]
end

subgraph Search["Search Engine"]
bm25[BM25 Engine<br/>Scoring]
tokenizer[Tokenizer]
tuning[Tuning]
primitiveIndex[PrimitiveIndex<br/>Search API]
types[Search Types]
end

subgraph Storage["Storage"]
indexStore[JSON Index Store]
xdgAppStorage[XdgAppStorage<br/>XDG storage]
xdgBaseDirs[XDG Base Dirs]
end

subgraph Stores["State Stores"]
lockfile[JSON Lockfile Store]
targetState[Target State Store]
layoutConfig[Layout Config Store]
activeHub[Active Hub Store]
profileActivation[Profile Activation Store]
end

subgraph Scaffolding["Scaffolding"]
templateEngine[Template Engine]
templates[Template Files<br/>7 primitive types]
end

subgraph Writers["Writers"]
fileTreeWriter[FileTreeTargetWriter<br/>Per-target writing]
zipWriter[ZipWriter]
repoWriter[RepoScopeWriter]
defaultLayouts[Default Layouts]
end

subgraph Downloaders["Downloaders"]
assetFetcher[Asset Fetcher<br/>Release downloads]
end

subgraph Extractors["Extractors"]
zipExtractor[AdmZipBundleExtractor]
end

subgraph Clock["Clock"]
systemClock[SystemClock]
end
end

GitHubAPI[(GitHub API<br/>HTTPS)]
FS[(File System<br/>Node.js fs)]

tokenProvider --> composite
composite --> ghClient
ghClient --> httpClient
httpClient --> GitHubAPI

Adapters --> ghClient
Adapters --> httpClient
Adapters --> FS

harvester --> Adapters
harvester --> extractor
harvester --> blobCache
harvester --> etagStore
harvester --> progressLog
hubHarvester --> harvester
hubHarvester --> ghClient
providers --> harvester
treeEnum --> ghClient

searchOrch --> bm25
searchOrch --> facets
searchOrch --> indexStore

bm25 --> tokenizer
bm25 --> tuning
primitiveIndex --> bm25
primitiveIndex --> Stores

xdgAppStorage --> xdgBaseDirs
xdgAppStorage --> FS

Stores --> FS
Storage --> FS
indexStore --> FS

Scaffolding --> FS
Writers --> FS
Extractors --> FS
Downloaders --> ghClient
Downloaders --> GitHubAPI

Key Components

ComponentResponsibilityKey Files
TokenProviderAuth token resolution (env, gh, static)auth/*
NodeHttpClientNode http/https client with redirects and credential strippinghttp/node-http-client.ts
GitHubApiClientGitHub API with retry, rate-limit handling, and ETag supporthttp/github-api-client.ts
Source AdaptersSourceAdapter implementations for local and remote sourcesadapters/*
HarvesterBundle discovery and primitive extractionharvest/harvester.ts, harvest/extractor.ts
HubHarvesterHub-wide harvesting pipelineharvest/hub-harvester.ts
BM25 EngineFull-text search scoringsearch/bm25-engine.ts
PrimitiveIndexSearch API with faceting and BM25 scoringsearch/primitive-index.ts
JSON Index StorePersist primitive index to JSONstores/json-index-store.ts
XdgAppStorageXDG Base Directory-compliant AppStorage adapterstorage/xdg-app-storage.ts
State StoresLockfile, target-state, active hub, profile activationstores/*
FileTreeTargetWriterPer-target file writing with layout routingwriters/file-tree-target-writer.ts
Default LayoutsBuilt-in target layouts for vscode, vscode-insiders, copilot-cli, kiro, windsurf, claude-codewriters/default-layouts.json
Template EngineHandlebars template renderingscaffolding/template-engine.ts
Asset FetcherRelease asset downloadingdownloaders/*
AdmZipBundleExtractorZIP bundle extractionextractors/*
SystemClockClock port implementationclock/system-clock.ts

App Package Components

flowchart TB
subgraph App["@ai-primitives-hub/app"]
subgraph Collection["Collection Logic"]
readColl[Read Collection<br/>Parse and validate]
genSkill[Generate Skill<br/>Skill generation]
end

subgraph Install["Install Orchestration"]
installBundle[Install Bundle<br/>Installation logic]
uninstallBundle[Uninstall Bundle<br/>Uninstallation logic]
installPipeline[Install Pipeline<br/>Orchestration]
uninstallPipeline[Uninstall Pipeline<br/>Orchestration]
layoutResolver[Layout Resolver<br/>Layout configuration]
end

subgraph Registry["Registry Management"]
hubMgr[Hub Manager<br/>Hub configuration]
profileActivator[Profile Activator<br/>Profile logic]
userConfigPaths[User Config Paths<br/>Configuration paths]
detectUpdates[Detect Updates]
resolveBundle[Resolve Bundle]
lifecycle[Profile Lifecycle]
end

subgraph ContextDetection["Context Detection"]
detector[ContextDetector<br/>Repository detection]
end

subgraph Discovery["Discovery"]
profileGen[Profile Generator]
recommendation[Recommendation Engine]
end

subgraph Transform["Multi-Target Transform"]
registry[TransformerRegistry]
kiro[Kiro Transformer]
windsurf[Windsurf / Devin Transformer]
claude[Claude Code Transformer]
noop[Noop Transformer]
end

subgraph Search["Search Orchestration"]
exportProfile[Export Profile from Shortlist]
end

subgraph Writers["App Writers"]
fileTreeWriter[FileTreeTargetWriter]
end

subgraph Stores["App Stores"]
lockfileStore[JSON Lockfile Store]
end

subgraph Update["Update"]
checkUpdates[Check Updates]
autoUpdate[Auto Update]
logEvent[Log Event]
end
end

FS[(File System<br/>Node.js fs)]

readColl --> FS
genSkill --> FS

installBundle --> FS
uninstallBundle --> FS
installPipeline --> FS
uninstallPipeline --> FS
layoutResolver --> FS

hubMgr --> FS
profileActivator --> FS
userConfigPaths --> FS
detectUpdates --> FS
resolveBundle --> FS
lifecycle --> FS

detector --> FS
profileGen --> FS
recommendation --> FS

registry --> kiro
registry --> windsurf
registry --> claude
registry --> noop

exportProfile --> FS
fileTreeWriter --> FS
lockfileStore --> FS
checkUpdates --> FS
autoUpdate --> FS
logEvent --> FS

Key Components

ComponentResponsibilityKey Files
Read CollectionParse and validate collection YAMLcollection/read-collection.ts
Generate SkillGenerate skill from collectioncollection/generate-skill.ts
Install BundleBundle installation logicinstall/install-bundle.ts
Uninstall BundleBundle uninstallation logicinstall/uninstall-bundle.ts
Install PipelineInstallation orchestrationinstall/pipeline.ts
Uninstall PipelineUninstallation orchestrationinstall/uninstall-pipeline.ts
Layout ResolverLayout configuration resolutioninstall/layout-resolver.ts
Hub ManagerHub configuration managementregistry/hub-manager.ts
Profile ActivatorProfile activation logicregistry/activate-registry-profile.ts
User Config PathsUser configuration pathsregistry/user-config-paths.ts
Detect UpdatesDetect bundle updatesregistry/detect-updates.ts
Resolve BundleResolve bundle for installregistry/resolve-installation-bundle.ts
Profile LifecycleCreate/edit/delete profilesregistry/profile-lifecycle.ts
Context DetectorRepository context detectioncontext-detection/detector.ts
Profile GeneratorGenerate profile from contextdiscovery/profile-generator.ts
Recommendation EngineRecommend primitives from contextdiscovery/recommendation-engine.ts
Transformer RegistryRegistry of per-target content transformerstransform/transformer-registry.ts
Kiro TransformerKiro-specific content transformtransform/transformers/kiro-transformer.ts
Windsurf TransformerWindsurf / Devin transformtransform/transformers/windsurf-transformer.ts
Claude Code TransformerClaude Code transformtransform/transformers/claude-code-transformer.ts
Export ProfileExport shortlist to profilesearch/export-profile.ts
FileTreeTargetWriterApp-level writer compositionwriters/file-tree-writer.ts
JSON Lockfile StoreApp-level lockfile storestores/json-lockfile-store.ts
Check UpdatesUpdate checking orchestrationupdate/check-updates.ts
Auto UpdateAuto-update orchestrationupdate/auto-update.ts

Core Package Components

flowchart TB
subgraph Core["@ai-primitives-hub/core"]
subgraph Domain["Domain Types"]
bundle[Bundle Types<br/>BundleManifest, BundleRef]
collection[Collection Types<br/>Collection, CollectionItem]
primitive[Primitive Types<br/>Primitive, PrimitiveKind]
hub[Hub Types<br/>HubConfig, HubSource]
install[Install Types<br/>Target, Installable, CopilotFileType]
registry[Registry Types<br/>RegistryConfig, BundleSpec]
scaffold[Scaffold Types<br/>ScaffoldContext, ScaffoldResult]
skill[Skill Types<br/>Skill Validation]
source[Source Types<br/>Source, SourceId]
sourceId[SourceId Utilities]
errors[Domain Errors]
end

subgraph Ports["Port Interfaces"]
sourceAdapter[SourceAdapter]
appStorage[AppStorage]
clock[Clock]
copilotSDK[Copilot SDK]
filesystem[FileSystem]
githubAPI[GitHubApi]
http[HttpClient]
processRunner[ProcessRunner]
bundleDownloader[BundleDownloader]
bundleExtractor[BundleExtractor]
targetWriter[TargetWriter]
layoutConfigLoader[LayoutConfigLoader]
resourceTransformer[ResourceTransformer]
sourceResolver[SourceResolver]
registryOps[RegistryOperations]
updateStore[UpdateStore]
updateNotifier[UpdateNotifier]
telemetry[Telemetry]
end

subgraph Public["Public APIs"]
schemas[JSON Schemas<br/>Validation schemas]
schemaDir[SCHEMA_DIR<br/>Schema path export]
collectionSchema[COLLECTION_SCHEMA<br/>Embedded schema]
end
end

Key Components

ComponentResponsibilityKey Files
Bundle TypesBundle metadata, references, harvested files, providersdomain/bundle/
Collection TypesCollection structure, items, validation, manifest validationdomain/collection/
Primitive TypesPrimitive union, kinds, and searchable fieldsdomain/primitive/
Hub TypesHub configuration, sources, and validationdomain/hub/
Install TypesInstallation targets, installables, layouts, transforms, copilot file typedomain/install/
Registry TypesRegistry configuration, settings, and guardsdomain/registry/
Scaffold TypesScaffolding context and resultsdomain/scaffold/
Skill TypesSkill metadata and validationdomain/skill/validate.ts
Source TypesSource definitions and SourceId utilitiesdomain/source/, domain/source-id.ts
Domain ErrorsRegistry and domain errorsdomain/errors.ts, domain/registry-error.ts
Port InterfacesAbstractions for implementationsports/
JSON SchemasValidation schemaspublic/schemas/collection.schema.json
SCHEMA_DIRExported schema directory pathindex.ts
COLLECTION_SCHEMAEmbedded collection schema JSONindex.ts

VS Code Extension Components

flowchart TB
subgraph Ext["apps/vscode-extension"]
subgraph Commands["Commands"]
installCmd[Install / Uninstall<br/>Commands]
hubCmd[Hub / Profile<br/>Commands]
updateCmd[Update / Apply<br/>Commands]
end

subgraph UI["UI"]
marketplace[Marketplace WebView]
treeView[Registry Tree View]
end

subgraph Services["Services"]
registryMgr[RegistryManager]
bundleInstaller[BundleInstaller]
userScopeService[UserScopeService]
lockfileMgr[LockfileManager]
hubStorage[HubStorage]
end

subgraph Storage["Storage"]
registryStorage[RegistryStorage]
globalState[VS Code globalState]
end
end

VSCodeAPI[(VS Code API)]
FS[(File System)]

Commands --> Services
UI --> Commands
Services --> Storage
Services --> FS
Storage --> VSCodeAPI
Storage --> FS

Key Components

ComponentResponsibilityKey Files
Install CommandsInstall/uninstall bundles from the IDEsrc/commands/install*.ts
Hub/Profile CommandsManage hubs and profilessrc/commands/hub-profile-commands.ts
Update CommandsCheck and apply updatessrc/commands/update*.ts
Marketplace WebViewBundle marketplace UIsrc/ui/marketplace/*
Registry Tree ViewTree view of installed sources and bundlessrc/ui/tree-view/*
RegistryManagerCoordinates adapters, storage, and installersrc/services/registry-manager.ts
BundleInstallerDownload, extract, validate, and install bundlessrc/services/bundle-installer.ts
UserScopeServiceUser-scope primitive sync with layout and transformssrc/services/user-scope-service.ts
LockfileManagerRepository lockfile managementsrc/services/lockfile-manager.ts
HubStorageHub persistent storagesrc/storage/hub-storage.ts
RegistryStorageVS Code globalStorage-based statesrc/storage/registry-storage.ts

Note: The extension is being migrated onto app/core/infra through a strangler-fig approach (see ADR-0001); the Services layer is becoming thin delegators over the shared app use cases.


Component Dependencies

flowchart TB
subgraph Core["@ai-primitives-hub/core<br/>No package deps"]
D[Domain Types]
P[Port Interfaces]
S[JSON Schemas]
end

subgraph Infra["@ai-primitives-hub/infra<br/>Depends on core"]
G[GitHub / HTTP Client]
H[Harvester]
SR[Search Engine]
ST[Storage / Stores]
SC[Scaffolding / Writers]
end

subgraph App["@ai-primitives-hub/app<br/>Depends on core, infra"]
C[Collection Logic]
I[Install Orchestration]
R[Registry Management]
DSC[Discovery]
T[Transform]
end

subgraph CLI["@ai-primitives-hub/cli<br/>Depends on core, infra, app"]
CMD[CLI Commands]
FRM[CLI Framework]
VAL[Validation]
BL[Bundle Builder]
end

subgraph Ext["apps/vscode-extension<br/>Depends on core, infra, app"]
EC[Extension Commands]
EU[Extension UI]
ES[Extension Services]
end

Infra --> Core
App --> Core
App --> Infra
CLI --> Core
CLI --> Infra
CLI --> App
Ext --> Core
Ext --> Infra
Ext --> App

Key Rule: Core has no package dependencies. Infra depends only on Core. App depends on Core and Infra. CLI and the VS Code extension depend on Core, Infra, and App. App also serves as the public SDK surface.

See Also