Skip to content

feat: client-flip self_hosted mode (route item CRUD to cloud API) - #19

Merged
andrei-hasna merged 1 commit into
mainfrom
feat/client-flip-self-hosted
Jul 7, 2026
Merged

feat: client-flip self_hosted mode (route item CRUD to cloud API)#19
andrei-hasna merged 1 commit into
mainfrom
feat/client-flip-self-hosted

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

Wires the knowledge CLI storage resolver to the @hasna/contracts HTTP storage client so mode=self_hosted actually reads/writes the cloud API.

What

  • New src/cloud-store.ts: resolveKnowledgeCloudStore(env) returns a cloud store when the client-flip resolves to cloud-http (HASNA_KNOWLEDGE_STORAGE_MODE=self_hosted + HASNA_KNOWLEDGE_API_URL + HASNA_KNOWLEDGE_API_KEY), else null (local). Throws if cloud requested but misconfigured (no silent local drift).
  • src/cli.ts: every knowledge-item command (add/list/get/update/archive/restore/untag/upsert/delete/export/prune/dedupe/stats) routes to https://knowledge.hasna.xyz/v1/notes when cloud is active, else local db.json. --store override pins to local.
  • Bumps @hasna/contracts to ^0.5.0 (client/storage subpath).

Proof (installed CLI against the live cloud)

  • create -> verified via independent curl to the API -> delete -> confirmed gone.
  • With env unset, writes go to local db.json and are NOT present in the cloud.

Tests

  • New tests/cloud-store.test.ts (6 pass). Pre-existing failures in cloud-storage-kit.test.ts are unrelated.

Architecture: API-client only (bearer key to .hasna.xyz/v1). No DSN, no STORAGE_MODE=remote, reversible by unsetting the env vars.

When HASNA_KNOWLEDGE_STORAGE_MODE=self_hosted and HASNA_KNOWLEDGE_API_URL +
HASNA_KNOWLEDGE_API_KEY are set, the CLI now routes every knowledge-item
read and write (add/list/get/update/archive/restore/untag/upsert/delete/
export/prune/dedupe/stats) to https://knowledge.hasna.xyz/v1/notes via the
@hasna/contracts HTTP storage client (bearer key), instead of the local
db.json store. Unset the env vars -> local (fully reversible). An explicit
--store override always pins to local.

Bumps @hasna/contracts to ^0.5.0 for the client/storage subpath.
@andrei-hasna
andrei-hasna merged commit 344bd13 into main Jul 7, 2026
0 of 7 checks passed
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.

1 participant