Skip to content

feat(cli): add authored data sync commands#76

Open
jost-s wants to merge 1 commit into
mainfrom
feat/add-data-sync-commands-to-cli
Open

feat(cli): add authored data sync commands#76
jost-s wants to merge 1 commit into
mainfrom
feat/add-data-sync-commands-to-cli

Conversation

@jost-s

@jost-s jost-s commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Add commands to create data blobs in the in-memory store, inspect the store and pull them from other peers.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jost-s, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 34 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 828d1f73-6291-442b-993e-c944f0b65992

📥 Commits

Reviewing files that changed from the base of the PR and between 78b9f25 and 6bed28b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • packages/authored-data-sync/src/authored-data-sync.ts
  • packages/authored-data-sync/src/index.ts
  • packages/cli/package.json
  • packages/cli/src/commands.ts
  • packages/cli/src/logging.ts
  • packages/cli/src/main.ts
  • packages/cli/src/node.ts
  • packages/cli/src/relay.ts
  • packages/peer-session/src/node.ts

Walkthrough

This PR splits the CLI into relay and node command modules, adds an interactive node REPL runner, configures file-based and environment-driven logging, exposes authored-data-sync epochDuration and store types, and extends peer-session with a Peer type, a connect(alias) method, and optional module registration when starting a node.

Suggested reviewers

  • veeso
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose and scope of the new CLI commands for authored data sync.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding CLI commands for authored data synchronization functionality across multiple CLI files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-data-sync-commands-to-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jost-s jost-s force-pushed the feat/add-data-sync-package branch 5 times, most recently from 2e1ee8e to 7f297aa Compare June 6, 2026 17:15
@veeso veeso force-pushed the feat/add-data-sync-package branch from 7f297aa to b904aaa Compare June 7, 2026 08:48
@jost-s jost-s force-pushed the feat/add-data-sync-package branch 2 times, most recently from 0b26fc6 to 6c9234f Compare June 8, 2026 09:21
Base automatically changed from feat/add-data-sync-package to main June 8, 2026 09:32
@jost-s jost-s force-pushed the feat/add-data-sync-commands-to-cli branch from cebbeb7 to 9483c21 Compare June 9, 2026 11:24

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/cli/src/relay.ts (2)

59-62: ⚡ Quick win

Add error handling in the SIGINT handler.

If relaySession.shutdown() throws, the error will be uncaught and might prevent the process from exiting cleanly. Wrap the call in try-catch to ensure a graceful shutdown even if cleanup fails.

♻️ Proposed error handling
       process.on("SIGINT", async () => {
-        await relaySession.shutdown();
-        process.exit(0);
+        try {
+          await relaySession.shutdown();
+        } catch (error) {
+          console.error(`Error during shutdown: ${error instanceof Error ? error.message : String(error)}`);
+        }
+        process.exit(0);
       });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/relay.ts` around lines 59 - 62, In the SIGINT handler
registered with process.on("SIGINT"), wrap the await relaySession.shutdown()
call in a try-catch so any thrown error is caught; inside try await
relaySession.shutdown(), and in catch log the error (use existing logger if
available, otherwise console.error) and then ensure the process still exits
(process.exit(0) on success, process.exit(1) on failure) so the process
terminates cleanly even if relaySession.shutdown() fails.

42-44: ⚡ Quick win

Consider wrapping buildRelayAnnounceAddr in a try-catch for better error UX.

buildRelayAnnounceAddr throws if the IP is invalid or if the port is 0. While the error messages are clear, an uncaught exception will display a stack trace. Wrapping in try-catch would allow you to format the error more cleanly and exit gracefully.

♻️ Proposed error handling
       const listenAddr = addr ?? localDevRelayListenAddr;
       let announceAddr: string | undefined;
       if (opts.publicIp) {
-        announceAddr = buildRelayAnnounceAddr(listenAddr, opts.publicIp);
+        try {
+          announceAddr = buildRelayAnnounceAddr(listenAddr, opts.publicIp);
+        } catch (error) {
+          console.error(`Failed to build relay announce address: ${error instanceof Error ? error.message : String(error)}`);
+          process.exit(1);
+        }
       }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/relay.ts` around lines 42 - 44, Wrap the call to
