Skip to content

feat(cli): add the agents command to teach evlog to AI agents - #492

Merged
HugoRCD merged 4 commits into
mainfrom
feat/cli-agents-command
Aug 2, 2026
Merged

feat(cli): add the agents command to teach evlog to AI agents#492
HugoRCD merged 4 commits into
mainfrom
feat/cli-agents-command

Conversation

@HugoRCD

@HugoRCD HugoRCD commented Aug 2, 2026

Copy link
Copy Markdown
Owner

🔗 Linked issue

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • New Features
    • Added evlog agents to generate or update AGENTS.md and CLAUDE.md guidance.
    • Added optional skill installation with project/global detection, dry-run, JSON, interactive, and non-interactive modes.
    • Integrated agent guidance setup into evlog init, with an option to skip it and continued execution after skill failures.
  • Documentation
    • Added CLI usage, options, examples, and agent-skills guidance.
  • Tests
    • Added coverage for configuration, detection, dry runs, idempotency, and failure reporting.

@HugoRCD HugoRCD self-assigned this Aug 2, 2026
@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b287962

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@evlog/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, v0 Aug 2, 2026 12:54pm
evlog-render-lab Ready Ready Preview Aug 2, 2026 12:54pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
evlog-telemetry Skipped Skipped Aug 2, 2026 12:54pm
just-use-evlog Skipped Skipped Aug 2, 2026 12:54pm

Request Review

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Aug 2, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@evlog/cli@492
npm i https://pkg.pr.new/evlog@492
npm i https://pkg.pr.new/@evlog/nuxthub@492
npm i https://pkg.pr.new/@evlog/telemetry@492

commit: b287962

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fefffe11-3884-410a-834e-0a8c738c62db

📥 Commits

Reviewing files that changed from the base of the PR and between 2bb4901 and b287962.

📒 Files selected for processing (4)
  • apps/docs/content/3.cli/8.agents.md
  • packages/cli/README.md
  • packages/cli/src/lib/agents/report.ts
  • packages/cli/test/agents.test.ts

📝 Walkthrough

Walkthrough

The CLI adds evlog agents to generate agent guidance, update AGENTS.md and CLAUDE.md, detect or install skills, and report results. evlog init now performs the same setup by default, with an option to disable it.

Changes

Agent setup workflow

Layer / File(s) Summary
Guidance rendering and planning
packages/cli/src/core/context.ts, packages/cli/src/lib/agents/block.ts, packages/cli/src/lib/agents/plan.ts, packages/cli/src/lib/agents/run.ts, packages/cli/src/lib/agents/report.ts, packages/cli/test/agents.test.ts
The CLI renders framework-aware guidance, updates managed blocks, maintains Claude pointers, detects the home directory, plans file changes, records outcomes, and preserves user-authored content.
Skill discovery and agents command
packages/cli/src/lib/agents/skills.ts, packages/cli/src/commands/agents.ts, packages/cli/src/commands/index.ts, packages/cli/src/lib/command.ts, packages/cli/src/lib/errors.ts, packages/cli/test/agents.test.ts
evlog agents supports skill selection, scope and source options, dry runs, interactive mode, JSON output, cancellation, skill installation, validation, and structured failure handling.
Initialization integration
packages/cli/src/commands/init.ts, packages/cli/src/lib/init/*, packages/cli/test/init.resolve.test.ts, packages/cli/test/init.test.ts
evlog init includes optional agent guidance and skill installation, displays planned commands, continues after skill failures, reports status, and serializes agent-guide results.
Documentation and telemetry support
apps/docs/content/3.cli/*, apps/docs/content/7.reference/6.agent-skills.md, apps/docs/skills/review-logging-patterns/SKILL.md, packages/cli/README.md, apps/telemetry/*, .changeset/cli-agents-command.md
Documentation describes the command and initialization behavior. Agent telemetry fields are allowlisted and covered by a compatibility test.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant AgentsCommand
  participant RunAgents
  participant ProjectFiles
  participant SkillsCLI
  User->>AgentsCommand: run evlog agents
  AgentsCommand->>RunAgents: pass command options
  RunAgents->>ProjectFiles: plan and write AGENTS.md and CLAUDE.md
  RunAgents->>SkillsCLI: run npx skills add
  SkillsCLI-->>RunAgents: return installation status
  RunAgents-->>AgentsCommand: return and format result
  AgentsCommand-->>User: display human or JSON output
Loading

Possibly related PRs

Suggested labels: documentation

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only the template and leaves the issue, change summary, rationale, and checklist incomplete. Add a concise change summary, explain the problem and solution, link an issue if applicable, and mark the documentation checklist item.
Docstring Coverage ⚠️ Warning Docstring coverage is 72.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change and uses the conventional feat(cli) format.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-agents-command

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/docs/content/3.cli/8.agents.md`:
- Around line 67-70: Keep the agent-file documentation consistent across all
listed sites: in apps/docs/content/3.cli/8.agents.md lines 67-70, clarify that
--no-skills still writes both AGENTS.md and CLAUDE.md while skipping only skill
installation; in apps/docs/content/3.cli/1.init.md lines 87-88, name both files
in the init agent step; in apps/docs/content/3.cli/1.init.md line 332, state
that --no-agents skips both files and skills; and in packages/cli/README.md
lines 54-57, apply the same both-file wording to both skip flags.
- Around line 40-44: Update the documentation around the agent skills
installation flow to specify a reviewed, pinned version and integrity or trust
validation for the npx skills add command invoked by evlog agents. Include the
--source path in the documented command and clearly describe the accepted trust
model before shipping the command.

In `@packages/cli/src/commands/agents.ts`:
- Around line 90-106: Move the shared fail(error, { args, log, ui }) helper from
agents.ts into packages/cli/src/lib/command.ts, preserving its EvlogError
handling, catalog logging, UI output, and EXIT_FAIL behavior. Export it from
command.ts, then remove the local duplicate and import the shared fail helper in
both agents.ts and init.ts.
- Line 38: Validate the source option before passing it to skillsCommand: add a
parseSourceArg helper that accepts only non-empty absolute http: or https: URLs,
normalizes valid values, and throws cliErrors.AGENTS_BAD_SOURCE for invalid
input. Apply it in the run option-parsing flow so runSkills receives only the
validated source.
- Around line 11-15: Update parseSkillsArg so both false and an empty string
return { skills: [], noSkills: true }, while preserving trimming and filtering
for valid comma-separated input. Add unit coverage for false, '', and valid
comma-separated values, verifying each parsed result.

In `@packages/cli/src/lib/agents/plan.ts`:
- Around line 32-34: Update read to catch readFileSync failures for existing
paths and raise the established catalog error, including the AGENTS.md path and
its fix metadata, instead of propagating the raw exception. Add the
corresponding catalog entry and imports using the existing cliErrors helper
conventions; preserve the null result for paths that do not exist.

In `@packages/cli/src/lib/agents/report.ts`:
- Around line 36-52: Extract the skills-status branch logic from the agent
report into a shared skillsReportLines helper in the agents report module,
accepting the existing paint function and skills outcome fields. Preserve all
four statuses, glyphs, wording, error rendering, and refresh/retry alignment
exactly, then replace the duplicated rendering in both report modules with
lines.push(...skillsReportLines(paint, skills)).

In `@packages/cli/src/lib/agents/run.ts`:
- Around line 241-268: Update recordAgentsRun to construct the nine-field
telemetry payload once, pass that payload to telemetry.set, and derive
agentsTelemetryFieldNames from the payload’s keys. Remove the duplicated
hard-coded name list while preserving all existing emitted fields and values.
- Around line 119-129: Ensure the generated agents guidance does not claim
skills are available before installation succeeds. Update the flow around
installing, planAgents, and the later skills installation so planning/writing
occurs after the skills outcome when possible, or rewrite the block with
hasSkills: false when skills.status is 'failed' and not in dry-run mode,
allowing the existing documentation fallback in renderBlock to be used.

In `@packages/cli/src/lib/agents/skills.ts`:
- Around line 84-119: Prevent shell injection in the command construction and
execution flow centered on skillsCommand and runSkills. Ensure user-controlled
source and skill values are safely passed when Windows uses shell execution,
using a batch-safe argument mechanism or strict validation/escaping rather than
treating raw values as commands; preserve the existing command behavior and
display output for valid inputs.

In `@packages/cli/src/lib/init/run.ts`:
- Around line 282-295: Update the installing and addingSkills conditions used to
build runs so they no longer require !dryRun, allowing the interactive dry-run
preview in showPlan to include both commands. Preserve the separate dryRun
checks in the execution flow so these commands remain preview-only and are not
actually run during dry runs.

In `@packages/cli/test/agents.test.ts`:
- Around line 105-106: Update the findInstalledSkills test setup to derive
NO_HOME from a fresh, suite-owned mkdtemp directory before each test instead of
using the fixed tmpdir path. Add the required beforeEach import from vitest and
ensure the temporary directory is created and assigned before assertions run,
matching the existing fakeContext isolation pattern.
- Around line 214-299: Add a runAgents test that mocks or spies on the imported
runSkills function to return a failed result, while allowing the normal skills
path to execute. Assert that the returned skills object has status 'failed' and
a populated error field, covering the failure branch used by the agents command.

In `@packages/cli/test/init.test.ts`:
- Around line 242-290: The agent-guidelines tests in runInit lack coverage for
the default agentGuide path when no skills are installed. Add a test alongside
the existing cases that uses nuxtProject() without skill files, mocks the skills
execution seam identified by the agentGuide/SkillsStatus pending transition in
runInit, and verifies the result status changes from pending to the mock’s
installed or failed outcome. Also assert the generated AGENTS.md/CLAUDE.md
writes occur in the expected order relative to skills execution, while
preserving the existing no-skill-file behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: afc9ead3-92b6-4409-96af-58dbc123e768

📥 Commits

Reviewing files that changed from the base of the PR and between 6b75006 and cc1c78d.

📒 Files selected for processing (26)
  • .changeset/cli-agents-command.md
  • apps/docs/content/3.cli/0.overview.md
  • apps/docs/content/3.cli/1.init.md
  • apps/docs/content/3.cli/8.agents.md
  • apps/docs/content/7.reference/6.agent-skills.md
  • apps/docs/skills/review-logging-patterns/SKILL.md
  • apps/telemetry/server/utils/allowed-tools.ts
  • apps/telemetry/test/allowed-tools.test.ts
  • packages/cli/README.md
  • packages/cli/src/commands/agents.ts
  • packages/cli/src/commands/index.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/core/context.ts
  • packages/cli/src/lib/agents/block.ts
  • packages/cli/src/lib/agents/plan.ts
  • packages/cli/src/lib/agents/report.ts
  • packages/cli/src/lib/agents/run.ts
  • packages/cli/src/lib/agents/skills.ts
  • packages/cli/src/lib/init/prompts.ts
  • packages/cli/src/lib/init/report.ts
  • packages/cli/src/lib/init/resolve.ts
  • packages/cli/src/lib/init/run.ts
  • packages/cli/src/lib/init/telemetry.ts
  • packages/cli/test/agents.test.ts
  • packages/cli/test/init.resolve.test.ts
  • packages/cli/test/init.test.ts

Comment thread apps/docs/content/3.cli/8.agents.md
Comment thread apps/docs/content/3.cli/8.agents.md Outdated
Comment thread packages/cli/src/commands/agents.ts
Comment thread packages/cli/src/commands/agents.ts
Comment thread packages/cli/src/commands/agents.ts Outdated
Comment thread packages/cli/src/lib/agents/skills.ts
Comment thread packages/cli/src/lib/init/run.ts Outdated
Comment thread packages/cli/test/agents.test.ts Outdated
Comment thread packages/cli/test/agents.test.ts
Comment thread packages/cli/test/init.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/lib/init/run.ts (1)

252-280: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

runInit does not correct AGENTS.md guidance after a failed skill install.

agentGuide is planned with hasSkills: true at line 263, and this block is written to disk before the skill install (runSkills) runs at line 353. When that install fails, agentGuide.status is set to 'failed' (line 356), but nothing rewrites AGENTS.md — the file keeps telling the agent to read the review-logging-patterns skill, which is not on disk.

packages/cli/src/lib/agents/run.ts already fixes this exact scenario for evlog agents (lines 190-206): after a failed install, it re-plans with hasSkills: false and rewrites the guidance files. Port the same correction here so evlog init gives consistent behavior with evlog agents.

The test packages/cli/test/init.test.ts at lines 326-335 confirms this gap — it only checks that AGENTS.md exists, not that it stops promising the missing skill.

🐛 Suggested fix — mirror the correction from agents/run.ts
   if (agentGuide) {
     if (agentGuide.found.length > 0) {
       agentGuide.status = 'already'
     } else if (dryRun) {
       agentGuide.status = 'pending'
     } else {
       /* Runs after the writes: the block is the part we own, and it should be
          on disk whatever a subprocess we do not control decides to do. */
       if (interactive) noteSkillsStarting(ctx, agentGuide.command)
       const outcome = await log.step(
         'skills',
         () => runSkills(skillsCommand({ interactive }), project.packageDir, interactive),
         r => ({ installed: r.ok }),
       )
       agentGuide.status = outcome.ok ? 'installed' : 'failed'
