Skip to main content

Data Model: Unified Skills API & Template Import

Spec: spec.md

1. Persisted skill config (agent_skills)โ€‹

MongoDB documents follow the existing AgentSkill TypeScript shape (ui/src/types/agent-skill.ts).

Collection migration: This feature does not rename or bulk-migrate the collection. See mongodb-migration.md.

Core fieldsโ€‹

FieldTypeNotes
idstringUnique; user skills often UUID; system template imports: skill-{slug}-{6hex}
namestringDisplay name
descriptionstring?
categorystring
tasksAgentSkillTask[]Workflow steps
owner_idstringEmail or 'system' for system rows
is_systembooleantrue for packaged/imported system skills
created_at, updated_atDate
metadataobject?See below
skill_contentstring?SKILL.md body for builder
visibilityprivate | team | globalUser skills; system imports typically global
shared_with_teamsstring[]?When visibility is team
scan_statuspassed | flagged | unscanned
ancillary_filesRecord<string, string>?Path โ†’ content

Metadata extensions (template import)โ€‹

FieldTypeNotes
metadata.template_source_idstringStable id from packaged template (folder id / chart key); dedupe key with is_system
metadata.import_kindstringe.g. helm_template_v1

Existing AgentSkillMetadata fields (tags, schema_version, etc.) remain optional.

Validation rules (from spec + existing API)โ€‹

  • Template import rows: is_system: true, owner_id: 'system', metadata.template_source_id required for dedupe.
  • Dedupe query: find existing with same template_source_id and is_system โ†’ skip insert (FR-006).
  • User-created skills: must not be overwritten by template import keyed only on id prefix (edge case in spec).

2. Catalog skill entry (not a separate collection)โ€‹

Returned by merged catalog (GET /api/skills and supervisor merge): name, description, source discriminator (filesystem | agent_skills | hubs / product-specific), optional body, ids as today. No schema change required for source strings per spec out-of-scope.

3. Packaged template (filesystem)โ€‹

Chart directory: charts/.../data/skills/<template-id>/SKILL.md + metadata.json. Loaded by existing template loader for import UI and optional seed.

4. State transitionsโ€‹

  • Import: Packaged template โ†’ (POST import) โ†’ Mongo agent_skills row if not deduped.
  • CRUD: Standard create/update/delete via configs API; supervisor refresh triggered on write (existing).

5. Scan job (planned; FR-011, FR-012)โ€‹

Async hub or catalog scan runs (distinct from synchronous per-save scan in 097). Intended storage (align with 097 skill_scan_findings and supervisor):

FieldTypeNotes
idstringJob id (opaque).
statusqueued | running | succeeded | failed | cancelled
kindhub | catalogWhat was scanned.
hub_idstring?When kind is hub.
started_at, finished_atDate?
errorstring?Failure message.
summaryobject?Counts by severity, optional link to findings query.

6. Quarantine policy (planned; FR-013โ€“FR-016)โ€‹

Policy for whether flagged skills appear in merged catalog / supervisor (strict gate vs visibility). Cross-reference: 097 FR-027 (scan_status, SKILL_SCANNER_GATE=strict, catalog exclusion). Planned document shape (Mongo or config):

FieldTypeNotes
exclude_flagged_from_catalogbooleanWhen true, scan_status: flagged rows omitted from merged catalog (default strict).
allow_list_skill_idsstring[]?Optional override so specific skills remain visible while flagged.
updated_atDate
updated_bystring?Actor id or email.

Findings: Persisted in skill_scan_findings per 097 data-model ยง Skill scan finding.