Skip to content

Create ppg serve command and Fastify server scaffold #63

@2witstudios

Description

@2witstudios

Epic 2: Server Foundation — Issue 1/5

Source: Composite — 2-agent's lifecycle + serve-auth's security

Description

Create the ppg serve command and Fastify server scaffold with plugin architecture, CORS, health endpoint, graceful shutdown, and state file management.

Acceptance Criteria

  • src/commands/serve.ts — Commander.js registration with --port, --host, --token, --daemon, --json
  • src/server/index.ts — Fastify instance with CORS, plugin registration hooks
  • Health endpoint: GET /health returns { status: "ok", uptime, version }
  • Graceful shutdown on SIGTERM/SIGINT
  • State file (serve.json) with 0o600 permissions
  • Path helpers: serveConfigPath(), servePidPath() in lib/paths.ts
  • QR code display on startup (token + connection URL)
  • Network interface detection for LAN IP

Files to Create/Modify

  • src/commands/serve.ts (new)
  • src/server/index.ts (new)
  • src/lib/paths.ts (add serve paths)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions