Saturday, 14 February 2026

PROMPT: Calculator (MVPL Platform) extension for a footer bar to hold further buttons


✅ MVPL SAFE FOOTER BAR BUTTON EXTENSION GENERATOR PROMPT


SYSTEM ROLE
You are Codex.

You are generating a fully compliant MVPL calculator extension that adds a new function button to a shared footer function bar, while safely creating the footer bar if it does not already exist, without violating MVPL extension safety rules or creating fragile dependencies.


GLOBAL OBJECTIVE

Generate a new MVPL extension script named:


atbutton.js

This extension must:

• Add a button labeled @
• Use the shared footer function bar if it exists
• Safely create its own compatible footer bar if it does not exist
• Fully comply with MVPL lifecycle, safety, and isolation rules


OUTPUT REQUIREMENTS

Generate EXACTLY ONE FILE:


atbutton.js

Return ONLY JavaScript source code.

Do NOT include explanations outside code comments.


GLOBAL TECHNICAL CONSTRAINTS

• Must be standalone JavaScript
• Must run offline
• Must not require external libraries
• Must not modify calculator core globals
• Must interact ONLY through extensionAPI
• Must follow MVPL lifecycle model
• Must preserve backward compatibility
• Must fail safely if extensionAPI functions are unavailable
• Must prevent duplicate UI creation
• Must preserve profile state isolation
• Must not disrupt calculator layout or core keypad


EXTENSION NAME


AtFunctionButtonExtension


ARCHITECTURAL PURPOSE

This extension represents a footer function bar client extension.

It must:

• Attach a button to a shared footer function bar if one exists
• Create a compatible fallback footer bar if none exists
• Never assume another extension provides infrastructure
• Never remove or interfere with UI created by other extensions


SHARED FOOTER BAR CONTRACT

The shared container must be identified by:


mvpl-footer-function-bar

If this container exists:

• Use it

If this container does NOT exist:

• Create a compatible container
• Insert container into the
footer zone
• Follow MVPL safe infrastructure ownership rules


FALLBACK INFRASTRUCTURE RULES

If this extension creates the footer bar:

• It owns that instance
• It may remove the bar ONLY if it created it
• It must NOT remove the bar if it was created by another extension


BUTTON REQUIREMENTS

Button label:


@


BUTTON FUNCTIONAL BEHAVIOR

When pressed:

• Read current display value
• Convert to numeric
• Divide the value by 1 (placeholder logic)
• Display result
• Update extension state


CUSTOMISATION REQUIREMENT

The placeholder logic MUST be isolated inside:


placeholderFunction(value)

Developers must be able to safely modify this function later.


PROFILE BEHAVIOR

This extension must:

• Be allowed in all profiles
• Maintain profile-isolated state
• Persist state separately for each profile


STATE SCHEMA REQUIREMENTS


stateSchema: {

  lastUsed: null

}

State must be accessed using:


api.state("AtFunctionButtonExtension")


MVPL LIFECYCLE REQUIREMENTS

The extension MUST implement:


onInit

onProfileSwitch

onLayoutChange

onDestroy


LIFECYCLE BEHAVIOR


onInit(api, state)

• Verify extensionAPI availability
• Locate existing footer bar
• Create fallback footer bar if needed
• Create @ button
• Insert button into footer bar
• Prevent duplicate insertion


onProfileSwitch(api, state)

• Ensure button exists
• Ensure footer bar exists
• Prevent duplicate UI


onLayoutChange(api, state)

• Verify container integrity
• Recreate fallback container if necessary
• Prevent duplication


onDestroy(api, state)

• Remove only the @ button
• Remove fallback footer bar ONLY if created by this extension AND bar is empty
• Preserve stored state


EXTENSION ECOSYSTEM SAFETY RULES

The extension MUST:

• Never assume another extension manages the footer bar
• Never remove buttons created by other extensions
• Only remove UI elements that it owns
• Allow other extensions to coexist inside the footer bar
• Continue functioning if other extensions modify the bar
• Detect existing container using ID rather than assumptions


UI DESIGN REQUIREMENTS

The fallback footer bar must:

• Use flexbox layout
• Match calculator button appearance
• Maintain touch-friendly sizing
• Respect calculator visual theme
• Avoid styling conflicts


ERROR HANDLING REQUIREMENTS

The extension MUST:

• Display "Error" if display value is invalid
• Display
"Error" if placeholder function returns invalid numeric result
• Fail safely without throwing unhandled errors
• Never interrupt calculator core behavior


DUPLICATE PREVENTION REQUIREMENTS

The extension MUST:

• Check for container existence before creating it
• Track button reference internally
• Avoid attaching duplicate event listeners
• Remain safe across repeated lifecycle triggers


DOCUMENTATION REQUIREMENTS (INSIDE CODE COMMENTS)

Include teaching comments explaining:

• MVPL lifecycle handling
• Shared UI fallback infrastructure design
• Ownership tracking of fallback footer bar
• Profile state namespacing
• Placeholder function customization instructions
• Why the @ symbol was chosen
• How extensions should safely coexist inside shared UI


TESTING INSTRUCTIONS (INSIDE CODE COMMENTS)

Include instructions describing how to:

  1. Load atbutton.js into index.html
  2. Enable extension in profile enabledExtensions arrays
  3. Verify @ button appears in footer
  4. Verify fallback footer bar is created if missing
  5. Verify fallback bar is not duplicated if shared bar exists
  6. Switch profiles and confirm state isolation
  7. Disable extension and confirm safe UI removal
  8. Confirm calculator arithmetic remains correct
  9. Confirm compatibility with FooterFunctionBarExtension if both are loaded


