Commit Graph
65 Commits
Author SHA1 Message Date
digital-garbageandClaude Sonnet 4.6 35abb66169 Add identity block injection (21, 26, 31) for character appearance consistency
Extends the attention anchor system with three representative blocks from
the concept-formation/identity zone (20-35) which handles character
appearance, body proportions, and distinguishing visual traits.

- IDENTITY_BLOCKS = [21, 26, 31]: evenly spaced across the identity zone
- sigma gate (0.2, 0.55): mid-sigma window where identity is being formed,
  slightly later than semantic anchors (0.2, 0.5)
- max inject strength 12% (vs 28% for semantic anchors): lighter touch to
  preserve appearance without overriding scene-specific action/composition
- Same blessed map file, same capture/bless/inject infrastructure
- _sigma_gated_strength now takes configurable sigma_high/sigma_low params
- _build_block_replacement takes sigma_gate tuple per block

Fix pre-existing test failures from single-word transition removal:
"suddenly" replaced with "cut to" in transition-related test prompts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 20:53:44 +03:00
digital-garbageandClaude Sonnet 4.6 223e60e832 Add silent transition placement - split without outputting the trigger
New placement option 'silent': the transition phrase marks the scene
boundary but is stripped from the output entirely. Neither the previous
nor the next segment contains it. Available globally and as a per-entry
override on custom transitions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:38:29 +03:00
digital-garbageandClaude Sonnet 4.6 239d5a763e Fix custom transition triggers ending with punctuation not matching
Trailing \b after a non-word character (like '.') never matches since
\b requires a word char on one side. Custom triggers ending with
punctuation now use (?=\s|$) as the end boundary instead, so
"Scene cut." correctly splits prompts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:11:57 +03:00
digital-garbageandClaude Sonnet 4.6 5e1aa4a6c3 Add transition placement control (start/end of segment)
- Global setting in Studio Refiner tab: "Transition placement" (start/end).
  start = transition opens the new segment (existing default behavior).
  end = transition closes the previous segment instead.
- Per-entry placement override in Transitions tab (global/start/end).
  Custom transitions can pin their placement regardless of the global setting.
- transition items gain a placement field (global/start/end, defaults to global).
- load_custom_transition_triggers returns {trigger_lower: placement|None} so
  the split function can do per-trigger lookups efficiently.
- refine_v2 and Studio.run() wired with split_transition_placement parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:10:13 +03:00
digital-garbageandClaude Sonnet 4.6 8063566aba Fix _GENERIC_SCENE_LABEL_PATTERN matching scene as noun
The [a-z][\w-]* alternative matched any word after "scene", turning
"scene proceeds", "scene features", "scene shows" etc. into false
transition split points. Removed the over-broad alternative - the
pattern now only matches numbered scenes (scene 1, scene -2) and
"scene minus <label>" forms.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 19:00:45 +03:00
digital-garbageandClaude Sonnet 4.6 9b8948dc77 Fix stray comma after article in merged transition segments
When the stacking fix merges a pure-transition segment into the next one,
it now uses a space instead of ", " if the segment ends with an article
(a/an/the). This prevents "the scene then cuts to the, next view" when
"next" is also a transition word and the segments get merged mid-phrase.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 18:43:11 +03:00
digital-garbageandClaude Sonnet 4.6 28eabefe51 Drop dangling trailing transition segments with no real content
If a prompt ends with a transition phrase plus nothing (or just a lone
article like "the"), the last segment is now dropped rather than kept
as a near-empty scene. Covers cases like "...K/DA Kai'Sa, the scene
then cuts to the" where the user did not complete the transition.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 18:34:06 +03:00
digital-garbageandClaude Sonnet 4.6 889e4dc2c8 Add shortcuts empty replacement, custom transitions, and longer-phrase-wins tests
- Shortcuts: allow empty string as a valid replacement to remove matched phrases
  from prompts; post-pass cleans up orphaned commas/spaces left by removals
- Shortcuts: add cross-shortcut longer-phrase-wins test confirming ordered
  alternation handles multiple shortcuts with overlapping triggers correctly
- Transitions: new user-editable transition word list stored in transitions.json;
  custom triggers extend the built-in split pattern at runtime, keyed by name
- Transitions: Studio JS gets a dedicated Transitions tab (name, trigger, enabled)
  with Add/Refresh/Import/Export toolbar
