@yasaswy.nagavolu/agents 0.26.12 → 0.26.13
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 +2 -1
- package/content/skills/html-mocker/mocker.py +19 -0
- package/content/skills/html-mocker/tests/test_mocker_url_path.py +29 -0
- package/content/skills/publish-article/SKILL.md +13 -4
- package/content/skills/publish-article/architecture_review.py +7 -9
- package/content/skills/publish-article/html_mock_review.py +31 -11
- package/content/skills/publish-article/lint_article.py +17 -1
- package/content/skills/publish-article/publish_article.py +32 -13
- package/content/skills/publish-article/review_store.py +113 -0
- package/content/skills/publish-article/tests/test_architecture_review.py +4 -3
- package/content/skills/publish-article/tests/test_html_mock_review.py +34 -3
- package/content/skills/publish-article/tests/test_lint_article.py +4 -3
- package/content/skills/publish-article/tests/test_lint_investing.py +23 -0
- package/content/skills/publish-article/tests/test_publish_article.py +68 -1
- package/content/skills/publish-article/tests/test_review_store.py +69 -0
- package/package.json +1 -1
package/content/manifest.json
CHANGED
|
@@ -52,6 +52,23 @@ STATUS_ROUTE = "/__mocker/status"
|
|
|
52
52
|
ARTIFACTS_ROOT = Path.home() / ".claude" / "skill-artifacts"
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
_MSYS_ROOT = re.compile(r"^[A-Za-z]:[\\/].*?[\\/]Git[\\/](.*)$", re.I)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def normalize_url_path(url_path: str | None) -> str | None:
|
|
59
|
+
"""Git Bash rewrites an argument like /my-article/ into C:/Program Files/Git/my-article/
|
|
60
|
+
before Python sees it. Undo that (and warn) so the route still resolves."""
|
|
61
|
+
if not url_path:
|
|
62
|
+
return url_path
|
|
63
|
+
m = _MSYS_ROOT.match(url_path)
|
|
64
|
+
if not m:
|
|
65
|
+
return url_path
|
|
66
|
+
fixed = "/" + m.group(1)
|
|
67
|
+
print(f"WARNING: --url-path was rewritten by Git Bash to {url_path!r}; using {fixed!r}. "
|
|
68
|
+
"Set MSYS_NO_PATHCONV=1 or run from PowerShell to avoid this.", file=sys.stderr)
|
|
69
|
+
return fixed
|
|
70
|
+
|
|
71
|
+
|
|
55
72
|
def default_out_dir(target: str, url_path: str | None = None) -> Path:
|
|
56
73
|
# When url_path is given (directory target + a specific route within it,
|
|
57
74
|
# e.g. a whole-site `dist/` root plus `/my-article/`), name the session
|
|
@@ -363,6 +380,7 @@ def resolve_target(target: str, annotate: bool = False, annotations_path: Path |
|
|
|
363
380
|
corrected). url_path only makes sense for a directory target — a single
|
|
364
381
|
file target already has an unambiguous name and root.
|
|
365
382
|
"""
|
|
383
|
+
url_path = normalize_url_path(url_path)
|
|
366
384
|
if is_url(target):
|
|
367
385
|
if annotate:
|
|
368
386
|
raise ValueError("--annotate needs a local target (can't inject into a remote origin); use --open only for URLs")
|
|
@@ -459,6 +477,7 @@ def main() -> int:
|
|
|
459
477
|
ap.add_argument("--port", type=int, default=0, help="bind port (default 0 = OS-assigned ephemeral; set a fixed port when a caller needs to know it in advance, e.g. for adb reverse or a firewall rule)")
|
|
460
478
|
args = ap.parse_args()
|
|
461
479
|
|
|
480
|
+
args.url_path = normalize_url_path(args.url_path)
|
|
462
481
|
out_dir = Path(args.out) if args.out else default_out_dir(args.target, args.url_path)
|
|
463
482
|
annotations_path = out_dir / "annotations.jsonl"
|
|
464
483
|
feedback_log = Path(args.feedback_log) if args.feedback_log else None
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
mocker.normalize_url_path: Git Bash turns /my-article/ into C:/Program Files/Git/my-article/
|
|
3
|
+
before Python sees it. The route must be recovered, with a warning, and normal paths untouched.
|
|
4
|
+
|
|
5
|
+
Run: pytest skills/html-mocker/tests/test_mocker_url_path.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 mocker # noqa: E402
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.parametrize("mangled,expected", [
|
|
17
|
+
("C:/Program Files/Git/keepwarm-prompt-cache/", "/keepwarm-prompt-cache/"),
|
|
18
|
+
("D:/tools/Git/my-article/sub/", "/my-article/sub/"),
|
|
19
|
+
("C:/Program Files (x86)/Git/a/", "/a/"),
|
|
20
|
+
])
|
|
21
|
+
def test_git_bash_mangled_route_is_recovered_and_warned(mangled, expected, capsys):
|
|
22
|
+
assert mocker.normalize_url_path(mangled) == expected
|
|
23
|
+
assert "rewritten by Git Bash" in capsys.readouterr().err
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.parametrize("fine", ["/my-article/", "my-article/", None, "", "/"])
|
|
27
|
+
def test_normal_routes_are_left_alone(fine, capsys):
|
|
28
|
+
assert mocker.normalize_url_path(fine) == fine
|
|
29
|
+
assert capsys.readouterr().err == ""
|
|
@@ -30,7 +30,7 @@ feedback stops being one-off fixes and becomes the harness. Nothing is live from
|
|
|
30
30
|
|---|---|---|
|
|
31
31
|
| **capture** | user is mid-build and hits a teachable concept; does NOT want to spend this context | Run `capture --slug <kebab> [--title ...] [--section building\|investing] [--skill KEY]` (default `building`; `investing` scaffolds a research-brief stub instead, see ADR 0020; `--skill` is a `tools.json` key — see Frontmatter contract below). Then **write the concept brief** into the generated `<slug>.brief.md` (the idea, key points, code in play, their angle). Tell them to commit and keep working. Author NOTHING else here. |
|
|
32
32
|
| **build** | fresh chat, later | Run `build --slug <slug>`, read `<slug>.brief.md`, author the full MDX + any React islands. Preview with `npm --prefix <repo>/src/publish-article/site run dev`. |
|
|
33
|
-
| **review** | local, over days | Iterate, AND satisfy the mandatory html-mocker gate before `stage`: run `mock --slug <slug>` (builds locally, prints the exact html-mocker `--annotate` command), run that command, wait for the user's `REVIEW_DONE`, read `annotations.jsonl`, apply fixes, then `python html_mock_review.py record --slug <slug>`. Article
|
|
33
|
+
| **review** | local, over days | Iterate, AND satisfy the mandatory html-mocker gate before `stage`: run `mock --slug <slug>` (builds locally, drafts included, so no `draft:` flip; prints the exact html-mocker `--annotate` command and its Monitor call), run that command under Monitor, wait for the user's `REVIEW_DONE`, read `annotations.jsonl`, apply fixes, then `python html_mock_review.py record --slug <slug>`. Article can stay `draft: true` — nothing is live. |
|
|
34
34
|
| **stage** | candidate ready to show the user | Flip `draft: false`, run `stage --slug <slug>`. Relay the **staging URL** and ask the user to test it. Staging is not public-indexed. |
|
|
35
35
|
| **(user) approve — optional** | user has tested staging and wants a personal record of it | The user may run `approve --slug <slug>` **themselves** (interactive, content-bound) — purely informational, not required. You cannot run it — do not try. |
|
|
36
36
|
| **publish** | candidate is ready to go live | Run `publish --slug <slug>`. There is no approval gate (ADR 0019 removed it) — `draft: false` ships straight to prod: deploy → live Playwright smoke → prints **live URL + LinkedIn draft**. Relay both. |
|
|
@@ -188,7 +188,11 @@ not `## Technicals`, the freshness banner, the no-personal-position-data scan) i
|
|
|
188
188
|
recorded-verdict shape, applied to the article's own rendered page instead of the shared diagram
|
|
189
189
|
spec. Run `mock --slug <slug>` → the printed html-mocker `--annotate` command → wait for
|
|
190
190
|
`REVIEW_DONE` → read `annotations.jsonl` → apply fixes → `html_mock_review.py record --slug
|
|
191
|
-
<slug>` → then `stage` will proceed.
|
|
191
|
+
<slug>` → then `stage` will proceed. Records live in one per-user store (`review_store.py`:
|
|
192
|
+
`~/.claude/publish-article/reviews/{architecture,html-mock}/<slug>.json`, or `$PUBLISH_ARTICLE_REVIEWS`),
|
|
193
|
+
so any worktree and the deployed skill copy see the same record; old records are copied in on first
|
|
194
|
+
read. The review hash ignores the `draft:` line and line endings, so flipping the draft flag keeps a
|
|
195
|
+
review valid; any other text change makes it stale.
|
|
192
196
|
- **`draft: false` + `publish` IS live (ADR 0019).** There is no approval gate between "shippable
|
|
193
197
|
candidate" and "in production" anymore — `stage` + a human look at the staging URL is the only
|
|
194
198
|
check before `publish` ships it. Don't imply otherwise to the user.
|
|
@@ -196,12 +200,17 @@ not `## Technicals`, the freshness banner, the no-personal-position-data scan) i
|
|
|
196
200
|
deploy may be up but unverified; do not present it as done.
|
|
197
201
|
- **Always relay the returned staging/live URL** so the user can do the test + final human check.
|
|
198
202
|
- Provisioning/first-run AWS setup is in `docs/publish-article/RUNBOOK.md` — point there, don't
|
|
199
|
-
improvise infra.
|
|
203
|
+
improvise infra. `stage`/`publish` run `tofu init` themselves on a fresh worktree
|
|
204
|
+
(`pipeline/tofu_bootstrap.py`, bucket derived from the caller's AWS account). Module map:
|
|
205
|
+
`docs/publish-article/PIPELINE-SEAMS.md`.
|
|
200
206
|
- **`share` (no flag) never posts for you — that stays true everywhere.** The shipped skill's
|
|
201
207
|
default is still manual paste: kit + composer + clipboard, nothing goes live on its own. On the
|
|
202
208
|
author's machine only, `share --post` drives `pipeline/linkedin_browser.py` (a personal-use
|
|
203
209
|
Playwright tool over the user's own logged-in session) to actually post — the gate is the user's
|
|
204
|
-
explicit chat-level "publish/post it" instruction, not the flag itself. `--post`
|
|
210
|
+
explicit chat-level "publish/post it" instruction, not the flag itself. `--post` runs headless
|
|
211
|
+
(`--headed` to watch), uploads the GIF only (no MP4 fallback: a GIF failure stops the run and the
|
|
212
|
+
founder decides), and counts as posted only when LinkedIn shows "Your post was successful" (exit 7
|
|
213
|
+
otherwise; the Premium upsell is dismissed with "Not now"). `--post` degrades to the
|
|
205
214
|
manual flow automatically anywhere that file isn't present (ADR 0007 addendum).
|
|
206
215
|
- **LinkedIn share-kit media defaults to GIF, not MP4 (as of 2026-07-09).** A reader reported
|
|
207
216
|
the MP4 (H.264, technically well-formed) showing a black screen on iOS Safari/Chrome for the
|
|
@@ -10,16 +10,17 @@ Usage:
|
|
|
10
10
|
python architecture_review.py record --slug <slug> --verdict pass|fail --notes "..."
|
|
11
11
|
python architecture_review.py check --slug <slug> # exit 0 = recorded pass against current spec
|
|
12
12
|
|
|
13
|
-
Reviews are stored
|
|
13
|
+
Reviews are stored by review_store.py (one per-user folder shared by every checkout
|
|
14
|
+
and the deployed skill copy), kind "architecture".
|
|
14
15
|
"""
|
|
15
16
|
import argparse
|
|
16
17
|
import hashlib
|
|
17
|
-
import json
|
|
18
18
|
import sys
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
|
|
21
21
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
22
22
|
import repo_locate # noqa: E402
|
|
23
|
+
import review_store # noqa: E402
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
def _resolve_spec_path() -> Path:
|
|
@@ -46,7 +47,7 @@ def _resolve_spec_path() -> Path:
|
|
|
46
47
|
|
|
47
48
|
REPO_ROOT = Path(__file__).parent.parent.parent
|
|
48
49
|
SPEC_PATH = _resolve_spec_path()
|
|
49
|
-
|
|
50
|
+
KIND = "architecture"
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
def spec_hash() -> str:
|
|
@@ -54,16 +55,13 @@ def spec_hash() -> str:
|
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
def record(slug: str, verdict: str, notes: str) -> None:
|
|
57
|
-
|
|
58
|
-
payload = {"slug": slug, "verdict": verdict, "notes": notes, "spec_hash": spec_hash()}
|
|
59
|
-
(REVIEWS_DIR / f"{slug}.json").write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
58
|
+
review_store.write(KIND, slug, {"slug": slug, "verdict": verdict, "notes": notes, "spec_hash": spec_hash()})
|
|
60
59
|
|
|
61
60
|
|
|
62
61
|
def check(slug: str) -> tuple[bool, str]:
|
|
63
|
-
|
|
64
|
-
if
|
|
62
|
+
payload = review_store.read(KIND, slug)
|
|
63
|
+
if payload is None:
|
|
65
64
|
return False, f"no architecture-diagram-council review recorded for '{slug}'"
|
|
66
|
-
payload = json.loads(path.read_text(encoding="utf-8"))
|
|
67
65
|
if payload.get("verdict") != "pass":
|
|
68
66
|
return False, f"architecture-diagram-council rejected '{slug}': {payload.get('notes', '')}"
|
|
69
67
|
if payload.get("spec_hash") != spec_hash():
|
|
@@ -18,44 +18,64 @@ Usage:
|
|
|
18
18
|
python html_mock_review.py record --slug <slug> [--notes "..."]
|
|
19
19
|
python html_mock_review.py check --slug <slug> # exit 0 = recorded review against current content
|
|
20
20
|
|
|
21
|
-
Reviews are stored
|
|
21
|
+
Reviews are stored by review_store.py (one per-user folder shared by every checkout
|
|
22
|
+
and the deployed skill copy), kind "html-mock".
|
|
23
|
+
|
|
24
|
+
The hash covers the article's own text only: line endings are normalised and the
|
|
25
|
+
`draft:` frontmatter line is dropped, so flipping draft true/false or a CRLF/LF
|
|
26
|
+
change does not invalidate a review. Any other change to the article does.
|
|
22
27
|
"""
|
|
23
28
|
import argparse
|
|
24
29
|
import hashlib
|
|
25
30
|
import json
|
|
31
|
+
import re
|
|
26
32
|
import sys
|
|
27
33
|
from datetime import datetime, timezone
|
|
28
34
|
from pathlib import Path
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
sys.path.insert(0, str(Path(__file__).parent))
|
|
37
|
+
import review_store # noqa: E402
|
|
38
|
+
|
|
39
|
+
KIND = "html-mock"
|
|
40
|
+
HASH_VERSION = 2
|
|
41
|
+
_FRONTMATTER = re.compile(r"\A(---\n)(.*?)(\n---\n)", re.S)
|
|
42
|
+
_DRAFT_LINE = re.compile(r"^draft:.*$")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def normalized_content(text: str) -> str:
|
|
46
|
+
text = text.replace("\r\n", "\n").replace("\r", "\n")
|
|
47
|
+
m = _FRONTMATTER.match(text)
|
|
48
|
+
if not m:
|
|
49
|
+
return text
|
|
50
|
+
head = "\n".join(l for l in m.group(2).split("\n") if not _DRAFT_LINE.match(l))
|
|
51
|
+
return m.group(1) + head + m.group(3) + text[m.end():]
|
|
31
52
|
|
|
32
53
|
|
|
33
54
|
def content_hash(mdx_path: Path) -> str:
|
|
34
|
-
|
|
55
|
+
text = mdx_path.read_text(encoding="utf-8")
|
|
56
|
+
return hashlib.sha256(normalized_content(text).encode("utf-8")).hexdigest()[:16]
|
|
35
57
|
|
|
36
58
|
|
|
37
59
|
def record(slug: str, mdx_path: Path, notes: str = "") -> None:
|
|
38
|
-
|
|
39
|
-
payload = {
|
|
60
|
+
review_store.write(KIND, slug, {
|
|
40
61
|
"slug": slug,
|
|
41
62
|
"content_hash": content_hash(mdx_path),
|
|
63
|
+
"hash_version": HASH_VERSION,
|
|
42
64
|
"notes": notes,
|
|
43
65
|
"recorded_at": datetime.now(timezone.utc).isoformat(),
|
|
44
|
-
}
|
|
45
|
-
(REVIEWS_DIR / f"{slug}.json").write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
66
|
+
})
|
|
46
67
|
|
|
47
68
|
|
|
48
69
|
def check(slug: str, mdx_path: Path) -> tuple[bool, str]:
|
|
49
|
-
|
|
50
|
-
if
|
|
70
|
+
payload = review_store.read(KIND, slug)
|
|
71
|
+
if payload is None:
|
|
51
72
|
return False, (
|
|
52
73
|
f"no html-mocker review recorded for '{slug}' — run "
|
|
53
74
|
f"`python publish_article.py mock --slug {slug}` (serves the built page via "
|
|
54
75
|
"html-mocker's --annotate panel), have the user review it, then "
|
|
55
76
|
f"`python html_mock_review.py record --slug {slug}`."
|
|
56
77
|
)
|
|
57
|
-
payload
|
|
58
|
-
if payload.get("content_hash") != content_hash(mdx_path):
|
|
78
|
+
if payload.get("hash_version") != HASH_VERSION or payload.get("content_hash") != content_hash(mdx_path):
|
|
59
79
|
return False, (
|
|
60
80
|
f"html-mocker review for '{slug}' is stale (the article changed since the "
|
|
61
81
|
f"recorded review) — re-review required: run `python publish_article.py mock "
|
|
@@ -411,6 +411,20 @@ def _scan_for_position_leaks(text: str, source: str) -> list[str]:
|
|
|
411
411
|
return problems
|
|
412
412
|
|
|
413
413
|
|
|
414
|
+
ASSET_SUFFIXES = {".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif", ".svg", ".ico", ".mp4", ".webm",
|
|
415
|
+
".woff", ".woff2", ".ttf", ".otf", ".pdf", ".json", ".css"}
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def _read_island_text(path: Path) -> str | None:
|
|
419
|
+
"""Island source as text, or None for an asset (image, font, ...) or any file that is not UTF-8."""
|
|
420
|
+
if path.suffix.lower() in ASSET_SUFFIXES:
|
|
421
|
+
return None
|
|
422
|
+
try:
|
|
423
|
+
return path.read_text(encoding="utf-8")
|
|
424
|
+
except UnicodeDecodeError:
|
|
425
|
+
return None
|
|
426
|
+
|
|
427
|
+
|
|
414
428
|
def _resolve_island_import(base_dir: Path, import_path: str) -> Path | None:
|
|
415
429
|
"""Best-effort resolve a relative island import (e.g. `../islands/Foo`) to
|
|
416
430
|
a file on disk, trying common component extensions. Returns None if it
|
|
@@ -443,7 +457,9 @@ def lint_personal_position_data(mdx_path: Path, body: str) -> tuple[list[str], l
|
|
|
443
457
|
"the personal-position-data scan for it."
|
|
444
458
|
)
|
|
445
459
|
continue
|
|
446
|
-
island_text = resolved
|
|
460
|
+
island_text = _read_island_text(resolved)
|
|
461
|
+
if island_text is None:
|
|
462
|
+
continue
|
|
447
463
|
problems += _scan_for_position_leaks(island_text, f"imported island `{resolved.name}`")
|
|
448
464
|
return problems, warnings
|
|
449
465
|
|
|
@@ -46,6 +46,7 @@ from pathlib import Path
|
|
|
46
46
|
|
|
47
47
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
48
48
|
import html_mock_review # noqa: E402
|
|
49
|
+
import review_store # noqa: E402
|
|
49
50
|
import learn_feedback # noqa: E402
|
|
50
51
|
import lint_article # noqa: E402
|
|
51
52
|
import repo_locate # noqa: E402
|
|
@@ -618,36 +619,43 @@ def _share_open_summary(composer_ok: bool, folder_ok: bool, is_remote: bool) ->
|
|
|
618
619
|
return f"→ Could not open {' and '.join(missing)} automatically — see the path(s) printed above."
|
|
619
620
|
|
|
620
621
|
|
|
621
|
-
def _auto_post_kit(repo: Repo, kit: Path, slug: str, post_click: bool) -> int | None:
|
|
622
|
+
def _auto_post_kit(repo: Repo, kit: Path, slug: str, post_click: bool, headed: bool = False) -> int | None:
|
|
622
623
|
"""Hand the assembled kit to the personal-use LinkedIn browser-automation tool
|
|
623
624
|
(`pipeline/linkedin_browser.py`, ADR 0007 addendum) instead of the manual
|
|
624
625
|
composer. Returns its exit code, or None if the tool isn't present on this
|
|
625
626
|
machine (any install but the author's) — the caller falls back to the manual
|
|
626
|
-
flow in that case.
|
|
627
|
+
flow in that case. Runs headless unless `headed`. Only the GIF is ever uploaded:
|
|
628
|
+
if it is missing or fails, the run stops and the kit stays for a manual post."""
|
|
627
629
|
script = repo.pipeline / "linkedin_browser.py"
|
|
628
630
|
if not script.exists():
|
|
629
631
|
print("auto-post unavailable here (personal-use tool, see ADR 0007 addendum) "
|
|
630
632
|
"— falling back to the manual composer flow.")
|
|
631
633
|
return None
|
|
634
|
+
gif = kit / f"{slug}.gif"
|
|
635
|
+
if not gif.exists():
|
|
636
|
+
print(f"⚠ auto-post stopped: no GIF at {gif}. Not falling back to MP4. "
|
|
637
|
+
f"Tell the founder; the kit is intact at {kit}.")
|
|
638
|
+
return 5
|
|
632
639
|
cmd = [
|
|
633
640
|
sys.executable, str(script), "post",
|
|
634
|
-
"--media", str(
|
|
635
|
-
"--fallback-media", str(kit / f"{slug}.mp4"),
|
|
641
|
+
"--media", str(gif),
|
|
636
642
|
"--caption-file", str(kit / "caption.txt"),
|
|
637
643
|
"--shotdir", str(kit / "post-evidence"),
|
|
638
644
|
]
|
|
645
|
+
if not headed:
|
|
646
|
+
cmd.append("--headless")
|
|
639
647
|
if not post_click:
|
|
640
648
|
cmd.append("--no-post")
|
|
641
649
|
rc = subprocess.run(cmd, cwd=str(repo.pipeline)).returncode
|
|
642
650
|
if rc != 0:
|
|
643
|
-
print(f"⚠ auto-post failed (exit {rc}) — the kit is intact at {kit};
|
|
651
|
+
print(f"⚠ auto-post failed (exit {rc}) — the kit is intact at {kit}. No MP4 fallback was tried; tell the founder.")
|
|
644
652
|
else:
|
|
645
653
|
print("✓ posted via linkedin_browser.py.")
|
|
646
654
|
return rc
|
|
647
655
|
|
|
648
656
|
|
|
649
657
|
def cmd_share(repo: Repo, slug: str, open_browser: bool = True, fmt: str = "gif",
|
|
650
|
-
post: bool = False, post_click: bool = True) -> int:
|
|
658
|
+
post: bool = False, post_click: bool = True, headed: bool = False) -> int:
|
|
651
659
|
"""Assemble a review-ready LinkedIn kit AND (by default) hand you off to the
|
|
652
660
|
browser: generate the diagram MP4 + GIF + deterministic caption, copy the
|
|
653
661
|
caption to the clipboard, open LinkedIn's composer, and open the kit folder.
|
|
@@ -658,7 +666,7 @@ def cmd_share(repo: Repo, slug: str, open_browser: bool = True, fmt: str = "gif"
|
|
|
658
666
|
`post=True` (CLI `--post`) posts the kit via the personal-use LinkedIn browser
|
|
659
667
|
automation (see `_auto_post_kit`) instead of opening the manual composer;
|
|
660
668
|
`post_click=False` (CLI `--no-post-click`) fills the composer and stops short of
|
|
661
|
-
clicking Post, for a review run."""
|
|
669
|
+
clicking Post, for a review run. The browser runs headless unless `headed` (`--headed`)."""
|
|
662
670
|
if not repo.mdx(slug).exists():
|
|
663
671
|
sys.exit(f"no article '{slug}'.")
|
|
664
672
|
kit = repo.pa / "share-kits" / slug
|
|
@@ -699,7 +707,7 @@ def cmd_share(repo: Repo, slug: str, open_browser: bool = True, fmt: str = "gif"
|
|
|
699
707
|
(kit / "POST.md").write_text(_post_md(slug, url, caption, media_ext, warn), encoding="utf-8")
|
|
700
708
|
|
|
701
709
|
if post:
|
|
702
|
-
rc = _auto_post_kit(repo, kit, slug, post_click)
|
|
710
|
+
rc = _auto_post_kit(repo, kit, slug, post_click, headed)
|
|
703
711
|
if rc is not None:
|
|
704
712
|
print("=" * 64)
|
|
705
713
|
print(f"SHARE KIT: {kit}")
|
|
@@ -873,7 +881,10 @@ def cmd_mock(repo: Repo, slug: str) -> int:
|
|
|
873
881
|
sys.exit("`npm` not found on PATH — install Node/npm to build the site locally.")
|
|
874
882
|
|
|
875
883
|
print(f"building site locally (plain pass, no PUBLISH_BASE) for '{slug}'…", flush=True)
|
|
876
|
-
|
|
884
|
+
# PUBLISH_INCLUDE_DRAFTS lets a draft:true article render in this local review
|
|
885
|
+
# build (no flip needed). deploy.py never sets it, so a draft can't ship.
|
|
886
|
+
rc = subprocess.run([npm, "run", "build"], cwd=str(repo.site),
|
|
887
|
+
env={**os.environ, "PUBLISH_INCLUDE_DRAFTS": "1"}).returncode
|
|
877
888
|
if rc != 0:
|
|
878
889
|
sys.exit(f"local build failed (exit {rc}) — fix the build, then retry `mock`.")
|
|
879
890
|
|
|
@@ -882,10 +893,10 @@ def cmd_mock(repo: Repo, slug: str) -> int:
|
|
|
882
893
|
if not page.exists():
|
|
883
894
|
sys.exit(
|
|
884
895
|
f"build succeeded but expected page not found: {page}\n"
|
|
885
|
-
f"(check that '{slug}' has a route under src/content/articles
|
|
896
|
+
f"(check that '{slug}' has a route under src/content/articles)"
|
|
886
897
|
)
|
|
887
898
|
|
|
888
|
-
out_dir = html_mock_review.
|
|
899
|
+
out_dir = review_store.kind_dir(html_mock_review.KIND) / f"{slug}-session"
|
|
889
900
|
mocker = Path.home() / ".claude" / "skills" / "html-mocker" / "mocker.py"
|
|
890
901
|
record_script = Path(__file__).parent / "html_mock_review.py"
|
|
891
902
|
|
|
@@ -899,8 +910,14 @@ def cmd_mock(repo: Repo, slug: str) -> int:
|
|
|
899
910
|
f'python "{mocker}" "{dist}" --url-path "/{slug}/" --annotate '
|
|
900
911
|
f'--feedback-log "{learn_feedback.COMMENTS_LOG}" --out "{out_dir}"'
|
|
901
912
|
)
|
|
902
|
-
print("\nBuilt
|
|
913
|
+
print("\nBuilt (a draft article is included in this review build, no flip needed).")
|
|
914
|
+
print("Review it with html-mocker's live --annotate panel. Run the command under the Monitor")
|
|
915
|
+
print("tool with persistent=true; Bash is blocked for --annotate.\n")
|
|
903
916
|
print(f" {cmd}\n")
|
|
917
|
+
print("Monitor call:")
|
|
918
|
+
print(json.dumps({"tool": "Monitor", "persistent": True,
|
|
919
|
+
"description": f"html-mocker annotate review for {slug}", "command": cmd}, indent=2))
|
|
920
|
+
print()
|
|
904
921
|
print(f"Watch `{out_dir / 'REVIEW_DONE'}`; once the user submits, read")
|
|
905
922
|
print(f"`{out_dir / 'annotations.jsonl'}`, apply any fixes, then run:")
|
|
906
923
|
print(f" python {record_script} record --slug {slug}")
|
|
@@ -997,6 +1014,8 @@ def main() -> int:
|
|
|
997
1014
|
"instead of the manual composer; degrades gracefully where it isn't present")
|
|
998
1015
|
sh.add_argument("--no-post-click", action="store_true",
|
|
999
1016
|
help="with --post, fill the composer and stop before clicking Post (review run)")
|
|
1017
|
+
sh.add_argument("--headed", action="store_true",
|
|
1018
|
+
help="with --post, show the browser window (default is headless)")
|
|
1000
1019
|
sub.add_parser("doctor")
|
|
1001
1020
|
|
|
1002
1021
|
args = ap.parse_args()
|
|
@@ -1024,7 +1043,7 @@ def main() -> int:
|
|
|
1024
1043
|
return cmd_linkedin(repo, check_slug(args.slug))
|
|
1025
1044
|
if args.mode == "share":
|
|
1026
1045
|
return cmd_share(repo, check_slug(args.slug), open_browser=not args.no_open, fmt=args.format,
|
|
1027
|
-
post=args.post, post_click=not args.no_post_click)
|
|
1046
|
+
post=args.post, post_click=not args.no_post_click, headed=args.headed)
|
|
1028
1047
|
return 2
|
|
1029
1048
|
|
|
1030
1049
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""review_store.py — the one place gate records (architecture council verdicts,
|
|
2
|
+
html-mocker reviews) are stored and read.
|
|
3
|
+
|
|
4
|
+
Records live in ONE per-user folder, not beside whichever copy of the script
|
|
5
|
+
happens to run, so a worktree, the primary checkout and the deployed skill copy
|
|
6
|
+
all see the same record:
|
|
7
|
+
|
|
8
|
+
$PUBLISH_ARTICLE_REVIEWS, else ~/.claude/publish-article/reviews/<kind>/<slug>.json
|
|
9
|
+
|
|
10
|
+
`kind` is "architecture" or "html-mock". Each record keeps its own hash binding
|
|
11
|
+
(spec_hash / content_hash); this module only stores and finds them.
|
|
12
|
+
|
|
13
|
+
A record found only in an older location (beside the script, the deployed skill
|
|
14
|
+
copy, or the repo's skills folder) is copied into the store on first read. The
|
|
15
|
+
old file is left in place.
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import os
|
|
21
|
+
import shutil
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
import repo_locate
|
|
25
|
+
|
|
26
|
+
KINDS = ("architecture", "html-mock")
|
|
27
|
+
_LEGACY_NAMES = {"architecture": ".architecture-reviews", "html-mock": ".html-mock-reviews"}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def store_root() -> Path:
|
|
31
|
+
env = os.environ.get("PUBLISH_ARTICLE_REVIEWS")
|
|
32
|
+
return Path(env) if env else Path.home() / ".claude" / "publish-article" / "reviews"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def kind_dir(kind: str) -> Path:
|
|
36
|
+
if kind not in KINDS:
|
|
37
|
+
raise ValueError(f"unknown review kind {kind!r}; expected one of {KINDS}")
|
|
38
|
+
return store_root() / kind
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def legacy_dirs(kind: str) -> list[Path]:
|
|
42
|
+
name = _LEGACY_NAMES[kind]
|
|
43
|
+
here = Path(__file__).resolve().parent
|
|
44
|
+
candidates = [here / name, Path.home() / ".claude" / "skills" / "publish-article" / name]
|
|
45
|
+
env_repo = repo_locate.env_candidate()
|
|
46
|
+
if env_repo is not None:
|
|
47
|
+
candidates.append(env_repo / "skills" / "publish-article" / name)
|
|
48
|
+
seen, out = set(), []
|
|
49
|
+
for c in candidates:
|
|
50
|
+
key = str(c)
|
|
51
|
+
if key not in seen:
|
|
52
|
+
seen.add(key)
|
|
53
|
+
out.append(c)
|
|
54
|
+
return out
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _path(kind: str, slug: str) -> Path:
|
|
58
|
+
return kind_dir(kind) / f"{slug}.json"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def migrate(kind: str, slug: str | None = None) -> list[str]:
|
|
62
|
+
"""Copy records from older locations into the store. Never overwrites a
|
|
63
|
+
record already in the store. Returns the slugs copied."""
|
|
64
|
+
copied: list[str] = []
|
|
65
|
+
dest = kind_dir(kind)
|
|
66
|
+
for legacy in legacy_dirs(kind):
|
|
67
|
+
if not legacy.is_dir():
|
|
68
|
+
continue
|
|
69
|
+
for f in sorted(legacy.glob("*.json")):
|
|
70
|
+
if slug is not None and f.stem != slug:
|
|
71
|
+
continue
|
|
72
|
+
target = dest / f.name
|
|
73
|
+
if target.exists():
|
|
74
|
+
continue
|
|
75
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
76
|
+
shutil.copy2(f, target)
|
|
77
|
+
copied.append(f.stem)
|
|
78
|
+
return copied
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def read(kind: str, slug: str) -> dict | None:
|
|
82
|
+
p = _path(kind, slug)
|
|
83
|
+
if not p.exists():
|
|
84
|
+
migrate(kind, slug)
|
|
85
|
+
if not p.exists():
|
|
86
|
+
return None
|
|
87
|
+
return json.loads(p.read_text(encoding="utf-8"))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def write(kind: str, slug: str, payload: dict) -> Path:
|
|
91
|
+
p = _path(kind, slug)
|
|
92
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
93
|
+
p.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
94
|
+
return p
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def main() -> int:
|
|
98
|
+
import argparse
|
|
99
|
+
|
|
100
|
+
ap = argparse.ArgumentParser(description="Show where review records live; migrate old ones.")
|
|
101
|
+
ap.add_argument("cmd", choices=["where", "migrate"])
|
|
102
|
+
args = ap.parse_args()
|
|
103
|
+
if args.cmd == "where":
|
|
104
|
+
print(store_root())
|
|
105
|
+
return 0
|
|
106
|
+
for kind in KINDS:
|
|
107
|
+
got = migrate(kind)
|
|
108
|
+
print(f"{kind}: migrated {len(got)} record(s) {got}")
|
|
109
|
+
return 0
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
if __name__ == "__main__":
|
|
113
|
+
raise SystemExit(main())
|
|
@@ -14,13 +14,14 @@ import pytest
|
|
|
14
14
|
|
|
15
15
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
16
16
|
import architecture_review # noqa: E402
|
|
17
|
+
import review_store # noqa: E402
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
@pytest.fixture
|
|
20
21
|
def isolated_reviews(tmp_path, monkeypatch):
|
|
21
|
-
|
|
22
|
-
monkeypatch.setattr(
|
|
23
|
-
return
|
|
22
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "reviews"))
|
|
23
|
+
monkeypatch.setattr(review_store, "legacy_dirs", lambda kind: [])
|
|
24
|
+
return tmp_path / "reviews" / "architecture"
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
@pytest.fixture
|
|
@@ -13,13 +13,14 @@ import pytest
|
|
|
13
13
|
|
|
14
14
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
15
15
|
import html_mock_review # noqa: E402
|
|
16
|
+
import review_store # noqa: E402
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
@pytest.fixture
|
|
19
20
|
def isolated_reviews(tmp_path, monkeypatch):
|
|
20
|
-
|
|
21
|
-
monkeypatch.setattr(
|
|
22
|
-
return
|
|
21
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "reviews"))
|
|
22
|
+
monkeypatch.setattr(review_store, "legacy_dirs", lambda kind: [])
|
|
23
|
+
return tmp_path / "reviews" / "html-mock"
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
def _write_mdx(tmp_path, body: str = "content v1") -> Path:
|
|
@@ -87,3 +88,33 @@ def test_different_slugs_are_independent(isolated_reviews, tmp_path):
|
|
|
87
88
|
assert ok_a is True
|
|
88
89
|
assert ok_b is False
|
|
89
90
|
assert "no html-mocker review recorded for 'slug-b'" in msg_b
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_flipping_draft_or_line_endings_keeps_the_review_valid(isolated_reviews, tmp_path):
|
|
94
|
+
mdx = tmp_path / "article.mdx"
|
|
95
|
+
mdx.write_text('---\ntitle: "T"\ndraft: true\n---\nbody text\n', encoding="utf-8")
|
|
96
|
+
html_mock_review.record("some-slug", mdx)
|
|
97
|
+
mdx.write_bytes(b'---\r\ntitle: "T"\r\ndraft: false\r\n---\r\nbody text\r\n')
|
|
98
|
+
ok, msg = html_mock_review.check("some-slug", mdx)
|
|
99
|
+
assert ok is True, msg
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_changing_title_or_body_still_invalidates(isolated_reviews, tmp_path):
|
|
103
|
+
mdx = tmp_path / "article.mdx"
|
|
104
|
+
mdx.write_text('---\ntitle: "T"\ndraft: true\n---\nbody text\n', encoding="utf-8")
|
|
105
|
+
html_mock_review.record("some-slug", mdx)
|
|
106
|
+
mdx.write_text('---\ntitle: "T2"\ndraft: true\n---\nbody text\n', encoding="utf-8")
|
|
107
|
+
assert html_mock_review.check("some-slug", mdx)[0] is False
|
|
108
|
+
mdx.write_text('---\ntitle: "T"\ndraft: true\n---\nbody text changed\n', encoding="utf-8")
|
|
109
|
+
assert html_mock_review.check("some-slug", mdx)[0] is False
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_record_with_old_hash_scheme_is_stale(isolated_reviews, tmp_path):
|
|
113
|
+
import json
|
|
114
|
+
|
|
115
|
+
mdx = _write_mdx(tmp_path)
|
|
116
|
+
isolated_reviews.mkdir(parents=True)
|
|
117
|
+
(isolated_reviews / "some-slug.json").write_text(
|
|
118
|
+
json.dumps({"slug": "some-slug", "content_hash": html_mock_review.content_hash(mdx)}), encoding="utf-8")
|
|
119
|
+
ok, msg = html_mock_review.check("some-slug", mdx)
|
|
120
|
+
assert ok is False and "stale" in msg
|
|
@@ -17,7 +17,8 @@ import sys
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
|
|
19
19
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
20
|
-
import architecture_review
|
|
20
|
+
import architecture_review
|
|
21
|
+
import review_store # noqa: E402
|
|
21
22
|
from lint_article import lint # noqa: E402
|
|
22
23
|
import lint_article # noqa: E402
|
|
23
24
|
|
|
@@ -232,10 +233,10 @@ def _build_arch_site(tmp_path, *, composes=True, palette=CANONICAL_PALETTE_TS, e
|
|
|
232
233
|
|
|
233
234
|
|
|
234
235
|
def _isolate_reviews(tmp_path, monkeypatch):
|
|
235
|
-
reviews_dir = tmp_path / "reviews"
|
|
236
236
|
spec_path = tmp_path / "ARCHITECTURE-DIAGRAMS.md"
|
|
237
237
|
spec_path.write_text("spec v1", encoding="utf-8")
|
|
238
|
-
monkeypatch.
|
|
238
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "reviews"))
|
|
239
|
+
monkeypatch.setattr(review_store, "legacy_dirs", lambda kind: [])
|
|
239
240
|
monkeypatch.setattr(architecture_review, "SPEC_PATH", spec_path)
|
|
240
241
|
return spec_path
|
|
241
242
|
|
|
@@ -321,3 +321,26 @@ def test_how_i_write_link_does_not_block_full_lint(tmp_path):
|
|
|
321
321
|
assert ok is True
|
|
322
322
|
assert not any("doesn't resolve to a known site route" in m for m in messages)
|
|
323
323
|
assert not any("Technicals section" in m for m in messages)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def test_imported_png_asset_does_not_crash_the_island_scan(tmp_path):
|
|
327
|
+
(tmp_path / "chip.png").write_bytes(b"\x89PNG\r\n\x1a\n\x00\x00\xff\xfe")
|
|
328
|
+
body = GOOD_OPENING + 'import chip from "./chip.png";\n\n## Details\nPlain text.\n'
|
|
329
|
+
p = write(tmp_path, body)
|
|
330
|
+
ok, messages = lint(p)
|
|
331
|
+
assert not any("position" in m for m in messages)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def test_imported_non_utf8_file_is_skipped_not_fatal(tmp_path):
|
|
335
|
+
(tmp_path / "blob.bin").write_bytes(b"\x89\x00\xff\xfe\x80")
|
|
336
|
+
body = GOOD_OPENING + 'import blob from "./blob.bin";\n\n## Details\nPlain text.\n'
|
|
337
|
+
p = write(tmp_path, body)
|
|
338
|
+
lint(p)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
def test_island_source_is_still_scanned_for_position_language(tmp_path):
|
|
342
|
+
(tmp_path / "Chart.tsx").write_text("export default () => 'This is my position and my net worth grew';", encoding="utf-8")
|
|
343
|
+
body = GOOD_OPENING + 'import Chart from "./Chart.tsx";\n\n## Details\nPlain text.\n'
|
|
344
|
+
p = write(tmp_path, body)
|
|
345
|
+
ok, messages = lint(p)
|
|
346
|
+
assert ok is False and any("imported island" in m for m in messages)
|
|
@@ -803,7 +803,9 @@ def test_share_post_invokes_linkedin_browser_when_present(repo, monkeypatch):
|
|
|
803
803
|
assert cmd[1] == str(script)
|
|
804
804
|
assert cmd[2] == "post"
|
|
805
805
|
assert cmd[cmd.index("--media") + 1] == str(kit / f"{slug}.gif")
|
|
806
|
-
assert
|
|
806
|
+
assert "--fallback-media" not in cmd
|
|
807
|
+
assert not any(str(c).endswith(".mp4") for c in cmd)
|
|
808
|
+
assert "--headless" in cmd
|
|
807
809
|
assert cmd[cmd.index("--caption-file") + 1] == str(kit / "caption.txt")
|
|
808
810
|
assert cmd[cmd.index("--shotdir") + 1] == str(kit / "post-evidence")
|
|
809
811
|
assert "--no-post" not in cmd
|
|
@@ -862,3 +864,68 @@ def test_share_without_post_flag_never_invokes_auto_post(repo, monkeypatch):
|
|
|
862
864
|
rc = publish_article.cmd_share(repo, slug, open_browser=False, post=False)
|
|
863
865
|
|
|
864
866
|
assert rc == 0
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
# ============================================================================ mock
|
|
870
|
+
def test_mock_builds_a_draft_preview_and_prints_the_monitor_form(repo, monkeypatch, tmp_path, capsys):
|
|
871
|
+
slug = "draft-preview-slug"
|
|
872
|
+
repo.mdx(slug).write_text('---\ntitle: "T"\nsummary: "S"\ndraft: true\n---\n\nBody.\n', encoding="utf-8")
|
|
873
|
+
page = repo.site / "dist" / slug / "index.html"
|
|
874
|
+
page.parent.mkdir(parents=True, exist_ok=True)
|
|
875
|
+
page.write_text("<html></html>", encoding="utf-8")
|
|
876
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "reviews"))
|
|
877
|
+
seen = []
|
|
878
|
+
|
|
879
|
+
def fake_run(cmd, **kwargs):
|
|
880
|
+
seen.append((cmd, kwargs.get("env")))
|
|
881
|
+
class R:
|
|
882
|
+
returncode = 0
|
|
883
|
+
return R()
|
|
884
|
+
|
|
885
|
+
monkeypatch.setattr(publish_article.subprocess, "run", fake_run)
|
|
886
|
+
monkeypatch.setattr(publish_article.shutil, "which", lambda n: "/usr/bin/npm")
|
|
887
|
+
assert publish_article.cmd_mock(repo, slug) == 0
|
|
888
|
+
build_env = [env for cmd, env in seen if env and "PUBLISH_INCLUDE_DRAFTS" in env]
|
|
889
|
+
assert build_env and build_env[0]["PUBLISH_INCLUDE_DRAFTS"] == "1"
|
|
890
|
+
out = capsys.readouterr().out
|
|
891
|
+
assert "Monitor call:" in out and '"persistent": true' in out
|
|
892
|
+
assert str(tmp_path / "reviews" / "html-mock" / f"{slug}-session") in out
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
def test_share_post_headed_override_drops_headless(repo, monkeypatch):
|
|
896
|
+
slug = "post-headed-slug"
|
|
897
|
+
_make_share_ready_article(repo, slug)
|
|
898
|
+
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None)
|
|
899
|
+
repo.pipeline.mkdir(parents=True, exist_ok=True)
|
|
900
|
+
(repo.pipeline / "linkedin_browser.py").write_text("# fake", encoding="utf-8")
|
|
901
|
+
captured = {}
|
|
902
|
+
|
|
903
|
+
def fake_run(cmd, **kwargs):
|
|
904
|
+
captured["cmd"] = cmd
|
|
905
|
+
class R:
|
|
906
|
+
returncode = 0
|
|
907
|
+
return R()
|
|
908
|
+
|
|
909
|
+
monkeypatch.setattr(publish_article.subprocess, "run", fake_run)
|
|
910
|
+
assert publish_article.cmd_share(repo, slug, open_browser=False, post=True, headed=True) == 0
|
|
911
|
+
assert "--headless" not in captured["cmd"]
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
def test_share_post_without_a_gif_stops_and_never_uses_the_mp4(repo, monkeypatch, capsys):
|
|
915
|
+
slug = "post-no-gif-slug"
|
|
916
|
+
_make_share_ready_article(repo, slug)
|
|
917
|
+
monkeypatch.setattr(publish_article.shutil, "which", lambda name: None)
|
|
918
|
+
repo.pipeline.mkdir(parents=True, exist_ok=True)
|
|
919
|
+
(repo.pipeline / "linkedin_browser.py").write_text("# fake", encoding="utf-8")
|
|
920
|
+
kit = repo.pa / "share-kits" / slug
|
|
921
|
+
monkeypatch.setattr(publish_article, "_island_gif", lambda r, s: None)
|
|
922
|
+
(kit).mkdir(parents=True, exist_ok=True)
|
|
923
|
+
(kit / f"{slug}.mp4").write_bytes(b"x")
|
|
924
|
+
|
|
925
|
+
def boom(cmd, **kwargs):
|
|
926
|
+
raise AssertionError("linkedin_browser must not run without a GIF")
|
|
927
|
+
|
|
928
|
+
monkeypatch.setattr(publish_article.subprocess, "run", boom)
|
|
929
|
+
rc = publish_article.cmd_share(repo, slug, open_browser=False, post=True)
|
|
930
|
+
assert rc == 5
|
|
931
|
+
assert "Not falling back to MP4" in capsys.readouterr().out
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for review_store.py — the one shared location for gate records, readable
|
|
3
|
+
from any checkout and from the deployed skill copy, with migration of old records.
|
|
4
|
+
|
|
5
|
+
Run: pytest skills/publish-article/tests/test_review_store.py
|
|
6
|
+
"""
|
|
7
|
+
import json
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
14
|
+
import review_store # noqa: E402
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
def store(tmp_path, monkeypatch):
|
|
19
|
+
monkeypatch.setenv("PUBLISH_ARTICLE_REVIEWS", str(tmp_path / "store"))
|
|
20
|
+
legacy = tmp_path / "legacy"
|
|
21
|
+
monkeypatch.setattr(review_store, "legacy_dirs", lambda kind: [legacy / kind])
|
|
22
|
+
return tmp_path
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_store_location_does_not_depend_on_the_script_location(store, tmp_path):
|
|
26
|
+
assert review_store.kind_dir("architecture") == tmp_path / "store" / "architecture"
|
|
27
|
+
assert review_store.kind_dir("html-mock") == tmp_path / "store" / "html-mock"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_default_location_is_per_user(monkeypatch):
|
|
31
|
+
monkeypatch.delenv("PUBLISH_ARTICLE_REVIEWS", raising=False)
|
|
32
|
+
assert review_store.store_root() == Path.home() / ".claude" / "publish-article" / "reviews"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_unknown_kind_is_rejected(store):
|
|
36
|
+
with pytest.raises(ValueError):
|
|
37
|
+
review_store.kind_dir("nope")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_write_then_read_round_trips(store):
|
|
41
|
+
review_store.write("architecture", "s", {"verdict": "pass"})
|
|
42
|
+
assert review_store.read("architecture", "s") == {"verdict": "pass"}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_read_missing_returns_none(store):
|
|
46
|
+
assert review_store.read("html-mock", "absent") is None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_old_record_is_migrated_on_first_read_and_left_in_place(store, tmp_path):
|
|
50
|
+
old = tmp_path / "legacy" / "architecture"
|
|
51
|
+
old.mkdir(parents=True)
|
|
52
|
+
(old / "s.json").write_text(json.dumps({"verdict": "pass", "spec_hash": "abc"}), encoding="utf-8")
|
|
53
|
+
assert review_store.read("architecture", "s")["spec_hash"] == "abc"
|
|
54
|
+
assert (tmp_path / "store" / "architecture" / "s.json").exists()
|
|
55
|
+
assert (old / "s.json").exists()
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_migration_never_overwrites_a_record_already_in_the_store(store, tmp_path):
|
|
59
|
+
old = tmp_path / "legacy" / "html-mock"
|
|
60
|
+
old.mkdir(parents=True)
|
|
61
|
+
(old / "s.json").write_text(json.dumps({"content_hash": "old"}), encoding="utf-8")
|
|
62
|
+
review_store.write("html-mock", "s", {"content_hash": "new"})
|
|
63
|
+
review_store.migrate("html-mock")
|
|
64
|
+
assert review_store.read("html-mock", "s") == {"content_hash": "new"}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_kinds_do_not_mix(store):
|
|
68
|
+
review_store.write("architecture", "s", {"a": 1})
|
|
69
|
+
assert review_store.read("html-mock", "s") is None
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasaswy.nagavolu/agents",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.13",
|
|
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",
|