If you want the UXP script, you cannot get the path automatically as you say. It will be roughly the same code on this page.
If it is a UXP plugin, you can specify the path as you like, so it can load an atn file in the same folder as the document you have open, for example.
const { localFileSystem } = require('uxp').storage ;
const { action, app, core } = require('photoshop') ;
const main = async () => {
try {
await core.executeAsModal(
async (control) => {
const doc = app.activeDocument ;
if(doc == null) {
app.showAlert(`Please execute with the document open.`) ;
return ;
}
const docPath = doc.path ;
if(docPath === '') {
app.showAlert(`Please save the document and then execute it.`) ;
return ;
}
// get atn file in same folder as active document
const parentPath = path.dirname(docPath) ;
const atnName = 'set1.atn' ;
const atnPath = path.join(parentPath, atnName) ;
const atnEntry = await localFileSystem.getEntryWithUrl(atnPath) ;
// load an action set with the same name if it does not exist
const actionSetName = path.basename(atnPath, '.atn') ;
const whetherExistsActionSet = action.validateReference({_ref: 'actionSet', _name: actionSetName}) ;
if(whetherExistsActionSet) {
await app.showAlert(`No action set was loaded since it already exists.`) ;
return ;
} else {
await app.open(atnEntry) ;
await app.showAlert(`ActionSet '${actionSetName}' has been loaded.`) ;
}
},
{'commandName': 'Load Action Set'}
) ;
} catch(e) {
await app.showAlert(e) ;
}
} ;