A CI agent that keeps packages/docs/content/ in sync with source changes on pull requests. It runs in two modes: review posts a PR comment assessing whether docs coverage is adequate for a diff; apply edits the markdown docs, runs a docs build check (currently a no-op — packages/docs has no docs:build script, so the invocation prints Bun's usage help and exits 0 without building anything), and commits/pushes the result.
Triggered by .github/workflows/docs-agent.yml:
pull_request(opened/synchronize/reopened) touchingpackages/**/src/**oragents/**/src/**→ runsreview.- Commenting
@docs-agent applyon a PR (as an owner/member/collaborator) → runsapply. - Manual
workflow_dispatchfor either mode.
bun run --cwd agents/docs-agent docs-agent:workflow \
--mode review \
--pr-number 123 \
--sha <head-sha> \
--repo humanlayer/agentlayer \
--base-ref mainRequired env: GH_TOKEN (or --gh-token) unless --dry-run is passed. Both modes need FIREWORKS_API_KEY to actually invoke the LLM agent; without it apply throws (or, in --dry-run, no-ops), and review throws too — unless --dry-run is passed, in which case review always returns a heuristic comment regardless of whether the key is set.
flowchart TD
W["workflow.ts CLI"] -->|git diff base...HEAD| D["source diff + changed files"]
D --> R["runDocsReviewer (reviewer.ts)"]
R -->|Agent w/ read, glob, grep, list tools| RV["review markdown"]
RV -->|--mode review| C1["upsertAgentComment (docs-reviewer)"]
RV -->|--mode apply, reused as recommendations| E["runDocsEditor (editor.ts)"]
E -->|Agent w/ filesystem toolset + approval hook| ED["edits under packages/docs/content/*.md"]
ED --> B["bun --cwd packages/docs run docs:build (no-op: no such script)"]
B --> G["git commit + push"]
G --> C2["upsertAgentComment (docs-editor)"]
workflow.ts (src/workflow.ts) is the CLI entry point (Commander-based). It diffs base-ref...HEAD under the packages/ and agents/ directories, then filters the resulting changed-file list (used for the run gate and prompt file list, not the diff text itself) down to packages/**/src/** and agents/**/src/** paths, then:
- review: calls
runDocsReviewer, wraps the result, and upserts a marked PR comment (docs-reviewer). - apply: reuses an existing
docs-reviewercomment if present (else runs the reviewer inline), callsrunDocsEditor, runsbun --cwd packages/docs run docs:buildas a build check (currently a no-op — see above), commits/pushes any changed files underpackages/docs/content/, and upserts adocs-editorPR comment. It refuses to run ifpackages/docs/content/already has uncommitted changes.
runDocsReviewer(opts: { cwd, diff, changedFiles, dryRun? })— a read-onlyAgent(firepass model,read/glob/grep/listtools from@humanlayer/agentlayer-filesystem/tools) that inspects existing docs and returns a## Verdict/## Recommended Updates/## Files Worth Updatingmarkdown report.runDocsEditor(opts: { cwd, diff, recommendations, dryRun? })— anAgentwith the full filesystem toolset (createClaudeAgentFilesystemToolset, which includes an unrestrictedbashtool) gated by acreateApprovalHook([WriteTool, EditTool], ...)that denieswrite/edittool calls outsidepackages/docs/content/*.md; the hook does not coverbash, which can act anywhere on disk.loadAgentComment/upsertAgentComment(src/github.ts) — find/create/update a PR comment tagged with an HTML marker<!-- <agentName>:sha=<sha> -->, used to keep one comment per agent per PR instead of spamming new ones.
Built on @humanlayer/agentlayer-core (Agent, startState, maxSteps, createApprovalHook, extractLastAssistantText, WriteTool, EditTool), @humanlayer/agentlayer-filesystem (read/glob/grep/list tools and the combined filesystem toolset), and @humanlayer/codelayer (resolveModel, DEFAULT_MODELS) for provider/model resolution.