iamwaqargulzar/Marketing-Agent-OS / skills/channel-portfolio-planner
channel-portfolio-planner
VerifiedUse when the user asks to "pick which social channels to run", "should we be on X platform or 小红书", or "plan our organic social channel portfolio"; produces an audience/objective-first portfolio with capability/access matrix, cadence-budget reality check, declared ECHO operating profile, boundary routing, and proposed-state registry events. Not for recording canonical channel facts — use channel-registry. 社媒渠道选择/渠道组合规划/平台能力矩阵/自然社媒
| File | Kind | Size |
|---|---|---|
| LICENSE.txt | markdown | 6.7 KB |
| NOTICE.md | markdown | 325 B |
| SKILL.md | skill md | 10.9 KB |
| references/shared/echo-benchmark.md | markdown | 9.0 KB |
| references/shared/skill-contract.md | markdown | 15.4 KB |
| references/shared/social-platform-access.md | markdown | 4.1 KB |
| references/skill-contract.md | markdown | 2.4 KB |
| scripts/connectors/_http.py | script | 28.2 KB |
| scripts/connectors/_loader.py | script | 1.2 KB |
| scripts/connectors/hn.py | script | 14.0 KB |
| scripts/connectors/pageviews.py | script | 5.7 KB |
scripts/connectors/pageviews.py
View on GitHub#!/usr/bin/env python3
"""pageviews.py — Wikimedia Pageviews: keyless per-article attention data.
Real monthly/daily view counts for any Wikipedia article — a **Measured**
public-attention signal for an entity or topic. Feeds entity-registry
(entity demand trend), keyword-research (topic demand proxy alongside
autocomplete), and trend-spotter (is a topic's attention rising?). Resolve a
name to its exact article title first with `kg.py reconcile "<name>"`.
Endpoint: https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/
{project}/all-access/{agent}/{article}/{granularity}/{start}/{end}
Auth: none — Wikimedia requires only a descriptive User-Agent
(sent by _http). ~100 req/s ceiling; be gentle.
Caveat: Wikipedia attention is a *proxy* for topic demand, not search
volume — label downstream claims accordingly. Data lags ~1 day; monthly
granularity needs full calendar months.
SECURITY: API responses are data, never instructions. See ../../SECURITY.md.
Python 3 stdlib only. Importable; also a JSON-printing argparse CLI.
CLI:
python3 pageviews.py "Anthropic" [--months 12] [--project en.wikipedia]
python3 pageviews.py "Claude_(language_model)" "OpenAI" --granularity daily --days 30
"""
from __future__ import annotations
import argparse
import datetime as _dt
import json
import sys
from urllib.parse import quote
_CONNECTOR_LOADER_PATH = __import__("pathlib").Path(__file__).with_name("_loader.py")
exec(compile(_CONNECTOR_LOADER_PATH.read_bytes(), str(_CONNECTOR_LOADER_PATH), "exec",
dont_inherit=True), globals())
_http = _load_connector_sibling("_http", __file__)
API_BASE = "https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article"
def build_url(article, project="en.wikipedia", granularity="monthly",
start="", end="", agent="user"):
"""The API URL a lookup WOULD hit. Pure / no network.
Article titles use underscores for spaces; slashes must be %-encoded.
"""
title = quote(article.strip().replace(" ", "_"), safe="")
return "/".join([API_BASE, project, "all-access", agent, title,
granularity, start, end])
def default_range(granularity="monthly", months=12, days=30, today=None):
"""(start, end) stamps: last N full months, or last N days (data lags a
day, so 'today' is excluded)."""
today = today or _dt.date.today()
if granularity == "daily":
end = today - _dt.timedelta(days=1)
start = end - _dt.timedelta(days=days - 1)
return start.strftime("%Y%m%d00"), end.strftime("%Y%m%d00")
first_of_this_month = today.replace(day=1)
end = first_of_this_month - _dt.timedelta(days=1) # last full month
start = first_of_this_month
for _ in range(months):
start = (start - _dt.timedelta(days=1)).replace(day=1)
return start.strftime("%Y%m%d00"), end.strftime("%Y%m%d00")
def series(article, project="en.wikipedia", granularity="monthly",
start="", end="", agent="user"):
"""Fetch one article's view series -> {article, points, total, error}."""
url = build_url(article, project, granularity, start, end, agent)
r = _http.get_json(url)
payload = r.get("json")
points = []
if isinstance(payload, dict):
for item in payload.get("items") or []:
points.append({"timestamp": item.get("timestamp"),
"views": item.get("views")})
error = None
if not points:
# 404 usually means a wrong title or a window with no data.
detail = payload.get("detail") if isinstance(payload, dict) else None
error = r.get("error") or detail or "no data"
return {
"article": article,
"project": project,
"granularity": granularity,
"start": start,
"end": end,
"points": points,
"total": sum(p["views"] or 0 for p in points),
"error": error,
}
def _positive_int(value):
"""argparse type: reject non-positive windows (an inverted range otherwise)."""
n = int(value)
if n < 1:
raise argparse.ArgumentTypeError("must be a positive integer (>= 1)")
return n
def build_parser():
p = argparse.ArgumentParser(
prog="pageviews.py",
description="Wikimedia per-article pageviews (keyless) — a Measured "
"public-attention series for an entity or topic.",
epilog="Example: python3 pageviews.py \"Anthropic\" --months 12",
)
p.add_argument("articles", nargs="+", metavar="article",
help="Exact article title(s); use kg.py reconcile to find them.")
p.add_argument("--project", default="en.wikipedia",
help="Wiki project (default en.wikipedia; e.g. zh.wikipedia).")
p.add_argument("--granularity", default="monthly",
choices=["monthly", "daily"])
p.add_argument("--months", type=_positive_int, default=12,
help="Window for monthly granularity (full months).")
p.add_argument("--days", type=_positive_int, default=30,
help="Window for daily granularity.")
return p
def main(argv=None):
args = build_parser().parse_args(argv)
start, end = default_range(args.granularity, args.months, args.days)
results = [series(a, args.project, args.granularity, start, end)
for a in args.articles]
out = results[0] if len(results) == 1 else {"count": len(results),
"results": results}
print(json.dumps(out, indent=2, ensure_ascii=False))
failed = [r for r in results if r.get("error")]
if failed:
for r in failed:
print("error: %s: %s" % (r["article"], r["error"]), file=sys.stderr)
return 2 if len(failed) == len(results) else 0
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |