thoughtleaders-cli 0.7.3__py3-none-any.whl → 0.7.5__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: thoughtleaders-cli
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: ThoughtLeaders CLI — query sponsorship data, channels, brands, and intelligence
5
5
  Project-URL: Homepage, https://thoughtleaders.io
6
6
  Project-URL: Repository, https://github.com/ThoughtLeaders-io/thoughtleaders-cli
@@ -1,4 +1,4 @@
1
- tl_cli/__init__.py,sha256=h7zCqgU0QJjYC5VcMTIOfWFMG-FXtPnjPiAH-u4wRMY,112
1
+ tl_cli/__init__.py,sha256=42wtAYnJRvJF6uR3-XllRTU49NwpGdrk-2Ap1Lnu_a8,112
2
2
  tl_cli/_completions.py,sha256=kOyEUqC26vbYvyXWi513WX8fF73qQLR5WWuRSe_wqyk,164
3
3
  tl_cli/_typer_utils.py,sha256=ZiZsCVmEznPvBw-dYbr3tu3zWZ0iN6kjoQmK3gMqD28,860
4
4
  tl_cli/config.py,sha256=UV_OYTXuQnAIqbi_oVCXx0hhIdZWR678RRapVv51UwQ,1859
@@ -7,9 +7,8 @@ tl_cli/hints.py,sha256=cT8kuDtkAZqwXkc2RV0Yg_abofK-g9UiXwTTBunX78U,1557
7
7
  tl_cli/main.py,sha256=A_8b2SQjBKATxrjO7AGC5Ab1QWlP35gGo4TWzYZtlOM,5806
8
8
  tl_cli/self_update.py,sha256=akXOWYgBX2otyaVlx9CDl04gG2s_hYigE2Vkpubt0SA,18302
9
9
  tl_cli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- tl_cli/auth/commands.py,sha256=NtM5WGnReXrpZ3bysNudUYT_TcRRPE0Ho1EwbRgM_Ws,6285
11
- tl_cli/auth/finalize.py,sha256=74x8U39dK4nhEnIUMKhX5rNsn1Qjjm8or1n1nUH0SbQ,3346
12
- tl_cli/auth/login.py,sha256=6Jhfw7_eXGxZvUfNP33AZPRmnqmu_scvgt4AcOydsrE,10665
10
+ tl_cli/auth/commands.py,sha256=BiT-87UbZjsOJKtjv2dKcCwbAg4-Dp4oICRM0c97TFg,7409
11
+ tl_cli/auth/login.py,sha256=Rf65nhN7sjUNcaHYlsO7oYCiHqhGo8e8XwoGI2S4mgM,11487
13
12
  tl_cli/auth/pkce.py,sha256=4Q6Ip-TeZFNG9c3swXNi4gH7mdMkltKa62gZZNybt8U,658
14
13
  tl_cli/auth/token_store.py,sha256=TcZnUol4-8r0jMEJhOPmABCX12_5RkAln2xfWPNdmHk,3275
15
14
  tl_cli/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -21,7 +20,7 @@ tl_cli/commands/balance.py,sha256=JHSmKdAUNtd-9zlKZhit9_BmhHXrEk0kQ-oSlQ0Eo6Y,27
21
20
  tl_cli/commands/brands.py,sha256=rvYRrhkDhHDlvFpWrf8TtGbBt8KyNxHcVodjjFNpmHY,12443
22
21
  tl_cli/commands/bulk_import.py,sha256=d4y1k_lD52LPJcCqXxEmyHIqcIwomZgbjqs1_QxPjeQ,4536
23
22
  tl_cli/commands/changelog.py,sha256=D1PtDdHpawTlWqUHjKzVmv9yXLSU915UVmI3dZzEwyA,4241
24
- tl_cli/commands/channels.py,sha256=EgwTzweKsQEerBTwiWGCP1myCTW3KQFu4Om2j4Htfzk,17217
23
+ tl_cli/commands/channels.py,sha256=ALw2fgJL3w0dpYp3A41OECL0odenhSV16vFA7la7aQI,16878
25
24
  tl_cli/commands/credits.py,sha256=2xCht2e420LmaFBKNdKoMz8GlTh31qSWSlJAnVzoZic,7308
26
25
  tl_cli/commands/db.py,sha256=rdIQrxT7sdrPEnBbByNHvPr2X6iIg-wb19X9bWYwDRc,5053