buildRelayAnnounceAddr(listenAddr, opts.publicIp) in a try-catch inside the
branch that checks opts.publicIp; on error, catch the thrown exception, log a
clean user-facing message (including the error.message) instead of letting a
stack trace print, and exit the process with a non-zero code so announceAddr
isn't used when invalid. Ensure you reference announceAddr, listenAddr and
opts.publicIp in the handler so the log gives context about which input failed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/logging.ts`:
- Around line 3-5: Wrap the parseLogLevel(process.env.PEERKIT_LOG) call in a
try-catch: if PEERKIT_LOG is set, attempt to parse it inside try and assign to
logLevel; on catch, write a clear user-friendly error to stderr (including the
invalid value and the parse error message) and exit non-zero (process.exit(1))
so the CLI fails fast with a helpful message; if PEERKIT_LOG is not set then
keep the existing default "warning". Use the existing symbol names logLevel,
parseLogLevel and PEERKIT_LOG in this change.

In `@packages/cli/src/relay.ts`:
- Around line 45-57: Wrap the call to startRelay in a try-catch to handle
startup failures: catch errors thrown by startRelay (e.g., transport/port
failures), log a clear message including the error (use console.error or
processLogger if available) and exit with a non-zero status; ensure you still
reference relaySession.dialAddr only after successful startRelay so the code
that logs Relay address runs inside the try block and any cleanup or graceful
shutdown logic can run in the catch/finally as needed.

---

Nitpick comments:
In `@packages/cli/src/relay.ts`:
- Around line 59-62: In the SIGINT handler registered with process.on("SIGINT"),
wrap the await relaySession.shutdown() call in a try-catch so any thrown error
is caught; inside try await relaySession.shutdown(), and in catch log the error
(use existing logger if available, otherwise console.error) and then ensure the
process still exits (process.exit(0) on success, process.exit(1) on failure) so
the process terminates cleanly even if relaySession.shutdown() fails.
- Around line 42-44: Wrap the call to buildRelayAnnounceAddr(listenAddr,
opts.publicIp) in a try-catch inside the branch that checks opts.publicIp; on
error, catch the thrown exception, log a clean user-facing message (including
the error.message) instead of letting a stack trace print, and exit the process
with a non-zero code so announceAddr isn't used when invalid. Ensure you
reference announceAddr, listenAddr and opts.publicIp in the handler so the log
gives context about which input failed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c207ba0-bc6d-4ead-8cac-62957e6c24bc

📥 Commits

Reviewing files that changed from the base of the PR and between 393cc54 and 9483c21.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • packages/authored-data-sync/src/authored-data-sync.ts
  • packages/cli/package.json
  • packages/cli/src/commands.ts
  • packages/cli/src/logging.ts
  • packages/cli/src/main.ts
  • packages/cli/src/node.ts
  • packages/cli/src/relay.ts
  • packages/peer-session/src/node.ts

Comment thread packages/cli/src/commands.ts
Comment thread packages/cli/src/logging.ts
Comment thread packages/cli/src/relay.ts
@jost-s jost-s force-pushed the feat/add-data-sync-commands-to-cli branch from 9483c21 to 78b9f25 Compare June 9, 2026 15:36

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/package.json`:
- Around line 32-33: The package.json uses exact versions for `@peerkit/api` and
`@peerkit/authored-data-sync` but other workspace `@peerkit` deps use caret ranges;
update the dependency entries for "`@peerkit/api`" and
"`@peerkit/authored-data-sync`" to use caret-prefixed versions (e.g.
^0.1.0-alpha.12) so they match the existing pattern for "`@peerkit/peer-session`"
and "`@peerkit/transport-libp2p-nodejs`" and then regenerate your lockfile
(npm/yarn/pnpm) if needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51362865-8a86-417f-b8e9-c81a95d58bb4

📥 Commits

Reviewing files that changed from the base of the PR and between 9483c21 and 78b9f25.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • packages/authored-data-sync/src/authored-data-sync.ts
  • packages/authored-data-sync/src/index.ts
  • packages/cli/package.json
  • packages/cli/src/commands.ts
  • packages/cli/src/logging.ts
  • packages/cli/src/main.ts
  • packages/cli/src/node.ts
  • packages/cli/src/relay.ts
  • packages/peer-session/src/node.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/cli/src/logging.ts
  • packages/authored-data-sync/src/authored-data-sync.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/cli/src/relay.ts
  • packages/peer-session/src/node.ts
  • packages/cli/src/commands.ts
  • packages/cli/src/main.ts
  • packages/cli/src/node.ts

Comment thread packages/cli/package.json Outdated
@jost-s jost-s force-pushed the feat/add-data-sync-commands-to-cli branch from 78b9f25 to 6bed28b Compare June 9, 2026 15:45
@cocogitto-bot

cocogitto-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

✔️ 6bed28b - Conventional commits check succeeded.

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