bpmax-cli 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ The update command checks the npm registry for `bpmax-cli`, runs `npm install -g
20
20
 
21
21
  ## First-time setup
22
22
 
23
- After installation, bpmax-cli prints an agent-oriented setup hint. The expected flow is: ask the user for any BPMAX page URL in the target workspace, then run setup with that URL.
23
+ After installation, bpmax-cli prints an agent-oriented setup hint. The expected flow is: ask the user to directly input any BPMAX page URL in the target workspace, then run setup with that URL after the user replies.
24
24
 
25
25
  For agent-driven use, ask the user for any BPMAX page URL in the target workspace, then run setup with that URL. The CLI extracts the environment origin and workspace from the URL and opens browser authorization without terminal prompts:
26
26
 
package/dist/bin.js CHANGED
@@ -9,8 +9,8 @@ import { mkdir, readFile, writeFile } from "fs/promises";
9
9
  import path from "path";
10
10
 
11
11
  // src/core/setup-guide.ts
12
- var SETUP_URL_PROMPT = "Please provide any BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr.";
13
- var SETUP_COMMAND_HINT = "Then run: bpmax-cli setup <BPMAX_WORKSPACE_URL> --name local";
12
+ var SETUP_URL_PROMPT = "Agent action: ask the user to directly input a BPMAX workspace page URL, for example http://127.0.0.1:10018/w:store_mgr.";
13
+ var SETUP_COMMAND_HINT = 'Do not show a command template yet. After the user replies with the URL, run: bpmax-cli setup "<USER_URL>" --name local';
14
14
 
15
15
  // src/core/config.ts
16
16
  var DEFAULT_WORKSPACE = "default";
@@ -847,7 +847,7 @@ function registerSetupCommand(program2, deps = {}) {
847
847
  // package.json
848
848
  var package_default = {
849
849
  name: "bpmax-cli",
850
- version: "0.1.4",
850
+ version: "0.1.6",
851
851
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
852
852
  type: "module",
853
853
  bin: {
@@ -1372,6 +1372,7 @@ function registerUserCommands(program2) {
1372
1372
  // src/core/notices.ts
1373
1373
  var pendingUpdate = null;
1374
1374
  var pendingSkills = null;
1375
+ var pendingSetup = null;
1375
1376
  function updateMessage(info) {
1376
1377
  return `bpmax-cli ${info.latest} available, current ${info.current}, run: bpmax-cli update`;
1377
1378
  }
@@ -1381,12 +1382,39 @@ function skillsMessage(info) {
1381
1382
  }
1382
1383
  return `bpmax-cli skills ${info.current} out of sync with binary ${info.target}, run: bpmax-cli update`;
1383
1384
  }
1384
- async function setupNotices() {
1385
+ function setupMessage() {
1386
+ return [
1387
+ "bpmax-cli is not initialized.",
1388
+ SETUP_URL_PROMPT,
1389
+ SETUP_COMMAND_HINT
1390
+ ].join("\n");
1391
+ }
1392
+ function hasConfiguredProfile(config) {
1393
+ return Object.values(config.profiles).some((profile) => Boolean(profile.origin?.trim()));
1394
+ }
1395
+ function shouldWriteSetupNotice(argv) {
1396
+ const args = argv.slice(2);
1397
+ if (args.length === 0) {
1398
+ return true;
1399
+ }
1400
+ return args.includes("--version") || args.includes("-V");
1401
+ }
1402
+ async function setupNotices(argv = process.argv) {
1385
1403
  pendingUpdate = await checkCachedUpdate(VERSION);
1386
1404
  const skills = await checkSkillsSync(VERSION);
1387
1405
  pendingSkills = skills.inSync ? null : { current: skills.current, target: skills.target };
1406
+ const config = await loadConfig();
1407
+ pendingSetup = hasConfiguredProfile(config) ? null : { message: setupMessage() };
1408
+ if (pendingSetup && shouldWriteSetupNotice(argv)) {
1409
+ console.error(pendingSetup.message);
1410
+ }
1388
1411
  setNoticeProvider(() => {
1389
1412
  const notice = {};
1413
+ if (pendingSetup) {
1414
+ notice.setup = {
1415
+ message: pendingSetup.message
1416
+ };
1417
+ }
1390
1418
  if (pendingUpdate) {
1391
1419
  notice.update = {
1392
1420
  current: pendingUpdate.current,
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bin.ts","../src/core/config.ts","../src/core/setup-guide.ts","../src/core/http.ts","../src/core/output.ts","../src/commands/api.ts","../src/core/auth.ts","../src/commands/auth.ts","../src/commands/config.ts","../src/commands/flow.ts","../src/commands/project.ts","../src/core/manifest.ts","../src/commands/schema.ts","../src/commands/setup.ts","../src/core/setup.ts","../package.json","../src/core/build.ts","../src/core/skills.ts","../src/core/process.ts","../src/core/update.ts","../src/commands/update.ts","../src/commands/user.ts","../src/core/notices.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport { registerApiCommands } from './commands/api.js';\nimport { registerAuthCommands } from './commands/auth.js';\nimport { registerConfigCommands } from './commands/config.js';\nimport { registerFlowCommands } from './commands/flow.js';\nimport { registerProjectCommands } from './commands/project.js';\nimport { registerSchemaCommands } from './commands/schema.js';\nimport { registerSetupCommand } from './commands/setup.js';\nimport { registerUpdateCommands } from './commands/update.js';\nimport { registerUserCommands } from './commands/user.js';\nimport { CLI_NAME, VERSION } from './core/build.js';\nimport { setupNotices } from './core/notices.js';\n\nconst program = new Command();\n\nprogram\n .name(CLI_NAME)\n .description('BPMAX multi-environment CLI')\n .version(VERSION);\n\nregisterConfigCommands(program);\nregisterAuthCommands(program);\nregisterApiCommands(program);\nregisterSchemaCommands(program);\nregisterUserCommands(program);\nregisterFlowCommands(program);\nregisterProjectCommands(program);\nregisterSetupCommand(program);\nregisterUpdateCommands(program);\n\nconst isCompletion = process.argv.includes('completion') || process.argv.includes('__complete');\n\n(isCompletion ? Promise.resolve() : setupNotices())\n .then(() => program.parseAsync(process.argv))\n .catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n });\n","import { homedir } from 'node:os';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type {\n AnyConfigFile,\n ConfigFileV2,\n LegacyConfigFile,\n ProfileConfig,\n ResolvedProfile,\n} from './types.js';\nimport { SETUP_COMMAND_HINT, SETUP_URL_PROMPT } from './setup-guide.js';\n\nexport const DEFAULT_WORKSPACE = 'default';\nexport const DEFAULT_LANGUAGE = 'zhCN';\n\nconst CONFIG_DIR = path.join(homedir(), '.bpmax');\nconst CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');\n\nconst defaultConfig = (): ConfigFileV2 => ({\n version: 2,\n current_profile: 'default',\n profiles: {\n default: {\n origin: '',\n workspace: DEFAULT_WORKSPACE,\n language: DEFAULT_LANGUAGE,\n },\n },\n});\n\nconst normalizeOrigin = (origin: string): string => origin.trim().replace(/\\/+$/, '');\n\nconst isV2Config = (input: AnyConfigFile): input is ConfigFileV2 =>\n typeof input === 'object' &&\n input !== null &&\n 'version' in input &&\n (input as ConfigFileV2).version === 2 &&\n 'profiles' in input;\n\nconst toV2Config = (input: AnyConfigFile): ConfigFileV2 => {\n if (isV2Config(input)) {\n return {\n version: 2,\n current_profile: input.current_profile || 'default',\n profiles: Object.fromEntries(\n Object.entries(input.profiles || {}).map(([name, profile]) => [\n name,\n {\n ...profile,\n origin: normalizeOrigin(profile.origin || ''),\n workspace: profile.workspace || DEFAULT_WORKSPACE,\n language: profile.language || DEFAULT_LANGUAGE,\n },\n ]),\n ),\n };\n }\n\n const legacy = input as LegacyConfigFile;\n const migrated = defaultConfig();\n migrated.profiles.default = {\n origin: normalizeOrigin(legacy.host || ''),\n api_key: legacy.api_key || '',\n workspace: DEFAULT_WORKSPACE,\n language: DEFAULT_LANGUAGE,\n };\n return migrated;\n};\n\nexport async function loadConfig(): Promise<ConfigFileV2> {\n try {\n const raw = await readFile(CONFIG_PATH, 'utf8');\n const parsed = JSON.parse(raw) as AnyConfigFile;\n return toV2Config(parsed);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return defaultConfig();\n }\n throw error;\n }\n}\n\nexport async function saveConfig(config: ConfigFileV2): Promise<void> {\n await mkdir(CONFIG_DIR, { recursive: true });\n await writeFile(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\\n`, 'utf8');\n}\n\nexport function getConfigPath(): string {\n return CONFIG_PATH;\n}\n\nexport function getConfigDir(): string {\n return CONFIG_DIR;\n}\n\nexport function maskApiKey(apiKey?: string): string {\n if (!apiKey) {\n return '(unset)';\n }\n if (apiKey.length <= 10) {\n return apiKey;\n }\n return `${apiKey.slice(0, 8)}****${apiKey.slice(-4)}`;\n}\n\nexport function ensureProfile(config: ConfigFileV2, profileName: string): ProfileConfig {\n const profile = config.profiles[profileName];\n if (!profile) {\n throw new Error(`Profile \"${profileName}\" not found.`);\n }\n return profile;\n}\n\nexport function resolveProfile(config: ConfigFileV2, profileName?: string): ResolvedProfile {\n const name = profileName || config.current_profile || 'default';\n const profile = ensureProfile(config, name);\n\n if (!profile.origin) {\n throw new Error(\n [\n `Profile \"${name}\" has no origin configured. bpmax-cli is not initialized yet.`,\n SETUP_URL_PROMPT,\n SETUP_COMMAND_HINT,\n ].join('\\n'),\n );\n }\n\n return {\n name,\n config: {\n origin: normalizeOrigin(profile.origin),\n api_key: profile.api_key,\n workspace: profile.workspace || DEFAULT_WORKSPACE,\n language: profile.language || DEFAULT_LANGUAGE,\n user: profile.user,\n },\n };\n}\n\nexport async function upsertProfile(name: string, nextProfile: ProfileConfig): Promise<ConfigFileV2> {\n const config = await loadConfig();\n config.profiles[name] = {\n ...config.profiles[name],\n ...nextProfile,\n origin: normalizeOrigin(nextProfile.origin || config.profiles[name]?.origin || ''),\n workspace: nextProfile.workspace || config.profiles[name]?.workspace || DEFAULT_WORKSPACE,\n language: nextProfile.language || config.profiles[name]?.language || DEFAULT_LANGUAGE,\n };\n if (!config.current_profile) {\n config.current_profile = name;\n }\n await saveConfig(config);\n return config;\n}\n","export const SETUP_URL_PROMPT =\n 'Please provide any BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr.';\n\nexport const SETUP_COMMAND_HINT =\n 'Then run: bpmax-cli setup <BPMAX_WORKSPACE_URL> --name local';\n","import axios, { AxiosHeaders, type AxiosInstance } from 'axios';\n\nimport type { ApiEnvelope, ResolvedProfile } from './types.js';\n\nconst ensureApiPath = (path: string): string => {\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n if (path.startsWith('/api/')) {\n return path;\n }\n return `/api${path}`;\n};\n\nexport function createApiClient(profile: ResolvedProfile): AxiosInstance {\n const instance = axios.create({\n baseURL: profile.config.origin,\n withCredentials: false,\n });\n\n instance.interceptors.request.use((config) => {\n config.params = {\n ...(config.params || {}),\n $workspace: config.params?.$workspace ?? profile.config.workspace,\n $language: config.params?.$language ?? profile.config.language,\n };\n if (profile.config.api_key) {\n const headers = AxiosHeaders.from(config.headers || {});\n headers.set('Authorization', `Bearer ${profile.config.api_key}`);\n config.headers = headers;\n }\n return config;\n });\n\n return instance;\n}\n\nexport async function apiRequest<T>(\n client: AxiosInstance,\n method: string,\n path: string,\n options: {\n params?: Record<string, unknown>;\n data?: unknown;\n } = {},\n): Promise<T> {\n const response = await client.request<ApiEnvelope<T>>({\n method,\n url: ensureApiPath(path),\n params: options.params,\n data: options.data,\n });\n const body = response.data;\n if (body.code !== 0) {\n throw new Error(body.msg || `Request failed with code ${body.code}`);\n }\n return (body.data ?? body) as T;\n}\n","import type { OutputFormat } from './types.js';\n\ntype NoticeValue = Record<string, unknown>;\ntype NoticeProvider = () => Record<string, NoticeValue> | null;\n\nlet noticeProvider: NoticeProvider | null = null;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport function setNoticeProvider(provider: NoticeProvider): void {\n noticeProvider = provider;\n}\n\nexport function clearNoticeProvider(): void {\n noticeProvider = null;\n}\n\nfunction currentNotice(): Record<string, NoticeValue> | null {\n return noticeProvider?.() || null;\n}\n\nfunction withJsonNotice(value: unknown): unknown {\n const notice = currentNotice();\n if (!notice || Object.keys(notice).length === 0) {\n return value;\n }\n if (isRecord(value)) {\n return { ...value, _notice: notice };\n }\n return value;\n}\n\nfunction emitTextNotice(): void {\n const notice = currentNotice();\n if (!notice) {\n return;\n }\n Object.values(notice).forEach((entry) => {\n if (typeof entry.message === 'string') {\n console.error(entry.message);\n }\n });\n}\n\nexport function printResult(format: OutputFormat, value: unknown): void {\n switch (format) {\n case 'json':\n console.log(JSON.stringify(withJsonNotice(value), null, 2));\n return;\n case 'ndjson':\n if (Array.isArray(value)) {\n value.forEach((item) => {\n console.log(JSON.stringify(item));\n });\n } else {\n console.log(JSON.stringify(value));\n }\n return;\n case 'table':\n if (Array.isArray(value)) {\n console.table(value);\n } else if (isRecord(value)) {\n console.table([value]);\n } else {\n console.log(value);\n }\n return;\n case 'pretty':\n default:\n emitTextNotice();\n if (typeof value === 'string') {\n console.log(value);\n return;\n }\n console.log(JSON.stringify(value, null, 2));\n }\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nfunction parseJson(input?: string): unknown {\n if (!input) {\n return undefined;\n }\n return JSON.parse(input);\n}\n\nexport function registerApiCommands(program: Command): void {\n program\n .command('api <method> <path>')\n .description('Call an arbitrary BPMAX /api endpoint')\n .option('--profile <profile>', 'Profile name')\n .option('--params <json>', 'Query params JSON')\n .option('--data <json>', 'Request body JSON')\n .option('--format <format>', 'Output format', 'json')\n .action(async (method: string, path: string, options: {\n profile?: string;\n params?: string;\n data?: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown>(createApiClient(profile), method, path, {\n params: parseJson(options.params) as Record<string, unknown> | undefined,\n data: parseJson(options.data),\n });\n printResult(options.format, result);\n });\n}\n","import { createServer } from 'node:http';\nimport { randomBytes } from 'node:crypto';\n\nimport open from 'open';\n\nimport type { CallbackPayload, ProfileConfig, UserSummary } from './types.js';\n\nexport interface LoginResult {\n apiKey: string;\n user?: UserSummary;\n}\n\nfunction buildBridgeUrl(\n origin: string,\n workspace: string,\n params: Record<string, string>,\n): string {\n const query = new URLSearchParams(params);\n return `${origin}/${encodeURIComponent(workspace)}/cli-login?${query.toString()}`;\n}\n\nexport async function runBrowserLogin(options: {\n origin: string;\n workspace: string;\n profileName: string;\n apiKeyName: string;\n timeoutMs?: number;\n}): Promise<LoginResult & { state: string }> {\n const state = randomBytes(16).toString('hex');\n const timeoutMs = options.timeoutMs ?? 5 * 60 * 1000;\n\n return await new Promise((resolve, reject) => {\n const server = createServer(async (req, res) => {\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type');\n\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n\n if (req.method !== 'POST' || req.url !== '/callback') {\n res.statusCode = 404;\n res.end(JSON.stringify({ ok: false, message: 'Not found' }));\n return;\n }\n\n let raw = '';\n req.on('data', (chunk) => {\n raw += chunk.toString();\n });\n req.on('end', () => {\n try {\n const payload = JSON.parse(raw) as CallbackPayload;\n if (payload.state !== state) {\n res.statusCode = 400;\n res.end(JSON.stringify({ ok: false, message: 'Invalid state' }));\n return;\n }\n if (!payload.api_key) {\n res.statusCode = 400;\n res.end(JSON.stringify({ ok: false, message: 'Missing api_key' }));\n return;\n }\n res.statusCode = 200;\n res.end(JSON.stringify({ ok: true }));\n clearTimeout(timer);\n server.close();\n resolve({ apiKey: payload.api_key, user: payload.user, state });\n } catch (error) {\n res.statusCode = 400;\n res.end(\n JSON.stringify({\n ok: false,\n message: error instanceof Error ? error.message : 'Invalid callback payload',\n }),\n );\n }\n });\n req.on('error', reject);\n });\n\n server.listen(0, '127.0.0.1', async () => {\n const address = server.address();\n if (!address || typeof address === 'string') {\n reject(new Error('Failed to allocate local callback port.'));\n return;\n }\n const callbackUrl = `http://127.0.0.1:${address.port}/callback`;\n const bridgeUrl = buildBridgeUrl(options.origin, options.workspace, {\n callback: callbackUrl,\n state,\n profile: options.profileName,\n key_name: options.apiKeyName,\n });\n await open(bridgeUrl);\n });\n\n server.on('error', reject);\n\n const timer = setTimeout(() => {\n server.close();\n reject(new Error('Timed out waiting for browser login callback.'));\n }, timeoutMs);\n });\n}\n\nexport function updateProfileAuth(profile: ProfileConfig, result: LoginResult): ProfileConfig {\n return {\n ...profile,\n api_key: result.apiKey,\n user: result.user,\n };\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, maskApiKey, resolveProfile, saveConfig } from '../core/config.js';\nimport { runBrowserLogin, updateProfileAuth } from '../core/auth.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerAuthCommands(program: Command): void {\n const auth = program.command('auth').description('Authenticate and manage API key state');\n\n auth\n .command('login')\n .description('Open the hpt-frontend bridge page and persist the returned API key')\n .option('--profile <profile>', 'Profile name')\n .option('--key-name <keyName>', 'Target API key name', 'bpmax-cli')\n .action(async (options: { profile?: string; keyName: string }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await runBrowserLogin({\n origin: profile.config.origin,\n workspace: profile.config.workspace,\n profileName: profile.name,\n apiKeyName: options.keyName,\n });\n config.profiles[profile.name] = updateProfileAuth(config.profiles[profile.name], result);\n await saveConfig(config);\n console.log(`Saved API key for profile \"${profile.name}\".`);\n });\n\n auth\n .command('status')\n .description('Show saved auth state and validate /api/user/current')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const output: Record<string, unknown> = {\n profile: profile.name,\n origin: profile.config.origin,\n workspace: profile.config.workspace,\n language: profile.config.language,\n api_key: maskApiKey(profile.config.api_key),\n };\n\n if (profile.config.api_key) {\n try {\n const currentUser = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n '/user/current',\n );\n output.user = currentUser;\n output.authenticated = true;\n } catch (error) {\n output.authenticated = false;\n output.error = error instanceof Error ? error.message : String(error);\n }\n } else {\n output.authenticated = false;\n }\n\n printResult(options.format, output);\n });\n\n auth\n .command('logout')\n .description('Clear the stored API key for the selected profile')\n .option('--profile <profile>', 'Profile name')\n .action(async (options: { profile?: string }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n config.profiles[profile.name] = {\n ...config.profiles[profile.name],\n api_key: '',\n user: undefined,\n };\n await saveConfig(config);\n console.log(`Cleared API key for profile \"${profile.name}\".`);\n });\n}\n","import { text } from '@clack/prompts';\nimport type { Command } from 'commander';\n\nimport {\n DEFAULT_LANGUAGE,\n DEFAULT_WORKSPACE,\n getConfigPath,\n loadConfig,\n maskApiKey,\n saveConfig,\n upsertProfile,\n} from '../core/config.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat, ProfileConfig } from '../core/types.js';\n\nasync function ensureValue(current: string | undefined, label: string, placeholder?: string): Promise<string> {\n if (current) {\n return current;\n }\n const result = await text({\n message: label,\n placeholder,\n });\n if (typeof result !== 'string' || !result.trim()) {\n throw new Error(`${label} is required.`);\n }\n return result.trim();\n}\n\nexport function registerConfigCommands(program: Command): void {\n const config = program.command('config').description('Manage local bpmax-cli profiles');\n const profile = config.command('profile').description('Manage named environment profiles');\n\n profile\n .command('add')\n .description('Add or update a profile')\n .option('--name <name>', 'Profile name')\n .option('--origin <origin>', 'Profile origin')\n .option('--api-key <apiKey>', 'API key')\n .option('--workspace <workspace>', 'Default workspace', DEFAULT_WORKSPACE)\n .option('--language <language>', 'Default language', DEFAULT_LANGUAGE)\n .action(async (options) => {\n const name = await ensureValue(options.name, 'Profile name', 'default');\n const origin = await ensureValue(options.origin, 'Origin', 'https://example.com');\n await upsertProfile(name, {\n origin,\n api_key: options.apiKey,\n workspace: options.workspace,\n language: options.language,\n });\n console.log(`Saved profile \"${name}\" to ${getConfigPath()}.`);\n });\n\n profile\n .command('list')\n .description('List profiles')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { format: OutputFormat }) => {\n const configData = await loadConfig();\n const rows = Object.entries(configData.profiles).map(([name, profileConfig]) => ({\n name,\n current: configData.current_profile === name,\n origin: profileConfig.origin,\n workspace: profileConfig.workspace || DEFAULT_WORKSPACE,\n language: profileConfig.language || DEFAULT_LANGUAGE,\n api_key: maskApiKey(profileConfig.api_key),\n }));\n printResult(options.format, rows);\n });\n\n profile\n .command('use <name>')\n .description('Set the active profile')\n .action(async (name: string) => {\n const configData = await loadConfig();\n if (!configData.profiles[name]) {\n throw new Error(`Profile \"${name}\" not found.`);\n }\n configData.current_profile = name;\n await saveConfig(configData);\n console.log(`Current profile set to \"${name}\".`);\n });\n\n profile\n .command('remove <name>')\n .description('Remove a profile')\n .action(async (name: string) => {\n const configData = await loadConfig();\n if (!configData.profiles[name]) {\n throw new Error(`Profile \"${name}\" not found.`);\n }\n delete configData.profiles[name];\n if (configData.current_profile === name) {\n const [nextProfile] = Object.keys(configData.profiles);\n configData.current_profile = nextProfile || 'default';\n }\n await saveConfig(configData);\n console.log(`Removed profile \"${name}\".`);\n });\n\n profile\n .command('show')\n .description('Show a profile')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; format: OutputFormat }) => {\n const configData = await loadConfig();\n const name = options.profile || configData.current_profile;\n const target = configData.profiles[name];\n if (!target) {\n throw new Error(`Profile \"${name}\" not found.`);\n }\n printResult(options.format, {\n name,\n config_path: getConfigPath(),\n origin: target.origin,\n workspace: target.workspace || DEFAULT_WORKSPACE,\n language: target.language || DEFAULT_LANGUAGE,\n api_key: maskApiKey(target.api_key),\n user: target.user || null,\n });\n });\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerFlowCommands(program: Command): void {\n const flow = program.command('flow').description('Flow commands');\n\n flow\n .command('list')\n .description('List flows')\n .option('--profile <profile>', 'Profile name')\n .option('--draft <draft>', 'Draft flag', '1')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { profile?: string; draft: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown[]>(\n createApiClient(profile),\n 'GET',\n '/flow/flow_type',\n {\n params: {\n draft: options.draft,\n skip_i18n: 'true',\n },\n },\n );\n printResult(options.format, result);\n });\n\n flow\n .command('options')\n .description('List flow options')\n .option('--profile <profile>', 'Profile name')\n .option('--name <name>', 'Flow name filter')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { profile?: string; name?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown[]>(\n createApiClient(profile),\n 'GET',\n '/flow/options',\n {\n params: options.name ? { name: options.name } : undefined,\n },\n );\n printResult(options.format, result);\n });\n\n flow\n .command('get')\n .description('Get flow detail by id')\n .requiredOption('--id <id>', 'Flow id')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { id: string; profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown[]>(\n createApiClient(profile),\n 'POST',\n '/flow/batch_get',\n {\n data: {\n ids: [Number(options.id)],\n },\n },\n );\n printResult(options.format, result[0] ?? null);\n });\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nfunction parseJson(input?: string): Record<string, unknown> {\n if (!input) {\n return {};\n }\n return JSON.parse(input) as Record<string, unknown>;\n}\n\nasync function resolveFlowIdentifiers(\n client: ReturnType<typeof createApiClient>,\n options: { flowId?: string; flowType?: string; flowKey?: string },\n): Promise<{ flow_type: string; flow_key: string }> {\n if (options.flowType && options.flowKey !== undefined) {\n return {\n flow_type: options.flowType,\n flow_key: options.flowKey,\n };\n }\n\n if (!options.flowId) {\n throw new Error('Either --flow-id or both --flow-type and --flow-key are required.');\n }\n\n const flows = await apiRequest<Array<Record<string, unknown>>>(\n client,\n 'POST',\n '/flow/batch_get',\n {\n data: { ids: [Number(options.flowId)] },\n },\n );\n const flow = flows[0];\n if (!flow) {\n throw new Error(`Flow ${options.flowId} not found.`);\n }\n return {\n flow_type: String(flow.flow_type || 'default'),\n flow_key: String(flow.key || ''),\n };\n}\n\nexport function registerProjectCommands(program: Command): void {\n const project = program.command('project').description('Project commands');\n\n project\n .command('list')\n .description('List projects')\n .option('--profile <profile>', 'Profile name')\n .option('--page <page>', 'Page number', '1')\n .option('--page-size <pageSize>', 'Page size', '20')\n .option('--body <json>', 'Project list body JSON', '{}')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: {\n profile?: string;\n page: string;\n pageSize: string;\n body: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'POST',\n '/project/list',\n {\n params: {\n page: Number(options.page),\n page_size: Number(options.pageSize),\n },\n data: parseJson(options.body),\n },\n );\n printResult(options.format, result);\n });\n\n project\n .command('get <id>')\n .description('Get project detail')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (id: string, options: { profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n `/project/${id}`,\n );\n printResult(options.format, result);\n });\n\n project\n .command('my-step')\n .description('List my pending project steps')\n .option('--profile <profile>', 'Profile name')\n .option('--finished <finished>', 'Finished flag', '0')\n .option('--page <page>', 'Page number', '1')\n .option('--page-size <pageSize>', 'Page size', '20')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: {\n profile?: string;\n finished: string;\n page: string;\n pageSize: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n '/project/my_step',\n {\n params: {\n finished: options.finished,\n page: Number(options.page),\n page_size: Number(options.pageSize),\n },\n },\n );\n printResult(options.format, result);\n });\n\n project\n .command('create')\n .description('Minimal project create shortcut')\n .option('--profile <profile>', 'Profile name')\n .option('--flow-id <flowId>', 'Flow id')\n .option('--flow-type <flowType>', 'Flow type')\n .option('--flow-key <flowKey>', 'Flow key')\n .option('--name <name>', 'Project name')\n .option('--json <json>', 'Additional request JSON')\n .option('--body <body>', 'Full request body JSON override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: {\n profile?: string;\n flowId?: string;\n flowType?: string;\n flowKey?: string;\n name?: string;\n json?: string;\n body?: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const client = createApiClient(profile);\n\n let payload = parseJson(options.body);\n if (!options.body) {\n if (!options.name) {\n throw new Error('--name is required unless --body is provided.');\n }\n const flow = await resolveFlowIdentifiers(client, options);\n const extra = parseJson(options.json);\n const form =\n typeof extra.form === 'object' && extra.form !== null && !Array.isArray(extra.form)\n ? (extra.form as Record<string, unknown>)\n : {};\n payload = {\n ...extra,\n ...flow,\n name: options.name,\n workspace: profile.config.workspace,\n form,\n };\n }\n\n const result = await apiRequest<Record<string, unknown>>(\n client,\n 'POST',\n '/project/open-api/create',\n {\n data: payload,\n },\n );\n printResult(options.format, result);\n });\n}\n","import type { SchemaEntry } from './types.js';\n\nexport const schemaEntries: SchemaEntry[] = [\n { name: 'auth.login', description: 'Open hpt-frontend bridge page and persist API key locally.' },\n { name: 'auth.status', description: 'Show current profile status and validate /api/user/current.' },\n { name: 'auth.logout', description: 'Clear the saved API key for the selected profile.' },\n { name: 'user.current', description: 'Get current user.', method: 'GET', path: '/api/user/current' },\n { name: 'flow.list', description: 'List flows.', method: 'GET', path: '/api/flow/flow_type' },\n { name: 'flow.options', description: 'List flow options.', method: 'GET', path: '/api/flow/options' },\n { name: 'flow.get', description: 'Fetch flow details by id.', method: 'POST', path: '/api/flow/batch_get' },\n { name: 'project.list', description: 'List projects.', method: 'POST', path: '/api/project/list' },\n { name: 'project.get', description: 'Get project detail.', method: 'GET', path: '/api/project/:id' },\n { name: 'project.my-step', description: 'List my pending steps.', method: 'GET', path: '/api/project/my_step' },\n { name: 'project.create', description: 'Minimal project create shortcut.', method: 'POST', path: '/api/project/open-api/create' },\n];\n","import type { Command } from 'commander';\n\nimport { printResult } from '../core/output.js';\nimport { schemaEntries } from '../core/manifest.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerSchemaCommands(program: Command): void {\n const schema = program.command('schema').description('Inspect built-in bpmax-cli schema metadata');\n\n schema\n .command('list')\n .description('List known command and endpoint mappings')\n .option('--format <format>', 'Output format', 'table')\n .action((options: { format: OutputFormat }) => {\n printResult(options.format, schemaEntries);\n });\n\n schema\n .command('show <name>')\n .description('Show a single schema entry')\n .option('--format <format>', 'Output format', 'pretty')\n .action((name: string, options: { format: OutputFormat }) => {\n const entry = schemaEntries.find((item) => item.name === name);\n if (!entry) {\n throw new Error(`Schema entry \"${name}\" not found.`);\n }\n printResult(options.format, entry);\n });\n}\n","import { confirm, text } from '@clack/prompts';\nimport type { Command } from 'commander';\n\nimport { runBrowserLogin, updateProfileAuth, type LoginResult } from '../core/auth.js';\nimport {\n DEFAULT_LANGUAGE,\n DEFAULT_WORKSPACE,\n loadConfig as loadConfigDefault,\n saveConfig as saveConfigDefault,\n} from '../core/config.js';\nimport { printResult } from '../core/output.js';\nimport {\n applySetupProfile,\n configuredProfiles,\n defaultSetupProfileName,\n parseBpmUrl,\n setupSummary,\n} from '../core/setup.js';\nimport type { ConfigFileV2, OutputFormat } from '../core/types.js';\n\ninterface SetupDeps {\n loadConfig?: () => Promise<ConfigFileV2>;\n saveConfig?: (config: ConfigFileV2) => Promise<void>;\n login?: (options: {\n origin: string;\n workspace: string;\n profileName: string;\n apiKeyName: string;\n }) => Promise<LoginResult>;\n}\n\ninterface SetupOptions {\n name?: string;\n origin?: string;\n url?: string;\n workspace?: string;\n language?: string;\n keyName: string;\n skipLogin?: boolean;\n force?: boolean;\n format: OutputFormat;\n}\n\nasync function promptText(current: string | undefined, message: string, placeholder: string): Promise<string> {\n if (current?.trim()) {\n return current.trim();\n }\n const value = await text({ message, placeholder });\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`${message} is required.`);\n }\n return value.trim();\n}\n\nasync function promptConfirm(message: string): Promise<boolean> {\n const value = await confirm({ message, initialValue: true });\n return value === true;\n}\n\nexport function registerSetupCommand(program: Command, deps: SetupDeps = {}): void {\n const loadConfig = deps.loadConfig || loadConfigDefault;\n const saveConfig = deps.saveConfig || saveConfigDefault;\n const login = deps.login || runBrowserLogin;\n\n program\n .command('setup')\n .description('Configure a BPMAX environment profile and optionally authorize it')\n .argument('[url]', 'Full BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr')\n .option('--name <name>', 'Profile name')\n .option('--url <url>', 'Full BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr')\n .option('--origin <origin>', 'BPMAX environment root URL, for example http://127.0.0.1:10018')\n .option('--workspace <workspace>', 'Default workspace', DEFAULT_WORKSPACE)\n .option('--language <language>', 'Default language', DEFAULT_LANGUAGE)\n .option('--key-name <keyName>', 'Target API key name', 'bpmax-cli')\n .option('--skip-login', 'Only save the profile, do not open browser authorization')\n .option('--force', 'Configure a new profile even when configured profiles already exist')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (setupUrl: string | undefined, options: SetupOptions, command: Command) => {\n if (setupUrl && options.url) {\n throw new Error('Pass the BPMAX URL either as an argument or with --url, not both.');\n }\n\n const urlInput = setupUrl || options.url;\n const parsedUrl = urlInput ? parseBpmUrl(urlInput) : undefined;\n const workspaceWasProvided = command.getOptionValueSource('workspace') === 'cli';\n const config = await loadConfig();\n const existing = configuredProfiles(config);\n\n if (existing.length > 0 && !options.force && !urlInput && !options.origin && !options.name) {\n printResult(options.format, {\n configured: true,\n profiles: existing,\n next: 'Run `bpmax-cli setup --force` to add another profile, or `bpmax-cli auth login --profile <name>` to re-authorize.',\n });\n return;\n }\n\n const defaultName = defaultSetupProfileName(config);\n const name = urlInput && !options.name ? defaultName : await promptText(options.name, 'Profile name', defaultName);\n const origin = await promptText(\n options.origin || parsedUrl?.origin,\n 'BPMAX environment URL',\n 'http://127.0.0.1:10018',\n );\n const workspace = await promptText(\n workspaceWasProvided ? options.workspace : parsedUrl?.workspace || options.workspace,\n 'Default workspace',\n DEFAULT_WORKSPACE,\n );\n const language = options.language || DEFAULT_LANGUAGE;\n\n let nextConfig = applySetupProfile(config, name, {\n origin,\n workspace,\n language,\n });\n await saveConfig(nextConfig);\n\n const shouldLogin = options.skipLogin\n ? false\n : options.origin || urlInput\n ? true\n : await promptConfirm('Open browser to authorize this profile now?');\n if (!shouldLogin) {\n printResult(options.format, setupSummary({ profile: name, origin, workspace, login: 'skipped' }));\n return;\n }\n\n const result = await login({\n origin,\n workspace,\n profileName: name,\n apiKeyName: options.keyName,\n });\n nextConfig = applySetupProfile(nextConfig, name, updateProfileAuth(nextConfig.profiles[name], result));\n await saveConfig(nextConfig);\n\n printResult(\n options.format,\n setupSummary({\n profile: name,\n origin,\n workspace,\n login: 'authenticated',\n user: result.user,\n }),\n );\n });\n}\n","import { DEFAULT_LANGUAGE, DEFAULT_WORKSPACE } from './config.js';\nimport type { ConfigFileV2, ProfileConfig, UserSummary } from './types.js';\n\nexport interface ConfiguredProfile {\n name: string;\n current: boolean;\n origin: string;\n workspace: string;\n language: string;\n authenticated: boolean;\n}\n\nexport interface SetupSummaryInput {\n profile: string;\n origin: string;\n workspace: string;\n login: 'skipped' | 'authenticated';\n user?: UserSummary;\n}\n\nexport interface ParsedBpmUrl {\n origin: string;\n workspace: string;\n}\n\nexport function parseBpmUrl(input: string): ParsedBpmUrl {\n const trimmed = input.trim();\n if (!trimmed) {\n throw new Error('BPMAX URL is required.');\n }\n\n let url: URL;\n try {\n url = new URL(trimmed);\n } catch {\n throw new Error(`Invalid BPMAX URL: ${input}`);\n }\n\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error(`BPMAX URL must start with http:// or https://: ${input}`);\n }\n\n const workspace = url.pathname\n .split('/')\n .filter(Boolean)\n .map((segment) => decodeURIComponent(segment))[0];\n if (!workspace) {\n throw new Error(`BPMAX URL must include a workspace path, for example ${url.origin}/w:store_mgr`);\n }\n\n return {\n origin: url.origin,\n workspace,\n };\n}\n\nexport function configuredProfiles(config: ConfigFileV2): ConfiguredProfile[] {\n return Object.entries(config.profiles)\n .filter(([, profile]) => Boolean(profile.origin?.trim()))\n .map(([name, profile]) => ({\n name,\n current: config.current_profile === name,\n origin: profile.origin,\n workspace: profile.workspace || DEFAULT_WORKSPACE,\n language: profile.language || DEFAULT_LANGUAGE,\n authenticated: Boolean(profile.api_key),\n }));\n}\n\nexport function defaultSetupProfileName(config: ConfigFileV2): string {\n if (configuredProfiles(config).length > 0) {\n let index = 2;\n while (config.profiles[`local-${index}`]) {\n index += 1;\n }\n return `local-${index}`;\n }\n const defaultProfile = config.profiles.default;\n if (!defaultProfile || !defaultProfile.origin?.trim()) {\n return 'default';\n }\n let index = 2;\n while (config.profiles[`local-${index}`]) {\n index += 1;\n }\n return `local-${index}`;\n}\n\nexport function applySetupProfile(\n config: ConfigFileV2,\n name: string,\n profile: ProfileConfig,\n): ConfigFileV2 {\n return {\n ...config,\n current_profile: name,\n profiles: {\n ...config.profiles,\n [name]: {\n ...config.profiles[name],\n ...profile,\n },\n },\n };\n}\n\nexport function setupSummary(input: SetupSummaryInput): Record<string, unknown> {\n return {\n profile: input.profile,\n origin: input.origin,\n workspace: input.workspace,\n login: input.login,\n ...(input.user ? { user: input.user } : {}),\n ...(input.login === 'skipped'\n ? { next: `Run \\`bpmax-cli auth login --profile ${input.profile}\\` to authorize this profile.` }\n : {}),\n };\n}\n","{\n \"name\": \"bpmax-cli\",\n \"version\": \"0.1.4\",\n \"description\": \"CLI for BPMAX environments with multi-profile config and local login callback flow\",\n \"type\": \"module\",\n \"bin\": {\n \"bpmax-cli\": \"dist/bin.js\"\n },\n \"files\": [\n \"dist\",\n \"scripts/install-skills.mjs\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"postinstall\": \"node scripts/install-skills.mjs\",\n \"build\": \"tsup\",\n \"dev\": \"tsx src/bin.ts\",\n \"install:skills\": \"node scripts/install-skills.mjs\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@clack/prompts\": \"^1.2.0\",\n \"axios\": \"^1.9.0\",\n \"commander\": \"^14.0.0\",\n \"open\": \"^10.1.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.15.17\",\n \"tsup\": \"^8.5.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.1.3\"\n }\n}\n","import packageJson from '../../package.json' with { type: 'json' };\n\nexport const CLI_NAME = 'bpmax-cli';\nexport const VERSION = packageJson.version;\nexport const NPM_PACKAGE = 'bpmax-cli';\n","import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { getConfigDir } from './config.js';\nimport { runCommand, type CommandRunner, type RunResult } from './process.js';\n\nconst SKILLS_STAMP_FILE = 'skills.stamp';\nconst SKILLS_INSTALL_TIMEOUT_MS = 2 * 60 * 1000;\n\nexport interface SkillsStatus {\n current: string;\n target: string;\n inSync: boolean;\n}\n\nfunction stampPath(configDir = getConfigDir()): string {\n return path.join(configDir, SKILLS_STAMP_FILE);\n}\n\nexport async function readSkillsStamp(configDir = getConfigDir()): Promise<string> {\n try {\n return (await readFile(stampPath(configDir), 'utf8')).trim();\n } catch {\n return '';\n }\n}\n\nexport async function writeSkillsStamp(version: string, configDir = getConfigDir()): Promise<void> {\n await mkdir(configDir, { recursive: true });\n await writeFile(stampPath(configDir), version, 'utf8');\n}\n\nexport async function checkSkillsSync(currentVersion: string, configDir = getConfigDir()): Promise<SkillsStatus> {\n if (process.env.BPMAX_CLI_NO_SKILLS_NOTIFIER) {\n return { current: currentVersion, target: currentVersion, inSync: true };\n }\n const current = await readSkillsStamp(configDir);\n return { current, target: currentVersion, inSync: current === currentVersion };\n}\n\nfunction defaultPackageRoot(): string {\n return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');\n}\n\nexport async function runSkillsInstall(\n options: { packageRoot?: string; runner?: CommandRunner } = {},\n): Promise<RunResult> {\n const runner = options.runner || runCommand;\n return runner(process.execPath, [path.join(options.packageRoot || defaultPackageRoot(), 'scripts', 'install-skills.mjs')], {\n timeoutMs: SKILLS_INSTALL_TIMEOUT_MS,\n });\n}\n\nexport async function syncSkills(\n version: string,\n options: { force?: boolean; configDir?: string; packageRoot?: string; runner?: CommandRunner } = {},\n): Promise<{ action: 'in_sync' | 'synced' | 'failed'; result?: RunResult }> {\n if (!options.force) {\n const status = await checkSkillsSync(version, options.configDir);\n if (status.inSync) {\n return { action: 'in_sync' };\n }\n }\n const result = await runSkillsInstall({ packageRoot: options.packageRoot, runner: options.runner });\n if (result.exitCode === 0) {\n await writeSkillsStamp(version, options.configDir);\n return { action: 'synced', result };\n }\n return { action: 'failed', result };\n}\n","import { spawn } from 'node:child_process';\n\nexport interface RunResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport interface RunOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n timeoutMs?: number;\n}\n\nexport type CommandRunner = (command: string, args: string[], options?: RunOptions) => Promise<RunResult>;\n\nexport const runCommand: CommandRunner = (command, args, options = {}) =>\n new Promise((resolve) => {\n const child = spawn(command, args, {\n cwd: options.cwd,\n env: options.env,\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n let stdout = '';\n let stderr = '';\n let settled = false;\n const timer =\n options.timeoutMs && options.timeoutMs > 0\n ? setTimeout(() => {\n if (settled) {\n return;\n }\n settled = true;\n child.kill('SIGTERM');\n resolve({\n stdout,\n stderr: `${stderr}${stderr ? '\\n' : ''}Timed out after ${options.timeoutMs}ms`,\n exitCode: 124,\n });\n }, options.timeoutMs)\n : undefined;\n\n child.stdout?.on('data', (chunk) => {\n stdout += String(chunk);\n });\n child.stderr?.on('data', (chunk) => {\n stderr += String(chunk);\n });\n child.on('error', (error) => {\n if (settled) {\n return;\n }\n settled = true;\n if (timer) {\n clearTimeout(timer);\n }\n resolve({ stdout, stderr: `${stderr}${stderr ? '\\n' : ''}${error.message}`, exitCode: 1 });\n });\n child.on('close', (code) => {\n if (settled) {\n return;\n }\n settled = true;\n if (timer) {\n clearTimeout(timer);\n }\n resolve({ stdout, stderr, exitCode: code ?? 1 });\n });\n });\n","import { access, mkdir, readFile, realpath, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { NPM_PACKAGE } from './build.js';\nimport { getConfigDir } from './config.js';\nimport { runCommand, type CommandRunner, type RunResult } from './process.js';\n\nconst DEFAULT_REGISTRY_URL = 'https://registry.npmjs.org/';\nconst UPDATE_STATE_FILE = 'update-state.json';\nconst CACHE_TTL_MS = 24 * 60 * 60 * 1000;\nconst FETCH_TIMEOUT_MS = 5_000;\nconst NPM_INSTALL_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport interface UpdateInfo {\n current: string;\n latest: string;\n}\n\ninterface UpdateState {\n latest_version: string;\n checked_at: number;\n}\n\ninterface FetchLatestOptions {\n packageName?: string;\n env?: NodeJS.ProcessEnv;\n fetchImpl?: typeof fetch;\n}\n\nexport interface DetectInstallInput {\n executablePath?: string;\n npmPath?: string | null;\n}\n\nexport interface InstallDetection {\n method: 'npm' | 'manual';\n resolvedPath: string;\n npmAvailable: boolean;\n}\n\nexport function buildRegistryUrl(packageName = NPM_PACKAGE, env: NodeJS.ProcessEnv = process.env): string {\n const base = env.BPMAX_CLI_REGISTRY_URL || DEFAULT_REGISTRY_URL;\n const normalizedBase = base.endsWith('/') ? base : `${base}/`;\n return new URL(`${encodeURIComponent(packageName).replace('%40', '@')}/latest`, normalizedBase).toString();\n}\n\ninterface ParsedVersion {\n core: [number, number, number];\n prerelease: string[];\n}\n\nfunction parseVersion(version: string): ParsedVersion | null {\n const clean = version.trim().replace(/^v/, '').split('+')[0];\n const [coreText, prereleaseText = ''] = clean.split('-', 2);\n const coreParts = coreText.split('.');\n if (coreParts.length !== 3) {\n return null;\n }\n const core = coreParts.map((part) => {\n if (!/^(0|[1-9]\\d*)$/.test(part)) {\n return Number.NaN;\n }\n return Number(part);\n }) as [number, number, number];\n if (core.some((part) => Number.isNaN(part))) {\n return null;\n }\n if (prereleaseText && !/^(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*$/.test(prereleaseText)) {\n return null;\n }\n return { core, prerelease: prereleaseText ? prereleaseText.split('.') : [] };\n}\n\nfunction comparePrerelease(left: string[], right: string[]): number {\n if (left.length === 0 && right.length === 0) {\n return 0;\n }\n if (left.length === 0) {\n return 1;\n }\n if (right.length === 0) {\n return -1;\n }\n const max = Math.max(left.length, right.length);\n for (let index = 0; index < max; index += 1) {\n const a = left[index];\n const b = right[index];\n if (a === undefined) {\n return -1;\n }\n if (b === undefined) {\n return 1;\n }\n const aNumber = /^(0|[1-9]\\d*)$/.test(a) ? Number(a) : null;\n const bNumber = /^(0|[1-9]\\d*)$/.test(b) ? Number(b) : null;\n if (aNumber !== null && bNumber !== null) {\n if (aNumber !== bNumber) {\n return aNumber > bNumber ? 1 : -1;\n }\n continue;\n }\n if (aNumber !== null) {\n return -1;\n }\n if (bNumber !== null) {\n return 1;\n }\n if (a !== b) {\n return a > b ? 1 : -1;\n }\n }\n return 0;\n}\n\nexport function isNewerVersion(candidate: string, current: string): boolean {\n const next = parseVersion(candidate);\n if (!next) {\n return false;\n }\n const existing = parseVersion(current);\n if (!existing) {\n return true;\n }\n for (let index = 0; index < 3; index += 1) {\n if (next.core[index] > existing.core[index]) {\n return true;\n }\n if (next.core[index] < existing.core[index]) {\n return false;\n }\n }\n return comparePrerelease(next.prerelease, existing.prerelease) > 0;\n}\n\nexport async function fetchLatestVersion(options: FetchLatestOptions = {}): Promise<string> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n try {\n const fetchImpl = options.fetchImpl || fetch;\n const response = await fetchImpl(buildRegistryUrl(options.packageName, options.env), {\n signal: controller.signal,\n });\n if (!response.ok) {\n throw new Error(`npm registry returned HTTP ${response.status}`);\n }\n const body = (await response.json()) as { version?: unknown };\n if (typeof body.version !== 'string' || !body.version.trim()) {\n throw new Error('npm registry returned an empty version');\n }\n return body.version.trim();\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction updateStatePath(configDir = getConfigDir()): string {\n return path.join(configDir, UPDATE_STATE_FILE);\n}\n\nasync function readUpdateState(configDir?: string): Promise<UpdateState | null> {\n try {\n const raw = await readFile(updateStatePath(configDir), 'utf8');\n const parsed = JSON.parse(raw) as Partial<UpdateState>;\n if (typeof parsed.latest_version !== 'string' || typeof parsed.checked_at !== 'number') {\n return null;\n }\n return { latest_version: parsed.latest_version, checked_at: parsed.checked_at };\n } catch {\n return null;\n }\n}\n\nasync function writeUpdateState(state: UpdateState, configDir = getConfigDir()): Promise<void> {\n await mkdir(configDir, { recursive: true });\n await writeFile(updateStatePath(configDir), JSON.stringify(state), 'utf8');\n}\n\nexport async function checkCachedUpdate(currentVersion: string, configDir = getConfigDir()): Promise<UpdateInfo | null> {\n if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {\n return null;\n }\n const state = await readUpdateState(configDir);\n if (!state) {\n return null;\n }\n const checkedAtMs = state.checked_at * 1000;\n if (Date.now() - checkedAtMs > CACHE_TTL_MS) {\n return null;\n }\n if (!isNewerVersion(state.latest_version, currentVersion)) {\n return null;\n }\n return { current: currentVersion, latest: state.latest_version };\n}\n\nexport async function refreshUpdateCache(\n currentVersion: string,\n configDir = getConfigDir(),\n options: FetchLatestOptions = {},\n): Promise<UpdateInfo | null> {\n if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {\n return null;\n }\n const state = await readUpdateState(configDir);\n if (state && Date.now() - state.checked_at * 1000 < CACHE_TTL_MS) {\n return isNewerVersion(state.latest_version, currentVersion)\n ? { current: currentVersion, latest: state.latest_version }\n : null;\n }\n const latest = await fetchLatestVersion(options);\n await writeUpdateState({ latest_version: latest, checked_at: Math.floor(Date.now() / 1000) }, configDir);\n return isNewerVersion(latest, currentVersion) ? { current: currentVersion, latest } : null;\n}\n\nasync function executablePath(): Promise<string> {\n const candidate = process.argv[1] || '';\n if (!candidate) {\n return '';\n }\n try {\n return await realpath(candidate);\n } catch {\n return candidate;\n }\n}\n\nasync function findNpmPath(): Promise<string | null> {\n const command = process.platform === 'win32' ? 'where' : 'which';\n const result = await runCommand(command, ['npm'], { timeoutMs: 10_000 });\n if (result.exitCode !== 0) {\n return null;\n }\n return result.stdout.split(/\\r?\\n/).find(Boolean)?.trim() || null;\n}\n\nexport function detectInstallMethod(input: DetectInstallInput): InstallDetection {\n const resolvedPath = input.executablePath || '';\n const method = resolvedPath.includes(`node_modules${path.sep}`) || resolvedPath.includes('node_modules/')\n ? 'npm'\n : 'manual';\n return {\n method,\n resolvedPath,\n npmAvailable: method === 'npm' && Boolean(input.npmPath),\n };\n}\n\nexport async function detectCurrentInstallMethod(): Promise<InstallDetection> {\n return detectInstallMethod({\n executablePath: await executablePath(),\n npmPath: await findNpmPath(),\n });\n}\n\nexport async function runNpmInstall(\n version: string,\n options: { packageName?: string; runner?: CommandRunner } = {},\n): Promise<RunResult> {\n const runner = options.runner || runCommand;\n return runner('npm', ['install', '-g', `${options.packageName || NPM_PACKAGE}@${version}`], {\n timeoutMs: NPM_INSTALL_TIMEOUT_MS,\n });\n}\n\nexport async function canAccess(targetPath: string): Promise<boolean> {\n try {\n await access(targetPath);\n return true;\n } catch {\n return false;\n }\n}\n","import type { Command } from 'commander';\n\nimport { NPM_PACKAGE, VERSION } from '../core/build.js';\nimport { checkSkillsSync, syncSkills as syncSkillsDefault, type SkillsStatus } from '../core/skills.js';\nimport {\n detectCurrentInstallMethod,\n fetchLatestVersion,\n isNewerVersion,\n runNpmInstall,\n type InstallDetection,\n} from '../core/update.js';\n\nconst MAX_DETAIL = 2_000;\n\ninterface UpdateCommandDeps {\n fetchLatest?: () => Promise<string>;\n detectInstall?: () => Promise<InstallDetection>;\n install?: (version: string) => Promise<{ stdout: string; stderr: string; exitCode: number }>;\n syncSkills?: (version: string, options: { force: boolean }) => Promise<{ action: 'in_sync' | 'synced' | 'failed'; result?: { stderr: string } }>;\n getSkillsStatus?: () => Promise<SkillsStatus>;\n}\n\ninterface UpdateOptions {\n json?: boolean;\n check?: boolean;\n force?: boolean;\n}\n\nfunction printJson(value: unknown): void {\n console.log(JSON.stringify(value, null, 2));\n}\n\nfunction truncate(value: string): string {\n if (value.length <= MAX_DETAIL) {\n return value;\n }\n return value.slice(value.length - MAX_DETAIL);\n}\n\nfunction manualReason(detect: InstallDetection): string {\n if (detect.method === 'npm' && !detect.npmAvailable) {\n return 'installed via npm, but npm is not available in PATH';\n }\n return 'not installed via npm';\n}\n\nfunction skillsAction(result: Awaited<ReturnType<NonNullable<UpdateCommandDeps['syncSkills']>>>): Record<string, unknown> {\n if (result.action !== 'failed') {\n return { skills_action: result.action };\n }\n return {\n skills_action: 'failed',\n skills_warning: 'skills update failed',\n ...(result.result?.stderr ? { skills_detail: truncate(result.result.stderr.trim()) } : {}),\n };\n}\n\nexport function registerUpdateCommands(program: Command, deps: UpdateCommandDeps = {}): void {\n const fetchLatest = deps.fetchLatest || (() => fetchLatestVersion({ packageName: NPM_PACKAGE }));\n const detectInstall = deps.detectInstall || detectCurrentInstallMethod;\n const install = deps.install || ((version: string) => runNpmInstall(version, { packageName: NPM_PACKAGE }));\n const runSkills = deps.syncSkills || ((version: string, options: { force: boolean }) => syncSkillsDefault(version, options));\n const getSkillsStatus = deps.getSkillsStatus || (() => checkSkillsSync(VERSION));\n\n program\n .command('update')\n .description('Update bpmax-cli to the latest version')\n .option('--check', 'only check for updates, do not install')\n .option('--force', 'force reinstall even if already up to date')\n .option('--json', 'structured JSON output')\n .action(async (options: UpdateOptions) => {\n let latest: string;\n try {\n latest = await fetchLatest();\n } catch (error) {\n const message = `failed to check latest version: ${error instanceof Error ? error.message : String(error)}`;\n if (options.json) {\n printJson({ ok: false, error: { type: 'network', message } });\n process.exitCode = 1;\n return;\n }\n throw new Error(message);\n }\n\n const detect = await detectInstall();\n const updateAvailable = isNewerVersion(latest, VERSION);\n\n if (options.check) {\n const status = await getSkillsStatus();\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: VERSION,\n latest_version: latest,\n action: updateAvailable ? 'update_available' : 'already_up_to_date',\n auto_update: detect.method === 'npm' && detect.npmAvailable,\n skills_status: {\n current: status.current,\n target: status.target,\n in_sync: status.inSync,\n },\n };\n if (options.json) {\n printJson(body);\n } else if (updateAvailable) {\n console.error(`Update available: ${VERSION} -> ${latest}`);\n console.error(`Run: bpmax-cli update`);\n } else {\n console.error(`bpmax-cli ${VERSION} is already up to date`);\n }\n return;\n }\n\n if (!options.force && !updateAvailable) {\n const synced = await runSkills(VERSION, { force: false });\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: VERSION,\n latest_version: latest,\n action: 'already_up_to_date',\n ...skillsAction(synced),\n };\n if (options.json) {\n printJson(body);\n } else {\n console.error(`bpmax-cli ${VERSION} is already up to date`);\n if (synced.action === 'failed') {\n console.error('Skills update failed. Run manually: npm run install:skills');\n } else if (synced.action === 'synced') {\n console.error('Skills updated');\n }\n }\n return;\n }\n\n if (detect.method !== 'npm' || !detect.npmAvailable) {\n const synced = await runSkills(VERSION, { force: Boolean(options.force) });\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: VERSION,\n latest_version: latest,\n action: 'manual_required',\n message: `Automatic update unavailable: ${manualReason(detect)} (path: ${detect.resolvedPath})`,\n manual_command: `npm install -g ${NPM_PACKAGE}@${latest}`,\n ...skillsAction(synced),\n };\n if (options.json) {\n printJson(body);\n } else {\n console.error(body.message);\n console.error(`Run manually: ${body.manual_command}`);\n }\n return;\n }\n\n if (!options.json) {\n console.error(`Updating bpmax-cli ${VERSION} -> ${latest} via npm ...`);\n }\n const installResult = await install(latest);\n if (installResult.exitCode !== 0) {\n const detail = truncate(`${installResult.stdout}${installResult.stderr}`.trim());\n if (options.json) {\n printJson({\n ok: false,\n error: {\n type: 'update_error',\n message: `npm install failed with exit code ${installResult.exitCode}`,\n detail,\n },\n });\n process.exitCode = 1;\n return;\n }\n throw new Error(`npm install failed with exit code ${installResult.exitCode}${detail ? `\\n${detail}` : ''}`);\n }\n\n const synced = await runSkills(latest, { force: Boolean(options.force) });\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: latest,\n latest_version: latest,\n action: 'updated',\n ...skillsAction(synced),\n };\n if (options.json) {\n printJson(body);\n } else {\n console.error(`Successfully updated bpmax-cli from ${VERSION} to ${latest}`);\n if (synced.action === 'failed') {\n console.error('Skills update failed. Run manually: npm run install:skills');\n } else if (synced.action === 'synced') {\n console.error('Skills updated');\n }\n }\n });\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerUserCommands(program: Command): void {\n const user = program.command('user').description('User commands');\n\n user\n .command('current')\n .description('Get current user')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n '/user/current',\n );\n printResult(options.format, result);\n });\n}\n","import { VERSION } from './build.js';\nimport { checkSkillsSync } from './skills.js';\nimport { setNoticeProvider } from './output.js';\nimport { checkCachedUpdate, refreshUpdateCache, type UpdateInfo } from './update.js';\n\ninterface SkillsNotice {\n current: string;\n target: string;\n}\n\nlet pendingUpdate: UpdateInfo | null = null;\nlet pendingSkills: SkillsNotice | null = null;\n\nfunction updateMessage(info: UpdateInfo): string {\n return `bpmax-cli ${info.latest} available, current ${info.current}, run: bpmax-cli update`;\n}\n\nfunction skillsMessage(info: SkillsNotice): string {\n if (!info.current) {\n return 'bpmax-cli skills not installed, run: bpmax-cli update';\n }\n return `bpmax-cli skills ${info.current} out of sync with binary ${info.target}, run: bpmax-cli update`;\n}\n\nexport async function setupNotices(): Promise<void> {\n pendingUpdate = await checkCachedUpdate(VERSION);\n const skills = await checkSkillsSync(VERSION);\n pendingSkills = skills.inSync ? null : { current: skills.current, target: skills.target };\n\n setNoticeProvider(() => {\n const notice: Record<string, Record<string, unknown>> = {};\n if (pendingUpdate) {\n notice.update = {\n current: pendingUpdate.current,\n latest: pendingUpdate.latest,\n message: updateMessage(pendingUpdate),\n };\n }\n if (pendingSkills) {\n notice.skills = {\n current: pendingSkills.current,\n target: pendingSkills.target,\n message: skillsMessage(pendingSkills),\n };\n }\n return Object.keys(notice).length > 0 ? notice : null;\n });\n\n void refreshUpdateCache(VERSION)\n .then((info) => {\n if (info) {\n pendingUpdate = info;\n }\n })\n .catch(() => {\n // Update notices are best-effort and must never block CLI commands.\n });\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,OAAO,UAAU,iBAAiB;AAC3C,OAAO,UAAU;;;ACFV,IAAM,mBACX;AAEK,IAAM,qBACX;;;ADSK,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AAEhC,IAAM,aAAa,KAAK,KAAK,QAAQ,GAAG,QAAQ;AAChD,IAAM,cAAc,KAAK,KAAK,YAAY,aAAa;AAEvD,IAAM,gBAAgB,OAAqB;AAAA,EACzC,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,UAAU;AAAA,IACR,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,U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AAI,eAAe;AACjB,aAAO,SAAS;AAAA,QACd,SAAS,cAAc;AAAA,QACvB,QAAQ,cAAc;AAAA,QACtB,SAAS,cAAc,aAAa;AAAA,MACtC;AAAA,IACF;AACA,QAAI,eAAe;AACjB,aAAO,SAAS;AAAA,QACd,SAAS,cAAc;AAAA,QACvB,QAAQ,cAAc;AAAA,QACtB,SAAS,cAAc,aAAa;AAAA,MACtC;AAAA,IACF;AACA,WAAO,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AAAA,EACnD,CAAC;AAED,OAAK,mBAAmB,OAAO,EAC5B,KAAK,CAAC,SAAS;AACd,QAAI,MAAM;AACR,sBAAgB;AAAA,IAClB;AAAA,EACF,CAAC,EACA,MAAM,MAAM;AAAA,EAEb,CAAC;AACL;;;AtB3CA,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,QAAQ,EACb,YAAY,6BAA6B,EACzC,QAAQ,OAAO;AAElB,uBAAuB,OAAO;AAC9B,qBAAqB,OAAO;AAC5B,oBAAoB,OAAO;AAC3B,uBAAuB,OAAO;AAC9B,qBAAqB,OAAO;AAC5B,qBAAqB,OAAO;AAC5B,wBAAwB,OAAO;AAC/B,qBAAqB,OAAO;AAC5B,uBAAuB,OAAO;AAE9B,IAAM,eAAe,QAAQ,KAAK,SAAS,YAAY,KAAK,QAAQ,KAAK,SAAS,YAAY;AAAA,CAE7F,eAAe,QAAQ,QAAQ,IAAI,aAAa,GAC9C,KAAK,MAAM,QAAQ,WAAW,QAAQ,IAAI,CAAC,EAC3C,MAAM,CAAC,UAAU;AAClB,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AACpE,UAAQ,WAAW;AACnB,CAAC;","names":["path","program","path","program","program","program","parseJson","program","program","text","index","text","program","loadConfig","saveConfig","mkdir","readFile","writeFile","path","path","readFile","mkdir","writeFile","mkdir","readFile","writeFile","path","path","readFile","mkdir","writeFile","program","body","synced","program"]}
1
+ {"version":3,"sources":["../src/bin.ts","../src/core/config.ts","../src/core/setup-guide.ts","../src/core/http.ts","../src/core/output.ts","../src/commands/api.ts","../src/core/auth.ts","../src/commands/auth.ts","../src/commands/config.ts","../src/commands/flow.ts","../src/commands/project.ts","../src/core/manifest.ts","../src/commands/schema.ts","../src/commands/setup.ts","../src/core/setup.ts","../package.json","../src/core/build.ts","../src/core/skills.ts","../src/core/process.ts","../src/core/update.ts","../src/commands/update.ts","../src/commands/user.ts","../src/core/notices.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport { registerApiCommands } from './commands/api.js';\nimport { registerAuthCommands } from './commands/auth.js';\nimport { registerConfigCommands } from './commands/config.js';\nimport { registerFlowCommands } from './commands/flow.js';\nimport { registerProjectCommands } from './commands/project.js';\nimport { registerSchemaCommands } from './commands/schema.js';\nimport { registerSetupCommand } from './commands/setup.js';\nimport { registerUpdateCommands } from './commands/update.js';\nimport { registerUserCommands } from './commands/user.js';\nimport { CLI_NAME, VERSION } from './core/build.js';\nimport { setupNotices } from './core/notices.js';\n\nconst program = new Command();\n\nprogram\n .name(CLI_NAME)\n .description('BPMAX multi-environment CLI')\n .version(VERSION);\n\nregisterConfigCommands(program);\nregisterAuthCommands(program);\nregisterApiCommands(program);\nregisterSchemaCommands(program);\nregisterUserCommands(program);\nregisterFlowCommands(program);\nregisterProjectCommands(program);\nregisterSetupCommand(program);\nregisterUpdateCommands(program);\n\nconst isCompletion = process.argv.includes('completion') || process.argv.includes('__complete');\n\n(isCompletion ? Promise.resolve() : setupNotices())\n .then(() => program.parseAsync(process.argv))\n .catch((error) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 1;\n });\n","import { homedir } from 'node:os';\nimport { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type {\n AnyConfigFile,\n ConfigFileV2,\n LegacyConfigFile,\n ProfileConfig,\n ResolvedProfile,\n} from './types.js';\nimport { SETUP_COMMAND_HINT, SETUP_URL_PROMPT } from './setup-guide.js';\n\nexport const DEFAULT_WORKSPACE = 'default';\nexport const DEFAULT_LANGUAGE = 'zhCN';\n\nconst CONFIG_DIR = path.join(homedir(), '.bpmax');\nconst CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');\n\nconst defaultConfig = (): ConfigFileV2 => ({\n version: 2,\n current_profile: 'default',\n profiles: {\n default: {\n origin: '',\n workspace: DEFAULT_WORKSPACE,\n language: DEFAULT_LANGUAGE,\n },\n },\n});\n\nconst normalizeOrigin = (origin: string): string => origin.trim().replace(/\\/+$/, '');\n\nconst isV2Config = (input: AnyConfigFile): input is ConfigFileV2 =>\n typeof input === 'object' &&\n input !== null &&\n 'version' in input &&\n (input as ConfigFileV2).version === 2 &&\n 'profiles' in input;\n\nconst toV2Config = (input: AnyConfigFile): ConfigFileV2 => {\n if (isV2Config(input)) {\n return {\n version: 2,\n current_profile: input.current_profile || 'default',\n profiles: Object.fromEntries(\n Object.entries(input.profiles || {}).map(([name, profile]) => [\n name,\n {\n ...profile,\n origin: normalizeOrigin(profile.origin || ''),\n workspace: profile.workspace || DEFAULT_WORKSPACE,\n language: profile.language || DEFAULT_LANGUAGE,\n },\n ]),\n ),\n };\n }\n\n const legacy = input as LegacyConfigFile;\n const migrated = defaultConfig();\n migrated.profiles.default = {\n origin: normalizeOrigin(legacy.host || ''),\n api_key: legacy.api_key || '',\n workspace: DEFAULT_WORKSPACE,\n language: DEFAULT_LANGUAGE,\n };\n return migrated;\n};\n\nexport async function loadConfig(): Promise<ConfigFileV2> {\n try {\n const raw = await readFile(CONFIG_PATH, 'utf8');\n const parsed = JSON.parse(raw) as AnyConfigFile;\n return toV2Config(parsed);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return defaultConfig();\n }\n throw error;\n }\n}\n\nexport async function saveConfig(config: ConfigFileV2): Promise<void> {\n await mkdir(CONFIG_DIR, { recursive: true });\n await writeFile(CONFIG_PATH, `${JSON.stringify(config, null, 2)}\\n`, 'utf8');\n}\n\nexport function getConfigPath(): string {\n return CONFIG_PATH;\n}\n\nexport function getConfigDir(): string {\n return CONFIG_DIR;\n}\n\nexport function maskApiKey(apiKey?: string): string {\n if (!apiKey) {\n return '(unset)';\n }\n if (apiKey.length <= 10) {\n return apiKey;\n }\n return `${apiKey.slice(0, 8)}****${apiKey.slice(-4)}`;\n}\n\nexport function ensureProfile(config: ConfigFileV2, profileName: string): ProfileConfig {\n const profile = config.profiles[profileName];\n if (!profile) {\n throw new Error(`Profile \"${profileName}\" not found.`);\n }\n return profile;\n}\n\nexport function resolveProfile(config: ConfigFileV2, profileName?: string): ResolvedProfile {\n const name = profileName || config.current_profile || 'default';\n const profile = ensureProfile(config, name);\n\n if (!profile.origin) {\n throw new Error(\n [\n `Profile \"${name}\" has no origin configured. bpmax-cli is not initialized yet.`,\n SETUP_URL_PROMPT,\n SETUP_COMMAND_HINT,\n ].join('\\n'),\n );\n }\n\n return {\n name,\n config: {\n origin: normalizeOrigin(profile.origin),\n api_key: profile.api_key,\n workspace: profile.workspace || DEFAULT_WORKSPACE,\n language: profile.language || DEFAULT_LANGUAGE,\n user: profile.user,\n },\n };\n}\n\nexport async function upsertProfile(name: string, nextProfile: ProfileConfig): Promise<ConfigFileV2> {\n const config = await loadConfig();\n config.profiles[name] = {\n ...config.profiles[name],\n ...nextProfile,\n origin: normalizeOrigin(nextProfile.origin || config.profiles[name]?.origin || ''),\n workspace: nextProfile.workspace || config.profiles[name]?.workspace || DEFAULT_WORKSPACE,\n language: nextProfile.language || config.profiles[name]?.language || DEFAULT_LANGUAGE,\n };\n if (!config.current_profile) {\n config.current_profile = name;\n }\n await saveConfig(config);\n return config;\n}\n","export const SETUP_URL_PROMPT =\n 'Agent action: ask the user to directly input a BPMAX workspace page URL, for example http://127.0.0.1:10018/w:store_mgr.';\n\nexport const SETUP_COMMAND_HINT =\n 'Do not show a command template yet. After the user replies with the URL, run: bpmax-cli setup \"<USER_URL>\" --name local';\n","import axios, { AxiosHeaders, type AxiosInstance } from 'axios';\n\nimport type { ApiEnvelope, ResolvedProfile } from './types.js';\n\nconst ensureApiPath = (path: string): string => {\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n if (path.startsWith('/api/')) {\n return path;\n }\n return `/api${path}`;\n};\n\nexport function createApiClient(profile: ResolvedProfile): AxiosInstance {\n const instance = axios.create({\n baseURL: profile.config.origin,\n withCredentials: false,\n });\n\n instance.interceptors.request.use((config) => {\n config.params = {\n ...(config.params || {}),\n $workspace: config.params?.$workspace ?? profile.config.workspace,\n $language: config.params?.$language ?? profile.config.language,\n };\n if (profile.config.api_key) {\n const headers = AxiosHeaders.from(config.headers || {});\n headers.set('Authorization', `Bearer ${profile.config.api_key}`);\n config.headers = headers;\n }\n return config;\n });\n\n return instance;\n}\n\nexport async function apiRequest<T>(\n client: AxiosInstance,\n method: string,\n path: string,\n options: {\n params?: Record<string, unknown>;\n data?: unknown;\n } = {},\n): Promise<T> {\n const response = await client.request<ApiEnvelope<T>>({\n method,\n url: ensureApiPath(path),\n params: options.params,\n data: options.data,\n });\n const body = response.data;\n if (body.code !== 0) {\n throw new Error(body.msg || `Request failed with code ${body.code}`);\n }\n return (body.data ?? body) as T;\n}\n","import type { OutputFormat } from './types.js';\n\ntype NoticeValue = Record<string, unknown>;\ntype NoticeProvider = () => Record<string, NoticeValue> | null;\n\nlet noticeProvider: NoticeProvider | null = null;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport function setNoticeProvider(provider: NoticeProvider): void {\n noticeProvider = provider;\n}\n\nexport function clearNoticeProvider(): void {\n noticeProvider = null;\n}\n\nfunction currentNotice(): Record<string, NoticeValue> | null {\n return noticeProvider?.() || null;\n}\n\nfunction withJsonNotice(value: unknown): unknown {\n const notice = currentNotice();\n if (!notice || Object.keys(notice).length === 0) {\n return value;\n }\n if (isRecord(value)) {\n return { ...value, _notice: notice };\n }\n return value;\n}\n\nfunction emitTextNotice(): void {\n const notice = currentNotice();\n if (!notice) {\n return;\n }\n Object.values(notice).forEach((entry) => {\n if (typeof entry.message === 'string') {\n console.error(entry.message);\n }\n });\n}\n\nexport function printResult(format: OutputFormat, value: unknown): void {\n switch (format) {\n case 'json':\n console.log(JSON.stringify(withJsonNotice(value), null, 2));\n return;\n case 'ndjson':\n if (Array.isArray(value)) {\n value.forEach((item) => {\n console.log(JSON.stringify(item));\n });\n } else {\n console.log(JSON.stringify(value));\n }\n return;\n case 'table':\n if (Array.isArray(value)) {\n console.table(value);\n } else if (isRecord(value)) {\n console.table([value]);\n } else {\n console.log(value);\n }\n return;\n case 'pretty':\n default:\n emitTextNotice();\n if (typeof value === 'string') {\n console.log(value);\n return;\n }\n console.log(JSON.stringify(value, null, 2));\n }\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nfunction parseJson(input?: string): unknown {\n if (!input) {\n return undefined;\n }\n return JSON.parse(input);\n}\n\nexport function registerApiCommands(program: Command): void {\n program\n .command('api <method> <path>')\n .description('Call an arbitrary BPMAX /api endpoint')\n .option('--profile <profile>', 'Profile name')\n .option('--params <json>', 'Query params JSON')\n .option('--data <json>', 'Request body JSON')\n .option('--format <format>', 'Output format', 'json')\n .action(async (method: string, path: string, options: {\n profile?: string;\n params?: string;\n data?: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown>(createApiClient(profile), method, path, {\n params: parseJson(options.params) as Record<string, unknown> | undefined,\n data: parseJson(options.data),\n });\n printResult(options.format, result);\n });\n}\n","import { createServer } from 'node:http';\nimport { randomBytes } from 'node:crypto';\n\nimport open from 'open';\n\nimport type { CallbackPayload, ProfileConfig, UserSummary } from './types.js';\n\nexport interface LoginResult {\n apiKey: string;\n user?: UserSummary;\n}\n\nfunction buildBridgeUrl(\n origin: string,\n workspace: string,\n params: Record<string, string>,\n): string {\n const query = new URLSearchParams(params);\n return `${origin}/${encodeURIComponent(workspace)}/cli-login?${query.toString()}`;\n}\n\nexport async function runBrowserLogin(options: {\n origin: string;\n workspace: string;\n profileName: string;\n apiKeyName: string;\n timeoutMs?: number;\n}): Promise<LoginResult & { state: string }> {\n const state = randomBytes(16).toString('hex');\n const timeoutMs = options.timeoutMs ?? 5 * 60 * 1000;\n\n return await new Promise((resolve, reject) => {\n const server = createServer(async (req, res) => {\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type');\n\n if (req.method === 'OPTIONS') {\n res.statusCode = 204;\n res.end();\n return;\n }\n\n if (req.method !== 'POST' || req.url !== '/callback') {\n res.statusCode = 404;\n res.end(JSON.stringify({ ok: false, message: 'Not found' }));\n return;\n }\n\n let raw = '';\n req.on('data', (chunk) => {\n raw += chunk.toString();\n });\n req.on('end', () => {\n try {\n const payload = JSON.parse(raw) as CallbackPayload;\n if (payload.state !== state) {\n res.statusCode = 400;\n res.end(JSON.stringify({ ok: false, message: 'Invalid state' }));\n return;\n }\n if (!payload.api_key) {\n res.statusCode = 400;\n res.end(JSON.stringify({ ok: false, message: 'Missing api_key' }));\n return;\n }\n res.statusCode = 200;\n res.end(JSON.stringify({ ok: true }));\n clearTimeout(timer);\n server.close();\n resolve({ apiKey: payload.api_key, user: payload.user, state });\n } catch (error) {\n res.statusCode = 400;\n res.end(\n JSON.stringify({\n ok: false,\n message: error instanceof Error ? error.message : 'Invalid callback payload',\n }),\n );\n }\n });\n req.on('error', reject);\n });\n\n server.listen(0, '127.0.0.1', async () => {\n const address = server.address();\n if (!address || typeof address === 'string') {\n reject(new Error('Failed to allocate local callback port.'));\n return;\n }\n const callbackUrl = `http://127.0.0.1:${address.port}/callback`;\n const bridgeUrl = buildBridgeUrl(options.origin, options.workspace, {\n callback: callbackUrl,\n state,\n profile: options.profileName,\n key_name: options.apiKeyName,\n });\n await open(bridgeUrl);\n });\n\n server.on('error', reject);\n\n const timer = setTimeout(() => {\n server.close();\n reject(new Error('Timed out waiting for browser login callback.'));\n }, timeoutMs);\n });\n}\n\nexport function updateProfileAuth(profile: ProfileConfig, result: LoginResult): ProfileConfig {\n return {\n ...profile,\n api_key: result.apiKey,\n user: result.user,\n };\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, maskApiKey, resolveProfile, saveConfig } from '../core/config.js';\nimport { runBrowserLogin, updateProfileAuth } from '../core/auth.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerAuthCommands(program: Command): void {\n const auth = program.command('auth').description('Authenticate and manage API key state');\n\n auth\n .command('login')\n .description('Open the hpt-frontend bridge page and persist the returned API key')\n .option('--profile <profile>', 'Profile name')\n .option('--key-name <keyName>', 'Target API key name', 'bpmax-cli')\n .action(async (options: { profile?: string; keyName: string }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await runBrowserLogin({\n origin: profile.config.origin,\n workspace: profile.config.workspace,\n profileName: profile.name,\n apiKeyName: options.keyName,\n });\n config.profiles[profile.name] = updateProfileAuth(config.profiles[profile.name], result);\n await saveConfig(config);\n console.log(`Saved API key for profile \"${profile.name}\".`);\n });\n\n auth\n .command('status')\n .description('Show saved auth state and validate /api/user/current')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const output: Record<string, unknown> = {\n profile: profile.name,\n origin: profile.config.origin,\n workspace: profile.config.workspace,\n language: profile.config.language,\n api_key: maskApiKey(profile.config.api_key),\n };\n\n if (profile.config.api_key) {\n try {\n const currentUser = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n '/user/current',\n );\n output.user = currentUser;\n output.authenticated = true;\n } catch (error) {\n output.authenticated = false;\n output.error = error instanceof Error ? error.message : String(error);\n }\n } else {\n output.authenticated = false;\n }\n\n printResult(options.format, output);\n });\n\n auth\n .command('logout')\n .description('Clear the stored API key for the selected profile')\n .option('--profile <profile>', 'Profile name')\n .action(async (options: { profile?: string }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n config.profiles[profile.name] = {\n ...config.profiles[profile.name],\n api_key: '',\n user: undefined,\n };\n await saveConfig(config);\n console.log(`Cleared API key for profile \"${profile.name}\".`);\n });\n}\n","import { text } from '@clack/prompts';\nimport type { Command } from 'commander';\n\nimport {\n DEFAULT_LANGUAGE,\n DEFAULT_WORKSPACE,\n getConfigPath,\n loadConfig,\n maskApiKey,\n saveConfig,\n upsertProfile,\n} from '../core/config.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat, ProfileConfig } from '../core/types.js';\n\nasync function ensureValue(current: string | undefined, label: string, placeholder?: string): Promise<string> {\n if (current) {\n return current;\n }\n const result = await text({\n message: label,\n placeholder,\n });\n if (typeof result !== 'string' || !result.trim()) {\n throw new Error(`${label} is required.`);\n }\n return result.trim();\n}\n\nexport function registerConfigCommands(program: Command): void {\n const config = program.command('config').description('Manage local bpmax-cli profiles');\n const profile = config.command('profile').description('Manage named environment profiles');\n\n profile\n .command('add')\n .description('Add or update a profile')\n .option('--name <name>', 'Profile name')\n .option('--origin <origin>', 'Profile origin')\n .option('--api-key <apiKey>', 'API key')\n .option('--workspace <workspace>', 'Default workspace', DEFAULT_WORKSPACE)\n .option('--language <language>', 'Default language', DEFAULT_LANGUAGE)\n .action(async (options) => {\n const name = await ensureValue(options.name, 'Profile name', 'default');\n const origin = await ensureValue(options.origin, 'Origin', 'https://example.com');\n await upsertProfile(name, {\n origin,\n api_key: options.apiKey,\n workspace: options.workspace,\n language: options.language,\n });\n console.log(`Saved profile \"${name}\" to ${getConfigPath()}.`);\n });\n\n profile\n .command('list')\n .description('List profiles')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { format: OutputFormat }) => {\n const configData = await loadConfig();\n const rows = Object.entries(configData.profiles).map(([name, profileConfig]) => ({\n name,\n current: configData.current_profile === name,\n origin: profileConfig.origin,\n workspace: profileConfig.workspace || DEFAULT_WORKSPACE,\n language: profileConfig.language || DEFAULT_LANGUAGE,\n api_key: maskApiKey(profileConfig.api_key),\n }));\n printResult(options.format, rows);\n });\n\n profile\n .command('use <name>')\n .description('Set the active profile')\n .action(async (name: string) => {\n const configData = await loadConfig();\n if (!configData.profiles[name]) {\n throw new Error(`Profile \"${name}\" not found.`);\n }\n configData.current_profile = name;\n await saveConfig(configData);\n console.log(`Current profile set to \"${name}\".`);\n });\n\n profile\n .command('remove <name>')\n .description('Remove a profile')\n .action(async (name: string) => {\n const configData = await loadConfig();\n if (!configData.profiles[name]) {\n throw new Error(`Profile \"${name}\" not found.`);\n }\n delete configData.profiles[name];\n if (configData.current_profile === name) {\n const [nextProfile] = Object.keys(configData.profiles);\n configData.current_profile = nextProfile || 'default';\n }\n await saveConfig(configData);\n console.log(`Removed profile \"${name}\".`);\n });\n\n profile\n .command('show')\n .description('Show a profile')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; format: OutputFormat }) => {\n const configData = await loadConfig();\n const name = options.profile || configData.current_profile;\n const target = configData.profiles[name];\n if (!target) {\n throw new Error(`Profile \"${name}\" not found.`);\n }\n printResult(options.format, {\n name,\n config_path: getConfigPath(),\n origin: target.origin,\n workspace: target.workspace || DEFAULT_WORKSPACE,\n language: target.language || DEFAULT_LANGUAGE,\n api_key: maskApiKey(target.api_key),\n user: target.user || null,\n });\n });\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerFlowCommands(program: Command): void {\n const flow = program.command('flow').description('Flow commands');\n\n flow\n .command('list')\n .description('List flows')\n .option('--profile <profile>', 'Profile name')\n .option('--draft <draft>', 'Draft flag', '1')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { profile?: string; draft: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown[]>(\n createApiClient(profile),\n 'GET',\n '/flow/flow_type',\n {\n params: {\n draft: options.draft,\n skip_i18n: 'true',\n },\n },\n );\n printResult(options.format, result);\n });\n\n flow\n .command('options')\n .description('List flow options')\n .option('--profile <profile>', 'Profile name')\n .option('--name <name>', 'Flow name filter')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { profile?: string; name?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown[]>(\n createApiClient(profile),\n 'GET',\n '/flow/options',\n {\n params: options.name ? { name: options.name } : undefined,\n },\n );\n printResult(options.format, result);\n });\n\n flow\n .command('get')\n .description('Get flow detail by id')\n .requiredOption('--id <id>', 'Flow id')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { id: string; profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<unknown[]>(\n createApiClient(profile),\n 'POST',\n '/flow/batch_get',\n {\n data: {\n ids: [Number(options.id)],\n },\n },\n );\n printResult(options.format, result[0] ?? null);\n });\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nfunction parseJson(input?: string): Record<string, unknown> {\n if (!input) {\n return {};\n }\n return JSON.parse(input) as Record<string, unknown>;\n}\n\nasync function resolveFlowIdentifiers(\n client: ReturnType<typeof createApiClient>,\n options: { flowId?: string; flowType?: string; flowKey?: string },\n): Promise<{ flow_type: string; flow_key: string }> {\n if (options.flowType && options.flowKey !== undefined) {\n return {\n flow_type: options.flowType,\n flow_key: options.flowKey,\n };\n }\n\n if (!options.flowId) {\n throw new Error('Either --flow-id or both --flow-type and --flow-key are required.');\n }\n\n const flows = await apiRequest<Array<Record<string, unknown>>>(\n client,\n 'POST',\n '/flow/batch_get',\n {\n data: { ids: [Number(options.flowId)] },\n },\n );\n const flow = flows[0];\n if (!flow) {\n throw new Error(`Flow ${options.flowId} not found.`);\n }\n return {\n flow_type: String(flow.flow_type || 'default'),\n flow_key: String(flow.key || ''),\n };\n}\n\nexport function registerProjectCommands(program: Command): void {\n const project = program.command('project').description('Project commands');\n\n project\n .command('list')\n .description('List projects')\n .option('--profile <profile>', 'Profile name')\n .option('--page <page>', 'Page number', '1')\n .option('--page-size <pageSize>', 'Page size', '20')\n .option('--body <json>', 'Project list body JSON', '{}')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: {\n profile?: string;\n page: string;\n pageSize: string;\n body: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'POST',\n '/project/list',\n {\n params: {\n page: Number(options.page),\n page_size: Number(options.pageSize),\n },\n data: parseJson(options.body),\n },\n );\n printResult(options.format, result);\n });\n\n project\n .command('get <id>')\n .description('Get project detail')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (id: string, options: { profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n `/project/${id}`,\n );\n printResult(options.format, result);\n });\n\n project\n .command('my-step')\n .description('List my pending project steps')\n .option('--profile <profile>', 'Profile name')\n .option('--finished <finished>', 'Finished flag', '0')\n .option('--page <page>', 'Page number', '1')\n .option('--page-size <pageSize>', 'Page size', '20')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: {\n profile?: string;\n finished: string;\n page: string;\n pageSize: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n '/project/my_step',\n {\n params: {\n finished: options.finished,\n page: Number(options.page),\n page_size: Number(options.pageSize),\n },\n },\n );\n printResult(options.format, result);\n });\n\n project\n .command('create')\n .description('Minimal project create shortcut')\n .option('--profile <profile>', 'Profile name')\n .option('--flow-id <flowId>', 'Flow id')\n .option('--flow-type <flowType>', 'Flow type')\n .option('--flow-key <flowKey>', 'Flow key')\n .option('--name <name>', 'Project name')\n .option('--json <json>', 'Additional request JSON')\n .option('--body <body>', 'Full request body JSON override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: {\n profile?: string;\n flowId?: string;\n flowType?: string;\n flowKey?: string;\n name?: string;\n json?: string;\n body?: string;\n format: OutputFormat;\n }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const client = createApiClient(profile);\n\n let payload = parseJson(options.body);\n if (!options.body) {\n if (!options.name) {\n throw new Error('--name is required unless --body is provided.');\n }\n const flow = await resolveFlowIdentifiers(client, options);\n const extra = parseJson(options.json);\n const form =\n typeof extra.form === 'object' && extra.form !== null && !Array.isArray(extra.form)\n ? (extra.form as Record<string, unknown>)\n : {};\n payload = {\n ...extra,\n ...flow,\n name: options.name,\n workspace: profile.config.workspace,\n form,\n };\n }\n\n const result = await apiRequest<Record<string, unknown>>(\n client,\n 'POST',\n '/project/open-api/create',\n {\n data: payload,\n },\n );\n printResult(options.format, result);\n });\n}\n","import type { SchemaEntry } from './types.js';\n\nexport const schemaEntries: SchemaEntry[] = [\n { name: 'auth.login', description: 'Open hpt-frontend bridge page and persist API key locally.' },\n { name: 'auth.status', description: 'Show current profile status and validate /api/user/current.' },\n { name: 'auth.logout', description: 'Clear the saved API key for the selected profile.' },\n { name: 'user.current', description: 'Get current user.', method: 'GET', path: '/api/user/current' },\n { name: 'flow.list', description: 'List flows.', method: 'GET', path: '/api/flow/flow_type' },\n { name: 'flow.options', description: 'List flow options.', method: 'GET', path: '/api/flow/options' },\n { name: 'flow.get', description: 'Fetch flow details by id.', method: 'POST', path: '/api/flow/batch_get' },\n { name: 'project.list', description: 'List projects.', method: 'POST', path: '/api/project/list' },\n { name: 'project.get', description: 'Get project detail.', method: 'GET', path: '/api/project/:id' },\n { name: 'project.my-step', description: 'List my pending steps.', method: 'GET', path: '/api/project/my_step' },\n { name: 'project.create', description: 'Minimal project create shortcut.', method: 'POST', path: '/api/project/open-api/create' },\n];\n","import type { Command } from 'commander';\n\nimport { printResult } from '../core/output.js';\nimport { schemaEntries } from '../core/manifest.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerSchemaCommands(program: Command): void {\n const schema = program.command('schema').description('Inspect built-in bpmax-cli schema metadata');\n\n schema\n .command('list')\n .description('List known command and endpoint mappings')\n .option('--format <format>', 'Output format', 'table')\n .action((options: { format: OutputFormat }) => {\n printResult(options.format, schemaEntries);\n });\n\n schema\n .command('show <name>')\n .description('Show a single schema entry')\n .option('--format <format>', 'Output format', 'pretty')\n .action((name: string, options: { format: OutputFormat }) => {\n const entry = schemaEntries.find((item) => item.name === name);\n if (!entry) {\n throw new Error(`Schema entry \"${name}\" not found.`);\n }\n printResult(options.format, entry);\n });\n}\n","import { confirm, text } from '@clack/prompts';\nimport type { Command } from 'commander';\n\nimport { runBrowserLogin, updateProfileAuth, type LoginResult } from '../core/auth.js';\nimport {\n DEFAULT_LANGUAGE,\n DEFAULT_WORKSPACE,\n loadConfig as loadConfigDefault,\n saveConfig as saveConfigDefault,\n} from '../core/config.js';\nimport { printResult } from '../core/output.js';\nimport {\n applySetupProfile,\n configuredProfiles,\n defaultSetupProfileName,\n parseBpmUrl,\n setupSummary,\n} from '../core/setup.js';\nimport type { ConfigFileV2, OutputFormat } from '../core/types.js';\n\ninterface SetupDeps {\n loadConfig?: () => Promise<ConfigFileV2>;\n saveConfig?: (config: ConfigFileV2) => Promise<void>;\n login?: (options: {\n origin: string;\n workspace: string;\n profileName: string;\n apiKeyName: string;\n }) => Promise<LoginResult>;\n}\n\ninterface SetupOptions {\n name?: string;\n origin?: string;\n url?: string;\n workspace?: string;\n language?: string;\n keyName: string;\n skipLogin?: boolean;\n force?: boolean;\n format: OutputFormat;\n}\n\nasync function promptText(current: string | undefined, message: string, placeholder: string): Promise<string> {\n if (current?.trim()) {\n return current.trim();\n }\n const value = await text({ message, placeholder });\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`${message} is required.`);\n }\n return value.trim();\n}\n\nasync function promptConfirm(message: string): Promise<boolean> {\n const value = await confirm({ message, initialValue: true });\n return value === true;\n}\n\nexport function registerSetupCommand(program: Command, deps: SetupDeps = {}): void {\n const loadConfig = deps.loadConfig || loadConfigDefault;\n const saveConfig = deps.saveConfig || saveConfigDefault;\n const login = deps.login || runBrowserLogin;\n\n program\n .command('setup')\n .description('Configure a BPMAX environment profile and optionally authorize it')\n .argument('[url]', 'Full BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr')\n .option('--name <name>', 'Profile name')\n .option('--url <url>', 'Full BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr')\n .option('--origin <origin>', 'BPMAX environment root URL, for example http://127.0.0.1:10018')\n .option('--workspace <workspace>', 'Default workspace', DEFAULT_WORKSPACE)\n .option('--language <language>', 'Default language', DEFAULT_LANGUAGE)\n .option('--key-name <keyName>', 'Target API key name', 'bpmax-cli')\n .option('--skip-login', 'Only save the profile, do not open browser authorization')\n .option('--force', 'Configure a new profile even when configured profiles already exist')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (setupUrl: string | undefined, options: SetupOptions, command: Command) => {\n if (setupUrl && options.url) {\n throw new Error('Pass the BPMAX URL either as an argument or with --url, not both.');\n }\n\n const urlInput = setupUrl || options.url;\n const parsedUrl = urlInput ? parseBpmUrl(urlInput) : undefined;\n const workspaceWasProvided = command.getOptionValueSource('workspace') === 'cli';\n const config = await loadConfig();\n const existing = configuredProfiles(config);\n\n if (existing.length > 0 && !options.force && !urlInput && !options.origin && !options.name) {\n printResult(options.format, {\n configured: true,\n profiles: existing,\n next: 'Run `bpmax-cli setup --force` to add another profile, or `bpmax-cli auth login --profile <name>` to re-authorize.',\n });\n return;\n }\n\n const defaultName = defaultSetupProfileName(config);\n const name = urlInput && !options.name ? defaultName : await promptText(options.name, 'Profile name', defaultName);\n const origin = await promptText(\n options.origin || parsedUrl?.origin,\n 'BPMAX environment URL',\n 'http://127.0.0.1:10018',\n );\n const workspace = await promptText(\n workspaceWasProvided ? options.workspace : parsedUrl?.workspace || options.workspace,\n 'Default workspace',\n DEFAULT_WORKSPACE,\n );\n const language = options.language || DEFAULT_LANGUAGE;\n\n let nextConfig = applySetupProfile(config, name, {\n origin,\n workspace,\n language,\n });\n await saveConfig(nextConfig);\n\n const shouldLogin = options.skipLogin\n ? false\n : options.origin || urlInput\n ? true\n : await promptConfirm('Open browser to authorize this profile now?');\n if (!shouldLogin) {\n printResult(options.format, setupSummary({ profile: name, origin, workspace, login: 'skipped' }));\n return;\n }\n\n const result = await login({\n origin,\n workspace,\n profileName: name,\n apiKeyName: options.keyName,\n });\n nextConfig = applySetupProfile(nextConfig, name, updateProfileAuth(nextConfig.profiles[name], result));\n await saveConfig(nextConfig);\n\n printResult(\n options.format,\n setupSummary({\n profile: name,\n origin,\n workspace,\n login: 'authenticated',\n user: result.user,\n }),\n );\n });\n}\n","import { DEFAULT_LANGUAGE, DEFAULT_WORKSPACE } from './config.js';\nimport type { ConfigFileV2, ProfileConfig, UserSummary } from './types.js';\n\nexport interface ConfiguredProfile {\n name: string;\n current: boolean;\n origin: string;\n workspace: string;\n language: string;\n authenticated: boolean;\n}\n\nexport interface SetupSummaryInput {\n profile: string;\n origin: string;\n workspace: string;\n login: 'skipped' | 'authenticated';\n user?: UserSummary;\n}\n\nexport interface ParsedBpmUrl {\n origin: string;\n workspace: string;\n}\n\nexport function parseBpmUrl(input: string): ParsedBpmUrl {\n const trimmed = input.trim();\n if (!trimmed) {\n throw new Error('BPMAX URL is required.');\n }\n\n let url: URL;\n try {\n url = new URL(trimmed);\n } catch {\n throw new Error(`Invalid BPMAX URL: ${input}`);\n }\n\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n throw new Error(`BPMAX URL must start with http:// or https://: ${input}`);\n }\n\n const workspace = url.pathname\n .split('/')\n .filter(Boolean)\n .map((segment) => decodeURIComponent(segment))[0];\n if (!workspace) {\n throw new Error(`BPMAX URL must include a workspace path, for example ${url.origin}/w:store_mgr`);\n }\n\n return {\n origin: url.origin,\n workspace,\n };\n}\n\nexport function configuredProfiles(config: ConfigFileV2): ConfiguredProfile[] {\n return Object.entries(config.profiles)\n .filter(([, profile]) => Boolean(profile.origin?.trim()))\n .map(([name, profile]) => ({\n name,\n current: config.current_profile === name,\n origin: profile.origin,\n workspace: profile.workspace || DEFAULT_WORKSPACE,\n language: profile.language || DEFAULT_LANGUAGE,\n authenticated: Boolean(profile.api_key),\n }));\n}\n\nexport function defaultSetupProfileName(config: ConfigFileV2): string {\n if (configuredProfiles(config).length > 0) {\n let index = 2;\n while (config.profiles[`local-${index}`]) {\n index += 1;\n }\n return `local-${index}`;\n }\n const defaultProfile = config.profiles.default;\n if (!defaultProfile || !defaultProfile.origin?.trim()) {\n return 'default';\n }\n let index = 2;\n while (config.profiles[`local-${index}`]) {\n index += 1;\n }\n return `local-${index}`;\n}\n\nexport function applySetupProfile(\n config: ConfigFileV2,\n name: string,\n profile: ProfileConfig,\n): ConfigFileV2 {\n return {\n ...config,\n current_profile: name,\n profiles: {\n ...config.profiles,\n [name]: {\n ...config.profiles[name],\n ...profile,\n },\n },\n };\n}\n\nexport function setupSummary(input: SetupSummaryInput): Record<string, unknown> {\n return {\n profile: input.profile,\n origin: input.origin,\n workspace: input.workspace,\n login: input.login,\n ...(input.user ? { user: input.user } : {}),\n ...(input.login === 'skipped'\n ? { next: `Run \\`bpmax-cli auth login --profile ${input.profile}\\` to authorize this profile.` }\n : {}),\n };\n}\n","{\n \"name\": \"bpmax-cli\",\n \"version\": \"0.1.6\",\n \"description\": \"CLI for BPMAX environments with multi-profile config and local login callback flow\",\n \"type\": \"module\",\n \"bin\": {\n \"bpmax-cli\": \"dist/bin.js\"\n },\n \"files\": [\n \"dist\",\n \"scripts/install-skills.mjs\",\n \"skills\",\n \"README.md\"\n ],\n \"scripts\": {\n \"postinstall\": \"node scripts/install-skills.mjs\",\n \"build\": \"tsup\",\n \"dev\": \"tsx src/bin.ts\",\n \"install:skills\": \"node scripts/install-skills.mjs\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"dependencies\": {\n \"@clack/prompts\": \"^1.2.0\",\n \"axios\": \"^1.9.0\",\n \"commander\": \"^14.0.0\",\n \"open\": \"^10.1.2\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^22.15.17\",\n \"tsup\": \"^8.5.0\",\n \"tsx\": \"^4.19.4\",\n \"typescript\": \"^5.8.3\",\n \"vitest\": \"^3.1.3\"\n }\n}\n","import packageJson from '../../package.json' with { type: 'json' };\n\nexport const CLI_NAME = 'bpmax-cli';\nexport const VERSION = packageJson.version;\nexport const NPM_PACKAGE = 'bpmax-cli';\n","import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { getConfigDir } from './config.js';\nimport { runCommand, type CommandRunner, type RunResult } from './process.js';\n\nconst SKILLS_STAMP_FILE = 'skills.stamp';\nconst SKILLS_INSTALL_TIMEOUT_MS = 2 * 60 * 1000;\n\nexport interface SkillsStatus {\n current: string;\n target: string;\n inSync: boolean;\n}\n\nfunction stampPath(configDir = getConfigDir()): string {\n return path.join(configDir, SKILLS_STAMP_FILE);\n}\n\nexport async function readSkillsStamp(configDir = getConfigDir()): Promise<string> {\n try {\n return (await readFile(stampPath(configDir), 'utf8')).trim();\n } catch {\n return '';\n }\n}\n\nexport async function writeSkillsStamp(version: string, configDir = getConfigDir()): Promise<void> {\n await mkdir(configDir, { recursive: true });\n await writeFile(stampPath(configDir), version, 'utf8');\n}\n\nexport async function checkSkillsSync(currentVersion: string, configDir = getConfigDir()): Promise<SkillsStatus> {\n if (process.env.BPMAX_CLI_NO_SKILLS_NOTIFIER) {\n return { current: currentVersion, target: currentVersion, inSync: true };\n }\n const current = await readSkillsStamp(configDir);\n return { current, target: currentVersion, inSync: current === currentVersion };\n}\n\nfunction defaultPackageRoot(): string {\n return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');\n}\n\nexport async function runSkillsInstall(\n options: { packageRoot?: string; runner?: CommandRunner } = {},\n): Promise<RunResult> {\n const runner = options.runner || runCommand;\n return runner(process.execPath, [path.join(options.packageRoot || defaultPackageRoot(), 'scripts', 'install-skills.mjs')], {\n timeoutMs: SKILLS_INSTALL_TIMEOUT_MS,\n });\n}\n\nexport async function syncSkills(\n version: string,\n options: { force?: boolean; configDir?: string; packageRoot?: string; runner?: CommandRunner } = {},\n): Promise<{ action: 'in_sync' | 'synced' | 'failed'; result?: RunResult }> {\n if (!options.force) {\n const status = await checkSkillsSync(version, options.configDir);\n if (status.inSync) {\n return { action: 'in_sync' };\n }\n }\n const result = await runSkillsInstall({ packageRoot: options.packageRoot, runner: options.runner });\n if (result.exitCode === 0) {\n await writeSkillsStamp(version, options.configDir);\n return { action: 'synced', result };\n }\n return { action: 'failed', result };\n}\n","import { spawn } from 'node:child_process';\n\nexport interface RunResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport interface RunOptions {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n timeoutMs?: number;\n}\n\nexport type CommandRunner = (command: string, args: string[], options?: RunOptions) => Promise<RunResult>;\n\nexport const runCommand: CommandRunner = (command, args, options = {}) =>\n new Promise((resolve) => {\n const child = spawn(command, args, {\n cwd: options.cwd,\n env: options.env,\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n let stdout = '';\n let stderr = '';\n let settled = false;\n const timer =\n options.timeoutMs && options.timeoutMs > 0\n ? setTimeout(() => {\n if (settled) {\n return;\n }\n settled = true;\n child.kill('SIGTERM');\n resolve({\n stdout,\n stderr: `${stderr}${stderr ? '\\n' : ''}Timed out after ${options.timeoutMs}ms`,\n exitCode: 124,\n });\n }, options.timeoutMs)\n : undefined;\n\n child.stdout?.on('data', (chunk) => {\n stdout += String(chunk);\n });\n child.stderr?.on('data', (chunk) => {\n stderr += String(chunk);\n });\n child.on('error', (error) => {\n if (settled) {\n return;\n }\n settled = true;\n if (timer) {\n clearTimeout(timer);\n }\n resolve({ stdout, stderr: `${stderr}${stderr ? '\\n' : ''}${error.message}`, exitCode: 1 });\n });\n child.on('close', (code) => {\n if (settled) {\n return;\n }\n settled = true;\n if (timer) {\n clearTimeout(timer);\n }\n resolve({ stdout, stderr, exitCode: code ?? 1 });\n });\n });\n","import { access, mkdir, readFile, realpath, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { NPM_PACKAGE } from './build.js';\nimport { getConfigDir } from './config.js';\nimport { runCommand, type CommandRunner, type RunResult } from './process.js';\n\nconst DEFAULT_REGISTRY_URL = 'https://registry.npmjs.org/';\nconst UPDATE_STATE_FILE = 'update-state.json';\nconst CACHE_TTL_MS = 24 * 60 * 60 * 1000;\nconst FETCH_TIMEOUT_MS = 5_000;\nconst NPM_INSTALL_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport interface UpdateInfo {\n current: string;\n latest: string;\n}\n\ninterface UpdateState {\n latest_version: string;\n checked_at: number;\n}\n\ninterface FetchLatestOptions {\n packageName?: string;\n env?: NodeJS.ProcessEnv;\n fetchImpl?: typeof fetch;\n}\n\nexport interface DetectInstallInput {\n executablePath?: string;\n npmPath?: string | null;\n}\n\nexport interface InstallDetection {\n method: 'npm' | 'manual';\n resolvedPath: string;\n npmAvailable: boolean;\n}\n\nexport function buildRegistryUrl(packageName = NPM_PACKAGE, env: NodeJS.ProcessEnv = process.env): string {\n const base = env.BPMAX_CLI_REGISTRY_URL || DEFAULT_REGISTRY_URL;\n const normalizedBase = base.endsWith('/') ? base : `${base}/`;\n return new URL(`${encodeURIComponent(packageName).replace('%40', '@')}/latest`, normalizedBase).toString();\n}\n\ninterface ParsedVersion {\n core: [number, number, number];\n prerelease: string[];\n}\n\nfunction parseVersion(version: string): ParsedVersion | null {\n const clean = version.trim().replace(/^v/, '').split('+')[0];\n const [coreText, prereleaseText = ''] = clean.split('-', 2);\n const coreParts = coreText.split('.');\n if (coreParts.length !== 3) {\n return null;\n }\n const core = coreParts.map((part) => {\n if (!/^(0|[1-9]\\d*)$/.test(part)) {\n return Number.NaN;\n }\n return Number(part);\n }) as [number, number, number];\n if (core.some((part) => Number.isNaN(part))) {\n return null;\n }\n if (prereleaseText && !/^(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*$/.test(prereleaseText)) {\n return null;\n }\n return { core, prerelease: prereleaseText ? prereleaseText.split('.') : [] };\n}\n\nfunction comparePrerelease(left: string[], right: string[]): number {\n if (left.length === 0 && right.length === 0) {\n return 0;\n }\n if (left.length === 0) {\n return 1;\n }\n if (right.length === 0) {\n return -1;\n }\n const max = Math.max(left.length, right.length);\n for (let index = 0; index < max; index += 1) {\n const a = left[index];\n const b = right[index];\n if (a === undefined) {\n return -1;\n }\n if (b === undefined) {\n return 1;\n }\n const aNumber = /^(0|[1-9]\\d*)$/.test(a) ? Number(a) : null;\n const bNumber = /^(0|[1-9]\\d*)$/.test(b) ? Number(b) : null;\n if (aNumber !== null && bNumber !== null) {\n if (aNumber !== bNumber) {\n return aNumber > bNumber ? 1 : -1;\n }\n continue;\n }\n if (aNumber !== null) {\n return -1;\n }\n if (bNumber !== null) {\n return 1;\n }\n if (a !== b) {\n return a > b ? 1 : -1;\n }\n }\n return 0;\n}\n\nexport function isNewerVersion(candidate: string, current: string): boolean {\n const next = parseVersion(candidate);\n if (!next) {\n return false;\n }\n const existing = parseVersion(current);\n if (!existing) {\n return true;\n }\n for (let index = 0; index < 3; index += 1) {\n if (next.core[index] > existing.core[index]) {\n return true;\n }\n if (next.core[index] < existing.core[index]) {\n return false;\n }\n }\n return comparePrerelease(next.prerelease, existing.prerelease) > 0;\n}\n\nexport async function fetchLatestVersion(options: FetchLatestOptions = {}): Promise<string> {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n try {\n const fetchImpl = options.fetchImpl || fetch;\n const response = await fetchImpl(buildRegistryUrl(options.packageName, options.env), {\n signal: controller.signal,\n });\n if (!response.ok) {\n throw new Error(`npm registry returned HTTP ${response.status}`);\n }\n const body = (await response.json()) as { version?: unknown };\n if (typeof body.version !== 'string' || !body.version.trim()) {\n throw new Error('npm registry returned an empty version');\n }\n return body.version.trim();\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction updateStatePath(configDir = getConfigDir()): string {\n return path.join(configDir, UPDATE_STATE_FILE);\n}\n\nasync function readUpdateState(configDir?: string): Promise<UpdateState | null> {\n try {\n const raw = await readFile(updateStatePath(configDir), 'utf8');\n const parsed = JSON.parse(raw) as Partial<UpdateState>;\n if (typeof parsed.latest_version !== 'string' || typeof parsed.checked_at !== 'number') {\n return null;\n }\n return { latest_version: parsed.latest_version, checked_at: parsed.checked_at };\n } catch {\n return null;\n }\n}\n\nasync function writeUpdateState(state: UpdateState, configDir = getConfigDir()): Promise<void> {\n await mkdir(configDir, { recursive: true });\n await writeFile(updateStatePath(configDir), JSON.stringify(state), 'utf8');\n}\n\nexport async function checkCachedUpdate(currentVersion: string, configDir = getConfigDir()): Promise<UpdateInfo | null> {\n if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {\n return null;\n }\n const state = await readUpdateState(configDir);\n if (!state) {\n return null;\n }\n const checkedAtMs = state.checked_at * 1000;\n if (Date.now() - checkedAtMs > CACHE_TTL_MS) {\n return null;\n }\n if (!isNewerVersion(state.latest_version, currentVersion)) {\n return null;\n }\n return { current: currentVersion, latest: state.latest_version };\n}\n\nexport async function refreshUpdateCache(\n currentVersion: string,\n configDir = getConfigDir(),\n options: FetchLatestOptions = {},\n): Promise<UpdateInfo | null> {\n if (process.env.BPMAX_CLI_NO_UPDATE_NOTIFIER) {\n return null;\n }\n const state = await readUpdateState(configDir);\n if (state && Date.now() - state.checked_at * 1000 < CACHE_TTL_MS) {\n return isNewerVersion(state.latest_version, currentVersion)\n ? { current: currentVersion, latest: state.latest_version }\n : null;\n }\n const latest = await fetchLatestVersion(options);\n await writeUpdateState({ latest_version: latest, checked_at: Math.floor(Date.now() / 1000) }, configDir);\n return isNewerVersion(latest, currentVersion) ? { current: currentVersion, latest } : null;\n}\n\nasync function executablePath(): Promise<string> {\n const candidate = process.argv[1] || '';\n if (!candidate) {\n return '';\n }\n try {\n return await realpath(candidate);\n } catch {\n return candidate;\n }\n}\n\nasync function findNpmPath(): Promise<string | null> {\n const command = process.platform === 'win32' ? 'where' : 'which';\n const result = await runCommand(command, ['npm'], { timeoutMs: 10_000 });\n if (result.exitCode !== 0) {\n return null;\n }\n return result.stdout.split(/\\r?\\n/).find(Boolean)?.trim() || null;\n}\n\nexport function detectInstallMethod(input: DetectInstallInput): InstallDetection {\n const resolvedPath = input.executablePath || '';\n const method = resolvedPath.includes(`node_modules${path.sep}`) || resolvedPath.includes('node_modules/')\n ? 'npm'\n : 'manual';\n return {\n method,\n resolvedPath,\n npmAvailable: method === 'npm' && Boolean(input.npmPath),\n };\n}\n\nexport async function detectCurrentInstallMethod(): Promise<InstallDetection> {\n return detectInstallMethod({\n executablePath: await executablePath(),\n npmPath: await findNpmPath(),\n });\n}\n\nexport async function runNpmInstall(\n version: string,\n options: { packageName?: string; runner?: CommandRunner } = {},\n): Promise<RunResult> {\n const runner = options.runner || runCommand;\n return runner('npm', ['install', '-g', `${options.packageName || NPM_PACKAGE}@${version}`], {\n timeoutMs: NPM_INSTALL_TIMEOUT_MS,\n });\n}\n\nexport async function canAccess(targetPath: string): Promise<boolean> {\n try {\n await access(targetPath);\n return true;\n } catch {\n return false;\n }\n}\n","import type { Command } from 'commander';\n\nimport { NPM_PACKAGE, VERSION } from '../core/build.js';\nimport { checkSkillsSync, syncSkills as syncSkillsDefault, type SkillsStatus } from '../core/skills.js';\nimport {\n detectCurrentInstallMethod,\n fetchLatestVersion,\n isNewerVersion,\n runNpmInstall,\n type InstallDetection,\n} from '../core/update.js';\n\nconst MAX_DETAIL = 2_000;\n\ninterface UpdateCommandDeps {\n fetchLatest?: () => Promise<string>;\n detectInstall?: () => Promise<InstallDetection>;\n install?: (version: string) => Promise<{ stdout: string; stderr: string; exitCode: number }>;\n syncSkills?: (version: string, options: { force: boolean }) => Promise<{ action: 'in_sync' | 'synced' | 'failed'; result?: { stderr: string } }>;\n getSkillsStatus?: () => Promise<SkillsStatus>;\n}\n\ninterface UpdateOptions {\n json?: boolean;\n check?: boolean;\n force?: boolean;\n}\n\nfunction printJson(value: unknown): void {\n console.log(JSON.stringify(value, null, 2));\n}\n\nfunction truncate(value: string): string {\n if (value.length <= MAX_DETAIL) {\n return value;\n }\n return value.slice(value.length - MAX_DETAIL);\n}\n\nfunction manualReason(detect: InstallDetection): string {\n if (detect.method === 'npm' && !detect.npmAvailable) {\n return 'installed via npm, but npm is not available in PATH';\n }\n return 'not installed via npm';\n}\n\nfunction skillsAction(result: Awaited<ReturnType<NonNullable<UpdateCommandDeps['syncSkills']>>>): Record<string, unknown> {\n if (result.action !== 'failed') {\n return { skills_action: result.action };\n }\n return {\n skills_action: 'failed',\n skills_warning: 'skills update failed',\n ...(result.result?.stderr ? { skills_detail: truncate(result.result.stderr.trim()) } : {}),\n };\n}\n\nexport function registerUpdateCommands(program: Command, deps: UpdateCommandDeps = {}): void {\n const fetchLatest = deps.fetchLatest || (() => fetchLatestVersion({ packageName: NPM_PACKAGE }));\n const detectInstall = deps.detectInstall || detectCurrentInstallMethod;\n const install = deps.install || ((version: string) => runNpmInstall(version, { packageName: NPM_PACKAGE }));\n const runSkills = deps.syncSkills || ((version: string, options: { force: boolean }) => syncSkillsDefault(version, options));\n const getSkillsStatus = deps.getSkillsStatus || (() => checkSkillsSync(VERSION));\n\n program\n .command('update')\n .description('Update bpmax-cli to the latest version')\n .option('--check', 'only check for updates, do not install')\n .option('--force', 'force reinstall even if already up to date')\n .option('--json', 'structured JSON output')\n .action(async (options: UpdateOptions) => {\n let latest: string;\n try {\n latest = await fetchLatest();\n } catch (error) {\n const message = `failed to check latest version: ${error instanceof Error ? error.message : String(error)}`;\n if (options.json) {\n printJson({ ok: false, error: { type: 'network', message } });\n process.exitCode = 1;\n return;\n }\n throw new Error(message);\n }\n\n const detect = await detectInstall();\n const updateAvailable = isNewerVersion(latest, VERSION);\n\n if (options.check) {\n const status = await getSkillsStatus();\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: VERSION,\n latest_version: latest,\n action: updateAvailable ? 'update_available' : 'already_up_to_date',\n auto_update: detect.method === 'npm' && detect.npmAvailable,\n skills_status: {\n current: status.current,\n target: status.target,\n in_sync: status.inSync,\n },\n };\n if (options.json) {\n printJson(body);\n } else if (updateAvailable) {\n console.error(`Update available: ${VERSION} -> ${latest}`);\n console.error(`Run: bpmax-cli update`);\n } else {\n console.error(`bpmax-cli ${VERSION} is already up to date`);\n }\n return;\n }\n\n if (!options.force && !updateAvailable) {\n const synced = await runSkills(VERSION, { force: false });\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: VERSION,\n latest_version: latest,\n action: 'already_up_to_date',\n ...skillsAction(synced),\n };\n if (options.json) {\n printJson(body);\n } else {\n console.error(`bpmax-cli ${VERSION} is already up to date`);\n if (synced.action === 'failed') {\n console.error('Skills update failed. Run manually: npm run install:skills');\n } else if (synced.action === 'synced') {\n console.error('Skills updated');\n }\n }\n return;\n }\n\n if (detect.method !== 'npm' || !detect.npmAvailable) {\n const synced = await runSkills(VERSION, { force: Boolean(options.force) });\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: VERSION,\n latest_version: latest,\n action: 'manual_required',\n message: `Automatic update unavailable: ${manualReason(detect)} (path: ${detect.resolvedPath})`,\n manual_command: `npm install -g ${NPM_PACKAGE}@${latest}`,\n ...skillsAction(synced),\n };\n if (options.json) {\n printJson(body);\n } else {\n console.error(body.message);\n console.error(`Run manually: ${body.manual_command}`);\n }\n return;\n }\n\n if (!options.json) {\n console.error(`Updating bpmax-cli ${VERSION} -> ${latest} via npm ...`);\n }\n const installResult = await install(latest);\n if (installResult.exitCode !== 0) {\n const detail = truncate(`${installResult.stdout}${installResult.stderr}`.trim());\n if (options.json) {\n printJson({\n ok: false,\n error: {\n type: 'update_error',\n message: `npm install failed with exit code ${installResult.exitCode}`,\n detail,\n },\n });\n process.exitCode = 1;\n return;\n }\n throw new Error(`npm install failed with exit code ${installResult.exitCode}${detail ? `\\n${detail}` : ''}`);\n }\n\n const synced = await runSkills(latest, { force: Boolean(options.force) });\n const body = {\n ok: true,\n previous_version: VERSION,\n current_version: latest,\n latest_version: latest,\n action: 'updated',\n ...skillsAction(synced),\n };\n if (options.json) {\n printJson(body);\n } else {\n console.error(`Successfully updated bpmax-cli from ${VERSION} to ${latest}`);\n if (synced.action === 'failed') {\n console.error('Skills update failed. Run manually: npm run install:skills');\n } else if (synced.action === 'synced') {\n console.error('Skills updated');\n }\n }\n });\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport type { OutputFormat } from '../core/types.js';\n\nexport function registerUserCommands(program: Command): void {\n const user = program.command('user').description('User commands');\n\n user\n .command('current')\n .description('Get current user')\n .option('--profile <profile>', 'Profile name')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; format: OutputFormat }) => {\n const config = await loadConfig();\n const profile = resolveProfile(config, options.profile);\n const result = await apiRequest<Record<string, unknown>>(\n createApiClient(profile),\n 'GET',\n '/user/current',\n );\n printResult(options.format, result);\n });\n}\n","import { VERSION } from './build.js';\nimport { loadConfig } from './config.js';\nimport { checkSkillsSync } from './skills.js';\nimport { setNoticeProvider } from './output.js';\nimport { SETUP_COMMAND_HINT, SETUP_URL_PROMPT } from './setup-guide.js';\nimport { checkCachedUpdate, refreshUpdateCache, type UpdateInfo } from './update.js';\n\ninterface SkillsNotice {\n current: string;\n target: string;\n}\n\nlet pendingUpdate: UpdateInfo | null = null;\nlet pendingSkills: SkillsNotice | null = null;\nlet pendingSetup: { message: string } | null = null;\n\nfunction updateMessage(info: UpdateInfo): string {\n return `bpmax-cli ${info.latest} available, current ${info.current}, run: bpmax-cli update`;\n}\n\nfunction skillsMessage(info: SkillsNotice): string {\n if (!info.current) {\n return 'bpmax-cli skills not installed, run: bpmax-cli update';\n }\n return `bpmax-cli skills ${info.current} out of sync with binary ${info.target}, run: bpmax-cli update`;\n}\n\nfunction setupMessage(): string {\n return [\n 'bpmax-cli is not initialized.',\n SETUP_URL_PROMPT,\n SETUP_COMMAND_HINT,\n ].join('\\n');\n}\n\nfunction hasConfiguredProfile(config: Awaited<ReturnType<typeof loadConfig>>): boolean {\n return Object.values(config.profiles).some((profile) => Boolean(profile.origin?.trim()));\n}\n\nfunction shouldWriteSetupNotice(argv: string[]): boolean {\n const args = argv.slice(2);\n if (args.length === 0) {\n return true;\n }\n return args.includes('--version') || args.includes('-V');\n}\n\nexport async function setupNotices(argv = process.argv): Promise<void> {\n pendingUpdate = await checkCachedUpdate(VERSION);\n const skills = await checkSkillsSync(VERSION);\n pendingSkills = skills.inSync ? null : { current: skills.current, target: skills.target };\n const config = await loadConfig();\n pendingSetup = hasConfiguredProfile(config) ? null : { message: setupMessage() };\n\n if (pendingSetup && shouldWriteSetupNotice(argv)) {\n console.error(pendingSetup.message);\n }\n\n setNoticeProvider(() => {\n const notice: Record<string, Record<string, unknown>> = {};\n if (pendingSetup) {\n notice.setup = {\n message: pendingSetup.message,\n };\n }\n if (pendingUpdate) {\n notice.update = {\n current: pendingUpdate.current,\n latest: pendingUpdate.latest,\n message: updateMessage(pendingUpdate),\n };\n }\n if (pendingSkills) {\n notice.skills = {\n current: pendingSkills.current,\n target: pendingSkills.target,\n message: skillsMessage(pendingSkills),\n };\n }\n return Object.keys(notice).length > 0 ? notice : null;\n });\n\n void refreshUpdateCache(VERSION)\n .then((info) => {\n if (info) {\n pendingUpdate = info;\n }\n })\n .catch(() => {\n // Update notices are best-effort and must never block CLI commands.\n });\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,SAAS,eAAe;AACxB,SAAS,OAAO,UAAU,iBAAiB;AAC3C,OAAO,UAAU;;;ACFV,IAAM,mBACX;AAEK,IAAM,qBACX;;;ADSK,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AAEhC,IAAM,aAAa,KAAK,KAAK,QAAQ,GAAG,QAAQ;AAChD,IAAM,cAAc,KAAK,KAAK,YAAY,aAAa;AAEvD,IAAM,gBAAgB,OAAqB;AAAA,EACzC,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,UAAU;AAAA,IACR,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,UAAU;AAAA,IACZ;AAAA,EACF;AACF;AAEA,IAAM,kBAAkB,CAAC,WAA2B,OAAO,KAAK,EAAE,QAAQ,QAAQ,EAAE;AAEpF,IAAM,aAAa,CAAC,UAClB,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,SACZ,MAAuB,YAAY,KACpC,cAAc;AAEhB,IAAM,aAAa,CAAC,UAAuC;AACzD,MAAI,WAAW,KAAK,GAAG;AACrB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,iBAAiB,MAAM,mBAAmB;AAAA,MAC1C,UAAU,OAAO;AAAA,QACf,OAAO,QAAQ,MAAM,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,OAAO,MAAM;AAAA,UAC5D;AAAA,UACA;AAAA,YACE,GAAG;AAAA,YACH,QAAQ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,OAAO,KAAK,CAAC;AACpE,UAAQ,WAAW;AACnB,CAAC;","names":["path","program","path","program","program","program","parseJson","program","program","text","index","text","program","loadConfig","saveConfig","mkdir","readFile","writeFile","path","path","readFile","mkdir","writeFile","mkdir","readFile","writeFile","path","path","readFile","mkdir","writeFile","program","body","synced","program"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmax-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "CLI for BPMAX environments with multi-profile config and local login callback flow",
5
5
  "type": "module",
6
6
  "bin": {
@@ -7,8 +7,8 @@ const projectRoot = path.resolve(import.meta.dirname, '..');
7
7
  const sourceSkillsDir = path.join(projectRoot, 'skills');
8
8
  const jsonOutput = process.argv.includes('--json');
9
9
  const setupHint = [
10
- '[bpmax-cli] Next: ask the user for any BPMAX workspace URL, for example http://127.0.0.1:10018/w:store_mgr',
11
- '[bpmax-cli] Then run: bpmax-cli setup <BPMAX_WORKSPACE_URL> --name local',
10
+ '[bpmax-cli] Agent action: ask the user to directly input a BPMAX workspace page URL, for example http://127.0.0.1:10018/w:store_mgr',
11
+ '[bpmax-cli] Do not show a command template yet. After the user replies with the URL, run: bpmax-cli setup "<USER_URL>" --name local',
12
12
  '[bpmax-cli] To save the profile without browser authorization, add: --skip-login',
13
13
  ];
14
14
  const stampPath = path.join(homedir(), '.bpmax', 'skills.stamp');