@codazen/harmonica-mcp 4.0.2 → 4.1.0

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 +45 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -26329,6 +26329,15 @@ var normalizeSystemId = (raw) => {
26329
26329
  if (!id) return raw;
26330
26330
  return { ...b, systemId: id };
26331
26331
  };
26332
+ var normalizeSystemIdAndName = (raw) => {
26333
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
26334
+ const b = raw;
26335
+ const result = { ...b };
26336
+ const id = b["systemId"] || b["projectId"];
26337
+ if (id) result["systemId"] = id;
26338
+ if ((b["systemName"] == null || b["systemName"] === "") && b["projectName"]) result["systemName"] = b["projectName"];
26339
+ return result;
26340
+ };
26332
26341
  var normalizeSystemIdAndTitle = (raw) => {
26333
26342
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return raw;
26334
26343
  const b = raw;
@@ -26344,15 +26353,17 @@ var BeatApiSchema = external_exports.preprocess(
26344
26353
  if (typeof raw !== "object" || raw === null) return raw;
26345
26354
  const b = raw;
26346
26355
  const id = b["systemId"] || b["projectId"];
26347
- if (!id) return raw;
26348
- return { ...b, systemId: id };
26356
+ const result = { ...b };
26357
+ if (id) result["systemId"] = id;
26358
+ if ((b["systemName"] == null || b["systemName"] === "") && b["projectName"]) result["systemName"] = b["projectName"];
26359
+ return result;
26349
26360
  },
26350
26361
  external_exports.object({
26351
26362
  beatId: external_exports.string(),
26352
26363
  systemId: external_exports.string(),
26353
- /** Source project's title; attached by the flat /api/beats endpoint for
26354
- * multi-project (teamspace/org) responses. */
26355
- projectName: external_exports.string().nullish(),
26364
+ /** Source system's title; attached by the flat /api/beats endpoint for
26365
+ * multi-system (teamspace/org) responses. */
26366
+ systemName: external_exports.string().nullish(),
26356
26367
  title: external_exports.string(),
26357
26368
  version: external_exports.number().nullish(),
26358
26369
  description: external_exports.string().nullish(),
@@ -26818,13 +26829,13 @@ var NextActionSchema = external_exports.object({
26818
26829
  var NextActionsResponseSchema = external_exports.object({
26819
26830
  actions: external_exports.array(NextActionSchema)
26820
26831
  }).passthrough();
26821
- var SearchResultSchema = external_exports.preprocess(normalizeSystemId, external_exports.object({
26832
+ var SearchResultSchema = external_exports.preprocess(normalizeSystemIdAndName, external_exports.object({
26822
26833
  entityId: external_exports.string(),
26823
26834
  entityType: external_exports.enum(["beat", "note", "revision", "beatVersion", "drop", "project", "system"]),
26824
26835
  score: external_exports.number(),
26825
26836
  snippet: external_exports.string(),
26826
26837
  systemId: external_exports.string().optional(),
26827
- projectName: external_exports.string().optional(),
26838
+ systemName: external_exports.string().optional(),
26828
26839
  teamspaceId: external_exports.string().optional()
26829
26840
  }).passthrough());
26830
26841
  var SearchScopeSchema = external_exports.object({
@@ -27816,7 +27827,7 @@ function registerNoteTools(server, ctx, client) {
27816
27827
  const noteId = await client.getNextNoteId(projectCode, systemId);
27817
27828
  note = await client.createNote({
27818
27829
  noteId,
27819
- projectId: systemId,
27830
+ systemId,
27820
27831
  beatId,
27821
27832
  revisionId,
27822
27833
  beatVersionId,
@@ -28915,7 +28926,7 @@ Systems (${createdProjects.length}):`);
28915
28926
  const n = await client.createNote({
28916
28927
  noteId: `N-TEMP-${(0, import_node_crypto.randomUUID)()}`,
28917
28928
  // overridden server-side
28918
- projectId: project.systemId,
28929
+ systemId: project.systemId,
28919
28930
  noteType: note.noteType,
28920
28931
  content: note.content,
28921
28932
  rationale: note.rationale,
@@ -29575,6 +29586,7 @@ function registerPulseReportTools(server, _ctx, client) {
29575
29586
  }
29576
29587
 
29577
29588
  // ../../libs/harmonica-services/src/delivery-policy.decide.ts
29589
+ var DELIVERY_STEPS = ["openPullRequest", "requestAgentReview", "watchPullRequest"];
29578
29590
  function decideDeliveryStep(resolution, step) {
29579
29591
  if (!resolution.resolved) return "ask";
29580
29592
  const value = resolution.policy[step];
@@ -29582,6 +29594,19 @@ function decideDeliveryStep(resolution, step) {
29582
29594
  if (value === false) return "prohibited";
29583
29595
  return "ask";
29584
29596
  }
29597
+ function mergeAgentDeliveryPolicy(current, patch) {
29598
+ const merged = { ...current };
29599
+ for (const step of DELIVERY_STEPS) {
29600
+ if (!(step in patch)) continue;
29601
+ const value = patch[step];
29602
+ if (value === null) {
29603
+ delete merged[step];
29604
+ } else if (value === true || value === false) {
29605
+ merged[step] = value;
29606
+ }
29607
+ }
29608
+ return merged;
29609
+ }
29585
29610
 
29586
29611
  // ../../libs/harmonica-services/src/mcp/tools/revision-lifecycle-tools.ts
29587
29612
  async function checkDeliveryStep(client, revisionId, step) {
@@ -30685,7 +30710,7 @@ function formatImportSummary(result, targetTeamspaceId) {
30685
30710
  lines.push("", `Errors (${result.errors.length}):`);
30686
30711
  result.errors.forEach((e) => lines.push(` - ${e}`));
30687
30712
  }
30688
- const hasTeamspaceData = result.projectTeamspaceId !== void 0 || (result.counts.drops ?? 0) + (result.counts.deliverables ?? 0) > 0;
30713
+ const hasTeamspaceData = result.systemTeamspaceId !== void 0 || (result.counts.drops ?? 0) + (result.counts.deliverables ?? 0) > 0;
30689
30714
  if (!targetTeamspaceId && hasTeamspaceData) {
30690
30715
  lines.push(
30691
30716
  "",
@@ -30959,8 +30984,14 @@ function registerSystemTools(server, ctx, client) {
30959
30984
  if (Object.keys(nonEmpty).length === 0) {
30960
30985
  return { content: [{ type: "text", text: "No updates provided." }], isError: true };
30961
30986
  }
30962
- await assertSystemInOrg(client, systemId, ctx.orgId);
30987
+ const currentSystem = await fetchSystemInOrg(client, systemId, ctx.orgId);
30963
30988
  if (nonEmpty["accountId"] === "") delete nonEmpty["accountId"];
30989
+ if (nonEmpty["agentDeliveryPolicy"] && typeof nonEmpty["agentDeliveryPolicy"] === "object") {
30990
+ nonEmpty["agentDeliveryPolicy"] = mergeAgentDeliveryPolicy(
30991
+ currentSystem.agentDeliveryPolicy,
30992
+ nonEmpty["agentDeliveryPolicy"]
30993
+ );
30994
+ }
30964
30995
  if (typeof updates.teamspaceId === "string") {
30965
30996
  const teamspace = await client.getTeamspace(updates.teamspaceId);
30966
30997
  if (!teamspace) {
@@ -33160,9 +33191,8 @@ function createHttpClient(config2) {
33160
33191
  return result?.note ?? result;
33161
33192
  },
33162
33193
  createNote: async (input) => {
33163
- const inputRec = input;
33164
- const effectiveSystemId = inputRec.systemId ?? input.projectId;
33165
- if (!effectiveSystemId) throw new Error("createNote: systemId (or legacy projectId) is required");
33194
+ const effectiveSystemId = input.systemId;
33195
+ if (!effectiveSystemId) throw new Error("createNote: systemId is required");
33166
33196
  const result = await request("POST", `/api/systems/${encodeURIComponent(effectiveSystemId)}/notes`, input);
33167
33197
  return result?.note ?? result;
33168
33198
  },
@@ -34994,7 +35024,7 @@ function loadConfig() {
34994
35024
  };
34995
35025
  }
34996
35026
  async function main() {
34997
- console.error(`[harmonica-mcp] v${"4.0.2"} starting\u2026`);
35027
+ console.error(`[harmonica-mcp] v${"4.1.0"} starting\u2026`);
34998
35028
  const config2 = loadConfig();
34999
35029
  const client = createHttpClient({
35000
35030
  apiBaseUrl: config2.apiBaseUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codazen/harmonica-mcp",
3
- "version": "4.0.2",
3
+ "version": "4.1.0",
4
4
  "description": "MCP server for Harmonica — connect any MCP-compatible AI assistant to Harmonica",
5
5
  "license": "MIT",
6
6
  "bin": {