feat(cli): affitor onboard — composed detect → wire → verify (G6, #9)#18
Merged
Conversation
The capstone verb that ties the agent loop into one command, so the
Echoly-class stack (Fastify+Stripe) can be 1-shot. `affitor onboard`:
detect stack + payment provider
→ install @affitor/sdk + inject browser tracker (reuses init wizard)
→ locate the Stripe webhook (webhook-detect) + pull the canonical
recipe (@affitor/recipes) → inject affitor.trackSale + its import
into the handler (DIFF PREVIEW + confirm; idempotent)
→ write AFFITOR_API_KEY (never overwrites)
→ VERIFY LOOP: fire the synthetic chain + poll readiness until
integration_verified, print the blocking gate's next_action.
SAFETY: never edits payment code silently. The webhook transform
(injectStripeTrackSale) is conservative — it injects only when it finds
constructEvent + exactly one checkout.session.completed + a clean
`session` binding, and adds the `import { affitor }` so the result
compiles; anything ambiguous returns `unrecognized` → the exact patch is
PRINTED, never forced. Checkout-metadata is always printed (never
auto-edited). --json/--yes for agents (no prompts; --json never
auto-edits). 429 on the chain backs off (capped).
api-client gains getReadiness() + runVerificationChain() (429 no-throw).
init/wizard byte-stable. Build clean, suite 77/77.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The capstone of the agent-onboarding build (#1/#5/#6/#7/#8 already merged). One verb so the Echoly-class stack (Fastify + Stripe-webhook) can be 1-shot. Design ref:
SPEC-PAYMENT-TRACKING-AGENT-GUIDANCE.md.affitor onboarddetect stack + payment provider → install
@affitor/sdk+ inject browser tracker (reuses theinitwizard) → locate the Stripe webhook (webhook-detect) + pull the canonical recipe (@affitor/recipes) → injectaffitor.trackSale+ its import into the handler → writeAFFITOR_API_KEY→ verify loop (fire the synthetic chain + poll readiness untilintegration_verified, print the blocking gate'snext_action).Safety rails (this edits payment code)
injectStripeTrackSaleis conservative: injects only when it findsconstructEvent+ exactly onecheckout.session.completed+ a cleansessionbinding, and adds theimport { affitor }so the file compiles. Anything ambiguous →unrecognized→ the exact patch is PRINTED, never forced. Idempotent (re-run =already, no duplication — smoke-tested on the built dist)..envkey appended only if absent; a different existing value is never overwritten.--json/--yesfor agents (no prompts;--jsonnever auto-edits — reportsmanualso the agent drives the edit).retry_after_seconds, capped.api-clientgainsgetReadiness()+runVerificationChain()(429 no-throw, mirrors the MCP helper).init/wizardbyte-stable.npm run buildclean; full suite 77/77.🤖 Generated with Claude Code