原始内容
@selesai/code
Selesai coding agent — a terminal-based AI coding agent built on the
pi runtime.
This repo is the Selesai-branded fork/repackage. It builds the same TypeScript
source and ships a selesai CLI binary plus an importable SDK.
Prerequisites
- Node.js ≥ 20 (ESM,
Node16module resolution) - npm ≥ 10
- A POSIX shell (
shxhandles cross-platform file ops in build scripts) - No native compilation required for the agent itself; one dependency
(
@silvia-odwyer/photon-node) ships prebuilt native binaries via npm optionalDependencies, so justnpm install.
Install (from source)
git clone git@github.com:SelesaiInTech/selesai-code.git
cd selesai-code
npm install
Build
npm run build
What it does:
tsgo -p tsconfig.build.json— compilessrc/**/*.ts→dist/with declarations, source maps, and rewritten.ts→.jsimport extensions.chmod +x dist/cli.js— makes the CLI entrypoint executable.copy-assets— copies non-TS assets intodist/:src/modes/interactive/theme/*.jsonsrc/modes/interactive/assets/*.pngsrc/core/export-html/{template.html,template.css,template.js}src/core/export-html/vendor/*.js
Clean rebuild:
npm run clean && npm run build
Run locally
After building, invoke the CLI directly:
./dist/cli.js
# or link it globally:
npm link
selesai
Or run from source without linking (TypeScript via jiti is a runtime dep):
node --experimental-strip-types src/cli.ts
Note: the
binfield mapsselesai→dist/cli.js, so the published package exposes aselesaicommand once installed.
Project layout
src/
cli.ts CLI entrypoint
index.ts public SDK exports (main/types)
cli/startup-ui.ts pre-session TUI prompts (first-run setup, selectors)
modes/ interactive, non-interactive, headless modes
core/ agent loop, settings, package manager, export-html
config.ts app name, config dir, paths
docs/ user + contributor documentation
examples/ extension / SDK examples
Config dir on disk is ~/.selesai (see piConfig.configDir in
package.json).
Publish to npm
The package is published as @selesai/code (scoped). There is no
prepare/prepublishOnly script — you must build before publishing so
dist/ exists and is included by the files allowlist.
1. Authenticate
# one-time: log in to npm under the @selesai scope owner account
npm login
npm whoami # confirm you're authenticated
Publishing a scoped package publicly requires the Selesai org (or your account) to own the
@selesaiscope. If the scope isn't created yet:npm org create selesai <your-npm-username>
2. Bump version
There's no version script wired up; use the standard flow:
npm version patch # 0.1.0 -> 0.1.1 (bugfix)
npm version minor # 0.1.0 -> 0.2.0 (backward-compatible feature)
npm version major # 0.1.0 -> 1.0.0 (breaking)
This updates package.json, commits, and tags. Update CHANGELOG.md
in the same commit if you maintain one (it's in the files allowlist).
3. Build, verify pack contents, publish
# build dist/ (REQUIRED — npm publishes whatever is on disk)
npm run build
# dry-run: inspect exactly what gets published (must NOT include src/)
npm pack --dry-run
# publish to the public registry
npm publish --access public
--access public is mandatory for scoped packages unless you intend a paid
private package; without it the publish fails by default.
4. Verify
npm view @selesai/code version
# or in a clean sandbox:
npx @selesai/code@latest --help
Continuous publishing (CI)
Minimal GitHub Actions snippet — adapt to your runner auth (e.g. an
NPM_TOKEN secret with publish rights on @selesai):
# .github/workflows/publish.yml
name: publish
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Publishing checklist
-
npm run clean && npm run buildsucceeds with no errors -
npm pack --dry-runshows onlydist/,docs/,examples/,CHANGELOG.md,package.json,README.md,LICENSE— neversrc/ - Version bumped and committed
- Logged in as an account with publish rights on
@selesai -
--access publicpassed (scoped package) -
npm view @selesai/code versionmatches the version you intended
Notes & gotchas
- No
prepublishOnlyhook. Forgettingnpm run buildbeforenpm publishwill publish a stale (or empty)dist/. Always build. tsgois@typescript/native-preview(the Go-backed TS compiler preview) — it's a devDependency, so CI/npm ciinstalls it automatically.- Asset copy is manual, not a bundler step. If you add new JSON/PNG/HTML
themes or vendor JS, update the
copy-assetsscript inpackage.json. - Scoped publish.
@selesai/codeis under a scope; first-time publish needs--access public(public visibility is free, private costs money). - Binary name. Users get a
selesaicommand afternpm i -g @selesai/code.