Skip to content

feat(cli): add CLI scaffold, app bootstrap, daemon, and shared libraries#670

Merged
alexfreska merged 1 commit into
mainfrom
cli/scaffold-and-daemon
May 8, 2026
Merged

feat(cli): add CLI scaffold, app bootstrap, daemon, and shared libraries#670
alexfreska merged 1 commit into
mainfrom
cli/scaffold-and-daemon

Conversation

@alexfreska

Copy link
Copy Markdown
Member

Adds the cli/daemon runtime foundation that runs sync, thumbnail, optimize, trash-purge, and log-rotation workers on a scheduler, exposed over a Unix-socket IPC server. A CliApp factory wires SQLite, fsIO, secrets, and the SDK; daemon entry is split into lifecycle, scheduler, and ipc/* modules.

Copilot AI review requested due to automatic review settings May 6, 2026 23:01
@socket-security

socket-security Bot commented May 6, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​types/​react-dom@​19.2.31001007586100
Added@​tailwindcss/​cli@​4.2.21001007798100
Addedlucide-react@​1.8.0100100989580
Added@​types/​node@​22.15.21001008196100
Addedtailwindcss@​4.2.21001008498100
Addedcommander@​14.0.39810010085100
Addedreact-dom@​19.2.01001009298100
Added@​clack/​prompts@​1.2.010010010095100

View full report

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the initial CLI + daemon runtime scaffold for Sia Storage, including IPC transport, background worker scheduling, and node-side database lifecycle support (finalize/close), plus repo-level scripts and dependency wiring to build and test the new CLI app.

Changes:

  • Extend the core DatabaseAdapter contract with optional lifecycle hooks (finalize, close) and implement them in node adapters.
  • Introduce apps/cli scaffold: bootstrap wiring, daemon lifecycle/scheduler, Unix-socket IPC server + client helpers, and basic CLI entrypoint.
  • Add supporting scripts/config (root package.json scripts, CLI tsconfig/jest config, changeset, lockfile updates).

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
packages/node-adapters/src/database.ts better-sqlite3 adapter: expose finalize() and adjust adapter typing
packages/node-adapters/src/bunDatabase.ts bun:sqlite adapter: expose finalize() and adjust adapter typing
packages/core/src/db/operations/test-setup.ts Test DB setup/teardown updated for optional close()
packages/core/src/adapters/db.ts DatabaseAdapter docs + optional lifecycle methods (finalize, close)
package.json Add root scripts for building/linking CLI
bun.lock Lockfile updates for new CLI deps and version bumps
apps/integration/test/fs-eviction.test.ts Fix ArrayBuffer write payload construction for test FS writes
apps/integration/test/app.ts Adjust test database wrapper for optional close() typing
apps/cli/tsconfig.json CLI TypeScript config + workspace path mappings
apps/cli/test/e2e/setup.ts Placeholder E2E setup file (future PR hook)
apps/cli/test/mocks/bun-sqlite.ts Jest runtime stub for bun:sqlite in tests
apps/cli/test/mocks/@siafoundation/sia-storage.ts Jest runtime stubs for SDK bindings during tests
apps/cli/src/testMode.ts Test-mode bootstrap using Mock SDK and stubbed auth adapters
apps/cli/src/lib/resolveFile.ts Utility to resolve a file by id/path/name for CLI commands
apps/cli/src/lib/normalizePath.ts Path normalization helper for CLI argument parsing
apps/cli/src/lib/ingestFile.ts Disk-to-library ingestion helper (stream copy + sha256 + DB record)
apps/cli/src/lib/format.ts CLI formatting helpers (colors, bytes/date formatting, table/progress)
apps/cli/src/lib/appServiceClient.ts IPC-backed AppService client factory for CLI ↔ daemon
apps/cli/src/index.ts CLI entrypoint + daemon mode fork via env flag
apps/cli/src/daemon/supervisor.ts Ensure daemon running + IPC command helper
apps/cli/src/daemon/spawn.ts Spawn detached daemon process with log redirection
apps/cli/src/daemon/scheduler.ts Interval-based background service scheduler initialization
apps/cli/src/daemon/lifecycle.ts Lock acquisition + signal handling + graceful shutdown sequence
apps/cli/src/daemon/ipc/upload.ts IPC handlers for upload + upload state queries
apps/cli/src/daemon/ipc/status.ts IPC handlers for ping/status/shutdown
apps/cli/src/daemon/ipc/index.ts IPC dispatcher wiring + AppService method reflection
apps/cli/src/daemon/entry.ts Daemon startup orchestration (bootstrap, scheduler, IPC, signals)
apps/cli/src/app.ts CLI app factory/bootstrap wiring (DB/storage/secrets/sdk/uploader/etc.)
apps/cli/package.json CLI package metadata, scripts, and dependencies
apps/cli/jest.config.cjs Jest multi-project config (unit + e2e) with module mapping
.changeset/cli-scaffold-daemon.md Changeset documenting the new CLI/daemon scaffold
Comments suppressed due to low confidence (1)

packages/core/src/db/operations/test-setup.ts:10

  • _db is declared as a non-nullable DatabaseAdapter but is uninitialized until setupTestDb() runs. This makes db()’s signature unsound (it can return undefined at runtime) and leads to awkward optional chaining in teardown. Consider declaring _db as DatabaseAdapter | undefined (or | null) and updating db() to either throw if called before setup or return an optional type.
let _db: DatabaseAdapter

export function db(): DatabaseAdapter {
  return _db
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/node-adapters/src/database.ts
Comment thread packages/node-adapters/src/bunDatabase.ts
Comment thread apps/cli/src/index.ts Outdated
Comment thread apps/cli/src/index.ts Outdated
Comment thread apps/cli/src/lib/format.ts Outdated
Comment thread apps/cli/src/daemon/supervisor.ts Outdated
Comment thread apps/cli/src/daemon/lifecycle.ts Outdated
Comment thread apps/cli/src/daemon/entry.ts Outdated
Comment thread apps/cli/src/daemon/ipc/index.ts
Comment thread apps/cli/jest.config.cjs
@alexfreska alexfreska force-pushed the cli/scaffold-and-daemon branch 2 times, most recently from b476d53 to d14eb29 Compare May 7, 2026 22:12
@alexfreska alexfreska force-pushed the cli/scaffold-and-daemon branch from d14eb29 to dadb90c Compare May 8, 2026 21:37

alexfreska commented May 8, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • May 8, 10:25 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 8, 10:25 PM UTC: @alexfreska merged this pull request with Graphite.

@alexfreska alexfreska merged commit f05b020 into main May 8, 2026
9 checks passed
@alexfreska alexfreska deleted the cli/scaffold-and-daemon branch May 8, 2026 22:25
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.

3 participants