27
26
  tl_cli/commands/deals.py,sha256=ZK9yneInsC6DXoCPS65oyLoVR0eRW1xdRlEN7oRp1pc,2174
@@ -30,7 +29,7 @@ tl_cli/commands/doctor.py,sha256=KUKglwhMc7B26XXy_3M0LkHu7wqfFO5T0YPHO1SH1VY,902
30
29
  tl_cli/commands/matches.py,sha256=K5o6B8FLECp7825dU4W3X8n-wuXvGJz57xpQPXeXQ-0,2886
31
30
  tl_cli/commands/proposals.py,sha256=khsjorluIfgrJ22DiwzIAFcYD4JbirjkOBz1KuQ0Sdk,2918
32
31
  tl_cli/commands/recommender.py,sha256=DIRvnSbV2TwvVUgA5luGJ7uQUOjHx2CULFsZVaqUYw4,18922
33
- tl_cli/commands/reports.py,sha256=1QDJN6FrUmWCuvaMxN884_bVdy-l7anBuS2jkCZF1VQ,22543
32
+ tl_cli/commands/reports.py,sha256=WcZWtBVRX49z-1Fw4T5iq_xZqks3QmIXlWVg5iVGs58,26532
34
33
  tl_cli/commands/schema.py,sha256=GCBEE4fDatQhVasLKKr7bkGhELRZ0scYm_hUCbDYmuA,5985
35
34
  tl_cli/commands/setup.py,sha256=QST6DCSxJHLFNX1UUJHwZ3hTDTnySATaV2Tc2JsdYYY,21920
36
35
  tl_cli/commands/snapshots.py,sha256=mWxnZI_UBzbZZHsA3uP0Q7Gt2XsLLoRD5dRNGt-mGUE,3428
@@ -40,14 +39,14 @@ tl_cli/commands/whoami.py,sha256=aUXwBRwh1vAGrvz8CKGfHYtEOKJCIDfwrGesKAwYZMk,786
40
39
  tl_cli/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
40
  tl_cli/output/formatter.py,sha256=pqlKmb2nZ1Z2e1A9m8l5mgVemJinVAP4in1tUzFWHno,22522
42
41
  tl_cli/_plugin/.claude-plugin/marketplace.json,sha256=l56PMmyjfGXNGlV30wRyOAe74B6gJNCVNCxgsBbSNxc,446
43
- tl_cli/_plugin/.claude-plugin/plugin.json,sha256=6Y3Jk9hf7TpQou5Bp-Ylaqt9jwpnhHmaJWWghJIteJY,466
42
+ tl_cli/_plugin/.claude-plugin/plugin.json,sha256=p-kkTL4_8uxs1HMp_shuo7K82_3aT2bcUp-q980utQ0,466
44
43
  tl_cli/_plugin/agents/tl-analyst.md,sha256=6J3X3NANkWg6OOUCvNirkN4ulIk80KSumPncDUBt75E,6761
45
44
  tl_cli/_plugin/agents/youtube-comment-classifier.md,sha256=S5lr_htA98FIX0su8FJ2ntiHfbdK8OB2NQKC4lTnQcw,2178
46
45
  tl_cli/_plugin/hooks/hooks.json,sha256=FSWibw1xAjA-suFV3fR8btIb2kQ82LQ08otTr-NpmFw,835
47
46
  tl_cli/_plugin/hooks/scripts/load-tl-skill.mjs,sha256=EBsyZ-caei-CBJsRtqzJXJs_20O3H22MuVmDpu96umo,805
48
47
  tl_cli/_plugin/hooks/scripts/post-usage.sh,sha256=WVvZLkZik6lbeZ20Kh-wgm4JkRFHFN0Uwl4C8S3Y0sY,759
49
48
  tl_cli/_plugin/hooks/scripts/pre-check.sh,sha256=E9KeuXy6yeHEBOnOFW4hDW-Et-Dbp1Oh--3WXKfOX78,898
50
- tl_cli/_plugin/skills/tl/SKILL.md,sha256=jSZ6fe3VIQHBE8BemgwWcw0dPhUEEeMtaP7-0SbxHss,58195
49
+ tl_cli/_plugin/skills/tl/SKILL.md,sha256=YDpZ3DtP_HjEfZtC17ELG9kk-OixRXNvRL7VWwrrMXI,59099
51
50
  tl_cli/_plugin/skills/tl/references/business-glossary.md,sha256=FCS-qBOGpdJCmHdglRGRjAuTQAtzpxJNpMkEWThuvlI,17779
52
51
  tl_cli/_plugin/skills/tl/references/elasticsearch-schema.md,sha256=OpHvixZ8UcZYJd8GdwgumryFyKwPAxj3AvPkl1QreMY,9316
53
52
  tl_cli/_plugin/skills/tl/references/firebolt-schema.md,sha256=KagpSWWEWIRfsAWz271PvAqVbSPvWLoogWhCA_XFSZw,10642
@@ -111,8 +110,8 @@ tl_cli/_plugin/skills/tl-top-partnerships/SKILL.md,sha256=hvH05hIaGlc0RfTE0GLBtD
111
110
  tl_cli/_plugin/skills/tl-top-partnerships/scripts/top_partnerships.py,sha256=_13W6-HuD_jtl7AWQQcZQ0SQO9qODMymlcL-1s4-VwU,13248
112
111
  tl_cli/_plugin/skills/tl-views-guarantee/SKILL.md,sha256=IH7q1WJDWri9TWJMiga1FMGJO_GKSbWwaDS6CVNZ9c0,9270
113
112
  tl_cli/_plugin/skills/tl-views-guarantee/scripts/vg.py,sha256=Qp5poinHEqh9374anq0bLtlxj2YL6ipBicaT960-Cws,15825
114
- thoughtleaders_cli-0.7.3.dist-info/METADATA,sha256=mctSp2dkZ0dHayu3muuIfBWJ8T1no1bS5NmUsYoRz20,18452
115
- thoughtleaders_cli-0.7.3.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
116
- thoughtleaders_cli-0.7.3.dist-info/entry_points.txt,sha256=umZp-1BkGkHDG0bNZXpTXrjwW0HGf9IDFN40eAWuuvg,39
117
- thoughtleaders_cli-0.7.3.dist-info/licenses/LICENSE,sha256=RUfdfLsn6jygiyrnnVUHt6r4IPwr2rbDm9Kixgtu8fo,1071
118
- thoughtleaders_cli-0.7.3.dist-info/RECORD,,
113
+ thoughtleaders_cli-0.7.5.dist-info/METADATA,sha256=DrOuWCd6RmuSEdebcd8PU8b4FpRSJejLHQkAVXcvTw0,18452
114
+ thoughtleaders_cli-0.7.5.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
115
+ thoughtleaders_cli-0.7.5.dist-info/entry_points.txt,sha256=umZp-1BkGkHDG0bNZXpTXrjwW0HGf9IDFN40eAWuuvg,39
116
+ thoughtleaders_cli-0.7.5.dist-info/licenses/LICENSE,sha256=RUfdfLsn6jygiyrnnVUHt6r4IPwr2rbDm9Kixgtu8fo,1071
117
+ thoughtleaders_cli-0.7.5.dist-info/RECORD,,
tl_cli/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """ThoughtLeaders CLI — query sponsorship data, channels, brands, and intelligence."""
2
2
 
