Skip to content

Extract chat-domain formatters into publishable SDK package#2

Open
Herklos wants to merge 4 commits into
masterfrom
claude/octochat-sdk-library-BTidf
Open

Extract chat-domain formatters into publishable SDK package#2
Herklos wants to merge 4 commits into
masterfrom
claude/octochat-sdk-library-BTidf

Conversation

@Herklos
Copy link
Copy Markdown
Collaborator

@Herklos Herklos commented Jun 5, 2026

Summary

Introduces @drakkar.software/octochat-sdk, a new headless, publishable package containing reusable OctoChat core logic with no UI or platform lock-in. The mobile app now consumes formatting utilities (format, emoji, message-format, markdown) from the SDK instead of local @/lib imports.

Key Changes

  • New SDK package (packages/sdk):

    • Created package.json, tsconfig.json, tsup.config.ts, and vitest.config.ts for a standalone, publishable ESM module
    • Configured to bundle chat-domain logic while keeping @drakkar.software/* packages external (consumer owns the single installed copy)
    • Tier 1 extraction: pure formatters (format, emoji, message-format, markdown) with no UI or Starfish dependency
  • Mobile app integration:

    • Added SDK as a workspace dependency in apps/mobile/package.json
    • Updated tsconfig.json path alias to resolve @drakkar.software/octochat-sdk to SDK source during development
    • Updated vitest.config.ts to alias SDK imports to source for test runs without a build step
    • Migrated 11 component and utility files to import formatters from @drakkar.software/octochat-sdk instead of @/lib
  • Documentation:

    • Updated CLAUDE.md to document the new SDK package and its role in the monorepo

Implementation Details

  • SDK exports are re-exported from src/index.ts for a clean public API
  • Mobile app path aliases enable seamless consumption of SDK source during development while supporting future published npm distribution
  • Formatter modules remain unchanged; only import paths updated to reflect new ownership

https://claude.ai/code/session_01TfQhHrB93ondXY7BTpWLiq

…matters (Tier 1)

New publishable headless-core package (tsup ESM+DTS, vitest). Move the pure,
dependency-free formatters — format, emoji, message-format, markdown (+ their
tests) — out of apps/mobile/src/lib into packages/sdk, rewrite app imports to
the package barrel, and wire it into the workspace (dependency, tsconfig path to
source, vitest alias to source). App typecheck clean; 289 app tests + 39 SDK
tests pass.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 5, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
octochat e2015e7 Jun 05 2026, 09:42 PM

claude added 2 commits June 5, 2026 15:41
…ploy)

The SDK's dist is gitignored, so a fresh CI checkout couldn't resolve
@drakkar.software/octochat-sdk via package exports -> dist, breaking the Expo
web export (Cloudflare deploy). Map the package name to packages/sdk/src in
metro.config.js so Metro bundles it from source (it already watches the
workspace root); make the barrel imports extensionless so Metro resolves them.
Verified: expo export -p web succeeds; published npm package still ships dist.
…-sdk

Move the bulk of OctoChat's non-UI logic out of apps/mobile/src/lib into the
publishable headless SDK: the whole Starfish sync/crypto layer (identity, client,
keyrings, registry, objects/object-index, members, member-caps, dm/pubspace,
attachments, stream-bots, session-restore, paths, account-seal) plus the domain
types and id helpers — ~50 modules + 108 tests.

- Adapter seams: configureOctoChat() (server URL/namespace/events/web origin,
  replacing env reads) and configureKv() (localStorage/AsyncStorage), wired once
  at boot via apps/mobile/src/lib/octochat-init.ts. The SDK is now fully headless
  (no React, no Expo, no env, no platform branching) so any frontend can consume it.
- App rewired: 237 import sites across 117 files now import from the package;
  platform-branched modules (kv/storage/platform/passkey/hash-wasm-shim) + React
  contexts/hooks stay in the app. Built on the published starfish alpha.19.

Verified: SDK typecheck+build+108 tests; app typecheck; 220 app tests; web export.
@Herklos Herklos force-pushed the claude/octochat-sdk-library-BTidf branch from ac22a2c to 9c1c95e Compare June 5, 2026 18:42
Extract the rest of OctoChat's non-UI logic from apps/mobile/src/lib into the SDK:
reads/mutes (synced prefs), quick-reactions-settings, reactions, message-view,
threads, cross-room, space-stats, project-board, doc-block, nostr, object-types,
notification-format/labels/preview, explore-spaces, the events SSE subscriber
(events.shared), the pure link parsers (linkify/mentionsUser), the outbox message
shape + headless send, and the automations core (runner/orchestrator/hash/secrets/
append/registry-write/providers).

- Intra-SDK imports resolve to specific sibling modules (no barrel cycles);
  kv/config route through the SDK's adapters/config seams.
- Decoupled the last UI leaks: object-types/automations icons are plain strings
  (the app casts to IconName); pure links split from the app's openUrl/openRoom.
- Removed the dead events.ts/events.native.ts re-export shims (consumers import
  subscribeRoomChanges from the SDK directly).
- App keeps only React (contexts + use-* hooks), platform-branched modules
  (kv/storage/platform/passkey/connectivity/...), the outbox store, links nav.

Verified: SDK 275 tests + typecheck + build; app typecheck; 52 app tests; web export.
@Herklos Herklos force-pushed the claude/octochat-sdk-library-BTidf branch from 9c1c95e to e2015e7 Compare June 5, 2026 21:41
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