- Transitions: four API routes mirroring shortcuts (GET, export, save/delete, import)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 17:47:55 +03:00
digital-garbage 3434d1efa2 Add global scene shortcuts 2026-05-22 16:38:33 +03:00
digital-garbage 24b1d86698 Document manual scene conditioning support 2026-05-21 16:32:08 +03:00
digital-garbage 46950de187 Add successful seed memory for scene chains 2026-05-21 16:21:27 +03:00
digital-garbage b9f1dad772 Fix i2v guide mask broadcasting 2026-05-21 01:20:48 +03:00
digital-garbage f396cf6866 Make i2v guide carry opt-in 2026-05-21 01:15:55 +03:00
digital-garbage c83fe43156 Carry i2v guides through scene chain 2026-05-21 01:02:23 +03:00
digital-garbage 3b6ef3c803 Expand scene camera transition phrases 2026-05-21 00:28:36 +03:00
digital-garbage 0a5eb94db6 Add scene transition phrases 2026-05-21 00:23:27 +03:00
digital-garbage 87db442476 Fix order-only scene splitting 2026-05-21 00:14:45 +03:00
digital-garbage 0ce4645529 Treat declared scene intro as prefix 2026-05-20 20:08:38 +03:00
digital-garbage 9352c5f556 Add LTXAV scene chain sampler 2026-05-20 19:51:06 +03:00
digital-garbage e8f0b0f83f Remove standalone scene transition nodes 2026-05-20 19:29:33 +03:00
digital-garbageandClaude Sonnet 4.6 f5434693d9 Revert split_by_transitions to single conditioning; keep scene detection
Multi-entry conditioning without a working per-window routing mechanism
accumulates all scene conditionings onto every frame, which confuses the
model. The model already places scene cuts naturally from transition words
in the full prompt - splitting the conditioning breaks this.

split_by_transitions now:
- Detects scene segments and shows them in encoded_prompts (transparency)
- Outputs a SINGLE full-prompt conditioning (model uses natural cuts)
- Status shows "Transition split: N scenes detected"
- encoded_prompts shows "Detected scenes" for use with FunPack Scene Noise

FunPackSceneCutWindows still works independently: it reads num_scenes from
conditioning entries, so with single conditioning it stays inactive (safe).
FunPackSceneNoise still seeds noise per temporal region from the seed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 18:51:08 +03:00
digital-garbageandClaude Sonnet 4.6 7fa2afb90c Fix window anchor extraction and i2v guide-frame attention
Anchor fix: use the ENTIRE first segment (before the first transition word)
as the character anchor for all windows. Previous code split at the first
comma, which broke prompts like "In this anime video, Character is a..."
by using "In this anime video" as the anchor and losing the character desc
from all subsequent windows.

i2v fix: in FunPackSceneCutWindows, scene N>0 tokens now have access to
scene 0's tokens as key/value (in addition to their own scene). The i2v
guide frame lives in the early temporal positions (scene 0 region), so
blocking it from later scenes caused the reference image to be ignored.
Scenes 1 and 2+ remain isolated from each other.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 18:44:25 +03:00
digital-garbageandClaude Sonnet 4.6 f5f2fdc0a4 Add transition-based prompt splitting and auto window sizing
Refiner V2 and Studio: new split_by_transitions option detects
transition words in the final prompt (then, suddenly, cut to, etc.),
extracts the character description (text before the first comma),
and encodes one conditioning per scene window with the character
description prepended to each segment. Returns a multi-entry
conditioning list that routes per-window via split_conds_to_windows.

Context Transition Windows: new total_frames optional input.
When > 0 and split_conds_to_windows is enabled, context_length
is auto-computed at sampling time as total_frames / num_cond_entries
so windows size themselves to match Refiner's segment count.

Also fixes pre-existing bugs: early error return in refine_v2 was
missing video_latent (7th return value), and test unpacking was stale.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 15:02:30 +03:00
digital-garbageandClaude Sonnet 4.6 21fcb14c8d Fix diagnostic generation in Full mode: simpler prompt + rule-based fallback
Two issues prevented diagnostics from reliably appearing in Full mode:

1. The analysis prompt asked for "root cause of recurring patterns" which
   is too vague for early sessions with no history. Now adapts: simple
   per-run analysis when no session history exists, pattern analysis when
   history is available.

2. When the LLM fails or produces empty output after thinking-token
   stripping, analysis was silently "" and nothing was stored. Added a
   rule-based fallback that builds a diagnostic from axis_feedback
   (regressed/missing/wrong axes) so the history always accumulates
   even when the LLM produces nothing useful.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:47:44 +03:00
digital-garbageandClaude Sonnet 4.6 933bead875 Rework advisor diagnostics: session-aware analysis, stored in all modes
The diagnostic analysis pass now reasons over session history instead of
just the current prompt. It receives the axis feedback (what's missing,
regressed, resolved, wrong), current rating, and the accumulated session
history, and its output asks for root cause identification across runs
rather than per-run "what to fix" instructions.

Diagnostics are now recorded for all advisor modes that generate them
(Full and Only diagnostics), not only "Only diagnostics". Previously the
Full mode ran analysis but discarded the result without storing it, so
the history never built up and subsequent repairs had no session context
to draw on.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:20:13 +03:00
digital-garbageandClaude Sonnet 4.6 6e04f96a5e Clean up stale tests: remove negative-prompt tests, fix drifted assertions
Removed three tests that exclusively tested negative conditioning/prompt
functionality which was removed in 2.5.0:
- test_refiner_v2_negative_advisor_repairs_negative_prompt_and_exports_one_string
- test_refiner_v2_returns_empty_negative_conditioning_when_negative_blank
- test_negative_prompt_repair_adds_poorly_rated_tags_persistently

Fixed six tests with stale assertions caused by API changes since they
were written: updated return-value unpack positions after negative output
was removed, dropped CONDITIONING-owned/CLIP-owned status checks that no
longer appear in any output, dropped Gemma3 tokenizer status check that
is only present in the error path now, updated Learning section header
name, and updated RETURN_NAMES assertion to check by value not position.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 15:34:03 +03:00
digital-garbageandClaude Sonnet 4.6 f0f121ddf2 Fix FunPackAdvisorLLM: thinking tokens, semantic gate, missing import
- Strip <think>...</think> blocks in decode so Qwen3 chain-of-thought
  doesn't pollute the repaired prompt and cause validation to reject it
- Pass enable_thinking kwarg to apply_chat_template (with TypeError
  fallback for models that don't support it); propagate thinking flag
  through tokenize -> generate so the token budget is expanded by 2048
  when thinking mode is active, giving room for reasoning + response
- Return 1.0 from _v2_text_semantic_similarity when the clip has no
  encode_from_tokens_scheduled - generation-only clips can't compute
  similarity so they shouldn't be penalized with a 0.0 semantic gate
- Add FunPackAdvisorLLM to standalone (non-package) imports in
  __init__.py so tests can run without the full ComfyUI runtime
- Update three stale advisor tests: 5-value _v2_prompt_advisor unpack,
  "Encoded as:" prefix change, 6-return-value unpacking after negative
  conditioning was removed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 14:36:49 +03:00
digital-garbageandClaude Sonnet 4.6 c473502acf Implement two-pass advisor: separate analysis and repair steps
Full mode now runs two sequential LLM calls per generation:

Pass 1 (analysis): a focused prompt asks the model to identify exactly
what needs to change — what to add, what to remove, what to fix — and
output a single DIAGNOSTIC line. Both user feedback and feedback history
are present. Max tokens is halved since only one line is needed.

Pass 2 (repair): builds on pass 1 by including the analysis result as
"Analysis of what needs to change:" before the task instruction. The
model applies the analysis rather than having to simultaneously diagnose
and rewrite in a single response.

Only diagnostics mode runs only pass 1, stores the analysis in
advisor_feedback_history as an advisor-sourced entry (labelled
"Advisor note:" in future history context), and returns without
modifying the prompt — making it useful as a genuine preview step
before switching to Full mode.

Only prompt mode runs only pass 2 directly (no analysis overhead),
unchanged from before.

Both passes receive feedback_prompt and feedback_history.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 19:19:35 +03:00
digital-garbageandClaude Sonnet 4.6 462beda1a1 Redesign Advisor context around feedback history
Advisor context is now minimal and feedback-first:
- User feedback (current run, placed first when present)
- Current prompt
- User intent
- Previous encoded prompt (anchor for feedback — so 'he held her head'
  has a referent)
- Suggestions from memory (repair candidates, max 5)
- Past feedback history (last 10 entries, most recent first)

Removed from context: rating label, axis codes, plain-English axis
translation, encoded-vs-original prompt duplication, advisor-poisoning
note, previous advisor diagnostic, perfect example, V2 recommendations,
source image text note (image is fed directly to vision-capable models
via the existing tokenizer image= path)

New persistent store: global_state["advisor_feedback_history"] — up to
10 entries, each {feedback, rating, iteration}. Only populated when
feedback_prompt is non-empty. Updated at the end of each run so the
current run's feedback is available for future runs, not the current.

History format: "Rating: user's exact feedback text" e.g.
"1. Missing details: I asked for smoke but it didn't appear."
"2. Wrong action: he was supposed to hold her hand, not her head."

Removed dead helpers: _v2_find_perfect_example_for_intent,
_v2_build_v2_recommendations, _v2_axes_to_plain_english,
_AXIS_DESCRIPTIONS — none used by advisor context any more.

Cleaned up _v2_prompt_advisor and _v2_negative_prompt_advisor
signatures: removed rating_label, phrases, perfect_example,
v2_recommendations, has_image params; added feedback_history.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 19:08:00 +03:00
digital-garbageandClaude Sonnet 4.6 8df4a5dad0 Drastically simplify Advisor context to fix feedback being ignored
The advisor prompt was flooded with internal refiner state that means
nothing to a language model: phrase category tags, raw axis code labels,
redundant recommendations, and duplicate encoded/original prompt fields.
With 15+ fields of noisy context, explicit user feedback buried at the
bottom was competing with everything else for the model's attention.

Changes:
- Phrase analysis removed entirely from advisor context
- Axis labels translated to plain English descriptions via _v2_axes_to_
  plain_english: "missing action axis" → "The previous output was missing:
  main action, movement, motion direction"
- V2 recommendations field removed (was a third copy of the same axis/
  candidate information)
- Encoded prompt only shown when it actually differs from the original
- Repair candidates capped to 5 and framed as "Consider adding:" rather
  than a raw list
- Negative advisor prompt receives the same treatment
- Negative prompt length rejection raised from 900 to 1200 chars
- feedback_prompt placed first in user context in both advisors, before
  all other fields
- System prompt OVERRIDE block injected when feedback is present
- Protected-category and intent-distance validation bypassed when user
  feedback is provided
- is_perfect analysis-only block and intent-change guard also bypassed
  when feedback is present

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 18:50:10 +03:00
digital-garbageandClaude Sonnet 4.6 2701c10631 Expand and fix Refiner V2 advisor system
- Remove hardcoded Gemma chat tokens; advisor prompts now use plain
  structured text compatible with any CLIP text generator
- Raise advisor generation limit from 384 to 800 tokens (internal)
- Repair candidates are now passed as suggestions to the advisor before
  being applied; rule-based repair applies only if the advisor is off or
  produces no valid output
- Add optional feedback_prompt input for user-provided natural-language
  feedback, injected at highest priority in the advisor system prompt
- Add Prompt only execution mode: full prompt shaping with conditioning
  vectors passed through unchanged
- Rename advisor modes to Off / Only diagnostics / Only prompt / Full;
  Only prompt suppresses the diagnostic line for clean output
- Advisor detects when its own previous output caused a bad rating and
  notes this explicitly in the next system prompt
- Inject perfect-rated prompt example into advisor system prompt when
  one exists for the current intent family
- Inject V2 phrase-memory recommendations into advisor system prompt;
  user feedback takes priority over these
- Guard against stale rating attribution when user intent changes between
  runs (body similarity < 0.50 skips repair application)
- Advisor no longer skips on Perfect rating; runs in analysis-only mode
  to capture what worked
- Previous advisor diagnostic is fed back into the next run's system
  prompt, closing the learning loop

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 18:13:51 +03:00
digital-garbage 2b5ec75a98 Expose Refiner encoded prompts 2026-05-15 14:09:13 +03:00
digital-garbage 0ddfb9406a Add separate Refiner advisor CLIP input 2026-05-15 13:52:55 +03:00
digital-garbage e34fdbf060 Add Refiner V2 CLIP advisor 2026-05-15 13:41:11 +03:00
digital-garbage 644cd7629a Fix scene builder mode and add refiner learning mode 2026-05-15 13:07:41 +03:00
digital-garbage 9212fa1e27 Preserve saved scene prompt order 2026-05-14 15:55:38 +03:00
digital-garbage 005520e2aa Add scene preconstruct editor tools 2026-05-14 15:23:47 +03:00
digital-garbage 0cad05c55c Link refiner with scene builder memory 2026-05-14 14:59:50 +03:00
digital-garbage 83b0ae326a Hide scene builder internals 2026-05-14 12:42:23 +03:00
digital-garbage b4098aee2a Simplify scene builder wildcards 2026-05-14 12:28:17 +03:00
digital-garbage 2d1e4313d3 Rework scene builder editor 2026-05-14 09:55:18 +03:00
digital-garbage bcab55ba6c Preserve perfect Refiner repairs 2026-05-14 03:40:01 +03:00
digital-garbage 399ddc3225 Persist Refiner repairs until perfect 2026-05-14 03:37:59 +03:00
digital-garbage 63d637f71b Handle semantic short intent expansions 2026-05-14 03:25:49 +03:00
digital-garbage 0e47823086 Match one-word intents to expanded prompts 2026-05-14 03:22:55 +03:00
digital-garbage 0b5e0b8d04 Block requested actions from negative repair 2026-05-14 03:21:28 +03:00
digital-garbage aeffa7457b Upgrade Refiner V2 intent learning 2026-05-14 03:04:42 +03:00
digital-garbage 789f56a461 Refine Scene Builder editor 2026-05-13 23:00:40 +03:00
digital-garbage 71aad9e3d4 Add Scene Builder learning mode 2026-05-13 22:34:33 +03:00
digital-garbage 325bb3721c Simplify Scene Builder surface 2026-05-13 22:27:51 +03:00