Stencils actually go into the database, it's only when defining custom scripts that these scripts are stored in the content store. The SCRIPT_FILE table has a foreign key to the STENCIL_SET, and a store_id, that is the id from the content store. The reason is performance: streaming a file from disk is quicker than via the database.
But no, there is no way to distinguish that in the code, the ContentStorage only takes in an Inputstream and has no knowledge about the calling method.
About the ECM integration: this is for
1) finding documents in Alfresco (or Google Drive/Box if you enable it) and attaching them to a task
2) publishing documents from task attachments / document generation tasks to Alfresco.
You enable Alfresco in the properties, but configure the Alfresco repository in the 'Tenant > Alfresco Repositories' tab