Files
pi-kit/extensions/confluence-tools.ts
T
Aleksey Shakhmatov 0c6e590273 refactor(extensions): simplify lib helpers, tool registration and kit-doctor
Behavior-preserving cleanups:
- extract shared resolveBaseUrl helper for jira/confluence base-URL logic
- extract shared registerTool helper; port jira/gitlab/confluence tools to it
- make scanSecrets declarative (filter/map)
- collapse ok/warn pair into status() and drop double existsSync in kit-doctor

Typecheck clean; npm test 71 PASS, 0 FAIL.
2026-08-07 00:24:04 +03:00

63 lines
2.5 KiB
TypeScript

/**
* Confluence tools — native pi tools over the corporate wiki REST API.
* Thin wrappers around lib/confluence.ts.
*
* CONFIGURE: config/company.json → docsUrl; env.sh → CONFLUENCE_TOKEN.
* DISABLE: remove/rename this file from extensions/.
*/
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { registerTool, type ToolSpec } from "./lib/tools.ts";
import { search, pageGet, pageCreate } from "./lib/confluence.ts";
export default function confluenceToolsExtension(pi: ExtensionAPI) {
const tools: ToolSpec[] = [
{
name: "confluence_search",
description: "Найти страницы в Confluence по CQL-запросу (текст/заголовок/пространство).",
errorPrefix: "confluence",
parameters: {
type: "object",
properties: {
cql: { type: "string", description: 'CQL, например text="деплой" AND space = TECHRUN' },
limit: { type: "number", description: "Макс. результатов (default 25)" },
expandBody: { type: "boolean", description: "Вернуть полный текст страниц" },
},
required: ["cql"],
},
run: async (p) => search(p.cql, { limit: p.limit, expandBody: p.expandBody }),
},
{
name: "confluence_page_get",
description: "Получить страницу Confluence по ID (с содержимым, если expandBody).",
errorPrefix: "confluence",
parameters: {
type: "object",
properties: {
id: { type: "string", description: "ID страницы" },
expandBody: { type: "boolean", description: "Вернуть тело страницы" },
},
required: ["id"],
},
run: async (p) => pageGet(p.id, { expandBody: p.expandBody }),
},
{
name: "confluence_page_create",
description: "Создать страницу в Confluence. body — HTML в Storage format.",
errorPrefix: "confluence",
parameters: {
type: "object",
properties: {
spaceKey: { type: "string", description: "Ключ пространства" },
title: { type: "string", description: "Заголовок страницы" },
body: { type: "string", description: "Содержимое страницы (HTML Storage format или текст)" },
parentId: { type: "string", description: "ID родительской страницы (для вложенности)" },
},
required: ["spaceKey", "title", "body"],
},
run: async (p) => pageCreate(p),
},
];
for (const t of tools) registerTool(pi, t);
}