Skip to content

feat(cli): contextify compile + deprecate prompt#9

Merged
furkankoykiran merged 3 commits into
mainfrom
feat/compile-command
May 18, 2026
Merged

feat(cli): contextify compile + deprecate prompt#9
furkankoykiran merged 3 commits into
mainfrom
feat/compile-command

Conversation

@furkankoykiran
Copy link
Copy Markdown
Owner

contextify compile <intent> is the new canonical command for producing Claude-Code-ready XML prompts. Same server engine as contextify prompt, three output modes (mutually exclusive):

  • --raw (default): XML to stdout, pipe-friendly.
  • --paste: copy to system clipboard, stderr confirmation.
  • --claude: clipboard + stderr tip framed for Claude Code paste.

Clipboard goes to the platform's native tool (pbcopy / wl-copy / xclip / xsel / clip.exe) so the CLI stays clipboard-dep-free. Failure falls back to stdout + exit 1.

contextify prompt keeps working and now prints a one-line stderr deprecation. Both commands share a prompt-client.ts helper, so there is one HTTP path inside the CLI matching the one synth engine on the server (generateProjectPrompt in apps/web).

Tests

  • 7 new unit tests in src/commands/compile.test.ts (default raw, --paste, --claude, clipboard fallback, mutex enforcement, stdin path, Bearer key attach). All green locally.
  • tsc --noEmit green.
  • Dogfooded end-to-end against a localhost Contextify with a real API key: all three modes produce valid synthesized XML and persist correctly.

Test plan

  • pnpm build then node dist/index.js --help shows the new compile section.
  • contextify compile "task description" prints XML to stdout (needs CONTEXTIFY_API_KEY configured).
  • contextify compile "x" --paste copies XML and stderr prints "Copied compiled prompt to clipboard."
  • contextify compile "x" --claude copies XML and stderr prints the Claude Code paste tip.
  • contextify compile "x" --raw --paste returns exit 2 with the mutex message.
  • contextify prompt "x" still works and prints the deprecation line on stderr.

After merge: bump package.json to 0.6.0, tag v0.6.0, push — the release workflow auto-publishes to npm.

`contextify compile <intent>` is the new canonical command for producing
Claude-Code-ready XML from an intent draft. Output modes are mutually
exclusive: --raw to stdout (default, pipe-friendly), --paste to the
system clipboard, --claude to clipboard with a stderr tip framed for
Claude Code paste. Clipboard uses the platform's native tool
(pbcopy/wl-copy/xclip/xsel/clip.exe) so the CLI stays free of clipboard
npm deps.

Both `compile` and the older `prompt` route through a single
prompt-client.ts helper, which POSTs to /api/prompt/generate — the one
synth engine in apps/web/src/lib/prompt-pipeline.ts. `prompt` continues
to work but now emits a one-line stderr deprecation; it will be removed
in a future minor.
Root monorepo's `pnpm format:check` glob picks up files inside the
submodule. CI on contextify/contextify caught the unformatted hunks
and failed the lint+typecheck+test+build job. Format is identical
to what prettier --write produces locally; no behavior change.
Comment thread src/prompt-client.ts

let res: Response;
try {
res = await fetchImpl(url, { method: 'POST', headers, body: JSON.stringify(body) });
Comment thread src/prompt-client.ts

let res: Response;
try {
res = await fetchImpl(url, { method: 'POST', headers, body: JSON.stringify(body) });
CodeQL flagged the fetch on prompt-client.ts:63 as a `js/file-access-to-http`
finding (alerts #11 + #12 on PR #9). The flag is technically accurate but
by-design: this CLI exists to read locally-stored project config + API
credential and POST them to the configured Contextify server. There is no
untrusted intermediary; the URL is constructed from the operator-controlled
serverUrl in resolveConfig.

Inline lgtm[js/file-access-to-http] suppression with a short rationale
above the call. Scope is intentionally narrow — does not touch the same
pre-existing pattern in src/commands/prompt.ts (alerts #8 + #9). That
pattern was present on main before this PR and should be cleaned up in a
separate security-hygiene pass, not bundled into the compile release.
@furkankoykiran furkankoykiran merged commit 221c05a into main May 18, 2026
4 checks passed
@furkankoykiran furkankoykiran deleted the feat/compile-command branch May 18, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants