@taiga-ai/mcp-server 0.38.0-dev.1207 → 0.38.0-dev.1211

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.
Files changed (2) hide show
  1. package/dist/index.js +176 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -24102,6 +24102,10 @@ var TaigaClient = class {
24102
24102
  async updateBacklogItem(itemId, body) {
24103
24103
  return this.request("PATCH", `/backlog/${seg(itemId)}`, body);
24104
24104
  }
24105
+ /** Deletes an initiative as the web does: its runs stop and the pull request it waits on closes (PRO-4983). */
24106
+ async deleteBacklogItem(itemId) {
24107
+ return this.request("DELETE", `/backlog/${seg(itemId)}`);
24108
+ }
24105
24109
  async getFactory(id) {
24106
24110
  return this.request("GET", `/factories/${seg(id)}`);
24107
24111
  }
@@ -37196,6 +37200,7 @@ const TOOLSET_OF = {
37196
37200
  taiga_queue_initiative: "operate",
37197
37201
  taiga_move_initiative: "operate",
37198
37202
  taiga_update_initiative: "operate",
37203
+ taiga_delete_initiative: "operate",
37199
37204
  taiga_review_plan: "operate",
37200
37205
  taiga_plan_again: "operate",
37201
37206
  taiga_resume_initiative: "operate",
@@ -37284,6 +37289,7 @@ const DELIVERY_TOOLS = /* @__PURE__ */ new Set([
37284
37289
  "taiga_queue_initiative",
37285
37290
  "taiga_move_initiative",
37286
37291
  "taiga_update_initiative",
37292
+ "taiga_delete_initiative",
37287
37293
  "taiga_review_plan",
37288
37294
  "taiga_plan_again",
37289
37295
  "taiga_resume_initiative",
@@ -41651,6 +41657,7 @@ function registerBacklogTools(server, client) {
41651
41657
  if (may("backlog:read")) registerBacklogReads(server, client);
41652
41658
  if (may("backlog:write")) registerMove(server, client);
41653
41659
  if (may("backlog:write")) registerEdit(server, client);
41660
+ if (may("backlog:write")) registerDelete(server, client);
41654
41661
  if (may("products:write")) registerRequest(server, client);
41655
41662
  if (may("backlog:write") && may("products:write")) registerQueue(server, client);
41656
41663
  if (may("products:write")) registerResume(server, client);
@@ -41814,7 +41821,7 @@ function registerRequest(server, client) {
41814
41821
  function registerMove(server, client) {
41815
41822
  server.registerTool("taiga_move_initiative", {
41816
41823
  title: "Move initiative on the board",
41817
- description: "Move an initiative to another board column, take it off the line, or reorder it. Moving it out of Build stops its plan or run; moving it to backlog, todo or canceled closes the pull request it waits on. state build is Start now, from queue, todo or backlog: the initiative is planned at once against main as it is now and built alongside the current work; parallel builds in one repository can conflict, so say that when you ask. It is refused, with the API's message, for done, canceled, archived, plan and build initiatives, and when the line is stopped or there is no buildable repository. archived: true archives it in place (never from Build): pass its current column as state, or it moves too. To change its title, description or criteria, edit it with taiga_update_initiative; do not cancel it and request a new one.",
41824
+ description: "Move an initiative to another board column, take it off the line, or reorder it. Moving it out of Build stops its plan or run; moving it to backlog, todo or canceled closes the pull request it waits on. state build is Start now, from queue, todo or backlog: the initiative is planned at once against main as it is now and built alongside the current work; parallel builds in one repository can conflict, so say that when you ask. It is refused, with the API's message, for done, canceled, archived, plan and build initiatives, and when the line is stopped or there is no buildable repository. archived: true archives it in place (never from Build): pass its current column as state, or it moves too. To change its title, description or criteria, edit it with taiga_update_initiative; do not cancel it and request a new one. canceled keeps the card and its history; taiga_delete_initiative removes it.",
41818
41825
  inputSchema: object({
41819
41826
  initiativeId,
41820
41827
  state: _enum(USER_DROP_STATES).describe("The column to move into"),
@@ -41830,6 +41837,108 @@ function registerMove(server, client) {
41830
41837
  }));
41831
41838
  }
41832
41839
  /**
41840
+ * What linking knowledge to an initiative reads and needs: the initiative (its
41841
+ * product and the files it links now), each file, and the write the web's
41842
+ * picker is gated on (PRO-4984). A factory's file also reads the product, for
41843
+ * its factory (products:read).
41844
+ */
41845
+ const LINK_KNOWLEDGE_NEEDS = [
41846
+ "backlog:read",
41847
+ "customDocuments:read",
41848
+ "customDocuments:write"
41849
+ ];
41850
+ /**
41851
+ * Why a file read by ID cannot stay linked, or null: one that failed
41852
+ * processing, which the API refuses (findReferenceableIds). One still
41853
+ * processing stays, as the web's upload links it at once. A deleted file does
41854
+ * not read at all; the API's refusal of it is passed through.
41855
+ */
41856
+ function gone(file) {
41857
+ return file.status === "failed" ? "failed processing; add it again" : null;
41858
+ }
41859
+ /** Why a file cannot be newly linked, or null when it can: as the picker offers them (isAddable), ready ones only. */
41860
+ function unavailable(file) {
41861
+ if (file.kbStatus !== "active") return "is being removed";
41862
+ return gone(file) ?? (file.status !== "ready" ? "is still being processed; link it once its status is ready" : null);
41863
+ }
41864
+ /**
41865
+ * The knowledge an edit links, checked as the web's picker offers it
41866
+ * (ReferencedDocumentsPicker): the product's own files and its factory's,
41867
+ * once ready. The API takes any file of the organization, so another
41868
+ * product's file is refused here; a file the person cannot open reads as not
41869
+ * found. Each file is read by ID, its scope and state on it. The description's
41870
+ * images are linked too (origin inline), but the API keeps them whatever is
41871
+ * sent, so they are left out of the list, its cap and the answer. A file linked
41872
+ * already that failed since is refused by the API, so it is named here.
41873
+ */
41874
+ async function knowledgeLinks(client, item, documentIds) {
41875
+ const current = item.documentIds ?? [];
41876
+ const wanted = [...new Set(documentIds)];
41877
+ const ids = [.../* @__PURE__ */ new Set([...current, ...wanted])];
41878
+ const read = await Promise.all(ids.map((docId) => client.getKnowledge(docId).then((result) => [docId, result.data], (error) => {
41879
+ if (isMissOrRefusal(error)) return [docId, null];
41880
+ throw error;
41881
+ })));
41882
+ const files = new Map(read);
41883
+ const inline = (docId) => files.get(docId)?.origin === "inline";
41884
+ const send = wanted.filter((docId) => !inline(docId));
41885
+ if (send.length > 25) return { refused: `An initiative links at most 25 knowledge files.` };
41886
+ const before = current.filter((docId) => !inline(docId));
41887
+ const changed = send.length !== before.length || send.some((docId) => !before.includes(docId));
41888
+ const ref = (docId) => ({
41889
+ id: docId,
41890
+ fileName: files.get(docId)?.fileName ?? null
41891
+ });
41892
+ if (!changed) return {
41893
+ send,
41894
+ changed,
41895
+ linked: send.map(ref),
41896
+ unlinked: []
41897
+ };
41898
+ let factoryId;
41899
+ const reasons = [];
41900
+ for (const docId of send) {
41901
+ const file = files.get(docId);
41902
+ const name = file ? `${file.fileName} (${docId})` : docId;
41903
+ if (before.includes(docId)) {
41904
+ const why = file && gone(file);
41905
+ if (why) reasons.push(`${name}, linked already, ${why}; leave it out to unlink it`);
41906
+ continue;
41907
+ }
41908
+ if (!file) {
41909
+ reasons.push(`${docId} is not a knowledge file this key can open`);
41910
+ continue;
41911
+ }
41912
+ let ofThisProduct = file.productId === item.productId;
41913
+ if (!ofThisProduct && file.productId === null && file.factoryId !== null) {
41914
+ if (!client.hasCapability("products:read")) {
41915
+ reasons.push(`${name} is a factory's file; linking one reads the product, which needs products:read`);
41916
+ continue;
41917
+ }
41918
+ factoryId ??= (await client.getProduct(item.productId)).data.factoryId ?? null;
41919
+ ofThisProduct = file.factoryId === factoryId;
41920
+ }
41921
+ if (!ofThisProduct) {
41922
+ reasons.push(`${name} is not a knowledge file of this product or its factory`);
41923
+ continue;
41924
+ }
41925
+ const why = unavailable(file);
41926
+ if (why) reasons.push(`${name} ${why}`);
41927
+ }
41928
+ if (reasons.length > 0) return { refused: `${reasons.join("; ")}. taiga_list_knowledge lists the product's files (productId) and its factory's (factoryId).` };
41929
+ return {
41930
+ send,
41931
+ changed,
41932
+ linked: send.map(ref),
41933
+ unlinked: before.filter((docId) => !send.includes(docId)).map(ref)
41934
+ };
41935
+ }
41936
+ /** What an edit that changed nothing left as it was. */
41937
+ function unchangedWhat(criteria, knowledge) {
41938
+ if (criteria && knowledge) return "The criteria and linked knowledge are as they were";
41939
+ return criteria ? "The criteria are as they were" : "The linked knowledge is as it was";
41940
+ }
41941
+ /**
41833
41942
  * A criterion as the edit takes it: its text, and whether it needs an
41834
41943
  * end-to-end check. Whether it is met is not the caller's to say: checking a
41835
41944
  * criterion off is a person's verdict or a run's verification, and the web's
@@ -41892,7 +42001,7 @@ const MAX_INT = 2147483647;
41892
42001
  function registerEdit(server, client) {
41893
42002
  server.registerTool("taiga_update_initiative", {
41894
42003
  title: "Edit initiative",
41895
- description: "Change an initiative's title, description, priority, estimate, category, dependencies or acceptance criteria in place, as a person edits it in the web. Use it to correct, reword or translate an initiative rather than canceling it and requesting a new one. A field left out stays as it is. dependencies and acceptanceCriteria replace the whole list: read it first with taiga_get_initiative full: true. A criterion whose text is unchanged keeps whether it is met; a new, reworded or newly end-to-end one starts unmet. The text is refused (CONFLICT) while an agent works on the initiative or its plan waits for review. taiga_move_initiative moves it on the board.",
42004
+ description: "Change an initiative's title, description, priority, estimate, category, dependencies, acceptance criteria or linked knowledge in place, as a person edits it in the web. Use it to correct, reword or translate an initiative rather than canceling it and requesting a new one. A field left out stays as it is. dependencies and acceptanceCriteria and documentIds replace the whole list: read it first with taiga_get_initiative full: true. A criterion whose text is unchanged keeps whether it is met; a new, reworded or newly end-to-end one starts unmet. The text is refused (CONFLICT) while an agent works on the initiative or its plan waits for review. documentIds links knowledge files the planner reads when it plans it: the product's own and its factory's, once ready (taiga_list_knowledge); the result names what it links and unlinks. taiga_move_initiative moves it on the board.",
41896
42005
  inputSchema: object({
41897
42006
  initiativeId,
41898
42007
  title: string$2().trim().min(1).max(500).optional().describe("A new title"),
@@ -41901,34 +42010,79 @@ function registerEdit(server, client) {
41901
42010
  estimate: number$1().int().min(0).max(MAX_INT).optional().describe("Its size in points"),
41902
42011
  category: _enum(BACKLOG_CATEGORIES).optional().describe("The kind of work"),
41903
42012
  dependencies: array(idInput("initiative", "taiga_list_initiatives gives it")).optional().describe("Every initiative it waits for, replacing the list; [] clears it"),
41904
- acceptanceCriteria: array(criterionInput).optional().describe("Every criterion, in order, replacing the list")
42013
+ acceptanceCriteria: array(criterionInput).optional().describe("Every criterion, in order, replacing the list"),
42014
+ documentIds: array(idInput("knowledge file", "taiga_list_knowledge gives it")).optional().describe(`Every knowledge file it links, at most 25, replacing the list; [] clears it. Images in its description stay linked whatever is sent`)
41905
42015
  }),
41906
42016
  annotations: WRITE
41907
42017
  }, (params) => runTool(async () => {
41908
- const { initiativeId: id, acceptanceCriteria, ...fields } = params;
42018
+ const { initiativeId: id, acceptanceCriteria, documentIds, ...fields } = params;
41909
42019
  if (fields.dependencies?.includes(id)) return toolError("VALIDATION_ERROR", "An initiative cannot depend on itself.");
41910
- if (acceptanceCriteria === void 0 && Object.values(fields).every((value) => value === void 0)) return toolError("VALIDATION_ERROR", "Give at least one of title, description, priority, estimate, category, dependencies or acceptanceCriteria.");
42020
+ if (acceptanceCriteria === void 0 && documentIds === void 0 && Object.values(fields).every((value) => value === void 0)) return toolError("VALIDATION_ERROR", "Give at least one of title, description, priority, estimate, category, dependencies, acceptanceCriteria or documentIds.");
42021
+ if (documentIds !== void 0) {
42022
+ const lacking = LINK_KNOWLEDGE_NEEDS.filter((capability) => !client.hasCapability(capability));
42023
+ if (lacking.length > 0) return toolError("FORBIDDEN", `Linking knowledge reads the initiative and each file, and needs ${lacking.join(", ")}, which this key lacks.`);
42024
+ }
41911
42025
  if (acceptanceCriteria !== void 0 && !client.hasCapability("backlog:read")) return toolError("FORBIDDEN", "Editing acceptance criteria reads the current ones first and needs backlog:read, which this key lacks.");
42026
+ const current = acceptanceCriteria !== void 0 || documentIds !== void 0 ? (await client.getBacklogItem(id)).data : null;
42027
+ let links;
42028
+ if (documentIds !== void 0 && current) {
42029
+ const checked = await knowledgeLinks(client, current, documentIds);
42030
+ if ("refused" in checked) return toolError("VALIDATION_ERROR", checked.refused);
42031
+ links = checked;
42032
+ }
41912
42033
  let criteria;
41913
- if (acceptanceCriteria !== void 0) {
41914
- const current = (await client.getBacklogItem(id)).data;
42034
+ if (acceptanceCriteria !== void 0 && current) {
41915
42035
  const carried = carriedCriteria(current.acceptanceCriteria, acceptanceCriteria);
41916
42036
  if (criteriaSpec(carried) !== criteriaSpec(current.acceptanceCriteria)) criteria = carried;
41917
- else if (Object.values(fields).every((value) => value === void 0)) return toolResult({
41918
- ...outcomeOf(current),
41919
- unchanged: "The criteria are as they were; nothing was written."
41920
- });
41921
42037
  }
41922
- const item = (await client.updateBacklogItem(id, {
41923
- ...fields.title !== void 0 ? { title: fields.title } : {},
41924
- ...fields.description !== void 0 ? { description: fields.description } : {},
41925
- ...fields.priority !== void 0 ? { priority: fields.priority } : {},
41926
- ...fields.estimate !== void 0 ? { estimate: fields.estimate } : {},
41927
- ...fields.category !== void 0 ? { category: fields.category } : {},
41928
- ...fields.dependencies !== void 0 ? { dependencies: fields.dependencies } : {},
41929
- ...criteria !== void 0 ? { acceptanceCriteria: criteria } : {}
41930
- })).data;
41931
- return outcome(item);
42038
+ const linksChange = links?.changed === true;
42039
+ if (current && criteria === void 0 && !linksChange && Object.values(fields).every((v) => v === void 0)) return toolResult({
42040
+ ...outcomeOf(current),
42041
+ unchanged: `${unchangedWhat(acceptanceCriteria !== void 0, documentIds !== void 0)}; nothing was written.`
42042
+ });
42043
+ let item;
42044
+ try {
42045
+ item = (await client.updateBacklogItem(id, {
42046
+ ...fields.title !== void 0 ? { title: fields.title } : {},
42047
+ ...fields.description !== void 0 ? { description: fields.description } : {},
42048
+ ...fields.priority !== void 0 ? { priority: fields.priority } : {},
42049
+ ...fields.estimate !== void 0 ? { estimate: fields.estimate } : {},
42050
+ ...fields.category !== void 0 ? { category: fields.category } : {},
42051
+ ...fields.dependencies !== void 0 ? { dependencies: fields.dependencies } : {},
42052
+ ...criteria !== void 0 ? { acceptanceCriteria: criteria } : {},
42053
+ ...links && linksChange ? { documentIds: links.send } : {}
42054
+ })).data;
42055
+ } catch (error) {
42056
+ if (links && error instanceof TaigaApiError && error.status === 400 && /Referenced documents/.test(error.apiMessage ?? "")) return toolError("VALIDATION_ERROR", `${error.apiMessage} Leave them out of documentIds to unlink them.`);
42057
+ throw error;
42058
+ }
42059
+ if (!links) return outcome(item);
42060
+ return toolResult({
42061
+ ...outcomeOf(item),
42062
+ linkedKnowledge: links.linked,
42063
+ unlinkedKnowledge: links.unlinked
42064
+ });
42065
+ }));
42066
+ }
42067
+ /**
42068
+ * Deleting an initiative, as the web's Delete does (PRO-4983). The route stops
42069
+ * the runs building it and closes its open pull requests, so it is paid work
42070
+ * asked first (PAID_WORK); canceled is the move that keeps the card and its
42071
+ * history. It does not stop a plan being written (PRO-4993), so the
42072
+ * description promises only the run.
42073
+ */
42074
+ function registerDelete(server, client) {
42075
+ server.registerTool("taiga_delete_initiative", {
42076
+ title: "Delete initiative",
42077
+ description: "Delete an initiative: it leaves the board and every list and read, and cannot be brought back. A run building it stops, and its open pull requests are closed unmerged; one its forge will not let Taiga close stays open. Use it for a duplicate or a mistake; to keep the card and its history, move it to canceled with taiga_move_initiative instead. Name the initiative to the person, and what it stops, when you ask. When the forge does not answer, nothing is deleted and the refusal says to try again.",
42078
+ inputSchema: object({ initiativeId }),
42079
+ annotations: OPERATE
42080
+ }, (params) => runTool(async () => {
42081
+ await client.deleteBacklogItem(params.initiativeId);
42082
+ return toolResult({
42083
+ id: params.initiativeId,
42084
+ deleted: true
42085
+ });
41932
42086
  }));
41933
42087
  }
41934
42088
  /** The two halves of the Build station, where Plan again is offered. */
@@ -59787,6 +59941,7 @@ function writeNotice(name, annotations) {
59787
59941
  */
59788
59942
  const PAID_WORK = /* @__PURE__ */ new Set([
59789
59943
  "taiga_add_knowledge",
59944
+ "taiga_delete_initiative",
59790
59945
  "taiga_finish_discovery",
59791
59946
  "taiga_fix_finding",
59792
59947
  "taiga_fix_policy_violation",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ai/mcp-server",
3
- "version": "0.38.0-dev.1207",
3
+ "version": "0.38.0-dev.1211",
4
4
  "description": "Taiga for AI coding assistants: read products, policies, initiatives and runs, and operate the line, over MCP",
5
5
  "mcpName": "ga.tai/mcp-server",
6
6
  "license": "UNLICENSED",