note here means any row without leading bullet or trailing : ?
The blue-framed triangles are part of the row ? (or a parenthesising device for this post ?)
root in the TaskPaper scripting model is, I think, a virtual (textless) node – the parent of all (visible) top-level outline items – here you are thinking of a document which has only one top-level row ?
if a row is matched for deletion, and has further rows indented under it, are they deleted too ?
If no one else gets there first, I’ll take a look this evening, but generally, I think:
You should be able to parameterise some arbitrary matching predicate – perhaps expressed in terms of an item path – to experiment with defining the first matching row in different ways.
I personally happen to be a bit superstitious and avoidant about sharing scripts which delete, so there again, it may make sense to parameterise the effect applied to the first matching row (if any), and offer you a choice of different effects (including deletion) to uncomment and experiment with
Saving will need to be triggered outside the TaskPaper JSContext, and is well within reach of JXA, but probably worth suspending until you are absolutely sure that the deletions aren’t going to overshoot or otherwise surprise …