Lines 6-46javascript
6// Design contract (see docs/architecture/overview.md and the ypic task plan):
7// - `ypic` does NOT self-start a server. On launch it performs a single
8// `GET /api/cli/health` against the configured host:port. If the check
9// fails or the responder is not yolk-pi-web, it prints guidance telling
10// the user to manually start `ypi` / the Web server and exits.
11// - Chat is driven entirely over the existing HTTP/SSE API:
12// POST /api/agent/draft -> create an empty session bound to cwd
13// GET /api/agent/:id/events -> SSE stream of agent events
14// POST /api/agent/:id -> prompt / steer / follow_up / abort / get_state
15// This keeps Studio extension injection, approval gate, JSONL, usage
16// accounting and tool-call normalization identical to Web sessions.
17// - The current directory (process.cwd()) is the workspace. If it is not
18// already a known project/space, `ypic` registers it through the existing
19// Project Registry API (idempotent by canonical pathKey) so the Web/Studio
20// side treats it as a normal project space.
22// This file is CommonJS and only depends on Node built-ins plus the shared
23// `bin/server-runner.js` `openBrowser` helper. It MUST NOT import project
24// TypeScript (lib/**) so the npm-published package can execute it directly.
26// eslint-disable-next-line @typescript-eslint/no-require-imports
27const { parseArgs } = require("util");
28// eslint-disable-next-line @typescript-eslint/no-require-imports
MediumDynamic Require
Package source references dynamic require/import behavior.
bin/ypic.jsView on unpkg · L26 29const readline = require("readline");
30// eslint-disable-next-line @typescript-eslint/no-require-imports
31const fs = require("fs");
32// eslint-disable-next-line @typescript-eslint/no-require-imports
33const path = require("path");
34// eslint-disable-next-line @typescript-eslint/no-require-imports
35const serverRunner = require("./server-runner");
37const { openBrowser } = serverRunner;
39const DEFAULT_PORT = "30141";
41const HELP_TEXT = `ypic — terminal chat for yolk pi web
44 ypic [options] [message] Start a chat session in the current directory.
45 If [message] is given it is sent as the first
46 prompt, then the chat loop continues.