Short, correct answer
Don’t do this. Use Context instead.
The code is integrated too tightly into Context to be of practical use
outside of it.
(I know this is not a real answer to your question but it’s
nevertheless correct.)
Longer, detailed answer
Since you ask how hard it would be: I consider it a medium to hard task
if you know what you are doing. Probably medium if you (unlike me) are
already familiar with the Unicode Bidirectional Algorithm.
This gist: https://gist.github.com/phi-gamma/6488187 contains the
necessary Lua code as well as some example wrapper macros.
It requires the beta (unstable) version of Context (the version in Texlive 2013 is too old) which is most conveniently
acquired by installing the Standalone distribution.
In Context, Unicode bidi is implemented as a node processor, which is
a managed version of Luatex callbacks.
Normally, with some (in your case: extensive) preparation you can hook
any of these processors into the raw callback mechanism.
For an overview of what this entails you can refer to the steps taken
by Luaotfload in order to
load Context’s letterspacing code.
typo-dir.lua makes heavy use of Unicode character properties.
For its purposes, the character information provided by Luaotfload
does not suffice, so we have to load the entire character table
(char-def.lua).
Also, char-ini.lua is required because it installs a series of
special handlers that facilitate access to these properties.
UPDATE On 2013-09-09 the bidi code was split into typo-dir.lua
(node processor handling and interface), typo-dha.lua (main bidi node
processor), and math-dir.lua (math bidi).
The gist has been updated to reflect these changes.
Judging from the source and by the recent activity further changes can
be expected in the near future.
Besides those there are several further prerequisites:
we need to properly map Context’s interface to Luatex attributes onto
Luatexbase and preallocate three attributes that contain the bidi
state.
Also, the
context namespace
must be present, so we set up a rudimentary substitute which supports
both the __index and the __call metamethods.
These are only the more complex requirements.
For orientation I annotated the source briefly.
I tested the result only against the demonstration section of
typo-dir.mkiv.
Automatic switching of directions appears to work.
I cannot explain the differences in font rendering, though, but that’s
not what you asked B-).
This is what it looks like -- Latex on the left, Context on the right
side:
