@nodaro/prompts 1.3.1 → 1.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodaro/prompts",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Nodaro's prompt-engineering layer — person/picker catalogs with prompt hints, identity-lock clauses, entity prompt builders, brand presets, and prompt/reference assembly shared by the Nodaro platform and SDK.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -171,3 +171,25 @@ describe("resolveSeedance2Inputs", () => {
171
171
  }
172
172
  })
173
173
  })
174
+
175
+ describe("promptBindsFirstFrame suffix suppression (overlap colon-position finding)", () => {
176
+ it("suppresses the trailing sentence when the prompt already binds the first frame", () => {
177
+ const r = resolveSeedance2Inputs({
178
+ prompt: "extend @video_1 as follows:use @image_1 as the first frame, it is the last keyframe of @video_1\nbeats",
179
+ firstFrameUrl: "https://r2/anchor.jpg",
180
+ refVideoUrls: ["https://r2/ref.mp4"],
181
+ })
182
+ expect(r.promptSuffix).toBe("")
183
+ expect(r.referenceImageUrls).toEqual(["https://r2/anchor.jpg"]) // image still rides
184
+ })
185
+
186
+ it("keeps the sentence for plain prompts and for first+last frame pairs", () => {
187
+ const plain = resolveSeedance2Inputs({ prompt: "a cat", firstFrameUrl: "https://r2/a.jpg", refVideoUrls: ["https://r2/v.mp4"] })
188
+ expect(plain.promptSuffix).toContain("opening (first) frame")
189
+ const both = resolveSeedance2Inputs({
190
+ prompt: "use @image_1 as the first frame, it is the last keyframe of @video_1",
191
+ firstFrameUrl: "https://r2/a.jpg", lastFrameUrl: "https://r2/b.jpg", refVideoUrls: ["https://r2/v.mp4"],
192
+ })
193
+ expect(both.promptSuffix).toContain("closing (last) frame") // pair sentence kept — last frame has no in-prompt binding
194
+ })
195
+ })
@@ -4,6 +4,9 @@ import { REF_BINDING } from "./video-reference-resolver.js"
4
4
  export type Seedance2Mode = "first-frame" | "first-last-frame" | "reference"
5
5
 
6
6
  export interface Seedance2InputsArgs {
7
+ /** The generation prompt — used ONLY to detect an existing first-frame
8
+ * binding and suppress the duplicate trailing sentence. */
9
+ prompt?: string
7
10
  firstFrameUrl?: string
8
11
  lastFrameUrl?: string
9
12
  refImageUrls?: readonly string[]
@@ -37,6 +40,19 @@ const cleanList = (xs?: readonly string[]): string[] =>
37
40
  * reference_image_urls (after the user's own images, so their @Image ordinals do
38
41
  * not shift) and named in a doctrine-compliant prompt suffix.
39
42
  */
43
+ /** True when the prompt ALREADY binds an image as the first/opening frame —
44
+ * e.g. the gvp overlap transport's colon-position directive ("use @image_1
45
+ * as the first frame, it is the last keyframe of @video_1"). Field finding
46
+ * (2026-07-20): the first-frame directive only works adjacent to the extend
47
+ * colon; a duplicate sentence at the END of the prompt (this resolver's
48
+ * default position) dilutes it back into coin-flip behavior — so when the
49
+ * prompt carries its own binding, the suffix is suppressed (the frame image
50
+ * itself still rides the reference list). */
51
+ export function promptBindsFirstFrame(prompt: string | undefined): boolean {
52
+ if (!prompt) return false
53
+ return /@image_\d+\s+as\s+the\s+(first|opening)\s*(\(first\))?\s*frame/i.test(prompt)
54
+ }
55
+
40
56
  export function resolveSeedance2Inputs(args: Seedance2InputsArgs): Seedance2InputsResult {
41
57
  const firstFrameUrl = clean(args.firstFrameUrl)
42
58
  const lastFrameUrl = clean(args.lastFrameUrl)
@@ -76,7 +92,10 @@ export function resolveSeedance2Inputs(args: Seedance2InputsArgs): Seedance2Inpu
76
92
  if (lastFrameUrl) { referenceImageUrls.push(lastFrameUrl); lastOrdinal = referenceImageUrls.length }
77
93
 
78
94
  let promptSuffix = ""
79
- if (firstOrdinal > 0 && lastOrdinal > 0) {
95
+ const suppressFrameSentence = promptBindsFirstFrame(args.prompt)
96
+ if (suppressFrameSentence && firstOrdinal > 0 && lastOrdinal === 0) {
97
+ // The prompt already binds the first frame at its own (working) position.
98
+ } else if (firstOrdinal > 0 && lastOrdinal > 0) {
80
99
  // Combined sentence — REF_BINDING.frame() emits a single-frame sentence, so use
81
100
  // REF_BINDING.ordinal() for each ordinal inline to keep the combined wording AND
82
101
  // route both ordinals through the single swap-point.