2.8 KiB
Sticker Refactor Implementation Plan
For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Move EXIF generation and WebP conversion helpers out of sticker.go into helper packages.
Architecture:
- Create
helper/exif.gohandling exif metadata extraction. - Create
helper/media_convert.goabstracting commands likecwebpandffmpegwrappers to convert byte slices to webp. - Simplify
cmds/media/sticker.goto depend on these new exports.
Tech Stack: Go, exec, Neo Context, waProto
Global Constraints
- Only use standard library inside
helper/where possible (no whatsapp dependencies except general bytes handling). - The behavior of the
/Users/fd/Documents/perf/cmds/media/sticker.gocommand should remain functionally identical.
Task 1: Migrate Exif Support to Helper
Files:
- Create:
/Users/fd/Documents/perf/helper/exif.go - Modify:
/Users/fd/Documents/perf/cmds/media/sticker.go
Interfaces:
-
Produces:
helper.CreateDynamicExif(args []string) (exifPath string, cleanup bool) -
Step 1: Write
exif.goExtractexifData,webpExif,getOrCreateDefaultExif, andresolveExifintohelper/exif.go. MakeresolveExifexported asResolveExif. Ensure it uses the existing env logic. Keepuuiddependency. -
Step 2: Update
sticker.goEXIF usage Remove the exif functions/structs fromsticker.goand updateSticker.Runto callhelper.ResolveExif(ctx.Arguments()). -
Step 3: Commit
Task 2: Abstract Conversion Functions
Files:
- Create:
/Users/fd/Documents/perf/helper/media_convert.go - Modify:
/Users/fd/Documents/perf/cmds/media/sticker.go
Interfaces:
-
Produces:
ConvertImageToSticker(imgData []byte, exifPath string) ([]byte, error)ConvertVideoToSticker(vidData []byte, exifPath string) ([]byte, error)RewriteStickerExif(webpData []byte, exifPath string) ([]byte, error) -
Step 1: Create
media_convert.goImplement the three conversion functions. Each should take bytes (downloaded media) and anexifPath, do the conversion viaexec.Command, inject exif viawebpmux, clean up its own internal temp files, and return the final[]byteof the webp ready to send. (They don't need Whatsapp Context). -
Step 2: Update
sticker.gomedia usage RemovecmdStickerImage,cmdStickerVideo, andcmdStickerRewritefromsticker.go. Instead, inSticker.Run, download the bytes directly usingctx.Client().Download(...), then pass those bytes to thehelper.ConvertXfunctions, andctx.SendSticker()the returned bytes. -
Step 3: Test build Run
go build ./... -
Step 4: Commit
git commit -m "refactor: extract media conversion logic to helper"