feat: client-flip self_hosted mode (route item CRUD to cloud API) - #19
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wires the knowledge CLI storage resolver to the @hasna/contracts HTTP storage client so
mode=self_hostedactually reads/writes the cloud API.What
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 tohttps://knowledge.hasna.xyz/v1/noteswhen cloud is active, else local db.json.--storeoverride pins to local.@hasna/contractsto ^0.5.0 (client/storage subpath).Proof (installed CLI against the live cloud)
curlto the API -> delete -> confirmed gone.Tests
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.