Skip to content

feat(cli): affitor onboard — composed detect → wire → verify (G6, #9)#18

Merged
sonpiaz merged 1 commit into
mainfrom
feat/cli-onboard-inject
Jun 15, 2026
Merged

feat(cli): affitor onboard — composed detect → wire → verify (G6, #9)#18
sonpiaz merged 1 commit into
mainfrom
feat/cli-onboard-inject

Conversation

@sonpiaz

@sonpiaz sonpiaz commented Jun 15, 2026

Copy link
Copy Markdown
Member

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 onboard

detect stack + payment provider → install @affitor/sdk + inject browser tracker (reuses the init wizard) → locate the Stripe webhook (webhook-detect) + pull the canonical recipe (@affitor/recipes) → inject affitor.trackSale + its import into the handler → write AFFITOR_API_KEYverify loop (fire the synthetic chain + poll readiness until integration_verified, print the blocking gate's next_action).

Safety rails (this edits payment code)

  • Never silent. The webhook transform injectStripeTrackSale is conservative: injects only when it finds constructEvent + exactly one checkout.session.completed + a clean session binding, and adds the import { 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).
  • Checkout-metadata is always printed, never auto-edited (the create call can't be located reliably).
  • .env key appended only if absent; a different existing value is never overwritten.
  • --json / --yes for agents (no prompts; --json never auto-edits — reports manual so the agent drives the edit).
  • Chain 429 (10/program/hour) → backs off via retry_after_seconds, capped.

api-client gains getReadiness() + runVerificationChain() (429 no-throw, mirrors the MCP helper). init/wizard byte-stable. npm run build clean; full suite 77/77.

Remaining build items (separate): #3 isRecurring/event-split, #4 dedup unique-index backstop. After this, an agent can affitor onboard (or via MCP: get_integration_plan → apply → run_verification → readiness) and reach integration_verified on the Echoly stack.

🤖 Generated with Claude Code

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>
@sonpiaz sonpiaz merged commit 8cf83a3 into main Jun 15, 2026
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