{"uid":"cap_yOlPtj6AG_PVjXTHe-bng","slug":"oss-openrewrite-java-package-relocation-444e859a","name":"OSS OpenRewrite Java Package Relocation","description":"Relocates a Java package across a bounded set of source files using OpenRewrite, which works on a type-attributed syntax tree rather than on text. That is the difference that matters: a textual search and replace hits strings, comments and same-named symbols from other packages, while this changes only what actually refers to the package. Both the before and after state are compiled and the result is reported, so a refactoring that breaks the build says so instead of being handed over as done.","url":"https://agent.halowerk.com/v1/oss-openrewrite-java-package-relocation?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"files":{"type":"array","items":{"type":"object","required":["path","content"],"properties":{"path":{"type":"string","pattern":"^src/(?:[A-Za-z_][A-Za-z0-9_]*/)*(?:[A-Za-z_][A-Za-z0-9_]*|package-info)\\.java$","maxLength":256},"content":{"type":"string","maxLength":16384,"minLength":1}},"additionalProperties":false},"maxItems":32,"minItems":1},"recursive":{"type":"boolean"},"new_package":{"type":"string","pattern":"^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*$","maxLength":128},"old_package":{"type":"string","pattern":"^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*$","maxLength":128}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.004","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.004/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_ywRxybWEVHkbfd7nUbeG3","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.004","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Relocates a Java package across up to 32 source files using OpenRewrite's type-attributed syntax tree, reporting build validity before and after the change.","exampleAgentPrompt":"Rename the Java package from com.example.legacy to com.example.modern across these source files — use OpenRewrite so only real package references change, not strings or comments, and tell me if the result still compiles.","exampleUseCases":[{"title":"Library namespace migration","prompt":"I'm migrating my library from com.acme.oldlib to io.acme.newlib — can you run the package relocation across these 15 Java files and confirm the build still passes after?"},{"title":"Monorepo module restructure","prompt":"We're restructuring our monorepo and need to move everything under org.internal.util to org.platform.shared.util — apply the rename across all the source files I'm sending and report any build breakage."},{"title":"Open-source fork rebranding","prompt":"I forked a project and need to rebrand the root package from com.original.project to com.myfork.project in these Java files — please do it with proper AST-based renaming so comments and unrelated symbols aren't touched."}],"resultDescription":"Returns the transformed Java source files with all references to the old package updated to the new package name, along with a compilation report indicating whether the code built successfully before and after the relocation.","failureModes":["Build failure reported if renamed code does not compile","Invalid package name pattern returns validation error","Source file path not matching expected src/ Java path pattern is rejected","File content exceeding 16384 characters is refused","More than 32 files submitted triggers a limit error","Old and new package names identical may produce a no-op result"],"whenToPreferThis":"Prefer this endpoint over text-based search-and-replace tools whenever you need semantically correct Java package renaming — it operates on a type-attributed syntax tree so only genuine package references are changed, leaving string literals, comments, and identically named symbols from other packages untouched. It also validates compilation before and after, so you know immediately if the refactoring is safe.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T00:33:33.816Z","isFirstParty":false,"canonicalSlug":"oss-openrewrite-java-package-relocation-444e859a"}