diff --git a/bin/hpl.ts b/bin/hpl.ts index 8410449..f024cbf 100644 --- a/bin/hpl.ts +++ b/bin/hpl.ts @@ -25,7 +25,7 @@ const program = new Command(); program .name("hpl") - .description("Human Pattern Lab CLI (alpha)") + .description("Human Pattern Lab CLI") .option("--json", "Emit contract JSON only on stdout") .showHelpAfterError() .configureHelp({ helpWidth: 100 }); diff --git a/package.json b/package.json index 710bc6e..9622af2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thehumanpatternlab/hpl", - "version": "1.0.0", + "version": "1.0.5", "description": "AI-forward, automation-safe SDK and CLI for the Human Pattern Lab", "type": "module", "license": "MIT", diff --git a/src/__tests__/json-output.test.ts b/src/__tests__/json-output.test.ts index b130c9e..a4a3bc1 100644 --- a/src/__tests__/json-output.test.ts +++ b/src/__tests__/json-output.test.ts @@ -13,6 +13,13 @@ describe("CLI --json output contract", () => { } ); + // Debug output + if (result.exitCode !== 0) { + console.log("Exit code:", result.exitCode); + console.log("stdout:", result.stdout); + console.log("stderr:", result.stderr); + } + // 1. Process must succeed expect(result.exitCode).toBe(0); diff --git a/src/commands/capabilities.ts b/src/commands/capabilities.ts index 5c591f6..40721c3 100644 --- a/src/commands/capabilities.ts +++ b/src/commands/capabilities.ts @@ -5,9 +5,9 @@ import { Command } from "commander"; import { writeHuman, writeJson } from "../io.js"; import { EXIT } from "../contract/exitCodes.js"; -import { getAlphaIntent } from "../contract/intents"; -import { ok } from "../contract/envelope"; -import { getCapabilitiesAlpha } from "../contract/capabilities"; +import { getAlphaIntent } from "../contract/intents.js"; +import { ok } from "../contract/envelope.js"; +import { getCapabilitiesAlpha } from "../contract/capabilities.js"; type GlobalOpts = { json?: boolean }; diff --git a/src/commands/health.ts b/src/commands/health.ts index bcd4388..e4b19c9 100644 --- a/src/commands/health.ts +++ b/src/commands/health.ts @@ -5,10 +5,10 @@ import { Command } from "commander"; import { writeHuman, writeJson } from "../io.js"; import { z } from "zod"; -import { getAlphaIntent } from "../contract/intents"; -import { ok, err } from "../contract/envelope"; -import { EXIT } from "../contract/exitCodes"; -import { getJson, HttpError } from "../http/client"; +import { getAlphaIntent } from "../contract/intents.js"; +import { ok, err } from "../contract/envelope.js"; +import { EXIT } from "../contract/exitCodes.js"; +import { getJson, HttpError } from "../http/client.js"; const HealthSchema = z.object({ status: z.string(), diff --git a/src/commands/version.ts b/src/commands/version.ts index b17d13a..aa0fc2f 100644 --- a/src/commands/version.ts +++ b/src/commands/version.ts @@ -5,14 +5,25 @@ import { Command } from "commander"; import { writeHuman, writeJson } from "../io.js"; import { EXIT } from "../contract/exitCodes.js"; -import { createRequire } from "node:module"; -import { getAlphaIntent } from "../contract/intents"; -import { ok } from "../contract/envelope"; +import { fileURLToPath } from "url"; +import { dirname, join } from "path"; +import { readFileSync, existsSync } from "fs"; +import { getAlphaIntent } from "../contract/intents.js"; +import { ok } from "../contract/envelope.js"; type GlobalOpts = { json?: boolean } -const require = createRequire(import.meta.url); -const pkg = require("../../package.json") as { name: string; version: string }; +// Resolve package.json from current file location (works for both tsx and compiled) +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +// Try source location first (tsx), then compiled location +let pkgPath = join(__dirname, "../../package.json"); +if (!existsSync(pkgPath)) { + pkgPath = join(__dirname, "../../../package.json"); +} + +const pkg = JSON.parse(readFileSync(pkgPath, "utf-8")) as { name: string; version: string }; export function versionCommand(): Command { return new Command("version") diff --git a/src/contract/capabilities.ts b/src/contract/capabilities.ts index f01f1f3..5f6236e 100644 --- a/src/contract/capabilities.ts +++ b/src/contract/capabilities.ts @@ -5,8 +5,8 @@ Contract: show_capabilities MUST emit tier, intents, schema versions. =========================================================== */ -import { CLI_SCHEMA_VERSION } from "./schema"; -import { listAlphaIntents } from "./intents"; +import { CLI_SCHEMA_VERSION } from "./schema.js"; +import { listAlphaIntents } from "./intents.js"; export type Capabilities = { intentTier: "alpha" | "full"; diff --git a/src/contract/envelope.ts b/src/contract/envelope.ts index 3d0c9aa..2da8ab1 100644 --- a/src/contract/envelope.ts +++ b/src/contract/envelope.ts @@ -5,8 +5,8 @@ Guarantee: When --json, stdout emits JSON only (no logs). =========================================================== */ -import type { IntentDescriptor } from "./intents"; -import { CLI_SCHEMA_VERSION, type ErrorPayload } from "./schema"; +import type { IntentDescriptor } from "./intents.js"; +import { CLI_SCHEMA_VERSION, type ErrorPayload } from "./schema.js"; export type CommandStatus = "ok" | "warn" | "error"; diff --git a/src/http/client.ts b/src/http/client.ts index d518753..7886060 100644 --- a/src/http/client.ts +++ b/src/http/client.ts @@ -6,7 +6,7 @@ - Supports both raw API payloads and envelope form { ok: true, data: ... }. =========================================================== */ -import { getConfig } from "../config"; +import { getConfig } from "../config.js"; export class HttpError extends Error { status?: number; diff --git a/src/index.ts b/src/index.ts index a98fd4b..89ac11b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,8 +26,8 @@ const program = new Command(); program .name("hpl") - .description("Human Pattern Lab CLI (alpha)") - .version("0.1.0") + .description("Human Pattern Lab CLI") + .version("1.0.3") .option("--json", "Emit contract JSON only on stdout") .configureHelp({ helpWidth: 100 }); diff --git a/src/render/text.ts b/src/render/text.ts index c1c83be..b19a536 100644 --- a/src/render/text.ts +++ b/src/render/text.ts @@ -4,7 +4,7 @@ Purpose: Deterministic, dependency-free formatting for terminals. =========================================================== */ import type { BaseEnvelope } from "../contract/envelope.js"; -import {formatTags, safeLine} from "./table"; +import {formatTags, safeLine} from "./table.js"; export function stripHtml(input: string): string { const s = (input || "");