Documentation
¶
Overview ¶
Package wiki declares reviewed, truth-preserving shortcuts for Wiki spaces, members, nodes, and activity feeds.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DeleteSpace = writeShortcut("+delete-space", "删除知识库", "用户明确确认后将整个知识库移入回收站;删除前读取目标,删除响应必须有 success=true。", "dws wiki +delete-space --workspace <workspaceId> --format json", shortcut.RiskHighWrite, wikiDeleteSafety(), []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID 或 URL"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}}, func(rt *shortcut.RuntimeContext) error { preflight, err := rt.CallMCPData("wiki", "get_wikiSpace", map[string]any{"workspaceId": rt.Str("workspace")}) if err != nil { return err } preflight, err = requireWikiObject(preflight, "wiki/get_wikiSpace") if err != nil { return err } if rt.DryRun() { return rt.Output(map[string]any{"dryRun": true, "executed": false, "operation": "wiki/delete_wikiSpace", "target": preflight}) } written, err := rt.CallMCPWriteDataStrict("wiki", "delete_wikiSpace", map[string]any{"workspaceId": rt.Str("workspace")}) if err != nil { return err } written, err = requireWikiWrite(written, "wiki/delete_wikiSpace") if err != nil { return err } return rt.Output(map[string]any{"success": true, "workspaceId": rt.Str("workspace"), "deleted": true}) })
View Source
var FeedList = readShortcut("+feed-list", "严格分页列出知识库动态", "查看谁在何时创建、更新或评论了知识库内容;严格验证 feeds 数组并保留游标。", "feeds", "dws wiki +feed-list --workspace <workspaceId> --format json", []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID 或 URL"}, {Name: "limit", Type: shortcut.FlagInt, Default: "10", Desc: "每页数量 1-20"}, {Name: "cursor", Type: shortcut.FlagString, Desc: "分页游标"}, {Name: "exclude-file", Type: shortcut.FlagBool, Desc: "排除普通文件动态"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}, {Name: "limit", Property: "maxResults"}, {Name: "cursor", Property: "nextToken"}, {Name: "exclude-file", Property: "excludeFile"}}, func(rt *shortcut.RuntimeContext) error { items, page, err := collectWikiPages(rt, "wiki/list_workspace_feeds", rt.Int("limit"), []string{"feeds", "items", "list"}, func(cursor string, size int) (map[string]any, error) { params := map[string]any{"workspaceId": rt.Str("workspace"), "maxResults": size} if cursor != "" { params["nextToken"] = cursor } if rt.Changed("exclude-file") { params["excludeFile"] = rt.Bool("exclude-file") } return rt.CallMCPData("wiki", "list_workspace_feeds", params) }) if err != nil { return err } feeds := projectWikiRowsPreservingSource(items, map[string][]string{"id": {"id", "feedId"}, "type": {"type", "feedType", "action"}, "time": {"time", "createTime"}, "name": {"name", "title", "fileName"}, "nodeId": {"nodeId", "fileId"}}) out := map[string]any{"count": len(feeds), "feeds": feeds} addWikiPagination(out, page) return rt.Output(out) })
View Source
var MemberAdd = memberWrite("+member-add", "add_member", "添加知识库成员", "向知识库授予一个或多个用户容器级角色;仅以写接口 success=true 作为终态证据,不内置读回;另用 wiki member list 分页核对。", "dws wiki +member-add --workspace <workspaceId> --users <userId> --role READER --format json", true, wikiWriteSafety(false))
View Source
var MemberList = readShortcut("+member-list", "严格列出知识库成员", "列出知识库成员及角色;本命令单页上限 50;续页用 wiki member list --next-token。", "members", "dws wiki +member-list --workspace <workspaceId> --format json", []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID 或 URL"}, {Name: "limit", Type: shortcut.FlagInt, Default: "30", Desc: "返回上限 1-50"}, {Name: "filter-role", Type: shortcut.FlagStringSlice, Desc: "角色过滤"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}, {Name: "limit", Property: "maxResults"}, {Name: "filter-role", Property: "filterRoleIds"}}, func(rt *shortcut.RuntimeContext) error { if rt.Int("limit") < 1 || rt.Int("limit") > 50 { return fmt.Errorf("--limit 必须在 1-50 之间;服务端不支持超过 50 或游标续页") } params := map[string]any{"workspaceId": rt.Str("workspace"), "maxResults": rt.Int("limit")} if rt.Changed("filter-role") { params["filterRoleIds"] = rt.StrSlice("filter-role") } data, err := rt.CallMCPData("wiki", "list_member", params) if err != nil { return err } items, page, err := requireWikiCollection(data, "wiki/list_member", "members") if err != nil { return err } members := projectWikiRows(items, map[string][]string{"id": {"id", "userId"}, "name": {"name", "nick"}, "role": {"role", "roleId"}, "type": {"type"}, "outer": {"outer"}}) out := map[string]any{"count": len(members), "members": members} addWikiPagination(out, page) return rt.Output(out) })
View Source
var MemberRemove = memberWrite("+member-remove", "remove_member", "移除知识库成员", "移除一个或多个用户的知识库容器级访问;仅以写接口 success=true 作为终态证据,不内置读回;另用 wiki member list 分页核对。", "dws wiki +member-remove --workspace <workspaceId> --users <userId> --format json", false, wikiWriteSafety(true))
View Source
var MemberUpdate = memberWrite("+member-update", "update_member", "更新知识库成员角色", "调整已有成员的知识库容器级角色;仅以写接口 success=true 作为终态证据,不内置读回;另用 wiki member list 分页核对。", "dws wiki +member-update --workspace <workspaceId> --users <userId> --role EDITOR --format json", true, wikiWriteSafety(false))
View Source
var Move = writeShortcut("+move", "移动节点到知识库并读回验证", "将 Wiki 节点或我的文档在线节点移动到目标知识库/文件夹;同一入口覆盖库内移动与在线文档入库场景。", "dws wiki +move --workspace <workspaceId> --node <nodeId> --format json", shortcut.RiskWrite, wikiWriteSafety(true), []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "目标知识库 ID"}, {Name: "node", Type: shortcut.FlagString, Required: true, Desc: "节点 ID"}, {Name: "folder", Type: shortcut.FlagString, Desc: "目标文件夹 ID"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}, {Name: "node", Property: "nodeId"}, {Name: "folder", Property: "targetFolderId"}}, func(rt *shortcut.RuntimeContext) error { return executeMove(rt, false) })
View Source
var MoveToDrive = writeShortcut("+move-to-drive", "移动 Wiki 节点到我的文档并验证目标域", "将 Wiki 在线节点移动到我的文档根目录或指定文件夹;可用 --workspace 断言来源知识库,返回移动前后元数据,并确认目标 workspace 属于 myWikiSpace 范围。", "dws wiki +move-to-drive --node <nodeId> --workspace <sourceWorkspaceId> --format json", shortcut.RiskWrite, wikiWriteSafety(true), []shortcut.Flag{{Name: "node", Type: shortcut.FlagString, Required: true, Desc: "Wiki 节点 ID"}, {Name: "workspace", Type: shortcut.FlagString, Desc: "可选的来源知识库 ID;移动前必须与节点归属一致"}, {Name: "folder", Type: shortcut.FlagString, Desc: "我的文档目标文件夹 ID"}}, []contract.ParamDecl{{Name: "node", Property: "nodeId"}, {Name: "workspace", Property: "sourceWorkspaceId"}, {Name: "folder", Property: "targetFolderId"}}, func(rt *shortcut.RuntimeContext) error { return executeMove(rt, true) })
View Source
var NodeCopy = writeShortcut("+node-copy", "复制知识库节点并验证独立副本", "复制现有在线节点到目标知识库/文件夹;先读源节点,再要求新 nodeId 与源 ID 不同,并验证副本 workspace、folder 和类型。", "dws wiki +node-copy --workspace <workspaceId> --node <nodeId> --format json", shortcut.RiskHighWrite, contract.SafetySpec{Effect: "write", Risk: "high", Confirmation: "user_required", Idempotency: "non_idempotent"}, []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "目标知识库 ID"}, {Name: "node", Type: shortcut.FlagString, Required: true, Desc: wikiCopySourceIDRequirement}, {Name: "folder", Type: shortcut.FlagString, Desc: "目标文件夹 ID"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}, {Name: "node", Property: "nodeId"}, {Name: "folder", Property: "targetFolderId"}}, func(rt *shortcut.RuntimeContext) error { params := map[string]any{"workspaceId": rt.Str("workspace"), "nodeId": rt.Str("node")} if rt.Changed("folder") { params["targetFolderId"] = rt.Str("folder") } if rt.DryRun() { return rt.Output(map[string]any{"dryRun": true, "executed": false, "operation": "doc/copy_document", "arguments": params}) } source, err := rt.CallMCPData("doc", "get_document_info", map[string]any{"nodeId": rt.Str("node")}) if err != nil { return err } source, err = requireWikiObject(source, "doc/get_document_info") if err != nil { return err } if err := requireWikiNodeIdentity(source, "doc/copy_document", rt.Str("node")); err != nil { return err } if firstWikiString(source, "workspaceId", "spaceId") == "" { return wikiResponseError("doc/copy_document", "source_missing_workspace", "源节点读回缺少 workspaceId,无法报告复制前位置") } written, err := rt.CallMCPWriteDataStrict("doc", "copy_document", params) if err != nil { return err } id, verified, err := verifyWikiNodeWrite(rt, written, "doc/copy_document", rt.Str("node")) if err != nil { return err } sourceType, copyType := wikiNodeType(source), wikiNodeType(verified) if sourceType != "" && copyType != "" && sourceType != copyType { return wikiNodeWriteError(rt, id, rt.Str("node"), wikiResponseError("doc/copy_document", "copy_type_mismatch", "副本类型与源节点不一致")) } source = projectWikiNode(source) verified = projectWikiNode(verified) out := map[string]any{ "success": true, "sourceNodeId": rt.Str("node"), "nodeId": id, "sourceWorkspaceId": firstWikiString(source, "workspaceId", "spaceId"), "targetWorkspaceId": firstWikiString(verified, "workspaceId", "spaceId"), "source": source, "copy": verified, } if folderID := firstWikiString(verified, "folderId", "parentFolderId", "parentId"); folderID != "" { out["targetFolderId"] = folderID } return rt.Output(out) })
View Source
var NodeCreate = writeShortcut("+node-create", "创建知识库节点并严格读回验证", "在知识库根目录或文件夹中创建文档、表格、白板、脑图或文件夹;只有新 nodeId、workspace、名称、类型和显式父文件夹读回一致才成功。", "dws wiki +node-create --workspace <workspaceId> --name \"新文档\" --format json", shortcut.RiskWrite, wikiWriteSafety(false), []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID"}, {Name: "name", Type: shortcut.FlagString, Required: true, Desc: "节点名称"}, {Name: "type", Type: shortcut.FlagString, Default: "adoc", Desc: "节点类型", Enum: []string{"adoc", "axls", "able", "appt", "adraw", "amind", "folder"}}, {Name: "folder", Type: shortcut.FlagString, Desc: "父文件夹 ID"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}, {Name: "name", Property: "name"}, {Name: "type", Property: "type"}, {Name: "folder", Property: "folderId"}}, func(rt *shortcut.RuntimeContext) error { params := map[string]any{"workspaceId": rt.Str("workspace"), "name": rt.Str("name"), "type": rt.Str("type")} if rt.Changed("folder") { params["folderId"] = rt.Str("folder") } if rt.DryRun() { return rt.Output(map[string]any{"dryRun": true, "executed": false, "operation": "doc/create_file", "arguments": params}) } written, err := rt.CallMCPWriteDataStrict("doc", "create_file", params) if err != nil { return err } id, verified, err := verifyWikiNodeWrite(rt, written, "doc/create_file", "") if err != nil { return err } if err := requireWikiCreatedNode(verified, "doc/create_file", id, rt.Str("workspace"), rt.Str("folder"), rt.Str("name"), rt.Str("type")); err != nil { return wikiNodeWriteError(rt, id, "", err) } verified = projectWikiNode(verified) return rt.Output(map[string]any{"success": true, "nodeId": id, "workspaceId": rt.Str("workspace"), "requestedType": rt.Str("type"), "node": verified}) })
View Source
var NodeDelete = writeShortcut("+node-delete", "删除知识库节点", "明确确认后将节点移入回收站;先读取目标,且删除响应必须提供 success=true 终态证据。", "dws wiki +node-delete --workspace <workspaceId> --node <nodeId> --format json", shortcut.RiskHighWrite, wikiDeleteSafety(), []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID,用于确认影响范围"}, {Name: "node", Type: shortcut.FlagString, Required: true, Desc: "节点 ID"}}, []contract.ParamDecl{{Name: "node", Property: "nodeId"}}, func(rt *shortcut.RuntimeContext) error { preflight, err := rt.CallMCPData("doc", "get_document_info", map[string]any{"nodeId": rt.Str("node")}) if err != nil { return err } preflight, err = requireWikiObject(preflight, "doc/get_document_info") if err != nil { return err } if _, err = requireWikiResponse(preflight, "doc/get_document_info"); err != nil { return err } nodeID := firstWikiString(preflight, "nodeId", "id", "fileId") if nodeID == "" { return wikiResponseError("doc/delete_document", "missing_preflight_node_id", "删除预检缺少节点 ID,未发送删除请求") } if nodeID != rt.Str("node") { return wikiResponseError("doc/delete_document", "node_preflight_mismatch", "删除预检返回的节点与请求不一致,未发送删除请求") } workspaceID := firstWikiString(preflight, "workspaceId", "spaceId") if workspaceID == "" { return wikiResponseError("doc/delete_document", "missing_preflight_workspace", "删除预检缺少知识库归属,未发送删除请求") } if workspaceID != rt.Str("workspace") { return wikiResponseError("doc/delete_document", "workspace_preflight_mismatch", "节点不属于请求确认的知识库") } if rt.DryRun() { return rt.Output(map[string]any{"dryRun": true, "executed": false, "operation": "doc/delete_document", "target": preflight}) } written, err := rt.CallMCPWriteDataStrict("doc", "delete_document", map[string]any{"nodeId": rt.Str("node")}) if err != nil { return err } if _, err = requireWikiWrite(written, "doc/delete_document"); err != nil { return err } return rt.Output(map[string]any{"success": true, "nodeId": rt.Str("node"), "deleted": true}) })
View Source
var NodeGet = readShortcut("+node-get", "获取知识库节点详情", "已知节点 ID 或在线文档 URL 时读取元数据,并在节点信息之外统一返回文档/文件属性。", "", "dws wiki +node-get --node <nodeId> --format json", []shortcut.Flag{{Name: "node", Type: shortcut.FlagString, Required: true, Desc: "节点 ID 或 URL"}}, []contract.ParamDecl{{Name: "node", Property: "nodeId"}}, func(rt *shortcut.RuntimeContext) error { data, err := rt.CallMCPData("doc", "get_document_info", map[string]any{"nodeId": rt.Str("node")}) if err != nil { return err } object, err := requireWikiObject(data, "doc/get_document_info") if err != nil { return err } if firstWikiString(object, "nodeId", "id", "fileId") == "" { return wikiResponseError("doc/get_document_info", "missing_node_id", "节点详情缺少 nodeId") } return rt.Output(projectWikiNode(object)) })
View Source
var NodeList = readShortcut("+node-list", "严格分页列出知识库节点", "浏览知识库根目录或指定文件夹;只有显式 nodes:[] 才表示空目录,并完整保留 nextCursor/hasMore。", "nodes", "dws wiki +node-list --workspace <workspaceId> --format json", []shortcut.Flag{ {Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID"}, {Name: "folder", Type: shortcut.FlagString, Desc: "父节点 ID"}, {Name: "limit", Type: shortcut.FlagInt, Default: "50", Desc: "每页数量 1-50"}, {Name: "cursor", Type: shortcut.FlagString, Desc: "分页游标", Aliases: []string{"page-token"}, AliasesVisible: true}, }, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}, {Name: "folder", Property: "folderId"}, {Name: "limit", Property: "pageSize"}, {Name: "cursor", Property: "pageToken"}}, func(rt *shortcut.RuntimeContext) error { items, page, err := collectWikiPages(rt, "wiki/list_nodes", rt.Int("limit"), []string{"nodes", "items", "list"}, func(cursor string, size int) (map[string]any, error) { params := map[string]any{"workspaceId": rt.Str("workspace"), "pageSize": size} if rt.Changed("folder") { params["folderId"] = rt.Str("folder") } if cursor != "" { params["pageToken"] = cursor } return rt.CallMCPData("doc", "list_nodes", params) }) if err != nil { return err } nodes := projectWikiRowsPreservingSource(items, nodeAliases()) out := map[string]any{"count": len(nodes), "nodes": nodes} addWikiPagination(out, page) return rt.Output(out) })
View Source
var NodeSearch = readShortcut("+node-search", "严格分页搜索知识库节点", "在指定知识库内按关键词和扩展名搜索节点;需要完整结果时用 --page-all,零命中必须来自显式 documents:[]。", "nodes", "dws wiki +node-search --workspace <workspaceId> --query \"方案\" --format json", []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID"}, {Name: "query", Type: shortcut.FlagString, Required: true, Desc: "关键词"}, {Name: "extensions", Type: shortcut.FlagStringSlice, Desc: "扩展名过滤"}, {Name: "limit", Type: shortcut.FlagInt, Default: "10", Desc: "每页数量 1-30"}, {Name: "cursor", Type: shortcut.FlagString, Desc: "分页游标"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceIds"}, {Name: "query", Property: "keyword"}, {Name: "extensions", Property: "extensions"}, {Name: "limit", Property: "pageSize"}, {Name: "cursor", Property: "pageToken"}}, func(rt *shortcut.RuntimeContext) error { pageSize := rt.Int("limit") if pageSize < 1 || pageSize > 30 { return fmt.Errorf("--limit 必须是 1-30 之间的整数") } items, page, err := collectWikiPages(rt, "doc/search_documents", pageSize, []string{"documents", "docs", "nodes", "items", "list"}, func(cursor string, size int) (map[string]any, error) { params := map[string]any{"workspaceIds": []string{rt.Str("workspace")}, "keyword": rt.Str("query"), "pageSize": size} if rt.Changed("extensions") { params["extensions"] = rt.StrSlice("extensions") } if cursor != "" { params["pageToken"] = cursor } return rt.CallMCPData("doc", "search_documents", params) }) if err != nil { return err } nodes := projectWikiRowsPreservingSource(items, nodeAliases()) out := map[string]any{"count": len(nodes), "nodes": nodes} addWikiPagination(out, page) return rt.Output(out) })
View Source
var SpaceCreate = writeShortcut("+space-create", "创建知识库并读回验证空间类型", "创建新的知识库容器;必须取得 workspaceId、通过详情读回,并用详情或组织/个人范围列表验证空间类型后才报告成功。", "dws wiki +space-create --name \"产品文档库\" --format json", shortcut.RiskWrite, wikiWriteSafety(false), []shortcut.Flag{{Name: "name", Type: shortcut.FlagString, Required: true, Desc: "知识库名称,不超过 32 个字符。--name 不超过 32 个字符;--desc 不超过 500 个字符"}, {Name: "desc", Type: shortcut.FlagString, Desc: "知识库描述,不超过 500 个字符。--name 不超过 32 个字符;--desc 不超过 500 个字符"}, {Name: "icon", Type: shortcut.FlagString, Desc: "图标标识"}}, []contract.ParamDecl{{Name: "name", Property: "name"}, {Name: "desc", Property: "description"}, {Name: "icon", Property: "icon"}}, func(rt *shortcut.RuntimeContext) error { params := map[string]any{"name": rt.Str("name")} if rt.Changed("desc") { params["description"] = rt.Str("desc") } if rt.Changed("icon") { params["icon"] = rt.Str("icon") } if rt.DryRun() { return rt.Output(map[string]any{"dryRun": true, "executed": false, "operation": "wiki/create_wikiSpace", "arguments": params}) } written, err := rt.CallMCPWriteDataStrict("wiki", "create_wikiSpace", params) if err != nil { return err } written, err = requireWikiWrite(written, "wiki/create_wikiSpace") if err != nil { return err } id := nestedWikiString(written, "workspaceId", "spaceId", "id") if id == "" { return wikiResponseError("wiki/create_wikiSpace", "missing_created_id", "创建响应没有 workspaceId;远端效果未知") } verified, err := rt.CallMCPData("wiki", "get_wikiSpace", map[string]any{"workspaceId": id}) if err != nil { return err } verified, err = requireWikiObject(verified, "wiki/get_wikiSpace") if err != nil { return err } if firstWikiString(verified, "workspaceId", "spaceId", "id") != id { return wikiResponseError("wiki/create_wikiSpace", "readback_id_mismatch", "创建后读回的 workspaceId 不一致") } spaceType, evidence, err := verifyWikiSpaceType(rt, id, verified) if err != nil { return wikiSpaceTypeVerificationError(id, verified, err) } return rt.Output(map[string]any{"success": true, "workspaceId": id, "space": verified, "spaceType": spaceType, "spaceTypeVerified": true, "spaceTypeEvidence": evidence}) })
View Source
var SpaceGet = readShortcut("+space-get", "获取知识库详情", "已知 workspace ID 或知识库 URL 时读取并验证空间详情。", "", "dws wiki +space-get --workspace <workspaceId> --format json", []shortcut.Flag{{Name: "workspace", Type: shortcut.FlagString, Required: true, Desc: "知识库 ID 或 URL"}}, []contract.ParamDecl{{Name: "workspace", Property: "workspaceId"}}, func(rt *shortcut.RuntimeContext) error { data, err := rt.CallMCPData("wiki", "get_wikiSpace", map[string]any{"workspaceId": rt.Str("workspace")}) if err != nil { return err } object, err := requireWikiObject(data, "wiki/get_wikiSpace") if err != nil { return err } if firstWikiString(object, "workspaceId", "spaceId", "id") == "" { return wikiResponseError("wiki/get_wikiSpace", "missing_workspace_id", "空间详情缺少 workspaceId") } return rt.Output(object) })
View Source
var SpaceList = readShortcut("+space-list", "严格分页列出知识库并保留类型范围证据", "按 orgWikiSpace 或 myWikiSpace 范围浏览有权访问的知识库,并保留请求类型和服务端分页证据;只有显式 wikiSpaces:[] 才是空结果。", "spaces", "dws wiki +space-list --type orgWikiSpace --limit 50 --page-all --format json", []shortcut.Flag{ {Name: "type", Type: shortcut.FlagString, Default: "orgWikiSpace", Desc: "知识库类型", Enum: []string{"orgWikiSpace", "myWikiSpace"}}, {Name: "limit", Type: shortcut.FlagString, Desc: "每页数量 1-50(默认 20)"}, {Name: "cursor", Type: shortcut.FlagString, Desc: "分页游标", Aliases: []string{"page-token"}, AliasesVisible: true}, }, []contract.ParamDecl{{Name: "type", Property: "wikiSpaceType"}, {Name: "limit", Property: "pageSize"}, {Name: "cursor", Property: "pageToken"}}, func(rt *shortcut.RuntimeContext) error { pageSize, err := wikiStringInt(rt, "limit", 20, 1, 50) if err != nil { return err } items, page, err := collectWikiPages(rt, "wiki/list_wikiSpaces", pageSize, []string{"wikiSpaces", "spaces"}, func(cursor string, size int) (map[string]any, error) { params := map[string]any{"wikiSpaceType": rt.Str("type"), "pageSize": size} if cursor != "" { params["pageToken"] = cursor } return rt.CallMCPData("wiki", "list_wikiSpaces", params) }) if err != nil { return err } spaces := projectWikiRows(items, map[string][]string{"workspaceId": {"workspaceId", "spaceId", "id"}, "name": {"name", "spaceName", "title"}, "description": {"description", "desc"}, "createTime": {"createTime", "createdAt"}, "url": {"spaceUrl", "url"}, "spaceType": {"spaceType", "wikiSpaceType", "type"}}) out := map[string]any{"count": len(spaces), "requestedType": rt.Str("type"), "spaces": spaces} addWikiPagination(out, page) return rt.Output(out) })
View Source
var SpaceSearch = wikiWithInterfaceReason(readShortcut("+space-search", "严格搜索知识库", "按名称关键词定位知识库;严格验证搜索数组,避免内部异常被误报为零命中。", "spaces", "dws wiki +space-search --query \"产品文档\" --format json", []shortcut.Flag{ {Name: "query", Type: shortcut.FlagString, Required: true, Desc: "搜索关键词"}, {Name: "limit", Type: shortcut.FlagString, Desc: "返回数量 1-20(默认 10)"}, }, []contract.ParamDecl{{Name: "query", Property: "query"}, {Name: "limit", Property: "limit"}}, func(rt *shortcut.RuntimeContext) error { pageSize, err := wikiStringInt(rt, "limit", 10, 1, 20) if err != nil { return err } data, err := rt.CallMCPData("wiki", "search_wikiSpaces", map[string]any{"keyword": rt.Str("query"), "pageSize": pageSize}) if err != nil { return err } items, page, err := requireWikiCollection(data, "wiki/search_wikiSpaces", "wikiSpaces", "spaces") if err != nil { return err } spaces := projectWikiRows(items, map[string][]string{"workspaceId": {"workspaceId", "spaceId", "id"}, "name": {"name", "spaceName", "title"}, "description": {"description", "desc"}, "url": {"spaceUrl", "url"}}) out := map[string]any{"count": len(spaces), "spaces": spaces} addWikiPagination(out, page) return rt.Output(out) }), wikiSpaceSearchCompositeReason)
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.