Skip to content

warren init --project against a remote server #1240

Description

@jayminwest

The gap

warren init --project <id> only works when the CLI runs on the same machine as the warren server. Against a remote server it fails with project clone missing on disk, even though the docs present it as the way to scaffold config for a project warren manages.

src/cli/commands/target-dir.ts:44-53 fetches the project row over GET /projects/:id and then checks existsSync(row.localPath) on the machine running the CLI. localPath is a path on the server's filesystem, so on any other machine the check fails and throws. src/cli/commands/init.ts:114-146 then expects to mkdir and writeFile into that path locally. src/cli/commands/config-migrate.ts:80 goes through the same resolveTargetDir and has the same limitation.

There is no write route for this today. src/server/handlers/route-table.ts:192-197 serves only GET /projects/:id/warren-config, and the nearest mutation is POST /projects/:id/refresh (:230-233).

docs/onboarding-external-repos.md:18-39 documents warren init --project as step 2 of the mirror recipe, with no mention that it must run on the host. The comment at target-dir.ts:40-43 records the earlier decision that "writing into the clone only makes sense on the host", which this issue reverses.

What to build

  1. A server route that scaffolds .warren/triggers.yaml and .warren/config.yaml into the project's host clone. POST /projects/:id/init with a JSON body carrying the same options the CLI accepts today (default role, prompt, provider, model, branch prefix, and an overwrite flag) is the recommended shape. The handler goes in src/server/handlers/projects.ts next to refreshProjectHandler (:443), which is the precedent for an admin-policy mutation on a project. Reuse the existing template and renderConfigYaml logic from init.ts by moving it into src/projects/ so the handler and the CLI call one implementation (the "single source of truth" rule in AGENTS.md).
  2. An SDK method on WarrenClient in src/client/client.ts, beside refreshProject (:174).
  3. The CLI switch. warren init --project calls the route. Keep the current local-filesystem path for the no---project case (scaffolding the current directory), which never touches the server. Apply the same change to warren config migrate --project.
  4. Docs. Regenerate docs/http-api.md and docs/openapi.yaml (bun run gen:docs, bun run gen:openapi), regenerate the CLI reference if flags change (bun run gen:cli-ref), and drop the host-only assumption from docs/onboarding-external-repos.md.

Scope

Out of scope: committing the scaffolded files upstream (they stay untracked in the host clone, as today), and any change to what the templates contain.

Tests: a new src/server/handlers/projects.init.test.ts following projects.refresh.test.ts; src/cli/commands/init.test.ts gains a remote-mode case (its mockClient at :31 already models projects by localPath, so extend it with the new method); src/cli/commands/config-migrate.test.ts; src/client/client.projects-agents.test.ts. bun run lint includes check-client-contract, which fails if the UI or SDK calls a path ROUTE_TABLE does not serve, so the route and the client must land together.

Getting started

AGENTS.md covers setup, the handler and SDK conventions, and the layer rules (src/cli/** must not import src/server/**). Everything here is testable in-process with no cluster and no credentials. Run bun run check:all before pushing. Warnings count as failures.

Tracked internally as warren-166d.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliCLI commands (src/cli/, warren / wr entry points)area/serverHTTP API surface (src/server/, ROUTE_TABLE, handlers)effort/medium1-3 days of focused workgood first challengeLarger contributor-ready project: scoped, self-contained, gate-verifiedhelp wantedMaintainers welcome external contributions herepriority/P2Medium: default priority for normal feature worktype/featureNew user-facing capability

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions