Skip to content
Merged
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
1 change: 1 addition & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ COPY package.json bun.lock* tsconfig*.json ./

# Copy package manifests first for layer caching
COPY packages/cli/package.json packages/cli/tsconfig.json ./packages/cli/
COPY packages/cli/scripts/ ./packages/cli/scripts/
COPY packages/agent/package.json packages/agent/tsconfig.json ./packages/agent/

RUN bun install --frozen-lockfile 2>/dev/null || bun install
Expand Down
16 changes: 4 additions & 12 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 19 additions & 2 deletions packages/cli/bin/tps.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const platform = process.platform;
const arch = process.arch;
const pkg = `@tpsdev-ai/cli-${platform}-${arch}`;

if (process.argv.includes('--version') || process.argv.includes('-v')) {
// Fast-path version output even when native binary package is missing.
// eslint-disable-next-line @typescript-eslint/no-var-requires
const version = require('../package.json').version;
console.log(version);
process.exit(0);
}

// Search for the platform binary relative to this package, not the cwd.
// npm nests optionalDependencies inside the parent's node_modules.
const searchPaths = [path.join(__dirname, '..'), path.join(__dirname, '..', '..')];
Expand All @@ -21,10 +29,19 @@ function runBinary() {
// Fall through to error message
}

// Fallback for source/dev installs where dist JS exists.
try {
const jsCli = path.join(__dirname, '..', 'dist', 'bin', 'tps.js');
execFileSync(process.execPath, [jsCli, ...process.argv.slice(2)], { stdio: 'inherit' });
return;
} catch (_) {
// continue to error output
}

console.error(`Failed to load native binding`);
console.error(`TPS: no binary package available for ${platform}-${arch}.`);
console.error(`Run npm install -g ${pkg} to install the platform binary package.`);
console.error('Or run from source inside the repository via `bun run tps` in packages/cli.');
console.error(`Try reinstalling main package: npm install -g @tpsdev-ai/cli@${require('../package.json').version}`);
console.error(`Or install platform binary directly: npm install -g ${pkg}@${require('../package.json').version}`);
process.exitCode = 1;
}

Expand Down
10 changes: 10 additions & 0 deletions packages/cli/bin/tps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ async function checkNono() {
}

async function main() {
if (process.argv.includes("--version") || process.argv.includes("-v")) {
const { readFileSync } = await import("node:fs");
const { dirname, join } = await import("node:path");
const { fileURLToPath } = await import("node:url");
const here = dirname(fileURLToPath(import.meta.url));
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf-8"));
console.log(pkg.version);
return;
}

await checkNono();
switch (command) {
case "hire": {
Expand Down
11 changes: 6 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"tps": "./bin/tps.cjs"
},
"optionalDependencies": {
"@tpsdev-ai/cli-darwin-arm64": "0.4.2",
"@tpsdev-ai/cli-darwin-x64": "0.4.2",
"@tpsdev-ai/cli-linux-arm64": "0.4.2",
"@tpsdev-ai/cli-linux-x64": "0.4.2"
"@tpsdev-ai/cli-darwin-arm64": "0.5.0",
"@tpsdev-ai/cli-darwin-x64": "0.5.0",
"@tpsdev-ai/cli-linux-arm64": "0.5.0",
"@tpsdev-ai/cli-linux-x64": "0.5.0"
},
"scripts": {
"build": "tsc",
Expand All @@ -25,7 +25,8 @@
"lint": "biome lint ./src ./bin",
"lint:ci": "biome lint ./src ./bin --max-diagnostics=200",
"pretest": "tsc",
"test": "bun test"
"test": "bun test",
"postinstall": "node scripts/postinstall.cjs"
},
"keywords": [
"cli",
Expand Down
11 changes: 11 additions & 0 deletions packages/cli/scripts/postinstall.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if (process.env.CI) process.exit(0);
const { execSync } = require("child_process");
const { arch, platform } = process;
const pkg = `@tpsdev-ai/cli-${platform}-${arch}`;
const version = require("../package.json").version;

try {
execSync(`npm install -g ${pkg}@${version}`, { stdio: "inherit" });
} catch {
console.warn(`Optional: install ${pkg}@${version} for native binary performance.`);
}
10 changes: 10 additions & 0 deletions packages/cli/scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { execSync } = require("child_process");
const { arch, platform } = process;
const pkg = `@tpsdev-ai/cli-${platform}-${arch}`;
const version = require("../package.json").version;

try {
execSync(`npm install -g ${pkg}@${version}`, { stdio: "inherit" });
} catch {
console.warn(`Optional: install ${pkg}@${version} for native binary performance.`);
}
Loading