@taiga-ai/mcp-server 0.36.0-dev.774 → 0.36.0-dev.777

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 +97 -90
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23680,11 +23680,22 @@ var TaigaClient = class {
23680
23680
  async getTenantDocumentDraft(type) {
23681
23681
  return this.request("GET", `/tenants/current/documents/${seg(type)}/draft`);
23682
23682
  }
23683
+ /**
23684
+ * Save the draft. `expectedRevision` (design_standards only) is the `revision` the edit was built on, or null when
23685
+ * it was built on the published version because no draft existed; the API refuses with 409 `draft_changed` when
23686
+ * the draft is no longer that. With no draft, `expectedPublishedVersion` (the published version the edit was built
23687
+ * on, null when none) is checked the same way. Omitted means no check.
23688
+ */
23683
23689
  async saveTenantDocumentDraft(type, body) {
23684
23690
  return this.request("PUT", `/tenants/current/documents/${seg(type)}/draft`, body);
23685
23691
  }
23686
- async publishTenantDocument(type) {
23687
- return this.request("POST", `/tenants/current/documents/${seg(type)}/publish`);
23692
+ /**
23693
+ * Publish the draft. With `requireTokensAligned` the API checks, in the same transaction as the publish, that a
23694
+ * design standards draft's text and tokens agree, and answers 409 `tokens_out_of_line` without publishing when
23695
+ * they do not. The POST stays bodiless.
23696
+ */
23697
+ async publishTenantDocument(type, options) {
23698
+ return this.request("POST", `/tenants/current/documents/${seg(type)}/publish${query$1({ requireTokensAligned: options?.requireTokensAligned ? true : void 0 })}`);
23688
23699
  }
23689
23700
  /** Whether the design standards draft's (or published version's) text and tokens were last brought into line. */
23690
23701
  async getDesignTokenAlignment(version) {
@@ -23803,14 +23814,6 @@ var TaigaClient = class {
23803
23814
  async getActivePlan(itemId) {
23804
23815
  return this.request("GET", `/backlog/${seg(itemId)}/plans/active`);
23805
23816
  }
23806
- /** Every plan version of an initiative with the verdict it received, newest first unless `order` says otherwise. */
23807
- async listPlanHistory(itemId, order) {
23808
- return this.request("GET", `/backlog/${seg(itemId)}/plans/history${query$1({ order })}`);
23809
- }
23810
- /** One plan version with its steps, whether or not it is the active one. */
23811
- async getPlan(planId) {
23812
- return this.request("GET", `/plans/${seg(planId)}`);
23813
- }
23814
23817
  async approvePlan(planId) {
23815
23818
  return this.request("POST", `/plans/${seg(planId)}/approve`);
23816
23819
  }
@@ -26550,7 +26553,7 @@ const PRODUCT_NETWORK_ACCESS = ["allowlist", "unrestricted"];
26550
26553
  * reads as deleted) and fields they explain would simply be missing. So it
26551
26554
  * refuses to start, and says what to do.
26552
26555
  */
26553
- function apiLevelProblem(introspection, apiUrl, required = 7, version = SERVER_VERSION) {
26556
+ function apiLevelProblem(introspection, apiUrl, required = 8, version = SERVER_VERSION) {
26554
26557
  const offered = introspection.mcpApiLevel ?? 0;
26555
26558
  if (offered >= required) return null;
26556
26559
  return `The Taiga API at ${apiUrl} is older than @taiga-ai/mcp-server ${version} needs (API level ${offered}, needs ${required}). Run the version published for it, or wait for that API to be updated; an earlier release of this package works against it.`;
@@ -26585,7 +26588,6 @@ const TOOLSET_OF = {
26585
26588
  taiga_list_initiatives: "core",
26586
26589
  taiga_get_initiative: "core",
26587
26590
  taiga_get_plan: "core",
26588
- taiga_list_plans: "core",
26589
26591
  taiga_list_runs: "core",
26590
26592
  taiga_get_run: "core",
26591
26593
  taiga_get_line: "core",
@@ -26916,7 +26918,7 @@ const ITEM_ID_HINT = "taiga_list_initiatives lists a product's initiatives with
26916
26918
  const BY_ARGUMENT = {
26917
26919
  initiativeId: ITEM_ID_HINT,
26918
26920
  runId: "taiga_list_runs lists the runs, of one product or of every product the key can see.",
26919
- planId: "taiga_get_plan gives the initiative's active plan and its ID; taiga_list_plans lists every version's ID.",
26921
+ planId: "taiga_get_plan gives the initiative's active plan and its ID.",
26920
26922
  linkId: "taiga_list_product_repositories lists the product's repository links; a linkable repository id is not a link ID.",
26921
26923
  replacesLinkId: "taiga_list_product_repositories lists the product's repository links.",
26922
26924
  linkableRepositoryId: "taiga_list_linkable_repositories lists the repositories the GitHub and GitLab connections reach, with their ids.",
@@ -28913,11 +28915,23 @@ function documentSummary(doc) {
28913
28915
  */
28914
28916
  async function editBase(scope) {
28915
28917
  const draft = (await scope.getDraft()).data;
28916
- if (draft) return draft.data;
28918
+ if (draft) return {
28919
+ base: draft.data,
28920
+ revision: "revision" in draft ? draft.revision : void 0
28921
+ };
28917
28922
  try {
28918
- return (await scope.getPublished()).data.data;
28923
+ const published = (await scope.getPublished()).data;
28924
+ return {
28925
+ base: published.data,
28926
+ revision: null,
28927
+ publishedVersion: published.version ?? null
28928
+ };
28919
28929
  } catch (error) {
28920
- if (error instanceof TaigaApiError && error.status === 404) return { sections: {} };
28930
+ if (error instanceof TaigaApiError && error.status === 404) return {
28931
+ base: { sections: {} },
28932
+ revision: null,
28933
+ publishedVersion: null
28934
+ };
28921
28935
  throw error;
28922
28936
  }
28923
28937
  }
@@ -28925,14 +28939,18 @@ async function editBase(scope) {
28925
28939
  * Edit one section of a document's draft; the edit keeps every other section
28926
28940
  * and the section's own metadata, see sections.ts.
28927
28941
  */
28928
- async function updateSection(scope, type, id, content) {
28929
- const base = await editBase(scope);
28942
+ async function updateSection(scope, type, id, content, options = {}) {
28943
+ const { base, revision, publishedVersion } = await editBase(scope);
28930
28944
  const sections = sectionsOf(base);
28931
28945
  if (!sections) return toolError("UNSUPPORTED_DOCUMENT", `Document ${type} is not made of sections and cannot be edited section by section. Edit it in the Taiga app.`);
28932
- const saved = await scope.saveDraft({
28946
+ const edited = {
28933
28947
  ...base,
28934
28948
  sections: applySectionEdit(sections, id, content)
28935
- });
28949
+ };
28950
+ const saved = await scope.saveDraft(edited, options.sendRevision && revision !== void 0 ? {
28951
+ expectedRevision: revision,
28952
+ ...revision === null && publishedVersion !== void 0 ? { expectedPublishedVersion: publishedVersion } : {}
28953
+ } : void 0);
28936
28954
  return toolResult({
28937
28955
  ...documentSummary(saved.data),
28938
28956
  section: {
@@ -28948,7 +28966,10 @@ async function updateSection(scope, type, id, content) {
28948
28966
  * which are kept: they are the only way the publisher hears of them.
28949
28967
  */
28950
28968
  async function publishDraft(scope, extra = {}) {
28951
- const published = await scope.publish();
28969
+ return publishedResult(await scope.publish(), extra);
28970
+ }
28971
+ /** The tool result for a publish that went through: the document's summary, the alignment if any, and every warning. */
28972
+ function publishedResult(published, extra) {
28952
28973
  const own = extra.warnings ?? [];
28953
28974
  const api = published.warnings;
28954
28975
  const warnings = own.length === 0 ? api : [...Array.isArray(api) ? api : api ? [api] : [], ...own];
@@ -28987,9 +29008,28 @@ function withFields(result, fields) {
28987
29008
  ...fields
28988
29009
  });
28989
29010
  }
28990
- /** A section edit of the design standards says whether its tokens still match the text. */
29011
+ const DRAFT_CHANGED = "The design standards draft changed after this edit read it (a person, an agent or a token sync changed it), so nothing was saved and their change was kept. Read the draft again with taiga_get_organization_document and make the edit again.";
29012
+ /** The reason of a 409 the API sent with a structured `details.reason`, else undefined. */
29013
+ function conflictReason(error) {
29014
+ if (!(error instanceof TaigaApiError) || error.status !== 409) return void 0;
29015
+ const reason = error.details?.["reason"];
29016
+ return typeof reason === "string" && error.details ? {
29017
+ reason,
29018
+ details: error.details
29019
+ } : void 0;
29020
+ }
29021
+ /**
29022
+ * A section edit of the design standards says whether its tokens still match the text. It is saved against the
29023
+ * revision of the draft it read, so a change made since is refused rather than overwritten.
29024
+ */
28991
29025
  async function updateDesignStandardsSection(client, scope, id, content) {
28992
- const saved = await updateSection(scope, DESIGN_STANDARDS, id, content);
29026
+ let saved;
29027
+ try {
29028
+ saved = await updateSection(scope, DESIGN_STANDARDS, id, content, { sendRevision: true });
29029
+ } catch (error) {
29030
+ if (conflictReason(error)?.reason === "draft_changed") return toolError("CONFLICT", DRAFT_CHANGED);
29031
+ throw error;
29032
+ }
28993
29033
  if (saved.isError) return saved;
28994
29034
  const tokenAlignment = await alignmentOf(client, "draft");
28995
29035
  return withFields(saved, {
@@ -28997,42 +29037,35 @@ async function updateDesignStandardsSection(client, scope, id, content) {
28997
29037
  ...tokenAlignment.status === "aligned" ? {} : { hint: TOKENS_HINT }
28998
29038
  });
28999
29039
  }
29040
+ /** The refusal a publish of the design standards drew, as a tool error; undefined for any other failure. */
29041
+ function publishRefusal(error) {
29042
+ const conflict = conflictReason(error);
29043
+ if (!conflict) return void 0;
29044
+ if (conflict.reason === "design_job_running") return toolError("CONFLICT", "A design job is updating the draft. If it is a token sync, wait for it with taiga_get_design_token_sync; for any other design job (a derive or a component generation), wait with taiga_wait (jobId). Then publish again. Nothing was published.");
29045
+ if (conflict.reason !== "tokens_out_of_line") return void 0;
29046
+ const found = conflict.details["tokenAlignment"];
29047
+ const tokenAlignment = isRecord$1(found) ? found : void 0;
29048
+ return toolError("TOKENS_OUT_OF_LINE", `${typeof tokenAlignment?.["message"] === "string" ? tokenAlignment["message"] : "The tokens do not match the text."} Bring the tokens in line with taiga_update_design_tokens or taiga_sync_design_tokens, then publish again; to publish them out of line ask again with publishWithTokensOutOfLine: true. Readers and builds keep the published version.`, tokenAlignment ? { tokenAlignment } : void 0);
29049
+ }
29000
29050
  /**
29001
- * Publish the design standards draft only when its text and tokens agree, or when the caller says to publish them
29002
- * out of line; builds read the tokens, so a publish that leaves them behind the text is never silent.
29051
+ * Publish the design standards draft. The API checks that its text and tokens agree in the same transaction as the
29052
+ * publish, so nothing can change between the check and the publish; unless the caller says to publish them out of
29053
+ * line, a disagreement is refused and nothing is published.
29003
29054
  */
29004
- async function publishDesignStandards(client, scope, outOfLineAllowed) {
29005
- let tokenAlignment;
29055
+ async function publishDesignStandards(scope, outOfLineAllowed) {
29056
+ let published;
29006
29057
  try {
29007
- tokenAlignment = (await client.getDesignTokenAlignment("draft")).data;
29058
+ published = await scope.publish({ requireTokensAligned: !outOfLineAllowed });
29008
29059
  } catch (error) {
29009
- if (error instanceof TaigaApiError && error.status === 404) return publishDraft(scope);
29010
- tokenAlignment = unknownAlignment("draft", error);
29060
+ const refused = publishRefusal(error);
29061
+ if (refused) return refused;
29062
+ throw error;
29011
29063
  }
29012
- if (tokenAlignment.status !== "aligned" && !outOfLineAllowed) return toolError("TOKENS_OUT_OF_LINE", `${tokenAlignment.message} Nothing was published. Bring the tokens in line first: edit them with taiga_update_design_tokens or start taiga_sync_design_tokens, then publish again. To publish the text with tokens that do not match it, ask again with publishWithTokensOutOfLine: true. Readers and builds keep the published version until a publish goes through.`, { tokenAlignment });
29013
- const published = await publishDraft(scope, tokenAlignment.status === "aligned" ? { tokenAlignment } : {
29064
+ const tokenAlignment = published.tokenAlignment;
29065
+ if (!tokenAlignment) return publishedResult(published, { warnings: ["The API did not report the token alignment, so this publish was not checked for text and tokens agreeing; read it with taiga_get_organization_document."] });
29066
+ return publishedResult(published, {
29014
29067
  tokenAlignment,
29015
- warnings: [`Published with the tokens out of line (${tokenAlignment.status}): the published text and tokens may disagree, and builds use the tokens.`]
29016
- });
29017
- if (published.isError) return published;
29018
- return confirmPublishedAlignment(client, published, tokenAlignment, outOfLineAllowed);
29019
- }
29020
- /**
29021
- * The check above and the publish are separate requests, so the draft can change between them. What was published
29022
- * is read back: the result reports the published version's own alignment, and a publish that went out of line
29023
- * without the caller's say-so is said so in its warnings, never reported as aligned.
29024
- */
29025
- async function confirmPublishedAlignment(client, published, checked, outOfLineAllowed) {
29026
- const first = published.content[0];
29027
- if (first?.type !== "text") return published;
29028
- const after = await alignmentOf(client, "published");
29029
- if (after.status === "aligned") return withFields(published, { tokenAlignment: after });
29030
- const body = JSON.parse(first.text);
29031
- const warnings = Array.isArray(body["warnings"]) ? body["warnings"] : [];
29032
- const note = after.status === "unknown" ? `The published version's token alignment could not be confirmed after publishing (the check before it said ${checked.status}).` : `The draft changed after the alignment check, so the published text and tokens may disagree (${after.status}), and builds use the tokens. Edit the tokens or start taiga_sync_design_tokens, then publish again.`;
29033
- return withFields(published, {
29034
- tokenAlignment: after,
29035
- ...outOfLineAllowed && after.status !== "unknown" ? {} : { warnings: [...warnings, note] }
29068
+ ...tokenAlignment.status === "aligned" ? {} : { warnings: [`Published with the tokens out of line (${tokenAlignment.status}): the published text and tokens may disagree, and builds use the tokens.`] }
29036
29069
  });
29037
29070
  }
29038
29071
  /** The section ids that are not control ids at all. GDPR-1.1 is a control id, so it is not among them, though it names no single policy. */
@@ -29112,12 +29145,16 @@ function registerDocumentTools(server, client) {
29112
29145
  const tenantScope = (type) => ({
29113
29146
  getDraft: () => client.getTenantDocumentDraft(type),
29114
29147
  getPublished: () => client.getTenantDocument(type),
29115
- saveDraft: (data) => client.saveTenantDocumentDraft(type, { data }),
29116
- publish: () => client.publishTenantDocument(type)
29148
+ saveDraft: (data, options) => client.saveTenantDocumentDraft(type, {
29149
+ data,
29150
+ ...options?.expectedRevision !== void 0 ? { expectedRevision: options.expectedRevision } : {},
29151
+ ...options?.expectedPublishedVersion !== void 0 ? { expectedPublishedVersion: options.expectedPublishedVersion } : {}
29152
+ }),
29153
+ publish: (options) => client.publishTenantDocument(type, options)
29117
29154
  });
29118
29155
  server.registerTool("taiga_update_organization_document", {
29119
29156
  title: "Update a section of an organization document draft",
29120
- description: "Change one section of an organization document's draft, such as a policy. Readers keep the published version until it is published.",
29157
+ description: "Change one section of an organization document's draft, such as a policy. Readers keep the published version until it is published. A design standards edit is refused (CONFLICT) if the draft changed since it was read.",
29121
29158
  inputSchema: object({
29122
29159
  type: tenantDocumentType,
29123
29160
  sectionId: sectionIdFrom("taiga_get_organization_document"),
@@ -29127,13 +29164,13 @@ function registerDocumentTools(server, client) {
29127
29164
  }, (params) => runTool(() => params.type === DESIGN_STANDARDS ? updateDesignStandardsSection(client, tenantScope(params.type), params.sectionId, params.content) : updateSection(tenantScope(params.type), params.type, params.sectionId, params.content)));
29128
29165
  server.registerTool("taiga_publish_organization_document", {
29129
29166
  title: "Publish an organization document draft",
29130
- description: "Publish an organization document's draft as its next version, which every agent and person then follows. A design standards draft whose tokens do not match its text is refused (TOKENS_OUT_OF_LINE) unless publishWithTokensOutOfLine is true.",
29167
+ description: "Publish an organization document's draft as its next version, which every agent and person then follows. A design standards draft whose tokens do not match its text is refused (TOKENS_OUT_OF_LINE), checked in the publish itself, unless publishWithTokensOutOfLine is true.",
29131
29168
  inputSchema: object({
29132
29169
  type: tenantDocumentType,
29133
29170
  publishWithTokensOutOfLine: boolean().optional().describe("design_standards only: publish although its tokens may not match its text; the result then carries a warning")
29134
29171
  }),
29135
29172
  annotations: PUBLISH
29136
- }, (params) => runTool(() => params.type === DESIGN_STANDARDS ? publishDesignStandards(client, tenantScope(params.type), params.publishWithTokensOutOfLine === true) : publishDraft(tenantScope(params.type))));
29173
+ }, (params) => runTool(() => params.type === DESIGN_STANDARDS ? publishDesignStandards(tenantScope(params.type), params.publishWithTokensOutOfLine === true) : publishDraft(tenantScope(params.type))));
29137
29174
  }
29138
29175
  if (client.hasCapability("factories:read")) server.registerTool("taiga_get_factory_document", {
29139
29176
  title: "Get factory instructions",
@@ -30516,57 +30553,27 @@ function registerBacklogReads(server, client) {
30516
30553
  }));
30517
30554
  server.registerTool("taiga_get_plan", {
30518
30555
  title: "Get the active plan",
30519
- description: "Read an initiative's active plan, step by step: what each builds, the files it writes and reads, and what it depends on. Enough to approve or reject it; full: true adds each step's complete instructions (long). A plan a request for changes revised says so in revision: the steps it added, edited and dropped, and the committed steps it reverts. version reads an earlier version instead (taiga_list_plans lists them): the plan comes with its verdict, who gave it and the comment, and what it answers. NOT_FOUND when there is no active plan, the initiative's situation says why; with version, when the initiative has no such version, and the message names the ones it has.",
30556
+ description: "Read an initiative's active plan, step by step: what each builds, the files it writes and reads, and what it depends on. Enough to approve or reject it; full: true adds each step's complete instructions (long). A plan a request for changes revised says so in revision: the steps it added, edited and dropped, and the committed steps it reverts. NOT_FOUND when there is no active plan, the initiative's situation says why.",
30520
30557
  inputSchema: object({
30521
30558
  initiativeId,
30522
- version: number$1().int().min(1).optional().describe("A plan version to read, such as 1 (default: the active plan); taiga_list_plans lists the versions"),
30523
30559
  full: boolean().optional().describe("Carry each step's complete instructions (default false: a summary)")
30524
30560
  }),
30525
30561
  annotations: READ_ONLY
30526
30562
  }, (params) => runTool(async () => {
30527
- let plan;
30528
- let versionNote = {};
30529
- if (params.version === void 0) plan = (await client.getActivePlan(params.initiativeId)).data;
30530
- else {
30531
- const history = (await client.listPlanHistory(params.initiativeId, "oldest")).data;
30532
- const entry = history.find((candidate) => candidate.version === params.version);
30533
- if (!entry) {
30534
- const have = history.map((candidate) => candidate.version).sort((a, b) => a - b);
30535
- return toolError("NOT_FOUND", have.length > 0 ? `This initiative has no plan version ${params.version}; it has version${have.length > 1 ? "s" : ""} ${have.join(", ")}.` : `This initiative has no plan version ${params.version}: it has never been planned.`);
30536
- }
30537
- plan = (await client.getPlan(entry.planId)).data;
30538
- versionNote = {
30539
- verdict: entry.verdict,
30540
- answers: entry.answers
30541
- };
30542
- }
30563
+ const plan = (await client.getActivePlan(params.initiativeId)).data;
30543
30564
  const revision = await planRevisionOf(client, params.initiativeId, plan.id);
30544
30565
  const revised = revision ? { revision } : {};
30545
30566
  if (params.full) return toolResult({
30546
30567
  ...plan,
30547
- ...versionNote,
30548
30568
  ...revised
30549
30569
  });
30550
30570
  const steps = Array.isArray(plan.steps) ? plan.steps : [];
30551
30571
  return toolResult({
30552
30572
  ...pickFields([plan], PLAN_SUMMARY_FIELDS)[0],
30553
- ...versionNote,
30554
30573
  ...revised,
30555
30574
  steps: pickFields(steps, PLAN_STEP_SUMMARY_FIELDS)
30556
30575
  });
30557
30576
  }));
30558
- server.registerTool("taiga_list_plans", {
30559
- title: "List plan versions and their verdicts",
30560
- description: "List every plan version of an initiative, newest first (order: 'oldest' reverses it). Each version has its status, its verdict (approved, rejected, changes_requested, awaiting_review, or none when none was recorded), who gave it by name, when and the comment, and the earlier version and comment it answers. taiga_get_plan with version reads one in full. An initiative never planned returns an empty list.",
30561
- inputSchema: object({
30562
- initiativeId,
30563
- order: _enum(["newest", "oldest"]).optional().describe("Order of the versions (default 'newest')")
30564
- }),
30565
- annotations: READ_ONLY
30566
- }, (params) => runTool(async () => {
30567
- const versions = (await client.listPlanHistory(params.initiativeId, params.order)).data;
30568
- return toolResult({ versions });
30569
- }));
30570
30577
  }
30571
30578
  function registerRequest(server, client) {
30572
30579
  server.registerTool("taiga_request_initiatives", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ai/mcp-server",
3
- "version": "0.36.0-dev.774",
3
+ "version": "0.36.0-dev.777",
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",