Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@inceptionstack/roundhouse",
"version": "0.5.38",
"version": "0.5.40",
"type": "module",
"description": "Multi-platform chat gateway that routes messages through a configured AI agent",
"license": "MIT",
Expand All @@ -26,7 +26,8 @@
"start": "tsx src/index.ts",
"dev": "tsx watch src/index.ts",
"test": "vitest run",
"test:watch": "vitest"
"test:watch": "vitest",
"postpublish": "node scripts/verify-publish.mjs"
},
"files": [
"src/",
Expand Down
49 changes: 49 additions & 0 deletions scripts/verify-publish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env node
/**
* Verify npm publish succeeded by spawning a background agent
* to check registry, version, and dist tags.
*
* Only runs in interactive shells (skip CI, dry-run, non-TTY).
* Detaches to background to avoid blocking npm publish.
*/

import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import { existsSync } from 'fs';

// Skip in CI, dry-run, or non-interactive shells
if (process.env.CI || process.env.npm_config_dry_run || !process.stdout.isTTY) {
process.exit(0);
}

const __dirname = dirname(fileURLToPath(import.meta.url));
const repoRoot = dirname(__dirname);

// Try to find roundhouse: global PATH or local bin
let roundhouseCmd = 'roundhouse';
const localBin = resolve(repoRoot, 'node_modules/.bin/roundhouse');
if (existsSync(localBin)) {
roundhouseCmd = localBin;
}

// Spawn agent in background (detached, non-blocking)
try {
const child = spawn(roundhouseCmd, [
'subagent', 'spawn',
'--role', 'review',
'--task', 'Verify npm publish succeeded for @inceptionstack/roundhouse. Check registry, version, and dist tags.',
Comment on lines +31 to +35
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle spawn failures via error event

When roundhouse is not available on PATH (which is common in this repo checkout), spawn() does not throw synchronously; it emits an asynchronous 'error' event. Because no 'error' listener is attached, this becomes an unhandled error and exits with code 1, so the new postpublish hook can make npm publish report failure instead of gracefully warning and skipping verification as intended.

Useful? React with 👍 / 👎.

'--cwd', repoRoot,
'--timeout', '120000'
], {
detached: true,
stdio: 'ignore'
});

child.unref(); // Allow parent (npm publish) to exit without waiting
} catch (err) {
if (err.code === 'ENOENT') {
console.warn(`⚠️ Warning: roundhouse not found on PATH. Publish verification skipped. Install roundhouse globally or ensure it's in your PATH.`);
}
process.exit(0);
}
Loading