Skip to content

feat: extract reusable CLI package primitives - #784

Merged
ilyabo merged 1 commit into
mainfrom
codex/extract-reusable-cli-packages
Jul 2, 2026
Merged

ilyabo merged 1 commit into
mainfrom
codex/extract-reusable-cli-packages

Conversation

@ilyabo

@ilyabo ilyabo commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Extract command-backed block-document AI adapter into @sqlrooms/documents with canonical append command and actor constants.
  • Extract HTML app revision commands and HTML app block-document block construction into @sqlrooms/app-runtime.
  • Add a DuckDB-backed Mosaic database AI adapter and rewire the CLI app to use the new package primitives.
  • Leave the stateful block artifact registry in the CLI after evaluation because it is still host product surface.

Validation

  • pnpm build
  • pnpm --filter @sqlrooms/documents test --runInBand createBlockDocumentCommandAiAdapter.test.ts
  • pnpm --filter @sqlrooms/app-runtime test --runInBand HtmlAppRevisionCommands.test.ts
  • pnpm --filter @sqlrooms/mosaic test --runInBand createDatabaseAiAdapter.test.ts
  • pnpm --filter sqlrooms-cli-app test --runInBand createWorksheetAiAdapter.test.ts createHtmlAppRevisionCommands.test.ts
  • Pre-push hook: knip, turbo typecheck, madge --circular, turbo test

The Obsidian plan checklist is updated through Stage 6; Follow-up remains unchecked as requested.

Summary by CodeRabbit

  • New Features
    • Added shared HTML app revision controls (write, rename, restore, undo, redo) with canonical command IDs.
    • Introduced an AI block-document command adapter and an owned HTML app “block document” creator.
    • Added a DuckDB-backed database AI adapter factory.
  • Bug Fixes
    • Standardized command and actor identifiers across app and worksheet AI flows.
  • Documentation
    • Updated README/developer guidance for the shared revision and block-document workflows.
  • Tests
    • Expanded Jest coverage for revision command behavior and canonical command payloads.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 700509b0-c8d0-4ed2-95b6-eedb2e457174

📥 Commits

Reviewing files that changed from the base of the PR and between 7377770 and 43c6f86.

📒 Files selected for processing (21)
  • apps/sqlrooms-cli-ui/src/__tests__/createHtmlAppRevisionCommands.test.ts
  • apps/sqlrooms-cli-ui/src/__tests__/createWorksheetAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • apps/sqlrooms-cli-ui/src/createDatabaseAiAdapter.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppAgent.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppRevisionCommands.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
  • packages/app-runtime/README.md
  • packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts
  • packages/app-runtime/src/HtmlAppRevisionCommands.ts
  • packages/app-runtime/src/html-app-block-document.ts
  • packages/app-runtime/src/index.ts
  • packages/documents/README.md
  • packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts
  • packages/documents/src/createBlockDocumentCommandAiAdapter.ts
  • packages/documents/src/index.ts
  • packages/mosaic/README.md
  • packages/mosaic/__tests__/createDatabaseAiAdapter.test.ts
  • packages/mosaic/src/ai.ts
  • packages/mosaic/src/ai/createDatabaseAiAdapter.ts
  • packages/mosaic/src/index.ts
✅ Files skipped from review due to trivial changes (5)
  • packages/mosaic/src/ai.ts
  • packages/app-runtime/README.md
  • packages/mosaic/README.md
  • apps/sqlrooms-cli-ui/src/tests/createWorksheetAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppAgent.ts
🚧 Files skipped from review as they are similar to previous changes (16)
  • packages/app-runtime/src/index.ts
  • packages/documents/src/index.ts
  • packages/mosaic/src/ai/createDatabaseAiAdapter.ts
  • packages/app-runtime/src/html-app-block-document.ts
  • packages/mosaic/src/index.ts
  • apps/sqlrooms-cli-ui/src/createDatabaseAiAdapter.ts
  • packages/documents/README.md
  • packages/mosaic/tests/createDatabaseAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
  • packages/documents/tests/createBlockDocumentCommandAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppRevisionCommands.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • packages/documents/src/createBlockDocumentCommandAiAdapter.ts
  • packages/app-runtime/src/HtmlAppRevisionCommands.ts
  • packages/app-runtime/tests/HtmlAppRevisionCommands.test.ts
  • apps/sqlrooms-cli-ui/src/tests/createHtmlAppRevisionCommands.test.ts

📝 Walkthrough

Walkthrough

This PR extracts shared factories for HTML app revision commands, block-document AI adapters, and DuckDB database AI adapters, then updates sqlrooms-cli-ui and mosaic to use those shared implementations and exported constants.

Changes

Shared HTML app revision commands and block-document DTO

Layer / File(s) Summary
Revision command API
packages/app-runtime/src/HtmlAppRevisionCommands.ts
Defines command IDs, input schemas, options, and app selection logic for the HTML app revision command factory.
Revision command implementations and validation
packages/app-runtime/src/HtmlAppRevisionCommands.ts, packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts, packages/app-runtime/README.md, packages/app-runtime/src/index.ts
Implements write/rename/restore/undo/redo commands, with tests, docs, and exports for host wiring and command results.
HTML app block-document DTO helper
packages/app-runtime/src/html-app-block-document.ts, packages/app-runtime/README.md, packages/app-runtime/src/index.ts
Adds the owned HTML app block DTO helper and related types, and re-exports them.
cli-ui revision delegation and command IDs
apps/sqlrooms-cli-ui/src/createHtmlAppRevisionCommands.ts, apps/sqlrooms-cli-ui/src/createHtmlAppAgent.ts, apps/sqlrooms-cli-ui/src/__tests__/createHtmlAppRevisionCommands.test.ts
Switches cli-ui to the runtime factory and shared HTML app command IDs in code and tests.
cli-ui HTML app block tool uses runtime DTO helper
apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
Builds HTML app block documents through the runtime helper instead of manual construction.

Shared block-document AI command adapter

Layer / File(s) Summary
Block-document command adapter factory
packages/documents/src/createBlockDocumentCommandAiAdapter.ts, packages/documents/src/index.ts, packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts, packages/documents/README.md
Adds the shared block-document AI adapter, its exports, tests, and usage docs around the canonical append-blocks command.
cli-ui worksheet adapter delegates to shared adapter
apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts, apps/sqlrooms-cli-ui/src/__tests__/createWorksheetAiAdapter.test.ts
Replaces the worksheet-specific adapter with the shared block-document adapter and updates tests to shared constants.

Shared DuckDB database AI adapter

Layer / File(s) Summary
DuckDB database adapter factory
packages/mosaic/src/ai/createDatabaseAiAdapter.ts, packages/mosaic/src/ai.ts, packages/mosaic/src/index.ts, packages/mosaic/__tests__/createDatabaseAiAdapter.test.ts, packages/mosaic/README.md
Adds the DuckDB-backed database AI adapter, exports it, tests it, and documents its use.
cli-ui database adapter delegates to shared adapter
apps/sqlrooms-cli-ui/src/createDatabaseAiAdapter.ts
Returns the shared DuckDB adapter directly instead of implementing table access locally.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Host
  participant createHtmlAppRevisionCommands
  participant resolveHtmlAppCommandAppId
  participant commitHtmlAppRevision

  Host->>createHtmlAppRevisionCommands: execute HTML_APP_WRITE_REVISION_COMMAND_ID
  createHtmlAppRevisionCommands->>resolveHtmlAppCommandAppId: resolve appId
  resolveHtmlAppCommandAppId-->>createHtmlAppRevisionCommands: appId
  createHtmlAppRevisionCommands->>commitHtmlAppRevision: commit patch/metadata
  commitHtmlAppRevision-->>createHtmlAppRevisionCommands: revisionId, revisionName
  createHtmlAppRevisionCommands-->>Host: success payload
Loading
sequenceDiagram
  participant Adapter as createBlockDocumentCommandAiAdapter
  participant Store
  participant Commands as invokeCommand

  Adapter->>Store: ensureBlockDocument(artifactId)
  Adapter->>Commands: invokeCommand(BLOCK_DOCUMENT_APPEND_BLOCKS_COMMAND_ID, payload, {surface: 'ai', actor: BLOCK_DOCUMENT_AGENT_ACTOR})
  Commands-->>Adapter: result (blockId/blockIds)
  Adapter-->>Store: return derived blockId
Loading

Possibly related PRs

  • sqlrooms/sqlrooms#666: Introduces the block-document command constants and adapter work that this PR’s worksheet adapter changes build on.
  • sqlrooms/sqlrooms#748: Adds the HTML app revision command layer that this PR’s cli-ui wiring now delegates to.
  • sqlrooms/sqlrooms#765: Introduces the HTML app block-document helper that this PR’s cli-ui tool now uses.

Suggested reviewers: dmitriy-kostianetskiy, igorDykhta

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: extracting reusable package primitives from the CLI.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/extract-reusable-cli-packages

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (4)
packages/mosaic/src/index.ts (1)

447-447: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the new root re-export with a public-entrypoint test.

The current test only imports from ../src/ai, so it doesn't lock in the new packages/mosaic/src/index.ts wiring. Add one assertion through the package root entrypoint to keep this API covered.

🤖 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/mosaic/src/index.ts` at line 447, The new root re-export in the
package entrypoint is not covered by tests, so add a public-entrypoint assertion
for createDuckDbDatabaseAiAdapter through the main index export. Update the
existing public API test suite to import from the package root (the module that
contains the createDuckDbDatabaseAiAdapter re-export) and verify the symbol is
available there, alongside the current ../src/ai coverage.

Source: Coding guidelines

packages/app-runtime/src/HtmlAppRevisionCommands.ts (1)

36-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

.removeDefault() is a deprecated legacy alias in Zod 4.

Confirmed via Zod docs: in Zod 4, .removeDefault() on ZodDefault still works but is a "Legacy method (deprecated)"; .unwrap() is the current equivalent. Not a functional bug, but worth migrating to avoid relying on a deprecated API.

♻️ Proposed fix
 const HtmlAppRestoreRevisionCommandInput =
-  HtmlAppRevisionCommandInput.removeDefault().extend({
+  HtmlAppRevisionCommandInput.unwrap().extend({
     revisionId: z.string().describe('Target revision id for restore.'),
   });
🤖 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/app-runtime/src/HtmlAppRevisionCommands.ts` around lines 36 - 39,
The `HtmlAppRestoreRevisionCommandInput` schema is using the deprecated Zod 4
legacy alias `.removeDefault()`. Update the `HtmlAppRevisionCommandInput`
transformation to use `.unwrap()` instead, keeping the same schema shape while
removing reliance on the deprecated API.
packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts (1)

71-111: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the failure and validation branches.

Current tests only cover the happy path and a compatible-artifact predicate. Missing coverage for: addBlock/ensureBlockDocument throwing when the artifact type doesn't match isBlockDocumentArtifact, and addBlock throwing when result.success is false.

As per coding guidelines, "Add or update tests when changing behavior or public API, when practical."

🤖 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/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts`
around lines 71 - 111, Add tests for the missing failure paths in
createBlockDocumentCommandAiAdapter: verify addBlock and ensureBlockDocument
reject when the store artifact type does not satisfy isBlockDocumentArtifact,
and verify addBlock throws when invokeCommand returns a result with success set
to false. Extend the existing createMockStore-based setup in
createBlockDocumentCommandAiAdapter.test.ts to simulate these cases, and assert
the errors are surfaced from the adapter methods. Keep the happy-path
expectations intact while covering the validation and command-failure branches.

Source: Coding guidelines

apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts (1)

46-53: 🗄️ Data Integrity & Integration | 🔵 Trivial

Unsafe as cast hides a field mismatch between HtmlAppBlockDocumentBlock and BlockDocumentStatefulBlockBlock.

HtmlAppBlockDocumentBlock (from @sqlrooms/app-runtime) includes an intent field that BlockDocumentStatefulBlockBlock doesn't declare (see companion comment on html-app-block-document.ts). The cast type-checks only because extra properties don't break structural subtyping, but it silently papers over the fact that the two types aren't actually the same shape. If any downstream consumer re-validates against the zod schema, intent would be dropped without a compile-time signal here.

Consider a purpose-built return type (or narrowing/validating explicitly) instead of an as cast, so a future schema/field drift surfaces as a type error rather than a silent runtime behavior change.

🤖 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 `@apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts` around
lines 46 - 53, The unsafe cast in createAddHtmlAppBlockDocumentBlockTool is
masking a shape mismatch between HtmlAppBlockDocumentBlock and
BlockDocumentStatefulBlockBlock. Remove the blanket as assertion and make the
return type explicit by either returning the exact runtime block shape from
createHtmlAppRuntimeBlockDocumentBlock or introducing a dedicated
mapped/validated return type that includes the intent field if it is meant to
survive. Use the createHtmlAppRuntimeBlockDocumentBlock result and the block
return type in this module to ensure any future schema drift becomes a
compile-time error instead of being silently dropped.
🤖 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/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts`:
- Around line 78-140: The test suite for createHtmlAppRevisionCommands is
missing coverage for HTML_APP_RENAME_COMMAND_ID, so add a rename test alongside
the existing write/restore/undo/redo cases. Exercise the rename command through
getCommand(...).execute with a real title change and a mutating renameHtmlApp
mock, and assert the returned appId/title/revision fields. Make sure the test
covers the branching behavior in the rename path, including the
commit-vs-plain-rename flow and the title-unchanged detection in
HtmlAppRevisionCommands.

In `@packages/app-runtime/src/html-app-block-document.ts`:
- Around line 3-13: Add tsdoc to the exported type HtmlAppBlockDocumentBlock in
html-app-block-document.ts so it matches the documentation style used by
CreateHtmlAppBlockDocumentBlockOptions and the exported function. Add a brief
top-level doc comment describing what the type represents and, if helpful, note
any key fields such as type, blockType, ownership, and intent; keep it directly
above the HtmlAppBlockDocumentBlock declaration.

In `@packages/app-runtime/src/HtmlAppRevisionCommands.ts`:
- Around line 218-263: The Rename HTML app command currently claims to be
idempotent even though HtmlAppRevisionCommands.execute can create a new revision
via commitHtmlAppRevision whenever files or metadata trigger the revision path,
which can duplicate history on retries. Update the command metadata for
HTML_APP_RENAME_COMMAND_ID so it no longer advertises blanket idempotence, or
make it conditional if the command framework supports that, and keep the
behavior in execute consistent with the title-only path handled by
renameHtmlApp.
- Around line 244-284: The unchanged-result check in HtmlAppRevisionCommands
uses the mutable current app.title, which can be updated by
commitHtmlAppRevision or renameHtmlApp before the response is built. Update the
success payload logic in the rename command to compare against previousTitle
instead of app.title so the `html-app-title-unchanged` code is only returned
when the title truly did not change; keep the rest of the response data sourced
from nextApp as it is now.

---

Nitpick comments:
In `@apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts`:
- Around line 46-53: The unsafe cast in createAddHtmlAppBlockDocumentBlockTool
is masking a shape mismatch between HtmlAppBlockDocumentBlock and
BlockDocumentStatefulBlockBlock. Remove the blanket as assertion and make the
return type explicit by either returning the exact runtime block shape from
createHtmlAppRuntimeBlockDocumentBlock or introducing a dedicated
mapped/validated return type that includes the intent field if it is meant to
survive. Use the createHtmlAppRuntimeBlockDocumentBlock result and the block
return type in this module to ensure any future schema drift becomes a
compile-time error instead of being silently dropped.

In `@packages/app-runtime/src/HtmlAppRevisionCommands.ts`:
- Around line 36-39: The `HtmlAppRestoreRevisionCommandInput` schema is using
the deprecated Zod 4 legacy alias `.removeDefault()`. Update the
`HtmlAppRevisionCommandInput` transformation to use `.unwrap()` instead, keeping
the same schema shape while removing reliance on the deprecated API.

In `@packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts`:
- Around line 71-111: Add tests for the missing failure paths in
createBlockDocumentCommandAiAdapter: verify addBlock and ensureBlockDocument
reject when the store artifact type does not satisfy isBlockDocumentArtifact,
and verify addBlock throws when invokeCommand returns a result with success set
to false. Extend the existing createMockStore-based setup in
createBlockDocumentCommandAiAdapter.test.ts to simulate these cases, and assert
the errors are surfaced from the adapter methods. Keep the happy-path
expectations intact while covering the validation and command-failure branches.

In `@packages/mosaic/src/index.ts`:
- Line 447: The new root re-export in the package entrypoint is not covered by
tests, so add a public-entrypoint assertion for createDuckDbDatabaseAiAdapter
through the main index export. Update the existing public API test suite to
import from the package root (the module that contains the
createDuckDbDatabaseAiAdapter re-export) and verify the symbol is available
there, alongside the current ../src/ai coverage.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 67207c93-5313-4636-8bc6-5e9d1f1c1a71

📥 Commits

Reviewing files that changed from the base of the PR and between ae147e9 and 1a3d28b.

📒 Files selected for processing (21)
  • apps/sqlrooms-cli-ui/src/__tests__/createHtmlAppRevisionCommands.test.ts
  • apps/sqlrooms-cli-ui/src/__tests__/createWorksheetAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • apps/sqlrooms-cli-ui/src/createDatabaseAiAdapter.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppAgent.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppRevisionCommands.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
  • packages/app-runtime/README.md
  • packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts
  • packages/app-runtime/src/HtmlAppRevisionCommands.ts
  • packages/app-runtime/src/html-app-block-document.ts
  • packages/app-runtime/src/index.ts
  • packages/documents/README.md
  • packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts
  • packages/documents/src/createBlockDocumentCommandAiAdapter.ts
  • packages/documents/src/index.ts
  • packages/mosaic/README.md
  • packages/mosaic/__tests__/createDatabaseAiAdapter.test.ts
  • packages/mosaic/src/ai.ts
  • packages/mosaic/src/ai/createDatabaseAiAdapter.ts
  • packages/mosaic/src/index.ts

Comment thread packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts
Comment thread packages/app-runtime/src/html-app-block-document.ts
Comment thread packages/app-runtime/src/HtmlAppRevisionCommands.ts
Comment thread packages/app-runtime/src/HtmlAppRevisionCommands.ts
@ilyabo
ilyabo force-pushed the codex/extract-reusable-cli-packages branch from 1a3d28b to 7377770 Compare July 2, 2026 09:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts (1)

8-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing coverage for setCurrentBlockDocument.

The mock store already tracks setCurrentArtifact (Line 20, exposed at Line 67) but no test ever calls adapter.setCurrentBlockDocument or asserts it delegates to store.getState().artifacts.setCurrentArtifact. Since this is one of the four public methods introduced by the new adapter factory, it's worth adding a small test for parity with the other three methods.

✅ Suggested test addition
+  it('delegates setCurrentBlockDocument to the artifacts store', () => {
+    const {store} = createMockStore();
+    const adapter = createBlockDocumentCommandAiAdapter({store});
+    const spy = jest.spyOn(store.getState().artifacts, 'setCurrentArtifact');
+
+    adapter.setCurrentBlockDocument('doc-1');
+
+    expect(spy).toHaveBeenCalledWith('doc-1');
+  });

As per coding guidelines, "Add or update tests when changing behavior or public API, when practical."

Also applies to: 71-155

🤖 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/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts`
around lines 8 - 69, Add test coverage for the adapter’s setCurrentBlockDocument
public method by using the existing createMockStore helper and asserting it
calls store.getState().artifacts.setCurrentArtifact; the mock already exposes
setCurrentArtifact but no test exercises this delegation. Update the
createBlockDocumentCommandAiAdapter test suite to invoke
adapter.setCurrentBlockDocument and verify the underlying artifact state setter
is called with the expected block document/artifact input, alongside the other
adapter method parity checks.

Source: Coding guidelines

packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts (1)

127-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Rename tests still skip the files-provided branch.

shouldCommitRevision = files || (metadata && previousTitle !== trimmedTitle) in the implementation has a distinct path when files is supplied (forces a commit even without metadata/title change), but no test exercises it here.

As per coding guidelines, "Add or update tests when changing behavior or public API, when practical."

it('commits a revision when files are provided even without a title change', async () => {
  const {commands, state, renameHtmlApp, commitHtmlAppRevision} =
    createState();

  const result = await getCommand(
    commands,
    HTML_APP_RENAME_COMMAND_ID,
  ).execute(createCommandContext(state), {
    appId: 'app-1',
    title: 'App',
    files: {'/index.html': '<html><title>App v2</title></html>'},
  });

  expect(renameHtmlApp).not.toHaveBeenCalled();
  expect(commitHtmlAppRevision).toHaveBeenCalled();
  expect(result).toMatchObject({success: true, commandId: HTML_APP_RENAME_COMMAND_ID});
});
🤖 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/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts` around lines
127 - 215, The rename command tests still miss the branch where files force a
revision commit even when the title does not change. Add a test alongside the
existing HTML_APP_RENAME_COMMAND_ID cases that executes the command with files
provided and the same title, then assert renameHtmlApp is not called,
commitHtmlAppRevision is called, and the result is successful. Use createState
and getCommand to cover the files-driven path in the rename command
implementation.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts`:
- Around line 127-215: The rename command tests still miss the branch where
files force a revision commit even when the title does not change. Add a test
alongside the existing HTML_APP_RENAME_COMMAND_ID cases that executes the
command with files provided and the same title, then assert renameHtmlApp is not
called, commitHtmlAppRevision is called, and the result is successful. Use
createState and getCommand to cover the files-driven path in the rename command
implementation.

In `@packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts`:
- Around line 8-69: Add test coverage for the adapter’s setCurrentBlockDocument
public method by using the existing createMockStore helper and asserting it
calls store.getState().artifacts.setCurrentArtifact; the mock already exposes
setCurrentArtifact but no test exercises this delegation. Update the
createBlockDocumentCommandAiAdapter test suite to invoke
adapter.setCurrentBlockDocument and verify the underlying artifact state setter
is called with the expected block document/artifact input, alongside the other
adapter method parity checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21b73895-2402-4dfd-88f1-641b89fc0d0d

📥 Commits

Reviewing files that changed from the base of the PR and between 1a3d28b and 7377770.

📒 Files selected for processing (21)
  • apps/sqlrooms-cli-ui/src/__tests__/createHtmlAppRevisionCommands.test.ts
  • apps/sqlrooms-cli-ui/src/__tests__/createWorksheetAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • apps/sqlrooms-cli-ui/src/createDatabaseAiAdapter.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppAgent.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppRevisionCommands.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
  • packages/app-runtime/README.md
  • packages/app-runtime/__tests__/HtmlAppRevisionCommands.test.ts
  • packages/app-runtime/src/HtmlAppRevisionCommands.ts
  • packages/app-runtime/src/html-app-block-document.ts
  • packages/app-runtime/src/index.ts
  • packages/documents/README.md
  • packages/documents/__tests__/createBlockDocumentCommandAiAdapter.test.ts
  • packages/documents/src/createBlockDocumentCommandAiAdapter.ts
  • packages/documents/src/index.ts
  • packages/mosaic/README.md
  • packages/mosaic/__tests__/createDatabaseAiAdapter.test.ts
  • packages/mosaic/src/ai.ts
  • packages/mosaic/src/ai/createDatabaseAiAdapter.ts
  • packages/mosaic/src/index.ts
✅ Files skipped from review due to trivial changes (5)
  • packages/mosaic/src/ai/createDatabaseAiAdapter.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppAgent.ts
  • packages/app-runtime/README.md
  • packages/documents/README.md
  • packages/mosaic/README.md
🚧 Files skipped from review as they are similar to previous changes (14)
  • packages/mosaic/tests/createDatabaseAiAdapter.test.ts
  • packages/documents/src/index.ts
  • packages/mosaic/src/index.ts
  • packages/mosaic/src/ai.ts
  • apps/sqlrooms-cli-ui/src/tests/createWorksheetAiAdapter.test.ts
  • apps/sqlrooms-cli-ui/src/createDatabaseAiAdapter.ts
  • packages/documents/src/createBlockDocumentCommandAiAdapter.ts
  • packages/app-runtime/src/html-app-block-document.ts
  • apps/sqlrooms-cli-ui/src/createWorksheetAiAdapter.ts
  • apps/sqlrooms-cli-ui/src/ai/createAddHtmlAppBlockDocumentBlockTool.ts
  • apps/sqlrooms-cli-ui/src/tests/createHtmlAppRevisionCommands.test.ts
  • packages/app-runtime/src/index.ts
  • apps/sqlrooms-cli-ui/src/createHtmlAppRevisionCommands.ts
  • packages/app-runtime/src/HtmlAppRevisionCommands.ts

@ilyabo
ilyabo force-pushed the codex/extract-reusable-cli-packages branch from 7377770 to 43c6f86 Compare July 2, 2026 09:18
@ilyabo
ilyabo merged commit 3997caf into main Jul 2, 2026
6 checks passed
@ilyabo
ilyabo deleted the codex/extract-reusable-cli-packages branch July 2, 2026 09:33
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