@bintel/dimens-cli
Advanced tools
| import { t as __exportAll } from "./rolldown-runtime-95iHPtFO.mjs"; | ||
| import { n as logger } from "./logger-CEOtAYhF.mjs"; | ||
| import { a as AuthSDK, i as ColumnSDK, l as getVersion, n as RowSDK, o as DimensClient, r as ProjectSDK, s as FlowChatSDK, t as SheetSDK } from "./sheet-jiBqJC3e.mjs"; | ||
| import { readFile, writeFile } from "fs/promises"; | ||
| import { join } from "path"; | ||
| import { homedir } from "os"; | ||
| import { existsSync, readFileSync, readdirSync, statSync } from "node:fs"; | ||
| import { dirname as dirname$1, join as join$1, relative, resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| //#region src/core/config.ts | ||
| /** | ||
| * 配置管理 | ||
| */ | ||
| const DEFAULT_CONFIG = { | ||
| version: "1.0.0", | ||
| profile: {}, | ||
| skills: {}, | ||
| preferences: {} | ||
| }; | ||
| var ConfigManager = class { | ||
| configPath; | ||
| config; | ||
| constructor() { | ||
| this.configPath = join(homedir(), ".dimens-cli", "config.json"); | ||
| this.config = DEFAULT_CONFIG; | ||
| } | ||
| async load() { | ||
| try { | ||
| const data = await readFile(this.configPath, "utf-8"); | ||
| const parsed = JSON.parse(data); | ||
| this.config = { | ||
| ...DEFAULT_CONFIG, | ||
| ...parsed, | ||
| profile: { | ||
| ...DEFAULT_CONFIG.profile, | ||
| ...parsed.profile || {} | ||
| }, | ||
| skills: parsed.skills || {}, | ||
| preferences: parsed.preferences || {} | ||
| }; | ||
| logger.debug("配置加载成功", { path: this.configPath }); | ||
| } catch (error) { | ||
| logger.debug("配置文件不存在,使用默认配置"); | ||
| this.config = { | ||
| ...DEFAULT_CONFIG, | ||
| profile: { ...DEFAULT_CONFIG.profile } | ||
| }; | ||
| } | ||
| } | ||
| async save() { | ||
| try { | ||
| const { mkdir } = await import("fs/promises"); | ||
| await mkdir(join(homedir(), ".dimens-cli"), { recursive: true }); | ||
| await writeFile(this.configPath, JSON.stringify(this.config, null, 2), "utf-8"); | ||
| logger.debug("配置保存成功", { path: this.configPath }); | ||
| } catch (error) { | ||
| logger.error("配置保存失败", { error: String(error) }); | ||
| throw error; | ||
| } | ||
| } | ||
| get(key) { | ||
| return this.config[key]; | ||
| } | ||
| set(key, value) { | ||
| this.config[key] = value; | ||
| } | ||
| getAll() { | ||
| return { | ||
| ...this.config, | ||
| profile: { ...this.config.profile }, | ||
| skills: { ...this.config.skills }, | ||
| preferences: { ...this.config.preferences } | ||
| }; | ||
| } | ||
| }; | ||
| const config = new ConfigManager(); | ||
| //#endregion | ||
| //#region src/commands/registry.ts | ||
| const registeredCommands = /* @__PURE__ */ new Map(); | ||
| const registeredGroups = /* @__PURE__ */ new Map(); | ||
| const qualifiedCommands = /* @__PURE__ */ new Map(); | ||
| function createCommandGroup(name, description) { | ||
| const group = { | ||
| name, | ||
| description, | ||
| commands: [] | ||
| }; | ||
| registeredGroups.set(name, group); | ||
| return group; | ||
| } | ||
| function registerCommand(command) { | ||
| if (registeredCommands.has(command.name)) logger.warn(`命令 ${command.name} 已存在,将被覆盖`); | ||
| registeredCommands.set(command.name, command); | ||
| if (command.aliases) command.aliases.forEach((alias) => { | ||
| registeredCommands.set(alias, command); | ||
| }); | ||
| logger.debug(`命令已注册: ${command.name}`); | ||
| } | ||
| function registerGroupCommand(groupName, command) { | ||
| (registeredGroups.get(groupName) || createCommandGroup(groupName, groupName)).commands.push(command); | ||
| const qualifiedName = `${groupName}:${command.name}`; | ||
| qualifiedCommands.set(qualifiedName, command); | ||
| if (groupName === "system" || groupName === "auth") { | ||
| registerCommand(command); | ||
| return; | ||
| } | ||
| if (command.aliases) command.aliases.forEach((alias) => { | ||
| qualifiedCommands.set(`${groupName}:${alias}`, command); | ||
| }); | ||
| logger.debug(`命令已注册: ${qualifiedName}`); | ||
| } | ||
| function getCommand(name) { | ||
| return registeredCommands.get(name); | ||
| } | ||
| function getGroupCommand(groupName, commandName) { | ||
| return qualifiedCommands.get(`${groupName}:${commandName}`); | ||
| } | ||
| function getAllCommands() { | ||
| const uniqueCommands = new Set(registeredCommands.values()); | ||
| return Array.from(uniqueCommands); | ||
| } | ||
| function getCommandGroup(name) { | ||
| return registeredGroups.get(name); | ||
| } | ||
| function getAllCommandGroups() { | ||
| return Array.from(registeredGroups.values()); | ||
| } | ||
| function clearCommands() { | ||
| registeredCommands.clear(); | ||
| registeredGroups.clear(); | ||
| qualifiedCommands.clear(); | ||
| logger.debug("所有命令已清除"); | ||
| } | ||
| function createCommand(name, description, handler, options) { | ||
| return { | ||
| name, | ||
| description, | ||
| handler, | ||
| ...options | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/skills/mappings.ts | ||
| const SKILL_MAPPINGS = { | ||
| "dimens-system-orchestrator": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "system", | ||
| "orchestrator", | ||
| "planner", | ||
| "routing", | ||
| "builder" | ||
| ], | ||
| commandGroups: ["skill"], | ||
| commands: [ | ||
| "skill recommend", | ||
| "skill info", | ||
| "skill show" | ||
| ], | ||
| sdkModules: [], | ||
| toolNames: ["system_decomposition", "skill_routing"] | ||
| }, | ||
| "dimens-workflow": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "workflow", | ||
| "flow", | ||
| "ai", | ||
| "project", | ||
| "team" | ||
| ], | ||
| commandGroups: ["ai"], | ||
| commands: ["ai chat-completions"], | ||
| sdkModules: ["FlowChatSDK", "DimensSDK.ai"], | ||
| toolNames: [ | ||
| "flow_list", | ||
| "project_workflow_binding_list", | ||
| "flow_run_invoke", | ||
| "flow_run_debug", | ||
| "flow_config_get" | ||
| ] | ||
| }, | ||
| "dimens-key-auth": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "auth", | ||
| "api-key", | ||
| "token", | ||
| "login", | ||
| "security" | ||
| ], | ||
| commandGroups: ["auth"], | ||
| commands: [ | ||
| "auth api-key-login", | ||
| "auth login", | ||
| "auth refresh", | ||
| "auth status", | ||
| "auth profile" | ||
| ], | ||
| sdkModules: ["AuthSDK", "DimensSDK.auth"], | ||
| toolNames: [ | ||
| "api_key_create", | ||
| "api_key_list", | ||
| "api_key_status", | ||
| "api_key_delete", | ||
| "api_key_reset_secret", | ||
| "api_key_log_page" | ||
| ] | ||
| }, | ||
| "dimens-team": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "team", | ||
| "project", | ||
| "tenant", | ||
| "member", | ||
| "context" | ||
| ], | ||
| commandGroups: ["auth", "project"], | ||
| commands: [ | ||
| "auth use-team", | ||
| "auth use-project", | ||
| "project list", | ||
| "project info", | ||
| "project create", | ||
| "project update", | ||
| "project trash", | ||
| "project restore" | ||
| ], | ||
| sdkModules: ["ProjectSDK", "DimensSDK.project"], | ||
| toolNames: [ | ||
| "team_info", | ||
| "team_user_list", | ||
| "project_list", | ||
| "project_info", | ||
| "project_create", | ||
| "project_update", | ||
| "project_trash", | ||
| "project_restore" | ||
| ] | ||
| }, | ||
| "dimens-table": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "table", | ||
| "sheet", | ||
| "row", | ||
| "column", | ||
| "view" | ||
| ], | ||
| commandGroups: [ | ||
| "sheet", | ||
| "column", | ||
| "row" | ||
| ], | ||
| commands: [ | ||
| "sheet list", | ||
| "sheet tree", | ||
| "sheet create", | ||
| "sheet info", | ||
| "sheet update", | ||
| "sheet delete", | ||
| "column list", | ||
| "column create", | ||
| "column update", | ||
| "column delete", | ||
| "row page", | ||
| "row info", | ||
| "row create", | ||
| "row update", | ||
| "row delete", | ||
| "row set-cell" | ||
| ], | ||
| sdkModules: [ | ||
| "SheetSDK", | ||
| "ColumnSDK", | ||
| "RowSDK", | ||
| "DimensSDK.sheet", | ||
| "DimensSDK.column", | ||
| "DimensSDK.row" | ||
| ], | ||
| toolNames: [ | ||
| "sheet_list", | ||
| "sheet_info", | ||
| "column_list", | ||
| "column_create", | ||
| "row_page", | ||
| "row_update", | ||
| "row_set_cell" | ||
| ] | ||
| }, | ||
| "dimens-permission": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "permission", | ||
| "acl", | ||
| "row-policy", | ||
| "yjs", | ||
| "security" | ||
| ], | ||
| commandGroups: [], | ||
| commands: [], | ||
| sdkModules: [], | ||
| toolNames: [ | ||
| "project_authority_check", | ||
| "permission_resolve", | ||
| "column_permission_resolve", | ||
| "row_policy_check", | ||
| "yjs_permission_snapshot" | ||
| ] | ||
| }, | ||
| "dimens-report": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "report", | ||
| "chart", | ||
| "dashboard", | ||
| "parameter", | ||
| "query" | ||
| ], | ||
| commandGroups: [], | ||
| commands: [], | ||
| sdkModules: [], | ||
| toolNames: [ | ||
| "report_list", | ||
| "report_info", | ||
| "report_widget_list", | ||
| "report_parameter_list", | ||
| "report_query", | ||
| "report_export" | ||
| ] | ||
| } | ||
| }; | ||
| function getSkillMapping(name) { | ||
| return SKILL_MAPPINGS[name]; | ||
| } | ||
| //#endregion | ||
| //#region src/skills/index.ts | ||
| /** | ||
| * 技能发现与读取 | ||
| */ | ||
| function getPackageRoot() { | ||
| const currentDir = dirname$1(fileURLToPath(import.meta.url)); | ||
| return [resolve(currentDir, "../"), resolve(currentDir, "../../")].find((candidate) => existsSync(join$1(candidate, "package.json")) && existsSync(join$1(candidate, "skills"))) ?? resolve(currentDir, "../../"); | ||
| } | ||
| function getSkillsRoot() { | ||
| return join$1(getPackageRoot(), "skills"); | ||
| } | ||
| function parseFrontmatter(content) { | ||
| const lines = content.split("\n"); | ||
| if (lines[0]?.trim() !== "---") return {}; | ||
| let i = 1; | ||
| const data = {}; | ||
| while (i < lines.length) { | ||
| const line = lines[i]; | ||
| if (line?.trim() === "---") break; | ||
| if (line?.startsWith("name:")) { | ||
| data.name = line.slice(5).trim(); | ||
| i += 1; | ||
| continue; | ||
| } | ||
| if (line?.startsWith("description:")) { | ||
| const inline = line.slice(12).trim(); | ||
| if (inline && inline !== "|") { | ||
| data.description = inline; | ||
| i += 1; | ||
| continue; | ||
| } | ||
| i += 1; | ||
| const block = []; | ||
| while (i < lines.length) { | ||
| const next = lines[i]; | ||
| if (!next) { | ||
| block.push(""); | ||
| i += 1; | ||
| continue; | ||
| } | ||
| if (!next.startsWith(" ")) break; | ||
| block.push(next.slice(2)); | ||
| i += 1; | ||
| } | ||
| data.description = block.join("\n").trim(); | ||
| continue; | ||
| } | ||
| i += 1; | ||
| } | ||
| return data; | ||
| } | ||
| function listReferenceFiles(referencesDir) { | ||
| if (!existsSync(referencesDir)) return []; | ||
| return readdirSync(referencesDir).filter((file) => file.endsWith(".md")).sort().map((file) => join$1(referencesDir, file)); | ||
| } | ||
| function loadSkillFromDirectory(skillDir) { | ||
| const skillPath = join$1(skillDir, "SKILL.md"); | ||
| if (!existsSync(skillPath) || !statSync(skillPath).isFile()) return; | ||
| const frontmatter = parseFrontmatter(readFileSync(skillPath, "utf8")); | ||
| const name = frontmatter.name?.trim(); | ||
| const description = frontmatter.description?.trim(); | ||
| if (!name || !description) return; | ||
| const referencesDir = join$1(skillDir, "references"); | ||
| const mapping = getSkillMapping(name); | ||
| const skill = { | ||
| name, | ||
| description, | ||
| skillPath, | ||
| references: listReferenceFiles(referencesDir), | ||
| ...mapping | ||
| }; | ||
| if (existsSync(referencesDir)) skill.referencesDir = referencesDir; | ||
| return skill; | ||
| } | ||
| function discoverSkills() { | ||
| const skillsRoot = getSkillsRoot(); | ||
| if (!existsSync(skillsRoot)) return []; | ||
| return readdirSync(skillsRoot).map((entry) => join$1(skillsRoot, entry)).filter((entryPath) => statSync(entryPath).isDirectory()).map(loadSkillFromDirectory).filter((skill) => Boolean(skill)).sort((a, b) => a.name.localeCompare(b.name, "zh-CN")); | ||
| } | ||
| const SKILLS = discoverSkills(); | ||
| function getSkill(name) { | ||
| return SKILLS.find((skill) => skill.name === name); | ||
| } | ||
| function getAllSkills() { | ||
| return [...SKILLS]; | ||
| } | ||
| function getSkillsRootPath() { | ||
| return getSkillsRoot(); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/help.ts | ||
| function findRelatedSkills(groupName, commandName) { | ||
| const qualifiedCommand = commandName ? `${groupName} ${commandName}` : void 0; | ||
| return getAllSkills().filter((skill) => { | ||
| const matchesGroup = skill.commandGroups?.includes(groupName) ?? false; | ||
| const matchesCommand = qualifiedCommand ? skill.commands?.includes(qualifiedCommand) ?? false : false; | ||
| return matchesGroup || matchesCommand; | ||
| }).map((skill) => skill.name).sort((a, b) => a.localeCompare(b, "zh-CN")); | ||
| } | ||
| function printRelatedSkills(groupName, commandName) { | ||
| const relatedSkills = findRelatedSkills(groupName, commandName); | ||
| if (relatedSkills.length === 0) return; | ||
| console.log("相关 Skill:"); | ||
| relatedSkills.forEach((skillName) => { | ||
| console.log(` - ${skillName}`); | ||
| }); | ||
| } | ||
| const helpCommand = { | ||
| name: "help", | ||
| description: "显示帮助信息", | ||
| usage: "help [command] [subcommand]", | ||
| aliases: ["h", "?"], | ||
| handler: async (args) => { | ||
| if (args.length > 0) { | ||
| const groupName = args[0]; | ||
| const commandName = args[1]; | ||
| if (!groupName) return; | ||
| const group = getCommandGroup(groupName); | ||
| if (!group) { | ||
| console.log(`未找到命令组: ${groupName}`); | ||
| return; | ||
| } | ||
| if (commandName) { | ||
| const command = group.commands.find((c) => c.name === commandName || c.aliases?.includes(commandName)); | ||
| if (!command) { | ||
| console.log(`未找到命令: ${groupName} ${commandName}`); | ||
| return; | ||
| } | ||
| console.log(`\n命令: ${group.name} ${command.name}`); | ||
| console.log(`描述: ${command.description}`); | ||
| if (command.usage) console.log(`用法: ${command.usage}`); | ||
| if (command.aliases && command.aliases.length > 0) console.log(`别名: ${command.aliases.join(", ")}`); | ||
| if (command.examples && command.examples.length > 0) { | ||
| console.log("示例:"); | ||
| command.examples.forEach((example) => { | ||
| console.log(` ${example}`); | ||
| }); | ||
| } | ||
| printRelatedSkills(group.name, command.name); | ||
| console.log(""); | ||
| return; | ||
| } | ||
| console.log(`\n命令组: ${group.name}`); | ||
| console.log(`描述: ${group.description}`); | ||
| console.log("可用命令:"); | ||
| group.commands.forEach((command) => { | ||
| console.log(` ${command.name.padEnd(15)} ${command.description}`); | ||
| }); | ||
| printRelatedSkills(group.name); | ||
| console.log(""); | ||
| return; | ||
| } | ||
| console.log("\nDimens CLI - 多维项目开发助手"); | ||
| console.log(`版本: ${getVersion()}\n`); | ||
| console.log("可用命令组:\n"); | ||
| getAllCommandGroups().forEach((group) => { | ||
| console.log(` ${group.name.padEnd(15)} ${group.description}`); | ||
| }); | ||
| console.log("\n使用 \"help [group]\" 查看命令组,使用 \"help [group] [command]\" 查看具体命令"); | ||
| console.log("使用 \"help skill\" 查看技能命令组,使用 \"skill info <name>\" 查看具体 Skill\n"); | ||
| } | ||
| }; | ||
| function registerHelpCommand() { | ||
| createCommandGroup("system", "系统命令"); | ||
| registerGroupCommand("system", helpCommand); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/version.ts | ||
| const versionCommand = { | ||
| name: "version", | ||
| description: "显示版本信息", | ||
| usage: "version", | ||
| aliases: [ | ||
| "v", | ||
| "-v", | ||
| "--version" | ||
| ], | ||
| handler: async () => { | ||
| console.log(`Dimens CLI v${getVersion()}`); | ||
| } | ||
| }; | ||
| function registerVersionCommand() { | ||
| registerGroupCommand("system", versionCommand); | ||
| } | ||
| //#endregion | ||
| //#region src/core/context.ts | ||
| const DEFAULT_BASE_URL = "https://dimens.bintelai.com/api"; | ||
| function resolveContext(args = {}, profile = {}) { | ||
| const context = { output: args.output ?? profile.output ?? "table" }; | ||
| const baseUrl = args.baseUrl ?? process.env.DIMENS_BASE_URL ?? profile.baseUrl ?? "https://dimens.bintelai.com/api"; | ||
| const token = args.token ?? process.env.DIMENS_TOKEN ?? profile.token; | ||
| const refreshToken = args.refreshToken ?? profile.refreshToken; | ||
| const teamId = args.teamId ?? process.env.DIMENS_TEAM_ID ?? profile.teamId; | ||
| const projectId = args.projectId ?? process.env.DIMENS_PROJECT_ID ?? profile.projectId; | ||
| context.baseUrl = baseUrl; | ||
| if (token !== void 0) context.token = token; | ||
| if (refreshToken !== void 0) context.refreshToken = refreshToken; | ||
| if (teamId !== void 0) context.teamId = teamId; | ||
| if (projectId !== void 0) context.projectId = projectId; | ||
| return context; | ||
| } | ||
| //#endregion | ||
| //#region src/core/output.ts | ||
| function formatSuccess(message, data, mode) { | ||
| if (mode === "json") return JSON.stringify({ | ||
| success: true, | ||
| message, | ||
| data | ||
| }, null, 2); | ||
| if (mode === "raw") return [message, typeof data === "string" ? data : JSON.stringify(data)].join("\n"); | ||
| return [message, JSON.stringify(data, null, 2)].join("\n"); | ||
| } | ||
| function formatError(message, mode, options) { | ||
| const relatedSkills = options?.relatedSkills ?? []; | ||
| if (mode === "json") return JSON.stringify({ | ||
| success: false, | ||
| message, | ||
| relatedSkills | ||
| }, null, 2); | ||
| if (relatedSkills.length === 0) return message; | ||
| return [ | ||
| message, | ||
| "", | ||
| "相关 Skill:", | ||
| ...relatedSkills.map((skill) => `- ${skill}`) | ||
| ].join("\n"); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/execution-context.ts | ||
| let currentContext = {}; | ||
| function setExecutionContext(context) { | ||
| currentContext = context; | ||
| } | ||
| function clearExecutionContext() { | ||
| currentContext = {}; | ||
| } | ||
| function getRelatedSkillsForExecutionContext() { | ||
| const { groupName, commandName } = currentContext; | ||
| if (!groupName) return []; | ||
| const qualifiedCommand = commandName ? `${groupName} ${commandName}` : void 0; | ||
| return getAllSkills().filter((skill) => { | ||
| const matchesGroup = skill.commandGroups?.includes(groupName) ?? false; | ||
| const matchesCommand = qualifiedCommand ? skill.commands?.includes(qualifiedCommand) ?? false : false; | ||
| return matchesGroup || matchesCommand; | ||
| }).map((skill) => skill.name).sort((a, b) => a.localeCompare(b, "zh-CN")); | ||
| } | ||
| function getRelatedSkillObjectsForExecutionContext() { | ||
| const relatedSkillNames = new Set(getRelatedSkillsForExecutionContext()); | ||
| return getAllSkills().filter((skill) => relatedSkillNames.has(skill.name)); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/utils.ts | ||
| function parseFlags(args) { | ||
| const flags = {}; | ||
| for (let index = 0; index < args.length; index += 1) { | ||
| const current = args[index]; | ||
| if (!current?.startsWith("--")) continue; | ||
| const normalized = current.slice(2); | ||
| const equalIndex = normalized.indexOf("="); | ||
| if (equalIndex >= 0) { | ||
| const key = normalized.slice(0, equalIndex); | ||
| flags[key] = normalized.slice(equalIndex + 1) || "true"; | ||
| continue; | ||
| } | ||
| const next = args[index + 1]; | ||
| if (next && !next.startsWith("--")) { | ||
| flags[normalized] = next; | ||
| index += 1; | ||
| continue; | ||
| } | ||
| flags[normalized] = "true"; | ||
| } | ||
| return flags; | ||
| } | ||
| function getProfile() { | ||
| return config.get("profile"); | ||
| } | ||
| function saveProfile(profile) { | ||
| config.set("profile", profile); | ||
| return config.save(); | ||
| } | ||
| function mergeProfile(patch) { | ||
| return { | ||
| ...getProfile(), | ||
| ...patch | ||
| }; | ||
| } | ||
| function getContext(flags = {}) { | ||
| const contextArgs = {}; | ||
| if (flags["base-url"]) contextArgs.baseUrl = flags["base-url"]; | ||
| if (flags.token) contextArgs.token = flags.token; | ||
| if (flags["team-id"]) contextArgs.teamId = flags["team-id"]; | ||
| if (flags["project-id"]) contextArgs.projectId = flags["project-id"]; | ||
| if (flags.output === "json" || flags.output === "raw" || flags.output === "table") contextArgs.output = flags.output; | ||
| return resolveContext(contextArgs, getProfile()); | ||
| } | ||
| function createClient(context) { | ||
| if (!context.baseUrl) throw new Error("缺少 baseUrl,请先执行 auth login 或传入 --base-url"); | ||
| const options = { baseUrl: context.baseUrl }; | ||
| if (context.token) options.token = context.token; | ||
| if (context.refreshToken) options.refreshToken = context.refreshToken; | ||
| if (context.teamId) options.teamId = context.teamId; | ||
| if (context.projectId) options.projectId = context.projectId; | ||
| return new DimensClient(options); | ||
| } | ||
| function printSuccess(context, message, data) { | ||
| console.log(formatSuccess(message, data, context.output)); | ||
| } | ||
| function printError(context, error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| const relatedSkills = getRelatedSkillsForExecutionContext(); | ||
| console.log(formatError(message, context.output, { relatedSkills })); | ||
| process.exitCode = 1; | ||
| } | ||
| function requireTeamId(context, flags) { | ||
| const teamId = flags["team-id"] || context.teamId; | ||
| if (!teamId) throw new Error("缺少 teamId,请先执行 auth use-team 或传入 --team-id"); | ||
| return teamId; | ||
| } | ||
| function requireProjectId(context, flags) { | ||
| const projectId = flags["project-id"] || context.projectId; | ||
| if (!projectId) throw new Error("缺少 projectId,请先执行 auth use-project 或传入 --project-id"); | ||
| return projectId; | ||
| } | ||
| function requireSheetId(flags, args) { | ||
| const sheetId = flags["sheet-id"] || args[0]; | ||
| if (!sheetId) throw new Error("缺少 sheetId,请传入 --sheet-id 或 sheet <command> <sheetId>"); | ||
| return sheetId; | ||
| } | ||
| //#endregion | ||
| //#region src/commands/ai/index.ts | ||
| function registerAICommands() { | ||
| createCommandGroup("ai", "AI 对话"); | ||
| registerGroupCommand("ai", createCommand("chat-completions", "调用工作流 OpenAI 兼容聊天接口", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const message = flags.message; | ||
| if (!message) throw new Error("缺少 message,请传入 --message"); | ||
| const sdk = new FlowChatSDK(createClient(context)); | ||
| const payload = { | ||
| model: flags.model || "default", | ||
| messages: [{ | ||
| role: "user", | ||
| content: message | ||
| }], | ||
| stream: flags.stream === "true" | ||
| }; | ||
| if (flags.user) payload.user = flags.user; | ||
| printSuccess(context, "AI 对话调用成功", (await sdk.completions(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "ai chat-completions --message <text> [--model default] [--team-id <teamId>]", | ||
| examples: ["dimens-cli ai chat-completions --message \"你好\" --model default"] | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/auth/index.ts | ||
| function registerAuthCommands() { | ||
| createCommandGroup("auth", "认证与上下文"); | ||
| registerGroupCommand("auth", createCommand("login", "登录并保存本地凭证", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const username = flags.username; | ||
| const password = flags.password; | ||
| if (!username || !password) throw new Error("缺少登录参数,请传入 --username 和 --password"); | ||
| const result = await new AuthSDK(createClient(context)).login({ | ||
| username, | ||
| password | ||
| }); | ||
| const nextProfile = mergeProfile(context.baseUrl ? { | ||
| baseUrl: context.baseUrl, | ||
| token: result.data.token | ||
| } : { token: result.data.token }); | ||
| if (result.data.refreshToken) nextProfile.refreshToken = result.data.refreshToken; | ||
| await saveProfile(nextProfile); | ||
| printSuccess(context, "登录成功", result.data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "auth login --username <name> --password <password> [--base-url <url>]", | ||
| examples: ["dimens-cli auth login --username admin --password 123456", "dimens-cli auth login --base-url https://custom.example.com --username admin --password 123456"] | ||
| })); | ||
| registerGroupCommand("auth", createCommand("api-key-login", "使用 apiKey 和 apiSecret 登录并换取 token", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const apiKey = flags["api-key"]; | ||
| const apiSecret = flags["api-secret"]; | ||
| if (!apiKey || !apiSecret) throw new Error("缺少登录参数,请传入 --api-key 和 --api-secret"); | ||
| const result = await new AuthSDK(createClient(context)).loginByApiKey({ | ||
| apiKey, | ||
| apiSecret | ||
| }); | ||
| const nextProfile = mergeProfile(context.baseUrl ? { | ||
| baseUrl: context.baseUrl, | ||
| token: result.data.token | ||
| } : { token: result.data.token }); | ||
| if (result.data.refreshToken) nextProfile.refreshToken = result.data.refreshToken; | ||
| await saveProfile(nextProfile); | ||
| printSuccess(context, "API Key 登录成功", result.data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "auth api-key-login --api-key <apiKey> --api-secret <apiSecret> [--base-url <url>]", | ||
| examples: ["dimens-cli auth api-key-login --api-key ak_xxx --api-secret sk_xxx", "dimens-cli auth api-key-login --base-url https://custom.example.com --api-key ak_xxx --api-secret sk_xxx"] | ||
| })); | ||
| registerGroupCommand("auth", createCommand("refresh", "刷新 token", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const result = await new AuthSDK(createClient(context)).refreshToken(); | ||
| const nextProfile = mergeProfile({ token: result.data.token }); | ||
| const refreshToken = result.data.refreshToken ?? context.refreshToken; | ||
| if (refreshToken) nextProfile.refreshToken = refreshToken; | ||
| await saveProfile(nextProfile); | ||
| printSuccess(context, "刷新成功", result.data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "auth refresh [--base-url <url>]" })); | ||
| registerGroupCommand("auth", createCommand("status", "查看当前上下文", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| printSuccess(context, "当前上下文", context); | ||
| }, { usage: "auth status" })); | ||
| registerGroupCommand("auth", createCommand("use-team", "设置默认团队", async (args) => { | ||
| const context = getContext(); | ||
| try { | ||
| const teamId = args[0]; | ||
| if (!teamId) throw new Error("缺少 teamId,请传入 auth use-team <teamId>"); | ||
| await saveProfile(mergeProfile({ teamId })); | ||
| printSuccess(context, "默认团队已更新", { teamId }); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "auth use-team <teamId>" })); | ||
| registerGroupCommand("auth", createCommand("use-project", "设置默认项目", async (args) => { | ||
| const context = getContext(); | ||
| try { | ||
| const projectId = args[0]; | ||
| if (!projectId) throw new Error("缺少 projectId,请传入 auth use-project <projectId>"); | ||
| await saveProfile(mergeProfile({ projectId })); | ||
| printSuccess(context, "默认项目已更新", { projectId }); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "auth use-project <projectId>" })); | ||
| registerGroupCommand("auth", createCommand("profile", "查看本地 profile", async (args) => { | ||
| printSuccess(getContext(parseFlags(args)), "本地 Profile", getProfile()); | ||
| }, { usage: "auth profile" })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/column/index.ts | ||
| function registerColumnCommands() { | ||
| createCommandGroup("column", "字段管理"); | ||
| registerGroupCommand("column", createCommand("list", "获取字段列表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "字段列表获取成功", (await new ColumnSDK(createClient(context)).list(teamId, projectId, sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("column", createCommand("create", "创建字段", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const label = flags.label || flags.title; | ||
| if (!label) throw new Error("缺少字段标题,请传入 --label 或兼容参数 --title"); | ||
| const sdk = new ColumnSDK(createClient(context)); | ||
| const payload = { label }; | ||
| if (flags.type) payload.type = flags.type; | ||
| if (payload.type === "relation") payload.config = buildRelationConfig(flags); | ||
| printSuccess(context, "字段创建成功", (await sdk.create(teamId, projectId, sheetId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("column", createCommand("update", "更新字段", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const fieldId = flags["field-id"] || args[0]; | ||
| if (!fieldId) throw new Error("缺少字段 ID,请传入 --field-id"); | ||
| const sdk = new ColumnSDK(createClient(context)); | ||
| const payload = {}; | ||
| if (flags.label || flags.title) payload.label = flags.label || flags.title; | ||
| if (flags.type) payload.type = flags.type; | ||
| printSuccess(context, "字段更新成功", (await sdk.update(sheetId, fieldId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("column", createCommand("delete", "删除字段", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const fieldId = flags["field-id"] || args[0]; | ||
| if (!fieldId) throw new Error("缺少字段 ID,请传入 --field-id"); | ||
| printSuccess(context, "字段删除成功", (await new ColumnSDK(createClient(context)).delete(sheetId, fieldId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| } | ||
| function buildRelationConfig(flags) { | ||
| const targetSheetId = flags["target-sheet-id"]; | ||
| if (!targetSheetId) throw new Error("relation 字段缺少目标表,请传入 --target-sheet-id"); | ||
| const relationConfig = { targetSheetId }; | ||
| if (flags["display-column-id"]) relationConfig.displayColumnId = flags["display-column-id"]; | ||
| if (flags.bidirectional) relationConfig.bidirectional = parseBooleanFlag(flags.bidirectional, "bidirectional"); | ||
| if (flags.multiple) relationConfig.multiple = parseBooleanFlag(flags.multiple, "multiple"); | ||
| return { relationConfig }; | ||
| } | ||
| function parseBooleanFlag(value, fieldName) { | ||
| if (value === "true") return true; | ||
| if (value === "false") return false; | ||
| throw new Error(`${fieldName} 必须是 true 或 false`); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/project/index.ts | ||
| function registerProjectCommands() { | ||
| createCommandGroup("project", "项目管理"); | ||
| registerGroupCommand("project", createCommand("list", "获取项目列表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const sdk = new ProjectSDK(createClient(context)); | ||
| const payload = { | ||
| page: Number(flags.page || "1"), | ||
| size: Number(flags.size || "20") | ||
| }; | ||
| if (flags.keyword) payload.keyword = flags.keyword; | ||
| printSuccess(context, "项目列表获取成功", (await sdk.page(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "project list [--team-id <teamId>] [--page 1] [--size 20]", | ||
| examples: ["dimens-cli project list --team-id TEAM1"] | ||
| })); | ||
| registerGroupCommand("project", createCommand("info", "获取项目详情", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const id = flags.id || args[0]; | ||
| if (!id) throw new Error("缺少项目 ID,请传入 --id 或 project info <id>"); | ||
| printSuccess(context, "项目详情获取成功", (await new ProjectSDK(createClient(context)).info(teamId, id)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project info --id <projectId>" })); | ||
| registerGroupCommand("project", createCommand("create", "创建项目", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const name = flags.name; | ||
| if (!name) throw new Error("缺少项目名称,请传入 --name"); | ||
| const sdk = new ProjectSDK(createClient(context)); | ||
| const payload = { name }; | ||
| if (flags.remark) payload.remark = flags.remark; | ||
| printSuccess(context, "项目创建成功", (await sdk.create(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project create --name <name>" })); | ||
| registerGroupCommand("project", createCommand("update", "更新项目", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const id = flags.id; | ||
| if (!id) throw new Error("缺少项目 ID,请传入 --id"); | ||
| const sdk = new ProjectSDK(createClient(context)); | ||
| const payload = { id }; | ||
| if (flags.name) payload.name = flags.name; | ||
| if (flags.remark) payload.remark = flags.remark; | ||
| printSuccess(context, "项目更新成功", (await sdk.update(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project update --id <projectId> [--name <name>]" })); | ||
| registerGroupCommand("project", createCommand("trash", "将项目移入回收站", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const ids = (flags.ids || args.join(",")).split(",").map((item) => item.trim()).filter(Boolean); | ||
| if (ids.length === 0) throw new Error("缺少项目 ID,请传入 --ids P1,P2"); | ||
| printSuccess(context, "项目已移入回收站", (await new ProjectSDK(createClient(context)).trash(teamId, ids)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project trash --ids <id1,id2>" })); | ||
| registerGroupCommand("project", createCommand("restore", "恢复项目", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const ids = (flags.ids || args.join(",")).split(",").map((item) => item.trim()).filter(Boolean); | ||
| if (ids.length === 0) throw new Error("缺少项目 ID,请传入 --ids P1,P2"); | ||
| printSuccess(context, "项目恢复成功", (await new ProjectSDK(createClient(context)).restore(teamId, ids)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project restore --ids <id1,id2>" })); | ||
| registerGroupCommand("project", createCommand("use", "设置默认项目", async (args) => { | ||
| const context = getContext(); | ||
| try { | ||
| const projectId = args[0]; | ||
| if (!projectId) throw new Error("缺少项目 ID,请传入 project use <projectId>"); | ||
| await saveProfile(mergeProfile({ projectId })); | ||
| printSuccess(context, "默认项目已切换", { projectId }); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project use <projectId>" })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/row/index.ts | ||
| function registerRowCommands() { | ||
| createCommandGroup("row", "行数据管理"); | ||
| registerGroupCommand("row", createCommand("page", "分页获取行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const sdk = new RowSDK(createClient(context)); | ||
| const payload = { | ||
| page: Number(flags.page || "1"), | ||
| size: Number(flags.size || "20") | ||
| }; | ||
| printSuccess(context, "行分页获取成功", (await sdk.page(teamId, projectId, sheetId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("info", "获取行详情", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"] || args[0]; | ||
| if (!rowId) throw new Error("缺少行 ID,请传入 --row-id"); | ||
| printSuccess(context, "行详情获取成功", (await new RowSDK(createClient(context)).info(teamId, projectId, sheetId, rowId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("create", "创建行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const sdk = new RowSDK(createClient(context)); | ||
| const values = flags.values ? JSON.parse(flags.values) : {}; | ||
| printSuccess(context, "行创建成功", (await sdk.create(sheetId, { data: values })).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("update", "更新行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"] || args[0]; | ||
| if (!rowId) throw new Error("缺少行 ID,请传入 --row-id"); | ||
| const version = Number(flags.version || ""); | ||
| if (Number.isNaN(version)) throw new Error("缺少 version,请传入 --version"); | ||
| const values = flags.values ? JSON.parse(flags.values) : {}; | ||
| printSuccess(context, "行更新成功", (await new RowSDK(createClient(context)).update(sheetId, rowId, values, version)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("delete", "删除行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"] || args[0]; | ||
| if (!rowId) throw new Error("缺少行 ID,请传入 --row-id"); | ||
| printSuccess(context, "行删除成功", (await new RowSDK(createClient(context)).delete(sheetId, rowId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("set-cell", "更新单元格", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"]; | ||
| const fieldId = flags["field-id"] || flags["column-id"]; | ||
| if (!rowId || !fieldId) throw new Error("缺少 rowId 或 fieldId,请传入 --row-id 和 --field-id;--column-id 仅作兼容参数"); | ||
| const version = flags.version ? Number(flags.version) : void 0; | ||
| if (flags.version && Number.isNaN(version)) throw new Error("version 必须是数字,请传入 --version"); | ||
| printSuccess(context, "单元格更新成功", (await new RowSDK(createClient(context)).updateCell(sheetId, { | ||
| rowId, | ||
| fieldId, | ||
| value: flags.value, | ||
| ...version === void 0 ? {} : { version } | ||
| })).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/sheet/index.ts | ||
| function registerSheetCommands() { | ||
| createCommandGroup("sheet", "多维表管理"); | ||
| registerGroupCommand("sheet", createCommand("list", "获取表列表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const projectId = requireProjectId(context, flags); | ||
| printSuccess(context, "表列表获取成功", (await new SheetSDK(createClient(context)).list(projectId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("tree", "获取表树结构", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const projectId = requireProjectId(context, flags); | ||
| printSuccess(context, "表树获取成功", (await new SheetSDK(createClient(context)).tree(projectId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("create", "创建表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const projectId = requireProjectId(context, flags); | ||
| const name = flags.name; | ||
| if (!name) throw new Error("缺少表名称,请传入 --name"); | ||
| printSuccess(context, "表创建成功", (await new SheetSDK(createClient(context)).create(projectId, { name })).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("info", "获取表详情", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "表详情获取成功", (await new SheetSDK(createClient(context)).info(teamId, projectId, sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("update", "更新表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const sdk = new SheetSDK(createClient(context)); | ||
| const payload = {}; | ||
| if (flags.name) payload.name = flags.name; | ||
| printSuccess(context, "表更新成功", (await sdk.update(teamId, projectId, sheetId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("delete", "删除表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "表删除成功", (await new SheetSDK(createClient(context)).delete(teamId, projectId, sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("structure", "获取表结构", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "表结构获取成功", (await new SheetSDK(createClient(context)).structure(sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/skill/index.ts | ||
| function requireSkillName(args) { | ||
| const skillName = args[0]; | ||
| if (!skillName) throw new Error("缺少技能名称,请传入 skill info <name> 或 skill show <name>"); | ||
| return skillName; | ||
| } | ||
| function getSkillOrThrow(name) { | ||
| const skill = getSkill(name); | ||
| if (!skill) throw new Error(`未找到技能: ${name}`); | ||
| return skill; | ||
| } | ||
| function toRelativeSkillPath(filePath) { | ||
| return relative(getSkillsRootPath(), filePath) || filePath; | ||
| } | ||
| function printList(title, items) { | ||
| console.log(`${title}:`); | ||
| if (!items || items.length === 0) { | ||
| console.log(" (无)"); | ||
| return; | ||
| } | ||
| items.forEach((item) => { | ||
| console.log(` - ${item}`); | ||
| }); | ||
| } | ||
| function normalizeSkillForOutput(skill) { | ||
| return { | ||
| ...skill, | ||
| recommendExamples: getRecommendExamples(skill.name), | ||
| skillPath: skill.skillPath ? toRelativeSkillPath(skill.skillPath) : void 0, | ||
| referencesDir: skill.referencesDir ? toRelativeSkillPath(skill.referencesDir) : void 0, | ||
| references: skill.references?.map((reference) => toRelativeSkillPath(reference)) ?? [] | ||
| }; | ||
| } | ||
| function printMapping(skill) { | ||
| printList("命令组", skill.commandGroups); | ||
| printList("命令", skill.commands); | ||
| printList("SDK", skill.sdkModules); | ||
| printList("工具", skill.toolNames); | ||
| } | ||
| const SKILL_RECOMMEND_EXAMPLES = { | ||
| "dimens-system-orchestrator": [ | ||
| "帮我生成一个客户管理系统", | ||
| "帮我做一个项目管理平台", | ||
| "生成一个审批系统" | ||
| ], | ||
| "dimens-workflow": [ | ||
| "工作流 默认模型 AI 分析", | ||
| "审批流程 自动化", | ||
| "flow chat completions" | ||
| ], | ||
| "dimens-key-auth": [ | ||
| "api-key token", | ||
| "api secret 登录", | ||
| "第三方鉴权接入" | ||
| ], | ||
| "dimens-team": [ | ||
| "团队 项目 成员", | ||
| "teamId projectId", | ||
| "租户隔离 项目上下文" | ||
| ], | ||
| "dimens-table": [ | ||
| "多维表格 字段 row", | ||
| "sheet column view", | ||
| "字段类型 系统视图" | ||
| ], | ||
| "dimens-permission": [ | ||
| "行级权限 公开访问 只读", | ||
| "列权限 协同越权", | ||
| "acl 权限" | ||
| ], | ||
| "dimens-report": [ | ||
| "报表 图表 参数筛选", | ||
| "dashboard 数据源", | ||
| "统计看板 导出" | ||
| ] | ||
| }; | ||
| function getRecommendExamples(skillName) { | ||
| return SKILL_RECOMMEND_EXAMPLES[skillName] ?? []; | ||
| } | ||
| function getRecommendQuery(args) { | ||
| const queryParts = []; | ||
| for (let index = 0; index < args.length; index += 1) { | ||
| const current = args[index]; | ||
| if (!current) continue; | ||
| if (current.startsWith("--")) { | ||
| const next = args[index + 1]; | ||
| if (next && !next.startsWith("--")) index += 1; | ||
| continue; | ||
| } | ||
| queryParts.push(current); | ||
| } | ||
| return queryParts.join(" ").trim(); | ||
| } | ||
| const SYSTEM_BUILD_VERBS = [ | ||
| "生成", | ||
| "新建", | ||
| "创建", | ||
| "做", | ||
| "搭建", | ||
| "搭", | ||
| "构建", | ||
| "开发" | ||
| ]; | ||
| const SYSTEM_BUILD_TARGETS = [ | ||
| "系统", | ||
| "平台", | ||
| "管理系统", | ||
| "业务系统", | ||
| "crm", | ||
| "客户管理", | ||
| "项目管理", | ||
| "售后管理", | ||
| "审批系统" | ||
| ]; | ||
| const WORKFLOW_INTENT_KEYWORDS = [ | ||
| "工作流", | ||
| "workflow", | ||
| "flow", | ||
| "默认模型", | ||
| "ai 分析", | ||
| "审批流程", | ||
| "自动化" | ||
| ]; | ||
| const AUTH_INTENT_KEYWORDS = [ | ||
| "api-key", | ||
| "apikey", | ||
| "api key", | ||
| "api-secret", | ||
| "apisecret", | ||
| "api secret", | ||
| "token", | ||
| "登录", | ||
| "鉴权" | ||
| ]; | ||
| const TABLE_INTENT_KEYWORDS = [ | ||
| "多维表格", | ||
| "sheet", | ||
| "row", | ||
| "column", | ||
| "字段", | ||
| "视图", | ||
| "table" | ||
| ]; | ||
| const PERMISSION_INTENT_KEYWORDS = [ | ||
| "权限", | ||
| "行级权限", | ||
| "列权限", | ||
| "公开访问", | ||
| "只读", | ||
| "acl", | ||
| "协同越权" | ||
| ]; | ||
| const REPORT_INTENT_KEYWORDS = [ | ||
| "报表", | ||
| "图表", | ||
| "dashboard", | ||
| "参数筛选", | ||
| "数据源", | ||
| "统计", | ||
| "看板" | ||
| ]; | ||
| function getSystemOrchestratorBonus(skill, normalizedQuery) { | ||
| if (skill.name !== "dimens-system-orchestrator") return 0; | ||
| const hasBuildVerb = SYSTEM_BUILD_VERBS.some((keyword) => normalizedQuery.includes(keyword)); | ||
| const matchedTargets = SYSTEM_BUILD_TARGETS.filter((keyword) => normalizedQuery.includes(keyword)); | ||
| let score = 0; | ||
| if (hasBuildVerb && matchedTargets.length > 0) score += 10; | ||
| score += matchedTargets.length * 4; | ||
| return score; | ||
| } | ||
| function hasIntentKeyword(normalizedQuery, keywords) { | ||
| return keywords.some((keyword) => normalizedQuery.includes(keyword)); | ||
| } | ||
| function getSkillMatchSignals(skill, query) { | ||
| const normalizedQuery = query.toLowerCase(); | ||
| const haystacks = [ | ||
| skill.name, | ||
| skill.description, | ||
| ...skill.tags ?? [], | ||
| ...skill.commandGroups ?? [], | ||
| ...skill.commands ?? [], | ||
| ...skill.sdkModules ?? [], | ||
| ...skill.toolNames ?? [] | ||
| ].join("\n").toLowerCase(); | ||
| const compactQuery = normalizedQuery.replace(/\s+/g, ""); | ||
| const keywords = normalizedQuery.split(/\s+/).map((item) => item.trim()).filter(Boolean); | ||
| let keywordScore = 0; | ||
| const matchedBy = []; | ||
| keywords.forEach((keyword) => { | ||
| if (!keyword) return; | ||
| if (skill.name.toLowerCase().includes(keyword)) { | ||
| keywordScore += 4; | ||
| if (!matchedBy.includes("name-keyword")) matchedBy.push("name-keyword"); | ||
| return; | ||
| } | ||
| if (haystacks.includes(keyword)) { | ||
| keywordScore += 1; | ||
| if (!matchedBy.includes("context-keyword")) matchedBy.push("context-keyword"); | ||
| } | ||
| }); | ||
| let phraseScore = 0; | ||
| if (compactQuery && compactQuery !== normalizedQuery && haystacks.includes(compactQuery)) phraseScore += 2; | ||
| if (compactQuery && haystacks.includes(compactQuery)) phraseScore += 2; | ||
| if (phraseScore > 0 && !matchedBy.includes("compact-phrase")) matchedBy.push("compact-phrase"); | ||
| const systemBonus = getSystemOrchestratorBonus(skill, normalizedQuery); | ||
| if (systemBonus > 0) matchedBy.push("system-build-intent"); | ||
| if (skill.name === "dimens-workflow" && hasIntentKeyword(normalizedQuery, WORKFLOW_INTENT_KEYWORDS)) matchedBy.push("workflow-intent"); | ||
| if (skill.name === "dimens-key-auth" && hasIntentKeyword(normalizedQuery, AUTH_INTENT_KEYWORDS)) matchedBy.push("auth-intent"); | ||
| if (skill.name === "dimens-table" && hasIntentKeyword(normalizedQuery, TABLE_INTENT_KEYWORDS)) matchedBy.push("table-intent"); | ||
| if (skill.name === "dimens-permission" && hasIntentKeyword(normalizedQuery, PERMISSION_INTENT_KEYWORDS)) matchedBy.push("permission-intent"); | ||
| if (skill.name === "dimens-report" && hasIntentKeyword(normalizedQuery, REPORT_INTENT_KEYWORDS)) matchedBy.push("report-intent"); | ||
| const score = keywordScore + phraseScore + systemBonus; | ||
| const reasonParts = []; | ||
| if (systemBonus > 0) reasonParts.push("命中系统建设意图"); | ||
| if (matchedBy.includes("workflow-intent")) reasonParts.push("命中工作流意图"); | ||
| if (matchedBy.includes("auth-intent")) reasonParts.push("命中鉴权接入意图"); | ||
| if (matchedBy.includes("table-intent")) reasonParts.push("命中多维表格意图"); | ||
| if (matchedBy.includes("permission-intent")) reasonParts.push("命中权限意图"); | ||
| if (matchedBy.includes("report-intent")) reasonParts.push("命中报表意图"); | ||
| if (matchedBy.includes("name-keyword")) reasonParts.push("匹配到技能名关键词"); | ||
| if (matchedBy.includes("context-keyword")) reasonParts.push("匹配到描述或映射关键词"); | ||
| if (matchedBy.includes("compact-phrase")) reasonParts.push("匹配到紧凑短语"); | ||
| return { | ||
| score, | ||
| matchedBy, | ||
| reason: reasonParts.join(";") || "基于关键词相关性匹配" | ||
| }; | ||
| } | ||
| function registerSkillCommands() { | ||
| createCommandGroup("skill", "技能查看与提示语文档"); | ||
| registerGroupCommand("skill", createCommand("list", "列出所有已发现的技能", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const skills = getAllSkills(); | ||
| if (context.output === "json") { | ||
| console.log(formatSuccess("技能列表获取成功", skills.map((skill) => normalizeSkillForOutput(skill)), context.output)); | ||
| return; | ||
| } | ||
| console.log("\n已发现技能:\n"); | ||
| skills.forEach((skill) => { | ||
| console.log(`- ${skill.name}`); | ||
| console.log(` ${skill.description.split("\n")[0] ?? skill.description}`); | ||
| }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill list", | ||
| examples: ["dimens-cli skill list"] | ||
| })); | ||
| registerGroupCommand("skill", createCommand("info", "查看技能元信息", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const skill = getSkillOrThrow(requireSkillName(args)); | ||
| const normalizedSkill = normalizeSkillForOutput(skill); | ||
| if (context.output === "json") { | ||
| console.log(formatSuccess("技能信息获取成功", normalizedSkill, context.output)); | ||
| return; | ||
| } | ||
| console.log(`\n技能: ${skill.name}`); | ||
| console.log(`描述: ${skill.description.split("\n")[0] ?? skill.description}`); | ||
| if (skill.skillPath) console.log(`主文件: ${toRelativeSkillPath(skill.skillPath)}`); | ||
| if (skill.referencesDir) console.log(`参考目录: ${toRelativeSkillPath(skill.referencesDir)}`); | ||
| printMapping(skill); | ||
| printList("推荐关键词示例", getRecommendExamples(skill.name)); | ||
| printList("references", skill.references?.map((reference) => toRelativeSkillPath(reference))); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill info <name>", | ||
| examples: ["dimens-cli skill info dimens-table"] | ||
| })); | ||
| registerGroupCommand("skill", createCommand("recommend", "根据文本或关键词推荐相关技能", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const query = getRecommendQuery(args); | ||
| if (!query) throw new Error("缺少推荐文本,请传入 skill recommend <text>"); | ||
| const rankedSkills = getAllSkills().map((skill) => ({ | ||
| skill, | ||
| ...getSkillMatchSignals(skill, query) | ||
| })).filter((item) => item.score > 0).sort((a, b) => b.score - a.score || a.skill.name.localeCompare(b.skill.name, "zh-CN")); | ||
| if (context.output === "json") { | ||
| console.log(formatSuccess("技能推荐完成", rankedSkills.map((item) => ({ | ||
| score: item.score, | ||
| matchedBy: item.matchedBy, | ||
| reason: item.reason, | ||
| skill: normalizeSkillForOutput(item.skill) | ||
| })), context.output)); | ||
| return; | ||
| } | ||
| console.log(`\n推荐 Skill(query: ${query}):\n`); | ||
| if (rankedSkills.length === 0) { | ||
| console.log("(无匹配结果)\n"); | ||
| return; | ||
| } | ||
| rankedSkills.forEach((item) => { | ||
| console.log(`- ${item.skill.name} (score: ${item.score})`); | ||
| console.log(` ${item.skill.description.split("\n")[0] ?? item.skill.description}`); | ||
| }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill recommend <text>", | ||
| examples: ["dimens-cli skill recommend 工作流 默认模型 AI 分析", "dimens-cli skill recommend api-key token --output json"] | ||
| })); | ||
| registerGroupCommand("skill", createCommand("show", "显示技能文档内容", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const skillName = requireSkillName(args.filter((arg) => !arg.startsWith("--"))); | ||
| const skill = getSkillOrThrow(skillName); | ||
| const normalizedSkill = normalizeSkillForOutput(skill); | ||
| if (!skill.skillPath) throw new Error(`技能 ${skillName} 缺少主文件路径`); | ||
| const mainOnly = flags["main-only"] === "true"; | ||
| const referencesOnly = flags["references-only"] === "true"; | ||
| const mappingOnly = flags["mapping-only"] === "true"; | ||
| const includeReferences = flags.references === "true" || referencesOnly; | ||
| if (context.output === "json") { | ||
| const payload = { skill: normalizedSkill }; | ||
| if (!referencesOnly && !mappingOnly) payload.main = readFileSync(skill.skillPath, "utf8"); | ||
| if (!mainOnly && !mappingOnly && skill.references && skill.references.length > 0) payload.references = skill.references.map((reference) => ({ | ||
| path: toRelativeSkillPath(reference), | ||
| content: readFileSync(reference, "utf8") | ||
| })); | ||
| if (!mainOnly && !referencesOnly) payload.mapping = { | ||
| commandGroups: skill.commandGroups ?? [], | ||
| commands: skill.commands ?? [], | ||
| sdkModules: skill.sdkModules ?? [], | ||
| toolNames: skill.toolNames ?? [] | ||
| }; | ||
| console.log(formatSuccess("技能文档获取成功", payload, context.output)); | ||
| return; | ||
| } | ||
| if (!referencesOnly && !mappingOnly) { | ||
| console.log(`\n===== ${skill.name} / ${toRelativeSkillPath(skill.skillPath)} =====\n`); | ||
| console.log(readFileSync(skill.skillPath, "utf8")); | ||
| } | ||
| if (!mainOnly && !referencesOnly) { | ||
| console.log(`\n===== ${skill.name} / mapping =====\n`); | ||
| printMapping(skill); | ||
| } | ||
| if (!mainOnly && !mappingOnly && includeReferences && skill.references && skill.references.length > 0) skill.references.forEach((reference) => { | ||
| console.log(`\n===== ${toRelativeSkillPath(reference)} =====\n`); | ||
| console.log(readFileSync(reference, "utf8")); | ||
| }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill show <name> [--references] [--main-only] [--references-only] [--mapping-only]", | ||
| examples: [ | ||
| "dimens-cli skill show dimens-workflow", | ||
| "dimens-cli skill show dimens-workflow --references", | ||
| "dimens-cli skill show dimens-table --mapping-only", | ||
| "dimens-cli skill show dimens-key-auth --output json" | ||
| ] | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/index.ts | ||
| var commands_exports = /* @__PURE__ */ __exportAll({ registerCommands: () => registerCommands }); | ||
| function registerCommands() { | ||
| logger.info("开始注册所有命令..."); | ||
| createCommandGroup("system", "系统命令"); | ||
| registerHelpCommand(); | ||
| registerVersionCommand(); | ||
| registerAuthCommands(); | ||
| registerSkillCommands(); | ||
| registerProjectCommands(); | ||
| registerSheetCommands(); | ||
| registerColumnCommands(); | ||
| registerRowCommands(); | ||
| registerAICommands(); | ||
| logger.info("所有命令注册完成"); | ||
| } | ||
| //#endregion | ||
| export { config as _, getRelatedSkillObjectsForExecutionContext as a, getAllSkills as c, clearCommands as d, getAllCommands as f, registerCommand as g, getGroupCommand as h, clearExecutionContext as i, getSkill as l, getCommandGroup as m, registerCommands as n, setExecutionContext as o, getCommand as p, parseFlags as r, SKILLS as s, commands_exports as t, getSkillsRootPath as u }; | ||
| //# sourceMappingURL=commands-5eowaDaS.mjs.map |
Sorry, the diff of this file is too big to display
| # dimens-key-auth | ||
| ## 技能简介 | ||
| `dimens-key-auth` 用于处理维表智联中的 API Key / API Secret 登录换 token、第三方系统接入边界、Key 安全规则和权限继承问题。 | ||
| ## 适用场景 | ||
| - 需要用 `apiKey + apiSecret` 登录 | ||
| - 需要解释 token 获取与复用链路 | ||
| - 需要排查 Key 可用但接口无权限的问题 | ||
| - 需要说明 IP 白名单、过期时间、Secret 重置等规则 | ||
| ## 快速开始 | ||
| ```bash | ||
| dimens-cli auth api-key-login \ | ||
| --api-key ak_xxx \ | ||
| --api-secret sk_xxx | ||
| ``` | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:登录流、示例、能力边界等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/login-flow.md` | ||
| - `references/examples.md` | ||
| - `references/integration-boundaries.md` | ||
| - `references/capability-status.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # dimens-permission | ||
| ## 技能简介 | ||
| `dimens-permission` 用于分析维表智联中的团队准入、表级权限、列级权限、行级权限、公开访问者以及 Yjs 协同广播权限。 | ||
| ## 适用场景 | ||
| - 用户能看但不能改资源 | ||
| - 行分页正常但协同异常 | ||
| - 公开访问、只读、越权同步类问题 | ||
| - 需要解释表列行权限链路 | ||
| ## 快速开始 | ||
| 优先先确认: | ||
| - `teamId` | ||
| - `projectId` | ||
| - `sheetId` | ||
| - 当前用户或角色上下文 | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:权限矩阵、示例、能力状态等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/matrix.md` | ||
| - `references/examples.md` | ||
| - `references/scenario-routing.md` | ||
| - `references/capability-status.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # dimens-report | ||
| ## 技能简介 | ||
| `dimens-report` 用于处理维表智联中的报表、图表组件、数据源配置、参数联动和查询链路说明。 | ||
| ## 适用场景 | ||
| - 查询或解释报表结构 | ||
| - 排查图表不显示、查不到数据 | ||
| - 分析参数联动和导出链路 | ||
| - 说明报表与项目权限、多维表格数据源的关系 | ||
| ## 快速开始 | ||
| 优先准备: | ||
| - `projectId` | ||
| - `reportId` | ||
| - 相关参数定义 | ||
| - 数据源信息 | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:用法、示例、能力范围等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/usage.md` | ||
| - `references/examples.md` | ||
| - `references/capability-status.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # dimens-system-orchestrator | ||
| ## 技能简介 | ||
| `dimens-system-orchestrator` 是维表智联的系统级总控技能,用于把“生成一个 XX 系统”这类需求先拆成模块,再路由到团队、表格、权限、工作流、报表或认证等子技能。 | ||
| ## 适用场景 | ||
| - 搭建 CRM、项目管理、售后、审批等完整系统 | ||
| - 还没明确项目、表结构、权限和流程边界 | ||
| - 需要给出模块清单、执行顺序和风险提示 | ||
| ## 快速开始 | ||
| 推荐执行顺序: | ||
| 1. 先确认认证和上下文 | ||
| 2. 做系统拆解 | ||
| 3. 路由到子技能 | ||
| 4. 再落到具体命令或接口 | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:系统拆解、接口导航、命令映射等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/system-decomposition.md` | ||
| - `references/skill-routing.md` | ||
| - `references/interface-navigation.md` | ||
| - `references/command-mapping.md` | ||
| - `references/examples.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # dimens-table | ||
| ## 技能简介 | ||
| `dimens-table` 用于处理维表智联中的工作表、字段、视图、行数据和系统视图字段映射问题,是多维表格建模和写入排查的主技能。 | ||
| ## 适用场景 | ||
| - 创建或查询工作表、字段、行数据 | ||
| - 设计字段结构、关联关系、示例数据 | ||
| - 排查字段写入失败、行写入失败 | ||
| - 解释筛选、排序、搜索和系统视图映射 | ||
| ## 快速开始 | ||
| 推荐先确认: | ||
| - 已完成认证 | ||
| - `teamId` | ||
| - `projectId` | ||
| - `sheetId` | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:字段设计、建表流程、示例、筛选规则等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/build-flow.md` | ||
| - `references/field-design-patterns.md` | ||
| - `references/field-rules.md` | ||
| - `references/row-filters.md` | ||
| - `references/examples.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # dimens-team | ||
| ## 技能简介 | ||
| `dimens-team` 用于处理维表智联中的团队、成员、项目、部门和租户隔离上下文,是其他技能判断资源归属和默认上下文的上游入口。 | ||
| ## 适用场景 | ||
| - 查询团队、项目、成员关系 | ||
| - 解释为什么用户看不到某个项目 | ||
| - 判断 `teamId`、`projectId` 的作用和来源 | ||
| - 为表格、权限、工作流等技能补齐上下文 | ||
| ## 快速开始 | ||
| 优先准备: | ||
| - 当前用户上下文 | ||
| - `teamId` | ||
| - `projectId` | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:示例、隔离模型、项目入口说明等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/examples.md` | ||
| - `references/context-sources.md` | ||
| - `references/isolation.md` | ||
| - `references/project-entry.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # dimens-workflow | ||
| ## 技能简介 | ||
| `dimens-workflow` 用于处理维表智联中的团队工作流定义、项目挂载、运行调用、默认模型配置与 OpenAI 兼容调用链路。 | ||
| ## 适用场景 | ||
| - 查询或调用工作流 | ||
| - 排查工作流在项目中不可见、不可运行 | ||
| - 解释默认模型和节点模型配置 | ||
| - 说明 `chat/completions` 与普通工作流运行区别 | ||
| ## 快速开始 | ||
| 推荐先确认: | ||
| - `teamId` | ||
| - `projectId` | ||
| - `flowId` 或 `label` | ||
| ## 目录说明 | ||
| - `SKILL.md`:平台识别入口和技能主体 | ||
| - `rules/`:发布平台兼容入口,当前用于指向原始规则文档 | ||
| - `references/`:使用说明、示例、模型路由、项目绑定等补充资料 | ||
| 关系说明:`rules/` 面向发布平台规则扫描,`references/` 保持技能知识文档沉淀。 | ||
| ## 参考资料 | ||
| - `references/usage.md` | ||
| - `references/examples.md` | ||
| - `references/model-routing.md` | ||
| - `references/project-binding.md` | ||
| - `references/capability-status.md` |
| # rules(发布兼容层) | ||
| 本目录用于兼容 ClawHub/OpenClaw 的 `rules/` 目录扫描约定。 | ||
| - `rules/`:存放平台规则入口与发布侧兼容文件(当前先提供最小占位说明) | ||
| - `references/`:存放技能背景资料、场景示例与扩展文档 | ||
| 发布时可优先读取 `rules/`,再按需引用 `references/`。 |
| # skills 发布兼容说明 | ||
| ## 1. 目的 | ||
| `dimens-cli/skills` 这套技能最初按项目内独立知识体系维护,已有较稳定的 `references/` 文档组织方式。 | ||
| 为了兼容 ClawHub / OpenClaw 等技能平台的发布目录规范,本目录采用以下策略: | ||
| - 保留原有 `references/`,避免打断现有技能内部引用 | ||
| - 在各技能目录补充 `README.md` | ||
| - 在各技能目录补充 `rules/` 兼容入口 | ||
| - `assets/` 当前按需保留为空,不强行制造无意义资源文件 | ||
| ## 2. 当前兼容策略 | ||
| ### 2.1 `SKILL.md` | ||
| 每个技能目录都已补齐: | ||
| - `name` | ||
| - `slug` | ||
| - `description` | ||
| - `version` | ||
| - `author` | ||
| - `tags` | ||
| ### 2.2 `README.md` | ||
| 每个技能目录都已补充: | ||
| - 技能简介 | ||
| - 适用场景 | ||
| - 快速开始 | ||
| - 目录说明 | ||
| - 参考资料 | ||
| ### 2.3 `rules/` | ||
| `rules/` 目录作为平台兼容层使用,不直接替代原始 `references/`。 | ||
| 推荐做法: | ||
| - `rules/README.md` 作为入口说明 | ||
| - 明确指出规则正文仍维护在 `../references/` | ||
| - 后续如果平台确实要求规则文件必须直接放在 `rules/` 下,再做镜像或拆分 | ||
| ## 3. 不直接重命名 `references/` 的原因 | ||
| - 现有 Skill 正文和 README 已大量引用 `references/*.md` | ||
| - 直接重命名会引入额外维护成本和路径断裂风险 | ||
| - 当前最小兼容方案已经能满足目录结构展示与平台识别要求 | ||
| ## 4. 后续建议 | ||
| 如果平台后续增加更严格的审核项,建议继续补充: | ||
| - 每个技能的封面图到 `assets/` | ||
| - 统一的发布清单与截图 | ||
| - `rules/` 下更细粒度的规则拆分文件 |
| # dimens-cli/skills 批量发布检查清单(ClawHub/OpenClaw) | ||
| 检查日期:2026-04-19 | ||
| 检查范围:`dimens-cli/skills` 下 7 个正式技能目录(`dimens-*`) | ||
| 检查方式:基于当前仓库现状做静态核验(目录结构 + frontmatter + 引用扫描),不改动既有文件 | ||
| --- | ||
| ## 1. 发布核验项(本次执行口径) | ||
| 本次逐项核验以下发布规范项: | ||
| 1. `SKILL.md` 存在且含 frontmatter | ||
| 2. frontmatter 关键字段:`name`、`slug`、`description`、`version`、`author`、`tags` | ||
| 3. `README.md` 存在 | ||
| 4. `rules/` 目录存在 | ||
| 5. `assets/` 目录存在 | ||
| 6. `slug` 全局唯一 | ||
| 7. `description` 长度可用性(记录字符长度) | ||
| 8. `tags` 非空 | ||
| 9. 版本字段存在(并记录一致性情况) | ||
| 10. 作者字段存在 | ||
| 11. 目录完整性(`SKILL.md` + `README.md` + `rules/` + `references/` + `assets/`) | ||
| 12. 引用风险(绝对路径、跨目录相对引用、外链等) | ||
| --- | ||
| ## 2. 全局结论 | ||
| - 7/7 技能目录都具备:`SKILL.md`、frontmatter、`README.md`、`rules/`、`references/` | ||
| - 7/7 技能目录都缺少:`assets/` | ||
| - 7/7 技能的 `slug` 唯一,无冲突 | ||
| - 7/7 技能的 `description`、`tags`、`version`、`author` 均存在 | ||
| - 引用风险方面: | ||
| - `dimens-team`、`dimens-table`、`dimens-key-auth`、`dimens-permission`、`dimens-workflow` 的 `SKILL.md` 中存在 `../references/...` 相对路径引用 | ||
| - 各技能普遍包含外部官网链接(`https://dimens.bintelai.com/`) | ||
| - 本次未发现 `.trae/`、`AGENTS.md`、`/Users/...` 绝对路径被写入 7 个技能 `SKILL.md` | ||
| --- | ||
| ## 3. 逐技能核验结果与待办 | ||
| 状态说明:`PASS` 通过,`TODO` 待补充,`RISK` 有发布风险需确认平台规则 | ||
| | 技能目录 | SKILL/frontmatter | README | rules/ | assets/ | slug 唯一性 | description 长度 | tags | version | author | 目录完整性 | 引用风险 | 核验结论 | | ||
| | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | ||
| | `dimens-system-orchestrator` | PASS | PASS | PASS | TODO | PASS | 49 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(外链) | 可发布(补齐 assets 更稳) | | ||
| | `dimens-workflow` | PASS | PASS | PASS | TODO | PASS | 49 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(`../` + 外链) | 可发布(需确认相对引用策略) | | ||
| | `dimens-key-auth` | PASS | PASS | PASS | TODO | PASS | 64 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(`../` + 外链) | 可发布(需确认相对引用策略) | | ||
| | `dimens-team` | PASS | PASS | PASS | TODO | PASS | 55 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(`../` + 外链) | 可发布(需确认相对引用策略) | | ||
| | `dimens-table` | PASS | PASS | PASS | TODO | PASS | 46 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(`../` + 外链) | 可发布(需确认相对引用策略) | | ||
| | `dimens-permission` | PASS | PASS | PASS | TODO | PASS | 48 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(`../` + 外链) | 可发布(需确认相对引用策略) | | ||
| | `dimens-report` | PASS | PASS | PASS | TODO | PASS | 46 | PASS(5) | PASS(1.0.0) | PASS | TODO(缺 assets) | RISK(`../` + 外链) | 可发布(补齐 assets 更稳) | | ||
| --- | ||
| ## 4. 待办清单(按优先级) | ||
| ### P0(发布前建议确认) | ||
| 1. **确认 `assets/` 是否为硬性要求** | ||
| - 当前 7 个技能均无 `assets/` 目录。 | ||
| - 若 ClawHub/OpenClaw 审核要求 `assets/` 必须存在,需为每个技能补齐目录(至少放置占位封面/图标)。 | ||
| 2. **确认相对路径引用是否被平台渲染器支持** | ||
| - 多个 `SKILL.md` 和 `rules/README.md` 使用 `../references/...`。 | ||
| - 若平台仅收录单文件正文或不保留相对目录结构,可能出现链接失效。 | ||
| ### P1(一致性建议) | ||
| 3. **技能版本统一为 `1.0.0`,但包版本为 `1.0.2`** | ||
| - 如平台展示技能版本并与包版本对齐,建议制定统一映射策略(例如技能版本跟随包版本或独立语义化版本)。 | ||
| 4. **`rules/` 当前为兼容入口(README 跳转到 references)** | ||
| - 若平台要求 `rules/` 下必须有可直接消费的规则正文,需补充规则拆分文件,而不仅是入口说明。 | ||
| --- | ||
| ## 5. 本次核验命令要点(可复核) | ||
| - 枚举技能目录并统计:确认 `dimens-*` 共 7 个 | ||
| - 读取每个 `SKILL.md` 前 40 行:核对 frontmatter 字段 | ||
| - 检查目录存在性:`README.md` / `rules/` / `assets/` | ||
| - 扫描风险关键字:`/Users/`、`.trae/`、`AGENTS.md`、`../` | ||
| - 检查 `slug` 唯一性:未发现重复 | ||
| --- | ||
| ## 6. 发布建议结论 | ||
| 按当前仓库状态,7 个技能已经满足“可被识别并可基础发布”的主干条件(`SKILL.md + frontmatter + README + rules + slug 唯一`)。 | ||
| 主要短板集中在 `assets/` 缺失与“跨文件相对引用在目标平台是否稳定可解析”的不确定性,建议先完成 P0 两项确认后再批量上架。 |
+1
-0
@@ -70,2 +70,3 @@ //#region src/sdk/client.d.ts | ||
| description?: string; | ||
| config?: Record<string, unknown>; | ||
| [key: string]: unknown; | ||
@@ -72,0 +73,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.mts","names":[],"sources":["../src/sdk/client.ts","../src/sdk/auth.ts","../src/sdk/column.ts","../src/sdk/flow-chat.ts","../src/sdk/project.ts","../src/sdk/row.ts","../src/sdk/sheet.ts","../src/sdk/index.ts","../src/types.ts","../src/core/logger.ts","../src/core/config.ts","../src/core/version.ts","../src/tools/registry.ts","../src/tools/index.ts","../src/commands/registry.ts","../src/commands/index.ts","../src/cli.ts","../src/skills/index.ts","../index.ts"],"mappings":";UAGiB,mBAAA;EACf,OAAA;EACA,KAAA;EACA,YAAA;EACA,MAAA;EACA,SAAA;AAAA;AAAA,UAGe,WAAA;EACf,IAAA;EACA,OAAA;EACA,IAAA,EAAM,CAAA;AAAA;AAAA,KAGH,UAAA;AAAA,KACA,WAAA,GAAc,MAAA,SAAe,UAAA;AAAA,cAIrB,YAAA;EAAA,iBACM,OAAA;cAEL,OAAA,EAAS,mBAAA;EA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AA;AAAA,iBAwCzB,UAAA,CAAW,IAAA,WAAe,UAAA;AAAA,iBAI1B,eAAA,CACd,SAAA,UACA,WAAA,WACC,UAAA;AAAA,iBAIa,cAAA,CAAA,GAAkB,UAAA;;;iBC5ClB,gBAAA,CAAA;;;iBCqCM,MAAA,CAAO,IAAA,aAAiB,OAAA;;;cC6EjC,MAAA,EAAQ,KAAA;AAAA,iBAEL,QAAA,CAAS,IAAA,WAAe,KAAA;AAAA,iBAIxB,YAAA,CAAA,GAAgB,KAAA;;;;;;iBCpGV,UAAA,CAAA,GAAU,OAAA;;;wBAAA,gBAAA;;;;;;iBAeV,eAAA,CACpB,MAAA,GADmC,SAAA,GACG,OAAA,CAAA,SAAA"} | ||
| {"version":3,"file":"index.d.mts","names":[],"sources":["../src/sdk/client.ts","../src/sdk/auth.ts","../src/sdk/column.ts","../src/sdk/flow-chat.ts","../src/sdk/project.ts","../src/sdk/row.ts","../src/sdk/sheet.ts","../src/sdk/index.ts","../src/types.ts","../src/core/logger.ts","../src/core/config.ts","../src/core/version.ts","../src/tools/registry.ts","../src/tools/index.ts","../src/commands/registry.ts","../src/commands/index.ts","../src/cli.ts","../src/skills/index.ts","../index.ts"],"mappings":";UAGiB,mBAAA;EACf,OAAA;EACA,KAAA;EACA,YAAA;EACA,MAAA;EACA,SAAA;AAAA;AAAA,UAGe,WAAA;EACf,IAAA;EACA,OAAA;EACA,IAAA,EAAM,CAAA;AAAA;AAAA,KAGH,UAAA;AAAA,KACA,WAAA,GAAc,MAAA,SAAe,UAAA;AAAA,cAIrB,YAAA;EAAA,iBACM,OAAA;cAEL,OAAA,EAAS,mBAAA;EAIrB,UAAA,CAAA,GAAc,mBAAA;EAIR,GAAA,GAAA,CACJ,IAAA,UACA,KAAA,GAAQ,WAAA,EACR,IAAA,GAAM,WAAA,GACL,OAAA,CAAQ,WAAA,CAAY,CAAA;EAQjB,IAAA,GAAA,CACJ,IAAA,UACA,IAAA,YACA,IAAA,GAAM,WAAA,GACL,OAAA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aAAiB,OAAA;;;cC6EjC,MAAA,EAAQ,KAAA;AAAA,iBAEL,QAAA,CAAS,IAAA,WAAe,KAAA;AAAA,iBAIxB,YAAA,CAAA,GAAgB,KAAA;;;;;;iBCpGV,UAAA,CAAA,GAAU,OAAA;;;wBAAA,gBAAA;;;;;;iBAeV,eAAA,CACpB,MAAA,GADmC,SAAA,GACG,OAAA,CAAA,SAAA"} |
+2
-2
| import { n as logger, t as createLogger } from "./logger-CEOtAYhF.mjs"; | ||
| import { _ as config, a as getRelatedSkillObjectsForExecutionContext, c as getAllSkills, d as clearCommands, f as getAllCommands, g as registerCommand, h as getGroupCommand, i as clearExecutionContext, l as getSkill, m as getCommandGroup, n as registerCommands, o as setExecutionContext, p as getCommand, r as parseFlags, s as SKILLS, u as getSkillsRootPath } from "./commands-DhXU3rGj.mjs"; | ||
| import { _ as config, a as getRelatedSkillObjectsForExecutionContext, c as getAllSkills, d as clearCommands, f as getAllCommands, g as registerCommand, h as getGroupCommand, i as clearExecutionContext, l as getSkill, m as getCommandGroup, n as registerCommands, o as setExecutionContext, p as getCommand, r as parseFlags, s as SKILLS, u as getSkillsRootPath } from "./commands-5eowaDaS.mjs"; | ||
| import { a as AuthSDK, c as getUserAgent, i as ColumnSDK, l as getVersion, n as RowSDK, o as DimensClient, r as ProjectSDK, s as FlowChatSDK, t as SheetSDK, u as version } from "./sheet-jiBqJC3e.mjs"; | ||
@@ -106,3 +106,3 @@ import { a as registerTool, i as getTool, r as getAllTools, t as registerAllTools } from "./tools-C66Gl8k6.mjs"; | ||
| const { registerAllTools } = await import("./tools-C66Gl8k6.mjs").then((n) => n.n); | ||
| const { registerCommands } = await import("./commands-DhXU3rGj.mjs").then((n) => n.t); | ||
| const { registerCommands } = await import("./commands-5eowaDaS.mjs").then((n) => n.t); | ||
| return { | ||
@@ -109,0 +109,0 @@ name: "@bintel/dimens-cli", |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sheet-jiBqJC3e.mjs","names":[],"sources":["../src/core/version.ts","../src/sdk/flow-chat.ts","../src/core/http.ts","../src/sdk/client.ts","../src/sdk/auth.ts","../src/sdk/column.ts","../src/sdk/project.ts","../src/sdk/row.ts","../src/sdk/sheet.ts"],"sourcesContent":["/**\n * 版本信息\n */\n\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { dirname } from 'path';\n\nlet _version: string | undefined;\n\nexport function getVersion(): string {\n if (_version) return _version;\n\n try {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const packageJsonPath = join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n _version = packageJson.version;\n } catch {\n _version = '1.0.0';\n }\n\n return _version ?? '1.0.0';\n}\n\nexport const version = getVersion();\n\nexport function getUserAgent(): string {\n return `DimensCLI/${version} (Node.js/${process.version})`;\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface FlowChatMessage {\n role: 'system' | 'user' | 'assistant';\n content: string;\n}\n\nexport interface FlowChatCompletionsPayload {\n model?: string | number;\n messages: FlowChatMessage[];\n stream?: boolean;\n user?: string;\n sessionId?: string;\n [key: string]: unknown;\n}\n\nexport interface FlowChatCompletionChoice {\n index?: number;\n message: {\n role: string;\n content: string;\n };\n finish_reason?: string | null;\n}\n\nexport interface FlowChatCompletionResult {\n id: string;\n object?: string;\n created?: number;\n model?: string;\n choices: FlowChatCompletionChoice[];\n usage?: Record<string, unknown>;\n}\n\nexport class FlowChatSDK {\n constructor(private readonly client: DimensClient) {}\n\n completions(\n teamId: string,\n payload: FlowChatCompletionsPayload\n ): Promise<APIResponse<FlowChatCompletionResult>> {\n return this.client.post<FlowChatCompletionResult>(\n `/app/flow/${teamId}/v1/chat/completions`,\n payload\n );\n }\n}\n","export async function requestJson<T>(\n url: string,\n init: RequestInit = {}\n): Promise<T> {\n const response = await fetch(url, init);\n const payload = (await response.json()) as { message?: string };\n\n if (!response.ok) {\n throw new Error(payload?.message || `HTTP ${response.status}`);\n }\n\n return payload as T;\n}\n","import { getUserAgent } from '../core/version';\nimport { requestJson } from '../core/http';\n\nexport interface DimensClientOptions {\n baseUrl: string;\n token?: string;\n refreshToken?: string;\n teamId?: string;\n projectId?: string;\n}\n\nexport interface APIResponse<T> {\n code: number;\n message: string;\n data: T;\n}\n\ntype QueryValue = string | number | boolean | null | undefined;\ntype QueryParams = Record<string, QueryValue>;\ntype HeaderTupleList = Array<[string, string]> | string[][];\ntype HeaderObjectInput = Record<string, string | readonly string[]>;\n\nexport class DimensClient {\n private readonly options: DimensClientOptions;\n\n constructor(options: DimensClientOptions) {\n this.options = options;\n }\n\n getOptions(): DimensClientOptions {\n return { ...this.options };\n }\n\n async get<T>(\n path: string,\n query?: QueryParams,\n init: RequestInit = {}\n ): Promise<APIResponse<T>> {\n return requestJson<APIResponse<T>>(this.buildUrl(path, query), {\n ...init,\n method: 'GET',\n headers: this.buildHeaders(init.headers),\n });\n }\n\n async post<T>(\n path: string,\n body?: unknown,\n init: RequestInit = {}\n ): Promise<APIResponse<T>> {\n const requestInit: RequestInit = {\n ...init,\n method: 'POST',\n headers: this.buildHeaders(init.headers, true),\n };\n\n if (body !== undefined) {\n requestInit.body = JSON.stringify(body);\n }\n\n return requestJson<APIResponse<T>>(this.buildUrl(path), requestInit);\n }\n\n private buildUrl(path: string, query?: QueryParams): string {\n const base = this.options.baseUrl.replace(/\\/+$/, '');\n const normalizedPath = path.startsWith('/') ? path : `/${path}`;\n const url = new URL(`${base}${normalizedPath}`);\n\n Object.entries(query || {}).forEach(([key, value]) => {\n if (value === undefined || value === null || value === '') {\n return;\n }\n url.searchParams.set(key, String(value));\n });\n\n return url.toString();\n }\n\n private buildHeaders(\n headers?: unknown,\n hasJsonBody = false\n ): Record<string, string> {\n const merged = normalizeHeaders(headers);\n merged.Accept = 'application/json';\n merged['User-Agent'] = getUserAgent();\n\n if (hasJsonBody) {\n merged['Content-Type'] = 'application/json';\n }\n if (this.options.token) {\n merged.Authorization = `Bearer ${this.options.token}`;\n }\n if (this.options.refreshToken) {\n merged['X-Refresh-Token'] = this.options.refreshToken;\n }\n\n return merged;\n }\n}\n\nfunction normalizeHeaders(headers?: unknown): Record<string, string> {\n if (!headers) {\n return {};\n }\n if (typeof Headers !== 'undefined' && headers instanceof Headers) {\n return Object.fromEntries(headers.entries());\n }\n if (Array.isArray(headers)) {\n return Object.fromEntries(\n (headers as HeaderTupleList).map(([key, value]) => [String(key), String(value)])\n );\n }\n const normalized: Record<string, string> = {};\n Object.entries(headers as HeaderObjectInput).forEach(([key, value]) => {\n normalized[key] = typeof value === 'string' ? value : value.join(', ');\n });\n return normalized;\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface LoginPayload {\n username: string;\n password: string;\n captchaId?: string;\n verifyCode?: string;\n}\n\nexport interface ApiKeyLoginPayload {\n apiKey: string;\n apiSecret: string;\n}\n\nexport interface LoginResult {\n token: string;\n refreshToken?: string;\n expire?: number;\n userInfo?: Record<string, unknown>;\n}\n\nexport interface RefreshTokenResult {\n token: string;\n refreshToken?: string;\n expire?: number;\n}\n\nexport class AuthSDK {\n constructor(private readonly client: DimensClient) {}\n\n login(payload: LoginPayload): Promise<APIResponse<LoginResult>> {\n return this.client.post<LoginResult>('/login', payload);\n }\n\n loginByApiKey(payload: ApiKeyLoginPayload): Promise<APIResponse<LoginResult>> {\n return this.client.post<LoginResult>('/open/user/login/apiKey', payload);\n }\n\n exchangeTokenByApiKey(\n payload: ApiKeyLoginPayload\n ): Promise<APIResponse<LoginResult>> {\n return this.loginByApiKey(payload);\n }\n\n refreshToken(): Promise<APIResponse<RefreshTokenResult>> {\n return this.client.get<RefreshTokenResult>('/refreshToken');\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface ColumnInfo {\n id: string;\n title?: string;\n label?: string;\n type?: string;\n [key: string]: unknown;\n}\n\nexport interface ColumnMutationPayload {\n title?: string;\n label?: string;\n type?: string;\n description?: string;\n [key: string]: unknown;\n}\n\nexport class ColumnSDK {\n constructor(private readonly client: DimensClient) {}\n\n list(\n teamId: string,\n projectId: string,\n sheetId: string\n ): Promise<APIResponse<ColumnInfo[]>> {\n return this.client.get<ColumnInfo[]>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/column/list`\n );\n }\n\n create(\n teamId: string,\n projectId: string,\n sheetId: string,\n payload: ColumnMutationPayload\n ): Promise<APIResponse<ColumnInfo>> {\n return this.client.post<ColumnInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/column/create`,\n payload\n );\n }\n\n update(\n sheetId: string,\n fieldId: string,\n payload: ColumnMutationPayload\n ): Promise<APIResponse<ColumnInfo>> {\n return this.client.post<ColumnInfo>(\n `/app/mul/sheet/${sheetId}/column/${fieldId}/update`,\n payload\n );\n }\n\n delete(sheetId: string, fieldId: string): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/mul/sheet/${sheetId}/column/${fieldId}/delete`);\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface ProjectInfo {\n id: string;\n name: string;\n [key: string]: unknown;\n}\n\nexport interface ProjectPagePayload {\n page?: number;\n size?: number;\n keyword?: string;\n [key: string]: unknown;\n}\n\nexport interface ProjectPageResult {\n list: ProjectInfo[];\n pagination?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface ProjectMutationPayload {\n id?: string;\n name?: string;\n icon?: string;\n remark?: string;\n [key: string]: unknown;\n}\n\nexport class ProjectSDK {\n constructor(private readonly client: DimensClient) {}\n\n page(teamId: string, payload: ProjectPagePayload): Promise<APIResponse<ProjectPageResult>> {\n return this.client.post<ProjectPageResult>(`/app/org/${teamId}/project/page`, payload);\n }\n\n info(teamId: string, id: string): Promise<APIResponse<ProjectInfo>> {\n return this.client.get<ProjectInfo>(`/app/org/${teamId}/project/info`, { id });\n }\n\n create(\n teamId: string,\n payload: ProjectMutationPayload\n ): Promise<APIResponse<ProjectInfo>> {\n return this.client.post<ProjectInfo>(`/app/org/${teamId}/project/add`, payload);\n }\n\n update(\n teamId: string,\n payload: ProjectMutationPayload\n ): Promise<APIResponse<ProjectInfo>> {\n return this.client.post<ProjectInfo>(`/app/org/${teamId}/project/update`, payload);\n }\n\n trash(teamId: string, ids: string[]): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/org/${teamId}/project/trash`, { ids });\n }\n\n restore(teamId: string, ids: string[]): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/org/${teamId}/project/restore`, { ids });\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface RowInfo {\n id: string;\n [key: string]: unknown;\n}\n\nexport interface RowPagePayload {\n page?: number;\n size?: number;\n viewId?: string;\n filters?: unknown[];\n sorter?: unknown;\n [key: string]: unknown;\n}\n\nexport interface RowPageResult {\n list: RowInfo[];\n total?: number;\n [key: string]: unknown;\n}\n\nexport interface RowCreatePayload {\n data?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface RowCellPayload {\n rowId: string;\n fieldId: string;\n value: unknown;\n version?: number;\n [key: string]: unknown;\n}\n\nexport class RowSDK {\n constructor(private readonly client: DimensClient) {}\n\n page(\n teamId: string,\n projectId: string,\n sheetId: string,\n payload: RowPagePayload\n ): Promise<APIResponse<RowPageResult>> {\n return this.client.post<RowPageResult>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/row/page`,\n payload\n );\n }\n\n info(\n teamId: string,\n projectId: string,\n sheetId: string,\n rowId: string\n ): Promise<APIResponse<RowInfo>> {\n return this.client.get<RowInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/row/${rowId}/info`\n );\n }\n\n create(sheetId: string, payload: RowCreatePayload): Promise<APIResponse<RowInfo>> {\n return this.client.post<RowInfo>(`/app/mul/sheet/${sheetId}/row/create`, payload);\n }\n\n update(\n sheetId: string,\n rowId: string,\n data: Record<string, unknown>,\n version: number\n ): Promise<APIResponse<RowInfo>> {\n return this.client.post<RowInfo>(`/app/mul/sheet/${sheetId}/row/${rowId}/update`, {\n data,\n version,\n });\n }\n\n delete(sheetId: string, rowId: string): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/mul/sheet/${sheetId}/row/${rowId}/delete`);\n }\n\n updateCell(sheetId: string, payload: RowCellPayload): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/mul/sheet/${sheetId}/row/cell`, payload);\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface SheetInfo {\n id: string;\n name?: string;\n [key: string]: unknown;\n}\n\nexport interface SheetMutationPayload {\n name?: string;\n icon?: string;\n folderId?: string;\n [key: string]: unknown;\n}\n\nexport class SheetSDK {\n constructor(private readonly client: DimensClient) {}\n\n list(projectId: string): Promise<APIResponse<SheetInfo[]>> {\n return this.client.get<SheetInfo[]>(`/app/mul/project/${projectId}/sheet/list`);\n }\n\n tree(projectId: string): Promise<APIResponse<unknown[]>> {\n return this.client.get<unknown[]>(`/app/mul/project/${projectId}/sheet/tree`);\n }\n\n create(projectId: string, payload: SheetMutationPayload): Promise<APIResponse<SheetInfo>> {\n return this.client.post<SheetInfo>(`/app/mul/project/${projectId}/sheet/create`, payload);\n }\n\n info(teamId: string, projectId: string, sheetId: string): Promise<APIResponse<SheetInfo>> {\n return this.client.get<SheetInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/info`\n );\n }\n\n update(\n teamId: string,\n projectId: string,\n sheetId: string,\n payload: SheetMutationPayload\n ): Promise<APIResponse<SheetInfo>> {\n return this.client.post<SheetInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/update`,\n payload\n );\n }\n\n delete(teamId: string, projectId: string, sheetId: string): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/delete`\n );\n }\n\n structure(sheetId: string): Promise<APIResponse<Record<string, unknown>>> {\n return this.client.get<Record<string,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S,QAAQ,OAClD;;CAGH,OACE,QACA,WACA,SACA,SACiC;AACjC,SAAO,KAAK,OAAO,KACjB,YAAY,OAAO,GAAG,UAAU,SAAS,QAAQ,UACjD,QACD;;CAGH,OAAO,QAAgB,WAAmB,SAAgD;AACxF,SAAO,KAAK,OAAO,KACjB,YAAY,OAAO,GAAG,UAAU,SAAS,QAAQ,SAClD;;CAGH,UAAU,SAAgE;AACxE,SAAO,KAAK,OAAO,IAA6B,kBAAkB,QAAQ,YAAY"} | ||
| {"version":3,"file":"sheet-jiBqJC3e.mjs","names":[],"sources":["../src/core/version.ts","../src/sdk/flow-chat.ts","../src/core/http.ts","../src/sdk/client.ts","../src/sdk/auth.ts","../src/sdk/column.ts","../src/sdk/project.ts","../src/sdk/row.ts","../src/sdk/sheet.ts"],"sourcesContent":["/**\n * 版本信息\n */\n\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { dirname } from 'path';\n\nlet _version: string | undefined;\n\nexport function getVersion(): string {\n if (_version) return _version;\n\n try {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const packageJsonPath = join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\n _version = packageJson.version;\n } catch {\n _version = '1.0.0';\n }\n\n return _version ?? '1.0.0';\n}\n\nexport const version = getVersion();\n\nexport function getUserAgent(): string {\n return `DimensCLI/${version} (Node.js/${process.version})`;\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface FlowChatMessage {\n role: 'system' | 'user' | 'assistant';\n content: string;\n}\n\nexport interface FlowChatCompletionsPayload {\n model?: string | number;\n messages: FlowChatMessage[];\n stream?: boolean;\n user?: string;\n sessionId?: string;\n [key: string]: unknown;\n}\n\nexport interface FlowChatCompletionChoice {\n index?: number;\n message: {\n role: string;\n content: string;\n };\n finish_reason?: string | null;\n}\n\nexport interface FlowChatCompletionResult {\n id: string;\n object?: string;\n created?: number;\n model?: string;\n choices: FlowChatCompletionChoice[];\n usage?: Record<string, unknown>;\n}\n\nexport class FlowChatSDK {\n constructor(private readonly client: DimensClient) {}\n\n completions(\n teamId: string,\n payload: FlowChatCompletionsPayload\n ): Promise<APIResponse<FlowChatCompletionResult>> {\n return this.client.post<FlowChatCompletionResult>(\n `/app/flow/${teamId}/v1/chat/completions`,\n payload\n );\n }\n}\n","export async function requestJson<T>(\n url: string,\n init: RequestInit = {}\n): Promise<T> {\n const response = await fetch(url, init);\n const payload = (await response.json()) as { message?: string };\n\n if (!response.ok) {\n throw new Error(payload?.message || `HTTP ${response.status}`);\n }\n\n return payload as T;\n}\n","import { getUserAgent } from '../core/version';\nimport { requestJson } from '../core/http';\n\nexport interface DimensClientOptions {\n baseUrl: string;\n token?: string;\n refreshToken?: string;\n teamId?: string;\n projectId?: string;\n}\n\nexport interface APIResponse<T> {\n code: number;\n message: string;\n data: T;\n}\n\ntype QueryValue = string | number | boolean | null | undefined;\ntype QueryParams = Record<string, QueryValue>;\ntype HeaderTupleList = Array<[string, string]> | string[][];\ntype HeaderObjectInput = Record<string, string | readonly string[]>;\n\nexport class DimensClient {\n private readonly options: DimensClientOptions;\n\n constructor(options: DimensClientOptions) {\n this.options = options;\n }\n\n getOptions(): DimensClientOptions {\n return { ...this.options };\n }\n\n async get<T>(\n path: string,\n query?: QueryParams,\n init: RequestInit = {}\n ): Promise<APIResponse<T>> {\n return requestJson<APIResponse<T>>(this.buildUrl(path, query), {\n ...init,\n method: 'GET',\n headers: this.buildHeaders(init.headers),\n });\n }\n\n async post<T>(\n path: string,\n body?: unknown,\n init: RequestInit = {}\n ): Promise<APIResponse<T>> {\n const requestInit: RequestInit = {\n ...init,\n method: 'POST',\n headers: this.buildHeaders(init.headers, true),\n };\n\n if (body !== undefined) {\n requestInit.body = JSON.stringify(body);\n }\n\n return requestJson<APIResponse<T>>(this.buildUrl(path), requestInit);\n }\n\n private buildUrl(path: string, query?: QueryParams): string {\n const base = this.options.baseUrl.replace(/\\/+$/, '');\n const normalizedPath = path.startsWith('/') ? path : `/${path}`;\n const url = new URL(`${base}${normalizedPath}`);\n\n Object.entries(query || {}).forEach(([key, value]) => {\n if (value === undefined || value === null || value === '') {\n return;\n }\n url.searchParams.set(key, String(value));\n });\n\n return url.toString();\n }\n\n private buildHeaders(\n headers?: unknown,\n hasJsonBody = false\n ): Record<string, string> {\n const merged = normalizeHeaders(headers);\n merged.Accept = 'application/json';\n merged['User-Agent'] = getUserAgent();\n\n if (hasJsonBody) {\n merged['Content-Type'] = 'application/json';\n }\n if (this.options.token) {\n merged.Authorization = `Bearer ${this.options.token}`;\n }\n if (this.options.refreshToken) {\n merged['X-Refresh-Token'] = this.options.refreshToken;\n }\n\n return merged;\n }\n}\n\nfunction normalizeHeaders(headers?: unknown): Record<string, string> {\n if (!headers) {\n return {};\n }\n if (typeof Headers !== 'undefined' && headers instanceof Headers) {\n return Object.fromEntries(headers.entries());\n }\n if (Array.isArray(headers)) {\n return Object.fromEntries(\n (headers as HeaderTupleList).map(([key, value]) => [String(key), String(value)])\n );\n }\n const normalized: Record<string, string> = {};\n Object.entries(headers as HeaderObjectInput).forEach(([key, value]) => {\n normalized[key] = typeof value === 'string' ? value : value.join(', ');\n });\n return normalized;\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface LoginPayload {\n username: string;\n password: string;\n captchaId?: string;\n verifyCode?: string;\n}\n\nexport interface ApiKeyLoginPayload {\n apiKey: string;\n apiSecret: string;\n}\n\nexport interface LoginResult {\n token: string;\n refreshToken?: string;\n expire?: number;\n userInfo?: Record<string, unknown>;\n}\n\nexport interface RefreshTokenResult {\n token: string;\n refreshToken?: string;\n expire?: number;\n}\n\nexport class AuthSDK {\n constructor(private readonly client: DimensClient) {}\n\n login(payload: LoginPayload): Promise<APIResponse<LoginResult>> {\n return this.client.post<LoginResult>('/login', payload);\n }\n\n loginByApiKey(payload: ApiKeyLoginPayload): Promise<APIResponse<LoginResult>> {\n return this.client.post<LoginResult>('/open/user/login/apiKey', payload);\n }\n\n exchangeTokenByApiKey(\n payload: ApiKeyLoginPayload\n ): Promise<APIResponse<LoginResult>> {\n return this.loginByApiKey(payload);\n }\n\n refreshToken(): Promise<APIResponse<RefreshTokenResult>> {\n return this.client.get<RefreshTokenResult>('/refreshToken');\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface ColumnInfo {\n id: string;\n title?: string;\n label?: string;\n type?: string;\n [key: string]: unknown;\n}\n\nexport interface ColumnMutationPayload {\n title?: string;\n label?: string;\n type?: string;\n description?: string;\n config?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport class ColumnSDK {\n constructor(private readonly client: DimensClient) {}\n\n list(\n teamId: string,\n projectId: string,\n sheetId: string\n ): Promise<APIResponse<ColumnInfo[]>> {\n return this.client.get<ColumnInfo[]>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/column/list`\n );\n }\n\n create(\n teamId: string,\n projectId: string,\n sheetId: string,\n payload: ColumnMutationPayload\n ): Promise<APIResponse<ColumnInfo>> {\n return this.client.post<ColumnInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/column/create`,\n payload\n );\n }\n\n update(\n sheetId: string,\n fieldId: string,\n payload: ColumnMutationPayload\n ): Promise<APIResponse<ColumnInfo>> {\n return this.client.post<ColumnInfo>(\n `/app/mul/sheet/${sheetId}/column/${fieldId}/update`,\n payload\n );\n }\n\n delete(sheetId: string, fieldId: string): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/mul/sheet/${sheetId}/column/${fieldId}/delete`);\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface ProjectInfo {\n id: string;\n name: string;\n [key: string]: unknown;\n}\n\nexport interface ProjectPagePayload {\n page?: number;\n size?: number;\n keyword?: string;\n [key: string]: unknown;\n}\n\nexport interface ProjectPageResult {\n list: ProjectInfo[];\n pagination?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface ProjectMutationPayload {\n id?: string;\n name?: string;\n icon?: string;\n remark?: string;\n [key: string]: unknown;\n}\n\nexport class ProjectSDK {\n constructor(private readonly client: DimensClient) {}\n\n page(teamId: string, payload: ProjectPagePayload): Promise<APIResponse<ProjectPageResult>> {\n return this.client.post<ProjectPageResult>(`/app/org/${teamId}/project/page`, payload);\n }\n\n info(teamId: string, id: string): Promise<APIResponse<ProjectInfo>> {\n return this.client.get<ProjectInfo>(`/app/org/${teamId}/project/info`, { id });\n }\n\n create(\n teamId: string,\n payload: ProjectMutationPayload\n ): Promise<APIResponse<ProjectInfo>> {\n return this.client.post<ProjectInfo>(`/app/org/${teamId}/project/add`, payload);\n }\n\n update(\n teamId: string,\n payload: ProjectMutationPayload\n ): Promise<APIResponse<ProjectInfo>> {\n return this.client.post<ProjectInfo>(`/app/org/${teamId}/project/update`, payload);\n }\n\n trash(teamId: string, ids: string[]): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/org/${teamId}/project/trash`, { ids });\n }\n\n restore(teamId: string, ids: string[]): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/org/${teamId}/project/restore`, { ids });\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface RowInfo {\n id: string;\n [key: string]: unknown;\n}\n\nexport interface RowPagePayload {\n page?: number;\n size?: number;\n viewId?: string;\n filters?: unknown[];\n sorter?: unknown;\n [key: string]: unknown;\n}\n\nexport interface RowPageResult {\n list: RowInfo[];\n total?: number;\n [key: string]: unknown;\n}\n\nexport interface RowCreatePayload {\n data?: Record<string, unknown>;\n [key: string]: unknown;\n}\n\nexport interface RowCellPayload {\n rowId: string;\n fieldId: string;\n value: unknown;\n version?: number;\n [key: string]: unknown;\n}\n\nexport class RowSDK {\n constructor(private readonly client: DimensClient) {}\n\n page(\n teamId: string,\n projectId: string,\n sheetId: string,\n payload: RowPagePayload\n ): Promise<APIResponse<RowPageResult>> {\n return this.client.post<RowPageResult>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/row/page`,\n payload\n );\n }\n\n info(\n teamId: string,\n projectId: string,\n sheetId: string,\n rowId: string\n ): Promise<APIResponse<RowInfo>> {\n return this.client.get<RowInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/row/${rowId}/info`\n );\n }\n\n create(sheetId: string, payload: RowCreatePayload): Promise<APIResponse<RowInfo>> {\n return this.client.post<RowInfo>(`/app/mul/sheet/${sheetId}/row/create`, payload);\n }\n\n update(\n sheetId: string,\n rowId: string,\n data: Record<string, unknown>,\n version: number\n ): Promise<APIResponse<RowInfo>> {\n return this.client.post<RowInfo>(`/app/mul/sheet/${sheetId}/row/${rowId}/update`, {\n data,\n version,\n });\n }\n\n delete(sheetId: string, rowId: string): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/mul/sheet/${sheetId}/row/${rowId}/delete`);\n }\n\n updateCell(sheetId: string, payload: RowCellPayload): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(`/app/mul/sheet/${sheetId}/row/cell`, payload);\n }\n}\n","import type { APIResponse } from './client';\nimport { DimensClient } from './client';\n\nexport interface SheetInfo {\n id: string;\n name?: string;\n [key: string]: unknown;\n}\n\nexport interface SheetMutationPayload {\n name?: string;\n icon?: string;\n folderId?: string;\n [key: string]: unknown;\n}\n\nexport class SheetSDK {\n constructor(private readonly client: DimensClient) {}\n\n list(projectId: string): Promise<APIResponse<SheetInfo[]>> {\n return this.client.get<SheetInfo[]>(`/app/mul/project/${projectId}/sheet/list`);\n }\n\n tree(projectId: string): Promise<APIResponse<unknown[]>> {\n return this.client.get<unknown[]>(`/app/mul/project/${projectId}/sheet/tree`);\n }\n\n create(projectId: string, payload: SheetMutationPayload): Promise<APIResponse<SheetInfo>> {\n return this.client.post<SheetInfo>(`/app/mul/project/${projectId}/sheet/create`, payload);\n }\n\n info(teamId: string, projectId: string, sheetId: string): Promise<APIResponse<SheetInfo>> {\n return this.client.get<SheetInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/info`\n );\n }\n\n update(\n teamId: string,\n projectId: string,\n sheetId: string,\n payload: SheetMutationPayload\n ): Promise<APIResponse<SheetInfo>> {\n return this.client.post<SheetInfo>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/update`,\n payload\n );\n }\n\n delete(teamId: string, projectId: string, sheetId: string): Promise<APIResponse<boolean>> {\n return this.client.post<boolean>(\n `/app/mul/${teamId}/${projectId}/sheet/${sheetId}/delete`\n );\n }\n\n structure(sheetId: string): Promise<APIResponse<Record<string, unknown>>> {\n return this.client.get<Record<string, unknown>>(`/app/mul/sheet/${sheetId}/structure`);\n }\n}\n"],"mappings":";;;;;;;;AASA,IAAI;AAEJ,SAAgB,aAAqB;AACnC,KAAI,SAAU,QAAO;AAErB,KAAI;EAGF,MAAM,kBAAkB,KADN,QADC,cAAc,OAAO,KAAK,IAAI,CACZ,EACG,MAAM,MAAM,eAAe;AAEnE,aADoB,KAAK,MAAM,aAAa,iBAAiB,QAAQ,CAAC,CAC/C;SACjB;AACN,aAAW;;AAGb,QAAO,YAAY;;AAGrB,MAAa,UAAU,YAAY;AAEnC,SAAgB,eAAuB;AACrC,QAAO,aAAa,QAAQ,YAAY,QAAQ,QAAQ;;;;;ACK1D,IAAa,cAAb,MAAyB;CACvB,YAAY,AAAiB,QAAsB;EAAtB;;CAE7B,YACE,QACA,SACgD;AAChD,SAAO,KAAK,OAAO,KACjB,aAAa,OAAO,uBACpB,QACD;;;;;;AC7CL,eAAsB,YACpB,KACA,OAAoB,EAAE,EACV;CACZ,MAAM,WAAW,MAAM,MAAM,KAAK,KAAK;CACvC,MAAM,UAAW,MAAM,SAAS,MAAM;AAEtC,KAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MAAM,SAAS,WAAW,QAAQ,SAAS,SAAS;AAGhE,QAAO;;;;;ACWT,IAAa,eAAb,MAA0B;CACxB,AAAiB;CAEjB,YAAY,SAA8B;AACxC,OAAK,UAAU;;CA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a,WAAb,MAAsB;CACpB,YAAY,AAAiB,QAAsB;EAAtB;;CAE7B,KAAK,WAAsD;AACzD,SAAO,KAAK,OAAO,IAAiB,oBAAoB,UAAU,aAAa;;CAGjF,KAAK,WAAoD;AACvD,SAAO,KAAK,OAAO,IAAe,oBAAoB,UAAU,aAAa;;CAG/E,OAAO,WAAmB,SAAgE;AACxF,SAAO,KAAK,OAAO,KAAgB,oBAAoB,UAAU,gBAAgB,QAAQ;;CAG3F,KAAK,QAAgB,WAAmB,SAAkD;AACxF,SAAO,KAAK,OAAO,IACjB,YAAY,OAAO,GAAG,UAAU,SAAS,QAAQ,OAClD;;CAGH,OACE,QACA,WACA,SACA,SACiC;AACjC,SAAO,KAAK,OAAO,KACjB,YAAY,OAAO,GAAG,UAAU,SAAS,QAAQ,UACjD,QACD;;CAGH,OAAO,QAAgB,WAAmB,SAAgD;AACxF,SAAO,KAAK,OAAO,KACjB,YAAY,OAAO,GAAG,UAAU,SAAS,QAAQ,SAClD;;CAGH,UAAU,SAAgE;AACxE,SAAO,KAAK,OAAO,IAA6B,kBAAkB,QAAQ,YAAY"} |
+2
-2
| { | ||
| "name": "@bintel/dimens-cli", | ||
| "version": "1.0.2", | ||
| "description": "Dimens CLI 与 Node.js SDK,提供多维项目的认证、项目、表格、行数据与 AI chat-completions 调用能力", | ||
| "version": "1.0.3", | ||
| "description": "Dimens CLI 与 Node.js SDK,提供维表智联项目的认证、项目、表格、行数据与 AI chat-completions 调用能力", | ||
| "type": "module", | ||
@@ -6,0 +6,0 @@ "exports": { |
| --- | ||
| name: dimens-key-auth | ||
| description: | | ||
| 维表智联中的 API Key / API Secret 鉴权技能,覆盖 Key 创建、启停、删除、重置 Secret、登录换 token 与调用边界说明。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 需要创建或管理 API Key | ||
| (2) 需要使用 `apiKey + apiSecret` 换取登录 token | ||
| (3) 需要说明第三方系统如何复用现有 `/app/*` 接口 | ||
| (4) 用户提到“key 登录”、“apiKey”、“apiSecret”、“开放接口”、“token 换取” | ||
| (5) 需要解释 API Key 的安全边界、权限边界、数量限制或 IP 白名单 | ||
| slug: dimens-key-auth | ||
| description: 用于维表智联 API Key / API Secret 登录换取 token、分析第三方接入边界、排查 Key 与权限链路问题。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [auth, api-key, token, integration, dimens-cli] | ||
| --- | ||
@@ -13,0 +9,0 @@ |
| --- | ||
| name: dimens-permission | ||
| description: | | ||
| 维表智联中的权限技能,覆盖团队准入、表级权限、列级权限、行级权限、公开访问者、协同权限快照与广播过滤。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 需要解释为什么用户能看、不能看、能改、不能改某个资源 | ||
| (2) 需要排查表格、字段、行、协同广播相关的权限问题 | ||
| (3) 用户提到“权限”、“行级权限”、“列权限”、“公开访问”、“协同越权”、“只读” | ||
| (4) 需要解释行分页读取链路与 `yjs-socket` 为什么表现不同 | ||
| (5) 需要结合团队、项目、公开角色、缓存和 Yjs 协同分析问题 | ||
| slug: dimens-permission | ||
| description: 用于维表智联团队准入、表列行权限、公开访问与协同广播链路分析,适合排查“能看不能改”类权限问题。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [permission, access-control, yjs, security, dimens-cli] | ||
| --- | ||
@@ -13,0 +9,0 @@ |
| --- | ||
| name: dimens-report | ||
| description: | | ||
| 维表智联中的报表技能,覆盖报表、图表组件、参数联动、数据源配置、查询链路和项目级权限边界。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 需要查询、创建、修改、发布或说明报表 | ||
| (2) 需要解释图表组件、数据源、参数联动和导出链路 | ||
| (3) 用户提到“报表”、“图表”、“dashboard”、“参数筛选”、“数据源” | ||
| (4) 需要说明报表为什么查不到数据、组件不显示或参数联动异常 | ||
| (5) 需要结合项目权限和多维表格数据源解释报表问题 | ||
| slug: dimens-report | ||
| description: 用于维表智联报表、图表组件、参数联动和数据源查询链路说明,适合排查报表无数据或参数异常问题。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [report, dashboard, data-source, analytics, dimens-cli] | ||
| --- | ||
@@ -13,0 +9,0 @@ |
| --- | ||
| name: dimens-system-orchestrator | ||
| description: | | ||
| 维表智联中的系统级总控编排技能,用于接住“生成一个 XX 系统 / 平台 / 管理系统 / 业务系统”这类系统建设需求,先做系统拆解,再路由到合适的子 Skill。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 用户要“生成一个客户管理系统 / CRM / 平台 / 管理系统 / 业务系统” | ||
| (2) 用户描述的是完整业务系统,而不是单一表、单一权限、单一工作流问题 | ||
| (3) 需要先拆模块,再决定调用哪些子 Skill | ||
| (4) 需要生成系统建设方案、模块清单、执行顺序和风险提示 | ||
| (5) 用户还没有明确团队、表结构、权限、工作流、报表等具体边界 | ||
| slug: dimens-system-orchestrator | ||
| description: 用于维表智联系统级方案拆解与技能路由,适合“生成一个客户管理系统/平台”这类完整业务系统搭建需求。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [orchestrator, system-design, routing, planning, dimens-cli] | ||
| --- | ||
@@ -13,0 +9,0 @@ |
@@ -217,2 +217,8 @@ # dimens-table 接口案例 | ||
| 补充说明: | ||
| - `dimens-cli column create --type relation` 当前已支持把 `--target-sheet-id` 映射为 `config.relationConfig.targetSheetId` | ||
| - 推荐同时传 `--display-column-id`,避免 relation 展示值异常 | ||
| - 如果后续仍出现“CLI 成功但字段未落库”,优先对照服务端最终入库结构核对 `config.relationConfig` | ||
| ## 5. 查询行分页 | ||
@@ -219,0 +225,0 @@ |
@@ -171,2 +171,34 @@ # dimens-table 字段设计模式 | ||
| ### 4.2.1 relation 字段模板 | ||
| CLI 参数: | ||
| - `--type relation` | ||
| - `--target-sheet-id <目标表ID>` | ||
| - `--display-column-id <目标表展示字段ID>` | ||
| - `--bidirectional true|false` | ||
| - `--multiple true|false` | ||
| API body 格式: | ||
| ```json | ||
| { | ||
| "label": "字段名称", | ||
| "type": "relation", | ||
| "config": { | ||
| "relationConfig": { | ||
| "targetSheetId": "sh_目标表ID", | ||
| "displayColumnId": "fld_显示字段ID", | ||
| "bidirectional": false | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| 说明: | ||
| - `--target-sheet-id` 对应服务端真实字段 `config.relationConfig.targetSheetId` | ||
| - `displayColumnId` 建议显式提供,否则关联值展示体验通常不稳定 | ||
| - 行写入 relation 值前,仍然需要先确认目标表和展示字段 | ||
| ### 4.3 relation 字段的常见失败点 | ||
@@ -173,0 +205,0 @@ |
| --- | ||
| name: dimens-table | ||
| description: | | ||
| 维表智联中的多维表格技能,覆盖工作表、字段、视图、行数据、系统视图映射和表格相关业务上下文。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 需要查询、创建、修改、删除工作表、字段、视图或行数据 | ||
| (2) 需要解释字段类型、系统视图字段、项目级绑定与默认回退 | ||
| (3) 用户提到“多维表格”、“sheet”、“row”、“column”、“view”、“字段类型” | ||
| (4) 需要结合 `teamId`、`projectId`、`sheetId` 解释表格相关问题 | ||
| (5) 需要说明工作流系统视图与项目级表格入口之间的关系 | ||
| slug: dimens-table | ||
| description: 用于维表智联工作表、字段、视图和行数据设计与排查,适合多维表格建模、字段写入和查询链路说明。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [table, sheet, row, column, dimens-cli] | ||
| --- | ||
@@ -29,2 +25,3 @@ | ||
| - ✅ 字段设计必须细到可落地,不能只写“有客户名称、状态、时间”这种抽象描述 | ||
| - ✅ relation 字段创建必须补齐目标表,推荐显式传 `--target-sheet-id`,并尽量补 `--display-column-id` | ||
| - ✅ `row/page` 默认要按“基于字段的搜索、筛选、排序”来解释,不只是分页 | ||
@@ -31,0 +28,0 @@ - ✅ 系统视图相关问题要区分团队级默认字段和项目级实际分配字段 |
| --- | ||
| name: dimens-team | ||
| description: | | ||
| 维表智联中的团队与项目上下文技能,覆盖团队、成员、部门、项目、租户隔离和默认上下文判断。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 需要查询团队、成员、项目、部门或租户隔离关系 | ||
| (2) 需要判断某个用户为什么看得到或看不到某个项目 | ||
| (3) 需要说明 `teamId`、`projectId` 在命令、SDK、接口中的作用 | ||
| (4) 用户提到“团队”、“项目”、“成员”、“部门”、“空间”、“租户隔离” | ||
| (5) 需要为其他 Skill 提供上游上下文判断 | ||
| slug: dimens-team | ||
| description: 用于维表智联团队、成员、项目和租户隔离上下文分析,适合确认 teamId/projectId 与资源归属关系。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [team, project, tenant, context, dimens-cli] | ||
| --- | ||
@@ -13,0 +9,0 @@ |
| --- | ||
| name: dimens-workflow | ||
| description: | | ||
| 维表智联中的 AI 工作流技能,覆盖团队工作流定义、项目工作流挂载、运行调用、默认模型与节点模型配置边界。 | ||
| **当以下情况时使用此 Skill**: | ||
| (1) 需要查询、解释、调用团队工作流 | ||
| (2) 需要判断工作流为什么在项目中看不到、不能运行或不能发布 | ||
| (3) 需要说明默认模型、节点模型、OpenAI 兼容聊天接口与执行链路 | ||
| (4) 用户提到“工作流”、“AI 分析”、“审批流程”、“自动化”、“flow”、“chat completions” | ||
| (5) 需要结合 `teamId`、`projectId`、权限边界分析工作流相关问题 | ||
| slug: dimens-workflow | ||
| description: 用于维表智联工作流定义、项目挂载、运行调用与模型配置边界说明,适合排查工作流不可见或不可运行问题。 | ||
| version: 1.0.0 | ||
| author: 方块智联工作室 | ||
| tags: [workflow, ai, automation, flow, dimens-cli] | ||
| --- | ||
@@ -13,0 +9,0 @@ |
| import { t as __exportAll } from "./rolldown-runtime-95iHPtFO.mjs"; | ||
| import { n as logger } from "./logger-CEOtAYhF.mjs"; | ||
| import { a as AuthSDK, i as ColumnSDK, l as getVersion, n as RowSDK, o as DimensClient, r as ProjectSDK, s as FlowChatSDK, t as SheetSDK } from "./sheet-jiBqJC3e.mjs"; | ||
| import { readFile, writeFile } from "fs/promises"; | ||
| import { join } from "path"; | ||
| import { homedir } from "os"; | ||
| import { existsSync, readFileSync, readdirSync, statSync } from "node:fs"; | ||
| import { dirname as dirname$1, join as join$1, relative, resolve } from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| //#region src/core/config.ts | ||
| /** | ||
| * 配置管理 | ||
| */ | ||
| const DEFAULT_CONFIG = { | ||
| version: "1.0.0", | ||
| profile: {}, | ||
| skills: {}, | ||
| preferences: {} | ||
| }; | ||
| var ConfigManager = class { | ||
| configPath; | ||
| config; | ||
| constructor() { | ||
| this.configPath = join(homedir(), ".dimens-cli", "config.json"); | ||
| this.config = DEFAULT_CONFIG; | ||
| } | ||
| async load() { | ||
| try { | ||
| const data = await readFile(this.configPath, "utf-8"); | ||
| const parsed = JSON.parse(data); | ||
| this.config = { | ||
| ...DEFAULT_CONFIG, | ||
| ...parsed, | ||
| profile: { | ||
| ...DEFAULT_CONFIG.profile, | ||
| ...parsed.profile || {} | ||
| }, | ||
| skills: parsed.skills || {}, | ||
| preferences: parsed.preferences || {} | ||
| }; | ||
| logger.debug("配置加载成功", { path: this.configPath }); | ||
| } catch (error) { | ||
| logger.debug("配置文件不存在,使用默认配置"); | ||
| this.config = { | ||
| ...DEFAULT_CONFIG, | ||
| profile: { ...DEFAULT_CONFIG.profile } | ||
| }; | ||
| } | ||
| } | ||
| async save() { | ||
| try { | ||
| const { mkdir } = await import("fs/promises"); | ||
| await mkdir(join(homedir(), ".dimens-cli"), { recursive: true }); | ||
| await writeFile(this.configPath, JSON.stringify(this.config, null, 2), "utf-8"); | ||
| logger.debug("配置保存成功", { path: this.configPath }); | ||
| } catch (error) { | ||
| logger.error("配置保存失败", { error: String(error) }); | ||
| throw error; | ||
| } | ||
| } | ||
| get(key) { | ||
| return this.config[key]; | ||
| } | ||
| set(key, value) { | ||
| this.config[key] = value; | ||
| } | ||
| getAll() { | ||
| return { | ||
| ...this.config, | ||
| profile: { ...this.config.profile }, | ||
| skills: { ...this.config.skills }, | ||
| preferences: { ...this.config.preferences } | ||
| }; | ||
| } | ||
| }; | ||
| const config = new ConfigManager(); | ||
| //#endregion | ||
| //#region src/commands/registry.ts | ||
| const registeredCommands = /* @__PURE__ */ new Map(); | ||
| const registeredGroups = /* @__PURE__ */ new Map(); | ||
| const qualifiedCommands = /* @__PURE__ */ new Map(); | ||
| function createCommandGroup(name, description) { | ||
| const group = { | ||
| name, | ||
| description, | ||
| commands: [] | ||
| }; | ||
| registeredGroups.set(name, group); | ||
| return group; | ||
| } | ||
| function registerCommand(command) { | ||
| if (registeredCommands.has(command.name)) logger.warn(`命令 ${command.name} 已存在,将被覆盖`); | ||
| registeredCommands.set(command.name, command); | ||
| if (command.aliases) command.aliases.forEach((alias) => { | ||
| registeredCommands.set(alias, command); | ||
| }); | ||
| logger.debug(`命令已注册: ${command.name}`); | ||
| } | ||
| function registerGroupCommand(groupName, command) { | ||
| (registeredGroups.get(groupName) || createCommandGroup(groupName, groupName)).commands.push(command); | ||
| const qualifiedName = `${groupName}:${command.name}`; | ||
| qualifiedCommands.set(qualifiedName, command); | ||
| if (groupName === "system" || groupName === "auth") { | ||
| registerCommand(command); | ||
| return; | ||
| } | ||
| if (command.aliases) command.aliases.forEach((alias) => { | ||
| qualifiedCommands.set(`${groupName}:${alias}`, command); | ||
| }); | ||
| logger.debug(`命令已注册: ${qualifiedName}`); | ||
| } | ||
| function getCommand(name) { | ||
| return registeredCommands.get(name); | ||
| } | ||
| function getGroupCommand(groupName, commandName) { | ||
| return qualifiedCommands.get(`${groupName}:${commandName}`); | ||
| } | ||
| function getAllCommands() { | ||
| const uniqueCommands = new Set(registeredCommands.values()); | ||
| return Array.from(uniqueCommands); | ||
| } | ||
| function getCommandGroup(name) { | ||
| return registeredGroups.get(name); | ||
| } | ||
| function getAllCommandGroups() { | ||
| return Array.from(registeredGroups.values()); | ||
| } | ||
| function clearCommands() { | ||
| registeredCommands.clear(); | ||
| registeredGroups.clear(); | ||
| qualifiedCommands.clear(); | ||
| logger.debug("所有命令已清除"); | ||
| } | ||
| function createCommand(name, description, handler, options) { | ||
| return { | ||
| name, | ||
| description, | ||
| handler, | ||
| ...options | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/skills/mappings.ts | ||
| const SKILL_MAPPINGS = { | ||
| "dimens-system-orchestrator": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "system", | ||
| "orchestrator", | ||
| "planner", | ||
| "routing", | ||
| "builder" | ||
| ], | ||
| commandGroups: ["skill"], | ||
| commands: [ | ||
| "skill recommend", | ||
| "skill info", | ||
| "skill show" | ||
| ], | ||
| sdkModules: [], | ||
| toolNames: ["system_decomposition", "skill_routing"] | ||
| }, | ||
| "dimens-workflow": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "workflow", | ||
| "flow", | ||
| "ai", | ||
| "project", | ||
| "team" | ||
| ], | ||
| commandGroups: ["ai"], | ||
| commands: ["ai chat-completions"], | ||
| sdkModules: ["FlowChatSDK", "DimensSDK.ai"], | ||
| toolNames: [ | ||
| "flow_list", | ||
| "project_workflow_binding_list", | ||
| "flow_run_invoke", | ||
| "flow_run_debug", | ||
| "flow_config_get" | ||
| ] | ||
| }, | ||
| "dimens-key-auth": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "auth", | ||
| "api-key", | ||
| "token", | ||
| "login", | ||
| "security" | ||
| ], | ||
| commandGroups: ["auth"], | ||
| commands: [ | ||
| "auth api-key-login", | ||
| "auth login", | ||
| "auth refresh", | ||
| "auth status", | ||
| "auth profile" | ||
| ], | ||
| sdkModules: ["AuthSDK", "DimensSDK.auth"], | ||
| toolNames: [ | ||
| "api_key_create", | ||
| "api_key_list", | ||
| "api_key_status", | ||
| "api_key_delete", | ||
| "api_key_reset_secret", | ||
| "api_key_log_page" | ||
| ] | ||
| }, | ||
| "dimens-team": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "team", | ||
| "project", | ||
| "tenant", | ||
| "member", | ||
| "context" | ||
| ], | ||
| commandGroups: ["auth", "project"], | ||
| commands: [ | ||
| "auth use-team", | ||
| "auth use-project", | ||
| "project list", | ||
| "project info", | ||
| "project create", | ||
| "project update", | ||
| "project trash", | ||
| "project restore" | ||
| ], | ||
| sdkModules: ["ProjectSDK", "DimensSDK.project"], | ||
| toolNames: [ | ||
| "team_info", | ||
| "team_user_list", | ||
| "project_list", | ||
| "project_info", | ||
| "project_create", | ||
| "project_update", | ||
| "project_trash", | ||
| "project_restore" | ||
| ] | ||
| }, | ||
| "dimens-table": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "table", | ||
| "sheet", | ||
| "row", | ||
| "column", | ||
| "view" | ||
| ], | ||
| commandGroups: [ | ||
| "sheet", | ||
| "column", | ||
| "row" | ||
| ], | ||
| commands: [ | ||
| "sheet list", | ||
| "sheet tree", | ||
| "sheet create", | ||
| "sheet info", | ||
| "sheet update", | ||
| "sheet delete", | ||
| "column list", | ||
| "column create", | ||
| "column update", | ||
| "column delete", | ||
| "row page", | ||
| "row info", | ||
| "row create", | ||
| "row update", | ||
| "row delete", | ||
| "row set-cell" | ||
| ], | ||
| sdkModules: [ | ||
| "SheetSDK", | ||
| "ColumnSDK", | ||
| "RowSDK", | ||
| "DimensSDK.sheet", | ||
| "DimensSDK.column", | ||
| "DimensSDK.row" | ||
| ], | ||
| toolNames: [ | ||
| "sheet_list", | ||
| "sheet_info", | ||
| "column_list", | ||
| "column_create", | ||
| "row_page", | ||
| "row_update", | ||
| "row_set_cell" | ||
| ] | ||
| }, | ||
| "dimens-permission": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "permission", | ||
| "acl", | ||
| "row-policy", | ||
| "yjs", | ||
| "security" | ||
| ], | ||
| commandGroups: [], | ||
| commands: [], | ||
| sdkModules: [], | ||
| toolNames: [ | ||
| "project_authority_check", | ||
| "permission_resolve", | ||
| "column_permission_resolve", | ||
| "row_policy_check", | ||
| "yjs_permission_snapshot" | ||
| ] | ||
| }, | ||
| "dimens-report": { | ||
| version: "1.0.0", | ||
| tags: [ | ||
| "report", | ||
| "chart", | ||
| "dashboard", | ||
| "parameter", | ||
| "query" | ||
| ], | ||
| commandGroups: [], | ||
| commands: [], | ||
| sdkModules: [], | ||
| toolNames: [ | ||
| "report_list", | ||
| "report_info", | ||
| "report_widget_list", | ||
| "report_parameter_list", | ||
| "report_query", | ||
| "report_export" | ||
| ] | ||
| } | ||
| }; | ||
| function getSkillMapping(name) { | ||
| return SKILL_MAPPINGS[name]; | ||
| } | ||
| //#endregion | ||
| //#region src/skills/index.ts | ||
| /** | ||
| * 技能发现与读取 | ||
| */ | ||
| function getPackageRoot() { | ||
| const currentDir = dirname$1(fileURLToPath(import.meta.url)); | ||
| return [resolve(currentDir, "../"), resolve(currentDir, "../../")].find((candidate) => existsSync(join$1(candidate, "package.json")) && existsSync(join$1(candidate, "skills"))) ?? resolve(currentDir, "../../"); | ||
| } | ||
| function getSkillsRoot() { | ||
| return join$1(getPackageRoot(), "skills"); | ||
| } | ||
| function parseFrontmatter(content) { | ||
| const lines = content.split("\n"); | ||
| if (lines[0]?.trim() !== "---") return {}; | ||
| let i = 1; | ||
| const data = {}; | ||
| while (i < lines.length) { | ||
| const line = lines[i]; | ||
| if (line?.trim() === "---") break; | ||
| if (line?.startsWith("name:")) { | ||
| data.name = line.slice(5).trim(); | ||
| i += 1; | ||
| continue; | ||
| } | ||
| if (line?.startsWith("description:")) { | ||
| const inline = line.slice(12).trim(); | ||
| if (inline && inline !== "|") { | ||
| data.description = inline; | ||
| i += 1; | ||
| continue; | ||
| } | ||
| i += 1; | ||
| const block = []; | ||
| while (i < lines.length) { | ||
| const next = lines[i]; | ||
| if (!next) { | ||
| block.push(""); | ||
| i += 1; | ||
| continue; | ||
| } | ||
| if (!next.startsWith(" ")) break; | ||
| block.push(next.slice(2)); | ||
| i += 1; | ||
| } | ||
| data.description = block.join("\n").trim(); | ||
| continue; | ||
| } | ||
| i += 1; | ||
| } | ||
| return data; | ||
| } | ||
| function listReferenceFiles(referencesDir) { | ||
| if (!existsSync(referencesDir)) return []; | ||
| return readdirSync(referencesDir).filter((file) => file.endsWith(".md")).sort().map((file) => join$1(referencesDir, file)); | ||
| } | ||
| function loadSkillFromDirectory(skillDir) { | ||
| const skillPath = join$1(skillDir, "SKILL.md"); | ||
| if (!existsSync(skillPath) || !statSync(skillPath).isFile()) return; | ||
| const frontmatter = parseFrontmatter(readFileSync(skillPath, "utf8")); | ||
| const name = frontmatter.name?.trim(); | ||
| const description = frontmatter.description?.trim(); | ||
| if (!name || !description) return; | ||
| const referencesDir = join$1(skillDir, "references"); | ||
| const mapping = getSkillMapping(name); | ||
| const skill = { | ||
| name, | ||
| description, | ||
| skillPath, | ||
| references: listReferenceFiles(referencesDir), | ||
| ...mapping | ||
| }; | ||
| if (existsSync(referencesDir)) skill.referencesDir = referencesDir; | ||
| return skill; | ||
| } | ||
| function discoverSkills() { | ||
| const skillsRoot = getSkillsRoot(); | ||
| if (!existsSync(skillsRoot)) return []; | ||
| return readdirSync(skillsRoot).map((entry) => join$1(skillsRoot, entry)).filter((entryPath) => statSync(entryPath).isDirectory()).map(loadSkillFromDirectory).filter((skill) => Boolean(skill)).sort((a, b) => a.name.localeCompare(b.name, "zh-CN")); | ||
| } | ||
| const SKILLS = discoverSkills(); | ||
| function getSkill(name) { | ||
| return SKILLS.find((skill) => skill.name === name); | ||
| } | ||
| function getAllSkills() { | ||
| return [...SKILLS]; | ||
| } | ||
| function getSkillsRootPath() { | ||
| return getSkillsRoot(); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/help.ts | ||
| function findRelatedSkills(groupName, commandName) { | ||
| const qualifiedCommand = commandName ? `${groupName} ${commandName}` : void 0; | ||
| return getAllSkills().filter((skill) => { | ||
| const matchesGroup = skill.commandGroups?.includes(groupName) ?? false; | ||
| const matchesCommand = qualifiedCommand ? skill.commands?.includes(qualifiedCommand) ?? false : false; | ||
| return matchesGroup || matchesCommand; | ||
| }).map((skill) => skill.name).sort((a, b) => a.localeCompare(b, "zh-CN")); | ||
| } | ||
| function printRelatedSkills(groupName, commandName) { | ||
| const relatedSkills = findRelatedSkills(groupName, commandName); | ||
| if (relatedSkills.length === 0) return; | ||
| console.log("相关 Skill:"); | ||
| relatedSkills.forEach((skillName) => { | ||
| console.log(` - ${skillName}`); | ||
| }); | ||
| } | ||
| const helpCommand = { | ||
| name: "help", | ||
| description: "显示帮助信息", | ||
| usage: "help [command] [subcommand]", | ||
| aliases: ["h", "?"], | ||
| handler: async (args) => { | ||
| if (args.length > 0) { | ||
| const groupName = args[0]; | ||
| const commandName = args[1]; | ||
| if (!groupName) return; | ||
| const group = getCommandGroup(groupName); | ||
| if (!group) { | ||
| console.log(`未找到命令组: ${groupName}`); | ||
| return; | ||
| } | ||
| if (commandName) { | ||
| const command = group.commands.find((c) => c.name === commandName || c.aliases?.includes(commandName)); | ||
| if (!command) { | ||
| console.log(`未找到命令: ${groupName} ${commandName}`); | ||
| return; | ||
| } | ||
| console.log(`\n命令: ${group.name} ${command.name}`); | ||
| console.log(`描述: ${command.description}`); | ||
| if (command.usage) console.log(`用法: ${command.usage}`); | ||
| if (command.aliases && command.aliases.length > 0) console.log(`别名: ${command.aliases.join(", ")}`); | ||
| if (command.examples && command.examples.length > 0) { | ||
| console.log("示例:"); | ||
| command.examples.forEach((example) => { | ||
| console.log(` ${example}`); | ||
| }); | ||
| } | ||
| printRelatedSkills(group.name, command.name); | ||
| console.log(""); | ||
| return; | ||
| } | ||
| console.log(`\n命令组: ${group.name}`); | ||
| console.log(`描述: ${group.description}`); | ||
| console.log("可用命令:"); | ||
| group.commands.forEach((command) => { | ||
| console.log(` ${command.name.padEnd(15)} ${command.description}`); | ||
| }); | ||
| printRelatedSkills(group.name); | ||
| console.log(""); | ||
| return; | ||
| } | ||
| console.log("\nDimens CLI - 多维项目开发助手"); | ||
| console.log(`版本: ${getVersion()}\n`); | ||
| console.log("可用命令组:\n"); | ||
| getAllCommandGroups().forEach((group) => { | ||
| console.log(` ${group.name.padEnd(15)} ${group.description}`); | ||
| }); | ||
| console.log("\n使用 \"help [group]\" 查看命令组,使用 \"help [group] [command]\" 查看具体命令"); | ||
| console.log("使用 \"help skill\" 查看技能命令组,使用 \"skill info <name>\" 查看具体 Skill\n"); | ||
| } | ||
| }; | ||
| function registerHelpCommand() { | ||
| createCommandGroup("system", "系统命令"); | ||
| registerGroupCommand("system", helpCommand); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/version.ts | ||
| const versionCommand = { | ||
| name: "version", | ||
| description: "显示版本信息", | ||
| usage: "version", | ||
| aliases: [ | ||
| "v", | ||
| "-v", | ||
| "--version" | ||
| ], | ||
| handler: async () => { | ||
| console.log(`Dimens CLI v${getVersion()}`); | ||
| } | ||
| }; | ||
| function registerVersionCommand() { | ||
| registerGroupCommand("system", versionCommand); | ||
| } | ||
| //#endregion | ||
| //#region src/core/context.ts | ||
| const DEFAULT_BASE_URL = "https://dimens.bintelai.com/api"; | ||
| function resolveContext(args = {}, profile = {}) { | ||
| const context = { output: args.output ?? profile.output ?? "table" }; | ||
| const baseUrl = args.baseUrl ?? process.env.DIMENS_BASE_URL ?? profile.baseUrl ?? "https://dimens.bintelai.com/api"; | ||
| const token = args.token ?? process.env.DIMENS_TOKEN ?? profile.token; | ||
| const refreshToken = args.refreshToken ?? profile.refreshToken; | ||
| const teamId = args.teamId ?? process.env.DIMENS_TEAM_ID ?? profile.teamId; | ||
| const projectId = args.projectId ?? process.env.DIMENS_PROJECT_ID ?? profile.projectId; | ||
| context.baseUrl = baseUrl; | ||
| if (token !== void 0) context.token = token; | ||
| if (refreshToken !== void 0) context.refreshToken = refreshToken; | ||
| if (teamId !== void 0) context.teamId = teamId; | ||
| if (projectId !== void 0) context.projectId = projectId; | ||
| return context; | ||
| } | ||
| //#endregion | ||
| //#region src/core/output.ts | ||
| function formatSuccess(message, data, mode) { | ||
| if (mode === "json") return JSON.stringify({ | ||
| success: true, | ||
| message, | ||
| data | ||
| }, null, 2); | ||
| if (mode === "raw") return [message, typeof data === "string" ? data : JSON.stringify(data)].join("\n"); | ||
| return [message, JSON.stringify(data, null, 2)].join("\n"); | ||
| } | ||
| function formatError(message, mode, options) { | ||
| const relatedSkills = options?.relatedSkills ?? []; | ||
| if (mode === "json") return JSON.stringify({ | ||
| success: false, | ||
| message, | ||
| relatedSkills | ||
| }, null, 2); | ||
| if (relatedSkills.length === 0) return message; | ||
| return [ | ||
| message, | ||
| "", | ||
| "相关 Skill:", | ||
| ...relatedSkills.map((skill) => `- ${skill}`) | ||
| ].join("\n"); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/execution-context.ts | ||
| let currentContext = {}; | ||
| function setExecutionContext(context) { | ||
| currentContext = context; | ||
| } | ||
| function clearExecutionContext() { | ||
| currentContext = {}; | ||
| } | ||
| function getRelatedSkillsForExecutionContext() { | ||
| const { groupName, commandName } = currentContext; | ||
| if (!groupName) return []; | ||
| const qualifiedCommand = commandName ? `${groupName} ${commandName}` : void 0; | ||
| return getAllSkills().filter((skill) => { | ||
| const matchesGroup = skill.commandGroups?.includes(groupName) ?? false; | ||
| const matchesCommand = qualifiedCommand ? skill.commands?.includes(qualifiedCommand) ?? false : false; | ||
| return matchesGroup || matchesCommand; | ||
| }).map((skill) => skill.name).sort((a, b) => a.localeCompare(b, "zh-CN")); | ||
| } | ||
| function getRelatedSkillObjectsForExecutionContext() { | ||
| const relatedSkillNames = new Set(getRelatedSkillsForExecutionContext()); | ||
| return getAllSkills().filter((skill) => relatedSkillNames.has(skill.name)); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/utils.ts | ||
| function parseFlags(args) { | ||
| const flags = {}; | ||
| for (let index = 0; index < args.length; index += 1) { | ||
| const current = args[index]; | ||
| if (!current?.startsWith("--")) continue; | ||
| const normalized = current.slice(2); | ||
| const equalIndex = normalized.indexOf("="); | ||
| if (equalIndex >= 0) { | ||
| const key = normalized.slice(0, equalIndex); | ||
| flags[key] = normalized.slice(equalIndex + 1) || "true"; | ||
| continue; | ||
| } | ||
| const next = args[index + 1]; | ||
| if (next && !next.startsWith("--")) { | ||
| flags[normalized] = next; | ||
| index += 1; | ||
| continue; | ||
| } | ||
| flags[normalized] = "true"; | ||
| } | ||
| return flags; | ||
| } | ||
| function getProfile() { | ||
| return config.get("profile"); | ||
| } | ||
| function saveProfile(profile) { | ||
| config.set("profile", profile); | ||
| return config.save(); | ||
| } | ||
| function mergeProfile(patch) { | ||
| return { | ||
| ...getProfile(), | ||
| ...patch | ||
| }; | ||
| } | ||
| function getContext(flags = {}) { | ||
| const contextArgs = {}; | ||
| if (flags["base-url"]) contextArgs.baseUrl = flags["base-url"]; | ||
| if (flags.token) contextArgs.token = flags.token; | ||
| if (flags["team-id"]) contextArgs.teamId = flags["team-id"]; | ||
| if (flags["project-id"]) contextArgs.projectId = flags["project-id"]; | ||
| if (flags.output === "json" || flags.output === "raw" || flags.output === "table") contextArgs.output = flags.output; | ||
| return resolveContext(contextArgs, getProfile()); | ||
| } | ||
| function createClient(context) { | ||
| if (!context.baseUrl) throw new Error("缺少 baseUrl,请先执行 auth login 或传入 --base-url"); | ||
| const options = { baseUrl: context.baseUrl }; | ||
| if (context.token) options.token = context.token; | ||
| if (context.refreshToken) options.refreshToken = context.refreshToken; | ||
| if (context.teamId) options.teamId = context.teamId; | ||
| if (context.projectId) options.projectId = context.projectId; | ||
| return new DimensClient(options); | ||
| } | ||
| function printSuccess(context, message, data) { | ||
| console.log(formatSuccess(message, data, context.output)); | ||
| } | ||
| function printError(context, error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| const relatedSkills = getRelatedSkillsForExecutionContext(); | ||
| console.log(formatError(message, context.output, { relatedSkills })); | ||
| process.exitCode = 1; | ||
| } | ||
| function requireTeamId(context, flags) { | ||
| const teamId = flags["team-id"] || context.teamId; | ||
| if (!teamId) throw new Error("缺少 teamId,请先执行 auth use-team 或传入 --team-id"); | ||
| return teamId; | ||
| } | ||
| function requireProjectId(context, flags) { | ||
| const projectId = flags["project-id"] || context.projectId; | ||
| if (!projectId) throw new Error("缺少 projectId,请先执行 auth use-project 或传入 --project-id"); | ||
| return projectId; | ||
| } | ||
| function requireSheetId(flags, args) { | ||
| const sheetId = flags["sheet-id"] || args[0]; | ||
| if (!sheetId) throw new Error("缺少 sheetId,请传入 --sheet-id 或 sheet <command> <sheetId>"); | ||
| return sheetId; | ||
| } | ||
| //#endregion | ||
| //#region src/commands/ai/index.ts | ||
| function registerAICommands() { | ||
| createCommandGroup("ai", "AI 对话"); | ||
| registerGroupCommand("ai", createCommand("chat-completions", "调用工作流 OpenAI 兼容聊天接口", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const message = flags.message; | ||
| if (!message) throw new Error("缺少 message,请传入 --message"); | ||
| const sdk = new FlowChatSDK(createClient(context)); | ||
| const payload = { | ||
| model: flags.model || "default", | ||
| messages: [{ | ||
| role: "user", | ||
| content: message | ||
| }], | ||
| stream: flags.stream === "true" | ||
| }; | ||
| if (flags.user) payload.user = flags.user; | ||
| printSuccess(context, "AI 对话调用成功", (await sdk.completions(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "ai chat-completions --message <text> [--model default] [--team-id <teamId>]", | ||
| examples: ["dimens-cli ai chat-completions --message \"你好\" --model default"] | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/auth/index.ts | ||
| function registerAuthCommands() { | ||
| createCommandGroup("auth", "认证与上下文"); | ||
| registerGroupCommand("auth", createCommand("login", "登录并保存本地凭证", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const username = flags.username; | ||
| const password = flags.password; | ||
| if (!username || !password) throw new Error("缺少登录参数,请传入 --username 和 --password"); | ||
| const result = await new AuthSDK(createClient(context)).login({ | ||
| username, | ||
| password | ||
| }); | ||
| const nextProfile = mergeProfile(context.baseUrl ? { | ||
| baseUrl: context.baseUrl, | ||
| token: result.data.token | ||
| } : { token: result.data.token }); | ||
| if (result.data.refreshToken) nextProfile.refreshToken = result.data.refreshToken; | ||
| await saveProfile(nextProfile); | ||
| printSuccess(context, "登录成功", result.data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "auth login --username <name> --password <password> [--base-url <url>]", | ||
| examples: ["dimens-cli auth login --username admin --password 123456", "dimens-cli auth login --base-url https://custom.example.com --username admin --password 123456"] | ||
| })); | ||
| registerGroupCommand("auth", createCommand("api-key-login", "使用 apiKey 和 apiSecret 登录并换取 token", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const apiKey = flags["api-key"]; | ||
| const apiSecret = flags["api-secret"]; | ||
| if (!apiKey || !apiSecret) throw new Error("缺少登录参数,请传入 --api-key 和 --api-secret"); | ||
| const result = await new AuthSDK(createClient(context)).loginByApiKey({ | ||
| apiKey, | ||
| apiSecret | ||
| }); | ||
| const nextProfile = mergeProfile(context.baseUrl ? { | ||
| baseUrl: context.baseUrl, | ||
| token: result.data.token | ||
| } : { token: result.data.token }); | ||
| if (result.data.refreshToken) nextProfile.refreshToken = result.data.refreshToken; | ||
| await saveProfile(nextProfile); | ||
| printSuccess(context, "API Key 登录成功", result.data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "auth api-key-login --api-key <apiKey> --api-secret <apiSecret> [--base-url <url>]", | ||
| examples: ["dimens-cli auth api-key-login --api-key ak_xxx --api-secret sk_xxx", "dimens-cli auth api-key-login --base-url https://custom.example.com --api-key ak_xxx --api-secret sk_xxx"] | ||
| })); | ||
| registerGroupCommand("auth", createCommand("refresh", "刷新 token", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const result = await new AuthSDK(createClient(context)).refreshToken(); | ||
| const nextProfile = mergeProfile({ token: result.data.token }); | ||
| const refreshToken = result.data.refreshToken ?? context.refreshToken; | ||
| if (refreshToken) nextProfile.refreshToken = refreshToken; | ||
| await saveProfile(nextProfile); | ||
| printSuccess(context, "刷新成功", result.data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "auth refresh [--base-url <url>]" })); | ||
| registerGroupCommand("auth", createCommand("status", "查看当前上下文", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| printSuccess(context, "当前上下文", context); | ||
| }, { usage: "auth status" })); | ||
| registerGroupCommand("auth", createCommand("use-team", "设置默认团队", async (args) => { | ||
| const context = getContext(); | ||
| try { | ||
| const teamId = args[0]; | ||
| if (!teamId) throw new Error("缺少 teamId,请传入 auth use-team <teamId>"); | ||
| await saveProfile(mergeProfile({ teamId })); | ||
| printSuccess(context, "默认团队已更新", { teamId }); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "auth use-team <teamId>" })); | ||
| registerGroupCommand("auth", createCommand("use-project", "设置默认项目", async (args) => { | ||
| const context = getContext(); | ||
| try { | ||
| const projectId = args[0]; | ||
| if (!projectId) throw new Error("缺少 projectId,请传入 auth use-project <projectId>"); | ||
| await saveProfile(mergeProfile({ projectId })); | ||
| printSuccess(context, "默认项目已更新", { projectId }); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "auth use-project <projectId>" })); | ||
| registerGroupCommand("auth", createCommand("profile", "查看本地 profile", async (args) => { | ||
| printSuccess(getContext(parseFlags(args)), "本地 Profile", getProfile()); | ||
| }, { usage: "auth profile" })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/column/index.ts | ||
| function registerColumnCommands() { | ||
| createCommandGroup("column", "字段管理"); | ||
| registerGroupCommand("column", createCommand("list", "获取字段列表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "字段列表获取成功", (await new ColumnSDK(createClient(context)).list(teamId, projectId, sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("column", createCommand("create", "创建字段", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const label = flags.label || flags.title; | ||
| if (!label) throw new Error("缺少字段标题,请传入 --label 或兼容参数 --title"); | ||
| const sdk = new ColumnSDK(createClient(context)); | ||
| const payload = { label }; | ||
| if (flags.type) payload.type = flags.type; | ||
| printSuccess(context, "字段创建成功", (await sdk.create(teamId, projectId, sheetId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("column", createCommand("update", "更新字段", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const fieldId = flags["field-id"] || args[0]; | ||
| if (!fieldId) throw new Error("缺少字段 ID,请传入 --field-id"); | ||
| const sdk = new ColumnSDK(createClient(context)); | ||
| const payload = {}; | ||
| if (flags.label || flags.title) payload.label = flags.label || flags.title; | ||
| if (flags.type) payload.type = flags.type; | ||
| printSuccess(context, "字段更新成功", (await sdk.update(sheetId, fieldId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("column", createCommand("delete", "删除字段", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const fieldId = flags["field-id"] || args[0]; | ||
| if (!fieldId) throw new Error("缺少字段 ID,请传入 --field-id"); | ||
| printSuccess(context, "字段删除成功", (await new ColumnSDK(createClient(context)).delete(sheetId, fieldId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/project/index.ts | ||
| function registerProjectCommands() { | ||
| createCommandGroup("project", "项目管理"); | ||
| registerGroupCommand("project", createCommand("list", "获取项目列表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const sdk = new ProjectSDK(createClient(context)); | ||
| const payload = { | ||
| page: Number(flags.page || "1"), | ||
| size: Number(flags.size || "20") | ||
| }; | ||
| if (flags.keyword) payload.keyword = flags.keyword; | ||
| printSuccess(context, "项目列表获取成功", (await sdk.page(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "project list [--team-id <teamId>] [--page 1] [--size 20]", | ||
| examples: ["dimens-cli project list --team-id TEAM1"] | ||
| })); | ||
| registerGroupCommand("project", createCommand("info", "获取项目详情", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const id = flags.id || args[0]; | ||
| if (!id) throw new Error("缺少项目 ID,请传入 --id 或 project info <id>"); | ||
| printSuccess(context, "项目详情获取成功", (await new ProjectSDK(createClient(context)).info(teamId, id)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project info --id <projectId>" })); | ||
| registerGroupCommand("project", createCommand("create", "创建项目", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const name = flags.name; | ||
| if (!name) throw new Error("缺少项目名称,请传入 --name"); | ||
| const sdk = new ProjectSDK(createClient(context)); | ||
| const payload = { name }; | ||
| if (flags.remark) payload.remark = flags.remark; | ||
| printSuccess(context, "项目创建成功", (await sdk.create(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project create --name <name>" })); | ||
| registerGroupCommand("project", createCommand("update", "更新项目", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const id = flags.id; | ||
| if (!id) throw new Error("缺少项目 ID,请传入 --id"); | ||
| const sdk = new ProjectSDK(createClient(context)); | ||
| const payload = { id }; | ||
| if (flags.name) payload.name = flags.name; | ||
| if (flags.remark) payload.remark = flags.remark; | ||
| printSuccess(context, "项目更新成功", (await sdk.update(teamId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project update --id <projectId> [--name <name>]" })); | ||
| registerGroupCommand("project", createCommand("trash", "将项目移入回收站", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const ids = (flags.ids || args.join(",")).split(",").map((item) => item.trim()).filter(Boolean); | ||
| if (ids.length === 0) throw new Error("缺少项目 ID,请传入 --ids P1,P2"); | ||
| printSuccess(context, "项目已移入回收站", (await new ProjectSDK(createClient(context)).trash(teamId, ids)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project trash --ids <id1,id2>" })); | ||
| registerGroupCommand("project", createCommand("restore", "恢复项目", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const ids = (flags.ids || args.join(",")).split(",").map((item) => item.trim()).filter(Boolean); | ||
| if (ids.length === 0) throw new Error("缺少项目 ID,请传入 --ids P1,P2"); | ||
| printSuccess(context, "项目恢复成功", (await new ProjectSDK(createClient(context)).restore(teamId, ids)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project restore --ids <id1,id2>" })); | ||
| registerGroupCommand("project", createCommand("use", "设置默认项目", async (args) => { | ||
| const context = getContext(); | ||
| try { | ||
| const projectId = args[0]; | ||
| if (!projectId) throw new Error("缺少项目 ID,请传入 project use <projectId>"); | ||
| await saveProfile(mergeProfile({ projectId })); | ||
| printSuccess(context, "默认项目已切换", { projectId }); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { usage: "project use <projectId>" })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/row/index.ts | ||
| function registerRowCommands() { | ||
| createCommandGroup("row", "行数据管理"); | ||
| registerGroupCommand("row", createCommand("page", "分页获取行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const sdk = new RowSDK(createClient(context)); | ||
| const payload = { | ||
| page: Number(flags.page || "1"), | ||
| size: Number(flags.size || "20") | ||
| }; | ||
| printSuccess(context, "行分页获取成功", (await sdk.page(teamId, projectId, sheetId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("info", "获取行详情", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"] || args[0]; | ||
| if (!rowId) throw new Error("缺少行 ID,请传入 --row-id"); | ||
| printSuccess(context, "行详情获取成功", (await new RowSDK(createClient(context)).info(teamId, projectId, sheetId, rowId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("create", "创建行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const sdk = new RowSDK(createClient(context)); | ||
| const values = flags.values ? JSON.parse(flags.values) : {}; | ||
| printSuccess(context, "行创建成功", (await sdk.create(sheetId, { data: values })).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("update", "更新行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"] || args[0]; | ||
| if (!rowId) throw new Error("缺少行 ID,请传入 --row-id"); | ||
| const version = Number(flags.version || ""); | ||
| if (Number.isNaN(version)) throw new Error("缺少 version,请传入 --version"); | ||
| const values = flags.values ? JSON.parse(flags.values) : {}; | ||
| printSuccess(context, "行更新成功", (await new RowSDK(createClient(context)).update(sheetId, rowId, values, version)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("delete", "删除行", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"] || args[0]; | ||
| if (!rowId) throw new Error("缺少行 ID,请传入 --row-id"); | ||
| printSuccess(context, "行删除成功", (await new RowSDK(createClient(context)).delete(sheetId, rowId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("row", createCommand("set-cell", "更新单元格", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| const rowId = flags["row-id"]; | ||
| const fieldId = flags["field-id"] || flags["column-id"]; | ||
| if (!rowId || !fieldId) throw new Error("缺少 rowId 或 fieldId,请传入 --row-id 和 --field-id;--column-id 仅作兼容参数"); | ||
| const version = flags.version ? Number(flags.version) : void 0; | ||
| if (flags.version && Number.isNaN(version)) throw new Error("version 必须是数字,请传入 --version"); | ||
| printSuccess(context, "单元格更新成功", (await new RowSDK(createClient(context)).updateCell(sheetId, { | ||
| rowId, | ||
| fieldId, | ||
| value: flags.value, | ||
| ...version === void 0 ? {} : { version } | ||
| })).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/sheet/index.ts | ||
| function registerSheetCommands() { | ||
| createCommandGroup("sheet", "多维表管理"); | ||
| registerGroupCommand("sheet", createCommand("list", "获取表列表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const projectId = requireProjectId(context, flags); | ||
| printSuccess(context, "表列表获取成功", (await new SheetSDK(createClient(context)).list(projectId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("tree", "获取表树结构", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const projectId = requireProjectId(context, flags); | ||
| printSuccess(context, "表树获取成功", (await new SheetSDK(createClient(context)).tree(projectId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("create", "创建表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const projectId = requireProjectId(context, flags); | ||
| const name = flags.name; | ||
| if (!name) throw new Error("缺少表名称,请传入 --name"); | ||
| printSuccess(context, "表创建成功", (await new SheetSDK(createClient(context)).create(projectId, { name })).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("info", "获取表详情", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "表详情获取成功", (await new SheetSDK(createClient(context)).info(teamId, projectId, sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("update", "更新表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| const sdk = new SheetSDK(createClient(context)); | ||
| const payload = {}; | ||
| if (flags.name) payload.name = flags.name; | ||
| printSuccess(context, "表更新成功", (await sdk.update(teamId, projectId, sheetId, payload)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("delete", "删除表", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const teamId = requireTeamId(context, flags); | ||
| const projectId = requireProjectId(context, flags); | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "表删除成功", (await new SheetSDK(createClient(context)).delete(teamId, projectId, sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| registerGroupCommand("sheet", createCommand("structure", "获取表结构", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const sheetId = requireSheetId(flags, args); | ||
| printSuccess(context, "表结构获取成功", (await new SheetSDK(createClient(context)).structure(sheetId)).data); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/skill/index.ts | ||
| function requireSkillName(args) { | ||
| const skillName = args[0]; | ||
| if (!skillName) throw new Error("缺少技能名称,请传入 skill info <name> 或 skill show <name>"); | ||
| return skillName; | ||
| } | ||
| function getSkillOrThrow(name) { | ||
| const skill = getSkill(name); | ||
| if (!skill) throw new Error(`未找到技能: ${name}`); | ||
| return skill; | ||
| } | ||
| function toRelativeSkillPath(filePath) { | ||
| return relative(getSkillsRootPath(), filePath) || filePath; | ||
| } | ||
| function printList(title, items) { | ||
| console.log(`${title}:`); | ||
| if (!items || items.length === 0) { | ||
| console.log(" (无)"); | ||
| return; | ||
| } | ||
| items.forEach((item) => { | ||
| console.log(` - ${item}`); | ||
| }); | ||
| } | ||
| function normalizeSkillForOutput(skill) { | ||
| return { | ||
| ...skill, | ||
| recommendExamples: getRecommendExamples(skill.name), | ||
| skillPath: skill.skillPath ? toRelativeSkillPath(skill.skillPath) : void 0, | ||
| referencesDir: skill.referencesDir ? toRelativeSkillPath(skill.referencesDir) : void 0, | ||
| references: skill.references?.map((reference) => toRelativeSkillPath(reference)) ?? [] | ||
| }; | ||
| } | ||
| function printMapping(skill) { | ||
| printList("命令组", skill.commandGroups); | ||
| printList("命令", skill.commands); | ||
| printList("SDK", skill.sdkModules); | ||
| printList("工具", skill.toolNames); | ||
| } | ||
| const SKILL_RECOMMEND_EXAMPLES = { | ||
| "dimens-system-orchestrator": [ | ||
| "帮我生成一个客户管理系统", | ||
| "帮我做一个项目管理平台", | ||
| "生成一个审批系统" | ||
| ], | ||
| "dimens-workflow": [ | ||
| "工作流 默认模型 AI 分析", | ||
| "审批流程 自动化", | ||
| "flow chat completions" | ||
| ], | ||
| "dimens-key-auth": [ | ||
| "api-key token", | ||
| "api secret 登录", | ||
| "第三方鉴权接入" | ||
| ], | ||
| "dimens-team": [ | ||
| "团队 项目 成员", | ||
| "teamId projectId", | ||
| "租户隔离 项目上下文" | ||
| ], | ||
| "dimens-table": [ | ||
| "多维表格 字段 row", | ||
| "sheet column view", | ||
| "字段类型 系统视图" | ||
| ], | ||
| "dimens-permission": [ | ||
| "行级权限 公开访问 只读", | ||
| "列权限 协同越权", | ||
| "acl 权限" | ||
| ], | ||
| "dimens-report": [ | ||
| "报表 图表 参数筛选", | ||
| "dashboard 数据源", | ||
| "统计看板 导出" | ||
| ] | ||
| }; | ||
| function getRecommendExamples(skillName) { | ||
| return SKILL_RECOMMEND_EXAMPLES[skillName] ?? []; | ||
| } | ||
| function getRecommendQuery(args) { | ||
| const queryParts = []; | ||
| for (let index = 0; index < args.length; index += 1) { | ||
| const current = args[index]; | ||
| if (!current) continue; | ||
| if (current.startsWith("--")) { | ||
| const next = args[index + 1]; | ||
| if (next && !next.startsWith("--")) index += 1; | ||
| continue; | ||
| } | ||
| queryParts.push(current); | ||
| } | ||
| return queryParts.join(" ").trim(); | ||
| } | ||
| const SYSTEM_BUILD_VERBS = [ | ||
| "生成", | ||
| "新建", | ||
| "创建", | ||
| "做", | ||
| "搭建", | ||
| "搭", | ||
| "构建", | ||
| "开发" | ||
| ]; | ||
| const SYSTEM_BUILD_TARGETS = [ | ||
| "系统", | ||
| "平台", | ||
| "管理系统", | ||
| "业务系统", | ||
| "crm", | ||
| "客户管理", | ||
| "项目管理", | ||
| "售后管理", | ||
| "审批系统" | ||
| ]; | ||
| const WORKFLOW_INTENT_KEYWORDS = [ | ||
| "工作流", | ||
| "workflow", | ||
| "flow", | ||
| "默认模型", | ||
| "ai 分析", | ||
| "审批流程", | ||
| "自动化" | ||
| ]; | ||
| const AUTH_INTENT_KEYWORDS = [ | ||
| "api-key", | ||
| "apikey", | ||
| "api key", | ||
| "api-secret", | ||
| "apisecret", | ||
| "api secret", | ||
| "token", | ||
| "登录", | ||
| "鉴权" | ||
| ]; | ||
| const TABLE_INTENT_KEYWORDS = [ | ||
| "多维表格", | ||
| "sheet", | ||
| "row", | ||
| "column", | ||
| "字段", | ||
| "视图", | ||
| "table" | ||
| ]; | ||
| const PERMISSION_INTENT_KEYWORDS = [ | ||
| "权限", | ||
| "行级权限", | ||
| "列权限", | ||
| "公开访问", | ||
| "只读", | ||
| "acl", | ||
| "协同越权" | ||
| ]; | ||
| const REPORT_INTENT_KEYWORDS = [ | ||
| "报表", | ||
| "图表", | ||
| "dashboard", | ||
| "参数筛选", | ||
| "数据源", | ||
| "统计", | ||
| "看板" | ||
| ]; | ||
| function getSystemOrchestratorBonus(skill, normalizedQuery) { | ||
| if (skill.name !== "dimens-system-orchestrator") return 0; | ||
| const hasBuildVerb = SYSTEM_BUILD_VERBS.some((keyword) => normalizedQuery.includes(keyword)); | ||
| const matchedTargets = SYSTEM_BUILD_TARGETS.filter((keyword) => normalizedQuery.includes(keyword)); | ||
| let score = 0; | ||
| if (hasBuildVerb && matchedTargets.length > 0) score += 10; | ||
| score += matchedTargets.length * 4; | ||
| return score; | ||
| } | ||
| function hasIntentKeyword(normalizedQuery, keywords) { | ||
| return keywords.some((keyword) => normalizedQuery.includes(keyword)); | ||
| } | ||
| function getSkillMatchSignals(skill, query) { | ||
| const normalizedQuery = query.toLowerCase(); | ||
| const haystacks = [ | ||
| skill.name, | ||
| skill.description, | ||
| ...skill.tags ?? [], | ||
| ...skill.commandGroups ?? [], | ||
| ...skill.commands ?? [], | ||
| ...skill.sdkModules ?? [], | ||
| ...skill.toolNames ?? [] | ||
| ].join("\n").toLowerCase(); | ||
| const compactQuery = normalizedQuery.replace(/\s+/g, ""); | ||
| const keywords = normalizedQuery.split(/\s+/).map((item) => item.trim()).filter(Boolean); | ||
| let keywordScore = 0; | ||
| const matchedBy = []; | ||
| keywords.forEach((keyword) => { | ||
| if (!keyword) return; | ||
| if (skill.name.toLowerCase().includes(keyword)) { | ||
| keywordScore += 4; | ||
| if (!matchedBy.includes("name-keyword")) matchedBy.push("name-keyword"); | ||
| return; | ||
| } | ||
| if (haystacks.includes(keyword)) { | ||
| keywordScore += 1; | ||
| if (!matchedBy.includes("context-keyword")) matchedBy.push("context-keyword"); | ||
| } | ||
| }); | ||
| let phraseScore = 0; | ||
| if (compactQuery && compactQuery !== normalizedQuery && haystacks.includes(compactQuery)) phraseScore += 2; | ||
| if (compactQuery && haystacks.includes(compactQuery)) phraseScore += 2; | ||
| if (phraseScore > 0 && !matchedBy.includes("compact-phrase")) matchedBy.push("compact-phrase"); | ||
| const systemBonus = getSystemOrchestratorBonus(skill, normalizedQuery); | ||
| if (systemBonus > 0) matchedBy.push("system-build-intent"); | ||
| if (skill.name === "dimens-workflow" && hasIntentKeyword(normalizedQuery, WORKFLOW_INTENT_KEYWORDS)) matchedBy.push("workflow-intent"); | ||
| if (skill.name === "dimens-key-auth" && hasIntentKeyword(normalizedQuery, AUTH_INTENT_KEYWORDS)) matchedBy.push("auth-intent"); | ||
| if (skill.name === "dimens-table" && hasIntentKeyword(normalizedQuery, TABLE_INTENT_KEYWORDS)) matchedBy.push("table-intent"); | ||
| if (skill.name === "dimens-permission" && hasIntentKeyword(normalizedQuery, PERMISSION_INTENT_KEYWORDS)) matchedBy.push("permission-intent"); | ||
| if (skill.name === "dimens-report" && hasIntentKeyword(normalizedQuery, REPORT_INTENT_KEYWORDS)) matchedBy.push("report-intent"); | ||
| const score = keywordScore + phraseScore + systemBonus; | ||
| const reasonParts = []; | ||
| if (systemBonus > 0) reasonParts.push("命中系统建设意图"); | ||
| if (matchedBy.includes("workflow-intent")) reasonParts.push("命中工作流意图"); | ||
| if (matchedBy.includes("auth-intent")) reasonParts.push("命中鉴权接入意图"); | ||
| if (matchedBy.includes("table-intent")) reasonParts.push("命中多维表格意图"); | ||
| if (matchedBy.includes("permission-intent")) reasonParts.push("命中权限意图"); | ||
| if (matchedBy.includes("report-intent")) reasonParts.push("命中报表意图"); | ||
| if (matchedBy.includes("name-keyword")) reasonParts.push("匹配到技能名关键词"); | ||
| if (matchedBy.includes("context-keyword")) reasonParts.push("匹配到描述或映射关键词"); | ||
| if (matchedBy.includes("compact-phrase")) reasonParts.push("匹配到紧凑短语"); | ||
| return { | ||
| score, | ||
| matchedBy, | ||
| reason: reasonParts.join(";") || "基于关键词相关性匹配" | ||
| }; | ||
| } | ||
| function registerSkillCommands() { | ||
| createCommandGroup("skill", "技能查看与提示语文档"); | ||
| registerGroupCommand("skill", createCommand("list", "列出所有已发现的技能", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const skills = getAllSkills(); | ||
| if (context.output === "json") { | ||
| console.log(formatSuccess("技能列表获取成功", skills.map((skill) => normalizeSkillForOutput(skill)), context.output)); | ||
| return; | ||
| } | ||
| console.log("\n已发现技能:\n"); | ||
| skills.forEach((skill) => { | ||
| console.log(`- ${skill.name}`); | ||
| console.log(` ${skill.description.split("\n")[0] ?? skill.description}`); | ||
| }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill list", | ||
| examples: ["dimens-cli skill list"] | ||
| })); | ||
| registerGroupCommand("skill", createCommand("info", "查看技能元信息", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const skill = getSkillOrThrow(requireSkillName(args)); | ||
| const normalizedSkill = normalizeSkillForOutput(skill); | ||
| if (context.output === "json") { | ||
| console.log(formatSuccess("技能信息获取成功", normalizedSkill, context.output)); | ||
| return; | ||
| } | ||
| console.log(`\n技能: ${skill.name}`); | ||
| console.log(`描述: ${skill.description.split("\n")[0] ?? skill.description}`); | ||
| if (skill.skillPath) console.log(`主文件: ${toRelativeSkillPath(skill.skillPath)}`); | ||
| if (skill.referencesDir) console.log(`参考目录: ${toRelativeSkillPath(skill.referencesDir)}`); | ||
| printMapping(skill); | ||
| printList("推荐关键词示例", getRecommendExamples(skill.name)); | ||
| printList("references", skill.references?.map((reference) => toRelativeSkillPath(reference))); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill info <name>", | ||
| examples: ["dimens-cli skill info dimens-table"] | ||
| })); | ||
| registerGroupCommand("skill", createCommand("recommend", "根据文本或关键词推荐相关技能", async (args) => { | ||
| const context = getContext(parseFlags(args)); | ||
| try { | ||
| const query = getRecommendQuery(args); | ||
| if (!query) throw new Error("缺少推荐文本,请传入 skill recommend <text>"); | ||
| const rankedSkills = getAllSkills().map((skill) => ({ | ||
| skill, | ||
| ...getSkillMatchSignals(skill, query) | ||
| })).filter((item) => item.score > 0).sort((a, b) => b.score - a.score || a.skill.name.localeCompare(b.skill.name, "zh-CN")); | ||
| if (context.output === "json") { | ||
| console.log(formatSuccess("技能推荐完成", rankedSkills.map((item) => ({ | ||
| score: item.score, | ||
| matchedBy: item.matchedBy, | ||
| reason: item.reason, | ||
| skill: normalizeSkillForOutput(item.skill) | ||
| })), context.output)); | ||
| return; | ||
| } | ||
| console.log(`\n推荐 Skill(query: ${query}):\n`); | ||
| if (rankedSkills.length === 0) { | ||
| console.log("(无匹配结果)\n"); | ||
| return; | ||
| } | ||
| rankedSkills.forEach((item) => { | ||
| console.log(`- ${item.skill.name} (score: ${item.score})`); | ||
| console.log(` ${item.skill.description.split("\n")[0] ?? item.skill.description}`); | ||
| }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill recommend <text>", | ||
| examples: ["dimens-cli skill recommend 工作流 默认模型 AI 分析", "dimens-cli skill recommend api-key token --output json"] | ||
| })); | ||
| registerGroupCommand("skill", createCommand("show", "显示技能文档内容", async (args) => { | ||
| const flags = parseFlags(args); | ||
| const context = getContext(flags); | ||
| try { | ||
| const skillName = requireSkillName(args.filter((arg) => !arg.startsWith("--"))); | ||
| const skill = getSkillOrThrow(skillName); | ||
| const normalizedSkill = normalizeSkillForOutput(skill); | ||
| if (!skill.skillPath) throw new Error(`技能 ${skillName} 缺少主文件路径`); | ||
| const mainOnly = flags["main-only"] === "true"; | ||
| const referencesOnly = flags["references-only"] === "true"; | ||
| const mappingOnly = flags["mapping-only"] === "true"; | ||
| const includeReferences = flags.references === "true" || referencesOnly; | ||
| if (context.output === "json") { | ||
| const payload = { skill: normalizedSkill }; | ||
| if (!referencesOnly && !mappingOnly) payload.main = readFileSync(skill.skillPath, "utf8"); | ||
| if (!mainOnly && !mappingOnly && skill.references && skill.references.length > 0) payload.references = skill.references.map((reference) => ({ | ||
| path: toRelativeSkillPath(reference), | ||
| content: readFileSync(reference, "utf8") | ||
| })); | ||
| if (!mainOnly && !referencesOnly) payload.mapping = { | ||
| commandGroups: skill.commandGroups ?? [], | ||
| commands: skill.commands ?? [], | ||
| sdkModules: skill.sdkModules ?? [], | ||
| toolNames: skill.toolNames ?? [] | ||
| }; | ||
| console.log(formatSuccess("技能文档获取成功", payload, context.output)); | ||
| return; | ||
| } | ||
| if (!referencesOnly && !mappingOnly) { | ||
| console.log(`\n===== ${skill.name} / ${toRelativeSkillPath(skill.skillPath)} =====\n`); | ||
| console.log(readFileSync(skill.skillPath, "utf8")); | ||
| } | ||
| if (!mainOnly && !referencesOnly) { | ||
| console.log(`\n===== ${skill.name} / mapping =====\n`); | ||
| printMapping(skill); | ||
| } | ||
| if (!mainOnly && !mappingOnly && includeReferences && skill.references && skill.references.length > 0) skill.references.forEach((reference) => { | ||
| console.log(`\n===== ${toRelativeSkillPath(reference)} =====\n`); | ||
| console.log(readFileSync(reference, "utf8")); | ||
| }); | ||
| console.log(""); | ||
| } catch (error) { | ||
| printError(context, error); | ||
| } | ||
| }, { | ||
| usage: "skill show <name> [--references] [--main-only] [--references-only] [--mapping-only]", | ||
| examples: [ | ||
| "dimens-cli skill show dimens-workflow", | ||
| "dimens-cli skill show dimens-workflow --references", | ||
| "dimens-cli skill show dimens-table --mapping-only", | ||
| "dimens-cli skill show dimens-key-auth --output json" | ||
| ] | ||
| })); | ||
| } | ||
| //#endregion | ||
| //#region src/commands/index.ts | ||
| var commands_exports = /* @__PURE__ */ __exportAll({ registerCommands: () => registerCommands }); | ||
| function registerCommands() { | ||
| logger.info("开始注册所有命令..."); | ||
| createCommandGroup("system", "系统命令"); | ||
| registerHelpCommand(); | ||
| registerVersionCommand(); | ||
| registerAuthCommands(); | ||
| registerSkillCommands(); | ||
| registerProjectCommands(); | ||
| registerSheetCommands(); | ||
| registerColumnCommands(); | ||
| registerRowCommands(); | ||
| registerAICommands(); | ||
| logger.info("所有命令注册完成"); | ||
| } | ||
| //#endregion | ||
| export { config as _, getRelatedSkillObjectsForExecutionContext as a, getAllSkills as c, clearCommands as d, getAllCommands as f, registerCommand as g, getGroupCommand as h, clearExecutionContext as i, getSkill as l, getCommandGroup as m, registerCommands as n, setExecutionContext as o, getCommand as p, parseFlags as r, SKILLS as s, commands_exports as t, getSkillsRootPath as u }; | ||
| //# sourceMappingURL=commands-DhXU3rGj.mjs.map |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
470152
3.79%75
27.12%2126
0.71%