Skip to content

fix(clipboard): detect a script folder as XMSC, not XMSS - #94

Open
anwespanda wants to merge 1 commit into
petrowsky:mainfrom
anwespanda:fix/clipboard-script-folder-class
Open

anwespanda wants to merge 1 commit into
petrowsky:mainfrom
anwespanda:fix/clipboard-script-folder-class

Conversation

@anwespanda

Copy link
Copy Markdown

Problem

The documented way to install the companion scripts into a host solution does not work.

QUICKSTART.md → "Option B — Install via clipboard":

python3 agent/scripts/clipboard.py write filemaker/agentic-fm.xml
Clipboard ready → filemaker/agentic-fm.xml as XMSS (Script Steps)

It should be XMSC (Script). Pasting the XMSS clipboard into the Script Workspace does not install the scripts — confirmed by testing both classes into a scratch file: XMSS does nothing, --class XMSC produces the agentic-fm folder with all 15 scripts as documented.

Cause

A script folder exported from the Script Workspace wraps its <Script> elements in a <Group>:

<fmxmlsnippet type="FMObjectList">
  <Group groupCollapsed="False" includeInMenu="False" id="1" name="agentic-fm">
    <Script includeInMenu="False" ... id="2" name="Get agentic-fm path">
      <Step enable="True" id="89" name="# (comment)">

Group is not in XML_ELEMENT_TO_CLASS, so the XML-parse branch of detect_class_from_xml() returns None:

cls = XML_ELEMENT_TO_CLASS.get(root[0].tag)   # root[0].tag == 'Group' → None

Execution then falls through to the regex scan, which iterates the mapping in insertion order — 'Step' first. filemaker/agentic-fm.xml contains 344 nested <Step> elements, so it matches XMSS and returns.

The file holds 15 <Script> elements, and the module's own table already declares 'Script': 'XMSC'.

Fix

Map 'Group' to XMSC, and give it priority over 'Step' in the regex fallback so a truncated script-folder snippet is still classified correctly.

This mirrors the precedence already in place for CustomMenu / CustomMenuSet, which exists for exactly the same reason — menu XML also nests <Step> inside action blocks.

'Script' is deliberately not given the same regex precedence. A steps-only snippet containing a Perform Script step holds <Script id="0" name="..."/>, and promoting Script above Step would misclassify that as XMSC. Only <Group> is unambiguous — it never appears inside a step.

Verification

Every snippet shape in the repo, before and after:

Input Before After
script folder (filemaker/agentic-fm.xml) XMSS ❌ XMSC ✅
custom function (filemaker/context.xml) XMFN XMFN
steps only XMSS XMSS
steps incl. Perform Script XMSS XMSS
bare <Script>, no <Group> XMSC XMSC
malformed script folder XMSS ❌ XMSC ✅
malformed steps only XMSS XMSS

I also checked that <Group> does not appear as the root child of any other snippet type in agent/snippet_examples/, agent/library/ or filemaker/ — only the script-folder file.

Notes

Related to #52, which touches the same install path — that report notes the CLI route working, which I'd guess means the bundled .fmp12 (Option A) was used rather than Option B.

🤖 Generated with Claude Code

`clipboard.py write filemaker/agentic-fm.xml` loads the companion scripts
onto the clipboard as XMSS (Script Steps). Pasting that into the Script
Workspace does not work — nothing is installed.

That is the documented install path for a host solution: QUICKSTART's
"Option B — Install via clipboard" is exactly this command.

Cause: a script folder exported from the Script Workspace wraps its
<Script> elements in a <Group>:

    <fmxmlsnippet type="FMObjectList">
      <Group groupCollapsed="False" includeInMenu="False" id="1" name="agentic-fm">
        <Script ... name="Get agentic-fm path">
          <Step .../>

`Group` is not in XML_ELEMENT_TO_CLASS, so the XML-parse branch of
detect_class_from_xml() returns None and execution falls through to the
regex scan. That loop iterates the mapping in insertion order, where
'Step' comes first, and filemaker/agentic-fm.xml contains 344 nested
<Step> elements — so it matches XMSS. The file holds 15 <Script>
elements, and the module's own table already declares 'Script': 'XMSC'.

Fix: map 'Group' to XMSC, and give it priority over 'Step' in the regex
fallback so a truncated script-folder snippet is still classified
correctly. This mirrors the existing CustomMenu/CustomMenuSet precedence,
which exists for the same reason — menu XML also nests <Step>.

'Script' is deliberately NOT given the same regex precedence: a
steps-only snippet containing a Perform Script step holds
<Script id="0" name="..."/>, and promoting it would misclassify that as
XMSC. Only <Group> is unambiguous.

Verified against every snippet shape in the repo:

  script folder                  -> XMSC  (was XMSS)
  custom function                -> XMFN  unchanged
  steps only                     -> XMSS  unchanged
  steps incl. Perform Script     -> XMSS  unchanged
  bare <Script>, no Group        -> XMSC  unchanged
  malformed script folder        -> XMSC  (was XMSS)
  malformed steps only           -> XMSS  unchanged

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant