Skip to content

feat: mvp of cdb generator#62

Merged
Seele-Official merged 12 commits intoclice-io:mainfrom
Seele-Official:cdb
Mar 21, 2026
Merged

feat: mvp of cdb generator#62
Seele-Official merged 12 commits intoclice-io:mainfrom
Seele-Official:cdb

Conversation

@Seele-Official
Copy link
Copy Markdown
Collaborator

@Seele-Official Seele-Official commented Mar 21, 2026

Summary by CodeRabbit

  • New Features

    • Compiler identification API exposed; new script captures compile invocations and can emit compile_commands.json. CLI gains script path/args, mode, working directory and packed args.
  • Refactor

    • Service lifecycle hooks now receive finish events; IPC pipe name is runtime-derived; lifecycle and startup flow updated with clearer dispatching.
  • Tests

    • Added unit tests for compiler identification.
  • Chores

    • Removed obsolete scripts package manifest and its TypeScript config.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d0af59a-8045-44c6-b856-95ecac82b18e

📥 Commits

Reviewing files that changed from the base of the PR and between d6e7e37 and 9c28301.

📒 Files selected for processing (1)
  • api/package.json

📝 Walkthrough

Walkthrough

Adds compiler-identification APIs and implementation, a CDB script service and scripts export, changes service onFinish to receive an ExecutionEvent and binds lifecycle callbacks, refactors IPC/session to use runtime pipe naming and ServiceBase, rewrites main to option-driven dispatch, and updates tests/configs.

Changes

