@egbe-ai/opencode 0.0.0-stage → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +124 -2
- package/index.js +5 -0
- package/package.json +55 -4
- package/plugin.js +230 -0
- package/session-log.js +315 -0
- package/skills/.egbe-catalog/manifest.json +1 -0
- package/skills/egbe-os-analytics/SKILL.md +499 -0
- package/skills/egbe-os-analytics/canonical-events.v1.json +256 -0
- package/skills/egbe-os-analytics/references/session-funnel.md +130 -0
- package/skills/egbe-os-analytics/references/workflows/activation-tracking.md +147 -0
- package/skills/egbe-os-analytics/references/workflows/landing-click-tracking.md +209 -0
- package/skills/egbe-os-analytics/references/workflows/payment-lifecycle-tracking.md +122 -0
- package/skills/egbe-os-analytics/references/workflows/product-funnel-tracking.md +77 -0
- package/skills/egbe-os-analytics/references/workflows/signup-lifecycle-tracking.md +208 -0
- package/skills/egbe-os-analytics/scripts/umami_funnel.py +927 -0
- package/skills/egbe-os-apollo-lead-finder/SKILL.md +135 -0
- package/skills/egbe-os-apollo-lead-finder/references/operations.md +240 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/enrich.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/find-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/apollo-client.js +343 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/helpers.js +127 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/places-filters.js +217 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/lib/sourcing.js +153 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.js +653 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/places-leads.sh +4 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.js +6 -0
- package/skills/egbe-os-apollo-lead-finder/scripts/search.sh +4 -0
- package/skills/egbe-os-campaign-landing-page/SKILL.md +95 -0
- package/skills/egbe-os-campaign-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-campaign-landing-page/references/leads-calendar-and-tracking.md +66 -0
- package/skills/egbe-os-campaign-landing-page/references/os-wiring.md +58 -0
- package/skills/egbe-os-campaign-landing-page/references/qa.md +40 -0
- package/skills/egbe-os-campaign-landing-page/references/routing.md +32 -0
- package/skills/egbe-os-db/SKILL.md +174 -0
- package/skills/egbe-os-deploy/SKILL.md +412 -0
- package/skills/egbe-os-design/SKILL.md +182 -0
- package/skills/egbe-os-design-landing-page/SKILL.md +117 -0
- package/skills/egbe-os-design-landing-page/agents/openai.yaml +4 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/.dockerignore +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/AGENTS.md +31 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/Dockerfile +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/eslint.config.mjs +18 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/next.config.ts +11 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/package.json +36 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/postcss.config.mjs +7 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/public/.gitkeep +1 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.edge.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/sentry.server.config.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/global-error.tsx +19 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/globals.css +22 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/layout.tsx +21 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/page.tsx +3 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/app/privacy/page.tsx +28 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/components/egbe-analytics.tsx +39 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation-client.ts +15 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/instrumentation.ts +13 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/egbe-observability.generated.ts +20 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/src/lib/utils.ts +6 -0
- package/skills/egbe-os-design-landing-page/assets/scaffold/tsconfig.json +34 -0
- package/skills/egbe-os-design-landing-page/references/application-preparation.md +44 -0
- package/skills/egbe-os-design-landing-page/references/page-inputs.md +22 -0
- package/skills/egbe-os-destination-readiness/SKILL.md +132 -0
- package/skills/egbe-os-destination-readiness/references/checks.md +130 -0
- package/skills/egbe-os-destination-readiness/references/network-requirements.md +34 -0
- package/skills/egbe-os-destination-readiness/references/report.md +116 -0
- package/skills/egbe-os-domains/SKILL.md +189 -0
- package/skills/egbe-os-errors/SKILL.md +259 -0
- package/skills/egbe-os-git/SKILL.md +275 -0
- package/skills/egbe-os-git/references/issues.md +33 -0
- package/skills/egbe-os-google-ads/SKILL.md +163 -0
- package/skills/egbe-os-google-ads/references/artifacts.md +133 -0
- package/skills/egbe-os-google-ads/references/campaigns.md +157 -0
- package/skills/egbe-os-google-ads/references/conversions.md +153 -0
- package/skills/egbe-os-google-ads/references/delivery.md +128 -0
- package/skills/egbe-os-google-ads/references/keyword-ideas.md +40 -0
- package/skills/egbe-os-google-ads/references/reporting.md +105 -0
- package/skills/egbe-os-google-ads/references/search-assets.md +219 -0
- package/skills/egbe-os-google-ads/references/server-conversions.md +119 -0
- package/skills/egbe-os-google-auth/SKILL.md +285 -0
- package/skills/egbe-os-google-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-gtm-knowledge/SKILL.md +151 -0
- package/skills/egbe-os-images/SKILL.md +163 -0
- package/skills/egbe-os-images/references/stock-images.md +21 -0
- package/skills/egbe-os-instantly-campaign-launcher/SKILL.md +127 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/instantly-ops.md +260 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/observation-and-scheduling.md +188 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/reply-handling.md +116 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-spec-template.json +65 -0
- package/skills/egbe-os-instantly-campaign-launcher/references/run-state.md +145 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/conclude-campaign.js +158 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/install-crons.js +956 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/launch-campaign.js +2008 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/campaign-metrics.js +124 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/confirmed-opt-outs.js +208 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/connection-identity.js +17 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/create-once.js +23 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/gtm-identity.js +125 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/helpers.js +545 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/html-body.js +266 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/instantly-client.js +328 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/outreach-db.js +370 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/recipient-exclusion/index.js +86 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/replenish-test-harness.js +53 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/reply-queue.js +67 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/run-config.js +103 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/lib/sender-selection.js +105 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/monitor-campaign.js +607 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/outreach-report.js +147 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/replenish-leads.js +619 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/reply-worker.js +258 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/run-cron-job.js +32 -0
- package/skills/egbe-os-instantly-campaign-launcher/scripts/send-reply.js +260 -0
- package/skills/egbe-os-linkedin-ads/SKILL.md +114 -0
- package/skills/egbe-os-linkedin-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/api-reference.md +154 -0
- package/skills/egbe-os-linkedin-ads/references/runtime/artifacts.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/build-paused.md +44 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/conversions.md +88 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/launch-and-pause.md +49 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/monitoring.md +35 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/readiness.md +63 -0
- package/skills/egbe-os-linkedin-ads/references/workflows/targeting-and-creative.md +52 -0
- package/skills/egbe-os-llm/SKILL.md +160 -0
- package/skills/egbe-os-mail/SKILL.md +180 -0
- package/skills/egbe-os-me/SKILL.md +119 -0
- package/skills/egbe-os-meta-ads/SKILL.md +114 -0
- package/skills/egbe-os-meta-ads/references/creative/creative-specs.md +15 -0
- package/skills/egbe-os-meta-ads/references/creative/talking-head.md +35 -0
- package/skills/egbe-os-meta-ads/references/destination-requirements.md +30 -0
- package/skills/egbe-os-meta-ads/references/runtime/api-reference.md +436 -0
- package/skills/egbe-os-meta-ads/references/runtime/artifacts.md +51 -0
- package/skills/egbe-os-meta-ads/references/runtime/insights-reference.md +187 -0
- package/skills/egbe-os-meta-ads/references/runtime/pixel-install.md +196 -0
- package/skills/egbe-os-meta-ads/references/runtime/shared-analytics-attribution.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/build-paused.md +36 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch-ready.md +16 -0
- package/skills/egbe-os-meta-ads/references/workflows/launch.md +23 -0
- package/skills/egbe-os-meta-ads/references/workflows/monitoring.md +72 -0
- package/skills/egbe-os-meta-ads/references/workflows/pause.md +17 -0
- package/skills/egbe-os-meta-ads/references/workflows/recovery.md +23 -0
- package/skills/egbe-os-meta-ads/scripts/check-pixel.py +229 -0
- package/skills/egbe-os-meta-ads/scripts/validate-meta-artifacts.py +187 -0
- package/skills/egbe-os-notifications/SKILL.md +78 -0
- package/skills/egbe-os-openai-ads/SKILL.md +149 -0
- package/skills/egbe-os-openai-ads/references/creative/chat-card.md +51 -0
- package/skills/egbe-os-openai-ads/references/destination-requirements.md +29 -0
- package/skills/egbe-os-openai-ads/references/runtime/api-reference.md +219 -0
- package/skills/egbe-os-openai-ads/references/runtime/artifacts.md +169 -0
- package/skills/egbe-os-openai-ads/references/workflows/build-paused.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/conversions.md +40 -0
- package/skills/egbe-os-openai-ads/references/workflows/creative-assembly.md +24 -0
- package/skills/egbe-os-openai-ads/references/workflows/launch.md +27 -0
- package/skills/egbe-os-openai-ads/references/workflows/monitoring.md +54 -0
- package/skills/egbe-os-openai-ads/references/workflows/pause.md +22 -0
- package/skills/egbe-os-openai-ads/references/workflows/readiness.md +37 -0
- package/skills/egbe-os-openai-ads/references/workflows/tracking.md +32 -0
- package/skills/egbe-os-openai-ads/scripts/validate-openai-artifacts.py +271 -0
- package/skills/egbe-os-organic-trend-watch/SKILL.md +139 -0
- package/skills/egbe-os-organic-trend-watch/agents/openai.yaml +4 -0
- package/skills/egbe-os-organic-trend-watch/references/analysis-and-adaptation.md +54 -0
- package/skills/egbe-os-organic-trend-watch/references/collection-and-analysis.md +117 -0
- package/skills/egbe-os-organic-trend-watch/references/output-contract.md +133 -0
- package/skills/egbe-os-organic-trend-watch/references/provider-contract.md +169 -0
- package/skills/egbe-os-organic-trend-watch/references/runtime-contract.md +204 -0
- package/skills/egbe-os-organic-trend-watch/references/visual-analysis-prompt.md +17 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_analysis.py +612 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_contract.py +1133 -0
- package/skills/egbe-os-organic-trend-watch/scripts/_provider_inputs.py +165 -0
- package/skills/egbe-os-organic-trend-watch/scripts/analyze-visual-evidence.py +315 -0
- package/skills/egbe-os-organic-trend-watch/scripts/build-provider-inputs.py +88 -0
- package/skills/egbe-os-organic-trend-watch/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-organic-trend-watch/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-organic-trend-watch/scripts/finalize-receipt.py +106 -0
- package/skills/egbe-os-organic-trend-watch/scripts/normalize-videos.py +647 -0
- package/skills/egbe-os-organic-trend-watch/scripts/prepare-visual-evidence.py +324 -0
- package/skills/egbe-os-organic-trend-watch/scripts/render-result.py +30 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-apify.py +723 -0
- package/skills/egbe-os-organic-trend-watch/scripts/run-state.py +192 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-context.py +27 -0
- package/skills/egbe-os-organic-trend-watch/scripts/validate-runtime.py +137 -0
- package/skills/egbe-os-payments/SKILL.md +215 -0
- package/skills/egbe-os-payments/agents/openai.yaml +4 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/.egbe/scaffolds/billing-nextjs-subscription.v1.json +5 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/AGENTS.append.md +13 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/db/migrations/1000_egbe_billing.sql +66 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/package.fragment.json +12 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/scripts/billing-sync.mjs +162 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/error.tsx +11 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/loading.tsx +8 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/account/billing/page.tsx +121 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/checkout/route.ts +102 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/portal/route.ts +54 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/billing/status/route.ts +22 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/app/api/payments/webhook/route.ts +65 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/components/egbe-billing/plan-badge.tsx +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/billing-sync.test.mjs +58 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/catalog.ts +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/checkout-payload.ts +47 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/foundation-contract.test.mjs +59 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.d.ts +16 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.mjs +82 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/lifecycle.test.mjs +94 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/os-client.ts +96 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/plans.json +17 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/repository.ts +325 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.d.ts +6 -0
- package/skills/egbe-os-payments/assets/scaffolds/billing-nextjs-subscription/src/lib/egbe-billing/signature.mjs +22 -0
- package/skills/egbe-os-payments/references/contracts/plan-catalog.md +46 -0
- package/skills/egbe-os-payments/references/security/durable-verification.md +64 -0
- package/skills/egbe-os-payments/references/security/server-integration.md +26 -0
- package/skills/egbe-os-payments/references/security/webhook-and-entitlements.md +152 -0
- package/skills/egbe-os-payments/references/ux/billing-experience.md +47 -0
- package/skills/egbe-os-payments/references/workflows/account-billing.md +64 -0
- package/skills/egbe-os-payments/references/workflows/discounts-and-promotion-codes.md +265 -0
- package/skills/egbe-os-payments/references/workflows/one-time-purchase.md +75 -0
- package/skills/egbe-os-payments/references/workflows/product-checkout.md +355 -0
- package/skills/egbe-os-payments/references/workflows/subscription-lifecycle.md +55 -0
- package/skills/egbe-os-playbook/SKILL.md +79 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/email-outreach.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/google-search.md +40 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/linkedin.md +24 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/meta.md +23 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/openai.md +15 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/channels/reddit.md +56 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/choose-test.md +73 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/evaluate.md +91 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/market.md +96 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition/run-test.md +111 -0
- package/skills/egbe-os-playbook/playbooks/market-and-acquisition.md +56 -0
- package/skills/egbe-os-playbook/playbooks/product/business-loop.md +141 -0
- package/skills/egbe-os-playbook/playbooks/product/collaboration.md +26 -0
- package/skills/egbe-os-playbook/playbooks/product/deliver.md +75 -0
- package/skills/egbe-os-playbook/playbooks/product/diagnose.md +80 -0
- package/skills/egbe-os-playbook/playbooks/product/evaluate.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/experience.md +132 -0
- package/skills/egbe-os-playbook/playbooks/product/loop-examples.md +67 -0
- package/skills/egbe-os-playbook/playbooks/product/offer.md +65 -0
- package/skills/egbe-os-playbook/playbooks/product/value.md +91 -0
- package/skills/egbe-os-playbook/playbooks/product.md +67 -0
- package/skills/egbe-os-playbook/references/catalog.md +127 -0
- package/skills/egbe-os-playbook/references/changes.md +167 -0
- package/skills/egbe-os-playbook/scripts/playbook-changes.py +6 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/__init__.py +1 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/cli.py +57 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/operations.py +137 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/protocol.py +132 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/storage.py +180 -0
- package/skills/egbe-os-playbook/scripts/playbook_changes/transport.py +113 -0
- package/skills/egbe-os-product-auth/SKILL.md +151 -0
- package/skills/egbe-os-product-auth/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-auth/assets/db/README.md +102 -0
- package/skills/egbe-os-product-auth/assets/db/create-validation-session.mjs +223 -0
- package/skills/egbe-os-product-auth/assets/db/migrate.mjs +64 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0001_auth.sql +33 -0
- package/skills/egbe-os-product-auth/assets/db/migrations/0002_auth_identities.sql +16 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/AGENTS.append.md +17 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-auth-database/package.fragment.json +10 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/AGENTS.append.md +9 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/package.fragment.json +13 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/db.ts +31 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/identity.ts +94 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/index.ts +3 -0
- package/skills/egbe-os-product-auth/assets/scaffolds/product-nextjs-postgres/src/lib/egbe-product/session.ts +91 -0
- package/skills/egbe-os-product-auth/references/contracts/live-auth-interface.md +108 -0
- package/skills/egbe-os-product-auth/references/frameworks/nextjs.md +34 -0
- package/skills/egbe-os-product-auth/references/security/session-and-credentials.md +73 -0
- package/skills/egbe-os-product-auth/references/ux/auth-experience.md +58 -0
- package/skills/egbe-os-product-auth/references/workflows/account-recovery.md +22 -0
- package/skills/egbe-os-product-auth/references/workflows/build-auth.md +212 -0
- package/skills/egbe-os-product-auth/references/workflows/google.md +34 -0
- package/skills/egbe-os-product-auth/references/workflows/passwordless-email.md +65 -0
- package/skills/egbe-os-product-build/SKILL.md +111 -0
- package/skills/egbe-os-product-build/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-build/references/capabilities.md +25 -0
- package/skills/egbe-os-product-build/references/engineering.md +72 -0
- package/skills/egbe-os-product-build/references/execution.md +55 -0
- package/skills/egbe-os-product-build/references/foundations.md +93 -0
- package/skills/egbe-os-product-build/references/interface-quality.md +32 -0
- package/skills/egbe-os-product-build/references/workflows/private-review-handoff.md +86 -0
- package/skills/egbe-os-product-build/scripts/scaffold.py +296 -0
- package/skills/egbe-os-product-demo-video/SKILL.md +118 -0
- package/skills/egbe-os-product-demo-video/references/recording.md +32 -0
- package/skills/egbe-os-product-market-research/SKILL.md +159 -0
- package/skills/egbe-os-product-market-research/agents/openai.yaml +4 -0
- package/skills/egbe-os-product-market-research/references/catalog.v1.json +177 -0
- package/skills/egbe-os-product-market-research/references/config/channel-footprint-sources.v1.json +99 -0
- package/skills/egbe-os-product-market-research/references/config/creative-taxonomy.v1.json +367 -0
- package/skills/egbe-os-product-market-research/references/contracts/creative-video.md +75 -0
- package/skills/egbe-os-product-market-research/references/contracts/funnel-teardown.md +235 -0
- package/skills/egbe-os-product-market-research/references/contracts/geography-comparison.md +71 -0
- package/skills/egbe-os-product-market-research/references/contracts/lifecycle-capture.md +119 -0
- package/skills/egbe-os-product-market-research/references/contracts/research-artifacts.md +520 -0
- package/skills/egbe-os-product-market-research/references/contracts/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.md +137 -0
- package/skills/egbe-os-product-market-research/references/prompts/acquisition-channels.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.md +118 -0
- package/skills/egbe-os-product-market-research/references/prompts/competitive-landscape.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.md +154 -0
- package/skills/egbe-os-product-market-research/references/prompts/demand-validation.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.md +100 -0
- package/skills/egbe-os-product-market-research/references/prompts/market-size-and-dynamics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.md +126 -0
- package/skills/egbe-os-product-market-research/references/prompts/pricing-and-monetization.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.md +98 -0
- package/skills/egbe-os-product-market-research/references/prompts/target-audience.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.md +217 -0
- package/skills/egbe-os-product-market-research/references/prompts/unit-economics.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.md +113 -0
- package/skills/egbe-os-product-market-research/references/prompts/value-proposition.user.md +4 -0
- package/skills/egbe-os-product-market-research/references/workflows/acquisition-channels.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/channel-footprint.md +163 -0
- package/skills/egbe-os-product-market-research/references/workflows/community-demand.md +100 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitive-landscape.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-ads.md +82 -0
- package/skills/egbe-os-product-market-research/references/workflows/competitor-set.md +300 -0
- package/skills/egbe-os-product-market-research/references/workflows/creative-patterns.md +228 -0
- package/skills/egbe-os-product-market-research/references/workflows/demand-validation.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/fleet-prior.md +80 -0
- package/skills/egbe-os-product-market-research/references/workflows/funnel-teardown.md +184 -0
- package/skills/egbe-os-product-market-research/references/workflows/geography-comparison.md +84 -0
- package/skills/egbe-os-product-market-research/references/workflows/keyword-economics.md +122 -0
- package/skills/egbe-os-product-market-research/references/workflows/lifecycle-capture.md +218 -0
- package/skills/egbe-os-product-market-research/references/workflows/local-research.md +55 -0
- package/skills/egbe-os-product-market-research/references/workflows/market-size-and-dynamics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/preview.md +175 -0
- package/skills/egbe-os-product-market-research/references/workflows/pricing-and-monetization.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/recommendations.md +35 -0
- package/skills/egbe-os-product-market-research/references/workflows/review-mining.md +76 -0
- package/skills/egbe-os-product-market-research/references/workflows/target-audience.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/tiktok-reels-market-trends.md +46 -0
- package/skills/egbe-os-product-market-research/references/workflows/unit-economics.md +27 -0
- package/skills/egbe-os-product-market-research/references/workflows/value-proposition.md +27 -0
- package/skills/egbe-os-product-market-research/scripts/build-organic-trend-context.py +167 -0
- package/skills/egbe-os-product-market-research/scripts/build-preview-context.py +91 -0
- package/skills/egbe-os-product-market-research/scripts/build-research-query.py +225 -0
- package/skills/egbe-os-product-market-research/scripts/channel-footprint-model.py +294 -0
- package/skills/egbe-os-product-market-research/scripts/connection_identity.py +22 -0
- package/skills/egbe-os-product-market-research/scripts/creative-model.py +364 -0
- package/skills/egbe-os-product-market-research/scripts/creative-selection.py +113 -0
- package/skills/egbe-os-product-market-research/scripts/creative-semantics.py +365 -0
- package/skills/egbe-os-product-market-research/scripts/creative-video.py +542 -0
- package/skills/egbe-os-product-market-research/scripts/egbe_artifacts.py +24 -0
- package/skills/egbe-os-product-market-research/scripts/finalize-organic-trend-watch.py +304 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-email-review.py +97 -0
- package/skills/egbe-os-product-market-research/scripts/funnel-model.py +966 -0
- package/skills/egbe-os-product-market-research/scripts/funnel_features.py +50 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison-contract.py +172 -0
- package/skills/egbe-os-product-market-research/scripts/geography-comparison.py +169 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-forecast.py +61 -0
- package/skills/egbe-os-product-market-research/scripts/keyword-locale-publication.py +136 -0
- package/skills/egbe-os-product-market-research/scripts/lifecycle-start.py +190 -0
- package/skills/egbe-os-product-market-research/scripts/persist-research-report.py +63 -0
- package/skills/egbe-os-product-market-research/scripts/research-artifact-io.py +281 -0
- package/skills/egbe-os-product-market-research/scripts/research-evidence.py +496 -0
- package/skills/egbe-os-product-market-research/scripts/research-policy.py +33 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-runtime.py +343 -0
- package/skills/egbe-os-product-market-research/scripts/research-section-workflow.py +288 -0
- package/skills/egbe-os-product-market-research/scripts/research_integrity.py +122 -0
- package/skills/egbe-os-product-market-research/scripts/review-research-completion.py +306 -0
- package/skills/egbe-os-product-market-research/scripts/run-acquisition-channels.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-channel-footprint.py +2258 -0
- package/skills/egbe-os-product-market-research/scripts/run-community-demand.py +1603 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitive-landscape.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-ads.py +1156 -0
- package/skills/egbe-os-product-market-research/scripts/run-competitor-set.py +2514 -0
- package/skills/egbe-os-product-market-research/scripts/run-creative-patterns.py +2042 -0
- package/skills/egbe-os-product-market-research/scripts/run-demand-validation.py +72 -0
- package/skills/egbe-os-product-market-research/scripts/run-fleet-prior.py +652 -0
- package/skills/egbe-os-product-market-research/scripts/run-funnel-teardown.py +493 -0
- package/skills/egbe-os-product-market-research/scripts/run-keyword-economics.py +1443 -0
- package/skills/egbe-os-product-market-research/scripts/run-lifecycle-capture.py +1543 -0
- package/skills/egbe-os-product-market-research/scripts/run-market-size-and-dynamics.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-os-research.py +311 -0
- package/skills/egbe-os-product-market-research/scripts/run-pricing-and-monetization.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-review-mining.py +1051 -0
- package/skills/egbe-os-product-market-research/scripts/run-target-audience.py +66 -0
- package/skills/egbe-os-product-market-research/scripts/run-unit-economics.py +71 -0
- package/skills/egbe-os-product-market-research/scripts/run-value-proposition.py +67 -0
- package/skills/egbe-os-product-market-research/scripts/upsert-markdown-section.py +156 -0
- package/skills/egbe-os-product-market-research/scripts/walk-funnels.py +249 -0
- package/skills/egbe-os-product-market-research/scripts/write-preview.py +710 -0
- package/skills/egbe-os-product-market-research/scripts/write-recommendations.py +272 -0
- package/skills/egbe-os-product-report/SKILL.md +150 -0
- package/skills/egbe-os-product-report/references/artifacts.md +84 -0
- package/skills/egbe-os-product-report/references/brief.md +34 -0
- package/skills/egbe-os-product-report/references/daily.md +76 -0
- package/skills/egbe-os-product-report/references/sources.md +68 -0
- package/skills/egbe-os-product-routines/SKILL.md +166 -0
- package/skills/egbe-os-product-routines/references/catalog.md +22 -0
- package/skills/egbe-os-product-routines/references/continuation-check.md +41 -0
- package/skills/egbe-os-product-routines/references/product-reporting.md +163 -0
- package/skills/egbe-os-product-routines/references/run-preset.md +32 -0
- package/skills/egbe-os-quickstart/scripts/egbe-curl.py +357 -0
- package/skills/egbe-os-quiz-funnel/SKILL.md +152 -0
- package/skills/egbe-os-quiz-funnel/agents/openai.yaml +4 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.d.mts +224 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.mjs +652 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-engine.test.mjs +764 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.d.mts +31 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.mjs +87 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-history.test.mjs +265 -0
- package/skills/egbe-os-quiz-funnel/assets/engine/quiz-reference.test.mjs +254 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/QUIZ.md +195 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.json +421 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/quiz.public.json +369 -0
- package/skills/egbe-os-quiz-funnel/assets/examples/egbe-docs/product/quizzes/books-checkup/validation.json +21 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/index.html +26 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-bootstrap.js +31 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-early-actions.mjs +11 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-first-screen.mjs +32 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz-page.mjs +480 -0
- package/skills/egbe-os-quiz-funnel/assets/reference/quiz.css +264 -0
- package/skills/egbe-os-quiz-funnel/references/competitor-teardown.md +159 -0
- package/skills/egbe-os-quiz-funnel/references/conversion-handoff.md +156 -0
- package/skills/egbe-os-quiz-funnel/references/implementation.md +207 -0
- package/skills/egbe-os-quiz-funnel/references/inputs.md +37 -0
- package/skills/egbe-os-quiz-funnel/references/measurement.md +122 -0
- package/skills/egbe-os-quiz-funnel/references/spec-contract.md +335 -0
- package/skills/egbe-os-quiz-funnel/references/verification.md +101 -0
- package/skills/egbe-os-quiz-funnel/references/walk-mechanics.v2.json +18 -0
- package/skills/egbe-os-quiz-funnel/scripts/compile-quiz-spec.py +1869 -0
- package/skills/egbe-os-quiz-funnel/scripts/prepare-research-identity.py +66 -0
- package/skills/egbe-os-reddit-ads/SKILL.md +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/schema.json +41 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/bold-statement/template.html +106 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/schema.json +61 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/data-proof/template.html +151 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/schema.json +91 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/honest-breakdown/template.html +185 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/schema.json +51 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/question-hook/template.html +121 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/schema.json +87 -0
- package/skills/egbe-os-reddit-ads/assets/static-banners/reddit-post-style/template.html +212 -0
- package/skills/egbe-os-reddit-ads/references/creative/html-to-png-pipeline.md +123 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-qa.md +12 -0
- package/skills/egbe-os-reddit-ads/references/creative/static-banner-system.md +16 -0
- package/skills/egbe-os-reddit-ads/references/destination-requirements.md +36 -0
- package/skills/egbe-os-reddit-ads/references/runtime/api-reference.md +435 -0
- package/skills/egbe-os-reddit-ads/references/runtime/artifacts.md +57 -0
- package/skills/egbe-os-reddit-ads/references/runtime/monitoring.md +64 -0
- package/skills/egbe-os-reddit-ads/references/runtime/pixel-and-tracking.md +49 -0
- package/skills/egbe-os-reddit-ads/references/runtime/policies.md +19 -0
- package/skills/egbe-os-reddit-ads/references/runtime/shared-analytics-attribution.md +14 -0
- package/skills/egbe-os-reddit-ads/references/workflows/build-paused.md +35 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch-ready.md +19 -0
- package/skills/egbe-os-reddit-ads/references/workflows/launch.md +32 -0
- package/skills/egbe-os-reddit-ads/references/workflows/readiness.md +9 -0
- package/skills/egbe-os-reddit-ads/scripts/capture-ad.sh +178 -0
- package/skills/egbe-os-reddit-ads/scripts/validate-reddit-artifacts.py +187 -0
- package/skills/egbe-os-report-ui/SKILL.md +133 -0
- package/skills/egbe-os-report-ui/assets/egbe-wordmark.svg +9 -0
- package/skills/egbe-os-report-ui/assets/examples/components.html +417 -0
- package/skills/egbe-os-report-ui/assets/examples/editorial.html +209 -0
- package/skills/egbe-os-report-ui/assets/scaffold.html +179 -0
- package/skills/egbe-os-report-ui/references/components.md +209 -0
- package/skills/egbe-os-research/SKILL.md +125 -0
- package/skills/egbe-os-saas-unit-economics/SKILL.md +188 -0
- package/skills/egbe-os-scrape/SKILL.md +160 -0
- package/skills/egbe-os-search/SKILL.md +182 -0
- package/skills/egbe-os-search/references/google-places.md +81 -0
- package/skills/egbe-os-support/SKILL.md +149 -0
- package/skills/egbe-os-telemetry/SKILL.md +344 -0
- package/skills/egbe-os-telemetry/references/harnesses/claude-code.md +97 -0
- package/skills/egbe-os-telemetry/references/harnesses/codex.md +22 -0
- package/skills/egbe-os-telemetry/references/harnesses/hermes.md +39 -0
- package/skills/egbe-os-telemetry/references/harnesses/openclaw.md +139 -0
- package/skills/egbe-os-telemetry/references/harnesses/opencode.md +28 -0
- package/skills/egbe-os-tools/SKILL.md +180 -0
- package/skills/egbe-os-tools/references/theona.md +26 -0
- package/skills/egbe-os-wallet/SKILL.md +181 -0
- package/skills/egbe-setup/EGBE.md +484 -0
- package/skills/egbe-setup/SKILL.md +116 -0
- package/skills/egbe-setup/references/project.md +80 -0
- package/state.js +37 -0
- package/update.js +361 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Portable browser-observation projection shared by producers and consumers.
|
|
2
|
+
|
|
3
|
+
Ship byte-identical copies inside each skill. Missing optional observations
|
|
4
|
+
remain unknown even on a complete path; explicit absence is a different fact.
|
|
5
|
+
No network, repository imports or independent proof policy are used here.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FunnelFeaturesError(ValueError):
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def observation_features(walk: dict) -> dict:
|
|
15
|
+
screens = [s for s in walk.get("screens", []) if s.get("branch_role") == "main"]
|
|
16
|
+
if not screens:
|
|
17
|
+
raise FunnelFeaturesError("funnel proof needs at least one observed main-path screen")
|
|
18
|
+
partial = walk.get("partial")
|
|
19
|
+
if type(partial) is not bool:
|
|
20
|
+
raise FunnelFeaturesError("funnel path must explicitly declare partial")
|
|
21
|
+
kinds = [str(s.get("kind", "")).split(":", 1)[0] for s in screens]
|
|
22
|
+
positions = {
|
|
23
|
+
"contact_at": next((i + 1 for i, k in enumerate(kinds) if k == "contact request"), None),
|
|
24
|
+
"teaser_at": next((i + 1 for i, s in enumerate(screens) if s.get("result_type") == "teaser"), None),
|
|
25
|
+
"result_at": next((i + 1 for i, s in enumerate(screens) if s.get("result_type") == "final"), None),
|
|
26
|
+
"price_at": next((i + 1 for i, s in enumerate(screens) if any(a.get("kind") == "price" for a in s.get("amounts", []))), None),
|
|
27
|
+
"offer_at": next((i + 1 for i, s in enumerate(screens) if s.get("offer")), None),
|
|
28
|
+
}
|
|
29
|
+
result, contact = positions["result_at"], positions["contact_at"]
|
|
30
|
+
relation = result < contact if result is not None and contact is not None else None
|
|
31
|
+
present = lambda condition: True if condition else None if partial else False
|
|
32
|
+
types = {"quiz": "question" in kinds,
|
|
33
|
+
"landing_with_form": "landing" in kinds and "contact request" in kinds,
|
|
34
|
+
"webinar_registration": any(s.get("conversion_kind") == "webinar_registration" for s in screens),
|
|
35
|
+
"trial": any(s.get("conversion_kind") == "trial" for s in screens),
|
|
36
|
+
"call_booking": "booking" in kinds, "checkout": "payment gate" in kinds}
|
|
37
|
+
proof_seen = any(s.get("proof") or kind == "proof" for s, kind in zip(screens, kinds))
|
|
38
|
+
progress_seen = any(s.get("progress_indicator") is True for s in screens)
|
|
39
|
+
features = {
|
|
40
|
+
"question_flow": present("question" in kinds),
|
|
41
|
+
"proof_blocks": True if proof_seen else False if not partial and all("proof" in s for s in screens) else None,
|
|
42
|
+
"progress_indicator": True if progress_seen else False if not partial and all("progress_indicator" in s for s in screens) else None,
|
|
43
|
+
"result_before_contact": relation,
|
|
44
|
+
"contact_before_result": not relation if relation is not None else None,
|
|
45
|
+
"short_flow": len(screens) <= 5 if not partial else None,
|
|
46
|
+
"long_flow": len(screens) >= 10 if not partial else None,
|
|
47
|
+
"automatic_advance": sum(s.get("advance") == "automatic" for s in screens) / len(screens) >= .5 if not partial else None,
|
|
48
|
+
}
|
|
49
|
+
features.update({"type:" + name: present(value) for name, value in types.items()})
|
|
50
|
+
return {"positions": positions, "features": features, "funnel_types": [name for name, value in types.items() if value]}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"""Structure and rendering for agent-authored geography analysis, not market scoring."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import sys as _artifact_sys
|
|
5
|
+
from pathlib import Path as _ArtifactPath
|
|
6
|
+
_artifact_sys.path.insert(0, str(_ArtifactPath(__file__).resolve().parent))
|
|
7
|
+
from egbe_artifacts import artifact_path as _artifact_path
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from datetime import date
|
|
11
|
+
from pathlib import PurePosixPath
|
|
12
|
+
from urllib.parse import urlparse
|
|
13
|
+
|
|
14
|
+
SECTION_ID = "geography_comparison"
|
|
15
|
+
HEADING = "Geography comparison"
|
|
16
|
+
SOURCE_ROOT = PurePosixPath(_artifact_path("egbe-docs/research/market/evidence/geography-comparison-sources"))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def artifact_path(reference: str) -> PurePosixPath:
|
|
20
|
+
path = PurePosixPath(reference.removeprefix("artifact:"))
|
|
21
|
+
if ".." in path.parts or not path.is_relative_to(SOURCE_ROOT) or path.suffix not in {".md", ".json", ".txt"}:
|
|
22
|
+
raise ValueError(_artifact_path("Artifact sources must be sanitized notes under egbe-docs/research/market/evidence/geography-comparison-sources/"))
|
|
23
|
+
return path
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def text(value, label: str) -> str:
|
|
27
|
+
if not isinstance(value, str) or not value.strip():
|
|
28
|
+
raise ValueError(f"{label} must be non-empty text")
|
|
29
|
+
return value
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def fields(value, required: set[str], label: str) -> None:
|
|
33
|
+
if not isinstance(value, dict) or set(value) != required:
|
|
34
|
+
raise ValueError(f"{label} requires exactly: {', '.join(sorted(required))}")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def items(value, label: str) -> list:
|
|
38
|
+
if not isinstance(value, list):
|
|
39
|
+
raise ValueError(f"{label} must be an array")
|
|
40
|
+
return value
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def validate(data: dict, *, available_sections: set[str]) -> None:
|
|
44
|
+
fields(data, {"schema_version", "section_id", "context_sha256", "decision",
|
|
45
|
+
"geography_basis", "reason", "countries", "criteria", "sources",
|
|
46
|
+
"rows", "recommendation", "limitations"}, "comparison")
|
|
47
|
+
if type(data["schema_version"]) is not int or data["schema_version"] != 1 or data["section_id"] != SECTION_ID:
|
|
48
|
+
raise ValueError("Expected geography_comparison schema version 1")
|
|
49
|
+
if not re.fullmatch(r"[0-9a-f]{64}", text(data["context_sha256"], "context_sha256")):
|
|
50
|
+
raise ValueError("context_sha256 must identify the prepared context")
|
|
51
|
+
if data["decision"] not in ("compare", "not_compared"):
|
|
52
|
+
raise ValueError("decision must be compare or not_compared")
|
|
53
|
+
if data["geography_basis"] not in ("founder_constraint", "preference", "open", "evidence_supported"):
|
|
54
|
+
raise ValueError("Invalid geography_basis")
|
|
55
|
+
text(data["reason"], "reason")
|
|
56
|
+
countries = set()
|
|
57
|
+
for entry in items(data["countries"], "countries"):
|
|
58
|
+
fields(entry, {"code", "reason"}, "country")
|
|
59
|
+
code = text(entry["code"], "country.code")
|
|
60
|
+
if not re.fullmatch(r"[A-Z]{2}", code) or code in countries:
|
|
61
|
+
raise ValueError("Countries need unique uppercase two-letter codes")
|
|
62
|
+
countries.add(code)
|
|
63
|
+
text(entry["reason"], "country.reason")
|
|
64
|
+
if not countries:
|
|
65
|
+
raise ValueError("Declare the country scope; a comparison needs at least two")
|
|
66
|
+
criteria = items(data["criteria"], "criteria")
|
|
67
|
+
for criterion in criteria:
|
|
68
|
+
text(criterion, "criterion")
|
|
69
|
+
if len(set(criteria)) != len(criteria):
|
|
70
|
+
raise ValueError("Criteria must be unique")
|
|
71
|
+
sources = set()
|
|
72
|
+
for source in items(data["sources"], "sources"):
|
|
73
|
+
fields(source, {"id", "reference", "accessed_on", "period", "limitation"}, "source")
|
|
74
|
+
identifier = text(source["id"], "source.id")
|
|
75
|
+
if not re.fullmatch(r"S[1-9][0-9]*", identifier) or identifier in sources:
|
|
76
|
+
raise ValueError("Source IDs must be unique S1, S2, …")
|
|
77
|
+
sources.add(identifier)
|
|
78
|
+
reference = text(source["reference"], "source.reference")
|
|
79
|
+
if any(character.isspace() for character in reference):
|
|
80
|
+
raise ValueError("Source reference must be one URL or research ID without whitespace")
|
|
81
|
+
if reference.startswith("research:"):
|
|
82
|
+
if reference.removeprefix("research:") not in available_sections:
|
|
83
|
+
raise ValueError("Research source is not completed in the prepared context")
|
|
84
|
+
elif reference.startswith("artifact:"):
|
|
85
|
+
artifact_path(reference)
|
|
86
|
+
else:
|
|
87
|
+
parsed = urlparse(reference)
|
|
88
|
+
if parsed.scheme not in {"http", "https"} or not parsed.netloc or parsed.username or parsed.password:
|
|
89
|
+
raise ValueError("Source must be a public URL, prepared research:<id>, or owned artifact:<path>")
|
|
90
|
+
date.fromisoformat(text(source["accessed_on"], "source.accessed_on"))
|
|
91
|
+
text(source["period"], "source.period")
|
|
92
|
+
text(source["limitation"], "source.limitation")
|
|
93
|
+
covered = set()
|
|
94
|
+
for row in items(data["rows"], "rows"):
|
|
95
|
+
fields(row, {"type", "country", "criterion", "classification", "statement", "source_ids", "limitation"}, "finding")
|
|
96
|
+
if row["type"] != "geography_finding" or row["country"] not in countries or row["criterion"] not in criteria:
|
|
97
|
+
raise ValueError("Finding must reference a declared country and criterion")
|
|
98
|
+
key = (row["country"], row["criterion"])
|
|
99
|
+
if key in covered:
|
|
100
|
+
raise ValueError("Use one finding per country/criterion; combine evidence or state disagreement")
|
|
101
|
+
covered.add(key)
|
|
102
|
+
classification = row["classification"]
|
|
103
|
+
if classification not in ("observation", "estimate", "hypothesis", "unknown"):
|
|
104
|
+
raise ValueError("Finding classification must distinguish observations, estimates, hypotheses and unknowns")
|
|
105
|
+
refs = items(row["source_ids"], "source_ids")
|
|
106
|
+
if any(not isinstance(ref, str) or ref not in sources for ref in refs):
|
|
107
|
+
raise ValueError("Finding cites an unknown source ID")
|
|
108
|
+
if classification == "observation" and not refs:
|
|
109
|
+
raise ValueError("An observation needs a source; use hypothesis/unknown for unsupported claims")
|
|
110
|
+
text(row["statement"], "finding.statement")
|
|
111
|
+
text(row["limitation"], "finding.limitation")
|
|
112
|
+
recommendation = data["recommendation"]
|
|
113
|
+
fields(recommendation, {"primary_country", "runner_up_country", "rationale", "changes_choice_when", "next_step"}, "recommendation")
|
|
114
|
+
for key in ("primary_country", "runner_up_country"):
|
|
115
|
+
if recommendation[key] is not None and recommendation[key] not in countries:
|
|
116
|
+
raise ValueError("Recommendation must reference a shortlisted country or null")
|
|
117
|
+
if recommendation["runner_up_country"] is not None and (
|
|
118
|
+
recommendation["primary_country"] is None or recommendation["runner_up_country"] == recommendation["primary_country"]
|
|
119
|
+
):
|
|
120
|
+
raise ValueError("Runner-up requires a distinct primary recommendation")
|
|
121
|
+
for key in ("rationale", "changes_choice_when", "next_step"):
|
|
122
|
+
text(recommendation[key], f"recommendation.{key}")
|
|
123
|
+
for limitation in items(data["limitations"], "limitations"):
|
|
124
|
+
text(limitation, "limitation")
|
|
125
|
+
if data["decision"] == "compare":
|
|
126
|
+
if len(countries) < 2 or not criteria or covered != {(c, k) for c in countries for k in criteria}:
|
|
127
|
+
raise ValueError("Compare every shortlisted country on the same criteria; unknown is a valid cell")
|
|
128
|
+
elif criteria or covered or recommendation["primary_country"] is not None or recommendation["runner_up_country"] is not None:
|
|
129
|
+
raise ValueError("not_compared must not contain a comparison or a market winner")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def cell(value: str) -> str:
|
|
133
|
+
# Agent strings are literal content, never fences/headings or table syntax.
|
|
134
|
+
# Normalize every line separator, including Unicode separators from sources.
|
|
135
|
+
plain = " ".join(value.split())
|
|
136
|
+
escaped = re.sub(r"([\\`*_{}\[\]()#+\-.!~])", r"\\\1", plain)
|
|
137
|
+
return escaped.replace("&", "&").replace("<", "<").replace(">", ">").replace("|", "|")
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def render(data: dict) -> str:
|
|
141
|
+
rec = data["recommendation"]
|
|
142
|
+
lines = ["Agent-authored comparison; source facts and judgments are distinguished below.", "",
|
|
143
|
+
f"**Geography basis:** {cell(data['geography_basis'])}. {cell(data['reason'])}", "",
|
|
144
|
+
f"**Coverage:** {data['decision']}. This is advice, not an approved market change.", "",
|
|
145
|
+
"### Recommendation for the next test", "",
|
|
146
|
+
f"Primary: {rec['primary_country'] or 'Undetermined'}. Runner-up: {rec['runner_up_country'] or 'Undetermined'}.", "",
|
|
147
|
+
cell(rec["rationale"]), "", f"Reconsider when: {cell(rec['changes_choice_when'])}", "",
|
|
148
|
+
f"Next step: {cell(rec['next_step'])}", "", "### Shortlist", ""]
|
|
149
|
+
lines.extend(f"- **{entry['code']}** — {cell(entry['reason'])}" for entry in data["countries"])
|
|
150
|
+
if data["rows"]:
|
|
151
|
+
lines.extend(["", "### Comparable findings", "", "| Country | Criterion | Finding and basis | Limitations |", "| --- | --- | --- | --- |"])
|
|
152
|
+
for row in data["rows"]:
|
|
153
|
+
refs = ", ".join(row["source_ids"])
|
|
154
|
+
lines.append(f"| {row['country']} | {cell(row['criterion'])} | {row['classification']}: {cell(row['statement'])} [{refs or 'no source'}] | {cell(row['limitation'])} |")
|
|
155
|
+
lines.extend(["", "### Sources", ""])
|
|
156
|
+
for source in data["sources"]:
|
|
157
|
+
reference = source["reference"]
|
|
158
|
+
if reference.startswith("research:"):
|
|
159
|
+
reference = f"Previously published research: {reference.removeprefix('research:')}"
|
|
160
|
+
elif reference.startswith("artifact:"):
|
|
161
|
+
path = artifact_path(reference)
|
|
162
|
+
reference = f"[{path.name}]({path.relative_to(SOURCE_ROOT.parent.parent).as_posix()})"
|
|
163
|
+
else:
|
|
164
|
+
reference = f"<{reference.replace('<', '%3C').replace('>', '%3E')}>"
|
|
165
|
+
lines.append(f"- {source['id']}: {reference}. Accessed {source['accessed_on']}; period: {cell(source['period'])}. {cell(source['limitation'])}")
|
|
166
|
+
if not data["sources"]:
|
|
167
|
+
lines.append("No sourced observations available; do not treat this as market validation.")
|
|
168
|
+
lines.extend(["", "### Evidence gaps and limitations", ""])
|
|
169
|
+
lines.extend(f"- {cell(value)}" for value in data["limitations"])
|
|
170
|
+
if not data["limitations"]:
|
|
171
|
+
lines.append("See the per-finding limitations; no additional gap was recorded.")
|
|
172
|
+
return "\n".join(lines).strip() + "\n"
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Prepare reusable evidence, then publish one agent-authored geography comparison."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys as _artifact_sys
|
|
6
|
+
from pathlib import Path as _ArtifactPath
|
|
7
|
+
_artifact_sys.path.insert(0, str(_ArtifactPath(__file__).resolve().parent))
|
|
8
|
+
from egbe_artifacts import artifact_path as _artifact_path
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import importlib.util
|
|
12
|
+
import json
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
ROOT = Path(_artifact_path("egbe-docs/research/market/work/geography_comparison"))
|
|
16
|
+
EVIDENCE = Path(_artifact_path("egbe-docs/research/market/evidence/geography-comparison.json"))
|
|
17
|
+
REPORT = Path(_artifact_path("egbe-docs/research/market/full-report.md"))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def load(name):
|
|
21
|
+
spec = importlib.util.spec_from_file_location("pmr_" + name.replace("-", "_"), Path(__file__).with_name(name + ".py"))
|
|
22
|
+
module = importlib.util.module_from_spec(spec)
|
|
23
|
+
# Dataclass-based existing helpers expect their module to be registered.
|
|
24
|
+
import sys
|
|
25
|
+
sys.modules[spec.name] = module
|
|
26
|
+
spec.loader.exec_module(module)
|
|
27
|
+
return module
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def current_files(workspace: Path, files: dict) -> bool:
|
|
31
|
+
io = load("research-artifact-io")
|
|
32
|
+
for name, digest in files.items():
|
|
33
|
+
path = workspace / name
|
|
34
|
+
if not path.resolve().is_relative_to(workspace.resolve()):
|
|
35
|
+
raise ValueError("Geography input files must remain inside the workspace")
|
|
36
|
+
if not path.is_file() or io.sha256(path) != digest:
|
|
37
|
+
return False
|
|
38
|
+
return True
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def prepare(workspace: Path, *, context_file=None) -> dict:
|
|
42
|
+
evidence, io = load("research-evidence"), load("research-artifact-io")
|
|
43
|
+
path = workspace / ROOT / "context.json"
|
|
44
|
+
with io.file_lock(workspace / ROOT / ".run.lock", timeout=1):
|
|
45
|
+
selected = io.bind_context(workspace, "geography_comparison", context_file=context_file)
|
|
46
|
+
binding = io.context_binding(workspace, "geography_comparison")
|
|
47
|
+
files = {binding["path"]: binding["sha256"]}
|
|
48
|
+
sections = []
|
|
49
|
+
selection_path = workspace / evidence.RUNTIME / "preview-context.json"
|
|
50
|
+
selection = evidence.read_json(selection_path) if selection_path.exists() else {}
|
|
51
|
+
statuses = {row["id"]: row["status"] for row in selection.get("sections", [])}
|
|
52
|
+
for section, spec in evidence.catalog().items():
|
|
53
|
+
if section in {"geography_comparison", "fleet_prior"}:
|
|
54
|
+
continue
|
|
55
|
+
status = statuses.get(section)
|
|
56
|
+
outcome = {"status": status} if status == "could_not_complete" else evidence.inspect_section(workspace, section)
|
|
57
|
+
if status == "not_selected" and outcome["status"] == "pending":
|
|
58
|
+
outcome = {"status": "not_selected"}
|
|
59
|
+
entry = {"id": section, "label": spec["label"], "status": outcome["status"], "reason": outcome.get("reason")}
|
|
60
|
+
if outcome["status"] == "completed":
|
|
61
|
+
entry["body"] = outcome["body"]
|
|
62
|
+
root = workspace / evidence.RUNTIME / section
|
|
63
|
+
# Bind only existing proof files; never copy private Fleet data or provider credentials.
|
|
64
|
+
for filename in ("request.json", "integration-receipt.json", "receipt.json", "result.md", "completion-review.json", "input-provenance.json", "publication.json"):
|
|
65
|
+
source = root / filename
|
|
66
|
+
if source.is_file():
|
|
67
|
+
files[source.relative_to(workspace).as_posix()] = io.sha256(source)
|
|
68
|
+
if section in evidence.MEASURED:
|
|
69
|
+
source = workspace / evidence.EVIDENCE / evidence.MEASURED[section]
|
|
70
|
+
files[source.relative_to(workspace).as_posix()] = io.sha256(source)
|
|
71
|
+
sections.append(entry)
|
|
72
|
+
context = {"schema_version": 1, "product_context": selected["text"], "research_context": binding,
|
|
73
|
+
"input_files": files, "sections": sections}
|
|
74
|
+
if not path.exists() or evidence.read_json(path) != context:
|
|
75
|
+
io.write_json(workspace / ROOT / "request.json", {
|
|
76
|
+
"schema_version": 1, "section_id": "geography_comparison", "status": "pending", "error": None,
|
|
77
|
+
"research_context": binding,
|
|
78
|
+
})
|
|
79
|
+
io.write_json(path, context)
|
|
80
|
+
return {"context_path": str(path), "context_sha256": io.sha256(path)}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def finalize(workspace: Path, input_path: Path, *, persist=None) -> dict:
|
|
84
|
+
io, evidence, contract = load("research-artifact-io"), load("research-evidence"), load("geography-comparison-contract")
|
|
85
|
+
with io.section_attempt(workspace, "geography_comparison"):
|
|
86
|
+
context_path = workspace / ROOT / "context.json"
|
|
87
|
+
context = evidence.read_json(context_path)
|
|
88
|
+
data = evidence.read_json(input_path)
|
|
89
|
+
available = {s["id"] for s in context["sections"] if s["status"] == "completed"}
|
|
90
|
+
contract.validate(data, available_sections=available)
|
|
91
|
+
source_files = {}
|
|
92
|
+
for source in data["sources"]:
|
|
93
|
+
if source["reference"].startswith("artifact:"):
|
|
94
|
+
relative = contract.artifact_path(source["reference"])
|
|
95
|
+
path = workspace / relative
|
|
96
|
+
if not path.resolve().is_relative_to(workspace.resolve()):
|
|
97
|
+
raise ValueError("Artifact source escapes the workspace")
|
|
98
|
+
source_files[relative.as_posix()] = io.sha256(path)
|
|
99
|
+
if data["context_sha256"] != io.sha256(context_path) or not current_files(workspace, context["input_files"]):
|
|
100
|
+
raise ValueError("Prepared geography context changed; rerun --prepare and review the comparison before publishing")
|
|
101
|
+
for section in available:
|
|
102
|
+
if evidence.inspect_section(workspace, section)["status"] != "completed":
|
|
103
|
+
raise ValueError(f"Supporting {section} is no longer completed; rerun --prepare and review")
|
|
104
|
+
result = contract.render(data)
|
|
105
|
+
result_path = workspace / ROOT / "result.md"
|
|
106
|
+
with io.publication_lock(workspace / REPORT):
|
|
107
|
+
io.write_json(workspace / EVIDENCE, data)
|
|
108
|
+
io.write_atomic(result_path, result)
|
|
109
|
+
load("upsert-markdown-section")._upsert_markdown_section(workspace / REPORT, contract.HEADING, result)
|
|
110
|
+
# Already under the shared report lock; use the lock-free persistence boundary.
|
|
111
|
+
publisher = persist or load("persist-research-report")._persist_research_report
|
|
112
|
+
publication = publisher(workspace, extra_paths=[EVIDENCE,
|
|
113
|
+
*(Path(name) for name in source_files)])
|
|
114
|
+
state = {"schema_version": 1, "section_id": contract.SECTION_ID, "status": "completed", "error": None,
|
|
115
|
+
"research_context": context["research_context"],
|
|
116
|
+
"context_sha256": io.sha256(context_path), "input_files": context["input_files"],
|
|
117
|
+
"source_files": source_files,
|
|
118
|
+
"result_path": (ROOT / "result.md").as_posix(), "result_sha256": io.sha256(result_path),
|
|
119
|
+
"evidence_path": EVIDENCE.as_posix(), "evidence_sha256": io.sha256(workspace / EVIDENCE),
|
|
120
|
+
"publication_mode": publication.publication_mode, "report_commit_sha": publication.commit_sha}
|
|
121
|
+
evidence._publication(state)
|
|
122
|
+
io.write_json(workspace / ROOT / "request.json", state)
|
|
123
|
+
return state
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def inspect(workspace: Path, state: dict) -> tuple[str, dict]:
|
|
127
|
+
"""Validate the same portable boundary used by standalone preview."""
|
|
128
|
+
evidence, io, contract = load("research-evidence"), load("research-artifact-io"), load("geography-comparison-contract")
|
|
129
|
+
if state.get("schema_version") != 1 or state.get("section_id") != contract.SECTION_ID:
|
|
130
|
+
raise ValueError("Invalid geography receipt")
|
|
131
|
+
evidence._publication(state)
|
|
132
|
+
context = evidence.read_json(workspace / ROOT / "context.json")
|
|
133
|
+
io.verify_context(workspace, "geography_comparison", state.get("research_context"))
|
|
134
|
+
if (state.get("context_sha256") != io.sha256(workspace / ROOT / "context.json")
|
|
135
|
+
or state.get("input_files") != context["input_files"]
|
|
136
|
+
or not current_files(workspace, context["input_files"])
|
|
137
|
+
or not current_files(workspace, state["source_files"])):
|
|
138
|
+
raise ValueError("Geography comparison inputs changed; prepare and review again")
|
|
139
|
+
result = evidence._bound_file(workspace, state, ROOT / "result.md", "result")
|
|
140
|
+
data = evidence.read_json(evidence._bound_file(workspace, state, EVIDENCE, "evidence"))
|
|
141
|
+
available = {s["id"] for s in context["sections"] if s["status"] == "completed"}
|
|
142
|
+
contract.validate(data, available_sections=available)
|
|
143
|
+
for section in available:
|
|
144
|
+
if evidence.inspect_section(workspace, section)["status"] != "completed":
|
|
145
|
+
raise ValueError(f"Geography input {section} is no longer completed")
|
|
146
|
+
if data["context_sha256"] != state["context_sha256"] or result.read_text().strip() != contract.render(data).strip():
|
|
147
|
+
raise ValueError("Geography comparison rendering/context does not match its analysis")
|
|
148
|
+
return result.read_text().strip(), data
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def main() -> int:
|
|
152
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
153
|
+
parser.add_argument("--workspace", type=Path, default=Path("."))
|
|
154
|
+
parser.add_argument("--context-file", type=Path, help="Explicit context for the comparison.")
|
|
155
|
+
action = parser.add_mutually_exclusive_group(required=True)
|
|
156
|
+
action.add_argument("--prepare", action="store_true")
|
|
157
|
+
action.add_argument("--input", type=Path, help="Agent-authored JSON; validates and publishes without provider calls")
|
|
158
|
+
args = parser.parse_args()
|
|
159
|
+
try:
|
|
160
|
+
workspace = args.workspace.resolve()
|
|
161
|
+
outcome = prepare(workspace, context_file=args.context_file) if args.prepare else finalize(workspace, args.input)
|
|
162
|
+
except (OSError, ValueError, KeyError, TypeError, RuntimeError) as exc:
|
|
163
|
+
parser.exit(1, f"Geography comparison: {exc}\n")
|
|
164
|
+
print(json.dumps(outcome, indent=2))
|
|
165
|
+
return 0
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if __name__ == "__main__":
|
|
169
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Validate one homogeneous forecast scenario; never choose live campaign bids."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import math
|
|
7
|
+
|
|
8
|
+
MAX_KEYWORDS = 1000
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def keywords(values: list) -> list[str]:
|
|
12
|
+
if not isinstance(values, list) or not values:
|
|
13
|
+
raise ValueError("forecast keywords must be a nonempty list of strings")
|
|
14
|
+
result = []
|
|
15
|
+
for value in values:
|
|
16
|
+
if not isinstance(value, str):
|
|
17
|
+
raise ValueError("forecast accepts keyword strings, not mixed match/bid assets")
|
|
18
|
+
term = " ".join(value.lower().split())
|
|
19
|
+
if not term or len(term) > 80 or len(term.split()) > 10:
|
|
20
|
+
raise ValueError("forecast keywords must be 1–80 characters and at most 10 words")
|
|
21
|
+
if term not in result:
|
|
22
|
+
result.append(term)
|
|
23
|
+
return result
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def validate_scenario(value: dict, locale: dict) -> dict:
|
|
27
|
+
required = {"keywords", "location_code", "language_code", "match", "bid", "rationale", "source"}
|
|
28
|
+
if not isinstance(value, dict) or set(value) != required:
|
|
29
|
+
raise ValueError(f"scenario must contain exactly: {', '.join(sorted(required))}")
|
|
30
|
+
if any(value[k] != v for k, v in locale.items()):
|
|
31
|
+
raise ValueError("scenario location/language must match this run")
|
|
32
|
+
terms = keywords(value["keywords"])
|
|
33
|
+
if len(terms) > MAX_KEYWORDS:
|
|
34
|
+
raise ValueError("explicit scenario exceeds the 1000-keyword provider cap; choose a bounded scenario")
|
|
35
|
+
if value["match"] not in {"exact", "phrase", "broad"}:
|
|
36
|
+
raise ValueError("scenario requires one match type: exact, phrase or broad")
|
|
37
|
+
bid = value["bid"]
|
|
38
|
+
if type(bid) not in (int, float) or not math.isfinite(bid) or not 0 < bid <= 500:
|
|
39
|
+
raise ValueError("scenario bid must be finite, positive and at most 500")
|
|
40
|
+
if not float(bid).is_integer():
|
|
41
|
+
raise ValueError("scenario bid must be whole USD (1–500); choose an explicit whole-dollar assumption")
|
|
42
|
+
for key in ("rationale", "source"):
|
|
43
|
+
if not isinstance(value[key], str) or not value[key].strip():
|
|
44
|
+
raise ValueError(f"scenario {key} is required")
|
|
45
|
+
return {**value, "keywords": terms}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def coverage(*, requested: list[str], submitted: list[str], excluded: list[dict],
|
|
49
|
+
locale: dict, bid: float, match: str, scenario: dict | None) -> dict:
|
|
50
|
+
assumptions = scenario or {"rationale": "Exploratory historical CPC assumption, not a starting bid",
|
|
51
|
+
"source": "candidate keyword auction observations"}
|
|
52
|
+
return {
|
|
53
|
+
"kind": "explicit_scenario" if scenario else "exploratory_candidate_set",
|
|
54
|
+
"locale": locale, "match": match, "bid": bid, "forecast_period": "next_month",
|
|
55
|
+
"requested_count": len(requested), "submitted_count": len(submitted),
|
|
56
|
+
"submitted_keywords": submitted, "omitted_keywords": requested[len(submitted):],
|
|
57
|
+
"excluded": excluded, "rationale": assumptions["rationale"], "source": assumptions["source"],
|
|
58
|
+
"scenario_sha256": hashlib.sha256(json.dumps(scenario or {}, sort_keys=True).encode()).hexdigest(),
|
|
59
|
+
"limitations": "One homogeneous keyword set; not total market reach or an approved campaign. "
|
|
60
|
+
"Test-budget clicks are conditional linear arithmetic, not a daily-budget forecast.",
|
|
61
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""Publish independent keyword locales into one receipt-bound report section."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import sys as _artifact_sys
|
|
5
|
+
from pathlib import Path as _ArtifactPath
|
|
6
|
+
_artifact_sys.path.insert(0, str(_ArtifactPath(__file__).resolve().parent))
|
|
7
|
+
from egbe_artifacts import artifact_path as _artifact_path
|
|
8
|
+
|
|
9
|
+
import hashlib
|
|
10
|
+
import json
|
|
11
|
+
import re
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
ROOT = Path(_artifact_path("egbe-docs/research/market/work/keyword_economics"))
|
|
15
|
+
EVIDENCE = Path(_artifact_path("egbe-docs/research/market/evidence/keyword-economics.json"))
|
|
16
|
+
REPORT = Path(_artifact_path("egbe-docs/research/market/full-report.md"))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def locale_key(location: int, language: str) -> str:
|
|
20
|
+
if type(location) is not int or location <= 0 or not re.fullmatch(r"[a-z]{2,3}(?:-[a-z]{2})?", language):
|
|
21
|
+
raise ValueError("Invalid keyword locale; use a positive location code and normalized language")
|
|
22
|
+
return f"{location}-{language}"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _read(path: Path) -> dict:
|
|
26
|
+
value = json.loads(path.read_text())
|
|
27
|
+
if not isinstance(value, dict):
|
|
28
|
+
raise ValueError(f"Expected JSON object: {path}")
|
|
29
|
+
return value
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def ensure_current_format(workspace: Path) -> None:
|
|
33
|
+
path = workspace / EVIDENCE
|
|
34
|
+
if path.exists() and _read(path).get("schema_version") != 2:
|
|
35
|
+
raise ValueError("Existing Keyword Economics evidence uses an old format. Preserve it in a separate "
|
|
36
|
+
"research workspace and rerun with the updated bundle; it will not be overwritten.")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def begin(workspace: Path, key: str, context_hash: dict, io) -> None:
|
|
40
|
+
ensure_current_format(workspace)
|
|
41
|
+
io.write_json(workspace / ROOT / "locales" / key / "request.json", {
|
|
42
|
+
"status": "pending", "research_context": context_hash, "locale_key": key,
|
|
43
|
+
})
|
|
44
|
+
with io.publication_lock(workspace / REPORT):
|
|
45
|
+
io.write_json(workspace / ROOT / "request.json", {"schema_version": 1,
|
|
46
|
+
"section_id": "keyword_economics", "status": "pending", "error": None,
|
|
47
|
+
"research_context": context_hash})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def failed(workspace: Path, key: str, context_hash: dict, io) -> None:
|
|
51
|
+
# Do not store upstream exception text: it can contain provider request details.
|
|
52
|
+
with io.publication_lock(workspace / REPORT):
|
|
53
|
+
io.write_json(workspace / ROOT / "locales" / key / "request.json", {
|
|
54
|
+
"status": "failed", "research_context": context_hash, "locale_key": key,
|
|
55
|
+
"error": "Collection or publication failed; retry this locale using its cache.",
|
|
56
|
+
})
|
|
57
|
+
io.write_json(workspace / ROOT / "request.json", {"schema_version": 1,
|
|
58
|
+
"section_id": "keyword_economics", "status": "failed",
|
|
59
|
+
"research_context": context_hash,
|
|
60
|
+
"error": f"Locale {key} failed; last successful files are retained, not current completion."})
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def aggregate(workspace: Path, context_hash: dict, io) -> tuple[dict, str, list[Path]]:
|
|
64
|
+
locales, rows, body, paths, hashes = [], [], [], [], set()
|
|
65
|
+
for request_path in sorted((workspace / ROOT / "locales").glob("*/request.json")):
|
|
66
|
+
state = _read(request_path)
|
|
67
|
+
key = request_path.parent.name
|
|
68
|
+
path = EVIDENCE.parent / "keyword-economics" / f"{key}.json"
|
|
69
|
+
entry = {"key": key, "status": state["status"], "evidence_path": path.as_posix()}
|
|
70
|
+
if state.get("research_context") != context_hash:
|
|
71
|
+
entry["status"] = "stale"
|
|
72
|
+
elif state["status"] in {"collected", "completed"}:
|
|
73
|
+
if not (workspace / path).is_file() or io.sha256(workspace / path) != state.get("evidence_sha256"):
|
|
74
|
+
entry["status"] = "invalid"
|
|
75
|
+
else:
|
|
76
|
+
data = _read(workspace / path)
|
|
77
|
+
entry.update({"locale": data["locale"], "retrieved_on": data["retrieved_on"],
|
|
78
|
+
"evidence_sha256": state["evidence_sha256"], "simulation": data["simulation"],
|
|
79
|
+
"inputs_sha256": data["inputs_sha256"], "status": "completed"})
|
|
80
|
+
rows.extend({**r, "locale_key": key, "locale": data["locale"]} for r in data["rows"])
|
|
81
|
+
hashes.update(data["request_hashes"])
|
|
82
|
+
paths.append(path)
|
|
83
|
+
nested = re.sub(r"(?m)^(#{3,5}) ", r"\1# ", data["section_markdown"])
|
|
84
|
+
body.append(f"### Locale {key}\n\n{nested.strip()}")
|
|
85
|
+
locales.append(entry)
|
|
86
|
+
if entry["status"] != "completed":
|
|
87
|
+
body.append(f"### Locale {key}\n\nCurrent outcome: **{entry['status']}**. "
|
|
88
|
+
"Previous results, if any, are not evidence of successful current coverage.")
|
|
89
|
+
cost = 0.0
|
|
90
|
+
for digest in sorted(hashes):
|
|
91
|
+
if not re.fullmatch(r"[0-9a-f]{64}", digest):
|
|
92
|
+
raise ValueError("Invalid provider request hash")
|
|
93
|
+
cache = _read(workspace / ROOT / "cache" / f"{digest}.json")
|
|
94
|
+
value = cache["response"].get("cost")
|
|
95
|
+
if isinstance(value, (int, float)):
|
|
96
|
+
cost += value
|
|
97
|
+
evidence = {"schema_version": 2, "section_id": "keyword_economics",
|
|
98
|
+
"research_context": context_hash, "locales": locales, "rows": rows,
|
|
99
|
+
"request_hashes": sorted(hashes), "totals": {"tasks_spent": len(hashes), "estimated_cost_usd": round(cost, 4)}}
|
|
100
|
+
intro = ("Country scenarios are separate alternatives: volumes and CPCs are not pooled. "
|
|
101
|
+
"The same test budget is not an allocation funding every country.\n\n")
|
|
102
|
+
return evidence, intro + "\n\n".join(body) + "\n", paths
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def publish(workspace: Path, key: str, context_hash: dict, outcome: dict, io, upsert, persist) -> dict:
|
|
106
|
+
with io.publication_lock(workspace / REPORT):
|
|
107
|
+
data = {**outcome["evidence"], "research_context": context_hash,
|
|
108
|
+
"section_markdown": outcome["section_markdown"]}
|
|
109
|
+
data["inputs_sha256"] = hashlib.sha256(json.dumps(data["inputs"], sort_keys=True).encode()).hexdigest()
|
|
110
|
+
path = workspace / EVIDENCE.parent / "keyword-economics" / f"{key}.json"
|
|
111
|
+
io.write_json(path, data)
|
|
112
|
+
state = {"locale_key": key, "research_context": context_hash, "status": "collected",
|
|
113
|
+
"evidence_sha256": io.sha256(path), "attempt": outcome["attempt"]}
|
|
114
|
+
state_path = workspace / ROOT / "locales" / key / "request.json"
|
|
115
|
+
io.write_json(state_path, state)
|
|
116
|
+
evidence, markdown, locale_paths = aggregate(workspace, context_hash, io)
|
|
117
|
+
io.write_json(workspace / EVIDENCE, evidence)
|
|
118
|
+
io.write_atomic(workspace / ROOT / "result.md", markdown)
|
|
119
|
+
upsert._upsert_markdown_section(workspace / REPORT, "Keyword economics", markdown)
|
|
120
|
+
persistence = persist._persist_research_report(
|
|
121
|
+
workspace, commit_message="research: update keyword economics locales",
|
|
122
|
+
extra_paths=[EVIDENCE, *locale_paths])
|
|
123
|
+
state.update(status="completed", report_commit_sha=persistence.commit_sha,
|
|
124
|
+
publication_mode=persistence.publication_mode)
|
|
125
|
+
io.write_json(state_path, state)
|
|
126
|
+
complete = all(x["status"] == "completed" for x in evidence["locales"])
|
|
127
|
+
receipt = {"schema_version": 1, "section_id": "keyword_economics",
|
|
128
|
+
"status": "completed" if complete else "incomplete", "error": None,
|
|
129
|
+
"research_context": context_hash, "locales": evidence["locales"],
|
|
130
|
+
"evidence_path": EVIDENCE.as_posix(), "evidence_sha256": io.sha256(workspace / EVIDENCE),
|
|
131
|
+
"result_path": (ROOT / "result.md").as_posix(), "result_sha256": io.sha256(workspace / ROOT / "result.md"),
|
|
132
|
+
**evidence["totals"], "attempt_tasks_spent": outcome["attempt"]["tasks_spent"],
|
|
133
|
+
"attempt_cache_hits": outcome["attempt"]["cache_hits"],
|
|
134
|
+
"report_commit_sha": persistence.commit_sha, "publication_mode": persistence.publication_mode}
|
|
135
|
+
io.write_json(workspace / ROOT / "request.json", receipt)
|
|
136
|
+
return receipt
|