nerve create sense: scaffold TypeScript + esbuild bundle instead of raw .js #225

Closed
opened 2026-04-28 07:33:20 +00:00 by xiaoju · 0 comments
Owner

Context

Following #224, senses now use TypeScript source + esbuild bundle (matching the workflow convention). But nerve create sense still scaffolds a raw index.js.

Tasks

1. Update packages/cli/src/commands/create.ts

  • buildSenseIndexJs() → rename to buildSenseIndexTs(), output TypeScript with types
  • Write to src/index.ts instead of index.js
  • buildSenseSchemaTs() → write to src/schema.ts instead of schema.ts
  • Add buildSensePackageJson() that generates:
{
  "name": "sense-<name>",
  "version": "0.0.1",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=index.js --packages=external"
  },
  "devDependencies": {
    "@types/node": "^22.0.0",
    "esbuild": "^0.27.0",
    "typescript": "^5.7.0"
  },
  "pnpm": {
    "onlyBuiltDependencies": ["esbuild"]
  }
}
  • After scaffolding, run pnpm install && pnpm build in the sense directory
  • Keep migrations/ at sense root (unchanged)

2. Update packages/skills/nerve-dev/SKILL.md

  • Update the sense file structure section to show src/index.ts, src/schema.ts, package.json
  • Update the example compute code to TypeScript
  • Note that index.js at root is the esbuild bundle output, not hand-written

3. Update tests

  • packages/cli/src/__tests__/create-sense.test.ts — verify new structure
  • packages/cli/src/__tests__/e2e-create.test.ts — if sense-related, update

Reference

See nerve-workspace senses for the target pattern: https://git.shazhou.work/xiaoju/nerve-workspace/src/branch/master/senses/linux-system-health/

## Context Following #224, senses now use TypeScript source + esbuild bundle (matching the workflow convention). But `nerve create sense` still scaffolds a raw `index.js`. ## Tasks ### 1. Update `packages/cli/src/commands/create.ts` - `buildSenseIndexJs()` → rename to `buildSenseIndexTs()`, output TypeScript with types - Write to `src/index.ts` instead of `index.js` - `buildSenseSchemaTs()` → write to `src/schema.ts` instead of `schema.ts` - Add `buildSensePackageJson()` that generates: ```json { "name": "sense-<name>", "version": "0.0.1", "private": true, "type": "module", "scripts": { "build": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=index.js --packages=external" }, "devDependencies": { "@types/node": "^22.0.0", "esbuild": "^0.27.0", "typescript": "^5.7.0" }, "pnpm": { "onlyBuiltDependencies": ["esbuild"] } } ``` - After scaffolding, run `pnpm install && pnpm build` in the sense directory - Keep `migrations/` at sense root (unchanged) ### 2. Update `packages/skills/nerve-dev/SKILL.md` - Update the sense file structure section to show `src/index.ts`, `src/schema.ts`, `package.json` - Update the example compute code to TypeScript - Note that `index.js` at root is the esbuild bundle output, not hand-written ### 3. Update tests - `packages/cli/src/__tests__/create-sense.test.ts` — verify new structure - `packages/cli/src/__tests__/e2e-create.test.ts` — if sense-related, update ## Reference See nerve-workspace senses for the target pattern: https://git.shazhou.work/xiaoju/nerve-workspace/src/branch/master/senses/linux-system-health/
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#225