Cohort / File(s) Summary
C API & TypeScript types
api/catter-c/capi.d.ts
service_on_finish now receives an ExecutionEvent; added exported Compiler union and identify_compiler(compiler_name) declaration.
Compiler implementation & tests
src/catter/core/compiler.h, src/catter/core/compiler.cc, src/catter/core/capi/compiler.cc, tests/unit/catter/core/compiler.cc
New catter::Compiler enum and regex-based identify_compiler implementation; C API wrapper and unit tests added.
TypeScript exports & util
api/src/index.ts, api/src/util/cmd.ts
Exposed scripts at top-level, adjusted option export, re-exported identify_compiler/Compiler, and added CompilerKind const for consistency checks.
Scripts: CDB service
api/src/scripts/cdb.ts, api/src/scripts/index.ts
New CDB class implementing service.CatterService to record compiler invocations and emit a compile_commands.json; re-exported from scripts index.
Service JS bindings & registration
api/src/service.ts, api/test/service.ts
onFinish signature changed to accept an ExecutionEvent; registration now binds service methods to preserve this; tests updated.
JS/C++ bridge
src/catter/core/js.h, src/catter/core/js.cc, tests/unit/catter/core/js.cc
Native JS bridge forwards ExecutionEvent into JS on_finish(event); types and callsites updated.
IPC / Session / ServiceBase refactor
src/catter/core/ipc.h, src/catter/core/session.h, src/catter/core/session.cc, src/catter-proxy/ipc.cc
Replaced ServiceServiceBase (virtual dtor), added aliases, updated Session::run() to return int64 and removed lifecycle virtuals, switched to config::ipc::pipe_name().
Main / CLI / Options
src/catter/main.cc, src/common/opt/main/option.h
Main rewritten to option-driven dispatcher (deco CLI), integrates JS runtime hooks and dispatch flow; new CatterOption CLI struct added.
Config & pipe naming
src/common/config/ipc.h, src/common/config/catter.h, src/common/config/catter-main.h
Replaced compile-time PIPE_NAME with pipe_name() function; added config::core::LOG_PATH_REL; removed old catter-main header.
Packet I/O
src/common/util/packet_io.h
PacketChannel::write_packet success type changed to void in eventide::task<void, eventide::error>.
Build / scripts removal
xmake.lua, scripts/package.json (deleted), scripts/tsconfig.json (deleted)
Updated eventide package version; removed scripts package manifest and its tsconfig.
Tests & small fixes
tests/integration/test/catter-proxy.cc, tests/unit/.../payload/*
Adjusted tests for Session::run return and onFinish(event) signature; fixed optional access assertions; removed local SessionImpl.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI/Main
    participant Dispatcher as Dispatcher
    participant JS as JS Runtime
    participant Session as Session
    participant Service as ServiceImpl
    participant IPC as IPC Layer

    CLI->>Dispatcher: parse options (script, mode, args)
    Dispatcher->>CLI: extracted config
    CLI->>JS: load script (builtin or file) and call on_start
    CLI->>Session: run(config)
    Session->>Service: create service instance
    Service->>IPC: connect/listen (pipe_name())
    loop commands
        IPC->>Service: receive command (cwd, exe, argv, id)
        Service->>JS: on_command(payload)
        JS-->>Service: action (inject/skip/modify)
        Service->>IPC: write response/action
    end
    Session->>Service: finish
    Service->>JS: on_finish(ExecutionEvent)
    JS-->>CLI: script cleanup complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • star-hengxing

Poem

🐰 I sniffed the compiler names in rows,
regex whiskers twitching as it goes.
JS scripts hop, collect, and write,
pipes hum softly through the night.
A tiny rabbit cheers: "Build bright!" ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: mvp of cdb generator' accurately describes the main feature being introduced: a CDB (compilation database) generator MVP. The title directly reflects the new CDB class and script functionality added across multiple files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@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: 6

Caution

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

⚠️ Outside diff range comments (1)
tests/integration/test/catter-proxy.cc (1)

108-108: ⚠️ Potential issue | 🟡 Minor

Unreachable code.

Line 108 return 0; is unreachable—all execution paths through the try-catch block already return at lines 100, 103, or 106.

🧹 Proposed fix
     } catch(...) {
         std::println("Unknown fatal error.");
         return 1;
     }
-    return 0;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test/catter-proxy.cc` at line 108, The trailing "return 0;"
after the try-catch in the function (the extra return at line 108) is
unreachable because all branches in the try/catch already return (lines 100,
103, 106); remove the redundant "return 0;" or consolidate returns so there is a
single exit point in the function (e.g., have the try/catch set a result
variable and return it once after the block) — locate the function (main or the
test entry in catter-proxy.cc) and eliminate or refactor the unreachable return
to resolve the dead code.
🧹 Nitpick comments (4)
src/catter/core/ipc.h (1)

23-25: Initialize m_mode explicitly to avoid indeterminate state.

m_mode is currently default-initialized as a fundamental enum field, which is not deterministic.

Proposed change
 private:
-    ServiceMode m_mode;
+    ServiceMode m_mode{};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/catter/core/ipc.h` around lines 23 - 25, m_mode (the enum member in the
class) is currently left uninitialized; initialize it explicitly to a sensible
default to avoid indeterminate state by either providing an in-class initializer
(e.g., "ServiceMode m_mode = <DEFAULT>") or setting it in the class constructor
initializer list for the class that declares m_mode; reference the symbol m_mode
and whichever constructor of that class (or the ServiceMode enum) to locate
where to assign the chosen default value.
tests/unit/catter/core/compiler.cc (1)

1-1: Unused include.

The <optional> header is included but not used in this test file.

🧹 Proposed fix
-#include <optional>
-
 `#include` <eventide/zest/macro.h>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/catter/core/compiler.cc` at line 1, Remove the unused header
include <optional> from the test file: the line including <optional> should be
deleted since no symbols from std::optional are referenced in this test (search
for the include in compiler.cc and remove it).
api/src/scripts/cdb.ts (1)

6-6: Unused import: Compiler type is imported but not used.

The Compiler type is imported from catter-c but the code only uses the return value of identify_compiler directly. Consider removing if unused.

♻️ Proposed fix
-import { identify_compiler, Compiler } from "catter-c";
+import { identify_compiler } from "catter-c";

Or if the type annotation on commandArray is intended to use it:

commandArray: Array<[Compiler, service.CommandData]> = [];

Then you need to import the type. Verify that the Compiler import is correctly used for the type annotation on line 18.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/src/scripts/cdb.ts` at line 6, The import currently brings in both
identify_compiler and Compiler from "catter-c" but Compiler is unused; either
remove Compiler from the import list or make it a type-only import and use it in
the commandArray annotation. Locate the import line with identify_compiler and
Compiler and either delete Compiler from that import or change to `import type {
Compiler }` and update commandArray to use Array<[Compiler,
service.CommandData]>. Ensure identify_compiler remains imported and used as-is.
src/catter/core/compiler.cc (1)

61-65: Minor inefficiency: std::string allocation in loop.

The std::string(compiler_name) conversion happens on every iteration. Consider moving it outside the loop to avoid repeated allocations.

♻️ Proposed optimization
+    std::string compiler_str(compiler_name);
     for(auto& compiler_pattern: DEFAULT_PATTERNS) {
-        if(std::regex_match(std::string(compiler_name), compiler_pattern.pattern)) {
+        if(std::regex_match(compiler_str, compiler_pattern.pattern)) {
             return compiler_pattern.type;
         }
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/catter/core/compiler.cc` around lines 61 - 65, The loop repeatedly
constructs std::string(compiler_name) causing unnecessary allocations; before
iterating DEFAULT_PATTERNS create a single std::string (e.g. compilerStr =
std::string(compiler_name)) and use that in the std::regex_match call (compare
compilerStr against compiler_pattern.pattern) so the conversion happens once;
update references to compiler_name in the loop to use compilerStr.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/src/scripts/cdb.ts`:
- Around line 48-65: The stored commands loop in onFinish iterates
this.commandArray but only handles "clang", causing errors when onCommand
previously saved gcc/flang/ifort entries; update onCommand to only push entries
for compiler === "clang" (so this.commandArray contains only clang rows) or
alternatively extend the switch in onFinish to handle other compilers (e.g., add
cases for "gcc"/"flang"/"ifort" with appropriate parsing) — locate and update
the onCommand logic that populates this.commandArray (and/or the switch in
onFinish that references compiler) and ensure use of option.ClangID.ID_INPUT and
parse(...) remains consistent for clang entries.
- Around line 49-61: The const parsed declared inside the switch's case "clang":
can leak into other cases; wrap the case body in its own block (e.g., case
"clang": { ... break; }) so parsed (and any other block-scoped locals) are
scoped to that case. Update the switch handling in the function that calls
this.parse(compiler, command.argv.slice(1)) and uses option.ClangID.ID_INPUT,
command, and cdb to ensure parsed is declared inside a new { } block immediately
after case "clang": and before the break.

In `@src/catter/main.cc`:
- Around line 5-8: Remove the duplicate include of the <print> header in
src/catter/main.cc so only one `#include` <print> remains; inspect the include
block containing `#include` <print>, `#include` <cassert>, and `#include` <format> and
delete the redundant `#include` <print> line so the file only includes each header
once.
- Around line 179-183: Session::run returns an int64_t (the spawn task result)
but the current code discards it; capture the return value from
session.run(config.build_system_command, ServiceImpl::Factory{}) into a variable
(e.g., int64_t exit_code) and then use it to determine process outcome before
calling js::on_finish() — for example propagate it to the caller, convert to an
appropriate exit status, log/report failures, or pass it into js::on_finish() as
needed so the build system command exit code is not lost.

In `@src/common/config/ipc.h`:
- Around line 10-11: The static initialization of path in pipe_name() calls
util::get_catter_data_path() which can throw when HOME is unset; change
pipe_name() to avoid throwing at static init by computing the path at call time
with a non-throwing strategy: check getenv("HOME") (or catch exceptions from
util::get_catter_data_path()), and if unavailable fall back to a safe
non-throwing location such as /tmp or return an empty/optional string and
propagate an actionable error to caller; update callers that use pipe_name()
(IPC setup/cleanup paths) to handle the fallback/empty result explicitly instead
of relying on a thrown exception. Ensure references to pipe_name(),
util::get_catter_data_path(), and the static path variable are replaced so no
throw occurs during static init.

In `@src/common/opt/main/option.h`:
- Around line 2-5: The header is not self-sufficient: option.h declares
std::string fields but doesn't include <string>, so add `#include` <string> to the
top of option.h (alongside the existing includes like <vector>,
<eventide/deco/decl.h>, <eventide/deco/macro.h>) so declarations that use
std::string (the string fields in the Option-related declarations) compile
without relying on transitive includes.

---

Outside diff comments:
In `@tests/integration/test/catter-proxy.cc`:
- Line 108: The trailing "return 0;" after the try-catch in the function (the
extra return at line 108) is unreachable because all branches in the try/catch
already return (lines 100, 103, 106); remove the redundant "return 0;" or
consolidate returns so there is a single exit point in the function (e.g., have
the try/catch set a result variable and return it once after the block) — locate
the function (main or the test entry in catter-proxy.cc) and eliminate or
refactor the unreachable return to resolve the dead code.

---

Nitpick comments:
In `@api/src/scripts/cdb.ts`:
- Line 6: The import currently brings in both identify_compiler and Compiler
from "catter-c" but Compiler is unused; either remove Compiler from the import
list or make it a type-only import and use it in the commandArray annotation.
Locate the import line with identify_compiler and Compiler and either delete
Compiler from that import or change to `import type { Compiler }` and update
commandArray to use Array<[Compiler, service.CommandData]>. Ensure
identify_compiler remains imported and used as-is.

In `@src/catter/core/compiler.cc`:
- Around line 61-65: The loop repeatedly constructs std::string(compiler_name)
causing unnecessary allocations; before iterating DEFAULT_PATTERNS create a
single std::string (e.g. compilerStr = std::string(compiler_name)) and use that
in the std::regex_match call (compare compilerStr against
compiler_pattern.pattern) so the conversion happens once; update references to
compiler_name in the loop to use compilerStr.

In `@src/catter/core/ipc.h`:
- Around line 23-25: m_mode (the enum member in the class) is currently left
uninitialized; initialize it explicitly to a sensible default to avoid
indeterminate state by either providing an in-class initializer (e.g.,
"ServiceMode m_mode = <DEFAULT>") or setting it in the class constructor
initializer list for the class that declares m_mode; reference the symbol m_mode
and whichever constructor of that class (or the ServiceMode enum) to locate
where to assign the chosen default value.

In `@tests/unit/catter/core/compiler.cc`:
- Line 1: Remove the unused header include <optional> from the test file: the
line including <optional> should be deleted since no symbols from std::optional
are referenced in this test (search for the include in compiler.cc and remove
it).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2fdc741a-18c7-4f7e-a514-3f92d599d115

📥 Commits

Reviewing files that changed from the base of the PR and between 779582d and 8b3d3ff.

📒 Files selected for processing (26)
  • api/catter-c/capi.d.ts
  • api/src/index.ts
  • api/src/scripts/cdb.ts
  • api/src/scripts/index.ts
  • api/src/service.ts
  • api/src/util/cmd.ts
  • scripts/package.json
  • scripts/tsconfig.json
  • src/catter-proxy/ipc.cc
  • src/catter/core/capi/compiler.cc
  • src/catter/core/compiler.cc
  • src/catter/core/compiler.h
  • src/catter/core/ipc.h
  • src/catter/core/session.cc
  • src/catter/core/session.h
  • src/catter/main.cc
  • src/common/config/catter-main.h
  • src/common/config/catter.h
  • src/common/config/ipc.h
  • src/common/opt/main/option.h
  • src/common/util/packet_io.h
  • tests/integration/test/catter-proxy.cc
  • tests/unit/catter-hook/unix/payload/command.cc
  • tests/unit/catter-hook/unix/payload/executor.cc
  • tests/unit/catter/core/compiler.cc
  • xmake.lua
💤 Files with no reviewable changes (3)
  • src/common/config/catter-main.h
  • scripts/package.json
  • scripts/tsconfig.json

Comment on lines +48 to +65
for (const [compiler, command] of this.commandArray) {
switch (compiler) {
case "clang":
const parsed = this.parse(compiler, command.argv.slice(1));
for (const item of parsed) {
if (item.id === option.ClangID.ID_INPUT) {
cdb.push({
directory: command.cwd,
file: item.key,
command: command.argv.join(" "),
});
}
}
break;
default:
throw new Error(`Unsupported compiler: ${compiler}`);
}
}
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.

⚠️ Potential issue | 🟠 Major

Logic mismatch: onCommand accepts all compilers, but onFinish only handles "clang".

onCommand stores commands for any non-"unknown" compiler (gcc, flang, ifort, etc.), but onFinish throws an error for anything other than "clang". This will cause runtime failures if any gcc/flang/ifort commands are captured.

Either filter to only "clang" in onCommand, or extend onFinish to handle other compilers.

🔧 Option 1: Filter in onCommand (simpler for MVP)
   onCommand(
     id: number,
     data: service.CommandData | service.CatterErr,
   ): service.Action {
     if ("msg" in data) {
       io.println(`CDB received error: ${data.msg}`);
     } else {
       const compiler = identify_compiler(data.exe);
-      if (compiler !== "unknown") {
+      if (compiler === "clang") {
         this.commandArray.push([compiler, data]);
       }
     }
🧰 Tools
🪛 Biome (2.4.7)

[error] 51-51: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

(lint/correctness/noSwitchDeclarations)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/src/scripts/cdb.ts` around lines 48 - 65, The stored commands loop in
onFinish iterates this.commandArray but only handles "clang", causing errors
when onCommand previously saved gcc/flang/ifort entries; update onCommand to
only push entries for compiler === "clang" (so this.commandArray contains only
clang rows) or alternatively extend the switch in onFinish to handle other
compilers (e.g., add cases for "gcc"/"flang"/"ifort" with appropriate parsing) —
locate and update the onCommand logic that populates this.commandArray (and/or
the switch in onFinish that references compiler) and ensure use of
option.ClangID.ID_INPUT and parse(...) remains consistent for clang entries.

Copy link
Copy Markdown
Contributor

@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

♻️ Duplicate comments (2)
api/src/scripts/cdb.ts (2)

56-68: ⚠️ Potential issue | 🟡 Minor

Wrap the case "clang" body in braces.

Line 58 declares const parsed directly under a switch case. Block it to avoid cross-case scope leakage.

🔧 Scoped switch-case declaration
       switch (compiler) {
-        case "clang":
+        case "clang": {
           const parsed = this.parse(compiler, command.argv.slice(1));
           for (const item of parsed) {
             if (item.id === option.ClangID.ID_INPUT) {
               cdb.push({
                 directory: command.cwd,
                 file: item.key,
                 command: command.argv.join(" "),
               });
             }
           }
           break;
+        }
         default:
           throw new Error(`Unsupported compiler: ${compiler}`);
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/src/scripts/cdb.ts` around lines 56 - 68, The switch case for "clang"
declares a block-scoped const (parsed) without braces which can leak scope; wrap
the entire case "clang" body in braces so that const parsed =
this.parse(compiler, command.argv.slice(1)); and the for loop that checks
item.id === option.ClangID.ID_INPUT and pushes into cdb (using command.cwd,
item.key, command.argv.join(" ")) are all inside a local block, preserving
correct scoping for parsed and any other block-scoped variables.

89-92: ⚠️ Potential issue | 🟠 Major

Prevent non-clang commands from crashing onFinish.

Line 90 stores all known compilers, but Line 70 throws for anything except "clang". This makes mixed-toolchain builds fail during CDB generation.

🔧 MVP-safe fix (filter at ingestion)
-      if (compiler !== "unknown") {
+      if (compiler === "clang") {
         this.commandArray.push([compiler, data]);
       }

Also applies to: 55-71

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/src/scripts/cdb.ts` around lines 89 - 92, The code is crashing later in
onFinish because non-clang toolchain entries are being processed or cause a
throw; to fix, filter out non-clang commands at ingestion: in the path that
calls identify_compiler(data.exe) and pushes into this.commandArray, only push
when identify_compiler(...) === "clang" (or normalize identify_compiler to
return "clang"/"unknown" without throwing), and ensure onFinish and related
handlers (identify_compiler, this.commandArray processing) expect only clang
entries so they no longer throw on mixed-toolchain builds; update
identify_compiler and the ingestion site to skip/log non-clang entries instead
of allowing them through to onFinish.
🧹 Nitpick comments (1)
api/src/scripts/cdb.ts (1)

8-14: Avoid rebuilding shell command with argv.join(" ").

Line 64 can produce ambiguous/invalid commands when args contain spaces or quotes. Prefer serializing arguments directly in the CDB entry.

🔧 Prefer `arguments` over joined command text
 type CDBItem = {
   directory: string;
   file: string;
-  command: string;
-  arguments?: string[];
+  arguments: string[];
+  command?: string;
   output?: string;
 };
@@
               cdb.push({
                 directory: command.cwd,
                 file: item.key,
-                command: command.argv.join(" "),
+                arguments: command.argv,
               });

Also applies to: 61-65

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/src/scripts/cdb.ts` around lines 8 - 14, The CDB entry currently rebuilds
the shell command with argv.join(" "), which breaks when args contain spaces or
quotes; instead populate the CDBItem.arguments array with the original argv
array (do not create a single joined command string) and update any code that
serializes or replays the CDB entries to use CDBItem.arguments as an args array
(or pass it directly to spawn/execFile) rather than parsing a reconstructed
command string; adjust places referencing CDBItem.command/arguments to ensure
command stays the executable and arguments remains string[] so no manual
join/escape is needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/src/scripts/cdb.ts`:
- Line 74: The TextFileStream currently only supports "ascii" and using
io.TextFileStream.with(this.save_path, "ascii", ...) corrupts non-ASCII
paths/commands; add UTF-8 support to the TextFileStream implementation (expand
the encoding handling in the TextFileStream class to accept "utf8"/"utf-8" and
write using Buffer.from(string, "utf8") or equivalent write method) and then
change the call site to io.TextFileStream.with(this.save_path, "utf8", (stream)
=> {...}) so compile_commands.json is written with UTF-8 encoding; update any
encoding switch/validation logic and tests to include "utf8"/"utf-8" variants
and ensure stream.close/flush still behaves correctly.

In `@src/catter/main.cc`:
- Around line 166-180: js::on_start(...) returns an updated config that must be
used but is currently discarded; capture its return (e.g., auto effective =
js::on_start({...});) and then use fields from that returned config
(effective.buildSystemCommand, effective.runtime, effective.options.log,
effective.isScriptSupported, etc.) when constructing and invoking Session and
session.run instead of the original config so changes such as rewritten
buildSystemCommand and isScriptSupported are honored.
- Around line 52-56: The switch currently treats js::ActionType::drop the same
as js::ActionType::skip by returning data::action{.type = data::action::INJECT,
.cmd = cmd}; change the js::ActionType::drop branch to return the non-executing
IPC action instead (e.g., return data::action{.type = data::action::NONE} or the
project’s equivalent no-op/ DROP action) so that a drop request does not execute
the original cmd; update only the case for js::ActionType::drop in the switch
handling act.type.
- Around line 42-50: The CommandData passed to js::on_command is missing the
required .runtime field; populate CommandData.runtime (e.g., .runtime =
cmd.runtime or construct a Runtime object with the correct
type/supportActions/supportEvents) before calling js::on_command so scripts see
the correct capability set; update the aggregate that builds js::CommandData
(the code setting .cwd/.exe/.argv/.env/.parent where act is created) to include
.runtime filled from the incoming cmd or computed runtime info.

---

Duplicate comments:
In `@api/src/scripts/cdb.ts`:
- Around line 56-68: The switch case for "clang" declares a block-scoped const
(parsed) without braces which can leak scope; wrap the entire case "clang" body
in braces so that const parsed = this.parse(compiler, command.argv.slice(1));
and the for loop that checks item.id === option.ClangID.ID_INPUT and pushes into
cdb (using command.cwd, item.key, command.argv.join(" ")) are all inside a local
block, preserving correct scoping for parsed and any other block-scoped
variables.
- Around line 89-92: The code is crashing later in onFinish because non-clang
toolchain entries are being processed or cause a throw; to fix, filter out
non-clang commands at ingestion: in the path that calls
identify_compiler(data.exe) and pushes into this.commandArray, only push when
identify_compiler(...) === "clang" (or normalize identify_compiler to return
"clang"/"unknown" without throwing), and ensure onFinish and related handlers
(identify_compiler, this.commandArray processing) expect only clang entries so
they no longer throw on mixed-toolchain builds; update identify_compiler and the
ingestion site to skip/log non-clang entries instead of allowing them through to
onFinish.

---

Nitpick comments:
In `@api/src/scripts/cdb.ts`:
- Around line 8-14: The CDB entry currently rebuilds the shell command with
argv.join(" "), which breaks when args contain spaces or quotes; instead
populate the CDBItem.arguments array with the original argv array (do not create
a single joined command string) and update any code that serializes or replays
the CDB entries to use CDBItem.arguments as an args array (or pass it directly
to spawn/execFile) rather than parsing a reconstructed command string; adjust
places referencing CDBItem.command/arguments to ensure command stays the
executable and arguments remains string[] so no manual join/escape is needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 85cdfbca-5497-4146-96e2-88f0f8a27943

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3d3ff and fea1106.

📒 Files selected for processing (9)
  • api/catter-c/capi.d.ts
  • api/src/scripts/cdb.ts
  • api/src/service.ts
  • api/test/service.ts
  • src/catter/core/js.cc
  • src/catter/core/js.h
  • src/catter/main.cc
  • src/common/opt/main/option.h
  • tests/unit/catter/core/js.cc

Copy link
Copy Markdown
Contributor

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/src/scripts/cdb.ts`:
- Around line 62-66: The cdb entry currently builds a single command string by
joining command.argv which corrupts args containing spaces; update the cdb.push
call (the object created where you currently set command: command.argv.join("
")) to instead set an arguments field with the raw array (arguments:
command.argv) per the Compilation Database spec (you can drop or keep command as
an optional convenience but ensure arguments is present and populated from
command.argv to preserve quoting/spaces).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 677566f2-184b-4fa4-9160-135d7f3d5012

📥 Commits

Reviewing files that changed from the base of the PR and between fea1106 and d6e7e37.

📒 Files selected for processing (1)
  • api/src/scripts/cdb.ts

@Seele-Official Seele-Official merged commit e5fc3ba into clice-io:main Mar 21, 2026
5 checks passed
@Seele-Official Seele-Official deleted the cdb branch March 24, 2026 08:09
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