Skip to content

[codex] Add local startup script#38

Merged
gsxdsm merged 2 commits intomainfrom
codex/local-start-script
May 5, 2026
Merged

[codex] Add local startup script#38
gsxdsm merged 2 commits intomainfrom
codex/local-start-script

Conversation

@aronprins
Copy link
Copy Markdown
Collaborator

@aronprins aronprins commented May 5, 2026

Summary

Adds a repo-level pnpm local startup wrapper for local development.

The script keeps the default path simple and conservative:

  • binds to localhost by default
  • avoids reserved port 4040 by choosing 4050+ by default
  • starts dashboard/API only unless --engine is passed
  • disables auth only for localhost unless overridden
  • checks dependencies and initializes/registers the local Fusion project when needed

Also documents the new commands in the README development section.

Validation

Ran:

  • pnpm exec eslint scripts/start-local.mjs
  • pnpm local -- --dry-run --port 4040
  • pnpm local -- --port 4057
  • curl http://localhost:4057/
  • curl http://localhost:4057/api/health
  • curl http://localhost:4057/api/tasks
  • fetched the built dashboard JS asset and confirmed HTTP 200

pnpm verify:workspace was started after rebasing onto current main; lint passed and the suite progressed through multiple packages, but the full gate was intentionally stopped at the user's request to avoid waiting on the whole workspace run for this small dev-tooling change.

Notes

During local startup, existing upstream runtime warnings were observed but did not block serving the app/API:

  • mDNS service name already in use
  • dependency graph plugin reload copy warning from the current local build output

Summary by CodeRabbit

  • New Features
    • Added pnpm local command to start the local dashboard and API for development.
    • Added pnpm local -- --engine command to start the local dashboard with the AI engine enabled.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

Adds a new local startup CLI (scripts/start-local.mjs), documents two pnpm local commands, and wires a local script in package.json. The CLI parses flags, validates environment and Node version, ensures dependencies and project state, selects a port, and spawns the dev server.

Changes

Local Development Startup

Layer / File(s) Summary
Documentation
README.md
Added pnpm local and pnpm local -- --engine to Development commands.
Script Wiring
package.json
Added scripts.localnode scripts/start-local.mjs.
CLI Entry / Help
scripts/start-local.mjs
New CLI entrypoint with help banner and supported flags (--engine, --paused, --host, --port, --no-auth/--auth, --skip-install, --skip-register, --reserved-port, --dry-run).
Console Utilities
scripts/start-local.mjs
Small helpers for logging and failure (fail, info, ok, warn).
Arg Parsing
scripts/start-local.mjs
parseArgs(argv) parses and validates flag values, --help handling.
Process Runner
scripts/start-local.mjs
run(command, args, options?) wrapper around spawnSync for command execution and stdout capture.
Repo & Node Validation
scripts/start-local.mjs
ensureRepoRoot() verifies repo layout; ensureNodeVersion() enforces Node >= 22.5.0.
Dependency Management
scripts/start-local.mjs
ensureDependencies(opts) checks node_modules, runs pnpm install --frozen-lockfile if missing (respecting --skip-install).
Project Init
scripts/start-local.mjs
ensureProjectInitialized() creates local Fusion DB if missing via tsx ... init.
Registry Management
scripts/start-local.mjs
ensureProjectRegistered(opts) optionally registers/activates project using an inline tsx --eval script interacting with CentralCore (skippable via --skip-register).
Networking / Port Selection
scripts/start-local.mjs
pickPort(preferredPort, host, allow4040) probes ports with reserved-4040 enforcement.
Auth Decision & Summary
scripts/start-local.mjs
shouldDisableAuth(opts) decides --no-auth; printSummary(opts, port, dashboardArgs) logs mode, URL, host, auth, and the spawned command.
Orchestration & Spawn
scripts/start-local.mjs
main() sequences validation, init/registration, port selection, builds dashboard args (adds --dev when engine disabled, --paused, etc.), handles --dry-run, spawns scripts/dev-with-memory.mjs, and forwards child exit/signals.
Tests / Docs
README.md, package.json
Documentation and script wiring updated; no test files added.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as start-local.mjs
    participant Env as Repo/Node Validator
    participant Deps as Dependency Installer
    participant DB as Project Initializer
    participant Reg as Registry Manager
    participant Net as Port Probe
    participant Dev as dev-with-memory.mjs

    User->>CLI: run `pnpm local [--engine]`
    CLI->>CLI: parse flags
    CLI->>Env: verify repo layout & Node >= 22.5
    CLI->>Deps: ensure node_modules (or skip)
    CLI->>DB: init local project DB if missing
    CLI->>Reg: register/activate project (unless skipped)
    CLI->>Net: probe/select available port (handle 4040 rule)
    CLI->>CLI: build dashboard args (dev/paused/no-auth)
    CLI->>User: print startup summary
    CLI->>Dev: spawn `dev-with-memory.mjs` with args
    Dev->>User: dashboard/API serving locally
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

🐰 A tiny script hops out to play,
It checks the roots and finds a way,
Ports lined up like carrots bright,
Projects wake and take to flight,
Dashboard blooms beneath the night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[codex] Add local startup script' directly and accurately summarizes the main change—adding a startup script for local development with documentation updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/local-start-script

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

  • Adds scripts/start-local.mjs, a new one-command local development launcher that handles dependency checks, project init/registration, port probing, and spawning dev-with-memory.mjs with sensible localhost-safe defaults.
  • The --no-auth security warning (line 336) only triggers for host === \"0.0.0.0\" and misses any other non-localhost bind (e.g. --host 192.168.1.x --no-auth); a broader isExternalBind check is recommended.
  • --auth and --no-auth can be passed together silently; --no-auth wins without any diagnostic, which may confuse users.

Confidence Score: 5/5

Safe to merge; all findings are P2 suggestions with no runtime-breaking defects.

Only P2 issues found (narrow security warning scope, no validation for mutually exclusive flags). The core startup logic, port probing, signal propagation, and project registration are all correct.

scripts/start-local.mjs — auth warning condition and flag conflict validation

Important Files Changed

Filename Overview
scripts/start-local.mjs New 363-line startup orchestrator: parses CLI flags, checks deps, initialises/registers the local Fusion project via an inline tsx --eval helper, probes for a free port, then spawns dev-with-memory.mjs. Two P2 issues: the --no-auth security warning only fires for 0.0.0.0 (not specific external IPs), and conflicting --auth/--no-auth flags are silently accepted.
package.json Adds the "local" script entry pointing to scripts/start-local.mjs. No structural issues.
README.md Adds two lines documenting pnpm local and pnpm local -- --engine to the development commands section. Accurate and consistent with the new script.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([pnpm local]) --> B[parseArgs]
    B --> C{--help?}
    C -- yes --> D([print HELP & exit])
    C -- no --> E[ensureRepoRoot]
    E --> F[ensureNodeVersion]
    F --> G{node_modules exists?}
    G -- no & skipInstall --> H([fail])
    G -- no --> I[pnpm install --frozen-lockfile]
    G -- yes --> J[ensureProjectInitialized]
    I --> J
    J --> K{.fusion/fusion.db?}
    K -- no --> L[fn init --name name]
    K -- yes --> M[ensureProjectRegistered]
    L --> M
    M --> N[tsx --eval CentralCore helper]
    N --> O[pickPort]
    O --> P{port free?}
    P -- no, try next --> O
    P -- yes --> Q[build dashboardArgs]
    Q --> R{--no-auth on external host?}
    R -- warn --> S[printSummary]
    R -- ok --> S
    S --> T{--dry-run?}
    T -- yes --> U([exit])
    T -- no --> V[spawn node dev-with-memory.mjs]
    V --> W([child exits → re-propagate code/signal])
Loading

Reviews (2): Last reviewed commit: "fix(FN-000): address local startup revie..." | Re-trigger Greptile

Comment thread scripts/start-local.mjs Outdated
Comment thread package.json
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.

🧹 Nitpick comments (1)
scripts/start-local.mjs (1)

203-268: 💤 Low value

LGTM with one suggestion.

The inline script is well-structured with proper try/finally cleanup and safe string interpolation via JSON.stringify.

One note: Line 254 silently swallows errors from ensureMemoryFileWithBackend. Consider at least logging a warning if this fails, as it could hide setup issues that are confusing to debug later.

Optional: Log a warning on memory file setup failure
-        await ensureMemoryFileWithBackend(root).catch(() => false);
+        await ensureMemoryFileWithBackend(root).catch((err) => {
+          console.warn("Memory file setup skipped: " + (err instanceof Error ? err.message : String(err)));
+        });
🤖 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 `@scripts/start-local.mjs` around lines 203 - 268, In ensureProjectRegistered,
the helper currently swallows errors from ensureMemoryFileWithBackend with
.catch(() => false); change that to log a warning including the error (use
console.warn or processLogger) so failures to set up the memory file are
visible; update the inline helper string (the main() function inside the helper)
to catch the error from ensureMemoryFileWithBackend(root) and emit a descriptive
warning mentioning ensureMemoryFileWithBackend and the error before continuing.
🤖 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 `@scripts/start-local.mjs`:
- Around line 203-268: In ensureProjectRegistered, the helper currently swallows
errors from ensureMemoryFileWithBackend with .catch(() => false); change that to
log a warning including the error (use console.warn or processLogger) so
failures to set up the memory file are visible; update the inline helper string
(the main() function inside the helper) to catch the error from
ensureMemoryFileWithBackend(root) and emit a descriptive warning mentioning
ensureMemoryFileWithBackend and the error before continuing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9dff045d-ab10-466f-80a3-55444602e1d5

📥 Commits

Reviewing files that changed from the base of the PR and between 53a7877 and d53a151.

📒 Files selected for processing (2)
  • package.json
  • scripts/start-local.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

@gsxdsm gsxdsm merged commit 1f50be8 into main May 5, 2026
6 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.

2 participants