Communitygithub.com

源码溯源 (Source Recon)

锁定产品源代码为只读导出,验证该提交与生产环境一致,并将视频脚本的每个屏幕映射到对应的路由、组件、国际化字符串和状态,最终写入视频的 SOURCES.md 文件。

源码溯源 (Source Recon) 是什么?

该技能旨在解决视频制作中因代码版本不匹配而导致的错误。它通过只读方式锁定并导出产品源代码,确保用于屏幕映射的代码与生产环境真实运行的代码一致,从而避免类似“基于旧代码重做视频”的悲剧。用户可通过“what changed”、“refresh the sources”、“which commit is in prod”等指令触发此技能。 技能工作流程清晰:首先,使用 `fetch_sources.py` 脚本根据 product.yaml 中定义的来源(Git 仓库 URL 或本地路径)将代码以只读方式导出到 `sources/` 目录,并生成 `sources.lock` 文件记录提交哈希。导出过程会保留 Git 历史,并对路径来源进行哈希校验。其次,通过检查发布标签、部署流水线配置或团队确认等手段,断言哪个提交正在生产环境运行。若无法确认,会在结果中明确标注“production commit unconfirmed”。 接着,技能会读取视频的 BRIEF.md 和 COVERAGE.md,为每个屏幕并行启动只读“探索子代理”(Explore subagent),子代理根据模板定向分析导出的代码,返回路由、组件文件、i18n 键值对、控制渲染的状态(如标志位、功能门控)、图标和资源,以及任何未发布或受限的代码。在写入 SOURCES.md 前,还需人工抽查视频片段与导出版本是否一致。 最终生成的 SOURCES.md 文件以表格形式列出每个屏幕的映射信息,并包含 `strings`、`state`、`icons`、`flags or gates` 等详细条目。对于代码中不存在的屏幕,会记录为“未找到”并列出可用的无代码参考资料(如录屏、会话记录截图)。当代码变更时,`changed_since.py` 脚本能高效地识别哪些视频的依赖文件发生了变化,指导后续更新。该技能支持多种 AI Agent 平台,遵循只读操作、不泄露密钥、标记受限特性、避免使用真实数据等严格规则。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/josueh04/product-video-skills/tree/HEAD/skills/source-recon

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

源码溯源 (Source Recon) 是做什么的?

视频中的每一个像素和每一句话最终都要与代码进行比对,因此所使用的代码必须是正确的。在生成此技能的实际生产环境中,主前端签出(checkout)落后生产环境约两个月,而当前代码则位于另一个无人关注的工作区中。在有人注意到之前,同一个视频的三个版本都是基于旧代码重建的。该技能的存在就是为了杜绝此类事件再次发生:首先锁定源码,证明其与生产环境一致,然后将屏幕映射到文件。

操作要求:只读。你只能读取代码;不得编辑、签出、拉取到或创建工作区。用户的工作树可能包含未提交的工作,而签出或拉取操作会改变他们未要求你更改的状态。

1. 锁定源码 (Pin the sources)

PVS_HOME="$(cd "$(cd "${CLAUDE_SKILL_DIR}" && pwd -P)/../.." && pwd)"
"$PVS_HOME/bin/pvs-py" "$PVS_HOME/skills/source-recon/scripts/fetch_sources.py" <product_dir>

该脚本读取 product.yaml 中的 sources: 字段,并根据角色(role)执行以下操作:

  • url: 将分支浅克隆到 sources/.git-cache/<role>.git 并进行导出。
  • path: (指向 Git 仓库):对 <branch> 和 origin/<branch> 中较新的一个执行 git archive。当本地分支落后于远程或已分叉、远程引用(origin refs)是一周前拉取的、以及同一仓库的另一个工作区比导出结果更新时,会发出警告。
  • path: (非 Git 仓库):直接复制,并通过文件哈希锁定("pinned": false,因此对它的引用可能会在无警告的情况下失效;优先使用 Git 源)。

导出结果存放在 sources/<role>/ 目录下(只读),sources.lock 记录提交哈希。如果磁盘上缺少已锁定的角色(例如产品仓库新克隆),则会从锁定的提交中恢复导出,以确保引用始终指向正确的代码行。请读取并处理其输出的每一条 note: 行,因为它们都可能表明导出结果并非生产环境代码。

后续所有引用都使用 <role>/<path>:<line>@<short sha> 格式,其中路径相对于仓库根目录(因此 sources/<role>/<path> 存在),sha 是锁定的提交哈希。

2. 证明它是生产环境代码 (Prove it is production)

分支名不是证明。生产环境代码是部署管道最后构建的代码。在映射任何屏幕之前,按以下优先级确定哪个提交在生产环境运行:

  1. 发布记录:发布标签、部署日志、部署仓库中的“上次部署的 sha”文件。
  2. 部署管道配置:它从哪个分支构建,以及构建参数(构建时注入的环境变量可能会改变品牌形象或隐藏功能)。
  3. 团队确认的最新部署分支,结合 git worktree list、分支日期和 merge-base 进行验证。

请阅读 references/freshness.md 了解具体命令和注意事项(过时的远程引用、功能标志、改变渲染结果的构建参数)。如果你无法确认生产环境提交,请在 SOURCES.md 顶部明确说明("production commit unconfirmed"),然后向用户提出一个封闭式问题并附上建议答案,例如:“将 origin/develop(最新,包含主分支)导出作为生产环境代码?建议:是,这是部署工作流构建的内容。”

当用户确认使用不同分支后,修改 product.yaml 中的 branch: 字段,并运行 fetch_sources.py <product_dir> --refresh --role <role>(如果视频已引用此源,请先运行 changed_since.py,见第 6 节)。

3. 映射每个屏幕 (Map each screen)

获取视频的 BRIEF.md(章节)和 COVERAGE.md 中的屏幕和状态。为每个屏幕(或共享组件的一小组屏幕)启动一个只读的“探索子代理”(Explore subagent),并行执行。为每个子代理提供 references/recon-prompt.md 中的提示,并指向 sources/<role>/(锁定后的导出目录,绝不是用户的工作区),以确保返回的每个行号都与锁定的提交匹配。

每个子代理应返回(含引用):路由、页面和相关子组件(模板、逻辑、样式文件)、视频语言对应的 i18n 键和准确字符串、决定渲染内容的控制状态(默认值、标志、功能门控、空状态、权限检查)、使用的图标集和资源,以及任何看起来未发布、受门控或受限的内容。

然后,你需亲自对照生产环境校验内容:从你拥有的任何参考资料(录屏、恢复的截图、文档)中抽查每个屏幕的两到三个字符串。如果发现字符串不同,说明导出的代码不是生产环境代码,或者该屏幕被功能门控隐藏。在编写 SOURCES.md 之前解决此问题。

4. 编写 SOURCES.md (Write SOURCES.md)

每个视频对应一个文件,位于 videos/<video>/SOURCES.md:

# 来源:<video>

锁定:前端 main@1a2b3c4 (2026-01-12),后端 main@5d6e7f8 (2026-01-10)
生产环境:由 <release tag v4.2.0 | deploy workflow builds main | team confirmation> 确认

| 屏幕 | 路由 | 组件 | 引用
|---|---|---|---|
| 看板,空状态 | /board | BoardPage > TaskList > EmptyState | frontend/src/pages/board/BoardPage.tsx:14@1a2b3c4 |

## 看板,空状态
- 字符串:`board.empty.title` "暂无计划" (frontend/src/i18n/en.json:88@1a2b3c4)
- 状态:当 `tasks.length === 0` 时渲染 (frontend/src/pages/board/TaskList.tsx:41@1a2b3c4)
- 图标:lucide `calendar-plus` (frontend/src/pages/board/EmptyState.tsx:9@1a2b3c4)
- 标志或门控:未发现
- 未找到:<剧情需要但代码中不存在的任何内容>

## 无代码参考
<每个无代码屏幕的可用参考资料,见第 5 节>

没有引用的屏幕不会出现在视频中。将其列入“未找到”部分并告知用户;虚构屏幕是审核者无法容忍的错误,因为它展示了一个不存在的产品。

5. 列出无代码参考 (List the no-code references)

对于代码无法展示的屏幕(第三方 UI、运行时输出、仓库中不存在的后端、或完全没有前端代码),请按照以下偏好顺序列出可用资料:references/ 中的录屏分析、从过去会话中可恢复的截图、像生产环境一样构建的本地实例、公开文档和截图。请勿在此处自行截取;那是 ui-reference-capture 的任务。切勿依赖审核者的个人浏览器。

6. 当代码发生变化时 (When the code changes)

"$PVS_HOME/bin/pvs-py" "$PVS_HOME/skills/source-recon/scripts/changed_since.py" <product_dir> [--offline]

该脚本比较每个锁定的提交与当前分支头部 (HEAD),并列出所有引用了已更改文件的视频(和工具包文件),这些文件记录在 SOURCES.md、TRUTH.md、规格或 video/src/ 中,并标记出具体行已更改的引用。它不会移动任何文件。在任何 --refresh 操作之前运行它:因为它比较的是锁定与当前头部,而刷新会使两者一致,之后变更列表就会消失(脚本会转而输出提示)。向用户展示该列表,然后,如果他们需要新代码,运行 fetch_sources.py --refresh,为受影响的屏幕重新运行 ui-spec-from-code,为受影响的行重新运行 product-truth。未引用任何已更改文件的视频保持不变。

规则及原因 (Rules and why)

  • 读取导出,引用锁定。 来自不同签出版本的行号会在下一次刷新后悄然指向错误的代码。
  • 切勿打印你在代码中发现的秘密。 前端通常包含密钥和令牌。仅报告文件路径和行号,并将其作为安全风险告知用户。
  • 未发布、受门控或受限的功能同样是事实。 在 SOURCES.md 中标记它们(gate: <flag>,restricted: <who sees it>)。product-truth 将决定视频是否可以展示它们,通常需要审核者签字确认。
  • 保持真实数据隔离。 仓库中的固件和种子文件可能包含真实客户名称。引用它们的结构,切勿引用它们的值。

Individual skills in this repo

This repo contains 14 individual skills — each has its own dedicated page.

josueh04/product-video-skills

Extract, once per product, everything every video of it reuses and write it to kit/ and product.yaml (design tokens, font subsets as woff2, icon subsets as SVG from the product's own icon packages, logos in light, dark and app-tile variants from the repo, a fictional cast proposed once for veto and then frozen, the canonical-names map, pronunciations, banned terms and the read-only tool list). Use it when a product is set up or its kit is missing or incomplete, when a video needs an icon, font or logo that is not in kit/ yet, when someone asks for demo names, fake customers, phone numbers or emails, when a brand word is mispronounced or an old product name shows up, and when checking that demo data is fictional.

josueh04/product-video-skills

Interview the user about a product, then create products/<slug>/ with its own git history, a filled product.yaml and linked skills, fetch its sources and build its kit. Run only when the user types /product-new.

josueh04/product-video-skills

Back every sentence of a video's narration (audio/lines.tsv) and every screen it shows with a citation into the pinned source code (role/path:line@sha) or a docs URL, mark what is visible in the UI versus backend-only, flag restricted or unreleased features, and cut or rewrite anything unbacked; writes the video's TRUTH.md and checks it with truth_check.py. Use it whenever a script or narration is drafted or edited, before voice is generated, before a build, when someone asks "can we say this?", "is this true?", "does the product really do X?", when a reviewer asks for a feature or a claim the product may not support, and when a source document (pitch deck, PRD, marketing page) makes claims the video wants to repeat.

josueh04/product-video-skills

Check a rendered product video before anyone else sees it: worker-pattern flicker, black frames, loudness and true peak, clipping, clicks at clip edges, overlapping narration, speech to text against the script, banned terms and legacy names, camera zoom, contact sheets, frame strips at transitions and parity against the approved version; then write qa/REPORT.json, the only thing deliver.py accepts. Use it after every HyperFrames render, whenever someone asks "is the render clean", "QA this", "check the video", "check the audio", "why does it flicker", "there is a click", "compare v3 with v2", "did the approved part change", or before showing, sending, uploading or delivering any MP4, even when the request does not say QA. Also use it to triage a defect a reviewer reported in a render.

josueh04/product-video-skills

Write a product video's narration and turn it into voice clips with word timings, pronunciation fixes, sound effects and even loudness. The script becomes a table of moments and then audio/lines.tsv (one clip per sentence, with role and speed columns); tts.py voices it with ElevenLabs or the free macOS say voice, maps brand respellings back to the on-screen spelling, normalizes every clip and writes audio/timings.json for the composer; make_sfx.py builds typing tracks from real keystrokes and places recorded click and pop sounds. Use it whenever a video needs a script, narration, voice-over, lines.tsv, timings.json, TTS, a new take, a voice or casting choice, a pronunciation fix ("it says the name wrong"), a changed sentence, a tone note ("too hype", "sounds cut off"), audio levels, a click at the end of a clip, typing or click sounds, or when the build stage asks for the voice. Also use it for silent loops, which still need a moment table and SFX.

josueh04/product-video-skills

The animation rules that keep HyperFrames' parallel render workers from dropping, flashing or flickering elements, plus a static lint (lint_motion.py) that finds the violations in a video's template before it costs a render. Use it whenever you write or edit GSAP tweens, timelines, cursors, camera moves, typing, scrolls or pop-ups in a HyperFrames composition or a video's src/template.tpl, whenever a render shows flicker, stutter, an element that vanishes on some frames, a title that flashes, or a "WORKER PATTERN" line from scan_render.py or qa.py, and whenever the preview looks right but the MP4 does not. Also use it to review someone else's timeline code before rendering.

josueh04/product-video-skills

Compose a narrated product demo in HyperFrames: the stage (the product UI rebuilt at its real viewport and scaled to 1080p, camera, rack focus with veil, chapter titles, cursor and clicks, typing, streaming text, pop-ups, toasts, scrolls, end screen and lockup) and the build.py that anchors every beat to a word of the narration. Use it whenever you write or edit a video's video/build.py, src/template.tpl or src/app.css, place a beat on a word, add a chapter, a click, a pop-up or a push-in, frame a screen, build the end screen or lockup, snapshot setup beats, or render a draft or delivery MP4 of a product video in this workbench. Also use it when someone says "the cursor is off", "too zoomed in", "too fast", "it feels chaotic", "the title flashes", "sync the UI to the voice", or asks for a walkthrough, demo or pitch video of a UI.

josueh04/product-video-skills

Gather pixel references for UI that the code cannot show, or to check a rebuild against the real thing, using frames and timed OCR text from screen recordings, captures recovered from past Claude Code session transcripts, a local instance of the app built like production, and web research for third-party apps, plus side-by-side parity images and contact sheets. Use it whenever someone hands over a screen recording (.mov or .mp4) of the product, when a screen has no usable source code (a stale checkout, another company's UI such as a sign-in page, calendar or CRM, runtime output from a backend not in the repos), when asked "what does it really look like", "match the recording", "how long does that animation take in the app", "compare our render to the real app", or when screenshots from an earlier session might already exist. Never uses the reviewer's personal browser.

josueh04/product-video-skills

Turn a product's real frontend code into 1:1 rebuild specs for a video, one read-only subagent per screen, each returning static HTML, CSS with every variable resolved to its literal value and cited (role/path:line@sha), every state, transitions with exact durations and easings, icons from the code's own icon sets, and the exact i18n strings; plus resolve_tokens.py to write the product's design tokens to kit/tokens.css. Use it whenever a screen of the product has to appear in a video, when writing or fixing video/src/app.css or the template markup, when someone asks for exact sizes, colors, fonts, paddings, animations or icons of a screen, when a rebuilt screen "looks off" next to the real app, and when the design tokens or theme of a product need extracting. Framework adapters cover Angular with PrimeNG (proven), React, Vue, Tailwind and plain HTML (unproven).

josueh04/product-video-skills

Say where this session stands in the Product Video Skills workbench (setup state, which product and video the current folder belongs to, the stage of every video) and the exact next command to type. Also answers "how do I..." questions about the workbench from its docs.

josueh04/product-video-skills

Coordinate the build of one or more signed videos of the current product with subagents (source recon, product truth, UI specs, voice, one builder per video), re-run QA itself, then deliver. A light coordinator that never builds itself. Run only when the user types /video-build.

josueh04/product-video-skills

Start a new video of the current product - create videos/<video>/, write BRIEF.md, the feature coverage matrix (COVERAGE.md) and the claims sheet (CLAIMS.md), propose chapters, then stop for the reviewer's sign-off. Never builds. Run only when the user types /video-new.

josueh04/product-video-skills

Turn a batch of reviewer feedback on the product's videos into one table per video, fix every video that got notes in parallel (one subagent each) while keeping approved parts, re-run QA and parity, bump versions and deliver. Run only when the user types /video-review.

josueh04/product-video-skills

Check this machine and install the pinned video toolchain of the Product Video Skills workbench (HyperFrames CLI, its rendering Chrome and its agent skills from the same release, the Python environment, the speech model for QA), then run the self-check. Safe to run again. `/video-setup check` only reports.

相关技能