Skip to content

fix: testing poc for autofix of summaries opportunity - #3197

Open
nishant803 wants to merge 26 commits into
mainfrom
autofix-poc
Open

fix: testing poc for autofix of summaries opportunity#3197
nishant803 wants to merge 26 commits into
mainfrom
autofix-poc

Conversation

@nishant803

Copy link
Copy Markdown

Title: feat: apply Summarization suggestions directly to AEM page content

Summary

  • Adds POST /sites/:siteId/opportunities/:opportunityId/suggestions/aem-apply, a new endpoint that writes a suggestion's content directly into an AEM CS page's own content tree — editing the human-facing page. This is distinct from the existing edge-deploy endpoint, which only ever writes a bot-targeted overlay at the Tokowaka CDN edge and never touches AEM itself.
  • For each suggestion: resolves data.url to an AEM pageId via the existing determineAEMCSPageId resolver (@adobe/spacecat-shared-utils, same one resolveDocumentPath already uses for other opportunity types), fetches the page's content tree + ETag, resolves transformRules.selector against it, and applies transformRules.action (insertAfter / insertBefore / appendChild / replace) as a JSON Patch.
  • Handles two shapes of transformRules: a direct target (selector names the existing node to act on — today's Summarization case) and an anchor + tag (selector names an existing anchor, tag names a new heading element to create relative to it — e.g. a "missing heading" fix), so the same endpoint isn't limited to one suggestion archetype.
  • Auth: forwards the caller's own bearer token to AEM, the same pattern the existing content-api-access autofix-check probe already uses against this API — no new credential/auth path introduced.
  • Scoped to aem_cs delivery-type sites only; returns a 400 otherwise.
  • Selector matching is intentionally narrow today (bare tag or tag#id, against title/heading components only) and fails closed — an unresolvable selector or unsupported action returns a per-suggestion 404/422 in the 207 response rather than guessing a placement.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.49505% with 602 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/controllers/suggestions.js 21.30% 532 Missing ⚠️
src/support/aem-content-mcp-client.js 43.54% 70 Missing ⚠️

📢 Thoughts on this report? Let us know!

# Conflicts:
#	src/controllers/suggestions.js
Nishant Agarwal and others added 2 commits September 7, 2026 19:37
…shared

get-aem-pages returns launch copies (/content/launches/...) alongside the live
page for the same publishPath, often first. limit:1 + items[0] could target a
launch. Fetch more and prefer the item whose authorPath is not under launches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant