feat: vk create --mode replica|script (+aspect/bgm) for 0.4.2#2
Merged
Conversation
Apply findings from /simplify review: - client/figlens/stream.go: add typed Code field to StreamEvent so task.failed events carry the SSE envelope code as data, not stuffed into Message as a "[code] msg" string prefix. Eliminates the leaky cross-package string protocol the cmd package was parsing. - internal/httpclient/errors.go: extract MapBusinessCode(envCode) as the single source of truth for 100xxx → label mappings; SSE and HTTP paths now both delegate, so a new business code only needs one edit. - client/figlens/task.go: embed InitTaskParams in initTaskWire (was copy-pasted field-by-field); export VideoKindReplica / VideoKindScriptLock constants used by cmd/create.go. - cmd/create.go: switch on ev.Code instead of string-prefix scanning ev.Message; collapse scriptInvalid+taskFailed booleans into a single failExitCode int; delete dead helpers (scriptInvalidPrefix, isScriptInvalidMessage, extractScriptInvalidUserMessage); trim resolver comments and the redundant invariant comment above the script_lock kbID/docID setup. - tests/integration/create_mode_test.go: flush after each SSE event in the fastQueryOptimize mock, matching the stream handler pattern. No behavior changes for users. All existing tests pass; the NDJSON task.failed envelope now also carries a "code" field alongside "message" (purely additive).
Re-cut this branch as a patch release. The next minor (0.5.0) is
reserved for engine selection (vk create --engine agent|pipeline),
which is a wider-surface change introducing a new SSE event type
(node.progress) and cross-flag validation. Video-kinds is comparatively
a "thread new flags through existing pipeline" patch and fits 0.4.2.
Source-of-truth flips:
- package.json
- skills/vibeknow-{core,create,doc}/SKILL.md
- CHANGELOG.md heading
Spec files (untracked docs/) reflect the new numbering separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unlocks two go-figlens video modes that the CLI couldn't reach, behind a single
vk create --modeflag:--mode replica— PPT/PDF page-by-page reproduction (doc_replica_plan/doc_replica_shootpipeline).--mode script— verbatim-script narration ("讲稿锁定"). Backend preflight at/v1/tasks/initdecides whether the doc is suitable; rejection exits 2 with the backend's localized message (not a generic "business error").--aspect horizontal|vertical(with16:9/9:16aliases) and--bgmflags wired through the same client structs.Default invocation (no
--mode, no--aspect, no--bgm) produces byte-identical wire bodies to 0.4.1.Spec:
docs/superpowers/specs/2026-05-14-video-kinds-design.mdPlan:
docs/superpowers/plans/2026-05-14-video-kinds.mdWhat's in the diff
client/figlens/{optimize,stream,task}.go— threadvideo_kind(+aspect,bgm_enabled) through three SSE/HTTP endpoints;StreamEventgains a typedCodefield so callers don't parse error labels out of the message string.cmd/create.go—--mode/--aspect/--bgmflag registration, resolver helpers with table tests, kbID/docID promoted to InitTask payload for script mode, exit-2 routing on both the InitTask HTTP path and the SSEtask.failedpath.internal/stage/stage.go— mapdoc_replica_plan→outlineanddoc_replica_shoot→renderso replica-mode SSE events aren't filtered.internal/httpclient/errors.go— extractMapBusinessCode(envCode)shared between SSE and HTTP error paths so new backend business codes only need one edit site.internal/i18n/strings.go— six new keys, both en and zh.tests/integration/create_mode_test.go— end-to-end test asserting wire body + SSE node visibility.CHANGELOG.md,AGENTS.md,README{,.zh}.md— documentation for the new flags.package.json+skills/*/SKILL.md— version bump to 0.5.0.14 commits, all green.
Test plan
go test ./...passes (incl. integration test at ~83s)go build ./...cleanvk create --helpshows the three new flagsvk versionprintsv0.5.0vk create --from <src>wire body unchanged (covered byOmits*unit tests on each client call)--mode replicareachesdoc_replica_planSSE event end-to-end (integration test)