@yasaswy.nagavolu/agents 0.26.13 → 0.26.15
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/content/manifest.json +1 -0
- package/content/skills/html-mocker/audit.js +11 -1
- package/content/skills/html-mocker/tests/test_audit.py +18 -0
- package/content/skills/publish-article/SKILL.md +13 -1
- package/content/skills/publish-article/caption_review.py +124 -0
- package/content/skills/publish-article/html_mock_review.py +20 -0
- package/content/skills/publish-article/publish_article.py +35 -1
- package/content/skills/publish-article/review_store.py +8 -6
- package/content/skills/publish-article/tests/test_caption_review.py +71 -0
- package/content/skills/publish-article/tests/test_html_mock_review.py +40 -1
- package/content/skills/publish-article/tests/test_publish_article.py +92 -0
- package/package.json +1 -1
package/content/manifest.json
CHANGED
|
@@ -1375,6 +1375,7 @@
|
|
|
1375
1375
|
"exclude": [
|
|
1376
1376
|
"tests/test_architecture_review.py",
|
|
1377
1377
|
"tests/test_bundle_skill.py",
|
|
1378
|
+
"tests/test_caption_review.py",
|
|
1378
1379
|
"tests/test_companion_repo_checklist.py",
|
|
1379
1380
|
"tests/test_html_mock_review.py",
|
|
1380
1381
|
"tests/test_learn_feedback.py",
|
|
@@ -19,6 +19,16 @@
|
|
|
19
19
|
return path;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// Content that overflows inside an overflow-x:auto|scroll ancestor is reachable by
|
|
23
|
+
// scrolling that box, so it does not spill off the page.
|
|
24
|
+
function insideScroller(el) {
|
|
25
|
+
for (let a = el.parentElement; a && a !== document.body; a = a.parentElement) {
|
|
26
|
+
const ox = getComputedStyle(a).overflowX;
|
|
27
|
+
if (ox === "auto" || ox === "scroll") return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
function auditLayout() {
|
|
23
33
|
const findings = [];
|
|
24
34
|
const docEl = document.documentElement;
|
|
@@ -74,7 +84,7 @@
|
|
|
74
84
|
});
|
|
75
85
|
}
|
|
76
86
|
|
|
77
|
-
if (style.overflowX === "visible" && rect.left < viewportWidth && rect.right > viewportWidth + 1) {
|
|
87
|
+
if (style.overflowX === "visible" && rect.left < viewportWidth && rect.right > viewportWidth + 1 && !insideScroller(el)) {
|
|
78
88
|
findings.push({
|
|
79
89
|
selector: selectorFor(el),
|
|
80
90
|
kind: "spill-right",
|
|
@@ -70,3 +70,21 @@ def test_genuine_clipped_overflow_without_ellipsis_is_still_error(page_with):
|
|
|
70
70
|
clip_findings = [f for f in findings if f["kind"] == "clipped-overflow-x"]
|
|
71
71
|
assert len(clip_findings) == 1
|
|
72
72
|
assert clip_findings[0]["severity"] == "error"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def test_overflow_inside_scroll_container_is_not_spill_right(page_with):
|
|
76
|
+
html = """<!doctype html><html><body style="margin:0">
|
|
77
|
+
<div style="width:300px;overflow-x:auto;"><table><tr>
|
|
78
|
+
<td style="white-space:nowrap">a very wide table cell that cannot wrap and is wider than the viewport itself</td>
|
|
79
|
+
</tr></table></div>
|
|
80
|
+
</body></html>"""
|
|
81
|
+
findings = page_with(html)
|
|
82
|
+
assert not [f for f in findings if f["kind"] == "spill-right"]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_overflow_without_scroll_container_is_still_spill_right(page_with):
|
|
86
|
+
html = """<!doctype html><html><body style="margin:0">
|
|
87
|
+
<div style="width:300px;"><span style="white-space:nowrap">a very wide unwrappable label that is wider than the viewport itself</span></div>
|
|
88
|
+
</body></html>"""
|
|
89
|
+
findings = page_with(html)
|
|
90
|
+
assert [f for f in findings if f["kind"] == "spill-right"]
|
|
@@ -49,7 +49,8 @@ feedback stops being one-off fixes and becomes the harness. Nothing is live from
|
|
|
49
49
|
| `approve` | `--slug S` | **interactive, human-only, optional** — records a content-bound "I tested this" note; nothing checks it before publish (ADR 0019); aborts non-interactively |
|
|
50
50
|
| `publish` | `--slug S [--no-test]` | build + deploy to prod (no approval gate, ADR 0019) + prod-smoke; prints live URL + LinkedIn draft |
|
|
51
51
|
| `linkedin` | `--slug S` | prints the paste-ready LinkedIn caption |
|
|
52
|
-
| `
|
|
52
|
+
| `caption-review` | `--slug S [--record]` | prints the exact kit caption + media + hash (no flag); `--record` stores the founder's approval for that hash. **Required before any LinkedIn post or edit (`share --post` exits 8 without it)** |
|
|
53
|
+
| `share` | `--slug S [--post [--no-post-click]] [--no-open] [--format {gif,mp4}]` | assembles a review-ready LinkedIn share kit (both `.gif` and `.mp4` always generated, plus caption + `POST.md`); `--format` only picks which one `POST.md` tells you to upload first — default `gif` (flipped from `mp4` on 2026-07-09, see below). `--no-open` skips opening the browser composer + kit folder (CI/headless). `--post` posts the kit via the personal-use LinkedIn browser automation instead of opening the manual composer (ADR 0007 addendum; only available on the author's machine — degrades gracefully to the manual flow elsewhere); `--no-post-click` fills the composer and stops short of clicking Post, for a review run. `--post` exits 8 unless the founder approved the current caption (see Caption approval) |
|
|
53
54
|
|
|
54
55
|
## Rules (judgment the script can't make)
|
|
55
56
|
|
|
@@ -203,6 +204,17 @@ not `## Technicals`, the freshness banner, the no-personal-position-data scan) i
|
|
|
203
204
|
improvise infra. `stage`/`publish` run `tofu init` themselves on a fresh worktree
|
|
204
205
|
(`pipeline/tofu_bootstrap.py`, bucket derived from the caller's AWS account). Module map:
|
|
205
206
|
`docs/publish-article/PIPELINE-SEAMS.md`.
|
|
207
|
+
- **Caption approval (code-enforced, exit 8).** Every LinkedIn post, and every edit of a live post, needs
|
|
208
|
+
the founder's explicit OK on the exact caption first. Contract:
|
|
209
|
+
| Step | Who | Command |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| 1 | agent | `share --slug S --no-open` builds the kit |
|
|
212
|
+
| 2 | agent | `caption-review --slug S`, then paste the printed caption + media name in chat |
|
|
213
|
+
| 3 | founder | replies with an explicit OK in chat |
|
|
214
|
+
| 4 | agent | `caption-review --slug S --record`, then `share --slug S --post` |
|
|
215
|
+
Never run `--record` on your own, or on a vague reply. Any caption or media change voids the approval; a
|
|
216
|
+
confirmed post consumes it. `share --post`, `linkedin_browser.py post` (clicking Post) and any future edit
|
|
217
|
+
path refuse without it. Manual `share` is not gated.
|
|
206
218
|
- **`share` (no flag) never posts for you — that stays true everywhere.** The shipped skill's
|
|
207
219
|
default is still manual paste: kit + composer + clipboard, nothing goes live on its own. On the
|
|
208
220
|
author's machine only, `share --post` drives `pipeline/linkedin_browser.py` (a personal-use
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""caption_review.py — the founder-approval gate for every LinkedIn post.
|
|
2
|
+
|
|
3
|
+
The exact caption (and the media file name) must be shown to the founder in chat, and the
|
|
4
|
+
founder must say OK, BEFORE anything is posted. This module stores that approval and checks it.
|
|
5
|
+
|
|
6
|
+
A record is keyed by the hash of the caption text plus the media file name. Any caption edit
|
|
7
|
+
or media change gives a new hash, so the old approval no longer matches. A confirmed post
|
|
8
|
+
consumes its record: the next post needs a new approval.
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
python caption_review.py show --caption-file F --media M # print caption + hash
|
|
12
|
+
python caption_review.py record --caption-file F --media M [--slug S] # founder said OK
|
|
13
|
+
python caption_review.py check --caption-file F --media M # exit 0 ok, 8 not approved
|
|
14
|
+
|
|
15
|
+
Records live in review_store.py, kind "caption", one file per hash.
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import hashlib
|
|
21
|
+
import sys
|
|
22
|
+
from datetime import datetime, timezone
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
26
|
+
import review_store # noqa: E402
|
|
27
|
+
|
|
28
|
+
KIND = "caption"
|
|
29
|
+
EXIT_NOT_APPROVED = 8
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def normalize(caption: str) -> str:
|
|
33
|
+
return caption.replace("\r\n", "\n").replace("\r", "\n").strip()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def caption_hash(caption: str, media_name: str) -> str:
|
|
37
|
+
payload = normalize(caption) + "\n--media--\n" + media_name
|
|
38
|
+
return hashlib.sha256(payload.encode("utf-8")).hexdigest()[:16]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def read_caption(caption_file: Path) -> str:
|
|
42
|
+
return normalize(Path(caption_file).read_text(encoding="utf-8"))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def is_approved(caption: str, media_name: str) -> bool:
|
|
46
|
+
return review_store.read(KIND, caption_hash(caption, media_name)) is not None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def not_approved_message(caption_file: Path | str, media_name: str, slug: str | None = None) -> str:
|
|
50
|
+
slug_arg = f" --slug {slug}" if slug else ""
|
|
51
|
+
return (
|
|
52
|
+
f"NOT APPROVED: the founder has not approved this exact caption + media ({media_name}).\n"
|
|
53
|
+
"Nothing was posted. Paste the exact caption from "
|
|
54
|
+
f"{caption_file} in chat, wait for the founder's explicit OK, then run:\n"
|
|
55
|
+
f" python publish_article.py caption-review{slug_arg} --record\n"
|
|
56
|
+
"(or caption_review.py record --caption-file ... --media ...). "
|
|
57
|
+
"Never record on your own. Any caption edit needs a fresh approval."
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def require(caption: str, media_name: str, caption_file: Path | str = "caption.txt",
|
|
62
|
+
slug: str | None = None) -> int:
|
|
63
|
+
"""0 when the founder approved this exact caption + media, else EXIT_NOT_APPROVED."""
|
|
64
|
+
if is_approved(caption, media_name):
|
|
65
|
+
return 0
|
|
66
|
+
print(not_approved_message(caption_file, media_name, slug), file=sys.stderr)
|
|
67
|
+
return EXIT_NOT_APPROVED
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def record(caption: str, media_name: str, slug: str | None = None) -> str:
|
|
71
|
+
h = caption_hash(caption, media_name)
|
|
72
|
+
if slug:
|
|
73
|
+
for f in review_store.kind_dir(KIND).glob("*.json"):
|
|
74
|
+
old = review_store.read(KIND, f.stem)
|
|
75
|
+
if old and old.get("slug") == slug and f.stem != h:
|
|
76
|
+
f.unlink()
|
|
77
|
+
review_store.write(KIND, h, {
|
|
78
|
+
"slug": slug,
|
|
79
|
+
"caption_hash": h,
|
|
80
|
+
"media": media_name,
|
|
81
|
+
"caption": normalize(caption),
|
|
82
|
+
"recorded_at": datetime.now(timezone.utc).isoformat(),
|
|
83
|
+
})
|
|
84
|
+
return h
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def consume(caption: str, media_name: str) -> None:
|
|
88
|
+
review_store.path(KIND, caption_hash(caption, media_name)).unlink(missing_ok=True)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def show(caption: str, media_name: str, caption_file: Path | str, slug: str | None = None) -> None:
|
|
92
|
+
print("=" * 64)
|
|
93
|
+
print("CAPTION FOR FOUNDER REVIEW (paste this exact text in chat)")
|
|
94
|
+
print("=" * 64)
|
|
95
|
+
print(normalize(caption))
|
|
96
|
+
print("=" * 64)
|
|
97
|
+
print(f"media: {media_name}")
|
|
98
|
+
print(f"caption file: {caption_file}")
|
|
99
|
+
print(f"hash: {caption_hash(caption, media_name)}")
|
|
100
|
+
print(f"approved: {'yes' if is_approved(caption, media_name) else 'no'}")
|
|
101
|
+
if not is_approved(caption, media_name):
|
|
102
|
+
slug_arg = f" --slug {slug}" if slug else ""
|
|
103
|
+
print(f"After the founder's explicit OK in chat: python publish_article.py caption-review{slug_arg} --record")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def main() -> int:
|
|
107
|
+
ap = argparse.ArgumentParser(description="Founder caption-approval gate.")
|
|
108
|
+
ap.add_argument("cmd", choices=["show", "record", "check"])
|
|
109
|
+
ap.add_argument("--caption-file", required=True)
|
|
110
|
+
ap.add_argument("--media", required=True, help="media file name or path (only the name is hashed)")
|
|
111
|
+
ap.add_argument("--slug")
|
|
112
|
+
a = ap.parse_args()
|
|
113
|
+
caption, media = read_caption(Path(a.caption_file)), Path(a.media).name
|
|
114
|
+
if a.cmd == "show":
|
|
115
|
+
show(caption, media, a.caption_file, a.slug)
|
|
116
|
+
return 0
|
|
117
|
+
if a.cmd == "record":
|
|
118
|
+
print(f"recorded founder caption approval (hash={record(caption, media, a.slug)})")
|
|
119
|
+
return 0
|
|
120
|
+
return require(caption, media, a.caption_file, a.slug)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
raise SystemExit(main())
|
|
@@ -66,8 +66,28 @@ def record(slug: str, mdx_path: Path, notes: str = "") -> None:
|
|
|
66
66
|
})
|
|
67
67
|
|
|
68
68
|
|
|
69
|
+
def _legacy_hashes(mdx_path: Path) -> set[str]:
|
|
70
|
+
"""The pre-v2 hash was sha256 of the raw file bytes. Accept the same text with either
|
|
71
|
+
line ending, since a checkout may convert them."""
|
|
72
|
+
raw = mdx_path.read_bytes()
|
|
73
|
+
lf = raw.replace(b"\r\n", b"\n")
|
|
74
|
+
return {hashlib.sha256(b).hexdigest()[:16] for b in (raw, lf, lf.replace(b"\n", b"\r\n"))}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _upgrade_legacy(slug: str, payload: dict, mdx_path: Path) -> dict:
|
|
78
|
+
"""A v1 record whose raw-bytes hash equals the current file proves the same content was
|
|
79
|
+
reviewed: rewrite it as v2. Any other v1 record is left alone (stale)."""
|
|
80
|
+
if payload.get("hash_version") is not None or payload.get("content_hash") not in _legacy_hashes(mdx_path):
|
|
81
|
+
return payload
|
|
82
|
+
upgraded = {**payload, "content_hash": content_hash(mdx_path), "hash_version": HASH_VERSION, "upgraded_from_hash_version": 1}
|
|
83
|
+
review_store.write(KIND, slug, upgraded)
|
|
84
|
+
return upgraded
|
|
85
|
+
|
|
86
|
+
|
|
69
87
|
def check(slug: str, mdx_path: Path) -> tuple[bool, str]:
|
|
70
88
|
payload = review_store.read(KIND, slug)
|
|
89
|
+
if payload is not None:
|
|
90
|
+
payload = _upgrade_legacy(slug, payload, mdx_path)
|
|
71
91
|
if payload is None:
|
|
72
92
|
return False, (
|
|
73
93
|
f"no html-mocker review recorded for '{slug}' — run "
|
|
@@ -21,6 +21,9 @@ Modes:
|
|
|
21
21
|
linkedin --slug S print the ready-to-paste LinkedIn draft
|
|
22
22
|
share --slug S assemble a review-ready LinkedIn kit: diagram
|
|
23
23
|
video (MP4) + caption + UTM link, in one folder
|
|
24
|
+
caption-review --slug S [--record]
|
|
25
|
+
show the exact kit caption for the founder; --record
|
|
26
|
+
stores their approval (required before share --post)
|
|
24
27
|
doctor check external tool deps (node, npm, aws, tofu,
|
|
25
28
|
playwright browsers required; just, ffmpeg optional)
|
|
26
29
|
|
|
@@ -45,6 +48,7 @@ import webbrowser
|
|
|
45
48
|
from pathlib import Path
|
|
46
49
|
|
|
47
50
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
51
|
+
import caption_review # noqa: E402
|
|
48
52
|
import html_mock_review # noqa: E402
|
|
49
53
|
import review_store # noqa: E402
|
|
50
54
|
import learn_feedback # noqa: E402
|
|
@@ -636,6 +640,11 @@ def _auto_post_kit(repo: Repo, kit: Path, slug: str, post_click: bool, headed: b
|
|
|
636
640
|
print(f"⚠ auto-post stopped: no GIF at {gif}. Not falling back to MP4. "
|
|
637
641
|
f"Tell the founder; the kit is intact at {kit}.")
|
|
638
642
|
return 5
|
|
643
|
+
if post_click:
|
|
644
|
+
gate_rc = caption_review.require(caption_review.read_caption(kit / "caption.txt"), gif.name,
|
|
645
|
+
kit / "caption.txt", slug)
|
|
646
|
+
if gate_rc != 0:
|
|
647
|
+
return gate_rc
|
|
639
648
|
cmd = [
|
|
640
649
|
sys.executable, str(script), "post",
|
|
641
650
|
"--media", str(gif),
|
|
@@ -647,13 +656,33 @@ def _auto_post_kit(repo: Repo, kit: Path, slug: str, post_click: bool, headed: b
|
|
|
647
656
|
if not post_click:
|
|
648
657
|
cmd.append("--no-post")
|
|
649
658
|
rc = subprocess.run(cmd, cwd=str(repo.pipeline)).returncode
|
|
650
|
-
if rc
|
|
659
|
+
if rc == caption_review.EXIT_NOT_APPROVED:
|
|
660
|
+
print(f"⚠ auto-post refused: no founder caption approval. Nothing was posted; the kit is intact at {kit}.")
|
|
661
|
+
elif rc != 0:
|
|
651
662
|
print(f"⚠ auto-post failed (exit {rc}) — the kit is intact at {kit}. No MP4 fallback was tried; tell the founder.")
|
|
652
663
|
else:
|
|
653
664
|
print("✓ posted via linkedin_browser.py.")
|
|
654
665
|
return rc
|
|
655
666
|
|
|
656
667
|
|
|
668
|
+
def cmd_caption_review(repo: Repo, slug: str, record: bool = False) -> int:
|
|
669
|
+
"""Show the exact kit caption + media + hash for the founder; with `record`, store the
|
|
670
|
+
founder's approval (only after their explicit OK in chat). `share --post` needs it."""
|
|
671
|
+
kit = repo.pa / "share-kits" / slug
|
|
672
|
+
caption_file = kit / "caption.txt"
|
|
673
|
+
if not caption_file.exists():
|
|
674
|
+
sys.exit(f"no share kit for '{slug}' — run `share --slug {slug} --no-open` first.")
|
|
675
|
+
caption = caption_review.read_caption(caption_file)
|
|
676
|
+
media = f"{slug}.gif"
|
|
677
|
+
if not (kit / media).exists():
|
|
678
|
+
print(f"⚠ no GIF at {kit / media} — the post will stop with exit 5 until the kit has one.")
|
|
679
|
+
if record:
|
|
680
|
+
print(f"recorded founder caption approval (hash={caption_review.record(caption, media, slug)})")
|
|
681
|
+
return 0
|
|
682
|
+
caption_review.show(caption, media, caption_file, slug)
|
|
683
|
+
return 0
|
|
684
|
+
|
|
685
|
+
|
|
657
686
|
def cmd_share(repo: Repo, slug: str, open_browser: bool = True, fmt: str = "gif",
|
|
658
687
|
post: bool = False, post_click: bool = True, headed: bool = False) -> int:
|
|
659
688
|
"""Assemble a review-ready LinkedIn kit AND (by default) hand you off to the
|
|
@@ -1016,6 +1045,9 @@ def main() -> int:
|
|
|
1016
1045
|
help="with --post, fill the composer and stop before clicking Post (review run)")
|
|
1017
1046
|
sh.add_argument("--headed", action="store_true",
|
|
1018
1047
|
help="with --post, show the browser window (default is headless)")
|
|
1048
|
+
cr = sub.add_parser("caption-review"); cr.add_argument("--slug", required=True)
|
|
1049
|
+
cr.add_argument("--record", action="store_true",
|
|
1050
|
+
help="store the founder's approval of the shown caption — only after their explicit OK in chat")
|
|
1019
1051
|
sub.add_parser("doctor")
|
|
1020
1052
|
|
|
1021
1053
|
args = ap.parse_args()
|
|
@@ -1041,6 +1073,8 @@ def main() -> int:
|
|
|
1041
1073
|
return cmd_publish(repo, check_slug(args.slug), run_test=not args.no_test, dry_run=args.dry_run)
|
|
1042
1074
|
if args.mode == "linkedin":
|
|
1043
1075
|
return cmd_linkedin(repo, check_slug(args.slug))
|
|
1076
|
+
if args.mode == "caption-review":
|
|
1077
|
+
return cmd_caption_review(repo, check_slug(args.slug), record=args.record)
|
|
1044
1078
|
if args.mode == "share":
|
|
1045
1079
|
return cmd_share(repo, check_slug(args.slug), open_browser=not args.no_open, fmt=args.format,
|
|
1046
1080
|
post=args.post, post_click=not args.no_post_click, headed=args.headed)
|
|
@@ -7,7 +7,7 @@ all see the same record:
|
|
|
7
7
|
|
|
8
8
|
$PUBLISH_ARTICLE_REVIEWS, else ~/.claude/publish-article/reviews/<kind>/<slug>.json
|
|
9
9
|
|
|
10
|
-
`kind` is "architecture"
|
|
10
|
+
`kind` is "architecture", "html-mock" or "caption". Each record keeps its own hash binding
|
|
11
11
|
(spec_hash / content_hash); this module only stores and finds them.
|
|
12
12
|
|
|
13
13
|
A record found only in an older location (beside the script, the deployed skill
|
|
@@ -23,7 +23,7 @@ from pathlib import Path
|
|
|
23
23
|
|
|
24
24
|
import repo_locate
|
|
25
25
|
|
|
26
|
-
KINDS = ("architecture", "html-mock")
|
|
26
|
+
KINDS = ("architecture", "html-mock", "caption")
|
|
27
27
|
_LEGACY_NAMES = {"architecture": ".architecture-reviews", "html-mock": ".html-mock-reviews"}
|
|
28
28
|
|
|
29
29
|
|
|
@@ -39,7 +39,9 @@ def kind_dir(kind: str) -> Path:
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def legacy_dirs(kind: str) -> list[Path]:
|
|
42
|
-
name = _LEGACY_NAMES
|
|
42
|
+
name = _LEGACY_NAMES.get(kind)
|
|
43
|
+
if name is None:
|
|
44
|
+
return []
|
|
43
45
|
here = Path(__file__).resolve().parent
|
|
44
46
|
candidates = [here / name, Path.home() / ".claude" / "skills" / "publish-article" / name]
|
|
45
47
|
env_repo = repo_locate.env_candidate()
|
|
@@ -54,7 +56,7 @@ def legacy_dirs(kind: str) -> list[Path]:
|
|
|
54
56
|
return out
|
|
55
57
|
|
|
56
58
|
|
|
57
|
-
def
|
|
59
|
+
def path(kind: str, slug: str) -> Path:
|
|
58
60
|
return kind_dir(kind) / f"{slug}.json"
|
|
59
61
|
|
|
60
62
|
|
|
@@ -79,7 +81,7 @@ def migrate(kind: str, slug: str | None = None) -> list[str]:
|
|
|
79
81
|
|
|
80
82
|
|
|
81
83
|
def read(kind: str, slug: str) -> dict | None:
|
|
82
|
-
p =
|
|
84
|
+
p = path(kind, slug)
|
|
83
85
|
if not p.exists():
|
|
84
86
|
migrate(kind, slug)
|
|
85
87
|
if not p.exists():
|
|
@@ -88,7 +90,7 @@ def read(kind: str, slug: str) -> dict | None:
|
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
def write(kind: str, slug: str, payload: dict) -> Path:
|
|
91
|
-
p =
|
|
93
|
+
p = path(kind, slug)
|
|
92
94
|
p.parent.mkdir(parents=True, exist_ok=True)
|
|
93
95
|
p.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
94
96
|
return p
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for caption_review.py - the founder caption-approval gate: bound to the caption text
|
|
3
|
+
and media file name, invalidated by any edit, consumed by a confirmed post.
|
|
4
|
+
|
|
5
|
+
Run: pytest skills/publish-article/tests/test_caption_review.py
|
|
6
|
+
"""
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
13
|
+
import caption_review # noqa: E402
|
|
14
|
+
import review_store # noqa: E402
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture(autouse=True)
|
|
18
|
+
def isolated_reviews(tmp_path, monkeypatch):
|
|
19
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "reviews"))
|
|
20
|
+
monkeypatch.setattr(review_store, "legacy_dirs", lambda kind: [])
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_unapproved_caption_is_refused_with_clear_instructions(capsys):
|
|
24
|
+
assert caption_review.require("hello", "a.gif", "kit/caption.txt", "a") == 8
|
|
25
|
+
err = capsys.readouterr().err
|
|
26
|
+
assert "NOT APPROVED" in err and "explicit OK" in err and "caption-review --slug a --record" in err
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_record_then_require_passes():
|
|
30
|
+
caption_review.record("hello", "a.gif", "a")
|
|
31
|
+
assert caption_review.require("hello", "a.gif") == 0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_caption_edit_invalidates_the_record():
|
|
35
|
+
caption_review.record("hello", "a.gif", "a")
|
|
36
|
+
assert caption_review.require("hello!", "a.gif") == 8
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_media_change_invalidates_the_record():
|
|
40
|
+
caption_review.record("hello", "a.gif", "a")
|
|
41
|
+
assert caption_review.require("hello", "b.gif") == 8
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_line_endings_and_outer_whitespace_do_not_invalidate():
|
|
45
|
+
caption_review.record("line1\nline2\n", "a.gif", "a")
|
|
46
|
+
assert caption_review.require("\r\nline1\r\nline2", "a.gif") == 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_new_record_for_the_same_slug_replaces_the_old_one():
|
|
50
|
+
caption_review.record("v1", "a.gif", "a")
|
|
51
|
+
caption_review.record("v2", "a.gif", "a")
|
|
52
|
+
assert caption_review.require("v1", "a.gif") == 8
|
|
53
|
+
assert caption_review.require("v2", "a.gif") == 0
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_consume_removes_the_approval():
|
|
57
|
+
caption_review.record("hello", "a.gif", "a")
|
|
58
|
+
caption_review.consume("hello", "a.gif")
|
|
59
|
+
assert caption_review.require("hello", "a.gif") == 8
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_cli_check_exit_codes(tmp_path, monkeypatch):
|
|
63
|
+
f = tmp_path / "caption.txt"
|
|
64
|
+
f.write_text("hello\n", encoding="utf-8")
|
|
65
|
+
argv = ["--caption-file", str(f), "--media", str(tmp_path / "a.gif")]
|
|
66
|
+
monkeypatch.setattr(sys, "argv", ["caption_review.py", "check", *argv])
|
|
67
|
+
assert caption_review.main() == 8
|
|
68
|
+
monkeypatch.setattr(sys, "argv", ["caption_review.py", "record", *argv])
|
|
69
|
+
assert caption_review.main() == 0
|
|
70
|
+
monkeypatch.setattr(sys, "argv", ["caption_review.py", "check", *argv])
|
|
71
|
+
assert caption_review.main() == 0
|
|
@@ -115,6 +115,45 @@ def test_record_with_old_hash_scheme_is_stale(isolated_reviews, tmp_path):
|
|
|
115
115
|
mdx = _write_mdx(tmp_path)
|
|
116
116
|
isolated_reviews.mkdir(parents=True)
|
|
117
117
|
(isolated_reviews / "some-slug.json").write_text(
|
|
118
|
-
json.dumps({"slug": "some-slug", "content_hash":
|
|
118
|
+
json.dumps({"slug": "some-slug", "content_hash": "0123456789abcdef"}), encoding="utf-8")
|
|
119
119
|
ok, msg = html_mock_review.check("some-slug", mdx)
|
|
120
120
|
assert ok is False and "stale" in msg
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _legacy_record(isolated_reviews, slug, raw_bytes):
|
|
124
|
+
import hashlib
|
|
125
|
+
import json
|
|
126
|
+
|
|
127
|
+
isolated_reviews.mkdir(parents=True, exist_ok=True)
|
|
128
|
+
(isolated_reviews / f"{slug}.json").write_text(
|
|
129
|
+
json.dumps({"slug": slug, "content_hash": hashlib.sha256(raw_bytes).hexdigest()[:16], "notes": "n"}), encoding="utf-8")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_old_record_for_identical_content_is_upgraded_not_stale(isolated_reviews, tmp_path):
|
|
133
|
+
raw = b'---\r\ntitle: "T"\r\ndraft: false\r\n---\r\nbody\r\n'
|
|
134
|
+
mdx = tmp_path / "a.mdx"
|
|
135
|
+
mdx.write_bytes(raw)
|
|
136
|
+
_legacy_record(isolated_reviews, "s", raw)
|
|
137
|
+
ok, msg = html_mock_review.check("s", mdx)
|
|
138
|
+
assert ok is True, msg
|
|
139
|
+
import json
|
|
140
|
+
|
|
141
|
+
saved = json.loads((isolated_reviews / "s.json").read_text(encoding="utf-8"))
|
|
142
|
+
assert saved["hash_version"] == html_mock_review.HASH_VERSION and saved["upgraded_from_hash_version"] == 1
|
|
143
|
+
assert saved["notes"] == "n"
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_old_record_survives_a_line_ending_conversion(isolated_reviews, tmp_path):
|
|
147
|
+
crlf = b'---\r\ntitle: "T"\r\n---\r\nbody\r\n'
|
|
148
|
+
mdx = tmp_path / "a.mdx"
|
|
149
|
+
mdx.write_bytes(crlf.replace(b"\r\n", b"\n"))
|
|
150
|
+
_legacy_record(isolated_reviews, "s", crlf)
|
|
151
|
+
assert html_mock_review.check("s", mdx)[0] is True
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_old_record_for_different_content_stays_stale(isolated_reviews, tmp_path):
|
|
155
|
+
mdx = tmp_path / "a.mdx"
|
|
156
|
+
mdx.write_bytes(b"new content")
|
|
157
|
+
_legacy_record(isolated_reviews, "s", b"old content")
|
|
158
|
+
ok, msg = html_mock_review.check("s", mdx)
|
|
159
|
+
assert ok is False and "stale" in msg
|
|
@@ -27,6 +27,8 @@ import pytest
|
|
|
27
27
|
|
|
28
28
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
29
29
|
import publish_article # noqa: E402
|
|
30
|
+
import caption_review # noqa: E402
|
|
31
|
+
import review_store # noqa: E402
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
# --------------------------------------------------------------------- helpers
|
|
@@ -70,6 +72,12 @@ def repo(tmp_path):
|
|
|
70
72
|
return make_repo(tmp_path)
|
|
71
73
|
|
|
72
74
|
|
|
75
|
+
@pytest.fixture(autouse=True)
|
|
76
|
+
def isolated_reviews(tmp_path, monkeypatch):
|
|
77
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "reviews"))
|
|
78
|
+
monkeypatch.setattr(review_store, "legacy_dirs", lambda kind: [])
|
|
79
|
+
|
|
80
|
+
|
|
73
81
|
# ================================================================ build_share_caption
|
|
74
82
|
SKILL_FRONTMATTER = (
|
|
75
83
|
'---\n'
|
|
@@ -775,9 +783,14 @@ def _make_share_ready_article(repo: publish_article.Repo, slug: str) -> None:
|
|
|
775
783
|
(island_dir / f"{slug}-island.gif").write_bytes(b"GIF89a")
|
|
776
784
|
|
|
777
785
|
|
|
786
|
+
def _approve_caption(repo: publish_article.Repo, slug: str) -> None:
|
|
787
|
+
caption_review.record(publish_article.build_share_caption(repo, slug), f"{slug}.gif", slug)
|
|
788
|
+
|
|
789
|
+
|
|
778
790
|
def test_share_post_invokes_linkedin_browser_when_present(repo, monkeypatch):
|
|
779
791
|
slug = "post-present-slug"
|
|
780
792
|
_make_share_ready_article(repo, slug)
|
|
793
|
+
_approve_caption(repo, slug)
|
|
781
794
|
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None) # no real ffmpeg call
|
|
782
795
|
|
|
783
796
|
repo.pipeline.mkdir(parents=True, exist_ok=True)
|
|
@@ -895,6 +908,7 @@ def test_mock_builds_a_draft_preview_and_prints_the_monitor_form(repo, monkeypat
|
|
|
895
908
|
def test_share_post_headed_override_drops_headless(repo, monkeypatch):
|
|
896
909
|
slug = "post-headed-slug"
|
|
897
910
|
_make_share_ready_article(repo, slug)
|
|
911
|
+
_approve_caption(repo, slug)
|
|
898
912
|
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None)
|
|
899
913
|
repo.pipeline.mkdir(parents=True, exist_ok=True)
|
|
900
914
|
(repo.pipeline / "linkedin_browser.py").write_text("# fake", encoding="utf-8")
|
|
@@ -929,3 +943,81 @@ def test_share_post_without_a_gif_stops_and_never_uses_the_mp4(repo, monkeypatch
|
|
|
929
943
|
rc = publish_article.cmd_share(repo, slug, open_browser=False, post=True)
|
|
930
944
|
assert rc == 5
|
|
931
945
|
assert "Not falling back to MP4" in capsys.readouterr().out
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
# ============================================================================ caption-review gate
|
|
949
|
+
def _fake_linkedin_browser(repo, monkeypatch):
|
|
950
|
+
repo.pipeline.mkdir(parents=True, exist_ok=True)
|
|
951
|
+
(repo.pipeline / "linkedin_browser.py").write_text("# fake", encoding="utf-8")
|
|
952
|
+
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None)
|
|
953
|
+
ran = []
|
|
954
|
+
|
|
955
|
+
def fake_run(cmd, **kwargs):
|
|
956
|
+
ran.append(cmd)
|
|
957
|
+
class R:
|
|
958
|
+
returncode = 0
|
|
959
|
+
return R()
|
|
960
|
+
|
|
961
|
+
monkeypatch.setattr(publish_article.subprocess, "run", fake_run)
|
|
962
|
+
return ran
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
def test_share_post_refuses_without_caption_approval(repo, monkeypatch, capsys):
|
|
966
|
+
slug = "gate-none-slug"
|
|
967
|
+
_make_share_ready_article(repo, slug)
|
|
968
|
+
ran = _fake_linkedin_browser(repo, monkeypatch)
|
|
969
|
+
rc = publish_article.cmd_share(repo, slug, open_browser=False, post=True)
|
|
970
|
+
assert rc == caption_review.EXIT_NOT_APPROVED == 8
|
|
971
|
+
assert ran == []
|
|
972
|
+
err = capsys.readouterr().err
|
|
973
|
+
assert "NOT APPROVED" in err and "explicit OK" in err and f"caption-review --slug {slug} --record" in err
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
def test_share_post_refuses_after_caption_edit(repo, monkeypatch):
|
|
977
|
+
slug = "gate-edit-slug"
|
|
978
|
+
_make_share_ready_article(repo, slug)
|
|
979
|
+
ran = _fake_linkedin_browser(repo, monkeypatch)
|
|
980
|
+
_approve_caption(repo, slug)
|
|
981
|
+
repo.mdx(slug).write_text(
|
|
982
|
+
'---\ntitle: "T2 changed"\nsummary: "S2 changed"\ndraft: false\ntags: [architecture]\n---\n\nBody.\n',
|
|
983
|
+
encoding="utf-8",
|
|
984
|
+
)
|
|
985
|
+
assert publish_article.cmd_share(repo, slug, open_browser=False, post=True) == 8
|
|
986
|
+
assert ran == []
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
def test_share_post_passes_after_record(repo, monkeypatch):
|
|
990
|
+
slug = "gate-ok-slug"
|
|
991
|
+
_make_share_ready_article(repo, slug)
|
|
992
|
+
ran = _fake_linkedin_browser(repo, monkeypatch)
|
|
993
|
+
_approve_caption(repo, slug)
|
|
994
|
+
assert publish_article.cmd_share(repo, slug, open_browser=False, post=True) == 0
|
|
995
|
+
assert len(ran) == 1
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
def test_manual_share_is_unaffected_by_the_gate(repo, monkeypatch):
|
|
999
|
+
slug = "gate-manual-slug"
|
|
1000
|
+
_make_share_ready_article(repo, slug)
|
|
1001
|
+
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None)
|
|
1002
|
+
assert publish_article.cmd_share(repo, slug, open_browser=False, post=False) == 0
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
def test_caption_review_shows_then_records_bound_to_the_kit(repo, monkeypatch, capsys):
|
|
1006
|
+
slug = "gate-cli-slug"
|
|
1007
|
+
_make_share_ready_article(repo, slug)
|
|
1008
|
+
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None)
|
|
1009
|
+
publish_article.cmd_share(repo, slug, open_browser=False)
|
|
1010
|
+
capsys.readouterr()
|
|
1011
|
+
assert publish_article.cmd_caption_review(repo, slug) == 0
|
|
1012
|
+
shown = capsys.readouterr().out
|
|
1013
|
+
caption = (repo.pa / "share-kits" / slug / "caption.txt").read_text(encoding="utf-8").strip()
|
|
1014
|
+
assert caption in shown and f"{slug}.gif" in shown and "approved: no" in shown
|
|
1015
|
+
assert publish_article.cmd_caption_review(repo, slug, record=True) == 0
|
|
1016
|
+
assert caption_review.is_approved(caption, f"{slug}.gif")
|
|
1017
|
+
publish_article.cmd_caption_review(repo, slug)
|
|
1018
|
+
assert "approved: yes" in capsys.readouterr().out
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
def test_caption_review_without_a_kit_exits(repo):
|
|
1022
|
+
with pytest.raises(SystemExit):
|
|
1023
|
+
publish_article.cmd_caption_review(repo, "no-kit-slug")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasaswy.nagavolu/agents",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.15",
|
|
4
4
|
"description": "CLI for installing the yasaswy.nagavolu agent/skill/hook bundle. `install` opens an interactive bundle menu in a TTY (or `--bundle <key> --yes` for non-interactive installs), with hash-tracked idempotent deploys, automatic hook wiring into settings.json, and masked secret prompting. `update` reconciles installed bundles against the current source (hash-tracked: silent overwrite, conflict diff+prompt, or --theirs/--keep-mine). `uninstall` removes a bundle's files and wiring. `secrets` re-runs secret prompting for already-installed bundles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|