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 import commands with API auth - #3

Draft
nomark-dev wants to merge 2 commits into
mainfrom
claude/festive-davinci-ysm7md
Draft

nomark-dev wants to merge 2 commits into
mainfrom
claude/festive-davinci-ysm7md

Conversation

@nomark-dev

Copy link
Copy Markdown
Contributor

Summary

  • nomark login — validates a nomark_sk_ API key against the process-import edge function, saves it to ~/.nomark/config.json (chmod 0600). Reads from NOMARK_TOKEN env or interactive prompt.
  • nomark whoami — reads the stored token, validates it against the API, and prints the masked key on success. Exits 1 with a clear message if not authenticated.
  • nomark import --platform <p> --file <f> — supports chatgpt, claude, gemini; parses the export file, POSTs to process-import with Authorization: Bearer, and prints an ImportResult summary (conversations analysed, signals extracted/promoted, by-confidence breakdown).
  • config.ts fix — replaced module-level CONFIG_DIR/CONFIG_PATH constants (evaluated at import time) with getConfigDir()/getConfigPath() runtime functions, fixing test isolation when HOME is overridden per-test.
  • README — added Install, Authenticate, Import, and Managing API Keys sections.

Security

  • Credentials never logged or echoed beyond the masked last-4 display.
  • Config file written with fs.chmodSync(path, 0o600) after every save.
  • Token sent only to https://cnwiskdzeygqxezmazoq.supabase.co/functions/v1/process-import.

Test plan

  • 291 tests pass (npm test) — 13 new import tests, 5 login, 5 whoami, 7 config
  • TypeScript clean (npx tsc --noEmit)
  • Build succeeds (npm run build) — ESM + CJS + DTS all emit
  • Manual: NOMARK_TOKEN=nomark_sk_... npx nomark login saves key and shows masked confirmation
  • Manual: npx nomark whoami shows authenticated status
  • Manual: npx nomark import --platform chatgpt --file conversations.json prints ImportResult summary

Generated by Claude Code

claude added 2 commits June 23, 2026 14:26
- loginCommand: validates nomark_sk_ token against process-import endpoint,
  saves to ~/.nomark/config.json with chmod 0600
- whoamiCommand: reads stored token, validates against API, shows masked key
- importCommand: supports chatgpt, claude, gemini platforms; reads file,
  POSTs to process-import with Bearer auth, prints ImportResult summary
- config.ts: replace module-level constants with runtime functions so
  os.homedir() is evaluated at call time (fixes test isolation)
- index.ts: wire login/whoami routes, update HELP text, bump VERSION 0.2.1
- 13 new tests for import, 5 for login, 5 for whoami, 7 for config
- README: add Install, Authenticate, Import, Managing API Keys sections

All 291 tests pass. Build succeeds (tsup). TypeScript clean.
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