01b477da26
- Implemented build.js to bundle TypeScript source into a minified executable using Bun. - Created publish.js to handle version bumping, building, and publishing to npm with user prompts. - Added tests for database schema and hook functions in database-schema.test.ts. - Introduced integration tests for hooks database in hooks-database-integration.test.ts. - Developed end-to-end tests for SDK prompts and parser in sdk-prompts-parser.test.ts. - Created session lifecycle tests to simulate complete Claude Code session in session-lifecycle.test.ts.
2.7 KiB
2.7 KiB
Build & Publish Guide
This repository is now the primary source for claude-mem. All builds and publishes happen from this repo.
Prerequisites
- Bun - Fast JavaScript runtime and bundler
- npm account with publish access to
claude-mem
Building
Build the project to create a bundled, minified executable:
npm run build
# or
node build.js
This will:
- Bundle all TypeScript source files using Bun
- Minify the output
- Add shebang (
#!/usr/bin/env node) - Set executable permissions
- Output to
dist/claude-mem.min.js
Build Output
- Entry point:
src/bin/cli.ts - Output:
dist/claude-mem.min.js(~350KB minified) - Target: Node.js (via Bun's
--target=node) - Externals:
@anthropic-ai/claude-agent-sdk(not bundled)
Publishing
To publish a new version to npm:
npm run publish:npm
# or
node publish.js
The publish script will:
- Check git status (warn if uncommitted changes)
- Show current version and prompt for version bump type:
patch- Bug fixes (1.0.X)minor- New features (1.X.0)major- Breaking changes (X.0.0)custom- Enter version manually
- Update
package.jsonwith new version - Run build script
- Run tests (if configured)
- Create git commit and tag (
v{version}) - Publish to npm
- Push commit and tags to GitHub
Manual Publishing
If you prefer to do it manually:
# 1. Update version in package.json
# 2. Build
npm run build
# 3. Commit and tag
git add package.json dist/
git commit -m "Release v3.9.17"
git tag v3.9.17
# 4. Publish
npm publish
# 5. Push
git push && git push --tags
Development
Run the CLI directly from source without building:
npm run dev -- [command] [options]
# or
bun run src/bin/cli.ts [command] [options]
Example:
npm run dev -- status
npm run dev -- --version
File Structure
claude-mem/
├── src/ # TypeScript source
│ ├── bin/cli.ts # CLI entry point
│ ├── commands/ # Command implementations
│ ├── services/ # Core services
│ └── shared/ # Shared utilities
├── dist/ # Build output
│ └── claude-mem.min.js # Bundled executable
├── build.js # Build script
├── publish.js # Publish script
└── package.json # Package configuration
Notes
- The build process embeds the version from
package.jsonat build time prepublishOnlyscript ensures build runs before npm publish- Dependencies are bundled except for external packages
- The published package includes:
dist/,hook-templates/,commands/,src/