Skip to content

Commit 62ff303

Browse files
committed
feat: update CLI to use terminal-link for clickable URLs and enhance dependency documentation
1 parent 9cb3640 commit 62ff303

6 files changed

Lines changed: 128 additions & 9 deletions

File tree

AGENTS.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,38 @@
1717

1818
## Documentation
1919

20-
- `docs/plans/` stores numbered implementation plans for features and milestones.
20+
- `docs/plans/` stores numbered implementation plans for features and milestones. Name files `NNN-short-slug.md` (hyphen-separated).
2121
- Before starting a new feature or refactor, read the relevant plan in `docs/plans/`.
2222
- Keep plans aligned with staged or merged implementation changes.
2323

24+
### Plans
25+
26+
Every plan in `docs/plans/` that touches package dependencies must include a **Dependency Changes** section with:
27+
28+
- **Add**: package name(s) to install, with a one-line reason for each.
29+
- **Remove**: package name(s) to uninstall, with a one-line reason for each.
30+
- **Commands**: the exact `pnpm add` / `pnpm remove` commands for reference.
31+
32+
Example:
33+
34+
```markdown
35+
## Dependency Changes
36+
37+
### Add
38+
- `terminal-link` — OSC 8 hyperlinks for clickable CLI URLs.
39+
40+
### Remove
41+
- `consola` — only used for startup box; replaced by `terminal-link` + `console.info`.
42+
43+
### Commands (manual only)
44+
pnpm remove consola
45+
pnpm add terminal-link
46+
```
47+
48+
**Dependency commands are manual-only.** Do not run `pnpm add`, `pnpm remove`, or similar install/uninstall commands unless the user explicitly asks. List the commands in the plan; the user runs them by hand before or during implementation.
49+
50+
**Persist plans after execution.** Once implementation is done, write the finalized plan into `docs/plans/` so it is versioned in the repo. Use the next sequential number and a short slug joined by hyphens, for example `002-clickable-cli-url.md`. The committed plan should match what was actually shipped—update goals, dependency changes, and verification steps if they diverged during implementation. Do not leave execution-only plans in ephemeral locations when the work is complete.
51+
2452
## Tooling
2553

2654
- Use `pnpm` for all package operations.
@@ -46,7 +74,7 @@
4674
- Keep strict TypeScript settings satisfied; avoid weakening types to silence errors.
4775
- Prefer small, explicit exported APIs from `src/index.ts`.
4876
- Use `cac` for CLI startup and command parsing.
49-
- Use `consola` for CLI logging instead of direct `console.*` calls; prefer `consola.box` for CLI startup messages.
77+
- Use `terminal-link` for clickable CLI URLs; print startup messages with `console.info`.
5078
- Use `hono` with `@hono/node-server` for the local Web UI service; prefer simple Hono JSX views for the initial UI.
5179
- Preserve the package's side-effect-free behavior unless a feature explicitly requires otherwise.
5280
- Keep generated artifacts out of manual edits.
File renamed without changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Clickable CLI Startup URL Plan
2+
3+
## Goal
4+
5+
Make the workspace URL printed at CLI startup clickable in modern terminals (Cursor/VS Code, iTerm2, WezTerm, etc.). Replace `consola.box` with a simple one-line startup message.
6+
7+
The public package entrypoint in `src/index.ts` stays unchanged.
8+
9+
## Architecture
10+
11+
```mermaid
12+
flowchart TD
13+
userShell["User Shell"] --> packageBin["bin/index.js"]
14+
packageBin --> bundledBin["dist/bin/index.mjs"]
15+
bundledBin --> cacDefault["cac Default Command"]
16+
cacDefault --> startWebUi["startWebUiServer()"]
17+
cacDefault --> terminalLink["terminal-link OSC 8"]
18+
terminalLink --> consoleInfo["console.info"]
19+
startWebUi --> honoApp["Hono App"]
20+
```
21+
22+
## Dependency Changes
23+
24+
### Add
25+
26+
- `terminal-link` — wraps the URL in OSC 8 hyperlinks so supported terminals can open it with Cmd+click; uses `supports-hyperlinks` for capability detection.
27+
28+
### Remove
29+
30+
- `consola` — only used for `consola.box` on startup; replaced by `terminal-link` plus `console.info`.
31+
32+
### Commands (manual only)
33+
34+
```bash
35+
pnpm remove consola
36+
pnpm add terminal-link
37+
```
38+
39+
## Implementation
40+
41+
- `src/bin/index.ts` calls `terminalLink(webUi.url, webUi.url, { fallback: false })` and prints a one-line message via `console.info` after `startWebUiServer()`.
42+
- `AGENTS.md` updates CLI conventions: use `terminal-link` for clickable URLs; document plan dependency-change and post-execution persistence rules.
43+
44+
## Behavior
45+
46+
- Host remains hard-coded to `127.0.0.1`; port remains `7777`.
47+
- Startup output is a single line: `Foundry workspace is running at <url>`.
48+
- `fallback: false` keeps unsupported terminals from printing the URL twice.
49+
- Apple Terminal.app does not support OSC 8; the URL still displays as plain text.
50+
51+
## Verification
52+
53+
- `pnpm run lint`
54+
- `pnpm run test`
55+
- `pnpm run build`
56+
- Run `foundry` in Cursor terminal; Cmd+click the URL to open `http://127.0.0.1:7777`.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"dependencies": {
8585
"@hono/node-server": "^2.0.8",
8686
"cac": "^7.0.0",
87-
"consola": "^3.4.2",
88-
"hono": "^4.12.27"
87+
"hono": "^4.12.27",
88+
"terminal-link": "^5.0.0"
8989
}
9090
}

pnpm-lock.yaml

Lines changed: 33 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bin/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import cac from 'cac';
2-
import { consola } from 'consola';
2+
import terminalLink from 'terminal-link';
33
import { startWebUiServer } from './server';
44

55
const cli = cac('foundry');
@@ -8,7 +8,12 @@ cli
88
.command('[...args]', 'Open a local Foundry workspace')
99
.action(() => {
1010
const webUi = startWebUiServer();
11-
consola.box(`Foundry workspace is running at ${webUi.url}`);
11+
const linkedUrl = terminalLink(
12+
webUi.url,
13+
webUi.url,
14+
{ fallback: false },
15+
);
16+
console.info(`Foundry workspace is running at ${linkedUrl}`);
1217
});
1318

1419
cli.help();

0 commit comments

Comments
 (0)