Files
d349868c31 feat(agents): one definition per coding agent, and Cursor's CLI
Every list of the coding agents now derives from internal/agents'
registry, one Def each, and Cursor's CLI (cursor-agent) is a fifth
agent.

The registry:
- each agent's login command, login formats and capture on its Def;
  one message for every agent where each had its own
- the agents' table, the README's list and the docs' history lists are
  generated from the registry (cli.DocBlocks, TestDocBlocks); scripts
  and Go tests take their lists from it too
- each agent's own code lives in a file named for it; the structure
  test lets only an agent's own files choose by its name, following
  constants named after an agent
- a VM remade by clone on/off keeps no agent's login files
  (agents.LoginFiles from every Def.Logins; Claude Code's .claude.json
  stays, as it is also history)

Cursor's CLI:
- `devvm --agents cursor`, `devvm agent login cursor`, history import
  and export of ~/.cursor/chats
- the proxy captures its login at a GET endpoint, guards a shared host
  by path, and puts the login in only where the CLI sends it, bound to
  the CLI's 57 methods
- account changes and the agent store are refused in a VM; Cursor's
  headers and trailers are scanned for tokens
- e2e: Cursor's CLI in the network section, its poll behind the fake
  company proxy

Docs: the agents' pages lead with commands, with a How it works page
for the agents.

Co-authored-by: JB <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:49:48 -07:00

56 lines
1.5 KiB
Go

package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/devvmhq/devvm/assets"
"github.com/devvmhq/devvm/internal/cli"
"github.com/devvmhq/devvm/internal/state"
)
// filled returns page with b's text between its markers, which the page
// must have once each, in order.
func filled(page string, b cli.DocBlock) (string, error) {
text, err := b.Text(assets.FS)
if err != nil {
return "", err
}
before, rest, ok := strings.Cut(page, b.Begin())
_, after, ok2 := strings.Cut(rest, b.End())
if !ok || !ok2 || strings.Contains(after, b.Begin()) {
return "", fmt.Errorf("%s: no %q and %q around %s, once each", b.Page, b.Begin(), b.End(), b.Name)
}
return before + b.Begin() + text + b.End() + after, nil
}
// blocks fills every generated block of the pages below root, the repo's
// root, writing a page only when its block changed, and returns the pages
// that changed. With check, it writes none.
func blocks(root string, check bool) ([]string, error) {
var stale []string
for _, b := range cli.DocBlocks() {
path := filepath.Join(root, filepath.FromSlash(b.Page))
data, err := os.ReadFile(path) //nolint:gosec // a page of the developer's repo
if err != nil {
return nil, err
}
page, err := filled(string(data), b)
if err != nil {
return nil, err
}
if page == string(data) {
continue
}
stale = append(stale, b.Page)
if !check {
if err := state.WriteFileMode(path, []byte(page), 0o644); err != nil {
return nil, err
}
}
}
return stale, nil
}