-      if (!outcome.ok) agentGuide.error = outcome.error
+      if (!outcome.ok) {
+        agentGuide.error = outcome.error
+        /* The block was written on the assumption the install would succeed.
+           Rewrite it so it stops naming a skill that is not on disk. */
+        const corrected = planAgents({
+          root: project.packageDir,
+          projectName: project.packageName ?? 'This project',
+          framework: answers.framework,
+          hasSkills: false,
+        })
+        await log.step('rewriteAgentGuide', async () => {
+          for (const action of corrected.actions) {
+            await writeFile(action.path, action.contents, 'utf8')
+          }
+          return corrected.actions.length
+        })
+      }
     }
   }

Consider extracting this correction into a shared helper (e.g. in packages/cli/src/lib/agents/plan.ts) so agents/run.ts and init/run.ts do not each carry their own copy.

Also applies to: 342-360

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/lib/init/run.ts` around lines 252 - 280, Update runInit’s
failed runSkills path to re-plan agent guidance with hasSkills: false and
rewrite the guidance files after setting agentGuide.status to failed, matching
the existing correction in agents/run.ts. Prefer extracting and reusing a shared
helper from the agent planning code if practical, while preserving
successful-install behavior and the existing status/reporting flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/docs/content/3.cli/8.agents.md`:
- Around line 61-65: The documented command and trust statement must match the
command produced and displayed by skillsCommand. Update the relevant
documentation or skillsCommand display construction to include the leading --yes
and any non-interactive or option-specific arguments, while preserving the exact
command shown before execution.

