TL;DR of the full STYLE_GUIDE.md - print this and keep it handy!
□ npm install
□ npm run build
□ npm test
□ Read STYLE_GUIDE.md (at least the Import Rules section!)ALL relative imports MUST end in .js (even for .ts files)
✅ import { foo } from "./bar.js"
❌ import { foo } from "./bar"□ npm run build # Succeeds?
□ npm test # Passes?
□ Check .js extensions # All imports have them?
□ Commit message # Emoji prefix + format?<emoji> <scope>: <subject>
Common prefixes:
⚙️ feat:- New features🐛 fix:- Bug fixes📚 docs:- Documentation🔧 refactor:- Code restructuring✅ test:- Tests🌉 bridge:- Relay system
# Development
npm run dev <command> # Run with tsx (no build)
npm run build # Compile TypeScript
npm start <command> # Run built version
# Testing
npm test # All tests
npm test:watch # Watch mode
# Local Install
npm install -g . # Install globally
hpl version # Test it works
# Emergency Reset
rm -rf dist/ node_modules/
npm install && npm run build# Find imports missing .js
grep -r "from ['\"]\.\.*/[^'\"]*[^s]['\"]" src/ --include="*.ts" | grep -v "\.js['\"]"
# Or just look at the error:
# "Cannot find module '.../XXX' imported from YYY.js"
# ^^^ ^^^
# Missing .js Check this source fileimport { Command } from "commander";
import { writeHuman, writeJson } from "../io.js";
import { EXIT } from "../contract/exitCodes.js";
import { getAlphaIntent } from "../contract/intents.js";
import { ok } from "../contract/envelope.js";
type GlobalOpts = { json?: boolean };
export function myCommand(): Command {
return new Command("mycommand")
.description("...")
.action((...args: any[]) => {
const cmd = args[args.length - 1] as Command;
const opts = (cmd.parent?.opts?.() ?? {}) as GlobalOpts;
const result = runMyCommand();
if (opts.json) writeJson(result);
else writeHuman("...");
process.exitCode = EXIT.OK;
});
}
export function runMyCommand() {
const intent = getAlphaIntent("my_intent");
return ok("mycommand", intent, { /* data */ });
}| Problem | Cause | Fix |
|---|---|---|
ERR_MODULE_NOT_FOUND |
Missing .js |
Add .js to import |
| Type passes, runtime fails | No validation | Use Zod schemas |
| JSON has extra output | Logs to stdout | Use console.error() |
| Wrong exit code | Not set | Set process.exitCode |
| Old version runs | npm cache | npm uninstall -g && npm cache clean --force |
Breaking Changes (DON'T DO in v0.x):
- ❌ Change envelope structure
- ❌ Remove JSON fields
- ❌ Change exit codes
- ❌ Rename commands
- ❌ Change intent IDs
Safe Changes:
- ✅ Add new commands
- ✅ Add new JSON fields
- ✅ Add new intents
- ✅ Improve error messages
- ✅ Internal refactoring
Add to .vscode/settings.json:
{
"typescript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.importModuleSpecifier": "relative"
}This auto-adds .js to imports!
src/
├── contract/ # Output contracts - STABLE
│ ├── schema.ts # Zod schemas
│ ├── envelope.ts # Success/error wrappers
│ ├── intents.ts # Intent registry
│ └── exitCodes.ts # Exit code constants
├── commands/ # CLI commands
│ └── notes/ # Domain commands
├── lib/ # Shared utilities
└── io.ts # stdout/stderr helpers
bin/
└── hpl.ts # Entrypoint
See STYLE_GUIDE.md for:
- Detailed explanations
- More code examples
- Architecture decisions
- Full gotcha list
- Contract details
Totally Stuck?
- Check error message carefully (it tells you which file!)
- Look at similar existing code
- Run
npm testto see examples - Full reset:
rm -rf dist/ node_modules/ && npm install && npm run build - Ask for help (with error message + what you tried)
Healthy Repo:
$ npm run build
✓ Compiled successfully
$ npm test
✓ All tests passing
$ npm start version
✓ Shows version
$ hpl version
✓ Shows version (global install works)Print this page and tape it to your monitor! 🦊
Quick ref for STYLE_GUIDE.md - Last updated: 2025-01-27