3
- __version__ = "0.7.3"
3
+ __version__ = "0.7.5"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tl-cli",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "ThoughtLeaders CLI — query sponsorship deals, channels, brands, uploads, and intelligence from the terminal",
5
5
  "author": {
6
6
  "name": "ThoughtLeaders",
@@ -150,6 +150,8 @@ Unless the user specifically asks for running a specific report or showing the r
150
150
 
151
151
  If the user says yes (or uses any of the save-trigger phrases, like `save it`, `save the list`, `make a report`, `persist this`, `turn this into a campaign`, `I want to come back to this`), invoke the `tl-save-report` skill — it owns the filter-vs-list decision flow, the FilterSet mapping, and the `tl reports create` / `tl reports save-list` save call. **Don't try to compose the report config yourself**; hand off to the skill.
152
152
 
153
+ **When the user already has specific IDs in hand** — "make a report of these sponsorship IDs", "save these exact channels", or a curated set you just resolved — that is always a **list-style** report: pin the IDs with `tl reports save-list <entity> --ids-file` (or add them to an existing report with `tl bulk-import <entity> -c <report-id>`). **Never** route an explicit-ID request through `tl reports create "<natural-language prompt>"` — the prompt path builds *predicate filters* and pins none of those IDs, so the report comes back showing unrelated records, not the ones the user named. After creating it, confirm the report actually contains those records before sharing the link.
154
+
153
155
  Skip the save offer when the result clearly doesn't fit a report type — a single scalar count, an aggregate roll-up across entity types, view-curve time series, schema introspection output, or anything that isn't a list of channels / brands / videos / sponsorships. A trailing offer on those would just be noise.
154
156
 
155
157
  Prefer writing shell code, `jq` commands, or `duckdb` commands that fetch or analysise large sets of data instead of analysing it yourself. On Mac and Linux, create temporary files in `/tmp` that can be analysed later in different ways. On Windows, create them in the directory pointed to by the `%TEMP%` environment variable. When coding, do it in Python.
@@ -765,7 +767,7 @@ tl channels similar 29834 msn:no --limit 30 # non-MSN channels
765
767
  tl channels similar 29834 tpp:yes --limit 30 # TPP (TL-managed) channels only
766
768
  tl channels similar 29834 min-subs:1000000 exclude:477487 --limit 15 # client-side filters
767
769
  ```
768
- **Both `tl channels show` and `tl channels similar` accept either a numeric channel ID or a channel name.** Name arguments are case-insensitive partial matches; if more than one active channel matches, the command prints a candidates table (channel_id, subscribers, name) and exits 1 so you can retry with a specific ID. The `msn` filter on `similar` is tri-state: `yes` (only MSN channels — the default), `no` (only non-MSN channels), `both` (no MSN filter). `tl channels look-alike` is a hidden alias for `similar` that matches the internal "look-alike channels" terminology.
770
+ **Both `tl channels show` and `tl channels similar` accept either a numeric channel ID or a channel name.** Name arguments are case-insensitive partial matches; if more than one active channel matches, the command prints a candidates table (channel_id, subscribers, name) and exits 1 so you can retry with a specific ID. The `msn` filter on `similar` is tri-state: `yes` (only MSN channels — the default), `no` (only non-MSN channels), `both` (no MSN filter). `tl channels look-alike` is a hidden alias for `similar` that matches the internal "look-alike channels" terminology. `tl channels show` returns a `tl_url` field — the canonical ThoughtLeaders web-app analysis page for the channel; use it verbatim when linking a user to the channel instead of constructing a URL by hand.
769
771
 
770
772
  ### "Browse the recommender" (categories, demographics, formats):
771
773
  ```bash
tl_cli/auth/commands.py CHANGED
@@ -8,9 +8,9 @@ from tl_cli._typer_utils import AlphaSortedTyperGroup
8
8
  from rich.console import Console
9
9
  from rich.prompt import Prompt
10
10
 
11
- from tl_cli.auth.finalize import finalize_signup
12
- from tl_cli.auth.login import login_browser, login_device_code
11
+ from tl_cli.auth.login import login_browser, login_device_code, revoke_refresh_token
13
12
  from tl_cli.auth.token_store import KIND_API_KEY, StoredTokens, clear_tokens, load_tokens, save_tokens
13
+ from tl_cli.config import get_config
14
14
 
15
15
  app = typer.Typer(cls=AlphaSortedTyperGroup, help="Authentication commands")
16
16
  console = Console(stderr=True)
@@ -106,8 +106,6 @@ def login_cmd() -> None:
106
106
  else:
107
107
  login_browser()
108
108
 
109
- finalize_signup()
110
-
111
109
 
112
110
  def _login_api_key() -> None:
113
111
  """Store a user-supplied API key as the active credential.
@@ -171,7 +169,27 @@ def _login_api_key() -> None:
171
169
 
172
170
  @app.command("logout")
173
171
  def logout_cmd() -> None:
174
- """Clear stored authentication tokens."""
172
+ """Log out: revoke the refresh token at Auth0, then clear stored tokens."""
173
+ tokens = load_tokens()
174
+ # Revoke the long-lived credential server-side so a leaked/synced copy of
175
+ # the local token store can't keep minting access tokens. Best-effort —
176
+ # API-key auth has no refresh token, and an offline revoke must not block
177
+ # clearing local credentials.
178
+ if tokens and not tokens.is_api_key and tokens.refresh_token:
179
+ if revoke_refresh_token(tokens.refresh_token):
180
+ console.print("[dim]Refresh token revoked at Auth0.[/dim]")
181
+ else:
182
+ console.print(
183
+ "[yellow]Could not reach Auth0 to revoke the refresh token; "
184
+ "clearing local credentials anyway.[/yellow]"
185
+ )
186
+ # Revoking the refresh token doesn't end the browser SSO session that
187
+ # the interactive login established. Point the user at Auth0's logout
188
+ # URL so the next `tl auth login` doesn't silently SSO straight back in.
189
+ logout_url = f"https://{get_config().auth0_domain}/logout"
190
+ console.print(
191
+ f"To end your Auth0 browser session, visit: [cyan]{logout_url}[/cyan]"
192
+ )
175
193
  clear_tokens()
176
194
  console.print("[green]Logged out successfully.[/green]")
177
195
 
tl_cli/auth/login.py CHANGED
@@ -212,6 +212,29 @@ def refresh_access_token(refresh_token: str) -> StoredTokens:
212
212
  return tokens
213
213
 
214
214
 
215
+ def revoke_refresh_token(refresh_token: str) -> bool:
216
+ """Best-effort revocation of a refresh token at Auth0 (RFC 7009).
217
+
218
+ Invalidates the long-lived credential server-side so it can no longer mint
219
+ new access tokens. Public-client call — `client_id` only, no secret. Returns
220
+ True on success; never raises — network / Auth0 errors are swallowed so
221
+ `tl auth logout` can still clear the local credentials when offline.
222
+ """
223
+ config = get_config()
224
+ try:
225
+ response = httpx.post(
226
+ f"https://{config.auth0_domain}/oauth/revoke",
227
+ json={
228
+ "client_id": config.auth0_client_id,
229
+ "token": refresh_token,
230
+ },
231
+ timeout=10,
232
+ )
233
+ except httpx.HTTPError:
234
+ return False
235
+ return response.status_code == 200
236
+
237
+
215
238
  def _exchange_code(
216
239
  code: str,
217
240
  code_verifier: str,
@@ -64,14 +64,6 @@ def show_cmd(
64
64
  client = get_client()
65
65
  try:
66
66
  data = client.get(f"/channels/{encoded_ref}")
67
- for i, r in enumerate(data.get("results", []) if isinstance(data.get("results"), list) else []):
68
- renamed = {}
69
- for k, v in r.items():
70
- if k == "id":
71
- renamed["channel_id"] = v
72
- else:
73
- renamed[k] = v
74
- data["results"][i] = renamed
75
67
  output_single(data, fmt)
76
68
  if fmt == "table" and data.get("show_cta"):
77
69
  record = data.get("results", data)
@@ -22,6 +22,71 @@ REPORT_TYPE_LABELS = {1: "Content", 2: "Brands", 3: "Channels", 8: "Sponsorships
22
22
 
23
23
  POLL_INTERVAL = 2 # seconds between server polls
24
24
 
25
+ # Filterset keys that pin specific entities into a report (the curated-ID
26
+ # lists). A report built from these holds exactly those records; a report built
27
+ # from predicate filters re-evaluates against live data and pins nothing.
28
+ _PIN_ENTITIES = ("channels", "brands", "sponsorships", "articles")
29
+ # Filterset keys that are structural, not user-facing predicate filters.
30
+ _NON_PREDICATE_KEYS = {"keyword_operator", "sort"}
31
+
32
+
33
+ def _summarize_report_contents(config: dict) -> dict:
34
+ """Summarize what a saved report config actually contains.
35
+
36
+ Returns the report-type label, a per-entity count of *pinned* IDs (the
37
+ curated lists that freeze specific channels/brands/sponsorships/articles
38
+ into the report), and the active predicate-filter keys. Lets a caller —
39
+ human or agent — catch a filters-vs-pinned-IDs mismatch (or a wholly blank
40
+ report) before sharing the link: a report built from a natural-language
41
+ prompt yields predicate filters and pins *nothing*, so "pinned: none" is
42
+ the tell that it doesn't contain the specific records the user named.
43
+ """
44
+ filterset = config.get("filterset") or {}
45
+ pinned = {
46
+ entity: len(filterset[entity])
47
+ for entity in _PIN_ENTITIES
48
+ if isinstance(filterset.get(entity), list) and filterset[entity]
49
+ }
50
+ skip = set(_PIN_ENTITIES) | {f"exclude_{e}" for e in _PIN_ENTITIES} | _NON_PREDICATE_KEYS
51
+ filters = sorted(
52
+ key
53
+ for key, value in filterset.items()
54
+ if key not in skip and value not in (None, "", [], {}, False)
55
+ )
56
+ return {
57
+ "report_type": REPORT_TYPE_LABELS.get(config.get("report_type"), config.get("report_type")),
58
+ "pinned": pinned,
59
+ "filters": filters,
60
+ }
61
+
62
+
63
+ def _render_contents_line(summary: dict) -> str:
64
+ """One-line human rendering of a `_summarize_report_contents` result."""
65
+ pinned = summary.get("pinned") or {}
66
+ pin_str = ", ".join(f"{count} {entity}" for entity, count in pinned.items()) if pinned else "none"
67
+ filters = summary.get("filters") or []
68
+ filt_str = ", ".join(filters) if filters else "none"
69
+ return f"Contents: {summary.get('report_type')} report · pinned: {pin_str} · filters: {filt_str}"
70
+
71
+
72
+ def _print_contents_summary(summary: dict) -> None:
73
+ """Surface a saved report's contents on stderr (safe in every output mode).
74
+
75
+ A report with no pinned entities *and* no filters gets a loud warning —
76
+ that blank/default state is the failure behind "you sent me an empty
77
+ report". Otherwise a dim one-liner lets the caller confirm the report holds
78
+ what the user actually asked for.
79
+ """
80
+ line = _render_contents_line(summary)
81
+ if not summary.get("pinned") and not summary.get("filters"):
82
+ err.print(
83
+ f"[yellow]⚠ {line}\n"
84
+ f" This report has no filters and no pinned entities — it will show "
85
+ f"a blank/default view.[/yellow]"
86
+ )
87
+ else:
88
+ err.print(f"[dim]{line}[/dim]")
89
+
25
90
 
26
91
  @app.callback(invoke_without_command=True)
27
92
  def reports(
@@ -330,6 +395,13 @@ def create_report(
330
395
  With a prompt, runs the AI Report Builder pipeline (keyword research, config
331
396
  generation, review) and saves the resulting campaign.
332
397
 
398
+ Have specific IDs already? A report of *exactly* the channels / brands /
399
+ sponsorships / articles you already have the IDs for is a different job —
400
+ use `tl reports save-list <entity> --ids-file` to pin those IDs into a new
401
+ report, or `tl bulk-import <entity> -c <report-id>` to add them to an
402
+ existing one. A natural-language prompt here builds *predicate filters* and
403
+ pins none of those IDs, so the report comes back showing unrelated records.
404
+
333
405
  With --config '<json>' or --config-file <path>, skips the orchestration
334
406
  pipeline and saves the provided config directly. Useful when an external
335
407
  agent (e.g. the tl-report-builder Claude Code skill) has already produced a
@@ -404,6 +476,13 @@ def create_report(
404
476
  report_url = result.get("report_url", "")
405
477
  campaign_id = result.get("campaign_id", "")
406
478
 
479
+ # Echo what the report actually contains. Surfaced even under
480
+ # --yes/--json (the agent path), so a report built from a prompt —
481
+ # which yields predicate filters and pins no specific IDs — can be
482
+ # spotted before its link is shared.
483
+ summary = _summarize_report_contents(config)
484
+ data["report_contents"] = summary
485
+
407
486
  if toon_output:
408
487
  print(toon_encode(data))
409
488
  elif json_output:
@@ -422,6 +501,8 @@ def create_report(
422
501
  if usage:
423
502
  err.print(f"\n [dim]{usage.get('credits_charged', 0)} credits · {usage.get('balance_remaining', '?')} remaining[/dim]")
424
503
 
504
+ _print_contents_summary(summary)
505
+
425
506
  except ApiError as e:
426
507
  handle_api_error(e)
427
508
  finally:
@@ -541,23 +622,26 @@ def save_list_cmd(
541
622
  finally:
542
623
  client.close()
543
624
 
625
+ summary = _summarize_report_contents(config)
626
+ data["report_contents"] = summary
627
+
544
628
  if fmt == "toon":
545
629
  print(toon_encode(data))
546
- return
547
- if fmt == "json":
630
+ elif fmt == "json":
548
631
  print(json.dumps(data, indent=2, default=str))
549
- return
632
+ else:
633
+ results = data.get("results", [{}])
634
+ result = results[0] if results else {}
635
+ err.print()
636
+ err.print("[green bold]Report created![/green bold]")
637
+ err.print(f" Campaign ID: {result.get('campaign_id', '?')}")
638
+ err.print(f" URL: https://app.thoughtleaders.io{result.get('report_url', '')}")
639
+ err.print(
640
+ "\n[dim]Refine columns, widgets, title, or description with "
641
+ "`tl reports update <id>`.[/dim]"
642
+ )
550
643
 
551
- results = data.get("results", [{}])
552
- result = results[0] if results else {}
553
- err.print()
554
- err.print("[green bold]Report created![/green bold]")
555
- err.print(f" Campaign ID: {result.get('campaign_id', '?')}")
556
- err.print(f" URL: https://app.thoughtleaders.io{result.get('report_url', '')}")
557
- err.print(
558
- "\n[dim]Refine columns, widgets, title, or description with "
559
- "`tl reports update <id>`.[/dim]"
560
- )
644
+ _print_contents_summary(summary)
561
645
 
562
646
 
563
647
  @app.command("update")
tl_cli/auth/finalize.py DELETED
@@ -1,88 +0,0 @@
1
- """Server-side signup finalize, called once per login.
2
-
3
- After Auth0 returns a valid token the CLI asks the server whether an
4
- account exists for the email. If yes, this is a no-op. If no, the CLI
5
- prompts for a persona (Media Buyer or Creator) and POSTs it back; the
6
- server creates the User, Organization, Profile and CreditAccount.
7
-
8
- Errors here never abort login — the user can always retry the prompt
9
- on the next call. We do print a clear message so it's obvious whether
10
- the account is fully set up.
11
- """
12
-
13
- from __future__ import annotations
14
-
15
- import typer
16
- from rich.console import Console
17
- from rich.prompt import Prompt
18
-
19
- from tl_cli.client.errors import ApiError
20
- from tl_cli.client.http import get_client
21
-
22
- console = Console(stderr=True)
23
-
24
- PERSONA_LABEL_TO_KEY = {
25
- "Media Buyer": "media_buyer",
26
- "Creator": "creator",
27
- }
28
-
29
-
30
- def finalize_signup() -> None:
31
- """POST /auth/finalize, prompting for persona if the server asks for one."""
32
- client = get_client()
33
- try:
34
- # First call: no body. Server tells us whether persona is required.
35
- try:
36
- result = client.post("/auth/finalize", {})
37
- except ApiError as exc:
38
- if exc.status_code == 400 and isinstance(exc.raw, dict) and exc.raw.get("code") == "persona_required":
39
- result = _prompt_and_finalize(client, exc.raw.get("allowed_personas") or [])
40
- elif exc.status_code == 404:
41
- # Server predates this endpoint — silently skip; legacy
42
- # accounts already exist and don't need provisioning.
43
- return
44
- else:
45
- console.print(f"[yellow]Could not finalize signup: {exc.detail}[/yellow]")
46
- return
47
-
48
- if result.get("created"):
49
- org = result.get("organization", {})
50
- console.print(
51
- f"[green]Account created for {org.get('name', 'your organization')}.[/green] "
52
- "Run [bold]tl balance[/bold] to see your starter credits."
53
- )
54
- finally:
55
- client.close()
56
-
57
-
58
- def _prompt_and_finalize(client, allowed: list[str]) -> dict:
59
- """Prompt the user for a persona, then retry /auth/finalize."""
60
- console.print()
61
- console.print("[bold]Welcome to ThoughtLeaders![/bold] We need one more detail to set up your account.")
62
- console.print(" [cyan]1[/cyan] — Media Buyer (brands and agencies buying sponsorships)")
63
- console.print(" [cyan]2[/cyan] — Creator (channels selling sponsorships)")
64
-
65
- persona_key: str | None = None
66
- while persona_key is None:
67
- choice = Prompt.ask("I am a", choices=["1", "2"], default="1", console=console)
68
- candidate = "media_buyer" if choice == "1" else "creator"
69
- if allowed and candidate not in allowed:
70
- console.print(f"[yellow]Server rejects persona '{candidate}'. Allowed: {', '.join(allowed)}.[/yellow]")
71
- continue
72
- persona_key = candidate
73
-
74
- org_name = Prompt.ask(
75
- "Organization name (optional, leave blank to use your email)",
76
- default="",
77
- console=console,
78
- ).strip()
79
-
80
- body = {"persona": persona_key}
81
- if org_name:
82
- body["organization_name"] = org_name
83
-
84
- try:
85
- return client.post("/auth/finalize", body)
86
- except ApiError as exc:
87
- console.print(f"[red]Signup failed:[/red] {exc.detail}")
88
- raise typer.Exit(1)