In `@packages/cli/src/lib/agents/skills.ts`:
- Around line 82-102: Update checkSource to reject valid HTTP(S) URLs containing
cmd.exe shell metacharacters such as &, |, ;, and related command separators
before returning the raw value, while preserving existing URL and protocol
validation. Keep the change scoped to the source validation used by runSkills.

---

Outside diff comments:
In `@packages/cli/src/lib/init/run.ts`:
- Around line 252-280: Update runInit’s failed runSkills path to re-plan agent
guidance with hasSkills: false and rewrite the guidance files after setting
agentGuide.status to failed, matching the existing correction in agents/run.ts.
Prefer extracting and reusing a shared helper from the agent planning code if
practical, while preserving successful-install behavior and the existing
status/reporting flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bb88f1f8-14b2-407d-9264-9e9d22bcfb56

📥 Commits

Reviewing files that changed from the base of the PR and between cc1c78d and bca999c.

📒 Files selected for processing (16)
  • .changeset/cli-agents-command.md
  • apps/docs/content/3.cli/1.init.md
  • apps/docs/content/3.cli/8.agents.md
  • packages/cli/README.md
  • packages/cli/src/commands/agents.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/lib/agents/plan.ts
  • packages/cli/src/lib/agents/report.ts
  • packages/cli/src/lib/agents/run.ts
  • packages/cli/src/lib/agents/skills.ts
  • packages/cli/src/lib/command.ts
  • packages/cli/src/lib/errors.ts
  • packages/cli/src/lib/init/report.ts
  • packages/cli/src/lib/init/run.ts
  • packages/cli/test/agents.test.ts
  • packages/cli/test/init.test.ts

Comment thread apps/docs/content/3.cli/8.agents.md Outdated
Comment thread packages/cli/src/lib/agents/skills.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/docs/content/3.cli/8.agents.md`:
- Line 63: The “What runs” documentation overstates command visibility by saying
it is always printed before execution. Update that sentence to distinguish the
interactive plan from non-interactive modes, stating that the exact command is
shown in the interactive plan and included in the resulting report/output
otherwise, while preserving the command composition details.

In `@packages/cli/README.md`:
- Around line 59-60: Update the agent-specific options table in the README to
document the supported evlog agents --yes / -y flag, noting that it skips
confirmation for scripted and CI usage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 31cb2ff1-1dfb-4be4-b575-48e5758f96c4

📥 Commits

Reviewing files that changed from the base of the PR and between bca999c and 2bb4901.

📒 Files selected for processing (5)
  • apps/docs/content/3.cli/8.agents.md
  • packages/cli/README.md
  • packages/cli/src/lib/agents/skills.ts
  • packages/cli/test/agents.test.ts
  • packages/cli/test/init.test.ts

Comment thread apps/docs/content/3.cli/8.agents.md Outdated
Comment thread packages/cli/README.md Outdated
@HugoRCD
HugoRCD merged commit 31e5084 into main Aug 2, 2026
17 checks passed
@HugoRCD
HugoRCD deleted the feat/cli-agents-command branch August 2, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant