Skip to content

CaptainStarbuck/janebot

Repository files navigation

JaneBot

A minimal TypeScript ESM command line helper for Codex that exposes a single command named janebot. The executable entry point is src/index.ts, and focused supporting modules under src/ handle CLI parsing, runtime configuration, generated project scaffolding, Codex arguments, process output, transcript logging, and workspace path validation.

Prerequisites

  • Node.js 22+
  • npm 10+ (ships with Node 22)

Configuration

Copy .env_template to .env to override runtime preferences.

BASE_FOLDER=/tmp
CODEX_COMMAND=codex
JANEBOT_LOG_DIR=/tmp
NODE_PACKAGE_MANAGER=npm
OS_PACKAGE_MANAGER=apt
  • BASE_FOLDER selects the parent folder where generated projects are created. Relative values are resolved from the JaneBot project root and must remain within /opt/codex or /tmp.
  • CODEX_COMMAND selects the Codex CLI binary that janebot executes.
  • JANEBOT_LOG_DIR selects the folder used for saved Codex transcripts.
  • NODE_PACKAGE_MANAGER selects the package manager name written into generated project setup guidance. Allowed values are npm and pnpm.
  • OS_PACKAGE_MANAGER selects the operating system package manager name written into generated setup guidance. Allowed values are apt and none.

Development

npm install
npm run build  # Emits ESM to dist/

Source modules follow the same modularity policy that JaneBot gives generated projects: src/index.ts remains the direct CLI entry point and flow coordinator, focused supporting modules live under src/, modules stay under 120 lines, and functions stay at 60 lines or less.

Usage

After npm run build, link the CLI globally for the current Node installation:

npm link
janebot "do something"
janebot --output json "do something"
janebot note-sync "Create a JavaScript CLI tool that mirrors markdown notes between folders"

npm link depends on dist/index.js existing because the package exposes ./dist/index.js as the janebot executable. Remove the link later with npm unlink --global janebot.

The request text must be wrapped in quotes so the shell passes it to janebot as a single argument. Use janebot {id} "{request}" when you want a stable generated folder and command name. Use janebot --output readable "{request}" or janebot --output json "{request}" to choose whether JaneBot prints readable live Codex output or raw Codex JSONL events.

Use janebot --version or janebot -v to print the package version locally without invoking Codex.

Use janebot --help, janebot help, or janebot -? to print a short summary of the supported CLI patterns and options locally without invoking Codex.

When a local .env file is present, janebot loads it from the project root before invoking Codex.

JaneBot now streams Codex output live to the terminal by default while still saving the full transcript to JANEBOT_LOG_DIR.

--output json passes --json to codex exec and prints raw JSONL events directly. This surfaces Codex event traffic, but it does not expose hidden chain-of-thought. If you want interactive terminal scrollback while running Codex directly, codex --no-alt-screen is still useful, but that setting is separate from JaneBot's non-interactive wrapper behavior.

When a request looks like a code-generation task, janebot creates a generated project folder under BASE_FOLDER before invoking Codex and then runs Codex against that generated folder during the same command. JaneBot validates the generated project path into /opt/codex or /tmp before granting Codex direct write access to that generated folder so implementation can land immediately. Generation mode is triggered by either direct builder verbs such as create, build, generate, make, and write, or conversational prefixes such as give me, I want, and I need when the request still names a code target such as a CLI, tool, script, app, or project. The folder name is derived from the request text unless an explicit id is provided, and the scaffold includes:

  • package.json so npm link can expose the generated command name
  • README.md for user-facing information about what the generated project does and how to use it
  • docs/index.md for generated project documentation links
  • docs/details.md for technical implementation details

The Codex request is expanded to point implementation work at that folder and to use src/{project-id}.js as the main entry point for generated functionality. janebot creates that entry file as part of the initial scaffold, creates docs/index.md and docs/details.md for generated project documentation, runs Codex in the generated project folder with write access so the original request is implemented immediately, places supporting modules under src/ when they are needed, and uses package.json to map npm link to src/{project-id}.js.

Generated source follows a modular structure. src/{project-id}.js remains the direct CLI entry point and flow coordinator, while core feature modules and housekeeping utilities can live in supporting modules under src/. Generated modules stay under 120 lines of code, and generated functions stay at 60 lines or less.

When an explicit id is provided, janebot uses that id for the generated folder name, src/{project-id}.js entry point, and linked command name instead of deriving the name from the request text.

Generated base folders, generated project paths, and log output paths are validated to stay within /opt/codex or /tmp.

Comments from CaptainStarbuck

After creating this project I have asked myself many times if it's any better than just running codex from the command-line. I think so. It does a lot more.

But I don't think this provides really significant value. I just don't know. Maybe it will for some people.
Others will prefer to just use codex directly, or create their own projects, or script Codex CLI the way they want, or create their own wrapper around the tooling.

Or maybe people will like JaneBot and just want to keep enhancing it. I'll be happy to accept Issues for enhancements, and after discussion and agreement to accept PRs.

I welcome your feedback. Please check the poll in GitHub Discussions.

About

CLI wrapper around Codex CLI generates consistent project packages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors