Skip to content

feat(cli,playground,docs,generators): Export LikeC4 views to Draw.io#16

Merged
sraphaz merged 12 commits intomainfrom
feat/drawio-export-pr16
Feb 13, 2026
Merged

feat(cli,playground,docs,generators): Export LikeC4 views to Draw.io#16
sraphaz merged 12 commits intomainfrom
feat/drawio-export-pr16

Conversation

@sraphaz
Copy link
Copy Markdown
Owner

@sraphaz sraphaz commented Feb 13, 2026

feat(cli,playground,docs,generators): Export LikeC4 views to Draw.io

Summary

This PR adds export of LikeC4 views to Draw.io (.drawio) format from the CLI (likec4 export drawio) and the Playground (right-click on diagram → DrawIO → Export view / Export all). It does not include import; import will be proposed in a separate PR.

Context for maintainers: This work was first submitted in PR #2614, which received substantial review feedback focused on clean code, structure, and maintainability. We took that feedback seriously and ran a deliberate refactor pass (Uncle Bob / Clean Code) over the DrawIO-related code. This PR re-submits the same feature set with a cleaner, refactored codebase that we believe is easier to review and maintain. We’re grateful for the earlier review and have aimed to address those concerns in this iteration.


What’s in this PR

1. Generators (@likec4/generators)

  • generate-drawio.ts — Export single or multiple views to Draw.io XML; layout, styles, round-trip comments. Refactors: computeDiagramLayout split into smaller helpers; getViewDescriptionString extracted; buildNodeCellXml / buildEdgeCellXml and constants (SOLID/DRY/KISS); exported type DrawioViewModelLike.
  • parse-drawio.ts — Round-trip comment parsing and parse-to-LikeC4 for future import. Refactors: parseDrawioToLikeC4Multi split into mergeDiagramStatesIntoMaps, buildRootsFromFqnToCell, emitMultiDiagramModel (orchestrator ~50–60 lines); buildViewBlockLines / escapeLikec4Quotes; O(n²) deduplication replaced with parsedIds Set; UserObject fullTag uses innerXml so sibling <data> is preserved.
  • Tests: generate-drawio.spec.ts, parse-drawio.spec.ts; snapshots in __snapshots__/. Decompress error assertion accepts (base64 decode|inflate|URI decode) for Node/env behavior; snapshots updated for CI.

2. CLI (@likec4/likec4)

  • export/drawio/handler.tslikec4 export drawio with --outdir/-o, --all-in-one, --roundtrip, --uncompressed, --project, --use-dot. Uses DEFAULT_DRAWIO_ALL_FILENAME from @likec4/generators (DRY). Phase comments and thin handler pattern aligned with other export commands.
  • export/png/handler.ts — Type PngExportArgs, runExportPng(args, logger); PNG export supports --outdir/-o (docs updated).
  • No likec4 import drawio in this PR (no packages/likec4/src/cli/import/).

3. Playground

  • DrawIO context menu export only: Export view…, Export all… (DrawioContextMenuProvider, DrawioContextMenuDropdown, useDrawioContextMenuActions). Uses generateDrawio / generateDrawioMulti and parseDrawioRoundtripComments. No Import menu item or file input.
  • Monaco: only “Export to DrawIO” in editor context menu.

4. Documentation

  • drawio.mdx — Export only: mapping, options, multi-diagram, troubleshooting, re-export via comment blocks.
  • cli.mdx / docker.mdx — Export to DrawIO and PNG --outdir; no Import section.

5. E2E & tests

  • e2e/tests/drawio-playground.spec.ts — DrawIO menu (Export view / Export all). Run with playwright.playground.config.ts.
  • likec4: drawio-demo-export-import.spec.ts, drawio-tutorial-export-import.spec.ts — export tests; import/round-trip tests skipped in this PR.

What’s not in this PR

  • No likec4 import drawio command.
  • No Playground “Import from DrawIO” or Monaco Import action.
  • No docs for importing from Draw.io.
  • Import/round-trip tests remain skipped until the import PR.

Refactor summary (response to PR likec4#2614 feedback)

After the initial submission (PR likec4#2614), we applied a structured clean-code pass:

  • Generators: Smaller, single-responsibility functions; named types (DrawioViewModelLike); constants; phase comments; DRY (e.g. DEFAULT_DRAWIO_ALL_FILENAME, shared helpers).
  • CLI: Thin handlers; args types and runExport*(args, logger) pattern for drawio/PNG/JSON; consistent error handling and JSDoc.
  • Playground: Clear separation in useDrawioContextMenuActions (fillFromLayoutedModel, fillFromViewStates, etc.); constants for fonts/sizes.
  • E2E: Shared helpers (selectors, timeouts) in e2e/helpers/.

We believe this version is in better shape for review and long-term maintenance.


Correções após review (PR #11)

Incorporadas as sugestões do review anterior:

  • Changesets: Escopo export-only; removidas menções a import nos textos de release (drawio-implementation-plan, drawio-import-postpack).
  • DrawioContextMenuProvider: Valor do context api memoizado com useMemo(..., [actions.openMenu]) para evitar re-renders desnecessários.
  • LanguageClientSync: Uso de LayoutView.req em sendRequest (type-safe; removido cast manual).
  • E2E likec4-cli-export-drawio: Teste "empty workspace" agora verifica exitCode === 1 no erro rejeitado.
  • packages/config filenames.ts: basename remove barras finais (/ e \) e trata resultado vazio com fallback.
  • generate-drawio.ts: arcSize=12 (inteiro percentagem) em vez de 0.12 para cantos ligeiramente arredondados no Draw.io.
  • parse-drawio.ts: Lógica comum extraída para buildCommonDiagramStateFromCells; buildSingleDiagramState e buildDiagramState reutilizam (DRY).
  • drawio handler: useDot lido dos args e passado a runExportDrawio; graphviz binary vs wasm conforme flag --use-dot.
  • json handler: Campo useDot nos args e em runExportJson; guard quando projectsModels.length === 0 (warn + throw).

Alterações adicionais (nitpicks e robustez)

  • Changeset drawio-import-postpack: Texto reescrito para descrever apenas export e postpack; removidas menções a import/parser/CLI no bullet do Draw.io.
  • LanguageClientSync: requestLayoutView passa a usar LayoutView.req em sendRequest (type-safe; params e resposta inferidos; cast removido).
  • PNG handler: Bloco que inicia o servidor (viteDev) e o ciclo de export passou para dentro do mesmo try; finally garante server.close() mesmo quando resolveServerUrl ou o export lançam (evita leak do ViteDevServer).
  • Drawio handler: readWorkspaceSourceContent com proteção a ciclos de symlink: realpath + visitedDirs para não seguir o mesmo diretório duas vezes.
  • Comentários: DrawioContextMenuProvider (useCallbackRef evita churn do listener); generate-drawio.spec (navigateTo/ProcessedView); parse-drawio (collectRoundtrip quatro passagens); parse-drawio.spec (fallback getFirstDiagram).

Checklist

  • I have read the latest contribution guidelines.
  • My branch is synced with main (merge/rebase as appropriate).
  • Commit messages follow Conventional Commits (e.g. feat:, refactor:, test:).
  • Tests added/updated; import-related tests skipped in this branch. pnpm ci:test (Vitest) passes.
  • Documentation updated (drawio.mdx, cli.mdx, docker.mdx for export only).
  • Changesets can be added for user-facing packages if maintainers request.

Verification

  • pnpm build (filter !./apps/*), pnpm typecheck, pnpm test (or pnpm ci:test) — pass.
  • E2E drawio-playground: run with playground Playwright config when validating.

Notes for reviewers

  • Export behavior is unchanged from the original feature; changes are structural (refactors, types, constants, tests).
  • Generators: DrawioViewModelLike is the public type for view models passed to generateDrawio / generateDrawioMulti.
  • CLI: Drawio and PNG export handlers follow the same pattern as other export commands (args type + runExport* + thin handler).
  • We’re happy to address any further feedback and to add a changeset for the export feature if desired.

Fork / local CI changes (this session)

  • packages/log formatters: Use loggable (safe-stringify) instead of JSON.stringify in formatters to avoid stack overflow with circular references.
  • .github/workflows/checks.yaml: Linux jobs switched to runs-on: ubuntu-24.04-arm (reviewer davydkov’s suggestion).
  • .github/workflows/ci-pr.yaml: Kept only locally in the fork; added to .gitignore and removed from tracking (git rm --cached) so it is not pushed to upstream. The PR to origin does not include this file.
  • CodeRabbit: Pending comments (buildEdgeGeometryXml relative="1", parse-drawio ln = lines[i]?.trim()) already reflected in code; unresolved items reviewed and confirmed.

Reference

  • Initial submission and review context: PR #2614.
  • Original DrawIO bidirectional discussion: PR #2593. This PR is export-only; import will follow in a separate PR.

Summary by CodeRabbit

  • New Features

    • Workspace ID tracking in the VS Code extension.
    • Recognizes additional LikeC4 config filename variants (JS/CJS/MJS/TS/CTS/MTS).
  • Improvements

    • Enhanced hover tooltips with relationship info.
    • Richer logging formatters and configurable console formatting.
    • Better workspace-path parsing/fallback and small runtime fallbacks.
    • Clarified export/drawio command options and docs.
  • Bug Fixes

    • Fixes for title inheritance and MCP server initialization.
  • Documentation

    • Widespread JSDoc and changelog updates.
  • Chores

    • CI workflow added and tracked in repo.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Adds a tracked CI workflow, refactors several tests, adds JSDoc and minor runtime fallbacks, introduces a workspace ID hook, adjusts MCP workspace-path parsing, enhances logging APIs/formatters, and expands language-server model/location APIs and caching behavior.

Changes

Cohort / File(s) Summary
CI Workflow
/.github/workflows/ci-pr.yaml, .gitignore
Adds CI (PR & push) workflow and removes it from .gitignore so it is tracked; workflow reuses existing checks job, adds concurrency/cancel rules and conditional skip on commit message.
E2E & Tests
e2e/src/likec4-cli-export-drawio.spec.ts, packages/core/src/compute-view/deployment-view/stages/stage-exclude.spec.ts
Replaced try/catch exit assertions with result-based checks for the CLI test; added explanatory comments and left one spec skipped with clarifying notes.
CLI / Export
packages/likec4/src/cli/index.ts, packages/likec4/src/cli/export/...
Added JSDoc; explicitly sets process.exitCode on failures; extended drawio export helpers signatures/params (roundtrip, uncompressed, logger) and updated internal flows and docs.
Language Server — provider & hover docs
packages/language-server/src/documentation/documentation-provider.ts, packages/language-server/src/lsp/HoverProvider.ts, packages/language-server/src/model/builder/MergedSpecification.ts
Marked getDocumentation as override and removed nonexhaustive usage; added JSDoc on hover methods; removed an unused remeda import.
Language Server — models/cache/locator
packages/language-server/src/model/last-seen-artifacts.ts, packages/language-server/src/model/model-locator.ts
Changed internal styles map value type and updated rememberModel cache update logic; added exported ViewLocateResult and public methods locateElement/locateView with JSDoc and typed locals.
Language Server — changelog
packages/language-server/CHANGELOG.md
Added 1.49.0 patch notes enumerating enhancements, fixes, and dependency bumps.
VSCode extension — MCP & workspace
packages/vscode/src/node/mcp-server.ts, packages/vscode/src/node/useMcpRegistration.ts, packages/vscode/src/useWorkspaceId.ts, packages/vscode/src/utils.ts
Added readEnvVar fallback for LIKEC4_WORKSPACE parsing; added extensionContext guard and logging fix; introduced useWorkspaceId singleton (nanoid); added now() fallback.
Build / packaging
packages/vscode/tsdown.config.ts
copyPreview now throws an Error when preview dist is missing instead of silently logging and exiting.
Config filenames
packages/config/src/filenames.ts
Added JSON and non-JSON LikeC4 config filename lists, aggregate export, and type-guard helpers isLikeC4JsonConfig/isLikeC4NonJsonConfig/isLikeC4Config.
Generators / DrawIO utils
packages/generators/src/drawio/xml-utils.ts, packages/generators/src/drawio/{generate-drawio.ts,parse-drawio.ts}
Added and expanded JSDoc for XML helpers and drawio parsing/generation utilities; no behavioral changes beyond docs.
Logging library
packages/log/src/formatters.ts, packages/log/src/index.ts, packages/log/src/sink.ts, packages/log/src/utils.ts
Added error extraction/wrapping and message-append logic, new formatter builders (message-only, text, ANSI color), configureLogger implementation, merged console sink options, and JSDoc for utilities.
Misc docs & small helpers
packages/language-server/src/protocol.ts, packages/language-server/src/utils/projectId.ts, packages/likec4/src/cli/export/index.ts, packages/likec4/src/cli/export/png/takeScreenshot.ts, packages/vscode/src/utils.ts
Minor docstring wording adjustments and added JSDoc for helpers; small runtime fallback added for now().

Sequence Diagram(s)

(Skipped — changes are documentation, small API additions, tests, and tooling; no new multi-component control flow introduced that meets the diagram criteria.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped through branches, tiny and spry,

CI now tracked beneath the sky,
Tests rechecked by gentler light,
Logs that show errors bold and bright,
A workspace ID to hum at night.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the primary change: adding LikeC4 views export to Draw.io across CLI, playground, docs, and generators.
Description check ✅ Passed The description is comprehensive and covers the changes, refactoring rationale, and PR scope. However, the template checklist boxes are marked but the description itself is structured differently than the template format.
Docstring Coverage ✅ Passed Docstring coverage is 89.80% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/drawio-export-pr16

No actionable comments were generated in the recent review. 🎉


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

sraphaz and others added 2 commits February 13, 2026 13:21
…o empty workspace accept exit 1 or stderr; docs: clarify skip comments (drawio tgz CI, stage-exclude empty node)

Co-authored-by: Cursor <[email protected]>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/language-server/src/protocol.ts (1)

323-339: ⚠️ Potential issue | 🟡 Minor

Align projectId optionality with the docstring.

The comment says “(if any)” but the type is required. Either make it optional or update the comment to avoid a misleading API contract.

✏️ Suggested doc fix (if `projectId` is always present)
-    /**
-     * Project ID this document belongs to (if any)
-     */
+    /**
+     * Project ID this document belongs to
+     */
🤖 Fix all issues with AI agents
In `@packages/language-server/CHANGELOG.md`:
- Around line 17-29: The fenced code block showing the sample using view {
include some.element with { notes ''' ... } } lacks a language identifier and
triggers MD040; update that block by adding a language after the opening triple
backticks (e.g., "likec4") so the block becomes ```likec4 — locate the example
containing view { include some.element with { notes ''' ... } } in CHANGELOG.md
and add the language token to the opening fence.

In `@packages/language-server/src/documentation/documentation-provider.ts`:
- Around line 62-63: The call to nonexhaustive(node) is unreachable because the
earlier guard that filters to DeploymentNode, DeployedInstance, or Element and
the three case-specific returns (the handlers for those node types) always
return before that call; remove the nonexhaustive(node) invocation to eliminate
dead code (or if you intended an exhaustive-check assertion, move the
nonexhaustive(node) check into the branch where you handle all cases before
returning). Update the function that contains the
DeploymentNode/DeployedInstance/Element handlers to delete the final
nonexhaustive(node) call so control flow ends with the existing final return or
error handling.

In `@packages/language-server/src/model/last-seen-artifacts.ts`:
- Around line 12-14: The private field `#styles` is typed as c4.LikeC4Styles but
the file imports LikeC4Styles directly and the getter/getter return type uses
LikeC4Styles; change the type of the `#styles` map from c4.LikeC4Styles to
LikeC4Styles so the declaration for `#styles` = new Map<c4.ProjectId,
c4.LikeC4Styles>() becomes consistent with the imported LikeC4Styles and the
method return types (referencing `#styles` and LikeC4Styles in the class).

In `@packages/vscode/src/useWorkspaceId.ts`:
- Around line 7-21: The implementation of useWorkspaceId currently returns a new
id each session but the docstring says it is stored in workspace state; either
make the code persist the id or update the comment. To persist: restore the
commented logic in useWorkspaceId — read extensionContext.value?.workspaceState
into workspaceState, return a generated `likec4-${nanoid(4)}` only if
workspaceState.get('workspaceId') is missing, call
workspaceState.update('workspaceId', workspaceId) and then return the persisted
value; ensure nanoid is imported and handle the case where extensionContext or
workspaceState is undefined (fall back to generating a transient id).
Alternatively, change the docstring on useWorkspaceId to state it generates a
per-session id and is not stored.
🧹 Nitpick comments (8)
packages/vscode/src/node/mcp-server.ts (1)

29-42: Handle raw path values for LIKEC4_WORKSPACE.

If the env var is set to a plain path (not JSON), it’s silently ignored and the server falls back to cwd. Consider a fallback to treat the raw value as a single workspace path.

♻️ Suggested fallback
   try {
     const parsed = envSchema.parse(JSON.parse(value))
     const asArray = isString(parsed) ? [parsed] : parsed
     if (hasAtLeast(asArray, 1)) {
       return map(asArray, v => URI.parse(v).fsPath)
     }
   } catch {
-    // ignore
+    // Fallback: treat the raw value as a single workspace path
+    return [URI.parse(value).fsPath]
   }
packages/language-server/src/model/builder/MergedSpecification.ts (1)

6-6: Unused import: hasAtLeast

The hasAtLeast function is imported but not used anywhere in this file.

🧹 Remove unused import
 import {
-  hasAtLeast,
   isEmpty,
   isEmptyish,
   isNonNullish,
   only,
   unique,
 } from 'remeda'
packages/vscode/tsdown.config.ts (1)

109-124: Consider throwing an error instead of process.exit(1)

Using process.exit(1) immediately terminates the process without allowing tsdown's error handling to run. Throwing an error would provide better error reporting and allow the build system to handle the failure gracefully.

♻️ Proposed fix
 async function copyPreview() {
   const vscodePreview = resolve('../vscode-preview/dist/')
   if (!existsSync(vscodePreview)) {
-    console.error(`"${vscodePreview}" not found`)
-    process.exit(1)
+    throw new Error(`vscode-preview not found at "${vscodePreview}". Ensure `@likec4/vscode-preview` is built first.`)
   }
   console.info('Copy vscode preview from %s', vscodePreview)
packages/vscode/src/node/useMcpRegistration.ts (2)

28-34: Non-null assertion on extensionContext.value

Using extensionContext.value! assumes the extension context is always available when this composable runs. Since this is a singleton composable called during extension activation, it should be safe, but consider adding a guard or using optional chaining with a fallback for defensive coding.

🛡️ Defensive check
+  const ctx = extensionContext.value
+  if (!ctx) {
+    throw new Error('useMcpRegistration must be called after extension activation')
+  }
-  const serverModule = extensionContext.value!.asAbsolutePath(
+  const serverModule = ctx.asAbsolutePath(
     join(
       'dist',
       'node',
       'mcp-server.mjs',
     ),
   )

51-52: Tagged template literal may not format as expected

Line 52 uses tagged template syntax logger.debug`Resolving MCP server ${server.label}` while line 54 uses a regular function call. The tagged template might not interpolate the value as expected depending on the logger implementation. Consider using consistent function call syntax.

🧹 Use consistent logging syntax
       resolveMcpServerDefinition: async (server) => {
-        logger.debug`Resolving MCP server ${server.label}`
+        logger.debug(`Resolving MCP server ${server.label}`)
         if (server.label === 'likec4' && isMcpStdioServerDefinition(server)) {
packages/language-server/src/lsp/HoverProvider.ts (1)

183-200: Consider adding JSDoc for the protected hover methods.

The new protected methods (getElementHover, getElementModelHover, getDeploymentNodeHover, getDeployedInstanceHover) lack JSDoc documentation. As per coding guidelines, public/protected methods should be documented.

📝 Example JSDoc for one method
+  /**
+   * Builds hover content for a deployed instance node.
+   * Displays the instance ID, FQN reference, and optionally the element title.
+   */
   protected getDeployedInstanceHover(node: ast.DeployedInstance): MaybePromise<Hover | undefined> {
packages/language-server/src/model/last-seen-artifacts.ts (1)

45-55: Consider adding JSDoc to the public accessor methods.

The accessor methods (specification, styles, model) would benefit from brief JSDoc documentation describing what they return and when they might return undefined.

📝 Example JSDoc additions
+  /**
+   * Returns the last seen merged specification for the given project, if available.
+   */
   public specification(projectId: c4.ProjectId): MergedSpecification | undefined {
     return this.#specs.get(projectId)
   }

+  /**
+   * Returns the last seen styles for the given project, if available.
+   */
   public styles(projectId: c4.ProjectId): LikeC4Styles | undefined {
     return this.#styles.get(projectId)
   }

+  /**
+   * Returns the last seen computed model for the given project, if available.
+   */
   public model(projectId: c4.ProjectId): LikeC4Model.Computed | undefined {
     return this.#models.get(projectId)
   }
packages/language-server/src/model/model-locator.ts (1)

54-91: Consider explicit type annotations for intermediate variables.

The rest-args pattern works but makes type narrowing implicit. Adding explicit types to astNodeOrFqn and projectId would improve readability and make the type flow clearer for maintainers.

🔧 Suggested type annotations
   try {
-    let astNodeOrFqn
-    let projectId
+    let astNodeOrFqn: ast.Element | c4.Fqn
+    let projectId: c4.ProjectId
     if (args.length === 2) {
       astNodeOrFqn = args[0]
       projectId = args[1]
     } else {
       astNodeOrFqn = args[0]
       projectId = isString(astNodeOrFqn) ? this.projects.ensureProjectId() : projectIdFrom(astNodeOrFqn)
     }

…able nonexhaustive, consistent LikeC4Styles, useWorkspaceId doc)

Co-authored-by: Cursor <[email protected]>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/language-server/src/model/last-seen-artifacts.ts`:
- Around line 24-55: Add JSDoc comments to each public method
(rememberSpecification, rememberModel, specification, styles, model) describing
what the method does, its parameters and return value; for rememberSpecification
and rememberModel include `@param` with the parameter type (MergedSpecification, M
extends LikeC4Model.Computed) and note side effects (stores in internal maps),
and `@returns` with the returned type; for the accessor methods specification,
styles, and model include `@param` for projectId and `@returns` (possibly undefined)
types. Keep comments concise, consistent with project style, and placed
immediately above each method.
🧹 Nitpick comments (1)
packages/language-server/src/documentation/documentation-provider.ts (1)

8-16: Consider adding JSDoc documentation for the public class and constructor.

The class and constructor lack JSDoc comments. As per coding guidelines, public classes and methods should be documented.

📝 Suggested JSDoc documentation
+/**
+ * Provides documentation for LikeC4 AST nodes, extending JSDoc parsing
+ * with specialized formatting for deployment nodes, deployed instances, and elements.
+ */
 export class LikeC4DocumentationProvider extends JSDocDocumentationProvider {
   private parser: LikeC4ModelParser
   private locator: LikeC4ModelLocator

+  /**
+   * Creates a new documentation provider.
+   * `@param` services - The LikeC4 language services.
+   */
   constructor(services: LikeC4Services) {

sraphaz and others added 6 commits February 13, 2026 14:35
…own throw, useMcpRegistration guard+log, HoverProvider JSDoc, last-seen-artifacts JSDoc, model-locator types)

Co-authored-by: Cursor <[email protected]>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/config/src/filenames.ts (1)

47-48: ⚠️ Potential issue | 🟠 Major

Type guard narrows to incorrect type when full path is passed.

The type predicate claims filename is typeof configJsonFilenames[number] (e.g., ".likec4rc"), but the function checks basename(filename). If the caller passes "/some/path/.likec4rc", the guard returns true while TypeScript incorrectly narrows filename to a literal like ".likec4rc".

Consider returning boolean instead of a type predicate, or clarifying in documentation that the narrowed type only reflects the basename, not the full path.

-export function isLikeC4JsonConfig(filename: string): filename is typeof configJsonFilenames[number] {
+export function isLikeC4JsonConfig(filename: string): boolean {
   return (configJsonFilenames as readonly string[]).includes(basename(filename))
 }

The same issue applies to isLikeC4NonJsonConfig (line 54) and isLikeC4Config (line 61).

🤖 Fix all issues with AI agents
In `@packages/config/src/filenames.ts`:
- Line 28: The JSDoc for the constant that lists known LikeC4 non-JSON config
filenames in packages/config/src/filenames.ts is incomplete (it mentions "JS,
MJS, TS, MTS" but the array also contains CJS and CTS); update the JSDoc comment
above that constant (the known LikeC4 non-JSON config filenames definition) to
include "CJS" and "CTS" so the comment matches the actual extensions present in
the array.
🧹 Nitpick comments (2)
packages/likec4/src/cli/index.ts (2)

28-33: Add explicit types to applyLoggerConfig.
Align with the repo rule for explicit TypeScript types.

Suggested change
-function applyLoggerConfig(isDebug = isDevelopment) {
+function applyLoggerConfig(isDebug: boolean = isDevelopment): void {

As per coding guidelines, "Use TypeScript with explicit types; avoid using any".


49-53: Add an explicit return type to main.
This keeps the public signature clear and consistent with the TypeScript rule.

Suggested change
-async function main() {
+async function main(): Promise<void> {

As per coding guidelines, "Use TypeScript with explicit types; avoid using any".

'likec4.config.json',
] as const

/** Known LikeC4 non-JSON config filenames (JS, MJS, TS, MTS). */
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

JSDoc comment is incomplete.

The comment lists "(JS, MJS, TS, MTS)" but the array also includes CJS and CTS extensions.

📝 Suggested fix
-/** Known LikeC4 non-JSON config filenames (JS, MJS, TS, MTS). */
+/** Known LikeC4 non-JSON config filenames (JS, CJS, MJS, TS, CTS, MTS). */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/** Known LikeC4 non-JSON config filenames (JS, MJS, TS, MTS). */
/** Known LikeC4 non-JSON config filenames (JS, CJS, MJS, TS, CTS, MTS). */
🤖 Prompt for AI Agents
In `@packages/config/src/filenames.ts` at line 28, The JSDoc for the constant that
lists known LikeC4 non-JSON config filenames in packages/config/src/filenames.ts
is incomplete (it mentions "JS, MJS, TS, MTS" but the array also contains CJS
and CTS); update the JSDoc comment above that constant (the known LikeC4
non-JSON config filenames definition) to include "CJS" and "CTS" so the comment
matches the actual extensions present in the array.

@sraphaz sraphaz merged commit 15b652c into main Feb 13, 2026
37 of 46 checks passed
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