bpmax-cli 0.1.9 → 0.1.10
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 +8 -0
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +99 -6
package/README.md
CHANGED
|
@@ -124,3 +124,11 @@ Running `npm install` or `npm run install:skills` copies project skills into det
|
|
|
124
124
|
- `~/.gemini/skills`
|
|
125
125
|
|
|
126
126
|
Only directories that already exist, or whose parent agent home exists, are targeted.
|
|
127
|
+
|
|
128
|
+
If `aily-skillhub` is available in `PATH`, the installer also runs:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
aily-skillhub install --file-path <skill-directory>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
for each bundled `skills/bpmax-*` directory.
|
package/dist/bin.js
CHANGED
|
@@ -1508,7 +1508,7 @@ function registerSetupCommand(program2, deps = {}) {
|
|
|
1508
1508
|
// package.json
|
|
1509
1509
|
var package_default = {
|
|
1510
1510
|
name: "bpmax-cli",
|
|
1511
|
-
version: "0.1.
|
|
1511
|
+
version: "0.1.10",
|
|
1512
1512
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
1513
1513
|
type: "module",
|
|
1514
1514
|
bin: {
|
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/core/form-schema.ts","../src/core/urls.ts","../src/commands/project.ts","../src/commands/recipe.ts","../src/core/recipes.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/url.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 { registerRecipeCommands } from './commands/recipe.js';\nimport { registerSchemaCommands } from './commands/schema.js';\nimport { registerSetupCommand } from './commands/setup.js';\nimport { registerUpdateCommands } from './commands/update.js';\nimport { registerUrlCommands } from './commands/url.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);\nregisterRecipeCommands(program);\nregisterUrlCommands(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 getProfileDataDir(profileName: string): string {\n return path.join(CONFIG_DIR, 'profiles', profileName);\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","export interface FormField {\n key: string;\n label?: string;\n type?: string;\n required: boolean;\n options?: string[];\n}\n\nexport interface ValidationResult {\n fields: FormField[];\n errors: string[];\n}\n\nconst FIELD_KEY_NAMES = [\n 'key',\n 'field_key',\n 'fieldKey',\n 'field',\n 'code',\n 'prop',\n 'name',\n 'data_index',\n 'dataIndex',\n 'id',\n];\n\nconst FIELD_LABEL_NAMES = ['label', 'title', 'display_name', 'displayName', 'text'];\nconst FIELD_TYPE_NAMES = ['type', 'field_type', 'fieldType', 'value_type', 'valueType', 'control', 'component', 'widget'];\nconst OPTION_NAMES = ['options', 'items', 'choices', 'values'];\nconst REQUIRED_NAMES = ['required', 'is_required', 'isRequired', 'require', 'must'];\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction pickString(source: Record<string, unknown>, keys: string[]): string | undefined {\n for (const key of keys) {\n const value = source[key];\n if (typeof value === 'string' && value.trim()) {\n return value.trim();\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n return String(value);\n }\n }\n return undefined;\n}\n\nfunction pickBoolean(source: Record<string, unknown>, keys: string[]): boolean {\n for (const key of keys) {\n const value = source[key];\n if (typeof value === 'boolean') {\n return value;\n }\n if (value === 1 || value === '1' || value === 'true') {\n return true;\n }\n }\n\n const rules = source.rules;\n if (Array.isArray(rules)) {\n return rules.some((rule) => isRecord(rule) && pickBoolean(rule, REQUIRED_NAMES));\n }\n return false;\n}\n\nfunction optionValue(option: unknown): string | null {\n if (typeof option === 'string' || typeof option === 'number') {\n return String(option);\n }\n if (!isRecord(option)) {\n return null;\n }\n return pickString(option, ['value', 'key', 'id', 'name', 'label', 'title']) ?? null;\n}\n\nfunction pickOptions(source: Record<string, unknown>): string[] | undefined {\n for (const key of OPTION_NAMES) {\n const value = source[key];\n if (!Array.isArray(value)) {\n continue;\n }\n const options = value.map(optionValue).filter((item): item is string => Boolean(item));\n if (options.length > 0) {\n return options;\n }\n }\n return undefined;\n}\n\nfunction fieldFromRecord(source: Record<string, unknown>): FormField | null {\n const key = pickString(source, FIELD_KEY_NAMES);\n if (!key) {\n return null;\n }\n\n const type = pickString(source, FIELD_TYPE_NAMES);\n const label = pickString(source, FIELD_LABEL_NAMES);\n const options = pickOptions(source);\n const required = pickBoolean(source, REQUIRED_NAMES);\n if (!type && !label && !options && !required) {\n return null;\n }\n\n return {\n key,\n ...(label ? { label } : {}),\n ...(type ? { type } : {}),\n required,\n ...(options ? { options } : {}),\n };\n}\n\nfunction collectFieldCandidates(value: unknown, fields: Map<string, FormField>, depth = 0): void {\n if (depth > 8) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n collectFieldCandidates(item, fields, depth + 1);\n }\n return;\n }\n\n if (!isRecord(value)) {\n return;\n }\n\n const field = fieldFromRecord(value);\n if (field) {\n fields.set(field.key, { ...fields.get(field.key), ...field });\n }\n\n for (const child of Object.values(value)) {\n if (isRecord(child) || Array.isArray(child)) {\n collectFieldCandidates(child, fields, depth + 1);\n }\n }\n}\n\nexport function extractFormFields(flowDetail: unknown): FormField[] {\n const fields = new Map<string, FormField>();\n collectFieldCandidates(flowDetail, fields);\n return [...fields.values()].sort((left, right) => left.key.localeCompare(right.key));\n}\n\nfunction isEmpty(value: unknown): boolean {\n return value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);\n}\n\nfunction validateType(field: FormField, value: unknown): string | null {\n const type = field.type?.toLowerCase() ?? '';\n if (!type || isEmpty(value)) {\n return null;\n }\n\n if (field.options) {\n const values = Array.isArray(value) ? value.map(String) : [String(value)];\n const invalid = values.filter((item) => !field.options?.includes(item));\n if (invalid.length > 0) {\n return `${field.key} has invalid option value(s): ${invalid.join(', ')}`;\n }\n }\n\n if (/(number|int|decimal|float|double|amount)/.test(type) && typeof value !== 'number') {\n return `${field.key} must be a number`;\n }\n if (/(boolean|bool|switch|checkbox)/.test(type) && typeof value !== 'boolean') {\n return `${field.key} must be a boolean`;\n }\n if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {\n return `${field.key} must be an array`;\n }\n if (/(string|text|textarea|input|date|time|select|user|department)/.test(type) && typeof value === 'object' && value !== null && !Array.isArray(value)) {\n return `${field.key} must be a scalar value`;\n }\n return null;\n}\n\nexport function validateFormAgainstFields(form: Record<string, unknown>, fields: FormField[]): ValidationResult {\n const byKey = new Map(fields.map((field) => [field.key, field]));\n const errors: string[] = [];\n\n for (const field of fields) {\n if (field.required && isEmpty(form[field.key])) {\n errors.push(`${field.key} is required`);\n }\n }\n\n for (const [key, value] of Object.entries(form)) {\n const field = byKey.get(key);\n if (!field) {\n errors.push(`${key} is not defined in the flow create form`);\n continue;\n }\n const typeError = validateType(field, value);\n if (typeError) {\n errors.push(typeError);\n }\n }\n\n return { fields, errors };\n}\n","import type { ResolvedProfile } from './types.js';\n\nexport type BpmaxUrlKind = 'workspace' | 'project-list' | 'project-detail' | 'project-step';\n\nexport interface BuildBpmaxUrlParams {\n workspace?: string;\n projectId?: string;\n stepId?: string;\n}\n\nexport interface BpmaxUrlResult {\n kind: BpmaxUrlKind;\n profile: string;\n origin: string;\n workspace: string;\n path: string;\n url: string;\n project_id?: string;\n step_id?: string;\n}\n\nexport type ProjectUrlResult<T> = T & { url?: string };\n\nfunction stripSlashes(value: string): string {\n return value.trim().replace(/^\\/+|\\/+$/g, '');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function normalizeWorkspaceForUrl(workspace: string): string {\n const nextWorkspace = stripSlashes(workspace);\n if (!nextWorkspace) {\n throw new Error('Workspace is required to build a BPMAX URL.');\n }\n if (nextWorkspace === 'default' || nextWorkspace.startsWith('w:')) {\n return nextWorkspace;\n }\n return `w:${nextWorkspace}`;\n}\n\nfunction normalizeOrigin(origin: string): string {\n const nextOrigin = origin.trim().replace(/\\/+$/, '');\n if (!nextOrigin) {\n throw new Error('Origin is required to build a BPMAX URL.');\n }\n return nextOrigin;\n}\n\nfunction requireNumericId(value: string | undefined, name: string): string {\n const nextValue = String(value || '').trim();\n if (!/^\\d+$/.test(nextValue)) {\n throw new Error(`${name} must be a non-empty numeric string.`);\n }\n return nextValue;\n}\n\nfunction withQuery(path: string, query: Record<string, string>): string {\n const params = new URLSearchParams(query);\n return `${path}?${params.toString()}`;\n}\n\nexport function buildBpmaxUrl(\n profile: ResolvedProfile,\n kind: BpmaxUrlKind,\n params: BuildBpmaxUrlParams = {},\n): BpmaxUrlResult {\n const origin = normalizeOrigin(profile.config.origin);\n const workspace = normalizeWorkspaceForUrl(params.workspace || profile.config.workspace);\n const basePath = `/${workspace}`;\n let path = basePath;\n const result: Omit<BpmaxUrlResult, 'path' | 'url'> = {\n kind,\n profile: profile.name,\n origin,\n workspace,\n };\n\n if (kind === 'project-list') {\n path = `${basePath}/project`;\n } else if (kind === 'project-detail') {\n const projectId = requireNumericId(params.projectId, 'projectId');\n path = `${basePath}/project_detail/0/${projectId}`;\n result.project_id = projectId;\n } else if (kind === 'project-step') {\n const projectId = requireNumericId(params.projectId, 'projectId');\n const stepId = requireNumericId(params.stepId, 'stepId');\n path = withQuery(`${basePath}/projectContinue`, {\n id: projectId,\n step_id: stepId,\n });\n result.project_id = projectId;\n result.step_id = stepId;\n }\n\n return {\n ...result,\n path,\n url: `${origin}${path}`,\n };\n}\n\nexport function extractProjectId(value: unknown): string | undefined {\n if (!isRecord(value)) {\n return undefined;\n }\n const candidates = [value.id, value.project_id, value.projectId];\n const candidate = candidates.find((item) => item !== undefined && item !== null);\n if (candidate === undefined) {\n return undefined;\n }\n const projectId = String(candidate).trim();\n return /^\\d+$/.test(projectId) ? projectId : undefined;\n}\n\nexport function attachProjectDetailUrl<T>(profile: ResolvedProfile, value: T): ProjectUrlResult<T> {\n if (!isRecord(value) || typeof value.url === 'string') {\n return value as ProjectUrlResult<T>;\n }\n const projectId = extractProjectId(value);\n if (!projectId) {\n return value as ProjectUrlResult<T>;\n }\n return {\n ...value,\n url: buildBpmaxUrl(profile, 'project-detail', { projectId }).url,\n } as ProjectUrlResult<T>;\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { extractFormFields, validateFormAgainstFields } from '../core/form-schema.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport { attachProjectDetailUrl } from '../core/urls.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; flowDetail?: Record<string, unknown> }> {\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 flowDetail: flow,\n };\n}\n\nasync function validateCreateForm(\n client: ReturnType<typeof createApiClient>,\n options: { flowId?: string; flowDetail?: Record<string, unknown>; form: Record<string, unknown> },\n): Promise<void> {\n if (Object.keys(options.form).length === 0) {\n return;\n }\n\n let flowDetail = options.flowDetail;\n if (!flowDetail && options.flowId) {\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 flowDetail = flows[0];\n }\n\n const fields = extractFormFields(flowDetail);\n if (fields.length === 0) {\n throw new Error(\n [\n 'Could not discover the flow create form schema for local validation.',\n 'Re-run with --skip-form-validation only if you intentionally want the server to validate the raw payload.',\n ].join('\\n'),\n );\n }\n\n const result = validateFormAgainstFields(options.form, fields);\n if (result.errors.length > 0) {\n throw new Error(`Form validation failed:\\n- ${result.errors.join('\\n- ')}`);\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, attachProjectDetailUrl(profile, 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('--skip-form-validation', 'Skip local form schema validation before submit')\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 skipFormValidation?: boolean;\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 { flowDetail, ...flowIdentifiers } = flow;\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 ...flowIdentifiers,\n name: options.name,\n workspace: profile.config.workspace,\n form,\n };\n if (!options.skipFormValidation) {\n await validateCreateForm(client, { flowId: options.flowId, flowDetail, 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, attachProjectDetailUrl(profile, result));\n });\n}\n","import { spawn } from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nimport type { Command } from 'commander';\n\nimport { DEFAULT_WORKSPACE, loadConfig, resolveProfile } from '../core/config.js';\nimport { printResult } from '../core/output.js';\nimport {\n getRecipesDir,\n listRecipes,\n loadRecipe,\n mergeVariables,\n renderArgv,\n resolveRecipeLocation,\n writeRecipeScaffold,\n} from '../core/recipes.js';\nimport type { ConfigFileV2, OutputFormat } from '../core/types.js';\n\ntype RunRecipe = (argv: string[]) => Promise<number>;\n\nexport interface RecipeCommandDeps {\n loadConfig?: typeof loadConfig;\n getProfileDataDir?: (profileName: string) => string;\n runRecipe?: RunRecipe;\n}\n\nfunction currentCliInvocation(): { command: string; argsPrefix: string[] } {\n const entry = process.argv[1] || fileURLToPath(import.meta.url);\n return {\n command: process.execPath,\n argsPrefix: [entry],\n };\n}\n\nfunction defaultRunRecipe(argv: string[]): Promise<number> {\n const invocation = currentCliInvocation();\n return new Promise((resolve, reject) => {\n const child = spawn(invocation.command, [...invocation.argsPrefix, ...argv], {\n stdio: 'inherit',\n shell: false,\n });\n child.on('error', reject);\n child.on('close', (code) => resolve(code ?? 1));\n });\n}\n\nfunction resolveTargetProfile(configData: ConfigFileV2, profileName?: string) {\n const resolved = resolveProfile(configData, profileName);\n return {\n name: resolved.name,\n workspace: resolved.config.workspace || DEFAULT_WORKSPACE,\n };\n}\n\nfunction collectVarEntries(value?: string | string[]): string[] {\n if (!value) {\n return [];\n }\n return Array.isArray(value) ? value : [value];\n}\n\nexport function registerRecipeCommands(program: Command, deps: RecipeCommandDeps = {}): void {\n const load = deps.loadConfig || loadConfig;\n const getProfileDir = deps.getProfileDataDir;\n const runRecipe = deps.runRecipe || defaultRunRecipe;\n const recipe = program.command('recipe').description('Manage profile-scoped BPMAX recipes');\n\n recipe\n .command('init <name>')\n .description('Create a scaffold for a profile/workspace recipe')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--title <title>', 'Recipe title')\n .option('--force', 'Overwrite existing scaffold files')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (name: string, options: { profile?: string; workspace?: string; title?: string; force?: boolean; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n await writeRecipeScaffold({ location, title: options.title, force: options.force });\n printResult(options.format, {\n name,\n profile: target.name,\n workspace: location.workspaceDirName,\n path: location.recipeDir,\n });\n });\n\n recipe\n .command('list')\n .description('List recipes for a profile/workspace')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const workspace = options.workspace || target.workspace;\n const rows = await listRecipes(getRecipesDir({ profileName: target.name, workspace, getProfileDir }));\n printResult(options.format, rows);\n });\n\n recipe\n .command('show <name>')\n .description('Show a recipe definition')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (name: string, options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n const definition = await loadRecipe(location.recipeDir);\n printResult(options.format, {\n ...definition,\n profile: target.name,\n path: location.recipeDir,\n });\n });\n\n recipe\n .command('path <name>')\n .description('Print a recipe directory path')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .action(async (name: string, options: { profile?: string; workspace?: string }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n console.log(location.recipeDir);\n });\n\n recipe\n .command('run <name>')\n .description('Render and run a profile/workspace recipe through bpmax-cli')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--var <entry>', 'Recipe variable as key=value', (value, previous: string[] = []) => [...previous, value], [])\n .option('--vars <json>', 'Recipe variables JSON object')\n .option('--yes', 'Confirm running a mutating recipe')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (name: string, options: { profile?: string; workspace?: string; var?: string[]; vars?: string; yes?: boolean; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n const definition = await loadRecipe(location.recipeDir);\n if (definition.command.mutating && !options.yes) {\n throw new Error('Recipe is marked as mutating. Re-run with --yes to execute it.');\n }\n const variables = mergeVariables(options.vars, collectVarEntries(options.var));\n const argv = await renderArgv({\n recipe: definition,\n recipeDir: location.recipeDir,\n variables,\n profileName: target.name,\n });\n const exitCode = await runRecipe(argv);\n if (exitCode !== 0) {\n throw new Error(`Recipe command failed with exit code ${exitCode}.`);\n }\n if (options.format === 'json') {\n printResult('json', { name, profile: target.name, workspace: location.workspaceDirName, argv, exitCode });\n }\n });\n}\n","import { access, mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { DEFAULT_WORKSPACE, getProfileDataDir } from './config.js';\n\nexport interface RecipeVariable {\n name: string;\n required?: boolean;\n}\n\nexport interface RecipeCommand {\n argv: string[];\n mutating?: boolean;\n}\n\nexport interface RecipeDefinition {\n version: 1;\n name: string;\n title?: string;\n description?: string;\n workspace?: string;\n variables?: RecipeVariable[];\n command: RecipeCommand;\n}\n\nexport interface RecipeLocation {\n profileName: string;\n workspace: string;\n workspaceDirName: string;\n recipeName: string;\n recipeDir: string;\n}\n\nexport interface RecipeSummary {\n name: string;\n title?: string;\n description?: string;\n workspace?: string;\n path: string;\n mutating: boolean;\n}\n\nexport type RecipeVariables = Record<string, string>;\n\nconst RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;\nconst TEMPLATE_PATTERN = /{{\\s*([a-zA-Z0-9_.-]+)\\s*}}/g;\n\nfunction assertSafeName(kind: string, value: string): void {\n if (!RECIPE_NAME_PATTERN.test(value) || value.includes('..') || value.includes('/') || value.includes('\\\\')) {\n throw new Error(`${kind} must contain only letters, numbers, dots, underscores, and dashes.`);\n }\n}\n\nexport function normalizeWorkspaceForPath(workspace?: string): string {\n const normalized = (workspace || DEFAULT_WORKSPACE).trim() || DEFAULT_WORKSPACE;\n const withoutPrefix = normalized.startsWith('w:') ? normalized.slice(2) : normalized;\n assertSafeName('Workspace', withoutPrefix);\n return withoutPrefix;\n}\n\nexport function resolveRecipeLocation(options: {\n profileName: string;\n workspace?: string;\n recipeName: string;\n getProfileDir?: (profileName: string) => string;\n}): RecipeLocation {\n assertSafeName('Recipe name', options.recipeName);\n const workspace = options.workspace || DEFAULT_WORKSPACE;\n const workspaceDirName = normalizeWorkspaceForPath(workspace);\n const profileDir = (options.getProfileDir || getProfileDataDir)(options.profileName);\n return {\n profileName: options.profileName,\n workspace,\n workspaceDirName,\n recipeName: options.recipeName,\n recipeDir: path.join(profileDir, 'recipes', workspaceDirName, options.recipeName),\n };\n}\n\nexport function getRecipesDir(options: {\n profileName: string;\n workspace?: string;\n getProfileDir?: (profileName: string) => string;\n}): string {\n const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);\n return path.join((options.getProfileDir || getProfileDataDir)(options.profileName), 'recipes', workspaceDirName);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asString(value: unknown, fieldName: string): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`${fieldName} must be a non-empty string.`);\n }\n return value;\n}\n\nexport function parseRecipeDefinition(input: unknown): RecipeDefinition {\n if (!isRecord(input)) {\n throw new Error('recipe.json must be a JSON object.');\n }\n if (input.version !== 1) {\n throw new Error('recipe.json version must be 1.');\n }\n const name = asString(input.name, 'recipe.name');\n assertSafeName('Recipe name', name);\n if (!isRecord(input.command)) {\n throw new Error('recipe.command must be an object.');\n }\n const argv = input.command.argv;\n if (!Array.isArray(argv) || argv.some((item) => typeof item !== 'string' || item.length === 0)) {\n throw new Error('recipe.command.argv must be a non-empty string array.');\n }\n\n const variables = Array.isArray(input.variables)\n ? input.variables.map((item, index) => {\n if (!isRecord(item)) {\n throw new Error(`recipe.variables[${index}] must be an object.`);\n }\n const variableName = asString(item.name, `recipe.variables[${index}].name`);\n assertSafeName('Variable name', variableName);\n return {\n name: variableName,\n required: item.required === undefined ? undefined : Boolean(item.required),\n };\n })\n : undefined;\n\n return {\n version: 1,\n name,\n ...(typeof input.title === 'string' ? { title: input.title } : {}),\n ...(typeof input.description === 'string' ? { description: input.description } : {}),\n ...(typeof input.workspace === 'string' ? { workspace: input.workspace } : {}),\n ...(variables ? { variables } : {}),\n command: {\n argv: argv as string[],\n mutating: Boolean(input.command.mutating),\n },\n };\n}\n\nexport async function loadRecipe(recipeDir: string): Promise<RecipeDefinition> {\n const raw = await readFile(path.join(recipeDir, 'recipe.json'), 'utf8');\n return parseRecipeDefinition(JSON.parse(raw));\n}\n\nexport async function listRecipes(recipesDir: string): Promise<RecipeSummary[]> {\n let entries: string[];\n try {\n entries = await readdir(recipesDir);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw error;\n }\n\n const summaries: RecipeSummary[] = [];\n for (const entry of entries.sort()) {\n if (!RECIPE_NAME_PATTERN.test(entry)) {\n continue;\n }\n const recipeDir = path.join(recipesDir, entry);\n try {\n const recipe = await loadRecipe(recipeDir);\n summaries.push({\n name: recipe.name,\n title: recipe.title,\n description: recipe.description,\n workspace: recipe.workspace,\n path: recipeDir,\n mutating: Boolean(recipe.command.mutating),\n });\n } catch {\n // Ignore malformed directories in list output; `recipe show` reports exact errors.\n }\n }\n return summaries;\n}\n\nexport function parseVarEntries(entries: string[] = []): RecipeVariables {\n const variables: RecipeVariables = {};\n for (const entry of entries) {\n const index = entry.indexOf('=');\n if (index <= 0) {\n throw new Error(`Invalid --var value \"${entry}\". Expected key=value.`);\n }\n const key = entry.slice(0, index);\n assertSafeName('Variable name', key);\n variables[key] = entry.slice(index + 1);\n }\n return variables;\n}\n\nexport function parseVarsJson(input?: string): RecipeVariables {\n if (!input) {\n return {};\n }\n const parsed = JSON.parse(input) as unknown;\n if (!isRecord(parsed)) {\n throw new Error('--vars must be a JSON object.');\n }\n const variables: RecipeVariables = {};\n for (const [key, value] of Object.entries(parsed)) {\n assertSafeName('Variable name', key);\n variables[key] = String(value);\n }\n return variables;\n}\n\nexport function mergeVariables(varsJson?: string, varEntries: string[] = []): RecipeVariables {\n return {\n ...parseVarsJson(varsJson),\n ...parseVarEntries(varEntries),\n };\n}\n\nexport function validateRequiredVariables(recipe: RecipeDefinition, variables: RecipeVariables): void {\n const missing = (recipe.variables || [])\n .filter((variable) => variable.required && !Object.prototype.hasOwnProperty.call(variables, variable.name))\n .map((variable) => variable.name);\n if (missing.length > 0) {\n throw new Error(`Missing required recipe variable(s): ${missing.join(', ')}.`);\n }\n}\n\nexport function renderTemplate(template: string, variables: RecipeVariables): string {\n return template.replace(TEMPLATE_PATTERN, (match, variableName: string) => {\n if (!Object.prototype.hasOwnProperty.call(variables, variableName)) {\n throw new Error(`Missing recipe variable: ${variableName}.`);\n }\n return variables[variableName];\n });\n}\n\nfunction resolveRecipeFile(recipeDir: string, token: string): string {\n const relative = token.slice(1);\n if (!relative || relative.includes('..') || path.isAbsolute(relative)) {\n throw new Error(`Unsafe recipe file reference: ${token}`);\n }\n const resolved = path.resolve(recipeDir, relative);\n const root = path.resolve(recipeDir);\n if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`)) {\n throw new Error(`Recipe file reference escapes recipe directory: ${token}`);\n }\n return resolved;\n}\n\nexport async function renderArgv(options: {\n recipe: RecipeDefinition;\n recipeDir: string;\n variables: RecipeVariables;\n profileName: string;\n}): Promise<string[]> {\n validateRequiredVariables(options.recipe, options.variables);\n const rendered: string[] = [];\n for (const token of options.recipe.command.argv) {\n if (token.startsWith('@')) {\n const raw = await readFile(resolveRecipeFile(options.recipeDir, token), 'utf8');\n rendered.push(renderTemplate(raw, options.variables));\n } else {\n rendered.push(renderTemplate(token, options.variables));\n }\n }\n\n if (!rendered.includes('--profile')) {\n rendered.push('--profile', options.profileName);\n }\n return rendered;\n}\n\nexport async function ensureEmptyOrForce(targetDir: string, force = false): Promise<void> {\n try {\n await access(targetDir);\n if (!force) {\n throw new Error(`Recipe already exists at ${targetDir}. Re-run with --force to overwrite scaffold files.`);\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function writeRecipeScaffold(options: {\n location: RecipeLocation;\n title?: string;\n force?: boolean;\n}): Promise<void> {\n await ensureEmptyOrForce(options.location.recipeDir, options.force);\n await mkdir(options.location.recipeDir, { recursive: true });\n const title = options.title || options.location.recipeName;\n const recipe: RecipeDefinition = {\n version: 1,\n name: options.location.recipeName,\n title,\n description: 'Describe what this BPMAX environment recipe does.',\n workspace: options.location.workspaceDirName,\n variables: [{ name: 'name', required: true }],\n command: {\n argv: ['project', 'create', '--body', '@payload.json', '--format', 'json'],\n mutating: true,\n },\n };\n await writeFile(path.join(options.location.recipeDir, 'recipe.json'), `${JSON.stringify(recipe, null, 2)}\\n`, 'utf8');\n await writeFile(\n path.join(options.location.recipeDir, 'payload.json'),\n `${JSON.stringify({ name: '{{name}}' }, null, 2)}\\n`,\n 'utf8',\n );\n await writeFile(\n path.join(options.location.recipeDir, 'README.md'),\n [`# ${title}`, '', 'Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.', ''].join('\\n'),\n 'utf8',\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: 'Create a project with local form schema validation when form payload is provided.', 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.9\",\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 { printResult } from '../core/output.js';\nimport { buildBpmaxUrl, type BpmaxUrlKind, type BpmaxUrlResult } from '../core/urls.js';\nimport type { ConfigFileV2, OutputFormat } from '../core/types.js';\n\nexport interface UrlCommandDeps {\n loadConfig?: typeof loadConfig;\n}\n\nfunction printUrl(format: OutputFormat, result: BpmaxUrlResult): void {\n if (format === 'pretty') {\n console.log(result.url);\n return;\n }\n printResult(format, result);\n}\n\nasync function resolveUrl(\n load: () => Promise<ConfigFileV2>,\n kind: BpmaxUrlKind,\n options: { profile?: string; workspace?: string; format: OutputFormat; projectId?: string; stepId?: string },\n): Promise<void> {\n const config = await load();\n const profile = resolveProfile(config, options.profile);\n printUrl(\n options.format,\n buildBpmaxUrl(profile, kind, {\n workspace: options.workspace,\n projectId: options.projectId,\n stepId: options.stepId,\n }),\n );\n}\n\nexport function registerUrlCommands(program: Command, deps: UrlCommandDeps = {}): void {\n const load = deps.loadConfig || loadConfig;\n const url = program.command('url').description('Generate BPMAX web URLs');\n\n url\n .command('workspace')\n .description('Generate the current workspace URL')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n await resolveUrl(load, 'workspace', options);\n });\n\n url\n .command('project-list')\n .description('Generate the project list URL')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n await resolveUrl(load, 'project-list', options);\n });\n\n url\n .command('project-detail <projectId>')\n .description('Generate a project detail URL')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(\n async (\n projectId: string,\n options: { profile?: string; workspace?: string; format: OutputFormat },\n ) => {\n await resolveUrl(load, 'project-detail', { ...options, projectId });\n },\n );\n\n url\n .command('project-step <projectId>')\n .description('Generate a project step processing URL')\n .requiredOption('--step-id <stepId>', 'Step id')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(\n async (\n projectId: string,\n options: { profile?: string; workspace?: string; stepId: string; format: OutputFormat },\n ) => {\n await resolveUrl(load, 'project-step', { ...options, projectId });\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,gBAAgB,QAAQ,UAAU,EAAE;AAAA,YAC5C,WAAW,QAAQ,aAAa;AAAA,YAChC,UAAU,QAAQ,YAAY;AAAA,UAChC;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS;AACf,QAAM,WA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program","isRecord","isRecord","normalizeOrigin","path","parseJson","program","mkdir","readFile","writeFile","path","path","isRecord","readFile","mkdir","writeFile","program","program","text","index","text","program","loadConfig","saveConfig","mkdir","readFile","writeFile","path","fileURLToPath","spawn","path","readFile","mkdir","writeFile","fileURLToPath","access","mkdir","readFile","writeFile","path","path","readFile","mkdir","writeFile","program","body","synced","program","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/core/form-schema.ts","../src/core/urls.ts","../src/commands/project.ts","../src/commands/recipe.ts","../src/core/recipes.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/url.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 { registerRecipeCommands } from './commands/recipe.js';\nimport { registerSchemaCommands } from './commands/schema.js';\nimport { registerSetupCommand } from './commands/setup.js';\nimport { registerUpdateCommands } from './commands/update.js';\nimport { registerUrlCommands } from './commands/url.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);\nregisterRecipeCommands(program);\nregisterUrlCommands(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 getProfileDataDir(profileName: string): string {\n return path.join(CONFIG_DIR, 'profiles', profileName);\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","export interface FormField {\n key: string;\n label?: string;\n type?: string;\n required: boolean;\n options?: string[];\n}\n\nexport interface ValidationResult {\n fields: FormField[];\n errors: string[];\n}\n\nconst FIELD_KEY_NAMES = [\n 'key',\n 'field_key',\n 'fieldKey',\n 'field',\n 'code',\n 'prop',\n 'name',\n 'data_index',\n 'dataIndex',\n 'id',\n];\n\nconst FIELD_LABEL_NAMES = ['label', 'title', 'display_name', 'displayName', 'text'];\nconst FIELD_TYPE_NAMES = ['type', 'field_type', 'fieldType', 'value_type', 'valueType', 'control', 'component', 'widget'];\nconst OPTION_NAMES = ['options', 'items', 'choices', 'values'];\nconst REQUIRED_NAMES = ['required', 'is_required', 'isRequired', 'require', 'must'];\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction pickString(source: Record<string, unknown>, keys: string[]): string | undefined {\n for (const key of keys) {\n const value = source[key];\n if (typeof value === 'string' && value.trim()) {\n return value.trim();\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n return String(value);\n }\n }\n return undefined;\n}\n\nfunction pickBoolean(source: Record<string, unknown>, keys: string[]): boolean {\n for (const key of keys) {\n const value = source[key];\n if (typeof value === 'boolean') {\n return value;\n }\n if (value === 1 || value === '1' || value === 'true') {\n return true;\n }\n }\n\n const rules = source.rules;\n if (Array.isArray(rules)) {\n return rules.some((rule) => isRecord(rule) && pickBoolean(rule, REQUIRED_NAMES));\n }\n return false;\n}\n\nfunction optionValue(option: unknown): string | null {\n if (typeof option === 'string' || typeof option === 'number') {\n return String(option);\n }\n if (!isRecord(option)) {\n return null;\n }\n return pickString(option, ['value', 'key', 'id', 'name', 'label', 'title']) ?? null;\n}\n\nfunction pickOptions(source: Record<string, unknown>): string[] | undefined {\n for (const key of OPTION_NAMES) {\n const value = source[key];\n if (!Array.isArray(value)) {\n continue;\n }\n const options = value.map(optionValue).filter((item): item is string => Boolean(item));\n if (options.length > 0) {\n return options;\n }\n }\n return undefined;\n}\n\nfunction fieldFromRecord(source: Record<string, unknown>): FormField | null {\n const key = pickString(source, FIELD_KEY_NAMES);\n if (!key) {\n return null;\n }\n\n const type = pickString(source, FIELD_TYPE_NAMES);\n const label = pickString(source, FIELD_LABEL_NAMES);\n const options = pickOptions(source);\n const required = pickBoolean(source, REQUIRED_NAMES);\n if (!type && !label && !options && !required) {\n return null;\n }\n\n return {\n key,\n ...(label ? { label } : {}),\n ...(type ? { type } : {}),\n required,\n ...(options ? { options } : {}),\n };\n}\n\nfunction collectFieldCandidates(value: unknown, fields: Map<string, FormField>, depth = 0): void {\n if (depth > 8) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n collectFieldCandidates(item, fields, depth + 1);\n }\n return;\n }\n\n if (!isRecord(value)) {\n return;\n }\n\n const field = fieldFromRecord(value);\n if (field) {\n fields.set(field.key, { ...fields.get(field.key), ...field });\n }\n\n for (const child of Object.values(value)) {\n if (isRecord(child) || Array.isArray(child)) {\n collectFieldCandidates(child, fields, depth + 1);\n }\n }\n}\n\nexport function extractFormFields(flowDetail: unknown): FormField[] {\n const fields = new Map<string, FormField>();\n collectFieldCandidates(flowDetail, fields);\n return [...fields.values()].sort((left, right) => left.key.localeCompare(right.key));\n}\n\nfunction isEmpty(value: unknown): boolean {\n return value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);\n}\n\nfunction validateType(field: FormField, value: unknown): string | null {\n const type = field.type?.toLowerCase() ?? '';\n if (!type || isEmpty(value)) {\n return null;\n }\n\n if (field.options) {\n const values = Array.isArray(value) ? value.map(String) : [String(value)];\n const invalid = values.filter((item) => !field.options?.includes(item));\n if (invalid.length > 0) {\n return `${field.key} has invalid option value(s): ${invalid.join(', ')}`;\n }\n }\n\n if (/(number|int|decimal|float|double|amount)/.test(type) && typeof value !== 'number') {\n return `${field.key} must be a number`;\n }\n if (/(boolean|bool|switch|checkbox)/.test(type) && typeof value !== 'boolean') {\n return `${field.key} must be a boolean`;\n }\n if (/(array|multi|multiple)/.test(type) && !Array.isArray(value)) {\n return `${field.key} must be an array`;\n }\n if (/(string|text|textarea|input|date|time|select|user|department)/.test(type) && typeof value === 'object' && value !== null && !Array.isArray(value)) {\n return `${field.key} must be a scalar value`;\n }\n return null;\n}\n\nexport function validateFormAgainstFields(form: Record<string, unknown>, fields: FormField[]): ValidationResult {\n const byKey = new Map(fields.map((field) => [field.key, field]));\n const errors: string[] = [];\n\n for (const field of fields) {\n if (field.required && isEmpty(form[field.key])) {\n errors.push(`${field.key} is required`);\n }\n }\n\n for (const [key, value] of Object.entries(form)) {\n const field = byKey.get(key);\n if (!field) {\n errors.push(`${key} is not defined in the flow create form`);\n continue;\n }\n const typeError = validateType(field, value);\n if (typeError) {\n errors.push(typeError);\n }\n }\n\n return { fields, errors };\n}\n","import type { ResolvedProfile } from './types.js';\n\nexport type BpmaxUrlKind = 'workspace' | 'project-list' | 'project-detail' | 'project-step';\n\nexport interface BuildBpmaxUrlParams {\n workspace?: string;\n projectId?: string;\n stepId?: string;\n}\n\nexport interface BpmaxUrlResult {\n kind: BpmaxUrlKind;\n profile: string;\n origin: string;\n workspace: string;\n path: string;\n url: string;\n project_id?: string;\n step_id?: string;\n}\n\nexport type ProjectUrlResult<T> = T & { url?: string };\n\nfunction stripSlashes(value: string): string {\n return value.trim().replace(/^\\/+|\\/+$/g, '');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function normalizeWorkspaceForUrl(workspace: string): string {\n const nextWorkspace = stripSlashes(workspace);\n if (!nextWorkspace) {\n throw new Error('Workspace is required to build a BPMAX URL.');\n }\n if (nextWorkspace === 'default' || nextWorkspace.startsWith('w:')) {\n return nextWorkspace;\n }\n return `w:${nextWorkspace}`;\n}\n\nfunction normalizeOrigin(origin: string): string {\n const nextOrigin = origin.trim().replace(/\\/+$/, '');\n if (!nextOrigin) {\n throw new Error('Origin is required to build a BPMAX URL.');\n }\n return nextOrigin;\n}\n\nfunction requireNumericId(value: string | undefined, name: string): string {\n const nextValue = String(value || '').trim();\n if (!/^\\d+$/.test(nextValue)) {\n throw new Error(`${name} must be a non-empty numeric string.`);\n }\n return nextValue;\n}\n\nfunction withQuery(path: string, query: Record<string, string>): string {\n const params = new URLSearchParams(query);\n return `${path}?${params.toString()}`;\n}\n\nexport function buildBpmaxUrl(\n profile: ResolvedProfile,\n kind: BpmaxUrlKind,\n params: BuildBpmaxUrlParams = {},\n): BpmaxUrlResult {\n const origin = normalizeOrigin(profile.config.origin);\n const workspace = normalizeWorkspaceForUrl(params.workspace || profile.config.workspace);\n const basePath = `/${workspace}`;\n let path = basePath;\n const result: Omit<BpmaxUrlResult, 'path' | 'url'> = {\n kind,\n profile: profile.name,\n origin,\n workspace,\n };\n\n if (kind === 'project-list') {\n path = `${basePath}/project`;\n } else if (kind === 'project-detail') {\n const projectId = requireNumericId(params.projectId, 'projectId');\n path = `${basePath}/project_detail/0/${projectId}`;\n result.project_id = projectId;\n } else if (kind === 'project-step') {\n const projectId = requireNumericId(params.projectId, 'projectId');\n const stepId = requireNumericId(params.stepId, 'stepId');\n path = withQuery(`${basePath}/projectContinue`, {\n id: projectId,\n step_id: stepId,\n });\n result.project_id = projectId;\n result.step_id = stepId;\n }\n\n return {\n ...result,\n path,\n url: `${origin}${path}`,\n };\n}\n\nexport function extractProjectId(value: unknown): string | undefined {\n if (!isRecord(value)) {\n return undefined;\n }\n const candidates = [value.id, value.project_id, value.projectId];\n const candidate = candidates.find((item) => item !== undefined && item !== null);\n if (candidate === undefined) {\n return undefined;\n }\n const projectId = String(candidate).trim();\n return /^\\d+$/.test(projectId) ? projectId : undefined;\n}\n\nexport function attachProjectDetailUrl<T>(profile: ResolvedProfile, value: T): ProjectUrlResult<T> {\n if (!isRecord(value) || typeof value.url === 'string') {\n return value as ProjectUrlResult<T>;\n }\n const projectId = extractProjectId(value);\n if (!projectId) {\n return value as ProjectUrlResult<T>;\n }\n return {\n ...value,\n url: buildBpmaxUrl(profile, 'project-detail', { projectId }).url,\n } as ProjectUrlResult<T>;\n}\n","import type { Command } from 'commander';\n\nimport { loadConfig, resolveProfile } from '../core/config.js';\nimport { extractFormFields, validateFormAgainstFields } from '../core/form-schema.js';\nimport { createApiClient, apiRequest } from '../core/http.js';\nimport { printResult } from '../core/output.js';\nimport { attachProjectDetailUrl } from '../core/urls.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; flowDetail?: Record<string, unknown> }> {\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 flowDetail: flow,\n };\n}\n\nasync function validateCreateForm(\n client: ReturnType<typeof createApiClient>,\n options: { flowId?: string; flowDetail?: Record<string, unknown>; form: Record<string, unknown> },\n): Promise<void> {\n if (Object.keys(options.form).length === 0) {\n return;\n }\n\n let flowDetail = options.flowDetail;\n if (!flowDetail && options.flowId) {\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 flowDetail = flows[0];\n }\n\n const fields = extractFormFields(flowDetail);\n if (fields.length === 0) {\n throw new Error(\n [\n 'Could not discover the flow create form schema for local validation.',\n 'Re-run with --skip-form-validation only if you intentionally want the server to validate the raw payload.',\n ].join('\\n'),\n );\n }\n\n const result = validateFormAgainstFields(options.form, fields);\n if (result.errors.length > 0) {\n throw new Error(`Form validation failed:\\n- ${result.errors.join('\\n- ')}`);\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, attachProjectDetailUrl(profile, 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('--skip-form-validation', 'Skip local form schema validation before submit')\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 skipFormValidation?: boolean;\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 { flowDetail, ...flowIdentifiers } = flow;\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 ...flowIdentifiers,\n name: options.name,\n workspace: profile.config.workspace,\n form,\n };\n if (!options.skipFormValidation) {\n await validateCreateForm(client, { flowId: options.flowId, flowDetail, 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, attachProjectDetailUrl(profile, result));\n });\n}\n","import { spawn } from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nimport type { Command } from 'commander';\n\nimport { DEFAULT_WORKSPACE, loadConfig, resolveProfile } from '../core/config.js';\nimport { printResult } from '../core/output.js';\nimport {\n getRecipesDir,\n listRecipes,\n loadRecipe,\n mergeVariables,\n renderArgv,\n resolveRecipeLocation,\n writeRecipeScaffold,\n} from '../core/recipes.js';\nimport type { ConfigFileV2, OutputFormat } from '../core/types.js';\n\ntype RunRecipe = (argv: string[]) => Promise<number>;\n\nexport interface RecipeCommandDeps {\n loadConfig?: typeof loadConfig;\n getProfileDataDir?: (profileName: string) => string;\n runRecipe?: RunRecipe;\n}\n\nfunction currentCliInvocation(): { command: string; argsPrefix: string[] } {\n const entry = process.argv[1] || fileURLToPath(import.meta.url);\n return {\n command: process.execPath,\n argsPrefix: [entry],\n };\n}\n\nfunction defaultRunRecipe(argv: string[]): Promise<number> {\n const invocation = currentCliInvocation();\n return new Promise((resolve, reject) => {\n const child = spawn(invocation.command, [...invocation.argsPrefix, ...argv], {\n stdio: 'inherit',\n shell: false,\n });\n child.on('error', reject);\n child.on('close', (code) => resolve(code ?? 1));\n });\n}\n\nfunction resolveTargetProfile(configData: ConfigFileV2, profileName?: string) {\n const resolved = resolveProfile(configData, profileName);\n return {\n name: resolved.name,\n workspace: resolved.config.workspace || DEFAULT_WORKSPACE,\n };\n}\n\nfunction collectVarEntries(value?: string | string[]): string[] {\n if (!value) {\n return [];\n }\n return Array.isArray(value) ? value : [value];\n}\n\nexport function registerRecipeCommands(program: Command, deps: RecipeCommandDeps = {}): void {\n const load = deps.loadConfig || loadConfig;\n const getProfileDir = deps.getProfileDataDir;\n const runRecipe = deps.runRecipe || defaultRunRecipe;\n const recipe = program.command('recipe').description('Manage profile-scoped BPMAX recipes');\n\n recipe\n .command('init <name>')\n .description('Create a scaffold for a profile/workspace recipe')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--title <title>', 'Recipe title')\n .option('--force', 'Overwrite existing scaffold files')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (name: string, options: { profile?: string; workspace?: string; title?: string; force?: boolean; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n await writeRecipeScaffold({ location, title: options.title, force: options.force });\n printResult(options.format, {\n name,\n profile: target.name,\n workspace: location.workspaceDirName,\n path: location.recipeDir,\n });\n });\n\n recipe\n .command('list')\n .description('List recipes for a profile/workspace')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'table')\n .action(async (options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const workspace = options.workspace || target.workspace;\n const rows = await listRecipes(getRecipesDir({ profileName: target.name, workspace, getProfileDir }));\n printResult(options.format, rows);\n });\n\n recipe\n .command('show <name>')\n .description('Show a recipe definition')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (name: string, options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n const definition = await loadRecipe(location.recipeDir);\n printResult(options.format, {\n ...definition,\n profile: target.name,\n path: location.recipeDir,\n });\n });\n\n recipe\n .command('path <name>')\n .description('Print a recipe directory path')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .action(async (name: string, options: { profile?: string; workspace?: string }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n console.log(location.recipeDir);\n });\n\n recipe\n .command('run <name>')\n .description('Render and run a profile/workspace recipe through bpmax-cli')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--var <entry>', 'Recipe variable as key=value', (value, previous: string[] = []) => [...previous, value], [])\n .option('--vars <json>', 'Recipe variables JSON object')\n .option('--yes', 'Confirm running a mutating recipe')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (name: string, options: { profile?: string; workspace?: string; var?: string[]; vars?: string; yes?: boolean; format: OutputFormat }) => {\n const configData = await load();\n const target = resolveTargetProfile(configData, options.profile);\n const location = resolveRecipeLocation({\n profileName: target.name,\n workspace: options.workspace || target.workspace,\n recipeName: name,\n getProfileDir,\n });\n const definition = await loadRecipe(location.recipeDir);\n if (definition.command.mutating && !options.yes) {\n throw new Error('Recipe is marked as mutating. Re-run with --yes to execute it.');\n }\n const variables = mergeVariables(options.vars, collectVarEntries(options.var));\n const argv = await renderArgv({\n recipe: definition,\n recipeDir: location.recipeDir,\n variables,\n profileName: target.name,\n });\n const exitCode = await runRecipe(argv);\n if (exitCode !== 0) {\n throw new Error(`Recipe command failed with exit code ${exitCode}.`);\n }\n if (options.format === 'json') {\n printResult('json', { name, profile: target.name, workspace: location.workspaceDirName, argv, exitCode });\n }\n });\n}\n","import { access, mkdir, readdir, readFile, writeFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { DEFAULT_WORKSPACE, getProfileDataDir } from './config.js';\n\nexport interface RecipeVariable {\n name: string;\n required?: boolean;\n}\n\nexport interface RecipeCommand {\n argv: string[];\n mutating?: boolean;\n}\n\nexport interface RecipeDefinition {\n version: 1;\n name: string;\n title?: string;\n description?: string;\n workspace?: string;\n variables?: RecipeVariable[];\n command: RecipeCommand;\n}\n\nexport interface RecipeLocation {\n profileName: string;\n workspace: string;\n workspaceDirName: string;\n recipeName: string;\n recipeDir: string;\n}\n\nexport interface RecipeSummary {\n name: string;\n title?: string;\n description?: string;\n workspace?: string;\n path: string;\n mutating: boolean;\n}\n\nexport type RecipeVariables = Record<string, string>;\n\nconst RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;\nconst TEMPLATE_PATTERN = /{{\\s*([a-zA-Z0-9_.-]+)\\s*}}/g;\n\nfunction assertSafeName(kind: string, value: string): void {\n if (!RECIPE_NAME_PATTERN.test(value) || value.includes('..') || value.includes('/') || value.includes('\\\\')) {\n throw new Error(`${kind} must contain only letters, numbers, dots, underscores, and dashes.`);\n }\n}\n\nexport function normalizeWorkspaceForPath(workspace?: string): string {\n const normalized = (workspace || DEFAULT_WORKSPACE).trim() || DEFAULT_WORKSPACE;\n const withoutPrefix = normalized.startsWith('w:') ? normalized.slice(2) : normalized;\n assertSafeName('Workspace', withoutPrefix);\n return withoutPrefix;\n}\n\nexport function resolveRecipeLocation(options: {\n profileName: string;\n workspace?: string;\n recipeName: string;\n getProfileDir?: (profileName: string) => string;\n}): RecipeLocation {\n assertSafeName('Recipe name', options.recipeName);\n const workspace = options.workspace || DEFAULT_WORKSPACE;\n const workspaceDirName = normalizeWorkspaceForPath(workspace);\n const profileDir = (options.getProfileDir || getProfileDataDir)(options.profileName);\n return {\n profileName: options.profileName,\n workspace,\n workspaceDirName,\n recipeName: options.recipeName,\n recipeDir: path.join(profileDir, 'recipes', workspaceDirName, options.recipeName),\n };\n}\n\nexport function getRecipesDir(options: {\n profileName: string;\n workspace?: string;\n getProfileDir?: (profileName: string) => string;\n}): string {\n const workspaceDirName = normalizeWorkspaceForPath(options.workspace || DEFAULT_WORKSPACE);\n return path.join((options.getProfileDir || getProfileDataDir)(options.profileName), 'recipes', workspaceDirName);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asString(value: unknown, fieldName: string): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new Error(`${fieldName} must be a non-empty string.`);\n }\n return value;\n}\n\nexport function parseRecipeDefinition(input: unknown): RecipeDefinition {\n if (!isRecord(input)) {\n throw new Error('recipe.json must be a JSON object.');\n }\n if (input.version !== 1) {\n throw new Error('recipe.json version must be 1.');\n }\n const name = asString(input.name, 'recipe.name');\n assertSafeName('Recipe name', name);\n if (!isRecord(input.command)) {\n throw new Error('recipe.command must be an object.');\n }\n const argv = input.command.argv;\n if (!Array.isArray(argv) || argv.some((item) => typeof item !== 'string' || item.length === 0)) {\n throw new Error('recipe.command.argv must be a non-empty string array.');\n }\n\n const variables = Array.isArray(input.variables)\n ? input.variables.map((item, index) => {\n if (!isRecord(item)) {\n throw new Error(`recipe.variables[${index}] must be an object.`);\n }\n const variableName = asString(item.name, `recipe.variables[${index}].name`);\n assertSafeName('Variable name', variableName);\n return {\n name: variableName,\n required: item.required === undefined ? undefined : Boolean(item.required),\n };\n })\n : undefined;\n\n return {\n version: 1,\n name,\n ...(typeof input.title === 'string' ? { title: input.title } : {}),\n ...(typeof input.description === 'string' ? { description: input.description } : {}),\n ...(typeof input.workspace === 'string' ? { workspace: input.workspace } : {}),\n ...(variables ? { variables } : {}),\n command: {\n argv: argv as string[],\n mutating: Boolean(input.command.mutating),\n },\n };\n}\n\nexport async function loadRecipe(recipeDir: string): Promise<RecipeDefinition> {\n const raw = await readFile(path.join(recipeDir, 'recipe.json'), 'utf8');\n return parseRecipeDefinition(JSON.parse(raw));\n}\n\nexport async function listRecipes(recipesDir: string): Promise<RecipeSummary[]> {\n let entries: string[];\n try {\n entries = await readdir(recipesDir);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return [];\n }\n throw error;\n }\n\n const summaries: RecipeSummary[] = [];\n for (const entry of entries.sort()) {\n if (!RECIPE_NAME_PATTERN.test(entry)) {\n continue;\n }\n const recipeDir = path.join(recipesDir, entry);\n try {\n const recipe = await loadRecipe(recipeDir);\n summaries.push({\n name: recipe.name,\n title: recipe.title,\n description: recipe.description,\n workspace: recipe.workspace,\n path: recipeDir,\n mutating: Boolean(recipe.command.mutating),\n });\n } catch {\n // Ignore malformed directories in list output; `recipe show` reports exact errors.\n }\n }\n return summaries;\n}\n\nexport function parseVarEntries(entries: string[] = []): RecipeVariables {\n const variables: RecipeVariables = {};\n for (const entry of entries) {\n const index = entry.indexOf('=');\n if (index <= 0) {\n throw new Error(`Invalid --var value \"${entry}\". Expected key=value.`);\n }\n const key = entry.slice(0, index);\n assertSafeName('Variable name', key);\n variables[key] = entry.slice(index + 1);\n }\n return variables;\n}\n\nexport function parseVarsJson(input?: string): RecipeVariables {\n if (!input) {\n return {};\n }\n const parsed = JSON.parse(input) as unknown;\n if (!isRecord(parsed)) {\n throw new Error('--vars must be a JSON object.');\n }\n const variables: RecipeVariables = {};\n for (const [key, value] of Object.entries(parsed)) {\n assertSafeName('Variable name', key);\n variables[key] = String(value);\n }\n return variables;\n}\n\nexport function mergeVariables(varsJson?: string, varEntries: string[] = []): RecipeVariables {\n return {\n ...parseVarsJson(varsJson),\n ...parseVarEntries(varEntries),\n };\n}\n\nexport function validateRequiredVariables(recipe: RecipeDefinition, variables: RecipeVariables): void {\n const missing = (recipe.variables || [])\n .filter((variable) => variable.required && !Object.prototype.hasOwnProperty.call(variables, variable.name))\n .map((variable) => variable.name);\n if (missing.length > 0) {\n throw new Error(`Missing required recipe variable(s): ${missing.join(', ')}.`);\n }\n}\n\nexport function renderTemplate(template: string, variables: RecipeVariables): string {\n return template.replace(TEMPLATE_PATTERN, (match, variableName: string) => {\n if (!Object.prototype.hasOwnProperty.call(variables, variableName)) {\n throw new Error(`Missing recipe variable: ${variableName}.`);\n }\n return variables[variableName];\n });\n}\n\nfunction resolveRecipeFile(recipeDir: string, token: string): string {\n const relative = token.slice(1);\n if (!relative || relative.includes('..') || path.isAbsolute(relative)) {\n throw new Error(`Unsafe recipe file reference: ${token}`);\n }\n const resolved = path.resolve(recipeDir, relative);\n const root = path.resolve(recipeDir);\n if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`)) {\n throw new Error(`Recipe file reference escapes recipe directory: ${token}`);\n }\n return resolved;\n}\n\nexport async function renderArgv(options: {\n recipe: RecipeDefinition;\n recipeDir: string;\n variables: RecipeVariables;\n profileName: string;\n}): Promise<string[]> {\n validateRequiredVariables(options.recipe, options.variables);\n const rendered: string[] = [];\n for (const token of options.recipe.command.argv) {\n if (token.startsWith('@')) {\n const raw = await readFile(resolveRecipeFile(options.recipeDir, token), 'utf8');\n rendered.push(renderTemplate(raw, options.variables));\n } else {\n rendered.push(renderTemplate(token, options.variables));\n }\n }\n\n if (!rendered.includes('--profile')) {\n rendered.push('--profile', options.profileName);\n }\n return rendered;\n}\n\nexport async function ensureEmptyOrForce(targetDir: string, force = false): Promise<void> {\n try {\n await access(targetDir);\n if (!force) {\n throw new Error(`Recipe already exists at ${targetDir}. Re-run with --force to overwrite scaffold files.`);\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return;\n }\n throw error;\n }\n}\n\nexport async function writeRecipeScaffold(options: {\n location: RecipeLocation;\n title?: string;\n force?: boolean;\n}): Promise<void> {\n await ensureEmptyOrForce(options.location.recipeDir, options.force);\n await mkdir(options.location.recipeDir, { recursive: true });\n const title = options.title || options.location.recipeName;\n const recipe: RecipeDefinition = {\n version: 1,\n name: options.location.recipeName,\n title,\n description: 'Describe what this BPMAX environment recipe does.',\n workspace: options.location.workspaceDirName,\n variables: [{ name: 'name', required: true }],\n command: {\n argv: ['project', 'create', '--body', '@payload.json', '--format', 'json'],\n mutating: true,\n },\n };\n await writeFile(path.join(options.location.recipeDir, 'recipe.json'), `${JSON.stringify(recipe, null, 2)}\\n`, 'utf8');\n await writeFile(\n path.join(options.location.recipeDir, 'payload.json'),\n `${JSON.stringify({ name: '{{name}}' }, null, 2)}\\n`,\n 'utf8',\n );\n await writeFile(\n path.join(options.location.recipeDir, 'README.md'),\n [`# ${title}`, '', 'Describe the BPMAX flow, field mapping, prerequisites, and verification steps for this recipe.', ''].join('\\n'),\n 'utf8',\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: 'Create a project with local form schema validation when form payload is provided.', 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.10\",\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 { printResult } from '../core/output.js';\nimport { buildBpmaxUrl, type BpmaxUrlKind, type BpmaxUrlResult } from '../core/urls.js';\nimport type { ConfigFileV2, OutputFormat } from '../core/types.js';\n\nexport interface UrlCommandDeps {\n loadConfig?: typeof loadConfig;\n}\n\nfunction printUrl(format: OutputFormat, result: BpmaxUrlResult): void {\n if (format === 'pretty') {\n console.log(result.url);\n return;\n }\n printResult(format, result);\n}\n\nasync function resolveUrl(\n load: () => Promise<ConfigFileV2>,\n kind: BpmaxUrlKind,\n options: { profile?: string; workspace?: string; format: OutputFormat; projectId?: string; stepId?: string },\n): Promise<void> {\n const config = await load();\n const profile = resolveProfile(config, options.profile);\n printUrl(\n options.format,\n buildBpmaxUrl(profile, kind, {\n workspace: options.workspace,\n projectId: options.projectId,\n stepId: options.stepId,\n }),\n );\n}\n\nexport function registerUrlCommands(program: Command, deps: UrlCommandDeps = {}): void {\n const load = deps.loadConfig || loadConfig;\n const url = program.command('url').description('Generate BPMAX web URLs');\n\n url\n .command('workspace')\n .description('Generate the current workspace URL')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n await resolveUrl(load, 'workspace', options);\n });\n\n url\n .command('project-list')\n .description('Generate the project list URL')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(async (options: { profile?: string; workspace?: string; format: OutputFormat }) => {\n await resolveUrl(load, 'project-list', options);\n });\n\n url\n .command('project-detail <projectId>')\n .description('Generate a project detail URL')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(\n async (\n projectId: string,\n options: { profile?: string; workspace?: string; format: OutputFormat },\n ) => {\n await resolveUrl(load, 'project-detail', { ...options, projectId });\n },\n );\n\n url\n .command('project-step <projectId>')\n .description('Generate a project step processing URL')\n .requiredOption('--step-id <stepId>', 'Step id')\n .option('--profile <profile>', 'Profile name')\n .option('--workspace <workspace>', 'Workspace override')\n .option('--format <format>', 'Output format', 'pretty')\n .action(\n async (\n projectId: string,\n options: { profile?: string; workspace?: string; stepId: string; format: OutputFormat },\n ) => {\n await resolveUrl(load, 'project-step', { ...options, projectId });\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,QA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AQ,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,uBAAuB,OAAO;AAC9B,oBAAoB,OAAO;AAC3B,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","isRecord","isRecord","normalizeOrigin","path","parseJson","program","mkdir","readFile","writeFile","path","path","isRecord","readFile","mkdir","writeFile","program","program","text","index","text","program","loadConfig","saveConfig","mkdir","readFile","writeFile","path","fileURLToPath","spawn","path","readFile","mkdir","writeFile","fileURLToPath","access","mkdir","readFile","writeFile","path","path","readFile","mkdir","writeFile","program","body","synced","program","program"]}
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cp, mkdir, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import process from 'node:process';
|
|
@@ -80,6 +81,71 @@ async function writeSkillsStamp() {
|
|
|
80
81
|
await writeFile(stampPath, version, 'utf8');
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
function runCommand(command, args) {
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
const child = spawn(command, args, {
|
|
87
|
+
shell: false,
|
|
88
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
89
|
+
});
|
|
90
|
+
let stdout = '';
|
|
91
|
+
let stderr = '';
|
|
92
|
+
child.stdout.on('data', (chunk) => {
|
|
93
|
+
stdout += String(chunk);
|
|
94
|
+
});
|
|
95
|
+
child.stderr.on('data', (chunk) => {
|
|
96
|
+
stderr += String(chunk);
|
|
97
|
+
});
|
|
98
|
+
child.on('error', (error) => {
|
|
99
|
+
resolve({ exitCode: 1, stdout, stderr: error.message });
|
|
100
|
+
});
|
|
101
|
+
child.on('close', (code) => {
|
|
102
|
+
resolve({ exitCode: code ?? 1, stdout, stderr });
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function findAilySkillhub() {
|
|
108
|
+
const command = process.platform === 'win32' ? 'where' : 'which';
|
|
109
|
+
const result = await runCommand(command, ['aily-skillhub']);
|
|
110
|
+
if (result.exitCode !== 0) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return result.stdout.split(/\r?\n/).find((line) => line.trim())?.trim() || 'aily-skillhub';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function installWithAilySkillhub(skillNames) {
|
|
117
|
+
const executable = await findAilySkillhub();
|
|
118
|
+
if (!executable) {
|
|
119
|
+
return { action: 'skipped', executable: null, installed: [], failed: [] };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const installed = [];
|
|
123
|
+
const failed = [];
|
|
124
|
+
for (const skillName of skillNames) {
|
|
125
|
+
const sourceDir = path.join(sourceSkillsDir, skillName);
|
|
126
|
+
const result = await runCommand(executable, ['install', '--file-path', sourceDir]);
|
|
127
|
+
const item = {
|
|
128
|
+
skill: skillName,
|
|
129
|
+
path: sourceDir,
|
|
130
|
+
stdout: result.stdout.trim(),
|
|
131
|
+
stderr: result.stderr.trim(),
|
|
132
|
+
exitCode: result.exitCode,
|
|
133
|
+
};
|
|
134
|
+
if (result.exitCode === 0) {
|
|
135
|
+
installed.push(item);
|
|
136
|
+
} else {
|
|
137
|
+
failed.push(item);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
action: failed.length > 0 ? 'partial' : 'installed',
|
|
143
|
+
executable,
|
|
144
|
+
installed,
|
|
145
|
+
failed,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
83
149
|
async function main() {
|
|
84
150
|
if (!(await exists(sourceSkillsDir))) {
|
|
85
151
|
const result = { ok: true, action: 'skipped', installed: [], message: 'No project skills directory found.' };
|
|
@@ -102,41 +168,68 @@ async function main() {
|
|
|
102
168
|
return result;
|
|
103
169
|
}
|
|
104
170
|
const allInstalled = [];
|
|
171
|
+
const sourceSkillDirs = [];
|
|
105
172
|
|
|
106
173
|
for (const skillName of skillNames) {
|
|
107
174
|
const sourceDir = path.join(sourceSkillsDir, skillName);
|
|
108
175
|
if (!(await exists(sourceDir))) {
|
|
109
176
|
continue;
|
|
110
177
|
}
|
|
178
|
+
sourceSkillDirs.push(sourceDir);
|
|
111
179
|
const installed = await installSkillDir(skillName, sourceDir);
|
|
112
180
|
installed.forEach((target) => allInstalled.push(target));
|
|
113
181
|
}
|
|
182
|
+
const ailySkillhub = await installWithAilySkillhub(skillNames);
|
|
114
183
|
|
|
115
|
-
if (allInstalled.length === 0) {
|
|
184
|
+
if (allInstalled.length === 0 && ailySkillhub.installed.length === 0) {
|
|
116
185
|
const result = {
|
|
117
186
|
ok: true,
|
|
118
187
|
action: 'skipped',
|
|
119
188
|
installed: [],
|
|
189
|
+
source_skills: sourceSkillDirs,
|
|
190
|
+
aily_skillhub: ailySkillhub,
|
|
120
191
|
message: 'No compatible local agent skill directories detected.',
|
|
121
192
|
};
|
|
122
193
|
if (jsonOutput) {
|
|
123
194
|
console.log(JSON.stringify(result, null, 2));
|
|
124
195
|
} else {
|
|
125
196
|
console.log('[bpmax-cli] No compatible local agent skill directories detected. Nothing installed.');
|
|
197
|
+
if (ailySkillhub.action === 'skipped') {
|
|
198
|
+
console.log('[bpmax-cli] aily-skillhub not found in PATH, skipping aily skill install.');
|
|
199
|
+
}
|
|
200
|
+
if (ailySkillhub.failed.length > 0) {
|
|
201
|
+
console.log('[bpmax-cli] aily-skillhub install warnings:');
|
|
202
|
+
ailySkillhub.failed.forEach((item) => {
|
|
203
|
+
console.log(`- ${item.skill}: ${item.stderr || item.stdout || `exit ${item.exitCode}`}`);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
126
206
|
setupHint.forEach((line) => console.log(line));
|
|
127
207
|
}
|
|
128
208
|
return result;
|
|
129
209
|
}
|
|
130
210
|
|
|
131
|
-
const result = { ok: true, action: 'installed', installed: allInstalled };
|
|
211
|
+
const result = { ok: true, action: 'installed', installed: allInstalled, source_skills: sourceSkillDirs, aily_skillhub: ailySkillhub };
|
|
132
212
|
await writeSkillsStamp();
|
|
133
213
|
if (jsonOutput) {
|
|
134
214
|
console.log(JSON.stringify(result, null, 2));
|
|
135
215
|
} else {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
216
|
+
if (allInstalled.length > 0) {
|
|
217
|
+
console.log('[bpmax-cli] Installed skills to:');
|
|
218
|
+
allInstalled.forEach((target) => {
|
|
219
|
+
console.log(`- ${target}`);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (ailySkillhub.action === 'skipped') {
|
|
223
|
+
console.log('[bpmax-cli] aily-skillhub not found in PATH, skipping aily skill install.');
|
|
224
|
+
} else {
|
|
225
|
+
console.log(`[bpmax-cli] aily-skillhub ${ailySkillhub.action}:`);
|
|
226
|
+
ailySkillhub.installed.forEach((item) => {
|
|
227
|
+
console.log(`- ${item.skill}`);
|
|
228
|
+
});
|
|
229
|
+
ailySkillhub.failed.forEach((item) => {
|
|
230
|
+
console.log(`- ${item.skill}: failed (${item.stderr || item.stdout || `exit ${item.exitCode}`})`);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
140
233
|
setupHint.forEach((line) => console.log(line));
|
|
141
234
|
}
|
|
142
235
|
return result;
|