apolo-mcp 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/items.js +2 -0
- package/dist/tools/exclusao.js +11 -7
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/items.js
CHANGED
|
@@ -4,6 +4,8 @@ export const API_PATH = { historia: "stories", task: "tasks", issue: "issues", e
|
|
|
4
4
|
export const LABEL = { historia: "História", task: "Task", issue: "Issue", epico: "Épico" };
|
|
5
5
|
// A concordância do particípio: "história criada", "épico criado".
|
|
6
6
|
export const done = (kind, verb) => `${verb}${kind === "epico" ? "o" : "a"}`;
|
|
7
|
+
// O artigo de cada tipo: "a história", "o épico".
|
|
8
|
+
export const ARTICLE = { historia: "a", task: "a", issue: "a", epico: "o" };
|
|
7
9
|
// Os links antigos de cada tipo redirecionam para o painel do item na lista certa.
|
|
8
10
|
const WEB_SECTION = { historia: "historias", task: "tasks", issue: "issues", epico: "epicos" };
|
|
9
11
|
// Como a busca e o Meu trabalho da API chamam os tipos.
|
package/dist/tools/exclusao.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { API_PATH, itemWebPath, KINDS, LABEL, refLabel } from "../items.js";
|
|
2
|
+
import { API_PATH, ARTICLE, itemWebPath, KINDS, LABEL, refLabel } from "../items.js";
|
|
3
3
|
import { DESTRUCTIVE, guarded, loadItem, projectArg, ToolError } from "./context.js";
|
|
4
4
|
const TARGETS = ["historia", "task", "issue", "epico", "sprint", "pagina_wiki", "link_wiki", "comentario", "anexo", "lancamento_horas"];
|
|
5
5
|
const cut = (text, size = 80) => {
|
|
@@ -20,7 +20,7 @@ async function planOf(ctx, args) {
|
|
|
20
20
|
const tasks = kind === "historia" ? detail.tasks?.length ?? 0 : 0;
|
|
21
21
|
const extra = tasks ? `, com ${tasks} ${tasks === 1 ? "task" : "tasks"}` : "";
|
|
22
22
|
return {
|
|
23
|
-
what: `${LABEL[kind].toLowerCase()} ${refLabel(detail.item.ref)} "${detail.item.subject}"${extra}`,
|
|
23
|
+
what: `${ARTICLE[kind]} ${LABEL[kind].toLowerCase()} ${refLabel(detail.item.ref)} "${detail.item.subject}"${extra}`,
|
|
24
24
|
path: `/${API_PATH[kind]}/${id}`,
|
|
25
25
|
web: api.webUrl(itemWebPath(kind, detail.item.project_id, id)),
|
|
26
26
|
};
|
|
@@ -74,17 +74,20 @@ async function planOf(ctx, args) {
|
|
|
74
74
|
const id = need(args.id, `Informe o id do ${args.tipo}.`);
|
|
75
75
|
const detail = await loadItem(api, kind, itemId);
|
|
76
76
|
const owner = `${LABEL[kind].toLowerCase()} ${refLabel(detail.item.ref)}`;
|
|
77
|
+
// "na história", "do épico".
|
|
78
|
+
const inOwner = `${ARTICLE[kind] === "a" ? "na" : "no"} ${owner}`;
|
|
79
|
+
const ofOwner = `${ARTICLE[kind] === "a" ? "da" : "do"} ${owner}`;
|
|
77
80
|
const web = api.webUrl(itemWebPath(kind, detail.item.project_id, itemId));
|
|
78
81
|
if (args.tipo === "comentario") {
|
|
79
82
|
const comment = detail.comments.find((candidate) => candidate.id === id);
|
|
80
83
|
if (!comment)
|
|
81
|
-
throw new ToolError(`O comentário ${id} não está
|
|
82
|
-
return { what: `o comentário de ${comment.author_name}
|
|
84
|
+
throw new ToolError(`O comentário ${id} não está ${inOwner}.`);
|
|
85
|
+
return { what: `o comentário de ${comment.author_name} ${inOwner}: "${cut(comment.body)}"`, path: `/${API_PATH[kind]}/${itemId}/comments/${id}`, web };
|
|
83
86
|
}
|
|
84
87
|
const attachment = detail.attachments.find((candidate) => candidate.id === id);
|
|
85
88
|
if (!attachment)
|
|
86
|
-
throw new ToolError(`O anexo ${id} não está
|
|
87
|
-
return { what: `o anexo "${attachment.name}"
|
|
89
|
+
throw new ToolError(`O anexo ${id} não está ${inOwner}.`);
|
|
90
|
+
return { what: `o anexo "${attachment.name}" ${ofOwner}`, path: `/${API_PATH[kind]}/${itemId}/attachments/${id}`, web };
|
|
88
91
|
}
|
|
89
92
|
export function registerDeleteTools(server, ctx) {
|
|
90
93
|
server.registerTool("excluir", {
|
|
@@ -102,7 +105,8 @@ export function registerDeleteTools(server, ctx) {
|
|
|
102
105
|
}, guarded(ctx, async (args) => {
|
|
103
106
|
const plan = await planOf(ctx, args);
|
|
104
107
|
if (!server.server.getClientCapabilities()?.elicitation?.form) {
|
|
105
|
-
|
|
108
|
+
// Não é erro: é a regra. Como resposta normal, a ferramenta mostra o aviso, e não uma falha.
|
|
109
|
+
return `Esta ferramenta não tem como pedir a confirmação da pessoa, então o Apolo não exclui por aqui. Para excluir ${plan.what}, abra no navegador: ${plan.web}. Não tente excluir por outro caminho.`;
|
|
106
110
|
}
|
|
107
111
|
const answer = await server.server.elicitInput({
|
|
108
112
|
mode: "form",
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Acompanha o "version" do package.json; o teste confere.
|
|
2
|
-
export const VERSION = "0.3.
|
|
2
|
+
export const VERSION = "0.3.1";
|
package/package.json
CHANGED