simple question as stated in the subject: is it possible to define rules inside a script? I'm asking this because I'm using a script to create a template into "Company Home" -> "Data Dictionary" -> "Space Templates" folder, so that I can pack up everything for an easier deploy on other machines.
There is no API to do this no. However, in theory it is possible as rules (like 99% of all objects and concepts in Alfresco) are defined as nodes, aspects and properties. Therefore you would need to work out how rules are defined as aspects/properties and create the same objects against your space nodes. It will probably take some investigation!
Actually that's not quite true. You need the createAssoc() method support added to the JavaScript API in Alfresco 2.1 to create the associations between the rule/action nodes. So the answer is "yes you can in Alfresco 2.1, but it's still quite involved" I expect we will wire up specific method to call the RuleService from JavaScript in a later release also.