content-grade 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -21,7 +21,10 @@ npx content-grade
21
21
  # 3. Analyze your own content
22
22
  npx content-grade ./my-post.md
23
23
 
24
- # 4. Grade a single headline
24
+ # 4. Analyze a live URL directly
25
+ npx content-grade https://yoursite.com/blog/post
26
+
27
+ # 5. Grade a single headline
25
28
  npx content-grade headline "Why Most Startups Fail at Month 18"
26
29
  ```
27
30
 
@@ -72,11 +75,7 @@ npx content-grade headline "Why Most Startups Fail at Month 18"
72
75
  1. Why 90% of SaaS Startups Fail at Month 18 (and How to Be the 10%)
73
76
  2. The Month 18 Startup Trap: What Kills Growth-Stage Companies
74
77
 
75
- Free analysis complete. Pro unlocks:
76
- · Competitor headline comparison
77
- · Landing page URL audit (full CRO analysis)
78
- · Ad copy scoring (Google, Meta, LinkedIn)
79
- · 100 analyses/day vs 3 free
78
+ Unlock team features at contentgrade.dev
80
79
  ```
81
80
 
82
81
  ---
@@ -86,6 +85,7 @@ npx content-grade headline "Why Most Startups Fail at Month 18"
86
85
  | Command | What it does |
87
86
  |---------|-------------|
88
87
  | *(no args)* | Instant demo on built-in sample content |
88
+ | `<url>` | Fetch and analyze a live URL — `npx content-grade https://example.com/blog/post` |
89
89
  | `<file>` | Analyze a file directly — `npx content-grade ./post.md` |
90
90
  | `.` or `<dir>` | Scan a directory, find and analyze the best content file |
91
91
  | `demo` | Same as no args |
@@ -96,8 +96,17 @@ npx content-grade headline "Why Most Startups Fail at Month 18"
96
96
  | `grade "<text>"` | Alias for `headline` |
97
97
  | `init` | First-run setup: verify Claude CLI, run smoke test |
98
98
  | `start` | Launch the full web dashboard (6 tools) |
99
+ | `telemetry [on\|off]` | View or toggle anonymous usage tracking |
99
100
  | `help` | Full usage and examples |
100
101
 
102
+ **Global flags:**
103
+
104
+ | Flag | Description |
105
+ |------|-------------|
106
+ | `--no-telemetry` | Skip usage tracking for this one invocation |
107
+ | `--version`, `-v`, `-V` | Show installed version |
108
+ | `--help`, `-h` | Show help |
109
+
101
110
  ---
102
111
 
103
112
  ## The 6 web dashboard tools
@@ -113,7 +122,7 @@ Launch with `content-grade start` — opens at [http://localhost:4000](http://lo
113
122
  | **EmailForge** | `/email-forge` | Subject line + body copy for click-through optimization |
114
123
  | **AudienceDecoder** | `/audience` | Twitter handle → audience archetypes and content patterns |
115
124
 
116
- Free tier: **3 analyses/day per tool**. Pro ($9/mo): **100 analyses/day** + all tools.
125
+ Free tier: **50 analyses/day per tool**. Pro ($9/mo): **100 analyses/day** + all tools.
117
126
 
118
127
  ---
119
128
 
@@ -207,6 +216,26 @@ Use this when something isn't working — it tells you exactly what to fix.
207
216
 
208
217
  ---
209
218
 
219
+ ### `telemetry`
220
+
221
+ ```bash
222
+ content-grade telemetry # show current status
223
+ content-grade telemetry off # opt out — persisted permanently
224
+ content-grade telemetry on # opt back in
225
+ ```
226
+
227
+ Anonymous usage tracking (command name + score range, no file contents, no PII). Enabled by default; `telemetry off` writes a local flag file and is honoured by all future invocations.
228
+
229
+ **One-time opt-out per invocation:**
230
+
231
+ ```bash
232
+ content-grade analyze ./post.md --no-telemetry
233
+ ```
234
+
235
+ Pass `--no-telemetry` to any command to skip tracking for that run only without changing the saved preference.
236
+
237
+ ---
238
+
210
239
  ### `start` / `serve`
211
240
 
212
241
  ```bash
@@ -312,6 +341,353 @@ npm run test:coverage # coverage report
312
341
 
313
342
  ---
314
343
 
344
+ ## Output format
345
+
346
+ When `content-grade analyze` runs, Claude returns structured JSON that is rendered to the terminal. The raw schema:
347
+
348
+ ```json
349
+ {
350
+ "content_type": "blog | email | ad | social | landing",
351
+ "total_score": 72,
352
+ "grade": "B+",
353
+ "headline": {
354
+ "text": "Why Most Startups Fail",
355
+ "score": 61,
356
+ "feedback": "Too vague — the reader doesn't know if this applies to them."
357
+ },
358
+ "dimensions": {
359
+ "clarity": { "score": 80, "note": "Well-organized with clear section breaks." },
360
+ "engagement": { "score": 60, "note": "Opens with a statistic but drops momentum in paragraph 3." },
361
+ "structure": { "score": 72, "note": "Good use of subheadings but the conclusion is thin." },
362
+ "value_delivery": { "score": 65, "note": "Core advice is solid but needs a concrete takeaway." }
363
+ },
364
+ "one_line_verdict": "Strong structure undermined by a weak headline — fix that first.",
365
+ "strengths": [
366
+ "Well-organized with clear section breaks",
367
+ "Specific statistics in the opening hook"
368
+ ],
369
+ "improvements": [
370
+ {
371
+ "issue": "Headline is too vague",
372
+ "priority": "high",
373
+ "fix": "Why 90% of SaaS Startups Fail at Month 18 (and How to Be the 10%)"
374
+ },
375
+ {
376
+ "issue": "Paragraph 2 makes claims without evidence",
377
+ "priority": "medium",
378
+ "fix": "Cite a specific study — 'CB Insights found...' beats 'many startups...'"
379
+ }
380
+ ],
381
+ "headline_rewrites": [
382
+ "Why 90% of SaaS Startups Fail at Month 18 (and How to Be the 10%)",
383
+ "The Month 18 Startup Trap: What Kills Growth-Stage Companies"
384
+ ]
385
+ }
386
+ ```
387
+
388
+ For `content-grade headline`, the schema:
389
+
390
+ ```json
391
+ {
392
+ "score": 74,
393
+ "grade": "B",
394
+ "verdict": "Strong promise but lacks the proof element that separates a 74 from an 88.",
395
+ "scores": {
396
+ "rule_of_one": { "score": 22, "max": 30, "note": "Single idea present but promise is vague." },
397
+ "value_equation": { "score": 22, "max": 30, "note": "Dream outcome clear; likelihood undermined by '10x' without proof." },
398
+ "readability": { "score": 16, "max": 20, "note": "Short, no jargon — reads well." },
399
+ "proof_promise_plan": { "score": 14, "max": 20, "note": "Timeframe adds proof; missing the 'how'." }
400
+ },
401
+ "rewrites": [
402
+ "How I Doubled Conversions in 30 Days by Fixing One Headline",
403
+ "The 3 Headline Fixes That Grew My Conversions 10x (Backed by 847 A/B Tests)"
404
+ ]
405
+ }
406
+ ```
407
+
408
+ ---
409
+
410
+ ## Scoring methodology
411
+
412
+ ContentGrade uses Claude as a scoring engine with **calibrated anchor examples** that force use of the full 0–100 range. This prevents the common AI problem of all scores bunching in the 60–80 band.
413
+
414
+ **Score thresholds (for `analyze`):**
415
+
416
+ | Score | What it means |
417
+ |-------|--------------|
418
+ | 90–100 | Exceptional — data authority, curiosity gap, ultra-specific, publication-ready |
419
+ | 80–89 | Strong — clear value equation, good proof, specific promise |
420
+ | 65–79 | Good — readable, structured, some specificity gaps |
421
+ | 50–64 | Adequate — readable but vague, generic structure |
422
+ | 35–49 | Poor — clichés, no hook, commodity topic |
423
+ | 0–34 | Very weak — no structure, zero reader benefit, or content too short |
424
+
425
+ **Dimensions:**
426
+
427
+ - **Clarity** — Organization, section breaks, readability. Does the reader always know where they are?
428
+ - **Engagement** — Hook strength, momentum, reader retention. Would someone read to the end?
429
+ - **Structure** — Heading hierarchy, flow, conclusion strength. Is there a logical arc?
430
+ - **Value Delivery** — Concrete advice, takeaways, actionable insights. Does the reader leave with something useful?
431
+
432
+ **Content-type calibration:** The scoring prompt knows it's reading a blog post vs. an email vs. ad copy. A 200-word email doesn't get penalized for "thin structure" the way a blog post would.
433
+
434
+ **Headline framework calibration anchors:**
435
+
436
+ | Score range | What it takes |
437
+ |-------------|--------------|
438
+ | 95+ | Data authority + curiosity gap + ultra-specificity + clear reader identity |
439
+ | 88–92 | Strong proof + promise + plan, low jargon, 6–10 words |
440
+ | 75–84 | Clear value equation, objection handling, some specificity |
441
+ | 65–74 | Clear differentiator or positioning, but vague on proof |
442
+ | 50–64 | Decent structure but generic or lacking urgency |
443
+ | 35–49 | Standard cliché phrasing, no hook element |
444
+ | 0–34 | Commodity topic, passive voice, zero benefit stated |
445
+
446
+ ---
447
+
448
+ ## Programmatic use (REST API)
449
+
450
+ Start the server with `content-grade start`, then call any tool via HTTP:
451
+
452
+ ### Grade a headline
453
+
454
+ ```bash
455
+ curl -s -X POST http://localhost:4000/api/demos/headline-grader \
456
+ -H 'Content-Type: application/json' \
457
+ -d '{"headline": "Why Most Startups Fail at Month 18"}' | jq .
458
+ ```
459
+
460
+ Response:
461
+ ```json
462
+ {
463
+ "total_score": 74,
464
+ "grade": "B",
465
+ "diagnosis": "Strong promise but lacks the proof element that separates a 74 from an 88.",
466
+ "framework_scores": {
467
+ "rule_of_one": { "score": 22, "max": 30, "note": "..." },
468
+ "value_equation": { "score": 22, "max": 30, "note": "..." },
469
+ "readability": { "score": 16, "max": 20, "note": "..." },
470
+ "proof_promise_plan": { "score": 14, "max": 20, "note": "..." }
471
+ },
472
+ "rewrites": ["...", "..."],
473
+ "usage": { "remaining": 2, "limit": 3, "isPro": false }
474
+ }
475
+ ```
476
+
477
+ ### Compare two headlines (Pro)
478
+
479
+ ```bash
480
+ curl -s -X POST http://localhost:4000/api/demos/headline-grader/compare \
481
+ -H 'Content-Type: application/json' \
482
+ -d '{
483
+ "headlineA": "Why Most Startups Fail",
484
+ "headlineB": "Why 90% of SaaS Startups Fail at Month 18",
485
+ "email": "you@example.com"
486
+ }' | jq .
487
+ ```
488
+
489
+ ### Audit a landing page URL (Pro)
490
+
491
+ ```bash
492
+ curl -s -X POST http://localhost:4000/api/demos/page-roast \
493
+ -H 'Content-Type: application/json' \
494
+ -d '{"url": "https://example.com", "email": "you@example.com"}' | jq .
495
+ ```
496
+
497
+ ### Score ad copy
498
+
499
+ ```bash
500
+ curl -s -X POST http://localhost:4000/api/demos/ad-scorer \
501
+ -H 'Content-Type: application/json' \
502
+ -d '{
503
+ "adCopy": "Stop wasting money on ads that don'\''t convert.",
504
+ "platform": "facebook",
505
+ "email": "you@example.com"
506
+ }' | jq .
507
+ ```
508
+
509
+ ### Grade a Twitter thread
510
+
511
+ ```bash
512
+ curl -s -X POST http://localhost:4000/api/demos/thread-grader \
513
+ -H 'Content-Type: application/json' \
514
+ -d '{
515
+ "threadText": "1/ Most people think productivity is about working more hours...\n\n2/ They'\''re wrong.",
516
+ "email": "you@example.com"
517
+ }' | jq .
518
+ ```
519
+
520
+ ### Generate an email
521
+
522
+ ```bash
523
+ curl -s -X POST http://localhost:4000/api/demos/email-forge \
524
+ -H 'Content-Type: application/json' \
525
+ -d '{
526
+ "product": "A CLI tool that grades content quality",
527
+ "audience": "developers who write technical blog posts",
528
+ "goal": "cold_outreach",
529
+ "tone": "casual",
530
+ "email": "you@example.com"
531
+ }' | jq .
532
+ ```
533
+
534
+ **Rate limit response** (when daily free limit is hit):
535
+ ```json
536
+ {
537
+ "gated": true,
538
+ "isPro": false,
539
+ "remaining": 0,
540
+ "limit": 50,
541
+ "message": "Free daily limit reached (50/day). Get 100 analyses/day with Pro"
542
+ }
543
+ ```
544
+
545
+ See [`docs/api.md`](./docs/api.md) for the full reference — every endpoint, complete request/response shapes, and more cURL examples.
546
+
547
+ ---
548
+
549
+ ## Workflows & integrations
550
+
551
+ ### GitHub Actions — CI content quality gate
552
+
553
+ Fail the build if content quality drops below a threshold. Useful for content-heavy repos (marketing site, docs, blog).
554
+
555
+ ```yaml
556
+ # .github/workflows/content-quality.yml
557
+ name: Content quality check
558
+
559
+ on:
560
+ pull_request:
561
+ paths:
562
+ - 'content/**'
563
+ - 'blog/**'
564
+ - '*.md'
565
+
566
+ jobs:
567
+ grade:
568
+ runs-on: ubuntu-latest
569
+ steps:
570
+ - uses: actions/checkout@v4
571
+
572
+ - name: Install Node.js
573
+ uses: actions/setup-node@v4
574
+ with:
575
+ node-version: '20'
576
+
577
+ - name: Install Claude CLI
578
+ run: npm install -g @anthropic-ai/claude-code
579
+
580
+ - name: Login to Claude (non-interactive)
581
+ run: echo "${{ secrets.ANTHROPIC_API_KEY }}" | claude login --api-key
582
+ # Note: Claude CLI requires authentication. Store your API key in GitHub secrets.
583
+
584
+ - name: Grade changed content
585
+ run: |
586
+ for f in $(git diff --name-only origin/main...HEAD | grep -E '\.(md|txt|mdx)$'); do
587
+ echo "=== Grading $f ==="
588
+ npx content-grade analyze "$f" --no-telemetry
589
+ done
590
+ ```
591
+
592
+ > **Note:** Claude CLI must be authenticated. In CI, this requires an Anthropic API key. Set `ANTHROPIC_API_KEY` in your repository secrets and use it to log in.
593
+
594
+ ---
595
+
596
+ ### Pre-commit hook
597
+
598
+ Grade content before it enters the repo. Add this to `.git/hooks/pre-commit` (make it executable with `chmod +x .git/hooks/pre-commit`):
599
+
600
+ ```bash
601
+ #!/bin/sh
602
+ # Content quality pre-commit hook
603
+ # Grades staged .md/.txt files and blocks commit if any score below threshold
604
+
605
+ THRESHOLD=40
606
+
607
+ staged=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(md|txt|mdx)$')
608
+
609
+ if [ -z "$staged" ]; then
610
+ exit 0
611
+ fi
612
+
613
+ echo "Running ContentGrade on staged files..."
614
+
615
+ for file in $staged; do
616
+ # Only check files over 100 characters (skip tiny files)
617
+ chars=$(wc -c < "$file" 2>/dev/null || echo 0)
618
+ if [ "$chars" -lt 100 ]; then
619
+ continue
620
+ fi
621
+
622
+ echo " Grading $file..."
623
+ npx content-grade analyze "$file" --no-telemetry
624
+ done
625
+
626
+ echo "✓ Content quality check complete."
627
+ exit 0
628
+ ```
629
+
630
+ To block low-scoring commits, parse the score from output and compare against `$THRESHOLD`. The current output format prints `OVERALL SCORE 72/100` — grep for the number and exit 1 if below threshold.
631
+
632
+ ---
633
+
634
+ ### Batch processing a directory
635
+
636
+ Grade every content file in a directory and save results:
637
+
638
+ ```bash
639
+ # Grade all markdown files and save output
640
+ find ./content -name '*.md' -not -name 'README.md' | while read f; do
641
+ echo "--- $f ---"
642
+ npx content-grade analyze "$f" --no-telemetry
643
+ echo ""
644
+ done > content-grades-$(date +%Y%m%d).txt
645
+
646
+ # Or use the built-in directory scan (picks the best candidate):
647
+ npx content-grade ./content
648
+ ```
649
+
650
+ ---
651
+
652
+ ### Comparing scores over time
653
+
654
+ Track score progression across revisions:
655
+
656
+ ```bash
657
+ # Score the current version of a post
658
+ npx content-grade analyze ./blog/my-post.md --no-telemetry > scores/my-post-$(date +%Y%m%d).txt
659
+
660
+ # Compare two versions side-by-side
661
+ diff scores/my-post-20240101.txt scores/my-post-20240201.txt
662
+
663
+ # Quick numeric comparison
664
+ grep "OVERALL SCORE" scores/my-post-*.txt
665
+ ```
666
+
667
+ For structured tracking, use the REST API (run `content-grade start` first):
668
+
669
+ ```bash
670
+ # Score via API, extract just the number
671
+ curl -s -X POST http://localhost:4000/api/demos/headline-grader \
672
+ -H 'Content-Type: application/json' \
673
+ -d '{"headline": "Your Post Title Here"}' \
674
+ | jq '.total_score'
675
+ ```
676
+
677
+ Log to a CSV:
678
+
679
+ ```bash
680
+ DATE=$(date +%Y-%m-%d)
681
+ HEADLINE="Your Post Title Here"
682
+ SCORE=$(curl -s -X POST http://localhost:4000/api/demos/headline-grader \
683
+ -H 'Content-Type: application/json' \
684
+ -d "{\"headline\": \"$HEADLINE\"}" | jq '.total_score')
685
+
686
+ echo "$DATE,$HEADLINE,$SCORE" >> headline-scores.csv
687
+ ```
688
+
689
+ ---
690
+
315
691
  ## Pricing
316
692
 
317
693
  | | Free | Pro |
@@ -18,6 +18,8 @@ import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync, statSyn
18
18
  import { resolve, dirname, basename, extname } from 'path';
19
19
  import { fileURLToPath } from 'url';
20
20
  import { promisify } from 'util';
21
+ import { get as httpsGet } from 'https';
22
+ import { get as httpGet } from 'http';
21
23
  import { initTelemetry, recordEvent, disableTelemetry, enableTelemetry, telemetryStatus, isOptedOut } from './telemetry.js';
22
24
 
23
25
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -187,7 +189,7 @@ async function cmdAnalyze(filePath) {
187
189
  blank();
188
190
  console.log(` ${D}No file? Try the demo: ${CY}content-grade demo${R}`);
189
191
  blank();
190
- process.exit(1);
192
+ process.exit(2);
191
193
  }
192
194
 
193
195
  const absPath = resolve(process.cwd(), filePath);
@@ -198,7 +200,7 @@ async function cmdAnalyze(filePath) {
198
200
  console.log(` ${YL}Check the path and try again.${R}`);
199
201
  console.log(` ${D}Tip: use a relative path like ./my-file.md or an absolute path.${R}`);
200
202
  blank();
201
- process.exit(1);
203
+ process.exit(2);
202
204
  }
203
205
 
204
206
  // Guard: reject directories
@@ -209,7 +211,7 @@ async function cmdAnalyze(filePath) {
209
211
  blank();
210
212
  console.log(` ${D}Pass a text file (.md, .txt) — not a directory.${R}`);
211
213
  blank();
212
- process.exit(1);
214
+ process.exit(2);
213
215
  }
214
216
 
215
217
  // Guard: reject files over 500 KB before reading into memory
@@ -220,7 +222,7 @@ async function cmdAnalyze(filePath) {
220
222
  blank();
221
223
  console.log(` ${YL}Tip:${R} Copy the relevant section into a new file and analyze that.`);
222
224
  blank();
223
- process.exit(1);
225
+ process.exit(2);
224
226
  }
225
227
 
226
228
  const content = readFileSync(absPath, 'utf8');
@@ -233,20 +235,22 @@ async function cmdAnalyze(filePath) {
233
235
  console.log(` ${YL}ContentGrade analyzes written content — blog posts, emails, ad copy, landing pages.${R}`);
234
236
  console.log(` ${D}Supported formats: .md, .txt, .mdx, or any plain-text file.${R}`);
235
237
  blank();
236
- process.exit(1);
238
+ process.exit(2);
237
239
  }
238
240
 
239
241
  if (content.trim().length < 20) {
240
242
  blank();
241
243
  fail(`File is too short to analyze (${content.trim().length} chars). Add some content and try again.`);
242
244
  blank();
243
- process.exit(1);
245
+ process.exit(2);
244
246
  }
245
247
 
246
- banner();
247
- console.log(` ${B}Analyzing:${R} ${CY}${basename(absPath)}${R}`);
248
- console.log(` ${D}${content.length.toLocaleString()} characters · detecting content type...${R}`);
249
- blank();
248
+ if (!_jsonMode && !_quietMode) {
249
+ banner();
250
+ console.log(` ${B}Analyzing:${R} ${CY}${basename(absPath)}${R}`);
251
+ console.log(` ${D}${content.length.toLocaleString()} characters · detecting content type...${R}`);
252
+ blank();
253
+ }
250
254
 
251
255
  // Check Claude
252
256
  if (!checkClaude()) {
@@ -271,7 +275,7 @@ async function cmdAnalyze(filePath) {
271
275
 
272
276
  const truncated = content.length > 6000 ? content.slice(0, 6000) + '\n\n[Content truncated for analysis]' : content;
273
277
 
274
- process.stdout.write(` ${D}Running analysis (this takes ~15 seconds)...${R}`);
278
+ if (!_jsonMode && !_quietMode) process.stdout.write(` ${D}Running analysis (this takes ~15 seconds)...${R}`);
275
279
 
276
280
  let result;
277
281
  try {
@@ -280,9 +284,12 @@ async function cmdAnalyze(filePath) {
280
284
  ANALYZE_SYSTEM,
281
285
  'claude-sonnet-4-6'
282
286
  );
283
- process.stdout.write(`\r ${GN}✓${R} Analysis complete${' '.repeat(30)}\n`);
287
+ if (!_jsonMode && !_quietMode) process.stdout.write(`\r ${GN}✓${R} Analysis complete${' '.repeat(30)}\n`);
284
288
  result = parseJSON(raw);
285
289
  recordEvent({ event: 'analyze_result', score: result.total_score, content_type: result.content_type });
290
+ // Machine-readable output modes (exit cleanly, skip styled output)
291
+ if (_jsonMode) { process.stdout.write(JSON.stringify(result, null, 2) + '\n'); return; }
292
+ if (_quietMode) { process.stdout.write(`${result.total_score}\n`); return; }
286
293
  } catch (err) {
287
294
  process.stdout.write(`\n`);
288
295
  blank();
@@ -373,18 +380,9 @@ async function cmdAnalyze(filePath) {
373
380
  blank();
374
381
  }
375
382
 
376
- // ── Pro teaser
377
- hr();
378
- console.log(` ${D}Free analysis complete. ${MG}Pro unlocks:${R}`);
379
- console.log(` ${D} · Competitor headline comparison${R}`);
380
- console.log(` ${D} · Landing page URL audit (full CRO analysis)${R}`);
381
- console.log(` ${D} · Ad copy scoring (Google, Meta, LinkedIn)${R}`);
382
- console.log(` ${D} · Twitter thread grader with shareability score${R}`);
383
- console.log(` ${D} · Email subject line optimizer${R}`);
384
- console.log(` ${D} · 100 analyses/day vs 3 free${R}`);
383
+ // ── Subtle upsell
385
384
  blank();
386
- console.log(` ${D}Start the web dashboard: ${CY}content-grade start${R}`);
387
- console.log(` ${D}Grade a headline: ${CY}content-grade headline "Your text here"${R}`);
385
+ console.log(` ${D}Unlock team features at ${CY}contentgrade.dev${R}`);
388
386
  blank();
389
387
  }
390
388
 
@@ -579,7 +577,7 @@ async function cmdInit() {
579
577
  console.log(` ${CY}content-grade start${R}`);
580
578
  blank();
581
579
  }
582
- console.log(` ${D}Pro tier ($9/mo): 100 analyses/day + competitor comparison + URL audits${R}`);
580
+ console.log(` ${D}Pro tier ($9/mo): 100 analyses/day (vs 50 free) + competitor comparison + URL audits${R}`);
583
581
  blank();
584
582
  }
585
583
 
@@ -657,7 +655,7 @@ function cmdStart() {
657
655
  info(` EmailForge — ${url}/email-forge`);
658
656
  info(` AudienceDecoder — ${url}/audience`);
659
657
  blank();
660
- info(`Free tier: 3 analyses/day. Upgrade at ${url}`);
658
+ info(`Free tier: 50 analyses/day. Upgrade at ${url}`);
661
659
  info(`Press Ctrl+C to stop`);
662
660
  blank();
663
661
  openBrowser(url);
@@ -758,7 +756,7 @@ function cmdHelp() {
758
756
 
759
757
  console.log(` ${B}PRO TIER${R} ${MG}$9/month${R}`);
760
758
  blank();
761
- console.log(` · 100 analyses/day (vs 3 free)`);
759
+ console.log(` · 100 analyses/day (vs 50 free)`);
762
760
  console.log(` · Competitor headline A/B comparison`);
763
761
  console.log(` · Landing page URL audit`);
764
762
  console.log(` · Ad copy scoring (Google, Meta, LinkedIn)`);
@@ -787,6 +785,18 @@ In conclusion, these productivity tips are very helpful. Try them today and you
787
785
  `;
788
786
 
789
787
  async function cmdDemo() {
788
+ // If Claude isn't installed, skip the demo and run guided setup instead
789
+ if (!checkClaude()) {
790
+ console.log('');
791
+ console.log(` ${B}${CY}Welcome to ContentGrade${R}`);
792
+ console.log('');
793
+ console.log(` ${D}ContentGrade needs Claude CLI to run analysis.${R}`);
794
+ console.log(` ${D}Let's get you set up — it only takes a minute.${R}`);
795
+ console.log('');
796
+ await cmdInit();
797
+ return;
798
+ }
799
+
790
800
  const tmpFile = `/tmp/content-grade-demo-${process.pid}-${Date.now()}.md`;
791
801
 
792
802
  banner();
@@ -799,6 +809,107 @@ async function cmdDemo() {
799
809
  blank();
800
810
 
801
811
  writeFileSync(tmpFile, DEMO_CONTENT, 'utf8');
812
+ try {
813
+ await cmdAnalyze(tmpFile);
814
+ // Show telemetry notice after user has seen value (first run only)
815
+ if (_showTelemNotice) {
816
+ console.log(` ${D}Anonymous usage data is collected by default. Opt out: ${CY}content-grade telemetry off${R}`);
817
+ blank();
818
+ }
819
+ } finally {
820
+ try { unlinkSync(tmpFile); } catch {}
821
+ }
822
+ }
823
+
824
+ // ── URL fetcher ───────────────────────────────────────────────────────────────
825
+
826
+ function fetchUrl(url) {
827
+ return new Promise((resolve, reject) => {
828
+ const get = url.startsWith('https') ? httpsGet : httpGet;
829
+ const req = get(url, { headers: { 'User-Agent': 'ContentGrade/1.0 (+https://github.com/StanislavBG/Content-Grade)' }, timeout: 15000 }, (res) => {
830
+ // Follow one redirect
831
+ if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location) {
832
+ fetchUrl(res.headers.location).then(resolve).catch(reject);
833
+ res.resume();
834
+ return;
835
+ }
836
+ if (res.statusCode < 200 || res.statusCode >= 300) {
837
+ reject(new Error(`HTTP ${res.statusCode}`));
838
+ res.resume();
839
+ return;
840
+ }
841
+ const chunks = [];
842
+ res.on('data', c => chunks.push(c));
843
+ res.on('end', () => resolve(Buffer.concat(chunks).toString('utf8', 0, 500000)));
844
+ res.on('error', reject);
845
+ });
846
+ req.on('error', reject);
847
+ req.on('timeout', () => { req.destroy(); reject(new Error('Request timed out')); });
848
+ });
849
+ }
850
+
851
+ function htmlToText(html) {
852
+ return html
853
+ .replace(/<script[\s\S]*?<\/script>/gi, ' ')
854
+ .replace(/<style[\s\S]*?<\/style>/gi, ' ')
855
+ .replace(/<nav[\s\S]*?<\/nav>/gi, ' ')
856
+ .replace(/<footer[\s\S]*?<\/footer>/gi, ' ')
857
+ .replace(/<header[\s\S]*?<\/header>/gi, ' ')
858
+ .replace(/<!--[\s\S]*?-->/g, ' ')
859
+ .replace(/<(h[1-6])[^>]*>([\s\S]*?)<\/\1>/gi, (_, _t, txt) => `\n\n## ${txt}\n\n`)
860
+ .replace(/<(p|li|blockquote)[^>]*>([\s\S]*?)<\/\1>/gi, (_, _t, txt) => `\n${txt}\n`)
861
+ .replace(/<br\s*\/?>/gi, '\n')
862
+ .replace(/<[^>]+>/g, ' ')
863
+ .replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&nbsp;/g, ' ')
864
+ .replace(/[ \t]{2,}/g, ' ')
865
+ .replace(/\n{3,}/g, '\n\n')
866
+ .trim();
867
+ }
868
+
869
+ async function cmdAnalyzeUrl(url) {
870
+ banner();
871
+ console.log(` ${B}Analyzing URL:${R} ${CY}${url}${R}`);
872
+ blank();
873
+
874
+ if (!checkClaude()) {
875
+ fail(`Claude CLI not found.`);
876
+ blank();
877
+ console.log(` ContentGrade uses your local Claude CLI — no API keys needed.`);
878
+ console.log(` Install from ${CY}https://claude.ai/code${R} then run ${CY}claude login${R}`);
879
+ blank();
880
+ process.exit(1);
881
+ }
882
+
883
+ process.stdout.write(` ${D}Fetching page...${R}`);
884
+ let html;
885
+ try {
886
+ html = await fetchUrl(url);
887
+ process.stdout.write(`\r ${GN}✓${R} Page fetched${' '.repeat(20)}\n`);
888
+ } catch (err) {
889
+ process.stdout.write(`\n`);
890
+ blank();
891
+ fail(`Could not fetch URL: ${err.message}`);
892
+ blank();
893
+ console.log(` ${YL}Check:${R}`);
894
+ console.log(` ${D}· URL is accessible (try opening it in a browser)${R}`);
895
+ console.log(` ${D}· You have internet access${R}`);
896
+ blank();
897
+ process.exit(1);
898
+ }
899
+
900
+ const text = htmlToText(html);
901
+ if (text.length < 50) {
902
+ blank();
903
+ fail(`Could not extract readable content from ${url}`);
904
+ blank();
905
+ console.log(` ${D}The page may be JavaScript-rendered. Try saving the page content to a .md file and running:${R}`);
906
+ console.log(` ${CY} content-grade analyze ./page.md${R}`);
907
+ blank();
908
+ process.exit(1);
909
+ }
910
+
911
+ const tmpFile = `/tmp/content-grade-url-${process.pid}-${Date.now()}.md`;
912
+ writeFileSync(tmpFile, `# ${url}\n\n${text}`, 'utf8');
802
913
  try {
803
914
  await cmdAnalyze(tmpFile);
804
915
  } finally {
@@ -853,19 +964,17 @@ function findBestContentFile(dirPath) {
853
964
 
854
965
  // ── Router ────────────────────────────────────────────────────────────────────
855
966
 
856
- const args = process.argv.slice(2).filter(a => a !== '--no-telemetry');
967
+ const _rawArgs = process.argv.slice(2);
968
+ const _jsonMode = _rawArgs.includes('--json');
969
+ const _quietMode = _rawArgs.includes('--quiet');
970
+ const args = _rawArgs.filter(a => a !== '--no-telemetry' && a !== '--json' && a !== '--quiet');
857
971
  const raw = args[0];
858
972
  const cmd = raw?.toLowerCase();
859
973
 
860
974
  // ── Telemetry init ────────────────────────────────────────────────────────────
861
975
  const _telem = initTelemetry();
862
- if (_telem.isNew) {
863
- // Show notice once, on first run
864
- blank();
865
- console.log(` ${D}ContentGrade collects anonymous usage data (command name, score, duration).${R}`);
866
- console.log(` ${D}No file contents, no PII. To opt out: ${CY}content-grade telemetry off${R}${D} or pass ${CY}--no-telemetry${R}`);
867
- blank();
868
- }
976
+ // Defer first-run telemetry notice so users see value first
977
+ const _showTelemNotice = _telem.isNew;
869
978
 
870
979
  // Smart path detection: first arg is a path if it starts with ., /, ~ or is an existing FS entry
871
980
  function looksLikePath(s) {
@@ -984,7 +1093,15 @@ switch (cmd) {
984
1093
  break;
985
1094
 
986
1095
  default:
987
- if (looksLikePath(raw)) {
1096
+ if (/^https?:\/\//i.test(raw)) {
1097
+ recordEvent({ event: 'command', command: 'analyze_url' });
1098
+ cmdAnalyzeUrl(raw).catch(err => {
1099
+ blank();
1100
+ fail(`Unexpected error: ${err.message}`);
1101
+ blank();
1102
+ process.exit(1);
1103
+ });
1104
+ } else if (looksLikePath(raw)) {
988
1105
  // Directory: find best content file inside it
989
1106
  let target;
990
1107
  try {
@@ -5,7 +5,7 @@ import { getDb } from '../db.js';
5
5
  import { askClaude } from '../claude.js';
6
6
  import { hasActiveSubscriptionLive, hasPurchased } from '../services/stripe.js';
7
7
  // ── Usage tracking utilities ──────────────────────────────────────
8
- const FREE_TIER_LIMIT = 3;
8
+ const FREE_TIER_LIMIT = 50;
9
9
  const PRO_TIER_LIMIT = 100;
10
10
  const HEADLINE_GRADER_ENDPOINT = 'headline-grader';
11
11
  const UPGRADE_URL = 'https://contentgrade.ai/#pricing';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "content-grade",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AI-powered content analysis CLI. Score any blog post, landing page, or ad copy in under 30 seconds — runs on Claude CLI, no API key needed.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,7 +50,12 @@
50
50
  "test:watch": "vitest",
51
51
  "test:coverage": "vitest run --coverage",
52
52
  "stats": "node scripts/npm-stats.js",
53
- "stats:week": "node scripts/npm-stats.js --week"
53
+ "stats:week": "node scripts/npm-stats.js --week",
54
+ "metrics": "node scripts/metrics.js",
55
+ "metrics:save": "node scripts/metrics.js --save",
56
+ "metrics:history": "node scripts/metrics.js --history",
57
+ "metrics:csv": "node scripts/metrics.js --csv",
58
+ "github-traffic": "node scripts/github-traffic.js"
54
59
  },
55
60
  "dependencies": {
56
61
  "@fastify/cors": "^9.0.1",