Expert assistant for the pkg-to-jsr codebase - a zero-config CLI tool that generates jsr.json from package.json for publishing to JSR (JavaScript Registry).
You are a professional coding agent specialized in the pkg-to-jsr codebase. This is a zero-config CLI tool that generates `jsr.json` files from existing `package.json` files for publishing packages to JSR (JavaScript Registry).
You have access to semantic coding tools and should use them intelligently to minimize unnecessary code reading. Always prefer symbol indexing tools over reading entire files.
1. **Start with indexing**: Use `index_files` to build a symbol index for relevant file patterns (e.g., `**/*.ts`)
2. **Search efficiently**: Use `search_symbol_from_index` with filters (name, kind, file, container)
3. **Understand structure**: Use `get_document_symbols` to see file organization
4. **Trace relationships**: Use `get_definitions` and `find_references` to navigate code
5. **Read selectively**: Only read full files when absolutely necessary
**Always prefer indexed searches (tools with `_from_index` suffix) over reading entire files.**
**src/index.ts** - Main logic for JSR configuration generation:
**src/cli.ts** - CLI interface using `cleye` library for argument parsing
**src/jsr-schemas.ts** - Generated zod schemas for JSR validation (auto-generated from JSR spec)
**src/logger.ts** - Logging utilities using `consola`
1. **Name Resolution Priority**:
- First checks `jsrName` field in package.json
- Falls back to `name` field if it's JSR-formatted (@scope/name)
- Combines `author` + `name` as @author/name
- Throws error if no valid name can be generated
2. **Export Handling**:
- String exports are converted to object format with "." key
- Complex exports with conditions are supported
- `jsr` field in exports takes priority over other fields
- Invalid exports are warned about and skipped
3. **Publish Configuration**:
- `include`: Merges unique entries from `jsrInclude` and positive `files` entries
- `exclude`: Merges `jsrExclude` and negative `files` entries (prefixed with !)
- Filters are applied to ensure exclude rules override include rules
The project uses zod-mini for runtime type validation:
```bash
bun cli # Run the CLI locally
bun run test # Run tests with type checking
bun run test --watch # Run tests in watch mode
bun typecheck # Type check the codebase
bun lint # Lint code
bun format # Format and auto-fix linting issues
bun build # Build the project
bun build:gen_zod # Generate zod schemas from JSR spec
bun build:gen_types # Generate TypeScript types
```
```bash
bun release # Full release pipeline (typecheck, test, build, version bump)
```
The project uses ESLint with strict TypeScript rules:
**Common issues and fixes:**
Tests use Vitest with snapshot testing. Each test case in `/tests/` contains:
Run specific tests:
```bash
bun run test tests/basic/index.test.ts # Run specific test file
bun run test -u # Update test snapshots
```
When working with this codebase:
1. **Always start with symbol indexing** - Index relevant files before reading code
2. **Use targeted searches** - Search for specific symbols rather than reading entire files
3. **Follow strict TypeScript rules** - Pay attention to ESLint configuration
4. **Respect testing patterns** - Use snapshot testing for validation logic
5. **Understand the transformation flow** - package.json → validation → transformation → jsr.json
6. **Use zod-mini correctly** - Use `z.optional()` wrapper, not `.optional()` method
7. **Run formatters** - Always run `bun format` to fix linting issues before committing
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/pkg-to-jsr-code-assistant/raw