Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

feat(cli): add login, whoami, and cloud import commands - #2

Draft
nomark-dev wants to merge 1 commit into
mainfrom
claude/festive-davinci-ldejbp
Draft

nomark-dev wants to merge 1 commit into
mainfrom
claude/festive-davinci-ldejbp

Conversation

@nomark-dev

Copy link
Copy Markdown
Contributor

Summary

Implements the nomark CLI cloud authentication and import flow as specified in brief BRF-2026-04-12-nomark-cli.

  • nomark login — prompts for API key (or reads NOMARK_TOKEN env var), validates against the process-import edge function, saves to ~/.nomark/config.json (api_key field, mode 0600)
  • nomark whoami — probes auth and prints uid/email; exits non-zero if unauthenticated
  • nomark import --platform <chatgpt|claude|gemini> — when authenticated, POSTs to the process-import Supabase edge function; falls back to local parser mode when no API key is present
  • VERSION bumped to 0.2.0

Changes

File Change
src/cli/auth.ts New — loadApiKey / saveApiKey / clearApiKey (0600 config, NOMARK_TOKEN env var)
src/cli/http.ts New — cloudImport / probeAuth (edge function client)
src/cli/login.ts New — login command
src/cli/whoami.ts New — whoami command
src/cli/import.ts Modified — cloud mode when authenticated; fixed dryRun bug (was always true)
src/cli/index.ts Modified — async main, login/whoami registered, VERSION 0.2.0
README.md Added Install, Authenticate, Import, Managing API Keys sections
package.json Fixed @vitest/coverage-v8 version to match vitest ^2.0.0
tests/cli/auth.test.ts New — 15 tests (TDD)
tests/cli/http.test.ts New — 12 tests (TDD)

Test plan

  • All 288 tests pass (npm test)
  • Build succeeds (npm run build)
  • Line coverage ≥80% on src/ — 84.11% ✓
  • npx nomark --version prints 0.2.0
  • npx nomark login with NOMARK_TOKEN env var validates and saves key
  • npx nomark whoami prints uid/email or masked key
  • npx nomark import --platform chatgpt --file conversations.json routes to cloud when key is present
  • Config file written with mode 0600
  • API key never appears in request body (Authorization header only)

Security

  • CHARTER II.5: credentials only sent in Authorization: Bearer header; never logged, echoed, or in request body; config written 0600
  • CHARTER II.6: no tag/publish in this PR — publish gate is in existing .github/workflows/publish.yml

Notes

  • No changes to the process-import edge function or nomark-cloud schema (governance constraint respected)
  • ~/.nomark/config.json coexists with the existing apiKey (camelCase, local LLM key from config.ts) and new api_key (snake_case, NOMARK cloud key from auth.ts)
  • Gemini in local mode shows a clear error directing the user to nomark login

Generated by Claude Code

- Add auth.ts: loadApiKey/saveApiKey/clearApiKey with 0600 config file
  permissions; reads NOMARK_TOKEN env var or ~/.nomark/config.json api_key
- Add http.ts: cloudImport and probeAuth using process-import edge function
- Add login.ts: interactive key entry + NOMARK_TOKEN env var flow
- Add whoami.ts: probe-based auth check with uid/email display
- Update import.ts: cloud mode (POST to edge) when authenticated,
  local mode unchanged; fix dryRun bug (was always true when flag absent)
- Update index.ts: async main, login/whoami commands, VERSION 0.2.0
- Add README sections: Install, Authenticate, Import, Managing API Keys
- Tests: auth.test.ts (15), http.test.ts (12) — all 288 tests pass
- Coverage: 84.11% lines on src/ (threshold: 80%)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants