Publishing Guide
Publishing Guide
Section titled “Publishing Guide”This guide covers how to publish packages to npm for the agent-detective monorepo.
Package Overview
Section titled “Package Overview”The root agent-detective app is "private": true and is not published to npm. Publish workspace packages under packages/ (via Changesets) as needed.
| Package | Description |
|---|---|
@agent-detective/types | Shared TypeScript types |
@agent-detective/core | OpenAPI / HTTP controller helpers |
@agent-detective/observability | Logging, metrics, health |
@agent-detective/process-utils | Process / shell helpers |
@agent-detective/local-repos-plugin | Local repo + matcher plugin |
@agent-detective/jira-adapter | Jira adapter plugin |
Prerequisites
Section titled “Prerequisites”- npm account with appropriate organization access
- pnpm installed:
npm install -g pnpm - 2FA enabled on your npm account (recommended)
- Clean git state with all changes committed
Pre-Publishing Checklist
Section titled “Pre-Publishing Checklist”- All tests pass:
pnpm run test - TypeScript check passes:
pnpm run typecheck - Build succeeds:
pnpm run build - Git working directory is clean
- Version numbers updated
Publishing Workflow
Section titled “Publishing Workflow”This monorepo uses Changesets for version management.
Standard Release Flow
Section titled “Standard Release Flow”# 1. Ensure clean stategit status # Should show clean working directory
# 2. Run pre-release checkspnpm run testpnpm run typecheckpnpm run lintpnpm run build
# 3. Create a changeset (describe what changed)pnpm changeset
# 4. Apply version bumps (updates package.json files)pnpm changeset version
# 5. Build with new versionspnpm run build
# 6. Commit version changesgit add -Agit commit -m "chore: release vX.Y.Z"git push
# 7. Publish packagespnpm publish -r --access publicChangeset File Format
Section titled “Changeset File Format”When you run pnpm changeset, it creates a file in .changeset/ with this format:
---"@agent-detective/types": patch"@agent-detective/jira-adapter": minor---
Description of changesVersion types:
patch- Bug fixes (1.0.0 → 1.0.1)minor- New features (1.0.0 → 1.1.0)major- Breaking changes (1.0.0 → 2.0.0)
Single Package Hotfix
Section titled “Single Package Hotfix”# Create changeset for specific packageecho '{"changesets":[]}' > .changeset/skip-versioning.mdpnpm changeset add --empty
# Or manually edit version in package.jsoncd packages/typespnpm version patchcd ../..pnpm run buildcd packages/types && pnpm publish --access publicVersion Numbering
Section titled “Version Numbering”We follow Semantic Versioning:
- MAJOR (1.0.0 → 2.0.0): Breaking changes to types or APIs
- MINOR (1.0.0 → 1.1.0): New types, new plugin features (backward compatible)
- PATCH (1.0.0 → 1.0.1): Bug fixes, documentation updates
Version Compatibility
Section titled “Version Compatibility”| @agent-detective/types | agent-detective |
|---|---|
| 1.x | 0.x |
| 2.x | 1.x (when released) |
For External Plugin Developers
Section titled “For External Plugin Developers”Wiring a published or private package into a running app (plugins in config, Docker volume paths, pnpm in the app root) is covered in extending-with-plugins.md. Below: @agent-detective/types and publish mechanics.
Installing Types Package
Section titled “Installing Types Package”npm install @agent-detective/types# orpnpm add @agent-detective/typesUsing Types in Your Plugin
Section titled “Using Types in Your Plugin”import type { Plugin, PluginContext, TaskEvent } from '@agent-detective/types';
const myPlugin: Plugin = { name: '@myorg/my-adapter', version: '1.0.0', schemaVersion: '1.0', schema: { type: 'object', properties: { enabled: { type: 'boolean', default: true }, }, required: [], }, register(app, context: PluginContext) { // context.agentRunner, context.repoMapping, etc. }};
export default myPlugin;Workspace vs Published Versions
Section titled “Workspace vs Published Versions”Within the monorepo, packages use workspace:* for dependencies:
{ "dependencies": { "@agent-detective/types": "workspace:*" }}When published to npm, pnpm automatically replaces workspace:* with the actual version.
Troubleshooting
Section titled “Troubleshooting””You must be logged in to publish packages"
Section titled “”You must be logged in to publish packages"”npm login# orpnpm login"You need to authorize this package for public access"
Section titled “"You need to authorize this package for public access"”# First time publishing a new scopenpm org add @agent-detective your-username"Cannot find module” after publish
Section titled “"Cannot find module” after publish”Check that dist/index.js and dist/index.d.ts exist in the published package.
Version conflict errors
Section titled “Version conflict errors”# Clear pnpm cachepnpm store prunepnpm installCI/CD Considerations
Section titled “CI/CD Considerations”For automated releases, consider:
- Using GitHub Actions to run tests and builds
- Using
release-pleaseor similar for automated version bumps - Adding npm tokens as GitHub Secrets
Example GitHub Action workflow:
name: Releaseon: push: tags: - 'v*'jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 - uses: actions/setup-node@v4 with: node-version: '24' registry-url: 'https://registry.npmjs.org' - run: pnpm install --frozen-lockfile - run: pnpm run test - run: pnpm run build - run: pnpm publish -r --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}Unpublishing
Section titled “Unpublishing”If you need to unpublish a version:
# Unpublish specific versionnpm unpublish @agent-detective/types@1.0.1
# Unpublish entire package (use with caution)npm unpublish @agent-detective/types --forceNote: You cannot unpublish a version if another package depends on it.
Docker Image Publishing (ghcr.io)
Section titled “Docker Image Publishing (ghcr.io)”The agent-detective Docker image is published to GitHub Container Registry (ghcr.io).
Image Information
Section titled “Image Information”| Item | Value |
|---|---|
| Registry | ghcr.io |
| Organization | toniop99 |
| Repository | agent-detective |
| Visibility | Public |
Image Tags
Section titled “Image Tags”| Tag | Description | Updated |
|---|---|---|
latest | Latest build from main branch | Every push to main |
stable | Latest release | On version tag |
1, 1.0, 1.0.0 | Version-specific tags | On version tag |
GitHub Actions Workflows
Section titled “GitHub Actions Workflows”The repository includes two workflows:
docker.yml (Build on Push)
Section titled “docker.yml (Build on Push)”- Trigger: Push to
mainbranch - Action: Builds and pushes Docker image with
latesttag - Platforms: linux/amd64, linux/arm64
release.yml (Build on Version Tag)
Section titled “release.yml (Build on Version Tag)”- Trigger: Push of tag
v*.*.* - Action: Builds and pushes Docker image with all version tags
- Platforms: linux/amd64, linux/arm64
Manual Image Build
Section titled “Manual Image Build”# Build locallydocker build --target production \ --build-arg AGENTS="opencode,claude" \ -t ghcr.io/toniop99/agent-detective:latest .
# Login to ghcr.ioecho $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# Pushdocker push ghcr.io/toniop99/agent-detective:latestVersion Tagging
Section titled “Version Tagging”# Create a version taggit tag v1.0.0git push origin v1.0.0
# This triggers release.yml which:# 1. Builds the image# 2. Pushes with tags: latest, stable, 1, 1.0, 1.0.0# 3. Creates a GitHub ReleaseAgent Selection at Build Time
Section titled “Agent Selection at Build Time”Build arguments control which agents are installed:
# Build with default agents (opencode only)docker build --target production -t agent-detective .
# Build with multiple agentsdocker build --target production \ --build-arg AGENTS="opencode,claude" \ -t agent-detective:multi .
# Available agents for AGENTS build-arg: opencode, claude (npm global).# Cursor Agent CLI (in-app id: cursor) is not installed via npm; see ../development/cursor-agent.md.Docker Image Structure
Section titled “Docker Image Structure”ghcr.io/toniop99/agent-detective:latest├── dist/ # Built application├── config/ # Default config├── plugins/ # Third-party plugins (volume mount)│ └── .gitkeep└── node_modules/ # Dependencies + bundled pluginsPulling the Image
Section titled “Pulling the Image”# Latestdocker pull ghcr.io/toniop99/agent-detective:latest
# Specific versiondocker pull ghcr.io/toniop99/agent-detective:1.0.0
# Stabledocker pull ghcr.io/toniop99/agent-detective:stable