* Add macro autocomplete for free text inputs
Implements macro autocomplete (`{{`) for textareas and input fields marked with `data-macros` attribute. Extracts shared autocomplete logic into MacroAutoCompleteHelper.js for consistency between slash command and free text contexts. Includes MutationObserver for dynamic element initialization and supports variable shorthands, operators, flags, and scoped macro closing tags.
* fix annoying circular dependency again
* Add `data-macros` attribute to enable macro autocomplete on text inputs
Enables macro autocomplete (`{{`) for various textareas and input fields throughout the UI by adding the `data-macros` attribute. Includes context template fields, instruct mode sequences, character/persona descriptions, world info content, and other prompt-related inputs. Also ensures the attribute is preserved when expanding editors and creating world info entries.
* Allow macro autocomplete in editing messages
Enables macro autocomplete (`{{`) when editing messages by adding the `data-macros` attribute to the dynamically created edit textarea element.
* Add autocomplete visibility setting support for macro autocomplete
Respects the global STScript autocomplete visibility setting (`power_user.stscript.autocomplete.state`) for macro autocomplete in free text inputs. When set to "Input length > 1", macro autocomplete only activates after typing `{{` plus at least 2 characters. Also adds a tooltip to the visibility setting explaining it applies to both slash commands and macros.
* Fix unclosed div tag in STScript autocomplete visibility setting
Closes the `<div>` tag that was incorrectly left open in the autocomplete visibility setting markup.
* Add setting to control macro autocomplete visibility in non-expanded fields
Introduces a new `showInAllMacroFields` setting that controls whether macro autocomplete appears in all macro-enabled fields or only in expanded editors and when pressing Ctrl+Space. Also adds `data-macros-autocomplete` attribute support with `always` and `hide` modes for per-field override. When the setting is off, autocomplete only shows in expanded editors (which now get `data-macros-autocomplete="always"`) and the completion
* Add `data-macros-autocomplete-style` attribute to control macro autocomplete popup size
Introduces a new `data-macros-autocomplete-style` attribute with `small` (33vw, max 700px) and `expanded` (default chat width) modes to control macro autocomplete popup dimensions. The `small` style is now the default for inline fields, while `expanded` is used for expanded editors and prompt manager. Also refactors `getAutocompleteMode` to return `DEFAULT` instead of `null` and adds corresponding `getAutocompleteStyle` helper
* Fix autocomplete details panel alignment when list is constrained by viewport edge
Adjusts the details panel position to align with the actual autocomplete list position when the list is constrained by the right edge of the viewport. Previously, the panel would position based on cursor location even when the list was pushed left, causing misalignment. Now checks if the list's actual position differs from the calculated position (with 5px tolerance) and uses the list's position instead.
* Guard autocomplete details panel alignment check with `isReplaceable` condition
Prevents attempting to read the autocomplete list's bounding rect when the list is not visible. The alignment adjustment for viewport-constrained lists now only runs when `isReplaceable` is true, avoiding potential errors when the list DOM is not rendered.
* Fix macro autocomplete cursor detection to handle nested macros correctly
Updates `findMacroAtCursor` to track nesting depth when searching for opening `{{` and closing `}}` braces. Previously would incorrectly stop at the first brace pair encountered in either direction, breaking autocomplete when cursor was inside nested macros like `{{getvar::{{getvar::name}}}}`. Now properly skips over nested macro boundaries by incrementing/decrementing depth counters until finding the matching braces at depth
* gief me my comments back (and fixes, that were missed)
- Added detailed JSDoc comments to all exported functions explaining parameters, return types, and behavior
- Added inline comments throughout functions explaining logic flow, edge cases, and implementation details
- Documented parser-based vs regex-based unclosed scope detection approaches
- Clarified variable shorthand autocomplete logic including operator filtering, context display, and priority
* refactor(macros): freeze MACRO_AUTOCOMPLETE_MODE and MACRO_AUTOCOMPLETE_STYLE enums
* feat(macros): explicitly set `makeSelectable` flag for non-insertable autocomplete options
- Set `makeSelectable = true` for variable shorthand options in {{if}} conditions (already insertable)
- Set `makeSelectable = false` for already-typed operators in variable shorthand autocomplete
- Set `makeSelectable = false` for already-typed flags in macro autocomplete
- Set `makeSelectable = false` for non-selectable closing block flags when no unclosed scopes exist
- Set `makeSelectable = false` for sc
* refactor(macros): consolidate typedef imports in MacroAutoCompleteHelper
- Fixed typo in MacroDefinition typedef import (removed extra `/` from JSDoc comment)
- Replaced long-form typedef imports with short-form aliases for MacroAutoCompleteContext and MacroDefinition
- Improved code consistency by using imported typedefs throughout function signatures
* refactor(autocomplete): select first selectable item as default instead of always first item
- Extracted default item selection logic into `selectDefaultItem()` method
- Changed default selection to prioritize first selectable item over first item in list
- Falls back to last item when no selectable items exist (preserves context for info-only options)
- Added JSDoc documentation explaining selection behavior
* feat(macros): make already-typed variable names non-selectable in autocomplete
- Set `makeSelectable = false` for variable name options that match the currently typed name
- Set empty `valueProvider` for matched variables to prevent re-insertion
- Prevents redundant selection of variables that are already fully typed in the input
* feat(macros): add value context autocomplete option for variable shorthand operators
- Created `VariableValueContextAutoCompleteOption` class to display context about expected values
- Shows operator name, symbol, and description when typing variable shorthand values
- Displays currently typed value and completion hint
- Non-selectable option (context only) with priority 4
- Added to variable shorthand autocomplete when operator is typed and value is being entered
* fix lint
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
- Update `getFreeWorldName()` to accept optional `worldName` parameter and `stripIndex` option
- Add JSDoc documentation for `getFreeWorldName()` parameters and return value
- Modify world duplicate handler to pass current world name to `getFreeWorldName()`
- Strip existing numbered suffix from base name before generating new numbered name
- Default to "New World" when no world name is provided
- Make "New World" translatable
* create and export updateWorldInfoSettings
* Add WorldInfoSettings type and refactor updateWorldInfoSettings function
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* chore: Add WORLDINFO_SCAN_DONE event with mutable state for extensions
* Fix incorrect scan state reference in world info recursion logic
* Fix typo in world info scan state property name: 'sucessful' → 'successful'
(am i stupid)
* feat: allow create new world books via /getpersonabook and /getcharbook
Refactor character world info management into dedicated functions
Extract character world assignment logic from UI handlers into reusable functions
Add support for automatic lorebook creation in slash commands
Improve code maintainability by centralizing world info operations
* refactor: update boolean enum provider from onOffToggle to trueFalse in world info commands
* fix: improve world info name uniqueness check using getUniqueName utility
* Unset current persona WI on file deletion
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* feat: add outlet prompt support for world info entries
* feat: add outlet name field with autocomplete for world info entries
* feat: add outlet entries for world info support to WI parsing
* feat: add tooltip and validation for WI outlet name entries
* Trim macro outlet name
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor: consolidate WI injection cleanup and fix strict equality comparison
* fix: update outlet macro regex pattern to use double colon delimiter
* fix: replace carriage returns with newlines in WI entry outlet tooltip
* fix: add null checks and array validation for WI outlet entries handling
* feat: add outletName field to world info entry definition schema (supports /setwientryfield command)
* fix: add outletName field to export of character lore books
* do not remove outlet name on position change, but filter out for auto complete
* Match WI extensions field name
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* outlet name being used in char WI import too
* docs: add outlet macro documentation to help template
* be explicit about risu/novel/agnai wi not supporting outlets
* Inject A/N and TC sysprompt after populating outlets
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* Update UpdateAndStart.bat
* feat(client): desktop version uses select2 to search, filter, and select world info to edit
feat(client): styles for select2 to separate items and highlight
* fix(client): more aligned with current select2
fix(client): removed unecessary functions and styles
* Update WI editor layout
* Add min-width for WI sort and search
* Adjust control styling
* Update option creation logic
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* feature: ignore budget switch
The budget cap default at 25% is a big gotcha at the start of chats, as a person may assume that a constant lore book entry will always be present, no matter what. This pull request adds a budget ignore switch which ignores the budget cap and includes the lore book entry even if it would exceed the budget cap.
* Move the toggle to entry details
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* Add generation type triggers to world info
* Simplify includes check
* Refactor getEntryField validation and default value handling
* Remove invalid attribute
* Check for a valid trigger
* Add support for characterFilter to getEntryField and setEntryField
* No more conflicts between lint and autoformat
* Fix array type default values hint
* Properly capitalize name
* Fix search by name
---------
Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
* remove unnecessary arg passage from WI helper funcs
* remove some typescript red from script.js
* hide in shame
* Add JSDoc to helper functions
* Fix fav_ch_checked not updating
* Move PWA mode match to firstLoadInit
* Fix more type errors and deprecations
* Fix the rest of type errors in script.js
---------
Co-authored-by: RossAscends <124905043+RossAscends@users.noreply.github.com>
Results in a slight delay depending on entries visible via pagination (about 2s for 50 visible entries), but I added a pleasant fade transition to make it feel organic.