ACCEPTANCE CRITERIA

Extension is complete ONLY if:

✔ @ button appears in footer bar
✔ Uses existing footer bar when present
✔ Creates fallback bar when missing
✔ Removes only owned UI
✔ Placeholder function divides value by 1
✔ Footer bar is not duplicated
✔ State persists per profile
✔ Calculator core remains stable
✔ Extension coexists with other footer bar extensions


FINAL AUTHORITATIVE RULE

If any instruction conflicts:

Preserve calculator core stability
Preserve backward compatibility
Preserve profile state isolation
Preserve extension lifecycle correctness


OUTPUT FORMAT (STRICT)

Return EXACTLY:


----- atbutton.js -----

<full code>

No summaries
No explanations
Only code output


Friday, 13 February 2026

PROMPT: Calculator (MVPL Platform) prompt for a custom extension

CUSTOM EXTENSION GENERATION PROMPT


MVPL Extension Generator — CustomExtension


SYSTEM ROLE

You are Codex.

You are generating a fully compliant MVPL calculator extension that integrates with an already existing MVPL Modular Calculator Core (index.html is already implemented and loaded in the environment).


GLOBAL OBJECTIVE

Generate a new MVPL extension script named:

custom.js

This extension must fully comply with the MVPL extension architecture, lifecycle system, and safety model already implemented in the core platform.


OUTPUT REQUIREMENTS

Generate EXACTLY ONE FILE:

custom.js

Do NOT include explanations outside code comments.

Return ONLY the JavaScript source code.


GLOBAL TECHNICAL CONSTRAINTS

• Must be standalone JavaScript
• Must run offline
• Must not require external libraries
• Must not modify core globals
• Must interact ONLY through extensionAPI
• Must follow MVPL lifecycle model
• Must preserve backward compatibility
• Must be safe if lifecycle hooks are missing in other extensions
• Must prevent duplicate UI insertion
• Must preserve profile state isolation


MVPL EXTENSION CONTRACT

The extension MUST use the manifest structure:


{

  name: string,

  version: string,

  description: string,

  dependencies?: string[],

  priority?: number,

  stateSchema?: object,

  onInit(api, state),

  onProfileSwitch(api, state),

  onLayoutChange(api, state),

  onDestroy(api, state)

}

Extension must be registered using:


registerExtension(manifest)


EXTENSION NAME

CustomExtension


FUNCTIONAL BEHAVIOR

The extension must:

• Add a button labeled K
• When pressed, compute a custom function of the current display value
• Initially, the function MUST return the value unchanged
• The function logic must be clearly isolated and documented so developers can easily edit it later inside custom.js


PROFILE RESTRICTION

The K button MUST:

• Only appear in the education profile
• Be removed automatically when switching to any other profile
• Only execute its function when the education profile is active
• Remain inactive or hidden otherwise


UI INSERTION RULES

• Must insert using extension slot system
• Must use slot-extension-2
• Must NOT replace or reposition core calculator buttons
• Must prevent duplicate button insertion


ERROR HANDLING REQUIREMENTS

The extension MUST:

• Display "Error" if display value is invalid numeric input
• Display "Error" if division by zero occurs within future custom functions
• Fail safely without crashing the calculator core


STATE SCHEMA REQUIREMENTS

The extension must implement a namespaced state model using:


stateSchema: {

  lastUsed: null

}

State must be stored and retrieved through:


api.state("CustomExtension")

State must persist per profile and MUST NOT leak across profiles.


LIFECYCLE REQUIREMENTS

CustomExtension MUST implement:

onInit
onProfileSwitch
onLayoutChange
onDestroy

Lifecycle behavior must follow MVPL rules:

onInit:
• Create button
• Insert button only if education profile is active

onProfileSwitch:
• Insert or remove button based on profile

onLayoutChange:
• Must remain safe and not duplicate UI

onDestroy:
• Must remove UI components
• Must preserve stored state


SAFETY REQUIREMENTS

The extension MUST:

• Never modify calculator core variables
• Never assume slot exists without checking
• Safely remove UI elements when destroyed
• Avoid duplicate event bindings
• Fail gracefully if extensionAPI functions are unavailable


DOCUMENTATION REQUIREMENTS (INSIDE CODE COMMENTS)

Include clear teaching comments explaining:

• MVPL extension lifecycle
• Profile restriction logic
• Slot keypad insertion rules
• Namespaced state handling
• How developers can later customize the function logic


ACCEPTANCE CRITERIA

The extension is considered complete ONLY if:

✔ K button appears only in education profile
✔ Button disappears when profile changes
✔ Button inserts using slot-extension-2
✔ Extension uses lifecycle hooks correctly
✔ State persists per profile
✔ Calculator core remains stable
✔ Button executes identity function initially
✔ Error handling works
✔ No duplicate UI insertion occurs


TESTING INSTRUCTIONS (INSIDE CODE COMMENTS)

In index.html:

• Edit the profile for ‘education’, adding CustomExtension to enabledExtensions, and just before the </body> end tag add <script src="custom.js"></script>

Include instructions describing how to:

• Load custom.js alongside index.html
• Switch to education profile
• Verify K button visibility
• Verify button removal when switching profiles
• Confirm state persistence
• Confirm error handling
• Confirm calculator arithmetic remains correct


FINAL AUTHORITATIVE RULE

If any instruction conflicts:

Preserve calculator core stability
Preserve backward compatibility
Preserve profile state isolation
Preserve lifecycle correctness


OUTPUT FORMAT (STRICT)

Return EXACTLY:


----- custom.js -----

<full code>

No summaries
No explanations
Only code output