Skip to content

Commit 36f0986

Browse files
authored
Merge pull request #31 from BjornMelin/feat/add-agent-skills
feat: add agent skills + UI for management
2 parents 9693fea + a09e6c7 commit 36f0986

126 files changed

Lines changed: 16479 additions & 2549 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ NEXT_PUBLIC_AUTH_SOCIAL_PROVIDERS=vercel
3737
# (auto-managed by .github/workflows/vercel-preview-env-sync.yml).
3838
APP_BASE_URL=
3939

40+
# Agent Skills (optional)
41+
# Comma-separated list of skill root directories scanned for repo-bundled skills.
42+
# Defaults to ".agents/skills,.codex/skills". Supported values: ".agents/skills", ".codex/skills" (subset allowed).
43+
AGENT_SKILLS_DIRS=.agents/skills,.codex/skills
44+
4045
# Database (Neon Postgres)
4146
# Prefer connection strings with `sslmode=verify-full`.
4247
DATABASE_URL=

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ yarn-error.log*
4747
# Vercel
4848
.vercel/
4949

50+
# Neon
51+
.neon
52+
5053
# OS
5154
.DS_Store
5255
.AppleDouble

.neon

Lines changed: 0 additions & 3 deletions
This file was deleted.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ bun run fetch:models # Update AI model catalog (requires AI_GATEWAY_AP
4141
- Do **not** switch to package barrel imports by default.
4242
- Barrel imports are allowed only for packages listed in `next.config.ts` `experimental.optimizePackageImports` (currently `radix-ui` and `lucide-react`).
4343
- For all other packages, use explicit/non-barrel imports.
44+
- **Workflow layering guardrail**: Workflow-only shared helpers must live in `src/workflows/_shared/` (not `src/lib/`). Avoid `index.ts` re-export facades; import concrete modules directly.
4445

4546
## Drizzle + database
4647

PRD.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,20 @@ Primary spec/ADR references:
135135
- [`docs/architecture/spec/SPEC-0004-chat-retrieval-augmentation.md`](./docs/architecture/spec/SPEC-0004-chat-retrieval-augmentation.md)
136136
- [`docs/architecture/adr/ADR-0006-agent-runtime-ai-sdk-v6-toolloopagent-streaming-ui-responses.md`](./docs/architecture/adr/ADR-0006-agent-runtime-ai-sdk-v6-toolloopagent-streaming-ui-responses.md)
137137

138+
### Epic 4b: Agent Skills (progressive disclosure)
139+
140+
- Support runtime-loadable Agent Skills (name/description index + on-demand load). (FR-035)
141+
- Support project-scoped skill overrides stored in the DB. (FR-036)
142+
- Support installing skills from the public skills.sh registry from the UI. (FR-037)
143+
- Keep skill loading read-only; any execution of skill scripts must be sandboxed and approval-gated. (NFR-013, NFR-014, NFR-016)
144+
145+
Primary spec/ADR references:
146+
147+
- [`docs/architecture/spec/SPEC-0027-agent-skills-runtime-integration.md`](./docs/architecture/spec/SPEC-0027-agent-skills-runtime-integration.md)
148+
- [`docs/architecture/spec/SPEC-0028-skills-registry-ui-and-bundled-installs.md`](./docs/architecture/spec/SPEC-0028-skills-registry-ui-and-bundled-installs.md)
149+
- [`docs/architecture/adr/ADR-0028-agent-skills-progressive-disclosure-hybrid-fs-db.md`](./docs/architecture/adr/ADR-0028-agent-skills-progressive-disclosure-hybrid-fs-db.md)
150+
- [`docs/architecture/adr/ADR-0029-skills-registry-integration-ui-installs-and-bundled-db-files.md`](./docs/architecture/adr/ADR-0029-skills-registry-integration-ui-installs-and-bundled-db-files.md)
151+
138152
### Epic 5: Durable runs (research → artifacts)
139153

140154
- Start and persist durable runs with step status and tool call logs. (FR-010, FR-011)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ trail).
2020
- Enforces per-user project ownership for all project-scoped reads/writes.
2121
- Applies server-side search guardrails (strict query validation + rate limiting).
2222
- Maintains a formal architecture pack (PRD, ADRs, specs, security) in-repo with deterministic export.
23+
- Supports runtime-loadable Agent Skills (SKILL.md progressive disclosure) with per-project overrides and skills.sh registry installs.
2324
- Supports an implementation/deployment phase (approval-gated side effects) to:
2425
- connect a target GitHub repo
2526
- plan changes traceable to artifacts
@@ -65,6 +66,8 @@ flowchart LR
6566
- Provisioning + deploy automation: [`docs/architecture/spec/SPEC-0018-infrastructure-provisioning-and-secrets-for-target-apps.md`](./docs/architecture/spec/SPEC-0018-infrastructure-provisioning-and-secrets-for-target-apps.md)
6667
- Sandbox verification jobs: [`docs/architecture/spec/SPEC-0019-sandbox-build-test-and-ci-execution.md`](./docs/architecture/spec/SPEC-0019-sandbox-build-test-and-ci-execution.md)
6768
- Workspace + search UX: [`docs/architecture/spec/SPEC-0020-project-workspace-and-search.md`](./docs/architecture/spec/SPEC-0020-project-workspace-and-search.md)
69+
- Agent Skills (progressive disclosure): [`docs/architecture/spec/SPEC-0027-agent-skills-runtime-integration.md`](./docs/architecture/spec/SPEC-0027-agent-skills-runtime-integration.md)
70+
- Skills registry installs: [`docs/architecture/spec/SPEC-0028-skills-registry-ui-and-bundled-installs.md`](./docs/architecture/spec/SPEC-0028-skills-registry-ui-and-bundled-installs.md)
6871
- GitOps + deploy ADRs:
6972
- [`docs/architecture/adr/ADR-0024-gitops-repository-automation-pr-based-workflows.md`](./docs/architecture/adr/ADR-0024-gitops-repository-automation-pr-based-workflows.md)
7073
- [`docs/architecture/adr/ADR-0025-infrastructure-provisioning-and-vercel-deployment-automation.md`](./docs/architecture/adr/ADR-0025-infrastructure-provisioning-and-vercel-deployment-automation.md)
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
ADR: 0028
3+
Title: Agent Skills progressive disclosure (hybrid filesystem + DB)
4+
Status: Implemented
5+
Version: 0.1
6+
Date: 2026-02-09
7+
Supersedes: []
8+
Superseded-by: []
9+
Related: [ADR-0006, ADR-0010, ADR-0013, ADR-0021, ADR-0026, ADR-0029]
10+
Tags: [ai-sdk, agents, nextjs, workflow, security, caching]
11+
Related-Requirements: [FR-035, FR-036, NFR-006, NFR-013, NFR-014, NFR-016]
12+
References:
13+
- [AI SDK cookbook: Add Skills to Your Agent](https://ai-sdk.dev/cookbook/guides/agent-skills)
14+
- [1Password: From Magic to Malware (Agent Skills attack surface)](https://1password.com/blog/from-magic-to-malware-how-openclaws-agent-skills-become-an-attack-surface)
15+
- [Vercel KB: Using files in Serverless Functions](https://vercel.com/kb/guide/how-can-i-use-files-in-serverless-functions)
16+
---
17+
18+
## Status
19+
20+
Implemented — 2026-02-09.
21+
22+
## Context
23+
24+
This app relies on multiple agents and workflows (chat, research, code mode,
25+
implementation runs). Agents need **specialized, high-signal workflows** (e.g.
26+
Workflow DevKit patterns, Sandbox safety, AI SDK usage) but the system prompt
27+
must remain small to preserve:
28+
29+
- cost controls (token budgets)
30+
- relevance (avoid noisy instructions)
31+
- reliability (reduce prompt drift)
32+
33+
We also need **project-scoped customization** so a project can override or
34+
extend the default skills without requiring a redeploy.
35+
36+
## Decision Drivers
37+
38+
- Progressive disclosure (small prompt index, load full instructions on demand)
39+
- Per-project overrides with deterministic precedence
40+
- Safe-by-default: no code execution from skill content in app runtime
41+
- Vercel/Next.js serverless compatibility (skill files must be traced/bundled)
42+
- Maintainability: strict TS, simple resolution rules, minimal new surface area
43+
44+
## Alternatives Considered
45+
46+
### A. Filesystem-only skills (repo-bundled)
47+
48+
Pros:
49+
50+
- Very low maintenance and operational complexity.
51+
- Skills are versioned and reviewed via PRs.
52+
- Deterministic deploys.
53+
54+
Cons:
55+
56+
- No per-project customization without redeploy.
57+
- Cannot support non-developer editing via UI.
58+
59+
### B. Database-only skills (project-defined)
60+
61+
Pros:
62+
63+
- Maximum flexibility and per-project customization.
64+
- No reliance on filesystem tracing for skills.
65+
66+
Cons:
67+
68+
- Higher maintenance burden (validation, governance, drift management).
69+
- Loses the “vetted standard library” properties of repo-bundled skills.
70+
71+
### C. Hybrid filesystem + DB (DB overrides by normalized name) (**Chosen**)
72+
73+
Pros:
74+
75+
- Repo ships a vetted “standard library” of skills.
76+
- Projects can override/extend skills without redeploy.
77+
- Clear precedence rule: DB wins on normalized name collisions.
78+
79+
Cons:
80+
81+
- Added complexity: merging/indexing semantics and cache invalidation.
82+
- Requires careful path confinement for any file reads.
83+
84+
### D. Filesystem-only with project-local overrides in-repo
85+
86+
Pros:
87+
88+
- Override semantics without DB schema/migrations.
89+
- Git-tracked overrides.
90+
91+
Cons:
92+
93+
- Requires writing to the repo (not compatible with this app’s product UX).
94+
- Still effectively requires redeploy/branch management for updates.
95+
96+
## Decision Framework
97+
98+
Weights:
99+
100+
- Solution leverage: 35%
101+
- Application value: 30%
102+
- Maintenance and cognitive load: 25%
103+
- Architectural adaptability: 10%
104+
105+
| Option | Leverage | Value | Maintenance | Adaptability | Weighted total |
106+
| --- | ---: | ---: | ---: | ---: | ---: |
107+
| A. Filesystem-only | 6.8 | 5.8 | 9.2 | 4.6 | 7.06 |
108+
| B. Database-only | 8.6 | 9.1 | 7.2 | 9.0 | 8.42 |
109+
| C. Hybrid FS + DB overrides | 9.4 | 9.3 | 8.6 | 9.0 | **9.13** |
110+
| D. FS-only + project-local overrides | 7.4 | 6.4 | 8.4 | 6.0 | 7.25 |
111+
112+
Consensus process artifacts used in evaluation:
113+
114+
- Exa deep research task: `01kh25d2yzphpxetpdat8ym2mf`
115+
- Zen consensus continuation: `c845be0a-d38e-47d2-8445-65eeccd705c4`
116+
117+
## Decision
118+
119+
Adopt **Hybrid FS + DB Agent Skills** with **progressive disclosure**:
120+
121+
1. Repo-bundled skills live in the filesystem and are discovered from
122+
`AGENT_SKILLS_DIRS`.
123+
2. Projects can define DB skills that override filesystem skills by normalized
124+
name (`trim().toLowerCase()`).
125+
3. Agents only see `{name, description}` in the prompt. Full instructions are
126+
loaded on-demand via:
127+
- `skills.load` (load skill body)
128+
- `skills.readFile` (read repo-bundled skill files and bundled DB skill
129+
files when present; strict path safety)
130+
4. Skill-bundled scripts are **not executed** by the app runtime. Any future
131+
execution must be implemented as separate sandbox tools and gated by explicit
132+
approvals (see ADR-0010).
133+
134+
Implementation details are defined in:
135+
136+
- [SPEC-0027](../spec/SPEC-0027-agent-skills-runtime-integration.md)
137+
- [SPEC-0028](../spec/SPEC-0028-skills-registry-ui-and-bundled-installs.md)
138+
139+
## Consequences
140+
141+
### Positive outcomes
142+
143+
- Skill workflows scale without prompt bloat (progressive disclosure).
144+
- Teams can adapt skills per project without redeploy.
145+
- Read-only file access and sandbox-only execution preserve security posture.
146+
147+
### Negative outcomes / risks
148+
149+
- Added complexity in resolution/debugging (two sources).
150+
- Mitigation: deterministic precedence, normalized-name resolution, and UI
151+
showing “effective skills”.
152+
- Untrusted DB skill content can cause prompt injection.
153+
- Mitigation: skills remain text-only; side-effectful tools remain
154+
least-privilege + approval-gated.
155+
156+
## Changelog
157+
158+
- **0.1 (2026-02-09)**: Initial version. Implemented as part of SPEC-0027.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
ADR: 0029
3+
Title: Skills registry integration (skills.sh) with UI installs + bundled DB skill files
4+
Status: Implemented
5+
Version: 0.1
6+
Date: 2026-02-09
7+
Supersedes: []
8+
Superseded-by: []
9+
Related: [ADR-0028, ADR-0010, ADR-0013, ADR-0026, ADR-0021]
10+
Tags: [agents, skills, nextjs, workflow, blob, security]
11+
Related-Requirements: [FR-035, FR-036, FR-037, NFR-001, NFR-006, NFR-013, NFR-014, NFR-016, IR-006, IR-011]
12+
References:
13+
- [skills.sh docs](https://skills.sh/docs)
14+
- [skills.sh CLI docs](https://skills.sh/docs/cli)
15+
- [skills.sh search API](https://skills.sh/api/search)
16+
- [vercel-labs/skills (GitHub)](https://github.com/vercel-labs/skills)
17+
---
18+
19+
## Status
20+
21+
Implemented — 2026-02-09.
22+
23+
## Context
24+
25+
The app uses Agent Skills (progressive disclosure) to keep system prompts small
26+
while providing deep, task-specific workflows (Sandbox, Workflow DevKit, AI SDK,
27+
etc.). The base implementation supports:
28+
29+
- repo-bundled filesystem skills
30+
- project-scoped DB skills that override filesystem skills by normalized name
31+
32+
Teams need a **UI-managed** way to discover and install skills from the public
33+
ecosystem (skills.sh) without requiring developers to:
34+
35+
- edit the repo to add skill folders
36+
- copy/paste `SKILL.md` into the DB manually
37+
38+
We must preserve the security posture:
39+
40+
- Do not execute skill-bundled code in the app runtime.
41+
- Any execution must remain sandboxed and approval-gated (ADR-0010).
42+
- Do not leak Blob URLs/pathnames to clients (public-only storage).
43+
44+
## Decision Drivers
45+
46+
- High leverage: reuse skills.sh registry and GitHub-hosted skills.
47+
- Strong security: no runtime `npx` or repo writes; strict size/SSRF guardrails.
48+
- Maintainability: simple contracts, minimal new surface area, strict TS.
49+
- UX: install/update/uninstall from the project Skills tab.
50+
51+
## Alternatives Considered
52+
53+
### A. Run `npx skills add/remove` in app runtime
54+
55+
Pros:
56+
57+
- Matches the official CLI behavior.
58+
59+
Cons:
60+
61+
- Unacceptable supply-chain risk (runtime package execution).
62+
- Operational complexity (filesystem writes, caching, cleanup).
63+
- Conflicts with serverless tracing + immutable deployments.
64+
65+
### B. Run `npx skills` inside Vercel Sandbox
66+
67+
Pros:
68+
69+
- Isolation from app runtime.
70+
71+
Cons:
72+
73+
- Still requires package execution (supply chain + allowlist complexity).
74+
- Introduces a new control plane (tokens, policy, caching, output validation).
75+
- Harder UX (async installs, logs, retries) for a first iteration.
76+
77+
### C. Use skills.sh search + GitHub archive ingestion + DB/Blob bundles (**Chosen**)
78+
79+
Pros:
80+
81+
- No runtime package execution.
82+
- Deterministic parsing: resolve `SKILL.md` by frontmatter `name`.
83+
- Files for `skills.readFile` are supported via a bundle ZIP stored in Blob.
84+
- Fits existing precedence model (DB overrides FS).
85+
86+
Cons:
87+
88+
- Requires careful bounds (archive size, bundle limits).
89+
- Update semantics are “reinstall” (no pinning/version UI yet).
90+
91+
### D. Write skills into repo directories from the UI
92+
93+
Pros:
94+
95+
- Skills become part of the repo skill library.
96+
97+
Cons:
98+
99+
- Not compatible with serverless/immutable deploys.
100+
- Requires RepoOps + PR flows (large scope, high risk for this feature).
101+
102+
## Decision Framework (must be ≥ 9.0)
103+
104+
Weights:
105+
106+
- Solution leverage: 35%
107+
- Application value: 30%
108+
- Maintenance and cognitive load: 25%
109+
- Architectural adaptability: 10%
110+
111+
| Option | Leverage | Value | Maintenance | Adaptability | Weighted total |
112+
| --- | ---: | ---: | ---: | ---: | ---: |
113+
| A. Runtime `npx skills` | 6.5 | 7.5 | 3.0 | 5.5 | 5.74 |
114+
| B. Sandbox `npx skills` | 7.8 | 8.6 | 7.0 | 8.2 | 7.85 |
115+
| C. Search API + GitHub zip + DB/Blob bundles | 9.4 | 9.3 | 8.8 | 9.0 | **9.16** |
116+
| D. Repo write/PR-based installs | 6.8 | 7.2 | 5.6 | 8.6 | 6.70 |
117+
118+
## Decision
119+
120+
Implement registry management as:
121+
122+
1. Search via `skills.sh/api/search`.
123+
2. Install/update via a **Workflow DevKit** workflow:
124+
- Download GitHub archive ZIP (`main``master` fallback).
125+
- Resolve the chosen skill by matching `SKILL.md` frontmatter `name` to the
126+
requested `skillId`.
127+
- Bundle the skill directory into a ZIP and upload to Vercel Blob.
128+
- Upsert the skill into `project_skills` with server-only metadata
129+
referencing the registry id and bundle blob pathname.
130+
3. Uninstall deletes the DB record and best-effort deletes the bundle blob.
131+
4. `skills.readFile` supports DB skills **only when** they have a valid bundle
132+
reference.
133+
134+
Details and file-level contracts are defined in:
135+
136+
- [SPEC-0028](../spec/SPEC-0028-skills-registry-ui-and-bundled-installs.md)
137+
- [SPEC-0027](../spec/SPEC-0027-agent-skills-runtime-integration.md)
138+
139+
## Consequences
140+
141+
### Positive outcomes
142+
143+
- Users can install skills from the UI without redeploying or editing the repo.
144+
- Read-only file access works for installed skills (bundled ZIP).
145+
- Avoids runtime `npx` execution and keeps the app runtime minimal.
146+
147+
### Negative outcomes / risks
148+
149+
- GitHub archive downloads can fail/rate-limit.
150+
- Mitigation: optional `GITHUB_TOKEN`, strict timeouts, durable retries.
151+
- Public-only Blob means bundles must be treated as sensitive.
152+
- Mitigation: never send blob URLs/pathnames to clients; redact metadata.
153+
154+
## Changelog
155+
156+
- **0.1 (2026-02-09)**: Initial version. Implemented as part of SPEC-0028.

docs/architecture/adr/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
- [ADR-0023](./ADR-0023-public-signup-deferred-until-byok.md) — Public sign-up deferred until BYOK (deferred)
2626
- [ADR-0026](./ADR-0026-orchestration-vercel-workflow-devkit-for-interactive-runs.md) — Orchestration: Vercel Workflow DevKit for interactive runs (QStash for background jobs)
2727
- [ADR-0027](./ADR-0027-preview-resource-governance-for-bot-branches-vercel-neon.md) — Preview resource governance for bot branches (Vercel + Neon) (Implemented)
28+
- [ADR-0028](./ADR-0028-agent-skills-progressive-disclosure-hybrid-fs-db.md) — Agent Skills progressive disclosure (hybrid filesystem + DB) (Implemented)
29+
- [ADR-0029](./ADR-0029-skills-registry-integration-ui-installs-and-bundled-db-files.md) — Skills registry integration (skills.sh) with UI installs + bundled DB skill files (Implemented)
2830

2931
## Implementation & deployment automation
3032

0 commit comments

Comments
 (0)